GliderPRO/Sources/Events.c

1 line
13 KiB
C
Raw Normal View History

//============================================================================ //---------------------------------------------------------------------------- // Events.c //---------------------------------------------------------------------------- //============================================================================ #include <AppleEvents.h> #include <ToolUtils.h> #include "Externs.h" #include "Environ.h" #include "House.h" #include "ObjectEdit.h" short BitchAboutColorDepth (void); void HandleMouseEvent (EventRecord *); void HandleKeyEvent (EventRecord *); void HandleUpdateEvent (EventRecord *); void HandleOSEvent (EventRecord *); void HandleHighLevelEvent (EventRecord *); void HandleIdleTask (void); void IncrementMode (void); long lastUp, incrementModeTime; UInt32 doubleTime; Point lastWhere; short idleMode; Boolean doAutoDemo, switchedOut; extern WindowPtr mapWindow, toolsWindow, linkWindow; extern WindowPtr menuWindow; extern short isEditH, isEditV, isMapH, isMapV, isToolsH, isToolsV; extern short isLinkH, isLinkV, isCoordH, isCoordV; extern Boolean quitting, isMusicOn, failedMusic; extern Boolean autoRoomEdit, newRoomNow, isPlayMusicIdle; //============================================================== Functions //-------------------------------------------------------------- BitchAboutColorDepth // Display a dialog that alerts the user that they have switched the bit<69> // depth of the monitor under our noses. They must return it to previous. short BitchAboutColorDepth (void) { #define kColorSwitchedAlert 1042 short sheSaid; // CenterAlert(kColorSwitchedAlert); sheSaid = Alert(kColorSwitchedAlert, nil); return (sheSaid); } //-------------------------------------------------------------- HandleMouseEvent // Handle a mouse click event. void HandleMouseEvent (EventRecord *theEvent) { WindowPtr whichWindow; long menuChoice, newSize; short thePart, hDelta, vDelta; Boolean isDoubleClick; thePart = FindWindow(theEvent->where, &whichWindow); switch (thePart) { case inSysWindow: // SystemClick(theEvent, whichWindow); break; case inMenuBar: menuChoice = MenuSelect(theEvent->where); DoMenuChoice(menuChoice); break; case inDrag: DragWindow(whichWindow, theEvent->where, &thisMac.screen); if (whichWindow == mainWindow) { SendBehind(mainWindow, (WindowPtr)0L); GetWindowLeftTop(whichWindow, &isEditH, &isEditV); } else if (whichWindow == mapWindow) GetWindowLeftTop(whichWindow, &isMapH, &isMapV); else if (whichWindow == toolsWindow) GetWindowLeftTop(whichWindow, &isToolsH, &isToolsV); else if (whichWindow == linkWindow) GetWindowLeftTop(whichWindow, &isLinkH, &isLinkV); else if (whichWindow == coordWindow) GetWindowLeftTop(whichWindow, &isCoordH, &isCoordV); HiliteAllWindows(); break; case inGoAway: if (TrackGoAway(whichWindow,theEvent->where)) { if (whichWindow == mapWindow) ToggleMapWindow(); else if (whichWindow == toolsWindow) ToggleToolsWindow(); else if (whichWindow == linkWindow) CloseLinkWindow(); else if (whichWindow == coordWindow) ToggleCoordinateWindow(); } break; case inGrow: if (whichWindow == mapWindow) { newSize = GrowWindow(mapWindow, theEvent->where, &thisMac.gray); ResizeMapWindow(LoWord(newSize), HiWord(newSize)); } break; case inZoomIn: case inZoomOut: if (TrackBox(whichWindow, theEvent->where, thePart)) ZoomWindow(whichWindow, thePart, true); break; case inContent: if (whichWindow == mainWindow) { hDelta = theEvent->where.h - lastWhere.h; if (hDelta < 0) hDelta = -hDelta; vDelta = theEvent->where.v - lastWhere.v; if (vDelta < 0) vDelta = -vDelta; if (((theEvent->when - lastUp) < doubleTime) && (hDelta < 5) && (vDelta < 5)) isDoubleClick = true; else { isDoubleClick = false; lastUp = theEvent->when; lastWhere = theEvent->where; } HandleMainClick(theEvent->where, isDoubleClick); } else if (whichWindow == mapWindow) HandleMapClick(theEvent);