//
//  try_empty_windowAppDelegate.m
//  try_empty_window
//
//  Created by david van brink on 7/22/10.
//  Copyright omino.com 2010. All rights reserved.
//

#import "OmLocAppDelegate.h"
#import "VieweyController.h"




@implementation OmLocAppDelegate

@synthesize window;


#pragma mark -
#pragma mark Application lifecycle


CGRect doR(int x,int y,int w,int h)
{
    CGRect r;
    r.origin.x = x;
    r.origin.y = y;
    r.size.width = w;
    r.size.height = h;
    return r;
}

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    
    
    [application setStatusBarHidden:YES];

    CGRect screenBounds = [[UIScreen mainScreen] applicationFrame];
    CGRect windowBounds = screenBounds;
    windowBounds.origin.y = 0.0;
    
    self.window = [[UIWindow alloc] initWithFrame:windowBounds];
    
    // Override point for customization after application launch.
	
    
    CGRect r;
    r.origin.x = 0;
    r.origin.y = 0;
    r.size.width = 320;
    r.size.height = 240;
    UIView *v = [UIView alloc];
    [v initWithFrame:(CGRect)r];
    
//     [[UIApplication sharedApplication] setStatusBarStyle: UIStatusBarStyleBlackTranslucent];
    
    UIColor *bg = [[UIColor alloc] initWithRed:1 green:0 blue:0 alpha:1];
    [v setBackgroundColor:bg];
    [bg release];
    
    UITextView *tv = [UITextView alloc];
    CGRect tvr = {
        80,80,80,80
    };
    
    [tv initWithFrame:tvr];
    tv.text = @"fishes here";
    //[tv setTextColor:(UIColor *)UIColor.whiteColor];
    //[v addSubview:tv];
    
    UISlider *sl = [UISlider alloc];
    CGRect slr = {
        20,20,280,20
    };
    [sl initWithFrame:slr];

    
//    [window addSubview:v];
//    [v addSubview:sl];

    bool useController = true;
    if(useController)
    {
        VieweyController *vc = [[VieweyController alloc] init];
        [window addSubview:vc.view];
    }
    else
    {
        self->viewey = [Viewey alloc];
        [self->viewey initWithFrame:doR(0,0,320,480)];
        [window addSubview:self->viewey];
    }
    
    [window makeKeyAndVisible];
	
	return YES;
}


- (void)applicationWillResignActive:(UIApplication *)application {
    /*
     Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
     Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
     */
}


- (void)applicationDidEnterBackground:(UIApplication *)application {
    /*
     Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 
     If your application supports background execution, called instead of applicationWillTerminate: when the user quits.
     */
}


- (void)applicationWillEnterForeground:(UIApplication *)application 
{
    /*
     Called as part of  transition from the background to the inactive state: here you can undo many of the changes made on entering the background.
     */
//    [viewey applicationWillEnterForeground];
}


- (void)applicationDidBecomeActive:(UIApplication *)application {
    /*
     Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
     */
    [viewey applicationWillEnterForeground];
}


- (void)applicationWillTerminate:(UIApplication *)application {
    /*
     Called when the application is about to terminate.
     See also applicationDidEnterBackground:.
     */
}


#pragma mark -
#pragma mark Memory management

- (void)applicationDidReceiveMemoryWarning:(UIApplication *)application {
    /*
     Free up as much memory as possible by purging cached data objects that can be recreated (or reloaded from disk) later.
     */
}


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





@end

