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