summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/c_fl_simple_counter.cpp70
-rw-r--r--src/c_fl_simple_counter.h27
-rw-r--r--src/fltk-widgets-valuators-counters-simple.adb109
-rw-r--r--src/fltk-widgets-valuators-counters-simple.ads38
4 files changed, 244 insertions, 0 deletions
diff --git a/src/c_fl_simple_counter.cpp b/src/c_fl_simple_counter.cpp
new file mode 100644
index 0000000..87ace91
--- /dev/null
+++ b/src/c_fl_simple_counter.cpp
@@ -0,0 +1,70 @@
+
+
+#include <FL/Fl_Simple_Counter.H>
+#include "c_fl_simple_counter.h"
+#include "c_fl_type.h"
+
+
+
+
+class My_Simple_Counter : public Fl_Simple_Counter {
+ public:
+ using Fl_Simple_Counter::Fl_Simple_Counter;
+ friend void simple_counter_set_draw_hook(SIMPLE_COUNTER c, void * d);
+ friend void fl_simple_counter_draw(SIMPLE_COUNTER c);
+ friend void simple_counter_set_handle_hook(SIMPLE_COUNTER c, void * h);
+ friend int fl_simple_counter_handle(SIMPLE_COUNTER c, 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;
+};
+
+void My_Simple_Counter::draw() {
+ (*draw_hook)(this->user_data());
+}
+
+void My_Simple_Counter::real_draw() {
+ Fl_Simple_Counter::draw();
+}
+
+int My_Simple_Counter::handle(int e) {
+ return (*handle_hook)(this->user_data(), e);
+}
+
+int My_Simple_Counter::real_handle(int e) {
+ return Fl_Simple_Counter::handle(e);
+}
+
+void simple_counter_set_draw_hook(SIMPLE_COUNTER c, void * d) {
+ reinterpret_cast<My_Simple_Counter*>(c)->draw_hook = reinterpret_cast<d_hook_p>(d);
+}
+
+void fl_simple_counter_draw(SIMPLE_COUNTER c) {
+ reinterpret_cast<My_Simple_Counter*>(c)->real_draw();
+}
+
+void simple_counter_set_handle_hook(SIMPLE_COUNTER c, void * h) {
+ reinterpret_cast<My_Simple_Counter*>(c)->handle_hook = reinterpret_cast<h_hook_p>(h);
+}
+
+int fl_simple_counter_handle(SIMPLE_COUNTER c, int e) {
+ return reinterpret_cast<My_Simple_Counter*>(c)->real_handle(e);
+}
+
+
+
+
+SIMPLE_COUNTER new_fl_simple_counter(int x, int y, int w, int h, char* label) {
+ My_Simple_Counter *c = new My_Simple_Counter(x, y, w, h, label);
+ return c;
+}
+
+void free_fl_simple_counter(SIMPLE_COUNTER c) {
+ delete reinterpret_cast<My_Simple_Counter*>(c);
+}
+
+
diff --git a/src/c_fl_simple_counter.h b/src/c_fl_simple_counter.h
new file mode 100644
index 0000000..54c5f19
--- /dev/null
+++ b/src/c_fl_simple_counter.h
@@ -0,0 +1,27 @@
+
+
+#ifndef FL_SIMPLE_COUNTER_GUARD
+#define FL_SIMPLE_COUNTER_GUARD
+
+
+
+
+typedef void* SIMPLE_COUNTER;
+
+
+
+
+extern "C" void simple_counter_set_draw_hook(SIMPLE_COUNTER c, void * d);
+extern "C" void fl_simple_counter_draw(SIMPLE_COUNTER c);
+extern "C" void simple_counter_set_handle_hook(SIMPLE_COUNTER c, void * h);
+extern "C" int fl_simple_counter_handle(SIMPLE_COUNTER c, int e);
+
+
+
+
+extern "C" SIMPLE_COUNTER new_fl_simple_counter(int x, int y, int w, int h, char* label);
+extern "C" void free_fl_simple_counter(SIMPLE_COUNTER c);
+
+
+#endif
+
diff --git a/src/fltk-widgets-valuators-counters-simple.adb b/src/fltk-widgets-valuators-counters-simple.adb
new file mode 100644
index 0000000..3b05cb0
--- /dev/null
+++ b/src/fltk-widgets-valuators-counters-simple.adb
@@ -0,0 +1,109 @@
+
+
+with
+
+ Interfaces.C.Strings,
+ System;
+
+use type
+
+ System.Address;
+
+
+package body FLTK.Widgets.Valuators.Counters.Simple is
+
+
+ procedure simple_counter_set_draw_hook
+ (W, D : in System.Address);
+ pragma Import (C, simple_counter_set_draw_hook, "simple_counter_set_draw_hook");
+
+ procedure simple_counter_set_handle_hook
+ (W, H : in System.Address);
+ pragma Import (C, simple_counter_set_handle_hook, "simple_counter_set_handle_hook");
+
+
+
+
+ function new_fl_simple_counter
+ (X, Y, W, H : in Interfaces.C.int;
+ Text : in Interfaces.C.char_array)
+ return System.Address;
+ pragma Import (C, new_fl_simple_counter, "new_fl_simple_counter");
+
+ procedure free_fl_simple_counter
+ (A : in System.Address);
+ pragma Import (C, free_fl_simple_counter, "free_fl_simple_counter");
+
+
+
+
+ procedure fl_simple_counter_draw
+ (W : in System.Address);
+ pragma Import (C, fl_simple_counter_draw, "fl_simple_counter_draw");
+
+ function fl_simple_counter_handle
+ (W : in System.Address;
+ E : in Interfaces.C.int)
+ return Interfaces.C.int;
+ pragma Import (C, fl_simple_counter_handle, "fl_simple_counter_handle");
+
+
+
+
+ procedure Finalize
+ (This : in out Simple_Counter) is
+ begin
+ if This.Void_Ptr /= System.Null_Address and then
+ This in Simple_Counter'Class
+ then
+ free_fl_simple_counter (This.Void_Ptr);
+ This.Void_Ptr := System.Null_Address;
+ end if;
+ Finalize (Counter (This));
+ end Finalize;
+
+
+
+
+ function Create
+ (X, Y, W, H : in Integer;
+ Text : in String)
+ return Simple_Counter is
+ begin
+ return This : Simple_Counter do
+ This.Void_Ptr := new_fl_simple_counter
+ (Interfaces.C.int (X),
+ Interfaces.C.int (Y),
+ Interfaces.C.int (W),
+ Interfaces.C.int (H),
+ Interfaces.C.To_C (Text));
+ fl_widget_set_user_data
+ (This.Void_Ptr,
+ Widget_Convert.To_Address (This'Unchecked_Access));
+ simple_counter_set_draw_hook (This.Void_Ptr, Draw_Hook'Address);
+ simple_counter_set_handle_hook (This.Void_Ptr, Handle_Hook'Address);
+ end return;
+ end Create;
+
+
+
+
+ procedure Draw
+ (This : in out Simple_Counter) is
+ begin
+ fl_simple_counter_draw (This.Void_Ptr);
+ end Draw;
+
+
+ function Handle
+ (This : in out Simple_Counter;
+ Event : in Event_Kind)
+ return Event_Outcome is
+ begin
+ return Event_Outcome'Val
+ (fl_simple_counter_handle (This.Void_Ptr, Event_Kind'Pos (Event)));
+ end Handle;
+
+
+end FLTK.Widgets.Valuators.Counters.Simple;
+
diff --git a/src/fltk-widgets-valuators-counters-simple.ads b/src/fltk-widgets-valuators-counters-simple.ads
new file mode 100644
index 0000000..195db5a
--- /dev/null
+++ b/src/fltk-widgets-valuators-counters-simple.ads
@@ -0,0 +1,38 @@
+
+
+package FLTK.Widgets.Valuators.Counters.Simple is
+
+
+ type Simple_Counter is new Counter with private;
+
+
+
+
+ function Create
+ (X, Y, W, H : in Integer;
+ Text : in String)
+ return Simple_Counter;
+
+
+
+
+ procedure Draw
+ (This : in out Simple_Counter);
+
+ function Handle
+ (This : in out Simple_Counter;
+ Event : in Event_Kind)
+ return Event_Outcome;
+
+
+private
+
+
+ type Simple_Counter is new Counter with null record;
+
+ overriding procedure Finalize
+ (This : in out Simple_Counter);
+
+
+end FLTK.Widgets.Valuators.Counters.Simple;
+