Retired Document
Important: This sample code may not represent best practices for current development. The project may use deprecated symbols and illustrate technologies and techniques that are no longer recommended.
TumblerSource/Tumbler_initialize.c
// initialize.c |
// |
// Initialization routines. |
// |
// |
// Author: Nick Thompson & Pablo Fernicola, with thanks to the QuickDraw 3D team |
// Date: Tuesday, February 25, 1992 |
// |
// Copyright © 1992-95 Apple Computer, Inc., All Rights Reserved |
// |
// Modification History: |
// 11/26/94 nick added InitializeAppStuff |
// |
#include <Drag.h> |
#include <Gestalt.h> |
#include <segload.h> |
#include <Gestalt.h> |
#include "Tumbler_globals.h" |
#include "Tumbler_resources.h" |
#include "Tumbler_utility.h" |
#include "QD3D.h" |
#include "Tumbler_initialize.h" |
WindowPtr pSplasher ; // used for the splash screen |
void InitializeToolbox(void) |
{ |
InitGraf(&qd.thePort); |
InitFonts(); |
InitWindows(); |
InitMenus(); |
TEInit(); |
InitDialogs(0L); |
InitCursor(); |
} |
//----------------------------------------------------------------------- |
// make sure enough master pointers are allocated or heap fragmentation |
// will result!! |
void InitializeAppStuff( short numMoreMasters ) |
{ |
short index ; |
long gestaltResponse; |
for( index = 1; index <= numMoreMasters; index++) |
MoreMasters(); |
MaxApplZone(); |
FlushEvents(everyEvent, 0); |
if ((Gestalt(gestaltDragMgrAttr, &gestaltResponse) != noErr) || |
(!(gestaltResponse & (1 << gestaltDragMgrPresent)))) { |
Alert(512, 0L); |
ExitToShell(); |
} |
} |
void InitializeGlobals(void) |
{ Handle theHandle; |
gQuit = gQuitting = false; |
gDocumentCount = 0; |
gFontItem = gSizeItem = 0; |
gInBackground = false; |
gCanUndoDrag = slCantUndo; |
gUsingHardware = false ; |
Q3Initialize(); |
} |
void DeallocateGlobals(void) |
{ |
Q3Exit(); |
} |
void SetupMenus(void) |
{ Handle theMenuBar; |
MenuHandle theMenu; |
Str255 theStr; |
if ((theMenuBar = GetNewMBar(MenuBarID)) == 0) { |
SysBeep(1); |
ExitToShell(); |
} |
SetMenuBar(theMenuBar); |
// DisposHandle(theMenuBar); |
AppendResMenu(GetMenuHandle(idAppleMenu), 'DRVR'); |
//AppendResMenu(GetMenuHandle(idDisplayMenu), 'FONT'); |
GetIndString(theStr, MenuStringsID, slCantUndo); |
SetMenuItemText(GetMenuHandle(idEditMenu), iUndo, theStr); |
theMenu = GetMenuHandle(idDisplayMenu); |
#ifndef PODIUM_APP |
InsertMenu(GetMenu(idStyleMenu), -1); |
InsertMenu(GetMenu(idRendererMenu), -1); |
InsertMenu(GetMenu(idAnimateMenu), -1); |
InsertMenu(GetMenu(idBackfacingMenu), -1); |
#endif |
DrawMenuBar(); |
} |
//------------------------------------------------------------------------------------------- |
void SplashSetUp( void ) |
{ |
PicHandle thePict = GetPicture( 128 ) ; |
GrafPtr savedPort ; |
GetPort( &savedPort ) ; |
if(thePict != nil) { |
GDHandle theMainDevice = GetMainDevice() ; // if this is nil then the world just ended |
if(theMainDevice != nil) { |
Rect thePictFrame = (**thePict).picFrame ; |
Rect deviceRect = (**theMainDevice).gdRect ; |
thePictFrame = (**thePict).picFrame ; |
PositionRectInRect(&deviceRect, &thePictFrame, FixRatio(1, 2), FixRatio(1, 3)) ; |
pSplasher = NewWindow(nil,&thePictFrame,"\p",false,dBoxProc,(WindowPtr)-1,false,0L); |
if( pSplasher != nil ) { |
SetWRefCon( pSplasher, (long)savedPort ) ; |
ShowWindow(pSplasher) ; |
SetPort((GrafPtr)pSplasher) ; |
DrawPicture(thePict, &pSplasher->portRect) ; |
} |
} |
} |
} |
void SplashTearDown( void ) |
{ |
GrafPtr savedPort = (GrafPtr)GetWRefCon(pSplasher) ; |
if(pSplasher!=nil) { |
CloseWindow(pSplasher); |
SetPort(savedPort) ; |
} |
} |
Copyright © 2003 Apple Computer, Inc. All Rights Reserved. Terms of Use | Privacy Policy | Updated: 2003-01-14