package Widgets.Buttons is
type Button_Action is new Action with private;
type A_Button_Action is access all Button_Action'Class;
Press : constant Action_Id;
Held : constant Action_Id;
Release : constant Action_Id;
Click : constant Action_Id;
type Button_Listener is limited interface and Action_Listener;
type A_Button_Listener is access all Button_Listener'Class;
procedure Handle_Action( this : access Button_Listener;
action : A_Button_Action ) is abstract;
type A_Button_Handler is
access procedure( action : A_Button_Action );
type Button is abstract new Widget with private;
type A_Button is access all Button'Class;
procedure Add_Listener( this : access Button;
listener : not null A_Button_Listener );
procedure Add_Listener( this : access Button;
handler : not null A_Button_Handler );
procedure Contrast_Text( this : not null access Button'Class; enabled : Boolean );
function Get_State( this : not null access Button'Class ) return Boolean;
function Get_Text( this : not null access Button'Class ) return String;
procedure Remove_Listener( this : access Button;
listener : not null A_Button_Listener );
procedure Set_Align( this : not null access Button'Class; align : Align_Type );
#if OSX then
procedure Set_Color( this : access Button;
purpose : Color_Purpose;
color : Color_Type );
#end if;
procedure Set_Icon( this : access Button; icon : String );
procedure Set_State( this : access Button; on : Boolean );
procedure Set_Text( this : access Button; text : String );
procedure Toggle_State( this : access Button );
private
SPACING : constant Integer := 2;
type Button_Action is new Action with null record;
Press : constant Action_Id := To_Action_Id( "button.press" );
Held : constant Action_Id := To_Action_Id( "button.held" );
Release : constant Action_Id := To_Action_Id( "button.release" );
Click : constant Action_Id := To_Action_Id( "button.click" );
procedure Delete( this : in out A_Button_Action );
pragma Postcondition( this = null );
type Simple_Button_Listener is new Simple_Action_Listener and Button_Listener with
record
handler : A_Button_Handler := null;
end record;
type A_Simple_Button_Listener is access all Simple_Button_Listener'Class;
function Create_Listener( handler : not null A_Button_Handler ) return A_Button_Listener;
pragma Postcondition( Create_Listener'Result /= null );
procedure Handle_Action( this : access Simple_Button_Listener;
action : A_Button_Action );
type Button is abstract new Widget with
record
text : Unbounded_String;
icon : Integer := 0;
on : Boolean := False;
align : Align_Type := Align_Center;
contrastText : Boolean := False;
end record;
procedure Construct( this : access Button;
view : not null access Game_Views.Game_View'Class;
id : String;
text : String;
icon : String );
pragma Precondition( id'Length > 0 );
procedure Dispatch_Action( this : access Button; id : Action_Id );
procedure Draw_Content( this : access Button; dc : Drawing_Context );
function Get_Min_Height( this : access Button ) return Natural;
function Get_Min_Width( this : access Button ) return Natural;
#if WINDOWS then
procedure Set_Color( this : access Button;
purpose : Color_Purpose;
color : Color_Type );
#end if;
function To_String( this : access Button ) return String;
end Widgets.Buttons;