The following program looks "correct" when my Windows display scaling is 
set to 100%, and looks "wrong" when set to anything higher than 100%. By 
"correct" I mean that the 4 squares meet in the center of the canvas, 
stretched to the maximum size possible that the canvas width and height 
will allow.

What is interesting is that I can make the program look correct by 
immediately scaling the values returned from `get-scaled-client-size`. For 
example, if my display is set to 150%, I can make the program look correct 
by immediately multiplying the returned width and height by 2/3, because 
100% is 2/3 of 150%. But right now I have to hard-code the 2/3 factor. Is 
there a way to get that 2/3 factor programmatically in Racket? Or (even 
better), is there something else I should be calling instead of 
`get-scaled-client-size` that would return the dimensions I want?

This is Racket CS 8.0.0.11 on Windows. Let me know if you want screenshots. 
Thanks in advance.


#lang racket/gui

(require pict)

(define frame
  (new frame%
       [label "Scale Test"]))

(define (paint canvas dc)
  (define-values (w h) (send canvas get-scaled-client-size))
  (define-values (size x-offset y-offset)
    (if (> w h)
        (values h (/ (- w h) 2) 0)
        (values w 0 (/ (- h w) 2))))
  (println (list w h size x-offset y-offset))
  (for ([x (list x-offset (+ x-offset (/ size 2)))]
        #:when #t
        [y (list y-offset (+ y-offset (/ size 2)))])
    (send dc draw-rectangle x y (/ size 2) (/ size 2))))

(define canvas
  (new canvas%
       [parent frame]
       [paint-callback paint]))

(send frame show #t)

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/ef44708d-8938-4a57-b2d7-576b02bdd8f3n%40googlegroups.com.

Reply via email to