[plt-scheme] About canvas class

From: François Michaudon (f.michaudon at gmail.com)
Date: Mon Apr 27 03:19:59 EDT 2009

hi ,
What's the best between :

(define MY-CANVAS%
  (class canvas%
    (init-field
     (buff (make-object bitmap% 1000 1000))
     (Dbuffer  (new bitmap-dc% [bitmap buff ] ))
     (bitmap1 (make-object bitmap% "test.jpg")))

    (inherit get-dc)
    (define/override (refresh)
      (send Dbuffer clear)
      (send Dbuffer draw-bitmap bitmap1 0 0 'solid )
      (send (get-dc) draw-bitmap Dbuffer 0 0))

    (define/override (on-paint) (send this refresh))
    (super-new)))

or like this:

(define buff (make-object bitmap% 1000 1000))
(define Dbuffer  (new bitmap-dc% (bitmap buff)))
(define bitmap1 (make-object bitmap% "test.jpg"))

(define canvas  (new canvas%
                     (parent FRAME)
                     (paint-callback (λ (c dc)
                                       (send Dbuffer clear)
                                       (send Dbuffer draw-bitmap bitmap1 0 0
'solid )
                                       (send dc draw-bitmap Dbuffer 0 0)))))



I get the same result, but whicth method I must use ?
What is the most conventional?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20090427/9afb096e/attachment.html>

Posted on the users mailing list.