/* Generated by Interface Builder */

#import "ProgressView.h"
#import <dpsclient/psops.h>

@implementation ProgressView


- drawSelf:(const NXRect *)rects :(int)rectCount
{
    NXDrawGrayBezel(&bounds,&bounds);
    if (relPosition >= 0) {
        NXRect r = bounds;  
        r.size.width = 1;
        r.size.height = bounds.size.height - 4 ;
	r.origin.x = 2 + (bounds.size.width-6) * relPosition; 
	r.origin.y = bounds.origin.y + 2; 
        PSsetgray(NX_BLACK);
        NXRectFill(&r); 
    }
    return self;
}


- setPosition:(float)newPosition
{
    float del;
    if (newPosition > max) newPosition = max;
    if (newPosition < min) newPosition = min;
    del = max - min;
    relPosition = 0;
    if (del) relPosition = (newPosition - min) / del;
    else relPosition = 0;
    position = newPosition;
    [self display];
    return self;
}

- setMin:(float)newMin
{
    min = newMin;
    [self setPosition: position];
    [self display];
    return self;
}

- setMax:(float)newMax
{
    max = newMax;
    [self setPosition: position];
    [self display];
    return self;
}

- reset
{
    min = 0;
    max = 0;
    return self;
}

- (float)relPosition;
{
    return relPosition;
}

- takeFloatValueFrom:sender
{
    [self setPosition:(float)[sender floatValue]];
    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
