1. ----------------------------------------------------------------------- 
  2. --               GtkAda - Ada95 binding for Gtk+/Gnome               -- 
  3. --                                                                   -- 
  4. --                    Copyright (C) 2010, AdaCore                    -- 
  5. --                                                                   -- 
  6. -- This library is free software; you can redistribute it and/or     -- 
  7. -- modify it under the terms of the GNU General Public               -- 
  8. -- License as published by the Free Software Foundation; either      -- 
  9. -- version 2 of the License, or (at your option) any later version.  -- 
  10. --                                                                   -- 
  11. -- This library is distributed in the hope that it will be useful,   -- 
  12. -- but WITHOUT ANY WARRANTY; without even the implied warranty of    -- 
  13. -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU -- 
  14. -- General Public License for more details.                          -- 
  15. --                                                                   -- 
  16. -- You should have received a copy of the GNU General Public         -- 
  17. -- License along with this library; if not, write to the             -- 
  18. -- Free Software Foundation, Inc., 59 Temple Place - Suite 330,      -- 
  19. -- Boston, MA 02111-1307, USA.                                       -- 
  20. --                                                                   -- 
  21. -- -- -- -- -- -- -- -- -- -- -- --
  22. ----------------------------------------------------------------------- 
  23.  
  24. --  <description> 
  25. --  Gtk_Paper_Size handles paper sizes. It uses the standard called 
  26. --  "PWG 5101.1-2002 PWG: Standard for Media Standardized Names" to name the 
  27. --  paper sizes (and to get the data for the page sizes). In addition to 
  28. --  standard paper sizes, Gtk_Paper_Size allows to construct custom paper 
  29. --  sizes with arbitrary dimensions. 
  30. -- 
  31. --  The Gtk_Paper_Size object stores not only the dimensions (width and height) 
  32. --  of a paper size and its name, it also provides default print margins. 
  33. --  </description> 
  34. --  <c_version>2.16.6</c_version> 
  35.  
  36. with Ada.Unchecked_Conversion; 
  37.  
  38. with Glib.Glist; 
  39. with Glib.Key_File; 
  40. with Gtk.Enums; 
  41.  
  42. package Gtk.Paper_Size is 
  43.  
  44.    type Gtk_Paper_Size is new Glib.C_Proxy; 
  45.  
  46.    function Convert is 
  47.      new Ada.Unchecked_Conversion (Gtk_Paper_Size, System.Address); 
  48.    function Convert is 
  49.      new Ada.Unchecked_Conversion (System.Address, Gtk_Paper_Size); 
  50.    package Gtk_Paper_Size_Glist is 
  51.      new Glib.Glist.Generic_List (Gtk_Paper_Size); 
  52.  
  53.    function Get_Type return GType; 
  54.  
  55.    procedure Gtk_New 
  56.      (Widget : out Gtk_Paper_Size; 
  57.       Name   : String); 
  58.    --  Creates a new Gtk_Paper_Size object by parsing a PWG 5101.1-2002 
  59.    --  paper name. 
  60.    -- 
  61.    --  If Name is "", the default paper size is returned; see Get_Default. 
  62.  
  63.    procedure Gtk_New_Custom 
  64.      (Widget       : out Gtk_Paper_Size; 
  65.       Name         : String; 
  66.       Display_Name : String; 
  67.       Width        : Gdouble; 
  68.       Height       : Gdouble; 
  69.       Unit         : Gtk.Enums.Gtk_Unit); 
  70.    --  Creates a new Gtk_Paper_Size object with the given parameters: 
  71.    -- 
  72.    --  Name:         the paper name 
  73.    --  Display_Name: the human-readable name 
  74.    --  Width:        the paper width, in units of Unit 
  75.    --  Height:       the paper height, in units of Unit 
  76.    --  Unit:         the unit for Width and Height 
  77.  
  78.    procedure Gtk_New_From_Key_File 
  79.      (Widget     : out Gtk_Paper_Size; 
  80.       Key_File   : Glib.Key_File.G_Key_File; 
  81.       Group_Name : String := ""); 
  82.    --  Reads a paper size from the group Group_Name in the key file 
  83.    --  Key_File.  Will set Widget to null in case of error. 
  84.  
  85.    procedure Gtk_New_From_Ppd 
  86.      (Widget           : out Gtk_Paper_Size; 
  87.       Ppd_Name         : String; 
  88.       Ppd_Display_Name : String := ""; 
  89.       Width            : Gdouble; 
  90.       Height           : Gdouble); 
  91.    --  Creates a new Gtk_Paper_Size object by using PPD information: 
  92.    -- 
  93.    --  Ppd_Name:         a PPD paper name 
  94.    --  Ppd_Display_Name: the corresponding human-readable name 
  95.    --  Width:            the paper width, in points 
  96.    --  Height:           the paper height in points 
  97.    -- 
  98.    --  If Ppd_Name is not a recognized PPD paper name, 
  99.    --  Ppd_Display_Name, Width and Height are used to 
  100.    --  construct a custom Gtk_Paper_Size object. 
  101.  
  102.    procedure To_Key_File 
  103.      (Size       : Gtk_Paper_Size; 
  104.       Key_File   : Glib.Key_File.G_Key_File; 
  105.       Group_Name : String := ""); 
  106.    --  This function adds the paper size from Size to Key_File, 
  107.    --  within the group Group_Name. 
  108.  
  109.    function Copy (Other : Gtk_Paper_Size) return Gtk_Paper_Size; 
  110.    --  Copies an existing Gtk_Paper_Size. 
  111.  
  112.    procedure Free (Size : Gtk_Paper_Size); 
  113.    --  Free the given Gtk_Paper_Size object. 
  114.  
  115.    function Get_Default return String; 
  116.    --  Returns the name of the default paper size, which 
  117.    --  depends on the current locale. 
  118.  
  119.    function Get_Name (Size : Gtk_Paper_Size) return String; 
  120.    --  Gets the name of the Gtk_Paper_Size. 
  121.  
  122.    function Get_Display_Name 
  123.      (Size : Gtk_Paper_Size) return String; 
  124.    --  Gets the human-readable name of the Gtk_Paper_Size. 
  125.  
  126.    function Get_Ppd_Name (Size : Gtk_Paper_Size) return String; 
  127.    --  Gets the PPD name of the Gtk_Paper_Size. 
  128.  
  129.    function Is_Custom (Size : Gtk_Paper_Size) return Boolean; 
  130.    --  Returns True if Size is not a standard paper size. 
  131.  
  132.    ----------- 
  133.    -- Sizes -- 
  134.    ----------- 
  135.  
  136.    function Get_Width 
  137.      (Size : Gtk_Paper_Size; 
  138.       Unit : Gtk.Enums.Gtk_Unit) 
  139.       return Gdouble; 
  140.    function Get_Height 
  141.      (Size : Gtk_Paper_Size; 
  142.       Unit : Gtk.Enums.Gtk_Unit) 
  143.       return Gdouble; 
  144.    --  Gets the paper width/height of the Gtk_Paper_Size, in units of Unit. 
  145.  
  146.    procedure Set_Size 
  147.      (Size   : Gtk_Paper_Size; 
  148.       Width  : Gdouble; 
  149.       Height : Gdouble; 
  150.       Unit   : Gtk.Enums.Gtk_Unit); 
  151.    --  Changes the dimensions of a Size to Width x Height. 
  152.  
  153.    function Get_Paper_Sizes 
  154.      (Include_Custom : Boolean) 
  155.       return Gtk_Paper_Size_Glist.Glist; 
  156.    --  Creates a list of known paper sizes.  The caller must specify whether 
  157.    --  to include custom paper sizes as defined in the page setup dialog 
  158.  
  159.    function "=" (Size1, Size2 : Gtk_Paper_Size) return Boolean; 
  160.    --  Compares two Gtk_Paper_Size objects. 
  161.  
  162.    ------------- 
  163.    -- Margins -- 
  164.    ------------- 
  165.  
  166.    function Get_Default_Bottom_Margin 
  167.      (Size : Gtk_Paper_Size; 
  168.       Unit : Gtk.Enums.Gtk_Unit) 
  169.       return Gdouble; 
  170.    function Get_Default_Left_Margin 
  171.      (Size : Gtk_Paper_Size; 
  172.       Unit : Gtk.Enums.Gtk_Unit) 
  173.       return Gdouble; 
  174.    function Get_Default_Right_Margin 
  175.      (Size : Gtk_Paper_Size; 
  176.       Unit : Gtk.Enums.Gtk_Unit) 
  177.       return Gdouble; 
  178.    function Get_Default_Top_Margin 
  179.      (Size : Gtk_Paper_Size; 
  180.       Unit : Gtk.Enums.Gtk_Unit) 
  181.       return Gdouble; 
  182.    --  Gets the default bottom/left/right/top margin for the Gtk_Paper_Size, 
  183.    --  using the units specified by Unit. 
  184.  
  185.    --  Common names, from PWG 5101.1-2002 PWG: Standard for Media Standardized 
  186.    --  Names 
  187.    Gtk_Paper_Name_A3        : constant String := "iso_a3"; 
  188.    Gtk_Paper_Name_A4        : constant String := "iso_a4"; 
  189.    Gtk_Paper_Name_A5        : constant String := "iso_a5"; 
  190.    Gtk_Paper_Name_B5        : constant String := "iso_b5"; 
  191.    Gtk_Paper_Name_Letter    : constant String := "na_letter"; 
  192.    Gtk_Paper_Name_Executive : constant String := "na_executive"; 
  193.    Gtk_Paper_Name_Legal     : constant String := "na_legal"; 
  194.  
  195. private 
  196.  
  197.    type Gtk_Paper_Size_Record is 
  198.      new Glib.Object.GObject_Record with null record; 
  199.  
  200.    pragma Import (C, Get_Type, "gtk_paper_size_get_type"); 
  201.    pragma Import (C, Copy, "gtk_paper_size_copy"); 
  202.    pragma Import (C, Free, "gtk_paper_size_free"); 
  203.    pragma Import (C, Get_Default_Bottom_Margin, 
  204.                   "gtk_paper_size_get_default_bottom_margin"); 
  205.    pragma Import (C, Get_Default_Left_Margin, 
  206.                   "gtk_paper_size_get_default_left_margin"); 
  207.    pragma Import (C, Get_Default_Right_Margin, 
  208.                   "gtk_paper_size_get_default_right_margin"); 
  209.    pragma Import (C, Get_Default_Top_Margin, 
  210.                   "gtk_paper_size_get_default_top_margin"); 
  211.    pragma Import (C, Get_Height, "gtk_paper_size_get_height"); 
  212.    pragma Import (C, Get_Width, "gtk_paper_size_get_width"); 
  213.    pragma Import (C, Set_Size, "gtk_paper_size_set_size"); 
  214.  
  215. end Gtk.Paper_Size;