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_PBoard_Listener class provides a mechanism for registering any 
  10. -- method of a class, matching a certain prototype, as a progress board action 
  11. -- handler. 
  12. -- 
  13. -- Instantiate this package with the class and class-wide access type of an 
  14. -- object that will handle input actions. 
  15. generic 
  16.     type Target (<>) is tagged limited private; 
  17. package Widgets.Progress_Boards.Simple_Listeners is 
  18.  
  19.     type A_Handler is access 
  20.         procedure( object : not null access Target'Class; 
  21.                    action : A_PBoard_Action ); 
  22.  
  23.     -- Invokes the 'handler' method of 'obj' for all progress board actions. 
  24.     function Listener( id      : Action_Id; 
  25.                        obj     : access Target'Class; 
  26.                        handler : not null A_Handler ) return A_PBoard_Listener; 
  27.     pragma Postcondition( Listener'Result /= null ); 
  28.  
  29. private 
  30.  
  31.     type Simple_PBoard_Listener is new Simple_Action_Listener and 
  32.                                        PBoard_Listener with 
  33.         record 
  34.             id      : Action_Id; 
  35.             object  : access Target'Class := null; 
  36.             handler : A_Handler := null; 
  37.         end record; 
  38.  
  39.     -- Invokes the handler procedure of the simple pboard listener's target. 
  40.     procedure Handle_Action( this   : access Simple_PBoard_Listener; 
  41.                              action : A_PBoard_Action ); 
  42.  
  43. end Widgets.Progress_Boards.Simple_Listeners;