mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-30 16:00:37 +00:00
cleanup of previous commit
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@16188 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
8ad1f16325
commit
15a1fb917c
1 changed files with 46 additions and 45 deletions
|
@ -500,7 +500,6 @@ _addLeftBorderOffsetToRect(NSRect aRect, BOOL isHorizontal)
|
||||||
unsigned i;
|
unsigned i;
|
||||||
unsigned howMany = [_itemCells count];
|
unsigned howMany = [_itemCells count];
|
||||||
float neededImageAndTitleWidth = [_font widthOfString: [_menu title]];
|
float neededImageAndTitleWidth = [_font widthOfString: [_menu title]];
|
||||||
float initialImageAndTitleWidth = neededImageAndTitleWidth;
|
|
||||||
float neededKeyEquivalentWidth = 0.0;
|
float neededKeyEquivalentWidth = 0.0;
|
||||||
float neededStateImageWidth = 0.0;
|
float neededStateImageWidth = 0.0;
|
||||||
float accumulatedOffset = 0.0;
|
float accumulatedOffset = 0.0;
|
||||||
|
@ -516,66 +515,68 @@ _addLeftBorderOffsetToRect(NSRect aRect, BOOL isHorizontal)
|
||||||
if ([_menu _ownedByPopUp])
|
if ([_menu _ownedByPopUp])
|
||||||
_leftBorderOffset = 0;
|
_leftBorderOffset = 0;
|
||||||
|
|
||||||
|
if ([_menu supermenu] != nil)
|
||||||
|
neededImageAndTitleWidth = [_font widthOfString: [_menu title]] + 15;
|
||||||
|
else
|
||||||
|
neededImageAndTitleWidth = [_font widthOfString: [_menu title]];
|
||||||
|
|
||||||
// TODO: Optimize this loop.
|
// TODO: Optimize this loop.
|
||||||
for (i = 0; i < howMany; i++)
|
for (i = 0; i < howMany; i++)
|
||||||
{
|
{
|
||||||
float anImageAndTitleWidth;
|
float anImageAndTitleWidth = 0.0;
|
||||||
float anImageWidth;
|
float anImageWidth = 0.0;
|
||||||
float aKeyEquivalentWidth;
|
float aKeyEquivalentWidth = 0.0;
|
||||||
float aStateImageWidth;
|
float aStateImageWidth = 0.0;
|
||||||
float aTitleWidth;
|
float aTitleWidth = 0.0;
|
||||||
NSMenuItemCell *aCell = [_itemCells objectAtIndex: i];
|
NSMenuItemCell *aCell = [_itemCells objectAtIndex: i];
|
||||||
|
|
||||||
// State image area.
|
// State image area.
|
||||||
aStateImageWidth = [aCell stateImageWidth];
|
aStateImageWidth = [aCell stateImageWidth];
|
||||||
|
|
||||||
if (aStateImageWidth > neededStateImageWidth)
|
// Title and Image area.
|
||||||
neededStateImageWidth = aStateImageWidth;
|
|
||||||
|
|
||||||
// Image and title area.
|
|
||||||
aTitleWidth = [aCell titleWidth];
|
aTitleWidth = [aCell titleWidth];
|
||||||
anImageWidth = [aCell imageWidth];
|
anImageWidth = [aCell imageWidth];
|
||||||
|
|
||||||
|
// Key equivalent area.
|
||||||
|
aKeyEquivalentWidth = [aCell keyEquivalentWidth];
|
||||||
|
|
||||||
switch ([aCell imagePosition])
|
switch ([aCell imagePosition])
|
||||||
{
|
{
|
||||||
case NSNoImage:
|
case NSNoImage:
|
||||||
anImageAndTitleWidth = aTitleWidth;
|
anImageAndTitleWidth = aTitleWidth;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NSImageOnly:
|
case NSImageOnly:
|
||||||
anImageAndTitleWidth = anImageWidth;
|
anImageAndTitleWidth = anImageWidth;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NSImageLeft:
|
case NSImageLeft:
|
||||||
case NSImageRight:
|
case NSImageRight:
|
||||||
anImageAndTitleWidth = anImageWidth + aTitleWidth + xDist;
|
anImageAndTitleWidth = anImageWidth + aTitleWidth + xDist;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NSImageBelow:
|
case NSImageBelow:
|
||||||
case NSImageAbove:
|
case NSImageAbove:
|
||||||
case NSImageOverlaps:
|
case NSImageOverlaps:
|
||||||
default:
|
default:
|
||||||
if (aTitleWidth > anImageWidth)
|
if (aTitleWidth > anImageWidth)
|
||||||
anImageAndTitleWidth = aTitleWidth;
|
anImageAndTitleWidth = aTitleWidth;
|
||||||
else
|
else
|
||||||
anImageAndTitleWidth = anImageWidth;
|
anImageAndTitleWidth = anImageWidth;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
anImageAndTitleWidth += aStateImageWidth;
|
anImageAndTitleWidth += aStateImageWidth;
|
||||||
if (anImageAndTitleWidth > neededImageAndTitleWidth)
|
|
||||||
neededImageAndTitleWidth = anImageAndTitleWidth;
|
|
||||||
|
|
||||||
// Key equivalent area.
|
if (aStateImageWidth > neededStateImageWidth)
|
||||||
aKeyEquivalentWidth = [aCell keyEquivalentWidth];
|
neededStateImageWidth = aStateImageWidth;
|
||||||
|
|
||||||
|
if (anImageAndTitleWidth > neededImageAndTitleWidth)
|
||||||
|
neededImageAndTitleWidth = anImageAndTitleWidth;
|
||||||
|
|
||||||
if (aKeyEquivalentWidth > neededKeyEquivalentWidth)
|
if (aKeyEquivalentWidth > neededKeyEquivalentWidth)
|
||||||
neededKeyEquivalentWidth = aKeyEquivalentWidth;
|
neededKeyEquivalentWidth = aKeyEquivalentWidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (neededImageAndTitleWidth == initialImageAndTitleWidth)
|
|
||||||
{
|
|
||||||
neededImageAndTitleWidth += 10;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Cache the needed widths.
|
// Cache the needed widths.
|
||||||
_stateImageWidth = neededStateImageWidth;
|
_stateImageWidth = neededStateImageWidth;
|
||||||
_imageAndTitleWidth = neededImageAndTitleWidth;
|
_imageAndTitleWidth = neededImageAndTitleWidth;
|
||||||
|
@ -584,9 +585,9 @@ _addLeftBorderOffsetToRect(NSRect aRect, BOOL isHorizontal)
|
||||||
// Calculate the offsets and cache them.
|
// Calculate the offsets and cache them.
|
||||||
_stateImageOffset = _imageAndTitleOffset = accumulatedOffset
|
_stateImageOffset = _imageAndTitleOffset = accumulatedOffset
|
||||||
= _horizontalEdgePad;
|
= _horizontalEdgePad;
|
||||||
accumulatedOffset += 2 * _horizontalEdgePad + neededImageAndTitleWidth;
|
accumulatedOffset += neededImageAndTitleWidth;
|
||||||
|
|
||||||
_keyEqOffset = accumulatedOffset += _horizontalEdgePad;
|
_keyEqOffset = accumulatedOffset += 2 * _horizontalEdgePad;
|
||||||
accumulatedOffset += neededKeyEquivalentWidth + _horizontalEdgePad;
|
accumulatedOffset += neededKeyEquivalentWidth + _horizontalEdgePad;
|
||||||
|
|
||||||
// Calculate frame size.
|
// Calculate frame size.
|
||||||
|
@ -600,14 +601,14 @@ _addLeftBorderOffsetToRect(NSRect aRect, BOOL isHorizontal)
|
||||||
float menuBarHeight = [[self class] menuBarHeight];
|
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,
|
||||||
NSWidth (_bounds), menuBarHeight)];
|
NSWidth (_bounds), menuBarHeight)];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
[self setFrameSize: NSMakeSize((howMany * _cellSize.width),
|
[self setFrameSize: NSMakeSize((howMany * _cellSize.width),
|
||||||
_cellSize.height + _leftBorderOffset)];
|
_cellSize.height + _leftBorderOffset)];
|
||||||
}
|
}
|
||||||
|
|
||||||
_needsSizing = NO;
|
_needsSizing = NO;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue