[racket] Invisible Canvas question

From: Eduardo Bellani (ebellani at gmail.com)
Date: Thu Mar 31 17:04:35 EDT 2011

Thanks Matthew for the prompt reply. Just noticed the dot and the part
in the docs referring to the geometry management.

On 03/31/2011 05:58 PM, Matthew Flatt wrote:
> A plain `panel%' doesn't perform any geometry management of its
> children, and so `invisible-canvas' isn't moved and resized to fill the
> frame. On my screen, I can see a little white dot where the canvas is 1
> pixel by 1 pixel.
> 
> Normally, you want either `vertical-panel%' or `horizontal-panel%', or
> you make a subclass of `panel%' to implement a different kind of
> geometry management.
> 
> 
> At Thu, 31 Mar 2011 17:29:14 -0300, Eduardo Bellani wrote:
>> Could someone please explain why there is an invisible canvas in this
>> example?
>>
>> Env:
>> Linux 2.6.31-23-generic Ubuntu i686 GNU/Linux
>> racket 5.1.0.4
>>
>> #lang racket
>>
>> (require racket/gui)
>>
>> (define bitmap-canvas%
>>   (class canvas%
>>     (init-field [bitmap #f])
>>     (inherit get-dc)
>>     (define/override (on-paint)
>>       (send (get-dc) draw-bitmap bitmap 0 0))
>>     (super-new)))
>>
>>
>> (define bitmap (read-bitmap "data/image_0.jpg"))
>>
>> (define f (new frame% [label "foo"] [width 100] [height 100]))
>> (define p (new panel% [parent f]))
>> (define p2 (new vertical-panel% [parent f]))
>>
>> ;; why is this invisible?
>> (define invisible-canvas (new bitmap-canvas%
>>                               [parent p]
>>                               [bitmap bitmap]))
>> (define visible-canvas (new bitmap-canvas%
>>                             [parent p2]
>>                             [bitmap bitmap]))
>>
>> (send f show #t)
>>
>>
>>
>>
>> -- 
>> Eduardo Bellani
>>
>> omnia mutantur, nihil interit.
>> _________________________________________________
>>   For list-related administrative tasks:
>>   http://lists.racket-lang.org/listinfo/users


-- 
Eduardo Bellani

omnia mutantur, nihil interit.


Posted on the users mailing list.