home *** CD-ROM | disk | FTP | other *** search
/ Super Net 1 / SUPERNET_1.iso / PC / OTROS / UNIX / ARCHIE / CLIENTS / NEXTARCH.TAR / NeXTArchie / MorphView.m < prev    next >
Encoding:
Text File  |  1992-01-22  |  1.2 KB  |  64 lines

  1. #import "MorphView.h"
  2.  
  3. #import <appkit/Button.h>
  4. #import <appkit/NXImage.h>
  5. #import <dpsclient/dpsclient.h>
  6.  
  7. #define MORPH_DELAY 2000
  8.  
  9. @implementation MorphView
  10.  
  11. - initFrame: (NXRect *) theFrame
  12. {
  13.     [super initFrame: theFrame];
  14.     image0 = [NXImage findImageNamed: "scottInfo"];
  15.     image1 = [NXImage findImageNamed: "otherInfo"];
  16.     return self;
  17. }
  18.  
  19. - morph : sender
  20. {
  21. float delta;
  22. int n;
  23. id tmpImage;
  24. static BOOL morphingActive = NO;
  25. static id lastSender;
  26.  
  27.     [self lockFocus];
  28.     for(delta = 0; delta <= 1.0; delta += 0.05)
  29.     {
  30.         [image0 composite:NX_SOVER toPoint: &bounds.origin];
  31.         [image1 dissolve: delta toPoint: &bounds.origin];
  32.         [window flushWindow];
  33.         for(n = 0; n < 100000; n ++);
  34.     }
  35.     [image1 composite:NX_SOVER toPoint: &bounds.origin];
  36.     [window flushWindow];
  37.     [self unlockFocus];
  38.     tmpImage = image0;
  39.     image0 = image1;
  40.     image1 = tmpImage;
  41.     if(morphingActive == NO)
  42.     {
  43.         lastSender = [sender setEnabled: NO];
  44.         [self perform: _cmd with: self 
  45.             afterDelay: MORPH_DELAY cancelPrevious: YES];
  46.         morphingActive = YES;
  47.     }
  48.     else
  49.     {
  50.         morphingActive = NO;
  51.         [lastSender setEnabled: YES];
  52.     }
  53.  
  54.     return self;
  55. }
  56.  
  57. - drawSelf:(const NXRect *) rects :(int) rectCount
  58. {
  59.     [image0 composite: NX_SOVER toPoint: &bounds.origin];
  60.     return self;
  61. }
  62.  
  63. @end
  64.