with Objects; use Objects;
limited with Widgets;
private with Ada.Containers;
package Actions is
-- Represents the type of action that occurred
type Action_Id is private;
function "="( l, r : Action_Id ) return Boolean;
function To_Action_Id( actName : String ) return Action_Id;
----------------------------------------------------------------------------
-- Represents an action that occurred to a widget in the GUI, such as a
-- click, toggle, press, etc.
type Action is abstract new Object with private;
-- All actions have a base type/id and the widget that reported the action.
-- Additional information about the action may be included, depending on the
-- concrete action class. A concrete action class represents a set of action
-- types that all share the same kind of action information, or come from
-- the same class of widget.
procedure Construct( this : access Action;
id : Action_Id;
source : not null access Widgets.Widget'Class );
-- Returns the identity of the action. This is the specific type of action
-- that occured at the source widget, like Click, Input_Entered, etc.
function Get_Id( this : not null access Action'Class ) return Action_Id;
-- Returns a reference to the widget that reported the action.
function Get_Source( this : not null access Action'Class ) return access Widgets.Widget'Class;
----------------------------------------------------------------------------
-- An interface from which all concrete Action_Listener interfaces are to be
-- inherited from. This interface does not define any procedures because it
-- is not used directly. The interface is useful for putting different
-- classes of Action_Listeners in a common container.
type Action_Listener is limited interface;
type A_Action_Listener is access all Action_Listener'Class;
private
use Ada.Containers;
-- An action Id is a hashed string.
type Action_Id is new Ada.Containers.Hash_Type;
type Action is abstract new Object with
record
id : Action_Id := Action_Id'First;
source : access Widgets.Widget'Class;
end record;
end Actions;