From fe94ecb9cda5b24f802a1502b30b95c7531ecefd Mon Sep 17 00:00:00 2001 From: FredKiefer Date: Mon, 21 Jun 2004 11:41:26 +0000 Subject: [PATCH] Made mouse down changes of table view work with outline view. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@19571 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 9 ++++++++ Source/NSOutlineView.m | 51 +++++++++++++++++++++++++----------------- Source/NSTableView.m | 50 +++++++++++++++++++++++------------------ 3 files changed, 68 insertions(+), 42 deletions(-) diff --git a/ChangeLog b/ChangeLog index c8e682c74..f9589d6f3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2004-06-21 Fred Kiefer + + * Source/NSTableView.m: + * Source/NSOutlineView.m: (-_willDisplayCell:forTableColumn:row:) + New method to abstract from differences in table and outline + view. Used whenever the delegate gets informed by + willDisplayCell:. + (_setObjectValue:forTableColumn:row:) Check for correct method. + 2004-06-20 Fred Kiefer * Source/NSTableView.m: (-mouseDown:) Set value after cell tracking. diff --git a/Source/NSOutlineView.m b/Source/NSOutlineView.m index 74c48265f..0d8a5e844 100644 --- a/Source/NSOutlineView.m +++ b/Source/NSOutlineView.m @@ -85,6 +85,9 @@ static NSImage *unexpandable = nil; - (BOOL) _shouldSelectionChange; - (BOOL) _shouldEditTableColumn: (NSTableColumn *)tableColumn row: (int) rowIndex; +- (void) _willDisplayCell: (NSCell*)cell + forTableColumn: (NSTableColumn *)tb + row: (int)index; - (id)_objectValueForTableColumn: (NSTableColumn *)tb row: (int)index; - (void) _setObjectValue: (id)value @@ -1010,15 +1013,9 @@ static NSImage *unexpandable = nil; tb = [_tableColumns objectAtIndex: i]; cell = [tb dataCellForRow: rowIndex]; - - if ([_delegate respondsToSelector: @selector(outlineView:willDisplayCell:forTableColumn:item:)]) - { - [_delegate outlineView: self - willDisplayCell: cell - forTableColumn: tb - item: item]; - } - + [self _willDisplayCell: cell + forTableColumn: tb + row: rowIndex]; [cell setObjectValue: [_dataSource outlineView: self objectValueForTableColumn: tb byItem: item]]; @@ -1205,10 +1202,11 @@ static NSImage *unexpandable = nil; - (BOOL) _shouldEditTableColumn: (NSTableColumn *)tableColumn row: (int) rowIndex { - id item = [self itemAtRow: rowIndex]; if ([_delegate respondsToSelector: @selector(outlineView:shouldEditTableColumn:item:)]) { + id item = [self itemAtRow: rowIndex]; + if ([_delegate outlineView: self shouldEditTableColumn: tableColumn item: item] == NO) { @@ -1219,15 +1217,31 @@ static NSImage *unexpandable = nil; return YES; } +- (void) _willDisplayCell: (NSCell*)cell + forTableColumn: (NSTableColumn *)tb + row: (int)index +{ + if (_del_responds) + { + id item = [self itemAtRow: index]; + + [_delegate outlineView: self + willDisplayCell: cell + forTableColumn: tb + item: item]; + } +} + - (id) _objectValueForTableColumn: (NSTableColumn *)tb row: (int) index { id result = nil; - id item = [self itemAtRow: index]; if([_dataSource respondsToSelector: @selector(outlineView:objectValueForTableColumn:byItem:)]) { + id item = [self itemAtRow: index]; + result = [_dataSource outlineView: self objectValueForTableColumn: tb byItem: item]; @@ -1240,10 +1254,11 @@ static NSImage *unexpandable = nil; forTableColumn: (NSTableColumn *)tb row: (int) index { - id item = [self itemAtRow: index]; if([_dataSource respondsToSelector: - @selector(outlineView:objectValueForTableColumn:byItem:)]) + @selector(outlineView:setObjectValue:forTableColumn:byItem:)]) { + id item = [self itemAtRow: index]; + [_dataSource outlineView: self setObjectValue: value forTableColumn: tb @@ -1713,13 +1728,9 @@ static NSImage *unexpandable = nil; } // But of course the delegate can mess it up if it wants - if (_del_responds) - { - [_delegate outlineView: self - willDisplayCell: _editedCell - forTableColumn: tb - item: [self itemAtRow: rowIndex]]; - } + [self _willDisplayCell: _editedCell + forTableColumn: tb + row: rowIndex]; /* Please note the important point - calling stringValue normally causes the _editedCell to call the validateEditing method of its diff --git a/Source/NSTableView.m b/Source/NSTableView.m index 71a69a0cf..7184a423c 100644 --- a/Source/NSTableView.m +++ b/Source/NSTableView.m @@ -92,6 +92,9 @@ static unsigned currentDragOperation; - (BOOL) _shouldSelectionChange; - (BOOL) _shouldEditTableColumn: (NSTableColumn *)tableColumn row: (int) rowIndex; +- (void) _willDisplayCell: (NSCell*)cell + forTableColumn: (NSTableColumn *)tb + row: (int)index; - (BOOL) _writeRows: (NSArray *) rows toPasteboard: (NSPasteboard *)pboard; @@ -3246,11 +3249,9 @@ byExtendingSelection: (BOOL)flag } // But of course the delegate can mess it up if it wants - if (_del_responds) - { - [_delegate tableView: self willDisplayCell: _editedCell - forTableColumn: tb row: rowIndex]; - } + [self _willDisplayCell: _editedCell + forTableColumn: tb + row: rowIndex]; /* Please note the important point - calling stringValue normally causes the _editedCell to call the validateEditing method of its @@ -3469,13 +3470,9 @@ inline float computePeriod(NSPoint mouseLocationWin, [cell setHighlighted: YES]; [self setNeedsDisplayInRect: cellFrame]; /* give delegate a chance to i.e set target */ - if (_del_responds) - { - [_delegate tableView: self - willDisplayCell: cell - forTableColumn: tb - row: _clickedRow]; - } + [self _willDisplayCell: cell + forTableColumn: tb + row: _clickedRow]; if ([cell trackMouse: lastEvent inRect: cellFrame ofView: self @@ -4215,11 +4212,9 @@ inline float computePeriod(NSPoint mouseLocationWin, [cell setObjectValue: [_dataSource tableView: self objectValueForTableColumn: tb row: row]]; - if (_del_responds) - { - [_delegate tableView: self willDisplayCell: cell - forTableColumn: tb row: row]; - } + [self _willDisplayCell: cell + forTableColumn: tb + row: row]; candidate_width = [cell cellSize].width; if (_drawsGrid) @@ -4435,11 +4430,9 @@ inline float computePeriod(NSPoint mouseLocationWin, { tb = [_tableColumns objectAtIndex: i]; cell = [tb dataCellForRow: rowIndex]; - if (_del_responds) - { - [_delegate tableView: self willDisplayCell: cell - forTableColumn: tb row: rowIndex]; - } + [self _willDisplayCell: cell + forTableColumn: tb + row: rowIndex]; [cell setObjectValue: [_dataSource tableView: self objectValueForTableColumn: tb row: rowIndex]]; @@ -5866,6 +5859,19 @@ inline float computePeriod(NSPoint mouseLocationWin, return YES; } +- (void) _willDisplayCell: (NSCell*)cell + forTableColumn: (NSTableColumn *)tb + row: (int)index +{ + if (_del_responds) + { + [_delegate tableView: self + willDisplayCell: cell + forTableColumn: tb + row: index]; + } +} + - (id) _objectValueForTableColumn: (NSTableColumn *)tb row: (int) index {