From b72f41264d96f6cd9333badad82f978ecdc48fc2 Mon Sep 17 00:00:00 2001 From: Jed Barber Date: Fri, 15 Jul 2016 22:20:30 +1000 Subject: Groups and Widgets should now keep track of themselves properly, also all named access types removed --- src/fltk_binding/fltk-widgets-buttons.adb | 35 ++++++++++++++++--------------- 1 file changed, 18 insertions(+), 17 deletions(-) (limited to 'src/fltk_binding/fltk-widgets-buttons.adb') diff --git a/src/fltk_binding/fltk-widgets-buttons.adb b/src/fltk_binding/fltk-widgets-buttons.adb index d74718a..2f2f938 100644 --- a/src/fltk_binding/fltk-widgets-buttons.adb +++ b/src/fltk_binding/fltk-widgets-buttons.adb @@ -10,7 +10,7 @@ package body FLTK.Widgets.Buttons is function new_fl_button (X, Y, W, H : in Interfaces.C.int; - Label : in Interfaces.C.char_array) + Text : in Interfaces.C.char_array) return System.Address; pragma Import (C, new_fl_button, "new_fl_button"); @@ -38,8 +38,11 @@ package body FLTK.Widgets.Buttons is procedure Finalize (This : in out Button) is begin - if (This.Void_Ptr /= System.Null_Address) then - free_fl_button (This.Void_Ptr); + Finalize (Widget (This)); + if This.Void_Ptr /= System.Null_Address then + if This in Button then + free_fl_button (This.Void_Ptr); + end if; end if; end Finalize; @@ -48,48 +51,46 @@ package body FLTK.Widgets.Buttons is function Create (X, Y, W, H : in Integer; - Label : in String) + Text : in String) return Button is - - VP : System.Address; - begin - VP := new_fl_button + return This : Button do + This.Void_Ptr := new_fl_button (Interfaces.C.int (X), Interfaces.C.int (Y), Interfaces.C.int (W), Interfaces.C.int (H), - Interfaces.C.To_C (Label)); - return (Ada.Finalization.Limited_Controlled with Void_Ptr => VP); + Interfaces.C.To_C (Text)); + end return; end Create; function Get_State - (B : in Button'Class) + (This : in Button) return State is begin - return State'Val (fl_button_get_state (B.Void_Ptr)); + return State'Val (fl_button_get_state (This.Void_Ptr)); end Get_State; procedure Set_State - (B : in out Button'Class; - S : in State) is + (This : in out Button; + St : in State) is begin - fl_button_set_state (B.Void_Ptr, State'Pos (S)); + fl_button_set_state (This.Void_Ptr, State'Pos (St)); end Set_State; procedure Set_Only - (B : in out Button'Class) is + (This : in out Button) is begin - fl_button_set_only (B.Void_Ptr); + fl_button_set_only (This.Void_Ptr); end Set_Only; -- cgit