summaryrefslogtreecommitdiff
path: root/src/c_fl_int_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_int_input.cpp
parent49f2a539cdc77b504ddef00162625531b659c767 (diff)
Revised Input subhierarchy, separated bindings for Fl_Input and Fl_Input_ widgets
Diffstat (limited to 'src/c_fl_int_input.cpp')
-rw-r--r--src/c_fl_int_input.cpp69
1 files changed, 31 insertions, 38 deletions
diff --git a/src/c_fl_int_input.cpp b/src/c_fl_int_input.cpp
index 393af90..0f90cf2 100644
--- a/src/c_fl_int_input.cpp
+++ b/src/c_fl_int_input.cpp
@@ -6,69 +6,62 @@
#include <FL/Fl_Int_Input.H>
#include "c_fl_int_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_Int_Input : public Fl_Int_Input {
- public:
- using Fl_Int_Input::Fl_Int_Input;
- friend void int_input_set_draw_hook(INT_INPUT i, void * d);
- friend void fl_int_input_draw(INT_INPUT i);
- friend void int_input_set_handle_hook(INT_INPUT i, void * h);
- friend int fl_int_input_handle(INT_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_Int_Input::Fl_Int_Input;
+
+ friend void fl_int_input_draw(INTINPUT i);
+ friend int fl_int_input_handle(INTINPUT i, int e);
+
+ void draw();
+ int handle(int e);
};
void My_Int_Input::draw() {
- (*draw_hook)(this->user_data());
-}
-
-void My_Int_Input::real_draw() {
- Fl_Int_Input::draw();
+ widget_draw_hook(this->user_data());
}
int My_Int_Input::handle(int e) {
- return (*handle_hook)(this->user_data(), e);
+ return widget_handle_hook(this->user_data(), e);
}
-int My_Int_Input::real_handle(int e) {
- return Fl_Int_Input::handle(e);
-}
-void int_input_set_draw_hook(INT_INPUT i, void * d) {
- reinterpret_cast<My_Int_Input*>(i)->draw_hook = reinterpret_cast<d_hook_p>(d);
-}
-void fl_int_input_draw(INT_INPUT i) {
- reinterpret_cast<My_Int_Input*>(i)->real_draw();
-}
-void int_input_set_handle_hook(INT_INPUT i, void * h) {
- reinterpret_cast<My_Int_Input*>(i)->handle_hook = reinterpret_cast<h_hook_p>(h);
+// Flattened C API
+
+INTINPUT new_fl_int_input(int x, int y, int w, int h, char* label) {
+ My_Int_Input *i = new My_Int_Input(x, y, w, h, label);
+ return i;
}
-int fl_int_input_handle(INT_INPUT i, int e) {
- return reinterpret_cast<My_Int_Input*>(i)->real_handle(e);
+void free_fl_int_input(INTINPUT i) {
+ delete reinterpret_cast<My_Int_Input*>(i);
}
-INT_INPUT new_fl_int_input(int x, int y, int w, int h, char* label) {
- My_Int_Input *i = new My_Int_Input(x, y, w, h, label);
- return i;
+void fl_int_input_draw(INTINPUT i) {
+ reinterpret_cast<My_Int_Input*>(i)->Fl_Int_Input::draw();
}
-void free_fl_int_input(INT_INPUT i) {
- delete reinterpret_cast<My_Int_Input*>(i);
+int fl_int_input_handle(INTINPUT i, int e) {
+ return reinterpret_cast<My_Int_Input*>(i)->Fl_Int_Input::handle(e);
}