[MSPAINT] Add selectionModel.hitTest and use it

Refactoring. CORE-19094
This commit is contained in:
Katayama Hirofumi MZ 2023-11-23 10:31:24 +09:00
parent df54fb01fd
commit c2bb5aa01d
4 changed files with 14 additions and 16 deletions

View file

@ -317,7 +317,7 @@ LRESULT CCanvasWindow::OnButtonDown(UINT nMsg, WPARAM wParam, LPARAM lParam, BOO
return 0;
}
HITTEST hitSelection = SelectionHitTest(pt);
HITTEST hitSelection = selectionModel.hitTest(pt);
if (hitSelection != HIT_NONE)
{
selectionModel.m_nSelectionBrush = 0; // Selection Brush is OFF
@ -634,7 +634,7 @@ LRESULT CCanvasWindow::OnSetCursor(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL
return 0;
}
HITTEST hitSelection = SelectionHitTest(pt);
HITTEST hitSelection = selectionModel.hitTest(pt);
if (hitSelection != HIT_NONE)
{
if (!setCursorOnSizeBox(hitSelection))
@ -746,19 +746,6 @@ VOID CCanvasWindow::finishDrawing()
Invalidate(FALSE);
}
HITTEST CCanvasWindow::SelectionHitTest(POINT ptImage)
{
if (!selectionModel.m_bShow)
return HIT_NONE;
RECT rcSelection = selectionModel.m_rc;
Zoomed(rcSelection);
::OffsetRect(&rcSelection, GRIP_SIZE - GetScrollPos(SB_HORZ), GRIP_SIZE - GetScrollPos(SB_VERT));
::InflateRect(&rcSelection, GRIP_SIZE, GRIP_SIZE);
return getSizeBoxHitTest(ptImage, &rcSelection);
}
VOID CCanvasWindow::StartSelectionDrag(HITTEST hit, POINT ptImage)
{
m_hitSelection = hit;

View file

@ -68,7 +68,6 @@ protected:
VOID DoDraw(HDC hDC, RECT& rcClient, RECT& rcPaint);
VOID OnHVScroll(WPARAM wParam, INT fnBar);
HITTEST SelectionHitTest(POINT ptImage);
VOID StartSelectionDrag(HITTEST hit, POINT ptImage);
VOID SelectionDragging(POINT ptImage);
VOID EndSelectionDrag(POINT ptImage);

View file

@ -529,6 +529,17 @@ void SelectionModel::SwapWidthAndHeight()
m_rc.bottom = m_rc.top + cx;
}
HITTEST SelectionModel::hitTest(POINT ptCanvas)
{
if (!m_bShow)
return HIT_NONE;
RECT rcSelection = m_rc;
canvasWindow.ImageToCanvas(rcSelection);
::InflateRect(&rcSelection, GRIP_SIZE, GRIP_SIZE);
return getSizeBoxHitTest(ptCanvas, &rcSelection);
}
void SelectionModel::StretchSelection(BOOL bShrink)
{
if (!m_bShow)

View file

@ -39,6 +39,7 @@ public:
BOOL IsLanded() const;
void HideSelection();
void DeleteSelection();
HITTEST hitTest(POINT ptCanvas);
HBITMAP GetSelectionContents();
void DrawFramePoly(HDC hDCImage);