From 306adba6ddaab80c6929fe955567f25d9da7915f Mon Sep 17 00:00:00 2001 From: Jed Barber Date: Mon, 1 May 2017 17:45:13 +1000 Subject: Draw method for Text Display and derivatives, concrete Menu_ derivatives --- src/c_fl_text_editor.cpp | 56 +++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 48 insertions(+), 8 deletions(-) (limited to 'src/c_fl_text_editor.cpp') diff --git a/src/c_fl_text_editor.cpp b/src/c_fl_text_editor.cpp index c28f6fa..a99774f 100644 --- a/src/c_fl_text_editor.cpp +++ b/src/c_fl_text_editor.cpp @@ -4,45 +4,85 @@ #include "c_fl_text_editor.h" +typedef void (hook)(void*); +typedef hook* hook_p; + + + + +class My_Text_Editor : public Fl_Text_Editor { + public: + 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); + protected: + void draw(); + void real_draw(); + hook_p draw_hook; +}; + + +void My_Text_Editor::draw() { + (*draw_hook)(this->user_data()); +} + + +void My_Text_Editor::real_draw() { + Fl_Text_Editor::draw(); +} + + +void text_editor_set_draw_hook(TEXTEDITOR te, void * d) { + reinterpret_cast(te)->draw_hook = reinterpret_cast(d); +} + + +void fl_text_editor_draw(TEXTEDITOR te) { + reinterpret_cast(te)->real_draw(); +} + + + + TEXTEDITOR new_fl_text_editor(int x, int y, int w, int h, char* label) { - Fl_Text_Editor *te = new Fl_Text_Editor(x, y, w, h, label); + My_Text_Editor *te = new My_Text_Editor(x, y, w, h, label); return te; } void free_fl_text_editor(TEXTEDITOR te) { - delete reinterpret_cast(te); + delete reinterpret_cast(te); } void fl_text_editor_undo(TEXTEDITOR te) { - Fl_Text_Editor::kf_undo(0, reinterpret_cast(te)); + My_Text_Editor::kf_undo(0, reinterpret_cast(te)); } void fl_text_editor_cut(TEXTEDITOR te) { - Fl_Text_Editor::kf_cut(0, reinterpret_cast(te)); + My_Text_Editor::kf_cut(0, reinterpret_cast(te)); } void fl_text_editor_copy(TEXTEDITOR te) { - Fl_Text_Editor::kf_copy(0, reinterpret_cast(te)); + My_Text_Editor::kf_copy(0, reinterpret_cast(te)); } void fl_text_editor_paste(TEXTEDITOR te) { - Fl_Text_Editor::kf_paste(0, reinterpret_cast(te)); + My_Text_Editor::kf_paste(0, reinterpret_cast(te)); } void fl_text_editor_delete(TEXTEDITOR te) { - Fl_Text_Editor::kf_delete(0, reinterpret_cast(te)); + My_Text_Editor::kf_delete(0, reinterpret_cast(te)); } void fl_text_editor_remove_key_binding(TEXTEDITOR te, unsigned int k, unsigned long m) { - reinterpret_cast(te)->remove_key_binding(k, m); + reinterpret_cast(te)->remove_key_binding(k, m); } -- cgit