#import "ScheduleDelegate.h"

const int FIRST_TIME_COLUMN_INDEX  = 1;	// this takes care of all but a few instances of special column dealing
const int NUMBER_OF_HOURS  = 10;
const int CELLS_PER_HOUR = 2;
const float START_HOUR = 8.0;		// start at 8 AM.

@implementation ScheduleDelegate

- (void)awakeFromNib
{
	int newColCount = FIRST_TIME_COLUMN_INDEX + NUMBER_OF_HOURS * CELLS_PER_HOUR;
	int i;
	float hour = START_HOUR;

	[oTable setBackgroundColor:[NSColor colorWithCalibratedRed:0.929 green:0.953 blue:0.996 alpha:1.0]];
	
	for( i= FIRST_TIME_COLUMN_INDEX ; i< newColCount ; i++ )	// start past non-time columns
	{
		NSTableColumn *column = [[[NSTableColumn alloc] init] autorelease];
		[column setWidth:50];
		[column setEditable:NO];
		[column setResizable:NO];
		[column setIdentifier:[NSString stringWithFormat:@"%f", hour]];

		if ((i-FIRST_TIME_COLUMN_INDEX) % CELLS_PER_HOUR == 0)
		{
			// Really, we ought to properly localize the time display.
			[[column headerCell] setStringValue:[NSString stringWithFormat:@"%d:00", (int)hour]];
		}
		else	// half-hour cells have blank headers
		{
			[[column headerCell] setStringValue:@""];
		}

		// Finally, add the column we've built
		[oTable addTableColumn:column];

		// Increment our hour counter
		hour += (1.0 / CELLS_PER_HOUR);
	}
}

@end
