Just one delegate method seems to do it for me, but I wrote this quick so I 
might be overlooking something:

- (void)splitView:(NSSplitView *)sender 
resizeSubviewsWithOldSize:(NSSize)oldSize
{
        float desiredTopViewHeight = [_topView frame].size.height;
        [sender adjustSubviews];
        NSRect frameOne = [_topView frame];
        NSRect frameTwo = [_bottomView frame];
        
        frameOne.size.height = desiredTopViewHeight;
        frameTwo.size.height = [sender frame].size.height - 
desiredTopViewHeight - [sender dividerThickness];
        
        [_topView setFrame:frameOne];
        [_bottomView setFrame:frameTwo];
}

--Andy


 
On Tuesday, September 15, 2009, at 10:01AM, "Graham Cox" 
<graham....@bigpond.com> wrote:
>Ok, I'm beating my head on this one, wasting time I have better things  
>to spend it on. NSSplitView is a travesty, but we're stuck with it, so  
>I need to know the magic incantation of delegate methods and other  
>voodoo needed to implement the following for a split view with one  
>upper and one lower pane.
>
>1. When I drag the splitter directly, it moves allowing me to position  
>it where I want within the constrained min and max of the contained  
>views.
>2. When the window resizes I want the split to stay exactly where it  
>is relative to the top of the window. I do not want it to move  
>proportionally which seems to be the default. In other words the  
>window resize affects the bottom pane only, even though the top one  
>can be resized by the split. Whoever decided that was a sensible  
>behaviour for the default anyway?
>3. When the window is resized programatically as well as drag-resized,  
>2. needs to be true also.
>
>This seems so simple and obvious that I'm finding it very frustrating  
>that nothing I have tried works.
>
>What I have tried:
>
>- (BOOL)splitView:(NSSplitView *)splitView shouldAdjustSizeOfSubview: 
>(NSView *)subview
>
>I've tried returning NO for the times when the window is being  
>resized, assuming that this would effectively lock the split in place.  
>It's not even called except once when the view is instantiated. I'm  
>guessing then that this is meant to indicate the general disposition  
>of view splitting, called just once for all time. The docs are unclear  
>on this to say the least.
>
>- (CGFloat)splitView:(NSSplitView *)splitView constrainSplitPosition: 
>(CGFloat)proposedPosition ofSubviewAt:(NSInteger)dividerIndex
>
>This is at only called during manual dragging, so can't be used to  
>constrain the split during window resize, as even though the split is  
>being moved at that time, this isn't checked. In any case there's no  
>way to obtain the current split position at the start of the window  
>resize so I can return it to effect a "lock".
>
>- (void)splitViewWillResizeSubviews:(NSNotification *)aNotification
>
>This is called in both cases - dragging the split and resizing the  
>window. But what can I do with it? Since there's no way to get the  
>split position at the start of a resize I can't set it from here or  
>anywhere else.
>
>Any ideas what I can do?
>
>
>--Graham
>
>
>_______________________________________________
>
>Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>
>Please do not post admin requests or moderator comments to the list.
>Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
>Help/Unsubscribe/Update your Subscription:
>http://lists.apple.com/mailman/options/cocoa-dev/aglee%40mac.com
>
>This email sent to ag...@mac.com
>
>
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to