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

		MFTypes.h

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

		Author:	
		Date:	

		Revision History

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

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

#ifndef __MCFTYPES__
#define __MCFTYPES__

#include "MCBasicTypes.h"
#include "MCBasicDefines.h"
#include "BitField.h"
#include "MCPoint.h"
#include "MCCompiler.h"

enum IdleStage 
{
	kStartIdle,
	kContinueIdle,
	kFinishIdle
};

enum TrackStage
{
	kBeginTracking,
	kContinueTracking,
	kFinishTracking
};

enum EMFReceiveResult
{
	kMFReceiveResult_KeepGoing,
	kMFReceiveResult_Stop
};

typedef int32 MessageID;


/// \addtogroup MCF
/// \{


/// TMFEventResult Describes the result of the handling of an event by a part.
///
/// \note Only used for SelfMouseDown and CallMouseDown for now.
///
class TMFEventResult : protected TBitField32
{
public:
	//	We could add a send event to next part flag... or to the part extension's part...
	inline TMFEventResult(boolean handled= false, boolean needsSelection= false) 
	{ 
		ClearAllBits(); 
		SetBitValue(kWasHandledBit, handled);
		SetBitValue(kNeedsSelectionBit, needsSelection);
	}

	/// Factory default
	///
	inline void			ClearResult			()							{ ClearAllBits(); }

	/// Returns true if the event was handled by the part
	///
	inline boolean		WasHandled			() const					{ return TestBit(kWasHandledBit); }

	/// Sets the wasHandled flag to given value
	///
	inline void			SetWasHandled		(boolean handled)			{ SetBitValue(kWasHandledBit, handled); }

	/// Returns true if the part "needs selection"
	/// Note: for now only tested by TMFWindoidPart to select the window or not in CallMouseDown
	inline boolean		NeedsSelection		() const					{ return TestBit(kNeedsSelectionBit); }

	/// Sets the NeedsSelection flag to given value
	///
	inline void			SetNeedsSelection	(boolean needsSelection)	{ SetBitValue(kNeedsSelectionBit, needsSelection); }

	/// Sets wasHandled and NeedsSelection flags
	///
	inline void			SetHandledAndSelect ()							{ SetBit(kWasHandledBit); SetBit(kNeedsSelectionBit); }

	inline void operator |=					(const TMFEventResult& rhs) { bits |= rhs.bits; }

protected:
	enum EBitsDefs
	{
		kWasHandledBit		= 0,
		kNeedsSelectionBit	= 1
	};
};


class TMFTabletMouseSample : public TMCObject
{
public:
	void			Reset()
	{
		fTimeOS = 0;
		fX = 0;
		fY = 0;
		fZ = 0;
		fRelPressure = 0;
		fRelTangPressure = 0;
		fRelTilt = 0;
		fRelBearing = 0;
		fRelRotation = 0;
	}

	void			InitFromPoint(const TMCPoint& point)
	{
		Reset();

		fX = point.x;
		fY = point.y;
	}

public:
	int32			fTimeOS;			// Event time
	real64			fX;					// X
	real64			fY;					// Y
	real64			fZ;					// Z
	real64			fRelPressure;		// Pressure {0.0 ... 1.0}
	real64			fRelTangPressure;	// Tangential pressure {-1.0 ... 1.0}
	real64			fRelTilt;			// Tilt {0.0 ... 1.0}; 0 = vertical
	real64			fRelBearing;		// Bearing {0.0 ... 1.0}; CCW, 0 = 3 o'clock
	real64			fRelRotation;		// Rotation {0.0 ... 1.0}; CCW, 0 = 'up'
};

/// \}

#endif