https://git.reactos.org/?p=reactos.git;a=commitdiff;h=f935132fbe134b41079ef…
commit f935132fbe134b41079ef529522496db088e56c1
Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com>
AuthorDate: Thu Nov 23 14:44:27 2023 +0900
Commit: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com>
CommitDate: Thu Nov 23 14:44:27 2023 +0900
[MSPAINT] Add selectionModel.moveSelection and use it
Refactoring. CORE-19094
---
base/applications/mspaint/canvas.cpp | 10 ----------
base/applications/mspaint/canvas.h | 1 -
base/applications/mspaint/selectionmodel.cpp | 10 ++++++++++
base/applications/mspaint/selectionmodel.h | 1 +
base/applications/mspaint/winproc.cpp | 8 ++++----
5 files changed, 15 insertions(+), 15 deletions(-)
diff --git a/base/applications/mspaint/canvas.cpp b/base/applications/mspaint/canvas.cpp
index 4509fbceee4..8a010603305 100644
--- a/base/applications/mspaint/canvas.cpp
+++ b/base/applications/mspaint/canvas.cpp
@@ -770,16 +770,6 @@ VOID CCanvasWindow::EndSelectionDrag(POINT ptImage)
Invalidate(FALSE);
}
-VOID CCanvasWindow::MoveSelection(INT xDelta, INT yDelta)
-{
- if (!selectionModel.m_bShow)
- return;
-
- selectionModel.TakeOff();
- ::OffsetRect(&selectionModel.m_rc, xDelta, yDelta);
- Invalidate(FALSE);
-}
-
LRESULT CCanvasWindow::OnCtlColorEdit(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL&
bHandled)
{
SetTextColor((HDC)wParam, paletteModel.GetFgColor());
diff --git a/base/applications/mspaint/canvas.h b/base/applications/mspaint/canvas.h
index 9c780028cb2..e59b37cc670 100644
--- a/base/applications/mspaint/canvas.h
+++ b/base/applications/mspaint/canvas.h
@@ -52,7 +52,6 @@ public:
VOID CanvasToImage(POINT& pt);
VOID CanvasToImage(RECT& rc);
VOID GetImageRect(RECT& rc);
- VOID MoveSelection(INT xDelta, INT yDelta);
VOID getNewZoomRect(CRect& rcView, INT newZoom, CPoint ptTarget);
VOID zoomTo(INT newZoom, LONG left = 0, LONG top = 0);
diff --git a/base/applications/mspaint/selectionmodel.cpp
b/base/applications/mspaint/selectionmodel.cpp
index 8e32d17030d..a1ab20626b8 100644
--- a/base/applications/mspaint/selectionmodel.cpp
+++ b/base/applications/mspaint/selectionmodel.cpp
@@ -551,6 +551,16 @@ void SelectionModel::drawFrameOnCanvas(HDC hCanvasDC)
drawSizeBoxes(hCanvasDC, &rcSelection, TRUE);
}
+void SelectionModel::moveSelection(INT xDelta, INT yDelta)
+{
+ if (!m_bShow)
+ return;
+
+ TakeOff();
+ ::OffsetRect(&m_rc, xDelta, yDelta);
+ canvasWindow.Invalidate();
+}
+
void SelectionModel::StretchSelection(BOOL bShrink)
{
if (!m_bShow)
diff --git a/base/applications/mspaint/selectionmodel.h
b/base/applications/mspaint/selectionmodel.h
index f2d3a596823..37cf74ca38f 100644
--- a/base/applications/mspaint/selectionmodel.h
+++ b/base/applications/mspaint/selectionmodel.h
@@ -41,6 +41,7 @@ public:
void DeleteSelection();
HITTEST hitTest(POINT ptCanvas);
void drawFrameOnCanvas(HDC hCanvasDC);
+ void moveSelection(INT xDelta, INT yDelta);
HBITMAP GetSelectionContents();
void DrawFramePoly(HDC hDCImage);
diff --git a/base/applications/mspaint/winproc.cpp
b/base/applications/mspaint/winproc.cpp
index a459dda4b76..0a280d95755 100644
--- a/base/applications/mspaint/winproc.cpp
+++ b/base/applications/mspaint/winproc.cpp
@@ -529,16 +529,16 @@ LRESULT CMainWindow::OnKeyDown(UINT nMsg, WPARAM wParam, LPARAM
lParam, BOOL& bH
break;
case VK_LEFT:
- canvasWindow.MoveSelection(-1, 0);
+ selectionModel.moveSelection(-1, 0);
break;
case VK_RIGHT:
- canvasWindow.MoveSelection(+1, 0);
+ selectionModel.moveSelection(+1, 0);
break;
case VK_UP:
- canvasWindow.MoveSelection(0, -1);
+ selectionModel.moveSelection(0, -1);
break;
case VK_DOWN:
- canvasWindow.MoveSelection(0, +1);
+ selectionModel.moveSelection(0, +1);
break;
default:
break;