[MSPAINT] Rename scrollbox as canvas

- s/CScrollboxWindow/CCanvasWindow/
- s/scrollboxWindow/canvasWindow/
- s/UpdateScrollbox/UpdateCanvas/
CORE-18867
This commit is contained in:
Katayama Hirofumi MZ 2023-03-17 07:45:14 +09:00
parent a88dcbd6c3
commit 7361592ede
8 changed files with 59 additions and 59 deletions

View file

@ -7,6 +7,7 @@ if(DBG)
endif()
list(APPEND SOURCE
canvas.cpp
dialogs.cpp
dib.cpp
drawing.cpp
@ -19,7 +20,6 @@ list(APPEND SOURCE
palette.cpp
palettemodel.cpp
registry.cpp
scrollbox.cpp
selection.cpp
selectionmodel.cpp
sizebox.cpp

View file

@ -1,8 +1,8 @@
/*
* PROJECT: PAINT for ReactOS
* LICENSE: LGPL
* FILE: base/applications/mspaint/scrollbox.cpp
* PURPOSE: Functionality surrounding the scroll box window class
* FILE: base/applications/mspaint/canvas.cpp
* PURPOSE: Providing the canvas window class
* PROGRAMMERS: Benedikt Freisen
*/
@ -14,22 +14,22 @@
/* FUNCTIONS ********************************************************/
void
UpdateScrollbox(HWND hwndFrom)
UpdateCanvas(HWND hwndFrom)
{
CRect tempRect;
scrollboxWindow.GetClientRect(&tempRect);
canvasWindow.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 */
scrollboxWindow.ShowScrollBar(SB_HORZ, sizeScrollBox.cx < sizeWhole.cx);
scrollboxWindow.ShowScrollBar(SB_VERT, sizeScrollBox.cy < sizeWhole.cy);
canvasWindow.ShowScrollBar(SB_HORZ, sizeScrollBox.cx < sizeWhole.cx);
canvasWindow.ShowScrollBar(SB_VERT, sizeScrollBox.cy < sizeWhole.cy);
if (sizeScrollBox.cx < sizeWhole.cx || sizeScrollBox.cy < sizeWhole.cy)
{
scrollboxWindow.GetClientRect(&tempRect);
canvasWindow.GetClientRect(&tempRect);
sizeScrollBox = CSize(tempRect.Width(), tempRect.Height());
}
@ -38,14 +38,14 @@ UpdateScrollbox(HWND hwndFrom)
si.nMax = sizeWhole.cx;
si.nPage = sizeScrollBox.cx;
scrollboxWindow.SetScrollInfo(SB_HORZ, &si);
canvasWindow.SetScrollInfo(SB_HORZ, &si);
si.nMax = sizeWhole.cy;
si.nPage = sizeScrollBox.cy;
scrollboxWindow.SetScrollInfo(SB_VERT, &si);
canvasWindow.SetScrollInfo(SB_VERT, &si);
INT dx = -scrollboxWindow.GetScrollPos(SB_HORZ);
INT dy = -scrollboxWindow.GetScrollPos(SB_VERT);
INT dx = -canvasWindow.GetScrollPos(SB_HORZ);
INT dy = -canvasWindow.GetScrollPos(SB_VERT);
if (sizeboxLeftTop.IsWindow())
{
@ -77,16 +77,16 @@ UpdateScrollbox(HWND hwndFrom)
imageArea.MoveWindow(dx + GRIP_SIZE, dy + GRIP_SIZE, sizeZoomed.cx, sizeZoomed.cy, TRUE);
}
LRESULT CScrollboxWindow::OnSize(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
LRESULT CCanvasWindow::OnSize(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
if (m_hWnd)
{
UpdateScrollbox(m_hWnd);
UpdateCanvas(m_hWnd);
}
return 0;
}
LRESULT CScrollboxWindow::OnHScroll(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
LRESULT CCanvasWindow::OnHScroll(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
SCROLLINFO si;
si.cbSize = sizeof(SCROLLINFO);
@ -112,11 +112,11 @@ LRESULT CScrollboxWindow::OnHScroll(UINT nMsg, WPARAM wParam, LPARAM lParam, BOO
break;
}
SetScrollInfo(SB_HORZ, &si);
UpdateScrollbox(m_hWnd);
UpdateCanvas(m_hWnd);
return 0;
}
LRESULT CScrollboxWindow::OnVScroll(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
LRESULT CCanvasWindow::OnVScroll(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
SCROLLINFO si;
si.cbSize = sizeof(SCROLLINFO);
@ -142,11 +142,11 @@ LRESULT CScrollboxWindow::OnVScroll(UINT nMsg, WPARAM wParam, LPARAM lParam, BOO
break;
}
SetScrollInfo(SB_VERT, &si);
UpdateScrollbox(m_hWnd);
UpdateCanvas(m_hWnd);
return 0;
}
LRESULT CScrollboxWindow::OnLButtonDown(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
LRESULT CCanvasWindow::OnLButtonDown(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
switch (toolsModel.GetActiveTool())
{
@ -167,7 +167,7 @@ LRESULT CScrollboxWindow::OnLButtonDown(UINT nMsg, WPARAM wParam, LPARAM lParam,
return 0;
}
LRESULT CScrollboxWindow::OnMouseWheel(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
LRESULT CCanvasWindow::OnMouseWheel(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
return ::SendMessage(GetParent(), nMsg, wParam, lParam);
}

View file

@ -1,19 +1,19 @@
/*
* PROJECT: PAINT for ReactOS
* LICENSE: LGPL
* FILE: base/applications/mspaint/scrollbox.h
* PURPOSE: Functionality surrounding the scroll box window class
* FILE: base/applications/mspaint/canvas.h
* PURPOSE: Providing the canvas window class
* PROGRAMMERS: Benedikt Freisen
*/
#pragma once
class CScrollboxWindow : public CWindowImpl<CScrollboxWindow>
class CCanvasWindow : public CWindowImpl<CCanvasWindow>
{
public:
DECLARE_WND_CLASS_EX(_T("Scrollbox"), 0, COLOR_APPWORKSPACE)
DECLARE_WND_CLASS_EX(_T("ReactOSPaintCanvas"), 0, COLOR_APPWORKSPACE)
BEGIN_MSG_MAP(CScrollboxWindow)
BEGIN_MSG_MAP(CCanvasWindow)
MESSAGE_HANDLER(WM_SIZE, OnSize)
MESSAGE_HANDLER(WM_HSCROLL, OnHScroll)
MESSAGE_HANDLER(WM_VSCROLL, OnVScroll)
@ -28,4 +28,4 @@ public:
LRESULT OnMouseWheel(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
};
void UpdateScrollbox(HWND hwndFrom);
void UpdateCanvas(HWND hwndFrom);

View file

@ -61,7 +61,7 @@ class CMiniatureWindow;
class CToolBox;
class CToolSettingsWindow;
class CPaletteWindow;
class CScrollboxWindow;
class CCanvasWindow;
class CSelectionWindow;
class CImgAreaWindow;
class CSizeboxWindow;
@ -73,7 +73,7 @@ extern CMiniatureWindow miniature;
extern CToolBox toolBoxContainer;
extern CToolSettingsWindow toolSettingsWindow;
extern CPaletteWindow paletteWindow;
extern CScrollboxWindow scrollboxWindow;
extern CCanvasWindow canvasWindow;
extern CSelectionWindow selectionWindow;
extern CImgAreaWindow imageArea;
extern CSizeboxWindow sizeboxLeftTop;

View file

@ -22,10 +22,10 @@ void CImgAreaWindow::drawZoomFrame(int mouseX, int mouseY)
LOGBRUSH logbrush;
int rop;
RECT clientRectScrollbox;
RECT clientRectCanvas;
RECT clientRectImageArea;
int x, y, w, h;
scrollboxWindow.GetClientRect(&clientRectScrollbox);
canvasWindow.GetClientRect(&clientRectCanvas);
GetClientRect(&clientRectImageArea);
w = clientRectImageArea.right * 2;
h = clientRectImageArea.bottom * 2;
@ -33,8 +33,8 @@ void CImgAreaWindow::drawZoomFrame(int mouseX, int mouseY)
{
return;
}
w = clientRectImageArea.right * clientRectScrollbox.right / w;
h = clientRectImageArea.bottom * clientRectScrollbox.bottom / h;
w = clientRectImageArea.right * clientRectCanvas.right / w;
h = clientRectImageArea.bottom * clientRectCanvas.bottom / h;
x = max(0, min(clientRectImageArea.right - w, mouseX - w / 2));
y = max(0, min(clientRectImageArea.bottom - h, mouseY - h / 2));
@ -54,7 +54,7 @@ LRESULT CImgAreaWindow::OnSize(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bH
{
if (!IsWindow())
return 0;
UpdateScrollbox(NULL);
UpdateCanvas(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)
{
UpdateScrollbox(NULL);
UpdateCanvas(NULL);
return 0;
}

View file

@ -60,7 +60,7 @@ CMiniatureWindow miniature;
CToolBox toolBoxContainer;
CToolSettingsWindow toolSettingsWindow;
CPaletteWindow paletteWindow;
CScrollboxWindow scrollboxWindow;
CCanvasWindow canvasWindow;
CSelectionWindow selectionWindow;
CImgAreaWindow imageArea;
CSizeboxWindow sizeboxLeftTop;
@ -223,9 +223,9 @@ _tWinMain (HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPTSTR lpszArgument
RECT paletteWindowPos = {56, 9, 56 + 255, 9 + 32};
paletteWindow.Create(hwnd, paletteWindowPos, NULL, WS_CHILD | WS_VISIBLE);
/* creating the scroll box */
RECT scrollboxWindowPos = {0, 0, 0 + 500, 0 + 500};
scrollboxWindow.Create(hwnd, scrollboxWindowPos, NULL,
// creating the canvas
RECT canvasWindowPos = {0, 0, 0 + 500, 0 + 500};
canvasWindow.Create(hwnd, canvasWindowPos, NULL,
WS_CHILD | WS_GROUP | WS_HSCROLL | WS_VSCROLL | WS_VISIBLE, WS_EX_CLIENTEDGE);
/* creating the status bar */
@ -236,9 +236,9 @@ _tWinMain (HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPTSTR lpszArgument
if (registrySettings.ShowStatusBar)
ShowWindow(hStatusBar, SW_SHOWNOACTIVATE);
// Creating the window inside the scroll box
// Creating the window inside the canvas
RECT imageAreaPos = {GRIP_SIZE, GRIP_SIZE, GRIP_SIZE + imageModel.GetWidth(), GRIP_SIZE + imageModel.GetHeight()};
imageArea.Create(scrollboxWindow.m_hWnd, imageAreaPos, NULL, WS_CHILD | WS_VISIBLE);
imageArea.Create(canvasWindow.m_hWnd, imageAreaPos, NULL, WS_CHILD | WS_VISIBLE);
/* create selection window (initially hidden) */
RECT selectionWindowPos = {350, 0, 350 + 100, 0 + 100};
@ -308,14 +308,14 @@ _tWinMain (HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPTSTR lpszArgument
/* creating the size boxes */
RECT sizeboxPos = {0, 0, GRIP_SIZE, GRIP_SIZE};
sizeboxLeftTop.Create(scrollboxWindow.m_hWnd, sizeboxPos, NULL, WS_CHILD | WS_VISIBLE);
sizeboxCenterTop.Create(scrollboxWindow.m_hWnd, sizeboxPos, NULL, WS_CHILD | WS_VISIBLE);
sizeboxRightTop.Create(scrollboxWindow.m_hWnd, sizeboxPos, NULL, WS_CHILD | WS_VISIBLE);
sizeboxLeftCenter.Create(scrollboxWindow.m_hWnd, sizeboxPos, NULL, WS_CHILD | WS_VISIBLE);
sizeboxRightCenter.Create(scrollboxWindow.m_hWnd, sizeboxPos, NULL, WS_CHILD | WS_VISIBLE);
sizeboxLeftBottom.Create(scrollboxWindow.m_hWnd, sizeboxPos, NULL, WS_CHILD | WS_VISIBLE);
sizeboxCenterBottom.Create(scrollboxWindow.m_hWnd, sizeboxPos, NULL, WS_CHILD | WS_VISIBLE);
sizeboxRightBottom.Create(scrollboxWindow.m_hWnd, sizeboxPos, NULL, WS_CHILD | WS_VISIBLE);
sizeboxLeftTop.Create(canvasWindow, sizeboxPos, NULL, WS_CHILD | WS_VISIBLE);
sizeboxCenterTop.Create(canvasWindow, sizeboxPos, NULL, WS_CHILD | WS_VISIBLE);
sizeboxRightTop.Create(canvasWindow, sizeboxPos, NULL, WS_CHILD | WS_VISIBLE);
sizeboxLeftCenter.Create(canvasWindow, sizeboxPos, NULL, WS_CHILD | WS_VISIBLE);
sizeboxRightCenter.Create(canvasWindow, sizeboxPos, NULL, WS_CHILD | WS_VISIBLE);
sizeboxLeftBottom.Create(canvasWindow, sizeboxPos, NULL, WS_CHILD | WS_VISIBLE);
sizeboxCenterBottom.Create(canvasWindow, sizeboxPos, NULL, WS_CHILD | WS_VISIBLE);
sizeboxRightBottom.Create(canvasWindow, sizeboxPos, NULL, WS_CHILD | WS_VISIBLE);
/* placing the size boxes around the image */
imageArea.SendMessage(WM_SIZE, 0, 0);

View file

@ -39,6 +39,7 @@
#define WM_SELECTIONMODELREFRESHNEEDED (WM_APP + 7)
#include "resource.h"
#include "canvas.h"
#include "drawing.h"
#include "dib.h"
#include "fullscreen.h"
@ -49,7 +50,6 @@
#include "palette.h"
#include "palettemodel.h"
#include "registry.h"
#include "scrollbox.h"
#include "selection.h"
#include "selectionmodel.h"
#include "sizebox.h"

View file

@ -46,7 +46,7 @@ zoomTo(int newZoom, int mouseX, int mouseY)
RECT clientRectScrollbox;
RECT clientRectImageArea;
int x, y, w, h;
scrollboxWindow.GetClientRect(&clientRectScrollbox);
canvasWindow.GetClientRect(&clientRectScrollbox);
imageArea.GetClientRect(&clientRectImageArea);
w = clientRectImageArea.right * newZoom / toolsModel.GetZoom();
h = clientRectImageArea.bottom * newZoom / toolsModel.GetZoom();
@ -62,11 +62,11 @@ zoomTo(int newZoom, int mouseX, int mouseY)
toolsModel.SetZoom(newZoom);
imageArea.MoveWindow(GRIP_SIZE, GRIP_SIZE, Zoomed(imageModel.GetWidth()), Zoomed(imageModel.GetHeight()), FALSE);
scrollboxWindow.Invalidate(TRUE);
canvasWindow.Invalidate(TRUE);
imageArea.Invalidate(FALSE);
scrollboxWindow.SendMessage(WM_HSCROLL, MAKEWPARAM(SB_THUMBPOSITION, x), 0);
scrollboxWindow.SendMessage(WM_VSCROLL, MAKEWPARAM(SB_THUMBPOSITION, y), 0);
canvasWindow.SendMessage(WM_HSCROLL, MAKEWPARAM(SB_THUMBPOSITION, x), 0);
canvasWindow.SendMessage(WM_VSCROLL, MAKEWPARAM(SB_THUMBPOSITION, y), 0);
return TRUE;
}
@ -102,9 +102,9 @@ void CMainWindow::alignChildrenToMainWindow()
rcSpace.top += CY_PALETTE;
}
if (scrollboxWindow.IsWindow())
if (canvasWindow.IsWindow())
{
hDWP = ::DeferWindowPos(hDWP, scrollboxWindow, NULL,
hDWP = ::DeferWindowPos(hDWP, canvasWindow, NULL,
rcSpace.left, rcSpace.top,
rcSpace.right - rcSpace.left, rcSpace.bottom - rcSpace.top,
SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOREPOSITION);
@ -216,9 +216,9 @@ LRESULT CMainWindow::OnMouseWheel(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL&
for (UINT i = 0; i < nCount; ++i)
{
if (zDelta < 0)
::PostMessageW(scrollboxWindow, WM_HSCROLL, MAKEWPARAM(SB_LINEDOWN, 0), 0);
::PostMessageW(canvasWindow, WM_HSCROLL, MAKEWPARAM(SB_LINEDOWN, 0), 0);
else if (zDelta > 0)
::PostMessageW(scrollboxWindow, WM_HSCROLL, MAKEWPARAM(SB_LINEUP, 0), 0);
::PostMessageW(canvasWindow, WM_HSCROLL, MAKEWPARAM(SB_LINEUP, 0), 0);
}
}
else
@ -227,9 +227,9 @@ LRESULT CMainWindow::OnMouseWheel(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL&
for (UINT i = 0; i < nCount; ++i)
{
if (zDelta < 0)
::PostMessageW(scrollboxWindow, WM_VSCROLL, MAKEWPARAM(SB_LINEDOWN, 0), 0);
::PostMessageW(canvasWindow, WM_VSCROLL, MAKEWPARAM(SB_LINEDOWN, 0), 0);
else if (zDelta > 0)
::PostMessageW(scrollboxWindow, WM_VSCROLL, MAKEWPARAM(SB_LINEUP, 0), 0);
::PostMessageW(canvasWindow, WM_VSCROLL, MAKEWPARAM(SB_LINEUP, 0), 0);
}
}
}