home *** CD-ROM | disk | FTP | other *** search
- (in-package :oou)
- (oou-provide :PICT-svm)
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;; PICT-svm.Lisp
- ;;
- ;; Copyright ⌐ 1992 Northwestern University Institute for the Learning Sciences
- ;; All Rights Reserved
- ;;
- ;; author: Michael S. Engber
- ;;
- ;; mixin for adding PICTs to views
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
- (oou-dependencies
- :graphic-rsrc-svm
- :PICT-u
- :records-u)
-
- (export '(PICT-svm set-view-PICT))
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
- (defclass PICT-svm (graphic-rsrc-svm)
- ((rsrc-id :initarg :PICT-id)
- (rsrc-name :initarg :PICT-name)
- (rsrc-handle :initarg :PICT-handle)
- (PICT-file :initarg :PICT-file)
- (PICT-storage :initarg :PICT-storage)
- (graphic-scaling :initarg :PICT-scaling))
- (:default-initargs
- :rsrc-type "PICT"
- :PICT-storage :memory
- :graphic-default-size #@(100 100)))
-
- (defmethod rsrc-handle-install ((sv PICT-svm))
- (call-next-method)
- (when (and (not (slot-boundp sv 'rsrc-handle)) (slot-boundp sv 'PICT-file))
- (setf (slot-value sv 'rsrc-handle)
- (ecase (slot-value sv 'PICT-storage)
- (:memory (get-picture-from-file (slot-value sv 'PICT-file)))
- (:disk (let ((PICT_h (#_NewHandle (rlength :Picture))))
- (when (%null-ptr-p PICT_h)
- (error "unable to allocate a ~a picture record handle (~a bytes) for ~s"
- (rlength :Picture)
- (slot-value sv 'PICT-file)))
- (with-dereferenced-handles ((PICT_p PICT_h))
- (get-PICT-file-info (slot-value sv 'PICT-file) PICT_p))
- PICT_h))))))
-
- (defmethod rsrc-get-fn ((sv PICT-svm) rsrc-type rsrc-id-or-name)
- (declare (ignore rsrc-type))
- (etypecase rsrc-id-or-name
- (fixnum (#_GetPicture rsrc-id-or-name))
- (string (#_GetPicture (get-resource-id "PICT" rsrc-id-or-name)))))
-
- (defmethod graphic-size ((sv PICT-svm) PICT-handle)
- (declare (ignore sv))
- (subtract-points
- (href PICT-handle :Picture.picFrame.botRight)
- (href PICT-handle :Picture.picFrame.topLeft )))
-
- (defmethod draw-graphic ((sv PICT-svm) PICT-handle rect)
- (ecase (slot-value sv 'PICT-storage)
- (:memory (#_DrawPicture PICT-handle rect))
- (:disk (draw-picture-from-file (slot-value sv 'PICT-file) rect))))
-
- (defmethod view-default-size ((sv PICT-svm))
- (add-points (multiple-value-call #'add-points (graphic-margins sv)) #@(100 100)))
-
- (defmethod set-view-PICT ((sv PICT-svm) &key PICT-id PICT-name PICT-handle PICT-file PICT-storage)
- (when PICT-file (setf (slot-value sv 'PICT-file) PICT-file))
- (when PICT-storage (setf (slot-value sv 'PICT-storage) PICT-storage))
- (set-view-resource sv :rsrc-id PICT-id :rsrc-name PICT-name :rsrc-handle PICT-handle))
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- #|
- example code can be found in PICT-di
- |#