[plt-scheme] Pasteboard in pasteboard and the error: here: I am

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Wed Apr 8 08:54:27 EDT 2009

At Sat, 04 Apr 2009 22:16:28 +0200, Jens Axel Soegaard wrote:
> Can anyone provide a simple example of a
> pasteboard containing another pasteboard?
> Preferably where the containing pasteboard
> is diplayable (via an editor-snip) in the DrScheme REPL?

Like this?

 (let ([pb1 (new pasteboard%)]
       [pb2 (new pasteboard%)])
   (send pb1
         (new editor-snip% [editor pb2])
         0 0)
   (let ([e (new editor-snip% [editor pb1])])
     (send e resize 100 100)

> Anyways, while playing I came upon this error,
>      here: I am
> which, well, is not too informative.
> What does it mean, and why does it occur?

Based on the surrounding `when' in the source, I've changed the error
message to

 allotted width or height is not positive

But the root of the problem seems to be in adding to a column without
first putting the column's snip into an editor (and so that's still not
a good error message). I hacked `column->snip' like this:

 (define (column->snip col frame canvas parent)
    (let* ([pasteboard  (new vertical-pasteboard%)]
           [editor-snip (new aligned-editor-snip% [editor pasteboard]
                             [min-width 1] [min-height 1])]
           [frame       (if frame frame
                            (new frame% [label
                                      "never shown, needed by canvas"]))]
           [canvas      (if canvas canvas
                            (new aligned-editor-canvas% [parent frame]
                                  [editor pasteboard]))])
      (when parent
        (send parent insert editor-snip))
      (insert-snips pasteboard
                    (reverse (map (lambda (e)
                                    (element->snip e frame canvas pasteboard))
                                  (column-elements col))))
      (realign pasteboard)

and `element->snip' propagates the parent in the obvious way, while
`column-write' supplies #f as the parent. That seems to make it work.

Posted on the users mailing list.