Reverted changes of previous commit to rollback unintentional reformatting of code in the files NSTableView.m and NSOutlineView.m.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/branches/gnustep_testplant_branch@36044 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Frank Le Grand 2013-01-31 01:52:05 +00:00
parent 10ad99f43f
commit fe5d19ee8e
2 changed files with 6704 additions and 6786 deletions

View file

@ -29,7 +29,7 @@
If not, see <http://www.gnu.org/licenses/> or write to the If not, see <http://www.gnu.org/licenses/> or write to the
Free Software Foundation, 51 Franklin Street, Fifth Floor, Free Software Foundation, 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA. Boston, MA 02110-1301, USA.
*/ */
#import <Foundation/NSArray.h> #import <Foundation/NSArray.h>
#import <Foundation/NSDictionary.h> #import <Foundation/NSDictionary.h>
@ -144,13 +144,13 @@ static NSImage *unexpandable = nil;
[self setVersion: current_version]; [self setVersion: current_version];
nc = [NSNotificationCenter defaultCenter]; nc = [NSNotificationCenter defaultCenter];
#if 0 #if 0
/* Old Interface Builder style. */ /* Old Interface Builder style. */
collapsed = [NSImage imageNamed: @"common_outlineCollapsed"]; collapsed = [NSImage imageNamed: @"common_outlineCollapsed"];
expanded = [NSImage imageNamed: @"common_outlineExpanded"]; expanded = [NSImage imageNamed: @"common_outlineExpanded"];
unexpandable = [NSImage imageNamed: @"common_outlineUnexpandable"]; unexpandable = [NSImage imageNamed: @"common_outlineUnexpandable"];
#else #else
/* Current OSX style images. */ /* Current OSX style images. */
// FIXME ... better ones? // FIXME ... better ones?
collapsed = [NSImage imageNamed: @"common_ArrowRightH"]; collapsed = [NSImage imageNamed: @"common_ArrowRightH"];
expanded = [NSImage imageNamed: @"common_ArrowDownH"]; expanded = [NSImage imageNamed: @"common_ArrowDownH"];
unexpandable = [[NSImage alloc] initWithSize: [expanded size]]; unexpandable = [[NSImage alloc] initWithSize: [expanded size]];
@ -672,9 +672,9 @@ static NSImage *unexpandable = nil;
- (void) setDataSource: (id)anObject - (void) setDataSource: (id)anObject
{ {
#define CHECK_REQUIRED_METHOD(selector_name) \ #define CHECK_REQUIRED_METHOD(selector_name) \
if (anObject && ![anObject respondsToSelector: @selector(selector_name)]) \ if (anObject && ![anObject respondsToSelector: @selector(selector_name)]) \
[NSException raise: NSInternalInconsistencyException \ [NSException raise: NSInternalInconsistencyException \
format: @"data source does not respond to %@", @#selector_name] format: @"data source does not respond to %@", @#selector_name]
CHECK_REQUIRED_METHOD(outlineView:child:ofItem:); CHECK_REQUIRED_METHOD(outlineView:child:ofItem:);
CHECK_REQUIRED_METHOD(outlineView:isItemExpandable:); CHECK_REQUIRED_METHOD(outlineView:isItemExpandable:);
@ -738,10 +738,10 @@ format: @"data source does not respond to %@", @#selector_name]
_delegate = anObject; _delegate = anObject;
#define SET_DELEGATE_NOTIFICATION(notif_name) \ #define SET_DELEGATE_NOTIFICATION(notif_name) \
if ([_delegate respondsToSelector: @selector(outlineView##notif_name:)]) \ if ([_delegate respondsToSelector: @selector(outlineView##notif_name:)]) \
[nc addObserver: _delegate \ [nc addObserver: _delegate \
selector: @selector(outlineView##notif_name:) \ selector: @selector(outlineView##notif_name:) \
name: NSOutlineView##notif_name##Notification object: self] name: NSOutlineView##notif_name##Notification object: self]
SET_DELEGATE_NOTIFICATION(ColumnDidMove); SET_DELEGATE_NOTIFICATION(ColumnDidMove);
SET_DELEGATE_NOTIFICATION(ColumnDidResize); SET_DELEGATE_NOTIFICATION(ColumnDidResize);
@ -1222,7 +1222,7 @@ name: NSOutlineView##notif_name##Notification object: self]
} }
/* Returns the row whose item is the parent that owns the child at the given row. /* Returns the row whose item is the parent that owns the child at the given row.
Also returns the child index relative to this parent. */ Also returns the child index relative to this parent. */
- (NSInteger) _parentRowForRow: (NSInteger)row - (NSInteger) _parentRowForRow: (NSInteger)row
atLevel: (NSInteger)level atLevel: (NSInteger)level
andReturnChildIndex: (NSInteger *)childIndex andReturnChildIndex: (NSInteger *)childIndex
@ -1517,7 +1517,7 @@ name: NSOutlineView##notif_name##Notification object: self]
} }
return [_dataSource outlineView: self return [_dataSource outlineView: self
namesOfPromisedFilesDroppedAtDestination: dropDestination namesOfPromisedFilesDroppedAtDestination: dropDestination
forDraggedItems: itemArray]; forDraggedItems: itemArray];
} }
else else
@ -1526,7 +1526,6 @@ namesOfPromisedFilesDroppedAtDestination: dropDestination
} }
} }
// Autosave methods... // Autosave methods...
- (void) setAutosaveName: (NSString *)name - (void) setAutosaveName: (NSString *)name
{ {
@ -2266,25 +2265,6 @@ namesOfPromisedFilesDroppedAtDestination: dropDestination
return cell; return cell;
} }
// This is used to build the drag image.
- (NSString *) _objectStringForTableColum:(NSTableColumn *)column item:(int)row {
NSString *draggedItemString = nil;
if ([[self dataSource] respondsToSelector:@selector(outlineView:objectValueForTableColumn:byItem:)]) {
id item = [self itemAtRow:row];
id draggedObject = [[self dataSource] outlineView:self
objectValueForTableColumn:column
byItem:item];
// Pad the string to match its indentation level:
int level = [self levelForRow:row];
NSString *pad = [@"" stringByPaddingToLength:(level*4)
withString:@" "
startingAtIndex:0];
draggedItemString = [pad stringByAppendingString:[draggedObject description]];
}
return draggedItemString;
}
@end @end
@implementation NSOutlineView (Private) @implementation NSOutlineView (Private)
@ -2302,5 +2282,4 @@ namesOfPromisedFilesDroppedAtDestination: dropDestination
} }
[autoExpanded removeAllObjects]; [autoExpanded removeAllObjects];
} }
@end @end

