Re: SplitView subview autoresize
Re: SplitView subview autoresize
- Subject: Re: SplitView subview autoresize
- From: Timothy Larkin <email@hidden>
- Date: Mon, 03 Jun 2002 08:16:01 -0400
On 2002.06.02 22:18, "Paul A. Seligman" <email@hidden>
wrote:
>
>
I'm looking to either make sure that when the window is made smaller, the
>
subviews don't shrink below their min constraints, or barring that, that only
>
one subview resizes, while the others keep a constant height.
The solution is NSSplitView's delegate function
splitView:resizeSubviewsWithOldSize:
- (void)splitView:(NSSplitView *)sender
resizeSubviewsWithOldSize:(NSSize)oldSize
"Allows the delegate to specify custom sizing behavior for the subviews of
the NSSplitView. If the delegate implements this method,
splitView:resizeSubviewsWithOldSize: is invoked after the NSSplitView is
resized. The size of the NSSplitView before the user resized it is indicated
by oldSize; the subviews should be resized such that the sum of the sizes of
the subviews plus the sum of the thickness of the dividers equals the size
of the NSSplitView's new frame. You can get the thickness of a divider
through the dividerThickness method."
As an example, I have a split view with two subframes, tableView and
imageView. This implementation maintains the width of tableView as a
constant, and gives the remaining width to imageView, while keeping the
heights of the 2 views the same.
- (void)splitView:(NSSplitView *)sender
resizeSubviewsWithOldSize:(NSSize)oldSize
{
NSSize newSplitViewSize = [sender frame].size;
NSScrollView *imageScroll = [imageView enclosingScrollView];
NSSize imageScrollSize = [imageScroll frame].size;
NSScrollView *thumbScroll = [tableView enclosingScrollView];
NSSize thumbScrollSize = [thumbScroll frame].size;
imageScrollSize.width += newSplitViewSize.width - oldSize.width;
imageScrollSize.height += newSplitViewSize.height - oldSize.height;
[imageScroll setFrameSize:imageScrollSize];
thumbScrollSize.height += newSplitViewSize.height - oldSize.height;
[thumbScroll setFrameSize:thumbScrollSize];
}
--
Timothy Larkin
Abstract Tools
Caroline, NY
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.