Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

76 lines
2.4 KiB

  1. #ifndef _SELTRACK_H_
  2. #define _SELTRACK_H_
  3. // This file defines the class used to handle the selection rectangle
  4. // complete with resize handles
  5. BOOL InitSelectionTracking();
  6. void CleanupSelectionTracking();
  7. /////////////////////////////////////////////////////////////////////////////
  8. // CSelectionTracker - simple rectangular tracking rectangle w/resize handles
  9. class CSelectionTracker
  10. {
  11. public:
  12. // Constructor / Destructor
  13. CSelectionTracker();
  14. virtual ~CSelectionTracker();
  15. BOOL Init(); // You must call Init after construction
  16. // Style Flags
  17. enum StyleFlags
  18. {
  19. solidLine = 1, dottedLine = 2, hatchedBorder = 4,
  20. resizeInside = 8, resizeOutside = 16, hatchInside = 32,
  21. lineSelection = 64
  22. };
  23. // Hit-Test codes
  24. enum TrackerHit
  25. {
  26. hitNothing = -1,
  27. hitTopLeft = 0, hitTopRight = 1, hitBottomRight = 2, hitBottomLeft = 3,
  28. hitTop = 4, hitRight = 5, hitBottom = 6, hitLeft = 7, hitMiddle = 8
  29. };
  30. // Attributes
  31. UINT m_uStyle; // current state
  32. CRect m_rect; // current position (always in pixels)
  33. CSize m_sizeMin; // minimum X and Y size during track operation
  34. int m_nHandleSize; // size of resize handles (default from WIN.INI)
  35. // Operations
  36. void Draw(HDC hdc) const;
  37. void GetTrueRect(LPRECT lpTrueRect) const;
  38. BOOL SetCursor(HWND hwnd, LPARAM lParam) const;
  39. BOOL Track(HWND hwnd, CPoint point, BOOL bAllowInvert = FALSE,
  40. HWND hwndClipTo = NULL);
  41. BOOL TrackRubberBand(HWND hwnd, CPoint point, BOOL bAllowInvert = TRUE);
  42. int HitTest(CPoint point) const;
  43. int NormalizeHit(int nHandle) const;
  44. private:
  45. BOOL _bAllowInvert; // flag passed to Track or TrackRubberBand
  46. CRect _rectLast;
  47. CSize _sizeLast;
  48. CSize _sizeMin;
  49. BOOL _bErase; // TRUE if _DrawTrackerRect is called for erasing
  50. BOOL _bFinalErase; // TRUE if _DragTrackerRect called for final erase
  51. // implementation helpers
  52. void _DrawTrackerRect(LPCRECT lpRect, HWND hwndClipTo, HDC hdc, HWND hwnd);
  53. void _AdjustRect(int nHandle, LPRECT lpRect);
  54. void _OnChangedRect(const CRect& rectOld);
  55. UINT _GetHandleMask() const;
  56. int _HitTestHandles(CPoint point) const;
  57. void _GetHandleRect(int nHandle, CRect* pHandleRect) const;
  58. void _GetModifyPointers(int nHandle, int** ppx, int** ppy, int* px, int*py);
  59. int _GetHandleSize(LPCRECT lpRect = NULL) const;
  60. BOOL _TrackHandle(int nHandle, HWND hwnd, CPoint point, HWND hwndClipTo);
  61. void _DrawDragRect(HDC hdc, LPCRECT lpRect, SIZE size, LPCRECT lpRectLast, SIZE sizeLast);
  62. };
  63. #endif