diff options
author | Jedidiah Barber <contact@jedbarber.id.au> | 2025-03-02 16:06:45 +1300 |
---|---|---|
committer | Jedidiah Barber <contact@jedbarber.id.au> | 2025-03-02 16:06:45 +1300 |
commit | f2352c6df585d817b3613145ec81446f917dcc21 (patch) | |
tree | 3b43830d3f8dc7e9fba186db127d2ddf91b3feda /spec/fltk-events.ads | |
parent | d5fd3906e62969fce7fec7f2fccdc5a7436cbdbc (diff) |
Diffstat (limited to 'spec/fltk-events.ads')
-rw-r--r-- | spec/fltk-events.ads | 44 |
1 files changed, 35 insertions, 9 deletions
diff --git a/spec/fltk-events.ads b/spec/fltk-events.ads index 6a556ff..5dbc573 100644 --- a/spec/fltk-events.ads +++ b/spec/fltk-events.ads @@ -6,11 +6,12 @@ with - FLTK.Widgets.Groups.Windows; + FLTK.Widgets.Groups.Windows, + System; private with - Ada.Containers.Vectors, + Ada.Finalization, System.Address_To_Access_Conversions; @@ -27,15 +28,33 @@ package FLTK.Events is return Event_Outcome; + type System_Event is new System.Address; + + type System_Handler is access function + (Event : in System_Event) + return Event_Outcome; + + -- Handlers -- procedure Add_Handler - (Func : in Event_Handler); + (Func : in not null Event_Handler); procedure Remove_Handler - (Func : in Event_Handler); + (Func : in not null Event_Handler); + + procedure Add_System_Handler + (Func : in not null System_Handler); + + procedure Remove_System_Handler + (Func : in not null System_Handler); + + + + + -- Dispatch -- function Get_Dispatch return Event_Dispatch; @@ -255,11 +274,6 @@ private (FLTK.Widgets.Groups.Windows.Window'Class); - package Handler_Vectors is new Ada.Containers.Vectors - (Index_Type => Positive, Element_Type => Event_Handler); - - - Handlers : Handler_Vectors.Vector := Handler_Vectors.Empty_Vector; Current_Dispatch : Event_Dispatch := null; @@ -275,6 +289,9 @@ private pragma Inline (Add_Handler); pragma Inline (Remove_Handler); + pragma Inline (Add_System_Handler); + pragma Inline (Remove_System_Handler); + pragma Inline (Get_Dispatch); pragma Inline (Set_Dispatch); pragma Inline (Handle_Dispatch); @@ -333,6 +350,15 @@ private pragma Inline (Key_Shift); + -- Needed to deregister the handlers + type FLTK_Events_Final_Controller is new Ada.Finalization.Limited_Controlled with null record; + + overriding procedure Finalize + (This : in out FLTK_Events_Final_Controller); + + Cleanup : FLTK_Events_Final_Controller; + + end FLTK.Events; |