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"
 
#include "QTInternals.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( (IsWindowObjectOurs(aWindowObject)) &&  ((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)
{
    MovieController mc = NULL;
    
    mc = GetMCFromFrontWindow();
    if (mc == NULL) return;                         // we didn't have any movie windows frontmost
    
    //  HANDLE ANY ADDITIONAL MENU ENTRIES HERE
    switch(theMenuID)
    {
        case mTesting:
            switch(theMenuItem)
            {
                case iMovieInfo:
                    ShowGlobalMovieInfo(MCGetMovie(mc));
                    break;
 
                case iTrackInfo:
                    ShowMovieTrackInfo(MCGetMovie(mc));
                    break;
                    
                case iVideoInfo:
                    ShowMovieVideoInfo(MCGetMovie(mc));
                    break;
                
                case iSoundInfo:
                    ShowMovieSoundInfo(MCGetMovie(mc));
                    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
    {
        EnableItem(GetMHandle(mTesting), iMovieInfo);
        EnableItem(GetMHandle(mTesting), iTrackInfo);
        EnableItem(GetMHandle(mTesting), iVideoInfo);
        EnableItem(GetMHandle(mTesting), iSoundInfo);
    }
    else
    {
        DisableItem(GetMHandle(mTesting), iMovieInfo);
        DisableItem(GetMHandle(mTesting), iTrackInfo);
        DisableItem(GetMHandle(mTesting), iVideoInfo);
        DisableItem(GetMHandle(mTesting), iSoundInfo);
    }
}
 
 
// ______________________________________________________________________
void AddControllerFunctionality(MovieController mc)
{
    long controllerFlags;
    
// 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);
}