
#import "ImageView.h"
 
@implementation ImageView

- initWithFrame:(NSRect)frameRect
{
	[super initWithFrame:frameRect];
	_image = nil;
	_imageName = nil;
	return self;
}

- (void)dealloc
{
	if(_image)
		[_image release];
	if(_imageName)
		[_imageName release];
	return [super dealloc];
}

- (NSImage *)image
{
	return _image;
}

- (NSString *)imageName
{
	return _imageName;
}

- (void)setImage:(NSImage *)anImage
{
	NSScrollView *sv = [self enclosingScrollView];

	if(anImage == _image)
		return;
	[_image release];
	_image = [anImage retain];
	if(sv)
		[self setFrameSize:[_image size]];
	[[self window] display];
}

- (void)setImageName:(NSString *)anImageName
{
	if(anImageName == _imageName)
		return;
	[_imageName release];
	_imageName = [anImageName retain];
}


- (void)drawRect:(NSRect)r
{   
	PSsetgray(NSLightGray);
	NSRectFill([self bounds]);
	if(_image)
		[_image compositeToPoint:NSZeroPoint operation:NSCompositeCopy];
}

@end




