02.04.2013 Views

QuickTime Kit Programming Guide - filibeto.org

QuickTime Kit Programming Guide - filibeto.org

QuickTime Kit Programming Guide - filibeto.org

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

C H A P T E R 3<br />

Extending the QT<strong>Kit</strong>Player Application<br />

[[mMovieView window] setFrame:NSMakeRect(topLeft.x, topLeft.y -<br />

newWindowBounds.size.height, newWindowBounds.size.width,<br />

newWindowBounds.size.height) display:YES];<br />

}<br />

nowSizing = NO;<br />

9. To deal with NSDocument overrides, add these lines:<br />

- (NSString *)windowNibName<br />

{<br />

return @"MovieDocument";<br />

}<br />

10. To set up the movie view and set the editable state of the controller, you need to add this chunk<br />

of code. You also want to “listen” for any movie size changes, so notifications are added here.<br />

Insert the following:<br />

- (void)windowControllerDidLoadNib:(NSWindowController *)windowController<br />

{<br />

// set up the movie view<br />

if (mMovie)<br />

{<br />

NSSize contentSize = [[mMovie attributeForKey:QTMovieNaturalSizeAttribute]<br />

sizeValue];<br />

[mMovieView setMovie:mMovie];<br />

if ([mMovieView isControllerVisible])<br />

{<br />

contentSize.height += [mMovieView movieControllerBounds].size.height;<br />

if (contentSize.width == 0)<br />

{<br />

contentSize.width = kDefaultWidthForNonvisualMovies;<br />

}<br />

}<br />

[[mMovieView window] setContentSize:contentSize];<br />

}<br />

else<br />

[mMovieView setMovie:[QTMovie movie]];<br />

// set the editable state<br />

[mMovie setAttribute:[NSNumber numberWithBool:YES]<br />

forKey:QTMovieEditableAttribute];<br />

// watch for movie resizings<br />

if (mMovie)<br />

[[NSNotificationCenter defaultCenter] addObserver:self<br />

selector:@selector(sizeWindowToMovie:) name:QTMovieSizeDidChangeNotification<br />

object:mMovie];<br />

}<br />

11. To write to handle updates and saves, add the following code:<br />

- (BOOL)writeWithBackupToFile:(NSString *)fullDocumentPath ofType:(NSString<br />

*)type saveOperation:(NSSaveOperationType)saveOperation<br />

{<br />

BOOL success = NO;<br />

Adding Code to MovieDocument.m 51<br />

2005-11-09 | © 2004, 2005 Apple Computer, Inc. All Rights Reserved.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!