Mac Framework/MacApplication.c

/*
    File:       MacApplication.c
 
    Contains:   Functions that could be overridden in a specific application.
 
    Written by: DTS
 
    Copyright:  © 1994-1995 by Apple Computer, Inc., all rights reserved.
 
    Change History (most recent first):
 
       <1>      12/21/94    khs     first file
       
*/
 
 
// INCLUDES
#include "MacApplication.h"
#include "MacFramework.h"
#include "AppConfiguration.h"
#include "DTSQTUtilities.h"
 
// Header file for the specific test functions.
#include "TestFunctions.h"
 
// GLOBALS
long gMaxMilliSecToUse = kMaxMilliSecToUse;     
 
 
// FUNCTIONS
// ______________________________________________________________________
void DoIdle(WindowRef theWindow)
{
    GrafPtr                 aSavedPort;
    WindowObject        aWindowObject;
    MovieController  mc = NULL;
    
    GetPort(&aSavedPort);
    SetPort(theWindow);
    
    if( (aWindowObject = (WindowObject)GetWRefCon(theWindow) ) != NULL)
    {
        if( (mc = (**aWindowObject).controller) != NULL)
            MoviesTask(MCGetMovie(mc), gMaxMilliSecToUse);  
    }
 
// @@@INSERT ANY IDLE BASED FUNCTIONALITY HERE
 
    SetPort(aSavedPort);
}
 
 
// ______________________________________________________________________
void DoUpdateWindow(WindowRef theWindow, Rect *theRefrehArea)
{
    GrafPtr aSavedPort;
    
    GetPort(&aSavedPort);
    SetPort(theWindow);
    
    BeginUpdate(theWindow);
 
// @@@INSERT WINDOW SPECIFIC DRAWING FUNCTIONALITY HERE
 
    EndUpdate(theWindow);
    SetPort(aSavedPort);
}
 
 
// ______________________________________________________________________
void HandleContentClick(WindowRef theWindow, EventRecord *theEvent)
{
    GrafPtr aSavedPort;
    
    GetPort(&aSavedPort);
    SetPort(theWindow);
 
// @@@INSERT APPLICATION SPECIFIC CONTENT CLICKING FUNCTIONALITY HERE
 
    SetPort(aSavedPort);
}
 
 
// ______________________________________________________________________
WindowRef CreateMovieWindow(Rect *theRect, Str255 theTitle)
{
    WindowRef aWindow;
 
// MODIFY IF NEEDED THE WAY TO CREATE NEW WINDOWS   
    aWindow = NewCWindow(NULL, theRect, theTitle, false, noGrowDocProc, (WindowPtr) - 1L, true, 0);
    return aWindow;
}
 
// ______________________________________________________________________
void HandleApplicationMenu(short theMenuID, short theMenuItem)
{
    //  HANDLE ANY ADDITIONAL MENU ENTRIES HERE
    switch(theMenuID)
    {
        case mTesting:
            switch(theMenuItem)
            {
                case iTest1:
                {
                // @@@INSERT YOUR TEST FUNCTION 1 HERE
                    ResizeTheMovieWindow(kNormalMovieSize);
                    break;
                }
                
                case iTest2:
                {
                // @@@INSERT YOUR TEST FUNCTION 2 HERE
                    ResizeTheMovieWindow(kHalfMovieSize);
                    break;
                }
                
                case iTest3:
                {
                // @@@INSERT YOUR TEST FUNCTION 3 HERE
                    ResizeTheMovieWindow(kDoubleMovieSize);
                    break;
                }
            }
            break;
    }
}
 
 
// ______________________________________________________________________
void    AdjustApplicationMenus(void)
{
    WindowRef           aWindow = NULL;
    MovieController     mc = NULL;
    
    mc = GetMCFromFrontWindow();
    if(mc != NULL)                              // we do have windows with movie controllers = movie windows
    // @@@ADJUST YOUR MENUS HERE
    {
        EnableItem(GetMHandle(mTesting), iTest1);
        EnableItem(GetMHandle(mTesting), iTest2);
        EnableItem(GetMHandle(mTesting), iTest3);
    }
    else
    {
        DisableItem(GetMHandle(mTesting), iTest1);
        DisableItem(GetMHandle(mTesting), iTest2);
        DisableItem(GetMHandle(mTesting), iTest3);
    }
}
 
 
// ______________________________________________________________________
void AddControllerFunctionality(MovieController mc)
{
    long controllerFlags;
 
// @@@MOVIE CONTROLLER FUNCTIONALITY
// Specify here the functionality you want to have added to the movie controller.
 
// CLUT Table use   
    MCDoAction(mc, mcActionGetFlags, &controllerFlags);
    MCDoAction(mc, mcActionSetFlags, (void *) (controllerFlags | mcFlagsUseWindowPalette));
 
// Enable keyboard event handling   
    MCDoAction(mc, mcActionSetKeysEnabled, (void *) true);
    
// Enable Drag Support (assume we have System 7.5 for the time being)
    MCDoAction(mc, mcActionSetDragEnabled, (void *) true);
}