cocoa: set button control size when font is small
Closes PR 11404 original commit: d7369f819c014ab15da4b9dc23c6a4ac7f0f5664
This commit is contained in:
parent
f83d833348
commit
68fbeb7cde
|
@ -23,6 +23,9 @@
|
|||
(define MIN-BUTTON-WIDTH 72)
|
||||
(define BUTTON-EXTRA-WIDTH 12)
|
||||
|
||||
(define NSSmallControlSize 1)
|
||||
(define NSMiniControlSize 2)
|
||||
|
||||
(define-objc-class MyButton NSButton
|
||||
#:mixins (FocusResponder KeyMouseResponder CursorDisplayer)
|
||||
[wxb]
|
||||
|
@ -61,6 +64,14 @@
|
|||
(tellv cocoa sizeToFit)
|
||||
(when (and (eq? event-type 'button)
|
||||
(string? label))
|
||||
(when font
|
||||
(let ([n (send font get-point-size)])
|
||||
(when (n . < . sys-font-size)
|
||||
(tellv (tell cocoa cell)
|
||||
setControlSize: #:type _int
|
||||
(if (n . < . (- sys-font-size 2))
|
||||
NSMiniControlSize
|
||||
NSSmallControlSize)))))
|
||||
(let ([frame (tell #:type _NSRect cocoa frame)])
|
||||
(tellv cocoa setFrame: #:type _NSRect
|
||||
(make-NSRect (NSRect-origin frame)
|
||||
|
|
|
@ -244,7 +244,7 @@
|
|||
(not (send p get-sheet)))))
|
||||
(let ([p (get-parent)])
|
||||
(send p set-sheet this)
|
||||
(tell (tell NSApplication sharedApplication)
|
||||
(tellv (tell NSApplication sharedApplication)
|
||||
beginSheet: cocoa
|
||||
modalForWindow: (send p get-cocoa)
|
||||
modalDelegate: #f
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
ffi/unsafe
|
||||
ffi/unsafe/objc
|
||||
"../../syntax.rkt"
|
||||
"../../lock.rkt"
|
||||
"window.rkt"
|
||||
"const.rkt"
|
||||
"types.rkt"
|
||||
|
@ -10,11 +11,17 @@
|
|||
|
||||
(provide
|
||||
(protect-out item%
|
||||
install-control-font))
|
||||
install-control-font
|
||||
sys-font-size))
|
||||
|
||||
(import-class NSFont)
|
||||
(define sys-font (tell NSFont
|
||||
systemFontOfSize: #:type _CGFloat 13))
|
||||
|
||||
(define sys-font-size 13)
|
||||
(define sys-font
|
||||
(atomically
|
||||
(let ([f (tell NSFont systemFontOfSize: #:type _CGFloat sys-font-size)])
|
||||
(tellv f retain)
|
||||
f)))
|
||||
|
||||
(define (install-control-font cocoa font)
|
||||
(if font
|
||||
|
|
Loading…
Reference in New Issue
Block a user