home *** CD-ROM | disk | FTP | other *** search
/ Nebula / nebula.bin / SourceCode / Classes / Rubberview / Rubberview.m < prev    next >
Text File  |  1991-12-21  |  2KB  |  121 lines

  1.  
  2. /* Generated by Interface Builder */
  3. /* 
  4.     Augmented by Slugg Jello, 
  5.     Mouthing Flowers
  6.     152 20th Ave. #1
  7.     Seattle, WA. 98112
  8.     slugg@mouthers.nwnexus.wa.com
  9. */
  10.  
  11.  
  12. #import "Rubberview.h"
  13. #import "Rubberband.h"
  14. #import <c.h>
  15. #import <appkit/Application.h>
  16. #import <appkit/Window.h>
  17. #import <appkit/NXCursor.h>
  18. #import <appkit/NXImage.h>
  19. #import <dpsclient/wraps.h>
  20. #import <appkit/graphics.h>
  21.  
  22. @implementation Rubberview
  23.  
  24. - initRubberband
  25. /* geez, ought to be able to do this in initFrame, but at that point view 
  26.     doesn't yet know its bounds */
  27. {
  28.     if (myRubberband == nil)
  29.     {
  30.         myRubberband = [[Rubberband alloc] initWithView:self];
  31.         originalBounds = bounds;
  32.     }
  33.     if (myCursorImage == nil)
  34.         myCursorImage = [[NXImage alloc] initFromSection :"brush21"];
  35.     if (myCursor == nil)
  36.         myCursor = [[NXCursor alloc] initFromImage :myCursorImage];
  37.  
  38.     return self;
  39. }
  40.  
  41. -free
  42. {
  43.     if (myRubberband)
  44.         [myRubberband free];
  45.     if (myCursor)
  46.         [myCursor free];
  47.     if (myCursorImage)
  48.         [myCursorImage free];
  49.     return [super free];
  50. }
  51.  
  52. - setRubberBounds :sender
  53. {
  54.     if (myRubberband == nil)
  55.         [self initRubberband];
  56.     
  57.     flags.gettingBounds = TRUE;
  58.     [[self window] invalidateCursorRectsForView :self];
  59.     [myRubberband setBounds :&originalBounds];
  60.     [self display];
  61.     
  62.     return self;
  63. }
  64.  
  65. - setRubberAnchor :sender
  66. {
  67.     if (myRubberband == nil)
  68.         [self initRubberband];
  69.     whichAnchor = (whichAnchor == RB_CENTER ? RB_CORNER : RB_CENTER);
  70.     [myRubberband setPivot :whichAnchor];
  71.     return sender;
  72. }
  73.  
  74. - mouseDown:(NXEvent *)theEvent
  75. {
  76.     if (myRubberband == nil)
  77.         [self initRubberband];
  78.             
  79.     [myRubberband doStretch :theEvent];
  80.     if (flags.gettingBounds)
  81.     {
  82.         [myRubberband setCurrentRectToBounds];
  83.         flags.gettingBounds = FALSE;
  84.         [[self window] invalidateCursorRectsForView :self];
  85.         [self display];
  86.     }
  87.     return self;
  88. }
  89.  
  90. - drawSelf:(const NXRect *)rects :(int)rectCount
  91. {
  92.     NXRect rect;
  93.     
  94.     PSsetgray(NX_LTGRAY);
  95.     NXRectFill(&bounds);
  96.     if (myRubberband)
  97.         [myRubberband bounds :&rect];
  98.     else
  99.         rect = bounds;
  100.     NXDrawGroove(&rect,rects);
  101.     return self;
  102. }
  103.  
  104.  
  105. - resetCursorRects
  106. {
  107.     NXRect visible;
  108.     if (flags.gettingBounds)
  109.     {
  110.         if ([self getVisibleRect:&visible])
  111.             [self addCursorRect:&visible cursor:myCursor];
  112.     }
  113.     else
  114.             [self addCursorRect:&visible cursor:nil];
  115.     return self;
  116. }
  117.  
  118.  
  119.  
  120. @end
  121.