home *** CD-ROM | disk | FTP | other *** search
- // MADE - Macintosh Application Development Essentials
- // ---------------------------------------------------
-
- // (c) Gideon Greenspan, Sig Software - June 1997 - http://www.kagi.com/gdg/
-
- // These files can only be used for experimental standalone purposes. To obtain
- // fully commented code, and licenses for standalone, shareware, internal and
- // commercial usage, run the enclosed Register application.
-
- // Essential Shell.h
- //
- // The application entry point, initialisations and Gestalt checking.
- //
- // Version 1.0.0 - 10th November 1996
- // Version 1.0.1 - 4th June 1997
- // Fixed macro, function names
-
- #include "Essential Headers.h"
- #include "Essential Prototypes.h"
-
- Boolean applicationHasQuit=false;
- void* dummy;
-
- void main()
- {
- Error error=0;
- InitGraf(&qd.thePort);
- InitFonts();
- InitWindows();
- InitMenus();
- TEInit();
- InitDialogs(0L);
- InitCursor();
- MoreMasters();
- MaxApplZone();
-
- #if Use_AppleEvents
-
- if (CheckGestaltBit(gestaltAppleEventsAttr, gestaltAppleEventsPresent)) {
- error=InitAppleEvents();
- TestError(error);
-
- #if Insist_On_AppleEvent_Support
- if (error) goto quitApplication;
- #endif
-
- } else {
- #if Insist_On_AppleEvent_Support
- TestError(System_Software_Version_Error);
- goto quitApplication;
- #endif
- }
-
- #endif
-
- #if Use_Drag_Manager
-
- if (CheckGestaltBit(gestaltDragMgrAttr, gestaltDragMgrPresent)) {
- error=InitDragManager();
- TestError(error);
-
- #if Insist_On_Drag_Manager_Support
- if (error) goto quitApplication;
- #endif
-
- } else {
-
- #if Insist_On_Drag_Manager_Support
- TestError(System_Software_Version_Error);
- goto quitApplication;
- #endif
- }
-
- #endif
-
- #if Project_Under_Development && Initialise_Allocated_Memory
-
- dummy=(void*)NewPtr(MaxMem((Size*)&dummy));
- if (dummy) {
-
- InitialiseMemory(dummy, GetPtrSize((Ptr)dummy));
- DisposPtr((Ptr)dummy);
- }
-
- #endif
-
- error=InitMenuBar();
- TestError(error);
- if (error) goto quitApplication;
-
- MyInitialiseApplication();
-
- ExecutionBody();
-
- quitApplication:;
- }
-
- void ExecutionBody()
- {
- while (!applicationHasQuit)
- MainEventLoop();
-
- MyClearUpApplication();
-
- ExitToShell();
- }
-
- Boolean CheckGestaltBit(OSType selector, char bit)
- {
- long response;
-
- if (Gestalt(selector, &response)) return false;
- else if (!(response&(1<<bit))) return false;
- else return true;
- }
-