www.pudn.com > my2cadtest07261930.rar > LineTool.cpp, change:2006-07-25,size:1070b


 
#include "stdafx.h" 
#include "LineTool.h" 
#include "Line.h" 
#include "list.h" 
#include "Shape.h" 
 
extern CList<CShape *> m_list; 
 
CLineTool::CLineTool(HWND hWnd,bool partof) 
:CTool(hWnd),m_partof(partof) 
{ 
 
} 
 
CLineTool::~CLineTool() 
{ 
 
} 
 
void CLineTool::PreDraw() 
{ 
		 
	::MoveToEx(m_hdc,m_begPT.GetPoint().x,m_begPT.GetPoint().y,NULL);		//覆盖旧线 
	::LineTo(m_hdc,m_oldPT.GetPoint().x,m_oldPT.GetPoint().y); 
 
	::MoveToEx(m_hdc,m_begPT.GetPoint().x,m_begPT.GetPoint().y,NULL);		//绘制新线 
	::LineTo(m_hdc,m_endPT.GetPoint().x,m_endPT.GetPoint().y); 
 
	m_oldPT = m_endPT; 
 
} 
 
void CLineTool::Draw() 
{	 
	::MoveToEx(m_hdc,m_begPT.GetPoint().x,m_begPT.GetPoint().y,NULL);		//绘制新线 
	::LineTo(m_hdc,m_endPT.GetPoint().x,m_endPT.GetPoint().y); 
} 
 
 
void CLineTool::SaveSelf() 
{ 
  if(!m_partof) 
  { 
   CShape* pLine=new CLine(m_begPT,m_endPT); 
 
   pLine->SetLOGPEN(penattrib->GetPenStyle(false)); 
   pLine->SetLOGBRUSH(penattrib->GetBrushStyle(false)); 
    
   m_list.AddTail(pLine); 
   m_list.SetEditStatus(true); 
  } 
 
}