Added ITSplashScreen stuff. Added ITSplashScreen.h to ITKit header.
authorKent Sutherland <ksuther@ithinksw.com>
Wed, 24 Nov 2004 18:40:59 +0000 (18:40 +0000)
committerKent Sutherland <ksuther@ithinksw.com>
Wed, 24 Nov 2004 18:40:59 +0000 (18:40 +0000)
ITKit.h
ITKit.xcode/project.pbxproj
ITSplashScreen.h [new file with mode: 0644]
ITSplashScreen.m [new file with mode: 0644]
ITSplashView.h [new file with mode: 0644]
ITSplashView.m [new file with mode: 0644]
ITSplashWindow.h [new file with mode: 0644]
ITSplashWindow.m [new file with mode: 0644]

diff --git a/ITKit.h b/ITKit.h
index 8e03709..60a36c9 100755 (executable)
--- a/ITKit.h
+++ b/ITKit.h
@@ -27,6 +27,7 @@
 #import <ITKit/ITBevelView.h>
 #import <ITKit/ITTextField.h>
 #import <ITKit/ITTransientStatusWindow.h>
+#import <ITKit/ITSplashScreen.h>
 
 #import <ITKit/ITIconAndTextStatusWindow.h>
 
index 2e5e568..e8fc996 100755 (executable)
                                7C992F9B054F547C000B93EA,
                                7C993057054F6832000B93EA,
                                2AAF7B22056C3536009B9225,
+                               37B7F65C0754F8440089C005,
                                7C992DED054F5179000B93EA,
                                7C992DEE054F5179000B93EA,
                        );
                        settings = {
                        };
                };
+               37B7F65C0754F8440089C005 = {
+                       children = (
+                               37B7F6710754F87A0089C005,
+                               37B7F66F0754F87A0089C005,
+                               37B7F66C0754F87A0089C005,
+                               37B7F66B0754F87A0089C005,
+                               37B7F66D0754F87A0089C005,
+                               37B7F66E0754F87A0089C005,
+                       );
+                       isa = PBXGroup;
+                       name = SplashScreen;
+                       refType = 4;
+                       sourceTree = "<group>";
+               };
+               37B7F66B0754F87A0089C005 = {
+                       fileEncoding = 30;
+                       isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.c.objc;
+                       path = ITSplashView.m;
+                       refType = 4;
+                       sourceTree = "<group>";
+               };
+               37B7F66C0754F87A0089C005 = {
+                       fileEncoding = 30;
+                       isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.c.h;
+                       path = ITSplashView.h;
+                       refType = 4;
+                       sourceTree = "<group>";
+               };
+               37B7F66D0754F87A0089C005 = {
+                       fileEncoding = 30;
+                       isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.c.h;
+                       path = ITSplashWindow.h;
+                       refType = 4;
+                       sourceTree = "<group>";
+               };
+               37B7F66E0754F87A0089C005 = {
+                       fileEncoding = 30;
+                       isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.c.objc;
+                       path = ITSplashWindow.m;
+                       refType = 4;
+                       sourceTree = "<group>";
+               };
+               37B7F66F0754F87A0089C005 = {
+                       fileEncoding = 30;
+                       isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.c.objc;
+                       path = ITSplashScreen.m;
+                       refType = 4;
+                       sourceTree = "<group>";
+               };
+               37B7F6710754F87A0089C005 = {
+                       fileEncoding = 30;
+                       isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.c.h;
+                       path = ITSplashScreen.h;
+                       refType = 4;
+                       sourceTree = "<group>";
+               };
+               37B7F6720754F87A0089C005 = {
+                       fileRef = 37B7F66B0754F87A0089C005;
+                       isa = PBXBuildFile;
+                       settings = {
+                       };
+               };
+               37B7F6730754F87A0089C005 = {
+                       fileRef = 37B7F66C0754F87A0089C005;
+                       isa = PBXBuildFile;
+                       settings = {
+                       };
+               };
+               37B7F6740754F87A0089C005 = {
+                       fileRef = 37B7F66D0754F87A0089C005;
+                       isa = PBXBuildFile;
+                       settings = {
+                       };
+               };
+               37B7F6750754F87A0089C005 = {
+                       fileRef = 37B7F66E0754F87A0089C005;
+                       isa = PBXBuildFile;
+                       settings = {
+                       };
+               };
+               37B7F6760754F87A0089C005 = {
+                       fileRef = 37B7F66F0754F87A0089C005;
+                       isa = PBXBuildFile;
+                       settings = {
+                       };
+               };
+               37B7F6780754F87A0089C005 = {
+                       fileRef = 37B7F6710754F87A0089C005;
+                       isa = PBXBuildFile;
+                       settings = {
+                               ATTRIBUTES = (
+                                       Public,
+                               );
+                       };
+               };
 //370
 //371
 //372
                                372C5815068FE72F00CEF54A,
                                37B3906B06923D1200E828B9,
                                3747E3FA06950A0D001ACA46,
