/***** * TFractalViewerWindow.c * * The window methods for the application. * * TFractalViewerWindow inherits its Draw method from TWindow. * TMandelbrot, TJulia, and others override DrawShape to draw their own kind of CGI. * *****/ #include // for NumToString prototype #include "TFractalViewerWindow.h" #include #include "Utils.h" /**** * TFractalViewerWindow constructor * * Create a bullseye window. This constructor relies * on the TWindow constructor to place the window in * in attractive place. Then it appends a number to the * window title. * ****/ TFractalViewerWindow::TFractalViewerWindow(void) { Str15 numStr; Str255 title; long windowNumber; // Set the title of the window to be // the title in the resource // plus the window counter. // The window counter is a class variable // declared in the TWindow class. GetWindowTitle(title); windowNumber = GetWindowNumber(); NumToString(GetWindowNumber(), numStr); concat(title, numStr); SetWindowTitle(title); } /**** * Hit * * Handle a mouse down in the window. * Bullseye window just force a refresh. * ****/ void TFractalViewerWindow::Hit(Point where) { RefreshWindow(false); // preserve the scroll bars } /**** * GetStyle * SetStyle * * Get and set the color style * ****/ short TFractalViewerWindow::GetStyle() { return style; } void TFractalViewerWindow::SetStyle(short w) { style = w; RefreshWindow(true); } short TFractalViewerWindow::GetDrawMode() { return drawMode; } void TFractalViewerWindow::SetDrawMode(short m) { if (drawMode != m) { drawMode = m; RefreshWindow(true); } } /**** * Draw * * Draw the bullseye figures. * Repeatedly call DrawShape with a smaller drawing area. * The drawing area gets smaller by 2 * the width. * ****/ void TFractalViewerWindow::Draw(void) { RgnHandle saveClip = NewRgn(); PenState pen; Rect drawingRect; GetPenState(&pen); GetClip(saveClip); inherited::Draw(); GetWindowRect(&drawingRect, false); // Don't draw in the scroll // bar areas. Note that it's // ok to pass the address of // drawingRect because // GetWindowRect won't move // memory. sTop = drawingRect.top; sLeft = drawingRect.left; DrawShape(&drawingRect); SetClip(saveClip); DisposeRgn(saveClip); SetPenState(&pen); } /**** * DrawShape methods * * These are the DrawShape methods for * TBullWindow: does nothing * TCircleBull: Circles * TSquareBull: Squares * TPlasma: "Triangles" * * All the DrawShape methods take a drawingRect * as a parameter. The pen width * is already set to the appropriate width. * ****/ void TFractalViewerWindow::DrawShape(Rect *drawingRect) { } // // ZOOM CONTENT // void TFractalViewerWindow::ZoomContent(short z) { RefreshWindow(false); // preserve the scroll bars }