diff options
Diffstat (limited to 'src/c_fl_choice.cpp')
-rw-r--r-- | src/c_fl_choice.cpp | 69 |
1 files changed, 31 insertions, 38 deletions
diff --git a/src/c_fl_choice.cpp b/src/c_fl_choice.cpp index 6d6a472..e8c8374 100644 --- a/src/c_fl_choice.cpp +++ b/src/c_fl_choice.cpp @@ -6,62 +6,44 @@ #include <FL/Fl_Choice.H> #include "c_fl_choice.h" -#include "c_fl_type.h" -class My_Choice : public Fl_Choice { - public: - using Fl_Choice::Fl_Choice; - friend void choice_set_draw_hook(CHOICE n, void * d); - friend void fl_choice_draw(CHOICE n); - friend void choice_set_handle_hook(CHOICE n, void * h); - friend int fl_choice_handle(CHOICE n, 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_Choice::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_Choice::real_draw() { - Fl_Choice::draw(); -} -int My_Choice::handle(int e) { - return (*handle_hook)(this->user_data(), e); -} -int My_Choice::real_handle(int e) { - return Fl_Choice::handle(e); -} -void choice_set_draw_hook(CHOICE n, void * d) { - reinterpret_cast<My_Choice*>(n)->draw_hook = reinterpret_cast<d_hook_p>(d); -} +// Attaching all relevant hooks and friends -void fl_choice_draw(CHOICE n) { - reinterpret_cast<My_Choice*>(n)->real_draw(); -} +class My_Choice : public Fl_Choice { +public: + using Fl_Choice::Fl_Choice; + + friend void fl_choice_draw(CHOICE n); + friend int fl_choice_handle(CHOICE n, int e); + + void draw(); + int handle(int e); +}; -void choice_set_handle_hook(CHOICE n, void * h) { - reinterpret_cast<My_Choice*>(n)->handle_hook = reinterpret_cast<h_hook_p>(h); +void My_Choice::draw() { + widget_draw_hook(this->user_data()); } -int fl_choice_handle(CHOICE n, int e) { - return reinterpret_cast<My_Choice*>(n)->real_handle(e); +int My_Choice::handle(int e) { + return widget_handle_hook(this->user_data(), e); } +// Flattened C API + CHOICE new_fl_choice(int x, int y, int w, int h, char* label) { My_Choice *b = new My_Choice(x, y, w, h, label); return b; @@ -87,3 +69,14 @@ int fl_choice_set_value2(CHOICE c, void * i) { } + + +void fl_choice_draw(CHOICE n) { + reinterpret_cast<My_Choice*>(n)->Fl_Choice::draw(); +} + +int fl_choice_handle(CHOICE n, int e) { + return reinterpret_cast<My_Choice*>(n)->Fl_Choice::handle(e); +} + + |