summaryrefslogtreecommitdiff
path: root/src/c_fl_tabs.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_tabs.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_tabs.cpp')
-rw-r--r--src/c_fl_tabs.cpp82
1 files changed, 45 insertions, 37 deletions
diff --git a/src/c_fl_tabs.cpp b/src/c_fl_tabs.cpp
index 2973502..a3e8581 100644
--- a/src/c_fl_tabs.cpp
+++ b/src/c_fl_tabs.cpp
@@ -6,62 +6,54 @@
#include <FL/Fl_Tabs.H>
#include "c_fl_tabs.h"
-#include "c_fl_type.h"
-class My_Tabs : public Fl_Tabs {
- public:
- using Fl_Tabs::Fl_Tabs;
- friend void tabs_set_draw_hook(TABS t, void * d);
- friend void fl_tabs_draw(TABS t);
- friend void tabs_set_handle_hook(TABS t, void * h);
- friend int fl_tabs_handle(TABS t, 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
+
+extern "C" void widget_draw_hook(void * ud);
+extern "C" int widget_handle_hook(void * ud, int e);
+
+
+
+
+// Non-friend protected access
+
+class Friend_Tabs : Fl_Tabs {
+public:
+ using Fl_Tabs::redraw_tabs;
};
-void My_Tabs::draw() {
- (*draw_hook)(this->user_data());
-}
-void My_Tabs::real_draw() {
- Fl_Tabs::draw();
-}
-int My_Tabs::handle(int e) {
- return (*handle_hook)(this->user_data(), e);
-}
-int My_Tabs::real_handle(int e) {
- return Fl_Tabs::handle(e);
-}
+// Attaching all relevant hooks and friends
-void tabs_set_draw_hook(TABS t, void * d) {
- reinterpret_cast<My_Tabs*>(t)->draw_hook = reinterpret_cast<d_hook_p>(d);
-}
+class My_Tabs : public Fl_Tabs {
+public:
+ using Fl_Tabs::Fl_Tabs;
-void fl_tabs_draw(TABS t) {
- reinterpret_cast<My_Tabs*>(t)->real_draw();
-}
+ friend void fl_tabs_draw(TABS t);
+ friend int fl_tabs_handle(TABS t, int e);
-void tabs_set_handle_hook(TABS t, void * h) {
- reinterpret_cast<My_Tabs*>(t)->handle_hook = reinterpret_cast<h_hook_p>(h);
+ void draw();
+ int handle(int e);
+};
+
+void My_Tabs::draw() {
+ widget_draw_hook(this->user_data());
}
-int fl_tabs_handle(TABS t, int e) {
- return reinterpret_cast<My_Tabs*>(t)->real_handle(e);
+int My_Tabs::handle(int e) {
+ return widget_handle_hook(this->user_data(), e);
}
+// Flattened C API
+
TABS new_fl_tabs(int x, int y, int w, int h, char* label) {
My_Tabs *t = new My_Tabs(x, y, w, h, label);
return t;
@@ -101,3 +93,19 @@ void * fl_tabs_which(TABS t, int x, int y) {
return reinterpret_cast<Fl_Tabs*>(t)->which(x,y);
}
+
+
+
+void fl_tabs_draw(TABS t) {
+ reinterpret_cast<My_Tabs*>(t)->Fl_Tabs::draw();
+}
+
+void fl_tabs_redraw_tabs(TABS t) {
+ (reinterpret_cast<Fl_Tabs*>(t)->*(&Friend_Tabs::redraw_tabs))();
+}
+
+int fl_tabs_handle(TABS t, int e) {
+ return reinterpret_cast<My_Tabs*>(t)->Fl_Tabs::handle(e);
+}
+
+