home *** CD-ROM | disk | FTP | other *** search
/ The Fatted Calf / The Fatted Calf.iso / Applications / Graphics / Gnuplot / Source / TicCell.m < prev    next >
Encoding:
Text File  |  1993-03-18  |  2.1 KB  |  93 lines

  1.  
  2. static char RCSId[]="$Id: TicCell.m,v 1.1.1.1 1993/03/18 03:36:23 davis Exp $";
  3.  
  4.  
  5. #import <appkit/Font.h>
  6. #import <appkit/Text.h>        /* NXTextFontInfo()        */
  7. #import <dpsclient/wraps.h>
  8. #import <strings.h>
  9.  
  10. #import "TicCell.h"
  11. #import "TicObject.h"
  12.  
  13. #define VALUE_COLUMN_END 95.0
  14. #define STRING_COLUMN_START 100.0
  15. #define DIGITS_ACCURACY 5
  16.  
  17.  
  18. @implementation TicCell
  19.  
  20. - drawInside:(const NXRect *)cellFrame inView:controlView
  21. {
  22.     float    stringWidth;
  23.     NXRect    rectArray[2];
  24.     char    valueString[100];
  25.  
  26.     sprintf (valueString, "%.*f", DIGITS_ACCURACY, [subObject doubleValue]);
  27.    
  28.     /*  
  29.      *  Find width of the string, which depends on the font, which 
  30.      *  depends on whether we're printing or drawing.
  31.      */
  32.  
  33.     if (NXDrawingStatus == NX_DRAWING)
  34.     stringWidth = [[[support screenFont] set] getWidthOf:valueString];
  35.     else
  36.     stringWidth = [[support set] getWidthOf:valueString];
  37.  
  38.     
  39.     PSsetgray(cFlags1.highlighted ? NX_WHITE : NX_LTGRAY);     /* Erase cell */
  40.     NXRectFill(cellFrame);
  41.  
  42.  
  43.     PSsetgray(cFlags1.disabled? NX_DKGRAY : NX_BLACK);
  44.  
  45.     /*  
  46.      *  TicCells draw both the double value and the string value in 
  47.      *  the cell.  Here's the string value ("contents"):
  48.      */
  49.  
  50.     PSmoveto(NX_X(cellFrame) + STRING_COLUMN_START,
  51.              NX_Y(cellFrame) + lineHeight - descender);
  52.     PSshow(contents);
  53.     
  54.     /*  ... and the double value:  */
  55.  
  56.     PSmoveto(NX_X(cellFrame) + VALUE_COLUMN_END - stringWidth,
  57.          NX_Y(cellFrame) + lineHeight - descender);
  58.     PSshow(valueString);
  59.     
  60.  
  61.     /*  Draw the two dark gray lines above and below the cell.  */
  62.  
  63.     PSsetgray(NX_DKGRAY);
  64.     if (cFlags1.highlighted) {
  65.     /*
  66.      *  Draw 1-pixel tall rectangles instead of lines (this is 
  67.      *  faster than PSmoveto(); PSlineto()).
  68.      */
  69.     NXSetRect(&(rectArray[0]), NX_X(cellFrame), NX_Y(cellFrame),
  70.           NX_WIDTH(cellFrame), 1.0);
  71.     NXSetRect(&(rectArray[1]), NX_X(cellFrame), NX_MAXY(cellFrame) - 1.0,
  72.           NX_WIDTH(cellFrame), 1.0);
  73.  
  74.     /* 
  75.      * Using NXRectFillList is faster than separate calls to 
  76.      * NXRectFill.
  77.      */
  78.     NXRectFillList(rectArray, 2);
  79.     }
  80.  
  81.     return self;
  82. }
  83.  
  84.  
  85. // Shuts up the compiler about unused RCSId
  86. - (const char *) rcsid
  87. {
  88.     return RCSId;
  89. }
  90.  
  91.  
  92. @end
  93.