package Widgets.Containers.Panels.Dialogs is
-- A Dialog is an abstract container widget for modal dialogs. All of the
-- dialog's controls are added as children and a title can be set using the
-- inherited operations from Panel. The Dialog class extends the Panel's
-- functionality by adding Hide and Show procedures to hide and show the
-- dialog as a modal widget in the window. If the dialog has a title bar, it
-- can also be dragged with the mouse. Events to pause and resume gameplay
-- will be queued when the dialog is shown and hidden, respectively, because
-- it is modal.
type Dialog is abstract new Panel and
Key_Listener and
Visibility_Listener with private;
type A_Dialog is access all Dialog'Class;
-- Hides the dialog. It remains a child of the window.
procedure Hide( this : access Dialog );
-- Shows the modal dialog in the window. The dialog must have been added
-- to the window before this is called.
procedure Show( this : access Dialog );
private
type Dialog is abstract new Panel and
Key_Listener and
Visibility_Listener with
record
dragStartX,
dragStartY : Integer := -1;
end record;
procedure Construct( this : access Dialog;
view : not null access Game_Views.Game_View'Class;
id : String;
title : String;
icon : String );
pragma Precondition( id'Length > 0 );
procedure Delete( this : in out Dialog );
-- Traps key actions, preventing them from being propagated to the dialog's
-- window.
procedure Handle_Action( this : access Dialog;
action : A_Key_Action;
handled : out Boolean );
-- Handles visibility actions by dispatching to the Handle_Show and
-- Handle_Hide procedures implemented by a concrete subclass.
procedure Handle_Action( this : access Dialog;
action : A_Visibility_Action );
-- This is called when the dialog is hidden or closed. Override this
-- procedure to implement its behavior.
procedure Handle_Hide( this : access Dialog );
-- Moves the dialog around its parent if its being dragged.
procedure Handle_Mouse_Move( this : access Dialog;
evt : not null A_Mouse_Event );
-- Detects if the dialog should be dragged when the left mouse is pressed.
procedure Handle_Mouse_Press( this : access Dialog;
evt : not null A_Mouse_Button_Event );
-- This is called when the dialog is shown or opened. Override this
-- procedure to implement its behavior.
procedure Handle_Show( this : access Dialog );
end Widgets.Containers.Panels.Dialogs;