home *** CD-ROM | disk | FTP | other *** search
/ Nebula / nebula.bin / SourceCode / Classes / Gauges / ValuatorGauge.m < prev   
Text File  |  1993-01-19  |  2KB  |  67 lines

  1.  
  2. /* Generated by Interface Builder */
  3.  
  4. #import "ValuatorGauge.h"
  5.  
  6. @implementation ValuatorGauge
  7.  
  8. + newFrame: (NXRect *) r
  9. {
  10.     self = [super newFrame:r];
  11.     return self;
  12. }
  13.  
  14. #define POINTWIDTH    0.05    /* 5% of the scale */
  15. -drawSelf:(NXRect *)drawRects :(int)rectCount
  16. {
  17.     NXRect    dataRect;
  18.     
  19.     dataRect = FaceRect;
  20.     PScomposite(0.0,0.0,bounds.size.width,bounds.size.height,
  21.         GaugeDat.bmgState,0.0, 0.0,NX_COPY);
  22.     /* now draw the pointer */
  23.     PSsetgray(GaugeDat.ptGray);
  24.     if (NX_WIDTH(&bounds) > NX_HEIGHT(&bounds)){
  25.         /* do horizontal pointer */
  26.         NX_X(&dataRect) += (((GaugeDat.value - GaugeDat.startValue) 
  27.                 / GAUGESIZE) 
  28.                 * NX_WIDTH(&dataRect) -
  29.                 (NX_WIDTH(&FaceRect) * POINTWIDTH / 2));            
  30.         dataRect.size.width = (NX_WIDTH(&FaceRect) * POINTWIDTH);
  31.     }else{
  32.         /* do vertical pointer */
  33.         NX_Y(&dataRect) += (((GaugeDat.value - GaugeDat.startValue)
  34.                 / GAUGESIZE)
  35.                 * NX_HEIGHT(&dataRect) -
  36.                 (NX_HEIGHT(&FaceRect) * POINTWIDTH / 2));
  37.         dataRect.size.height = (NX_HEIGHT(&FaceRect) * POINTWIDTH);
  38.  
  39.     }
  40.     if (GaugeFlags.borderType == NX_NOBORDER) {
  41.         if (GaugeFlags.labelTicsOn){
  42.             PSsetlinewidth(1.0);
  43.             if (NX_WIDTH(&bounds) > NX_HEIGHT(&bounds)){
  44.                 PSmoveto(NX_X(&dataRect),NX_MAXY(&dataRect));
  45.                 PSlineto(NX_MAXX(&dataRect),NX_MAXY(&dataRect));
  46.                 PSlineto(NX_X(&dataRect)+NX_WIDTH(&dataRect)/2.,
  47.                     NX_Y(&dataRect));
  48.                 PSfill();
  49.             }else{
  50.                 PSmoveto(NX_MAXX(&dataRect),NX_MAXY(&dataRect));
  51.                 PSlineto(NX_MAXX(&dataRect),NX_Y(&dataRect));
  52.                 PSlineto(NX_X(&dataRect),
  53.                     NX_Y(&dataRect)+(NX_HEIGHT(&dataRect)/2.));
  54.                 PSfill();
  55.             }
  56.         }else NXRectFill(&dataRect);
  57.         if (GaugeFlags.overFlow) NXHighlightRect(&bounds);
  58.         return self; /* exit quick */
  59.     }
  60.     PSsetgray(GaugeDat.ticGray);
  61.     FancyRect(&dataRect);
  62.     if (GaugeFlags.overFlow) NXHighlightRect(&bounds);
  63.     return self;
  64. }
  65.  
  66. @end
  67.