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