Sources/Toolbox.cp

/*
    File:       Toolbox.cp
 
    Contains:   TToolbox is a Toolbox utility class, used for initialization and Toolbox functions.
                TToolbox.cp contains the class body information for the TToolbox member functions.
  
    Written by: Kent Sandvik    
 
    Copyright:  Copyright © 1992-1999 by Apple Computer, Inc., All Rights Reserved.
 
                You may incorporate this Apple sample source code into your program(s) without
                restriction. This Apple sample source code has been provided "AS IS" and the
                responsibility for its operation is yours. You are not permitted to redistribute
                this Apple sample source code as "Apple sample source code" after having made
                changes. If you're going to re-distribute the source, we require that you make
                it clear in the source that the code was descended from Apple sample source
                code, but that you've made changes.
 
    Change History (most recent first):
                8/18/1999   Karl Groethe    Updated for Metrowerks Codewarror Pro 2.1
                
 
*/
// Include files
#ifndef _TOOLBOX_
#include "Toolbox.h"
#endif
 
 
// _________________________________________________________________________________________________________ //
// TToolbox class member function implementations
//  CONSTRUCTORS & DESTRUCTORS
#pragma segment Toolbox                  
TToolbox::TToolbox()
// Default constructor.
{
}
 
 
#pragma segment Toolbox
TToolbox::~TToolbox()
// Virtual destructor, we are not doing anything inside this one just now, note 
// that virtual destructors should not be inlined
{
}
 
 
//  INITIATION ROUTINES
#pragma segment Toolbox
void TToolbox::InitializeToolbox()
// Initialize the Macintosh Toolbox environment, standard initialization routines.
{
    ::InitGraf(&qd.thePort);
    ::InitFonts();
    ::InitWindows();
    ::InitMenus();
    ::TEInit();
    ::InitDialogs(NULL);
    ::InitCursor();
}
 
 
// MAIN INTERFACE
#pragma segment Toolbox
void TToolbox::PullApplicationToFront(short nCount)
// Make sure that any possible splash screens are placed front-most.
{
    EventRecord anEvent;
    short aCount;
 
    for (aCount = 1; aCount <= nCount; aCount++)        // pluck out a couple of events until things are OK
        ::EventAvail(everyEvent, &anEvent);
}
 
 
#pragma segment Toolbox
Boolean TToolbox::CreateMasterPointers(short nMasterPtr)
// Create n amount of Master Pointers.
{
    OSErr anErr;
 
    while (nMasterPtr--)
        ::MoreMasters();
 
    anErr = MemError();
    VASSERT(anErr == noErr, ("Problems with MoreMasters = %d", anErr));
    
    if(anErr == noErr)
        return true;
    else
        return false;           // we had problems, and signal this
}
 
 
#pragma segment Toolbox
void TToolbox::Initialize()
// Default initialization of Toolbox routines.
{
    this->InitializeToolbox();
    this->CreateMasterPointers();
    this->PullApplicationToFront();
}
 
 
// _________________________________________________________________________________________________________ //
 
/*  Change History (most recent last):
  No        Init.   Date        Comment
  1         khs     6/6/92      New file
  2         khs     1/3/93      Cleanup
*/