summaryrefslogtreecommitdiff
path: root/src/c_fl_value_slider.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_slider.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_slider.cpp')
-rw-r--r--src/c_fl_value_slider.cpp86
1 files changed, 40 insertions, 46 deletions
diff --git a/src/c_fl_value_slider.cpp b/src/c_fl_value_slider.cpp
index 5fd9d02..b79d7f5 100644
--- a/src/c_fl_value_slider.cpp
+++ b/src/c_fl_value_slider.cpp
@@ -6,95 +6,89 @@
#include <FL/Fl_Value_Slider.H>
#include "c_fl_value_slider.h"
-#include "c_fl_type.h"
-class My_Value_Slider : public Fl_Value_Slider {
- public:
- using Fl_Value_Slider::Fl_Value_Slider;
- friend void value_slider_set_draw_hook(VALUE_SLIDER s, void * d);
- friend void fl_value_slider_draw(VALUE_SLIDER s);
- friend void value_slider_set_handle_hook(VALUE_SLIDER s, void * h);
- friend int fl_value_slider_handle(VALUE_SLIDER s, 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_Slider::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_Slider::real_draw() {
- Fl_Value_Slider::draw();
-}
-int My_Value_Slider::handle(int e) {
- return (*handle_hook)(this->user_data(), e);
-}
-int My_Value_Slider::real_handle(int e) {
- return Fl_Value_Slider::handle(e);
-}
-void value_slider_set_draw_hook(VALUE_SLIDER s, void * d) {
- reinterpret_cast<My_Value_Slider*>(s)->draw_hook = reinterpret_cast<d_hook_p>(d);
-}
+// Attaching all relevant hooks and friends
-void fl_value_slider_draw(VALUE_SLIDER s) {
- reinterpret_cast<My_Value_Slider*>(s)->real_draw();
-}
+class My_Value_Slider : public Fl_Value_Slider {
+public:
+ using Fl_Value_Slider::Fl_Value_Slider;
+
+ friend void fl_value_slider_draw(VALUESLIDER s);
+ friend int fl_value_slider_handle(VALUESLIDER s, int e);
-void value_slider_set_handle_hook(VALUE_SLIDER s, void * h) {
- reinterpret_cast<My_Value_Slider*>(s)->handle_hook = reinterpret_cast<h_hook_p>(h);
+ void draw();
+ int handle(int e);
+};
+
+void My_Value_Slider::draw() {
+ widget_draw_hook(this->user_data());
}
-int fl_value_slider_handle(VALUE_SLIDER s, int e) {
- return reinterpret_cast<My_Value_Slider*>(s)->real_handle(e);
+int My_Value_Slider::handle(int e) {
+ return widget_handle_hook(this->user_data(), e);
}
-VALUE_SLIDER new_fl_value_slider(int x, int y, int w, int h, char* label) {
+// Flattened C API
+
+VALUESLIDER new_fl_value_slider(int x, int y, int w, int h, char* label) {
My_Value_Slider *s = new My_Value_Slider(x, y, w, h, label);
return s;
}
-void free_fl_value_slider(VALUE_SLIDER s) {
+void free_fl_value_slider(VALUESLIDER s) {
delete reinterpret_cast<My_Value_Slider*>(s);
}
-unsigned int fl_value_slider_get_textcolor(VALUE_SLIDER s) {
+unsigned int fl_value_slider_get_textcolor(VALUESLIDER s) {
return reinterpret_cast<Fl_Value_Slider*>(s)->textcolor();
}
-void fl_value_slider_set_textcolor(VALUE_SLIDER s, unsigned int t) {
+void fl_value_slider_set_textcolor(VALUESLIDER s, unsigned int t) {
reinterpret_cast<Fl_Value_Slider*>(s)->textcolor(t);
}
-int fl_value_slider_get_textfont(VALUE_SLIDER s) {
+int fl_value_slider_get_textfont(VALUESLIDER s) {
return reinterpret_cast<Fl_Value_Slider*>(s)->textfont();
}
-void fl_value_slider_set_textfont(VALUE_SLIDER s, int t) {
+void fl_value_slider_set_textfont(VALUESLIDER s, int t) {
reinterpret_cast<Fl_Value_Slider*>(s)->textfont(t);
}
-int fl_value_slider_get_textsize(VALUE_SLIDER s) {
+int fl_value_slider_get_textsize(VALUESLIDER s) {
return reinterpret_cast<Fl_Value_Slider*>(s)->textsize();
}
-void fl_value_slider_set_textsize(VALUE_SLIDER s, int t) {
+void fl_value_slider_set_textsize(VALUESLIDER s, int t) {
reinterpret_cast<Fl_Value_Slider*>(s)->textsize(t);
}
+
+
+
+void fl_value_slider_draw(VALUESLIDER s) {
+ reinterpret_cast<My_Value_Slider*>(s)->Fl_Value_Slider::draw();
+}
+
+int fl_value_slider_handle(VALUESLIDER s, int e) {
+ return reinterpret_cast<My_Value_Slider*>(s)->Fl_Value_Slider::handle(e);
+}
+
+