WButton: remove WButton::selected. Use WST_FOCUSED instead.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
Andrew Borodin 2016-06-12 20:43:21 +03:00
parent ad166313a4
commit e1a2e8f8ec
2 changed files with 40 additions and 40 deletions

View File

@ -120,48 +120,50 @@ button_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *
case MSG_UNFOCUS:
case MSG_FOCUS:
case MSG_DRAW:
if (msg == MSG_UNFOCUS)
b->selected = FALSE;
else if (msg == MSG_FOCUS)
b->selected = TRUE;
widget_selectcolor (w, b->selected, FALSE);
widget_move (w, 0, 0);
switch (b->flags)
{
case DEFPUSH_BUTTON:
tty_print_string ("[< ");
break;
case NORMAL_BUTTON:
tty_print_string ("[ ");
break;
case NARROW_BUTTON:
tty_print_string ("[");
break;
case HIDDEN_BUTTON:
default:
gboolean focused;
focused = widget_get_state (w, WST_FOCUSED);
widget_selectcolor (w, focused, FALSE);
widget_move (w, 0, 0);
switch (b->flags)
{
case DEFPUSH_BUTTON:
tty_print_string ("[< ");
break;
case NORMAL_BUTTON:
tty_print_string ("[ ");
break;
case NARROW_BUTTON:
tty_print_string ("[");
break;
case HIDDEN_BUTTON:
default:
return MSG_HANDLED;
}
hotkey_draw (w, b->text, focused);
switch (b->flags)
{
case DEFPUSH_BUTTON:
tty_print_string (" >]");
break;
case NORMAL_BUTTON:
tty_print_string (" ]");
break;
case NARROW_BUTTON:
tty_print_string ("]");
break;
default:
break;
}
return MSG_HANDLED;
}
hotkey_draw (w, b->text, b->selected);
switch (b->flags)
{
case DEFPUSH_BUTTON:
tty_print_string (" >]");
break;
case NORMAL_BUTTON:
tty_print_string (" ]");
break;
case NARROW_BUTTON:
tty_print_string ("]");
break;
default:
break;
}
return MSG_HANDLED;
case MSG_DESTROY:
release_hotkey (b->text);
return MSG_HANDLED;
@ -212,7 +214,6 @@ button_new (int y, int x, int action, button_flags_t flags, const char *text, bc
b->text = parse_hotkey (text);
widget_init (w, y, x, 1, button_get_len (b), button_callback, button_mouse_callback);
w->options |= WOP_SELECTABLE | WOP_WANT_CURSOR | WOP_WANT_HOTKEY;
b->selected = FALSE;
b->callback = callback;
b->hotpos = (b->text.hotkey != NULL) ? str_term_width1 (b->text.start) : -1;

View File

@ -32,7 +32,6 @@ typedef struct WButton
{
Widget widget;
int action; /* what to do when pressed */
gboolean selected; /* button state */
button_flags_t flags; /* button flags */
hotkey_t text; /* text of button, contain hotkey too */