AmendHub

Download

pfuentes69

/

FractalViewer

/

TFractalViewerWindow.cp

 

(View History)

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

1 /*****
2 * TFractalViewerWindow.c
3 *
4 * The window methods for the application.
5 *
6 * TFractalViewerWindow inherits its Draw method from TWindow.
7 * TMandelbrot, TJulia, and others override DrawShape to draw their own kind of CGI.
8 *
9 *****/
10
11 #include <Packages.h> // for NumToString prototype
12 #include "TFractalViewerWindow.h"
13 #include <stdlib.h>
14 #include "Utils.h"
15
16
17 /****
18 * TFractalViewerWindow constructor
19 *
20 * Create a bullseye window. This constructor relies
21 * on the TWindow constructor to place the window in
22 * in attractive place. Then it appends a number to the
23 * window title.
24 *
25 ****/
26
27 TFractalViewerWindow::TFractalViewerWindow(void)
28 {
29 Str15 numStr;
30 Str255 title;
31 long windowNumber;
32
33
34 // Set the title of the window to be
35 // the title in the resource
36 // plus the window counter.
37 // The window counter is a class variable
38 // declared in the TWindow class.
39
40
41 GetWindowTitle(title);
42 windowNumber = GetWindowNumber();
43 NumToString(GetWindowNumber(), numStr);
44 concat(title, numStr);
45 SetWindowTitle(title);
46
47 }
48
49
50 /****
51 * Hit
52 *
53 * Handle a mouse down in the window.
54 * Bullseye window just force a refresh.
55 *
56 ****/
57
58 void TFractalViewerWindow::Hit(Point where)
59 {
60 RefreshWindow(false); // preserve the scroll bars
61 }
62
63
64 /****
65 * GetStyle
66 * SetStyle
67 *
68 * Get and set the color style
69 *
70 ****/
71
72 short TFractalViewerWindow::GetStyle()
73 {
74 return style;
75 }
76
77
78 void TFractalViewerWindow::SetStyle(short w)
79 {
80 style = w;
81 RefreshWindow(true);
82 }
83
84
85
86 short TFractalViewerWindow::GetDrawMode()
87 {
88 return drawMode;
89 }
90
91
92 void TFractalViewerWindow::SetDrawMode(short m)
93 {
94 if (drawMode != m) {
95 drawMode = m;
96 RefreshWindow(true);
97 }
98 }
99
100
101
102 /****
103 * Draw
104 *
105 * Draw the bullseye figures.
106 * Repeatedly call DrawShape with a smaller drawing area.
107 * The drawing area gets smaller by 2 * the width.
108 *
109 ****/
110
111 void TFractalViewerWindow::Draw(void)
112
113 {
114 RgnHandle saveClip = NewRgn();
115 PenState pen;
116 Rect drawingRect;
117
118
119 GetPenState(&pen);
120 GetClip(saveClip);
121
122 inherited::Draw();
123
124 GetWindowRect(&drawingRect, false); // Don't draw in the scroll
125 // bar areas. Note that it's
126 // ok to pass the address of
127 // drawingRect because
128 // GetWindowRect won't move
129 // memory.
130
131 sTop = drawingRect.top;
132 sLeft = drawingRect.left;
133
134 DrawShape(&drawingRect);
135
136 SetClip(saveClip);
137 DisposeRgn(saveClip);
138 SetPenState(&pen);
139
140 }
141
142
143 /****
144 * DrawShape methods
145 *
146 * These are the DrawShape methods for
147 * TBullWindow: does nothing
148 * TCircleBull: Circles
149 * TSquareBull: Squares
150 * TPlasma: "Triangles"
151 *
152 * All the DrawShape methods take a drawingRect
153 * as a parameter. The pen width
154 * is already set to the appropriate width.
155 *
156 ****/
157
158 void TFractalViewerWindow::DrawShape(Rect *drawingRect)
159 {
160 }
161
162 //
163 // ZOOM CONTENT
164 //
165
166 void TFractalViewerWindow::ZoomContent(short z)
167 {
168 RefreshWindow(false); // preserve the scroll bars
169 }