mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-23 20:01:11 +00:00
Added documentation. Refined fix to GSNibTemplates.m concerning memory leak. More improvements to follow. GJC
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@18281 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
617334d4fa
commit
75d4c1baa5
3 changed files with 289 additions and 35 deletions
|
@ -1,3 +1,10 @@
|
|||
2003-12-28 19:33 Gregory John Casamento <greg_casamento@yahoo.com>
|
||||
|
||||
* Headers/AppKit/NSMenuItem.h: Added documentation for many
|
||||
of the methods in NSMenuItem.
|
||||
* Source/GSNibTemplates.m: Further refinements on the earlier
|
||||
memory leak fix.
|
||||
|
||||
2003-12-25 00:03 Gregory John Casamento <greg_casamento@yahoo.com>
|
||||
|
||||
* Source/NSDataLinkPanel.m: Changed to use the correct method
|
||||
|
|
|
@ -44,50 +44,280 @@
|
|||
*/
|
||||
@protocol NSMenuItem <NSCopying, NSCoding, NSObject>
|
||||
|
||||
/**
|
||||
<p> Returns a seperator. This is just a blank menu item which serves
|
||||
to divide the menu into seperate parts.
|
||||
</p>
|
||||
*/
|
||||
+ (id<NSMenuItem>) separatorItem;
|
||||
|
||||
/**
|
||||
<p>
|
||||
Sets a flag that, when set to <code>YES</code>, objects of this class will use user defined key equivalents.
|
||||
</p>
|
||||
*/
|
||||
+ (void) setUsesUserKeyEquivalents: (BOOL)flag;
|
||||
|
||||
/**
|
||||
<p> Returns a flag which indicates if the receiver will use user defined
|
||||
key equivalents.
|
||||
</p>
|
||||
*/
|
||||
+ (BOOL) usesUserKeyEquivalents;
|
||||
|
||||
/**
|
||||
<p>
|
||||
Returns the action of the receiver.
|
||||
</p>
|
||||
*/
|
||||
- (SEL) action;
|
||||
|
||||
/**
|
||||
<p>
|
||||
Returns a boolean indicating if the receiver has a sub menu.
|
||||
</p>
|
||||
*/
|
||||
- (BOOL) hasSubmenu;
|
||||
|
||||
/**
|
||||
<p>
|
||||
Returns the image to be displayed in the receiver.
|
||||
</p>
|
||||
*/
|
||||
- (NSImage*) image;
|
||||
|
||||
/**
|
||||
<p>
|
||||
Initializes the receiver with <var>aString</var> as the title.
|
||||
The method called with the menu is selected is represented by <var>aSelector</var>.
|
||||
The key equivalent which can be used to invoke this menu item is represented by
|
||||
<var>charCode</var>.
|
||||
</p>
|
||||
*/
|
||||
- (id) initWithTitle: (NSString*)aString
|
||||
action: (SEL)aSelector
|
||||
keyEquivalent: (NSString*)charCode;
|
||||
|
||||
/**
|
||||
<p>
|
||||
Returns <code>YES</code> if the receiver is enabled.
|
||||
</p>
|
||||
*/
|
||||
- (BOOL) isEnabled;
|
||||
|
||||
/**
|
||||
<p>
|
||||
Returns a boolean indicating if the receiver is a separator.
|
||||
</p>
|
||||
*/
|
||||
- (BOOL) isSeparatorItem;
|
||||
|
||||
/**
|
||||
<p>
|
||||
Returns the key equivalent of the receiver.
|
||||
</p>
|
||||
*/
|
||||
- (NSString*) keyEquivalent;
|
||||
|
||||
/**
|
||||
<p>
|
||||
Returns the key equivalent mask.
|
||||
</p>
|
||||
*/
|
||||
- (unsigned int) keyEquivalentModifierMask;
|
||||
|
||||
/**
|
||||
<p>
|
||||
Returns the menu to which this menu item is connected.
|
||||
</p>
|
||||
*/
|
||||
- (NSMenu*) menu;
|
||||
|
||||
/**
|
||||
<p>
|
||||
Returns the image to be displayed when the receiver is in the "Mixed" state.
|
||||
</p>
|
||||
*/
|
||||
- (NSImage*) mixedStateImage;
|
||||
- (NSString*) mnemonic;
|
||||
- (unsigned) mnemonicLocation;
|
||||
|
||||
/**
|
||||
<p>
|
||||
Returns the image to be displayed when the receiver is in the "Off" state.
|
||||
</p>
|
||||
*/
|
||||
- (NSImage*) offStateImage;
|
||||
|
||||
/**
|
||||
<p>
|
||||
Returns the image to be displayed when the receiver is in the "On" state.
|
||||
</p>
|
||||
*/
|
||||
- (NSImage*) onStateImage;
|
||||
|
||||
/**
|
||||
<p>
|
||||
Returns the object represented by the reciever.
|
||||
</p>
|
||||
*/
|
||||
- (id) representedObject;
|
||||
|
||||
/**
|
||||
<p>
|
||||
Sets the action as <var>aSelector</var> on the receiver.
|
||||
</p>
|
||||
*/
|
||||
- (void) setAction: (SEL)aSelector;
|
||||
|
||||
/**
|
||||
<p>
|
||||
Set the receiver to be enabled.
|
||||
</p>
|
||||
*/
|
||||
- (void) setEnabled: (BOOL)flag;
|
||||
|
||||
/**
|
||||
<p>
|
||||
Sets the image to be displayed in the receiver.
|
||||
</p>
|
||||
*/
|
||||
- (void) setImage: (NSImage*)menuImage;
|
||||
|
||||
/**
|
||||
<p>
|
||||
Sets the key equivalent of the receiver.
|
||||
</p>
|
||||
*/
|
||||
- (void) setKeyEquivalent: (NSString*)aKeyEquivalent;
|
||||
|
||||
/**
|
||||
<p>
|
||||
Sets the modfier for the key equivalent. These masks indicate if the
|
||||
key equivalent requires ALT, Control or other key modifiers.
|
||||
</p>
|
||||
*/
|
||||
- (void) setKeyEquivalentModifierMask: (unsigned int)mask;
|
||||
|
||||
/**
|
||||
<p> Sets the menu which this item belongs to. This method does not retain the
|
||||
object represented by <var>menu</var>.
|
||||
</p>
|
||||
*/
|
||||
- (void) setMenu: (NSMenu*)menu;
|
||||
|
||||
/**
|
||||
<p>
|
||||
Sets the image to be displayed when the receiver is in the "Mixed" state.
|
||||
</p>
|
||||
*/
|
||||
- (void) setMixedStateImage: (NSImage*)image;
|
||||
- (void) setMnemonicLocation: (unsigned) location;
|
||||
|
||||
/**
|
||||
<p>
|
||||
Sets the image to be displayed when the receiver is in the "Off" state.
|
||||
</p>
|
||||
*/
|
||||
- (void) setOffStateImage: (NSImage*)image;
|
||||
|
||||
/**
|
||||
<p>
|
||||
Sets the image to be displayed when the receiver is in the "On" state.
|
||||
</p>
|
||||
*/
|
||||
- (void) setOnStateImage: (NSImage*)image;
|
||||
|
||||
/**
|
||||
<p>
|
||||
Sets the object represented by the reciever to <var>anObject</var>.
|
||||
</p>
|
||||
*/
|
||||
- (void) setRepresentedObject: (id)anObject;
|
||||
|
||||
/**
|
||||
<p>
|
||||
Sets the state of the the receiver.
|
||||
</p>
|
||||
*/
|
||||
- (void) setState: (int)state;
|
||||
|
||||
/**
|
||||
<p>
|
||||
Sets the submenu of the receiver. This method does retain the
|
||||
<var>submenu</var> object.
|
||||
</p>
|
||||
*/
|
||||
- (void) setSubmenu: (NSMenu*)submenu;
|
||||
|
||||
/**
|
||||
<p>
|
||||
Sets the tag of the reciever as <var>anInt</var>.
|
||||
</p>
|
||||
*/
|
||||
- (void) setTag: (int)anInt;
|
||||
|
||||
/**
|
||||
<p>
|
||||
Sets the target as <var>anObject</var> on the receiver.
|
||||
</p>
|
||||
*/
|
||||
- (void) setTarget: (id)anObject;
|
||||
|
||||
/**
|
||||
<p>
|
||||
Sets the title of the menu, represented by <var>aString</var>.
|
||||
</p>
|
||||
*/
|
||||
- (void) setTitle: (NSString*)aString;
|
||||
- (void) setTitleWithMnemonic: (NSString*)stringWithAmpersand;
|
||||
|
||||
/**
|
||||
<p>
|
||||
Returns the state of the receiver.
|
||||
</p>
|
||||
*/
|
||||
- (int) state;
|
||||
/**
|
||||
<p>
|
||||
Returns the attached submenu.
|
||||
</p>
|
||||
*/
|
||||
- (NSMenu*) submenu;
|
||||
|
||||
/**
|
||||
<p>
|
||||
Returns the tag of the receiver.
|
||||
</p>
|
||||
*/
|
||||
- (int) tag;
|
||||
|
||||
/**
|
||||
<p>
|
||||
Returns the target of the receiver.
|
||||
</p>
|
||||
*/
|
||||
- (id) target;
|
||||
|
||||
/**
|
||||
<p>
|
||||
Returns the menu's title.
|
||||
</p>
|
||||
*/
|
||||
- (NSString*) title;
|
||||
|
||||
/**
|
||||
<p>
|
||||
Returns the user defined key equivalent modifier.
|
||||
</p>
|
||||
*/
|
||||
- (unsigned int) userKeyEquivalentModifierMask;
|
||||
|
||||
/**
|
||||
<p>
|
||||
Returns the key equivalent defined by the users defaults.
|
||||
</p>
|
||||
*/
|
||||
- (NSString*) userKeyEquivalent;
|
||||
|
||||
@end
|
||||
|
|
|
@ -42,16 +42,17 @@
|
|||
#include <Foundation/NSString.h>
|
||||
#include <Foundation/NSUserDefaults.h>
|
||||
#include <Foundation/NSKeyValueCoding.h>
|
||||
#include "AppKit/NSMenu.h"
|
||||
#include "AppKit/NSControl.h"
|
||||
#include "AppKit/NSImage.h"
|
||||
#include "AppKit/NSSound.h"
|
||||
#include "AppKit/NSView.h"
|
||||
#include "AppKit/NSTextView.h"
|
||||
#include "AppKit/NSWindow.h"
|
||||
#include <AppKit/NSMenu.h>
|
||||
#include <AppKit/NSImage.h>
|
||||
#include <AppKit/NSSound.h>
|
||||
#include <AppKit/NSView.h>
|
||||
#include <AppKit/NSTextView.h>
|
||||
#include <AppKit/NSWindow.h>
|
||||
#include <AppKit/NSNibLoading.h>
|
||||
#include <AppKit/NSNibConnector.h>
|
||||
#include <AppKit/NSApplication.h>
|
||||
#include <AppKit/NSTableColumn.h>
|
||||
#include <AppKit/NSTabViewItem.h>
|
||||
#include <GNUstepBase/GSObjCRuntime.h>
|
||||
#include <GNUstepGUI/GSNibTemplates.h>
|
||||
|
||||
|
@ -163,19 +164,20 @@ static const int currentVersion = 1; // GSNibItem version number...
|
|||
while ((key = [enumerator nextObject]) != nil)
|
||||
{
|
||||
if ([context objectForKey: key] == nil ||
|
||||
([key isEqualToString: @"NSOwner"] && // we want to send the message to the owner
|
||||
[key isEqualToString: @"NSWindowsMenu"] == NO && // we don't want to send a message to these menus twice,
|
||||
[key isEqualToString: @"NSServicesMenu"] == NO && // if they're custom classes.
|
||||
[key isEqualToString: @"NSVisible"] == NO && // also exclude any other special parts of the nameTable.
|
||||
[key isEqualToString: @"NSDeferred"] == NO &&
|
||||
[key isEqualToString: @"NSTopLevelObjects"] == NO))
|
||||
[key isEqualToString: @"NSOwner"]) // we want to send the message to the owner
|
||||
{
|
||||
id o;
|
||||
|
||||
o = [nameTable objectForKey: key];
|
||||
if ([o respondsToSelector: @selector(awakeFromNib)])
|
||||
if([key isEqualToString: @"NSWindowsMenu"] == NO && // we don't want to send a message to these menus twice,
|
||||
[key isEqualToString: @"NSServicesMenu"] == NO && // if they're custom classes.
|
||||
[key isEqualToString: @"NSVisible"] == NO && // also exclude any other special parts of the nameTable.
|
||||
[key isEqualToString: @"NSDeferred"] == NO &&
|
||||
[key isEqualToString: @"NSTopLevelObjects"] == NO &&
|
||||
[key isEqualToString: @"GSCustomClassMap"] == NO)
|
||||
{
|
||||
[o awakeFromNib];
|
||||
id o = [nameTable objectForKey: key];
|
||||
if ([o respondsToSelector: @selector(awakeFromNib)])
|
||||
{
|
||||
[o awakeFromNib];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -203,21 +205,28 @@ static const int currentVersion = 1; // GSNibItem version number...
|
|||
enumerator = [nameTable keyEnumerator];
|
||||
while ((key = [enumerator nextObject]) != nil)
|
||||
{
|
||||
if ([context objectForKey: key] == nil ||
|
||||
([key isEqualToString: @"NSOwner"] == NO && // dont retain the owner.
|
||||
[key isEqualToString: @"NSWindowsMenu"] == NO && // exclude special sections.
|
||||
[key isEqualToString: @"NSServicesMenu"] == NO &&
|
||||
[key isEqualToString: @"NSVisible"] == NO &&
|
||||
[key isEqualToString: @"NSDeferred"] == NO &&
|
||||
[key isEqualToString: @"NSTopLevelObjects"] == NO))
|
||||
if ([context objectForKey: key] == nil &&
|
||||
[key isEqualToString: @"NSWindowsMenu"] == NO && // exclude special sections.
|
||||
[key isEqualToString: @"NSServicesMenu"] == NO &&
|
||||
[key isEqualToString: @"NSVisible"] == NO &&
|
||||
[key isEqualToString: @"NSDeferred"] == NO &&
|
||||
[key isEqualToString: @"NSTopLevelObjects"] == NO &&
|
||||
[key isEqualToString: @"GSCustomClassMap"] == NO)
|
||||
{
|
||||
id o = [nameTable objectForKey: key];
|
||||
id o = [nameTable objectForKey: key];
|
||||
// RETAIN all top-level items...
|
||||
if (([o isKindOfClass: [NSMenu class]] == YES &&
|
||||
[key isEqualToString: @"NSMenu"] == YES) || // the main menu...
|
||||
([o isKindOfClass: [NSWindow class]] == YES) || // any windows...
|
||||
([o isKindOfClass: [NSObject class]] == YES &&
|
||||
[o isKindOfClass: [NSView class]] == NO)) // any objects which are not views..
|
||||
([o isKindOfClass: [NSObject class]] == YES && // any controllers...
|
||||
[o isKindOfClass: [NSCell class]] == NO && // no cells
|
||||
[o isKindOfClass: [NSMenu class]] == NO && // no menus, they're handled above
|
||||
[o isKindOfClass: [NSMenuItem class]] == NO && // no menu items
|
||||
[o isKindOfClass: [NSTableColumn class]] == NO && // no table columns
|
||||
[o isKindOfClass: [NSTabViewItem class]] == NO && // no table columns
|
||||
[o isKindOfClass: [NSWindow class]] == NO && // no tab view items
|
||||
[o isKindOfClass: [NSView class]] == NO // no tab view items
|
||||
))
|
||||
{
|
||||
if(topLevelObjects == nil)
|
||||
{
|
||||
|
@ -236,7 +245,7 @@ static const int currentVersion = 1; // GSNibItem version number...
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* See if there are objects that should be made visible.
|
||||
*/
|
||||
|
@ -363,15 +372,19 @@ static const int currentVersion = 1; // GSNibItem version number...
|
|||
|
||||
obj = [cls allocWithZone: [self zone]];
|
||||
if (theFrame.size.height > 0 && theFrame.size.width > 0)
|
||||
obj = [obj initWithFrame: theFrame];
|
||||
{
|
||||
obj = [obj initWithFrame: theFrame];
|
||||
}
|
||||
else
|
||||
obj = [obj init];
|
||||
{
|
||||
obj = [obj init];
|
||||
}
|
||||
|
||||
if ([obj respondsToSelector: @selector(setAutoresizingMask:)])
|
||||
{
|
||||
[obj setAutoresizingMask: mask];
|
||||
}
|
||||
|
||||
|
||||
RELEASE(self);
|
||||
return obj;
|
||||
}
|
||||
|
@ -392,10 +405,14 @@ static const int currentVersion = 1; // GSNibItem version number...
|
|||
|
||||
obj = [cls allocWithZone: [self zone]];
|
||||
if (theFrame.size.height > 0 && theFrame.size.width > 0)
|
||||
obj = [obj initWithFrame: theFrame];
|
||||
{
|
||||
obj = [obj initWithFrame: theFrame];
|
||||
}
|
||||
else
|
||||
obj = [obj init];
|
||||
|
||||
{
|
||||
obj = [obj init];
|
||||
}
|
||||
|
||||
RELEASE(self);
|
||||
return obj;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue