//
//  HypnosisAppDelegate.m
//  Hypnosis
//
//  Created by Richard Wicentowski on 2/2/11.
//  Copyright 2011 __MyCompanyName__. All rights reserved.
//

#import "HypnosisAppDelegate.h"

@implementation HypnosisAppDelegate

@synthesize window;


#pragma mark -
#pragma mark Application lifecycle

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    
    
    // Override point for customization after application launch.
    CGRect wholeWindow = self.window.bounds;

	UIScrollView *sv = [[UIScrollView alloc] 
						initWithFrame:wholeWindow];

	// How big is the thing we want to scroll around?
	CGRect scrollViewRect;
	scrollViewRect.origin = CGPointZero;
	scrollViewRect.size.width = wholeWindow.size.width * 2;
	scrollViewRect.size.height = wholeWindow.size.height * 2;
	sv.contentSize = scrollViewRect.size;
	
	// Center the content of the scroll view
	CGPoint offset;
	offset.x = wholeWindow.size.width / 2;
	offset.y = wholeWindow.size.height / 2;
	sv.contentOffset = offset;
	
	// Enable zooming!
	sv.delegate = self;
	sv.maximumZoomScale = 5;
	sv.minimumZoomScale = 0.5;
	
	// Turn off scroll indicators, thanks to Zack O. and Jon G.
	sv.showsVerticalScrollIndicator = NO;
	sv.showsHorizontalScrollIndicator = NO;
	
	// Turn off status bar
	[[UIApplication sharedApplication] setStatusBarHidden:YES 
											withAnimation:NO];
	
	// Put scrollview in the window
	[self.window addSubview:sv];
	[sv release];

	// Create a new Hypnotic view in the large scrollViewRect
	hv = [[HypnoticView alloc] initWithFrame:scrollViewRect];
	hv.backgroundColor = [UIColor clearColor];
	
	// Put the hypnotic view in the scrollview
	[sv addSubview:hv];
	 
	
    [self.window makeKeyAndVisible];
    
    return YES;
}

#pragma mark -
#pragma mark Zooming

- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView
{
	return hv;
}


#pragma mark -
#pragma mark Memory Management

- (void)dealloc {
	[hv release];
    [window release];
    [super dealloc];
}


@end
