
/* Generated by Interface Builder */

#import <appkit/appkit.h>
#import "ScorePlot.h"

@implementation ScorePlot

- setUp
{
	[window orderFront:self];
	[self setSecondLength:40.0];
	[self setClipping:NO];
	[self allocateGState];
	lastx = 0.0;
	drawPoint = frame.size.width - (3.0 * secondLength);
	[self display];
	return self;
}

- drawSelf:(const NXRect *)r :(int)c
{
	drawstafflines(r->origin.x, r->size.width);
	return self;
}

- setSecondLength:(float)length
{
	secondLength = length;
	return self;
}

- drawNoteKey:(struct ScoreArgs *)sc_args
{
	grafiknote gnote;
	NXPoint scrollPoint;

	if (sc_args->vel <= 0.0) return nil;
	if (sc_args->vel > 127.0) sc_args->vel = 127.0; 
	if (sc_args->key < 0.0) return nil;
	if (sc_args->key >= 128.0) return nil;

	gnote.gray = (127.0 - sc_args->vel) / 127.0;
	gnote.x = secondLength * sc_args->start;
	gnote.y = sc_args->key * NOTESPACE;
	gnote.width = secondLength * sc_args->dur;

	scrollPoint.x = lastx - gnote.x; 
	scrollPoint.y = 0.0;
	lastx = gnote.x;

	[self lockFocus];
	/*PSsetinstance(YES);*/

	[self scrollRect:&bounds by:&scrollPoint];
	// PSsetgray(gnote.gray);
	// PSrectfill(drawPoint, gnote.y, gnote.width, NOTEHEIGHT);
	// PSsetgray(0);
	// PSrectstroke(drawPoint, gnote.y, gnote.width, NOTEHEIGHT);
	drawnote(gnote.gray, drawPoint, gnote.y, gnote.width, NOTEHEIGHT);

	[self unlockFocus];
	[window flushWindow];

	return self;
}

- drawDelayedNoteKey
{
	struct ScoreArgs sc_args;
	[cScoreStorage retrieve:&sc_args];
	return [self drawNoteKey:&sc_args];
}

@end

