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