00001 #pragma once
00002
00003 #include "CTList.h"
00004 #include "TObject.h"
00005
00006 const int hitNothing = 13;
00007 const int hitTopLeft = 0;
00008 const int hitBottomLeft = 1;
00009 const int hitTopRight = 2;
00010 const int hitBottomRight = 3;
00011 const int hitMiddleLeft = 4;
00012 const int hitMiddleRight = 5;
00013 const int hitMiddleTop = 6;
00014 const int hitMiddleBottom = 7;
00015 const int hitTop = 8;
00016 const int hitBottom = 9;
00017 const int hitLeft = 10;
00018 const int hitRight = 11;
00019 const int hitMiddle = 12;
00020
00021 const int mskTopLeft = 1;
00022 const int mskBottomLeft = 2;
00023 const int mskTopRight = 4;
00024 const int mskBottomRight = 8;
00025 const int mskMiddleLeft = 16;
00026 const int mskMiddleRight = 32;
00027 const int mskMiddleTop = 64;
00028 const int mskMiddleBottom = 128;
00029 const int mskTop = 256;
00030 const int mskBottom = 512;
00031 const int mskLeft = 1024;
00032 const int mskRight = 2048;
00033 const int mskMiddle = 4096;
00034 const int mskNothing = 0;
00035 const int mskAll = 0xFFFFFFFF;
00036 const int mskWidth = mskTopLeft | mskTopRight | mskMiddleTop |
00037 mskBottomLeft | mskBottomRight | mskMiddleBottom;
00038 const int mskHeight = mskTopLeft | mskTopRight | mskMiddleLeft |
00039 mskBottomLeft | mskBottomRight | mskMiddleRight;
00040 const int mskSize = mskTopLeft | mskTopRight | mskMiddleLeft |
00041 mskBottomLeft | mskBottomRight | mskMiddleRight |
00042 mskMiddleTop | mskMiddleBottom;
00043 const int mskMove = mskLeft | mskRight | mskTop | mskBottom;
00044
00045
00046
00047
00048 class CMultiRectTracker
00049 {
00050
00051 public:
00052 CMultiRectTracker();
00053 ~CMultiRectTracker();
00054
00055 void DrawMultiSelectionRect(CDC* pDC, CTList<CTObject *> *objects, bool bCurTmp);
00056
00057 void DrawSelectionRect(CDC* pDC, bool bDrawOnly);
00058
00059 void DrawDottedRect(CDC * pDC, int x0, int y0, int x1, int y1);
00060
00061 void DrawMultiTrackerRect(CDC * pDC);
00062 void DrawTrackerRect(CDC * pDC, CRect rect, bool bIsLast);
00063
00064 CRect GetObjectTotalRect(CTList<CTObject *> * objects, CRect & tltRect);
00065 void InvalidateNumRects(CTList<CTObject *> * objects, CRect * tltRect = NULL);
00066
00067 int HitTest(CPoint point, CRect rect);
00068 int MultiHitTest(CPoint point);
00069
00070 bool AddObject(CTObject * pObject);
00071 void RemoveAllObjects();
00072 bool IsSelObjectsListEmpty();
00073
00074 void SetMask(int nMask);
00075
00076
00077 BOOL SetCursor(CWnd* pWnd, UINT nHitTest);
00078
00079 void SetScrollPos(int nScrollPosX, int nScrollPosY);
00080 void SetClipRect(CRect & clpRect);
00081
00082 bool Track(CWnd* pWnd, CPoint point, int nHitTest);
00083 BOOL TrackRubberBand(CWnd *pWnd, CPoint point);
00084
00085 bool PosChange();
00086 void MoveSelObjects(CWnd * pWnd);
00087 bool IntersectRect(CRect & rect0, CRect & rect1);
00088
00089 void UpdateSelObjectsPos(int nSizeXL, int nSizeYT, int nSizeXR, int nSizeYB);
00090 void UpdateSelObjectsBkg(CWnd * pWnd, bool bCurOld);
00091 void QuantizeObjectsPos();
00092 void StoreObjectsPrevPos();
00093
00094 void QuantizeRect(CRect & rect, bool bCurOld);
00095 void NormalizeSelObjectsPos();
00096
00097 void RecalculateSelctionRect();
00098 void ExpandRect(CRect & rect);
00099 void ExpandRect(CRect & srcRect, CRect & expRect);
00100 void SetRect(CRect & rect);
00101 CRect CalcDragRect(CRect & rect);
00102 CBrush * LoadDIBBrush(int IDB_BRUSH);
00103
00104 void Swap(int & iSrc, int & iDst);
00105 int Nearest(int nPos, int nGrid);
00106
00107 void SetGrid(int nGridX, int nGridY);
00108
00109 CTList <CTObject *> m_selObjects;
00110 CTList <CTObject *> * m_objects;
00111 typedef CTList<CTObject *>::iterator objSelIterator;
00112 CRect GetObjectRealRect(CTObject * pTObject, CRect & rect);
00113 CRect GetObjectRect(CTObject * pTObject, CRect & rect);
00114
00115
00116 protected:
00117
00118 public:
00119 int m_nTrackerWidth;
00120 int m_nTrackerHeight;
00121
00122 int m_nGridX;
00123 int m_nGridY;
00124
00125 int m_nMousePosX;
00126 int m_nMousePosY;
00127
00128 int m_nObjSelected;
00129
00130 int m_nMask;
00131
00132 CRect m_curRect;
00133 CRect m_oldRect;
00134 CRect m_clpRect;
00135 CRect m_tmpRect;
00136
00137 CRect m_qCurRect;
00138
00139 HCURSOR m_hcurArrow;
00140 HCURSOR m_hcurMove;
00141 HCURSOR m_hcurSize1;
00142 HCURSOR m_hcurSize2;
00143 HCURSOR m_hcurSize3;
00144 HCURSOR m_hcurSize4;
00145
00146 bool m_bMultiSelection;
00147 bool m_bAllowInvert;
00148 bool m_bDlgSelected;
00149 bool m_bDragNDrop;
00150
00151
00152
00153
00154 bool m_bHitMove;
00155 int m_nHitTest;
00156
00157 CWnd * m_pParent;
00158
00159 };
00160