bool CTrack::Down(int x, int y, bool bInsideMoveAllowed) { if (m_bDisabled) return false; m_bMoved = false; m_iHandleGrabbed = 0; m_bPtInBorder = false; m_bPtInHandle = false; CPoint Point(x, y); for (int h = 0; h < NUM_HANDLES; h++) { if (!m_iHandleInUse[h]) continue; if (PtInRect(&m_hHandleRects[h], Point)) { m_iHandleGrabbed = h; m_bPtInHandle = true; break; } } if (m_iHandleGrabbed) { if (m_bShear) { if (!CONTROL && m_iHandleGrabbed != H_MOVE && m_iHandleGrabbed != H_CENTER && m_iHandleGrabbed != H_ROTATE ) ConstrainXY(&x, &y, true/*bButtonDown*/, true/*bInit*/, true/*bActive*/); } } else { if (PtInBorder(Point)) m_bPtInBorder = true; CRect rect = m_Distort.Rect; m_Matrix.Transform(rect); m_ViewToDeviceMatrix.Transform(rect); // Make sure the rect is big enough to grab if (rect.Width() < 20) rect.InflateRect(10, 0); if (rect.Height() < 20) rect.InflateRect(0, 10); if (m_bPtInBorder || (bInsideMoveAllowed && PtInRect(&rect, Point))) { m_iHandleGrabbed = H_MOVE; m_bPtInHandle = false; } } if (m_iHandleGrabbed) { CPoint pt(x, y); m_iLastDownX = pt.x; m_iLastDownY = pt.y; m_ViewToDeviceMatrix.Inverse().Transform(pt); m_iLastX = pt.x; m_iLastY = pt.y; m_StartRect = m_Distort.Rect; m_Matrix.Transform(m_StartRect); m_StartMatrix = m_Matrix; m_iStartRotateX = m_ptRotate.x; m_iStartRotateY = m_ptRotate.y; #ifdef READOUT m_fReadoutScale1X = m_fReadoutScaleX; m_fReadoutScale1Y = m_fReadoutScaleY; m_fReadoutAngle1X = m_fReadoutAngleX; m_fReadoutAngle1Y = m_fReadoutAngleY; #endif READOUT } return !!m_iHandleGrabbed; }
bool CTrack::SetCursor(int x, int y, bool bInsideMoveAllowed, bool& bPtInBorder, bool& bPtInHandle) { if (m_bDisabled) return false; CPoint Point(x, y); HINSTANCE hInst = NULL; LPCSTR lpCursor = NULL; bPtInBorder = false; bPtInHandle = false; for (int h = 0; h < NUM_HANDLES; h++) { if (!m_iHandleInUse[h]) continue; if (!PtInRect(&m_hHandleRects[h], Point)) continue; bPtInHandle = true; switch (h) { case H_ROTATE: lpCursor = IDC_CROSS; //j MAKEINTRESOURCE(ID_ROTATE); hInst = _AtlBaseModule.GetResourceInstance(); break; case H_CENTER: lpCursor = IDC_ARROW; break; case H_CORNER_UL: case H_CORNER_UR: case H_CORNER_LR: case H_CORNER_LL: lpCursor = IDC_ARROW; break; case H_UL: case H_LR: lpCursor = IDC_SIZENWSE; break; case H_UR: case H_LL: lpCursor = IDC_SIZENESW; break; case H_TOP: case H_BOTTOM: lpCursor = IDC_SIZENS; break; case H_LEFT: case H_RIGHT: lpCursor = IDC_SIZEWE; break; default: break; } break; } if (!lpCursor) { if (PtInBorder(Point)) bPtInBorder = true; CRect rect = m_Distort.Rect; m_Matrix.Transform(rect); m_ViewToDeviceMatrix.Transform(rect); // Make sure the rect is big enough to grab if (rect.Width() < 20) rect.InflateRect(10, 0); if (rect.Height() < 20) rect.InflateRect(0, 10); if (bPtInBorder || (bInsideMoveAllowed && PtInRect(&rect, Point))) lpCursor = IDC_SIZEALL; } if (lpCursor) { ::SetCursor(::LoadCursor(hInst, lpCursor)); return true; } return false; }
bool CTrack::SetCursor(int x, int y) { POINT Point = {x, y}; LPCSTR lpCursor = NULL; HINSTANCE hInst = NULL; for (int h = 0; h < NUM_HANDLES; h++) { if (!m_iHandleInUse[h]) continue; if (!PtInRect(&m_hHandleRects[h], Point)) continue; switch (h) { case H_ROTATE: lpCursor = MAKEINTRESOURCE(ID_ROTATE); hInst = _AtlBaseModule.GetResourceInstance(); break; case H_CENTER: lpCursor = (LPCSTR)IDC_ARROW; hInst = NULL; break; case H_CORNER_UL: case H_CORNER_UR: case H_CORNER_LR: case H_CORNER_LL: lpCursor = (LPCSTR)IDC_ARROW; hInst = NULL; break; case H_UL: case H_LR: lpCursor = (LPCSTR)IDC_SIZENWSE; hInst = NULL; break; case H_UR: case H_LL: lpCursor = (LPCSTR)IDC_SIZENESW; hInst = NULL; break; case H_TOP: case H_BOTTOM: lpCursor = (LPCSTR)IDC_SIZENS; hInst = NULL; break; case H_LEFT: case H_RIGHT: lpCursor = (LPCSTR)IDC_SIZEWE; hInst = NULL; break; default: break; } break; } if (!lpCursor) { if (PtInBorder(Point)) { lpCursor = IDC_SIZEALL; hInst = NULL; } } if (lpCursor) { ::SetCursor(::LoadCursor(hInst, lpCursor)); return true; } return false; }