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
|
// Programmed by Jedidiah Barber
// Released into the public domain
#include <FL/Fl_Choice.H>
#include "c_fl_choice.h"
// Exports from Ada
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_Choice : public Fl_Choice {
public:
using Fl_Choice::Fl_Choice;
friend void fl_choice_draw(CHOICE n);
friend int fl_choice_handle(CHOICE n, int e);
void draw();
int handle(int e);
};
void My_Choice::draw() {
widget_draw_hook(this->user_data());
}
int My_Choice::handle(int e) {
return widget_handle_hook(this->user_data(), e);
}
// Flattened C API
CHOICE new_fl_choice(int x, int y, int w, int h, char* label) {
My_Choice *b = new My_Choice(x, y, w, h, label);
return b;
}
void free_fl_choice(CHOICE b) {
delete reinterpret_cast<My_Choice*>(b);
}
int fl_choice_value(CHOICE c) {
return reinterpret_cast<Fl_Choice*>(c)->value();
}
int fl_choice_set_value(CHOICE c, int p) {
return reinterpret_cast<Fl_Choice*>(c)->value(p);
}
int fl_choice_set_value2(CHOICE c, void * i) {
return reinterpret_cast<Fl_Choice*>(c)->value(reinterpret_cast<Fl_Menu_Item*>(i));
}
void fl_choice_draw(CHOICE n) {
reinterpret_cast<My_Choice*>(n)->Fl_Choice::draw();
}
int fl_choice_handle(CHOICE n, int e) {
return reinterpret_cast<My_Choice*>(n)->Fl_Choice::handle(e);
}
|