/* SwitchViewInspector.h
 * Written By:  Thomas Burkholder
 *
 * You may freely copy, distribute, and reuse the code in this example.
 * NeXT disclaims any warranty of any kind, expressed or  implied, as to its
 * fitness for any particular use.
 */


#import "SwitchViewInspector.h"

@implementation SwitchView (AttributesInspector)

- (const char *)getInspectorClassName
{
	NXEvent *ev = [NXApp currentEvent];

	if (ev->flags & NX_ALTERNATEMASK)
		return [super getInspectorClassName];
	else
		return "SwitchViewInspector";
}

@end

@implementation SwitchViewInspector

- init
{
	char buf[MAXPATHLEN + 1];
	id bundle;
	
	[super init];
	
	bundle = [NXBundle bundleForClass:[SwitchView class]];
	[bundle getPath:buf forResource:"SwitchViewInspector" ofType:"nib"];
	[NXApp loadNibFile:buf owner:self withNames:NO fromZone:[self zone]];
	
	return self;
}

- ok:sender
{
	if (![messageHowMatrix selectedRow])
		[messageTypeField setStringValue:""];
	[object setValueSelector:sel_getUid([messageTypeField stringValue])];
	[messageTypeField setEnabled:(BOOL)[messageHowMatrix selectedRow]];
	[object setInitialViewNumber:[initialField intValue]];
	return [super ok:sender];
}

- revert:sender
{
	[messageHowMatrix selectCellAt:([object valueSelector]!=(SEL)0) :0];
	[messageTypeField setEnabled:([object valueSelector]!=(SEL)0)];
	if ([object valueSelector]) {
		[messageTypeField setStringValue:sel_getName([object valueSelector])];
	} else {
		[messageTypeField setStringValue:""];
	}
	[initialField setIntValue:[object initialViewNumber]];
	return [super revert:sender];
}

- (BOOL)wantsButtons
{
	return NO;
}

@end
