mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-23 06:51:44 +00:00
* Source/GSThemeMenu.m: Added implementation for
updateAllWindowsWithMenu:, updateMenu:forWindow:, altered implementation for setMenu:forWindow:, added private method _setMenu: to set the current menu on the window. * Source/GSWindowDecorationView.m: Changes to layout * Source/NSMenu.m: Only call the method updateAllWindowsWithMenu: when NSMenuInterfaceStyle = NSWindows95InterfaceStyle. * Source/NSMenuView.m: Change to -update so that it does not render the top bar of the menu if NSMenuInterfaceStyle = NSWindows95InterfaceStyle. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@31782 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
3817cc34d5
commit
cc3ce8896e
5 changed files with 79 additions and 35 deletions
13
ChangeLog
13
ChangeLog
|
@ -1,3 +1,16 @@
|
|||
2010-12-27 02:12-EST Gregory John Casamento <greg.casamento@gmail.com>
|
||||
|
||||
* Source/GSThemeMenu.m: Added implementation for
|
||||
updateAllWindowsWithMenu:, updateMenu:forWindow:, altered
|
||||
implementation for setMenu:forWindow:, added private method
|
||||
_setMenu: to set the current menu on the window.
|
||||
* Source/GSWindowDecorationView.m: Changes to layout
|
||||
* Source/NSMenu.m: Only call the method updateAllWindowsWithMenu:
|
||||
when NSMenuInterfaceStyle = NSWindows95InterfaceStyle.
|
||||
* Source/NSMenuView.m: Change to -update so that it does not
|
||||
render the top bar of the menu if NSMenuInterfaceStyle =
|
||||
NSWindows95InterfaceStyle.
|
||||
|
||||
2010-12-23 Fred Kiefer <FredKiefer@gmx.de>
|
||||
|
||||
* Source/NSEvent.m (-deltaX, -deltaY, -deltaZ): Don't raise an
|
||||
|
|
|
@ -27,9 +27,11 @@
|
|||
*/
|
||||
|
||||
#include <Foundation/NSString.h>
|
||||
#include <Foundation/NSArchiver.h>
|
||||
#include <AppKit/NSMenu.h>
|
||||
#include <AppKit/NSWindow.h>
|
||||
#include <AppKit/NSMenuView.h>
|
||||
#include <AppKit/NSApplication.h>
|
||||
|
||||
#include <GNUstepGUI/GSTheme.h>
|
||||
#include <GNUstepGUI/GSWindowDecorationView.h>
|
||||
|
@ -38,6 +40,7 @@
|
|||
|
||||
@interface NSWindow (Private)
|
||||
- (GSWindowDecorationView *) windowView;
|
||||
- (void) _setMenu: (NSMenu *)menu;
|
||||
@end
|
||||
|
||||
@implementation NSWindow (Private)
|
||||
|
@ -45,6 +48,11 @@
|
|||
{
|
||||
return _wv;
|
||||
}
|
||||
|
||||
- (void) _setMenu: (NSMenu *)menu
|
||||
{
|
||||
[super setMenu: menu];
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation GSTheme (Menu)
|
||||
|
@ -52,29 +60,26 @@
|
|||
forWindow: (NSWindow *)window
|
||||
{
|
||||
GSWindowDecorationView *wv = [window windowView];
|
||||
if ([window menu] != menu)
|
||||
if ([window menu] == nil && menu != nil)
|
||||
{
|
||||
NSMenuView *menuView;
|
||||
|
||||
/* Restore the old representation to its original menu after
|
||||
* removing it from the window. If we didn't do this, the menu
|
||||
* representation would be left without a partent view or
|
||||
* window to draw in.
|
||||
NSData *data = [NSArchiver archivedDataWithRootObject: menu]; // copy the view...
|
||||
NSMenu *newMenu = [NSUnarchiver unarchiveObjectWithData: data];
|
||||
|
||||
/*
|
||||
* Set the new menu
|
||||
*/
|
||||
menuView = [wv removeMenuView];
|
||||
[[window menu] setMenuRepresentation: menuView];
|
||||
[menuView sizeToFit];
|
||||
|
||||
/* Set the new menu, and transfer the new menu representation
|
||||
* to the window decoration view.
|
||||
[window _setMenu: newMenu];
|
||||
|
||||
/*
|
||||
* And transfer the new menu representation to the window decoration view.
|
||||
*/
|
||||
menuView = [menu menuRepresentation];
|
||||
NSMenuView *menuView = [newMenu menuRepresentation];
|
||||
if (menuView != nil)
|
||||
{
|
||||
[menu close];
|
||||
[menuView setHorizontal: YES];
|
||||
[menuView sizeToFit];
|
||||
[wv addMenuView: menuView];
|
||||
[menuView sizeToFit];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -123,12 +128,22 @@
|
|||
|
||||
- (void) updateMenu: (NSMenu *)menu forWindow: (NSWindow *)window
|
||||
{
|
||||
// default implementation of this method does nothing.
|
||||
[self setMenu: menu
|
||||
forWindow: window];
|
||||
}
|
||||
|
||||
- (void) updateAllWindowsWithMenu: (NSMenu *) menu
|
||||
{
|
||||
// default implementation of this method does nothing.
|
||||
NSEnumerator *en = [[NSApp windows] objectEnumerator];
|
||||
id o = nil;
|
||||
|
||||
while ((o = [en nextObject]) != nil)
|
||||
{
|
||||
if([o canBecomeMainWindow])
|
||||
{
|
||||
[self updateMenu: menu forWindow: o];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (BOOL) doesProcessEventsForPopUpMenu
|
||||
|
|
|
@ -254,13 +254,14 @@
|
|||
NSMenuView *menuView;
|
||||
GSTheme *theme = [GSTheme theme];
|
||||
float menuBarHeight = [theme menuHeightForWindow: _window];
|
||||
|
||||
NSRect menuRect =
|
||||
NSMakeRect(contentViewFrame.origin.x,
|
||||
NSMaxY(contentViewFrame) - menuBarHeight,
|
||||
contentViewFrame.size.width,
|
||||
menuBarHeight);
|
||||
|
||||
menuView = [[_window menu] menuRepresentation];
|
||||
[menuView setFrame: NSMakeRect(
|
||||
contentViewFrame.origin.x,
|
||||
NSMaxY(contentViewFrame) - menuBarHeight,
|
||||
contentViewFrame.size.width,
|
||||
menuBarHeight)];
|
||||
[menuView setFrame: menuRect];
|
||||
contentViewFrame.size.height -= menuBarHeight;
|
||||
}
|
||||
|
||||
|
@ -268,7 +269,7 @@
|
|||
{
|
||||
GSToolbarView *tv = [tb _toolbarView];
|
||||
float newToolbarViewHeight;
|
||||
|
||||
NSRect toolbarRect;
|
||||
// If the width changed we may need to recalculate the height
|
||||
if (contentViewFrame.size.width != [tv frame].size.width)
|
||||
{
|
||||
|
@ -277,10 +278,11 @@
|
|||
[tv _reload];
|
||||
}
|
||||
newToolbarViewHeight = [tv _heightFromLayout];
|
||||
[tv setFrame: NSMakeRect(contentViewFrame.origin.x,
|
||||
toolbarRect = NSMakeRect(contentViewFrame.origin.x,
|
||||
NSMaxY(contentViewFrame) - newToolbarViewHeight,
|
||||
contentViewFrame.size.width,
|
||||
newToolbarViewHeight)];
|
||||
newToolbarViewHeight);
|
||||
[tv setFrame: toolbarRect];
|
||||
contentViewFrame.size.height -= newToolbarViewHeight;
|
||||
}
|
||||
|
||||
|
@ -463,15 +465,15 @@
|
|||
float menubarHeight = [[GSTheme theme]
|
||||
menuHeightForWindow:
|
||||
_window];
|
||||
NSRect menuRect = NSMakeRect(contentRect.origin.x,
|
||||
NSMaxY(contentRect),
|
||||
contentRect.size.width,
|
||||
menubarHeight);
|
||||
hasMenu = YES;
|
||||
// Plug the menu view
|
||||
[menuView setFrame: NSMakeRect(
|
||||
contentRect.origin.x,
|
||||
NSMaxY(contentRect),
|
||||
contentRect.size.width,
|
||||
menubarHeight)];
|
||||
[menuView setFrame: menuRect];
|
||||
[self addSubview: menuView];
|
||||
|
||||
|
||||
[self changeWindowHeight: menubarHeight];
|
||||
}
|
||||
|
||||
|
|
|
@ -1757,7 +1757,11 @@ static BOOL menuBarVisible = YES;
|
|||
|
||||
- (void) applicationDidFinishLaunching:(NSNotification *)notification
|
||||
{
|
||||
[[GSTheme theme] updateAllWindowsWithMenu: [NSApp mainMenu]];
|
||||
if (NSInterfaceStyleForKey(@"NSMenuInterfaceStyle", nil) ==
|
||||
NSWindows95InterfaceStyle)
|
||||
{
|
||||
[[GSTheme theme] updateAllWindowsWithMenu: [NSApp mainMenu]];
|
||||
}
|
||||
[self _showTornOffMenuIfAny:notification];
|
||||
}
|
||||
|
||||
|
@ -2011,7 +2015,12 @@ static BOOL menuBarVisible = YES;
|
|||
{
|
||||
[self display];
|
||||
}
|
||||
[[GSTheme theme] updateAllWindowsWithMenu: self];
|
||||
|
||||
if (NSInterfaceStyleForKey(@"NSMenuInterfaceStyle", nil) ==
|
||||
NSWindows95InterfaceStyle)
|
||||
{
|
||||
[[GSTheme theme] updateAllWindowsWithMenu: self];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -594,7 +594,12 @@ static NSMapTable *viewInfo = 0;
|
|||
/*
|
||||
* Ensure that a title view exists only if needed.
|
||||
*/
|
||||
if (_attachedMenu == nil)
|
||||
if (NSInterfaceStyleForKey(@"NSMenuInterfaceStyle", nil) ==
|
||||
NSWindows95InterfaceStyle)
|
||||
{
|
||||
needTitleView = NO;
|
||||
}
|
||||
else if (_attachedMenu == nil)
|
||||
{
|
||||
needTitleView = NO;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue