mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-06-03 21:20:41 +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.
|
// Set ivar to new index.
|
||||||
|
if ([_attachedMenu _ownedByPopUp] &&
|
||||||
|
index == 0 && [[_attachedMenu _owningPopUp] pullsDown])
|
||||||
|
{
|
||||||
|
_highlightedItemIndex = -1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
_highlightedItemIndex = index;
|
_highlightedItemIndex = index;
|
||||||
|
}
|
||||||
|
|
||||||
// Highlight new
|
// Highlight new
|
||||||
if (_highlightedItemIndex != -1)
|
if (_highlightedItemIndex != -1)
|
||||||
|
@ -764,15 +772,8 @@ static float menuBarHeight = 0.0;
|
||||||
unsigned i;
|
unsigned i;
|
||||||
unsigned howMany = [_itemCells count];
|
unsigned howMany = [_itemCells count];
|
||||||
float currentX = HORIZONTAL_MENU_LEFT_PADDING;
|
float currentX = HORIZONTAL_MENU_LEFT_PADDING;
|
||||||
// NSRect scRect = [[NSScreen mainScreen] frame];
|
|
||||||
|
|
||||||
GSIArrayRemoveAllItems(cellRects);
|
GSIArrayRemoveAllItems(cellRects);
|
||||||
|
|
||||||
/*
|
|
||||||
scRect.size.height = [NSMenuView menuBarHeight];
|
|
||||||
[self setFrameSize: scRect.size];
|
|
||||||
_cellSize.height = scRect.size.height;
|
|
||||||
*/
|
|
||||||
_cellSize.height = [NSMenuView menuBarHeight];
|
_cellSize.height = [NSMenuView menuBarHeight];
|
||||||
|
|
||||||
if (howMany && isPullDown)
|
if (howMany && isPullDown)
|
||||||
|
@ -967,9 +968,8 @@ static float menuBarHeight = 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
[self setFrameSize: NSMakeSize(_cellSize.width + _leftBorderOffset,
|
[self setFrameSize: NSMakeSize(_cellSize.width + _leftBorderOffset,
|
||||||
[self totalHeight]
|
[self totalHeight] + menuBarHeight)];
|
||||||
+ menuBarHeight)];
|
[_titleView setFrame: NSMakeRect(0, [self totalHeight],
|
||||||
[_titleView setFrame: NSMakeRect (0, [self totalHeight],
|
|
||||||
NSWidth (_bounds), menuBarHeight)];
|
NSWidth (_bounds), menuBarHeight)];
|
||||||
}
|
}
|
||||||
_needsSizing = NO;
|
_needsSizing = NO;
|
||||||
|
@ -1048,13 +1048,6 @@ static float menuBarHeight = 0.0;
|
||||||
[self sizeToFit];
|
[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)
|
if (_horizontal == YES)
|
||||||
{
|
{
|
||||||
GSCellRect aRect;
|
GSCellRect aRect;
|
||||||
|
@ -1212,37 +1205,6 @@ static float menuBarHeight = 0.0;
|
||||||
if (_needsSizing)
|
if (_needsSizing)
|
||||||
[self sizeToFit];
|
[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;
|
cellFrame = screenRect;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1296,22 +1258,11 @@ static float menuBarHeight = 0.0;
|
||||||
popUpFrame.size.width += borderOffsetInBaseCoords;
|
popUpFrame.size.width += borderOffsetInBaseCoords;
|
||||||
popUpFrame.origin.x -= 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
|
// Compute position for popups, if needed
|
||||||
if (selectedItemIndex != -1)
|
if (selectedItemIndex != -1
|
||||||
|
&& [[_attachedMenu _owningPopUp] pullsDown] == NO)
|
||||||
{
|
{
|
||||||
popUpFrame.origin.y
|
popUpFrame.origin.y += cellFrame.size.height * selectedItemIndex;
|
||||||
+= cellFrame.size.height * selectedItemIndex;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -1319,18 +1270,9 @@ static float menuBarHeight = 0.0;
|
||||||
f = cellFrame.size.width * (items - 1);
|
f = cellFrame.size.width * (items - 1);
|
||||||
popUpFrame.size.width += f;
|
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
|
// Compute position for popups, if needed
|
||||||
if (selectedItemIndex != -1)
|
if (selectedItemIndex != -1
|
||||||
|
&& [[_attachedMenu _owningPopUp] pullsDown] == NO)
|
||||||
{
|
{
|
||||||
popUpFrame.origin.x -= cellFrame.size.width * selectedItemIndex;
|
popUpFrame.origin.x -= cellFrame.size.width * selectedItemIndex;
|
||||||
}
|
}
|
||||||
|
|
|
@ -918,15 +918,18 @@ static NSImage *_pbc_image[5];
|
||||||
cellFrame.origin = [cvWin convertBaseToScreen: cellFrame.origin];
|
cellFrame.origin = [cvWin convertBaseToScreen: cellFrame.origin];
|
||||||
|
|
||||||
if (_pbcFlags.pullsDown)
|
if (_pbcFlags.pullsDown)
|
||||||
|
{
|
||||||
selectedItem = -1;
|
selectedItem = -1;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
selectedItem = [self indexOfSelectedItem];
|
selectedItem = [self indexOfSelectedItem];
|
||||||
|
}
|
||||||
|
|
||||||
if (selectedItem == -1)
|
if (selectedItem == -1)
|
||||||
{
|
{
|
||||||
selectedItem = 0;
|
selectedItem = 0;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (selectedItem > 0)
|
if (selectedItem > 0)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue