Re: Find the height of the toolbar?
Re: Find the height of the toolbar?
- Subject: Re: Find the height of the toolbar?
- From: Andreas Mayer <email@hidden>
- Date: Sat, 17 Sep 2005 16:31:23 +0200
Am 17.09.2005 um 15:56 Uhr schrieb Aaron Wallis:
Im writing a preference window that contains multiple views to
allow 'tabbing' of the users preferences.
The user can change area via a simple click on the toolbar [like
the preference window in Mail and safari]
Similar to this?
http://www.harmless.de/cocoa.html#prefpane
So, my question is.
Is there a way to find out what the height of the toolbar is?
Just calculate the difference between the size of the old content
view and the window's frame (and then add the new view's size to get
the new window frame):
- (NSRect)frameForContentSize:(NSSize)contentSize
{
NSRect result;
NSRect oldWindowFrame = [[self window] frame];
NSRect oldContentViewFrame = [[[self window] contentView] frame];
result = oldWindowFrame;
float deltaX = (oldWindowFrame.size.width-
oldContentViewFrame.size.width);
float deltaY = (oldWindowFrame.size.height-
oldContentViewFrame.size.height);
result.size.width = contentSize.width+deltaX;
result.size.height = contentSize.height+deltaY;
result.origin.y += (oldWindowFrame.size.height-result.size.height);
return result;
}
- (void)changeContentView:(NSView *)contentView
{
NSRect newContentViewFrame = [contentView frame];
NSRect newWindowFrame = [self
frameForContentSize:newContentViewFrame.size];
[[self window] setContentView:contentView];
[[self window] setFrame:newWindowFrame display:YES animate:YES];
}
Andreas
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden