Implemented encoding/decoding

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@7375 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Nicola Pero 2000-09-04 22:59:23 +00:00
parent 9532564638
commit 93a9b4e1ad
2 changed files with 66 additions and 0 deletions

View file

@ -415,4 +415,33 @@
return (_documentView != nil) ? [_documentView becomeFirstResponder] : NO;
}
/*
* NSCoding protocol
*/
- (void) encodeWithCoder: (NSCoder*)aCoder
{
[super encodeWithCoder: aCoder];
[aCoder encodeObject: _backgroundColor];
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_copiesOnScroll];
[aCoder encodeObject: _cursor];
[aCoder encodeObject: _documentView];
}
- (id) initWithCoder: (NSCoder*)aDecoder
{
NSView *document;
self = [super initWithCoder: aDecoder];
[self setAutoresizesSubviews: YES];
[aDecoder decodeValueOfObjCType: @encode(id) at: &_backgroundColor];
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_copiesOnScroll];
[aDecoder decodeValueOfObjCType: @encode(id) at: &_cursor];
document = [aDecoder decodeObject];
[self setDocumentView: document];
return self;
}
@end

View file

@ -136,10 +136,47 @@ static NSColor *scrollBarColor = nil;
- (void) encodeWithCoder: (NSCoder*)aCoder
{
[super encodeWithCoder: aCoder];
[aCoder encodeValueOfObjCType: @encode(unsigned int) at: &_arrowsPosition];
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_isEnabled];
[aCoder encodeConditionalObject: _target];
[aCoder encodeValueOfObjCType: @encode(SEL) at: &_action];
/* We do not save float value, knob proportion. */
}
- (id) initWithCoder: (NSCoder*)aDecoder
{
self = [super initWithCoder: aDecoder];
if (_frame.size.width > _frame.size.height)
{
_isHorizontal = YES;
}
else
{
_isHorizontal = NO;
}
if (_isHorizontal)
{
_floatValue = 0.0;
}
else
{
_floatValue = 1.0;
}
_hitPart = NSScrollerNoPart;
[aDecoder decodeValueOfObjCType: @encode(unsigned int) at: &_arrowsPosition];
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_isEnabled];
[aDecoder decodeValueOfObjCType: @encode(id) at: &_target];
[aDecoder decodeValueOfObjCType: @encode(SEL) at: &_action];
[self drawParts];
[self checkSpaceForParts];
return self;
}