aboutsummaryrefslogtreecommitdiff
path: root/AppKit/GTMUILocalizerAndLayoutTweaker.m
diff options
context:
space:
mode:
authorGravatar gtm.daemon <gtm.daemon@7dc7ac4e-7543-0410-b95c-c1676fc8e2a3>2009-10-30 18:35:16 +0000
committerGravatar gtm.daemon <gtm.daemon@7dc7ac4e-7543-0410-b95c-c1676fc8e2a3>2009-10-30 18:35:16 +0000
commite1c938bc73510d64b908408bf404eb10a419001e (patch)
tree0001b2d01f045c33f33fff7051fceddcc00971a4 /AppKit/GTMUILocalizerAndLayoutTweaker.m
parente1cbd4dc301f0f7e0a0fd7616a958bfaeb615b67 (diff)
[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)
Diffstat (limited to 'AppKit/GTMUILocalizerAndLayoutTweaker.m')
-rw-r--r--AppKit/GTMUILocalizerAndLayoutTweaker.m20
1 files changed, 20 insertions, 0 deletions
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