* Source/NSApplication.m: Remove keys from initWithCoder: and

encodeWithCoder:.
	* Source/NSCell.m: Initialize the cell based on content in 
	initWithCoder:.
	* Source/NSFormCell.m: Removed unnecessary decoding of NSContents key
	in initWithCoder: since it is already done in NSCell.m.
	* Source/NSMatrix.m: initWithCoder:/encodeWithCoder: added 
	autosizesCells flag and clear flags which are not used
	prior to encoding.
	* Source/NSPopUpButtonCell.m: Implemented encoding in 
	encodeWithCoder:.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@23318 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Gregory John Casamento 2006-08-20 16:18:31 +00:00
parent 9381ab8eec
commit 3c5f004f90
6 changed files with 97 additions and 30 deletions

View file

@ -1,3 +1,17 @@
2006-08-20 12:14-EDT Gregory John Casamento <greg_casamento@yahoo.com>
* Source/NSApplication.m: Remove keys from initWithCoder: and
encodeWithCoder:.
* Source/NSCell.m: Initialize the cell based on content in
initWithCoder:.
* Source/NSFormCell.m: Removed unnecessary decoding of NSContents key
in initWithCoder: since it is already done in NSCell.m.
* Source/NSMatrix.m: initWithCoder:/encodeWithCoder: added
autosizesCells flag and clear flags which are not used
prior to encoding.
* Source/NSPopUpButtonCell.m: Implemented encoding in
encodeWithCoder:.
2006-08-19 15:56-EDT Gregory John Casamento <greg_casamento@yahoo.com>
* Source/NSBrowser.m: Added comment in encodeWithCoder:.

View file

