// Copyright 1999 // College of Computer Science // Northeastern University Boston MA 02115 // This software may be used for educational purposes as long as this copyright // notice is retained at the top of all files // Should this software be modified, the words "Modified from Original" must be // included as a comment below this notice // All publication rights are retained. This software or its documentation may // not be published in any media either in whole or in part. /////////////////////////////////////////////////////////////////////////////// // GraphicsState.cpp /////////////////////////////////////////////////////////////////////////////// #include "CoreTools.h" #include "SystemBase.h" #include "GraphicsState.h" void GraphicsState::StartUp() { // objects Location. Set(0, 0); // upper left of window PenSize. Set(1, 1); // initial size = 1,1 PenSize. SetMinAndDef(1, 1); // minimum size = 1,1 PenColor. Set( 0, 0, 0); // black FillColor. Set( 0, 0, 0); // black TextColor. Set( 0, 0, 0); // black BackgroundColor.Set(255, 255, 255); // white Transform. Set(1, 0, 1, 0); // identity transform // scalars PenMode = PM_Normal; TextAlign = HAlign_Left | VAlign_Top; BackgroundMode = BM_Transparent; EnableClip = false; } #if defined(CORE_PLATFORM_WIN32) void WIN32_GraphicsState::StartUp() { // set some colors RGBdata black( 0, 0, 0); // clean up the existing brushes if any if(!isfirst) CleanUp(); // initial pen xpen = 1; ypen = 1; // create brushes PenBrush = CreateSolidBrush(black.Native()); FillBrush = CreateSolidBrush(black.Native()); // no clip region ClipRgn = NULL; TextAlign = TA_NOUPDATECP | TA_TOP | TA_LEFT; isfirst = false; } void WIN32_GraphicsState::CleanUp() { // if isfirst then nothing to clean up if (isfirst) return; // delete brushes DeleteObject(PenBrush); DeleteObject(FillBrush); // delete clip region if it exists if (ClipRgn != NULL) { DeleteObject(ClipRgn); ClipRgn = NULL; } isfirst = true; } void WIN32_GraphicsState::SetPenColor(const RGBdata& color) { // make sure the whole state is initialized if (isfirst) StartUp(); DeleteObject(PenBrush); PenBrush = CreateSolidBrush(color.Native()); } void WIN32_GraphicsState::SetFillColor(const RGBdata& color) { // make sure the whole state is initialized if (isfirst) StartUp(); DeleteObject(FillBrush); FillBrush = CreateSolidBrush(color.Native()); } #endif // end WIN32 specific #if defined(CORE_PLATFORM_MACOS) #endif // end MacOS specific