From 83347f1533df81e1b4bd41d43ce32292b5171be7 Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Fri, 22 Nov 2013 12:56:20 -0700 Subject: [PATCH] racket/gui cocoa: fix border of `combo-field%` for recent Mac OS X Merge to v6.0 (cherry picked from commit e0026f5de44b32690565c17a3e077c8e45cdeb7a) --- .../gui-lib/mred/private/wx/cocoa/canvas.rkt | 29 ++++++++++++++++--- pkgs/gui-pkgs/gui-test/tests/gracket/item.rkt | 2 +- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/pkgs/gui-pkgs/gui-lib/mred/private/wx/cocoa/canvas.rkt b/pkgs/gui-pkgs/gui-lib/mred/private/wx/cocoa/canvas.rkt index a0baed7457..9d4d845e23 100644 --- a/pkgs/gui-pkgs/gui-lib/mred/private/wx/cocoa/canvas.rkt +++ b/pkgs/gui-pkgs/gui-lib/mred/private/wx/cocoa/canvas.rkt @@ -216,6 +216,25 @@ (define-struct scroller (cocoa [range #:mutable] [page #:mutable])) (define scroll-width (tell #:type _CGFloat NSScroller scrollerWidth)) +;; Customizing by version is a terrible idea, but I can't figure +;; out the right way to get the content area of an NSComboBox +(define combo-dx (if (version-10.7-or-later?) + 2 + 2)) +(define combo-dy (if (version-10.7-or-later?) + 4 + 2)) +(define combo-dw (if (version-10.7-or-later?) + 24 + 22)) +(define combo-dh (if (version-10.7-or-later?) + 6 + 5)) +;; extra height shaved off drawing; we can't just increase +;; combo-dh, because that just creates a request for an even taller +;; combo box whose primitive drawing overlaps the focus ring +(define combo-backing-dh 1) + (define canvas% (canvas-mixin (class (canvas-autoscroll-mixin window%) @@ -313,7 +332,7 @@ (define/public (do-canvas-backing-flush ctx) (do-backing-flush this dc (tell NSGraphicsContext currentContext) - (if is-combo? 2 0) (if is-combo? 2 0))) + (if is-combo? combo-dx 0) (if is-combo? combo-dy 0))) ;; not used, because Cocoa canvas refreshes do not go through ;; the eventspace queue: @@ -426,8 +445,8 @@ (define/override (get-client-size xb yb) (super get-client-size xb yb) (when is-combo? - (set-box! xb (max 0 (- (unbox xb) 22))) - (set-box! yb (max 0 (- (unbox yb) 5))))) + (set-box! xb (max 0 (- (unbox xb) combo-dw))) + (set-box! yb (max 0 (- (unbox yb) combo-dh))))) (define/override (maybe-register-as-child parent on?) (register-as-child parent on?)) @@ -835,7 +854,9 @@ (void)) (define/public (get-backing-size xb yb) - (get-client-size xb yb)) + (get-client-size xb yb) + (when is-combo? + (set-box! yb (max 0 (- (unbox yb) combo-backing-dh))))) (define/override (get-cursor-width-delta) 0) diff --git a/pkgs/gui-pkgs/gui-test/tests/gracket/item.rkt b/pkgs/gui-pkgs/gui-test/tests/gracket/item.rkt index ef979ca037..0a779a55fb 100644 --- a/pkgs/gui-pkgs/gui-test/tests/gracket/item.rkt +++ b/pkgs/gui-pkgs/gui-test/tests/gracket/item.rkt @@ -192,7 +192,7 @@ (let ([d (this-expression-source-directory)]) (values (lambda (n) - (build-path (collection-path "icons") n)) + (collection-file-path n "icons")) (lambda (n) (build-path d n)))))