#ifndef __SFJP_MYU__AGH_VisualControlBase_H__
#define __SFJP_MYU__AGH_VisualControlBase_H__


/*仩仭仩仭仩仭仩仭仩仭仩仭仩仭仩仭仩仭仩仭仩仭仩仭仩仭仩仭仩仭仩仭仩仭仩仭仩仭仩仭仩仭仩仭*/

/*仩仭仩仭仩仭仩仭仩仭仩仭仩仭仩仭仩仭仩仭仩仭仩仭仩仭仩仭仩仭仩仭仩仭仩仭仩仭仩仭仩仭仩仭*/

/*仩仭仩仭仩仭仩仭仩仭仩仭仩仭仩仭仩仭仩仭仩仭仩仭仩仭仩仭仩仭仩仭仩仭仩仭仩仭仩仭仩仭仩仭*/


#define USE_RECT_CTRL

//	昞帵宯僐儞僩儘乕儖婎掙僋儔僗
class CRectControl : public agh::CControlBase
{

protected:
	agh::CRect m_rect;				//	僆僽僕僃僋僩偺嬮宍 : This Object Client Rect
	agh::COLOR m_backgroundColor;	//	攚宨怓

private:
	void _CRectControl() {
		//AghZeroMemory(&m_rect, sizeof(m_rect)); <- 僐儞僗僩儔僋僞偑傗偭偰偔傟傞偺偱梫傜側偔側偭偨丅
		m_backgroundColor = 0;
	}
public:
	//	僐儞僗僩儔僋僞
	CRectControl(){ _CRectControl(); }
	/*	暿偵彂偐側偔偰傕摨偠偐側乕丠
	CRectControl(const CRectControl& from){
		m_rect = from.m_rect;
		m_backgroundColor = from.m_backgroundColor;
	}*/
	CRectControl(int nTypeFlg) : CControlBase(nTypeFlg) {
		_CRectControl();
	}
	//	僨僗僩儔僋僞
	virtual ~CRectControl(){
	}

	/////////////////////////////////////////////////////////////////////////////

	//	埵抲娭楢僾儘僷僥傿儊僜僢僪
	//virtual void SetPos(int x, int y){ Move(x,y); }	//	2009/10/29 SetPos()偑側傫偱Move()偵側偭偰傫偺偐攃埇偟偨丅偪傖傫偲width,height寁嶼偟偰側偔偰屻夞偟偵偟偨偺偹丒丒丒
	virtual void SetPos(int x, int y){
		int width = m_rect.right - m_rect.left;
		int height = m_rect.bottom - m_rect.top;

		m_rect.left = x;
		m_rect.top = y;
		m_rect.right = x + width;
		m_rect.bottom = y + height;
	}
	virtual int GetPosX(){
		return m_rect.left;
	}
	virtual int GetPosY(){
		return m_rect.top;
	}
	virtual AGHVECTOR2 GetPos(){
		return AGHVECTOR2(m_rect.left, m_rect.top);
	}

	virtual void Move(int x, int y){
		m_rect.left += x;
		m_rect.top += y;
		m_rect.right += x;
		m_rect.bottom += y;
	}

	/*virtual void SetPos(int left, int top, int right, int bottom){
		m_rect.left = left;
		m_rect.top = top;
		m_rect.right = right;
		m_rect.bottom = bottom;
	}*/
	virtual void SetRect(int left, int top, int right, int bottom){
		m_rect.left = left;
		m_rect.top = top;
		m_rect.right = right;
		m_rect.bottom = bottom;
	}
	virtual void SetRect(_AGH_RECT &rect){
		m_rect = rect;
	}
	virtual _AGH_RECT GetRect(){ return m_rect; }
	virtual _AGH_RECT& RefRect(){ return m_rect; }

	virtual int GetWidth(){ return GetRect().right - GetRect().left; }
	virtual int GetHeight(){ return GetRect().bottom - GetRect().top; }

	/////////////////////////////////////////////////////////////////////////////

	//	2009/10/07  愨懳嵗昗庢摼
	virtual _AGH_POINT GetAbsolutePoint()
	{
		if ( m_pParent == NULL || ( m_pParent!=NULL && m_pParent->IsVisual() == false ) )
		{
			/*_AGH_RECT rect = GetRect();
			return CPoint(rect.left, rect.top);*/
			return GetRect().GetLt();
		}
		else
			return GetRect().GetLt() + ((CRectControl*)m_pParent)->GetAbsolutePoint();
	}

