home *** CD-ROM | disk | FTP | other *** search
Text File | 1997-05-14 | 5.2 KB | 224 lines | [TEXT/CWIE] |
- // ===========================================================================
- // CFlyThroughApp.cp
- // ===========================================================================
- //
-
- #include "CFlyThroughApp.h"
-
- #include "StQD3DInitializer.h"
- #include "CQD3DErrorWindow.h" // for reporting QD3D errors
-
- #include "CQD3DPane.h"
- #include "CVehicleViewPane.h"
- #include "CFlyThroughDoc.h"
-
- #include "CAGASlider.h"
- #include "CBevelAttachment.h"
-
- #include <LGrowZone.h>
- #include <LWindow.h>
- #include <PP_Messages.h>
- #include <PP_Resources.h>
- #include <PPobClasses.h>
- #include <UDrawingState.h>
- #include <UMemoryMgr.h>
- #include <URegistrar.h>
- #include <LEditField.h>
-
- const ResIDT ALRT_QD3DNotInstalled = 1000;
-
- // ===========================================================================
- // • Main Program
- // ===========================================================================
-
- void main(void)
- {
- // Set Debugging options
- SetDebugThrow_(debugAction_Alert);
- #if 1
- SetDebugSignal_(debugAction_Alert);
- #else
- SetDebugSignal_(debugAction_SourceDebugger);
- #endif
-
- InitializeHeap(3); // Initialize Memory Manager
- // Parameter is number of Master Pointer
- // blocks to allocate
-
- // Initialize standard Toolbox managers
- UQDGlobals::InitializeToolbox(&qd);
-
- new LGrowZone(20000); // Install a GrowZone function to catch
- // low memory situations.
-
- StQD3DInitializer q3; // Initalize QuickDraw 3D
- if ( q3.GetStatus() == kQ3Success ) {
-
- CFlyThroughApp theApp;
-
- // Make the QD3D Error Message window.
- // CQD3DErrorWindow::Install( &theApp );
-
- theApp.Run();
-
- } else {
-
- // SignalPStr_("\pThis application requires QuickDraw 3D.");
- ::StopAlert( ALRT_QD3DNotInstalled, UModalFilter::GetFilter() );
-
- }
- }
-
-
- // ---------------------------------------------------------------------------
- // • CFlyThroughApp // replace this with your App type
- // ---------------------------------------------------------------------------
- // Constructor
-
- CFlyThroughApp::CFlyThroughApp()
- {
- // Register functions to create core PowerPlant classes
-
- RegisterAllPPClasses();
-
- CQD3DPane::Register();
- CVehicleViewPane::Register();
- CAGASlider::Register();
- CBevelAttachment::Register();
- }
-
-
- // ---------------------------------------------------------------------------
- // • ~CFlyThroughApp // replace this with your App type
- // ---------------------------------------------------------------------------
- // Destructor
- //
-
- CFlyThroughApp::~CFlyThroughApp()
- {
- }
-
- // ---------------------------------------------------------------------------
- // • StartUp
- // ---------------------------------------------------------------------------
- // This function lets you do something when the application starts up
- // without a document. For example, you could issue your own new command.
-
- void
- CFlyThroughApp::StartUp()
- {
- #ifdef HAS_NEW_SCENE_MENU
- ObeyCommand(cmd_8Cubes, nil);
- #else
- ObeyCommand(cmd_Open, nil);
- #endif // HAS_NEW_SCENE_MENU
- }
-
- // ---------------------------------------------------------------------------
- // • ObeyCommand
- // ---------------------------------------------------------------------------
- // Respond to commands
-
- Boolean
- CFlyThroughApp::ObeyCommand(
- CommandT inCommand,
- void *ioParam)
- {
- Boolean cmdHandled = true;
-
- switch (inCommand) {
-
- // Deal with command messages (defined in PP_Messages.h).
- // Any that you don't handle will be passed to LApplication
-
- #ifdef HAS_NEW_SCENE_MENU
- case cmd_8Cubes:
- case cmd_27Cubes:
- case cmd_64Cubes:
- case cmd_Scatter20Box:
- case cmd_Scatter40Box:
- case cmd_TriGridBox10:
- case cmd_TriGridBox30:
-
- new CFlyThroughDoc(this,inCommand);
- break;
- #endif // HAS_NEW_SCENE_MENU
-
- case cmd_Open:
- ChooseDocument();
- break;
-
- default:
- cmdHandled = LApplication::ObeyCommand(inCommand, ioParam);
- break;
- }
-
- return cmdHandled;
- }
-
- // ---------------------------------------------------------------------------
- // • FindCommandStatus
- // ---------------------------------------------------------------------------
- // This function enables menu commands.
- //
-
- void
- CFlyThroughApp::FindCommandStatus(
- CommandT inCommand,
- Boolean &outEnabled,
- Boolean &outUsesMark,
- Char16 &outMark,
- Str255 outName)
- {
-
- switch (inCommand) {
-
- // Return menu item status according to command messages.
- // Any that you don't handle will be passed to LApplication
-
- case cmd_Open:
- outEnabled = true;
- break;
-
- #ifdef HAS_NEW_SCENE_MENU
- case cmd_New:
- outEnabled = true; // enable the New sub-menu
- break;
-
- case cmd_8Cubes:
- case cmd_27Cubes:
- case cmd_64Cubes:
- case cmd_Scatter20Box:
- case cmd_Scatter40Box:
- case cmd_TriGridBox10:
- case cmd_TriGridBox30:
- outEnabled = true;
- break;
- #endif // HAS_NEW_SCENE_MENU
-
- default:
- LApplication::FindCommandStatus(inCommand, outEnabled,
- outUsesMark, outMark, outName);
- break;
- }
- }
-
- void CFlyThroughApp::OpenDocument( FSSpec *inMacFSSpec)
- {
- new CFlyThroughDoc(this, inMacFSSpec);
- }
-
- void CFlyThroughApp::ChooseDocument()
- {
- SFTypeList kTypeList = { '3DMF' };
- const Int16 kTypeCount = 1;
-
- StandardFileReply theReply;
- ::UDesktop::Deactivate();
- ::StandardGetFile( nil, kTypeCount, kTypeList, &theReply );
- ::UDesktop::Activate();
-
- if ( theReply.sfGood ) SendAEOpenDoc( theReply.sfFile );
- }
-
-