static int
display_callback (struct Dlg_head *h, int id, int Msg)
{
#ifndef HAVE_X
    switch (Msg){
    case DLG_DRAW:
	attrset (COLOR_NORMAL);
	dlg_erase (h);
	draw_box (h, 1, 2, h->lines - 2, h->cols - 4);

	attrset (COLOR_HOT_NORMAL);
	dlg_move (h, 1, (h->cols - strlen(display_title))/2);
	addstr (display_title);
	attrset (COLOR_NORMAL);
	break;

    case DLG_UNFOCUS:
	if((WRadio *) h->current->widget == my_radio){
	    assign_text (status, displays_status [my_radio->sel]);
	    input_set_point (status, 0);
	}
	break;
	
    case DLG_KEY:
	if (id == '\n'){
	    if((WRadio *) h->current->widget == my_radio){
		assign_text (status, displays_status [my_radio->sel]);
		dlg_stop (h);
		break;
	    }
	    
	    if ((WInput *) h->current->widget == user){
		h->ret_value = B_USER + 6;
		dlg_stop (h);
		break;
	    }
	
	    if ((WInput *) h->current->widget == status){
		h->ret_value = B_USER + 7;
		dlg_stop (h);
		break;
	    }
	}

	if (tolower(id) == user_hotkey && h->current->widget != (Widget *) user
	    && h->current->widget != (Widget *) status){
	    my_radio->sel = 3;
	    dlg_select_widget (h, my_radio); /* force redraw */
	    dlg_select_widget (h, user);
	    return MSG_HANDLED;
	}
    }
#endif    
    return MSG_NOT_HANDLED;
}
Пример #2
0
static cb_ret_t
display_callback (struct Dlg_head *h, dlg_msg_t msg, int parm)
{
    switch (msg) {
    case DLG_UNFOCUS:
	if (dlg_widget_active (my_radio)) {
	    assign_text (status, displays_status[my_radio->sel]);
	    input_set_point (status, 0);
	}
	return MSG_HANDLED;

    case DLG_KEY:
	if (parm == '\n') {
	    if (dlg_widget_active (my_radio)) {
		assign_text (status, displays_status[my_radio->sel]);
		dlg_stop (h);
		return MSG_HANDLED;
	    }

	    if (dlg_widget_active (user)) {
		h->ret_value = B_USER + 6;
		dlg_stop (h);
		return MSG_HANDLED;
	    }

	    if (dlg_widget_active (status)) {
		h->ret_value = B_USER + 7;
		dlg_stop (h);
		return MSG_HANDLED;
	    }
	}

	if (tolower (parm) == user_hotkey && dlg_widget_active (user)
	    && dlg_widget_active (status)) {
	    my_radio->sel = 3;
	    dlg_select_widget (h, my_radio);	/* force redraw */
	    dlg_select_widget (h, user);
	    return MSG_HANDLED;
	}
	return MSG_NOT_HANDLED;

    default:
	return default_dlg_callback (h, msg, parm);
    }
}
Пример #3
0
static void
display_init (int radio_sel, char *init_text, int _check_status,
	      char **_status)
{
    static const char *display_title = N_("Listing mode");
    static int i18n_displays_flag;
    const char *user_mini_status = _("user &Mini status");
    const char *ok_button = _("&OK");
    const char *cancel_button = _("&Cancel");

    static int button_start = 30;

    displays_status = _status;

    if (!i18n_displays_flag) {
	int i, l, maxlen = 0;
	const char *cp;

	display_title = _(display_title);
	for (i = 0; i < LIST_TYPES; i++) {
	    displays[i] = _(displays[i]);
	    if ((l = strlen (displays[i])) > maxlen)
		maxlen = l;
	}

	i = strlen (ok_button) + 5;
	l = strlen (cancel_button) + 3;
	l = max (i, l);

	i = maxlen + l + 16;
	if (i > DISPLAY_X)
	    DISPLAY_X = i;

	i = strlen (user_mini_status) + 13;
	if (i > DISPLAY_X)
	    DISPLAY_X = i;

	i = strlen (display_title) + 10;
	if (i > DISPLAY_X)
	    DISPLAY_X = i;

	button_start = DISPLAY_X - l - 5;

	/* get hotkey of user-defined format string */
	cp = strchr (displays[USER_TYPE], '&');
	if (cp != NULL && *++cp != '\0')
	    user_hotkey = tolower (*cp);

	i18n_displays_flag = 1;
    }
    dd = create_dlg (0, 0, DISPLAY_Y, DISPLAY_X, dialog_colors,
		     display_callback, "[Listing Mode...]", display_title,
		     DLG_CENTER | DLG_REVERSE);

    add_widget (dd,
		button_new (4, button_start, B_CANCEL, NORMAL_BUTTON,
			    cancel_button, 0));

    add_widget (dd,
		button_new (3, button_start, B_ENTER, DEFPUSH_BUTTON,
			    ok_button, 0));

    status =
	input_new (10, 9, INPUT_COLOR, DISPLAY_X - 14, _status[radio_sel],
		   "mini-input");
    add_widget (dd, status);
    input_set_point (status, 0);

    check_status =
	check_new (9, 5, _check_status, user_mini_status);
    add_widget (dd, check_status);

    user =
	input_new (7, 9, INPUT_COLOR, DISPLAY_X - 14, init_text,
		   "user-fmt-input");
    add_widget (dd, user);
    input_set_point (user, 0);

    my_radio = radio_new (3, 5, LIST_TYPES, displays, 1);
    my_radio->sel = my_radio->pos = current_mode;
    add_widget (dd, my_radio);
}
static void
display_init (int radio_sel, char *init_text,
	      int _check_status, char ** _status)
{
	char* user_mini_status = _("user &Mini status");
	char* ok_button = _("&Ok");
	char* cancel_button = _("&Cancel");
	
	static int button_start = 30;
	
    displays_status = _status;

    if (!i18n_displays_flag){
		int i, l, maxlen = 0;
		char* cp;

 		display_title = _(display_title);
		for (i = 0; i < LIST_TYPES; i++)
		{
		    displays [i] = _(displays [i]);
			if ((l = strlen(displays [i])) > maxlen)
				maxlen = l;
		}

		i = strlen (ok_button) + 5;
		l = strlen (cancel_button) + 3;
		l = max(i, l);

		i = maxlen + l + 16;
		if (i > DISPLAY_X)
			DISPLAY_X = i;

		i = strlen (user_mini_status) + 13;
		if (i > DISPLAY_X)
			DISPLAY_X = i;
			
		i = strlen (display_title) + 8;
		if (i > DISPLAY_X)
			DISPLAY_X = i;

		button_start = DISPLAY_X - l - 5;
		
		/* get hotkey of user-defined format string */
		cp = strchr(displays[LIST_TYPES-1],'&');
		if (cp != NULL && *++cp != '\0')
			user_hotkey = tolower(*cp);

        i18n_displays_flag = 1;
    }
    dd = create_dlg (0, 0, DISPLAY_Y, DISPLAY_X, dialog_colors,
		     display_callback, "[Left and Right Menus]", "display",
		     DLG_CENTER | DLG_GRID);

    x_set_dialog_title (dd, _("Listing mode"));
    add_widgetl (dd,
        button_new (4, button_start, B_CANCEL, 
			NORMAL_BUTTON, cancel_button, 0, 0, "cancel-button"),
	XV_WLAY_RIGHTOF);

    add_widgetl (dd,
		button_new (3, button_start, B_ENTER, 
			DEFPUSH_BUTTON, ok_button, 0, 0, "ok-button"),
	 XV_WLAY_CENTERROW);

    status = input_new (10, 9, INPUT_COLOR, DISPLAY_X-14, _status [radio_sel], "mini-input");
    add_widgetl (dd, status, XV_WLAY_RIGHTDOWN);
    input_set_point (status, 0);

    check_status = check_new (9, 5, _check_status, user_mini_status, "mini-status");
    add_widgetl (dd, check_status, XV_WLAY_NEXTROW);
    
    user = input_new  (7, 9, INPUT_COLOR, DISPLAY_X-14, init_text, "user-fmt-input");
    add_widgetl (dd, user, XV_WLAY_RIGHTDOWN);
    input_set_point (user, 0);

#ifdef PORT_HAS_ICON_VIEW
    my_radio = radio_new (3, 5, LIST_TYPES, displays, 1, "radio");
#else
    my_radio = radio_new (3, 5, LIST_TYPES-1, displays, 1, "radio");
#endif
    my_radio->sel = my_radio->pos = current_mode;
    add_widgetl (dd, my_radio, XV_WLAY_BELOWCLOSE);
}
Пример #5
0
static Dlg_head *
display_init (int radio_sel, char *init_text, int _check_status,
	      char **_status)
{
    int dlg_width = 48, dlg_height = 15;
    Dlg_head *dd;

    /* Controls whether the array strings have been translated */
    const char *displays [LIST_TYPES] =
    {
	N_("&Full file list"),
	N_("&Brief file list"),
	N_("&Long file list"),
	N_("&User defined:")
    };

    /* Index in displays[] for "user defined" */
    const int user_type_idx = 3;

    const char *display_title = N_("Listing mode");
    const char *user_mini_status = N_("user &Mini status");
    const char *ok_name = N_("&OK");
    const char *cancel_name = N_("&Cancel");

    WButton *ok_button, *cancel_button;

    {
	int i, maxlen = 0;
	const char *cp;
	int ok_len, cancel_len;

#ifdef ENABLE_NLS
	display_title = _(display_title);
	user_mini_status = _(user_mini_status);
	ok_name = _(ok_name);
	cancel_name = _(cancel_name);

	for (i = 0; i < LIST_TYPES; i++)
	    displays[i] = _(displays[i]);
#endif

	/* get hotkey of user-defined format string */
	cp = strchr (displays[user_type_idx], '&');
	if (cp != NULL && *++cp != '\0')
	    display_user_hotkey = g_ascii_tolower (*cp);

	/* xpos will be fixed later */
	ok_button = button_new (dlg_height - 3, 0, B_ENTER, DEFPUSH_BUTTON, ok_name, 0);
	ok_len = button_get_len (ok_button);
	cancel_button = button_new (dlg_height - 3, 0, B_CANCEL, NORMAL_BUTTON, cancel_name, 0);
	cancel_len = button_get_len (cancel_button);

	dlg_width = max (dlg_width, str_term_width1 (display_title) + 10);
	/* calculate max width of radiobutons */
	for (i = 0; i < LIST_TYPES; i++)
	    maxlen = max (maxlen, str_term_width1 (displays[i]));
	dlg_width = max (dlg_width, maxlen);
	dlg_width = max (dlg_width, str_term_width1 (user_mini_status) + 13);

	/* buttons */
	dlg_width = max (dlg_width, ok_len + cancel_len + 8);
	ok_button->widget.x = dlg_width/3 - ok_len/2;
	cancel_button->widget.x = dlg_width * 2/3 - cancel_len/2;
    }

    displays_status = _status;

    dd = create_dlg (0, 0, dlg_height, dlg_width, dialog_colors,
		     display_callback, "[Listing Mode...]", display_title,
		     DLG_CENTER | DLG_REVERSE);

    add_widget (dd, cancel_button);
    add_widget (dd, ok_button);

    display_mini_status = input_new (10, 8, INPUT_COLOR, dlg_width - 12, _status[radio_sel],
			    "mini-input", INPUT_COMPLETE_DEFAULT);
    add_widget (dd, display_mini_status);
    input_set_point (display_mini_status, 0);

    display_check_status = check_new (9, 4, _check_status, user_mini_status);
    add_widget (dd, display_check_status);

    display_user_format = input_new (7, 8, INPUT_COLOR, dlg_width - 12, init_text,
			"user-fmt-input", INPUT_COMPLETE_DEFAULT);
    add_widget (dd, display_user_format);
    input_set_point (display_user_format, 0);

    display_radio = radio_new (3, 4, LIST_TYPES, displays);
    display_radio->sel = display_radio->pos = radio_sel;
    add_widget (dd, display_radio);

    return dd;
}