예제 #1
0
void
dlg_set_size (WDialog * h, int lines, int cols)
{
    int x = 0, y = 0;

    dlg_adjust_position (WIDGET (h)->pos_flags, &y, &x, &lines, &cols);
    dlg_set_position (h, y, x, lines, cols);
}
예제 #2
0
파일: wtools.c 프로젝트: BpArCuCTeMbI/mc
static cb_ret_t
query_default_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *data)
{
    WDialog *h = DIALOG (w);

    switch (msg)
    {
    case MSG_RESIZE:
        if ((h->flags & DLG_CENTER) == 0)
        {
            WDialog *prev_dlg = NULL;
            int ypos, xpos;

            /* get dialog under h */
            if (top_dlg != NULL)
            {
                if (top_dlg->data != (void *) h)
                    prev_dlg = DIALOG (top_dlg->data);
                else
                {
                    GList *p;

                    /* Top dialog is current if it is visible.
                       Get previous dialog in stack */
                    p = g_list_next (top_dlg);
                    if (p != NULL)
                        prev_dlg = DIALOG (p->data);
                }
            }

            /* if previous dialog is not fullscreen'd -- overlap it */
            if (prev_dlg == NULL || prev_dlg->fullscreen)
                ypos = LINES / 3 - (w->lines - 3) / 2;
            else
                ypos = WIDGET (prev_dlg)->y + 2;

            xpos = COLS / 2 - w->cols / 2;

            /* set position */
            dlg_set_position (h, ypos, xpos, ypos + w->lines, xpos + w->cols);

            return MSG_HANDLED;
        }
        /* fallthrough */

    default:
        return dlg_default_callback (w, sender, msg, parm, data);
    }
}
예제 #3
0
파일: wtools.c 프로젝트: ryanlee/mc
static cb_ret_t
default_query_callback (Dlg_head * h, Widget * sender, dlg_msg_t msg, int parm, void *data)
{
    switch (msg)
    {
    case DLG_RESIZE:
        if ((h->flags & DLG_CENTER) == 0)
        {
            Dlg_head *prev_dlg = NULL;
            int ypos, xpos;

            /* get dialog under h */
            if (top_dlg != NULL)
            {
                if (top_dlg->data != (void *) h)
                    prev_dlg = (Dlg_head *) top_dlg->data;
                else
                {
                    GList *p;

                    /* Top dialog is current if it is visible.
                       Get previous dialog in stack */
                    p = g_list_next (top_dlg);
                    if (p != NULL)
                        prev_dlg = (Dlg_head *) p->data;
                }
            }

            /* if previous dialog is not fullscreen'd -- overlap it */
            if (prev_dlg == NULL || prev_dlg->fullscreen)
                ypos = LINES / 3 - (h->lines - 3) / 2;
            else
                ypos = prev_dlg->y + 2;

            xpos = COLS / 2 - h->cols / 2;

            /* set position */
            dlg_set_position (h, ypos, xpos, ypos + h->lines, xpos + h->cols);

            return MSG_HANDLED;
        }
        /* fallthrough */

    default:
        return default_dlg_callback (h, sender, msg, parm, data);
    }
}
예제 #4
0
void
dlg_set_size (WDialog * h, int lines, int cols)
{
    int x = WIDGET (h)->x;
    int y = WIDGET (h)->y;

    if (h->flags & DLG_CENTER)
    {
        y = (LINES - lines) / 2;
        x = (COLS - cols) / 2;
    }

    if ((h->flags & DLG_TRYUP) && (y > 3))
        y -= 2;

    dlg_set_position (h, y, x, y + lines, x + cols);
}
예제 #5
0
파일: history.c 프로젝트: BrEacK/mc
static cb_ret_t
history_dlg_reposition (Dlg_head * dlg_head)
{
    history_dlg_data *data;
    int x = 0, y, he, wi;

    /* guard checks */
    if ((dlg_head == NULL) || (dlg_head->data == NULL))
        return MSG_NOT_HANDLED;

    data = (history_dlg_data *) dlg_head->data;

    y = data->widget->y;
    he = data->count + 2;

    if (he <= y || y > (LINES - 6))
    {
        he = min (he, y - 1);
        y -= he;
    }
    else
    {
        y++;
        he = min (he, LINES - y);
    }

    if (data->widget->x > 2)
        x = data->widget->x - 2;

    wi = data->maxlen + 4;

    if ((wi + x) > COLS)
    {
        wi = min (wi, COLS);
        x = COLS - wi;
    }

    dlg_set_position (dlg_head, y, x, y + he, x + wi);

    return MSG_HANDLED;
}