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  
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 /*
25  * Conversion parameters:
26  * inFile  = GtkPaperSize.html
27  * outPack = gtk
28  * outFile = PaperSize
29  * strct   = GtkPaperSize
30  * realStrct=
31  * ctorStrct=
32  * clss    = PaperSize
33  * interf  = 
34  * class Code: No
35  * interface Code: No
36  * template for:
37  * extend  = 
38  * implements:
39  * prefixes:
40  * 	- gtk_paper_size_
41  * omit structs:
42  * omit prefixes:
43  * omit code:
44  * omit signals:
45  * imports:
46  * 	- glib.Str
47  * 	- glib.ErrorG
48  * 	- glib.GException
49  * 	- glib.ListG
50  * 	- glib.KeyFile
51  * structWrap:
52  * 	- GKeyFile* -> KeyFile
53  * 	- GList* -> ListG
54  * 	- GtkPaperSize* -> PaperSize
55  * module aliases:
56  * local aliases:
57  * overrides:
58  */
59 
60 module gtk.PaperSize;
61 
62 public  import gtkc.gtktypes;
63 
64 private import gtkc.gtk;
65 private import glib.ConstructionException;
66 private import gobject.ObjectG;
67 
68 
69 private import glib.Str;
70 private import glib.ErrorG;
71 private import glib.GException;
72 private import glib.ListG;
73 private import glib.KeyFile;
74 
75 
76 
77 private import gobject.Boxed;
78 
79 /**
80  * GtkPaperSize handles paper sizes. It uses the standard called
81  * "PWG 5101.1-2002 PWG: Standard for Media Standardized Names"
82  * to name the paper sizes (and to get the data for the page sizes).
83  * In addition to standard paper sizes, GtkPaperSize allows to
84  * construct custom paper sizes with arbitrary dimensions.
85  *
86  * The GtkPaperSize object stores not only the dimensions (width
87  * and height) of a paper size and its name, it also provides
88  * default print margins.
89  *
90  * Printing support has been added in GTK+ 2.10.
91  */
92 public class PaperSize : Boxed
93 {
94 	
95 	/** the main Gtk struct */
96 	protected GtkPaperSize* gtkPaperSize;
97 	
98 	
99 	public GtkPaperSize* getPaperSizeStruct()
100 	{
101 		return gtkPaperSize;
102 	}
103 	
104 	
105 	/** the main Gtk struct as a void* */
106 	protected void* getStruct()
107 	{
108 		return cast(void*)gtkPaperSize;
109 	}
110 	
111 	/**
112 	 * Sets our main struct and passes it to the parent class
113 	 */
114 	public this (GtkPaperSize* gtkPaperSize)
115 	{
116 		this.gtkPaperSize = gtkPaperSize;
117 	}
118 	
119 	/**
120 	 */
121 	
122 	/**
123 	 * Creates a new GtkPaperSize object by parsing a
124 	 * PWG 5101.1-2002
125 	 * paper name.
126 	 * If name is NULL, the default paper size is returned,
127 	 * see gtk_paper_size_get_default().
128 	 * Since 2.10
129 	 * Params:
130 	 * name = a paper size name, or NULL. [allow-none]
131 	 * Throws: ConstructionException GTK+ fails to create the object.
132 	 */
133 	public this (string name)
134 	{
135 		// GtkPaperSize * gtk_paper_size_new (const gchar *name);
136 		auto p = gtk_paper_size_new(Str.toStringz(name));
137 		if(p is null)
138 		{
139 			throw new ConstructionException("null returned by gtk_paper_size_new(Str.toStringz(name))");
140 		}
141 		this(cast(GtkPaperSize*) p);
142 	}
143 	
144 	/**
145 	 * Creates a new GtkPaperSize object by using
146 	 * PPD information.
147 	 * If ppd_name is not a recognized PPD paper name,
148 	 * ppd_display_name, width and height are used to
149 	 * construct a custom GtkPaperSize object.
150 	 * Since 2.10
151 	 * Params:
152 	 * ppdName = a PPD paper name
153 	 * ppdDisplayName = the corresponding human-readable name
154 	 * width = the paper width, in points
155 	 * height = the paper height in points
156 	 * Throws: ConstructionException GTK+ fails to create the object.
157 	 */
158 	public this (string ppdName, string ppdDisplayName, double width, double height)
159 	{
160 		// GtkPaperSize * gtk_paper_size_new_from_ppd (const gchar *ppd_name,  const gchar *ppd_display_name,  gdouble width,  gdouble height);
161 		auto p = gtk_paper_size_new_from_ppd(Str.toStringz(ppdName), Str.toStringz(ppdDisplayName), width, height);
162 		if(p is null)
163 		{
164 			throw new ConstructionException("null returned by gtk_paper_size_new_from_ppd(Str.toStringz(ppdName), Str.toStringz(ppdDisplayName), width, height)");
165 		}
166 		this(cast(GtkPaperSize*) p);
167 	}
168 	
169 	/**
170 	 * Creates a new GtkPaperSize object with the
171 	 * given parameters.
172 	 * Since 2.10
173 	 * Params:
174 	 * name = the paper name
175 	 * displayName = the human-readable name
176 	 * width = the paper width, in units of unit
177 	 * height = the paper height, in units of unit
178 	 * unit = the unit for width and height. not GTK_UNIT_NONE.
179 	 * Throws: ConstructionException GTK+ fails to create the object.
180 	 */
181 	public this (string name, string displayName, double width, double height, GtkUnit unit)
182 	{
183 		// GtkPaperSize * gtk_paper_size_new_custom (const gchar *name,  const gchar *display_name,  gdouble width,  gdouble height,  GtkUnit unit);
184 		auto p = gtk_paper_size_new_custom(Str.toStringz(name), Str.toStringz(displayName), width, height, unit);
185 		if(p is null)
186 		{
187 			throw new ConstructionException("null returned by gtk_paper_size_new_custom(Str.toStringz(name), Str.toStringz(displayName), width, height, unit)");
188 		}
189 		this(cast(GtkPaperSize*) p);
190 	}
191 	
192 	/**
193 	 * Copies an existing GtkPaperSize.
194 	 * Since 2.10
195 	 * Returns: a copy of other
196 	 */
197 	public PaperSize copy()
198 	{
199 		// GtkPaperSize * gtk_paper_size_copy (GtkPaperSize *other);
200 		auto p = gtk_paper_size_copy(gtkPaperSize);
201 		
202 		if(p is null)
203 		{
204 			return null;
205 		}
206 		
207 		return ObjectG.getDObject!(PaperSize)(cast(GtkPaperSize*) p);
208 	}
209 	
210 	/**
211 	 * Free the given GtkPaperSize object.
212 	 * Since 2.10
213 	 */
214 	public void free()
215 	{
216 		// void gtk_paper_size_free (GtkPaperSize *size);
217 		gtk_paper_size_free(gtkPaperSize);
218 	}
219 	
220 	/**
221 	 * Compares two GtkPaperSize objects.
222 	 * Since 2.10
223 	 * Params:
224 	 * size2 = another GtkPaperSize object
225 	 * Returns: TRUE, if size1 and size2 represent the same paper size
226 	 */
227 	public int isEqual(PaperSize size2)
228 	{
229 		// gboolean gtk_paper_size_is_equal (GtkPaperSize *size1,  GtkPaperSize *size2);
230 		return gtk_paper_size_is_equal(gtkPaperSize, (size2 is null) ? null : size2.getPaperSizeStruct());
231 	}
232 	
233 	/**
234 	 * Creates a list of known paper sizes.
235 	 * Since 2.12
236 	 * Params:
237 	 * includeCustom = whether to include custom paper sizes
238 	 * as defined in the page setup dialog
239 	 * Returns: a newly allocated list of newly allocated GtkPaperSize objects. [element-type GtkPaperSize][transfer full]
240 	 */
241 	public static ListG getPaperSizes(int includeCustom)
242 	{
243 		// GList * gtk_paper_size_get_paper_sizes (gboolean include_custom);
244 		auto p = gtk_paper_size_get_paper_sizes(includeCustom);
245 		
246 		if(p is null)
247 		{
248 			return null;
249 		}
250 		
251 		return ObjectG.getDObject!(ListG)(cast(GList*) p);
252 	}
253 	
254 	/**
255 	 * Gets the name of the GtkPaperSize.
256 	 * Since 2.10
257 	 * Returns: the name of size
258 	 */
259 	public string getName()
260 	{
261 		// const gchar * gtk_paper_size_get_name (GtkPaperSize *size);
262 		return Str.toString(gtk_paper_size_get_name(gtkPaperSize));
263 	}
264 	
265 	/**
266 	 * Gets the human-readable name of the GtkPaperSize.
267 	 * Since 2.10
268 	 * Returns: the human-readable name of size
269 	 */
270 	public string getDisplayName()
271 	{
272 		// const gchar * gtk_paper_size_get_display_name (GtkPaperSize *size);
273 		return Str.toString(gtk_paper_size_get_display_name(gtkPaperSize));
274 	}
275 	
276 	/**
277 	 * Gets the PPD name of the GtkPaperSize, which
278 	 * may be NULL.
279 	 * Since 2.10
280 	 * Returns: the PPD name of size
281 	 */
282 	public string getPpdName()
283 	{
284 		// const gchar * gtk_paper_size_get_ppd_name (GtkPaperSize *size);
285 		return Str.toString(gtk_paper_size_get_ppd_name(gtkPaperSize));
286 	}
287 	
288 	/**
289 	 * Gets the paper width of the GtkPaperSize, in
290 	 * units of unit.
291 	 * Since 2.10
292 	 * Params:
293 	 * unit = the unit for the return value, not GTK_UNIT_NONE
294 	 * Returns: the paper width
295 	 */
296 	public double getWidth(GtkUnit unit)
297 	{
298 		// gdouble gtk_paper_size_get_width (GtkPaperSize *size,  GtkUnit unit);
299 		return gtk_paper_size_get_width(gtkPaperSize, unit);
300 	}
301 	
302 	/**
303 	 * Gets the paper height of the GtkPaperSize, in
304 	 * units of unit.
305 	 * Since 2.10
306 	 * Params:
307 	 * unit = the unit for the return value, not GTK_UNIT_NONE
308 	 * Returns: the paper height
309 	 */
310 	public double getHeight(GtkUnit unit)
311 	{
312 		// gdouble gtk_paper_size_get_height (GtkPaperSize *size,  GtkUnit unit);
313 		return gtk_paper_size_get_height(gtkPaperSize, unit);
314 	}
315 	
316 	/**
317 	 * Returns TRUE if size is not a standard paper size.
318 	 * Returns: whether size is a custom paper size.
319 	 */
320 	public int isCustom()
321 	{
322 		// gboolean gtk_paper_size_is_custom (GtkPaperSize *size);
323 		return gtk_paper_size_is_custom(gtkPaperSize);
324 	}
325 	
326 	/**
327 	 * Changes the dimensions of a size to width x height.
328 	 * Since 2.10
329 	 * Params:
330 	 * width = the new width in units of unit
331 	 * height = the new height in units of unit
332 	 * unit = the unit for width and height
333 	 */
334 	public void setSize(double width, double height, GtkUnit unit)
335 	{
336 		// void gtk_paper_size_set_size (GtkPaperSize *size,  gdouble width,  gdouble height,  GtkUnit unit);
337 		gtk_paper_size_set_size(gtkPaperSize, width, height, unit);
338 	}
339 	
340 	/**
341 	 * Gets the default top margin for the GtkPaperSize.
342 	 * Since 2.10
343 	 * Params:
344 	 * unit = the unit for the return value, not GTK_UNIT_NONE
345 	 * Returns: the default top margin
346 	 */
347 	public double getDefaultTopMargin(GtkUnit unit)
348 	{
349 		// gdouble gtk_paper_size_get_default_top_margin  (GtkPaperSize *size,  GtkUnit unit);
350 		return gtk_paper_size_get_default_top_margin(gtkPaperSize, unit);
351 	}
352 	
353 	/**
354 	 * Gets the default bottom margin for the GtkPaperSize.
355 	 * Since 2.10
356 	 * Params:
357 	 * unit = the unit for the return value, not GTK_UNIT_NONE
358 	 * Returns: the default bottom margin
359 	 */
360 	public double getDefaultBottomMargin(GtkUnit unit)
361 	{
362 		// gdouble gtk_paper_size_get_default_bottom_margin  (GtkPaperSize *size,  GtkUnit unit);
363 		return gtk_paper_size_get_default_bottom_margin(gtkPaperSize, unit);
364 	}
365 	
366 	/**
367 	 * Gets the default left margin for the GtkPaperSize.
368 	 * Since 2.10
369 	 * Params:
370 	 * unit = the unit for the return value, not GTK_UNIT_NONE
371 	 * Returns: the default left margin
372 	 */
373 	public double getDefaultLeftMargin(GtkUnit unit)
374 	{
375 		// gdouble gtk_paper_size_get_default_left_margin  (GtkPaperSize *size,  GtkUnit unit);
376 		return gtk_paper_size_get_default_left_margin(gtkPaperSize, unit);
377 	}
378 	
379 	/**
380 	 * Gets the default right margin for the GtkPaperSize.
381 	 * Since 2.10
382 	 * Params:
383 	 * unit = the unit for the return value, not GTK_UNIT_NONE
384 	 * Returns: the default right margin
385 	 */
386 	public double getDefaultRightMargin(GtkUnit unit)
387 	{
388 		// gdouble gtk_paper_size_get_default_right_margin  (GtkPaperSize *size,  GtkUnit unit);
389 		return gtk_paper_size_get_default_right_margin(gtkPaperSize, unit);
390 	}
391 	
392 	/**
393 	 * Returns the name of the default paper size, which
394 	 * depends on the current locale.
395 	 * Since 2.10
396 	 * Returns: the name of the default paper size. The string is owned by GTK+ and should not be modified.
397 	 */
398 	public static string getDefault()
399 	{
400 		// const gchar * gtk_paper_size_get_default (void);
401 		return Str.toString(gtk_paper_size_get_default());
402 	}
403 	
404 	/**
405 	 * Reads a paper size from the group group_name in the key file
406 	 * key_file.
407 	 * Since 2.12
408 	 * Params:
409 	 * keyFile = the GKeyFile to retrieve the papersize from
410 	 * groupName = the name ofthe group in the key file to read,
411 	 * or NULL to read the first group
412 	 * Throws: GException on failure.
413 	 * Throws: ConstructionException GTK+ fails to create the object.
414 	 */
415 	public this (KeyFile keyFile, string groupName)
416 	{
417 		// GtkPaperSize * gtk_paper_size_new_from_key_file (GKeyFile *key_file,  const gchar *group_name,  GError **error);
418 		GError* err = null;
419 		
420 		auto p = gtk_paper_size_new_from_key_file((keyFile is null) ? null : keyFile.getKeyFileStruct(), Str.toStringz(groupName), &err);
421 		
422 		if (err !is null)
423 		{
424 			throw new GException( new ErrorG(err) );
425 		}
426 		
427 		if(p is null)
428 		{
429 			throw new ConstructionException("null returned by gtk_paper_size_new_from_key_file((keyFile is null) ? null : keyFile.getKeyFileStruct(), Str.toStringz(groupName), &err)");
430 		}
431 		this(cast(GtkPaperSize*) p);
432 	}
433 	
434 	/**
435 	 * This function adds the paper size from size to key_file.
436 	 * Since 2.12
437 	 * Params:
438 	 * keyFile = the GKeyFile to save the paper size to
439 	 * groupName = the group to add the settings to in key_file
440 	 */
441 	public void toKeyFile(KeyFile keyFile, string groupName)
442 	{
443 		// void gtk_paper_size_to_key_file (GtkPaperSize *size,  GKeyFile *key_file,  const gchar *group_name);
444 		gtk_paper_size_to_key_file(gtkPaperSize, (keyFile is null) ? null : keyFile.getKeyFileStruct(), Str.toStringz(groupName));
445 	}
446 }