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
|
// Programmed by Jedidiah Barber
// Released into the public domain
#include <FL/Fl_Clock.H>
#include "c_fl_clock_output.h"
// Exports from Ada
extern "C" void widget_draw_hook(void * ud);
extern "C" int widget_handle_hook(void * ud, int e);
// Non-friend protected access
class Friend_Clock_Output : Fl_Clock_Output {
public:
// Really only needed for the (int,int,int,int) version
using Fl_Clock_Output::draw;
};
// Attaching all relevant hooks and friends
class My_Clock_Output : public Fl_Clock_Output {
public:
using Fl_Clock_Output::Fl_Clock_Output;
friend void fl_clock_output_draw(CLOCK_OUTPUT c);
friend int fl_clock_output_handle(CLOCK_OUTPUT c, int e);
void draw();
int handle(int e);
};
void My_Clock_Output::draw() {
widget_draw_hook(this->user_data());
}
int My_Clock_Output::handle(int e) {
return widget_handle_hook(this->user_data(), e);
}
// Flattened C API
CLOCK_OUTPUT new_fl_clock_output(int x, int y, int w, int h, char* label) {
My_Clock_Output *c = new My_Clock_Output(x, y, w, h, label);
return c;
}
void free_fl_clock_output(CLOCK_OUTPUT c) {
delete reinterpret_cast<My_Clock_Output*>(c);
}
int fl_clock_output_get_hour(CLOCK_OUTPUT c) {
return reinterpret_cast<Fl_Clock_Output*>(c)->Fl_Clock_Output::hour();
}
int fl_clock_output_get_minute(CLOCK_OUTPUT c) {
return reinterpret_cast<Fl_Clock_Output*>(c)->Fl_Clock_Output::minute();
}
int fl_clock_output_get_second(CLOCK_OUTPUT c) {
return reinterpret_cast<Fl_Clock_Output*>(c)->Fl_Clock_Output::second();
}
unsigned long fl_clock_output_get_value(CLOCK_OUTPUT c) {
return reinterpret_cast<Fl_Clock_Output*>(c)->Fl_Clock_Output::value();
}
void fl_clock_output_set_value(CLOCK_OUTPUT c, unsigned long v) {
reinterpret_cast<Fl_Clock_Output*>(c)->Fl_Clock_Output::value(v);
}
void fl_clock_output_set_value2(CLOCK_OUTPUT c, int h, int m, int s) {
reinterpret_cast<Fl_Clock_Output*>(c)->Fl_Clock_Output::value(h,m,s);
}
void fl_clock_output_draw(CLOCK_OUTPUT c) {
reinterpret_cast<My_Clock_Output*>(c)->Fl_Clock_Output::draw();
}
void fl_clock_output_draw2(CLOCK_OUTPUT c, int x, int y, int w, int h) {
void (Fl_Clock_Output::*mydraw)(int,int,int,int) = &Friend_Clock_Output::draw;
(reinterpret_cast<Fl_Clock_Output*>(c)->*mydraw)(x, y, w, h);
}
int fl_clock_output_handle(CLOCK_OUTPUT c, int e) {
return reinterpret_cast<My_Clock_Output*>(c)->Fl_Clock_Output::handle(e);
}
|