home *** CD-ROM | disk | FTP | other *** search
/ Super Net 1 / SUPERNET_1.iso / PC / OTROS / UNIX / ARCHIE / CLIENTS / NEXTARCH / PERCENTV.M < prev    next >
Encoding:
Text File  |  1992-01-21  |  993 b   |  54 lines

  1. #import <PercentView.h>
  2. #import <dpsclient/dpsclient.h>
  3. #import <dpsclient/wraps.h>
  4. #import <appkit/nextstd.h>
  5. #import <appkit/graphics.h>
  6.  
  7. @implementation PercentView
  8.  
  9. - displayPercent: (float) p
  10. {
  11. float dp;
  12.     dp = ABS(percent - p);
  13.     if(p != 1.0 && dp < 0.02)
  14.         return nil; 
  15.     percent = p;
  16.     [self display];
  17.     return self;
  18. }
  19.  
  20. - drawSelf: (const NXRect *) rects :(int) rectCount
  21. {
  22. float x,y,dx,dy;
  23. float r,endAngle;
  24.  
  25.     if(rectCount == 0)
  26.         return self;
  27.  
  28.     /* Calculate my center and half width */
  29.     dx = bounds.size.width / 2.0;
  30.     x =  dx + bounds.origin.x;
  31.     dy = bounds.size.height / 2.0;
  32.     y = dy + bounds.origin.y;
  33.     r = MIN(dx,dy);
  34.     r -= 2;
  35.     endAngle = 90.0 - 360.0 * percent;
  36.     /* Erase my bounds */
  37.     PSsetgray(NX_LTGRAY);
  38.     NXRectFill(&bounds);
  39.  
  40.     /* Draw black circle */
  41.     PSsetgray(NX_BLACK);
  42.     PSarc(x, y, r, 0.0, 360.0);
  43.     PSstroke();
  44.     r --;
  45.     PSsetgray(NX_DKGRAY);
  46.     PSmoveto(x,y);
  47.     PSarcn(x,y,r,90.0, endAngle);
  48.     PSfill();
  49.  
  50.     return self;
  51. }
  52.  
  53. @end
  54.