/src/wrappers/gtk/library/gtk_paper_size.e

http://github.com/tybor/Liberty · Specman e · 225 lines · 138 code · 42 blank · 45 comment · 6 complexity · d8acfe12cd75a53f0ada2dda3200182f MD5 · raw file

  1. indexing
  2. description: "Named paper sizes."
  3. copyright: "[
  4. Copyright (C) 2007 Paolo Redaelli, GTK+ team
  5. This library is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU Lesser General Public License
  7. as published by the Free Software Foundation; either version 2.1 of
  8. the License, or (at your option) any later version.
  9. This library is distributed in the hopeOA that it will be useful, but
  10. WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. Lesser General Public License for more details.
  13. You should have received a copy of the GNU Lesser General Public
  14. License along with this library; if not, write to the Free Software
  15. Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  16. 02110-1301 USA
  17. ]"
  18. wrapped_version: "2.10.6"
  19. class GTK_PAPER_SIZE
  20. -- GtkPaperSize handles paper sizes. It uses the standard called
  21. -- "PWG 5101.1-2002 PWG: Standard for Media Standardized Names" to
  22. -- name the paper sizes (and to get the data for the page
  23. -- sizes). In addition to standard paper sizes, GtkPaperSize allows
  24. -- to construct custom paper sizes with arbitrary dimensions.
  25. -- The GtkPaperSize object stores not only the dimensions (width
  26. -- and height) of a paper size and its name, it also provides
  27. -- default print margins.
  28. -- Printing support has been added in GTK+ 2.10.
  29. inherit
  30. C_STRUCT
  31. undefine free
  32. redefine copy, is_equal
  33. end
  34. EIFFEL_OWNED undefine free end
  35. insert
  36. GTK_PAPER_SIZE_EXTERNALS rename gtk_paper_size_free as free end
  37. GTK_UNIT
  38. creation make, from_external_pointer
  39. feature {} -- Creation
  40. make (a_paper_name: STRING) is
  41. -- Creates a new GtkPaperSize object by parsing a PWG
  42. -- 5101.1-2002 PWG `a_paper_name'.
  43. require name_not_void: a_paper_name /= Void
  44. do
  45. from_external_pointer(gtk_paper_size_new(a_paper_name.to_external))
  46. end
  47. make_default is
  48. -- Creates a new GtkPaperSize object for the default paper
  49. -- size.
  50. do
  51. from_external_pointer(gtk_paper_size_new(default_pointer))
  52. end
  53. from_ppd (a_ppd_name, a_ppd_display_name: STRING; a_width, an_height: REAL) is
  54. -- Creates a new GtkPaperSize object by using PPD
  55. -- information.
  56. -- If `a_ppd_name' is not a recognized PPD paper name,
  57. -- `a_ppd_display_name,' `a_width' and `an_height' are used
  58. -- to construct a custom GtkPaperSize object.
  59. -- `a_ppd_name' a PPD paper name
  60. -- `a_ppd_display_name' the corresponding human-readable name
  61. -- `a_width' : the paper width, in points
  62. -- `an_height' : the paper height in points
  63. require
  64. name_not_void: a_ppd_name /= Void
  65. display_name_not_void: a_ppd_display_name /= Void
  66. do
  67. from_external_pointer (gtk_paper_size_new_from_ppd
  68. (a_ppd_name.to_external, a_ppd_display_name.to_external,
  69. a_width, an_height))
  70. end
  71. make_custom (a_name, a_display_name: STRING; a_width, an_height: REAL; a_unit: INTEGER) is
  72. -- Creates a new GtkPaperSize object with the given
  73. -- parameters.
  74. -- `a_name' : the paper name
  75. -- `a_display_name' : the human-readable name
  76. -- `a_width' : the paper width, in units of `a_unit'
  77. -- `an_height' : the paper height, in units of `a_unit'
  78. -- `a_unit' : the unit for `a_width' and `an_height'
  79. require
  80. name_not_void: a_name /= Void
  81. display_name_not_void: a_display_name /= Void
  82. valid_unit: is_valid_gtk_unit (a_unit)
  83. do
  84. from_external_pointer(gtk_paper_size_new_custom
  85. (a_name.to_external, a_display_name.to_external,
  86. a_width, an_height, a_unit))
  87. end
  88. feature -- Copying
  89. copy (another: GTK_PAPER_SIZE) is
  90. -- Copies an existing GtkPaperSize.
  91. do
  92. from_external_pointer(gtk_paper_size_copy(another.handle))
  93. end
  94. feature -- Queries
  95. is_equal (another: GTK_PAPER_SIZE): BOOLEAN is
  96. -- Do Current and `another' represent the same paper size?
  97. do
  98. Result:=gtk_paper_size_is_equal(handle, another.handle).to_boolean
  99. end
  100. name: CONST_STRING is
  101. -- the name of the GtkPaperSize.
  102. do
  103. if stored_name=Void then
  104. create stored_name.from_external (gtk_paper_size_get_name(handle))
  105. end
  106. Result:=stored_name
  107. end
  108. display_name: CONST_STRING is
  109. -- the human-readable name of the GtkPaperSize.
  110. do
  111. if stored_display_name=Void then
  112. create stored_display_name.from_external (gtk_paper_size_get_display_name(handle))
  113. end
  114. Result:=stored_display_name
  115. end
  116. ppd_name:CONST_STRING is
  117. -- the PPD name of the GtkPaperSize, which may be Void.
  118. local ptr: POINTER
  119. do
  120. if not ppd_name_retrieved then
  121. ptr:=gtk_paper_size_get_ppd_name(handle)
  122. if ptr.is_not_null then
  123. create stored_ppd_name.from_external(ptr)
  124. end
  125. ppd_name_retrieved:=True
  126. end
  127. Result:=stored_ppd_name
  128. end
  129. unit: INTEGER
  130. -- the unit measure for all the further queries
  131. width: REAL is
  132. -- the paper width of the GtkPaperSize
  133. do
  134. Result:=gtk_paper_size_get_width(handle, unit)
  135. end
  136. height: REAL is
  137. -- the paper height of the GtkPaperSize
  138. do
  139. Result:=gtk_paper_size_get_height(handle, unit)
  140. end
  141. is_custom: BOOLEAN is
  142. -- Is size not a standard paper size?
  143. do
  144. Result:=gtk_paper_size_is_custom(handle).to_boolean
  145. end
  146. default_top_margin: REAL is
  147. -- The default top margin for the GtkPaperSize.
  148. do
  149. Result:=gtk_paper_size_get_default_top_margin(handle,unit)
  150. end
  151. default_bottom_margin: REAL is
  152. -- the default bottom margin for the GtkPaperSize.
  153. do
  154. Result:=gtk_paper_size_get_default_bottom_margin(handle,unit)
  155. end
  156. default_left_margin: REAL is
  157. -- the default left margin for the GtkPaperSize.
  158. do
  159. Result:=gtk_paper_size_get_default_left_margin(handle, unit)
  160. end
  161. default_right_margin: REAL is
  162. -- the default right margin for the GtkPaperSize.
  163. do
  164. Result:=gtk_paper_size_get_default_right_margin(handle,unit)
  165. end
  166. feature -- Setters
  167. set_unit (a_unit: INTEGER) is
  168. -- Set the unit measure for all the further queries
  169. do
  170. unit:=a_unit
  171. ensure set: unit = a_unit
  172. end
  173. set_size (a_width, an_height: REAL; a_unit: INTEGER) is
  174. -- Changes the dimensions of a size to `a_width' x `an_height',
  175. -- expressed in `a_unit'.
  176. require valid_unit: is_valid_gtk_unit(a_unit)
  177. do
  178. gtk_paper_size_set_size(handle, a_width, an_height, a_unit)
  179. end
  180. feature {} -- Implementation
  181. stored_name, stored_display_name, stored_ppd_name: CONST_STRING
  182. ppd_name_retrieved: BOOLEAN
  183. end -- class GTK_PAPER_SIZE