* NSMenu.m->NSMenuMatrix in insertItemWithTitle: removed call to

_resizeMenuForCellSize for performance reasons.  _resizeMenuForCellSize
		is called later on a sizeToFit.
	* NSMenu.m->NSMenuMatrix in removeItem: removed call to
		_resizeMenuForCellSize for performance reasons.  _resizeMenuForCellSize
		is called later on a sizeToFit.
	* NSMenu.m->NSMenu in insertItemWithTitle: replaced call to _menuChanged
		with menuHasChanged=YES for performance reasons.
	* NSMenu.m->NSMenu in removeItem: replaced call to _menuChanged with
		menuHasChanged=YES for performance reasons.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@2973 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
far 1998-09-08 21:50:33 +00:00
parent e77403ce70
commit 24eac4c538
5 changed files with 66 additions and 53 deletions

View file

@ -141,9 +141,9 @@ static NSFont* menuFont = nil;
}
- (id <NSMenuItem>)insertItemWithTitle:(NSString*)aString
action:(SEL)aSelector
keyEquivalent:(NSString*)charCode
atIndex:(unsigned int)index
action:(SEL)aSelector
keyEquivalent:(NSString*)charCode
atIndex:(unsigned int)index
{
id menuCell = [[[NSMenu cellClass] new] autorelease];
@ -154,7 +154,6 @@ static NSFont* menuFont = nil;
[menuCell setKeyEquivalent:charCode];
[cells insertObject:menuCell atIndex:index];
[self _resizeMenuForCellSize];
return menuCell;
}
@ -167,7 +166,6 @@ static NSFont* menuFont = nil;
return;
[cells removeObjectAtIndex:row];
[self _resizeMenuForCellSize];
}
- (NSArray*)itemArray { return cells; }
@ -343,25 +341,25 @@ static Class menuCellClass = nil;
}
- (id <NSMenuItem>)addItemWithTitle:(NSString*)aString
action:(SEL)aSelector
keyEquivalent:(NSString*)charCode
action:(SEL)aSelector
keyEquivalent:(NSString*)charCode
{
return [self insertItemWithTitle:aString
action:aSelector
keyEquivalent:charCode
atIndex:[[menuCells itemArray] count]];
action:aSelector
keyEquivalent:charCode
atIndex:[[menuCells itemArray] count]];
}
- (id <NSMenuItem>)insertItemWithTitle:(NSString*)aString
action:(SEL)aSelector
keyEquivalent:(NSString*)charCode
atIndex:(unsigned int)index
action:(SEL)aSelector
keyEquivalent:(NSString*)charCode
atIndex:(unsigned int)index
{
id menuCell = [menuCells insertItemWithTitle:aString
action:aSelector
keyEquivalent:charCode
atIndex:index];
[self _menuChanged];
action:aSelector
keyEquivalent:charCode
atIndex:index];
menuHasChanged = YES; // menu needs update
return menuCell;
}
@ -369,7 +367,7 @@ static Class menuCellClass = nil;
- (void)removeItem:(id <NSMenuItem>)anItem
{
[menuCells removeItem:anItem];
[self _menuChanged];
menuHasChanged = YES; // menu needs update
}
- (NSArray*)itemArray
@ -592,7 +590,8 @@ static Class menuCellClass = nil;
/* Reenable displaying of menus */
[self setMenuChangedMessagesEnabled:YES];
[self sizeToFit];
if(menuHasChanged) // resize if menu
[self sizeToFit]; // has been changed
}
- (void)performActionForItem:(id <NSMenuItem>)cell