diff options
author | Jedidiah Barber <contact@jedbarber.id.au> | 2025-01-08 14:33:30 +1300 |
---|---|---|
committer | Jedidiah Barber <contact@jedbarber.id.au> | 2025-01-08 14:51:36 +1300 |
commit | 3a9028302447ad84363c580b2152f30417186667 (patch) | |
tree | 6f0e66ed7c0d831dfc744462335e76fdcb724d69 /src/c_fl_multiline_input.cpp | |
parent | 49f2a539cdc77b504ddef00162625531b659c767 (diff) |
Revised Input subhierarchy, separated bindings for Fl_Input and Fl_Input_ widgets
Diffstat (limited to 'src/c_fl_multiline_input.cpp')
-rw-r--r-- | src/c_fl_multiline_input.cpp | 69 |
1 files changed, 31 insertions, 38 deletions
diff --git a/src/c_fl_multiline_input.cpp b/src/c_fl_multiline_input.cpp index a329ab8..46d0a33 100644 --- a/src/c_fl_multiline_input.cpp +++ b/src/c_fl_multiline_input.cpp @@ -6,69 +6,62 @@ #include <FL/Fl_Multiline_Input.H> #include "c_fl_multiline_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_Multiline_Input : public Fl_Multiline_Input { - public: - using Fl_Multiline_Input::Fl_Multiline_Input; - friend void multiline_input_set_draw_hook(MULTILINE_INPUT i, void * d); - friend void fl_multiline_input_draw(MULTILINE_INPUT i); - friend void multiline_input_set_handle_hook(MULTILINE_INPUT i, void * h); - friend int fl_multiline_input_handle(MULTILINE_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_Multiline_Input::Fl_Multiline_Input; + + friend void fl_multiline_input_draw(MULTILINEINPUT i); + friend int fl_multiline_input_handle(MULTILINEINPUT i, int e); + + void draw(); + int handle(int e); }; void My_Multiline_Input::draw() { - (*draw_hook)(this->user_data()); -} - -void My_Multiline_Input::real_draw() { - Fl_Multiline_Input::draw(); + widget_draw_hook(this->user_data()); } int My_Multiline_Input::handle(int e) { - return (*handle_hook)(this->user_data(), e); + return widget_handle_hook(this->user_data(), e); } -int My_Multiline_Input::real_handle(int e) { - return Fl_Multiline_Input::handle(e); -} -void multiline_input_set_draw_hook(MULTILINE_INPUT i, void * d) { - reinterpret_cast<My_Multiline_Input*>(i)->draw_hook = reinterpret_cast<d_hook_p>(d); -} -void fl_multiline_input_draw(MULTILINE_INPUT i) { - reinterpret_cast<My_Multiline_Input*>(i)->real_draw(); -} -void multiline_input_set_handle_hook(MULTILINE_INPUT i, void * h) { - reinterpret_cast<My_Multiline_Input*>(i)->handle_hook = reinterpret_cast<h_hook_p>(h); +// Flattened C API + +MULTILINEINPUT new_fl_multiline_input(int x, int y, int w, int h, char* label) { + My_Multiline_Input *i = new My_Multiline_Input(x, y, w, h, label); + return i; } -int fl_multiline_input_handle(MULTILINE_INPUT i, int e) { - return reinterpret_cast<My_Multiline_Input*>(i)->real_handle(e); +void free_fl_multiline_input(MULTILINEINPUT i) { + delete reinterpret_cast<My_Multiline_Input*>(i); } -MULTILINE_INPUT new_fl_multiline_input(int x, int y, int w, int h, char* label) { - My_Multiline_Input *i = new My_Multiline_Input(x, y, w, h, label); - return i; +void fl_multiline_input_draw(MULTILINEINPUT i) { + reinterpret_cast<My_Multiline_Input*>(i)->Fl_Multiline_Input::draw(); } -void free_fl_multiline_input(MULTILINE_INPUT i) { - delete reinterpret_cast<My_Multiline_Input*>(i); +int fl_multiline_input_handle(MULTILINEINPUT i, int e) { + return reinterpret_cast<My_Multiline_Input*>(i)->Fl_Multiline_Input::handle(e); } |