--------------------------------------------------------------------------------
--                                                                            --
-- 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 Print 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;
with System;                  use System;

with Interfaces.C;            use Interfaces.C;

package RASCAL.ToolboxPrint is

   -- Flags
   PrintDBox_Generate_About_To_Be_Shown    : constant := 16#1#;
   PrintDBox_Generate_Dialogue_Completed   : constant := 16#2#;
   PrintDBox_Generate_Show_Setup_Action    : constant := 16#4#;
   PrintDBox_Include_All_From_To           : constant := 16#8#;
   PrintDBox_Include_Copies                : constant := 16#10#;
   PrintDBox_Include_Scale                 : constant := 16#20#;
   PrintDBox_Include_Orientation           : constant := 16#40#;
   PrintDBox_Include_Save                  : constant := 16#80#;
   PrintDBox_Include_Set_up                : constant := 16#100#;
   PrintDBox_Include_Draft                 : constant := 16#200#;
   PrintDBox_Select_From_to                : constant := 16#400#;
   PrintDBox_Select_Sideways               : constant := 16#800#;
   PrintDBox_Select_Draft                  : constant := 16#1000#;
   PrintDBox_Print_Sideways                : constant := 16#1#;
   PrintDBox_Print_Draft                   : constant := 16#2#;
   PrintDBox_Page_Range_All                : constant := -1;

   type PrintDBoxTemplate is
   record
   Flags           : System.Unsigned_Types.Unsigned;
   From            : Integer;
   To              : Integer;
   Copies          : Integer;
   Scale           : Integer;
   Further_Options : Address;
   Window          : Address;
   end record;
   pragma Convention (C, PrintDBoxTemplate);

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

   type Toolbox_PrintDbox_AboutToBeShown_Pointer is access Toolbox_PrintDbox_AboutToBeShown;

   type ATEL_Toolbox_PrintDbox_AboutToBeShown is abstract
        new Toolbox_EventListener(Toolbox_Event_PrintDbox_AboutToBeShown,-1,-1) with

   record
   Event : Toolbox_PrintDbox_AboutToBeShown_Pointer;
   end record;
   
   --
   -- Event is raised after the Print window has been hidden.
   --
   type Toolbox_PrintDbox_DialogueCompleted is
   record
   Header  : Toolbox_Event_Header;
   end record;
   pragma Convention (C, Toolbox_PrintDbox_DialogueCompleted);

   type Toolbox_PrintDbox_DialogueCompleted_Pointer is access Toolbox_PrintDbox_DialogueCompleted;

   type ATEL_Toolbox_PrintDbox_DialogueCompleted is abstract
        new Toolbox_EventListener(Toolbox_Event_PrintDbox_DialogueCompleted,-1,-1) with

   record
   Event : Toolbox_PrintDbox_DialogueCompleted_Pointer;
   end record;

   --
   --Event is raised when the user clicks on 'Print'.
   --
   type Toolbox_PrintDbox_Print is
   record
   Header      : Toolbox_Event_Header;
   Start_Page  : Integer;
   Finish_Page : Integer;
   Copies      : Integer;
   Scale_Factor: Integer;
   end record;
   pragma Convention (C, Toolbox_PrintDbox_Print);

   type Toolbox_PrintDbox_Print_Pointer is access Toolbox_PrintDbox_Print;

   type ATEL_Toolbox_PrintDbox_Print is abstract
        new Toolbox_EventListener(Toolbox_Event_PrintDbox_Print,-1,-1) with

   record
   Event : Toolbox_PrintDbox_Print_Pointer;
   end record;

   --
   -- Event is raised when the user clicks on 'Save'.
   --
   type Toolbox_PrintDbox_Save is
   record
   Header  : Toolbox_Event_Header;
   Start_Page  : Integer;
   Finish_Page : Integer;
   Copies      : Integer;
   Scale_Factor: Integer;
   end record;
   pragma Convention (C, Toolbox_PrintDbox_Save);

   type Toolbox_PrintDbox_Save_Pointer is access Toolbox_PrintDbox_Save;

   type ATEL_Toolbox_PrintDbox_Save is abstract
        new Toolbox_EventListener(Toolbox_Event_PrintDbox_Save,-1,-1) with
        
   record
   Event : Toolbox_PrintDbox_Save_Pointer;
   end record;

   --
   -- Event is raised when the user clicks on 'Setup'.
   --
   type Toolbox_PrintDbox_Setup is
   record
   Header  : Toolbox_Event_Header;
   end record;
   pragma Convention (C, Toolbox_PrintDbox_Setup);

   type Toolbox_PrintDbox_Setup_Pointer is access Toolbox_PrintDbox_Setup;

   type ATEL_Toolbox_PrintDbox_Setup is abstract
        new Toolbox_EventListener(Toolbox_Event_PrintDbox_Setup,-1,-1) with

   record
   Event : Toolbox_PrintDbox_Setup_Pointer;
   end record;

   --
   -- Event is raised just before the window is opened.
   --Type lacks union.
   --
   type Toolbox_PrintDbox_SetupAboutToBeShown is
   record
   Header    : Toolbox_Event_Header;
   Object    : Object_ID;
   Show_Type : Integer;
   Info      : Window_Position_Type(Full_Spec);
   end record;
   pragma Convention (C, Toolbox_PrintDbox_SetupAboutToBeShown);

   type Toolbox_PrintDbox_SetupAboutToBeShown_Pointer is
        access Toolbox_PrintDbox_SetupAboutToBeShown;

   type ATEL_Toolbox_PrintDbox_SetupAboutToBeShown is abstract
        new Toolbox_EventListener(Toolbox_Event_PrintDbox_SetupAboutToBeShown,-1,-1) with

   record
   Event : Toolbox_PrintDbox_SetupAboutToBeShown_Pointer;
   end record;

   --
   -- Returns the number of copies for the Print Dialogue.
   --
   function Get_Copies (Print : Object_ID;
                        Flags : in System.Unsigned_Types.Unsigned := 0) return integer;

   --
   -- Returns the draft mode status.
   --
   function is_Draft (Print : Object_ID;
                      Flags : in System.Unsigned_Types.Unsigned := 0) return boolean;

   --
   -- Returns the page orientation.
   --
   function Is_Upright (Print : Object_ID;
                        Flags : in System.Unsigned_Types.Unsigned := 0) return boolean;

   --
   -- Returns the page range for the Print dialogue. (Start := -1 means all)
   --
   procedure Get_Page_Range (Print     : in Object_ID;
                            Start_Page : out integer;
                            End_Page   : out integer;
                            Flags      : in System.Unsigned_Types.Unsigned := 0);

   --
   -- Returns the scale factor for the Print dialogue.
   --
   function Get_Scale (Print : Object_ID;
                       Flags : in System.Unsigned_Types.Unsigned := 0) return integer;

   --
   -- Returns the Wimp id of the underlying window used for the PRintDbox dialogue.
   --
   function Get_Window_ID (Print : Object_ID;
                           Flags : in System.Unsigned_Types.Unsigned := 0) return Object_ID;

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

   --
   -- Sets the number of copies for the Print dialogue.
   --
   procedure Set_Copies (Print  : Object_ID;
                         Copies : in integer;
                         Flags  : in System.Unsigned_Types.Unsigned := 0);

   --
   -- Sets the draft printing mode for the Print dialogue.
   --
   procedure Set_Draft (Print : Object_ID;
                        Draft : in boolean;
                        Flags : in System.Unsigned_Types.Unsigned := 0);

   --
   -- Sets the page orientation for the Print dialogue.
   --
   procedure Set_Orientation (Print    : Object_ID;
                              Sideways : in boolean;
                              Flags    : in System.Unsigned_Types.Unsigned := 0);

   --
   -- Sets the page range for the Print dialogue.
   --
   procedure Set_Page_Range (Print      : Object_ID;
                             Start_Page : integer;
                             End_Page   : integer;
                             Flags      : in System.Unsigned_Types.Unsigned := 0);

   --
   -- Sets the scale for the Print dialogue.
   --
   procedure Set_Scale (Print : Object_ID;
                        Scale : in integer;
                        Flags : in System.Unsigned_Types.Unsigned := 0);

end RASCAL.ToolboxPrint;
