#include "stdafx.h" #include "ItemSetContourName.h" #include "SigmaDoc.h" #include "actionreplacenameitem.h" CItemSetContourName::CItemSetContourName(CSigmaDoc * ppDoc) : CItem(ppDoc) { this->SetType(ITEM_SET_CONTOUR_NAME); this->m_OperateSuccess = false; } CItemSetContourName::~CItemSetContourName(void) { } void CItemSetContourName::OnLButtonDown(CDC* pDC, UINT nFlags, CPoint point, int vk) { GetDC()->Create(pDC); CPoint2D rp = GetDC()->GetReal(point); POSITION pos = NULL; this->m_OperateSuccess = false; pos = GetDoc()->GetSelectedItem(rp); if (pos == NULL) { return; } else { COne* pOne = GetDoc()->GetDraw()->GetAt(pos); if (pOne->GetType() != DOUBLEFOX_CURVE) { return; } CCurveEx *pc = (CCurveEx*)pOne->GetValue(); CString oldName = pc->GetName(); pc->SetName(m_newName); // for redo/undo CActionReplaceNameItem* pAction = new CActionReplaceNameItem(GetDoc(), ID_OPERATION_CURVE_NAME, pOne, oldName, m_newName); GetDoc()->SetActionItem(pAction); this->m_OperateSuccess = true; } } CString CItemSetContourName::GetNewName() { return m_newName; } void CItemSetContourName::SetNewName(LPCTSTR newName) { m_newName = newName; }