with Scaling; use Scaling;
with Widgets.Menubars; use Widgets.Menubars;
limited with Game_Views;
private with Allegro.Keyboard;
private with Mouse;
package Widgets.Containers.Windows is
type Window is new Container with private;
type A_Window is access all Window'Class;
function Create_Window( view : access Game_Views.Game_View'Class;
id : String;
width,
height : Natural;
scale : Positive := 1;
filter : Filter_Type := Filter_Nearest
) return A_Window;
pragma Precondition( id'Length > 0 );
pragma Postcondition( Create_Window'Result /= null );
procedure Dispatch_Click( this : access Window;
evt : not null A_Mouse_Button_Event );
function Dispatch_Key_Held( this : access Window;
evt : not null A_Key_Event ) return Boolean;
function Dispatch_Key_Press( this : access Window;
evt : not null A_Key_Event ) return Boolean;
function Dispatch_Key_Release( this : access Window;
evt : not null A_Key_Event ) return Boolean;
procedure Dispatch_Mouse_Held( this : access Window;
evt : not null A_Mouse_Button_Event );
procedure Dispatch_Mouse_Move( this : access Window;
evt : not null A_Mouse_Event );
procedure Dispatch_Mouse_Press( this : access Window;
evt : not null A_Mouse_Button_Event );
procedure Dispatch_Mouse_Release( this : access Window;
evt : not null A_Mouse_Button_Event );
function Dispatch_Mouse_Scroll( this : access Window;
evt : not null A_Mouse_Scroll_Event ) return Boolean;
procedure Draw( this : access Window; bmp : not null A_Bitmap );
function Get_Scale( this : not null access Window'Class ) return Positive;
procedure Give_Focus( this : access Window; target : not null A_Widget );
procedure Pop_Popup( this : access Window );
procedure Pop_Popup( this : access Window; popup : not null A_Widget );
procedure Push_Popup( this : access Window; popup : not null A_Widget );
procedure Set_Offset( this : access Window; x, y : Integer );
procedure Set_Menubar( this : access Window; menu : in out A_Menubar );
pragma Postcondition( menu = null );
procedure Set_Modal( this : access Window; modal : A_Widget );
procedure Set_Title( this : access Window; title : String );
procedure Delete( this : in out A_Window );
pragma Postcondition( this = null );
private
use Allegro.Keyboard;
use Mouse;
type Mouse_Widget_Array is array (Mouse_Button) of A_Widget;
type Key_Widget_Array is array (1..KEY_MAX) of A_Widget;
type Window is new Container with
record
scale : Positive := 1;
filter : Filter_Type := Filter_Nearest;
scalebmp : A_Bitmap := null;
menu : A_Menubar := null;
mouseOver : A_Widget := null;
mousePressedOn : Mouse_Widget_Array;
mouseClickedOn : Mouse_Widget_Array;
focus : A_Widget := null;
modal : A_Widget := null;
popups : Widget_Lists.List;
keyPressSentTo : Key_Widget_Array := Key_Widget_Array'(others=>null);
end record;
procedure Construct( this : access Window;
view : access Game_Views.Game_View'Class;
id : String;
width,
height : Natural;
scale : Positive;
filter : Filter_Type );
pragma Precondition( id'Length > 0 );
procedure Delete( this : in out Window );
procedure Dispatch_Mouse_Release( this : access Window;
x, y : Integer;
btn : Mouse_Button );
procedure Draw( this : access Window; bmp : not null A_Bitmap; x, y : Integer );
procedure Draw_Content( this : access Window; dc : Drawing_Context );
procedure Find_Widget( this : access Window;
sx, sy : Integer;
wx, wy : out Integer;
found : out A_Widget );
function Get_Window( this : access Window ) return access Window'Class;
procedure Handle_Descendant_Hidden( this : access Window;
descendant : not null A_Widget );
procedure Handle_Descendant_Unhidden( this : access Window;
descendant : not null A_Widget );
function Handle_Key_Press( this : access Window;
evt : not null A_Key_Event ) return Boolean;
procedure Pack( this : access Window );
procedure Translate_To_Content( this : access Window;
sx, sy : Integer;
cx, cy : out Integer );
procedure Translate_To_Window( this : access Window;
cx, cy : Integer;
wx, wy : out Integer );
end Widgets.Containers.Windows;