|
|
#include "stdafx.h"
|
|
|
#include "CurveHandleDrawer.h"
|
|
|
|
|
|
#define TRACKER_SOLID 1
|
|
|
#define TRACKER_RECT 2
|
|
|
#define TRACKER_CIRCLE 4
|
|
|
#define TRACKER_NO_EDIT TRACKER_SOLID | TRACKER_CIRCLE
|
|
|
|
|
|
CurveHandleDrawer::CurveHandleDrawer()
|
|
|
{
|
|
|
m_colorHandlesEnableBrush = RGB(255, 255, 255);
|
|
|
m_colorHandlesDisableBursh = RGB(80, 80, 80);
|
|
|
m_colorHandles = RGB(220, 20, 60);
|
|
|
}
|
|
|
|
|
|
void CurveHandleDrawer::Draw(CDC* pDC, CRect& rect, DWORD nDrawMode)
|
|
|
{
|
|
|
//int od = pDC->SetROP2(R2_NOTXORPEN);
|
|
|
CBrush brush, *pOldBrush;
|
|
|
DWORD nNotEdit = TRACKER_NO_EDIT;
|
|
|
if ((nDrawMode & nNotEdit) == nNotEdit)
|
|
|
{
|
|
|
brush.CreateSolidBrush(m_colorHandlesDisableBursh);
|
|
|
pOldBrush = (CBrush*)pDC->SelectObject(&brush);
|
|
|
rect.DeflateRect(1, 1);//ËõС1¸ö
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
if (nDrawMode & TRACKER_SOLID)
|
|
|
{
|
|
|
brush.CreateSolidBrush(m_colorHandlesEnableBrush);
|
|
|
pOldBrush = (CBrush*)pDC->SelectObject(&brush);
|
|
|
}
|
|
|
else
|
|
|
pOldBrush = (CBrush*)pDC->SelectStockObject(NULL_BRUSH);
|
|
|
}
|
|
|
|
|
|
CPen penHandles(PS_SOLID, 0, m_colorHandles);
|
|
|
CPen* op = (CPen*)pDC->SelectObject(&penHandles);
|
|
|
|
|
|
if (nDrawMode & TRACKER_RECT)
|
|
|
pDC->Rectangle(rect);
|
|
|
else if (nDrawMode & TRACKER_CIRCLE || (nDrawMode & nNotEdit) == nNotEdit)
|
|
|
pDC->Ellipse(&rect);
|
|
|
|
|
|
pDC->SelectObject(pOldBrush);
|
|
|
pDC->SelectObject(op);
|
|
|
|
|
|
//if (od >= 0)
|
|
|
// pDC->SetROP2(od);
|
|
|
}
|