1. package Widgets.Containers.Panels.Dialogs is 
  2.  
  3.     -- A Dialog is an abstract container widget for modal dialogs. All of the 
  4.     -- dialog's controls are added as children and a title can be set using the 
  5.     -- inherited operations from Panel. The Dialog class extends the Panel's 
  6.     -- functionality by adding Hide and Show procedures to hide and show the 
  7.     -- dialog as a modal widget in the window. If the dialog has a title bar, it 
  8.     -- can also be dragged with the mouse. Events to pause and resume gameplay 
  9.     -- will be queued when the dialog is shown and hidden, respectively, because 
  10.     -- it is modal. 
  11.     type Dialog is abstract new Panel and 
  12.                                 Key_Listener and 
  13.                                 Visibility_Listener with private; 
  14.     type A_Dialog is access all Dialog'Class; 
  15.  
  16.     -- Hides the dialog. It remains a child of the window. 
  17.     procedure Hide( this : access Dialog ); 
  18.  
  19.     -- Shows the modal dialog in the window. The dialog must have been added 
  20.     -- to the window before this is called. 
  21.     procedure Show( this : access Dialog ); 
  22.  
  23. private 
  24.  
  25.     type Dialog is abstract new Panel and 
  26.                                 Key_Listener and 
  27.                                 Visibility_Listener with 
  28.         record 
  29.             dragStartX, 
  30.             dragStartY : Integer := -1; 
  31.         end record; 
  32.  
  33.     procedure Construct( this  : access Dialog; 
  34.                          view  : not null access Game_Views.Game_View'Class; 
  35.                          id    : String; 
  36.                          title : String; 
  37.                          icon  : String ); 
  38.     pragma Precondition( id'Length > 0 ); 
  39.  
  40.     procedure Delete( this : in out Dialog ); 
  41.  
  42.     -- Traps key actions, preventing them from being propagated to the dialog's 
  43.     -- window. 
  44.     procedure Handle_Action( this    : access Dialog; 
  45.                              action  : A_Key_Action; 
  46.                              handled : out Boolean ); 
  47.  
  48.     -- Handles visibility actions by dispatching to the Handle_Show and 
  49.     -- Handle_Hide procedures implemented by a concrete subclass. 
  50.     procedure Handle_Action( this   : access Dialog; 
  51.                              action : A_Visibility_Action ); 
  52.  
  53.     -- This is called when the dialog is hidden or closed. Override this 
  54.     -- procedure to implement its behavior. 
  55.     procedure Handle_Hide( this : access Dialog ); 
  56.  
  57.     -- Moves the dialog around its parent if its being dragged. 
  58.     procedure Handle_Mouse_Move( this : access Dialog; 
  59.                                  evt  : not null A_Mouse_Event ); 
  60.  
  61.     -- Detects if the dialog should be dragged when the left mouse is pressed. 
  62.     procedure Handle_Mouse_Press( this : access Dialog; 
  63.                                   evt  : not null A_Mouse_Button_Event ); 
  64.  
  65.     -- This is called when the dialog is shown or opened. Override this 
  66.     -- procedure to implement its behavior. 
  67.     procedure Handle_Show( this : access Dialog ); 
  68.  
  69. end Widgets.Containers.Panels.Dialogs;