mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-23 07:00:46 +00:00
Add code to cause delegate methods which are not used for viewBased tables to be called in viewBased mode, add code to instantiate the prototypeCellView when adding it to the tableView
This commit is contained in:
parent
5294e2a126
commit
20f29b2d1d
2 changed files with 87 additions and 58 deletions
|
@ -3535,8 +3535,9 @@ static NSDictionary *titleTextAttributes[3] = {nil, nil, nil};
|
|||
/* Draw the row between startingColumn and endingColumn */
|
||||
for (i = startingColumn; i <= endingColumn; i++)
|
||||
{
|
||||
NSRect drawingRect = drawingRect = [tableView frameOfCellAtColumn: i
|
||||
row: rowIndex];
|
||||
NSRect drawingRect = [tableView
|
||||
frameOfCellAtColumn: i
|
||||
row: rowIndex];
|
||||
NSTableColumn *tb = nil;
|
||||
|
||||
// drawingRect.origin.y += headerHeight;
|
||||
|
@ -3555,14 +3556,11 @@ static NSDictionary *titleTextAttributes[3] = {nil, nil, nil};
|
|||
NSEnumerator *en = [protoCellViews objectEnumerator];
|
||||
id cellView = nil;
|
||||
|
||||
// NSLog(@"Rect for calculated frame = %@", NSStringFromRect(drawingRect));
|
||||
|
||||
while ((cellView = [en nextObject]) != nil)
|
||||
{
|
||||
cellView = [cellView copy]; // instantiate the prototype...
|
||||
[cellView setFrame: drawingRect];
|
||||
[tableView addSubview: cellView];
|
||||
|
||||
NSLog(@"cell view = %@, title = %@", cellView, [[cellView textField] stringValue]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3218,18 +3218,23 @@ byExtendingSelection: (BOOL)flag
|
|||
- (NSCell *) preparedCellAtColumn: (NSInteger)columnIndex row: (NSInteger)rowIndex
|
||||
{
|
||||
NSCell *cell = nil;
|
||||
NSTableColumn *tb = [_tableColumns objectAtIndex: columnIndex];
|
||||
|
||||
if ([_delegate respondsToSelector:
|
||||
@selector(tableView:dataCellForTableColumn:row:)])
|
||||
{
|
||||
cell = [_delegate tableView: self dataCellForTableColumn: tb
|
||||
row: rowIndex];
|
||||
}
|
||||
if (cell == nil)
|
||||
{
|
||||
cell = [tb dataCellForRow: rowIndex];
|
||||
if (_viewBased == NO)
|
||||
{
|
||||
NSTableColumn *tb = [_tableColumns objectAtIndex: columnIndex];
|
||||
|
||||
if ([_delegate respondsToSelector:
|
||||
@selector(tableView:dataCellForTableColumn:row:)])
|
||||
{
|
||||
cell = [_delegate tableView: self dataCellForTableColumn: tb
|
||||
row: rowIndex];
|
||||
}
|
||||
if (cell == nil)
|
||||
{
|
||||
cell = [tb dataCellForRow: rowIndex];
|
||||
}
|
||||
}
|
||||
|
||||
return cell;
|
||||
}
|
||||
|
||||
|
@ -3350,6 +3355,11 @@ byExtendingSelection: (BOOL)flag
|
|||
NSRect drawingRect;
|
||||
NSUInteger length = 0;
|
||||
|
||||
if (_viewBased)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (rowIndex != _selectedRow)
|
||||
{
|
||||
[NSException raise:NSInvalidArgumentException
|
||||
|
@ -3483,6 +3493,11 @@ static inline NSTimeInterval computePeriod(NSPoint mouseLocationWin,
|
|||
row: (NSInteger) rowIndex
|
||||
withEvent: (NSEvent *) theEvent
|
||||
{
|
||||
if (_viewBased)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (rowIndex == -1 || columnIndex == -1)
|
||||
{
|
||||
return;
|
||||
|
@ -3848,31 +3863,35 @@ if (currentRow >= 0 && currentRow < _numberOfRows) \
|
|||
|
||||
if (eventType == NSLeftMouseDown)
|
||||
{
|
||||
/*
|
||||
* Can never get here from a dragging source
|
||||
* so they need to track in mouse up.
|
||||
*/
|
||||
NSCell *cell = [self preparedCellAtColumn: _clickedColumn
|
||||
row: _clickedRow];
|
||||
|
||||
[self _trackCellAtColumn: _clickedColumn
|
||||
row: _clickedRow
|
||||
withEvent: theEvent];
|
||||
didTrackCell = YES;
|
||||
|
||||
if ([[cell class] prefersTrackingUntilMouseUp])
|
||||
{
|
||||
/* the mouse could have gone up outside of the cell
|
||||
* avoid selecting the row under mouse cursor */
|
||||
sendAction = YES;
|
||||
done = YES;
|
||||
if (_viewBased == NO)
|
||||
{
|
||||
/*
|
||||
* Can never get here from a dragging source
|
||||
* so they need to track in mouse up.
|
||||
*/
|
||||
NSCell *cell = [self preparedCellAtColumn: _clickedColumn
|
||||
row: _clickedRow];
|
||||
|
||||
[self _trackCellAtColumn: _clickedColumn
|
||||
row: _clickedRow
|
||||
withEvent: theEvent];
|
||||
didTrackCell = YES;
|
||||
|
||||
if ([[cell class] prefersTrackingUntilMouseUp])
|
||||
{
|
||||
/* the mouse could have gone up outside of the cell
|
||||
* avoid selecting the row under mouse cursor */
|
||||
sendAction = YES;
|
||||
done = YES;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Since we may have tracked a cell which may have caused
|
||||
* a change to the currentEvent we may need to loop over
|
||||
* the current event
|
||||
*/
|
||||
*/
|
||||
getNextEvent = (lastEvent == [NSApp currentEvent]);
|
||||
}
|
||||
else
|
||||
|
@ -5805,6 +5824,11 @@ This method is deprecated, use -columnIndexesInRect:. */
|
|||
{
|
||||
NSInteger i, j;
|
||||
|
||||
if (_viewBased)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (aCell == nil)
|
||||
return;
|
||||
|
||||
|
@ -6704,7 +6728,7 @@ For a more detailed explanation, -setSortDescriptors:. */
|
|||
forTableColumn: (NSTableColumn *)tb
|
||||
row: (NSInteger)index
|
||||
{
|
||||
if (_del_responds)
|
||||
if (_del_responds && _viewBased == NO)
|
||||
{
|
||||
[_delegate tableView: self
|
||||
willDisplayCell: cell
|
||||
|
@ -6717,23 +6741,27 @@ For a more detailed explanation, -setSortDescriptors:. */
|
|||
row: (NSInteger) index
|
||||
{
|
||||
id result = nil;
|
||||
GSKeyValueBinding *theBinding;
|
||||
|
||||
theBinding = [GSKeyValueBinding getBinding: NSValueBinding
|
||||
forObject: tb];
|
||||
if (theBinding != nil)
|
||||
|
||||
if (_viewBased == NO)
|
||||
{
|
||||
return [(NSArray *)[theBinding destinationValue]
|
||||
objectAtIndex: index];
|
||||
GSKeyValueBinding *theBinding;
|
||||
|
||||
theBinding = [GSKeyValueBinding getBinding: NSValueBinding
|
||||
forObject: tb];
|
||||
if (theBinding != nil)
|
||||
{
|
||||
return [(NSArray *)[theBinding destinationValue]
|
||||
objectAtIndex: index];
|
||||
}
|
||||
else if ([_dataSource respondsToSelector:
|
||||
@selector(tableView:objectValueForTableColumn:row:)])
|
||||
{
|
||||
result = [_dataSource tableView: self
|
||||
objectValueForTableColumn: tb
|
||||
row: index];
|
||||
}
|
||||
}
|
||||
else if ([_dataSource respondsToSelector:
|
||||
@selector(tableView:objectValueForTableColumn:row:)])
|
||||
{
|
||||
result = [_dataSource tableView: self
|
||||
objectValueForTableColumn: tb
|
||||
row: index];
|
||||
}
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -6741,15 +6769,18 @@ For a more detailed explanation, -setSortDescriptors:. */
|
|||
forTableColumn: (NSTableColumn *)tb
|
||||
row: (NSInteger) index
|
||||
{
|
||||
if ([_dataSource respondsToSelector:
|
||||
@selector(tableView:setObjectValue:forTableColumn:row:)])
|
||||
if (_viewBased == NO)
|
||||
{
|
||||
[_dataSource tableView: self
|
||||
setObjectValue: value
|
||||
forTableColumn: tb
|
||||
row: index];
|
||||
if ([_dataSource respondsToSelector:
|
||||
@selector(tableView:setObjectValue:forTableColumn:row:)])
|
||||
{
|
||||
[_dataSource tableView: self
|
||||
setObjectValue: value
|
||||
forTableColumn: tb
|
||||
row: index];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Quasi private method called on self from -noteNumberOfRowsChanged
|
||||
* implemented in NSTableView and subclasses
|
||||
|
|
Loading…
Reference in a new issue