summaryrefslogtreecommitdiff
path: root/src/c_fl_text_editor.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/c_fl_text_editor.cpp')
-rw-r--r--src/c_fl_text_editor.cpp39
1 files changed, 35 insertions, 4 deletions
diff --git a/src/c_fl_text_editor.cpp b/src/c_fl_text_editor.cpp
index 156d439..6608af9 100644
--- a/src/c_fl_text_editor.cpp
+++ b/src/c_fl_text_editor.cpp
@@ -4,8 +4,14 @@
#include "c_fl_text_editor.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_Text_Editor : public Fl_Text_Editor {
using Fl_Text_Editor::Fl_Text_Editor;
friend void text_editor_set_draw_hook(TEXTEDITOR te, void * d);
friend void fl_text_editor_draw(TEXTEDITOR te);
+ friend void text_editor_set_handle_hook(TEXTEDITOR te, void * h);
+ friend int fl_text_editor_handle(TEXTEDITOR te, 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_Text_Editor::real_draw() {
}
+int My_Text_Editor::handle(int e) {
+ return (*handle_hook)(this->user_data(), e);
+}
+
+
+int My_Text_Editor::real_handle(int e) {
+ return Fl_Text_Editor::handle(e);
+}
+
+
void text_editor_set_draw_hook(TEXTEDITOR te, void * d) {
- reinterpret_cast<My_Text_Editor*>(te)->draw_hook = reinterpret_cast<hook_p>(d);
+ reinterpret_cast<My_Text_Editor*>(te)->draw_hook = reinterpret_cast<d_hook_p>(d);
}
@@ -42,6 +63,16 @@ void fl_text_editor_draw(TEXTEDITOR te) {
}
+void text_editor_set_handle_hook(TEXTEDITOR te, void * h) {
+ reinterpret_cast<My_Text_Editor*>(te)->handle_hook = reinterpret_cast<h_hook_p>(h);
+}
+
+
+int fl_text_editor_handle(TEXTEDITOR te, int e) {
+ return reinterpret_cast<My_Text_Editor*>(te)->real_handle(e);
+}
+
+
TEXTEDITOR new_fl_text_editor(int x, int y, int w, int h, char* label) {