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-groups-windows-single-menu.adb | 63 ++++++++++--------------- 1 file changed, 24 insertions(+), 39 deletions(-) (limited to 'src/fltk-widgets-groups-windows-single-menu.adb') diff --git a/src/fltk-widgets-groups-windows-single-menu.adb b/src/fltk-widgets-groups-windows-single-menu.adb index fa2c9b3..7448c3b 100644 --- a/src/fltk-widgets-groups-windows-single-menu.adb +++ b/src/fltk-widgets-groups-windows-single-menu.adb @@ -16,18 +16,9 @@ use type package body FLTK.Widgets.Groups.Windows.Single.Menu is - procedure menu_window_set_draw_hook - (W, D : in Storage.Integer_Address); - pragma Import (C, menu_window_set_draw_hook, "menu_window_set_draw_hook"); - pragma Inline (menu_window_set_draw_hook); - - procedure menu_window_set_handle_hook - (W, H : in Storage.Integer_Address); - pragma Import (C, menu_window_set_handle_hook, "menu_window_set_handle_hook"); - pragma Inline (menu_window_set_handle_hook); - - - + ------------------------ + -- Functions From C -- + ------------------------ function new_fl_menu_window (X, Y, W, H : in Interfaces.C.int; @@ -103,6 +94,10 @@ package body FLTK.Widgets.Groups.Windows.Single.Menu is + ------------------- + -- Destructors -- + ------------------- + procedure Extra_Final (This : in out Menu_Window) is begin @@ -123,6 +118,10 @@ package body FLTK.Widgets.Groups.Windows.Single.Menu is + -------------------- + -- Constructors -- + -------------------- + procedure Extra_Init (This : in out Menu_Window; X, Y, W, H : in Integer; @@ -132,6 +131,14 @@ package body FLTK.Widgets.Groups.Windows.Single.Menu is end Extra_Init; + procedure Initialize + (This : in out Menu_Window) is + begin + This.Draw_Ptr := fl_menu_window_draw'Address; + This.Handle_Ptr := fl_menu_window_handle'Address; + end Initialize; + + package body Forge is function Create @@ -147,10 +154,6 @@ package body FLTK.Widgets.Groups.Windows.Single.Menu is Interfaces.C.int (H), Interfaces.C.To_C (Text)); Extra_Init (This, X, Y, W, H, Text); - menu_window_set_draw_hook - (This.Void_Ptr, Storage.To_Integer (Draw_Hook'Address)); - menu_window_set_handle_hook - (This.Void_Ptr, Storage.To_Integer (Handle_Hook'Address)); end return; end Create; @@ -166,10 +169,6 @@ package body FLTK.Widgets.Groups.Windows.Single.Menu is Interfaces.C.int (H), Interfaces.C.To_C (Text)); Extra_Init (This, This.Get_X, This.Get_Y, W, H, Text); - menu_window_set_draw_hook - (This.Void_Ptr, Storage.To_Integer (Draw_Hook'Address)); - menu_window_set_handle_hook - (This.Void_Ptr, Storage.To_Integer (Handle_Hook'Address)); end return; end Create; @@ -178,6 +177,10 @@ package body FLTK.Widgets.Groups.Windows.Single.Menu is + ----------------------- + -- API Subprograms -- + ----------------------- + procedure Show (This : in out Menu_Window) is begin @@ -221,24 +224,6 @@ package body FLTK.Widgets.Groups.Windows.Single.Menu is end Set_Overlay; - - - procedure Draw - (This : in out Menu_Window) is - begin - fl_menu_window_draw (This.Void_Ptr); - end Draw; - - - function Handle - (This : in out Menu_Window; - Event : in Event_Kind) - return Event_Outcome is - begin - return Event_Outcome'Val - (fl_menu_window_handle (This.Void_Ptr, Event_Kind'Pos (Event))); - end Handle; - - end FLTK.Widgets.Groups.Windows.Single.Menu; + -- cgit