Mirrored Matthew's commit to CVS:

Moving the implementation of `save-file' in text% and pasteboard% from C++ to Scheme.

svn: r10
This commit is contained in:
Eli Barzilay 2005-05-29 07:24:50 +00:00
parent ed0515ef8a
commit 761562eeb7
24 changed files with 425 additions and 283 deletions

View File

@ -43,6 +43,10 @@
(unless (or (not str) (string? str)) (unless (or (not str) (string? str))
(raise-type-error (who->name who) "string or #f" str))) (raise-type-error (who->name who) "string or #f" str)))
(define (check-path who str)
(unless (path-string? str)
(raise-type-error (who->name who) "path or string" str)))
(define (check-path/false who str) (define (check-path/false who str)
(unless (or (not str) (path-string? str)) (unless (or (not str) (path-string? str))
(raise-type-error (who->name who) "path, string, or #f" str))) (raise-type-error (who->name who) "path, string, or #f" str)))

View File

@ -36,15 +36,24 @@
get-active-canvas set-active-canvas get-active-canvas set-active-canvas
get-canvas get-canvas
add-canvas remove-canvas add-canvas remove-canvas
auto-wrap get-max-view-size)) auto-wrap get-max-view-size
save-file))
(define-local-member-name (define-local-member-name
-format-filter -format-filter
-format-filter/save
-get-current-format -get-current-format
-get-file-format -get-file-format
-set-file-format -set-file-format
-set-position
-set-format) -set-format)
(define (check-format who format)
(unless (memq format '(guess standard text text-force-cr same copy))
(raise-type-error (who->name who)
"'guess, 'standard, 'text, 'text-force-cr, 'same, or 'copy"
format)))
(define-syntax (augmentize stx) (define-syntax (augmentize stx)
(syntax-case stx () (syntax-case stx ()
[(_ (result id arg ...) ...) [(_ (result id arg ...) ...)
@ -53,7 +62,7 @@
(and (super id arg ...) (and (super id arg ...)
(inner result id arg ...))) (inner result id arg ...)))
...)])) ...)]))
(define (make-editor-buffer% % can-wrap? get-editor%) (define (make-editor-buffer% % can-wrap? get-editor%)
; >>> This class is instantiated directly by the end-user <<< ; >>> This class is instantiated directly by the end-user <<<
(class* % (editor<%> internal-editor<%>) (class* % (editor<%> internal-editor<%>)
@ -62,13 +71,15 @@
[super-begin-edit-sequence begin-edit-sequence] [super-begin-edit-sequence begin-edit-sequence]
[super-end-edit-sequence end-edit-sequence] [super-end-edit-sequence end-edit-sequence]
[super-insert-port insert-port] [super-insert-port insert-port]
[super-save-port save-port]
[super-erase erase] [super-erase erase]
[super-clear-undos clear-undos] [super-clear-undos clear-undos]
[super-get-load-overwrites-styles get-load-overwrites-styles] [super-get-load-overwrites-styles get-load-overwrites-styles]
[super-get-filename get-filename]) [super-get-filename get-filename])
(inherit get-max-width set-max-width get-admin (inherit get-max-width set-max-width get-admin
get-keymap get-style-list get-keymap get-style-list
set-modified set-filename) set-modified set-filename
get-file put-file)
(define canvases null) (define canvases null)
(define active-canvas #f) (define active-canvas #f)
(define auto-set-wrap? #f) (define auto-set-wrap? #f)
@ -92,19 +103,30 @@
(values (unbox wb) (unbox hb))))]) (values (unbox wb) (unbox hb))))])
(public* (public*
[-format-filter (lambda (f) f)] [-format-filter (lambda (f) f)]
[-format-filter/save (lambda (f) f)]
[-set-file-format (lambda (f) (void))] [-set-file-format (lambda (f) (void))]
[-set-position (lambda () (void))]
[-get-file-format (lambda () 'standard)]) [-get-file-format (lambda () 'standard)])
(override* (override*
[insert-file [insert-file
(opt-lambda ([file #f] [format 'guess] [show-errors? #t]) (opt-lambda (file [format 'guess] [show-errors? #t])
(dynamic-wind (let ([who '(method editor<%> insert-file)])
(lambda () (super-begin-edit-sequence)) (check-path who file)
(lambda () (super-insert-port file format #f)) (check-format who format))
(lambda () (super-end-edit-sequence))))] (do-load-file file format #f))]
[load-file [load-file
(opt-lambda ([file #f] [format 'guess] [show-errors? #t]) (opt-lambda ([file #f] [format 'guess] [show-errors? #t])
(do-load-file file format #t))])
(private*
[do-load-file
(lambda (file format load?)
(let ([who '(method editor<%> load-file)])
(unless (equal? file "")
(check-path/false who file))
(check-format who format))
(let* ([temp-filename?-box (box #f)] (let* ([temp-filename?-box (box #f)]
[old-filename (super-get-filename temp-filename?-box)]) [old-filename (super-get-filename temp-filename?-box)])
(let* ([file (cond (let* ([file (cond
@ -114,15 +136,17 @@
(let ([path (if old-filename (let ([path (if old-filename
(path-only old-filename) (path-only old-filename)
#f)]) #f)])
((get-get-file) path)) (get-file path))
old-filename)] old-filename)]
[(path? file) file] [(path? file) file]
[else (string->path file)])]) [else (string->path file)])])
(and (and
file file
(can-load-file? file (-format-filter format)) (or (not load?)
(can-load-file? file (-format-filter format)))
(begin (begin
(on-load-file file (-format-filter format)) (or (not load?)
(on-load-file file (-format-filter format)))
(let ([port (open-input-file file)] (let ([port (open-input-file file)]
[finished? #f]) [finished? #f])
(dynamic-wind (dynamic-wind
@ -133,10 +157,11 @@
(dynamic-wind (dynamic-wind
void void
(lambda () (lambda ()
(super-erase) (when load?
(unless (and (not (unbox temp-filename?-box)) (super-erase)
(equal? file old-filename)) (unless (and (not (unbox temp-filename?-box))
(set-filename file #f)) (equal? file old-filename))
(set-filename file #f)))
(let ([format (if (eq? format 'same) (let ([format (if (eq? format 'same)
(-get-file-format) (-get-file-format)
format)]) format)])
@ -146,20 +171,84 @@
(raise x))]) (raise x))])
(super-insert-port port (super-insert-port port
(-format-filter format) (-format-filter format)
(super-get-load-overwrites-styles)))]) (and load?
(super-get-load-overwrites-styles))))])
(close-input-port port) ; close as soon as possible (close-input-port port) ; close as soon as possible
(-set-file-format new-format)))) ; text% only (when load?
(-set-file-format new-format)
(-set-position))))) ; text% only
(lambda () (lambda ()
(super-end-edit-sequence) (super-end-edit-sequence)
(wx:end-busy-cursor))) (wx:end-busy-cursor)))
(super-clear-undos) (when load?
(set-modified #f) (super-clear-undos)
(set-modified #f))
(set! finished? #t) (set! finished? #t)
#t) #t)
(lambda () (lambda ()
(after-load-file finished?)
;; In case it wasn't closed before: ;; In case it wasn't closed before:
(close-input-port port)))))))))]) (close-input-port port)
(when load?
(after-load-file finished?))))))))))])
(public*
[save-file
(opt-lambda ([file #f] [format 'same] [show-errors? #t])
(let ([who '(method editor<%> save-file)])
(unless (equal? file "")
(check-path/false who file))
(check-format who format))
(let* ([temp-filename?-box (box #f)]
[old-filename (super-get-filename temp-filename?-box)])
(let* ([file (cond
[(or (not (path-string? file))
(equal? file ""))
(if (or (equal? file "") (not old-filename) (unbox temp-filename?-box))
(let ([path (if old-filename
(path-only old-filename)
#f)])
(put-file path (and old-filename
(file-name-from-path old-filename))))
old-filename)]
[(path? file) file]
[else (string->path file)])]
[f-format (-format-filter/save format)]
[actual-format (if (memq f-format '(copy same))
(-get-file-format)
f-format)]
[text? (not (memq actual-format '(text text-force-cr)))])
(and
file
(can-save-file? file f-format)
(begin
(on-save-file file f-format)
(let ([port (open-output-file file (if text? 'text 'binary) 'truncate/replace)]
[finished? #f])
(dynamic-wind
void
(lambda ()
(wx:file-creator-and-type file #"mReD" (if text? #"TEXT" #"WXME"))
(wx:begin-busy-cursor)
(dynamic-wind
void
(lambda ()
(super-save-port port format #t)
(close-output-port port) ; close as soon as possible
(unless (or (eq? format 'copy)
(and (not (unbox temp-filename?-box))
(equal? file old-filename)))
(set-filename file #f))
(unless (eq? format 'copy)
(-set-file-format actual-format))) ; text% only
(lambda ()
(wx:end-busy-cursor)))
(unless (eq? format 'copy)
(set-modified #f))
(set! finished? #t)
#t)
(lambda ()
;; In case it wasn't closed before:
(close-output-port port)
(after-save-file finished?)))))))))])
(public* (public*
[get-canvases (entry-point (lambda () (map wx->mred canvases)))] [get-canvases (entry-point (lambda () (map wx->mred canvases)))]
@ -290,8 +379,9 @@
[-get-file-format (lambda () [-get-file-format (lambda ()
(super-get-file-format))] (super-get-file-format))]
[-set-file-format (lambda (format) [-set-file-format (lambda (format)
(super-set-file-format format) (super-set-file-format format))]
(super-set-position 0 0))]) [-set-position (lambda ()
(super-set-position 0 0))])
(augmentize (#t can-insert? s e) (augmentize (#t can-insert? s e)
((void) on-insert s e) ((void) on-insert s e)
@ -316,7 +406,10 @@
(define pasteboard% (define pasteboard%
(class (es-contract-mixin (make-editor-buffer% wx:pasteboard% #f (lambda () pasteboard%))) () (class (es-contract-mixin (make-editor-buffer% wx:pasteboard% #f (lambda () pasteboard%))) ()
(override* (override*
[-format-filter (lambda (f) 'standard)]) [-format-filter (lambda (f) 'standard)]
[-format-filter/save (lambda (f) (if (eq? f 'copy)
f
'standard))])
(augmentize (#t can-insert? s s2 x y) (augmentize (#t can-insert? s s2 x y)
((void) on-insert s s2 x y) ((void) on-insert s s2 x y)
((void) after-insert s s2 x y) ((void) after-insert s s2 x y)

View File

@ -225,7 +225,7 @@
insert-file insert-file
load-file load-file
insert-port insert-port
save-file save-port
get-flattened-text get-flattened-text
put-file put-file
get-file get-file

View File

@ -49,6 +49,21 @@
(check-instance 'get-ps-setup-from-user wx:ps-setup% 'ps-setup% #t pss-in) (check-instance 'get-ps-setup-from-user wx:ps-setup% 'ps-setup% #t pss-in)
(check-style 'get-ps-setup-from-user #f null style))) (check-style 'get-ps-setup-from-user #f null style)))
(define bad-fields null)
(define number-callback
(lambda (f ev)
(let ([e (send f get-editor)]
[ok? (real? (string->number (send f get-value)))])
(send e change-style
(send (make-object wx:style-delta%)
set-delta-background
(if ok? "white" "yellow"))
0 (send e last-position))
(set! bad-fields (remq f bad-fields))
(unless ok?
(set! bad-fields (cons f bad-fields)))
(send ok enable (null? bad-fields)))))
(define pss (or pss-in (wx:current-ps-setup))) (define pss (or pss-in (wx:current-ps-setup)))
(define f (make-object dialog% "PostScript Setup" parent)) (define f (make-object dialog% "PostScript Setup" parent))
(define papers (define papers
@ -67,11 +82,14 @@
(define sp (make-object vertical-pane% ssp)) (define sp (make-object vertical-pane% ssp))
(define def-scale "0100.000") (define def-scale "0100.000")
(define def-offset "0000.000") (define def-offset "0000.000")
(define xscale (make-object text-field% "Horizontal Scale:" sp void def-scale)) (define def-margin "0016.000")
(define xoffset (make-object text-field% "Horizontal Translation:" sp void def-offset)) (define xscale (make-object text-field% "Horizontal Scale:" sp number-callback def-scale))
(define xoffset (make-object text-field% "Horizontal Translation:" sp number-callback def-offset))
(define xmargin (make-object text-field% "Horizontal Margin:" sp number-callback def-margin))
(define sp2 (make-object vertical-pane% ssp)) (define sp2 (make-object vertical-pane% ssp))
(define yscale (make-object text-field% "Vertical Scale:" sp2 void def-scale)) (define yscale (make-object text-field% "Vertical Scale:" sp2 number-callback def-scale))
(define yoffset (make-object text-field% "Vertical Translation:" sp2 void def-offset)) (define yoffset (make-object text-field% "Vertical Translation:" sp2 number-callback def-offset))
(define ymargin (make-object text-field% "Vertical Margin:" sp2 number-callback def-margin))
(define l2 (make-object check-box% "PostScript Level 2" f void)) (define l2 (make-object check-box% "PostScript Level 2" f void))
@ -84,7 +102,8 @@
(send f show #f) (send f show #f)
(set! ok? ?)) (set! ok? ?))
(define-values (xsb ysb xtb ytb) (values (box 0) (box 0) (box 0) (box 0))) (define-values (xsb ysb xtb ytb xmb ymb)
(values (box 0) (box 0) (box 0) (box 0) (box 0) (box 0)))
(send paper set-selection (or (find-pos papers (send pss get-paper-name) equal?) 0)) (send paper set-selection (or (find-pos papers (send pss get-paper-name) equal?) 0))
(send orientation set-selection (if (eq? (send pss get-orientation) 'landscape) 1 0)) (send orientation set-selection (if (eq? (send pss get-orientation) 'landscape) 1 0))
@ -102,16 +121,21 @@
(send pss get-translation xtb ytb) (send pss get-translation xtb ytb)
(send xoffset set-value (number->string* (unbox xtb))) (send xoffset set-value (number->string* (unbox xtb)))
(send yoffset set-value (number->string* (unbox ytb))) (send yoffset set-value (number->string* (unbox ytb)))
(send pss get-margin xmb ymb)
(send xmargin set-value (number->string* (unbox xmb)))
(send ymargin set-value (number->string* (unbox ymb)))
(send xscale stretchable-width #f) (send xscale stretchable-width #f)
(send yscale stretchable-width #f) (send yscale stretchable-width #f)
(send xoffset stretchable-width #f) (send xoffset stretchable-width #f)
(send yoffset stretchable-width #f) (send yoffset stretchable-width #f)
(send xmargin stretchable-width #f)
(send ymargin stretchable-width #f)
(send l2 set-value (send pss get-level-2)) (send l2 set-value (send pss get-level-2))
(send f set-alignment 'center 'top) (send f set-alignment 'center 'top)
(map no-stretch (list f xscale yscale xoffset yoffset dp)) (map no-stretch (list f xscale yscale xoffset yoffset xmargin ymargin dp))
(send f center) (send f center)
@ -132,6 +156,7 @@
[(2) 'file]))) [(2) 'file])))
(send s set-scaling (gv xscale xsb) (gv yscale ysb)) (send s set-scaling (gv xscale xsb) (gv yscale ysb))
(send s set-translation (gv xoffset xtb) (gv yoffset ytb)) (send s set-translation (gv xoffset xtb) (gv yoffset ytb))
(send s set-margin (gv xmargin xmb) (gv ymargin ymb))
(send s set-level-2 (send l2 get-value)) (send s set-level-2 (send l2 get-value))
(when (eq? (system-type) 'unix) (when (eq? (system-type) 'unix)

View File

@ -279,6 +279,22 @@ runs the slides.
The "Slideshow" executable accepts a number of command-line flags. The "Slideshow" executable accepts a number of command-line flags.
Use the --help flag to obtain a list of other flags. Use the --help flag to obtain a list of other flags.
Printing
========
The -p or --print command-line flag causes slideshow to print slides
instead of showing them on the screen. Under Unix, the result is
always PostScript. For all platforms, -P or --ps generates PostScript.
PS-to-PDF converters vary on how well they handle landscape
mode. Here's a Ghostscript command that converts slides reliably
(replace "src.ps" and "dest.pdf" with your file names, and put the
command all on one line):
gs -q -dAutoRotatePages=/None -dSAFER -dNOPAUSE -dBATCH
-sOutputFile=dest.pdf -sDEVICE=pdfwrite -c .setpdfwrite
-c "<</Orientation 3>> setpagedevice" -f src.ps
Procedure Reference Procedure Reference
=================== ===================

View File

@ -672,49 +672,50 @@
(redraw))) (redraw)))
(define/public (redraw) (define/public (redraw)
(reset-display-inset! (sliderec-inset (talk-list-ref current-page))) (unless printing?
(send commentary lock #f) (reset-display-inset! (sliderec-inset (talk-list-ref current-page)))
(send commentary begin-edit-sequence) (send commentary lock #f)
(send commentary erase) (send commentary begin-edit-sequence)
(let ([s (talk-list-ref current-page)]) (send commentary erase)
(when (just-a-comment? (sliderec-comment s)) (let ([s (talk-list-ref current-page)])
(for-each (lambda (v) (when (just-a-comment? (sliderec-comment s))
(send commentary insert (if (string? v) (for-each (lambda (v)
v (send commentary insert (if (string? v)
(make-object pict-snip% v)))) v
(just-a-comment-content (sliderec-comment s))))) (make-object pict-snip% v))))
(send commentary scroll-to-position 0 #f 'same 'start) (just-a-comment-content (sliderec-comment s)))))
(send commentary end-edit-sequence) (send commentary scroll-to-position 0 #f 'same 'start)
(send commentary lock #t) (send commentary end-edit-sequence)
(set! click-regions null) (send commentary lock #t)
(set! clicking #f) (set! click-regions null)
(stop-transition/no-refresh) (set! clicking #f)
(cond (stop-transition/no-refresh)
[config:use-offscreen?
(let-values ([(cw ch) (get-client-size)])
(when (and offscreen
(let ([bm (send offscreen get-bitmap)])
(not (and (= cw (send bm get-width))
(= ch (send bm get-height))))))
(send offscreen set-bitmap #f)
(set! offscreen #f))
(unless offscreen
(set! offscreen (make-object bitmap-dc%
(make-bitmap cw ch)))))
(send offscreen clear)
(cond (cond
[config:use-offscreen?
(let-values ([(cw ch) (get-client-size)])
(when (and offscreen
(let ([bm (send offscreen get-bitmap)])
(not (and (= cw (send bm get-width))
(= ch (send bm get-height))))))
(send offscreen set-bitmap #f)
(set! offscreen #f))
(unless offscreen
(set! offscreen (make-object bitmap-dc%
(make-bitmap cw ch)))))
(send offscreen clear)
(cond
[(equal? prefetched-page current-page)
(paint-prefetch offscreen)]
[else
(paint-slide offscreen)])
(let ([bm (send offscreen get-bitmap)])
(send (get-dc) draw-bitmap bm 0 0))]
[(equal? prefetched-page current-page) [(equal? prefetched-page current-page)
(paint-prefetch offscreen)] (paint-prefetch (get-dc))]
[else [else
(paint-slide offscreen)]) (let ([dc (get-dc)])
(let ([bm (send offscreen get-bitmap)]) (send dc clear)
(send (get-dc) draw-bitmap bm 0 0))] (paint-slide dc))])))
[(equal? prefetched-page current-page)
(paint-prefetch (get-dc))]
[else
(let ([dc (get-dc)])
(send dc clear)
(paint-slide dc))]))
(super-new [style '(no-autoclear)]))) (super-new [style '(no-autoclear)])))
(define two-c% (define two-c%
@ -773,7 +774,7 @@
[(send e button-up?) [(send e button-up?)
(send (get-top-level-window) next)])) (send (get-top-level-window) next)]))
(define/public (redraw) (on-paint)) (define/public (redraw) (unless printing? (on-paint)))
(super-new))) (super-new)))
(define (paint-letterbox dc cw ch usw ush) (define (paint-letterbox dc cw ch usw ush)

View File

@ -5,6 +5,129 @@
;; Editor Tests ;; ;; Editor Tests ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;; File and port save/load tests
(define (run-save/load-tests editor% insert reset?)
(when reset?
(map (lambda (f)
(when (file-exists? f) (delete-file f)))
'("tmp99" "tmp98" "tmp97" "tmp96" "tmp95")))
(let* ([mode #f]
[editor+% (class editor%
(define/augment (on-load-file path -mode)
(set! mode -mode))
(define/augment (on-save-file path -mode)
(set! mode -mode))
(super-new))]
[e (make-object editor+%)]
[ck-text (lambda (path)
(when (eq? editor% text%)
(st 'text e get-file-format)
(when path
(test "Hello" 'content (with-input-from-file path
(lambda ()
(read-string 100)))))))]
[ck-binary (lambda (path)
(when (eq? editor% text%)
(st 'standard e get-file-format))
(when path
(test #"WXME" 'content (with-input-from-file path
(lambda ()
(read-bytes 4))))))]
[ck-mode (lambda (-mode)
(test (if (eq? editor% pasteboard%)
(if (eq? -mode 'copy)
'copy
'standard)
-mode)
'mode mode))])
(insert e "Hello")
(st #t e is-modified?)
(st #f e get-filename)
(when (eq? editor% text%)
(st 'standard e get-file-format))
(st #t e save-file "tmp99" 'text)
(ck-mode 'text)
(st (string->path "tmp99") e get-filename)
(st #f e is-modified?)
(ck-text "tmp99")
(insert e "Ack")
(st #t e is-modified?)
(st #t e load-file "tmp99" 'guess)
(ck-mode 'guess)
(ck-text #f)
(st #f e is-modified?)
(st "Hello" e get-flattened-text)
(let ([now (file-or-directory-modify-seconds "tmp99")])
(st #t e save-file "tmp99" 'same)
(ck-text "tmp99")
(st (string->path "tmp99") e get-filename)
(let ([later (file-or-directory-modify-seconds "tmp99")])
(test #t 'file-date (now . <= . later))
(st #t e save-file "tmp98" 'standard)
(test #f 'file-date (later . < . (file-or-directory-modify-seconds "tmp99")))
(ck-binary "tmp98")
(st #t e load-file "tmp98" 'guess)
(ck-mode 'guess)
(ck-binary #f)
(st #t e load-file "tmp98" 'text)
(ck-mode 'text)
(ck-text #f)
(when (eq? editor% text%)
(st "WXME" e get-text 0 4))
(st #t e load-file "tmp98" 'same)
(ck-mode 'same)
(ck-text #f)
(when (eq? editor% text%)
(st "WXME" e get-text 0 4))
(st #t e load-file "tmp98" 'guess)
(ck-mode 'guess)
(ck-binary #f)
(st "Hello" e get-flattened-text)))
(let ([target "tmp97"])
;; Check [non-]temporary file names
(set! e (make-object (class editor+%
(define/override (put-file file dir)
(string->path target))
(super-new))))
(insert e "Howdy")
(st #t e is-modified?)
(set! mode #f)
(st #t e save-file #f 'copy)
(ck-mode 'copy)
(set! target "tmp95")
(st #t e is-modified?)
(ck-binary "tmp97")
(stv e set-filename "tmp96")
(st #t e save-file #f)
(st #f e is-modified?)
(st (string->path "tmp96") e get-filename)
(ck-binary "tmp96")
(stv e set-filename "tmp96" #t)
(st #t e save-file #f)
(ck-mode 'same)
(st (string->path "tmp95") e get-filename)
(stv e set-filename "tmp96" #t)
(st #t e save-file "")
(st (string->path "tmp95") e get-filename)
(ck-binary "tmp95")
(st "Howdy" e get-flattened-text)
(when (eq? editor% text%)
(stv e set-position 100))
(st #t e insert-file "tmp98")
(st "HowdyHello" e get-flattened-text)
(st #t e insert-file "tmp99")
(st "HowdyHelloHello" e get-flattened-text)
(st (string->path "tmp95") e get-filename))))
(map (lambda (reset?)
(run-save/load-tests text% (lambda (e t) (send e insert t)) reset?)
(run-save/load-tests pasteboard% (lambda (e t) (send e insert (make-object string-snip% t))) reset?))
'(#t #f))
(report-errs)
done
;;;;;; Undo tests ;;;;;; Undo tests
(define e (make-object text%)) (define e (make-object text%))

View File

@ -286,9 +286,9 @@ Basic Constructors:
extend slightly beyond the box.) extend slightly beyond the box.)
[MrEd only, in utils.ss] [MrEd only, in utils.ss]
> (pt-line dx dy size) -> pict > (pip-line dx dy size) -> pict
> (pt-arrow-line dx dy size) -> pict > (pip-arrow-line dx dy size) -> pict
> (pt-arrows-line dx dy size) -> pict > (pip-arrows-line dx dy size) -> pict
Creates a line [with arrowhead(s)] as a 0-sized picture suitable Creates a line [with arrowhead(s)] as a 0-sized picture suitable
for use with `pin-over'. The 0-sized picture contains the starting for use with `pin-over'. The 0-sized picture contains the starting

