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