summaryrefslogtreecommitdiff
path: root/src/c_fl_value_output.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_value_output.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_value_output.cpp')
-rw-r--r--src/c_fl_value_output.cpp89
1 files changed, 41 insertions, 48 deletions
diff --git a/src/c_fl_value_output.cpp b/src/c_fl_value_output.cpp
index 3faa25f..b7cc1d6 100644
--- a/src/c_fl_value_output.cpp
+++ b/src/c_fl_value_output.cpp
@@ -6,107 +6,100 @@
#include <FL/Fl_Value_Output.H>
#include "c_fl_value_output.h"
-#include "c_fl_type.h"
-class My_Value_Output : public Fl_Value_Output {
- public:
- using Fl_Value_Output::Fl_Value_Output;
- friend void value_output_set_draw_hook(VALUE_OUTPUT a, void * d);
- friend void fl_value_output_draw(VALUE_OUTPUT a);
- friend void value_output_set_handle_hook(VALUE_OUTPUT a, void * h);
- friend int fl_value_output_handle(VALUE_OUTPUT a, 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_Value_Output::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_Value_Output::real_draw() {
- Fl_Value_Output::draw();
-}
-int My_Value_Output::handle(int e) {
- return (*handle_hook)(this->user_data(), e);
-}
-int My_Value_Output::real_handle(int e) {
- return Fl_Value_Output::handle(e);
-}
-void value_output_set_draw_hook(VALUE_OUTPUT a, void * d) {
- reinterpret_cast<My_Value_Output*>(a)->draw_hook = reinterpret_cast<d_hook_p>(d);
-}
+// Attaching all relevant hooks and friends
-void fl_value_output_draw(VALUE_OUTPUT a) {
- reinterpret_cast<My_Value_Output*>(a)->real_draw();
-}
+class My_Value_Output : public Fl_Value_Output {
+public:
+ using Fl_Value_Output::Fl_Value_Output;
+
+ friend void fl_value_output_draw(VALUEOUTPUT a);
+ friend int fl_value_output_handle(VALUEOUTPUT a, int e);
-void value_output_set_handle_hook(VALUE_OUTPUT a, void * h) {
- reinterpret_cast<My_Value_Output*>(a)->handle_hook = reinterpret_cast<h_hook_p>(h);
+ void draw();
+ int handle(int e);
+};
+
+void My_Value_Output::draw() {
+ widget_draw_hook(this->user_data());
}
-int fl_value_output_handle(VALUE_OUTPUT a, int e) {
- return reinterpret_cast<My_Value_Output*>(a)->real_handle(e);
+int My_Value_Output::handle(int e) {
+ return widget_handle_hook(this->user_data(), e);
}
-VALUE_OUTPUT new_fl_value_output(int x, int y, int w, int h, char* label) {
+// Flattened C API
+
+VALUEOUTPUT new_fl_value_output(int x, int y, int w, int h, char* label) {
My_Value_Output *a = new My_Value_Output(x, y, w, h, label);
return a;
}
-void free_fl_value_output(VALUE_OUTPUT a) {
+void free_fl_value_output(VALUEOUTPUT a) {
delete reinterpret_cast<My_Value_Output*>(a);
}
-int fl_value_output_is_soft(VALUE_OUTPUT a) {
+int fl_value_output_is_soft(VALUEOUTPUT a) {
return reinterpret_cast<Fl_Value_Output*>(a)->soft();
}
-void fl_value_output_set_soft(VALUE_OUTPUT a, int t) {
+void fl_value_output_set_soft(VALUEOUTPUT a, int t) {
reinterpret_cast<Fl_Value_Output*>(a)->soft(t);
}
-unsigned int fl_value_output_get_text_color(VALUE_OUTPUT v) {
+unsigned int fl_value_output_get_text_color(VALUEOUTPUT v) {
return reinterpret_cast<Fl_Value_Output*>(v)->textcolor();
}
-void fl_value_output_set_text_color(VALUE_OUTPUT v, unsigned int c) {
+void fl_value_output_set_text_color(VALUEOUTPUT v, unsigned int c) {
reinterpret_cast<Fl_Value_Output*>(v)->textcolor(static_cast<Fl_Color>(c));
}
-int fl_value_output_get_text_font(VALUE_OUTPUT v) {
+int fl_value_output_get_text_font(VALUEOUTPUT v) {
return reinterpret_cast<Fl_Value_Output*>(v)->textfont();
}
-void fl_value_output_set_text_font(VALUE_OUTPUT v, int f) {
+void fl_value_output_set_text_font(VALUEOUTPUT v, int f) {
reinterpret_cast<Fl_Value_Output*>(v)->textfont(static_cast<Fl_Font>(f));
}
-int fl_value_output_get_text_size(VALUE_OUTPUT v) {
+int fl_value_output_get_text_size(VALUEOUTPUT v) {
return reinterpret_cast<Fl_Value_Output*>(v)->textsize();
}
-void fl_value_output_set_text_size(VALUE_OUTPUT v, int s) {
+void fl_value_output_set_text_size(VALUEOUTPUT v, int s) {
reinterpret_cast<Fl_Value_Output*>(v)->textsize(static_cast<Fl_Fontsize>(s));
}
+
+
+void fl_value_output_draw(VALUEOUTPUT a) {
+ reinterpret_cast<My_Value_Output*>(a)->Fl_Value_Output::draw();
+}
+
+int fl_value_output_handle(VALUEOUTPUT a, int e) {
+ return reinterpret_cast<My_Value_Output*>(a)->Fl_Value_Output::handle(e);
+}
+
+