home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1995 August / NEBULA.mdf / SourceCode / MiniExamples / AppKit / TIFFandEPS / ImageView.m < prev    next >
Encoding:
Text File  |  1992-07-22  |  995 b   |  48 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 "ImageView.h"
  13.  
  14. @implementation ImageView : View
  15.  
  16. - initFromImage: newImage
  17. {
  18.     NXRect imageRect = {{0.0, 0.0}, {0.0, 0.0}};
  19.     [newImage getSize:&imageRect.size];
  20.  
  21.     [super initFrame:&imageRect];
  22.     anImage = newImage;
  23.     return self;
  24. }
  25.  
  26. - image
  27. {
  28.     return anImage;
  29. }
  30.  
  31. - drawSelf:(NXRect *)rects :(int)rectCount
  32. {
  33.     NXPoint pt = {0.0, 0.0};
  34.     
  35.     NXSetColor(NX_COLORWHITE);
  36.     NXRectFill(rects);
  37.     [anImage composite: NX_SOVER  toPoint: &pt];
  38.     return self;
  39. }
  40.  
  41. - free
  42. {
  43.     [anImage free];
  44.     return [super free];
  45. }
  46.  
  47. @end
  48.