Implement encoding for these objects and correct issue with font size encoding. It was encoded/decoded as an int when it should have been a float.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@23226 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Gregory John Casamento 2006-08-09 05:48:54 +00:00
parent 84d0296b74
commit 78bbf9e972
8 changed files with 113 additions and 58 deletions

View file

@ -1,3 +1,18 @@
2006-08-09 01:44-EDT Gregory John Casamento <greg_casamento@yahoo.com>
* Source/NSFont.m: Correct issue with size encoding in encodeWithCoder:
and initWithCoder:. Properly encode/decode as a float.
* Source/NSImageCell.m: Implement encodeWithCoder:.
* Source/NSImage.m: Comment out code in encodeWithCoder: which
encodes reps until can determine how to properly encode images.
* Source/NSImageView.m: implement encoding in encodeWithCoder:
* Source/NSScrollView.m: Don't encode headerClipView if it's
nil.
* Source/NSTextView.m: Properly encode background color in
NSTextViewSharedData.
* Source/NSView.m: Encoding corrections in initWithCoder: and
encodeWithCoder:.
2006-08-08 21:33-EDT Gregory John Casamento <greg_casamento@yahoo.com>
* Headers/Additions/GNUstepGUI/GSNibCompatibility.h

View file

@ -1137,7 +1137,7 @@ static BOOL flip_hack;
if ([aCoder allowsKeyedCoding])
{
[aCoder encodeObject: fontName forKey: @"NSName"];
[aCoder encodeInt: [self pointSize] forKey: @"NSSize"];
[aCoder encodeFloat: [self pointSize] forKey: @"NSSize"];
switch (role >> 1)
{
@ -1177,7 +1177,7 @@ static BOOL flip_hack;
if ([aDecoder allowsKeyedCoding])
{
NSString *name = [aDecoder decodeObjectForKey: @"NSName"];
int size = [aDecoder decodeIntForKey: @"NSSize"];
float size = [aDecoder decodeFloatForKey: @"NSSize"];
RELEASE(self);
if ([aDecoder containsValueForKey: @"NSfFlags"])

View file

@ -1482,6 +1482,7 @@ repd_for_rep(NSArray *_reps, NSImageRep *rep)
if([coder allowsKeyedCoding])
{
// FIXME: Not sure this is the way it goes...
/*
if(_flags.archiveByName == NO)
{
NSMutableArray *container = [NSMutableArray array];
@ -1501,6 +1502,7 @@ repd_for_rep(NSArray *_reps, NSImageRep *rep)
{
[coder encodeObject: _name forKey: @"NSImageName"];
}
*/
// encode the rest...
[coder encodeObject: _color forKey: @"NSColor"];

View file

@ -369,42 +369,52 @@ scaleProportionally(NSSize imageSize, NSRect canvasRect)
- (void) encodeWithCoder: (NSCoder *)aCoder
{
[super encodeWithCoder: aCoder];
[aCoder encodeValueOfObjCType: @encode(NSImageAlignment) at: &_imageAlignment];
[aCoder encodeValueOfObjCType: @encode(NSImageFrameStyle) at: &_frameStyle];
[aCoder encodeValueOfObjCType: @encode(NSImageScaling) at: &_imageScaling];
[aCoder encodeSize: _original_image_size];
if([aCoder allowsKeyedCoding])
{
[aCoder encodeInt: _imageAlignment forKey: @"NSAlign"];
[aCoder encodeInt: _imageScaling forKey: @"NSScale"];
[aCoder encodeInt: _frameStyle forKey: @"NSStyle"];
[aCoder encodeBool: NO forKey: @"NSAnimates"];
}
else
{
[aCoder encodeValueOfObjCType: @encode(NSImageAlignment) at: &_imageAlignment];
[aCoder encodeValueOfObjCType: @encode(NSImageFrameStyle) at: &_frameStyle];
[aCoder encodeValueOfObjCType: @encode(NSImageScaling) at: &_imageScaling];
[aCoder encodeSize: _original_image_size];
}
}
- (id) initWithCoder: (NSCoder *)aDecoder
{
self = [super initWithCoder: aDecoder];
if ([aDecoder allowsKeyedCoding])
if((self = [super initWithCoder: aDecoder]) != nil)
{
if ([aDecoder containsValueForKey: @"NSAlign"])
{
[self setImageAlignment: [aDecoder decodeIntForKey: @"NSAlign"]];
if ([aDecoder allowsKeyedCoding])
{
if ([aDecoder containsValueForKey: @"NSAlign"])
{
[self setImageAlignment: [aDecoder decodeIntForKey: @"NSAlign"]];
}
if ([aDecoder containsValueForKey: @"NSScale"])
{
[self setImageScaling: [aDecoder decodeIntForKey: @"NSScale"]];
}
if ([aDecoder containsValueForKey: @"NSStyle"])
{
[self setImageFrameStyle: [aDecoder decodeIntForKey: @"NSStyle"]];
}
if ([aDecoder containsValueForKey: @"NSAnimates"])
{
//BOOL animates = [aDecoder decodeBoolForKey: @"NSAnimates"];
}
}
if ([aDecoder containsValueForKey: @"NSScale"])
{
[self setImageScaling: [aDecoder decodeIntForKey: @"NSScale"]];
else
{
[aDecoder decodeValueOfObjCType: @encode(NSImageAlignment) at: &_imageAlignment];
[aDecoder decodeValueOfObjCType: @encode(NSImageFrameStyle) at: &_frameStyle];
[aDecoder decodeValueOfObjCType: @encode(NSImageScaling) at: &_imageScaling];
_original_image_size = [aDecoder decodeSize];
}
if ([aDecoder containsValueForKey: @"NSStyle"])
{
[self setImageFrameStyle: [aDecoder decodeIntForKey: @"NSStyle"]];
}
if ([aDecoder containsValueForKey: @"NSAnimates"])
{
//BOOL animates = [aDecoder decodeBoolForKey: @"NSAnimates"];
}
}
else
{
[aDecoder decodeValueOfObjCType: @encode(NSImageAlignment) at: &_imageAlignment];
[aDecoder decodeValueOfObjCType: @encode(NSImageFrameStyle) at: &_frameStyle];
[aDecoder decodeValueOfObjCType: @encode(NSImageScaling) at: &_imageScaling];
_original_image_size = [aDecoder decodeSize];
}
return self;
}

View file

@ -279,8 +279,15 @@ static Class imageCellClass;
- (void) encodeWithCoder: (NSCoder *)aCoder
{
[super encodeWithCoder: aCoder];
[aCoder encodeConditionalObject: _target];
[aCoder encodeValueOfObjCType: @encode(SEL) at: &_action];
if([aCoder allowsKeyedCoding])
{
[aCoder encodeBool: [self isEditable] forKey: @"NSEditable"];
}
else
{
[aCoder encodeConditionalObject: _target];
[aCoder encodeValueOfObjCType: @encode(SEL) at: &_action];
}
}
- (id) initWithCoder: (NSCoder *)aDecoder
@ -290,7 +297,6 @@ static Class imageCellClass;
if ([aDecoder allowsKeyedCoding])
{
//NSArray *dragType = [aDecoder decodeObjectForKey: @"NSDragTypes"];
if ([aDecoder containsValueForKey: @"NSEditable"])
{
[self setEditable: [aDecoder decodeBoolForKey: @"NSEditable"]];

View file

@ -1220,6 +1220,25 @@ static float scrollerWidth;
if([aCoder allowsKeyedCoding])
{
unsigned long flags = 0;
GSScrollViewFlags scrollViewFlags;
[aCoder encodeObject: _horizScroller forKey: @"NSHScroller"];
[aCoder encodeObject: _vertScroller forKey: @"NSVScroller"];
[aCoder encodeObject: _contentView forKey: @"NSContentView"];
// only encode this, if it's not null...
if(_headerClipView != nil)
{
[aCoder encodeObject: _headerClipView forKey: @"NSHeaderClipView"];
}
scrollViewFlags.hasVScroller = _hasVertScroller;
scrollViewFlags.hasHScroller = _hasHorizScroller;
scrollViewFlags.border = _borderType;
memcpy((void *)&flags, (void *)&scrollViewFlags,sizeof(unsigned long));
[aCoder encodeInt: flags forKey: @"NSsFlags"];
}
else
{

View file

@ -200,7 +200,7 @@ Interface for a bunch of internal methods that need to be cleaned up.
{
if([coder allowsKeyedCoding])
{
[coder encodeObject: backgroundColor forKey: @"NSBackgoundColor"];
[coder encodeObject: backgroundColor forKey: @"NSBackgroundColor"];
[coder encodeObject: paragraphStyle forKey: @"NSDefaultParagraphStyle"];
[coder encodeInt: flags forKey: @"NSFlags"];
[coder encodeObject: markAttr forKey: @"NSMarkedAttributes"];

View file

@ -4018,29 +4018,7 @@ static NSView* findByTag(NSView *view, int aTag, unsigned *level)
_rFlags.flipped_view = [self isFlipped];
subs = [aDecoder decodeObjectForKey: @"NSSubviews"];
// iterate over subviews and put them into the view...
e = [subs objectEnumerator];
while ((sub = [e nextObject]) != nil)
{
NSAssert([sub window] == nil,
NSInternalInconsistencyException);
NSAssert([sub superview] == nil,
NSInternalInconsistencyException);
[sub viewWillMoveToWindow: _window];
[sub viewWillMoveToSuperview: self];
[sub setNextResponder: self];
[_sub_views addObject: sub];
_rFlags.has_subviews = 1;
[sub resetCursorRects];
[sub setNeedsDisplay: YES];
[sub _viewDidMoveToWindow];
[sub viewDidMoveToSuperview];
[self didAddSubview: sub];
}
RELEASE(subs);
// previous and next key views...
prevKeyView = [aDecoder decodeObjectForKey: @"NSPreviousKeyView"];
nextKeyView = [aDecoder decodeObjectForKey: @"NSNextKeyView"];
if (nextKeyView != nil)
@ -4061,6 +4039,31 @@ static NSView* findByTag(NSView *view, int aTag, unsigned *level)
[self setAutoresizesSubviews: ((vFlags & 0x100) == 0x100)];
[self setHidden: ((vFlags & 0x80000000) == 0x80000000)];
}
// iterate over subviews and put them into the view...
subs = [aDecoder decodeObjectForKey: @"NSSubviews"];
e = [subs objectEnumerator];
while ((sub = [e nextObject]) != nil)
{
NSAssert([sub window] == nil,
NSInternalInconsistencyException);
NSAssert([sub superview] == nil,
NSInternalInconsistencyException);
[sub viewWillMoveToWindow: _window];
[sub viewWillMoveToSuperview: self];
[sub setNextResponder: self];
[_sub_views addObject: sub];
_rFlags.has_subviews = 1;
[sub resetCursorRects];
[sub setNeedsDisplay: YES];
[sub _viewDidMoveToWindow];
[sub viewDidMoveToSuperview];
[self didAddSubview: sub];
}
RELEASE(subs);
// the superview...
[aDecoder decodeObjectForKey: @"NSSuperview"];
}
else
{