* dlg.c (send_message_to): Remove, use send_message() instead.

(send_message): Make inline, remove Dlg_head argument.  Change
all callers.
This commit is contained in:
Pavel Roskin 2002-11-13 02:56:40 +00:00
parent bc70c8cc1e
commit 66f451aac7
10 changed files with 45 additions and 62 deletions

View File

@ -32,12 +32,12 @@
static void menu_cmd (int i)
{
send_message (wedit->widget.parent, (Widget *) wedit, WIDGET_COMMAND, i);
send_message ((Widget *) wedit, WIDGET_COMMAND, i);
}
static void menu_key (int i)
{
send_message (wedit->widget.parent, (Widget *) wedit, WIDGET_KEY, i);
send_message ((Widget *) wedit, WIDGET_KEY, i);
}
void edit_wrap_cmd (void)

View File

@ -229,54 +229,54 @@ static void edit_my_define (Dlg_head * h, int idx, char *text,
static void cmd_F1 (WEdit * edit)
{
send_message (edit->widget.parent, (Widget *) edit, WIDGET_KEY, KEY_F (1));
send_message ((Widget *) edit, WIDGET_KEY, KEY_F (1));
}
static void cmd_F2 (WEdit * edit)
{
send_message (edit->widget.parent, (Widget *) edit, WIDGET_KEY, KEY_F (2));
send_message ((Widget *) edit, WIDGET_KEY, KEY_F (2));
}
static void cmd_F3 (WEdit * edit)
{
send_message (edit->widget.parent, (Widget *) edit, WIDGET_KEY, KEY_F (3));
send_message ((Widget *) edit, WIDGET_KEY, KEY_F (3));
}
static void cmd_F4 (WEdit * edit)
{
send_message (edit->widget.parent, (Widget *) edit, WIDGET_KEY, KEY_F (4));
send_message ((Widget *) edit, WIDGET_KEY, KEY_F (4));
}
static void cmd_F5 (WEdit * edit)
{
send_message (edit->widget.parent, (Widget *) edit, WIDGET_KEY, KEY_F (5));
send_message ((Widget *) edit, WIDGET_KEY, KEY_F (5));
}
static void cmd_F6 (WEdit * edit)
{
send_message (edit->widget.parent, (Widget *) edit, WIDGET_KEY, KEY_F (6));
send_message ((Widget *) edit, WIDGET_KEY, KEY_F (6));
}
static void cmd_F7 (WEdit * edit)
{
send_message (edit->widget.parent, (Widget *) edit, WIDGET_KEY, KEY_F (7));
send_message ((Widget *) edit, WIDGET_KEY, KEY_F (7));
}
static void cmd_F8 (WEdit * edit)
{
send_message (edit->widget.parent, (Widget *) edit, WIDGET_KEY, KEY_F (8));
send_message ((Widget *) edit, WIDGET_KEY, KEY_F (8));
}
#if 0
static void cmd_F9 (WEdit * edit)
{
send_message (edit->widget.parent, (Widget *) edit, WIDGET_KEY, KEY_F (9));
send_message ((Widget *) edit, WIDGET_KEY, KEY_F (9));
}
#endif
static void cmd_F10 (WEdit * edit)
{
send_message (edit->widget.parent, (Widget *) edit, WIDGET_KEY, KEY_F (10));
send_message ((Widget *) edit, WIDGET_KEY, KEY_F (10));
}
void

View File

@ -1,5 +1,9 @@
2002-11-12 Pavel Roskin <proski@gnu.org>
* dlg.c (send_message_to): Remove, use send_message() instead.
(send_message): Make inline, remove Dlg_head argument. Change
all callers.
* dlg.h: Remove Dlg_head argument from callback_fn - it's
excessive and can be trivially derived from the widget.
(default_proc): Remove Dlg_head argument. Change all callers.

View File

@ -216,7 +216,7 @@ static void update_mode (Dlg_head * h)
attrset (COLOR_NORMAL);
dlg_move (h, BY + 2, 9);
printw ("%12o", get_mode ());
send_message (h, h->current->widget, WIDGET_FOCUS, 0);
send_message (h->current->widget, WIDGET_FOCUS, 0);
}
static int l_call (void *data)
@ -459,7 +459,7 @@ static int advanced_chown_callback (Dlg_head * h, int Par, int Msg)
x_toggle ^= (1 << Par);
update_mode (h);
dlg_broadcast_msg (h, WIDGET_DRAW, 0);
send_message (h, h->current->widget, WIDGET_FOCUS, 0);
send_message (h->current->widget, WIDGET_FOCUS, 0);
break;
case XCTRL ('x'):
@ -475,7 +475,7 @@ static int advanced_chown_callback (Dlg_head * h, int Par, int Msg)
x_toggle ^= (1 << Par);
update_mode (h);
dlg_broadcast_msg (h, WIDGET_DRAW, 0);
send_message (h, h->current->widget, WIDGET_FOCUS, 0);
send_message (h->current->widget, WIDGET_FOCUS, 0);
break;
case 'x':

