From 4ff4b72168ca298f766d9bb2fb5f8c525ffb5795 Mon Sep 17 00:00:00 2001 From: Gregory John Casamento Date: Sat, 31 Jan 2009 23:37:33 +0000 Subject: [PATCH] Allow addition of plain NSView to gorm file. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/apps/gorm/trunk@27748 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 5 ++ GormCore/GormCustomView.m | 102 +++++++++++++++----------------------- 2 files changed, 45 insertions(+), 62 deletions(-) diff --git a/ChangeLog b/ChangeLog index ccb7db48..bd676ec9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2009-01-31 18:45-EST Gregory John Casamento + + * GormCore/GormCustomView.m: Allow addition of plain NSView to + a gorm file. + 2009-01-25 09:47-EST Gregory John Casamento * GormCore/GormViewWindow.m: Change the color used for standalone diff --git a/GormCore/GormCustomView.m b/GormCore/GormCustomView.m index df7789dd..35db270a 100644 --- a/GormCore/GormCustomView.m +++ b/GormCore/GormCustomView.m @@ -36,6 +36,21 @@ @class GSCustomView; +@interface CustomView : NSView +@end + +@implementation CustomView +- (id) initWithFrame: (NSRect)frame +{ + if((self = [super initWithFrame: frame]) != nil) + { + // Replace the CustomView with an NSView of the same dimensions. + self = [[NSView alloc] initWithFrame: frame]; + } + return self; +} +@end + @implementation GormCustomView - (id)initWithFrame:(NSRect)frameRect @@ -105,83 +120,46 @@ 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([self _classNameIsSet]) + if([aCoder allowsKeyedCoding]) { - */ - if([aCoder allowsKeyedCoding]) + 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) { - 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); + [aCoder encodeObject: extension forKey: @"NSExtension"]; } - else + + if([self nextResponder] != nil) { - [aCoder encodeObject: [self stringValue]]; - [aCoder encodeRect: _frame]; - [aCoder encodeValueOfObjCType: @encode(unsigned int) - at: &_autoresizingMask]; + [aCoder encodeObject: [self nextResponder] forKey: @"NSNextResponder"]; } - /* + + if([self superview] != nil) + { + [aCoder encodeObject: [self superview] forKey: @"NSSuperview"]; + } + + RELEASE(extension); } else { - if([aCoder allowsKeyedCoding] == NO) - { - NSView *temp = [[NSView alloc] initWithFrame: [self frame]]; - [temp setNextResponder: [self nextResponder]]; - [(NSArchiver *)aCoder replaceObject: self withObject: temp]; - } + [aCoder encodeObject: [self stringValue]]; + [aCoder encodeRect: _frame]; + [aCoder encodeValueOfObjCType: @encode(unsigned int) + at: &_autoresizingMask]; } - */ } - (id) initWithCoder: (NSCoder*)aCoder