Git init
[framework/uifw/xorg/lib/libxt.git] / specs / CH03
1 .\" $Xorg: CH03,v 1.3 2000/08/17 19:42:44 cpqbld Exp $
2 .\" Copyright \(co 1985, 1986, 1987, 1988, 1991, 1994
3 .\" X Consortium
4 .\" 
5 .\" Permission is hereby granted, free of charge, to any person obtaining
6 .\" a copy of this software and associated documentation files (the
7 .\" "Software"), to deal in the Software without restriction, including
8 .\" without limitation the rights to use, copy, modify, merge, publish,
9 .\" distribute, sublicense, and/or sell copies of the Software, and to
10 .\" permit persons to whom the Software is furnished to do so, subject to
11 .\" the following conditions:
12 .\" 
13 .\" The above copyright notice and this permission notice shall be included
14 .\" in all copies or substantial portions of the Software.
15 .\" 
16 .\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17 .\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 .\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19 .\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
20 .\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21 .\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22 .\" OTHER DEALINGS IN THE SOFTWARE.
23 .\" 
24 .\" Except as contained in this notice, the name of the X Consortium shall
25 .\" not be used in advertising or otherwise to promote the sale, use or
26 .\" other dealings in this Software without prior written authorization
27 .\" from the X Consortium.
28 .\" 
29 .\" Copyright \(co 1985, 1986, 1987, 1988, 1991, 1994
30 .\" Digital Equipment Corporation, Maynard, Massachusetts.
31 .\" 
32 .\" Permission to use, copy, modify and distribute this documentation for any
33 .\" purpose and without fee is hereby granted, provided that the above copyright
34 .\" notice appears in all copies and that both that copyright notice and this
35 .\" permission notice appear in supporting documentation, and that the name of
36 .\" Digital not be used in in advertising or publicity pertaining
37 .\" to distribution of the software without specific, written prior permission.
38 .\" Digital makes no representations about the suitability of the
39 .\" software described herein for any purpose.
40 .\" It is provided ``as is'' without express or implied warranty.
41 .\"
42 \&
43 .sp 1
44 .ce 3
45 \s+1\fBChapter 3\fP\s-1
46
47 \s+1\fBComposite Widgets and Their Children\fP\s-1
48 .sp 2
49 .nr H1 3
50 .nr H2 0
51 .nr H3 0
52 .nr H4 0
53 .nr H5 0
54 .LP
55 .XS
56 Chapter 3 \(em Composite Widgets and Their Children
57 .XE
58 .IN "Composite widgets"
59 Composite widgets (widgets whose class is a subclass of 
60 .PN compositeWidgetClass )
61 can have an arbitrary number of children.
62 Consequently, they are responsible for much more than primitive widgets.
63 Their responsibilities (either implemented directly by the widget class
64 or indirectly by \*(xI functions) include:
65 .IP \(bu 5
66 Overall management of children from creation to destruction.
67 .IP \(bu 5
68 Destruction of descendants when the composite widget is destroyed.
69 .IP \(bu 5
70 Physical arrangement (geometry management) of a displayable subset of
71 children (that is, the managed children).
72 .IP \(bu 5
73 Mapping and unmapping of a subset of the managed children.
74 .LP
75 Overall management is handled by the generic procedures
76 .PN XtCreateWidget
77 and
78 .PN XtDestroyWidget .
79 .PN XtCreateWidget
80 adds children to their parent by calling the parent's insert_child
81 procedure.
82 .PN XtDestroyWidget
83 removes children from their parent by calling the parent's delete_child
84 procedure and ensures that all children of a destroyed composite widget
85 also get destroyed.
86 .LP
87 Only a subset of the total number of children is actually managed by
88 the geometry manager and hence possibly visible.
89 For example, a composite editor widget
90 supporting multiple editing buffers might allocate one child
91 widget for each file buffer,
92 but it might display only a small number of the existing buffers.
93 Widgets that are in this displayable subset are called managed widgets
94 and enter into geometry manager calculations.
95 The other children are called unmanaged widgets
96 and, by definition, are not mapped by the \*(xI.
97 .LP
98 Children are added to and removed from their parent's managed set by using
99 .PN XtManageChild ,
100 .PN XtManageChildren ,
101 .PN XtUnmanageChild ,
102 .PN XtUnmanageChildren ,
103 and
104 .PN XtChangeManagedSet ,
105 which notify the parent to recalculate the physical layout of its children
106 by calling the parent's change_managed procedure.
107 The 
108 .PN XtCreateManagedWidget
109 convenience function calls
110 .PN XtCreateWidget
111 and
112 .PN XtManageChild
113 on the result.
114 .LP
115 Most managed children are mapped,
116 but some widgets can be in a state where they take up physical space
117 but do not show anything.
118 Managed widgets are not mapped automatically
119 if their \fImap_when_managed\fP field is 
120 .PN False .
121 The default is 
122 .PN True 
123 and is changed by using
124 .PN XtSetMappedWhenManaged .
125 .LP
126 Each composite widget class declares a geometry manager,
127 which is responsible for figuring out where the managed children
128 should appear within the composite widget's window.
129 Geometry management techniques fall into four classes:
130 .IP "Fixed boxes" 1.6i
131 Fixed boxes have a fixed number of children created by the parent.
132 All these children are managed,
133 and none ever makes geometry manager requests.
134 .IP "Homogeneous boxes" 1.6i
135 Homogeneous boxes treat all children equally and apply the same geometry
136 constraints to each child.
137 Many clients insert and delete widgets freely.
138 .IP "Heterogeneous boxes" 1.6i
139 Heterogeneous boxes have a specific location where each child is placed.
140 This location usually is not specified in pixels,
141 because the window may be resized, but is expressed rather
142 in terms of the relationship between a child
143 and the parent or between the child and other specific children.
144 The class of heterogeneous boxes is usually a subclass of
145 Constraint.
146 .IP "Shell boxes" 1.6i
147 Shell boxes typically have only one child,
148 and the child's size is usually
149 exactly the size of the shell.
150 The geometry manager must communicate with the window manager, if it exists,
151 and the box must also accept
152 .PN ConfigureNotify
153 events when the window size is changed by the window manager.
154
155 .NH 2
156 Addition of Children to a Composite Widget: The insert_child Procedure
157 .XS
158 \*(SN Addition of Children to a Composite Widget: The insert_child Procedure
159 .XE
160 .LP
161 .IN "insert_child procedure"
162 To add a child to
163 the parent's list of children, the
164 .PN XtCreateWidget
165 function calls the parent's class routine insert_child.
166 The insert_child procedure pointer in a composite widget is of type
167 .PN XtWidgetProc .
168 .LP
169 .IN "insert_child procedure" "" "@DEF@"
170 .sM
171 .FD 0
172 typedef void (*XtWidgetProc)(Widget);
173 .br
174       Widget \fIw\fP;
175 .FN
176 .IP \fIw\fP 1i
177 Passes the newly created child.
178 .LP
179 .eM
180 Most composite widgets inherit their superclass's operation.
181 The insert_child routine in
182 .PN CompositeWidgetClass calls the insert_position procedure
183 and inserts the child at the specified position
184 in the \fIchildren\fP list, expanding it if necessary.
185 .LP
186 Some composite widgets define their own insert_child routine
187 so that they can order their children in some convenient way,
188 create companion controller widgets for a new widget,
189 or limit the number or class of their child widgets.
190 A composite widget class that wishes
191 to allow nonwidget children (see Chapter 12) must specify a
192 .PN CompositeClassExtension
193 extension record as described
194 in Section 1.4.2.1 and set the \fIaccepts_objects\fP field in this record to
195 .PN True .
196 If the
197 .PN CompositeClassExtension
198 record is not specified or the
199 \fIaccepts_objects\fP field is
200 .PN False ,
201 the composite widget can assume that all its children are of a subclass of Core
202 without an explicit subclass test in the insert_child procedure.
203 .LP
204 If there is not enough room to insert a new child in the \fIchildren\fP array
205 (that is, \fInum_children\fP is equal to \fInum_slots\fP),
206 the insert_child procedure must first reallocate the array
207 and update \fInum_slots\fP.
208 The insert_child procedure then places the child at the appropriate position
209 in the array and increments the \fInum_children\fP field.
210
211 .NH 2
212 Insertion Order of Children: The insert_position Procedure
213 .XS
214 \fB\*(SN Insertion Order of Children: The insert_position Procedure\fP
215 .XE
216 .LP
217 Instances of composite widgets sometimes need to specify more about the order in which
218 their children are kept.
219 For example,
220 an application may want a set of command buttons in some logical order
221 grouped by function,
222 and it may want buttons that represent file names to be kept
223 in alphabetical order without constraining the order in which the
224 buttons are created.
225 .LP
226 An application controls the presentation order of a set of children by
227 supplying an
228 .IN XtNinsertPosition
229 XtNinsertPosition
230 resource.
231 The insert_position procedure pointer in a composite widget instance is of type
232 .PN XtOrderProc .
233 .LP
234 .IN "XtOrderProc" "" "@DEF@"
235 .sM
236 .FD 0
237 typedef Cardinal (*XtOrderProc)(Widget);
238 .br
239       Widget \fIw\fP;
240 .FN
241 .IP \fIw\fP 1i
242 Passes the newly created widget.
243 .LP
244 .eM
245 Composite widgets that allow clients to order their children (usually
246 homogeneous boxes) can call their widget instance's insert_position
247 procedure from the class's insert_child procedure to determine where a new
248 child should go in its \fIchildren\fP array.
249 Thus, a client using a composite class can apply different sorting criteria
250 to widget instances of the class, passing in a different insert_position
251 procedure resource when it creates each composite widget instance.
252 .LP
253 The return value of the insert_position procedure
254 indicates how many children should go before the widget.
255 Returning zero indicates that the widget should go before all other children,
256 and returning \fInum_children\fP indicates that it should go after all other children.
257 The default insert_position function returns \fInum_children\fP
258 and can be overridden by a specific composite widget's resource list
259 or by the argument list provided when the composite widget is created.
260
261 .NH 2
262 Deletion of Children: The delete_child Procedure
263 .XS
264 \*(SN Deletion of Children: The delete_child Procedure
265 .XE
266 .LP
267 .IN "delete_child procedure"
268 .LP
269 To remove the child from the parent's \fIchildren\fP list, the
270 .PN XtDestroyWidget
271 function eventually causes a call to the Composite parent's class delete_child
272 procedure.
273 The delete_child procedure pointer is of type
274 .PN XtWidgetProc .
275 .LP
276 .IN "delete_child procedure" "" "@DEF@"
277 .sM
278 .FD 0
279 typedef void (*XtWidgetProc)(Widget);
280 .br
281       Widget \fIw\fP;
282 .FN
283 .IP \fIw\fP
284 Passes the child being deleted.
285 .LP
286 .eM
287 Most widgets inherit the delete_child procedure from their superclass.
288 Composite widgets that create companion widgets define their own
289 delete_child procedure to remove these companion widgets.
290
291 .NH 2
292 Adding and Removing Children from the Managed Set
293 .XS
294 \fB\*(SN Adding and Removing Children from the Managed Set\fP
295 .XE
296 .LP
297 The \*(xI provide a set of generic routines to permit the addition of
298 widgets to or the removal of widgets from a composite widget's managed set.
299 .IN "change_managed procedure"
300 These generic routines eventually call the composite widget's change_managed
301 procedure if the procedure pointer is non-NULL.
302 The change_managed procedure pointer is of type
303 .PN XtWidgetProc .
304 The widget argument specifies the composite widget whose managed child
305 set has been modified.
306
307 .NH 3
308 Managing Children
309 .XS
310 \fB\*(SN Managing Children\fP
311 .XE
312 .LP
313 To add a list of widgets to the geometry-managed (and hence displayable)
314 subset of their Composite parent, use
315 .PN XtManageChildren .
316 .LP
317 .IN "XtManageChildren" "" "@DEF@"
318 .sM
319 .FD 0
320 typedef Widget *WidgetList;
321 .sp
322 void XtManageChildren(\fIchildren\fP, \fInum_children\fP)
323 .br
324       WidgetList \fIchildren\fP;
325 .br
326       Cardinal \fInum_children\fP;
327 .FN
328 .IP \fIchildren\fP 1i
329 Specifies a list of child widgets.  Each child must be of class
330 RectObj or any subclass thereof.
331 .IP \fInum_children\fP 1i
332 Specifies the number of children in the list.
333 .LP
334 .eM
335 The
336 .PN XtManageChildren
337 function performs the following:
338 .IP \(bu 5
339 Issues an error if the children do not all have the same parent or
340 if the parent's class is not a subclass of 
341 .PN compositeWidgetClass .
342 .IP \(bu 5
343 Returns immediately if the common parent is being destroyed;
344 otherwise, for each unique child on the list,
345 .PN XtManageChildren
346 ignores the child if it already is managed or is being destroyed,
347 and marks it if not.
348 .IP \(bu 5
349 If the parent is realized and after all children have been marked,
350 it makes some of the newly managed children viewable:
351 .RS
352 .IP \- 5
353 Calls the change_managed routine of the widgets' parent.
354 .IP \- 5
355 Calls
356 .PN XtRealizeWidget
357 on each previously unmanaged child that is unrealized.
358 .IP \- 5
359 Maps each previously unmanaged child that has \fImap_when_managed\fP 
360 .PN True .
361 .RE
362 .LP
363 Managing children is independent of the ordering of children and
364 independent of creating and deleting children.
365 The layout routine of the parent
366 should consider children whose \fImanaged\fP field is
367 .PN True 
368 and should ignore all other children.
369 Note that some composite widgets, especially fixed boxes, call
370 .PN XtManageChild
371 from their insert_child procedure.
372 .LP
373 If the parent widget is realized,
374 its change_managed procedure is called to notify it
375 that its set of managed children has changed.
376 The parent can reposition and resize any of its children.
377 It moves each child as needed by calling 
378 .PN XtMoveWidget ,
379 which first updates the \fIx\fP and \fIy\fP fields and which then calls
380 .PN XMoveWindow .
381 .LP
382 If the composite widget wishes to change the size or border width of any of
383 its children, it calls 
384 .PN XtResizeWidget ,
385 which first updates the
386 \fIwidth\fP, \fIheight\fP, and \fIborder_width\fP
387 fields and then calls
388 .PN XConfigureWindow .
389 Simultaneous repositioning and resizing may be done with
390 .PN XtConfigureWidget ;
391 see Section 6.6.
392 .sp
393 .LP
394 To add a single child to its parent widget's set of managed children, use
395 .PN XtManageChild .
396 .LP
397 .IN "XtManageChild" "" "@DEF@"
398 .sM
399 .FD 0
400 void XtManageChild(\fIchild\fP)
401 .br
402       Widget \fIchild\fP;
403 .FN
404 .IP \fIchild\fP 1i
405 Specifies the child.  \*(rI
406 .LP
407 .eM
408 The
409 .PN XtManageChild
410 function constructs a
411 .PN WidgetList
412 of length 1 and calls
413 .PN XtManageChildren .
414 .sp
415 .LP
416 To create and manage a child widget in a single procedure, use
417 .PN XtCreateManagedWidget
418 or
419 .PN XtVaCreateManagedWidget .
420 .LP
421 .IN "XtCreateManagedWidget" "" "@DEF@"
422 .sM
423 .FD 0
424 Widget XtCreateManagedWidget(\fIname\fP, \fIwidget_class\fP, \fIparent\fP, \
425 \fIargs\fP, \fInum_args\fP)
426 .br
427       String \fIname\fP;
428 .br
429       WidgetClass \fIwidget_class\fP;
430 .br
431       Widget \fIparent\fP;
432 .br
433       ArgList \fIargs\fP;
434 .br
435       Cardinal \fInum_args\fP;
436 .FN
437 .IP \fIname\fP 1i
438 Specifies the resource instance name for the created widget.
439 .IP \fIwidget_class\fP 1i
440 Specifies the widget class pointer for the created widget.  \*(rC
441 .IP \fIparent\fP 1i
442 Specifies the parent widget.  Must be of class Composite or any
443 subclass thereof.
444 .IP \fIargs\fP 1i
445 Specifies the argument list to override any other resource specifications.
446 .IP \fInum_args\fP 1i
447 Specifies the number of entries in the argument list.
448 .LP
449 .eM
450 The
451 .PN XtCreateManagedWidget
452 function is a convenience routine that calls
453 .PN XtCreateWidget
454 and
455 .PN XtManageChild .
456 .sp
457 .LP
458 .IN "XtVaCreateManagedWidget" "" "@DEF@"
459 .sM
460 .FD 0
461 Widget XtVaCreateManagedWidget(\fIname\fP, \fIwidget_class\fP, \fIparent\fP, ...)
462 .br
463       String \fIname\fP;
464 .br
465       WidgetClass \fIwidget_class\fP;
466 .br
467       Widget \fIparent\fP;
468 .FN
469 .IP \fIname\fP 1i
470 Specifies the resource instance name for the created widget.
471 .IP \fIwidget_class\fP 1i
472 Specifies the widget class pointer for the created widget.  \*(rC
473 .IP \fIparent\fP 1i
474 Specifies the parent widget.  Must be of class Composite or any
475 subclass thereof.
476 .IP ... 1i
477 Specifies the variable argument list to override any other
478 resource specifications.
479 .LP
480 .eM
481 .PN XtVaCreateManagedWidget
482 is identical in function to
483 .PN XtCreateManagedWidget
484 with the \fIargs\fP and \fInum_args\fP parameters replaced
485 by a varargs list, as described in Section 2.5.1.
486
487 .NH 3
488 Unmanaging Children
489 .XS
490 \fB\*(SN Unmanaging Children\fP
491 .XE
492 .LP
493 To remove a list of children from a parent widget's managed list, use
494 .PN XtUnmanageChildren .
495 .LP
496 .IN "XtUnmanageChildren" "" "@DEF@"
497 .sM
498 .FD 0
499 void XtUnmanageChildren(\fIchildren\fP, \fInum_children\fP)
500 .br
501       WidgetList \fIchildren\fP;
502 .br
503       Cardinal \fInum_children\fP;
504 .FN
505 .IP \fIchildren\fP 1i
506 Specifies a list of child widgets.  Each child must be of class
507 RectObj or any subclass thereof.
508 .IP \fInum_children\fP 1i
509 Specifies the number of children.
510 .LP
511 .eM
512 The
513 .PN XtUnmanageChildren
514 function performs the following:
515 .IP \(bu 5
516 Returns immediately if the common parent is being destroyed.
517 .IP \(bu 5
518 Issues an error if the children do not all have the same parent
519 or if the parent is not a subclass of 
520 .PN compositeWidgetClass .
521 .IP \(bu 5
522 For each unique child on the list, 
523 .PN XtUnmanageChildren
524 ignores the child if it is unmanaged; otherwise it performs the following:
525 .RS
526 .IP \- 5
527 Marks the child as unmanaged.
528 .IP \- 5
529 If the child is realized and the \fImap_when_managed\fP field is
530 .PN True ,
531 it is unmapped.
532 .RE
533 .IP \(bu 5
534 If the parent is realized and if any children have become unmanaged,
535 calls the change_managed routine of the widgets' parent.
536 .LP
537 .PN XtUnmanageChildren
538 does not destroy the child widgets.
539 Removing widgets from a parent's managed set is often a temporary banishment,
540 and some time later the client may manage the children again.
541 To destroy widgets entirely,
542 .PN XtDestroyWidget
543 should be called instead;
544 see Section 2.9.
545 .sp
546 .LP
547 To remove a single child from its parent widget's managed set, use
548 .PN XtUnmanageChild .
549 .LP
550 .IN "XtUnmanageChild" "" "@DEF@"
551 .sM
552 .FD 0
553 void XtUnmanageChild(\fIchild\fP)
554 .br
555       Widget \fIchild\fP;
556 .FN
557 .IP \fIchild\fP 1i
558 Specifies the child.  \*(rI
559 .LP
560 .eM
561 The
562 .PN XtUnmanageChild
563 function constructs a widget list
564 of length 1 and calls
565 .PN XtUnmanageChildren .
566 .LP
567 These functions are low-level routines that are used by generic
568 composite widget building routines.
569 In addition, composite widgets can provide widget-specific,
570 high-level convenience procedures.
571
572 .NH 3
573 Bundling Changes to the Managed Set
574 .XS
575 \fB\*(SN Bundling Changes to the Managed Set\fP
576 .XE
577 .LP
578 A client may simultaneously unmanage and manage children
579 with a single call to the \*(xI.  In this same call the
580 client may provide a callback procedure that can modify the
581 geometries of one or more children.  The composite widget class
582 defines whether this single client call results in separate invocations
583 of the change_managed method, one to unmanage and the other to
584 manage, or in just a single invocation.
585 .\" .LP
586 .\" The composite widget class specifies how its change_managed method
587 .\" should be invoked by declaring a
588 .\" .PN CompositeClassExtension
589 .\" structure as described in section 1.4.2.1.  If the
590 .\" \fIallows_change_managed_set\fP field in the
591 .\" .PN CompositeClassExtension
592 .\" record is
593 .\" .PN False ,
594 .\" the change_managed method will be invoked twice; once before any
595 .\" geometry changes are requested by the client callback and once
596 .\" after.  If the \fIallows_change_managed_set\fP field is
597 .\" .PN True ,
598 .\" the change_managed method will be invoked just once after the
599 .\" specified children have been marked as unmanaged or managed and
600 .\" the client's callback has been invoked.
601 .\" If no
602 .\" .PN CompositeClassExtension
603 .\" record is found in the extension field of the
604 .\" composite class part with record type
605 .\" .PN \s-1NULLQUARK\s+1
606 .\" and version greater
607 .\" than 1 and if
608 .\" .PN XtInheritChangeManaged
609 .\" was specified in the class record during class initialization, the
610 .\" value of the \fIallows_change_managed_set\fP
611 .\" field will be inherited from the superclass.
612 .LP
613 To simultaneously remove from and add to the geometry-managed
614 set of children of a composite parent, use
615 .PN XtChangeManagedSet .
616 .LP
617 .IN "XtChangeManagedSet" "" "@DEF@"
618 .sM
619 .FD 0
620 void XtChangeManagedSet(\fIunmanage_children\fP, \fInum_unmanage_children\fP,
621                                               \fIdo_change_proc\fP, \fIclient_data\fP,
622                                               \fImanage_children\fP, \fInum_manage_children\fP)
623 .br
624       WidgetList \fIunmanage_children\fP;
625 .br
626       Cardinal \fInum_unmanage_children\fP;
627 .br
628       XtDoChangeProc \fIdo_change_proc\fP;
629 .br
630       XtPointer \fIclient_data\fP;
631 .br
632       WidgetList \fImanage_children\fP;
633 .br
634       Cardinal \fInum_manage_children\fP;
635 .FN
636 .IP \fIunmanage_children\fP 1.8i
637 Specifies the list of widget children to initially remove from the managed set.
638 .IP \fInum_unmanage_children\fP 1.8i
639 Specifies the number of entries in the \fIunmanage_children\fP list.
640 .IP \fIdo_change_proc\fP 1.8i
641 Specifies a procedure to invoke between unmanaging
642 and managing the children, or NULL.
643 .IP \fIclient_data\fP 1.8i
644 Specifies client data to be passed to the do_change_proc.
645 .IP \fImanage_children\fP 1.8i
646 Specifies the list of widget children to finally add to the managed set.
647 .IP \fInum_manage_children\fP 1.8i
648 Specifies the number of entries in the \fImanage_children\fP list.
649 .LP
650 .eM
651 The 
652 .PN XtChangeManagedSet
653 function performs the following:
654 .IP \(bu 5
655 Returns immediately if \fInum_unmanage_children\fP and
656 \fInum_manage_children\fP are both 0.
657 .IP \(bu 5
658 Issues a warning and returns if the widgets specified in the
659 \fImanage_children\fP and
660 the \fIunmanage_children\fP lists do not all have the same parent or if
661 that parent is not a subclass of
662 .PN compositeWidgetClass .
663 .IP \(bu 5
664 Returns immediately if the common parent is being destroyed.
665 .IP \(bu 5
666 If \fIdo_change_proc\fP is not NULL and the parent's
667 .PN CompositeClassExtension
668 \fIallows_change_managed_set\fP field is
669 .PN False ,
670 then
671 .PN XtChangeManagedSet
672 performs the following:
673 .RS
674 .IP \- 5
675 Calls
676 .PN XtUnmanageChildren
677 (\fIunmanage_children\fP, \fInum_unmanage_children\fP).
678 .IP \- 5
679 Calls the \fIdo_change_proc\fP.
680 .IP \- 5
681 Calls
682 .PN XtManageChildren
683 (\fImanage_children\fP, \fInum_manage_children\fP).
684 .RE
685 .IP \(bu 5
686 Otherwise, the following is performed:
687 .RS
688 .IP \- 5
689 For each child on the \fIunmanage_children\fP list; if the child is
690 already unmanaged it is ignored, otherwise it is marked as unmanaged,
691 and if it is realized and its \fImap_when_managed\fP field is
692 .PN True ,
693 it is unmapped.
694 .IP \- 5
695 If \fIdo_change_proc\fP is non-NULL, the procedure is invoked.
696 .IP \- 5
697 For each child on the \fImanage_children\fP list; if the child is already
698 managed or is being destroyed, it is ignored; otherwise it is 
699 marked as managed.
700 .IP \- 5
701 If the parent is realized and after all children have been marked,
702 the change_managed method of the parent is invoked, and subsequently 
703 some of the newly managed children are made viewable by calling
704 .PN XtRealizeWidget
705 on each previously unmanaged child that is unrealized and
706 mapping each previously unmanaged child that has \fImap_when_managed\fP
707 .PN True .
708 .RE
709 .LP
710 If no
711 .PN CompositeClassExtension
712 record is found in the parent's composite class part \fIextension\fP field
713 with record type
714 .PN \s-1NULLQUARK\s+1
715 and version greater than 1, and if
716 .PN XtInheritChangeManaged
717 was specified in the parent's class record during class initialization,
718 the value of the \fIallows_change_managed_set\fP
719 field is inherited from the superclass.  The value inherited from
720 .PN compositeWidgetClass
721 for the \fIallows_change_managed_set\fP field is
722 .PN False .
723 .LP
724 It is not an error to include a child in both the \fIunmanage_children\fP
725 and the \fImanage_children\fP lists.  The effect of such a call is that
726 the child remains managed following the call, but the \fIdo_change_proc\fP is
727 able to affect the child while it is in an unmanaged state.
728 .sp
729 .LP
730 The \fIdo_change_proc\fP is of type
731 .PN XtDoChangeProc .
732 .LP
733 .IN "XtDoChangeProc" "" "@DEF"
734 .sM
735 .FD 0
736 typedef void (*XtDoChangeProc)(Widget, WidgetList, Cardinal*, WidgetList, Cardinal*, XtPointer);
737 .br
738       Widget \fIcomposite_parent\fP;
739 .br
740       WidgetList \fIunmange_children\fP;
741 .br
742       Cardinal *\fInum_unmanage_children\fP;
743 .br
744       WidgetList \fImanage_children\fP;
745 .br
746       Cardinal *\fInum_manage_children\fP;
747 .br
748       XtPointer \fIclient_data\fP;
749 .FN
750 .IP \fIcomposite_parent\fP 1.8i
751 Passes the composite parent whose managed set is being altered.
752 .IP \fIunmanage_children\fP 1.8i
753 Passes the list of children just removed from the managed set.
754 .IP \fInum_unmanage_children\fP 1.8i
755 Passes the number of entries in the \fIunmanage_children\fP list.
756 .IP \fImanage_children\fP 1.8i
757 Passes the list of children about to be added to the managed set.
758 .IP \fInum_manage_children\fP 1.8i
759 Passes the number of entries in the \fImanage_children\fP list.
760 .IP \fIclient_data\fP 1.8i
761 Passes the client data passed to
762 .PN XtChangeManagedSet .
763 .LP
764 .eM
765 The \fIdo_change_proc\fP procedure is used by the caller of
766 .PN XtChangeManagedSet
767 to make changes to one or more children at the point when the
768 managed set contains the fewest entries.  These changes may
769 involve geometry requests, and in this case the caller of
770 .PN XtChangeManagedSet
771 may take advantage of the fact that the \*(xI internally grant
772 geometry requests made by unmanaged children without invoking
773 the parent's geometry manager.  To achieve this advantage, if
774 the \fIdo_change_proc\fP procedure
775 changes the geometry of a child or of a descendant of a child, then
776 that child should be included in the \fIunmanage_children\fP and
777 \fImanage_children\fP lists.
778
779 .NH 3
780 Determining if a Widget Is Managed
781 .XS
782 \fB\*(SN Determining if a Widget Is Managed\fP
783 .XE
784 .LP
785 To determine the managed state of a given child widget, use
786 .PN XtIsManaged .
787 .LP
788 .IN "XtIsManaged" "" "@DEF@"
789 .sM
790 .FD 0
791 Boolean XtIsManaged(\fIw\fP)
792 .br
793        Widget \fIw\fP\^;
794 .FN
795 .IP \fIw\fP 1i
796 Specifies the widget.  \*(oI
797 .LP
798 .eM
799 The
800 .PN XtIsManaged
801 function returns
802 .PN True
803 if the specified widget is of class RectObj or any subclass thereof
804 and is managed, or
805 .PN False
806 otherwise.
807
808 .NH 2
809 Controlling When Widgets Get Mapped
810 .XS
811 \fB\*(SN Controlling When Widgets Get Mapped\fP
812 .XE
813 .LP
814 A widget is normally mapped if it is managed.
815 However,
816 this behavior can be overridden by setting the XtNmappedWhenManaged resource
817 for the widget when it is created
818 or by setting the \fImap_when_managed\fP field to 
819 .PN False .
820 .sp
821 .LP
822 To change the value of a given widget's \fImap_when_managed\fP field, use
823 .PN XtSetMappedWhenManaged .
824 .LP
825 .IN "XtSetMappedWhenManaged" "" "@DEF@"
826 .sM
827 .FD 0
828 void XtSetMappedWhenManaged(\fIw\fP, \fImap_when_managed\fP)
829 .br
830       Widget \fIw\fP;
831 .br
832       Boolean \fImap_when_managed\fP;
833 .FN
834 .IP \fIw\fP 1i
835 Specifies the widget.  \*(cI
836 .IP \fImap_when_managed\fP 1i
837 Specifies a Boolean value that indicates the new value
838 that is stored into the widget's \fImap_when_managed\fP 
839 field.
840 .LP
841 .eM
842 If the widget is realized and managed,
843 and if \fImap_when_managed\fP is 
844 .PN True ,
845 .PN XtSetMappedWhenManaged
846 maps the window.
847 If the widget is realized and managed,
848 and if \fImap_when_managed\fP is 
849 .PN False ,
850 it unmaps the window.
851 .PN XtSetMappedWhenManaged
852 is a convenience function that is equivalent to (but slightly faster than)
853 calling
854 .PN XtSetValues
855 and setting the new value for the XtNmappedWhenManaged resource
856 then mapping the widget as appropriate.
857 As an alternative to using
858 .PN XtSetMappedWhenManaged
859 to control mapping,
860 a client may set \fImapped_when_managed\fP to
861 .PN False
862 and use
863 .PN XtMapWidget
864 and
865 .PN XtUnmapWidget
866 explicitly.
867 .sp
868 .LP
869 To map a widget explicitly, use
870 .PN XtMapWidget .
871 .LP
872 .IN "XtMapWidget" "" "@DEF@"
873 .sM
874 .FD 0
875 XtMapWidget(\fIw\fP)
876 .br
877      Widget \fIw\fP\^;
878 .FN
879 .IP \fIw\fP 1i
880 Specifies the widget.  \*(cI
881 .LP
882 .eM
883 To unmap a widget explicitly, use
884 .PN XtUnmapWidget .
885 .LP
886 .IN "XtUnmapWidget" "" "@DEF@"
887 .sM
888 .FD 0
889 XtUnmapWidget(\fIw\fP)
890 .br
891      Widget \fIw\fP\^;
892 .FN
893 .IP \fIw\fP 1i
894 Specifies the widget.  \*(cI
895 .LP
896 .eM
897
898 .NH 2
899 Constrained Composite Widgets
900 .XS
901 \*(SN Constrained Composite Widgets
902 .XE
903 .LP
904 The Constraint 
905 widget class is a subclass of
906 .PN compositeWidgetClass .
907 The name is derived from the fact that constraint widgets
908 may manage the geometry 
909 of their children based on constraints associated with each child.
910 These constraints can be as simple as the maximum width and height 
911 the parent will allow the child to occupy or can be as complicated as
912 how other children should change if this child is moved or resized.
913 Constraint
914 widgets let a parent define constraints as resources that are supplied for their children.
915 For example, if the
916 Constraint
917 parent defines the maximum sizes for its children,
918 these new size resources are retrieved for each child as if they were
919 resources that were defined by the child widget's class.
920 Accordingly,
921 constraint resources may be included in the argument list or resource file just
922 like any other resource for the child.
923 .LP
924 Constraint 
925 widgets have all the responsibilities of normal composite widgets
926 and, in addition, must process and act upon the constraint information
927 associated with each of their children.
928 .LP
929 To make it easy for widgets and the \*(xI to keep track of the
930 constraints associated with a child, 
931 every widget has a \fIconstraints\fP field,
932 which is the address of a parent-specific structure that contains
933 constraint information about the child.
934 If a child's parent does not belong to a subclass of
935 .PN constraintWidgetClass ,
936 then the child's \fIconstraints\fP field is NULL.
937 .LP
938 Subclasses of
939 Constraint 
940 can add constraint data to the constraint record defined by their superclass.
941 To allow this, widget writers should define the constraint
942 records in their private .h file by using the same conventions as used for
943 widget records.
944 For example, a widget class that needs to maintain a maximum
945 width and height for each child might define its constraint record as
946 follows:
947 .LP
948 .Ds
949 .TA .5i 3i
950 .ta .5i 3i
951 typedef struct {
952         Dimension max_width, max_height;
953 } MaxConstraintPart;
954
955 typedef struct {
956         MaxConstraintPart max;
957 } MaxConstraintRecord, *MaxConstraint;
958 .De
959 .LP
960 A subclass of this widget class that also needs to maintain a minimum size would
961 define its constraint record as follows:
962 .LP
963 .Ds
964 .TA .5i 3i
965 .ta .5i 3i
966 typedef struct {
967         Dimension min_width, min_height;
968 } MinConstraintPart;
969
970 typedef struct {
971         MaxConstraintPart max;
972         MinConstraintPart min;
973 } MaxMinConstraintRecord, *MaxMinConstraint;
974 .De
975 .LP
976 Constraints are allocated, initialized, deallocated, and otherwise maintained
977 insofar as possible by the \*(xI.
978 The Constraint class record part has several entries that facilitate this.
979 All entries in
980 .PN ConstraintClassPart
981 are fields and procedures that are defined and implemented by the parent,
982 but they are called whenever actions are performed on the parent's children.
983 .LP
984 The
985 .PN XtCreateWidget
986 function uses the \fIconstraint_size\fP field in the parent's class record
987 to allocate a constraint record when a child is created.
988 .PN XtCreateWidget
989 also uses the constraint resources to fill in resource fields in the
990 constraint record associated with a child.
991 It then calls the constraint initialize procedure so that the parent
992 can compute constraint fields that are derived from constraint resources
993 and can possibly move or resize the child to conform to the given constraints.
994 .LP
995 When the
996 .PN XtGetValues
997 and
998 .PN XtSetValues
999 functions are executed
1000 on a child, they use the constraint resources to get the values or
1001 set the values of constraints associated with that child.
1002 .PN XtSetValues
1003 then calls the constraint set_values procedures so that the parent can
1004 recompute derived constraint fields and move or resize the child
1005 as appropriate.
1006 If a
1007 Constraint
1008 widget class or any of its superclasses have declared a
1009 .PN ConstraintClassExtension
1010 record in the
1011 .PN ConstraintClassPart
1012 \fIextension\fP
1013 fields with a record type of
1014 .PN \s-1NULLQUARK\s+1
1015 and the \fIget_values_hook\fP field in
1016 .IN "get_values_hook procedure"
1017 .IN "Constraint" "get_values_hook"
1018 the extension record is non-NULL,
1019 .PN XtGetValues
1020 calls the get_values_hook
1021 procedure(s) to allow the parent to return derived constraint fields.
1022 .LP
1023 The
1024 .PN XtDestroyWidget
1025 function calls the constraint destroy procedure to deallocate any
1026 dynamic storage associated with a constraint record.
1027 The constraint record itself must not be deallocated by the constraint
1028 destroy procedure;
1029 .PN XtDestroyWidget
1030 does this automatically.
1031 .bp