// 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.h

///////////////////////////////////////////////////////////////////////////////

#ifndef GRAPHICSSTATE_H_
#define GRAPHICSSTATE_H_

// The commented include files are brought in by later include directives

// #include "Platform.h"
// #include "CHeaders.h"
// #include "MathUtil.h"
// #include "GeoTypes.h"
// #include "Basic2D.h"
// #include "Scale.h"

#include "RGB.h"
#include "Scale2D.h"


// forward declaration

class EXPORT GraphicsWindow;

// The following constants represent the pen modes

const int PM_Normal    = 1;			// use normal colors
const int PM_White     = 2;			// fill with white & don't change default colors
const int PM_Black     = 3;			// fill with black & don't change default colors
const int PM_Invert    = 4	;		// invert pixels underneath


// The following constants represent the choices when an object can both be
// filled with the fill color and framed with the pen color

const int FF_Fill      = 1;			// fill only: no frame
const int FF_Frame     = 2;			// frame only: no fill
const int FF_FillFrame = 3;			// both fill and frame: same as FrameFill
const int FF_FrameFill = 3;			// both fill and frame: same as FillFrame


// The following constants represent the choices for the polygon fill mode:

const int PFM_Regular  = 1;			// use regular alternating edge fill algorithm
const int PFM_Winding  = 2;			// use winding number fill algorithm


// The following constants represent the choices for text alignment

const int VAlign_Top      = 1;		// 00000001
const int VAlign_Baseline = 2;		// 00000010
const int VAlign_Bottom   = 4;		// 00000100

const int HAlign_Left     = 8;		// 00001000
const int HAlign_Center   = 16;		// 00010000
const int HAlign_Right    = 32;		// 00100000

// For internal use only

const int VAlign_MASK     = 7;      // 00000111
const int HAlign_MASK     = 56;     // 00111000


// The following constants represent the choices for the background mode

const int BM_Transparent = 0;
const int BM_Opaque = 1;


// The GraphicsState class will have all public fields to enable easy
// manipulation by the GraphicsWindow and GraphicsWidget classes


class EXPORT GraphicsState {

public:

	// object state

	PointData		Location;			// Current graphics location for line draws
										// and text position

	SizeData		PenSize;			// Note: In WIN32 only x coordinate is used


	RGBdata			PenColor;

	RGBdata			FillColor;

	RGBdata			TextColor;

	RGBdata			BackgroundColor;


	RectData		ClipRect;			// clip rectangle if clipping is enabled


	LinearScale2D	Transform;			// transform for scalable 2D widget


	// scalar state

	short			PenMode;			// pen color to pixel color transfer mode

	short			TextAlign;			// text align mask

	short			BackgroundMode;		// background mode: Transparent or Opaque

	bool			EnableClip;			// is clipping enabled?


	void StartUp();
};


// system dependent state structures and definitions


#if defined(CORE_PLATFORM_WIN32)


class EXPORT WIN32_GraphicsState {

public:

	bool	isfirst;

	// pen coordinates
	int	xpen;
	int	ypen;

	// brushes
	HBRUSH	PenBrush;
	HBRUSH	FillBrush;

	// clip region
	HRGN	ClipRgn;

	// WIN32 text alignment code
	int		TextAlign;

	// StartUp initializes to the standard initial state
	// isfirst determines if the WIN32 data should be initialized or refreshed

	void StartUp();

	// CleanUp deletes the WIN32 data

	void CleanUp();

	// Call SetFirst each time the graphics window is opened

	void SetFirst()       { isfirst = true; };

	// default constructor

	WIN32_GraphicsState() { isfirst = true; };

	// set the colors

	void SetPenColor(const RGBdata& color);

	void SetFillColor(const RGBdata& color);
};


#endif	// end WIN32 specific


#if defined(CORE_PLATFORM_MACOS)


class EXPORT MacOS_GraphicsState {

public:

	bool	isfirst;

	// StartUp initializes to the standard initial state
	// isfirst determines if the MacOS data should be initialized or refreshed

	void StartUp() { };

	// CleanUp deletes the MacOS data

	void CleanUp() { };

	// Call SetFirst each time the graphics window is opened

	void SetFirst()       { isfirst = true; };

	// default constructor

	MacOS_GraphicsState() { isfirst = true; };
};


#endif	// end MacOS specific


#endif //GRAPHICSSTATE_H_
