Files
FreeJ/xcode/CVFileInputView.mm
Xant 3326a82f2c Refactoring the osx project (WIP)
- Separating view logic from the real layer implementations
  (so layers can be created programmatically and associated to a
  view only if/when necessary)
- Separating the c++ glue classes from their related cocoa implementations
2009-09-11 22:14:25 +02:00

68 lines
2.1 KiB
Plaintext

//
// CVFileInputView.mm
// freej
//
// Created by xant on 9/2/09.
// Copyright 2009 __MyCompanyName__. All rights reserved.
//
#import "CVFileInputView.h"
@implementation CVFileInputView
- (void)openFilePanelDidEnd:(NSOpenPanel *)panel returnCode:(int)returnCode contextInfo:(void *)contextInfo
{
if(returnCode == NSOKButton){
func("openFilePanel: OK");
} else if(returnCode == NSCancelButton) {
func("openFilePanel: Cancel");
return;
} else {
error("openFilePanel: Error %3d",returnCode);
return;
} // end if
NSString * tvarDirectory = [panel directory];
func("openFile directory = %@",tvarDirectory);
NSString * tvarFilename = [panel filename];
func("openFile filename = %@",tvarFilename);
if (tvarFilename) {
NSDictionary *movieAttributes = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithBool:YES], QTMovieOpenAsyncOKAttribute,
tvarFilename, QTMovieFileNameAttribute,
[NSNumber numberWithBool:NO] , QTMovieHasAudioAttribute,
nil];
QTMovie *movie = [[QTMovie alloc] initWithAttributes:movieAttributes error:nil];
[movie setIdling:NO];
if (![(CVFileInputController *)layerController setQTMovie:movie])
warning("Can't open file: %s", [tvarFilename UTF8String]);
}
}
- (IBAction)openFile:(id)sender
{
NSOpenPanel *fileSelectionPanel = [NSOpenPanel openPanel];
NSArray *types = [NSArray arrayWithObjects:
@"avi", @"mov", @"mpg", @"asf", @"jpg",
@"png", @"tif", @"bmp", @"gif", @"pdf", nil];
[fileSelectionPanel
beginSheetForDirectory:nil
file:nil
types:types
modalForWindow:[sender window]
modalDelegate:self
didEndSelector:@selector(openFilePanelDidEnd: returnCode: contextInfo:)
contextInfo:nil];
[fileSelectionPanel setCanChooseFiles:YES];
} // end openFile
- (void) drawRect:(NSRect)theRect
{
[super drawRect:theRect];
}
@end