summaryrefslogtreecommitdiff
path: root/src/c_fl_repeat_button.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_repeat_button.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_repeat_button.cpp')
-rw-r--r--src/c_fl_repeat_button.cpp75
1 files changed, 38 insertions, 37 deletions
diff --git a/src/c_fl_repeat_button.cpp b/src/c_fl_repeat_button.cpp
index fbbbf35..7f05235 100644
--- a/src/c_fl_repeat_button.cpp
+++ b/src/c_fl_repeat_button.cpp
@@ -6,68 +6,69 @@
#include <FL/Fl_Repeat_Button.H>
#include "c_fl_repeat_button.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_Repeat_Button : public Fl_Repeat_Button {
- public:
- using Fl_Repeat_Button::Fl_Repeat_Button;
- friend void repeat_button_set_draw_hook(REPEATBUTTON b, void * d);
- friend void fl_repeat_button_draw(REPEATBUTTON b);
- friend void repeat_button_set_handle_hook(REPEATBUTTON b, void * h);
- friend int fl_repeat_button_handle(REPEATBUTTON b, 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_Repeat_Button::Fl_Repeat_Button;
+
+ friend void fl_repeat_button_draw(REPEATBUTTON b);
+ friend int fl_repeat_button_handle(REPEATBUTTON b, int e);
+
+ void draw();
+ int handle(int e);
};
void My_Repeat_Button::draw() {
- (*draw_hook)(this->user_data());
-}
-
-void My_Repeat_Button::real_draw() {
- Fl_Repeat_Button::draw();
+ widget_draw_hook(this->user_data());
}
int My_Repeat_Button::handle(int e) {
- return (*handle_hook)(this->user_data(), e);
+ return widget_handle_hook(this->user_data(), e);
}
-int My_Repeat_Button::real_handle(int e) {
- return Fl_Repeat_Button::handle(e);
-}
-void repeat_button_set_draw_hook(REPEATBUTTON b, void * d) {
- reinterpret_cast<My_Repeat_Button*>(b)->draw_hook = reinterpret_cast<d_hook_p>(d);
-}
-void fl_repeat_button_draw(REPEATBUTTON b) {
- reinterpret_cast<My_Repeat_Button*>(b)->real_draw();
+
+// Flattened C API
+
+REPEATBUTTON new_fl_repeat_button(int x, int y, int w, int h, char* label) {
+ My_Repeat_Button *b = new My_Repeat_Button(x, y, w, h, label);
+ return b;
}
-void repeat_button_set_handle_hook(REPEATBUTTON b, void * h) {
- reinterpret_cast<My_Repeat_Button*>(b)->handle_hook = reinterpret_cast<h_hook_p>(h);
+void free_fl_repeat_button(REPEATBUTTON b) {
+ delete reinterpret_cast<My_Repeat_Button*>(b);
}
-int fl_repeat_button_handle(REPEATBUTTON b, int e) {
- return reinterpret_cast<My_Repeat_Button*>(b)->real_handle(e);
+
+
+
+void fl_repeat_button_deactivate(REPEATBUTTON b) {
+ reinterpret_cast<Fl_Repeat_Button*>(b)->deactivate();
}
-REPEATBUTTON new_fl_repeat_button(int x, int y, int w, int h, char* label) {
- My_Repeat_Button *b = new My_Repeat_Button(x, y, w, h, label);
- return b;
+void fl_repeat_button_draw(REPEATBUTTON b) {
+ reinterpret_cast<My_Repeat_Button*>(b)->Fl_Repeat_Button::draw();
}
-void free_fl_repeat_button(REPEATBUTTON b) {
- delete reinterpret_cast<My_Repeat_Button*>(b);
+int fl_repeat_button_handle(REPEATBUTTON b, int e) {
+ return reinterpret_cast<My_Repeat_Button*>(b)->Fl_Repeat_Button::handle(e);
}
+