static cb_ret_t listbox_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *data) { WListbox *l = LISTBOX (w); cb_ret_t ret_code; switch (msg) { case MSG_INIT: return MSG_HANDLED; case MSG_HOTKEY: { int pos; pos = listbox_check_hotkey (l, parm); if (pos < 0) return MSG_NOT_HANDLED; listbox_run_hotkey (l, pos); return MSG_HANDLED; } case MSG_KEY: ret_code = listbox_key (l, parm); if (ret_code != MSG_NOT_HANDLED) listbox_on_change (l); return ret_code; case MSG_ACTION: return listbox_execute_cmd (l, parm); case MSG_CURSOR: widget_move (l, l->cursor_y, 0); return MSG_HANDLED; case MSG_FOCUS: case MSG_UNFOCUS: l->focused = msg == MSG_FOCUS; /* fall through */ case MSG_DRAW: listbox_draw (l, l->focused); return MSG_HANDLED; case MSG_DESTROY: listbox_destroy (l); return MSG_HANDLED; case MSG_RESIZE: return MSG_HANDLED; default: return widget_default_callback (w, sender, msg, parm, data); } }
static cb_ret_t listbox_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *data) { WListbox *l = LISTBOX (w); WDialog *h = w->owner; cb_ret_t ret_code; switch (msg) { case MSG_INIT: return MSG_HANDLED; case MSG_HOTKEY: { int pos, action; pos = listbox_check_hotkey (l, parm); if (pos < 0) return MSG_NOT_HANDLED; listbox_select_entry (l, pos); send_message (h, w, MSG_ACTION, l->pos, NULL); if (l->callback != NULL) action = l->callback (l); else action = LISTBOX_DONE; if (action == LISTBOX_DONE) { h->ret_value = B_ENTER; dlg_stop (h); } return MSG_HANDLED; } case MSG_KEY: ret_code = listbox_key (l, parm); if (ret_code != MSG_NOT_HANDLED) { listbox_draw (l, TRUE); send_message (h, w, MSG_ACTION, l->pos, NULL); } return ret_code; case MSG_ACTION: return listbox_execute_cmd (l, parm); case MSG_CURSOR: widget_move (l, l->cursor_y, 0); send_message (h, w, MSG_ACTION, l->pos, NULL); return MSG_HANDLED; case MSG_FOCUS: case MSG_UNFOCUS: case MSG_DRAW: listbox_draw (l, msg != MSG_UNFOCUS); return MSG_HANDLED; case MSG_DESTROY: listbox_destroy (l); return MSG_HANDLED; case MSG_RESIZE: return MSG_HANDLED; default: return widget_default_callback (w, sender, msg, parm, data); } }