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-adjusters.adb | 55 ++++++++++++++++++++++---------- 1 file changed, 38 insertions(+), 17 deletions(-) (limited to 'src/fltk-widgets-valuators-adjusters.adb') diff --git a/src/fltk-widgets-valuators-adjusters.adb b/src/fltk-widgets-valuators-adjusters.adb index 0c96332..b4a8bc3 100644 --- a/src/fltk-widgets-valuators-adjusters.adb +++ b/src/fltk-widgets-valuators-adjusters.adb @@ -16,18 +16,9 @@ use type package body FLTK.Widgets.Valuators.Adjusters is - procedure adjuster_set_draw_hook - (W, D : in Storage.Integer_Address); - pragma Import (C, adjuster_set_draw_hook, "adjuster_set_draw_hook"); - pragma Inline (adjuster_set_draw_hook); - - procedure adjuster_set_handle_hook - (W, H : in Storage.Integer_Address); - pragma Import (C, adjuster_set_handle_hook, "adjuster_set_handle_hook"); - pragma Inline (adjuster_set_handle_hook); - - - + ------------------------ + -- Functions From C -- + ------------------------ function new_fl_adjuster (X, Y, W, H : in Interfaces.C.int; @@ -59,6 +50,11 @@ package body FLTK.Widgets.Valuators.Adjusters is + procedure fl_adjuster_value_damage + (A : in Storage.Integer_Address); + pragma Import (C, fl_adjuster_value_damage, "fl_adjuster_value_damage"); + pragma Inline (fl_adjuster_value_damage); + procedure fl_adjuster_draw (W : in Storage.Integer_Address); pragma Import (C, fl_adjuster_draw, "fl_adjuster_draw"); @@ -74,6 +70,10 @@ package body FLTK.Widgets.Valuators.Adjusters is + ------------------- + -- Destructors -- + ------------------- + procedure Extra_Final (This : in out Adjuster) is begin @@ -94,6 +94,10 @@ package body FLTK.Widgets.Valuators.Adjusters is + -------------------- + -- Constructors -- + -------------------- + procedure Extra_Init (This : in out Adjuster; X, Y, W, H : in Integer; @@ -103,6 +107,14 @@ package body FLTK.Widgets.Valuators.Adjusters is end Extra_Init; + procedure Initialize + (This : in out Adjuster) is + begin + This.Draw_Ptr := fl_adjuster_draw'Address; + This.Handle_Ptr := fl_adjuster_handle'Address; + end Initialize; + + package body Forge is function Create @@ -118,8 +130,6 @@ package body FLTK.Widgets.Valuators.Adjusters is Interfaces.C.int (H), Interfaces.C.To_C (Text)); Extra_Init (This, X, Y, W, H, Text); - adjuster_set_draw_hook (This.Void_Ptr, Storage.To_Integer (Draw_Hook'Address)); - adjuster_set_handle_hook (This.Void_Ptr, Storage.To_Integer (Handle_Hook'Address)); end return; end Create; @@ -128,6 +138,10 @@ package body FLTK.Widgets.Valuators.Adjusters is + ----------------------- + -- API Subprograms -- + ----------------------- + function Is_Soft (This : in Adjuster) return Boolean is @@ -146,10 +160,17 @@ package body FLTK.Widgets.Valuators.Adjusters is + procedure Value_Damage + (This : in out Adjuster) is + begin + fl_adjuster_value_damage (This.Void_Ptr); + end Value_Damage; + + procedure Draw (This : in out Adjuster) is begin - fl_adjuster_draw (This.Void_Ptr); + Valuator (This).Draw; end Draw; @@ -158,10 +179,10 @@ package body FLTK.Widgets.Valuators.Adjusters is Event : in Event_Kind) return Event_Outcome is begin - return Event_Outcome'Val - (fl_adjuster_handle (This.Void_Ptr, Event_Kind'Pos (Event))); + return Valuator (This).Handle (Event); end Handle; end FLTK.Widgets.Valuators.Adjusters; + -- cgit