home *** CD-ROM | disk | FTP | other *** search
Text File | 1998-06-17 | 2.7 KB | 124 lines | [TEXT/CWIE] |
- // Program Author: Paul Baxter
- // pbaxter@assistivetech.com
- //
- //
- #include <Speech.h>
- #include <Ctype.h>
- #include <DeskBus.h>
- #include <Retrace.h>
-
- #include "filter.h"
- #include "adb.h"
- #include "pref.h"
- #include "globals.h"
- #include "menu.h"
- #include "speech.h"
- #include "event.h"
- #include "DeferredTask.h"
-
- // * ****************************************************************************** *
- // * EventLoop
- // * Main Event loop
- // * ****************************************************************************** *
- void EventLoop(void)
- {
- EventRecord theEvent;
-
- do {
- WaitNextEvent(everyEvent, &theEvent, 15, 0);
- HandleEvent (&theEvent);
- } while (!gQuitting);
- }
-
- // * ****************************************************************************** *
- // * HandleEvent
- // * Handle One Event or One Fowarded Event from filter
- // * ****************************************************************************** *
- void HandleEvent(EventRecord* theEvent)
- {
- WindowPtr whichWin, frontWin;
- char theKey, theChar;
- short thePart;
- Boolean fowardedEvent;
-
-
- fowardedEvent = (theEvent->what != nullEvent) ? false : GetFowardedEvent(theEvent);
-
- switch (theEvent->what) {
- case mouseDown:
- if (!fowardedEvent) {
- thePart = FindWindow(theEvent->where, &whichWin);
- frontWin = FrontWindow();
- switch(thePart) {
- case inMenuBar:
- DoMenuItem(MenuSelect(theEvent->where));
- break;
-
- case inSysWindow:
- SystemClick(theEvent, whichWin);
- break;
-
- default:
- break;
- }
- }
- else {
- AppendWordBuffer('.');
- AppendSentenceBuffer('.');
- }
- break;
-
- case keyDown:
- theChar = theEvent->message & charCodeMask;
- theKey = (theEvent->message & keyCodeMask) >> 8;
- if (fowardedEvent) {
- AppendWordBuffer(theChar);
- AppendSentenceBuffer(theChar);
-
- }
- else {
- if (theEvent->modifiers & cmdKey) {
- DoMenuItem(MenuKey(theChar));
- }
- }
- break;
-
- case kHighLevelEvent:
- AEProcessAppleEvent(theEvent);
- break;
-
- case osEvt:
- InitCursor();
-
- default:
- break;
- }
- if (fowardedEvent)
- SpeakBuffers();
- }
-
-
- // * ****************************************************************************** *
- // * GetFowardedEvent
- // * Get an event fowarded by our filter
- // * ****************************************************************************** *
- Boolean GetFowardedEvent(EventRecord *theEvent)
- {
- Boolean fowardEvent = false;
- short err=0;
- EvQEl *fwdEvent=0;
-
- // Extract any forwarded events... and treat them as normal
- if ((fwdEvent = (EvQEl *) gForwardedEvents.qHead) != nil)
- err = Dequeue((QElemPtr) fwdEvent, &gForwardedEvents);
-
- if (fwdEvent && !err) {
- BlockMove(&fwdEvent->evtQWhat, theEvent, sizeof(EventRecord));
- DisposePtr((Ptr) fwdEvent);
-
- fowardEvent = true;
- }
-
- return(fowardEvent);
- }
-