https://git.reactos.org/?p=reactos.git;a=commitdiff;h=c2bb5aa01d5b66e8d7852…
commit c2bb5aa01d5b66e8d7852c334e776433adac8f33
Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com>
AuthorDate: Thu Nov 23 10:31:24 2023 +0900
Commit: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com>
CommitDate: Thu Nov 23 10:31:24 2023 +0900
[MSPAINT] Add selectionModel.hitTest and use it
Refactoring. CORE-19094
---
base/applications/mspaint/canvas.cpp | 17 ++---------------
base/applications/mspaint/canvas.h | 1 -
base/applications/mspaint/selectionmodel.cpp | 11 +++++++++++
base/applications/mspaint/selectionmodel.h | 1 +
4 files changed, 14 insertions(+), 16 deletions(-)
diff --git a/base/applications/mspaint/canvas.cpp b/base/applications/mspaint/canvas.cpp
index 99f1abf772b..99be275fd02 100644
--- a/base/applications/mspaint/canvas.cpp
+++ b/base/applications/mspaint/canvas.cpp
@@ -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;
diff --git a/base/applications/mspaint/canvas.h b/base/applications/mspaint/canvas.h
index e275e97a4d3..d65be1df606 100644
--- a/base/applications/mspaint/canvas.h
+++ b/base/applications/mspaint/canvas.h
@@ -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);
diff --git a/base/applications/mspaint/selectionmodel.cpp
b/base/applications/mspaint/selectionmodel.cpp
index 3cf31aab9e0..1dda60404a4 100644
--- a/base/applications/mspaint/selectionmodel.cpp
+++ b/base/applications/mspaint/selectionmodel.cpp
@@ -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)
diff --git a/base/applications/mspaint/selectionmodel.h
b/base/applications/mspaint/selectionmodel.h
index e66b2bff0cc..4fa9e3887dc 100644
--- a/base/applications/mspaint/selectionmodel.h
+++ b/base/applications/mspaint/selectionmodel.h
@@ -39,6 +39,7 @@ public:
BOOL IsLanded() const;
void HideSelection();
void DeleteSelection();
+ HITTEST hitTest(POINT ptCanvas);
HBITMAP GetSelectionContents();
void DrawFramePoly(HDC hDCImage);