PageRenderTime 50ms CodeModel.GetById 20ms RepoModel.GetById 1ms app.codeStats 0ms

/generated/gtkd/gtk/PaperSize.d

http://github.com/gtkd-developers/GtkD
D | 562 lines | 193 code | 57 blank | 312 comment | 16 complexity | 227db240d1b362368d75ade1726aeba1 MD5 | raw file
Possible License(s): LGPL-3.0
  1. /*
  2. * This file is part of gtkD.
  3. *
  4. * gtkD is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU Lesser General Public License
  6. * as published by the Free Software Foundation; either version 3
  7. * of the License, or (at your option) any later version, with
  8. * some exceptions, please read the COPYING file.
  9. *
  10. * gtkD is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU Lesser General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU Lesser General Public License
  16. * along with gtkD; if not, write to the Free Software
  17. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
  18. */
  19. // generated automatically - do not change
  20. // find conversion definition on APILookup.txt
  21. // implement new conversion functionalities on the wrap.utils pakage
  22. module gtk.PaperSize;
  23. private import glib.ConstructionException;
  24. private import glib.ErrorG;
  25. private import glib.GException;
  26. private import glib.KeyFile;
  27. private import glib.ListG;
  28. private import glib.Str;
  29. private import glib.Variant;
  30. private import gobject.ObjectG;
  31. private import gtk.c.functions;
  32. public import gtk.c.types;
  33. public import gtkc.gtktypes;
  34. private import gtkd.Loader;
  35. /**
  36. * GtkPaperSize handles paper sizes. It uses the standard called
  37. * [PWG 5101.1-2002 PWG: Standard for Media Standardized Names](http://www.pwg.org/standards.html)
  38. * to name the paper sizes (and to get the data for the page sizes).
  39. * In addition to standard paper sizes, GtkPaperSize allows to
  40. * construct custom paper sizes with arbitrary dimensions.
  41. *
  42. * The #GtkPaperSize object stores not only the dimensions (width
  43. * and height) of a paper size and its name, it also provides
  44. * default [print margins][print-margins].
  45. *
  46. * Printing support has been added in GTK+ 2.10.
  47. */
  48. public class PaperSize
  49. {
  50. /** the main Gtk struct */
  51. protected GtkPaperSize* gtkPaperSize;
  52. protected bool ownedRef;
  53. /** Get the main Gtk struct */
  54. public GtkPaperSize* getPaperSizeStruct(bool transferOwnership = false)
  55. {
  56. if (transferOwnership)
  57. ownedRef = false;
  58. return gtkPaperSize;
  59. }
  60. /** the main Gtk struct as a void* */
  61. protected void* getStruct()
  62. {
  63. return cast(void*)gtkPaperSize;
  64. }
  65. /**
  66. * Sets our main struct and passes it to the parent class.
  67. */
  68. public this (GtkPaperSize* gtkPaperSize, bool ownedRef = false)
  69. {
  70. this.gtkPaperSize = gtkPaperSize;
  71. this.ownedRef = ownedRef;
  72. }
  73. ~this ()
  74. {
  75. if ( Linker.isLoaded(LIBRARY_GTK) && ownedRef )
  76. gtk_paper_size_free(gtkPaperSize);
  77. }
  78. /** */
  79. public static GType getType()
  80. {
  81. return gtk_paper_size_get_type();
  82. }
  83. /**
  84. * Creates a new #GtkPaperSize object by parsing a
  85. * [PWG 5101.1-2002](ftp://ftp.pwg.org/pub/pwg/candidates/cs-pwgmsn10-20020226-5101.1.pdf)
  86. * paper name.
  87. *
  88. * If @name is %NULL, the default paper size is returned,
  89. * see gtk_paper_size_get_default().
  90. *
  91. * Params:
  92. * name = a paper size name, or %NULL
  93. *
  94. * Returns: a new #GtkPaperSize, use gtk_paper_size_free()
  95. * to free it
  96. *
  97. * Since: 2.10
  98. *
  99. * Throws: ConstructionException GTK+ fails to create the object.
  100. */
  101. public this(string name)
  102. {
  103. auto p = gtk_paper_size_new(Str.toStringz(name));
  104. if(p is null)
  105. {
  106. throw new ConstructionException("null returned by new");
  107. }
  108. this(cast(GtkPaperSize*) p);
  109. }
  110. /**
  111. * Creates a new #GtkPaperSize object with the
  112. * given parameters.
  113. *
  114. * Params:
  115. * name = the paper name
  116. * displayName = the human-readable name
  117. * width = the paper width, in units of @unit
  118. * height = the paper height, in units of @unit
  119. * unit = the unit for @width and @height. not %GTK_UNIT_NONE.
  120. *
  121. * Returns: a new #GtkPaperSize object, use gtk_paper_size_free()
  122. * to free it
  123. *
  124. * Since: 2.10
  125. *
  126. * Throws: ConstructionException GTK+ fails to create the object.
  127. */
  128. public this(string name, string displayName, double width, double height, GtkUnit unit)
  129. {
  130. auto p = gtk_paper_size_new_custom(Str.toStringz(name), Str.toStringz(displayName), width, height, unit);
  131. if(p is null)
  132. {
  133. throw new ConstructionException("null returned by new_custom");
  134. }
  135. this(cast(GtkPaperSize*) p);
  136. }
  137. /**
  138. * Deserialize a paper size from an a{sv} variant in
  139. * the format produced by gtk_paper_size_to_gvariant().
  140. *
  141. * Params:
  142. * variant = an a{sv} #GVariant
  143. *
  144. * Returns: a new #GtkPaperSize object
  145. *
  146. * Since: 3.22
  147. *
  148. * Throws: ConstructionException GTK+ fails to create the object.
  149. */
  150. public this(Variant variant)
  151. {
  152. auto p = gtk_paper_size_new_from_gvariant((variant is null) ? null : variant.getVariantStruct());
  153. if(p is null)
  154. {
  155. throw new ConstructionException("null returned by new_from_gvariant");
  156. }
  157. this(cast(GtkPaperSize*) p);
  158. }
  159. /**
  160. * Creates a new #GtkPaperSize object by using
  161. * IPP information.
  162. *
  163. * If @ipp_name is not a recognized paper name,
  164. * @width and @height are used to
  165. * construct a custom #GtkPaperSize object.
  166. *
  167. * Params:
  168. * ippName = an IPP paper name
  169. * width = the paper width, in points
  170. * height = the paper height in points
  171. *
  172. * Returns: a new #GtkPaperSize, use gtk_paper_size_free()
  173. * to free it
  174. *
  175. * Since: 3.16
  176. *
  177. * Throws: ConstructionException GTK+ fails to create the object.
  178. */
  179. public this(string ippName, double width, double height)
  180. {
  181. auto p = gtk_paper_size_new_from_ipp(Str.toStringz(ippName), width, height);
  182. if(p is null)
  183. {
  184. throw new ConstructionException("null returned by new_from_ipp");
  185. }
  186. this(cast(GtkPaperSize*) p);
  187. }
  188. /**
  189. * Reads a paper size from the group @group_name in the key file
  190. * @key_file.
  191. *
  192. * Params:
  193. * keyFile = the #GKeyFile to retrieve the papersize from
  194. * groupName = the name of the group in the key file to read,
  195. * or %NULL to read the first group
  196. *
  197. * Returns: a new #GtkPaperSize object with the restored
  198. * paper size, or %NULL if an error occurred
  199. *
  200. * Since: 2.12
  201. *
  202. * Throws: GException on failure.
  203. * Throws: ConstructionException GTK+ fails to create the object.
  204. */
  205. public this(KeyFile keyFile, string groupName)
  206. {
  207. GError* err = null;
  208. auto p = gtk_paper_size_new_from_key_file((keyFile is null) ? null : keyFile.getKeyFileStruct(), Str.toStringz(groupName), &err);
  209. if (err !is null)
  210. {
  211. throw new GException( new ErrorG(err) );
  212. }
  213. if(p is null)
  214. {
  215. throw new ConstructionException("null returned by new_from_key_file");
  216. }
  217. this(cast(GtkPaperSize*) p);
  218. }
  219. /**
  220. * Creates a new #GtkPaperSize object by using
  221. * PPD information.
  222. *
  223. * If @ppd_name is not a recognized PPD paper name,
  224. * @ppd_display_name, @width and @height are used to
  225. * construct a custom #GtkPaperSize object.
  226. *
  227. * Params:
  228. * ppdName = a PPD paper name
  229. * ppdDisplayName = the corresponding human-readable name
  230. * width = the paper width, in points
  231. * height = the paper height in points
  232. *
  233. * Returns: a new #GtkPaperSize, use gtk_paper_size_free()
  234. * to free it
  235. *
  236. * Since: 2.10
  237. *
  238. * Throws: ConstructionException GTK+ fails to create the object.
  239. */
  240. public this(string ppdName, string ppdDisplayName, double width, double height)
  241. {
  242. auto p = gtk_paper_size_new_from_ppd(Str.toStringz(ppdName), Str.toStringz(ppdDisplayName), width, height);
  243. if(p is null)
  244. {
  245. throw new ConstructionException("null returned by new_from_ppd");
  246. }
  247. this(cast(GtkPaperSize*) p);
  248. }
  249. /**
  250. * Copies an existing #GtkPaperSize.
  251. *
  252. * Returns: a copy of @other
  253. *
  254. * Since: 2.10
  255. */
  256. public PaperSize copy()
  257. {
  258. auto p = gtk_paper_size_copy(gtkPaperSize);
  259. if(p is null)
  260. {
  261. return null;
  262. }
  263. return ObjectG.getDObject!(PaperSize)(cast(GtkPaperSize*) p, true);
  264. }
  265. /**
  266. * Free the given #GtkPaperSize object.
  267. *
  268. * Since: 2.10
  269. */
  270. public void free()
  271. {
  272. gtk_paper_size_free(gtkPaperSize);
  273. ownedRef = false;
  274. }
  275. /**
  276. * Gets the default bottom margin for the #GtkPaperSize.
  277. *
  278. * Params:
  279. * unit = the unit for the return value, not %GTK_UNIT_NONE
  280. *
  281. * Returns: the default bottom margin
  282. *
  283. * Since: 2.10
  284. */
  285. public double getDefaultBottomMargin(GtkUnit unit)
  286. {
  287. return gtk_paper_size_get_default_bottom_margin(gtkPaperSize, unit);
  288. }
  289. /**
  290. * Gets the default left margin for the #GtkPaperSize.
  291. *
  292. * Params:
  293. * unit = the unit for the return value, not %GTK_UNIT_NONE
  294. *
  295. * Returns: the default left margin
  296. *
  297. * Since: 2.10
  298. */
  299. public double getDefaultLeftMargin(GtkUnit unit)
  300. {
  301. return gtk_paper_size_get_default_left_margin(gtkPaperSize, unit);
  302. }
  303. /**
  304. * Gets the default right margin for the #GtkPaperSize.
  305. *
  306. * Params:
  307. * unit = the unit for the return value, not %GTK_UNIT_NONE
  308. *
  309. * Returns: the default right margin
  310. *
  311. * Since: 2.10
  312. */
  313. public double getDefaultRightMargin(GtkUnit unit)
  314. {
  315. return gtk_paper_size_get_default_right_margin(gtkPaperSize, unit);
  316. }
  317. /**
  318. * Gets the default top margin for the #GtkPaperSize.
  319. *
  320. * Params:
  321. * unit = the unit for the return value, not %GTK_UNIT_NONE
  322. *
  323. * Returns: the default top margin
  324. *
  325. * Since: 2.10
  326. */
  327. public double getDefaultTopMargin(GtkUnit unit)
  328. {
  329. return gtk_paper_size_get_default_top_margin(gtkPaperSize, unit);
  330. }
  331. /**
  332. * Gets the human-readable name of the #GtkPaperSize.
  333. *
  334. * Returns: the human-readable name of @size
  335. *
  336. * Since: 2.10
  337. */
  338. public string getDisplayName()
  339. {
  340. return Str.toString(gtk_paper_size_get_display_name(gtkPaperSize));
  341. }
  342. /**
  343. * Gets the paper height of the #GtkPaperSize, in
  344. * units of @unit.
  345. *
  346. * Params:
  347. * unit = the unit for the return value, not %GTK_UNIT_NONE
  348. *
  349. * Returns: the paper height
  350. *
  351. * Since: 2.10
  352. */
  353. public double getHeight(GtkUnit unit)
  354. {
  355. return gtk_paper_size_get_height(gtkPaperSize, unit);
  356. }
  357. /**
  358. * Gets the name of the #GtkPaperSize.
  359. *
  360. * Returns: the name of @size
  361. *
  362. * Since: 2.10
  363. */
  364. public string getName()
  365. {
  366. return Str.toString(gtk_paper_size_get_name(gtkPaperSize));
  367. }
  368. /**
  369. * Gets the PPD name of the #GtkPaperSize, which
  370. * may be %NULL.
  371. *
  372. * Returns: the PPD name of @size
  373. *
  374. * Since: 2.10
  375. */
  376. public string getPpdName()
  377. {
  378. return Str.toString(gtk_paper_size_get_ppd_name(gtkPaperSize));
  379. }
  380. /**
  381. * Gets the paper width of the #GtkPaperSize, in
  382. * units of @unit.
  383. *
  384. * Params:
  385. * unit = the unit for the return value, not %GTK_UNIT_NONE
  386. *
  387. * Returns: the paper width
  388. *
  389. * Since: 2.10
  390. */
  391. public double getWidth(GtkUnit unit)
  392. {
  393. return gtk_paper_size_get_width(gtkPaperSize, unit);
  394. }
  395. /**
  396. * Returns %TRUE if @size is not a standard paper size.
  397. *
  398. * Returns: whether @size is a custom paper size.
  399. */
  400. public bool isCustom()
  401. {
  402. return gtk_paper_size_is_custom(gtkPaperSize) != 0;
  403. }
  404. /**
  405. * Compares two #GtkPaperSize objects.
  406. *
  407. * Params:
  408. * size2 = another #GtkPaperSize object
  409. *
  410. * Returns: %TRUE, if @size1 and @size2
  411. * represent the same paper size
  412. *
  413. * Since: 2.10
  414. */
  415. public bool isEqual(PaperSize size2)
  416. {
  417. return gtk_paper_size_is_equal(gtkPaperSize, (size2 is null) ? null : size2.getPaperSizeStruct()) != 0;
  418. }
  419. /**
  420. * Returns %TRUE if @size is an IPP standard paper size.
  421. *
  422. * Returns: whether @size is not an IPP custom paper size.
  423. */
  424. public bool isIpp()
  425. {
  426. return gtk_paper_size_is_ipp(gtkPaperSize) != 0;
  427. }
  428. /**
  429. * Changes the dimensions of a @size to @width x @height.
  430. *
  431. * Params:
  432. * width = the new width in units of @unit
  433. * height = the new height in units of @unit
  434. * unit = the unit for @width and @height
  435. *
  436. * Since: 2.10
  437. */
  438. public void setSize(double width, double height, GtkUnit unit)
  439. {
  440. gtk_paper_size_set_size(gtkPaperSize, width, height, unit);
  441. }
  442. /**
  443. * Serialize a paper size to an a{sv} variant.
  444. *
  445. * Returns: a new, floating, #GVariant
  446. *
  447. * Since: 3.22
  448. */
  449. public Variant toGvariant()
  450. {
  451. auto p = gtk_paper_size_to_gvariant(gtkPaperSize);
  452. if(p is null)
  453. {
  454. return null;
  455. }
  456. return new Variant(cast(GVariant*) p);
  457. }
  458. /**
  459. * This function adds the paper size from @size to @key_file.
  460. *
  461. * Params:
  462. * keyFile = the #GKeyFile to save the paper size to
  463. * groupName = the group to add the settings to in @key_file
  464. *
  465. * Since: 2.12
  466. */
  467. public void toKeyFile(KeyFile keyFile, string groupName)
  468. {
  469. gtk_paper_size_to_key_file(gtkPaperSize, (keyFile is null) ? null : keyFile.getKeyFileStruct(), Str.toStringz(groupName));
  470. }
  471. /**
  472. * Returns the name of the default paper size, which
  473. * depends on the current locale.
  474. *
  475. * Returns: the name of the default paper size. The string
  476. * is owned by GTK+ and should not be modified.
  477. *
  478. * Since: 2.10
  479. */
  480. public static string getDefault()
  481. {
  482. return Str.toString(gtk_paper_size_get_default());
  483. }
  484. /**
  485. * Creates a list of known paper sizes.
  486. *
  487. * Params:
  488. * includeCustom = whether to include custom paper sizes
  489. * as defined in the page setup dialog
  490. *
  491. * Returns: a newly allocated list of newly
  492. * allocated #GtkPaperSize objects
  493. *
  494. * Since: 2.12
  495. */
  496. public static ListG getPaperSizes(bool includeCustom)
  497. {
  498. auto p = gtk_paper_size_get_paper_sizes(includeCustom);
  499. if(p is null)
  500. {
  501. return null;
  502. }
  503. return new ListG(cast(GList*) p, true);
  504. }
  505. }