Core.cpp
资源名称:44757463.rar [点击查看]
上传用户:lj3531212
上传日期:2007-06-18
资源大小:346k
文件大小:3k
源码类别:
绘图程序
开发平台:
Visual C++
- // Core.cpp: implementation of the CCore class.
- //
- //////////////////////////////////////////////////////////////////////
- #include "stdafx.h"
- #include "graphsoft.h"
- #include "Core.h"
- #include "CoreLog.h"
- #ifdef _DEBUG
- #undef THIS_FILE
- static char THIS_FILE[]=__FILE__;
- #define new DEBUG_NEW
- #endif
- //////////////////////////////////////////////////////////////////////
- // Construction/Destruction
- //////////////////////////////////////////////////////////////////////
- CCore::CCore(CGraphSoftDoc* pDoc,CGraphSoftView* pView)
- {
- m_pDoc=pDoc;
- m_pView=pView;
- m_bEnableUndo=FALSE;
- m_bSendMessageLog=FALSE;
- m_pLog=new CCoreLog();
- }
- CCore::~CCore()
- {
- delete m_pLog;
- }
- ////////////////////////////////////////////////////////////////////
- void CCore::OnEditUndo()
- {
- CWaitCursor wait;
- m_pLog->OnEditUndo(this);
- }
- void CCore::OnEditRedo()
- {
- CWaitCursor wait;
- m_pLog->OnEditRedo(this);
- }
- BOOL CCore::IsAbleToUndo()
- {
- // return (m_bEnableUndo && m_pLog->IsAbleToUndo() && !m_bPowerStageMode2);
- return (m_pLog->IsAbleToUndo());
- }
- BOOL CCore::IsAbleToRedo()
- {
- // return (m_bEnableUndo && m_pLog->IsAbleToRedo() && !m_bPowerStageMode2);
- return (m_pLog->IsAbleToRedo());
- }
- void CCore::EnableUndo(BOOL bFlag)
- {
- m_bEnableUndo = bFlag;
- }
- BOOL CCore::WriteLogString(CString text)
- {
- m_pLog->WriteLogString(text);
- return true;
- }
- void CCore::AddUndoItem(CUND_Base* pUndo)
- {
- m_pLog->AddUndoItem(pUndo);
- }
- void CCore::DelLastUndoItem()
- {
- m_pLog->DelLastUndoItem();
- }
- //////////////////////////////////////////////////////////////////////
- // MODULE :DrawGraph
- // ABSTRACT :绘画/清空图形
- // FUNCTION :一般在撤消/恢复中用到
- // NOTE :
- // RETURN :
- // ARGUMENTS:
- // I/O TYPE NAME EXPLANATION
- // I BOOL bFlag TRUE-Draw FALSE-Clear
- // CREATE : FNST)handwolf 2004-4-23
- // UPDATE :
- // : Modify reason
- //////////////////////////////////////////////////////////////////////
- void CCore::DrawGraph(CShape* pShape,BOOL bFlag)
- {
- CDC* pDC=CDC::FromHandle(GetDC(m_pView->GetSafeHwnd()));
- m_pView->OnPrepareDC(pDC);
- if(!bFlag){
- pShape->DrawCutToRect(pDC,RGB(255,255,255),RGB(255,255,255),m_pView->m_rectTarget,m_pView->m_rectMaxWindow);
- }else{
- pShape->DrawCutToRect(pDC,m_pView->m_rectTarget,m_pView->m_rectMaxWindow);
- }
- }
- CShape* CCore::GetShapeByID(unsigned long nID)
- {
- CShape* pShape=NULL;
- POSITION pos;
- pos=m_pDoc->m_shapeList.GetHeadPosition();
- while (pos!=NULL) {
- pShape=m_pDoc->m_shapeList.GetNext(pos);
- if(pShape->GetID()==nID){
- break;
- }
- }
- return pShape;
- }
- void CCore::ReMoveShape(unsigned long nID)
- {
- CShape* pShape=NULL;
- POSITION pos,posPre;
- pos=m_pDoc->m_shapeList.GetHeadPosition();
- while (pos!=NULL) {
- posPre=pos;
- pShape=m_pDoc->m_shapeList.GetNext(pos);
- if(pShape->GetID()==nID){
- m_pDoc->m_shapeList.RemoveAt(posPre);
- break;
- }
- }
- }