home *** CD-ROM | disk | FTP | other *** search
/ QuickTime 2.0 Developer Kit / QuickTime 2.0 Developer Kit.iso / mac / MAC / Programming Stuff / Sample Code / Movie Toolbox / Inside Mac Movie Toolbox Code / mtb4.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-12-05  |  2.1 KB  |  107 lines  |  [TEXT/MPS ]

  1. /*
  2.   File:            mtb4.c
  3.   Contains:        Main Function
  4.   Written by:    DTS and QT Engineering
  5.   Copyright:    © 1992-1994 by Apple Computer, Inc., all rights reserved.
  6.   Change History (most recent first):
  7.   <1>         12/4/94    khs        changed the format of the file to the new look and feel
  8.   To Do:
  9. */
  10.  
  11.  
  12. // INCLUDES
  13. #include "mtb.h"
  14.  
  15.  
  16. // MAIN
  17. void main(void)
  18. {
  19.     WindowPtr aWindow;
  20.     Rect windowRect;
  21.     Rect movieBox;
  22.     Movie aMovie;
  23.     Boolean done = false;
  24.     OSErr err;
  25.     EventRecord theEvent;
  26.     WindowPtr whichWindow;
  27.     short part;
  28.  
  29.     InitGraf(&qd.thePort);
  30.     InitFonts();
  31.     InitWindows();
  32.     InitMenus();
  33.     TEInit();
  34.     InitDialogs(nil);
  35.     MaxApplZone();
  36.  
  37.     if (!IsQuickTimeInstalled())
  38.     {
  39.         CheckError(-1, "\pPlease install QuickTime and try again.");
  40.     }
  41.  
  42.     err = EnterMovies();
  43.     if (err)
  44.         return;
  45.  
  46.     SetRect(&windowRect, 100, 100, 200, 200);
  47.     aWindow = NewCWindow(nil, &windowRect, "\pMovie", false, noGrowDocProc, (WindowPtr) - 1, true, 0);
  48.  
  49.     SetPort(aWindow);
  50.     aMovie = GetMovie();
  51.     if (aMovie == nil)
  52.         return;
  53.  
  54.     GetMovieBox(aMovie, &movieBox);
  55.     OffsetRect(&movieBox, -movieBox.left, -movieBox.top);
  56.     SetMovieBox(aMovie, &movieBox);
  57.  
  58.     SizeWindow(aWindow, movieBox.right, movieBox.bottom, true);
  59.     ShowWindow(aWindow);
  60.  
  61.     SetMovieGWorld(aMovie, (CGrafPtr)aWindow, nil);
  62.  
  63.     StartMovie(aMovie);
  64.  
  65.     while (!IsMovieDone(aMovie) &&!done)
  66.     {
  67.         if (WaitNextEvent(everyEvent, &theEvent, 0, nil))
  68.         {
  69.             switch (theEvent.what)
  70.             {
  71.                 case updateEvt:
  72.                     whichWindow = (WindowPtr)theEvent.message;
  73.                     if (whichWindow == aWindow)
  74.                     {
  75.                         BeginUpdate(whichWindow);
  76.                         UpdateMovie(aMovie);
  77.                         SetPort(whichWindow);
  78.                         EraseRect(&whichWindow->portRect);
  79.                         EndUpdate(whichWindow);
  80.                     }
  81.                     break;
  82.  
  83.                 case mouseDown:
  84.                     part = FindWindow(theEvent.where, &whichWindow);
  85.                     if (whichWindow == aWindow)
  86.                     {
  87.                         switch (part)
  88.                         {
  89.                             case inGoAway:
  90.                                 done = TrackGoAway(whichWindow, theEvent.where);
  91.                                 break;
  92.                             case inDrag:
  93.                                 DragWindow(whichWindow, theEvent.where, &qd.screenBits.bounds);
  94.                                 break;
  95.                         }
  96.                     }
  97.                     break;
  98.             }
  99.         }
  100.         MoviesTask(aMovie, DoTheRightThing);
  101.     }
  102.     DisposeMovie(aMovie);
  103.     DisposeWindow(aWindow);
  104. }
  105.  
  106.  
  107.