1. ------------------------------------------------------------------------------ 
  2. --                                                                          -- 
  3. --      Copyright (C) 1998-2000 E. Briot, J. Brobecker and A. Charlet       -- 
  4. --                     Copyright (C) 2000-2014, AdaCore                     -- 
  5. --                                                                          -- 
  6. -- This library is free software;  you can redistribute it and/or modify it -- 
  7. -- under terms of the  GNU General Public License  as published by the Free -- 
  8. -- Software  Foundation;  either version 3,  or (at your  option) any later -- 
  9. -- version. This library is distributed in the hope that it will be useful, -- 
  10. -- but WITHOUT ANY WARRANTY;  without even the implied warranty of MERCHAN- -- 
  11. -- TABILITY or FITNESS FOR A PARTICULAR PURPOSE.                            -- 
  12. --                                                                          -- 
  13. -- As a special exception under Section 7 of GPL version 3, you are granted -- 
  14. -- additional permissions described in the GCC Runtime Library Exception,   -- 
  15. -- version 3.1, as published by the Free Software Foundation.               -- 
  16. --                                                                          -- 
  17. -- You should have received a copy of the GNU General Public License and    -- 
  18. -- a copy of the GCC Runtime Library Exception along with this program;     -- 
  19. -- see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see    -- 
  20. -- <http://www.gnu.org/licenses/>.                                          -- 
  21. --                                                                          -- 
  22. ------------------------------------------------------------------------------ 
  23.  
  24. --  <description> 
  25. --  A GtkPageSetup object stores the page size, orientation and margins. The 
  26. --  idea is that you can get one of these from the page setup dialog and then 
  27. --  pass it to the Gtk.Print_Operation.Gtk_Print_Operation when printing. The 
  28. --  benefit of splitting this out of the Gtk.Print_Settings.Gtk_Print_Settings 
  29. --  is that these affect the actual layout of the page, and thus need to be set 
  30. --  long before user prints. 
  31. -- 
  32. --  <para id="print-margins"> The margins specified in this object are the 
  33. --  "print margins", i.e. the parts of the page that the printer cannot print 
  34. --  on. These are different from the layout margins that a word processor uses; 
  35. --  they are typically used to determine the *minimal* size for the layout 
  36. --  margins. 
  37. --  To obtain a Gtk.Page_Setup.Gtk_Page_Setup use Gtk.Page_Setup.Gtk_New to 
  38. --  get the defaults, or use gtk_print_run_page_setup_dialog to show the page 
  39. --  setup dialog and receive the resulting page setup. 
  40. -- 
  41. --  == A page setup dialog == 
  42. -- 
  43. --    static GtkPrintSettings *settings = NULL; 
  44. --    static GtkPageSetup *page_setup = NULL; 
  45. --    static void 
  46. --    do_page_setup (void) 
  47. --    { 
  48. --       GtkPageSetup *new_page_setup; 
  49. --       if (settings == NULL) 
  50. --       settings = gtk_print_settings_new (<!-- -->); 
  51. --             new_page_setup = gtk_print_run_page_setup_dialog (GTK_WINDOW (main_window), 
  52. --          page_setup, settings); 
  53. --       if (page_setup) 
  54. --       g_object_unref (page_setup); 
  55. --       page_setup = new_page_setup; 
  56. --    } 
  57. -- 
  58. --  Printing support was added in GTK+ 2.10. 
  59. -- 
  60. --  </description> 
  61. pragma Ada_2005; 
  62.  
  63. pragma Warnings (Off, "*is already use-visible*"); 
  64. with Glib;           use Glib; 
  65. with Glib.Key_File;  use Glib.Key_File; 
  66. with Glib.Object;    use Glib.Object; 
  67. with Gtk.Enums;      use Gtk.Enums; 
  68. with Gtk.Paper_Size; use Gtk.Paper_Size; 
  69.  
  70. package Gtk.Page_Setup is 
  71.  
  72.    type Gtk_Page_Setup_Record is new GObject_Record with null record; 
  73.    type Gtk_Page_Setup is access all Gtk_Page_Setup_Record'Class; 
  74.  
  75.    ------------------ 
  76.    -- Constructors -- 
  77.    ------------------ 
  78.  
  79.    procedure Gtk_New (Self : out Gtk_Page_Setup); 
  80.    procedure Initialize (Self : not null access Gtk_Page_Setup_Record'Class); 
  81.    --  Creates a new Gtk.Page_Setup.Gtk_Page_Setup. 
  82.    --  Since: gtk+ 2.10 
  83.  
  84.    function Gtk_Page_Setup_New return Gtk_Page_Setup; 
  85.    --  Creates a new Gtk.Page_Setup.Gtk_Page_Setup. 
  86.    --  Since: gtk+ 2.10 
  87.  
  88.    procedure Gtk_New_From_File 
  89.       (Self      : out Gtk_Page_Setup; 
  90.        File_Name : UTF8_String); 
  91.    procedure Initialize_From_File 
  92.       (Self      : not null access Gtk_Page_Setup_Record'Class; 
  93.        File_Name : UTF8_String); 
  94.    --  Reads the page setup from the file File_Name. Returns a new 
  95.    --  Gtk.Page_Setup.Gtk_Page_Setup object with the restored page setup, or 
  96.    --  null if an error occurred. See Gtk.Page_Setup.To_File. 
  97.    --  Since: gtk+ 2.12 
  98.    --  "file_name": the filename to read the page setup from 
  99.  
  100.    function Gtk_Page_Setup_New_From_File 
  101.       (File_Name : UTF8_String) return Gtk_Page_Setup; 
  102.    --  Reads the page setup from the file File_Name. Returns a new 
  103.    --  Gtk.Page_Setup.Gtk_Page_Setup object with the restored page setup, or 
  104.    --  null if an error occurred. See Gtk.Page_Setup.To_File. 
  105.    --  Since: gtk+ 2.12 
  106.    --  "file_name": the filename to read the page setup from 
  107.  
  108.    procedure Gtk_New_From_Key_File 
  109.       (Self       : out Gtk_Page_Setup; 
  110.        Key_File   : Glib.Key_File.G_Key_File; 
  111.        Group_Name : UTF8_String := ""); 
  112.    procedure Initialize_From_Key_File 
  113.       (Self       : not null access Gtk_Page_Setup_Record'Class; 
  114.        Key_File   : Glib.Key_File.G_Key_File; 
  115.        Group_Name : UTF8_String := ""); 
  116.    --  Reads the page setup from the group Group_Name in the key file 
  117.    --  Key_File. Returns a new Gtk.Page_Setup.Gtk_Page_Setup object with the 
  118.    --  restored page setup, or null if an error occurred. 
  119.    --  Since: gtk+ 2.12 
  120.    --  "key_file": the Gkey.File.Gkey_File to retrieve the page_setup from 
  121.    --  "group_name": the name of the group in the key_file to read, or null to 
  122.    --  use the default name "Page Setup" 
  123.  
  124.    function Gtk_Page_Setup_New_From_Key_File 
  125.       (Key_File   : Glib.Key_File.G_Key_File; 
  126.        Group_Name : UTF8_String := "") return Gtk_Page_Setup; 
  127.    --  Reads the page setup from the group Group_Name in the key file 
  128.    --  Key_File. Returns a new Gtk.Page_Setup.Gtk_Page_Setup object with the 
  129.    --  restored page setup, or null if an error occurred. 
  130.    --  Since: gtk+ 2.12 
  131.    --  "key_file": the Gkey.File.Gkey_File to retrieve the page_setup from 
  132.    --  "group_name": the name of the group in the key_file to read, or null to 
  133.    --  use the default name "Page Setup" 
  134.  
  135.    function Get_Type return Glib.GType; 
  136.    pragma Import (C, Get_Type, "gtk_page_setup_get_type"); 
  137.  
  138.    ------------- 
  139.    -- Methods -- 
  140.    ------------- 
  141.  
  142.    function Copy 
  143.       (Self : not null access Gtk_Page_Setup_Record) return Gtk_Page_Setup; 
  144.    --  Copies a Gtk.Page_Setup.Gtk_Page_Setup. 
  145.    --  Since: gtk+ 2.10 
  146.  
  147.    function Get_Bottom_Margin 
  148.       (Self : not null access Gtk_Page_Setup_Record; 
  149.        Unit : Gtk.Enums.Gtk_Unit) return Gdouble; 
  150.    --  Gets the bottom margin in units of Unit. 
  151.    --  Since: gtk+ 2.10 
  152.    --  "unit": the unit for the return value 
  153.  
  154.    procedure Set_Bottom_Margin 
  155.       (Self   : not null access Gtk_Page_Setup_Record; 
  156.        Margin : Gdouble; 
  157.        Unit   : Gtk.Enums.Gtk_Unit); 
  158.    --  Sets the bottom margin of the Gtk.Page_Setup.Gtk_Page_Setup. 
  159.    --  Since: gtk+ 2.10 
  160.    --  "margin": the new bottom margin in units of Unit 
  161.    --  "unit": the units for Margin 
  162.  
  163.    function Get_Left_Margin 
  164.       (Self : not null access Gtk_Page_Setup_Record; 
  165.        Unit : Gtk.Enums.Gtk_Unit) return Gdouble; 
  166.    --  Gets the left margin in units of Unit. 
  167.    --  Since: gtk+ 2.10 
  168.    --  "unit": the unit for the return value 
  169.  
  170.    procedure Set_Left_Margin 
  171.       (Self   : not null access Gtk_Page_Setup_Record; 
  172.        Margin : Gdouble; 
  173.        Unit   : Gtk.Enums.Gtk_Unit); 
  174.    --  Sets the left margin of the Gtk.Page_Setup.Gtk_Page_Setup. 
  175.    --  Since: gtk+ 2.10 
  176.    --  "margin": the new left margin in units of Unit 
  177.    --  "unit": the units for Margin 
  178.  
  179.    function Get_Orientation 
  180.       (Self : not null access Gtk_Page_Setup_Record) 
  181.        return Gtk.Enums.Gtk_Page_Orientation; 
  182.    --  Gets the page orientation of the Gtk.Page_Setup.Gtk_Page_Setup. 
  183.    --  Since: gtk+ 2.10 
  184.  
  185.    procedure Set_Orientation 
  186.       (Self        : not null access Gtk_Page_Setup_Record; 
  187.        Orientation : Gtk.Enums.Gtk_Page_Orientation); 
  188.    --  Sets the page orientation of the Gtk.Page_Setup.Gtk_Page_Setup. 
  189.    --  Since: gtk+ 2.10 
  190.    --  "orientation": a Gtk.Enums.Gtk_Page_Orientation value 
  191.  
  192.    function Get_Page_Height 
  193.       (Self : not null access Gtk_Page_Setup_Record; 
  194.        Unit : Gtk.Enums.Gtk_Unit) return Gdouble; 
  195.    --  Returns the page height in units of Unit. 
  196.    --  Note that this function takes orientation and margins into 
  197.    --  consideration. See Gtk.Page_Setup.Get_Paper_Height. 
  198.    --  Since: gtk+ 2.10 
  199.    --  "unit": the unit for the return value 
  200.  
  201.    function Get_Page_Width 
  202.       (Self : not null access Gtk_Page_Setup_Record; 
  203.        Unit : Gtk.Enums.Gtk_Unit) return Gdouble; 
  204.    --  Returns the page width in units of Unit. 
  205.    --  Note that this function takes orientation and margins into 
  206.    --  consideration. See Gtk.Page_Setup.Get_Paper_Width. 
  207.    --  Since: gtk+ 2.10 
  208.    --  "unit": the unit for the return value 
  209.  
  210.    function Get_Paper_Height 
  211.       (Self : not null access Gtk_Page_Setup_Record; 
  212.        Unit : Gtk.Enums.Gtk_Unit) return Gdouble; 
  213.    --  Returns the paper height in units of Unit. 
  214.    --  Note that this function takes orientation, but not margins into 
  215.    --  consideration. See Gtk.Page_Setup.Get_Page_Height. 
  216.    --  Since: gtk+ 2.10 
  217.    --  "unit": the unit for the return value 
  218.  
  219.    function Get_Paper_Size 
  220.       (Self : not null access Gtk_Page_Setup_Record) 
  221.        return Gtk.Paper_Size.Gtk_Paper_Size; 
  222.    --  Gets the paper size of the Gtk.Page_Setup.Gtk_Page_Setup. 
  223.    --  Since: gtk+ 2.10 
  224.  
  225.    procedure Set_Paper_Size 
  226.       (Self : not null access Gtk_Page_Setup_Record; 
  227.        Size : Gtk.Paper_Size.Gtk_Paper_Size); 
  228.    --  Sets the paper size of the Gtk.Page_Setup.Gtk_Page_Setup without 
  229.    --  changing the margins. See 
  230.    --  Gtk.Page_Setup.Set_Paper_Size_And_Default_Margins. 
  231.    --  Since: gtk+ 2.10 
  232.    --  "size": a Gtk.Paper_Size.Gtk_Paper_Size 
  233.  
  234.    function Get_Paper_Width 
  235.       (Self : not null access Gtk_Page_Setup_Record; 
  236.        Unit : Gtk.Enums.Gtk_Unit) return Gdouble; 
  237.    --  Returns the paper width in units of Unit. 
  238.    --  Note that this function takes orientation, but not margins into 
  239.    --  consideration. See Gtk.Page_Setup.Get_Page_Width. 
  240.    --  Since: gtk+ 2.10 
  241.    --  "unit": the unit for the return value 
  242.  
  243.    function Get_Right_Margin 
  244.       (Self : not null access Gtk_Page_Setup_Record; 
  245.        Unit : Gtk.Enums.Gtk_Unit) return Gdouble; 
  246.    --  Gets the right margin in units of Unit. 
  247.    --  Since: gtk+ 2.10 
  248.    --  "unit": the unit for the return value 
  249.  
  250.    procedure Set_Right_Margin 
  251.       (Self   : not null access Gtk_Page_Setup_Record; 
  252.        Margin : Gdouble; 
  253.        Unit   : Gtk.Enums.Gtk_Unit); 
  254.    --  Sets the right margin of the Gtk.Page_Setup.Gtk_Page_Setup. 
  255.    --  Since: gtk+ 2.10 
  256.    --  "margin": the new right margin in units of Unit 
  257.    --  "unit": the units for Margin 
  258.  
  259.    function Get_Top_Margin 
  260.       (Self : not null access Gtk_Page_Setup_Record; 
  261.        Unit : Gtk.Enums.Gtk_Unit) return Gdouble; 
  262.    --  Gets the top margin in units of Unit. 
  263.    --  Since: gtk+ 2.10 
  264.    --  "unit": the unit for the return value 
  265.  
  266.    procedure Set_Top_Margin 
  267.       (Self   : not null access Gtk_Page_Setup_Record; 
  268.        Margin : Gdouble; 
  269.        Unit   : Gtk.Enums.Gtk_Unit); 
  270.    --  Sets the top margin of the Gtk.Page_Setup.Gtk_Page_Setup. 
  271.    --  Since: gtk+ 2.10 
  272.    --  "margin": the new top margin in units of Unit 
  273.    --  "unit": the units for Margin 
  274.  
  275.    function Load_File 
  276.       (Self      : not null access Gtk_Page_Setup_Record; 
  277.        File_Name : UTF8_String) return Boolean; 
  278.    --  Reads the page setup from the file File_Name. See 
  279.    --  Gtk.Page_Setup.To_File. 
  280.    --  Since: gtk+ 2.14 
  281.    --  "file_name": the filename to read the page setup from 
  282.  
  283.    function Load_Key_File 
  284.       (Self       : not null access Gtk_Page_Setup_Record; 
  285.        Key_File   : Glib.Key_File.G_Key_File; 
  286.        Group_Name : UTF8_String := "") return Boolean; 
  287.    --  Reads the page setup from the group Group_Name in the key file 
  288.    --  Key_File. 
  289.    --  Since: gtk+ 2.14 
  290.    --  "key_file": the Gkey.File.Gkey_File to retrieve the page_setup from 
  291.    --  "group_name": the name of the group in the key_file to read, or null to 
  292.    --  use the default name "Page Setup" 
  293.  
  294.    procedure Set_Paper_Size_And_Default_Margins 
  295.       (Self : not null access Gtk_Page_Setup_Record; 
  296.        Size : Gtk.Paper_Size.Gtk_Paper_Size); 
  297.    --  Sets the paper size of the Gtk.Page_Setup.Gtk_Page_Setup and modifies 
  298.    --  the margins according to the new paper size. 
  299.    --  Since: gtk+ 2.10 
  300.    --  "size": a Gtk.Paper_Size.Gtk_Paper_Size 
  301.  
  302.    function To_File 
  303.       (Self      : not null access Gtk_Page_Setup_Record; 
  304.        File_Name : UTF8_String) return Boolean; 
  305.    --  This function saves the information from Setup to File_Name. 
  306.    --  Since: gtk+ 2.12 
  307.    --  "file_name": the file to save to 
  308.  
  309.    procedure To_Key_File 
  310.       (Self       : not null access Gtk_Page_Setup_Record; 
  311.        Key_File   : Glib.Key_File.G_Key_File; 
  312.        Group_Name : UTF8_String); 
  313.    --  This function adds the page setup from Setup to Key_File. 
  314.    --  Since: gtk+ 2.12 
  315.    --  "key_file": the Gkey.File.Gkey_File to save the page setup to 
  316.    --  "group_name": the group to add the settings to in Key_File, or null to 
  317.    --  use the default name "Page Setup" 
  318.  
  319. end Gtk.Page_Setup;