mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-31 12:00:48 +00:00
* NSApplication.m in init set default for main_menu, windows_need_update. * NSApplication.m in run added support for OPENSTEP autodisplay mechanism. * NSApplication.m _eventMatchingMask: reformat. * NSApplication.m nextEventMatchingMask:untilDate:inMode:dequeue: move calls to _flushWindows to XDPS backend. * NSApplication.m implemented updateWindows. * NSApplication.m implemented setWindowsNeedUpdate:. * NSApplication.m setMainMenu: test for menu prior to release. * NSActionCell.m removed setState: method. * NSActionCell.m copyWithZone: optimized ivar copying. * NSButtonCell.m added _init and moved common defaults to this method. * NSButtonCell.m initImageCell: and initTextCell: minor optimizations. * NSButtonCell.m setAlternateTitle: optimize and use ASSIGN macro. * NSButtonCell.m setKeyEquivalent: remove [copy release]. * NSButtonCell.m setKeyEquivalentFont:size: optimize. * NSButtonCell.m copyWithZone: optimized ivar copying where possible. * NSCell.m _init removed call to [super init]. * NSCell.m initTextCell: removed duplicate default initializers. * NSCell.m setImage: rewrote to use ASSIGN macro. * NSCell.m setDoubleValue: rewrote to use ASSIGN macro. * NSCell.m setFloatValue: rewrote to use ASSIGN macro. * NSCell.m setIntValue: rewrote to use ASSIGN macro. * NSCell.m setStringValue: rewrote to use ASSIGN macro. * NSCell.m setFont: rewrote to use ASSIGN macro. * NSCell.m setRepresentedObject: rewrote to use ASSIGN macro. * NSCell.m copyWithZone: optimized ivar copying where possible. * NSClipView.m viewBoundsChanged: minor optimization. * NSClipView.m viewFrameChanged: minor optimization. * NSClipView.m scaleUnitSquareToSize: minor optimization. * NSClipView.m setBoundsOrigin: minor optimization. * NSClipView.m setBoundsSize: minor optimization. * NSClipView.m setFrameSize: minor optimization. * NSClipView.m setFrameOrigin: minor optimization. * NSClipView.m setFrame: minor optimization. * NSClipView.m translateOriginToPoint: minor optimization. * NSMatrix.m eliminate retain/release of selected cell via ASSIGN. * NSMatrix.m initWithFrame: remove duplicate setting of selected row and column. * NSMatrix.m removeColumn: rewrite so that col is removed before new selection is attempted (needed because selected cell is not retained). * NSMatrix.m removeRow: rewrite so that row is removed before new selection is attempted (needed because selected cell is not retained). * NSMatrix.m deselectAllCells per OS spec try to select a cell at end if empty selection is not allowed. * NSMatrix.m deselectSelectedCell set default selected row/col to 0. * NSMatrix.m mouseDown: optimize for new drawing behaviour. * NSMenu.m setSelectedCell: eliminate use of retain/release of selected cell via ASSIGN. * NSMenuItem.m copyWithZone: optimized ivar copying where possible. * NSMenuItem.m dealloc minor optimization. * NSMenuItem.m setTarget: minor optimization. * NSScroller.m trackScrollButtons: heavily optimized. * NSScroller.m sendAction: reimplemented to use sendAction: per spec also optimized. * NSText.m implemented init method. * NSText.m initWithFrame: fixed initialization of ivars which are released to retain. * NSText.m dealloc add release of retained ivars. * NSView.m dealloc add release of retained ivars. * NSView.m displayRect: and _addSubviewForNeedingDisplay reformatted code and rewrote comments. * NSWindow.m setFrame:display: rewrote for clarity. * NSWindow.m implemented update method per OPENSTEP spec. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@2941 72102866-910b-0410-8b05-ffd578937521
159 lines
3.3 KiB
Objective-C
159 lines
3.3 KiB
Objective-C
/*
|
|
NSMenuItem.m
|
|
|
|
The menu cell class.
|
|
|
|
Copyright (C) 1996 Free Software Foundation, Inc.
|
|
|
|
Author: Ovidiu Predescu <ovidiu@net-community.com>
|
|
Date: May 1997
|
|
|
|
This file is part of the GNUstep GUI Library.
|
|
|
|
This library is free software; you can redistribute it and/or
|
|
modify it under the terms of the GNU Library General Public
|
|
License as published by the Free Software Foundation; either
|
|
version 2 of the License, or (at your option) any later version.
|
|
|
|
This library is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Library General Public License for more details.
|
|
|
|
You should have received a copy of the GNU Library General Public
|
|
License along with this library; see the file COPYING.LIB.
|
|
If not, write to the Free Software Foundation,
|
|
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
*/
|
|
|
|
#include <gnustep/gui/config.h>
|
|
#include <Foundation/NSString.h>
|
|
#include <Foundation/NSUserDefaults.h>
|
|
#include <Foundation/NSDictionary.h>
|
|
#include <AppKit/NSMenuItem.h>
|
|
#include <AppKit/NSMenu.h>
|
|
|
|
#define ASSIGN(variable, value) \
|
|
[value retain]; \
|
|
[variable release]; \
|
|
variable = value;
|
|
|
|
static BOOL usesUserKeyEquivalents = YES;
|
|
|
|
@implementation NSMenuItem
|
|
|
|
+ (void)initialize
|
|
{
|
|
if (self == [NSMenuItem class])
|
|
{
|
|
// Initial version
|
|
[self setVersion:2];
|
|
}
|
|
}
|
|
|
|
+ (void)setUsesUserKeyEquivalents:(BOOL)flag
|
|
{
|
|
usesUserKeyEquivalents = flag;
|
|
}
|
|
|
|
+ (BOOL)usesUserKeyEquivalents
|
|
{
|
|
return usesUserKeyEquivalents;
|
|
}
|
|
|
|
- init
|
|
{
|
|
[self setAlignment:NSLeftTextAlignment];
|
|
return self;
|
|
}
|
|
|
|
- (void)dealloc
|
|
{
|
|
NSDebugLog (@"NSMenuItem '%@' dealloc", [self title]);
|
|
|
|
[representedObject release];
|
|
if (hasSubmenu)
|
|
[target release];
|
|
[super dealloc];
|
|
}
|
|
|
|
- (id)copyWithZone:(NSZone*)zone
|
|
{
|
|
NSMenuItem* copy = [super copyWithZone:zone];
|
|
|
|
NSDebugLog (@"menu item '%@' copy", [self title]);
|
|
copy->representedObject = [representedObject retain];
|
|
copy->hasSubmenu = hasSubmenu;
|
|
if (hasSubmenu) {
|
|
id submenu = [[target copyWithZone:zone] autorelease];
|
|
copy->target = [submenu retain];
|
|
}
|
|
|
|
return copy;
|
|
}
|
|
|
|
- (void)setTarget:(id)anObject
|
|
{
|
|
hasSubmenu = anObject && [anObject isKindOfClass:[NSMenu class]];
|
|
if (hasSubmenu) {
|
|
[anObject retain];
|
|
[target release];
|
|
}
|
|
[super setTarget:anObject];
|
|
}
|
|
|
|
- (void)setTitle:(NSString*)aString
|
|
{
|
|
[super setStringValue:aString];
|
|
}
|
|
|
|
- (NSString*)title
|
|
{
|
|
return [self stringValue];
|
|
}
|
|
|
|
- (BOOL)hasSubmenu
|
|
{
|
|
return hasSubmenu;
|
|
}
|
|
|
|
- (BOOL)isEnabled
|
|
{
|
|
if (hasSubmenu)
|
|
return YES;
|
|
else
|
|
return [super isEnabled];
|
|
}
|
|
|
|
- (NSString*)keyEquivalent
|
|
{
|
|
if (usesUserKeyEquivalents)
|
|
return [self userKeyEquivalent];
|
|
else
|
|
return [super keyEquivalent];
|
|
}
|
|
|
|
- (NSString*)userKeyEquivalent
|
|
{
|
|
NSString* userKeyEquivalent = [[[[NSUserDefaults standardUserDefaults]
|
|
persistentDomainForName:NSGlobalDomain]
|
|
objectForKey:@"NSCommandKeys"]
|
|
objectForKey:[self stringValue]];
|
|
|
|
if (!userKeyEquivalent)
|
|
userKeyEquivalent = [super keyEquivalent];
|
|
|
|
return userKeyEquivalent;
|
|
}
|
|
|
|
- (void)setRepresentedObject:(id)anObject
|
|
{
|
|
ASSIGN(representedObject, anObject);
|
|
}
|
|
|
|
- (id)representedObject
|
|
{
|
|
return representedObject;
|
|
}
|
|
|
|
@end
|