home *** CD-ROM | disk | FTP | other *** search
/ Otherware / Otherware_1_SB_Development.iso / mac / developm / source / oodleutl.cpt / oodles-of-utils / mixin-madness / dialog-item-mixins / disable-dim.lisp < prev    next >
Encoding:
Text File  |  1992-01-30  |  1.4 KB  |  47 lines

  1. (in-package :oou)
  2. (oou-provide :disable-dim)
  3. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  4. ;; disable-dim.Lisp
  5. ;;
  6. ;; Copyright ⌐ 1992 Northwestern University Institute for the Learning Sciences
  7. ;; All Rights Reserved
  8. ;;
  9. ;; author: Michael S. Engber
  10. ;;
  11. ;; Dialog item mixin for graying out disabled dialog items.
  12. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  13.  
  14. (oou-dependencies
  15.  :QuickDraw-u
  16.  :simple-view-ce)
  17.  
  18. (export '(disable-dim))
  19.  
  20. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  21.  
  22. (defclass disable-dim ()
  23.   ((dim-pnMode :initarg :dim-pnMode
  24.                :accessor dim-pnMode)
  25.    (dim-pnPat  :initarg :dim-pnPat
  26.                :accessor dim-pnPat))
  27.   (:default-initargs :dim-pnMode #.#$patBic :dim-pnPat *gray-pattern*))
  28.  
  29. (defmethod view-draw-contents :after ((di disable-dim))
  30.   (unless (dialog-item-enabled-p di)
  31.     (with-pen-state (:pnMode (dim-pnMode di)
  32.                      :pnPat  (dim-pnPat di))
  33.       (multiple-value-bind (topLeft botRight) (view-corners di)
  34.         (rlet ((r :Rect :topLeft topLeft :bottomRight botRight))
  35.           (#_PaintRect r))))))
  36.  
  37.  
  38. ;;;Hacks to fix enable/disable erase problem
  39.  
  40. (defmethod dialog-item-enable :before ((di disable-dim))
  41.   (erase-view di))
  42.  
  43. (defmethod dialog-item-disable :before ((di disable-dim))
  44.   (erase-view di))
  45.  
  46. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  47.