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