home *** CD-ROM | disk | FTP | other *** search
- /*****
- * CATalkApp.c
- *
- * Application methods for an appletalk typical application.
- *
- * Copyright © 1992 Bernard Bernstein. All rights reserved.
- *
- *****/
-
- #include "CATalkApp.h"
- #include "CATalkDoc.h"
-
- #include <CButton.h>
-
- extern OSType gSignature;
-
- #define kExtraMasters 4
- #define kRainyDayFund 20480
- #define kCriticalBalance 20480
- #define kToolboxBalance 20480
-
-
- /***
- * IATalkApp
- *
- * Initialize the 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 CATalkApp::IATalkApp(void)
-
- {
- CApplication::IApplication( kExtraMasters, kRainyDayFund,
- kCriticalBalance, kToolboxBalance);
-
- }
-
-
-
- /***
- * SetUpFileParameters
- *
- * In this routine, you specify the kinds of files your
- * application opens.
- *
- *
- ***/
-
- void CATalkApp::SetUpFileParameters(void)
-
- {
- inherited::SetUpFileParameters(); /* Be sure to call the default method */
-
- sfNumTypes = 1;
- sfFileTypes[0] = 'TEXT';
-
- gSignature = '????';
- }
-
-
- /***
- * SetUpMenus
- *
- * Set up menus which must be created at run time, such as a
- * Font menu. You can eliminate this method if your application
- * does not have any such menus.
- *
- ***/
-
- void CATalkApp::SetUpMenus()
- {
-
- inherited::SetUpMenus(); /* Superclass takes care of adding
- menus specified in a MBAR id = 1
- resource
- */
-
- /* Add your code for creating run-time menus here */
- }
-
-
-
- /***
- * DoCommand
- *
- * Your application will probably handle its own commands.
- * Remember, the command numbers from 1-1023 are reserved.
- * The file Commands.h contains all the predefined TCL
- * commands.
- *
- * Be sure to call the default method, so you can get
- * the default behvior for standard commands.
- *
- ***/
- void CATalkApp::DoCommand(long theCommand)
-
- {
- switch (theCommand) {
-
- /* Your commands go here */
-
- default: inherited::DoCommand(theCommand);
- break;
- }
- }
-
-
- /***
- *
- * UpdateMenus
- *
- * Perform menu management tasks
- *
- ***/
-
- void CATalkApp::UpdateMenus()
- {
- inherited::UpdateMenus(); /* Enable standard commands */
-
- /* Enable the commands handled by your Application class */
- }
-
-
- /***
- * 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 CATalkApp::Exit()
-
- {
- /* your exit handler here */
- }
-
-
- /***
- * 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 CATalkApp::CreateDocument()
-
- {
- CATalkDoc *theDocument = NULL;
-
- TRY
- {
- theDocument = new(CATalkDoc);
-
- theDocument->IATalkDoc(this, TRUE);
- theDocument->NewFile();
- }
-
- CATCH
- {
-
- if (theDocument) theDocument->Dispose();
-
- }
- ENDTRY;
- }
-
- /***
- * OpenDocument
- *
- * The user chose Open… from the File menu.
- * In this method you need to create a document
- * and send it an OpenFile() message.
- *
- * The macSFReply is a good SFReply record that contains
- * the name and vRefNum of the file the user chose to
- * open.
- *
- ***/
-
- void CATalkApp::OpenDocument(SFReply *macSFReply)
-
- {
- CATalkDoc *theDocument = NULL;
-
- TRY
- {
-
- theDocument = new(CATalkDoc);
-
- theDocument->IATalkDoc(this, TRUE);
-
- theDocument->OpenFile(macSFReply);
- }
-
- CATCH
- {
-
- if (theDocument) theDocument->Dispose();
- }
- ENDTRY;
- }
-
-
-
- /******************************************************************************
- ForceClassReferences
-
- This method creates dummy references to classes that we don't want
- stripped out by the linker when the application is built. This could
- happen if the class is only created via new_by_name and is never directly
- referenced. CApplication automatically calls this method.
-
- ******************************************************************************/
- void CATalkApp::ForceClassReferences( void)
- {
- Boolean alwaysFalse = FALSE;
- CObject *dummy = NULL;
-
- if (alwaysFalse == TRUE)
- {
- member( dummy, CButton);
- }
- }
-