2001-12-17 16:51:51 +00:00
|
|
|
|
/** <title>NSBundleAdditions</title>
|
1997-01-29 16:07:56 +00:00
|
|
|
|
|
2001-12-17 16:51:51 +00:00
|
|
|
|
<abstract>Implementation of NSBundle Additions</abstract>
|
1997-01-29 16:07:56 +00:00
|
|
|
|
|
1999-01-15 10:14:28 +00:00
|
|
|
|
Copyright (C) 1997, 1999 Free Software Foundation, Inc.
|
1997-01-29 16:07:56 +00:00
|
|
|
|
|
|
|
|
|
Author: Simon Frankau <sgf@frankau.demon.co.uk>
|
|
|
|
|
Date: 1997
|
1999-01-15 10:14:28 +00:00
|
|
|
|
Author: Richard Frith-Macdonald <richard@brainstorm.co.uk>
|
|
|
|
|
Date: 1999
|
1997-01-29 16:07:56 +00:00
|
|
|
|
|
|
|
|
|
This file is part of the GNUstep GUI Library.
|
|
|
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or
|
|
|
|
|
modify it under the terms of the GNU Library General Public
|
|
|
|
|
License as published by the Free Software Foundation; either
|
|
|
|
|
version 2 of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
|
|
This library is distributed in the hope that it will be useful,
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
|
Library General Public License for more details.
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Library General Public
|
1999-09-09 02:56:20 +00:00
|
|
|
|
License along with this library;
|
|
|
|
|
If not, write to the Free Software Foundation,
|
|
|
|
|
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
1997-01-29 16:07:56 +00:00
|
|
|
|
*/
|
|
|
|
|
|
1997-09-23 22:43:24 +00:00
|
|
|
|
#include <gnustep/gui/config.h>
|
2002-10-06 23:59:30 +00:00
|
|
|
|
#include <Foundation/NSClassDescription.h>
|
1999-01-15 10:14:28 +00:00
|
|
|
|
#include <Foundation/NSArchiver.h>
|
1999-01-17 08:14:03 +00:00
|
|
|
|
#include <Foundation/NSArray.h>
|
1997-01-29 16:07:56 +00:00
|
|
|
|
#include <Foundation/NSBundle.h>
|
1999-01-15 10:14:28 +00:00
|
|
|
|
#include <Foundation/NSCoder.h>
|
|
|
|
|
#include <Foundation/NSData.h>
|
|
|
|
|
#include <Foundation/NSDictionary.h>
|
2002-04-11 23:17:42 +00:00
|
|
|
|
#include <Foundation/NSDebug.h>
|
1999-01-15 10:14:28 +00:00
|
|
|
|
#include <Foundation/NSEnumerator.h>
|
2002-04-11 23:17:42 +00:00
|
|
|
|
#include <Foundation/NSException.h>
|
1999-01-17 08:14:03 +00:00
|
|
|
|
#include <Foundation/NSInvocation.h>
|
1999-01-15 10:14:28 +00:00
|
|
|
|
#include <Foundation/NSObjCRuntime.h>
|
2002-04-11 23:17:42 +00:00
|
|
|
|
#include <Foundation/NSPathUtilities.h>
|
1999-11-29 11:45:50 +00:00
|
|
|
|
#include <Foundation/NSFileManager.h>
|
1999-01-15 10:14:28 +00:00
|
|
|
|
#include <Foundation/NSString.h>
|
1999-11-29 11:45:50 +00:00
|
|
|
|
#include <Foundation/NSUserDefaults.h>
|
2002-10-06 23:59:30 +00:00
|
|
|
|
#include <Foundation/NSKeyValueCoding.h>
|
2000-01-13 21:20:15 +00:00
|
|
|
|
#include <AppKit/NSApplication.h>
|
|
|
|
|
#include <AppKit/NSMenu.h>
|
1999-11-29 11:45:50 +00:00
|
|
|
|
#include <AppKit/NSControl.h>
|
1999-09-02 11:28:47 +00:00
|
|
|
|
#include <AppKit/NSImage.h>
|
2002-07-30 21:19:05 +00:00
|
|
|
|
#include <AppKit/NSSound.h>
|
1999-01-17 08:14:03 +00:00
|
|
|
|
#include <AppKit/NSView.h>
|
2002-10-06 23:59:30 +00:00
|
|
|
|
#include <AppKit/NSTextView.h>
|
1999-12-31 10:54:44 +00:00
|
|
|
|
#include <AppKit/NSWindow.h>
|
1999-11-29 11:45:50 +00:00
|
|
|
|
#include <AppKit/NSNibConnector.h>
|
1997-02-18 00:29:25 +00:00
|
|
|
|
#include <AppKit/NSNibLoading.h>
|
2002-10-06 23:59:30 +00:00
|
|
|
|
#include <AppKit/GSNibTemplates.h>
|
2000-07-30 08:20:51 +00:00
|
|
|
|
#include <AppKit/IMLoading.h>
|
1999-11-29 11:45:50 +00:00
|
|
|
|
|
2002-10-06 23:59:30 +00:00
|
|
|
|
//
|
|
|
|
|
// For the template classes since they need to know about any and all subclasses
|
|
|
|
|
// of the parent classes covered by them.
|
|
|
|
|
//
|
|
|
|
|
#include <AppKit/AppKit.h>
|
|
|
|
|
|
2002-03-01 14:41:59 +00:00
|
|
|
|
static const int currentVersion = 1;
|
|
|
|
|
|
1999-11-29 11:45:50 +00:00
|
|
|
|
@implementation NSNibConnector
|
|
|
|
|
|
|
|
|
|
- (void) dealloc
|
|
|
|
|
{
|
|
|
|
|
RELEASE(_src);
|
|
|
|
|
RELEASE(_dst);
|
|
|
|
|
RELEASE(_tag);
|
|
|
|
|
[super dealloc];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (id) destination
|
|
|
|
|
{
|
|
|
|
|
return _dst;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) encodeWithCoder: (NSCoder*)aCoder
|
|
|
|
|
{
|
|
|
|
|
[aCoder encodeObject: _src];
|
|
|
|
|
[aCoder encodeObject: _dst];
|
|
|
|
|
[aCoder encodeObject: _tag];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) establishConnection
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (id) initWithCoder: (NSCoder*)aCoder
|
|
|
|
|
{
|
|
|
|
|
[aCoder decodeValueOfObjCType: @encode(id) at: &_src];
|
|
|
|
|
[aCoder decodeValueOfObjCType: @encode(id) at: &_dst];
|
|
|
|
|
[aCoder decodeValueOfObjCType: @encode(id) at: &_tag];
|
|
|
|
|
return self;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (NSString*) label
|
|
|
|
|
{
|
|
|
|
|
return _tag;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) replaceObject: (id)anObject withObject: (id)anotherObject
|
|
|
|
|
{
|
1999-12-03 14:51:56 +00:00
|
|
|
|
if (_src == anObject)
|
|
|
|
|
{
|
|
|
|
|
ASSIGN(_src, anotherObject);
|
|
|
|
|
}
|
|
|
|
|
if (_dst == anObject)
|
|
|
|
|
{
|
|
|
|
|
ASSIGN(_dst, anotherObject);
|
|
|
|
|
}
|
|
|
|
|
if (_tag == anObject)
|
|
|
|
|
{
|
|
|
|
|
ASSIGN(_tag, anotherObject);
|
|
|
|
|
}
|
1999-11-29 11:45:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (id) source
|
|
|
|
|
{
|
|
|
|
|
return _src;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) setDestination: (id)anObject
|
|
|
|
|
{
|
|
|
|
|
ASSIGN(_dst, anObject);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) setLabel: (NSString*)label
|
|
|
|
|
{
|
|
|
|
|
ASSIGN(_tag, label);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) setSource: (id)anObject
|
|
|
|
|
{
|
|
|
|
|
ASSIGN(_src, anObject);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
|
|
@implementation NSNibControlConnector
|
|
|
|
|
- (void) establishConnection
|
|
|
|
|
{
|
|
|
|
|
SEL sel = NSSelectorFromString(_tag);
|
|
|
|
|
|
|
|
|
|
[_src setTarget: _dst];
|
|
|
|
|
[_src setAction: sel];
|
|
|
|
|
}
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
|
|
@implementation NSNibOutletConnector
|
|
|
|
|
- (void) establishConnection
|
|
|
|
|
{
|
2000-01-03 18:42:16 +00:00
|
|
|
|
if (_src != nil)
|
|
|
|
|
{
|
|
|
|
|
NSString *selName;
|
|
|
|
|
SEL sel;
|
1999-11-29 11:45:50 +00:00
|
|
|
|
|
2002-03-26 16:24:42 +00:00
|
|
|
|
selName = [NSString stringWithFormat: @"set%@%@:",
|
|
|
|
|
[[_tag substringToIndex: 1] uppercaseString],
|
|
|
|
|
[_tag substringFromIndex: 1]];
|
2000-01-03 18:42:16 +00:00
|
|
|
|
sel = NSSelectorFromString(selName);
|
1999-11-29 11:45:50 +00:00
|
|
|
|
|
2001-05-08 02:42:45 +00:00
|
|
|
|
if (sel && [_src respondsToSelector: sel])
|
2000-01-03 18:42:16 +00:00
|
|
|
|
{
|
|
|
|
|
[_src performSelector: sel withObject: _dst];
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2002-11-27 21:39:48 +00:00
|
|
|
|
const char *nam = [_tag cString];
|
|
|
|
|
const char *type;
|
|
|
|
|
unsigned int size;
|
|
|
|
|
unsigned int offset;
|
|
|
|
|
|
2000-01-03 18:42:16 +00:00
|
|
|
|
/*
|
2002-11-27 21:39:48 +00:00
|
|
|
|
* Use the GNUstep additional function to set the instance
|
|
|
|
|
* variable directly.
|
|
|
|
|
* FIXME - need some way to do this for libFoundation and
|
|
|
|
|
* Foundation based systems.
|
2000-01-03 18:42:16 +00:00
|
|
|
|
*/
|
2002-11-29 14:23:46 +00:00
|
|
|
|
if (GSObjCFindVariable(_src, nam, &type, &size, &offset))
|
2002-11-27 21:39:48 +00:00
|
|
|
|
{
|
|
|
|
|
GSObjCSetVariable(_src, offset, size, (void*)&_dst);
|
|
|
|
|
}
|
2000-01-03 18:42:16 +00:00
|
|
|
|
}
|
1999-11-29 11:45:50 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1997-01-29 16:07:56 +00:00
|
|
|
|
@implementation NSBundle (NSBundleAdditions)
|
|
|
|
|
|
2001-07-31 16:57:26 +00:00
|
|
|
|
static
|
|
|
|
|
Class gmodel_class(void)
|
|
|
|
|
{
|
|
|
|
|
static Class gmclass = Nil;
|
|
|
|
|
|
|
|
|
|
if (gmclass == Nil)
|
|
|
|
|
{
|
2002-02-11 16:29:15 +00:00
|
|
|
|
NSBundle *theBundle;
|
|
|
|
|
NSEnumerator *benum;
|
|
|
|
|
NSString *path;
|
|
|
|
|
|
|
|
|
|
/* Find the bundle */
|
|
|
|
|
benum = [NSStandardLibraryPaths() objectEnumerator];
|
|
|
|
|
while ((path = [benum nextObject]))
|
|
|
|
|
{
|
|
|
|
|
path = [path stringByAppendingPathComponent: @"Bundles"];
|
|
|
|
|
path = [path stringByAppendingPathComponent: @"libgmodel.bundle"];
|
|
|
|
|
if ([[NSFileManager defaultManager] fileExistsAtPath: path])
|
|
|
|
|
break;
|
|
|
|
|
path = nil;
|
|
|
|
|
}
|
|
|
|
|
NSCAssert(path != nil, @"Unable to load gmodel bundle");
|
|
|
|
|
NSDebugLog(@"Loading gmodel from %@", path);
|
|
|
|
|
|
|
|
|
|
theBundle = [NSBundle bundleWithPath: path];
|
|
|
|
|
NSCAssert(theBundle != nil, @"Can't init gmodel bundle");
|
|
|
|
|
gmclass = [theBundle classNamed: @"GMModel"];
|
|
|
|
|
NSCAssert(gmclass, @"Can't load gmodel bundle");
|
2001-07-31 16:57:26 +00:00
|
|
|
|
}
|
|
|
|
|
return gmclass;
|
|
|
|
|
}
|
|
|
|
|
|
2002-02-11 16:29:15 +00:00
|
|
|
|
+ (BOOL) loadNibFile: (NSString*)fileName
|
|
|
|
|
externalNameTable: (NSDictionary*)context
|
|
|
|
|
withZone: (NSZone*)zone
|
1997-01-29 16:07:56 +00:00
|
|
|
|
{
|
1999-01-15 10:14:28 +00:00
|
|
|
|
BOOL loaded = NO;
|
2000-01-17 07:18:42 +00:00
|
|
|
|
NSUnarchiver *unarchiver = nil;
|
2000-07-30 08:20:51 +00:00
|
|
|
|
NSString *ext = [fileName pathExtension];
|
2002-01-24 17:02:33 +00:00
|
|
|
|
|
2002-02-11 16:29:15 +00:00
|
|
|
|
if ([ext isEqual: @"nib"])
|
2002-01-24 17:02:33 +00:00
|
|
|
|
{
|
2002-02-11 16:29:15 +00:00
|
|
|
|
NSFileManager *mgr = [NSFileManager defaultManager];
|
|
|
|
|
NSString *base = [fileName stringByDeletingPathExtension];
|
|
|
|
|
|
|
|
|
|
/* We can't read nibs, look for an equivalent gorm or gmodel file */
|
|
|
|
|
fileName = [base stringByAppendingPathExtension: @"gorm"];
|
|
|
|
|
if ([mgr isReadableFileAtPath: fileName])
|
|
|
|
|
{
|
|
|
|
|
ext = @"gorm";
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2002-02-12 19:10:31 +00:00
|
|
|
|
fileName = [base stringByAppendingPathExtension: @"gmodel"];
|
2002-02-11 16:29:15 +00:00
|
|
|
|
ext = @"gmodel";
|
|
|
|
|
}
|
2002-01-24 17:02:33 +00:00
|
|
|
|
}
|
2000-07-30 08:20:51 +00:00
|
|
|
|
|
2002-02-11 16:29:15 +00:00
|
|
|
|
/*
|
|
|
|
|
* If the file to be read is a gmodel, use the GMModel method to
|
|
|
|
|
* read it in and skip the dearchiving below.
|
|
|
|
|
*/
|
|
|
|
|
if ([ext isEqualToString: @"gmodel"])
|
2000-07-30 08:20:51 +00:00
|
|
|
|
{
|
2001-07-31 16:57:26 +00:00
|
|
|
|
return [gmodel_class() loadIMFile: fileName
|
2000-09-23 02:05:09 +00:00
|
|
|
|
owner: [context objectForKey: @"NSOwner"]];
|
2000-07-30 08:20:51 +00:00
|
|
|
|
}
|
1999-01-15 10:14:28 +00:00
|
|
|
|
|
2002-06-06 05:22:45 +00:00
|
|
|
|
NSDebugLog(@"Loading Nib `%@'...\n", fileName);
|
2000-01-17 07:18:42 +00:00
|
|
|
|
NS_DURING
|
1999-01-15 10:14:28 +00:00
|
|
|
|
{
|
2002-10-31 14:59:18 +00:00
|
|
|
|
NSFileManager *mgr = [NSFileManager defaultManager];
|
|
|
|
|
BOOL isDir = NO;
|
|
|
|
|
|
|
|
|
|
if([mgr fileExistsAtPath: fileName isDirectory: &isDir])
|
1999-01-15 10:14:28 +00:00
|
|
|
|
{
|
2002-10-31 14:59:18 +00:00
|
|
|
|
NSData *data = nil;
|
|
|
|
|
|
|
|
|
|
// if the data is in a directory, then load from objects.gorm in the directory
|
|
|
|
|
if(isDir == NO)
|
|
|
|
|
{
|
|
|
|
|
data = [NSData dataWithContentsOfFile: fileName];
|
|
|
|
|
NSDebugLog(@"Loaded data from file...");
|
|
|
|
|
}
|
|
|
|
|
else
|
1999-01-15 10:14:28 +00:00
|
|
|
|
{
|
2002-10-31 14:59:18 +00:00
|
|
|
|
NSString *newFileName = [fileName stringByAppendingPathComponent: @"objects.gorm"];
|
|
|
|
|
data = [NSData dataWithContentsOfFile: newFileName];
|
|
|
|
|
NSDebugLog(@"Loaded data from %@...",newFileName);
|
|
|
|
|
}
|
2000-01-17 07:18:42 +00:00
|
|
|
|
|
2002-10-31 14:59:18 +00:00
|
|
|
|
if (data != nil)
|
|
|
|
|
{
|
|
|
|
|
unarchiver = [[NSUnarchiver alloc] initForReadingWithData: data];
|
|
|
|
|
if (unarchiver != nil)
|
1999-01-15 10:14:28 +00:00
|
|
|
|
{
|
2002-10-31 14:59:18 +00:00
|
|
|
|
id obj;
|
|
|
|
|
|
2002-12-29 05:38:29 +00:00
|
|
|
|
// font fallback and automatic translation...
|
|
|
|
|
[unarchiver decodeClassName: @"NSFont" asClassName: @"GSFontProxy"];
|
|
|
|
|
// [unarchiver decodeClassName: @"NSString" asClassName: @"GSStringProxy"];
|
|
|
|
|
|
2002-10-31 14:59:18 +00:00
|
|
|
|
NSDebugLog(@"Invoking unarchiver");
|
|
|
|
|
[unarchiver setObjectZone: zone];
|
|
|
|
|
obj = [unarchiver decodeObject];
|
|
|
|
|
if (obj != nil)
|
2000-01-17 07:18:42 +00:00
|
|
|
|
{
|
2002-10-31 14:59:18 +00:00
|
|
|
|
if ([obj isKindOfClass: [GSNibContainer class]])
|
|
|
|
|
{
|
|
|
|
|
NSDebugLog(@"Calling awakeWithContext");
|
|
|
|
|
[obj awakeWithContext: context];
|
|
|
|
|
/*
|
|
|
|
|
*Ok - it's all done now - just retain the nib container
|
|
|
|
|
*so that it will not be released when the unarchiver
|
|
|
|
|
*is released, and the nib contents will persist.
|
|
|
|
|
*/
|
|
|
|
|
RETAIN(obj);
|
|
|
|
|
loaded = YES;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
NSLog(@"Nib '%@' without container object!", fileName);
|
|
|
|
|
}
|
2000-01-17 07:18:42 +00:00
|
|
|
|
}
|
2002-10-31 14:59:18 +00:00
|
|
|
|
RELEASE(unarchiver);
|
1999-01-15 10:14:28 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2000-01-17 07:18:42 +00:00
|
|
|
|
NS_HANDLER
|
|
|
|
|
{
|
2002-10-06 23:59:30 +00:00
|
|
|
|
NSLog(@"Exception occured while loading model: %@",[localException reason]);
|
2000-01-17 07:18:42 +00:00
|
|
|
|
TEST_RELEASE(unarchiver);
|
|
|
|
|
}
|
|
|
|
|
NS_ENDHANDLER
|
2000-09-23 02:05:09 +00:00
|
|
|
|
|
2002-02-11 16:29:15 +00:00
|
|
|
|
if (loaded == NO)
|
|
|
|
|
{
|
|
|
|
|
NSLog(@"Failed to load Nib\n");
|
|
|
|
|
}
|
1999-01-15 10:14:28 +00:00
|
|
|
|
return loaded;
|
1997-01-29 16:07:56 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-01-15 10:14:28 +00:00
|
|
|
|
+ (BOOL) loadNibNamed: (NSString *)aNibName
|
|
|
|
|
owner: (id)owner
|
1997-01-29 16:07:56 +00:00
|
|
|
|
{
|
1999-01-15 10:14:28 +00:00
|
|
|
|
NSDictionary *table;
|
|
|
|
|
NSBundle *bundle;
|
|
|
|
|
|
|
|
|
|
if (owner == nil || aNibName == nil)
|
2002-02-11 16:29:15 +00:00
|
|
|
|
{
|
|
|
|
|
return NO;
|
|
|
|
|
}
|
1999-01-15 10:14:28 +00:00
|
|
|
|
table = [NSDictionary dictionaryWithObject: owner forKey: @"NSOwner"];
|
1999-11-29 11:45:50 +00:00
|
|
|
|
bundle = [self bundleForClass: [owner class]];
|
|
|
|
|
if (bundle == nil)
|
1999-01-15 10:14:28 +00:00
|
|
|
|
{
|
1999-11-29 11:45:50 +00:00
|
|
|
|
bundle = [self mainBundle];
|
1999-01-15 10:14:28 +00:00
|
|
|
|
}
|
1999-11-29 11:45:50 +00:00
|
|
|
|
return [bundle loadNibFile: aNibName
|
|
|
|
|
externalNameTable: table
|
|
|
|
|
withZone: [owner zone]];
|
1997-01-29 16:07:56 +00:00
|
|
|
|
}
|
|
|
|
|
|
2001-11-26 20:28:34 +00:00
|
|
|
|
- (NSString *) pathForNibResource: (NSString *)fileName
|
1999-11-29 11:45:50 +00:00
|
|
|
|
{
|
|
|
|
|
NSFileManager *mgr = [NSFileManager defaultManager];
|
|
|
|
|
NSMutableArray *array = [NSMutableArray arrayWithCapacity: 8];
|
|
|
|
|
NSArray *languages = [NSUserDefaults userLanguages];
|
|
|
|
|
NSString *rootPath = [self bundlePath];
|
|
|
|
|
NSString *primary;
|
|
|
|
|
NSString *language;
|
|
|
|
|
NSEnumerator *enumerator;
|
|
|
|
|
NSString *ext;
|
|
|
|
|
|
|
|
|
|
ext = [fileName pathExtension];
|
|
|
|
|
fileName = [fileName stringByDeletingPathExtension];
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Build an array of resource paths that differs from the normal order -
|
|
|
|
|
* we want a localized file in preference to a generic one.
|
|
|
|
|
*/
|
|
|
|
|
primary = [rootPath stringByAppendingPathComponent: @"Resources"];
|
|
|
|
|
enumerator = [languages objectEnumerator];
|
|
|
|
|
while ((language = [enumerator nextObject]))
|
|
|
|
|
{
|
|
|
|
|
NSString *langDir;
|
|
|
|
|
|
|
|
|
|
langDir = [NSString stringWithFormat: @"%@.lproj", language];
|
|
|
|
|
[array addObject: [primary stringByAppendingPathComponent: langDir]];
|
|
|
|
|
}
|
|
|
|
|
[array addObject: primary];
|
|
|
|
|
primary = rootPath;
|
|
|
|
|
enumerator = [languages objectEnumerator];
|
|
|
|
|
while ((language = [enumerator nextObject]))
|
|
|
|
|
{
|
|
|
|
|
NSString *langDir;
|
|
|
|
|
|
|
|
|
|
langDir = [NSString stringWithFormat: @"%@.lproj", language];
|
|
|
|
|
[array addObject: [primary stringByAppendingPathComponent: langDir]];
|
|
|
|
|
}
|
|
|
|
|
[array addObject: primary];
|
|
|
|
|
|
|
|
|
|
enumerator = [array objectEnumerator];
|
|
|
|
|
while ((rootPath = [enumerator nextObject]) != nil)
|
|
|
|
|
{
|
|
|
|
|
NSString *path;
|
|
|
|
|
|
2000-07-30 08:20:51 +00:00
|
|
|
|
rootPath = [rootPath stringByAppendingPathComponent: fileName];
|
|
|
|
|
// If the file does not have an extension, then we need to
|
|
|
|
|
// figure out what type of model file to load.
|
|
|
|
|
if ([ext isEqualToString: @""] == YES)
|
1999-11-29 11:45:50 +00:00
|
|
|
|
{
|
2000-07-30 08:20:51 +00:00
|
|
|
|
path = [rootPath stringByAppendingPathExtension: @"gorm"];
|
1999-11-29 11:45:50 +00:00
|
|
|
|
if ([mgr isReadableFileAtPath: path] == NO)
|
|
|
|
|
{
|
2000-07-30 08:20:51 +00:00
|
|
|
|
path = [rootPath stringByAppendingPathExtension: @"nib"];
|
1999-11-29 11:45:50 +00:00
|
|
|
|
if ([mgr isReadableFileAtPath: path] == NO)
|
|
|
|
|
{
|
2000-07-30 08:20:51 +00:00
|
|
|
|
path = [rootPath stringByAppendingPathExtension: @"gmodel"];
|
1999-11-29 11:45:50 +00:00
|
|
|
|
if ([mgr isReadableFileAtPath: path] == NO)
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2001-11-26 20:28:34 +00:00
|
|
|
|
return path;
|
1999-11-29 11:45:50 +00:00
|
|
|
|
}
|
2000-07-30 08:20:51 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
path = [rootPath stringByAppendingPathExtension: ext];
|
|
|
|
|
if([mgr isReadableFileAtPath: path])
|
|
|
|
|
{
|
2001-11-26 20:28:34 +00:00
|
|
|
|
return path;
|
2000-07-30 08:20:51 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
1999-11-29 11:45:50 +00:00
|
|
|
|
}
|
2000-07-30 08:20:51 +00:00
|
|
|
|
|
2001-11-26 20:28:34 +00:00
|
|
|
|
return nil;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (BOOL) loadNibFile: (NSString*)fileName
|
|
|
|
|
externalNameTable: (NSDictionary*)context
|
|
|
|
|
withZone: (NSZone*)zone
|
|
|
|
|
{
|
|
|
|
|
NSString *path = [self pathForNibResource: fileName];
|
|
|
|
|
|
|
|
|
|
if (path != nil)
|
2002-02-11 16:29:15 +00:00
|
|
|
|
{
|
|
|
|
|
return [NSBundle loadNibFile: path
|
|
|
|
|
externalNameTable: context
|
|
|
|
|
withZone: (NSZone*)zone];
|
|
|
|
|
}
|
2001-11-26 20:28:34 +00:00
|
|
|
|
else
|
2002-02-11 16:29:15 +00:00
|
|
|
|
{
|
|
|
|
|
return NO;
|
|
|
|
|
}
|
1999-11-29 11:45:50 +00:00
|
|
|
|
}
|
1997-01-29 16:07:56 +00:00
|
|
|
|
@end
|
1997-02-18 00:29:25 +00:00
|
|
|
|
|
1999-01-15 10:14:28 +00:00
|
|
|
|
|
1997-02-18 00:29:25 +00:00
|
|
|
|
|
2001-05-24 14:47:43 +00:00
|
|
|
|
@interface NSApplication (GSNibContainer)
|
|
|
|
|
- (void)_deactivateVisibleWindow: (NSWindow *)win;
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
|
|
@implementation NSApplication (GSNibContainer)
|
|
|
|
|
/* Since awakeWithContext often gets called before the the app becomes
|
|
|
|
|
active, [win -orderFront:] requests get ignored, so we add the window
|
|
|
|
|
to the inactive list, so it gets sent an -orderFront when the app
|
|
|
|
|
becomes active. */
|
2002-02-11 16:29:15 +00:00
|
|
|
|
- (void) _deactivateVisibleWindow: (NSWindow *)win
|
2001-05-24 14:47:43 +00:00
|
|
|
|
{
|
|
|
|
|
if (_inactive)
|
|
|
|
|
[_inactive addObject: win];
|
|
|
|
|
}
|
|
|
|
|
@end
|
|
|
|
|
|
1999-01-15 10:14:28 +00:00
|
|
|
|
/*
|
2000-01-03 18:42:16 +00:00
|
|
|
|
* The GSNibContainer class manages the internals of a nib file.
|
1999-01-15 10:14:28 +00:00
|
|
|
|
*/
|
|
|
|
|
@implementation GSNibContainer
|
1999-11-29 11:45:50 +00:00
|
|
|
|
|
2002-11-18 06:00:26 +00:00
|
|
|
|
+ (void) initialize
|
|
|
|
|
{
|
|
|
|
|
if (self == [GSNibContainer class])
|
|
|
|
|
{
|
|
|
|
|
[self setVersion: GNUSTEP_NIB_VERSION];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2000-01-03 18:42:16 +00:00
|
|
|
|
- (void) awakeWithContext: (NSDictionary*)context
|
|
|
|
|
{
|
|
|
|
|
if (_isAwake == NO)
|
|
|
|
|
{
|
|
|
|
|
NSEnumerator *enumerator;
|
|
|
|
|
NSNibConnector *connection;
|
|
|
|
|
NSString *key;
|
|
|
|
|
NSArray *visible;
|
2000-01-13 21:20:15 +00:00
|
|
|
|
NSMenu *menu;
|
2000-01-03 18:42:16 +00:00
|
|
|
|
|
|
|
|
|
_isAwake = YES;
|
|
|
|
|
/*
|
|
|
|
|
* Add local entries into name table.
|
|
|
|
|
*/
|
|
|
|
|
if ([context count] > 0)
|
|
|
|
|
{
|
|
|
|
|
[nameTable addEntriesFromDictionary: context];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Now establish all connections by taking the names
|
|
|
|
|
* stored in the connection objects, and replaciong them
|
|
|
|
|
* with the corresponding values from the name table
|
|
|
|
|
* before telling the connections to establish themselves.
|
|
|
|
|
*/
|
|
|
|
|
enumerator = [connections objectEnumerator];
|
|
|
|
|
while ((connection = [enumerator nextObject]) != nil)
|
|
|
|
|
{
|
|
|
|
|
id val;
|
|
|
|
|
|
|
|
|
|
val = [nameTable objectForKey: [connection source]];
|
|
|
|
|
[connection setSource: val];
|
|
|
|
|
val = [nameTable objectForKey: [connection destination]];
|
|
|
|
|
[connection setDestination: val];
|
|
|
|
|
[connection establishConnection];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Now tell all the objects that they have been loaded from
|
|
|
|
|
* a nib.
|
|
|
|
|
*/
|
|
|
|
|
enumerator = [nameTable keyEnumerator];
|
|
|
|
|
while ((key = [enumerator nextObject]) != nil)
|
|
|
|
|
{
|
2002-07-18 13:46:41 +00:00
|
|
|
|
if ([context objectForKey: key] == nil ||
|
|
|
|
|
[key isEqualToString: @"NSOwner"]) // we want to send the message to the owner
|
2000-01-03 18:42:16 +00:00
|
|
|
|
{
|
|
|
|
|
id o;
|
|
|
|
|
|
|
|
|
|
o = [nameTable objectForKey: key];
|
|
|
|
|
if ([o respondsToSelector: @selector(awakeFromNib)])
|
|
|
|
|
{
|
|
|
|
|
[o awakeFromNib];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* See if there are objects that should be made visible.
|
|
|
|
|
*/
|
|
|
|
|
visible = [nameTable objectForKey: @"NSVisible"];
|
|
|
|
|
if (visible != nil
|
|
|
|
|
&& [visible isKindOfClass: [NSArray class]] == YES)
|
|
|
|
|
{
|
|
|
|
|
unsigned pos = [visible count];
|
|
|
|
|
|
|
|
|
|
while (pos-- > 0)
|
|
|
|
|
{
|
2001-05-24 14:47:43 +00:00
|
|
|
|
NSWindow *win = [visible objectAtIndex: pos];
|
|
|
|
|
if ([NSApp isActive])
|
|
|
|
|
[win orderFront: self];
|
|
|
|
|
else
|
|
|
|
|
[NSApp _deactivateVisibleWindow: win];
|
2000-01-03 18:42:16 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2000-01-13 21:20:15 +00:00
|
|
|
|
/*
|
|
|
|
|
* See if there is a main menu to be set.
|
|
|
|
|
*/
|
|
|
|
|
menu = [nameTable objectForKey: @"NSMenu"];
|
|
|
|
|
if (menu != nil && [menu isKindOfClass: [NSMenu class]] == YES)
|
|
|
|
|
{
|
|
|
|
|
[NSApp setMainMenu: menu];
|
|
|
|
|
}
|
|
|
|
|
|
2000-01-03 18:42:16 +00:00
|
|
|
|
/*
|
|
|
|
|
* Now remove any objects added from the context dictionary.
|
|
|
|
|
*/
|
|
|
|
|
if ([context count] > 0)
|
|
|
|
|
{
|
|
|
|
|
[nameTable removeObjectsForKeys: [context allKeys]];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
1999-11-29 11:45:50 +00:00
|
|
|
|
- (NSMutableArray*) connections
|
|
|
|
|
{
|
|
|
|
|
return connections;
|
|
|
|
|
}
|
|
|
|
|
|
1999-01-15 10:14:28 +00:00
|
|
|
|
- (void) dealloc
|
|
|
|
|
{
|
1999-11-29 11:45:50 +00:00
|
|
|
|
RELEASE(nameTable);
|
|
|
|
|
RELEASE(connections);
|
1999-01-15 10:14:28 +00:00
|
|
|
|
[super dealloc];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) encodeWithCoder: (NSCoder*)aCoder
|
|
|
|
|
{
|
|
|
|
|
[aCoder encodeObject: nameTable];
|
1999-11-29 11:45:50 +00:00
|
|
|
|
[aCoder encodeObject: connections];
|
1999-01-15 10:14:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (id) init
|
|
|
|
|
{
|
|
|
|
|
if ((self = [super init]) != nil)
|
|
|
|
|
{
|
|
|
|
|
nameTable = [[NSMutableDictionary alloc] initWithCapacity: 8];
|
1999-11-29 11:45:50 +00:00
|
|
|
|
connections = [[NSMutableArray alloc] initWithCapacity: 8];
|
1999-01-15 10:14:28 +00:00
|
|
|
|
}
|
|
|
|
|
return self;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (id) initWithCoder: (NSCoder*)aCoder
|
|
|
|
|
{
|
2002-11-18 06:00:26 +00:00
|
|
|
|
int version = [aCoder versionForClassName: @"GSNibContainer"];
|
2002-12-29 05:38:29 +00:00
|
|
|
|
|
2002-11-18 06:00:26 +00:00
|
|
|
|
if(version == GNUSTEP_NIB_VERSION)
|
|
|
|
|
{
|
|
|
|
|
[aCoder decodeValueOfObjCType: @encode(id) at: &nameTable];
|
|
|
|
|
[aCoder decodeValueOfObjCType: @encode(id) at: &connections];
|
|
|
|
|
}
|
|
|
|
|
|
1999-01-15 10:14:28 +00:00
|
|
|
|
return self;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (NSMutableDictionary*) nameTable
|
|
|
|
|
{
|
|
|
|
|
return nameTable;
|
|
|
|
|
}
|
|
|
|
|
|
1997-02-18 00:29:25 +00:00
|
|
|
|
@end
|
|
|
|
|
|
1999-01-17 08:14:03 +00:00
|
|
|
|
@implementation GSNibItem
|
2002-03-01 14:41:59 +00:00
|
|
|
|
+ (void) initialize
|
|
|
|
|
{
|
|
|
|
|
if (self == [GSNibItem class])
|
|
|
|
|
{
|
|
|
|
|
[self setVersion: currentVersion];
|
|
|
|
|
}
|
|
|
|
|
}
|
1999-11-29 11:45:50 +00:00
|
|
|
|
|
1999-01-17 08:14:03 +00:00
|
|
|
|
- (void) dealloc
|
|
|
|
|
{
|
1999-11-29 11:45:50 +00:00
|
|
|
|
RELEASE(theClass);
|
|
|
|
|
[super dealloc];
|
1999-01-17 08:14:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-11-29 11:45:50 +00:00
|
|
|
|
- (void) encodeWithCoder: (NSCoder*)aCoder
|
1999-01-17 08:14:03 +00:00
|
|
|
|
{
|
1999-11-29 11:45:50 +00:00
|
|
|
|
[aCoder encodeObject: theClass];
|
|
|
|
|
[aCoder encodeRect: theFrame];
|
2002-03-01 14:41:59 +00:00
|
|
|
|
[aCoder encodeValueOfObjCType: @encode(unsigned int)
|
|
|
|
|
at: &autoresizingMask];
|
1999-01-17 08:14:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (id) initWithCoder: (NSCoder*)aCoder
|
|
|
|
|
{
|
2002-03-01 14:41:59 +00:00
|
|
|
|
int version = [aCoder versionForClassName:
|
|
|
|
|
NSStringFromClass([self class])];
|
1999-01-17 08:14:03 +00:00
|
|
|
|
|
2002-03-01 14:41:59 +00:00
|
|
|
|
if (version == 1)
|
|
|
|
|
{
|
|
|
|
|
id obj;
|
|
|
|
|
Class cls;
|
|
|
|
|
unsigned int mask;
|
|
|
|
|
|
|
|
|
|
[aCoder decodeValueOfObjCType: @encode(id) at: &theClass];
|
|
|
|
|
theFrame = [aCoder decodeRect];
|
|
|
|
|
[aCoder decodeValueOfObjCType: @encode(unsigned int)
|
|
|
|
|
at: &mask];
|
|
|
|
|
|
|
|
|
|
cls = NSClassFromString(theClass);
|
|
|
|
|
if (cls == nil)
|
|
|
|
|
{
|
|
|
|
|
[NSException raise: NSInternalInconsistencyException
|
|
|
|
|
format: @"Unable to find class '%@'", theClass];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
obj = [cls allocWithZone: [self zone]];
|
|
|
|
|
if (theFrame.size.height > 0 && theFrame.size.width > 0)
|
|
|
|
|
obj = [obj initWithFrame: theFrame];
|
|
|
|
|
else
|
|
|
|
|
obj = [obj init];
|
1999-01-17 08:14:03 +00:00
|
|
|
|
|
2002-03-01 14:41:59 +00:00
|
|
|
|
if ([obj respondsToSelector: @selector(setAutoresizingMask:)])
|
|
|
|
|
{
|
|
|
|
|
[obj setAutoresizingMask: mask];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
RELEASE(self);
|
|
|
|
|
return obj;
|
|
|
|
|
}
|
|
|
|
|
else if (version == 0)
|
1999-11-29 11:45:50 +00:00
|
|
|
|
{
|
2002-03-01 14:41:59 +00:00
|
|
|
|
id obj;
|
|
|
|
|
Class cls;
|
|
|
|
|
|
|
|
|
|
[aCoder decodeValueOfObjCType: @encode(id) at: &theClass];
|
|
|
|
|
theFrame = [aCoder decodeRect];
|
|
|
|
|
|
|
|
|
|
cls = NSClassFromString(theClass);
|
|
|
|
|
if (cls == nil)
|
|
|
|
|
{
|
|
|
|
|
[NSException raise: NSInternalInconsistencyException
|
|
|
|
|
format: @"Unable to find class '%@'", theClass];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
obj = [cls allocWithZone: [self zone]];
|
|
|
|
|
if (theFrame.size.height > 0 && theFrame.size.width > 0)
|
|
|
|
|
obj = [obj initWithFrame: theFrame];
|
|
|
|
|
else
|
|
|
|
|
obj = [obj init];
|
|
|
|
|
|
|
|
|
|
RELEASE(self);
|
|
|
|
|
return obj;
|
1999-11-29 11:45:50 +00:00
|
|
|
|
}
|
1999-01-17 08:14:03 +00:00
|
|
|
|
else
|
2002-03-01 14:41:59 +00:00
|
|
|
|
{
|
|
|
|
|
NSLog(@"no initWithCoder for this version");
|
|
|
|
|
RELEASE(self);
|
|
|
|
|
return nil;
|
|
|
|
|
}
|
1999-01-17 08:14:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
2001-10-03 17:05:57 +00:00
|
|
|
|
@implementation GSCustomView
|
2002-03-01 14:41:59 +00:00
|
|
|
|
+ (void) initialize
|
|
|
|
|
{
|
|
|
|
|
if (self == [GSCustomView class])
|
|
|
|
|
{
|
|
|
|
|
[self setVersion: currentVersion];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2001-10-03 17:05:57 +00:00
|
|
|
|
- (void) encodeWithCoder: (NSCoder*)aCoder
|
|
|
|
|
{
|
|
|
|
|
[super encodeWithCoder: aCoder];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (id) initWithCoder: (NSCoder*)aCoder
|
|
|
|
|
{
|
|
|
|
|
return [super initWithCoder: aCoder];
|
|
|
|
|
}
|
|
|
|
|
@end
|
2002-10-06 23:59:30 +00:00
|
|
|
|
|
2002-10-08 06:30:13 +00:00
|
|
|
|
/*
|
|
|
|
|
*
|
|
|
|
|
* Template Classes: these are used to
|
|
|
|
|
* persist custom classes (classes implemented by the user and loaded into Gorm
|
|
|
|
|
* to .gorm files.
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
2002-10-06 23:59:30 +00:00
|
|
|
|
// Template for any class which derives from NSWindow.
|
|
|
|
|
@implementation NSWindowTemplate
|
|
|
|
|
+ (void) initialize
|
|
|
|
|
{
|
|
|
|
|
if (self == [NSWindowTemplate class])
|
|
|
|
|
{
|
|
|
|
|
[self setVersion: 0];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) dealloc
|
|
|
|
|
{
|
|
|
|
|
RELEASE(_className);
|
|
|
|
|
[super dealloc];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- init
|
|
|
|
|
{
|
|
|
|
|
[super init];
|
|
|
|
|
|
|
|
|
|
// Start initially with the highest level class...
|
|
|
|
|
ASSIGN(_className, NSStringFromClass([super class]));
|
|
|
|
|
RETAIN(_className);
|
2002-10-13 06:03:10 +00:00
|
|
|
|
ASSIGN(_parentClassName, NSStringFromClass([super class]));
|
|
|
|
|
RETAIN(_parentClassName);
|
2002-10-06 23:59:30 +00:00
|
|
|
|
|
|
|
|
|
// defer flag...
|
|
|
|
|
_deferFlag = NO;
|
|
|
|
|
|
|
|
|
|
return self;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (id) initWithCoder: (NSCoder *)aCoder
|
|
|
|
|
{
|
|
|
|
|
[aCoder decodeValueOfObjCType: @encode(id) at: &_className];
|
2002-10-13 06:03:10 +00:00
|
|
|
|
[aCoder decodeValueOfObjCType: @encode(id) at: &_parentClassName];
|
2002-10-06 23:59:30 +00:00
|
|
|
|
[aCoder decodeValueOfObjCType: @encode(BOOL) at: &_deferFlag];
|
|
|
|
|
return [super initWithCoder: aCoder];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) encodeWithCoder: (NSCoder *)aCoder
|
|
|
|
|
{
|
|
|
|
|
[aCoder encodeValueOfObjCType: @encode(id) at: &_className];
|
2002-10-13 06:03:10 +00:00
|
|
|
|
[aCoder encodeValueOfObjCType: @encode(id) at: &_parentClassName];
|
2002-10-06 23:59:30 +00:00
|
|
|
|
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_deferFlag];
|
|
|
|
|
[super encodeWithCoder: aCoder];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (id) awakeAfterUsingCoder: (NSCoder *)coder
|
|
|
|
|
{
|
|
|
|
|
return [self instantiateObject: coder];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (id) instantiateObject: (NSCoder *)coder
|
|
|
|
|
{
|
|
|
|
|
id obj = nil;
|
|
|
|
|
Class aClass = NSClassFromString(_className);
|
|
|
|
|
|
|
|
|
|
if (aClass == nil)
|
|
|
|
|
{
|
|
|
|
|
[NSException raise: NSInternalInconsistencyException
|
|
|
|
|
format: @"Unable to find class '%@'", _className];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
obj = [[aClass allocWithZone: [self zone]]
|
|
|
|
|
initWithContentRect: [self frame]
|
|
|
|
|
styleMask: [self styleMask]
|
|
|
|
|
backing: [self backingType]
|
|
|
|
|
defer: _deferFlag];
|
|
|
|
|
|
2002-10-08 06:30:13 +00:00
|
|
|
|
// fill in actual object from template...
|
2002-10-06 23:59:30 +00:00
|
|
|
|
[obj setBackgroundColor: [self backgroundColor]];
|
|
|
|
|
[obj setContentView: [self contentView]];
|
|
|
|
|
[obj setFrameAutosaveName: [self frameAutosaveName]];
|
|
|
|
|
[obj setHidesOnDeactivate: [self hidesOnDeactivate]];
|
|
|
|
|
[obj setInitialFirstResponder: [self initialFirstResponder]];
|
|
|
|
|
[obj setAutodisplay: [self isAutodisplay]];
|
|
|
|
|
[obj setReleasedWhenClosed: [self isReleasedWhenClosed]];
|
|
|
|
|
[obj _setVisible: [self isVisible]];
|
|
|
|
|
[obj setTitle: [self title]];
|
|
|
|
|
[obj setFrame: [self frame] display: NO];
|
|
|
|
|
|
|
|
|
|
RELEASE(self);
|
|
|
|
|
return obj;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// setters and getters...
|
|
|
|
|
- (void) setClassName: (NSString *)name
|
|
|
|
|
{
|
|
|
|
|
ASSIGN(_className, name);
|
2002-11-18 06:00:26 +00:00
|
|
|
|
RETAIN(_className);
|
2002-10-06 23:59:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (NSString *)className
|
|
|
|
|
{
|
|
|
|
|
return _className;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (BOOL)deferFlag
|
|
|
|
|
{
|
|
|
|
|
return _deferFlag;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void)setDeferFlag: (BOOL)flag
|
|
|
|
|
{
|
|
|
|
|
_deferFlag = flag;
|
|
|
|
|
}
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
|
|
// Template for any classes which derive from NSView
|
|
|
|
|
@implementation NSViewTemplate
|
|
|
|
|
+ (void) initialize
|
|
|
|
|
{
|
|
|
|
|
if (self == [NSViewTemplate class])
|
|
|
|
|
{
|
|
|
|
|
[self setVersion: 0];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) dealloc
|
|
|
|
|
{
|
|
|
|
|
RELEASE(_className);
|
|
|
|
|
[super dealloc];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- initWithFrame: (NSRect)frame
|
|
|
|
|
{
|
|
|
|
|
// Start initially with the highest level class...
|
|
|
|
|
ASSIGN(_className, NSStringFromClass([super class]));
|
|
|
|
|
RETAIN(_className);
|
2002-10-13 06:03:10 +00:00
|
|
|
|
ASSIGN(_parentClassName, NSStringFromClass([super class]));
|
|
|
|
|
RETAIN(_parentClassName);
|
2002-10-06 23:59:30 +00:00
|
|
|
|
[super initWithFrame: frame];
|
|
|
|
|
|
|
|
|
|
return self;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- init
|
|
|
|
|
{
|
|
|
|
|
// Start initially with the highest level class...
|
|
|
|
|
[super init];
|
|
|
|
|
ASSIGN(_className, NSStringFromClass([super class]));
|
|
|
|
|
RETAIN(_className);
|
2002-10-13 06:03:10 +00:00
|
|
|
|
ASSIGN(_parentClassName, NSStringFromClass([super class]));
|
|
|
|
|
RETAIN(_parentClassName);
|
2002-10-06 23:59:30 +00:00
|
|
|
|
return self;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (id) initWithCoder: (NSCoder *)aCoder
|
|
|
|
|
{
|
|
|
|
|
[aCoder decodeValueOfObjCType: @encode(id) at: &_className];
|
2002-10-13 06:03:10 +00:00
|
|
|
|
[aCoder decodeValueOfObjCType: @encode(id) at: &_parentClassName];
|
|
|
|
|
return [super initWithCoder: aCoder];
|
2002-10-06 23:59:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) encodeWithCoder: (NSCoder *)aCoder
|
|
|
|
|
{
|
|
|
|
|
[aCoder encodeValueOfObjCType: @encode(id) at: &_className];
|
2002-10-13 06:03:10 +00:00
|
|
|
|
[aCoder encodeValueOfObjCType: @encode(id) at: &_parentClassName];
|
2002-10-06 23:59:30 +00:00
|
|
|
|
[super encodeWithCoder: aCoder];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (id) awakeAfterUsingCoder: (NSCoder *)coder
|
|
|
|
|
{
|
|
|
|
|
return [self instantiateObject: coder];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (id) instantiateObject: (NSCoder *)coder
|
|
|
|
|
{
|
|
|
|
|
Class aClass = NSClassFromString(_className);
|
|
|
|
|
NSRect theFrame = [self frame];
|
|
|
|
|
id obj = nil;
|
|
|
|
|
|
|
|
|
|
if (aClass == nil)
|
|
|
|
|
{
|
|
|
|
|
[NSException raise: NSInternalInconsistencyException
|
|
|
|
|
format: @"Unable to find class '%@'", _className];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
obj = [[aClass allocWithZone: NSDefaultMallocZone()]
|
|
|
|
|
initWithFrame: theFrame];
|
|
|
|
|
|
|
|
|
|
// set the attributes for the view
|
|
|
|
|
[obj setBounds: [self bounds]];
|
|
|
|
|
|
|
|
|
|
RELEASE(self);
|
|
|
|
|
return obj;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// setters and getters
|
|
|
|
|
- (void) setClassName: (NSString *)name
|
|
|
|
|
{
|
|
|
|
|
ASSIGN(_className, name);
|
2002-11-18 06:00:26 +00:00
|
|
|
|
RETAIN(_className);
|
2002-10-06 23:59:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (NSString *)className
|
|
|
|
|
{
|
|
|
|
|
return _className;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
|
|
// Template for any classes which derive from NSText
|
|
|
|
|
@implementation NSTextTemplate
|
|
|
|
|
+ (void) initialize
|
|
|
|
|
{
|
|
|
|
|
if (self == [NSTextTemplate class])
|
|
|
|
|
{
|
|
|
|
|
[self setVersion: 0];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) dealloc
|
|
|
|
|
{
|
|
|
|
|
RELEASE(_className);
|
|
|
|
|
[super dealloc];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- initWithFrame: (NSRect)frame
|
|
|
|
|
{
|
|
|
|
|
// Start initially with the highest level class...
|
|
|
|
|
ASSIGN(_className, NSStringFromClass([super class]));
|
|
|
|
|
RETAIN(_className);
|
2002-10-13 06:03:10 +00:00
|
|
|
|
ASSIGN(_parentClassName, NSStringFromClass([super class]));
|
|
|
|
|
RETAIN(_parentClassName);
|
2002-10-06 23:59:30 +00:00
|
|
|
|
[super initWithFrame: frame];
|
|
|
|
|
return self;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- init
|
|
|
|
|
{
|
|
|
|
|
// Start initially with the highest level class...
|
|
|
|
|
[super init];
|
|
|
|
|
ASSIGN(_className, NSStringFromClass([super class]));
|
|
|
|
|
RETAIN(_className);
|
|
|
|
|
return self;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (id) initWithCoder: (NSCoder *)aCoder
|
|
|
|
|
{
|
|
|
|
|
[aCoder decodeValueOfObjCType: @encode(id) at: &_className];
|
2002-10-13 06:03:10 +00:00
|
|
|
|
[aCoder decodeValueOfObjCType: @encode(id) at: &_parentClassName];
|
|
|
|
|
return [super initWithCoder: aCoder];
|
2002-10-06 23:59:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) encodeWithCoder: (NSCoder *)aCoder
|
|
|
|
|
{
|
|
|
|
|
[aCoder encodeValueOfObjCType: @encode(id) at: &_className];
|
2002-10-13 06:03:10 +00:00
|
|
|
|
[aCoder encodeValueOfObjCType: @encode(id) at: &_parentClassName];
|
2002-10-06 23:59:30 +00:00
|
|
|
|
[super encodeWithCoder: aCoder];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (id) awakeAfterUsingCoder: (NSCoder *)coder
|
|
|
|
|
{
|
|
|
|
|
return [self instantiateObject: coder];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (id) instantiateObject: (NSCoder *)coder
|
|
|
|
|
{
|
|
|
|
|
Class aClass = NSClassFromString(_className);
|
|
|
|
|
NSRect theFrame = [self frame];
|
|
|
|
|
id obj = nil;
|
|
|
|
|
|
|
|
|
|
if (aClass == nil)
|
|
|
|
|
{
|
|
|
|
|
[NSException raise: NSInternalInconsistencyException
|
|
|
|
|
format: @"Unable to find class '%@'", _className];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
obj = [[aClass allocWithZone: NSDefaultMallocZone()]
|
|
|
|
|
initWithFrame: theFrame];
|
|
|
|
|
|
|
|
|
|
// set the attributes for the view
|
|
|
|
|
[obj setBounds: [self bounds]];
|
|
|
|
|
|
|
|
|
|
// set the attributes for text
|
|
|
|
|
[obj setBackgroundColor: [self backgroundColor]];
|
|
|
|
|
[obj setDrawsBackground: [self drawsBackground]];
|
|
|
|
|
[obj setEditable: [self isEditable]];
|
|
|
|
|
[obj setSelectable: [self isSelectable]];
|
|
|
|
|
[obj setFieldEditor: [self isFieldEditor]];
|
|
|
|
|
[obj setRichText: [self isRichText]];
|
|
|
|
|
[obj setImportsGraphics: [self importsGraphics]];
|
|
|
|
|
[obj setDelegate: [self delegate]];
|
|
|
|
|
|
|
|
|
|
RELEASE(self);
|
|
|
|
|
return obj;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// accessor methods...
|
|
|
|
|
- (void) setClassName: (NSString *)name
|
|
|
|
|
{
|
|
|
|
|
ASSIGN(_className, name);
|
2002-11-18 06:00:26 +00:00
|
|
|
|
RETAIN(_className);
|
2002-10-06 23:59:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (NSString *)className
|
|
|
|
|
{
|
|
|
|
|
return _className;
|
|
|
|
|
}
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
|
|
// Template for any classes which derive from NSTextView
|
|
|
|
|
@implementation NSTextViewTemplate
|
|
|
|
|
+ (void) initialize
|
|
|
|
|
{
|
|
|
|
|
if (self == [NSTextViewTemplate class])
|
|
|
|
|
{
|
|
|
|
|
[self setVersion: 0];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) dealloc
|
|
|
|
|
{
|
|
|
|
|
RELEASE(_className);
|
|
|
|
|
[super dealloc];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- initWithFrame: (NSRect)frame
|
|
|
|
|
{
|
|
|
|
|
// Start initially with the highest level class...
|
|
|
|
|
ASSIGN(_className, NSStringFromClass([super class]));
|
|
|
|
|
RETAIN(_className);
|
2002-10-13 06:03:10 +00:00
|
|
|
|
ASSIGN(_parentClassName, NSStringFromClass([super class]));
|
|
|
|
|
RETAIN(_parentClassName);
|
2002-10-06 23:59:30 +00:00
|
|
|
|
[super initWithFrame: frame];
|
|
|
|
|
return self;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- init
|
|
|
|
|
{
|
|
|
|
|
[super init];
|
|
|
|
|
ASSIGN(_className, NSStringFromClass([super class]));
|
|
|
|
|
RETAIN(_className);
|
2002-10-13 06:03:10 +00:00
|
|
|
|
ASSIGN(_parentClassName, NSStringFromClass([super class]));
|
|
|
|
|
RETAIN(_parentClassName);
|
2002-10-06 23:59:30 +00:00
|
|
|
|
return self;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (id) initWithCoder: (NSCoder *)aCoder
|
|
|
|
|
{
|
|
|
|
|
[aCoder decodeValueOfObjCType: @encode(id) at: &_className];
|
2002-10-13 06:03:10 +00:00
|
|
|
|
[aCoder decodeValueOfObjCType: @encode(id) at: &_parentClassName];
|
|
|
|
|
return [super initWithCoder: aCoder];
|
2002-10-06 23:59:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) encodeWithCoder: (NSCoder *)aCoder
|
|
|
|
|
{
|
|
|
|
|
[aCoder encodeValueOfObjCType: @encode(id) at: &_className];
|
2002-10-13 06:03:10 +00:00
|
|
|
|
[aCoder encodeValueOfObjCType: @encode(id) at: &_parentClassName];
|
2002-10-06 23:59:30 +00:00
|
|
|
|
[super encodeWithCoder: aCoder];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (id) awakeAfterUsingCoder: (NSCoder *)coder
|
|
|
|
|
{
|
|
|
|
|
return [self instantiateObject: coder];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (id) instantiateObject: (NSCoder *)coder
|
|
|
|
|
{
|
|
|
|
|
Class aClass = NSClassFromString(_className);
|
|
|
|
|
NSRect theFrame = [self frame];
|
|
|
|
|
id obj = nil;
|
|
|
|
|
|
|
|
|
|
if (aClass == nil)
|
|
|
|
|
{
|
|
|
|
|
[NSException raise: NSInternalInconsistencyException
|
|
|
|
|
format: @"Unable to find class '%@'", _className];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
obj = [[aClass allocWithZone: NSDefaultMallocZone()]
|
|
|
|
|
initWithFrame: theFrame];
|
|
|
|
|
|
|
|
|
|
// set the attributes for the view
|
|
|
|
|
[obj setBounds: [self bounds]];
|
|
|
|
|
|
|
|
|
|
// set the attributes for text
|
|
|
|
|
[obj setBackgroundColor: [self backgroundColor]];
|
|
|
|
|
[obj setDrawsBackground: [self drawsBackground]];
|
|
|
|
|
[obj setEditable: [self isEditable]];
|
|
|
|
|
[obj setSelectable: [self isSelectable]];
|
|
|
|
|
[obj setFieldEditor: [self isFieldEditor]];
|
|
|
|
|
[obj setRichText: [self isRichText]];
|
|
|
|
|
[obj setImportsGraphics: [self importsGraphics]];
|
|
|
|
|
[obj setDelegate: [self delegate]];
|
|
|
|
|
|
|
|
|
|
// text view
|
|
|
|
|
[obj setRulerVisible: [self isRulerVisible]];
|
|
|
|
|
[obj setInsertionPointColor: [self insertionPointColor]];
|
|
|
|
|
|
|
|
|
|
RELEASE(self);
|
|
|
|
|
return obj;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// accessors
|
|
|
|
|
- (void) setClassName: (NSString *)name
|
|
|
|
|
{
|
|
|
|
|
ASSIGN(_className, name);
|
2002-11-18 06:00:26 +00:00
|
|
|
|
RETAIN(_className);
|
2002-10-06 23:59:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (NSString *)className
|
|
|
|
|
{
|
|
|
|
|
return _className;
|
|
|
|
|
}
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
|
|
// Template for any classes which derive from NSMenu.
|
|
|
|
|
@implementation NSMenuTemplate
|
|
|
|
|
+ (void) initialize
|
|
|
|
|
{
|
|
|
|
|
if (self == [NSMenuTemplate class])
|
|
|
|
|
{
|
|
|
|
|
[self setVersion: 0];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) dealloc
|
|
|
|
|
{
|
|
|
|
|
RELEASE(_className);
|
|
|
|
|
[super dealloc];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- init
|
|
|
|
|
{
|
|
|
|
|
[super init];
|
|
|
|
|
// Start initially with the highest level class...
|
|
|
|
|
ASSIGN(_className, NSStringFromClass([super class]));
|
|
|
|
|
RETAIN(_className);
|
2002-10-13 06:03:10 +00:00
|
|
|
|
ASSIGN(_parentClassName, NSStringFromClass([super class]));
|
|
|
|
|
RETAIN(_parentClassName);
|
2002-10-06 23:59:30 +00:00
|
|
|
|
return self;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (id) initWithCoder: (NSCoder *)aCoder
|
|
|
|
|
{
|
|
|
|
|
[aCoder decodeValueOfObjCType: @encode(id) at: &_className];
|
2002-10-13 06:03:10 +00:00
|
|
|
|
[aCoder decodeValueOfObjCType: @encode(id) at: &_parentClassName];
|
|
|
|
|
return [super initWithCoder: aCoder];
|
2002-10-06 23:59:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) encodeWithCoder: (NSCoder *)aCoder
|
|
|
|
|
{
|
|
|
|
|
[aCoder encodeValueOfObjCType: @encode(id) at: &_className];
|
2002-10-13 06:03:10 +00:00
|
|
|
|
[aCoder encodeValueOfObjCType: @encode(id) at: &_parentClassName];
|
2002-10-06 23:59:30 +00:00
|
|
|
|
[super encodeWithCoder: aCoder];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (id) awakeAfterUsingCoder: (NSCoder *)coder
|
|
|
|
|
{
|
|
|
|
|
return [self instantiateObject: coder];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (id) instantiateObject: (NSCoder *)coder
|
|
|
|
|
{
|
|
|
|
|
Class aClass = NSClassFromString(_className);
|
|
|
|
|
id obj = nil;
|
|
|
|
|
|
|
|
|
|
if (aClass == nil)
|
|
|
|
|
{
|
|
|
|
|
[NSException raise: NSInternalInconsistencyException
|
|
|
|
|
format: @"Unable to find class '%@'", _className];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
obj = [[aClass allocWithZone: NSDefaultMallocZone()] init];
|
|
|
|
|
|
|
|
|
|
// copy attributes
|
|
|
|
|
[obj setAutoenablesItems: [self autoenablesItems]];
|
|
|
|
|
[obj setTitle: [self title]];
|
|
|
|
|
|
|
|
|
|
RELEASE(self);
|
|
|
|
|
return obj;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// accessors
|
|
|
|
|
- (void) setClassName: (NSString *)name
|
|
|
|
|
{
|
|
|
|
|
ASSIGN(_className, name);
|
2002-11-18 06:00:26 +00:00
|
|
|
|
RETAIN(_className);
|
|
|
|
|
|
2002-10-06 23:59:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (NSString *)className
|
|
|
|
|
{
|
|
|
|
|
return _className;
|
|
|
|
|
}
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Template for any classes which derive from NSControl
|
|
|
|
|
@implementation NSControlTemplate
|
|
|
|
|
+ (void) initialize
|
|
|
|
|
{
|
|
|
|
|
if (self == [NSControlTemplate class])
|
|
|
|
|
{
|
|
|
|
|
[self setVersion: 0];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) dealloc
|
|
|
|
|
{
|
|
|
|
|
RELEASE(_className);
|
|
|
|
|
[super dealloc];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- initWithFrame: (NSRect)frame
|
|
|
|
|
{
|
|
|
|
|
// Start initially with the highest level class...
|
|
|
|
|
ASSIGN(_className, NSStringFromClass([super class]));
|
|
|
|
|
RETAIN(_className);
|
2002-10-13 06:03:10 +00:00
|
|
|
|
ASSIGN(_parentClassName, NSStringFromClass([super class]));
|
|
|
|
|
RETAIN(_parentClassName);
|
2002-10-06 23:59:30 +00:00
|
|
|
|
[super initWithFrame: frame];
|
|
|
|
|
|
|
|
|
|
return self;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- init
|
|
|
|
|
{
|
|
|
|
|
// Start initially with the highest level class...
|
|
|
|
|
[super init];
|
|
|
|
|
ASSIGN(_className, NSStringFromClass([super class]));
|
|
|
|
|
RETAIN(_className);
|
2002-10-13 06:03:10 +00:00
|
|
|
|
ASSIGN(_parentClassName, NSStringFromClass([super class]));
|
|
|
|
|
RETAIN(_parentClassName);
|
2002-10-06 23:59:30 +00:00
|
|
|
|
return self;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (id) initWithCoder: (NSCoder *)aCoder
|
|
|
|
|
{
|
|
|
|
|
[aCoder decodeValueOfObjCType: @encode(id) at: &_className];
|
2002-10-13 06:03:10 +00:00
|
|
|
|
[aCoder decodeValueOfObjCType: @encode(id) at: &_parentClassName];
|
2002-10-06 23:59:30 +00:00
|
|
|
|
[aCoder decodeValueOfObjCType: @encode(id) at: &_delegate];
|
2002-10-08 02:05:54 +00:00
|
|
|
|
[aCoder decodeValueOfObjCType: @encode(id) at: &_dataSource];
|
|
|
|
|
[aCoder decodeValueOfObjCType: @encode(BOOL) at: &_usesDataSource];
|
|
|
|
|
return [super initWithCoder: aCoder];
|
2002-10-06 23:59:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) encodeWithCoder: (NSCoder *)aCoder
|
|
|
|
|
{
|
|
|
|
|
[aCoder encodeValueOfObjCType: @encode(id) at: &_className];
|
2002-10-13 06:03:10 +00:00
|
|
|
|
[aCoder encodeValueOfObjCType: @encode(id) at: &_parentClassName];
|
2002-10-06 23:59:30 +00:00
|
|
|
|
[aCoder encodeValueOfObjCType: @encode(id) at: &_delegate];
|
2002-10-08 02:05:54 +00:00
|
|
|
|
[aCoder encodeValueOfObjCType: @encode(id) at: &_dataSource];
|
|
|
|
|
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_usesDataSource];
|
2002-10-06 23:59:30 +00:00
|
|
|
|
[super encodeWithCoder: aCoder];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (id) awakeAfterUsingCoder: (NSCoder *)coder
|
|
|
|
|
{
|
|
|
|
|
return [self instantiateObject: coder];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (id) instantiateObject: (NSCoder *)coder
|
|
|
|
|
{
|
|
|
|
|
Class aClass = NSClassFromString(_className);
|
|
|
|
|
NSRect theFrame = [self frame];
|
|
|
|
|
id obj = nil;
|
|
|
|
|
|
|
|
|
|
if (aClass == nil)
|
|
|
|
|
{
|
|
|
|
|
[NSException raise: NSInternalInconsistencyException
|
|
|
|
|
format: @"Unable to find class '%@'", _className];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
obj = [[aClass allocWithZone: NSDefaultMallocZone()]
|
|
|
|
|
initWithFrame: theFrame];
|
|
|
|
|
|
|
|
|
|
// set the attributes for the view
|
|
|
|
|
[obj setBounds: [self bounds]];
|
|
|
|
|
|
|
|
|
|
// set the attributes for the control
|
|
|
|
|
[obj setDoubleValue: [self doubleValue]];
|
|
|
|
|
[obj setFloatValue: [self floatValue]];
|
|
|
|
|
[obj setIntValue: [self intValue]];
|
|
|
|
|
[obj setObjectValue: [self objectValue]];
|
|
|
|
|
[obj setStringValue: [self stringValue]];
|
|
|
|
|
[obj setTag: [self tag]];
|
|
|
|
|
[obj setFont: [self font]];
|
|
|
|
|
[obj setAlignment: [self alignment]];
|
|
|
|
|
[obj setEnabled: [self isEnabled]];
|
2002-10-08 02:05:54 +00:00
|
|
|
|
[obj setContinuous: [self isContinuous]];
|
2002-10-06 23:59:30 +00:00
|
|
|
|
|
|
|
|
|
// since only some controls have delegates, we need to test...
|
|
|
|
|
if([obj respondsToSelector: @selector(setDelegate:)])
|
|
|
|
|
[obj setDelegate: _delegate];
|
|
|
|
|
|
|
|
|
|
// since only some controls have data sources, we need to test...
|
|
|
|
|
if([obj respondsToSelector: @selector(setDataSource:)])
|
|
|
|
|
[obj setDataSource: _dataSource];
|
|
|
|
|
|
|
|
|
|
// since only some controls have data sources, we need to test...
|
|
|
|
|
if([obj respondsToSelector: @selector(setUsesDataSource:)])
|
|
|
|
|
[obj setUsesDataSource: _usesDataSource];
|
2002-10-08 06:30:13 +00:00
|
|
|
|
|
|
|
|
|
RELEASE(self);
|
|
|
|
|
return obj;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// accessors
|
|
|
|
|
- (void) setClassName: (NSString *)name
|
|
|
|
|
{
|
|
|
|
|
ASSIGN(_className, name);
|
2002-11-18 06:00:26 +00:00
|
|
|
|
RETAIN(_className);
|
2002-10-08 06:30:13 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (NSString *)className
|
|
|
|
|
{
|
|
|
|
|
return _className;
|
|
|
|
|
}
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
|
|
// Template for any classes which derive from NSButton
|
|
|
|
|
@implementation NSButtonTemplate
|
|
|
|
|
+ (void) initialize
|
|
|
|
|
{
|
|
|
|
|
if (self == [NSButtonTemplate class])
|
|
|
|
|
{
|
|
|
|
|
[self setVersion: 0];
|
2002-10-06 23:59:30 +00:00
|
|
|
|
}
|
2002-10-08 06:30:13 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) dealloc
|
|
|
|
|
{
|
|
|
|
|
RELEASE(_className);
|
|
|
|
|
[super dealloc];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- initWithFrame: (NSRect)frame
|
|
|
|
|
{
|
|
|
|
|
// Start initially with the highest level class...
|
|
|
|
|
ASSIGN(_className, NSStringFromClass([super class]));
|
|
|
|
|
RETAIN(_className);
|
2002-10-13 06:03:10 +00:00
|
|
|
|
ASSIGN(_parentClassName, NSStringFromClass([super class]));
|
|
|
|
|
RETAIN(_parentClassName);
|
2002-10-08 06:30:13 +00:00
|
|
|
|
_buttonType = NSMomentaryLightButton;
|
|
|
|
|
[super initWithFrame: frame];
|
|
|
|
|
|
|
|
|
|
return self;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- init
|
|
|
|
|
{
|
|
|
|
|
// Start initially with the highest level class...
|
|
|
|
|
[super init];
|
|
|
|
|
ASSIGN(_className, NSStringFromClass([super class]));
|
|
|
|
|
RETAIN(_className);
|
2002-10-13 06:03:10 +00:00
|
|
|
|
ASSIGN(_parentClassName, NSStringFromClass([super class]));
|
|
|
|
|
RETAIN(_parentClassName);
|
2002-10-08 06:30:13 +00:00
|
|
|
|
_buttonType = NSMomentaryLightButton;
|
|
|
|
|
return self;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (id) initWithCoder: (NSCoder *)aCoder
|
|
|
|
|
{
|
|
|
|
|
[aCoder decodeValueOfObjCType: @encode(id) at: &_className];
|
2002-10-13 06:03:10 +00:00
|
|
|
|
[aCoder decodeValueOfObjCType: @encode(id) at: &_parentClassName];
|
2002-10-08 06:30:13 +00:00
|
|
|
|
[aCoder decodeValueOfObjCType: @encode(int) at: &_buttonType];
|
|
|
|
|
return [super initWithCoder: aCoder];
|
|
|
|
|
}
|
2002-10-06 23:59:30 +00:00
|
|
|
|
|
2002-10-08 06:30:13 +00:00
|
|
|
|
- (void) encodeWithCoder: (NSCoder *)aCoder
|
|
|
|
|
{
|
|
|
|
|
[aCoder encodeValueOfObjCType: @encode(id) at: &_className];
|
2002-10-13 06:03:10 +00:00
|
|
|
|
[aCoder encodeValueOfObjCType: @encode(id) at: &_parentClassName];
|
2002-10-08 06:30:13 +00:00
|
|
|
|
[aCoder encodeValueOfObjCType: @encode(int) at: &_buttonType];
|
|
|
|
|
[super encodeWithCoder: aCoder];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (id) awakeAfterUsingCoder: (NSCoder *)coder
|
|
|
|
|
{
|
|
|
|
|
return [self instantiateObject: coder];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (id) instantiateObject: (NSCoder *)coder
|
|
|
|
|
{
|
|
|
|
|
Class aClass = NSClassFromString(_className);
|
|
|
|
|
NSRect theFrame = [self frame];
|
|
|
|
|
id obj = nil;
|
|
|
|
|
|
|
|
|
|
if (aClass == nil)
|
2002-10-06 23:59:30 +00:00
|
|
|
|
{
|
2002-10-08 06:30:13 +00:00
|
|
|
|
[NSException raise: NSInternalInconsistencyException
|
|
|
|
|
format: @"Unable to find class '%@'", _className];
|
2002-10-06 23:59:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-10-08 06:30:13 +00:00
|
|
|
|
obj = [[aClass allocWithZone: NSDefaultMallocZone()]
|
|
|
|
|
initWithFrame: theFrame];
|
|
|
|
|
|
|
|
|
|
// set the attributes for the view
|
|
|
|
|
[obj setBounds: [self bounds]];
|
|
|
|
|
|
|
|
|
|
// set the attributes for the control
|
|
|
|
|
[obj setDoubleValue: [self doubleValue]];
|
|
|
|
|
[obj setFloatValue: [self floatValue]];
|
|
|
|
|
[obj setIntValue: [self intValue]];
|
|
|
|
|
[obj setObjectValue: [self objectValue]];
|
|
|
|
|
[obj setStringValue: [self stringValue]];
|
|
|
|
|
[obj setTag: [self tag]];
|
|
|
|
|
[obj setFont: [self font]];
|
|
|
|
|
[obj setAlignment: [self alignment]];
|
|
|
|
|
[obj setEnabled: [self isEnabled]];
|
|
|
|
|
[obj setContinuous: [self isContinuous]];
|
|
|
|
|
|
|
|
|
|
// button
|
|
|
|
|
[obj setButtonType: _buttonType];
|
|
|
|
|
[obj setBezelStyle: [self bezelStyle]];
|
|
|
|
|
[obj setBordered: [self isBordered]];
|
|
|
|
|
[obj setAllowsMixedState: [self allowsMixedState]];
|
|
|
|
|
[obj setTitle: [self title]];
|
|
|
|
|
[obj setAlternateTitle: [self alternateTitle]];
|
|
|
|
|
[obj setImage: [self image]];
|
|
|
|
|
[obj setAlternateImage: [self alternateImage]];
|
|
|
|
|
[obj setImagePosition: [self imagePosition]];
|
|
|
|
|
[obj setKeyEquivalent: [self keyEquivalent]];
|
|
|
|
|
|
2002-10-06 23:59:30 +00:00
|
|
|
|
RELEASE(self);
|
|
|
|
|
return obj;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// accessors
|
|
|
|
|
- (void) setClassName: (NSString *)name
|
|
|
|
|
{
|
|
|
|
|
ASSIGN(_className, name);
|
2002-11-18 06:00:26 +00:00
|
|
|
|
RETAIN(_className);
|
2002-10-06 23:59:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (NSString *)className
|
|
|
|
|
{
|
|
|
|
|
return _className;
|
|
|
|
|
}
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// This class uses the templates above to persist the correct type of
|
|
|
|
|
// custom object into the nib file.
|
|
|
|
|
@implementation GSClassSwapper
|
|
|
|
|
+ (void) initialize
|
|
|
|
|
{
|
|
|
|
|
if (self == [GSClassSwapper class])
|
|
|
|
|
{
|
|
|
|
|
[self setVersion: 0];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (id) init
|
|
|
|
|
{
|
|
|
|
|
_className = nil;
|
|
|
|
|
_template = nil;
|
|
|
|
|
return self;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (id) initWithCoder: (NSCoder *)aCoder
|
|
|
|
|
{
|
|
|
|
|
[aCoder decodeValueOfObjCType: @encode(id) at: &_className];
|
|
|
|
|
[aCoder decodeValueOfObjCType: @encode(id) at: &_template];
|
|
|
|
|
return self;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) encodeWithCoder: (NSCoder *)aCoder
|
|
|
|
|
{
|
|
|
|
|
[aCoder encodeValueOfObjCType: @encode(id) at: &_className];
|
|
|
|
|
[aCoder encodeValueOfObjCType: @encode(id) at: &_template];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) dealloc
|
|
|
|
|
{
|
|
|
|
|
RELEASE(_className);
|
|
|
|
|
RELEASE(_template);
|
|
|
|
|
[super dealloc];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (NSString *) className
|
|
|
|
|
{
|
|
|
|
|
return _className;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) setClassName: (NSString *)name
|
|
|
|
|
{
|
|
|
|
|
ASSIGN(_className, name);
|
2002-11-18 06:00:26 +00:00
|
|
|
|
RETAIN(_className);
|
2002-10-06 23:59:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (id) template
|
|
|
|
|
{
|
|
|
|
|
return _template;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) setTemplate: (id)template
|
|
|
|
|
{
|
|
|
|
|
ASSIGN(_template, template);
|
|
|
|
|
}
|
|
|
|
|
@end
|
2002-12-29 05:38:29 +00:00
|
|
|
|
|
|
|
|
|
// Font proxy...
|
|
|
|
|
@implementation GSFontProxy
|
|
|
|
|
- (id) initWithCoder: (NSCoder *)aDecoder
|
|
|
|
|
{
|
|
|
|
|
id result = [super initWithCoder: aDecoder];
|
|
|
|
|
NSDebugLog(@"Inside font proxy...");
|
|
|
|
|
if(result == nil)
|
|
|
|
|
{
|
|
|
|
|
NSDebugLog(@"Couldn't find the font specified, so supply a system font instead.");
|
|
|
|
|
result = [NSFont systemFontOfSize: [NSFont systemFontSize]];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
|
|
// String proxy for dynamic translation...
|
|
|
|
|
/*
|
|
|
|
|
@implementation GSStringProxy
|
|
|
|
|
- (id) initWithCoder: (NSCoder *)aDecoder
|
|
|
|
|
{
|
|
|
|
|
id result = [[NSString alloc] initWithCoder: aDecoder];
|
|
|
|
|
NSLog(@"Do your translation here... %@", result);
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
@end
|
|
|
|
|
*/
|
|
|
|
|
// end of NSBundleAdditions...
|