1. limited with Widgets; 
  2.  
  3. private with Ada.Containers; 
  4.  
  5. package Actions is 
  6.  
  7.     pragma Preelaborate; 
  8.  
  9.     -- Represents the type of action that occurred 
  10.     type Action_Id is private; 
  11.  
  12.     function "="( l, r : Action_Id ) return Boolean; 
  13.  
  14.     function To_Action_Id( actName : String ) return Action_Id; 
  15.  
  16.     ---------------------------------------------------------------------------- 
  17.  
  18.     -- Represents an action that occurred to a widget in the GUI, such as a 
  19.     -- click, toggle, press, etc. 
  20.     type Action is abstract tagged limited private; 
  21.  
  22.     -- All actions have a base type/id and the widget that reported the action. 
  23.     -- Additional information about the action may be included, depending on the 
  24.     -- concrete action class. A concrete action class represents a set of action 
  25.     -- types that all share the same kind of action information, or come from 
  26.     -- the same class of widget. 
  27.     procedure Construct( this   : access Action; 
  28.                          id     : Action_Id; 
  29.                          source : not null access Widgets.Widget'Class ); 
  30.  
  31.     -- Returns the identity of the action. This is the specific type of action 
  32.     -- that occured at the source widget, like Click, Input_Entered, etc. 
  33.     function Get_Id( this : not null access Action'Class ) return Action_Id; 
  34.  
  35.     -- Returns a reference to the widget that reported the action. 
  36.     function Get_Source( this : not null access Action'Class ) return access Widgets.Widget'Class; 
  37.  
  38.     ---------------------------------------------------------------------------- 
  39.  
  40.     -- An interface from which all concrete Action_Listener interfaces are to be 
  41.     -- inherited from. This interface does not define any procedures because it 
  42.     -- is not used directly. The interface is useful for putting different 
  43.     -- classes of Action_Listeners in a common container. 
  44.     type Action_Listener is limited interface; 
  45.     type A_Action_Listener is access all Action_Listener'Class; 
  46.  
  47. private 
  48.  
  49.     use Ada.Containers; 
  50.  
  51.     -- An action Id is a hashed string. 
  52.     type Action_Id is new Ada.Containers.Hash_Type; 
  53.  
  54.     type Action is abstract tagged limited 
  55.         record 
  56.             id     : Action_Id := Action_Id'First; 
  57.             source : access Widgets.Widget'Class; 
  58.         end record; 
  59.  
  60. end Actions;