Original patch as attached on the bugreport
[midnight-commander.git] / src / wtools.h
blobe6e0e163e36a2972172f533af80277038cdcc5b0
1 #ifndef MC_WTOOLS_H
2 #define MC_WTOOLS_H
4 #include "widget.h"
6 typedef struct {
7 struct Dlg_head *dlg;
8 struct WListbox *list;
9 } Listbox;
11 /* Listbox utility functions */
12 Listbox *create_listbox_window (int cols, int lines, const char *title, const char *help);
13 #define LISTBOX_APPEND_TEXT(l,h,t,d) \
14 listbox_add_item (l->list, LISTBOX_APPEND_AT_END, h, t, d)
16 int run_listbox (Listbox *l);
18 /* Quick Widgets */
19 enum {
20 quick_end, quick_checkbox,
21 quick_button, quick_input,
22 quick_label, quick_radio
23 } /* quick_t */;
25 /* The widget is placed on relative_?/divisions_? of the parent widget */
27 typedef struct {
28 int widget_type;
29 int relative_x;
30 int x_divisions;
31 int relative_y;
32 int y_divisions;
34 const char *text; /* Text */
35 int hotkey_pos; /* the hotkey position */
36 int value; /* Buttons only: value of button */
37 int *result; /* Checkbutton: where to store result */
38 char **str_result; /* Input lines: destination */
39 const char *histname; /* Name of the section for saving history */
40 } QuickWidget;
41 #define NULL_QuickWidget { 0, 0, 0, 0, 0, NULL, 0, 0, NULL, NULL, NULL }
43 typedef struct {
44 int xlen, ylen;
45 int xpos, ypos; /* if -1, then center the dialog */
46 const char *title;
47 const char *help;
48 QuickWidget *widgets;
49 int i18n; /* If true, internationalization has happened */
50 } QuickDialog;
52 int quick_dialog (QuickDialog *qd);
53 int quick_dialog_skip (QuickDialog *qd, int nskip);
55 /* The input dialogs */
57 /* Pass this as def_text to request a password */
58 #define INPUT_PASSWORD ((char *) -1)
60 char *input_dialog (const char *header, const char *text,
61 const char *history_name, const char *def_text);
62 char *input_dialog_help (const char *header, const char *text, const char *help,
63 const char *history_name, const char *def_text);
64 char *input_expand_dialog (const char *header, const char *text,
65 const char *history_name, const char *def_text);
67 void query_set_sel (int new_sel);
69 /* Create message box but don't dismiss it yet, not background safe */
70 struct Dlg_head *create_message (int flags, const char *title,
71 const char *text, ...)
72 __attribute__ ((format (__printf__, 3, 4)));
74 /* Show message box, background safe */
75 void message (int flags, const char *title, const char *text, ...)
76 __attribute__ ((format (__printf__, 3, 4)));
79 /* Use this as header for message() - it expands to "Error" */
80 #define MSG_ERROR ((char *) -1)
82 int query_dialog (const char *header, const char *text, int flags, int count, ...);
84 /* flags for message() and query_dialog() */
85 enum {
86 D_NORMAL = 0,
87 D_ERROR = 1
88 } /* dialog options */;
90 #endif