Clarify widget redraw in runtime.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
Andrew Borodin 2013-02-11 15:35:00 +04:00
parent ef94b84eaf
commit 30959e0b7d
20 changed files with 40 additions and 38 deletions

View File

@ -241,8 +241,7 @@ button_set_text (WButton * b, const char *text)
release_hotkey (b->text);
b->text = parse_hotkey (text);
w->cols = button_get_len (b);
if (w->owner != NULL)
send_message (w, NULL, MSG_DRAW, 0, NULL);
widget_redraw (w);
}
/* --------------------------------------------------------------------------------------------- */

View File

@ -47,13 +47,6 @@ WButtonBar *find_buttonbar (const WDialog * h);
/*** inline functions ****************************************************************************/
static inline void
buttonbar_redraw (WButtonBar * bb)
{
if (bb != NULL)
send_message (bb, NULL, MSG_DRAW, 0, NULL);
}
static inline void
buttonbar_set_visible (WButtonBar * bb, gboolean visible)
{

View File

@ -1382,8 +1382,7 @@ dlg_replace_widget (Widget * old_w, Widget * new_w)
if (should_focus)
dlg_select_widget (new_w);
if (new_w->owner->state == DLG_ACTIVE)
send_message (new_w, NULL, MSG_DRAW, 0, NULL);
widget_redraw (new_w);
}
/* --------------------------------------------------------------------------------------------- */

View File

@ -164,7 +164,7 @@ gauge_set_value (WGauge * g, int max, int current)
max = 1; /* I do not like division by zero :) */
g->current = current;
g->max = max;
gauge_callback (WIDGET (g), NULL, MSG_DRAW, 0, NULL);
widget_redraw (WIDGET (g));
}
/* --------------------------------------------------------------------------------------------- */
@ -175,7 +175,7 @@ gauge_show (WGauge * g, gboolean shown)
if (g->shown != shown)
{
g->shown = shown;
gauge_callback (WIDGET (g), NULL, MSG_DRAW, 0, NULL);
widget_redraw (WIDGET (g));
}
}

View File

@ -119,8 +119,6 @@ groupbox_new (int y, int x, int height, int width, const char *title)
void
groupbox_set_title (WGroupbox * g, const char *title)
{
Widget *w = WIDGET (g);
g_free (g->title);
g->title = NULL;
@ -134,8 +132,7 @@ groupbox_set_title (WGroupbox * g, const char *title)
g_free (t);
}
if (w->owner != NULL)
send_message (w, NULL, MSG_DRAW, 0, NULL);
widget_redraw (WIDGET (g));
}
/* --------------------------------------------------------------------------------------------- */

View File

@ -150,8 +150,7 @@ hline_set_text (WHLine * l, const char *text)
else
l->text = g_strdup (text);
if (WIDGET (l)->owner != NULL)
send_message (l, NULL, MSG_DRAW, 0, NULL);
widget_redraw (WIDGET (l));
}
/* --------------------------------------------------------------------------------------------- */

View File

@ -1265,6 +1265,7 @@ input_set_point (WInput * in, int pos)
void
input_update (WInput * in, gboolean clear_first)
{
Widget *w = WIDGET (in);
int has_history = 0;
int i;
int buf_len;
@ -1292,13 +1293,13 @@ input_update (WInput * in, gboolean clear_first)
in->mark = min (in->mark, buf_len);
/* don't draw widget not put into dialog */
if (WIDGET (in)->owner == NULL)
if (w->owner == NULL || w->owner->state != DLG_ACTIVE)
return;
if (has_history != 0)
draw_history_button (in);
if ((WIDGET (in)->options & W_DISABLED) != 0)
if ((w->options & W_DISABLED) != 0)
tty_setcolor (DISABLED_COLOR);
else if (in->first)
tty_setcolor (in->color[WINPUTC_UNCHANGED]);

View File

@ -1058,7 +1058,7 @@ query_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *d
listbox_select_entry (LISTBOX (h->current->data), i);
end = new_end;
input_handle_char (input, parm);
send_message (h->current->data, NULL, MSG_DRAW, 0, NULL);
widget_redraw (WIDGET (h->current->data));
break;
}
}
@ -1161,7 +1161,7 @@ query_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *d
if (need_redraw == 2)
{
insert_text (input, last_text, low);
send_message (h->current->data, NULL, MSG_DRAW, 0, NULL);
widget_redraw (WIDGET (h->current->data));
}
else if (need_redraw == 1)
{

View File

@ -182,11 +182,10 @@ label_set_text (WLabel * label, const char *text)
}
}
if (w->owner != NULL)
send_message (w, NULL, MSG_DRAW, 0, NULL);
if (newcols < w->cols)
w->cols = newcols;
widget_redraw (w);
}
/* --------------------------------------------------------------------------------------------- */

View File

