//----------------------------------------------------------------------------------------------------
//
//	CalendarInspector
//
//	Inherits From:		IBInspector
//
//	Declared In:		CalendarInspector.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 "CalendarInspector.h"
#import "Calendar.h"


@implementation CalendarInspector

- init
{
	//  Initialize and return an instance of this class.		
    	char 	path[MAXPATHLEN+1];
    	id 		bundle;
		
    	[super init];
    	if ( ! (bundle = [NXBundle bundleForClass: [CalendarInspector class]] ) ) return nil;    	if ( ! [bundle getPath: path forResource: "CalendarInspector" ofType: "nib"] ) return nil;
    	[NXApp loadNibFile: path owner: self  withNames: NO fromZone: [self zone]];
    	return self;
}


- revert:sender
{
	//  Sync with inspected object.
	
	[calendar month: [object monthIntValue]];
	[calendar day: [object dayIntValue]];
	[calendar year: [object yearIntValue]];
	[disableButton setState: ! [object isEnabled]];

    	return [super revert:sender];
}


- ok: sender
{
	//  Make changes to object .  Notify IB changes have occurred.

	[object month: [calendar monthIntValue]];
	[object day: [calendar dayIntValue]];
	[object year: [calendar yearIntValue]];
	[object setEnabled: ! [disableButton state]];

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


- (BOOL)wantsButtons
{
	//  Tell IB we want 'Revert' and 'Ok' buttons.

    	return YES;
}


@end