/*
 * AppController.j
 * Tutorial-QuickTime
 *
 * Created by Philippe Laval on 2009/04/04.
 * Copyright 2009 www.nice-panorama.com . All rights reserved.
 */

@import <Foundation/CPObject.j>

@import "CPQuickTimeMovie.j"
@import "CPQuickTimeView.j"

@import "MyViewWithLayerSubclassing.j"

@implementation AppController : CPObject
{
}

- (void)applicationDidFinishLaunching:(CPNotification)aNotification
{
	/* Enable Logging (DEBUG) */
	// CPLogRegister(CPLogPopup);
    
    var theWindow = [[CPWindow alloc] initWithContentRect:CGRectMakeZero() styleMask:CPBorderlessBridgeWindowMask];
    var contentView = [theWindow contentView];

	// Create a QuickTime Movie
	var aFileName = [[CPBundle mainBundle] pathForResource:@"Biot01_3000.mov"];
	var movie = [CPQuickTimeMovie quickTimeMovieWithFile:aFileName];

	// Create a QuickTime View and associate the QuickTime Movie
	var quickTimeView = [[CPQuickTimeView alloc] initWithFrame:CGRectMake(20.0, 20.0, 540.0, 408.0)];
    [quickTimeView setAutoresizingMask:CPViewWidthSizable | CPViewHeightSizable];
    [quickTimeView setQuickTimeMovie:movie];
    [contentView addSubview:quickTimeView];

    [theWindow orderFront:self];

   [self showWindow3];
}

- (void)showWindow3
{
    var theWindow = [[CPWindow alloc] initWithContentRect:CGRectMake(300.0, 80.0, 400.0, 300.0) styleMask:CPTitledWindowMask | CPResizableWindowMask | CPClosableWindowMask];
    var contentView = [theWindow contentView];
    var bounds = [contentView bounds];

    var myView = [[MyViewWithLayerSubclassing alloc] initWithFrame:CGRectMake(10, 10, CGRectGetWidth(bounds) - 20, CGRectGetHeight(bounds) - 20)];
    [myView setAutoresizingMask:CPViewHeightSizable | CPViewWidthSizable];
    [contentView addSubview:myView];
        
    [theWindow setTitle:@"MyViewWithLayerSubclassing"];
    [theWindow orderFront:self];
}

@end
