home *** CD-ROM | disk | FTP | other *** search
- /******************************************************************************
- myApp.c
-
- Sample Application Class
-
- Copyright 1988 Gregory H. Dow. All Rights Reserved.
-
- PARENT = Application
-
- INSTANCE VARIABLES:
- OSType signature $ File creator
- short numTypes $ Number of file types recognized
- SFTypeList typeList $ Types of files recognized
-
- INSTANCE METHODS/MESSAGES: long myAppDispatcher
- $ Initialize application
- msgINITobj()
- $ Exit application
- msgEXITappl()
-
- ******************************************************************************/
-
- #include "Common.h"
- #include "GlobalVars.h"
- #include "Dispatcher.h"
- #include "CDebugger.h"
- #include "CPrinter.h"
- #include "CApplication.h"
-
- /*** Class Variables ***/
-
- static ApplicationObjH self = NULL;
- static char *className = "myApp";
- static LongFunc parent = ApplicationDispatcher;
-
- /******************************************************************************
- Do_INITobj {OVERRIDE}
-
- Initialize instance variables for an application object
- ******************************************************************************/
-
- static
- void Do_INITobj()
- {
- register ApplicationObj *selfPtr;
-
- selfPtr = *self; /* Dereference handle */
-
- OpenResFile("\pmyApp.RSRC"); /* My application's resources */
-
- /** Set instance variables **/
- selfPtr->signature = 'SubC'; /* My creator signature */
- selfPtr->numTypes = 2; /* Two file types recognized */
- selfPtr->typeList[0] = 'PICT'; /* PICT files are used */
- selfPtr->typeList[1] = 'TEXT'; /* TEXT files are used */
-
- SetUpMyMenus(); /* Install Menus */
- DrawMenuBar();
-
- /* Init the debugger object */
- gDebugger = (DebuggerObjH) NewObject(sizeof(DebuggerObj),
- DebuggerDispatcher);
- SendMsg(gDebugger, msgINITobj);
-
- /* Create printer object */
- gPrinter = (PrinterObjH) NewObject(sizeof(PrinterObj), PrinterDispatcher);
- SendMsg(gPrinter, msgINITobj);
- }
-
-
- /******************************************************************************
- myAppDispatcher
-
- Receive messages for my Application objects and invoke the
- corresponding methods
- ******************************************************************************/
-
- long myAppDispatcher(theObject, theMessage)
- ApplicationObjH theObject; /* Object receiving the message */
- short theMessage; /* The message received */
- {
- EnterDispatcher(); /* Standard dispatcher entry code */
-
- switch (theMessage) {
-
- case msgINITobj: /* Initialize the application */
- Do_INITobj();
- break;
-
- default: /* Pass message up hierarchy */
- PassToParent();
-
- }
-
- ExitDispatcher(); /* Standard dispatcher exit code */
- }