//---------------------------------------------------------------------------------------------------------
//
//	MyObjectInspector
//
//	Inherits From:		IBInspector
//
//	Declared In:		MyObjectInspector.h
//
//	Disclaimer
//
//		You may freely copy, distribute and reuse this software and its
//		associated documentation. I disclaim any warranty of any kind, 
//		expressed or implied, as to its fitness for any particular use.
//
//---------------------------------------------------------------------------------------------------------
#import "MyObjectInspector.h"
#import "MyObject.h"


@implementation MyObjectInspector

- init
{
	//  Init instance and load the nib...  Call 'revert:' to sync.
	
    	id 		bundle;
    	char 	path [MAXPATHLEN + 1];
    
    	[super init];
    
    	if ( ! (bundle = [NXBundle bundleForClass: [MyObject class]] ) ) return nil;    	if ( ! [bundle getPath: path forResource: "MyObjectInspector" ofType: "nib"] )  return nil;
    	[NXApp loadNibFile: path owner: self  withNames: NO fromZone: [self zone]];

	[self revert: nil];

    	return self;
}


- (BOOL) wantsButtons
{
	//  Tell IB whether to display 'Revert' and 'Ok' buttons...
    	return NO;
}


- revert: sender
{
	//  Called in 'init' and first time an instance is inspected.
	//  Must always call [super revert:].
	
	[stateSlider setIntValue: [object state]];
    	[stateText setIntValue: [object state]];
    	return [super revert:sender];
}


- ok: sender
{
	//  Message the inspected instance to change its values.  Tell IB active doc has changed.  
	//  (IB will subsequently dirty the active doc - FileViewer).  Must call [super ok: sender].
	
	if  ([sender intValue]  > 100)  [sender setIntValue: 100];
	if  ([sender intValue]  <  0)      [sender setIntValue: 0];

    	[object setState: [sender intValue]];
	[stateSlider setIntValue: [object state]];
    	[stateText setIntValue: [object state]];

	[[NXApp activeDocument] touch];
    	return [super ok: sender];
}

@end
