2
* Motif Tools Library, Version 3.1
5
* Written by David Flanagan.
6
* Copyright (c) 1992-2001 by David Flanagan.
7
* All Rights Reserved. See the file COPYRIGHT for details.
8
* This is open source software. See the file LICENSE for details.
9
* There is no warranty for this software. See NO_WARRANTY for details.
12
* Revision 1.1.1.1 2001/07/18 11:06:02 root
15
* Revision 1.2 2001/06/12 16:25:28 andre
16
* *** empty log message ***
22
* This file is almost directly from the X11R5 distribution.
23
* It is included with the Xmt library to patch an RS/6000 bug in AIX 3.2,
24
* which has a broken X11R4 version of the file, which cause the
25
* XmtLayout widget not to work.
26
* This file will only be included in the Xmt library if you have
27
* set the appropriate variable in Xmt.tmpl.
29
* Thanks to Peter Klingebiel for figuring out this workaround.
32
#ifdef IBM_MANAGE_WORKAROUND
34
/* $XConsortium: Manage.c,v 1.25 90/12/12 14:52:32 rws Exp $ */
36
/***********************************************************
37
Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts,
38
and the Massachusetts Institute of Technology, Cambridge, Massachusetts.
42
Permission to use, copy, modify, and distribute this software and its
43
documentation for any purpose and without fee is hereby granted,
44
provided that the above copyright notice appear in all copies and that
45
both that copyright notice and this permission notice appear in
46
supporting documentation, and that the names of Digital or MIT not be
47
used in advertising or publicity pertaining to distribution of the
48
software without specific, written prior permission.
50
DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
51
ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
52
DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
53
ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
54
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
55
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
58
******************************************************************/
60
#include "IntrinsicP.h"
62
static String XtCXtToolkitError = "XtToolkitError";
63
static String XtNinvalidChild = "invalidChild";
64
static String XtNxtUnmanageChildren = "xtUnmanageChildren";
65
static String XtNxtManageChildren = "xtManageChildren";
67
void XtUnmanageChildren(children, num_children)
69
Cardinal num_children;
71
register CompositeWidget parent;
72
register Widget child;
73
register Cardinal num_unique_children, i;
74
XtWidgetProc change_managed;
77
if (num_children == 0) return;
78
if (children[0] == NULL) {
79
XtWarningMsg(XtNinvalidChild,XtNxtUnmanageChildren,XtCXtToolkitError,
80
"Null child passed to XtUnmanageChildren",
81
(String *)NULL, (Cardinal *)NULL);
84
parent = (CompositeWidget) children[0]->core.parent;
85
if (parent->core.being_destroyed) return;
87
if (XtIsComposite((Widget) parent)) {
88
change_managed = ((CompositeWidgetClass) parent->core.widget_class)
89
->composite_class.change_managed;
90
parent_realized = XtIsRealized((Widget)parent);
93
num_unique_children = 0;
94
for (i = 0; i < num_children; i++) {
97
XtAppWarningMsg(XtWidgetToApplicationContext((Widget)parent),
98
XtNinvalidChild,XtNxtUnmanageChildren,XtCXtToolkitError,
99
"Null child passed to XtUnmanageChildren",
100
(String *)NULL, (Cardinal *)NULL);
103
if ((CompositeWidget) child->core.parent != parent) {
104
XtAppWarningMsg(XtWidgetToApplicationContext((Widget)parent),
105
"ambiguousParent",XtNxtUnmanageChildren,XtCXtToolkitError,
106
"Not all children have same parent in XtUnmanageChildren",
107
(String *)NULL, (Cardinal *)NULL);
109
if (child->core.managed) {
110
num_unique_children++;
111
child->core.managed = FALSE;
112
if (XtIsWidget(child)
113
&& XtIsRealized(child)
114
&& child->core.mapped_when_managed)
115
XtUnmapWidget(child);
117
{ /* RectObj child */
118
Widget pw = child->core.parent;
119
RectObj r = (RectObj) child;
120
while ((pw!=NULL) && (!XtIsWidget(pw))) pw = pw->core.parent;
121
if ((pw!=NULL) && XtIsRealized (pw))
122
XClearArea (XtDisplay (pw), XtWindow (pw),
123
r->rectangle.x, r->rectangle.y,
124
r->rectangle.width + (r->rectangle.border_width << 1),
125
r->rectangle.height + (r->rectangle.border_width << 1),
131
if (num_unique_children != 0 && change_managed != NULL && parent_realized) {
132
(*change_managed) ((Widget)parent);
134
} /* XtUnmanageChildren */
137
void XtUnmanageChild(child)
140
XtUnmanageChildren(&child, (Cardinal)1);
141
} /* XtUnmanageChild */
144
void XtManageChildren(children, num_children)
146
Cardinal num_children;
148
#define MAXCHILDREN 100
149
register CompositeWidget parent;
150
register Widget child;
151
register Cardinal num_unique_children, i;
152
XtWidgetProc change_managed;
153
register WidgetList unique_children;
154
Widget cache[MAXCHILDREN];
155
Bool parent_realized;
157
if (num_children == 0) return;
158
if (children[0] == NULL) {
159
XtWarningMsg(XtNinvalidChild,XtNxtManageChildren,XtCXtToolkitError,
160
"null child passed to XtManageChildren",
161
(String *)NULL, (Cardinal *)NULL);
164
parent = (CompositeWidget) children[0]->core.parent;
165
if (XtIsComposite((Widget) parent)) {
166
change_managed = ((CompositeWidgetClass) parent->core.widget_class)
167
->composite_class.change_managed;
168
parent_realized = XtIsRealized((Widget)parent);
171
XtAppErrorMsg(XtWidgetToApplicationContext((Widget)parent),
172
"invalidParent",XtNxtManageChildren, XtCXtToolkitError,
173
"Attempt to manage a child when parent is not Composite",
174
(String *) NULL, (Cardinal *) NULL);
176
if (parent->core.being_destroyed) return;
178
/* Construct new list of children that really need to be operated upon. */
179
if (num_children <= MAXCHILDREN) {
180
unique_children = cache;
182
unique_children = (WidgetList) XtMalloc(num_children * sizeof(Widget));
184
num_unique_children = 0;
185
for (i = 0; i < num_children; i++) {
188
XtAppWarningMsg(XtWidgetToApplicationContext((Widget)parent),
189
XtNinvalidChild,XtNxtManageChildren,XtCXtToolkitError,
190
"null child passed to XtManageChildren",
191
(String *)NULL, (Cardinal *)NULL);
192
if (unique_children != cache) XtFree((char *) unique_children);
196
if (!XtIsRectObj(child)) {
198
Cardinal num_params = 2;
199
params[0] = XtName(child);
200
params[1] = child->core.widget_class->core_class.class_name;
201
XtAppWarningMsg(XtWidgetToApplicationContext((Widget)parent),
202
"notRectObj",XtNxtManageChildren,XtCXtToolkitError,
203
"child \"%s\", class %s is not a RectObj",
204
params, &num_params);
208
if ((CompositeWidget) child->core.parent != parent) {
209
XtAppWarningMsg(XtWidgetToApplicationContext((Widget)parent),
210
"ambiguousParent",XtNxtManageChildren,XtCXtToolkitError,
211
"Not all children have same parent in XtManageChildren",
212
(String *)NULL, (Cardinal *)NULL);
213
} else if (! child->core.managed && !child->core.being_destroyed) {
214
unique_children[num_unique_children++] = child;
215
child->core.managed = TRUE;
219
if (num_unique_children != 0 && parent_realized) {
220
/* Compute geometry of new managed set of children. */
221
if (change_managed != NULL) (*change_managed) ((Widget)parent);
223
/* Realize each child if necessary, then map if necessary */
224
for (i = 0; i < num_unique_children; i++) {
225
child = unique_children[i];
226
if (XtIsWidget(child)) {
227
if (! XtIsRealized(child)) XtRealizeWidget(child);
228
if (child->core.mapped_when_managed) XtMapWidget(child);
229
} else { /* RectObj child */
230
Widget pw = child->core.parent;
231
RectObj r = (RectObj) child;
232
while ((pw!=NULL) && (!XtIsWidget(pw)))
233
pw = pw->core.parent;
235
XClearArea (XtDisplay (pw), XtWindow (pw),
236
r->rectangle.x, r->rectangle.y,
237
r->rectangle.width + (r->rectangle.border_width << 1),
238
r->rectangle.height + (r->rectangle.border_width << 1),
244
if (unique_children != cache) XtFree((char *) unique_children);
245
} /* XtManageChildren */
248
void XtManageChild(child)
251
XtManageChildren(&child, (Cardinal) 1);
252
} /* XtManageChild */
255
#if NeedFunctionPrototypes
256
void XtSetMappedWhenManaged(
257
register Widget widget,
258
_XtBoolean mapped_when_managed
261
void XtSetMappedWhenManaged(widget, mapped_when_managed)
262
register Widget widget;
263
Boolean mapped_when_managed;
266
if (widget->core.mapped_when_managed == mapped_when_managed) return;
267
widget->core.mapped_when_managed = mapped_when_managed;
268
if (! XtIsManaged(widget)) return;
270
if (mapped_when_managed) {
271
/* Didn't used to be mapped when managed. */
272
if (XtIsRealized(widget)) XtMapWidget(widget);
274
/* Used to be mapped when managed. */
275
if (XtIsRealized(widget)) XtUnmapWidget(widget);
277
} /* XtSetMappedWhenManaged */
281
/* just so the compiler doesn't complain about an empty file. */
282
static char XmtDummy;