1. -- 
  2. -- Copyright (c) 2012 Kevin Wellwood 
  3. -- All rights reserved. 
  4. -- 
  5. -- This source code is distributed under the Modified BSD License. For terms and 
  6. -- conditions, see license.txt. 
  7. -- 
  8.  
  9. -- The Simple_Input_Listener class provides a mechanism for registering any 
  10. -- method of a class, matching a certain prototype, as an input action handler. 
  11. -- 
  12. -- Instantiate this package with the class and class-wide access type of an 
  13. -- object that will handle input actions. 
  14. generic 
  15.     type Target (<>) is tagged limited private; 
  16. package Widgets.Menu_Enumerations.Simple_Listeners is 
  17.  
  18.     type A_Handler is access 
  19.         procedure( object : not null access Target'Class; 
  20.                    action : A_Enum_Action ); 
  21.  
  22.     -- Invokes the 'handler' method of 'obj' for all input actions. 
  23.     function Listener( obj     : access Target'Class; 
  24.                        handler : not null A_Handler ) return A_Enum_Listener; 
  25.     pragma Postcondition( Listener'Result /= null ); 
  26.  
  27. private 
  28.  
  29.     type Simple_Enum_Listener is new Simple_Action_Listener and 
  30.                                      Enum_Listener with 
  31.         record 
  32.             object  : access Target'Class := null; 
  33.             handler : A_Handler := null; 
  34.         end record; 
  35.  
  36.     -- Invokes the handler procedure of the simple enum listener's target. 
  37.     procedure Handle_Action( this   : access Simple_Enum_Listener; 
  38.                              action : A_Enum_Action ); 
  39.  
  40. end Widgets.Menu_Enumerations.Simple_Listeners;