summaryrefslogtreecommitdiff
path: root/src/c_fl_button.cpp
diff options
context:
space:
mode:
authorJed Barber <jjbarber@y7mail.com>2017-05-13 12:35:40 +1000
committerJed Barber <jjbarber@y7mail.com>2017-05-13 12:35:40 +1000
commit1c0ddbf9eeb33f6bedc1fb9156e124b3a7b17bbc (patch)
treed662c3fb080042625696734c194328a78f81de1b /src/c_fl_button.cpp
parent40d66b087fcf846c84da53c111ecbeb75bdd29ce (diff)
Handle method added for Boxes, Buttons, Widgets
Diffstat (limited to 'src/c_fl_button.cpp')
-rw-r--r--src/c_fl_button.cpp39
1 files changed, 35 insertions, 4 deletions
diff --git a/src/c_fl_button.cpp b/src/c_fl_button.cpp
index f031ff9..725a0bc 100644
--- a/src/c_fl_button.cpp
+++ b/src/c_fl_button.cpp
@@ -4,8 +4,14 @@
#include "c_fl_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_Button : public Fl_Button {
using Fl_Button::Fl_Button;
friend void button_set_draw_hook(BUTTON b, void * d);
friend void fl_button_draw(BUTTON b);
+ friend void button_set_handle_hook(BUTTON b, void * h);
+ friend int fl_button_handle(BUTTON 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_Button::real_draw() {
}
+int My_Button::handle(int e) {
+ return (*handle_hook)(this->user_data(), e);
+}
+
+
+int My_Button::real_handle(int e) {
+ return Fl_Button::handle(e);
+}
+
+
void button_set_draw_hook(BUTTON b, void * d) {
- reinterpret_cast<My_Button*>(b)->draw_hook = reinterpret_cast<hook_p>(d);
+ reinterpret_cast<My_Button*>(b)->draw_hook = reinterpret_cast<d_hook_p>(d);
}
@@ -42,6 +63,16 @@ void fl_button_draw(BUTTON b) {
}
+void button_set_handle_hook(BUTTON b, void * h) {
+ reinterpret_cast<My_Button*>(b)->handle_hook = reinterpret_cast<h_hook_p>(h);
+}
+
+
+int fl_button_handle(BUTTON b, int e) {
+ return reinterpret_cast<My_Button*>(b)->real_handle(e);
+}
+
+
BUTTON new_fl_button(int x, int y, int w, int h, char* label) {