summaryrefslogtreecommitdiff
path: root/src/c_fl_widget.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_widget.cpp
parent40d66b087fcf846c84da53c111ecbeb75bdd29ce (diff)
Handle method added for Boxes, Buttons, Widgets
Diffstat (limited to 'src/c_fl_widget.cpp')
-rw-r--r--src/c_fl_widget.cpp27
1 files changed, 23 insertions, 4 deletions
diff --git a/src/c_fl_widget.cpp b/src/c_fl_widget.cpp
index 6dab9fa..d13d612 100644
--- a/src/c_fl_widget.cpp
+++ b/src/c_fl_widget.cpp
@@ -5,8 +5,14 @@
#include "c_fl_widget.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,13 @@ class My_Widget : public Fl_Widget {
public:
using Fl_Widget::Fl_Widget;
friend void widget_set_draw_hook(WIDGET w, void * d);
+ friend void widget_set_handle_hook(WIDGET w, void * h);
friend WIDGET new_fl_widget(int x, int y, int w, int h, char* label);
protected:
void draw();
- hook_p draw_hook;
+ int handle(int e);
+ d_hook_p draw_hook;
+ h_hook_p handle_hook;
};
@@ -27,8 +36,18 @@ void My_Widget::draw() {
}
+int My_Widget::handle(int e) {
+ return (*handle_hook)(this->user_data(), e);
+}
+
+
void widget_set_draw_hook(WIDGET w, void * d) {
- reinterpret_cast<My_Widget*>(w)->draw_hook = reinterpret_cast<hook_p>(d);
+ reinterpret_cast<My_Widget*>(w)->draw_hook = reinterpret_cast<d_hook_p>(d);
+}
+
+
+void widget_set_handle_hook(WIDGET w, void * h) {
+ reinterpret_cast<My_Widget*>(w)->handle_hook = reinterpret_cast<h_hook_p>(h);
}