original commit: edf76ef8f5c72aa3460affe46a552d5cfd80332a
This commit is contained in:
Matthew Flatt 1998-07-17 14:14:53 +00:00
parent 9b51d18bd4
commit f72f567c79
2 changed files with 74 additions and 8 deletions

View File

@ -0,0 +1,52 @@
The canvas test frame is primarily for checking the behvaiour of the
scrollbars. Canvas scrollbars work in one of two modes:
1) Managing: the scrollbar determines the size and offset of
the canvas's drawing area.
2) Non-managing: the scrollbars are simply placed next to the
canvas; the canvas's size and offset are not affected by
the scrollbar values.
In the test frame, the top canvas is initially unmanaged, and the
bottom is managed.
An HVCanvas has both horizontal and vertical scrollbars, but the
scrollbars are initially disabled. Clikcing the "Vertical Scroll"
checkbox enables the vertical scroll. A VCanvas has only a vertical
scrollbar; clicking "Horizontal Scroll" in this case has no effect.
When a canvas is managed by its scrollbars and a scrollbar is missing
in a particular direction, it should act the same as an unmanaged
canvas in that direction.
On each canvas, the following are painted at 0,0:
* The name of the canvas
* Three values per scroll bar, for UNMANAGED canvases:
- The current value of the scroll
- The maximum value of the scroll
- The page step of the scroll
These should all be 0 for MANAGED canvases and for
disabled directions
* Two size measurements:
- The client size of the canvas
- The drawing area of the canvas
These should be the same for UNMANAGED canvases/directions
* Two lines showing the boundaries of the canvas if it
is managed and the scrollbars is enabled. When the canvas
is managed with a vertical scrollbar, the bottom boundary
line should not be visible (i.e., it should be clipped).
As the scroll is changed for the bottom canvas, the information will
move, because the scrolls are automatically adjusting the offset of
the canvas. For the top canvas, the information is always visible in
the same place; it is just updated.
The top's scrollbars have a range of 10 and a page step of 3. The
bottom's scrollbars have a range of 20 and a page step of 3 (although
the page step is generally ignored for a managed canvas). In the
bottom frame, one vertical scroll step is mapped to 10 pixels and one
horizontal step to 25 pixels, making the drawing area 200 pixels high
and 500 pixels wide.
The "Small" checkbox changes the bottom's range to 2 instead of
20. This will make the drawing area of the canvas small.
* Enable vertical scroll. Displayed info should change.

View File

@ -1338,6 +1338,8 @@
get-scroll-pos get-scroll-range get-scroll-page
get-client-size get-virtual-size)
(public
[vw 10]
[vh 10]
[on-paint
(lambda ()
(let ([s (format "V: p: ~s r: ~s g: ~s H: ~s ~s ~s"
@ -1359,27 +1361,39 @@
(draw-text (format "client: ~s x ~s virtual: ~s x ~s"
(unbox w) (unbox h)
(unbox w2) (unbox h2))
3 27)))]
3 27)
(draw-line 0 vh vw vh)
(draw-line vw 0 vw vh)))]
[set-vsize (lambda (w h) (set! vw w) (set! vh h))]
[on-scroll
(lambda (e) (on-paint))])
(sequence
(super-init p -1 -1 -1 -1 flags))))
(define c1 (make-object c% "Unmanaged scroll" p))
(define c2 (make-object c% "Automanaged scroll" p))
(define (reset-scrolls)
(define (reset-scrolls for-small?)
(let* ([h? (send ck-h get-value)]
[v? (send ck-v get-value)]
[small? (send ck-s get-value)]
[swap? (send ck-w get-value)])
(send c1 set-scrollbars (if h? 1 -1) (if v? 1 -1) 10 10 3 3 0 0 swap?)
(send c1 set-vsize 10 10)
(send c1 set-scrollbars (if h? 1 -1) (if v? 1 -1) 10 10 3 3 1 1 swap?)
(send c2 set-vsize (if small? 50 500) (if small? 20 200))
(send c2 set-scrollbars (if h? 25 -1) (if v? 10 -1) (if small? 2 20) (if small? 2 20)
3 3 0 0 (not swap?))))
3 3 1 1 (not swap?))
(if for-small?
; Specifically refresh the bottom canvas
(send c2 refresh)
; Otherwise, we have to specifically refresh the unmanaged canvas
(send (if swap? c2 c1) refresh))))
(define p2 (make-object mred:horizontal-panel% p))
(define jumk (send p2 stretchable-in-y #f))
(define ck-v (make-object mred:check-box% p2 (lambda (b e) (reset-scrolls)) "Vertical Scroll"))
(define ck-h (make-object mred:check-box% p2 (lambda (b e) (reset-scrolls)) "Horizontal Scroll"))
(define ck-s (make-object mred:check-box% p2 (lambda (b e) (reset-scrolls)) "Small"))
(define ck-w (make-object mred:check-box% p2 (lambda (b e) (reset-scrolls)) "Swap"))
(define ck-v (make-object mred:check-box% p2 (lambda (b e) (reset-scrolls #f)) "Vertical Scroll"))
(define ck-h (make-object mred:check-box% p2 (lambda (b e) (reset-scrolls #f)) "Horizontal Scroll"))
(define ck-s (make-object mred:check-box% p2 (lambda (b e) (reset-scrolls #t)) "Small"))
(define ck-w (make-object mred:check-box% p2 (lambda (b e) (reset-scrolls #f)) "Swap"))
(send c1 set-vsize 10 10)
(send c2 set-vsize 500 200)
(send f show #t))
;----------------------------------------------------------------------