home *** CD-ROM | disk | FTP | other *** search
/ Big Green CD 8 / BGCD_8_Dev.iso / OPENSTEP / Utilities / VMPages-1.0-I / VMApp.m < prev    next >
Encoding:
Text File  |  1997-01-27  |  1.9 KB  |  85 lines

  1. /* VMApp.m created by chaos on Tue 14-Jan-1997 */
  2.  
  3. #import "VMApp.h"
  4.  
  5. id    bgImage, nxImage;
  6.  
  7. @implementation VMApp:NSApplication
  8.  
  9. const char *swapName = {"/private/vm/swapfile"};
  10.  
  11. - init
  12. {
  13.     if ((self = [super init])) {
  14.         [self setDelegate:self]; // so that we get NSApp delegation methods
  15.     }
  16.     return self;
  17. }
  18.  
  19. -(void) applicationDidFinishLaunching: (NSNotification *)aNotification
  20. {
  21.     id aBundle = [NSBundle mainBundle];
  22.  
  23.  
  24.     
  25.     if (!bgImage) bgImage = [[NSImage alloc] initWithContentsOfFile: [aBundle pathForResource:@"tile" ofType:@"tiff"]];
  26.     if (!nxImage) nxImage = [[NSImage alloc] initWithContentsOfFile:[aBundle pathForResource:@"NeXT" ofType:@"tiff"]];
  27.     
  28.     period = (NSTimeInterval)1;
  29.     
  30.     timer = [NSTimer scheduledTimerWithTimeInterval: period
  31.     target:self selector:@selector(calcNow) userInfo:nil repeats:YES];
  32.  
  33.     [NSApp hide: self];
  34. }
  35.  
  36.  
  37. -(void) calcNow
  38. {
  39.     NSPoint aPoint= {0, 0};
  40.     vm_statistics_data_t    vm_stats;
  41.     float    all, angle;
  42.  
  43.     id    myImage = [bgImage copy];
  44.     id    myColor = [NSColor colorWithDeviceRed: 0.0 green:0.0 blue:0.0 alpha:0.3];
  45.     id    cheeseColor = [NSColor colorWithDeviceRed: 0.8 green:0.1 blue:0.1 alpha:1];
  46.  
  47.  
  48.     if (vm_statistics(task_self(), &vm_stats) != KERN_SUCCESS) {
  49.         //UGH!!
  50.     }
  51.  
  52.     all = (float)(vm_stats.free_count
  53.         + vm_stats.active_count
  54.         + vm_stats.inactive_count
  55.         + vm_stats.wire_count);
  56.     angle = ((vm_stats.free_count * 360.0)/all);
  57.  
  58.     [myImage lockFocus];
  59.  
  60. //    [nxImage dissolveToPoint: aPoint fraction: 0.8];
  61.  
  62.     [myColor set];
  63.     PSFilledCheese(8+3, 8-3, 48, 48, angle);
  64.  
  65.     [cheeseColor set];
  66. //    PSLineWidth(2.5);
  67.     PSFilledCheese(8, 8, 48, 48, angle);
  68.  
  69.     
  70.     [myImage unlockFocus];
  71.  
  72.     [NSApp setApplicationIconImage: myImage];
  73. }
  74.  
  75. -(void) stopApp: sender
  76. {
  77.     [timer invalidate];
  78.     [timer release];
  79.  
  80.     [self setDelegate: nil];
  81.     [self terminate: self];
  82. }
  83.  
  84. @end
  85.