summaryrefslogtreecommitdiff
path: root/src/c_fl_wizard.cpp
diff options
context:
space:
mode:
authorJedidiah Barber <contact@jedbarber.id.au>2025-01-12 01:14:58 +1300
committerJedidiah Barber <contact@jedbarber.id.au>2025-01-12 01:14:58 +1300
commite93b9bbc02e2791f3a35b6f077fcbb8514c28aed (patch)
tree3661530027db6809a9cbad7b2477416009e00787 /src/c_fl_wizard.cpp
parent53aa8144851913994b963ed611cca8885b8f9a9e (diff)
Refactored draw/handle methods in Widgets hierarchy, improved docs, added a few minor method bindings here and there
Diffstat (limited to 'src/c_fl_wizard.cpp')
-rw-r--r--src/c_fl_wizard.cpp70
1 files changed, 33 insertions, 37 deletions
diff --git a/src/c_fl_wizard.cpp b/src/c_fl_wizard.cpp
index 1aeb0e5..d826ca6 100644
--- a/src/c_fl_wizard.cpp
+++ b/src/c_fl_wizard.cpp
@@ -6,34 +6,37 @@
#include <FL/Fl_Wizard.H>
#include "c_fl_wizard.h"
-#include "c_fl_type.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_Wizard : public Fl_Wizard {
- public:
- using Fl_Wizard::Fl_Wizard;
- friend void wizard_set_draw_hook(WIZARD w, void * d);
- friend void fl_wizard_draw(WIZARD w);
- friend void wizard_set_handle_hook(WIZARD w, void * h);
- friend int fl_wizard_handle(WIZARD w, 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;
+public:
+ using Fl_Wizard::Fl_Wizard;
+
+ friend void fl_wizard_draw(WIZARD w);
+ friend int fl_wizard_handle(WIZARD w, int e);
+
+ void draw();
+ void real_draw();
+ int handle(int e);
};
void My_Wizard::draw() {
- (*draw_hook)(this->user_data());
+ widget_draw_hook(this->user_data());
}
void My_Wizard::real_draw() {
- //Fl_Wizard::draw();
-
// required because of Fl_Wizard::draw() being private
// probably a bug in FLTK?
Fl_Widget *kid = value();
@@ -50,31 +53,13 @@ void My_Wizard::real_draw() {
}
int My_Wizard::handle(int e) {
- return (*handle_hook)(this->user_data(), e);
+ return widget_handle_hook(this->user_data(), e);
}
-int My_Wizard::real_handle(int e) {
- return Fl_Wizard::handle(e);
-}
-
-void wizard_set_draw_hook(WIZARD w, void * d) {
- reinterpret_cast<My_Wizard*>(w)->draw_hook = reinterpret_cast<d_hook_p>(d);
-}
-
-void fl_wizard_draw(WIZARD w) {
- reinterpret_cast<My_Wizard*>(w)->real_draw();
-}
-
-void wizard_set_handle_hook(WIZARD w, void * h) {
- reinterpret_cast<My_Wizard*>(w)->handle_hook = reinterpret_cast<h_hook_p>(h);
-}
-
-int fl_wizard_handle(WIZARD w, int e) {
- return reinterpret_cast<My_Wizard*>(w)->real_handle(e);
-}
+// Flattened C API
WIZARD new_fl_wizard(int x, int y, int w, int h, char* label) {
My_Wizard *g = new My_Wizard(x, y, w, h, label);
@@ -108,3 +93,14 @@ void fl_wizard_set_visible(WIZARD w, void * i) {
}
+
+
+void fl_wizard_draw(WIZARD w) {
+ reinterpret_cast<My_Wizard*>(w)->real_draw();
+}
+
+int fl_wizard_handle(WIZARD w, int e) {
+ return reinterpret_cast<My_Wizard*>(w)->Fl_Wizard::handle(e);
+}
+
+