www.pudn.com > CHA03.rar   To Read all the content


[file head]:
// DrawTool.cpp: implementation of the CDrawTool class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "DrawCli.h"
#include "DrawTool.h"

#include "drawdoc.h"
#include "drawvw.h"
#include "drawobj.h"


#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// CDrawTool implementation

CPtrList CDrawTool::c_tools;

static CSelectTool selectTool;
static CRectTool lineTool(line);
static CRectTool rectTool(rect);
static CRectTool roundRectTool(roundRect);
static CRectTool ellipseTool(ellipse);
static CRectTool circleTool(circle);
//static CPolyTool polyTool;

CPoint CDrawTool::c_down;
UINT CDrawTool::c_nDownFlags;
... ...

[file tail]:
... ...
:ellipse;
break;

case line:
pObj->m_nShape = CDrawRect::line;
break;
case circle:
pObj->m_nShape = CDrawRect::circle;
break;
}
pView->GetDocument()->Add(pObj);
pView->Select(pObj);

selectMode = size;
nDragHandle = 1;
lastPoint = local;

}

void CRectTool::OnLButtonDblClk(CDrawView* pView, UINT nFlags, const CPoint&amt; point)
{
CDrawTool::OnLButtonDblClk(pView, nFlags, point);
}

void CRectTool::OnLButtonUp(CDrawView* pView, UINT nFlags, const CPoint&amt; point)
{
if (point == c_down)
{
// Don't create empty objects...
CDrawObj *pObj = pView->m_selection.GetTail();
pView->GetDocument()->Remove(pObj);
pObj->Remove();
selectTool.OnLButtonDown(pView, nFlags, point); // try a select!
}

selectTool.OnLButtonUp(pView, nFlags, point);
}

void CRectTool::OnMouseMove(CDrawView* pView, UINT nFlags, const CPoint&amt; point)
{
SetCursor(AfxGetApp()->LoadStandardCursor(IDC_CROSS));
selectTool.OnMouseMove(pView, nFlags, point);
}