--------------------------------------------------------------------------------
--                                                                            --
-- Copyright (C) 2004, RISC OS Ada Library (RASCAL) developers.               --
--                                                                            --
-- This library is free software; you can redistribute it and/or              --
-- modify it under the terms of the GNU Lesser General Public                 --
-- License as published by the Free Software Foundation; either               --
-- version 2.1 of the License, or (at your option) any later version.         --
--                                                                            --
-- This library is distributed in the hope that it will be useful,            --
-- but WITHOUT ANY WARRANTY; without even the implied warranty of             --
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU           --
-- Lesser General Public License for more details.                            --
--                                                                            --
-- You should have received a copy of the GNU Lesser General Public           --
-- License along with this library; if not, write to the Free Software        --
-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA    --
--                                                                            --
--------------------------------------------------------------------------------

-- @brief ToolboxFontDbox related types and methods.
-- $Author$
-- $Date$
-- $Revision$

with RASCAL.Toolbox;          use RASCAL.Toolbox;
with RASCAL.OS;               use RASCAL.OS;
with RASCAL.Utility;          use RASCAL.Utility;

with System.Unsigned_Types;   use System.Unsigned_Types;

package RASCAL.ToolboxFontDbox is

   -- Flags
   FontDBox_Generate_About_To_Be_Shown   : constant := 16#1#;
   FontDBox_Generate_Dialogue_Completed  : constant := 16#2#;
   FontDBox_Include_System_Font          : constant := 16#4#;

   FontDBox_Set_Height                   : constant := 16#1#;
   FontDBox_Set_Aspect                   : constant := 16#2#;

   FontDBox_Apply                        : constant := 16#82A0000#;
   FontDBox_Cancel                       : constant := 16#82A0001#;
   FontDBox_Try                          : constant := 16#82A0002#;
   FontDBox_Try_String                   : constant := 16#82A0003#;
   FontDBox_Aspect_Ratio                 : constant := 16#82A0004#;
   FontDBox_Height                       : constant := 16#82A0005#;
   FontDBox_Standard_Size0               : constant := 16#82A0006#;
   FontDBox_Standard_Size1               : constant := 16#82A0007#;
   FontDBox_Standard_Size2               : constant := 16#82A0008#;
   FontDBox_Standard_Size3               : constant := 16#82A0009#;
   FontDBox_Standard_Size4               : constant := 16#82A000A#;
   FontDBox_Standard_Size5               : constant := 16#82A000B#;
   FontDBox_Standard_Size6               : constant := 16#82A000C#;
   FontDBox_Standard_Size7               : constant := 16#82A000D#;
   FontDBox_Standard_Size8               : constant := 16#82A000E#;
   FontDBox_Standard_Size9               : constant := 16#82A000F#;
   FontDBox_Style                        : constant := 16#82A0010#;
   FontDBox_Weight                       : constant := 16#82A0011#;
   FontDBox_Font                         : constant := 16#82A0012#;


   type FonDBoxTemplate is
   record
   Flags          : System.Unsigned_Types.Unsigned;
   Title          : Address;
   Max_Title      : Integer;
   Initial_Font   : Address;
   Initial_Height : Integer;
   Initial_Aspect : Integer;
   Try_String     : Address;
   Window         : Address;
   end record;
   pragma Convention (C, FonDBoxTemplate);

   --
   -- Event is raised just before the Font Dialgue window is displayed.
   --Type lacks union.
   --
   type Toolbox_FontDbox_AboutToBeShown is
   record
   Header     : Toolbox_Event_Header;
   Show_Type  : Integer;
   Info       : Window_Position_Type(Full_Spec);
   end record;
   pragma Convention (C, Toolbox_FontDbox_AboutToBeShown);

   type Toolbox_FontDbox_AboutToBeShown_Pointer is access Toolbox_FontDbox_AboutToBeShown;

   type ATEL_Toolbox_FontDbox_AboutToBeShown is abstract
        new Toolbox_EventListener(Toolbox_Event_FontDbox_AboutToBeShown,-1,-1) with

   record
   Event : Toolbox_FontDbox_AboutToBeShown_Pointer;
   end record;

   --
   -- Event is raised immediately after the Font dialogue window is hidden.
   --
   type Toolbox_FontDbox_ApplyFont is
   record
   Header  : Toolbox_Event_Header;
   Height  : System.Unsigned_Types.Unsigned;
   Aspect  : System.Unsigned_Types.Unsigned;
   Font    : Char_Array(1..208);
   end record;
   pragma Convention (C, Toolbox_FontDbox_ApplyFont);

   type Toolbox_FontDbox_ApplyFont_Pointer is access Toolbox_FontDbox_ApplyFont;

   type ATEL_Toolbox_FontDbox_ApplyFont is abstract
        new Toolbox_EventListener(Toolbox_Event_FontDbox_ApplyFont,-1,-1) with
        
   record
   Event : Toolbox_FontDbox_ApplyFont_Pointer;
   end record;

   --
   -- Event is raised immediately after the Font Dialogue window is hidden.
   --
   type Toolbox_FontDbox_DialogueCompleted is
   record
   Header  : Toolbox_Event_Header;
   end record;
   pragma Convention (C, Toolbox_FontDbox_DialogueCompleted);

   type Toolbox_FontDbox_DialogueCompleted_Pointer is access Toolbox_FontDbox_DialogueCompleted;

   type ATEL_Toolbox_FontDbox_DialogueCompleted is abstract
        new Toolbox_EventListener(Toolbox_Event_FontDbox_DialogueCompleted,-1,-1) with
        
   record
   Event : Toolbox_FontDbox_DialogueCompleted_Pointer;
   end record;

   --
   -- Returns the currently selected font for the Font dialogue.
   --
   function Get_Font (FontDbox : in Object_ID;
                      Flags    : in System.Unsigned_Types.Unsigned := 0) return string;

   --
   -- Sets the currently selected font for the Font dialogue.
   --
   procedure Set_Font (FontDbox : in Object_ID;
                       Font     : in string;
                       Flags    : in System.Unsigned_Types.Unsigned := 0);

   --
   -- Returns the size for the currently selected font for the Font dialogue.
   --
   procedure Get_Size (FontDbox : in Object_ID;
                       Height   : out integer;
                       Aspect   : out integer;
                       Flags    : in System.Unsigned_Types.Unsigned := 0);

   --
   -- Sets the size for the currently selected font for the Font dialogue.
   --
   procedure Set_Size (FontDbox : in Object_ID;
                       Height   : in integer;
                       Aspect   : in integer;
                       Flags    : in System.Unsigned_Types.Unsigned := 0);

   --
   -- Returns the title for the Font dialogue.
   --
   function Get_Title (FontDbox : in Object_ID;
                       Flags    : in System.Unsigned_Types.Unsigned := 0) return string;

   --
   -- Sets the title for the Font dialogue.
   --
   procedure Set_Title (FontDbox : in Object_ID;
                        Title    : in string;
                        Flags    : in System.Unsigned_Types.Unsigned := 0);

   --
   -- Returns the string for the 'Try' writable field in the Font dialogue.
   --
   function Get_TryString (FontDbox : in Object_ID;
                           Flags    : in System.Unsigned_Types.Unsigned := 0) return string;

   --
   -- Sets the string for the 'Try' writable field in the Font dialogue.
   --
   procedure Set_TryString (FontDbox : in Object_ID;
                            TryString: in string;
                            Flags    : in System.Unsigned_Types.Unsigned := 0);

   --
   -- Returns the id of the underlying Wimp window for the Font dialogue.
   --
   function Get_Window_ID (FontDbox : in Object_ID;
                           Flags    : in System.Unsigned_Types.Unsigned := 0) return Object_ID;

end RASCAL.ToolboxFontDbox;
