home *** CD-ROM | disk | FTP | other *** search
/ Big Green CD 8 / BGCD_8_Dev.iso / NEXTSTEP / Utilities / Fiend-1.4.1-src / ProgressView.m < prev    next >
Encoding:
Text File  |  1995-08-13  |  1.5 KB  |  81 lines

  1. /**********************************************************************
  2.     ProgressView.m
  3.  
  4.     Author:    (taken from NeXT doc, DevTools/18_CustomPalette and
  5.              modified by David Lambert)
  6.     Date:    9 December, 1992
  7. **********************************************************************/
  8. #import <dpsclient/wraps.h>
  9. #import "ProgressView.h"
  10.  
  11. @implementation ProgressView
  12.  
  13. - initFrame:(const NXRect *)frameRect
  14. {
  15.     [super initFrame:frameRect];
  16.     ratio = 0.0;
  17.     total = MAXSIZE;
  18.     stepSize = DEFAULTSTEPSIZE;
  19.     return self;
  20. }
  21.  
  22. - drawSelf:(const NXRect *)rects :(int)rectCount
  23. {
  24.     NXRect        barRect = bounds;
  25.  
  26.     NXInsetRect(&barRect, 2.0, 2.0);
  27.     NXDrawGrayBezel(&bounds, &bounds);
  28.  
  29.     if (ratio > 0) {
  30.         NXRect r = barRect;  
  31.         r.size.width = NX_WIDTH(&barRect) * ratio; 
  32.         PSsetgray(NX_DKGRAY);
  33.         NXRectFill(&r); 
  34.     }
  35.     return self;
  36. }
  37.  
  38. - setStepSize:(int)value
  39. {
  40.     stepSize = value;
  41.     return self;
  42. }
  43.  
  44. - (int)stepSize
  45. {
  46.     return stepSize;
  47. }
  48.  
  49. - setRatio:(float)newRatio
  50. {
  51.     if (newRatio > 1.0) newRatio = 1.0;
  52.     if (ratio != newRatio) {
  53.         ratio = newRatio;
  54.         [self display];
  55.     }
  56.     return self;
  57. }
  58.  
  59. - increment:sender
  60. {
  61.     count += stepSize;
  62.     [self setRatio:(float)count/(float)total];
  63.     return self;
  64. }
  65.  
  66. - read:(NXTypedStream*)stream
  67. {
  68.     [super read:stream];
  69.     NXReadTypes(stream, "ii", &total, &stepSize);
  70.     return self;
  71. }
  72.  
  73. - write:(NXTypedStream*)stream
  74. {
  75.     [super write:stream];
  76.     NXWriteTypes(stream, "ii", &total, &stepSize);
  77.     return self;
  78. }
  79.  
  80. @end
  81.