1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
#include "cfl_menu.h"
#include "cfl_lock.h"
#include "cfl_widget.hpp"
#include <FL/Enumerations.H>
#include <FL/Fl.H>
#include <FL/Fl_Choice.H>
#include <FL/Fl_Image.H>
#include <FL/Fl_Menu_Bar.H>
#include <FL/Fl_Menu_Button.H>
#include <FL/Fl_Menu_Item.H>
#include <FL/Fl_Multi_Label.H>
#include <FL/Fl_Sys_Menu_Bar.H>
#include <FL/platform.H>
#define MENU_DEFINE(widget) \
int widget##_add(widget *self, const char *name, int shortcut, Fl_Callback *cb, void *data, \
int flag) { \
LOCK(auto ret = self->add(name, shortcut, cb, data, flag)); \
return ret; \
} \
int widget##_insert(widget *self, int index, const char *name, int shortcut, Fl_Callback *cb, \
void *data, int flag) { \
LOCK(auto ret = self->insert(index, name, shortcut, cb, data, flag)); \
return ret; \
} \
Fl_Menu_Item *widget##_get_item(widget *self, const char *name) { \
LOCK(auto ret = (Fl_Menu_Item *)self->find_item(name)); \
return ret; \
} \
int widget##_set_item(widget *self, Fl_Menu_Item *item) { \
LOCK(auto ret = self->value(item)); \
return ret; \
} \
int widget##_text_font(widget *self) { \
LOCK(auto ret = self->textfont()); \
return ret; \
} \
void widget##_set_text_font(widget *self, int c) { \
LOCK(self->textfont(c)); \
} \
int widget##_text_size(widget *self) { \
LOCK(auto ret = self->textsize()); \
return ret; \
} \
void widget##_set_text_size(widget *self, int c) { \
LOCK(self->textsize(c)); \
} \
unsigned int widget##_text_color(widget *self) { \
LOCK(auto ret = self->textcolor()); \
return ret; \
} \
void widget##_set_text_color(widget *self, unsigned int c) { \
LOCK(self->textcolor(c)); \
} \
int widget##_add_choice(widget *self, const char *str) { \
LOCK(auto ret = self->add(str)); \
return ret; \
} \
const char *widget##_get_choice(widget *self) { \
LOCK(auto ret = self->text()); \
return ret; \
} \
int widget##_value(widget *self) { \
LOCK(auto ret = self->value()); \
return ret; \
} \
int widget##_set_value(widget *self, int v) { \
LOCK(auto ret = self->value(v)); \
return ret; \
} \
void widget##_clear(widget *self) { \
LOCK(self->clear()); \
} \
int widget##_clear_submenu(widget *self, int index) { \
LOCK(auto ret = self->clear_submenu(index)); \
return ret; \
} \
int widget##_size(const widget *self) { \
LOCK(auto ret = self->size()); \
return ret; \
} \
const char *widget##_text(const widget *self, int idx) { \
LOCK(auto ret = self->text(idx)); \
return ret; \
} \
const Fl_Menu_Item *widget##_at(const widget *self, int idx) { \
LOCK(auto ret = &self->menu()[idx]); \
return ret; \
} \
void widget##_set_mode(widget *self, int i, int fl) { \
LOCK(self->mode(fl)); \
} \
int widget##_mode(const widget *self, int i) { \
LOCK(auto ret = self->mode(i)); \
return ret; \
} \
int widget##_find_index(const widget *self, const char *label) { \
LOCK(auto ret = self->find_index(label)); \
return ret; \
} \
const Fl_Menu_Item *widget##_menu(const widget *self) { \
LOCK(auto ret = self->menu()); \
return ret; \
} \
void widget##_set_menu(widget *self, const Fl_Menu_Item *item) { \
Fl_Menu_Item *temp = new Fl_Menu_Item[self->size()]; \
if (!temp) \
return; \
for (int i = 0; i < self->size(); i++) { \
temp[i] = item[i]; \
if (item[i].text) { \
auto c = new char[strlen(item[i].text) + 1]; \
strcpy(c, item[i].text); \
temp[i].text = c; \
} \
} \
LOCK(self->menu(temp)); \
} \
void widget##_remove(widget *self, int idx) { \
LOCK(self->remove(idx)); \
} \
void widget##_set_down_box(widget *self, int box) { \
LOCK(self->down_box(static_cast<Fl_Boxtype>(box))); \
} \
int widget##_down_box(const widget *self) { \
LOCK(auto ret = self->down_box()); \
return ret; \
} \
void widget##_global(widget *self) { \
LOCK(self->global()); \
} \
int widget##_item_pathname(const widget *self, char *pathname, int pathnamelen, \
const Fl_Menu_Item *item) { \
char temp[256] = {0}; \
LOCK(auto ret = self->item_pathname(temp, 256, item); \
if (ret == 0) strncpy(pathname, temp, strlen(temp));); \
return ret; \
}
WIDGET_CLASS(Fl_Menu_Bar)
WIDGET_DEFINE(Fl_Menu_Bar)
MENU_DEFINE(Fl_Menu_Bar)
WIDGET_CLASS(Fl_Menu_Button)
WIDGET_DEFINE(Fl_Menu_Button)
const Fl_Menu_Item *Fl_Menu_Button_popup(Fl_Menu_Button *self) {
LOCK(auto ret = self->popup());
return ret;
}
MENU_DEFINE(Fl_Menu_Button)
WIDGET_CLASS(Fl_Choice)
WIDGET_DEFINE(Fl_Choice)
MENU_DEFINE(Fl_Choice)
WIDGET_CLASS(Fl_Sys_Menu_Bar)
WIDGET_DEFINE(Fl_Sys_Menu_Bar)
MENU_DEFINE(Fl_Sys_Menu_Bar)
Fl_Menu_Item *Fl_Menu_Item_new(char **args, int sz) {
Fl_Menu_Item *items = new Fl_Menu_Item[sz + 1];
if (!items)
return NULL;
for (int i = 0; i < sz; i++) {
items[i] = {args[i]};
}
items[sz] = {NULL};
return items;
}
void Fl_Menu_Item_delete(Fl_Menu_Item *self) {
delete[] self;
}
const Fl_Menu_Item *Fl_Menu_Item_popup(Fl_Menu_Item *self, int x, int y) {
LOCK(auto ret = self->popup(x, y));
return ret;
}
const char *Fl_Menu_Item_label(Fl_Menu_Item *self) {
LOCK(auto ret = self->label());
return ret;
}
void Fl_Menu_Item_set_label(Fl_Menu_Item *self, const char *a) {
LOCK(self->label(a));
}
int Fl_Menu_Item_label_type(Fl_Menu_Item *self) {
LOCK(auto ret = self->labeltype());
return ret;
}
void Fl_Menu_Item_set_label_type(Fl_Menu_Item *self, int a) {
LOCK(self->labeltype(static_cast<Fl_Labeltype>(a)));
}
unsigned int Fl_Menu_Item_label_color(Fl_Menu_Item *self) {
LOCK(auto ret = self->labelcolor());
return ret;
}
void Fl_Menu_Item_set_label_color(Fl_Menu_Item *self, unsigned int a) {
LOCK(self->labelcolor(a));
}
int Fl_Menu_Item_label_font(Fl_Menu_Item *self) {
LOCK(auto ret = self->labelfont());
return ret;
}
void Fl_Menu_Item_set_label_font(Fl_Menu_Item *self, int a) {
LOCK(self->labelfont(a));
}
int Fl_Menu_Item_label_size(Fl_Menu_Item *self) {
LOCK(auto ret = self->labelsize());
return ret;
}
void Fl_Menu_Item_set_label_size(Fl_Menu_Item *self, int a) {
LOCK(self->labelsize(a));
}
int Fl_Menu_Item_value(Fl_Menu_Item *self) {
LOCK(auto ret = self->value());
return ret;
}
void Fl_Menu_Item_set(Fl_Menu_Item *self) {
LOCK(self->set());
}
void Fl_Menu_Item_clear(Fl_Menu_Item *self) {
LOCK(self->clear());
}
int Fl_Menu_Item_visible(Fl_Menu_Item *self) {
LOCK(auto ret = self->visible());
return ret;
}
void Fl_Menu_Item_show(Fl_Menu_Item *self) {
LOCK(self->show());
}
void Fl_Menu_Item_hide(Fl_Menu_Item *self) {
LOCK(self->hide());
}
int Fl_Menu_Item_active(Fl_Menu_Item *self) {
LOCK(auto ret = self->active());
return ret;
}
void Fl_Menu_Item_activate(Fl_Menu_Item *self) {
LOCK(self->activate());
}
void Fl_Menu_Item_deactivate(Fl_Menu_Item *self) {
LOCK(self->deactivate());
}
int Fl_Menu_Item_submenu(const Fl_Menu_Item *self) {
LOCK(auto ret = self->submenu());
return ret;
}
int Fl_Menu_Item_checkbox(const Fl_Menu_Item *self) {
LOCK(auto ret = self->checkbox());
return ret;
}
int Fl_Menu_Item_radio(const Fl_Menu_Item *self) {
LOCK(auto ret = self->radio());
return ret;
}
Fl_Menu_Item *Fl_Menu_Item_next(Fl_Menu_Item *self, int idx) {
LOCK(auto ret = self->next(idx));
return ret;
}
void Fl_Menu_Item_set_callback(Fl_Menu_Item *self, Fl_Callback *c, void *p) {
LOCK(self->callback(c, p));
}
void *Fl_Menu_Item_user_data(const Fl_Menu_Item *self) {
LOCK(auto ret = self->user_data());
return ret;
}
void Fl_Menu_Item_set_user_data(Fl_Menu_Item *self, void *data) {
LOCK(self->user_data(data));
}
void Fl_Menu_Item_draw(const Fl_Menu_Item *self, int x, int y, int w, int h, const void *m,
int selected) {
fl_open_display();
LOCK(self->draw(x, y, w, h, (const Fl_Menu_ *)m, selected));
}
int Fl_Menu_Item_measure(const Fl_Menu_Item *self, int *hp, const void *m) {
LOCK(auto ret = self->measure(hp, (const Fl_Menu_ *)m));
return ret;
}
void Fl_Menu_Item_image(Fl_Menu_Item *self, void *image) {
LOCK(self->image((Fl_Image *)image));
}
void Fl_Menu_Item_add_image(Fl_Menu_Item *self, void *image, int on_left) {
LOCK(
Fl_Image *temp = NULL;
if (image) { temp = ((Fl_Image *)image)->copy(); } Fl_Multi_Label *ml = new Fl_Multi_Label;
if (on_left) {
ml->typea = FL_IMAGE_LABEL;
ml->labela = (const char *)temp;
ml->typeb = FL_NORMAL_LABEL;
ml->labelb = self->label();
} else {
ml->typeb = FL_IMAGE_LABEL;
ml->labelb = (const char *)temp;
ml->typea = FL_NORMAL_LABEL;
ml->labela = self->label();
} self->label(FL_MULTI_LABEL, (const char *)ml));
}
int Fl_Menu_Item_children(const Fl_Menu_Item *self) {
if (!self->submenu())
return 0;
LOCK(int i = 0; while (true) {
if (!self[i].text) {
break;
}
i += 1;
})
return i;
}
const Fl_Menu_Item *Fl_Menu_Item_at(const Fl_Menu_Item *self, int idx) {
LOCK(auto ret = &self[idx]);
return ret;
}
int Fl_Menu_Item_add(Fl_Menu_Item *self, const char *name, int shortcut, Fl_Callback *cb,
void *data, int flag) {
LOCK(auto ret = self->add(name, shortcut, cb, data, flag));
return ret;
}
int Fl_Menu_Item_insert(Fl_Menu_Item *self, int index, const char *name, int shortcut,
Fl_Callback *cb, void *data, int flag) {
LOCK(auto ret = self->insert(index, name, shortcut, cb, data, flag));
return ret;
}
void Fl_Menu_Item_set_shortcut(Fl_Menu_Item *self, int shortcut) {
LOCK(self->shortcut(shortcut));
}
void Fl_Menu_Item_set_flag(Fl_Menu_Item *self, int flag) {
LOCK(self->flags = flag);
}
void Fl_mac_set_about(Fl_Callback *cb, void *user_data, int shortcut) {
#ifdef __APPLE__
LOCK(fl_mac_set_about(cb, user_data, shortcut));
#endif
}