📄 drawinpdadoc.cpp
字号:
// DrawInPDADoc.cpp : implementation of the CDrawInPDADoc class
//
#include "stdafx.h"
#include "DrawInPDA.h"
#include "Shape.h"
#include "DrawInPDADoc.h"
#include "Tool.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CDrawInPDADoc
IMPLEMENT_DYNCREATE(CDrawInPDADoc, CDocument)
BEGIN_MESSAGE_MAP(CDrawInPDADoc, CDocument)
//{{AFX_MSG_MAP(CDrawInPDADoc)
// NOTE - the ClassWizard will add and remove mapping macros here.
// DO NOT EDIT what you see in these blocks of generated code!
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDrawInPDADoc construction/destruction
CDrawInPDADoc::CDrawInPDADoc()
{
// TODO: add one-time construction code here
}
CDrawInPDADoc::~CDrawInPDADoc()
{
POSITION pos = m_Shapes.GetHeadPosition();//POSITION: A value used to denote the position of an
//element in a collection; used by MFC collection classes.
//Gets the position of the head element of this list.
while (pos != NULL)
delete m_Shapes.GetNext(pos);//
}
BOOL CDrawInPDADoc::OnNewDocument()
{
if (!CDocument::OnNewDocument())
return FALSE;
// TODO: add reinitialization code here
// (SDI documents will reuse this document)
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
// CDrawInPDADoc serialization
void CDrawInPDADoc::Serialize(CArchive& ar)
{
if (ar.IsStoring())
{
// TODO: add storing code here
}
else
{
// TODO: add loading code here
}
}
/////////////////////////////////////////////////////////////////////////////
// CDrawInPDADoc diagnostics
#ifdef _DEBUG
void CDrawInPDADoc::AssertValid() const
{
CDocument::AssertValid();
}
void CDrawInPDADoc::Dump(CDumpContext& dc) const
{
CDocument::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CDrawInPDADoc commands
//class CShape
void CDrawInPDADoc::Draw(CDC *pDC)
{
POSITION pos = m_Shapes.GetHeadPosition();
while (pos != NULL)
{
CShape* pShape = m_Shapes.GetNext(pos);
pShape->Draw(pDC);
}
}
void CDrawInPDADoc::ShapeAdd(CShape *pShape)
{
m_Shapes.AddTail(pShape);//Adds a new element or list of elements to the tail of this list. The list
//can be empty before the operation.
POSITION pos = m_Shapes.GetHeadPosition();
}
CShape* CDrawInPDADoc::Select(const CPoint &point)
{
CRect rect(point - CSize(2,2), CSize(4, 4));
POSITION pos = m_Shapes.GetTailPosition();
while (pos != NULL)
{
CShape* pObj = m_Shapes.GetPrev(pos);
if (pObj->Intersects(rect))
return pObj;
}
return NULL;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -