From e1c938bc73510d64b908408bf404eb10a419001e Mon Sep 17 00:00:00 2001 From: "gtm.daemon" Date: Fri, 30 Oct 2009 18:35:16 +0000 Subject: [Author: thomasvl] Add a helper for doing view resizing without resizing subviews. Fix the fixed width call to not change the width. Update the unittest to make sure the fixed width call doesn't change the width. R=stuartmorgan,dmaclach DELTA=41 (30 added, 0 deleted, 11 changed) --- AppKit/GTMUILocalizerAndLayoutTweaker.m | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'AppKit/GTMUILocalizerAndLayoutTweaker.m') diff --git a/AppKit/GTMUILocalizerAndLayoutTweaker.m b/AppKit/GTMUILocalizerAndLayoutTweaker.m index dca167a..382871c 100644 --- a/AppKit/GTMUILocalizerAndLayoutTweaker.m +++ b/AppKit/GTMUILocalizerAndLayoutTweaker.m @@ -223,6 +223,7 @@ static BOOL IsRightAnchored(NSView *view); NSRect initialFrame = [textField frame]; NSRect sizeRect = NSMakeRect(0, 0, NSWidth(initialFrame), CGFLOAT_MAX); NSSize newSize = [[textField cell] cellSizeForBounds:sizeRect]; + newSize.width = NSWidth(initialFrame); [textField setFrameSize:newSize]; return newSize.height - NSHeight(initialFrame); } @@ -278,6 +279,25 @@ static BOOL IsRightAnchored(NSView *view); } } ++ (void)resizeViewWithoutAutoResizingSubViews:(NSView*)view + delta:(NSSize)delta { + // Clear autosizesSubviews (saving the state). + BOOL autoresizesSubviews = [view autoresizesSubviews]; + if (autoresizesSubviews) { + [view setAutoresizesSubviews:NO]; + } + + NSRect rect = [view frame]; + rect.size.width += delta.width; + rect.size.height += delta.height; + [view setFrame:rect]; + + // Restore autosizesSubviews. + if (autoresizesSubviews) { + [view setAutoresizesSubviews:YES]; + } +} + @end @implementation GTMWidthBasedTweaker -- cgit v1.2.3