home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1 / Nebula One.iso / Graphics / Misc / BackBounce / Source / BackApp.m < prev    next >
Encoding:
Text File  |  1995-06-12  |  2.0 KB  |  74 lines

  1. #import "BackApp.h"
  2. #import <appkit/Window.h>
  3. #import "Animator.h"
  4. #import "BounceView.h"
  5. #import <defaults/defaults.h>
  6. #import <stdlib.h>
  7. #import <appkit/Bitmap.h>
  8. #import <appkit/Control.h>
  9.  
  10. @implementation BackApp
  11.  
  12. + new            // create the new application, and make us its delegate.
  13. {
  14.   self = [super new];
  15.   [self setDelegate:self];
  16.   return self;
  17. }
  18. - setIconView:anObject        // let me know where the view is.
  19.                 // Note that the View is in the Speed window,
  20.                 // but "hidden" below the bottom.  Resize from
  21.                 // IB to "find" it.  Size makes no difference here.
  22.                 // It may not need to be hidden, either, as it
  23.                 // is moved right away anyway.
  24. {
  25.   iconView=anObject;
  26.   return self;
  27. }
  28. - setSpeedSlider:anObject    // let me know where the slider is.
  29. {
  30.   speedSlider=anObject;
  31.   return self;
  32. }
  33. - appDidInit:sender            // set up in the icon, and set the timing.
  34. {
  35.   NXRect r;
  36.   const char *t;
  37.                       // So that clicking in background doesn't
  38.                     // activate BackBounce.
  39.   [[iconView window] removeFromEventMask:NX_LMOUSEDOWNMASK];
  40.                       // Moves background behind everyone else.
  41.   _NXSetWindowLevel([[iconView window] windowNum], -1);
  42.   
  43.   if( t=NXGetDefaultValue( [NXApp appName], "Speed"))    // set the speed.
  44.     [[iconView animator] setTiming:atof( t)];
  45.   [[iconView animator] start:iconView];        // and start the animator.
  46.   
  47.   [speedSlider setDoubleValue:[[iconView animator] timing]];    // fix the slider.
  48.  
  49.   [[iconView window] orderFront:self];            // get us visible.
  50.  
  51.   return self;
  52. }
  53. - terminate:sender            // store the defaults, and go away.
  54. {
  55.   char s[ 20];
  56.   sprintf( s, "%f", [[iconView animator] timing]);    // write to string,
  57.   NXWriteDefault( [self appName], "Speed", s);        // and store it.
  58.   return [super terminate:sender];
  59. }
  60. - appPowerOffIn:(int)ms andSave:(int)aFlag    // catch Workspace logout.
  61. {
  62.   return [self terminate:self];
  63. }
  64.  
  65. - windowWillResize:sender toSize:(NXSize *)s    // Just limits a window's size.
  66. {
  67.   NXRect r;
  68.   [sender getFrame:&r];
  69.   s->height=r.size.height;            // kindly change it back.
  70.   return self;
  71. }
  72.  
  73. @end
  74.