--
-- 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_PBoard_Listener class provides a mechanism for registering any
-- method of a class, matching a certain prototype, as a progress board action
-- handler.
--
-- Instantiate this package with the class and class-wide access type of an
-- object that will handle input actions.
generic
type Target (<>) is tagged limited private;
package Widgets.Progress_Boards.Simple_Listeners is
type A_Handler is access
procedure( object : not null access Target'Class;
action : A_PBoard_Action );
-- Invokes the 'handler' method of 'obj' for all progress board actions.
function Listener( id : Action_Id;
obj : access Target'Class;
handler : not null A_Handler ) return A_PBoard_Listener;
pragma Postcondition( Listener'Result /= null );
private
type Simple_PBoard_Listener is new Simple_Action_Listener and
PBoard_Listener with
record
id : Action_Id;
object : access Target'Class := null;
handler : A_Handler := null;
end record;
-- Invokes the handler procedure of the simple pboard listener's target.
procedure Handle_Action( this : access Simple_PBoard_Listener;
action : A_PBoard_Action );
end Widgets.Progress_Boards.Simple_Listeners;