aboutsummaryrefslogtreecommitdiff
path: root/AppKit/GTMUILocalizerAndLayoutTweaker.m
diff options
context:
space:
mode:
authorGravatar gtm.daemon <gtm.daemon@7dc7ac4e-7543-0410-b95c-c1676fc8e2a3>2009-08-27 16:45:23 +0000
committerGravatar gtm.daemon <gtm.daemon@7dc7ac4e-7543-0410-b95c-c1676fc8e2a3>2009-08-27 16:45:23 +0000
commit4203884610ea0e0621aafdf5cced614447dbcd5e (patch)
tree05a08f840ba265cc01fc252e5c6e6db3d0731fa2 /AppKit/GTMUILocalizerAndLayoutTweaker.m
parent66fc63df47cd6714ca8ff034ae3f54de5ef58ea9 (diff)
[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)
Diffstat (limited to 'AppKit/GTMUILocalizerAndLayoutTweaker.m')
-rw-r--r--AppKit/GTMUILocalizerAndLayoutTweaker.m9
1 files changed, 4 insertions, 5 deletions
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