From e9dc75679fcac3bf2024e47641941d0a5ef0899d Mon Sep 17 00:00:00 2001 From: Jed Barber Date: Mon, 1 May 2017 12:49:40 +1000 Subject: Draw method implemented for Boxes/Inputs --- src/c_fl_box.cpp | 44 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 42 insertions(+), 2 deletions(-) (limited to 'src/c_fl_box.cpp') 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(n)->draw_hook = reinterpret_cast(d); +} + + +void fl_box_draw(BOX n) { + reinterpret_cast(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(b); + delete reinterpret_cast(b); } -- cgit