Add type annotations for GUI libraries
The types for racket/gui are substantially complete, but there are still some missing classes and methods. Some interesting future work would be to ensure type coverage by comparing the class members vs. the types in the environment. That could be run as a test to ensure it stays up to date. Most types for the framework library are still missing. original commit: 00a3b7cb149ae35c63b9eb64df34d87424407a10
This commit is contained in:
parent
72e1cfc91b
commit
f90c6f92b0
|
@ -8,6 +8,7 @@
|
|||
"draw-lib"
|
||||
"rackunit-lib"
|
||||
"rackunit-gui"
|
||||
"snip-lib"
|
||||
"typed-racket-lib"
|
||||
"gui-lib"
|
||||
"pict-lib"))
|
||||
|
|
43
pkgs/typed-racket-pkgs/typed-racket-more/typed/framework.rkt
Normal file
43
pkgs/typed-racket-pkgs/typed-racket-more/typed/framework.rkt
Normal file
|
@ -0,0 +1,43 @@
|
|||
#lang s-exp typed-racket/base-env/extra-env-lang
|
||||
|
||||
;; A typed wrapper for the framework library
|
||||
|
||||
(require framework
|
||||
(for-syntax (only-in (rep type-rep)
|
||||
make-Instance))
|
||||
"racket/private/gui-types.rkt"
|
||||
(for-syntax (submod "racket/private/gui-types.rkt" #%type-decl))
|
||||
"private/framework-types.rkt"
|
||||
(for-syntax (submod "private/framework-types.rkt" #%type-decl)))
|
||||
|
||||
(provide (all-from-out "private/framework-types.rkt"))
|
||||
|
||||
(begin-for-syntax
|
||||
(define -Button% (parse-type #'Button%))
|
||||
(define -Event% (parse-type #'Event%)))
|
||||
|
||||
(type-environment
|
||||
;; 8 Canvas
|
||||
[canvas:basic% (parse-type #'Canvas:Basic%)]
|
||||
[canvas:wide-snip-mixin (parse-type #'Canvas:Wide-Snip-Mixin)]
|
||||
;; 11 Editor
|
||||
[editor:get-standard-style-list
|
||||
(-> (make-Instance (parse-type #'Style-List%)))]
|
||||
;; 14 Frame
|
||||
[frame:basic-mixin (parse-type #'Frame:Basic-Mixin)]
|
||||
[frame:focus-table-mixin (parse-type #'Frame:Focus-Table-Mixin)]
|
||||
[frame:size-pref-mixin (parse-type #'Frame:Size-Pref-Mixin)]
|
||||
[frame:register-group-mixin (parse-type #'Frame:Register-Group-Mixin)]
|
||||
[frame:status-line-mixin (parse-type #'Frame:Status-Line-Mixin)]
|
||||
;; 16
|
||||
[gui-utils:ok/cancel-buttons
|
||||
(-> (make-Instance (parse-type #'Horizontal-Panel%))
|
||||
(-> (make-Instance -Button%) (make-Instance -Event%) -Void)
|
||||
(-> (make-Instance -Button%) (make-Instance -Event%) -Void)
|
||||
(-values (list Univ Univ)))]
|
||||
;; 27
|
||||
[preferences:get (-> -Symbol -Sexp)]
|
||||
[preferences:set (-> -Symbol -Sexp -Void)]
|
||||
[preferences:set-default (-> -Symbol -Sexp (-> Univ -Boolean) -Void)]
|
||||
;; 28
|
||||
[racket:text% (parse-type #'Text:Basic<%>)])
|
|
@ -0,0 +1,173 @@
|
|||
#lang typed/racket
|
||||
|
||||
;; Types for the framework library
|
||||
|
||||
(require "../racket/private/gui-types.rkt")
|
||||
|
||||
;; 4 Canvas
|
||||
(provide Canvas:Basic<%>
|
||||
Canvas:Basic%
|
||||
Canvas:Wide-Snip<%>
|
||||
Canvas:Wide-Snip-Mixin)
|
||||
|
||||
(define-type Canvas:Basic<%>
|
||||
(Class #:implements Editor-Canvas%))
|
||||
|
||||
(define-type Canvas:Basic%
|
||||
(Class #:implements Canvas:Basic<%>
|
||||
(init [parent (Instance Dialog%)]
|
||||
[editor (Instance Text:Basic<%>)])))
|
||||
|
||||
(define-type Canvas:Wide-Snip<%>
|
||||
(Class #:implements Canvas:Basic<%>
|
||||
[recalc-snips (-> Void)]
|
||||
[add-wide-snip ((Instance Snip%) -> Void)]
|
||||
[add-tall-snip ((Instance Snip%) -> Void)]))
|
||||
|
||||
(define-type Canvas:Wide-Snip-Mixin
|
||||
(All (r #:row)
|
||||
(Class #:row-var r #:implements Canvas:Basic<%>)
|
||||
->
|
||||
(Class #:row-var r #:implements Canvas:Wide-Snip<%>)))
|
||||
|
||||
;; 11 Editor
|
||||
(provide Editor:Basic<%>
|
||||
Editor:Keymap<%>
|
||||
Editor:File<%>)
|
||||
|
||||
(define-type Editor:Basic<%>
|
||||
(Class #:implements Editor<%>
|
||||
[has-focus? (-> Boolean)]
|
||||
;; FIXME
|
||||
))
|
||||
|
||||
(define-type Editor:Keymap<%>
|
||||
(Class #:implements Editor:Basic<%>
|
||||
;; FIXME
|
||||
))
|
||||
|
||||
(define-type Editor:File<%>
|
||||
(Class #:implements Editor:Keymap<%>
|
||||
;; FIXME
|
||||
[update-frame-filename (-> Void)]
|
||||
[allow-close-with-no-filename? (-> Boolean)]
|
||||
[user-saves-or-not-modified? (#t -> Boolean)] ; FIXME: fishy docs
|
||||
))
|
||||
|
||||
;; 14 Frame
|
||||
(provide Frame:Basic<%>
|
||||
Frame:Focus-Table<%>
|
||||
Frame:Size-Pref<%>
|
||||
Frame:Register-Group<%>
|
||||
Frame:Status-Line<%>
|
||||
Frame:Basic-Mixin
|
||||
Frame:Focus-Table-Mixin
|
||||
Frame:Size-Pref-Mixin
|
||||
Frame:Register-Group-Mixin
|
||||
Frame:Status-Line-Mixin)
|
||||
|
||||
(define-type Frame:Basic<%>
|
||||
(Class #:implements Frame%
|
||||
;; this method has a tricky type
|
||||
[get-area-container% (-> Any)]
|
||||
[get-area-container (-> (Instance Area-Container<%>))]
|
||||
[get-menu-bar% (-> Any)]
|
||||
[make-root-area-container
|
||||
(Any (Instance Area-Container<%>) -> (Instance Area-Container<%>))]
|
||||
[close (-> Void)]
|
||||
[editing-this-file? (Path -> Boolean)]
|
||||
[get-filename
|
||||
(case->
|
||||
(-> (Option Path))
|
||||
((Option (Boxof Boolean)) -> (Option Path)))]
|
||||
[make-visible (String -> Void)]))
|
||||
|
||||
(define-type Frame:Focus-Table<%>
|
||||
(Class #:implements Frame%))
|
||||
|
||||
(define-type Frame:Size-Pref<%>
|
||||
(Class #:implements Frame:Basic<%>
|
||||
[adjust-size-when-monitor-setup-changes? (-> Boolean)]))
|
||||
|
||||
(define-type Frame:Register-Group<%>
|
||||
(Class #:implements Frame%))
|
||||
|
||||
(define-type Frame:Status-Line<%>
|
||||
;; Note: if you change this next line to
|
||||
;; #:implements Frame%, then the mixin using this
|
||||
;; type below should be ruled out by sealing contracts.
|
||||
;;
|
||||
;; TODO: implement sealing contracts and make sure
|
||||
;; that mistake is ruled out
|
||||
(Class #:implements Frame:Basic<%>
|
||||
[open-status-line (Symbol -> Void)]
|
||||
[close-status-line (Symbol -> Void)]
|
||||
[update-status-line
|
||||
(Symbol (Option String) -> Void)]))
|
||||
|
||||
(define-type Frame:Basic-Mixin
|
||||
(All (r #:row)
|
||||
(Class #:row-var r #:implements Frame%)
|
||||
->
|
||||
(Class #:row-var r #:implements Frame:Basic<%>)))
|
||||
|
||||
(define-type Frame:Focus-Table-Mixin
|
||||
(All (r #:row)
|
||||
(Class #:row-var r #:implements Frame%)
|
||||
->
|
||||
(Class #:row-var r #:implements Frame:Focus-Table<%>)))
|
||||
|
||||
(define-type Frame:Size-Pref-Mixin
|
||||
(All (r #:row)
|
||||
(Class #:row-var r #:implements Frame%)
|
||||
->
|
||||
(Class #:row-var r #:implements Frame:Size-Pref<%>
|
||||
(init [size-preferences Symbol]
|
||||
[position-preferences-key (Option Symbol) #:optional]
|
||||
[width (Option Natural)]
|
||||
[height (Option Natural)]
|
||||
[x (Option Integer)]
|
||||
[y (Option Integer)]))))
|
||||
|
||||
(define-type Frame:Register-Group-Mixin
|
||||
(All (r #:row)
|
||||
(Class #:row-var r #:implements Frame:Basic<%>)
|
||||
->
|
||||
(Class #:row-var r #:implements Frame:Focus-Table<%>)))
|
||||
|
||||
(define-type Frame:Status-Line-Mixin
|
||||
(All (r #:row)
|
||||
(Class #:row-var r #:implements Frame:Basic<%>)
|
||||
->
|
||||
(Class #:row-var r #:implements Frame:Status-Line<%>)))
|
||||
|
||||
;; 29 Text
|
||||
(provide Text:Basic<%>
|
||||
Text:File<%>)
|
||||
|
||||
(define-type Text:Basic<%>
|
||||
(Class #:implements Text%
|
||||
;; highlight-range
|
||||
;; unhighlight-range
|
||||
;; unhighlight-ranges/key
|
||||
[unhighlight-ranges/key (Any -> Void)]
|
||||
;; unhighlight-ranges
|
||||
;; get-highlighted-ranges
|
||||
[get-styles-fixed (-> Boolean)]
|
||||
;; get-fixed-style
|
||||
[set-styles-fixed (Boolean -> Void)]
|
||||
;; move/copy-to-edit
|
||||
[initial-autowrap-bitmap
|
||||
(-> (Option (Instance Bitmap%)))]
|
||||
[get-port-name
|
||||
(-> (U Path-String Symbol #f))]
|
||||
[port-name-matches? (Any -> Boolean)]
|
||||
[get-edition-number (-> Natural)]
|
||||
[get-start-of-line (Natural -> Natural)]))
|
||||
|
||||
(define-type Text:File<%>
|
||||
(Class #:implements Text:Basic<%>
|
||||
#:implements Editor:File<%>
|
||||
[get-read-write? (-> Boolean)]
|
||||
[while-unlocked ((-> Any) -> Any)]))
|
||||
|
|
@ -0,0 +1,78 @@
|
|||
#lang s-exp typed-racket/base-env/extra-env-lang
|
||||
|
||||
;; This module provides a base type environment including
|
||||
;; racket/draw bindings
|
||||
|
||||
(begin
|
||||
(require racket/draw/private/bitmap
|
||||
racket/draw/private/bitmap-dc
|
||||
racket/draw/private/brush
|
||||
racket/draw/private/color
|
||||
racket/draw/private/font
|
||||
racket/draw/private/gl-config
|
||||
racket/draw/private/pen
|
||||
racket/draw/private/region
|
||||
(for-syntax (only-in (rep type-rep) make-Instance))
|
||||
"private/gui-types.rkt"
|
||||
(for-syntax (submod "private/gui-types.rkt" #%type-decl)))
|
||||
|
||||
(provide (all-from-out racket/draw/private/bitmap
|
||||
racket/draw/private/bitmap-dc
|
||||
racket/draw/private/brush
|
||||
racket/draw/private/color
|
||||
racket/draw/private/font
|
||||
racket/draw/private/pen
|
||||
racket/draw/private/region)
|
||||
LoadFileKind
|
||||
Font-Family
|
||||
Font-Style
|
||||
Font-Weight
|
||||
Font-Smoothing
|
||||
Font-Hinting
|
||||
Bitmap%
|
||||
Bitmap-DC%
|
||||
Brush-Style
|
||||
Brush%
|
||||
Brush-List%
|
||||
Color%
|
||||
Color-Database<%>
|
||||
DC<%>
|
||||
Font%
|
||||
Font-List%
|
||||
GL-Config%
|
||||
GL-Context<%>
|
||||
Pen%
|
||||
Pen-List%
|
||||
Pen-Style
|
||||
Pen-Cap-Style
|
||||
Pen-Join-Style
|
||||
Point%
|
||||
Region%))
|
||||
|
||||
(type-environment
|
||||
[the-brush-list (make-Instance (parse-type #'Brush-List%))]
|
||||
[the-pen-list (make-Instance (parse-type #'Pen-List%))]
|
||||
[the-font-list (make-Instance (parse-type #'Font-List%))]
|
||||
[make-bitmap
|
||||
(->optkey -PosInt -PosInt [Univ] #:backing-scale -Real #f
|
||||
(make-Instance (parse-type #'Bitmap%)))]
|
||||
[read-bitmap
|
||||
(->opt (Un -Pathlike) [-Symbol (Un (make-Instance (parse-type #'Color%)) (-val #f)) Univ]
|
||||
(make-Instance (parse-type #'Bitmap%)))]
|
||||
[make-color
|
||||
(->optkey -Byte -Byte -Byte
|
||||
[-Real]
|
||||
#:immutable? Univ #f
|
||||
(make-Instance (parse-type #'Color%)))]
|
||||
|
||||
[bitmap% (parse-type #'Bitmap%)]
|
||||
[bitmap-dc% (parse-type #'Bitmap-DC%)]
|
||||
[brush% (parse-type #'Brush%)]
|
||||
[brush-list% (parse-type #'Brush-List%)]
|
||||
[color% (parse-type #'Color%)]
|
||||
[the-color-database (make-Instance (parse-type #'Color-Database<%>))]
|
||||
[font% (parse-type #'Font%)]
|
||||
[font-list% (parse-type #'Font-List%)]
|
||||
[gl-config% (parse-type #'GL-Config%)]
|
||||
[pen% (parse-type #'Pen%)]
|
||||
[region% (parse-type #'Region%)])
|
332
pkgs/typed-racket-pkgs/typed-racket-more/typed/racket/gui.rkt
Normal file
332
pkgs/typed-racket-pkgs/typed-racket-more/typed/racket/gui.rkt
Normal file
|
@ -0,0 +1,332 @@
|
|||
#lang s-exp typed-racket/base-env/extra-env-lang
|
||||
|
||||
;; This module provides a base type environment including
|
||||
;; most GUI library bindings
|
||||
|
||||
(require racket/require
|
||||
(subtract-in racket/gui/base
|
||||
racket/draw
|
||||
(except-in racket/snip get-the-snip-class-list))
|
||||
(for-syntax (only-in (rep type-rep)
|
||||
make-Evt
|
||||
make-Instance
|
||||
make-Opaque))
|
||||
"draw.rkt"
|
||||
"snip.rkt"
|
||||
"private/gui-types.rkt"
|
||||
(for-syntax (submod "private/gui-types.rkt" #%type-decl)))
|
||||
|
||||
(provide (all-from-out "draw.rkt")
|
||||
(all-from-out "snip.rkt")
|
||||
(all-from-out "private/gui-types.rkt"))
|
||||
|
||||
(begin-for-syntax
|
||||
(define -Eventspace (make-Opaque #'eventspace?))
|
||||
(define -Color% (parse-type #'Color%))
|
||||
(define -Color%-Obj (make-Instance -Color%)))
|
||||
|
||||
(type-environment
|
||||
[button% (parse-type #'Button%)]
|
||||
[canvas% (parse-type #'Canvas%)]
|
||||
[check-box% (parse-type #'Check-Box%)]
|
||||
[checkable-menu-item% (parse-type #'Checkable-Menu-Item%)]
|
||||
[choice% (parse-type #'Choice%)]
|
||||
[clipboard-client% (parse-type #'Clipboard-Client%)]
|
||||
[combo-field% (parse-type #'Combo-Field%)]
|
||||
[column-control-event% (parse-type #'Column-Control-Event%)]
|
||||
[control-event% (parse-type #'Control-Event%)]
|
||||
[cursor% (parse-type #'Cursor%)]
|
||||
[dialog% (parse-type #'Dialog%)]
|
||||
[event% (parse-type #'Event%)]
|
||||
[frame% (parse-type #'Frame%)]
|
||||
[gauge% (parse-type #'Gauge%)]
|
||||
[group-box-panel% (parse-type #'Group-Box-Panel%)]
|
||||
[grow-box-spacer-pane% (parse-type #'Grow-Box-Spacer-Pane%)]
|
||||
[horizontal-pane% (parse-type #'Horizontal-Pane%)]
|
||||
[horizontal-panel% (parse-type #'Horizontal-Panel%)]
|
||||
[key-event% (parse-type #'Key-Event%)]
|
||||
[list-box% (parse-type #'List-Box%)]
|
||||
[menu% (parse-type #'Menu%)]
|
||||
[menu-bar% (parse-type #'Menu-Bar%)]
|
||||
[menu-item% (parse-type #'Menu-Item%)]
|
||||
[message% (parse-type #'Message%)]
|
||||
[mouse-event% (parse-type #'Mouse-Event%)]
|
||||
[pane% (parse-type #'Pane%)]
|
||||
[panel% (parse-type #'Panel%)]
|
||||
[popup-menu% (parse-type #'Popup-Menu%)]
|
||||
[printer-dc% (parse-type #'Printer-DC%)]
|
||||
[radio-box% (parse-type #'Radio-Box%)]
|
||||
[separator-menu-item% (parse-type #'Separator-Menu-Item%)]
|
||||
[scroll-event% (parse-type #'Scroll-Event%)]
|
||||
[slider% (parse-type #'Slider%)]
|
||||
[tab-panel% (parse-type #'Tab-Panel%)]
|
||||
[text-field% (parse-type #'Text-Field%)]
|
||||
[timer% (parse-type #'Timer%)]
|
||||
[vertical-pane% (parse-type #'Vertical-Pane%)]
|
||||
[vertical-panel% (parse-type #'Vertical-Panel%)]
|
||||
[the-font-list (make-Instance (parse-type #'Font-List%))]
|
||||
[get-face-list
|
||||
(->optkey [(one-of/c 'mono 'all)]
|
||||
#:all-variants? Univ #f
|
||||
(-lst -String))]
|
||||
[editor-canvas% (parse-type #'Editor-Canvas%)]
|
||||
[message-box (-> -String -String (one-of/c 'ok 'cancel 'yes 'no))]
|
||||
[open-input-text-editor
|
||||
(->optkey (make-Instance (parse-type #'Text%))
|
||||
[-Integer
|
||||
(Un (-val 'end) -Integer)
|
||||
(-> (make-Instance (parse-type #'Snip%))
|
||||
(make-Instance (parse-type #'Snip%)))
|
||||
(make-Instance (parse-type #'Text%))
|
||||
-Boolean]
|
||||
#:lock-while-reading? Univ #f
|
||||
-Input-Port)]
|
||||
;; Editor classes
|
||||
[editor-admin% (parse-type #'Editor-Admin%)]
|
||||
[editor-canvas% (parse-type #'Editor-Canvas%)]
|
||||
[editor-data% (parse-type #'Editor-Data%)]
|
||||
[editor-data-class% (parse-type #'Editor-Data-Class%)]
|
||||
[editor-stream-in% (parse-type #'Editor-Stream-In%)]
|
||||
[editor-stream-out% (parse-type #'Editor-Stream-Out%)]
|
||||
[keymap% (parse-type #'Keymap%)]
|
||||
[pasteboard% (parse-type #'Pasteboard%)]
|
||||
[text% (parse-type #'Text%)]
|
||||
;; 4.1 Dialogs
|
||||
[get-file
|
||||
(->optkey [(Un (-val #f) -String)
|
||||
(Un (-val #f)
|
||||
(make-Instance (parse-type #'Frame%))
|
||||
(make-Instance (parse-type #'Dialog%)))
|
||||
(Un (-val #f) -Pathlike)
|
||||
(Un (-val #f) -Pathlike)
|
||||
(Un (-val #f) -String)
|
||||
(-lst (one-of/c 'packages 'enter-packages 'common))
|
||||
(-lst (-pair -String (-pair -String (-val null))))]
|
||||
#:dialog-mixin (Un) #f
|
||||
(Un (-val #f) -Path))]
|
||||
[get-file-list
|
||||
(->optkey [(Un (-val #f) -String)
|
||||
(Un (-val #f)
|
||||
(make-Instance (parse-type #'Frame%))
|
||||
(make-Instance (parse-type #'Dialog%)))
|
||||
(Un (-val #f) -Pathlike)
|
||||
(Un (-val #f) -Pathlike)
|
||||
(Un (-val #f) -String)
|
||||
(-lst (one-of/c 'packages 'enter-packages 'common))
|
||||
(-lst (-pair -String (-pair -String (-val null))))]
|
||||
#:dialog-mixin (Un) #f
|
||||
(Un (-val #f) (-lst -Path)))]
|
||||
[put-file
|
||||
(->optkey [(Un (-val #f) -String)
|
||||
(Un (-val #f)
|
||||
(make-Instance (parse-type #'Frame%))
|
||||
(make-Instance (parse-type #'Dialog%)))
|
||||
(Un (-val #f) -Pathlike)
|
||||
(Un (-val #f) -Pathlike)
|
||||
(Un (-val #f) -String)
|
||||
(-lst (one-of/c 'packages 'enter-packages 'common))
|
||||
(-lst (-pair -String (-pair -String (-val null))))]
|
||||
#:dialog-mixin (Un) #f
|
||||
(Un (-val #f) -Path))]
|
||||
[get-directory
|
||||
(->optkey [(Un (-val #f) -String)
|
||||
(Un (-val #f)
|
||||
(make-Instance (parse-type #'Frame%))
|
||||
(make-Instance (parse-type #'Dialog%)))
|
||||
(Un (-val #f) -Pathlike)
|
||||
(-lst (one-of/c 'enter-packages 'common))]
|
||||
;; FIXME: better type for this argument
|
||||
#:dialog-mixin (Un) #f
|
||||
(Un (-val #f) -Path))]
|
||||
[message-box
|
||||
(->optkey -String -String
|
||||
[(Un (-val #f)
|
||||
(make-Instance (parse-type #'Frame%))
|
||||
(make-Instance (parse-type #'Dialog%)))
|
||||
(-lst (one-of/c 'ok 'ok-cancel 'yes-no
|
||||
'caution 'stop 'no-icon))]
|
||||
#:dialog-mixin (Un) #f
|
||||
(one-of/c 'ok 'cancel 'yes 'no))]
|
||||
[message-box/custom
|
||||
(->optkey -String -String
|
||||
(Un -String (make-Instance (parse-type #'Bitmap%)) (-val #f))
|
||||
(Un -String (make-Instance (parse-type #'Bitmap%)) (-val #f))
|
||||
(Un -String (make-Instance (parse-type #'Bitmap%)) (-val #f))
|
||||
[(Un (-val #f)
|
||||
(make-Instance (parse-type #'Frame%))
|
||||
(make-Instance (parse-type #'Dialog%)))
|
||||
(-lst (one-of/c 'stop 'caution 'no-icon 'number-order
|
||||
'disallow-close 'no-default
|
||||
'default=1 'default=2 'default=3))
|
||||
Univ]
|
||||
#:dialog-mixin (Un) #f
|
||||
Univ)]
|
||||
[message+check-box
|
||||
(->optkey -String -String -String
|
||||
[(Un (-val #f)
|
||||
(make-Instance (parse-type #'Frame%))
|
||||
(make-Instance (parse-type #'Dialog%)))
|
||||
(-lst (one-of/c 'ok 'ok-cancel 'yes-no
|
||||
'caution 'stop 'no-icon 'checked))]
|
||||
#:dialog-mixin (Un) #f
|
||||
(-values (list (one-of/c 'ok 'cancel 'yes 'no)
|
||||
-Boolean)))]
|
||||
[message+check-box
|
||||
(->optkey -String -String -String
|
||||
[(Un (-val #f)
|
||||
(make-Instance (parse-type #'Frame%))
|
||||
(make-Instance (parse-type #'Dialog%)))
|
||||
(-lst (one-of/c 'ok 'ok-cancel 'yes-no
|
||||
'caution 'stop 'no-icon 'checked))]
|
||||
#:dialog-mixin (Un) #f
|
||||
(-values (list (one-of/c 'ok 'cancel 'yes 'no)
|
||||
-Boolean)))]
|
||||
[message+check-box/custom
|
||||
(->optkey -String -String -String
|
||||
(Un -String (make-Instance (parse-type #'Bitmap%)) (-val #f))
|
||||
(Un -String (make-Instance (parse-type #'Bitmap%)) (-val #f))
|
||||
(Un -String (make-Instance (parse-type #'Bitmap%)) (-val #f))
|
||||
[(Un (-val #f)
|
||||
(make-Instance (parse-type #'Frame%))
|
||||
(make-Instance (parse-type #'Dialog%)))
|
||||
(-lst (one-of/c 'stop 'caution 'no-icon 'number-order
|
||||
'disallow-close 'no-default
|
||||
'default=1 'default=2 'default=3))
|
||||
Univ]
|
||||
#:dialog-mixin (Un) #f
|
||||
Univ)]
|
||||
[get-text-from-user
|
||||
(->optkey -String -String
|
||||
[(Un (-val #f)
|
||||
(make-Instance (parse-type #'Frame%))
|
||||
(make-Instance (parse-type #'Dialog%)))
|
||||
(-lst (one-of/c 'password 'disallow-invalid))]
|
||||
#:validate (-> -String -Boolean) #f
|
||||
#:dialog-mixin (Un) #f
|
||||
(Un (-val #f) -String))]
|
||||
[get-choices-from-user
|
||||
(->optkey -String -String (-lst -String)
|
||||
[(Un (-val #f)
|
||||
(make-Instance (parse-type #'Frame%))
|
||||
(make-Instance (parse-type #'Dialog%)))
|
||||
(-lst -Integer)
|
||||
(-lst (one-of/c 'single 'multiple 'extended))]
|
||||
(Un (-val #f) (-lst -Nat)))]
|
||||
[get-choices-from-user
|
||||
(->optkey [(Un (-val #f) -String)
|
||||
(Un (-val #f)
|
||||
(make-Instance (parse-type #'Frame%))
|
||||
(make-Instance (parse-type #'Dialog%)))
|
||||
(Un -Color%-Obj
|
||||
(-val #f))
|
||||
(-lst (-val 'alpha))]
|
||||
(Un (-val #f) -Color%-Obj))]
|
||||
[get-font-from-user
|
||||
(->optkey [(Un (-val #f) -String)
|
||||
(Un (-val #f)
|
||||
(make-Instance (parse-type #'Frame%))
|
||||
(make-Instance (parse-type #'Dialog%)))
|
||||
(Un (make-Instance (parse-type #'Font%)) (-val #f))
|
||||
(-val null)]
|
||||
(Un (-val #f) (make-Instance (parse-type #'Font%))))]
|
||||
[can-get-page-setup-from-user? (-> -Boolean)]
|
||||
;; 4.2 Eventspaces
|
||||
[#:opaque Eventspace eventspace?]
|
||||
[make-eventspace (-> -Eventspace)]
|
||||
[current-eventspace (-Param -Eventspace -Eventspace)]
|
||||
[event-dispatch-handler (-Param (-> -Eventspace Univ) (-> -Eventspace Univ))]
|
||||
[eventspace-event-evt
|
||||
(cl->* (-> (make-Evt -Eventspace))
|
||||
(-> -Eventspace (make-Evt -Eventspace)))]
|
||||
[eventspace-shutdown? (-> -Eventspace -Boolean)]
|
||||
[eventspace-handler-thread (-> -Eventspace (-opt -Thread))]
|
||||
[check-for-break (-> -Boolean)]
|
||||
[get-top-level-windows
|
||||
(-> (-lst (Un (make-Instance (parse-type #'Frame%))
|
||||
(make-Instance (parse-type #'Dialog%)))))]
|
||||
[get-top-level-focus-window
|
||||
(-> (Un (-val #f)
|
||||
(make-Instance (parse-type #'Frame%))
|
||||
(make-Instance (parse-type #'Dialog%))))]
|
||||
[get-top-level-edit-target-window
|
||||
(-> (Un (-val #f)
|
||||
(make-Instance (parse-type #'Frame%))
|
||||
(make-Instance (parse-type #'Dialog%))))]
|
||||
[special-control-key
|
||||
(cl->* (-> Univ -Void) (-> -Boolean))]
|
||||
[special-option-key
|
||||
(cl->* (-> Univ -Void) (-> -Boolean))]
|
||||
[queue-callback (->opt (-> Univ) [Univ] -Void)]
|
||||
[yield
|
||||
(-poly (a)
|
||||
(cl->* (-> -Boolean)
|
||||
(-> (-val 'wait) (-val #t))
|
||||
(-> (make-Evt a) a)))]
|
||||
[sleep/yield (-> -NonNegReal -Void)]
|
||||
;; 4.4 Global Graphics
|
||||
[flush-display (-> -Void)]
|
||||
[get-display-count (-> -PosInt)]
|
||||
[get-display-depth (-> -Nat)]
|
||||
[get-display-left-top-inset
|
||||
(cl->* (->key #:monitor -Nat #f
|
||||
(-values (list (Un (-val #f) -Nat)
|
||||
(Un (-val #f) -Nat))))
|
||||
(->key Univ #:monitor -Nat #f
|
||||
(-values (list (Un (-val #f) -Nat)
|
||||
(Un (-val #f) -Nat)))))]
|
||||
[get-display-size
|
||||
(cl->* (->key #:monitor -Nat #f
|
||||
(-values (list (Un (-val #f) -Nat)
|
||||
(Un (-val #f) -Nat))))
|
||||
(->key Univ #:monitor -Nat #f
|
||||
(-values (list (Un (-val #f) -Nat)
|
||||
(Un (-val #f) -Nat)))))]
|
||||
[is-color-display? (-> -Boolean)]
|
||||
;; 4.5 Fonts
|
||||
[menu-control-font (make-Instance (parse-type #'Font%))]
|
||||
[normal-control-font (make-Instance (parse-type #'Font%))]
|
||||
[small-control-font (make-Instance (parse-type #'Font%))]
|
||||
[tiny-control-font (make-Instance (parse-type #'Font%))]
|
||||
[view-control-font (make-Instance (parse-type #'Font%))]
|
||||
;; 4.6 Miscellaneous
|
||||
[begin-busy-cursor (-> -Void)]
|
||||
[bell (-> -Void)]
|
||||
[dimension-integer? (-> Univ -Boolean)]
|
||||
[end-busy-cursor (-> -Void)]
|
||||
[file-creator-and-type
|
||||
(cl->* (-> -Path (-values (list -Bytes -Bytes)))
|
||||
(-> -Path -Bytes -Bytes -Void))]
|
||||
[find-graphical-system-path
|
||||
(-> (one-of/c 'init-file 'x-display) (-opt -Path))]
|
||||
[get-default-shortcut-prefix
|
||||
(-> (Un (-lst* (-val 'ctl))
|
||||
(-lst* (-val 'cmd))
|
||||
(-lst (one-of/c 'alt 'cmd 'meta 'ctl 'shift 'option))))]
|
||||
[get-panel-background (-> -Color%-Obj)]
|
||||
[get-highlight-background-color (-> -Color%-Obj)]
|
||||
[get-highlight-text-color (-> (-opt -Color%-Obj))]
|
||||
; get-window-text-extent
|
||||
; graphical-read-eval-print-loop
|
||||
; textual-read-eval-print-loop
|
||||
; get-current-mouse-state
|
||||
[hide-cursor-until-moved (-> -Void)]
|
||||
[is-busy? (-> -Boolean)]
|
||||
[label->plain-label (-> -String -String)]
|
||||
; make-gl-bitmap
|
||||
[make-gui-empty-namespace (-> -Namespace)]
|
||||
[make-gui-namespace (-> -Namespace)]
|
||||
; make-screen-bitmap
|
||||
; play-sound
|
||||
; position-integer?
|
||||
; positive-dimension-integer?
|
||||
; register-collecting-blit
|
||||
; unregister-collecting-blit
|
||||
; send-message-to-window
|
||||
; spacing-integer?
|
||||
[system-position-ok-before-cancel? (-> -Boolean)]
|
||||
; the-clipboard
|
||||
; the-x-selection-clipboard
|
||||
; label-string?
|
||||
; key-code-symbol?
|
||||
;; 8 Editor functions
|
||||
[get-the-snip-class-list (-> (make-Instance (parse-type #'Snip-Class-List<%>)))])
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,26 @@
|
|||
#lang s-exp typed-racket/base-env/extra-env-lang
|
||||
|
||||
;; This module provides a base type environment including
|
||||
;; racket/snip bindings
|
||||
|
||||
(require racket/snip/private/snip
|
||||
racket/snip/private/snip-admin
|
||||
racket/snip/private/style
|
||||
"private/gui-types.rkt"
|
||||
(for-syntax (submod "private/gui-types.rkt" #%type-decl)))
|
||||
|
||||
(provide Snip%
|
||||
Snip-Admin%
|
||||
Snip-Class%
|
||||
String-Snip%
|
||||
Style<%>
|
||||
Style-Delta%
|
||||
Style-List%)
|
||||
|
||||
(type-environment
|
||||
[snip% (parse-type #'Snip%)]
|
||||
[snip-admin% (parse-type #'Snip-Admin%)]
|
||||
[snip-class% (parse-type #'Snip-Class%)]
|
||||
[string-snip% (parse-type #'String-Snip%)]
|
||||
[style-delta% (parse-type #'Style-Delta%)]
|
||||
[style-list% (parse-type #'Style-List%)])
|
Loading…
Reference in New Issue
Block a user