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