[NSTableView initWithCoder]: Read alternatingRowBackgroundColors, from tableViewFlags (#252)

* [NSTableView initWithCoder]: Read alternatingRowBackgroundColors,  from tableViewFlags

* [NSTableView _numRows]: Check _tableColumns is not empty

* [NSTableView encodeWithCoder]: add autosaveTableColumns, usesAlternatingRowBackgroundColors
This commit is contained in:
Frederik Carlier 2024-04-03 23:54:10 +02:00 committed by GitHub
parent 059d13f5ab
commit 85b8a3e495
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 26 additions and 6 deletions

View file

@ -125,6 +125,7 @@ APPKIT_EXPORT_CLASS
BOOL _allowsColumnReordering;
BOOL _autoresizesAllColumnsToFit;
BOOL _selectingColumns;
BOOL _usesAlternatingRowBackgroundColors;
NSText *_textObject;
NSInteger _editedRow;
NSInteger _editedColumn;

View file

@ -96,9 +96,17 @@ typedef struct _tableViewFlags
unsigned int emptySelection:1;
unsigned int multipleSelection:1;
unsigned int columnSelection:1;
unsigned int _unused:26;
unsigned int unknown1:1;
unsigned int columnAutosave:1;
unsigned int alternatingRowBackgroundColors:1;
unsigned int unknown2:3;
unsigned int _unused:20;
#else
unsigned int _unused:26;
unsigned int _unused:20;
unsigned int unknown2:3;
unsigned int alternatingRowBackgroundColors:1;
unsigned int columnAutosave:1;
unsigned int unknown1:1;
unsigned int columnSelection:1;
unsigned int multipleSelection:1;
unsigned int emptySelection:1;
@ -2560,13 +2568,16 @@ static void computeNewSelection
- (void) setUsesAlternatingRowBackgroundColors: (BOOL)useAlternatingRowColors
{
// FIXME
if (_usesAlternatingRowBackgroundColors != useAlternatingRowColors)
{
_usesAlternatingRowBackgroundColors = useAlternatingRowColors;
[self reloadData];
}
}
- (BOOL) usesAlternatingRowBackgroundColors
{
// FIXME
return NO;
return _usesAlternatingRowBackgroundColors;
}
- (void)setSelectionHighlightStyle: (NSTableViewSelectionHighlightStyle)s
@ -5494,6 +5505,8 @@ This method is deprecated, use -columnIndexesInRect:. */
tableViewFlags.drawsGrid = [self drawsGrid];
tableViewFlags.columnResizing = [self allowsColumnResizing];
tableViewFlags.columnOrdering = [self allowsColumnReordering];
tableViewFlags.columnAutosave = [self autosaveTableColumns];
tableViewFlags.alternatingRowBackgroundColors = [self usesAlternatingRowBackgroundColors];
memcpy((void *)&vFlags,(void *)&tableViewFlags,sizeof(unsigned int));
@ -5678,6 +5691,8 @@ This method is deprecated, use -columnIndexesInRect:. */
[self setDrawsGrid: tableViewFlags.drawsGrid];
[self setAllowsColumnResizing: tableViewFlags.columnResizing];
[self setAllowsColumnReordering: tableViewFlags.columnOrdering];
[self setAutosaveTableColumns: tableViewFlags.columnAutosave];
[self setUsesAlternatingRowBackgroundColors: tableViewFlags.alternatingRowBackgroundColors];
}
// get the table columns...
@ -6729,7 +6744,7 @@ For a more detailed explanation, -setSortDescriptors:. */
{
return [_dataSource numberOfRowsInTableView:self];
}
else
else if([_tableColumns count] > 0)
{
NSTableColumn *tb = [_tableColumns objectAtIndex: 0];
GSKeyValueBinding *theBinding;
@ -6744,6 +6759,10 @@ For a more detailed explanation, -setSortDescriptors:. */
// FIXME
return 0;
}
else
{
return 0;
}
}
- (BOOL) _isDraggingSource