* 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>
* Source/NSButtonCell.m: Improvements in both initWithCoder: and

View file

@ -152,30 +152,43 @@ static NSTextFieldCell *titleCell;
- (void) encodeWithCoder: (NSCoder *)aCoder
{
int dummy = 0;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_isLoaded];
[aCoder encodeObject: _columnScrollView];
[aCoder encodeObject: _columnMatrix];
[aCoder encodeValueOfObjCType: @encode(int) at: &dummy];
[aCoder encodeObject: _columnTitle];
if([aCoder allowsKeyedCoding])
{
}
else
{
int dummy = 0;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_isLoaded];
[aCoder encodeObject: _columnScrollView];
[aCoder encodeObject: _columnMatrix];
[aCoder encodeValueOfObjCType: @encode(int) at: &dummy];
[aCoder encodeObject: _columnTitle];
}
}
- (id) initWithCoder: (NSCoder *)aDecoder
{
int dummy = 0;
if([aDecoder allowsKeyedCoding])
{
}
else
{
int dummy = 0;
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_isLoaded];
_columnScrollView = [aDecoder decodeObject];
if (_columnScrollView)
RETAIN(_columnScrollView);
_columnMatrix = [aDecoder decodeObject];
if (_columnMatrix)
RETAIN(_columnMatrix);
[aDecoder decodeValueOfObjCType: @encode(int) at: &dummy];
_columnTitle = [aDecoder decodeObject];
if (_columnTitle)
RETAIN(_columnTitle);
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_isLoaded];
_columnScrollView = [aDecoder decodeObject];
if (_columnScrollView)
RETAIN(_columnScrollView);
_columnMatrix = [aDecoder decodeObject];
if (_columnMatrix)
RETAIN(_columnMatrix);
[aDecoder decodeValueOfObjCType: @encode(int) at: &dummy];
_columnTitle = [aDecoder decodeObject];
if (_columnTitle)
RETAIN(_columnTitle);
}
return self;
}
@ -2488,51 +2501,77 @@ static NSTextFieldCell *titleCell;
- (void) encodeWithCoder: (NSCoder*)aCoder
{
[super encodeWithCoder: aCoder];
if([aCoder allowsKeyedCoding])
{
[aCoder encodeObject: _browserCellPrototype forKey: @"NSCellPrototype"];
[aCoder encodeObject: [self _getTitleOfColumn: 0] forKey: @"NSFirstColumnTitle"];
[aCoder encodeObject: _pathSeparator forKey: @"NSPathSeparator"];
// Here to keep compatibility with old version
[aCoder encodeObject: nil];
[aCoder encodeObject:_browserCellPrototype];
[aCoder encodeObject: NSStringFromClass (_browserMatrixClass)];
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 encodeObject:_pathSeparator];
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_isLoaded];
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_allowsBranchSelection];
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_allowsEmptySelection];
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_allowsMultipleSelection];
[aCoder encodeValueOfObjCType: @encode(int) at: &_maxVisibleColumns];
[aCoder encodeValueOfObjCType: @encode(float) at: &_minColumnWidth];
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_reusesColumns];
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_separatesColumns];
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_takesTitleFromPreviousColumn];
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_isTitled];
[aCoder encodeObject:_horizontalScroller];
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_hasHorizontalScroller];
[aCoder encodeRect: _scrollerRect];
[aCoder encodeSize: _columnSize];
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_acceptsArrowKeys];
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_sendsActionOnArrowKeys];
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_acceptsAlphaNumericalKeys];
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_sendsActionOnAlphaNumericalKeys];
[aCoder encodeConditionalObject:_browserDelegate];
[aCoder encodeValueOfObjCType: @encode(SEL) at: &_doubleAction];
[aCoder encodeConditionalObject: _target];
[aCoder encodeValueOfObjCType: @encode(SEL) at: &_action];
[aCoder encodeObject: _browserColumns];
// Just encode the number of columns and the first visible
// and rebuild the browser columns on the decoding side
{
int colCount = [_browserColumns count];
[aCoder encodeValueOfObjCType: @encode(int) at: &colCount];
[aCoder encodeValueOfObjCType: @encode(int) at: &_firstVisibleColumn];
}
[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
[aCoder encodeObject: nil];
[aCoder encodeObject:_browserCellPrototype];
[aCoder encodeObject: NSStringFromClass (_browserMatrixClass)];
[aCoder encodeObject:_pathSeparator];
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_isLoaded];
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_allowsBranchSelection];
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_allowsEmptySelection];
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_allowsMultipleSelection];
[aCoder encodeValueOfObjCType: @encode(int) at: &_maxVisibleColumns];
[aCoder encodeValueOfObjCType: @encode(float) at: &_minColumnWidth];
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_reusesColumns];
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_separatesColumns];
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_takesTitleFromPreviousColumn];
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_isTitled];
[aCoder encodeObject:_horizontalScroller];
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_hasHorizontalScroller];
[aCoder encodeRect: _scrollerRect];
[aCoder encodeSize: _columnSize];
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_acceptsArrowKeys];
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_sendsActionOnArrowKeys];
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_acceptsAlphaNumericalKeys];
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_sendsActionOnAlphaNumericalKeys];
[aCoder encodeConditionalObject:_browserDelegate];
[aCoder encodeValueOfObjCType: @encode(SEL) at: &_doubleAction];
[aCoder encodeConditionalObject: _target];
[aCoder encodeValueOfObjCType: @encode(SEL) at: &_action];
[aCoder encodeObject: _browserColumns];
// Just encode the number of columns and the first visible
// and rebuild the browser columns on the decoding side
{
int colCount = [_browserColumns count];
[aCoder encodeValueOfObjCType: @encode(int) at: &colCount];
[aCoder encodeValueOfObjCType: @encode(int) at: &_firstVisibleColumn];
}
}
}
- (id) initWithCoder: (NSCoder*)aDecoder
@ -2544,7 +2583,7 @@ static NSTextFieldCell *titleCell;
NSCell *proto = [aDecoder decodeObjectForKey: @"NSCellPrototype"];
NSString *title = [aDecoder decodeObjectForKey: @"NSFirstColumnTitle"];
NSString *sep = [aDecoder decodeObjectForKey: @"NSPathSeparator"];
int flags;
long flags;
// start //
NSSize bs;
@ -2615,16 +2654,16 @@ static NSTextFieldCell *titleCell;
{
flags = [aDecoder decodeIntForKey: @"NSBrFlags"];
[self setHasHorizontalScroller: (flags & 0x10000)];
[self setAllowsEmptySelection: !(flags & 0x20000)];
[self setSendsActionOnArrowKeys: (flags & 0x40000)];
[self setAcceptsArrowKeys: (flags & 0x100000)];
[self setSeparatesColumns: (flags & 0x4000000)];
[self setTakesTitleFromPreviousColumn: (flags & 0x8000000)];
[self setTitled: (flags & 0x10000000)];
[self setReusesColumns: (flags & 0x20000000)];
[self setAllowsBranchSelection: (flags & 0x40000000)];
[self setAllowsMultipleSelection: (flags & 0x80000000)];
[self setHasHorizontalScroller: ((flags & 0x10000) == 0x10000)];
[self setAllowsEmptySelection: !((flags & 0x20000) == 0x20000)];
[self setSendsActionOnArrowKeys: ((flags & 0x40000) == 0x40000)];
[self setAcceptsArrowKeys: ((flags & 0x100000) == 0x100000)];
[self setSeparatesColumns: ((flags & 0x4000000) == 0x4000000)];
[self setTakesTitleFromPreviousColumn: ((flags & 0x8000000) == 0x8000000)];
[self setTitled: ((flags & 0x10000000) == 0x10000000)];
[self setReusesColumns: ((flags & 0x20000000) == 0x20000000)];
[self setAllowsBranchSelection: ((flags & 0x40000000) == 0x40000000)];
[self setAllowsMultipleSelection: ((flags & 0x80000000) == 0x80000000)];
}
if ([aDecoder containsValueForKey: @"NSNumberOfVisibleColumns"])

View file

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

View file

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