home *** CD-ROM | disk | FTP | other *** search
- #include <SetUpA4.h>
- #include <oops.h>
-
- /*
- * Get the name of the subclass that the glue code will use. If the
- * subclass file is funky then use the default base class CAfterDark.
- */
-
- #include "GlueCode.h"
-
- #ifndef SUBCLASS
- #include "CAfterDark.h"
- #define SUBCLASS CAfterDark
- #endif
-
- /*
- * The main() code glues together the default After Dark calling
- * mechanism to an object/message interface.
- */
- pascal OSErr main(Handle *storage, RgnHandle blankRgn,
- short message, GMParamBlockPtr params)
- {
- OSErr err = noErr;
-
- /*
- * Setup THINK C's A4 global environment.
- */
- RememberA0();
- SetUpA4();
-
- /*
- * If we've allocated storage then lock it down.
- */
- if (*storage != 0) {
- MoveHHi(*storage);
- HLock(*storage);
- }
-
- switch (message) {
- /*
- * Initialize creates a new object and assigns it to storage. If
- * there's a problem then it returns MemError() which is what After
- * Dark expects. Otherwise, lock the object down and send it an
- * Initialize message.
- */
- case Initialize:
- *storage = new(SUBCLASS);
- if (*storage == 0)
- return MemError();
- MoveHHi(*storage);
- HLock(*storage);
- err = ((CAfterDark *)*storage)->Init(blankRgn, params);
- break;
-
- /*
- * Close sends the object a Close message and then deletes the object.
- */
- case Close:
- err = ((CAfterDark *)*storage)->Close(blankRgn, params);
- delete(*storage);
- *storage = 0;
- break;
-
- /*
- * Blank just sends the object a blank message.
- */
- case Blank:
- err = ((CAfterDark *)*storage)->Blank(blankRgn, params);
- break;
-
- /*
- * DrawFrame just sends the object a blank message.
- */
- case DrawFrame:
- err = ((CAfterDark *)*storage)->DrawFrame(blankRgn, params);
- break;
-
- /*
- * The default case for other messages is to check and see
- * if they're ButtomMessages. If so, a SetUp message is sent
- * to the object.
- */
- default:
- if (message >= ButtonMessage)
- err = ((CAfterDark *)*storage)->SetUp(blankRgn, message, params);
- break;
- }
-
- /*
- * If we've allocated storage then we should unlock what we've
- * previously locked.
- */
- if (*storage != 0)
- HUnlock(*storage);
-
- /*
- * Restore THINK C's A4 global environment.
- */
- RestoreA4();
-
- return err;
- }