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
|
// Programmed by Jedidiah Barber
// Released into the public domain
#include <FL/Fl_Multi_Browser.H>
#include "c_fl_multi_browser.h"
// Exports from Ada
extern "C" int browser_full_width_hook(void * b);
extern "C" int browser_full_height_hook(void * b);
extern "C" int browser_incr_height_hook(void * b);
extern "C" int browser_item_quick_height_hook(void * b, void * i);
extern "C" int browser_item_width_hook(void * b, void * i);
extern "C" int browser_item_height_hook(void * b, void * i);
extern "C" void * browser_item_first_hook(void * b);
extern "C" void * browser_item_last_hook(void * b);
extern "C" void * browser_item_next_hook(void * b, void * i);
extern "C" void * browser_item_prev_hook(void * b, void * i);
extern "C" void * browser_item_at_hook(void * b, int n);
extern "C" void browser_item_select_hook(void * b, void * i, int s);
extern "C" int browser_item_selected_hook(void * b, void * i);
extern "C" void browser_item_swap_hook(void * b, void * one, void * two);
extern "C" const char * browser_item_text_hook(void * b, void * i);
extern "C" void browser_item_draw_hook(void * b, void * i, int x, int y, int w, int h);
extern "C" void widget_draw_hook(void * ud);
extern "C" int widget_handle_hook(void * ud, int e);
// Attaching all relevant hooks and friends
class My_Multi_Browser : public Fl_Multi_Browser {
public:
using Fl_Multi_Browser::Fl_Multi_Browser;
friend int fl_multi_browser_item_width(MULTIBROWSER b, void * item);
friend int fl_multi_browser_item_height(MULTIBROWSER b, void * item);
friend void * fl_multi_browser_item_first(MULTIBROWSER b);
friend void * fl_multi_browser_item_last(MULTIBROWSER b);
friend void * fl_multi_browser_item_next(MULTIBROWSER b, void * item);
friend void * fl_multi_browser_item_prev(MULTIBROWSER b, void * item);
friend void * fl_multi_browser_item_at(MULTIBROWSER b, int index);
friend void fl_multi_browser_item_select(MULTIBROWSER b, void * item, int val);
friend int fl_multi_browser_item_selected(MULTIBROWSER b, void * item);
friend void fl_multi_browser_item_swap(MULTIBROWSER b, void * x, void * y);
friend const char * fl_multi_browser_item_text(MULTIBROWSER b, void * item);
friend void fl_multi_browser_item_draw(MULTIBROWSER b, void * item, int x, int y, int w, int h);
friend int fl_multi_browser_lineno(MULTIBROWSER b, void * item);
friend void * fl_multi_browser_selection(MULTIBROWSER c);
friend int fl_multi_browser_displayed2(MULTIBROWSER c, void * i);
friend void * fl_multi_browser_find_item(MULTIBROWSER c, int y);
friend void * fl_multi_browser_top(MULTIBROWSER c);
friend void fl_multi_browser_bbox(MULTIBROWSER c, int &x, int &y, int &w, int &h);
friend int fl_multi_browser_leftedge(MULTIBROWSER c);
friend void fl_multi_browser_redraw_line(MULTIBROWSER c, void * i);
friend void fl_multi_browser_redraw_lines(MULTIBROWSER c);
friend int fl_multi_browser_full_width(MULTIBROWSER c);
friend int fl_multi_browser_full_height(MULTIBROWSER c);
friend int fl_multi_browser_incr_height(MULTIBROWSER c);
friend int fl_multi_browser_item_quick_height(MULTIBROWSER c, void * i);
friend void fl_multi_browser_new_list(MULTIBROWSER b);
friend void fl_multi_browser_inserting(MULTIBROWSER b, void * a1, void * a2);
friend void fl_multi_browser_deleting(MULTIBROWSER b, void * item);
friend void fl_multi_browser_replacing(MULTIBROWSER b, void * a1, void * a2);
friend void fl_multi_browser_swapping(MULTIBROWSER b, void * a1, void * a2);
friend void fl_multi_browser_draw(MULTIBROWSER b);
int handle(int e);
protected:
int full_width() const;
int full_height() const;
int incr_height() const;
int item_quick_height(void * item) const;
int item_width(void * item) const;
int item_height(void * item) const;
void * item_first() const;
void * item_last() const;
void * item_next(void * item) const;
void * item_prev(void * item) const;
void * item_at(int index) const;
void item_select(void * item, int val=1);
int item_selected(void * item) const;
void item_swap(void * a, void * b);
const char * item_text(void * item) const;
void item_draw(void * item, int x, int y, int w, int h) const;
void draw();
};
int My_Multi_Browser::full_width() const {
return browser_full_width_hook(this->user_data());
}
int My_Multi_Browser::full_height() const {
return browser_full_height_hook(this->user_data());
}
int My_Multi_Browser::incr_height() const {
return browser_incr_height_hook(this->user_data());
}
int My_Multi_Browser::item_quick_height(void * item) const {
return browser_item_quick_height_hook(this->user_data(), item);
}
int My_Multi_Browser::item_width(void * item) const {
return browser_item_width_hook(this->user_data(), item);
}
int My_Multi_Browser::item_height(void * item) const {
return browser_item_height_hook(this->user_data(), item);
}
void * My_Multi_Browser::item_first() const {
return browser_item_first_hook(this->user_data());
}
void * My_Multi_Browser::item_last() const {
return browser_item_last_hook(this->user_data());
}
void * My_Multi_Browser::item_next(void * item) const {
return browser_item_next_hook(this->user_data(), item);
}
void * My_Multi_Browser::item_prev(void * item) const {
return browser_item_prev_hook(this->user_data(), item);
}
void * My_Multi_Browser::item_at(int index) const {
return browser_item_at_hook(this->user_data(), index);
}
void My_Multi_Browser::item_select(void * item, int val) {
browser_item_select_hook(this->user_data(), item, val);
}
int My_Multi_Browser::item_selected(void * item) const {
return browser_item_selected_hook(this->user_data(), item);
}
void My_Multi_Browser::item_swap(void * a, void * b) {
browser_item_swap_hook(this->user_data(), a, b);
}
const char * My_Multi_Browser::item_text(void * item) const {
return browser_item_text_hook(this->user_data(), item);
}
void My_Multi_Browser::item_draw(void * item, int x, int y, int w, int h) const {
browser_item_draw_hook(this->user_data(), item, x, y, w, h);
}
void My_Multi_Browser::draw() {
widget_draw_hook(this->user_data());
}
int My_Multi_Browser::handle(int e) {
return widget_handle_hook(this->user_data(), e);
}
// Flattened C API begins here
MULTIBROWSER new_fl_multi_browser(int x, int y, int w, int h, char * label) {
My_Multi_Browser *b = new My_Multi_Browser(x, y, w, h, label);
return b;
}
void free_fl_multi_browser(MULTIBROWSER b) {
delete reinterpret_cast<My_Multi_Browser*>(b);
}
// These have to be reimplemented due to relying on custom class extensions
int fl_multi_browser_full_height(MULTIBROWSER c) {
return reinterpret_cast<My_Multi_Browser*>(c)->Fl_Browser::full_height();
}
int fl_multi_browser_incr_height(MULTIBROWSER c) {
return reinterpret_cast<My_Multi_Browser*>(c)->Fl_Browser::incr_height();
}
int fl_multi_browser_item_width(MULTIBROWSER b, void * item) {
return reinterpret_cast<My_Multi_Browser*>(b)->item_width(item);
}
int fl_multi_browser_item_height(MULTIBROWSER b, void * item) {
return reinterpret_cast<My_Multi_Browser*>(b)->item_height(item);
}
void * fl_multi_browser_item_first(MULTIBROWSER b) {
return reinterpret_cast<My_Multi_Browser*>(b)->item_first();
}
void * fl_multi_browser_item_last(MULTIBROWSER b) {
return reinterpret_cast<My_Multi_Browser*>(b)->item_last();
}
void * fl_multi_browser_item_next(MULTIBROWSER b, void * item) {
return reinterpret_cast<My_Multi_Browser*>(b)->item_next(item);
}
void * fl_multi_browser_item_prev(MULTIBROWSER b, void * item) {
return reinterpret_cast<My_Multi_Browser*>(b)->item_prev(item);
}
void * fl_multi_browser_item_at(MULTIBROWSER b, int index) {
return reinterpret_cast<My_Multi_Browser*>(b)->item_at(index);
}
void fl_multi_browser_item_select(MULTIBROWSER b, void * item, int val) {
reinterpret_cast<My_Multi_Browser*>(b)->item_select(item, val);
}
int fl_multi_browser_item_selected(MULTIBROWSER b, void * item) {
return reinterpret_cast<My_Multi_Browser*>(b)->item_selected(item);
}
void fl_multi_browser_item_swap(MULTIBROWSER b, void * x, void * y) {
reinterpret_cast<My_Multi_Browser*>(b)->item_swap(x, y);
}
const char * fl_multi_browser_item_text(MULTIBROWSER b, void * item) {
return reinterpret_cast<My_Multi_Browser*>(b)->item_text(item);
}
void fl_multi_browser_item_draw(MULTIBROWSER b, void * item, int x, int y, int w, int h) {
reinterpret_cast<My_Multi_Browser*>(b)->item_draw(item, x, y, w, h);
}
int fl_multi_browser_lineno(MULTIBROWSER b, void * item) {
return reinterpret_cast<My_Multi_Browser*>(b)->lineno(item);
}
void * fl_multi_browser_selection(MULTIBROWSER c) {
return reinterpret_cast<My_Multi_Browser*>(c)->selection();
}
int fl_multi_browser_displayed2(MULTIBROWSER c, void * i) {
return reinterpret_cast<My_Multi_Browser*>(c)->Fl_Browser_::displayed(i);
}
void * fl_multi_browser_find_item(MULTIBROWSER c, int y) {
return reinterpret_cast<My_Multi_Browser*>(c)->find_item(y);
}
void * fl_multi_browser_top(MULTIBROWSER c) {
return reinterpret_cast<My_Multi_Browser*>(c)->top();
}
void fl_multi_browser_bbox(MULTIBROWSER c, int &x, int &y, int &w, int &h) {
reinterpret_cast<My_Multi_Browser*>(c)->bbox(x, y, w, h);
}
int fl_multi_browser_leftedge(MULTIBROWSER c) {
return reinterpret_cast<My_Multi_Browser*>(c)->leftedge();
}
void fl_multi_browser_redraw_line(MULTIBROWSER c, void * i) {
reinterpret_cast<My_Multi_Browser*>(c)->redraw_line(i);
}
void fl_multi_browser_redraw_lines(MULTIBROWSER c) {
reinterpret_cast<My_Multi_Browser*>(c)->redraw_lines();
}
int fl_multi_browser_full_width(MULTIBROWSER c) {
return reinterpret_cast<My_Multi_Browser*>(c)->Fl_Browser::full_width();
}
int fl_multi_browser_item_quick_height(MULTIBROWSER c, void * i) {
return reinterpret_cast<My_Multi_Browser*>(c)->Fl_Browser::item_quick_height(i);
}
void fl_multi_browser_new_list(MULTIBROWSER b) {
reinterpret_cast<My_Multi_Browser*>(b)->new_list();
}
void fl_multi_browser_inserting(MULTIBROWSER b, void * a1, void * a2) {
reinterpret_cast<My_Multi_Browser*>(b)->inserting(a1, a2);
}
void fl_multi_browser_deleting(MULTIBROWSER b, void * item) {
reinterpret_cast<My_Multi_Browser*>(b)->deleting(item);
}
void fl_multi_browser_replacing(MULTIBROWSER b, void * a1, void * a2) {
reinterpret_cast<My_Multi_Browser*>(b)->replacing(a1, a2);
}
void fl_multi_browser_swapping(MULTIBROWSER b, void * a1, void * a2) {
reinterpret_cast<My_Multi_Browser*>(b)->swapping(a1, a2);
}
void fl_multi_browser_draw(MULTIBROWSER b) {
reinterpret_cast<My_Multi_Browser*>(b)->Fl_Browser::draw();
}
int fl_multi_browser_handle(MULTIBROWSER b, int e) {
return reinterpret_cast<My_Multi_Browser*>(b)->Fl_Browser::handle(e);
}
|