ftp.nice.ch/pub/next/developer/objc/fromnext/MiniExamples.91.9.s.tar.gz#/MiniExamples/ZooView/RightSubView.m

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

/* 
 * RightSubView.m
 *
 * Purpose:
 *		This object simply blasts an image to itself. Knows the name of the
 *		image, too.
 *
 * You may freely copy, distribute, and reuse the code in this example.
 * NeXT disclaims any warranty of any kind, expressed or  implied, as to its
 * fitness for any particular use.
 *
 * Written by: Mary McNabb
 * Created: Apr 91
 *
 */

#import "RightSubView.h"
#import <dpsclient/psops.h>
#import <appkit/NXImage.h>
#import <string.h>

@implementation RightSubView

- drawSelf:(const NXRect *)r :(int)c
{
	NXPoint position;
	NXSize animalSize;
	
	id image = [NXImage findImageNamed:animalName];
		
		/* figure out the position of the lower left hand corner */
	[image getSize:&animalSize];
	position.x = bounds.size.width / 2.0 - animalSize.width / 2.0;
	position.y = bounds.size.height / 2.0 - animalSize.height / 2.0;
	if (position.x < 0) position.x = bounds.origin.x;
	if (position.y < 0) position.y = bounds.origin.y;
	
		/* draw background first to cover up old image */
	PSsetgray(NX_LTGRAY);
	NXRectFill(r);
	[image composite:NX_SOVER toPoint:&position];
	[image free];
	PSsetgray(NX_DKGRAY);
	NXFrameRect(r);
	
	return self;
}

/*
 * just remember the name of the picture
 */
- setAnimalPicture:(char *) path
{
	strcpy(animalName, path);
	[self display];
	return self;
}

@end

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