View File

@ -849,8 +849,7 @@ query_callback (Dlg_head * h, int Par, int Msg)
widget), e1);
handle_char (input, Par);
end--;
send_message (h, h->current->widget,
WIDGET_DRAW, 0);
send_message (h->current->widget, WIDGET_DRAW, 0);
break;
}
e1 = e1->next;
@ -906,7 +905,7 @@ query_callback (Dlg_head * h, int Par, int Msg)
} while (e != e1);
if (need_redraw == 2) {
insert_text (input, last_text, low);
send_message (h, h->current->widget, WIDGET_DRAW, 0);
send_message (h->current->widget, WIDGET_DRAW, 0);
} else if (need_redraw == 1) {
h->ret_value = B_ENTER;
dlg_stop (h);

View File

@ -305,18 +305,13 @@ int add_widget (Dlg_head *where, void *what)
where->count++;
/* If the widget is inserted in a running dialog */
if (where->running){
send_message (where, widget, WIDGET_INIT, 0);
send_message (where, widget, WIDGET_DRAW, 0);
if (where->running) {
send_message (widget, WIDGET_INIT, 0);
send_message (widget, WIDGET_DRAW, 0);
}
return (where->count - 1);
}
int send_message (Dlg_head *h, Widget *w, int msg, int par)
{
return (*(w->callback))(w, msg, par);
}
/* broadcast a message to all the widgets in a dialog that have
* the options set to flags.
*/
@ -339,7 +334,7 @@ dlg_broadcast_msg_to (Dlg_head *h, int message, int reverse, int flags)
p = p->prev;
else
p = p->next;
send_message (h, wi->widget, message, 0);
send_message (wi->widget, message, 0);
} while (first != p);
}
@ -354,7 +349,7 @@ int dlg_focus (Dlg_head *h)
if (!h->current)
return 0;
if (send_message (h, h->current->widget, WIDGET_FOCUS, 0)){
if (send_message (h->current->widget, WIDGET_FOCUS, 0)){
(*h->callback) (h, h->current->dlg_id, DLG_FOCUS);
return 1;
}
@ -367,7 +362,7 @@ dlg_unfocus (Dlg_head *h)
if (!h->current)
return 0;
if (send_message (h, h->current->widget, WIDGET_UNFOCUS, 0)){
if (send_message (h->current->widget, WIDGET_UNFOCUS, 0)){
(*h->callback) (h, h->current->dlg_id, DLG_UNFOCUS);
return 1;
}
@ -443,8 +438,8 @@ void dlg_one_up (Dlg_head *h)
select_a_widget (h, 0);
if (dlg_overlap (old->widget, h->current->widget)){
send_message (h, h->current->widget, WIDGET_DRAW, 0);
send_message (h, h->current->widget, WIDGET_FOCUS, 0);
send_message (h->current->widget, WIDGET_DRAW, 0);
send_message (h->current->widget, WIDGET_FOCUS, 0);
}
}
@ -461,8 +456,8 @@ void dlg_one_down (Dlg_head *h)
select_a_widget (h, 1);
if (dlg_overlap (old->widget, h->current->widget)){
send_message (h, h->current->widget, WIDGET_DRAW, 0);
send_message (h, h->current->widget, WIDGET_FOCUS, 0);
send_message (h->current->widget, WIDGET_DRAW, 0);
send_message (h->current->widget, WIDGET_FOCUS, 0);
}
}
@ -482,25 +477,6 @@ int dlg_select_widget (Dlg_head *h, void *w)
return 0;
}
int send_message_to (Dlg_head *h, Widget *w, int msg, int par)
{
Widget_Item *p = h->current;
int v, i;
if (!h->current)
return 0;
v = 0;
for (i = 0; i < h->count; i++){
if (w == (void *) p->widget){
v = send_message (h, p->widget, msg, par);
break;
}
p = p->next;
}
return v;
}
#define callback(h) (h->current->widget->callback)
void update_cursor (Dlg_head *h)
@ -508,7 +484,7 @@ void update_cursor (Dlg_head *h)
if (!h->current)
return;
if (h->current->widget->options & W_WANT_CURSOR)
send_message (h, h->current->widget, WIDGET_CURSOR, 0);
send_message (h->current->widget, WIDGET_CURSOR, 0);
else {
Widget_Item *p = h->current;
@ -908,17 +884,17 @@ void dlg_replace_widget (Dlg_head *h, Widget *old, Widget *new)
/* We found the widget */
/* First kill the widget */
new->parent = h;
send_message_to (h, old, WIDGET_DESTROY, 0);
send_message (old, WIDGET_DESTROY, 0);
(*old->destroy) (old);
/* We insert the new widget */
p->widget = new;
send_message_to (h, new, WIDGET_INIT, 0);
send_message (new, WIDGET_INIT, 0);
if (should_focus){
if (dlg_focus (h) == 0)
select_a_widget (h, 1);
}
send_message_to (h, new, WIDGET_DRAW, 0);
send_message (new, WIDGET_DRAW, 0);
break;
}
p = p->next;

