* Source/NSBrowserCell.m: Improved encoding and decoding in

encodeWithCoder: and initWithCoder:
	* Source/NSBrowser.m: Improved encoding and decoding in
	encodeWithCoder: and initWithCoder:
	* Source/NSScrollView.m: Improved encoding and decoding in
	encodeWithCoder: and initWithCoder:


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@23315 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
gcasa 2006-08-19 14:34:52 +00:00
parent e97c9a158f
commit d24ee43d13
4 changed files with 137 additions and 81 deletions

View file

@ -1,3 +1,12 @@
2006-08-19 10:33-EDT Gregory John Casamento <greg_casamento@yahoo.com>
* Source/NSBrowserCell.m: Improved encoding and decoding in
encodeWithCoder: and initWithCoder:
* Source/NSBrowser.m: Improved encoding and decoding in
encodeWithCoder: and initWithCoder:
* Source/NSScrollView.m: Improved encoding and decoding in
encodeWithCoder: and initWithCoder:
2006-08-17 00:54-EDT Gregory John Casamento <greg_casamento@yahoo.com> 2006-08-17 00:54-EDT Gregory John Casamento <greg_casamento@yahoo.com>
* Source/NSButtonCell.m: Improvements in both initWithCoder: and * Source/NSButtonCell.m: Improvements in both initWithCoder: and

View file

@ -152,6 +152,11 @@ static NSTextFieldCell *titleCell;
- (void) encodeWithCoder: (NSCoder *)aCoder - (void) encodeWithCoder: (NSCoder *)aCoder
{ {
if([aCoder allowsKeyedCoding])
{
}
else
{
int dummy = 0; int dummy = 0;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_isLoaded]; [aCoder encodeValueOfObjCType: @encode(BOOL) at: &_isLoaded];
@ -159,10 +164,17 @@ static NSTextFieldCell *titleCell;
[aCoder encodeObject: _columnMatrix]; [aCoder encodeObject: _columnMatrix];
[aCoder encodeValueOfObjCType: @encode(int) at: &dummy]; [aCoder encodeValueOfObjCType: @encode(int) at: &dummy];
[aCoder encodeObject: _columnTitle]; [aCoder encodeObject: _columnTitle];
}
} }
- (id) initWithCoder: (NSCoder *)aDecoder - (id) initWithCoder: (NSCoder *)aDecoder
{ {
if([aDecoder allowsKeyedCoding])
{
}
else
{
int dummy = 0; int dummy = 0;
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_isLoaded]; [aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_isLoaded];
@ -176,6 +188,7 @@ static NSTextFieldCell *titleCell;
_columnTitle = [aDecoder decodeObject]; _columnTitle = [aDecoder decodeObject];
if (_columnTitle) if (_columnTitle)
RETAIN(_columnTitle); RETAIN(_columnTitle);
}
return self; return self;
} }
@ -2488,7 +2501,33 @@ static NSTextFieldCell *titleCell;
- (void) encodeWithCoder: (NSCoder*)aCoder - (void) encodeWithCoder: (NSCoder*)aCoder
{ {
[super encodeWithCoder: aCoder]; [super encodeWithCoder: aCoder];
if([aCoder allowsKeyedCoding])
{
[aCoder encodeObject: _browserCellPrototype forKey: @"NSCellPrototype"];
[aCoder encodeObject: [self _getTitleOfColumn: 0] forKey: @"NSFirstColumnTitle"];
[aCoder encodeObject: _pathSeparator forKey: @"NSPathSeparator"];
long flags = 0;
flags |= [self hasHorizontalScroller] ? 0x10000 : 0;
flags |= ([self allowsEmptySelection] == NO) ? 0x20000 : 0;
flags |= [self sendsActionOnArrowKeys] ? 0x40000 : 0;
flags |= [self acceptsArrowKeys] ? 0x100000 : 0;
flags |= [self separatesColumns] ? 0x4000000 : 0;
flags |= [self takesTitleFromPreviousColumn] ? 0x8000000 : 0;
flags |= [self isTitled] ? 0x10000000 : 0;
flags |= [self reusesColumns] ? 0x20000000 : 0;
flags |= [self allowsBranchSelection] ? 0x40000000 : 0;
flags |= [self allowsMultipleSelection] ? 0x80000000 : 0;
[aCoder encodeInt: flags forKey: @"NSBrFlags"];
[aCoder encodeInt: _maxVisibleColumns forKey: @"NSNumberOfVisibleColumns"];
[aCoder encodeFloat: _minColumnWidth forKey: @"NSMinColumnWidth"];
//[aCoder encodeInt: columnResizingType forKey: @"NSColumnResizingType"]];
//[aCoder encodeInt: prefWidth forKey: @"NSPreferedColumnWidth"];
}
else
{
// Here to keep compatibility with old version // Here to keep compatibility with old version
[aCoder encodeObject: nil]; [aCoder encodeObject: nil];
[aCoder encodeObject:_browserCellPrototype]; [aCoder encodeObject:_browserCellPrototype];
@ -2532,7 +2571,7 @@ static NSTextFieldCell *titleCell;
[aCoder encodeValueOfObjCType: @encode(int) at: &colCount]; [aCoder encodeValueOfObjCType: @encode(int) at: &colCount];
[aCoder encodeValueOfObjCType: @encode(int) at: &_firstVisibleColumn]; [aCoder encodeValueOfObjCType: @encode(int) at: &_firstVisibleColumn];
} }
}
} }
- (id) initWithCoder: (NSCoder*)aDecoder - (id) initWithCoder: (NSCoder*)aDecoder
@ -2544,7 +2583,7 @@ static NSTextFieldCell *titleCell;
NSCell *proto = [aDecoder decodeObjectForKey: @"NSCellPrototype"]; NSCell *proto = [aDecoder decodeObjectForKey: @"NSCellPrototype"];
NSString *title = [aDecoder decodeObjectForKey: @"NSFirstColumnTitle"]; NSString *title = [aDecoder decodeObjectForKey: @"NSFirstColumnTitle"];
NSString *sep = [aDecoder decodeObjectForKey: @"NSPathSeparator"]; NSString *sep = [aDecoder decodeObjectForKey: @"NSPathSeparator"];
int flags; long flags;
// start // // start //
NSSize bs; NSSize bs;
@ -2615,16 +2654,16 @@ static NSTextFieldCell *titleCell;
{ {
flags = [aDecoder decodeIntForKey: @"NSBrFlags"]; flags = [aDecoder decodeIntForKey: @"NSBrFlags"];
[self setHasHorizontalScroller: (flags & 0x10000)]; [self setHasHorizontalScroller: ((flags & 0x10000) == 0x10000)];
[self setAllowsEmptySelection: !(flags & 0x20000)]; [self setAllowsEmptySelection: !((flags & 0x20000) == 0x20000)];
[self setSendsActionOnArrowKeys: (flags & 0x40000)]; [self setSendsActionOnArrowKeys: ((flags & 0x40000) == 0x40000)];
[self setAcceptsArrowKeys: (flags & 0x100000)]; [self setAcceptsArrowKeys: ((flags & 0x100000) == 0x100000)];
[self setSeparatesColumns: (flags & 0x4000000)]; [self setSeparatesColumns: ((flags & 0x4000000) == 0x4000000)];
[self setTakesTitleFromPreviousColumn: (flags & 0x8000000)]; [self setTakesTitleFromPreviousColumn: ((flags & 0x8000000) == 0x8000000)];
[self setTitled: (flags & 0x10000000)]; [self setTitled: ((flags & 0x10000000) == 0x10000000)];
[self setReusesColumns: (flags & 0x20000000)]; [self setReusesColumns: ((flags & 0x20000000) == 0x20000000)];
[self setAllowsBranchSelection: (flags & 0x40000000)]; [self setAllowsBranchSelection: ((flags & 0x40000000) == 0x40000000)];
[self setAllowsMultipleSelection: (flags & 0x80000000)]; [self setAllowsMultipleSelection: ((flags & 0x80000000) == 0x80000000)];
} }
if ([aDecoder containsValueForKey: @"NSNumberOfVisibleColumns"]) if ([aDecoder containsValueForKey: @"NSNumberOfVisibleColumns"])

