AmendHub

Download

pfuentes69

/

FractalViewer

/

FractalViewer.cp

 

(View History)

pfp   First commit Latest amendment: 1 on 2022-08-26

1 /*****
2 * FractalViewer.c
3 *
4 * Simple object-oriented application to draw 2D CGI,
5 * mostly fractals, using QuickDraw
6 *
7 *****/
8
9 /* MacHeaders Included */
10
11 #include <oops.h>
12 #include "FractalViewerMenus.h"
13 #include "TFractalViewerWindow.h"
14
15
16 /****
17 * InitMacintosh()
18 *
19 * Initialize all the managers & memory
20 *
21 ****/
22
23 static void InitMacintosh(void)
24
25 {
26 MaxApplZone();
27
28 InitGraf(&thePort);
29 InitFonts();
30 FlushEvents(everyEvent, 0);
31 InitWindows();
32 InitMenus();
33 TEInit();
34 InitDialogs(0L);
35 InitCursor();
36 }
37 /* end InitMacintosh */
38
39
40 /****
41 * HandleMouseDown (theEvent)
42 *
43 * Take care of mouseDown events.
44 *
45 ****/
46
47 static void HandleMouseDown(EventRecord *theEvent)
48 {
49 WindowPeek wp;
50 short windowPart = FindWindow (theEvent->where, (WindowPtr*) &wp);
51
52 switch (windowPart)
53 {
54 case inSysWindow:
55 SystemClick (theEvent, (WindowPtr) wp);
56 break;
57
58 case inMenuBar:
59 HandleMenu(MenuSelect(theEvent->where));
60 break;
61
62 case inDrag:
63 if (wp->windowKind == TWINDOWKIND)
64 OBJ(wp)->Drag(theEvent->where);
65 break;
66
67 case inContent:
68 if (wp->windowKind == TWINDOWKIND) {
69 if (wp != (WindowPeek) FrontWindow())
70 OBJ(wp)->Select();
71 else
72 OBJ(wp)->Hit(theEvent->where);
73 }
74 break;
75
76 case inGoAway:
77 if (wp->windowKind == TWINDOWKIND)
78 OBJ(wp)->TrackClose(theEvent->where);
79 break;
80
81 case inGrow:
82 if (wp->windowKind == TWINDOWKIND)
83 OBJ(wp)->Grow(theEvent->where);
84 break;
85
86 case inZoomIn:
87 case inZoomOut:
88 if (wp->windowKind == TWINDOWKIND)
89 OBJ(wp)->TrackZoom(theEvent->where, windowPart);
90 }
91 }
92 /* end HandleMouseDown */
93
94
95 /****
96 * HandleEvent()
97 *
98 * The main event dispatcher. This routine should be called
99 * repeatedly (it handles only one event).
100 *
101 *****/
102
103 static void HandleEvent(void)
104 {
105 short ok;
106 EventRecord theEvent;
107
108 HiliteMenu(0);
109 SystemTask (); /* Handle desk accessories */
110 AdjustMenus();
111
112 ok = GetNextEvent (everyEvent, &theEvent);
113 if (ok)
114 {
115 switch (theEvent.what)
116 {
117 case mouseDown:
118 HandleMouseDown(&theEvent);
119 break;
120
121 case keyDown:
122 case autoKey:
123 if ((theEvent.modifiers & cmdKey) != 0)
124 HandleMenu(MenuKey((char) (theEvent.message & charCodeMask)));
125 break;
126
127 case updateEvt:
128 if (((WindowPeek) theEvent.message)->windowKind == TWINDOWKIND)
129 OBJ(theEvent.message)->Update();
130 break;
131
132 case activateEvt:
133 if (((WindowPeek) theEvent.message)->windowKind == TWINDOWKIND)
134 OBJ(theEvent.message)->Activate(theEvent.modifiers & 0x01);
135 break;
136 }
137 }
138 }
139 /* end HandleEvent */
140
141
142 /*****
143 * main()
144 *
145 * This is where everything happens
146 *
147 *****/
148
149
150 void main(void)
151 {
152 InitMacintosh();
153 SetUpMenus();
154
155 for (;;)
156 HandleEvent();
157 }
158 /* end main */