Mandy/MandyWindow.c

1 line
2.6 KiB
C
Raw Permalink Normal View History

2021-12-14 18:40:24 +00:00
/***** * MandyWindow.c * * A simple fractal generator * * *****/ #include "mwMenus.h" #include "mwWindow.h" extern WindowPtr mwWindow; extern Rect dragRect; void InitMacintosh(void); void HandleMouseDown (EventRecord *theEvent); void HandleEvent(void); /* InitMacintosh() Initialize all the managers & memory */ void InitMacintosh(void) { MaxApplZone(); InitGraf(&thePort); InitFonts(); FlushEvents(everyEvent, 0); InitWindows(); InitMenus(); TEInit(); InitDialogs(0L); InitCursor(); } void HandleMouseDown (EventRecord *theEvent) { WindowPtr theWindow; int windowCode = FindWindow (theEvent->where, &theWindow); switch (windowCode) { case inSysWindow: SystemClick (theEvent, theWindow); break; case inMenuBar: AdjustMenus(); HandleMenu(MenuSelect(theEvent->where)); break; case inDrag: if (theWindow == mwWindow) DragWindow(mwWindow, theEvent->where, &dragRect); break; case inContent: if (theWindow == mwWindow) { if (theWindow != FrontWindow()) SelectWindow(mwWindow); else InvalRect(&mwWindow->portRect); } break; case inGoAway: if (theWindow == mwWindow && TrackGoAway(mwWindow, theEvent->where)) HideWindow(mwWindow); break; } } void HandleEvent(void) { int ok; EventRecord theEvent; HiliteMenu(0); SystemTask (); /* Handle desk accessories */ ok = GetNextEvent (everyEvent, &theEvent); if (ok) { switch (theEvent.what) { case mouseDown: HandleMouseDown(&theEvent); break; case keyDown: case autoKey: if ((theEvent.modifiers & cmdKey) != 0) { AdjustMenus(); HandleMenu(MenuKey((char) (theEvent.message & charCodeMask))); } break; case updateEvt: BeginUpdate(mwWindow); DrawContent(((WindowPeek) mwWindow)->hilited); EndUpdate(mwWindow); break; case activateEvt: InvalRect(&mwWindow->portRect); break; } } } void main(void) { InitMacintosh(); SetUpMenus(); SetUpWindow(); for (;;) { HandleEvent(); } }