	_AGH_RECT GetAbsoluteRect()
	{
		//return GetRect() + GetAbsolutePoint();
		if ( m_pParent == NULL || ( m_pParent!=NULL && m_pParent->IsVisual() == false ) )
			return GetRect();
		else
			return GetRect() + ((CRectControl*)m_pParent)->GetAbsolutePoint();
	}
	//_AGH_RECT GetAbsoluteRect(){ return GetAbsoluteRect() }

	/////////////////////////////////////////////////////////////////////////////

	//	怓娭楢僾儘僷僥傿
	virtual void SetBackgroundColor(agh::COLOR color){ m_backgroundColor = color; }
	virtual void SetBackGroundColor(agh::COLOR color){ m_backgroundColor = color; }
	virtual void SetBgColor(agh::COLOR color){ m_backgroundColor = color; }
	virtual agh::COLOR GetBackgroundColor(){ return m_backgroundColor; }
	virtual agh::COLOR GetBackGroundColor(){ return m_backgroundColor; }
	virtual agh::COLOR GetBgColor(){ return m_backgroundColor; }
};


/*************************************************************************************************/
/*                                                                                               */
/*  CVisualControlBase                                                                           */
/*                                                                                               */
/*************************************************************************************************/

#define AGH_CONTROL_OPTION_NULL						(0)
#define AGH_CONTROL_OPTION_DRAGGING_NO_OVER_PARENT	(1)

//	偳偙偵懙偊傞偐
#define AGH_CONTROL_ALIGN_LEFT			(0x00)
#define AGH_CONTROL_ALIGN_RIGHT			(0x01)
#define AGH_CONTROL_ALIGN_CENTER		(0x02)
#define AGH_CONTROL_ALIGN_TOP			(0x10)
#define AGH_CONTROL_ALIGN_BOTTOM		(0x11)
#define AGH_CONTROL_ALIGN_VCENTER		(0x12)
#define _AGH_CONTROL_ALIGN_HFILTER(a)	((a)&0x0f)
#define _AGH_CONTROL_ALIGN_VFILTER(a)	((a)&0xf0)

//	僸僢僩僥僗僩偺testMode
#define AGH_HITTEST_MODE_DEFAULT		(-1)
#define AGH_HITTEST_MODE_RECT			(1)		//	扨弮側嬮宍寁嶼乮夞揮偼峫椂偟側偄乯
#define AGH_HITTEST_MODE_SIMPLE_RECT	(AGH_HITTEST_MODE_RECT)
#define AGH_HITTEST_MODE_RECT2			(2)		//	夞揮傪峫椂偟偨嬮宍寁嶼
#define AGH_HITTEST_MODE_RECT_EX		(AGH_HITTEST_MODE_RECT2)
#define AGH_HITTEST_MODE_ANGLE_RECT		(AGH_HITTEST_MODE_RECT2)
#define AGH_HITTEST_MODE_ANGLE_N_RECT	(AGH_HITTEST_MODE_RECT2)
#define AGH_HITTEST_MODE_ANGLE_AND_RECT	(AGH_HITTEST_MODE_RECT2)

#define AGH_HITTEST_MODE_POINT			(10)	//	揰摉偨傝敾掕  /  val1:拞怱偐傜偺嫍棧X  /  val2:拞怱偐傜偺嫍棧Y
#define AGH_HITTEST_MODE_CENTER			(AGH_HITTEST_MODE_POINT)
//#define AGH_HITTEST_MODE_LINE			(20)	//	慄摉偨傝敾掕丒丒丒側傫偰梫傜側偄婥偑偡傞偺偱偲傝偁偊偢幚憰偟側偄
//#define AGH_HITTEST_MODE_TRIANGLE		(30)	//	嶰妏宍摉偨傝敾掕丒丒丒傕梋傝昁梫惈偑晄柧側偺偱偲傝偁偊偢曐棷
#define AGH_HITTEST_MODE_SQUARE			(40)	//	惓曽宍摉偨傝敾掕  /  val1:堦曈偺挿偝亐2乮偮傑傝拞怱揰偐傜曈傑偱偺嵟抁嫍棧乯
#define AGH_HITTEST_MODE_SQUARE_EX		(41)	//	AGH_HITTEST_MODE_SQUARE 偵壛偊偰妏搙寁嶼傪峫椂丅val1偵壛偊偰val2:夞揮妏搙乮扨埵亖搙乯
#define AGH_HITTEST_MODE_RECTANGLE		(42)	//	挿曽宍摉偨傝敾掕  /  val1:墶曈偺挿偝亐2  /  val2:廲曈偺挿偝亐2
#define AGH_HITTEST_MODE_RECTANGLE_EX	(43)	//	AGH_HITTEST_MODE_RECTANGLE 偵壛偊偰妏搙寁嶼傪峫椂丅val1偵壛偊偰val2:夞揮妏搙乮扨埵亖搙乯
#define AGH_HITTEST_MODE_CIRCLE			(90)	//	墌摉偨傝敾掕  /  val1:敿宎

