Fix badly placed #endif

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@5269 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
richard 1999-11-24 16:54:23 +00:00
parent 95dc98cfed
commit a569f85d44
2 changed files with 59 additions and 55 deletions

View file

@ -1,3 +1,7 @@
Wed Nov 24 16:58:00 1999 Richard Frith-Macdonald <richard@brainstorm.co.uk>
* Source/NSMenuView.m: ([-sizeTofit]) oops - fixed error in last mod.
Wed Nov 24 1999 Nicola Pero <n.pero@mi.flashnet.it> Wed Nov 24 1999 Nicola Pero <n.pero@mi.flashnet.it>
The three new autolayout classes; code extremely stable, API The three new autolayout classes; code extremely stable, API

View file

@ -392,71 +392,71 @@ static float GSMenuBarHeight = 25.0; // A wild guess.
return menuv_needsSizing; return menuv_needsSizing;
} }
- (void)sizeToFit - (void) sizeToFit
{ {
int i; unsigned i;
int howMany = [menuv_itemCells count]; unsigned howMany = [menuv_itemCells count];
float howHigh = (howMany * cellSize.height); float howHigh = (howMany * cellSize.height);
float neededImageAndTitleWidth = [[NSFont boldSystemFontOfSize: 12] float neededImageAndTitleWidth = [[NSFont boldSystemFontOfSize: 12]
widthOfString: [menuv_menu title]] + 17; widthOfString: [menuv_menu title]] + 17;
float neededKeyEquivalentWidth = 0.; float neededKeyEquivalentWidth = 0.;
float neededStateImageWidth = 0.; float neededStateImageWidth = 0.;
float accumulatedOffset = 0.; float accumulatedOffset = 0.;
// TODO: Optimize this loop. // TODO: Optimize this loop.
for (i = 0; i < howMany; i++) for (i = 0; i < howMany; i++)
{ {
float anImageAndTitleWidth; float anImageAndTitleWidth;
float anImageWidth; float anImageWidth;
float aKeyEquivalentWidth; float aKeyEquivalentWidth;
float aStateImageWidth; float aStateImageWidth;
float aTitleWidth; float aTitleWidth;
NSMenuItemCell *aCell = [menuv_itemCells objectAtIndex: i]; NSMenuItemCell *aCell = [menuv_itemCells objectAtIndex: i];
// State image area. // State image area.
aStateImageWidth = [aCell stateImageWidth]; aStateImageWidth = [aCell stateImageWidth];
if (aStateImageWidth > neededStateImageWidth) if (aStateImageWidth > neededStateImageWidth)
neededStateImageWidth = aStateImageWidth; neededStateImageWidth = aStateImageWidth;
// Image and title area. // Image and title area.
aTitleWidth = [aCell titleWidth]; aTitleWidth = [aCell titleWidth];
anImageWidth = [aCell imageWidth]; anImageWidth = [aCell imageWidth];
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) if (anImageAndTitleWidth > neededImageAndTitleWidth)
neededImageAndTitleWidth = anImageAndTitleWidth; neededImageAndTitleWidth = anImageAndTitleWidth;
// Key equivalent area. // Key equivalent area.
aKeyEquivalentWidth = [aCell keyEquivalentWidth]; aKeyEquivalentWidth = [aCell keyEquivalentWidth];
if (aKeyEquivalentWidth > neededKeyEquivalentWidth) if (aKeyEquivalentWidth > neededKeyEquivalentWidth)
neededKeyEquivalentWidth = aKeyEquivalentWidth; neededKeyEquivalentWidth = aKeyEquivalentWidth;
} }
// Cache the needed widths. // Cache the needed widths.
menuv_stateImageWidth = neededStateImageWidth; menuv_stateImageWidth = neededStateImageWidth;
@ -474,15 +474,15 @@ static float GSMenuBarHeight = 25.0; // A wild guess.
// Calculate frame size. // Calculate frame size.
#if 0 #if 0
if (![menuv_menu _isBeholdenToPopUpButton]) if (![menuv_menu _isBeholdenToPopUpButton])
cellSize.width = accumulatedOffset + 3; // Add the border width
#endif #endif
cellSize.width = accumulatedOffset + 3; // Add the border width
[self setFrameSize: NSMakeSize(cellSize.width + 1, howHigh)]; [self setFrameSize: NSMakeSize(cellSize.width + 1, howHigh)];
menuv_needsSizing = NO; menuv_needsSizing = NO;
} }
- (void)sizeToFitForPopUpButton - (void) sizeToFitForPopUpButton
{ {
int howHigh = ([menuv_items_link count] * cellSize.height); int howHigh = ([menuv_items_link count] * cellSize.height);