You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

207 lines
3.6 KiB
C++

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#include "StdAfx.h"
#include "WellPoleDoc.h"
#include "WellPoleView.h"
#include "WellPoleLib/WellBaseObj.h"
#include "ItemNestBase.h"
#include "DrawUndoManager.h"
#include "ActionModifiedItem.h"
namespace NItem
{
CItemNestBase::CItemNestBase(CSigmaDoc* ppDoc)
: CItemSelect(ppDoc)
{
m_bInEdit = TRUE;
m_pItemSelected = NULL;
m_bLDown = FALSE;
m_bDrag = FALSE;
nDragHandle = 0;
selectMode = CItemNestBase::selnone;
m_bNestItem = TRUE;
}
CItemNestBase::~CItemNestBase(void)
{
if(m_pItemSelected != NULL)
delete m_pItemSelected;
m_pItemSelected = NULL;
}
void CItemNestBase::DrawHandle(CXyDC *pDC)
{//本函数在OnDraw函数中执行画到显示缓冲中因此需要使用传入的DC
if(GetDrawObj() != NULL)
{
CWellBaseObj* pObj = GetDrawObj();
CRect rect = pDC->GetScreen(pObj->GetRect());
rect.InflateRect(2,2,3,3);
DrawFocusRect(rect,pDC->GetDC());
rect.DeflateRect(1,1,1,1);
DrawFocusRect(rect,pDC->GetDC());
rect.InflateRect(2,2,2,2);
DrawFocusRect(rect,pDC->GetDC());
}
}
void CItemNestBase::DrawFocusRect(CRect rect, CDC *pInDC)
{
//GetView()->DocToClient(rect);
rect.NormalizeRect();
if (pInDC == NULL)
{
CDC *pDC = GetView()->GetDc();
pDC->DrawFocusRect(rect);
//GetView()->ReleaseDC(pDC);
}
else
{
CDC *pDC = pInDC;
pDC->SetMapMode(MM_TEXT);
pDC->DrawFocusRect(rect);
//GetView()->PrepareDC(pDC);
}
}
void CItemNestBase::DrawHandle(CXyDC *pDC, const CPoint2D &point)
{
CRect rt=GetDoc()->m_itemTracker.GetHandleRectFocus(pDC->GetSX(point.x0),pDC->GetSY(point.y0));
GetDoc()->m_itemTracker.DrawHandle(pDC->GetDC(),rt,TRACKER_SOLID|TRACKER_RECT);
}
void CItemNestBase::MoveHandle(int nHandle, CPoint point, CRect& rect)
{
switch (nHandle)
{
default:
ASSERT(FALSE);
case 1:
rect.left = point.x;
rect.top = point.y;
break;
case 2:
rect.top = point.y;
break;
case 3:
rect.right = point.x;
rect.top = point.y;
break;
case 4:
rect.right = point.x;
break;
case 5:
rect.right = point.x;
rect.bottom = point.y;
break;
case 6:
rect.bottom = point.y;
break;
case 7:
rect.left = point.x;
rect.bottom = point.y;
break;
case 8:
rect.left = point.x;
break;
}
}
BOOL CItemNestBase::OnSetCursor(CPoint pt, int& handle)
{
handle = -1;
//if(GetItem() == this)
// return CItemSelect::OnSetCursor(pt,handle);
////else
//// return GetItem()->OnSetCursor(pt,handle);
return FALSE;
}
void CItemNestBase::SetItem(CItem* pItem)
{
if(m_pItemSelected != NULL)
{
if(m_pItemSelected->GetItem() != m_pItemSelected)
m_pItemSelected->DeleteItem();
else
{
delete m_pItemSelected;
m_pItemSelected = NULL;
}
}
m_pItemSelected = pItem;
}
CItem* CItemNestBase::GetItem()
{
if(m_pItemSelected != NULL)
return m_pItemSelected->GetItem();
else
return this;
}
void CItemNestBase::DeleteItem()
{
if(m_pItemSelected != NULL)
{
if(m_pItemSelected->GetItem() != m_pItemSelected)
m_pItemSelected->DeleteItem();
else
{
delete m_pItemSelected;
m_pItemSelected = NULL;
}
//GetDoc()->GetTracker().Clear();
}
m_selection.RemoveAll();
}
void CItemNestBase::Redo(void)
{
DeleteItem();
if(m_pItemSelected != NULL)
delete m_pItemSelected;
m_pItemSelected = NULL;
//GetDrawUndoManager()->Redo(GetDoc());
}
void CItemNestBase::Undo(void)
{
DeleteItem();
if(m_pItemSelected != NULL)
delete m_pItemSelected;
m_pItemSelected = NULL;
//GetDrawUndoManager()->Undo(GetDoc());
}
void CItemNestBase::SetReUnDoAction(BOOL bNoSaveData, UINT actionType,int actionItemType)
{
CPositionList list;
POSITION pos = GetPos();
if(NULL != pos)
{
list.AddTail(pos);
(GetDoc())->SetActionItem(new CActionModifiedItem(GetDoc(), actionType, list));
GetDoc()->Modified(TRUE);
}
}
};