// LegendreInspector.m
// By Charles G. Fleming, Educational Computing Services, Allegheny College.
// Copyright 1993, Allegheny College.
// You may freely copy, distribute and reuse this code. 
// Allegheny College and the author disclaim any warranty of any kind, 
// expressed or implied, as to its fitness for any particular use.

#import "LegendreInspector.h"
#import "Legendre.h"

@implementation LegendreInspector

// ****************************************************************************
// ****************************************************************************
// Inspector protocol methods.
// ****************************************************************************
// ****************************************************************************

// Return the title for the inspector's panel.
- (char *)inspectorTitle
{
	return "Legendre Inspector";
}

// Return the window that represents the inspector.
- window
{
	return window;
} 

// Make sure the inspector displays the object's current values.
- revert:sender
{
	[[functionSelectorMatrix cellAt:0 :0] setIntValue:[object legendreN]];
	[[functionSelectorMatrix cellAt:0 :1] setIntValue:[object legendreM]];
	
	[[outputTypeMatrix cellAt:0 :0] setState:(int)[object plotRequested]];
	[[outputTypeMatrix cellAt:0 :1] setState:(int)[object functionRequested]];
	
	[[domainMatrix cellAt:0 :0] setFloatValue:[object plotMin]];
	[[domainMatrix cellAt:0 :1] setFloatValue:[object plotMax]];

	[inputFormButton setState:(int)[object inputForm]];
	return self;
}

// Set the object's current values.
- ok:sender
{
	int tag;
	
	tag = [sender tag];
	switch(tag)
	{
		case 0:
			[object setLegendreN:[[sender cellAt:0 :0] intValue]];
			[object setLegendreM:[[sender cellAt:1 :0] intValue]];
			break;
		case 1:
			[object setPlotRequested:(BOOL)[[sender cellAt:0 :0] state]];
			[object setFunctionRequested:(BOOL)[[sender cellAt:1 :0] state]];
			break;
		case 2:
			[object setPlotMin:[[sender cellAt:0 :0] floatValue]];
			[object setPlotMax:[[sender cellAt:1 :0] floatValue]];
			break;
		case 3:
			[object setInputForm:[sender state]];
			break;
		default:
			break;
	}		
	// Make the inspector's window be the first responder so that 
	// textDidChange: messages will be received.
	[window makeFirstResponder:window];
	return self;
}

@end
