mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-31 16:51:18 +00:00
* Source/NSMenuView.m (setHighlightedItemIndex:): do not highlight first
item for pulldown popup button's menu. (sizeToFit): removed commented useless code; fixed formatting. (rectOfItemAtIndex:): draw first item cell of pulldown popup menu. (setWindowFrameForAttachingToRect:onScreen:preferredEdge:popUpSelectedItem:): remove useless (was used for old-style popup menu) positionning code for popup menu. Check if owning popup is not pulldown before vertical position correction. * Source/NSPopUpButtonCell.m (attachPopUpWithFrame:inView:): make setting selected item code more generic for pulldown and non-pulldown button. Fixed formatting.
This commit is contained in:
parent
a655fe1192
commit
d9197c5096
2 changed files with 30 additions and 85 deletions
|
@ -405,7 +405,15 @@ static float menuBarHeight = 0.0;
|
|||
}
|
||||
|
||||
// Set ivar to new index.
|
||||
_highlightedItemIndex = index;
|
||||
if ([_attachedMenu _ownedByPopUp] &&
|
||||
index == 0 && [[_attachedMenu _owningPopUp] pullsDown])
|
||||
{
|
||||
_highlightedItemIndex = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
_highlightedItemIndex = index;
|
||||
}
|
||||
|
||||
// Highlight new
|
||||
if (_highlightedItemIndex != -1)
|
||||
|
@ -764,15 +772,8 @@ static float menuBarHeight = 0.0;
|
|||
unsigned i;
|
||||
unsigned howMany = [_itemCells count];
|
||||
float currentX = HORIZONTAL_MENU_LEFT_PADDING;
|
||||
// NSRect scRect = [[NSScreen mainScreen] frame];
|
||||
|
||||
GSIArrayRemoveAllItems(cellRects);
|
||||
|
||||
/*
|
||||
scRect.size.height = [NSMenuView menuBarHeight];
|
||||
[self setFrameSize: scRect.size];
|
||||
_cellSize.height = scRect.size.height;
|
||||
*/
|
||||
_cellSize.height = [NSMenuView menuBarHeight];
|
||||
|
||||
if (howMany && isPullDown)
|
||||
|
@ -967,10 +968,9 @@ static float menuBarHeight = 0.0;
|
|||
}
|
||||
|
||||
[self setFrameSize: NSMakeSize(_cellSize.width + _leftBorderOffset,
|
||||
[self totalHeight]
|
||||
+ menuBarHeight)];
|
||||
[_titleView setFrame: NSMakeRect (0, [self totalHeight],
|
||||
NSWidth (_bounds), menuBarHeight)];
|
||||
[self totalHeight] + menuBarHeight)];
|
||||
[_titleView setFrame: NSMakeRect(0, [self totalHeight],
|
||||
NSWidth (_bounds), menuBarHeight)];
|
||||
}
|
||||
_needsSizing = NO;
|
||||
}
|
||||
|
@ -1048,13 +1048,6 @@ static float menuBarHeight = 0.0;
|
|||
[self sizeToFit];
|
||||
}
|
||||
|
||||
// The first item of a pull down menu holds its title and isn't displayed
|
||||
if (index == 0 && [_attachedMenu _ownedByPopUp] &&
|
||||
[[_attachedMenu _owningPopUp] pullsDown])
|
||||
{
|
||||
return NSZeroRect;
|
||||
}
|
||||
|
||||
if (_horizontal == YES)
|
||||
{
|
||||
GSCellRect aRect;
|
||||
|
@ -1212,37 +1205,6 @@ static float menuBarHeight = 0.0;
|
|||
if (_needsSizing)
|
||||
[self sizeToFit];
|
||||
|
||||
/* FIXME: Perhaps all of this belongs into NSPopupButtonCell and
|
||||
should be used to determine the proper screenRect to pass on into
|
||||
this method.
|
||||
*/
|
||||
/* certain style of pulldowns don't want sizing on the _cellSize.height */
|
||||
if ([_attachedMenu _ownedByPopUp])
|
||||
{
|
||||
NSPopUpButtonCell *bcell;
|
||||
|
||||
bcell = [_attachedMenu _owningPopUp];
|
||||
if ([bcell pullsDown])
|
||||
{
|
||||
if ([bcell isBordered] == NO)
|
||||
{
|
||||
growHeight = NO;
|
||||
}
|
||||
else
|
||||
{
|
||||
switch ([bcell bezelStyle])
|
||||
{
|
||||
case NSRegularSquareBezelStyle:
|
||||
case NSShadowlessSquareBezelStyle:
|
||||
growHeight = NO;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cellFrame = screenRect;
|
||||
|
||||
/*
|
||||
|
@ -1296,22 +1258,11 @@ static float menuBarHeight = 0.0;
|
|||
popUpFrame.size.width += borderOffsetInBaseCoords;
|
||||
popUpFrame.origin.x -= borderOffsetInBaseCoords;
|
||||
|
||||
// If the menu is a pull down menu the first item, which would
|
||||
// appear at the top of the menu, holds the title and is omitted
|
||||
if ([_attachedMenu _ownedByPopUp])
|
||||
{
|
||||
if ([[_attachedMenu _owningPopUp] pullsDown])
|
||||
{
|
||||
popUpFrame.size.height -= cellFrame.size.height;
|
||||
popUpFrame.origin.y += cellFrame.size.height;
|
||||
}
|
||||
}
|
||||
|
||||
// Compute position for popups, if needed
|
||||
if (selectedItemIndex != -1)
|
||||
if (selectedItemIndex != -1
|
||||
&& [[_attachedMenu _owningPopUp] pullsDown] == NO)
|
||||
{
|
||||
popUpFrame.origin.y
|
||||
+= cellFrame.size.height * selectedItemIndex;
|
||||
popUpFrame.origin.y += cellFrame.size.height * selectedItemIndex;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -1319,23 +1270,14 @@ static float menuBarHeight = 0.0;
|
|||
f = cellFrame.size.width * (items - 1);
|
||||
popUpFrame.size.width += f;
|
||||
|
||||
// If the menu is a pull down menu the first item holds the
|
||||
// title and is omitted
|
||||
if ([_attachedMenu _ownedByPopUp])
|
||||
{
|
||||
if ([[_attachedMenu _owningPopUp] pullsDown])
|
||||
{
|
||||
popUpFrame.size.width -= cellFrame.size.width;
|
||||
}
|
||||
}
|
||||
|
||||
// Compute position for popups, if needed
|
||||
if (selectedItemIndex != -1)
|
||||
if (selectedItemIndex != -1
|
||||
&& [[_attachedMenu _owningPopUp] pullsDown] == NO)
|
||||
{
|
||||
popUpFrame.origin.x -= cellFrame.size.width * selectedItemIndex;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Update position, if needed, using the preferredEdge
|
||||
if (selectedItemIndex == -1)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue