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


		MFPartTypes.h


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


		Author:	Ian from link and RDSource.
		Date:	1/5/98

		This file contains types used with the MFrame view system.

		Revision History

		when		who			what & why
		==========	==========	======================================================
		10/1/99		EricB		Added kRGBColorValueType - you be prefered to kColorValueType,
								because it does NOT generate accuracy erros whenused in PMaps
		8/1/99		Ian			Got rid of mouse moved state, we now use explicit functions.
		6/10/99		Yann		Removed unneeded #include to GCTypes.h. 
		6/3/99		Ian			Moved TMFPartConstraints to MFConstraints.h and renamed it
								to TMFConstraints.
		06/01/99	del			Irrelevant comment, be careful when changing code, people
								rely on comments when they exist
		05/26/99	Frh			Added kIMCUnknownValueType.
		4/21/99		Ian			Added contextual menu ID to part info, and a token for it.
		4/5/99		Ian			Added tool tip data, updated token contants to correct
								format.
		3/30/99		Ian			Renamed kInt32MinMaxValueType to kInt32MinMaxOnlyValueType
								and kReal32MinMaxValueType to kReal32MinMaxOnlyValueType.
								Added kInt32MinMaxCurPageValueType and
								kReal32MinMaxCurPageValueType, these replace the old
								kInt32MinMaxValueType and kReal32MinMaxValueType.
								TMFPartConstraints::Apply() now takes an optional
								parameter that will contain the actual change.
		2/15/99		Ian			Added kActionValueType.
		01/19/99	Nba			Added rect and point types
		11/5/98		Ian			Added TMFRevealData for use with kMsg_RevealRect.
		10/5/98		dsm			changed uint32 to IDType
		8/28/98		Ian			Added some more data types for set value,
								added kMustInvalidate_Token, got rid of fControlMessage
								and added fMustFullyInvalidate.
		8/12/98		Thierry		added SelfApply to TMFPartConstraints
		8/3/98		Ian			MCFont.h changed to MCTextStyle.h.
		7/19/98		Ian			Added TMFDragDropInfo.
		7/10/98		Thierry		added Apply of TMFPartConstraints
		6/19/98		Ian			Got rid of MFPartValue, added kBooleanValueType.
		6/12/98		Greg		New GetValue(), SetValue()
		6/12/98		Ian			fBackErase is now in the part info.
								Removed some obsolete stream operators.
		6/10/98		Ian			Added EMouseMovedState.
		5/27/98		Ian			Added token code. ReadAttribute(), WriteAttributes().
		5/8/98		Pbk			added a fUseDoubleBuffer to Partinfo with appropriate accessors
		5/7/98		Ian			Added kMFDialogResourceType.
		5/5/98		Ian			Added an operator>> and << for TMFPartConstraints, also
								reved the TMFPartInfo version.
		4/30/98		Ian			Added kMFNodeResourceType, and kMFWindowResourceType,
								added a version to TMFPartInfo and added constants to
								be used with it.
		4/23/98		Ian			Included MFTypes. Implemented TMFPartConstraints.
		4/10/98		Ian			Added MFStreamDelimitor type, and some enums to go with
								it, as well as an enum to describe the resource type of
								our framework elements, also added fControlMessage to
								TMFPartInfo.
		4/7/98		Ian			Added EMFPartRectVisiblity, it's used as a return value for
								TMFLeafPart::IsRectVisible(). Initializing more data in
								the constructor for TMFScrollDataPacket.
		4/2/98		Ian			Moved stream operators into MCStreamOperators.h, changed
								TMFDataPacket to be a base struct that the different message
								structs derive from. Added TMFScrollDataPacket.
		3/17/98		Ian			Moved kDataFrequencyMsg, and kEnableFrequencyMsg from
								here to MFLeafPart.
		3/13/98		Ian			Changed all View to Part. Also added TMFDataPacket,
								related types, and constants.

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

#ifndef __MFPartTypes__
#define __MFPartTypes__

#if CP_PRAGMA_ONCE
#pragma once
#endif

#include "MCBasicTypes.h"
#include "MCTextStyle.h"
#include "MCStreamBased.h"

#include "MFTypes.h"

class TMCRect;

typedef uint32	MFFrequency;
typedef uint32	MFPartID;
typedef uint32	MFPartKind;
typedef uint32	MFCursorID;
typedef uint32	MFStreamDelimitor;

