Re: Splitview; keeping one sub-view at constant width when window resizes
Re: Splitview; keeping one sub-view at constant width when window resizes
- Subject: Re: Splitview; keeping one sub-view at constant width when window resizes
- From: Michael Rothwell <email@hidden>
- Date: Mon, 1 Dec 2003 16:13:33 -0500
Below is what I came up with; the key method is
resizeSubviewsWithOldSize. It controls how the subviews are tiled when
the parent frame (e.g., my application window) is resized. The
"constrain" methods are only for when the user adjusts the slider.
/
************************************************************************
*
* resizeSubviewsWithOldSize
************************************************************************
*/
- (void)splitView:(NSSplitView *)sender
resizeSubviewsWithOldSize:(NSSize)oldSize
{
float dividerThickness = [sender dividerThickness];
id sv1 = [[sender subviews] objectAtIndex:0];
id sv2 = [[sender subviews] objectAtIndex:1];
NSRect leftFrame = [sv1 frame];
NSRect rightFrame = [sv2 frame];
NSRect newFrame = [sender frame];
if (sender != m_SourceItemSplitView) return;
leftFrame.size.height = newFrame.size.height;
leftFrame.origin = NSMakePoint(0,0);
rightFrame.size.width = newFrame.size.width - leftFrame.size.width
- dividerThickness;
rightFrame.size.height = newFrame.size.height;
rightFrame.origin.x = leftFrame.size.width + dividerThickness;
[sv1 setFrame:leftFrame];
[sv2 setFrame:rightFrame];
};
/
************************************************************************
*
* constrainMinCoordinate
************************************************************************
*/
- (float)splitView:(NSSplitView *)sender
constrainMinCoordinate:(float)proposedMin
ofSubviewAt:(int)offset
{
NSLog(@"constrainMinCoordinate");
return 125;
};
/
************************************************************************
*
* constrainMaxCoordinate
************************************************************************
*/
- (float)splitView:(NSSplitView *)sender
constrainMaxCoordinate:(float)proposedMax
ofSubviewAt:(int)offset
{
NSLog(@"constrainMinCoordinate");
return 175;
};
On Dec 1, 2003, at 3:22 PM, Laurent Daudelin wrote:
>
>
Did you look at the splitview delegation methods?
_______________________________________________
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.