home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-11-08 | 2.6 KB | 108 lines | [TEXT/MPCC] |
- // ----------------------------------------------------------------------------------
- // InitMain.c
- // ----------------------------------------------------------------------------------
- // Initializes constants and the toolbox.
- //
- // ----------------------------------------------------------------------------------
- // History:
- // 8/26/94 Clark Goble Original
- //
-
- #include "EventLoop.h"
- #include "MenuHandler.h"
-
- #define _Unimplemented 0xA89F
- #define _WaitNextEvent 0xA860
-
- #include "Globals.h"
-
- extern void ErrMsg(Str255 msg);
- extern Boolean TrapAvailable ( short tNum, short tType);
-
- // ----------------------------------------------------------------------------------
- // WNEIsImplemented
- // ----------------------------------------------------------------------------------
- // Determines if we have WaitNextEvent available.
-
- Boolean WNEIsImplemented( void )
- {
- SysEnvRec theWorld;
-
- SysEnvirons(1,&theWorld);
- if (theWorld.machineType < 0)
- return false;
- else
- return TrapAvailable ( _WaitNextEvent, ToolTrap);
- }
-
- // ----------------------------------------------------------------------------------
- // BuildMenuBars
- // ----------------------------------------------------------------------------------
- // Creates the menus from a resource.
-
- void BuildMenuBars(void)
- {
- Handle theMenus;
-
- theMenus = GetNewMBar(128);
-
- if(theMenus)
- { SetMenuBar(theMenus);
- AddResMenu(GetMHandle(mApple),'DRVR');
-
- // AddResMenu(GetMHandle(mFont), 'FONT');
- DrawMenuBar();
-
- } else
- {
- ErrMsg("\pMenubar resouce not loaded. Program will abort.");
- ExitToShell();
- }
- }
-
- // ----------------------------------------------------------------------------------
- // InitToolBox
- // ----------------------------------------------------------------------------------
- // Initialize all the toolbox libraries. You pass the number of master handle areas
- // that you need. For a small app four should do. If you have more handles, then
- // increase the number of Masters you use.
-
- void InitToolBox(short numberOfMasters)
- {
- SysEnvRec envRec; // Environment
-
- // Initialize Toolbox
- InitGraf(&qd.thePort);
- InitFonts();
- InitWindows();
- InitMenus();
- InitCursor();
- TEInit();
- FlushEvents(everyEvent, 0);
- InitDialogs(nil);
-
- // Initialize handles
- while(numberOfMasters--)
- MoreMasters();
-
- MaxApplZone();
-
- SysEnvirons(curSysEnvVers, &envRec);
-
- // We require at least a Mac+
- if (envRec.machineType < 0)
- ExitToShell();
-
- // Check to see if we are running System 7
- gSys7 = (envRec.systemVersion >= 0x0700);
-
-
- // Determine if we have WaitNextEvent
- gHaveWNE = WNEIsImplemented();
- InitCursor();
-
- gTextCurs = GetCursor(iBeamCursor);
- HLock ((Handle) gTextCurs);
-
- }
-