mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-31 20:00:48 +00:00
Fix bug #15631 and improve submenus in horizontal menus.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@22438 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
99c7295ae9
commit
ce5e3f0368
2 changed files with 48 additions and 22 deletions
|
@ -1,3 +1,9 @@
|
||||||
|
2006-02-05 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
|
* Source/NSMenuView.m: ([-sizeToFit]) Fix bug #15631
|
||||||
|
([-locationForSubmenu:]) for horizontal root menus, make successive
|
||||||
|
submenus be positioned with top left corner next to item in parent.
|
||||||
|
|
||||||
2006-02-04 Richard Frith-Macdonald <rfm@gnu.org>
|
2006-02-04 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
* Source/NSMenu.m:
|
* Source/NSMenu.m:
|
||||||
|
|
|
@ -73,6 +73,24 @@ 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 NSMenuView (Private)
|
||||||
|
- (BOOL) _rootIsHorizontal;
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation NSMenuView (Private)
|
||||||
|
- (BOOL) _rootIsHorizontal
|
||||||
|
{
|
||||||
|
NSMenu *m = _attachedMenu;
|
||||||
|
|
||||||
|
/* Determine root menu of this menu hierarchy */
|
||||||
|
while ([m supermenu] != nil)
|
||||||
|
{
|
||||||
|
m = [m supermenu];
|
||||||
|
}
|
||||||
|
return [[m menuRepresentation] isHorizontal];
|
||||||
|
}
|
||||||
|
@end
|
||||||
|
|
||||||
@implementation NSMenuView
|
@implementation NSMenuView
|
||||||
|
|
||||||
static NSRect
|
static NSRect
|
||||||
|
@ -642,22 +660,24 @@ _addLeftBorderOffsetToRect(NSRect aRect)
|
||||||
// Popup menu doesn't need title bar
|
// Popup menu doesn't need title bar
|
||||||
if (![_attachedMenu _ownedByPopUp] && _titleView)
|
if (![_attachedMenu _ownedByPopUp] && _titleView)
|
||||||
{
|
{
|
||||||
if ([_attachedMenu supermenu] != nil)
|
NSMenu *m = [_attachedMenu supermenu];
|
||||||
|
NSMenuView *r = [m menuRepresentation];
|
||||||
|
|
||||||
|
neededImageAndTitleWidth = [_titleView titleSize].width;
|
||||||
|
if (r != nil && [r isHorizontal] == YES)
|
||||||
{
|
{
|
||||||
NSMenuItemCell *msr;
|
NSMenuItemCell *msr;
|
||||||
|
|
||||||
msr = [[[_attachedMenu supermenu] menuRepresentation]
|
msr = [r menuItemCellForItemAtIndex:
|
||||||
menuItemCellForItemAtIndex:
|
[m indexOfItemWithTitle: [_attachedMenu title]]];
|
||||||
[[_attachedMenu supermenu] indexOfItemWithTitle:
|
|
||||||
[_attachedMenu title]]];
|
|
||||||
neededImageAndTitleWidth
|
neededImageAndTitleWidth
|
||||||
+= [msr titleWidth] + GSCellTextImageXDist;
|
= [msr titleWidth] + GSCellTextImageXDist;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_titleView)
|
if (_titleView)
|
||||||
menuBarHeight = [[self class] menuBarHeight];
|
menuBarHeight = [[self class] menuBarHeight];
|
||||||
else
|
else
|
||||||
menuBarHeight += 3; // 2 on bottom, 1 on top
|
menuBarHeight += _leftBorderOffset;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -784,21 +804,11 @@ _addLeftBorderOffsetToRect(NSRect aRect)
|
||||||
_keyEqOffset = _cellSize.width - _keyEqWidth - popupImageWidth;
|
_keyEqOffset = _cellSize.width - _keyEqWidth - popupImageWidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_horizontal == NO)
|
[self setFrameSize: NSMakeSize(_cellSize.width + _leftBorderOffset,
|
||||||
{
|
(howMany * _cellSize.height)
|
||||||
[self setFrameSize: NSMakeSize(_cellSize.width + _leftBorderOffset,
|
+ menuBarHeight)];
|
||||||
(howMany * _cellSize.height)
|
[_titleView setFrame: NSMakeRect (0, howMany * _cellSize.height,
|
||||||
+ menuBarHeight)];
|
NSWidth (_bounds), menuBarHeight)];
|
||||||
[_titleView setFrame: NSMakeRect (0, howMany * _cellSize.height,
|
|
||||||
NSWidth (_bounds), menuBarHeight)];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
[self setFrameSize: NSMakeSize(((howMany + 1) * _cellSize.width),
|
|
||||||
_cellSize.height + _leftBorderOffset)];
|
|
||||||
[_titleView setFrame: NSMakeRect (0, 0,
|
|
||||||
_cellSize.width, _cellSize.height + 1)];
|
|
||||||
}
|
|
||||||
|
|
||||||
_needsSizing = NO;
|
_needsSizing = NO;
|
||||||
}
|
}
|
||||||
|
@ -985,6 +995,16 @@ _addLeftBorderOffsetToRect(NSRect aRect)
|
||||||
subOrigin.y - NSHeight(submenuFrame) - 3 +
|
subOrigin.y - NSHeight(submenuFrame) - 3 +
|
||||||
2*[NSMenuView menuBarHeight]);
|
2*[NSMenuView menuBarHeight]);
|
||||||
}
|
}
|
||||||
|
else if ([self _rootIsHorizontal] == YES)
|
||||||
|
{
|
||||||
|
NSRect aRect = [self rectOfItemAtIndex:
|
||||||
|
[_attachedMenu indexOfItemWithSubmenu: aSubmenu]];
|
||||||
|
NSPoint subOrigin = [_window convertBaseToScreen:
|
||||||
|
NSMakePoint(aRect.origin.x, aRect.origin.y)];
|
||||||
|
|
||||||
|
return NSMakePoint (NSMaxX(frame),
|
||||||
|
subOrigin.y - NSHeight(submenuFrame) + aRect.size.height);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return NSMakePoint(NSMaxX(frame),
|
return NSMakePoint(NSMaxX(frame),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue