DrawSysDoc.cpp
资源名称:DrawSys.zip [点击查看]
上传用户:mosfetic
上传日期:2022-06-16
资源大小:4612k
文件大小:3k
源码类别:
GDI/图象编程
开发平台:
Visual C++
- // DrawSysDoc.cpp : implementation of the CDrawSysDoc class
- //
- #include "stdafx.h"
- #include "DrawSys.h"
- #include "DrawSysDoc.h"
- #include "DrawShape.h"
- #include "MainFrm.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CDrawSysDoc
- IMPLEMENT_DYNCREATE(CDrawSysDoc, CDocument)
- BEGIN_MESSAGE_MAP(CDrawSysDoc, CDocument)
- //{{AFX_MSG_MAP(CDrawSysDoc)
- // 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()
- /////////////////////////////////////////////////////////////////////////////
- // CDrawSysDoc construction/destruction
- CDrawSysDoc::CDrawSysDoc()
- {
- // TODO: add one-time construction code here
- }
- CDrawSysDoc::~CDrawSysDoc()
- {
- }
- BOOL CDrawSysDoc::OnNewDocument()
- {
- if (!CDocument::OnNewDocument())
- return FALSE;
- // TODO: add reinitialization code here
- // (SDI documents will reuse this document)
- return TRUE;
- }
- /////////////////////////////////////////////////////////////////////////////
- // CDrawSysDoc serialization
- void CDrawSysDoc::Serialize(CArchive& ar)
- {
- if (ar.IsStoring())
- {
- // TODO: add storing code here
- }
- else
- {
- // TODO: add loading code here
- }
- m_obArray.Serialize(ar);
- }
- /////////////////////////////////////////////////////////////////////////////
- // CDrawSysDoc diagnostics
- #ifdef _DEBUG
- void CDrawSysDoc::AssertValid() const
- {
- CDocument::AssertValid();
- }
- void CDrawSysDoc::Dump(CDumpContext& dc) const
- {
- CDocument::Dump(dc);
- }
- #endif //_DEBUG
- /////////////////////////////////////////////////////////////////////////////
- // CDrawSysDoc commands
- void CDrawSysDoc::AddShape(CDrawShape* pDrawShape)
- {
- if(pDrawShape)
- {
- m_obArray.Add((CObject*)pDrawShape);
- }
- }
- void CDrawSysDoc::DeleteContents()
- {
- // TODO: Add your specialized code here and/or call the base class
- while(m_obArray.GetSize() > 0)
- {
- delete m_obArray.GetAt(0);
- m_obArray.RemoveAt(0);
- }
- CDocument::DeleteContents();
- }
- BOOL CDrawSysDoc::OnOpenDocument(LPCTSTR lpszPathName)
- {
- if (!CDocument::OnOpenDocument(lpszPathName))
- return FALSE;
- // TODO: Add your specialized creation code here
- int iTotal = m_obArray.GetSize();
- CWnd* pWnd = AfxGetMainWnd();
- for(int i=0; i<iTotal; i++)
- {
- ((CMainFrame*)pWnd)->m_wndShapeTree.InsertShape((CDrawShape*)m_obArray.GetAt(i), i+1);
- }
- return TRUE;
- }