//
//  OmController.m
//  misc_test_app
//
//  Created by david van brink on 8/1/10.
//  Copyright 2010 omino.com. All rights reserved.
//

#import "OmController.h"


@implementation OmController



/*
 // The designated initializer. Override to perform setup that is required before the view is loaded.
 - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
 if ((self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])) {
 // Custom initialization
 }
 return self;
 }
 */


// Implement loadView to create a view hierarchy programmatically, without using a nib.
- (void)loadView 
{
    // I do it explicitly at attachView, instead...
}

- (void)attachView:(OmView *)newView
{
    CGRect bounds = [[UIScreen mainScreen] applicationFrame];
    
    self->omView = newView;
    [self->omView setController:self];
    [self->omView initWithFrame:bounds];
    self.view = newView;
    [self->omView setController:self];
}


/*
 // Override to allow orientations other than the default portrait orientation.
 - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
 // Return YES for supported orientations
 return (interfaceOrientation == UIInterfaceOrientationPortrait);
 }
 */

- (void)didReceiveMemoryWarning {
	// Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
	
	// Release any cached data, images, etc that aren't in use.
}

- (void)viewDidUnload {
	// Release any retained subviews of the main view.
	// e.g. self.myOutlet = nil;
}


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

+ (OmController *)allocAndInitWithOmView:(OmView *)aView
{
    OmController *oc = [OmController alloc];
    [oc init];
    [oc attachView:aView];
    return oc;
}

+ (OmController *)animateView:(OmView *)aView parentController:(UIViewController *)parentController style:(UIModalTransitionStyle)style
{
    OmController *oc = [OmController allocAndInitWithOmView:aView];
    oc.modalTransitionStyle = style;
    [parentController presentModalViewController:oc animated:YES];
    return oc;
}

+ (OmController *)animateViewFlip:(OmView *)aView parentController:(UIViewController *)parentController
{
    OmController *oc = [OmController animateView:aView parentController:parentController style:UIModalTransitionStyleFlipHorizontal];
    return oc;
}

+ (OmController *)animateViewSlide:(OmView *)aView parentController:(UIViewController *)parentController
{
    OmController *oc = [OmController animateView:aView parentController:parentController style:UIModalTransitionStyleCoverVertical];
    return oc;
}



@end
