diff options
author | Jedidiah Barber <contact@jedbarber.id.au> | 2025-01-21 21:04:54 +1300 |
---|---|---|
committer | Jedidiah Barber <contact@jedbarber.id.au> | 2025-01-21 21:04:54 +1300 |
commit | b4438b2fbe895694be98e6e8426103deefc51448 (patch) | |
tree | 760d86cd7c06420a91dad102cc9546aee73146fc /body/c_fl_value_input.cpp | |
parent | a4703a65b015140cd4a7a985db66264875ade734 (diff) |
Split public API and private implementation files into different directories
Diffstat (limited to 'body/c_fl_value_input.cpp')
-rw-r--r-- | body/c_fl_value_input.cpp | 148 |
1 files changed, 148 insertions, 0 deletions
diff --git a/body/c_fl_value_input.cpp b/body/c_fl_value_input.cpp new file mode 100644 index 0000000..3d19845 --- /dev/null +++ b/body/c_fl_value_input.cpp @@ -0,0 +1,148 @@ + + +// Programmed by Jedidiah Barber +// Released into the public domain + + +#include <FL/Fl_Value_Input.H> +#include "c_fl_value_input.h" + + + + +// Exports from Ada + +extern "C" void widget_draw_hook(void * ud); +extern "C" int widget_handle_hook(void * ud, int e); + +extern "C" int valuator_format_hook(void * ud, char * buf); + + + + +// Attaching all relevant hooks and friends + +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); + + int format(char * buf); + void draw(); + int handle(int e); +}; + +int My_Value_Input::format(char * buf) { + return valuator_format_hook(this->user_data(), buf); +} + +void My_Value_Input::draw() { + widget_draw_hook(this->user_data()); +} + +int My_Value_Input::handle(int e) { + return widget_handle_hook(this->user_data(), e); +} + + + + +// 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(VALUEINPUT a) { + delete static_cast<My_Value_Input*>(a); +} + + + + +void * fl_value_input_get_input(VALUEINPUT v) { + return &(static_cast<Fl_Value_Input*>(v)->input); +} + + + + +unsigned int fl_value_input_get_cursor_color(VALUEINPUT v) { + return static_cast<Fl_Value_Input*>(v)->cursor_color(); +} + +void fl_value_input_set_cursor_color(VALUEINPUT v, unsigned int c) { + static_cast<Fl_Value_Input*>(v)->cursor_color(c); +} + + + + +int fl_value_input_get_shortcut(VALUEINPUT v) { + return static_cast<Fl_Value_Input*>(v)->Fl_Value_Input::shortcut(); +} + +void fl_value_input_set_shortcut(VALUEINPUT v, int k) { + static_cast<Fl_Value_Input*>(v)->Fl_Value_Input::shortcut(k); +} + + + + +int fl_value_input_is_soft(VALUEINPUT a) { + return static_cast<Fl_Value_Input*>(a)->soft(); +} + +void fl_value_input_set_soft(VALUEINPUT a, int t) { + static_cast<Fl_Value_Input*>(a)->soft(t); +} + + + + +unsigned int fl_value_input_get_text_color(VALUEINPUT v) { + return static_cast<Fl_Value_Input*>(v)->textcolor(); +} + +void fl_value_input_set_text_color(VALUEINPUT v, unsigned int c) { + static_cast<Fl_Value_Input*>(v)->textcolor(static_cast<Fl_Color>(c)); +} + +int fl_value_input_get_text_font(VALUEINPUT v) { + return static_cast<Fl_Value_Input*>(v)->textfont(); +} + +void fl_value_input_set_text_font(VALUEINPUT v, int f) { + static_cast<Fl_Value_Input*>(v)->textfont(static_cast<Fl_Font>(f)); +} + +int fl_value_input_get_text_size(VALUEINPUT v) { + return static_cast<Fl_Value_Input*>(v)->textsize(); +} + +void fl_value_input_set_text_size(VALUEINPUT v, int s) { + static_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) { + static_cast<Fl_Value_Input*>(v)->resize(x, y, w, h); +} + + + + +void fl_value_input_draw(VALUEINPUT a) { + static_cast<My_Value_Input*>(a)->Fl_Value_Input::draw(); +} + +int fl_value_input_handle(VALUEINPUT a, int e) { + return static_cast<My_Value_Input*>(a)->Fl_Value_Input::handle(e); +} + + |