From e93b9bbc02e2791f3a35b6f077fcbb8514c28aed Mon Sep 17 00:00:00 2001 From: Jedidiah Barber Date: Sun, 12 Jan 2025 01:14:58 +1300 Subject: Refactored draw/handle methods in Widgets hierarchy, improved docs, added a few minor method bindings here and there --- src/fltk-widgets-valuators-value_outputs.adb | 45 ++++++++++++++++------------ 1 file changed, 26 insertions(+), 19 deletions(-) (limited to 'src/fltk-widgets-valuators-value_outputs.adb') diff --git a/src/fltk-widgets-valuators-value_outputs.adb b/src/fltk-widgets-valuators-value_outputs.adb index dcd763d..de6adf7 100644 --- a/src/fltk-widgets-valuators-value_outputs.adb +++ b/src/fltk-widgets-valuators-value_outputs.adb @@ -16,18 +16,9 @@ use type package body FLTK.Widgets.Valuators.Value_Outputs is - procedure value_output_set_draw_hook - (W, D : in Storage.Integer_Address); - pragma Import (C, value_output_set_draw_hook, "value_output_set_draw_hook"); - pragma Inline (value_output_set_draw_hook); - - procedure value_output_set_handle_hook - (W, H : in Storage.Integer_Address); - pragma Import (C, value_output_set_handle_hook, "value_output_set_handle_hook"); - pragma Inline (value_output_set_handle_hook); - - - + ------------------------ + -- Functions From C -- + ------------------------ function new_fl_value_output (X, Y, W, H : in Interfaces.C.int; @@ -113,6 +104,10 @@ package body FLTK.Widgets.Valuators.Value_Outputs is + ------------------- + -- Destructors -- + ------------------- + procedure Extra_Final (This : in out Value_Output) is begin @@ -133,6 +128,10 @@ package body FLTK.Widgets.Valuators.Value_Outputs is + -------------------- + -- Constructors -- + -------------------- + procedure Extra_Init (This : in out Value_Output; X, Y, W, H : in Integer; @@ -142,6 +141,14 @@ package body FLTK.Widgets.Valuators.Value_Outputs is end Extra_Init; + procedure Initialize + (This : in out Value_Output) is + begin + This.Draw_Ptr := fl_value_output_draw'Address; + This.Handle_Ptr := fl_value_output_handle'Address; + end Initialize; + + package body Forge is function Create @@ -157,10 +164,6 @@ package body FLTK.Widgets.Valuators.Value_Outputs is Interfaces.C.int (H), Interfaces.C.To_C (Text)); Extra_Init (This, X, Y, W, H, Text); - value_output_set_draw_hook - (This.Void_Ptr, Storage.To_Integer (Draw_Hook'Address)); - value_output_set_handle_hook - (This.Void_Ptr, Storage.To_Integer (Handle_Hook'Address)); end return; end Create; @@ -169,6 +172,10 @@ package body FLTK.Widgets.Valuators.Value_Outputs is + ----------------------- + -- API Subprograms -- + ----------------------- + function Is_Soft (This : in Value_Output) return Boolean is @@ -240,7 +247,7 @@ package body FLTK.Widgets.Valuators.Value_Outputs is procedure Draw (This : in out Value_Output) is begin - fl_value_output_draw (This.Void_Ptr); + Valuator (This).Draw; end Draw; @@ -249,10 +256,10 @@ package body FLTK.Widgets.Valuators.Value_Outputs is Event : in Event_Kind) return Event_Outcome is begin - return Event_Outcome'Val - (fl_value_output_handle (This.Void_Ptr, Event_Kind'Pos (Event))); + return Valuator (This).Handle (Event); end Handle; end FLTK.Widgets.Valuators.Value_Outputs; + -- cgit