• R/O
  • SSH
  • HTTPS

tortoisesvn: Commit


Commit MetaInfo

Revisão29189 (tree)
Hora2021-05-04 02:31:52
Autorstefankueng

Mensagem de Log

cleanup ui files

Mudança Sumário

Diff

--- trunk/src/TortoiseProc/CommitDlg.cpp (revision 29188)
+++ trunk/src/TortoiseProc/CommitDlg.cpp (revision 29189)
@@ -586,7 +586,7 @@
586586
587587 UINT CCommitDlg::StatusThreadEntry(LPVOID pVoid)
588588 {
589- CCrashReportThread crashthread;
589+ CCrashReportThread crashThread;
590590 return static_cast<CCommitDlg*>(pVoid)->StatusThread();
591591 }
592592
@@ -1519,7 +1519,7 @@
15191519 case WM_NOTIFY:
15201520 if (wParam == IDC_SPLITTER)
15211521 {
1522- SPC_NMHDR* pHdr = reinterpret_cast<SPC_NMHDR*>(lParam);
1522+ SpcNMHDR* pHdr = reinterpret_cast<SpcNMHDR*>(lParam);
15231523 DoSize(pHdr->delta);
15241524 }
15251525 break;
--- trunk/src/TortoiseProc/LogDialog/LogDlg.cpp (revision 29188)
+++ trunk/src/TortoiseProc/LogDialog/LogDlg.cpp (revision 29189)
@@ -4259,17 +4259,17 @@
42594259 case WM_NOTIFY:
42604260 if (wParam == IDC_SPLITTERTOP)
42614261 {
4262- SPC_NMHDR* pHdr = reinterpret_cast<SPC_NMHDR*>(lParam);
4262+ SpcNMHDR* pHdr = reinterpret_cast<SpcNMHDR*>(lParam);
42634263 DoSizeV1(pHdr->delta);
42644264 }
42654265 else if (wParam == IDC_SPLITTERBOTTOM)
42664266 {
4267- SPC_NMHDR* pHdr = reinterpret_cast<SPC_NMHDR*>(lParam);
4267+ SpcNMHDR* pHdr = reinterpret_cast<SpcNMHDR*>(lParam);
42684268 DoSizeV2(pHdr->delta);
42694269 }
42704270 else if (wParam == IDC_SPLITTERLEFT)
42714271 {
4272- SPC_NMHDR* pHdr = reinterpret_cast<SPC_NMHDR*>(lParam);
4272+ SpcNMHDR* pHdr = reinterpret_cast<SpcNMHDR*>(lParam);
42734273 DoSizeV3(pHdr->delta);
42744274 }
42754275 else
--- trunk/src/Utils/MiscUI/LinkControl.cpp (revision 29188)
+++ trunk/src/Utils/MiscUI/LinkControl.cpp (revision 29189)
@@ -1,6 +1,6 @@
11 // TortoiseSVN - a Windows shell extension for easy version control
22
3-// Copyright (C) 2009, 2012-2016, 2018 - TortoiseSVN
3+// Copyright (C) 2009, 2012-2016, 2018, 2021 - TortoiseSVN
44
55 // This program is free software; you can redistribute it and/or
66 // modify it under the terms of the GNU General Public License
@@ -20,23 +20,22 @@
2020 #include "LinkControl.h"
2121 #include "CommonAppUtils.h"
2222
23-const UINT CLinkControl::LK_LINKITEMCLICKED
24-= ::RegisterWindowMessage(L"LK_LINKITEMCLICKED");
23+const UINT CLinkControl::LK_LINKITEMCLICKED = ::RegisterWindowMessage(L"LK_LINKITEMCLICKED");
2524
26-CLinkControl::CLinkControl(void)
27- : m_bOverControl(false)
28- , m_hLinkCursor(nullptr)
25+CLinkControl::CLinkControl()
26+ : m_hLinkCursor(nullptr)
27+ , m_bOverControl(false)
2928 {
3029 }
3130
32-CLinkControl::~CLinkControl(void)
31+CLinkControl::~CLinkControl()
3332 {
3433 /*
3534 * No need to call DestroyCursor() for cursors acquired through
3635 * LoadCursor().
3736 */
38- m_NormalFont.DeleteObject();
39- m_UnderlineFont.DeleteObject();
37+ m_normalFont.DeleteObject();
38+ m_underlineFont.DeleteObject();
4039 }
4140
4241 void CLinkControl::PreSubclassWindow()
@@ -45,32 +44,32 @@
4544
4645 ModifyStyle(0, SS_NOTIFY);
4746
48- m_hLinkCursor = ::LoadCursor(NULL, IDC_HAND); // Load Windows' hand cursor
49- if (!m_hLinkCursor) // if not available, use the standard Arrow cursor
47+ m_hLinkCursor = ::LoadCursor(nullptr, IDC_HAND); // Load Windows' hand cursor
48+ if (!m_hLinkCursor) // if not available, use the standard Arrow cursor
5049 {
51- m_hLinkCursor = ::LoadCursor(NULL, IDC_ARROW);
50+ m_hLinkCursor = ::LoadCursor(nullptr, IDC_ARROW);
5251 }
5352
5453 // Create an updated font by adding an underline.
5554 LOGFONT lf;
56- CFont* pFont = GetFont();
55+ CFont* pFont = GetFont();
5756 if (pFont)
5857 pFont->GetObject(sizeof(lf), &lf);
5958 else
6059 {
61- NONCLIENTMETRICS metrics = { 0 };
62- metrics.cbSize = sizeof(NONCLIENTMETRICS);
60+ NONCLIENTMETRICS metrics = {0};
61+ metrics.cbSize = sizeof(NONCLIENTMETRICS);
6362 SystemParametersInfo(SPI_GETNONCLIENTMETRICS, 0, &metrics, FALSE);
6463 memcpy_s(&lf, sizeof(LOGFONT), &metrics.lfMessageFont, sizeof(LOGFONT));
6564 }
6665
6766 lf.lfWeight = FW_BOLD;
68- m_NormalFont.CreateFontIndirect(&lf);
67+ m_normalFont.CreateFontIndirect(&lf);
6968
7069 lf.lfUnderline = TRUE;
71- m_UnderlineFont.CreateFontIndirect(&lf);
70+ m_underlineFont.CreateFontIndirect(&lf);
7271
73- SetFont(&m_NormalFont, FALSE);
72+ SetFont(&m_normalFont, FALSE);
7473
7574 CCommonAppUtils::SetAccProperty(GetSafeHwnd(), PROPID_ACC_ROLE, ROLE_SYSTEM_LINK);
7675 UpdateAccState();
@@ -102,12 +101,13 @@
102101 else
103102 {
104103 m_bOverControl = TRUE;
105- SetFont(&m_UnderlineFont, FALSE);
106- InvalidateRect(NULL, FALSE);
104+ SetFont(&m_underlineFont, FALSE);
105+ InvalidateRect(nullptr, FALSE);
107106 SetCapture();
108107 }
109108 }
110109
110+// ReSharper disable once CppMemberFunctionMayBeConst
111111 BOOL CLinkControl::OnSetCursor(CWnd* /*pWnd*/, UINT /*nHitTest*/, UINT /*message*/)
112112 {
113113 ::SetCursor(m_hLinkCursor);
@@ -114,11 +114,11 @@
114114 return TRUE;
115115 }
116116
117-void CLinkControl::OnCaptureChanged(CWnd * /*pWnd*/)
117+void CLinkControl::OnCaptureChanged(CWnd* /*pWnd*/)
118118 {
119119 m_bOverControl = FALSE;
120- SetFont(&m_NormalFont, FALSE);
121- InvalidateRect(NULL, FALSE);
120+ SetFont(&m_normalFont, FALSE);
121+ InvalidateRect(nullptr, FALSE);
122122 }
123123
124124 void CLinkControl::OnSetFocus(CWnd* pOldWnd)
@@ -133,9 +133,9 @@
133133 __super::OnKillFocus(pOldWnd);
134134 }
135135
136-void CLinkControl::DrawFocusRect()
136+void CLinkControl::DrawFocusRect() const
137137 {
138- CWnd *parent = GetParent();
138+ CWnd* parent = GetParent();
139139
140140 if (parent)
141141 {
@@ -143,7 +143,7 @@
143143 RECT rc;
144144 GetWindowRect(&rc);
145145
146- InflateRect(&rc, 1, 1); // add one pixel all around
146+ InflateRect(&rc, 1, 1); // add one pixel all around
147147 parent->ScreenToClient(&rc);
148148
149149 CClientDC dcParent(parent);
@@ -151,9 +151,9 @@
151151 }
152152 }
153153
154-void CLinkControl::ClearFocusRect()
154+void CLinkControl::ClearFocusRect() const
155155 {
156- CWnd *parent = GetParent();
156+ CWnd* parent = GetParent();
157157
158158 if (parent)
159159 {
@@ -161,7 +161,7 @@
161161 RECT rc;
162162 GetWindowRect(&rc);
163163
164- InflateRect(&rc, 1, 1); // add one pixel all around
164+ InflateRect(&rc, 1, 1); // add one pixel all around
165165 parent->ScreenToClient(&rc);
166166 // Ask parent to redraw area where we rendered focus rect before.
167167 parent->InvalidateRect(&rc);
@@ -168,7 +168,7 @@
168168 }
169169 }
170170
171-void CLinkControl::UpdateAccState()
171+void CLinkControl::UpdateAccState() const
172172 {
173173 DWORD state = STATE_SYSTEM_READONLY;
174174 if (!IsWindowEnabled())
@@ -177,15 +177,15 @@
177177 CCommonAppUtils::SetAccProperty(GetSafeHwnd(), PROPID_ACC_STATE, state);
178178 }
179179
180-void CLinkControl::NotifyParent(UINT msg)
180+void CLinkControl::NotifyParent(UINT msg) const
181181 {
182- ::PostMessage(GetParent()->GetSafeHwnd(), msg, (WPARAM)GetSafeHwnd(), (LPARAM) 0);
182+ ::PostMessage(GetParent()->GetSafeHwnd(), msg, reinterpret_cast<WPARAM>(GetSafeHwnd()), static_cast<LPARAM>(0));
183183 }
184184
185185 UINT CLinkControl::OnGetDlgCode()
186186 {
187- UINT dlgCode = CStatic::OnGetDlgCode();
188- const MSG *pMsg = CWnd::GetCurrentMessage();
187+ UINT dlgCode = CStatic::OnGetDlgCode();
188+ const MSG* pMsg = CWnd::GetCurrentMessage();
189189
190190 // we want all keys to get the return key
191191 dlgCode |= DLGC_WANTALLKEYS;
@@ -196,8 +196,8 @@
196196 dlgCode &= ~DLGC_STATIC;
197197
198198 if (pMsg->lParam &&
199- ((MSG *)pMsg->lParam)->message == WM_KEYDOWN &&
200- ((MSG *)pMsg->lParam)->wParam == VK_TAB)
199+ reinterpret_cast<MSG*>(pMsg->lParam)->message == WM_KEYDOWN &&
200+ reinterpret_cast<MSG*>(pMsg->lParam)->wParam == VK_TAB)
201201 {
202202 dlgCode &= ~DLGC_WANTMESSAGE;
203203 }
@@ -205,6 +205,7 @@
205205 return dlgCode;
206206 }
207207
208+// ReSharper disable once CppMemberFunctionMayBeConst
208209 void CLinkControl::OnKeyDown(UINT nChar, UINT /*nRepCnt*/, UINT /*nFlags*/)
209210 {
210211 if (nChar == VK_SPACE || nChar == VK_RETURN)
@@ -213,6 +214,7 @@
213214 }
214215 }
215216
217+// ReSharper disable once CppMemberFunctionMayBeConst
216218 void CLinkControl::OnClicked()
217219 {
218220 NotifyParent(LK_LINKITEMCLICKED);
@@ -230,8 +232,8 @@
230232 switch (message)
231233 {
232234 case BM_CLICK:
233- NotifyParent(LK_LINKITEMCLICKED);
234- break;
235+ NotifyParent(LK_LINKITEMCLICKED);
236+ break;
235237 }
236238
237239 return CStatic::OnWndMsg(message, wParam, lParam, pResult);
--- trunk/src/Utils/MiscUI/LinkControl.h (revision 29188)
+++ trunk/src/Utils/MiscUI/LinkControl.h (revision 29189)
@@ -1,6 +1,6 @@
1-// TortoiseSVN - a Windows shell extension for easy version control
1+// TortoiseSVN - a Windows shell extension for easy version control
22
3-// Copyright (C) 2009, 2012, 2015-2016 - TortoiseSVN
3+// Copyright (C) 2009, 2012, 2015-2016, 2021 - TortoiseSVN
44
55 // This program is free software; you can redistribute it and/or
66 // modify it under the terms of the GNU General Public License
@@ -22,30 +22,30 @@
2222 class CLinkControl : public CStatic
2323 {
2424 public:
25- CLinkControl(void);
26- virtual ~CLinkControl(void);
25+ CLinkControl();
26+ ~CLinkControl() override;
2727
2828 static const UINT LK_LINKITEMCLICKED;
2929
3030 protected:
31- virtual void PreSubclassWindow();
32- virtual BOOL OnWndMsg(UINT message, WPARAM wParam, LPARAM lParam, LRESULT* pResult);
31+ void PreSubclassWindow() override;
32+ BOOL OnWndMsg(UINT message, WPARAM wParam, LPARAM lParam, LRESULT* pResult) override;
3333
3434 private:
35- HCURSOR m_hLinkCursor; // Cursor for hyperlink
36- CFont m_UnderlineFont; // Font for underline display
37- CFont m_NormalFont; // Font for default display
38- bool m_bOverControl; // cursor over control?
35+ HCURSOR m_hLinkCursor; // Cursor for hyperlink
36+ CFont m_underlineFont; // Font for underline display
37+ CFont m_normalFont; // Font for default display
38+ bool m_bOverControl; // cursor over control?
3939
40- void DrawFocusRect();
41- void ClearFocusRect();
42- void UpdateAccState();
43- void NotifyParent(UINT msg);
40+ void DrawFocusRect() const;
41+ void ClearFocusRect() const;
42+ void UpdateAccState() const;
43+ void NotifyParent(UINT msg) const;
4444
4545 protected:
4646 afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
4747 afx_msg void OnMouseMove(UINT nFlags, CPoint point);
48- afx_msg void OnCaptureChanged(CWnd *pWnd);
48+ afx_msg void OnCaptureChanged(CWnd* pWnd);
4949 afx_msg void OnSetFocus(CWnd* pOldWnd);
5050 afx_msg void OnKillFocus(CWnd* pNewWnd);
5151 afx_msg UINT OnGetDlgCode();
@@ -55,4 +55,3 @@
5555
5656 DECLARE_MESSAGE_MAP()
5757 };
58-
--- trunk/src/Utils/MiscUI/MyGraph.cpp (revision 29188)
+++ trunk/src/Utils/MiscUI/MyGraph.cpp (revision 29189)
@@ -6,17 +6,18 @@
66 #include "Theme.h"
77
88 #include <cmath>
9+// ReSharper disable once CppInconsistentNaming
910 #define _USE_MATH_DEFINES
10-#include <math.h> // for M_PI
11+#include <math.h> // for M_PI
1112 #include <memory>
1213
1314 #ifdef _DEBUG
14-#define new DEBUG_NEW
15-#undef THIS_FILE
15+// ReSharper disable once CppInconsistentNaming
16+# define new DEBUG_NEW
17+# undef THIS_FILE
1618 static char THIS_FILE[] = __FILE__;
1719 #endif
1820
19-
2021 /////////////////////////////////////////////////////////////////////////////
2122 // This macro can be called at the beginning and ending of every
2223 // method. It is identical to saying "ASSERT_VALID(); ASSERT_KINDOF();"
@@ -23,34 +24,34 @@
2324 // but is written like this so that VALIDATE can be a macro. It is useful
2425 // as an "early warning" that something has gone wrong with "this" object.
2526 #ifndef VALIDATE
26- #ifdef _DEBUG
27- #define VALIDATE ::AfxAssertValidObject(this, __FILE__ , __LINE__ ); \
28- _ASSERTE(IsKindOf(GetRuntimeClass()));
29- #else
30- #define VALIDATE
31- #endif
27+# ifdef _DEBUG
28+# define VALIDATE \
29+ ::AfxAssertValidObject(this, __FILE__, __LINE__); \
30+ _ASSERTE(IsKindOf(GetRuntimeClass()));
31+# else
32+# define VALIDATE
33+# endif
3234 #endif
3335
34-
3536 /////////////////////////////////////////////////////////////////////////////
3637 // Constants.
3738
38-#define TICK_PIXELS 4 // Size of tick marks.
39-#define GAP_PIXELS 6 // Better if an even value.
40-#define LEGEND_COLOR_BAR_WIDTH_PIXELS 50 // Width of color bar.
41-#define LEGEND_COLOR_BAR_GAP_PIXELS 1 // Space between color bars.
42-#define Y_AXIS_TICK_COUNT_TARGET 5 // How many ticks should be there on the y axis.
43-#define MIN_FONT_SIZE 70 // The minimum font-size in pt*10.
44-#define LEGEND_VISIBILITY_THRESHOLD 300 // The width of the graph in pixels when the legend gets hidden.
39+#define TICK_PIXELS 4 // Size of tick marks.
40+#define GAP_PIXELS 6 // Better if an even value.
41+#define LEGEND_COLOR_BAR_WIDTH_PIXELS 50 // Width of color bar.
42+#define LEGEND_COLOR_BAR_GAP_PIXELS 1 // Space between color bars.
43+#define Y_AXIS_TICK_COUNT_TARGET 5 // How many ticks should be there on the y axis.
44+#define MIN_FONT_SIZE 70 // The minimum font-size in pt*10.
45+#define LEGEND_VISIBILITY_THRESHOLD 300 // The width of the graph in pixels when the legend gets hidden.
4546
46-#define INTERSERIES_PERCENT_USED 0.85 // How much of the graph is
47- // used for bars/pies (the
48- // rest is for inter-series
49- // spacing).
47+#define INTERSERIES_PERCENT_USED 0.85 // How much of the graph is \
48+ // used for bars/pies (the \
49+ // rest is for inter-series \
50+ // spacing).
5051
51-#define TITLE_DIVISOR 5 // Scale font to graph width.
52-#define LEGEND_DIVISOR 8 // Scale font to graph height.
53-#define Y_AXIS_LABEL_DIVISOR 6 // Scale font to graph height.
52+#define TITLE_DIVISOR 5 // Scale font to graph width.
53+#define LEGEND_DIVISOR 8 // Scale font to graph height.
54+#define Y_AXIS_LABEL_DIVISOR 6 // Scale font to graph height.
5455
5556 #ifndef M_PI
5657 const double M_PI = 3.1415926535897932384626433832795;
@@ -60,7 +61,7 @@
6061 // MyGraphSeries
6162
6263 // Constructor.
63-MyGraphSeries::MyGraphSeries(const CString& sLabel /* = "" */ )
64+MyGraphSeries::MyGraphSeries(const CString& sLabel /* = "" */)
6465 : m_sLabel(sLabel)
6566 {
6667 }
@@ -68,7 +69,8 @@
6869 // Destructor.
6970 /* virtual */ MyGraphSeries::~MyGraphSeries()
7071 {
71- for (int nGroup = 0; nGroup < m_oaRegions.GetSize(); ++nGroup) {
72+ for (int nGroup = 0; nGroup < m_oaRegions.GetSize(); ++nGroup)
73+ {
7274 delete m_oaRegions.GetAt(nGroup);
7375 }
7476 }
@@ -110,7 +112,7 @@
110112 ASSERT_VALID(prgn);
111113
112114 // If there is an existing region, delete it.
113- CRgn* prgnOld = NULL;
115+ CRgn* prgnOld = nullptr;
114116
115117 if (nGroup < m_oaRegions.GetSize())
116118 {
@@ -119,7 +121,7 @@
119121 }
120122
121123 delete prgnOld;
122- prgnOld = NULL;
124+ prgnOld = nullptr;
123125
124126 // Add the new region.
125127 m_oaRegions.SetAtGrow(nGroup, prgn);
@@ -152,12 +154,15 @@
152154
153155 int nMax(0);
154156
155- for (int nGroup = 0; nGroup < m_dwaValues.GetSize(); ++nGroup) {
156- if(!bStackedGraph){
157- nMax = max(nMax, static_cast<int> (m_dwaValues.GetAt(nGroup)));
157+ for (int nGroup = 0; nGroup < m_dwaValues.GetSize(); ++nGroup)
158+ {
159+ if (!bStackedGraph)
160+ {
161+ nMax = max(nMax, static_cast<int>(m_dwaValues.GetAt(nGroup)));
158162 }
159- else{
160- nMax += static_cast<int> (m_dwaValues.GetAt(nGroup));
163+ else
164+ {
165+ nMax += static_cast<int>(m_dwaValues.GetAt(nGroup));
161166 }
162167 }
163168
@@ -171,14 +176,15 @@
171176
172177 int nTotal = 0;
173178
174- for (int nGroup = 0; nGroup < m_dwaValues.GetSize(); ++nGroup) {
175- nTotal += static_cast<int> (m_dwaValues.GetAt(nGroup));
179+ for (int nGroup = 0; nGroup < m_dwaValues.GetSize(); ++nGroup)
180+ {
181+ nTotal += static_cast<int>(m_dwaValues.GetAt(nGroup));
176182 }
177183
178184 if (m_dwaValues.GetSize() == 0)
179185 return 0;
180186
181- return nTotal / (int)m_dwaValues.GetSize();
187+ return nTotal / static_cast<int>(m_dwaValues.GetSize());
182188 }
183189
184190 // Returns the number of data points that are not zero.
@@ -188,9 +194,10 @@
188194
189195 int nCount(0);
190196
191- for (int nGroup = 0; nGroup < m_dwaValues.GetSize(); ++nGroup) {
192-
193- if (m_dwaValues.GetAt(nGroup)) {
197+ for (int nGroup = 0; nGroup < m_dwaValues.GetSize(); ++nGroup)
198+ {
199+ if (m_dwaValues.GetAt(nGroup))
200+ {
194201 ++nCount;
195202 }
196203 }
@@ -205,7 +212,8 @@
205212
206213 int nTotal(0);
207214
208- for (int nGroup = 0; nGroup < m_dwaValues.GetSize(); ++nGroup) {
215+ for (int nGroup = 0; nGroup < m_dwaValues.GetSize(); ++nGroup)
216+ {
209217 nTotal += m_dwaValues.GetAt(nGroup);
210218 }
211219
@@ -217,11 +225,13 @@
217225 {
218226 VALIDATE;
219227
220- for (int nGroup = searchStart; nGroup < m_oaRegions.GetSize(); ++nGroup) {
228+ for (int nGroup = searchStart; nGroup < m_oaRegions.GetSize(); ++nGroup)
229+ {
221230 CRgn* prgnData = m_oaRegions.GetAt(nGroup);
222231 ASSERT_NULL_OR_POINTER(prgnData, CRgn);
223232
224- if (prgnData && prgnData->PtInRegion(pt)) {
233+ if (prgnData && prgnData->PtInRegion(pt))
234+ {
225235 return nGroup;
226236 }
227237 }
@@ -230,7 +240,7 @@
230240 }
231241
232242 // Get the series portion of the tip for this group in this series.
233-CString MyGraphSeries::GetTipText(int nGroup, const CString &unitString) const
243+CString MyGraphSeries::GetTipText(int nGroup, const CString& unitString) const
234244 {
235245 VALIDATE;
236246 _ASSERTE(0 <= nGroup);
@@ -239,19 +249,19 @@
239249 CString sTip;
240250
241251 sTip.Format(L"%d %s (%d%%)", m_dwaValues.GetAt(nGroup),
242- (LPCTSTR)unitString,
243- GetDataTotal() ? (int) (100.0 * (double) m_dwaValues.GetAt(nGroup) /
244- (double) GetDataTotal()) : 0);
252+ static_cast<LPCWSTR>(unitString),
253+ GetDataTotal() ? static_cast<int>(100.0 * static_cast<double>(m_dwaValues.GetAt(nGroup)) /
254+ static_cast<double>(GetDataTotal()))
255+ : 0);
245256
246257 return sTip;
247258 }
248259
249-
250260 /////////////////////////////////////////////////////////////////////////////
251261 // MyGraph
252262
253263 // Constructor.
254-MyGraph::MyGraph(GraphType eGraphType /* = MyGraph::Pie */ , bool bStackedGraph /* = false */)
264+MyGraph::MyGraph(GraphType eGraphType /* = MyGraph::Pie */, bool bStackedGraph /* = false */)
255265 : m_nXAxisWidth(0)
256266 , m_nYAxisHeight(0)
257267 , m_nAxisLabelHeight(0)
@@ -290,45 +300,50 @@
290300 VERIFY(EnableToolTips(true));
291301 }
292302
293-
294303 /////////////////////////////////////////////////////////////////////////////
295304 // MyGraph message handlers
296305
297306 // Handle the tooltip messages. Returns true to mean message was handled.
307+// ReSharper disable once CppMemberFunctionMayBeConst
298308 BOOL MyGraph::OnNeedText(UINT /*uiId*/, NMHDR* pNMHDR, LRESULT* pResult)
299309 {
300- _ASSERTE(pNMHDR && "Bad parameter passed");
301- _ASSERTE(pResult && "Bad parameter passed");
310+ _ASSERTE(pNMHDR && "Bad parameter passed");
311+ _ASSERTE(pResult && "Bad parameter passed");
302312
303- bool bReturn(false);
313+ bool bReturn(false);
304314 UINT_PTR uiID(pNMHDR->idFrom);
305315
306316 // Notification in NT from automatically created tooltip.
307- if (0U != uiID) {
317+ if (0U != uiID)
318+ {
308319 bReturn = true;
309320
310321 // Need to handle both ANSI and UNICODE versions of the message.
311- TOOLTIPTEXTA* pTTTA = reinterpret_cast<TOOLTIPTEXTA*> (pNMHDR);
322+ TOOLTIPTEXTA* pTTTA = reinterpret_cast<TOOLTIPTEXTA*>(pNMHDR);
312323 ASSERT_POINTER(pTTTA, TOOLTIPTEXTA);
313324
314- TOOLTIPTEXTW* pTTTW = reinterpret_cast<TOOLTIPTEXTW*> (pNMHDR);
325+ TOOLTIPTEXTW* pTTTW = reinterpret_cast<TOOLTIPTEXTW*>(pNMHDR);
315326 ASSERT_POINTER(pTTTW, TOOLTIPTEXTW);
316327
317328 CString sTipText(GetTipText());
318329
319330 #ifndef _UNICODE
320- if (TTN_NEEDTEXTA == pNMHDR->code) {
331+ if (TTN_NEEDTEXTA == pNMHDR->code)
332+ {
321333 lstrcpyn(pTTTA->szText, sTipText, _countof(pTTTA->szText) - 1);
322334 }
323- else {
335+ else
336+ {
324337 _mbstowcsz(pTTTW->szText, sTipText, _countof(pTTTA->szText));
325338 }
326339 #else
327- if (pNMHDR->code == TTN_NEEDTEXTA) {
340+ if (pNMHDR->code == TTN_NEEDTEXTA)
341+ {
328342 _wcstombsz(pTTTA->szText, sTipText, _countof(pTTTA->szText));
329343 }
330- else {
331- lstrcpyn(pTTTW->szText, sTipText, _countof(pTTTA->szText) - 1);
344+ else
345+ {
346+ lstrcpyn(pTTTW->szText, sTipText, _countof(pTTTA->szText) - 1LL);
332347 }
333348 #endif
334349
@@ -340,38 +355,42 @@
340355
341356 // The framework calls this member function to determine whether a point is in
342357 // the bounding rectangle of the specified tool.
343-INT_PTR MyGraph::OnToolHitTest(CPoint point, TOOLINFO* pTI) const
358+INT_PTR MyGraph::OnToolHitTest(CPoint point, TOOLINFO* pTi) const
344359 {
345- _ASSERTE(pTI && "Bad parameter passed");
360+ _ASSERTE(pTi && "Bad parameter passed");
346361
347362 // This works around the problem of the tip remaining visible when you move
348363 // the mouse to various positions over this control.
349- INT_PTR nReturn(0);
350- static bool bTipPopped(false);
351- static CPoint ptPrev(-1,-1);
364+ INT_PTR nReturn(0);
365+ static bool bTipPopped(false);
366+ static CPoint ptPrev(-1, -1);
352367
353- if (point != ptPrev) {
368+ if (point != ptPrev)
369+ {
354370 ptPrev = point;
355371
356- if (bTipPopped) {
372+ if (bTipPopped)
373+ {
357374 bTipPopped = false;
358- nReturn = -1;
375+ nReturn = -1;
359376 }
360- else {
377+ else
378+ {
361379 ::Sleep(50);
362380 bTipPopped = true;
363381
364- pTI->hwnd = m_hWnd;
365- pTI->uId = (UINT_PTR) m_hWnd;
366- pTI->lpszText = LPSTR_TEXTCALLBACK;
382+ pTi->hwnd = m_hWnd;
383+ pTi->uId = reinterpret_cast<UINT_PTR>(m_hWnd);
384+ pTi->lpszText = LPSTR_TEXTCALLBACK;
367385
368386 CRect rcWnd;
369387 GetClientRect(&rcWnd);
370- pTI->rect = rcWnd;
371- nReturn = 1;
388+ pTi->rect = rcWnd;
389+ nReturn = 1;
372390 }
373391 }
374- else {
392+ else
393+ {
375394 nReturn = 1;
376395 }
377396
@@ -394,21 +413,26 @@
394413 ScreenToClient(&pt);
395414
396415 // Ask each part of the graph to check and see if the mouse is over it.
397- if (m_rcLegend.PtInRect(pt)) {
416+ if (m_rcLegend.PtInRect(pt))
417+ {
398418 sTip = "Legend";
399419 }
400- else if (m_rcTitle.PtInRect(pt)) {
420+ else if (m_rcTitle.PtInRect(pt))
421+ {
401422 sTip = "Title";
402423 }
403- else {
424+ else
425+ {
404426 int maxXAxis = m_ptOrigin.x + (m_nXAxisWidth - m_rcLegend.Width() - (GAP_PIXELS * 2));
405- if (pt.x >= m_ptOrigin.x && pt.x <= maxXAxis) {
406- int average = GetAverageDataValue();
407- int nMaxDataValue = max(GetMaxDataValue(), 1);
408- double barTop = m_ptOrigin.y - (double)m_nYAxisHeight *
409- (average / (double)nMaxDataValue);
410- if (pt.y >= barTop - 2 && pt.y <= barTop + 2) {
411- sTip.Format(_T("Average: %d %s (%d%%)"), average, (LPCTSTR)m_sYAxisLabel, nMaxDataValue ? (100 * average / nMaxDataValue) : 0);
427+ if (pt.x >= m_ptOrigin.x && pt.x <= maxXAxis)
428+ {
429+ int average = GetAverageDataValue();
430+ int nMaxDataValue = max(GetMaxDataValue(), 1);
431+ double barTop = m_ptOrigin.y - static_cast<double>(m_nYAxisHeight) *
432+ (average / static_cast<double>(nMaxDataValue));
433+ if (pt.y >= barTop - 2 && pt.y <= barTop + 2)
434+ {
435+ sTip.Format(_T("Average: %d %s (%d%%)"), average, static_cast<LPCWSTR>(m_sYAxisLabel), nMaxDataValue ? (100 * average / nMaxDataValue) : 0);
412436 return sTip;
413437 }
414438 }
@@ -415,16 +439,20 @@
415439
416440 POSITION pos(m_olMyGraphSeries.GetHeadPosition());
417441
418- while (pos && sTip.IsEmpty()) {
442+ while (pos && sTip.IsEmpty())
443+ {
419444 MyGraphSeries* pSeries = m_olMyGraphSeries.GetNext(pos);
420445 ASSERT_VALID(pSeries);
421446
422447 int nGroup(0);
423- do{
424- nGroup = pSeries->HitTest(pt,nGroup);
448+ do
449+ {
450+ nGroup = pSeries->HitTest(pt, nGroup);
425451
426- if (-1 != nGroup) {
427- if(!sTip.IsEmpty()){
452+ if (-1 != nGroup)
453+ {
454+ if (!sTip.IsEmpty())
455+ {
428456 sTip += L", ";
429457 }
430458 sTip += m_saLegendLabels.GetAt(nGroup) + L": ";
@@ -431,7 +459,7 @@
431459 sTip += pSeries->GetTipText(nGroup, m_sYAxisLabel);
432460 nGroup++;
433461 }
434- }while(-1 != nGroup);
462+ } while (-1 != nGroup);
435463 }
436464 }
437465
@@ -463,7 +491,7 @@
463491 {
464492 VALIDATE;
465493
466- m_eGraphType = e;
494+ m_eGraphType = e;
467495 m_bStackedGraph = bStackedGraph;
468496 }
469497
@@ -474,16 +502,18 @@
474502 ASSERT_VALID(&dc);
475503
476504 CString sMax;
477- int nMaxChars(-1);
478- CSize siz(-1,-1);
505+ int nMaxChars(-1);
506+ CSize siz(-1, -1);
479507
480508 // First get max number of characters.
481- for (int nGroup = 0; nGroup < m_saLegendLabels.GetSize(); ++nGroup) {
509+ for (int nGroup = 0; nGroup < m_saLegendLabels.GetSize(); ++nGroup)
510+ {
482511 int nLabelLength(m_saLegendLabels.GetAt(nGroup).GetLength());
483512
484- if (nMaxChars < nLabelLength) {
513+ if (nMaxChars < nLabelLength)
514+ {
485515 nMaxChars = nLabelLength;
486- sMax = m_saLegendLabels.GetAt(nGroup);
516+ sMax = m_saLegendLabels.GetAt(nGroup);
487517 }
488518 }
489519
@@ -500,14 +530,15 @@
500530 {
501531 VALIDATE;
502532
503- int nMax(0);
533+ int nMax(0);
504534 POSITION pos(m_olMyGraphSeries.GetHeadPosition());
505535
506- while (pos) {
536+ while (pos)
537+ {
507538 MyGraphSeries* pSeries = m_olMyGraphSeries.GetNext(pos);
508539 ASSERT_VALID(pSeries);
509540
510- nMax = max(nMax, (int)pSeries->m_dwaValues.GetSize());
541+ nMax = max(nMax, static_cast<int>(pSeries->m_dwaValues.GetSize()));
511542 }
512543
513544 return nMax;
@@ -518,10 +549,11 @@
518549 {
519550 VALIDATE;
520551
521- int nMax(0);
552+ int nMax(0);
522553 POSITION pos(m_olMyGraphSeries.GetHeadPosition());
523554
524- while (pos) {
555+ while (pos)
556+ {
525557 MyGraphSeries* pSeries = m_olMyGraphSeries.GetNext(pos);
526558 ASSERT_VALID(pSeries);
527559
@@ -536,10 +568,11 @@
536568 {
537569 VALIDATE;
538570
539- int nMax(0);
571+ int nMax(0);
540572 POSITION pos(m_olMyGraphSeries.GetHeadPosition());
541573
542- while (pos) {
574+ while (pos)
575+ {
543576 MyGraphSeries* pSeries = m_olMyGraphSeries.GetNext(pos);
544577 ASSERT_VALID(pSeries);
545578
@@ -554,10 +587,11 @@
554587 {
555588 VALIDATE;
556589
557- int nTotal = 0, nCount = 0;
590+ int nTotal = 0, nCount = 0;
558591 POSITION pos(m_olMyGraphSeries.GetHeadPosition());
559592
560- while (pos) {
593+ while (pos)
594+ {
561595 MyGraphSeries* pSeries = m_olMyGraphSeries.GetNext(pos);
562596 ASSERT_VALID(pSeries);
563597
@@ -576,14 +610,16 @@
576610 {
577611 VALIDATE;
578612
579- int nCount(0);
613+ int nCount(0);
580614 POSITION pos(m_olMyGraphSeries.GetHeadPosition());
581615
582- while (pos) {
616+ while (pos)
617+ {
583618 MyGraphSeries* pSeries = m_olMyGraphSeries.GetNext(pos);
584619 ASSERT_VALID(pSeries);
585620
586- if (0 < pSeries->GetNonZeroElementCount()) {
621+ if (0 < pSeries->GetNonZeroElementCount())
622+ {
587623 ++nCount;
588624 }
589625 }
@@ -595,11 +631,12 @@
595631 int MyGraph::LookupLabel(const CString& sLabel) const
596632 {
597633 VALIDATE;
598- _ASSERTE(! sLabel.IsEmpty());
634+ _ASSERTE(!sLabel.IsEmpty());
599635
600- for (int nGroup = 0; nGroup < m_saLegendLabels.GetSize(); ++nGroup) {
601-
602- if (0 == sLabel.CompareNoCase(m_saLegendLabels.GetAt(nGroup))) {
636+ for (int nGroup = 0; nGroup < m_saLegendLabels.GetSize(); ++nGroup)
637+ {
638+ if (0 == sLabel.CompareNoCase(m_saLegendLabels.GetAt(nGroup)))
639+ {
603640 return nGroup;
604641 }
605642 }
@@ -628,7 +665,7 @@
628665 void MyGraph::SetXAxisLabel(const CString& sLabel)
629666 {
630667 VALIDATE;
631- _ASSERTE(! sLabel.IsEmpty());
668+ _ASSERTE(!sLabel.IsEmpty());
632669
633670 m_sXAxisLabel = sLabel;
634671 }
@@ -637,7 +674,7 @@
637674 void MyGraph::SetYAxisLabel(const CString& sLabel)
638675 {
639676 VALIDATE;
640- _ASSERTE(! sLabel.IsEmpty());
677+ _ASSERTE(!sLabel.IsEmpty());
641678
642679 m_sYAxisLabel = sLabel;
643680 }
@@ -649,18 +686,19 @@
649686 VALIDATE;
650687
651688 // Add the group.
652- int nGroup((int)m_saLegendLabels.GetSize());
689+ int nGroup(static_cast<int>(m_saLegendLabels.GetSize()));
653690 SetLegend(nGroup, sLabel);
654691
655692 // Make sure that all series have this element.
656693 POSITION pos(m_olMyGraphSeries.GetHeadPosition());
657694
658- while (pos) {
659-
695+ while (pos)
696+ {
660697 MyGraphSeries* pSeries = m_olMyGraphSeries.GetNext(pos);
661698 ASSERT_VALID(pSeries);
662699
663- if (nGroup >= pSeries->m_dwaValues.GetSize()) {
700+ if (nGroup >= pSeries->m_dwaValues.GetSize())
701+ {
664702 pSeries->m_dwaValues.SetAtGrow(nGroup, 0);
665703 }
666704 }
@@ -681,7 +719,7 @@
681719 void MyGraph::SetGraphTitle(const CString& sTitle)
682720 {
683721 VALIDATE;
684- _ASSERTE(! sTitle.IsEmpty());
722+ _ASSERTE(!sTitle.IsEmpty());
685723
686724 m_sTitle = sTitle;
687725 }
@@ -692,13 +730,14 @@
692730 VALIDATE;
693731 ASSERT_VALID(&dc);
694732
695- if (GetMaxSeriesSize()) {
733+ if (GetMaxSeriesSize())
734+ {
696735 dc.SetBkMode(TRANSPARENT);
697736
698737 dc.SetTextColor(CTheme::Instance().IsDarkTheme() ? CTheme::darkTextColor : GetSysColor(COLOR_WINDOWTEXT));
699- auto themePen = CreatePen(PS_SOLID, 1, CTheme::Instance().IsDarkTheme() ? CTheme::darkTextColor : GetSysColor(COLOR_WINDOWTEXT));
700- auto themeBrush = CreateSolidBrush(CTheme::Instance().IsDarkTheme() ? CTheme::darkBkColor : GetSysColor(COLOR_WINDOW));
701- auto oldThemePen = dc.SelectObject(themePen);
738+ auto themePen = CreatePen(PS_SOLID, 1, CTheme::Instance().IsDarkTheme() ? CTheme::darkTextColor : GetSysColor(COLOR_WINDOWTEXT));
739+ auto themeBrush = CreateSolidBrush(CTheme::Instance().IsDarkTheme() ? CTheme::darkBkColor : GetSysColor(COLOR_WINDOW));
740+ auto oldThemePen = dc.SelectObject(themePen);
702741 auto oldThemeBrush = dc.SelectObject(themeBrush);
703742
704743 // Populate the colors as a group of evenly spaced colors of maximum
@@ -705,8 +744,8 @@
705744 // saturation.
706745 int nColorsDelta(240 / GetMaxSeriesSize());
707746
708- int baseColorL = 120;
709- int diffColorL = 60;
747+ int baseColorL = 120;
748+ int diffColorL = 60;
710749 DWORD backgroundColor = CTheme::Instance().IsDarkTheme() ? CTheme::darkBkColor : GetSysColor(COLOR_WINDOW);
711750 // If graph is a non-stacked line graph, use darker colors if system window color is light.
712751 #if 0
@@ -718,10 +757,11 @@
718757 }
719758 }
720759 #endif
721- for (WORD nGroup = 0; nGroup < GetMaxSeriesSize(); ++nGroup) {
722- WORD colorH = (WORD)(nColorsDelta * nGroup);
723- WORD colorL = (WORD)(baseColorL+(diffColorL*(nGroup%2)));
724- WORD colorS = (WORD)(180)+(30*((1-nGroup%2)*(nGroup%3)));
760+ for (WORD nGroup = 0; nGroup < GetMaxSeriesSize(); ++nGroup)
761+ {
762+ WORD colorH = static_cast<WORD>(nColorsDelta * nGroup);
763+ WORD colorL = static_cast<WORD>(baseColorL + (diffColorL * (nGroup % 2)));
764+ WORD colorS = static_cast<WORD>(180) + (30 * ((1 - nGroup % 2) * (nGroup % 3)));
725765 COLORREF cr(MyGraph::HLStoRGB(colorH, colorL, colorS)); // Populate colors cleverly
726766 m_dwaColors.SetAtGrow(nGroup, cr);
727767 }
@@ -733,9 +773,9 @@
733773 // GAP_PIXELS). These settings are altered by axis labels and legends.
734774 CRect rcWnd;
735775 GetClientRect(&rcWnd);
736- m_rcGraph.left = GAP_PIXELS;
737- m_rcGraph.top = GAP_PIXELS;
738- m_rcGraph.right = rcWnd.Width() - GAP_PIXELS;
776+ m_rcGraph.left = GAP_PIXELS;
777+ m_rcGraph.top = GAP_PIXELS;
778+ m_rcGraph.right = rcWnd.Width() - GAP_PIXELS;
739779 m_rcGraph.bottom = rcWnd.Height() - GAP_PIXELS;
740780
741781 CBrush br;
@@ -750,24 +790,39 @@
750790 SetupAxes(dc);
751791
752792 // Draw legend if there is one and there's enough space.
753- if (m_saLegendLabels.GetSize() && m_rcGraph.right-m_rcGraph.left > LEGEND_VISIBILITY_THRESHOLD) {
793+ if (m_saLegendLabels.GetSize() && m_rcGraph.right - m_rcGraph.left > LEGEND_VISIBILITY_THRESHOLD)
794+ {
754795 DrawLegend(dc);
755796 }
756- else{
797+ else
798+ {
757799 m_rcLegend.SetRectEmpty();
758800 }
759801
760802 // Draw axes unless it's a pie.
761- if (m_eGraphType != MyGraph::PieChart) {
803+ if (m_eGraphType != MyGraph::PieChart)
804+ {
762805 DrawAxes(dc);
763806 }
764807
765808 // Draw series data and labels.
766- switch (m_eGraphType) {
767- case MyGraph::Bar: DrawSeriesBar(dc); break;
768- case MyGraph::Line: if (m_bStackedGraph) DrawSeriesLineStacked(dc); else DrawSeriesLine(dc); break;
769- case MyGraph::PieChart: DrawSeriesPie(dc); break;
770- default: _ASSERTE(! "Bad default case"); break;
809+ switch (m_eGraphType)
810+ {
811+ case MyGraph::Bar:
812+ DrawSeriesBar(dc);
813+ break;
814+ case MyGraph::Line:
815+ if (m_bStackedGraph)
816+ DrawSeriesLineStacked(dc);
817+ else
818+ DrawSeriesLine(dc);
819+ break;
820+ case MyGraph::PieChart:
821+ DrawSeriesPie(dc);
822+ break;
823+ default:
824+ _ASSERTE(!"Bad default case");
825+ break;
771826 }
772827 dc.SelectObject(oldThemePen);
773828 dc.SelectObject(oldThemeBrush);
@@ -785,21 +840,19 @@
785840 // Create the title font.
786841 CFont fontTitle;
787842 VERIFY(fontTitle.CreatePointFont(max(m_rcGraph.Width() / TITLE_DIVISOR, MIN_FONT_SIZE),
788- L"Arial", &dc));
843+ L"Arial", &dc));
789844 CFont* pFontOld = dc.SelectObject(&fontTitle);
790845 ASSERT_VALID(pFontOld);
791846
792847 // Draw the title.
793848 m_rcTitle.SetRect(GAP_PIXELS, GAP_PIXELS, m_rcGraph.Width() + GAP_PIXELS,
794- m_rcGraph.Height() + GAP_PIXELS);
849+ m_rcGraph.Height() + GAP_PIXELS);
795850
796- dc.DrawText(m_sTitle, m_rcTitle, DT_CENTER | DT_NOPREFIX | DT_SINGLELINE |
797- DT_TOP | DT_CALCRECT);
851+ dc.DrawText(m_sTitle, m_rcTitle, DT_CENTER | DT_NOPREFIX | DT_SINGLELINE | DT_TOP | DT_CALCRECT);
798852
799853 m_rcTitle.right = m_rcGraph.Width() + GAP_PIXELS;
800854
801- dc.DrawText(m_sTitle, m_rcTitle, DT_CENTER | DT_NOPREFIX | DT_SINGLELINE |
802- DT_TOP);
855+ dc.DrawText(m_sTitle, m_rcTitle, DT_CENTER | DT_NOPREFIX | DT_SINGLELINE | DT_TOP);
803856
804857 VERIFY(dc.SelectObject(pFontOld));
805858 fontTitle.DeleteObject();
@@ -813,13 +866,15 @@
813866
814867 // Since pie has no axis lines, set to full size minus GAP_PIXELS on each
815868 // side. These are needed for legend to plot itself.
816- if (MyGraph::PieChart == m_eGraphType) {
817- m_nXAxisWidth = m_rcGraph.Width() - (GAP_PIXELS * 2);
869+ if (MyGraph::PieChart == m_eGraphType)
870+ {
871+ m_nXAxisWidth = m_rcGraph.Width() - (GAP_PIXELS * 2);
818872 m_nYAxisHeight = m_rcGraph.Height() - m_rcTitle.bottom;
819- m_ptOrigin.x = GAP_PIXELS;
820- m_ptOrigin.y = m_rcGraph.Height() - GAP_PIXELS;
873+ m_ptOrigin.x = GAP_PIXELS;
874+ m_ptOrigin.y = m_rcGraph.Height() - GAP_PIXELS;
821875 }
822- else {
876+ else
877+ {
823878 // Bar and Line graphs.
824879
825880 // Need to find out how wide the biggest Y-axis tick label is
@@ -827,7 +882,7 @@
827882 // Get and store height of axis label font.
828883 m_nAxisLabelHeight = max(m_rcGraph.Height() / Y_AXIS_LABEL_DIVISOR, MIN_FONT_SIZE);
829884 // Get and store height of tick label font.
830- m_nAxisTickLabelHeight = max(int(m_nAxisLabelHeight*0.8), MIN_FONT_SIZE);
885+ m_nAxisTickLabelHeight = max(static_cast<int>(m_nAxisLabelHeight * 0.8), MIN_FONT_SIZE);
831886
832887 CFont fontTickLabels;
833888 VERIFY(fontTickLabels.CreatePointFont(m_nAxisTickLabelHeight, L"Arial", &dc));
@@ -845,12 +900,11 @@
845900 fontTickLabels.DeleteObject();
846901
847902 // Determine axis specifications.
848- m_ptOrigin.x = m_rcGraph.left + m_nAxisLabelHeight/10 + 2*GAP_PIXELS
849- + sizTickLabel.cx + GAP_PIXELS + TICK_PIXELS;
850- m_ptOrigin.y = m_rcGraph.bottom - m_nAxisLabelHeight/10 - 2*GAP_PIXELS -
851- sizTickLabel.cy - GAP_PIXELS - TICK_PIXELS;
903+ m_ptOrigin.x = m_rcGraph.left + m_nAxisLabelHeight / 10 + 2 * GAP_PIXELS + sizTickLabel.cx + GAP_PIXELS + TICK_PIXELS;
904+ m_ptOrigin.y = m_rcGraph.bottom - m_nAxisLabelHeight / 10 - 2 * GAP_PIXELS -
905+ sizTickLabel.cy - GAP_PIXELS - TICK_PIXELS;
852906 m_nYAxisHeight = m_ptOrigin.y - m_rcTitle.bottom - (2 * GAP_PIXELS);
853- m_nXAxisWidth = (m_rcGraph.Width() - GAP_PIXELS) - m_ptOrigin.x;
907+ m_nXAxisWidth = (m_rcGraph.Width() - GAP_PIXELS) - m_ptOrigin.x;
854908 }
855909 }
856910
@@ -862,7 +916,7 @@
862916
863917 // Create the legend font.
864918 CFont fontLegend;
865- int pointFontHeight = max(m_rcGraph.Height() / LEGEND_DIVISOR, MIN_FONT_SIZE);
919+ int pointFontHeight = max(m_rcGraph.Height() / LEGEND_DIVISOR, MIN_FONT_SIZE);
866920 VERIFY(fontLegend.CreatePointFont(pointFontHeight, L"Arial", &dc));
867921
868922 // Get the height of each label.
@@ -877,16 +931,17 @@
877931 // Calculate optimal label height = AvailableLegendHeight/AllAuthors
878932 // Use a buffer of (GAP_PIXELS / 2) on each side inside the legend, and in addition the same
879933 // gab above and below the legend frame, so in total 2*GAP_PIXELS
880- double optimalLabelHeight = double(m_rcGraph.Height() - 2*GAP_PIXELS)/nLegendEntries;
934+ double optimalLabelHeight = static_cast<double>(m_rcGraph.Height() - 2 * GAP_PIXELS) / nLegendEntries;
881935
882936 // Now relate the LabelHeight to the PointFontHeight
883- int optimalPointFontHeight = int(pointFontHeight*optimalLabelHeight/nLabelHeight);
937+ int optimalPointFontHeight = static_cast<int>(pointFontHeight * optimalLabelHeight / nLabelHeight);
884938
885939 // Limit the optimal PointFontHeight to the available range
886- optimalPointFontHeight = min( max(optimalPointFontHeight, MIN_FONT_SIZE), pointFontHeight);
940+ optimalPointFontHeight = min(max(optimalPointFontHeight, MIN_FONT_SIZE), pointFontHeight);
887941
888942 // If the optimalPointFontHeight is different from the initial one, create a new legend font
889- if (optimalPointFontHeight != pointFontHeight) {
943+ if (optimalPointFontHeight != pointFontHeight)
944+ {
890945 fontLegend.DeleteObject();
891946 VERIFY(fontLegend.CreatePointFont(optimalPointFontHeight, L"Arial", &dc));
892947 VERIFY(fontLegend.GetLogFont(&lf));
@@ -894,9 +949,9 @@
894949 }
895950
896951 // Calculate maximum number of authors that can be shown with the current label height
897- int nShownAuthors = (m_rcGraph.Height() - 2*GAP_PIXELS)/nLabelHeight - 1;
952+ int nShownAuthors = (m_rcGraph.Height() - 2 * GAP_PIXELS) / nLabelHeight - 1;
898953 // Fix rounding errors.
899- if (nShownAuthors+1 == GetMaxSeriesSize())
954+ if (nShownAuthors + 1 == GetMaxSeriesSize())
900955 ++nShownAuthors;
901956
902957 // Get number of authors to be shown.
@@ -911,54 +966,56 @@
911966 int nLegendHeight = (GAP_PIXELS / 2) + (nShownAuthors * nLabelHeight) + (GAP_PIXELS / 2);
912967 // Draw the legend border. Allow LEGEND_COLOR_BAR_PIXELS pixels for
913968 // display of label bars.
914- m_rcLegend.top = (m_rcGraph.Height() - nLegendHeight) / 2;
969+ m_rcLegend.top = (m_rcGraph.Height() - nLegendHeight) / 2;
915970 m_rcLegend.bottom = m_rcLegend.top + nLegendHeight;
916- m_rcLegend.right = m_rcGraph.Width() - GAP_PIXELS;
917- m_rcLegend.left = m_rcLegend.right - GetMaxLegendLabelLength(dc) -
918- LEGEND_COLOR_BAR_WIDTH_PIXELS;
971+ m_rcLegend.right = m_rcGraph.Width() - GAP_PIXELS;
972+ m_rcLegend.left = m_rcLegend.right - GetMaxLegendLabelLength(dc) -
973+ LEGEND_COLOR_BAR_WIDTH_PIXELS;
919974 VERIFY(dc.Rectangle(m_rcLegend));
920975
921- int skipped_row = -1; // if != -1, this is the row that we show the ... in
976+ int skippedRow = -1; // if != -1, this is the row that we show the ... in
922977 if (nShownAuthors < GetMaxSeriesSize())
923- skipped_row = nShownAuthors-2;
978+ skippedRow = nShownAuthors - 2;
924979
925980 dc.SetTextColor(CTheme::Instance().IsDarkTheme() ? CTheme::darkTextColor : GetSysColor(COLOR_WINDOWTEXT));
926981 // Draw each group's label and bar.
927- for (int nGroup = 0; nGroup < nShownAuthors; ++nGroup) {
928-
982+ for (int nGroup = 0; nGroup < nShownAuthors; ++nGroup)
983+ {
929984 int nLabelTop(m_rcLegend.top + (nGroup * nLabelHeight) +
930- (GAP_PIXELS / 2));
985+ (GAP_PIXELS / 2));
931986
932987 int nShownGroup = nGroup; // introduce helper variable to avoid code duplication
933988
934989 // Do we have a skipped row?
935- if (skipped_row != -1)
990+ if (skippedRow != -1)
936991 {
937- if (nGroup == skipped_row) {
992+ if (nGroup == skippedRow)
993+ {
938994 // draw the dots
939- VERIFY(dc.TextOut(m_rcLegend.left + GAP_PIXELS, nLabelTop, L"..." ));
995+ VERIFY(dc.TextOut(m_rcLegend.left + GAP_PIXELS, nLabelTop, L"..."));
940996 continue;
941997 }
942- if (nGroup == nShownAuthors-1) {
998+ if (nGroup == nShownAuthors - 1)
999+ {
9431000 // we show the last group instead of the scheduled group
944- nShownGroup = GetMaxSeriesSize()-1;
1001+ nShownGroup = GetMaxSeriesSize() - 1;
9451002 }
9461003 }
9471004 // Draw the label.
9481005 VERIFY(dc.TextOut(m_rcLegend.left + GAP_PIXELS, nLabelTop,
949- m_saLegendLabels.GetAt(nShownGroup)));
1006+ m_saLegendLabels.GetAt(nShownGroup)));
9501007
9511008 // Determine the bar.
9521009 CRect rcBar;
953- rcBar.left = m_rcLegend.left + GAP_PIXELS + GetMaxLegendLabelLength(dc) + GAP_PIXELS;
954- rcBar.top = nLabelTop + LEGEND_COLOR_BAR_GAP_PIXELS;
955- rcBar.right = m_rcLegend.right - GAP_PIXELS;
1010+ rcBar.left = m_rcLegend.left + GAP_PIXELS + GetMaxLegendLabelLength(dc) + GAP_PIXELS;
1011+ rcBar.top = nLabelTop + LEGEND_COLOR_BAR_GAP_PIXELS;
1012+ rcBar.right = m_rcLegend.right - GAP_PIXELS;
9561013 rcBar.bottom = rcBar.top + nLabelHeight - LEGEND_COLOR_BAR_GAP_PIXELS;
9571014 VERIFY(dc.Rectangle(rcBar));
9581015
9591016 // Draw bar for group.
9601017 COLORREF crBar(m_dwaColors.GetAt(nShownGroup));
961- CBrush br(crBar);
1018+ CBrush br(crBar);
9621019
9631020 CBrush* pBrushOld = dc.SelectObject(&br);
9641021 ASSERT_VALID(pBrushOld);
@@ -990,13 +1047,14 @@
9901047 // Draw x axis.
9911048 dc.MoveTo(m_ptOrigin);
9921049
993- if (m_saLegendLabels.GetSize()) {
994-
1050+ if (m_saLegendLabels.GetSize())
1051+ {
9951052 VERIFY(dc.LineTo(m_ptOrigin.x +
996- (m_nXAxisWidth - m_rcLegend.Width() - (GAP_PIXELS * 2)),
997- m_ptOrigin.y));
1053+ (m_nXAxisWidth - m_rcLegend.Width() - (GAP_PIXELS * 2)),
1054+ m_ptOrigin.y));
9981055 }
999- else {
1056+ else
1057+ {
10001058 VERIFY(dc.LineTo(m_ptOrigin.x + m_nXAxisWidth, m_ptOrigin.y));
10011059 }
10021060
@@ -1027,8 +1085,7 @@
10271085 CLIP_DEFAULT_PRECIS,
10281086 PROOF_QUALITY,
10291087 VARIABLE_PITCH | FF_DONTCARE,
1030- L"Arial")
1031- );
1088+ L"Arial"));
10321089
10331090 // Set the y-axis label font and draw the label.
10341091 CFont* pFontOld = dc.SelectObject(&fontYAxis);
@@ -1035,13 +1092,13 @@
10351092 ASSERT_VALID(pFontOld);
10361093 CSize sizYLabel(dc.GetTextExtent(m_sYAxisLabel));
10371094 VERIFY(dc.TextOut(GAP_PIXELS, (m_rcGraph.Height() + sizYLabel.cx) / 2,
1038- m_sYAxisLabel));
1095+ m_sYAxisLabel));
10391096
10401097 // Set the x-axis label font and draw the label.
10411098 VERIFY(dc.SelectObject(&fontXAxis));
10421099 CSize sizXLabel(dc.GetTextExtent(m_sXAxisLabel));
10431100 VERIFY(dc.TextOut(m_ptOrigin.x + (m_nXAxisWidth - sizXLabel.cx) / 2,
1044- m_rcGraph.bottom - GAP_PIXELS - sizXLabel.cy, m_sXAxisLabel));
1101+ m_rcGraph.bottom - GAP_PIXELS - sizXLabel.cy, m_sXAxisLabel));
10451102
10461103 // chose suitable tick step (1, 2, 5, 10, 20, 50, etc.)
10471104 int nMaxDataValue(GetMaxDataValue());
@@ -1056,8 +1113,8 @@
10561113 nTickStep *= 2;
10571114
10581115 // We hardwire TITLE_DIVISOR y-axis ticks here for simplicity.
1059- int nTickCount(nMaxDataValue / nTickStep);
1060- double tickSpace = (double)m_nYAxisHeight * nTickStep / (double)nMaxDataValue;
1116+ int nTickCount(nMaxDataValue / nTickStep);
1117+ double tickSpace = static_cast<double>(m_nYAxisHeight) * nTickStep / static_cast<double>(nMaxDataValue);
10611118
10621119 // create tick label font and set it in the device context
10631120 CFont fontTickLabels;
@@ -1066,49 +1123,48 @@
10661123
10671124 for (int nTick = 0; nTick < nTickCount; ++nTick)
10681125 {
1069- int nTickYLocation = static_cast<int>(m_ptOrigin.y - tickSpace * (nTick + 1) + 0.5);
1126+ int nTickYLocation = static_cast<int>(m_ptOrigin.y - tickSpace * (nTick + 1LL) + 0.5);
10701127 dc.MoveTo(m_ptOrigin.x - TICK_PIXELS, nTickYLocation);
10711128 VERIFY(dc.LineTo(m_ptOrigin.x + TICK_PIXELS, nTickYLocation));
10721129
10731130 // Draw tick label.
10741131 CString sTickLabel;
1075- sTickLabel.Format(L"%d", nTickStep * (nTick+1));
1132+ sTickLabel.Format(L"%d", nTickStep * (nTick + 1));
10761133 CSize sizTickLabel(dc.GetTextExtent(sTickLabel));
10771134
10781135 VERIFY(dc.TextOut(m_ptOrigin.x - GAP_PIXELS - sizTickLabel.cx - TICK_PIXELS,
1079- nTickYLocation - sizTickLabel.cy/2, sTickLabel));
1136+ nTickYLocation - sizTickLabel.cy / 2, sTickLabel));
10801137 }
10811138
10821139 // Draw X axis tick marks.
10831140 POSITION pos(m_olMyGraphSeries.GetHeadPosition());
1084- int nSeries(0);
1141+ int nSeries(0);
10851142
1086- while (pos) {
1087-
1143+ while (pos)
1144+ {
10881145 MyGraphSeries* pSeries = m_olMyGraphSeries.GetNext(pos);
10891146 ASSERT_VALID(pSeries);
10901147
10911148 // Ignore unpopulated series if bar chart.
1092- if (m_eGraphType != MyGraph::Bar ||
1093- 0 < pSeries->GetNonZeroElementCount()) {
1094-
1149+ if (m_eGraphType != MyGraph::Bar ||
1150+ 0 < pSeries->GetNonZeroElementCount())
1151+ {
10951152 // Get the spacing of the series.
10961153 int nSeriesSpace(0);
10971154
1098- if (m_saLegendLabels.GetSize()) {
1099-
1155+ if (m_saLegendLabels.GetSize())
1156+ {
11001157 nSeriesSpace =
11011158 (m_nXAxisWidth - m_rcLegend.Width() - (GAP_PIXELS * 2)) /
1102- (m_eGraphType == MyGraph::Bar ?
1103- GetNonZeroSeriesCount() : (int)m_olMyGraphSeries.GetCount());
1159+ (m_eGraphType == MyGraph::Bar ? GetNonZeroSeriesCount() : static_cast<int>(m_olMyGraphSeries.GetCount()));
11041160 }
1105- else {
1106- nSeriesSpace = m_nXAxisWidth / (m_eGraphType == MyGraph::Bar ?
1107- GetNonZeroSeriesCount() : (int)m_olMyGraphSeries.GetCount());
1161+ else
1162+ {
1163+ nSeriesSpace = m_nXAxisWidth / (m_eGraphType == MyGraph::Bar ? GetNonZeroSeriesCount() : static_cast<int>(m_olMyGraphSeries.GetCount()));
11081164 }
11091165
11101166 int nTickXLocation(m_ptOrigin.x + ((nSeries + 1) * nSeriesSpace) -
1111- (nSeriesSpace / 2));
1167+ (nSeriesSpace / 2));
11121168
11131169 dc.MoveTo(nTickXLocation, m_ptOrigin.y - TICK_PIXELS);
11141170 VERIFY(dc.LineTo(nTickXLocation, m_ptOrigin.y + TICK_PIXELS));
@@ -1115,10 +1171,10 @@
11151171
11161172 // Draw x-axis tick label.
11171173 CString sTickLabel(pSeries->GetLabel());
1118- CSize sizTickLabel(dc.GetTextExtent(sTickLabel));
1174+ CSize sizTickLabel(dc.GetTextExtent(sTickLabel));
11191175
11201176 VERIFY(dc.TextOut(nTickXLocation - (sizTickLabel.cx / 2),
1121- m_ptOrigin.y + TICK_PIXELS + GAP_PIXELS, sTickLabel));
1177+ m_ptOrigin.y + TICK_PIXELS + GAP_PIXELS, sTickLabel));
11221178
11231179 ++nSeries;
11241180 }
@@ -1139,10 +1195,10 @@
11391195 // How much space does each series get (includes inter series space)?
11401196 // We ignore series whose members are all zero.
11411197 double availableSpace = m_saLegendLabels.GetSize()
1142- ? m_nXAxisWidth - m_rcLegend.Width() - (GAP_PIXELS * 2)
1143- : m_nXAxisWidth;
1198+ ? m_nXAxisWidth - m_rcLegend.Width() - (GAP_PIXELS * 2)
1199+ : m_nXAxisWidth;
11441200
1145- double seriesSpace = availableSpace / (double)GetNonZeroSeriesCount();
1201+ double seriesSpace = availableSpace / static_cast<double>(GetNonZeroSeriesCount());
11461202
11471203 // Determine width of bars. Data points with a value of zero are assumed
11481204 // to be empty. This is a bad assumption.
@@ -1151,62 +1207,65 @@
11511207 // This is the width of the largest series (no inter series space).
11521208 double maxSeriesPlotSize(0.0);
11531209
1154- if(!m_bStackedGraph){
1155- int seriessize = GetMaxNonZeroSeriesSize();
1156- barWidth = seriessize ? seriesSpace / seriessize : 0;
1157- if (1 < GetNonZeroSeriesCount()) {
1210+ if (!m_bStackedGraph)
1211+ {
1212+ int seriesSize = GetMaxNonZeroSeriesSize();
1213+ barWidth = seriesSize ? seriesSpace / seriesSize : 0;
1214+ if (1 < GetNonZeroSeriesCount())
1215+ {
11581216 barWidth *= INTERSERIES_PERCENT_USED;
11591217 }
11601218 maxSeriesPlotSize = GetMaxNonZeroSeriesSize() * barWidth;
11611219 }
1162- else{
1163- barWidth = seriesSpace * INTERSERIES_PERCENT_USED;
1220+ else
1221+ {
1222+ barWidth = seriesSpace * INTERSERIES_PERCENT_USED;
11641223 maxSeriesPlotSize = barWidth;
11651224 }
11661225
11671226 // Iterate the series.
11681227 POSITION pos(m_olMyGraphSeries.GetHeadPosition());
1169- int nSeries(0);
1228+ int nSeries(0);
11701229
1171- while (pos) {
1172-
1230+ while (pos)
1231+ {
11731232 MyGraphSeries* pSeries = m_olMyGraphSeries.GetNext(pos);
11741233 ASSERT_VALID(pSeries);
11751234
11761235 // Ignore unpopulated series.
1177- if (0 < pSeries->GetNonZeroElementCount()) {
1178-
1236+ if (0 < pSeries->GetNonZeroElementCount())
1237+ {
11791238 // Draw each bar; empty bars are not drawn.
1180- double runningLeft(m_ptOrigin.x + (nSeries + 1) * seriesSpace -
1181- maxSeriesPlotSize);
1239+ double runningLeft(m_ptOrigin.x + (nSeries + 1LL) * seriesSpace -
1240+ maxSeriesPlotSize);
11821241
11831242 double stackAccumulator(0.0);
11841243
1185- for (int nGroup = 0; nGroup < GetMaxSeriesSize(); ++nGroup) {
1186-
1187- if (pSeries->GetData(nGroup)) {
1188-
1244+ for (int nGroup = 0; nGroup < GetMaxSeriesSize(); ++nGroup)
1245+ {
1246+ if (pSeries->GetData(nGroup))
1247+ {
11891248 int nMaxDataValue(GetMaxDataValue());
11901249 nMaxDataValue = max(nMaxDataValue, 1);
1191- double barTop = m_ptOrigin.y - (double)m_nYAxisHeight *
1192- pSeries->GetData(nGroup) / (double)nMaxDataValue - stackAccumulator;
1250+ double barTop = m_ptOrigin.y - static_cast<double>(m_nYAxisHeight) * pSeries->GetData(nGroup) / static_cast<double>(nMaxDataValue) - stackAccumulator;
11931251
11941252 CRect rcBar;
1195- rcBar.left = (int)runningLeft;
1196- rcBar.top = (int)barTop;
1253+ rcBar.left = static_cast<int>(runningLeft);
1254+ rcBar.top = static_cast<int>(barTop);
11971255 // Make adjacent bar borders overlap, so there's only one pixel border line between them.
1198- rcBar.right = (int)(runningLeft + barWidth) + 1;
1199- rcBar.bottom = (int)((double)m_ptOrigin.y - stackAccumulator) + 1;
1256+ rcBar.right = static_cast<int>(runningLeft + barWidth) + 1;
1257+ rcBar.bottom = static_cast<int>(static_cast<double>(m_ptOrigin.y) - stackAccumulator) + 1;
12001258
1201- if(m_bStackedGraph){
1202- stackAccumulator = (double)m_ptOrigin.y - barTop;
1259+ if (m_bStackedGraph)
1260+ {
1261+ stackAccumulator = static_cast<double>(m_ptOrigin.y) - barTop;
12031262 }
12041263
12051264 pSeries->SetTipRegion(nGroup, rcBar);
12061265
12071266 COLORREF crBar(m_dwaColors.GetAt(nGroup));
1208- CBrush br(crBar);
1209- CBrush* pBrushOld = dc.SelectObject(&br);
1267+ CBrush br(crBar);
1268+ CBrush* pBrushOld = dc.SelectObject(&br);
12101269 ASSERT_VALID(pBrushOld);
12111270
12121271 VERIFY(dc.Rectangle(rcBar));
@@ -1213,7 +1272,8 @@
12131272 dc.SelectObject(pBrushOld);
12141273 br.DeleteObject();
12151274
1216- if(!m_bStackedGraph){
1275+ if (!m_bStackedGraph)
1276+ {
12171277 runningLeft += barWidth;
12181278 }
12191279 }
@@ -1222,12 +1282,13 @@
12221282 ++nSeries;
12231283 }
12241284 }
1225- if (!m_bStackedGraph) {
1226- int nMaxDataValue = max(GetMaxDataValue(), 1);
1227- double barTop = m_ptOrigin.y - (double)m_nYAxisHeight *
1228- (GetAverageDataValue() / (double)nMaxDataValue);
1229- dc.MoveTo(m_ptOrigin.x, (int)barTop);
1230- VERIFY(dc.LineTo(m_ptOrigin.x + (m_nXAxisWidth - m_rcLegend.Width() - (GAP_PIXELS * 2)), (int)barTop));
1285+ if (!m_bStackedGraph)
1286+ {
1287+ int nMaxDataValue = max(GetMaxDataValue(), 1);
1288+ double barTop = m_ptOrigin.y - static_cast<double>(m_nYAxisHeight) *
1289+ (GetAverageDataValue() / static_cast<double>(nMaxDataValue));
1290+ dc.MoveTo(m_ptOrigin.x, static_cast<int>(barTop));
1291+ VERIFY(dc.LineTo(m_ptOrigin.x + (m_nXAxisWidth - m_rcLegend.Width() - (GAP_PIXELS * 2)), static_cast<int>(barTop)));
12311292 }
12321293 }
12331294
@@ -1239,21 +1300,22 @@
12391300 _ASSERTE(!m_bStackedGraph);
12401301
12411302 // Iterate the groups.
1242- CPoint ptLastLoc(0,0);
1243- int dataLastLoc(0);
1303+ CPoint ptLastLoc(0, 0);
1304+ int dataLastLoc(0);
12441305
1245- for (int nGroup = 0; nGroup < GetMaxSeriesSize(); nGroup++) {
1246-
1306+ for (int nGroup = 0; nGroup < GetMaxSeriesSize(); nGroup++)
1307+ {
12471308 // How much space does each series get (includes inter series space)?
12481309 int nSeriesSpace(0);
12491310
1250- if (m_saLegendLabels.GetSize()) {
1251-
1311+ if (m_saLegendLabels.GetSize())
1312+ {
12521313 nSeriesSpace = (m_nXAxisWidth - m_rcLegend.Width() - (GAP_PIXELS * 2)) /
1253- (int)m_olMyGraphSeries.GetCount();
1314+ static_cast<int>(m_olMyGraphSeries.GetCount());
12541315 }
1255- else {
1256- nSeriesSpace = m_nXAxisWidth / (int)m_olMyGraphSeries.GetCount();
1316+ else
1317+ {
1318+ nSeriesSpace = m_nXAxisWidth / static_cast<int>(m_olMyGraphSeries.GetCount());
12571319 }
12581320
12591321 // Determine width of bars.
@@ -1261,8 +1323,9 @@
12611323 nMaxSeriesSize = max(nMaxSeriesSize, 1);
12621324 int nBarWidth(nSeriesSpace / nMaxSeriesSize);
12631325
1264- if (1 < m_olMyGraphSeries.GetCount()) {
1265- nBarWidth = (int) ((double) nBarWidth * INTERSERIES_PERCENT_USED);
1326+ if (1 < m_olMyGraphSeries.GetCount())
1327+ {
1328+ nBarWidth = static_cast<int>(static_cast<double>(nBarWidth) * INTERSERIES_PERCENT_USED);
12661329 }
12671330
12681331 // This is the width of the largest series (no inter series space).
@@ -1273,35 +1336,34 @@
12731336
12741337 // Build objects.
12751338 COLORREF crLine(m_dwaColors.GetAt(nGroup));
1276- CBrush br(crLine);
1277- CBrush* pBrushOld = dc.SelectObject(&br);
1339+ CBrush br(crLine);
1340+ CBrush* pBrushOld = dc.SelectObject(&br);
12781341 ASSERT_VALID(pBrushOld);
1279- CPen penLine(PS_SOLID, 1, crLine);
1342+ CPen penLine(PS_SOLID, 1, crLine);
12801343 CPen* pPenOld = dc.SelectObject(&penLine);
12811344 ASSERT_VALID(pPenOld);
12821345
1283- for (int nSeries = 0; nSeries < m_olMyGraphSeries.GetCount(); ++nSeries) {
1284-
1346+ for (int nSeries = 0; nSeries < m_olMyGraphSeries.GetCount(); ++nSeries)
1347+ {
12851348 MyGraphSeries* pSeries = m_olMyGraphSeries.GetNext(pos);
12861349 ASSERT_VALID(pSeries);
12871350
12881351 // Get x and y location of center of ellipse.
1289- CPoint ptLoc(0,0);
1352+ CPoint ptLoc(0, 0);
12901353
12911354 ptLoc.x = m_ptOrigin.x + (((nSeries + 1) * nSeriesSpace) -
1292- (nSeriesSpace / 2));
1355+ (nSeriesSpace / 2));
12931356
12941357 int nMaxDataValue(GetMaxDataValue());
12951358 nMaxDataValue = max(nMaxDataValue, 1);
12961359 double dLineHeight(pSeries->GetData(nGroup) * m_nYAxisHeight /
1297- double(nMaxDataValue));
1360+ static_cast<double>(nMaxDataValue));
12981361
1299- ptLoc.y = (int) ((double) m_ptOrigin.y - dLineHeight);
1362+ ptLoc.y = static_cast<int>(static_cast<double>(m_ptOrigin.y) - dLineHeight);
13001363
1301-
13021364 // Draw line back to last data member.
1303- if (nSeries > 0 && (pSeries->GetData(nGroup)!=0 || dataLastLoc != 0)) {
1304-
1365+ if (nSeries > 0 && (pSeries->GetData(nGroup) != 0 || dataLastLoc != 0))
1366+ {
13051367 dc.MoveTo(ptLastLoc.x, ptLastLoc.y - 1);
13061368 VERIFY(dc.LineTo(ptLoc.x - 1, ptLoc.y - 1));
13071369 }
@@ -1308,7 +1370,8 @@
13081370
13091371 // Now draw ellipse.
13101372 CRect rcEllipse(ptLoc.x - 3, ptLoc.y - 3, ptLoc.x + 3, ptLoc.y + 3);
1311- if(pSeries->GetData(nGroup)!=0){
1373+ if (pSeries->GetData(nGroup) != 0)
1374+ {
13121375 VERIFY(dc.Ellipse(rcEllipse));
13131376 }
13141377 if (m_olMyGraphSeries.GetCount() < 40)
@@ -1317,7 +1380,7 @@
13171380 }
13181381
13191382 // Save last pt and data
1320- ptLastLoc = ptLoc;
1383+ ptLastLoc = ptLoc;
13211384 dataLastLoc = pSeries->GetData(nGroup);
13221385 }
13231386 VERIFY(dc.SelectObject(pPenOld));
@@ -1326,11 +1389,11 @@
13261389 br.DeleteObject();
13271390 }
13281391
1329- int nMaxDataValue = max(GetMaxDataValue(), 1);
1330- double barTop = m_ptOrigin.y - (double)m_nYAxisHeight *
1331- (GetAverageDataValue() / (double)nMaxDataValue);
1332- dc.MoveTo(m_ptOrigin.x, (int)barTop);
1333- VERIFY(dc.LineTo(m_ptOrigin.x + (m_nXAxisWidth - m_rcLegend.Width() - (GAP_PIXELS * 2)), (int)barTop));
1392+ int nMaxDataValue = max(GetMaxDataValue(), 1);
1393+ double barTop = m_ptOrigin.y - static_cast<double>(m_nYAxisHeight) *
1394+ (GetAverageDataValue() / static_cast<double>(nMaxDataValue));
1395+ dc.MoveTo(m_ptOrigin.x, static_cast<int>(barTop));
1396+ VERIFY(dc.LineTo(m_ptOrigin.x + (m_nXAxisWidth - m_rcLegend.Width() - (GAP_PIXELS * 2)), static_cast<int>(barTop)));
13341397 }
13351398
13361399 //
@@ -1340,7 +1403,7 @@
13401403 ASSERT_VALID(&dc);
13411404 _ASSERTE(m_bStackedGraph);
13421405
1343- int nSeriesCount = (int)m_olMyGraphSeries.GetCount();
1406+ int nSeriesCount = static_cast<int>(m_olMyGraphSeries.GetCount());
13441407
13451408 CArray<int> stackAccumulator;
13461409 stackAccumulator.SetSize(nSeriesCount);
@@ -1348,74 +1411,83 @@
13481411 CArray<CPoint> polygon;
13491412 // Special case: if we only have single series, make polygon
13501413 // a bar instead of one pixel line.
1351- polygon.SetSize(nSeriesCount==1 ? 4 : nSeriesCount * 2);
1414+ polygon.SetSize(nSeriesCount == 1 ? 4 : nSeriesCount * 2);
13521415
13531416 // How much space does each series get?
13541417 int nSeriesSpace(0);
1355- if (m_saLegendLabels.GetSize()) {
1418+ if (m_saLegendLabels.GetSize())
1419+ {
13561420 nSeriesSpace = (m_nXAxisWidth - m_rcLegend.Width() - (GAP_PIXELS * 2)) /
1357- nSeriesCount;
1421+ nSeriesCount;
13581422 }
1359- else {
1423+ else
1424+ {
13601425 nSeriesSpace = m_nXAxisWidth / nSeriesCount;
13611426 }
13621427
13631428 int nMaxDataValue(GetMaxDataValue());
1364- nMaxDataValue = max(nMaxDataValue, 1);
1365- double dYScaling = double(m_nYAxisHeight) / nMaxDataValue;
1429+ nMaxDataValue = max(nMaxDataValue, 1);
1430+ double dYScaling = static_cast<double>(m_nYAxisHeight) / nMaxDataValue;
13661431
13671432 // Iterate the groups.
1368- for (int nGroup = 0; nGroup < GetMaxSeriesSize(); nGroup++) {
1369-
1433+ for (int nGroup = 0; nGroup < GetMaxSeriesSize(); nGroup++)
1434+ {
13701435 // Build objects.
13711436 COLORREF crGroup(m_dwaColors.GetAt(nGroup));
1372- CBrush br(crGroup);
1373- CBrush* pBrushOld = dc.SelectObject(&br);
1437+ CBrush br(crGroup);
1438+ CBrush* pBrushOld = dc.SelectObject(&br);
13741439 ASSERT_VALID(pBrushOld);
13751440 // For polygon outline, use average of this and previous color, and darken it.
1376- COLORREF crPrevGroup(nGroup > 0 ? m_dwaColors.GetAt(nGroup-1) : crGroup);
1441+ COLORREF crPrevGroup(nGroup > 0 ? m_dwaColors.GetAt(nGroup - 1LL) : crGroup);
13771442 COLORREF crOutline = RGB(
1378- (GetRValue(crGroup)+GetRValue(crPrevGroup))/3,
1379- (GetGValue(crGroup)+GetGValue(crPrevGroup))/3,
1380- (GetBValue(crGroup)+GetBValue(crPrevGroup))/3);
1381- CPen penLine(PS_SOLID, 1, crOutline);
1443+ (GetRValue(crGroup) + GetRValue(crPrevGroup)) / 3,
1444+ (GetGValue(crGroup) + GetGValue(crPrevGroup)) / 3,
1445+ (GetBValue(crGroup) + GetBValue(crPrevGroup)) / 3);
1446+ CPen penLine(PS_SOLID, 1, crOutline);
13821447 CPen* pPenOld = dc.SelectObject(&penLine);
13831448 ASSERT_VALID(pPenOld);
13841449
13851450 // Construct bottom part of polygon from current stack accumulator
1386- for (int nPolyBottom = 0; nPolyBottom < nSeriesCount; ++nPolyBottom) {
1451+ for (int nPolyBottom = 0; nPolyBottom < nSeriesCount; ++nPolyBottom)
1452+ {
13871453 CPoint ptLoc;
13881454 ptLoc.x = m_ptOrigin.x + (((nPolyBottom + 1) * nSeriesSpace) - (nSeriesSpace / 2));
13891455 double dLineHeight((stackAccumulator[nPolyBottom]) * dYScaling);
1390- ptLoc.y = (int) ((double) m_ptOrigin.y - dLineHeight);
1456+ ptLoc.y = static_cast<int>(static_cast<double>(m_ptOrigin.y) - dLineHeight);
13911457
1392- if (nSeriesCount > 1) {
1393- polygon[nSeriesCount-nPolyBottom-1] = ptLoc;
1394- } else {
1458+ if (nSeriesCount > 1)
1459+ {
1460+ polygon[nSeriesCount - nPolyBottom - 1LL] = ptLoc;
1461+ }
1462+ else
1463+ {
13951464 // special case: when there's one series, make polygon a bar
1396- polygon[0] = CPoint(ptLoc.x-GAP_PIXELS/2, ptLoc.y);
1397- polygon[1] = CPoint(ptLoc.x+GAP_PIXELS/2, ptLoc.y);
1465+ polygon[0] = CPoint(ptLoc.x - GAP_PIXELS / 2, ptLoc.y);
1466+ polygon[1] = CPoint(ptLoc.x + GAP_PIXELS / 2, ptLoc.y);
13981467 }
13991468 }
14001469
14011470 // Iterate the series, construct upper part of polygon and upadte stack accumulator
14021471 POSITION pos(m_olMyGraphSeries.GetHeadPosition());
1403- for (int nSeries = 0; nSeries < nSeriesCount; ++nSeries) {
1404-
1472+ for (int nSeries = 0; nSeries < nSeriesCount; ++nSeries)
1473+ {
14051474 MyGraphSeries* pSeries = m_olMyGraphSeries.GetNext(pos);
14061475 ASSERT_VALID(pSeries);
14071476
14081477 CPoint ptLoc;
14091478 ptLoc.x = m_ptOrigin.x + (((nSeries + 1) * nSeriesSpace) -
1410- (nSeriesSpace / 2));
1479+ (nSeriesSpace / 2));
14111480 double dLineHeight((pSeries->GetData(nGroup) + stackAccumulator[nSeries]) * dYScaling);
1412- ptLoc.y = (int) ((double) m_ptOrigin.y - dLineHeight);
1413- if (nSeriesCount > 1) {
1414- polygon[nSeriesCount+nSeries] = ptLoc;
1415- } else {
1481+ ptLoc.y = static_cast<int>(static_cast<double>(m_ptOrigin.y) - dLineHeight);
1482+ if (nSeriesCount > 1)
1483+ {
1484+ polygon[nSeriesCount + nSeries] = ptLoc;
1485+ }
1486+ else
1487+ {
14161488 // special case: when there's one series, make polygon a bar
1417- polygon[2] = CPoint(ptLoc.x+GAP_PIXELS/2, ptLoc.y);
1418- polygon[3] = CPoint(ptLoc.x-GAP_PIXELS/2, ptLoc.y);
1489+ polygon[2] = CPoint(ptLoc.x + GAP_PIXELS / 2, ptLoc.y);
1490+ polygon[3] = CPoint(ptLoc.x - GAP_PIXELS / 2, ptLoc.y);
14191491 }
14201492
14211493 stackAccumulator[nSeries] += pSeries->GetData(nGroup);
@@ -1422,7 +1494,7 @@
14221494 }
14231495
14241496 // Draw polygon
1425- VERIFY(dc.Polygon(polygon.GetData(), (int)polygon.GetSize()));
1497+ VERIFY(dc.Polygon(polygon.GetData(), static_cast<int>(polygon.GetSize())));
14261498
14271499 VERIFY(dc.SelectObject(pPenOld));
14281500 penLine.DeleteObject();
@@ -1443,7 +1515,8 @@
14431515 int seriesCount = GetNonZeroSeriesCount();
14441516 int horizontalSpace(0);
14451517
1446- if (m_saLegendLabels.GetSize()) {
1518+ if (m_saLegendLabels.GetSize())
1519+ {
14471520 // With legend box.
14481521
14491522 horizontalSpace = m_nXAxisWidth - m_rcLegend.Width() - (GAP_PIXELS * 2);
@@ -1450,24 +1523,29 @@
14501523 int nPieAndSpaceWidth(horizontalSpace / (seriesCount ? seriesCount : 1));
14511524
14521525 // Height is limiting factor.
1453- if (nPieAndSpaceWidth > m_nYAxisHeight - (GAP_PIXELS * 2)) {
1526+ if (nPieAndSpaceWidth > m_nYAxisHeight - (GAP_PIXELS * 2))
1527+ {
14541528 nSeriesSpace = (m_nYAxisHeight - (GAP_PIXELS * 2));
14551529 }
1456- else {
1530+ else
1531+ {
14571532 // Width is limiting factor.
14581533 nSeriesSpace = nPieAndSpaceWidth;
14591534 }
14601535 }
1461- else {
1536+ else
1537+ {
14621538 // No legend box.
14631539
14641540 horizontalSpace = m_nXAxisWidth;
14651541
14661542 // Height is limiting factor.
1467- if (m_nXAxisWidth > m_nYAxisHeight * (seriesCount ? seriesCount : 1)) {
1543+ if (m_nXAxisWidth > m_nYAxisHeight * (seriesCount ? seriesCount : 1))
1544+ {
14681545 nSeriesSpace = m_nYAxisHeight;
14691546 }
1470- else {
1547+ else
1548+ {
14711549 // Width is limiting factor.
14721550 nSeriesSpace = m_nXAxisWidth / (seriesCount ? seriesCount : 1);
14731551 }
@@ -1478,24 +1556,24 @@
14781556
14791557 // Create font for labels.
14801558 CFont fontLabels;
1481- int pointFontHeight = max(m_rcGraph.Height() / Y_AXIS_LABEL_DIVISOR, MIN_FONT_SIZE);
1559+ int pointFontHeight = max(m_rcGraph.Height() / Y_AXIS_LABEL_DIVISOR, MIN_FONT_SIZE);
14821560 VERIFY(fontLabels.CreatePointFont(pointFontHeight, L"Arial", &dc));
14831561 CFont* pFontOld = dc.SelectObject(&fontLabels);
14841562 ASSERT_VALID(pFontOld);
14851563
14861564 // Draw each pie.
1487- int nPie(0);
1488- int nRadius((int) (nSeriesSpace * INTERSERIES_PERCENT_USED / 2.0));
1565+ int nPie(0);
1566+ int nRadius(static_cast<int>(nSeriesSpace * INTERSERIES_PERCENT_USED / 2.0));
14891567 POSITION pos(m_olMyGraphSeries.GetHeadPosition());
14901568
1491- while (pos) {
1492-
1569+ while (pos)
1570+ {
14931571 MyGraphSeries* pSeries = m_olMyGraphSeries.GetNext(pos);
14941572 ASSERT_VALID(pSeries);
14951573
14961574 // Don't leave a space for empty pies.
1497- if (0 < pSeries->GetNonZeroElementCount()) {
1498-
1575+ if (0 < pSeries->GetNonZeroElementCount())
1576+ {
14991577 // Locate this pie.
15001578 CPoint ptCenter;
15011579 ptCenter.x = xOrigin + (nSeriesSpace * nPie) + nSeriesSpace / 2;
@@ -1502,9 +1580,9 @@
15021580 ptCenter.y = m_ptOrigin.y - m_nYAxisHeight / 2;
15031581
15041582 CRect rcPie;
1505- rcPie.left = ptCenter.x - nRadius;
1506- rcPie.right = ptCenter.x + nRadius;
1507- rcPie.top = ptCenter.y - nRadius;
1583+ rcPie.left = ptCenter.x - nRadius;
1584+ rcPie.right = ptCenter.x + nRadius;
1585+ rcPie.top = ptCenter.y - nRadius;
15081586 rcPie.bottom = ptCenter.y + nRadius;
15091587
15101588 // Draw series label.
@@ -1511,7 +1589,7 @@
15111589 CSize sizPieLabel(dc.GetTextExtent(pSeries->GetLabel()));
15121590
15131591 VERIFY(dc.TextOut(ptCenter.x - (sizPieLabel.cx / 2),
1514- ptCenter.y + nRadius + GAP_PIXELS, pSeries->GetLabel()));
1592+ ptCenter.y + nRadius + GAP_PIXELS, pSeries->GetLabel()));
15151593
15161594 // How much do the wedges total to?
15171595 double dPieTotal(pSeries->GetDataTotal());
@@ -1520,11 +1598,11 @@
15201598 CPoint ptStart(rcPie.left, ptCenter.y);
15211599 double dRunningWedgeTotal(0.0);
15221600
1523- for (int nGroup = 0; nGroup < m_saLegendLabels.GetSize(); ++nGroup) {
1524-
1601+ for (int nGroup = 0; nGroup < m_saLegendLabels.GetSize(); ++nGroup)
1602+ {
15251603 // Ignore empty wedges.
1526- if (0 < pSeries->GetData(nGroup)) {
1527-
1604+ if (0 < pSeries->GetData(nGroup))
1605+ {
15281606 // Get the degrees of this wedge.
15291607 dRunningWedgeTotal += pSeries->GetData(nGroup);
15301608 double dPercent(dRunningWedgeTotal * 100.0 / dPieTotal);
@@ -1536,8 +1614,9 @@
15361614 // Special case: a wedge that takes up the whole pie would
15371615 // otherwise be confused with an empty wedge.
15381616 bool drawEmptyWedges = false;
1539- if (1 == pSeries->GetNonZeroElementCount()) {
1540- _ASSERTE(360 == (int)degrees && ptStart == ptEnd && "This is the problem we're correcting");
1617+ if (1 == pSeries->GetNonZeroElementCount())
1618+ {
1619+ _ASSERTE(360 == static_cast<int>(degrees) && ptStart == ptEnd && "This is the problem we're correcting");
15411620 --ptEnd.y;
15421621 drawEmptyWedges = true;
15431622 }
@@ -1547,13 +1626,13 @@
15471626 // where center and both endpoints lie on the same coordinate,
15481627 // and endpoints differ only in one pixel. GDI draws such pie as whole pie,
15491628 // so we just skip them instead.
1550- int distance = abs(ptStart.x-ptEnd.x) + abs(ptStart.y-ptEnd.y);
1551- if (drawEmptyWedges || distance > 1) {
1552-
1629+ int distance = abs(ptStart.x - ptEnd.x) + abs(ptStart.y - ptEnd.y);
1630+ if (drawEmptyWedges || distance > 1)
1631+ {
15531632 // Draw wedge.
15541633 COLORREF crWedge(m_dwaColors.GetAt(nGroup));
1555- CBrush br(crWedge);
1556- CBrush* pBrushOld = dc.SelectObject(&br);
1634+ CBrush br(crWedge);
1635+ CBrush* pBrushOld = dc.SelectObject(&br);
15571636 ASSERT_VALID(pBrushOld);
15581637 VERIFY(dc.Pie(rcPie, ptStart, ptEnd));
15591638
@@ -1579,8 +1658,8 @@
15791658
15801659 // Draw X axis title
15811660 CSize sizXLabel(dc.GetTextExtent(m_sXAxisLabel));
1582- VERIFY(dc.TextOut(xOrigin + (nSeriesSpace * nPie - sizXLabel.cx)/2,
1583- m_ptOrigin.y - m_nYAxisHeight/2 + nRadius + GAP_PIXELS*2 + sizXLabel.cy, m_sXAxisLabel));
1661+ VERIFY(dc.TextOut(xOrigin + (nSeriesSpace * nPie - sizXLabel.cx) / 2,
1662+ m_ptOrigin.y - m_nYAxisHeight / 2 + nRadius + GAP_PIXELS * 2 + sizXLabel.cy, m_sXAxisLabel));
15841663
15851664 VERIFY(dc.SelectObject(pFontOld));
15861665 fontLabels.DeleteObject();
@@ -1588,7 +1667,7 @@
15881667
15891668 // Convert degrees to x and y coords.
15901669 CPoint MyGraph::WedgeEndFromDegrees(double degrees, const CPoint& ptCenter,
1591- double radius) const
1670+ double radius) const
15921671 {
15931672 VALIDATE;
15941673
@@ -1596,10 +1675,10 @@
15961675
15971676 double radians = degrees / 360.0 * M_PI * 2.0;
15981677
1599- pt.x = (int) (radius * cos(radians));
1678+ pt.x = static_cast<int>(radius * cos(radians));
16001679 pt.x = ptCenter.x - pt.x;
16011680
1602- pt.y = (int) (radius * sin(radians));
1681+ pt.y = static_cast<int>(radius * sin(radians));
16031682 pt.y = ptCenter.y + pt.y;
16041683
16051684 return pt;
@@ -1607,15 +1686,16 @@
16071686
16081687 // Spin The Message Loop: C++ version. See "Advanced Windows Programming",
16091688 // M. Heller, p. 153, and the MS TechNet CD, PSS ID Number: Q99999.
1610-/* static */ UINT MyGraph::SpinTheMessageLoop(bool bNoDrawing /* = false */ ,
1611- bool bOnlyDrawing /* = false */ ,
1612- UINT uiMsgAllowed /* = WM_NULL */ )
1689+/* static */ UINT MyGraph::SpinTheMessageLoop(bool bNoDrawing /* = false */,
1690+ bool bOnlyDrawing /* = false */,
1691+ UINT uiMsgAllowed /* = WM_NULL */)
16131692 {
1614- MSG msg = {0};
1615- while (::PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) {
1616-
1693+ MSG msg = {nullptr};
1694+ while (::PeekMessage(&msg, nullptr, 0, 0, PM_REMOVE))
1695+ {
16171696 // Do painting only.
1618- if (bOnlyDrawing && WM_PAINT == msg.message) {
1697+ if (bOnlyDrawing && WM_PAINT == msg.message)
1698+ {
16191699 ::TranslateMessage(&msg);
16201700 ::DispatchMessage(&msg);
16211701
@@ -1623,23 +1703,26 @@
16231703 AfxGetApp()->OnIdle(0);
16241704 }
16251705 // Do everything *but* painting.
1626- else if (bNoDrawing && WM_PAINT == msg.message) {
1706+ else if (bNoDrawing && WM_PAINT == msg.message)
1707+ {
16271708 break;
16281709 }
16291710 // Special handling for this message.
1630- else if (WM_QUIT == msg.message) {
1711+ else if (WM_QUIT == msg.message)
1712+ {
16311713 ::PostQuitMessage(static_cast<int>(msg.wParam));
16321714 break;
16331715 }
16341716 // Allow one message (like WM_LBUTTONDOWN).
1635- else if (uiMsgAllowed == msg.message
1636- && ! AfxGetApp()->PreTranslateMessage(&msg)) {
1717+ else if (uiMsgAllowed == msg.message && !AfxGetApp()->PreTranslateMessage(&msg))
1718+ {
16371719 ::TranslateMessage(&msg);
16381720 ::DispatchMessage(&msg);
16391721 break;
16401722 }
16411723 // This is the general case.
1642- else if (! bOnlyDrawing && ! AfxGetApp()->PreTranslateMessage(&msg)) {
1724+ else if (!bOnlyDrawing && !AfxGetApp()->PreTranslateMessage(&msg))
1725+ {
16431726 ::TranslateMessage(&msg);
16441727 ::DispatchMessage(&msg);
16451728
@@ -1652,22 +1735,20 @@
16521735 return msg.message;
16531736 }
16541737
1655-
16561738 /////////////////////////////////////////////////////////////////////////////
16571739 // Conversion routines: RGB to HLS (Red-Green-Blue to Hue-Luminosity-Saturation).
16581740 // See Microsoft KnowledgeBase article Q29240.
16591741
1660-#define HLSMAX 240 // H,L, and S vary over 0-HLSMAX
1661-#define RGBMAX 255 // R,G, and B vary over 0-RGBMAX
1662- // HLSMAX BEST IF DIVISIBLE BY 6
1663- // RGBMAX, HLSMAX must each fit in a byte (255).
1742+#define HLSMAX 240 // H,L, and S vary over 0-HLSMAX
1743+#define RGBMAX 255 // R,G, and B vary over 0-RGBMAX \
1744+ // HLSMAX BEST IF DIVISIBLE BY 6 \
1745+ // RGBMAX, HLSMAX must each fit in a byte (255).
16641746
1665-#define UNDEFINED (HLSMAX * 2 / 3) // Hue is undefined if Saturation is 0
1666- // (grey-scale). This value determines
1667- // where the Hue scrollbar is initially
1668- // set for achromatic colors.
1747+#define UNDEFINED (HLSMAX * 2 / 3) // Hue is undefined if Saturation is 0 \
1748+ // (grey-scale). This value determines \
1749+ // where the Hue scrollbar is initially \
1750+ // set for achromatic colors.
16691751
1670-
16711752 // Convert HLS to RGB.
16721753 /* static */ COLORREF MyGraph::HLStoRGB(WORD wH, WORD wL, WORD wS)
16731754 {
@@ -1680,35 +1761,40 @@
16801761 WORD wB(0);
16811762
16821763 // Achromatic case.
1683- if (0 == wS) {
1764+ if (0 == wS)
1765+ {
16841766 wR = wG = wB = (wL * RGBMAX) / HLSMAX;
16851767
1686- if (UNDEFINED != wH) {
1687- _ASSERTE(! "ERROR");
1768+ if (UNDEFINED != wH)
1769+ {
1770+ _ASSERTE(!"ERROR");
16881771 }
16891772 }
1690- else {
1773+ else
1774+ {
16911775 // Chromatic case.
1692- WORD Magic1(0);
1693- WORD Magic2(0);
1776+ WORD magic1(0);
1777+ WORD magic2(0);
16941778
16951779 // Set up magic numbers.
1696- if (wL <= HLSMAX / 2) {
1697- Magic2 = (wL * (HLSMAX + wS) + (HLSMAX / 2)) / HLSMAX;
1780+ if (wL <= HLSMAX / 2)
1781+ {
1782+ magic2 = (wL * (HLSMAX + wS) + (HLSMAX / 2)) / HLSMAX;
16981783 }
1699- else {
1700- Magic2 = wL + wS - ((wL * wS) + (HLSMAX / 2)) / HLSMAX;
1784+ else
1785+ {
1786+ magic2 = wL + wS - ((wL * wS) + (HLSMAX / 2)) / HLSMAX;
17011787 }
17021788
1703- Magic1 = 2 * wL - Magic2;
1789+ magic1 = 2 * wL - magic2;
17041790
17051791 // Get RGB, change units from HLSMAX to RGBMAX.
1706- wR = (HueToRGB(Magic1, Magic2, wH + (HLSMAX / 3)) * RGBMAX + (HLSMAX / 2)) / HLSMAX;
1707- wG = (HueToRGB(Magic1, Magic2, wH) * RGBMAX + (HLSMAX / 2)) / HLSMAX;
1708- wB = (HueToRGB(Magic1, Magic2, wH - (HLSMAX / 3)) * RGBMAX + (HLSMAX / 2)) / HLSMAX;
1792+ wR = (HueToRGB(magic1, magic2, wH + (HLSMAX / 3)) * RGBMAX + (HLSMAX / 2)) / HLSMAX;
1793+ wG = (HueToRGB(magic1, magic2, wH) * RGBMAX + (HLSMAX / 2)) / HLSMAX;
1794+ wB = (HueToRGB(magic1, magic2, wH - (HLSMAX / 3)) * RGBMAX + (HLSMAX / 2)) / HLSMAX;
17091795 }
17101796
1711- return RGB(wR,wG,wB);
1797+ return RGB(wR, wG, wB);
17121798 }
17131799
17141800 // Utility routine for HLStoRGB.
@@ -1715,24 +1801,28 @@
17151801 /* static */ WORD MyGraph::HueToRGB(WORD w1, WORD w2, WORD wH)
17161802 {
17171803 // Range check: note values passed add/subtract thirds of range.
1718- if (wH > HLSMAX) {
1804+ if (wH > HLSMAX)
1805+ {
17191806 wH -= HLSMAX;
17201807 }
17211808
17221809 // Return r, g, or b value from this tridrant.
1723- if (wH < HLSMAX / 6) {
1810+ if (wH < HLSMAX / 6)
1811+ {
17241812 return w1 + (((w2 - w1) * wH + (HLSMAX / 12)) / (HLSMAX / 6));
17251813 }
17261814
1727- if (wH < HLSMAX / 2) {
1815+ if (wH < HLSMAX / 2)
1816+ {
17281817 return w2;
17291818 }
17301819
1731- if (wH < (HLSMAX * 2) / 3) {
1820+ if (wH < (HLSMAX * 2) / 3)
1821+ {
17321822 return w1 + (((w2 - w1) * (((HLSMAX * 2) / 3) - wH) + (HLSMAX / 12)) / (HLSMAX / 6));
17331823 }
1734- else {
1824+ else
1825+ {
17351826 return w1;
17361827 }
17371828 }
1738-
--- trunk/src/Utils/MiscUI/MyGraph.h (revision 29188)
+++ trunk/src/Utils/MiscUI/MyGraph.h (revision 29189)
@@ -2,7 +2,6 @@
22
33 #pragma once
44
5-
65 /////////////////////////////////////////////////////////////////////////////
76 // MyGraphSeries
87
@@ -10,25 +9,29 @@
109 {
1110 friend class MyGraph;
1211
13-// Construction.
12+ // Construction.
1413 public:
1514 MyGraphSeries(const CString& sLabel = L"");
16- virtual ~MyGraphSeries();
15+ ~MyGraphSeries() override;
1716
18-// Declared but not defined.
17+ // Declared but not defined.
1918 private:
2019 MyGraphSeries(const MyGraphSeries& rhs) = delete;
2120 MyGraphSeries& operator=(const MyGraphSeries& rhs) = delete;
2221
23-// Operations.
22+ // Operations.
2423 public:
25- void Clear() {m_dwaValues.RemoveAll(); m_oaRegions.RemoveAll();}
24+ void Clear()
25+ {
26+ m_dwaValues.RemoveAll();
27+ m_oaRegions.RemoveAll();
28+ }
2629 void SetLabel(const CString& sLabel);
2730 CString GetLabel() const;
2831 void SetData(int nGroup, int nValue);
2932 int GetData(int nGroup) const;
3033
31-// Implementation.
34+ // Implementation.
3235 private:
3336 int GetMaxDataValue(bool bStackedGraph) const;
3437 int GetAverageDataValue() const;
@@ -37,113 +40,111 @@
3740 void SetTipRegion(int nGroup, const CRect& rc);
3841 void SetTipRegion(int nGroup, CRgn* prgn);
3942 int HitTest(const CPoint& pt, int searchStart) const;
40- CString GetTipText(int nGroup, const CString &unitString) const;
43+ CString GetTipText(int nGroup, const CString& unitString) const;
4144
42-// Data.
45+ // Data.
4346 private:
44- CString m_sLabel; // Series label.
45- CDWordArray m_dwaValues; // Values array.
46- CArray<CRgn*,CRgn*> m_oaRegions; // Tooltip regions.
47+ CString m_sLabel; // Series label.
48+ CDWordArray m_dwaValues; // Values array.
49+ CArray<CRgn*, CRgn*> m_oaRegions; // Tooltip regions.
4750 };
4851
49-
5052 /////////////////////////////////////////////////////////////////////////////
5153 // MyGraph
5254
5355 class MyGraph : public CStatic
5456 {
55-// Enum.
57+ // Enum.
5658 public:
57- enum GraphType { Bar, Line, PieChart }; // Renamed 'Pie' because it hides a GDI function name
59+ enum GraphType
60+ {
61+ Bar,
62+ Line,
63+ PieChart
64+ }; // Renamed 'Pie' because it hides a GDI function name
5865
59-// Construction.
66+ // Construction.
6067 public:
6168 MyGraph(GraphType eGraphType = MyGraph::PieChart, bool bStackedGraph = false);
62- virtual ~MyGraph();
69+ ~MyGraph() override;
6370
64-// Declared but not defined.
71+ // Declared but not defined.
6572 private:
6673 MyGraph(const MyGraph& rhs) = delete;
6774 MyGraph& operator=(const MyGraph& rhs) = delete;
6875
69-// Operations.
76+ // Operations.
7077 public:
71- void Clear();
72- void AddSeries(MyGraphSeries& rMyGraphSeries);
73- void SetXAxisLabel(const CString& sLabel);
74- void SetYAxisLabel(const CString& sLabel);
75- int AppendGroup(const CString& sLabel);
76- void SetLegend(int nGroup, const CString& sLabel);
77- void SetGraphType(GraphType eType, bool bStackedGraph);
78- void SetGraphTitle(const CString& sTitle);
79- int LookupLabel(const CString& sLabel) const;
80- void DrawGraph(CDC& dc);
78+ void Clear();
79+ void AddSeries(MyGraphSeries& rMyGraphSeries);
80+ void SetXAxisLabel(const CString& sLabel);
81+ void SetYAxisLabel(const CString& sLabel);
82+ int AppendGroup(const CString& sLabel);
83+ void SetLegend(int nGroup, const CString& sLabel);
84+ void SetGraphType(GraphType eType, bool bStackedGraph);
85+ void SetGraphTitle(const CString& sTitle);
86+ int LookupLabel(const CString& sLabel) const;
87+ void DrawGraph(CDC& dc);
8188
82-// Implementation.
89+ // Implementation.
8390 private:
84- void DrawTitle(CDC& dc);
85- void SetupAxes(CDC& dc);
86- void DrawAxes(CDC& dc) const;
87- void DrawLegend(CDC& dc);
88- void DrawSeriesBar(CDC& dc) const;
89- void DrawSeriesLine(CDC& dc) const;
90- void DrawSeriesLineStacked(CDC& dc) const;
91- void DrawSeriesPie(CDC& dc) const;
91+ void DrawTitle(CDC& dc);
92+ void SetupAxes(CDC& dc);
93+ void DrawAxes(CDC& dc) const;
94+ void DrawLegend(CDC& dc);
95+ void DrawSeriesBar(CDC& dc) const;
96+ void DrawSeriesLine(CDC& dc) const;
97+ void DrawSeriesLineStacked(CDC& dc) const;
98+ void DrawSeriesPie(CDC& dc) const;
9299
93- int GetMaxLegendLabelLength(CDC& dc) const;
94- int GetMaxSeriesSize() const;
95- int GetMaxNonZeroSeriesSize() const;
96- int GetMaxDataValue() const;
97- int GetAverageDataValue() const;
98- int GetNonZeroSeriesCount() const;
100+ int GetMaxLegendLabelLength(CDC& dc) const;
101+ int GetMaxSeriesSize() const;
102+ int GetMaxNonZeroSeriesSize() const;
103+ int GetMaxDataValue() const;
104+ int GetAverageDataValue() const;
105+ int GetNonZeroSeriesCount() const;
99106
100107 CString GetTipText() const;
101108
102- INT_PTR OnToolHitTest(CPoint point, TOOLINFO* pTI) const;
109+ INT_PTR OnToolHitTest(CPoint point, TOOLINFO* pTi) const override;
103110
104- CPoint WedgeEndFromDegrees(double degrees, const CPoint& ptCenter,
105- double radius) const;
111+ CPoint WedgeEndFromDegrees(double degrees, const CPoint& ptCenter,
112+ double radius) const;
106113
107- static UINT SpinTheMessageLoop(bool bNoDrawing = false,
108- bool bOnlyDrawing = false,
109- UINT uiMsgAllowed = WM_NULL);
114+ static UINT SpinTheMessageLoop(bool bNoDrawing = false,
115+ bool bOnlyDrawing = false,
116+ UINT uiMsgAllowed = WM_NULL);
110117
111- static void RGBtoHLS(COLORREF crRGB, WORD& wH, WORD& wL, WORD& wS);
112- static COLORREF HLStoRGB(WORD wH, WORD wL, WORD wS);
113- static WORD HueToRGB(WORD w1, WORD w2, WORD wH);
118+ static void RGBtoHLS(COLORREF crRGB, WORD& wH, WORD& wL, WORD& wS);
119+ static COLORREF HLStoRGB(WORD wH, WORD wL, WORD wS);
120+ static WORD HueToRGB(WORD w1, WORD w2, WORD wH);
114121
115- // Overrides
116- // ClassWizard generated virtual function overrides
117- //{{AFX_VIRTUAL(MyGraph)
118- protected:
119- virtual void PreSubclassWindow();
120- //}}AFX_VIRTUAL
122+protected:
123+ void PreSubclassWindow() override;
121124
122-// Generated message map functions
125+ // Generated message map functions
123126 protected:
124- //{{AFX_MSG(MyGraph)
125127 afx_msg void OnPaint();
126128 afx_msg void OnSize(UINT nType, int cx, int cy);
127- //}}AFX_MSG
128129 afx_msg BOOL OnNeedText(UINT uiId, NMHDR* pNMHDR, LRESULT* pResult);
129130 DECLARE_MESSAGE_MAP()
130131
131-// Data.
132+ // Data.
132133 private:
133- int m_nXAxisWidth;
134- int m_nYAxisHeight;
135- int m_nAxisLabelHeight;
136- int m_nAxisTickLabelHeight;
137- CPoint m_ptOrigin;
138- CRect m_rcGraph;
139- CRect m_rcLegend;
140- CRect m_rcTitle;
141- CString m_sXAxisLabel;
142- CString m_sYAxisLabel;
143- CString m_sTitle;
144- CDWordArray m_dwaColors;
145- CStringArray m_saLegendLabels;
146- CList<MyGraphSeries*,MyGraphSeries*> m_olMyGraphSeries;
147- GraphType m_eGraphType;
148- bool m_bStackedGraph;
134+ int m_nXAxisWidth;
135+ int m_nYAxisHeight;
136+ int m_nAxisLabelHeight;
137+ int m_nAxisTickLabelHeight;
138+ CPoint m_ptOrigin;
139+ CRect m_rcGraph;
140+ CRect m_rcLegend;
141+ CRect m_rcTitle;
142+ CString m_sXAxisLabel;
143+ CString m_sYAxisLabel;
144+ CString m_sTitle;
145+ CDWordArray m_dwaColors;
146+ CStringArray m_saLegendLabels;
147+ CList<MyGraphSeries*, MyGraphSeries*> m_olMyGraphSeries;
148+ GraphType m_eGraphType;
149+ bool m_bStackedGraph;
149150 };
--- trunk/src/Utils/MiscUI/PathEdit.cpp (revision 29188)
+++ trunk/src/Utils/MiscUI/PathEdit.cpp (revision 29189)
@@ -1,6 +1,6 @@
1-// TortoiseSVN - a Windows shell extension for easy version control
1+// TortoiseSVN - a Windows shell extension for easy version control
22
3-// Copyright (C) 2009-2010, 2014, 2017 - TortoiseSVN
3+// Copyright (C) 2009-2010, 2014, 2017, 2021 - TortoiseSVN
44
55 // This program is free software; you can redistribute it and/or
66 // modify it under the terms of the GNU General Public License
@@ -17,7 +17,6 @@
1717 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
1818 //
1919 #include "stdafx.h"
20-#include "TortoiseProc.h"
2120 #include "PathEdit.h"
2221 #include "StringUtils.h"
2322
@@ -34,7 +33,7 @@
3433
3534 CPathEdit::~CPathEdit()
3635 {
37- if ((HFONT)m_boldFont)
36+ if (static_cast<HFONT>(m_boldFont))
3837 m_boldFont.DeleteObject();
3938 }
4039
@@ -50,56 +49,52 @@
5049
5150 switch (message)
5251 {
53- case WM_SIZE:
52+ case WM_SIZE:
5453 {
5554 CString path = m_sRealText;
5655 FitPathToWidth(path);
5756 m_bInternalCall = true;
58- CEdit::SendMessage(WM_SETTEXT, 0, (LPARAM)(LPCTSTR)path);
57+ CEdit::SendMessage(WM_SETTEXT, 0, reinterpret_cast<LPARAM>(static_cast<LPCWSTR>(path)));
5958 m_bInternalCall = false;
6059 return CEdit::DefWindowProc(message, wParam, lParam);
6160 }
62- break;
63- case WM_SETTEXT:
61+ case WM_SETTEXT:
6462 {
65- m_sRealText = (LPCTSTR)lParam;
63+ m_sRealText = reinterpret_cast<LPCWSTR>(lParam);
6664 m_tooltips.AddTool(this, m_sRealText);
6765 CString path = m_sRealText;
6866 FitPathToWidth(path);
69- lParam = (LPARAM)(LPCTSTR)path;
67+ lParam = reinterpret_cast<LPARAM>(static_cast<LPCWSTR>(path));
7068 LRESULT ret = CEdit::DefWindowProc(message, wParam, lParam);
7169 return ret;
7270 }
73- break;
74- case WM_GETTEXT:
71+ case WM_GETTEXT:
7572 {
7673 // return the real text
77- wcsncpy_s((TCHAR*)lParam, wParam, (LPCTSTR)m_sRealText, _TRUNCATE);
78- return wcslen((TCHAR*)lParam);
74+ wcsncpy_s(reinterpret_cast<wchar_t*>(lParam), wParam, static_cast<LPCWSTR>(m_sRealText), _TRUNCATE);
75+ return wcslen(reinterpret_cast<wchar_t*>(lParam));
7976 }
80- break;
81- case WM_GETTEXTLENGTH:
77+ case WM_GETTEXTLENGTH:
8278 {
8379 return m_sRealText.GetLength();
8480 }
85- break;
86- case WM_COPY:
81+ case WM_COPY:
8782 {
8883 int start, end;
8984 m_bInternalCall = true;
9085 CEdit::GetSel(start, end);
9186 m_bInternalCall = false;
92- CString selText = m_sFitText.Mid(start, end-start);
93- if (m_sFitText.Find(L"..")<0)
87+ CString selText = m_sFitText.Mid(start, end - start);
88+ if (m_sFitText.Find(L"..") < 0)
9489 return CStringUtils::WriteAsciiStringToClipboard(selText, m_hWnd);
95- if (selText.Find(L"...")>=0)
90+ if (selText.Find(L"...") >= 0)
9691 {
97- int dotLength = m_sRealText.GetLength()-m_sFitText.GetLength();
98- selText = m_sRealText.Mid(start, end-start+dotLength);
92+ int dotLength = m_sRealText.GetLength() - m_sFitText.GetLength();
93+ selText = m_sRealText.Mid(start, end - start + dotLength);
9994 return CStringUtils::WriteAsciiStringToClipboard(selText, m_hWnd);
10095 }
101- if ((m_sFitText.Left(start).Find(L"...")>=0) ||
102- (m_sFitText.Mid(end).Find(L"...")>=0))
96+ if ((m_sFitText.Left(start).Find(L"...") >= 0) ||
97+ (m_sFitText.Mid(end).Find(L"...") >= 0))
10398 {
10499 return CStringUtils::WriteAsciiStringToClipboard(selText, m_hWnd);
105100 }
@@ -106,7 +101,6 @@
106101 // we shouldn't get here, but just in case: copy *all* the text, not just the selected text
107102 return CStringUtils::WriteAsciiStringToClipboard(m_sRealText, m_hWnd);
108103 }
109- break;
110104 }
111105
112106 return CEdit::DefWindowProc(message, wParam, lParam);
@@ -116,13 +110,13 @@
116110 {
117111 CRect rect;
118112 GetClientRect(&rect);
119- rect.right -= 5; // assume a border size of 5 pixels
113+ rect.right -= 5; // assume a border size of 5 pixels
120114
121- CDC * pDC = GetDC();
115+ CDC* pDC = GetDC();
122116 if (pDC)
123117 {
124118 CFont* previousFont = pDC->SelectObject(GetFont());
125- path = path.Left(MAX_PATH - 1);
119+ path = path.Left(MAX_PATH - 1);
126120 PathCompactPath(pDC->m_hDC, path.GetBuffer(MAX_PATH), rect.Width());
127121 path.ReleaseBuffer();
128122 m_sFitText = path;
@@ -138,15 +132,15 @@
138132 SetFont(GetFont());
139133 }
140134
141-CFont * CPathEdit::GetFont()
135+CFont* CPathEdit::GetFont()
142136 {
143137 if (!m_bBold)
144138 return __super::GetFont();
145139
146- if ((HFONT)m_boldFont == NULL)
140+ if (static_cast<HFONT>(m_boldFont) == nullptr)
147141 {
148- HFONT hFont = (HFONT)SendMessage(WM_GETFONT);
149- LOGFONT lf = {0};
142+ HFONT hFont = reinterpret_cast<HFONT>(SendMessage(WM_GETFONT));
143+ LOGFONT lf = {0};
150144 GetObject(hFont, sizeof(LOGFONT), &lf);
151145 lf.lfWeight = FW_BOLD;
152146 m_boldFont.CreateFontIndirect(&lf);
--- trunk/src/Utils/MiscUI/PathEdit.h (revision 29188)
+++ trunk/src/Utils/MiscUI/PathEdit.h (revision 29189)
@@ -1,6 +1,6 @@
1-// TortoiseSVN - a Windows shell extension for easy version control
1+// TortoiseSVN - a Windows shell extension for easy version control
22
3-// Copyright (C) 2009-2010, 2017 - TortoiseSVN
3+// Copyright (C) 2009-2010, 2017, 2021 - TortoiseSVN
44
55 // This program is free software; you can redistribute it and/or
66 // modify it under the terms of the GNU General Public License
@@ -32,23 +32,23 @@
3232
3333 public:
3434 CPathEdit();
35- virtual ~CPathEdit();
36- void SetBold();
35+ ~CPathEdit() override;
36+ void SetBold();
3737
3838 protected:
3939 DECLARE_MESSAGE_MAP()
4040 public:
41- virtual LRESULT DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam);
42- virtual BOOL PreTranslateMessage(MSG* pMsg);
43- virtual ULONG GetGestureStatus(CPoint ptTouch) override;
41+ LRESULT DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam) override;
42+ BOOL PreTranslateMessage(MSG* pMsg) override;
43+ ULONG GetGestureStatus(CPoint ptTouch) override;
4444
4545 private:
46- CString m_sRealText;
47- CString m_sFitText;
48- bool m_bInternalCall;
49- bool m_bBold;
50- CFont m_boldFont;
51- void FitPathToWidth(CString& path);
52- CFont * GetFont();
53- CToolTips m_tooltips;
46+ CString m_sRealText;
47+ CString m_sFitText;
48+ bool m_bInternalCall;
49+ bool m_bBold;
50+ CFont m_boldFont;
51+ void FitPathToWidth(CString& path);
52+ CFont* GetFont();
53+ CToolTips m_tooltips;
5454 };
--- trunk/src/Utils/MiscUI/RegexEdit.cpp (revision 29188)
+++ trunk/src/Utils/MiscUI/RegexEdit.cpp (revision 29189)
@@ -1,6 +1,6 @@
1-// TortoiseSVN - a Windows shell extension for easy version control
1+// TortoiseSVN - a Windows shell extension for easy version control
22
3-// Copyright (C) 2011-2012, 2016 - TortoiseSVN
3+// Copyright (C) 2011-2012, 2016, 2021 - TortoiseSVN
44
55 // This program is free software; you can redistribute it and/or
66 // modify it under the terms of the GNU General Public License
@@ -32,12 +32,10 @@
3232 {
3333 }
3434
35-
3635 BEGIN_MESSAGE_MAP(CRegexEdit, CEdit)
3736 ON_WM_CTLCOLOR_REFLECT()
3837 END_MESSAGE_MAP()
3938
40-
4139 HBRUSH CRegexEdit::CtlColor(CDC* pDC, UINT /*nCtlColor*/)
4240 {
4341 // check if the regex is valid
@@ -55,12 +53,11 @@
5553
5654 if (!m_bValid)
5755 {
58- pDC->SetBkColor(GetSysColor(COLOR_3DFACE) - RGB(0,20,20));
59- if (m_invalidBkgnd.GetSafeHandle() == NULL)
60- m_invalidBkgnd.CreateSolidBrush(GetSysColor(COLOR_3DFACE) - RGB(0,20,20));
61- return (HBRUSH)m_invalidBkgnd.GetSafeHandle();
56+ pDC->SetBkColor(GetSysColor(COLOR_3DFACE) - RGB(0, 20, 20));
57+ if (m_invalidBkgnd.GetSafeHandle() == nullptr)
58+ m_invalidBkgnd.CreateSolidBrush(GetSysColor(COLOR_3DFACE) - RGB(0, 20, 20));
59+ return static_cast<HBRUSH>(m_invalidBkgnd.GetSafeHandle());
6260 }
6361
64- return NULL;
62+ return nullptr;
6563 }
66-
--- trunk/src/Utils/MiscUI/RegexEdit.h (revision 29188)
+++ trunk/src/Utils/MiscUI/RegexEdit.h (revision 29189)
@@ -1,6 +1,6 @@
1-// TortoiseSVN - a Windows shell extension for easy version control
1+// TortoiseSVN - a Windows shell extension for easy version control
22
3-// Copyright (C) 2011 - TortoiseSVN
3+// Copyright (C) 2011, 2021 - TortoiseSVN
44
55 // This program is free software; you can redistribute it and/or
66 // modify it under the terms of the GNU General Public License
@@ -29,7 +29,7 @@
2929
3030 public:
3131 CRegexEdit();
32- virtual ~CRegexEdit();
32+ ~CRegexEdit() override;
3333
3434 bool IsValidRegex() const { return m_bValid; }
3535
@@ -38,8 +38,6 @@
3838 afx_msg HBRUSH CtlColor(CDC* /*pDC*/, UINT /*nCtlColor*/);
3939
4040 private:
41- CBrush m_invalidBkgnd;
42- bool m_bValid;
41+ CBrush m_invalidBkgnd;
42+ bool m_bValid;
4343 };
44-
45-
--- trunk/src/Utils/MiscUI/SciEdit.cpp (revision 29188)
+++ trunk/src/Utils/MiscUI/SciEdit.cpp (revision 29189)
@@ -1,6 +1,6 @@
11 // TortoiseSVN - a Windows shell extension for easy version control
22
3-// Copyright (C) 2003-2020 - TortoiseSVN
3+// Copyright (C) 2003-2021 - TortoiseSVN
44 // Copyright (C) 2015-2020 - TortoiseGit
55
66 // This program is free software; you can redistribute it and/or
@@ -19,7 +19,6 @@
1919 //
2020 #include "stdafx.h"
2121 #include "resource.h"
22-#include "AppUtils.h"
2322 #include "PathUtils.h"
2423 #include "UnicodeUtils.h"
2524 #include <string>
@@ -28,60 +27,60 @@
2827 #include "OnOutOfScope.h"
2928 #include "LoadIconEx.h"
3029 #include "Theme.h"
30+#include "SciLexer.h"
3131
32+void CSciEditContextMenuInterface::InsertMenuItems(CMenu&, int&) { return; }
33+bool CSciEditContextMenuInterface::HandleMenuItemClick(int, CSciEdit*) { return false; }
34+void CSciEditContextMenuInterface::HandleSnippet(int, const CString&, CSciEdit*) { return; }
3235
33-void CSciEditContextMenuInterface::InsertMenuItems(CMenu&, int&) {return;}
34-bool CSciEditContextMenuInterface::HandleMenuItemClick(int, CSciEdit *) {return false;}
35-void CSciEditContextMenuInterface::HandleSnippet(int, const CString &, CSciEdit *) { return; }
36+#define STYLE_ISSUEBOLD 11
37+#define STYLE_ISSUEBOLDITALIC 12
38+#define STYLE_BOLD 14
39+#define STYLE_ITALIC 15
40+#define STYLE_UNDERLINED 16
41+#define STYLE_URL 17
42+#define INDIC_MISSPELLED 18
3643
37-
38-#define STYLE_ISSUEBOLD 11
39-#define STYLE_ISSUEBOLDITALIC 12
40-#define STYLE_BOLD 14
41-#define STYLE_ITALIC 15
42-#define STYLE_UNDERLINED 16
43-#define STYLE_URL 17
44-#define INDIC_MISSPELLED 18
45-
4644 #define STYLE_MASK 0x1f
4745
48-#define SCI_ADDWORD 2000
46+#define SCI_ADDWORD 2000
4947
50-struct loc_map {
51- const char * cp;
52- const char * def_enc;
48+struct LocMap
49+{
50+ const char* cp;
51+ const char* defEnc;
5352 };
5453
55-struct loc_map enc2locale[] = {
56- {"28591","ISO8859-1"},
57- {"28592","ISO8859-2"},
58- {"28593","ISO8859-3"},
59- {"28594","ISO8859-4"},
60- {"28595","ISO8859-5"},
61- {"28596","ISO8859-6"},
62- {"28597","ISO8859-7"},
63- {"28598","ISO8859-8"},
64- {"28599","ISO8859-9"},
65- {"28605","ISO8859-15"},
66- {"20866","KOI8-R"},
67- {"21866","KOI8-U"},
68- {"1251","microsoft-cp1251"},
69- {"65001","UTF-8"},
70- };
54+struct LocMap enc2Locale[] = {
55+ {"28591", "ISO8859-1"},
56+ {"28592", "ISO8859-2"},
57+ {"28593", "ISO8859-3"},
58+ {"28594", "ISO8859-4"},
59+ {"28595", "ISO8859-5"},
60+ {"28596", "ISO8859-6"},
61+ {"28597", "ISO8859-7"},
62+ {"28598", "ISO8859-8"},
63+ {"28599", "ISO8859-9"},
64+ {"28605", "ISO8859-15"},
65+ {"20866", "KOI8-R"},
66+ {"21866", "KOI8-U"},
67+ {"1251", "microsoft-cp1251"},
68+ {"65001", "UTF-8"},
69+};
7170
72-
7371 IMPLEMENT_DYNAMIC(CSciEdit, CWnd)
7472
75-CSciEdit::CSciEdit(void) : m_DirectFunction(NULL)
76- , m_DirectPointer(NULL)
77- , m_bDoStyle(false)
78- , m_spellcodepage(0)
73+CSciEdit::CSciEdit()
74+ : m_directFunction(NULL)
75+ , m_directPointer(NULL)
76+ , m_spellCodepage(0)
7977 , m_separator(' ')
8078 , m_typeSeparator('?')
79+ , m_bDoStyle(false)
8180 , m_nAutoCompleteMinChars(3)
8281 , m_spellCheckerFactory(nullptr)
83- , m_SpellChecker(nullptr)
84- , m_SpellingCache(2000)
82+ , m_spellChecker(nullptr)
83+ , m_spellingCache(2000)
8584 , m_blockModifiedHandler(false)
8685 , m_bReadOnly(false)
8786 , m_themeCallbackId(0)
@@ -89,7 +88,7 @@
8988 m_hModule = ::LoadLibrary(L"SciLexer.DLL");
9089 }
9190
92-CSciEdit::~CSciEdit(void)
91+CSciEdit::~CSciEdit()
9392 {
9493 CTheme::Instance().RemoveRegisteredCallback(m_themeCallbackId);
9594 m_personalDict.Save();
@@ -108,50 +107,48 @@
108107 if (!GetObject(iconInfo.hbmColor, sizeof(BITMAP), &bm))
109108 return nullptr;
110109
111- int width = bm.bmWidth;
112- int height = bm.bmHeight;
113- int bytesPerScanLine = (width * 3 + 3) & 0xFFFFFFFC;
114- int size = bytesPerScanLine * height;
115- BITMAPINFO infoheader;
116- infoheader.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
117- infoheader.bmiHeader.biWidth = width;
118- infoheader.bmiHeader.biHeight = height;
119- infoheader.bmiHeader.biPlanes = 1;
120- infoheader.bmiHeader.biBitCount = 24;
121- infoheader.bmiHeader.biCompression = BI_RGB;
122- infoheader.bmiHeader.biSizeImage = size;
110+ int width = bm.bmWidth;
111+ int height = bm.bmHeight;
112+ int bytesPerScanLine = (width * 3 + 3) & 0xFFFFFFFC;
113+ int size = bytesPerScanLine * height;
114+ BITMAPINFO infoHeader;
115+ infoHeader.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
116+ infoHeader.bmiHeader.biWidth = width;
117+ infoHeader.bmiHeader.biHeight = height;
118+ infoHeader.bmiHeader.biPlanes = 1;
119+ infoHeader.bmiHeader.biBitCount = 24;
120+ infoHeader.bmiHeader.biCompression = BI_RGB;
121+ infoHeader.bmiHeader.biSizeImage = size;
123122
124- auto ptrb = std::make_unique<BYTE[]>(size * 2 + height * width * 4);
123+ auto ptrb = std::make_unique<BYTE[]>(size * 2LL + height * width * 4LL);
125124 LPBYTE pixelsIconRGB = ptrb.get();
126- LPBYTE alphaPixels = pixelsIconRGB + size;
127- HDC hDC = CreateCompatibleDC(nullptr);
125+ LPBYTE alphaPixels = pixelsIconRGB + size;
126+ HDC hDC = CreateCompatibleDC(nullptr);
128127 OnOutOfScope(DeleteDC(hDC));
129- HBITMAP hBmpOld = (HBITMAP)SelectObject(hDC, (HGDIOBJ)iconInfo.hbmColor);
130- if (!GetDIBits(hDC, iconInfo.hbmColor, 0, height, (LPVOID)pixelsIconRGB, &infoheader, DIB_RGB_COLORS))
128+ HBITMAP hBmpOld = static_cast<HBITMAP>(SelectObject(hDC, static_cast<HGDIOBJ>(iconInfo.hbmColor)));
129+ if (!GetDIBits(hDC, iconInfo.hbmColor, 0, height, static_cast<LPVOID>(pixelsIconRGB), &infoHeader, DIB_RGB_COLORS))
131130 return nullptr;
132131
133132 SelectObject(hDC, hBmpOld);
134- if (!GetDIBits(hDC, iconInfo.hbmMask, 0,height, (LPVOID)alphaPixels, &infoheader, DIB_RGB_COLORS))
133+ if (!GetDIBits(hDC, iconInfo.hbmMask, 0, height, static_cast<LPVOID>(alphaPixels), &infoHeader, DIB_RGB_COLORS))
135134 return nullptr;
136135
137136 auto imagePixels = std::make_unique<UINT[]>(height * width);
138- int lsSrc = width * 3;
139- int vsDest = height - 1;
137+ int lsSrc = width * 3;
138+ int vsDest = height - 1;
140139 for (int y = 0; y < height; y++)
141140 {
142- int linePosSrc = (vsDest - y) * lsSrc;
141+ int linePosSrc = (vsDest - y) * lsSrc;
143142 int linePosDest = y * width;
144143 for (int x = 0; x < width; x++)
145144 {
146- int currentDestPos = linePosDest + x;
147- int currentSrcPos = linePosSrc + x * 3;
148- imagePixels[currentDestPos] = (((UINT)(
149- (
150- ((pixelsIconRGB[currentSrcPos + 2] /*Red*/)
151- | (pixelsIconRGB[currentSrcPos + 1] << 8 /*Green*/))
152- | pixelsIconRGB[currentSrcPos] << 16 /*Blue*/
153- )
154- | ((alphaPixels[currentSrcPos] ? 0 : 0xff) << 24))) & 0xffffffff);
145+ int currentDestPos = linePosDest + x;
146+ int currentSrcPos = linePosSrc + x * 3;
147+ imagePixels[currentDestPos] = (static_cast<UINT>((
148+ ((pixelsIconRGB[currentSrcPos + 2] /*Red*/) | (pixelsIconRGB[currentSrcPos + 1] << 8 /*Green*/)) | pixelsIconRGB[currentSrcPos] << 16 /*Blue*/
149+ ) |
150+ ((alphaPixels[currentSrcPos] ? 0 : 0xff) << 24)) &
151+ 0xffffffff);
155152 }
156153 }
157154 return imagePixels;
@@ -160,15 +157,15 @@
160157 void CSciEdit::Init(LONG lLanguage)
161158 {
162159 //Setup the direct access data
163- m_DirectFunction = SendMessage(SCI_GETDIRECTFUNCTION, 0, 0);
164- m_DirectPointer = SendMessage(SCI_GETDIRECTPOINTER, 0, 0);
160+ m_directFunction = SendMessage(SCI_GETDIRECTFUNCTION, 0, 0);
161+ m_directPointer = SendMessage(SCI_GETDIRECTPOINTER, 0, 0);
165162 Call(SCI_SETMARGINWIDTHN, 1, 0);
166- Call(SCI_SETUSETABS, 0); //pressing TAB inserts spaces
163+ Call(SCI_SETUSETABS, 0); //pressing TAB inserts spaces
167164 Call(SCI_SETWRAPVISUALFLAGS, SC_WRAPVISUALFLAG_END);
168165 Call(SCI_AUTOCSETIGNORECASE, 1);
169166 Call(SCI_SETLEXER, SCLEX_CONTAINER);
170167 Call(SCI_SETCODEPAGE, SC_CP_UTF8);
171- Call(SCI_AUTOCSETFILLUPS, 0, (LPARAM)"\t([");
168+ Call(SCI_AUTOCSETFILLUPS, 0, reinterpret_cast<LPARAM>("\t(["));
172169 Call(SCI_AUTOCSETMAXWIDTH, 0);
173170 //Set the default windows colors for edit controls
174171 Call(SCI_STYLESETFORE, STYLE_DEFAULT, ::GetSysColor(COLOR_WINDOWTEXT));
@@ -176,50 +173,50 @@
176173 Call(SCI_SETCARETFORE, ::GetSysColor(COLOR_WINDOWTEXT));
177174 Call(SCI_SETMODEVENTMASK, SC_MOD_INSERTTEXT | SC_MOD_DELETETEXT | SC_PERFORMED_UNDO | SC_PERFORMED_REDO);
178175 Call(SCI_INDICSETSTYLE, INDIC_MISSPELLED, INDIC_SQUIGGLE);
179- Call(SCI_INDICSETFORE, INDIC_MISSPELLED, RGB(255,0,0));
176+ Call(SCI_INDICSETFORE, INDIC_MISSPELLED, RGB(255, 0, 0));
180177 CStringA sWordChars;
181178 CStringA sWhiteSpace;
182- for (int i=0; i<255; ++i)
179+ for (int i = 0; i < 255; ++i)
183180 {
184181 if (i == '\r' || i == '\n')
185182 continue;
186183 else if (i < 0x20 || i == ' ')
187- sWhiteSpace += (char)i;
184+ sWhiteSpace += static_cast<char>(i);
188185 else if (isalnum(i) || i == '\'' || i == '_' || i == '-')
189- sWordChars += (char)i;
186+ sWordChars += static_cast<char>(i);
190187 }
191- Call(SCI_SETWORDCHARS, 0, (LPARAM)(LPCSTR)sWordChars);
192- Call(SCI_SETWHITESPACECHARS, 0, (LPARAM)(LPCSTR)sWhiteSpace);
193- m_bDoStyle = ((DWORD)CRegStdDWORD(L"Software\\TortoiseSVN\\StyleCommitMessages", TRUE))==TRUE;
194- m_nAutoCompleteMinChars= (int)(DWORD)CRegStdDWORD(L"Software\\TortoiseSVN\\AutoCompleteMinChars", 3);
188+ Call(SCI_SETWORDCHARS, 0, reinterpret_cast<LPARAM>(static_cast<LPCSTR>(sWordChars)));
189+ Call(SCI_SETWHITESPACECHARS, 0, reinterpret_cast<LPARAM>(static_cast<LPCSTR>(sWhiteSpace)));
190+ m_bDoStyle = static_cast<DWORD>(CRegStdDWORD(L"Software\\TortoiseSVN\\StyleCommitMessages", TRUE)) == TRUE;
191+ m_nAutoCompleteMinChars = static_cast<int>(static_cast<DWORD>(CRegStdDWORD(L"Software\\TortoiseSVN\\AutoCompleteMinChars", 3)));
195192 // look for dictionary files and use them if found
196- long langId = GetUserDefaultLCID();
193+ long langId = GetUserDefaultLCID();
197194 long origLangId = langId;
198195 if (lLanguage > 0)
199196 {
200197 // if a specific language is requested, then use that
201- langId = lLanguage;
198+ langId = lLanguage;
202199 origLangId = lLanguage;
203200 }
204201 if (lLanguage >= 0)
205202 {
206- if (((DWORD)CRegStdDWORD(L"Software\\TortoiseSVN\\Spellchecker", FALSE))==FALSE)
203+ if (static_cast<DWORD>(CRegStdDWORD(L"Software\\TortoiseSVN\\Spellchecker", FALSE)) == FALSE)
207204 {
208205 // first try the Win8 spell checker
209- BOOL supported = FALSE;
210- HRESULT hr = CoCreateInstance(__uuidof(SpellCheckerFactory), nullptr, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&m_spellCheckerFactory));
211- bool bFallbackUsed = false;
206+ BOOL supported = FALSE;
207+ HRESULT hr = CoCreateInstance(__uuidof(SpellCheckerFactory), nullptr, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&m_spellCheckerFactory));
208+ bool bFallbackUsed = false;
212209 if (SUCCEEDED(hr))
213210 {
214- wchar_t localename[LOCALE_NAME_MAX_LENGTH] = {0};
211+ wchar_t localeName[LOCALE_NAME_MAX_LENGTH] = {0};
215212 do
216213 {
217- LCIDToLocaleName(langId, localename, _countof(localename), 0);
214+ LCIDToLocaleName(langId, localeName, _countof(localeName), 0);
218215 supported = FALSE;
219- hr = m_spellCheckerFactory->IsSupported(localename, &supported);
216+ hr = m_spellCheckerFactory->IsSupported(localeName, &supported);
220217 if (supported)
221218 {
222- hr = m_spellCheckerFactory->CreateSpellChecker(localename, &m_SpellChecker);
219+ hr = m_spellCheckerFactory->CreateSpellChecker(localeName, &m_spellChecker);
223220 if (SUCCEEDED(hr))
224221 {
225222 m_personalDict.Init(langId);
@@ -245,7 +242,7 @@
245242 {
246243 if (bFallbackUsed)
247244 langId = origLangId;
248- if ((lLanguage == 0)||(lLanguage && !LoadDictionaries(lLanguage)))
245+ if ((lLanguage == 0) || (lLanguage && !LoadDictionaries(lLanguage)))
249246 {
250247 do
251248 {
@@ -265,10 +262,10 @@
265262 else
266263 langId = 1033;
267264 }
268- } while ((langId) && (!pChecker));
265+ } while ((langId) && (!m_pChecker));
269266 }
270- if (bFallbackUsed && pChecker)
271- m_SpellChecker = nullptr;
267+ if (bFallbackUsed && m_pChecker)
268+ m_spellChecker = nullptr;
272269 }
273270 }
274271 }
@@ -280,7 +277,7 @@
280277 Call(SCI_ASSIGNCMDKEY, SCK_HOME + (SCMOD_SHIFT << 16), SCI_HOMEWRAPEXTEND);
281278
282279 CRegStdDWORD used2d(L"Software\\TortoiseSVN\\ScintillaDirect2D", TRUE);
283- if (DWORD(used2d))
280+ if (static_cast<DWORD>(used2d))
284281 {
285282 // set font quality for the popup window, since that window does not use D2D
286283 Call(SCI_SETFONTQUALITY, SC_EFF_QUALITY_LCD_OPTIMIZED);
@@ -288,7 +285,7 @@
288285 Call(SCI_SETTECHNOLOGY, SC_TECHNOLOGY_DIRECTWRITERETAIN);
289286 Call(SCI_SETBUFFEREDDRAW, 0);
290287 CRegStdDWORD useBiDi(L"Software\\TortoiseSVN\\ScintillaBidirectional", FALSE);
291- if (DWORD(useBiDi))
288+ if (static_cast<DWORD>(useBiDi))
292289 {
293290 // enable bidirectional mode
294291 // note: bidirectional mode requires d2d, and to make selections
@@ -318,8 +315,7 @@
318315 Call(SCI_SETSELBACK, TRUE, ::GetSysColor(COLOR_HIGHLIGHT));
319316 }
320317 m_themeCallbackId = CTheme::Instance().RegisterThemeChangeCallback(
321- [this]()
322- {
318+ [this]() {
323319 OnSysColorChange();
324320 });
325321 OnSysColorChange();
@@ -329,8 +325,8 @@
329325 {
330326 Init(props.lProjectLanguage);
331327 m_sCommand = CStringA(CUnicodeUtils::GetUTF8(props.GetCheckRe()));
332- m_sBugID = CStringA(CUnicodeUtils::GetUTF8(props.GetBugIDRe()));
333- m_sUrl = CStringA(CUnicodeUtils::GetUTF8(props.sUrl));
328+ m_sBugID = CStringA(CUnicodeUtils::GetUTF8(props.GetBugIDRe()));
329+ m_sUrl = CStringA(CUnicodeUtils::GetUTF8(props.sUrl));
334330
335331 Call(SCI_SETMOUSEDWELLTIME, 333);
336332
@@ -349,9 +345,9 @@
349345 }
350346 }
351347
352-void CSciEdit::SetIcon(const std::map<int, UINT> &icons)
348+void CSciEdit::SetIcon(const std::map<int, UINT>& icons) const
353349 {
354- int iconWidth = GetSystemMetrics(SM_CXSMICON);
350+ int iconWidth = GetSystemMetrics(SM_CXSMICON);
355351 int iconHeight = GetSystemMetrics(SM_CYSMICON);
356352 Call(SCI_RGBAIMAGESETWIDTH, iconWidth);
357353 Call(SCI_RGBAIMAGESETHEIGHT, iconHeight);
@@ -358,8 +354,8 @@
358354 for (auto icon : icons)
359355 {
360356 CAutoIcon hIcon = LoadIconEx(AfxGetInstanceHandle(), MAKEINTRESOURCE(icon.second), iconWidth, iconHeight);
361- auto bytes = Icon2Image(hIcon);
362- Call(SCI_REGISTERRGBAIMAGE, icon.first, (LPARAM)bytes.get());
357+ auto bytes = Icon2Image(hIcon);
358+ Call(SCI_REGISTERRGBAIMAGE, icon.first, reinterpret_cast<LPARAM>(bytes.get()));
363359 }
364360 }
365361
@@ -366,64 +362,63 @@
366362 BOOL CSciEdit::LoadDictionaries(LONG lLanguageID)
367363 {
368364 // Setup the spell checker
369- TCHAR buf[6] = { 0 };
370- CString sFolderUp = CPathUtils::GetAppParentDirectory();
365+ TCHAR buf[6] = {0};
366+ CString sFolderUp = CPathUtils::GetAppParentDirectory();
371367 CString sFolderAppData = CPathUtils::GetAppDataDirectory();
372- CString sFile;
373368
374369 GetLocaleInfo(MAKELCID(lLanguageID, SORT_DEFAULT), LOCALE_SISO639LANGNAME, buf, _countof(buf));
375- sFile = buf;
370+ CString sFile = buf;
376371 sFile += L"_";
377372 GetLocaleInfo(MAKELCID(lLanguageID, SORT_DEFAULT), LOCALE_SISO3166CTRYNAME, buf, _countof(buf));
378373 sFile += buf;
379- if (pChecker==NULL)
374+ if (m_pChecker == nullptr)
380375 {
381376 if ((PathFileExists(sFolderAppData + L"dic\\" + sFile + L".aff")) &&
382377 (PathFileExists(sFolderAppData + L"dic\\" + sFile + L".dic")))
383378 {
384- pChecker = std::make_unique<Hunspell>(CStringA(sFolderAppData + L"dic\\" + sFile + L".aff"), CStringA(sFolderAppData + L"dic\\" + sFile + L".dic"));
379+ m_pChecker = std::make_unique<Hunspell>(CStringA(sFolderAppData + L"dic\\" + sFile + L".aff"), CStringA(sFolderAppData + L"dic\\" + sFile + L".dic"));
385380 }
386381 else if ((PathFileExists(sFolderUp + L"Languages\\" + sFile + L".aff")) &&
387382 (PathFileExists(sFolderUp + L"Languages\\" + sFile + L".dic")))
388383 {
389- pChecker = std::make_unique<Hunspell>(CStringA(sFolderUp + L"Languages\\" + sFile + L".aff"), CStringA(sFolderUp + L"Languages\\" + sFile + L".dic"));
384+ m_pChecker = std::make_unique<Hunspell>(CStringA(sFolderUp + L"Languages\\" + sFile + L".aff"), CStringA(sFolderUp + L"Languages\\" + sFile + L".dic"));
390385 }
391- if (pChecker)
386+ if (m_pChecker)
392387 {
393- const char* encoding = pChecker->get_dic_encoding();
388+ const char* encoding = m_pChecker->get_dic_encoding();
394389 CTraceToOutputDebugString::Instance()(__FUNCTION__ ": %s\n", encoding);
395- int n = _countof(enc2locale);
396- m_spellcodepage = 0;
390+ int n = _countof(enc2Locale);
391+ m_spellCodepage = 0;
397392 for (int i = 0; i < n; i++)
398393 {
399- if (strcmp(encoding, enc2locale[i].def_enc) == 0)
394+ if (strcmp(encoding, enc2Locale[i].defEnc) == 0)
400395 {
401- m_spellcodepage = atoi(enc2locale[i].cp);
396+ m_spellCodepage = atoi(enc2Locale[i].cp);
402397 }
403398 }
404399 m_personalDict.Init(lLanguageID);
405400 }
406401 }
407- if (pChecker)
402+ if (m_pChecker)
408403 return TRUE;
409404 return FALSE;
410405 }
411406
412-LRESULT CSciEdit::Call(UINT message, WPARAM wParam, LPARAM lParam)
407+LRESULT CSciEdit::Call(UINT message, WPARAM wParam, LPARAM lParam) const
413408 {
414409 ASSERT(::IsWindow(m_hWnd)); //Window must be valid
415- ASSERT(m_DirectFunction); //Direct function must be valid
416- return ((SciFnDirect) m_DirectFunction)(m_DirectPointer, message, wParam, lParam);
410+ ASSERT(m_directFunction); //Direct function must be valid
411+ return reinterpret_cast<SciFnDirect>(m_directFunction)(m_directPointer, message, wParam, lParam);
417412 }
418413
419-CString CSciEdit::StringFromControl(const CStringA& text)
414+CString CSciEdit::StringFromControl(const CStringA& text) const
420415 {
421416 CString sText;
422417 #ifdef UNICODE
423- int codepage = (int)Call(SCI_GETCODEPAGE);
424- int reslen = MultiByteToWideChar(codepage, 0, text, text.GetLength(), 0, 0);
425- MultiByteToWideChar(codepage, 0, text, text.GetLength(), sText.GetBuffer(reslen+1), reslen+1);
426- sText.ReleaseBuffer(reslen);
418+ int codepage = static_cast<int>(Call(SCI_GETCODEPAGE));
419+ int resLen = MultiByteToWideChar(codepage, 0, text, text.GetLength(), nullptr, 0);
420+ MultiByteToWideChar(codepage, 0, text, text.GetLength(), sText.GetBuffer(resLen + 1), resLen + 1);
421+ sText.ReleaseBuffer(resLen);
427422 #else
428423 sText = text;
429424 #endif
@@ -430,14 +425,14 @@
430425 return sText;
431426 }
432427
433-CStringA CSciEdit::StringForControl(const CString& text)
428+CStringA CSciEdit::StringForControl(const CString& text) const
434429 {
435430 CStringA sTextA;
436431 #ifdef UNICODE
437- int codepage = (int)Call(SCI_GETCODEPAGE);
438- int reslen = WideCharToMultiByte(codepage, 0, text, text.GetLength(), 0, 0, 0, 0);
439- WideCharToMultiByte(codepage, 0, text, text.GetLength(), sTextA.GetBuffer(reslen), reslen, 0, 0);
440- sTextA.ReleaseBuffer(reslen);
432+ int codepage = static_cast<int>(Call(SCI_GETCODEPAGE));
433+ int resLen = WideCharToMultiByte(codepage, 0, text, text.GetLength(), nullptr, 0, nullptr, nullptr);
434+ WideCharToMultiByte(codepage, 0, text, text.GetLength(), sTextA.GetBuffer(resLen), resLen, nullptr, nullptr);
435+ sTextA.ReleaseBuffer(resLen);
441436 #else
442437 sTextA = text;
443438 #endif
@@ -452,7 +447,7 @@
452447 SetReadOnly(false);
453448
454449 CStringA sTextA = StringForControl(sText);
455- Call(SCI_SETTEXT, 0, (LPARAM)(LPCSTR)sTextA);
450+ Call(SCI_SETTEXT, 0, reinterpret_cast<LPARAM>(static_cast<LPCSTR>(sTextA)));
456451
457452 if (Call(SCI_GETSCROLLWIDTHTRACKING) != 0)
458453 Call(SCI_SETSCROLLWIDTH, 1);
@@ -473,42 +468,42 @@
473468 SetReadOnly(false);
474469
475470 CStringA sTextA = StringForControl(sText);
476- Call(SCI_REPLACESEL, 0, (LPARAM)(LPCSTR)sTextA);
471+ Call(SCI_REPLACESEL, 0, reinterpret_cast<LPARAM>(static_cast<LPCSTR>(sTextA)));
477472 if (bNewLine)
478- Call(SCI_REPLACESEL, 0, (LPARAM)(LPCSTR)"\n");
473+ Call(SCI_REPLACESEL, 0, reinterpret_cast<LPARAM>(static_cast<LPCSTR>("\n")));
479474 }
480475
481-CString CSciEdit::GetText()
476+CString CSciEdit::GetText() const
482477 {
483- LRESULT len = Call(SCI_GETTEXT, 0, 0);
478+ LRESULT len = Call(SCI_GETTEXT, 0, 0);
484479 CStringA sTextA;
485- Call(SCI_GETTEXT, (WPARAM)(len+1), (LPARAM)(LPCSTR)sTextA.GetBuffer((int)len+1));
480+ Call(SCI_GETTEXT, static_cast<WPARAM>(len + 1), reinterpret_cast<LPARAM>(static_cast<LPCSTR>(sTextA.GetBuffer(static_cast<int>(len) + 1))));
486481 sTextA.ReleaseBuffer();
487482 return StringFromControl(sTextA);
488483 }
489484
490-CString CSciEdit::GetWordUnderCursor(bool bSelectWord, bool allchars)
485+CString CSciEdit::GetWordUnderCursor(bool bSelectWord, bool allchars) const
491486 {
492- Sci_TextRange textrange;
493- int pos = (int)Call(SCI_GETCURRENTPOS);
494- textrange.chrg.cpMin = (LONG)Call(SCI_WORDSTARTPOSITION, pos, TRUE);
495- if ((pos == textrange.chrg.cpMin)||(textrange.chrg.cpMin < 0))
487+ Sci_TextRange textRange;
488+ int pos = static_cast<int>(Call(SCI_GETCURRENTPOS));
489+ textRange.chrg.cpMin = static_cast<LONG>(Call(SCI_WORDSTARTPOSITION, pos, TRUE));
490+ if ((pos == textRange.chrg.cpMin) || (textRange.chrg.cpMin < 0))
496491 return CString();
497- textrange.chrg.cpMax = (LONG)Call(SCI_WORDENDPOSITION, textrange.chrg.cpMin, TRUE);
492+ textRange.chrg.cpMax = static_cast<LONG>(Call(SCI_WORDENDPOSITION, textRange.chrg.cpMin, TRUE));
498493
499- auto textbuffer = std::make_unique<char[]>(textrange.chrg.cpMax - textrange.chrg.cpMin + 1);
500- textrange.lpstrText = textbuffer.get();
501- Call(SCI_GETTEXTRANGE, 0, (LPARAM)&textrange);
502- CString sRet = StringFromControl(textbuffer.get());
494+ auto textBuffer = std::make_unique<char[]>(textRange.chrg.cpMax - textRange.chrg.cpMin + 1);
495+ textRange.lpstrText = textBuffer.get();
496+ Call(SCI_GETTEXTRANGE, 0, reinterpret_cast<LPARAM>(&textRange));
497+ CString sRet = StringFromControl(textBuffer.get());
503498 if (m_bDoStyle && !allchars)
504499 {
505- for (const auto styleindicator : { '*', '_', '^' })
500+ for (const auto styleindicator : {'*', '_', '^'})
506501 {
507502 if (sRet.IsEmpty())
508503 break;
509504 if (sRet[sRet.GetLength() - 1] == styleindicator)
510505 {
511- --textrange.chrg.cpMax;
506+ --textRange.chrg.cpMax;
512507 sRet.Truncate(sRet.GetLength() - 1);
513508 }
514509 if (sRet.IsEmpty())
@@ -515,42 +510,42 @@
515510 break;
516511 if (sRet[0] == styleindicator)
517512 {
518- ++textrange.chrg.cpMin;
513+ ++textRange.chrg.cpMin;
519514 sRet = sRet.Right(sRet.GetLength() - 1);
520515 }
521516 }
522517 }
523518 if (bSelectWord)
524- Call(SCI_SETSEL, textrange.chrg.cpMin, textrange.chrg.cpMax);
519+ Call(SCI_SETSEL, textRange.chrg.cpMin, textRange.chrg.cpMax);
525520 return sRet;
526521 }
527522
528-void CSciEdit::SetFont(CString sFontName, int iFontSizeInPoints)
523+void CSciEdit::SetFont(CString sFontName, int iFontSizeInPoints) const
529524 {
530525 CStringA fontName = CUnicodeUtils::GetUTF8(sFontName);
531- Call(SCI_STYLESETFONT, STYLE_DEFAULT, (LPARAM)(LPCSTR)fontName);
526+ Call(SCI_STYLESETFONT, STYLE_DEFAULT, reinterpret_cast<LPARAM>(static_cast<LPCSTR>(fontName)));
532527 Call(SCI_STYLESETSIZE, STYLE_DEFAULT, iFontSizeInPoints);
533528 Call(SCI_STYLECLEARALL);
534529
535- LPARAM color = (LPARAM)GetSysColor(COLOR_HIGHLIGHT);
530+ LPARAM color = static_cast<LPARAM>(GetSysColor(COLOR_HIGHLIGHT));
536531 // set the styles for the bug ID strings
537- Call(SCI_STYLESETBOLD, STYLE_ISSUEBOLD, (LPARAM)TRUE);
532+ Call(SCI_STYLESETBOLD, STYLE_ISSUEBOLD, static_cast<LPARAM>(TRUE));
538533 Call(SCI_STYLESETFORE, STYLE_ISSUEBOLD, color);
539- Call(SCI_STYLESETBOLD, STYLE_ISSUEBOLDITALIC, (LPARAM)TRUE);
540- Call(SCI_STYLESETITALIC, STYLE_ISSUEBOLDITALIC, (LPARAM)TRUE);
534+ Call(SCI_STYLESETBOLD, STYLE_ISSUEBOLDITALIC, static_cast<LPARAM>(TRUE));
535+ Call(SCI_STYLESETITALIC, STYLE_ISSUEBOLDITALIC, static_cast<LPARAM>(TRUE));
541536 Call(SCI_STYLESETFORE, STYLE_ISSUEBOLDITALIC, color);
542- Call(SCI_STYLESETHOTSPOT, STYLE_ISSUEBOLDITALIC, (LPARAM)TRUE);
537+ Call(SCI_STYLESETHOTSPOT, STYLE_ISSUEBOLDITALIC, static_cast<LPARAM>(TRUE));
543538
544539 // set the formatted text styles
545- Call(SCI_STYLESETBOLD, STYLE_BOLD, (LPARAM)TRUE);
546- Call(SCI_STYLESETITALIC, STYLE_ITALIC, (LPARAM)TRUE);
547- Call(SCI_STYLESETUNDERLINE, STYLE_UNDERLINED, (LPARAM)TRUE);
540+ Call(SCI_STYLESETBOLD, STYLE_BOLD, static_cast<LPARAM>(TRUE));
541+ Call(SCI_STYLESETITALIC, STYLE_ITALIC, static_cast<LPARAM>(TRUE));
542+ Call(SCI_STYLESETUNDERLINE, STYLE_UNDERLINED, static_cast<LPARAM>(TRUE));
548543
549544 // set the style for URLs
550545 Call(SCI_STYLESETFORE, STYLE_URL, color);
551- Call(SCI_STYLESETHOTSPOT, STYLE_URL, (LPARAM)TRUE);
546+ Call(SCI_STYLESETHOTSPOT, STYLE_URL, static_cast<LPARAM>(TRUE));
552547
553- Call(SCI_SETHOTSPOTACTIVEUNDERLINE, (LPARAM)TRUE);
548+ Call(SCI_SETHOTSPOTACTIVEUNDERLINE, static_cast<LPARAM>(TRUE));
554549 }
555550
556551 void CSciEdit::SetAutoCompletionList(std::map<CString, int>&& list, TCHAR separator, TCHAR typeSeparator)
@@ -558,21 +553,21 @@
558553 //copy the auto completion list.
559554
560555 m_autolist.clear();
561- m_autolist = std::move(list);
562- m_separator = separator;
556+ m_autolist = std::move(list);
557+ m_separator = separator;
563558 m_typeSeparator = typeSeparator;
564559 }
565560
566561 // Helper for CSciEdit::IsMisspelled()
567562 // Returns TRUE if sWord has spelling errors.
568-BOOL CSciEdit::CheckWordSpelling(const CString& sWord)
563+BOOL CSciEdit::CheckWordSpelling(const CString& sWord) const
569564 {
570565 if (m_bReadOnly)
571566 return FALSE;
572- if (m_SpellChecker)
567+ if (m_spellChecker)
573568 {
574569 IEnumSpellingErrorPtr enumSpellingError = nullptr;
575- if (SUCCEEDED(m_SpellChecker->Check(sWord, &enumSpellingError)))
570+ if (SUCCEEDED(m_spellChecker->Check(sWord, &enumSpellingError)))
576571 {
577572 ISpellingErrorPtr spellingError = nullptr;
578573 if (enumSpellingError->Next(&spellingError) == S_OK)
@@ -586,12 +581,12 @@
586581 }
587582 }
588583 }
589- else if (pChecker)
584+ else if (m_pChecker)
590585 {
591586 // convert the string from the control to the encoding of the spell checker module.
592587 auto sWordA = GetWordForSpellChecker(sWord);
593588
594- if (!pChecker->spell(sWordA))
589+ if (!m_pChecker->spell(sWordA))
595590 {
596591 return TRUE;
597592 }
@@ -610,7 +605,7 @@
610605 return FALSE;
611606
612607 // Check spell checking cache first.
613- const BOOL *cacheResult = m_SpellingCache.try_get(std::wstring(sWord, sWord.GetLength()));
608+ const BOOL* cacheResult = m_spellingCache.try_get(std::wstring(sWord, sWord.GetLength()));
614609 if (cacheResult)
615610 return *cacheResult;
616611
@@ -626,13 +621,13 @@
626621 misspelled = FALSE;
627622 if (sWord.GetLength() > 1)
628623 {
629- int wordstart = 0;
630- int wordend = 1;
631- while (wordend < sWord.GetLength())
624+ int wordStart = 0;
625+ int wordEnd = 1;
626+ while (wordEnd < sWord.GetLength())
632627 {
633- while ((wordend < sWord.GetLength())&&(!_istupper(sWord[wordend])))
634- wordend++;
635- if ((wordstart == 0)&&(wordend == sWord.GetLength()))
628+ while ((wordEnd < sWord.GetLength()) && (!_istupper(sWord[wordEnd])))
629+ wordEnd++;
630+ if ((wordStart == 0) && (wordEnd == sWord.GetLength()))
636631 {
637632 // words in the auto list are also assumed correctly spelled
638633 if (m_autolist.find(sWord) != m_autolist.end())
@@ -645,7 +640,7 @@
645640 break;
646641 }
647642
648- CString token(sWord.Mid(wordstart, wordend - wordstart));
643+ CString token(sWord.Mid(wordStart, wordEnd - wordStart));
649644 if (token.GetLength() > 2 && CheckWordSpelling(token))
650645 {
651646 misspelled = TRUE;
@@ -652,14 +647,14 @@
652647 break;
653648 }
654649
655- wordstart = wordend;
656- wordend++;
650+ wordStart = wordEnd;
651+ wordEnd++;
657652 }
658653 }
659654 }
660655
661656 // Update cache.
662- m_SpellingCache.insert_or_assign(std::wstring(sWord, sWord.GetLength()), misspelled);
657+ m_spellingCache.insert_or_assign(std::wstring(sWord, sWord.GetLength()), misspelled);
663658
664659 return misspelled;
665660 }
@@ -666,94 +661,94 @@
666661
667662 void CSciEdit::CheckSpelling(Sci_Position startpos, Sci_Position endpos)
668663 {
669- if ((pChecker == NULL) && (m_SpellChecker == nullptr))
664+ if ((m_pChecker == nullptr) && (m_spellChecker == nullptr))
670665 return;
671666 if (m_bReadOnly)
672667 return;
673668
674- Sci_TextRange textrange;
669+ Sci_TextRange textRange;
675670
676- textrange.chrg.cpMin = (Sci_PositionCR)startpos;
677- textrange.chrg.cpMax = textrange.chrg.cpMin;
678- LRESULT lastpos = endpos;
679- if (lastpos < 0)
680- lastpos = Call(SCI_GETLENGTH)-textrange.chrg.cpMin;
671+ textRange.chrg.cpMin = static_cast<Sci_PositionCR>(startpos);
672+ textRange.chrg.cpMax = textRange.chrg.cpMin;
673+ LRESULT lastPos = endpos;
674+ if (lastPos < 0)
675+ lastPos = Call(SCI_GETLENGTH) - textRange.chrg.cpMin;
681676 Call(SCI_SETINDICATORCURRENT, INDIC_MISSPELLED);
682- while (textrange.chrg.cpMax < lastpos)
677+ while (textRange.chrg.cpMax < lastPos)
683678 {
684- textrange.chrg.cpMin = (LONG)Call(SCI_WORDSTARTPOSITION, textrange.chrg.cpMax+1, TRUE);
685- if (textrange.chrg.cpMin < textrange.chrg.cpMax)
679+ textRange.chrg.cpMin = static_cast<LONG>(Call(SCI_WORDSTARTPOSITION, textRange.chrg.cpMax + 1LL, TRUE));
680+ if (textRange.chrg.cpMin < textRange.chrg.cpMax)
686681 break;
687- textrange.chrg.cpMax = (LONG)Call(SCI_WORDENDPOSITION, textrange.chrg.cpMin, TRUE);
688- if (textrange.chrg.cpMin == textrange.chrg.cpMax)
682+ textRange.chrg.cpMax = static_cast<LONG>(Call(SCI_WORDENDPOSITION, textRange.chrg.cpMin, TRUE));
683+ if (textRange.chrg.cpMin == textRange.chrg.cpMax)
689684 {
690- textrange.chrg.cpMax++;
685+ textRange.chrg.cpMax++;
691686 // since Scintilla squiggles to the end of the text even if told to stop one char before it,
692687 // we have to clear here the squiggly lines to the end.
693- if (textrange.chrg.cpMin)
694- Call(SCI_INDICATORCLEARRANGE, textrange.chrg.cpMin-1, textrange.chrg.cpMax - textrange.chrg.cpMin + 1);
688+ if (textRange.chrg.cpMin)
689+ Call(SCI_INDICATORCLEARRANGE, textRange.chrg.cpMin - 1, textRange.chrg.cpMax - textRange.chrg.cpMin + 1);
695690 continue;
696691 }
697- ATLASSERT(textrange.chrg.cpMax >= textrange.chrg.cpMin);
698- auto textbuffer = std::make_unique<char[]>(textrange.chrg.cpMax - textrange.chrg.cpMin + 2);
699- SecureZeroMemory(textbuffer.get(), textrange.chrg.cpMax - textrange.chrg.cpMin + 2);
700- textrange.lpstrText = textbuffer.get();
701- textrange.chrg.cpMax++;
702- Call(SCI_GETTEXTRANGE, 0, (LPARAM)&textrange);
703- int len = (int)strlen(textrange.lpstrText);
692+ ATLASSERT(textRange.chrg.cpMax >= textRange.chrg.cpMin);
693+ auto textbuffer = std::make_unique<char[]>(textRange.chrg.cpMax - textRange.chrg.cpMin + 2);
694+ SecureZeroMemory(textbuffer.get(), textRange.chrg.cpMax - textRange.chrg.cpMin + 2);
695+ textRange.lpstrText = textbuffer.get();
696+ textRange.chrg.cpMax++;
697+ Call(SCI_GETTEXTRANGE, 0, reinterpret_cast<LPARAM>(&textRange));
698+ int len = static_cast<int>(strlen(textRange.lpstrText));
704699 if (len == 0)
705700 {
706- textrange.chrg.cpMax--;
707- Call(SCI_GETTEXTRANGE, 0, (LPARAM)&textrange);
708- len = (int)strlen(textrange.lpstrText);
709- textrange.chrg.cpMax++;
701+ textRange.chrg.cpMax--;
702+ Call(SCI_GETTEXTRANGE, 0, reinterpret_cast<LPARAM>(&textRange));
703+ len = static_cast<int>(strlen(textRange.lpstrText));
704+ textRange.chrg.cpMax++;
710705 len++;
711706 }
712- if (len && textrange.lpstrText[len - 1] == '.')
707+ if (len && textRange.lpstrText[len - 1] == '.')
713708 {
714709 // Try to ignore file names from the auto list.
715710 // Do do this, for each word ending with '.' we extract next word and check
716711 // whether the combined string is present in auto list.
717712 Sci_TextRange twoWords;
718- twoWords.chrg.cpMin = textrange.chrg.cpMin;
719- twoWords.chrg.cpMax = (LONG)Call(SCI_WORDENDPOSITION, textrange.chrg.cpMax + 1, TRUE);
720- auto twoWordsBuffer = std::make_unique<char[]>(twoWords.chrg.cpMax - twoWords.chrg.cpMin + 1);
721- twoWords.lpstrText = twoWordsBuffer.get();
722- SecureZeroMemory(twoWords.lpstrText, twoWords.chrg.cpMax - twoWords.chrg.cpMin + 1);
723- Call(SCI_GETTEXTRANGE, 0, (LPARAM)&twoWords);
713+ twoWords.chrg.cpMin = textRange.chrg.cpMin;
714+ twoWords.chrg.cpMax = static_cast<LONG>(Call(SCI_WORDENDPOSITION, textRange.chrg.cpMax + 1, TRUE));
715+ auto twoWordsBuffer = std::make_unique<char[]>(twoWords.chrg.cpMax - twoWords.chrg.cpMin + 1LL);
716+ twoWords.lpstrText = twoWordsBuffer.get();
717+ SecureZeroMemory(twoWords.lpstrText, twoWords.chrg.cpMax - twoWords.chrg.cpMin + 1LL);
718+ Call(SCI_GETTEXTRANGE, 0, reinterpret_cast<LPARAM>(&twoWords));
724719 CString sWord = StringFromControl(twoWords.lpstrText);
725720 if (m_autolist.find(sWord) != m_autolist.end())
726721 {
727722 //mark word as correct (remove the squiggle line)
728723 Call(SCI_INDICATORCLEARRANGE, twoWords.chrg.cpMin, twoWords.chrg.cpMax - twoWords.chrg.cpMin);
729- textrange.chrg.cpMax = twoWords.chrg.cpMax;
724+ textRange.chrg.cpMax = twoWords.chrg.cpMax;
730725 continue;
731726 }
732727 }
733728 if (len)
734- textrange.lpstrText[len - 1] = 0;
735- textrange.chrg.cpMax--;
736- if (textrange.lpstrText[0] != 0)
729+ textRange.lpstrText[len - 1] = 0;
730+ textRange.chrg.cpMax--;
731+ if (textRange.lpstrText[0] != 0)
737732 {
738- CString sWord = StringFromControl(textrange.lpstrText);
739- if ((GetStyleAt(textrange.chrg.cpMin) != STYLE_URL) && IsMisspelled(sWord))
733+ CString sWord = StringFromControl(textRange.lpstrText);
734+ if ((GetStyleAt(textRange.chrg.cpMin) != STYLE_URL) && IsMisspelled(sWord))
740735 {
741736 //mark word as misspelled
742- Call(SCI_INDICATORFILLRANGE, textrange.chrg.cpMin, textrange.chrg.cpMax - textrange.chrg.cpMin);
737+ Call(SCI_INDICATORFILLRANGE, textRange.chrg.cpMin, textRange.chrg.cpMax - textRange.chrg.cpMin);
743738 }
744739 else
745740 {
746741 //mark word as correct (remove the squiggle line)
747- Call(SCI_INDICATORCLEARRANGE, textrange.chrg.cpMin, textrange.chrg.cpMax - textrange.chrg.cpMin);
748- Call(SCI_INDICATORCLEARRANGE, textrange.chrg.cpMin, textrange.chrg.cpMax - textrange.chrg.cpMin + 1);
742+ Call(SCI_INDICATORCLEARRANGE, textRange.chrg.cpMin, textRange.chrg.cpMax - textRange.chrg.cpMin);
743+ Call(SCI_INDICATORCLEARRANGE, textRange.chrg.cpMin, textRange.chrg.cpMax - textRange.chrg.cpMin + 1);
749744 }
750745 }
751746 }
752747 }
753748
754-void CSciEdit::SuggestSpellingAlternatives()
749+void CSciEdit::SuggestSpellingAlternatives() const
755750 {
756- if ((pChecker == NULL) && (m_SpellChecker == nullptr))
751+ if ((m_pChecker == nullptr) && (m_spellChecker == nullptr))
757752 return;
758753 CString word = GetWordUnderCursor(true);
759754 Call(SCI_SETCURRENTPOS, Call(SCI_WORDSTARTPOSITION, Call(SCI_GETCURRENTPOS), TRUE));
@@ -761,34 +756,33 @@
761756 return;
762757
763758 CString suggestions;
764- if (m_SpellChecker)
759+ if (m_spellChecker)
765760 {
766761 IEnumStringPtr enumSpellingSuggestions = nullptr;
767- if (SUCCEEDED(m_SpellChecker->Suggest(word, &enumSpellingSuggestions)))
762+ if (SUCCEEDED(m_spellChecker->Suggest(word, &enumSpellingSuggestions)))
768763 {
769764 LPOLESTR string = nullptr;
770765 while (enumSpellingSuggestions->Next(1, &string, nullptr) == S_OK)
771766 {
772- suggestions.AppendFormat(L"%s%c%d%c", (LPCWSTR)CString(string), m_typeSeparator, AUTOCOMPLETE_SPELLING, m_separator);
767+ suggestions.AppendFormat(L"%s%c%d%c", static_cast<LPCWSTR>(CString(string)), m_typeSeparator, AUTOCOMPLETE_SPELLING, m_separator);
773768 CoTaskMemFree(string);
774769 }
775770 }
776771 }
777- else if (pChecker)
772+ else if (m_pChecker)
778773 {
779- auto wlst = pChecker->suggest(GetWordForSpellChecker(word));
774+ auto wlst = m_pChecker->suggest(GetWordForSpellChecker(word));
780775 for (const auto& alternative : wlst)
781- suggestions.AppendFormat(L"%s%c%d%c", static_cast<LPCTSTR>(GetWordFromSpellChecker(alternative)), m_typeSeparator, AUTOCOMPLETE_SPELLING, m_separator);
776+ suggestions.AppendFormat(L"%s%c%d%c", static_cast<LPCWSTR>(GetWordFromSpellChecker(alternative)), m_typeSeparator, AUTOCOMPLETE_SPELLING, m_separator);
782777 }
783778
784779 suggestions.TrimRight(m_separator);
785780 if (suggestions.IsEmpty())
786781 return;
787- Call(SCI_AUTOCSETSEPARATOR, (WPARAM)CStringA(m_separator).GetAt(0));
788- Call(SCI_AUTOCSETTYPESEPARATOR, (WPARAM)m_typeSeparator);
782+ Call(SCI_AUTOCSETSEPARATOR, static_cast<WPARAM>(CStringA(m_separator).GetAt(0)));
783+ Call(SCI_AUTOCSETTYPESEPARATOR, static_cast<WPARAM>(m_typeSeparator));
789784 Call(SCI_AUTOCSETDROPRESTOFWORD, 1);
790- Call(SCI_AUTOCSHOW, 0, (LPARAM)(LPCSTR)StringForControl(suggestions));
791- return;
785+ Call(SCI_AUTOCSHOW, 0, reinterpret_cast<LPARAM>(static_cast<LPCSTR>(StringForControl(suggestions))));
792786 }
793787
794788 void CSciEdit::DoAutoCompletion(Sci_Position nMinPrefixLength)
@@ -795,7 +789,7 @@
795789 {
796790 if (m_autolist.empty())
797791 return;
798- int pos = (int)Call(SCI_GETCURRENTPOS);
792+ int pos = static_cast<int>(Call(SCI_GETCURRENTPOS));
799793 if (pos != Call(SCI_WORDENDPOSITION, pos, TRUE))
800794 return; // don't auto complete if we're not at the end of a word
801795 CString word = GetWordUnderCursor();
@@ -803,7 +797,7 @@
803797 {
804798 word = GetWordUnderCursor(false, true);
805799 if (word.GetLength() < nMinPrefixLength)
806- return; // don't auto complete yet, word is too short
800+ return; // don't auto complete yet, word is too short
807801 }
808802 CString sAutoCompleteList;
809803
@@ -827,15 +821,15 @@
827821 CString s = wordLower.Left(pos);
828822 if (s.GetLength() >= nMinPrefixLength)
829823 words.push_back(s);
830- s = wordLower.Mid(pos+1);
824+ s = wordLower.Mid(pos + 1);
831825 if (s.GetLength() >= nMinPrefixLength)
832826 words.push_back(s);
833827 s = wordHigher.Left(pos);
834828 if (s.GetLength() >= nMinPrefixLength)
835829 words.push_back(wordHigher.Left(pos));
836- s = wordHigher.Mid(pos+1);
830+ s = wordHigher.Mid(pos + 1);
837831 if (s.GetLength() >= nMinPrefixLength)
838- words.push_back(wordHigher.Mid(pos+1));
832+ words.push_back(wordHigher.Mid(pos + 1));
839833 }
840834
841835 // note: the m_autolist is case-sensitive because
@@ -842,18 +836,18 @@
842836 // its contents are also used to mark words in it
843837 // as correctly spelled. If it would be case-insensitive,
844838 // case spelling mistakes would not show up as misspelled.
845- std::map<CString, int> wordset;
839+ std::map<CString, int> wordSet;
846840 for (const auto& w : words)
847841 {
848- for (auto lowerit = m_autolist.lower_bound(w);
849- lowerit != m_autolist.end(); ++lowerit)
842+ for (auto lowerIt = m_autolist.lower_bound(w);
843+ lowerIt != m_autolist.end(); ++lowerIt)
850844 {
851- int compare = w.CompareNoCase(lowerit->first.Left(w.GetLength()));
852- if (compare>0)
845+ int compare = w.CompareNoCase(lowerIt->first.Left(w.GetLength()));
846+ if (compare > 0)
853847 continue;
854848 else if (compare == 0)
855849 {
856- wordset.emplace(lowerit->first, lowerit->second);
850+ wordSet.emplace(lowerIt->first, lowerIt->second);
857851 }
858852 else
859853 {
@@ -862,12 +856,11 @@
862856 }
863857 }
864858
865- for (const auto& w : wordset)
866- sAutoCompleteList.AppendFormat(L"%s%c%d%c", (LPCWSTR)w.first, m_typeSeparator, w.second, m_separator);
859+ for (const auto& w : wordSet)
860+ sAutoCompleteList.AppendFormat(L"%s%c%d%c", static_cast<LPCWSTR>(w.first), m_typeSeparator, w.second, m_separator);
867861
868862 sAutoCompleteList.TrimRight(m_separator);
869863
870-
871864 if (i == 0)
872865 {
873866 if (sAutoCompleteList.IsEmpty())
@@ -883,13 +876,12 @@
883876 if (sAutoCompleteList.IsEmpty())
884877 return;
885878 }
886-
887879 }
888880
889- Call(SCI_AUTOCSETSEPARATOR, (WPARAM)CStringA(m_separator).GetAt(0));
890- Call(SCI_AUTOCSETTYPESEPARATOR, (WPARAM)m_typeSeparator);
881+ Call(SCI_AUTOCSETSEPARATOR, static_cast<WPARAM>(CStringA(m_separator).GetAt(0)));
882+ Call(SCI_AUTOCSETTYPESEPARATOR, static_cast<WPARAM>(m_typeSeparator));
891883 auto sForControl = StringForControl(sAutoCompleteList);
892- Call(SCI_AUTOCSHOW, StringForControl(word).GetLength(), (LPARAM)(LPCSTR)sForControl);
884+ Call(SCI_AUTOCSHOW, StringForControl(word).GetLength(), reinterpret_cast<LPARAM>(static_cast<LPCSTR>(sForControl)));
893885 }
894886
895887 BOOL CSciEdit::OnChildNotify(UINT message, WPARAM wParam, LPARAM lParam, LRESULT* pLResult)
@@ -897,16 +889,16 @@
897889 if (message != WM_NOTIFY)
898890 return CWnd::OnChildNotify(message, wParam, lParam, pLResult);
899891
900- LPNMHDR lpnmhdr = (LPNMHDR) lParam;
901- SCNotification * lpSCN = (SCNotification *)lParam;
892+ LPNMHDR lpnmhdr = reinterpret_cast<LPNMHDR>(lParam);
893+ SCNotification* lpScn = reinterpret_cast<SCNotification*>(lParam);
902894
903- if(lpnmhdr->hwndFrom==m_hWnd)
895+ if (lpnmhdr->hwndFrom == m_hWnd)
904896 {
905- switch(lpnmhdr->code)
897+ switch (lpnmhdr->code)
906898 {
907- case SCN_CHARADDED:
899+ case SCN_CHARADDED:
908900 {
909- if ((lpSCN->ch < 32)&&(lpSCN->ch != 13)&&(lpSCN->ch != 10))
901+ if ((lpScn->ch < 32) && (lpScn->ch != 13) && (lpScn->ch != 10))
910902 Call(SCI_DELETEBACK);
911903 else
912904 {
@@ -914,79 +906,78 @@
914906 }
915907 return TRUE;
916908 }
917- break;
918- case SCN_AUTOCSELECTION:
909+ case SCN_AUTOCSELECTION:
919910 {
920- CString text = StringFromControl(lpSCN->text);
911+ CString text = StringFromControl(lpScn->text);
921912 if (m_autolist[text] == AUTOCOMPLETE_SNIPPET)
922913 {
923914 Call(SCI_AUTOCCANCEL);
924- for (INT_PTR handlerindex = 0; handlerindex < m_arContextHandlers.GetCount(); ++handlerindex)
915+ for (INT_PTR handlerIndex = 0; handlerIndex < m_arContextHandlers.GetCount(); ++handlerIndex)
925916 {
926- CSciEditContextMenuInterface * pHandler = m_arContextHandlers.GetAt(handlerindex);
917+ CSciEditContextMenuInterface* pHandler = m_arContextHandlers.GetAt(handlerIndex);
927918 pHandler->HandleSnippet(m_autolist[text], text, this);
928919 }
929920 }
930921 return TRUE;
931922 }
932- case SCN_STYLENEEDED:
923+ case SCN_STYLENEEDED:
933924 {
934- Sci_Position startpos = (Sci_Position)Call(SCI_GETENDSTYLED);
935- Sci_Position endpos = ((SCNotification *)lpnmhdr)->position;
925+ Sci_Position startPos = static_cast<Sci_Position>(Call(SCI_GETENDSTYLED));
926+ Sci_Position endPos = reinterpret_cast<SCNotification*>(lpnmhdr)->position;
936927
937- Sci_Position startwordpos = (Sci_Position)Call(SCI_WORDSTARTPOSITION, startpos, true);
938- Sci_Position endwordpos = (Sci_Position)Call(SCI_WORDENDPOSITION, endpos, true);
928+ Sci_Position startWordPos = static_cast<Sci_Position>(Call(SCI_WORDSTARTPOSITION, startPos, true));
929+ Sci_Position endWordPos = static_cast<Sci_Position>(Call(SCI_WORDENDPOSITION, endPos, true));
939930
940- MarkEnteredBugID(startwordpos, endwordpos);
931+ MarkEnteredBugID(startWordPos, endWordPos);
941932 if (m_bDoStyle)
942- StyleEnteredText(startwordpos, endwordpos);
933+ StyleEnteredText(startWordPos, endWordPos);
943934
944- StyleURLs(startwordpos, endwordpos);
945- CheckSpelling(startwordpos, endwordpos);
935+ StyleURLs(startWordPos, endWordPos);
936+ CheckSpelling(startWordPos, endWordPos);
946937
947938 // Tell scintilla editor that we styled all requested range.
948- Call(SCI_STARTSTYLING, endwordpos);
939+ Call(SCI_STARTSTYLING, endWordPos);
949940 Call(SCI_SETSTYLING, 0, 0);
950941 }
951942 break;
952- case SCN_MODIFIED:
943+ case SCN_MODIFIED:
953944 {
954- if (!m_blockModifiedHandler && (lpSCN->modificationType & (SC_MOD_INSERTTEXT | SC_MOD_DELETETEXT)))
945+ if (!m_blockModifiedHandler && (lpScn->modificationType & (SC_MOD_INSERTTEXT | SC_MOD_DELETETEXT)))
955946 {
956- LRESULT firstline = Call(SCI_GETFIRSTVISIBLELINE);
957- LRESULT lastline = firstline + Call(SCI_LINESONSCREEN);
958- Sci_Position firstpos = (Sci_Position)Call(SCI_POSITIONFROMLINE, firstline);
959- Sci_Position lastpos = (Sci_Position)Call(SCI_GETLINEENDPOSITION, lastline);
960- Sci_Position pos1 = lpSCN->position;
961- Sci_Position pos2 = pos1 + lpSCN->length;
947+ LRESULT firstLine = Call(SCI_GETFIRSTVISIBLELINE);
948+ LRESULT lastLine = firstLine + Call(SCI_LINESONSCREEN);
949+ Sci_Position firstPos = static_cast<Sci_Position>(Call(SCI_POSITIONFROMLINE, firstLine));
950+ Sci_Position lastPos = static_cast<Sci_Position>(Call(SCI_GETLINEENDPOSITION, lastLine));
951+ Sci_Position pos1 = lpScn->position;
952+ Sci_Position pos2 = pos1 + lpScn->length;
962953 // always use the bigger range
963- firstpos = min(firstpos, pos1);
964- lastpos = max(lastpos, pos2);
954+ firstPos = min(firstPos, pos1);
955+ lastPos = max(lastPos, pos2);
965956
966- WrapLines(firstpos, lastpos);
957+ WrapLines(firstPos, lastPos);
967958 }
968959 }
969960 break;
970- case SCN_DWELLSTART:
971- case SCN_HOTSPOTRELEASECLICK:
961+ case SCN_DWELLSTART:
962+ case SCN_HOTSPOTRELEASECLICK:
972963 {
973- if (lpSCN->position < 0)
964+ if (lpScn->position < 0)
974965 break;
975966
976- Sci_TextRange textrange;
977- textrange.chrg.cpMin = (Sci_PositionCR)lpSCN->position;
978- textrange.chrg.cpMax = (Sci_PositionCR)lpSCN->position;
979- DWORD style = GetStyleAt(lpSCN->position);
967+ Sci_TextRange textRange;
968+ textRange.chrg.cpMin = static_cast<Sci_PositionCR>(lpScn->position);
969+ textRange.chrg.cpMax = static_cast<Sci_PositionCR>(lpScn->position);
970+ DWORD style = GetStyleAt(lpScn->position);
980971 if (style == 0)
981972 break;
982- while (GetStyleAt(textrange.chrg.cpMin - 1) == style)
983- --textrange.chrg.cpMin;
984- while (GetStyleAt(textrange.chrg.cpMax + 1) == style)
985- ++textrange.chrg.cpMax;
986- ++textrange.chrg.cpMax;
987- auto textbuffer = std::make_unique<char[]>(textrange.chrg.cpMax - textrange.chrg.cpMin + 1);
988- textrange.lpstrText = textbuffer.get();
989- Call(SCI_GETTEXTRANGE, 0, (LPARAM)&textrange);
973+ while (GetStyleAt(textRange.chrg.cpMin - 1) == style)
974+ --textRange.chrg.cpMin;
975+ while (GetStyleAt(textRange.chrg.cpMax + 1) == style)
976+ ++textRange.chrg.cpMax;
977+ ++textRange.chrg.cpMax;
978+ auto textbuffer = std::make_unique<char[]>(textRange.chrg.cpMax - textRange.chrg.cpMin + 1);
979+ textRange.lpstrText = textbuffer.get();
980+ Call(SCI_GETTEXTRANGE, 0, reinterpret_cast<LPARAM>(&textRange));
990981 CString url;
991982 if (style == STYLE_URL)
992983 {
@@ -1003,10 +994,10 @@
1003994 if (url.Left(2).Compare(L"^/") == 0)
1004995 {
1005996 // URL is relative to the repository root
1006- CString url1 = m_sRepositoryRoot + url.Mid(1);
1007- TCHAR buf[INTERNET_MAX_URL_LENGTH] = { 0 };
1008- DWORD len = url.GetLength();
1009- if (UrlCanonicalize((LPCTSTR)url1, buf, &len, 0) == S_OK)
997+ CString url1 = m_sRepositoryRoot + url.Mid(1);
998+ TCHAR buf[INTERNET_MAX_URL_LENGTH] = {0};
999+ DWORD len = url.GetLength();
1000+ if (UrlCanonicalize(static_cast<LPCWSTR>(url1), buf, &len, 0) == S_OK)
10101001 url = CString(buf, len);
10111002 else
10121003 url = url1;
@@ -1016,14 +1007,14 @@
10161007 // URL is relative to the server's hostname
10171008 CString sHost;
10181009 // find the server's hostname
1019- int schemepos = m_sRepositoryRoot.Find(L"//");
1020- if (schemepos >= 0)
1010+ int schemePos = m_sRepositoryRoot.Find(L"//");
1011+ if (schemePos >= 0)
10211012 {
1022- sHost = m_sRepositoryRoot.Left(m_sRepositoryRoot.Find('/', schemepos+3));
1023- CString url1 = sHost + url;
1024- TCHAR buf[INTERNET_MAX_URL_LENGTH] = { 0 };
1025- DWORD len = url.GetLength();
1026- if (UrlCanonicalize((LPCTSTR)url, buf, &len, 0) == S_OK)
1013+ sHost = m_sRepositoryRoot.Left(m_sRepositoryRoot.Find('/', schemePos + 3));
1014+ CString url1 = sHost + url;
1015+ TCHAR buf[INTERNET_MAX_URL_LENGTH] = {0};
1016+ DWORD len = url.GetLength();
1017+ if (UrlCanonicalize(static_cast<LPCWSTR>(url), buf, &len, 0) == S_OK)
10271018 url = CString(buf, len);
10281019 else
10291020 url = url1;
@@ -1031,17 +1022,17 @@
10311022 }
10321023 }
10331024 if ((lpnmhdr->code == SCN_HOTSPOTRELEASECLICK) && (!url.IsEmpty()))
1034- ShellExecute(GetParent()->GetSafeHwnd(), L"open", url, NULL, NULL, SW_SHOWDEFAULT);
1025+ ShellExecute(GetParent()->GetSafeHwnd(), L"open", url, nullptr, nullptr, SW_SHOWDEFAULT);
10351026 else
10361027 {
10371028 CStringA sTextA = StringForControl(url);
1038- Call(SCI_CALLTIPSHOW, lpSCN->position + 3, (LPARAM)(LPCSTR)sTextA);
1029+ Call(SCI_CALLTIPSHOW, lpScn->position + 3, reinterpret_cast<LPARAM>(static_cast<LPCSTR>(sTextA)));
10391030 }
10401031 }
10411032 break;
1042- case SCN_DWELLEND:
1043- Call(SCI_CALLTIPCANCEL);
1044- break;
1033+ case SCN_DWELLEND:
1034+ Call(SCI_CALLTIPCANCEL);
1035+ break;
10451036 }
10461037 }
10471038 return CWnd::OnChildNotify(message, wParam, lParam, pLResult);
@@ -1059,7 +1050,7 @@
10591050 Call(SCI_CLEARDOCUMENTSTYLE);
10601051 if (CTheme::Instance().IsDarkTheme())
10611052 {
1062- SetClassLongPtr(GetSafeHwnd(), GCLP_HBRBACKGROUND, (LONG_PTR)GetStockObject(BLACK_BRUSH));
1053+ SetClassLongPtr(GetSafeHwnd(), GCLP_HBRBACKGROUND, reinterpret_cast<LONG_PTR>(GetStockObject(BLACK_BRUSH)));
10631054 Call(SCI_STYLESETFORE, STYLE_DEFAULT, CTheme::darkTextColor);
10641055 Call(SCI_STYLESETBACK, STYLE_DEFAULT, CTheme::darkBkColor);
10651056 Call(SCI_SETCARETFORE, CTheme::darkTextColor);
@@ -1066,7 +1057,7 @@
10661057 }
10671058 else
10681059 {
1069- SetClassLongPtr(GetSafeHwnd(), GCLP_HBRBACKGROUND, (LONG_PTR)GetSysColorBrush(COLOR_3DFACE));
1060+ SetClassLongPtr(GetSafeHwnd(), GCLP_HBRBACKGROUND, reinterpret_cast<LONG_PTR>(GetSysColorBrush(COLOR_3DFACE)));
10701061 Call(SCI_STYLESETFORE, STYLE_DEFAULT, ::GetSysColor(COLOR_WINDOWTEXT));
10711062 Call(SCI_STYLESETBACK, STYLE_DEFAULT, ::GetSysColor(COLOR_WINDOW));
10721063 Call(SCI_SETCARETFORE, ::GetSysColor(COLOR_WINDOWTEXT));
@@ -1079,13 +1070,13 @@
10791070 {
10801071 switch (nChar)
10811072 {
1082- case (VK_ESCAPE):
1073+ case (VK_ESCAPE):
10831074 {
10841075 // escape key is already handled in PreTranslateMessage to prevent
10851076 // it from getting to the main dialog. This code here is only
10861077 // in case it does not automatically go to the parent, which
10871078 // it sometimes does not.
1088- if ((Call(SCI_AUTOCACTIVE)==0)&&(Call(SCI_CALLTIPACTIVE)==0))
1079+ if ((Call(SCI_AUTOCACTIVE) == 0) && (Call(SCI_CALLTIPACTIVE) == 0))
10891080 ::SendMessage(GetParent()->GetSafeHwnd(), WM_CLOSE, 0, 0);
10901081 }
10911082 break;
@@ -1119,7 +1110,7 @@
11191110 }
11201111 }
11211112 break;
1122- case VK_SPACE:
1113+ case VK_SPACE:
11231114 {
11241115 if ((GetKeyState(VK_CONTROL) & 0x8000) && ((GetKeyState(VK_MENU) & 0x8000) == 0))
11251116 {
@@ -1128,24 +1119,24 @@
11281119 }
11291120 }
11301121 break;
1131- case VK_TAB:
1132- // The TAB cannot be handled in OnKeyDown because it is too late by then.
1133- {
1134- if ((GetKeyState(VK_CONTROL)&0x8000) && ((GetKeyState(VK_MENU) & 0x8000) == 0))
1122+ case VK_TAB:
1123+ // The TAB cannot be handled in OnKeyDown because it is too late by then.
11351124 {
1136- //Ctrl-Tab was pressed, this means we should provide the user with
1137- //a list of possible spell checking alternatives to the word under
1138- //the cursor
1139- SuggestSpellingAlternatives();
1140- return TRUE;
1125+ if ((GetKeyState(VK_CONTROL) & 0x8000) && ((GetKeyState(VK_MENU) & 0x8000) == 0))
1126+ {
1127+ //Ctrl-Tab was pressed, this means we should provide the user with
1128+ //a list of possible spell checking alternatives to the word under
1129+ //the cursor
1130+ SuggestSpellingAlternatives();
1131+ return TRUE;
1132+ }
1133+ else if (!Call(SCI_AUTOCACTIVE))
1134+ {
1135+ ::PostMessage(GetParent()->GetSafeHwnd(), WM_NEXTDLGCTL, GetKeyState(VK_SHIFT) & 0x8000, 0);
1136+ return TRUE;
1137+ }
11411138 }
1142- else if (!Call(SCI_AUTOCACTIVE))
1143- {
1144- ::PostMessage(GetParent()->GetSafeHwnd(), WM_NEXTDLGCTL, GetKeyState(VK_SHIFT)&0x8000, 0);
1145- return TRUE;
1146- }
1147- }
1148- break;
1139+ break;
11491140 }
11501141 }
11511142 return CWnd::PreTranslateMessage(pMsg);
@@ -1158,85 +1149,85 @@
11581149
11591150 void CSciEdit::OnContextMenu(CWnd* /*pWnd*/, CPoint point)
11601151 {
1161- int anchor = (int)Call(SCI_GETANCHOR);
1162- int currentpos = (int)Call(SCI_GETCURRENTPOS);
1163- int selstart = (int)Call(SCI_GETSELECTIONSTART);
1164- int selend = (int)Call(SCI_GETSELECTIONEND);
1165- int pointpos = 0;
1152+ int anchor = static_cast<int>(Call(SCI_GETANCHOR));
1153+ int currentPos = static_cast<int>(Call(SCI_GETCURRENTPOS));
1154+ int selStart = static_cast<int>(Call(SCI_GETSELECTIONSTART));
1155+ int selEnd = static_cast<int>(Call(SCI_GETSELECTIONEND));
1156+ int pointPos = 0;
11661157 if ((point.x == -1) && (point.y == -1))
11671158 {
11681159 CRect rect;
11691160 GetClientRect(&rect);
11701161 ClientToScreen(&rect);
1171- point = rect.CenterPoint();
1172- pointpos = (int)Call(SCI_GETCURRENTPOS);
1162+ point = rect.CenterPoint();
1163+ pointPos = static_cast<int>(Call(SCI_GETCURRENTPOS));
11731164 }
11741165 else
11751166 {
11761167 // change the cursor position to the point where the user
11771168 // right-clicked.
1178- CPoint clientpoint = point;
1179- ScreenToClient(&clientpoint);
1180- pointpos = (int)Call(SCI_POSITIONFROMPOINT, clientpoint.x, clientpoint.y);
1169+ CPoint clientPoint = point;
1170+ ScreenToClient(&clientPoint);
1171+ pointPos = static_cast<int>(Call(SCI_POSITIONFROMPOINT, clientPoint.x, clientPoint.y));
11811172 }
11821173 CString sMenuItemText;
1183- CMenu popup;
1184- bool bRestoreCursor = true;
1174+ CMenu popup;
1175+ bool bRestoreCursor = true;
11851176 if (popup.CreatePopupMenu())
11861177 {
1187- bool bCanUndo = !!Call(SCI_CANUNDO);
1188- bool bCanRedo = !!Call(SCI_CANREDO);
1189- bool bHasSelection = (selend-selstart > 0);
1190- bool bCanPaste = !!Call(SCI_CANPASTE);
1191- bool bIsReadOnly = !!Call(SCI_GETREADONLY);
1192- UINT uEnabledMenu = MF_STRING | MF_ENABLED;
1178+ bool bCanUndo = !!Call(SCI_CANUNDO);
1179+ bool bCanRedo = !!Call(SCI_CANREDO);
1180+ bool bHasSelection = (selEnd - selStart > 0);
1181+ bool bCanPaste = !!Call(SCI_CANPASTE);
1182+ bool bIsReadOnly = !!Call(SCI_GETREADONLY);
1183+ UINT uEnabledMenu = MF_STRING | MF_ENABLED;
11931184 UINT uDisabledMenu = MF_STRING | MF_GRAYED;
11941185
11951186 // find the word under the cursor
11961187 CString sWord;
1197- if (pointpos)
1188+ if (pointPos)
11981189 {
11991190 // setting the cursor clears the selection
1200- Call(SCI_SETANCHOR, pointpos);
1201- Call(SCI_SETCURRENTPOS, pointpos);
1191+ Call(SCI_SETANCHOR, pointPos);
1192+ Call(SCI_SETCURRENTPOS, pointPos);
12021193 sWord = GetWordUnderCursor();
12031194 // restore the selection
1204- Call(SCI_SETSELECTIONSTART, selstart);
1205- Call(SCI_SETSELECTIONEND, selend);
1195+ Call(SCI_SETSELECTIONSTART, selStart);
1196+ Call(SCI_SETSELECTIONEND, selEnd);
12061197 }
12071198 else
12081199 sWord = GetWordUnderCursor();
12091200 auto worda = GetWordForSpellChecker(sWord);
12101201
1211- int nCorrections = 1;
1212- bool bSpellAdded = false;
1202+ int nCorrections = 1;
1203+ bool bSpellAdded = false;
12131204 // check if the word under the cursor is spelled wrong
1214- if (!bIsReadOnly && (pChecker || m_SpellChecker) && (!worda.empty()))
1205+ if (!bIsReadOnly && (m_pChecker || m_spellChecker) && (!worda.empty()))
12151206 {
1216- if (m_SpellChecker)
1207+ if (m_spellChecker)
12171208 {
12181209 IEnumStringPtr enumSpellingSuggestions = nullptr;
1219- if (SUCCEEDED(m_SpellChecker->Suggest(sWord, &enumSpellingSuggestions)))
1210+ if (SUCCEEDED(m_spellChecker->Suggest(sWord, &enumSpellingSuggestions)))
12201211 {
12211212 LPOLESTR string = nullptr;
12221213 while (enumSpellingSuggestions->Next(1, &string, nullptr) == S_OK)
12231214 {
12241215 bSpellAdded = true;
1225- popup.InsertMenu((UINT)-1, 0, nCorrections++, string);
1216+ popup.InsertMenu(static_cast<UINT>(-1), 0, nCorrections++, string);
12261217 CoTaskMemFree(string);
12271218 }
12281219 }
12291220 }
1230- else if (pChecker)
1221+ else if (m_pChecker)
12311222 {
12321223 // get the spell suggestions
1233- auto wlst = pChecker->suggest(worda);
1224+ auto wlst = m_pChecker->suggest(worda);
12341225 // add the suggestions to the context menu
12351226 for (const auto& alternative : wlst)
12361227 {
12371228 bSpellAdded = true;
12381229 CString sug = GetWordFromSpellChecker(alternative);
1239- popup.InsertMenu((UINT)-1, 0, nCorrections++, sug);
1230+ popup.InsertMenu(static_cast<UINT>(-1), 0, nCorrections++, sug);
12401231 }
12411232 }
12421233 }
@@ -1247,9 +1238,9 @@
12471238 // also allow the user to add the word to the custom dictionary so
12481239 // it won't show up as misspelled anymore
12491240 if (!bIsReadOnly && (sWord.GetLength() < PDICT_MAX_WORD_LENGTH) && ((m_autolist.find(sWord) == m_autolist.end()) && (IsMisspelled(sWord))) &&
1250- (!_istdigit(sWord.GetAt(0)))&&(!m_personalDict.FindWord(sWord)))
1241+ (!_istdigit(sWord.GetAt(0))) && (!m_personalDict.FindWord(sWord)))
12511242 {
1252- sMenuItemText.Format(IDS_SCIEDIT_ADDWORD, (LPCWSTR)sWord);
1243+ sMenuItemText.Format(IDS_SCIEDIT_ADDWORD, static_cast<LPCWSTR>(sWord));
12531244 popup.AppendMenu(uEnabledMenu, SCI_ADDWORD, sMenuItemText);
12541245 // another separator
12551246 popup.AppendMenu(MF_SEPARATOR);
@@ -1287,7 +1278,7 @@
12871278 // now add any custom context menus
12881279 for (INT_PTR handlerindex = 0; handlerindex < m_arContextHandlers.GetCount(); ++handlerindex)
12891280 {
1290- CSciEditContextMenuInterface * pHandler = m_arContextHandlers.GetAt(handlerindex);
1281+ CSciEditContextMenuInterface* pHandler = m_arContextHandlers.GetAt(handlerindex);
12911282 pHandler->InsertMenuItems(popup, nCustoms);
12921283 }
12931284 if (nCustoms > nCorrections)
@@ -1296,28 +1287,28 @@
12961287 popup.AppendMenu(MF_SEPARATOR);
12971288 }
12981289
1299- int cmd = popup.TrackPopupMenu(TPM_RETURNCMD | TPM_LEFTALIGN | TPM_NONOTIFY | TPM_RIGHTBUTTON, point.x, point.y, this, 0);
1290+ int cmd = popup.TrackPopupMenu(TPM_RETURNCMD | TPM_LEFTALIGN | TPM_NONOTIFY | TPM_RIGHTBUTTON, point.x, point.y, this, nullptr);
13001291 switch (cmd)
13011292 {
1302- case 0:
1303- break; // no command selected
1304- case SCI_SELECTALL:
1305- bRestoreCursor = false;
1306- // fall through
1307- case SCI_UNDO:
1308- case SCI_REDO:
1309- case SCI_CUT:
1310- case SCI_COPY:
1311- case SCI_PASTE:
1312- Call(cmd);
1313- break;
1314- case SCI_ADDWORD:
1315- m_personalDict.AddWord(sWord);
1316- CheckSpelling((int)Call(SCI_POSITIONFROMLINE, Call(SCI_GETFIRSTVISIBLELINE)), (int)Call(SCI_POSITIONFROMLINE, Call(SCI_GETFIRSTVISIBLELINE) + Call(SCI_LINESONSCREEN)));
1317- break;
1318- case SCI_LINESSPLIT:
1293+ case 0:
1294+ break; // no command selected
1295+ case SCI_SELECTALL:
1296+ bRestoreCursor = false;
1297+ [[fallthrough]];
1298+ case SCI_UNDO:
1299+ case SCI_REDO:
1300+ case SCI_CUT:
1301+ case SCI_COPY:
1302+ case SCI_PASTE:
1303+ Call(cmd);
1304+ break;
1305+ case SCI_ADDWORD:
1306+ m_personalDict.AddWord(sWord);
1307+ CheckSpelling(static_cast<int>(Call(SCI_POSITIONFROMLINE, Call(SCI_GETFIRSTVISIBLELINE))), static_cast<int>(Call(SCI_POSITIONFROMLINE, Call(SCI_GETFIRSTVISIBLELINE) + Call(SCI_LINESONSCREEN))));
1308+ break;
1309+ case SCI_LINESSPLIT:
13191310 {
1320- int marker = (int)(Call(SCI_GETEDGECOLUMN) * Call(SCI_TEXTWIDTH, 0, (LPARAM)" "));
1311+ int marker = static_cast<int>(Call(SCI_GETEDGECOLUMN) * Call(SCI_TEXTWIDTH, 0, reinterpret_cast<LPARAM>(" ")));
13211312 if (marker)
13221313 {
13231314 m_blockModifiedHandler = true;
@@ -1328,82 +1319,82 @@
13281319 }
13291320 }
13301321 break;
1331- default:
1332- if (cmd < nCorrections)
1333- {
1334- Call(SCI_SETANCHOR, pointpos);
1335- Call(SCI_SETCURRENTPOS, pointpos);
1336- GetWordUnderCursor(true);
1337- CString temp;
1338- popup.GetMenuString(cmd, temp, 0);
1339- // setting the cursor clears the selection
1340- Call(SCI_REPLACESEL, 0, (LPARAM)(LPCSTR)StringForControl(temp));
1341- }
1342- else if (cmd < (nCorrections+nCustoms))
1343- {
1344- for (INT_PTR handlerindex = 0; handlerindex < m_arContextHandlers.GetCount(); ++handlerindex)
1322+ default:
1323+ if (cmd < nCorrections)
13451324 {
1346- CSciEditContextMenuInterface * pHandler = m_arContextHandlers.GetAt(handlerindex);
1347- if (pHandler->HandleMenuItemClick(cmd, this))
1348- break;
1325+ Call(SCI_SETANCHOR, pointPos);
1326+ Call(SCI_SETCURRENTPOS, pointPos);
1327+ GetWordUnderCursor(true);
1328+ CString temp;
1329+ popup.GetMenuString(cmd, temp, 0);
1330+ // setting the cursor clears the selection
1331+ Call(SCI_REPLACESEL, 0, reinterpret_cast<LPARAM>(static_cast<LPCSTR>(StringForControl(temp))));
13491332 }
1350- }
1333+ else if (cmd < (nCorrections + nCustoms))
1334+ {
1335+ for (INT_PTR handlerindex = 0; handlerindex < m_arContextHandlers.GetCount(); ++handlerindex)
1336+ {
1337+ CSciEditContextMenuInterface* pHandler = m_arContextHandlers.GetAt(handlerindex);
1338+ if (pHandler->HandleMenuItemClick(cmd, this))
1339+ break;
1340+ }
1341+ }
13511342 }
13521343 }
13531344 if (bRestoreCursor)
13541345 {
13551346 // restore the anchor and cursor position
1356- Call(SCI_SETCURRENTPOS, currentpos);
1347+ Call(SCI_SETCURRENTPOS, currentPos);
13571348 Call(SCI_SETANCHOR, anchor);
13581349 }
13591350 }
13601351
1361-bool CSciEdit::StyleEnteredText(Sci_Position startstylepos, Sci_Position endstylepos)
1352+bool CSciEdit::StyleEnteredText(Sci_Position startStylePos, Sci_Position endStylePos) const
13621353 {
1363- bool bStyled = false;
1364- const Sci_Position line = (Sci_Position)Call(SCI_LINEFROMPOSITION, startstylepos);
1365- const Sci_Position line_number_end = (Sci_Position)Call(SCI_LINEFROMPOSITION, endstylepos);
1366- for (auto line_number = line; line_number <= line_number_end; ++line_number)
1354+ bool bStyled = false;
1355+ const Sci_Position line = static_cast<Sci_Position>(Call(SCI_LINEFROMPOSITION, startStylePos));
1356+ const Sci_Position lineNumberEnd = static_cast<Sci_Position>(Call(SCI_LINEFROMPOSITION, endStylePos));
1357+ for (auto lineNumber = line; lineNumber <= lineNumberEnd; ++lineNumber)
13671358 {
1368- Sci_Position offset = (Sci_Position)Call(SCI_POSITIONFROMLINE, line_number);
1369- Sci_Position line_len = (Sci_Position)Call(SCI_LINELENGTH, line_number);
1370- auto linebuffer = std::make_unique<char[]>(line_len + 1);
1371- Call(SCI_GETLINE, line_number, (LPARAM)(linebuffer.get()));
1372- linebuffer[line_len] = 0;
1373- Sci_Position start = 0;
1374- Sci_Position end = 0;
1375- while (FindStyleChars(linebuffer.get(), '*', start, end))
1359+ Sci_Position offset = static_cast<Sci_Position>(Call(SCI_POSITIONFROMLINE, lineNumber));
1360+ Sci_Position lineLen = static_cast<Sci_Position>(Call(SCI_LINELENGTH, lineNumber));
1361+ auto lineBuffer = std::make_unique<char[]>(lineLen + 1);
1362+ Call(SCI_GETLINE, lineNumber, reinterpret_cast<LPARAM>(lineBuffer.get()));
1363+ lineBuffer[lineLen] = 0;
1364+ Sci_Position start = 0;
1365+ Sci_Position end = 0;
1366+ while (FindStyleChars(lineBuffer.get(), '*', start, end))
13761367 {
13771368 Call(SCI_STARTSTYLING, start + offset, STYLE_BOLD);
1378- Call(SCI_SETSTYLING, end-start, STYLE_BOLD);
1369+ Call(SCI_SETSTYLING, end - start, STYLE_BOLD);
13791370 bStyled = true;
1380- start = end;
1371+ start = end;
13811372 }
13821373 start = 0;
1383- end = 0;
1384- while (FindStyleChars(linebuffer.get(), '^', start, end))
1374+ end = 0;
1375+ while (FindStyleChars(lineBuffer.get(), '^', start, end))
13851376 {
13861377 Call(SCI_STARTSTYLING, start + offset, STYLE_ITALIC);
1387- Call(SCI_SETSTYLING, end-start, STYLE_ITALIC);
1378+ Call(SCI_SETSTYLING, end - start, STYLE_ITALIC);
13881379 bStyled = true;
1389- start = end;
1380+ start = end;
13901381 }
13911382 start = 0;
1392- end = 0;
1393- while (FindStyleChars(linebuffer.get(), '_', start, end))
1383+ end = 0;
1384+ while (FindStyleChars(lineBuffer.get(), '_', start, end))
13941385 {
13951386 Call(SCI_STARTSTYLING, start + offset, STYLE_UNDERLINED);
1396- Call(SCI_SETSTYLING, end-start, STYLE_UNDERLINED);
1387+ Call(SCI_SETSTYLING, end - start, STYLE_UNDERLINED);
13971388 bStyled = true;
1398- start = end;
1389+ start = end;
13991390 }
14001391 }
14011392 return bStyled;
14021393 }
14031394
1404-bool CSciEdit::WrapLines(Sci_Position startpos, Sci_Position endpos)
1395+bool CSciEdit::WrapLines(Sci_Position startpos, Sci_Position endpos) const
14051396 {
1406- Sci_Position markerX = (Sci_Position)(Call(SCI_GETEDGECOLUMN) * Call(SCI_TEXTWIDTH, 0, (LPARAM)" "));
1397+ Sci_Position markerX = static_cast<Sci_Position>(Call(SCI_GETEDGECOLUMN) * Call(SCI_TEXTWIDTH, 0, reinterpret_cast<LPARAM>(" ")));
14071398 if (markerX)
14081399 {
14091400 Call(SCI_SETTARGETSTART, startpos);
@@ -1414,19 +1405,19 @@
14141405 return false;
14151406 }
14161407
1417-void CSciEdit::AdvanceUTF8(const char * str, int& pos)
1408+void CSciEdit::AdvanceUTF8(const char* str, int& pos)
14181409 {
1419- if ((str[pos] & 0xE0)==0xC0)
1410+ if ((str[pos] & 0xE0) == 0xC0)
14201411 {
14211412 // utf8 2-byte sequence
14221413 pos += 2;
14231414 }
1424- else if ((str[pos] & 0xF0)==0xE0)
1415+ else if ((str[pos] & 0xF0) == 0xE0)
14251416 {
14261417 // utf8 3-byte sequence
14271418 pos += 3;
14281419 }
1429- else if ((str[pos] & 0xF8)==0xF0)
1420+ else if ((str[pos] & 0xF8) == 0xF0)
14301421 {
14311422 // utf8 4-byte sequence
14321423 pos += 4;
@@ -1435,10 +1426,10 @@
14351426 pos++;
14361427 }
14371428
1438-bool CSciEdit::FindStyleChars(const char * line, char styler, Sci_Position& start, Sci_Position& end)
1429+bool CSciEdit::FindStyleChars(const char* line, char styler, Sci_Position& start, Sci_Position& end)
14391430 {
1440- int i=0;
1441- int u=0;
1431+ int i = 0;
1432+ int u = 0;
14421433 while (i < start)
14431434 {
14441435 AdvanceUTF8(line, i);
@@ -1445,17 +1436,17 @@
14451436 u++;
14461437 }
14471438
1448- bool bFoundMarker = false;
1449- CString sULine = CUnicodeUtils::GetUnicode(line);
1439+ bool bFoundMarker = false;
1440+ CString sULine = CUnicodeUtils::GetUnicode(line);
14501441 // find a starting marker
14511442 while (line[i] != 0)
14521443 {
14531444 if (line[i] == styler)
14541445 {
1455- if ((line[i+1]!=0)&&(IsCharAlphaNumeric(sULine[u+1]))&&
1456- (((u>0)&&(!IsCharAlphaNumeric(sULine[u-1]))) || (u==0)))
1446+ if ((line[i + 1] != 0) && (IsCharAlphaNumeric(sULine[u + 1])) &&
1447+ (((u > 0) && (!IsCharAlphaNumeric(sULine[u - 1]))) || (u == 0)))
14571448 {
1458- start = i+1;
1449+ start = i + 1LL;
14591450 AdvanceUTF8(line, i);
14601451 u++;
14611452 bFoundMarker = true;
@@ -1473,9 +1464,8 @@
14731464 {
14741465 if (line[i] == styler)
14751466 {
1476- if ((IsCharAlphaNumeric(sULine[u-1]))&&
1477- ((((u+1)<sULine.GetLength())&&(!IsCharAlphaNumeric(sULine[u+1]))) || ((u+1) == sULine.GetLength()))
1478- )
1467+ if ((IsCharAlphaNumeric(sULine[u - 1])) &&
1468+ ((((u + 1) < sULine.GetLength()) && (!IsCharAlphaNumeric(sULine[u + 1]))) || ((u + 1) == sULine.GetLength())))
14791469 {
14801470 end = i;
14811471 i++;
@@ -1489,33 +1479,33 @@
14891479 return bFoundMarker;
14901480 }
14911481
1492-BOOL CSciEdit::MarkEnteredBugID(Sci_Position startstylepos, Sci_Position endstylepos)
1482+BOOL CSciEdit::MarkEnteredBugID(Sci_Position startstylepos, Sci_Position endstylepos) const
14931483 {
14941484 if (m_sCommand.IsEmpty())
14951485 return FALSE;
14961486 // get the text between the start and end position we have to style
1497- const Sci_Position line_number = (Sci_Position)Call(SCI_LINEFROMPOSITION, startstylepos);
1498- Sci_Position start_pos = (Sci_Position)Call(SCI_POSITIONFROMLINE, (WPARAM)line_number);
1499- Sci_Position end_pos = endstylepos;
1487+ const Sci_Position lineNumber = static_cast<Sci_Position>(Call(SCI_LINEFROMPOSITION, startstylepos));
1488+ Sci_Position startPos = static_cast<Sci_Position>(Call(SCI_POSITIONFROMLINE, static_cast<WPARAM>(lineNumber)));
1489+ Sci_Position endPos = endstylepos;
15001490
1501- if (start_pos == end_pos)
1491+ if (startPos == endPos)
15021492 return FALSE;
1503- if (start_pos > end_pos)
1493+ if (startPos > endPos)
15041494 {
1505- auto switchtemp = start_pos;
1506- start_pos = end_pos;
1507- end_pos = switchtemp;
1495+ auto switchtemp = startPos;
1496+ startPos = endPos;
1497+ endPos = switchtemp;
15081498 }
15091499
1510- auto textbuffer = std::make_unique<char[]>(end_pos - start_pos + 2);
1511- Sci_TextRange textrange;
1512- textrange.lpstrText = textbuffer.get();
1513- textrange.chrg.cpMin = (Sci_PositionCR)start_pos;
1514- textrange.chrg.cpMax = (Sci_PositionCR)end_pos;
1515- Call(SCI_GETTEXTRANGE, 0, (LPARAM)&textrange);
1516- CStringA msg = CStringA(textbuffer.get());
1500+ auto textBuffer = std::make_unique<char[]>(endPos - startPos + 2);
1501+ Sci_TextRange textRange;
1502+ textRange.lpstrText = textBuffer.get();
1503+ textRange.chrg.cpMin = static_cast<Sci_PositionCR>(startPos);
1504+ textRange.chrg.cpMax = static_cast<Sci_PositionCR>(endPos);
1505+ Call(SCI_GETTEXTRANGE, 0, reinterpret_cast<LPARAM>(&textRange));
1506+ CStringA msg = CStringA(textBuffer.get());
15171507
1518- Call(SCI_STARTSTYLING, start_pos, STYLE_MASK);
1508+ Call(SCI_STARTSTYLING, startPos, STYLE_MASK);
15191509
15201510 try
15211511 {
@@ -1522,11 +1512,11 @@
15221512 if (!m_sBugID.IsEmpty())
15231513 {
15241514 // match with two regex strings (without grouping!)
1525- const std::regex regCheck(m_sCommand);
1526- const std::regex regBugID(m_sBugID);
1515+ const std::regex regCheck(m_sCommand);
1516+ const std::regex regBugID(m_sBugID);
15271517 const std::sregex_iterator end;
1528- std::string s = msg;
1529- LONG pos = 0;
1518+ std::string s = static_cast<LPCSTR>(msg);
1519+ LONG pos = 0;
15301520 // note:
15311521 // if start_pos is 0, we're styling from the beginning and let the ^ char match the beginning of the line
15321522 // that way, the ^ matches the very beginning of the log message and not the beginning of further lines.
@@ -1533,14 +1523,14 @@
15331523 // problem is: this only works *while* entering log messages. If a log message is pasted in whole or
15341524 // multiple lines are pasted, start_pos can be 0 and styling goes over multiple lines. In that case, those
15351525 // additional line starts also match ^
1536- for (std::sregex_iterator it(s.begin(), s.end(), regCheck, start_pos != 0 ? std::regex_constants::match_not_bol : std::regex_constants::match_default); it != end; ++it)
1526+ for (std::sregex_iterator it(s.begin(), s.end(), regCheck, startPos != 0 ? std::regex_constants::match_not_bol : std::regex_constants::match_default); it != end; ++it)
15371527 {
15381528 // clear the styles up to the match position
1539- Call(SCI_SETSTYLING, it->position(0)-pos, STYLE_DEFAULT);
1529+ Call(SCI_SETSTYLING, it->position(0) - pos, STYLE_DEFAULT);
15401530
15411531 // (*it)[0] is the matched string
15421532 std::string matchedString = (*it)[0];
1543- LONG matchedpos = 0;
1533+ LONG matchedPos = 0;
15441534 for (std::sregex_iterator it2(matchedString.begin(), matchedString.end(), regBugID); it2 != end; ++it2)
15451535 {
15461536 ATLTRACE("matched id : %s\n", std::string((*it2)[0]).c_str());
@@ -1548,34 +1538,34 @@
15481538 // bold style up to the id match
15491539 ATLTRACE("position = %ld\n", it2->position(0));
15501540 if (it2->position(0))
1551- Call(SCI_SETSTYLING, it2->position(0)-matchedpos, STYLE_ISSUEBOLD);
1541+ Call(SCI_SETSTYLING, it2->position(0) - matchedPos, STYLE_ISSUEBOLD);
15521542 // bold and recursive style for the bug ID itself
15531543 if ((*it2)[0].str().size())
15541544 Call(SCI_SETSTYLING, (*it2)[0].str().size(), STYLE_ISSUEBOLDITALIC);
1555- matchedpos = (LONG)(it2->position(0) + (*it2)[0].str().size());
1545+ matchedPos = static_cast<LONG>(it2->position(0) + (*it2)[0].str().size());
15561546 }
1557- if ((matchedpos)&&(matchedpos < (LONG)matchedString.size()))
1547+ if ((matchedPos) && (matchedPos < static_cast<LONG>(matchedString.size())))
15581548 {
1559- Call(SCI_SETSTYLING, matchedString.size() - matchedpos, STYLE_ISSUEBOLD);
1549+ Call(SCI_SETSTYLING, matchedString.size() - matchedPos, STYLE_ISSUEBOLD);
15601550 }
1561- pos = (LONG)(it->position(0) + matchedString.size());
1551+ pos = static_cast<LONG>(it->position(0) + matchedString.size());
15621552 }
15631553 // bold style for the rest of the string which isn't matched
1564- if (s.size()-pos)
1565- Call(SCI_SETSTYLING, s.size()-pos, STYLE_DEFAULT);
1554+ if (s.size() - pos)
1555+ Call(SCI_SETSTYLING, s.size() - pos, STYLE_DEFAULT);
15661556 }
15671557 else
15681558 {
1569- const std::regex regCheck(m_sCommand);
1559+ const std::regex regCheck(m_sCommand);
15701560 const std::sregex_iterator end;
1571- std::string s = msg;
1572- LONG pos = 0;
1561+ std::string s = static_cast<LPCSTR>(msg);
1562+ LONG pos = 0;
15731563 for (std::sregex_iterator it(s.begin(), s.end(), regCheck); it != end; ++it)
15741564 {
15751565 // clear the styles up to the match position
15761566 if (it->position(0) - pos >= 0)
15771567 Call(SCI_SETSTYLING, it->position(0) - pos, STYLE_DEFAULT);
1578- pos = (LONG)it->position(0);
1568+ pos = static_cast<LONG>(it->position(0));
15791569
15801570 const std::smatch match = *it;
15811571 // we define group 1 as the whole issue text and
@@ -1586,12 +1576,14 @@
15861576 if (match[1].first - s.begin() - pos >= 0)
15871577 Call(SCI_SETSTYLING, match[1].first - s.begin() - pos, STYLE_ISSUEBOLD);
15881578 Call(SCI_SETSTYLING, std::string(match[1]).size(), STYLE_ISSUEBOLDITALIC);
1589- pos = (LONG)(match[1].second-s.begin());
1579+ pos = static_cast<LONG>(match[1].second - s.begin());
15901580 }
15911581 }
15921582 }
15931583 }
1594- catch (std::exception&) {}
1584+ catch (std::exception&)
1585+ {
1586+ }
15951587
15961588 return FALSE;
15971589 }
@@ -1599,64 +1591,64 @@
15991591 bool CSciEdit::IsValidURLChar(unsigned char ch)
16001592 {
16011593 return isalnum(ch) ||
1602- ch == '_' || ch == '/' || ch == ';' || ch == '?' || ch == '&' || ch == '=' ||
1603- ch == '%' || ch == ':' || ch == '.' || ch == '#' || ch == '-' || ch == '+' ||
1604- ch == '|' || ch == '>' || ch == '<' || ch == '!' || ch == '@' || ch == '~';
1594+ ch == '_' || ch == '/' || ch == ';' || ch == '?' || ch == '&' || ch == '=' ||
1595+ ch == '%' || ch == ':' || ch == '.' || ch == '#' || ch == '-' || ch == '+' ||
1596+ ch == '|' || ch == '>' || ch == '<' || ch == '!' || ch == '@' || ch == '~';
16051597 }
16061598
1607-void CSciEdit::StyleURLs(Sci_Position startstylepos, Sci_Position endstylepos)
1599+void CSciEdit::StyleURLs(Sci_Position startStylePos, Sci_Position endStylePos) const
16081600 {
1609- const Sci_Position line_number = (Sci_Position)Call(SCI_LINEFROMPOSITION, startstylepos);
1610- startstylepos = (Sci_Position)Call(SCI_POSITIONFROMLINE, (WPARAM)line_number);
1601+ const Sci_Position lineNumber = static_cast<Sci_Position>(Call(SCI_LINEFROMPOSITION, startStylePos));
1602+ startStylePos = static_cast<Sci_Position>(Call(SCI_POSITIONFROMLINE, static_cast<WPARAM>(lineNumber)));
16111603
1612- auto len = endstylepos - startstylepos + 1;
1613- auto textbuffer = std::make_unique<char[]>(len + 1);
1614- Sci_TextRange textrange;
1615- textrange.lpstrText = textbuffer.get();
1616- textrange.chrg.cpMin = (Sci_PositionCR)startstylepos;
1617- textrange.chrg.cpMax = (Sci_PositionCR)endstylepos;
1618- Call(SCI_GETTEXTRANGE, 0, (LPARAM)&textrange);
1604+ auto len = endStylePos - startStylePos + 1;
1605+ auto textBuffer = std::make_unique<char[]>(len + 1);
1606+ Sci_TextRange textRange;
1607+ textRange.lpstrText = textBuffer.get();
1608+ textRange.chrg.cpMin = static_cast<Sci_PositionCR>(startStylePos);
1609+ textRange.chrg.cpMax = static_cast<Sci_PositionCR>(endStylePos);
1610+ Call(SCI_GETTEXTRANGE, 0, reinterpret_cast<LPARAM>(&textRange));
16191611 // we're dealing with utf8 encoded text here, which means one glyph is
16201612 // not necessarily one byte/wchar_t
16211613 // that's why we use CStringA to still get a correct char index
1622- CStringA msg = textbuffer.get();
1614+ CStringA msg = textBuffer.get();
16231615
1624- int starturl = -1;
1616+ int startUrl = -1;
16251617 for (int i = 0; i <= msg.GetLength(); AdvanceUTF8(msg, i))
16261618 {
16271619 if ((i < len) && IsValidURLChar(msg[i]))
16281620 {
1629- if (starturl < 0)
1630- starturl = i;
1621+ if (startUrl < 0)
1622+ startUrl = i;
16311623 }
16321624 else
16331625 {
1634- if (starturl >= 0)
1626+ if (startUrl >= 0)
16351627 {
16361628 bool strip = true;
1637- if (msg[starturl] == '<' && i < len) // try to detect and do not strip URLs put within <>
1629+ if (msg[startUrl] == '<' && i < len) // try to detect and do not strip URLs put within <>
16381630 {
1639- while (starturl <= i && msg[starturl] == '<') // strip leading '<'
1640- ++starturl;
1631+ while (startUrl <= i && msg[startUrl] == '<') // strip leading '<'
1632+ ++startUrl;
16411633 strip = false;
1642- i = starturl;
1634+ i = startUrl;
16431635 while (i < len && msg[i] != '\r' && msg[i] != '\n' && msg[i] != '>') // find first '>' or new line after resetting i to start position
16441636 AdvanceUTF8(msg, i);
16451637 }
1646- ASSERT(startstylepos + i <= endstylepos);
1638+ ASSERT(startStylePos + i <= endStylePos);
16471639 int skipTrailing = 0;
1648- while (strip && i - skipTrailing - 1 > starturl && (msg[i - skipTrailing - 1] == '.' || msg[i - skipTrailing - 1] == '-' || msg[i - skipTrailing - 1] == '?' || msg[i - skipTrailing - 1] == ';' || msg[i - skipTrailing - 1] == ':' || msg[i - skipTrailing - 1] == '>' || msg[i - skipTrailing - 1] == '<' || msg[i - skipTrailing - 1] == '!'))
1640+ while (strip && i - skipTrailing - 1 > startUrl && (msg[i - skipTrailing - 1] == '.' || msg[i - skipTrailing - 1] == '-' || msg[i - skipTrailing - 1] == '?' || msg[i - skipTrailing - 1] == ';' || msg[i - skipTrailing - 1] == ':' || msg[i - skipTrailing - 1] == '>' || msg[i - skipTrailing - 1] == '<' || msg[i - skipTrailing - 1] == '!'))
16491641 ++skipTrailing;
1650- if (!IsUrlOrEmail(msg.Mid(starturl, i - starturl - skipTrailing)))
1642+ if (!IsUrlOrEmail(msg.Mid(startUrl, i - startUrl - skipTrailing)))
16511643 {
1652- starturl = -1;
1644+ startUrl = -1;
16531645 continue;
16541646 }
1655- ASSERT(startstylepos + i - skipTrailing <= endstylepos);
1656- Call(SCI_STARTSTYLING, startstylepos + starturl, STYLE_URL);
1657- Call(SCI_SETSTYLING, i - starturl - skipTrailing, STYLE_URL);
1647+ ASSERT(startStylePos + i - skipTrailing <= endStylePos);
1648+ Call(SCI_STARTSTYLING, startStylePos + startUrl, STYLE_URL);
1649+ Call(SCI_SETSTYLING, i - startUrl - skipTrailing, STYLE_URL);
16581650 }
1659- starturl = -1;
1651+ startUrl = -1;
16601652 }
16611653 }
16621654 }
@@ -1665,32 +1657,32 @@
16651657 {
16661658 if (!PathIsURLA(sText))
16671659 {
1668- auto atpos = sText.Find('@');
1669- if (atpos <= 0)
1660+ auto atPos = sText.Find('@');
1661+ if (atPos <= 0)
16701662 return false;
1671- if (sText.ReverseFind('.') > atpos)
1663+ if (sText.ReverseFind('.') > atPos)
16721664 return true;
16731665 return false;
16741666 }
1675- if (sText.Find("://")>=0)
1667+ if (sText.Find("://") >= 0)
16761668 return true;
16771669 return false;
16781670 }
16791671
1680-std::string CSciEdit::GetWordForSpellChecker(const CString& sWord)
1672+std::string CSciEdit::GetWordForSpellChecker(const CString& sWord) const
16811673 {
16821674 // convert the string from the control to the encoding of the spell checker module.
16831675 std::string sWordA;
1684- if (m_spellcodepage)
1676+ if (m_spellCodepage)
16851677 {
1686- int lengthIncTerminator = WideCharToMultiByte(m_spellcodepage, 0, sWord, -1, nullptr, 0, nullptr, nullptr);
1678+ int lengthIncTerminator = WideCharToMultiByte(m_spellCodepage, 0, sWord, -1, nullptr, 0, nullptr, nullptr);
16871679 if (lengthIncTerminator <= 1)
16881680 return ""; // converting to the codepage failed
1689- sWordA.resize(lengthIncTerminator - 1);
1690- WideCharToMultiByte(m_spellcodepage, 0, sWord, -1, sWordA.data(), lengthIncTerminator - 1, nullptr, nullptr);
1681+ sWordA.resize(lengthIncTerminator - 1LL);
1682+ WideCharToMultiByte(m_spellCodepage, 0, sWord, -1, sWordA.data(), lengthIncTerminator - 1, nullptr, nullptr);
16911683 }
16921684 else
1693- sWordA = std::string(reinterpret_cast<LPCSTR>(static_cast<LPCTSTR>(sWord)));
1685+ sWordA = std::string(reinterpret_cast<LPCSTR>(static_cast<LPCWSTR>(sWord)));
16941686
16951687 sWordA.erase(sWordA.find_last_not_of("\'\".,") + 1);
16961688 sWordA.erase(0, sWordA.find_first_not_of("\'\".,"));
@@ -1697,15 +1689,15 @@
16971689
16981690 if (m_bDoStyle)
16991691 {
1700- for (const auto styleindicator : { '*', '_', '^' })
1692+ for (const auto styleIndicator : {'*', '_', '^'})
17011693 {
17021694 if (sWordA.empty())
17031695 break;
1704- if (sWordA[sWordA.size() - 1] == styleindicator)
1696+ if (sWordA[sWordA.size() - 1] == styleIndicator)
17051697 sWordA.resize(sWordA.size() - 1);
17061698 if (sWordA.empty())
17071699 break;
1708- if (sWordA[0] == styleindicator)
1700+ if (sWordA[0] == styleIndicator)
17091701 sWordA = sWordA.substr(sWordA.size() - 1);
17101702 }
17111703 }
@@ -1713,17 +1705,17 @@
17131705 return sWordA;
17141706 }
17151707
1716-CString CSciEdit::GetWordFromSpellChecker(const std::string& sWordA)
1708+CString CSciEdit::GetWordFromSpellChecker(const std::string& sWordA) const
17171709 {
17181710 CString sWord;
1719- if (m_spellcodepage)
1711+ if (m_spellCodepage)
17201712 {
17211713 wchar_t* buf = sWord.GetBuffer(static_cast<int>(sWordA.size()) * 2);
1722- int lengthIncTerminator =
1723- MultiByteToWideChar(m_spellcodepage, 0, sWordA.c_str(), -1, buf, static_cast<int>(sWordA.size()) * 2);
1714+ int lengthIncTerminator =
1715+ MultiByteToWideChar(m_spellCodepage, 0, sWordA.c_str(), -1, buf, static_cast<int>(sWordA.size()) * 2);
17241716 if (lengthIncTerminator == 0)
17251717 return L"";
1726- sWord.ReleaseBuffer(lengthIncTerminator-1);
1718+ sWord.ReleaseBuffer(lengthIncTerminator - 1);
17271719 }
17281720 else
17291721 sWord = CString(sWordA.c_str());
@@ -1733,9 +1725,9 @@
17331725 return sWord;
17341726 }
17351727
1736-void CSciEdit::RestyleBugIDs()
1728+void CSciEdit::RestyleBugIDs() const
17371729 {
1738- int endstylepos = (int)Call(SCI_GETLENGTH);
1730+ int endstylepos = static_cast<int>(Call(SCI_GETLENGTH));
17391731 // clear all styles
17401732 Call(SCI_STARTSTYLING, 0, STYLE_MASK);
17411733 Call(SCI_SETSTYLING, endstylepos, STYLE_DEFAULT);
--- trunk/src/Utils/MiscUI/SciEdit.h (revision 29188)
+++ trunk/src/Utils/MiscUI/SciEdit.h (revision 29189)
@@ -1,6 +1,6 @@
11 // TortoiseSVN - a Windows shell extension for easy version control
22
3-// Copyright (C) 2003-2011, 2013, 2015-2020 - TortoiseSVN
3+// Copyright (C) 2003-2011, 2013, 2015-2021 - TortoiseSVN
44
55 // This program is free software; you can redistribute it and/or
66 // modify it under the terms of the GNU General Public License
@@ -19,7 +19,6 @@
1919 #pragma once
2020 #include "../SmartHandle.h"
2121 #include "scintilla.h"
22-#include "SciLexer.h"
2322 #include "../../../ext/hunspell/hunspell.hxx"
2423 #include "ProjectProperties.h"
2524 #include "PersonalDictionary.h"
@@ -27,10 +26,10 @@
2726 #include <spellcheck.h>
2827 #include "LruCache.h"
2928
30-#define AUTOCOMPLETE_SPELLING 0
31-#define AUTOCOMPLETE_FILENAME 1
32-#define AUTOCOMPLETE_PROGRAMCODE 2
33-#define AUTOCOMPLETE_SNIPPET 3
29+#define AUTOCOMPLETE_SPELLING 0
30+#define AUTOCOMPLETE_FILENAME 1
31+#define AUTOCOMPLETE_PROGRAMCODE 2
32+#define AUTOCOMPLETE_SNIPPET 3
3433
3534 _COM_SMARTPTR_TYPEDEF(ISpellCheckerFactory, __uuidof(ISpellCheckerFactory));
3635 _COM_SMARTPTR_TYPEDEF(ISpellChecker, __uuidof(ISpellChecker));
@@ -50,6 +49,7 @@
5049 class CSciEditContextMenuInterface
5150 {
5251 public:
52+ virtual ~CSciEditContextMenuInterface() = default;
5353 /**
5454 * When the handler is called with this method, it can add entries
5555 * to the \a mPopup context menu itself. The \a nCmd param is the command
@@ -56,7 +56,7 @@
5656 * ID number the handler must use for its commands. For every added command,
5757 * the handler is responsible to increment the \a nCmd param by one.
5858 */
59- virtual void InsertMenuItems(CMenu& mPopup, int& nCmd);
59+ virtual void InsertMenuItems(CMenu& mPopup, int& nCmd);
6060
6161 /**
6262 * The handler is called when the user clicks on any context menu entry
@@ -65,8 +65,8 @@
6565 * \remark the handler should return \a true if it handled the call, otherwise
6666 * it should return \a false
6767 */
68- virtual bool HandleMenuItemClick(int cmd, CSciEdit * pSciEdit);
69- virtual void HandleSnippet(int type, const CString &text, CSciEdit *pSciEdit);
68+ virtual bool HandleMenuItemClick(int cmd, CSciEdit* pSciEdit);
69+ virtual void HandleSnippet(int type, const CString& text, CSciEdit* pSciEdit);
7070 };
7171
7272 /**
@@ -79,24 +79,24 @@
7979 {
8080 DECLARE_DYNAMIC(CSciEdit)
8181 public:
82- CSciEdit(void);
83- ~CSciEdit(void);
82+ CSciEdit();
83+ ~CSciEdit() override;
8484 /**
8585 * Initialize the scintilla control. Must be called prior to any other
8686 * method!
8787 */
88- void Init(const ProjectProperties& props);
89- void Init(LONG lLanguage = 0);
90- void SetIcon(const std::map<int, UINT> &icons);
88+ void Init(const ProjectProperties& props);
89+ void Init(LONG lLanguage = 0);
90+ void SetIcon(const std::map<int, UINT>& icons) const;
9191
9292 /**
9393 * Execute a scintilla command, e.g. SCI_GETLINE.
9494 */
95- LRESULT Call(UINT message, WPARAM wParam = 0, LPARAM lParam = 0);
95+ LRESULT Call(UINT message, WPARAM wParam = 0, LPARAM lParam = 0) const;
9696 /**
9797 * The specified text is written to the scintilla control.
9898 */
99- void SetText(const CString& sText);
99+ void SetText(const CString& sText);
100100 /**
101101 * The specified text is inserted at the cursor position. If a text is
102102 * selected, that text is replaced.
@@ -103,79 +103,81 @@
103103 * \param sText test to insert
104104 * \param bNewLine if set to true, a newline is appended.
105105 */
106- void InsertText(const CString& sText, bool bNewLine = false);
106+ void InsertText(const CString& sText, bool bNewLine = false);
107107 /**
108108 * Retrieves the text in the scintilla control.
109109 */
110- CString GetText(void);
110+ CString GetText(void) const;
111111 /**
112112 * Sets the font for the control.
113113 */
114- void SetFont(CString sFontName, int iFontSizeInPoints);
114+ void SetFont(CString sFontName, int iFontSizeInPoints) const;
115115 /**
116116 * Adds a list of words for use in auto completion.
117117 */
118- void SetAutoCompletionList(std::map<CString, int>&& list, TCHAR separator = ';', TCHAR typeSeparator = '?');
118+ void SetAutoCompletionList(std::map<CString, int>&& list, TCHAR separator = ';', TCHAR typeSeparator = '?');
119119 /**
120120 * Returns the word located under the cursor.
121121 */
122- CString GetWordUnderCursor(bool bSelectWord = false, bool allchars = false);
122+ CString GetWordUnderCursor(bool bSelectWord = false, bool allchars = false) const;
123123
124- void RegisterContextMenuHandler(CSciEditContextMenuInterface * object) {m_arContextHandlers.Add(object);}
124+ void RegisterContextMenuHandler(CSciEditContextMenuInterface* object) { m_arContextHandlers.Add(object); }
125125
126- CStringA StringForControl(const CString& text);
127- CString StringFromControl(const CStringA& text);
126+ CStringA StringForControl(const CString& text) const;
127+ CString StringFromControl(const CStringA& text) const;
128128
129- void SetRepositoryRoot(const CString& url) {m_sRepositoryRoot = url;}
129+ void SetRepositoryRoot(const CString& url) { m_sRepositoryRoot = url; }
130130
131- void RestyleBugIDs();
131+ void RestyleBugIDs() const;
132132
133- void SetReadOnly(bool bReadOnly);
133+ void SetReadOnly(bool bReadOnly);
134+
134135 private:
135- CAutoLibrary m_hModule;
136- LRESULT m_DirectFunction;
137- LRESULT m_DirectPointer;
138- std::unique_ptr<Hunspell> pChecker;
139- UINT m_spellcodepage;
140- std::map<CString, int> m_autolist;
141- TCHAR m_separator;
142- TCHAR m_typeSeparator;
143- CStringA m_sCommand;
144- CStringA m_sBugID;
145- CString m_sUrl;
146- CString m_sRepositoryRoot;
147- CArray<CSciEditContextMenuInterface *, CSciEditContextMenuInterface *> m_arContextHandlers;
148- CPersonalDictionary m_personalDict;
149- bool m_bDoStyle;
150- int m_nAutoCompleteMinChars;
151- ISpellCheckerFactoryPtr m_spellCheckerFactory;
152- ISpellCheckerPtr m_SpellChecker;
153- LruCache<std::wstring, BOOL> m_SpellingCache;
154- bool m_blockModifiedHandler;
155- bool m_bReadOnly;
156- int m_themeCallbackId;
136+ CAutoLibrary m_hModule;
137+ LRESULT m_directFunction;
138+ LRESULT m_directPointer;
139+ std::unique_ptr<Hunspell> m_pChecker;
140+ UINT m_spellCodepage;
141+ std::map<CString, int> m_autolist;
142+ TCHAR m_separator;
143+ TCHAR m_typeSeparator;
144+ CStringA m_sCommand;
145+ CStringA m_sBugID;
146+ CString m_sUrl;
147+ CString m_sRepositoryRoot;
148+ CArray<CSciEditContextMenuInterface*, CSciEditContextMenuInterface*> m_arContextHandlers;
149+ CPersonalDictionary m_personalDict;
150+ bool m_bDoStyle;
151+ int m_nAutoCompleteMinChars;
152+ ISpellCheckerFactoryPtr m_spellCheckerFactory;
153+ ISpellCheckerPtr m_spellChecker;
154+ LruCache<std::wstring, BOOL> m_spellingCache;
155+ bool m_blockModifiedHandler;
156+ bool m_bReadOnly;
157+ int m_themeCallbackId;
157158
158159 static bool IsValidURLChar(unsigned char ch);
160+
159161 protected:
160- virtual BOOL OnChildNotify(UINT message, WPARAM wParam, LPARAM lParam, LRESULT* pLResult);
161- virtual BOOL PreTranslateMessage(MSG* pMsg);
162+ BOOL OnChildNotify(UINT message, WPARAM wParam, LPARAM lParam, LRESULT* pLResult) override;
163+ BOOL PreTranslateMessage(MSG* pMsg) override;
162164 virtual ULONG GetGestureStatus(CPoint ptTouch) override;
163- void CheckSpelling(Sci_Position startpos, Sci_Position endpos);
164- void SuggestSpellingAlternatives(void);
165- void DoAutoCompletion(Sci_Position nMinPrefixLength);
166- BOOL LoadDictionaries(LONG lLanguageID);
167- BOOL MarkEnteredBugID(Sci_Position startstylepos, Sci_Position endstylepos);
168- bool StyleEnteredText(Sci_Position startstylepos, Sci_Position endstylepos);
169- void StyleURLs(Sci_Position startstylepos, Sci_Position endstylepos);
170- bool WrapLines(Sci_Position startpos, Sci_Position endpos);
171- bool FindStyleChars(const char * line, char styler, Sci_Position& start, Sci_Position& end);
172- void AdvanceUTF8(const char * str, int& pos);
173- BOOL CheckWordSpelling(const CString & sWord);
174- BOOL IsMisspelled(const CString& sWord);
175- DWORD GetStyleAt(Sci_Position pos) { return (DWORD)Call(SCI_GETSTYLEAT, pos) & 0x1f; }
176- bool IsUrlOrEmail(const CStringA& sText);
177- std::string GetWordForSpellChecker(const CString& sWord);
178- CString GetWordFromSpellChecker(const std::string& sWordA);
165+ void CheckSpelling(Sci_Position startpos, Sci_Position endpos);
166+ void SuggestSpellingAlternatives(void) const;
167+ void DoAutoCompletion(Sci_Position nMinPrefixLength);
168+ BOOL LoadDictionaries(LONG lLanguageID);
169+ BOOL MarkEnteredBugID(Sci_Position startstylepos, Sci_Position endstylepos) const;
170+ bool StyleEnteredText(Sci_Position startStylePos, Sci_Position endStylePos) const;
171+ void StyleURLs(Sci_Position startStylePos, Sci_Position endStylePos) const;
172+ bool WrapLines(Sci_Position startpos, Sci_Position endpos) const;
173+ static bool FindStyleChars(const char* line, char styler, Sci_Position& start, Sci_Position& end);
174+ static void AdvanceUTF8(const char* str, int& pos);
175+ BOOL CheckWordSpelling(const CString& sWord) const;
176+ BOOL IsMisspelled(const CString& sWord);
177+ DWORD GetStyleAt(Sci_Position pos) const { return static_cast<DWORD>(Call(SCI_GETSTYLEAT, pos)) & 0x1f; }
178+ static bool IsUrlOrEmail(const CStringA& sText);
179+ std::string GetWordForSpellChecker(const CString& sWord) const;
180+ CString GetWordFromSpellChecker(const std::string& sWordA) const;
179181
180182 afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
181183 afx_msg void OnContextMenu(CWnd* /*pWnd*/, CPoint /*point*/);
--- trunk/src/Utils/MiscUI/SplitterControl.cpp (revision 29188)
+++ trunk/src/Utils/MiscUI/SplitterControl.cpp (revision 29189)
@@ -1,6 +1,6 @@
11 // TortoiseSVN - a Windows shell extension for easy version control
22
3-// Copyright (C) 2003-2006, 2008-2013, 2017, 2020 - TortoiseSVN
3+// Copyright (C) 2003-2006, 2008-2013, 2017, 2020-2021 - TortoiseSVN
44 // Copyright (C) 2019-2020 - TortoiseGit
55
66 // This program is free software; you can redistribute it and/or
@@ -19,12 +19,12 @@
1919 //
2020 #include "stdafx.h"
2121 #include "SplitterControl.h"
22-#include "MyMemDC.h"
2322 #include "Theme.h"
2423
2524 #ifdef _DEBUG
26-#define new DEBUG_NEW
27-#undef THIS_FILE
25+// ReSharper disable once CppInconsistentNaming
26+# define new DEBUG_NEW
27+# undef THIS_FILE
2828 static char THIS_FILE[] = __FILE__;
2929 #endif
3030
@@ -33,24 +33,24 @@
3333
3434 // hCursor1 is for vertical one
3535 // and hCursor2 is for horizontal one
36-static HCURSOR SplitterControl_hCursor1 = NULL;
37-static HCURSOR SplitterControl_hCursor2 = NULL;
36+static HCURSOR splitterControl_hCursor1 = nullptr;
37+static HCURSOR splitterControl_hCursor2 = nullptr;
3838
3939 CSplitterControl::CSplitterControl()
4040 : m_bIsPressed(false)
41- , m_nMin(-1)
42- , m_nMax(-1)
43- , m_bMouseOverControl(false)
4441 , m_nType(0)
4542 , m_nX(0)
4643 , m_nY(0)
44+ , m_nMin(-1)
45+ , m_nMax(-1)
4746 , m_nSavePos(0)
47+ , m_bMouseOverControl(false)
4848 {
49- m_AnimVarHot = Animator::Instance().CreateAnimationVariable(0.0);
49+ m_animVarHot = Animator::Instance().CreateAnimationVariable(0.0);
5050
5151 // GDI+ initialization
5252 Gdiplus::GdiplusStartupInput input;
53- Gdiplus::GdiplusStartup(&m_gdiPlusToken, &input, NULL);
53+ Gdiplus::GdiplusStartup(&m_gdiPlusToken, &input, nullptr);
5454 }
5555
5656 CSplitterControl::~CSplitterControl()
@@ -59,7 +59,6 @@
5959 Gdiplus::GdiplusShutdown(m_gdiPlusToken);
6060 }
6161
62-
6362 BEGIN_MESSAGE_MAP(CSplitterControl, CStatic)
6463 ON_WM_PAINT()
6564 ON_WM_MOUSEMOVE()
@@ -73,16 +72,15 @@
7372 /////////////////////////////////////////////////////////////////////////////
7473 // CSplitterControl message handlers
7574
76-
7775 // Set style for splitter control
7876 // nStyle = SPS_VERTICAL or SPS_HORIZONTAL
7977 int CSplitterControl::SetSplitterStyle(int nStyle)
8078 {
81- int m_nOldStyle = m_nType;
82- m_nType = nStyle;
83- return m_nOldStyle;
79+ int nOldStyle = m_nType;
80+ m_nType = nStyle;
81+ return nOldStyle;
8482 }
85-int CSplitterControl::GetSplitterStyle()
83+int CSplitterControl::GetSplitterStyle() const
8684 {
8785 return m_nType;
8886 }
@@ -89,12 +87,12 @@
8987
9088 void CSplitterControl::OnPaint()
9189 {
92- CPaintDC dcreal(this); // device context for painting
90+ CPaintDC dcReal(this); // device context for painting
9391 {
9492 CRect rcClient;
9593 GetClientRect(rcClient);
96- Gdiplus::Rect rc(rcClient.left, rcClient.top, rcClient.Width(), rcClient.Height());
97- Gdiplus::Graphics g(dcreal);
94+ Gdiplus::Rect rc(rcClient.left, rcClient.top, rcClient.Width(), rcClient.Height());
95+ Gdiplus::Graphics g(dcReal);
9896
9997 Gdiplus::Color c1;
10098 c1.SetFromCOLORREF(CTheme::Instance().GetThemeColor(GetSysColor(COLOR_3DFACE)));
@@ -105,20 +103,20 @@
105103 g.FillRectangle(&bkgBrush, rc);
106104
107105 // m_AnimVarHot changes from 0.0 (not hot) to 1.0 (hot)
108- auto alpha = Animator::GetValue(m_AnimVarHot);
109- c1.SetValue(Gdiplus::Color::MakeARGB(BYTE(alpha*255.0), c1.GetRed(), c1.GetBlue(), c1.GetGreen()));
110- c2.SetValue(Gdiplus::Color::MakeARGB(BYTE(alpha*255.0), c2.GetRed(), c2.GetBlue(), c2.GetGreen()));
106+ auto alpha = Animator::GetValue(m_animVarHot);
107+ c1.SetValue(Gdiplus::Color::MakeARGB(static_cast<BYTE>(alpha * 255.0), c1.GetRed(), c1.GetBlue(), c1.GetGreen()));
108+ c2.SetValue(Gdiplus::Color::MakeARGB(static_cast<BYTE>(alpha * 255.0), c2.GetRed(), c2.GetBlue(), c2.GetGreen()));
111109
112110 if (m_nType == SPS_VERTICAL)
113111 {
114- Gdiplus::LinearGradientBrush b1(Gdiplus::Point(rc.GetLeft(), rc.GetBottom()), Gdiplus::Point(rc.GetLeft() + rc.Width/2, rc.GetBottom()),
112+ Gdiplus::LinearGradientBrush b1(Gdiplus::Point(rc.GetLeft(), rc.GetBottom()), Gdiplus::Point(rc.GetLeft() + rc.Width / 2, rc.GetBottom()),
115113 c1, c2);
116114
117115 Gdiplus::LinearGradientBrush b2(Gdiplus::Point(rc.GetLeft() + rc.Width / 2, rc.GetBottom()), Gdiplus::Point(rc.GetRight(), rc.GetBottom()),
118116 c2, c1);
119117
120- g.FillRectangle(&b1, Gdiplus::Rect(rcClient.left, rcClient.top, rcClient.Width()/2, rcClient.Height()));
121- g.FillRectangle(&b2, Gdiplus::Rect(rcClient.left+rcClient.Width()/2, rcClient.top, rcClient.Width()/2, rcClient.Height()));
118+ g.FillRectangle(&b1, Gdiplus::Rect(rcClient.left, rcClient.top, rcClient.Width() / 2, rcClient.Height()));
119+ g.FillRectangle(&b2, Gdiplus::Rect(rcClient.left + rcClient.Width() / 2, rcClient.top, rcClient.Width() / 2, rcClient.Height()));
122120 }
123121 else
124122 {
@@ -132,7 +130,6 @@
132130 g.FillRectangle(&b2, Gdiplus::Rect(rcClient.left, rcClient.top, rcClient.Width(), rcClient.Height() / 2));
133131 }
134132
135-
136133 //dc.SetBkColor(GetSysColor(COLOR_3DFACE));
137134 //dc.ExtTextOut(0, 0, ETO_OPAQUE, &rcClient, NULL, 0, NULL);
138135
@@ -160,7 +157,7 @@
160157 {
161158 if (m_bIsPressed)
162159 {
163- CWnd * pParent = GetParent();
160+ CWnd* pParent = GetParent();
164161 {
165162 CPoint pt = point;
166163 ClientToScreen(&pt);
@@ -181,11 +178,11 @@
181178 m_nY = pt.y;
182179 }
183180 CPoint pt(m_nX, m_nY);
184- CWnd *pOwner = GetOwner();
181+ CWnd* pOwner = GetOwner();
185182 if (pOwner && IsWindow(pOwner->m_hWnd))
186183 {
187184 CRect rc;
188- int delta;
185+ int delta;
189186 pOwner->GetClientRect(rc);
190187 pOwner->ScreenToClient(&pt);
191188 MoveWindowTo(pt);
@@ -195,15 +192,14 @@
195192 else
196193 delta = m_nY - m_nSavePos;
197194
195+ SpcNMHDR nmsp;
198196
199- SPC_NMHDR nmsp;
200-
201197 nmsp.hdr.hwndFrom = m_hWnd;
202- nmsp.hdr.idFrom = GetDlgCtrlID();
203- nmsp.hdr.code = SPN_SIZED;
204- nmsp.delta = delta;
198+ nmsp.hdr.idFrom = GetDlgCtrlID();
199+ nmsp.hdr.code = SPN_SIZED;
200+ nmsp.delta = delta;
205201
206- pOwner->SendMessage(WM_NOTIFY, nmsp.hdr.idFrom, (LPARAM)&nmsp);
202+ pOwner->SendMessage(WM_NOTIFY, nmsp.hdr.idFrom, reinterpret_cast<LPARAM>(&nmsp));
207203 if (m_nType == SPS_VERTICAL)
208204 m_nSavePos = m_nX;
209205 else
@@ -210,22 +206,21 @@
210206 m_nSavePos = m_nY;
211207 pOwner->Invalidate();
212208 }
213-
214209 }
215210 else if (!m_bMouseOverControl)
216211 {
217- TRACKMOUSEEVENT Tme;
218- Tme.cbSize = sizeof(TRACKMOUSEEVENT);
219- Tme.dwFlags = TME_LEAVE;
220- Tme.hwndTrack = m_hWnd;
221- TrackMouseEvent(&Tme);
212+ TRACKMOUSEEVENT tme;
213+ tme.cbSize = sizeof(TRACKMOUSEEVENT);
214+ tme.dwFlags = TME_LEAVE;
215+ tme.hwndTrack = m_hWnd;
216+ TrackMouseEvent(&tme);
222217
223218 m_bMouseOverControl = true;
224- auto transHot = Animator::Instance().CreateLinearTransition(0.3, 1.0);
225- auto storyBoard = Animator::Instance().CreateStoryBoard();
226- if (storyBoard && transHot && m_AnimVarHot)
219+ auto transHot = Animator::Instance().CreateLinearTransition(0.3, 1.0);
220+ auto storyBoard = Animator::Instance().CreateStoryBoard();
221+ if (storyBoard && transHot && m_animVarHot)
227222 {
228- storyBoard->AddTransition(m_AnimVarHot, transHot);
223+ storyBoard->AddTransition(m_animVarHot, transHot);
229224 Animator::Instance().RunStoryBoard(storyBoard, [this]() {
230225 if (!this->GetSafeHwnd())
231226 return;
@@ -240,11 +235,11 @@
240235 {
241236 if (m_bMouseOverControl)
242237 {
243- auto transHot = Animator::Instance().CreateLinearTransition(0.3, 0.0);
238+ auto transHot = Animator::Instance().CreateLinearTransition(0.3, 0.0);
244239 auto storyBoard = Animator::Instance().CreateStoryBoard();
245- if (storyBoard && transHot && m_AnimVarHot)
240+ if (storyBoard && transHot && m_animVarHot)
246241 {
247- storyBoard->AddTransition(m_AnimVarHot, transHot);
242+ storyBoard->AddTransition(m_animVarHot, transHot);
248243 Animator::Instance().RunStoryBoard(storyBoard, [this]() {
249244 if (!this->GetSafeHwnd())
250245 return;
@@ -260,8 +255,8 @@
260255 {
261256 if (nHitTest == HTCLIENT)
262257 {
263- (m_nType == SPS_VERTICAL)?(::SetCursor(SplitterControl_hCursor1))
264- :(::SetCursor(SplitterControl_hCursor2));
258+ (m_nType == SPS_VERTICAL) ? (::SetCursor(splitterControl_hCursor1))
259+ : (::SetCursor(splitterControl_hCursor2));
265260 return 0;
266261 }
267262 else
@@ -281,7 +276,7 @@
281276 m_nX = rcWnd.left + rcWnd.Width() / 2;
282277
283278 else
284- m_nY = rcWnd.top + rcWnd.Height() / 2;
279+ m_nY = rcWnd.top + rcWnd.Height() / 2;
285280
286281 if (m_nType == SPS_VERTICAL)
287282 m_nSavePos = m_nX;
@@ -300,8 +295,7 @@
300295 {
301296 CRect rc;
302297 GetWindowRect(rc);
303- CWnd* pParent;
304- pParent = GetParent();
298+ CWnd* pParent = GetParent();
305299 if (!pParent || !::IsWindow(pParent->m_hWnd))
306300 return;
307301
@@ -309,19 +303,19 @@
309303 if (m_nType == SPS_VERTICAL)
310304 {
311305 int nMidX = (rc.left + rc.right) / 2;
312- int dx = pt.x - nMidX;
306+ int dx = pt.x - nMidX;
313307 rc.OffsetRect(dx, 0);
314308 }
315309 else
316310 {
317311 int nMidY = (rc.top + rc.bottom) / 2;
318- int dy = pt.y - nMidY;
312+ int dy = pt.y - nMidY;
319313 rc.OffsetRect(0, dy);
320314 }
321315 MoveWindow(rc);
322316 }
323317
324-HDWP CSplitterControl::ChangeRect(HDWP hdwp, CWnd * pWnd, int dleft, int dtop, int dright, int dbottom)
318+HDWP CSplitterControl::ChangeRect(HDWP hdwp, CWnd* pWnd, int dleft, int dtop, int dright, int dbottom)
325319 {
326320 CWnd* pParent = pWnd->GetParent();
327321 if (pParent && ::IsWindow(pParent->m_hWnd))
@@ -372,23 +366,22 @@
372366 GetClientRect(rc);
373367
374368 // Determine default type base on it's size.
375- m_nType = (rc.Width() < rc.Height())?SPS_VERTICAL:SPS_HORIZONTAL;
369+ m_nType = (rc.Width() < rc.Height()) ? SPS_VERTICAL : SPS_HORIZONTAL;
376370
377- if (!SplitterControl_hCursor1)
371+ if (!splitterControl_hCursor1)
378372 {
379- SplitterControl_hCursor1 = AfxGetApp()->LoadStandardCursor(IDC_SIZEWE);
380- SplitterControl_hCursor2 = AfxGetApp()->LoadStandardCursor(IDC_SIZENS);
373+ splitterControl_hCursor1 = AfxGetApp()->LoadStandardCursor(IDC_SIZEWE);
374+ splitterControl_hCursor2 = AfxGetApp()->LoadStandardCursor(IDC_SIZENS);
381375 }
382376
383377 // force the splitter not to be splitted.
384378 SetRange(0, 0, -1);
385379
386-
387380 CStatic::PreSubclassWindow();
388381 }
389382
383+// ReSharper disable once CppMemberFunctionMayBeStatic
390384 BOOL CSplitterControl::OnEraseBkgnd(CDC* /*pDC*/)
391385 {
392386 return TRUE;
393387 }
394-
--- trunk/src/Utils/MiscUI/SplitterControl.h (revision 29188)
+++ trunk/src/Utils/MiscUI/SplitterControl.h (revision 29189)
@@ -1,6 +1,6 @@
1-// TortoiseSVN - a Windows shell extension for easy version control
1+// TortoiseSVN - a Windows shell extension for easy version control
22
3-// Copyright (C) 2003-2006. 2011, 2017 - TortoiseSVN
3+// Copyright (C) 2003-2006. 2011, 2017, 2021 - TortoiseSVN
44
55 // This program is free software; you can redistribute it and/or
66 // modify it under the terms of the GNU General Public License
@@ -19,44 +19,39 @@
1919 #pragma once
2020 #include "AnimationManager.h"
2121
22-#pragma warning(push)
23-#pragma warning(disable: 4458) // declaration of 'xxx' hides class member
24-#include <gdiplus.h>
25-#pragma warning(pop)
26-
2722 /////////////////////////////////////////////////////////////////////////////
2823 // CSplitterControl window
2924
30-#define SPN_SIZED WM_USER + 1
31-#define CW_LEFTALIGN 1
32-#define CW_RIGHTALIGN 2
33-#define CW_TOPALIGN 3
25+#define SPN_SIZED WM_USER + 1
26+#define CW_LEFTALIGN 1
27+#define CW_RIGHTALIGN 2
28+#define CW_TOPALIGN 3
3429 #define CW_BOTTOMALIGN 4
35-#define SPS_VERTICAL 1
30+#define SPS_VERTICAL 1
3631 #define SPS_HORIZONTAL 2
37-typedef struct SPC_NMHDR
32+struct SpcNMHDR
3833 {
3934 NMHDR hdr;
40- int delta;
41-} SPC_NMHDR;
35+ int delta;
36+};
4237
4338 class CSplitterControl : public CStatic
4439 {
45-// Construction
40+ // Construction
4641 public:
4742 CSplitterControl();
48- virtual ~CSplitterControl();
43+ ~CSplitterControl() override;
4944
5045 static HDWP ChangeRect(HDWP hdwp, CWnd* pWnd, int dleft, int dtop, int dright, int dbottom);
5146 void SetRange(int nMin, int nMax);
5247 void SetRange(int nSubtraction, int nAddition, int nRoot);
5348
54- int GetSplitterStyle();
55- int SetSplitterStyle(int nStyle = SPS_VERTICAL);
49+ int GetSplitterStyle() const;
50+ int SetSplitterStyle(int nStyle = SPS_VERTICAL);
5651
5752 protected:
5853 void MoveWindowTo(CPoint pt);
59- virtual void PreSubclassWindow();
54+ void PreSubclassWindow() override;
6055 afx_msg void OnPaint();
6156 afx_msg void OnMouseMove(UINT nFlags, CPoint point);
6257 afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
@@ -67,12 +62,12 @@
6762 DECLARE_MESSAGE_MAP()
6863
6964 private:
70- bool m_bIsPressed;
71- int m_nType;
72- int m_nX, m_nY;
73- int m_nMin, m_nMax;
74- int m_nSavePos;
75- bool m_bMouseOverControl;
76- ULONG_PTR m_gdiPlusToken;
77- IUIAnimationVariablePtr m_AnimVarHot;
65+ bool m_bIsPressed;
66+ int m_nType;
67+ int m_nX, m_nY;
68+ int m_nMin, m_nMax;
69+ int m_nSavePos;
70+ bool m_bMouseOverControl;
71+ ULONG_PTR m_gdiPlusToken;
72+ IUIAnimationVariablePtr m_animVarHot;
7873 };
--- trunk/src/Utils/MiscUI/StandAloneDlg.cpp (revision 29188)
+++ trunk/src/Utils/MiscUI/StandAloneDlg.cpp (revision 29189)
@@ -19,7 +19,6 @@
1919 #include "stdafx.h"
2020 #include "resource.h"
2121 #include "StandAloneDlg.h"
22-#include "Monitor.h"
2322
2423 #pragma comment(lib, "Dwmapi.lib")
2524
@@ -336,7 +335,7 @@
336335 {
337336 CWnd* pOkBtn = GetDlgItem(IDOK);
338337 #ifdef ID_OK
339- if (pOkBtn == NULL)
338+ if (pOkBtn == nullptr)
340339 pOkBtn = GetDlgItem(ID_OK);
341340 #endif
342341 if (pOkBtn && pOkBtn->IsWindowEnabled())
--- trunk/src/Utils/MiscUI/StandAloneDlg.h (revision 29188)
+++ trunk/src/Utils/MiscUI/StandAloneDlg.h (revision 29189)
@@ -77,7 +77,7 @@
7777
7878 SetBackgroundIcon(IDI_AEROBACKGROUND, 256, 256);
7979 }
80- ~CStandAloneDialogTmpl()
80+ ~CStandAloneDialogTmpl() override
8181 {
8282 CTheme::Instance().RemoveRegisteredCallback(m_themeCallbackId);
8383 if (m_hBkgndIcon)
@@ -105,9 +105,9 @@
105105 m_tooltips.Create(this);
106106 SetTheme(CTheme::Instance().IsDarkTheme());
107107
108- auto CustomBreak = static_cast<DWORD>(CRegDWORD(L"Software\\TortoiseSVN\\UseCustomWordBreak", 2));
109- if (CustomBreak)
110- SetUrlWordBreakProcToChildWindows(GetSafeHwnd(), CustomBreak == 2);
108+ auto customBreak = static_cast<DWORD>(CRegDWORD(L"Software\\TortoiseSVN\\UseCustomWordBreak", 2));
109+ if (customBreak)
110+ SetUrlWordBreakProcToChildWindows(GetSafeHwnd(), customBreak == 2);
111111
112112 m_dpi = CDPIAware::Instance().GetDPI(GetSafeHwnd());
113113
--- trunk/src/Utils/MiscUI/SubTooltipListCtrl.cpp (revision 29188)
+++ trunk/src/Utils/MiscUI/SubTooltipListCtrl.cpp (revision 29189)
@@ -1,6 +1,6 @@
1-// TortoiseSVN - a Windows shell extension for easy version control
1+// TortoiseSVN - a Windows shell extension for easy version control
22
3-// Copyright (C) 2003-2008, 2011-2012, 2014, 2017 - TortoiseSVN
3+// Copyright (C) 2003-2008, 2011-2012, 2014, 2017, 2021 - TortoiseSVN
44
55 // This program is free software; you can redistribute it and/or
66 // modify it under the terms of the GNU General Public License
@@ -28,8 +28,9 @@
2828
2929 IMPLEMENT_DYNAMIC(CSubTooltipListCtrl, CListCtrl)
3030
31-CSubTooltipListCtrl::CSubTooltipListCtrl() : CListCtrl()
32- , pProvider(NULL)
31+CSubTooltipListCtrl::CSubTooltipListCtrl()
32+ : CListCtrl()
33+ , pProvider(nullptr)
3334 {
3435 }
3536
@@ -37,14 +38,14 @@
3738 {
3839 }
3940
40-INT_PTR CSubTooltipListCtrl::OnToolHitTest(CPoint point, TOOLINFO * pTI) const
41+INT_PTR CSubTooltipListCtrl::OnToolHitTest(CPoint point, TOOLINFO* pTi) const
4142 {
42- if (pProvider == NULL)
43+ if (pProvider == nullptr)
4344 return -1;
4445
4546 LVHITTESTINFO lvhitTestInfo;
4647
47- lvhitTestInfo.pt = point;
48+ lvhitTestInfo.pt = point;
4849
4950 int nItem = ListView_SubItemHitTest(
5051 this->m_hWnd,
@@ -51,7 +52,7 @@
5152 &lvhitTestInfo);
5253 int nSubItem = lvhitTestInfo.iSubItem;
5354
54- UINT nFlags = lvhitTestInfo.flags;
55+ UINT nFlags = lvhitTestInfo.flags;
5556
5657 //nFlags is 0 if the SubItemHitTest fails
5758 //Therefore, 0 & <anything> will equal false
@@ -63,15 +64,15 @@
6364
6465 //Get the client (area occupied by this control
6566 RECT rcClient;
66- GetClientRect( &rcClient );
67+ GetClientRect(&rcClient);
6768
6869 //Fill in the TOOLINFO structure
69- pTI->hwnd = m_hWnd;
70- pTI->uId = (UINT_PTR)((UINT_PTR(nItem)<<10)+(UINT_PTR(nSubItem)&0x3ff)+1);
71- pTI->lpszText = LPSTR_TEXTCALLBACK;
72- pTI->rect = rcClient;
70+ pTi->hwnd = m_hWnd;
71+ pTi->uId = static_cast<UINT_PTR>((static_cast<UINT_PTR>(nItem) << 10) + (static_cast<UINT_PTR>(nSubItem) & 0x3ff) + 1);
72+ pTi->lpszText = LPSTR_TEXTCALLBACK;
73+ pTi->rect = rcClient;
7374
74- return pTI->uId; //By returning a unique value per listItem,
75+ return pTi->uId; //By returning a unique value per listItem,
7576 //we ensure that when the mouse moves over another list item,
7677 //the tooltip will change
7778 }
@@ -82,18 +83,18 @@
8283 }
8384 }
8485
85-BOOL CSubTooltipListCtrl::OnToolTipText(UINT /*id*/, NMHDR * pNMHDR, LRESULT * pResult)
86+BOOL CSubTooltipListCtrl::OnToolTipText(UINT /*id*/, NMHDR* pNMHDR, LRESULT* pResult)
8687 {
87- if (pProvider == NULL)
88+ if (pProvider == nullptr)
8889 return FALSE;
8990
90- TOOLTIPTEXTA* pTTTA = (TOOLTIPTEXTA*)pNMHDR;
91- TOOLTIPTEXTW* pTTTW = (TOOLTIPTEXTW*)pNMHDR;
91+ TOOLTIPTEXTA* pTTTA = reinterpret_cast<NMTTDISPINFOA*>(pNMHDR);
92+ TOOLTIPTEXTW* pTTTW = reinterpret_cast<NMTTDISPINFOW*>(pNMHDR);
9293
9394 // Ignore messages from the built in tooltip, we are processing them internally
94- if( (pNMHDR->idFrom == (UINT_PTR)m_hWnd) &&
95- ( ((pNMHDR->code == TTN_NEEDTEXTA) && (pTTTA->uFlags & TTF_IDISHWND)) ||
96- ((pNMHDR->code == TTN_NEEDTEXTW) && (pTTTW->uFlags & TTF_IDISHWND)) ) )
95+ if ((pNMHDR->idFrom == reinterpret_cast<UINT_PTR>(m_hWnd)) &&
96+ (((pNMHDR->code == TTN_NEEDTEXTA) && (pTTTA->uFlags & TTF_IDISHWND)) ||
97+ ((pNMHDR->code == TTN_NEEDTEXTW) && (pTTTW->uFlags & TTF_IDISHWND))))
9798 {
9899 return FALSE;
99100 }
@@ -131,7 +132,7 @@
131132 else
132133 StringCchCopy(pTTTW->szText, _countof(pTTTW->szText), strTipText);
133134 #endif
134- return TRUE; //We found a tool tip,
135+ return TRUE; //We found a tool tip,
135136 //tell the framework this message has been handled
136137 }
137138
--- trunk/src/Utils/MiscUI/SubTooltipListCtrl.h (revision 29188)
+++ trunk/src/Utils/MiscUI/SubTooltipListCtrl.h (revision 29189)
@@ -1,6 +1,6 @@
1-// TortoiseSVN - a Windows shell extension for easy version control
1+// TortoiseSVN - a Windows shell extension for easy version control
22
3-// Copyright (C) 2003-2008, 2011 - TortoiseSVN
3+// Copyright (C) 2003-2008, 2011, 2021 - TortoiseSVN
44
55 // This program is free software; you can redistribute it and/or
66 // modify it under the terms of the GNU General Public License
@@ -21,6 +21,7 @@
2121 class IListCtrlTooltipProvider
2222 {
2323 public:
24+ virtual ~IListCtrlTooltipProvider() = default;
2425 virtual CString GetToolTipText(int nItem, int nSubItem) = 0;
2526 };
2627
@@ -32,17 +33,17 @@
3233 {
3334 public:
3435 CSubTooltipListCtrl();
35- ~CSubTooltipListCtrl();
36+ ~CSubTooltipListCtrl() override;
3637
37- void SetTooltipProvider(IListCtrlTooltipProvider * provider) {pProvider = provider;}
38+ void SetTooltipProvider(IListCtrlTooltipProvider* provider) { pProvider = provider; }
3839
3940 DECLARE_DYNAMIC(CSubTooltipListCtrl)
4041
4142 protected:
4243 DECLARE_MESSAGE_MAP()
43- virtual afx_msg BOOL OnToolTipText(UINT id, NMHDR * pNMHDR, LRESULT * pResult);
44- virtual INT_PTR OnToolHitTest(CPoint point, TOOLINFO * pTI) const;
44+ virtual afx_msg BOOL OnToolTipText(UINT id, NMHDR* pNMHDR, LRESULT* pResult);
45+ INT_PTR OnToolHitTest(CPoint point, TOOLINFO* pTi) const override;
4546
4647 private:
47- IListCtrlTooltipProvider * pProvider;
48+ IListCtrlTooltipProvider* pProvider;
4849 };
--- trunk/src/Utils/SmartHandle.h (revision 29188)
+++ trunk/src/Utils/SmartHandle.h (revision 29189)
@@ -1,6 +1,6 @@
11 // TortoiseSVN - a Windows shell extension for easy version control
22
3-// Copyright (C) 2011, 2015, 2017 - TortoiseSVN
3+// Copyright (C) 2011, 2015, 2017, 2021 - TortoiseSVN
44 // Copyright (C) 2015, 2019-2020 - TortoiseGit
55
66 // This program is free software; you can redistribute it and/or
@@ -20,10 +20,10 @@
2020 #pragma once
2121 #include <Uxtheme.h>
2222
23-template <typename type>
23+template <typename Type>
2424 struct CDefaultHandleNull
2525 {
26- static constexpr type DefaultHandle()
26+ static constexpr Type DefaultHandle()
2727 {
2828 return nullptr;
2929 }
@@ -42,13 +42,13 @@
4242 * Helper classes for handles.
4343 */
4444 template <typename HandleType,
45- template <class> class CloseFunction,
46- typename NullType = CDefaultHandleNull<HandleType>>
45+ template <class> class CloseFunction,
46+ typename NullType = CDefaultHandleNull<HandleType>>
4747 class CSmartHandle
4848 {
4949 public:
5050 CSmartHandle()
51- : m_Handle(NullType::DefaultHandle())
51+ : m_handle(NullType::DefaultHandle())
5252 {
5353 }
5454
@@ -56,36 +56,36 @@
5656 // Handles must be copied only using DuplicateHandle(). But we leave
5757 // that to an explicit call.
5858 // See compiler tests at the bottom
59- CSmartHandle(const HandleType& h) = delete;
59+ CSmartHandle(const HandleType& h) = delete;
6060 CSmartHandle(const CSmartHandle& h) = delete;
61- HandleType& operator=(const HandleType& h) = delete;
61+ HandleType& operator=(const HandleType& h) = delete;
6262 CSmartHandle& operator=(const CSmartHandle& h) = delete;
6363
64- CSmartHandle(HandleType && h)
64+ CSmartHandle(HandleType&& h)
6565 {
66- m_Handle = h;
66+ m_handle = h;
6767 }
6868
69- CSmartHandle(CSmartHandle && h)
69+ CSmartHandle(CSmartHandle&& h)
7070 {
71- m_Handle = h.Detach();
71+ m_handle = h.Detach();
7272 }
7373
74- CSmartHandle& operator=(CSmartHandle && h)
74+ CSmartHandle& operator=(CSmartHandle&& h)
7575 {
7676 *this = h.Detach();
7777 return *this;
7878 }
7979
80- HandleType& operator=(HandleType && h)
80+ HandleType& operator=(HandleType&& h)
8181 {
82- if (m_Handle != h)
82+ if (m_handle != h)
8383 {
8484 CleanUp();
85- m_Handle = h;
85+ m_handle = h;
8686 }
8787
88- return m_Handle;
88+ return m_handle;
8989 }
9090
9191 bool CloseHandle()
@@ -95,8 +95,8 @@
9595
9696 HandleType Detach()
9797 {
98- HandleType p = m_Handle;
99- m_Handle = NullType::DefaultHandle();
98+ HandleType p = m_handle;
99+ m_handle = NullType::DefaultHandle();
100100
101101 return p;
102102 }
@@ -103,12 +103,12 @@
103103
104104 operator HandleType() const
105105 {
106- return m_Handle;
106+ return m_handle;
107107 }
108108
109- HandleType * GetPointer()
109+ HandleType* GetPointer()
110110 {
111- return &m_Handle;
111+ return &m_handle;
112112 }
113113
114114 operator bool() const
@@ -118,7 +118,7 @@
118118
119119 bool IsValid() const
120120 {
121- return m_Handle != NullType::DefaultHandle();
121+ return m_handle != NullType::DefaultHandle();
122122 }
123123
124124 HandleType Duplicate() const
@@ -125,7 +125,7 @@
125125 {
126126 HandleType hDup = NullType::DefaultHandle();
127127 if (DuplicateHandle(GetCurrentProcess(),
128- (HANDLE)m_Handle,
128+ static_cast<HANDLE>(m_handle),
129129 GetCurrentProcess(),
130130 &hDup,
131131 0,
@@ -142,21 +142,19 @@
142142 CleanUp();
143143 }
144144
145-
146145 protected:
147146 bool CleanUp()
148147 {
149- if (m_Handle != NullType::DefaultHandle())
148+ if (m_handle != NullType::DefaultHandle())
150149 {
151- const bool b = CloseFunction<HandleType>::Close(m_Handle);
152- m_Handle = NullType::DefaultHandle();
150+ const bool b = CloseFunction<HandleType>::Close(m_handle);
151+ m_handle = NullType::DefaultHandle();
153152 return b;
154153 }
155154 return false;
156155 }
157156
158-
159- HandleType m_Handle;
157+ HandleType m_handle;
160158 };
161159
162160 template <typename T>
@@ -168,8 +166,6 @@
168166 }
169167 };
170168
171-
172-
173169 template <typename T>
174170 struct CCloseRegKey
175171 {
@@ -179,7 +175,6 @@
179175 }
180176 };
181177
182-
183178 template <typename T>
184179 struct CCloseLibrary
185180 {
@@ -189,7 +184,6 @@
189184 }
190185 };
191186
192-
193187 template <typename T>
194188 struct CCloseViewOfFile
195189 {
@@ -227,14 +221,14 @@
227221 };
228222
229223 // Client code (definitions of standard Windows handles).
230-typedef CSmartHandle<HANDLE, CCloseHandle> CAutoGeneralHandle;
231-typedef CSmartHandle<HKEY, CCloseRegKey> CAutoRegKey;
232-typedef CSmartHandle<PVOID, CCloseViewOfFile> CAutoViewOfFile;
233-typedef CSmartHandle<HMODULE, CCloseLibrary> CAutoLibrary;
234-typedef CSmartHandle<HANDLE, CCloseHandle, CDefaultHandleInvalid> CAutoFile;
235-typedef CSmartHandle<HANDLE, CCloseFindFile, CDefaultHandleInvalid> CAutoFindFile;
236-typedef CSmartHandle<HTHEME, CCloseThemeData> CAutoThemeData;
237-typedef CSmartHandle<HICON, CCloseIcon> CAutoIcon;
224+typedef CSmartHandle<HANDLE, CCloseHandle> CAutoGeneralHandle;
225+typedef CSmartHandle<HKEY, CCloseRegKey> CAutoRegKey;
226+typedef CSmartHandle<PVOID, CCloseViewOfFile> CAutoViewOfFile;
227+typedef CSmartHandle<HMODULE, CCloseLibrary> CAutoLibrary;
228+typedef CSmartHandle<HANDLE, CCloseHandle, CDefaultHandleInvalid> CAutoFile;
229+typedef CSmartHandle<HANDLE, CCloseFindFile, CDefaultHandleInvalid> CAutoFindFile;
230+typedef CSmartHandle<HTHEME, CCloseThemeData> CAutoThemeData;
231+typedef CSmartHandle<HICON, CCloseIcon> CAutoIcon;
238232
239233 /*
240234 void CompilerTests()
Show on old repository browser