--
-- Copyright (c) 2012 Kevin Wellwood
-- All rights reserved.
--
-- This source code is distributed under the Modified BSD License. For terms and
-- conditions, see license.txt.
--
-- The Simple_Button_Group_Listener class provides a mechanism for registering
-- any method of a class, matching a certain prototype, as a button group action
-- handler.
--
-- Instantiate this package with the class and class-wide access type of an
-- object that will handle button group actions.
generic
type Target (<>) is tagged limited private;
package Widgets.Buttons.Groups.Simple_Listeners is
type A_Handler is access
procedure( object : not null access Target'Class;
action : A_Button_Group_Action );
-- Invokes the 'handler' method of 'obj' for button group actions
-- matching 'id'.
function Listener( id : Action_Id;
obj : access Target'Class;
handler : not null A_Handler ) return A_Button_Group_Listener;
pragma Postcondition( Listener'Result /= null );
private
type Simple_Button_Group_Listener is new Simple_Action_Listener and
Button_Group_Listener with
record
id : Action_Id;
object : access Target'Class := null;
handler : A_Handler := null;
end record;
-- Invokes the handler procedure of the simple button group listener's target.
procedure Handle_Action( this : access Simple_Button_Group_Listener;
action : A_Button_Group_Action );
end Widgets.Buttons.Groups.Simple_Listeners;