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

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

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

package RASCAL.ToolboxDraggable is

   type Draggable_State is (Deselected,Selected);

   -- Flags
   Draggable_Generate_drag_started         : constant := 16#1#;
   Draggable_Sprite                        : constant := 16#2#;
   Draggable_Text                          : constant := 16#4#;
   Draggable_Type                          : constant := 16#38#;

   Draggable_Type_shift                    : constant := 16#3#;
   Draggable_Type_drag                     : constant := 16#0#;
   Draggable_Type_click_drag               : constant := 16#1#;
   Draggable_Type_click_double_drag        : constant := 16#2#;

   Draggable_Use_toolbox_ids               : constant := 16#40#;
   Draggable_Drop_shadow                   : constant := 16#80#;
   Draggable_No_dither                     : constant := 16#100#;

   Draggable_Drag_started_adjust           : constant := 16#1#;
   Draggable_Drag_started_select           : constant := 16#4#;
   Draggable_Drag_started_shift            : constant := 16#8#;
   Draggable_Drag_started_ctrl             : constant := 16#10#;
   Draggable_Drag_ended_toolbox_ids        : constant := 16#1#;

   --
   -- Event is raised when the user starts a drag of a draggable object.
   --
   type Toolbox_Draggable_DragStarted is
   record
   Header  : Toolbox_Event_Header;
   end record;
   pragma Convention (C, Toolbox_Draggable_DragStarted);

   type Toolbox_Draggable_DragStarted_Pointer is access Toolbox_Draggable_DragStarted;

   type ATEL_Toolbox_Draggable_DragStarted is abstract
        new Toolbox_EventListener(Toolbox_Event_Draggable_DragStarted,-1,-1) with

   record
   Event : Toolbox_Draggable_DragStarted_Pointer;
   end record;

   --
   -- Event is raised when the user finishes a drag of a draggable object.
   --
   type Toolbox_Draggable_DragEnded is
   record
   Header  : Toolbox_Event_Header;
   Window  : Wimp_Handle_Type;
   Icon    : Icon_handle_Type;
   X       : Integer;
   Y       : Integer;
   end record;
   pragma Convention (C, Toolbox_Draggable_DragEnded);

   type Toolbox_Draggable_DragEnded_Pointer is access Toolbox_Draggable_DragEnded;

   type ATEL_Toolbox_Draggable_DragEnded is abstract
        new Toolbox_EventListener(Toolbox_Event_Draggable_DragEnded,-1,-1) with
        
   record
   Event : Toolbox_Draggable_DragEnded_Pointer;
   end record;
      
   --
   -- Returns the draggable's state.
   --
   function Get_State (Draggable : in Object_ID;
                       Component : in Object_ID) return Draggable_State;

   --
   -- Returns the name of the sprite currently used for the draggable object.
   --
   function Get_Sprite (Draggable : in Object_ID;
                        Component : in Object_ID;
                        Flags   : in System.Unsigned_Types.Unsigned := 0) return String;

   --
   -- Returns the text being displayed in the draggable object.
   --
   function Get_Text (Draggable : in Object_ID;
                      Component : in Object_ID;
                      Flags   : in System.Unsigned_Types.Unsigned := 0) return String;

   --
   -- Sets the draggable's state to either selected or deselected.
   --
   procedure Set_State (Draggable : in Object_ID;
                        Component : in Object_ID;
                        State     : in Draggable_State;
                        Flags   : in System.Unsigned_Types.Unsigned := 0);

   --
   -- Sets the name of the sprite which will be used for this draggable object.
   --
   procedure Set_Sprite (Draggable : in Object_ID;
                         Component : in Object_ID;
                         Sprite  : in string;
                         Flags   : in System.Unsigned_Types.Unsigned := 0);

   --
   -- Sets the text that will be displayed in the draggable object.
   --
   procedure Set_Text (Draggable : in Object_ID;
                       Component : in Object_ID;
                       Text      : in string;
                       Flags     : in System.Unsigned_Types.Unsigned := 0);

end RASCAL.ToolboxDraggable;
