https://git.reactos.org/?p=reactos.git;a=commitdiff;h=4a52a4b04ce5695b6e97d…
commit 4a52a4b04ce5695b6e97dc4a38bb1440a3d5c8e7
Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com>
AuthorDate: Thu Nov 23 11:03:10 2023 +0900
Commit: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com>
CommitDate: Thu Nov 23 11:03:10 2023 +0900
[MSPAINT] Add selectionModel.drawFrameOnCanvas and use it
Refactoring. CORE-19094
---
base/applications/mspaint/mouse.cpp | 16 ++--------------
base/applications/mspaint/selectionmodel.cpp | 15 +++++++++++++--
base/applications/mspaint/selectionmodel.h | 1 +
base/applications/mspaint/toolsmodel.h | 3 ---
4 files changed, 16 insertions(+), 19 deletions(-)
diff --git a/base/applications/mspaint/mouse.cpp b/base/applications/mspaint/mouse.cpp
index 9c268514b15..69a016b4395 100644
--- a/base/applications/mspaint/mouse.cpp
+++ b/base/applications/mspaint/mouse.cpp
@@ -103,18 +103,6 @@ void ToolBase::endEvent()
m_hdc = NULL;
}
-void ToolBase::OnDrawSelectionOnCanvas(HDC hdc)
-{
- if (!selectionModel.m_bShow)
- return;
-
- RECT rcSelection = selectionModel.m_rc;
- canvasWindow.ImageToCanvas(rcSelection);
-
- ::InflateRect(&rcSelection, GRIP_SIZE, GRIP_SIZE);
- drawSizeBoxes(hdc, &rcSelection, TRUE);
-}
-
void ToolBase::pushToPtStack(LONG x, LONG y)
{
if (s_pointSP >= s_maxPointSP)
@@ -157,7 +145,7 @@ struct FreeSelTool : ToolBase
void OnDrawOverlayOnCanvas(HDC hdc) override
{
- OnDrawSelectionOnCanvas(hdc);
+ selectionModel.drawFrameOnCanvas(hdc);
}
void OnButtonDown(BOOL bLeftButton, LONG x, LONG y, BOOL bDoubleClick) override
@@ -249,7 +237,7 @@ struct RectSelTool : ToolBase
void OnDrawOverlayOnCanvas(HDC hdc) override
{
- OnDrawSelectionOnCanvas(hdc);
+ selectionModel.drawFrameOnCanvas(hdc);
}
void OnButtonDown(BOOL bLeftButton, LONG x, LONG y, BOOL bDoubleClick) override
diff --git a/base/applications/mspaint/selectionmodel.cpp
b/base/applications/mspaint/selectionmodel.cpp
index 1dda60404a4..8e32d17030d 100644
--- a/base/applications/mspaint/selectionmodel.cpp
+++ b/base/applications/mspaint/selectionmodel.cpp
@@ -523,8 +523,7 @@ void SelectionModel::NotifyContentChanged()
void SelectionModel::SwapWidthAndHeight()
{
- INT cx = m_rc.Width();
- INT cy = m_rc.Height();
+ INT cx = m_rc.Width(), cy = m_rc.Height();
m_rc.right = m_rc.left + cy;
m_rc.bottom = m_rc.top + cx;
}
@@ -540,6 +539,18 @@ HITTEST SelectionModel::hitTest(POINT ptCanvas)
return getSizeBoxHitTest(ptCanvas, &rcSelection);
}
+void SelectionModel::drawFrameOnCanvas(HDC hCanvasDC)
+{
+ if (!m_bShow)
+ return;
+
+ RECT rcSelection = m_rc;
+ canvasWindow.ImageToCanvas(rcSelection);
+
+ ::InflateRect(&rcSelection, GRIP_SIZE, GRIP_SIZE);
+ drawSizeBoxes(hCanvasDC, &rcSelection, TRUE);
+}
+
void SelectionModel::StretchSelection(BOOL bShrink)
{
if (!m_bShow)
diff --git a/base/applications/mspaint/selectionmodel.h
b/base/applications/mspaint/selectionmodel.h
index 4fa9e3887dc..f2d3a596823 100644
--- a/base/applications/mspaint/selectionmodel.h
+++ b/base/applications/mspaint/selectionmodel.h
@@ -40,6 +40,7 @@ public:
void HideSelection();
void DeleteSelection();
HITTEST hitTest(POINT ptCanvas);
+ void drawFrameOnCanvas(HDC hCanvasDC);
HBITMAP GetSelectionContents();
void DrawFramePoly(HDC hDCImage);
diff --git a/base/applications/mspaint/toolsmodel.h
b/base/applications/mspaint/toolsmodel.h
index 81af5af3d98..903ac33f632 100644
--- a/base/applications/mspaint/toolsmodel.h
+++ b/base/applications/mspaint/toolsmodel.h
@@ -65,9 +65,6 @@ struct ToolBase
void pushToPtStack(LONG x, LONG y);
static ToolBase* createToolObject(TOOLTYPE type);
-
-protected:
- void OnDrawSelectionOnCanvas(HDC hdc);
};
class ToolsModel