Example #1
0
static void
listbox_run_hotkey (WListbox * l, int pos)
{
    listbox_select_entry (l, pos);
    listbox_on_change (l);
    listbox_do_action (l);
}
Example #2
0
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);
    }
}
Example #3
0
static void
listbox_mouse_callback (Widget * w, mouse_msg_t msg, mouse_event_t * event)
{
    WListbox *l = LISTBOX (w);
    int old_pos;

    old_pos = l->pos;

    switch (msg)
    {
    case MSG_MOUSE_DOWN:
        widget_select (w);
        listbox_select_entry (l, listbox_y_pos (l, event->y));
        break;

    case MSG_MOUSE_SCROLL_UP:
        listbox_back (l, FALSE);
        break;

    case MSG_MOUSE_SCROLL_DOWN:
        listbox_fwd (l, FALSE);
        break;

    case MSG_MOUSE_DRAG:
        event->result.repeat = TRUE;    /* It'd be functional even without this. */
        listbox_select_entry (l, listbox_y_pos (l, event->y));
        break;

    case MSG_MOUSE_CLICK:
        /* We don't call listbox_select_entry() here: MSG_MOUSE_DOWN/DRAG did this already. */
        if (event->count == GPM_DOUBLE) /* Double click */
            listbox_do_action (l);
        break;

    default:
        break;
    }

    /* If the selection has changed, we redraw the widget and notify the dialog. */
    if (l->pos != old_pos)
        listbox_on_change (l);
}