#import "PAThumbWheelInspector.h"
#import "PAThumbWheel.h"

@implementation PAThumbWheelInspector

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

- textDidGetKeys:sender isEmpty:(BOOL)flag 
{ [self perform:@selector(ok:) with:self afterDelay:500 cancelPrevious:YES]; return self; }

- (BOOL)wantsButtons { return NO; }

- revert:sender
{
	[displayModeMatrix selectCellAt:[object displayMode] :0];
	[directionMatrix selectCellAt:[object direction] :0];
	
	[visibleMinText setFloatValue:[object visibleMin]];
	[visibleMaxText setFloatValue:[object visibleMax]];
	[currentText	setFloatValue:[object floatValue]];
	
	[snapBackValueText setFloatValue:[object snapBackValue]];
	[snapsBackSwitch	setState:[object snapsBack]];
	
	[absoluteMinText setFloatValue:[object absoluteMin]];
	[absoluteMaxText setFloatValue:[object absoluteMax]];
	[absoluteModeMatrix selectCellAt:[object absoluteMode] : 0];
	
	[dashIntervalText setFloatValue:[object dashInterval]];
	[showMainDashSwitch setState:[object showMainDash]];

	[colorWell setColor:[object color]];
	
	[tagText setIntValue:[object tag]];
	[disabledSwitch setState:![object isEnabled]];
	
	return [super revert:sender];
}

- ok:sender
{
	[[object window] disableDisplay];

	[object takeDisplayModeFromMatrix:displayModeMatrix];
	[object takeDirectionFromMatrix:directionMatrix];
	[object setFloatValue:[currentText floatValue]];
	
	[object takeVisibleMinFrom:visibleMinText];
	[object takeVisibleMaxFrom:visibleMaxText];
	
	[object takeSnapBackValueFrom:snapBackValueText];
	[object takeSnapsBackFromSwitch:snapsBackSwitch];
	
	[object takeAbsoluteMinFrom:absoluteMinText];
	[object takeAbsoluteMaxFrom:absoluteMaxText];
	[object takeAbsoluteModeFromMatrix:absoluteModeMatrix];
	
	[object takeDashIntervalFrom:dashIntervalText];
	[object takeShowMainDashFromSwitch:showMainDashSwitch];

	[object takeColorFrom:colorWell];

	[object takeTagFrom:tagText];
	[object takeDisabledFromSwitch:disabledSwitch];
	
	[[object window] reenableDisplay]; [object display];

	return [super ok:sender];
}

@end
