This source file includes following definitions.
- quick_dialog
1
2
3
4
5 #ifndef MC__QUICK_H
6 #define MC__QUICK_H
7
8
9
10
11
12 #define QUICK_CHECKBOX(txt, st, id_) \
13 { \
14 .widget_type = quick_checkbox, \
15 .options = WOP_DEFAULT, \
16 .pos_flags = WPOS_KEEP_DEFAULT, \
17 .id = id_, \
18 .u = { \
19 .checkbox = { \
20 .text = txt, \
21 .state = st, \
22 }, \
23 }, \
24 }
25
26 #define QUICK_BUTTON(txt, act, cb, id_) \
27 { \
28 .widget_type = quick_button, \
29 .options = WOP_DEFAULT, \
30 .pos_flags = WPOS_KEEP_DEFAULT, \
31 .id = id_, \
32 .u = { \
33 .button = { \
34 .text = txt, \
35 .action = act, \
36 .callback = cb, \
37 }, \
38 }, \
39 }
40
41 #define QUICK_INPUT(txt, hname, res, id_, is_passwd_, strip_passwd_, completion_flags_) \
42 { \
43 .widget_type = quick_input, \
44 .options = WOP_DEFAULT, \
45 .pos_flags = WPOS_KEEP_DEFAULT, \
46 .id = id_, \
47 .u = { \
48 .input = { \
49 .label_text = NULL, \
50 .label_location = input_label_none, \
51 .label = NULL, \
52 .text = txt, \
53 .completion_flags = completion_flags_, \
54 .is_passwd = is_passwd_, \
55 .strip_passwd = strip_passwd_, \
56 .histname = hname, \
57 .result = res, \
58 }, \
59 }, \
60 }
61
62 #define QUICK_LABELED_INPUT(label_, label_loc, txt, hname, res, id_, is_passwd_, strip_passwd_, \
63 completion_flags_) \
64 { \
65 .widget_type = quick_input, \
66 .options = WOP_DEFAULT, \
67 .pos_flags = WPOS_KEEP_DEFAULT, \
68 .id = id_, \
69 .u = { \
70 .input = { \
71 .label_text = label_, \
72 .label_location = label_loc, \
73 .label = NULL, \
74 .text = txt, \
75 .completion_flags = completion_flags_, \
76 .is_passwd = is_passwd_, \
77 .strip_passwd = strip_passwd_, \
78 .histname = hname, \
79 .result = res, \
80 }, \
81 }, \
82 }
83
84 #define QUICK_LABEL(txt, id_) \
85 { \
86 .widget_type = quick_label, \
87 .options = WOP_DEFAULT, \
88 .pos_flags = WPOS_KEEP_DEFAULT, \
89 .id = id_, \
90 .u = { \
91 .label = { \
92 .text = txt, \
93 .input = NULL, \
94 }, \
95 }, \
96 }
97
98 #define QUICK_RADIO(cnt, items_, val, id_) \
99 { \
100 .widget_type = quick_radio, \
101 .options = WOP_DEFAULT, \
102 .pos_flags = WPOS_KEEP_DEFAULT, \
103 .id = id_, \
104 .u = { \
105 .radio = { \
106 .count = cnt, \
107 .items = items_, \
108 .value = val, \
109 }, \
110 }, \
111 }
112
113 #define QUICK_START_GROUPBOX(t) \
114 { \
115 .widget_type = quick_start_groupbox, \
116 .options = WOP_DEFAULT, \
117 .pos_flags = WPOS_KEEP_DEFAULT, \
118 .id = NULL, \
119 .u = { \
120 .groupbox = { \
121 .title = t, \
122 }, \
123 }, \
124 }
125
126 #define QUICK_STOP_GROUPBOX \
127 { \
128 .widget_type = quick_stop_groupbox, \
129 .options = WOP_DEFAULT, \
130 .pos_flags = WPOS_KEEP_DEFAULT, \
131 .id = NULL, \
132 .u = { \
133 .input = { \
134 .text = NULL, \
135 .histname = NULL, \
136 .result = NULL, \
137 }, \
138 }, \
139 }
140
141 #define QUICK_SEPARATOR(line_) \
142 { \
143 .widget_type = quick_separator, \
144 .options = WOP_DEFAULT, \
145 .pos_flags = WPOS_KEEP_DEFAULT, \
146 .id = NULL, \
147 .u = { \
148 .separator = { \
149 .space = TRUE, \
150 .line = line_, \
151 }, \
152 }, \
153 }
154
155 #define QUICK_START_COLUMNS \
156 { \
157 .widget_type = quick_start_columns, \
158 .options = WOP_DEFAULT, \
159 .pos_flags = WPOS_KEEP_DEFAULT, \
160 .id = NULL, \
161 .u = { \
162 .input = { \
163 .text = NULL, \
164 .histname = NULL, \
165 .result = NULL, \
166 }, \
167 }, \
168 }
169
170 #define QUICK_NEXT_COLUMN \
171 { \
172 .widget_type = quick_next_column, \
173 .options = WOP_DEFAULT, \
174 .pos_flags = WPOS_KEEP_DEFAULT, \
175 .id = NULL, \
176 .u = { \
177 .input = { \
178 .text = NULL, \
179 .histname = NULL, \
180 .result = NULL, \
181 }, \
182 }, \
183 }
184
185 #define QUICK_STOP_COLUMNS \
186 { \
187 .widget_type = quick_stop_columns, \
188 .options = WOP_DEFAULT, \
189 .pos_flags = WPOS_KEEP_DEFAULT, \
190 .id = NULL, \
191 .u = { \
192 .input = { \
193 .text = NULL, \
194 .histname = NULL, \
195 .result = NULL, \
196 }, \
197 }, \
198 }
199
200 #define QUICK_START_BUTTONS(space_, line_) \
201 { \
202 .widget_type = quick_buttons, \
203 .options = WOP_DEFAULT, \
204 .pos_flags = WPOS_KEEP_DEFAULT, \
205 .id = NULL, \
206 .u = { \
207 .separator = { \
208 .space = space_, \
209 .line = line_, \
210 }, \
211 }, \
212 }
213
214 #define QUICK_BUTTONS_OK_CANCEL \
215 QUICK_START_BUTTONS (TRUE, TRUE), \
216 QUICK_BUTTON (N_ ("&OK"), B_ENTER, NULL, NULL), \
217 QUICK_BUTTON (N_ ("&Cancel"), B_CANCEL, NULL, NULL)
218
219 #define QUICK_END \
220 { \
221 .widget_type = quick_end, \
222 .options = WOP_DEFAULT, \
223 .pos_flags = WPOS_KEEP_DEFAULT, \
224 .id = NULL, \
225 .u = { \
226 .input = { \
227 .text = NULL, \
228 .histname = NULL, \
229 .result = NULL, \
230 }, \
231 }, \
232 }
233
234
235
236
237
238
239 typedef enum
240 {
241 quick_end = 0,
242 quick_checkbox = 1,
243 quick_button = 2,
244 quick_input = 3,
245 quick_label = 4,
246 quick_radio = 5,
247 quick_start_groupbox = 6,
248 quick_stop_groupbox = 7,
249 quick_separator = 8,
250 quick_start_columns = 9,
251 quick_next_column = 10,
252 quick_stop_columns = 11,
253 quick_buttons = 12
254 } quick_t;
255
256 typedef enum
257 {
258 input_label_none = 0,
259 input_label_above = 1,
260 input_label_left = 2,
261 input_label_right = 3,
262 input_label_below = 4
263 } quick_input_label_location_t;
264
265
266
267
268 typedef struct quick_widget_t quick_widget_t;
269
270 struct quick_widget_t
271 {
272 quick_t widget_type;
273
274 widget_options_t options;
275 widget_state_t state;
276 widget_pos_flags_t pos_flags;
277 unsigned long *id;
278
279
280 union
281 {
282 struct
283 {
284 const char *text;
285 gboolean *state;
286 } checkbox;
287
288 struct
289 {
290 const char *text;
291 int action;
292 bcback_fn callback;
293 } button;
294
295 struct
296 {
297 const char *label_text;
298 quick_input_label_location_t label_location;
299 quick_widget_t *label;
300 const char *text;
301 input_complete_t completion_flags;
302 gboolean is_passwd;
303 gboolean strip_passwd;
304 const char *histname;
305 char **result;
306 } input;
307
308 struct
309 {
310 const char *text;
311 quick_widget_t *input;
312 } label;
313
314 struct
315 {
316 int count;
317 const char **items;
318 int *value;
319 } radio;
320
321 struct
322 {
323 const char *title;
324 } groupbox;
325
326 struct
327 {
328 gboolean space;
329 gboolean line;
330 } separator;
331 } u;
332 };
333
334 typedef struct
335 {
336 WRect rect;
337
338 const char *title;
339 const char *help;
340 quick_widget_t *widgets;
341 widget_cb_fn callback;
342 widget_mouse_cb_fn mouse_callback;
343 } quick_dialog_t;
344
345
346
347
348
349 int quick_dialog_skip (quick_dialog_t *quick_dlg, int nskip);
350
351
352
353 static inline int
354 quick_dialog (quick_dialog_t *quick_dlg)
355 {
356 return quick_dialog_skip (quick_dlg, 1);
357 }
358
359 #endif