#import "AnimatedTableView.h"


@implementation AnimatedTableView

// ----------------------------------------------------------------------------------------
// Animated Sort support
// ----------------------------------------------------------------------------------------

/*"	Override NSTableView's method.  Let the delegate determine what the rectangle for a given row is, if that delegate responds to the selector to do so.  If animation is going on, it will probably return a value other than the default.
"*/
- (NSRect)rectOfRow:(int)rowIndex
{
	NSRect theDefaultRect = [super rectOfRow:rowIndex];
	if ([[self delegate] respondsToSelector:@selector(tableView:rectOfRow:defaultRect:)])
	{
		return [[self delegate] tableView:self rectOfRow:rowIndex defaultRect:theDefaultRect];
	}
	else
	{
		return theDefaultRect;
	}
}

/*"	Return the default NSTableView's version of the rectangle for a given row; this method is provided so we can determine the rectangle as if animation weren't happening.
"*/
- (NSRect)unanimatedRectOfRow:(int)rowIndex
{
	return [super rectOfRow:rowIndex];
}

/*"	Override NSTableView's method.  Let the delegate determine what the range of rows is for a given rectangle, if that delegate responds to the selector to do so.  If animation is going on, it will probably return a value other than the default.
"*/
- (NSRange)rowsInRect:(NSRect)inRect

{
	NSRange theDefaultRange = [super rowsInRect:inRect];
	if ([[self delegate] respondsToSelector:@selector(tableView:rowsInRect:defaultRange:)])
	{
		return [[self delegate] tableView:self rowsInRect:inRect defaultRange:theDefaultRange];
	}
	else
	{
		return theDefaultRange;
	}
}

@end
