Update menu code and set menu on window creation.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@29373 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Gregory John Casamento 2010-01-23 23:41:07 +00:00
parent f59546bebf
commit 15de26b03c
5 changed files with 49 additions and 17 deletions

View file

@ -1,3 +1,13 @@
2010-01-23 18:41-EST Gregory John Casamento <greg.casamento@gmail.com>
* Headers/Additions/GNUstepGUI/GSTheme.h: Add updateMenu:forWindow:
* Source/GSThemeMenu.m: Add default implementation of new method.
* Source/GSWindowDecorationView.m: Add code to use value
returned from menuHeightForWindow:.
* Source/NSWindow.m: initWithContentRect:.. call setMenu: here so that
the menu is added immediately when the window is created. Also
add code to update menus.
2010-01-20 German Arias <german@xelalug.org>
* Resources/Spanish.lproj/Localizable.strings: Added translation to "Opacity".

View file

@ -984,10 +984,10 @@ withRepeatedImage: (NSImage*)image
@end
@interface GSTheme (Menus)
- (void) setMenu: (NSMenu *)menu
forWindow: (NSWindow *)window;
- (void) processCommand: (void *)context;
- (void) setMenu: (NSMenu *)menu forWindow: (NSWindow *)window;
- (void) processCommand: (void *)context;
- (float) menuHeightForWindow: (NSWindow *)window;
- (void) updateMenu: (NSMenu *)menu forWindow: (NSWindow *)window;
@end
#endif /* OS_API_VERSION */

View file

@ -89,5 +89,10 @@
{
return [NSMenuView menuBarHeight];
}
- (void) updateMenu: (NSMenu *)menu forWindow: (NSWindow *)window
{
// default implementation of this method does nothing.
}
@end

View file

@ -139,8 +139,8 @@
if ([_window menu] != nil)
{
float menubarHeight = [[GSTheme theme]
menuHeightForWindow:
[self window]];
menuHeightForWindow:
_window];
content.size.height -= menubarHeight;
}
@ -164,7 +164,7 @@
{
float menubarHeight = [[GSTheme theme]
menuHeightForWindow:
[self window]];
_window];
aRect.size.height += menubarHeight;
}
@ -229,7 +229,7 @@
NSRect contentViewFrame;
NSToolbar *tb = [_window toolbar];
NSRect frame = [window frame];
frame.origin = NSZeroPoint;
contentViewFrame = [isa contentRectForFrameRect: frame
styleMask: [window styleMask]];
@ -237,9 +237,8 @@
if (hasMenu)
{
NSMenuView *menuView;
float menuBarHeight = [[GSTheme theme]
menuHeightForWindow:
[self window]];
GSTheme *theme = [GSTheme theme];
float menuBarHeight = [theme menuHeightForWindow: _window];
menuView = [[_window menu] menuRepresentation];
[menuView setFrame: NSMakeRect(
@ -390,10 +389,7 @@
contentYOrigin = NSMaxY(contentRect);
if(hasMenu)
{
float menuBarHeight = [[GSTheme theme]
menuHeightForWindow:
[self window]];
float menuBarHeight = [[GSTheme theme] menuHeightForWindow: _window];
contentYOrigin -= menuBarHeight;
}
@ -446,7 +442,7 @@
{
float menubarHeight = [[GSTheme theme]
menuHeightForWindow:
[self window]];
_window];
hasMenu = YES;
// Plug the menu view
[menuView setFrame: NSMakeRect(
@ -465,7 +461,7 @@
NSView *v;
float menubarHeight = [[GSTheme theme]
menuHeightForWindow:
[self window]];
_window];
while ((v = [e nextObject]) != nil)
{

View file

@ -983,6 +983,8 @@ many times.
screen: (NSScreen*)aScreen
{
NSRect cframe;
NSInterfaceStyle style =
NSInterfaceStyleForKey(@"NSMenuInterfaceStyle", nil);
NSAssert(NSApp,
@"The shared NSApplication instance must be created before windows "
@ -1056,6 +1058,14 @@ many times.
name: NSColorListChangedNotification
object: nil];
if (style == NSWindows95InterfaceStyle)
{
if([self canBecomeMainWindow])
{
[self setMenu: [NSApp mainMenu]];
}
}
NSDebugLLog(@"NSWindow", @"NSWindow end of init\n");
return self;
}
@ -2300,8 +2310,19 @@ many times.
}
}
- (void) update
- (void) _menuUpdate
{
NSInterfaceStyle style =
NSInterfaceStyleForKey(@"NSMenuInterfaceStyle", nil);
if(style == NSWindows95InterfaceStyle)
{
//[[GSTheme theme] updateMenu: [self menu] forWindow: self];
}
}
- (void) update
{
[self _menuUpdate];
[nc postNotificationName: NSWindowDidUpdateNotification object: self];
}