MacFramework.h

/*
    File:       MacFramework.h
 
    Contains:   Basic Macintosh Functions for window, menu handling and similar things for the 
                SG/vdig environment.
 
    Written by:     
 
    Copyright:  Copyright © 1994-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):
                7/28/1999   Karl Groethe    Updated for Metrowerks Codewarror Pro 2.1
                
 
*/
 
#pragma once
 
 
// INCLUDES
#include <Movies.h>
#include <QuickTimeComponents.h>
#include <TextUtils.h>
#include <Memory.h>
 
#include <stdio.h>
 
#ifdef __MWERKS__
#include <sioux.h>
#endif // __MWERKS__
 
 
// ENUMS, DEFINES AND GLOBALS
enum         {  kMovieControllerObject  = 'MCOb'
             };
 
 
 
// ENUMS 
// MENUS
enum eMenubar { mMenubar = 128};
 
enum eMainMenus {
    mApple = 128, mFile, mEdit
};
 
enum  eAppleMenu {
    iAbout = 1
};
 
enum   eFileMenu{
    iNew = 1, iClose, iQuit = 4
};
 
enum eEditMenu {
    iUndo = 1, iCut = 3, iCopy, iPaste, iClear, iSelectAll = 8
};
 
// DIALOGS
enum eDialogs {
    kAboutBox = 128, kAlertError = 129
};
 
 
// TYPEDEFS AND STRUCTURES
// WindowObjectRecord/Ptr is a data structure attached to the movie window. Use
// this structure if you want to associate any data with any window presented.
 
typedef struct {
    OSType                  ObjectType;                     // specific tag indicating that the window object belongs to our application
    MovieController     controller;
    Rect                        originalSize;                   // including movie controller
    FSSpec                  FileFSSpec;
    short                   FileResID;
    short                   FileRefNum;
    
// add more elements if needed
} WindowObjectRecord, *WindowObjectPtr, **WindowObject;
 
// SG specific data structures
 
typedef struct {
    SeqGrabComponent    sg;
    SGChannel                   videoChannel;
    SGChannel                   soundChannel;
    WindowPtr               sgWindow;
} SGResourceRecord, *SGResourcePtr, **SGResourceHndl;
 
 
// FUNCTION PROTOTYPES
 
// PURE MAC TOOLBOX FUNCTIONS
void                            InitStack(long extraStackSpace);
void                            InitMacEnvironment(long nMoreMasters);
 
Boolean                     InitMenubar(void);
void                            HandleMenuCommand(long theMenuResult);
void                            AdjustMenus(void);
void                            MainEventLoop(void);
 
Boolean                     IsAppWindow(WindowRef theWindow);
WindowObject            CreateWindowObject(WindowRef theWindow);
 
void                            HandleKeyPress(EventRecord *theEvent);
void                            ShowAboutDialogBox(void);
void                            ShowWarning(Str255 theMessage, OSErr theErr);
 
void                            DoDestroyMovieWindow(WindowRef theWindow);
void                            DoActivateWindow(WindowRef theWindow, Boolean becomingActive);
 
 
// APPLICATION SPECIFIC FUNCTIONS
// These are placed in the MacApplication.c file, you could override these for changing
// the behavior of the function in a specific application.
 
void                            DoIdle(WindowRef theWindow);
void                            DoUpdateWindow(WindowRef theWindow, Rect *theRefrehArea);
void                            DoCloseWindow(WindowRef theWindow);
void                            DoDragWindow(WindowRef theWindow, EventRecord *theEvent);
void                            HandleContentClick(WindowRef theWindow, EventRecord *theEvent);
WindowRef               CreateMovieWindow(Rect *theRect, Str255 theTitle);
void                            HandleApplicationMenu(short theMenuID, short theMenuItem);
void                            AdjustApplicationMenus(void);
 
// These are very specific sequence grabber and vdig functions used from the actual
// application level.
void                            CreateSGEnviroment(void);
SeqGrabComponent    GetDefaultSGInstance(void);
SGChannel                   GetDefaultVideoChannel(void);
SGChannel                   GetDefaultAudioChannel(void);
 
pascal ComponentResult SpecialGrabFrameComplete(SGChannel c, short bufferNum,
                                                                                Boolean *done, long refCon);
OSErr SetupVideoBottleNecks(SGChannel videoChannel, WindowPtr theWindow, CGrafPtr tempPort);