ftp.nice.ch/pub/next/developer/resources/classes/misckit/MiscKit.1.10.0.s.gnutar.gz#/MiscKit/Palettes/MiscProgressPalette/MiscProgressView.subproj/MiscProgressBar.m

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

//
//	MiscProgressBar.h -- a simple view class for displaying progress bar
//		Written and Copyright (c) 1993 by James Heiser.  (jheiser@adobe.com)
//				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.
//	


// Added two methoods -setTicsVisible: (BOOL) and -isTicsVisible:
// Allows the user to select whether ticmarks are Visible or not.
// James Heiser  Sat Sep 25 13:59:15 GMT-0800 1993
//
// Added two methoods -setTicsOverBar:(BOOL) and -isTicsOverBar
// Allows the user to select whether ticmarks are drawn above or
// below progress bar.
// Don Yacktman  Mon Oct 18 22:58:52 MDT 1993
//
// Added two methoods -setTickColor:(NXColor) and -tickColor
// Allows user to set color of ticmarks.
// Don Yacktman  Mon Oct 18 22:58:52 MDT 1993

#import "MiscProgressBar.h"

#define MISC_DEFALUT_TICKS 24		// number of ticks to show + 1
									// (so 24 divisions between 0-1 ratio)
									
#define MISC_DEFAULT_EMPHASIS 3		// every nth tick is longer...


@implementation MiscProgressBar

- initFrame:(const NXRect *)frameRect
{
    [super initFrame:frameRect];
	isTicsVisible = YES;
	isTicsOverBar = NO;
	numTicks = MISC_DEFALUT_TICKS;
	emphasis = MISC_DEFAULT_EMPHASIS;
	tc = NXConvertGrayToColor(NX_DKGRAY);
    return self;
}

- (NXColor)tickColor { return tc; }

- setTickColor:(NXColor)color
{
	tc = color;
	return self;
}

- renderTicks
{
	if (isTicsVisible == YES)  {
		int linecount;
		NXSetColor(tc);
		for (linecount = 1; linecount <= numTicks; ++linecount)  {
			int xcoord = (bounds.size.width / numTicks) * linecount;
			PSnewpath();
			PSmoveto(xcoord, 0);
			if (linecount % emphasis)
				PSlineto(xcoord, (int)(bounds.size.height / 4));
			else PSlineto(xcoord, (int)(bounds.size.height / 2));
			PSstroke();
		}
	}
	return self;
}

- renderBar
{
	if (isTicsOverBar) {
		[super renderBar];
		[self renderTicks];
	} else {
		[self renderTicks];
		[super renderBar];
	}
	return self;
}

- setTicsVisible:(BOOL)aBool
{
    isTicsVisible = aBool;
	[self display];
    return self;
}

- (BOOL)isTicsVisible
{
    return isTicsVisible;
}

- setTicsOverBar:(BOOL)aBool
{
    isTicsOverBar = aBool;
	[self display];
    return self;
}

- (BOOL)isTicsOverBar
{
    return isTicsOverBar;
}

- setNumTicks:(int)anInt
{
    numTicks = MAX(anInt + 1, 1);
	[self display];
    return self;
}

- (int)numTicks
{
    return (numTicks - 1);
}

- setEmphasis:(int)anInt
{
    emphasis = MAX(anInt, 1);
	[self display];
    return self;
}

- (int)emphasis
{
    return emphasis;
}


- read:(NXTypedStream*)stream
{
    [super read:stream];
	NXReadTypes(stream, "ccii", &isTicsVisible, &isTicsOverBar,
			&numTicks, &emphasis);
	tc = NXReadColor(stream);
    return self;
}

- write:(NXTypedStream*)stream
{
    [super write:stream];
    NXWriteTypes(stream, "ccii", &isTicsVisible, &isTicsOverBar,
			&numTicks, &emphasis);
	NXWriteColor(stream, tc);
    return self;
}

- (const char *)getInspectorClassName
{
     return "MiscProgressBarInspector";
}


@end

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