コード例 #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 プロジェクト: 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);
    }
}
コード例 #3
0
ファイル: dialog.c プロジェクト: GalaxyTab4/workbench
static int
dlg_mouse_event (WDialog * h, Gpm_Event * event)
{
    Widget *wh = WIDGET (h);

    GList *p, *first;

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

    if (wh->mouse != NULL)
    {
        int mou;

        mou = wh->mouse (event, wh);
        if (mou != MOU_UNHANDLED)
            return mou;
    }

    first = h->current;
    p = first;

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

        p = dlg_widget_prev (h, p);

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

            ret = w->mouse (event, w);
            if (ret != MOU_UNHANDLED)
                return ret;
        }
    }
    while (p != first);

    return MOU_UNHANDLED;
}
コード例 #4
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;
}
コード例 #5
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);
    }
}
コード例 #6
0
ファイル: dialog.c プロジェクト: GalaxyTab4/workbench
void
dlg_one_up (WDialog * h)
{
    if (h->widgets != NULL)
        do_select_widget (h, dlg_widget_prev (h, h->current), SELECT_PREV);
}