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.
start.c
/* |
File: start.c |
Contains: |
Written by: Jason Hodges Harris |
Copyright: Copyright © 1995-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 |
*/ |
// Mac Toolbox headers |
#ifndef __DIALOGS__ |
#include <Dialogs.h> |
#endif |
#ifndef __FONTS__ |
#include <Fonts.h> |
#endif |
#ifndef __GESTALT__ |
#include <Gestalt.h> |
#endif |
#ifndef __MEMORY__ |
#include <Memory.h> |
#endif |
#ifndef __MENUS__ |
#include <Menus.h> |
#endif |
#ifndef __QDOFFSCREEN__ |
#include <QDOffscreen.h> |
#endif |
#ifndef __SEGLOAD__ |
#include <SegLoad.h> |
#endif |
#ifndef __TEXTEDIT__ |
#include <TextEdit.h> |
#endif |
#ifndef __TOOLUTILS__ |
#include <ToolUtils.h> |
#endif |
#ifndef __WINDOWS__ |
#include <Windows.h> |
#endif |
// Program headers |
#ifndef __CHROMAPPHEADER__ |
#include "ChromaKeyMovie.h" |
#endif |
// Global Variables |
// Predefined RGBColors |
RGBColor kRGBWhite = {0xFFFF,0xFFFF,0xFFFF}, |
kRGBBlack = {0x0000,0x0000,0x0000}, |
gKeyColor; |
// Chroma keying mode |
short gKeyMode; |
// location of the movie relative to the background image |
Boolean gMovieBackGrnd; |
// Application loop exit test |
Boolean gDone; |
// Movie window open (only one window supported) |
Boolean gMovieOpen; |
// initialise the global variables |
void InitGlobals(void) |
{ |
gKeyColor = kRGBBlack; // preset chroma key color to black |
gKeyMode = transparentMode; // default Chroma key mode use transparent transfer mode |
gMovieBackGrnd = false; // movie in foreground |
gDone = false; // set global loop var to false while program active |
gMovieOpen = false; // No window open |
} |
// Gestalt tests |
#pragma segment Main |
void TestforQuickTimeVersion(void) |
{ |
long QTimeVersion; |
OSErr error; |
if(Gestalt('qtim',&QTimeVersion) == noErr) |
{ |
/* QuickTime version 2.1 or later required for all options to be available. |
If not display a warning dialog and disable QT 2.1 reliant feature */ |
if (QTimeVersion < 0x02100000) |
{ |
DisplayAlert (rGenWarning,rQTmessages,2); |
DisableItem(GetMenuHandle(mMode),iModifier); |
} |
// check for the QuickTime shared library loaded as Gestalt not always correct |
#if defined(powerc) || defined(__powerc) |
if (!EnterMovies) |
{ |
DisplayAlert(rGenAlert,rQTmessages,3); |
gDone = true; |
return; |
} |
#endif |
error = EnterMovies(); // initialise QuickTime |
if (error != noErr) |
{ |
DisplayAlert (rGenAlert,rQTmessages,1); |
gDone = true; // exit application |
} |
return; |
} |
DisplayAlert (rGenAlert,rQTmessages,1); |
gDone = true; |
return; |
} |
// Main function |
#pragma segment Main |
int main(void) |
{ |
long *AppSize; // application size |
short i; |
AppSize = (long*)(GetApplLimit()); |
SetApplLimit (AppSize-32768); |
// This decreases the application heap by 32k, which in turn |
// increases the stack by 32k. |
MaxApplZone(); // Expand the heap so code segments load at the top. |
for (i=0;i<5;i++) |
MoreMasters(); // allocate more master pointers |
// Initialise the toolbox |
InitGraf (&qd.thePort); |
InitFonts(); |
InitWindows(); |
InitMenus(); |
TEInit(); |
InitDialogs(0L); |
InitCursor(); |
InitGlobals(); // initialise globals |
MenuBarInit(); // init menubar |
TestforQuickTimeVersion(); // test for and initialise Quicktime |
DoAdjustMenus(); // menu setup |
EventLoop(); // Call the main event loop. |
ExitToShell(); // Quit the application. |
return 0; |
} |
Copyright © 2003 Apple Computer, Inc. All Rights Reserved. Terms of Use | Privacy Policy | Updated: 2003-01-14