static cb_ret_t help_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *data) { WDialog *h = DIALOG (w); switch (msg) { case MSG_RESIZE: { WButtonBar *bb; help_lines = MIN (LINES - 4, MAX (2 * LINES / 3, 18)); dlg_set_size (h, help_lines + 4, HELP_WINDOW_WIDTH + 4); bb = find_buttonbar (h); widget_set_size (WIDGET (bb), LINES - 1, 0, 1, COLS); return MSG_HANDLED; } case MSG_DRAW: dlg_default_repaint (h); help_show (h, currentpoint); return MSG_HANDLED; case MSG_KEY: return help_handle_key (h, parm); case MSG_ACTION: /* Handle shortcuts and buttonbar. */ return help_execute_cmd (parm); default: return dlg_default_callback (w, sender, msg, parm, data); } }
static cb_ret_t help_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *data) { WDialog *h = DIALOG (w); switch (msg) { case MSG_RESIZE: { WButtonBar *bb; help_lines = min (LINES - 4, max (2 * LINES / 3, 18)); dlg_set_size (h, help_lines + 4, HELP_WINDOW_WIDTH + 4); bb = find_buttonbar (h); widget_set_size (WIDGET (bb), LINES - 1, 0, 1, COLS); return MSG_HANDLED; } case MSG_DRAW: dlg_default_repaint (h); help_show (h, currentpoint); return MSG_HANDLED; case MSG_KEY: return help_handle_key (h, parm); case MSG_ACTION: /* shortcut */ if (sender == NULL) return help_execute_cmd (parm); /* message from buttonbar */ if (sender == WIDGET (find_buttonbar (h))) { if (data != NULL) return send_message (data, NULL, MSG_ACTION, parm, NULL); return help_execute_cmd (parm); } return MSG_NOT_HANDLED; default: return dlg_default_callback (w, sender, msg, parm, data); } }
static void chown_refresh (WDialog * h) { const int y = 3; const int x = 7 + GW * 2; dlg_default_repaint (h); tty_setcolor (COLOR_NORMAL); widget_move (h, y + 0, x); tty_print_string (_("Name")); widget_move (h, y + 2, x); tty_print_string (_("Owner name")); widget_move (h, y + 4, x); tty_print_string (_("Group name")); widget_move (h, y + 6, x); tty_print_string (_("Size")); widget_move (h, y + 8, x); tty_print_string (_("Permission")); }
cb_ret_t dlg_default_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *data) { WDialog *h = DIALOG (w); (void) sender; (void) parm; (void) data; switch (msg) { case MSG_DRAW: if (h->color != NULL) { dlg_default_repaint (h); return MSG_HANDLED; } return MSG_NOT_HANDLED; case MSG_IDLE: /* we don't want endless loop */ widget_idle (w, FALSE); return MSG_HANDLED; case MSG_RESIZE: /* this is default resizing mechanism */ /* the main idea of this code is to resize dialog according to flags (if any of flags require automatic resizing, like WPOS_CENTER, end after that reposition controls in dialog according to flags of widget) */ dlg_set_size (h, w->lines, w->cols); return MSG_HANDLED; default: break; } return MSG_NOT_HANDLED; }
static void chown_refresh (void) { dlg_default_repaint (ch_dlg); tty_setcolor (COLOR_NORMAL); widget_move (ch_dlg, BY - 1, 8); tty_print_string (_("owner")); widget_move (ch_dlg, BY - 1, 16); tty_print_string (_("group")); widget_move (ch_dlg, BY - 1, 24); tty_print_string (_("other")); widget_move (ch_dlg, BY - 1, 35); tty_print_string (_("owner")); widget_move (ch_dlg, BY - 1, 53); tty_print_string (_("group")); widget_move (ch_dlg, BY + 1, 3); tty_print_string (_("Flag")); print_flags (); }
static cb_ret_t layout_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *data) { WDialog *h = DIALOG (w); switch (msg) { case MSG_DRAW: /* When repainting the whole dialog (e.g. with C-l) we have to update everything */ dlg_default_repaint (h); old_output_lines = -1; update_split (h); if (old_output_lines != _output_lines) { old_output_lines = _output_lines; tty_setcolor (mc_global.tty.console_flag != '\0' ? COLOR_NORMAL : DISABLED_COLOR); widget_move (h, 9, 5); tty_print_string (output_lines_label); widget_move (h, 9, 5 + 3 + output_lines_label_len); tty_printf ("%02d", _output_lines); } return MSG_HANDLED; case MSG_POST_KEY: _menubar_visible = check_options[1].widget->state & C_BOOL; _command_prompt = (check_options[2].widget->state & C_BOOL) != 0; _keybar_visible = check_options[3].widget->state & C_BOOL; _message_visible = check_options[4].widget->state & C_BOOL; _xterm_title = (check_options[5].widget->state & C_BOOL) != 0; _free_space = check_options[6].widget->state & C_BOOL; if (mc_global.tty.console_flag != '\0') { int minimum; if (_output_lines < 0) _output_lines = 0; height = LINES - _keybar_visible - (_command_prompt ? 1 : 0) - _menubar_visible - _output_lines - _message_visible; minimum = MINHEIGHT * (1 + panels_layout.horizontal_split); if (height < minimum) { _output_lines -= minimum - height; height = minimum; } } else height = LINES - _keybar_visible - (_command_prompt ? 1 : 0) - _menubar_visible - _output_lines - _message_visible; if (old_output_lines != _output_lines) { old_output_lines = _output_lines; tty_setcolor (mc_global.tty.console_flag != '\0' ? COLOR_NORMAL : DISABLED_COLOR); widget_move (h, 9, 5 + 3 + output_lines_label_len); tty_printf ("%02d", _output_lines); } return MSG_HANDLED; case MSG_ACTION: if (sender == WIDGET (radio_widget)) { if (panels_layout.horizontal_split != radio_widget->sel) { int eq; panels_layout.horizontal_split = radio_widget->sel; if (panels_layout.horizontal_split) { eq = panels_layout.horizontal_equal; if (eq) panels_layout.top_panel_size = height / 2; } else { eq = panels_layout.vertical_equal; if (eq) panels_layout.left_panel_size = COLS / 2; } widget_disable (WIDGET (bleft_widget), eq); widget_disable (WIDGET (bright_widget), eq); update_split (h); layout_change (); do_refresh (); } else update_split (h); return MSG_HANDLED; } if (sender == WIDGET (check_options[0].widget)) { int eq; if (panels_layout.horizontal_split) { panels_layout.horizontal_equal = check_options[0].widget->state & C_BOOL; eq = panels_layout.horizontal_equal; } else { panels_layout.vertical_equal = check_options[0].widget->state & C_BOOL; eq = panels_layout.vertical_equal; } widget_disable (WIDGET (bleft_widget), eq); widget_disable (WIDGET (bright_widget), eq); update_split (h); layout_change (); do_refresh (); return MSG_HANDLED; } return MSG_NOT_HANDLED; default: return dlg_default_callback (w, sender, msg, parm, data); } }