https://git.reactos.org/?p=reactos.git;a=commitdiff;h=e9330371ea76ae46d09f5…
commit e9330371ea76ae46d09f5f850bc8197f01349b1c
Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com>
AuthorDate: Mon Dec 27 23:23:32 2021 +0900
Commit: GitHub <noreply(a)github.com>
CommitDate: Mon Dec 27 23:23:32 2021 +0900
[MSPAINT] Define enum TOOLTYPE and use it (#4197)
Improve code quality and debuggability. CORE-17931
---
base/applications/mspaint/definitions.h | 18 ----------------
base/applications/mspaint/imgarea.cpp | 4 ++++
base/applications/mspaint/mouse.cpp | 33 ++++++++++++++++++++++++++++++
base/applications/mspaint/toolbox.cpp | 32 ++++++++++++++---------------
base/applications/mspaint/toolsettings.cpp | 10 +++++++++
base/applications/mspaint/toolsmodel.cpp | 4 ++--
base/applications/mspaint/toolsmodel.h | 26 ++++++++++++++++++++---
base/applications/mspaint/winproc.cpp | 2 ++
8 files changed, 90 insertions(+), 39 deletions(-)
diff --git a/base/applications/mspaint/definitions.h
b/base/applications/mspaint/definitions.h
index 6d5e7bc109c..26ea4f19549 100644
--- a/base/applications/mspaint/definitions.h
+++ b/base/applications/mspaint/definitions.h
@@ -131,24 +131,6 @@
#define ID_ELLIPSE 614
#define ID_RRECT 615
-/* the following 16 numbers need to be in order, increasing by 1 */
-#define TOOL_FREESEL 1
-#define TOOL_RECTSEL 2
-#define TOOL_RUBBER 3
-#define TOOL_FILL 4
-#define TOOL_COLOR 5
-#define TOOL_ZOOM 6
-#define TOOL_PEN 7
-#define TOOL_BRUSH 8
-#define TOOL_AIRBRUSH 9
-#define TOOL_TEXT 10
-#define TOOL_LINE 11
-#define TOOL_BEZIER 12
-#define TOOL_RECT 13
-#define TOOL_SHAPE 14
-#define TOOL_ELLIPSE 15
-#define TOOL_RRECT 16
-
#define ID_ACCELERATORS 800
#define IDD_MIRRORROTATE 700
diff --git a/base/applications/mspaint/imgarea.cpp
b/base/applications/mspaint/imgarea.cpp
index c5169a2b1cc..d521b6f065d 100644
--- a/base/applications/mspaint/imgarea.cpp
+++ b/base/applications/mspaint/imgarea.cpp
@@ -275,6 +275,8 @@ LRESULT CImgAreaWindow::OnKeyDown(UINT nMsg, WPARAM wParam, LPARAM
lParam, BOOL&
case TOOL_SHAPE: case TOOL_BEZIER:
cancelDrawing();
break;
+ default:
+ break;
}
}
}
@@ -369,6 +371,8 @@ LRESULT CImgAreaWindow::OnMouseMove(UINT nMsg, WPARAM wParam, LPARAM
lParam, BOO
SendMessage(hStatusBar, SB_SETTEXT, 1, (LPARAM) (LPCTSTR) strCoord);
break;
}
+ default:
+ break;
}
if ((wParam & MK_LBUTTON) != 0)
{
diff --git a/base/applications/mspaint/mouse.cpp b/base/applications/mspaint/mouse.cpp
index 8c81c88562c..0720a9fde56 100644
--- a/base/applications/mspaint/mouse.cpp
+++ b/base/applications/mspaint/mouse.cpp
@@ -127,6 +127,9 @@ startPaintingL(HDC hdc, LONG x, LONG y, COLORREF fg, COLORREF bg)
pointSP++;
}
break;
+ case TOOL_COLOR:
+ case TOOL_ZOOM:
+ break;
}
}
@@ -217,6 +220,10 @@ whilePaintingL(HDC hdc, LONG x, LONG y, COLORREF fg, COLORREF bg)
regularize(start.x, start.y, x, y);
RRect(hdc, start.x, start.y, x, y, fg, bg, toolsModel.GetLineWidth(),
toolsModel.GetShapeStyle());
break;
+ case TOOL_FILL:
+ case TOOL_COLOR:
+ case TOOL_ZOOM:
+ break;
}
last.x = x;
@@ -330,6 +337,12 @@ endPaintingL(HDC hdc, LONG x, LONG y, COLORREF fg, COLORREF bg)
regularize(start.x, start.y, x, y);
RRect(hdc, start.x, start.y, x, y, fg, bg, toolsModel.GetLineWidth(),
toolsModel.GetShapeStyle());
break;
+ case TOOL_FILL:
+ case TOOL_COLOR:
+ case TOOL_ZOOM:
+ case TOOL_BRUSH:
+ case TOOL_AIRBRUSH:
+ break;
}
}
@@ -390,6 +403,10 @@ startPaintingR(HDC hdc, LONG x, LONG y, COLORREF fg, COLORREF bg)
pointSP++;
}
break;
+ case TOOL_RECTSEL:
+ case TOOL_COLOR:
+ case TOOL_ZOOM:
+ break;
}
}
@@ -462,6 +479,13 @@ whilePaintingR(HDC hdc, LONG x, LONG y, COLORREF fg, COLORREF bg)
regularize(start.x, start.y, x, y);
RRect(hdc, start.x, start.y, x, y, bg, fg, toolsModel.GetLineWidth(),
toolsModel.GetShapeStyle());
break;
+ case TOOL_FREESEL:
+ case TOOL_RECTSEL:
+ case TOOL_FILL:
+ case TOOL_COLOR:
+ case TOOL_ZOOM:
+ case TOOL_TEXT:
+ break;
}
last.x = x;
@@ -532,5 +556,14 @@ endPaintingR(HDC hdc, LONG x, LONG y, COLORREF fg, COLORREF bg)
regularize(start.x, start.y, x, y);
RRect(hdc, start.x, start.y, x, y, bg, fg, toolsModel.GetLineWidth(),
toolsModel.GetShapeStyle());
break;
+ case TOOL_FREESEL:
+ case TOOL_RECTSEL:
+ case TOOL_FILL:
+ case TOOL_COLOR:
+ case TOOL_ZOOM:
+ case TOOL_BRUSH:
+ case TOOL_AIRBRUSH:
+ case TOOL_TEXT:
+ break;
}
}
diff --git a/base/applications/mspaint/toolbox.cpp
b/base/applications/mspaint/toolbox.cpp
index adfc282cdc9..7e0a3aeeafd 100644
--- a/base/applications/mspaint/toolbox.cpp
+++ b/base/applications/mspaint/toolbox.cpp
@@ -76,52 +76,52 @@ LRESULT CToolBox::OnCommand(UINT nMsg, WPARAM wParam, LPARAM lParam,
BOOL& bHand
switch (LOWORD(wParam))
{
case ID_FREESEL:
- toolsModel.SetActiveTool(1);
+ toolsModel.SetActiveTool(TOOL_FREESEL);
break;
case ID_RECTSEL:
- toolsModel.SetActiveTool(2);
+ toolsModel.SetActiveTool(TOOL_RECTSEL);
break;
case ID_RUBBER:
- toolsModel.SetActiveTool(3);
+ toolsModel.SetActiveTool(TOOL_RUBBER);
break;
case ID_FILL:
- toolsModel.SetActiveTool(4);
+ toolsModel.SetActiveTool(TOOL_FILL);
break;
case ID_COLOR:
- toolsModel.SetActiveTool(5);
+ toolsModel.SetActiveTool(TOOL_COLOR);
break;
case ID_ZOOM:
- toolsModel.SetActiveTool(6);
+ toolsModel.SetActiveTool(TOOL_ZOOM);
break;
case ID_PEN:
- toolsModel.SetActiveTool(7);
+ toolsModel.SetActiveTool(TOOL_PEN);
break;
case ID_BRUSH:
- toolsModel.SetActiveTool(8);
+ toolsModel.SetActiveTool(TOOL_BRUSH);
break;
case ID_AIRBRUSH:
- toolsModel.SetActiveTool(9);
+ toolsModel.SetActiveTool(TOOL_AIRBRUSH);
break;
case ID_TEXT:
- toolsModel.SetActiveTool(10);
+ toolsModel.SetActiveTool(TOOL_TEXT);
break;
case ID_LINE:
- toolsModel.SetActiveTool(11);
+ toolsModel.SetActiveTool(TOOL_LINE);
break;
case ID_BEZIER:
- toolsModel.SetActiveTool(12);
+ toolsModel.SetActiveTool(TOOL_BEZIER);
break;
case ID_RECT:
- toolsModel.SetActiveTool(13);
+ toolsModel.SetActiveTool(TOOL_RECT);
break;
case ID_SHAPE:
- toolsModel.SetActiveTool(14);
+ toolsModel.SetActiveTool(TOOL_SHAPE);
break;
case ID_ELLIPSE:
- toolsModel.SetActiveTool(15);
+ toolsModel.SetActiveTool(TOOL_ELLIPSE);
break;
case ID_RRECT:
- toolsModel.SetActiveTool(16);
+ toolsModel.SetActiveTool(TOOL_RRECT);
break;
}
return 0;
diff --git a/base/applications/mspaint/toolsettings.cpp
b/base/applications/mspaint/toolsettings.cpp
index acda95196e5..4639d81da66 100644
--- a/base/applications/mspaint/toolsettings.cpp
+++ b/base/applications/mspaint/toolsettings.cpp
@@ -175,6 +175,11 @@ LRESULT CToolSettingsWindow::OnPaint(UINT nMsg, WPARAM wParam, LPARAM
lParam, BO
DeleteObject(SelectObject(hdc, oldPen));
break;
}
+ case TOOL_FILL:
+ case TOOL_COLOR:
+ case TOOL_ZOOM:
+ case TOOL_PEN:
+ break;
}
ReleaseDC(hdc);
return 0;
@@ -233,6 +238,11 @@ LRESULT CToolSettingsWindow::OnLButtonDown(UINT nMsg, WPARAM wParam,
LPARAM lPar
if ((y >= 70) && (y <= 132))
toolsModel.SetLineWidth((y - 72) / 12 + 1);
break;
+ case TOOL_FILL:
+ case TOOL_COLOR:
+ case TOOL_ZOOM:
+ case TOOL_PEN:
+ break;
}
return 0;
}
diff --git a/base/applications/mspaint/toolsmodel.cpp
b/base/applications/mspaint/toolsmodel.cpp
index 36a521f7b3d..a0ceaeff1ef 100644
--- a/base/applications/mspaint/toolsmodel.cpp
+++ b/base/applications/mspaint/toolsmodel.cpp
@@ -57,12 +57,12 @@ void ToolsModel::SetBrushStyle(int nBrushStyle)
NotifyToolSettingsChanged();
}
-int ToolsModel::GetActiveTool() const
+TOOLTYPE ToolsModel::GetActiveTool() const
{
return m_activeTool;
}
-void ToolsModel::SetActiveTool(int nActiveTool)
+void ToolsModel::SetActiveTool(TOOLTYPE nActiveTool)
{
m_activeTool = nActiveTool;
NotifyToolChanged();
diff --git a/base/applications/mspaint/toolsmodel.h
b/base/applications/mspaint/toolsmodel.h
index 104da42637c..0fff204d626 100644
--- a/base/applications/mspaint/toolsmodel.h
+++ b/base/applications/mspaint/toolsmodel.h
@@ -8,6 +8,26 @@
#pragma once
+enum TOOLTYPE
+{
+ TOOL_FREESEL = 1,
+ TOOL_RECTSEL = 2,
+ TOOL_RUBBER = 3,
+ TOOL_FILL = 4,
+ TOOL_COLOR = 5,
+ TOOL_ZOOM = 6,
+ TOOL_PEN = 7,
+ TOOL_BRUSH = 8,
+ TOOL_AIRBRUSH = 9,
+ TOOL_TEXT = 10,
+ TOOL_LINE = 11,
+ TOOL_BEZIER = 12,
+ TOOL_RECT = 13,
+ TOOL_SHAPE = 14,
+ TOOL_ELLIPSE = 15,
+ TOOL_RRECT = 16,
+};
+
/* CLASSES **********************************************************/
class ToolsModel
@@ -16,7 +36,7 @@ private:
int m_lineWidth;
int m_shapeStyle;
int m_brushStyle;
- int m_activeTool;
+ TOOLTYPE m_activeTool;
int m_airBrushWidth;
int m_rubberRadius;
BOOL m_transpBg;
@@ -34,8 +54,8 @@ public:
void SetShapeStyle(int nShapeStyle);
int GetBrushStyle() const;
void SetBrushStyle(int nBrushStyle);
- int GetActiveTool() const;
- void SetActiveTool(int nActiveTool);
+ TOOLTYPE GetActiveTool() const;
+ void SetActiveTool(TOOLTYPE nActiveTool);
int GetAirBrushWidth() const;
void SetAirBrushWidth(int nAirBrushWidth);
int GetRubberRadius() const;
diff --git a/base/applications/mspaint/winproc.cpp
b/base/applications/mspaint/winproc.cpp
index dea5e46cdda..1f251449669 100644
--- a/base/applications/mspaint/winproc.cpp
+++ b/base/applications/mspaint/winproc.cpp
@@ -405,6 +405,8 @@ LRESULT CMainWindow::OnKeyDown(UINT nMsg, WPARAM wParam, LPARAM
lParam, BOOL& bH
case TOOL_SHAPE: case TOOL_BEZIER:
imageArea.SendMessage(nMsg, wParam, lParam);
break;
+ default:
+ break;
}
}
}