From 3a9028302447ad84363c580b2152f30417186667 Mon Sep 17 00:00:00 2001 From: Jedidiah Barber Date: Wed, 8 Jan 2025 14:33:30 +1300 Subject: Revised Input subhierarchy, separated bindings for Fl_Input and Fl_Input_ widgets --- src/c_fl_multiline_input.cpp | 69 ++++++++++++++++++++------------------------ 1 file changed, 31 insertions(+), 38 deletions(-) (limited to 'src/c_fl_multiline_input.cpp') 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 #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(i)->draw_hook = reinterpret_cast(d); -} -void fl_multiline_input_draw(MULTILINE_INPUT i) { - reinterpret_cast(i)->real_draw(); -} -void multiline_input_set_handle_hook(MULTILINE_INPUT i, void * h) { - reinterpret_cast(i)->handle_hook = reinterpret_cast(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(i)->real_handle(e); +void free_fl_multiline_input(MULTILINEINPUT i) { + delete reinterpret_cast(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(i)->Fl_Multiline_Input::draw(); } -void free_fl_multiline_input(MULTILINE_INPUT i) { - delete reinterpret_cast(i); +int fl_multiline_input_handle(MULTILINEINPUT i, int e) { + return reinterpret_cast(i)->Fl_Multiline_Input::handle(e); } -- cgit