home *** CD-ROM | disk | FTP | other *** search
/ Otherware / Otherware_1_SB_Development.iso / mac / developm / source / oodleutl.cpt / oodles-of-utils / mixin-madness / simple-view-mixins / frame-svm.lisp < prev    next >
Encoding:
Text File  |  1992-02-17  |  2.4 KB  |  77 lines

  1. (in-package :oou)
  2. (oou-provide :frame-svm)
  3. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  4. ;; frame-svm.Lisp
  5. ;;
  6. ;; Copyright ⌐ 1992 Northwestern University Institute for the Learning Sciences
  7. ;; All Rights Reserved
  8. ;;
  9. ;; author: Michael S. Engber
  10. ;;
  11. ;; Simple view mixin for 3D framing the view.
  12. ;; Note: this effect only looks right over grayish backgrounds.
  13. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  14.  
  15. (oou-dependencies
  16.  :simple-view-ce
  17.  :QuickDraw-u)
  18.  
  19.  
  20. (export '(frame-svm draw-frame))
  21.  
  22. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  23.  
  24. (defclass frame-svm ()
  25.   ((frame-width :initarg :frame-width
  26.                 :accessor frame-width)
  27.    (color-list  :initarg :part-color-list))
  28.   (:default-initargs
  29.     :part-color-list nil
  30.     :frame-width 1))
  31.  
  32. (defmethod (setf frame-width) :after (new-width (sv frame-svm))
  33.   (declare (ignore new-width))
  34.   (invalidate-view sv t))
  35.  
  36. (defmethod view-draw-contents :after ((sv frame-svm))
  37.   (multiple-value-bind (topLeft botRight) (focused-corners sv)
  38.     (rlet ((r :Rect
  39.               :topLeft topLeft
  40.               :bottomRight botRight))
  41.       (with-fore-color (getf (part-color-list sv) :frame *black-color*)
  42.         (with-pen-state (:pnSize (make-point (frame-width sv) (frame-width sv)))
  43.           (draw-frame sv r))))))
  44.  
  45. (defmethod draw-frame ((sv frame-svm) rect)
  46.   (with-pen-state (:pnSize (make-point (frame-width sv) (frame-width sv)))
  47.     (#_FrameRect rect)))
  48.  
  49. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  50.  
  51. #|
  52.  
  53. ;;; a modest example - adding a frame to static text dialog items
  54.  
  55. (defclass sttxt (static-text-dialog-item frame-svm) ())
  56.  
  57. (progn
  58.   (setf *test-w*
  59.         (make-instance 'dialog
  60.                        :window-type :document
  61.                        :view-position :centered
  62.                        :view-size #@(200 100)
  63.                        :window-title "3D frame demo"
  64.                        ))
  65.   
  66.   (add-subviews *test-w* (make-dialog-item 'sttxt
  67.                                            #@(20 20)
  68.                                            #@(163 18)
  69.                                            "I'm static text + a mixin"
  70.                                            #'(lambda (item) (declare (ignore item)) (ed-beep))
  71.                                            
  72.                                            :view-nick-name :butt
  73.                                            )))
  74.  
  75. ;(setf (frame-width (view-named :butt *test-w*)) 4)
  76.  
  77. |#