From 823f6cc33bc088ab7dbd5e604d34415152cbe181 Mon Sep 17 00:00:00 2001 From: Jed Barber Date: Sat, 3 Mar 2018 17:32:54 +1100 Subject: Added FLTK.Widgets.Valuators.Dials.Fill --- src/c_fl_fill_dial.cpp | 70 +++++++++++++++++++ src/c_fl_fill_dial.h | 27 ++++++++ src/fltk-widgets-valuators-dials-fill.adb | 109 ++++++++++++++++++++++++++++++ src/fltk-widgets-valuators-dials-fill.ads | 38 +++++++++++ 4 files changed, 244 insertions(+) create mode 100644 src/c_fl_fill_dial.cpp create mode 100644 src/c_fl_fill_dial.h create mode 100644 src/fltk-widgets-valuators-dials-fill.adb create mode 100644 src/fltk-widgets-valuators-dials-fill.ads (limited to 'src') diff --git a/src/c_fl_fill_dial.cpp b/src/c_fl_fill_dial.cpp new file mode 100644 index 0000000..94e5795 --- /dev/null +++ b/src/c_fl_fill_dial.cpp @@ -0,0 +1,70 @@ + + +#include +#include "c_fl_fill_dial.h" +#include "c_fl_type.h" + + + + +class My_Fill_Dial : public Fl_Fill_Dial { + public: + using Fl_Fill_Dial::Fl_Fill_Dial; + friend void fill_dial_set_draw_hook(FILL_DIAL v, void * d); + friend void fl_fill_dial_draw(FILL_DIAL v); + friend void fill_dial_set_handle_hook(FILL_DIAL v, void * h); + friend int fl_fill_dial_handle(FILL_DIAL v, 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_Fill_Dial::draw() { + (*draw_hook)(this->user_data()); +} + +void My_Fill_Dial::real_draw() { + Fl_Fill_Dial::draw(); +} + +int My_Fill_Dial::handle(int e) { + return (*handle_hook)(this->user_data(), e); +} + +int My_Fill_Dial::real_handle(int e) { + return Fl_Fill_Dial::handle(e); +} + +void fill_dial_set_draw_hook(FILL_DIAL v, void * d) { + reinterpret_cast(v)->draw_hook = reinterpret_cast(d); +} + +void fl_fill_dial_draw(FILL_DIAL v) { + reinterpret_cast(v)->real_draw(); +} + +void fill_dial_set_handle_hook(FILL_DIAL v, void * h) { + reinterpret_cast(v)->handle_hook = reinterpret_cast(h); +} + +int fl_fill_dial_handle(FILL_DIAL v, int e) { + return reinterpret_cast(v)->real_handle(e); +} + + + + +FILL_DIAL new_fl_fill_dial(int x, int y, int w, int h, char* label) { + My_Fill_Dial *v = new My_Fill_Dial(x, y, w, h, label); + return v; +} + +void free_fl_fill_dial(FILL_DIAL v) { + delete reinterpret_cast(v); +} + + diff --git a/src/c_fl_fill_dial.h b/src/c_fl_fill_dial.h new file mode 100644 index 0000000..39dced5 --- /dev/null +++ b/src/c_fl_fill_dial.h @@ -0,0 +1,27 @@ + + +#ifndef FL_FILL_DIAL_GUARD +#define FL_FILL_DIAL_GUARD + + + + +typedef void* FILL_DIAL; + + + + +extern "C" void fill_dial_set_draw_hook(FILL_DIAL v, void * d); +extern "C" void fl_fill_dial_draw(FILL_DIAL v); +extern "C" void fill_dial_set_handle_hook(FILL_DIAL v, void * h); +extern "C" int fl_fill_dial_handle(FILL_DIAL v, int e); + + + + +extern "C" FILL_DIAL new_fl_fill_dial(int x, int y, int w, int h, char* label); +extern "C" void free_fl_fill_dial(FILL_DIAL v); + + +#endif + diff --git a/src/fltk-widgets-valuators-dials-fill.adb b/src/fltk-widgets-valuators-dials-fill.adb new file mode 100644 index 0000000..97a915b --- /dev/null +++ b/src/fltk-widgets-valuators-dials-fill.adb @@ -0,0 +1,109 @@ + + +with + + Interfaces.C.Strings, + System; + +use type + + System.Address; + + +package body FLTK.Widgets.Valuators.Dials.Fill is + + + procedure fill_dial_set_draw_hook + (W, D : in System.Address); + pragma Import (C, fill_dial_set_draw_hook, "fill_dial_set_draw_hook"); + + procedure fill_dial_set_handle_hook + (W, H : in System.Address); + pragma Import (C, fill_dial_set_handle_hook, "fill_dial_set_handle_hook"); + + + + + function new_fl_fill_dial + (X, Y, W, H : in Interfaces.C.int; + Text : in Interfaces.C.char_array) + return System.Address; + pragma Import (C, new_fl_fill_dial, "new_fl_fill_dial"); + + procedure free_fl_fill_dial + (D : in System.Address); + pragma Import (C, free_fl_fill_dial, "free_fl_fill_dial"); + + + + + procedure fl_fill_dial_draw + (W : in System.Address); + pragma Import (C, fl_fill_dial_draw, "fl_fill_dial_draw"); + + function fl_fill_dial_handle + (W : in System.Address; + E : in Interfaces.C.int) + return Interfaces.C.int; + pragma Import (C, fl_fill_dial_handle, "fl_fill_dial_handle"); + + + + + procedure Finalize + (This : in out Fill_Dial) is + begin + if This.Void_Ptr /= System.Null_Address and then + This in Fill_Dial'Class + then + free_fl_fill_dial (This.Void_Ptr); + This.Void_Ptr := System.Null_Address; + end if; + Finalize (Dial (This)); + end Finalize; + + + + + function Create + (X, Y, W, H : in Integer; + Text : in String) + return Fill_Dial is + begin + return This : Fill_Dial do + This.Void_Ptr := new_fl_fill_dial + (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)); + fill_dial_set_draw_hook (This.Void_Ptr, Draw_Hook'Address); + fill_dial_set_handle_hook (This.Void_Ptr, Handle_Hook'Address); + end return; + end Create; + + + + + procedure Draw + (This : in out Fill_Dial) is + begin + fl_fill_dial_draw (This.Void_Ptr); + end Draw; + + + function Handle + (This : in out Fill_Dial; + Event : in Event_Kind) + return Event_Outcome is + begin + return Event_Outcome'Val + (fl_fill_dial_handle (This.Void_Ptr, Event_Kind'Pos (Event))); + end Handle; + + +end FLTK.Widgets.Valuators.Dials.Fill; + diff --git a/src/fltk-widgets-valuators-dials-fill.ads b/src/fltk-widgets-valuators-dials-fill.ads new file mode 100644 index 0000000..ec01ac0 --- /dev/null +++ b/src/fltk-widgets-valuators-dials-fill.ads @@ -0,0 +1,38 @@ + + +package FLTK.Widgets.Valuators.Dials.Fill is + + + type Fill_Dial is new Dial with private; + + + + + function Create + (X, Y, W, H : in Integer; + Text : in String) + return Fill_Dial; + + + + + procedure Draw + (This : in out Fill_Dial); + + function Handle + (This : in out Fill_Dial; + Event : in Event_Kind) + return Event_Outcome; + + +private + + + type Fill_Dial is new Dial with null record; + + overriding procedure Finalize + (This : in out Fill_Dial); + + +end FLTK.Widgets.Valuators.Dials.Fill; + -- cgit