diff options
Diffstat (limited to 'src/c_fl_multiline_output.cpp')
-rw-r--r-- | src/c_fl_multiline_output.cpp | 69 |
1 files changed, 31 insertions, 38 deletions
diff --git a/src/c_fl_multiline_output.cpp b/src/c_fl_multiline_output.cpp index 1b44e58..6be13a2 100644 --- a/src/c_fl_multiline_output.cpp +++ b/src/c_fl_multiline_output.cpp @@ -6,69 +6,62 @@ #include <FL/Fl_Multiline_Output.H> #include "c_fl_multiline_output.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_Output : public Fl_Multiline_Output { - public: - using Fl_Multiline_Output::Fl_Multiline_Output; - friend void multiline_output_set_draw_hook(MULTILINE_OUTPUT i, void * d); - friend void fl_multiline_output_draw(MULTILINE_OUTPUT i); - friend void multiline_output_set_handle_hook(MULTILINE_OUTPUT i, void * h); - friend int fl_multiline_output_handle(MULTILINE_OUTPUT 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_Output::Fl_Multiline_Output; + + friend void fl_multiline_output_draw(MULTILINEOUTPUT i); + friend int fl_multiline_output_handle(MULTILINEOUTPUT i, int e); + + void draw(); + int handle(int e); }; void My_Multiline_Output::draw() { - (*draw_hook)(this->user_data()); -} - -void My_Multiline_Output::real_draw() { - Fl_Multiline_Output::draw(); + widget_draw_hook(this->user_data()); } int My_Multiline_Output::handle(int e) { - return (*handle_hook)(this->user_data(), e); + return widget_handle_hook(this->user_data(), e); } -int My_Multiline_Output::real_handle(int e) { - return Fl_Multiline_Output::handle(e); -} -void multiline_output_set_draw_hook(MULTILINE_OUTPUT i, void * d) { - reinterpret_cast<My_Multiline_Output*>(i)->draw_hook = reinterpret_cast<d_hook_p>(d); -} -void fl_multiline_output_draw(MULTILINE_OUTPUT i) { - reinterpret_cast<My_Multiline_Output*>(i)->real_draw(); -} -void multiline_output_set_handle_hook(MULTILINE_OUTPUT i, void * h) { - reinterpret_cast<My_Multiline_Output*>(i)->handle_hook = reinterpret_cast<h_hook_p>(h); +// Flattened C API + +MULTILINEOUTPUT new_fl_multiline_output(int x, int y, int w, int h, char* label) { + My_Multiline_Output *i = new My_Multiline_Output(x, y, w, h, label); + return i; } -int fl_multiline_output_handle(MULTILINE_OUTPUT i, int e) { - return reinterpret_cast<My_Multiline_Output*>(i)->real_handle(e); +void free_fl_multiline_output(MULTILINEOUTPUT i) { + delete reinterpret_cast<My_Multiline_Output*>(i); } -MULTILINE_OUTPUT new_fl_multiline_output(int x, int y, int w, int h, char* label) { - My_Multiline_Output *i = new My_Multiline_Output(x, y, w, h, label); - return i; +void fl_multiline_output_draw(MULTILINEOUTPUT i) { + reinterpret_cast<My_Multiline_Output*>(i)->Fl_Multiline_Output::draw(); } -void free_fl_multiline_output(MULTILINE_OUTPUT i) { - delete reinterpret_cast<My_Multiline_Output*>(i); +int fl_multiline_output_handle(MULTILINEOUTPUT i, int e) { + return reinterpret_cast<My_Multiline_Output*>(i)->Fl_Multiline_Output::handle(e); } |