View file

@ -338,14 +338,20 @@ static NSFont *_leafFont;
*/ */
- (void) encodeWithCoder: (NSCoder*)aCoder - (void) encodeWithCoder: (NSCoder*)aCoder
{ {
BOOL tmp;
[super encodeWithCoder: aCoder]; [super encodeWithCoder: aCoder];
if([aCoder allowsKeyedCoding])
{
// simply encodes prescence...
}
else
{
BOOL tmp;
tmp = _browsercell_is_leaf; tmp = _browsercell_is_leaf;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &tmp]; [aCoder encodeValueOfObjCType: @encode(BOOL) at: &tmp];
tmp = _browsercell_is_loaded; tmp = _browsercell_is_loaded;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &tmp]; [aCoder encodeValueOfObjCType: @encode(BOOL) at: &tmp];
[aCoder encodeObject: _alternateImage]; [aCoder encodeObject: _alternateImage];
}
} }
- (id) initWithCoder: (NSCoder*)aDecoder - (id) initWithCoder: (NSCoder*)aDecoder
@ -354,7 +360,7 @@ static NSFont *_leafFont;
if ([aDecoder allowsKeyedCoding]) if ([aDecoder allowsKeyedCoding])
{ {
// Nothing special // Nothing to decode...
} }
else else
{ {

View file

@ -1236,6 +1236,8 @@ static float scrollerWidth;
scrollViewFlags.hasVScroller = _hasVertScroller; scrollViewFlags.hasVScroller = _hasVertScroller;
scrollViewFlags.hasHScroller = _hasHorizScroller; scrollViewFlags.hasHScroller = _hasHorizScroller;
scrollViewFlags.border = _borderType; scrollViewFlags.border = _borderType;
scrollViewFlags.__unused4 = 0;
scrollViewFlags.__unused0 = 0;
memcpy((void *)&flags, (void *)&scrollViewFlags,sizeof(unsigned long)); memcpy((void *)&flags, (void *)&scrollViewFlags,sizeof(unsigned long));
[aCoder encodeInt: flags forKey: @"NSsFlags"]; [aCoder encodeInt: flags forKey: @"NSsFlags"];