]> Pileus Git - ~andy/gtk/blob - docs/reference/gtk/tmpl/gtkcontainer.sgml
2.9.0
[~andy/gtk] / docs / reference / gtk / tmpl / gtkcontainer.sgml
1 <!-- ##### SECTION Title ##### -->
2 GtkContainer
3
4 <!-- ##### SECTION Short_Description ##### -->
5 Base class for widgets which contain other widgets
6
7 <!-- ##### SECTION Long_Description ##### -->
8 <para>
9 A GTK+ user interface is constructed by nesting widgets inside widgets. Container widgets are the inner
10 nodes in the resulting tree of widgets: they contain other widgets. So, for example, you might have a 
11 #GtkWindow containing a #GtkFrame containing a GtkLabel. If you wanted an image instead of a textual label 
12 inside the frame, you might replace the #GtkLabel widget with a #GtkImage widget.
13 </para>
14 <para>
15 There are two major kinds of container widgets in GTK+. Both are subclasses of the abstract #GtkContainer 
16 base class.
17 </para>
18 <para>
19 The first type of container widget has a single child widget and derives from #GtkBin. These containers
20 are <firstterm>decorators</firstterm>, which add some kind of functionality to the child. For example, 
21 a #GtkButton makes its child into a clickable button; a #GtkFrame draws a frame around its child and 
22 a #GtkWindow places its child widget inside a top-level window.
23 </para>
24 <para>
25 The second type of container can have more than one child; its purpose is to manage 
26 <firstterm>layout</firstterm>. This means that these containers assign sizes and positions to their children. 
27 For example, a #GtkHBox arranges its children in a horizontal row, and a #GtkTable arranges the widgets it
28 contains in a two-dimensional grid. 
29 </para>
30 <para>
31 To fulfill its task, a layout container must negotiate the size requirements with its parent and its children.
32 This negotiation is carried out in two phases, <firstterm>size requisition</firstterm> and 
33 <firstterm>size allocation</firstterm>. 
34 </para>
35 <refsect2 id="size-requisition"><title>Size Requisition</title>
36 <para>
37 The size requisition of a widget is it's desired width and height. This is represented by a #GtkRequisition.
38 </para>
39 <para>
40 How a widget determines its desired size depends on the widget. A #GtkLabel, for example, requests enough space 
41 to display all its text. Container widgets generally base their size request on the requisitions of their 
42 children.  
43 </para>
44 <para>
45 The size requisition phase of the widget layout process operates top-down. It starts at a top-level widget,
46 typically a #GtkWindow. The top-level widget asks its child for its size requisition by calling
47 gtk_widget_size_request(). To determine its requisition, the child asks its own children for their requisitions 
48 and so on. Finally, the top-level widget will get a requisition back from its child. 
49 </para>
50 </refsect2>
51 <refsect2 id="size-allocation"><title>Size Allocation</title>
52 <para>
53 When the top-level widget has determined how much space its child would like to have, the second phase of the
54 size negotiation, size allocation, begins. Depending on its configuration (see gtk_window_set_resizable()), the 
55 top-level widget may be able to expand in order to satisfy the size request or it may have to ignore the size 
56 request and keep its fixed size. It then tells its child widget how much space it gets by calling 
57 gtk_widget_size_allocate(). The child widget divides the space among its children and tells each child how much 
58 space it got, and so on. Under normal circumstances, a #GtkWindow will always give its child the amount of space
59 the child requested.
60 </para>
61 <para>
62 A child's size allocation is represented by a #GtkAllocation. This struct contains not only a width and height, 
63 but also a position (i.e. X and Y coordinates), so that containers can tell their children not only how much
64 space they have gotten, but also where they are positioned inside the space available to the container. 
65 </para>
66 <para>
67 Widgets are required to honor the size allocation they receive; a size request is only a request, and widgets
68 must be able to cope with any size.
69 </para>
70 </refsect2>
71 <refsect2 id="child-properties"><title>Child properties</title>
72 <para>
73 <structname>GtkContainer</structname> introduces <firstterm>child 
74 properties</firstterm> - these are object properties that are not specific
75 to either the container or the contained widget, but rather to their relation.
76 Typical examples of child properties are the position or pack-type of a widget
77 which is contained in a #GtkBox.</para>
78 <para>
79 Use gtk_container_class_install_child_property() to install child properties 
80 for a container class and gtk_container_class_find_child_property() or
81 gtk_container_class_list_child_properties() to get information about existing
82 child properties.
83 </para>
84 <para>
85 To set the value of a child property, use gtk_container_child_set_property(), 
86 gtk_container_child_set() or gtk_container_child_set_valist(). 
87 To obtain the value of a child property, use 
88 gtk_container_child_get_property(), gtk_container_child_get() or
89 gtk_container_child_get_valist(). To emit notification about child property 
90 changes, use gtk_widget_child_notify().
91 </para>
92 </refsect2>
93
94 <!-- ##### SECTION See_Also ##### -->
95 <para>
96
97 </para>
98
99 <!-- ##### SECTION Stability_Level ##### -->
100
101
102 <!-- ##### STRUCT GtkContainer ##### -->
103 <para>
104
105 </para>
106
107
108 <!-- ##### SIGNAL GtkContainer::add ##### -->
109 <para>
110
111 </para>
112
113 @container: the object which received the signal.
114 @widget: 
115
116 <!-- ##### SIGNAL GtkContainer::check-resize ##### -->
117 <para>
118
119 </para>
120
121 @container: the object which received the signal.
122
123 <!-- ##### SIGNAL GtkContainer::remove ##### -->
124 <para>
125
126 </para>
127
128 @container: the object which received the signal.
129 @widget: 
130
131 <!-- ##### SIGNAL GtkContainer::set-focus-child ##### -->
132 <para>
133
134 </para>
135
136 @container: the object which received the signal.
137 @widget: 
138
139 <!-- ##### ARG GtkContainer:border-width ##### -->
140 <para>
141
142 </para>
143
144 <!-- ##### ARG GtkContainer:child ##### -->
145 <para>
146
147 </para>
148
149 <!-- ##### ARG GtkContainer:resize-mode ##### -->
150 <para>
151
152 </para>
153
154 <!-- ##### MACRO GTK_IS_RESIZE_CONTAINER ##### -->
155 <para>
156
157 </para>
158
159 @widget: 
160
161
162 <!-- ##### MACRO GTK_CONTAINER_WARN_INVALID_CHILD_PROPERTY_ID ##### -->
163 <para>
164
165 </para>
166
167 @object: 
168 @property_id: 
169 @pspec: 
170
171
172 <!-- ##### MACRO gtk_container_border_width ##### -->
173 <para>
174 Does the same as gtk_container_set_border_width().
175 </para>
176
177 @Deprecated: Use gtk_container_set_border_width() instead.
178
179
180 <!-- ##### FUNCTION gtk_container_add ##### -->
181 <para>
182
183 </para>
184
185 @container: 
186 @widget: 
187
188
189 <!-- ##### FUNCTION gtk_container_remove ##### -->
190 <para>
191
192 </para>
193
194 @container: 
195 @widget: 
196
197
198 <!-- ##### FUNCTION gtk_container_add_with_properties ##### -->
199 <para>
200
201 </para>
202
203 @container: 
204 @widget: 
205 @first_prop_name: 
206 @Varargs: 
207
208
209 <!-- ##### FUNCTION gtk_container_get_resize_mode ##### -->
210 <para>
211
212 </para>
213
214 @container: 
215 @Returns: 
216
217
218 <!-- ##### FUNCTION gtk_container_set_resize_mode ##### -->
219 <para>
220
221 </para>
222
223 @container: 
224 @resize_mode: 
225
226
227 <!-- ##### FUNCTION gtk_container_check_resize ##### -->
228 <para>
229
230 </para>
231
232 @container: 
233
234
235 <!-- ##### FUNCTION gtk_container_foreach ##### -->
236 <para>
237
238 </para>
239
240 @container: 
241 @callback: 
242 @callback_data: 
243
244
245 <!-- ##### FUNCTION gtk_container_foreach_full ##### -->
246 <para>
247
248 </para>
249
250 @container: 
251 @callback: 
252 @marshal: 
253 @callback_data: 
254 @notify: 
255 @Deprecated: Use gtk_container_foreach() instead.
256
257
258 <!-- ##### MACRO gtk_container_children ##### -->
259 <para>
260 Does the same as gtk_container_get_children().
261 </para>
262
263 @Returns: 
264 @Deprecated: Use gtk_container_get_children() instead.
265
266
267 <!-- ##### FUNCTION gtk_container_get_children ##### -->
268 <para>
269
270 </para>
271
272 @container: 
273 @Returns: 
274
275
276 <!-- ##### FUNCTION gtk_container_set_reallocate_redraws ##### -->
277 <para>
278
279 </para>
280
281 @container: 
282 @needs_redraws: 
283
284
285 <!-- ##### FUNCTION gtk_container_set_focus_child ##### -->
286 <para>
287
288 </para>
289
290 @container: 
291 @child: 
292
293
294 <!-- ##### FUNCTION gtk_container_get_focus_vadjustment ##### -->
295 <para>
296
297 </para>
298
299 @container: 
300 @Returns: 
301
302
303 <!-- ##### FUNCTION gtk_container_set_focus_vadjustment ##### -->
304 <para>
305
306 </para>
307
308 @container: 
309 @adjustment: 
310
311
312 <!-- ##### FUNCTION gtk_container_get_focus_hadjustment ##### -->
313 <para>
314
315 </para>
316
317 @container: 
318 @Returns: 
319
320
321 <!-- ##### FUNCTION gtk_container_set_focus_hadjustment ##### -->
322 <para>
323
324 </para>
325
326 @container: 
327 @adjustment: 
328
329
330 <!-- ##### FUNCTION gtk_container_resize_children ##### -->
331 <para>
332
333 </para>
334
335 @container: 
336
337
338 <!-- ##### FUNCTION gtk_container_child_type ##### -->
339 <para>
340
341 </para>
342
343 @container: 
344 @Returns: 
345
346
347 <!-- ##### FUNCTION gtk_container_child_get ##### -->
348 <para>
349
350 </para>
351
352 @container: 
353 @child: 
354 @first_prop_name: 
355 @Varargs: 
356
357
358 <!-- ##### FUNCTION gtk_container_child_set ##### -->
359 <para>
360
361 </para>
362
363 @container: 
364 @child: 
365 @first_prop_name: 
366 @Varargs: 
367
368
369 <!-- ##### FUNCTION gtk_container_child_get_property ##### -->
370 <para>
371
372 </para>
373
374 @container: 
375 @child: 
376 @property_name: 
377 @value: 
378
379
380 <!-- ##### FUNCTION gtk_container_child_set_property ##### -->
381 <para>
382
383 </para>
384
385 @container: 
386 @child: 
387 @property_name: 
388 @value: 
389
390
391 <!-- ##### FUNCTION gtk_container_child_get_valist ##### -->
392 <para>
393
394 </para>
395
396 @container: 
397 @child: 
398 @first_property_name: 
399 @var_args: 
400
401
402 <!-- ##### FUNCTION gtk_container_child_set_valist ##### -->
403 <para>
404
405 </para>
406
407 @container: 
408 @child: 
409 @first_property_name: 
410 @var_args: 
411
412
413 <!-- ##### FUNCTION gtk_container_forall ##### -->
414 <para>
415
416 </para>
417
418 @container: 
419 @callback: 
420 @callback_data: 
421
422
423 <!-- ##### FUNCTION gtk_container_get_border_width ##### -->
424 <para>
425
426 </para>
427
428 @container: 
429 @Returns: 
430
431
432 <!-- ##### FUNCTION gtk_container_set_border_width ##### -->
433 <para>
434
435 </para>
436
437 @container: 
438 @border_width: 
439
440
441 <!-- ##### FUNCTION gtk_container_propagate_expose ##### -->
442 <para>
443
444 </para>
445
446 @container: 
447 @child: 
448 @event: 
449
450
451 <!-- ##### FUNCTION gtk_container_get_focus_chain ##### -->
452 <para>
453
454 </para>
455
456 @container: 
457 @focusable_widgets: 
458 @Returns: 
459
460
461 <!-- ##### FUNCTION gtk_container_set_focus_chain ##### -->
462 <para>
463
464 </para>
465
466 @container: 
467 @focusable_widgets: 
468
469
470 <!-- ##### FUNCTION gtk_container_unset_focus_chain ##### -->
471 <para>
472
473 </para>
474
475 @container: 
476
477
478 <!-- ##### FUNCTION gtk_container_class_find_child_property ##### -->
479 <para>
480
481 </para>
482
483 @cclass: 
484 @property_name: 
485 @Returns: 
486
487
488 <!-- ##### FUNCTION gtk_container_class_install_child_property ##### -->
489 <para>
490
491 </para>
492
493 @cclass: 
494 @property_id: 
495 @pspec: 
496
497
498 <!-- ##### FUNCTION gtk_container_class_list_child_properties ##### -->
499 <para>
500
501 </para>
502
503 @cclass: 
504 @n_properties: 
505 @Returns: 
506
507