mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-23 07:00:46 +00:00
Additional keyed archiving implementation.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@23026 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
b7a6db5b82
commit
1c011de1a5
11 changed files with 429 additions and 170 deletions
22
ChangeLog
22
ChangeLog
|
@ -1,3 +1,25 @@
|
|||
2006-06-04 01:09 Gregory John Casamento <greg_casamento@yahoo.com>
|
||||
|
||||
* Source/GSHbox.m: Implemented keyed coding.
|
||||
* Source/GSNibCompatibility.m: Added private method to help
|
||||
better decode keys/values in the nib data structures.
|
||||
* Source/GSTable.m: Implemented keyed coding.
|
||||
* Source/GSTextStorage.m: Added code to skip existing
|
||||
coding method contents, if the coder is a keyed coder.
|
||||
* Source/GSVbox.m: Implemented keyed coding.
|
||||
* Source/NSMenuView.m: Added code to skip coding, if
|
||||
it is a keyed coder.
|
||||
* Source/NSPanel.m: Added comment indicating that the
|
||||
call to the superclass initWithCoder method should throw
|
||||
an exception per documentation.
|
||||
* Source/NSPrinter.m: Added if to skip the coder logic,
|
||||
if using a keyed coder.
|
||||
* Source/NSStepper.m: Removed dummy initWithCoder:/encodeWithCoder:
|
||||
methods since they only called the superclass.
|
||||
* Source/NSWindow.m: Added exception called for in the
|
||||
documentation if NSWindow initWithCoder:/encodeWithCoder:
|
||||
is called with a keyed archiver.
|
||||
|
||||
2006-06-03 Fred Kiefer <FredKiefer@gmx.de>
|
||||
|
||||
* Source/NSPrinter.m (-interpretQuotedValue:, -gethex:): Better
|
||||
|
|
|
@ -160,15 +160,31 @@ enablingXResizing: (BOOL)aFlag
|
|||
-(void) encodeWithCoder: (NSCoder*)aCoder
|
||||
{
|
||||
[super encodeWithCoder: aCoder];
|
||||
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_haveViews];
|
||||
[aCoder encodeValueOfObjCType: @encode(float) at: &_defaultMinXMargin];
|
||||
if([aCoder allowsKeyedCoding])
|
||||
{
|
||||
[aCoder encodeBool: _haveViews forKey: @"GSHaveViews"];
|
||||
[aCoder encodeFloat: _defaultMinXMargin forKey: @"GSDefaultMinXMargin"];
|
||||
}
|
||||
else
|
||||
{
|
||||
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_haveViews];
|
||||
[aCoder encodeValueOfObjCType: @encode(float) at: &_defaultMinXMargin];
|
||||
}
|
||||
}
|
||||
|
||||
-(id) initWithCoder: (NSCoder*)aDecoder
|
||||
{
|
||||
[super initWithCoder: aDecoder];
|
||||
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_haveViews];
|
||||
[aDecoder decodeValueOfObjCType: @encode(float) at: &_defaultMinXMargin];
|
||||
if([aDecoder allowsKeyedCoding])
|
||||
{
|
||||
_haveViews = [aDecoder decodeBoolForKey: @"GSHaveViews"];
|
||||
_defaultMinXMargin = [aDecoder decodeFloatForKey: @"GSDefaultMinXMargin"];
|
||||
}
|
||||
else
|
||||
{
|
||||
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_haveViews];
|
||||
[aDecoder decodeValueOfObjCType: @encode(float) at: &_defaultMinXMargin];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
@end
|
||||
|
|
|
@ -820,6 +820,14 @@
|
|||
[coder encodeObject: (id)originalClassName forKey: @"NSOriginalClassName"];
|
||||
}
|
||||
}
|
||||
|
||||
- (void) dealloc
|
||||
{
|
||||
RELEASE(_className);
|
||||
RELEASE(_originalClassName);
|
||||
RELEASE(_template);
|
||||
[super dealloc];
|
||||
}
|
||||
@end
|
||||
|
||||
/* Correct some instances where the ":" is missing from the method name in the label */
|
||||
|
@ -944,20 +952,36 @@
|
|||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the values from the map in the same order as the keys.
|
||||
*/
|
||||
- (NSArray *) _valuesForKeys: (NSArray *)keys inMap: (NSMapTable *)map
|
||||
{
|
||||
NSMutableArray *result = [NSMutableArray array];
|
||||
NSEnumerator *en = [keys objectEnumerator];
|
||||
id key = nil;
|
||||
while((key = [en nextObject]) != nil)
|
||||
{
|
||||
id value = (id)NSMapGet(map,key);
|
||||
[result addObject: value];
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
- (void) encodeWithCoder: (NSCoder *)coder
|
||||
{
|
||||
if([coder allowsKeyedCoding])
|
||||
{
|
||||
NSArray *accessibilityOidsKeys = (NSArray *)NSAllMapTableKeys(_accessibilityOids);
|
||||
NSArray *accessibilityOidsValues = (NSArray *)NSAllMapTableValues(_accessibilityOids);
|
||||
NSArray *accessibilityOidsValues = [self _valuesForKeys: accessibilityOidsKeys inMap: _accessibilityOids];
|
||||
NSArray *classKeys = (NSArray *)NSAllMapTableKeys(_classes);
|
||||
NSArray *classValues = (NSArray *)NSAllMapTableValues(_classes);
|
||||
NSArray *classValues = [self _valuesForKeys: classKeys inMap: _classes];
|
||||
NSArray *nameKeys = (NSArray *)NSAllMapTableKeys(_names);
|
||||
NSArray *nameValues = (NSArray *)NSAllMapTableValues(_names);
|
||||
NSArray *nameValues = [self _valuesForKeys: nameKeys inMap: _names];
|
||||
NSArray *objectsKeys = (NSArray *)NSAllMapTableKeys(_objects);
|
||||
NSArray *objectsValues = (NSArray *)NSAllMapTableValues(_objects);
|
||||
NSArray *objectsValues = [self _valuesForKeys: objectsKeys inMap: _objects];
|
||||
NSArray *oidsKeys = (NSArray *)NSAllMapTableKeys(_oids);
|
||||
NSArray *oidsValues = (NSArray *)NSAllMapTableValues(_oids);
|
||||
NSArray *oidsValues = [self _valuesForKeys: oidsKeys inMap: _oids];
|
||||
|
||||
[coder encodeObject: (id)_accessibilityConnectors forKey: @"NSAccessibilityConnectors"];
|
||||
[coder encodeObject: (id) accessibilityOidsKeys forKey: @"NSAccessibilityOidsKeys"];
|
||||
|
|
320
Source/GSTable.m
320
Source/GSTable.m
|
@ -722,118 +722,248 @@
|
|||
int i;
|
||||
|
||||
[super encodeWithCoder: aCoder];
|
||||
[aCoder encodeValueOfObjCType: @encode(int) at: &_numberOfRows];
|
||||
[aCoder encodeValueOfObjCType: @encode(int) at: &_numberOfColumns];
|
||||
for (i = 0; i < _numberOfRows * _numberOfColumns; i++)
|
||||
if([aCoder allowsKeyedCoding])
|
||||
{
|
||||
[aCoder encodeObject: _jails[i]];
|
||||
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_havePrisoner[i]];
|
||||
[aCoder encodeInt: _numberOfRows forKey: @"GSNumberOfRows"];
|
||||
[aCoder encodeInt: _numberOfColumns forKey: @"GSNumberOfColumns"];
|
||||
for (i = 0; i < _numberOfRows * _numberOfColumns; i++)
|
||||
{
|
||||
[aCoder encodeObject: _jails[i] forKey:
|
||||
[NSString stringWithFormat: @"GSJail%d",i]];
|
||||
[aCoder encodeBool: _havePrisoner[i] forKey:
|
||||
[NSString stringWithFormat: @"GSHavePrisoner%d",i]];
|
||||
}
|
||||
[aCoder encodeFloat: _minXBorder forKey: @"GSMinXBorder"];
|
||||
[aCoder encodeFloat: _maxXBorder forKey: @"GSMaxXBorder"];
|
||||
[aCoder encodeFloat: _minYBorder forKey: @"GSMinYBorder"];
|
||||
[aCoder encodeFloat: _maxYBorder forKey: @"GSMaxYBorder"];
|
||||
for (i = 0; i < _numberOfColumns; i++)
|
||||
{
|
||||
[aCoder encodeBool: _expandColumn[i] forKey:
|
||||
[NSString stringWithFormat: @"GSExpandColumn%d",i]];
|
||||
[aCoder encodeFloat: _columnDimension[i] forKey:
|
||||
[NSString stringWithFormat: @"GSColumnDimension%d",i]];
|
||||
[aCoder encodeFloat: _minColumnDimension[i] forKey:
|
||||
[NSString stringWithFormat: @"GSMinColumnDimension%d",i]];
|
||||
}
|
||||
for (i = 0; i < _numberOfRows; i++)
|
||||
{
|
||||
[aCoder encodeBool: _expandRow[i] forKey:
|
||||
[NSString stringWithFormat: @"GSExpandRow%d",i]];
|
||||
[aCoder encodeFloat: _rowDimension[i] forKey:
|
||||
[NSString stringWithFormat: @"GSRowDimension%d",i]];
|
||||
[aCoder encodeFloat: _minRowDimension[i] forKey:
|
||||
[NSString stringWithFormat: @"GSMinRowDimension%d",i]];
|
||||
}
|
||||
}
|
||||
[aCoder encodeValueOfObjCType: @encode(float) at: &_minXBorder];
|
||||
[aCoder encodeValueOfObjCType: @encode(float) at: &_maxXBorder];
|
||||
[aCoder encodeValueOfObjCType: @encode(float) at: &_minYBorder];
|
||||
[aCoder encodeValueOfObjCType: @encode(float) at: &_maxYBorder];
|
||||
for (i = 0; i < _numberOfColumns; i++)
|
||||
else
|
||||
{
|
||||
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_expandColumn[i]];
|
||||
[aCoder encodeValueOfObjCType: @encode(float) at: &_columnDimension[i]];
|
||||
[aCoder encodeValueOfObjCType: @encode(float)
|
||||
at: &_minColumnDimension[i]];
|
||||
}
|
||||
for (i = 0; i < _numberOfRows; i++)
|
||||
{
|
||||
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_expandRow[i]];
|
||||
[aCoder encodeValueOfObjCType: @encode(float) at: &_rowDimension[i]];
|
||||
[aCoder encodeValueOfObjCType: @encode(float) at: &_minRowDimension[i]];
|
||||
[aCoder encodeValueOfObjCType: @encode(int) at: &_numberOfRows];
|
||||
[aCoder encodeValueOfObjCType: @encode(int) at: &_numberOfColumns];
|
||||
for (i = 0; i < _numberOfRows * _numberOfColumns; i++)
|
||||
{
|
||||
[aCoder encodeObject: _jails[i]];
|
||||
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_havePrisoner[i]];
|
||||
}
|
||||
[aCoder encodeValueOfObjCType: @encode(float) at: &_minXBorder];
|
||||
[aCoder encodeValueOfObjCType: @encode(float) at: &_maxXBorder];
|
||||
[aCoder encodeValueOfObjCType: @encode(float) at: &_minYBorder];
|
||||
[aCoder encodeValueOfObjCType: @encode(float) at: &_maxYBorder];
|
||||
for (i = 0; i < _numberOfColumns; i++)
|
||||
{
|
||||
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_expandColumn[i]];
|
||||
[aCoder encodeValueOfObjCType: @encode(float) at: &_columnDimension[i]];
|
||||
[aCoder encodeValueOfObjCType: @encode(float)
|
||||
at: &_minColumnDimension[i]];
|
||||
}
|
||||
for (i = 0; i < _numberOfRows; i++)
|
||||
{
|
||||
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_expandRow[i]];
|
||||
[aCoder encodeValueOfObjCType: @encode(float) at: &_rowDimension[i]];
|
||||
[aCoder encodeValueOfObjCType: @encode(float) at: &_minRowDimension[i]];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
-(id) initWithCoder: (NSCoder*)aDecoder
|
||||
{
|
||||
int i;
|
||||
|
||||
|
||||
[super initWithCoder: aDecoder];
|
||||
[super setAutoresizesSubviews: NO];
|
||||
|
||||
[aDecoder decodeValueOfObjCType: @encode(int) at: &_numberOfRows];
|
||||
[aDecoder decodeValueOfObjCType: @encode(int) at: &_numberOfColumns];
|
||||
|
||||
//
|
||||
_jails = NSZoneMalloc (NSDefaultMallocZone (),
|
||||
sizeof (NSView *)
|
||||
* (_numberOfRows * _numberOfColumns));
|
||||
|
||||
_havePrisoner = NSZoneMalloc (NSDefaultMallocZone (),
|
||||
sizeof (BOOL)
|
||||
* (_numberOfRows * _numberOfColumns));
|
||||
|
||||
for (i = 0; i < _numberOfRows * _numberOfColumns; i++)
|
||||
if([aDecoder allowsKeyedCoding])
|
||||
{
|
||||
_jails[i] = [aDecoder decodeObject];
|
||||
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_havePrisoner[i]];
|
||||
}
|
||||
_numberOfRows = [aDecoder decodeIntForKey: @"GSNumberOfRows"];
|
||||
_numberOfColumns = [aDecoder decodeIntForKey: @"GSNumberOfColumns"];
|
||||
|
||||
[aDecoder decodeValueOfObjCType: @encode(float) at: &_minXBorder];
|
||||
[aDecoder decodeValueOfObjCType: @encode(float) at: &_maxXBorder];
|
||||
[aDecoder decodeValueOfObjCType: @encode(float) at: &_minYBorder];
|
||||
[aDecoder decodeValueOfObjCType: @encode(float) at: &_maxYBorder];
|
||||
// create the jails...
|
||||
_jails = NSZoneMalloc (NSDefaultMallocZone (),
|
||||
sizeof (NSView *)
|
||||
* (_numberOfRows * _numberOfColumns));
|
||||
|
||||
_havePrisoner = NSZoneMalloc (NSDefaultMallocZone (),
|
||||
sizeof (BOOL)
|
||||
* (_numberOfRows * _numberOfColumns));
|
||||
|
||||
|
||||
for (i = 0; i < _numberOfRows * _numberOfColumns; i++)
|
||||
{
|
||||
_jails[i] = [aDecoder decodeObjectForKey:
|
||||
[NSString stringWithFormat: @"GSJail%d",i]];
|
||||
_havePrisoner[i] = [aDecoder decodeBoolForKey:
|
||||
[NSString stringWithFormat: @"GSHavePrisoner%d",i]];
|
||||
}
|
||||
|
||||
_minXBorder = [aDecoder decodeFloatForKey: @"GSMinXBorder"];
|
||||
_maxXBorder = [aDecoder decodeFloatForKey: @"GSMaxXBorder"];
|
||||
_minYBorder = [aDecoder decodeFloatForKey: @"GSMinYBorder"];
|
||||
_maxYBorder = [aDecoder decodeFloatForKey: @"GSMaxYBorder"];
|
||||
|
||||
// We compute _minimumSize, _expandingRowNumber
|
||||
// and _expandingColumnNumber during deconding.
|
||||
_minimumSize = NSZeroSize;
|
||||
_expandingRowNumber = 0;
|
||||
_expandingColumnNumber = 0;
|
||||
|
||||
// Columns
|
||||
_expandColumn = NSZoneMalloc (NSDefaultMallocZone (),
|
||||
sizeof (BOOL) * _numberOfColumns);
|
||||
_columnDimension = NSZoneMalloc (NSDefaultMallocZone (),
|
||||
sizeof (float) * _numberOfColumns);
|
||||
_minColumnDimension = NSZoneMalloc (NSDefaultMallocZone (),
|
||||
sizeof (float) * _numberOfColumns);
|
||||
_minimumSize.width += _minXBorder;
|
||||
for (i = 0; i < _numberOfColumns; i++)
|
||||
{
|
||||
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_expandColumn[i]];
|
||||
if (_expandColumn[i])
|
||||
_expandingColumnNumber++;
|
||||
[aDecoder decodeValueOfObjCType: @encode(float) at: &_columnDimension[i]];
|
||||
[aDecoder decodeValueOfObjCType: @encode(float)
|
||||
at: &_minColumnDimension[i]];
|
||||
_minimumSize.width += _minColumnDimension[i];
|
||||
}
|
||||
_minimumSize.width += _maxXBorder;
|
||||
// Calculate column origins
|
||||
_columnXOrigin = NSZoneMalloc (NSDefaultMallocZone (),
|
||||
sizeof (float) * _numberOfColumns);
|
||||
_columnXOrigin[0] = _minXBorder;
|
||||
for (i = 1; i < _numberOfColumns; i++)
|
||||
_columnXOrigin[i] = _columnXOrigin[i - 1] + _columnDimension[i - 1];
|
||||
|
||||
// Rows
|
||||
_expandRow = NSZoneMalloc (NSDefaultMallocZone (),
|
||||
sizeof (BOOL) * _numberOfRows);
|
||||
_rowDimension = NSZoneMalloc (NSDefaultMallocZone (),
|
||||
sizeof (float) * _numberOfRows);
|
||||
_minRowDimension = NSZoneMalloc (NSDefaultMallocZone (),
|
||||
// We compute _minimumSize, _expandingRowNumber
|
||||
// and _expandingColumnNumber during deconding.
|
||||
_minimumSize = NSZeroSize;
|
||||
_expandingRowNumber = 0;
|
||||
_expandingColumnNumber = 0;
|
||||
|
||||
// Columns
|
||||
_expandColumn = NSZoneMalloc (NSDefaultMallocZone (),
|
||||
sizeof (BOOL) * _numberOfColumns);
|
||||
_columnDimension = NSZoneMalloc (NSDefaultMallocZone (),
|
||||
sizeof (float) * _numberOfColumns);
|
||||
_minColumnDimension = NSZoneMalloc (NSDefaultMallocZone (),
|
||||
sizeof (float) * _numberOfColumns);
|
||||
_minimumSize.width += _minXBorder;
|
||||
for (i = 0; i < _numberOfColumns; i++)
|
||||
{
|
||||
_expandColumn[i] = [aDecoder decodeBoolForKey:
|
||||
[NSString stringWithFormat: @"GSExpandColumn%d",i]];
|
||||
if (_expandColumn[i])
|
||||
_expandingColumnNumber++;
|
||||
_columnDimension[i] = [aDecoder decodeFloatForKey:
|
||||
[NSString stringWithFormat: @"GSColumnDimension%d",i]];
|
||||
_minColumnDimension[i] = [aDecoder decodeFloatForKey:
|
||||
[NSString stringWithFormat: @"GSMinColumnDimension%d",i]];
|
||||
_minimumSize.width += _minColumnDimension[i];
|
||||
}
|
||||
_minimumSize.width += _maxXBorder;
|
||||
// Calculate column origins
|
||||
_columnXOrigin = NSZoneMalloc (NSDefaultMallocZone (),
|
||||
sizeof (float) * _numberOfColumns);
|
||||
_columnXOrigin[0] = _minXBorder;
|
||||
for (i = 1; i < _numberOfColumns; i++)
|
||||
_columnXOrigin[i] = _columnXOrigin[i - 1] + _columnDimension[i - 1];
|
||||
|
||||
// Rows
|
||||
_expandRow = NSZoneMalloc (NSDefaultMallocZone (),
|
||||
sizeof (BOOL) * _numberOfRows);
|
||||
_rowDimension = NSZoneMalloc (NSDefaultMallocZone (),
|
||||
sizeof (float) * _numberOfRows);
|
||||
_minRowDimension = NSZoneMalloc (NSDefaultMallocZone (),
|
||||
sizeof (float) * _numberOfRows);
|
||||
_minimumSize.height += _minYBorder;
|
||||
for (i = 0; i < _numberOfRows; i++)
|
||||
{
|
||||
_expandRow[i] = [aDecoder decodeBoolForKey:
|
||||
[NSString stringWithFormat: @"GSExpandRow%d",i]];
|
||||
if (_expandRow[i])
|
||||
_expandingRowNumber++;
|
||||
_rowDimension[i] = [aDecoder decodeFloatForKey:
|
||||
[NSString stringWithFormat: @"GSRowDimension%d",i]];
|
||||
_minRowDimension[i] = [aDecoder decodeFloatForKey:
|
||||
[NSString stringWithFormat: @"GSMinRowDimension%d",i]];
|
||||
_minimumSize.height += _minRowDimension[i];
|
||||
}
|
||||
_minimumSize.height += _maxYBorder;
|
||||
// Calculate row origins
|
||||
_rowYOrigin = NSZoneMalloc (NSDefaultMallocZone (),
|
||||
sizeof (float) * _numberOfRows);
|
||||
_minimumSize.height += _minYBorder;
|
||||
for (i = 0; i < _numberOfRows; i++)
|
||||
{
|
||||
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_expandRow[i]];
|
||||
if (_expandRow[i])
|
||||
_expandingRowNumber++;
|
||||
[aDecoder decodeValueOfObjCType: @encode(float) at: &_rowDimension[i]];
|
||||
[aDecoder decodeValueOfObjCType: @encode(float) at: &_minRowDimension[i]];
|
||||
_minimumSize.height += _minRowDimension[i];
|
||||
_rowYOrigin[0] = _minYBorder;
|
||||
for (i = 1; i < _numberOfRows; i++)
|
||||
_rowYOrigin[i] = _rowYOrigin[i - 1] + _rowDimension[i - 1];
|
||||
}
|
||||
else
|
||||
{
|
||||
[aDecoder decodeValueOfObjCType: @encode(int) at: &_numberOfRows];
|
||||
[aDecoder decodeValueOfObjCType: @encode(int) at: &_numberOfColumns];
|
||||
|
||||
//
|
||||
_jails = NSZoneMalloc (NSDefaultMallocZone (),
|
||||
sizeof (NSView *)
|
||||
* (_numberOfRows * _numberOfColumns));
|
||||
|
||||
_havePrisoner = NSZoneMalloc (NSDefaultMallocZone (),
|
||||
sizeof (BOOL)
|
||||
* (_numberOfRows * _numberOfColumns));
|
||||
|
||||
for (i = 0; i < _numberOfRows * _numberOfColumns; i++)
|
||||
{
|
||||
_jails[i] = [aDecoder decodeObject];
|
||||
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_havePrisoner[i]];
|
||||
}
|
||||
|
||||
[aDecoder decodeValueOfObjCType: @encode(float) at: &_minXBorder];
|
||||
[aDecoder decodeValueOfObjCType: @encode(float) at: &_maxXBorder];
|
||||
[aDecoder decodeValueOfObjCType: @encode(float) at: &_minYBorder];
|
||||
[aDecoder decodeValueOfObjCType: @encode(float) at: &_maxYBorder];
|
||||
|
||||
// We compute _minimumSize, _expandingRowNumber
|
||||
// and _expandingColumnNumber during deconding.
|
||||
_minimumSize = NSZeroSize;
|
||||
_expandingRowNumber = 0;
|
||||
_expandingColumnNumber = 0;
|
||||
|
||||
// Columns
|
||||
_expandColumn = NSZoneMalloc (NSDefaultMallocZone (),
|
||||
sizeof (BOOL) * _numberOfColumns);
|
||||
_columnDimension = NSZoneMalloc (NSDefaultMallocZone (),
|
||||
sizeof (float) * _numberOfColumns);
|
||||
_minColumnDimension = NSZoneMalloc (NSDefaultMallocZone (),
|
||||
sizeof (float) * _numberOfColumns);
|
||||
_minimumSize.width += _minXBorder;
|
||||
for (i = 0; i < _numberOfColumns; i++)
|
||||
{
|
||||
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_expandColumn[i]];
|
||||
if (_expandColumn[i])
|
||||
_expandingColumnNumber++;
|
||||
[aDecoder decodeValueOfObjCType: @encode(float) at: &_columnDimension[i]];
|
||||
[aDecoder decodeValueOfObjCType: @encode(float)
|
||||
at: &_minColumnDimension[i]];
|
||||
_minimumSize.width += _minColumnDimension[i];
|
||||
}
|
||||
_minimumSize.width += _maxXBorder;
|
||||
// Calculate column origins
|
||||
_columnXOrigin = NSZoneMalloc (NSDefaultMallocZone (),
|
||||
sizeof (float) * _numberOfColumns);
|
||||
_columnXOrigin[0] = _minXBorder;
|
||||
for (i = 1; i < _numberOfColumns; i++)
|
||||
_columnXOrigin[i] = _columnXOrigin[i - 1] + _columnDimension[i - 1];
|
||||
|
||||
// Rows
|
||||
_expandRow = NSZoneMalloc (NSDefaultMallocZone (),
|
||||
sizeof (BOOL) * _numberOfRows);
|
||||
_rowDimension = NSZoneMalloc (NSDefaultMallocZone (),
|
||||
sizeof (float) * _numberOfRows);
|
||||
_minRowDimension = NSZoneMalloc (NSDefaultMallocZone (),
|
||||
sizeof (float) * _numberOfRows);
|
||||
_minimumSize.height += _minYBorder;
|
||||
for (i = 0; i < _numberOfRows; i++)
|
||||
{
|
||||
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_expandRow[i]];
|
||||
if (_expandRow[i])
|
||||
_expandingRowNumber++;
|
||||
[aDecoder decodeValueOfObjCType: @encode(float) at: &_rowDimension[i]];
|
||||
[aDecoder decodeValueOfObjCType: @encode(float) at: &_minRowDimension[i]];
|
||||
_minimumSize.height += _minRowDimension[i];
|
||||
}
|
||||
_minimumSize.height += _maxYBorder;
|
||||
// Calculate row origins
|
||||
_rowYOrigin = NSZoneMalloc (NSDefaultMallocZone (),
|
||||
sizeof (float) * _numberOfRows);
|
||||
_rowYOrigin[0] = _minYBorder;
|
||||
for (i = 1; i < _numberOfRows; i++)
|
||||
_rowYOrigin[i] = _rowYOrigin[i - 1] + _rowDimension[i - 1];
|
||||
}
|
||||
_minimumSize.height += _maxYBorder;
|
||||
// Calculate row origins
|
||||
_rowYOrigin = NSZoneMalloc (NSDefaultMallocZone (),
|
||||
sizeof (float) * _numberOfRows);
|
||||
_rowYOrigin[0] = _minYBorder;
|
||||
for (i = 1; i < _numberOfRows; i++)
|
||||
_rowYOrigin[i] = _rowYOrigin[i - 1] + _rowDimension[i - 1];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
|
|
@ -177,8 +177,11 @@ unCacheAttributes(NSDictionary *attrs)
|
|||
|
||||
- (void) encodeWithCoder: (NSCoder*)aCoder
|
||||
{
|
||||
[aCoder encodeValueOfObjCType: @encode(unsigned) at: &loc];
|
||||
[aCoder encodeValueOfObjCType: @encode(id) at: &attrs];
|
||||
if([aCoder allowsKeyedCoding] == NO)
|
||||
{
|
||||
[aCoder encodeValueOfObjCType: @encode(unsigned) at: &loc];
|
||||
[aCoder encodeValueOfObjCType: @encode(id) at: &attrs];
|
||||
}
|
||||
}
|
||||
|
||||
- (void) gcFinalize
|
||||
|
@ -189,11 +192,13 @@ unCacheAttributes(NSDictionary *attrs)
|
|||
|
||||
- (id) initWithCoder: (NSCoder*)aCoder
|
||||
{
|
||||
NSDictionary *a;
|
||||
|
||||
[aCoder decodeValueOfObjCType: @encode(unsigned) at: &loc];
|
||||
a = [aCoder decodeObject];
|
||||
attrs = cacheAttributes(a);
|
||||
if([aCoder allowsKeyedCoding] == NO)
|
||||
{
|
||||
NSDictionary *a;
|
||||
[aCoder decodeValueOfObjCType: @encode(unsigned) at: &loc];
|
||||
a = [aCoder decodeObject];
|
||||
attrs = cacheAttributes(a);
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
|
|
|
@ -163,15 +163,31 @@ enablingYResizing: (BOOL)aFlag
|
|||
-(void) encodeWithCoder: (NSCoder*)aCoder
|
||||
{
|
||||
[super encodeWithCoder: aCoder];
|
||||
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_haveViews];
|
||||
[aCoder encodeValueOfObjCType: @encode(float) at: &_defaultMinYMargin];
|
||||
if([aCoder allowsKeyedCoding])
|
||||
{
|
||||
[aCoder encodeBool: _haveViews forKey: @"GSHaveViews"];
|
||||
[aCoder encodeFloat: _defaultMinYMargin forKey: @"GSDefaultMinYMargin"];
|
||||
}
|
||||
else
|
||||
{
|
||||
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_haveViews];
|
||||
[aCoder encodeValueOfObjCType: @encode(float) at: &_defaultMinYMargin];
|
||||
}
|
||||
}
|
||||
|
||||
-(id) initWithCoder: (NSCoder*)aDecoder
|
||||
{
|
||||
[super initWithCoder: aDecoder];
|
||||
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_haveViews];
|
||||
[aDecoder decodeValueOfObjCType: @encode(float) at: &_defaultMinYMargin];
|
||||
if([aDecoder allowsKeyedCoding])
|
||||
{
|
||||
_haveViews = [aDecoder decodeBoolForKey: @"GSHaveViews"];
|
||||
_defaultMinYMargin = [aDecoder decodeFloatForKey: @"GSDefaultMinYMargin"];
|
||||
}
|
||||
else
|
||||
{
|
||||
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_haveViews];
|
||||
[aDecoder decodeValueOfObjCType: @encode(float) at: &_defaultMinYMargin];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
@end
|
||||
|
|
|
@ -1572,31 +1572,34 @@ _addLeftBorderOffsetToRect(NSRect aRect)
|
|||
- (void) encodeWithCoder: (NSCoder*)encoder
|
||||
{
|
||||
[super encodeWithCoder: encoder];
|
||||
|
||||
[encoder encodeObject: _itemCells];
|
||||
[encoder encodeObject: _font];
|
||||
[encoder encodeValueOfObjCType: @encode(BOOL) at: &_horizontal];
|
||||
[encoder encodeValueOfObjCType: @encode(float) at: &_horizontalEdgePad];
|
||||
[encoder encodeValueOfObjCType: @encode(NSSize) at: &_cellSize];
|
||||
if([encoder allowsKeyedCoding] == NO)
|
||||
{
|
||||
[encoder encodeObject: _itemCells];
|
||||
[encoder encodeObject: _font];
|
||||
[encoder encodeValueOfObjCType: @encode(BOOL) at: &_horizontal];
|
||||
[encoder encodeValueOfObjCType: @encode(float) at: &_horizontalEdgePad];
|
||||
[encoder encodeValueOfObjCType: @encode(NSSize) at: &_cellSize];
|
||||
}
|
||||
}
|
||||
|
||||
- (id) initWithCoder: (NSCoder*)decoder
|
||||
{
|
||||
self = [super initWithCoder: decoder];
|
||||
|
||||
[decoder decodeValueOfObjCType: @encode(id) at: &_itemCells];
|
||||
|
||||
[_itemCells makeObjectsPerformSelector: @selector(setMenuView:)
|
||||
withObject: self];
|
||||
|
||||
[decoder decodeValueOfObjCType: @encode(id) at: &_font];
|
||||
[decoder decodeValueOfObjCType: @encode(BOOL) at: &_horizontal];
|
||||
[decoder decodeValueOfObjCType: @encode(float) at: &_horizontalEdgePad];
|
||||
[decoder decodeValueOfObjCType: @encode(NSSize) at: &_cellSize];
|
||||
|
||||
_highlightedItemIndex = -1;
|
||||
_needsSizing = YES;
|
||||
|
||||
if([decoder allowsKeyedCoding] == NO)
|
||||
{
|
||||
[decoder decodeValueOfObjCType: @encode(id) at: &_itemCells];
|
||||
|
||||
[_itemCells makeObjectsPerformSelector: @selector(setMenuView:)
|
||||
withObject: self];
|
||||
|
||||
[decoder decodeValueOfObjCType: @encode(id) at: &_font];
|
||||
[decoder decodeValueOfObjCType: @encode(BOOL) at: &_horizontal];
|
||||
[decoder decodeValueOfObjCType: @encode(float) at: &_horizontalEdgePad];
|
||||
[decoder decodeValueOfObjCType: @encode(NSSize) at: &_cellSize];
|
||||
|
||||
_highlightedItemIndex = -1;
|
||||
_needsSizing = YES;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
|
|
|
@ -163,12 +163,20 @@
|
|||
BOOL flag;
|
||||
|
||||
[super encodeWithCoder: aCoder];
|
||||
flag = _becomesKeyOnlyIfNeeded;
|
||||
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
|
||||
flag = _isFloatingPanel;
|
||||
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
|
||||
flag = _worksWhenModal;
|
||||
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
|
||||
if([aCoder allowsKeyedCoding])
|
||||
{
|
||||
// Nothing to do here, for keyed coding this is handled by NSWindowTemplate.
|
||||
// Calling the above method should throw an NSInvalidArgumentException.
|
||||
}
|
||||
else
|
||||
{
|
||||
flag = _becomesKeyOnlyIfNeeded;
|
||||
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
|
||||
flag = _isFloatingPanel;
|
||||
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
|
||||
flag = _worksWhenModal;
|
||||
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
|
||||
}
|
||||
}
|
||||
|
||||
- (id) initWithCoder: (NSCoder*)aDecoder
|
||||
|
@ -176,12 +184,20 @@
|
|||
BOOL flag;
|
||||
|
||||
[super initWithCoder: aDecoder];
|
||||
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
|
||||
[self setBecomesKeyOnlyIfNeeded: flag];
|
||||
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
|
||||
[self setFloatingPanel: flag];
|
||||
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
|
||||
[self setWorksWhenModal: flag];
|
||||
if([aDecoder allowsKeyedCoding])
|
||||
{
|
||||
// Nothing to do here, for keyed coding this is handled by NSWindowTemplate.
|
||||
// Calling the above method should throw an NSInvalidArgumentException.
|
||||
}
|
||||
else
|
||||
{
|
||||
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
|
||||
[self setBecomesKeyOnlyIfNeeded: flag];
|
||||
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
|
||||
[self setFloatingPanel: flag];
|
||||
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
|
||||
[self setWorksWhenModal: flag];
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
|
|
@ -646,21 +646,34 @@ static NSMutableDictionary* printerCache;
|
|||
//
|
||||
- (void) encodeWithCoder: (NSCoder*)aCoder
|
||||
{
|
||||
[aCoder encodeObject: _printerHost];
|
||||
[aCoder encodeObject: _printerName];
|
||||
[aCoder encodeObject: _printerNote];
|
||||
[aCoder encodeObject: _printerType];
|
||||
[aCoder encodeObject: _tables];
|
||||
if([aCoder allowsKeyedCoding])
|
||||
{
|
||||
// TODO: Determine keys for NSPrinter.
|
||||
}
|
||||
else
|
||||
{
|
||||
[aCoder encodeObject: _printerHost];
|
||||
[aCoder encodeObject: _printerName];
|
||||
[aCoder encodeObject: _printerNote];
|
||||
[aCoder encodeObject: _printerType];
|
||||
[aCoder encodeObject: _tables];
|
||||
}
|
||||
}
|
||||
|
||||
- (id) initWithCoder: (NSCoder*)aDecoder
|
||||
{
|
||||
_printerHost = [aDecoder decodeObject];
|
||||
_printerName = [aDecoder decodeObject];
|
||||
_printerNote = [aDecoder decodeObject];
|
||||
_printerType = [aDecoder decodeObject];
|
||||
_tables = [aDecoder decodeObject];
|
||||
|
||||
if([aDecoder allowsKeyedCoding])
|
||||
{
|
||||
// TODO: Determine keys for NSPrinter.
|
||||
}
|
||||
else
|
||||
{
|
||||
_printerHost = [aDecoder decodeObject];
|
||||
_printerName = [aDecoder decodeObject];
|
||||
_printerNote = [aDecoder decodeObject];
|
||||
_printerType = [aDecoder decodeObject];
|
||||
_tables = [aDecoder decodeObject];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
|
|
|
@ -99,18 +99,6 @@ id _nsstepperCellClass = nil;
|
|||
{
|
||||
}
|
||||
|
||||
- (void) encodeWithCoder: (NSCoder *)aCoder
|
||||
{
|
||||
[super encodeWithCoder: aCoder];
|
||||
}
|
||||
|
||||
- (id) initWithCoder: (NSCoder *)aDecoder
|
||||
{
|
||||
[super initWithCoder: aDecoder];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (double) maxValue
|
||||
{
|
||||
return [_cell maxValue];
|
||||
|
|
|
@ -4188,6 +4188,19 @@ resetCursorRectsForView(NSView *theView)
|
|||
{
|
||||
BOOL flag;
|
||||
|
||||
|
||||
// If were're being initialized from a keyed coder...
|
||||
if([aCoder allowsKeyedCoding])
|
||||
{
|
||||
// The docs indicate that there should be an error when directly encoding with
|
||||
// a keyed coding archiver. We should only encode NSWindow and subclasses
|
||||
// using NSWindowTemplate.
|
||||
[NSException raise: NSInvalidArgumentException
|
||||
format: @"%@ keyed coding not implemented for %@.",
|
||||
NSStringFromClass([self class])];
|
||||
}
|
||||
|
||||
|
||||
[super encodeWithCoder: aCoder];
|
||||
|
||||
[aCoder encodeRect: [[self contentView] frame]];
|
||||
|
@ -4234,6 +4247,19 @@ resetCursorRectsForView(NSView *theView)
|
|||
id oldself = self;
|
||||
BOOL flag;
|
||||
|
||||
|
||||
// If were're being initialized from a keyed coder...
|
||||
if([aDecoder allowsKeyedCoding])
|
||||
{
|
||||
// The docs indicate that there should be an error when directly encoding with
|
||||
// a keyed coding archiver. We should only encode NSWindow and subclasses
|
||||
// using NSWindowTemplate.
|
||||
[NSException raise: NSInvalidArgumentException
|
||||
format: @"%@ keyed coding not implemented for %@.",
|
||||
NSStringFromClass([self class])];
|
||||
}
|
||||
|
||||
|
||||
if ((self = [super initWithCoder: aDecoder]) == oldself)
|
||||
{
|
||||
NSSize aSize;
|
||||
|
|
Loading…
Reference in a new issue