summaryrefslogtreecommitdiff
path: root/src/c_fl_value_input.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_input.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_input.cpp')
-rw-r--r--src/c_fl_value_input.cpp106
1 files changed, 53 insertions, 53 deletions
diff --git a/src/c_fl_value_input.cpp b/src/c_fl_value_input.cpp
index c2910c2..37273a7 100644
--- a/src/c_fl_value_input.cpp
+++ b/src/c_fl_value_input.cpp
@@ -6,136 +6,136 @@
#include <FL/Fl_Value_Input.H>
#include "c_fl_value_input.h"
-#include "c_fl_type.h"
-class My_Value_Input : public Fl_Value_Input {
- public:
- using Fl_Value_Input::Fl_Value_Input;
- friend void value_input_set_draw_hook(VALUE_INPUT a, void * d);
- friend void fl_value_input_draw(VALUE_INPUT a);
- friend void value_input_set_handle_hook(VALUE_INPUT a, void * h);
- friend int fl_value_input_handle(VALUE_INPUT 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_Input::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_Input::real_draw() {
- Fl_Value_Input::draw();
-}
-int My_Value_Input::handle(int e) {
- return (*handle_hook)(this->user_data(), e);
-}
-int My_Value_Input::real_handle(int e) {
- return Fl_Value_Input::handle(e);
-}
-void value_input_set_draw_hook(VALUE_INPUT a, void * d) {
- reinterpret_cast<My_Value_Input*>(a)->draw_hook = reinterpret_cast<d_hook_p>(d);
-}
+// Attaching all relevant hooks and friends
-void fl_value_input_draw(VALUE_INPUT a) {
- reinterpret_cast<My_Value_Input*>(a)->real_draw();
-}
+class My_Value_Input : public Fl_Value_Input {
+public:
+ using Fl_Value_Input::Fl_Value_Input;
+
+ friend void fl_value_input_draw(VALUEINPUT a);
+ friend int fl_value_input_handle(VALUEINPUT a, int e);
-void value_input_set_handle_hook(VALUE_INPUT a, void * h) {
- reinterpret_cast<My_Value_Input*>(a)->handle_hook = reinterpret_cast<h_hook_p>(h);
+ void draw();
+ int handle(int e);
+};
+
+void My_Value_Input::draw() {
+ widget_draw_hook(this->user_data());
}
-int fl_value_input_handle(VALUE_INPUT a, int e) {
- return reinterpret_cast<My_Value_Input*>(a)->real_handle(e);
+int My_Value_Input::handle(int e) {
+ return widget_handle_hook(this->user_data(), e);
}
-VALUE_INPUT new_fl_value_input(int x, int y, int w, int h, char* label) {
+// Flattened C API
+
+VALUEINPUT new_fl_value_input(int x, int y, int w, int h, char* label) {
My_Value_Input *a = new My_Value_Input(x, y, w, h, label);
return a;
}
-void free_fl_value_input(VALUE_INPUT a) {
+void free_fl_value_input(VALUEINPUT a) {
delete reinterpret_cast<My_Value_Input*>(a);
}
-void * fl_value_input_get_input(VALUE_INPUT v) {
+void * fl_value_input_get_input(VALUEINPUT v) {
return &(reinterpret_cast<Fl_Value_Input*>(v)->input);
}
-unsigned int fl_value_input_get_cursor_color(VALUE_INPUT v) {
+unsigned int fl_value_input_get_cursor_color(VALUEINPUT v) {
return reinterpret_cast<Fl_Value_Input*>(v)->cursor_color();
}
-void fl_value_input_set_cursor_color(VALUE_INPUT v, unsigned int c) {
+void fl_value_input_set_cursor_color(VALUEINPUT v, unsigned int c) {
reinterpret_cast<Fl_Value_Input*>(v)->cursor_color(c);
}
-int fl_value_input_get_shortcut(VALUE_INPUT v) {
+int fl_value_input_get_shortcut(VALUEINPUT v) {
return reinterpret_cast<Fl_Value_Input*>(v)->Fl_Value_Input::shortcut();
}
-void fl_value_input_set_shortcut(VALUE_INPUT v, int k) {
+void fl_value_input_set_shortcut(VALUEINPUT v, int k) {
reinterpret_cast<Fl_Value_Input*>(v)->Fl_Value_Input::shortcut(k);
}
-int fl_value_input_is_soft(VALUE_INPUT a) {
+int fl_value_input_is_soft(VALUEINPUT a) {
return reinterpret_cast<Fl_Value_Input*>(a)->soft();
}
-void fl_value_input_set_soft(VALUE_INPUT a, int t) {
+void fl_value_input_set_soft(VALUEINPUT a, int t) {
reinterpret_cast<Fl_Value_Input*>(a)->soft(t);
}
-unsigned int fl_value_input_get_text_color(VALUE_INPUT v) {
+unsigned int fl_value_input_get_text_color(VALUEINPUT v) {
return reinterpret_cast<Fl_Value_Input*>(v)->textcolor();
}
-void fl_value_input_set_text_color(VALUE_INPUT v, unsigned int c) {
+void fl_value_input_set_text_color(VALUEINPUT v, unsigned int c) {
reinterpret_cast<Fl_Value_Input*>(v)->textcolor(static_cast<Fl_Color>(c));
}
-int fl_value_input_get_text_font(VALUE_INPUT v) {
+int fl_value_input_get_text_font(VALUEINPUT v) {
return reinterpret_cast<Fl_Value_Input*>(v)->textfont();
}
-void fl_value_input_set_text_font(VALUE_INPUT v, int f) {
+void fl_value_input_set_text_font(VALUEINPUT v, int f) {
reinterpret_cast<Fl_Value_Input*>(v)->textfont(static_cast<Fl_Font>(f));
}
-int fl_value_input_get_text_size(VALUE_INPUT v) {
+int fl_value_input_get_text_size(VALUEINPUT v) {
return reinterpret_cast<Fl_Value_Input*>(v)->textsize();
}
-void fl_value_input_set_text_size(VALUE_INPUT v, int s) {
+void fl_value_input_set_text_size(VALUEINPUT v, int s) {
reinterpret_cast<Fl_Value_Input*>(v)->textsize(static_cast<Fl_Fontsize>(s));
}
+
+
+void fl_value_input_resize(VALUEINPUT v, int x, int y, int w, int h) {
+ reinterpret_cast<Fl_Value_Input*>(v)->resize(x, y, w, h);
+}
+
+
+
+
+void fl_value_input_draw(VALUEINPUT a) {
+ reinterpret_cast<My_Value_Input*>(a)->Fl_Value_Input::draw();
+}
+
+int fl_value_input_handle(VALUEINPUT a, int e) {
+ return reinterpret_cast<My_Value_Input*>(a)->Fl_Value_Input::handle(e);
+}
+
+