+                               37B7F6730754F87A0089C005,
+                               37B7F6740754F87A0089C005,
+                               37B7F6780754F87A0089C005,
                        );
                        isa = PBXHeadersBuildPhase;
                        runOnlyForDeploymentPostprocessing = 0;
                                372C5814068FE72F00CEF54A,
                                37B3906C06923D1200E828B9,
                                3747E3FB06950A0D001ACA46,
+                               37B7F6720754F87A0089C005,
+                               37B7F6750754F87A0089C005,
+                               37B7F6760754F87A0089C005,
                        );
                        isa = PBXSourcesBuildPhase;
                        runOnlyForDeploymentPostprocessing = 0;
diff --git a/ITSplashScreen.h b/ITSplashScreen.h
new file mode 100644 (file)
index 0000000..40ac83c
--- /dev/null
@@ -0,0 +1,25 @@
+/* ITSplashScreen */
+
+#import <Cocoa/Cocoa.h>
+
+@class ITSplashWindow, ITSplashView;
+
+@interface ITSplashScreen : NSObject
+{
+       NSTimer *_fadeTimer;
+       ITSplashWindow *_window;
+       ITSplashView *_view;
+}
++ (ITSplashScreen *)sharedController;
+
+- (double)progressValue;
+- (void)setProgressValue:(double)progress;
+- (NSImage *)image;
+- (void)setImage:(NSImage *)image;
+- (NSString *)string;
+- (void)setString:(NSString *)string;
+- (void)setSettingsPath:(NSString *)path;
+
+- (void)showSplashWindow;
+- (void)closeSplashWindow;
+@end
diff --git a/ITSplashScreen.m b/ITSplashScreen.m
new file mode 100644 (file)
index 0000000..ce7a8cd
--- /dev/null
@@ -0,0 +1,116 @@
+#import "ITSplashScreen.h"
+#import "ITSplashWindow.h"
+#import "ITSplashView.h"
+
+static ITSplashScreen *_sharedController;
+
+@implementation ITSplashScreen
+
++ (ITSplashScreen *)sharedController
+{
+       if (!_sharedController) {
+               _sharedController = [[ITSplashScreen alloc] init];
+       }
+       return _sharedController;
+}
+
+- (id)init
+{
+       if ( (self = [super init]) ) {
+               _window = [[ITSplashWindow alloc] initWithContentRect:NSMakeRect(0, 0, 200, 200) styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO];
+               _view = [[ITSplashView alloc] initWithFrame:NSMakeRect(0, 0, 200, 200)];
+               [_window setLevel:NSStatusWindowLevel];
+               [_window setContentView:[_view autorelease]];
+       }
+       return self;
+}
+
+- (void)dealloc
+{
+       [_window release];
+       [super dealloc];
+}
+
+- (double)progressValue
+{
+       return ([[_view progressIndicator] doubleValue] / 100.0);
+}
+
+- (void)setProgressValue:(double)progress
+{
+       if (progress >= 1.0) {
+               [[_view progressIndicator] setIndeterminate:YES];
+       } else {
+               [[_view progressIndicator] setDoubleValue:(progress * 100.0)];
+       }
+}
+
+- (NSImage *)image
+{
+       return [_view image];
+}
+
+- (void)setImage:(NSImage *)image
+{
+       NSRect rect = NSZeroRect, newRect = [_window frame];
+       rect.size = [image size];
+       newRect.size = rect.size;
+       [_window setFrame:newRect display:NO];
+       newRect.origin.x = 0;
+       newRect.origin.y = 0;
+       [_view setFrame:newRect];
+       [_view setImage:image];
+       [_window center];
+}
+
+- (NSString *)string
+{
+       return [_view string];
+}
+
+- (void)setString:(NSString *)string
+{
+       [_view setString:string];
+}
+
+- (void)setSettingsPath:(NSString *)path
+{
+       [_view loadControlsFromPath:path];
+}
+
+- (void)showSplashWindow
+{
+       //[_window setAlphaValue:0.0];
+       [_window makeKeyAndOrderFront:nil];
+       //_fadeTimer = [NSTimer scheduledTimerWithTimeInterval:(1.0 / 30.0) target:self selector:@selector(showStep:) userInfo:nil repeats:YES];
+}
+
+- (void)showStep:(NSTimer *)timer
+{
+       [_window setAlphaValue:[_window alphaValue] + 0.05];
+       if ([_window alphaValue] >= 1.0) {
+               [timer invalidate];
+               _fadeTimer = nil;
+       }
+}
+
+- (void)closeSplashWindow
+{
+       if (_fadeTimer) {
+               [_fadeTimer invalidate];
+       }
+       _fadeTimer = [NSTimer scheduledTimerWithTimeInterval:(1.0 / 30.0) target:self selector:@selector(closeStep:) userInfo:nil repeats:YES];
+}
+
+- (void)closeStep:(NSTimer *)timer
+{
+       [_window setAlphaValue:[_window alphaValue] - 0.05];
+       if ([_window alphaValue] <= 0.0) {
+               [timer invalidate];
+               _fadeTimer = nil;
+               [_window orderOut:nil];
+               [_view stopAnimation];
+       }
+}
+
+@end
diff --git a/ITSplashView.h b/ITSplashView.h
new file mode 100644 (file)
index 0000000..359bd3c
--- /dev/null
@@ -0,0 +1,24 @@
+//
+//  ITSplashView.h
+//  SplashScreen
+//
+//  Created by Kent Sutherland on 11/22/04.
+//  Copyright 2004 __MyCompanyName__. All rights reserved.
+//
+
+#import <Cocoa/Cocoa.h>
+
+@interface ITSplashView : NSView
+{
+       NSImage *_image;
+       NSProgressIndicator *_progress;
+       NSTextField *_text;
+}
+- (void)stopAnimation;
+- (NSProgressIndicator *)progressIndicator;
+- (NSImage *)image;
+- (NSString *)string;
+- (void)setImage:(NSImage *)image;
+- (void)setString:(NSString *)text;
+- (void)loadControlsFromPath:(NSString *)path;
+@end
diff --git a/ITSplashView.m b/ITSplashView.m
new file mode 100644 (file)
index 0000000..5c90f53
--- /dev/null
@@ -0,0 +1,118 @@
+//
+//  ITSplashView.m
+//  SplashScreen
+//
+//  Created by Kent Sutherland on 11/22/04.
+//  Copyright 2004 __MyCompanyName__. All rights reserved.
+//
+
+#import "ITSplashView.h"
+
+@implementation ITSplashView
+
+- (id)initWithFrame:(NSRect)frame
+{
+    if ( (self = [super initWithFrame:frame]) ) {
+    }
+    return self;
+}
+
+- (void)dealloc
+{
+       [_image release];
+       [_progress release];
+       [_text release];
+       [super dealloc];
+}
+
+- (void)drawRect:(NSRect)rect
+{
+       [_image compositeToPoint:NSZeroPoint operation:NSCompositeSourceOver];
+}
+
+- (BOOL)isOpaque
+{
+       return NO;
+}
+
+- (void)stopAnimation
+{
+       [_progress stopAnimation:nil];
+}
+
+- (NSProgressIndicator *)progressIndicator
+{
+       return _progress;
+}
+
+- (NSImage *)image
+{
+       return _image;
+}
+
+- (NSString *)string
+{
+       return [_text stringValue];
+}
+
+- (void)setImage:(NSImage *)image
+{
+       [_image autorelease];
+       _image = [image retain];
+}
+
+- (void)setString:(NSString *)text
+{
+       [_text setStringValue:text];
+}
+
+- (void)loadControlsFromPath:(NSString *)path
+{
+       [_progress removeFromSuperview];
+       [_progress release];
+       [_text removeFromSuperview];
+       [_text release];
+       //Reset the controls
+       NSDictionary *settings = [[NSDictionary alloc] initWithContentsOfFile:path];
+       int height = [[settings objectForKey:@"ProgressIndicator.thickness"] intValue];
+       NSControlSize size;
+       switch (height) {
+               /*case NSProgressIndicatorPreferredSmallThickness:
+                       size = NSMiniControlSize;
+               break;*/
+               case NSProgressIndicatorPreferredAquaThickness:
+                       size = NSSmallControlSize;
+               break;
+               case NSProgressIndicatorPreferredThickness:
+               default:
+                       size = NSRegularControlSize;
+               break;
+       }
+       if ([[settings objectForKey:@"ProgressIndicator.style"] intValue] == 0) {
+               //We have a normal bar
+               _progress = [[NSProgressIndicator alloc] initWithFrame:NSMakeRect([[settings objectForKey:@"ProgressIndicator.x"] intValue], [[settings objectForKey:@"ProgressIndicator.y"] intValue], [[settings objectForKey:@"ProgressIndicator.size"] intValue], height)];
+               [_progress setStyle:NSProgressIndicatorBarStyle];
+               [_progress setControlSize:size];
+               [_progress setIndeterminate:NO];
+               [_progress setMaxValue:100.0];
+               [_progress setMinValue:0.0];
+       } else {
+               //We have a spinner thinger
+               _progress = [[NSProgressIndicator alloc] initWithFrame:NSMakeRect([[settings objectForKey:@"ProgressIndicator.x"] intValue], [[settings objectForKey:@"ProgressIndicator.y"] intValue], [[settings objectForKey:@"ProgressIndicator.size"] intValue], [[settings objectForKey:@"ProgressIndicator.size"] intValue])];
+               [_progress setStyle:NSProgressIndicatorSpinningStyle];
+               [_progress setControlSize:size];
+       }
+       [self addSubview:_progress];
+       [_progress startAnimation:nil];
+       
+       _text = [[NSTextField alloc] initWithFrame:NSMakeRect([[settings objectForKey:@"StatusText.x"] intValue], [[settings objectForKey:@"StatusText.y"] intValue], [[settings objectForKey:@"StatusText.width"] intValue], 22)];
+       [_text setEditable:NO];
+       [_text setSelectable:NO];
+       [_text setBezeled:NO];
+       [_text setDrawsBackground:NO];
+       [self addSubview:_text];
+       
+       [settings release];
+}
+
+@end
diff --git a/ITSplashWindow.h b/ITSplashWindow.h
new file mode 100644 (file)
index 0000000..48c17e2
--- /dev/null
@@ -0,0 +1,8 @@
+/* ITSplashWindow */
+
+#import <Cocoa/Cocoa.h>
+
+@interface ITSplashWindow : NSWindow
+{
+}
+@end
diff --git a/ITSplashWindow.m b/ITSplashWindow.m
new file mode 100644 (file)
index 0000000..697e99e
--- /dev/null
@@ -0,0 +1,21 @@
+#import "ITSplashWindow.h"
+#import "ITSplashView.h"
+
+@implementation ITSplashWindow
+
+- (id)initWithContentRect:(NSRect)contentRect styleMask:(unsigned int)styleMask backing:(NSBackingStoreType)backingType defer:(BOOL)flag
+{
+       if ( (self = [super initWithContentRect:contentRect styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO]) ) {
+               [self setOpaque:NO];
+               [self setBackgroundColor:[NSColor clearColor]];
+               [self setHasShadow:YES];
+       }
+       return self;
+}
+
+- (BOOL)canBecomeKeyWindow
+{
+       return YES;
+}
+
+@end