mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-31 18:50:48 +00:00
* Headers/Additions/GNUstepGUI/GSNibLoading.h: Added methods to header
which were added during refactoring. * Source/GSNibLoading.m: Corrections to NSCustomView, refactoring. Changes to initialization logic to call awakeFromNib. * Source/NSBundleAdditions.m: Cleanup to move code to the nib loading code. * Source/NSClipView.m: Added assertion to guarantee that no NSCustomView is unarchived at time of initWithCoder: being called. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@27298 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
90cc29e4e5
commit
a7a1beee9a
5 changed files with 374 additions and 277 deletions
11
ChangeLog
11
ChangeLog
|
@ -1,3 +1,14 @@
|
||||||
|
2008-12-15 18:37-EST Gregory John Casamento <greg_casamento@yahoo.com>
|
||||||
|
|
||||||
|
* Headers/Additions/GNUstepGUI/GSNibLoading.h: Added methods to header
|
||||||
|
which were added during refactoring.
|
||||||
|
* Source/GSNibLoading.m: Corrections to NSCustomView, refactoring.
|
||||||
|
Changes to initialization logic to call awakeFromNib.
|
||||||
|
* Source/NSBundleAdditions.m: Cleanup to move code to the nib loading
|
||||||
|
code.
|
||||||
|
* Source/NSClipView.m: Added assertion to guarantee that no
|
||||||
|
NSCustomView is unarchived at time of initWithCoder: being called.
|
||||||
|
|
||||||
2008-12-15 Fred Kiefer <FredKiefer@gmx.de>
|
2008-12-15 Fred Kiefer <FredKiefer@gmx.de>
|
||||||
|
|
||||||
* Source/NSMenuItemCell.m (-_keyEquivalentString): Ignore function
|
* Source/NSMenuItemCell.m (-_keyEquivalentString): Ignore function
|
||||||
|
|
|
@ -50,9 +50,14 @@
|
||||||
@protocol OSXNibTemplate
|
@protocol OSXNibTemplate
|
||||||
- (void) setClassName: (NSString *)className;
|
- (void) setClassName: (NSString *)className;
|
||||||
- (NSString *)className;
|
- (NSString *)className;
|
||||||
|
- (void) setRealObject: (id)o;
|
||||||
- (id) realObject;
|
- (id) realObject;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
@protocol GSNibLoading
|
||||||
|
- (id) nibInstantiate;
|
||||||
|
@end
|
||||||
|
|
||||||
typedef struct _GSWindowTemplateFlags
|
typedef struct _GSWindowTemplateFlags
|
||||||
{
|
{
|
||||||
#ifdef WORDS_BIGENDIAN
|
#ifdef WORDS_BIGENDIAN
|
||||||
|
@ -110,7 +115,7 @@ typedef struct _GSWindowTemplateFlags
|
||||||
* when it's unarchived and second, it holds certain attributes (but doesn't set them
|
* when it's unarchived and second, it holds certain attributes (but doesn't set them
|
||||||
* on the window, when the window is being edited in the application builder.
|
* on the window, when the window is being edited in the application builder.
|
||||||
*/
|
*/
|
||||||
@interface NSWindowTemplate : NSObject <OSXNibTemplate, NSCoding>
|
@interface NSWindowTemplate : NSObject <OSXNibTemplate, NSCoding, GSNibLoading>
|
||||||
{
|
{
|
||||||
NSBackingStoreType _backingStoreType;
|
NSBackingStoreType _backingStoreType;
|
||||||
NSSize _maxSize;
|
NSSize _maxSize;
|
||||||
|
@ -152,7 +157,6 @@ typedef struct _GSWindowTemplateFlags
|
||||||
- (NSRect)windowRect;
|
- (NSRect)windowRect;
|
||||||
- (void) setScreenRect: (NSRect)rect;
|
- (void) setScreenRect: (NSRect)rect;
|
||||||
- (NSRect) screenRect;
|
- (NSRect) screenRect;
|
||||||
- (id) realObject;
|
|
||||||
- (void) setView: (id)view;
|
- (void) setView: (id)view;
|
||||||
- (id) view;
|
- (id) view;
|
||||||
- (Class) baseWindowClass;
|
- (Class) baseWindowClass;
|
||||||
|
@ -163,6 +167,8 @@ typedef struct _GSWindowTemplateFlags
|
||||||
NSString *_className;
|
NSString *_className;
|
||||||
id _realObject;
|
id _realObject;
|
||||||
}
|
}
|
||||||
|
- (id) initWithObject: (id)o
|
||||||
|
className: (NSString *)name;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@interface NSTextTemplate : NSViewTemplate
|
@interface NSTextTemplate : NSViewTemplate
|
||||||
|
@ -189,10 +195,9 @@ typedef struct _GSWindowTemplateFlags
|
||||||
}
|
}
|
||||||
- (void) setClassName: (NSString *)name;
|
- (void) setClassName: (NSString *)name;
|
||||||
- (NSString *)className;
|
- (NSString *)className;
|
||||||
- (id)nibInstantiate;
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@interface NSCustomObject : NSObject <NSCoding>
|
@interface NSCustomObject : NSObject <NSCoding, GSNibLoading>
|
||||||
{
|
{
|
||||||
NSString *_className;
|
NSString *_className;
|
||||||
NSString *_extension;
|
NSString *_extension;
|
||||||
|
@ -202,11 +207,9 @@ typedef struct _GSWindowTemplateFlags
|
||||||
- (NSString *)className;
|
- (NSString *)className;
|
||||||
- (void) setExtension: (NSString *)ext;
|
- (void) setExtension: (NSString *)ext;
|
||||||
- (NSString *)extension;
|
- (NSString *)extension;
|
||||||
- (void) setObject: (id)obj;
|
|
||||||
- (id)object;
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@interface NSCustomView : NSView
|
@interface NSCustomView : NSView <GSNibLoading>
|
||||||
{
|
{
|
||||||
NSString *_className;
|
NSString *_className;
|
||||||
NSString *_extension;
|
NSString *_extension;
|
||||||
|
@ -217,7 +220,6 @@ typedef struct _GSWindowTemplateFlags
|
||||||
- (NSString *)className;
|
- (NSString *)className;
|
||||||
- (void) setExtension: (NSString *)view;
|
- (void) setExtension: (NSString *)view;
|
||||||
- (NSString *)extension;
|
- (NSString *)extension;
|
||||||
- (id)nibInstantiate;
|
|
||||||
- (id)nibInstantiateWithCoder: (NSCoder *)coder;
|
- (id)nibInstantiateWithCoder: (NSCoder *)coder;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
@ -230,7 +232,6 @@ typedef struct _GSWindowTemplateFlags
|
||||||
- (NSString *)className;
|
- (NSString *)className;
|
||||||
- (void) setResourceName: (NSString *)view;
|
- (void) setResourceName: (NSString *)view;
|
||||||
- (NSString *)resourceName;
|
- (NSString *)resourceName;
|
||||||
- (id)nibInstantiate;
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@interface NSClassSwapper : NSObject <NSCoding>
|
@interface NSClassSwapper : NSObject <NSCoding>
|
||||||
|
@ -271,7 +272,6 @@ typedef struct _GSWindowTemplateFlags
|
||||||
NSMutableSet *_topLevelObjects;
|
NSMutableSet *_topLevelObjects;
|
||||||
}
|
}
|
||||||
- (id) instantiateObject: (id)obj;
|
- (id) instantiateObject: (id)obj;
|
||||||
- (void) nibInstantiateWithOwner: (id)owner;
|
|
||||||
- (void) nibInstantiateWithOwner: (id)owner topLevelObjects: (NSMutableArray *)toplevel;
|
- (void) nibInstantiateWithOwner: (id)owner topLevelObjects: (NSMutableArray *)toplevel;
|
||||||
- (id) objectForName: (NSString *)name;
|
- (id) objectForName: (NSString *)name;
|
||||||
- (NSString *) nameForObject: (id)name;
|
- (NSString *) nameForObject: (id)name;
|
||||||
|
|
|
@ -84,6 +84,10 @@ static BOOL _isInInterfaceBuilder = NO;
|
||||||
- (void) instantiateWithInstantiator: (id<GSInstantiator>)instantiator;
|
- (void) instantiateWithInstantiator: (id<GSInstantiator>)instantiator;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
@interface NSNibConnector (NibCompatibility)
|
||||||
|
- (void) instantiateWithInstantiator: (id<GSInstantiator>)instantiator;
|
||||||
|
@end
|
||||||
|
|
||||||
@interface NSDecimalNumberPlaceholder : NSObject
|
@interface NSDecimalNumberPlaceholder : NSObject
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
@ -375,8 +379,6 @@ static BOOL _isInInterfaceBuilder = NO;
|
||||||
if (_realObject == nil)
|
if (_realObject == nil)
|
||||||
{
|
{
|
||||||
Class aClass;
|
Class aClass;
|
||||||
NSEnumerator *en;
|
|
||||||
id v = nil;
|
|
||||||
|
|
||||||
if ([NSClassSwapper isInInterfaceBuilder])
|
if ([NSClassSwapper isInInterfaceBuilder])
|
||||||
{
|
{
|
||||||
|
@ -425,16 +427,6 @@ static BOOL _isInInterfaceBuilder = NO;
|
||||||
[_realObject setFrame: [NSWindow frameRectForContentRect: [self windowRect]
|
[_realObject setFrame: [NSWindow frameRectForContentRect: [self windowRect]
|
||||||
styleMask: [self windowStyle]]
|
styleMask: [self windowStyle]]
|
||||||
display: NO];
|
display: NO];
|
||||||
|
|
||||||
// swap out any views which need to be swapped...
|
|
||||||
en = [[[_realObject contentView] subviews] objectEnumerator];
|
|
||||||
while ((v = [en nextObject]) != nil)
|
|
||||||
{
|
|
||||||
if ([v respondsToSelector: @selector(nibInstantiate)])
|
|
||||||
{
|
|
||||||
[v nibInstantiate];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return _realObject;
|
return _realObject;
|
||||||
}
|
}
|
||||||
|
@ -530,6 +522,11 @@ static BOOL _isInInterfaceBuilder = NO;
|
||||||
return _screenRect;
|
return _screenRect;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void) setRealObject: (id)o
|
||||||
|
{
|
||||||
|
ASSIGN(_realObject,o);
|
||||||
|
}
|
||||||
|
|
||||||
- (id) realObject
|
- (id) realObject
|
||||||
{
|
{
|
||||||
return _realObject;
|
return _realObject;
|
||||||
|
@ -571,6 +568,17 @@ static BOOL _isInInterfaceBuilder = NO;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (id) initWithObject: (id)o
|
||||||
|
className: (NSString *)name
|
||||||
|
{
|
||||||
|
if((self = [super init]) != nil)
|
||||||
|
{
|
||||||
|
[self setRealObject: o];
|
||||||
|
[self setClassName: name];
|
||||||
|
}
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
- (id) initWithCoder: (NSCoder *)coder
|
- (id) initWithCoder: (NSCoder *)coder
|
||||||
{
|
{
|
||||||
self = [super initWithCoder: coder];
|
self = [super initWithCoder: coder];
|
||||||
|
@ -612,12 +620,14 @@ static BOOL _isInInterfaceBuilder = NO;
|
||||||
if ([coder allowsKeyedCoding])
|
if ([coder allowsKeyedCoding])
|
||||||
{
|
{
|
||||||
[coder encodeObject: (id)_className forKey: @"NSClassName"];
|
[coder encodeObject: (id)_className forKey: @"NSClassName"];
|
||||||
|
[_realObject encodeWithCoder: coder];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
[NSException raise: NSInvalidArgumentException
|
||||||
|
format: @"Can't encode %@ with %@.",NSStringFromClass([self class]),
|
||||||
|
NSStringFromClass([coder class])];
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
- (id) nibInstantiate
|
|
||||||
{
|
|
||||||
return _realObject;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// setters and getters
|
// setters and getters
|
||||||
|
@ -631,6 +641,11 @@ static BOOL _isInInterfaceBuilder = NO;
|
||||||
return _className;
|
return _className;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void) setRealObject: (id)o
|
||||||
|
{
|
||||||
|
ASSIGN(_realObject, o);
|
||||||
|
}
|
||||||
|
|
||||||
- (id) realObject
|
- (id) realObject
|
||||||
{
|
{
|
||||||
return _realObject;
|
return _realObject;
|
||||||
|
@ -678,11 +693,6 @@ static BOOL _isInInterfaceBuilder = NO;
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
- (id) nibInstantiate
|
|
||||||
{
|
|
||||||
return nil;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void) setClassName: (NSString *)className
|
- (void) setClassName: (NSString *)className
|
||||||
{
|
{
|
||||||
ASSIGN(_menuClass, className);
|
ASSIGN(_menuClass, className);
|
||||||
|
@ -693,6 +703,11 @@ static BOOL _isInInterfaceBuilder = NO;
|
||||||
return _menuClass;
|
return _menuClass;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void) setRealObject: (id)o
|
||||||
|
{
|
||||||
|
ASSIGN(_realObject,o);
|
||||||
|
}
|
||||||
|
|
||||||
- (id) realObject
|
- (id) realObject
|
||||||
{
|
{
|
||||||
return _realObject;
|
return _realObject;
|
||||||
|
@ -720,12 +735,12 @@ static BOOL _isInInterfaceBuilder = NO;
|
||||||
return _extension;
|
return _extension;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) setObject: (id)obj
|
- (void) setRealObject: (id)obj
|
||||||
{
|
{
|
||||||
ASSIGN(_object, obj);
|
ASSIGN(_object, obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (id) object
|
- (id) realObject
|
||||||
{
|
{
|
||||||
return _object;
|
return _object;
|
||||||
}
|
}
|
||||||
|
@ -785,7 +800,8 @@ static BOOL _isInInterfaceBuilder = NO;
|
||||||
format: @"Unable to find class '%@'", _className];
|
format: @"Unable to find class '%@'", _className];
|
||||||
}
|
}
|
||||||
|
|
||||||
if(GSObjCIsKindOf(aClass, [NSApplication class]))
|
if(GSObjCIsKindOf(aClass, [NSApplication class]) ||
|
||||||
|
[_className isEqual: @"NSApplication"])
|
||||||
{
|
{
|
||||||
_object = [aClass sharedApplication];
|
_object = [aClass sharedApplication];
|
||||||
}
|
}
|
||||||
|
@ -799,12 +815,21 @@ static BOOL _isInInterfaceBuilder = NO;
|
||||||
|
|
||||||
- (void) awakeFromNib
|
- (void) awakeFromNib
|
||||||
{
|
{
|
||||||
if ([_object respondsToSelector: @selector(awakeFromNib)])
|
NSLog(@"Called awakeFromNib on an NSCustomObject instance: %@", self);
|
||||||
|
if([_object respondsToSelector: @selector(awakeFromNib)])
|
||||||
{
|
{
|
||||||
[_object awakeFromNib];
|
[_object awakeFromNib];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (NSString *) description
|
||||||
|
{
|
||||||
|
return [NSString stringWithFormat: @"<%s: %lx> = <<className: %@, object: %@>>",
|
||||||
|
GSClassNameFromObject(self),
|
||||||
|
(unsigned long)self,
|
||||||
|
_className,_object];
|
||||||
|
}
|
||||||
|
|
||||||
- (void) dealloc
|
- (void) dealloc
|
||||||
{
|
{
|
||||||
RELEASE(_className);
|
RELEASE(_className);
|
||||||
|
@ -1014,11 +1039,6 @@ static BOOL _isInInterfaceBuilder = NO;
|
||||||
return _resourceName;
|
return _resourceName;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (id)nibInstantiate
|
|
||||||
{
|
|
||||||
return self;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (id) initWithCoder: (NSCoder *)coder
|
- (id) initWithCoder: (NSCoder *)coder
|
||||||
{
|
{
|
||||||
id realObject = nil;
|
id realObject = nil;
|
||||||
|
@ -1271,6 +1291,14 @@ static BOOL _isInInterfaceBuilder = NO;
|
||||||
}
|
}
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
@implementation NSNibConnector (NibCompatibility)
|
||||||
|
- (void) instantiateWithInstantiator: (id<GSInstantiator>)instantiator
|
||||||
|
{
|
||||||
|
_src = [instantiator instantiateObject: _src];
|
||||||
|
_dst = [instantiator instantiateObject: _dst];
|
||||||
|
}
|
||||||
|
@end
|
||||||
|
|
||||||
@implementation NSNibControlConnector (NibCompatibility)
|
@implementation NSNibControlConnector (NibCompatibility)
|
||||||
- (void) instantiateWithInstantiator: (id<GSInstantiator>)instantiator
|
- (void) instantiateWithInstantiator: (id<GSInstantiator>)instantiator
|
||||||
{
|
{
|
||||||
|
@ -1288,159 +1316,6 @@ static BOOL _isInInterfaceBuilder = NO;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@implementation NSIBObjectData
|
@implementation NSIBObjectData
|
||||||
- (id)instantiateObject: (id)obj
|
|
||||||
{
|
|
||||||
id newObject = obj;
|
|
||||||
if ([obj respondsToSelector: @selector(nibInstantiate)])
|
|
||||||
{
|
|
||||||
newObject = [obj nibInstantiate];
|
|
||||||
}
|
|
||||||
return newObject;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void) nibInstantiateWithOwner: (id)owner
|
|
||||||
{
|
|
||||||
[self nibInstantiateWithOwner: owner topLevelObjects: nil];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void) nibInstantiateWithOwner: (id)owner topLevelObjects: (NSMutableArray *)topLevelObjects
|
|
||||||
{
|
|
||||||
NSEnumerator *en = [_connections objectEnumerator];
|
|
||||||
NSArray *objs = NSAllMapTableKeys([self names]);
|
|
||||||
id obj = nil;
|
|
||||||
id menu = nil;
|
|
||||||
|
|
||||||
// replace the owner with the actual instance provided.
|
|
||||||
[_root setObject: owner];
|
|
||||||
|
|
||||||
// iterate over connections, instantiate, and then establish them.
|
|
||||||
while ((obj = [en nextObject]) != nil)
|
|
||||||
{
|
|
||||||
if ([obj respondsToSelector: @selector(instantiateWithInstantiator:)])
|
|
||||||
{
|
|
||||||
[obj instantiateWithInstantiator: self];
|
|
||||||
[obj establishConnection];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// iterate over all objects instantiate windows, awaken objects and fill
|
|
||||||
// in top level array.
|
|
||||||
en = [objs objectEnumerator];
|
|
||||||
while ((obj = [en nextObject]) != nil)
|
|
||||||
{
|
|
||||||
// instantiate all windows and fill in the top level array.
|
|
||||||
if ([obj isKindOfClass: [NSWindowTemplate class]])
|
|
||||||
{
|
|
||||||
if ([obj realObject] == nil)
|
|
||||||
{
|
|
||||||
obj = [self instantiateObject: obj];
|
|
||||||
[topLevelObjects addObject: obj];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
id v = NSMapGet(_objects, obj);
|
|
||||||
if (v == nil || v == owner)
|
|
||||||
{
|
|
||||||
[topLevelObjects addObject: obj];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// awaken the object.
|
|
||||||
if ([obj respondsToSelector: @selector(awakeFromNib)])
|
|
||||||
{
|
|
||||||
[obj awakeFromNib];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// bring visible windows to front...
|
|
||||||
en = [_visibleWindows objectEnumerator];
|
|
||||||
while ((obj = [en nextObject]) != nil)
|
|
||||||
{
|
|
||||||
id w = [obj realObject];
|
|
||||||
[w orderFront: self];
|
|
||||||
}
|
|
||||||
|
|
||||||
// add the menu...
|
|
||||||
menu = [self objectForName: @"MainMenu"];
|
|
||||||
if (menu != nil)
|
|
||||||
{
|
|
||||||
menu = [self instantiateObject: menu];
|
|
||||||
[NSApp _setMainMenu: menu];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void) awakeWithContext: (NSDictionary *)context
|
|
||||||
{
|
|
||||||
NSMutableArray *tlo = [context objectForKey: @"NSTopLevelObjects"];
|
|
||||||
id owner = [context objectForKey: @"NSOwner"];
|
|
||||||
[self nibInstantiateWithOwner: owner topLevelObjects: tlo];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (NSMutableArray *) connections
|
|
||||||
{
|
|
||||||
return _connections;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (NSMutableSet *) topLevelObjects
|
|
||||||
{
|
|
||||||
return _topLevelObjects;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (NSMutableDictionary *) nameTable
|
|
||||||
{
|
|
||||||
return nil;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (NSMutableArray *) visibleWindows
|
|
||||||
{
|
|
||||||
return _visibleWindows;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (NSMapTable *) objects
|
|
||||||
{
|
|
||||||
return _objects;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (NSMapTable *) names
|
|
||||||
{
|
|
||||||
return _names;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (NSMapTable *) classes
|
|
||||||
{
|
|
||||||
return _classes;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (NSMapTable *) oids
|
|
||||||
{
|
|
||||||
return _oids;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (id) objectForName: (NSString *)name
|
|
||||||
{
|
|
||||||
NSArray *nameKeys = (NSArray *)NSAllMapTableKeys(_names);
|
|
||||||
NSArray *nameValues = (NSArray *)NSAllMapTableValues(_names);
|
|
||||||
int i = [nameValues indexOfObject: name];
|
|
||||||
id result = nil;
|
|
||||||
|
|
||||||
if (i != NSNotFound)
|
|
||||||
{
|
|
||||||
result = [nameKeys objectAtIndex: i];
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (NSString *) nameForObject: (id)obj
|
|
||||||
{
|
|
||||||
NSArray *nameKeys = (NSArray *)NSAllMapTableKeys(_names);
|
|
||||||
NSArray *nameValues = (NSArray *)NSAllMapTableValues(_names);
|
|
||||||
int i = [nameKeys indexOfObject: obj];
|
|
||||||
NSString *result = [nameValues objectAtIndex: i];
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the values from the map in the same order as the keys.
|
* Get the values from the map in the same order as the keys.
|
||||||
*/
|
*/
|
||||||
|
@ -1457,6 +1332,31 @@ static BOOL _isInInterfaceBuilder = NO;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Build a map with two arrays of keys and values.
|
||||||
|
*/
|
||||||
|
- (void) _buildMap: (NSMapTable *)mapTable
|
||||||
|
withKeys: (NSArray *)keys
|
||||||
|
andValues: (NSArray *)values
|
||||||
|
{
|
||||||
|
NSEnumerator *ken = [keys objectEnumerator];
|
||||||
|
NSEnumerator *ven = [values objectEnumerator];
|
||||||
|
id key = nil;
|
||||||
|
id value = nil;
|
||||||
|
|
||||||
|
while ((key = [ken nextObject]) != nil && (value = [ven nextObject]) != nil)
|
||||||
|
{
|
||||||
|
NSMapInsert(mapTable, key, value);
|
||||||
|
if(value == nil)
|
||||||
|
{
|
||||||
|
NSLog(@"==> WARNING: Value for key %@ is %@",key , value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Encode the NSIBObjectData.
|
||||||
|
*/
|
||||||
- (void) encodeWithCoder: (NSCoder *)coder
|
- (void) encodeWithCoder: (NSCoder *)coder
|
||||||
{
|
{
|
||||||
if ([coder allowsKeyedCoding])
|
if ([coder allowsKeyedCoding])
|
||||||
|
@ -1500,92 +1400,90 @@ static BOOL _isInInterfaceBuilder = NO;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) _buildMap: (NSMapTable *)mapTable
|
/**
|
||||||
withKeys: (NSArray *)keys
|
* Decode the NSIBObjectData.
|
||||||
andValues: (NSArray *)values
|
*/
|
||||||
{
|
|
||||||
NSEnumerator *ken = [keys objectEnumerator];
|
|
||||||
NSEnumerator *ven = [values objectEnumerator];
|
|
||||||
id key = nil;
|
|
||||||
id value = nil;
|
|
||||||
|
|
||||||
while ((key = [ken nextObject]) != nil && (value = [ven nextObject]) != nil)
|
|
||||||
{
|
|
||||||
NSMapInsert(mapTable, key, value);
|
|
||||||
if(value == nil)
|
|
||||||
{
|
|
||||||
NSLog(@"==> WARNING: Value for key %@ is %@",key , value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
- (id) initWithCoder: (NSCoder *)coder
|
- (id) initWithCoder: (NSCoder *)coder
|
||||||
{
|
{
|
||||||
if ([coder allowsKeyedCoding])
|
if ([coder allowsKeyedCoding])
|
||||||
{
|
{
|
||||||
|
NSArray *nameKeys = nil;
|
||||||
|
NSArray *nameValues = nil;
|
||||||
|
NSArray *classKeys = nil;
|
||||||
|
NSArray *classValues = nil;
|
||||||
|
|
||||||
ASSIGN(_root, [coder decodeObjectForKey: @"NSRoot"]);
|
ASSIGN(_root, [coder decodeObjectForKey: @"NSRoot"]);
|
||||||
ASSIGN(_visibleWindows, (NSMutableArray *)[coder decodeObjectForKey: @"NSVisibleWindows"]);
|
ASSIGN(_visibleWindows,
|
||||||
ASSIGN(_accessibilityConnectors, (NSMutableArray *)[coder decodeObjectForKey: @"NSAccessibilityConnectors"]);
|
(NSMutableArray *)[coder decodeObjectForKey: @"NSVisibleWindows"]);
|
||||||
|
ASSIGN(_accessibilityConnectors,
|
||||||
|
(NSMutableArray *)[coder decodeObjectForKey: @"NSAccessibilityConnectors"]);
|
||||||
ASSIGN(_fontManager, [coder decodeObjectForKey: @"NSFontManager"]);
|
ASSIGN(_fontManager, [coder decodeObjectForKey: @"NSFontManager"]);
|
||||||
ASSIGN(_framework, [coder decodeObjectForKey: @"NSFramework"]);
|
ASSIGN(_framework, [coder decodeObjectForKey: @"NSFramework"]);
|
||||||
_nextOid = [coder decodeIntForKey: @"NSNextOid"];
|
_nextOid = [coder decodeIntForKey: @"NSNextOid"];
|
||||||
|
|
||||||
{
|
/*
|
||||||
NSArray *objectsKeys = (NSArray *)
|
objectsKeys = (NSArray *)
|
||||||
[coder decodeObjectForKey: @"NSObjectsKeys"];
|
[coder decodeObjectForKey: @"NSObjectsKeys"];
|
||||||
NSArray *objectsValues = (NSArray *)
|
objectsValues = (NSArray *)
|
||||||
[coder decodeObjectForKey: @"NSObjectsValues"];
|
[coder decodeObjectForKey: @"NSObjectsValues"];
|
||||||
NSArray *nameKeys = (NSArray *)
|
*/
|
||||||
[coder decodeObjectForKey: @"NSNamesKeys"];
|
nameKeys = (NSArray *)
|
||||||
NSArray *nameValues = (NSArray *)
|
[coder decodeObjectForKey: @"NSNamesKeys"];
|
||||||
[coder decodeObjectForKey: @"NSNamesValues"];
|
nameValues = (NSArray *)
|
||||||
NSArray *oidsKeys = (NSArray *)
|
[coder decodeObjectForKey: @"NSNamesValues"];
|
||||||
[coder decodeObjectForKey: @"NSOidsKeys"];
|
/*
|
||||||
NSArray *oidsValues = (NSArray *)
|
oidsKeys = (NSArray *)
|
||||||
[coder decodeObjectForKey: @"NSOidsValues"];
|
[coder decodeObjectForKey: @"NSOidsKeys"];
|
||||||
NSArray *classKeys = (NSArray *)
|
oidsValues = (NSArray *)
|
||||||
[coder decodeObjectForKey: @"NSClassesKeys"];
|
[coder decodeObjectForKey: @"NSOidsValues"];
|
||||||
NSArray *classValues = (NSArray *)
|
*/
|
||||||
[coder decodeObjectForKey: @"NSClassesValues"];
|
classKeys = (NSArray *)
|
||||||
NSArray *accessibilityOidsKeys = (NSArray *)
|
[coder decodeObjectForKey: @"NSClassesKeys"];
|
||||||
[coder decodeObjectForKey: @"NSAccessibilityOidsKeys"];
|
classValues = (NSArray *)
|
||||||
NSArray *accessibilityOidsValues = (NSArray *)
|
[coder decodeObjectForKey: @"NSClassesValues"];
|
||||||
[coder decodeObjectForKey: @"NSAccessibilityOidsValues"];
|
/*
|
||||||
|
accessibilityOidsKeys = (NSArray *)
|
||||||
// instantiate the maps..
|
[coder decodeObjectForKey: @"NSAccessibilityOidsKeys"];
|
||||||
_objects = NSCreateMapTable(NSObjectMapKeyCallBacks,
|
accessibilityOidsValues = (NSArray *)
|
||||||
NSObjectMapValueCallBacks, 2);
|
[coder decodeObjectForKey: @"NSAccessibilityOidsValues"];
|
||||||
_names = NSCreateMapTable(NSObjectMapKeyCallBacks,
|
*/
|
||||||
|
|
||||||
|
// instantiate the maps..
|
||||||
|
_objects = NSCreateMapTable(NSObjectMapKeyCallBacks,
|
||||||
NSObjectMapValueCallBacks, 2);
|
NSObjectMapValueCallBacks, 2);
|
||||||
_oids = NSCreateMapTable(NSObjectMapKeyCallBacks,
|
_names = NSCreateMapTable(NSObjectMapKeyCallBacks,
|
||||||
NSObjectMapValueCallBacks, 2);
|
NSObjectMapValueCallBacks, 2);
|
||||||
_classes = NSCreateMapTable(NSObjectMapKeyCallBacks,
|
_oids = NSCreateMapTable(NSObjectMapKeyCallBacks,
|
||||||
NSObjectMapValueCallBacks, 2);
|
NSObjectMapValueCallBacks, 2);
|
||||||
_accessibilityOids = NSCreateMapTable(NSObjectMapKeyCallBacks,
|
_classes = NSCreateMapTable(NSObjectMapKeyCallBacks,
|
||||||
NSObjectMapValueCallBacks, 2);
|
NSObjectMapValueCallBacks, 2);
|
||||||
|
_accessibilityOids = NSCreateMapTable(NSObjectMapKeyCallBacks,
|
||||||
// fill in the maps...
|
NSObjectMapValueCallBacks, 2);
|
||||||
[self _buildMap: _accessibilityOids
|
|
||||||
withKeys: accessibilityOidsKeys
|
// Fill in the maps...
|
||||||
andValues: accessibilityOidsValues];
|
/*
|
||||||
[self _buildMap: _classes
|
[self _buildMap: _accessibilityOids
|
||||||
withKeys: classKeys
|
withKeys: accessibilityOidsKeys
|
||||||
andValues: classValues];
|
andValues: accessibilityOidsValues];
|
||||||
[self _buildMap: _names
|
*/
|
||||||
withKeys: nameKeys
|
[self _buildMap: _classes
|
||||||
andValues: nameValues];
|
withKeys: classKeys
|
||||||
[self _buildMap: _objects
|
andValues: classValues];
|
||||||
withKeys: objectsKeys
|
[self _buildMap: _names
|
||||||
andValues: objectsValues];
|
withKeys: nameKeys
|
||||||
[self _buildMap: _oids
|
andValues: nameValues];
|
||||||
withKeys: oidsKeys
|
/*
|
||||||
andValues: oidsValues];
|
[self _buildMap: _objects
|
||||||
|
withKeys: objectsKeys
|
||||||
ASSIGN(_connections, [[coder decodeObjectForKey: @"NSConnections"] mutableCopy]);
|
andValues: objectsValues];
|
||||||
|
[self _buildMap: _oids
|
||||||
// instantiate...
|
withKeys: oidsKeys
|
||||||
_topLevelObjects = [[NSMutableSet alloc] init];
|
andValues: oidsValues];
|
||||||
}
|
*/
|
||||||
|
ASSIGN(_connections, [[coder decodeObjectForKey: @"NSConnections"] mutableCopy]);
|
||||||
|
|
||||||
|
// instantiate...
|
||||||
|
_topLevelObjects = [[NSMutableSet alloc] init];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1597,6 +1495,9 @@ static BOOL _isInInterfaceBuilder = NO;
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instantiate a new one.
|
||||||
|
*/
|
||||||
- (id) init
|
- (id) init
|
||||||
{
|
{
|
||||||
if ((self = [super init]) != nil)
|
if ((self = [super init]) != nil)
|
||||||
|
@ -1625,6 +1526,9 @@ static BOOL _isInInterfaceBuilder = NO;
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deallocate.
|
||||||
|
*/
|
||||||
- (void) dealloc
|
- (void) dealloc
|
||||||
{
|
{
|
||||||
// free the maps.
|
// free the maps.
|
||||||
|
@ -1645,6 +1549,149 @@ static BOOL _isInInterfaceBuilder = NO;
|
||||||
[super dealloc];
|
[super dealloc];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Call nibInstantiate on an object, if it responds to the nibInstantiate selector.
|
||||||
|
*/
|
||||||
|
- (id)instantiateObject: (id)obj
|
||||||
|
{
|
||||||
|
id newObject = obj;
|
||||||
|
if ([obj respondsToSelector: @selector(nibInstantiate)])
|
||||||
|
{
|
||||||
|
newObject = [obj nibInstantiate];
|
||||||
|
}
|
||||||
|
return newObject;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instantiate all of the objects in the nib file.
|
||||||
|
*/
|
||||||
|
- (void) nibInstantiateWithOwner: (id)owner topLevelObjects: (NSMutableArray *)topLevelObjects
|
||||||
|
{
|
||||||
|
NSEnumerator *en = [_connections objectEnumerator];
|
||||||
|
NSArray *objs = NSAllMapTableKeys([self names]);
|
||||||
|
id obj = nil;
|
||||||
|
id menu = nil;
|
||||||
|
|
||||||
|
// set the new root object.
|
||||||
|
[_root setRealObject: owner];
|
||||||
|
|
||||||
|
// iterate over connections, instantiate, and then establish them.
|
||||||
|
while ((obj = [en nextObject]) != nil)
|
||||||
|
{
|
||||||
|
if ([obj respondsToSelector: @selector(instantiateWithInstantiator:)])
|
||||||
|
{
|
||||||
|
[obj instantiateWithInstantiator: self];
|
||||||
|
[obj establishConnection];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// iterate over all objects instantiate windows, awaken objects and fill
|
||||||
|
// in top level array.
|
||||||
|
en = [objs objectEnumerator];
|
||||||
|
while ((obj = [en nextObject]) != nil)
|
||||||
|
{
|
||||||
|
// instantiate all windows and fill in the top level array.
|
||||||
|
if ([obj isKindOfClass: [NSWindowTemplate class]])
|
||||||
|
{
|
||||||
|
if ([obj realObject] == nil)
|
||||||
|
{
|
||||||
|
obj = [self instantiateObject: obj];
|
||||||
|
[topLevelObjects addObject: obj];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
id v = NSMapGet(_objects, obj);
|
||||||
|
if (v == nil || v == owner)
|
||||||
|
{
|
||||||
|
[topLevelObjects addObject: obj];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// awaken the object.
|
||||||
|
if ([obj respondsToSelector: @selector(awakeFromNib)])
|
||||||
|
{
|
||||||
|
[obj awakeFromNib];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// awaken the owner.
|
||||||
|
if([owner respondsToSelector: @selector(awakeFromNib)])
|
||||||
|
{
|
||||||
|
[owner awakeFromNib];
|
||||||
|
}
|
||||||
|
|
||||||
|
// bring visible windows to front...
|
||||||
|
en = [_visibleWindows objectEnumerator];
|
||||||
|
while ((obj = [en nextObject]) != nil)
|
||||||
|
{
|
||||||
|
id w = [obj realObject];
|
||||||
|
[w orderFront: self];
|
||||||
|
}
|
||||||
|
|
||||||
|
// add the menu...
|
||||||
|
menu = [self objectForName: @"MainMenu"];
|
||||||
|
if (menu != nil)
|
||||||
|
{
|
||||||
|
menu = [self instantiateObject: menu];
|
||||||
|
[NSApp _setMainMenu: menu];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Awake after loading the nib and extract the top level and owner for nib instantiation,
|
||||||
|
* then call nibInstantateWithOwner:topLevelObjects:
|
||||||
|
*/
|
||||||
|
- (void) awakeWithContext: (NSDictionary *)context
|
||||||
|
{
|
||||||
|
NSMutableArray *tlo = [context objectForKey: @"NSTopLevelObjects"];
|
||||||
|
id owner = [context objectForKey: @"NSOwner"];
|
||||||
|
|
||||||
|
// get using the alternate names.
|
||||||
|
if(tlo == nil)
|
||||||
|
{
|
||||||
|
tlo = [context objectForKey: @"NSNibTopLevelObjects"];
|
||||||
|
}
|
||||||
|
|
||||||
|
if(owner == nil)
|
||||||
|
{
|
||||||
|
owner = [context objectForKey: @"NSNibOwner"];
|
||||||
|
}
|
||||||
|
|
||||||
|
// instantiate...
|
||||||
|
[self nibInstantiateWithOwner: owner topLevelObjects: tlo];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve an object by name from the map.
|
||||||
|
*/
|
||||||
|
- (id) objectForName: (NSString *)name
|
||||||
|
{
|
||||||
|
NSArray *nameKeys = (NSArray *)NSAllMapTableKeys(_names);
|
||||||
|
NSArray *nameValues = (NSArray *)NSAllMapTableValues(_names);
|
||||||
|
int i = [nameValues indexOfObject: name];
|
||||||
|
id result = nil;
|
||||||
|
|
||||||
|
if (i != NSNotFound)
|
||||||
|
{
|
||||||
|
result = [nameKeys objectAtIndex: i];
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the name for an object.
|
||||||
|
*/
|
||||||
|
- (NSString *) nameForObject: (id)obj
|
||||||
|
{
|
||||||
|
NSArray *nameKeys = (NSArray *)NSAllMapTableKeys(_names);
|
||||||
|
NSArray *nameValues = (NSArray *)NSAllMapTableValues(_names);
|
||||||
|
int i = [nameKeys indexOfObject: obj];
|
||||||
|
NSString *result = [nameValues objectAtIndex: i];
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
- (void) setRoot: (id) root
|
- (void) setRoot: (id) root
|
||||||
{
|
{
|
||||||
ASSIGN(_root, root);
|
ASSIGN(_root, root);
|
||||||
|
@ -1664,6 +1711,46 @@ static BOOL _isInInterfaceBuilder = NO;
|
||||||
{
|
{
|
||||||
return _nextOid;
|
return _nextOid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (NSMutableArray *) connections
|
||||||
|
{
|
||||||
|
return _connections;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSMutableSet *) topLevelObjects
|
||||||
|
{
|
||||||
|
return _topLevelObjects;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSMutableDictionary *) nameTable
|
||||||
|
{
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSMutableArray *) visibleWindows
|
||||||
|
{
|
||||||
|
return _visibleWindows;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSMapTable *) objects
|
||||||
|
{
|
||||||
|
return _objects;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSMapTable *) names
|
||||||
|
{
|
||||||
|
return _names;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSMapTable *) classes
|
||||||
|
{
|
||||||
|
return _classes;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSMapTable *) oids
|
||||||
|
{
|
||||||
|
return _oids;
|
||||||
|
}
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@implementation NSButtonImageSource
|
@implementation NSButtonImageSource
|
||||||
|
|
|
@ -174,13 +174,6 @@
|
||||||
[self label]];
|
[self label]];
|
||||||
return desc;
|
return desc;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) instantiateWithInstantiator: (id<GSInstantiator>)instantiator
|
|
||||||
{
|
|
||||||
_src = [instantiator instantiateObject: _src];
|
|
||||||
_dst = [instantiator instantiateObject: _dst];
|
|
||||||
}
|
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@implementation NSNibControlConnector
|
@implementation NSNibControlConnector
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include <Foundation/NSNotification.h>
|
#include <Foundation/NSNotification.h>
|
||||||
|
#include <Foundation/NSException.h>
|
||||||
|
|
||||||
#include "AppKit/NSClipView.h"
|
#include "AppKit/NSClipView.h"
|
||||||
#include "AppKit/NSCursor.h"
|
#include "AppKit/NSCursor.h"
|
||||||
|
@ -38,6 +39,8 @@
|
||||||
#include "AppKit/NSWindow.h"
|
#include "AppKit/NSWindow.h"
|
||||||
#include "AppKit/PSOperators.h"
|
#include "AppKit/PSOperators.h"
|
||||||
|
|
||||||
|
#include <GNUstepGUI/GSNibLoading.h>
|
||||||
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
DEFINE_RINT_IF_MISSING
|
DEFINE_RINT_IF_MISSING
|
||||||
|
@ -789,6 +792,9 @@ static inline NSRect integralRect (NSRect rect, NSView *view)
|
||||||
if ([[self subviews] count] > 0)
|
if ([[self subviews] count] > 0)
|
||||||
{
|
{
|
||||||
id document = [aDecoder decodeObjectForKey: @"NSDocView"];
|
id document = [aDecoder decodeObjectForKey: @"NSDocView"];
|
||||||
|
|
||||||
|
NSAssert([document class] != [NSCustomView class],
|
||||||
|
NSInvalidArgumentException);
|
||||||
NSRect rect = [document frame];
|
NSRect rect = [document frame];
|
||||||
rect.origin = NSZeroPoint;
|
rect.origin = NSZeroPoint;
|
||||||
[document setFrame: rect];
|
[document setFrame: rect];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue