home *** CD-ROM | disk | FTP | other *** search
/ Big Green CD 8 / BGCD_8_Dev.iso / Rhapsody / Graphics / Morph-2.0a / PreviewCell.m < prev    next >
Encoding:
Text File  |  1998-01-25  |  1.3 KB  |  70 lines

  1. // PreviewCell.m 
  2. //
  3. // created by Martin Wennerberg on Sun 28-Dec-1997
  4. //
  5. // when        who    modification
  6.  
  7. #import "PreviewCell.h"
  8. #import "MorphDocument.h"
  9. #import "MorphLine.h"
  10.  
  11. @implementation PreviewCell
  12. - (void) drawInteriorWithFrame:(NSRect)cellFrame inView:(NSView *)controlView
  13. {
  14.     NSEnumerator *lineEnum = [[delegate morphLines] objectEnumerator];
  15.     MorphLine     *line;
  16.     NSPoint          p;
  17.  
  18.     PSgsave();
  19.     PSscale (1, -1);
  20.     PStranslate (0, -NSMaxY(cellFrame));
  21.     [bitmap drawInRect:cellFrame];
  22.  
  23.     if (shouldDrawLines)
  24.     {
  25.         PStranslate (NSMinX(cellFrame), NSMinY(cellFrame));
  26.  
  27.         PSscale (NSWidth(cellFrame), NSHeight(cellFrame));
  28.         PSsetlinewidth(0);
  29.  
  30.         while ((line = [lineEnum nextObject]))
  31.         {
  32.             p = [line startPointAtDelta:delta];
  33.             PSmoveto(p.x, p.y);
  34.             p = [line endPointAtDelta:delta];
  35.             PSlineto(p.x, p.y);
  36.         }
  37.         [[NSColor greenColor] set];
  38.         PSstroke();
  39.    }
  40.     
  41.     PSgrestore();
  42. }
  43.  
  44. - (void) setBitmap:(NSBitmapImageRep *)obj
  45. {
  46.     [bitmap autorelease];
  47.     bitmap = [obj retain];
  48. }
  49.  
  50. - (NSBitmapImageRep *)bitmap
  51. {
  52.     return bitmap;
  53. }
  54.  
  55. - (void) setDelta:(float) val
  56. {
  57.     delta = val;
  58. }
  59.  
  60. - (void) setDelegate:(id) val
  61. {
  62.     delegate = val;    // Don't retain the delegate.
  63. }
  64.  
  65. - (void) setShouldDrawLines:(BOOL)yn
  66. {
  67.     shouldDrawLines = yn;
  68. }
  69. @end
  70.