mirror of
https://github.com/dyne/FreeJ.git
synced 2026-02-14 00:25:43 +01:00
- 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
68 lines
2.1 KiB
Plaintext
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
|