* dialog.c (dlg_replace_widget): Use dlg_select_widget().
(select_a_widget): Rename to select_other_widget(), factorize most code from dlg_one_up() and dlg_one_down().
Этот коммит содержится в:
родитель
0657d80ec7
Коммит
bf4c26959c
@ -1,3 +1,9 @@
|
||||
2003-11-26 Pavel Roskin <proski@gnu.org>
|
||||
|
||||
* dialog.c (dlg_replace_widget): Use dlg_select_widget().
|
||||
(select_a_widget): Rename to select_other_widget(), factorize
|
||||
most code from dlg_one_up() and dlg_one_down().
|
||||
|
||||
2003-11-24 Pavel Roskin <proski@gnu.org>
|
||||
|
||||
* complete.c (check_is_cd): Simplify logic, use isspace().
|
||||
|
104
src/dialog.c
104
src/dialog.c
@ -346,19 +346,6 @@ dlg_unfocus (Dlg_head *h)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
select_a_widget (Dlg_head *h, int down)
|
||||
{
|
||||
if (!h->current)
|
||||
return;
|
||||
|
||||
do {
|
||||
if (down)
|
||||
h->current = h->current->next;
|
||||
else
|
||||
h->current = h->current->prev;
|
||||
} while (!dlg_focus (h));
|
||||
}
|
||||
|
||||
/* Return true if the windows overlap */
|
||||
int dlg_overlap (Widget *a, Widget *b)
|
||||
@ -372,6 +359,52 @@ int dlg_overlap (Widget *a, Widget *b)
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Try to select another widget. If forward is set, follow tab order.
|
||||
* Otherwise go to the previous widget.
|
||||
*/
|
||||
static void
|
||||
select_other_widget (Dlg_head *h, int forward)
|
||||
{
|
||||
Widget *old;
|
||||
|
||||
old = h->current;
|
||||
if (!old)
|
||||
return;
|
||||
|
||||
if (!dlg_unfocus (h))
|
||||
return;
|
||||
|
||||
do {
|
||||
if (forward)
|
||||
h->current = h->current->next;
|
||||
else
|
||||
h->current = h->current->prev;
|
||||
} while (!dlg_focus (h));
|
||||
|
||||
if (dlg_overlap (old, h->current)) {
|
||||
send_message (h->current, WIDGET_DRAW, 0);
|
||||
send_message (h->current, WIDGET_FOCUS, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Try to select previous widget in the tab order */
|
||||
void
|
||||
dlg_one_up (Dlg_head *h)
|
||||
{
|
||||
select_other_widget (h, 0);
|
||||
}
|
||||
|
||||
|
||||
/* Try to select next widget in the tab order */
|
||||
void
|
||||
dlg_one_down (Dlg_head *h)
|
||||
{
|
||||
select_other_widget (h, 1);
|
||||
}
|
||||
|
||||
|
||||
/* Find the widget with the given callback in the dialog h */
|
||||
Widget *
|
||||
find_widget_type (Dlg_head *h, void *callback)
|
||||
@ -419,44 +452,6 @@ dlg_select_by_id (Dlg_head *h, int id)
|
||||
dlg_select_widget(h, w_found);
|
||||
}
|
||||
|
||||
void dlg_one_up (Dlg_head *h)
|
||||
{
|
||||
Widget *old;
|
||||
|
||||
old = h->current;
|
||||
|
||||
if (!old)
|
||||
return;
|
||||
|
||||
/* If it accepts unFOCUSion */
|
||||
if (!dlg_unfocus(h))
|
||||
return;
|
||||
|
||||
select_a_widget (h, 0);
|
||||
if (dlg_overlap (old, h->current)){
|
||||
send_message (h->current, WIDGET_DRAW, 0);
|
||||
send_message (h->current, WIDGET_FOCUS, 0);
|
||||
}
|
||||
}
|
||||
|
||||
void dlg_one_down (Dlg_head *h)
|
||||
{
|
||||
Widget *old;
|
||||
|
||||
old = h->current;
|
||||
if (!old)
|
||||
return;
|
||||
|
||||
if (!dlg_unfocus (h))
|
||||
return;
|
||||
|
||||
select_a_widget (h, 1);
|
||||
if (dlg_overlap (old, h->current)){
|
||||
send_message (h->current, WIDGET_DRAW, 0);
|
||||
send_message (h->current, WIDGET_FOCUS, 0);
|
||||
}
|
||||
}
|
||||
|
||||
int dlg_select_widget (Dlg_head *h, void *w)
|
||||
{
|
||||
if (!h->current)
|
||||
@ -859,11 +854,8 @@ dlg_replace_widget (Dlg_head *h, Widget *old_w, Widget *new_w)
|
||||
send_message (old_w, WIDGET_DESTROY, 0);
|
||||
send_message (new_w, WIDGET_INIT, 0);
|
||||
|
||||
if (should_focus) {
|
||||
if (!dlg_focus (h)) {
|
||||
select_a_widget (h, 1);
|
||||
}
|
||||
}
|
||||
if (should_focus)
|
||||
dlg_select_widget (h, new_w);
|
||||
|
||||
send_message (new_w, WIDGET_DRAW, 0);
|
||||
}
|
||||
|
Загрузка…
Ссылка в новой задаче
Block a user