add pdf-dc%; make slideshow/pict depend on racket/draw, not racket/gui

original commit: 2edadd611303978255f6ff53efa5b691a0f7f0a5
This commit is contained in:
Matthew Flatt 2010-11-26 10:25:37 -07:00
parent 7789fcd827
commit f56c9fbe30
3 changed files with 17 additions and 11 deletions

View File

@ -143,6 +143,7 @@ open-output-text-editor
pane% pane%
panel% panel%
pasteboard% pasteboard%
pdf-dc%
pen% pen%
pen-list% pen-list%
play-sound play-sound

View File

@ -263,7 +263,7 @@
[on-paint [on-paint
(case-lambda (case-lambda
[() (time (on-paint #f))] [() (time (on-paint #f))]
[(ps?) [(kind)
(let* ([can-dc (get-dc)] (let* ([can-dc (get-dc)]
[pen0s (make-object pen% "BLACK" 0 'solid)] [pen0s (make-object pen% "BLACK" 0 'solid)]
[pen1s (make-object pen% "BLACK" 1 'solid)] [pen1s (make-object pen% "BLACK" 1 'solid)]
@ -811,7 +811,7 @@
(send dc draw-rectangle 180 205 20 20) (send dc draw-rectangle 180 205 20 20)
(send dc set-brush brushs)))) (send dc set-brush brushs))))
(when (and pixel-copy? last? (not (or ps? (eq? dc can-dc)))) (when (and pixel-copy? last? (not (or kind (eq? dc can-dc))))
(let* ([x 100] (let* ([x 100]
[y 170] [y 170]
[x2 245] [y2 188] [x2 245] [y2 188]
@ -941,7 +941,7 @@
(send dc draw-rectangle 187 310 20 20) (send dc draw-rectangle 187 310 20 20)
(send dc set-pen p))) (send dc set-pen p)))
(when (and last? (not (or ps? (eq? dc can-dc))) (when (and last? (not (or kind (eq? dc can-dc)))
(send mem-dc get-bitmap)) (send mem-dc get-bitmap))
(send can-dc draw-bitmap (send mem-dc get-bitmap) 0 0 'opaque))) (send can-dc draw-bitmap (send mem-dc get-bitmap) 0 0 'opaque)))
@ -950,10 +950,11 @@
(send (get-dc) set-scale 1 1) (send (get-dc) set-scale 1 1)
(send (get-dc) set-origin 0 0) (send (get-dc) set-origin 0 0)
(let ([dc (if ps? (let ([dc (if kind
(let ([dc (if (eq? ps? 'print) (let ([dc (case kind
(make-object printer-dc%) [(print) (make-object printer-dc%)]
(make-object post-script-dc%))]) [(ps) (make-object post-script-dc%)]
[(pdf) (make-object pdf-dc%)])])
(and (send dc ok?) dc)) (and (send dc ok?) dc))
(if (and use-bitmap?) (if (and use-bitmap?)
(begin (begin
@ -1112,7 +1113,7 @@
(let-values ([(w h) (send dc get-size)]) (let-values ([(w h) (send dc get-size)])
(unless (cond (unless (cond
[ps? #t] [kind #t]
[use-bad? #t] [use-bad? #t]
[use-bitmap? (and (= w (* xscale DRAW-WIDTH)) (= h (* yscale DRAW-HEIGHT)))] [use-bitmap? (and (= w (* xscale DRAW-WIDTH)) (= h (* yscale DRAW-HEIGHT)))]
[else (and (= w (* 2 DRAW-WIDTH)) (= h (* 2 DRAW-HEIGHT)))]) [else (and (= w (* 2 DRAW-WIDTH)) (= h (* 2 DRAW-HEIGHT)))])
@ -1143,10 +1144,10 @@
'(horizontal)) '(horizontal))
(make-object button% "PS" hp (make-object button% "PS" hp
(lambda (self event) (lambda (self event)
(send canvas on-paint #t))) (send canvas on-paint 'ps)))
(make-object button% "Print" hp (make-object button% "PDF" hp
(lambda (self event) (lambda (self event)
(send canvas on-paint 'print))) (send canvas on-paint 'pdf)))
(make-object choice% #f '("1" "*2" "/2" "1,*2" "*2,1") hp (make-object choice% #f '("1" "*2" "/2" "1,*2" "*2,1") hp
(lambda (self event) (lambda (self event)
(send canvas set-scale (send canvas set-scale
@ -1243,6 +1244,7 @@
(send canvas refresh))))]) (send canvas refresh))))])
(set! do-clock clock) (set! do-clock clock)
(make-object button% "Clip Clock" hp3 (lambda (b e) (clock #t))) (make-object button% "Clip Clock" hp3 (lambda (b e) (clock #t)))
(make-object button% "Print" hp4 (lambda (self event) (send canvas on-paint 'print)))
(make-object button% "Print Setup" hp4 (lambda (b e) (let ([c (get-page-setup-from-user)]) (make-object button% "Print Setup" hp4 (lambda (b e) (let ([c (get-page-setup-from-user)])
(when c (when c
(send (current-ps-setup) copy-from c))))) (send (current-ps-setup) copy-from c)))))

View File

@ -112,6 +112,9 @@ that it is installed as a clipping region.
The old 'xor mode for pens and brushes is no longer available (since The old 'xor mode for pens and brushes is no longer available (since
it is not supported by Cairo). it is not supported by Cairo).
The new `pdf-dc%' drawing context is like `post-script-dc%', but it
generates PDF output.
Editor Changes Editor Changes
-------------- --------------