#define AGH_HITTEST_MODE_BITMAP			(200)	//	價僢僩儅僢僾僺僋僙儖枅偵摉偨傝敾掕傪寁嶼偡傞丅乮兛抣偑0埲奜側傜偽Hit乯
#define AGH_HITTEST_MODE_PIXEL			(AGH_HITTEST_MODE_BITMAP)
#define AGH_HITTEST_MODE_BITMAP_X2		(AGH_HITTEST_MODE_BITMAP+1)	//	攞妏僺僋僙儖寁嶼丅幚憰偵傛偭偰偼崅懍偵側傞応崌傕偁傞乧偐傕偟傟側偄
#define AGH_HITTEST_MODE_BITMAP_X4		(AGH_HITTEST_MODE_BITMAP+2)	//	4攞妏僺僋僙儖寁嶼丅幚憰偵傛偭偰偼崅懍偵側傞応崌傕偁傞乧偐傕偟傟側偄
#define AGH_HITTEST_MODE_BITMAP_X8		(AGH_HITTEST_MODE_BITMAP+3)	//	8攞妏僺僋僙儖寁嶼丅幚憰偵傛偭偰偼崅懍偵側傞応崌傕偁傞乧偐傕偟傟側偄
#define AGH_HITTEST_MODE_BITMAP_X16		(AGH_HITTEST_MODE_BITMAP+4)	//	16攞妏僺僋僙儖寁嶼丅幚憰偵傛偭偰偼崅懍偵側傞応崌傕偁傞乧偐傕偟傟側偄
#define AGH_HITTEST_MODE_BITMAP_X32		(AGH_HITTEST_MODE_BITMAP+5)	//	32攞妏僺僋僙儖寁嶼丅幚憰偵傛偭偰偼崅懍偵側傞応崌傕偁傞乧偐傕偟傟側偄
#define AGH_HITTEST_MODE_BITMAP_X64		(AGH_HITTEST_MODE_BITMAP+6)	//	64攞妏僺僋僙儖寁嶼丅幚憰偵傛偭偰偼崅懍偵側傞応崌傕偁傞乧偐傕偟傟側偄


