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. --  GtkPaperSize handles paper sizes. It uses the standard called <ulink 
  26. --  url="http://www.pwg.org/standards.html">"PWG 5101.1-2002 PWG: Standard for 
  27. --  Media Standardized Names"</ulink> to name the paper sizes (and to get the 
  28. --  data for the page sizes). In addition to standard paper sizes, GtkPaperSize 
  29. --  allows to construct custom paper sizes with arbitrary dimensions. 
  30. -- 
  31. --  The Gtk.Paper_Size.Gtk_Paper_Size object stores not only the dimensions 
  32. --  (width and height) of a paper size and its name, it also provides default 
  33. --  <link linkend="print-margins">print margins</link>. 
  34. -- 
  35. --  Printing support has been added in GTK+ 2.10. 
  36. -- 
  37. --  </description> 
  38. pragma Ada_2005; 
  39.  
  40. pragma Warnings (Off, "*is already use-visible*"); 
  41. with Glib;          use Glib; 
  42. with Glib.Glist;    use Glib.Glist; 
  43. with Glib.Key_File; use Glib.Key_File; 
  44. with Gtk.Enums;     use Gtk.Enums; 
  45.  
  46. package Gtk.Paper_Size is 
  47.  
  48.    type Gtk_Paper_Size is new Glib.C_Boxed with null record; 
  49.    Null_Gtk_Paper_Size : constant Gtk_Paper_Size; 
  50.  
  51.    function From_Object (Object : System.Address) return Gtk_Paper_Size; 
  52.    function From_Object_Free (B : access Gtk_Paper_Size'Class) return Gtk_Paper_Size; 
  53.    pragma Inline (From_Object_Free, From_Object); 
  54.  
  55.    ------------------ 
  56.    -- Constructors -- 
  57.    ------------------ 
  58.  
  59.    procedure Gtk_New (Widget : out Gtk_Paper_Size; Name : UTF8_String := ""); 
  60.    --  Creates a new Gtk.Paper_Size.Gtk_Paper_Size object by parsing a <ulink 
  61.    --  url="ftp://ftp.pwg.org/pub/pwg/candidates/cs-pwgmsn10-20020226-5101.1.pdf">PWG 
  62.    --  5101.1-2002</ulink> paper name. 
  63.    --  If Name is null, the default paper size is returned, see 
  64.    --  Gtk.Paper_Size.Get_Default. 
  65.    --  Since: gtk+ 2.10 
  66.    --  "name": a paper size name, or null 
  67.  
  68.    function Gtk_Paper_Size_New 
  69.       (Name : UTF8_String := "") return Gtk_Paper_Size; 
  70.    --  Creates a new Gtk.Paper_Size.Gtk_Paper_Size object by parsing a <ulink 
  71.    --  url="ftp://ftp.pwg.org/pub/pwg/candidates/cs-pwgmsn10-20020226-5101.1.pdf">PWG 
  72.    --  5101.1-2002</ulink> paper name. 
  73.    --  If Name is null, the default paper size is returned, see 
  74.    --  Gtk.Paper_Size.Get_Default. 
  75.    --  Since: gtk+ 2.10 
  76.    --  "name": a paper size name, or null 
  77.  
  78.    procedure Gtk_New_Custom 
  79.       (Widget       : out Gtk_Paper_Size; 
  80.        Name         : UTF8_String; 
  81.        Display_Name : UTF8_String; 
  82.        Width        : Gdouble; 
  83.        Height       : Gdouble; 
  84.        Unit         : Gtk.Enums.Gtk_Unit); 
  85.    --  Creates a new Gtk.Paper_Size.Gtk_Paper_Size object with the given 
  86.    --  parameters. 
  87.    --  Since: gtk+ 2.10 
  88.    --  "name": the paper name 
  89.    --  "display_name": the human-readable name 
  90.    --  "width": the paper width, in units of Unit 
  91.    --  "height": the paper height, in units of Unit 
  92.    --  "unit": the unit for Width and Height. not Gtk.Enums.None. 
  93.  
  94.    function Gtk_Paper_Size_New_Custom 
  95.       (Name         : UTF8_String; 
  96.        Display_Name : UTF8_String; 
  97.        Width        : Gdouble; 
  98.        Height       : Gdouble; 
  99.        Unit         : Gtk.Enums.Gtk_Unit) return Gtk_Paper_Size; 
  100.    --  Creates a new Gtk.Paper_Size.Gtk_Paper_Size object with the given 
  101.    --  parameters. 
  102.    --  Since: gtk+ 2.10 
  103.    --  "name": the paper name 
  104.    --  "display_name": the human-readable name 
  105.    --  "width": the paper width, in units of Unit 
  106.    --  "height": the paper height, in units of Unit 
  107.    --  "unit": the unit for Width and Height. not Gtk.Enums.None. 
  108.  
  109.    procedure Gtk_New_From_Key_File 
  110.       (Widget     : out Gtk_Paper_Size; 
  111.        Key_File   : Glib.Key_File.G_Key_File; 
  112.        Group_Name : UTF8_String); 
  113.    --  Reads a paper size from the group Group_Name in the key file Key_File. 
  114.    --  Since: gtk+ 2.12 
  115.    --  "key_file": the Gkey.File.Gkey_File to retrieve the papersize from 
  116.    --  "group_name": the name ofthe group in the key file to read, or null to 
  117.    --  read the first group 
  118.  
  119.    function Gtk_Paper_Size_New_From_Key_File 
  120.       (Key_File   : Glib.Key_File.G_Key_File; 
  121.        Group_Name : UTF8_String) return Gtk_Paper_Size; 
  122.    --  Reads a paper size from the group Group_Name in the key file Key_File. 
  123.    --  Since: gtk+ 2.12 
  124.    --  "key_file": the Gkey.File.Gkey_File to retrieve the papersize from 
  125.    --  "group_name": the name ofthe group in the key file to read, or null to 
  126.    --  read the first group 
  127.  
  128.    procedure Gtk_New_From_Ppd 
  129.       (Widget           : out Gtk_Paper_Size; 
  130.        Ppd_Name         : UTF8_String; 
  131.        Ppd_Display_Name : UTF8_String; 
  132.        Width            : Gdouble; 
  133.        Height           : Gdouble); 
  134.    --  Creates a new Gtk.Paper_Size.Gtk_Paper_Size object by using PPD 
  135.    --  information. 
  136.    --  If Ppd_Name is not a recognized PPD paper name, Ppd_Display_Name, Width 
  137.    --  and Height are used to construct a custom Gtk.Paper_Size.Gtk_Paper_Size 
  138.    --  object. 
  139.    --  Since: gtk+ 2.10 
  140.    --  "ppd_name": a PPD paper name 
  141.    --  "ppd_display_name": the corresponding human-readable name 
  142.    --  "width": the paper width, in points 
  143.    --  "height": the paper height in points 
  144.  
  145.    function Gtk_Paper_Size_New_From_Ppd 
  146.       (Ppd_Name         : UTF8_String; 
  147.        Ppd_Display_Name : UTF8_String; 
  148.        Width            : Gdouble; 
  149.        Height           : Gdouble) return Gtk_Paper_Size; 
  150.    --  Creates a new Gtk.Paper_Size.Gtk_Paper_Size object by using PPD 
  151.    --  information. 
  152.    --  If Ppd_Name is not a recognized PPD paper name, Ppd_Display_Name, Width 
  153.    --  and Height are used to construct a custom Gtk.Paper_Size.Gtk_Paper_Size 
  154.    --  object. 
  155.    --  Since: gtk+ 2.10 
  156.    --  "ppd_name": a PPD paper name 
  157.    --  "ppd_display_name": the corresponding human-readable name 
  158.    --  "width": the paper width, in points 
  159.    --  "height": the paper height in points 
  160.  
  161.    function Get_Type return Glib.GType; 
  162.    pragma Import (C, Get_Type, "gtk_paper_size_get_type"); 
  163.  
  164.    ------------- 
  165.    -- Methods -- 
  166.    ------------- 
  167.  
  168.    function Copy (Widget : Gtk_Paper_Size) return Gtk_Paper_Size; 
  169.    --  Copies an existing Gtk.Paper_Size.Gtk_Paper_Size. 
  170.    --  Since: gtk+ 2.10 
  171.  
  172.    procedure Free (Widget : Gtk_Paper_Size); 
  173.    --  Free the given Gtk.Paper_Size.Gtk_Paper_Size object. 
  174.    --  Since: gtk+ 2.10 
  175.  
  176.    function Get_Default_Bottom_Margin 
  177.       (Widget : Gtk_Paper_Size; 
  178.        Unit   : Gtk.Enums.Gtk_Unit) return Gdouble; 
  179.    --  Gets the default bottom margin for the Gtk.Paper_Size.Gtk_Paper_Size. 
  180.    --  Since: gtk+ 2.10 
  181.    --  "unit": the unit for the return value, not Gtk.Enums.None 
  182.  
  183.    function Get_Default_Left_Margin 
  184.       (Widget : Gtk_Paper_Size; 
  185.        Unit   : Gtk.Enums.Gtk_Unit) return Gdouble; 
  186.    --  Gets the default left margin for the Gtk.Paper_Size.Gtk_Paper_Size. 
  187.    --  Since: gtk+ 2.10 
  188.    --  "unit": the unit for the return value, not Gtk.Enums.None 
  189.  
  190.    function Get_Default_Right_Margin 
  191.       (Widget : Gtk_Paper_Size; 
  192.        Unit   : Gtk.Enums.Gtk_Unit) return Gdouble; 
  193.    --  Gets the default right margin for the Gtk.Paper_Size.Gtk_Paper_Size. 
  194.    --  Since: gtk+ 2.10 
  195.    --  "unit": the unit for the return value, not Gtk.Enums.None 
  196.  
  197.    function Get_Default_Top_Margin 
  198.       (Widget : Gtk_Paper_Size; 
  199.        Unit   : Gtk.Enums.Gtk_Unit) return Gdouble; 
  200.    --  Gets the default top margin for the Gtk.Paper_Size.Gtk_Paper_Size. 
  201.    --  Since: gtk+ 2.10 
  202.    --  "unit": the unit for the return value, not Gtk.Enums.None 
  203.  
  204.    function Get_Display_Name (Widget : Gtk_Paper_Size) return UTF8_String; 
  205.    --  Gets the human-readable name of the Gtk.Paper_Size.Gtk_Paper_Size. 
  206.    --  Since: gtk+ 2.10 
  207.  
  208.    function Get_Height 
  209.       (Widget : Gtk_Paper_Size; 
  210.        Unit   : Gtk.Enums.Gtk_Unit) return Gdouble; 
  211.    --  Gets the paper height of the Gtk.Paper_Size.Gtk_Paper_Size, in units of 
  212.    --  Unit. 
  213.    --  Since: gtk+ 2.10 
  214.    --  "unit": the unit for the return value, not Gtk.Enums.None 
  215.  
  216.    function Get_Name (Widget : Gtk_Paper_Size) return UTF8_String; 
  217.    --  Gets the name of the Gtk.Paper_Size.Gtk_Paper_Size. 
  218.    --  Since: gtk+ 2.10 
  219.  
  220.    function Get_Ppd_Name (Widget : Gtk_Paper_Size) return UTF8_String; 
  221.    --  Gets the PPD name of the Gtk.Paper_Size.Gtk_Paper_Size, which may be 
  222.    --  null. 
  223.    --  Since: gtk+ 2.10 
  224.  
  225.    function Get_Width 
  226.       (Widget : Gtk_Paper_Size; 
  227.        Unit   : Gtk.Enums.Gtk_Unit) return Gdouble; 
  228.    --  Gets the paper width of the Gtk.Paper_Size.Gtk_Paper_Size, in units of 
  229.    --  Unit. 
  230.    --  Since: gtk+ 2.10 
  231.    --  "unit": the unit for the return value, not Gtk.Enums.None 
  232.  
  233.    function Is_Custom (Widget : Gtk_Paper_Size) return Boolean; 
  234.    --  Returns True if Size is not a standard paper size. 
  235.  
  236.    function Is_Equal 
  237.       (Widget : Gtk_Paper_Size; 
  238.        Size2  : Gtk_Paper_Size) return Boolean; 
  239.    --  Compares two Gtk.Paper_Size.Gtk_Paper_Size objects. 
  240.    --  Since: gtk+ 2.10 
  241.    --  "size2": another Gtk.Paper_Size.Gtk_Paper_Size object 
  242.  
  243.    procedure Set_Size 
  244.       (Widget : Gtk_Paper_Size; 
  245.        Width  : Gdouble; 
  246.        Height : Gdouble; 
  247.        Unit   : Gtk.Enums.Gtk_Unit); 
  248.    --  Changes the dimensions of a Size to Width x Height. 
  249.    --  Since: gtk+ 2.10 
  250.    --  "width": the new width in units of Unit 
  251.    --  "height": the new height in units of Unit 
  252.    --  "unit": the unit for Width and Height 
  253.  
  254.    procedure To_Key_File 
  255.       (Widget     : Gtk_Paper_Size; 
  256.        Key_File   : Glib.Key_File.G_Key_File; 
  257.        Group_Name : UTF8_String); 
  258.    --  This function adds the paper size from Size to Key_File. 
  259.    --  Since: gtk+ 2.12 
  260.    --  "key_file": the Gkey.File.Gkey_File to save the paper size to 
  261.    --  "group_name": the group to add the settings to in Key_File 
  262.  
  263.    ---------------------- 
  264.    -- GtkAda additions -- 
  265.    ---------------------- 
  266.  
  267.    --  Common names, from PWG 5101.1-2002 PWG: Standard for Media Standardized 
  268.    --  Names 
  269.    Gtk_Paper_Name_A3        : constant String := "iso_a3"; 
  270.    Gtk_Paper_Name_A4        : constant String := "iso_a4"; 
  271.    Gtk_Paper_Name_A5        : constant String := "iso_a5"; 
  272.    Gtk_Paper_Name_B5        : constant String := "iso_b5"; 
  273.    Gtk_Paper_Name_Letter    : constant String := "na_letter"; 
  274.    Gtk_Paper_Name_Executive : constant String := "na_executive"; 
  275.    Gtk_Paper_Name_Legal     : constant String := "na_legal"; 
  276.  
  277.    --------------- 
  278.    -- Functions -- 
  279.    --------------- 
  280.  
  281.    function Convert (R : Gtk.Paper_Size.Gtk_Paper_Size) return System.Address; 
  282.    function Convert (R : System.Address) return Gtk.Paper_Size.Gtk_Paper_Size; 
  283.    package Gtk_Paper_Size_Glist is new Generic_List (Gtk.Paper_Size.Gtk_Paper_Size); 
  284.  
  285.    function Get_Default return UTF8_String; 
  286.    --  Returns the name of the default paper size, which depends on the 
  287.    --  current locale. 
  288.    --  Since: gtk+ 2.10 
  289.  
  290.    function Get_Paper_Sizes 
  291.       (Include_Custom : Boolean) return Gtk_Paper_Size_Glist.Glist; 
  292.    --  Creates a list of known paper sizes. 
  293.    --  Since: gtk+ 2.12 
  294.    --  "include_custom": whether to include custom paper sizes as defined in 
  295.    --  the page setup dialog 
  296.  
  297. private 
  298.  
  299.    Null_Gtk_Paper_Size : constant Gtk_Paper_Size := (Glib.C_Boxed with null record); 
  300.  
  301. end Gtk.Paper_Size;