add width' and
height' arguments to post-script-dc% and pdf-dc%
and document the change that the PS bounding box is no longer inferred from drawing operations
This commit is contained in:
parent
a45792ca1c
commit
abcaa1775c
|
@ -23,12 +23,22 @@
|
||||||
[parent #f]
|
[parent #f]
|
||||||
[use-paper-bbox #f]
|
[use-paper-bbox #f]
|
||||||
[as-eps #t]
|
[as-eps #t]
|
||||||
|
[(init-w width) #f]
|
||||||
|
[(init-h height) #f]
|
||||||
[output #f])
|
[output #f])
|
||||||
|
|
||||||
(unless (or (not output)
|
(let ([get-name (lambda ()
|
||||||
(path-string? output)
|
(init-name (if pdf? 'pdf-dc% 'post-script-dc%)))])
|
||||||
(output-port? output))
|
(unless (or (not init-w)
|
||||||
(raise-type-error (init-name (if pdf? 'pdf-dc% 'post-script-dc%)) "path string, output port, or #f" output))
|
(and (real? init-w) (not (negative? init-w))))
|
||||||
|
(raise-type-error (get-name) "nonnegative real or #f" init-w))
|
||||||
|
(unless (or (not init-h)
|
||||||
|
(and (real? init-h) (not (negative? init-h))))
|
||||||
|
(raise-type-error (get-name) "nonnegative real or #f" init-h))
|
||||||
|
(unless (or (not output)
|
||||||
|
(path-string? output)
|
||||||
|
(output-port? output))
|
||||||
|
(raise-type-error (get-name) "path string, output port, or #f" output)))
|
||||||
|
|
||||||
(define-values (s port-box close-port? width height landscape?)
|
(define-values (s port-box close-port? width height landscape?)
|
||||||
(let ([su (if interactive
|
(let ([su (if interactive
|
||||||
|
@ -60,8 +70,12 @@
|
||||||
(not fn))
|
(not fn))
|
||||||
(values #f #f #f #f #f #f)
|
(values #f #f #f #f #f #f)
|
||||||
(let* ([paper (assoc (send pss get-paper-name) paper-sizes)]
|
(let* ([paper (assoc (send pss get-paper-name) paper-sizes)]
|
||||||
[w (cadr paper)]
|
[w (if (or (not init-w) use-paper-bbox)
|
||||||
[h (caddr paper)]
|
(cadr paper)
|
||||||
|
init-w)]
|
||||||
|
[h (if (or (not init-h) use-paper-bbox)
|
||||||
|
(caddr paper)
|
||||||
|
init-h)]
|
||||||
[landscape? (eq? (send pss get-orientation) 'landscape)]
|
[landscape? (eq? (send pss get-orientation) 'landscape)]
|
||||||
[file (if (output-port? fn)
|
[file (if (output-port? fn)
|
||||||
fn
|
fn
|
||||||
|
@ -91,17 +105,21 @@
|
||||||
(values #f #f #f #f #f #f)])))
|
(values #f #f #f #f #f #f)])))
|
||||||
|
|
||||||
(define-values (margin-x margin-y)
|
(define-values (margin-x margin-y)
|
||||||
(let ([xb (box 0)] [yb (box 0.0)])
|
(if as-eps
|
||||||
(send (current-ps-setup) get-margin xb yb)
|
(values 0.0 0.0)
|
||||||
(values (unbox xb) (unbox yb))))
|
(let ([xb (box 0)] [yb (box 0.0)])
|
||||||
|
(send (current-ps-setup) get-margin xb yb)
|
||||||
|
(values (unbox xb) (unbox yb)))))
|
||||||
(define-values (scale-x scale-y)
|
(define-values (scale-x scale-y)
|
||||||
(let ([xb (box 0)] [yb (box 0.0)])
|
(let ([xb (box 0)] [yb (box 0.0)])
|
||||||
(send (current-ps-setup) get-scaling xb yb)
|
(send (current-ps-setup) get-scaling xb yb)
|
||||||
(values (unbox xb) (unbox yb))))
|
(values (unbox xb) (unbox yb))))
|
||||||
(define-values (trans-x trans-y)
|
(define-values (trans-x trans-y)
|
||||||
(let ([xb (box 0)] [yb (box 0.0)])
|
(if as-eps
|
||||||
(send (current-ps-setup) get-translation xb yb)
|
(values 0.0 0.0)
|
||||||
(values (unbox xb) (unbox yb))))
|
(let ([xb (box 0)] [yb (box 0.0)])
|
||||||
|
(send (current-ps-setup) get-translation xb yb)
|
||||||
|
(values (unbox xb) (unbox yb)))))
|
||||||
|
|
||||||
(unless pdf?
|
(unless pdf?
|
||||||
(when (and s as-eps)
|
(when (and s as-eps)
|
||||||
|
|
|
@ -16,6 +16,8 @@ See also @scheme[printer-dc%].
|
||||||
[parent (or/c (is-a?/c frame%) (is-a?/c dialog%) false/c) #f]
|
[parent (or/c (is-a?/c frame%) (is-a?/c dialog%) false/c) #f]
|
||||||
[use-paper-bbox any/c #f]
|
[use-paper-bbox any/c #f]
|
||||||
[as-eps any/c #t]
|
[as-eps any/c #t]
|
||||||
|
[width (or/c (and/c real? (not/c negative?)) #f) #f]
|
||||||
|
[height (or/c (and/c real? (not/c negative?)) #f) #f]
|
||||||
[output (or/c path-string? output-port? #f) #f])]{
|
[output (or/c path-string? output-port? #f) #f])]{
|
||||||
|
|
||||||
If @scheme[interactive] is true, the user is given a dialog for
|
If @scheme[interactive] is true, the user is given a dialog for
|
||||||
|
@ -36,19 +38,21 @@ If @scheme[interactive] is @scheme[#f], then the settings returned by
|
||||||
hit @onscreen{Cancel} in that case so that @method[dc<%> ok?] returns @scheme[#f].
|
hit @onscreen{Cancel} in that case so that @method[dc<%> ok?] returns @scheme[#f].
|
||||||
|
|
||||||
If @scheme[use-paper-bbox] is @scheme[#f], then the PostScript
|
If @scheme[use-paper-bbox] is @scheme[#f], then the PostScript
|
||||||
bounding box for the output is determined by drawing commands issued
|
bounding box for the output is determined by @racket[width] and
|
||||||
to the object; such a bounding box encloses all parts of the drawing
|
@racket[height]. If @scheme[use-paper-bbox] is not @scheme[#f], then
|
||||||
@italic{ignoring} clipping regions (so the bounding box may be
|
the bounding box is determined by the current paper size (as
|
||||||
approximate). If @scheme[use-paper-bbox] is not @scheme[#f], then the
|
specified by @scheme[current-ps-setup]). When @racket[width] or
|
||||||
bounding box is determined by the current paper size (as specified by
|
@racket[height] is @racket[#f], then the corresponding dimension is
|
||||||
@scheme[current-ps-setup]), and the bounding box does not include the
|
determined by the paper size, even if @racket[use-paper-bbox] is
|
||||||
margin (also specified by @scheme[current-ps-setup]).
|
@racket[#f].
|
||||||
|
|
||||||
@index["Encapsulated PostScript (EPS)"]{If} @scheme[as-eps] is
|
@index["Encapsulated PostScript (EPS)"]{If} @scheme[as-eps] is
|
||||||
@scheme[#f], then the generated PostScript does not include an
|
@scheme[#f], then the generated PostScript does not include an
|
||||||
Encapsulated PostScript (EPS) header, and instead includes a generic
|
Encapsulated PostScript (EPS) header, and instead includes a generic
|
||||||
PostScript header. Otherwise, the generated PostScript includes a
|
PostScript header. The margin and translation factors specified by
|
||||||
header that identifiers it as EPS.
|
@racket[current-ps-setup] are used only when @racket[as-eps] is
|
||||||
|
@racket[#f]. If @racket[as-eps] is true, then the generated
|
||||||
|
PostScript includes a header that identifiers it as EPS.
|
||||||
|
|
||||||
When @racket[output] is not @racket[#f], then file-mode output is
|
When @racket[output] is not @racket[#f], then file-mode output is
|
||||||
written to @racket[output]. If @racket[output] is @racket[#f], then
|
written to @racket[output]. If @racket[output] is @racket[#f], then
|
||||||
|
|
|
@ -953,8 +953,20 @@
|
||||||
(let ([dc (if kind
|
(let ([dc (if kind
|
||||||
(let ([dc (case kind
|
(let ([dc (case kind
|
||||||
[(print) (make-object printer-dc%)]
|
[(print) (make-object printer-dc%)]
|
||||||
[(ps) (make-object post-script-dc%)]
|
[(ps pdf)
|
||||||
[(pdf) (make-object pdf-dc%)])])
|
(let ([page?
|
||||||
|
(eq? 'yes (message-box
|
||||||
|
"Bounding Box"
|
||||||
|
"Use paper bounding box?"
|
||||||
|
#f
|
||||||
|
'(yes-no)))])
|
||||||
|
(new (if (eq? kind 'ps)
|
||||||
|
post-script-dc%
|
||||||
|
pdf-dc%)
|
||||||
|
[width (* xscale DRAW-WIDTH)]
|
||||||
|
[height (* yscale DRAW-HEIGHT)]
|
||||||
|
[as-eps (not page?)]
|
||||||
|
[use-paper-bbox page?]))])])
|
||||||
(and (send dc ok?) dc))
|
(and (send dc ok?) dc))
|
||||||
(if (and use-bitmap?)
|
(if (and use-bitmap?)
|
||||||
(begin
|
(begin
|
||||||
|
|
|
@ -459,6 +459,8 @@
|
||||||
(let ([dc (new (if (eq? format 'eps-bytes) post-script-dc% pdf-dc%)
|
(let ([dc (new (if (eq? format 'eps-bytes) post-script-dc% pdf-dc%)
|
||||||
[interactive #f]
|
[interactive #f]
|
||||||
[as-eps #t]
|
[as-eps #t]
|
||||||
|
[width (pict-width p)]
|
||||||
|
[height (pict-height p)]
|
||||||
[output s])])
|
[output s])])
|
||||||
(send dc start-doc "pict")
|
(send dc start-doc "pict")
|
||||||
(send dc start-page)
|
(send dc start-page)
|
||||||
|
|
|
@ -95,6 +95,17 @@ backward-compatibile. Methods like `get-translation',
|
||||||
`set-translation', `scale', etc. help hide the reundancy.
|
`set-translation', `scale', etc. help hide the reundancy.
|
||||||
|
|
||||||
|
|
||||||
|
PostScript and PDF Drawing Contexts
|
||||||
|
-----------------------------------
|
||||||
|
|
||||||
|
The dimensions for PostScript output are no longer inferred from the
|
||||||
|
drawing. Instead, the width and height must be supplied when the
|
||||||
|
`post-script-dc%' is created.
|
||||||
|
|
||||||
|
The new `pdf-dc%' drawing context is like `post-script-dc%', but it
|
||||||
|
generates PDF output.
|
||||||
|
|
||||||
|
|
||||||
Other Drawing-Context Changes
|
Other Drawing-Context Changes
|
||||||
-----------------------------
|
-----------------------------
|
||||||
|
|
||||||
|
@ -112,9 +123,6 @@ 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
|
||||||
--------------
|
--------------
|
||||||
|
|
Loading…
Reference in New Issue
Block a user