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

with System;                     use System;
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.ToolboxToolAction is


   -- Flags
   ToolAction_GenerateSelectedEvent   : constant :=         2#1#;
   ToolAction_IsText                  : constant :=        2#10#;
   ToolAction_On                      : constant :=       2#100#;
   ToolAction_AutoToggle              : constant :=      2#1000#;
   ToolAction_NoPressedSprite         : constant :=     2#10000#;
   ToolAction_AutoRepeat              : constant :=    2#100000#;
   ToolAction_ShowTransient           : constant :=   2#1000000#;
   ToolAction_ShowAtPointer           : constant :=  2#10000000#;
   ToolAction_HasFadeSprite           : constant := 2#100000000#;

   ToolAction_Ident_Mask              : constant := 16#F#;
   ToolAction_Ident_Off               : constant := 16#0#;
   ToolAction_Ident_On                : constant := 16#1#;
   ToolAction_Ident_Fade              : constant := 16#2#;

   ToolAction_Selected_Adjust         : constant := 16#1#;
   ToolAction_Selected_Select         : constant := 16#4#;


   type Toolaction_Gadget is
   record
   Off_Text        : Address;
   Off_Text_Limit  : Integer;
   On_Text         : Address;
   On_Text_Limit   : Integer;
   Click_Action    : Integer;
   Select_Show     : Address;
   Adjust_Action   : Integer;
   Adjust_Show     : Address;
   Fade_Text       : Address;
   Fade_Text_Limit : Integer;
   end record;
   pragma Convention (C, Toolaction_Gadget);

   --
   -- This event is raised when the value of the number range has changed.
   --
   type Toolbox_ToolAction_ButtonClicked is
   record
   Header     : Toolbox_Event_Header;
   end record;
   pragma Convention (C, Toolbox_ToolAction_ButtonClicked);

   type Toolbox_ToolAction_ButtonClicked_Pointer is access Toolbox_ToolAction_ButtonClicked;

   type ATEL_Toolbox_ToolAction_ButtonClicked is abstract new Toolbox_EventListener(Toolbox_Event_ToolAction_ButtonClicked,-1,-1) with
   record
   Event : Toolbox_ToolAction_ButtonClicked_Pointer;
   end record;

   --
   -- Sets the ident string.
   --
   procedure Set_Ident (Window    : in Object_ID;
                        Component : in Component_ID;
                        Ident     : in String;
                        Flags     : in System.Unsigned_Types.Unsigned := 0);

   --
   -- Returns the ident string for the toolaction.
   --
   function Get_Ident (Window    : in Object_ID;
                       Component : in Component_ID;
                       Flags     : in System.Unsigned_Types.Unsigned := 0) return String;

   --
   --
   --
   procedure Set_Action (Window      : in Object_ID;
                        Component    : in Component_ID;
                        SelectAction : in Integer;
                        AdjustAction : in Integer;
                        Flags        : in System.Unsigned_Types.Unsigned := 0);

   --
   --
   --
   procedure Get_Action (Window       : in Object_ID;
                         Component    : in Component_ID;
                         SelectAction : out Integer;
                         AdjustAction : out Integer;
                         Flags        : in System.Unsigned_Types.Unsigned := 0);

   --
   --
   --
   procedure Set_ClickShow(Window     : in Object_ID;
                            Component  : in Component_ID;
                            SelectShow : in String;
                            AdjustShow : in String;
                            Flags      : in System.Unsigned_Types.Unsigned := 0);

   --
   --
   --
   procedure Get_ClickShow(Window     : in Object_ID;
                           Component  : in Component_ID;
                           SelectShow : out UString;
                           AdjustShow : out UString;
                           Flags      : in System.Unsigned_Types.Unsigned := 0);

   --
   -- Sets the state of the toolaction.
   --
   procedure Set_State (Window    : in Object_ID;
                        Component : in Component_ID;
                        State     : in Boolean;
                        Flags     : in System.Unsigned_Types.Unsigned := 0);

   --
   -- Returns the state of the toolaction.
   --
   function Get_State (Window    : in Object_ID;
                       Component : in Component_ID;
                       Flags     : in System.Unsigned_Types.Unsigned := 0) return Boolean;

end RASCAL.ToolboxToolAction;