View File

@ -20,9 +20,9 @@
arrowhead/offset arrowhead/offset
arrow-line arrow-line
arrows-line arrows-line
pt-line pip-line
pt-arrow-line pip-arrow-line
pt-arrows-line pip-arrows-line
ellipse ellipse
filled-ellipse filled-ellipse
@ -185,7 +185,7 @@
(+ x (/ size 2)) (+ y (/ size 2))) (+ x (/ size 2)) (+ y (/ size 2)))
(send dc set-brush b) (send dc set-brush b)
(send dc set-pen p))) (send dc set-pen p)))
size size 0 0) size size)
(- (- 0 (* 1/2 size (cos angle))) (/ size 2)) (- (- 0 (* 1/2 size (cos angle))) (/ size 2))
(- (+ (* 1/2 size) (- (* 1/2 size (sin angle)))) size))) (- (+ (* 1/2 size) (- (* 1/2 size (sin angle)))) size)))
@ -203,7 +203,7 @@
(define (arrowhead/offset size angle) (define (arrowhead/offset size angle)
(arrowhead/delta 0 size angle)) (arrowhead/delta 0 size angle))
(define (pt-line dx dy size) (define (pip-line dx dy size)
(picture (picture
0 0 0 0
`((connect 0 0 ,dx ,(- dy))))) `((connect 0 0 ,dx ,(- dy)))))
@ -215,7 +215,7 @@
`((connect 0 0 ,dx ,dy) `((connect 0 0 ,dx ,dy)
(place ,(+ dx adx) ,(+ ady dy) ,a))))) (place ,(+ dx adx) ,(+ ady dy) ,a)))))
(define (pt-arrow-line dx dy size) (define (pip-arrow-line dx dy size)
(arrow-line dx (- dy) size)) (arrow-line dx (- dy) size))
(define (arrows-line dx dy size) (define (arrows-line dx dy size)
@ -224,7 +224,7 @@
`((place 0 0 ,(arrow-line dx dy size)) `((place 0 0 ,(arrow-line dx dy size))
(place ,dx ,dy ,(arrow-line (- dx) (- dy) size))))) (place ,dx ,dy ,(arrow-line (- dx) (- dy) size)))))
(define (pt-arrows-line dx dy size) (define (pip-arrows-line dx dy size)
(arrows-line dx (- dy) size)) (arrows-line dx (- dy) size))
(define (filled-rectangle w h) (define (filled-rectangle w h)

View File

@ -1022,6 +1022,8 @@ int mred_in_restricted_context()
#ifdef NEED_HET_PARAM #ifdef NEED_HET_PARAM
/* see wxHiEventTrampoline for info on mred_het_param: */ /* see wxHiEventTrampoline for info on mred_het_param: */
Scheme_Object *v; Scheme_Object *v;
if (!scheme_current_thread)
return 1;
v = scheme_get_param(scheme_current_thread->init_config, mred_het_param); v = scheme_get_param(scheme_current_thread->init_config, mred_het_param);
if (SCHEME_TRUEP(v)) if (SCHEME_TRUEP(v))
return 1; return 1;

View File

@ -281,7 +281,7 @@ class wxMediaBuffer : public wxObject
virtual void PrintToDC(wxDC *dc, int page = -1) = 0; virtual void PrintToDC(wxDC *dc, int page = -1) = 0;
virtual Bool HasPrintPage(wxDC *dc, int page) = 0; virtual Bool HasPrintPage(wxDC *dc, int page) = 0;
virtual Bool SaveFile(char *filename = NULL, int format = wxMEDIA_FF_SAME, Bool showErrors = TRUE) = 0; virtual Bool SavePort(Scheme_Object *port, int format = wxMEDIA_FF_SAME, Bool showErrors = TRUE) = 0;
virtual int InsertPort(Scheme_Object *port, int format = wxMEDIA_FF_GUESS, Bool replaceStyles = TRUE) = 0; virtual int InsertPort(Scheme_Object *port, int format = wxMEDIA_FF_GUESS, Bool replaceStyles = TRUE) = 0;
char *GetFilename(Bool *temp = NULL); char *GetFilename(Bool *temp = NULL);

View File

@ -3256,74 +3256,28 @@ Bool wxMediaEdit::InsertFile(const char *who, Scheme_Object *f, char *WXUNUSED(f
return !fileerr; return !fileerr;
} }
Bool wxMediaEdit::SaveFile(char *file, int format, Bool showErrors) Bool wxMediaEdit::SavePort(Scheme_Object *f, int format, Bool showErrors)
{ {
Bool no_set_filename, fileerr; Bool fileerr;
Scheme_Object *f;
int is_binary;
if (readLocked)
return FALSE;
showErrors = TRUE; showErrors = TRUE;
if (!file || !*file) { if (readLocked) {
if ((file && !*file) || !filename || tempFilename) { if (showErrors)
char *path, *pfile; wxmeError("save-file in text%: editor locked for reading");
return FALSE;
if (filename) {
path = PathOnly(filename);
if (path && *path)
path = copystring(path);
else
path = NULL;
pfile = copystring(FileNameFromPath(filename));
} else
path = pfile = NULL;
file = PutFile(path, pfile);
} else
file = filename;
} }
if (!file)
return FALSE;
if (!CanSaveFile(file, format))
return FALSE;
OnSaveFile(file, format);
no_set_filename = (format == wxMEDIA_FF_COPY);
if ((format == wxMEDIA_FF_SAME) || (format == wxMEDIA_FF_GUESS) if ((format == wxMEDIA_FF_SAME) || (format == wxMEDIA_FF_GUESS)
|| (format == wxMEDIA_FF_COPY)) || (format == wxMEDIA_FF_COPY))
format = fileFormat; format = fileFormat;
is_binary = !((format == wxMEDIA_FF_TEXT)
|| (format == wxMEDIA_FF_TEXT_FORCE_CR));
f = scheme_open_output_file_with_mode(file, "save-file in text%", !is_binary);
if (!f) {
if (showErrors)
wxmeError("save-file in text%: couldn't write the file");
AfterSaveFile(FALSE);
return FALSE;
}
wxBeginBusyCursor();
#ifdef wx_mac
wxMediaSetFileCreatorType(file, is_binary);
#endif
fileerr = FALSE; fileerr = FALSE;
if (format == wxMEDIA_FF_TEXT || format == wxMEDIA_FF_TEXT_FORCE_CR) { if (format == wxMEDIA_FF_TEXT || format == wxMEDIA_FF_TEXT_FORCE_CR) {
wxchar *us; wxchar *us;
us = GetText(-1, -1, TRUE, format == wxMEDIA_FF_TEXT_FORCE_CR); us = GetText(-1, -1, TRUE, format == wxMEDIA_FF_TEXT_FORCE_CR);
scheme_put_char_string("save-file", f, us, 0, wxstrlen(us)); scheme_put_char_string("save-file", f, us, 0, wxstrlen(us));
scheme_close_output_port(f);
} else { } else {
wxMediaStreamOutFileBase *b; wxMediaStreamOutFileBase *b;
wxMediaStreamOut *mf; wxMediaStreamOut *mf;
@ -3339,24 +3293,11 @@ Bool wxMediaEdit::SaveFile(char *file, int format, Bool showErrors)
wxWriteMediaGlobalFooter(mf); wxWriteMediaGlobalFooter(mf);
fileerr = fileerr || !mf->Ok(); fileerr = fileerr || !mf->Ok();
scheme_close_output_port(f);
} }
if (fileerr && showErrors) if (fileerr && showErrors)
wxmeError("save-file in text%: error writing the file"); wxmeError("save-file in text%: error writing the file");
if (!no_set_filename && PTRNE(file, filename))
SetFilename(file, FALSE);
fileFormat = format;
wxEndBusyCursor();
if (!no_set_filename)
SetModified(fileerr);
AfterSaveFile(!fileerr);
return !fileerr; return !fileerr;
} }

View File

@ -348,7 +348,7 @@ class wxMediaEdit : public wxMediaBuffer
wxchar GetCharacter(long start); wxchar GetCharacter(long start);
char GetTruncatedCharacter(long start); char GetTruncatedCharacter(long start);
Bool SaveFile(char *filename = NULL, int format = wxMEDIA_FF_SAME, Bool showErrors = TRUE); Bool SavePort(Scheme_Object *port, int format = wxMEDIA_FF_SAME, Bool showErrors = TRUE);
int InsertPort(Scheme_Object *port, int format = wxMEDIA_FF_GUESS, Bool replaceStyles = TRUE); int InsertPort(Scheme_Object *port, int format = wxMEDIA_FF_GUESS, Bool replaceStyles = TRUE);
Bool ReadFromFile(wxMediaStreamIn *, long start, Bool overwritestyle = FALSE); Bool ReadFromFile(wxMediaStreamIn *, long start, Bool overwritestyle = FALSE);

View File

@ -91,7 +91,7 @@ class wxMediaPasteboard : public wxMediaBuffer
Bool WriteToFile(wxMediaStreamOut *); Bool WriteToFile(wxMediaStreamOut *);
Bool ReadFromFile(wxMediaStreamIn *, Bool overwritestyle = FALSE); Bool ReadFromFile(wxMediaStreamIn *, Bool overwritestyle = FALSE);
Bool SaveFile(char *filename = NULL, int format = wxMEDIA_FF_STD, Bool showErrors = TRUE); Bool SavePort(Scheme_Object *port, int format = wxMEDIA_FF_SAME, Bool showErrors = TRUE);
int InsertPort(Scheme_Object *port, int format = wxMEDIA_FF_GUESS, Bool replaceStyles = TRUE); int InsertPort(Scheme_Object *port, int format = wxMEDIA_FF_GUESS, Bool replaceStyles = TRUE);
void StyleHasChanged(wxStyle *style); void StyleHasChanged(wxStyle *style);

View File

@ -1656,7 +1656,7 @@ void wxMediaPasteboard::Draw(wxDC *dc, double dx, double dy,
void wxMediaPasteboard::Refresh(double localx, double localy, double w, double h, void wxMediaPasteboard::Refresh(double localx, double localy, double w, double h,
int show_caret, wxColour *bgColor) int show_caret, wxColour *bgColor)
{ {
double dx, dy, ddx, ddy; double dx, dy, right, bottom;
wxDC *dc; wxDC *dc;
if (!admin) if (!admin)
@ -1677,21 +1677,20 @@ void wxMediaPasteboard::Refresh(double localx, double localy, double w, double h
dc = admin->GetDC(&dx, &dy); dc = admin->GetDC(&dx, &dy);
/* Make sure all location information is integral,
so we can shift the coordinate system and generally
update on pixel boundaries. */
dx = floor(dx);
dy = floor(dy);
bottom = ceil(localy + h);
right = ceil(localx + w);
localy = floor(localy);
localx = floor(localx);
w = right - localx;
h = bottom - localy;
if (!offscreenInUse && bitmap && bitmap->Ok() && offscreen->Ok() if (!offscreenInUse && bitmap && bitmap->Ok() && offscreen->Ok()
&& bgColor) { && bgColor) {
/* Need to make sure that difference between coordinates is
integral; otherwise, roundoff error could affect drawing */
ddx = (localx - dx) - (long)(localx - dx);
if (ddx < 0)
ddx = 1 + ddx;
localx -= ddx;
w += ddx;
ddy = (localy - dy) - (long)(localy - dy);
if (ddy < 0)
ddy = 1 + ddy;
localy -= ddy;
h += ddy;
#ifndef EACH_BUFFER_OWN_OFFSCREEN #ifndef EACH_BUFFER_OWN_OFFSCREEN
offscreenInUse = TRUE; offscreenInUse = TRUE;
#endif #endif
@ -2610,62 +2609,14 @@ Bool wxMediaPasteboard::InsertFile(const char *who, Scheme_Object *f, const char
return !fileerr; return !fileerr;
} }
Bool wxMediaPasteboard::SaveFile(char *file, int format, Bool showErrors) Bool wxMediaPasteboard::SavePort(Scheme_Object *f, int format, Bool showErrors)
{ {
Scheme_Object *f;
Bool fileerr; Bool fileerr;
Bool no_set_filename;
wxMediaStreamOutFileBase *b; wxMediaStreamOutFileBase *b;
wxMediaStreamOut *mf; wxMediaStreamOut *mf;
showErrors = TRUE; showErrors = TRUE;
if (!file || !*file) {
if ((file && !*file) || !filename || tempFilename) {
char *path, *pfile;
if (filename) {
path = PathOnly(filename);
if (path && *path)
path = copystring(path);
else
path = NULL;
pfile = copystring(FileNameFromPath(filename));
} else
path = pfile = NULL;
file = PutFile(path, pfile);
} else
file = filename;
}
if (!file)
return FALSE;
if (format != wxMEDIA_FF_COPY)
format = wxMEDIA_FF_STD;
no_set_filename = (format == wxMEDIA_FF_COPY);
if (!CanSaveFile(file, wxMEDIA_FF_STD))
return FALSE;
OnSaveFile(file, wxMEDIA_FF_STD);
f = scheme_open_output_file(file, "save-file in pasteboard%");
if (!f) {
if (showErrors)
wxmeError("save-file in pasteboard%: could not write the file");
AfterSaveFile(FALSE);
return FALSE;
}
wxBeginBusyCursor();
#ifdef wx_mac
wxMediaSetFileCreatorType(file, TRUE);
#endif
b = new wxMediaStreamOutFileBase(f); b = new wxMediaStreamOutFileBase(f);
mf = new wxMediaStreamOut(b); mf = new wxMediaStreamOut(b);
@ -2680,21 +2631,9 @@ Bool wxMediaPasteboard::SaveFile(char *file, int format, Bool showErrors)
fileerr = fileerr || !mf->Ok(); fileerr = fileerr || !mf->Ok();
scheme_close_output_port(f);
if (fileerr && showErrors) if (fileerr && showErrors)
wxmeError("save-file in pasteboard%: error writing the file"); wxmeError("save-file in pasteboard%: error writing the file");
if (!no_set_filename)
SetFilename(file, FALSE);
wxEndBusyCursor();
if (!no_set_filename)
SetModified(fileerr);
AfterSaveFile(!fileerr);
return !fileerr; return !fileerr;
} }

View File

@ -2531,7 +2531,7 @@ void wxMediaEdit::Redraw()
void wxMediaEdit::Refresh(double left, double top, double width, double height, void wxMediaEdit::Refresh(double left, double top, double width, double height,
int show_caret, wxColour *bgColor) int show_caret, wxColour *bgColor)
{ {
double x, y, bottom, right, ddx, ddy; double x, y, bottom, right;
Bool ps; Bool ps;
wxDC *dc; wxDC *dc;
int show_xsel = 0; int show_xsel = 0;
@ -2565,8 +2565,17 @@ void wxMediaEdit::Refresh(double left, double top, double width, double height,
if (ReadyOffscreen(width, height)) if (ReadyOffscreen(width, height))
drawCachedInBitmap = FALSE; drawCachedInBitmap = FALSE;
bottom = top + height; /* Make sure all location information is integral,
right = left + width; so we can shift the coordinate system and generally
update on pixel boundaries. */
x = floor(x);
y = floor(y);
bottom = ceil(top + height);
right = ceil(left + width);
top = floor(top);
left = floor(left);
width = right - left;
height = bottom - top;
ps = (wxSubType(dc->__type, wxTYPE_DC_POSTSCRIPT) ps = (wxSubType(dc->__type, wxTYPE_DC_POSTSCRIPT)
|| wxSubType(dc->__type, wxTYPE_DC_PRINTER)); || wxSubType(dc->__type, wxTYPE_DC_PRINTER));
@ -2580,24 +2589,12 @@ void wxMediaEdit::Refresh(double left, double top, double width, double height,
#endif #endif
if (bgColor && !offscreenInUse && bitmap && bitmap->Ok() && offscreen->Ok() && !ps) { if (bgColor && !offscreenInUse && bitmap && bitmap->Ok() && offscreen->Ok() && !ps) {
/* Need to make sure that difference between coordinates is
integral; otherwise, roundoff error could affect drawing */
unsigned char red, green, blue; unsigned char red, green, blue;
red = (unsigned char)bgColor->Red(); red = (unsigned char)bgColor->Red();
green = (unsigned char)bgColor->Green(); green = (unsigned char)bgColor->Green();
blue = (unsigned char)bgColor->Blue(); blue = (unsigned char)bgColor->Blue();
ddx = (left - x) - (long)(left - x);
if (ddx < 0)
ddx = 1 + ddx;
left -= ddx;
width += ddx;
ddy = (top - y) - (long)(top - y);
if (ddy < 0)
ddy = 1 + ddy;
top -= ddy;
height += ddy;
#ifndef EACH_BUFFER_OWN_OFFSCREEN #ifndef EACH_BUFFER_OWN_OFFSCREEN
offscreenInUse = TRUE; offscreenInUse = TRUE;
#endif #endif

View File

@ -85,8 +85,8 @@
@ Z "on-edit-sequence" : void OnEditSequence(); @ Z "on-edit-sequence" : void OnEditSequence();
@ Z "after-edit-sequence" : void AfterEditSequence(); @ Z "after-edit-sequence" : void AfterEditSequence();
@ Z "get-file" : npathname GetFile(epathname); @ Z "get-file" : npathname GetFile(nepathname);
@ Z "put-file" : npathname PutFile(epathname, epathname); @ Z "put-file" : npathname PutFile(nepathname, nepathname);
@MACRO makeNoCopyFlatString[len] = WITH_VAR_STACK(scheme_make_sized_char_string(r, <len>, 0)) @MACRO makeNoCopyFlatString[len] = WITH_VAR_STACK(scheme_make_sized_char_string(r, <len>, 0))

View File

@ -996,8 +996,8 @@ class os_wxMediaEdit : public wxMediaEdit {
void DoPaste(nnlong x0, ExactLong x1); void DoPaste(nnlong x0, ExactLong x1);
void DoCopy(nnlong x0, nnlong x1, ExactLong x2, Bool x3); void DoCopy(nnlong x0, nnlong x1, ExactLong x2, Bool x3);
void SetAnchor(Bool x0); void SetAnchor(Bool x0);
npathname PutFile(epathname x0, epathname x1); npathname PutFile(nepathname x0, nepathname x1);
npathname GetFile(epathname x0); npathname GetFile(nepathname x0);
void AfterEditSequence(); void AfterEditSequence();
void OnEditSequence(); void OnEditSequence();
void AfterLoadFile(Bool x0); void AfterLoadFile(Bool x0);
@ -1926,7 +1926,7 @@ void os_wxMediaEdit::SetAnchor(Bool x0)
static Scheme_Object *os_wxMediaEditPutFile(int n, Scheme_Object *p[]); static Scheme_Object *os_wxMediaEditPutFile(int n, Scheme_Object *p[]);
npathname os_wxMediaEdit::PutFile(epathname x0, epathname x1) npathname os_wxMediaEdit::PutFile(nepathname x0, nepathname x1)
{ {
Scheme_Object *p[POFFSET+2] INIT_NULLED_ARRAY({ NULLED_OUT INA_comma NULLED_OUT INA_comma NULLED_OUT }); Scheme_Object *p[POFFSET+2] INIT_NULLED_ARRAY({ NULLED_OUT INA_comma NULLED_OUT INA_comma NULLED_OUT });
Scheme_Object *v; Scheme_Object *v;
@ -1969,7 +1969,7 @@ npathname os_wxMediaEdit::PutFile(epathname x0, epathname x1)
static Scheme_Object *os_wxMediaEditGetFile(int n, Scheme_Object *p[]); static Scheme_Object *os_wxMediaEditGetFile(int n, Scheme_Object *p[]);
npathname os_wxMediaEdit::GetFile(epathname x0) npathname os_wxMediaEdit::GetFile(nepathname x0)
{ {
Scheme_Object *p[POFFSET+1] INIT_NULLED_ARRAY({ NULLED_OUT INA_comma NULLED_OUT }); Scheme_Object *p[POFFSET+1] INIT_NULLED_ARRAY({ NULLED_OUT INA_comma NULLED_OUT });
Scheme_Object *v; Scheme_Object *v;
@ -7115,8 +7115,8 @@ static Scheme_Object *os_wxMediaEditPutFile(int n, Scheme_Object *p[])
REMEMBER_VAR_STACK(); REMEMBER_VAR_STACK();
npathname r; npathname r;
objscheme_check_valid(os_wxMediaEdit_class, "put-file in text%", n, p); objscheme_check_valid(os_wxMediaEdit_class, "put-file in text%", n, p);
epathname x0 INIT_NULLED_OUT; nepathname x0 INIT_NULLED_OUT;
epathname x1 INIT_NULLED_OUT; nepathname x1 INIT_NULLED_OUT;
SETUP_VAR_STACK_REMEMBERED(3); SETUP_VAR_STACK_REMEMBERED(3);
VAR_STACK_PUSH(0, p); VAR_STACK_PUSH(0, p);
@ -7124,8 +7124,8 @@ static Scheme_Object *os_wxMediaEditPutFile(int n, Scheme_Object *p[])
VAR_STACK_PUSH(2, x1); VAR_STACK_PUSH(2, x1);
x0 = (epathname)WITH_VAR_STACK(objscheme_unbundle_epathname(p[POFFSET+0], "put-file in text%")); x0 = (nepathname)WITH_VAR_STACK(objscheme_unbundle_nullable_epathname(p[POFFSET+0], "put-file in text%"));
x1 = (epathname)WITH_VAR_STACK(objscheme_unbundle_epathname(p[POFFSET+1], "put-file in text%")); x1 = (nepathname)WITH_VAR_STACK(objscheme_unbundle_nullable_epathname(p[POFFSET+1], "put-file in text%"));
if (((Scheme_Class_Object *)p[0])->primflag) if (((Scheme_Class_Object *)p[0])->primflag)
@ -7145,14 +7145,14 @@ static Scheme_Object *os_wxMediaEditGetFile(int n, Scheme_Object *p[])
REMEMBER_VAR_STACK(); REMEMBER_VAR_STACK();
npathname r; npathname r;
objscheme_check_valid(os_wxMediaEdit_class, "get-file in text%", n, p); objscheme_check_valid(os_wxMediaEdit_class, "get-file in text%", n, p);
epathname x0 INIT_NULLED_OUT; nepathname x0 INIT_NULLED_OUT;
SETUP_VAR_STACK_REMEMBERED(2); SETUP_VAR_STACK_REMEMBERED(2);
VAR_STACK_PUSH(0, p); VAR_STACK_PUSH(0, p);
VAR_STACK_PUSH(1, x0); VAR_STACK_PUSH(1, x0);
x0 = (epathname)WITH_VAR_STACK(objscheme_unbundle_epathname(p[POFFSET+0], "get-file in text%")); x0 = (nepathname)WITH_VAR_STACK(objscheme_unbundle_nullable_epathname(p[POFFSET+0], "get-file in text%"));
if (((Scheme_Class_Object *)p[0])->primflag) if (((Scheme_Class_Object *)p[0])->primflag)

View File

@ -2142,7 +2142,7 @@ static Scheme_Object *os_wxMediaBufferInsertPort(int n, Scheme_Object *p[])
VAR_STACK_PUSH(1, x0); VAR_STACK_PUSH(1, x0);
x0 = (SCHEME_INPORTP(p[POFFSET+0]) ? p[POFFSET+0] : (scheme_wrong_type(METHODNAME("editor<%>","insert-file"), "input port", -1, 1, &p[POFFSET+0]), (Scheme_Object *)NULL)); x0 = (SCHEME_INPORTP(p[POFFSET+0]) ? p[POFFSET+0] : (scheme_wrong_type(METHODNAME("editor<%>","insert-port"), "input port", -1, 1, &p[POFFSET+0]), (Scheme_Object *)NULL));
if (n > (POFFSET+1)) { if (n > (POFFSET+1)) {
x1 = WITH_VAR_STACK(unbundle_symset_fileType(p[POFFSET+1], "insert-port in editor<%>")); x1 = WITH_VAR_STACK(unbundle_symset_fileType(p[POFFSET+1], "insert-port in editor<%>"));
} else } else
@ -2161,13 +2161,13 @@ static Scheme_Object *os_wxMediaBufferInsertPort(int n, Scheme_Object *p[])
return WITH_REMEMBERED_STACK(bundle_symset_fileType(r)); return WITH_REMEMBERED_STACK(bundle_symset_fileType(r));
} }
static Scheme_Object *os_wxMediaBufferSaveFile(int n, Scheme_Object *p[]) static Scheme_Object *os_wxMediaBufferSavePort(int n, Scheme_Object *p[])
{ {
WXS_USE_ARGUMENT(n) WXS_USE_ARGUMENT(p) WXS_USE_ARGUMENT(n) WXS_USE_ARGUMENT(p)
REMEMBER_VAR_STACK(); REMEMBER_VAR_STACK();
Bool r; Bool r;
objscheme_check_valid(os_wxMediaBuffer_class, "save-file in editor<%>", n, p); objscheme_check_valid(os_wxMediaBuffer_class, "save-port in editor<%>", n, p);
nxpathname x0 INIT_NULLED_OUT; Scheme_Object* x0 INIT_NULLED_OUT;
int x1; int x1;
Bool x2; Bool x2;
@ -2176,21 +2176,18 @@ static Scheme_Object *os_wxMediaBufferSaveFile(int n, Scheme_Object *p[])
VAR_STACK_PUSH(1, x0); VAR_STACK_PUSH(1, x0);
if (n > (POFFSET+0)) { x0 = (SCHEME_OUTPORTP(p[POFFSET+0]) ? p[POFFSET+0] : (scheme_wrong_type(METHODNAME("editor<%>","save-port"), "output port", -1, 1, &p[POFFSET+0]), (Scheme_Object *)NULL));
x0 = (nxpathname)WITH_VAR_STACK(objscheme_unbundle_nullable_xpathname(p[POFFSET+0], "save-file in editor<%>"));
} else
x0 = NULL;
if (n > (POFFSET+1)) { if (n > (POFFSET+1)) {
x1 = WITH_VAR_STACK(unbundle_symset_fileType(p[POFFSET+1], "save-file in editor<%>")); x1 = WITH_VAR_STACK(unbundle_symset_fileType(p[POFFSET+1], "save-port in editor<%>"));
} else } else
x1 = wxMEDIA_FF_SAME; x1 = wxMEDIA_FF_SAME;
if (n > (POFFSET+2)) { if (n > (POFFSET+2)) {
x2 = WITH_VAR_STACK(objscheme_unbundle_bool(p[POFFSET+2], "save-file in editor<%>")); x2 = WITH_VAR_STACK(objscheme_unbundle_bool(p[POFFSET+2], "save-port in editor<%>"));
} else } else
x2 = TRUE; x2 = TRUE;
r = WITH_VAR_STACK(((wxMediaBuffer *)((Scheme_Class_Object *)p[0])->primdata)->SaveFile(x0, x1, x2)); r = WITH_VAR_STACK(((wxMediaBuffer *)((Scheme_Class_Object *)p[0])->primdata)->SavePort(x0, x1, x2));
@ -2272,7 +2269,7 @@ void objscheme_setup_wxMediaBuffer(Scheme_Env *env)
WITH_VAR_STACK(scheme_add_method_w_arity(os_wxMediaBuffer_class, "insert-file" " method", (Scheme_Method_Prim *)os_wxMediaBufferNoInsertFile, 0, 0)); WITH_VAR_STACK(scheme_add_method_w_arity(os_wxMediaBuffer_class, "insert-file" " method", (Scheme_Method_Prim *)os_wxMediaBufferNoInsertFile, 0, 0));
WITH_VAR_STACK(scheme_add_method_w_arity(os_wxMediaBuffer_class, "load-file" " method", (Scheme_Method_Prim *)os_wxMediaBufferNoLoadFile, 0, 0)); WITH_VAR_STACK(scheme_add_method_w_arity(os_wxMediaBuffer_class, "load-file" " method", (Scheme_Method_Prim *)os_wxMediaBufferNoLoadFile, 0, 0));
WITH_VAR_STACK(scheme_add_method_w_arity(os_wxMediaBuffer_class, "insert-port" " method", (Scheme_Method_Prim *)os_wxMediaBufferInsertPort, 1, 3)); WITH_VAR_STACK(scheme_add_method_w_arity(os_wxMediaBuffer_class, "insert-port" " method", (Scheme_Method_Prim *)os_wxMediaBufferInsertPort, 1, 3));
WITH_VAR_STACK(scheme_add_method_w_arity(os_wxMediaBuffer_class, "save-file" " method", (Scheme_Method_Prim *)os_wxMediaBufferSaveFile, 0, 3)); WITH_VAR_STACK(scheme_add_method_w_arity(os_wxMediaBuffer_class, "save-port" " method", (Scheme_Method_Prim *)os_wxMediaBufferSavePort, 1, 3));
WITH_VAR_STACK(scheme_made_class(os_wxMediaBuffer_class)); WITH_VAR_STACK(scheme_made_class(os_wxMediaBuffer_class));

View File

@ -49,8 +49,10 @@ static void *wxbDCToBuffer(wxMediaBuffer *b, double x, double y)
@MACRO rFALSE = return FALSE; @MACRO rFALSE = return FALSE;
@MACRO rZERO = return 0; @MACRO rZERO = return 0;
@MACRO ubPort = (SCHEME_INPORTP({x}) ? {x} : (scheme_wrong_type(METHODNAME("editor<%>","insert-file"), "input port", -1, 1, &{x}), (Scheme_Object *)NULL)) @MACRO ubiPort[who] = (SCHEME_INPORTP({x}) ? {x} : (scheme_wrong_type(METHODNAME("editor<%>",<who>), "input port", -1, 1, &{x}), (Scheme_Object *)NULL))
@MACRO cPort = SCHEME_INPORTP({x}) @MACRO ciPort = SCHEME_INPORTP({x})
@MACRO uboPort[who] = (SCHEME_OUTPORTP({x}) ? {x} : (scheme_wrong_type(METHODNAME("editor<%>",<who>), "output port", -1, 1, &{x}), (Scheme_Object *)NULL))
@MACRO coPort = SCHEME_OUTPORTP({x})
@INCLUDE wxs_eds.xci @INCLUDE wxs_eds.xci
@ -85,8 +87,8 @@ static void NoInsertFile(wxMediaBuffer *)
// but acutally are implemented with virtual // but acutally are implemented with virtual
@SETMARK W = D @SETMARK W = D
@ W "save-file" : bool SaveFile(nxpathname=NULL,SYM[fileType]=wxMEDIA_FF_SAME,bool=TRUE); @ W "save-port" : bool SavePort(Scheme_Object[]//uboPort["save-port"]/coPort///push,SYM[fileType]=wxMEDIA_FF_SAME,bool=TRUE);
@ W "insert-port" : SYM[fileType] InsertPort(Scheme_Object[]//ubPort/cPort///push,SYM[fileType]=wxMEDIA_FF_GUESS,bool=TRUE); <> port @ W "insert-port" : SYM[fileType] InsertPort(Scheme_Object[]//ubiPort["insert-port"]/ciPort///push,SYM[fileType]=wxMEDIA_FF_GUESS,bool=TRUE); <> port
// No longer actually in C, but we want them in the editor<%> interface: // No longer actually in C, but we want them in the editor<%> interface:
@ m "load-file" : void NoLoadFile() @ m "load-file" : void NoLoadFile()

View File

@ -419,8 +419,8 @@ class os_wxMediaPasteboard : public wxMediaPasteboard {
void DoPasteSelection(ExactLong x0); void DoPasteSelection(ExactLong x0);
void DoPaste(ExactLong x0); void DoPaste(ExactLong x0);
void DoCopy(ExactLong x0, Bool x1); void DoCopy(ExactLong x0, Bool x1);
npathname PutFile(epathname x0, epathname x1); npathname PutFile(nepathname x0, nepathname x1);
npathname GetFile(epathname x0); npathname GetFile(nepathname x0);
void AfterEditSequence(); void AfterEditSequence();
void OnEditSequence(); void OnEditSequence();
void AfterLoadFile(Bool x0); void AfterLoadFile(Bool x0);
@ -1710,7 +1710,7 @@ void os_wxMediaPasteboard::DoCopy(ExactLong x0, Bool x1)
static Scheme_Object *os_wxMediaPasteboardPutFile(int n, Scheme_Object *p[]); static Scheme_Object *os_wxMediaPasteboardPutFile(int n, Scheme_Object *p[]);
npathname os_wxMediaPasteboard::PutFile(epathname x0, epathname x1) npathname os_wxMediaPasteboard::PutFile(nepathname x0, nepathname x1)
{ {
Scheme_Object *p[POFFSET+2] INIT_NULLED_ARRAY({ NULLED_OUT INA_comma NULLED_OUT INA_comma NULLED_OUT }); Scheme_Object *p[POFFSET+2] INIT_NULLED_ARRAY({ NULLED_OUT INA_comma NULLED_OUT INA_comma NULLED_OUT });
Scheme_Object *v; Scheme_Object *v;
@ -1753,7 +1753,7 @@ npathname os_wxMediaPasteboard::PutFile(epathname x0, epathname x1)
static Scheme_Object *os_wxMediaPasteboardGetFile(int n, Scheme_Object *p[]); static Scheme_Object *os_wxMediaPasteboardGetFile(int n, Scheme_Object *p[]);
npathname os_wxMediaPasteboard::GetFile(epathname x0) npathname os_wxMediaPasteboard::GetFile(nepathname x0)
{ {
Scheme_Object *p[POFFSET+1] INIT_NULLED_ARRAY({ NULLED_OUT INA_comma NULLED_OUT }); Scheme_Object *p[POFFSET+1] INIT_NULLED_ARRAY({ NULLED_OUT INA_comma NULLED_OUT });
Scheme_Object *v; Scheme_Object *v;
@ -5284,8 +5284,8 @@ static Scheme_Object *os_wxMediaPasteboardPutFile(int n, Scheme_Object *p[])
REMEMBER_VAR_STACK(); REMEMBER_VAR_STACK();
npathname r; npathname r;
objscheme_check_valid(os_wxMediaPasteboard_class, "put-file in pasteboard%", n, p); objscheme_check_valid(os_wxMediaPasteboard_class, "put-file in pasteboard%", n, p);
epathname x0 INIT_NULLED_OUT; nepathname x0 INIT_NULLED_OUT;
epathname x1 INIT_NULLED_OUT; nepathname x1 INIT_NULLED_OUT;
SETUP_VAR_STACK_REMEMBERED(3); SETUP_VAR_STACK_REMEMBERED(3);
VAR_STACK_PUSH(0, p); VAR_STACK_PUSH(0, p);
@ -5293,8 +5293,8 @@ static Scheme_Object *os_wxMediaPasteboardPutFile(int n, Scheme_Object *p[])
VAR_STACK_PUSH(2, x1); VAR_STACK_PUSH(2, x1);
x0 = (epathname)WITH_VAR_STACK(objscheme_unbundle_epathname(p[POFFSET+0], "put-file in pasteboard%")); x0 = (nepathname)WITH_VAR_STACK(objscheme_unbundle_nullable_epathname(p[POFFSET+0], "put-file in pasteboard%"));
x1 = (epathname)WITH_VAR_STACK(objscheme_unbundle_epathname(p[POFFSET+1], "put-file in pasteboard%")); x1 = (nepathname)WITH_VAR_STACK(objscheme_unbundle_nullable_epathname(p[POFFSET+1], "put-file in pasteboard%"));
if (((Scheme_Class_Object *)p[0])->primflag) if (((Scheme_Class_Object *)p[0])->primflag)
@ -5314,14 +5314,14 @@ static Scheme_Object *os_wxMediaPasteboardGetFile(int n, Scheme_Object *p[])
REMEMBER_VAR_STACK(); REMEMBER_VAR_STACK();
npathname r; npathname r;
objscheme_check_valid(os_wxMediaPasteboard_class, "get-file in pasteboard%", n, p); objscheme_check_valid(os_wxMediaPasteboard_class, "get-file in pasteboard%", n, p);
epathname x0 INIT_NULLED_OUT; nepathname x0 INIT_NULLED_OUT;
SETUP_VAR_STACK_REMEMBERED(2); SETUP_VAR_STACK_REMEMBERED(2);
VAR_STACK_PUSH(0, p); VAR_STACK_PUSH(0, p);
VAR_STACK_PUSH(1, x0); VAR_STACK_PUSH(1, x0);
x0 = (epathname)WITH_VAR_STACK(objscheme_unbundle_epathname(p[POFFSET+0], "get-file in pasteboard%")); x0 = (nepathname)WITH_VAR_STACK(objscheme_unbundle_nullable_epathname(p[POFFSET+0], "get-file in pasteboard%"));
if (((Scheme_Class_Object *)p[0])->primflag) if (((Scheme_Class_Object *)p[0])->primflag)

View File

@ -2233,6 +2233,7 @@ void wxPrintSetupData::SetAFMPath(char *f)
void wxPrintSetupData::copy(wxPrintSetupData* data) void wxPrintSetupData::copy(wxPrintSetupData* data)
{ {
double x, y; double x, y;
long lx, ly;
char *s; char *s;
int i; int i;
@ -2257,6 +2258,10 @@ void wxPrintSetupData::copy(wxPrintSetupData* data)
SetPrinterTranslation(x, y); SetPrinterTranslation(x, y);
data->GetPrinterScaling(&x, &y); data->GetPrinterScaling(&x, &y);
SetPrinterScaling(x, y); SetPrinterScaling(x, y);
data->GetMargin(&x, &y);
SetMargin(x, y);
data->GetEditorMargin(&lx, &ly);
SetEditorMargin(lx, ly);
#ifdef wx_mac #ifdef wx_mac
if (data->native) { if (data->native) {

View File

@ -1480,8 +1480,7 @@ wxPathPathRgn::wxPathPathRgn(wxDC *dc_for_scale,
{ {
p = new wxPath(); p = new wxPath();
p->AddPath(_p); p->AddPath(_p);
xoffset = _xoffset; p->Translate(_xoffset, _yoffset);
yoffset = _yoffset;
fillStyle = _fillStyle; fillStyle = _fillStyle;
} }

View File

@ -170,8 +170,6 @@ class wxPathPathRgn : public wxPathRgn
{ {
public: public:
wxPath *p; wxPath *p;
double xoffset;
double yoffset;
int fillStyle; int fillStyle;
wxPathPathRgn(wxDC *dc_for_scale, wxPath *p, double xoffset, double yoffset, int fillStyle); wxPathPathRgn(wxDC *dc_for_scale, wxPath *p, double xoffset, double yoffset, int fillStyle);
virtual Bool Install(long target, Bool reverse, Bool align); virtual Bool Install(long target, Bool reverse, Bool align);