// Mark.h: interface for the CMark class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(_RV_MARK_H_INCLUDED_)
#define _RV_MARK_H_INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "IndiX.h"

//MARK OUTER SHAPE
//#define RV_MT_DEFAULT      0
//#define RV_MT_FOCUS        1
//#define RV_MT_SQUARE       2
//#define RV_MT_ROUND        3


//**************************** MARK flags *********************************
//MARK INNER SHAPE
#define RV_MIS_NONE          0
#define RV_MIS_SPOT          1   //POINT OR FILLED CIRCLE
#define RV_MIS_CROSS        (1 << 1) 
#define RV_MIS_EXPRESS      (1 << 2) 
#define RV_MIS_CROSS_EX     (1 << 3) 
#define RV_MIS_EXPRESS_EX   (1 << 4)  
#define RV_MIS_LINE_H       (1 << 5) 
#define RV_MIS_LINE_V       (1 << 6) 
#define RV_MIS_RULER_H      (1 << 7) 
#define RV_MIS_RULER_V      (1 << 8)  
#define RV_MIS_IMAGE        (1 << 15)   

//MARK OUTER SHAPE
#define RV_MOS_NONE       (0x0000 << 16)
#define RV_MOS_FOCUS      (0x0001 << 16)
#define RV_MOS_BOX        (0x0002 << 16)
#define RV_MOS_DISK       (0x0004 << 16)
#define RV_MOS_RULER      (0x0008 << 16)
#define RV_MOS_BOXDISK    (0x0010 << 16)
#define RV_MOS_DISKLINES  (0x0011 << 16)


//#define RV_MOS_LINES_H    (0x0008 << 16) //一对水平线
//#define RV_MOS_LINES_V    (0x0010 << 16) //一对垂直线 
//


class INDIX_API CMark  : public CIndicater  
{
public:
	enum OUTER_SHAPE
	{
		OS_NONE  = RV_MOS_NONE,
		OS_FOCUS = RV_MOS_FOCUS,
		OS_BOX   = RV_MOS_BOX,
		OS_DISK  = RV_MOS_DISK,
		OS_RULER = RV_MOS_RULER,
		OS_BOXDISK =RV_MOS_BOXDISK,
		OS_DISKLINES  = RV_MOS_DISKLINES,
	};

	enum INNTER_SHAPE
	{
		IS_NONE = RV_MIS_NONE ,
		IS_SPOT = RV_MIS_SPOT ,
		IS_CROSS = RV_MIS_CROSS,
		IS_EXPRESS = RV_MIS_EXPRESS,
		IS_CROSS_EX = RV_MIS_CROSS_EX,
		IS_EXPRESS_EX = RV_MIS_EXPRESS_EX, 
		IS_LINE_H = RV_MIS_LINE_H,  //用于divider
		IS_LINE_V = RV_MIS_LINE_V,  //用于divider
		IS_RULER_H = RV_MIS_RULER_H,
		IS_RULER_V = RV_MIS_RULER_V,
		IS_IMAGE  = RV_MIS_IMAGE,   
	};

	CMark();
	//style could be ,for example, OS_FOCUS | IS_CROSS;
	CMark(int style, GSize outerSize, GSize innerSize=GSIZE(18,18), GRgb color=GRGB(0xFF, 0,0));
	virtual ~CMark();


	virtual BOOL Serialize(HANDLE device, BOOL bIn ) ;
	virtual CUCObj* Clone(  CUCObj* twin) ;

	virtual BOOL  Create(/*CDelegate* pDelegate=NULL, */const TCHAR* strName = NULL, UINT id =-1, int style =RV_UC_DEFAULT_STYLE) ;
	 
	int  GetOuterStyle();
	//
	//如style为OS_RULER，必须设置Inner Style 为IS_RULER_H或IS_RULER_V或 IS_RULER_H | IS_RULER_V。
	//如果为OS_CUST，则必须设置Inner Style 为IS_IMAGE。
	void SetOuterStyle(int style);
	 
	int  GetInnerStyle();
	void SetInnerStyle(int style);

	//如bCentered为TRUE，表示将以目前的位置为中心进行改变大小。
	//Mark的位置为左上角。
	//这样Mark的中心位置将保持不变。
	void SetOuterSize(GSize size/*, BOOL bCentered =FALSE*/);
	void SetOuterSize(int  sx, int sy);


	GSize GetOuterSize() {return m_outerSize; }
	 
	void SetInnerSize(GSize size);
	void SetInnerSize(int  sx, int sy);


	GSize GetInnerSize() {return m_innerSize; }
	 
	BOOL IsPosCentered(){ return m_bPosCentered; };
	void SetPosCentered(BOOL flag);
	 
	//pos指左上角坐标。
	//如bCentered为TRUE，pos将以MARK的中心为坐标，而
	//不是左上角
	void SetCurPos(GPoint pos );
	void SetCurPos(int x, int y);

	//该为位置取决于centerpos的值
	GPoint GetCurPos( )  ;
	 
	void SetCustomImage(const RvImage image);

	virtual void Move(RvOffset &offset) ;
	virtual void Move(double dx, double dy) ;

	 
	virtual void   SetCtrlRect(int left, int top, UINT width, UINT height) ;

	//下面的函数将自动设置centerpos为FALSE
	virtual void   SetCtrlRect(int left, int top, int right, int bottom) ;
	virtual RvRect GetCtrlRect();

	virtual void   SetCtrlPos(int x, int y);
	virtual RvPoint GetCtrlPos();

	const TCHAR* GetCaption(){ return m_strCaption;};
	void  SetCaption(const TCHAR* strCaption);

public:
	 
 	virtual void Show(CDelegate* pDelegate,int mode, BOOL bForce);
	virtual void ShowSketch( CDelegate* pDelegate,CSketchMark* pMark,  HGPD hGpd,  int grabType, GPoint grabPos);
	//virtual void ShowSketch(CSketchMark* pMark, HGPD hGpd, int grabType, GPoint grabPos);
	//virtual void ShowSketch(RvPoint leftTop, RvPoint rightBottom);

	virtual void OnEndTrack(CDelegate* pDelegate,HGPD hCur,  GPoint point, int type) ;

protected:
	RV_HANDLE DrawMark(HGDC dc, int dx, int dy, float rotate, RV_HANDLE hStroke );
	RV_HANDLE DrawRuler(HGDC dc, int width, int height, RV_HANDLE hStroke );
	RV_HANDLE DrawImage( HGDC dc, /*int width, int height,*/ RV_HANDLE hStroke );
	RV_HANDLE DrawBox(HGDC dc, int dx, int dy, GPoint center, float rotate, RV_HANDLE hStroke);

	void SetDefaults( int style, GSize outerSize, GSize innerSize , GRgb color );

protected: 
	 
	GSize   m_outerSize;
	GSize   m_innerSize;
	//m_pos指左上角坐标。
	GPoint  m_pos;  

	UINT    m_nFlag;   //style

	RvImage m_imCustom;

	BOOL m_bPosCentered; //位置在中心
 
	CUtString m_strCaption ; 
	  
 
};




#endif // !defined(_RV_MARK_H_INCLUDED_)
