Address fred's comment about getting the cell more efficiently

This commit is contained in:
Gregory John Casamento 2021-03-14 14:32:04 -04:00
parent 2c488f07c8
commit 68dad85a1e
2 changed files with 14 additions and 8 deletions

View file

@ -156,7 +156,7 @@ APPKIT_EXPORT const CGFloat NSGridViewSizeForContent;
- (NSGridView *) gridView;
- (void) setGridView: (NSGridView *)gv;
- (NSInteger) numberOfCells;
- (NSGridCell *) cellAtIndex:(NSInteger)index;
- (NSGridCell *) cellAtIndex: (NSInteger)index;
- (NSGridCellPlacement) xPlacement;
- (void) setXPlacement: (NSGridCellPlacement)x;
@ -186,7 +186,7 @@ APPKIT_EXPORT const CGFloat NSGridViewSizeForContent;
- (NSGridView *) gridView;
- (void) setGridView: (NSGridView *)gv;
- (NSInteger) numberOfCells;
- (NSGridCell *)cellAtIndex:(NSInteger)index;
- (NSGridCell *)cellAtIndex: (NSInteger)index;
- (NSGridCellPlacement) yPlacement;
- (void) setYPlacement: (NSGridCellPlacement)y;

View file

@ -960,11 +960,14 @@
return [arr count];
}
- (NSGridCell *) cellAtIndex:(NSInteger)index
- (NSGridCell *) cellAtIndex: (NSInteger)index
{
NSUInteger ci = [_gridView indexOfColumn: self];
NSArray *arr = [_gridView _cellsForColumnAtIndex: ci];
return [arr objectAtIndex: index];
// First we get the columnIndex (ci) then we get the member of that column
// referred to by index. The method called here gets the correct cell out of
// the _cells array in the containing NSGridView.
return [_gridView cellAtColumnIndex: ci
rowIndex: index];
}
- (NSGridCellPlacement) xPlacement
@ -1134,11 +1137,14 @@
return [arr count];
}
- (NSGridCell *) cellAtIndex:(NSInteger)index
- (NSGridCell *) cellAtIndex: (NSInteger)index
{
NSUInteger ri = [_gridView indexOfRow: self];
NSArray *arr = [_gridView _cellsForRowAtIndex: ri];
return [arr objectAtIndex: index];
// First we get the rowIndex (ri) then we get the member of that row
// referred to by index. The method called here gets the correct cell out of
// the _cells array in the containing NSGridView.
return [_gridView cellAtColumnIndex: index
rowIndex: ri];
}
- (NSGridCellPlacement) yPlacement