summaryrefslogtreecommitdiff
path: root/src/c_fl_clock_output.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/c_fl_clock_output.cpp')
-rw-r--r--src/c_fl_clock_output.cpp83
1 files changed, 42 insertions, 41 deletions
diff --git a/src/c_fl_clock_output.cpp b/src/c_fl_clock_output.cpp
index b2a6546..91aaae4 100644
--- a/src/c_fl_clock_output.cpp
+++ b/src/c_fl_clock_output.cpp
@@ -6,63 +6,55 @@
#include <FL/Fl_Clock.H>
#include "c_fl_clock_output.h"
-#include "c_fl_type.h"
-class My_Clock_Output : public Fl_Clock_Output {
- public:
- using Fl_Clock_Output::Fl_Clock_Output;
- friend void clock_output_set_draw_hook(CLOCK_OUTPUT c, void * d);
- friend void fl_clock_output_draw(CLOCK_OUTPUT c);
- friend void clock_output_set_handle_hook(CLOCK_OUTPUT c, void * h);
- friend int fl_clock_output_handle(CLOCK_OUTPUT c, int e);
- friend void fl_clock_output_draw2(CLOCK_OUTPUT c, int x, int y, int w, int h);
- protected:
- void draw();
- void real_draw();
- int handle(int e);
- int real_handle(int e);
- d_hook_p draw_hook;
- h_hook_p handle_hook;
+// 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;
};
-void My_Clock_Output::draw() {
- (*draw_hook)(this->user_data());
-}
-void My_Clock_Output::real_draw() {
- Fl_Clock_Output::draw();
-}
-int My_Clock_Output::handle(int e) {
- return (*handle_hook)(this->user_data(), e);
-}
-int My_Clock_Output::real_handle(int e) {
- return Fl_Clock_Output::handle(e);
-}
+// Attaching all relevant hooks and friends
-void clock_output_set_draw_hook(CLOCK_OUTPUT c, void * d) {
- reinterpret_cast<My_Clock_Output*>(c)->draw_hook = reinterpret_cast<d_hook_p>(d);
-}
+class My_Clock_Output : public Fl_Clock_Output {
+public:
+ using Fl_Clock_Output::Fl_Clock_Output;
-void fl_clock_output_draw(CLOCK_OUTPUT c) {
- reinterpret_cast<My_Clock_Output*>(c)->real_draw();
-}
+ 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 clock_output_set_handle_hook(CLOCK_OUTPUT c, void * h) {
- reinterpret_cast<My_Clock_Output*>(c)->handle_hook = reinterpret_cast<h_hook_p>(h);
+void My_Clock_Output::draw() {
+ widget_draw_hook(this->user_data());
}
-int fl_clock_output_handle(CLOCK_OUTPUT c, int e) {
- return reinterpret_cast<My_Clock_Output*>(c)->real_handle(e);
+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;
@@ -88,11 +80,11 @@ int fl_clock_output_get_second(CLOCK_OUTPUT c) {
}
-ulong fl_clock_output_get_value(CLOCK_OUTPUT c) {
+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, ulong v) {
+void fl_clock_output_set_value(CLOCK_OUTPUT c, unsigned long v) {
reinterpret_cast<Fl_Clock_Output*>(c)->Fl_Clock_Output::value(v);
}
@@ -103,8 +95,17 @@ void fl_clock_output_set_value2(CLOCK_OUTPUT c, int h, int m, int 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) {
- reinterpret_cast<My_Clock_Output*>(c)->Fl_Clock_Output::draw(x,y,w,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);
}