From e35f258838e3a5e5d3458e9d9210deaaace08e9d Mon Sep 17 00:00:00 2001 From: Jed Barber Date: Sat, 13 May 2017 16:18:00 +1000 Subject: Enter_Button, Check_Button, Radio_Light_Button, Light_Button widgets now have Handle methods --- src/c_fl_radio_light_button.cpp | 39 +++++++++++++++++++++++++++++++++++---- 1 file changed, 35 insertions(+), 4 deletions(-) (limited to 'src/c_fl_radio_light_button.cpp') diff --git a/src/c_fl_radio_light_button.cpp b/src/c_fl_radio_light_button.cpp index c865480..3ffea4f 100644 --- a/src/c_fl_radio_light_button.cpp +++ b/src/c_fl_radio_light_button.cpp @@ -4,8 +4,14 @@ #include "c_fl_radio_light_button.h" -typedef void (hook)(void*); -typedef hook* hook_p; + + +typedef void (d_hook)(void*); +typedef d_hook* d_hook_p; + + +typedef int (h_hook)(void*,int); +typedef h_hook* h_hook_p; @@ -15,10 +21,15 @@ class My_Radio_Light_Button : public Fl_Radio_Light_Button { using Fl_Radio_Light_Button::Fl_Radio_Light_Button; friend void radio_light_button_set_draw_hook(RADIOLIGHTBUTTON b, void * d); friend void fl_radio_light_button_draw(RADIOLIGHTBUTTON b); + friend void radio_light_button_set_handle_hook(RADIOLIGHTBUTTON b, void * h); + friend int fl_radio_light_button_handle(RADIOLIGHTBUTTON b, int e); protected: void draw(); void real_draw(); - hook_p draw_hook; + int handle(int e); + int real_handle(int e); + d_hook_p draw_hook; + h_hook_p handle_hook; }; @@ -32,8 +43,18 @@ void My_Radio_Light_Button::real_draw() { } +int My_Radio_Light_Button::handle(int e) { + return (*handle_hook)(this->user_data(), e); +} + + +int My_Radio_Light_Button::real_handle(int e) { + return Fl_Radio_Light_Button::handle(e); +} + + void radio_light_button_set_draw_hook(RADIOLIGHTBUTTON b, void * d) { - reinterpret_cast(b)->draw_hook = reinterpret_cast(d); + reinterpret_cast(b)->draw_hook = reinterpret_cast(d); } @@ -42,6 +63,16 @@ void fl_radio_light_button_draw(RADIOLIGHTBUTTON b) { } +void radio_light_button_set_handle_hook(RADIOLIGHTBUTTON b, void * h) { + reinterpret_cast(b)->handle_hook = reinterpret_cast(h); +} + + +int fl_radio_light_button_handle(RADIOLIGHTBUTTON b, int e) { + return reinterpret_cast(b)->real_handle(e); +} + + RADIOLIGHTBUTTON new_fl_radio_light_button(int x, int y, int w, int h, char* label) { -- cgit