home *** CD-ROM | disk | FTP | other *** search
/ Graphics & Sound Program…ng Techniques for the Mac / Graphics and Sound Programming Techniques for the Mac.iso / M&T Graphics & Sound Examples / Symantec Versions / C09 App-QuickTime / P01 Film Edit / FileMenu.c < prev    next >
Encoding:
Text File  |  1995-08-05  |  4.4 KB  |  165 lines  |  [TEXT/KAHL]

  1. //____________________________________________________________
  2. //    FileMenu.c
  3. //
  4. //    Copyright © Dan Parks Sydow, 1995
  5. //    From the book:
  6. //    "Graphics and Sound Programming Techniques for the Mac",
  7. //    M&T Books, 1995
  8.  
  9.  
  10. //____________________________________________________________
  11.  
  12. #include <Movies.h>
  13.   
  14. #include "Defines.h" 
  15. #include "DataTypes.h"
  16. #include "Globals.h"
  17. #include "WindRecordAccess.h"
  18. #include "MovieUtilities.h"
  19. #include "FileMenu.h"
  20.  
  21.  
  22. //____________________________________________________________
  23.  
  24. void  HandleFileMenuOpenItem( void )
  25. {
  26.    SFTypeList         typeList = { MovieFileType, 0, 0, 0 };
  27.    StandardFileReply  theReply;
  28.    OSErr              theError;
  29.    short              theFileRefNum;
  30.    Movie              theMovie;
  31.    short              theMovieResID = 0;   
  32.    Str255             theMovieResName;
  33.    Boolean            wasAltered;
  34.    WindowPtr          theWindow;
  35.    Ptr                theWindowStorage;
  36.    Rect               theMovieBox;
  37.    Rect               theBoundsRect;
  38.    MovieController    theController;
  39.  
  40.    StandardGetFilePreview( nil, 1, typeList, &theReply );
  41.  
  42.    if ( theReply.sfGood == false )
  43.       return;
  44.  
  45.    theError = OpenMovieFile( &theReply.sfFile, &theFileRefNum, fsRdWrPerm );
  46.    if ( theError != noErr )
  47.       ExitToShell();
  48.       
  49.    theError = NewMovieFromFile( &theMovie, theFileRefNum, &theMovieResID,
  50.                                  theMovieResName, newMovieActive, &wasAltered );
  51.    if ( theError != noErr )
  52.       ExitToShell();
  53.    
  54.    theWindowStorage = NewPtr( sizeof ( BigWindRecord ) );
  55.    theWindow = GetNewCWindow( rMovieWindow, theWindowStorage, (WindowPtr)-1L );   
  56.  
  57.    SetMovieGWorld( theMovie, (CGrafPtr)theWindow, nil );   
  58.  
  59.    GetMovieBox( theMovie, &theMovieBox );
  60.  
  61.    theController = NewMovieController( theMovie, &theMovieBox, mcTopLeftMovie);   
  62.  
  63.    MCSetActionFilterWithRefCon( theController,
  64.                                 NewMCActionFilterWithRefConProc( SizeChangeMCActionFilter ),
  65.                                 (long)theWindow );
  66.  
  67.    MCGetControllerBoundsRect( theController, &theBoundsRect );
  68.  
  69.    SizeWindow( theWindow, theBoundsRect.right, theBoundsRect.bottom, true );  
  70.    ShowWindow( theWindow );
  71.  
  72.    MCEnableEditing( theController, true );  
  73.  
  74.    SetWindowType( theWindow, kMovieWindowType );
  75.    SetWindowMovie( theWindow, theMovie );
  76.    SetWindowController( theWindow, theController );
  77.    SetWindowFileReference( theWindow, theFileRefNum );
  78.    SetWindowMovieResourceID( theWindow, theMovieResID );
  79.  
  80.    ++gWindowCount;
  81. }
  82.  
  83.  
  84. //____________________________________________________________
  85.  
  86. void  HandleFileMenuCloseItem( void )
  87. {
  88.    WindowPtr  theWindow;
  89.    
  90.    theWindow = FrontWindow();
  91.    CloseMovieAndFile( theWindow );
  92. }
  93.  
  94.  
  95. //____________________________________________________________
  96.  
  97. void  HandleFileMenuSaveItem( void )
  98.    WindowPtr  theWindow;
  99.    Movie      theMovie;
  100.    short      theFileRefNum;
  101.    short      theMovieResID;
  102.    
  103.    theWindow = FrontWindow();
  104.    
  105.    if ( GetWindowType( theWindow ) == kMovieWindowType )
  106.    {  
  107.       theMovie = GetWindowMovie( theWindow);
  108.       theFileRefNum = GetWindowFileReference( theWindow );
  109.       theMovieResID = GetWindowMovieResourceID( theWindow );
  110.       UpdateMovieResource( theMovie, theFileRefNum, theMovieResID, nil );   
  111.    }      
  112. }
  113.  
  114. //____________________________________________________________
  115.  
  116. void  HandleFileMenuSaveAsItem( void )
  117. {
  118.    StandardFileReply  theReply;
  119.    WindowPtr          theWindow;
  120.    Movie              theMovie;
  121.  
  122.    StandardPutFile( "\pSave as:", "\pUntitled", &theReply );
  123.  
  124.    if ( theReply.sfGood == false )
  125.       return;
  126.  
  127.    theWindow = FrontWindow();
  128.  
  129.    theMovie = GetWindowMovie( theWindow );
  130.  
  131.    FlattenMovie( theMovie, flattenAddMovieToDataFork, 
  132.                  &theReply.sfFile, 'TVOD', 0, 
  133.                  createMovieFileDeleteCurFile, nil, nil );
  134.                  
  135.    SetWTitle( theWindow, theReply.sfFile.name );
  136. }
  137.  
  138.  
  139. //____________________________________________________________
  140.  
  141. void  HandleFileMenuQuitItem( void )
  142. {
  143.    int         i;
  144.    int         theNumWindows;
  145.    WindowPtr   theWindow;
  146.    WindowPeek  theWindPeek;
  147.    WindowPtr   theNextWindow;
  148.    
  149.    theNumWindows = gWindowCount;
  150.    theWindow = FrontWindow();
  151.    
  152.    for (i = 0; i < theNumWindows; i++)
  153.    {
  154.       theWindPeek = ((WindowPeek)theWindow)->nextWindow;
  155.       theNextWindow = (WindowPtr)theWindPeek;
  156.       if ( GetWindowType( theWindow ) == kMovieWindowType )
  157.          CloseMovieAndFile( theWindow );
  158.       theWindow = theNextWindow;
  159.    }      
  160.    gDone = true;
  161. }
  162.  
  163.  
  164.