home *** CD-ROM | disk | FTP | other *** search
/ Nebula / nebula.bin / SourceCode / Palettes / Clocks / Inspectors.subproj / ImageWell.m < prev    next >
Text File  |  1992-12-09  |  3KB  |  98 lines

  1. //------------------------------------------------------------------------------------------------
  2. //
  3. //    ImageWell
  4. //    
  5. //    Inherits From:    Control
  6. //
  7. //    Declared In:    ImageWell.h
  8. //
  9. //    Disclaimer
  10. //
  11. //        You may freely copy, distribute and reuse this software and its
  12. //        associated documentation. I disclaim any warranty of any kind, 
  13. //        expressed or implied, as to its fitness for any particular use.
  14. //
  15. //------------------------------------------------------------------------------------------------
  16. #import "ImageWell.h"
  17.  
  18.  
  19. @implementation ImageWell
  20.  
  21. //------------------------------------------------------------------------------------------------
  22. //    Initialization and Freeing
  23. //------------------------------------------------------------------------------------------------
  24. - initFrame: (const NXRect*) frameRect
  25.     [super initFrame:frameRect];
  26.     [self setCell: [[ActionCell allocFromZone:[self zone]] init]];
  27.         [self registerForDraggedTypes:&NXFilenamePboardType count:1];
  28.     return self;
  29. }
  30.  
  31.  
  32. - free
  33. {
  34.     if (image) [image free];
  35.     return [super free];
  36. }
  37.  
  38.  
  39. //------------------------------------------------------------------------------------------------
  40. //    Accessing Image
  41. //------------------------------------------------------------------------------------------------
  42. - image: anImage
  43. {
  44.     image = anImage;
  45.     [self update];
  46.     return self;
  47. }
  48.  
  49.  
  50. - image
  51. {
  52.     return image;
  53. }
  54.  
  55.  
  56. //------------------------------------------------------------------------------------------------
  57. //    Drawing
  58. //------------------------------------------------------------------------------------------------
  59. - drawSelf: (const NXRect *)rects :(int)count
  60. {
  61.     NXSetColor ([[self window] backgroundColor]);
  62.     NXRectFill (&bounds);
  63.     [image composite:NX_SOVER toPoint:&bounds.origin];
  64.     return self;
  65. }
  66.  
  67.  
  68. //------------------------------------------------------------------------------------------------
  69. //    Dragging
  70. //------------------------------------------------------------------------------------------------
  71. - (NXDragOperation) draggingEntered:dragSource
  72. {
  73.     return NX_DragOperationGeneric;
  74. }
  75.  
  76.  
  77. - (BOOL) performDragOperation:dragSource
  78. {
  79.     id     pasteboard = [dragSource draggingPasteboard];
  80.  
  81.     if ([NXImage canInitFromPasteboard: pasteboard] == NO) return NO;
  82.     
  83.     image = [[NXImage allocFromZone: [self zone]] initFromPasteboard: pasteboard];
  84.     [[image setScalable: YES] setSize: &frame.size];
  85.     return (image ? YES : NO);
  86. }
  87.  
  88.  
  89. - concludeDragOperation:dragSource
  90. {
  91.     [[self target] perform:[self action] with:self];
  92.     [self display];
  93.     return self;
  94. }
  95.  
  96.  
  97. @end