From fbdef14a42388934067427854b6f5559bef31e8d Mon Sep 17 00:00:00 2001 From: Jed Barber Date: Mon, 1 May 2017 22:56:51 +1000 Subject: Draw method implemented for Groups, Menus, although Menus are now no longer abstract even though they should be --- src/c_fl_group.cpp | 62 ++++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 51 insertions(+), 11 deletions(-) (limited to 'src/c_fl_group.cpp') diff --git a/src/c_fl_group.cpp b/src/c_fl_group.cpp index 9ea2764..4546be0 100644 --- a/src/c_fl_group.cpp +++ b/src/c_fl_group.cpp @@ -6,64 +6,104 @@ #include "c_fl_widget.h" +typedef void (hook)(void*); +typedef hook* hook_p; + + + + +class My_Group : public Fl_Group { + public: + using Fl_Group::Fl_Group; + friend void group_set_draw_hook(GROUP g, void * d); + friend void fl_group_draw(GROUP g); + protected: + void draw(); + void real_draw(); + hook_p draw_hook; +}; + + +void My_Group::draw() { + (*draw_hook)(this->user_data()); +} + + +void My_Group::real_draw() { + Fl_Group::draw(); +} + + +void group_set_draw_hook(GROUP g, void * d) { + reinterpret_cast(g)->draw_hook = reinterpret_cast(d); +} + + +void fl_group_draw(GROUP g) { + reinterpret_cast(g)->real_draw(); +} + + + + GROUP new_fl_group(int x, int y, int w, int h, char* label) { - Fl_Group *g = new Fl_Group(x, y, w, h, label); + My_Group *g = new My_Group(x, y, w, h, label); return g; } void free_fl_group(GROUP g) { - delete reinterpret_cast(g); + delete reinterpret_cast(g); } void fl_group_end(GROUP g) { - reinterpret_cast(g)->end(); + reinterpret_cast(g)->end(); } void fl_group_add(GROUP g, WIDGET item) { - reinterpret_cast(g)->add(reinterpret_cast(item)); + reinterpret_cast(g)->add(reinterpret_cast(item)); } int fl_group_find(GROUP g, WIDGET item) { - return reinterpret_cast(g)->find(reinterpret_cast(item)); + return reinterpret_cast(g)->find(reinterpret_cast(item)); } void fl_group_insert(GROUP g, WIDGET item, int place) { - reinterpret_cast(g)->insert(*(reinterpret_cast(item)), place); + reinterpret_cast(g)->insert(*(reinterpret_cast(item)), place); } void fl_group_remove(GROUP g, WIDGET item) { - reinterpret_cast(g)->remove(reinterpret_cast(item)); + reinterpret_cast(g)->remove(reinterpret_cast(item)); } void fl_group_remove2(GROUP g, int place) { - reinterpret_cast(g)->remove(place); + reinterpret_cast(g)->remove(place); } void fl_group_resizable(GROUP g, WIDGET item) { - reinterpret_cast(g)->resizable(reinterpret_cast(item)); + reinterpret_cast(g)->resizable(reinterpret_cast(item)); } int fl_group_children(GROUP g) { - return reinterpret_cast(g)->children(); + return reinterpret_cast(g)->children(); } void * fl_group_child(GROUP g, int place) { - return reinterpret_cast(g)->child(place); + return reinterpret_cast(g)->child(place); } -- cgit