diff options
Diffstat (limited to 'src/c_fl_box.cpp')
-rw-r--r-- | src/c_fl_box.cpp | 44 |
1 files changed, 42 insertions, 2 deletions
diff --git a/src/c_fl_box.cpp b/src/c_fl_box.cpp index eeee320..18afb1a 100644 --- a/src/c_fl_box.cpp +++ b/src/c_fl_box.cpp @@ -4,13 +4,53 @@ #include "c_fl_box.h" +typedef void (hook)(void*); +typedef hook* hook_p; + + + + +class My_Box : public Fl_Box { + public: + using Fl_Box::Fl_Box; + friend void box_set_draw_hook(BOX n, void * d); + friend void fl_box_draw(BOX n); + protected: + void draw(); + void real_draw(); + hook_p draw_hook; +}; + + +void My_Box::draw() { + (*draw_hook)(this->user_data()); +} + + +void My_Box::real_draw() { + Fl_Box::draw(); +} + + +void box_set_draw_hook(BOX n, void * d) { + reinterpret_cast<My_Box*>(n)->draw_hook = reinterpret_cast<hook_p>(d); +} + + +void fl_box_draw(BOX n) { + reinterpret_cast<My_Box*>(n)->real_draw(); +} + + + + BOX new_fl_box(int x, int y, int w, int h, char* label) { - Fl_Box *b = new Fl_Box(x, y, w, h, label); + My_Box *b = new My_Box(x, y, w, h, label); return b; } void free_fl_box(BOX b) { - delete reinterpret_cast<Fl_Box*>(b); + delete reinterpret_cast<My_Box*>(b); } |