#import "AttributedDelegate.h"

@implementation AttributedDelegate

- (void)tableView:(NSTableView *)inTableView
	 willDisplayCell:(id)inCell
	  forTableColumn:(NSTableColumn *)inTableColumn
						  row:(int)inRow
{
	NSDictionary *dict = [oData objectAtIndex:inRow];

	// Make the row's text red if the publisher is Karelia; black otherwise
	BOOL karelia = [[dict objectForKey:@"publisher"] isEqualToString:@"Karelia"];
	[inCell setTextColor:(karelia ? [NSColor redColor] : [NSColor blackColor])];

	if ([[inTableColumn identifier] isEqualToString:@"price"])
	{
		if ([[dict objectForKey:@"price"] isEqualToString:@"free"])
		{
			// Make the price text bold if it's free
			[inCell setFont:[NSFont boldSystemFontOfSize:[NSFont systemFontSize]]];
		}
		else
		{
			// Otherwise, just use regular system font
			[inCell setFont:[NSFont systemFontOfSize:[NSFont systemFontSize]]];
		}
	}
}

@end
