home *** CD-ROM | disk | FTP | other *** search
- /**********************************************************************
- ProgressView.m
-
- Author: (taken from NeXT doc, DevTools/18_CustomPalette and
- modified by David Lambert)
- Date: 9 December, 1992
- **********************************************************************/
- #import <dpsclient/wraps.h>
- #import "ProgressView.h"
-
- @implementation ProgressView
-
- - initFrame:(const NXRect *)frameRect
- {
- [super initFrame:frameRect];
- ratio = 0.0;
- total = MAXSIZE;
- stepSize = DEFAULTSTEPSIZE;
- return self;
- }
-
- - drawSelf:(const NXRect *)rects :(int)rectCount
- {
- NXRect barRect = bounds;
-
- NXInsetRect(&barRect, 2.0, 2.0);
- NXDrawGrayBezel(&bounds, &bounds);
-
- if (ratio > 0) {
- NXRect r = barRect;
- r.size.width = NX_WIDTH(&barRect) * ratio;
- PSsetgray(NX_DKGRAY);
- NXRectFill(&r);
- }
- return self;
- }
-
- - setStepSize:(int)value
- {
- stepSize = value;
- return self;
- }
-
- - (int)stepSize
- {
- return stepSize;
- }
-
- - setRatio:(float)newRatio
- {
- if (newRatio > 1.0) newRatio = 1.0;
- if (ratio != newRatio) {
- ratio = newRatio;
- [self display];
- }
- return self;
- }
-
- - increment:sender
- {
- count += stepSize;
- [self setRatio:(float)count/(float)total];
- return self;
- }
-
- - read:(NXTypedStream*)stream
- {
- [super read:stream];
- NXReadTypes(stream, "ii", &total, &stepSize);
- return self;
- }
-
- - write:(NXTypedStream*)stream
- {
- [super write:stream];
- NXWriteTypes(stream, "ii", &total, &stepSize);
- return self;
- }
-
- @end
-