From a92da16be5f972db99439bb4c6b3e507bb4ff547 Mon Sep 17 00:00:00 2001 From: gcasa Date: Sun, 27 Apr 2008 22:44:12 +0000 Subject: [PATCH] * Source/NSWindow.m: Change to correct issue with NSWindow placement when toolbar is present. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@26476 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 5 +++++ Source/NSWindow.m | 47 +++++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 48 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index dc44a8cca..fd9d93ec9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2008-04-27 18:42-EDT Gregory John Casamento + + * Source/NSWindow.m: Change to correct issue with NSWindow placement + when toolbar is present. + 2008-04-25 18:16-EDT Gregory John Casamento * Source/GSNibTemplates.m: Correct [GSNibTemplates deferredWindows] to diff --git a/Source/NSWindow.m b/Source/NSWindow.m index fbb24c066..5a8a63752 100644 --- a/Source/NSWindow.m +++ b/Source/NSWindow.m @@ -106,6 +106,24 @@ BOOL GSViewAcceptsDrag(NSView *v, id dragInfo); - (void) _viewWillMoveToWindow: (NSWindow*)newWindow; @end +@interface NSScreen (PrivateMethods) +- (id) _initWithScreenNumber: (int)screen; +@end + +/* + * FIXME: Not sure if I should be exposing this here, but it seems to be the only way + * to fix the window frame save issue when a toolbar is present. + */ +@interface NSWindow (ToolbarPrivate) +- (id) toolbar; +- (NSView *)contentViewWithoutToolbar; +@end + +@interface NSToolbar (GNUstepPrivate) +- (GSToolbarView *) _toolbarView; +@end +// FIXME: END (GJC) + /* * Category for internal methods (for use only within the NSWindow class itself * or with other AppKit classes. @@ -1001,8 +1019,9 @@ many times. // Get the properties for the underlying window winNum = [srv nativeWindow: windowRef : &contentRect : &bufferingType : &aStyle : &screen]; - // FIXME: Get the screen for the right screen number. - aScreen = nil; + + // Get the screen for the right screen number. + aScreen = [[NSScreen alloc] _initWithScreenNumber: screen]; // Set up a NSWindow with the same properties self = [self initWithContentRect: contentRect @@ -1041,13 +1060,11 @@ many times. - (NSRect) contentRectForFrameRect: (NSRect)frameRect { - // FIXME return [isa contentRectForFrameRect: frameRect styleMask: _styleMask]; } - (NSRect) frameRectForContentRect: (NSRect)contentRect { - // FIXME return [isa frameRectForContentRect: contentRect styleMask: _styleMask]; } @@ -4478,6 +4495,28 @@ current key view.
fRect = _frame; + /* + * FIXME: This may not be such an elegant solution, but it works. + * I need to find a better way to handle this, maybe in the window + * decoration view could handle these calculations. + */ + if([self toolbar] != nil) + { + NSView *tbview = [[self toolbar] _toolbarView]; + NSRect tbframe = [tbview frame]; + if([tbview superview] != nil) + { + NSRect r = [[self contentViewWithoutToolbar] frame]; + r = [NSWindow frameRectForContentRect: r + styleMask: _styleMask]; + + // copy w/h + fRect.size.width = r.size.width; + fRect.size.height = r.size.height; + fRect.origin.y += tbframe.size.height; + } + } + /* * The screen rectangle should gives the area of the screen in which * the window could be placed (ie a rectangle excluding the dock).