2003-10-25 20:50:08 +00:00
|
|
|
/** <title>GSNibCompatibility</title>
|
|
|
|
|
|
|
|
<abstract>
|
2006-05-20 22:12:46 +00:00
|
|
|
These are templates for use with OSX Nib files. These classes are the
|
|
|
|
templates and other things which are needed for reading/writing nib files.
|
2003-10-25 20:50:08 +00:00
|
|
|
</abstract>
|
|
|
|
|
|
|
|
Copyright (C) 1997, 1999 Free Software Foundation, Inc.
|
|
|
|
|
|
|
|
Author: Gregory John Casamento
|
2006-05-20 22:12:46 +00:00
|
|
|
Date: 2003, 2005
|
2003-10-25 20:50:08 +00:00
|
|
|
|
|
|
|
This file is part of the GNUstep GUI Library.
|
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or
|
2007-10-29 21:16:17 +00:00
|
|
|
modify it under the terms of the GNU Lesser General Public
|
2003-10-25 20:50:08 +00:00
|
|
|
License as published by the Free Software Foundation; either
|
2007-10-29 21:16:17 +00:00
|
|
|
version 3 of the License, or (at your option) any later version.
|
|
|
|
|
2003-10-25 20:50:08 +00:00
|
|
|
This library is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2007-10-29 21:16:17 +00:00
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
Lesser General Public License for more details.
|
2003-10-25 20:50:08 +00:00
|
|
|
|
2007-10-29 21:16:17 +00:00
|
|
|
You should have received a copy of the GNU Lesser General Public
|
|
|
|
License along with this library; see the file COPYING.LIB.
|
|
|
|
If not, see <http://www.gnu.org/licenses/> or write to the
|
|
|
|
Free Software Foundation, 51 Franklin Street, Fifth Floor,
|
|
|
|
Boston, MA 02110-1301, USA.
|
2003-10-25 20:50:08 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <Foundation/NSClassDescription.h>
|
|
|
|
#include <Foundation/NSArchiver.h>
|
|
|
|
#include <Foundation/NSArray.h>
|
|
|
|
#include <Foundation/NSBundle.h>
|
2006-06-25 16:42:38 +00:00
|
|
|
#include <Foundation/NSByteOrder.h>
|
2003-10-25 20:50:08 +00:00
|
|
|
#include <Foundation/NSCoder.h>
|
|
|
|
#include <Foundation/NSData.h>
|
2006-06-25 16:42:38 +00:00
|
|
|
#include <Foundation/NSDecimalNumber.h>
|
2003-10-25 20:50:08 +00:00
|
|
|
#include <Foundation/NSDictionary.h>
|
|
|
|
#include <Foundation/NSDebug.h>
|
|
|
|
#include <Foundation/NSEnumerator.h>
|
|
|
|
#include <Foundation/NSException.h>
|
|
|
|
#include <Foundation/NSInvocation.h>
|
|
|
|
#include <Foundation/NSObjCRuntime.h>
|
|
|
|
#include <Foundation/NSPathUtilities.h>
|
|
|
|
#include <Foundation/NSFileManager.h>
|
|
|
|
#include <Foundation/NSString.h>
|
|
|
|
#include <Foundation/NSUserDefaults.h>
|
|
|
|
#include <Foundation/NSKeyValueCoding.h>
|
2004-02-24 19:31:33 +00:00
|
|
|
#include <Foundation/NSKeyedArchiver.h>
|
2003-10-25 20:50:08 +00:00
|
|
|
#include "AppKit/AppKit.h"
|
|
|
|
#include <GNUstepBase/GSObjCRuntime.h>
|
2006-05-20 22:25:54 +00:00
|
|
|
#include <GNUstepBase/GSIArray.h>
|
2003-10-25 20:50:08 +00:00
|
|
|
#include <GNUstepGUI/GSNibCompatibility.h>
|
2006-05-20 22:12:46 +00:00
|
|
|
#include <GNUstepGUI/GSInstantiator.h>
|
2004-06-26 00:53:01 +00:00
|
|
|
|
2006-06-15 04:53:09 +00:00
|
|
|
static BOOL _isInInterfaceBuilder = NO;
|
|
|
|
|
2006-07-19 03:16:49 +00:00
|
|
|
@interface NSView (NibCompatibility)
|
|
|
|
- (void) _fixSubviews;
|
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation NSView (NibCompatibility)
|
|
|
|
- (void) _setWindow: (id) w
|
|
|
|
{
|
|
|
|
ASSIGN(_window,w);
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) _fixSubviews
|
|
|
|
{
|
|
|
|
NSEnumerator *en = [[self subviews] objectEnumerator];
|
|
|
|
id v = nil;
|
2006-10-15 08:34:47 +00:00
|
|
|
while ((v = [en nextObject]) != nil)
|
2006-07-19 03:16:49 +00:00
|
|
|
{
|
2006-10-15 08:34:47 +00:00
|
|
|
if ([v window] != [self window] ||
|
2007-11-27 00:09:24 +00:00
|
|
|
[v superview] != self)
|
|
|
|
{
|
|
|
|
[v _setWindow: [self window]];
|
|
|
|
RETAIN(v);
|
|
|
|
[_sub_views removeObject: v];
|
|
|
|
[self addSubview: v];
|
|
|
|
RELEASE(v);
|
|
|
|
}
|
2006-07-19 03:16:49 +00:00
|
|
|
[v _fixSubviews];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@end
|
|
|
|
|
2003-10-25 20:50:08 +00:00
|
|
|
@implementation NSWindowTemplate
|
|
|
|
+ (void) initialize
|
|
|
|
{
|
|
|
|
if (self == [NSWindowTemplate class])
|
|
|
|
{
|
|
|
|
[self setVersion: 0];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) dealloc
|
|
|
|
{
|
2006-05-20 22:12:46 +00:00
|
|
|
RELEASE(_title);
|
|
|
|
RELEASE(_viewClass);
|
|
|
|
RELEASE(_windowClass);
|
|
|
|
RELEASE(_view);
|
|
|
|
RELEASE(_autosaveName);
|
2003-10-25 20:50:08 +00:00
|
|
|
[super dealloc];
|
|
|
|
}
|
|
|
|
|
2006-07-14 05:18:08 +00:00
|
|
|
- (id) initWithWindow: (NSWindow *)window
|
2007-11-27 00:09:24 +00:00
|
|
|
className: (NSString *)windowClass
|
|
|
|
isDeferred: (BOOL) deferred
|
|
|
|
isOneShot: (BOOL) oneShot
|
|
|
|
isVisible: (BOOL) visible
|
2006-07-14 05:18:08 +00:00
|
|
|
wantsToBeColor: (BOOL) wantsToBeColor
|
|
|
|
autoPositionMask: (int) autoPositionMask
|
|
|
|
{
|
2006-10-15 08:34:47 +00:00
|
|
|
if ((self = [super init]) != nil)
|
2006-07-14 05:18:08 +00:00
|
|
|
{
|
2006-10-15 08:34:47 +00:00
|
|
|
if (window != nil)
|
2007-11-27 00:09:24 +00:00
|
|
|
{
|
|
|
|
// object members
|
|
|
|
ASSIGN(_title, [window title]);
|
|
|
|
ASSIGN(_viewClass, NSStringFromClass([[window contentView] class]));
|
|
|
|
ASSIGN(_windowClass, windowClass);
|
|
|
|
ASSIGN(_view, [window contentView]);
|
|
|
|
ASSIGN(_autosaveName, [window frameAutosaveName]);
|
|
|
|
|
|
|
|
// style & size
|
|
|
|
_windowStyle = [window styleMask];
|
|
|
|
_backingStoreType = [window backingType];
|
|
|
|
_maxSize = [window maxSize];
|
|
|
|
_minSize = [window minSize];
|
|
|
|
_windowRect = [window frame];
|
|
|
|
_screenRect = [[NSScreen mainScreen] frame];
|
|
|
|
|
|
|
|
// flags
|
|
|
|
_flags.isHiddenOnDeactivate = [window hidesOnDeactivate];
|
|
|
|
_flags.isNotReleasedOnClose = (![window isReleasedWhenClosed]);
|
|
|
|
_flags.isDeferred = deferred;
|
|
|
|
_flags.isOneShot = oneShot;
|
|
|
|
_flags.isVisible = visible;
|
|
|
|
_flags.wantsToBeColor = wantsToBeColor;
|
|
|
|
_flags.dynamicDepthLimit = [window hasDynamicDepthLimit];
|
|
|
|
_flags.autoPositionMask = autoPositionMask;
|
|
|
|
_flags.savePosition = YES; // not yet implemented.
|
|
|
|
}
|
2006-07-14 05:18:08 +00:00
|
|
|
}
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2006-05-20 22:12:46 +00:00
|
|
|
- (id) initWithCoder: (NSCoder *)coder
|
2003-10-25 20:50:08 +00:00
|
|
|
{
|
2006-05-20 22:12:46 +00:00
|
|
|
if ([coder allowsKeyedCoding])
|
2004-02-15 18:23:13 +00:00
|
|
|
{
|
2006-05-20 22:12:46 +00:00
|
|
|
if ([coder containsValueForKey: @"NSViewClass"])
|
|
|
|
{
|
2007-11-27 00:09:24 +00:00
|
|
|
ASSIGN(_viewClass, [coder decodeObjectForKey: @"NSViewClass"]);
|
|
|
|
}
|
2006-05-20 22:12:46 +00:00
|
|
|
if ([coder containsValueForKey: @"NSWindowClass"])
|
2004-02-24 19:31:33 +00:00
|
|
|
{
|
2007-11-27 00:09:24 +00:00
|
|
|
ASSIGN(_windowClass, [coder decodeObjectForKey: @"NSWindowClass"]);
|
|
|
|
}
|
2006-05-20 22:12:46 +00:00
|
|
|
if ([coder containsValueForKey: @"NSWindowStyleMask"])
|
2004-02-24 19:31:33 +00:00
|
|
|
{
|
2007-11-27 00:09:24 +00:00
|
|
|
_windowStyle = [coder decodeIntForKey: @"NSWindowStyleMask"];
|
|
|
|
}
|
2006-10-15 08:34:47 +00:00
|
|
|
if ([coder containsValueForKey: @"NSWindowBacking"])
|
2007-11-27 00:09:24 +00:00
|
|
|
{
|
|
|
|
_backingStoreType = [coder decodeIntForKey: @"NSWindowBacking"];
|
|
|
|
}
|
2006-05-20 22:12:46 +00:00
|
|
|
if ([coder containsValueForKey: @"NSWindowView"])
|
2004-02-15 18:23:13 +00:00
|
|
|
{
|
2007-11-27 00:09:24 +00:00
|
|
|
ASSIGN(_view, [coder decodeObjectForKey: @"NSWindowView"]);
|
|
|
|
}
|
2006-05-20 22:12:46 +00:00
|
|
|
if ([coder containsValueForKey: @"NSWTFlags"])
|
2004-02-15 18:23:13 +00:00
|
|
|
{
|
2007-11-27 00:09:24 +00:00
|
|
|
unsigned long flags = [coder decodeIntForKey: @"NSWTFlags"];
|
|
|
|
memcpy((void *)&_flags,(void *)&flags,sizeof(struct _GSWindowTemplateFlags));
|
|
|
|
}
|
2006-05-20 22:12:46 +00:00
|
|
|
if ([coder containsValueForKey: @"NSMinSize"])
|
2004-02-24 19:31:33 +00:00
|
|
|
{
|
2007-11-27 00:09:24 +00:00
|
|
|
_minSize = [coder decodeSizeForKey: @"NSMinSize"];
|
|
|
|
}
|
2006-05-20 22:12:46 +00:00
|
|
|
if ([coder containsValueForKey: @"NSMaxSize"])
|
|
|
|
{
|
2007-11-27 00:09:24 +00:00
|
|
|
_maxSize = [coder decodeSizeForKey: @"NSMaxSize"];
|
|
|
|
}
|
2006-05-20 22:12:46 +00:00
|
|
|
if ([coder containsValueForKey: @"NSWindowRect"])
|
|
|
|
{
|
2007-11-27 00:09:24 +00:00
|
|
|
_windowRect = [coder decodeRectForKey: @"NSWindowRect"];
|
|
|
|
}
|
2006-05-20 22:12:46 +00:00
|
|
|
if ([coder containsValueForKey: @"NSFrameAutosaveName"])
|
|
|
|
{
|
2007-11-27 00:09:24 +00:00
|
|
|
ASSIGN(_autosaveName, [coder decodeObjectForKey: @"NSFrameAutosaveName"]);
|
|
|
|
}
|
2006-05-20 22:12:46 +00:00
|
|
|
if ([coder containsValueForKey: @"NSWindowTitle"])
|
|
|
|
{
|
2007-11-27 00:09:24 +00:00
|
|
|
ASSIGN(_title, [coder decodeObjectForKey: @"NSWindowTitle"]);
|
|
|
|
_windowStyle |= NSTitledWindowMask;
|
|
|
|
}
|
2006-06-15 04:53:09 +00:00
|
|
|
|
|
|
|
_baseWindowClass = [NSWindow class];
|
2004-02-15 18:23:13 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-06-08 04:04:17 +00:00
|
|
|
[NSException raise: NSInvalidArgumentException
|
2007-11-27 00:09:24 +00:00
|
|
|
format: @"Can't decode %@ with %@.",NSStringFromClass([self class]),
|
|
|
|
NSStringFromClass([coder class])];
|
2004-02-24 19:31:33 +00:00
|
|
|
}
|
2006-05-20 22:12:46 +00:00
|
|
|
return self;
|
2003-10-25 20:50:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void) encodeWithCoder: (NSCoder *)aCoder
|
|
|
|
{
|
2006-05-20 22:12:46 +00:00
|
|
|
if ([aCoder allowsKeyedCoding])
|
|
|
|
{
|
|
|
|
unsigned long flags = 0;
|
2006-08-09 01:37:32 +00:00
|
|
|
NSRect rect = [NSWindow contentRectForFrameRect: _windowRect
|
2007-11-27 00:09:24 +00:00
|
|
|
styleMask: _windowStyle];
|
2006-05-20 22:12:46 +00:00
|
|
|
memcpy((void *)&flags,(void *)&_flags,sizeof(unsigned long));
|
|
|
|
|
|
|
|
[aCoder encodeObject: _viewClass forKey: @"NSViewClass"];
|
|
|
|
[aCoder encodeObject: _windowClass forKey: @"NSWindowClass"];
|
|
|
|
[aCoder encodeInt: _windowStyle forKey: @"NSWindowStyleMask"];
|
|
|
|
[aCoder encodeInt: _backingStoreType forKey: @"NSWindowBacking"];
|
|
|
|
[aCoder encodeObject: _view forKey: @"NSWindowView"];
|
|
|
|
[aCoder encodeInt: flags forKey: @"NSWTFlags"];
|
|
|
|
[aCoder encodeSize: _minSize forKey: @"NSMinSize"];
|
|
|
|
[aCoder encodeSize: _maxSize forKey: @"NSMaxSize"];
|
2006-08-09 01:37:32 +00:00
|
|
|
[aCoder encodeRect: rect forKey: @"NSWindowRect"];
|
2006-05-20 22:12:46 +00:00
|
|
|
[aCoder encodeObject: _title forKey: @"NSWindowTitle"];
|
|
|
|
[aCoder encodeObject: _autosaveName forKey: @"NSFrameAutosaveName"];
|
|
|
|
}
|
2003-10-25 20:50:08 +00:00
|
|
|
}
|
|
|
|
|
2006-05-20 22:12:46 +00:00
|
|
|
- (id) nibInstantiate
|
2003-10-25 20:50:08 +00:00
|
|
|
{
|
2006-10-15 08:34:47 +00:00
|
|
|
if (_realObject == nil)
|
2003-10-25 20:50:08 +00:00
|
|
|
{
|
2006-06-15 04:53:09 +00:00
|
|
|
Class aClass;
|
2006-05-20 22:12:46 +00:00
|
|
|
NSEnumerator *en;
|
|
|
|
id v = nil;
|
2006-06-15 04:53:09 +00:00
|
|
|
|
2006-10-15 08:34:47 +00:00
|
|
|
if ([NSClassSwapper isInInterfaceBuilder])
|
2007-11-27 00:09:24 +00:00
|
|
|
{
|
|
|
|
aClass = [self baseWindowClass];
|
|
|
|
}
|
2006-06-15 04:53:09 +00:00
|
|
|
else
|
2007-11-27 00:09:24 +00:00
|
|
|
{
|
|
|
|
aClass = NSClassFromString(_windowClass);
|
|
|
|
}
|
2006-06-15 04:53:09 +00:00
|
|
|
|
2006-05-20 22:12:46 +00:00
|
|
|
if (aClass == nil)
|
2007-11-27 00:09:24 +00:00
|
|
|
{
|
|
|
|
[NSException raise: NSInternalInconsistencyException
|
|
|
|
format: @"Unable to find class '%@'", _windowClass];
|
|
|
|
}
|
2006-05-20 22:12:46 +00:00
|
|
|
|
|
|
|
_realObject = [[aClass allocWithZone: NSDefaultMallocZone()]
|
2007-11-27 00:09:24 +00:00
|
|
|
initWithContentRect: _windowRect
|
|
|
|
styleMask: _windowStyle
|
|
|
|
backing: _backingStoreType
|
|
|
|
defer: _flags.isDeferred
|
|
|
|
screen: nil];
|
2006-05-20 22:12:46 +00:00
|
|
|
|
|
|
|
// set flags...
|
|
|
|
[_realObject setHidesOnDeactivate: _flags.isHiddenOnDeactivate];
|
|
|
|
[_realObject setReleasedWhenClosed: !(_flags.isNotReleasedOnClose)];
|
|
|
|
[_realObject setOneShot: _flags.isOneShot];
|
|
|
|
// [_realObject setVisible: _flags.isVisible]; // this is determined by whether it's in the visible windows array...
|
|
|
|
// [_realObject setWantsToBeColor: _flags.wantsToBeColor]; // not applicable on GNUstep.
|
|
|
|
[_realObject setAutodisplay: YES];
|
|
|
|
[_realObject setDynamicDepthLimit: _flags.dynamicDepthLimit];
|
|
|
|
// [_realObject setAutoPositionMask: _flags.autoPositionMask]; // currently not implemented for nibs
|
|
|
|
// [_realObject setAutoPosition: _flags.autoPosition];
|
|
|
|
[_realObject setDynamicDepthLimit: _flags.dynamicDepthLimit];
|
|
|
|
[_realObject setFrameAutosaveName: _autosaveName];
|
|
|
|
|
|
|
|
// reset attributes...
|
|
|
|
[_realObject setContentView: _view];
|
|
|
|
[_realObject setMinSize: _minSize];
|
|
|
|
[_realObject setMaxSize: _maxSize];
|
|
|
|
[_realObject setTitle: _title];
|
2006-06-18 00:39:35 +00:00
|
|
|
|
2006-08-05 12:46:20 +00:00
|
|
|
[_view _fixSubviews];
|
2006-07-19 03:16:49 +00:00
|
|
|
|
2006-06-18 00:39:35 +00:00
|
|
|
// resize the window...
|
2006-08-09 01:37:32 +00:00
|
|
|
[_realObject setFrame: [NSWindow frameRectForContentRect: [self windowRect]
|
2007-11-27 00:09:24 +00:00
|
|
|
styleMask: [self windowStyle]]
|
|
|
|
display: NO];
|
2006-08-09 01:37:32 +00:00
|
|
|
|
2006-05-20 22:12:46 +00:00
|
|
|
// swap out any views which need to be swapped...
|
|
|
|
en = [[[_realObject contentView] subviews] objectEnumerator];
|
2006-10-15 08:34:47 +00:00
|
|
|
while ((v = [en nextObject]) != nil)
|
2007-11-27 00:09:24 +00:00
|
|
|
{
|
|
|
|
if ([v respondsToSelector: @selector(nibInstantiate)])
|
|
|
|
{
|
|
|
|
[v nibInstantiate];
|
|
|
|
}
|
|
|
|
}
|
2006-05-20 22:12:46 +00:00
|
|
|
}
|
|
|
|
return _realObject;
|
2003-10-25 20:50:08 +00:00
|
|
|
}
|
|
|
|
|
2006-05-20 22:12:46 +00:00
|
|
|
// setters and getters
|
|
|
|
- (void) setBackingStoreType: (NSBackingStoreType)type
|
2003-10-25 20:50:08 +00:00
|
|
|
{
|
2006-05-20 22:12:46 +00:00
|
|
|
_backingStoreType = type;
|
|
|
|
}
|
2003-10-25 20:50:08 +00:00
|
|
|
|
2006-05-20 22:12:46 +00:00
|
|
|
- (NSBackingStoreType) backingStoreType
|
|
|
|
{
|
|
|
|
return _backingStoreType;
|
2003-10-25 20:50:08 +00:00
|
|
|
}
|
|
|
|
|
2006-05-20 22:12:46 +00:00
|
|
|
- (void) setDeferred: (BOOL)flag
|
2003-10-25 20:50:08 +00:00
|
|
|
{
|
2006-05-20 22:12:46 +00:00
|
|
|
_flags.isDeferred = flag;
|
2003-10-25 20:50:08 +00:00
|
|
|
}
|
|
|
|
|
2006-05-20 22:12:46 +00:00
|
|
|
- (BOOL) isDeferred
|
2003-10-25 20:50:08 +00:00
|
|
|
{
|
2006-05-20 22:12:46 +00:00
|
|
|
return _flags.isDeferred;
|
2003-10-25 20:50:08 +00:00
|
|
|
}
|
|
|
|
|
2006-05-20 22:12:46 +00:00
|
|
|
- (void) setMaxSize: (NSSize)maxSize
|
2003-10-25 20:50:08 +00:00
|
|
|
{
|
2006-05-20 22:12:46 +00:00
|
|
|
_maxSize = maxSize;
|
2003-10-25 20:50:08 +00:00
|
|
|
}
|
|
|
|
|
2006-05-20 22:12:46 +00:00
|
|
|
- (NSSize) maxSize
|
2003-10-25 20:50:08 +00:00
|
|
|
{
|
2006-05-20 22:12:46 +00:00
|
|
|
return _maxSize;
|
2003-10-25 20:50:08 +00:00
|
|
|
}
|
|
|
|
|
2006-05-20 22:12:46 +00:00
|
|
|
- (void) setMinSize: (NSSize)minSize
|
2003-10-25 20:50:08 +00:00
|
|
|
{
|
2006-05-20 22:12:46 +00:00
|
|
|
_minSize = minSize;
|
2003-10-25 20:50:08 +00:00
|
|
|
}
|
|
|
|
|
2006-05-20 22:12:46 +00:00
|
|
|
- (NSSize) minSize
|
2003-10-25 20:50:08 +00:00
|
|
|
{
|
2006-05-20 22:12:46 +00:00
|
|
|
return _minSize;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setWindowStyle: (unsigned)style
|
|
|
|
{
|
|
|
|
_windowStyle = style;
|
2003-10-25 20:50:08 +00:00
|
|
|
}
|
|
|
|
|
2006-05-20 22:12:46 +00:00
|
|
|
- (unsigned) windowStyle
|
2003-10-25 20:50:08 +00:00
|
|
|
{
|
2006-05-20 22:12:46 +00:00
|
|
|
return _windowStyle;
|
|
|
|
}
|
2003-10-25 20:50:08 +00:00
|
|
|
|
2006-05-20 22:12:46 +00:00
|
|
|
- (void) setTitle: (NSString *) title
|
|
|
|
{
|
|
|
|
ASSIGN(_title, title);
|
2003-10-25 20:50:08 +00:00
|
|
|
}
|
|
|
|
|
2006-05-20 22:12:46 +00:00
|
|
|
- (NSString *)title;
|
2003-10-25 20:50:08 +00:00
|
|
|
{
|
2006-05-20 22:12:46 +00:00
|
|
|
return _title;
|
2003-10-25 20:50:08 +00:00
|
|
|
}
|
|
|
|
|
2006-05-20 22:12:46 +00:00
|
|
|
- (void) setViewClass: (NSString *)viewClass
|
2003-10-25 20:50:08 +00:00
|
|
|
{
|
2006-05-20 22:12:46 +00:00
|
|
|
ASSIGN(_viewClass,viewClass);
|
2003-10-25 20:50:08 +00:00
|
|
|
}
|
|
|
|
|
2006-05-20 22:12:46 +00:00
|
|
|
- (NSString *)viewClass
|
|
|
|
{
|
|
|
|
return _viewClass;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setWindowRect: (NSRect)rect
|
2003-10-25 20:50:08 +00:00
|
|
|
{
|
2006-05-20 22:12:46 +00:00
|
|
|
_windowRect = rect;
|
2003-10-25 20:50:08 +00:00
|
|
|
}
|
|
|
|
|
2006-05-20 22:12:46 +00:00
|
|
|
- (NSRect)windowRect
|
2003-10-25 20:50:08 +00:00
|
|
|
{
|
2006-05-20 22:12:46 +00:00
|
|
|
return _windowRect;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setScreenRect: (NSRect)rect
|
|
|
|
{
|
|
|
|
_screenRect = rect;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSRect) screenRect
|
|
|
|
{
|
|
|
|
return _screenRect;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (id) realObject
|
|
|
|
{
|
|
|
|
return _realObject;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setView: (id)view
|
|
|
|
{
|
|
|
|
ASSIGN(_view,view);
|
|
|
|
}
|
|
|
|
|
|
|
|
- (id) view
|
|
|
|
{
|
|
|
|
return _view;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setClassName: (NSString *)name
|
|
|
|
{
|
|
|
|
ASSIGN(_windowClass, name);
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *)className
|
|
|
|
{
|
|
|
|
return _windowClass;
|
|
|
|
}
|
2006-06-15 04:53:09 +00:00
|
|
|
|
|
|
|
- (Class) baseWindowClass
|
|
|
|
{
|
|
|
|
return _baseWindowClass;
|
|
|
|
}
|
2006-05-20 22:12:46 +00:00
|
|
|
@end
|
|
|
|
|
|
|
|
// Template for any classes which derive from NSView
|
|
|
|
@implementation NSViewTemplate
|
|
|
|
+ (void) initialize
|
|
|
|
{
|
|
|
|
if (self == [NSViewTemplate class])
|
2003-10-25 20:50:08 +00:00
|
|
|
{
|
2006-05-20 22:12:46 +00:00
|
|
|
[self setVersion: 0];
|
2003-10-25 20:50:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-05-20 22:12:46 +00:00
|
|
|
- (id) initWithCoder: (NSCoder *)coder
|
2003-10-25 20:50:08 +00:00
|
|
|
{
|
2006-05-20 22:12:46 +00:00
|
|
|
self = [super initWithCoder: coder];
|
2006-10-15 08:34:47 +00:00
|
|
|
if (self != nil)
|
2003-10-25 20:50:08 +00:00
|
|
|
{
|
2006-10-15 08:34:47 +00:00
|
|
|
if ([coder allowsKeyedCoding])
|
2007-11-27 00:09:24 +00:00
|
|
|
{
|
|
|
|
_className = [coder decodeObjectForKey: @"NSClassName"];
|
|
|
|
}
|
2003-10-25 20:50:08 +00:00
|
|
|
}
|
2006-05-20 22:12:46 +00:00
|
|
|
else
|
|
|
|
{
|
2006-06-08 04:04:17 +00:00
|
|
|
[NSException raise: NSInvalidArgumentException
|
2007-11-27 00:09:24 +00:00
|
|
|
format: @"Can't decode %@ with %@.",NSStringFromClass([self class]),
|
|
|
|
NSStringFromClass([coder class])];
|
2006-05-20 22:12:46 +00:00
|
|
|
}
|
|
|
|
return self;
|
|
|
|
}
|
2003-10-25 20:50:08 +00:00
|
|
|
|
2006-05-20 22:12:46 +00:00
|
|
|
- (void) encodeWithCoder: (NSCoder *)coder
|
|
|
|
{
|
2006-10-15 08:34:47 +00:00
|
|
|
if ([coder allowsKeyedCoding])
|
2006-05-20 22:12:46 +00:00
|
|
|
{
|
|
|
|
[coder encodeObject: (id)_className forKey: @"NSClassName"];
|
|
|
|
}
|
|
|
|
}
|
2003-10-25 20:50:08 +00:00
|
|
|
|
2006-06-08 04:04:17 +00:00
|
|
|
- (id) nibInstantiate
|
2006-05-20 22:12:46 +00:00
|
|
|
{
|
2006-10-15 08:34:47 +00:00
|
|
|
if (_realObject == nil)
|
2006-05-20 22:12:46 +00:00
|
|
|
{
|
|
|
|
Class aClass = NSClassFromString(_className);
|
2006-10-15 08:34:47 +00:00
|
|
|
if (aClass == nil)
|
2007-11-27 00:09:24 +00:00
|
|
|
{
|
|
|
|
[NSException raise: NSInternalInconsistencyException
|
|
|
|
format: @"Unable to find class '%@'", _className];
|
|
|
|
}
|
2006-05-20 22:12:46 +00:00
|
|
|
else
|
2007-11-27 00:09:24 +00:00
|
|
|
{
|
|
|
|
_realObject = [[aClass allocWithZone: NSDefaultMallocZone()] initWithFrame: [self frame]];
|
|
|
|
[[self superview] replaceSubview: self with: _realObject]; // replace the old view...
|
|
|
|
}
|
2006-05-20 22:12:46 +00:00
|
|
|
}
|
2003-10-25 20:50:08 +00:00
|
|
|
|
2006-05-20 22:12:46 +00:00
|
|
|
return _realObject;
|
2003-10-25 20:50:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// setters and getters
|
|
|
|
- (void) setClassName: (NSString *)name
|
|
|
|
{
|
|
|
|
ASSIGN(_className, name);
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *)className
|
|
|
|
{
|
|
|
|
return _className;
|
|
|
|
}
|
|
|
|
|
2006-05-20 22:12:46 +00:00
|
|
|
- (id) realObject
|
|
|
|
{
|
|
|
|
return _realObject;
|
|
|
|
}
|
2003-10-25 20:50:08 +00:00
|
|
|
@end
|
|
|
|
|
|
|
|
// Template for any classes which derive from NSText
|
|
|
|
@implementation NSTextTemplate
|
|
|
|
+ (void) initialize
|
|
|
|
{
|
|
|
|
if (self == [NSTextTemplate class])
|
|
|
|
{
|
|
|
|
[self setVersion: 0];
|
|
|
|
}
|
|
|
|
}
|
2006-05-20 22:12:46 +00:00
|
|
|
@end
|
2003-10-25 20:50:08 +00:00
|
|
|
|
2006-05-20 22:12:46 +00:00
|
|
|
// Template for any classes which derive from NSTextView
|
|
|
|
@implementation NSTextViewTemplate
|
|
|
|
+ (void) initialize
|
2003-10-25 20:50:08 +00:00
|
|
|
{
|
2006-05-20 22:12:46 +00:00
|
|
|
if (self == [NSTextViewTemplate class])
|
|
|
|
{
|
|
|
|
[self setVersion: 0];
|
|
|
|
}
|
2003-10-25 20:50:08 +00:00
|
|
|
}
|
|
|
|
|
2006-05-20 22:12:46 +00:00
|
|
|
- (id)nibInstantiate
|
2003-10-25 20:50:08 +00:00
|
|
|
{
|
2006-10-15 08:34:47 +00:00
|
|
|
if (_realObject == nil)
|
2006-05-20 22:12:46 +00:00
|
|
|
{
|
|
|
|
Class aClass = NSClassFromString(_className);
|
2006-10-15 08:34:47 +00:00
|
|
|
if (aClass == nil)
|
2007-11-27 00:09:24 +00:00
|
|
|
{
|
|
|
|
[NSException raise: NSInternalInconsistencyException
|
|
|
|
format: @"Unable to find class '%@'", _className];
|
|
|
|
}
|
2006-05-20 22:12:46 +00:00
|
|
|
else
|
2007-11-27 00:09:24 +00:00
|
|
|
{
|
|
|
|
_realObject = [[aClass allocWithZone: NSDefaultMallocZone()] initWithFrame: [self frame]];
|
|
|
|
[[self superview] replaceSubview: self with: _realObject]; // replace the old view...
|
|
|
|
}
|
2006-05-20 22:12:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return _realObject;
|
2003-10-25 20:50:08 +00:00
|
|
|
}
|
2006-05-20 22:12:46 +00:00
|
|
|
@end
|
2003-10-25 20:50:08 +00:00
|
|
|
|
2006-05-20 22:12:46 +00:00
|
|
|
// Template for any classes which derive from NSMenu.
|
|
|
|
@implementation NSMenuTemplate
|
|
|
|
+ (void) initialize
|
2003-10-25 20:50:08 +00:00
|
|
|
{
|
2006-05-20 22:12:46 +00:00
|
|
|
if (self == [NSMenuTemplate class])
|
|
|
|
{
|
|
|
|
[self setVersion: 0];
|
|
|
|
}
|
2003-10-25 20:50:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (id) initWithCoder: (NSCoder *)aCoder
|
|
|
|
{
|
2006-05-20 22:12:46 +00:00
|
|
|
return nil;
|
2003-10-25 20:50:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void) encodeWithCoder: (NSCoder *)aCoder
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2006-05-20 22:12:46 +00:00
|
|
|
- (id) nibInstantiate
|
2003-10-25 20:50:08 +00:00
|
|
|
{
|
2006-05-20 22:12:46 +00:00
|
|
|
return nil;
|
2003-10-25 20:50:08 +00:00
|
|
|
}
|
|
|
|
|
2006-05-20 22:12:46 +00:00
|
|
|
- (void) setClassName: (NSString *)className
|
2003-10-25 20:50:08 +00:00
|
|
|
{
|
2006-05-20 22:12:46 +00:00
|
|
|
ASSIGN(_menuClass, className);
|
|
|
|
}
|
2003-10-25 20:50:08 +00:00
|
|
|
|
2006-05-20 22:12:46 +00:00
|
|
|
- (NSString *)className
|
|
|
|
{
|
|
|
|
return _menuClass;
|
|
|
|
}
|
2003-10-25 20:50:08 +00:00
|
|
|
|
2006-05-20 22:12:46 +00:00
|
|
|
- (id) realObject
|
|
|
|
{
|
|
|
|
return _realObject;
|
2003-10-25 20:50:08 +00:00
|
|
|
}
|
2006-05-20 22:12:46 +00:00
|
|
|
@end
|
2003-10-25 20:50:08 +00:00
|
|
|
|
2006-05-20 22:12:46 +00:00
|
|
|
@implementation NSCustomObject
|
2003-10-25 20:50:08 +00:00
|
|
|
- (void) setClassName: (NSString *)name
|
|
|
|
{
|
2006-08-11 05:53:28 +00:00
|
|
|
ASSIGNCOPY(_className, name);
|
2003-10-25 20:50:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *)className
|
|
|
|
{
|
|
|
|
return _className;
|
|
|
|
}
|
|
|
|
|
2006-05-20 22:12:46 +00:00
|
|
|
- (void) setExtension: (NSString *)name
|
2003-10-25 20:50:08 +00:00
|
|
|
{
|
2006-08-11 05:53:28 +00:00
|
|
|
ASSIGNCOPY(_extension, name);
|
2003-10-25 20:50:08 +00:00
|
|
|
}
|
|
|
|
|
2006-05-20 22:12:46 +00:00
|
|
|
- (NSString *)extension
|
2003-10-25 20:50:08 +00:00
|
|
|
{
|
2006-05-20 22:12:46 +00:00
|
|
|
return _extension;
|
2003-10-25 20:50:08 +00:00
|
|
|
}
|
|
|
|
|
2006-05-20 22:12:46 +00:00
|
|
|
- (void) setObject: (id)obj
|
2003-10-25 20:50:08 +00:00
|
|
|
{
|
2006-05-20 22:12:46 +00:00
|
|
|
ASSIGN(_object, obj);
|
2003-10-25 20:50:08 +00:00
|
|
|
}
|
|
|
|
|
2006-05-20 22:12:46 +00:00
|
|
|
- (id) object
|
2003-10-25 20:50:08 +00:00
|
|
|
{
|
2006-05-20 22:12:46 +00:00
|
|
|
return _object;
|
2003-10-25 20:50:08 +00:00
|
|
|
}
|
|
|
|
|
2006-05-20 22:12:46 +00:00
|
|
|
- (id) initWithCoder: (NSCoder *)coder
|
2003-10-25 20:50:08 +00:00
|
|
|
{
|
2006-10-15 08:34:47 +00:00
|
|
|
if ([coder allowsKeyedCoding])
|
2006-05-20 22:12:46 +00:00
|
|
|
{
|
|
|
|
ASSIGN(_className, [coder decodeObjectForKey: @"NSClassName"]);
|
|
|
|
ASSIGN(_extension, [coder decodeObjectForKey: @"NSExtension"]);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-06-08 04:04:17 +00:00
|
|
|
[NSException raise: NSInvalidArgumentException
|
2007-11-27 00:09:24 +00:00
|
|
|
format: @"Can't decode %@ with %@.",NSStringFromClass([self class]),
|
|
|
|
NSStringFromClass([coder class])];
|
2006-05-20 22:12:46 +00:00
|
|
|
}
|
|
|
|
return self;
|
2003-10-25 20:50:08 +00:00
|
|
|
}
|
|
|
|
|
2006-05-20 22:12:46 +00:00
|
|
|
- (void) encodeWithCoder: (NSCoder *)coder
|
2003-10-25 20:50:08 +00:00
|
|
|
{
|
2006-10-15 08:34:47 +00:00
|
|
|
if ([coder allowsKeyedCoding])
|
2006-05-20 22:12:46 +00:00
|
|
|
{
|
|
|
|
[coder encodeObject: (id)_className forKey: @"NSClassName"];
|
|
|
|
[coder encodeConditionalObject: (id)_extension forKey: @"NSExtension"];
|
|
|
|
}
|
2006-06-08 04:04:17 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
[NSException raise: NSInvalidArgumentException
|
2007-11-27 00:09:24 +00:00
|
|
|
format: @"Keyed coding not implemented for %@.",
|
|
|
|
NSStringFromClass([self class])];
|
2006-06-08 04:04:17 +00:00
|
|
|
}
|
|
|
|
|
2003-10-25 20:50:08 +00:00
|
|
|
}
|
|
|
|
|
2006-05-20 22:12:46 +00:00
|
|
|
- (id) nibInstantiate
|
2003-10-25 20:50:08 +00:00
|
|
|
{
|
2006-10-15 08:34:47 +00:00
|
|
|
if (_object == nil)
|
2003-10-25 20:50:08 +00:00
|
|
|
{
|
2006-06-15 04:53:09 +00:00
|
|
|
Class aClass;
|
|
|
|
|
2006-10-15 08:34:47 +00:00
|
|
|
if ([NSClassSwapper isInInterfaceBuilder])
|
2007-11-27 00:09:24 +00:00
|
|
|
{
|
|
|
|
aClass = [self class];
|
|
|
|
}
|
2006-06-15 04:53:09 +00:00
|
|
|
else
|
2007-11-27 00:09:24 +00:00
|
|
|
{
|
|
|
|
aClass = NSClassFromString(_className);
|
|
|
|
}
|
2006-06-15 04:53:09 +00:00
|
|
|
|
2006-10-15 08:34:47 +00:00
|
|
|
if (aClass == nil)
|
2007-11-27 00:09:24 +00:00
|
|
|
{
|
|
|
|
[NSException raise: NSInternalInconsistencyException
|
|
|
|
format: @"Unable to find class '%@'", _className];
|
|
|
|
}
|
2006-05-20 22:12:46 +00:00
|
|
|
|
|
|
|
_object = [[aClass allocWithZone: NSDefaultMallocZone()] init];
|
2003-10-25 20:50:08 +00:00
|
|
|
}
|
2006-05-20 22:12:46 +00:00
|
|
|
return _object;
|
|
|
|
}
|
2006-08-26 14:10:18 +00:00
|
|
|
|
2007-11-27 00:09:24 +00:00
|
|
|
- (void) awakeFromNib
|
|
|
|
{
|
|
|
|
if ([_object respondsToSelector: @selector(awakeFromNib)])
|
|
|
|
{
|
|
|
|
[_object awakeFromNib];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-08-26 14:10:18 +00:00
|
|
|
- (void) dealloc
|
|
|
|
{
|
|
|
|
RELEASE(_className);
|
|
|
|
RELEASE(_extension);
|
|
|
|
[super dealloc];
|
|
|
|
}
|
2006-05-20 22:12:46 +00:00
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation NSCustomView
|
|
|
|
- (void) setClassName: (NSString *)name
|
|
|
|
{
|
2006-08-11 05:53:28 +00:00
|
|
|
ASSIGNCOPY(_className, name);
|
2006-05-20 22:12:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *)className
|
|
|
|
{
|
|
|
|
return _className;
|
|
|
|
}
|
|
|
|
- (void) setExtension: (NSString *)ext;
|
|
|
|
{
|
2006-08-11 05:53:28 +00:00
|
|
|
ASSIGNCOPY(_extension, ext);
|
2003-10-25 20:50:08 +00:00
|
|
|
}
|
|
|
|
|
2006-05-20 22:12:46 +00:00
|
|
|
- (NSString *)extension
|
2003-10-25 20:50:08 +00:00
|
|
|
{
|
2006-05-20 22:12:46 +00:00
|
|
|
return _extension;
|
|
|
|
}
|
2003-10-25 20:50:08 +00:00
|
|
|
|
2006-06-08 04:04:17 +00:00
|
|
|
- (id) nibInstantiate
|
2006-05-20 22:12:46 +00:00
|
|
|
{
|
2006-10-15 08:34:47 +00:00
|
|
|
if (_view == nil)
|
2003-10-25 20:50:08 +00:00
|
|
|
{
|
2006-06-15 04:53:09 +00:00
|
|
|
Class aClass;
|
|
|
|
|
2006-10-15 08:34:47 +00:00
|
|
|
if ([NSClassSwapper isInInterfaceBuilder])
|
2007-11-27 00:09:24 +00:00
|
|
|
{
|
|
|
|
aClass = [self class];
|
|
|
|
}
|
2006-06-15 04:53:09 +00:00
|
|
|
else
|
2007-11-27 00:09:24 +00:00
|
|
|
{
|
|
|
|
aClass = NSClassFromString(_className);
|
|
|
|
}
|
2006-06-15 04:53:09 +00:00
|
|
|
|
2006-10-15 08:34:47 +00:00
|
|
|
if (aClass == nil)
|
2007-11-27 00:09:24 +00:00
|
|
|
{
|
|
|
|
[NSException raise: NSInternalInconsistencyException
|
|
|
|
format: @"Unable to find class '%@'", _className];
|
|
|
|
}
|
2006-05-20 22:12:46 +00:00
|
|
|
else
|
2007-11-27 00:09:24 +00:00
|
|
|
{
|
|
|
|
_view = [[aClass allocWithZone: NSDefaultMallocZone()] initWithFrame: [self frame]];
|
|
|
|
[_view setAutoresizingMask: [self autoresizingMask]];
|
|
|
|
[self setAutoresizesSubviews: [self autoresizesSubviews]];
|
|
|
|
[self setHidden: [self isHidden]];
|
|
|
|
[_view setNextResponder: [self nextResponder]];
|
|
|
|
[[self superview] replaceSubview: self with: _view]; // replace the old view...
|
|
|
|
if (_rFlags.has_subviews)
|
|
|
|
{
|
|
|
|
NSArray *subviews = [self subviews];
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < [subviews count]; i++)
|
|
|
|
{
|
|
|
|
[_view addSubview: [subviews objectAtIndex: i]];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// FIXME: Need to transfer all other settings as well
|
|
|
|
}
|
2003-10-25 20:50:08 +00:00
|
|
|
}
|
|
|
|
|
2006-05-20 22:12:46 +00:00
|
|
|
return _view;
|
|
|
|
}
|
2003-10-25 20:50:08 +00:00
|
|
|
|
2006-05-20 22:12:46 +00:00
|
|
|
- (id) initWithCoder: (NSCoder *)coder
|
|
|
|
{
|
|
|
|
self = [super initWithCoder: coder];
|
2006-10-15 08:34:47 +00:00
|
|
|
if (self != nil)
|
2006-05-20 22:12:46 +00:00
|
|
|
{
|
2006-10-15 08:34:47 +00:00
|
|
|
if ([coder allowsKeyedCoding])
|
2007-11-27 00:09:24 +00:00
|
|
|
{
|
|
|
|
ASSIGN(_className, [coder decodeObjectForKey: @"NSClassName"]);
|
|
|
|
ASSIGN(_extension, [coder decodeObjectForKey: @"NSExtension"]);
|
|
|
|
}
|
2006-06-08 04:04:17 +00:00
|
|
|
else
|
2007-11-27 00:09:24 +00:00
|
|
|
{
|
|
|
|
[NSException raise: NSInvalidArgumentException
|
|
|
|
format: @"Can't decode %@ with %@.",NSStringFromClass([self class]),
|
|
|
|
NSStringFromClass([coder class])];
|
|
|
|
}
|
2006-05-20 22:12:46 +00:00
|
|
|
}
|
|
|
|
return self;
|
|
|
|
}
|
2003-10-25 20:50:08 +00:00
|
|
|
|
2006-05-20 22:12:46 +00:00
|
|
|
- (void) encodeWithCoder: (NSCoder *)coder
|
|
|
|
{
|
2006-08-11 05:53:28 +00:00
|
|
|
[super encodeWithCoder: coder];
|
2006-10-15 08:34:47 +00:00
|
|
|
if ([coder allowsKeyedCoding])
|
2006-05-20 22:12:46 +00:00
|
|
|
{
|
2006-08-11 05:53:28 +00:00
|
|
|
[coder encodeObject: _className forKey: @"NSClassName"];
|
|
|
|
[coder encodeObject: _extension forKey: @"NSExtension"];
|
2006-05-20 22:12:46 +00:00
|
|
|
}
|
2006-06-08 04:04:17 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
[NSException raise: NSInvalidArgumentException
|
2007-11-27 00:09:24 +00:00
|
|
|
format: @"Can't encode %@ with %@.",NSStringFromClass([self class]),
|
|
|
|
NSStringFromClass([coder class])];
|
2006-06-08 04:04:17 +00:00
|
|
|
}
|
2006-05-20 22:12:46 +00:00
|
|
|
}
|
|
|
|
@end
|
2003-10-25 20:50:08 +00:00
|
|
|
|
2006-05-20 22:12:46 +00:00
|
|
|
@implementation NSCustomResource
|
|
|
|
- (void) setClassName: (NSString *)className
|
|
|
|
{
|
2006-08-11 05:53:28 +00:00
|
|
|
ASSIGNCOPY(_className, className);
|
2006-05-20 22:12:46 +00:00
|
|
|
}
|
2003-10-25 20:50:08 +00:00
|
|
|
|
2006-05-20 22:12:46 +00:00
|
|
|
- (NSString *)className
|
|
|
|
{
|
|
|
|
return _className;
|
|
|
|
}
|
2003-10-25 20:50:08 +00:00
|
|
|
|
2006-05-20 22:12:46 +00:00
|
|
|
- (void) setResourceName: (NSString *)resourceName
|
|
|
|
{
|
2006-08-11 05:53:28 +00:00
|
|
|
ASSIGNCOPY(_resourceName, resourceName);
|
2003-10-25 20:50:08 +00:00
|
|
|
}
|
|
|
|
|
2006-05-20 22:12:46 +00:00
|
|
|
- (NSString *)resourceName
|
2003-10-25 20:50:08 +00:00
|
|
|
{
|
2006-05-20 22:12:46 +00:00
|
|
|
return _resourceName;
|
2003-10-25 20:50:08 +00:00
|
|
|
}
|
|
|
|
|
2006-05-20 22:12:46 +00:00
|
|
|
- (id)nibInstantiate
|
2003-10-25 20:50:08 +00:00
|
|
|
{
|
2006-05-20 22:12:46 +00:00
|
|
|
return self;
|
2003-10-25 20:50:08 +00:00
|
|
|
}
|
|
|
|
|
2006-05-20 22:12:46 +00:00
|
|
|
- (id) initWithCoder: (NSCoder *)coder
|
2003-10-25 20:50:08 +00:00
|
|
|
{
|
2006-05-20 22:12:46 +00:00
|
|
|
id realObject = nil;
|
2006-10-15 08:34:47 +00:00
|
|
|
if ([coder allowsKeyedCoding])
|
2003-10-25 20:50:08 +00:00
|
|
|
{
|
2006-05-20 22:12:46 +00:00
|
|
|
ASSIGN(_className, [coder decodeObjectForKey: @"NSClassName"]);
|
|
|
|
ASSIGN(_resourceName, [coder decodeObjectForKey: @"NSResourceName"]);
|
|
|
|
|
|
|
|
// this is a hack, but for now it should do.
|
2006-10-15 08:34:47 +00:00
|
|
|
if ([_className isEqual: @"NSSound"])
|
2007-11-27 00:09:24 +00:00
|
|
|
{
|
|
|
|
realObject = RETAIN([NSSound soundNamed: _resourceName]);
|
|
|
|
}
|
2006-10-15 08:34:47 +00:00
|
|
|
else if ([_className isEqual: @"NSImage"])
|
2007-11-27 00:09:24 +00:00
|
|
|
{
|
|
|
|
realObject = RETAIN([NSImage imageNamed: _resourceName]);
|
|
|
|
}
|
2006-05-20 22:12:46 +00:00
|
|
|
|
|
|
|
// if an object has been substituted, then release the placeholder.
|
2006-10-15 08:34:47 +00:00
|
|
|
if (realObject != nil)
|
2007-11-27 00:09:24 +00:00
|
|
|
{
|
|
|
|
RELEASE(self);
|
|
|
|
}
|
2006-05-20 22:12:46 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-06-08 04:04:17 +00:00
|
|
|
[NSException raise: NSInvalidArgumentException
|
2007-11-27 00:09:24 +00:00
|
|
|
format: @"Can't decode %@ with %@.",NSStringFromClass([self class]),
|
|
|
|
NSStringFromClass([coder class])];
|
2003-10-25 20:50:08 +00:00
|
|
|
}
|
2006-05-20 22:12:46 +00:00
|
|
|
|
|
|
|
return realObject;
|
2003-10-25 20:50:08 +00:00
|
|
|
}
|
|
|
|
|
2006-05-20 22:12:46 +00:00
|
|
|
- (void) encodeWithCoder: (NSCoder *)coder
|
2003-10-25 20:50:08 +00:00
|
|
|
{
|
2006-10-15 08:34:47 +00:00
|
|
|
if ([coder allowsKeyedCoding])
|
2006-05-20 22:12:46 +00:00
|
|
|
{
|
|
|
|
[coder encodeObject: (id)_className forKey: @"NSClassName"];
|
|
|
|
[coder encodeObject: (id)_resourceName forKey: @"NSResourceName"];
|
|
|
|
}
|
2003-10-25 20:50:08 +00:00
|
|
|
}
|
2006-05-20 22:12:46 +00:00
|
|
|
@end
|
|
|
|
|
|
|
|
@interface NSKeyedUnarchiver (NSClassSwapperPrivate)
|
|
|
|
- (BOOL) replaceObject: (id)oldObj withObject: (id)newObj;
|
2006-05-20 23:46:51 +00:00
|
|
|
- (NSDictionary *)keyMap;
|
2006-05-20 22:12:46 +00:00
|
|
|
@end
|
2003-10-25 20:50:08 +00:00
|
|
|
|
2006-05-20 22:25:54 +00:00
|
|
|
@implementation NSKeyedUnarchiver (NSClassSwapperPrivate)
|
|
|
|
- (BOOL) replaceObject: (id)oldObj withObject: (id)newObj
|
|
|
|
{
|
|
|
|
unsigned int i = 0;
|
|
|
|
unsigned int count = GSIArrayCount(_objMap);
|
2006-10-15 08:34:47 +00:00
|
|
|
for (i = 0; i < count; i++)
|
2006-05-20 22:25:54 +00:00
|
|
|
{
|
|
|
|
id obj = GSIArrayItemAtIndex(_objMap, i).obj;
|
2006-10-15 08:34:47 +00:00
|
|
|
if (obj == oldObj)
|
2007-11-27 00:09:24 +00:00
|
|
|
break;
|
2006-05-20 22:25:54 +00:00
|
|
|
}
|
|
|
|
|
2006-10-15 08:34:47 +00:00
|
|
|
if (i < count)
|
2006-05-20 22:25:54 +00:00
|
|
|
{
|
|
|
|
GSIArraySetItemAtIndex(_objMap, (GSIArrayItem)newObj, i);
|
|
|
|
return YES;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NO;
|
|
|
|
}
|
2006-05-20 23:46:51 +00:00
|
|
|
|
|
|
|
- (NSDictionary *)keyMap
|
|
|
|
{
|
|
|
|
return _keyMap;
|
|
|
|
}
|
2006-05-20 22:25:54 +00:00
|
|
|
@end
|
|
|
|
|
2006-05-20 22:12:46 +00:00
|
|
|
@implementation NSClassSwapper
|
2006-08-05 12:46:20 +00:00
|
|
|
- (id) initWithObject: (id)object
|
|
|
|
withClassName: (NSString *)className
|
|
|
|
originalClassName: (NSString *)origClassName
|
|
|
|
{
|
2006-10-15 08:34:47 +00:00
|
|
|
if ((self = [super init]) != nil)
|
2006-08-05 12:46:20 +00:00
|
|
|
{
|
|
|
|
[self setTemplate: object];
|
|
|
|
[self setClassName: className];
|
|
|
|
[self setOriginalClassName: origClassName];
|
|
|
|
}
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2006-06-15 04:53:09 +00:00
|
|
|
+ (void) setIsInInterfaceBuilder: (BOOL)flag
|
|
|
|
{
|
|
|
|
_isInInterfaceBuilder = flag;
|
|
|
|
}
|
|
|
|
|
|
|
|
+ (BOOL) isInInterfaceBuilder
|
|
|
|
{
|
|
|
|
return _isInInterfaceBuilder;
|
|
|
|
}
|
|
|
|
|
2006-05-20 22:12:46 +00:00
|
|
|
- (void) setTemplate: (id)temp
|
2003-10-25 20:50:08 +00:00
|
|
|
{
|
2006-05-20 22:12:46 +00:00
|
|
|
ASSIGN(_template, temp);
|
2003-10-25 20:50:08 +00:00
|
|
|
}
|
|
|
|
|
2006-05-20 22:12:46 +00:00
|
|
|
- (id) template
|
2003-10-25 20:50:08 +00:00
|
|
|
{
|
2006-05-20 22:12:46 +00:00
|
|
|
return _template;
|
2003-10-25 20:50:08 +00:00
|
|
|
}
|
|
|
|
|
2006-05-20 22:12:46 +00:00
|
|
|
- (void) setClassName: (NSString *)className
|
2003-10-25 20:50:08 +00:00
|
|
|
{
|
2006-08-11 05:53:28 +00:00
|
|
|
ASSIGNCOPY(_className, className);
|
2003-10-25 20:50:08 +00:00
|
|
|
}
|
|
|
|
|
2006-05-20 22:12:46 +00:00
|
|
|
- (NSString *)className
|
2003-10-25 20:50:08 +00:00
|
|
|
{
|
2006-05-20 22:12:46 +00:00
|
|
|
return _className;
|
|
|
|
}
|
|
|
|
|
2006-08-05 12:46:20 +00:00
|
|
|
- (void) setOriginalClassName: (NSString *)className
|
|
|
|
{
|
2006-08-11 05:53:28 +00:00
|
|
|
ASSIGNCOPY(_originalClassName, className);
|
2006-08-05 12:46:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *)originalClassName
|
|
|
|
{
|
|
|
|
return _originalClassName;
|
|
|
|
}
|
|
|
|
|
2006-05-20 22:12:46 +00:00
|
|
|
- (void) instantiateRealObject: (NSCoder *)coder withClassName: (NSString *)className
|
2003-10-25 20:50:08 +00:00
|
|
|
{
|
2006-06-17 14:53:12 +00:00
|
|
|
Class aClass = nil;
|
2006-05-20 22:12:46 +00:00
|
|
|
id object = nil;
|
|
|
|
Class newCellClass = nil;
|
|
|
|
NSString *origCellClassName = nil;
|
|
|
|
Class origCellClass = nil;
|
2003-10-25 20:50:08 +00:00
|
|
|
|
2006-06-17 14:53:12 +00:00
|
|
|
// if there is a replacement class, use it, otherwise, use the one specified.
|
2006-10-15 08:34:47 +00:00
|
|
|
if ((aClass = [(NSKeyedUnarchiver *)coder classForClassName: className]) == nil)
|
2006-06-17 14:53:12 +00:00
|
|
|
{
|
|
|
|
aClass = NSClassFromString(className);
|
|
|
|
}
|
|
|
|
|
2006-10-15 08:34:47 +00:00
|
|
|
if (aClass == nil)
|
2003-10-25 20:50:08 +00:00
|
|
|
{
|
|
|
|
[NSException raise: NSInternalInconsistencyException
|
2007-11-27 00:09:24 +00:00
|
|
|
format: @"NSClassSwapper unable to find class '%@'", className];
|
2003-10-25 20:50:08 +00:00
|
|
|
}
|
|
|
|
|
2006-05-20 22:12:46 +00:00
|
|
|
// if this is a class which uses cells, override with the new cellClass, if the
|
|
|
|
// subclass responds to cellClass.
|
2006-10-15 08:34:47 +00:00
|
|
|
if ([aClass respondsToSelector: @selector(cellClass)] &&
|
2006-05-20 22:12:46 +00:00
|
|
|
[className isEqualToString: _originalClassName] == NO)
|
|
|
|
{
|
|
|
|
Class origClass = NSClassFromString(_originalClassName);
|
2003-10-25 20:50:08 +00:00
|
|
|
|
2006-05-20 22:12:46 +00:00
|
|
|
origCellClass = [origClass cellClass];
|
|
|
|
newCellClass = [aClass cellClass];
|
|
|
|
origCellClassName = NSStringFromClass(origCellClass);
|
|
|
|
[(NSKeyedUnarchiver *)coder setClass: newCellClass forClassName: origCellClassName];
|
|
|
|
}
|
2003-10-25 20:50:08 +00:00
|
|
|
|
2006-05-20 22:12:46 +00:00
|
|
|
// swap the class...
|
|
|
|
object = [aClass allocWithZone: NSDefaultMallocZone()];
|
|
|
|
[(NSKeyedUnarchiver *)coder replaceObject: self withObject: object];
|
2006-08-05 12:46:20 +00:00
|
|
|
[self setTemplate: [object initWithCoder: coder]];
|
2006-10-15 08:34:47 +00:00
|
|
|
if (object != _template)
|
2006-05-20 22:12:46 +00:00
|
|
|
{
|
|
|
|
[(NSKeyedUnarchiver *)coder replaceObject: object withObject: _template];
|
|
|
|
}
|
2003-10-25 20:50:08 +00:00
|
|
|
|
2006-10-15 08:34:47 +00:00
|
|
|
if (newCellClass != nil && origCellClass != nil)
|
2006-05-20 22:12:46 +00:00
|
|
|
{
|
|
|
|
[(NSKeyedUnarchiver *)coder setClass: origCellClass forClassName: nil];
|
|
|
|
}
|
2003-10-25 20:50:08 +00:00
|
|
|
}
|
|
|
|
|
2006-05-20 22:12:46 +00:00
|
|
|
- (id) initWithCoder: (NSCoder *)coder
|
2003-10-25 20:50:08 +00:00
|
|
|
{
|
2006-10-15 08:34:47 +00:00
|
|
|
if ([coder allowsKeyedCoding])
|
2006-05-20 22:12:46 +00:00
|
|
|
{
|
|
|
|
ASSIGN(_className, [coder decodeObjectForKey: @"NSClassName"]);
|
|
|
|
ASSIGN(_originalClassName, [coder decodeObjectForKey: @"NSOriginalClassName"]);
|
2003-10-25 20:50:08 +00:00
|
|
|
|
2006-05-20 22:12:46 +00:00
|
|
|
// build the real object...
|
2006-10-15 08:34:47 +00:00
|
|
|
if ([NSClassSwapper isInInterfaceBuilder] == YES)
|
2007-11-27 00:09:24 +00:00
|
|
|
{
|
|
|
|
[self instantiateRealObject: coder withClassName: _originalClassName];
|
|
|
|
}
|
2006-05-20 22:12:46 +00:00
|
|
|
else
|
2007-11-27 00:09:24 +00:00
|
|
|
{
|
|
|
|
[self instantiateRealObject: coder withClassName: _className];
|
|
|
|
}
|
2006-05-20 22:12:46 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-06-08 04:04:17 +00:00
|
|
|
[NSException raise: NSInvalidArgumentException
|
2007-11-27 00:09:24 +00:00
|
|
|
format: @"Can't decode %@ with %@.",NSStringFromClass([self class]),
|
|
|
|
NSStringFromClass([coder class])];
|
2006-05-20 22:12:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return _template;
|
2003-10-25 20:50:08 +00:00
|
|
|
}
|
|
|
|
|
2006-05-20 22:12:46 +00:00
|
|
|
- (void) encodeWithCoder: (NSCoder *)coder
|
2003-10-25 20:50:08 +00:00
|
|
|
{
|
2006-10-15 08:34:47 +00:00
|
|
|
if ([coder allowsKeyedCoding])
|
2006-05-20 22:12:46 +00:00
|
|
|
{
|
2006-08-11 05:53:28 +00:00
|
|
|
[coder encodeObject: _originalClassName forKey: @"NSOriginalClassName"];
|
|
|
|
[coder encodeObject: _className forKey: @"NSClassName"];
|
2006-08-05 12:46:20 +00:00
|
|
|
[_template encodeWithCoder: coder]; // encode the actual object;
|
2006-05-20 22:12:46 +00:00
|
|
|
}
|
2006-06-08 04:04:17 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
[NSException raise: NSInvalidArgumentException
|
2007-11-27 00:09:24 +00:00
|
|
|
format: @"Can't encode %@ with %@.",NSStringFromClass([self class]),
|
|
|
|
NSStringFromClass([coder class])];
|
2006-06-08 04:04:17 +00:00
|
|
|
}
|
2003-10-25 20:50:08 +00:00
|
|
|
}
|
2006-06-04 05:16:37 +00:00
|
|
|
|
|
|
|
- (void) dealloc
|
|
|
|
{
|
|
|
|
RELEASE(_className);
|
|
|
|
RELEASE(_originalClassName);
|
|
|
|
RELEASE(_template);
|
|
|
|
[super dealloc];
|
|
|
|
}
|
2003-10-25 20:50:08 +00:00
|
|
|
@end
|
|
|
|
|
2006-05-20 22:12:46 +00:00
|
|
|
/* Correct some instances where the ":" is missing from the method name in the label */
|
|
|
|
@interface NSNibControlConnector (NibCompatibility)
|
|
|
|
- (void) instantiateWithInstantiator: (id<GSInstantiator>)instantiator;
|
|
|
|
@end
|
2003-10-25 20:50:08 +00:00
|
|
|
|
2006-05-20 22:12:46 +00:00
|
|
|
@implementation NSNibControlConnector (NibCompatibility)
|
|
|
|
- (void) instantiateWithInstantiator: (id<GSInstantiator>)instantiator
|
2003-10-25 20:50:08 +00:00
|
|
|
{
|
2006-05-20 22:12:46 +00:00
|
|
|
NSRange colonRange = [_tag rangeOfString: @":"];
|
|
|
|
unsigned int location = colonRange.location;
|
|
|
|
|
2006-10-15 08:34:47 +00:00
|
|
|
if (location == NSNotFound)
|
2003-10-25 20:50:08 +00:00
|
|
|
{
|
2006-05-20 22:12:46 +00:00
|
|
|
NSString *newTag = [NSString stringWithFormat: @"%@:",_tag];
|
|
|
|
[self setLabel: (id)newTag];
|
2003-10-25 20:50:08 +00:00
|
|
|
}
|
2006-05-20 22:12:46 +00:00
|
|
|
|
|
|
|
[super instantiateWithInstantiator: instantiator];
|
2003-10-25 20:50:08 +00:00
|
|
|
}
|
2006-05-20 22:12:46 +00:00
|
|
|
@end
|
2003-10-25 20:50:08 +00:00
|
|
|
|
2006-05-20 22:12:46 +00:00
|
|
|
@implementation NSIBObjectData
|
|
|
|
- (id)instantiateObject: (id)obj
|
2003-10-25 20:50:08 +00:00
|
|
|
{
|
2006-05-20 22:12:46 +00:00
|
|
|
id newObject = obj;
|
2006-10-15 08:34:47 +00:00
|
|
|
if ([obj respondsToSelector: @selector(nibInstantiate)])
|
2006-05-20 22:12:46 +00:00
|
|
|
{
|
|
|
|
newObject = [obj nibInstantiate];
|
|
|
|
}
|
|
|
|
return newObject;
|
2003-10-25 20:50:08 +00:00
|
|
|
}
|
|
|
|
|
2006-05-20 22:12:46 +00:00
|
|
|
- (void) nibInstantiateWithOwner: (id)owner
|
2003-10-25 20:50:08 +00:00
|
|
|
{
|
2006-05-20 22:12:46 +00:00
|
|
|
[self nibInstantiateWithOwner: owner topLevelObjects: nil];
|
|
|
|
}
|
2003-10-25 20:50:08 +00:00
|
|
|
|
2006-05-20 22:12:46 +00:00
|
|
|
- (void) nibInstantiateWithOwner: (id)owner topLevelObjects: (NSMutableArray *)topLevelObjects
|
|
|
|
{
|
|
|
|
NSEnumerator *en = [_connections objectEnumerator];
|
2006-06-25 04:29:15 +00:00
|
|
|
NSArray *objs = NSAllMapTableKeys([self names]);
|
2006-05-20 22:12:46 +00:00
|
|
|
id obj = nil;
|
|
|
|
id menu = nil;
|
2006-06-25 04:29:15 +00:00
|
|
|
|
2006-05-20 22:12:46 +00:00
|
|
|
// replace the owner with the actual instance provided.
|
|
|
|
[_root setObject: owner];
|
|
|
|
|
|
|
|
// iterate over connections, instantiate, and then establish them.
|
2006-10-15 08:34:47 +00:00
|
|
|
while ((obj = [en nextObject]) != nil)
|
2006-05-20 22:12:46 +00:00
|
|
|
{
|
2006-10-15 08:34:47 +00:00
|
|
|
if ([obj respondsToSelector: @selector(instantiateWithInstantiator:)])
|
2007-11-27 00:09:24 +00:00
|
|
|
{
|
|
|
|
[obj instantiateWithInstantiator: self];
|
|
|
|
[obj establishConnection];
|
|
|
|
}
|
2006-05-20 22:12:46 +00:00
|
|
|
}
|
|
|
|
|
2007-11-24 17:39:44 +00:00
|
|
|
// iterate over all objects instantiate windows, awaken objects and fill
|
|
|
|
// in top level array.
|
2006-06-25 04:29:15 +00:00
|
|
|
en = [objs objectEnumerator];
|
2006-10-15 08:34:47 +00:00
|
|
|
while ((obj = [en nextObject]) != nil)
|
2006-06-25 04:29:15 +00:00
|
|
|
{
|
2007-11-24 17:39:44 +00:00
|
|
|
// instantiate all windows and fill in the top level array.
|
2006-10-15 08:34:47 +00:00
|
|
|
if ([obj isKindOfClass: [NSWindowTemplate class]])
|
2007-11-27 00:09:24 +00:00
|
|
|
{
|
|
|
|
if ([obj realObject] == nil)
|
|
|
|
{
|
|
|
|
obj = [self instantiateObject: obj];
|
|
|
|
[topLevelObjects addObject: obj];
|
|
|
|
}
|
|
|
|
}
|
2006-06-25 04:29:15 +00:00
|
|
|
else
|
2007-11-27 00:09:24 +00:00
|
|
|
{
|
|
|
|
id v = NSMapGet(_objects, obj);
|
|
|
|
if (v == nil || v == owner)
|
|
|
|
{
|
|
|
|
[topLevelObjects addObject: obj];
|
|
|
|
}
|
|
|
|
}
|
2007-11-24 17:39:44 +00:00
|
|
|
|
|
|
|
// awaken the object.
|
|
|
|
if ([obj respondsToSelector: @selector(awakeFromNib)])
|
2007-11-27 00:09:24 +00:00
|
|
|
{
|
|
|
|
[obj awakeFromNib];
|
|
|
|
}
|
2006-06-25 04:29:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// bring visible windows to front...
|
2006-05-20 22:12:46 +00:00
|
|
|
en = [_visibleWindows objectEnumerator];
|
2006-10-15 08:34:47 +00:00
|
|
|
while ((obj = [en nextObject]) != nil)
|
2006-05-20 22:12:46 +00:00
|
|
|
{
|
2006-06-25 04:29:15 +00:00
|
|
|
id w = [obj realObject];
|
2006-05-20 22:12:46 +00:00
|
|
|
[w orderFront: self];
|
|
|
|
}
|
|
|
|
|
2006-06-25 04:29:15 +00:00
|
|
|
// add the menu...
|
2006-05-20 22:12:46 +00:00
|
|
|
menu = [self objectForName: @"MainMenu"];
|
2006-10-15 08:34:47 +00:00
|
|
|
if (menu != nil)
|
2006-05-20 22:12:46 +00:00
|
|
|
{
|
|
|
|
menu = [self instantiateObject: menu];
|
|
|
|
[NSApp setMainMenu: menu];
|
|
|
|
}
|
2003-10-25 20:50:08 +00:00
|
|
|
}
|
|
|
|
|
2006-05-20 22:12:46 +00:00
|
|
|
- (void) awakeWithContext: (NSDictionary *)context
|
2003-10-25 20:50:08 +00:00
|
|
|
{
|
2006-05-20 22:12:46 +00:00
|
|
|
NSMutableArray *tlo = [context objectForKey: @"NSTopLevelObjects"];
|
|
|
|
id owner = [context objectForKey: @"NSOwner"];
|
|
|
|
[self nibInstantiateWithOwner: owner topLevelObjects: tlo];
|
2003-10-25 20:50:08 +00:00
|
|
|
}
|
|
|
|
|
2006-05-20 22:12:46 +00:00
|
|
|
- (NSMutableArray *) connections
|
2003-10-25 20:50:08 +00:00
|
|
|
{
|
2006-05-20 22:12:46 +00:00
|
|
|
return _connections;
|
2003-10-25 20:50:08 +00:00
|
|
|
}
|
|
|
|
|
2006-05-20 22:12:46 +00:00
|
|
|
- (NSMutableSet *) topLevelObjects
|
2003-10-25 20:50:08 +00:00
|
|
|
{
|
2006-06-15 04:53:09 +00:00
|
|
|
return _topLevelObjects;
|
2003-10-25 20:50:08 +00:00
|
|
|
}
|
|
|
|
|
2006-05-20 22:12:46 +00:00
|
|
|
- (NSMutableDictionary *) nameTable
|
2003-10-25 20:50:08 +00:00
|
|
|
{
|
2006-05-20 22:12:46 +00:00
|
|
|
return nil;
|
2003-10-25 20:50:08 +00:00
|
|
|
}
|
|
|
|
|
2006-08-05 12:46:20 +00:00
|
|
|
- (NSMutableArray *) visibleWindows
|
2006-06-08 04:04:17 +00:00
|
|
|
{
|
2006-08-05 12:46:20 +00:00
|
|
|
return _visibleWindows;
|
2006-06-08 04:04:17 +00:00
|
|
|
}
|
|
|
|
|
2006-06-21 01:02:25 +00:00
|
|
|
- (NSMapTable *) objects
|
2006-06-08 04:04:17 +00:00
|
|
|
{
|
2006-06-15 04:53:09 +00:00
|
|
|
return _objects;
|
2006-06-08 04:04:17 +00:00
|
|
|
}
|
|
|
|
|
2006-06-21 01:02:25 +00:00
|
|
|
- (NSMapTable *) names
|
|
|
|
{
|
|
|
|
return _names;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSMapTable *) classes
|
|
|
|
{
|
|
|
|
return _classes;
|
|
|
|
}
|
|
|
|
|
2006-08-15 05:04:35 +00:00
|
|
|
- (NSMapTable *) oids
|
|
|
|
{
|
|
|
|
return _oids;
|
|
|
|
}
|
|
|
|
|
2006-05-20 22:12:46 +00:00
|
|
|
- (id) objectForName: (NSString *)name
|
2003-10-25 20:50:08 +00:00
|
|
|
{
|
2006-05-20 22:12:46 +00:00
|
|
|
NSArray *nameKeys = (NSArray *)NSAllMapTableKeys(_names);
|
|
|
|
NSArray *nameValues = (NSArray *)NSAllMapTableValues(_names);
|
|
|
|
int i = [nameValues indexOfObject: name];
|
|
|
|
id result = nil;
|
2003-10-25 20:50:08 +00:00
|
|
|
|
2006-10-15 08:34:47 +00:00
|
|
|
if (i != NSNotFound)
|
2003-10-25 20:50:08 +00:00
|
|
|
{
|
2006-05-20 22:12:46 +00:00
|
|
|
result = [nameKeys objectAtIndex: i];
|
2003-10-25 20:50:08 +00:00
|
|
|
}
|
|
|
|
|
2006-05-20 22:12:46 +00:00
|
|
|
return result;
|
|
|
|
}
|
2003-10-25 20:50:08 +00:00
|
|
|
|
2006-05-20 22:12:46 +00:00
|
|
|
- (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;
|
|
|
|
}
|
2003-10-25 20:50:08 +00:00
|
|
|
|
2006-06-04 05:16:37 +00:00
|
|
|
/**
|
|
|
|
* Get the values from the map in the same order as the keys.
|
|
|
|
*/
|
|
|
|
- (NSArray *) _valuesForKeys: (NSArray *)keys inMap: (NSMapTable *)map
|
|
|
|
{
|
|
|
|
NSMutableArray *result = [NSMutableArray array];
|
|
|
|
NSEnumerator *en = [keys objectEnumerator];
|
|
|
|
id key = nil;
|
2006-10-15 08:34:47 +00:00
|
|
|
while ((key = [en nextObject]) != nil)
|
2006-06-04 05:16:37 +00:00
|
|
|
{
|
|
|
|
id value = (id)NSMapGet(map,key);
|
|
|
|
[result addObject: value];
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2006-05-20 22:12:46 +00:00
|
|
|
- (void) encodeWithCoder: (NSCoder *)coder
|
|
|
|
{
|
2006-10-15 08:34:47 +00:00
|
|
|
if ([coder allowsKeyedCoding])
|
2006-05-20 22:12:46 +00:00
|
|
|
{
|
|
|
|
NSArray *accessibilityOidsKeys = (NSArray *)NSAllMapTableKeys(_accessibilityOids);
|
2006-06-04 05:16:37 +00:00
|
|
|
NSArray *accessibilityOidsValues = [self _valuesForKeys: accessibilityOidsKeys inMap: _accessibilityOids];
|
2006-05-20 22:12:46 +00:00
|
|
|
NSArray *classKeys = (NSArray *)NSAllMapTableKeys(_classes);
|
2006-06-04 05:16:37 +00:00
|
|
|
NSArray *classValues = [self _valuesForKeys: classKeys inMap: _classes];
|
2006-05-20 22:12:46 +00:00
|
|
|
NSArray *nameKeys = (NSArray *)NSAllMapTableKeys(_names);
|
2006-06-04 05:16:37 +00:00
|
|
|
NSArray *nameValues = [self _valuesForKeys: nameKeys inMap: _names];
|
2006-05-20 22:12:46 +00:00
|
|
|
NSArray *objectsKeys = (NSArray *)NSAllMapTableKeys(_objects);
|
2006-06-04 05:16:37 +00:00
|
|
|
NSArray *objectsValues = [self _valuesForKeys: objectsKeys inMap: _objects];
|
2006-05-20 22:12:46 +00:00
|
|
|
NSArray *oidsKeys = (NSArray *)NSAllMapTableKeys(_oids);
|
2006-06-04 05:16:37 +00:00
|
|
|
NSArray *oidsValues = [self _valuesForKeys: oidsKeys inMap: _oids];
|
2006-05-20 22:12:46 +00:00
|
|
|
|
2006-08-12 22:44:56 +00:00
|
|
|
[(NSKeyedArchiver *)coder setClassName: @"_NSCornerView" forClass: NSClassFromString(@"GSTableCornerView")];
|
|
|
|
|
2006-05-20 22:12:46 +00:00
|
|
|
[coder encodeObject: (id)_accessibilityConnectors forKey: @"NSAccessibilityConnectors"];
|
|
|
|
[coder encodeObject: (id) accessibilityOidsKeys forKey: @"NSAccessibilityOidsKeys"];
|
|
|
|
[coder encodeObject: (id) accessibilityOidsValues forKey: @"NSAccessibilityOidsValues"];
|
|
|
|
[coder encodeObject: (id) classKeys forKey: @"NSClassesKeys"];
|
|
|
|
[coder encodeObject: (id) classValues forKey: @"NSClassesValues"];
|
|
|
|
[coder encodeObject: (id) nameKeys forKey: @"NSNamesKeys"];
|
|
|
|
[coder encodeObject: (id) nameValues forKey: @"NSNamesValues"];
|
|
|
|
[coder encodeObject: (id) objectsKeys forKey: @"NSObjectsKeys"];
|
|
|
|
[coder encodeObject: (id) objectsValues forKey: @"NSObjectsValues"];
|
|
|
|
[coder encodeObject: (id) oidsKeys forKey: @"NSOidsKeys"];
|
|
|
|
[coder encodeObject: (id) oidsValues forKey: @"NSOidsValues"];
|
|
|
|
[coder encodeObject: (id) _connections forKey: @"NSConnections"];
|
2006-08-11 05:53:28 +00:00
|
|
|
[coder encodeObject: (id) _fontManager forKey: @"NSFontManager"];
|
|
|
|
[coder encodeObject: (id) _framework forKey: @"NSFramework"];
|
2006-05-20 22:12:46 +00:00
|
|
|
[coder encodeObject: (id) _visibleWindows forKey: @"NSVisibleWindows"];
|
|
|
|
[coder encodeInt: _nextOid forKey: @"NSNextOid"];
|
|
|
|
[coder encodeConditionalObject: (id) _root forKey: @"NSRoot"];
|
|
|
|
}
|
2006-06-08 04:04:17 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
[NSException raise: NSInvalidArgumentException
|
2007-11-27 00:09:24 +00:00
|
|
|
format: @"Can't encode %@ with %@.",NSStringFromClass([self class]),
|
|
|
|
NSStringFromClass([coder class])];
|
2006-06-08 04:04:17 +00:00
|
|
|
}
|
2003-10-25 20:50:08 +00:00
|
|
|
}
|
|
|
|
|
2006-05-20 22:12:46 +00:00
|
|
|
- (void) _buildMap: (NSMapTable *)mapTable
|
2007-11-27 00:09:24 +00:00
|
|
|
withKeys: (NSArray *)keys
|
|
|
|
andValues: (NSArray *)values
|
2003-10-25 20:50:08 +00:00
|
|
|
{
|
2006-05-20 22:12:46 +00:00
|
|
|
NSEnumerator *ken = [keys objectEnumerator];
|
|
|
|
NSEnumerator *ven = [values objectEnumerator];
|
|
|
|
id key = nil;
|
|
|
|
id value = nil;
|
|
|
|
|
2006-10-15 08:34:47 +00:00
|
|
|
while ((key = [ken nextObject]) != nil && (value = [ven nextObject]) != nil)
|
2006-05-20 22:12:46 +00:00
|
|
|
{
|
|
|
|
NSMapInsert(mapTable, key, value);
|
|
|
|
}
|
2003-10-25 20:50:08 +00:00
|
|
|
}
|
|
|
|
|
2006-05-20 22:12:46 +00:00
|
|
|
- (id) initWithCoder: (NSCoder *)coder
|
2003-10-25 20:50:08 +00:00
|
|
|
{
|
2006-10-15 08:34:47 +00:00
|
|
|
if ([coder allowsKeyedCoding])
|
2006-05-20 22:12:46 +00:00
|
|
|
{
|
|
|
|
ASSIGN(_root, [coder decodeObjectForKey: @"NSRoot"]);
|
|
|
|
ASSIGN(_visibleWindows, (NSMutableArray *)[coder decodeObjectForKey: @"NSVisibleWindows"]);
|
|
|
|
ASSIGN(_accessibilityConnectors, (NSMutableArray *)[coder decodeObjectForKey: @"NSAccessibilityConnectors"]);
|
|
|
|
ASSIGN(_fontManager, [coder decodeObjectForKey: @"NSFontManager"]);
|
|
|
|
ASSIGN(_framework, [coder decodeObjectForKey: @"NSFramework"]);
|
|
|
|
_nextOid = [coder decodeIntForKey: @"NSNextOid"];
|
|
|
|
|
|
|
|
{
|
2007-11-27 00:09:24 +00:00
|
|
|
NSArray *objectsKeys = (NSArray *)
|
|
|
|
[coder decodeObjectForKey: @"NSObjectsKeys"];
|
|
|
|
NSArray *objectsValues = (NSArray *)
|
|
|
|
[coder decodeObjectForKey: @"NSObjectsValues"];
|
|
|
|
NSArray *nameKeys = (NSArray *)
|
|
|
|
[coder decodeObjectForKey: @"NSNamesKeys"];
|
|
|
|
NSArray *nameValues = (NSArray *)
|
|
|
|
[coder decodeObjectForKey: @"NSNamesValues"];
|
|
|
|
NSArray *oidsKeys = (NSArray *)
|
|
|
|
[coder decodeObjectForKey: @"NSOidsKeys"];
|
|
|
|
NSArray *oidsValues = (NSArray *)
|
|
|
|
[coder decodeObjectForKey: @"NSOidsValues"];
|
|
|
|
NSArray *classKeys = (NSArray *)
|
|
|
|
[coder decodeObjectForKey: @"NSClassesKeys"];
|
|
|
|
NSArray *classValues = (NSArray *)
|
|
|
|
[coder decodeObjectForKey: @"NSClassesValues"];
|
|
|
|
NSArray *accessibilityOidsKeys = (NSArray *)
|
|
|
|
[coder decodeObjectForKey: @"NSAccessibilityOidsKeys"];
|
|
|
|
NSArray *accessibilityOidsValues = (NSArray *)
|
|
|
|
[coder decodeObjectForKey: @"NSAccessibilityOidsValues"];
|
|
|
|
|
|
|
|
// instantiate the maps..
|
|
|
|
_objects = NSCreateMapTable(NSObjectMapKeyCallBacks,
|
|
|
|
NSObjectMapValueCallBacks, 2);
|
|
|
|
_names = NSCreateMapTable(NSObjectMapKeyCallBacks,
|
|
|
|
NSObjectMapValueCallBacks, 2);
|
|
|
|
_oids = NSCreateMapTable(NSObjectMapKeyCallBacks,
|
|
|
|
NSObjectMapValueCallBacks, 2);
|
|
|
|
_classes = NSCreateMapTable(NSObjectMapKeyCallBacks,
|
|
|
|
NSObjectMapValueCallBacks, 2);
|
|
|
|
_accessibilityOids = NSCreateMapTable(NSObjectMapKeyCallBacks,
|
|
|
|
NSObjectMapValueCallBacks, 2);
|
|
|
|
|
|
|
|
// fill in the maps...
|
|
|
|
[self _buildMap: _accessibilityOids
|
|
|
|
withKeys: accessibilityOidsKeys
|
|
|
|
andValues: accessibilityOidsValues];
|
|
|
|
[self _buildMap: _classes
|
|
|
|
withKeys: classKeys
|
|
|
|
andValues: classValues];
|
|
|
|
[self _buildMap: _names
|
|
|
|
withKeys: nameKeys
|
|
|
|
andValues: nameValues];
|
|
|
|
[self _buildMap: _objects
|
|
|
|
withKeys: objectsKeys
|
|
|
|
andValues: objectsValues];
|
|
|
|
[self _buildMap: _oids
|
|
|
|
withKeys: oidsKeys
|
|
|
|
andValues: oidsValues];
|
|
|
|
|
|
|
|
ASSIGN(_connections, [[coder decodeObjectForKey: @"NSConnections"] mutableCopy]);
|
|
|
|
|
|
|
|
// instantiate...
|
|
|
|
_topLevelObjects = [[NSMutableSet alloc] init];
|
2006-05-20 22:12:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-06-08 04:04:17 +00:00
|
|
|
[NSException raise: NSInvalidArgumentException
|
2007-11-27 00:09:24 +00:00
|
|
|
format: @"Can't decode %@ with %@.",NSStringFromClass([self class]),
|
|
|
|
NSStringFromClass([coder class])];
|
2006-05-20 22:12:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return self;
|
2003-10-25 20:50:08 +00:00
|
|
|
}
|
|
|
|
|
2006-05-20 22:12:46 +00:00
|
|
|
- (id) init
|
2003-10-25 20:50:08 +00:00
|
|
|
{
|
2006-10-15 08:34:47 +00:00
|
|
|
if ((self = [super init]) != nil)
|
2003-10-25 20:50:08 +00:00
|
|
|
{
|
2006-05-20 22:12:46 +00:00
|
|
|
// instantiate the maps..
|
|
|
|
_objects = NSCreateMapTable(NSObjectMapKeyCallBacks,
|
2007-11-27 00:09:24 +00:00
|
|
|
NSObjectMapValueCallBacks, 2);
|
2006-05-20 22:12:46 +00:00
|
|
|
_names = NSCreateMapTable(NSObjectMapKeyCallBacks,
|
2007-11-27 00:09:24 +00:00
|
|
|
NSObjectMapValueCallBacks, 2);
|
2006-05-20 22:12:46 +00:00
|
|
|
_oids = NSCreateMapTable(NSObjectMapKeyCallBacks,
|
2007-11-27 00:09:24 +00:00
|
|
|
NSObjectMapValueCallBacks, 2);
|
2006-05-20 22:12:46 +00:00
|
|
|
_classes = NSCreateMapTable(NSObjectMapKeyCallBacks,
|
2007-11-27 00:09:24 +00:00
|
|
|
NSObjectMapValueCallBacks, 2);
|
2006-05-20 22:12:46 +00:00
|
|
|
_accessibilityOids = NSCreateMapTable(NSObjectMapKeyCallBacks,
|
2007-11-27 00:09:24 +00:00
|
|
|
NSObjectMapValueCallBacks, 2);
|
2006-05-20 22:12:46 +00:00
|
|
|
|
|
|
|
// initialize the objects...
|
|
|
|
_accessibilityConnectors = [[NSMutableArray alloc] init];
|
|
|
|
_connections = [[NSMutableArray alloc] init];
|
|
|
|
_visibleWindows = [[NSMutableArray alloc] init];
|
|
|
|
_framework = nil;
|
|
|
|
_fontManager = nil;
|
|
|
|
_root = nil;
|
|
|
|
_nextOid = 0;
|
2003-10-25 20:50:08 +00:00
|
|
|
}
|
2006-05-20 22:12:46 +00:00
|
|
|
return self;
|
2003-10-25 20:50:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void) dealloc
|
|
|
|
{
|
2006-05-20 22:12:46 +00:00
|
|
|
// free the maps.
|
|
|
|
NSFreeMapTable(_objects);
|
|
|
|
NSFreeMapTable(_names);
|
|
|
|
NSFreeMapTable(_oids);
|
|
|
|
NSFreeMapTable(_classes);
|
|
|
|
NSFreeMapTable(_accessibilityOids);
|
|
|
|
|
|
|
|
// free other objects.
|
|
|
|
RELEASE(_accessibilityConnectors);
|
|
|
|
RELEASE(_connections);
|
|
|
|
RELEASE(_fontManager);
|
|
|
|
RELEASE(_framework);
|
|
|
|
RELEASE(_visibleWindows);
|
|
|
|
RELEASE(_root);
|
2006-06-15 04:53:09 +00:00
|
|
|
RELEASE(_topLevelObjects);
|
2003-10-25 20:50:08 +00:00
|
|
|
[super dealloc];
|
|
|
|
}
|
|
|
|
|
2006-05-20 22:12:46 +00:00
|
|
|
- (void) setRoot: (id) root
|
2003-10-25 20:50:08 +00:00
|
|
|
{
|
2006-05-20 22:12:46 +00:00
|
|
|
ASSIGN(_root, root);
|
2003-10-25 20:50:08 +00:00
|
|
|
}
|
|
|
|
|
2006-05-20 22:12:46 +00:00
|
|
|
- (id) root
|
2003-10-25 20:50:08 +00:00
|
|
|
{
|
2006-05-20 22:12:46 +00:00
|
|
|
return _root;
|
2003-10-25 20:50:08 +00:00
|
|
|
}
|
2006-08-05 12:46:20 +00:00
|
|
|
|
|
|
|
- (void) setNextOid: (int)noid
|
|
|
|
{
|
|
|
|
_nextOid = noid;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (int) nextOid
|
|
|
|
{
|
|
|
|
return _nextOid;
|
|
|
|
}
|
2006-05-20 22:12:46 +00:00
|
|
|
@end
|
2003-10-25 20:50:08 +00:00
|
|
|
|
2006-05-20 22:12:46 +00:00
|
|
|
@implementation NSButtonImageSource
|
|
|
|
- (id) initWithCoder: (NSCoder *)coder
|
2003-10-25 20:50:08 +00:00
|
|
|
{
|
2006-10-15 08:34:47 +00:00
|
|
|
if ([coder allowsKeyedCoding])
|
2006-05-20 22:12:46 +00:00
|
|
|
{
|
|
|
|
ASSIGN(imageName, [coder decodeObjectForKey: @"NSImageName"]);
|
|
|
|
}
|
2006-06-08 04:04:17 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
[NSException raise: NSInvalidArgumentException
|
2007-11-27 00:09:24 +00:00
|
|
|
format: @"Can't decode %@ with %@.",NSStringFromClass([self class]),
|
|
|
|
NSStringFromClass([coder class])];
|
2006-06-08 04:04:17 +00:00
|
|
|
}
|
|
|
|
|
2006-05-20 22:12:46 +00:00
|
|
|
RELEASE(self);
|
|
|
|
return [NSImage imageNamed: imageName];
|
2003-10-25 20:50:08 +00:00
|
|
|
}
|
|
|
|
|
2006-05-20 22:12:46 +00:00
|
|
|
- (void) encodeWithCoder: (NSCoder *)coder
|
2003-10-25 20:50:08 +00:00
|
|
|
{
|
2006-10-15 08:34:47 +00:00
|
|
|
if ([coder allowsKeyedCoding])
|
2003-10-25 20:50:08 +00:00
|
|
|
{
|
2006-05-20 22:12:46 +00:00
|
|
|
[coder encodeObject: imageName forKey: @"NSImageName"];
|
2003-10-25 20:50:08 +00:00
|
|
|
}
|
2006-06-08 04:04:17 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
[NSException raise: NSInvalidArgumentException
|
2007-11-27 00:09:24 +00:00
|
|
|
format: @"Can't encode %@ with %@.",NSStringFromClass([self class]),
|
|
|
|
NSStringFromClass([coder class])];
|
2006-06-08 04:04:17 +00:00
|
|
|
}
|
2003-10-25 20:50:08 +00:00
|
|
|
}
|
|
|
|
|
2006-08-09 01:37:32 +00:00
|
|
|
- (id) initWithImageNamed: (NSString *)name
|
|
|
|
{
|
2006-10-15 08:34:47 +00:00
|
|
|
if ((self = [super init]) != nil)
|
2006-08-09 01:37:32 +00:00
|
|
|
{
|
|
|
|
ASSIGN(imageName,name);
|
|
|
|
}
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2006-05-20 22:12:46 +00:00
|
|
|
- (NSString *)imageName
|
2003-10-25 20:50:08 +00:00
|
|
|
{
|
2006-05-20 22:12:46 +00:00
|
|
|
return imageName;
|
2003-10-25 20:50:08 +00:00
|
|
|
}
|
|
|
|
|
2006-05-20 22:12:46 +00:00
|
|
|
- (void) dealloc
|
2003-10-25 20:50:08 +00:00
|
|
|
{
|
2006-05-20 22:12:46 +00:00
|
|
|
RELEASE(imageName);
|
|
|
|
[super dealloc];
|
2003-10-25 20:50:08 +00:00
|
|
|
}
|
2006-05-20 22:12:46 +00:00
|
|
|
@end
|
2003-10-25 20:50:08 +00:00
|
|
|
|
2006-06-18 18:40:11 +00:00
|
|
|
@implementation NSIBHelpConnector
|
2006-10-07 14:20:53 +00:00
|
|
|
- (id) init
|
|
|
|
{
|
2006-10-15 08:34:47 +00:00
|
|
|
if ((self = [super init]) != nil)
|
2006-10-07 14:20:53 +00:00
|
|
|
{
|
|
|
|
_file = nil;
|
|
|
|
_marker = @"NSToolTipHelpKey";
|
|
|
|
}
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2006-10-07 14:03:50 +00:00
|
|
|
- (id) initWithCoder: (NSCoder *)coder
|
|
|
|
{
|
2006-10-15 08:34:47 +00:00
|
|
|
if ((self = [super initWithCoder: coder]) != nil)
|
2006-10-07 14:03:50 +00:00
|
|
|
{
|
2006-10-15 08:34:47 +00:00
|
|
|
if ([coder allowsKeyedCoding])
|
2007-11-27 00:09:24 +00:00
|
|
|
{
|
|
|
|
if ([coder containsValueForKey: @"NSFile"])
|
|
|
|
{
|
|
|
|
_file = RETAIN([coder decodeObjectForKey: @"NSFile"]);
|
|
|
|
}
|
|
|
|
if ([coder containsValueForKey: @"NSMarker"])
|
|
|
|
{
|
|
|
|
_marker = RETAIN([coder decodeObjectForKey: @"NSMarker"]);
|
|
|
|
}
|
|
|
|
}
|
2006-10-07 14:03:50 +00:00
|
|
|
else
|
2007-11-27 00:09:24 +00:00
|
|
|
{
|
|
|
|
_file = RETAIN([coder decodeObject]);
|
|
|
|
_marker = RETAIN([coder decodeObject]);
|
|
|
|
}
|
2006-10-07 14:03:50 +00:00
|
|
|
}
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) encodeWithCoder: (NSCoder *)coder
|
|
|
|
{
|
|
|
|
[super encodeWithCoder: coder];
|
2006-10-15 08:34:47 +00:00
|
|
|
if ([coder allowsKeyedCoding])
|
2006-10-07 14:03:50 +00:00
|
|
|
{
|
2006-10-15 08:34:47 +00:00
|
|
|
if (_file != nil)
|
2007-11-27 00:09:24 +00:00
|
|
|
{
|
|
|
|
[coder encodeObject: _file forKey: @"NSFile"];
|
|
|
|
}
|
2006-10-15 08:34:47 +00:00
|
|
|
if (_marker != nil)
|
2007-11-27 00:09:24 +00:00
|
|
|
{
|
|
|
|
[coder encodeObject: _file forKey: @"NSMarker"];
|
|
|
|
}
|
2006-10-07 14:03:50 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
[coder encodeObject: _file];
|
|
|
|
[coder encodeObject: _marker];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-10-07 14:17:29 +00:00
|
|
|
- (void) establishConnection
|
|
|
|
{
|
|
|
|
[_dst setToolTip: _marker];
|
|
|
|
}
|
|
|
|
|
2006-10-07 14:03:50 +00:00
|
|
|
- (void) setFile: (id)file
|
|
|
|
{
|
|
|
|
ASSIGN(_file, file);
|
|
|
|
}
|
|
|
|
|
|
|
|
- (id) file
|
|
|
|
{
|
|
|
|
return _file;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setMarker: (id)marker
|
|
|
|
{
|
|
|
|
ASSIGN(_marker, marker);
|
|
|
|
}
|
|
|
|
|
|
|
|
- (id) marker
|
|
|
|
{
|
|
|
|
return _marker;
|
|
|
|
}
|
2006-06-18 18:40:11 +00:00
|
|
|
@end
|
|
|
|
|
2006-06-25 16:42:38 +00:00
|
|
|
@interface NSDecimalNumberPlaceholder : NSObject
|
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation NSDecimalNumberPlaceholder
|
|
|
|
- (id) initWithCoder: (NSCoder *)coder
|
|
|
|
{
|
|
|
|
NSDecimalNumber *dn = nil;
|
2006-10-15 08:34:47 +00:00
|
|
|
if ([coder allowsKeyedCoding])
|
2006-06-25 16:42:38 +00:00
|
|
|
{
|
|
|
|
unsigned int len = 0;
|
|
|
|
short exponent = (short)[coder decodeIntForKey: @"NS.exponent"];
|
|
|
|
NSByteOrder bo = [coder decodeIntForKey: @"NS.mantissa.bo"];
|
|
|
|
BOOL negative = [coder decodeBoolForKey: @"NS.negative"];
|
|
|
|
void *mantissaBytes = (void *)[coder decodeBytesForKey: @"NS.mantissa" returnedLength: &len];
|
|
|
|
unsigned long long unswapped = 0;
|
|
|
|
unsigned long long mantissa = 0;
|
|
|
|
|
2006-09-13 04:32:23 +00:00
|
|
|
// BOOL compact = [coder decodeBoolForKey: @"NS.compact"];
|
|
|
|
// int length = [coder decodeIntForKey: @"NS.length"];
|
|
|
|
|
2006-06-25 16:42:38 +00:00
|
|
|
memcpy((void *)&unswapped, (void *)mantissaBytes, sizeof(unsigned long long));
|
|
|
|
|
|
|
|
switch(bo)
|
2007-11-27 00:09:24 +00:00
|
|
|
{
|
|
|
|
case NS_BigEndian:
|
|
|
|
mantissa = NSSwapBigLongLongToHost(unswapped);
|
|
|
|
break;
|
|
|
|
case NS_LittleEndian:
|
|
|
|
mantissa = NSSwapLittleLongLongToHost(unswapped);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2006-06-25 16:42:38 +00:00
|
|
|
|
|
|
|
dn = [[NSDecimalNumber alloc] initWithMantissa: mantissa
|
2007-11-27 00:09:24 +00:00
|
|
|
exponent: exponent
|
|
|
|
isNegative: negative];
|
2006-06-25 16:42:38 +00:00
|
|
|
}
|
|
|
|
return dn;
|
|
|
|
}
|
|
|
|
|
|
|
|
@end
|
2006-08-12 22:44:56 +00:00
|
|
|
|
2006-10-07 14:08:32 +00:00
|
|
|
// ...dummy/placeholder classes...
|
|
|
|
// overridden in NSTableView to be GSTableCornerView,
|
|
|
|
// but the class needs to be present to be overridden.
|
|
|
|
@interface _NSCornerView : NSView
|
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation _NSCornerView
|
|
|
|
@end
|
|
|
|
|
2006-08-12 22:44:56 +00:00
|
|
|
// class needed for nib encoding/decoding by
|
|
|
|
@implementation NSPSMatrix
|
|
|
|
- (void) encodeWithCoder: (NSCoder *)coder
|
|
|
|
{
|
|
|
|
// do nothing... just encoding the presence of the class.
|
|
|
|
}
|
|
|
|
|
|
|
|
- (id) initWithCoder: (NSCoder *)coder
|
|
|
|
{
|
|
|
|
// what's NSPSMatix all about?
|
|
|
|
// NSLog(@"NSPSMatrix = %@",[(NSKeyedUnarchiver *)coder keyMap]);
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
@end
|
|
|
|
|
|
|
|
|