 |
 |
Uncollapsing split view
|
 |
|
 |
|
Grizzled Veteran
Join Date: Jun 2002
Status:
Offline
|
|
Hi guys,
I have a split view that I can collapse using this code:
Code:
- (void)splitViewDoubleClick:(OASplitView *)sender
{
NSView *topView = [[sender subviews] objectAtIndex:0];
NSView *botView = [[sender subviews] objectAtIndex:1];
NSRect lastTopFrame = [topView frame];
NSRect lastBotFrame = [botView frame];
if(lastBotFrame.size.height==0)
{
// UnCollapse here.
}
else
{
lastTopFrame = [topView frame];
lastBotFrame = [botView frame];
lastBotFrame.size.height -= lastTopFrame.size.height;
[topView setFrame: lastTopFrame];
lastBotFrame.size.height = 0;
[botView setFrame: lastBotFrame];
[sender adjustSubviews];
}
}
Doing this, when I double click the split view collapses. But, I am wondering how I would go about uncollapsing it? By uncollapsing I mean returning the split view back to its original size. Any idea how to get the size before it was double clicked?
Thanks,
Oliver
|
|
|
| |
|
|
|
 |
|
 |
|
Dedicated MacNNer
Join Date: Dec 2000
Location: sj ca
Status:
Offline
|
|
I think you just have to remember it yourself. In the collapse code, you'll have to store the
values lastTopFrame and lastBotFrame so you can retrieve them later. Cause otherwise they're gone forever.
Is anyone else annoyed that the code is turned into smileys?
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Jan 2003
Location: NYC
Status:
Offline
|
|
yeah, couldn't you just store lastBotFrame.size.height in a variable before you collapse it, and then when you uncollapse, just return it to that value. i've never actually tried to do this, but it seems like it should work.
edit: aren't the first two lines of the else statement redundant, because you already assign those values before the if statement?
|
|
|
| |
|
|
|
 |
|
 |
|
Grizzled Veteran
Join Date: Jun 2002
Status:
Offline
|
|
Originally posted by MaxPower2k3:
edit: aren't the first two lines of the else statement redundant, because you already assign those values before the if statement?
Oops, I edited the code here, and forgot about the else bit  . I'll try storing those values.
Thanks,
Oliver
|
|
|
| |
|
|
|
 |
|
 |
|
Grizzled Veteran
Join Date: Jun 2002
Status:
Offline
|
|
For anyone that needs this code in the future, here it is (thanks smeger):
Code:
- (void)splitViewDoubleClick:(OASplitView *)sender;
{
NSView *topView=[[sender subviews] objectAtIndex:0];
NSView *botView=[[sender subviews] objectAtIndex:1];
NSRect topFrame=[topView frame];
NSRect botFrame=[botView frame];
if( 0 == botFrame.size.height )
{
// Uncollpase split view here.
[topView setFrame: mLastTopFrame];
[botView setFrame: mLastBotFrame];
[sender adjustSubviews];
}
else
{
// Collapse split view.
mLastTopFrame = topFrame;
mLastBotFrame = botFrame;
NSRect splitViewFrame = [sender bounds];
[topView setFrame: NSMakeRect(0, 0, splitViewFrame.size.width, splitViewFrame.size.height - [sender dividerThickness])];
[botView setFrame: NSZeroRect];
[sender adjustSubviews];
}
}
In your header (.h) file, define both mLastTopFrame and mLastBotFrame as NSRect's. so NSRect mLastTopFrame; and NSRect mLastBotFrame;
Thanks,
Oliver
|
|
|
| |
|
|
|
 |
|
 |
|
Professional Poster
Join Date: Nov 2000
Location: Tasmania, Australia
Status:
Offline
|
|
Originally posted by qyn:
Is anyone else annoyed that the code is turned into smileys?
That's what the disable smilies button is for :) :D :p ;)
|
|
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |
|