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  = GtkPageSetup.html
27  * outPack = gtk
28  * outFile = PageSetup
29  * strct   = GtkPageSetup
30  * realStrct=
31  * ctorStrct=
32  * clss    = PageSetup
33  * interf  = 
34  * class Code: No
35  * interface Code: No
36  * template for:
37  * extend  = 
38  * implements:
39  * prefixes:
40  * 	- gtk_page_setup_
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.KeyFile
50  * 	- gtk.PaperSize
51  * structWrap:
52  * 	- GKeyFile* -> KeyFile
53  * 	- GtkPageSetup* -> PageSetup
54  * 	- GtkPaperSize* -> PaperSize
55  * module aliases:
56  * local aliases:
57  * overrides:
58  */
59 
60 module gtk.PageSetup;
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.KeyFile;
73 private import gtk.PaperSize;
74 
75 
76 
77 private import gobject.ObjectG;
78 
79 /**
80  * A GtkPageSetup object stores the page size, orientation and margins.
81  * The idea is that you can get one of these from the page setup dialog
82  * and then pass it to the GtkPrintOperation when printing.
83  * The benefit of splitting this out of the GtkPrintSettings is that
84  * these affect the actual layout of the page, and thus need to be set
85  * long before user prints.
86  *
87  * The margins specified in this object are the "print margins", i.e. the
88  * parts of the page that the printer cannot print on. These are different
89  * from the layout margins that a word processor uses; they are typically
90  * used to determine the minimal size for the layout
91  * margins.
92  *
93  * To obtain a GtkPageSetup use gtk_page_setup_new() to get the defaults,
94  * or use gtk_print_run_page_setup_dialog() to show the page setup dialog
95  * and receive the resulting page setup.
96  *
97  * $(DDOC_COMMENT example)
98  *
99  * Printing support was added in GTK+ 2.10.
100  */
101 public class PageSetup : ObjectG
102 {
103 	
104 	/** the main Gtk struct */
105 	protected GtkPageSetup* gtkPageSetup;
106 	
107 	
108 	public GtkPageSetup* getPageSetupStruct()
109 	{
110 		return gtkPageSetup;
111 	}
112 	
113 	
114 	/** the main Gtk struct as a void* */
115 	protected override void* getStruct()
116 	{
117 		return cast(void*)gtkPageSetup;
118 	}
119 	
120 	/**
121 	 * Sets our main struct and passes it to the parent class
122 	 */
123 	public this (GtkPageSetup* gtkPageSetup)
124 	{
125 		super(cast(GObject*)gtkPageSetup);
126 		this.gtkPageSetup = gtkPageSetup;
127 	}
128 	
129 	protected override void setStruct(GObject* obj)
130 	{
131 		super.setStruct(obj);
132 		gtkPageSetup = cast(GtkPageSetup*)obj;
133 	}
134 	
135 	/**
136 	 */
137 	
138 	/**
139 	 * Creates a new GtkPageSetup.
140 	 * Since 2.10
141 	 * Throws: ConstructionException GTK+ fails to create the object.
142 	 */
143 	public this ()
144 	{
145 		// GtkPageSetup * gtk_page_setup_new (void);
146 		auto p = gtk_page_setup_new();
147 		if(p is null)
148 		{
149 			throw new ConstructionException("null returned by gtk_page_setup_new()");
150 		}
151 		this(cast(GtkPageSetup*) p);
152 	}
153 	
154 	/**
155 	 * Copies a GtkPageSetup.
156 	 * Since 2.10
157 	 * Returns: a copy of other. [transfer full]
158 	 */
159 	public PageSetup copy()
160 	{
161 		// GtkPageSetup * gtk_page_setup_copy (GtkPageSetup *other);
162 		auto p = gtk_page_setup_copy(gtkPageSetup);
163 		
164 		if(p is null)
165 		{
166 			return null;
167 		}
168 		
169 		return ObjectG.getDObject!(PageSetup)(cast(GtkPageSetup*) p);
170 	}
171 	
172 	/**
173 	 * Gets the page orientation of the GtkPageSetup.
174 	 * Since 2.10
175 	 * Returns: the page orientation
176 	 */
177 	public GtkPageOrientation getOrientation()
178 	{
179 		// GtkPageOrientation gtk_page_setup_get_orientation (GtkPageSetup *setup);
180 		return gtk_page_setup_get_orientation(gtkPageSetup);
181 	}
182 	
183 	/**
184 	 * Sets the page orientation of the GtkPageSetup.
185 	 * Since 2.10
186 	 * Params:
187 	 * orientation = a GtkPageOrientation value
188 	 */
189 	public void setOrientation(GtkPageOrientation orientation)
190 	{
191 		// void gtk_page_setup_set_orientation (GtkPageSetup *setup,  GtkPageOrientation orientation);
192 		gtk_page_setup_set_orientation(gtkPageSetup, orientation);
193 	}
194 	
195 	/**
196 	 * Gets the paper size of the GtkPageSetup.
197 	 * Since 2.10
198 	 * Returns: the paper size
199 	 */
200 	public PaperSize getPaperSize()
201 	{
202 		// GtkPaperSize * gtk_page_setup_get_paper_size (GtkPageSetup *setup);
203 		auto p = gtk_page_setup_get_paper_size(gtkPageSetup);
204 		
205 		if(p is null)
206 		{
207 			return null;
208 		}
209 		
210 		return ObjectG.getDObject!(PaperSize)(cast(GtkPaperSize*) p);
211 	}
212 	
213 	/**
214 	 * Sets the paper size of the GtkPageSetup without
215 	 * changing the margins. See
216 	 * gtk_page_setup_set_paper_size_and_default_margins().
217 	 * Since 2.10
218 	 * Params:
219 	 * size = a GtkPaperSize
220 	 */
221 	public void setPaperSize(PaperSize size)
222 	{
223 		// void gtk_page_setup_set_paper_size (GtkPageSetup *setup,  GtkPaperSize *size);
224 		gtk_page_setup_set_paper_size(gtkPageSetup, (size is null) ? null : size.getPaperSizeStruct());
225 	}
226 	
227 	/**
228 	 * Gets the top margin in units of unit.
229 	 * Since 2.10
230 	 * Params:
231 	 * unit = the unit for the return value
232 	 * Returns: the top margin
233 	 */
234 	public double getTopMargin(GtkUnit unit)
235 	{
236 		// gdouble gtk_page_setup_get_top_margin (GtkPageSetup *setup,  GtkUnit unit);
237 		return gtk_page_setup_get_top_margin(gtkPageSetup, unit);
238 	}
239 	
240 	/**
241 	 * Sets the top margin of the GtkPageSetup.
242 	 * Since 2.10
243 	 * Params:
244 	 * margin = the new top margin in units of unit
245 	 * unit = the units for margin
246 	 */
247 	public void setTopMargin(double margin, GtkUnit unit)
248 	{
249 		// void gtk_page_setup_set_top_margin (GtkPageSetup *setup,  gdouble margin,  GtkUnit unit);
250 		gtk_page_setup_set_top_margin(gtkPageSetup, margin, unit);
251 	}
252 	
253 	/**
254 	 * Gets the bottom margin in units of unit.
255 	 * Since 2.10
256 	 * Params:
257 	 * unit = the unit for the return value
258 	 * Returns: the bottom margin
259 	 */
260 	public double getBottomMargin(GtkUnit unit)
261 	{
262 		// gdouble gtk_page_setup_get_bottom_margin (GtkPageSetup *setup,  GtkUnit unit);
263 		return gtk_page_setup_get_bottom_margin(gtkPageSetup, unit);
264 	}
265 	
266 	/**
267 	 * Sets the bottom margin of the GtkPageSetup.
268 	 * Since 2.10
269 	 * Params:
270 	 * margin = the new bottom margin in units of unit
271 	 * unit = the units for margin
272 	 */
273 	public void setBottomMargin(double margin, GtkUnit unit)
274 	{
275 		// void gtk_page_setup_set_bottom_margin (GtkPageSetup *setup,  gdouble margin,  GtkUnit unit);
276 		gtk_page_setup_set_bottom_margin(gtkPageSetup, margin, unit);
277 	}
278 	
279 	/**
280 	 * Gets the left margin in units of unit.
281 	 * Since 2.10
282 	 * Params:
283 	 * unit = the unit for the return value
284 	 * Returns: the left margin
285 	 */
286 	public double getLeftMargin(GtkUnit unit)
287 	{
288 		// gdouble gtk_page_setup_get_left_margin (GtkPageSetup *setup,  GtkUnit unit);
289 		return gtk_page_setup_get_left_margin(gtkPageSetup, unit);
290 	}
291 	
292 	/**
293 	 * Sets the left margin of the GtkPageSetup.
294 	 * Since 2.10
295 	 * Params:
296 	 * margin = the new left margin in units of unit
297 	 * unit = the units for margin
298 	 */
299 	public void setLeftMargin(double margin, GtkUnit unit)
300 	{
301 		// void gtk_page_setup_set_left_margin (GtkPageSetup *setup,  gdouble margin,  GtkUnit unit);
302 		gtk_page_setup_set_left_margin(gtkPageSetup, margin, unit);
303 	}
304 	
305 	/**
306 	 * Gets the right margin in units of unit.
307 	 * Since 2.10
308 	 * Params:
309 	 * unit = the unit for the return value
310 	 * Returns: the right margin
311 	 */
312 	public double getRightMargin(GtkUnit unit)
313 	{
314 		// gdouble gtk_page_setup_get_right_margin (GtkPageSetup *setup,  GtkUnit unit);
315 		return gtk_page_setup_get_right_margin(gtkPageSetup, unit);
316 	}
317 	
318 	/**
319 	 * Sets the right margin of the GtkPageSetup.
320 	 * Since 2.10
321 	 * Params:
322 	 * margin = the new right margin in units of unit
323 	 * unit = the units for margin
324 	 */
325 	public void setRightMargin(double margin, GtkUnit unit)
326 	{
327 		// void gtk_page_setup_set_right_margin (GtkPageSetup *setup,  gdouble margin,  GtkUnit unit);
328 		gtk_page_setup_set_right_margin(gtkPageSetup, margin, unit);
329 	}
330 	
331 	/**
332 	 * Sets the paper size of the GtkPageSetup and modifies
333 	 * the margins according to the new paper size.
334 	 * Since 2.10
335 	 * Params:
336 	 * size = a GtkPaperSize
337 	 */
338 	public void setPaperSizeAndDefaultMargins(PaperSize size)
339 	{
340 		// void gtk_page_setup_set_paper_size_and_default_margins  (GtkPageSetup *setup,  GtkPaperSize *size);
341 		gtk_page_setup_set_paper_size_and_default_margins(gtkPageSetup, (size is null) ? null : size.getPaperSizeStruct());
342 	}
343 	
344 	/**
345 	 * Returns the paper width in units of unit.
346 	 * Note that this function takes orientation, but
347 	 * not margins into consideration.
348 	 * See gtk_page_setup_get_page_width().
349 	 * Since 2.10
350 	 * Params:
351 	 * unit = the unit for the return value
352 	 * Returns: the paper width.
353 	 */
354 	public double getPaperWidth(GtkUnit unit)
355 	{
356 		// gdouble gtk_page_setup_get_paper_width (GtkPageSetup *setup,  GtkUnit unit);
357 		return gtk_page_setup_get_paper_width(gtkPageSetup, unit);
358 	}
359 	
360 	/**
361 	 * Returns the paper height in units of unit.
362 	 * Note that this function takes orientation, but
363 	 * not margins into consideration.
364 	 * See gtk_page_setup_get_page_height().
365 	 * Since 2.10
366 	 * Params:
367 	 * unit = the unit for the return value
368 	 * Returns: the paper height.
369 	 */
370 	public double getPaperHeight(GtkUnit unit)
371 	{
372 		// gdouble gtk_page_setup_get_paper_height (GtkPageSetup *setup,  GtkUnit unit);
373 		return gtk_page_setup_get_paper_height(gtkPageSetup, unit);
374 	}
375 	
376 	/**
377 	 * Returns the page width in units of unit.
378 	 * Note that this function takes orientation and
379 	 * margins into consideration.
380 	 * See gtk_page_setup_get_paper_width().
381 	 * Since 2.10
382 	 * Params:
383 	 * unit = the unit for the return value
384 	 * Returns: the page width.
385 	 */
386 	public double getPageWidth(GtkUnit unit)
387 	{
388 		// gdouble gtk_page_setup_get_page_width (GtkPageSetup *setup,  GtkUnit unit);
389 		return gtk_page_setup_get_page_width(gtkPageSetup, unit);
390 	}
391 	
392 	/**
393 	 * Returns the page height in units of unit.
394 	 * Note that this function takes orientation and
395 	 * margins into consideration.
396 	 * See gtk_page_setup_get_paper_height().
397 	 * Since 2.10
398 	 * Params:
399 	 * unit = the unit for the return value
400 	 * Returns: the page height.
401 	 */
402 	public double getPageHeight(GtkUnit unit)
403 	{
404 		// gdouble gtk_page_setup_get_page_height (GtkPageSetup *setup,  GtkUnit unit);
405 		return gtk_page_setup_get_page_height(gtkPageSetup, unit);
406 	}
407 	
408 	/**
409 	 * Reads the page setup from the file file_name. Returns a
410 	 * new GtkPageSetup object with the restored page setup,
411 	 * or NULL if an error occurred. See gtk_page_setup_to_file().
412 	 * Since 2.12
413 	 * Params:
414 	 * fileName = the filename to read the page setup from. [type filename]
415 	 * Throws: GException on failure.
416 	 * Throws: ConstructionException GTK+ fails to create the object.
417 	 */
418 	public this (string fileName)
419 	{
420 		// GtkPageSetup * gtk_page_setup_new_from_file (const gchar *file_name,  GError **error);
421 		GError* err = null;
422 		
423 		auto p = gtk_page_setup_new_from_file(Str.toStringz(fileName), &err);
424 		
425 		if (err !is null)
426 		{
427 			throw new GException( new ErrorG(err) );
428 		}
429 		
430 		if(p is null)
431 		{
432 			throw new ConstructionException("null returned by gtk_page_setup_new_from_file(Str.toStringz(fileName), &err)");
433 		}
434 		this(cast(GtkPageSetup*) p);
435 	}
436 	
437 	/**
438 	 * Reads the page setup from the group group_name in the key file
439 	 * key_file. Returns a new GtkPageSetup object with the restored
440 	 * page setup, or NULL if an error occurred.
441 	 * Since 2.12
442 	 * Params:
443 	 * keyFile = the GKeyFile to retrieve the page_setup from
444 	 * groupName = the name of the group in the key_file to read, or NULL
445 	 * to use the default name "Page Setup". [allow-none]
446 	 * Throws: GException on failure.
447 	 * Throws: ConstructionException GTK+ fails to create the object.
448 	 */
449 	public this (KeyFile keyFile, string groupName)
450 	{
451 		// GtkPageSetup * gtk_page_setup_new_from_key_file (GKeyFile *key_file,  const gchar *group_name,  GError **error);
452 		GError* err = null;
453 		
454 		auto p = gtk_page_setup_new_from_key_file((keyFile is null) ? null : keyFile.getKeyFileStruct(), Str.toStringz(groupName), &err);
455 		
456 		if (err !is null)
457 		{
458 			throw new GException( new ErrorG(err) );
459 		}
460 		
461 		if(p is null)
462 		{
463 			throw new ConstructionException("null returned by gtk_page_setup_new_from_key_file((keyFile is null) ? null : keyFile.getKeyFileStruct(), Str.toStringz(groupName), &err)");
464 		}
465 		this(cast(GtkPageSetup*) p);
466 	}
467 	
468 	/**
469 	 * Reads the page setup from the file file_name.
470 	 * See gtk_page_setup_to_file().
471 	 * Since 2.14
472 	 * Params:
473 	 * fileName = the filename to read the page setup from. [type filename]
474 	 * Returns: TRUE on success
475 	 * Throws: GException on failure.
476 	 */
477 	public int loadFile(string fileName)
478 	{
479 		// gboolean gtk_page_setup_load_file (GtkPageSetup *setup,  const char *file_name,  GError **error);
480 		GError* err = null;
481 		
482 		auto p = gtk_page_setup_load_file(gtkPageSetup, Str.toStringz(fileName), &err);
483 		
484 		if (err !is null)
485 		{
486 			throw new GException( new ErrorG(err) );
487 		}
488 		
489 		return p;
490 	}
491 	
492 	/**
493 	 * Reads the page setup from the group group_name in the key file
494 	 * key_file.
495 	 * Since 2.14
496 	 * Params:
497 	 * keyFile = the GKeyFile to retrieve the page_setup from
498 	 * groupName = the name of the group in the key_file to read, or NULL
499 	 * to use the default name "Page Setup". [allow-none]
500 	 * Returns: TRUE on success
501 	 * Throws: GException on failure.
502 	 */
503 	public int loadKeyFile(KeyFile keyFile, string groupName)
504 	{
505 		// gboolean gtk_page_setup_load_key_file (GtkPageSetup *setup,  GKeyFile *key_file,  const gchar *group_name,  GError **error);
506 		GError* err = null;
507 		
508 		auto p = gtk_page_setup_load_key_file(gtkPageSetup, (keyFile is null) ? null : keyFile.getKeyFileStruct(), Str.toStringz(groupName), &err);
509 		
510 		if (err !is null)
511 		{
512 			throw new GException( new ErrorG(err) );
513 		}
514 		
515 		return p;
516 	}
517 	
518 	/**
519 	 * This function saves the information from setup to file_name.
520 	 * Since 2.12
521 	 * Params:
522 	 * fileName = the file to save to. [type filename]
523 	 * Returns: TRUE on success
524 	 * Throws: GException on failure.
525 	 */
526 	public int toFile(string fileName)
527 	{
528 		// gboolean gtk_page_setup_to_file (GtkPageSetup *setup,  const char *file_name,  GError **error);
529 		GError* err = null;
530 		
531 		auto p = gtk_page_setup_to_file(gtkPageSetup, Str.toStringz(fileName), &err);
532 		
533 		if (err !is null)
534 		{
535 			throw new GException( new ErrorG(err) );
536 		}
537 		
538 		return p;
539 	}
540 	
541 	/**
542 	 * This function adds the page setup from setup to key_file.
543 	 * Since 2.12
544 	 * Params:
545 	 * keyFile = the GKeyFile to save the page setup to
546 	 * groupName = the group to add the settings to in key_file,
547 	 * or NULL to use the default name "Page Setup"
548 	 */
549 	public void toKeyFile(KeyFile keyFile, string groupName)
550 	{
551 		// void gtk_page_setup_to_key_file (GtkPageSetup *setup,  GKeyFile *key_file,  const gchar *group_name);
552 		gtk_page_setup_to_key_file(gtkPageSetup, (keyFile is null) ? null : keyFile.getKeyFileStruct(), Str.toStringz(groupName));
553 	}
554 }