https://git.reactos.org/?p=reactos.git;a=commitdiff;h=eacf003c816335e79ab58…
commit eacf003c816335e79ab583f1af7a900aef0642c5
Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com>
AuthorDate: Fri Mar 17 07:51:12 2023 +0900
Commit: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com>
CommitDate: Fri Mar 17 07:51:12 2023 +0900
[MSPAINT] Move UpdateCanvas's code to newly-defined CCanvasWindow::Update
CORE-18867
---
base/applications/mspaint/canvas.cpp | 25 ++++++++++++-------------
base/applications/mspaint/canvas.h | 5 +++--
base/applications/mspaint/imgarea.cpp | 4 ++--
3 files changed, 17 insertions(+), 17 deletions(-)
diff --git a/base/applications/mspaint/canvas.cpp b/base/applications/mspaint/canvas.cpp
index 1293471ddbf..49249373ab8 100644
--- a/base/applications/mspaint/canvas.cpp
+++ b/base/applications/mspaint/canvas.cpp
@@ -13,23 +13,22 @@
/* FUNCTIONS ********************************************************/
-void
-UpdateCanvas(HWND hwndFrom)
+VOID CCanvasWindow::Update(HWND hwndFrom)
{
CRect tempRect;
- canvasWindow.GetClientRect(&tempRect);
+ GetClientRect(&tempRect);
CSize sizeScrollBox(tempRect.Width(), tempRect.Height());
CSize sizeZoomed = { Zoomed(imageModel.GetWidth()), Zoomed(imageModel.GetHeight())
};
CSize sizeWhole = { sizeZoomed.cx + (GRIP_SIZE * 2), sizeZoomed.cy + (GRIP_SIZE * 2)
};
/* show/hide the scrollbars */
- canvasWindow.ShowScrollBar(SB_HORZ, sizeScrollBox.cx < sizeWhole.cx);
- canvasWindow.ShowScrollBar(SB_VERT, sizeScrollBox.cy < sizeWhole.cy);
+ ShowScrollBar(SB_HORZ, sizeScrollBox.cx < sizeWhole.cx);
+ ShowScrollBar(SB_VERT, sizeScrollBox.cy < sizeWhole.cy);
if (sizeScrollBox.cx < sizeWhole.cx || sizeScrollBox.cy < sizeWhole.cy)
{
- canvasWindow.GetClientRect(&tempRect);
+ GetClientRect(&tempRect);
sizeScrollBox = CSize(tempRect.Width(), tempRect.Height());
}
@@ -38,14 +37,14 @@ UpdateCanvas(HWND hwndFrom)
si.nMax = sizeWhole.cx;
si.nPage = sizeScrollBox.cx;
- canvasWindow.SetScrollInfo(SB_HORZ, &si);
+ SetScrollInfo(SB_HORZ, &si);
si.nMax = sizeWhole.cy;
si.nPage = sizeScrollBox.cy;
- canvasWindow.SetScrollInfo(SB_VERT, &si);
+ SetScrollInfo(SB_VERT, &si);
- INT dx = -canvasWindow.GetScrollPos(SB_HORZ);
- INT dy = -canvasWindow.GetScrollPos(SB_VERT);
+ INT dx = -GetScrollPos(SB_HORZ);
+ INT dy = -GetScrollPos(SB_VERT);
if (sizeboxLeftTop.IsWindow())
{
@@ -81,7 +80,7 @@ LRESULT CCanvasWindow::OnSize(UINT nMsg, WPARAM wParam, LPARAM lParam,
BOOL& bHa
{
if (m_hWnd)
{
- UpdateCanvas(m_hWnd);
+ Update(m_hWnd);
}
return 0;
}
@@ -112,7 +111,7 @@ LRESULT CCanvasWindow::OnHScroll(UINT nMsg, WPARAM wParam, LPARAM
lParam, BOOL&
break;
}
SetScrollInfo(SB_HORZ, &si);
- UpdateCanvas(m_hWnd);
+ Update(m_hWnd);
return 0;
}
@@ -142,7 +141,7 @@ LRESULT CCanvasWindow::OnVScroll(UINT nMsg, WPARAM wParam, LPARAM
lParam, BOOL&
break;
}
SetScrollInfo(SB_VERT, &si);
- UpdateCanvas(m_hWnd);
+ Update(m_hWnd);
return 0;
}
diff --git a/base/applications/mspaint/canvas.h b/base/applications/mspaint/canvas.h
index b97d43a497d..22613518857 100644
--- a/base/applications/mspaint/canvas.h
+++ b/base/applications/mspaint/canvas.h
@@ -21,11 +21,12 @@ public:
MESSAGE_HANDLER(WM_MOUSEWHEEL, OnMouseWheel)
END_MSG_MAP()
+ VOID Update(HWND hwndFrom);
+
+protected:
LRESULT OnSize(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnHScroll(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnVScroll(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnLButtonDown(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnMouseWheel(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
};
-
-void UpdateCanvas(HWND hwndFrom);
diff --git a/base/applications/mspaint/imgarea.cpp
b/base/applications/mspaint/imgarea.cpp
index 22264f9bdce..1d8b05024ce 100644
--- a/base/applications/mspaint/imgarea.cpp
+++ b/base/applications/mspaint/imgarea.cpp
@@ -54,7 +54,7 @@ LRESULT CImgAreaWindow::OnSize(UINT nMsg, WPARAM wParam, LPARAM lParam,
BOOL& bH
{
if (!IsWindow())
return 0;
- UpdateCanvas(NULL);
+ canvasWindow.Update(NULL);
return 0;
}
@@ -346,7 +346,7 @@ LRESULT CImgAreaWindow::OnMouseLeave(UINT nMsg, WPARAM wParam, LPARAM
lParam, BO
LRESULT CImgAreaWindow::OnImageModelDimensionsChanged(UINT nMsg, WPARAM wParam, LPARAM
lParam, BOOL& bHandled)
{
- UpdateCanvas(NULL);
+ canvasWindow.Update(NULL);
return 0;
}