home *** CD-ROM | disk | FTP | other *** search
- (in-package :oou)
- (oou-provide :static-text-svm)
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;; static-text-svm.Lisp
- ;;
- ;; Copyright ⌐ 1992 Northwestern University Institute for the Learning Sciences
- ;; All Rights Reserved
- ;;
- ;; author: Michael S. Engber
- ;;
- ;; mixin for adding static text to views
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
- (oou-dependencies :simple-view-ce
- :traps-u)
-
- (export '(static-text-svm text-just text-margins text-string))
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
- (defclass static-text-svm ()
- ((text-string :initarg :text-string
- :accessor text-string)
- (color-list :initarg :part-color-list)
- (text-just))
- (:default-initargs
- :text-string "hi,ho"
- :text-just :center))
-
- (defmethod initialize-instance :after ((sv static-text-svm) &rest initargs &key text-just)
- (declare (dynamic-extent initargs)
- (ignore initargs))
- (setf (text-just sv) text-just))
-
- (defpascal dummy-EraseRect (:ptr r :void) (declare (ignore r)))
-
- (defmethod view-draw-contents :after ((sv static-text-svm))
- (multiple-value-bind (topLeft botRight) (text-corners sv)
- (rlet ((r :Rect
- :topLeft topLeft
- :bottomRight botRight))
- (with-cstrs ((s (text-string sv)))
- (with-fore-color (getf (part-color-list sv) :text *black-color*)
- (with-patched-trap (#_EraseRect dummy-EraseRect)
- (#_TextBox s (text-length sv) r (slot-value sv 'text-just))))))))
-
- (defmethod set-view-font :after ((sv static-text-svm) font-spec)
- (declare (ignore font-spec))
- (invalidate-view sv t))
-
- (defmethod (setf text-string) :after (new-text-string (sv static-text-svm))
- (declare (ignore new-text-string))
- (invalidate-view sv t))
-
- (defmethod text-just ((sv static-text-svm))
- ;;internally text-just is stored as the corresponding ToolBox constant
- (ecase (slot-value sv 'text-just)
- (#.#$teFlushDefault :default)
- (#.#$teCenter :center)
- (#.#$teFlushRight :right)
- (#.#$teFlushLeft :left)))
-
- (defmethod (setf text-just) (new-text-just (sv static-text-svm))
- ;;internally text-just is stored as the corresponding ToolBox constant
- (setf (slot-value sv 'text-just) (ecase new-text-just
- (:default #$teFlushDefault)
- (:center #$teCenter)
- (:right #$teFlushRight)
- (:left #$teFlushLeft)))
- (invalidate-view sv)
- new-text-just)
-
- (defmethod text-margins ((sv static-text-svm))
- (declare (ignore sv))
- (values #@(0 0) #@(0 0)))
-
- (defmethod text-corners ((sv static-text-svm))
- (multiple-value-bind (topLeft botRight) (focused-corners sv)
- (multiple-value-bind (tl-margin br-margin) (text-margins sv)
- (values (add-points topLeft tl-margin) (subtract-points botRight br-margin)))))
-
- (defmethod text-length ((sv static-text-svm))
- (length (text-string sv)))
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
- #|
- example code can be found in static-text-di
- |#