コード例 #1
0
ファイル: dialog.c プロジェクト: GalaxyTab4/workbench
static void
dlg_broadcast_msg_to (WDialog * h, widget_msg_t msg, gboolean reverse, int flags)
{
    GList *p, *first;

    if (h->widgets == NULL)
        return;

    if (h->current == NULL)
        h->current = h->widgets;

    if (reverse)
        p = dlg_widget_prev (h, h->current);
    else
        p = dlg_widget_next (h, h->current);

    first = p;

    do
    {
        Widget *w = WIDGET (p->data);

        if (reverse)
            p = dlg_widget_prev (h, p);
        else
            p = dlg_widget_next (h, p);

        if ((flags == 0) || ((flags & w->options) != 0))
            send_message (w, NULL, msg, 0, NULL);
    }
    while (first != p);
}
コード例 #2
0
ファイル: dialog.c プロジェクト: GalaxyTab4/workbench
/** delete widget from dialog */
void
del_widget (void *w)
{
    WDialog *h;
    GList *d;

    /* Don't accept NULL widget. This shouldn't happen */
    if (w == NULL)
        abort ();

    h = WIDGET (w)->owner;

    d = g_list_find (h->widgets, w);
    if (d == h->current)
        h->current = dlg_widget_next (h, d);

    h->widgets = g_list_remove_link (h->widgets, d);
    send_message (d->data, NULL, MSG_DESTROY, 0, NULL);
    g_free (d->data);
    g_list_free_1 (d);

    /* widget has been deleted in runtime */
    if (h->state == DLG_ACTIVE)
    {
        dlg_redraw (h);
        dlg_focus (h);
    }
}
コード例 #3
0
ファイル: dialog.c プロジェクト: GalaxyTab4/workbench
void
update_cursor (WDialog * h)
{
    GList *p = h->current;

    if ((p != NULL) && (h->state == DLG_ACTIVE))
    {
        Widget *w;

        w = WIDGET (p->data);

        if (((w->options & W_DISABLED) == 0) && ((w->options & W_WANT_CURSOR) != 0))
            send_message (w, NULL, MSG_CURSOR, 0, NULL);
        else
            do
            {
                p = dlg_widget_next (h, p);
                if (p == h->current)
                    break;

                w = WIDGET (p->data);

                if (((w->options & W_DISABLED) == 0) && ((w->options & W_WANT_CURSOR) != 0))
                    if (send_message (w, NULL, MSG_CURSOR, 0, NULL) == MSG_HANDLED)
                        break;
            }
            while (TRUE);
    }
}
コード例 #4
0
ファイル: dialog.c プロジェクト: GalaxyTab4/workbench
void
dlg_init (WDialog * h)
{
    if (top_dlg != NULL && DIALOG (top_dlg->data)->modal)
        h->modal = TRUE;

    /* add dialog to the stack */
    top_dlg = g_list_prepend (top_dlg, h);

    /* Initialize dialog manager and widgets */
    if (h->state == DLG_CONSTRUCT)
    {
        if (!h->modal)
            dialog_switch_add (h);

        send_message (h, NULL, MSG_INIT, 0, NULL);
        dlg_broadcast_msg (h, MSG_INIT);
        dlg_read_history (h);
    }

    h->state = DLG_ACTIVE;

    /* Select the first widget that takes focus */
    while (h->current != NULL && !dlg_focus (h))
        h->current = dlg_widget_next (h, h->current);

    dlg_redraw (h);

    h->ret_value = 0;
}
コード例 #5
0
ファイル: dialog.c プロジェクト: ryanlee/mc
/** delete widget from dialog */
void
del_widget (void *w)
{
    Dlg_head *h = ((Widget *) w)->owner;
    GList *d;

    /* Don't accept NULL widget. This shouldn't happen */
    if (w == NULL)
        abort ();

    d = g_list_find (h->widgets, w);
    if (d == h->current)
    {
        if ((h->flags & DLG_REVERSE) != 0)
            h->current = dlg_widget_prev (h, d);
        else
            h->current = dlg_widget_next (h, d);
    }

    h->widgets = g_list_remove_link (h->widgets, d);
    send_message (d->data, WIDGET_DESTROY, 0);
    g_list_free_1 (d);

    /* widget has been deleted in runtime */
    if (h->state == DLG_ACTIVE)
    {
        dlg_redraw (h);
        dlg_focus (h);
    }
}
コード例 #6
0
ファイル: dialog.c プロジェクト: ryanlee/mc
void
init_dlg (Dlg_head * h)
{
    if ((top_dlg != NULL) && ((Dlg_head *) top_dlg->data)->modal)
        h->modal = TRUE;

    /* add dialog to the stack */
    top_dlg = g_list_prepend (top_dlg, h);

    /* Initialize dialog manager and widgets */
    if (h->state == DLG_CONSTRUCT)
    {
        if (!h->modal)
            dialog_switch_add (h);

        h->callback (h, NULL, DLG_INIT, 0, NULL);
        dlg_broadcast_msg (h, WIDGET_INIT, FALSE);
        dlg_read_history (h);
    }

    h->state = DLG_ACTIVE;

    /* Select the first widget that takes focus */
    while (h->current != NULL && !dlg_focus (h))
        h->current = dlg_widget_next (h, h->current);

    dlg_redraw (h);

    h->ret_value = 0;
}
コード例 #7
0
ファイル: dialog.c プロジェクト: ryanlee/mc
static int
dlg_mouse_event (Dlg_head * h, Gpm_Event * event)
{
    GList *item;
    GList *starting_widget = h->current;
    int x = event->x;
    int y = event->y;

    /* close the dialog by mouse click out of dialog area */
    if (mouse_close_dialog && !h->fullscreen && ((event->buttons & GPM_B_LEFT) != 0)
        && ((event->type & GPM_DOWN) != 0) /* left click */
        && !((x > h->x) && (x <= h->x + h->cols) && (y > h->y) && (y <= h->y + h->lines)))
    {
        h->ret_value = B_CANCEL;
        dlg_stop (h);
        return MOU_NORMAL;
    }

    item = starting_widget;
    do
    {
        Widget *widget = (Widget *) item->data;

        if ((h->flags & DLG_REVERSE) == 0)
            item = dlg_widget_prev (h, item);
        else
            item = dlg_widget_next (h, item);

        if ((widget->options & W_DISABLED) == 0 && widget->mouse != NULL)
        {
            /* put global cursor position to the widget */
            int ret;

            ret = widget->mouse (event, widget);
            if (ret != MOU_UNHANDLED)
                return ret;
        }
    }
    while (item != starting_widget);

    return MOU_UNHANDLED;
}
コード例 #8
0
static int
dlg_mouse_event (Dlg_head * h, Gpm_Event * event)
{
    GList *item;
    GList *starting_widget = h->current;
    Gpm_Event new_event;
    int x = event->x;
    int y = event->y;

    /* close the dialog by mouse click out of dialog area */
    if (mouse_close_dialog && !h->fullscreen && ((event->buttons & GPM_B_LEFT) != 0) && ((event->type & GPM_DOWN) != 0) /* left click */
        && !((x > h->x) && (x <= h->x + h->cols) && (y > h->y) && (y <= h->y + h->lines)))
    {
        h->ret_value = B_CANCEL;
        dlg_stop (h);
        return MOU_NORMAL;
    }

    item = starting_widget;
    do
    {
        Widget *widget;

        widget = (Widget *) item->data;
        item = dlg_widget_next (h, item);

        if (((widget->options & W_DISABLED) == 0)
            && (x > widget->x) && (x <= widget->x + widget->cols)
            && (y > widget->y) && (y <= widget->y + widget->lines))
        {
            new_event = *event;
            new_event.x -= widget->x;
            new_event.y -= widget->y;

            if (widget->mouse != NULL)
                return widget->mouse (&new_event, widget);
        }
    }
    while (item != starting_widget);

    return MOU_NORMAL;
}
コード例 #9
0
ファイル: dialog.c プロジェクト: GalaxyTab4/workbench
static void
do_select_widget (WDialog * h, GList * w, select_dir_t dir)
{
    Widget *w0 = WIDGET (h->current->data);

    if (!dlg_unfocus (h))
        return;

    h->current = w;

    do
    {
        if (dlg_focus (h))
            break;

        switch (dir)
        {
        case SELECT_EXACT:
            h->current = g_list_find (h->widgets, w0);
            if (dlg_focus (h))
                return;
            /* try find another widget that can take focus */
            dir = SELECT_NEXT;
            /* fallthrough */
        case SELECT_NEXT:
            h->current = dlg_widget_next (h, h->current);
            break;
        case SELECT_PREV:
            h->current = dlg_widget_prev (h, h->current);
            break;
        }
    }
    while (h->current != w /* && (WIDGET (h->current->data)->options & W_DISABLED) == 0 */ );

    if (widget_overlapped (w0, WIDGET (h->current->data)))
    {
        send_message (h->current->data, NULL, MSG_DRAW, 0, NULL);
        send_message (h->current->data, NULL, MSG_FOCUS, 0, NULL);
    }
}
コード例 #10
0
ファイル: dialog.c プロジェクト: GalaxyTab4/workbench
static cb_ret_t
dlg_try_hotkey (WDialog * h, int d_key)
{
    GList *hot_cur;
    Widget *current;
    cb_ret_t handled;
    int c;

    if (h->widgets == NULL)
        return MSG_NOT_HANDLED;

    if (h->current == NULL)
        h->current = h->widgets;

    /*
     * Explanation: we don't send letter hotkeys to other widgets if
     * the currently selected widget is an input line
     */

    current = WIDGET (h->current->data);

    if ((current->options & W_DISABLED) != 0)
        return MSG_NOT_HANDLED;

    if (current->options & W_IS_INPUT)
    {
        /* skip ascii control characters, anything else can valid character in
         * some encoding */
        if (d_key >= 32 && d_key < 256)
            return MSG_NOT_HANDLED;
    }

    /* If it's an alt key, send the message */
    c = d_key & ~ALT (0);
    if (d_key & ALT (0) && g_ascii_isalpha (c))
        d_key = g_ascii_tolower (c);

    handled = MSG_NOT_HANDLED;
    if ((current->options & W_WANT_HOTKEY) != 0)
        handled = send_message (current, NULL, MSG_HOTKEY, d_key, NULL);

    /* If not used, send hotkey to other widgets */
    if (handled == MSG_HANDLED)
        return MSG_HANDLED;

    hot_cur = dlg_widget_next (h, h->current);

    /* send it to all widgets */
    while (h->current != hot_cur && handled == MSG_NOT_HANDLED)
    {
        current = WIDGET (hot_cur->data);

        if ((current->options & W_WANT_HOTKEY) != 0 && (current->options & W_DISABLED) == 0)
            handled = send_message (current, NULL, MSG_HOTKEY, d_key, NULL);

        if (handled == MSG_NOT_HANDLED)
            hot_cur = dlg_widget_next (h, hot_cur);
    }

    if (handled == MSG_HANDLED)
        do_select_widget (h, hot_cur, SELECT_EXACT);

    return handled;
}
コード例 #11
0
ファイル: dialog.c プロジェクト: GalaxyTab4/workbench
void
dlg_one_down (WDialog * h)
{
    if (h->widgets != NULL)
        do_select_widget (h, dlg_widget_next (h, h->current), SELECT_NEXT);
}