fixed relative symlink operations. Symlink now stay relative
[midnight-commander.git] / lib / widget / quick.h
blobf7ac2c23fdc3452970b21c59f0cc9cf9938c64b3
1 /** \file quick.h
2 * \brief Header: quick dialog engine
3 */
5 #ifndef MC__QUICK_H
6 #define MC__QUICK_H
8 /*** typedefs(not structures) and defined constants **********************************************/
10 #define QUICK_CHECKBOX(x, xdiv, y, ydiv, txt, st) \
11 { \
12 .widget_type = quick_checkbox, \
13 .relative_x = x, \
14 .x_divisions = xdiv, \
15 .relative_y = y, \
16 .y_divisions = ydiv, \
17 .widget = NULL, \
18 .options = 0, \
19 .u = { \
20 .checkbox = { \
21 .text = txt, \
22 .state = st \
23 } \
24 } \
27 #define QUICK_BUTTON(x, xdiv, y, ydiv, txt, act, cb) \
28 { \
29 .widget_type = quick_button, \
30 .relative_x = x, \
31 .x_divisions = xdiv, \
32 .relative_y = y, \
33 .y_divisions = ydiv, \
34 .widget = NULL, \
35 .options = 0, \
36 .u = { \
37 .button = { \
38 .text = txt, \
39 .action = act, \
40 .callback = cb \
41 } \
42 } \
45 #define QUICK_INPUT(x, xdiv, y, ydiv, txt, len_, flags_, hname, res) \
46 { \
47 .widget_type = quick_input, \
48 .relative_x = x, \
49 .x_divisions = xdiv, \
50 .relative_y = y, \
51 .y_divisions = ydiv, \
52 .widget = NULL, \
53 .options = 0, \
54 .u = { \
55 .input = { \
56 .text = txt, \
57 .len = len_, \
58 .flags = flags_, \
59 .histname = hname, \
60 .result = res \
61 } \
62 } \
65 #define QUICK_LABEL(x, xdiv, y, ydiv, txt) \
66 { \
67 .widget_type = quick_label, \
68 .relative_x = x, \
69 .x_divisions = xdiv, \
70 .relative_y = y, \
71 .y_divisions = ydiv, \
72 .widget = NULL, \
73 .options = 0, \
74 .u = { \
75 .label = { \
76 .text = txt \
77 } \
78 } \
81 #define QUICK_RADIO(x, xdiv, y, ydiv, cnt, items_, val) \
82 { \
83 .widget_type = quick_radio, \
84 .relative_x = x, \
85 .x_divisions = xdiv, \
86 .relative_y = y, \
87 .y_divisions = ydiv, \
88 .widget = NULL, \
89 .options = 0, \
90 .u = { \
91 .radio = { \
92 .count = cnt, \
93 .items = items_, \
94 .value = val \
95 } \
96 } \
99 #define QUICK_GROUPBOX(x, xdiv, y, ydiv, w, h, t) \
101 .widget_type = quick_groupbox, \
102 .relative_x = x, \
103 .x_divisions = xdiv, \
104 .relative_y = y, \
105 .y_divisions = ydiv, \
106 .widget = NULL, \
107 .options = 0, \
108 .u = { \
109 .groupbox = { \
110 .width = w, \
111 .height = h, \
112 .title = t \
117 #define QUICK_END \
119 .widget_type = quick_end, \
120 .relative_x = 0, \
121 .x_divisions = 0, \
122 .relative_y = 0, \
123 .y_divisions = 0, \
124 .widget = NULL, \
125 .options = 0, \
126 .u = { \
127 .input = { \
128 .text = NULL, \
129 .len = 0, \
130 .flags = 0, \
131 .histname = NULL, \
132 .result = NULL \
137 /*** enums ***************************************************************************************/
139 /* Quick Widgets */
140 typedef enum
142 quick_end = 0,
143 quick_checkbox = 1,
144 quick_button = 2,
145 quick_input = 3,
146 quick_label = 4,
147 quick_radio = 5,
148 quick_groupbox = 6
149 } quick_t;
151 /*** structures declarations (and typedefs of structures)*****************************************/
153 /* The widget is placed on relative_?/divisions_? of the parent widget */
154 typedef struct
156 quick_t widget_type;
158 int relative_x;
159 int x_divisions;
160 int relative_y;
161 int y_divisions;
163 Widget *widget;
164 widget_options_t options;
166 /* widget parameters */
167 union
169 struct
171 const char *text;
172 int *state; /* in/out */
173 } checkbox;
175 struct
177 const char *text;
178 int action;
179 bcback_fn callback;
180 } button;
182 struct
184 const char *text;
185 int len;
186 int flags; /* 1 -- is_password, 2 -- INPUT_COMPLETE_CD */
187 const char *histname;
188 char **result;
189 } input;
191 struct
193 const char *text;
194 } label;
196 struct
198 int count;
199 const char **items;
200 int *value; /* in/out */
201 } radio;
203 struct
205 int width;
206 int height;
207 const char *title;
208 } groupbox;
209 } u;
210 } QuickWidget;
212 typedef struct
214 int xlen, ylen;
215 int xpos, ypos; /* if -1, then center the dialog */
216 const char *title;
217 const char *help;
218 QuickWidget *widgets;
219 dlg_cb_fn callback;
220 gboolean i18n; /* If true, internationalization has happened */
221 } QuickDialog;
223 /*** global variables defined in .c file *********************************************************/
225 /*** declarations of public functions ************************************************************/
227 int quick_dialog_skip (QuickDialog * qd, int nskip);
229 /*** inline functions ****************************************************************************/
231 static inline int
232 quick_dialog (QuickDialog * qd)
234 return quick_dialog_skip (qd, 0);
237 #endif /* MC__QUICK_H */