~ubuntu-branches/ubuntu/utopic/gridengine/utopic

« back to all changes in this revision

Viewing changes to source/3rdparty/qmon/Xmt310/Xmt/IBMManage.c

  • Committer: Bazaar Package Importer
  • Author(s): Mark Hymers
  • Date: 2008-06-25 22:36:13 UTC
  • Revision ID: james.westby@ubuntu.com-20080625223613-tvd9xlhuoct9kyhm
Tags: upstream-6.2~beta2
ImportĀ upstreamĀ versionĀ 6.2~beta2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* 
 
2
 * Motif Tools Library, Version 3.1
 
3
 * $Id$
 
4
 * 
 
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.
 
10
 *
 
11
 * $Log$
 
12
 * Revision 1.1.1.1  2001/07/18 11:06:02  root
 
13
 * Initial checkin.
 
14
 *
 
15
 * Revision 1.2  2001/06/12 16:25:28  andre
 
16
 * *** empty log message ***
 
17
 *
 
18
 *
 
19
 */
 
20
 
 
21
/*
 
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.
 
28
 * 
 
29
 * Thanks to Peter Klingebiel for figuring out this workaround.
 
30
 */
 
31
 
 
32
#ifdef IBM_MANAGE_WORKAROUND
 
33
 
 
34
/* $XConsortium: Manage.c,v 1.25 90/12/12 14:52:32 rws Exp $ */
 
35
 
 
36
/***********************************************************
 
37
Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts,
 
38
and the Massachusetts Institute of Technology, Cambridge, Massachusetts.
 
39
 
 
40
                        All Rights Reserved
 
41
 
 
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.  
 
49
 
 
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
 
56
SOFTWARE.
 
57
 
 
58
******************************************************************/
 
59
 
 
60
#include "IntrinsicP.h"
 
61
 
 
62
static String XtCXtToolkitError = "XtToolkitError";
 
63
static String XtNinvalidChild = "invalidChild";
 
64
static String XtNxtUnmanageChildren = "xtUnmanageChildren";
 
65
static String XtNxtManageChildren = "xtManageChildren";
 
66
 
 
67
void XtUnmanageChildren(children, num_children)
 
68
    WidgetList children;
 
69
    Cardinal num_children;
 
70
{
 
71
    register CompositeWidget    parent;
 
72
    register Widget             child;
 
73
    register Cardinal           num_unique_children, i;
 
74
             XtWidgetProc       change_managed;
 
75
             Bool               parent_realized;
 
76
 
 
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);
 
82
        return;
 
83
    }
 
84
    parent = (CompositeWidget) children[0]->core.parent;
 
85
    if (parent->core.being_destroyed) return;
 
86
 
 
87
    if (XtIsComposite((Widget) parent)) {
 
88
        change_managed = ((CompositeWidgetClass) parent->core.widget_class)
 
89
                    ->composite_class.change_managed;
 
90
        parent_realized = XtIsRealized((Widget)parent);
 
91
    }
 
92
 
 
93
    num_unique_children = 0;
 
94
    for (i = 0; i < num_children; i++) {
 
95
        child = children[i];
 
96
        if (child == NULL) {
 
97
            XtAppWarningMsg(XtWidgetToApplicationContext((Widget)parent),
 
98
                  XtNinvalidChild,XtNxtUnmanageChildren,XtCXtToolkitError,
 
99
                  "Null child passed to XtUnmanageChildren",
 
100
                  (String *)NULL, (Cardinal *)NULL);
 
101
            return;
 
102
        }
 
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);
 
108
        } else
 
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);
 
116
            else
 
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),
 
126
                        TRUE);
 
127
            }
 
128
 
 
129
        }
 
130
    }
 
131
    if (num_unique_children != 0 && change_managed != NULL && parent_realized) {
 
132
        (*change_managed) ((Widget)parent);
 
133
    }
 
134
} /* XtUnmanageChildren */
 
135
 
 
136
 
 
137
void XtUnmanageChild(child)
 
138
    Widget child;
 
139
{
 
140
    XtUnmanageChildren(&child, (Cardinal)1);
 
141
} /* XtUnmanageChild */
 
142
 
 
143
 
 
144
void XtManageChildren(children, num_children)
 
145
    WidgetList  children;
 
146
    Cardinal    num_children;
 
147
{
 
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;
 
156
 
 
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);
 
162
        return;
 
163
    } 
 
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);
 
169
 
 
170
    } else {
 
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);
 
175
    }
 
176
    if (parent->core.being_destroyed) return;
 
177
 
 
178
    /* Construct new list of children that really need to be operated upon. */
 
179
    if (num_children <= MAXCHILDREN) {
 
180
        unique_children = cache;
 
181
    } else {
 
182
        unique_children = (WidgetList) XtMalloc(num_children * sizeof(Widget));
 
183
    }
 
184
    num_unique_children = 0;
 
185
    for (i = 0; i < num_children; i++) {
 
186
        child = children[i];
 
187
        if (child == NULL) {
 
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);
 
193
            return;
 
194
        }
 
195
#ifdef DEBUG
 
196
        if (!XtIsRectObj(child)) {
 
197
            String params[2];
 
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);
 
205
            continue;
 
206
        }
 
207
#endif /*DEBUG*/
 
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;
 
216
        }
 
217
    }
 
218
 
 
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);
 
222
 
 
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;
 
234
                if (pw != NULL)
 
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),
 
239
                    TRUE);
 
240
            }
 
241
        }
 
242
    }
 
243
 
 
244
    if (unique_children != cache) XtFree((char *) unique_children);
 
245
} /* XtManageChildren */
 
246
 
 
247
 
 
248
void XtManageChild(child)
 
249
    Widget child;
 
250
{
 
251
    XtManageChildren(&child, (Cardinal) 1);
 
252
} /* XtManageChild */
 
253
 
 
254
 
 
255
#if NeedFunctionPrototypes
 
256
void XtSetMappedWhenManaged(
 
257
    register Widget widget,
 
258
    _XtBoolean      mapped_when_managed
 
259
    )
 
260
#else
 
261
void XtSetMappedWhenManaged(widget, mapped_when_managed)
 
262
    register Widget widget;
 
263
    Boolean         mapped_when_managed;
 
264
#endif
 
265
{
 
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;
 
269
 
 
270
    if (mapped_when_managed) {
 
271
        /* Didn't used to be mapped when managed.               */
 
272
        if (XtIsRealized(widget)) XtMapWidget(widget);
 
273
    } else {
 
274
        /* Used to be mapped when managed.                      */
 
275
        if (XtIsRealized(widget)) XtUnmapWidget(widget);
 
276
    }
 
277
} /* XtSetMappedWhenManaged */
 
278
 
 
279
 
 
280
#else
 
281
/* just so the compiler doesn't complain about an empty file. */
 
282
static char XmtDummy;
 
283
#endif