summaryrefslogtreecommitdiff
path: root/src/c_fl_roller.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/c_fl_roller.cpp')
-rw-r--r--src/c_fl_roller.cpp69
1 files changed, 31 insertions, 38 deletions
diff --git a/src/c_fl_roller.cpp b/src/c_fl_roller.cpp
index 6a4ebb6..f5c7dd6 100644
--- a/src/c_fl_roller.cpp
+++ b/src/c_fl_roller.cpp
@@ -6,62 +6,44 @@
#include <FL/Fl_Roller.H>
#include "c_fl_roller.h"
-#include "c_fl_type.h"
-class My_Roller : public Fl_Roller {
- public:
- using Fl_Roller::Fl_Roller;
- friend void roller_set_draw_hook(ROLLER r, void * d);
- friend void fl_roller_draw(ROLLER r);
- friend void roller_set_handle_hook(ROLLER r, void * h);
- friend int fl_roller_handle(ROLLER r, int e);
- 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
-void My_Roller::draw() {
- (*draw_hook)(this->user_data());
-}
+extern "C" void widget_draw_hook(void * ud);
+extern "C" int widget_handle_hook(void * ud, int e);
-void My_Roller::real_draw() {
- Fl_Roller::draw();
-}
-int My_Roller::handle(int e) {
- return (*handle_hook)(this->user_data(), e);
-}
-int My_Roller::real_handle(int e) {
- return Fl_Roller::handle(e);
-}
-void roller_set_draw_hook(ROLLER r, void * d) {
- reinterpret_cast<My_Roller*>(r)->draw_hook = reinterpret_cast<d_hook_p>(d);
-}
+// Attaching all relevant hooks and friends
-void fl_roller_draw(ROLLER r) {
- reinterpret_cast<My_Roller*>(r)->real_draw();
-}
+class My_Roller : public Fl_Roller {
+public:
+ using Fl_Roller::Fl_Roller;
+
+ friend void fl_roller_draw(ROLLER r);
+ friend int fl_roller_handle(ROLLER r, int e);
+
+ void draw();
+ int handle(int e);
+};
-void roller_set_handle_hook(ROLLER r, void * h) {
- reinterpret_cast<My_Roller*>(r)->handle_hook = reinterpret_cast<h_hook_p>(h);
+void My_Roller::draw() {
+ widget_draw_hook(this->user_data());
}
-int fl_roller_handle(ROLLER r, int e) {
- return reinterpret_cast<My_Roller*>(r)->real_handle(e);
+int My_Roller::handle(int e) {
+ return widget_handle_hook(this->user_data(), e);
}
+// Flattened C API
+
ROLLER new_fl_roller(int x, int y, int w, int h, char* label) {
My_Roller *r = new My_Roller(x, y, w, h, label);
return r;
@@ -72,3 +54,14 @@ void free_fl_roller(ROLLER r) {
}
+
+
+void fl_roller_draw(ROLLER r) {
+ reinterpret_cast<My_Roller*>(r)->Fl_Roller::draw();
+}
+
+int fl_roller_handle(ROLLER r, int e) {
+ return reinterpret_cast<My_Roller*>(r)->Fl_Roller::handle(e);
+}
+
+