@ -268,6 +268,20 @@ widget_erase (Widget * w)
/* --------------------------------------------------------------------------------------------- */
void
widget_redraw (Widget * w)
{
if (w != NULL)
{
WDialog *h = w->owner;
if (h != NULL && h->state == DLG_ACTIVE)
w->callback (w, NULL, MSG_DRAW, 0, NULL);
}
}
/* --------------------------------------------------------------------------------------------- */
/* get mouse pointer location within widget */
Gpm_Event
mouse_get_local (const Gpm_Event * global, const Widget * w)

View File

@ -142,6 +142,7 @@ void widget_set_options (Widget * w, widget_options_t options, gboolean enable);
void widget_set_size (Widget * widget, int y, int x, int lines, int cols);
/* select color for widget in dependance of state */
void widget_selectcolor (Widget * w, gboolean focused, gboolean hotkey);
void widget_redraw (Widget * w);
void widget_erase (Widget * w);
/* get mouse pointer location within widget */

View File

@ -1878,7 +1878,7 @@ user_menu (WEdit * edit, const char *menu_file, int selected_entry)
edit_cursor_move (edit, curs - edit->curs1);
edit->force |= REDRAW_PAGE;
send_message (edit, NULL, MSG_DRAW, 0, NULL);
widget_redraw (WIDGET (edit));
}
/* --------------------------------------------------------------------------------------------- */

View File

@ -3333,7 +3333,7 @@ edit_select_codepage_cmd (WEdit * edit)
edit_set_codeset (edit);
edit->force = REDRAW_PAGE;
send_message (edit, NULL, MSG_DRAW, 0, NULL);
widget_redraw (WIDGET (edit));
}
#endif

View File

@ -1173,7 +1173,7 @@ edit_update_screen (WEdit * e)
edit_render_keypress (e);
}
buttonbar_redraw (find_buttonbar (h));
widget_redraw (WIDGET (find_buttonbar (h)));
}
/* --------------------------------------------------------------------------------------------- */

View File

@ -922,7 +922,7 @@ find_add_match (const char *dir, const char *file)
/* Don't scroll */
if (matches == 0)
listbox_select_first (find_list);
send_message (find_list, NULL, MSG_DRAW, 0, NULL);
widget_redraw (WIDGET (find_list));
matches++;
found_num_update ();

View File

@ -233,7 +233,7 @@ update_split (const WDialog * h)
check_options[0].widget->state = _panels_layout.horizontal_equal ? 1 : 0;
else
check_options[0].widget->state = _panels_layout.vertical_equal ? 1 : 0;
send_message (check_options[0].widget, NULL, MSG_DRAW, 0, NULL);
widget_redraw (WIDGET (check_options[0].widget));
tty_setcolor (check_options[0].widget->state & C_BOOL ? DISABLED_COLOR : COLOR_NORMAL);

View File

@ -1097,10 +1097,10 @@ static void
update_dirty_panels (void)
{
if (get_current_type () == view_listing && current_panel->dirty)
send_message (current_panel, NULL, MSG_DRAW, 0, NULL);
widget_redraw (WIDGET (current_panel));
if (get_other_type () == view_listing && other_panel->dirty)
send_message (other_panel, NULL, MSG_DRAW, 0, NULL);
widget_redraw (WIDGET (other_panel));
}
/* --------------------------------------------------------------------------------------------- */

View File

@ -2497,7 +2497,7 @@ do_search (WPanel * panel, int c_code)
unselect_item (panel);
panel->selected = sel;
select_item (panel);
send_message (panel, NULL, MSG_DRAW, 0, NULL);
widget_redraw (WIDGET (panel));
}
else if (c_code != KEY_BACKSPACE)
{
@ -3462,7 +3462,7 @@ panel_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *d
bb = find_buttonbar (w->owner);
midnight_set_buttonbar (bb);
buttonbar_redraw (bb);
widget_redraw (WIDGET (bb));
return MSG_HANDLED;
case MSG_UNFOCUS:
@ -3718,7 +3718,7 @@ panel_event (Gpm_Event * event, void *data)
finish:
if (panel->dirty)
send_message (w, NULL, MSG_DRAW, 0, NULL);
widget_redraw (w);
return MOU_NORMAL;
}

View File

@ -1236,7 +1236,7 @@ tree_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *da
buttonbar_clear_label (b, 7, WIDGET (tree));
#endif
buttonbar_set_label (b, 8, Q_ ("ButtonBar|Rmdir"), tree_map, w);
buttonbar_redraw (b);
widget_redraw (WIDGET (b));
/* FIXME: Should find a better way of only displaying the
currently selected item */

View File

@ -189,7 +189,7 @@ mcview_update (mcview_t * view)
{
view->dpy_bbar_dirty = FALSE;
mcview_set_buttonbar (view);
buttonbar_redraw (find_buttonbar (WIDGET (view)->owner));
widget_redraw (WIDGET (find_buttonbar (WIDGET (view)->owner)));
}
if (view->dirty > dirt_limit)