Merge branch '2833_url_port_in_history'
[midnight-commander.git] / lib / widget / quick.h
blobba852a4f22c2a1b7b831cc1bcfa6b75cbe960361
1 /** \file quick.h
2 * \brief Header: quick dialog engine
3 */
5 #ifndef MC__QUICK_H
6 #define MC__QUICK_H
8 #include "lib/tty/mouse.h"
10 /*** typedefs(not structures) and defined constants **********************************************/
12 #define QUICK_CHECKBOX(x, xdiv, y, ydiv, txt, st) \
13 { \
14 .widget_type = quick_checkbox, \
15 .relative_x = x, \
16 .x_divisions = xdiv, \
17 .relative_y = y, \
18 .y_divisions = ydiv, \
19 .widget = NULL, \
20 .options = 0, \
21 .u = { \
22 .checkbox = { \
23 .text = txt, \
24 .state = st \
25 } \
26 } \
29 #define QUICK_BUTTON(x, xdiv, y, ydiv, txt, act, cb) \
30 { \
31 .widget_type = quick_button, \
32 .relative_x = x, \
33 .x_divisions = xdiv, \
34 .relative_y = y, \
35 .y_divisions = ydiv, \
36 .widget = NULL, \
37 .options = 0, \
38 .u = { \
39 .button = { \
40 .text = txt, \
41 .action = act, \
42 .callback = cb \
43 } \
44 } \
47 #define QUICK_INPUT(x, xdiv, y, ydiv, txt, len_, flags_, hname, res) \
48 { \
49 .widget_type = quick_input, \
50 .relative_x = x, \
51 .x_divisions = xdiv, \
52 .relative_y = y, \
53 .y_divisions = ydiv, \
54 .widget = NULL, \
55 .options = 0, \
56 .u = { \
57 .input = { \
58 .text = txt, \
59 .len = len_, \
60 .flags = flags_, \
61 .histname = hname, \
62 .result = res \
63 } \
64 } \
67 #define QUICK_LABEL(x, xdiv, y, ydiv, txt) \
68 { \
69 .widget_type = quick_label, \
70 .relative_x = x, \
71 .x_divisions = xdiv, \
72 .relative_y = y, \
73 .y_divisions = ydiv, \
74 .widget = NULL, \
75 .options = 0, \
76 .u = { \
77 .label = { \
78 .text = txt \
79 } \
80 } \
83 #define QUICK_RADIO(x, xdiv, y, ydiv, cnt, items_, val) \
84 { \
85 .widget_type = quick_radio, \
86 .relative_x = x, \
87 .x_divisions = xdiv, \
88 .relative_y = y, \
89 .y_divisions = ydiv, \
90 .widget = NULL, \
91 .options = 0, \
92 .u = { \
93 .radio = { \
94 .count = cnt, \
95 .items = items_, \
96 .value = val \
97 } \
98 } \
101 #define QUICK_GROUPBOX(x, xdiv, y, ydiv, w, h, t) \
103 .widget_type = quick_groupbox, \
104 .relative_x = x, \
105 .x_divisions = xdiv, \
106 .relative_y = y, \
107 .y_divisions = ydiv, \
108 .widget = NULL, \
109 .options = 0, \
110 .u = { \
111 .groupbox = { \
112 .width = w, \
113 .height = h, \
114 .title = t \
119 #define QUICK_END \
121 .widget_type = quick_end, \
122 .relative_x = 0, \
123 .x_divisions = 0, \
124 .relative_y = 0, \
125 .y_divisions = 0, \
126 .widget = NULL, \
127 .options = 0, \
128 .u = { \
129 .input = { \
130 .text = NULL, \
131 .len = 0, \
132 .flags = 0, \
133 .histname = NULL, \
134 .result = NULL \
139 /*** enums ***************************************************************************************/
141 /* Quick Widgets */
142 typedef enum
144 quick_end = 0,
145 quick_checkbox = 1,
146 quick_button = 2,
147 quick_input = 3,
148 quick_label = 4,
149 quick_radio = 5,
150 quick_groupbox = 6
151 } quick_t;
153 /*** structures declarations (and typedefs of structures)*****************************************/
155 /* The widget is placed on relative_?/divisions_? of the parent widget */
156 typedef struct
158 quick_t widget_type;
160 int relative_x;
161 int x_divisions;
162 int relative_y;
163 int y_divisions;
165 Widget *widget;
166 widget_options_t options;
168 /* widget parameters */
169 union
171 struct
173 const char *text;
174 int *state; /* in/out */
175 } checkbox;
177 struct
179 const char *text;
180 int action;
181 bcback_fn callback;
182 } button;
184 struct
186 const char *text;
187 int len;
188 int flags; /* 1 -- is_password, 2 -- INPUT_COMPLETE_CD */
189 const char *histname;
190 char **result;
191 gboolean strip_password;
192 } input;
194 struct
196 const char *text;
197 } label;
199 struct
201 int count;
202 const char **items;
203 int *value; /* in/out */
204 } radio;
206 struct
208 int width;
209 int height;
210 const char *title;
211 } groupbox;
212 } u;
213 } QuickWidget;
215 typedef struct
217 int xlen, ylen;
218 int xpos, ypos; /* if -1, then center the dialog */
219 const char *title;
220 const char *help;
221 QuickWidget *widgets;
222 dlg_cb_fn callback;
223 mouse_h mouse;
224 gboolean i18n; /* If true, internationalization has happened */
225 } QuickDialog;
227 /*** global variables defined in .c file *********************************************************/
229 /*** declarations of public functions ************************************************************/
231 int quick_dialog_skip (QuickDialog * qd, int nskip);
233 /*** inline functions ****************************************************************************/
235 static inline int
236 quick_dialog (QuickDialog * qd)
238 return quick_dialog_skip (qd, 0);
241 #endif /* MC__QUICK_H */