/* CMUgraphics Package Macintosh version 1.0 Copyright (c) 1998 by Mark Stehlik. All rights reserved. Portions of the code in this file may be derived from code written by Geoff Washburn, Patrick Doane, Jim Roberts, and Lily Hou. Please send all bug reports via e-mail to Mark Stehlik at 'mjs@cs.cmu.edu'. Redistribution and use in source and binary forms of this library, with or without modification, are permitted provided that the following conditions are met: 1. Redistribution of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistribution in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. When redistributing modified version of this library it must carry prominent notices stating the name of individual(s) that altered the files, the nature of the modifications, and the date they were performed. 4. No fee is charged for redistribution or use without prior written permission from the author. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. This file was last modified on 10.06.1998 */ #include "Graphics.h" window::window() { ToolboxInit(); WindowInit (kMyWindowID); } int window::GetWidth() {Point userClick; userClick = GetWindowDimensions(kMyWindowID); return userClick.h; } int window::GetHeight() {Point userClick; userClick = GetWindowDimensions(kMyWindowID); return userClick.v; } void window::GetWindowSize(int &iX, int &iY) {Point userClick; userClick = GetWindowDimensions(kMyWindowID); iX = userClick.h; iY = userClick.v; } void window::GetMouseCoord(int &iX, int &iY) { GetMouseLocation(iX, iY); } void window::WaitMouseClick(int &iX, int &iY) { GetClick(iX, iY); } void window::GetKeyPress(char &cKey) { GetKey(cKey); } void window::SetBrush(int color) { SetColor(color); } void window::SetBrush(int iRed, int iGreen, int iBlue) {RGBColor color; color.red = iRed; color.green = iGreen; color.blue = iBlue; RGBForeColor(&color); } void window::SetPen(int width) { PenSize(width, width); } void window::SetFont(int iSize, int iStyle, int iFamily) { TextSize(iSize); TextFace(iStyle); TextFont(iFamily); } void window::DrawPixel(int iX, int iY) { LineDraw(iX, iY, iX, iY); } void window::DrawLine(int iX1, int iY1, int iX2, int iY2) { LineDraw(iX1, iY1, iX2, iY2); } void window::DrawRectangle(int iX1, int iY1, int iX2, int iY2, drawstyle dsStyle, int iWidth, int iHeight) { if (iWidth == 0 && iHeight == 0) switch (dsStyle) { case FILLED : RectangleDraw(iX1, iY1, iX2, iY2); break; case FRAME : RectangleFrame(iX1, iY1, iX2, iY2); break; case INVERTED : RectangleInvert(iX1, iY1, iX2, iY2); break; default : cout << "Fatal Error: Invalid drawstyle!" << endl; break; } else switch (dsStyle) { case FILLED : RoundRectangleDraw(iX1, iY1, iX2, iY2, iWidth, iHeight); break; case FRAME : RoundRectangleFrame(iX1, iY1, iX2, iY2, iWidth, iHeight); break; case INVERTED : RoundRectangleInvert(iX1, iY1, iX2, iY2, iWidth, iHeight); break; default : cout << "Fatal Error: Invalid drawstyle!" << endl; break; } } void window::DrawCircle(int iX, int iY, int iRadius, drawstyle dsStyle) { switch (dsStyle) { case FILLED : CircleDraw(iX, iY, iRadius); break; case FRAME : CircleFrame(iX, iY, iRadius); break; case INVERTED : CircleInvert(iX, iY, iRadius); break; default : cout << "Fatal Error: Invalid drawstyle!" << endl; break; } } void window::DrawEllipse(int iX1, int iY1, int iX2, int iY2, drawstyle dsStyle) { switch (dsStyle) { case FILLED : OvalDraw(iX1, iY1, iX2, iY2); break; case FRAME : OvalFrame(iX1, iY1, iX2, iY2); break; case INVERTED : OvalInvert(iX1, iY1, iX2, iY2); break; default : cout << "Fatal Error: Invalid drawstyle!" << endl; break; } } void window::DrawArc(int iX, int iY, int iRadius, int iStartDegrees, int iNumDegrees, drawstyle dsStyle) { switch (dsStyle) { case FILLED : ArcDraw(iX, iY, iRadius, iStartDegrees, iNumDegrees); break; case FRAME : ArcFrame(iX, iY, iRadius, iStartDegrees, iNumDegrees); break; case INVERTED : ArcInvert(iX, iY, iRadius, iStartDegrees, iNumDegrees); break; default : cout << "Fatal Error: Invalid drawstyle!" << endl; break; } } void window::DrawString(int iX, int iY, apstring strText) { MoveTo(iX, iY); DrawStringVariable(strText); } void window::DrawInteger(int iX, int iY, int number) { MoveTo(iX, iY); DrawInt(number); }