ftp.nice.ch/pub/next/science/mathematics/HippoDraw.2.0.s.tar.gz#/HippoDraw/Hippo.bproj/Draw.subproj/Rectangle.m

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

#import "draw.h"

@implementation Rectangle : Graphic
/*
 * This is the canonical Graphic.
 * It doesn't get much simpler than this.
 *
 * This line is just a stub to get genstrings to generate
 * a .strings file entry for the name of this type of Graphic.
 * The name is used in the Undo New <Whatever> menu item.
 *
 * NXLocalString("Rectangle", NULL, "Name of the tool that draws rectangles, i.e., the %s of the New %s operation.")
 */

+ initialize
/*
 * This bumps the class version so that we can compatibly read
 * old Graphic objects out of an archive.
 */
{
    [Rectangle setVersion:1];
    return self;
}

/* Methods overridden from superclass */

- (float)naturalAspectRatio
/*
 * The natural aspect ratio of a rectangle is 1.0 (a square).
 */
{
    return 1.0;
}

- (Graphic *)colorAcceptorAt:(const NXPoint *)point
{
    if ([self hit:point]) return self;
    return nil;
}

- draw
{
    if (bounds.size.width < 1.0 || bounds.size.height < 1.0) return self;

    if ([self fill]) {
	[self setFillColor];
	NXRectFill(&bounds);
    }
    if (!gFlags.nooutline) {
	[self setLineColor];
	PSrectstroke(bounds.origin.x, bounds.origin.y, bounds.size.width, bounds.size.height);
    }

    return self;
}

@end

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