This is VMApp.m in view mode; [Download] [Up]
/* VMApp.m created by chaos on Tue 14-Jan-1997 */
#import "VMApp.h"
id bgImage, nxImage;
@implementation VMApp:NSApplication
const char *swapName = {"/private/vm/swapfile"};
- init
{
if ((self = [super init])) {
[self setDelegate:self]; // so that we get NSApp delegation methods
}
return self;
}
-(void) applicationDidFinishLaunching: (NSNotification *)aNotification
{
id aBundle = [NSBundle mainBundle];
if (!bgImage) bgImage = [[NSImage alloc] initWithContentsOfFile: [aBundle pathForResource:@"tile" ofType:@"tiff"]];
if (!nxImage) nxImage = [[NSImage alloc] initWithContentsOfFile:[aBundle pathForResource:@"NeXT" ofType:@"tiff"]];
period = (NSTimeInterval)1;
timer = [NSTimer scheduledTimerWithTimeInterval: period
target:self selector:@selector(calcNow) userInfo:nil repeats:YES];
[NSApp hide: self];
}
-(void) calcNow
{
NSPoint aPoint= {0, 0};
vm_statistics_data_t vm_stats;
float all, angle;
id myImage = [bgImage copy];
id myColor = [NSColor colorWithDeviceRed: 0.0 green:0.0 blue:0.0 alpha:0.3];
id cheeseColor = [NSColor colorWithDeviceRed: 0.8 green:0.1 blue:0.1 alpha:1];
if (vm_statistics(task_self(), &vm_stats) != KERN_SUCCESS) {
//UGH!!
}
all = (float)(vm_stats.free_count
+ vm_stats.active_count
+ vm_stats.inactive_count
+ vm_stats.wire_count);
angle = ((vm_stats.free_count * 360.0)/all);
[myImage lockFocus];
// [nxImage dissolveToPoint: aPoint fraction: 0.8];
[myColor set];
PSFilledCheese(8+3, 8-3, 48, 48, angle);
[cheeseColor set];
// PSLineWidth(2.5);
PSFilledCheese(8, 8, 48, 48, angle);
[myImage unlockFocus];
[NSApp setApplicationIconImage: myImage];
}
-(void) stopApp: sender
{
[timer invalidate];
[timer release];
[self setDelegate: nil];
[self terminate: self];
}
@end
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.