diff --git a/ChangeLog b/ChangeLog index d64668c0d..c68235454 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2004-02-15 Fred Kiefer + + * Source/NSLayoutManager.m: + * Source/NSTextContainer.m: + * Source/NSTextStorage.m: + * Source/GSNibCompatibility.m: (NSWindowTemplate + More keyed dearchiving. + * Source/NSView.m: (-initWithCoder:) + Don't keyed decode next responder, as this gets set by superview + anyway. + 2004-02-14 23:05 Gregory John Casamento * Source/NSNib.[hm]: Corrected previous issue with NSNib. diff --git a/Source/GSNibCompatibility.m b/Source/GSNibCompatibility.m index 556b30fcd..c35b105dd 100644 --- a/Source/GSNibCompatibility.m +++ b/Source/GSNibCompatibility.m @@ -95,12 +95,49 @@ return self; } -- (id) initWithCoder: (NSCoder *)aCoder +- (id) initWithCoder: (NSCoder *)aDecoder { - [aCoder decodeValueOfObjCType: @encode(id) at: &_className]; - [aCoder decodeValueOfObjCType: @encode(id) at: &_parentClassName]; - [aCoder decodeValueOfObjCType: @encode(BOOL) at: &_deferFlag]; - return [super initWithCoder: aCoder]; + if ([aDecoder allowsKeyedCoding]) + { + NSRect screenRect = [aDecoder decodeRectForKey: @"NSScreenRect"]; + NSRect windowRect = [aDecoder decodeRectForKey: @"NSWindowRect"]; + NSString *viewClass = [aDecoder decodeObjectForKey: @"NSViewClass"]; + NSString *windowClass = [aDecoder decodeObjectForKey: @"NSWindowClass"]; + NSString *title = [aDecoder decodeObjectForKey: @"NSWindowTitle"]; + NSView *view = [aDecoder decodeObjectForKey: @"NSWindowView"]; + int flags = [aDecoder decodeIntForKey: @"NSWTFlags"]; + int style = [aDecoder decodeIntForKey: @"NSWindowStyleMask"]; + int backing = [aDecoder decodeIntForKey: @"NSWindowBacking"]; + + ASSIGN(_className, windowClass); + self = [self initWithContentRect: windowRect + styleMask: style + backing: backing + defer: NO + screen: nil]; + [self setContentView: view]; + + if ([aDecoder containsValueForKey: @"NSMinSize"]) + { + NSSize minSize = [aDecoder decodeSizeForKey: @"NSMinSize"]; + [self setMinSize: minSize]; + } + if ([aDecoder containsValueForKey: @"NSMaxSize"]) + { + NSSize maxSize = [aDecoder decodeSizeForKey: @"NSMaxSize"]; + [self setMaxSize: maxSize]; + } + [self setTitle: title]; + + return self; + } + else + { + [aDecoder decodeValueOfObjCType: @encode(id) at: &_className]; + [aDecoder decodeValueOfObjCType: @encode(id) at: &_parentClassName]; + [aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_deferFlag]; + return [super initWithCoder: aDecoder]; + } } - (void) encodeWithCoder: (NSCoder *)aCoder diff --git a/Source/NSLayoutManager.m b/Source/NSLayoutManager.m index 9f21605e8..e1cd0edd4 100644 --- a/Source/NSLayoutManager.m +++ b/Source/NSLayoutManager.m @@ -2139,5 +2139,37 @@ no_soft_invalidation: } +- (id) initWithCoder: (NSCoder*)aDecoder +{ + self = [self init]; + + if ([aDecoder allowsKeyedCoding]) + { + int i; + id delegate = [aDecoder decodeObjectForKey: @"NSDelegate"]; + int flags; + NSArray *array = [aDecoder decodeObjectForKey: @"NSTextContainers"]; + NSTextStorage *storage = [aDecoder decodeObjectForKey: @"NSTextStorage"]; + + if ([aDecoder containsValueForKey: @"NSLMFlags"]) + { + flags = [aDecoder decodeIntForKey: @"NSLMFlags"]; + // FIXME + } + [self setDelegate: delegate]; + [storage addLayoutManager: self]; + for (i = 0; i < [array count]; i++) + { + [self addTextContainer: [array objectAtIndex: i]]; + } + + return self; + } + else + { + return self; + } +} + @end diff --git a/Source/NSTextContainer.m b/Source/NSTextContainer.m index a7b6553b0..5656ac5ab 100644 --- a/Source/NSTextContainer.m +++ b/Source/NSTextContainer.m @@ -429,5 +429,33 @@ framework intact. return NSPointInRect(aPoint, _containerRect); } +- (id) initWithCoder: (NSCoder*)aDecoder +{ + if ([aDecoder allowsKeyedCoding]) + { + //NSLayoutManager *manager = [aDecoder decodeObjectForKey: @"NSLayoutManager"]; + NSTextView *view = [aDecoder decodeObjectForKey: @"NSTextView"]; + NSSize size = NSZeroSize; + + if ([aDecoder containsValueForKey: @"NSWidth"]) + { + size.width = [aDecoder decodeFloatForKey: @"NSWidth"]; + } + self = [self initWithContainerSize: size]; + if ([aDecoder containsValueForKey: @"NSTCFlags"]) + { + // FIXME + //int flags = [aDecoder decodeIntForKey: @"NSTCFlags"]; + } + // No need to set manager as the decoding of the layout manager does it + [self setTextView: view]; + return self; + } + else + { + return self; + } +} + @end /* NSTextContainer */ diff --git a/Source/NSTextStorage.m b/Source/NSTextStorage.m index 59e7bf5e8..4bf6a7c14 100644 --- a/Source/NSTextStorage.m +++ b/Source/NSTextStorage.m @@ -337,4 +337,21 @@ static NSNotificationCenter *nc = nil; [self fixAttributesInRange: range]; } +- (id) initWithCoder: (NSCoder*)aDecoder +{ + if ([aDecoder allowsKeyedCoding]) + { + id delegate = [aDecoder decodeObjectForKey: @"NSDelegate"]; + NSString *string = [aDecoder decodeObjectForKey: @"NSString"]; + + self = [self initWithString: string]; + [self setDelegate: delegate]; + } + else + { + self = [super initWithCoder: aDecoder]; + } + return self; +} + @end diff --git a/Source/NSView.m b/Source/NSView.m index 65dfc5fef..8d51915e8 100644 --- a/Source/NSView.m +++ b/Source/NSView.m @@ -3623,7 +3623,7 @@ static NSView* findByTag(NSView *view, int aTag, unsigned *level) if ([aDecoder allowsKeyedCoding]) { NSRect frame = NSZeroRect; - id next = [aDecoder decodeObjectForKey: @"NSNextResponder"]; + //id next = [aDecoder decodeObjectForKey: @"NSNextResponder"]; //NSView *superView = [aDecoder decodeObjectForKey: @"NSSuperview"]; NSView *nextKeyView = [aDecoder decodeObjectForKey: @"NSNextKeyView"]; NSArray *subViews = [aDecoder decodeObjectForKey: @"NSSubviews"]; @@ -3633,10 +3633,7 @@ static NSView* findByTag(NSView *view, int aTag, unsigned *level) frame = [aDecoder decodeRectForKey: @"NSFrame"]; } self = [self initWithFrame: frame]; - if (next != nil) - { - [self setNextResponder: next]; - } + if (subViews != nil) { NSEnumerator *enumerator = [subViews objectEnumerator];