From 4d117b2480998e2593ad7f5d47fc0c33932a3bfc Mon Sep 17 00:00:00 2001 From: Jed Barber Date: Sat, 3 Mar 2018 14:10:57 +1100 Subject: Mostly completed FLTK.Widgets.Valuators --- src/c_fl_valuator.cpp | 99 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 src/c_fl_valuator.cpp (limited to 'src/c_fl_valuator.cpp') diff --git a/src/c_fl_valuator.cpp b/src/c_fl_valuator.cpp new file mode 100644 index 0000000..c13669c --- /dev/null +++ b/src/c_fl_valuator.cpp @@ -0,0 +1,99 @@ + + +#include +#include "c_fl_valuator.h" +#include "c_fl_type.h" + + + + +class My_Valuator : public Fl_Valuator { + public: + using Fl_Valuator::Fl_Valuator; + friend void valuator_set_draw_hook(VALUATOR v, void * d); + friend void valuator_set_handle_hook(VALUATOR v, void * h); + friend int fl_valuator_handle(VALUATOR v, int e); + friend VALUATOR new_fl_valuator(int x, int y, int w, int h, char* label); + protected: + void draw(); + int handle(int e); + int real_handle(int e); + d_hook_p draw_hook; + h_hook_p handle_hook; +}; + +void My_Valuator::draw() { + (*draw_hook)(this->user_data()); +} + +int My_Valuator::handle(int e) { + return (*handle_hook)(this->user_data(), e); +} + +int My_Valuator::real_handle(int e) { + return Fl_Valuator::handle(e); +} + +void valuator_set_draw_hook(VALUATOR v, void * d) { + reinterpret_cast(v)->draw_hook = reinterpret_cast(d); +} + +void valuator_set_handle_hook(VALUATOR v, void * h) { + reinterpret_cast(v)->handle_hook = reinterpret_cast(h); +} + +int fl_valuator_handle(VALUATOR v, int e) { + return reinterpret_cast(v)->real_handle(e); +} + + + + +VALUATOR new_fl_valuator(int x, int y, int w, int h, char* label) { + My_Valuator *v = new My_Valuator(x, y, w, h, label); + return v; +} + +void free_fl_valuator(VALUATOR v) { + delete reinterpret_cast(v); +} + + + + +double fl_valuator_get_minimum(VALUATOR v) { + return reinterpret_cast(v)->minimum(); +} + +void fl_valuator_set_minimum(VALUATOR v, double t) { + reinterpret_cast(v)->minimum(t); +} + +double fl_valuator_get_maximum(VALUATOR v) { + return reinterpret_cast(v)->maximum(); +} + +void fl_valuator_set_maximum(VALUATOR v, double t) { + reinterpret_cast(v)->maximum(t); +} + +double fl_valuator_get_value(VALUATOR v) { + return reinterpret_cast(v)->value(); +} + +void fl_valuator_set_value(VALUATOR v, double t) { + reinterpret_cast(v)->value(t); +} + +void fl_valuator_bounds(VALUATOR v, double a, double b) { + reinterpret_cast(v)->bounds(a,b); +} + +void fl_valuator_precision(VALUATOR v, int s) { + reinterpret_cast(v)->precision(s); +} + +void fl_valuator_range(VALUATOR v, double a, double b) { + reinterpret_cast(v)->range(a,b); +} + -- cgit