From 7f764065e4d7a0801ecf13741054c6e7fa1e71eb Mon Sep 17 00:00:00 2001 From: "gtm.daemon" Date: Wed, 26 Aug 2009 16:30:24 +0000 Subject: [Author: thomasvl] Add an api for autosizing TextFields but keeping the width fixed. This needs a test in the future, but need it at the moment for chrome. R=stuartmorgan DELTA=18 (17 added, 1 deleted, 0 changed) --- AppKit/GTMUILocalizerAndLayoutTweaker.m | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'AppKit/GTMUILocalizerAndLayoutTweaker.m') diff --git a/AppKit/GTMUILocalizerAndLayoutTweaker.m b/AppKit/GTMUILocalizerAndLayoutTweaker.m index 4f94835..525b424 100644 --- a/AppKit/GTMUILocalizerAndLayoutTweaker.m +++ b/AppKit/GTMUILocalizerAndLayoutTweaker.m @@ -16,7 +16,6 @@ // the License. // -#import "GTMDefines.h" #import "GTMUILocalizerAndLayoutTweaker.h" #import "GTMUILocalizer.h" @@ -91,6 +90,15 @@ static BOOL IsRightAnchored(NSView *view); return SizeToFit(view, NSZeroPoint); } ++ (NSUInteger)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; +} + @end @implementation GTMWidthBasedTweaker -- cgit v1.2.3