From 371cccdf78fa9aaf49158ea57e598abcd5ff56f0 Mon Sep 17 00:00:00 2001 From: Jed Barber Date: Sun, 14 May 2017 11:13:43 +1000 Subject: File_Input, Float_Input, Integer_Input, Multiline_Input, Output, Multiline_Output, Secret_Input, Input, Menu, Menu_Bar, Menu_Button widgets all now have a Handle method --- src/c_fl_menu_button.cpp | 39 +++++++++++++++++++++++++++++++++++---- 1 file changed, 35 insertions(+), 4 deletions(-) (limited to 'src/c_fl_menu_button.cpp') diff --git a/src/c_fl_menu_button.cpp b/src/c_fl_menu_button.cpp index e4b963c..bc782a4 100644 --- a/src/c_fl_menu_button.cpp +++ b/src/c_fl_menu_button.cpp @@ -4,8 +4,14 @@ #include "c_fl_menu_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_Menu_Button : public Fl_Menu_Button { using Fl_Menu_Button::Fl_Menu_Button; friend void menu_button_set_draw_hook(MENUBUTTON m, void * d); friend void fl_menu_button_draw(MENUBUTTON m); + friend void menu_button_set_handle_hook(MENUBUTTON m, void * h); + friend int fl_menu_button_handle(MENUBUTTON m, 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_Menu_Button::real_draw() { } +int My_Menu_Button::handle(int e) { + return (*handle_hook)(this->user_data(), e); +} + + +int My_Menu_Button::real_handle(int e) { + return Fl_Menu_Button::handle(e); +} + + void menu_button_set_draw_hook(MENUBUTTON m, void * d) { - reinterpret_cast(m)->draw_hook = reinterpret_cast(d); + reinterpret_cast(m)->draw_hook = reinterpret_cast(d); } @@ -42,6 +63,16 @@ void fl_menu_button_draw(MENUBUTTON m) { } +void menu_button_set_handle_hook(MENUBUTTON m, void * h) { + reinterpret_cast(m)->handle_hook = reinterpret_cast(h); +} + + +int fl_menu_button_handle(MENUBUTTON m, int e) { + return reinterpret_cast(m)->real_handle(e); +} + + MENUBUTTON new_fl_menu_button(int x, int y, int w, int h, char* label) { -- cgit