2008-12-02 07:05:19 +00:00
/ * * < title > GSGormLoading < / title >
2003-08-23 01:03:40 +00:00
< abstract > Contains all of the private classes used in . gorm files . < / abstract >
Copyright ( C ) 2003 Free Software Foundation , Inc .
Author : Gregory John Casamento
Date : July 2003.
2023-11-27 07:26:16 +00:00
2003-08-23 01:03:40 +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-08-23 01:03:40 +00:00
License as published by the Free Software Foundation ; either
2008-06-10 04:01:49 +00:00
version 2 of the License , or ( at your option ) any later version .
2007-10-29 21:16:17 +00:00
2003-08-23 01:03:40 +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-08-23 01:03:40 +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 .
2023-11-27 07:26:16 +00:00
If not , see < http : // www . gnu . org / licenses / > or write to the
Free Software Foundation , 51 Franklin Street , Fifth Floor ,
2007-10-29 21:16:17 +00:00
Boston , MA 02110 -1301 , USA .
2023-11-27 07:26:16 +00:00
* /
2003-08-23 01:03:40 +00:00
2010-02-20 13:21:57 +00:00
# import < Foundation / NSCoder . h >
# import < Foundation / NSDictionary . h >
# import < Foundation / NSDebug . h >
# import < Foundation / NSException . h >
# import < Foundation / NSString . h >
# import < Foundation / NSKeyValueCoding . h >
# import < Foundation / NSNotification . h >
# import < Foundation / NSArchiver . h >
2010-02-24 11:53:53 +00:00
# import < Foundation / NSSet . h >
2010-02-20 13:21:57 +00:00
# import "AppKit/NSApplication.h"
# import "AppKit/NSControl.h"
# import "AppKit/NSMenu.h"
2010-03-28 21:33:08 +00:00
# import "AppKit/NSNib.h"
2010-02-20 13:21:57 +00:00
# import "AppKit/NSNibLoading.h"
# import "AppKit/NSNibConnector.h"
2010-02-24 11:53:53 +00:00
# import "AppKit/NSScreen.h"
2010-02-20 13:21:57 +00:00
# import "AppKit/NSTextView.h"
# import "AppKit/NSView.h"
# import "AppKit/NSWindow.h"
# import "GNUstepGUI/GSGormLoading.h"
2010-05-14 19:20:45 +00:00
# import "NSDocumentFrameworkPrivate.h"
2003-08-23 01:03:40 +00:00
static const int currentVersion = 1 ; // GSNibItem version number . . .
2004-08-28 14:41:16 +00:00
@ interface NSObject ( GSNibPrivateMethods )
- ( BOOL ) isInInterfaceBuilder ;
@ end
2004-06-29 03:04:28 +00:00
/ *
2023-11-27 07:26:16 +00:00
* This private class is used to collect the nib items while the
2004-06-29 03:04:28 +00:00
* . gorm file is being unarchived . This is done to allow only
* the top level items to be retained in a clean way . The reason it ' s
* being done this way is because old . gorm files don ' t have any
* array within the nameTable which indicates the objects which are
* considered top level , so there is no clean and generic way to determine
* this . Basically the top level items are any instances of or instances
* of subclasses of NSMenu , NSWindow , or any controller class .
* It ' s the last one that ' s hairy . Controller classes are
* represented in . gorm files by the GSNibItem class , but once they transform
2023-11-27 07:26:16 +00:00
* into the actual class instance it ' s not easy to tell if it should be
2004-06-29 03:04:28 +00:00
* retained or not since there are a lot of other things stored in the nameTable
* as well . GJC
* /
static NSString * GSInternalNibItemAddedNotification = @ "_GSInternalNibItemAddedNotification" ;
@ interface GSNibItemCollector : NSObject
{
NSMutableArray * items ;
}
- ( void ) handleNotification : ( NSNotification * ) notification ;
- ( NSMutableArray * ) items ;
@ end
@ implementation GSNibItemCollector
- ( void ) handleNotification : ( NSNotification * ) notification ;
{
id obj = [ notification object ] ;
[ items addObject : obj ] ;
}
- init
{
2005-11-16 11:34:25 +00:00
if ( ( self = [ super init ] ) ! = nil )
2004-06-29 03:04:28 +00:00
{
NSNotificationCenter * nc = [ NSNotificationCenter defaultCenter ] ;
// add myself as an observer and initialize the items array .
[ nc addObserver : self
selector : @ selector ( handleNotification : )
2023-11-27 07:26:16 +00:00
name : GSInternalNibItemAddedNotification
2004-06-29 03:04:28 +00:00
object : nil ] ;
items = [ [ NSMutableArray alloc ] init ] ;
}
return self ;
}
- ( void ) dealloc
{
[ [ NSNotificationCenter defaultCenter ] removeObserver : self ] ;
RELEASE ( items ) ;
[ super dealloc ] ;
}
- ( NSMutableArray * ) items
{
return items ;
}
@ end
2003-08-23 01:03:40 +00:00
/ *
* The GSNibContainer class manages the internals of a nib file .
* /
@ implementation GSNibContainer
+ ( void ) initialize
{
if ( self = = [ GSNibContainer class ] )
{
[ self setVersion : GNUSTEP_NIB _VERSION ] ;
}
}
2003-12-30 05:45:40 +00:00
- ( void ) awakeWithContext : ( NSDictionary * ) context
2003-08-23 01:03:40 +00:00
{
2004-06-29 03:04:28 +00:00
if ( isAwake = = NO )
2003-08-23 01:03:40 +00:00
{
NSEnumerator * enumerator ;
NSNibConnector * connection ;
NSString * key ;
NSMenu * menu ;
2023-11-27 07:26:16 +00:00
NSMutableArray * topObjects ;
2003-12-23 18:45:18 +00:00
id obj ;
2003-08-23 01:03:40 +00:00
2010-03-22 21:25:35 +00:00
// Add these objects with there old names as the code expects them
context = AUTORELEASE ( [ context mutableCopyWithZone : [ context zone ] ] ) ;
2004-06-29 03:04:28 +00:00
isAwake = YES ;
2003-08-23 01:03:40 +00:00
/ *
* 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 ] ;
}
2003-09-01 09:21:46 +00:00
/ *
2023-11-27 07:26:16 +00:00
* See if there is a main menu to be set . Report #4815 , mainMenu
2003-09-01 09:21:46 +00:00
* should be initialized before awakeFromNib is called .
* /
menu = [ nameTable objectForKey : @ "NSMenu" ] ;
if ( menu ! = nil && [ menu isKindOfClass : [ NSMenu class ] ] = = YES )
{
[ NSApp setMainMenu : menu ] ;
}
2003-09-28 23:25:16 +00:00
/ *
* Set the Services menu .
* Report #5205 , Services / Window menu does not behave correctly .
* /
menu = [ nameTable objectForKey : @ "NSServicesMenu" ] ;
if ( menu ! = nil && [ menu isKindOfClass : [ NSMenu class ] ] = = YES )
{
[ NSApp setServicesMenu : menu ] ;
}
/ *
* Set the Services menu .
* Report #5205 , Services / Window menu does not behave correctly .
* /
menu = [ nameTable objectForKey : @ "NSWindowsMenu" ] ;
if ( menu ! = nil && [ menu isKindOfClass : [ NSMenu class ] ] = = YES )
{
[ NSApp setWindowsMenu : menu ] ;
}
2010-05-14 19:20:45 +00:00
/ *
* Set the Recent Documents menu .
* /
menu = [ nameTable objectForKey : @ "NSRecentDocumentsMenu" ] ;
if ( menu ! = nil && [ menu isKindOfClass : [ NSMenu class ] ] = = YES )
{
[ [ NSDocumentController sharedDocumentController ]
_setRecentDocumentsMenu : menu ] ;
}
2004-06-29 03:04:28 +00:00
2023-11-27 07:26:16 +00:00
/ *
2010-03-28 21:33:08 +00:00
* See if the user has passed in the NSNibTopLevelObjects key .
* This is an implementation of a commonly used feature to give access to
2023-11-27 07:26:16 +00:00
* all top level objects of a gorm file .
2003-12-23 18:45:18 +00:00
* /
2010-03-28 21:33:08 +00:00
obj = [ context objectForKey : NSNibTopLevelObjects ] ;
2005-11-16 11:34:25 +00:00
if ( [ obj isKindOfClass : [ NSMutableArray class ] ] )
2003-12-23 18:45:18 +00:00
{
2004-06-29 03:04:28 +00:00
topObjects = obj ;
2003-12-23 18:45:18 +00:00
}
else
{
2023-11-27 07:26:16 +00:00
topObjects = nil ;
2003-12-23 18:45:18 +00:00
}
2004-06-29 03:04:28 +00:00
2003-12-23 18:45:18 +00:00
/ *
2004-06-29 03:04:28 +00:00
* Now tell all the objects that they have been loaded from
2023-11-27 07:26:16 +00:00
* a gorm model .
2003-12-23 18:45:18 +00:00
* /
enumerator = [ nameTable keyEnumerator ] ;
while ( ( key = [ enumerator nextObject ] ) ! = nil )
{
2023-11-27 07:26:16 +00:00
if ( [ context objectForKey : key ] = = nil ||
2010-03-28 21:33:08 +00:00
[ key isEqualToString : NSNibOwner ] ) // we want to send the message to the owner
2003-12-23 18:45:18 +00:00
{
2023-11-27 07:26:16 +00:00
// we don ' t want to send a message to these menus twice , if they ' re custom classes .
if ( [ key isEqualToString : @ "NSWindowsMenu" ] = = NO &&
[ key isEqualToString : @ "NSServicesMenu" ] = = NO &&
2010-03-28 21:33:08 +00:00
[ key isEqualToString : NSNibTopLevelObjects ] = = NO )
2003-12-23 18:45:18 +00:00
{
2004-06-29 03:04:28 +00:00
id o = [ nameTable objectForKey : key ] ;
2023-11-27 07:26:16 +00:00
// send the awake message , every object should respond to this message since
// it is defined on NSObject ( NSNibAwaking )
[ o awakeFromNib ] ;
// Call prepareForInteraceBuilder if we are in IB / Gorm .
if ( [ self respondsToSelector : @ selector ( isInInterfaceBuilder ) ] )
2003-12-23 18:45:18 +00:00
{
2023-11-27 07:26:16 +00:00
if ( [ self isInInterfaceBuilder ] = = YES )
{
// All objects should respond to this as it is defined on
// NSObject ( NSNibAwaking )
[ o prepareForInterfaceBuilder ] ;
}
2003-12-23 18:45:18 +00:00
}
2004-06-29 03:04:28 +00:00
/ *
2023-11-27 07:26:16 +00:00
* Retain all "top level" items so that , when the container
* is released , they will remain . The GSNibItems instantiated in the gorm need
* to be retained , since we are deallocating the container .
2004-07-18 16:04:39 +00:00
* We don ' t want to retain the owner .
*
2023-11-27 07:26:16 +00:00
* Please note : It is encumbent upon the developer of an application to
* release these objects . Instantiating a window manually or loading in a . gorm
* file are equivalent processes . These objects need to be released in their
* respective controllers . If the developer has used the NSNibTopLevelObjects feature ,
* then she will get the objects back in an array . She will will have to first release
* all the objects in the array and then the array itself in order to release the
* objects held within .
2004-06-29 03:04:28 +00:00
* /
2010-03-28 21:33:08 +00:00
if ( [ key isEqualToString : NSNibOwner ] = = NO )
2003-12-23 18:45:18 +00:00
{
2005-11-16 11:34:25 +00:00
if ( [ topLevelObjects containsObject : o ] ) // anything already designated a top level item . .
2004-06-29 03:04:28 +00:00
{
2010-03-28 21:33:08 +00:00
[ topObjects addObject : o ] ;
2010-03-30 07:09:44 +00:00
// All top level objects must be released by the
// caller to avoid leaking , unless they are going
2023-11-27 07:26:16 +00:00
// to be released by other gorm objects on behalf
2010-03-30 07:09:44 +00:00
// of the owner .
2010-03-28 21:33:08 +00:00
RETAIN ( o ) ;
2004-06-29 03:04:28 +00:00
}
2003-12-23 18:45:18 +00:00
}
}
}
}
2023-11-27 07:26:16 +00:00
2003-08-23 01:03:40 +00:00
/ *
* See if there are objects that should be made visible .
2004-06-29 03:04:28 +00:00
* This is the last thing we should do since changes might be made
* in the awakeFromNib methods which are called on all of the objects .
2003-08-23 01:03:40 +00:00
* /
2006-07-09 14:54:51 +00:00
if ( visibleWindows ! = nil )
2003-08-23 01:03:40 +00:00
{
2006-07-09 14:54:51 +00:00
unsigned pos = [ visibleWindows count ] ;
2003-08-23 01:03:40 +00:00
while ( pos - - > 0 )
{
2006-07-09 14:54:51 +00:00
NSWindow * win = [ visibleWindows objectAtIndex : pos ] ;
2011-02-10 06:40:35 +00:00
[ win orderFront : self ] ;
2003-08-23 01:03:40 +00:00
}
}
/ *
* Now remove any objects added from the context dictionary .
* /
if ( [ context count ] > 0 )
{
[ nameTable removeObjectsForKeys : [ context allKeys ] ] ;
}
}
}
- ( void ) dealloc
{
RELEASE ( nameTable ) ;
RELEASE ( connections ) ;
2004-06-29 03:04:28 +00:00
RELEASE ( topLevelObjects ) ;
2006-07-09 14:54:51 +00:00
RELEASE ( visibleWindows ) ;
RELEASE ( deferredWindows ) ;
RELEASE ( customClasses ) ;
2003-08-23 01:03:40 +00:00
[ super dealloc ] ;
}
2006-07-09 14:54:51 +00:00
- ( id ) init
{
if ( ( self = [ super init ] ) ! = nil )
{
nameTable = [ [ NSMutableDictionary alloc ] initWithCapacity : 8 ] ;
connections = [ [ NSMutableArray alloc ] initWithCapacity : 8 ] ;
topLevelObjects = [ [ NSMutableSet alloc ] initWithCapacity : 8 ] ;
customClasses = [ [ NSMutableDictionary alloc ] initWithCapacity : 8 ] ;
deferredWindows = [ [ NSMutableArray alloc ] initWithCapacity : 8 ] ;
visibleWindows = [ [ NSMutableArray alloc ] initWithCapacity : 8 ] ;
}
return self ;
}
2003-08-23 01:03:40 +00:00
- ( void ) encodeWithCoder : ( NSCoder * ) aCoder
{
2004-07-12 03:27:36 +00:00
int version = [ GSNibContainer version ] ;
2005-11-16 11:34:25 +00:00
if ( version = = GNUSTEP_NIB _VERSION )
2004-07-12 03:27:36 +00:00
{
2006-07-09 14:54:51 +00:00
[ aCoder encodeObject : topLevelObjects ] ;
[ aCoder encodeObject : visibleWindows ] ;
[ aCoder encodeObject : deferredWindows ] ;
2004-07-12 03:27:36 +00:00
[ aCoder encodeObject : nameTable ] ;
[ aCoder encodeObject : connections ] ;
2006-07-09 14:54:51 +00:00
[ aCoder encodeObject : customClasses ] ;
}
else if ( version = = 1 )
{
NSMutableDictionary * nt = [ NSMutableDictionary dictionaryWithDictionary : nameTable ] ;
2023-11-27 07:26:16 +00:00
[ nt setObject : [ NSMutableArray arrayWithArray : visibleWindows ]
2006-07-09 14:54:51 +00:00
forKey : @ "NSVisible" ] ;
2023-11-27 07:26:16 +00:00
[ nt setObject : [ NSMutableArray arrayWithArray : deferredWindows ]
2006-07-09 14:54:51 +00:00
forKey : @ "NSDeferred" ] ;
2023-11-27 07:26:16 +00:00
[ nt setObject : [ NSMutableDictionary dictionaryWithDictionary : customClasses ]
2006-07-09 14:54:51 +00:00
forKey : @ "GSCustomClassMap" ] ;
[ aCoder encodeObject : nt ] ;
[ aCoder encodeObject : connections ] ;
2004-07-12 03:27:36 +00:00
[ aCoder encodeObject : topLevelObjects ] ;
}
2006-07-09 14:54:51 +00:00
else if ( version = = 0 )
2004-07-12 03:27:36 +00:00
{
2006-07-09 14:54:51 +00:00
NSMutableDictionary * nt = [ NSMutableDictionary dictionaryWithDictionary : nameTable ] ;
2023-11-27 07:26:16 +00:00
[ nt setObject : [ NSMutableArray arrayWithArray : visibleWindows ]
2006-07-09 14:54:51 +00:00
forKey : @ "NSVisible" ] ;
2023-11-27 07:26:16 +00:00
[ nt setObject : [ NSMutableArray arrayWithArray : deferredWindows ]
2006-07-09 14:54:51 +00:00
forKey : @ "NSDeferred" ] ;
2023-11-27 07:26:16 +00:00
[ nt setObject : [ NSMutableDictionary dictionaryWithDictionary : customClasses ]
2006-07-09 14:54:51 +00:00
forKey : @ "GSCustomClassMap" ] ;
[ aCoder encodeObject : nt ] ;
2004-07-12 03:27:36 +00:00
[ aCoder encodeObject : connections ] ;
}
2006-07-09 14:54:51 +00:00
else
2003-08-23 01:03:40 +00:00
{
2006-07-09 14:54:51 +00:00
[ NSException raise : NSInternalInconsistencyException
format : @ "Unable to write GSNibContainer version #%d. GSNibContainer version for the installed gui lib is %d." , version , GNUSTEP_NIB _VERSION ] ;
2003-08-23 01:03:40 +00:00
}
}
- ( id ) initWithCoder : ( NSCoder * ) aCoder
{
2023-11-27 07:26:16 +00:00
int version = [ aCoder versionForClassName : @ "GSNibContainer" ] ;
2004-06-29 03:04:28 +00:00
// save the version to the ivar , we need it later .
2005-11-16 11:34:25 +00:00
if ( version = = GNUSTEP_NIB _VERSION )
2006-07-09 14:54:51 +00:00
{
[ aCoder decodeValueOfObjCType : @ encode ( id ) at : & topLevelObjects ] ;
[ aCoder decodeValueOfObjCType : @ encode ( id ) at : & visibleWindows ] ;
[ aCoder decodeValueOfObjCType : @ encode ( id ) at : & deferredWindows ] ;
[ aCoder decodeValueOfObjCType : @ encode ( id ) at : & nameTable ] ;
[ aCoder decodeValueOfObjCType : @ encode ( id ) at : & connections ] ;
[ aCoder decodeValueOfObjCType : @ encode ( id ) at : & customClasses ] ;
}
else if ( version = = 1 )
2003-08-23 01:03:40 +00:00
{
[ aCoder decodeValueOfObjCType : @ encode ( id ) at : & nameTable ] ;
[ aCoder decodeValueOfObjCType : @ encode ( id ) at : & connections ] ;
2004-06-29 03:04:28 +00:00
[ aCoder decodeValueOfObjCType : @ encode ( id ) at : & topLevelObjects ] ;
2006-07-09 14:54:51 +00:00
// initialize with special entries . . .
2023-11-27 07:26:16 +00:00
ASSIGN ( visibleWindows , [ NSMutableArray arrayWithArray :
2006-07-09 14:54:51 +00:00
[ nameTable objectForKey : @ "NSVisible" ] ] ) ;
2023-11-27 07:26:16 +00:00
ASSIGN ( deferredWindows , [ NSMutableArray arrayWithArray :
2006-07-09 14:54:51 +00:00
[ nameTable objectForKey : @ "NSDeferred" ] ] ) ;
2023-11-27 07:26:16 +00:00
ASSIGN ( customClasses , [ NSMutableDictionary dictionaryWithDictionary :
2006-07-09 14:54:51 +00:00
[ nameTable objectForKey : @ "GSCustomClassMap" ] ] ) ;
// then remove them from the name table .
[ nameTable removeObjectForKey : @ "NSVisible" ] ;
[ nameTable removeObjectForKey : @ "NSDeferred" ] ;
[ nameTable removeObjectForKey : @ "GSCustomClassMap" ] ;
2004-06-29 03:04:28 +00:00
}
2005-11-16 11:34:25 +00:00
else if ( version = = 0 )
2004-06-29 03:04:28 +00:00
{
GSNibItemCollector * nibitems = [ [ GSNibItemCollector alloc ] init ] ;
NSEnumerator * en ;
NSString * key ;
2023-11-27 07:26:16 +00:00
2004-06-29 03:04:28 +00:00
// initialize the set of top level objects . . .
topLevelObjects = [ [ NSMutableSet alloc ] initWithCapacity : 8 ] ;
// unarchive . . .
[ aCoder decodeValueOfObjCType : @ encode ( id ) at : & nameTable ] ;
[ aCoder decodeValueOfObjCType : @ encode ( id ) at : & connections ] ;
[ topLevelObjects addObjectsFromArray : [ nibitems items ] ] ; // get the top level items here . . .
RELEASE ( nibitems ) ;
// iterate through the objects returned
en = [ nameTable keyEnumerator ] ;
2005-11-16 11:34:25 +00:00
while ( ( key = [ en nextObject ] ) ! = nil )
2004-06-29 03:04:28 +00:00
{
id o = [ nameTable objectForKey : key ] ;
2005-11-16 11:34:25 +00:00
if ( ( [ o isKindOfClass : [ NSMenu class ] ] && [ key isEqual : @ "NSMenu" ] ) ||
2004-06-29 03:04:28 +00:00
[ o isKindOfClass : [ NSWindow class ] ] )
{
[ topLevelObjects addObject : o ] ; // if it ' s a top level object , add it .
}
}
2006-07-09 14:54:51 +00:00
// initialize with special entries . . .
2023-11-27 07:26:16 +00:00
ASSIGN ( visibleWindows , [ NSMutableArray arrayWithArray :
2006-07-09 14:54:51 +00:00
[ nameTable objectForKey : @ "NSVisible" ] ] ) ;
2023-11-27 07:26:16 +00:00
ASSIGN ( deferredWindows , [ NSMutableArray arrayWithArray :
2006-07-09 14:54:51 +00:00
[ nameTable objectForKey : @ "NSDeferred" ] ] ) ;
2023-11-27 07:26:16 +00:00
ASSIGN ( customClasses , [ NSMutableDictionary dictionaryWithDictionary :
2006-07-09 14:54:51 +00:00
[ nameTable objectForKey : @ "GSCustomClassMap" ] ] ) ;
// then remove them from the name table .
[ nameTable removeObjectForKey : @ "NSVisible" ] ;
[ nameTable removeObjectForKey : @ "NSDeferred" ] ;
[ nameTable removeObjectForKey : @ "GSCustomClassMap" ] ;
2004-06-29 03:04:28 +00:00
}
else
{
[ NSException raise : NSInternalInconsistencyException
2006-07-19 03:16:49 +00:00
format : @ "Unable to read GSNibContainer version #%d. GSNibContainer version for the installed gui lib is %d. Please upgrade to a more recent version of the gui library." , version , GNUSTEP_NIB _VERSION ] ;
2003-08-23 01:03:40 +00:00
}
return self ;
}
- ( NSMutableDictionary * ) nameTable
{
return nameTable ;
}
2004-06-29 03:04:28 +00:00
- ( NSMutableSet * ) topLevelObjects
{
return topLevelObjects ;
}
2006-06-08 04:04:17 +00:00
- ( NSMutableArray * ) connections
{
return connections ;
}
2006-07-09 14:54:51 +00:00
- ( NSMutableArray * ) visibleWindows
{
return visibleWindows ;
}
- ( NSMutableArray * ) deferredWindows
{
2008-04-25 22:18:34 +00:00
return deferredWindows ;
2006-07-09 14:54:51 +00:00
}
- ( NSMutableDictionary * ) customClasses
{
return customClasses ;
}
2003-08-23 01:03:40 +00:00
@ end
// The first standin objects here are for views and normal objects like controllers
// or data sources .
@ implementation GSNibItem
+ ( void ) initialize
{
if ( self = = [ GSNibItem class ] )
{
[ self setVersion : currentVersion ] ;
}
}
- ( void ) dealloc
{
RELEASE ( theClass ) ;
[ super dealloc ] ;
}
- ( void ) encodeWithCoder : ( NSCoder * ) aCoder
{
[ aCoder encodeObject : theClass ] ;
[ aCoder encodeRect : theFrame ] ;
2023-11-27 07:26:16 +00:00
[ aCoder encodeValueOfObjCType : @ encode ( unsigned int )
2003-08-23 01:03:40 +00:00
at : & autoresizingMask ] ;
}
- ( id ) initWithCoder : ( NSCoder * ) aCoder
{
2023-11-27 07:26:16 +00:00
int version = [ aCoder versionForClassName :
2003-08-23 01:03:40 +00:00
NSStringFromClass ( [ self class ] ) ] ;
2003-12-30 05:45:40 +00:00
id obj = nil ;
2003-08-23 01:03:40 +00:00
if ( version = = 1 )
{
Class cls ;
unsigned int mask ;
2023-11-27 07:26:16 +00:00
2003-08-23 01:03:40 +00:00
[ aCoder decodeValueOfObjCType : @ encode ( id ) at : & theClass ] ;
theFrame = [ aCoder decodeRect ] ;
2023-11-27 07:26:16 +00:00
[ aCoder decodeValueOfObjCType : @ encode ( unsigned int )
2003-08-23 01:03:40 +00:00
at : & mask ] ;
2023-11-27 07:26:16 +00:00
2003-08-23 01:03:40 +00:00
cls = NSClassFromString ( theClass ) ;
if ( cls = = nil )
{
[ NSException raise : NSInternalInconsistencyException
2004-06-29 03:04:28 +00:00
format : @ "Unable to find class '%@', it is not linked into the application." , theClass ] ;
2003-08-23 01:03:40 +00:00
}
2023-11-27 07:26:16 +00:00
2003-08-23 01:03:40 +00:00
if ( theFrame . size . height > 0 && theFrame . size . width > 0 )
2003-12-29 05:38:46 +00:00
{
2008-12-10 04:22:05 +00:00
obj = [ [ cls allocWithZone : [ self zone ] ] initWithFrame : theFrame ] ;
2003-12-29 05:38:46 +00:00
}
2003-08-23 01:03:40 +00:00
else
2003-12-29 05:38:46 +00:00
{
2008-12-10 04:22:05 +00:00
if ( GSObjCIsKindOf ( cls , [ NSApplication class ] ) )
{
2011-03-06 22:58:56 +00:00
obj = RETAIN ( [ cls sharedApplication ] ) ;
2008-12-10 04:22:05 +00:00
}
else
{
obj = [ [ cls allocWithZone : [ self zone ] ] init ] ;
2023-11-27 07:26:16 +00:00
}
2003-12-29 05:38:46 +00:00
}
2003-08-23 01:03:40 +00:00
if ( [ obj respondsToSelector : @ selector ( setAutoresizingMask : ) ] )
{
[ obj setAutoresizingMask : mask ] ;
}
}
else if ( version = = 0 )
{
Class cls ;
2023-11-27 07:26:16 +00:00
2003-08-23 01:03:40 +00:00
[ aCoder decodeValueOfObjCType : @ encode ( id ) at : & theClass ] ;
theFrame = [ aCoder decodeRect ] ;
2023-11-27 07:26:16 +00:00
2003-08-23 01:03:40 +00:00
cls = NSClassFromString ( theClass ) ;
if ( cls = = nil )
{
[ NSException raise : NSInternalInconsistencyException
2004-06-29 03:04:28 +00:00
format : @ "Unable to find class '%@', it is not linked into the application." , theClass ] ;
2003-08-23 01:03:40 +00:00
}
2023-11-27 07:26:16 +00:00
2003-08-23 01:03:40 +00:00
obj = [ cls allocWithZone : [ self zone ] ] ;
if ( theFrame . size . height > 0 && theFrame . size . width > 0 )
2003-12-29 05:38:46 +00:00
{
obj = [ obj initWithFrame : theFrame ] ;
}
2003-08-23 01:03:40 +00:00
else
2003-12-29 05:38:46 +00:00
{
obj = [ obj init ] ;
}
2003-08-23 01:03:40 +00:00
}
else
{
NSLog ( @ "no initWithCoder for this version" ) ;
}
2003-12-30 05:45:40 +00:00
// If this is a nib item and not a custom view , then we need to add it to
2004-06-29 03:04:28 +00:00
// the set of things to be retained . Also , the initial version of the nib container
// needed this code , but subsequent versions don ' t , so don ' t send the notification ,
// if the version isn ' t zero .
2005-11-16 11:34:25 +00:00
if ( obj ! = nil && [ aCoder versionForClassName : NSStringFromClass ( [ GSNibContainer class ] ) ] = = 0 )
2003-12-30 05:45:40 +00:00
{
2005-11-16 11:34:25 +00:00
if ( [ self isKindOfClass : [ GSNibItem class ] ] = = YES &&
2003-12-30 05:45:40 +00:00
[ self isKindOfClass : [ GSCustomView class ] ] = = NO )
{
NSNotificationCenter * nc = [ NSNotificationCenter defaultCenter ] ;
2004-06-29 03:04:28 +00:00
[ nc postNotificationName : GSInternalNibItemAddedNotification
2003-12-30 05:45:40 +00:00
object : obj ] ;
}
}
// release self and return the object this represents . . .
RELEASE ( self ) ;
return obj ;
2003-08-23 01:03:40 +00:00
}
@ end
@ implementation GSCustomView
+ ( void ) initialize
{
if ( self = = [ GSCustomView class ] )
{
[ self setVersion : currentVersion ] ;
}
}
- ( void ) encodeWithCoder : ( NSCoder * ) aCoder
{
[ super encodeWithCoder : aCoder ] ;
}
- ( id ) initWithCoder : ( NSCoder * ) aCoder
{
return [ super initWithCoder : aCoder ] ;
}
@ end
/ *
These stand - ins are here for use by GUI elements within Gorm . Since each gui element
has it ' s own "designated initializer" it ' s important to provide a division between these
2023-11-27 07:26:16 +00:00
so that when they are loaded , the application will call the correct initializer .
2003-08-23 01:03:40 +00:00
Some "tricks" are employed in this code . For instance the use of initWithCoder and
encodeWithCoder directly as opposed to using the encodeObjC . . methods is the obvious
standout . To understand this it ' s necessary to explain a little about how encoding itself
works .
2023-11-27 07:26:16 +00:00
When the model is saved by the Interface Builder ( whether Gorm or another
2003-08-23 01:03:40 +00:00
IB equivalent ) these classes should be used to substitute for the actual classes . The actual
classes are encoded as part of it , but since they are being replaced we can ' t use the normal
encode methods to do it and must encode it directly .
Also , the reason for encoding the superclass itself is that by doing so the unarchiver knows
what version is referred to by the encoded object . This way we can replace the object with
a substitute class which will allow it to create itself as the custom class when read it by
the application , and using the encoding system to do it in a clean way .
* /
@ implementation GSClassSwapper
+ ( void ) initialize
{
2023-11-27 07:26:16 +00:00
if ( self = = [ GSClassSwapper class ] )
{
2003-08-23 01:03:40 +00:00
[ self setVersion : GSSWAPPER_VERSION ] ;
}
}
- ( id ) initWithObject : ( id ) object className : ( NSString * ) className superClassName : ( NSString * ) superClassName
{
2005-11-16 11:34:25 +00:00
if ( ( self = [ self init ] ) ! = nil )
2003-08-23 01:03:40 +00:00
{
2003-08-24 17:22:11 +00:00
NSDebugLog ( @ "Created template %@ -> %@" , NSStringFromClass ( [ self class ] ) , className ) ;
2003-08-23 01:03:40 +00:00
ASSIGN ( _object , object ) ;
2005-04-11 14:30:27 +00:00
ASSIGN ( _className , className ) ;
2003-08-23 01:03:40 +00:00
_superClass = NSClassFromString ( superClassName ) ;
2005-11-16 11:34:25 +00:00
if ( _superClass = = nil )
2003-08-23 01:03:40 +00:00
{
[ NSException raise : NSInternalInconsistencyException
2004-06-29 03:04:28 +00:00
format : @ "Unable to find class '%@', it is not linked into the application." , superClassName ] ;
2003-08-23 01:03:40 +00:00
}
}
return self ;
}
- init
{
2005-11-16 11:34:25 +00:00
if ( ( self = [ super init ] ) ! = nil )
2003-08-23 01:03:40 +00:00
{
_className = nil ;
_superClass = nil ;
_object = nil ;
2023-11-27 07:26:16 +00:00
}
2003-08-23 01:03:40 +00:00
return self ;
}
2005-04-11 14:30:27 +00:00
- ( void ) dealloc
{
RELEASE ( _object ) ;
RELEASE ( _className ) ;
[ super dealloc ] ;
}
2003-08-23 01:03:40 +00:00
- ( void ) setClassName : ( NSString * ) name
{
2005-06-04 11:35:22 +00:00
ASSIGN ( _className , name ) ;
2003-08-23 01:03:40 +00:00
}
- ( NSString * ) className
{
return _className ;
}
- ( id ) initWithCoder : ( NSCoder * ) coder
{
id obj = nil ;
int version = [ coder versionForClassName : @ "GSClassSwapper" ] ;
2005-11-16 11:34:25 +00:00
if ( version = = 0 )
2003-08-23 01:03:40 +00:00
{
2005-11-16 11:34:25 +00:00
if ( ( self = [ super init ] ) ! = nil )
2003-08-23 01:03:40 +00:00
{
2004-01-10 23:46:59 +00:00
NSUnarchiver * unarchiver = ( NSUnarchiver * ) coder ;
2003-08-23 01:03:40 +00:00
// decode class / superclass . . .
2023-11-27 07:26:16 +00:00
[ coder decodeValueOfObjCType : @ encode ( id ) at : & _className ] ;
2003-08-23 01:03:40 +00:00
[ coder decodeValueOfObjCType : @ encode ( Class ) at : & _superClass ] ;
2023-11-27 07:26:16 +00:00
// if we are living within the interface builder app , then don ' t try to
2003-08-23 01:03:40 +00:00
// morph into the subclass .
2005-11-16 11:34:25 +00:00
if ( [ self shouldSwapClass ] )
2003-08-23 01:03:40 +00:00
{
Class aClass = NSClassFromString ( _className ) ;
2005-11-16 11:34:25 +00:00
if ( aClass = = nil )
2003-08-23 01:03:40 +00:00
{
[ NSException raise : NSInternalInconsistencyException
2004-06-29 03:04:28 +00:00
format : @ "Unable to find class '%@', it is not linked into the application." , _className ] ;
2003-08-23 01:03:40 +00:00
}
2023-11-27 07:26:16 +00:00
// Initialize the object . . . dont call decode , since this wont
// allow us to instantiate the class we want .
2004-01-10 23:46:59 +00:00
obj = [ aClass alloc ] ;
2003-08-23 01:03:40 +00:00
}
2004-08-28 14:41:16 +00:00
else
{
obj = [ _superClass alloc ] ;
}
2004-01-10 23:46:59 +00:00
// inform the coder that this object is to replace the template in all cases .
[ unarchiver replaceObject : self withObject : obj ] ;
2023-11-27 07:26:16 +00:00
obj = [ obj initWithCoder : coder ] ; // unarchive the object . . .
2003-08-23 01:03:40 +00:00
}
}
// change the class of the instance to the one we want to see . . .
return obj ;
}
- ( void ) encodeWithCoder : ( NSCoder * ) aCoder
{
2023-11-27 07:26:16 +00:00
[ aCoder encodeValueOfObjCType : @ encode ( id ) at : & _className ] ;
2003-08-23 01:03:40 +00:00
[ aCoder encodeValueOfObjCType : @ encode ( Class ) at : & _superClass ] ;
2005-11-16 11:34:25 +00:00
if ( _object ! = nil )
2003-08-23 01:03:40 +00:00
{
// Don ' t call encodeValue , the way templates are used will prevent
// it from being saved correctly . Just call encodeWithCoder directly .
2023-11-27 07:26:16 +00:00
[ _object encodeWithCoder : aCoder ] ;
2003-08-23 01:03:40 +00:00
}
}
2004-08-28 14:41:16 +00:00
- ( BOOL ) shouldSwapClass
{
BOOL result = YES ;
2005-11-16 11:34:25 +00:00
if ( [ self respondsToSelector : @ selector ( isInInterfaceBuilder ) ] )
2004-08-28 14:41:16 +00:00
{
result = ! ( [ self isInInterfaceBuilder ] ) ;
}
return result ;
}
2003-08-23 01:03:40 +00:00
@ end
@ implementation GSWindowTemplate
+ ( void ) initialize
{
2023-11-27 07:26:16 +00:00
if ( self = = [ GSWindowTemplate class ] )
{
2003-08-23 01:03:40 +00:00
[ self setVersion : GSWINDOWT_VERSION ] ;
}
}
2005-06-04 11:35:22 +00:00
- ( unsigned int ) autoPositionMask
{
return _autoPositionMask ;
}
2014-07-24 21:09:05 +00:00
- ( void ) setAutoPositionMask : ( unsigned int ) flag
2005-06-04 11:35:22 +00:00
{
_autoPositionMask = flag ;
}
2014-07-24 21:09:05 +00:00
- ( BOOL ) deferFlag
2003-08-23 01:03:40 +00:00
{
return _deferFlag ;
}
2014-07-24 21:09:05 +00:00
- ( void ) setDeferFlag : ( BOOL ) flag
2003-08-23 01:03:40 +00:00
{
_deferFlag = flag ;
}
2005-06-04 11:35:22 +00:00
- ( void ) autoPositionWindow : ( NSWindow * ) window
{
int options = 0 ;
NSRect currentScreenFrame = [ [ window screen ] frame ] ;
NSRect windowFrame = [ window frame ] ;
NSPoint origin = windowFrame . origin ;
NSSize newSize = currentScreenFrame . size ;
NSSize oldSize = _screenRect . size ;
BOOL changedOrigin = NO ;
// reposition the window on the screen .
2005-06-04 19:52:40 +00:00
if ( _autoPositionMask = = GSWindowAutoPositionNone )
2005-06-04 11:35:22 +00:00
return ;
/ *
* determine if and how the X axis can be resized
* /
if ( _autoPositionMask & GSWindowMinXMargin )
options + + ;
if ( _autoPositionMask & GSWindowMaxXMargin )
options + + ;
/ *
* adjust the X axis if any X options are set in the mask
* /
if ( options > 0 )
{
float change = newSize . width - oldSize . width ;
float changePerOption = change / options ;
if ( _autoPositionMask & GSWindowMinXMargin )
{
origin . x + = changePerOption ;
changedOrigin = YES ;
}
}
/ *
* determine if and how the Y axis can be resized
* /
options = 0 ;
if ( _autoPositionMask & GSWindowMinYMargin )
options + + ;
if ( _autoPositionMask & GSWindowMaxYMargin )
options + + ;
/ *
* adjust the Y axis if any Y options are set in the mask
* /
if ( options > 0 )
{
float change = newSize . height - oldSize . height ;
float changePerOption = change / options ;
2023-11-27 07:26:16 +00:00
2005-06-04 11:35:22 +00:00
if ( _autoPositionMask & ( GSWindowMaxYMargin | GSWindowMinYMargin ) )
{
if ( _autoPositionMask & GSWindowMinYMargin )
{
origin . y + = changePerOption ;
changedOrigin = YES ;
}
}
}
2023-11-27 07:26:16 +00:00
2005-06-04 11:35:22 +00:00
// change the origin of the window .
2005-11-16 11:34:25 +00:00
if ( changedOrigin )
2005-06-04 11:35:22 +00:00
{
[ window setFrameOrigin : origin ] ;
}
}
2003-08-23 01:03:40 +00:00
// NSCoding . . .
- ( id ) initWithCoder : ( NSCoder * ) coder
{
id obj = [ super initWithCoder : coder ] ;
2005-11-16 11:34:25 +00:00
if ( obj ! = nil )
2003-08-23 01:03:40 +00:00
{
2005-06-04 11:35:22 +00:00
int version = [ coder versionForClassName : @ "GSWindowTemplate" ] ;
2003-08-23 01:03:40 +00:00
2005-11-16 11:34:25 +00:00
if ( version = = GSWINDOWT_VERSION )
2005-06-04 11:35:22 +00:00
{
// decode the defer flag . . .
2023-11-27 07:26:16 +00:00
[ coder decodeValueOfObjCType : @ encode ( BOOL ) at : & _deferFlag ] ;
2005-06-04 11:35:22 +00:00
[ coder decodeValueOfObjCType : @ encode ( unsigned int ) at : & _autoPositionMask ] ;
_screenRect = [ coder decodeRect ] ;
}
2005-11-16 11:34:25 +00:00
else if ( version = = 0 )
2005-06-04 11:35:22 +00:00
{
// decode the defer flag . . .
2023-11-27 07:26:16 +00:00
[ coder decodeValueOfObjCType : @ encode ( BOOL ) at : & _deferFlag ] ;
2005-06-04 19:52:40 +00:00
_autoPositionMask = GSWindowAutoPositionNone ;
2014-07-24 21:09:05 +00:00
_screenRect = [ [ obj screen ] frame ] ;
2005-06-04 11:35:22 +00:00
}
2003-08-23 01:03:40 +00:00
2008-05-24 15:00:12 +00:00
// FIXME : The designated initializer logic for NSWindow is in the initWithCoder : method of
// NSWindow . Unfortunately , this means that the "defer" flag for NSWindows and NSWindow
2023-11-27 07:26:16 +00:00
// subclasses in gorm files will be ignored . This shouldn ' t have a great impact ,
// but it is not the correct behavior .
2008-05-24 15:00:12 +00:00
//
2023-11-27 07:26:16 +00:00
// Set all of the attributes into the object , if it
2008-05-24 15:00:12 +00:00
// responds to any of these methods .
//
if ( [ obj respondsToSelector : @ selector ( setAutoPositionMask : ) ] )
2005-06-04 11:35:22 +00:00
{
2008-05-24 15:00:12 +00:00
[ obj setAutoPositionMask : [ self autoPositionMask ] ] ;
2005-06-04 11:35:22 +00:00
}
2008-05-24 15:00:12 +00:00
2003-08-28 04:38:22 +00:00
RELEASE ( self ) ;
2003-08-23 01:03:40 +00:00
}
return obj ;
}
- ( void ) encodeWithCoder : ( NSCoder * ) coder
{
2005-06-04 11:35:22 +00:00
int version = [ [ self class ] version ] ;
2003-08-23 01:03:40 +00:00
[ super encodeWithCoder : coder ] ;
2005-06-04 11:35:22 +00:00
2005-11-16 11:34:25 +00:00
if ( version = = GSWINDOWT_VERSION )
2005-06-04 11:35:22 +00:00
{
2023-11-27 07:26:16 +00:00
_screenRect = [ [ _object screen ] frame ] ;
2005-06-04 11:35:22 +00:00
[ coder encodeValueOfObjCType : @ encode ( BOOL ) at : & _deferFlag ] ;
[ coder encodeValueOfObjCType : @ encode ( unsigned int ) at : & _autoPositionMask ] ;
2023-11-27 07:26:16 +00:00
[ coder encodeRect : _screenRect ] ;
2005-06-04 11:35:22 +00:00
}
2005-11-16 11:34:25 +00:00
else if ( version = = 0 )
2005-06-04 11:35:22 +00:00
{
[ coder encodeValueOfObjCType : @ encode ( BOOL ) at : & _deferFlag ] ;
}
2003-08-23 01:03:40 +00:00
}
@ end
@ implementation GSViewTemplate
+ ( void ) initialize
{
2023-11-27 07:26:16 +00:00
if ( self = = [ GSViewTemplate class ] )
2003-08-23 01:03:40 +00:00
{
[ self setVersion : GSVIEWT_VERSION ] ;
}
}
- ( id ) initWithCoder : ( NSCoder * ) coder
{
id obj = [ super initWithCoder : coder ] ;
2005-11-16 11:34:25 +00:00
if ( obj ! = nil )
2003-08-23 01:03:40 +00:00
{
RELEASE ( self ) ;
}
return obj ;
}
@ end
// Template for any classes which derive from NSText
@ implementation GSTextTemplate
+ ( void ) initialize
{
2023-11-27 07:26:16 +00:00
if ( self = = [ GSTextTemplate class ] )
2003-08-23 01:03:40 +00:00
{
[ self setVersion : GSTEXTT_VERSION ] ;
}
}
- ( id ) initWithCoder : ( NSCoder * ) coder
{
id obj = [ super initWithCoder : coder ] ;
2005-11-16 11:34:25 +00:00
if ( obj ! = nil )
2003-08-23 01:03:40 +00:00
{
RELEASE ( self ) ;
}
return obj ;
}
@ end
// Template for any classes which derive from GSTextView
@ implementation GSTextViewTemplate
+ ( void ) initialize
{
2023-11-27 07:26:16 +00:00
if ( self = = [ GSTextViewTemplate class ] )
2003-08-23 01:03:40 +00:00
{
[ self setVersion : GSTEXTVIEWT_VERSION ] ;
}
}
- ( id ) initWithCoder : ( NSCoder * ) coder
{
id obj = [ super initWithCoder : coder ] ;
2005-11-16 11:34:25 +00:00
if ( obj ! = nil )
2003-08-23 01:03:40 +00:00
{
RELEASE ( self ) ;
}
return obj ;
}
@ end
// Template for any classes which derive from NSMenu .
@ implementation GSMenuTemplate
+ ( void ) initialize
{
2023-11-27 07:26:16 +00:00
if ( self = = [ GSMenuTemplate class ] )
2003-08-23 01:03:40 +00:00
{
[ self setVersion : GSMENUT_VERSION ] ;
}
}
- ( id ) initWithCoder : ( NSCoder * ) coder
{
id obj = [ super initWithCoder : coder ] ;
2005-11-16 11:34:25 +00:00
if ( obj ! = nil )
2003-08-23 01:03:40 +00:00
{
RELEASE ( self ) ;
}
return obj ;
}
@ end
// Template for any classes which derive from NSControl
@ implementation GSControlTemplate
+ ( void ) initialize
{
2023-11-27 07:26:16 +00:00
if ( self = = [ GSControlTemplate class ] )
2003-08-23 01:03:40 +00:00
{
[ self setVersion : GSCONTROLT_VERSION ] ;
}
}
- ( id ) initWithCoder : ( NSCoder * ) coder
{
id obj = [ super initWithCoder : coder ] ;
2005-11-16 11:34:25 +00:00
if ( obj ! = nil )
2003-08-23 01:03:40 +00:00
{
2003-08-25 04:50:09 +00:00
RELEASE ( self ) ;
2003-08-23 01:03:40 +00:00
}
return obj ;
}
@ end
@ implementation GSObjectTemplate
+ ( void ) initialize
{
2023-11-27 07:26:16 +00:00
if ( self = = [ GSObjectTemplate class ] )
2003-08-23 01:03:40 +00:00
{
[ self setVersion : GSOBJECTT_VERSION ] ;
}
}
- ( id ) initWithCoder : ( NSCoder * ) coder
{
id obj = [ super initWithCoder : coder ] ;
2005-11-16 11:34:25 +00:00
if ( obj ! = nil )
2003-08-23 01:03:40 +00:00
{
RELEASE ( self ) ;
}
return obj ;
}
@ end
2023-11-27 07:26:16 +00:00
// Order in this factory method is very important .
2004-11-06 13:48:12 +00:00
// Which template to create must be determined
2003-08-23 01:03:40 +00:00
// in sequence because of the class hierarchy .
@ implementation GSTemplateFactory
2023-11-27 07:26:16 +00:00
+ ( id ) templateForObject : ( id ) object
2003-08-23 01:03:40 +00:00
withClassName : ( NSString * ) className
withSuperClassName : ( NSString * ) superClassName
{
id template = nil ;
2005-11-16 11:34:25 +00:00
if ( object ! = nil )
2003-08-23 01:03:40 +00:00
{
if ( [ object isKindOfClass : [ NSWindow class ] ] )
{
template = [ [ GSWindowTemplate alloc ] initWithObject : object
2023-11-27 07:26:16 +00:00
className : className
2003-08-23 01:03:40 +00:00
superClassName : superClassName ] ;
}
else if ( [ object isKindOfClass : [ NSTextView class ] ] )
{
template = [ [ GSTextViewTemplate alloc ] initWithObject : object
2023-11-27 07:26:16 +00:00
className : className
2003-08-23 01:03:40 +00:00
superClassName : superClassName ] ;
}
else if ( [ object isKindOfClass : [ NSText class ] ] )
{
template = [ [ GSTextTemplate alloc ] initWithObject : object
2023-11-27 07:26:16 +00:00
className : className
2003-08-23 01:03:40 +00:00
superClassName : superClassName ] ;
}
else if ( [ object isKindOfClass : [ NSControl class ] ] )
{
template = [ [ GSControlTemplate alloc ] initWithObject : object
2023-11-27 07:26:16 +00:00
className : className
2003-08-23 01:03:40 +00:00
superClassName : superClassName ] ;
}
else if ( [ object isKindOfClass : [ NSView class ] ] )
{
template = [ [ GSViewTemplate alloc ] initWithObject : object
2023-11-27 07:26:16 +00:00
className : className
2003-08-23 01:03:40 +00:00
superClassName : superClassName ] ;
}
else if ( [ object isKindOfClass : [ NSMenu class ] ] )
{
template = [ [ GSMenuTemplate alloc ] initWithObject : object
2023-11-27 07:26:16 +00:00
className : className
2003-08-23 01:03:40 +00:00
superClassName : superClassName ] ;
}
2023-11-27 07:26:16 +00:00
else if ( [ object isKindOfClass : [ NSObject class ] ] )
2003-08-23 01:03:40 +00:00
{
2005-04-25 04:08:10 +00:00
// for gui elements derived from NSObject
2003-08-23 01:03:40 +00:00
template = [ [ GSObjectTemplate alloc ] initWithObject : object
2023-11-27 07:26:16 +00:00
className : className
2003-08-23 01:03:40 +00:00
superClassName : superClassName ] ;
}
}
2005-04-11 14:30:27 +00:00
return AUTORELEASE ( template ) ;
2003-08-23 01:03:40 +00:00
}
@ end