private with Actions;
private with Ada.Containers.Indefinite_Vectors;
private with Ada.Real_Time;
pragma Elaborate_All( Actions );
package Widgets.Menu_Enumerations is
type Enum_Action is new Action with private;
type A_Enum_Action is access all Enum_Action'Class;
function Get_Index( this : not null access Enum_Action'Class ) return Natural;
function Get_Text( this : not null access Enum_Action'Class ) return String;
Changed : constant Action_Id;
type Enum_Listener is limited interface and Action_Listener;
type A_Enum_Listener is access all Enum_Listener'Class;
procedure Handle_Action( this : access Enum_Listener;
action : A_Enum_Action ) is abstract;
type Menu_Enumeration is new Widget and Animated with private;
type A_Menu_Enumeration is access all Menu_Enumeration'Class;
function Create_Menu_Enum( view : not null access Game_Views.Game_View'Class;
id : String ) return A_Menu_Enumeration;
pragma Precondition( id'Length > 0 );
pragma Postcondition( Create_Menu_Enum'Result /= null );
procedure Add_Listener( this : access Menu_Enumeration;
listener : not null A_Enum_Listener );
procedure Add_Option( this : not null access Menu_Enumeration'Class;
text : String );
function Get_Index( this : not null access Menu_Enumeration'Class ) return Natural;
function Get_Text( this : not null access Menu_Enumeration'Class ) return String;
procedure Set_Index( this : not null access Menu_Enumeration'Class;
index : Positive;
fireAction : Boolean := True );
private
use Ada.Real_Time;
type Enum_Action is new Action with
record
index : Natural := 0;
text : Unbounded_String;
end record;
procedure Construct( this : access Enum_Action;
id : Action_Id;
source : not null A_Widget;
index : Natural;
text : String );
Changed : constant Action_Id := Actions.To_Action_Id( "enum.changed" );
package String_Vectors is new Ada.Containers.Indefinite_Vectors( Positive, String, "=" );
type Menu_Enumeration is new Widget and Animated with
record
focusTime : Time_Span;
icon : Natural;
options : String_Vectors.Vector;
index : Natural := 0;
end record;
procedure Construct( this : access Menu_Enumeration;
view : not null access Game_Views.Game_View'Class;
id : String );
pragma Precondition( id'Length > 0 );
procedure Draw_Content( this : access Menu_Enumeration );
function Get_Min_Height( this : access Menu_Enumeration ) return Natural;
function Get_Min_Width( this : access Menu_Enumeration ) return Natural;
procedure On_Blur( this : access Menu_Enumeration );
procedure On_Disabled( this : access Menu_Enumeration );
procedure On_Enabled( this : access Menu_Enumeration );
procedure On_Focus( this : access Menu_Enumeration );
procedure On_Key_Press( this : access Menu_Enumeration;
evt : not null A_Key_Event;
handled : in out Boolean );
procedure Tick( this : access Menu_Enumeration; time : Tick_Time );
end Widgets.Menu_Enumerations;