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. package Applications.Gui is 
  10.  
  11.     -- An abstract application class with a single window for graphics and 
  12.     -- mouse/keyboard facilities. 
  13.     type Gui_Application is abstract new Application with private; 
  14.     type A_Gui_Application is access all Gui_Application'Class; 
  15.  
  16.     -- Returns the title text at the top of the application's window. 
  17.     function Get_Window_Title( this : not null access Gui_Application'Class ) return String; 
  18.  
  19. private 
  20.  
  21.     type Gui_Application is abstract new Application with 
  22.         record 
  23.             -- the following fields are protected by .lock 
  24.             winTitle    : Unbounded_String;    -- app window title 
  25.             interactive : Boolean := False;    -- application accepts user input 
  26.             use_mouse   : Boolean := False;    -- application uses the mouse 
  27.             xres, yres  : Integer := 0;        -- window resolution 
  28.             scale       : Integer := 1;        -- window scaling factor 
  29.         end record; 
  30.  
  31.     -- Constructs the application object. Constructs the application using 
  32.     -- 'name' as the default window title. To specify the window title, call 
  33.     -- Construct(4) instead. This should be called first by a subclass 
  34.     -- constructor. 
  35.     procedure Construct( this      : access Gui_Application; 
  36.                          company   : String; 
  37.                          name      : String; 
  38.                          configDir : String ); 
  39.  
  40.     -- Constructs the application object. 'winTitle' is the title at the top of 
  41.     -- the application window, if it's running in windowed mode. This should be 
  42.     -- called first by a subclass constructor. 
  43.     procedure Construct( this      : access Gui_Application; 
  44.                          company   : String; 
  45.                          name      : String; 
  46.                          configDir : String; 
  47.                          winTitle  : String ); 
  48.  
  49.     -- Closes the application and releases all resources. Do not call this if 
  50.     -- the application didn't successfully initialize. This should be called 
  51.     -- last by an overriding implementation. 
  52.     procedure Close( this : access Gui_Application ); 
  53.  
  54.     -- Initializes the application, setting up graphics and hardware. The 
  55.     -- application will open in 640x400 windowed mode by default. This setting 
  56.     -- can be overridden by the application's configuration. To specify the 
  57.     -- default window parameters, call Init(4) instead. Returns True on success. 
  58.     -- If initialization fails, Close will be called automatically to clean up. 
  59.     -- No exceptions will be raised. This should be called first by an 
  60.     -- overriding implementation. 
  61.     function Init( this : access Gui_Application ) return Boolean; 
  62.  
  63.     -- Initializes the application, setting up graphics and hardware. Returns 
  64.     -- True on success. If initialization fails, Close will be called 
  65.     -- automatically to clean up. No exceptions will be raised. This should be 
  66.     -- called first by an overriding implementation. 
  67.     function Init( this         : access Gui_Application; 
  68.                    app_xres, 
  69.                    app_yres     : Natural; 
  70.                    app_scale    : Positive; 
  71.                    app_windowed : Boolean ) return Boolean; 
  72.  
  73. end Applications.Gui;