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_output.cpp | 69 ++++++++++++++++++++++++----------------------------- 1 file changed, 31 insertions(+), 38 deletions(-) (limited to 'src/c_fl_output.cpp') diff --git a/src/c_fl_output.cpp b/src/c_fl_output.cpp index d591c59..2251f8d 100644 --- a/src/c_fl_output.cpp +++ b/src/c_fl_output.cpp @@ -6,62 +6,44 @@ #include #include "c_fl_output.h" -#include "c_fl_type.h" -class My_Output : public Fl_Output { - public: - using Fl_Output::Fl_Output; - friend void output_set_draw_hook(OUTPUTT i, void * d); - friend void fl_output_draw(OUTPUTT i); - friend void output_set_handle_hook(OUTPUTT i, void * h); - friend int fl_output_handle(OUTPUTT 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; -}; +// Exports from Ada -void My_Output::draw() { - (*draw_hook)(this->user_data()); -} +extern "C" void widget_draw_hook(void * ud); +extern "C" int widget_handle_hook(void * ud, int e); -void My_Output::real_draw() { - Fl_Output::draw(); -} -int My_Output::handle(int e) { - return (*handle_hook)(this->user_data(), e); -} -int My_Output::real_handle(int e) { - return Fl_Output::handle(e); -} -void output_set_draw_hook(OUTPUTT i, void * d) { - reinterpret_cast(i)->draw_hook = reinterpret_cast(d); -} +// Attaching all relevant hooks and friends -void fl_output_draw(OUTPUTT i) { - reinterpret_cast(i)->real_draw(); -} +class My_Output : public Fl_Output { +public: + using Fl_Output::Fl_Output; + + friend void fl_output_draw(OUTPUTT i); + friend int fl_output_handle(OUTPUTT i, int e); + + void draw(); + int handle(int e); +}; -void output_set_handle_hook(OUTPUTT i, void * h) { - reinterpret_cast(i)->handle_hook = reinterpret_cast(h); +void My_Output::draw() { + widget_draw_hook(this->user_data()); } -int fl_output_handle(OUTPUTT i, int e) { - return reinterpret_cast(i)->real_handle(e); +int My_Output::handle(int e) { + return widget_handle_hook(this->user_data(), e); } +// Flattened C API + OUTPUTT new_fl_output(int x, int y, int w, int h, char* label) { My_Output *i = new My_Output(x, y, w, h, label); return i; @@ -72,3 +54,14 @@ void free_fl_output(OUTPUTT i) { } + + +void fl_output_draw(OUTPUTT i) { + reinterpret_cast(i)->Fl_Output::draw(); +} + +int fl_output_handle(OUTPUTT i, int e) { + return reinterpret_cast(i)->Fl_Output::handle(e); +} + + -- cgit