[plt-scheme] windowing, drawing, editor

From: Katsmall the Wise (kela_bit at netvision.net.il)
Date: Mon Apr 7 17:12:07 EDT 2003

The problem is, it does refresh on resize, but does not remember what 
you drew on it.
Thus, you should use a memory-canvas% like I used:
; draws the log into the dc, eliminating error causing items.
(define (log->dc log dc)
  (define (iter l)
    (cond
      [(empty? l)
       empty]
      [(with-handlers ([exn? (lambda args #t)])
         (eval (append `(send ,dc)
                       (car l)))
         #f) ; in case of error
       (iter (cdr l))]
      [else
       (cons (car l) (iter (cdr l)))]))
  (iter log))
(define-macro define-dc-proc
  (lambda (name)
    `(begin
       (define (,name . args)
         (set! log (cons (cons ',name args) log))
         (refresh))
       (public ,name))))
(define memory-canvas%
  (class canvas%
    (super-instantiate ())
    (inherit get-dc)
    (inherit refresh)
    (define log empty)
    (define-dc-proc draw-line)
    (define-dc-proc draw-ellipse)
                ...
    (define-dc-proc set-pen)
    (define-dc-proc set-brush)
                ...
    (define/override (on-paint)
      (set! log (log->dc log (get-dc))))))

That should be about it, hope there are no errors.
This remembers what you drew on it with a log, then draws it again on-paint.

Katsmall the Wise

Vincent Hourdin wrote:

>  For list-related administrative tasks:
>  http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>
>Hi,
>I am currently working on an interface which has to support an editor (1/3 of 
>window size), a draw or a picture on which texts must be displayed, 
>radio-boxes and things like that.
>I tried to build a canvas and started to draw in his dc%, but I've seen I 
>cannot put my radio-box objects in this kind of display.
>So questions are:
>- How can I have a single window with control objects, several text displays 
>and a draw or a picture of my draw ?
>- How can I maximize a window under linux ?
>- Why does (send my-frame refresh) has no effect ? How can I make it refresh 
>itself automatically when it is moved or resized ... ?
>- How can I make my editor only take 1/3 of the frame space ?
>
>Thank you !
>
>  
>



Posted on the users mailing list.