SetSens.c revision 1477040f
1/* $Xorg: SetSens.c,v 1.4 2001/02/09 02:03:58 xorgcvs Exp $ */
2
3/***********************************************************
4Copyright 1993 Sun Microsystems, Inc.  All rights reserved.
5
6Permission is hereby granted, free of charge, to any person obtaining a
7copy of this software and associated documentation files (the "Software"),
8to deal in the Software without restriction, including without limitation
9the rights to use, copy, modify, merge, publish, distribute, sublicense,
10and/or sell copies of the Software, and to permit persons to whom the
11Software is furnished to do so, subject to the following conditions:
12
13The above copyright notice and this permission notice (including the next
14paragraph) shall be included in all copies or substantial portions of the
15Software.
16
17THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
20THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23DEALINGS IN THE SOFTWARE.
24
25Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts.
26
27                        All Rights Reserved
28
29Permission to use, copy, modify, and distribute this software and its
30documentation for any purpose and without fee is hereby granted,
31provided that the above copyright notice appear in all copies and that
32both that copyright notice and this permission notice appear in
33supporting documentation, and that the name of Digital not be
34used in advertising or publicity pertaining to distribution of the
35software without specific, written prior permission.
36
37DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
38ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
39DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
40ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
41WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
42ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
43SOFTWARE.
44
45******************************************************************/
46
47/*
48
49Copyright 1987, 1988, 1998  The Open Group
50
51Permission to use, copy, modify, distribute, and sell this software and its
52documentation for any purpose is hereby granted without fee, provided that
53the above copyright notice appear in all copies and that both that
54copyright notice and this permission notice appear in supporting
55documentation.
56
57The above copyright notice and this permission notice shall be included in
58all copies or substantial portions of the Software.
59
60THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
61IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
62FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
63OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
64AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
65CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
66
67Except as contained in this notice, the name of The Open Group shall not be
68used in advertising or otherwise to promote the sale, use or other dealings
69in this Software without prior written authorization from The Open Group.
70
71*/
72/* $XFree86: xc/lib/Xt/SetSens.c,v 1.3 2001/12/14 19:56:29 dawes Exp $ */
73
74#ifdef HAVE_CONFIG_H
75#include <config.h>
76#endif
77#include "IntrinsicI.h"
78#include "StringDefs.h"
79
80/*
81 *	XtSetSensitive()
82 */
83
84static void SetAncestorSensitive(
85    register Widget widget,
86    Boolean	    ancestor_sensitive)
87{
88    Arg			args[1];
89    register Cardinal   i;
90    register WidgetList children;
91
92    if (widget->core.ancestor_sensitive == ancestor_sensitive) return;
93
94    XtSetArg(args[0], XtNancestorSensitive, ancestor_sensitive);
95    XtSetValues(widget, args, XtNumber(args));
96
97    /* If widget's sensitive is TRUE, propagate new ancestor_sensitive to
98       children's ancestor_sensitive; else do nothing as children's
99       ancestor_sensitive is already FALSE */
100
101    if (widget->core.sensitive && XtIsComposite(widget)) {
102	children = ((CompositeWidget) widget)->composite.children;
103	for (i=0; i < ((CompositeWidget)widget)->composite.num_children; i++) {
104	    SetAncestorSensitive (children[i], ancestor_sensitive);
105	}
106    }
107} /* SetAncestorSensitive */
108
109
110void XtSetSensitive(
111    register Widget widget,
112    _XtBoolean	    sensitive)
113{
114    Arg			args[1];
115    register Cardinal   i;
116    register WidgetList children;
117    WIDGET_TO_APPCON(widget);
118
119    LOCK_APP(app);
120    if (widget->core.sensitive == sensitive) {
121	UNLOCK_APP(app);
122	return;
123    }
124
125    XtSetArg(args[0], XtNsensitive, sensitive);
126    XtSetValues(widget, args, XtNumber(args));
127
128    /* If widget's ancestor_sensitive is TRUE, propagate new sensitive to
129       children's ancestor_sensitive; else do nothing as children's
130       ancestor_sensitive is already FALSE */
131
132    if (widget->core.ancestor_sensitive && XtIsComposite (widget)) {
133	children = ((CompositeWidget) widget)->composite.children;
134	for (i = 0; i < ((CompositeWidget)widget)->composite.num_children; i++){
135	    SetAncestorSensitive (children[i], sensitive);
136	}
137    }
138    UNLOCK_APP(app);
139} /* XtSetSensitive */
140