//---------------------------------------------------------------------------------------------------------
//
//	MyObject
//
//	Inherits From:		Object
//
//	Declared In:		MyObject.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 "MyObject.h"


@implementation MyObject

//----------------------------------------------------------------------------------------------------
//	Accessors
//----------------------------------------------------------------------------------------------------
- (int)state
{
    	return state;
}


- setState: (int)newState
{
    	state = newState;
    	return self;
}


//----------------------------------------------------------------------------------------------------
//	Action Methods
//----------------------------------------------------------------------------------------------------
- action: sender
{
	//  An action method...
	
  	[outlet setStringValue:"Message Received..."];
    	
	NXRunAlertPanel ( "MyObject",
    		"self <id %x> (an instance of %s) got the message \"%s\" from sender <id %x> (an instance of %s)\n\nstate = %d",
		NULL, NULL, NULL,
		self, [self name], sel_getName(_cmd), sender, [sender name], state);

   	 [outlet setStringValue:"Message Executed..."];
   	 return self;
}


//----------------------------------------------------------------------------------------------------
//	Archiving
// 	Only necessary if you declare instance variables that need to 
//	be persistent...  We will save 'state' but not 'outlet'.
//----------------------------------------------------------------------------------------------------
- read: (NXTypedStream*) stream
{
    [super read: stream];
    NXReadType (stream, "i", &state);
    return self;
}

- write: (NXTypedStream*) stream
{
    [super write: stream];
    NXWriteType (stream, "i", &state);
    return self;
}


//----------------------------------------------------------------------------------------------------
//	IB Methods
//----------------------------------------------------------------------------------------------------
- (const char *)getInspectorClassName
{
	//  This returns the name of the class responsible for managing a custom 
	//  IB Attributes inspector.  See class spec for IBObject (an informal protocol)
	//  on the other custom inspectors...
	
    	return "MyObjectInspector";
}

- (NXImage*) getIBImage
{
	//  This returns the NXImage instance that will be displayed in IB's File Viewer
	//  when this class is instantiated.

	return [NXImage findImageNamed: "MyObjectIcon"];
}


@end
