Added stuff so that NSMenu won't get sized to smaller than it's title width.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@5043 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Lyndon Tremblay 1999-10-20 17:29:56 +00:00
parent d24294cb85
commit ad22faa6a2
4 changed files with 33 additions and 6 deletions

View file

@ -77,6 +77,7 @@ static NSString* NSMenuLocationsKey = @"NSMenuLocations";
- (id) init
{
return [self initWithTitle: @"Menu"];
//return self;
}
- (id) initWithPopUpButton: (NSPopUpButton *)popb
@ -134,6 +135,7 @@ static NSString* NSMenuLocationsKey = @"NSMenuLocations";
NSNotificationCenter* defaultCenter = [NSNotificationCenter defaultCenter];
NSApplication* theApp = [NSApplication sharedApplication];
NSRect winRect = {{0, 0}, {20, 17}};
//float titleWidth = 0;
[super init];
@ -366,7 +368,9 @@ static NSString* NSMenuLocationsKey = @"NSMenuLocations";
- (id <NSMenuItem>) itemAtIndex: (int)index
{
// FIXME should raise an exception if out of range.
if (index >= [menu_items count] || index < 0)
[NSException raise:NSRangeException format:@"menu index %i out of range",
index];
return [menu_items objectAtIndex: index];
}
@ -717,8 +721,9 @@ static NSString* NSMenuLocationsKey = @"NSMenuLocations";
NSRect mFrame;
NSSize size;
[menu_view sizeToFit];
//-setTitleWidth: ends up calling -sizeToFit.
[menu_view setTitleWidth:[[NSFont systemFontOfSize:12] widthOfString:menu_title]];
mFrame = [menu_view frame];
size.width = mFrame.size.width;