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. // // OPENSTEP conversion and mods: Todd Anthony Nathan <todd@thoughtful.com> // // 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 - initWithFrame:(NSRect)frameRect { [super initWithFrame:frameRect]; isTicsVisible = YES; isTicsOverBar = NO; numTicks = MISC_DEFALUT_TICKS; emphasis = MISC_DEFAULT_EMPHASIS; tc = [[NSColor darkGrayColor] retain]; return ( self ); } - (void) dealloc { [tc release]; [super dealloc]; return; } - (NSColor *) tickColor { return ( tc ); } - (void) setTickColor:(NSColor *)color { if ( tc != color ) { id tmp; tmp = tc; tc = [color retain]; [tmp release]; } return; } - (void) renderTicks { if ( isTicsVisible == YES ) { int linecount; [tc set]; for (linecount = 1; linecount <= numTicks; ++linecount) { int xcoord; xcoord = ([self bounds].size.width / numTicks) * linecount; PSnewpath(); PSmoveto(xcoord, 0); if ( linecount % emphasis ) { PSlineto(xcoord, (int)([self bounds].size.height / 4)); } else { PSlineto(xcoord, (int)([self bounds].size.height / 2)); } PSstroke(); } } } - (void) renderBar { if ( isTicsOverBar ) { [super renderBar]; [self renderTicks]; } else { [self renderTicks]; [super renderBar]; } return; } - (void) setTicsVisible:(BOOL)aBool { isTicsVisible = aBool; [self display]; return; } - (BOOL) isTicsVisible { return ( isTicsVisible ); } - (void) setTicsOverBar:(BOOL)aBool { isTicsOverBar = aBool; [self display]; } - (BOOL) isTicsOverBar { return ( isTicsOverBar ); } - (void) setNumTicks:(int)anInt { numTicks = MAX(anInt + 1, 1); [self display]; return; } - (int) numTicks { return ( numTicks - 1 ); } - (void) setEmphasis:(int)anInt { emphasis = MAX(anInt, 1); [self display]; return; } - (int) emphasis { return ( emphasis ); } - (id) initWithCoder:(NSCoder *)aDecoder { [super initWithCoder:aDecoder]; [aDecoder decodeValuesOfObjCTypes:"c", &isTicsVisible]; [aDecoder decodeValuesOfObjCTypes:"c", &isTicsOverBar]; [aDecoder decodeValuesOfObjCTypes:"i", &numTicks]; [aDecoder decodeValuesOfObjCTypes:"i", &emphasis]; tc = [[aDecoder decodeObject] retain]; return ( self ); } - (void) encodeWithCoder:(NSCoder *)aCoder { [super encodeWithCoder:aCoder]; [aCoder encodeValuesOfObjCTypes:"c", &isTicsVisible]; [aCoder encodeValuesOfObjCTypes:"c", &isTicsOverBar]; [aCoder encodeValuesOfObjCTypes:"i", &numTicks]; [aCoder encodeValuesOfObjCTypes:"i", &emphasis]; [aCoder encodeObject:tc]; return; } - (NSString *) inspectorClassName { return @"MiscProgressBarInspector"; } @end
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.