Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

newlines in table cells [nonews]

2 views
Skip to first unread message

Jeffrey Kane

unread,
Oct 2, 1999, 3:00:00 AM10/2/99
to
The default method for drawing cells calls "draw-string-crop", a function that doesn't draw return characters.

You need to simply override the draw-cell-contents method with one that will draw your text. A simple version (if this is a mac only program) might call the toolbox routine "Textbox", for example:


(defmethod cell-contents-string ((item my-table-dialog-item) h &optional v)
"Return the contents as a string"
(let ((contents (cell-contens item h v)))
(unless (stringp contents)
(setf contents (princ-to-string contents)))
contents))


(defmethod draw-cell-contents ((item my-table-dialog-item) h &optional v)
(ccl::normalize-h&v h v)
(let ((cell-position (cell-position item h v))
(view-position (view-position item)))
(rlet ((box :rect
:topleft cell-position)
:bottomright (add-points cell-position (cell-size item)))
(clip-rect :rect
:topleft view-position
:bottomright (add-points view-position (view-size item))))
(with-clip-rect clip-rect
(with-cstrs ((s (cell-contents-string item h v)))
(#_EraseRect box)
(#_TextBox s
(length (cell-contents-string item h v))
box
$teJustLeft))))))

Hope this helps,
Jeffrey

On 9/29/99 at 17:52, ldlc...@ihc.com (Lee Christensen) wrote:

> The existing 'draw-cell-contents seems to remove newlines from displayed
> strings, as well as truncate the string and add ellipses if it is too
> long. I would like to display a table with strings that might contain
> newlines. For instance, in the following example I would like the table
> to look like this:
>
> hello nihauma
> goodbye zaijian
>
> Rather than like this:
>
> hellogoodbye nihaumazaiji...
>
> (let* ((window (MAKE-INSTANCE
> 'COLOR-DIALOG
> :WINDOW-TYPE
> :DOCUMENT-WITH-GROW
> :VIEW-POSITION
> '(:LEFT 37)
> :VIEW-SIZE
> #@(656 563)
> :VIEW-FONT
> '("Charcoal" 12 :SRCOR :PLAIN (:COLOR-INDEX 0))
> :VIEW-SUBVIEWS
> (LIST (MAKE-DIALOG-ITEM
> 'MY-TABLE-DIALOG-ITEM
> #@(7 7)
> #@(639 509)
> ""
> 'NIL
> :VIEW-NICK-NAME 'my-table
> :CELL-SIZE #@(300 48)
> :SELECTION-TYPE
> :CONTIGUOUS
> :TABLE-HSCROLLP T
> :TABLE-VSCROLLP T
> :ROWS 2
> :COLUMNS 2
> :TRACK-THUMB-P NIL
> :SEPARATOR-COLOR 8421504
> :table-print-function #'write-string
> :SEPARATOR-PATTERN '*BLACK-PATTERN*
> :SEPARATOR-SIZE #@(0 0)))))
> (array (make-array `(2 1)
> :initial-contents
> `((,(format nil "hello~%goodbye"))
> (,(format nil
> "nihaoma~%zaijian"))))))
> (ccl::set-table-array (view-named 'my-table window) array)
> (view-draw-contents (view-named 'my-table window)))
>
>
> I fiddled around a bit with the 'table-print-function, and with
> shadowed versions of 'draw-cell-contents, but I have not been
> successful. I am not a "real" die-hard Mac or MCL programmer, and I am
> wondering if there is any simple solution to my quest, or any sample
> code that anyone would not mind sharing.
>
> Thanks all,
>
> Lee Christensen
>
>
> The quality of mercy is not sprained...
>
---
Jeffrey Kane <j...@world.std.com>

0 new messages