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