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

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

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

package RASCAL.ToolboxIconbar is

   type Iconbar_Button_Type is (Select_Button,Adjust_Button);

   -- Flags
   iconbar_Generate_Select_About_To_Be_Shown : constant := 16#1#;
   iconbar_Generate_Adjust_About_To_Be_Shown : constant := 16#2#;
   iconbar_Select_Is_Menu                    : constant := 16#4#;
   iconbar_Adjust_Is_Menu                    : constant := 16#8#;
   iconbar_Has_Text                          : constant := 16#10#;
   iconbar_Generate_Select_Clicked           : constant := 16#20#;
   iconbar_Generate_Adjust_Clicked           : constant := 16#40#;
   iconbar_Select                            : constant := 16#1#;
   iconbar_Adjust                            : constant := 16#2#;
   iconbar_Clicked_Adjust                    : constant := 16#1#;
   iconbar_Clicked_Select                    : constant := 16#4#;

   type IconbarTemplate is
   record
   Flags        : System.Unsigned_Types.Unsigned;
   Position     : Integer;
   Priority     : Integer;
   Sprite       : Address;
   Max_Sprite   : Integer;
   Text         : Address;
   Max_Text     : Integer;
   Menu         : Address;
   Select_Event : Integer;
   Adjust_Event : Integer;
   Select_Show  : Address;
   Adjust_Show  : Address;
   Help_Message : Address;
   Max_Help     : Integer;
   end record;
   pragma Convention (C, IconbarTemplate);

   --
   -- Event is raised before {fcode}Toolbox_ShowObject{f} is executed on an ADJUST click on the iconbar icon.
   --
   type Toolbox_Iconbar_AdjustAboutToBeShown is
   record
   Header  : Toolbox_Event_Header;
   end record;
   pragma Convention (C, Toolbox_Iconbar_AdjustAboutToBeShown);

   type Toolbox_Iconbar_AdjustAboutToBeShown_Pointer is access Toolbox_Iconbar_AdjustAboutToBeShown;

   type ATEL_Toolbox_Iconbar_AdjustAboutToBeShown is abstract
        new Toolbox_EventListener(Toolbox_Event_Iconbar_AdjustAboutToBeShown,-1,-1) with

   record
   Event : Toolbox_Iconbar_AdjustAboutToBeShown_Pointer;
   end record;

   --
   -- Event is raised when a click is performed on the iconbar icon.
   --
   type Toolbox_Iconbar_Clicked is
   record
   Header  : Toolbox_Event_Header;
   end record;
   pragma Convention (C, Toolbox_Iconbar_Clicked);

   type Toolbox_Iconbar_Clicked_Pointer is access Toolbox_Iconbar_Clicked;

   type ATEL_Toolbox_Iconbar_Clicked is abstract
        new Toolbox_EventListener(Toolbox_Event_Iconbar_Clicked,-1,-1) with

   record
   Event : Toolbox_Iconbar_Clicked_Pointer;
   end record;

   --
   -- Event is raised before {fcode}Toolbox_ShowObject{f} is executed on a SELECT click on the iconbar icon.
   --
   type Toolbox_Iconbar_SelectAboutToBeShown is
   record
   Header  : Toolbox_Event_Header;
   end record;
   pragma Convention (C, Toolbox_Iconbar_SelectAboutToBeShown);

   type Toolbox_Iconbar_SelectAboutToBeShown_Pointer is access Toolbox_Iconbar_SelectAboutToBeShown;

   type ATEL_Toolbox_Iconbar_SelectAboutToBeShown is abstract
        new Toolbox_EventListener(Toolbox_Event_Iconbar_SelectAboutToBeShown,-1,-1) with

   record
   Event : Toolbox_Iconbar_SelectAboutToBeShown_Pointer;
   end record;

   --
   -- Returns the Toolbox event to be raised when select is clicked on the iconbar icon.
   --
   function Get_Event (Iconbar : in Object_ID;
                       Button  : in Iconbar_Button_Type) return Toolbox_Event_Code_Type;

   --
   -- Returns the standard help message to be shown for the iconbar icon.
   --
   function Get_Help_Message (Iconbar : in Object_ID;
                              Flags   : in System.Unsigned_Types.Unsigned := 0) return String;

   --
   -- Returns the handle of the underlying Wimp icon of the iconbar icon.
   --
   function Get_IconHandle (Iconbar : in Object_ID;
                            Flags   : in System.Unsigned_Types.Unsigned := 0) return Component_ID;

   --
   -- Returns the menu to be used on the iconbar icon.
   --
   function Get_Menu (Iconbar : in Object_ID;
                      Flags   : in System.Unsigned_Types.Unsigned := 0) return Object_ID;

   --
   -- Returns the objects to be shown when SELECT/ADJUST is clicked on the iconbar.
   --
   function Get_Show (Iconbar : in Object_ID;
                      Button  : in Iconbar_Button_Type;
                      Flags   : in System.Unsigned_Types.Unsigned := 0) return Object_ID;

   --
   -- Returns the sprite being used for the iconbar icon.
   --
   function Get_Sprite (Iconbar : in Object_ID;
                        Flags   : in System.Unsigned_Types.Unsigned := 0) return String;

   --
   -- Returns the text being used for iconbar icontext.
   --
   function Get_Text (Iconbar : in Object_ID;
                      Flags   : in System.Unsigned_Types.Unsigned := 0) return String;

   --
   -- Sets the Toolbox event to be raised when SELECT is clicked on the iconbar icon.
   --
   procedure Set_Event (Iconbar : in Object_ID;
                        Button  : in Iconbar_Button_Type;
                        Event   : in Toolbox_Event_Code_Type;
                        Flags   : in System.Unsigned_Types.Unsigned := 0);

   --
   -- Sets the standard help message to be shown for the iconbar icon.
   --
   procedure Set_HelpMessage (Iconbar : in Object_ID;
                              Message : in string;
                              Flags   : in System.Unsigned_Types.Unsigned := 0);

   --
   -- Sets the menu to be used for iconbar icon.
   --
   procedure Set_Menu (Iconbar : in Object_ID;
                       Menu    : in Object_ID;
                       Flags   : in System.Unsigned_Types.Unsigned := 0);

   --
   -- Sets the objects to be shown when SELECT/ADJUST is clicked on the iconbar icon.
   --
   procedure Set_Show  (Iconbar : in Object_ID;
                        Button  : in Iconbar_Button_Type;
                        Object  : in Object_ID;
                        Flags   : in System.Unsigned_Types.Unsigned := 0);

   --
   -- Sets the sprite to be used as iconbar icon.
   --
   procedure Set_Sprite (Iconbar : in Object_ID;
                         Sprite  : in string;
                         Flags   : in System.Unsigned_Types.Unsigned := 0);

   --
   -- Sets the text to be used with the iconbar icon.
   --
   procedure Set_Text (Iconbar : in Object_ID;
                       Text    : in string;
                       Flags   : in System.Unsigned_Types.Unsigned := 0);

end RASCAL.ToolboxIconbar;
