summaryrefslogtreecommitdiff
path: root/src/c_fl_help_view.cpp
diff options
context:
space:
mode:
authorJedidiah Barber <contact@jedbarber.id.au>2025-01-12 01:14:58 +1300
committerJedidiah Barber <contact@jedbarber.id.au>2025-01-12 01:14:58 +1300
commite93b9bbc02e2791f3a35b6f077fcbb8514c28aed (patch)
tree3661530027db6809a9cbad7b2477416009e00787 /src/c_fl_help_view.cpp
parent53aa8144851913994b963ed611cca8885b8f9a9e (diff)
Refactored draw/handle methods in Widgets hierarchy, improved docs, added a few minor method bindings here and there
Diffstat (limited to 'src/c_fl_help_view.cpp')
-rw-r--r--src/c_fl_help_view.cpp89
1 files changed, 43 insertions, 46 deletions
diff --git a/src/c_fl_help_view.cpp b/src/c_fl_help_view.cpp
index 33f1e5f..50d5d58 100644
--- a/src/c_fl_help_view.cpp
+++ b/src/c_fl_help_view.cpp
@@ -8,70 +8,44 @@
#include <FL/Fl_Help_View.H>
#include <FL/Enumerations.H>
#include "c_fl_help_view.h"
-#include "c_fl_type.h"
-class My_Help_View : public Fl_Help_View {
- public:
- using Fl_Help_View::Fl_Help_View;
- friend void help_view_set_draw_hook(HELPVIEW v, void * d);
- friend void fl_help_view_draw(HELPVIEW v);
- friend void help_view_set_handle_hook(HELPVIEW v, void * h);
- friend int fl_help_view_handle(HELPVIEW v, int e);
- protected:
- void draw();
- void real_draw();
- int handle(int e);
- int real_handle(int e);
- d_hook_p draw_hook;
- h_hook_p handle_hook;
-};
+// Exports from Ada
-void My_Help_View::draw() {
- (*draw_hook)(this->user_data());
-}
+extern "C" void widget_draw_hook(void * ud);
+extern "C" int widget_handle_hook(void * ud, int e);
-void My_Help_View::real_draw() {
- #if FL_ABI_VERSION >= 10303
- Fl_Help_View::draw();
- #else
- Fl_Group::draw();
- #endif
-}
-int My_Help_View::handle(int e) {
- return (*handle_hook)(this->user_data(), e);
-}
-int My_Help_View::real_handle(int e) {
- #if FL_ABI_VERSION >= 10303
- return Fl_Help_View::handle(e);
- #else
- return Fl_Group::handle(e);
- #endif
-}
-void help_view_set_draw_hook(HELPVIEW v, void * d) {
- reinterpret_cast<My_Help_View*>(v)->draw_hook = reinterpret_cast<d_hook_p>(d);
-}
+// Attaching all relevant hooks and friends
-void fl_help_view_draw(HELPVIEW v) {
- reinterpret_cast<My_Help_View*>(v)->real_draw();
-}
+class My_Help_View : public Fl_Help_View {
+public:
+ using Fl_Help_View::Fl_Help_View;
+
+ friend void fl_help_view_draw(HELPVIEW v);
+ friend int fl_help_view_handle(HELPVIEW v, int e);
+
+ void draw();
+ int handle(int e);
+};
-void help_view_set_handle_hook(HELPVIEW v, void * h) {
- reinterpret_cast<My_Help_View*>(v)->handle_hook = reinterpret_cast<h_hook_p>(h);
+void My_Help_View::draw() {
+ widget_draw_hook(this->user_data());
}
-int fl_help_view_handle(HELPVIEW v, int e) {
- return reinterpret_cast<My_Help_View*>(v)->real_handle(e);
+int My_Help_View::handle(int e) {
+ return widget_handle_hook(this->user_data(), e);
}
+// Flattened C API
+
HELPVIEW new_fl_help_view(int x, int y, int w, int h, char * label) {
My_Help_View *v = new My_Help_View(x, y, w, h, label);
return v;
@@ -169,6 +143,10 @@ void fl_help_view_set_size(HELPVIEW v, int w, int h) {
reinterpret_cast<Fl_Help_View*>(v)->size(w, h);
}
+void fl_help_view_resize(HELPVIEW v, int x, int y, int w, int h) {
+ reinterpret_cast<Fl_Help_View*>(v)->resize(x, y, w, h);
+}
+
unsigned int fl_help_view_get_textcolor(HELPVIEW v) {
return reinterpret_cast<Fl_Help_View*>(v)->textcolor();
}
@@ -194,3 +172,22 @@ void fl_help_view_set_textsize(HELPVIEW v, int s) {
}
+
+
+void fl_help_view_draw(HELPVIEW v) {
+ #if FL_ABI_VERSION >= 10303
+ reinterpret_cast<My_Help_View*>(v)->Fl_Help_View::draw();
+ #else
+ reinterpret_cast<My_Help_View*>(v)->Fl_Group::draw();
+ #endif
+}
+
+int fl_help_view_handle(HELPVIEW v, int e) {
+ #if FL_ABI_VERSION >= 10303
+ return reinterpret_cast<My_Help_View*>(v)->Fl_Help_View::handle(e);
+ #else
+ return reinterpret_cast<My_Help_View*>(v)->Fl_Group::handle(e);
+ #endif
+}
+
+