NSMenuView popup button related fixes and additions

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@16214 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Sergii Stoian 2003-03-20 12:16:25 +00:00
parent b19a81ce43
commit 8ba951b342
2 changed files with 98 additions and 98 deletions

View file

@ -1,3 +1,15 @@
2003-03-20 Serg Stoyan <stoyan@on.com.ua>
* Source/NSMenuView.m
(sizeToFit): Removed setting _leftBorderOffset to 0 for popup menus.
Set menuBarHeight to title view height only if it's not popup menu.
Added recalculation of key equivalent offset for popup menu.
(setWindowFrameForAttachingToRect:onScreen:preferredEdge:popUpSelectedItem:):
Remove title view. Take into account left top border while calculating
screenFrame.
(drawRect:): Draw left top dark gray border for all types of menus with
NSDrawTiledRects().
2003-03-19 Fred Kiefer <FredKiefer@gmx.de>
* Headers/gnustep/gui/NSMenu.h

View file

@ -506,17 +506,14 @@ _addLeftBorderOffsetToRect(NSRect aRect, BOOL isHorizontal)
float neededKeyEquivalentWidth = 0.0;
float neededStateImageWidth = 0.0;
float accumulatedOffset = 0.0;
float popupImageWidth = 0.0;
float menuBarHeight = 0.0;
/* Set the necessary offset for the menuView. That is, how many pixels
* do we need for our left side border line. For regular menus this
* equals 1, for popups it is 0.
*
* Why here? I could not think of a better place. I figure that everyone
* should sizeToFit their popup/menu before using it so we should get
* this set properly fairly early.
*/
if ([_menu _ownedByPopUp])
_leftBorderOffset = 0;
// Popup menu doesn't need title bar
if (![_menu _ownedByPopUp])
menuBarHeight = [[self class] menuBarHeight];
else
menuBarHeight += _leftBorderOffset;
// TODO: Optimize this loop.
for (i = 0; i < howMany; i++)
@ -576,6 +573,10 @@ _addLeftBorderOffsetToRect(NSRect aRect, BOOL isHorizontal)
if (aKeyEquivalentWidth > neededKeyEquivalentWidth)
neededKeyEquivalentWidth = aKeyEquivalentWidth;
// Popup menu has only one item with nibble image
if (anImageWidth)
popupImageWidth = anImageWidth;
}
// Cache the needed widths.
@ -621,11 +622,13 @@ _addLeftBorderOffsetToRect(NSRect aRect, BOOL isHorizontal)
// Add the border width: 1 for left, 2 for right sides
_cellSize.width = accumulatedOffset + 3;
}
else
{
_keyEqOffset = _cellSize.width - _keyEqWidth - popupImageWidth;
}
if (_horizontal == NO)
{
float menuBarHeight = [[self class] menuBarHeight];
[self setFrameSize: NSMakeSize(_cellSize.width + _leftBorderOffset,
(howMany * _cellSize.height) + menuBarHeight)];
[_titleView setFrame: NSMakeRect (0, howMany * _cellSize.height,
@ -847,6 +850,8 @@ _addLeftBorderOffsetToRect(NSRect aRect, BOOL isHorizontal)
NSRect screenFrame;
int items = [_itemCells count];
[_titleView removeFromSuperview];
// Convert the screen rect to our view
cellFrame.size = screenRect.size;
cellFrame.origin = [_window convertScreenToBase: screenRect.origin];
@ -866,8 +871,10 @@ _addLeftBorderOffsetToRect(NSRect aRect, BOOL isHorizontal)
if (_horizontal == NO)
{
f = screenRect.size.height * (items - 1);
screenFrame.size.height += f;
screenFrame.size.height += f + _leftBorderOffset;
screenFrame.origin.y -= f;
screenFrame.size.width += _leftBorderOffset;
screenFrame.origin.x -= _leftBorderOffset;
}
else
{
@ -910,30 +917,11 @@ _addLeftBorderOffsetToRect(NSRect aRect, BOOL isHorizontal)
{
int i;
int howMany = [_itemCells count];
NSRectEdge sides[] = {NSMinXEdge, NSMaxYEdge};
float grays[] = {NSDarkGray, NSDarkGray};
/* For popupButtons we do not want this dark line. */
if (![_menu _ownedByPopUp])
{
NSGraphicsContext *ctxt = GSCurrentContext();
// Draw a dark gray line at the left of the menu item cells.
DPSgsave(ctxt);
DPSsetlinewidth(ctxt, 1);
DPSsetgray(ctxt, NSDarkGray);
if (_horizontal == NO)
{
DPSmoveto(ctxt, NSMinX(_bounds), NSMinY(_bounds));
DPSrlineto(ctxt, 0, _bounds.size.height);
}
else
{
DPSmoveto(ctxt, NSMinX(_bounds), NSMaxY(_bounds));
DPSrlineto(ctxt, _bounds.size.width, 0);
}
DPSstroke(ctxt);
DPSgrestore(ctxt);
}
// Draw the dark gray upper left lines.
NSDrawTiledRects(rect, rect, sides, grays, 2);
// Draw the menu cells.
for (i = 0; i < howMany; i++)