--
-- Copyright (c) 2012 Kevin Wellwood
-- All rights reserved.
--
-- This source code is distributed under the Modified BSD License. For terms and
-- conditions, see license.txt.
--
with Allegro.Displays; use Allegro.Displays;
package Applications.Gui is
-- An abstract application class with a single window for graphics and
-- mouse/keyboard facilities.
type Gui_Application is abstract new Application with private;
type A_Gui_Application is access all Gui_Application'Class;
-- Returns the Allegro display backing the application's window.
function Get_Display( this : not null access Gui_Application'Class ) return A_Allegro_Display;
-- Returns True if the mouse is enabled for the application, allowing it to
-- be drawn in fullscreen mode and for mouse events to be generated.
function Is_Mouse_Enabled( this : not null access Gui_Application'Class ) return Boolean;
private
type Gui_Application is abstract new Application with
record
-- these fields don't change after construction --
defaultWidth,
defaultHeight : Natural := 0;
defaultScale : Natural := 0;
defaultWindowed : Boolean := True;
-- the following fields are protected by .lock
display : A_Allegro_Display; -- the allegro display window
interactive : Boolean := False; -- application accepts user input
useMouse : Boolean := False; -- application uses the mouse
end record;
-- Constructs the application object. The default width, height, scale and
-- windowed mode arguments are used to initialize the application's display.
-- They may be overridden by preferences in the configuration file.
procedure Construct( this : access Gui_Application;
company : String;
name : String;
userDir : String;
defaultWidth,
defaultHeight : Natural;
defaultScale : Natural;
defaultWindowed : Boolean );
-- Finalizes the application and releases all resources. Do not call this if
-- the application didn't successfully initialize. This should be called
-- last by an overriding implementation.
procedure Finalize( this : access Gui_Application );
-- Initializes the application, setting up graphics and hardware. Returns
-- True on success. If initialization fails, Finalize should not be called.
-- No exceptions will be raised. This should be called first by an
-- overriding implementation.
function Initialize( this : access Gui_Application ) return Boolean;
-- Displays a low-level error message to the user with a native message box.
procedure Show_Error( this : access Gui_Application; text : String );
end Applications.Gui;