offset calulation fixes and optimization

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@16258 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Sergii Stoian 2003-03-25 15:34:08 +00:00
parent e1dd0679b1
commit da3b4b0583

View file

@ -550,21 +550,22 @@ _addLeftBorderOffsetToRect(NSRect aRect)
anImageAndTitleWidth = anImageWidth;
break;
}
anImageAndTitleWidth += aStateImageWidth;
if (aStateImageWidth > neededStateImageWidth)
neededStateImageWidth = aStateImageWidth;
if (anImageAndTitleWidth > neededImageAndTitleWidth)
{
neededImageAndTitleWidth = anImageAndTitleWidth;
wideTitleView = 0;
}
if (aKeyEquivalentWidth > neededKeyEquivalentWidth)
neededKeyEquivalentWidth = aKeyEquivalentWidth;
// Popup menu has only one item with nibble image
// Title view width less than item's left part width
if ((anImageAndTitleWidth + aStateImageWidth)
> neededImageAndTitleWidth)
wideTitleView = 0;
// Popup menu has only one item with nibble or arrow image
if (anImageWidth)
popupImageWidth = anImageWidth;
}
@ -574,35 +575,42 @@ _addLeftBorderOffsetToRect(NSRect aRect)
_imageAndTitleWidth = neededImageAndTitleWidth;
_keyEqWidth = neededKeyEquivalentWidth;
accumulatedOffset = _horizontalEdgePad;
if (howMany)
{
// Calculate the offsets and cache them.
if (neededStateImageWidth)
{
_stateImageOffset = accumulatedOffset += _horizontalEdgePad;
accumulatedOffset += neededStateImageWidth;
_stateImageOffset = accumulatedOffset;
accumulatedOffset += neededStateImageWidth += _horizontalEdgePad;
}
_imageAndTitleOffset = accumulatedOffset += _horizontalEdgePad;
if (neededImageAndTitleWidth)
{
_imageAndTitleOffset = accumulatedOffset;
accumulatedOffset += neededImageAndTitleWidth;
}
if (neededKeyEquivalentWidth)
if (wideTitleView)
{
_keyEqOffset = accumulatedOffset = neededImageAndTitleWidth
+ (3 * _horizontalEdgePad);
}
else
{
_keyEqOffset = accumulatedOffset += (2 * _horizontalEdgePad);
}
accumulatedOffset += neededKeyEquivalentWidth + _horizontalEdgePad;
}
else
if ([_menu supermenu] != nil && neededKeyEquivalentWidth < 8)
{
if (wideTitleView && [_menu supermenu] != nil)
accumulatedOffset += 15 + 3 + 2;
else
accumulatedOffset += 3 * _horizontalEdgePad;
accumulatedOffset += 8 - neededKeyEquivalentWidth;
}
}
else
{
accumulatedOffset += 5 + neededImageAndTitleWidth + 3 + 2;
if (wideTitleView && [_menu supermenu] != nil)
accumulatedOffset += neededImageAndTitleWidth + 3 + 2;
if ([_menu supermenu] != nil)
accumulatedOffset += 15;
}