Fix decoding

This commit is contained in:
Gregory John Casamento 2020-11-15 01:34:04 -05:00
parent f04f8536ec
commit 6184b12128
2 changed files with 64 additions and 33 deletions

View file

@ -112,6 +112,12 @@ APPKIT_EXPORT const CGFloat NSGridViewSizeForContent;
@interface NSGridCell : NSObject <NSCoding>
{
NSView *_contentView;
NSGridRowAlignment _rowAlignment;
NSGridCellPlacement _xPlacement;
NSGridCellPlacement _yPlacement;
id _mergeHead;
NSGridRow *_owningRow;
NSGridColumn *_owningColumn;
}
- (NSView *) contentView;
@ -168,7 +174,6 @@ APPKIT_EXPORT const CGFloat NSGridViewSizeForContent;
@interface NSGridRow : NSObject <NSCoding>
{
NSGridView *_gridView;
NSMutableArray *_row;
NSGridCellPlacement _yPlacement;
CGFloat _height;
CGFloat _bottomPadding;

View file

@ -350,6 +350,30 @@
self = [super init];
if ([coder allowsKeyedCoding])
{
if ([coder containsValueForKey: @"NSGrid_content"])
{
ASSIGN(_contentView, [coder decodeObjectForKey: @"NSGrid_content"]);
}
if ([coder containsValueForKey: @"NSGrid_mergeHead"])
{
_mergeHead = [coder decodeObjectForKey: @"NSGrid_mergeHead"];
}
if ([coder containsValueForKey: @"NSGrid_owningRow"])
{
_owningRow = [coder decodeObjectForKey: @"NSGrid_owningRow"];
}
if ([coder containsValueForKey: @"NSGrid_owningColumn"])
{
_owningColumn = [coder decodeObjectForKey: @"NSGrid_owningColumn"];
}
if ([coder containsValueForKey: @"NSGrid_xPlacement"])
{
_xPlacement = [coder decodeIntegerForKey: @"NSGrid_xPlacement"];
}
if ([coder containsValueForKey: @"NSGrid_yPlacement"])
{
_yPlacement = [coder decodeIntegerForKey: @"NSGrid_yPlacement"];
}
}
else
{
@ -459,7 +483,7 @@
}
if ([coder containsValueForKey: @"NSGrid_xPlacement"])
{
_xPlacement = [coder decodeBoolForKey: @"NSGrid_xPlacement"];
_xPlacement = [coder decodeIntegerForKey: @"NSGrid_xPlacement"];
}
}
else
@ -474,37 +498,9 @@
/// Row ///
@implementation NSGridRow
- (void) _setRow: (NSMutableArray *)row
{
_row = row; // weak reference;
}
- (NSMutableArray *) _row
{
return _row;
}
- (BOOL) isEqual: (NSGridRow *)r
{
if (_row == [r _row])
{
return YES;
}
else
{
NSUInteger idx = 0;
FOR_IN(NSGridCell*, cell, _row)
{
NSGridCell *otherCell = [[r _row] objectAtIndex: idx];
if (![cell isEqual: otherCell])
{
return NO;
}
idx++;
}
END_FOR_IN(_row);
}
return YES;
return NO;
}
- (void) setGridView: (NSGridView *)gridView
@ -519,12 +515,12 @@
- (NSInteger) numberOfCells
{
return [_row count];
return 0; // [_row count];
}
- (NSGridCell *) cellAtIndex:(NSInteger)index
{
return [_row objectAtIndex: index];
return nil; // [_row objectAtIndex: index];
}
- (NSGridCellPlacement) yPlacement
@ -589,6 +585,36 @@
- (instancetype) initWithCoder: (NSCoder *)coder
{
self = [super init];
if ([coder allowsKeyedCoding])
{
if ([coder containsValueForKey: @"NSGrid_hidden"])
{
_isHidden = [coder decodeBoolForKey: @"NSGrid_hidden"];
}
if ([coder containsValueForKey: @"NSGrid_bottomPadding"])
{
_bottomPadding = [coder decodeFloatForKey: @"NSGrid_bottomPadding"];
}
if ([coder containsValueForKey: @"NSGrid_owningGrid"])
{
ASSIGN(_gridView, [coder decodeObjectForKey: @"NSGrid_owningGrid"]);
}
if ([coder containsValueForKey: @"NSGrid_topPadding"])
{
_topPadding = [coder decodeFloatForKey: @"NSGrid_topPadding"];
}
if ([coder containsValueForKey: @"NSGrid_height"])
{
_height = [coder decodeFloatForKey: @"NSGrid_height"];
}
if ([coder containsValueForKey: @"NSGrid_yPlacement"])
{
_yPlacement = [coder decodeFloatForKey: @"NSGrid_yPlacement"];
}
}
else
{
}
return self;
}