mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-25 19:31:18 +00:00
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:
parent
b19a81ce43
commit
8ba951b342
2 changed files with 98 additions and 98 deletions
12
ChangeLog
12
ChangeLog
|
@ -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>
|
2003-03-19 Fred Kiefer <FredKiefer@gmx.de>
|
||||||
|
|
||||||
* Headers/gnustep/gui/NSMenu.h
|
* Headers/gnustep/gui/NSMenu.h
|
||||||
|
|
|
@ -506,17 +506,14 @@ _addLeftBorderOffsetToRect(NSRect aRect, BOOL isHorizontal)
|
||||||
float neededKeyEquivalentWidth = 0.0;
|
float neededKeyEquivalentWidth = 0.0;
|
||||||
float neededStateImageWidth = 0.0;
|
float neededStateImageWidth = 0.0;
|
||||||
float accumulatedOffset = 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
|
// Popup menu doesn't need title bar
|
||||||
* do we need for our left side border line. For regular menus this
|
if (![_menu _ownedByPopUp])
|
||||||
* equals 1, for popups it is 0.
|
menuBarHeight = [[self class] menuBarHeight];
|
||||||
*
|
else
|
||||||
* Why here? I could not think of a better place. I figure that everyone
|
menuBarHeight += _leftBorderOffset;
|
||||||
* should sizeToFit their popup/menu before using it so we should get
|
|
||||||
* this set properly fairly early.
|
|
||||||
*/
|
|
||||||
if ([_menu _ownedByPopUp])
|
|
||||||
_leftBorderOffset = 0;
|
|
||||||
|
|
||||||
// TODO: Optimize this loop.
|
// TODO: Optimize this loop.
|
||||||
for (i = 0; i < howMany; i++)
|
for (i = 0; i < howMany; i++)
|
||||||
|
@ -576,6 +573,10 @@ _addLeftBorderOffsetToRect(NSRect aRect, BOOL isHorizontal)
|
||||||
|
|
||||||
if (aKeyEquivalentWidth > neededKeyEquivalentWidth)
|
if (aKeyEquivalentWidth > neededKeyEquivalentWidth)
|
||||||
neededKeyEquivalentWidth = aKeyEquivalentWidth;
|
neededKeyEquivalentWidth = aKeyEquivalentWidth;
|
||||||
|
|
||||||
|
// Popup menu has only one item with nibble image
|
||||||
|
if (anImageWidth)
|
||||||
|
popupImageWidth = anImageWidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cache the needed widths.
|
// Cache the needed widths.
|
||||||
|
@ -621,11 +622,13 @@ _addLeftBorderOffsetToRect(NSRect aRect, BOOL isHorizontal)
|
||||||
// Add the border width: 1 for left, 2 for right sides
|
// Add the border width: 1 for left, 2 for right sides
|
||||||
_cellSize.width = accumulatedOffset + 3;
|
_cellSize.width = accumulatedOffset + 3;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_keyEqOffset = _cellSize.width - _keyEqWidth - popupImageWidth;
|
||||||
|
}
|
||||||
|
|
||||||
if (_horizontal == NO)
|
if (_horizontal == NO)
|
||||||
{
|
{
|
||||||
float menuBarHeight = [[self class] menuBarHeight];
|
|
||||||
|
|
||||||
[self setFrameSize: NSMakeSize(_cellSize.width + _leftBorderOffset,
|
[self setFrameSize: NSMakeSize(_cellSize.width + _leftBorderOffset,
|
||||||
(howMany * _cellSize.height) + menuBarHeight)];
|
(howMany * _cellSize.height) + menuBarHeight)];
|
||||||
[_titleView setFrame: NSMakeRect (0, howMany * _cellSize.height,
|
[_titleView setFrame: NSMakeRect (0, howMany * _cellSize.height,
|
||||||
|
@ -847,6 +850,8 @@ _addLeftBorderOffsetToRect(NSRect aRect, BOOL isHorizontal)
|
||||||
NSRect screenFrame;
|
NSRect screenFrame;
|
||||||
int items = [_itemCells count];
|
int items = [_itemCells count];
|
||||||
|
|
||||||
|
[_titleView removeFromSuperview];
|
||||||
|
|
||||||
// Convert the screen rect to our view
|
// Convert the screen rect to our view
|
||||||
cellFrame.size = screenRect.size;
|
cellFrame.size = screenRect.size;
|
||||||
cellFrame.origin = [_window convertScreenToBase: screenRect.origin];
|
cellFrame.origin = [_window convertScreenToBase: screenRect.origin];
|
||||||
|
@ -866,8 +871,10 @@ _addLeftBorderOffsetToRect(NSRect aRect, BOOL isHorizontal)
|
||||||
if (_horizontal == NO)
|
if (_horizontal == NO)
|
||||||
{
|
{
|
||||||
f = screenRect.size.height * (items - 1);
|
f = screenRect.size.height * (items - 1);
|
||||||
screenFrame.size.height += f;
|
screenFrame.size.height += f + _leftBorderOffset;
|
||||||
screenFrame.origin.y -= f;
|
screenFrame.origin.y -= f;
|
||||||
|
screenFrame.size.width += _leftBorderOffset;
|
||||||
|
screenFrame.origin.x -= _leftBorderOffset;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -910,30 +917,11 @@ _addLeftBorderOffsetToRect(NSRect aRect, BOOL isHorizontal)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int howMany = [_itemCells count];
|
int howMany = [_itemCells count];
|
||||||
|
NSRectEdge sides[] = {NSMinXEdge, NSMaxYEdge};
|
||||||
|
float grays[] = {NSDarkGray, NSDarkGray};
|
||||||
|
|
||||||
/* For popupButtons we do not want this dark line. */
|
// Draw the dark gray upper left lines.
|
||||||
|
NSDrawTiledRects(rect, rect, sides, grays, 2);
|
||||||
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 menu cells.
|
// Draw the menu cells.
|
||||||
for (i = 0; i < howMany; i++)
|
for (i = 0; i < howMany; i++)
|
||||||
|
|
Loading…
Reference in a new issue