From adefb08ae64788d4a706acd06677f3feb6246920 Mon Sep 17 00:00:00 2001 From: Gregory John Casamento Date: Sun, 24 Aug 2008 17:20:16 +0000 Subject: [PATCH] Fixing standalone view handling. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/apps/gorm/trunk@26818 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 6 +++ GormCore/GormCustomView.m | 81 +++++++++++++++++++++++++++------------ GormCore/GormDocument.m | 4 +- GormCore/GormViewWindow.m | 2 +- 4 files changed, 65 insertions(+), 28 deletions(-) diff --git a/ChangeLog b/ChangeLog index 45ad1ebd..cdc882a0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2008-08-24 13:20-EDT Gregory John Casamento + + * GormCore/GormCustomView.m + * GormCore/GormDocument.m + * GormCore/GormViewWindow.m: Fixing handling of standalone views. + 2008-07-20 09:32-EDT Gregory John Casamento * GormObjCHeaderParser/OCIVar.m diff --git a/GormCore/GormCustomView.m b/GormCore/GormCustomView.m index 7a4a9fa2..834d4c85 100644 --- a/GormCore/GormCustomView.m +++ b/GormCore/GormCustomView.m @@ -105,45 +105,76 @@ return cls; } +- (BOOL) _classNameIsSet +{ + if([className isEqualToString: @"CustomView"] || + [className isEqualToString: @""] || className == nil) + { + return NO; + } + return YES; +} + +- (Class) classForCoder +{ + if([self _classNameIsSet]) + { + return [NSView class]; + } + return [self class]; +} + /* * This needs to be coded like a GSNibItem. How do we make sure this * tracks changes in GSNibItem coding? */ - (void) encodeWithCoder: (NSCoder*)aCoder { - if([aCoder allowsKeyedCoding]) + if([self _classNameIsSet] && [self superview] != nil) { - GormClassManager *classManager = [(id)NSApp classManager]; - NSString *extension = nil; - - ASSIGNCOPY(extension,[classManager nonCustomSuperClassOf: className]); - - [aCoder encodeObject: className forKey: @"NSClassName"]; - [aCoder encodeRect: [self frame] forKey: @"NSFrame"]; - - if(extension != nil) + if([aCoder allowsKeyedCoding]) { - [aCoder encodeObject: extension forKey: @"NSExtension"]; + GormClassManager *classManager = [(id)NSApp classManager]; + NSString *extension = nil; + + ASSIGNCOPY(extension,[classManager nonCustomSuperClassOf: className]); + + [aCoder encodeObject: className forKey: @"NSClassName"]; + [aCoder encodeRect: [self frame] forKey: @"NSFrame"]; + + if(extension != nil) + { + [aCoder encodeObject: extension forKey: @"NSExtension"]; + } + + if([self nextResponder] != nil) + { + [aCoder encodeObject: [self nextResponder] forKey: @"NSNextResponder"]; + } + + if([self superview] != nil) + { + [aCoder encodeObject: [self superview] forKey: @"NSSuperview"]; + } + + RELEASE(extension); } - - if([self nextResponder] != nil) + else { - [aCoder encodeObject: [self nextResponder] forKey: @"NSNextResponder"]; + [aCoder encodeObject: [self stringValue]]; + [aCoder encodeRect: _frame]; + [aCoder encodeValueOfObjCType: @encode(unsigned int) + at: &_autoresizingMask]; } - - if([self superview] != nil) - { - [aCoder encodeObject: [self superview] forKey: @"NSSuperview"]; - } - - RELEASE(extension); } else { - [aCoder encodeObject: [self stringValue]]; - [aCoder encodeRect: _frame]; - [aCoder encodeValueOfObjCType: @encode(unsigned int) - at: &_autoresizingMask]; + if([aCoder allowsKeyedCoding] == NO) + { + NSView *temp = [[NSView alloc] initWithFrame: [self frame]]; + [temp setNextResponder: [self nextResponder]]; + [(NSArchiver *)aCoder replaceObject: self withObject: temp]; + } } } diff --git a/GormCore/GormDocument.m b/GormCore/GormDocument.m index 3648190a..ecda4553 100644 --- a/GormCore/GormDocument.m +++ b/GormCore/GormDocument.m @@ -2820,10 +2820,10 @@ static void _real_close(GormDocument *self, */ - (NSString *) description { - return [NSString stringWithFormat: @"<%s: %lx> = %@", + return [NSString stringWithFormat: @"<%s: %lx> = <>", GSClassNameFromObject(self), (unsigned long)self, - nameTable]; + nameTable, connections]; } /** diff --git a/GormCore/GormViewWindow.m b/GormCore/GormViewWindow.m index 122bc30a..b85e6257 100644 --- a/GormCore/GormViewWindow.m +++ b/GormCore/GormViewWindow.m @@ -145,7 +145,7 @@ [self setTitle: title]; [self setFrame: NSMakeRect(0,0,400,300) display: YES]; - // [self setBackgroundColor: [NSColor redColor]]; + [self setBackgroundColor: [NSColor darkGrayColor]]; [self setReleasedWhenClosed: NO]; [self setView: view]; }