mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-31 22:00:46 +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,25 +515,31 @@ _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:
|
||||||
|
@ -561,21 +566,17 @@ _addLeftBorderOffsetToRect(NSRect aRect, BOOL isHorizontal)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
anImageAndTitleWidth += aStateImageWidth;
|
anImageAndTitleWidth += aStateImageWidth;
|
||||||
|
|
||||||
|
if (aStateImageWidth > neededStateImageWidth)
|
||||||
|
neededStateImageWidth = aStateImageWidth;
|
||||||
|
|
||||||
if (anImageAndTitleWidth > neededImageAndTitleWidth)
|
if (anImageAndTitleWidth > neededImageAndTitleWidth)
|
||||||
neededImageAndTitleWidth = anImageAndTitleWidth;
|
neededImageAndTitleWidth = anImageAndTitleWidth;
|
||||||
|
|
||||||
// Key equivalent area.
|
|
||||||
aKeyEquivalentWidth = [aCell keyEquivalentWidth];
|
|
||||||
|
|
||||||
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.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue