ITKit for Menutunes
authorMatthew Judy <mjudy@ithinksw.com>
Mon, 27 Jan 2003 09:16:48 +0000 (09:16 +0000)
committerMatthew Judy <mjudy@ithinksw.com>
Mon, 27 Jan 2003 09:16:48 +0000 (09:16 +0000)
Commit Phase 3: Adding the Deprecated Directory and Files

This checkin moves the ITChasingArrows stuff to the new Deprecated directory.

12 files changed:
Deprecated/ITChasingArrow1.tiff [new file with mode: 0755]
Deprecated/ITChasingArrow10.tiff [new file with mode: 0755]
Deprecated/ITChasingArrow2.tiff [new file with mode: 0755]
Deprecated/ITChasingArrow3.tiff [new file with mode: 0755]
Deprecated/ITChasingArrow4.tiff [new file with mode: 0755]
Deprecated/ITChasingArrow5.tiff [new file with mode: 0755]
Deprecated/ITChasingArrow6.tiff [new file with mode: 0755]
Deprecated/ITChasingArrow7.tiff [new file with mode: 0755]
Deprecated/ITChasingArrow8.tiff [new file with mode: 0755]
Deprecated/ITChasingArrow9.tiff [new file with mode: 0755]
Deprecated/ITChasingArrowsView.h [new file with mode: 0755]
Deprecated/ITChasingArrowsView.m [new file with mode: 0755]

diff --git a/Deprecated/ITChasingArrow1.tiff b/Deprecated/ITChasingArrow1.tiff
new file mode 100755 (executable)
index 0000000..2c87a94
Binary files /dev/null and b/Deprecated/ITChasingArrow1.tiff differ
diff --git a/Deprecated/ITChasingArrow10.tiff b/Deprecated/ITChasingArrow10.tiff
new file mode 100755 (executable)
index 0000000..0a27697
Binary files /dev/null and b/Deprecated/ITChasingArrow10.tiff differ
diff --git a/Deprecated/ITChasingArrow2.tiff b/Deprecated/ITChasingArrow2.tiff
new file mode 100755 (executable)
index 0000000..abda131
Binary files /dev/null and b/Deprecated/ITChasingArrow2.tiff differ
diff --git a/Deprecated/ITChasingArrow3.tiff b/Deprecated/ITChasingArrow3.tiff
new file mode 100755 (executable)
index 0000000..37a3d6b
Binary files /dev/null and b/Deprecated/ITChasingArrow3.tiff differ
diff --git a/Deprecated/ITChasingArrow4.tiff b/Deprecated/ITChasingArrow4.tiff
new file mode 100755 (executable)
index 0000000..5653961
Binary files /dev/null and b/Deprecated/ITChasingArrow4.tiff differ
diff --git a/Deprecated/ITChasingArrow5.tiff b/Deprecated/ITChasingArrow5.tiff
new file mode 100755 (executable)
index 0000000..5e6a93d
Binary files /dev/null and b/Deprecated/ITChasingArrow5.tiff differ
diff --git a/Deprecated/ITChasingArrow6.tiff b/Deprecated/ITChasingArrow6.tiff
new file mode 100755 (executable)
index 0000000..5aed596
Binary files /dev/null and b/Deprecated/ITChasingArrow6.tiff differ
diff --git a/Deprecated/ITChasingArrow7.tiff b/Deprecated/ITChasingArrow7.tiff
new file mode 100755 (executable)
index 0000000..f10726f
Binary files /dev/null and b/Deprecated/ITChasingArrow7.tiff differ
diff --git a/Deprecated/ITChasingArrow8.tiff b/Deprecated/ITChasingArrow8.tiff
new file mode 100755 (executable)
index 0000000..a1ac918
Binary files /dev/null and b/Deprecated/ITChasingArrow8.tiff differ
diff --git a/Deprecated/ITChasingArrow9.tiff b/Deprecated/ITChasingArrow9.tiff
new file mode 100755 (executable)
index 0000000..f00c467
Binary files /dev/null and b/Deprecated/ITChasingArrow9.tiff differ
diff --git a/Deprecated/ITChasingArrowsView.h b/Deprecated/ITChasingArrowsView.h
new file mode 100755 (executable)
index 0000000..46ace83
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ *     ITKit
+ *  ITChasingArrowsView
+ *    Animating Asynchronous Arrows Widget
+ *    *** DEPRECATED: NSProgressIndicator now offers an async widget.  MLJ - 01/14/2003
+ *
+ *  Original Author : Doug Brown <...>
+ *   Responsibility : Matt Judy <mjudy@ithinksw.com>
+ *   Responsibility : Joseph Spiros <joseph.spiros@ithinksw.com>
+ *
+ *  Copyright (c) 2002 - 2003 iThink Software.
+ *  All Rights Reserved
+ *
+ */
+
+
+#import <Cocoa/Cocoa.h>
+
+
+@interface ITChasingArrowsView : NSView
+{
+    BOOL running, inForeground;
+    int curIndex;
+    NSTimer *timer;
+    NSArray *images;
+}
+
+- (IBAction)stop:(id)sender;
+- (IBAction)start:(id)sender;
+
+
+@end
diff --git a/Deprecated/ITChasingArrowsView.m b/Deprecated/ITChasingArrowsView.m
new file mode 100755 (executable)
index 0000000..b903182
--- /dev/null
@@ -0,0 +1,165 @@
+#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