@ -3294,9 +3294,14 @@ image.</p><p>See Also: -applicationIconImage</p>
[super encodeWithCoder: aCoder];
if([aCoder allowsKeyedCoding])
{
[aCoder encodeObject: _delegate forKey: @"NSDelegate"];
/*
if(_delegate != nil)
{
[aCoder encodeObject: _delegate forKey: @"NSDelegate"];
}
[aCoder encodeObject: _main_menu forKey: @"NSMainMenu"]; // ???
[aCoder encodeObject: _windows_menu forKey: @"NSWindowsMenu"]; // ???
*/
}
else
{
@ -3313,15 +3318,17 @@ image.</p><p>See Also: -applicationIconImage</p>
[super initWithCoder: aDecoder];
if([aDecoder allowsKeyedCoding])
{
/*
if([aDecoder containsValueForKey: @"NSDelegate"])
{
obj = [aDecoder decodeObjectForKey: @"NSDelegate"];
[self setDelegate: obj];
}
obj = [aDecoder decodeObjectForKey: @"NSMainMenu"]; // TODO_NIB: Verify this key!!
obj = [aDecoder decodeObjectForKey: @"NSMainMenu"];
[self setMainMenu: obj];
obj = [aDecoder decodeObjectForKey: @"NSWindowsMenu"]; // TODO_NIB: Verify this key!!
obj = [aDecoder decodeObjectForKey: @"NSWindowsMenu"];
[self setWindowsMenu: obj];
*/
}
else
{

View file

@ -2289,10 +2289,22 @@ static NSColor *shadowCol;
{
if ([aDecoder allowsKeyedCoding])
{
NSString *contents = [aDecoder decodeObjectForKey: @"NSContents"];
self = [self initTextCell: contents];
id contents = [aDecoder decodeObjectForKey: @"NSContents"];
// initialize based on content...
if([contents isKindOfClass: [NSString class]])
{
self = [self initTextCell: contents];
}
else if([contents isKindOfClass: [NSImage class]])
{
self = [self initImageCell: contents];
}
else
{
self = [self init];
}
if ([aDecoder containsValueForKey: @"NSCellFlags"])
{
unsigned long cFlags;

View file

@ -391,20 +391,29 @@ static NSColor *shadowCol;
- (void) encodeWithCoder: (NSCoder*)aCoder
{
BOOL tmp;
[super encodeWithCoder: aCoder];
tmp = _formcell_auto_title_width;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &tmp];
[aCoder encodeValueOfObjCType: @encode(float) at: &_displayedTitleWidth];
[aCoder encodeObject: _titleCell];
if([aCoder allowsKeyedCoding])
{
/*
if([self stringValue] != nil)
{
[aCoder encodeObject: [self stringValue] forKey: @"NSContents"];
}
*/
[aCoder encodeFloat: [self titleWidth] forKey: @"NSTitleWidth"];
[aCoder encodeObject: _titleCell forKey: @"NSTitleCell"];
}
else
{
BOOL tmp = _formcell_auto_title_width;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &tmp];
[aCoder encodeValueOfObjCType: @encode(float) at: &_displayedTitleWidth];
[aCoder encodeObject: _titleCell];
}
}
- (id) initWithCoder: (NSCoder*)aDecoder
{
BOOL tmp;
[super initWithCoder: aDecoder];
if ([aDecoder allowsKeyedCoding])
{
@ -423,6 +432,7 @@ static NSColor *shadowCol;
}
else
{
BOOL tmp;
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &tmp];
_formcell_auto_title_width = tmp;
[aDecoder decodeValueOfObjCType: @encode(float) at: &_displayedTitleWidth];

View file

@ -2698,6 +2698,15 @@ static SEL getSel;
matrixFlags.drawCellBackground = [self drawsCellBackground];
matrixFlags.drawBackground = [self drawsBackground];
matrixFlags.tabKeyTraversesCells = _tabKeyTraversesCells;
matrixFlags.autosizesCells = _autosizesCells;
// clear unused...
matrixFlags.autoScroll = 0;
matrixFlags.drawingAncestor = 0;
matrixFlags.tabKeyTraversesCellsExplicitly = 0;
matrixFlags.canSearchIncrementally = 0;
matrixFlags.unused = 0;
memcpy((void *)&mFlags,(void *)&matrixFlags,sizeof(unsigned int));
[aCoder encodeInt: mFlags forKey: @"NSMatrixFlags"];
@ -2806,6 +2815,7 @@ static SEL getSel;
[self setSelectionByRect: matrixFlags.selectionByRect];
[self setDrawsCellBackground: matrixFlags.drawCellBackground];
[self setDrawsBackground: matrixFlags.drawBackground];
_autosizesCells = matrixFlags.autosizesCells;
_tabKeyTraversesCells = matrixFlags.tabKeyTraversesCells;
}
if ([aDecoder containsValueForKey: @"NSNumCols"])

View file

@ -958,21 +958,36 @@ static NSImage *_pbc_image[2];
//
- (void) encodeWithCoder: (NSCoder*)aCoder
{
int flag;
[super encodeWithCoder: aCoder];
[aCoder encodeObject: _menu];
[aCoder encodeConditionalObject: [self selectedItem]];
flag = _pbcFlags.pullsDown;
[aCoder encodeValueOfObjCType: @encode(int) at: &flag];
flag = _pbcFlags.preferredEdge;
[aCoder encodeValueOfObjCType: @encode(int) at: &flag];
flag = _pbcFlags.usesItemFromMenu;
[aCoder encodeValueOfObjCType: @encode(int) at: &flag];
flag = _pbcFlags.altersStateOfSelectedItem;
[aCoder encodeValueOfObjCType: @encode(int) at: &flag];
flag = _pbcFlags.arrowPosition;
[aCoder encodeValueOfObjCType: @encode(int) at: &flag];
if([aCoder allowsKeyedCoding])
{
[aCoder encodeBool: [self altersStateOfSelectedItem] forKey: @"NSAltersState"];
[aCoder encodeBool: [self usesItemFromMenu] forKey: @"NSUsesItemFromMenu"];
[aCoder encodeInt: [self arrowPosition] forKey: @"NSArrowPosition"];
[aCoder encodeInt: [self preferredEdge] forKey: @"NSPreferredEdge"];
// encode the menu, if present.
if(_menu != nil)
{
[aCoder encodeObject: _menu forKey: @"NSMenu"];
}
}
else
{
int flag;
[aCoder encodeObject: _menu];
[aCoder encodeConditionalObject: [self selectedItem]];
flag = _pbcFlags.pullsDown;
[aCoder encodeValueOfObjCType: @encode(int) at: &flag];
flag = _pbcFlags.preferredEdge;
[aCoder encodeValueOfObjCType: @encode(int) at: &flag];
flag = _pbcFlags.usesItemFromMenu;
[aCoder encodeValueOfObjCType: @encode(int) at: &flag];
flag = _pbcFlags.altersStateOfSelectedItem;
[aCoder encodeValueOfObjCType: @encode(int) at: &flag];
flag = _pbcFlags.arrowPosition;
[aCoder encodeValueOfObjCType: @encode(int) at: &flag];
}
}
- (id) initWithCoder: (NSCoder*)aDecoder
@ -980,7 +995,6 @@ static NSImage *_pbc_image[2];
NSMenu *menu;
self = [super initWithCoder: aDecoder];
if ([aDecoder allowsKeyedCoding])
{
if ([aDecoder containsValueForKey: @"NSAltersState"])