2 /* Copyright 1995 William R. Pearson */
4 /* used only in Mac versions to provide mac multitasking */
13 #define NIL_MOUSE_REGION 0L
15 #define WNE_TRAP_NUM 0x60
16 #define UNIMPL_TRAP_NUM 0x9F
17 #define SUSPEND_RESUME_BIT 0x0001
21 Boolean gDone, gWNEImplemented=0;
22 EventRecord gTheEvent;
23 Rect gDragRect, gSizeRect;
28 gWNEImplemented=(NGetTrapAddress(WNE_TRAP_NUM,ToolTrap)!=
29 NGetTrapAddress(UNIMPL_TRAP_NUM,ToolTrap));
33 #define hiword(x) (((short *) &(x))[0])
34 #define loword(x) (((short *) &(x))[1])
35 static MenuHandle aMenu;
43 extern WindowPtr gDrawWindow;
44 extern PicHandle aPic;
47 static long checkTime=0;
54 Boolean gotEvent, SIOUXDidEvent;
58 if (TickCount() < checkTime) return;
59 checkTime = TickCount()+60L;
62 gotEvent=WaitNextEvent(everyEvent-diskMask,&event,SLEEP,NIL_MOUSE_REGION);
65 gotEvent=GetNextEvent(everyEvent-diskMask,&event);
68 if (gotEvent) SIOUXDidEvent=SIOUXHandleOneEvent(&event);
69 if (SIOUXDidEvent) return;
71 if (event.what == nullEvent) {
72 if (FrontWindow() == 0) InitCursor();
76 if (SystemEvent(&event)) return;
78 if (event.what == mouseDown) {
79 switch (FindWindow(event.where, (WindowPtr *)&wp)) {
82 choice = MenuSelect(event.where);
85 DragWindow((WindowPtr)wp, event.where, &gDragRect);
88 SystemClick(&event, (WindowPtr)wp);
96 switch (hiword(choice)) {
98 GetMenuItemText(aMenu, loword(choice), buf);
105 SystemEdit(loword(choice) - 1);
124 WaitNextEvent(everyEvent-diskMask,&event,SLEEP,NIL_MOUSE_REGION);
127 GetNextEvent(everyEvent-diskMask,&event);
132 if (event.what == nullEvent) {
136 if (SystemEvent(&event)) return 0;
138 if (event.what == updateEvt) {
139 if ((WindowPtr)event.message == gDrawWindow) {
140 BeginUpdate((WindowPtr)event.message);
141 DrawPicture(aPic,&gDrawWindow->portRect);
142 EndUpdate((WindowPtr)event.message);
145 BeginUpdate((WindowPtr)event.message);
146 EndUpdate((WindowPtr)event.message);
151 if (event.what == keyDown) return 1;
152 if (event.what == mouseDown) {
153 switch (FindWindow(event.where, (WindowPtr *)&wp)) {
156 choice = MenuSelect(event.where);
159 DragWindow((WindowPtr)wp, event.where, &gDragRect);
162 SystemClick(&event, (WindowPtr)wp);
167 SelectWindow((WindowPtr)wp);
168 SetPort(gDrawWindow);
169 DrawPicture(aPic,&gDrawWindow->portRect);
177 switch (hiword(choice)) {
179 GetItem(aMenu, loword(choice), buf);
186 SystemEdit(loword(choice) - 1);