mirror of
https://github.com/gnustep/apps-gorm.git
synced 2025-04-22 22:20:44 +00:00
Modifications to make use of new templates.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/apps/gorm/trunk@17512 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
4797ad490a
commit
ef9cf368da
10 changed files with 106 additions and 528 deletions
|
@ -1,3 +1,12 @@
|
|||
2003-08-22 Gregory John Casamento <greg_casamento@yahoo.com>
|
||||
|
||||
* GormDocument.m: Removed refrences to old template classes.
|
||||
Added code to use new template classes and fixed several
|
||||
bugs.
|
||||
* Gorm.m: Removed old subclasses for deprecated template classes.
|
||||
* GormPrivate.h: Removed subclasses for deprecated template classes.
|
||||
* GormLib/IBConnectors.[hm]: added nibInstantiate method.
|
||||
|
||||
2003-08-16 Adam Fedor <fedor@gnu.org>
|
||||
|
||||
* GNUmakefile.preamble (ADDITIONAL_GUI_LIBS): Add -lGormLib
|
||||
|
|
|
@ -404,4 +404,3 @@ Class gmodel_class(NSString *className)
|
|||
}
|
||||
return gmclass;
|
||||
}
|
||||
|
||||
|
|
303
Gorm.m
303
Gorm.m
|
@ -204,284 +204,6 @@ static NSButtonType _buttonTypeForObject( id button )
|
|||
return type;
|
||||
}
|
||||
|
||||
@implementation NSWindowTemplate (GormCustomClassAdditions)
|
||||
- (void) _setStyleMask: (unsigned int)mask
|
||||
{
|
||||
_styleMask = mask;
|
||||
}
|
||||
|
||||
- (id) initWithObject: (id)object
|
||||
className: (NSString *)name
|
||||
{
|
||||
// GSDataObject *data = [[GSDataObject alloc] initWithObject: object];
|
||||
// RETAIN(data);
|
||||
// NSLog(@"!!!!!!I'm here!!!!!!!!! %@",self);
|
||||
|
||||
[super init];
|
||||
[self setBackgroundColor: [object backgroundColor]];
|
||||
[self setContentView: [object contentView]];
|
||||
[self setFrameAutosaveName: [object frameAutosaveName]];
|
||||
[self setHidesOnDeactivate: [object hidesOnDeactivate]];
|
||||
[self setInitialFirstResponder: [object initialFirstResponder]];
|
||||
[self setAutodisplay: [object isAutodisplay]];
|
||||
[self setReleasedWhenClosed: [object isReleasedWhenClosed]];
|
||||
[self _setVisible: [object isVisible]];
|
||||
[self setTitle: [object title]];
|
||||
[self setFrame: [object frame] display: NO];
|
||||
[self _setStyleMask: [object styleMask]];
|
||||
[self setClassName: name];
|
||||
[(NSWindow *)object setContentView: nil];
|
||||
[self update];
|
||||
[object update];
|
||||
|
||||
_parentClassName = NSStringFromClass([object class]);
|
||||
return self;
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation NSViewTemplate (GormCustomClassAdditions)
|
||||
- (id) initWithObject: (id)object
|
||||
className: (NSString *)name
|
||||
{
|
||||
// call the super constructor
|
||||
[self initWithFrame: [object frame]];
|
||||
|
||||
// set the attributes for the view
|
||||
[self setBounds: [object bounds]];
|
||||
|
||||
[self setClassName: name];
|
||||
_parentClassName = NSStringFromClass([object class]);
|
||||
return self;
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation NSControlTemplate (GormCustomClassAdditions)
|
||||
- (id) initWithObject: (id)object
|
||||
className: (NSString *)name
|
||||
{
|
||||
// call the super constructor
|
||||
[self initWithFrame: [object frame]];
|
||||
|
||||
// set the attributes for the view
|
||||
[self setBounds: [object bounds]];
|
||||
|
||||
// set the attributes for the control
|
||||
[self setDoubleValue: [object doubleValue]];
|
||||
[self setFloatValue: [object floatValue]];
|
||||
[self setIntValue: [object intValue]];
|
||||
[self setObjectValue: [object objectValue]];
|
||||
[self setStringValue: [object stringValue]];
|
||||
[self setTag: [object tag]];
|
||||
[self setFont: [object font]];
|
||||
[self setAlignment: [object alignment]];
|
||||
[self setEnabled: [object isEnabled]];
|
||||
[self setContinuous: [object isContinuous]];
|
||||
|
||||
// since only some controls have delegates, we need to test...
|
||||
if([object respondsToSelector: @selector(delegate)])
|
||||
_delegate = [object delegate];
|
||||
|
||||
// since only some controls have data sources, we need to test...
|
||||
if([object respondsToSelector: @selector(dataSource)])
|
||||
_dataSource = [object dataSource];
|
||||
|
||||
// since only some controls have data sources, we need to test...
|
||||
if([object respondsToSelector: @selector(usesDataSource)])
|
||||
_usesDataSource = [object usesDataSource];
|
||||
|
||||
[self setClassName: name];
|
||||
_parentClassName = NSStringFromClass([object class]);
|
||||
return self;
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation NSButtonTemplate (GormCustomClassAdditions)
|
||||
- (id) initWithObject: (id)object
|
||||
className: (NSString *)name
|
||||
{
|
||||
// call the super constructor
|
||||
[self initWithFrame: [object frame]];
|
||||
|
||||
// set the attributes for the view
|
||||
[self setBounds: [object bounds]];
|
||||
|
||||
// set the attributes for the control
|
||||
[self setDoubleValue: [object doubleValue]];
|
||||
[self setFloatValue: [object floatValue]];
|
||||
[self setIntValue: [object intValue]];
|
||||
[self setObjectValue: [object objectValue]];
|
||||
[self setStringValue: [object stringValue]];
|
||||
[self setTag: [object tag]];
|
||||
[self setFont: [object font]];
|
||||
[self setAlignment: [object alignment]];
|
||||
[self setEnabled: [object isEnabled]];
|
||||
[self setContinuous: [object isContinuous]];
|
||||
|
||||
// set up template
|
||||
_buttonType = _buttonTypeForObject( object );
|
||||
[self setButtonType: _buttonType];
|
||||
[self setBezelStyle: [object bezelStyle]];
|
||||
[self setBordered: [object isBordered]];
|
||||
[self setAllowsMixedState: [object allowsMixedState]];
|
||||
[self setTitle: [object title]];
|
||||
[self setAlternateTitle: [object alternateTitle]];
|
||||
[self setImage: [object image]];
|
||||
[self setAlternateImage: [object alternateImage]];
|
||||
[self setImagePosition: [object imagePosition]];
|
||||
[self setKeyEquivalent: [object keyEquivalent]];
|
||||
|
||||
[self setClassName: name];
|
||||
_parentClassName = NSStringFromClass([object class]);
|
||||
return self;
|
||||
}
|
||||
@end
|
||||
|
||||
|
||||
@implementation NSTextTemplate (GormCustomClassAdditions)
|
||||
- (id) initWithObject: (id)object
|
||||
className: (NSString *)name
|
||||
{
|
||||
// call the super constructor
|
||||
[self initWithFrame: [object frame]];
|
||||
|
||||
// set the attributes for the view
|
||||
[self setBounds: [object bounds]];
|
||||
|
||||
// set the attributes for text
|
||||
[self setBackgroundColor: [object backgroundColor]];
|
||||
[self setDrawsBackground: [object drawsBackground]];
|
||||
[self setEditable: [object isEditable]];
|
||||
[self setSelectable: [object isSelectable]];
|
||||
[self setFieldEditor: [object isFieldEditor]];
|
||||
[self setRichText: [object isRichText]];
|
||||
[self setImportsGraphics: [object importsGraphics]];
|
||||
[self setDelegate: [object delegate]];
|
||||
|
||||
[self setClassName: name];
|
||||
_parentClassName = NSStringFromClass([object class]);
|
||||
return self;
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation NSTextViewTemplate (GormCustomClassAdditions)
|
||||
- (id) initWithObject: (id)object
|
||||
className: (NSString *)name
|
||||
{
|
||||
// call the super constructor
|
||||
[self initWithFrame: [object frame]];
|
||||
|
||||
// set the attributes for the view
|
||||
[self setBounds: [object bounds]];
|
||||
[self setFrame: [object frame]];
|
||||
|
||||
// set the attributes for text
|
||||
[self setBackgroundColor: [object backgroundColor]];
|
||||
[self setDrawsBackground: [object drawsBackground]];
|
||||
[self setEditable: [object isEditable]];
|
||||
[self setSelectable: [object isSelectable]];
|
||||
[self setFieldEditor: [object isFieldEditor]];
|
||||
[self setRichText: [object isRichText]];
|
||||
[self setImportsGraphics: [object importsGraphics]];
|
||||
[self setDelegate: [object delegate]];
|
||||
|
||||
// text view
|
||||
[self setRulerVisible: [object isRulerVisible]];
|
||||
[self setInsertionPointColor: [object insertionPointColor]];
|
||||
|
||||
[self setClassName: name];
|
||||
_parentClassName = NSStringFromClass([object class]);
|
||||
return self;
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation NSMenuTemplate (GormCustomClassAdditions)
|
||||
- (id) initWithObject: (id)object
|
||||
className: (NSString *)name
|
||||
{
|
||||
// copy attributes
|
||||
[self setAutoenablesItems: [object autoenablesItems]];
|
||||
[self setTitle: [object title]];
|
||||
|
||||
[self setClassName: name];
|
||||
_parentClassName = NSStringFromClass([object class]);
|
||||
return self;
|
||||
}
|
||||
@end
|
||||
|
||||
// Gorm template subclasses to allow persisting and unpersisting
|
||||
// from Gorm w/o the class trying to transform itself into the custom
|
||||
// class instance. Instead the class will transform itself into the
|
||||
// appropriate parent class which Gorm knows about.
|
||||
@implementation GormNSWindowTemplate
|
||||
- awakeAfterUsingCoder: (NSCoder *)coder
|
||||
{
|
||||
id obj = nil;
|
||||
[self setClassName: _parentClassName];
|
||||
obj = RETAIN([self instantiateObject: coder]);
|
||||
return obj;
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation GormNSViewTemplate
|
||||
- awakeAfterUsingCoder: (NSCoder *)coder
|
||||
{
|
||||
id obj = nil;
|
||||
[self setClassName: _parentClassName];
|
||||
obj = RETAIN([self instantiateObject: coder]);
|
||||
return obj;
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation GormNSTextTemplate
|
||||
- awakeAfterUsingCoder: (NSCoder *)coder
|
||||
{
|
||||
id obj = nil;
|
||||
[self setClassName: _parentClassName];
|
||||
obj = RETAIN([self instantiateObject: coder]);
|
||||
return obj;
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation GormNSControlTemplate
|
||||
- awakeAfterUsingCoder: (NSCoder *)coder
|
||||
{
|
||||
id obj = nil;
|
||||
[self setClassName: _parentClassName];
|
||||
obj = RETAIN([self instantiateObject: coder]);
|
||||
return obj;
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation GormNSButtonTemplate
|
||||
- awakeAfterUsingCoder: (NSCoder *)coder
|
||||
{
|
||||
id obj = nil;
|
||||
[self setClassName: _parentClassName];
|
||||
obj = RETAIN([self instantiateObject: coder]);
|
||||
return obj;
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation GormNSTextViewTemplate
|
||||
- awakeAfterUsingCoder: (NSCoder *)coder
|
||||
{
|
||||
id obj = nil;
|
||||
[self setClassName: _parentClassName];
|
||||
obj = RETAIN([self instantiateObject: coder]);
|
||||
return obj;
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation GormNSMenuTemplate
|
||||
- awakeAfterUsingCoder: (NSCoder *)coder
|
||||
{
|
||||
id obj = nil;
|
||||
[self setClassName: _parentClassName];
|
||||
obj = RETAIN([self instantiateObject: coder]);
|
||||
return obj;
|
||||
}
|
||||
@end
|
||||
|
||||
// define the class proxy...
|
||||
@implementation GormClassProxy
|
||||
- (id) initWithClassName: (NSString*)n
|
||||
|
@ -1648,6 +1370,31 @@ static NSButtonType _buttonTypeForObject( id button )
|
|||
}
|
||||
@end
|
||||
|
||||
// custom class additions...
|
||||
@interface GSClassSwapper (GormCustomClassAdditions)
|
||||
- (BOOL) isInInterfaceBuilder;
|
||||
@end
|
||||
|
||||
@implementation GSClassSwapper (GormCustomClassAdditions)
|
||||
- (BOOL) isInInterfaceBuilder
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
@end
|
||||
|
||||
// temporary until the deprecated template is removed...
|
||||
@interface NSWindowTemplate (GormCustomClassAdditions)
|
||||
- (BOOL) isInInterfaceBuilder;
|
||||
@end
|
||||
|
||||
@implementation NSWindowTemplate (GormCustomClassAdditions)
|
||||
- (BOOL) isInInterfaceBuilder
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
@end
|
||||
|
||||
// main...
|
||||
int
|
||||
main(int argc, const char **argv)
|
||||
{
|
||||
|
|
|
@ -109,7 +109,7 @@
|
|||
NSCell *cell = [browser selectedCellInColumn: 0];
|
||||
NSString *stringValue = [NSString stringWithString: [cell stringValue]];
|
||||
NSString *nameForObject = [_document nameForObject: _currentSelection];
|
||||
NSString *classForObject = NSStringFromClass([_currentSelection class]);
|
||||
NSString *classForObject = [GormClassManager correctClassName: NSStringFromClass([_currentSelection class])];
|
||||
|
||||
NSDebugLog(@"selected = %@, class = %@",stringValue,nameForObject);
|
||||
|
||||
|
@ -180,4 +180,3 @@ createRowsForColumn: (int)column
|
|||
return YES;
|
||||
}
|
||||
@end
|
||||
|
||||
|
|
|
@ -59,7 +59,6 @@
|
|||
GormClassEditor *classEditor; // perhaps should not be here...
|
||||
NSString *documentPath;
|
||||
NSMapTable *objToName;
|
||||
NSMutableDictionary *tempNameTable;
|
||||
NSWindow *window;
|
||||
NSMatrix *selectionView;
|
||||
NSBox *selectionBox;
|
||||
|
@ -80,6 +79,10 @@
|
|||
NSMutableSet *sounds;
|
||||
NSMutableSet *images;
|
||||
// NSFileWrapper *wrapper;
|
||||
|
||||
// working copies of objects in the container...
|
||||
NSMutableArray *workingConnections;
|
||||
NSMutableDictionary *workingNameTable;
|
||||
}
|
||||
- (void) addConnector: (id<IBConnectors>)aConnector;
|
||||
- (NSArray*) allConnectors;
|
||||
|
|
237
GormDocument.m
237
GormDocument.m
|
@ -304,82 +304,6 @@ static NSImage *classesImage = nil;
|
|||
return TEST_AUTORELEASE([[GormImage alloc] initWithName: name path: path]);
|
||||
}
|
||||
|
||||
// template support
|
||||
- (void) _replaceObjectsWithTemplates
|
||||
{
|
||||
if (![classManager isCustomClassMapEmpty])
|
||||
{
|
||||
NSEnumerator *en = [nameTable keyEnumerator];
|
||||
NSString *key = nil;
|
||||
|
||||
while ((key = [en nextObject]) != nil)
|
||||
{
|
||||
id obj = [nameTable objectForKey: key];
|
||||
id template = nil;
|
||||
NSString *className = [classManager customClassForName: key];
|
||||
|
||||
[tempNameTable setObject: obj forKey: key]; // save the old object
|
||||
NSDebugLog(@"className = (%@), obj = (%@), key = (%@)", className, obj, key);
|
||||
if (className != nil)
|
||||
{
|
||||
/*
|
||||
* The order in which these are handled is important.
|
||||
* The mutually exclusive conditions below need to be
|
||||
* evaluated in sequence to determine
|
||||
* which template class should be used.
|
||||
*/
|
||||
if ([obj isKindOfClass: [NSWindow class]])
|
||||
{
|
||||
BOOL isVisible = [self objectIsVisibleAtLaunch: obj];
|
||||
|
||||
NSDebugLog(@"In the window template if...");
|
||||
template = [[GormNSWindowTemplate alloc] initWithObject: obj
|
||||
className: className];
|
||||
[self setObject: obj isVisibleAtLaunch: NO];
|
||||
[self setObject: template isVisibleAtLaunch: isVisible];
|
||||
}
|
||||
else if ([obj isKindOfClass: [NSTextView class]])
|
||||
{
|
||||
template = [[GormNSTextViewTemplate alloc] initWithObject: obj
|
||||
className: className];
|
||||
[[obj superview] replaceSubview: obj with: template];
|
||||
}
|
||||
else if ([obj isKindOfClass: [NSText class]])
|
||||
{
|
||||
template = [[GormNSTextTemplate alloc] initWithObject: obj
|
||||
className: className];
|
||||
[[obj superview] replaceSubview: obj with: template];
|
||||
}
|
||||
else if ([obj isKindOfClass: [NSButton class]])
|
||||
{
|
||||
template = [[GormNSButtonTemplate alloc] initWithObject: obj
|
||||
className: className];
|
||||
[[obj superview] replaceSubview: obj with: template];
|
||||
}
|
||||
else if ([obj isKindOfClass: [NSControl class]])
|
||||
{
|
||||
template = [[GormNSControlTemplate alloc] initWithObject: obj
|
||||
className: className];
|
||||
[[obj superview] replaceSubview: obj with: template];
|
||||
}
|
||||
else if ([obj isKindOfClass: [NSView class]])
|
||||
{
|
||||
template = [[GormNSViewTemplate alloc] initWithObject: obj
|
||||
className: className];
|
||||
[[obj superview] replaceSubview: obj with: template];
|
||||
}
|
||||
else if ([obj isKindOfClass: [NSMenu class]])
|
||||
{
|
||||
template = [[GormNSMenuTemplate alloc] initWithObject: obj
|
||||
className: className];
|
||||
}
|
||||
|
||||
[nameTable setObject: template forKey: key];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void) beginArchiving
|
||||
{
|
||||
NSEnumerator *enumerator;
|
||||
|
@ -416,14 +340,6 @@ static NSImage *classesImage = nil;
|
|||
}
|
||||
[connections removeObjectsInArray: savedEditors];
|
||||
|
||||
/*
|
||||
* Method to replace custom objects with templates for archiving.
|
||||
*/
|
||||
if (![(id<IB>)NSApp isTestingInterface]) // if we arent testing the interface, substitute the templates when appropriate.
|
||||
{
|
||||
[self _replaceObjectsWithTemplates];
|
||||
}
|
||||
|
||||
NSDebugLog(@"*** customClassMap = %@",[classManager customClassMap]);
|
||||
[nameTable setObject: [classManager customClassMap] forKey: GSCustomClassMap];
|
||||
|
||||
|
@ -443,7 +359,6 @@ static NSImage *classesImage = nil;
|
|||
/* Add information about the NSOwner to the archive */
|
||||
NSMapInsert(objToName, (void*)[filesOwner className], (void*)@"NSOwner");
|
||||
[nameTable setObject: [filesOwner className] forKey: @"NSOwner"];
|
||||
|
||||
}
|
||||
|
||||
- (void) changeCurrentClass: (id)sender
|
||||
|
@ -713,13 +628,14 @@ static NSImage *classesImage = nil;
|
|||
RELEASE(savedEditors);
|
||||
RELEASE(scrollView);
|
||||
RELEASE(classesScrollView);
|
||||
RELEASE(tempNameTable);
|
||||
// RELEASE(workingNameTable);
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (void) detachObject: (id)anObject
|
||||
{
|
||||
NSString *name = RETAIN([self nameForObject: anObject]);
|
||||
GormClassManager *cm = [self classManager];
|
||||
unsigned count;
|
||||
|
||||
[[self editorForObject: anObject create: NO] close];
|
||||
|
@ -746,7 +662,13 @@ static NSImage *classesImage = nil;
|
|||
*/
|
||||
[self setObject: anObject isVisibleAtLaunch: NO];
|
||||
|
||||
// remove from custom class map...
|
||||
[cm removeCustomClassForObject: name];
|
||||
|
||||
// remove from name table...
|
||||
[nameTable removeObjectForKey: name];
|
||||
|
||||
// free...
|
||||
RELEASE(name);
|
||||
}
|
||||
|
||||
|
@ -1321,59 +1243,6 @@ static NSImage *classesImage = nil;
|
|||
}
|
||||
}
|
||||
|
||||
- (void) _replaceTemplatesWithObjects
|
||||
{
|
||||
NSEnumerator *en = [tempNameTable keyEnumerator];
|
||||
NSString *key = nil;
|
||||
|
||||
while ((key = [en nextObject]) != nil)
|
||||
{
|
||||
id obj = [tempNameTable objectForKey: key];
|
||||
id template = [nameTable objectForKey: key];
|
||||
|
||||
if ([template isKindOfClass: [GormNSWindowTemplate class]])
|
||||
{
|
||||
BOOL isVisible = [self objectIsVisibleAtLaunch: template];
|
||||
[(NSWindow *)obj setContentView: [template contentView]];
|
||||
[self setObject: template isVisibleAtLaunch: NO];
|
||||
[self setObject: obj isVisibleAtLaunch: isVisible];
|
||||
// RELEASE(template); // get rid of the template...
|
||||
}
|
||||
else if ([template isKindOfClass: [GormNSTextViewTemplate class]])
|
||||
{
|
||||
[[template superview] replaceSubview: template with: obj];
|
||||
// RELEASE(template); // get rid of the template...
|
||||
}
|
||||
else if ([template isKindOfClass: [GormNSTextTemplate class]])
|
||||
{
|
||||
[[template superview] replaceSubview: template with: obj];
|
||||
// RELEASE(template); // get rid of the template...
|
||||
}
|
||||
else if ([template isKindOfClass: [GormNSButtonTemplate class]])
|
||||
{
|
||||
[[template superview] replaceSubview: template with: obj];
|
||||
// RELEASE(template); // get rid of the template...
|
||||
}
|
||||
else if ([template isKindOfClass: [GormNSControlTemplate class]])
|
||||
{
|
||||
[[template superview] replaceSubview: template with: obj];
|
||||
// RELEASE(template); // get rid of the template...
|
||||
}
|
||||
else if ([template isKindOfClass: [GormNSViewTemplate class]])
|
||||
{
|
||||
[[template superview] replaceSubview: template with: obj];
|
||||
// RELEASE(template); // get rid of the template...
|
||||
}
|
||||
else if ([template isKindOfClass: [GormNSMenuTemplate class]])
|
||||
{
|
||||
[[template superview] replaceSubview: template with: obj];
|
||||
// RELEASE(template); // get rid of the template...
|
||||
}
|
||||
[nameTable setObject: obj forKey: key];
|
||||
}
|
||||
[tempNameTable removeAllObjects];
|
||||
}
|
||||
|
||||
- (void) endArchiving
|
||||
{
|
||||
NSEnumerator *enumerator;
|
||||
|
@ -1395,15 +1264,6 @@ static NSImage *classesImage = nil;
|
|||
NSMapInsert(objToName, (void*)fontManager, (void*)@"NSFont");
|
||||
}
|
||||
|
||||
/*
|
||||
* Method to replace custom templates with objects for archiving.
|
||||
*/
|
||||
if (![(id<IB>)NSApp isTestingInterface])
|
||||
// do not use templates if we are testing.
|
||||
{
|
||||
[self _replaceTemplatesWithObjects];
|
||||
}
|
||||
|
||||
/*
|
||||
* Map all connector source and destination names to their objects.
|
||||
*/
|
||||
|
@ -1577,10 +1437,7 @@ static NSImage *classesImage = nil;
|
|||
*/
|
||||
objToName = NSCreateMapTableWithZone(NSObjectMapKeyCallBacks,
|
||||
NSObjectMapValueCallBacks, 128, [self zone]);
|
||||
|
||||
// saving objects when the gorm file is persisted. Used for templates.
|
||||
tempNameTable = [[NSMutableDictionary alloc] initWithCapacity: 8];
|
||||
|
||||
|
||||
// for saving the editors when the gorm file is persisted.
|
||||
savedEditors = [NSMutableArray new];
|
||||
|
||||
|
@ -1999,24 +1856,6 @@ static NSImage *classesImage = nil;
|
|||
[u decodeClassName: @"NSOutlineView"
|
||||
asClassName: @"GormNSOutlineView"];
|
||||
|
||||
// templates
|
||||
[u decodeClassName: @"NSWindowTemplate"
|
||||
asClassName: @"GormNSWindowTemplate"];
|
||||
[u decodeClassName: @"NSViewTemplate"
|
||||
asClassName: @"GormNSViewTemplate"];
|
||||
[u decodeClassName: @"NSTextTemplate"
|
||||
asClassName: @"GormNSTextTemplate"];
|
||||
[u decodeClassName: @"NSControlTemplate"
|
||||
asClassName: @"GormNSControlTemplate"];
|
||||
[u decodeClassName: @"NSButtonTemplate"
|
||||
asClassName: @"GormNSButtonTemplate"];
|
||||
[u decodeClassName: @"NSTextViewTemplate"
|
||||
asClassName: @"GormNSTextViewTemplate"];
|
||||
[u decodeClassName: @"NSViewTemplate"
|
||||
asClassName: @"GormNSViewTemplate"];
|
||||
[u decodeClassName: @"NSMenuTemplate"
|
||||
asClassName: @"GormNSMenuTemplate"];
|
||||
|
||||
c = [u decodeObject];
|
||||
if (c == nil || [c isKindOfClass: [GSNibContainer class]] == NO)
|
||||
{
|
||||
|
@ -2346,14 +2185,14 @@ static NSImage *classesImage = nil;
|
|||
NSRect frame;
|
||||
while ((obj = [enumerator nextObject]) != nil)
|
||||
{
|
||||
// check to see if the object has a frame. If so, then
|
||||
// modify it. If not, simply iterate to the next object
|
||||
if([obj respondsToSelector: @selector(frame)])
|
||||
// check to see if the object has a frame. If so, then
|
||||
// modify it. If not, simply iterate to the next object
|
||||
if([obj respondsToSelector: @selector(frame)])
|
||||
{
|
||||
frame = [obj frame];
|
||||
frame.origin.x -= 6;
|
||||
frame.origin.y -= 6;
|
||||
[obj setFrame: frame];
|
||||
frame = [obj frame];
|
||||
frame.origin.x -= 6;
|
||||
frame.origin.y -= 6;
|
||||
[obj setFrame: frame];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2697,6 +2536,31 @@ static NSImage *classesImage = nil;
|
|||
return NO;
|
||||
}
|
||||
|
||||
//
|
||||
// Private method which iterates through the list of custom classes and instructs
|
||||
// the archiver to replace the actual object with template during the archiving
|
||||
// process.
|
||||
//
|
||||
- (void) _replaceObjectsWithTemplates: (NSArchiver *)archiver
|
||||
{
|
||||
GormClassManager *cm = [self classManager];
|
||||
NSDictionary *classMap = [cm customClassMap];
|
||||
NSEnumerator *en = [classMap keyEnumerator];
|
||||
id key = nil;
|
||||
NSLog(@"Called");
|
||||
while((key = [en nextObject]) != nil)
|
||||
{
|
||||
id customClass = [classMap objectForKey: key];
|
||||
id object = [self objectForName: key];
|
||||
NSString *superClass = [cm nonCustomSuperClassOf: customClass];
|
||||
id <GSTemplate> template = [GSTemplateFactory templateForObject: object
|
||||
withClassName: customClass
|
||||
withSuperClassName: superClass];
|
||||
NSLog(@"object = %@, key = %@, className = %@", object, key, customClass);
|
||||
[archiver replaceObject: object withObject: template];
|
||||
}
|
||||
}
|
||||
|
||||
- (BOOL) saveGormDocument: (id)sender
|
||||
{
|
||||
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
||||
|
@ -2749,24 +2613,7 @@ static NSImage *classesImage = nil;
|
|||
[archiver encodeClassName: @"GormNSOutlineView"
|
||||
intoClassName: @"NSOutlineView"];
|
||||
|
||||
/* Templates */
|
||||
[archiver encodeClassName: @"GormNSWindowTemplate"
|
||||
intoClassName: @"NSWindowTemplate"];
|
||||
[archiver encodeClassName: @"GormNSViewTemplate"
|
||||
intoClassName: @"NSViewTemplate"];
|
||||
[archiver encodeClassName: @"GormNSTextTemplate"
|
||||
intoClassName: @"NSTextTemplate"];
|
||||
[archiver encodeClassName: @"GormNSControlTemplate"
|
||||
intoClassName: @"NSControlTemplate"];
|
||||
[archiver encodeClassName: @"GormNSButtonTemplate"
|
||||
intoClassName: @"NSButtonTemplate"];
|
||||
[archiver encodeClassName: @"GormNSTextViewTemplate"
|
||||
intoClassName: @"NSTextViewTemplate"];
|
||||
[archiver encodeClassName: @"GormNSViewTemplate"
|
||||
intoClassName: @"NSViewTemplate"];
|
||||
[archiver encodeClassName: @"GormNSMenuTemplate"
|
||||
intoClassName: @"NSMenuTemplate"];
|
||||
|
||||
[self _replaceObjectsWithTemplates: archiver];
|
||||
|
||||
[archiver encodeRootObject: self];
|
||||
NSDebugLog(@"nameTable = %@",nameTable);
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
|
||||
#include <Foundation/NSObject.h>
|
||||
#include <AppKit/NSApplication.h>
|
||||
#include <AppKit/NSNibConnector.h>
|
||||
|
||||
// forward declarations
|
||||
@class NSString;
|
||||
|
@ -48,6 +49,14 @@ extern NSString *IBDidRemoveConnectorNotification;
|
|||
- (void) setDestination: (id)anObject;
|
||||
- (void) setLabel: (NSString*)label;
|
||||
- (void) setSource: (id)anObject;
|
||||
- (id) nibInstantiate;
|
||||
@end
|
||||
|
||||
@interface NSNibConnector (IBConnectorsProtocol) <IBConnectors>
|
||||
@end
|
||||
|
||||
@interface NSObject (IBNibInstantiation)
|
||||
- (id) nibInstantiate;
|
||||
@end
|
||||
|
||||
@interface NSApplication (IBConnections)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* IBApplicationAdditions.m
|
||||
/* IBConnectors.m
|
||||
*
|
||||
* Copyright (C) 2003 Free Software Foundation, Inc.
|
||||
*
|
||||
|
@ -23,6 +23,7 @@
|
|||
*/
|
||||
|
||||
#include <Foundation/NSString.h>
|
||||
#include <AppKit/NSNibConnector.h>
|
||||
|
||||
NSString *IBWillAddConnectorNotification
|
||||
= @"IBWillAddConnectorNotification";
|
||||
|
@ -32,3 +33,4 @@ NSString *IBWillRemoveConnectorNotification
|
|||
= @"IBWillRemoveConnectorNotification";
|
||||
NSString *IBDidRemoveConnectorNotification
|
||||
= @"IBDidRemoveConnectorNotification";
|
||||
|
||||
|
|
|
@ -58,54 +58,6 @@ extern NSString *GormDidDeleteClassNotification;
|
|||
- (void) setClassName: (NSString *)className;
|
||||
@end
|
||||
|
||||
// Additions to template classes within gorm.
|
||||
@protocol GormTemplate
|
||||
- (id) initWithObject: (id)object className: (NSString *)name;
|
||||
@end
|
||||
|
||||
@interface NSWindowTemplate (GormCustomClassAdditions) <GormTemplate>
|
||||
@end
|
||||
|
||||
@interface NSViewTemplate (GormCustomClassAdditions) <GormTemplate>
|
||||
@end
|
||||
|
||||
@interface NSTextTemplate (GormCustomClassAdditions) <GormTemplate>
|
||||
@end
|
||||
|
||||
@interface NSControlTemplate (GormCustomClassAdditions) <GormTemplate>
|
||||
@end
|
||||
|
||||
@interface NSButtonTemplate (GormCustomClassAdditions) <GormTemplate>
|
||||
@end
|
||||
|
||||
@interface NSTextViewTemplate (GormCustomClassAdditions) <GormTemplate>
|
||||
@end
|
||||
|
||||
@interface NSMenuTemplate (GormCustomClassAdditions) <GormTemplate>
|
||||
@end
|
||||
|
||||
// gorm template subclasses
|
||||
@interface GormNSWindowTemplate : NSWindowTemplate
|
||||
@end
|
||||
|
||||
@interface GormNSViewTemplate : NSViewTemplate
|
||||
@end
|
||||
|
||||
@interface GormNSTextTemplate : NSTextTemplate
|
||||
@end
|
||||
|
||||
@interface GormNSControlTemplate : NSControlTemplate
|
||||
@end
|
||||
|
||||
@interface GormNSButtonTemplate : NSButtonTemplate
|
||||
@end
|
||||
|
||||
@interface GormNSTextViewTemplate : NSTextViewTemplate
|
||||
@end
|
||||
|
||||
@interface GormNSMenuTemplate : NSMenuTemplate
|
||||
@end
|
||||
|
||||
@interface GormClassProxy : NSObject
|
||||
{
|
||||
NSString *name;
|
||||
|
|
|
@ -49,6 +49,18 @@
|
|||
@end
|
||||
|
||||
@implementation GormNSMenuWindow
|
||||
- initWithCoder: (NSCoder *)coder
|
||||
{
|
||||
NSLog(@"initWithCoder");
|
||||
return [super initWithCoder: coder];
|
||||
}
|
||||
|
||||
- (void) encodeWithCoder: (NSCoder *)coder
|
||||
{
|
||||
NSLog(@"encode");
|
||||
[super encodeWithCoder: coder];
|
||||
}
|
||||
|
||||
- (BOOL)canBecomeMainWindow
|
||||
{
|
||||
return YES;
|
||||
|
@ -103,7 +115,7 @@
|
|||
{
|
||||
if (_f.is_main == YES)
|
||||
{
|
||||
// NSLog(@"already main %@", [NSApp mainWindow]);
|
||||
NSLog(@"already main %@", [NSApp mainWindow]);
|
||||
}
|
||||
[self makeMainWindow];
|
||||
[self makeKeyWindow];
|
||||
|
@ -111,7 +123,6 @@
|
|||
|
||||
[super sendEvent: theEvent];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation GormNSMenu
|
||||
|
|
Loading…
Reference in a new issue