mirror of
https://github.com/MidnightCommander/mc
synced 2024-12-23 12:56:51 +03:00
Merge branch '2115_input_dialog_buttons'
* 2115_input_dialog_buttons: Applied MC indentation policy. Ticket #2115: fixed button location in common input dialog.
This commit is contained in:
commit
2e973fbbbd
166
src/wtools.c
166
src/wtools.c
@ -49,8 +49,7 @@ Listbox *
|
|||||||
create_listbox_window_centered (int center_y, int center_x, int lines, int cols,
|
create_listbox_window_centered (int center_y, int center_x, int lines, int cols,
|
||||||
const char *title, const char *help)
|
const char *title, const char *help)
|
||||||
{
|
{
|
||||||
const int listbox_colors[DLG_COLOR_NUM] =
|
const int listbox_colors[DLG_COLOR_NUM] = {
|
||||||
{
|
|
||||||
MENU_ENTRY_COLOR,
|
MENU_ENTRY_COLOR,
|
||||||
MENU_SELECTED_COLOR,
|
MENU_SELECTED_COLOR,
|
||||||
MENU_HOT_COLOR,
|
MENU_HOT_COLOR,
|
||||||
@ -65,7 +64,8 @@ create_listbox_window_centered (int center_y, int center_x, int lines, int cols,
|
|||||||
/* Adjust sizes */
|
/* Adjust sizes */
|
||||||
lines = min (lines, LINES - 6);
|
lines = min (lines, LINES - 6);
|
||||||
|
|
||||||
if (title != NULL) {
|
if (title != NULL)
|
||||||
|
{
|
||||||
len = str_term_width1 (title) + 4;
|
len = str_term_width1 (title) + 4;
|
||||||
cols = max (cols, len);
|
cols = max (cols, len);
|
||||||
}
|
}
|
||||||
@ -73,10 +73,13 @@ create_listbox_window_centered (int center_y, int center_x, int lines, int cols,
|
|||||||
cols = min (cols, COLS - 6);
|
cols = min (cols, COLS - 6);
|
||||||
|
|
||||||
/* adjust position */
|
/* adjust position */
|
||||||
if ((center_y < 0) || (center_x < 0)) {
|
if ((center_y < 0) || (center_x < 0))
|
||||||
|
{
|
||||||
ypos = LINES / 2;
|
ypos = LINES / 2;
|
||||||
xpos = COLS / 2;
|
xpos = COLS / 2;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
ypos = center_y;
|
ypos = center_y;
|
||||||
xpos = center_x;
|
xpos = center_x;
|
||||||
}
|
}
|
||||||
@ -98,8 +101,7 @@ create_listbox_window_centered (int center_y, int center_x, int lines, int cols,
|
|||||||
|
|
||||||
listbox->dlg =
|
listbox->dlg =
|
||||||
create_dlg (TRUE, ypos, xpos, lines + space, cols + space,
|
create_dlg (TRUE, ypos, xpos, lines + space, cols + space,
|
||||||
listbox_colors, NULL,
|
listbox_colors, NULL, help, title, DLG_REVERSE | DLG_TRYUP);
|
||||||
help, title, DLG_REVERSE | DLG_TRYUP);
|
|
||||||
|
|
||||||
listbox->list = listbox_new (2, 2, lines, cols, FALSE, NULL);
|
listbox->list = listbox_new (2, 2, lines, cols, FALSE, NULL);
|
||||||
add_widget (listbox->dlg, listbox->list);
|
add_widget (listbox->dlg, listbox->list);
|
||||||
@ -128,10 +130,10 @@ run_listbox (Listbox *l)
|
|||||||
|
|
||||||
/* default query callback, used to reposition query */
|
/* default query callback, used to reposition query */
|
||||||
static cb_ret_t
|
static cb_ret_t
|
||||||
default_query_callback (Dlg_head *h, Widget *sender,
|
default_query_callback (Dlg_head * h, Widget * sender, dlg_msg_t msg, int parm, void *data)
|
||||||
dlg_msg_t msg, int parm, void *data)
|
{
|
||||||
|
switch (msg)
|
||||||
{
|
{
|
||||||
switch (msg) {
|
|
||||||
case DLG_RESIZE:
|
case DLG_RESIZE:
|
||||||
{
|
{
|
||||||
int xpos = COLS / 2 - h->cols / 2;
|
int xpos = COLS / 2 - h->cols / 2;
|
||||||
@ -164,15 +166,16 @@ query_dialog (const char *header, const char *text, int flags, int count, ...)
|
|||||||
int result = -1;
|
int result = -1;
|
||||||
int cols, lines;
|
int cols, lines;
|
||||||
char *cur_name;
|
char *cur_name;
|
||||||
const int *query_colors = (flags & D_ERROR) ?
|
const int *query_colors = (flags & D_ERROR) ? alarm_colors : dialog_colors;
|
||||||
alarm_colors : dialog_colors;
|
|
||||||
|
|
||||||
if (header == MSG_ERROR)
|
if (header == MSG_ERROR)
|
||||||
header = _("Error");
|
header = _("Error");
|
||||||
|
|
||||||
if (count > 0) {
|
if (count > 0)
|
||||||
|
{
|
||||||
va_start (ap, count);
|
va_start (ap, count);
|
||||||
for (i = 0; i < count; i++) {
|
for (i = 0; i < count; i++)
|
||||||
|
{
|
||||||
char *cp = va_arg (ap, char *);
|
char *cp = va_arg (ap, char *);
|
||||||
win_len += str_term_width1 (cp) + 6;
|
win_len += str_term_width1 (cp) + 6;
|
||||||
if (strchr (cp, '&') != NULL)
|
if (strchr (cp, '&') != NULL)
|
||||||
@ -191,10 +194,12 @@ query_dialog (const char *header, const char *text, int flags, int count, ...)
|
|||||||
create_dlg (TRUE, 0, 0, lines, cols, query_colors, default_query_callback,
|
create_dlg (TRUE, 0, 0, lines, cols, query_colors, default_query_callback,
|
||||||
"[QueryBox]", header, DLG_NONE);
|
"[QueryBox]", header, DLG_NONE);
|
||||||
|
|
||||||
if (count > 0) {
|
if (count > 0)
|
||||||
|
{
|
||||||
cols = (cols - win_len - 2) / 2 + 2;
|
cols = (cols - win_len - 2) / 2 + 2;
|
||||||
va_start (ap, count);
|
va_start (ap, count);
|
||||||
for (i = 0; i < count; i++) {
|
for (i = 0; i < count; i++)
|
||||||
|
{
|
||||||
int xpos;
|
int xpos;
|
||||||
|
|
||||||
cur_name = va_arg (ap, char *);
|
cur_name = va_arg (ap, char *);
|
||||||
@ -202,9 +207,7 @@ query_dialog (const char *header, const char *text, int flags, int count, ...)
|
|||||||
if (strchr (cur_name, '&') != NULL)
|
if (strchr (cur_name, '&') != NULL)
|
||||||
xpos--;
|
xpos--;
|
||||||
|
|
||||||
button =
|
button = button_new (lines - 3, cols, B_USER + i, NORMAL_BUTTON, cur_name, 0);
|
||||||
button_new (lines - 3, cols, B_USER + i, NORMAL_BUTTON,
|
|
||||||
cur_name, 0);
|
|
||||||
add_widget (query_dlg, button);
|
add_widget (query_dlg, button);
|
||||||
cols += xpos;
|
cols += xpos;
|
||||||
if (i == sel_pos)
|
if (i == sel_pos)
|
||||||
@ -221,7 +224,8 @@ query_dialog (const char *header, const char *text, int flags, int count, ...)
|
|||||||
dlg_select_widget (defbutton);
|
dlg_select_widget (defbutton);
|
||||||
|
|
||||||
/* run dialog and make result */
|
/* run dialog and make result */
|
||||||
switch (run_dlg (query_dlg)) {
|
switch (run_dlg (query_dlg))
|
||||||
|
{
|
||||||
case B_CANCEL:
|
case B_CANCEL:
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -230,17 +234,19 @@ query_dialog (const char *header, const char *text, int flags, int count, ...)
|
|||||||
|
|
||||||
/* free used memory */
|
/* free used memory */
|
||||||
destroy_dlg (query_dlg);
|
destroy_dlg (query_dlg);
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
add_widget (query_dlg, label_new (2, 3, text));
|
add_widget (query_dlg, label_new (2, 3, text));
|
||||||
add_widget (query_dlg,
|
add_widget (query_dlg, button_new (0, 0, 0, HIDDEN_BUTTON, "-", 0));
|
||||||
button_new (0, 0, 0, HIDDEN_BUTTON, "-", 0));
|
|
||||||
last_query_dlg = query_dlg;
|
last_query_dlg = query_dlg;
|
||||||
}
|
}
|
||||||
sel_pos = 0;
|
sel_pos = 0;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void query_set_sel (int new_sel)
|
void
|
||||||
|
query_set_sel (int new_sel)
|
||||||
{
|
{
|
||||||
sel_pos = new_sel;
|
sel_pos = new_sel;
|
||||||
}
|
}
|
||||||
@ -325,7 +331,8 @@ message (int flags, const char *title, const char *text, ...)
|
|||||||
{
|
{
|
||||||
char *p;
|
char *p;
|
||||||
va_list ap;
|
va_list ap;
|
||||||
union {
|
union
|
||||||
|
{
|
||||||
void *p;
|
void *p;
|
||||||
void (*f) (int, int *, char *, const char *);
|
void (*f) (int, int *, char *, const char *);
|
||||||
} func;
|
} func;
|
||||||
@ -338,11 +345,12 @@ message (int flags, const char *title, const char *text, ...)
|
|||||||
title = _("Error");
|
title = _("Error");
|
||||||
|
|
||||||
#ifdef WITH_BACKGROUND
|
#ifdef WITH_BACKGROUND
|
||||||
if (we_are_background) {
|
if (we_are_background)
|
||||||
|
{
|
||||||
func.f = bg_message;
|
func.f = bg_message;
|
||||||
parent_call (func.p, NULL, 3, sizeof (flags), &flags,
|
parent_call (func.p, NULL, 3, sizeof (flags), &flags, strlen (title), title, strlen (p), p);
|
||||||
strlen (title), title, strlen (p), p);
|
}
|
||||||
} else
|
else
|
||||||
#endif /* WITH_BACKGROUND */
|
#endif /* WITH_BACKGROUND */
|
||||||
fg_message (flags, title, p);
|
fg_message (flags, title, p);
|
||||||
|
|
||||||
@ -367,8 +375,7 @@ quick_dialog_skip (QuickDialog *qd, int nskip)
|
|||||||
WRadio *r;
|
WRadio *r;
|
||||||
int return_val;
|
int return_val;
|
||||||
|
|
||||||
const int input_colors[3] =
|
const int input_colors[3] = {
|
||||||
{
|
|
||||||
INPUT_COLOR,
|
INPUT_COLOR,
|
||||||
INPUT_UNCHANGED_COLOR,
|
INPUT_UNCHANGED_COLOR,
|
||||||
INPUT_MARK_COLOR
|
INPUT_MARK_COLOR
|
||||||
@ -382,24 +389,28 @@ quick_dialog_skip (QuickDialog *qd, int nskip)
|
|||||||
DLG_CENTER | DLG_TRYUP | DLG_REVERSE);
|
DLG_CENTER | DLG_TRYUP | DLG_REVERSE);
|
||||||
else
|
else
|
||||||
dd = create_dlg (TRUE, qd->ypos, qd->xpos, qd->ylen, qd->xlen,
|
dd = create_dlg (TRUE, qd->ypos, qd->xpos, qd->ylen, qd->xlen,
|
||||||
dialog_colors, NULL, qd->help, qd->title,
|
dialog_colors, NULL, qd->help, qd->title, DLG_REVERSE);
|
||||||
DLG_REVERSE);
|
|
||||||
|
|
||||||
for (qw = qd->widgets; qw->widget_type != quick_end; qw++) {
|
for (qw = qd->widgets; qw->widget_type != quick_end; qw++)
|
||||||
|
{
|
||||||
int xpos;
|
int xpos;
|
||||||
int ypos;
|
int ypos;
|
||||||
|
|
||||||
xpos = (qd->xlen * qw->relative_x) / qw->x_divisions;
|
xpos = (qd->xlen * qw->relative_x) / qw->x_divisions;
|
||||||
ypos = (qd->ylen * qw->relative_y) / qw->y_divisions;
|
ypos = (qd->ylen * qw->relative_y) / qw->y_divisions;
|
||||||
|
|
||||||
switch (qw->widget_type) {
|
switch (qw->widget_type)
|
||||||
|
{
|
||||||
case quick_checkbox:
|
case quick_checkbox:
|
||||||
qw->widget = (Widget *) check_new (ypos, xpos, *qw->u.checkbox.state, I18N (qw->u.checkbox.text));
|
qw->widget =
|
||||||
|
(Widget *) check_new (ypos, xpos, *qw->u.checkbox.state,
|
||||||
|
I18N (qw->u.checkbox.text));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case quick_button:
|
case quick_button:
|
||||||
qw->widget = (Widget *) button_new (ypos, xpos, qw->u.button.action,
|
qw->widget = (Widget *) button_new (ypos, xpos, qw->u.button.action,
|
||||||
(qw->u.button.action == B_ENTER) ? DEFPUSH_BUTTON : NORMAL_BUTTON,
|
(qw->u.button.action ==
|
||||||
|
B_ENTER) ? DEFPUSH_BUTTON : NORMAL_BUTTON,
|
||||||
I18N (qw->u.button.text), qw->u.button.callback);
|
I18N (qw->u.button.text), qw->u.button.callback);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -462,9 +473,12 @@ quick_dialog_skip (QuickDialog *qd, int nskip)
|
|||||||
return_val = run_dlg (dd);
|
return_val = run_dlg (dd);
|
||||||
|
|
||||||
/* Get the data if we found something interesting */
|
/* Get the data if we found something interesting */
|
||||||
if (return_val != B_CANCEL) {
|
if (return_val != B_CANCEL)
|
||||||
for (qw = qd->widgets; qw->widget_type != quick_end; qw++) {
|
{
|
||||||
switch (qw->widget_type) {
|
for (qw = qd->widgets; qw->widget_type != quick_end; qw++)
|
||||||
|
{
|
||||||
|
switch (qw->widget_type)
|
||||||
|
{
|
||||||
case quick_checkbox:
|
case quick_checkbox:
|
||||||
*qw->u.checkbox.state = ((WCheck *) qw->widget)->state & C_BOOL;
|
*qw->u.checkbox.state = ((WCheck *) qw->widget)->state & C_BOOL;
|
||||||
break;
|
break;
|
||||||
@ -520,13 +534,14 @@ fg_input_dialog_help (const char *header, const char *text, const char *help,
|
|||||||
char *my_str;
|
char *my_str;
|
||||||
|
|
||||||
QuickWidget quick_widgets[] = {
|
QuickWidget quick_widgets[] = {
|
||||||
/* 0 */ QUICK_BUTTON (6, 10, 1, 0, N_("&Cancel"), B_CANCEL, NULL),
|
/* 0 */ QUICK_BUTTON (6, 64, 1, 0, N_("&Cancel"), B_CANCEL, NULL),
|
||||||
/* 1 */ QUICK_BUTTON (3, 10, 1, 0, N_("&OK"), B_ENTER, NULL),
|
/* 1 */ QUICK_BUTTON (3, 64, 1, 0, N_("&OK"), B_ENTER, NULL),
|
||||||
/* 2 */ QUICK_INPUT (3, 80, 0, 0, def_text, 58, 0, NULL, &my_str),
|
/* 2 */ QUICK_INPUT (3, 64, 0, 0, def_text, 58, 0, NULL, &my_str),
|
||||||
/* 3 */ QUICK_LABEL (3, 80, 2, 0, ""),
|
/* 3 */ QUICK_LABEL (3, 64, 2, 0, ""),
|
||||||
QUICK_END
|
QUICK_END
|
||||||
};
|
};
|
||||||
|
|
||||||
|
int b0_len, b1_len, b_len, gap;
|
||||||
char histname[64] = "inp|";
|
char histname[64] = "inp|";
|
||||||
int lines, cols;
|
int lines, cols;
|
||||||
int len;
|
int len;
|
||||||
@ -534,46 +549,54 @@ fg_input_dialog_help (const char *header, const char *text, const char *help,
|
|||||||
char *p_text;
|
char *p_text;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (history_name != NULL && *history_name != '\0') {
|
/* buttons */
|
||||||
|
#ifdef ENABLE_NLS
|
||||||
|
quick_widgets[0].u.button.text = _(quick_widgets[0].u.button.text);
|
||||||
|
quick_widgets[1].u.button.text = _(quick_widgets[1].u.button.text);
|
||||||
|
#endif /* ENABLE_NLS */
|
||||||
|
|
||||||
|
b0_len = str_term_width1 (quick_widgets[0].u.button.text) + 3;
|
||||||
|
b1_len = str_term_width1 (quick_widgets[1].u.button.text) + 5; /* default button */
|
||||||
|
b_len = b0_len + b1_len + 2; /* including gap */
|
||||||
|
|
||||||
|
/* input line */
|
||||||
|
if (history_name != NULL && *history_name != '\0')
|
||||||
|
{
|
||||||
g_strlcpy (histname + 3, history_name, sizeof (histname) - 3);
|
g_strlcpy (histname + 3, history_name, sizeof (histname) - 3);
|
||||||
quick_widgets[2].u.input.histname = histname;
|
quick_widgets[2].u.input.histname = histname;
|
||||||
}
|
}
|
||||||
|
|
||||||
msglen (text, &lines, &cols);
|
|
||||||
len = max (max (str_term_width1 (header), cols) + 4, 64);
|
|
||||||
|
|
||||||
/* The special value of def_text is used to identify password boxes
|
/* The special value of def_text is used to identify password boxes
|
||||||
and hide characters with "*". Don't save passwords in history! */
|
and hide characters with "*". Don't save passwords in history! */
|
||||||
if (def_text == INPUT_PASSWORD) {
|
if (def_text == INPUT_PASSWORD)
|
||||||
|
{
|
||||||
quick_widgets[2].u.input.flags = 1;
|
quick_widgets[2].u.input.flags = 1;
|
||||||
histname[3] = '\0';
|
histname[3] = '\0';
|
||||||
quick_widgets[2].u.input.text = "";
|
quick_widgets[2].u.input.text = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef ENABLE_NLS
|
/* text */
|
||||||
/*
|
|
||||||
* An attempt to place buttons symmetrically, based on actual i18n
|
|
||||||
* length of the string. It looks nicer with i18n (IMO) - alex
|
|
||||||
*/
|
|
||||||
quick_widgets[0].u.button.text = _(quick_widgets[0].u.button.text);
|
|
||||||
quick_widgets[1].u.button.text = _(quick_widgets[1].u.button.text);
|
|
||||||
quick_widgets[0].relative_x = len / 2 + 4;
|
|
||||||
quick_widgets[1].relative_x =
|
|
||||||
len / 2 - (str_term_width1 (quick_widgets[1].u.button.text) + 9);
|
|
||||||
quick_widgets[0].x_divisions = quick_widgets[1].x_divisions = len;
|
|
||||||
#endif /* ENABLE_NLS */
|
|
||||||
|
|
||||||
p_text = g_strstrip (g_strdup (text));
|
p_text = g_strstrip (g_strdup (text));
|
||||||
|
msglen (p_text, &lines, &cols);
|
||||||
quick_widgets[3].u.label.text = p_text;
|
quick_widgets[3].u.label.text = p_text;
|
||||||
|
|
||||||
|
/* dialog width */
|
||||||
|
len = max (max (str_term_width1 (header), cols) + 4, 64);
|
||||||
|
len = min (max (len, b_len + 6), COLS);
|
||||||
|
|
||||||
|
/* button locations */
|
||||||
|
gap = (len - 8 - b_len) / 3;
|
||||||
|
quick_widgets[1].relative_x = 3 + gap;
|
||||||
|
quick_widgets[0].relative_x = quick_widgets[1].relative_x + b1_len + gap + 2;
|
||||||
|
|
||||||
{
|
{
|
||||||
QuickDialog Quick_input =
|
QuickDialog Quick_input = {
|
||||||
{
|
|
||||||
len, lines + 6, -1, -1, header,
|
len, lines + 6, -1, -1, header,
|
||||||
help, quick_widgets, TRUE
|
help, quick_widgets, TRUE
|
||||||
};
|
};
|
||||||
|
|
||||||
for (i = 0; i < 4; i++) {
|
for (i = 0; i < 4; i++)
|
||||||
|
{
|
||||||
quick_widgets[i].x_divisions = Quick_input.xlen;
|
quick_widgets[i].x_divisions = Quick_input.xlen;
|
||||||
quick_widgets[i].y_divisions = Quick_input.ylen;
|
quick_widgets[i].y_divisions = Quick_input.ylen;
|
||||||
}
|
}
|
||||||
@ -602,10 +625,10 @@ char *
|
|||||||
input_dialog_help (const char *header, const char *text, const char *help,
|
input_dialog_help (const char *header, const char *text, const char *help,
|
||||||
const char *history_name, const char *def_text)
|
const char *history_name, const char *def_text)
|
||||||
{
|
{
|
||||||
union {
|
union
|
||||||
|
{
|
||||||
void *p;
|
void *p;
|
||||||
char * (*f) (const char *, const char *, const char *,
|
char *(*f) (const char *, const char *, const char *, const char *, const char *);
|
||||||
const char *, const char *);
|
|
||||||
} func;
|
} func;
|
||||||
#ifdef WITH_BACKGROUND
|
#ifdef WITH_BACKGROUND
|
||||||
if (we_are_background)
|
if (we_are_background)
|
||||||
@ -623,8 +646,8 @@ input_dialog_help (const char *header, const char *text, const char *help,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Show input dialog with default help, background safe */
|
/* Show input dialog with default help, background safe */
|
||||||
char *input_dialog (const char *header, const char *text,
|
char *
|
||||||
const char *history_name, const char *def_text)
|
input_dialog (const char *header, const char *text, const char *history_name, const char *def_text)
|
||||||
{
|
{
|
||||||
return input_dialog_help (header, text, "[Input Line Keys]", history_name, def_text);
|
return input_dialog_help (header, text, "[Input Line Keys]", history_name, def_text);
|
||||||
}
|
}
|
||||||
@ -637,7 +660,8 @@ input_expand_dialog (const char *header, const char *text,
|
|||||||
char *expanded;
|
char *expanded;
|
||||||
|
|
||||||
result = input_dialog (header, text, history_name, def_text);
|
result = input_dialog (header, text, history_name, def_text);
|
||||||
if (result) {
|
if (result)
|
||||||
|
{
|
||||||
expanded = tilde_expand (result);
|
expanded = tilde_expand (result);
|
||||||
g_free (result);
|
g_free (result);
|
||||||
return expanded;
|
return expanded;
|
||||||
|
40
src/wtools.h
40
src/wtools.h
@ -10,7 +10,8 @@
|
|||||||
#include "dialog.h"
|
#include "dialog.h"
|
||||||
#include "widget.h"
|
#include "widget.h"
|
||||||
|
|
||||||
typedef struct {
|
typedef struct
|
||||||
|
{
|
||||||
struct Dlg_head *dlg;
|
struct Dlg_head *dlg;
|
||||||
struct WListbox *list;
|
struct WListbox *list;
|
||||||
} Listbox;
|
} Listbox;
|
||||||
@ -25,7 +26,8 @@ Listbox *create_listbox_window (int lines, int cols, const char *title, const ch
|
|||||||
int run_listbox (Listbox * l);
|
int run_listbox (Listbox * l);
|
||||||
|
|
||||||
/* Quick Widgets */
|
/* Quick Widgets */
|
||||||
typedef enum {
|
typedef enum
|
||||||
|
{
|
||||||
quick_end = 0,
|
quick_end = 0,
|
||||||
quick_checkbox = 1,
|
quick_checkbox = 1,
|
||||||
quick_button = 2,
|
quick_button = 2,
|
||||||
@ -36,7 +38,8 @@ typedef enum {
|
|||||||
} quick_t;
|
} quick_t;
|
||||||
|
|
||||||
/* The widget is placed on relative_?/divisions_? of the parent widget */
|
/* The widget is placed on relative_?/divisions_? of the parent widget */
|
||||||
typedef struct {
|
typedef struct
|
||||||
|
{
|
||||||
quick_t widget_type;
|
quick_t widget_type;
|
||||||
|
|
||||||
int relative_x;
|
int relative_x;
|
||||||
@ -47,19 +50,23 @@ typedef struct {
|
|||||||
Widget *widget;
|
Widget *widget;
|
||||||
|
|
||||||
/* widget parameters */
|
/* widget parameters */
|
||||||
union {
|
union
|
||||||
struct {
|
{
|
||||||
|
struct
|
||||||
|
{
|
||||||
const char *text;
|
const char *text;
|
||||||
int *state; /* in/out */
|
int *state; /* in/out */
|
||||||
} checkbox;
|
} checkbox;
|
||||||
|
|
||||||
struct {
|
struct
|
||||||
|
{
|
||||||
const char *text;
|
const char *text;
|
||||||
int action;
|
int action;
|
||||||
bcback callback;
|
bcback callback;
|
||||||
} button;
|
} button;
|
||||||
|
|
||||||
struct {
|
struct
|
||||||
|
{
|
||||||
const char *text;
|
const char *text;
|
||||||
int len;
|
int len;
|
||||||
int flags; /* 1 -- is_password, 2 -- INPUT_COMPLETE_CD */
|
int flags; /* 1 -- is_password, 2 -- INPUT_COMPLETE_CD */
|
||||||
@ -67,17 +74,20 @@ typedef struct {
|
|||||||
char **result;
|
char **result;
|
||||||
} input;
|
} input;
|
||||||
|
|
||||||
struct {
|
struct
|
||||||
|
{
|
||||||
const char *text;
|
const char *text;
|
||||||
} label;
|
} label;
|
||||||
|
|
||||||
struct {
|
struct
|
||||||
|
{
|
||||||
int count;
|
int count;
|
||||||
const char **items;
|
const char **items;
|
||||||
int *value; /* in/out */
|
int *value; /* in/out */
|
||||||
} radio;
|
} radio;
|
||||||
|
|
||||||
struct {
|
struct
|
||||||
|
{
|
||||||
int width;
|
int width;
|
||||||
int height;
|
int height;
|
||||||
const char *title;
|
const char *title;
|
||||||
@ -186,6 +196,7 @@ typedef struct {
|
|||||||
} \
|
} \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#define QUICK_END \
|
#define QUICK_END \
|
||||||
{ \
|
{ \
|
||||||
.widget_type = quick_end, \
|
.widget_type = quick_end, \
|
||||||
@ -205,7 +216,8 @@ typedef struct {
|
|||||||
} \
|
} \
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef struct {
|
typedef struct
|
||||||
|
{
|
||||||
int xlen, ylen;
|
int xlen, ylen;
|
||||||
int xpos, ypos; /* if -1, then center the dialog */
|
int xpos, ypos; /* if -1, then center the dialog */
|
||||||
const char *title;
|
const char *title;
|
||||||
@ -233,8 +245,7 @@ void query_set_sel (int new_sel);
|
|||||||
|
|
||||||
/* Create message box but don't dismiss it yet, not background safe */
|
/* Create message box but don't dismiss it yet, not background safe */
|
||||||
struct Dlg_head *create_message (int flags, const char *title,
|
struct Dlg_head *create_message (int flags, const char *title,
|
||||||
const char *text, ...)
|
const char *text, ...) __attribute__ ((format (__printf__, 3, 4)));
|
||||||
__attribute__ ((format (__printf__, 3, 4)));
|
|
||||||
|
|
||||||
/* Show message box, background safe */
|
/* Show message box, background safe */
|
||||||
void message (int flags, const char *title, const char *text, ...)
|
void message (int flags, const char *title, const char *text, ...)
|
||||||
@ -247,7 +258,8 @@ void message (int flags, const char *title, const char *text, ...)
|
|||||||
int query_dialog (const char *header, const char *text, int flags, int count, ...);
|
int query_dialog (const char *header, const char *text, int flags, int count, ...);
|
||||||
|
|
||||||
/* flags for message() and query_dialog() */
|
/* flags for message() and query_dialog() */
|
||||||
enum {
|
enum
|
||||||
|
{
|
||||||
D_NORMAL = 0,
|
D_NORMAL = 0,
|
||||||
D_ERROR = 1
|
D_ERROR = 1
|
||||||
} /* dialog options */ ;
|
} /* dialog options */ ;
|
||||||
|
Loading…
Reference in New Issue
Block a user