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

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

with System.Unsigned_Types;   use System.Unsigned_Types;

package RASCAL.ToolboxScale is

   type standard_value_array  is array (Natural range <>) of Integer;

   type ScaleTemplate is
   record
   Flags : System.Unsigned_Types.Unsigned;
   Max_Value  : Integer;
   Min_Value  : Integer;
   Step_Size  : Integer;
   Title      : RASCAL.Utility.Address;
   Max_Title  : Integer;
   Window     : RASCAL.Utility.Address;
   std_value  : standard_value_array(0..3);
   end record;
   pragma Convention (C, ScaleTemplate);

   -- Scale
   Scale_generate_about_to_be_shown   : constant := 16#1#;
   Scale_generate_dialogue_completed  : constant := 16#2#;
   Scale_include_scale_to_fit         : constant := 16#4#;
   Scale_percent                      : constant := 16#82C000#;
   Scale_std_value0                   : constant := 16#82C001#;
   Scale_std_value1                   : constant := 16#82C002#;
   Scale_std_value2                   : constant := 16#82C003#;
   Scale_std_value3                   : constant := 16#82C004#;
   Scale_cancel                       : constant := 16#82C005#;
   Scale_scale                        : constant := 16#82C006#;
   Scale_percent_label                : constant := 16#82C007#;
   Scale_scale_label                  : constant := 16#82C008#;
   Scale_scale_to_fit                 : constant := 16#82C009#;
   Action_Scale_About_To_Be_Shown     : constant := 16#82C00#;
   Action_Scale_Dialogue_Completed    : constant := 16#82C01#;
   Action_Scale_Apply_Factor          : constant := 16#82C02#;
   Error_Scale_Tasks_Active           : constant := 16#80B700#;
   Error_Scale_Alloc_Failed           : constant := 16#80B701#;
   Error_Scale_Short_Buffer           : constant := 16#80B702#;
   Error_Scale_No_Such_Task           : constant := 16#80B711#;
   Error_Scale_No_Such_Method         : constant := 16#80B712#;
   Error_Scale_No_Such_Misc_Op_Method : constant := 16#80B713#;
   Scale_Set_Lower_Bound              : constant := 16#1#;
   Scale_Set_Upper_Bound              : constant := 16#2#;
   Scale_Set_Step_Size                : constant := 16#4#;

   --
   -- Event is raised just before the Scale dialogue is displayed.
   --Type lacks union.
   --
   type Toolbox_Scale_AboutToBeShown is
   record
   Header     : Toolbox_Event_Header;
   Show_Type  : Integer;
   Info       : Window_Position_Type(Full_Spec);
   end record;
   pragma Convention (C, Toolbox_Scale_AboutToBeShown);

   type Toolbox_Scale_AboutToBeShown_Pointer is access Toolbox_Scale_AboutToBeShown;

   type ATEL_Toolbox_Scale_AboutToBeShown is abstract new Toolbox_EventListener(Toolbox_Event_Scale_AboutToBeShown,-1,-1) with
   record
   Event : Toolbox_Scale_AboutToBeShown_Pointer;
   end record;

   --
   -- Event is raised when the user clicks on the 'Scale' or 'Scale to Fit' button, or presses return.
   --
   type Toolbox_Scale_ApplyFactor is
   record
   Header  : Toolbox_Event_Header;
   Factor  : System.Unsigned_Types.Unsigned;
   end record;
   pragma Convention (C, Toolbox_Scale_ApplyFactor);

   type Toolbox_Scale_ApplyFactor_Pointer is access Toolbox_Scale_ApplyFactor;

   type ATEL_Toolbox_Scale_ApplyFactor is abstract new Toolbox_EventListener(Toolbox_Event_Scale_ApplyFactor,-1,-1) with
   record
   Event : Toolbox_Scale_ApplyFactor_Pointer;
   end record;

   --
   -- Event is raised after the Scale dialogue is hidden.
   --
   type Toolbox_Scale_DialogueCompleted is
   record
   Header  : Toolbox_Event_Header;
   end record;
   pragma Convention (C, Toolbox_Scale_DialogueCompleted);

   type Toolbox_Scale_DialogueCompleted_Pointer is access Toolbox_Scale_DialogueCompleted;

   type ATEL_Toolbox_Scale_DialogueCompleted is abstract new Toolbox_EventListener(Toolbox_Event_Scale_DialogueCompleted,-1,-1) with
   record
   Event : Toolbox_Scale_DialogueCompleted_Pointer;
   end record;

   --
   -- Returns the title of the Scale dialogue window.
   --
   function Get_Title (Scale : Object_ID;
                       Flags : in System.Unsigned_Types.Unsigned := 0) return string;

   --
   -- Sets the title of the Scale dialogue window.
   --
   procedure Set_Title (Scale : in Object_ID;
                        Title : in string;
                        Flags : in System.Unsigned_Types.Unsigned := 0);

   --
   -- Returns the Wimp Id of the underlying window.
   --
   function Get_Window_ID (Scale : Object_ID;
                           Flags : in System.Unsigned_Types.Unsigned := 0) return Object_ID;

   --
   -- Returns the value of the writable field of the scale dialogue.
   --
   function Get_Value (Scale : Object_ID;
                       Flags : in System.Unsigned_Types.Unsigned := 0) return integer;

   --
   -- Sets the value of the writable field of the scale dialogue.
   --
   procedure Set_Value (Scale : in Object_ID;
                        Value : in integer;
                        Flags : in System.Unsigned_Types.Unsigned := 0);

   --
   -- Returns the lower and upper bounds and step size of the writable field in the scale dialogue.
   --
   function Get_Bounds (Scale : Object_ID;
                        Flags : in System.Unsigned_Types.Unsigned := 0) return integer;

   --
   -- Sets the lower and upper bounds and step size of the writable field in the scale dialogue.
   --
   procedure Set_Bounds (Scale  : in Object_ID;
                         Bounds : in integer;
                         Flags  : in System.Unsigned_Types.Unsigned := 0);

end RASCAL.ToolboxScale;
