Add more specific class types instead of Any.

Fixes Insert Large Letters dialog.  Merge to 5.3.1.
(cherry picked from commit 4124c9a41b)
This commit is contained in:
Sam Tobin-Hochstadt 2012-10-27 17:44:12 -07:00 committed by Ryan Culpepper
parent 64826c1db3
commit 421e8a469e
3 changed files with 32 additions and 29 deletions

View File

@ -7,7 +7,7 @@
(define-type-alias Bitmap-Message% (Class () (define-type-alias Bitmap-Message% (Class ()
([parent Any]) ([parent (Instance Horizontal-Panel%)])
([set-bm ((Instance Bitmap%) -> Void)]))) ([set-bm ((Instance Bitmap%) -> Void)])))
@ -16,7 +16,7 @@
(provide insert-large-letters) (provide insert-large-letters)
(: insert-large-letters (String Char (Instance Racket:Text%) Any -> Void)) (: insert-large-letters (String Char (Instance Text:Basic%) Any -> Void))
(define (insert-large-letters comment-prefix comment-character edit parent) (define (insert-large-letters comment-prefix comment-character edit parent)
(let ([str (make-large-letters-dialog comment-prefix comment-character #f)]) (let ([str (make-large-letters-dialog comment-prefix comment-character #f)])
(when (and str (when (and str
@ -90,7 +90,7 @@
(: pane2 (Instance Horizontal-Pane%)) (: pane2 (Instance Horizontal-Pane%))
(define pane2 (new horizontal-pane% (parent info-bar))) (define pane2 (new horizontal-pane% (parent info-bar)))
(: txt (Instance Racket:Text%)) (: txt (Instance Text:Basic%))
(define txt (new racket:text%)) (define txt (new racket:text%))
(: ec (Instance Editor-Canvas%)) (: ec (Instance Editor-Canvas%))
(define ec (new editor-canvas% [parent dlg] [editor txt])) (define ec (new editor-canvas% [parent dlg] [editor txt]))
@ -145,7 +145,7 @@
(format " (~a)" (floor (inexact->exact w)))))) (format " (~a)" (floor (inexact->exact w))))))
(: get-max-line-width ((Instance Racket:Text%) -> Real)) (: get-max-line-width ((Instance Text:Basic%) -> Real))
(define (get-max-line-width txt) (define (get-max-line-width txt)
(let loop ([i (+ (send txt last-paragraph) 1)] (let loop ([i (+ (send txt last-paragraph) 1)]
[#{m : Integer} 0]) [#{m : Integer} 0])
@ -156,7 +156,7 @@
(send txt paragraph-start-position (- i 1)))))]))) (send txt paragraph-start-position (- i 1)))))])))
(: render-large-letters (String Char (Instance Font%) String (Instance Racket:Text%) -> (Instance Bitmap%))) (: render-large-letters (String Char (Instance Font%) String (Instance Text:Basic%) -> (Instance Bitmap%)))
(define (render-large-letters comment-prefix comment-character the-font str edit) (define (render-large-letters comment-prefix comment-character the-font str edit)
(define bdc (make-object bitmap-dc% (make-object bitmap% 1 1 #t))) (define bdc (make-object bitmap-dc% (make-object bitmap% 1 1 #t)))
(define-values (tw raw-th td ta) (send bdc get-text-extent str the-font)) (define-values (tw raw-th td ta) (send bdc get-text-extent str the-font))

View File

@ -9,28 +9,13 @@
() ()
([get-font (-> (Instance Font%))]))))]))) ([get-font (-> (Instance Font%))]))))])))
(dt Racket:Text% (Class ()
()
([begin-edit-sequence (-> Void)]
[end-edit-sequence (-> Void)]
[lock (Boolean -> Void)]
[last-position (-> Number)]
[last-paragraph (-> Exact-Nonnegative-Integer)]
[delete (Number Number -> Void)]
[auto-wrap (Any -> Void)]
[paragraph-end-position (Number -> Natural)]
[paragraph-start-position (Number -> Natural)]
[get-start-position (-> Number)]
[get-end-position (-> Number)]
[insert (String Number Number -> Void)])))
(require/typed/provide (require/typed/provide
framework/framework framework/framework
[preferences:set-default (Symbol Sexp (Any -> Boolean) -> Void)] [preferences:set-default (Symbol Sexp (Any -> Boolean) -> Void)]
[preferences:set (Symbol Sexp -> Void)] [preferences:set (Symbol Sexp -> Void)]
[editor:get-standard-style-list [editor:get-standard-style-list
(-> (Instance Style-List%))] (-> (Instance Style-List%))]
[racket:text% Racket:Text%] [racket:text% Text:Basic%]
[gui-utils:ok/cancel-buttons [gui-utils:ok/cancel-buttons
((Instance Horizontal-Panel%) ((Instance Horizontal-Panel%)
((Instance Button%) (Instance Event%) -> Void) ((Instance Button%) (Instance Event%) -> Void)

View File

@ -20,28 +20,30 @@
([parent Any] [width Integer] [label String]) ([parent Any] [width Integer] [label String])
([show (Any -> Void)]))) ([show (Any -> Void)])))
(dt Text-Field% (Class () (dt Text-Field% (Class ()
([parent Any] [callback Any] [label String]) ([parent (Instance Dialog%)]
[callback (Any Any -> Any)]
[label String])
([get-value (-> String)] ([get-value (-> String)]
[focus (-> Void)]))) [focus (-> Void)])))
(dt Horizontal-Panel% (Class () (dt Horizontal-Panel% (Class ()
([parent Any] ([parent (Instance Dialog%)]
[stretchable-height Any #t] [stretchable-height Any #t]
[alignment (List Symbol Symbol) #t]) [alignment (List Symbol Symbol) #t])
())) ()))
(dt Choice% (Class () (dt Choice% (Class ()
([parent Any] [label String] [choices (Listof Any)] [callback Any]) ([parent (Instance Horizontal-Panel%)] [label String] [choices (Listof Any)] [callback (Any Any -> Any)])
([get-selection (-> (Option Natural))] ([get-selection (-> (Option Natural))]
[set-selection (Integer -> Any)] [set-selection (Integer -> Any)]
[get-string-selection (-> (Option String))] [get-string-selection (-> (Option String))]
[set-string-selection (String -> Void)]))) [set-string-selection (String -> Void)])))
(dt Message% (Class () (dt Message% (Class ()
([parent Any] [label String]) ([parent (Instance Horizontal-Panel%)] [label String])
([set-label ((U String (Instance Bitmap%)) -> Void)]))) ([set-label ((U String (Instance Bitmap%)) -> Void)])))
(dt Horizontal-Pane% (Class () (dt Horizontal-Pane% (Class ()
([parent Any]) ([parent (Instance Horizontal-Panel%)])
())) ()))
(dt Editor-Canvas% (Class () (dt Editor-Canvas% (Class ()
([parent Any] [editor Any]) ([parent (Instance Dialog%)] [editor (Instance Text:Basic%)])
([set-line-count ((U #f Integer) -> Void)]))) ([set-line-count ((U #f Integer) -> Void)])))
(dt Bitmap-DC% (Class ((Instance Bitmap%)) (dt Bitmap-DC% (Class ((Instance Bitmap%))
() ()
@ -55,6 +57,22 @@
(dt Snip% (Class () () ([get-count (-> Integer)]))) (dt Snip% (Class () () ([get-count (-> Integer)])))
(dt Text:Basic% (Class ()
()
([begin-edit-sequence (-> Void)]
[end-edit-sequence (-> Void)]
[lock (Boolean -> Void)]
[last-position (-> Number)]
[last-paragraph (-> Exact-Nonnegative-Integer)]
[delete (Number Number -> Void)]
[auto-wrap (Any -> Void)]
[paragraph-end-position (Number -> Integer)]
[paragraph-start-position (Number -> Integer)]
[get-start-position (-> Integer)]
[get-end-position (-> Integer)]
[get-text (Integer (U Integer 'eof) -> String)]
[insert (String Number Number -> Void)])))
(dt Text% (Class () (dt Text% (Class ()
() ()
([begin-edit-sequence (-> Void)] ([begin-edit-sequence (-> Void)]