home *** CD-ROM | disk | FTP | other *** search
/ Nebula / nebula.bin / SourceCode / MiniExamples / TIFFandEPS / ImageView.m < prev    next >
Text File  |  1993-01-19  |  1KB  |  50 lines

  1. /*  ImageView.m
  2.  *  Purpose: When a new TIFF or EPS image is opened, a window is created and
  3.  *     an instance of this class -- ImageView -- is installed as the contentView
  4.  *     for the window.  This ties the NXImage instance together with the view.
  5.  *
  6.  *  You may freely copy, distribute, and reuse the code in this example.
  7.  *  NeXT disclaims any warranty of any kind, expressed or  implied, as to its fitness
  8.  *  for any particular use.
  9.  *
  10.  */
  11.  
  12. #import <dpsclient/psops.h>
  13. #import <appkit/NXImage.h>
  14. #import "ImageView.h"
  15.  
  16. @implementation ImageView : View
  17.  
  18. - initFromImage: newImage
  19. {
  20.     NXRect imageRect = {{0.0, 0.0}, {0.0, 0.0}};
  21.     [newImage getSize:&imageRect.size];
  22.  
  23.     [super initFrame:&imageRect];
  24.     anImage = newImage;
  25.     return self;
  26. }
  27.  
  28. - image
  29. {
  30.     return anImage;
  31. }
  32.  
  33. - drawSelf:(NXRect *)rects :(int)rectCount
  34. {
  35.     NXPoint pt = {0.0, 0.0};
  36.     
  37.     PSsetgray(NX_WHITE);
  38.     NXRectFill(rects);
  39.     [anImage composite: NX_SOVER  toPoint: &pt];
  40.     return self;
  41. }
  42.  
  43. - free
  44. {
  45.     [anImage free];
  46.     return [super free];
  47. }
  48.  
  49. @end
  50.