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_output.cpp | |
parent | 49f2a539cdc77b504ddef00162625531b659c767 (diff) |
Revised Input subhierarchy, separated bindings for Fl_Input and Fl_Input_ widgets
Diffstat (limited to 'src/c_fl_output.cpp')
-rw-r--r-- | src/c_fl_output.cpp | 69 |
1 files changed, 31 insertions, 38 deletions
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 <FL/Fl_Output.H> #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<My_Output*>(i)->draw_hook = reinterpret_cast<d_hook_p>(d); -} +// Attaching all relevant hooks and friends -void fl_output_draw(OUTPUTT i) { - reinterpret_cast<My_Output*>(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<My_Output*>(i)->handle_hook = reinterpret_cast<h_hook_p>(h); +void My_Output::draw() { + widget_draw_hook(this->user_data()); } -int fl_output_handle(OUTPUTT i, int e) { - return reinterpret_cast<My_Output*>(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<My_Output*>(i)->Fl_Output::draw(); +} + +int fl_output_handle(OUTPUTT i, int e) { + return reinterpret_cast<My_Output*>(i)->Fl_Output::handle(e); +} + + |