View file

@ -28,7 +28,7 @@
If not, see <http://www.gnu.org/licenses/> or write to the If not, see <http://www.gnu.org/licenses/> or write to the
Free Software Foundation, 51 Franklin Street, Fifth Floor, Free Software Foundation, 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA. Boston, MA 02110-1301, USA.
*/ */
#import <Foundation/NSAutoreleasePool.h> #import <Foundation/NSAutoreleasePool.h>
#import <Foundation/NSDebug.h> #import <Foundation/NSDebug.h>
@ -68,8 +68,6 @@
#import "AppKit/NSCustomImageRep.h" #import "AppKit/NSCustomImageRep.h"
#import "GNUstepGUI/GSTheme.h" #import "GNUstepGUI/GSTheme.h"
#import "GSBindingHelpers.h" #import "GSBindingHelpers.h"
#import "AppKit/NSAttributedString.h"
#import "AppKit/NSStringDrawing.h"
#include <math.h> #include <math.h>
static NSNotificationCenter *nc = nil; static NSNotificationCenter *nc = nil;
@ -1986,8 +1984,6 @@ static void computeNewSelection
- (void) _autoloadTableColumns; - (void) _autoloadTableColumns;
- (NSCell *) _dataCellForTableColumn: (NSTableColumn *)tb - (NSCell *) _dataCellForTableColumn: (NSTableColumn *)tb
row: (int) rowIndex; row: (int) rowIndex;
- (NSString *) _objectStringForTableColum:(NSTableColumn *)column item:(int)row;
@end @end
@ -3602,21 +3598,21 @@ static inline float computePeriod(NSPoint mouseLocationWin,
{ {
#define COMPUTE_NEW_SELECTION do { \ #define COMPUTE_NEW_SELECTION do { \
if (originalRow == -1) \ if (originalRow == -1) \
{ \ { \
originalRow = currentRow; \ originalRow = currentRow; \
} \ } \
if (currentRow >= 0 && currentRow < _numberOfRows) \ if (currentRow >= 0 && currentRow < _numberOfRows) \
{ \ { \
computeNewSelection(self, \ computeNewSelection(self, \
oldSelectedRows, \ oldSelectedRows, \
_selectedRows, \ _selectedRows, \
originalRow, \ originalRow, \
oldRow, \ oldRow, \
currentRow, \ currentRow, \
&_selectedRow, \ &_selectedRow, \
selectionMode); \ selectionMode); \
[self displayIfNeeded]; \ [self displayIfNeeded]; \
} \ } \
} while (0); } while (0);
// Selection // Selection
@ -3950,10 +3946,10 @@ selectionMode); \
/* helpers for keyboard selection */ /* helpers for keyboard selection */
#define CHECK_CHANGING(x) { \ #define CHECK_CHANGING(x) { \
if (!x) \ if (!x) \
{ \ { \
[self _postSelectionIsChangingNotification]; \ [self _postSelectionIsChangingNotification]; \
x = YES; \ x = YES; \
} \ } \
} }
static BOOL selectContiguousRegion(NSTableView *self, static BOOL selectContiguousRegion(NSTableView *self,
NSIndexSet *_selectedRows, NSIndexSet *_selectedRows,
@ -4321,9 +4317,9 @@ static BOOL selectContiguousRegion(NSTableView *self,
/** Returns the indexes of the table columns which intersects the given rect. /** Returns the indexes of the table columns which intersects the given rect.
The rect is expressed in the receiver coordinate space. The rect is expressed in the receiver coordinate space.
Hidden table columns are never tested. */ Hidden table columns are never tested. */
- (NSIndexSet *) columnIndexesInRect: (NSRect)aRect - (NSIndexSet *) columnIndexesInRect: (NSRect)aRect
{ {
NSRange range = [self columnsInRect: aRect]; NSRange range = [self columnsInRect: aRect];
@ -4343,11 +4339,11 @@ static BOOL selectContiguousRegion(NSTableView *self,
/** Returns the index range of the table columns which intersects the given rect. /** Returns the index range of the table columns which intersects the given rect.
The rect is expressed in the receiver coordinate space. The rect is expressed in the receiver coordinate space.
The returned range can include hidden table column indexes. The returned range can include hidden table column indexes.
This method is deprecated, use -columnIndexesInRect:. */ This method is deprecated, use -columnIndexesInRect:. */
- (NSRange) columnsInRect: (NSRect)aRect - (NSRange) columnsInRect: (NSRect)aRect
{ {
NSRange range; NSRange range;
@ -4752,8 +4748,8 @@ static BOOL selectContiguousRegion(NSTableView *self,
[self tile]; [self tile];
} }
/* /*
- (void) sizeToFit - (void) sizeToFit
{ {
NSCell *cell; NSCell *cell;
NSEnumerator *enumerator; NSEnumerator *enumerator;
NSTableColumn *tb; NSTableColumn *tb;
@ -4829,8 +4825,8 @@ static BOOL selectContiguousRegion(NSTableView *self,
_tilingDisabled = NO; _tilingDisabled = NO;
[self tile]; [self tile];
NSLog(@"exiting sizeToFit"); NSLog(@"exiting sizeToFit");
} }
*/ */
- (void) noteNumberOfRowsChanged - (void) noteNumberOfRowsChanged
{ {
@ -5261,10 +5257,10 @@ static BOOL selectContiguousRegion(NSTableView *self,
_delegate = anObject; _delegate = anObject;
#define SET_DELEGATE_NOTIFICATION(notif_name) \ #define SET_DELEGATE_NOTIFICATION(notif_name) \
if ([_delegate respondsToSelector: @selector(tableView##notif_name:)]) \ if ([_delegate respondsToSelector: @selector(tableView##notif_name:)]) \
[nc addObserver: _delegate \ [nc addObserver: _delegate \
selector: @selector(tableView##notif_name:) \ selector: @selector(tableView##notif_name:) \
name: NSTableView##notif_name##Notification object: self] name: NSTableView##notif_name##Notification object: self]
SET_DELEGATE_NOTIFICATION(ColumnDidMove); SET_DELEGATE_NOTIFICATION(ColumnDidMove);
SET_DELEGATE_NOTIFICATION(ColumnDidResize); SET_DELEGATE_NOTIFICATION(ColumnDidResize);
@ -5341,10 +5337,6 @@ name: NSTableView##notif_name##Notification object: self]
event: (NSEvent*)event event: (NSEvent*)event
offset: (NSPoint*)offset offset: (NSPoint*)offset
{ {
if (!cols && ([self tableColumns]) && ([[self tableColumns] count] > 0)) {
cols = [NSArray arrayWithObject:[[self tableColumns] objectAtIndex:0]];
}
if (!rows || [rows count] < 1 || !cols || [cols count] < 1) {
// FIXME // FIXME
NSArray *rowArray; NSArray *rowArray;
@ -5352,46 +5344,6 @@ name: NSTableView##notif_name##Notification object: self]
return [self dragImageForRows: rowArray return [self dragImageForRows: rowArray
event: event event: event
dragImageOffset: offset]; dragImageOffset: offset];
}
// Build a string of texts, each representing a line from the tableView,
// separated by "\n":
NSString *descriptionsList = nil;
unsigned int index = [rows firstIndex];
while (index != NSNotFound) {
NSString *draggedItemString = [self _objectStringForTableColum:[cols objectAtIndex:0]
item:index];
if (!descriptionsList) {
descriptionsList = [NSMutableString stringWithString:draggedItemString];
}
else {
descriptionsList = [descriptionsList stringByAppendingFormat:@"\n%@", draggedItemString];
}
index = [rows indexGreaterThanIndex:index];
}
NSAttributedString *attributedString = [[[NSAttributedString alloc] initWithString:descriptionsList] autorelease];
NSSize boxSize = [attributedString size];
NSRect rect = NSMakeRect(0.0, 0.0, boxSize.width, boxSize.height);
NSImage *image = [[NSImage alloc] initWithSize:boxSize];
NSColor *bg = [NSColor whiteColor];
[image lockFocus];
// Filling with white color for now, transparent is showing as blackColor.
[bg set];
NSRectFill(rect);
[attributedString drawInRect:rect];
[image unlockFocus];
// Offset the image so it sits neatly next to the mouse cursor.
// Note: Cocoa actually offsets the image to position of the mouse down.
offset->x = (boxSize.width / 2) + 5;
offset->y = (boxSize.height / -2) + 5;
return [image autorelease];
} }
- (void) setDropRow: (int)row - (void) setDropRow: (int)row
@ -5426,7 +5378,7 @@ name: NSTableView##notif_name##Notification object: self]
@selector(tableView:namesOfPromisedFilesDroppedAtDestination:forDraggedRowsWithIndexes:)]) @selector(tableView:namesOfPromisedFilesDroppedAtDestination:forDraggedRowsWithIndexes:)])
{ {
return [_dataSource tableView: self return [_dataSource tableView: self
namesOfPromisedFilesDroppedAtDestination: dropDestination namesOfPromisedFilesDroppedAtDestination: dropDestination
forDraggedRowsWithIndexes: _selectedRows]; forDraggedRowsWithIndexes: _selectedRows];
} }
else else
@ -5815,7 +5767,7 @@ namesOfPromisedFilesDroppedAtDestination: dropDestination
@selector(tableView:mouseDownInHeaderOfTableColumn:)]) @selector(tableView:mouseDownInHeaderOfTableColumn:)])
{ {
[_delegate tableView: self [_delegate tableView: self
mouseDownInHeaderOfTableColumn: tc]; mouseDownInHeaderOfTableColumn: tc];
} }
} }
@ -5910,7 +5862,7 @@ mouseDownInHeaderOfTableColumn: tc];
} }
} }
// Should we loop around or not? // Should we loop around or not?
#if 0 #if 0
// Nothing found? Search in the rows before the current // Nothing found? Search in the rows before the current
for (i = 0; i < row; i++) for (i = 0; i < row; i++)
@ -5978,7 +5930,7 @@ mouseDownInHeaderOfTableColumn: tc];
} }
} }
// Should we loop around or not? // Should we loop around or not?
#if 0 #if 0
// Nothing found? Search in the rows after the current // Nothing found? Search in the rows after the current
for (i = _numberOfRows - 1; i > row; i--) for (i = _numberOfRows - 1; i > row; i--)
@ -6101,19 +6053,6 @@ mouseDownInHeaderOfTableColumn: tc];
return cell; return cell;
} }
- (NSString *) _objectStringForTableColum:(NSTableColumn *)column item:(int)row
{
NSString *draggedItemString = nil;
if ([_dataSource respondsToSelector:@selector(tableView:objectValueForTableColumn:byItem:)]) {
id draggedObject = [_dataSource tableView:self
objectValueForTableColumn:column
row:row];
draggedItemString = [draggedObject description];
}
return draggedItemString;
}
- (void) superviewFrameChanged: (NSNotification*)aNotification - (void) superviewFrameChanged: (NSNotification*)aNotification
{ {
if (_autoresizesAllColumnsToFit == YES) if (_autoresizesAllColumnsToFit == YES)
@ -6449,20 +6388,20 @@ mouseDownInHeaderOfTableColumn: tc];
*/ */
/** Sets the sort descriptors used to sort the rows and delegates the sorting /** Sets the sort descriptors used to sort the rows and delegates the sorting
to -tableView:didChangeSortDescriptors or -outlineView:didChangeSortDescriptors: to -tableView:didChangeSortDescriptors or -outlineView:didChangeSortDescriptors:
in NSOutlineView. in NSOutlineView.
The delegate methods can retrieve the new sort descriptors with The delegate methods can retrieve the new sort descriptors with
-sortDescriptors and override them with -setSortDescriptors:.<br /> -sortDescriptors and override them with -setSortDescriptors:.<br />
The first object in the new sort descriptor array is the sort descriptor The first object in the new sort descriptor array is the sort descriptor
prototype returned by the table column whose header was the last clicked. prototype returned by the table column whose header was the last clicked.
See -[NSTableColumn sortDescriptorPrototype]. See -[NSTableColumn sortDescriptorPrototype].
This method is called automatically when you click on a table column header, This method is called automatically when you click on a table column header,
so you shouldn't need to call it usually. so you shouldn't need to call it usually.
Take note the sort descriptors are encoded by the keyed archiving (rarely used Take note the sort descriptors are encoded by the keyed archiving (rarely used
since neither IB or Gorm support to set these directly). */ since neither IB or Gorm support to set these directly). */
- (void) setSortDescriptors: (NSArray *)sortDescriptors - (void) setSortDescriptors: (NSArray *)sortDescriptors
{ {
NSArray *oldSortDescriptors = [self sortDescriptors]; NSArray *oldSortDescriptors = [self sortDescriptors];
@ -6492,11 +6431,11 @@ mouseDownInHeaderOfTableColumn: tc];
} }
/** Returns the current sort descriptors, usually updated every time a click /** Returns the current sort descriptors, usually updated every time a click
happens on a table column header. happens on a table column header.
By default, returns an empty array. By default, returns an empty array.
For a more detailed explanation, -setSortDescriptors:. */ For a more detailed explanation, -setSortDescriptors:. */
- (NSArray *)sortDescriptors - (NSArray *)sortDescriptors
{ {
return _sortDescriptors; return _sortDescriptors;