[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: view-draw-contents
- To: Mark Nahabedian <naha@RIVERSIDE.SCRC.Symbolics.COM>
- Subject: Re: view-draw-contents
- From: bill@cambridge.apple.com (Bill St. Clair)
- Date: Tue, 5 May 1992 11:00:37 -0500
- Cc: info-mcl
>I would like to thank those who responded for their helpful suggestions
>about the view-draw-contents methods for my table cells. The problem
>did involve cursor positioning.
>
>I would up using Rich Lynch's suggestion of using #_TextBox to draw the
>text, which provided the additional functionality of right alignment of
>the numbers in the table.
>
>Now that that is solved and the program is basicly working I can address
>more frivolous matters. I'd like the row and column headings to come
>out in bold and certain cells to come out it italic. The headings are
>displayed in their own table cells just like the data. The font
>descriptor I'm using for the VIEW-FONT of the heading cells is
>
> ("geneva" :bold 9)
>
>but the text comes out the same as for the data cells whose TEXT-FONT is
>
> ("geneva" :plain 9)
>
>Is this merely because a bold font is unavailable? I have not installed
>TrueType or ATM.
Font focusing is not done by default except for dialog items.
You could define your table cells to be dialog items, or follow the
example included below.
>
>Also: I have a MacPlus with 4 meg of memory. If I upgrade to System 7,
>will the performance hit be modest or severe?
Though System 7's Finder is noticeably slower than System 6's, the
performance of applications is roughly the same. One thing that will
slow you down a bit is that MultiFinder is always enabled, and the
Finder will take some of your processor cycles when it is in the
background. I haven't found this to be noticeable (but I have a
Mac IIci).
The real problem with running MCL on a 4 meg mac under System 7
is that you'll effectively lose 600K-1M bytes of your memory.
Even with System 7 tune-up installed and no extensions loaded,
the system+finder requires a megabyte. This leaves you only
3 megs for MCL. This is enough to do real work, but will probably
not be enough to work with large datasets (ROOM says 97K free in the
Mac Heap, and 1357K free in the Lisp heap).
As always, these opinions are mine, not Apple's.
-Bill
------------------------------------------------------------------
;;; b1-font-focusing-macros.lisp
;;;
;;; This file defines the two font focusing macros that will be
;;; exported/documented in MCL 2.0 final.
;;;
;;; with-focused view does nothing about fonts, it only sets
;;; the grafport, origin, and clip region.
;;; These macros set the font as well.
(in-package :ccl)
;; with-font-focused-view executes its body focused on view and its font.
(defmacro with-font-focused-view (view &body body)
(let ((view-var (gensym)))
`(let ((,view-var ,view))
(with-focused-font-view (,view-var ,view-var)
,@body))))
;; with-focused-dialog-item is how simple-view's that care about
;; their fonts should be focused. It focuses on the container's
;; grafport, origin, and clip region, but uses item's font.
;; container defaults to (view-container item).
(defmacro with-focused-dialog-item ((item &optional container) &body body)
(let ((item-var (gensym)))
`(let ((,item-var ,item))
(with-focused-font-view (,item-var ,container)
,@body))))
#|
;; How to make a simple-view and regular view automatically focus their fonts
(defclass my-simple-view (simple-view)
((text :initform "my-simple-view" :initarg :text :accessor text)))
(defmethod view-focus-and-draw-contents ((view my-simple-view) &optional visrgn cliprgn)
(with-focused-dialog-item (view)
(when (regions-overlap-p visrgn cliprgn)
(view-draw-contents view))))
; Should really center the text vertically by adding the font ascent and descent,
; but that would complicate this example.
(defmethod view-draw-contents ((view my-simple-view))
(let ((pos (view-position view))
(size-v (point-v (view-size view))))
(#_MoveTo (+ (point-h pos) 3) (+ (point-v pos) size-v -3))
(with-pstrs ((s (text view)))
(#_DrawString s))))
(defclass my-view (view)
((text :initform "my-view" :initarg :text :accessor text)))
(defmethod view-focus-and-draw-contents ((view my-view) &optional visrgn cliprgn)
(with-font-focused-view view
(when (regions-overlap-p visrgn cliprgn)
(view-draw-contents view))))
(defmethod view-draw-contents ((view my-view))
(let ((size-v (point-v (view-size view))))
(#_MoveTo 3 (- size-v 3))
(with-pstrs ((s (text view)))
(#_DrawString s)))
(call-next-method))
(make-instance 'window
:view-size #@(500 75)
:view-subviews
(list (make-instance 'my-simple-view
:view-size #@(200 30)
:view-position #@(10 10)
:text "A long string that won't be truncated"
:view-font '("New York" 24 :shadow))
(make-instance 'my-view
:view-size #@(200 30)
:view-position #@(10 40)
:text "A long string that will be truncated"
:view-font '("Monaco" 24 :outline))))
|#