add `get-device-scale' to dc<%>

This commit is contained in:
Matthew Flatt 2011-03-15 07:36:52 -06:00
parent 3207efddb0
commit e8cb27c08c
6 changed files with 32 additions and 1 deletions

View File

@ -151,6 +151,9 @@
(define/override (get-size)
(values (/ page-width page-scaling) (/ page-height page-scaling)))
(define/override (get-device-scale)
(values page-scaling page-scaling))
(define current-page 0)
(define/public (get-page-count) (length pages))

View File

@ -222,6 +222,9 @@
(define/override (get-size)
(values (/ page-width page-scaling) (/ page-height page-scaling)))
(define/override (get-device-scale)
(values page-scaling page-scaling))
(define/override (end-doc)
(send (new printout%
[op-gtk (gtk_print_operation_new)]

View File

@ -32,6 +32,7 @@
get-char-height
get-char-width
get-clipping-region
get-device-scale
get-font
get-gl-context
get-initial-matrix

View File

@ -129,8 +129,9 @@
;; the color is for a background.
install-color
;; The public get-size method:
;; The public get-size & get-device-scale methods:
get-size
get-device-scale
;; set-auto-scroll : real real -> void
;;
@ -197,6 +198,7 @@
(define/public (collapse-bitmap-b&w?) #f)
(define/public (get-size) (values 0.0 0.0))
(define/public (get-device-scale) (values 1.0 1.0))
(define/public (set-auto-scroll dx dy) (void))
@ -612,6 +614,10 @@
(check-ok 'get-size)
(super get-size))
(define/override (get-device-scale)
(check-ok 'get-device-scale)
(super get-device-scale))
(def/public (suspend-flush) (void))
(def/public (resume-flush) (void))
(def/public (flush) (void))

View File

@ -142,6 +142,9 @@
(values h w)
(values w h))))
(define/override (get-device-scale)
(values scale-x scale-y))
(define/override (end-cr)
(cairo_surface_finish s)
(cairo_destroy c)

View File

@ -540,6 +540,21 @@ Gets the current clipping region, returning @scheme[#f] if the drawing
}
@defmethod[(get-device-scale)
(values (and/c real? (not/c negative?))
(and/c real? (not/c negative?)))]{
Gets an ``external'' scaling factor for drawing coordinates to the
target device. For most DCs, the result is @racket[1.0] and
@racket[1.0].
A @racket[post-script-dc%] or @racket[pdf-dc%] object returns scaling
factors determined via @xmethod[ps-setup% get-scaling] at the time
that the DC was created. A @racket[printer-dc%] may also have a
user-configured scaling factor.}
@defmethod[(get-font)
(is-a?/c font%)]{