diff options
Diffstat (limited to 'src/c_fl_progress.cpp')
-rw-r--r-- | src/c_fl_progress.cpp | 70 |
1 files changed, 32 insertions, 38 deletions
diff --git a/src/c_fl_progress.cpp b/src/c_fl_progress.cpp index 2e49643..9c18300 100644 --- a/src/c_fl_progress.cpp +++ b/src/c_fl_progress.cpp @@ -6,62 +6,44 @@ #include <FL/Fl_Progress.H> #include "c_fl_progress.h" -#include "c_fl_type.h" -class My_Progress : public Fl_Progress { - public: - using Fl_Progress::Fl_Progress; - friend void progress_set_draw_hook(PROGRESS p, void * d); - friend void fl_progress_draw(PROGRESS p); - friend void progress_set_handle_hook(PROGRESS p, void * h); - friend int fl_progress_handle(PROGRESS p, 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_Progress::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_Progress::real_draw() { - Fl_Progress::draw(); -} -int My_Progress::handle(int e) { - return (*handle_hook)(this->user_data(), e); -} -int My_Progress::real_handle(int e) { - return Fl_Progress::handle(e); -} -void progress_set_draw_hook(PROGRESS p, void * d) { - reinterpret_cast<My_Progress*>(p)->draw_hook = reinterpret_cast<d_hook_p>(d); -} +// Attaching all relevant hooks and friends -void fl_progress_draw(PROGRESS p) { - reinterpret_cast<My_Progress*>(p)->real_draw(); -} +class My_Progress : public Fl_Progress { +public: + using Fl_Progress::Fl_Progress; + + friend void fl_progress_draw(PROGRESS p); + friend int fl_progress_handle(PROGRESS p, int e); + + void draw(); + int handle(int e); +}; -void progress_set_handle_hook(PROGRESS p, void * h) { - reinterpret_cast<My_Progress*>(p)->handle_hook = reinterpret_cast<h_hook_p>(h); +void My_Progress::draw() { + widget_draw_hook(this->user_data()); } -int fl_progress_handle(PROGRESS p, int e) { - return reinterpret_cast<My_Progress*>(p)->real_handle(e); +int My_Progress::handle(int e) { + return widget_handle_hook(this->user_data(), e); } +// Flattened C API + PROGRESS new_fl_progress(int x, int y, int w, int h, char* label) { My_Progress *p = new My_Progress(x, y, w, h, label); return p; @@ -98,3 +80,15 @@ void fl_progress_set_value(PROGRESS p, float t) { reinterpret_cast<Fl_Progress*>(p)->value(t); } + + + +void fl_progress_draw(PROGRESS p) { + reinterpret_cast<My_Progress*>(p)->Fl_Progress::draw(); +} + +int fl_progress_handle(PROGRESS p, int e) { + return reinterpret_cast<My_Progress*>(p)->Fl_Progress::handle(e); +} + + |