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.
doevent.c
/* |
File: doevent.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 __DESK__ |
#include <Desk.h> |
#endif |
#ifndef __DISKINIT__ |
#include <DiskInit.h> |
#endif |
#ifndef __EVENTS__ |
#include <Events.h> |
#endif |
#ifndef __MENUS__ |
#include <Menus.h> |
#endif |
#ifndef __MOVIES__ |
#include <Movies.h> |
#endif |
#ifndef __QDOFFSCREEN__ |
#include <QDOffscreen.h> |
#endif |
#ifndef __TOOLUTILS__ |
#include <ToolUtils.h> |
#endif |
#ifndef __WINDOWS__ |
#include <Windows.h> |
#endif |
// Program headers |
#ifndef __CHROMAPPHEADER__ |
#include "ChromaKeyMovie.h" |
#endif |
// Global Variables |
extern short gKeyMode; |
extern Boolean gMovieOpen; |
// DoEvent function processess the events posted by the application. |
// This includes the handling of the movie controller, mouse, key, |
// disk and operating system events. |
#pragma segment Main |
void DoEvent (EventRecord *eventPtr) |
{ |
WindowPtr theWindow, |
theTempWindow; |
char theChar; |
theWindow = FrontWindow(); |
theTempWindow = theWindow; |
if (gMovieOpen) |
{ |
while (theTempWindow != nil) |
{ |
MCIsPlayerEvent((**((MovieDocHndl) |
GetWRefCon(theTempWindow))).theController,eventPtr); |
theTempWindow = &(*(((WindowPeek)theTempWindow)->nextWindow)).port; |
} |
} |
switch (eventPtr->what) |
{ |
case nullEvent: |
if (gMovieOpen) |
{ |
switch (gKeyMode) |
{ |
case transparentMode: |
TransparentKeyMode(theWindow); // use transparent transfer mode |
break; |
case graphix: |
break; |
case modifierTrax: |
break; |
} |
} |
break; |
case mouseDown: |
HandleMouseDown(eventPtr); |
break; |
case mouseUp: |
break; |
case keyDown: |
case autoKey: |
theChar=eventPtr->message & charCodeMask; |
if ((eventPtr->modifiers &cmdKey) !=0) |
DoMenuCommand(MenuKey (theChar)); |
break; |
case keyUp: |
break; |
case updateEvt: |
DoWindUpdate((WindowPtr)(eventPtr->message)); |
break; |
case diskEvt: |
DoDiskEvt(eventPtr); // disk inserted event |
break; |
case osEvt: |
if (eventPtr->message>>24==resumeFlag) |
//Show_Cursor(ARROW_CURSOR); // reset cursor |
SetCursor(&qd.arrow); |
break; |
} |
} |
// HandleMouseDown controls the further processing of mouse button down events. |
// This includes testing the location of the mouse pointer at the time of the event |
// and performing the appropriate action. e.g. if the mouse button was pressed |
// whilst the pointer was in the menubar, the value returned by MenuSelect() |
// (used to determine which menubar and item selected) is passed into DoMenuCommand() |
// which in turn handles the processing of the selected menu items. |
#pragma segment Main |
void HandleMouseDown(EventRecord *eventPtr) |
{ |
WindowPtr window; |
short thePart; |
long menuChoice; |
thePart=FindWindow (eventPtr->where,&window); |
switch (thePart) |
{ |
case inMenuBar: |
menuChoice = MenuSelect (eventPtr->where); |
DoMenuCommand(menuChoice); |
break; |
case inSysWindow: |
SystemClick(eventPtr,window); |
break; |
case inDrag: |
DragSelWind(window,eventPtr->where); |
case inGoAway: |
DoGoAwayWind(window,eventPtr->where); |
break; |
case inContent: |
{ |
if(window!=FrontWindow()) |
{ |
SelectWindow(window); |
break; |
} |
} |
break; |
case osEvt: |
break; |
} |
} |
// DoDiskEvt handles the event post by the OS when a disk is insert |
// and displays an error is the media cannot be mounted. |
#pragma segment Main |
void DoDiskEvt(EventRecord *eventPtr) |
{ |
short ErrResult; |
Point ErrPoint; |
if((HiWord(eventPtr->message)!=noErr)) |
{ |
SetPt(&ErrPoint,100,100); |
ErrResult=DIBadMount(ErrPoint,eventPtr->message); |
} |
} |
Copyright © 2003 Apple Computer, Inc. All Rights Reserved. Terms of Use | Privacy Policy | Updated: 2003-01-14