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