-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMandyWindow.c
More file actions
114 lines (94 loc) · 2.6 KB
/
MandyWindow.c
File metadata and controls
114 lines (94 loc) · 2.6 KB
1
/***** * 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(); }}