summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJed Barber <jjbarber@y7mail.com>2018-03-01 19:45:21 +1100
committerJed Barber <jjbarber@y7mail.com>2018-03-01 19:45:21 +1100
commit3bbd2259291b16ee5970865959d80960d70575ff (patch)
treed66d1684a07dbc52471d154a1d9a90cecdf4a898 /src
parent38e5d2200b48b86772d6921e1553bf76408e5809 (diff)
Added FLTK.Widgets.Clocks.Updated
Diffstat (limited to 'src')
-rw-r--r--src/c_fl_clock.cpp70
-rw-r--r--src/c_fl_clock.h27
-rw-r--r--src/fltk-widgets-clocks-updated.adb109
-rw-r--r--src/fltk-widgets-clocks-updated.ads38
4 files changed, 244 insertions, 0 deletions
diff --git a/src/c_fl_clock.cpp b/src/c_fl_clock.cpp
new file mode 100644
index 0000000..89b19bc
--- /dev/null
+++ b/src/c_fl_clock.cpp
@@ -0,0 +1,70 @@
+
+
+#include <FL/Fl_Clock.H>
+#include "c_fl_clock.h"
+#include "c_fl_type.h"
+
+
+
+
+class My_Clock : public Fl_Clock {
+ public:
+ using Fl_Clock::Fl_Clock;
+ friend void clock_set_draw_hook(CLOCK c, void * d);
+ friend void fl_clock_draw(CLOCK c);
+ friend void clock_set_handle_hook(CLOCK c, void * h);
+ friend int fl_clock_handle(CLOCK 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_Clock::draw() {
+ (*draw_hook)(this->user_data());
+}
+
+void My_Clock::real_draw() {
+ Fl_Clock::draw();
+}
+
+int My_Clock::handle(int e) {
+ return (*handle_hook)(this->user_data(), e);
+}
+
+int My_Clock::real_handle(int e) {
+ return Fl_Clock::handle(e);
+}
+
+void clock_set_draw_hook(CLOCK c, void * d) {
+ reinterpret_cast<My_Clock*>(c)->draw_hook = reinterpret_cast<d_hook_p>(d);
+}
+
+void fl_clock_draw(CLOCK c) {
+ reinterpret_cast<My_Clock*>(c)->real_draw();
+}
+
+void clock_set_handle_hook(CLOCK c, void * h) {
+ reinterpret_cast<My_Clock*>(c)->handle_hook = reinterpret_cast<h_hook_p>(h);
+}
+
+int fl_clock_handle(CLOCK c, int e) {
+ return reinterpret_cast<My_Clock*>(c)->real_handle(e);
+}
+
+
+
+
+CLOCK new_fl_clock(int x, int y, int w, int h, char* label) {
+ My_Clock *c = new My_Clock(x, y, w, h, label);
+ return c;
+}
+
+void free_fl_clock(CLOCK c) {
+ delete reinterpret_cast<My_Clock*>(c);
+}
+
+
diff --git a/src/c_fl_clock.h b/src/c_fl_clock.h
new file mode 100644
index 0000000..844f428
--- /dev/null
+++ b/src/c_fl_clock.h
@@ -0,0 +1,27 @@
+
+
+#ifndef FL_CLOCK_GUARD
+#define FL_CLOCK_GUARD
+
+
+
+
+typedef void* CLOCK;
+
+
+
+
+extern "C" void clock_set_draw_hook(CLOCK c, void * d);
+extern "C" void fl_clock_draw(CLOCK c);
+extern "C" void clock_set_handle_hook(CLOCK c, void * h);
+extern "C" int fl_clock_handle(CLOCK c, int e);
+
+
+
+
+extern "C" CLOCK new_fl_clock(int x, int y, int w, int h, char* label);
+extern "C" void free_fl_clock(CLOCK c);
+
+
+#endif
+
diff --git a/src/fltk-widgets-clocks-updated.adb b/src/fltk-widgets-clocks-updated.adb
new file mode 100644
index 0000000..e193962
--- /dev/null
+++ b/src/fltk-widgets-clocks-updated.adb
@@ -0,0 +1,109 @@
+
+
+with
+
+ Interfaces.C.Strings,
+ System;
+
+use type
+
+ System.Address;
+
+
+package body FLTK.Widgets.Clocks.Updated is
+
+
+ procedure clock_set_draw_hook
+ (W, D : in System.Address);
+ pragma Import (C, clock_set_draw_hook, "clock_set_draw_hook");
+
+ procedure clock_set_handle_hook
+ (W, H : in System.Address);
+ pragma Import (C, clock_set_handle_hook, "clock_set_handle_hook");
+
+
+
+
+ function new_fl_clock
+ (X, Y, W, H : in Interfaces.C.int;
+ Text : in Interfaces.C.char_array)
+ return System.Address;
+ pragma Import (C, new_fl_clock, "new_fl_clock");
+
+ procedure free_fl_clock
+ (F : in System.Address);
+ pragma Import (C, free_fl_clock, "free_fl_clock");
+
+
+
+
+ procedure fl_clock_draw
+ (W : in System.Address);
+ pragma Import (C, fl_clock_draw, "fl_clock_draw");
+
+ function fl_clock_handle
+ (W : in System.Address;
+ E : in Interfaces.C.int)
+ return Interfaces.C.int;
+ pragma Import (C, fl_clock_handle, "fl_clock_handle");
+
+
+
+
+ procedure Finalize
+ (This : in out Updated_Clock) is
+ begin
+ if This.Void_Ptr /= System.Null_Address and then
+ This in Updated_Clock'Class
+ then
+ free_fl_clock (This.Void_Ptr);
+ This.Void_Ptr := System.Null_Address;
+ end if;
+ Finalize (Clock (This));
+ end Finalize;
+
+
+
+
+ function Create
+ (X, Y, W, H : in Integer;
+ Text : in String)
+ return Updated_Clock is
+ begin
+ return This : Updated_Clock do
+ This.Void_Ptr := new_fl_clock
+ (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));
+ clock_set_draw_hook (This.Void_Ptr, Draw_Hook'Address);
+ clock_set_handle_hook (This.Void_Ptr, Handle_Hook'Address);
+ end return;
+ end Create;
+
+
+
+
+ procedure Draw
+ (This : in out Updated_Clock) is
+ begin
+ fl_clock_draw (This.Void_Ptr);
+ end Draw;
+
+
+ function Handle
+ (This : in out Updated_Clock;
+ Event : in Event_Kind)
+ return Event_Outcome is
+ begin
+ return Event_Outcome'Val
+ (fl_clock_handle (This.Void_Ptr, Event_Kind'Pos (Event)));
+ end Handle;
+
+
+end FLTK.Widgets.Clocks.Updated;
+
diff --git a/src/fltk-widgets-clocks-updated.ads b/src/fltk-widgets-clocks-updated.ads
new file mode 100644
index 0000000..bcfc59b
--- /dev/null
+++ b/src/fltk-widgets-clocks-updated.ads
@@ -0,0 +1,38 @@
+
+
+package FLTK.Widgets.Clocks.Updated is
+
+
+ type Updated_Clock is new Clock with private;
+
+
+
+
+ function Create
+ (X, Y, W, H : in Integer;
+ Text : in String)
+ return Updated_Clock;
+
+
+
+
+ procedure Draw
+ (This : in out Updated_Clock);
+
+ function Handle
+ (This : in out Updated_Clock;
+ Event : in Event_Kind)
+ return Event_Outcome;
+
+
+private
+
+
+ type Updated_Clock is new Clock with null record;
+
+ overriding procedure Finalize
+ (This : in out Updated_Clock);
+
+
+end FLTK.Widgets.Clocks.Updated;
+