#if !defined(AFX_BOX_H__D6DF5F90_7675_4BD4_A764_EC8DBBD8DC46__INCLUDED_)
#define AFX_BOX_H__D6DF5F90_7675_4BD4_A764_EC8DBBD8DC46__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// Box.h : header file
//
/
// CBox command target
class CBox : public CCmdTarget
{
DECLARE_SERIAL(CBox)
CBox(); // protected constructor used by dynamic creation
// Attributes
public:
// Operations
public:
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CBox)
public:
virtual void OnFinalRelease();
virtual void Serialize(CArchive& ar);
//}}AFX_VIRTUAL
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(CBox)
// NOTE - the ClassWizard will add and remove member functions here.
//}}AFX_MSG
public:
virtual ~CBox();
CBox(CRect rt) : m_rtBox( rt) {}
private:
BOOL m_bIsSeleced;
CRect m_rtBox;
public:
virtual CRect GetBox() const{return m_rtBox ;}
virtual void SetBox(CRect & rtBox) {m_rtBox = rtBox ;}
virtual BOOL IsSeleced() const {return m_bIsSeleced ;}
virtual BOOL SelectTest(const CPoint & ptHit) const
{
CRect rtBox(m_rtBox);
//调整坐标
rtBox.NormalizeRect();
return rtBox.PtInRect(ptHit);
}
// virtual BOOL SelectTest(const CRect & rtHit) const
// {
//
// CRect rtBox(m_rtBox);
// //调整坐标
// rtBox.NormalizeRect();
//
// CRect rtTest(rtHit);
// //调整坐标
// rtTest.NormalizeRect();
//
//
// CRect rtRet(0,0,0,0);
//
// //IntersectRect此函数使CRect等于两个现有矩形的交集。交集是同时包含在两个现有矩形中的最大矩形。
//
// return rtRet.IntersectRect(&rtBox,&rtTest);
//
// }
virtual void SetSeleced(){ m_bIsSeleced = TRUE ;}
virtual void UnSeleced() { m_bIsSeleced = FALSE ;}
virtual void OnDraw(CDC* pDC);
//声明为内联函数要放在类的外面
friend bool operator == (const CBox & , const CBox &) ;
protected:
// //调整坐标
// void ReviseRect(int iMapMode)
// {
// if(MM_TEXT == iMapMode)
// {
// m_rtBox.bottom = - abs(m_rtBox.bottom) ;
// m_rtBox.top = - abs(m_rtBox.top) ;
// }
// else
// {
// m_rtBox.bottom = abs(m_rtBox.bottom) ;
// m_rtBox.top = abs(m_rtBox.top) ;
// }
// }
virtual void DrawSelecedBox(CDC* pDC) { }
DECLARE_MESSAGE_MAP()
// Generated OLE dispatch map functions
//{{AFX_DISPATCH(CBox)
// NOTE - the ClassWizard will add and remove member functions here.
//}}AFX_DISPATCH
DECLARE_DISPATCH_MAP()
DECLARE_INTERFACE_MAP()
};
//这个内联定义要放在类的外面
inline bool operator == (const CBox & a , const CBox & b )
{return a.m_rtBox == b.m_rtBox ;}
/
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_BOX_H__D6DF5F90_7675_4BD4_A764_EC8DBBD8DC46__INCLUDED_)