//=======================================================
// Part Value Types (used in GetValue() and SetValue()
//=======================================================
typedef IDType MFPartValueType;
#define kInt16ValueType					'in16'	// Data is int16.
#define kInt32ValueType					'in32'	// Data is int32.
#define kReal32ValueType				're32'	// Data is real32.
#define kReal64ValueType				're64'	// Data is real64.
#define kStringValueType				'str '	// Data is TMCString.
#define kRGBColorValueType				'RGBc'	// Data is TMCRGBColor.
#define kColorRGBValueType				'colo'	// Data is TMCColorRGBA
#define kColorRGBAIndexValueType		'colI'	// Data is TMCColorRGBAIndex
#define kGradientValueType				'grad'	// Data is TMCGradient
#define kColorRGB214ValueType			'colF'  // Data is TColorRGB214
#define kRectValueType					'rect'	// Data is TMCRect
#define kPointValueType					'poit'	// Data is TMCPoint
#define kBooleanValueType				'bool'	// Data is boolean.
#define kVector2ValueType				'vec2'	// Data is TVector2
#define kVector3ValueType				'vec3'	// Data is TVector3
#define kMatrix33ValueType				'mat3'	// Data is TMatrix33
#define kActionValueType				'actn'	// Data is ActionNumber
#define kInt32MinMaxOnlyValueType		'mi32'	// Data is TMFMinMaxOnlyInt32DataPacket.
#define kReal32MinMaxOnlyValueType		'mr32'	// Data is TMFMinMaxReal32DataPacket.
#define kIMCUnknownValueType			'iunk'	// Data is IMCUnknown*.

//These are used as well in the data broadcast routines (BeginTracking(), ContinueTracking(), etc..)
#define kInt32MinMaxCurPageValueType	'mcpi'	// Data is TMFMinMaxCurPageInt32DataPacket.
#define kReal32MinMaxCurPageValueType	'mcpr'	// Data is TMFMinMaxCurPageReal32DataPacket.
#define kScrollInfoValueType			'sinf'	// Data is TMFScrollDataPacket.

//This is used in PartValueChanged to notify autoupdate members 
//that different multiple values have been set on the part
#define kUndefinedValueState			'undf'	// No Data


enum EMFCursorConstant
{
	kNoCursorID = 0
};

enum EMFHelpconstants
{
	kNoSelfHelp	= 0,
	kNoHelp		= -1
};

enum EMFPartRectVisiblity
{
	kNotVisible,
	kVisible,
	kPartiallyVisible
};


enum EOpacityKind
{
	kOpacityNone	= 0,
	kOpacityPartial = 1,
	kOpacityFull	= 2,

	kInvalidOpacity = 0xFFFFFFFF
};


//Misc. constants. Used by getResources()
enum EMFResources
{
	kMFPartResourceType					= 'Part',
	kMFNodeResourceType					= 'Node',
	kMFWindowResourceType				= 'Wind',
	kMFDialogResourceType				= 'Dlog',
	kMFToolbarResourceType				= 'TBAR',
	kMFStreamDel_NullObject				= 'null',
	kMFStreamDel_ClassIDAndClassname 	= 'CNam',
	kMFStreamDel_SignatureAndClassname	= 'SNam'
	
};

enum EMFPartConstraintVersion
{
	kPARTCONSTRAINTS_Version1		= 1,
	kPARTCONSTRAINTS_CurrentVersion = kPARTCONSTRAINTS_Version1
};


enum EMFPartInfoVersion
{
	kPARTINFO_Version1		 = 1,
	kPARTINFO_Version2		 = 2,
	kPARTINFO_CurrentVersion = kPARTINFO_Version2
};

enum EScrollInfoOrientation
{
	kScrollInfo_Horizontal = 0,
	kScrollInfo_Vertical
};

//	This class is for broadcasting data to other "things".
/// Undocumented, do NOT use in extensions.
///
struct TMFDataPacket
{
	MFPartValueType		fDataKind;
};

struct TMFInt32DataPacket : TMFDataPacket
{
	TMFInt32DataPacket(int32 inValue);

	int32 fValue;
};
inline TMFInt32DataPacket::TMFInt32DataPacket(int32 inValue)
{fDataKind = kInt32ValueType; fValue = inValue;}

struct TMFReal32DataPacket : TMFDataPacket
{
	TMFReal32DataPacket(real32 inValue);
	real32 fValue;
};
inline TMFReal32DataPacket::TMFReal32DataPacket(real32 inValue)
{fDataKind = kReal32ValueType; fValue = inValue;}

struct TMFStringDataPacket : TMFDataPacket
{
	TMFStringDataPacket(const TMCString& inString);
	const TMCString& fString;
};
inline TMFStringDataPacket::TMFStringDataPacket(const TMCString& inString) : fString(inString)
{fDataKind = kStringValueType;}

struct TMFColorIntDataPacket : TMFDataPacket
{
	TMFColorIntDataPacket(uint16 inRed, uint16 inGreen, uint16 inBlue);

	uint16	red;
	uint16	green;
	uint16	blue;
};
inline TMFColorIntDataPacket::TMFColorIntDataPacket(uint16 inRed, uint16 inGreen, uint16 inBlue)
{fDataKind = kRGBColorValueType; red = inRed; blue = inBlue; green = inGreen;}

struct TMFBooleanDataPacket : TMFDataPacket
{
	TMFBooleanDataPacket(boolean inValue);
	
