home *** CD-ROM | disk | FTP | other *** search
- /*
- File: mtb4.c
- Contains: Main Function
- Written by: DTS and QT Engineering
- Copyright: © 1992-1994 by Apple Computer, Inc., all rights reserved.
- Change History (most recent first):
- <1> 12/4/94 khs changed the format of the file to the new look and feel
- To Do:
- */
-
-
- // INCLUDES
- #include "mtb.h"
-
-
- // MAIN
- void main(void)
- {
- WindowPtr aWindow;
- Rect windowRect;
- Rect movieBox;
- Movie aMovie;
- Boolean done = false;
- OSErr err;
- EventRecord theEvent;
- WindowPtr whichWindow;
- short part;
-
- InitGraf(&qd.thePort);
- InitFonts();
- InitWindows();
- InitMenus();
- TEInit();
- InitDialogs(nil);
- MaxApplZone();
-
- if (!IsQuickTimeInstalled())
- {
- CheckError(-1, "\pPlease install QuickTime and try again.");
- }
-
- err = EnterMovies();
- if (err)
- return;
-
- SetRect(&windowRect, 100, 100, 200, 200);
- aWindow = NewCWindow(nil, &windowRect, "\pMovie", false, noGrowDocProc, (WindowPtr) - 1, true, 0);
-
- SetPort(aWindow);
- aMovie = GetMovie();
- if (aMovie == nil)
- return;
-
- GetMovieBox(aMovie, &movieBox);
- OffsetRect(&movieBox, -movieBox.left, -movieBox.top);
- SetMovieBox(aMovie, &movieBox);
-
- SizeWindow(aWindow, movieBox.right, movieBox.bottom, true);
- ShowWindow(aWindow);
-
- SetMovieGWorld(aMovie, (CGrafPtr)aWindow, nil);
-
- StartMovie(aMovie);
-
- while (!IsMovieDone(aMovie) &&!done)
- {
- if (WaitNextEvent(everyEvent, &theEvent, 0, nil))
- {
- switch (theEvent.what)
- {
- case updateEvt:
- whichWindow = (WindowPtr)theEvent.message;
- if (whichWindow == aWindow)
- {
- BeginUpdate(whichWindow);
- UpdateMovie(aMovie);
- SetPort(whichWindow);
- EraseRect(&whichWindow->portRect);
- EndUpdate(whichWindow);
- }
- break;
-
- case mouseDown:
- part = FindWindow(theEvent.where, &whichWindow);
- if (whichWindow == aWindow)
- {
- switch (part)
- {
- case inGoAway:
- done = TrackGoAway(whichWindow, theEvent.where);
- break;
- case inDrag:
- DragWindow(whichWindow, theEvent.where, &qd.screenBits.bounds);
- break;
- }
- }
- break;
- }
- }
- MoviesTask(aMovie, DoTheRightThing);
- }
- DisposeMovie(aMovie);
- DisposeWindow(aWindow);
- }
-
-
-