From: Joseph Spiros Date: Sat, 7 Dec 2002 12:38:33 +0000 (+0000) Subject: Initial revision X-Git-Tag: v0.1~89 X-Git-Url: http://git.ithinksw.org/ITKit.git/commitdiff_plain/671a785b0d869478451bc428ac4e4bf3415253b4 Initial revision --- 671a785b0d869478451bc428ac4e4bf3415253b4 diff --git a/English.lproj/InfoPlist.strings b/English.lproj/InfoPlist.strings new file mode 100755 index 0000000..94fa65d Binary files /dev/null and b/English.lproj/InfoPlist.strings differ diff --git a/ITChasingArrow1.tiff b/ITChasingArrow1.tiff new file mode 100755 index 0000000..2c87a94 Binary files /dev/null and b/ITChasingArrow1.tiff differ diff --git a/ITChasingArrow10.tiff b/ITChasingArrow10.tiff new file mode 100755 index 0000000..0a27697 Binary files /dev/null and b/ITChasingArrow10.tiff differ diff --git a/ITChasingArrow2.tiff b/ITChasingArrow2.tiff new file mode 100755 index 0000000..abda131 Binary files /dev/null and b/ITChasingArrow2.tiff differ diff --git a/ITChasingArrow3.tiff b/ITChasingArrow3.tiff new file mode 100755 index 0000000..37a3d6b Binary files /dev/null and b/ITChasingArrow3.tiff differ diff --git a/ITChasingArrow4.tiff b/ITChasingArrow4.tiff new file mode 100755 index 0000000..5653961 Binary files /dev/null and b/ITChasingArrow4.tiff differ diff --git a/ITChasingArrow5.tiff b/ITChasingArrow5.tiff new file mode 100755 index 0000000..5e6a93d Binary files /dev/null and b/ITChasingArrow5.tiff differ diff --git a/ITChasingArrow6.tiff b/ITChasingArrow6.tiff new file mode 100755 index 0000000..5aed596 Binary files /dev/null and b/ITChasingArrow6.tiff differ diff --git a/ITChasingArrow7.tiff b/ITChasingArrow7.tiff new file mode 100755 index 0000000..f10726f Binary files /dev/null and b/ITChasingArrow7.tiff differ diff --git a/ITChasingArrow8.tiff b/ITChasingArrow8.tiff new file mode 100755 index 0000000..a1ac918 Binary files /dev/null and b/ITChasingArrow8.tiff differ diff --git a/ITChasingArrow9.tiff b/ITChasingArrow9.tiff new file mode 100755 index 0000000..f00c467 Binary files /dev/null and b/ITChasingArrow9.tiff differ diff --git a/ITChasingArrowsView.h b/ITChasingArrowsView.h new file mode 100755 index 0000000..4991cb6 --- /dev/null +++ b/ITChasingArrowsView.h @@ -0,0 +1,20 @@ +// +// ITChasingArrowsView.h +// +// +// Created by Doug Brown on Sat May 11 2002. +// Copyright (c) 2002 iThink Software. All rights reserved. +// + +#import + + +@interface ITChasingArrowsView : NSView { + BOOL running, inForeground; + int curIndex; + NSTimer *timer; + NSArray *images; +} +- (IBAction)stop:(id)sender; +- (IBAction)start:(id)sender; +@end diff --git a/ITChasingArrowsView.m b/ITChasingArrowsView.m new file mode 100755 index 0000000..c32bb6c --- /dev/null +++ b/ITChasingArrowsView.m @@ -0,0 +1,172 @@ +// +// ITChasingArrowsView.m +// +// +// Created by Doug Brown on Sat May 11 2002. +// Copyright (c) 2002 iThink Software. All rights reserved. +// + +#import "ITChasingArrowsView.h" + + +@implementation ITChasingArrowsView + +- (id)initWithCoder:(NSCoder *)decoder +{ + self = [super initWithCoder:decoder]; + + running = NO; + + images = [[decoder decodeObject] retain]; + + curIndex = 0; + timer = nil; + + return self; +} + +- (void)encodeWithCoder:(NSCoder *)coder +{ + [super encodeWithCoder:coder]; + + [coder encodeObject:images]; +} + +- (id)initWithFrame:(NSRect)frame { + self = [super initWithFrame:frame]; + if (self) { + NSBundle *bund = [NSBundle bundleForClass:[self class]]; + running = NO; + images = [[NSArray alloc] initWithObjects: + [[[NSImage alloc] initWithContentsOfFile:[bund pathForImageResource:@"ITChasingArrow1.tiff"]] autorelease], + [[[NSImage alloc] initWithContentsOfFile:[bund pathForImageResource:@"ITChasingArrow2.tiff"]] autorelease], + [[[NSImage alloc] initWithContentsOfFile:[bund pathForImageResource:@"ITChasingArrow3.tiff"]] autorelease], + [[[NSImage alloc] initWithContentsOfFile:[bund pathForImageResource:@"ITChasingArrow4.tiff"]] autorelease], + [[[NSImage alloc] initWithContentsOfFile:[bund pathForImageResource:@"ITChasingArrow5.tiff"]] autorelease], + [[[NSImage alloc] initWithContentsOfFile:[bund pathForImageResource:@"ITChasingArrow6.tiff"]] autorelease], + [[[NSImage alloc] initWithContentsOfFile:[bund pathForImageResource:@"ITChasingArrow7.tiff"]] autorelease], + [[[NSImage alloc] initWithContentsOfFile:[bund pathForImageResource:@"ITChasingArrow8.tiff"]] autorelease], + [[[NSImage alloc] initWithContentsOfFile:[bund pathForImageResource:@"ITChasingArrow9.tiff"]] autorelease], + [[[NSImage alloc] initWithContentsOfFile:[bund pathForImageResource:@"ITChasingArrow10.tiff"]] autorelease], + nil]; + + curIndex = 0; + timer = nil; + } + return self; +} + +- (void)dealloc +{ + if (timer) + { + [timer invalidate]; + [timer release]; + timer = nil; + } + [images release]; + + [super dealloc]; +} +- (void)drawRect:(NSRect)rect { + + if (running) + { + NSImage *curImage = [images objectAtIndex:curIndex]; + float amt; + if (inForeground) + { + amt = 1.0; + } + else + { + amt = 0.5; + } + [curImage compositeToPoint:NSMakePoint(0,0) operation:NSCompositeSourceOver fraction:amt]; + } + else + { + // draw nothing. + } +} + +- (IBAction)stop:(id)sender +{ + running = NO; + + if (timer) + { + NSNotificationCenter *nc = [NSNotificationCenter defaultCenter]; + [nc removeObserver:self]; + [timer invalidate]; + [timer release]; + timer = nil; + } + + [self setNeedsDisplay:YES]; +} + +- (IBAction)start:(id)sender +{ + if (!timer) + { + NSNotificationCenter *nc = [NSNotificationCenter defaultCenter]; + [nc addObserver:self selector:@selector(appWentToBackground:) name:NSApplicationWillResignActiveNotification object:nil]; + [nc addObserver:self selector:@selector(appWentToForeground:) name:NSApplicationWillBecomeActiveNotification object:nil]; + [nc addObserver:self selector:@selector(windowWentToBackground:) name:NSWindowDidResignMainNotification object:nil]; + [nc addObserver:self selector:@selector(windowWentToForeground:) name:NSWindowDidBecomeMainNotification object:nil]; + inForeground = ([NSApp isActive] && [[self window] isMainWindow]); + curIndex = 0; + running = YES; + timer = [[NSTimer scheduledTimerWithTimeInterval:0.05 + target:self + selector:@selector(showNewImage:) + userInfo:nil + repeats:YES] retain]; + [[NSRunLoop currentRunLoop] addTimer:timer forMode:NSEventTrackingRunLoopMode]; + } +} + +- (void)showNewImage:(NSTimer *)t +{ + [self setNeedsDisplay:YES]; + + if (curIndex == 9) + { + curIndex = 0; + } + else + { + curIndex++; + } +} + +- (void)appWentToBackground:(NSNotification *)note +{ + inForeground = NO; +} + +- (void)appWentToForeground:(NSNotification *)note +{ + inForeground = YES; +} + +- (void)windowWentToBackground:(NSNotification *)note +{ + NSWindow *window = [note object]; + if (window == [self window]) + { + inForeground = NO; + } +} + +- (void)windowWentToForeground:(NSNotification *)note +{ + NSWindow *window = [note object]; + if (window == [self window]) + { + inForeground = YES; + } +} + +@end diff --git a/ITStatusItem.h b/ITStatusItem.h new file mode 100755 index 0000000..904e962 --- /dev/null +++ b/ITStatusItem.h @@ -0,0 +1,18 @@ +// +// ITStatusItem.h +// iThinkAppKit +// +// Created by Joseph Spiros on Fri Dec 06 2002. +// Copyright (c) 2002 iThink Software. All rights reserved. +// + +#import + + +@interface ITStatusItem : NSStatusItem { + NSStatusItem *statusItem; +} +- (NSStatusItem*) statusItem; +- (NSImage*) alternateImage; +- (void) setAlternateImage:(NSImage*)image; +@end diff --git a/ITStatusItem.m b/ITStatusItem.m new file mode 100755 index 0000000..3e2ce57 --- /dev/null +++ b/ITStatusItem.m @@ -0,0 +1,33 @@ +// +// ITStatusItem.m +// iThinkAppKit +// +// Created by Joseph Spiros on Fri Dec 06 2002. +// Copyright (c) 2002 iThink Software. All rights reserved. +// + +#import "ITStatusItem.h" + + +@implementation ITStatusItem + +- (id)initWithStatusBar:(NSStatusBar*)statusBar withLength:(float)length { + statusItem = [statusBar statusItemWithLength:length]; +} + +- (NSStatusItem*) statusItem { + return statusItem; +} + +- (NSImage*) alternateImage { + return [[statusItem _button] alternateImage]; +} + +- (void) setAlternateImage:(NSImage*)image { + if ([[[[statusItem _button] cell] super] type] != 0) { + [[[statusItem _button] cell] setType:0]; + } + [[statusItem _button] setAlternateImage:image]; +} + +@end diff --git a/iThinkAppKit.h b/iThinkAppKit.h new file mode 100755 index 0000000..590b523 --- /dev/null +++ b/iThinkAppKit.h @@ -0,0 +1,3 @@ +#import +#import +#import \ No newline at end of file