//	昞帵宯僐儞僩儘乕儖婎掙僋儔僗
#ifndef USE_RECT_CTRL
class CVisualControlBase : public agh::CControlBase, public agh::CMouseEventBase, public agh::COtherVisualEventBase
#else
class CVisualControlBase : public agh::CRectControl, public agh::CMouseEventBase, public agh::COtherVisualEventBase
#endif
{
public:
	typedef float ht_val_t;
protected:
	//	懏惈孮 (protected member variable)
#ifndef USE_RECT_CTRL
	_AGH_RECT m_rect;			//	偙偺僆僽僕僃僋僩偺嬮宍 : This Object Client Rect
#endif
	agh::COLOR m_color;			//	怓
	//float m_fCenterX;			//	拞怱亖0.5f丅僨僼僅儖僩抣偼0.5f丅儅僀僫僗偲偐1.0f埲忋巜掕偡傞偲丄(師峴傊懕偔)
	//float m_fCenterY;			//	廳怱偑夋憸偺斖埻奜偲尵偆偙偲偵側傝傑偡偹
	/*	偄傗偄傗丒丒丒Image偺曽偵偁傞傫偩偭偰丒丒丒乮偮偄傗偭偪傖偆
	float m_fAngle;				//	夞揮妏搙丅0乣360偺搙悢 : Rotation Angle
	float m_fScaleX;			//	弅広丅1.0f偱尦偺僒僀僘乮僨僼僅儖僩乯
	float m_fScaleY;			//	弅広丅1.0f偱尦偺僒僀僘乮僨僼僅儖僩乯
	*/
	bool m_bCentering;

	//	僷儔儊乕僞宯
	bool m_bDragMovable;		//	僪儔僢僌偵傛傞堏摦偑壜擻偐
	bool m_bDragNoOverParentRect;//	僪儔僢僌偵傛偭偰恊偺嬮宍傪僆乕僶乕偟側偄傛偆偵偡傞偐
	//_DWORD m_dwOptions;		//	僆僽僔儑儞孮

	//	僷儔儊乕僞娭楢儊僜僢僪
	bool IsNoOverParentRect(){ return m_bDragNoOverParentRect; }

	//	僨僼僅儖僩偺僸僢僩僥僗僩
	bool _HitTest_AghDefault(const AGH_POINT& point, int testMode, ht_val_t val1=0, ht_val_t val2=0, ht_val_t val3=0);
	//bool OnHitTestSIMPLE_RECT(AGH_POINT point);
	/*virtual bool OnHitTestSimpleRect(AGH_POINT point);
	virtual bool OnHitTestAngleRect(AGH_POINT point);
	virtual bool OnHitTestPoint(AGH_POINT point);
	virtual bool OnHitTestSquare(AGH_POINT point);
	virtual bool OnHitTestSquareEx(AGH_POINT point);
	virtual bool OnHitTestRectangle(AGH_POINT point);
	virtual bool OnHitTestRectangleEx(AGH_POINT point);
	virtual bool OnHitTestCircle(AGH_POINT point);*/
	bool _HitTest_AghDefault_SIMPLE_RECT(const AGH_POINT &point);
	bool _HitTest_AghDefault_ANGLE_RECT(const AGH_POINT &point);
	bool _HitTest_AghDefault_POINT(const AGH_POINT &point, ht_val_t val1=0, ht_val_t val2=0);
	bool _HitTest_AghDefault_SQUARE(const AGH_POINT &point, ht_val_t val1=0);
	bool _HitTest_AghDefault_SQUARE_EX(const AGH_POINT &point, ht_val_t val1=0, ht_val_t val2=0);
	bool _HitTest_AghDefault_RECTANGLE(const AGH_POINT &point, ht_val_t val1=0);
	bool _HitTest_AghDefault_RECTANGLE_EX(const AGH_POINT &point, ht_val_t val1=0, ht_val_t val2=0);
	bool _HitTest_AghDefault_CIRCLE(const AGH_POINT &point, ht_val_t val1=0);

private:
	//	僪儔僢僌拞偵娭楢偡傞曄悢
	bool m_bOnDragging;			//	僪儔僢僌拞偐 : is Now Dragging
	int m_nMouseDownX;			//	儅僂僗Down偟偨埵抲Y : Mouse Downed Position X
	int m_nMouseDownY;			//	儅僂僗Down偟偨埵抲Y : Mouse Downed Position Y
	_AGH_RECT m_dragOldRect;	//	僪儔僢僌慜偺嬮宍乮埵抲忣曬乯: Drag Prev Rect (Position Information)

	void SetVisualControlFlg(){ SetValInt(AGH_VALKEY_FOUNDA_CTRL, AGH_FOUNDA_CTRL_VISUAL); }

_AGH_EVENT_ACCESS_MODIFIER:
	//	僆乕僶乕儔僀僪壜擻 : Overridable Methods
	virtual void OnDraw(){}
	//OnMove() 偲偐昁梫偁傞偐傕

	//////////////////////////////////////////////////////////

_AGH_EVENT_ACCESS_MODIFIER:
	//	Drag Movable
	//virtual void _OnLButtonDown(int x, int y){
	virtual void OnLButtonDown(int x, int y){
		if (m_bDragMovable){
			m_bOnDragging = true;
			m_dragOldRect = m_rect;
		}
		m_nMouseDownX = x;
		m_nMouseDownY = y;
	}
	virtual void OnLButtonUp(int x, int y){
		if (m_bDragMovable){
			m_bOnDragging = false;
		}
	}
	virtual void OnLButtonUpOuter(int x, int y){
		if (m_bDragMovable){
			m_bOnDragging = false;
		}
	}
	virtual void OnMouseMove(int nPosX, int nPosY, int nMoveX, int nMoveY){
		if (m_bDragMovable && m_bOnDragging){
			/*m_rect.left += nMoveX;
			m_rect.top += nMoveY;
			m_rect.right += nMoveX;
			m_rect.bottom += nMoveY;*/
			m_rect.left = m_dragOldRect.left + nPosX - m_nMouseDownX;
			m_rect.top = m_dragOldRect.top + nPosY - m_nMouseDownY;
			m_rect.right = m_dragOldRect.right + nPosX - m_nMouseDownX;
			m_rect.bottom = m_dragOldRect.bottom + nPosY - m_nMouseDownY;
		}
	}
	virtual void OnMouseMoveOuter(int nPosX, int nPosY, int nMoveX, int nMoveY){
		OnMouseMove(nPosX,nPosY,nMoveX,nMoveY);
	}
	//	Mouse Event Interrupt
	//	(ret = true: Should call Control event Method / false: Should not call Control event Method)
	//	(暅婣抣 = true: 僐儞僩儘乕儖偺僀儀儞僩儊僜僢僪傪屇傇傋偒 / false: 屇偽側偄傋偒)
	virtual bool OnMouseEventInterrupt(agh::CControlBase* pControl, int nPosX, int nPosY, int nMoveX, int nMoveY){return true;}

public:
	//	岞奐懏惈 (public member variable)

public:
	//	僐儞僗僩儔僋僞
#ifndef USE_RECT_CTRL
	CVisualControlBase() : agh::CControlBase(AGH_CONTROL_TYPEFLG_VISUAL) {
#else
	CVisualControlBase() : agh::CRectControl(AGH_CONTROL_TYPEFLG_VISUAL) {
#endif
		//AghZeroMemory(&m_rect, sizeof(m_rect));
		m_bDragMovable = false;
		m_bOnDragging = false;
		m_bCentering = false;
		m_color = AGHCOLOR_FULLWHITE;

		SetVisualControlFlg();

		//m_fCenterX = 0.5f;	//	2009/03/31 偙傟偼暅妶偠傖乕
		//m_fCenterY = 0.5f;	//	2009/03/31 偙傟偼暅妶偠傖乕
		/*//	2009/03/25
		m_fAngle = 0.0f;
		m_fScaleX = 1.0f;
		m_fScaleY = 1.0f;*/
	}
	virtual ~CVisualControlBase(){}	//	僨僗僩儔僋僞偪傖傫偲屇偽傟傞偨傔偺懳嶔

	virtual void Draw(){
		//	2009/10/03  巕嫙偺Draw()傕屇傃弌偡懳墳

		//	傑偀丄巕嫙偑愭偐側偀丅
		for(vcitr it=vcbegin(); it != vcend(); it++)
			it->Draw();

		OnDraw();
	}
	virtual void DoDraw(){Draw();}

	/////////////////////////////////////////////////////////////////

#ifndef USE_RECT_CTRL
	//	埵抲娭楢僾儘僷僥傿儊僜僢僪
	virtual void SetPos(int x, int y){
		m_rect.left = x;
		m_rect.top = y;
	}
	virtual int GetPosX(){
		return m_rect.left;
	}
	virtual int GetPosY(){
		return m_rect.top;
	}
	virtual AGHVECTOR2 GetPos(){
		return AGHVECTOR2(m_rect.left, m_rect.top);
	}

	virtual void Move(int x, int y){
		m_rect.left += x;
		m_rect.top += y;
		m_rect.right += x;
		m_rect.bottom += y;
	}

	/*virtual void SetPos(int left, int top, int right, int bottom){
		m_rect.left = left;
		m_rect.top = top;
		m_rect.right = right;
		m_rect.bottom = bottom;
	}*/
	virtual void SetRect(int left, int top, int right, int bottom){
		m_rect.left = left;
		m_rect.top = top;
		m_rect.right = right;
		m_rect.bottom = bottom;
	}
	virtual void SetRect(_AGH_RECT &rect){
		m_rect = rect;
	}
	virtual _AGH_RECT& GetRect(){ return m_rect; }

	virtual int GetWidth(){ return GetRect().right - GetRect().left; }
	virtual int GetHeight(){ return GetRect().bottom - GetRect().top; }
#endif/* USE_RECT_CTRL */


	//	僸僢僩僥僗僩
	virtual bool HitTest(const AGH_POINT& point, int testMode, ht_val_t val1=0, ht_val_t val2=0, ht_val_t val3=0){
		return _HitTest_AghDefault(point, testMode == AGH_HITTEST_MODE_DEFAULT ? AGH_HITTEST_MODE_RECT : testMode, val1, val2, val3); }
	/*{ return false; }*/

	virtual agh::CVisualControlBase* HitTestRecursive(const AGH_POINT& point, int testMode=AGH_HITTEST_MODE_DEFAULT, ht_val_t val1=0, ht_val_t val2=0, ht_val_t val3=0)
	{
		if ( HitTest(point, testMode, val1, val2, val3) == true )
			return this;
		else
		{
			for(vcitr it=vcbegin(); it != vcend(); it++)
			{
				agh::CVisualControlBase* pChildHitTest = it->HitTestRecursive(point, testMode, val1, val2, val3);
				if ( pChildHitTest != NULL )
					return pChildHitTest;
			}
			return NULL;
		}
	}
	virtual agh::CVisualControlBase* HitTestChildAll(const AGH_POINT& point, int testMode=AGH_HITTEST_MODE_DEFAULT, ht_val_t val1=0, ht_val_t val2=0, ht_val_t val3=0){
		return HitTestRecursive(point, testMode, val1, val2, val3); }
	virtual agh::CVisualControlBase* CtrlHitTest(const AGH_POINT& point, int testMode=AGH_HITTEST_MODE_DEFAULT, ht_val_t val1=0, ht_val_t val2=0, ht_val_t val3=0){
		return HitTestRecursive(point, testMode, val1, val2, val3); }
	virtual agh::CVisualControlBase* GetCurPosCtrl(const AGH_POINT& curPos, int testMode=AGH_HITTEST_MODE_DEFAULT, ht_val_t val1=0, ht_val_t val2=0, ht_val_t val3=0){
		return HitTestRecursive(curPos, testMode, val1, val2, val3); }

	//	怓娭學
	virtual void SetColor(agh::COLOR color){ m_color = color; }
	virtual void SetARGB(AGH_BYTE a, AGH_BYTE r, AGH_BYTE g, AGH_BYTE b){ m_color = AGHCOLOR_ARGB(a,r,g,b); }
	virtual void SetRGB(AGH_BYTE r, AGH_BYTE g, AGH_BYTE b){ m_color = AGHCOLOR_RGB(r,g,b); }
	virtual void SetXRGB(AGH_BYTE r, AGH_BYTE g, AGH_BYTE b){ m_color = AGHCOLOR_XRGB(r,g,b); }
	virtual void SetAlpha(AGH_BYTE a){ m_color = AGHCOLOR_CHANGEA(m_color,a); }
	/*virtual void SetColorFilter(AGH_BYTE r, AGH_BYTE g, AGH_BYTE b);
	virtual void SetColorFilter(AGH_BYTE a, AGH_BYTE r, AGH_BYTE g, AGH_BYTE b);
	virtual void SetFilter(AGH_BYTE r, AGH_BYTE g, AGH_BYTE b);
	virtual void SetFilter(AGH_BYTE a, AGH_BYTE r, AGH_BYTE g, AGH_BYTE b);
	virtual void SetFilter(AGH_COLOR argb);
	virtual void SetArgbFilter(AGH_COLOR argb);*/
	virtual agh::COLOR GetColor(){ return m_color; }
	virtual agh::COLOR GetAlpha(){ return AGHCOLOR_GETA(m_color); }

	//	婑偣傞 (RECT曄峏) - 枹幚憰
	/*virtual void Align(int align){ m_nAlign = align; }
	virtual void NoAlign(){ Align( _AGH_CONTROL_ALIGN_VFILTER(m_nAlign) + AGH_CONTROL_ALIGN_LEFT ); }
	virtual void AlignNon(){ Align( _AGH_CONTROL_ALIGN_VFILTER(m_nAlign) + AGH_CONTROL_ALIGN_LEFT ); }
	virtual void AlignLeft(){ Align( _AGH_CONTROL_ALIGN_VFILTER(m_nAlign) + AGH_CONTROL_ALIGN_LEFT ); }
	virtual void AlignRight(){ Align( _AGH_CONTROL_ALIGN_VFILTER(m_nAlign) + AGH_CONTROL_ALIGN_RIGHT); }
	virtual void AlignCenter(){ Align( _AGH_CONTROL_ALIGN_VFILTER(m_nAlign) + AGH_CONTROL_ALIGN_CENTER); }
	virtual void AlignTop(){ Align( _AGH_CONTROL_ALIGN_HFILTER(m_nAlign) + AGH_CONTROL_ALIGN_TOP); }
	virtual void AlignBottom(){ Align( _AGH_CONTROL_ALIGN_HFILTER(m_nAlign) + AGH_CONTROL_ALIGN_BOTTOM); }
	virtual void AlignVCenter(){ Align( _AGH_CONTROL_ALIGN_HFILTER(m_nAlign) + AGH_CONTROL_ALIGN_VCENTER); }*/

	//	僆僾僔儑儞愝掕宯
	virtual void EnableDrag(bool bFlg=true){ m_bDragMovable = bFlg; }
	virtual void EnableDragMovable(bool bFlg=true){ m_bDragMovable = bFlg; }
	virtual void DisableDrag(){ m_bDragMovable = false; }
	virtual void DisableDragMovable(){ m_bDragMovable = false; }
	virtual void EnableDragNoOverParentRect(bool bFlg=true){ m_bDragNoOverParentRect = bFlg; }
	virtual void DisableDragNoOverParentRect(){ m_bDragNoOverParentRect = false; }
	virtual void EnableCentering(){ m_bCentering = true; }
	virtual void DisableCentering(){ m_bCentering = false; }

	virtual bool IsCentering(){ return m_bCentering; }

protected:
#ifdef _CControlBase_CHILD_ARRAY_TYPE_VECTOR
	agh::CVisualControlBase* GetVCtrlPtr(int i){ return (agh::CVisualControlBase*)m_ctrlPtrAry[i]; }
#endif
};

/////////////////////////////////////////////////////////////////////////////////////////////////////////////

inline bool CVisualControlBase::_HitTest_AghDefault(const AGH_POINT& point, int testMode, ht_val_t val1, ht_val_t val2, ht_val_t val3)
{
	switch(testMode){
		case AGH_HITTEST_MODE_SIMPLE_RECT:
			return _HitTest_AghDefault_SIMPLE_RECT(point);

		case AGH_HITTEST_MODE_ANGLE_RECT:
			return _HitTest_AghDefault_ANGLE_RECT(point);

		case AGH_HITTEST_MODE_POINT:
			return _HitTest_AghDefault_POINT(point, val1, val2);

		case AGH_HITTEST_MODE_SQUARE:
			return _HitTest_AghDefault_SQUARE(point, val1);

		case AGH_HITTEST_MODE_SQUARE_EX:
			return _HitTest_AghDefault_SQUARE_EX(point, val1, val2);

		case AGH_HITTEST_MODE_RECTANGLE:
			return _HitTest_AghDefault_RECTANGLE(point, val1);

		case AGH_HITTEST_MODE_RECTANGLE_EX:
			return _HitTest_AghDefault_RECTANGLE_EX(point, val1, val2);

		case AGH_HITTEST_MODE_CIRCLE:
			return _HitTest_AghDefault_CIRCLE(point, val1);
	}

	return false;
}

//	AGH_HITTEST_MODE_SIMPLE_RECT
inline bool CVisualControlBase::_HitTest_AghDefault_SIMPLE_RECT(const AGH_POINT &point)
{
	//AGH_RECT rect = this->GetRect();
	AGH_RECT rect = this->GetAbsoluteRect();
	if ( rect.left <= point.x  &&  point.x <= rect.right  &&
		 rect.top  <= point.y  &&  point.y <= rect.bottom )
		return true;
	else
		return false;
}

//	AGH_HITTEST_MODE_ANGLE_RECT
inline bool CVisualControlBase::_HitTest_AghDefault_ANGLE_RECT(const AGH_POINT &point)
{
	return false;
}

//	AGH_HITTEST_MODE_POINT
inline bool CVisualControlBase::_HitTest_AghDefault_POINT(const AGH_POINT &point, ht_val_t val1, ht_val_t val2)
{
	AGH_POINT target = this->GetRect().GetCenter();
	target.x += (agh::pos_t)val1;
	target.y += (agh::pos_t)val2;

	if ( target.x == point.x && target.y == point.y )
		return true;
	else
		return false;
}

//	AGH_HITTEST_MODE_SQUARE
inline bool CVisualControlBase::_HitTest_AghDefault_SQUARE(const AGH_POINT &point, ht_val_t val1)
{
	return false;
}

//	SQUARE_EX
inline bool CVisualControlBase::_HitTest_AghDefault_SQUARE_EX(const AGH_POINT &point, ht_val_t val1, ht_val_t val2)
{
	return false;
}

//	RECTANGLE
inline bool CVisualControlBase::_HitTest_AghDefault_RECTANGLE(const AGH_POINT &point, ht_val_t val1)
{
	return false;
}

//	RECTANGLE_EX
inline bool CVisualControlBase::_HitTest_AghDefault_RECTANGLE_EX(const AGH_POINT &point, ht_val_t val1, ht_val_t val2)
{
	return false;
}

//	CIRCLE
inline bool CVisualControlBase::_HitTest_AghDefault_CIRCLE(const AGH_POINT &point, ht_val_t val1)
{
	AGH_POINT center = this->GetRect().GetCenter();

	if ( center.x == point.x && center.y == point.y )
		return true;
	else
		return false;
}

/////////////////////////////////////////////////////////////////////////////////////////////////////////////

typedef CVisualControlBase C2dVisualControlBase, C2DVisualControlBase, CVisibleControlBase;
//typedef CControlBase CVisibleControlBase;
//typedef CControlBase CVisualControlBase;





/*仩仭仩仭仩仭仩仭仩仭仩仭仩仭仩仭仩仭仩仭仩仭仩仭仩仭仩仭仩仭仩仭仩仭仩仭仩仭仩仭仩仭仩仭*/

/*仩仭仩仭仩仭仩仭仩仭仩仭仩仭仩仭仩仭仩仭仩仭仩仭仩仭仩仭仩仭仩仭仩仭仩仭仩仭仩仭仩仭仩仭*/

/*仩仭仩仭仩仭仩仭仩仭仩仭仩仭仩仭仩仭仩仭仩仭仩仭仩仭仩仭仩仭仩仭仩仭仩仭仩仭仩仭仩仭仩仭*/




/*************************************************************************************************/
/*                                                                                               */
/*  C3DVisualControlBase                                                                         */
/*                                                                                               */
/*************************************************************************************************/

#define AGH_CONTROL_OPTION_NULL						(0)
#define AGH_CONTROL_OPTION_DRAGGING_NO_OVER_PARENT	(1)

//	昞帵宯僐儞僩儘乕儖婎掙僋儔僗
class C3dVisualControlBase : public agh::CVisualControlBase {
protected:
	agh::pos3d_t m_x;
	agh::pos3d_t m_y;
	agh::pos3d_t m_z;

	AGHVECTOR3 m_center;	//	拞怱亖0.5f丅僨僼僅儖僩抣偼0.5f丅儅僀僫僗偲偐1.0f埲忋巜掕偡傞偲丄廳怱偑僆僽僕僃僋僩偺斖埻奜偲尵偆偙偲偵側傝傑偡偹
	AGHVECTOR3 m_rotate;	//	夞揮妏搙丅0乣360偺搙悢 : Rotation Angle
	AGHVECTOR3 m_scale;		//	弅広丅1.0f偱尦偺僒僀僘乮僨僼僅儖僩乯

public:
	C3dVisualControlBase(){
		m_x = 0.0f;
		m_y = 0.0f;
		m_z = 0.0f;
		m_center.x = m_center.y = m_center.z = 0.5f;
		m_scale.x = m_scale.y = m_scale.z = 1.0f;
	}

	//	埵抲娭楢僾儘僷僥傿儊僜僢僪
	virtual void SetPos(agh::pos3d_t x, agh::pos3d_t y, agh::pos3d_t z){
		m_x = x;
		m_y = y;
		m_z = y;
	}
	virtual void Move(pos3d_t x, agh::pos3d_t y, agh::pos3d_t z){
		m_x += x;
		m_y += y;
		m_z += y;
	}

	//	埵抲娭楢僾儘僷僥傿儊僜僢僪
	virtual void SetAngle(pos3d_t x, agh::pos3d_t y, agh::pos3d_t z){
		m_rotate.x = x;
		m_rotate.y = y;
		m_rotate.z = y;
	}
	virtual void Rotate(pos3d_t x, agh::pos3d_t y, agh::pos3d_t z){
		m_rotate.x += x;
		m_rotate.y += y;
		m_rotate.z += y;
	}
	
	//	3D偺僸僢僩僥僗僩
	virtual bool HitTest3D(pos3d_t point, int testMode){ return false; }
};

typedef C3dVisualControlBase C3DVisualControlBase;

inline bool IsVisualCtrl(agh::CControlBase *pCtrl){
	return pCtrl->GetValInt(AGH_VALKEY_FOUNDA_CTRL) == AGH_FOUNDA_CTRL_VISUAL ? true : false;
}

#endif//__SFJP_MYU__AGH_VisualControlBase_H__
