From 4203884610ea0e0621aafdf5cced614447dbcd5e Mon Sep 17 00:00:00 2001 From: "gtm.daemon" Date: Thu, 27 Aug 2009 16:45:23 +0000 Subject: [Author: thomasvl] Update the textfield fixed width code to work with 10.5 (vs. 10.4 due to a change on apple's end). Add a unittest that captures the edge case. R=stuartmorgan,dmaclach DELTA=72 (66 added, 1 deleted, 5 changed) --- AppKit/GTMUILocalizerAndLayoutTweaker.m | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'AppKit/GTMUILocalizerAndLayoutTweaker.m') diff --git a/AppKit/GTMUILocalizerAndLayoutTweaker.m b/AppKit/GTMUILocalizerAndLayoutTweaker.m index d7494b2..1b5d8aa 100644 --- a/AppKit/GTMUILocalizerAndLayoutTweaker.m +++ b/AppKit/GTMUILocalizerAndLayoutTweaker.m @@ -92,11 +92,10 @@ static BOOL IsRightAnchored(NSView *view); + (CGFloat)sizeToFitFixedWidthTextField:(NSTextField *)textField { NSRect initialFrame = [textField frame]; - NSSize newSize = [[textField cell] cellSizeForBounds:initialFrame]; - NSRect newFrame = initialFrame; - newFrame.size.height = newSize.height; - [textField setFrame:newFrame]; - return initialFrame.size.height - newSize.height; + NSRect sizeRect = NSMakeRect(0, 0, NSWidth(initialFrame), CGFLOAT_MAX); + NSSize newSize = [[textField cell] cellSizeForBounds:sizeRect]; + [textField setFrameSize:newSize]; + return newSize.height - NSHeight(initialFrame); } @end -- cgit v1.2.3