
#import "TABInspector.h"

@implementation TABInspector

- awakeFromNib;
{
	[self clear:self];
	return self;
}
- (void)displayNote:(Note *)note;
{
	int	i;
	locationT	*l;
	
	if(!note)return;
	[self clear:self];
	for(i=0;i<5;i++){
		l = [note loc:i];
		if(l->string == -1)break;
		[[fieldMatrix findCellWithTag:l->string] setIntValue:l->fret];
	}
}
- clear:sender
{
	int i;
	
	for(i=0;i<6;i++){
		[[fieldMatrix findCellWithTag:i] setStringValue:""];
	}
	
    return self;
}
- (void)setEditable:(BOOL)yn;
{
	int i;
	
	[super setEditable:yn];
	for(i=0;i<6;i++){
		[(TextField *)[fieldMatrix findCellWithTag:i] setEnabled:yn];
		[(TextField *)[fieldMatrix findCellWithTag:i] setBackgroundGray:(yn? 1.0 : 2./3.)];
	}
}

- cellActed:sender
{
// note mit loc aus repository
// wenn nicht gefunden, Failure Sound spielen;
// sonst an client melden.
	locationT	l;
	Note	*myNote;
	id	sc = [sender selectedCell];

	l.string = [sc tag];
	l.fret = [sc intValue];
	if(myNote = [myNR noteByLoc:&l]){
		[self displayNote:myNote];
		[client newNote:myNote from:self];
	}else{
		NXBeep();
	}
	[fieldMatrix selectCell:sc];

    return self;
}


@end
