mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-31 17:50:47 +00:00
Merge original in-window menu branch.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@33924 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
92b44ffa68
commit
0de761d88e
4 changed files with 58 additions and 49 deletions
|
@ -1,6 +1,12 @@
|
||||||
|
2011-10-01 Fred Kiefer <FredKiefer@gmx.de>
|
||||||
|
|
||||||
|
* Source/GSThemeMenu.m,
|
||||||
|
* Source/GSThemeMenu.m,
|
||||||
|
* Source/GSWindowDecorationView.m: Rewrite of the in-window menu handling.
|
||||||
|
|
||||||
2011-09-12 German Arias <german@xelalug.org>
|
2011-09-12 German Arias <german@xelalug.org>
|
||||||
|
|
||||||
* Source/GSThemeMenu.m (-setMenu:forWindow:): Improvements to
|
* Source/GSThemeMenu.m (-setMenu:forWindow:): Improvements to
|
||||||
menu in window.
|
menu in window.
|
||||||
|
|
||||||
2011-09-12 Fred Kiefer <FredKiefer@gmx.de>
|
2011-09-12 Fred Kiefer <FredKiefer@gmx.de>
|
||||||
|
|
|
@ -61,52 +61,29 @@
|
||||||
forWindow: (NSWindow *)window
|
forWindow: (NSWindow *)window
|
||||||
{
|
{
|
||||||
GSWindowDecorationView *wv = [window windowView];
|
GSWindowDecorationView *wv = [window windowView];
|
||||||
if ([window menu] == nil && menu != nil)
|
|
||||||
{
|
|
||||||
// NSData *data = [NSArchiver archivedDataWithRootObject: menu]; //
|
|
||||||
NSMenu *newMenu = [menu copy];
|
|
||||||
NSMenuView *menuView = nil;
|
|
||||||
|
|
||||||
/*
|
// protect against stupid calls from updateAllWindowsWithMenu:
|
||||||
* Set the new menu
|
if ([window menu] == menu)
|
||||||
*/
|
return;
|
||||||
[window _setMenu: newMenu];
|
|
||||||
|
|
||||||
/*
|
// Prevent recursion
|
||||||
* And transfer the new menu representation to the window decoration view.
|
[window _setMenu: menu];
|
||||||
*/
|
|
||||||
menuView = [newMenu menuRepresentation];
|
// Remove any possible old menu view
|
||||||
if (menuView != nil)
|
[wv removeMenuView];
|
||||||
{
|
|
||||||
[menu close];
|
//NSLog(@"Adding menu %@ to window %@", menu, window);
|
||||||
[menuView setHorizontal: YES];
|
if (menu != nil)
|
||||||
[wv addMenuView: menuView];
|
{
|
||||||
[menuView sizeToFit];
|
NSMenuView *menuView = [[NSMenuView alloc] initWithFrame: NSZeroRect];
|
||||||
}
|
|
||||||
}
|
[menuView setMenu: menu];
|
||||||
else
|
[menuView setHorizontal: YES];
|
||||||
{
|
[menuView setInterfaceStyle: NSWindows95InterfaceStyle];
|
||||||
/* We copy "Windows" menu, since this can't be updated
|
[wv addMenuView: menuView];
|
||||||
* with calling -update:. However, with this way if the
|
[menuView sizeToFit];
|
||||||
* menus have a different name this will not work (for
|
RELEASE(menuView);
|
||||||
* example "Window" instead "Windows"). So the programmer
|
}
|
||||||
* must be careful here.
|
|
||||||
*/
|
|
||||||
|
|
||||||
NSMenuItem *windowsItem, *oldWindowsItem;
|
|
||||||
NSMenu *newWindowsMenu;
|
|
||||||
|
|
||||||
windowsItem = [menu itemWithTitle: _(@"Windows")];
|
|
||||||
if (windowsItem != nil && [windowsItem hasSubmenu])
|
|
||||||
{
|
|
||||||
//Get the new "Windows" menu
|
|
||||||
newWindowsMenu = [[windowsItem submenu] copy];
|
|
||||||
|
|
||||||
//Set this menu into the menu in this window
|
|
||||||
oldWindowsItem = [[window menu] itemWithTitle: _(@"Windows")];
|
|
||||||
[oldWindowsItem setSubmenu: newWindowsMenu];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) rightMouseDisplay: (NSMenu *)menu
|
- (void) rightMouseDisplay: (NSMenu *)menu
|
||||||
|
|
|
@ -294,7 +294,7 @@ static inline NSRect RectWithSizeScaledByFactor(NSRect aRect, CGFloat factor)
|
||||||
|
|
||||||
if (hasMenu)
|
if (hasMenu)
|
||||||
{
|
{
|
||||||
NSMenuView *menuView;
|
NSMenuView *menuView = nil;
|
||||||
GSTheme *theme = [GSTheme theme];
|
GSTheme *theme = [GSTheme theme];
|
||||||
float menuBarHeight = [theme menuHeightForWindow: _window];
|
float menuBarHeight = [theme menuHeightForWindow: _window];
|
||||||
NSRect menuRect =
|
NSRect menuRect =
|
||||||
|
@ -302,8 +302,17 @@ static inline NSRect RectWithSizeScaledByFactor(NSRect aRect, CGFloat factor)
|
||||||
(NSMaxY(contentRect) + 1) - menuBarHeight,
|
(NSMaxY(contentRect) + 1) - menuBarHeight,
|
||||||
contentViewFrame.size.width,
|
contentViewFrame.size.width,
|
||||||
menuBarHeight);
|
menuBarHeight);
|
||||||
|
NSEnumerator *e = [[self subviews] objectEnumerator];
|
||||||
menuView = [[_window menu] menuRepresentation];
|
NSView *v;
|
||||||
|
|
||||||
|
while ((v = [e nextObject]) != nil)
|
||||||
|
{
|
||||||
|
if ([v isKindOfClass: [NSMenuView class]] == YES)
|
||||||
|
{
|
||||||
|
menuView = (NSMenuView *)v;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
[menuView setFrame: menuRect];
|
[menuView setFrame: menuRect];
|
||||||
contentViewFrame.size.height -= menuBarHeight;
|
contentViewFrame.size.height -= menuBarHeight;
|
||||||
}
|
}
|
||||||
|
|
|
@ -86,6 +86,17 @@ static NSMapTable *viewInfo = 0;
|
||||||
/* A menu's title is an instance of this class */
|
/* A menu's title is an instance of this class */
|
||||||
@class NSButton;
|
@class NSButton;
|
||||||
|
|
||||||
|
@interface NSMenu (Private)
|
||||||
|
- (void) _attachMenu: (NSMenu*)aMenu;
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation NSMenu (Private)
|
||||||
|
- (void) _attachMenu: (NSMenu*)aMenu
|
||||||
|
{
|
||||||
|
_attachedMenu = aMenu;
|
||||||
|
}
|
||||||
|
@end
|
||||||
|
|
||||||
@interface NSMenuView (Private)
|
@interface NSMenuView (Private)
|
||||||
- (BOOL) _rootIsHorizontal: (BOOL*)isAppMenu;
|
- (BOOL) _rootIsHorizontal: (BOOL*)isAppMenu;
|
||||||
@end
|
@end
|
||||||
|
@ -548,6 +559,8 @@ static NSMapTable *viewInfo = 0;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
[attachedMenu close];
|
[attachedMenu close];
|
||||||
|
// Unselect the active item
|
||||||
|
[self setHighlightedItemIndex: -1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -577,7 +590,11 @@ static NSMapTable *viewInfo = 0;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
NSDebugLLog (@"NSMenu", @"Will open normal: %@", attachableMenu);
|
NSDebugLLog (@"NSMenu", @"Will open normal: %@", attachableMenu);
|
||||||
[attachableMenu display];
|
// FIXME: Only resize when needed
|
||||||
|
[attachableMenu sizeToFit];
|
||||||
|
[[attachableMenu window] setFrameOrigin: [self locationForSubmenu: attachableMenu]];
|
||||||
|
[_attachedMenu _attachMenu: attachableMenu];
|
||||||
|
[[attachableMenu window] orderFrontRegardless];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue