drawtool.cpp
上传用户:ywlong9188
上传日期:2022-05-31
资源大小:2656k
文件大小:25k
- #include "stdafx.h"
- #include "proj.h"
- #include "projdoc.h"
- #include "projview.h"
- #include "drawobj.h"
- #include "customDlg.h"
- #include "drawtool.h"
- /////////////////////////////////////////////////////////////////////////////
- // CDrawTool implementation
- CPtrList CDrawTool::c_tools;
- static CSelectTool selectTool;
- static CLineTool lineTool(line);
- static CRectTool rectTool(rect);
- static CEllipseTool ellipseTool(ellipse);
- static CPolyTool polyTool;
- static CTextTool textTool;
- static CBarTool barTool;
- static CAnimateTagTool animateTagTool;
- static CCursorTool cursorTool;
- static CISATool isaTool;
- static CLoopTool loopTool;
- static CCustomTool customTool;
- static CButtonTool buttonTool;
- CPoint CDrawTool::c_down;
- UINT CDrawTool::c_nDownFlags;
- CPoint CDrawTool::c_last;
- DrawShape CDrawTool::c_drawShape = selection;
- CDrawTool::CDrawTool(DrawShape drawShape)
- {
- m_drawShape = drawShape;
- c_tools.AddTail(this);
- }
- CDrawTool* CDrawTool::FindTool(DrawShape drawShape)
- {
- POSITION pos = c_tools.GetHeadPosition();
- while (pos != NULL)
- {
- CDrawTool* pTool = (CDrawTool*)c_tools.GetNext(pos);
- if (pTool->m_drawShape == drawShape)
- return pTool;
- }
- return NULL;
- }
- void CDrawTool::OnChar(CProjView* pView,UINT nFlags,UINT nChar)
- {
- }
- void CDrawTool::OnLButtonDown(CProjView* pView, UINT nFlags, const CPoint& point)
- {
- // deactivate any in-place active item on this view!
-
- pView->SetCapture();
- c_nDownFlags = nFlags;
- c_down = point;
- c_last = point;
- }
- /*void CDrawTool::OnRButtonDown(CProjView* pView, UINT nFlags, const CPoint& point)
- {
- }*/
- void CDrawTool::OnLButtonDblClk(CProjView* /*pView*/, UINT /*nFlags*/, const CPoint& /*point*/)
- {
- }
- void CDrawTool::OnLButtonUp(CProjView* /*pView*/, UINT /*nFlags*/, const CPoint& point)
- {
- ReleaseCapture();
- if (point == c_down)
- c_drawShape = selection;
- }
- void CDrawTool::OnMouseMove(CProjView* /*pView*/, UINT /*nFlags*/, const CPoint& point)
- {
- c_last = point;
- SetCursor(AfxGetApp()->LoadStandardCursor(IDC_ARROW));
- //SetCursor(AfxGetApp()->LoadStandardCursor(IDC_CROSS));
- }
- void CDrawTool::OnEditProperties(CProjView* /*pView*/)
- {
- }
- void CDrawTool::OnCancel(CProjView* pView)
- {
- c_drawShape = selection;
- }
- ////////////////////////////////////////////////////////////////////////////
- // CResizeTool
- enum SelectMode
- {
- none,
- netSelect,
- move,
- size
- };
- SelectMode selectMode = none;
- int nDragHandle;
- CPoint lastPoint;
- CSelectTool::CSelectTool()
- : CDrawTool(selection)
- {
- }
- void CSelectTool::OnLButtonDown(CProjView* pView, UINT nFlags, const CPoint& point)
- {
- CPoint local = point;
- pView->ClientToDoc(local);
- CDrawObj* pObj;
- selectMode = none;
- // Check for resizing (only allowed on single selections)
- if (pView->m_selection.GetCount() == 1)
- {
- pObj = pView->m_selection.GetHead();
- nDragHandle = pObj->HitTest(local, pView, TRUE);
- if (nDragHandle != 0 && nDragHandle != 10)//Add && nDragHandle != 10 for debug
- selectMode = size;
- }
- // See if the click was on an object, select and start move if so
- if (selectMode == none)
- {
- pObj = pView->GetDocument()->ObjectAt(local);
- if (pObj != NULL)
- {
- selectMode = move;
- if (!pView->IsSelected(pObj))
- pView->Select(pObj, (nFlags & MK_SHIFT) != 0);
- pObj->SetFlag(FALSE);
- // Ctrl+Click clones the selection...
- if ((nFlags & MK_CONTROL) != 0)
- pView->CloneSelection();
- }
- }
- // Click on background, start a net-selection
- if (selectMode == none)
- {
- if ((nFlags & MK_SHIFT) == 0)
- pView->Select(NULL);
- selectMode = netSelect;
- CClientDC dc(pView);
- CRect rect(point.x, point.y, point.x, point.y);
- rect.NormalizeRect();
- dc.DrawFocusRect(rect); //Comment this for test
- }
- lastPoint = local;
- CDrawTool::OnLButtonDown(pView, nFlags, point);
- }
- void CSelectTool::OnLButtonDblClk(CProjView* pView, UINT nFlags, const CPoint& point)
- {
- if ((nFlags & MK_SHIFT) != 0)
- {
- // Shift+DblClk deselects object...
- CPoint local = point;
- pView->ClientToDoc(local);
- CDrawObj* pObj = pView->GetDocument()->ObjectAt(local);
- if (pObj != NULL)
- pView->Deselect(pObj);
- }
- else
- {
- // "Normal" DblClk opens properties, or OLE server...
- if (pView->m_selection.GetCount() == 1)
- pView->m_selection.GetHead()->OnOpen(pView);
- }
- CDrawTool::OnLButtonDblClk(pView, nFlags, point);
- }
- void CSelectTool::OnEditProperties(CProjView* pView)
- {
- if (pView->m_selection.GetCount() == 1)
- // pView->m_selection.GetHead()->OnEditProperties( pView );
- pView->m_selection.GetHead()->OnOpen(pView);
- }
- void CSelectTool::OnLButtonUp(CProjView* pView, UINT nFlags, const CPoint& point)
- {
- if (pView->GetCapture() == pView)
- {
- if (selectMode == netSelect)
- {
- CClientDC dc(pView);
- CRect rect(c_down.x, c_down.y, c_last.x, c_last.y);
- rect.NormalizeRect();
- dc.DrawFocusRect(rect);
- pView->SelectWithinRect(rect, TRUE);
- // add these lines for a test
- /*if( pView->m_selection.GetCount()>=2)
- {
-
- POSITION pos = pView->m_selection.GetHeadPosition();
- CRect rect = (pView->m_selection.GetNext(pos))->m_position;
- while( pos!=NULL)
- {
- rect.NormalizeRect();
- CRect temp = (pView->m_selection.GetNext(pos))->m_position;
- temp.NormalizeRect();
- rect |= temp;
- }
- m_pOutRect = new CDrawOutRect(rect);
- pView->GetDocument()->Add(m_pOutRect);
-
- POSITION pos1 = pView->m_selection.GetHeadPosition();
- while( pos1 != NULL )
- m_pOutRect->m_objs.AddTail(pView->m_selection.GetNext(pos1));
- pView->Select(m_pOutRect);
- }*/
-
- // end of the test
- }
- else if (selectMode != none)
- {
- pView->GetDocument()->UpdateAllViews(pView);
- }
- }
- CDrawTool::OnLButtonUp(pView, nFlags, point);
- }
- void CSelectTool::OnMouseMove(CProjView* pView, UINT nFlags, const CPoint& point)
- {
- if (pView->GetCapture() != pView)
- {
- if (c_drawShape == selection && pView->m_selection.GetCount() == 1)
- {
- CDrawObj* pObj = pView->m_selection.GetHead();
-
- CPoint local = point;
- pView->ClientToDoc(local);
-
- int nHandle = pObj->HitTest(local, pView, TRUE);
- if (nHandle != 0)
- {
- SetCursor(pObj->GetHandleCursor(nHandle));
- return; // bypass CDrawTool
- }
- }
- if (c_drawShape == selection)
- CDrawTool::OnMouseMove(pView, nFlags, point);
- return;
- }
- if (selectMode == netSelect)
- {
- CClientDC dc(pView);
- CRect rect(c_down.x, c_down.y, c_last.x, c_last.y);
- rect.NormalizeRect();
- dc.DrawFocusRect(rect);
- rect.SetRect(c_down.x, c_down.y, point.x, point.y);
- rect.NormalizeRect();
- dc.DrawFocusRect(rect);
-
- /*pView->m_tracker.m_rect.NormalizeRect();
- if( pView->m_tracker.m_rect.PtInRect( point ))
- pView->m_bCursor = TRUE;
- else
- pView->m_bCursor = FALSE;
- */
- CDrawTool::OnMouseMove(pView, nFlags, point);
- return;
- }
- CPoint local = point;
- pView->ClientToDoc(local);
- CPoint delta = (CPoint)(local - lastPoint);
- POSITION pos = pView->m_selection.GetHeadPosition();
- while (pos != NULL)
- {
- CDrawObj* pObj = pView->m_selection.GetNext(pos);
- CRect position = pObj->m_position;
- if (selectMode == move)
- {
- position += delta;
- pObj->MoveTo(position, pView);
- }
- else if (nDragHandle != 0 && nDragHandle != 10)
- {
- pObj->MoveHandleTo(nDragHandle, local, pView);
- }
- }
- lastPoint = local;
- if (selectMode == size && c_drawShape == selection)
- {
- c_last = point;
- SetCursor(pView->m_selection.GetHead()->GetHandleCursor(nDragHandle));
- return; // bypass CDrawTool
- }
- c_last = point;
- // if (c_drawShape == selection)
- // CDrawTool::OnMouseMove(pView, nFlags, point);
- }
- ////////////////////////////////////////////////////////////////////////////
- // CRectTool
- CRectTool::CRectTool(DrawShape drawShape)
- : CDrawTool(rect)
- {
- }
- void CRectTool::OnLButtonDown(CProjView* pView, UINT nFlags, const CPoint& point)
- {
- CDrawTool::OnLButtonDown(pView, nFlags, point);
- CPoint local = point;
- pView->ClientToDoc(local);
- CDrawRect* pObj = new CDrawRect(CRect(local, CSize(0, 0)));
- pView->GetDocument()->Add(pObj);
- pView->Select(pObj);
- pObj->SetFlag();
- selectMode = size;
- nDragHandle = 1;
- lastPoint = local;
- }
- void CRectTool::OnLButtonDblClk(CProjView* pView, UINT nFlags, const CPoint& point)
- {
- CDrawTool::OnLButtonDblClk(pView, nFlags, point);
- }
- void CRectTool::OnLButtonUp(CProjView* pView, UINT nFlags, const CPoint& point)
- {
- CDrawObj *pObj = pView->m_selection.GetTail();
- pObj->SetFlag(FALSE);
- if (point == c_down)
- {
- // Don't create empty objects...
-
- pView->GetDocument()->Remove(pObj);
- pObj->Remove();
- CDrawObj::c_identify = CDrawObj::c_identify-1;
- selectTool.OnLButtonDown(pView, nFlags, point); // try a select!
- }
- selectTool.OnLButtonUp(pView, nFlags, point);
- }
- void CRectTool::OnMouseMove(CProjView* pView, UINT nFlags, const CPoint& point)
- {
- SetCursor(AfxGetApp()->LoadStandardCursor(IDC_CROSS));
- selectTool.OnMouseMove(pView, nFlags, point);
- }
- ////////////////////////////////////////////////////////////////////////////
- // CPolyTool
- CPolyTool::CPolyTool()
- : CDrawTool(poly)
- {
- m_pDrawObj = NULL;
- }
- void CPolyTool::OnLButtonDown(CProjView* pView, UINT nFlags, const CPoint& point)
- {
-
- CDrawTool::OnLButtonDown(pView, nFlags, point);
- CPoint local = point;
- pView->ClientToDoc(local);
- if (m_pDrawObj == NULL)
- {
- pView->SetCapture();
- m_pDrawObj = new CDrawPoly(CRect(local, CSize(0, 0)));
- pView->GetDocument()->Add(m_pDrawObj);
- pView->Select(m_pDrawObj);
- m_pDrawObj->AddPoint(local, pView);
-
- }
- else if (local == m_pDrawObj->m_points[0])
- {
- // Stop when the first point is repeated...
- ReleaseCapture();
- m_pDrawObj->m_nPoints -= 1;
- if (m_pDrawObj->m_nPoints < 2)
- {
- m_pDrawObj->Remove();
- CDrawObj::c_identify = CDrawObj::c_identify-1;
- }
- else
- {
- pView->InvalObj(m_pDrawObj);
- }
- m_pDrawObj = NULL;
- c_drawShape = selection;
- return;
- }
- local.x += 1; // adjacent points can't be the same!
- m_pDrawObj->AddPoint(local, pView);
- selectMode = size;
- nDragHandle = m_pDrawObj->GetHandleCount();
- lastPoint = local;
- }
- void CPolyTool::OnLButtonUp(CProjView* /*pView*/, UINT /*nFlags*/, const CPoint& /*point*/)
- {
- // Don't release capture yet!
- }
- void CPolyTool::OnMouseMove(CProjView* pView, UINT nFlags, const CPoint& point)
- {
- if (m_pDrawObj != NULL && (nFlags & MK_LBUTTON) != 0)
- {
- CPoint local = point;
- pView->ClientToDoc(local);
- m_pDrawObj->AddPoint(local);
- nDragHandle = m_pDrawObj->GetHandleCount();
- lastPoint = local;
- c_last = point;
- // SetCursor(AfxGetApp()->LoadCursor(IDC_PENCIL));
- }
- else
- {
- SetCursor(AfxGetApp()->LoadStandardCursor(IDC_CROSS));
- selectTool.OnMouseMove(pView, nFlags, point);
- }
- }
- void CPolyTool::OnLButtonDblClk(CProjView* pView, UINT , const CPoint& )
- {
- ReleaseCapture();
- int nPoints = m_pDrawObj->m_nPoints;
- if (nPoints > 2 &&
- (m_pDrawObj->m_points[nPoints - 1] == m_pDrawObj->m_points[nPoints - 2] ||
- m_pDrawObj->m_points[nPoints - 1].x - 1 == m_pDrawObj->m_points[nPoints - 2].x &&
- m_pDrawObj->m_points[nPoints - 1].y == m_pDrawObj->m_points[nPoints - 2].y))
- {
- // Nuke the last point if it's the same as the next to last...
- m_pDrawObj->m_nPoints -= 1;
- pView->InvalObj(m_pDrawObj);
- }
- m_pDrawObj = NULL;
- c_drawShape = selection;
- }
- void CPolyTool::OnCancel(CProjView* pView)
- {
- CDrawTool::OnCancel(pView);
- int nPoints = m_pDrawObj->m_nPoints;
- if (nPoints > 2 &&
- (m_pDrawObj->m_points[nPoints - 1] == m_pDrawObj->m_points[nPoints - 2] ||
- m_pDrawObj->m_points[nPoints - 1].x - 1 == m_pDrawObj->m_points[nPoints - 2].x &&
- m_pDrawObj->m_points[nPoints - 1].y == m_pDrawObj->m_points[nPoints - 2].y))
- {
- // Nuke the last point if it's the same as the next to last...
- m_pDrawObj->m_nPoints -= 1;
- pView->InvalObj(m_pDrawObj);
- }
- m_pDrawObj = NULL;
- c_drawShape = selection;
- }
- ////////////////////////////////////////////////////////////////////////////
- // CISATool
- CISATool::CISATool()
-
- {
- CDrawTool::m_drawShape = isa;
- }
- void CISATool::OnMouseMove(CProjView* pView, UINT nFlags, const CPoint& point){
- CPoint local = point;
- pView->ClientToDoc(local);
- if(m_pDrawText == NULL)
- {
-
- m_pDrawText = new CDrawISA(CRect(local,CSize(0,0)));
- pView->GetDocument()->Add(m_pDrawText);
- // pView->Select(m_pDrawText);
-
- }else{
-
- lastPoint = local;
- m_pDrawText->MoveTo(CRect(local,m_pDrawText->m_position.Size()),pView);
- }
- SetCursor(AfxGetApp()->LoadStandardCursor(IDC_IBEAM));
-
- }
- /////////////////////////////////////////////////////////////////////////////
- // CTextTool
- CTextTool::CTextTool()
- : CDrawTool(text)
- {
- m_pDrawText = NULL;
- }
- void CTextTool::OnLButtonDown(CProjView* pView, UINT nFlags, const CPoint& point)
- {
- //ReleaseCapture();
- if(m_pDrawText->m_text.IsEmpty()){
- CDrawObj *pObj = (pView->GetDocument())->m_objects.GetTail();
- pView->GetDocument()->Remove(pObj);
- pObj->Remove();
- selectTool.OnLButtonDown(pView, nFlags, point); // try a select!
- }
-
- m_pDrawText = NULL;
- c_drawShape = selection;
-
- }
- /*void CTextTool::OnRButtonDown(CProjView* pView, UINT nFlags, const CPoint& point)
- {
- //ReleaseCapture();
- if(m_pDrawText->m_text.IsEmpty()){
- CDrawObj *pObj = pView->m_selection.GetTail();
- pView->GetDocument()->Remove(pObj);
- pObj->Remove();
- selectTool.OnLButtonDown(pView, nFlags, point); // try a select!
- }
-
- m_pDrawText = NULL;
- c_drawShape = selection;
-
- }*/
- void CTextTool::OnCancel(CProjView* pView)
- {
- if(m_pDrawText->m_text.IsEmpty()){
- CDrawObj *pObj = (pView->GetDocument())->m_objects.GetTail();
- pView->GetDocument()->Remove(pObj);
- pObj->Remove();
-
- }
-
- m_pDrawText = NULL;
- c_drawShape = selection;
- CDrawTool::OnCancel(pView);
- }
- void CTextTool::OnLButtonUp(CProjView* /*pView*/, UINT /*nFlags*/, const CPoint& /*point*/)
- {
- // Don't release capture yet!
- }
- void CTextTool::OnLButtonDblClk(CProjView* pView, UINT , const CPoint& )
- {
- }
- void CTextTool::OnMouseMove(CProjView* pView, UINT nFlags, const CPoint& point)
- {
- //pView->SetCapture();
- CPoint local = point;
- pView->ClientToDoc(local);
- if(m_pDrawText == NULL)
- {
-
- m_pDrawText = new CDrawText(CRect(local,CSize(0,0)));
- pView->GetDocument()->Add(m_pDrawText);
- //pView->Select(m_pDrawText);
-
- }else{
-
- lastPoint = local;
- m_pDrawText->MoveTo(CRect(local,m_pDrawText->m_position.Size()),pView);
- }
- SetCursor(AfxGetApp()->LoadStandardCursor(IDC_IBEAM));
-
- }
- void CTextTool::OnChar(CProjView* pView,UINT nFlags,UINT nChar)
- {
-
- if(nChar == 0x8){
- m_pDrawText->m_text = m_pDrawText->m_text.Left(m_pDrawText->m_text.GetLength()-1);
- }
- //else if((nChar == 0x20 )|| (nChar>=0x30 && nChar<=0x39)
- //|| (nChar >=0x41 && nChar <=0x5A) || (nChar>=0x60 && nChar <=0x6F)){
- else if( (nChar >= 0x20 && nChar <= 0xff)){
- m_pDrawText->m_text+=nChar;
- }
- // m_pDrawText->RecalRect(pView);
- m_pDrawText->Invalidate();
- }
- ////////////////////////////////////////////////////////////////////////////
- // CBarTool
- CBarTool::CBarTool() : CDrawTool(barGraph)
- {
- }
- void CBarTool::OnLButtonDown(CProjView* pView, UINT nFlags, const CPoint& point)
- {
- CDrawTool::OnLButtonDown(pView, nFlags, point);
- CPoint local = point;
- pView->ClientToDoc(local);
- CDrawBar* pObj = new CDrawBar(CRect(local, CSize(0, 0)));
-
- pView->GetDocument()->Add(pObj);
- pView->Select(pObj);
- selectMode = size;
- nDragHandle = 1;
- lastPoint = local;
- }
- void CBarTool::OnLButtonDblClk(CProjView* pView, UINT nFlags, const CPoint& point)
- {
- CDrawTool::OnLButtonDblClk(pView, nFlags, point);
- }
- void CBarTool::OnLButtonUp(CProjView* pView, UINT nFlags, const CPoint& point)
- {
- if (point == c_down)
- {
- // Don't create empty objects...
- CDrawObj *pObj = pView->m_selection.GetTail();
- pView->GetDocument()->Remove(pObj);
- pObj->Remove();
- CDrawObj::c_identify = CDrawObj::c_identify-1;
- selectTool.OnLButtonDown(pView, nFlags, point); // try a select!
- }
- selectTool.OnLButtonUp(pView, nFlags, point);
- }
- void CBarTool::OnMouseMove(CProjView* pView, UINT nFlags, const CPoint& point)
- {
- SetCursor(AfxGetApp()->LoadStandardCursor(IDC_CROSS));
- selectTool.OnMouseMove(pView, nFlags, point);
- }
- ////////////////////////////////////////////////////////////////////////////
- // CLineTool
- CLineTool::CLineTool(DrawShape drawShape)
- : CDrawTool(drawShape)
- {
- }
- void CLineTool::OnLButtonDown(CProjView* pView, UINT nFlags, const CPoint& point)
- {
- CDrawTool::OnLButtonDown(pView, nFlags, point);
- CPoint local = point;
- pView->ClientToDoc(local);
- CDrawLine* pObj = new CDrawLine(CRect(local, CSize(0, 0)));
-
- pView->GetDocument()->Add(pObj);
- pView->Select(pObj);
- if((nFlags&MK_CONTROL)!=0)
- pObj->SetFlag(true);
- else
- pObj->SetFlag(false);
- selectMode = size;
- nDragHandle = 1;
- lastPoint = local;
- }
- void CLineTool::OnLButtonDblClk(CProjView* pView, UINT nFlags, const CPoint& point)
- {
- CDrawTool::OnLButtonDblClk(pView, nFlags, point);
- }
- void CLineTool::OnLButtonUp(CProjView* pView, UINT nFlags, const CPoint& point)
- {
- CDrawObj *pObj = pView->m_selection.GetTail();
- pObj->SetFlag(FALSE);
- if (point == c_down)
- {
- // Don't create empty objects...
-
- pView->GetDocument()->Remove(pObj);
- pObj->Remove();
- CDrawObj::c_identify = CDrawObj::c_identify-1;
- selectTool.OnLButtonDown(pView, nFlags, point); // try a select!
- }
-
- selectTool.OnLButtonUp(pView, nFlags, point);
- }
- void CLineTool::OnMouseMove(CProjView* pView, UINT nFlags, const CPoint& point)
- {
- SetCursor(AfxGetApp()->LoadStandardCursor(IDC_CROSS));
- selectTool.OnMouseMove(pView, nFlags, point);
- }
- ////////////////////////////////////////////////////////////////////////////
- // CEllipseTool
- CEllipseTool::CEllipseTool(DrawShape drawShape)
- : CDrawTool(drawShape)
- {
- }
- void CEllipseTool::OnLButtonDown(CProjView* pView, UINT nFlags, const CPoint& point)
- {
- CDrawTool::OnLButtonDown(pView, nFlags, point);
- CPoint local = point;
- pView->ClientToDoc(local);
- CDrawEllipse* pObj = new CDrawEllipse(CRect(local, CSize(0, 0)));
- pView->GetDocument()->Add(pObj);
- pView->Select(pObj);
- selectMode = size;
- nDragHandle = 1;
- lastPoint = local;
- }
- void CEllipseTool::OnLButtonDblClk(CProjView* pView, UINT nFlags, const CPoint& point)
- {
- CDrawTool::OnLButtonDblClk(pView, nFlags, point);
- }
- void CEllipseTool::OnLButtonUp(CProjView* pView, UINT nFlags, const CPoint& point)
- {
- if (point == c_down)
- {
- // Don't create empty objects...
- CDrawObj *pObj = pView->m_selection.GetTail();
- pView->GetDocument()->Remove(pObj);
- pObj->Remove();
- CDrawObj::c_identify = CDrawObj::c_identify-1;
- selectTool.OnLButtonDown(pView, nFlags, point); // try a select!
- }
- selectTool.OnLButtonUp(pView, nFlags, point);
- }
- void CEllipseTool::OnMouseMove(CProjView* pView, UINT nFlags, const CPoint& point)
- {
- SetCursor(AfxGetApp()->LoadStandardCursor(IDC_CROSS));
- selectTool.OnMouseMove(pView, nFlags, point);
- }
- ////////////////////////////////////////////////////////////////////////////
- // CClockTool
- /*CClockTool::CClockTool()
- : CDrawTool(clockGraph)
- {
- }
- void CClockTool::OnLButtonDown(CProjView* pView, UINT nFlags, const CPoint& point)
- {
- CDrawTool::OnLButtonDown(pView, nFlags, point);
- CPoint local = point;
- pView->ClientToDoc(local);
- CDrawClock* pObj = new CDrawClock(CRect(local, CSize(90, -250)));
- pView->GetDocument()->Add(pObj);
- pObj->ReConsist();
- pView->Select(pObj);
- selectMode = size;
- nDragHandle = 1;
- lastPoint = local;
- }
- void CClockTool::OnLButtonDblClk(CProjView* pView, UINT nFlags, const CPoint& point)
- {
- CDrawTool::OnLButtonDblClk(pView, nFlags, point);
- }
- void CClockTool::OnLButtonUp(CProjView* pView, UINT nFlags, const CPoint& point)
- {
- c_drawShape = selection;
- selectTool.OnLButtonUp(pView, nFlags, point);
- }
- void CClockTool::OnMouseMove(CProjView* pView, UINT nFlags, const CPoint& point)
- {
- }
- */
- /////////////////////////////////////////////////////////////////////////////
- // CAnimateTagTool
- CAnimateTagTool::CAnimateTagTool()
- {
- CDrawTool::m_drawShape = animateTag;
- }
- void CAnimateTagTool::OnMouseMove(CProjView* pView, UINT nFlags, const CPoint& point)
- {
- //pView->SetCapture();
- CPoint local = point;
- pView->ClientToDoc(local);
- if(m_pDrawText == NULL)
- {
-
- m_pDrawText = new CDrawAnimateTag(CRect(local,CSize(0,0)));
- pView->GetDocument()->Add(m_pDrawText);
- // pView->Select(m_pDrawText);
-
- }else{
-
- lastPoint = local;
- m_pDrawText->MoveTo(CRect(local,m_pDrawText->m_position.Size()),pView);
- }
- SetCursor(AfxGetApp()->LoadStandardCursor(IDC_IBEAM));
-
- }
- void CAnimateTagTool::OnChar(CProjView* pView,UINT nFlags,UINT nChar)
- {
-
-
- }
- ////////////////////////////////////////////////////////////////////////////
- // CCursorTool
- CCursorTool::CCursorTool()
- : CDrawTool(cursor)
- {
- }
- void CCursorTool::OnLButtonDown(CProjView* pView, UINT nFlags, const CPoint& point)
- {
- CDrawTool::OnLButtonDown(pView, nFlags, point);
- CPoint local = point;
- pView->ClientToDoc(local);
- //CDrawCursor* pObj = new CDrawCursor(CRect(local, CSize(0, 0)));
- CDrawCursor* pObj = new CDrawCursor(CRect(local, CSize(0, 0)));
- pView->GetDocument()->Add(pObj);
- pView->Select(pObj);
- selectMode = size;
- nDragHandle = 1;
- lastPoint = local;
- }
- void CCursorTool::OnLButtonDblClk(CProjView* pView, UINT nFlags, const CPoint& point)
- {
- CDrawTool::OnLButtonDblClk(pView, nFlags, point);
- }
- void CCursorTool::OnLButtonUp(CProjView* pView, UINT nFlags, const CPoint& point)
- {
- if (point == c_down)
- {
- // Don't create empty objects...
- CDrawObj *pObj = pView->m_selection.GetTail();
- pView->GetDocument()->Remove(pObj);
- pObj->Remove();
- CDrawObj::c_identify = CDrawObj::c_identify-1;
- selectTool.OnLButtonDown(pView, nFlags, point); // try a select!
- }
- selectTool.OnLButtonUp(pView, nFlags, point);
- }
- void CCursorTool::OnMouseMove(CProjView* pView, UINT nFlags, const CPoint& point)
- {
- SetCursor(AfxGetApp()->LoadStandardCursor(IDC_CROSS));
- selectTool.OnMouseMove(pView, nFlags, point);
- }
- ////////////////////////////////////////////////////////////////////////////
- // CLoopTool
- CLoopTool::CLoopTool()
- : CDrawTool(loop)
- {
- }
- void CLoopTool::OnLButtonDown(CProjView* pView, UINT nFlags, const CPoint& point)
- {
- CDrawTool::OnLButtonDown(pView, nFlags, point);
- CPoint local = point;
- pView->ClientToDoc(local);
- CDrawLoop* pObj = new CDrawLoop(CRect(local, CSize(80, 20)));
- pView->GetDocument()->Add(pObj);
- pView->Select(pObj);
- selectMode = size;
- nDragHandle = 1;
- lastPoint = local;
- }
- void CLoopTool::OnLButtonDblClk(CProjView* pView, UINT nFlags, const CPoint& point)
- {
- CDrawTool::OnLButtonDblClk(pView, nFlags, point);
- }
- void CLoopTool::OnLButtonUp(CProjView* pView, UINT nFlags, const CPoint& point)
- {
- c_drawShape = selection;
- selectTool.OnLButtonUp(pView, nFlags, point);
- }
- void CLoopTool::OnMouseMove(CProjView* pView, UINT nFlags, const CPoint& point)
- {
- SetCursor(AfxGetApp()->LoadStandardCursor(IDC_CROSS));
- selectTool.OnMouseMove(pView, nFlags, point);
- }
- ////////////////////////////////////////////////////////////////////////////
- // CCustomTool
- CCustomTool::CCustomTool()
- : CDrawTool(custom)
- {
- }
- void CCustomTool::OnLButtonDown(CProjView* pView, UINT nFlags, const CPoint& point)
- {
- CDrawTool::OnLButtonDown(pView, nFlags, point);
- POSITION pos;
- CCustomDlg dlg;
- CPoint local = point;
- pView->ClientToDoc(local);
- CProjDoc* pDoc = (CProjDoc* )pView->GetDocument();
- if(pDoc->LoadFromLib())
- {
- POSITION pos1 = (pDoc->m_customList).GetHeadPosition();
- while(pos1!=NULL)
- {
- dlg.m_list.AddTail((pDoc->m_customList).GetNext(pos1)->m_name);
- }
- dlg.PrepareView(pView);
- if(dlg.DoModal()!=IDOK)
- return;
- if(dlg.m_index >= 0){
- pos = (pDoc->m_customList).FindIndex(dlg.m_index);
- CDrawObj* pObj = ((pDoc->m_customList).GetAt(pos))->Clone(NULL);
- pDoc->Add(pObj);
- ((CMergeObj* )pObj)->ResetDoc();
- CRect rect(local,CSize(pObj->m_position.Width(),pObj->m_position.Height()));
- ((CMergeObj* )pObj)->MoveTo(rect,pView);
- pDoc->SetModifiedFlag();
- pDoc->UpdateAllViews(NULL);
- }
- }
- selectTool.OnLButtonUp(pView, nFlags, point);
- }
- ////////////////////////////////////////////////////////////////////////////
- // CButtonTool
- CButtonTool::CButtonTool()
- : CDrawTool(button)
- {
- }
- void CButtonTool::OnLButtonDown(CProjView* pView, UINT nFlags, const CPoint& point)
- {
- CDrawTool::OnLButtonDown(pView, nFlags, point);
- CPoint local = point;
- pView->ClientToDoc(local);
- CDrawButton* pObj = new CDrawButton(CRect(local, CSize(0, 0)));
- pView->GetDocument()->Add(pObj);
- pView->Select(pObj);
- selectMode = size;
- nDragHandle = 1;
- lastPoint = local;
- }
- void CButtonTool::OnLButtonDblClk(CProjView* pView, UINT nFlags, const CPoint& point)
- {
- CDrawTool::OnLButtonDblClk(pView, nFlags, point);
- }
- void CButtonTool::OnLButtonUp(CProjView* pView, UINT nFlags, const CPoint& point)
- {
- if (point == c_down)
- {
- // Don't create empty objects...
- CDrawObj *pObj = pView->m_selection.GetTail();
-
- pView->GetDocument()->Remove(pObj);
- pObj->Remove();
- CDrawObj::c_identify = CDrawObj::c_identify-1;
- selectTool.OnLButtonDown(pView, nFlags, point); // try a select!
- }
- selectTool.OnLButtonUp(pView, nFlags, point);
- }
- void CButtonTool::OnMouseMove(CProjView* pView, UINT nFlags, const CPoint& point)
- {
- SetCursor(AfxGetApp()->LoadStandardCursor(IDC_CROSS));
- selectTool.OnMouseMove(pView, nFlags, point);
- }
- // End of class implemention