summaryrefslogtreecommitdiff
path: root/src/c_fl_valuator.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/c_fl_valuator.cpp')
-rw-r--r--src/c_fl_valuator.cpp92
1 files changed, 61 insertions, 31 deletions
diff --git a/src/c_fl_valuator.cpp b/src/c_fl_valuator.cpp
index 3ee95c5..f70e6dd 100644
--- a/src/c_fl_valuator.cpp
+++ b/src/c_fl_valuator.cpp
@@ -6,53 +6,55 @@
#include <FL/Fl_Valuator.H>
#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;
+// Exports from Ada
+
+extern "C" void widget_draw_hook(void * ud);
+extern "C" int widget_handle_hook(void * ud, int e);
+
+
+
+
+// Non-friend protected access
+
+class Friend_Valuator : Fl_Valuator {
+public:
+ using Fl_Valuator::value_damage;
};
-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<My_Valuator*>(v)->draw_hook = reinterpret_cast<d_hook_p>(d);
-}
+// Attaching all relevant hooks and friends
+
+class My_Valuator : public Fl_Valuator {
+public:
+ using Fl_Valuator::Fl_Valuator;
+ friend VALUATOR new_fl_valuator(int x, int y, int w, int h, char* label);
-void valuator_set_handle_hook(VALUATOR v, void * h) {
- reinterpret_cast<My_Valuator*>(v)->handle_hook = reinterpret_cast<h_hook_p>(h);
+ friend void fl_valuator_draw(VALUATOR v);
+ friend int fl_valuator_handle(VALUATOR v, int e);
+
+ void draw();
+ int handle(int e);
+};
+
+void My_Valuator::draw() {
+ widget_draw_hook(this->user_data());
}
-int fl_valuator_handle(VALUATOR v, int e) {
- return reinterpret_cast<My_Valuator*>(v)->real_handle(e);
+int My_Valuator::handle(int e) {
+ return widget_handle_hook(this->user_data(), e);
}
+// Flattened C API
+
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;
@@ -100,10 +102,18 @@ double fl_valuator_get_step(VALUATOR v) {
return reinterpret_cast<Fl_Valuator*>(v)->step();
}
-void fl_valuator_set_step(VALUATOR v, double t) {
+void fl_valuator_set_step_top(VALUATOR v, double t) {
reinterpret_cast<Fl_Valuator*>(v)->step(t);
}
+void fl_valuator_set_step_bottom(VALUATOR v, int b) {
+ reinterpret_cast<Fl_Valuator*>(v)->step(b);
+}
+
+void fl_valuator_set_step(VALUATOR v, double t, int b) {
+ reinterpret_cast<Fl_Valuator*>(v)->step(t, b);
+}
+
double fl_valuator_get_value(VALUATOR v) {
return reinterpret_cast<Fl_Valuator*>(v)->value();
}
@@ -124,3 +134,23 @@ void fl_valuator_range(VALUATOR v, double a, double b) {
reinterpret_cast<Fl_Valuator*>(v)->range(a,b);
}
+
+
+
+void fl_valuator_value_damage(VALUATOR v) {
+ (reinterpret_cast<Fl_Valuator*>(v)->*(&Friend_Valuator::value_damage))();
+}
+
+void fl_valuator_draw(VALUATOR v) {
+ // The Fl_Valuator draw method doesn't technically exist, so...
+ (void)(v);
+ // It is more convenient for this function to exist, however,
+ // even though it will likely never be called, because it simplifies
+ // and makes uniform the implementation of the Ada Valuator Draw subprogram.
+}
+
+int fl_valuator_handle(VALUATOR v, int e) {
+ return reinterpret_cast<My_Valuator*>(v)->Fl_Valuator::handle(e);
+}
+
+