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