SetSens.c revision 444c061a
1444c061aSmrg/* $Xorg: SetSens.c,v 1.4 2001/02/09 02:03:58 xorgcvs Exp $ */
2444c061aSmrg
3444c061aSmrg/***********************************************************
4444c061aSmrgCopyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts
5444c061aSmrgCopyright 1993 by Sun Microsystems, Inc. Mountain View, CA.
6444c061aSmrg
7444c061aSmrg                        All Rights Reserved
8444c061aSmrg
9444c061aSmrgPermission to use, copy, modify, and distribute this software and its
10444c061aSmrgdocumentation for any purpose and without fee is hereby granted,
11444c061aSmrgprovided that the above copyright notice appear in all copies and that
12444c061aSmrgboth that copyright notice and this permission notice appear in
13444c061aSmrgsupporting documentation, and that the names of Digital or Sun not be
14444c061aSmrgused in advertising or publicity pertaining to distribution of the
15444c061aSmrgsoftware without specific, written prior permission.
16444c061aSmrg
17444c061aSmrgDIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
18444c061aSmrgALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
19444c061aSmrgDIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
20444c061aSmrgANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
21444c061aSmrgWHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
22444c061aSmrgARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
23444c061aSmrgSOFTWARE.
24444c061aSmrg
25444c061aSmrgSUN DISCLAIMS ALL WARRANTIES WITH REGARD TO  THIS  SOFTWARE,
26444c061aSmrgINCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT-
27444c061aSmrgNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SUN BE  LI-
28444c061aSmrgABLE  FOR  ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
29444c061aSmrgANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,  DATA  OR
30444c061aSmrgPROFITS,  WHETHER  IN  AN  ACTION OF CONTRACT, NEGLIGENCE OR
31444c061aSmrgOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION  WITH
32444c061aSmrgTHE USE OR PERFORMANCE OF THIS SOFTWARE.
33444c061aSmrg
34444c061aSmrg******************************************************************/
35444c061aSmrg
36444c061aSmrg/*
37444c061aSmrg
38444c061aSmrgCopyright 1987, 1988, 1998  The Open Group
39444c061aSmrg
40444c061aSmrgPermission to use, copy, modify, distribute, and sell this software and its
41444c061aSmrgdocumentation for any purpose is hereby granted without fee, provided that
42444c061aSmrgthe above copyright notice appear in all copies and that both that
43444c061aSmrgcopyright notice and this permission notice appear in supporting
44444c061aSmrgdocumentation.
45444c061aSmrg
46444c061aSmrgThe above copyright notice and this permission notice shall be included in
47444c061aSmrgall copies or substantial portions of the Software.
48444c061aSmrg
49444c061aSmrgTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
50444c061aSmrgIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
51444c061aSmrgFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
52444c061aSmrgOPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
53444c061aSmrgAN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
54444c061aSmrgCONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
55444c061aSmrg
56444c061aSmrgExcept as contained in this notice, the name of The Open Group shall not be
57444c061aSmrgused in advertising or otherwise to promote the sale, use or other dealings
58444c061aSmrgin this Software without prior written authorization from The Open Group.
59444c061aSmrg
60444c061aSmrg*/
61444c061aSmrg/* $XFree86: xc/lib/Xt/SetSens.c,v 1.3 2001/12/14 19:56:29 dawes Exp $ */
62444c061aSmrg
63444c061aSmrg#ifdef HAVE_CONFIG_H
64444c061aSmrg#include <config.h>
65444c061aSmrg#endif
66444c061aSmrg#include "IntrinsicI.h"
67444c061aSmrg#include "StringDefs.h"
68444c061aSmrg
69444c061aSmrg/*
70444c061aSmrg *	XtSetSensitive()
71444c061aSmrg */
72444c061aSmrg
73444c061aSmrgstatic void SetAncestorSensitive(
74444c061aSmrg    register Widget widget,
75444c061aSmrg    Boolean	    ancestor_sensitive)
76444c061aSmrg{
77444c061aSmrg    Arg			args[1];
78444c061aSmrg    register Cardinal   i;
79444c061aSmrg    register WidgetList children;
80444c061aSmrg
81444c061aSmrg    if (widget->core.ancestor_sensitive == ancestor_sensitive) return;
82444c061aSmrg
83444c061aSmrg    XtSetArg(args[0], XtNancestorSensitive, ancestor_sensitive);
84444c061aSmrg    XtSetValues(widget, args, XtNumber(args));
85444c061aSmrg
86444c061aSmrg    /* If widget's sensitive is TRUE, propagate new ancestor_sensitive to
87444c061aSmrg       children's ancestor_sensitive; else do nothing as children's
88444c061aSmrg       ancestor_sensitive is already FALSE */
89444c061aSmrg
90444c061aSmrg    if (widget->core.sensitive && XtIsComposite(widget)) {
91444c061aSmrg	children = ((CompositeWidget) widget)->composite.children;
92444c061aSmrg	for (i=0; i < ((CompositeWidget)widget)->composite.num_children; i++) {
93444c061aSmrg	    SetAncestorSensitive (children[i], ancestor_sensitive);
94444c061aSmrg	}
95444c061aSmrg    }
96444c061aSmrg} /* SetAncestorSensitive */
97444c061aSmrg
98444c061aSmrg
99444c061aSmrgvoid XtSetSensitive(
100444c061aSmrg    register Widget widget,
101444c061aSmrg    _XtBoolean	    sensitive)
102444c061aSmrg{
103444c061aSmrg    Arg			args[1];
104444c061aSmrg    register Cardinal   i;
105444c061aSmrg    register WidgetList children;
106444c061aSmrg    WIDGET_TO_APPCON(widget);
107444c061aSmrg
108444c061aSmrg    LOCK_APP(app);
109444c061aSmrg    if (widget->core.sensitive == sensitive) {
110444c061aSmrg	UNLOCK_APP(app);
111444c061aSmrg	return;
112444c061aSmrg    }
113444c061aSmrg
114444c061aSmrg    XtSetArg(args[0], XtNsensitive, sensitive);
115444c061aSmrg    XtSetValues(widget, args, XtNumber(args));
116444c061aSmrg
117444c061aSmrg    /* If widget's ancestor_sensitive is TRUE, propagate new sensitive to
118444c061aSmrg       children's ancestor_sensitive; else do nothing as children's
119444c061aSmrg       ancestor_sensitive is already FALSE */
120444c061aSmrg
121444c061aSmrg    if (widget->core.ancestor_sensitive && XtIsComposite (widget)) {
122444c061aSmrg	children = ((CompositeWidget) widget)->composite.children;
123444c061aSmrg	for (i = 0; i < ((CompositeWidget)widget)->composite.num_children; i++){
124444c061aSmrg	    SetAncestorSensitive (children[i], sensitive);
125444c061aSmrg	}
126444c061aSmrg    }
127444c061aSmrg    UNLOCK_APP(app);
128444c061aSmrg} /* XtSetSensitive */
129