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

with RASCAL.ToolboxWindow;       use RASCAL.ToolboxWindow;
with RASCAL.OS;                  use RASCAL.OS;

with System.Unsigned_Types;      use System.Unsigned_Types;

package RASCAL.ToolboxScrollbar is

   -- Flags
   Scrollbar_Vertical   : constant System.Unsigned_Types.Unsigned := 16#0#;
   Scrollbar_Horisontal : constant System.Unsigned_Types.Unsigned := 16#1#;

   -- Flags
   Action_Scrollbar_Position_Changed   : constant := 16#140183#;
   Scrollbar_Has_Vertical_scrollbar    : constant := 16#1#;
   Scrollbar_Has_Horizontal_scrollbar  : constant := 16#2#;
   Scrollbar_Bounds_Lower              : constant := 16#1#;
   Scrollbar_Bounds_Upper              : constant := 16#2#;
   Scrollbar_Bounds_Visible_Length     : constant := 16#4#;
   Scrollbar_Increments_Line           : constant := 16#1#;
   Scrollbar_Increments_Page           : constant := 16#2#;   

   --
   -- 
   --
   type Toolbox_Scrollbar_PositionChanged is
   record
   Header       : Toolbox_Event_Header;
   New_Position : System.Unsigned_Types.Unsigned;
   Directiom    : Integer;
   end record;
   pragma Convention (C, Toolbox_Scrollbar_PositionChanged);

   type Toolbox_Scrollbar_PositionChanged_Pointer is access Toolbox_Scrollbar_PositionChanged;

   type ATEL_Toolbox_Scrollbar_PositionChanged is abstract new Toolbox_EventListener(Toolbox_Event_Scrollbar_PositionChanged,-1,-1) with
   record
   Event : Toolbox_Scrollbar_PositionChanged_Pointer;
   end record;

   --
   -- Reads the state of the Scrollbar.
   --This method is functionally identical to Gadget_GetFlags.
   --
   function Get_State (Window    : in Object_ID;
                       Component : in Component_ID;
                       Flags     : in System.Unsigned_Types.Unsigned := 0) return System.Unsigned_Types.Unsigned;

   --
   -- Sets the state of the Scrollbar.
   --This method is functionally identical to Gadget_SetFlags.
   --
   procedure Set_State (Window    : in Object_ID;
                        Component : in Component_ID;
                        State     : in System.Unsigned_Types.Unsigned;
                        Flags     : in System.Unsigned_Types.Unsigned := 0);

   --
   -- Sets the bounds of the Scrollbar.
   --
   procedure Set_Bounds(Window         : in Object_ID;
                        Component      : in Component_ID;
                        Lower_Bound    : in Integer;
                        Upper_Bound    : in Integer;
                        Visible_Length : in Integer;
                        Flags          : in System.Unsigned_Types.Unsigned := 0);

   --
   -- Sets the upper bound of the Scrollbar.
   --
   procedure Set_UpperBound(Window      : in Object_ID;
                            Component   : in Component_ID;
                            Upper_Bound : in Integer);

   --
   -- Set the lower bound of the Scrollbar.
   --
   procedure Set_LowerBound(Window      : in Object_ID;
                            Component   : in Component_ID;
                            Lower_Bound : in Integer);
                               
   --
   -- Sets the visible length of the Scrollbar.
   --
   procedure Set_VisibleLength(Window         : in Object_ID;
                               Component      : in Component_ID;
                               Visible_Length : in Integer);

   --
   -- Gets the bounds of the Scrollbar.
   --
   procedure Get_Bounds(Window           : in Object_ID;
                        Component        : in Component_ID;
                        Lower_Bound      : out Integer;
                        Upper_Bound      : out Integer;
                        Visible_Length   : out Integer;
                        Flags            : in System.Unsigned_Types.Unsigned := 0);

   --
   -- Gets the lower bound of the Scrollbar.
   --
   function Get_LowerBound(Window      : in Object_ID;
                           Component   : in Component_ID) return Integer;

   --
   -- Gets the upper bound of the Scrollbar.
   --
   function Get_UpperBound(Window      : in Object_ID;
                           Component   : in Component_ID) return Integer;

   --
   -- Gets the visible length of the Scrollbar.
   --
   function Get_VisibleLength(Window      : in Object_ID;
                              Component   : in Component_ID) return Integer;
                              
   --
   -- Sets the value of the Scrollbar.
   --
   procedure Set_Value (Window    : in Object_ID;
                        Component : in Component_ID;
                        Value     : in Integer;
                        Flags     : in System.Unsigned_Types.Unsigned := 0);

   --
   -- Gets the value of the Scrollbar.
   --
   function Get_Value (Window    : in Object_ID;
                       Component : in Component_ID;
                       Flags     : in System.Unsigned_Types.Unsigned := 0) return Integer;


   --
   -- Set the increments for the scrollbar.
   --
   procedure Set_Increments (Window    : in Object_ID;
                             Component : in Component_ID;
                             Line      : in Integer;
                             Page      : in Integer;
                             Flags     : in System.Unsigned_Types.Unsigned := 0);

   --
   -- Sets the line increment of the Scrollbar.
   --
   procedure Set_LineIncrement(Window    : in Object_ID;
                               Component : in Component_ID;
                               Line      : in Integer);

   --
   -- Sets the page increment of the Scrollbar.
   --
   procedure Set_PageIncrement(Window    : in Object_ID;
                               Component : in Component_ID;
                               Page      : in Integer);

   --
   -- Get the increments for the scrollbar.
   --
   procedure Get_Increments (Window    : in Object_ID;
                             Component : in Component_ID;
                             Line      : out Integer;
                             Page      : out Integer;
                             Flags     : in System.Unsigned_Types.Unsigned := 0);

   --
   -- Gets the line increment of the Scrollbar.
   --
   function Get_LineIncrement(Window    : in Object_ID;
                              Component : in Component_ID) return Integer;

   --
   -- Gets the page increment of the Scrollbar.
   --
   function Get_PageIncrement(Window    : in Object_ID;
                              Component : in Component_ID) return Integer;

   --
   -- Sets the toolbox event for when a Scrollbar changes position.                                                        
   --                                                                 
   procedure Set_Event (Window    : in Object_ID;
                        Component : in Component_ID;
                        Event     : in Integer;
                        Flags     : in System.Unsigned_Types.Unsigned := 0);

   --
   -- Gets the toolbox event for when a Scrollbar changes position.
   --                                                                                
   function Get_Event (Window    : in Object_ID;
                       Component : in Component_ID;
                       Flags     : in System.Unsigned_Types.Unsigned := 0) return Integer;
    
end RASCAL.ToolboxScrollbar;
