ftp.nice.ch/Attic/openStep/developer/resources/MiscKit.2.0.5.s.gnutar.gz#/MiscKit2/Examples/Giger/ImageView.m

This is ImageView.m in view mode; [Download] [Up]

#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




These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.