summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--progress.txt2
-rw-r--r--src/c_fl_roller.cpp70
-rw-r--r--src/c_fl_roller.h27
-rw-r--r--src/fltk-widgets-valuators-rollers.adb109
-rw-r--r--src/fltk-widgets-valuators-rollers.ads38
5 files changed, 245 insertions, 1 deletions
diff --git a/progress.txt b/progress.txt
index 598f6b8..e5c91d2 100644
--- a/progress.txt
+++ b/progress.txt
@@ -52,6 +52,7 @@ FLTK.Widgets.Valuators.Counters.Simple
FLTK.Widgets.Valuators.Dials
FLTK.Widgets.Valuators.Dials.Fill
FLTK.Widgets.Valuators.Dials.Line
+FLTK.Widgets.Valuators.Rollers
@@ -101,7 +102,6 @@ FL_Tabs
FL_Tile
FL_Tree
FL_Wizard
-FL_Roller
FL_Slider
FL_Fill_Slider
FL_Hor_Fill_Slider
diff --git a/src/c_fl_roller.cpp b/src/c_fl_roller.cpp
new file mode 100644
index 0000000..94ac576
--- /dev/null
+++ b/src/c_fl_roller.cpp
@@ -0,0 +1,70 @@
+
+
+#include <FL/Fl_Roller.H>
+#include "c_fl_roller.h"
+#include "c_fl_type.h"
+
+
+
+
+class My_Roller : public Fl_Roller {
+ public:
+ using Fl_Roller::Fl_Roller;
+ friend void roller_set_draw_hook(ROLLER r, void * d);
+ friend void fl_roller_draw(ROLLER r);
+ friend void roller_set_handle_hook(ROLLER r, void * h);
+ friend int fl_roller_handle(ROLLER r, 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_Roller::draw() {
+ (*draw_hook)(this->user_data());
+}
+
+void My_Roller::real_draw() {
+ Fl_Roller::draw();
+}
+
+int My_Roller::handle(int e) {
+ return (*handle_hook)(this->user_data(), e);
+}
+
+int My_Roller::real_handle(int e) {
+ return Fl_Roller::handle(e);
+}
+
+void roller_set_draw_hook(ROLLER r, void * d) {
+ reinterpret_cast<My_Roller*>(r)->draw_hook = reinterpret_cast<d_hook_p>(d);
+}
+
+void fl_roller_draw(ROLLER r) {
+ reinterpret_cast<My_Roller*>(r)->real_draw();
+}
+
+void roller_set_handle_hook(ROLLER r, void * h) {
+ reinterpret_cast<My_Roller*>(r)->handle_hook = reinterpret_cast<h_hook_p>(h);
+}
+
+int fl_roller_handle(ROLLER r, int e) {
+ return reinterpret_cast<My_Roller*>(r)->real_handle(e);
+}
+
+
+
+
+ROLLER new_fl_roller(int x, int y, int w, int h, char* label) {
+ My_Roller *r = new My_Roller(x, y, w, h, label);
+ return r;
+}
+
+void free_fl_roller(ROLLER r) {
+ delete reinterpret_cast<My_Roller*>(r);
+}
+
+
diff --git a/src/c_fl_roller.h b/src/c_fl_roller.h
new file mode 100644
index 0000000..1820eee
--- /dev/null
+++ b/src/c_fl_roller.h
@@ -0,0 +1,27 @@
+
+
+#ifndef FL_ROLLER_GUARD
+#define FL_ROLLER_GUARD
+
+
+
+
+typedef void* ROLLER;
+
+
+
+
+extern "C" void roller_set_draw_hook(ROLLER r, void * d);
+extern "C" void fl_roller_draw(ROLLER r);
+extern "C" void roller_set_handle_hook(ROLLER r, void * h);
+extern "C" int fl_roller_handle(ROLLER r, int e);
+
+
+
+
+extern "C" ROLLER new_fl_roller(int x, int y, int w, int h, char* label);
+extern "C" void free_fl_roller(ROLLER r);
+
+
+#endif
+
diff --git a/src/fltk-widgets-valuators-rollers.adb b/src/fltk-widgets-valuators-rollers.adb
new file mode 100644
index 0000000..408a286
--- /dev/null
+++ b/src/fltk-widgets-valuators-rollers.adb
@@ -0,0 +1,109 @@
+
+
+with
+
+ Interfaces.C.Strings,
+ System;
+
+use type
+
+ System.Address;
+
+
+package body FLTK.Widgets.Valuators.Rollers is
+
+
+ procedure roller_set_draw_hook
+ (W, D : in System.Address);
+ pragma Import (C, roller_set_draw_hook, "roller_set_draw_hook");
+
+ procedure roller_set_handle_hook
+ (W, H : in System.Address);
+ pragma Import (C, roller_set_handle_hook, "roller_set_handle_hook");
+
+
+
+
+ function new_fl_roller
+ (X, Y, W, H : in Interfaces.C.int;
+ Text : in Interfaces.C.char_array)
+ return System.Address;
+ pragma Import (C, new_fl_roller, "new_fl_roller");
+
+ procedure free_fl_roller
+ (D : in System.Address);
+ pragma Import (C, free_fl_roller, "free_fl_roller");
+
+
+
+
+ procedure fl_roller_draw
+ (W : in System.Address);
+ pragma Import (C, fl_roller_draw, "fl_roller_draw");
+
+ function fl_roller_handle
+ (W : in System.Address;
+ E : in Interfaces.C.int)
+ return Interfaces.C.int;
+ pragma Import (C, fl_roller_handle, "fl_roller_handle");
+
+
+
+
+ procedure Finalize
+ (This : in out Roller) is
+ begin
+ if This.Void_Ptr /= System.Null_Address and then
+ This in Roller'Class
+ then
+ free_fl_roller (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 Roller is
+ begin
+ return This : Roller do
+ This.Void_Ptr := new_fl_roller
+ (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));
+ roller_set_draw_hook (This.Void_Ptr, Draw_Hook'Address);
+ roller_set_handle_hook (This.Void_Ptr, Handle_Hook'Address);
+ end return;
+ end Create;
+
+
+
+
+ procedure Draw
+ (This : in out Roller) is
+ begin
+ fl_roller_draw (This.Void_Ptr);
+ end Draw;
+
+
+ function Handle
+ (This : in out Roller;
+ Event : in Event_Kind)
+ return Event_Outcome is
+ begin
+ return Event_Outcome'Val
+ (fl_roller_handle (This.Void_Ptr, Event_Kind'Pos (Event)));
+ end Handle;
+
+
+end FLTK.Widgets.Valuators.Rollers;
+
diff --git a/src/fltk-widgets-valuators-rollers.ads b/src/fltk-widgets-valuators-rollers.ads
new file mode 100644
index 0000000..22a60b4
--- /dev/null
+++ b/src/fltk-widgets-valuators-rollers.ads
@@ -0,0 +1,38 @@
+
+
+package FLTK.Widgets.Valuators.Rollers is
+
+
+ type Roller is new Valuator with private;
+
+
+
+
+ function Create
+ (X, Y, W, H : in Integer;
+ Text : in String)
+ return Roller;
+
+
+
+
+ procedure Draw
+ (This : in out Roller);
+
+ function Handle
+ (This : in out Roller;
+ Event : in Event_Kind)
+ return Event_Outcome;
+
+
+private
+
+
+ type Roller is new Valuator with null record;
+
+ overriding procedure Finalize
+ (This : in out Roller);
+
+
+end FLTK.Widgets.Valuators.Rollers;
+