Merge branch '1555_help_buttonbar_draw'

* 1555_help_buttonbar_draw:
  Ticket #1555: draw buttonbar of help dialog.
This commit is contained in:
Andrew Borodin 2009-08-24 09:21:55 +04:00
commit 6ff684c8ce
4 changed files with 58 additions and 47 deletions

View File

@ -585,15 +585,21 @@ static void prev_node_cmd (void *vp)
history_ptr--;
if (history_ptr < 0)
history_ptr = HISTORY_SIZE-1;
help_callback (h, DLG_DRAW, 0);
}
static cb_ret_t
md_callback (Widget *w, widget_msg_t msg, int parm)
{
(void) w;
return default_proc (msg, parm);
switch (msg) {
case WIDGET_RESIZED:
w->lines = help_lines;
return MSG_HANDLED;
default:
return default_proc (msg, parm);
}
}
static Widget *
@ -642,7 +648,7 @@ help_handle_key (struct Dlg_head *h, int c)
case KEY_LEFT:
prev_node_cmd (h);
break;
case '\n':
case KEY_RIGHT:
/* follow link */
@ -656,7 +662,7 @@ help_handle_key (struct Dlg_head *h, int c)
history_ptr--;
if (history_ptr < 0)
history_ptr = HISTORY_SIZE-1;
currentpoint = history [history_ptr].page;
selected_item = history [history_ptr].link;
#endif
@ -668,7 +674,7 @@ help_handle_key (struct Dlg_head *h, int c)
}
selected_item = NULL;
break;
case KEY_DOWN:
case '\t':
new_item = select_next_link (selected_item);
@ -685,7 +691,7 @@ help_handle_key (struct Dlg_head *h, int c)
else
selected_item = NULL;
break;
case KEY_UP:
case ALT ('\t'):
/* select previous link */
@ -702,7 +708,7 @@ help_handle_key (struct Dlg_head *h, int c)
}
}
break;
case 'n':
/* Next node */
new_item = currentpoint;
@ -718,7 +724,7 @@ help_handle_key (struct Dlg_head *h, int c)
}
}
break;
case 'p':
/* Previous node */
new_item = currentpoint;
@ -732,11 +738,11 @@ help_handle_key (struct Dlg_head *h, int c)
currentpoint = new_item + 2;
selected_item = NULL;
break;
case 'c':
help_index_cmd (h);
break;
case ESC_CHAR:
case XCTRL('g'):
dlg_stop (h);
@ -744,16 +750,24 @@ help_handle_key (struct Dlg_head *h, int c)
default:
return MSG_NOT_HANDLED;
}
help_callback (h, DLG_DRAW, 0);
return MSG_HANDLED;
}
static cb_ret_t
help_callback (struct Dlg_head *h, dlg_msg_t msg, int parm)
help_callback (Dlg_head *h, dlg_msg_t msg, int parm)
{
WButtonBar *bb;
switch (msg) {
case DLG_RESIZE:
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 (&bb->widget, LINES - 1, 0, 1, COLS);
return MSG_HANDLED;
case DLG_DRAW:
common_dialog_repaint (h);
help_show (h, currentpoint);
@ -826,7 +840,7 @@ interactive_display (const char *filename, const char *node)
translate_file (filedata);
g_free (filedata);
if (!data)
return;
@ -862,8 +876,8 @@ interactive_display (const char *filename, const char *node)
}
help_bar = buttonbar_new (1);
((Widget *) help_bar)->y -= whelp->y;
((Widget *) help_bar)->x -= whelp->x;
help_bar->widget.y -= whelp->y;
help_bar->widget.x -= whelp->x;
md = mousedispatch_new (1, 1, help_lines, HELP_WINDOW_WIDTH - 2);

View File

@ -676,7 +676,7 @@ setup_panels (void)
widget_set_size (&the_prompt->widget, LINES, COLS, 0, 0);
}
widget_set_size ((Widget *) the_bar, LINES - 1, 0, keybar_visible, COLS);
widget_set_size (&the_bar->widget, LINES - 1, 0, keybar_visible, COLS);
buttonbar_set_visible (the_bar, keybar_visible);
/* Output window */

View File

@ -55,24 +55,6 @@
#define HISTORY_FILE_NAME ".mc/history"
/* number of bttons in buttonbar */
#define BUTTONBAR_LABELS_NUM 10
struct WButtonBar {
Widget widget;
int visible; /* Is it visible? */
int btn_width; /* width of one button */
struct {
char *text;
enum { BBFUNC_NONE, BBFUNC_VOID, BBFUNC_PTR } tag;
union {
voidfn fn_void;
buttonbarfn fn_ptr;
} u;
void *data;
} labels [BUTTONBAR_LABELS_NUM];
};
static void
widget_selectcolor (Widget *w, gboolean focused, gboolean hotkey)
{
@ -2584,12 +2566,14 @@ buttonbar_event (Gpm_Event *event, void *data)
WButtonBar *
buttonbar_new (int visible)
{
WButtonBar *bb;
int i;
WButtonBar *bb = g_new (WButtonBar, 1);
init_widget (&bb->widget, LINES-1, 0, 1, COLS,
bb = g_new0 (WButtonBar, 1);
init_widget (&bb->widget, LINES - 1, 0, 1, COLS,
buttonbar_callback, buttonbar_event);
bb->widget.pos_flags = WPOS_KEEP_HORZ | WPOS_KEEP_BOTTOM;
bb->visible = visible;
for (i = 0; i < BUTTONBAR_LABELS_NUM; i++){
bb->labels[i].text = NULL;

View File

@ -158,6 +158,27 @@ struct WListbox {
int cursor_x, cursor_y; /* Cache the values */
};
/* number of bttons in buttonbar */
#define BUTTONBAR_LABELS_NUM 10
typedef void (*voidfn)(void);
typedef void (*buttonbarfn)(void *);
typedef struct WButtonBar {
Widget widget;
int visible; /* Is it visible? */
int btn_width; /* width of one button */
struct {
char *text;
enum { BBFUNC_NONE, BBFUNC_VOID, BBFUNC_PTR } tag;
union {
voidfn fn_void;
buttonbarfn fn_ptr;
} u;
void *data;
} labels [BUTTONBAR_LABELS_NUM];
} WButtonBar;
typedef struct WGroupbox {
Widget widget;
char *title;
@ -176,6 +197,7 @@ WInput *input_new (int y, int x, int color, int len, const char *text, const
WLabel *label_new (int y, int x, const char *text);
WGauge *gauge_new (int y, int x, int shown, int max, int current);
WListbox *listbox_new (int y, int x, int height, int width, lcback callback);
WButtonBar *buttonbar_new (int visible);
WGroupbox *groupbox_new (int y, int x, int height, int width, const char *title);
/* Input lines */
@ -229,16 +251,7 @@ enum append_pos {
char *listbox_add_item (WListbox *l, enum append_pos pos, int
hotkey, const char *text, void *data);
/* Hintbar routines */
/* Buttonbar */
typedef void (*voidfn)(void);
typedef void (*buttonbarfn)(void *);
typedef struct WButtonBar WButtonBar;
WButtonBar *buttonbar_new (int visible);
WButtonBar *find_buttonbar (Dlg_head *h);
void buttonbar_clear_label (Dlg_head *, int idx);
void buttonbar_set_label (Dlg_head *, int index, const char *text, voidfn);