#if !defined(__RV_PICTURE_H_INCLUDED_)
#define __RV_PICTURE_H_INCLUDED_


#include "Indix.h"


//PICTURE CONTROL POINTS
#define PI_CP_COUNT  4
  

class INDIX_API CPicture :	public CIndicater
{
public:
	CPicture();
	virtual ~CPicture();

	enum STYLE
	{
		PS_DEFAULT =0,
		PS_STRETCH,
		PS_CIRCLE,
		PS_ANYQUAD,    //不变形
		PS_ANYQUAD_EX, //变形
		PS_CENTER,     //居中显示
	};

	virtual BOOL  Create(/*CDelegate* pDelegate=NULL,*/ const TCHAR* strName = NULL, UINT id =-1, int style =RV_UC_DEFAULT_STYLE) ;
	virtual void  Destroy(/*BOOL bEraseStroke=FALSE*/) ;
	virtual void  Show(CDelegate* pDelegate,int mode, BOOL bForce);	

	virtual void OnEndTrack(CDelegate* pDelegate,HGPD hCur,  GPoint point, int type) ;
	virtual CUCObj* Clone(  CUCObj* twin) ;
	
	virtual void SetClientRect(int x, int y, int w, int h);

	void  SetApperanceStyle(CPicture::STYLE style);

	int  GetApperanceStyle()	{	return m_nApperance; };
	   

	void    SetImage(const RvImage image);
	BOOL    SetImageEx(const TCHAR* strPathName);
	 
	//清除图像
	void  Clear();

	virtual BOOL Serialize(HANDLE device, BOOL bIn ) ;

	//控制点共四个，在显示类型为PS_ANYQUAD或PS_ANYQUAD的时候有效。
	//bUpdate将更行client rect数据
	void  SetControlPoint(int index, GPoint pos, BOOL bUpdate=FALSE);
	GPoint GetControlPoint(int index);

	const RvImage GetImage();

	GRgb    GetBorderColor() { return m_borderColor; };
	virtual void    SetBorderColor(GRgb& val);

public:
	virtual BOOL OnPositionChange( HGPD hOri, HGPD hCur, HGPD hNew, GPoint grabPos, RvOffset &offset) ;

	virtual BOOL OnExtenderChange( HGPD hCur, HGPD hNew, int index, GPoint &curPos) ;

	virtual void ShowSketch(CDelegate* pDelegate,CSketchMark* pMark, HGPD hGpd, int grabType, GPoint grabPos);

	virtual int  HitTest(CDelegate* pDelegate, GPoint point);

	virtual HGPD CreateGraphicDescriptor(CDelegate* pDelegate) ;

	//virtual GRect  GetGrabberRect(BOOL bActualSize) ;
	virtual GRect  GetExtenderRect(CDelegate* pDelegate,int index, RvSize size) ;
	  
protected:
	 
	RvImage   m_image;  
	RvImage   m_imAlpha;  
	GRgb m_borderColor;
   
	BOOL    m_bLoaded;
 

	int     m_nApperance;
 
	void ResetImageFormat();
	 
		 
	RV_HANDLE DrawImageCP(HGDC dc, RvImage image, GRect& rect,  int type, GPoint* pControlPoints, RV_HANDLE hStroke  );
	

	GPoint  m_controlPoints[PI_CP_COUNT];
	 


};






#endif //__RV_ILLUSTRATER_H_INCLUDED_