1. -- 
  2. -- Copyright (c) 2012 Kevin Wellwood 
  3. -- All rights reserved. 
  4. -- 
  5. -- This source code is distributed under the Modified BSD License. For terms and 
  6. -- conditions, see license.txt. 
  7. -- 
  8.  
  9. with Allegro.Displays;                  use Allegro.Displays; 
  10.  
  11. package Applications.Gui is 
  12.  
  13.     -- An abstract application class with a single window for graphics and 
  14.     -- mouse/keyboard facilities. 
  15.     type Gui_Application is abstract new Application with private; 
  16.     type A_Gui_Application is access all Gui_Application'Class; 
  17.  
  18.     -- Returns the Allegro display backing the application's window. 
  19.     function Get_Display( this : not null access Gui_Application'Class ) return A_Allegro_Display; 
  20.  
  21.     -- Returns True if the mouse is enabled for the application, allowing it to 
  22.     -- be drawn in fullscreen mode and for mouse events to be generated. 
  23.     function Is_Mouse_Enabled( this : not null access Gui_Application'Class ) return Boolean; 
  24.  
  25. private 
  26.  
  27.     type Gui_Application is abstract new Application with 
  28.         record 
  29.             -- these fields don't change after construction -- 
  30.             defaultWidth, 
  31.             defaultHeight   : Natural := 0; 
  32.             defaultScale    : Natural := 0; 
  33.             defaultWindowed : Boolean := True; 
  34.  
  35.             -- the following fields are protected by .lock 
  36.             display         : A_Allegro_Display;   -- the allegro display window 
  37.             interactive     : Boolean := False;    -- application accepts user input 
  38.             useMouse        : Boolean := False;    -- application uses the mouse 
  39.         end record; 
  40.  
  41.     -- Constructs the application object. The default width, height, scale and 
  42.     -- windowed mode arguments are used to initialize the application's display. 
  43.     -- They may be overridden by preferences in the configuration file. 
  44.     procedure Construct( this            : access Gui_Application; 
  45.                          company         : String; 
  46.                          name            : String; 
  47.                          userDir         : String; 
  48.                          defaultWidth, 
  49.                          defaultHeight   : Natural; 
  50.                          defaultScale    : Natural; 
  51.                          defaultWindowed : Boolean ); 
  52.  
  53.     -- Finalizes the application and releases all resources. Do not call this if 
  54.     -- the application didn't successfully initialize. This should be called 
  55.     -- last by an overriding implementation. 
  56.     procedure Finalize( this : access Gui_Application ); 
  57.  
  58.     -- Initializes the application, setting up graphics and hardware. Returns 
  59.     -- True on success. If initialization fails, Finalize should not be called. 
  60.     -- No exceptions will be raised. This should be called first by an 
  61.     -- overriding implementation. 
  62.     function Initialize( this : access Gui_Application ) return Boolean; 
  63.  
  64.     -- Displays a low-level error message to the user with a native message box. 
  65.     procedure Show_Error( this : access Gui_Application; text : String ); 
  66.  
  67. end Applications.Gui;