View File

@ -191,8 +191,12 @@ void common_dialog_repaint (struct Dlg_head *h);
extern Dlg_head *current_dlg;
int send_message (Dlg_head *h, Widget *w, int msg, int par);
int send_message_to (Dlg_head *h, Widget *w, int msg, int par);
static inline int
send_message (Widget *w, int Msg, int Par)
{
return (*(w->callback))(w, Msg, Par);
}
void dlg_replace_widget (Dlg_head *h, Widget *old, Widget *new);
int dlg_overlap (Widget *a, Widget *b);
void widget_erase (Widget *);

View File

@ -358,7 +358,7 @@ find_add_match (Dlg_head *h, char *dir, char *file)
else
listbox_select_last (find_list, 0);
/* Updates the current listing */
send_message (h, &find_list->widget, WIDGET_DRAW, 0);
send_message (&find_list->widget, WIDGET_DRAW, 0);
if (p == 7)
mc_refresh ();
}

View File

@ -1736,7 +1736,7 @@ midnight_callback (struct Dlg_head *h, int id, int msg)
}
if (id == '\n' && cmdline->buffer[0]) {
send_message_to (h, (Widget *) cmdline, WIDGET_KEY, id);
send_message ((Widget *) cmdline, WIDGET_KEY, id);
return MSG_HANDLED;
}
@ -1790,7 +1790,7 @@ midnight_callback (struct Dlg_head *h, int id, int msg)
if (command_prompt) {
int v;
v = send_message_to (h, (Widget *) cmdline, WIDGET_KEY, id);
v = send_message ((Widget *) cmdline, WIDGET_KEY, id);
if (v)
return v;
}

View File

@ -2338,6 +2338,6 @@ redraw_labels (Dlg_head *h)
if (!bb)
return;
send_message (h, (Widget *) bb, WIDGET_DRAW, 0);
send_message ((Widget *) bb, WIDGET_DRAW, 0);
}