1 #include <MacTypes.h>
2 #include <Quickdraw.h>
3 #include <Windows.h>
4 #include <Controls.h>
5 #include <ToolUtils.h>
6 #include "macint.h"
7 
8 extern WindowPtr gCommandWin, gGraphicsWin;
9 extern Boolean gCommandWinResized;
10 extern Rect dragRect, sizeRect;
11 
12 //=============================================================================
13 // Hanlde Mouse Down Events
14 //=============================================================================
15 
DoMouseDown(EventRecord * theEvent)16 void DoMouseDown (EventRecord *theEvent) {
17     WindowPtr whichWindow;
18     short int thePart = FindWindow (theEvent->where, &whichWindow);
19 
20     switch (thePart) {
21         case inSysWindow:
22             SystemClick (theEvent, whichWindow);
23             break;
24         case inDrag:
25             DragWindow (whichWindow, theEvent->where, &dragRect);
26             break;
27         case inMenuBar: {
28             long choice;
29             AdjustMenus ();
30             choice = MenuSelect (theEvent->where);
31             if (choice) DoMenu (choice);
32             break;
33         }
34         case inGoAway:
35             if ((whichWindow == gGraphicsWin)
36                     && (TrackGoAway (whichWindow, theEvent->where)))
37                 HideGrafWin ();
38             break;
39         case inContent:
40             if ((FrontWindow () == gCommandWin) && (whichWindow == gCommandWin))
41                 DoContent (theEvent);
42             else SelectWindow (whichWindow);
43             break;
44         case inGrow:
45         case inZoomIn:
46         case inZoomOut: {
47             long newSize;
48             GrafPtr oldPort;
49             if (thePart == inGrow) newSize = GrowWindow (whichWindow, theEvent->where, &sizeRect);
50             if (((thePart == inGrow) && newSize)
51                 || ((thePart != inGrow) && TrackBox (whichWindow, theEvent->where, thePart))) {
52                 GetPort (&oldPort);
53                 SetPort (whichWindow);
54                 EraseRect (&whichWindow->portRect);
55                 if (thePart == inGrow) SizeWindow (whichWindow, LoWord (newSize), HiWord (newSize), -1);
56                 else ZoomWindow (whichWindow, thePart, 0);
57                 gCommandWinResized = true;
58                 InvalRect (&whichWindow->portRect);
59                 SetPort (oldPort);
60             }
61             break;
62         }
63     }
64 }
65