mirror of
https://github.com/reactos/reactos.git
synced 2025-06-09 20:11:14 +00:00
[MSPAINT] Localize g_ptStart and g_ptEnd into mouse.cpp
And move some ToolsModel code into mouse.cpp CORE-19094
This commit is contained in:
parent
56828b82d9
commit
fa4b38d902
4 changed files with 128 additions and 130 deletions
|
@ -11,8 +11,6 @@
|
||||||
|
|
||||||
extern BOOL g_askBeforeEnlarging;
|
extern BOOL g_askBeforeEnlarging;
|
||||||
|
|
||||||
extern POINT g_ptStart, g_ptEnd;
|
|
||||||
|
|
||||||
extern HINSTANCE g_hinstExe;
|
extern HINSTANCE g_hinstExe;
|
||||||
|
|
||||||
extern WCHAR g_szFileName[MAX_LONG_PATH];
|
extern WCHAR g_szFileName[MAX_LONG_PATH];
|
||||||
|
|
|
@ -10,7 +10,6 @@
|
||||||
#include <dlgs.h>
|
#include <dlgs.h>
|
||||||
#include <mapi.h>
|
#include <mapi.h>
|
||||||
|
|
||||||
POINT g_ptStart, g_ptEnd;
|
|
||||||
BOOL g_askBeforeEnlarging = FALSE; // TODO: initialize from registry
|
BOOL g_askBeforeEnlarging = FALSE; // TODO: initialize from registry
|
||||||
HINSTANCE g_hinstExe = NULL;
|
HINSTANCE g_hinstExe = NULL;
|
||||||
WCHAR g_szFileName[MAX_LONG_PATH] = { 0 };
|
WCHAR g_szFileName[MAX_LONG_PATH] = { 0 };
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
* LICENSE: LGPL-2.0-or-later (https://spdx.org/licenses/LGPL-2.0-or-later)
|
* LICENSE: LGPL-2.0-or-later (https://spdx.org/licenses/LGPL-2.0-or-later)
|
||||||
* PURPOSE: Things which should not be in the mouse event handler itself
|
* PURPOSE: Things which should not be in the mouse event handler itself
|
||||||
* COPYRIGHT: Copyright 2015 Benedikt Freisen <b.freisen@gmx.net>
|
* COPYRIGHT: Copyright 2015 Benedikt Freisen <b.freisen@gmx.net>
|
||||||
* Copyright 2021 Katayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com>
|
* Copyright 2021-2023 Katayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* INCLUDES *********************************************************/
|
/* INCLUDES *********************************************************/
|
||||||
|
@ -12,6 +12,7 @@
|
||||||
|
|
||||||
INT ToolBase::s_pointSP = 0;
|
INT ToolBase::s_pointSP = 0;
|
||||||
POINT ToolBase::s_pointStack[256] = { { 0 } };
|
POINT ToolBase::s_pointStack[256] = { { 0 } };
|
||||||
|
static POINT g_ptStart, g_ptEnd;
|
||||||
|
|
||||||
/* FUNCTIONS ********************************************************/
|
/* FUNCTIONS ********************************************************/
|
||||||
|
|
||||||
|
@ -1097,3 +1098,129 @@ ToolBase::createToolObject(TOOLTYPE type)
|
||||||
UNREACHABLE;
|
UNREACHABLE;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ToolsModel::OnButtonDown(BOOL bLeftButton, LONG x, LONG y, BOOL bDoubleClick)
|
||||||
|
{
|
||||||
|
m_pToolObject->beginEvent();
|
||||||
|
g_ptStart.x = g_ptEnd.x = x;
|
||||||
|
g_ptStart.y = g_ptEnd.y = y;
|
||||||
|
m_pToolObject->OnButtonDown(bLeftButton, x, y, bDoubleClick);
|
||||||
|
m_pToolObject->endEvent();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ToolsModel::OnMouseMove(BOOL bLeftButton, LONG x, LONG y)
|
||||||
|
{
|
||||||
|
m_pToolObject->beginEvent();
|
||||||
|
if (m_pToolObject->OnMouseMove(bLeftButton, x, y))
|
||||||
|
{
|
||||||
|
g_ptEnd.x = x;
|
||||||
|
g_ptEnd.y = y;
|
||||||
|
}
|
||||||
|
m_pToolObject->endEvent();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ToolsModel::OnButtonUp(BOOL bLeftButton, LONG x, LONG y)
|
||||||
|
{
|
||||||
|
m_pToolObject->beginEvent();
|
||||||
|
if (m_pToolObject->OnButtonUp(bLeftButton, x, y))
|
||||||
|
{
|
||||||
|
g_ptEnd.x = x;
|
||||||
|
g_ptEnd.y = y;
|
||||||
|
}
|
||||||
|
m_pToolObject->endEvent();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ToolsModel::OnEndDraw(BOOL bCancel)
|
||||||
|
{
|
||||||
|
ATLTRACE("ToolsModel::OnEndDraw(%d)\n", bCancel);
|
||||||
|
m_pToolObject->beginEvent();
|
||||||
|
m_pToolObject->OnEndDraw(bCancel);
|
||||||
|
m_pToolObject->endEvent();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ToolsModel::OnDrawOverlayOnImage(HDC hdc)
|
||||||
|
{
|
||||||
|
m_pToolObject->OnDrawOverlayOnImage(hdc);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ToolsModel::OnDrawOverlayOnCanvas(HDC hdc)
|
||||||
|
{
|
||||||
|
m_pToolObject->OnDrawOverlayOnCanvas(hdc);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ToolsModel::SpecialTweak(BOOL bMinus)
|
||||||
|
{
|
||||||
|
m_pToolObject->OnSpecialTweak(bMinus);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ToolsModel::DrawWithMouseTool(POINT pt, WPARAM wParam)
|
||||||
|
{
|
||||||
|
LONG xRel = pt.x - g_ptStart.x, yRel = pt.y - g_ptStart.y;
|
||||||
|
|
||||||
|
switch (m_activeTool)
|
||||||
|
{
|
||||||
|
// freesel, rectsel and text tools always show numbers limited to fit into image area
|
||||||
|
case TOOL_FREESEL:
|
||||||
|
case TOOL_RECTSEL:
|
||||||
|
case TOOL_TEXT:
|
||||||
|
if (xRel < 0)
|
||||||
|
xRel = (pt.x < 0) ? -g_ptStart.x : xRel;
|
||||||
|
else if (pt.x > imageModel.GetWidth())
|
||||||
|
xRel = imageModel.GetWidth() - g_ptStart.x;
|
||||||
|
if (yRel < 0)
|
||||||
|
yRel = (pt.y < 0) ? -g_ptStart.y : yRel;
|
||||||
|
else if (pt.y > imageModel.GetHeight())
|
||||||
|
yRel = imageModel.GetHeight() - g_ptStart.y;
|
||||||
|
break;
|
||||||
|
|
||||||
|
// while drawing, update cursor coordinates only for tools 3, 7, 8, 9, 14
|
||||||
|
case TOOL_RUBBER:
|
||||||
|
case TOOL_PEN:
|
||||||
|
case TOOL_BRUSH:
|
||||||
|
case TOOL_AIRBRUSH:
|
||||||
|
case TOOL_SHAPE:
|
||||||
|
{
|
||||||
|
CStringW strCoord;
|
||||||
|
strCoord.Format(L"%ld, %ld", pt.x, pt.y);
|
||||||
|
::SendMessageW(g_hStatusBar, SB_SETTEXT, 1, (LPARAM)(LPCWSTR)strCoord);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// rectsel and shape tools always show non-negative numbers when drawing
|
||||||
|
if (m_activeTool == TOOL_RECTSEL || m_activeTool == TOOL_SHAPE)
|
||||||
|
{
|
||||||
|
xRel = labs(xRel);
|
||||||
|
yRel = labs(yRel);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (wParam & MK_LBUTTON)
|
||||||
|
{
|
||||||
|
OnMouseMove(TRUE, pt.x, pt.y);
|
||||||
|
canvasWindow.Invalidate(FALSE);
|
||||||
|
if ((m_activeTool >= TOOL_TEXT) || IsSelection())
|
||||||
|
{
|
||||||
|
CStringW strSize;
|
||||||
|
if ((m_activeTool >= TOOL_LINE) && (GetAsyncKeyState(VK_SHIFT) < 0))
|
||||||
|
yRel = xRel;
|
||||||
|
strSize.Format(L"%ld x %ld", xRel, yRel);
|
||||||
|
::SendMessageW(g_hStatusBar, SB_SETTEXT, 2, (LPARAM)(LPCWSTR)strSize);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (wParam & MK_RBUTTON)
|
||||||
|
{
|
||||||
|
OnMouseMove(FALSE, pt.x, pt.y);
|
||||||
|
canvasWindow.Invalidate(FALSE);
|
||||||
|
if (m_activeTool >= TOOL_TEXT)
|
||||||
|
{
|
||||||
|
CStringW strSize;
|
||||||
|
if ((m_activeTool >= TOOL_LINE) && (GetAsyncKeyState(VK_SHIFT) < 0))
|
||||||
|
yRel = xRel;
|
||||||
|
strSize.Format(L"%ld x %ld", xRel, yRel);
|
||||||
|
::SendMessageW(g_hStatusBar, SB_SETTEXT, 2, (LPARAM)(LPCWSTR)strSize);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -255,55 +255,6 @@ void ToolsModel::NotifyZoomChanged()
|
||||||
canvasWindow.SendMessage(WM_TOOLSMODELZOOMCHANGED);
|
canvasWindow.SendMessage(WM_TOOLSMODELZOOMCHANGED);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ToolsModel::OnButtonDown(BOOL bLeftButton, LONG x, LONG y, BOOL bDoubleClick)
|
|
||||||
{
|
|
||||||
m_pToolObject->beginEvent();
|
|
||||||
g_ptStart.x = g_ptEnd.x = x;
|
|
||||||
g_ptStart.y = g_ptEnd.y = y;
|
|
||||||
m_pToolObject->OnButtonDown(bLeftButton, x, y, bDoubleClick);
|
|
||||||
m_pToolObject->endEvent();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ToolsModel::OnMouseMove(BOOL bLeftButton, LONG x, LONG y)
|
|
||||||
{
|
|
||||||
m_pToolObject->beginEvent();
|
|
||||||
if (m_pToolObject->OnMouseMove(bLeftButton, x, y))
|
|
||||||
{
|
|
||||||
g_ptEnd.x = x;
|
|
||||||
g_ptEnd.y = y;
|
|
||||||
}
|
|
||||||
m_pToolObject->endEvent();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ToolsModel::OnButtonUp(BOOL bLeftButton, LONG x, LONG y)
|
|
||||||
{
|
|
||||||
m_pToolObject->beginEvent();
|
|
||||||
if (m_pToolObject->OnButtonUp(bLeftButton, x, y))
|
|
||||||
{
|
|
||||||
g_ptEnd.x = x;
|
|
||||||
g_ptEnd.y = y;
|
|
||||||
}
|
|
||||||
m_pToolObject->endEvent();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ToolsModel::OnEndDraw(BOOL bCancel)
|
|
||||||
{
|
|
||||||
ATLTRACE("ToolsModel::OnEndDraw(%d)\n", bCancel);
|
|
||||||
m_pToolObject->beginEvent();
|
|
||||||
m_pToolObject->OnEndDraw(bCancel);
|
|
||||||
m_pToolObject->endEvent();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ToolsModel::OnDrawOverlayOnImage(HDC hdc)
|
|
||||||
{
|
|
||||||
m_pToolObject->OnDrawOverlayOnImage(hdc);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ToolsModel::OnDrawOverlayOnCanvas(HDC hdc)
|
|
||||||
{
|
|
||||||
m_pToolObject->OnDrawOverlayOnCanvas(hdc);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ToolsModel::resetTool()
|
void ToolsModel::resetTool()
|
||||||
{
|
{
|
||||||
m_pToolObject->reset();
|
m_pToolObject->reset();
|
||||||
|
@ -316,80 +267,3 @@ void ToolsModel::selectAll()
|
||||||
OnMouseMove(TRUE, imageModel.GetWidth(), imageModel.GetHeight());
|
OnMouseMove(TRUE, imageModel.GetWidth(), imageModel.GetHeight());
|
||||||
OnButtonUp(TRUE, imageModel.GetWidth(), imageModel.GetHeight());
|
OnButtonUp(TRUE, imageModel.GetWidth(), imageModel.GetHeight());
|
||||||
}
|
}
|
||||||
|
|
||||||
void ToolsModel::SpecialTweak(BOOL bMinus)
|
|
||||||
{
|
|
||||||
m_pToolObject->OnSpecialTweak(bMinus);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ToolsModel::DrawWithMouseTool(POINT pt, WPARAM wParam)
|
|
||||||
{
|
|
||||||
LONG xRel = pt.x - g_ptStart.x, yRel = pt.y - g_ptStart.y;
|
|
||||||
|
|
||||||
switch (m_activeTool)
|
|
||||||
{
|
|
||||||
// freesel, rectsel and text tools always show numbers limited to fit into image area
|
|
||||||
case TOOL_FREESEL:
|
|
||||||
case TOOL_RECTSEL:
|
|
||||||
case TOOL_TEXT:
|
|
||||||
if (xRel < 0)
|
|
||||||
xRel = (pt.x < 0) ? -g_ptStart.x : xRel;
|
|
||||||
else if (pt.x > imageModel.GetWidth())
|
|
||||||
xRel = imageModel.GetWidth() - g_ptStart.x;
|
|
||||||
if (yRel < 0)
|
|
||||||
yRel = (pt.y < 0) ? -g_ptStart.y : yRel;
|
|
||||||
else if (pt.y > imageModel.GetHeight())
|
|
||||||
yRel = imageModel.GetHeight() - g_ptStart.y;
|
|
||||||
break;
|
|
||||||
|
|
||||||
// while drawing, update cursor coordinates only for tools 3, 7, 8, 9, 14
|
|
||||||
case TOOL_RUBBER:
|
|
||||||
case TOOL_PEN:
|
|
||||||
case TOOL_BRUSH:
|
|
||||||
case TOOL_AIRBRUSH:
|
|
||||||
case TOOL_SHAPE:
|
|
||||||
{
|
|
||||||
CStringW strCoord;
|
|
||||||
strCoord.Format(L"%ld, %ld", pt.x, pt.y);
|
|
||||||
::SendMessageW(g_hStatusBar, SB_SETTEXT, 1, (LPARAM)(LPCWSTR)strCoord);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// rectsel and shape tools always show non-negative numbers when drawing
|
|
||||||
if (m_activeTool == TOOL_RECTSEL || m_activeTool == TOOL_SHAPE)
|
|
||||||
{
|
|
||||||
xRel = labs(xRel);
|
|
||||||
yRel = labs(yRel);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (wParam & MK_LBUTTON)
|
|
||||||
{
|
|
||||||
OnMouseMove(TRUE, pt.x, pt.y);
|
|
||||||
canvasWindow.Invalidate(FALSE);
|
|
||||||
if ((m_activeTool >= TOOL_TEXT) || IsSelection())
|
|
||||||
{
|
|
||||||
CStringW strSize;
|
|
||||||
if ((m_activeTool >= TOOL_LINE) && (GetAsyncKeyState(VK_SHIFT) < 0))
|
|
||||||
yRel = xRel;
|
|
||||||
strSize.Format(L"%ld x %ld", xRel, yRel);
|
|
||||||
::SendMessageW(g_hStatusBar, SB_SETTEXT, 2, (LPARAM)(LPCWSTR)strSize);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (wParam & MK_RBUTTON)
|
|
||||||
{
|
|
||||||
OnMouseMove(FALSE, pt.x, pt.y);
|
|
||||||
canvasWindow.Invalidate(FALSE);
|
|
||||||
if (m_activeTool >= TOOL_TEXT)
|
|
||||||
{
|
|
||||||
CStringW strSize;
|
|
||||||
if ((m_activeTool >= TOOL_LINE) && (GetAsyncKeyState(VK_SHIFT) < 0))
|
|
||||||
yRel = xRel;
|
|
||||||
strSize.Format(L"%ld x %ld", xRel, yRel);
|
|
||||||
::SendMessageW(g_hStatusBar, SB_SETTEXT, 2, (LPARAM)(LPCWSTR)strSize);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue