summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/c_fl_adjuster.cpp80
-rw-r--r--src/c_fl_adjuster.h33
-rw-r--r--src/fltk-widgets-valuators-adjusters.adb141
-rw-r--r--src/fltk-widgets-valuators-adjusters.ads49
4 files changed, 303 insertions, 0 deletions
diff --git a/src/c_fl_adjuster.cpp b/src/c_fl_adjuster.cpp
new file mode 100644
index 0000000..36d7858
--- /dev/null
+++ b/src/c_fl_adjuster.cpp
@@ -0,0 +1,80 @@
+
+
+#include <FL/Fl_Adjuster.H>
+#include "c_fl_adjuster.h"
+#include "c_fl_type.h"
+
+
+
+
+class My_Adjuster : public Fl_Adjuster {
+ public:
+ using Fl_Adjuster::Fl_Adjuster;
+ friend void adjuster_set_draw_hook(ADJUSTER a, void * d);
+ friend void fl_adjuster_draw(ADJUSTER a);
+ friend void adjuster_set_handle_hook(ADJUSTER a, void * h);
+ friend int fl_adjuster_handle(ADJUSTER 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;
+};
+
+void My_Adjuster::draw() {
+ (*draw_hook)(this->user_data());
+}
+
+void My_Adjuster::real_draw() {
+ Fl_Adjuster::draw();
+}
+
+int My_Adjuster::handle(int e) {
+ return (*handle_hook)(this->user_data(), e);
+}
+
+int My_Adjuster::real_handle(int e) {
+ return Fl_Adjuster::handle(e);
+}
+
+void adjuster_set_draw_hook(ADJUSTER a, void * d) {
+ reinterpret_cast<My_Adjuster*>(a)->draw_hook = reinterpret_cast<d_hook_p>(d);
+}
+
+void fl_adjuster_draw(ADJUSTER a) {
+ reinterpret_cast<My_Adjuster*>(a)->real_draw();
+}
+
+void adjuster_set_handle_hook(ADJUSTER a, void * h) {
+ reinterpret_cast<My_Adjuster*>(a)->handle_hook = reinterpret_cast<h_hook_p>(h);
+}
+
+int fl_adjuster_handle(ADJUSTER a, int e) {
+ return reinterpret_cast<My_Adjuster*>(a)->real_handle(e);
+}
+
+
+
+
+ADJUSTER new_fl_adjuster(int x, int y, int w, int h, char* label) {
+ My_Adjuster *a = new My_Adjuster(x, y, w, h, label);
+ return a;
+}
+
+void free_fl_adjuster(ADJUSTER a) {
+ delete reinterpret_cast<My_Adjuster*>(a);
+}
+
+
+
+
+int fl_adjuster_is_soft(ADJUSTER a) {
+ return reinterpret_cast<My_Adjuster*>(a)->soft();
+}
+
+void fl_adjuster_set_soft(ADJUSTER a, int t) {
+ reinterpret_cast<My_Adjuster*>(a)->soft(t);
+}
+
diff --git a/src/c_fl_adjuster.h b/src/c_fl_adjuster.h
new file mode 100644
index 0000000..53a84eb
--- /dev/null
+++ b/src/c_fl_adjuster.h
@@ -0,0 +1,33 @@
+
+
+#ifndef FL_ADJUSTER_GUARD
+#define FL_ADJUSTER_GUARD
+
+
+
+
+typedef void* ADJUSTER;
+
+
+
+
+extern "C" void adjuster_set_draw_hook(ADJUSTER a, void * d);
+extern "C" void fl_adjuster_draw(ADJUSTER a);
+extern "C" void adjuster_set_handle_hook(ADJUSTER a, void * h);
+extern "C" int fl_adjuster_handle(ADJUSTER a, int e);
+
+
+
+
+extern "C" ADJUSTER new_fl_adjuster(int x, int y, int w, int h, char* label);
+extern "C" void free_fl_adjuster(ADJUSTER a);
+
+
+
+
+extern "C" int fl_adjuster_is_soft(ADJUSTER a);
+extern "C" void fl_adjuster_set_soft(ADJUSTER a, int t);
+
+
+#endif
+
diff --git a/src/fltk-widgets-valuators-adjusters.adb b/src/fltk-widgets-valuators-adjusters.adb
new file mode 100644
index 0000000..90495e6
--- /dev/null
+++ b/src/fltk-widgets-valuators-adjusters.adb
@@ -0,0 +1,141 @@
+
+
+with
+
+ Interfaces.C.Strings,
+ System;
+
+use type
+
+ Interfaces.C.int,
+ System.Address;
+
+
+package body FLTK.Widgets.Valuators.Adjusters is
+
+
+ procedure adjuster_set_draw_hook
+ (W, D : in System.Address);
+ pragma Import (C, adjuster_set_draw_hook, "adjuster_set_draw_hook");
+
+ procedure adjuster_set_handle_hook
+ (W, H : in System.Address);
+ pragma Import (C, adjuster_set_handle_hook, "adjuster_set_handle_hook");
+
+
+
+
+ function new_fl_adjuster
+ (X, Y, W, H : in Interfaces.C.int;
+ Text : in Interfaces.C.char_array)
+ return System.Address;
+ pragma Import (C, new_fl_adjuster, "new_fl_adjuster");
+
+ procedure free_fl_adjuster
+ (A : in System.Address);
+ pragma Import (C, free_fl_adjuster, "free_fl_adjuster");
+
+
+
+
+ function fl_adjuster_is_soft
+ (A : in System.Address)
+ return Interfaces.C.int;
+ pragma Import (C, fl_adjuster_is_soft, "fl_adjuster_is_soft");
+
+ procedure fl_adjuster_set_soft
+ (A : in System.Address;
+ T : in Interfaces.C.int);
+ pragma Import (C, fl_adjuster_set_soft, "fl_adjuster_set_soft");
+
+
+
+
+ procedure fl_adjuster_draw
+ (W : in System.Address);
+ pragma Import (C, fl_adjuster_draw, "fl_adjuster_draw");
+
+ function fl_adjuster_handle
+ (W : in System.Address;
+ E : in Interfaces.C.int)
+ return Interfaces.C.int;
+ pragma Import (C, fl_adjuster_handle, "fl_adjuster_handle");
+
+
+
+
+ procedure Finalize
+ (This : in out Adjuster) is
+ begin
+ if This.Void_Ptr /= System.Null_Address and then
+ This in Adjuster'Class
+ then
+ free_fl_adjuster (This.Void_Ptr);
+ This.Void_Ptr := System.Null_Address;
+ end if;
+ Finalize (Valuator (This));
+ end Finalize;
+
+
+
+
+ function Create
+ (X, Y, W, H : in Integer;
+ Text : in String)
+ return Adjuster is
+ begin
+ return This : Adjuster do
+ This.Void_Ptr := new_fl_adjuster
+ (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));
+ adjuster_set_draw_hook (This.Void_Ptr, Draw_Hook'Address);
+ adjuster_set_handle_hook (This.Void_Ptr, Handle_Hook'Address);
+ end return;
+ end Create;
+
+
+
+
+ function Is_Soft
+ (This : in Adjuster)
+ return Boolean is
+ begin
+ return fl_adjuster_is_soft (This.Void_Ptr) /= 0;
+ end Is_Soft;
+
+
+ procedure Set_Soft
+ (This : in out Adjuster;
+ To : in Boolean) is
+ begin
+ fl_adjuster_set_soft (This.Void_Ptr, Boolean'Pos (To));
+ end Set_Soft;
+
+
+
+
+ procedure Draw
+ (This : in out Adjuster) is
+ begin
+ fl_adjuster_draw (This.Void_Ptr);
+ end Draw;
+
+
+ function Handle
+ (This : in out Adjuster;
+ Event : in Event_Kind)
+ return Event_Outcome is
+ begin
+ return Event_Outcome'Val
+ (fl_adjuster_handle (This.Void_Ptr, Event_Kind'Pos (Event)));
+ end Handle;
+
+
+end FLTK.Widgets.Valuators.Adjusters;
+
diff --git a/src/fltk-widgets-valuators-adjusters.ads b/src/fltk-widgets-valuators-adjusters.ads
new file mode 100644
index 0000000..7ebeb0c
--- /dev/null
+++ b/src/fltk-widgets-valuators-adjusters.ads
@@ -0,0 +1,49 @@
+
+
+package FLTK.Widgets.Valuators.Adjusters is
+
+
+ type Adjuster is new Valuator with private;
+
+
+
+
+ function Create
+ (X, Y, W, H : in Integer;
+ Text : in String)
+ return Adjuster;
+
+
+
+
+ function Is_Soft
+ (This : in Adjuster)
+ return Boolean;
+
+ procedure Set_Soft
+ (This : in out Adjuster;
+ To : in Boolean);
+
+
+
+
+ procedure Draw
+ (This : in out Adjuster);
+
+ function Handle
+ (This : in out Adjuster;
+ Event : in Event_Kind)
+ return Event_Outcome;
+
+
+private
+
+
+ type Adjuster is new Valuator with null record;
+
+ overriding procedure Finalize
+ (This : in out Adjuster);
+
+
+end FLTK.Widgets.Valuators.Adjusters;
+