Ticket #2919: implement WST_VISIBLE widget state.

(widget_is_focusable): new widget API.
Use it to detect if widget can take focus or not.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
Andrew Borodin 2019-08-11 14:37:43 +03:00
parent f67b6c1d00
commit 4598667b4d
4 changed files with 12 additions and 8 deletions

View File

@ -514,8 +514,7 @@ dlg_init (WDialog * h)
}
/* Select the first widget that takes focus */
while (g->current != NULL && !widget_get_options (WIDGET (g->current->data), WOP_SELECTABLE)
&& !widget_get_state (WIDGET (g->current->data), WST_DISABLED))
while (g->current != NULL && !widget_is_focusable (g->current->data))
group_set_current_widget_next (g);
widget_set_state (wh, WST_ACTIVE, TRUE);

View File

@ -113,15 +113,12 @@ group_select_next_or_prev (WGroup * g, gboolean next)
if (g->widgets != NULL && g->current != NULL)
{
GList *l = g->current;
Widget *w;
do
{
l = group_get_next_or_prev_of (l, next);
w = WIDGET (l->data);
}
while ((widget_get_state (w, WST_DISABLED) || !widget_get_options (w, WOP_SELECTABLE))
&& l != g->current);
while (!widget_is_focusable (l->data) && l != g->current);
widget_select (l->data);
}

View File

@ -567,8 +567,7 @@ widget_replace (Widget * old_w, Widget * new_w)
GList *l;
for (l = group_get_widget_next_of (holder);
!widget_get_options (WIDGET (l->data), WOP_SELECTABLE)
&& !widget_get_state (WIDGET (l->data), WST_DISABLED);
widget_is_focusable (WIDGET (l->data);
l = group_get_widget_next_of (l))
;
@ -589,6 +588,14 @@ widget_replace (Widget * old_w, Widget * new_w)
widget_draw (new_w);
}
/* --------------------------------------------------------------------------------------------- */
gboolean
widget_is_focusable (const Widget * w)
{
return (widget_get_options (w, WOP_SELECTABLE) && !widget_get_state (w, WST_DISABLED));
}
/* --------------------------------------------------------------------------------------------- */
/**
* Select specified widget in it's owner.

View File

@ -213,6 +213,7 @@ void widget_erase (Widget * w);
gboolean widget_is_active (const void *w);
gboolean widget_overlapped (const Widget * a, const Widget * b);
void widget_replace (Widget * old, Widget * new);
gboolean widget_is_focusable (const Widget * w);
void widget_select (Widget * w);
void widget_set_bottom (Widget * w);