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.
74 lines
2.3 KiB
C++
74 lines
2.3 KiB
C++
#pragma once
|
|
|
|
namespace NItem
|
|
{
|
|
class CRectTrackerEx
|
|
{
|
|
public:
|
|
// Constructors
|
|
CRectTrackerEx() { Construct(); };
|
|
CRectTrackerEx(LPCRECT lpSrcRect, UINT nStyle);
|
|
|
|
// Style Flags
|
|
enum StyleFlags
|
|
{
|
|
solidLine = 1, dottedLine = 2, hatchedBorder = 4,
|
|
resizeInside = 8, resizeOutside = 16, hatchInside = 32,
|
|
};
|
|
|
|
// Hit-Test codes
|
|
enum TrackerHit
|
|
{
|
|
hitNothing = -1,
|
|
hitTopLeft = 0, hitTopRight = 1, hitBottomRight = 2, hitBottomLeft = 3,
|
|
hitTop = 4, hitRight = 5, hitBottom = 6, hitLeft = 7, hitMiddle = 8
|
|
};
|
|
|
|
// Attributes
|
|
UINT m_nStyle; // current state
|
|
CRect m_rect; // current position (always in pixels)
|
|
CSize m_sizeMin; // minimum X and Y size during track operation
|
|
int m_nHandleSize; // size of resize handles (default from WIN.INI)
|
|
|
|
// Operations
|
|
void Draw(CDC* pDC) const;
|
|
void GetTrueRect(LPRECT lpTrueRect) const;
|
|
BOOL SetCursor(CWnd* pWnd, UINT nHitTest) const;
|
|
BOOL Track(int nHandle, CPoint point, BOOL bAllowInvert, CDC * pDCScreen);
|
|
BOOL TrackRubberBand(CWnd* pWnd, CPoint point, BOOL bAllowInvert = TRUE);
|
|
int HitTest(CPoint point) const;
|
|
int NormalizeHit(int nHandle) const;
|
|
|
|
// Overridables
|
|
virtual void DrawTrackerRect(LPCRECT lpRect, CDC* pDC);
|
|
virtual void AdjustRect(int nHandle, LPRECT lpRect);
|
|
virtual void OnChangedRect(const CRect& rectOld);
|
|
virtual UINT GetHandleMask() const;
|
|
|
|
void SetTrackStart(CPoint& point);
|
|
|
|
// Implementation
|
|
public:
|
|
virtual ~CRectTrackerEx();
|
|
|
|
protected:
|
|
BOOL m_bAllowInvert = FALSE; // flag passed to Track or TrackRubberBand
|
|
CRect m_rectLast;
|
|
CSize m_sizeLast;
|
|
CPoint m_ptLast;
|
|
BOOL m_bErase = FALSE; // TRUE if DrawTrackerRect is called for erasing
|
|
BOOL m_bFinalErase = FALSE; // TRUE if DragTrackerRect called for final erase
|
|
|
|
// implementation helpers
|
|
int HitTestHandles(CPoint point) const;
|
|
void GetHandleRect(int nHandle, CRect* pHandleRect) const;
|
|
void GetModifyPointers(int nHandle, int**ppx, int**ppy, int* px, int*py);
|
|
void GetModifyPointers(int nHandle, CPoint point);
|
|
virtual int GetHandleSize(LPCRECT lpRect = NULL) const;
|
|
BOOL TrackHandle(int nHandle, CPoint point, CDC* pDCScreen, CDC* pDCBackground);
|
|
BOOL TrackHandle(int nHandle, CPoint point, CDC* pDCScreen);
|
|
void Construct();
|
|
};
|
|
};
|
|
using namespace NItem;
|