Functions.c revision 249c3046
1/*
2
3Copyright (c) 1993, Oracle and/or its affiliates. All rights reserved.
4
5Permission is hereby granted, free of charge, to any person obtaining a
6copy of this software and associated documentation files (the "Software"),
7to deal in the Software without restriction, including without limitation
8the rights to use, copy, modify, merge, publish, distribute, sublicense,
9and/or sell copies of the Software, and to permit persons to whom the
10Software is furnished to do so, subject to the following conditions:
11
12The above copyright notice and this permission notice (including the next
13paragraph) shall be included in all copies or substantial portions of the
14Software.
15
16THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
19THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22DEALINGS IN THE SOFTWARE.
23
24*/
25
26/*
27
28Copyright 1985, 1986, 1987, 1988, 1989, 1994, 1998  The Open Group
29
30Permission to use, copy, modify, distribute, and sell this software and its
31documentation for any purpose is hereby granted without fee, provided that
32the above copyright notice appear in all copies and that both that
33copyright notice and this permission notice appear in supporting
34documentation.
35
36The above copyright notice and this permission notice shall be included in
37all copies or substantial portions of the Software.
38
39THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
40IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
41FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
42OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
43AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
44CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
45
46Except as contained in this notice, the name of The Open Group shall not be
47used in advertising or otherwise to promote the sale, use or other dealings
48in this Software without prior written authorization from The Open Group.
49
50*/
51
52#ifdef HAVE_CONFIG_H
53#include <config.h>
54#endif
55#include "IntrinsicI.h"
56#include <X11/Shell.h>
57#include <X11/Vendor.h>
58
59/*
60 * This file defines functional equivalents to all macros defined
61 * in Intrinsic.h
62 *
63 */
64
65#undef XtIsRectObj
66Boolean XtIsRectObj(Widget object)
67{
68    return _XtCheckSubclassFlag(object, 0x02);
69}
70
71
72#undef XtIsWidget
73Boolean XtIsWidget(Widget object)
74{
75    return _XtCheckSubclassFlag(object, 0x04);
76}
77
78
79#undef XtIsComposite
80Boolean XtIsComposite(Widget object)
81{
82    return _XtCheckSubclassFlag(object, 0x08);
83}
84
85
86#undef XtIsConstraint
87Boolean XtIsConstraint(Widget object)
88{
89    return _XtCheckSubclassFlag(object, 0x10);
90}
91
92
93#undef XtIsShell
94Boolean XtIsShell(Widget object)
95{
96    return _XtCheckSubclassFlag(object, 0x20);
97}
98
99
100#undef XtIsOverrideShell
101Boolean XtIsOverrideShell(Widget object)
102{
103    return _XtIsSubclassOf(object, (WidgetClass)overrideShellWidgetClass,
104			   (WidgetClass)shellWidgetClass, 0x20);
105}
106
107
108#undef XtIsWMShell
109Boolean XtIsWMShell(Widget object)
110{
111    return _XtCheckSubclassFlag(object, 0x40);
112}
113
114
115#undef XtIsVendorShell
116Boolean XtIsVendorShell(Widget object)
117{
118    Boolean retval;
119
120    LOCK_PROCESS;
121    retval = _XtIsSubclassOf(object,
122#ifdef notdef
123/*
124 * We don't refer to vendorShell directly, because some shared libraries
125 * bind local references tightly.
126 */
127			   (WidgetClass)vendorShellWidgetClass,
128#endif
129			   transientShellWidgetClass->core_class.superclass,
130			   (WidgetClass)wmShellWidgetClass, 0x40);
131    UNLOCK_PROCESS;
132    return retval;
133}
134
135
136#undef XtIsTransientShell
137Boolean XtIsTransientShell(Widget object)
138{
139    return _XtIsSubclassOf(object, (WidgetClass)transientShellWidgetClass,
140			   (WidgetClass)wmShellWidgetClass, 0x40);
141}
142
143
144#undef XtIsTopLevelShell
145Boolean XtIsTopLevelShell(Widget object)
146{
147    return _XtCheckSubclassFlag(object, 0x80);
148}
149
150
151#undef XtIsApplicationShell
152Boolean XtIsApplicationShell(Widget object)
153{
154    return _XtIsSubclassOf(object, (WidgetClass)applicationShellWidgetClass,
155			   (WidgetClass)topLevelShellWidgetClass, 0x80);
156}
157
158#undef XtIsSessionShell
159Boolean XtIsSessionShell(Widget object)
160{
161    return _XtIsSubclassOf(object, (WidgetClass)sessionShellWidgetClass,
162			   (WidgetClass)topLevelShellWidgetClass, 0x80);
163}
164
165#undef XtMapWidget
166void XtMapWidget(Widget w)
167{
168    Widget hookobj;
169    WIDGET_TO_APPCON(w);
170
171    LOCK_APP(app);
172    XMapWindow(XtDisplay(w), XtWindow(w));
173    hookobj = XtHooksOfDisplay(XtDisplay(w));
174    if (XtHasCallbacks(hookobj, XtNchangeHook) == XtCallbackHasSome) {
175	XtChangeHookDataRec call_data;
176
177	call_data.type = XtHmapWidget;
178	call_data.widget = w;
179	XtCallCallbackList(hookobj,
180		((HookObject)hookobj)->hooks.changehook_callbacks,
181		(XtPointer)&call_data);
182    }
183    UNLOCK_APP(app);
184}
185
186
187#undef XtUnmapWidget
188void XtUnmapWidget(Widget w)
189{
190    Widget hookobj;
191    WIDGET_TO_APPCON(w);
192
193    LOCK_APP(app);
194    XUnmapWindow(XtDisplay(w), XtWindow(w));
195    hookobj = XtHooksOfDisplay(XtDisplay(w));
196    if (XtHasCallbacks(hookobj, XtNchangeHook) == XtCallbackHasSome) {
197	XtChangeHookDataRec call_data;
198
199	call_data.type = XtHunmapWidget;
200	call_data.widget = w;
201	XtCallCallbackList(hookobj,
202		((HookObject)hookobj)->hooks.changehook_callbacks,
203		(XtPointer)&call_data);
204    }
205    UNLOCK_APP(app);
206}
207
208
209#undef XtNewString
210String XtNewString(String str)
211{
212    if (str == NULL)
213	return NULL;
214    else
215	return strcpy(__XtMalloc((unsigned)strlen(str) + 1), str);
216}
217