home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / X / mit / lib / Xt / SetSens.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-01-06  |  3.1 KB  |  91 lines

  1. /* $XConsortium: SetSens.c,v 1.3 91/01/06 13:32:42 rws Exp $ */
  2.  
  3. /***********************************************************
  4. Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts,
  5. and the Massachusetts Institute of Technology, Cambridge, Massachusetts.
  6.  
  7.                         All Rights Reserved
  8.  
  9. Permission to use, copy, modify, and distribute this software and its 
  10. documentation for any purpose and without fee is hereby granted, 
  11. provided that the above copyright notice appear in all copies and that
  12. both that copyright notice and this permission notice appear in 
  13. supporting documentation, and that the names of Digital or MIT not be
  14. used in advertising or publicity pertaining to distribution of the
  15. software without specific, written prior permission.  
  16.  
  17. DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  18. ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
  19. DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
  20. ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  21. WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  22. ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  23. SOFTWARE.
  24.  
  25. ******************************************************************/
  26.  
  27. #include "IntrinsicI.h"
  28. #include "StringDefs.h"
  29.  
  30. /*
  31.  *    XtSetSensitive()
  32.  */
  33.  
  34. static void SetAncestorSensitive(widget, ancestor_sensitive)
  35.     register Widget widget;
  36.     Boolean        ancestor_sensitive;
  37. {
  38.     Arg            args[1];
  39.     register Cardinal   i;
  40.     register WidgetList children;
  41.  
  42.     if (widget->core.ancestor_sensitive == ancestor_sensitive) return;
  43.  
  44.     XtSetArg(args[0], XtNancestorSensitive, ancestor_sensitive);
  45.     XtSetValues(widget, args, XtNumber(args));
  46.  
  47.     /* If widget's sensitive is TRUE, propagate new ancestor_sensitive to
  48.        children's ancestor_sensitive; else do nothing as children's
  49.        ancestor_sensitive is already FALSE */
  50.     
  51.     if (widget->core.sensitive && XtIsComposite(widget)) {
  52.     children = ((CompositeWidget) widget)->composite.children;
  53.     for (i=0; i < ((CompositeWidget)widget)->composite.num_children; i++) {
  54.         SetAncestorSensitive (children[i], ancestor_sensitive);
  55.     }
  56.     }
  57. } /* SetAncestorSensitive */
  58.  
  59.  
  60. #if NeedFunctionPrototypes
  61. void XtSetSensitive(
  62.     register Widget widget,
  63.     _XtBoolean        sensitive
  64.     )
  65. #else
  66. void XtSetSensitive(widget, sensitive)
  67.     register Widget widget;
  68.     Boolean        sensitive;
  69. #endif
  70. {
  71.     Arg            args[1];
  72.     register Cardinal   i;
  73.     register WidgetList children;
  74.  
  75.     if (widget->core.sensitive == sensitive) return;
  76.  
  77.     XtSetArg(args[0], XtNsensitive, sensitive);
  78.     XtSetValues(widget, args, XtNumber(args));
  79.  
  80.     /* If widget's ancestor_sensitive is TRUE, propagate new sensitive to
  81.        children's ancestor_sensitive; else do nothing as children's
  82.        ancestor_sensitive is already FALSE */
  83.     
  84.     if (widget->core.ancestor_sensitive && XtIsComposite (widget)) {
  85.     children = ((CompositeWidget) widget)->composite.children;
  86.     for (i = 0; i < ((CompositeWidget)widget)->composite.num_children; i++){
  87.         SetAncestorSensitive (children[i], sensitive);
  88.     }
  89.     }
  90. } /* XtSetSensitive */
  91.