ftp.nice.ch/Attic/openStep/developer/resources/MiscKit.2.0.5.s.gnutar.gz#/MiscKit2/Temp/MiscProgressPalette1/MiscProgressView.subproj/MiscProgressPie.m

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

//
//	MiscProgressPie.m -- a simple view class for displaying a pie
//		Written and Copyright (c) 1993 by James Heiser.  (jheiser@adobe.com)
//				Rendering code massaged by Don Yacktman.
//				Version 1.0.  All rights reserved.
//
//		This notice may not be removed from this source code.
//
//	This object is included in the MiscKit by permission from the author
//	and its use is governed by the MiscKit license, found in the file
//	"LICENSE.rtf" in the MiscKit distribution.  Please refer to that file
//	for a list of all applicable permissions and restrictions.
//	

#import "MiscProgressPie.h"

@implementation MiscProgressPie

- initWithFrame:(NSRect)frameRect
{
    [super initWithFrame:frameRect];
	[self setHidden:NO];
    return self;
}

- renderBar
{
	float angle = 90.0;
	if ([self isHidden] || (ratio <= 0.0)) return self;
	if (ratio >= 1.0) angle = -270.0;
	if (ratio < 1.0 && ratio > 0.0) angle = 90.0 - 360.0 * ratio;
	PSmoveto (NSWidth([self bounds]) / 2.0, NSHeight([self bounds]) / 2.0);
	PSarcn (NSWidth([self bounds]) / 2.0, NSHeight([self bounds]) / 2.0,
			NSHeight([self bounds]) / 2.0, 90.0, angle);
	PSclosepath ();
	[fg set];
	PSfill();
	return self;
}

- renderBorder
{
	float angle = 90.0;
	if ([self isHidden]) return self;
	[bd set];
	PSarc (([self bounds].size.width / 2), ([self bounds].size.height / 2),
			([self bounds].size.height / 2), 0.0, 360.0);
	PSstroke();
	if (ratio >= 1.0) angle = -270.0;
	if ((ratio < 1.0) && (ratio > 0.0)) angle = 90.0 - 360.0 * ratio;
	PSmoveto (NSWidth([self bounds]) / 2.0, NSHeight([self bounds]) / 2.0);
	PSarcn (NSWidth([self bounds]) / 2.0, NSHeight([self bounds]) / 2.0,
			NSHeight([self bounds]) / 2.0, 90.0, angle);
	PSclosepath();
	PSstroke();
	return self;
}

- setHidden:(BOOL)aBool
{
    isHidden = aBool;
    return self;
}

- (BOOL)isHidden
{
    return isHidden;
}

- (id)initWithCoder:(NSCoder *)aDecoder
{
    [super initWithCoder:aDecoder];
    [aDecoder decodeValuesOfObjCTypes:"c", &isHidden];
    return self;
}

- (void)encodeWithCoder:(NSCoder *)aCoder
{
    [super encodeWithCoder:aCoder];
    [aCoder encodeValuesOfObjCTypes:"c", &isHidden];
}

- (NSString *)inspectorClassName
{
     return @"MiscProgressPieInspector";
}


@end

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