--------------------------------------------------------------------------------
--                                                                            --
-- 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 Toolbox ColourDbox related types and methods.
-- $Author$
-- $Date$
-- $Revision$

with Interfaces.C;            use Interfaces.C;
with System.Unsigned_Types;   use System.Unsigned_Types;

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

package RASCAL.ToolboxColourDbox is

   -- Flags
   ColourDBox_Dialogue_Completed_Colour_Choice : constant := 16#1#;
   Colourdbox_Generate_About_To_Be_Shown       : constant := 16#1#;
   Colourdbox_Generate_Dialogue_Completed      : constant := 16#2#;
   Colourdbox_Include_None_Button              : constant := 16#4#;
   Colourdbox_Select_None_button               : constant := 16#8#;
   Colourdbox_Colour_Transparent               : constant := 16#1#;

   type ColourDBoxTemplate is
   record
   Flags     : System.Unsigned_Types.Unsigned;
   Title     : Address;
   Max_Title : Integer;
   Colour    : System.Unsigned_Types.Unsigned;
   end record;
   pragma Convention (C, ColourDBoxTemplate);

   type Colour_Data is array(System.Unsigned_Types.Unsigned range <>)
                                      of System.Unsigned_Types.Unsigned;

   type Colour_Type(Nr : System.Unsigned_Types.Unsigned) is
   record
   Colour   : System.Unsigned_Types.Unsigned;
   Remainder: System.Unsigned_Types.Unsigned := 0;
   Model    : System.Unsigned_Types.Unsigned;
   Data     : Colour_Data(1..Nr);
   end record;

   type Colour_Model_Type(Nr : System.Unsigned_Types.Unsigned) is
   record
   Remainder : System.Unsigned_Types.Unsigned := 0;
   Model     : System.Unsigned_Types.Unsigned;
   Data      : Colour_Data(1..Nr);
   end record;

   --
   -- Event is raised just before the Colour Dialogue Box is displayed.
   --
   --Event type is not fully specified as it contains a union.
   --
   type Toolbox_ColourDbox_AboutToBeShown is
   record
   Header  : Toolbox_Event_Header;
   end record;
   pragma Convention (C, Toolbox_ColourDbox_AboutToBeShown);

   type Toolbox_ColourDbox_AboutToBeShown_Pointer is access Toolbox_ColourDbox_AboutToBeShown;

   type ATEL_Toolbox_ColourDbox_AboutToBeShown is abstract
        new Toolbox_EventListener(Toolbox_Event_ColourDbox_AboutToBeShown,-1,-1) with

   record
   Event : Toolbox_ColourDbox_AboutToBeShown_Pointer;
   end record;

   --
   -- Event is raised when the user clicks OK in the dialogue box.
   --
   type Toolbox_ColourDbox_ColourSelected is
   record
   Header        : Toolbox_Event_Header;
   Colour_Block  : System.Unsigned_Types.Unsigned;
   end record;
   pragma Convention (C, Toolbox_ColourDbox_ColourSelected);

   type Toolbox_ColourDbox_ColourSelected_Pointer is access Toolbox_ColourDbox_ColourSelected;

   type ATEL_Toolbox_ColourDbox_ColourSelected is abstract
        new Toolbox_EventListener(Toolbox_Event_ColourDbox_ColourSelected,-1,-1) with

   record
   Event : Toolbox_ColourDbox_ColourSelected_Pointer;
   end record;

   --
   -- Event is raised after the Colour Dialogue Box is hidden.
   --
   type Toolbox_ColourDbox_DialogueCompleted is
   record
   Header  : Toolbox_Event_Header;
   end record;
   pragma Convention (C, Toolbox_ColourDbox_DialogueCompleted);

   type Toolbox_ColourDbox_DialogueCompleted_Pointer is access Toolbox_ColourDbox_DialogueCompleted;

   type ATEL_Toolbox_ColourDbox_DialogueCompleted is abstract
        new Toolbox_EventListener(Toolbox_Event_ColourDbox_DialogueCompleted,-1,-1) with

   record
   Event : Toolbox_ColourDbox_DialogueCompleted_Pointer;
   end record;

   --
   -- Returns the colour displayed in the Colour Dialogue.
   --
   function Get_Colour (ColourDbox : in Object_ID;
                        Flags      : in System.Unsigned_Types.Unsigned := 0) return Colour_Type;

   --
   -- Returnt the colour model currently used in the Colour Dialogue.
   --
   function Get_ColourModel (ColourDbox : in Object_ID;
                             Flags      : in System.Unsigned_Types.Unsigned := 0) return Colour_Model_Type;

   --
   -- Returns the handle of the dialogue box used by the Colour Picker module.
   --
   function Get_DialogueHandle (ColourDbox : in Object_ID;
                                Flags      : in System.Unsigned_Types.Unsigned := 0) return Wimp_Handle_Type;

   --
   -- Is the 'None' option available in the Colour Dialogue ?
   --
   function Get_NoneAvailable (ColourDbox : in Object_ID;
                               Flags      : in System.Unsigned_Types.Unsigned := 0) return boolean;

   --
   -- Returns the Wimp window handle of the window used by the Colour Picker module.
   --
   function Get_WimpHandle (ColourDbox : in Object_ID;
                            Flags      : in System.Unsigned_Types.Unsigned := 0) return Wimp_Handle_Type;

   --
   -- Sets the colour displayed in the Colour Dialogue.
   --
   procedure Set_Colour (ColourDbox : in Object_ID;
                         Colour     : in Colour_Type;
                         Flags      : in System.Unsigned_Types.Unsigned := 0);

   --
   -- Sets the colour model currently used in the Colour Dialogue.
   --
   procedure Set_ColourModel (ColourDbox : in Object_ID;
                              Model      : in Colour_Model_Type;
                              Flags      : in System.Unsigned_Types.Unsigned := 0);

   --
   -- Sets whether a 'None' option is available in the Colour Dialogue.
   --
   procedure Set_NoneAvailable (ColourDbox     : in Object_ID;
                                None_Available : in boolean;
                                Flags          : in System.Unsigned_Types.Unsigned := 0);

end RASCAL.ToolboxColourDbox;
