Hi,

I'm using the plot-snip function to have interactive plots inside other GUI 
elements in my application.  This worked fine under Racket 6.1.1 but fails 
under Racket 6.2 (bot versions are 64 bit on Windows).  The program below 
illustrates the problem:  the function `working` creates a plot window 
using plot-frame.  The plot is resized correctly and the interactive zoom 
works as expected.  The function `not-working` tries to do the same, but 
creates the plot using plot-snip than adds it to a snip canvas.  It does 
essentially what plot-frame does, without the error checking (I copied out 
the functions from he plot package).  With this version, the plot is not 
resized correctly inside the window and zoom in and out does not work 
correctly.   Both functions work as expected under Racket version 6.1.1.

The program makes use of snip-canvas% which is in unstable/gui, but as far 
as I can tell, it has not changed between the two versions.

Does anyone know what needs to be done to get this to work, or is this a 
bug in the plot package?

Thanks,
Alex.

#lang racket/gui
(require plot)
(require unstable/gui/snip)

;; snip-frame% and make-snip-frame are copied from 
;; C:\Program Files\Racket\share\pkgs\plot-gui-lib\plot\private\gui\gui.rkt

(define snip-frame%
  (class frame%
    (define/override (on-traverse-char event)
      (define key-code (send event get-key-code))
      (case key-code
        [(escape)  (send this show #f)]
        [else  (super on-traverse-char event)]))
    
    (super-new)))

(define (make-snip-frame snip width height label)
  (define (make-snip w h) snip)
  
  (define frame
    (new snip-frame% [label label] [width (+ 20 width)] [height (+ 20 
height)]))
  
  (new snip-canvas%
       [parent frame]
       [make-snip make-snip]
       [horiz-margin 5] [vert-margin 5]
       [horizontal-inset 5] [vertical-inset 5])
  
  frame)

;; This works as expected when resizing the window and zooming the graph
(define (working)
  (parameterize ([plot-width    150]
                 [plot-height   150]
                 [plot-x-label  #f]
                 [plot-y-label  #f])
    (send (plot-frame (function sqr -2 2)) show #t)))

;; This does not
(define (not-working)
  (parameterize ([plot-width    150]
                 [plot-height   150]
                 [plot-x-label  #f]
                 [plot-y-label  #f])
    ;; this is essentially what plot-frame does sans error checking
    (send (make-snip-frame (plot-snip (function sqr -2 2)) 200 200 "hello") 
show #t)))

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-dev/f6feee82-3188-4272-ba15-872cf32d4632%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to