/****************************************************************************************


		MFFillAttributes.h


		Copyright: (c) 2001 Eovia Corp. All rights reserved.

		Author:	Greg
		Date:	2/17/99

		This file describes MFFillAttributes, which is used to describe a richer
		color/filling definition than a TMCRGBColor.  It is used by parts to set
	 	parameters such as color, pattern, and other parameters (eventually).  Right
	 	now, only colors can be described, but UI personality colors can be specified
	 	so a part user/writer can say that a fill color is a certain UI color rather
	 	than a specific RGB value.

		Revision History

		when		who			what & why
		==========	==========	======================================================

*****************************************************************************************/

#ifndef __MFFILLATTRIBUTES__
#define __MFFILLATTRIBUTES__

#if CP_PRAGMA_ONCE
#pragma once
#endif

#include "MCBasicTypes.h"
#include "MCUIColor.h"

#ifdef qIsInExtension
#include "COMUtilities.h"
#include "IShUtilities.h"
#else
#include "MCPersonality.h"
#endif


/// TMFFillAttributes is used to fill an area with a color (for now)
/// If #fUIColorIndex is not kUIColor_UseRGBColor, it references a predefined color 
/// (that the user can choose in the preferences).
/// Otherwise, the fColor field is used.
///
class TMFFillAttributes
{
public:

	TMFFillAttributes(EUIColor inUIColorIndex = kUIColor_UseRGBColor, TMCRGBColor inColor = TMCRGBColor::sBlack)
					 : fColor(inColor), fUIColorIndex(inUIColorIndex) {}

	TMFFillAttributes(TMCRGBColor inColor) : fColor(inColor), fUIColorIndex(kUIColor_UseRGBColor) {}

	operator				TMCRGBColor			()								{ return GetDisplayColor(); }

	inline boolean			operator==			(const TMFFillAttributes& inFill) const;

	/// Returns the color that should be used in a draw routine
	/// by decoding the UIColor and RGB color.  This value should not
	/// be cached since the personality colors can change at any time.
	///
	inline TMCRGBColor		GetDisplayColor		();
		
		
	// raw accessors
	TMCRGBColor&			GetRGBColor			() 								{ return fColor; }
	EUIColor				GetUIColorIndex		() const						{ return fUIColorIndex; }
	void					SetRGBColor			(const TMCRGBColor& inColor) 	{ fColor = inColor; }
	void					SetUIColorIndex		(EUIColor inUIColorIndex)		{ fUIColorIndex = inUIColorIndex; }
		
protected:

	TMCRGBColor		fColor;
	EUIColor		fUIColorIndex;
};


TMCRGBColor TMFFillAttributes::GetDisplayColor()
{
	if (fUIColorIndex != kUIColor_UseRGBColor)
	{
#ifdef qIsInExtension
		return gPersonalityUtilities->GetUIColor(fUIColorIndex);
#else
		return TMCPersonality::GetUIColor(fUIColorIndex);
#endif		
	}
	return fColor;
}

boolean TMFFillAttributes::operator==(const TMFFillAttributes& inFill) const
{
	if (fUIColorIndex != inFill.fUIColorIndex)
		return false;
	if (fUIColorIndex == kUIColor_UseRGBColor)
	{
		return (fColor == inFill.fColor);
	}
	return true;
}


#endif