home *** CD-ROM | disk | FTP | other *** search
- #include "DropShell3.h"
-
- #include <Memory.h>
- #include <Resources.h>
- #include <Errors.h>
- #include <string.h>
- #include <iostream>
-
- #include <SIOUX.h> /* To manipulate the console */
- #include <SIOUXGlobals.h> /* To manipulate the console */
- #include <SIOUXMenus.h> /* To manipulate the console menus */
-
- #include "DS3Resources.h"
- // #include "FileLib.h"
- // #include "GenLib.h"
-
- #include "AEHandlers.h"
-
- class CPSRunner : public CDropShell {
- public:
- CPSRunner ( Boolean walkFolders = false ) : CDropShell ( walkFolders ) {}
- virtual ~CPSRunner () {}
-
- void EventLoop( void );
- OSErr InitGlobals ( void );
- void DeInitGlobals ( void );
-
- OSErr InitAEVTStuff (void);
- void QuitApp ( void );
-
- OSErr ProcessItem ( FSSpec &theFile );
- void SelectFile ( void ) ;
- void SelectFile ( AEEventClass inClass, AEEventID inID );
-
- void SetUpMenus (void);
- void DoMenu ( long menuChoice ) ;
- void DoMouseDown ( EventRecord *curEvent ) ;
-
- private:
- };
-
- void CPSRunner::QuitApp (void)
- {
- fDone = true;
- SIOUXQuitting = true;
- SIOUXTextWindow->dirty = false; // this will make sure it doesn't ask to save!
- }
-
- OSErr CPSRunner::InitGlobals( void )
- {
- SIOUXSettings.initializeTB = false;
- SIOUXSettings.standalone = true;
- SIOUXSettings.setupmenus = false;
-
- // ClearMenuBar(); /* 1.2 ZSS - if we use SIOUX, we clear the menubar and let it take over... */
-
- // cout << "Welcome to PDF Library Tester" << endl;
- return noErr;
- }
-
- void CPSRunner::DeInitGlobals ( void )
- {
- }
-
-
- void CPSRunner::SetUpMenus (void)
- {
- // install the SIOUX menus
- SIOUXSetupMenus();
-
- // install any custom menus of our own
- // MenuHandle hMenu = GetMenu ( kToolsNum );
- // InsertMenu ( hMenu, 0 );
- DrawMenuBar();
- }
-
- void CPSRunner::DoMenu ( long menuChoice )
- {
- short menuID, itemID;
-
- menuID = HiWord ( menuChoice );
- itemID = LoWord ( menuChoice );
-
- switch ( menuID ) {
-
- default:
- SIOUXDoMenuChoice(menuChoice);
- break;
-
- }
-
- HiliteMenu ( 0 ); // turn off the menu
- }
-
- void CPSRunner::DoMouseDown ( EventRecord *curEvent )
- {
- WindowPtr whichWindow;
- short whichPart;
-
- whichPart = FindWindow ( curEvent->where, &whichWindow );
- switch ( whichPart ) {
- case inMenuBar:
- SIOUXUpdateMenuItems();
- DoMenu ( MenuSelect ( curEvent->where ));
- break;
-
- default:
- break;
- }
- }
-
- void CPSRunner::EventLoop( void )
- {
- EventRecord anEvent;
-
- Boolean haveEvent = WaitNextEvent ( everyEvent, &anEvent, 0, NULL );
- Boolean handled = false;
-
- // don't let SIOUX do my high levels!
- if (anEvent.what != kHighLevelEvent)
- handled = SIOUXHandleOneEvent( &anEvent );
-
- if (haveEvent && !handled) {
- switch ( anEvent.what ) {
- case kHighLevelEvent:
- AEProcessAppleEvent ( &anEvent );
- break;
-
- case mouseDown:
- DoMouseDown ( &anEvent );
- break;
-
- case keyDown:
- case autoKey:
- DoKeyDown ( &anEvent );
- break;
-
- case diskEvt:
- if ( HiWord ( anEvent.message )) {
- Point diskInitPt = { 100, 100 };
-
- DILoad ();
- DIBadMount ( diskInitPt, anEvent.message );
- DIUnload ();
- }
- break;
-
- default:
- break;
- }
- }
-
- if (SIOUXQuitting) fDone = true;
- }
-
-
- OSErr CPSRunner::InitAEVTStuff ()
- {
- CDropShell::InitAEVTStuff(); // call the base & install the default
-
- OSErr err = noErr;
-
- // now for all our app specific ones
- err = AEInstallEventHandler ( kAEMiscStandards, kAEDoScript,
- NewAEEventHandlerProc ( HandleDoScript ), 0, false );
-
- return err;
- }
-
- void CPSRunner::SelectFile ()
- {
- StandardFileReply stdReply;
- SFTypeList theTypeList = {'TEXT'};
-
- StandardGetFile ( NULL, 4, theTypeList, &stdReply );
- if ( stdReply.sfGood ) // user did not cancel
- SendODOCToSelf ( &stdReply.sfFile ); // so send me an event!
- }
-
- OSErr CPSRunner::ProcessItem ( FSSpec &theFile )
- {
- #pragma unused (theFile)
-
- OSErr err = noErr;
-
- // will never get here, but just in case!
- Debugger();
-
- return err;
- }
-
-
- /*
- Main Program for the Demo App
- */
-
- void main ( void )
- {
- CPSRunner *theApp;
-
- // Create the app
- // true --> handle folders as collections
- // false --> handle folders as individual items
- theApp = new CPSRunner ( true );
-
- // Run the app
- theApp->Run ();
-
- // kill it off
- delete theApp;
- }
-
- #pragma segment CompilerCruft
-