	boolean fValue;
};
inline TMFBooleanDataPacket::TMFBooleanDataPacket(boolean inValue)
{fDataKind = kBooleanValueType; fValue = inValue;}

struct TMFMinMaxOnlyInt32DataPacket : TMFDataPacket
{
	TMFMinMaxOnlyInt32DataPacket(int32 inMin, int32 inMax);
	
	int32	fCurValue;
	int32	fMinValue;
	int32	fMaxValue;
	int32	fPageValue;
};

inline TMFMinMaxOnlyInt32DataPacket::TMFMinMaxOnlyInt32DataPacket(int32 inMin, int32 inMax)
{fDataKind = kInt32MinMaxOnlyValueType; fMinValue = inMin; fMaxValue = inMax;}

struct TMFMinMaxCurPageInt32DataPacket : TMFMinMaxOnlyInt32DataPacket
{
	TMFMinMaxCurPageInt32DataPacket(int32 inCur, int32 inMin, int32 inMax, int32 inPage);
	
	int32	fMinValue;
	int32	fMaxValue;
};

inline TMFMinMaxCurPageInt32DataPacket::TMFMinMaxCurPageInt32DataPacket(int32 inCur, int32 inMin, int32 inMax, int32 inPage) :
	TMFMinMaxOnlyInt32DataPacket(inMin, inMax)
{fDataKind = kInt32MinMaxCurPageValueType; fCurValue = inCur; fPageValue = inPage;}

struct TMFMinMaxOnlyReal32DataPacket : TMFDataPacket
{
	TMFMinMaxOnlyReal32DataPacket(real32 inMin, real32 inMax);

	real32	fMinValue;
	real32	fMaxValue;
};
inline TMFMinMaxOnlyReal32DataPacket::TMFMinMaxOnlyReal32DataPacket(real32 inMin, real32 inMax)
{fDataKind = kReal32MinMaxOnlyValueType; fMinValue = inMin; fMaxValue = inMax;}

struct TMFMinMaxCurPageReal32DataPacket : TMFMinMaxOnlyReal32DataPacket
{
	TMFMinMaxCurPageReal32DataPacket(real32 inCur, real32 inMin, real32 inMax, real32 inPage);

	real32	fCurValue;
	real32	fPageValue;
};
inline TMFMinMaxCurPageReal32DataPacket::TMFMinMaxCurPageReal32DataPacket(real32 inCur, real32 inMin, real32 inMax, real32 inPage) :
	TMFMinMaxOnlyReal32DataPacket(inMin, inMax)
{fDataKind = kReal32MinMaxCurPageValueType; fCurValue = inCur; fPageValue = inPage;}

struct TMFScrollDataPacket : TMFDataPacket
{
	TMFScrollDataPacket(void);

	boolean fContainsData[2];
	int32	fCurValue[2];
	int32	fMinValue[2];
	int32	fMaxValue[2];
	int32	fPageValue[2];
};
inline TMFScrollDataPacket::TMFScrollDataPacket(void)
{fDataKind = kScrollInfoValueType; fContainsData[0] = false; fContainsData[1] = false;}

#if 0
struct TMFControllerDataPacket : TMFDataPacket
{
	TMFControllerDataPacket(real32 fCurValue, real32 fMinValue, real32 fMaxValue, real32 fPgeValue, boolean playing);

	float	fCurValue;
	float	fMinValue;
	float	fMaxValue;
	float	fPageValue;
	boolean	fPlaying;
};
inline TMFControllerDataPacket::TMFControllerDataPacket(real32 inCur, real32 inMin, real32 inMax, real32 inPage, boolean inPlaying)
{fDataKind = kDATA_MinMaxReal32; fCurValue = inCur; fMinValue = inMin; fMaxValue = inMax; fPageValue = inPage; fPlaying = inPlaying;}

class TMFDragDropInfo
{
	IDType				fDragType;
	TMCArray<IDType>	fDragFlavors;
	
};
#endif


/// Undocumented, do NOT use in extensions.
///
struct TMFEndTrackingData
{
	boolean			fHasChanged;
	TMFDataPacket*	fDataPacket;
};

/// Undocumented, do NOT use in extensions.
///
class TMFRevealData
{
public:
	enum HorizontalComponent
	{
		kLeft,
		kRight
	};

	enum VerticalComponent
	{
		kTop,
		kBottom
	};

	TMFRevealData(
		const TMCRect&		inRevealRect,
		HorizontalComponent	inImportantHorizontal = kLeft,
		VerticalComponent	inImportantVertical = kTop)
	: fRevealRect(inRevealRect),
	fImportantHorizontal(inImportantHorizontal),
	fImportantVertical(inImportantVertical) {}

	const TMCRect&		fRevealRect;			//in window coordinates.
	HorizontalComponent	fImportantHorizontal;	//Most important horizontal part of the rect to reveal.
	VerticalComponent	fImportantVertical;		//Most important horizontal part of the rect to reveal.
};

#endif