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


		MCTextStyle.h

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




		Author:	Ian (from RDSource)
		Date:	12/11/97

		Revision History

		when		who			what & why
		==========	==========	======================================================
		11/1/99		Pierre		Added validity concept
		4/20/99		Eml			moved enum MCTextMode and MCTextJustification to MCUITextStyle.h (for external use)
		3/26/99		Greg		moved ETextStyle to MCUITextStyle.h (for external use)
		3/4/99		Ian			Added fUIStyle, which is used to denote certain personality fonts.
		2/8/99		Ian			Added some operators.
		1/28/99		Ian			Got rid of TextFace type, use the constants defined in
								MCFont.h (kMCFontPlain, kMCFontBold, etc..). All functions
								that used to take and use TextFace now use a uint16.
		9/22/98		pbk			removed GetPixelSize you should use 
								static TMCGraphicContext::GetTextStylePixelSize instead
		9/21/98		pbk			Added support for vertical text.
		6/2/98		Ian			Made the App9 and Sys12 text styles available with accessors
								to fix order of initialization problems.
								Had to add a TMCPlatformWindow* global so we can calculate
								font metrics.
		4/2/98		Ian			Moved operators into MCStreamOperators.
		3/20/98		Ian			Cleaned up enums, and added kJustDefault.
		3/13/98		Ian			Added TMCTextMetrics class.

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

#ifndef __MCTextStyle__
#define __MCTextStyle__

#if CP_PRAGMA_ONCE
#pragma once
#endif

#include "MCBasicTypes.h"
#include "MCString.h"
#include "MCUITextStyle.h"


class TMCiostream;

/// Stores the infos about the style used to display some text.
/// When #fUIStyle is not kUseTextStyle, the style is one of the predefined styles. 
/// Otherwise, the other fields (#fFace, #fLogicalSize, #fFontName) will be used.
///
class TMCTextStyle : public TMCObject
{
public:
					TMCTextStyle	();
					TMCTextStyle	(const TMCString& fontName, uint16 size, uint16	face);

	void			GetFontName		(TMCString& fontName) const;
	uint16			GetLogicalSize	(void) const;
	uint16			GetFace			(void) const;
	ETextStyle		GetUIStyle		(void) const;

	void			SetUIStyle		(ETextStyle inStyle);
	void			SetFontName		(const TMCString& fontName);
	void			SetLogicalSize	(uint16 size);
	void			SetFace			(uint16 face);

	void			GetFromResource	(uint16 rsrcID);
	boolean			IsDefault		(void) const;
	boolean			IsDefaultFace	(void) const;

	boolean			HasValidTextStyle() const;
	void			SetValid		(boolean inValid);

	TMCTextStyle&	operator=		(const TMCTextStyle& inRhs);
	boolean			operator==		(const TMCTextStyle& inRhs) const;
	boolean			operator!=		(const TMCTextStyle& inRhs) const;

	friend TMCiostream& operator<<	(TMCiostream& outStream, const TMCTextStyle& writeOut);
	friend TMCiostream& operator>>	(TMCiostream& inStream, TMCTextStyle& readIn);

protected:
	void			CalculatePixelSize(); // Slow on PC.

	ETextStyle		fUIStyle;		///<

	boolean			fValid;			///< true if the style is valid
	uint16			fFace;			///< kMCFontPlain, kMCFontBold...
	uint16 			fLogicalSize;	///< The one in the resource
	uint16			fPixelSize;		///< The "real" one. 0 means not calculated yet
	TMCString63		fFontName;		///< The name of the font to use
};

inline boolean TMCTextStyle::operator!=	(const TMCTextStyle& inRhs) const 
{
	return !(*this == inRhs);
}


typedef uint32 MCTextAlignX;
typedef uint32 MCTextAlignY;
typedef uint32 MCTextWrap;

/// Undocumented
///
struct TMCTextMetrics  : public TMCObject
{
	int16	fAscent;
	int16	fDescent;
	int16	fWidthMax;
	int16	fLeading;
};

#endif