diff options
author | Jed Barber <jjbarber@y7mail.com> | 2018-03-01 23:33:48 +1100 |
---|---|---|
committer | Jed Barber <jjbarber@y7mail.com> | 2018-03-01 23:33:48 +1100 |
commit | de5fa364a30e187fd450bf4420019936f09fd9ab (patch) | |
tree | 8b473258e4f08e738348e0e72d0e8222c9fbf209 | |
parent | 3bbd2259291b16ee5970865959d80960d70575ff (diff) |
Added FLTK.Widgets.Clocks.Updated.Round
-rw-r--r-- | progress.txt | 4 | ||||
-rw-r--r-- | src/c_fl_round_clock.cpp | 70 | ||||
-rw-r--r-- | src/c_fl_round_clock.h | 27 | ||||
-rw-r--r-- | src/fltk-widgets-clocks-updated-round.adb | 109 | ||||
-rw-r--r-- | src/fltk-widgets-clocks-updated-round.ads | 38 |
5 files changed, 246 insertions, 2 deletions
diff --git a/progress.txt b/progress.txt index 19047a4..7ac0834 100644 --- a/progress.txt +++ b/progress.txt @@ -31,6 +31,8 @@ FLTK.Widgets.Buttons.Radio FLTK.Widgets.Buttons.Repeat FLTK.Widgets.Buttons.Toggle FLTK.Widgets.Clocks +FLTK.Widgets.Clocks.Updated +FLTK.Widgets.Clocks.Updated.Round FLTK.Widgets.Groups.Scrolls FLTK.Widgets.Groups.Text_Displays.Text_Editors FLTK.Widgets.Groups.Windows.Double @@ -74,8 +76,6 @@ FL_XPM_Image FL_Shared_Image FL_Tiled_Image FL_Chart -FL_Clock -FL_Round_Clock FL_Browser FL_Check_Browser FL_File_Browser diff --git a/src/c_fl_round_clock.cpp b/src/c_fl_round_clock.cpp new file mode 100644 index 0000000..56179fc --- /dev/null +++ b/src/c_fl_round_clock.cpp @@ -0,0 +1,70 @@ + + +#include <FL/Fl_Round_Clock.H> +#include "c_fl_round_clock.h" +#include "c_fl_type.h" + + + + +class My_Round_Clock : public Fl_Round_Clock { + public: + using Fl_Round_Clock::Fl_Round_Clock; + friend void round_clock_set_draw_hook(ROUND_CLOCK c, void * d); + friend void fl_round_clock_draw(ROUND_CLOCK c); + friend void round_clock_set_handle_hook(ROUND_CLOCK c, void * h); + friend int fl_round_clock_handle(ROUND_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_Round_Clock::draw() { + (*draw_hook)(this->user_data()); +} + +void My_Round_Clock::real_draw() { + Fl_Round_Clock::draw(); +} + +int My_Round_Clock::handle(int e) { + return (*handle_hook)(this->user_data(), e); +} + +int My_Round_Clock::real_handle(int e) { + return Fl_Round_Clock::handle(e); +} + +void round_clock_set_draw_hook(ROUND_CLOCK c, void * d) { + reinterpret_cast<My_Round_Clock*>(c)->draw_hook = reinterpret_cast<d_hook_p>(d); +} + +void fl_round_clock_draw(ROUND_CLOCK c) { + reinterpret_cast<My_Round_Clock*>(c)->real_draw(); +} + +void round_clock_set_handle_hook(ROUND_CLOCK c, void * h) { + reinterpret_cast<My_Round_Clock*>(c)->handle_hook = reinterpret_cast<h_hook_p>(h); +} + +int fl_round_clock_handle(ROUND_CLOCK c, int e) { + return reinterpret_cast<My_Round_Clock*>(c)->real_handle(e); +} + + + + +ROUND_CLOCK new_fl_round_clock(int x, int y, int w, int h, char* label) { + My_Round_Clock *c = new My_Round_Clock(x, y, w, h, label); + return c; +} + +void free_fl_round_clock(ROUND_CLOCK c) { + delete reinterpret_cast<My_Round_Clock*>(c); +} + + diff --git a/src/c_fl_round_clock.h b/src/c_fl_round_clock.h new file mode 100644 index 0000000..c0e6585 --- /dev/null +++ b/src/c_fl_round_clock.h @@ -0,0 +1,27 @@ + + +#ifndef FL_ROUND_CLOCK_GUARD +#define FL_ROUND_CLOCK_GUARD + + + + +typedef void* ROUND_CLOCK; + + + + +extern "C" void round_clock_set_draw_hook(ROUND_CLOCK c, void * d); +extern "C" void fl_round_clock_draw(ROUND_CLOCK c); +extern "C" void round_clock_set_handle_hook(ROUND_CLOCK c, void * h); +extern "C" int fl_round_clock_handle(ROUND_CLOCK c, int e); + + + + +extern "C" ROUND_CLOCK new_fl_round_clock(int x, int y, int w, int h, char* label); +extern "C" void free_fl_round_clock(ROUND_CLOCK c); + + +#endif + diff --git a/src/fltk-widgets-clocks-updated-round.adb b/src/fltk-widgets-clocks-updated-round.adb new file mode 100644 index 0000000..9e03e67 --- /dev/null +++ b/src/fltk-widgets-clocks-updated-round.adb @@ -0,0 +1,109 @@ + + +with + + Interfaces.C.Strings, + System; + +use type + + System.Address; + + +package body FLTK.Widgets.Clocks.Updated.Round is + + + procedure round_clock_set_draw_hook + (W, D : in System.Address); + pragma Import (C, round_clock_set_draw_hook, "round_clock_set_draw_hook"); + + procedure round_clock_set_handle_hook + (W, H : in System.Address); + pragma Import (C, round_clock_set_handle_hook, "round_clock_set_handle_hook"); + + + + + function new_fl_round_clock + (X, Y, W, H : in Interfaces.C.int; + Text : in Interfaces.C.char_array) + return System.Address; + pragma Import (C, new_fl_round_clock, "new_fl_round_clock"); + + procedure free_fl_round_clock + (F : in System.Address); + pragma Import (C, free_fl_round_clock, "free_fl_round_clock"); + + + + + procedure fl_round_clock_draw + (W : in System.Address); + pragma Import (C, fl_round_clock_draw, "fl_round_clock_draw"); + + function fl_round_clock_handle + (W : in System.Address; + E : in Interfaces.C.int) + return Interfaces.C.int; + pragma Import (C, fl_round_clock_handle, "fl_round_clock_handle"); + + + + + procedure Finalize + (This : in out Round_Clock) is + begin + if This.Void_Ptr /= System.Null_Address and then + This in Round_Clock'Class + then + free_fl_round_clock (This.Void_Ptr); + This.Void_Ptr := System.Null_Address; + end if; + Finalize (Updated_Clock (This)); + end Finalize; + + + + + function Create + (X, Y, W, H : in Integer; + Text : in String) + return Round_Clock is + begin + return This : Round_Clock do + This.Void_Ptr := new_fl_round_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)); + round_clock_set_draw_hook (This.Void_Ptr, Draw_Hook'Address); + round_clock_set_handle_hook (This.Void_Ptr, Handle_Hook'Address); + end return; + end Create; + + + + + procedure Draw + (This : in out Round_Clock) is + begin + fl_round_clock_draw (This.Void_Ptr); + end Draw; + + + function Handle + (This : in out Round_Clock; + Event : in Event_Kind) + return Event_Outcome is + begin + return Event_Outcome'Val + (fl_round_clock_handle (This.Void_Ptr, Event_Kind'Pos (Event))); + end Handle; + + +end FLTK.Widgets.Clocks.Updated.Round; + diff --git a/src/fltk-widgets-clocks-updated-round.ads b/src/fltk-widgets-clocks-updated-round.ads new file mode 100644 index 0000000..5f68382 --- /dev/null +++ b/src/fltk-widgets-clocks-updated-round.ads @@ -0,0 +1,38 @@ + + +package FLTK.Widgets.Clocks.Updated.Round is + + + type Round_Clock is new Updated_Clock with private; + + + + + function Create + (X, Y, W, H : in Integer; + Text : in String) + return Round_Clock; + + + + + procedure Draw + (This : in out Round_Clock); + + function Handle + (This : in out Round_Clock; + Event : in Event_Kind) + return Event_Outcome; + + +private + + + type Round_Clock is new Updated_Clock with null record; + + overriding procedure Finalize + (This : in out Round_Clock); + + +end FLTK.Widgets.Clocks.Updated.Round; + |