summaryrefslogtreecommitdiff
path: root/src/c_fl_float_input.cpp
diff options
context:
space:
mode:
authorJedidiah Barber <contact@jedbarber.id.au>2025-01-08 14:33:30 +1300
committerJedidiah Barber <contact@jedbarber.id.au>2025-01-08 14:51:36 +1300
commit3a9028302447ad84363c580b2152f30417186667 (patch)
tree6f0e66ed7c0d831dfc744462335e76fdcb724d69 /src/c_fl_float_input.cpp
parent49f2a539cdc77b504ddef00162625531b659c767 (diff)
Revised Input subhierarchy, separated bindings for Fl_Input and Fl_Input_ widgets
Diffstat (limited to 'src/c_fl_float_input.cpp')
-rw-r--r--src/c_fl_float_input.cpp69
1 files changed, 31 insertions, 38 deletions
diff --git a/src/c_fl_float_input.cpp b/src/c_fl_float_input.cpp
index 304f250..c5ce3e1 100644
--- a/src/c_fl_float_input.cpp
+++ b/src/c_fl_float_input.cpp
@@ -6,69 +6,62 @@
#include <FL/Fl_Float_Input.H>
#include "c_fl_float_input.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_Float_Input : public Fl_Float_Input {
- public:
- using Fl_Float_Input::Fl_Float_Input;
- friend void float_input_set_draw_hook(FLOAT_INPUT i, void * d);
- friend void fl_float_input_draw(FLOAT_INPUT i);
- friend void float_input_set_handle_hook(FLOAT_INPUT i, void * h);
- friend int fl_float_input_handle(FLOAT_INPUT i, 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_Float_Input::Fl_Float_Input;
+
+ friend void fl_float_input_draw(FLOATINPUT i);
+ friend int fl_float_input_handle(FLOATINPUT i, int e);
+
+ void draw();
+ int handle(int e);
};
void My_Float_Input::draw() {
- (*draw_hook)(this->user_data());
-}
-
-void My_Float_Input::real_draw() {
- Fl_Float_Input::draw();
+ widget_draw_hook(this->user_data());
}
int My_Float_Input::handle(int e) {
- return (*handle_hook)(this->user_data(), e);
+ return widget_handle_hook(this->user_data(), e);
}
-int My_Float_Input::real_handle(int e) {
- return Fl_Float_Input::handle(e);
-}
-void float_input_set_draw_hook(FLOAT_INPUT i, void * d) {
- reinterpret_cast<My_Float_Input*>(i)->draw_hook = reinterpret_cast<d_hook_p>(d);
-}
-void fl_float_input_draw(FLOAT_INPUT i) {
- reinterpret_cast<My_Float_Input*>(i)->real_draw();
-}
-void float_input_set_handle_hook(FLOAT_INPUT i, void * h) {
- reinterpret_cast<My_Float_Input*>(i)->handle_hook = reinterpret_cast<h_hook_p>(h);
+// Flattened C API
+
+FLOATINPUT new_fl_float_input(int x, int y, int w, int h, char* label) {
+ My_Float_Input *i = new My_Float_Input(x, y, w, h, label);
+ return i;
}
-int fl_float_input_handle(FLOAT_INPUT i, int e) {
- return reinterpret_cast<My_Float_Input*>(i)->real_handle(e);
+void free_fl_float_input(FLOATINPUT i) {
+ delete reinterpret_cast<My_Float_Input*>(i);
}
-FLOAT_INPUT new_fl_float_input(int x, int y, int w, int h, char* label) {
- My_Float_Input *i = new My_Float_Input(x, y, w, h, label);
- return i;
+void fl_float_input_draw(FLOATINPUT i) {
+ reinterpret_cast<My_Float_Input*>(i)->Fl_Float_Input::draw();
}
-void free_fl_float_input(FLOAT_INPUT i) {
- delete reinterpret_cast<My_Float_Input*>(i);
+int fl_float_input_handle(FLOATINPUT i, int e) {
+ return reinterpret_cast<My_Float_Input*>(i)->Fl_Float_Input::handle(e);
}