From 9ebf8b15cfb105864e97a0e8b005de8e6e5d5c42 Mon Sep 17 00:00:00 2001 From: "gtm.daemon" Date: Wed, 16 Sep 2009 16:30:26 +0000 Subject: [Author: thomasvl] add a helper for resizing a window without the subview resizing. R=stuartmorgan DELTA=32 (32 added, 0 deleted, 0 changed) --- AppKit/GTMUILocalizerAndLayoutTweaker.m | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'AppKit/GTMUILocalizerAndLayoutTweaker.m') diff --git a/AppKit/GTMUILocalizerAndLayoutTweaker.m b/AppKit/GTMUILocalizerAndLayoutTweaker.m index cae8a02..c79bfa1 100644 --- a/AppKit/GTMUILocalizerAndLayoutTweaker.m +++ b/AppKit/GTMUILocalizerAndLayoutTweaker.m @@ -104,6 +104,30 @@ static BOOL IsRightAnchored(NSView *view); return newSize.height - NSHeight(initialFrame); } ++ (void)resizeWindowWithoutAutoResizingSubViews:(NSWindow*)window + delta:(NSSize)delta { + NSView *contentView = [window contentView]; + + // Clear autosizesSubviews (saving the state). + BOOL autoresizesSubviews = [contentView autoresizesSubviews]; + if (autoresizesSubviews) { + [contentView setAutoresizesSubviews:NO]; + } + + NSRect rect = [window frame]; + rect.size.width += delta.width; + rect.size.height += delta.height; + [window setFrame:rect display:NO]; + // For some reason the content view is resizing, but some times not adjusting + // its origin, so correct it manually. + [contentView setFrameOrigin:NSMakePoint(0, 0)]; + + // Restore autosizesSubviews. + if (autoresizesSubviews) { + [contentView setAutoresizesSubviews:YES]; + } +} + @end @implementation GTMWidthBasedTweaker -- cgit v1.2.3