#import "NSTableView+util.h"

@interface NSTableView ( private_stuff )
// Declarations of 10.1 private methods, just to make the compiler happy.
+ (id) _defaultTableHeaderReverseSortImage;
+ (id) _defaultTableHeaderSortImage;
@end


@implementation NSTableView ( util )

/*"	Return the sorting indicator image; works on 10.1 and 10.2.
"*/

+ (NSImage *) ascendingSortIndicator
{
	NSImage *result = [NSImage imageNamed:@"NSAscendingSortIndicator"];
	if (nil == result && [[NSTableView class] respondsToSelector:@selector(_defaultTableHeaderSortImage)])
	{
		result = [NSTableView _defaultTableHeaderSortImage];
	}
	return result;
}

/*"	Return the sorting indicator image; works on 10.1 and 10.2.
"*/

+ (NSImage *) descendingSortIndicator
{
	NSImage *result = [NSImage imageNamed:@"NSDescendingSortIndicator"];
	if (nil == result && [[NSTableView class] respondsToSelector:@selector(_defaultTableHeaderReverseSortImage)])
	{
		result = [NSTableView _defaultTableHeaderReverseSortImage];
	}
	return result;
}

/*"	This merely provides an NSArray of the selected rows.
"*/

- (NSArray *) selectedRows
{
	NSEnumerator *theEnum = [self selectedRowEnumerator];
	NSNumber *rowNumber;
	NSMutableArray *rowNumberArray
		= [NSMutableArray arrayWithCapacity:[self numberOfSelectedRows]];

	while (nil != (rowNumber = [theEnum nextObject]) )
	{
		[rowNumberArray addObject:rowNumber];
	}
	return rowNumberArray;
}


@end
