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

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.ToolboxColourMenu is

   -- Flags
   Colourmenu_Generate_About_To_Be_Shown   : constant := 16#1#;
   Colourmenu_Generate_Dialogue_Completed  : constant := 16#2#;
   Colourmenu_Generate_Has_Been_Hidden     : constant := 16#2#;
   Colourmenu_None_Entry                   : constant := 16#4#;
   Colourmenu_Transparent                  : constant := 16#10#;
   Colourmenu_None                         : constant := 16#FFFFFFFF#;

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

   type Colour_Data is array(integer range <>) of integer;

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

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

   --
   -- Event is raised just before the Colour Menu is displayed.
   --
   type Toolbox_ColourMenu_AboutToBeShown is
   record
   Header    : Toolbox_Event_Header;
   Show_Type : Integer;
   Position  : OS_Coordinate;
   end record;
   pragma Convention (C, Toolbox_ColourMenu_AboutToBeShown);

   type Toolbox_ColourMenu_AboutToBeShown_Pointer is access Toolbox_ColourMenu_AboutToBeShown;

   type ATEL_Toolbox_ColourMenu_AboutToBeShown is abstract
        new Toolbox_EventListener(Toolbox_Event_ColourMenu_AboutToBeShown,-1,-1) with
   record
   Event : Toolbox_ColourMenu_AboutToBeShown_Pointer;
   end record;

   --
   -- Event is raised when the Colour Menu is closed.
   --
   type Toolbox_ColourMenu_HasBeenHidden is
   record
   Header  : Toolbox_Event_Header;
   end record;
   pragma Convention (C, Toolbox_ColourMenu_HasBeenHidden);

   type Toolbox_ColourMenu_HasBeenHidden_Pointer is access Toolbox_ColourMenu_HasBeenHidden;

   type ATEL_Toolbox_ColourMenu_HasBeenHidden is abstract
        new Toolbox_EventListener(Toolbox_Event_ColourMenu_HasBeenHidden,-1,-1) with
   record
   Event : Toolbox_ColourMenu_HasBeenHidden_Pointer;
   end record;

   --
   -- Event is raised when the user selects a colour from the menu.
   --
   type Toolbox_ColourMenu_Selection is
   record
   Header  : Toolbox_Event_Header;
   Colour  : Toolbox_Colour;
   end record;
   pragma Convention (C, Toolbox_ColourMenu_Selection);

   type Toolbox_ColourMenu_Selection_Pointer is access Toolbox_ColourMenu_Selection;

   type ATEL_Toolbox_ColourMenu_Selection is abstract
        new Toolbox_EventListener(Toolbox_Event_ColourMenu_Selection,-1,-1) with
        
   record
   Event : Toolbox_ColourMenu_Selection_Pointer;
   end record;
   
   --
   -- Returns the currently selected colour in the Colour Menu.
   --
   function Get_Colour (ColourMenu : Object_ID;
                        Flags      : in System.Unsigned_Types.Unsigned := 0) return Toolbox_Colour;

   --
   -- Returns the title of the Colour Menu.
   --
   function Get_Title (ColourMenu : Object_ID;
                      Flags       : in System.Unsigned_Types.Unsigned := 0) return string;

   --
   -- Returns whether there is a 'None' entry in the Colour Menu.
   --
   function Get_None_Available (ColourMenu : Object_ID;
                                 Flags     : in System.Unsigned_Types.Unsigned := 0) return boolean;

   --
   -- Sets the currently selected colour in the Colour Menu.
   --
   procedure Set_Colour (ColourMenu : in Object_ID;
                         Colour     : in Toolbox_Colour;
                         Flags      : in System.Unsigned_Types.Unsigned := 0);

   --
   -- Unsets any selection made. (No tick)
   --
   procedure UnSet_Colour (ColourMenu : in Object_ID;
                           Flags      : in System.Unsigned_Types.Unsigned := 0);

   --
   -- Sets whether there is a 'None' entry in the Colour Menu.
   --
   procedure Set_None_Available (ColourMenu     : in Object_ID;
                                 None_Available : in boolean;
                                 Flags          : in System.Unsigned_Types.Unsigned := 0);

   --
   -- Sets the title in the Colour Menu.
   --
   procedure Set_Title (FontMenu  : in Object_ID;
                        Title     : in string;
                        Flags     : in System.Unsigned_Types.Unsigned := 0);

end RASCAL.ToolboxColourMenu;
