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 module gtk.Requisition;
26 
27 private import glib.ConstructionException;
28 private import glib.c.functions;
29 private import gobject.ObjectG;
30 private import gtk.c.functions;
31 public  import gtk.c.types;
32 public  import gtkc.gtktypes;
33 private import gtkd.Loader;
34 
35 
36 /**
37  * A #GtkRequisition-struct represents the desired size of a widget. See
38  * [GtkWidget’s geometry management section][geometry-management] for
39  * more information.
40  */
41 public final class Requisition
42 {
43 	/** the main Gtk struct */
44 	protected GtkRequisition* gtkRequisition;
45 	protected bool ownedRef;
46 
47 	/** Get the main Gtk struct */
48 	public GtkRequisition* getRequisitionStruct(bool transferOwnership = false)
49 	{
50 		if (transferOwnership)
51 			ownedRef = false;
52 		return gtkRequisition;
53 	}
54 
55 	/** the main Gtk struct as a void* */
56 	protected void* getStruct()
57 	{
58 		return cast(void*)gtkRequisition;
59 	}
60 
61 	/**
62 	 * Sets our main struct and passes it to the parent class.
63 	 */
64 	public this (GtkRequisition* gtkRequisition, bool ownedRef = false)
65 	{
66 		this.gtkRequisition = gtkRequisition;
67 		this.ownedRef = ownedRef;
68 	}
69 
70 	~this ()
71 	{
72 		if ( Linker.isLoaded(LIBRARY_GTK) && ownedRef )
73 			gtk_requisition_free(gtkRequisition);
74 	}
75 
76 
77 	/**
78 	 * the widget’s desired width
79 	 */
80 	public @property int width()
81 	{
82 		return gtkRequisition.width;
83 	}
84 
85 	/** Ditto */
86 	public @property void width(int value)
87 	{
88 		gtkRequisition.width = value;
89 	}
90 
91 	/**
92 	 * the widget’s desired height
93 	 */
94 	public @property int height()
95 	{
96 		return gtkRequisition.height;
97 	}
98 
99 	/** Ditto */
100 	public @property void height(int value)
101 	{
102 		gtkRequisition.height = value;
103 	}
104 
105 	/** */
106 	public static GType getType()
107 	{
108 		return gtk_requisition_get_type();
109 	}
110 
111 	/**
112 	 * Allocates a new #GtkRequisition-struct and initializes its elements to zero.
113 	 *
114 	 * Returns: a new empty #GtkRequisition. The newly allocated #GtkRequisition should
115 	 *     be freed with gtk_requisition_free().
116 	 *
117 	 * Since: 3.0
118 	 *
119 	 * Throws: ConstructionException GTK+ fails to create the object.
120 	 */
121 	public this()
122 	{
123 		auto p = gtk_requisition_new();
124 
125 		if(p is null)
126 		{
127 			throw new ConstructionException("null returned by new");
128 		}
129 
130 		this(cast(GtkRequisition*) p);
131 	}
132 
133 	/**
134 	 * Copies a #GtkRequisition.
135 	 *
136 	 * Returns: a copy of @requisition
137 	 */
138 	public Requisition copy()
139 	{
140 		auto p = gtk_requisition_copy(gtkRequisition);
141 
142 		if(p is null)
143 		{
144 			return null;
145 		}
146 
147 		return ObjectG.getDObject!(Requisition)(cast(GtkRequisition*) p, true);
148 	}
149 
150 	/**
151 	 * Frees a #GtkRequisition.
152 	 */
153 	public void free()
154 	{
155 		gtk_requisition_free(gtkRequisition);
156 		ownedRef = false;
157 	}
158 }