home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-08-02 | 5.9 KB | 248 lines | [TEXT/KAHL] |
- /******************************************************************************
- CQTApp.cp
-
- My Application Class
-
- Copyright © 1995 Gregory Bonk, NewMedia Inc. All rights reserved.
-
- Generated by Visual Architect™ 5:28 PM Tue, Aug 1, 1995
- Portions Copyright © 1992 Joe Zobkiw. All rights reserved.
- Portions Copyright © 1995 Symantec Corporation. All rights reserved.
- ******************************************************************************/
-
- #include "CQTApp.h"
-
- #include <CDialog.h>
- #include <TCLForceReferences.h>
- #include "CQTDoc.h"
- #include "CAboutBox.h"
-
- #include <Movies.h>
- #include "CEBSwitchboard.h"
- #include "CEBCollaborator.h"
- #include "QuickTime Utilities.h"
-
- long gQuickTimeVersion;
- CEBCollaborator *gEBCollaborator;
-
-
- extern long gQuickTimeVersion;
- extern CEBCollaborator *gEBCollaborator;
-
-
- TCL_DEFINE_CLASS_M1(CQTApp, x_CQTApp);
-
- /**** C O N S T R U C T I O N / D E S T R U C T I O N M E T H O D S ****/
-
- CQTApp::CQTApp()
- {
- TCL_END_CONSTRUCTOR
- }
-
-
- CQTApp::~CQTApp()
- {
- TCL_START_DESTRUCTOR
- }
-
-
- /******************************************************************************
- ICQTApp
-
- Initialize an Application.Your initialization method should
- at least call the inherited method. If your application class
- defines its own instance variables or global variables, this
- is a good place to initialize them.
- ******************************************************************************/
- void CQTApp::ICQTApp()
- {
- OSErr err = noErr;
-
- Ix_CQTApp(4, 24000L, 20480L, 2048L);
-
- if (QuickTimeIsInstalled(&gQuickTimeVersion))
- {
- FailOSErr(EnterMovies());
- }
- else
- {
- gQuickTimeVersion = 0;
- FailOSErr(gestaltUndefSelectorErr);
- }
-
- gEBCollaborator = new CEBCollaborator();
- gEBCollaborator->IEBCollaborator();
- }
-
-
- /******************************************************************************
- ForceClassReferences {OVERRIDE}
-
- ******************************************************************************/
- void CQTApp::ForceClassReferences(void)
- {
- inherited::ForceClassReferences();
- }
-
- /******************************************************************************
- MakeSwitchboard
-
- Create application's switchboard. We use a special "Event Broadcasting"
- Switchboard that will use our gEBCollaborator instance to broadcast events
- to any available Movie Controllers before handling them itself.
-
- This is how Movie Controllers get thier events.
- ******************************************************************************/
- void CQTApp::MakeSwitchboard(void)
- {
- itsSwitchboard = new CEBSwitchboard();
- itsSwitchboard->InitAppleEvents();
- }
-
- /******************************************************************************
- SetUpFileParameters
-
- In this routine, you specify the kinds of files your
- application opens.
- ******************************************************************************/
- void CQTApp::SetUpFileParameters(void)
- {
- inherited::SetUpFileParameters(); /* Be sure to call the default method */
-
- sfNumTypes = 1;
- sfFileTypes[0] = kFileType1;
- }
-
- /**** C O M M A N D M E T H O D S ****/
-
-
- /******************************************************************************
- DoCommand {OVERRIDE}
-
- Handle application commands
- ******************************************************************************/
- void CQTApp::DoCommand(long theCommand)
- {
- FSSpec spec;
-
- switch (theCommand)
- {
- case cmdAbout:
- DoCmdAbout();
- break;
- case cmdOpen:
- if (GetMovieFileFSSpec(&spec))
- OpenQTDocument(&spec);
- break;
- default:
- inherited::DoCommand(theCommand);
- break;
- }
- }
-
-
- /******************************************************************************
- CreateDocument
-
- The user chose New from the File menu.
- In this method, you need to create a document and send it
- a NewFile() message.
- ******************************************************************************/
- void CQTApp::CreateDocument()
- {
- CQTDoc *theDocument = NULL;
-
- TRY
- {
- theDocument = new CQTDoc();
- theDocument->ICQTDoc();
- theDocument->NewFile();
- }
- CATCH
- {
- TCLForgetObject(theDocument);
- }
- ENDTRY
- }
-
- /******************************************************************************
- OpenDocument
-
- Converts the TCL’s SFReply into an FSSpec and then calls OpenQTDocument to
- open the movie document. This is only used when a movie is double-clicked
- from the Finder or an odoc AppleEvent is sent.
- ******************************************************************************/
- void CQTApp::OpenDocument(SFReply *macReply)
- {
- FSSpec spec;
-
- FailOSErr(FSMakeFSSpec(macReply->vRefNum, 0L, macReply->fName, &spec));
- this->OpenQTDocument(&spec);
- }
-
- /******************************************************************************
- OpenQTDocument
-
- Open a document using the FSSpec provided. In this case, it will be spec to a
- Movie document.
- ******************************************************************************/
- void CQTApp::OpenQTDocument(FSSpec *spec)
- {
- CQTDoc *theDocument = NULL;
-
- TRY
- {
- theDocument = new CQTDoc();
- theDocument->ICQTDoc();
- theDocument->OpenQTFile(spec);
- }
- CATCH
- {
- TCLForgetObject(theDocument);
- }
- ENDTRY
- }
-
-
- /******************************************************************************
- DoCmdAbout
-
- Show the About Box
- ******************************************************************************/
- void CQTApp::DoCmdAbout()
- {
- CAboutBox *dialog;
-
- dialog = new CAboutBox();
-
- TRY
- {
- dialog->ICAboutBox(this);
- dialog->BeginDialog();
- dialog->DoModalDialog(cmdNull);
-
- TCLForgetObject(dialog);
- }
- CATCH
- TCLForgetObject(dialog);
- ENDTRY
-
- }
-
-
- /******************************************************************************
- Exit
-
- Chances are you won't need this method.
- This is the last chance your application gets to clean up
- things like temporary files before terminating.
- ******************************************************************************/
- void CQTApp::Exit()
- {
- if (gQuickTimeVersion != 0)
- ExitMovies(); // tell QuickTime we are through
-
- if (gEBCollaborator != NULL)
- TCLForgetObject(gEBCollaborator); // nuke our global CEBCollaborator
- }
-