finix initial size of cocoa frame

original commit: ca29be4eb132bf17dfe552aa78981c1f3115b9c1
This commit is contained in:
Matthew Flatt 2010-08-03 17:13:54 -06:00
parent 1bf7884280
commit 4995e89a21

View File

@ -101,16 +101,20 @@
(let ([is-sheet? (and #f (let ([is-sheet? (and #f
is-dialog? is-dialog?
parent parent
(not (send parent frame-is-dialog?)))]) (not (send parent frame-is-dialog?)))]
(as-objc-allocation [init-rect (let-values ([(x y) (init-pos x y)])
(make-NSRect (make-NSPoint x y)
(make-NSSize (max 30 w)
(max (if (memq 'no-caption style)
0
22)
h))))])
(let ([c (as-objc-allocation
(tell (tell (if is-sheet? (tell (tell (if is-sheet?
MyPanel MyPanel
MyWindow) MyWindow)
alloc) alloc)
initWithContentRect: #:type _NSRect (let-values ([(x y) (init-pos x y)]) initWithContentRect: #:type _NSRect init-rect
(make-NSRect (make-NSPoint x y)
(make-NSSize (max 30 w)
(max 0 h))))
styleMask: #:type _int (if (memq 'no-caption style) styleMask: #:type _int (if (memq 'no-caption style)
NSBorderlessWindowMask NSBorderlessWindowMask
(bitwise-ior (bitwise-ior
@ -125,7 +129,10 @@
0 0
NSResizableWindowMask))))) NSResizableWindowMask)))))
backing: #:type _int NSBackingStoreBuffered backing: #:type _int NSBackingStoreBuffered
defer: #:type _BOOL NO)))] defer: #:type _BOOL NO))])
;; use init rect as frame size, not content size
(tellv c setFrame: #:type _NSRect init-rect display: #:type _BOOL #f)
c))]
[no-show? #t]) [no-show? #t])
(define cocoa (get-cocoa)) (define cocoa (get-cocoa))
(tellv cocoa setDelegate: cocoa) (tellv cocoa setDelegate: cocoa)