home *** CD-ROM | disk | FTP | other *** search
- (in-package :oou)
- (oou-provide :graphic-rsrc-svm)
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;; graphic-rsrc-svm.lisp
- ;;
- ;; Copyright ⌐ 1992 Northwestern University Institute for the Learning Sciences
- ;; All Rights Reserved
- ;;
- ;; author: Michael S. Engber
- ;;
- ;; mixin for displaying graphical resources in views
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
- (oou-dependencies
- :rsrc-svm
- :simple-view-ce)
-
-
- (export '(graphic-rsrc-svm graphic-size draw-graphic graphic-margins))
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
- (defclass graphic-rsrc-svm (rsrc-svm)
- ((graphic-scaling :initarg :graphic-scaling)
- (graphic-default-size :initarg :graphic-default-size)
- (erase-on-set-rsrc-p :initarg :erase-on-set-rsrc-p))
- (:default-initargs
- :graphic-scaling :adjust-view-size
- :graphic-default-size #@(32 32)
- :erase-on-set-rsrc-p t
- ))
-
- (defmethod graphic-size ((sv graphic-rsrc-svm) rsrc-handle)
- (declare (ignore rsrc-handle))
- (slot-value sv 'graphic-default-size))
-
- (defmethod draw-graphic ((sv graphic-rsrc-svm) rsrc-handle rect)
- (declare (ignore sv rsrc-handle rect)))
-
- (defmethod draw-bad-handle ((sv graphic-rsrc-svm))
- (multiple-value-bind (topLeft botRight) (graphic-corners sv)
- (rlet ((r :Rect :topLeft topLeft :botRight botRight))
- (#_FillRect r *light-gray-pattern*)
- (#_FrameRect r))))
-
- (defmethod view-draw-contents ((sv graphic-rsrc-svm))
- (if (slot-boundp sv 'rsrc-handle)
- (with-slots (rsrc-handle) sv
- (with-purgeable-resource (rsrc-handle)
- (multiple-value-bind (topLeft botRight) (graphic-corners sv)
- (if (handlep rsrc-handle)
- (ecase (slot-value sv 'graphic-scaling)
- (:scale-to-view (rlet ((r :Rect :topLeft topLeft :botRight botRight))
- (draw-graphic sv rsrc-handle r)))
- (:adjust-view-size (rlet ((r :Rect
- :topLeft topLeft
- :botRight (add-points topLeft (graphic-size sv rsrc-handle))))
- (draw-graphic sv rsrc-handle r)))
- (:clip-to-view (rlet ((clip-rect :Rect
- :topLeft topLeft
- :botRight botRight)
- (r :Rect :topLeft topLeft :botRight (add-points topLeft (graphic-size sv rsrc-handle))))
- (with-clip-rect clip-rect
- (draw-graphic sv rsrc-handle r)))))
- (draw-bad-handle sv)))))
- (draw-bad-handle sv))
- (call-next-method))
-
- (defmethod graphic-margins ((sv graphic-rsrc-svm))
- (declare (ignore sv))
- (values #@(0 0) #@(0 0)))
-
- (defmethod graphic-corners ((sv graphic-rsrc-svm))
- (multiple-value-bind (topLeft botRight) (focused-corners sv)
- (multiple-value-bind (tl-margin br-margin) (graphic-margins sv)
- (values (add-points topLeft tl-margin) (subtract-points botRight br-margin)))))
-
- (defmethod view-default-size ((sv graphic-rsrc-svm))
- (add-points (multiple-value-call #'add-points (graphic-margins sv))
- (slot-value sv 'graphic-default-size)))
-
- (defmethod scale-view-size ((sv graphic-rsrc-svm))
- (when (slot-boundp sv 'rsrc-handle)
- (with-slots (rsrc-handle) sv
- (let ((margin-size (multiple-value-call #'add-points (graphic-margins sv))))
- (set-view-size sv (add-points (graphic-size sv rsrc-handle) margin-size))))))
-
- (defmethod set-view-size :before ((sv graphic-rsrc-svm) h &optional v)
- (declare (ignore h v))
- (erase-view sv))
-
- (defmethod rsrc-handle-install :after ((sv graphic-rsrc-svm))
- (if (eq :adjust-view-size (slot-value sv 'graphic-scaling))
- (scale-view-size sv)
- (invalidate-view sv t)))
-
- (defmethod set-view-resource :after ((sv graphic-rsrc-svm) &key rsrc-type rsrc-id rsrc-name rsrc-handle)
- (declare (ignore rsrc-type rsrc-id rsrc-name rsrc-handle))
- (invalidate-view sv (slot-value sv 'erase-on-set-rsrc-p)))
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
- #|
- examples can be found in PICT-svm, PICT-di, ICON-di, cicn-di
- |#