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.
110 lines
2.5 KiB
C++
110 lines
2.5 KiB
C++
//////////////////////////////////////////////////////////////////////////////
|
|
//文件: CItem类扩展
|
|
//主要功能:
|
|
// 操作各类元素或完成一定的功能
|
|
// 利用VC自带的CRectTracker类实现选择框的功能
|
|
//
|
|
//程序编写:
|
|
//日期: 2008年3月28日
|
|
//
|
|
//
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
#include "StdAfx.h"
|
|
#include ".\itemrecttracker.h"
|
|
#include "SigmaDoc.h"
|
|
#include "SigmaView.h"
|
|
|
|
NItem::CItemRectTracker::CItemRectTracker(CSigmaDoc* ppDoc)
|
|
: CItem(ppDoc)
|
|
{
|
|
m_tracker.m_rect = CRect(0,0,0,0);
|
|
m_tracker.m_nStyle = 0;
|
|
m_tracker.m_nStyle |= CRectTrackerEx::dottedLine;
|
|
m_tracker.m_nStyle |= CRectTrackerEx::resizeOutside;
|
|
//m_tracker.m_nStyle |= CRectTracker::hatchedBorder;
|
|
m_bAllowInvert=TRUE;
|
|
|
|
m_tracker.m_nHandleSize = 6;
|
|
m_tracker.m_sizeMin.cx = 4;
|
|
m_tracker.m_sizeMin.cy = 4;
|
|
}
|
|
|
|
NItem::CItemRectTracker::~CItemRectTracker(void)
|
|
{
|
|
}
|
|
|
|
void NItem::CItemRectTracker::EnableHatchBorder(BOOL bEnable)
|
|
{
|
|
m_tracker.m_nStyle &= ~CRectTrackerEx::hatchedBorder;
|
|
if(bEnable)
|
|
m_tracker.m_nStyle |= CRectTrackerEx::hatchedBorder;
|
|
}
|
|
|
|
void NItem::CItemRectTracker::EnableHatchInside(BOOL bEnable)
|
|
{
|
|
m_tracker.m_nStyle &= ~CRectTrackerEx::hatchInside;
|
|
if(bEnable)
|
|
m_tracker.m_nStyle |= CRectTrackerEx::hatchInside;
|
|
}
|
|
|
|
void CItemRectTracker::OnLButtonDown(CDC *pDC, UINT nFlags, CPoint point, int vk)
|
|
{
|
|
CItem::OnLButtonDown(pDC, nFlags, point, vk);
|
|
|
|
m_bakRect=m_tracker.m_rect;
|
|
if (m_tracker.HitTest(point) < 0)
|
|
{
|
|
//CRectTracker track;
|
|
//if (track.TrackRubberBand(GetView(), point, m_bAllowInvert))
|
|
//{
|
|
// //设置一个新的区域
|
|
// track.m_rect.NormalizeRect();
|
|
// m_tracker.m_rect = track.m_rect;
|
|
// TraceEnd(-1);
|
|
//}
|
|
}
|
|
else
|
|
{
|
|
////修改已有的区域
|
|
//if (m_tracker.Track(GetView(), point, m_bAllowInvert))
|
|
//{
|
|
// m_tracker.m_rect.NormalizeRect();
|
|
// TraceEnd(1);
|
|
//}
|
|
}
|
|
}
|
|
|
|
void NItem::CItemRectTracker::TraceEnd(int nStatus)
|
|
{
|
|
}
|
|
|
|
void NItem::CItemRectTracker::OnDraw(CXyDC* pXyDC, CDC* pDC)
|
|
{
|
|
if (m_tracker.m_rect.Width() > 0 && m_tracker.m_rect.Height() > 0)
|
|
{
|
|
//m_tracker.Draw(GetScreenDC());
|
|
m_tracker.Draw(pDC);
|
|
}
|
|
//m_tracker.Draw(pDC->GetDC());/*, RGB(255,0,0)*/
|
|
}
|
|
|
|
BOOL NItem::CItemRectTracker::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
|
|
{
|
|
if(pWnd)
|
|
if(m_tracker.SetCursor( pWnd, nHitTest )) return TRUE;
|
|
return FALSE;
|
|
}
|
|
|
|
void NItem::CItemRectTracker::SetRect(CRect8 rect)
|
|
{
|
|
CRect rt=GetDC()->GetScreen(rect);
|
|
rt.NormalizeRect();
|
|
m_tracker.m_rect=rt;
|
|
}
|
|
|
|
CRect8 NItem::CItemRectTracker::GetRect(void)
|
|
{
|
|
return GetDC()->GetReal(m_tracker.m_rect);
|
|
}
|