#import "TabSelectionCell.h"

#import "MyController.h"

@implementation MyController

- appDidInit:sender
{
	NXRect	backgroundRect,matrixRect;

	/* Set backgroundView to be flipped ('cause Matrices are flipped) */
	[backgroundView setFlipped:YES];
	
	/* Get the backgroundView's dimensions */
	[backgroundView getBounds:&backgroundRect];

	/* Set up the matrix bounds */
	matrixRect = backgroundRect;
	matrixRect.origin.y = NX_MAXY(&matrixRect) - 17.0;

	/* Prepare a matrix to go inside the backgroundView */
	tabMatrix = [[Matrix allocFromZone:[self zone]] initFrame:&matrixRect 
								mode:NX_RADIOMODE
								cellClass:[TabSelectionCell class]
								numRows:1
								numCols:4];
	
	/* Set the background gray of tabMatrix to NX_DKGRAY */
	[tabMatrix setBackgroundGray:NX_DKGRAY];
	
	/* Set the autosizing and autoscrolling attributes of the matrix */
    [tabMatrix setAutosizing:NX_WIDTHSIZABLE|NX_HEIGHTSIZABLE];
	[tabMatrix setAutoscroll:YES];

	/* Stick the matrix in our scrollView */
	[backgroundView addSubview:tabMatrix];

	/* Set our target and single-click actions */
	[tabMatrix setTarget:self];
	[tabMatrix setAction:@selector(tabMatrixAction:)];

	/* Size tabMatrix to its cells and display it */
	[tabMatrix sizeToCells];
	[tabMatrix display];

	return self;
}

- tabMatrixAction:sender
{
	/* Put a cool action here (probably something like switching views
		underneath the tabs) */
	return self;
}

@end