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