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  = GtkSizeGroup.html
27  * outPack = gtk
28  * outFile = SizeGroup
29  * strct   = GtkSizeGroup
30  * realStrct=
31  * ctorStrct=
32  * clss    = SizeGroup
33  * interf  = 
34  * class Code: Yes
35  * interface Code: No
36  * template for:
37  * extend  = 
38  * implements:
39  * 	- BuildableIF
40  * prefixes:
41  * 	- gtk_size_group_
42  * 	- gtk_
43  * omit structs:
44  * omit prefixes:
45  * omit code:
46  * omit signals:
47  * imports:
48  * 	- gtk.Widget
49  * 	- glib.ListSG
50  * 	- gtk.BuildableIF
51  * 	- gtk.BuildableT
52  * structWrap:
53  * 	- GSList* -> ListSG
54  * 	- GtkWidget* -> Widget
55  * module aliases:
56  * local aliases:
57  * overrides:
58  */
59 
60 module gtk.SizeGroup;
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 gtk.Widget;
70 private import glib.ListSG;
71 private import gtk.BuildableIF;
72 private import gtk.BuildableT;
73 
74 
75 
76 private import gobject.ObjectG;
77 
78 /**
79  * Description
80  * GtkSizeGroup provides a mechanism for grouping a number of widgets
81  * together so they all request the same amount of space. This is
82  * typically useful when you want a column of widgets to have the same
83  * size, but you can't use a GtkTable widget.
84  * In detail, the size requested for each widget in a GtkSizeGroup is
85  * the maximum of the sizes that would have been requested for each
86  * widget in the size group if they were not in the size group. The mode
87  * of the size group (see gtk_size_group_set_mode()) determines whether
88  * this applies to the horizontal size, the vertical size, or both sizes.
89  * Note that size groups only affect the amount of space requested, not
90  * the size that the widgets finally receive. If you want the widgets in
91  * a GtkSizeGroup to actually be the same size, you need to pack them in
92  * such a way that they get the size they request and not more. For
93  * example, if you are packing your widgets into a table, you would not
94  * include the GTK_FILL flag.
95  * GtkSizeGroup objects are referenced by each widget in the size group,
96  * so once you have added all widgets to a GtkSizeGroup, you can drop
97  * the initial reference to the size group with g_object_unref(). If the
98  * widgets in the size group are subsequently destroyed, then they will
99  * be removed from the size group and drop their references on the size
100  * group; when all widgets have been removed, the size group will be
101  * freed.
102  * Widgets can be part of multiple size groups; GTK+ will compute the
103  * horizontal size of a widget from the horizontal requisition of all
104  * widgets that can be reached from the widget by a chain of size groups
105  * of type GTK_SIZE_GROUP_HORIZONTAL or GTK_SIZE_GROUP_BOTH, and the
106  * vertical size from the vertical requisition of all widgets that can be
107  * reached from the widget by a chain of size groups of type
108  * GTK_SIZE_GROUP_VERTICAL or GTK_SIZE_GROUP_BOTH.
109  * GtkSizeGroup as GtkBuildable
110  * Size groups can be specified in a UI definition by placing an
111  * <object> element with class="GtkSizeGroup"
112  * somewhere in the UI definition. The widgets that belong to the
113  * size group are specified by a <widgets> element that may
114  * contain multiple <widget> elements, one for each member
115  * of the size group. The name attribute gives the id of the widget.
116  * $(DDOC_COMMENT example)
117  */
118 public class SizeGroup : ObjectG, BuildableIF
119 {
120 	
121 	/** the main Gtk struct */
122 	protected GtkSizeGroup* gtkSizeGroup;
123 	
124 	
125 	public GtkSizeGroup* getSizeGroupStruct()
126 	{
127 		return gtkSizeGroup;
128 	}
129 	
130 	
131 	/** the main Gtk struct as a void* */
132 	protected override void* getStruct()
133 	{
134 		return cast(void*)gtkSizeGroup;
135 	}
136 	
137 	/**
138 	 * Sets our main struct and passes it to the parent class
139 	 */
140 	public this (GtkSizeGroup* gtkSizeGroup)
141 	{
142 		super(cast(GObject*)gtkSizeGroup);
143 		this.gtkSizeGroup = gtkSizeGroup;
144 	}
145 	
146 	protected override void setStruct(GObject* obj)
147 	{
148 		super.setStruct(obj);
149 		gtkSizeGroup = cast(GtkSizeGroup*)obj;
150 	}
151 	
152 	// add the Buildable capabilities
153 	mixin BuildableT!(GtkSizeGroup);
154 	
155 	/**
156 	 */
157 	
158 	/**
159 	 * Create a new GtkSizeGroup.
160 	 * Params:
161 	 * mode = the mode for the new size group.
162 	 * Throws: ConstructionException GTK+ fails to create the object.
163 	 */
164 	public this (GtkSizeGroupMode mode)
165 	{
166 		// GtkSizeGroup * gtk_size_group_new (GtkSizeGroupMode mode);
167 		auto p = gtk_size_group_new(mode);
168 		if(p is null)
169 		{
170 			throw new ConstructionException("null returned by gtk_size_group_new(mode)");
171 		}
172 		this(cast(GtkSizeGroup*) p);
173 	}
174 	
175 	/**
176 	 * Sets the GtkSizeGroupMode of the size group. The mode of the size
177 	 * group determines whether the widgets in the size group should
178 	 * all have the same horizontal requisition (GTK_SIZE_GROUP_MODE_HORIZONTAL)
179 	 * all have the same vertical requisition (GTK_SIZE_GROUP_MODE_VERTICAL),
180 	 * or should all have the same requisition in both directions
181 	 * (GTK_SIZE_GROUP_MODE_BOTH).
182 	 * Params:
183 	 * mode = the mode to set for the size group.
184 	 */
185 	public void setMode(GtkSizeGroupMode mode)
186 	{
187 		// void gtk_size_group_set_mode (GtkSizeGroup *size_group,  GtkSizeGroupMode mode);
188 		gtk_size_group_set_mode(gtkSizeGroup, mode);
189 	}
190 	
191 	/**
192 	 * Gets the current mode of the size group. See gtk_size_group_set_mode().
193 	 * Returns: the current mode of the size group.
194 	 */
195 	public GtkSizeGroupMode getMode()
196 	{
197 		// GtkSizeGroupMode gtk_size_group_get_mode (GtkSizeGroup *size_group);
198 		return gtk_size_group_get_mode(gtkSizeGroup);
199 	}
200 	
201 	/**
202 	 * Sets whether unmapped widgets should be ignored when
203 	 * calculating the size.
204 	 * Since 2.8
205 	 * Params:
206 	 * ignoreHidden = whether unmapped widgets should be ignored
207 	 * when calculating the size
208 	 */
209 	public void setIgnoreHidden(int ignoreHidden)
210 	{
211 		// void gtk_size_group_set_ignore_hidden (GtkSizeGroup *size_group,  gboolean ignore_hidden);
212 		gtk_size_group_set_ignore_hidden(gtkSizeGroup, ignoreHidden);
213 	}
214 	
215 	/**
216 	 * Returns if invisible widgets are ignored when calculating the size.
217 	 * Since 2.8
218 	 * Returns: TRUE if invisible widgets are ignored.
219 	 */
220 	public int getIgnoreHidden()
221 	{
222 		// gboolean gtk_size_group_get_ignore_hidden (GtkSizeGroup *size_group);
223 		return gtk_size_group_get_ignore_hidden(gtkSizeGroup);
224 	}
225 	
226 	/**
227 	 * Adds a widget to a GtkSizeGroup. In the future, the requisition
228 	 * of the widget will be determined as the maximum of its requisition
229 	 * and the requisition of the other widgets in the size group.
230 	 * Whether this applies horizontally, vertically, or in both directions
231 	 * depends on the mode of the size group. See gtk_size_group_set_mode().
232 	 * When the widget is destroyed or no longer referenced elsewhere, it will
233 	 * be removed from the size group.
234 	 * Params:
235 	 * widget = the GtkWidget to add
236 	 */
237 	public void addWidget(Widget widget)
238 	{
239 		// void gtk_size_group_add_widget (GtkSizeGroup *size_group,  GtkWidget *widget);
240 		gtk_size_group_add_widget(gtkSizeGroup, (widget is null) ? null : widget.getWidgetStruct());
241 	}
242 	
243 	/**
244 	 * Removes a widget from a GtkSizeGroup.
245 	 * Params:
246 	 * widget = the GtkWidget to remove
247 	 */
248 	public void removeWidget(Widget widget)
249 	{
250 		// void gtk_size_group_remove_widget (GtkSizeGroup *size_group,  GtkWidget *widget);
251 		gtk_size_group_remove_widget(gtkSizeGroup, (widget is null) ? null : widget.getWidgetStruct());
252 	}
253 	
254 	/**
255 	 * Returns the list of widgets associated with size_group.
256 	 * Since 2.10
257 	 * Returns: a GSList of widgets. The list is owned by GTK+ and should not be modified. [element-type GtkWidget][transfer none]
258 	 */
259 	public ListSG getWidgets()
260 	{
261 		// GSList * gtk_size_group_get_widgets (GtkSizeGroup *size_group);
262 		auto p = gtk_size_group_get_widgets(gtkSizeGroup);
263 		
264 		if(p is null)
265 		{
266 			return null;
267 		}
268 		
269 		return ObjectG.getDObject!(ListSG)(cast(GSList*) p);
270 	}
271 }