Properly convert window frames to content view frames and back. Don't assume that the position of the content view is (0,0).

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@19688 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Alexander Malmberg 2004-07-06 23:31:57 +00:00
parent 7ac30eed06
commit e2178bf8f1
2 changed files with 36 additions and 15 deletions

View file

@ -1,3 +1,10 @@
2004-07-07 01:23 Alexander Malmberg <alexander@malmberg.org>
* Source/NSWindow+Toolbar.m: Properly convert window frames to
content view frames and back.
(-_toggleToolbarViewWithDisplay:): Move the old content view to the
origin of the new content view.
2004-07-06 22:15 Alexander Malmberg <alexander@malmberg.org>
* Headers/Additions/GNUstepGUI/GSDisplayServer.h: Add

View file

@ -72,7 +72,10 @@
{
if (!isVisible) // In the case : not visible when the method has been called
{
[toolbarView setFrameSize: NSMakeSize([self frame].size.width, 100)];
[toolbarView setFrameSize:
NSMakeSize([NSWindow
contentRectForFrameRect: [self frame]
styleMask: [self styleMask]].size.width, 100)];
// -toogleToolbarViewWithDisplay: will reset the toolbarView frame
[toolbarView _reload]; // Will recalculate the layout
}
@ -190,7 +193,8 @@
if (toolbarView == nil)
{
toolbarView = [[GSToolbarView alloc] initWithFrame: NSMakeRect(0, 0,
[self frame].size.width, 100)];
[NSWindow contentRectForFrameRect: [self frame]
styleMask: [self styleMask]].size.width, 100)];
// _toggleToolbarView:display: method will set the toolbar view to the right
// frame
[toolbarView setAutoresizingMask: NSViewWidthSizable | NSViewMinYMargin];
@ -258,7 +262,9 @@
NSView *contentViewWithoutToolbar;
// Frame
NSRect windowFrame = [self frame];
NSRect windowContentFrame
= [NSWindow contentRectForFrameRect: [self frame]
styleMask: [self styleMask]];
if ([toolbarView superview] == nil)
{
@ -274,16 +280,18 @@
[[NSView alloc] initWithFrame: [_contentView frame]]];
// Resize the window
[self setFrame: NSMakeRect(
windowFrame.origin.x,
windowFrame.origin.y - newToolbarViewHeight,
windowFrame.size.width,
windowFrame.size.height + newToolbarViewHeight) display: NO];
windowContentFrame.origin.y -= newToolbarViewHeight;
windowContentFrame.size.height += newToolbarViewHeight;
[self setFrame: [NSWindow frameRectForContentRect: windowContentFrame
styleMask: [self styleMask]]
display: NO];
// Plug the toolbar view
contentViewWithoutToolbarFrame = [contentViewWithoutToolbar frame];
[toolbarView setFrame: NSMakeRect(
0,
@ -294,7 +302,13 @@
[_contentView addSubview: toolbarView];
// Insert the previous content view
/* We want contentViewWithoutToolbarFrame at the origin of our new
content view. There's no guarantee that the old position was (0,0). */
contentViewWithoutToolbarFrame.origin.x = 0;
contentViewWithoutToolbarFrame.origin.y = 0;
[contentViewWithoutToolbar setFrame: contentViewWithoutToolbarFrame];
[_contentView addSubview: contentViewWithoutToolbar];
RELEASE(contentViewWithoutToolbar);
}
@ -312,11 +326,11 @@
[contentViewWithoutToolbar setAutoresizingMask: NSViewMaxYMargin];
[self setFrame: NSMakeRect(
windowFrame.origin.x,
windowFrame.origin.y + toolbarViewHeight,
windowFrame.size.width,
windowFrame.size.height - toolbarViewHeight) display: NO];
windowContentFrame.origin.y += toolbarViewHeight;
windowContentFrame.size.height -= toolbarViewHeight;
[self setFrame: [NSWindow frameRectForContentRect: windowContentFrame
styleMask: [self styleMask]]
display: NO];
[contentViewWithoutToolbar setAutoresizingMask: NSViewWidthSizable
| NSViewHeightSizable];