From e5a4ab5b40e6f07ddc562fa5b49491f3da5dd4ad Mon Sep 17 00:00:00 2001 From: rfm Date: Sun, 25 Jan 2009 18:28:20 +0000 Subject: [PATCH] keep main menu available when using micrtosoft style git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@27692 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 7 ++++++ Source/GSWindowDecorationView.m | 1 + Source/NSMenu.m | 39 +++++++++++++++++++++++++++++---- Source/NSWindow.m | 9 ++++++-- 4 files changed, 50 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index f9d1aa1d0..d6b3f1b58 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2009-01-25 Richard Frith-Macdonald + + * Source/NSMenu.m: Keep the main menu in the main window (or visible + if there is no main menu) when using microsoft style menus. + * Source/NSWindow.m: If the main windows closes and it contains + the main menu, unset the menu. + 2009-01-25 11:51-EST Gregory John Casamento * Source/NSMenuView.m: Return from the trackWithEvent: method diff --git a/Source/GSWindowDecorationView.m b/Source/GSWindowDecorationView.m index 4c1fe410a..ba40b5b7e 100644 --- a/Source/GSWindowDecorationView.m +++ b/Source/GSWindowDecorationView.m @@ -438,6 +438,7 @@ return AUTORELEASE(v); } } + return nil; } @end diff --git a/Source/NSMenu.m b/Source/NSMenu.m index 8d013b738..918392e1f 100644 --- a/Source/NSMenu.m +++ b/Source/NSMenu.m @@ -942,6 +942,31 @@ static BOOL menuBarVisible = YES; - (void) update { + if (self == [NSApp mainMenu]) + { + /* For microsoft style menus, we attempt to notice that we have + * a main window, and make sure that the menu appears in it. + */ + if (NSInterfaceStyleForKey(@"NSMenuInterfaceStyle", nil) == + NSWindows95InterfaceStyle) + { + NSWindow *w = [NSApp mainWindow]; + + if (w == nil) + { + /* Make sure we are set up properly and displayed. + */ + if ([_aWindow isVisible] == NO) + { + [self setMain: YES]; + } + } + else if ([w menu] != self) + { + [w setMenu: self]; + } + } + } if (_delegate) { if ([_delegate respondsToSelector:@selector(menuNeedsUpdate:)]) @@ -1186,10 +1211,10 @@ static BOOL menuBarVisible = YES; - (void) setDelegate: (id)delegate { - _delegate=delegate; + _delegate = delegate; } -- (float)menuBarHeight +- (float) menuBarHeight { // FIXME return [NSMenuView menuBarHeight]; @@ -1683,7 +1708,6 @@ static BOOL menuBarVisible = YES; { NSMenu *sub = [self attachedMenu]; - if (_menu.transient) { NSDebugLLog (@"NSMenu", @"We should not close ordinary menu while transient version is still open"); @@ -1784,15 +1808,22 @@ static BOOL menuBarVisible = YES; RELEASE(newRep); if (newStyle == NSWindows95InterfaceStyle) { + /* Put menu in the main window for microsoft style. + */ [[NSApp mainWindow] setMenu: self]; } else if ([[NSApp mainWindow] menu] == self) { + /* Remove the menu from the main window. + */ [[NSApp mainWindow] setMenu: nil]; } } - if (newStyle != NSWindows95InterfaceStyle) + /* Adjust the menu window to suit the menu view unless the menu + * is being displayed in the application main window. + */ + if ([[NSApp mainWindow] menu] != self) { [[self window] setTitle: [[NSProcessInfo processInfo] processName]]; [[self window] setLevel: NSMainMenuWindowLevel]; diff --git a/Source/NSWindow.m b/Source/NSWindow.m index 8bdd3698a..ee160edad 100644 --- a/Source/NSWindow.m +++ b/Source/NSWindow.m @@ -1775,6 +1775,12 @@ many times. { [_wv setInputState: GSTitleBarNormal]; } + if ([self menu] == [NSApp mainMenu]) + { + /* This window contains the main menu ... remove it. + */ + [self setMenu: nil]; + } [nc postNotificationName: NSWindowDidResignMainNotification object: self]; } } @@ -2645,9 +2651,7 @@ resetCursorRectsForView(NSView *theView) _f.has_opened = NO; [NSApp removeWindowsItem: self]; [self orderOut: self]; - RELEASE(pool); - _f.has_closed = YES; RELEASE(self); } @@ -5175,6 +5179,7 @@ current key view.
*/ menuView = [_wv removeMenuView]; [[self menu] setMenuRepresentation: menuView]; + [menuView sizeToFit]; /* Set the new menu, and transfer the new menu representation * to the window decoration view.