From 797765173dd7d0ebc8c4c46ef8348782575a5222 Mon Sep 17 00:00:00 2001 From: Don HO Date: Mon, 18 Jul 2016 02:08:29 +0200 Subject: [PATCH] Improve code quality by using static code analysis tool (cppchecker) --- .../src/MISC/Exception/Win32Exception.h | 4 +- .../MISC/Process/ProcessAvecThread/Process.h | 16 ++---- PowerEditor/src/MISC/RegExt/regExtDlg.cpp | 4 +- PowerEditor/src/Notepad_plus.cpp | 10 +--- PowerEditor/src/Notepad_plus_Window.cpp | 2 +- PowerEditor/src/NppBigSwitch.cpp | 26 ++++----- PowerEditor/src/NppCommands.cpp | 11 ++-- PowerEditor/src/NppNotification.cpp | 2 +- PowerEditor/src/Parameters.cpp | 4 +- PowerEditor/src/Parameters.h | 32 +---------- .../src/ScitillaComponent/AutoCompletion.h | 28 +++------- PowerEditor/src/ScitillaComponent/Buffer.cpp | 2 +- .../src/ScitillaComponent/FindReplaceDlg.cpp | 7 +-- .../src/ScitillaComponent/FindReplaceDlg.h | 37 +++++------- .../src/ScitillaComponent/FunctionCallTip.h | 39 ++++++------- .../src/ScitillaComponent/GoToLineDlg.h | 17 ++---- PowerEditor/src/ScitillaComponent/Printer.h | 8 +-- .../ScitillaComponent/ScintillaEditView.cpp | 1 - .../src/ScitillaComponent/ScintillaEditView.h | 56 +++++-------------- .../src/ScitillaComponent/SmartHighlighter.h | 2 +- .../ScitillaComponent/UserDefineDialog.cpp | 4 +- .../src/ScitillaComponent/UserDefineDialog.h | 36 +++++------- .../src/ScitillaComponent/columnEditor.h | 2 +- .../xmlMatchedTagsHighlighter.h | 2 +- .../src/WinControls/AnsiCharPanel/ListView.h | 2 +- .../WinControls/AnsiCharPanel/ansiCharPanel.h | 2 +- .../clipboardHistoryPanel.cpp | 4 +- .../ClipboardHistory/clipboardHistoryPanel.h | 2 +- .../WinControls/ColourPicker/ColourPicker.cpp | 1 - .../WinControls/ColourPicker/ColourPopup.cpp | 15 +++-- .../WinControls/ColourPicker/WordStyleDlg.cpp | 6 +- .../WinControls/ColourPicker/WordStyleDlg.h | 20 +++---- .../src/WinControls/DockingWnd/Docking.h | 5 +- .../WinControls/DockingWnd/DockingCont.cpp | 4 +- .../src/WinControls/DockingWnd/DockingCont.h | 13 +---- .../DockingWnd/DockingDlgInterface.h | 27 +++------ .../WinControls/DockingWnd/DockingManager.cpp | 6 +- .../WinControls/DockingWnd/DockingManager.h | 29 +++------- .../src/WinControls/DockingWnd/Gripper.cpp | 3 +- .../src/WinControls/DocumentMap/documentMap.h | 23 +++----- .../FindCharsInRange/FindCharsInRange.h | 2 +- .../FunctionList/functionListPanel.cpp | 9 +-- .../WinControls/FunctionList/functionParser.h | 7 +-- .../src/WinControls/Grid/ShortcutMapper.cpp | 8 +-- .../src/WinControls/Grid/ShortcutMapper.h | 19 +------ .../WinControls/ImageListSet/ImageListSet.h | 16 +++--- .../WinControls/Preference/preferenceDlg.cpp | 9 +-- .../WinControls/ProjectPanel/ProjectPanel.cpp | 4 +- .../ReadDirectoryChangesPrivate.h | 2 +- .../WinControls/StaticDialog/RunDlg/RunDlg.h | 4 +- .../src/WinControls/TabBar/ControlsTab.h | 11 +--- PowerEditor/src/WinControls/TabBar/TabBar.h | 56 ++++++++----------- .../src/WinControls/TaskList/TaskList.h | 10 ++-- .../src/WinControls/TaskList/TaskListDlg.cpp | 4 +- .../src/WinControls/TaskList/TaskListDlg.h | 34 +++-------- .../src/WinControls/ToolBar/ToolBar.cpp | 22 +++++--- PowerEditor/src/WinControls/ToolBar/ToolBar.h | 21 ++++--- .../src/WinControls/WindowsDlg/SizeableDlg.h | 2 +- .../src/WinControls/WindowsDlg/WinMgr.h | 2 +- .../src/WinControls/WindowsDlg/WindowsDlg.cpp | 4 +- .../src/WinControls/WindowsDlg/WindowsDlg.h | 18 +++--- .../src/WinControls/shortcut/RunMacroDlg.h | 16 ++---- .../src/WinControls/shortcut/shortcut.cpp | 2 +- .../src/WinControls/shortcut/shortcut.h | 27 +++------ PowerEditor/src/lastRecentFileList.h | 31 +++++----- PowerEditor/src/lesDlgs.cpp | 4 +- 66 files changed, 308 insertions(+), 550 deletions(-) diff --git a/PowerEditor/src/MISC/Exception/Win32Exception.h b/PowerEditor/src/MISC/Exception/Win32Exception.h index 2b16a77c..0efa0ee0 100644 --- a/PowerEditor/src/MISC/Exception/Win32Exception.h +++ b/PowerEditor/src/MISC/Exception/Win32Exception.h @@ -50,7 +50,7 @@ public: EXCEPTION_POINTERS* info() const { return _info; } protected: - Win32Exception(EXCEPTION_POINTERS * info); //Constructor only accessible by exception handler + explicit Win32Exception(EXCEPTION_POINTERS * info); //Constructor only accessible by exception handler static void translate(unsigned code, EXCEPTION_POINTERS * info); private: @@ -68,7 +68,7 @@ public: bool isWrite() const { return _isWrite; } ExceptionAddress badAddress() const { return _badAddress; } private: - Win32AccessViolation(EXCEPTION_POINTERS * info); + explicit Win32AccessViolation(EXCEPTION_POINTERS * info); bool _isWrite; ExceptionAddress _badAddress; diff --git a/PowerEditor/src/MISC/Process/ProcessAvecThread/Process.h b/PowerEditor/src/MISC/Process/ProcessAvecThread/Process.h index 2d163780..d4f8c6d2 100644 --- a/PowerEditor/src/MISC/Process/ProcessAvecThread/Process.h +++ b/PowerEditor/src/MISC/Process/ProcessAvecThread/Process.h @@ -26,8 +26,7 @@ // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -#ifndef PROCESSUS_H -#define PROCESSUS_H +#pragma once #include //#include @@ -38,8 +37,6 @@ class Process public: Process() {} Process(const TCHAR *cmd, const TCHAR *cDir) - : _stdoutStr(TEXT("")), _stderrStr(TEXT("")), _hPipeOutR(NULL), - _hPipeErrR(NULL), _hProcess(NULL), _hProcessThread(NULL) { lstrcpy(_command, cmd); lstrcpy(_curDir, cDir); @@ -75,13 +72,13 @@ protected: // LES SORTIES generic_string _stdoutStr; generic_string _stderrStr; - int _exitCode; + int _exitCode = 0; // LES HANDLES - HANDLE _hPipeOutR; - HANDLE _hPipeErrR; - HANDLE _hProcess; - HANDLE _hProcessThread; + HANDLE _hPipeOutR = nullptr; + HANDLE _hPipeErrR = nullptr; + HANDLE _hProcess = nullptr; + HANDLE _hProcessThread = nullptr; //UINT _pid; // process ID assigned by caller @@ -98,5 +95,4 @@ protected: void error(const TCHAR *txt2display, BOOL & returnCode, int errCode); }; -#endif //PROCESSUS_H diff --git a/PowerEditor/src/MISC/RegExt/regExtDlg.cpp b/PowerEditor/src/MISC/RegExt/regExtDlg.cpp index 7cd0d66f..e02c2178 100644 --- a/PowerEditor/src/MISC/RegExt/regExtDlg.cpp +++ b/PowerEditor/src/MISC/RegExt/regExtDlg.cpp @@ -88,11 +88,11 @@ void RegExtDlg::doDialog(bool isRTL) { DLGTEMPLATE *pMyDlgTemplate = nullptr; HGLOBAL hMyDlgTemplate = makeRTLResource(IDD_REGEXT_BOX, &pMyDlgTemplate); - ::DialogBoxIndirectParam(_hInst, pMyDlgTemplate, _hParent, dlgProc, (LPARAM)this); + ::DialogBoxIndirectParam(_hInst, pMyDlgTemplate, _hParent, dlgProc, reinterpret_cast(this)); ::GlobalFree(hMyDlgTemplate); } else - ::DialogBoxParam(_hInst, MAKEINTRESOURCE(IDD_REGEXT_BOX), _hParent, dlgProc, (LPARAM)this); + ::DialogBoxParam(_hInst, MAKEINTRESOURCE(IDD_REGEXT_BOX), _hParent, dlgProc, reinterpret_cast(this)); } diff --git a/PowerEditor/src/Notepad_plus.cpp b/PowerEditor/src/Notepad_plus.cpp index 11e7bf0d..6e8e025e 100644 --- a/PowerEditor/src/Notepad_plus.cpp +++ b/PowerEditor/src/Notepad_plus.cpp @@ -1120,11 +1120,9 @@ void Notepad_plus::wsTabConvert(spaceTab whichWay) int count = 0; int column = 0; - int counter = 0; int newCurrentPos = 0; int tabStop = static_cast(tabWidth - 1); // remember, counting from zero ! bool onlyLeading = false; - bool nonSpaceFound = false; vector bookmarks; vector folding; @@ -1206,6 +1204,8 @@ void Notepad_plus::wsTabConvert(spaceTab whichWay) case space2TabAll: { bool nextChar = false; + int counter = 0; + bool nonSpaceFound = false; for (int i=0; source[i] != '\0'; ++i) { if (nonSpaceFound == false) @@ -2855,7 +2855,7 @@ void Notepad_plus::activateDoc(size_t pos) return; } - if (pos >= 0 && pos < nbDoc) + if (pos < nbDoc) { BufferID id = _pDocTab->getBufferByIndex(pos); activateBuffer(id, currentView()); @@ -6367,14 +6367,12 @@ bool Notepad_plus::undoStreamComment() //-- Check, if selectionStart or selectionEnd is within a stream comment ----- // or if the selection includes a complete stream-comment!! ---------------- - bool blnCommentFound = false; //-- First, check if there is a stream-comment around the selectionStart position: if ((blnStartCommentBefore[iSelStart] && blnEndCommentAfter[iSelStart]) && (!blnEndCommentBefore[iSelStart] || (posStartCommentBefore[iSelStart] >= posEndCommentBefore[iSelStart])) && (!blnStartCommentAfter[iSelStart] || (posEndCommentAfter[iSelStart] <= posStartCommentAfter[iSelStart]))) { - blnCommentFound = true; posStartComment = posStartCommentBefore[iSelStart]; posEndComment = posEndCommentAfter[iSelStart]; } @@ -6396,7 +6394,6 @@ bool Notepad_plus::undoStreamComment() && (!blnEndCommentBefore[iSelEnd] || (posStartCommentBefore[iSelEnd] >= posEndCommentBefore[iSelEnd])) && (!blnStartCommentAfter[iSelEnd] || (posEndCommentAfter[iSelEnd] <= posStartCommentAfter[iSelEnd]))) { - blnCommentFound = true; posStartComment = posStartCommentBefore[iSelEnd]; posEndComment = posEndCommentAfter[iSelEnd]; } @@ -6405,7 +6402,6 @@ bool Notepad_plus::undoStreamComment() && (blnEndCommentBefore[iSelEnd] && (posEndCommentBefore[iSelEnd] > selectionStart))) { //-- If there are more than one stream-comment within the selection, take the first one after selectionStart!! - blnCommentFound = true; posStartComment = posStartCommentAfter[iSelStart]; posEndComment = posEndCommentAfter[iSelStart]; } diff --git a/PowerEditor/src/Notepad_plus_Window.cpp b/PowerEditor/src/Notepad_plus_Window.cpp index 300cb700..166d06a2 100644 --- a/PowerEditor/src/Notepad_plus_Window.cpp +++ b/PowerEditor/src/Notepad_plus_Window.cpp @@ -40,7 +40,7 @@ namespace // anonymous struct PaintLocker final { - PaintLocker(HWND handle) + explicit PaintLocker(HWND handle) : handle(handle) { // disallow drawing on the window diff --git a/PowerEditor/src/NppBigSwitch.cpp b/PowerEditor/src/NppBigSwitch.cpp index 3ea53a62..3ce33a7d 100644 --- a/PowerEditor/src/NppBigSwitch.cpp +++ b/PowerEditor/src/NppBigSwitch.cpp @@ -574,7 +574,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa if (HIWORD(wParam) == SCEN_SETFOCUS) { HWND hMain = _mainEditView.getHSelf(), hSec = _subEditView.getHSelf(); - HWND hFocus = (HWND)lParam; + HWND hFocus = reinterpret_cast(lParam); if (hMain == hFocus) switchEditViewTo(MAIN_VIEW); else if (hSec == hFocus) @@ -1142,12 +1142,12 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa case NPPM_CREATESCINTILLAHANDLE: { - return (LRESULT)_scintillaCtrls4Plugins.createSintilla((lParam == NULL?hwnd:(HWND)lParam)); + return (LRESULT)_scintillaCtrls4Plugins.createSintilla((lParam == NULL?hwnd:reinterpret_cast(lParam))); } case NPPM_INTERNAL_GETSCINTEDTVIEW: { - return (LRESULT)_scintillaCtrls4Plugins.getScintillaEditViewFrom((HWND)lParam); + return (LRESULT)_scintillaCtrls4Plugins.getScintillaEditViewFrom(reinterpret_cast(lParam)); } case NPPM_INTERNAL_ENABLESNAPSHOT: @@ -1158,7 +1158,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa case NPPM_DESTROYSCINTILLAHANDLE: { - return _scintillaCtrls4Plugins.destroyScintilla((HWND)lParam); + return _scintillaCtrls4Plugins.destroyScintilla(reinterpret_cast(lParam)); } case NPPM_GETNBUSERLANG: @@ -1328,11 +1328,11 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa { for (size_t i = 0, len = _hModelessDlgs.size() ; i < len ; ++i) { - if (_hModelessDlgs[i] == (HWND)lParam) + if (_hModelessDlgs[i] == reinterpret_cast(lParam)) return NULL; } - _hModelessDlgs.push_back((HWND)lParam); + _hModelessDlgs.push_back(reinterpret_cast(lParam)); return lParam; } else @@ -1341,7 +1341,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa { for (size_t i = 0, len = _hModelessDlgs.size(); i < len ; ++i) { - if (_hModelessDlgs[i] == (HWND)lParam) + if (_hModelessDlgs[i] == reinterpret_cast(lParam)) { vector::iterator hDlg = _hModelessDlgs.begin() + i; _hModelessDlgs.erase(hDlg); @@ -1791,20 +1791,20 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa case NPPM_DMMSHOW: { - _dockingManager.showDockableDlg((HWND)lParam, SW_SHOW); + _dockingManager.showDockableDlg(reinterpret_cast(lParam), SW_SHOW); return TRUE; } case NPPM_DMMHIDE: { - _dockingManager.showDockableDlg((HWND)lParam, SW_HIDE); + _dockingManager.showDockableDlg(reinterpret_cast(lParam), SW_HIDE); return TRUE; } case NPPM_DMMUPDATEDISPINFO: { - if (::IsWindowVisible((HWND)lParam)) - _dockingManager.updateContainerInfo((HWND)lParam); + if (::IsWindowVisible(reinterpret_cast(lParam))) + _dockingManager.updateContainerInfo(reinterpret_cast(lParam)); return TRUE; } @@ -2014,7 +2014,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa case NPPM_INTERNAL_ISFOCUSEDTAB: { HWND hTabToTest = (currentView() == MAIN_VIEW)?_mainDocTab.getHSelf():_subDocTab.getHSelf(); - return (HWND)lParam == hTabToTest; + return reinterpret_cast(lParam) == hTabToTest; } case NPPM_INTERNAL_GETMENU: @@ -2043,7 +2043,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa case NPPM_INTERNAL_SWITCHVIEWFROMHWND: { - HWND handle = (HWND)lParam; + HWND handle = reinterpret_cast(lParam); if (_mainEditView.getHSelf() == handle || _mainDocTab.getHSelf() == handle) { switchEditViewTo(MAIN_VIEW); diff --git a/PowerEditor/src/NppCommands.cpp b/PowerEditor/src/NppCommands.cpp index cd9221b6..b52bf2e5 100644 --- a/PowerEditor/src/NppCommands.cpp +++ b/PowerEditor/src/NppCommands.cpp @@ -1467,12 +1467,11 @@ void Notepad_plus::command(int id) TabBarPlus::setDrawTabCloseButton(!TabBarPlus::drawTabCloseButton()); // This part is just for updating (redraw) the tabs - { - int tabDpiDynamicalHeight = NppParameters::getInstance()->_dpiManager.scaleY(TabBarPlus::drawTabCloseButton()?22:22); - int tabDpiDynamicalWidth = NppParameters::getInstance()->_dpiManager.scaleX(TabBarPlus::drawTabCloseButton() ? 60:45); - TabCtrl_SetItemSize(_mainDocTab.getHSelf(), tabDpiDynamicalWidth, tabDpiDynamicalHeight); - TabCtrl_SetItemSize(_subDocTab.getHSelf(), tabDpiDynamicalWidth, tabDpiDynamicalHeight); - } + int tabDpiDynamicalHeight = NppParameters::getInstance()->_dpiManager.scaleY(TabBarPlus::drawTabCloseButton() ? 22 : 22); + int tabDpiDynamicalWidth = NppParameters::getInstance()->_dpiManager.scaleX(TabBarPlus::drawTabCloseButton() ? 60 : 45); + TabCtrl_SetItemSize(_mainDocTab.getHSelf(), tabDpiDynamicalWidth, tabDpiDynamicalHeight); + TabCtrl_SetItemSize(_subDocTab.getHSelf(), tabDpiDynamicalWidth, tabDpiDynamicalHeight); + ::SendMessage(_pPublicInterface->getHSelf(), WM_SIZE, 0, 0); break; } diff --git a/PowerEditor/src/NppNotification.cpp b/PowerEditor/src/NppNotification.cpp index cbb2b39a..2c596135 100644 --- a/PowerEditor/src/NppNotification.cpp +++ b/PowerEditor/src/NppNotification.cpp @@ -879,7 +879,7 @@ BOOL Notepad_plus::notify(SCNotification *notification) // This treatment would fail on some valid URLs where there's actually supposed to be a comma or parenthesis at the end. size_t lastCharIndex = _tcsnlen(currentWord, MAX_PATH*2) - 1; - if(lastCharIndex >= 0 && (currentWord[lastCharIndex] == ',' || currentWord[lastCharIndex] == ')' || currentWord[lastCharIndex] == '(')) + if ((currentWord[lastCharIndex] == ',' || currentWord[lastCharIndex] == ')' || currentWord[lastCharIndex] == '(')) currentWord[lastCharIndex] = '\0'; ::ShellExecute(_pPublicInterface->getHSelf(), TEXT("open"), currentWord, NULL, NULL, SW_SHOW); diff --git a/PowerEditor/src/Parameters.cpp b/PowerEditor/src/Parameters.cpp index f2f5eea8..89fc071c 100644 --- a/PowerEditor/src/Parameters.cpp +++ b/PowerEditor/src/Parameters.cpp @@ -5115,7 +5115,7 @@ bool NppParameters::writeGUIParams() } else if (!lstrcmp(nm, TEXT("UserDefineDlg"))) { - const TCHAR *pStr = _nppGUI._userDefineDlgStatus & UDD_SHOW?TEXT("show"):TEXT("hide"); + const TCHAR *pStr = (_nppGUI._userDefineDlgStatus & UDD_SHOW) ? TEXT("show") : TEXT("hide"); TiXmlNode *n = childNode->FirstChild(); if (n) n->SetValue(pStr); @@ -5639,7 +5639,6 @@ bool NppParameters::writeGUIParams() GUIConfigElement->SetAttribute(TEXT("triggerFromNbChar"), int32_t(_nppGUI._autocFromLen)); const TCHAR * pStr = _nppGUI._funcParams?TEXT("yes"):TEXT("no"); GUIConfigElement->SetAttribute(TEXT("funcParams"), pStr); - autocExist = true; } if (!autocInsetExist) @@ -5665,7 +5664,6 @@ bool NppParameters::writeGUIParams() (hist_element.ToElement())->SetAttribute(TEXT("close"), close); GUIConfigElement->InsertEndChild(hist_element); } - autocInsetExist = true; } if (dockingParamNode) diff --git a/PowerEditor/src/Parameters.h b/PowerEditor/src/Parameters.h index fad3bdb7..3d5e7cf3 100644 --- a/PowerEditor/src/Parameters.h +++ b/PowerEditor/src/Parameters.h @@ -26,46 +26,16 @@ // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. #pragma once -#ifndef TINYXMLA_INCLUDED #include "tinyxmlA.h" -#endif //TINYXMLA_INCLUDED - -#ifndef TINYXML_INCLUDED #include "tinyxml.h" -#endif //TINYXML_INCLUDED - -#ifndef SCINTILLA_H #include "Scintilla.h" -#endif //SCINTILLA_H - -#ifndef SCINTILLA_REF_H #include "ScintillaRef.h" -#endif //SCINTILLA_REF_H - -#ifndef TOOL_BAR_H #include "ToolBar.h" -#endif //TOOL_BAR_H - -#ifndef USER_DEFINE_LANG_REFERENCE_H #include "UserDefineLangReference.h" -#endif //USER_DEFINE_LANG_REFERENCE_H - -#ifndef COLORS_H #include "colors.h" -#endif //COLORS_H - -#ifndef SHORTCUTS_H #include "shortcut.h" -#endif //SHORTCUTS_H - -#ifndef CONTEXTMENU_H #include "ContextMenu.h" -#endif //CONTEXTMENU_H - -#ifndef DPIMANAGER_H #include "dpiManager.h" -#endif //DPIMANAGER_H - #include #include @@ -649,7 +619,7 @@ public: !(month == 11 && day > 30)); } - Date(const TCHAR *dateStr); + explicit Date(const TCHAR *dateStr); // The constructor which makes the date of number of days from now // nbDaysFromNow could be negative if user want to make a date in the past diff --git a/PowerEditor/src/ScitillaComponent/AutoCompletion.h b/PowerEditor/src/ScitillaComponent/AutoCompletion.h index a66a0a90..d0837fc7 100644 --- a/PowerEditor/src/ScitillaComponent/AutoCompletion.h +++ b/PowerEditor/src/ScitillaComponent/AutoCompletion.h @@ -26,16 +26,10 @@ // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -#ifndef AUTOCOMPLETION_H -#define AUTOCOMPLETION_H +#pragma once -#ifndef FUNCTIONCALLTIP_H #include "FunctionCallTip.h" -#endif// FUNCTIONCALLTIP_H - -#ifndef TINYXML_INCLUDED #include "tinyxml.h" -#endif// TINYXML_INCLUDED const size_t tagMaxLen = 256; @@ -64,9 +58,7 @@ class AutoCompletion { public: enum ActiveCompletion {CompletionNone = 0, CompletionAuto, CompletionWord, CompletionFunc, CompletionPath}; - AutoCompletion(ScintillaEditView * pEditView) : _funcCompletionActive(false), _pEditView(pEditView), _funcCalltip(pEditView), - _curLang(L_TEXT), _pXmlFile(NULL), _keyWordMaxLen(0), - _pXmlKeyword(NULL), _ignoreCase(true), _keyWords(TEXT("")) { + explicit AutoCompletion(ScintillaEditView * pEditView): _pEditView(pEditView), _funcCalltip(pEditView) { //Do not load any language yet _insertedMatchedChars.init(_pEditView); }; @@ -95,24 +87,22 @@ public: void getCloseTag(char *closeTag, size_t closeTagLen, size_t caretPos, LangType language); private: - bool _funcCompletionActive; - ScintillaEditView * _pEditView; - LangType _curLang; - TiXmlDocument *_pXmlFile; - TiXmlElement *_pXmlKeyword; + bool _funcCompletionActive = false; + ScintillaEditView * _pEditView = nullptr; + LangType _curLang = L_TEXT; + TiXmlDocument *_pXmlFile = nullptr; + TiXmlElement *_pXmlKeyword = nullptr; InsertedMatchedChars _insertedMatchedChars; - bool _ignoreCase; + bool _ignoreCase = true; std::vector _keyWordArray; generic_string _keyWords; - size_t _keyWordMaxLen; + size_t _keyWordMaxLen = 0; FunctionCallTip _funcCalltip; const TCHAR * getApiFileName(); void getWordArray(std::vector & wordArray, TCHAR *beginChars); }; - -#endif //AUTOCOMPLETION_H diff --git a/PowerEditor/src/ScitillaComponent/Buffer.cpp b/PowerEditor/src/ScitillaComponent/Buffer.cpp index f3c7ca64..bbd395c9 100644 --- a/PowerEditor/src/ScitillaComponent/Buffer.cpp +++ b/PowerEditor/src/ScitillaComponent/Buffer.cpp @@ -967,7 +967,7 @@ bool FileManager::backupCurrentBuffer() class EventReset final { public: - EventReset(HANDLE h) + explicit EventReset(HANDLE h) { _h = h; } diff --git a/PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp b/PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp index 5051cafa..c4bdf55b 100644 --- a/PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp +++ b/PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp @@ -705,7 +705,7 @@ INT_PTR CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM case WM_HSCROLL : { - if ((HWND)lParam == ::GetDlgItem(_hSelf, IDC_PERCENTAGE_SLIDER)) + if (reinterpret_cast(lParam) == ::GetDlgItem(_hSelf, IDC_PERCENTAGE_SLIDER)) { int percent = static_cast(::SendDlgItemMessage(_hSelf, IDC_PERCENTAGE_SLIDER, TBM_GETPOS, 0, 0)); FindHistory & findHistory = (NppParameters::getInstance())->getFindHistory(); @@ -2509,11 +2509,11 @@ void FindInFinderDlg::doDialog(Finder *launcher, bool isRTL) { DLGTEMPLATE *pMyDlgTemplate = NULL; HGLOBAL hMyDlgTemplate = makeRTLResource(IDD_FINDINFINDER_DLG, &pMyDlgTemplate); - ::DialogBoxIndirectParam(_hInst, pMyDlgTemplate, _hParent, dlgProc, (LPARAM)this); + ::DialogBoxIndirectParam(_hInst, pMyDlgTemplate, _hParent, dlgProc, reinterpret_cast(this)); ::GlobalFree(hMyDlgTemplate); } else - ::DialogBoxParam(_hInst, MAKEINTRESOURCE(IDD_FINDINFINDER_DLG), _hParent, dlgProc, (LPARAM)this); + ::DialogBoxParam(_hInst, MAKEINTRESOURCE(IDD_FINDINFINDER_DLG), _hParent, dlgProc, reinterpret_cast(this)); } @@ -3218,7 +3218,6 @@ INT_PTR CALLBACK FindIncrementDlg::run_dlgProc(UINT message, WPARAM wParam, LPAR LRESULT lResult = SendMessage(hParent, WM_ERASEBKGND,(WPARAM)winDC, 0); ::SetWindowOrgEx(winDC, ptOrig.x, ptOrig.y, NULL); return (BOOL)lResult; - break; } } return DefWindowProc(getHSelf(), message, wParam, lParam); diff --git a/PowerEditor/src/ScitillaComponent/FindReplaceDlg.h b/PowerEditor/src/ScitillaComponent/FindReplaceDlg.h index 26a04bc7..d752b64d 100644 --- a/PowerEditor/src/ScitillaComponent/FindReplaceDlg.h +++ b/PowerEditor/src/ScitillaComponent/FindReplaceDlg.h @@ -26,21 +26,11 @@ // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -#ifndef FIND_REPLACE_DLG_H -#define FIND_REPLACE_DLG_H +#pragma once -#ifndef FINDREPLACE_DLG_H #include "FindReplaceDlg_rc.h" -#endif //FINDREPLACE_DLG_H - -#ifndef SCINTILLA_EDIT_VIEW_H #include "ScintillaEditView.h" -#endif //SCINTILLA_EDIT_VIEW_H - -#ifndef DOCKINGDLGINTERFACE_H #include "DockingDlgInterface.h" -#endif //DOCKINGDLGINTERFACE_H - #include "BoostRegexSearch.h" #include "StatusBar.h" @@ -119,7 +109,7 @@ private: class Finder : public DockingDlgInterface { friend class FindReplaceDlg; public: - Finder() : DockingDlgInterface(IDD_FINDRESULT), _pMainFoundInfos(&_foundInfos1), _pMainMarkings(&_markings1) { + Finder() : DockingDlgInterface(IDD_FINDRESULT) { _markingsStruct._length = 0; _markingsStruct._markings = NULL; }; @@ -158,20 +148,20 @@ private: enum { searchHeaderLevel = SC_FOLDLEVELBASE + 1, fileHeaderLevel, resultLevel }; - ScintillaEditView **_ppEditView; + ScintillaEditView **_ppEditView = nullptr; std::vector _foundInfos1; std::vector _foundInfos2; - std::vector* _pMainFoundInfos; + std::vector* _pMainFoundInfos = &_foundInfos1; std::vector _markings1; std::vector _markings2; - std::vector* _pMainMarkings; + std::vector* _pMainMarkings = &_markings1; SearchResultMarkings _markingsStruct; ScintillaEditView _scintView; unsigned int _nbFoundFiles = 0; - int _lastFileHeaderPos; - int _lastSearchHeaderPos; + int _lastFileHeaderPos = 0; + int _lastSearchHeaderPos = 0; bool _canBeVolatiled = true; @@ -417,7 +407,7 @@ private : class FindIncrementDlg : public StaticDialog { public : - FindIncrementDlg() : _pFRDlg(NULL), _pRebar(NULL), _findStatus(FSFound) {}; + FindIncrementDlg() {}; void init(HINSTANCE hInst, HWND hPere, FindReplaceDlg *pFRDlg, bool isRTL = false); virtual void destroy(); virtual void display(bool toShow = true) const; @@ -434,11 +424,11 @@ public : void addToRebar(ReBar * rebar); private : - bool _isRTL; - FindReplaceDlg *_pFRDlg; - FindStatus _findStatus; + bool _isRTL = false; + FindReplaceDlg *_pFRDlg = nullptr; + FindStatus _findStatus = FSFound; - ReBar * _pRebar; + ReBar * _pRebar = nullptr; REBARBANDINFO _rbBand; virtual INT_PTR CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam); @@ -449,7 +439,7 @@ private : class Progress { public: - Progress(HINSTANCE hInst); + explicit Progress(HINSTANCE hInst); ~Progress(); HWND open(HWND hCallerWnd = NULL, const TCHAR* header = NULL); @@ -503,4 +493,3 @@ private: HWND _hBtn; }; -#endif //FIND_REPLACE_DLG_H diff --git a/PowerEditor/src/ScitillaComponent/FunctionCallTip.h b/PowerEditor/src/ScitillaComponent/FunctionCallTip.h index 01575ce6..fa6fe88e 100644 --- a/PowerEditor/src/ScitillaComponent/FunctionCallTip.h +++ b/PowerEditor/src/ScitillaComponent/FunctionCallTip.h @@ -37,12 +37,7 @@ typedef std::vector stringVec; class FunctionCallTip { friend class AutoCompletion; public: - FunctionCallTip(ScintillaEditView * pEditView) : _pEditView(pEditView), _pXmlKeyword(NULL), _curPos(0), _startPos(0), - _curFunction(NULL), _currentNrOverloads(0), _currentOverload(0), - _currentParam(0), _funcName(NULL), - _start('('), _stop(')'), _param(','), _terminal(';'), _ignoreCase(true), - _additionalWordChar(TEXT("")), _selfActivated(false) - {}; + explicit FunctionCallTip(ScintillaEditView * pEditView) : _pEditView(pEditView) {}; ~FunctionCallTip() {/* cleanup(); */}; void setLanguageXML(TiXmlElement * pXmlKeyword); //set calltip keyword node bool updateCalltip(int ch, bool needShown = false); //Ch is character typed, or 0 if another event occured. NeedShown is true if calltip should be attempted to displayed. Return true if calltip was made visible @@ -52,29 +47,29 @@ public: void close(); //Close calltip if visible private: - ScintillaEditView * _pEditView; //Scintilla to display calltip in - TiXmlElement * _pXmlKeyword; //current keyword node (first one) + ScintillaEditView * _pEditView = nullptr; //Scintilla to display calltip in + TiXmlElement * _pXmlKeyword = nullptr; //current keyword node (first one) - int _curPos; //cursor position - int _startPos; //display start position + int _curPos = 0; //cursor position + int _startPos = 0; //display start position - TiXmlElement * _curFunction; //current function element + TiXmlElement * _curFunction = nullptr; //current function element //cache some XML values n stuff - TCHAR * _funcName; //name of function + TCHAR * _funcName = nullptr; //name of function stringVec _retVals; //vector of overload return values/types std::vector _overloads; //vector of overload params (=vector) stringVec _descriptions; //vecotr of function descriptions - int _currentNrOverloads; //current amount of overloads - int _currentOverload; //current chosen overload - int _currentParam; //current highlighted param + int _currentNrOverloads = 0; //current amount of overloads + int _currentOverload = 0; //current chosen overload + int _currentParam = 0; //current highlighted param - TCHAR _start; - TCHAR _stop; - TCHAR _param; - TCHAR _terminal; - generic_string _additionalWordChar; - bool _ignoreCase; - bool _selfActivated; + TCHAR _start = '('; + TCHAR _stop = ')'; + TCHAR _param = ','; + TCHAR _terminal = ';'; + generic_string _additionalWordChar = TEXT(""); + bool _ignoreCase = true; + bool _selfActivated = false; bool getCursorFunction(); //retrieve data about function at cursor. Returns true if a function was found. Calls loaddata if needed bool loadFunction(); //returns true if the function can be found diff --git a/PowerEditor/src/ScitillaComponent/GoToLineDlg.h b/PowerEditor/src/ScitillaComponent/GoToLineDlg.h index 12d21a1b..b7fd9ffa 100644 --- a/PowerEditor/src/ScitillaComponent/GoToLineDlg.h +++ b/PowerEditor/src/ScitillaComponent/GoToLineDlg.h @@ -26,21 +26,14 @@ // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -#ifndef GOTILINE_DLG_H -#define GOTILINE_DLG_H - -#ifndef RESOURCE_H +#pragma once #include "resource.h" -#endif //RESOURCE_H - -#ifndef SCINTILLA_EDIT_VIEW_H #include "ScintillaEditView.h" -#endif //SCINTILLA_EDIT_VIEW_H class GoToLineDlg : public StaticDialog { public : - GoToLineDlg() : StaticDialog(), _mode(go2line) {}; + GoToLineDlg() : StaticDialog() {}; void init(HINSTANCE hInst, HWND hPere, ScintillaEditView **ppEditView) { Window::init(hInst, hPere); @@ -67,12 +60,11 @@ public : protected : enum mode {go2line, go2offsset}; - mode _mode; + mode _mode = go2line; virtual INT_PTR CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam); private : - - ScintillaEditView **_ppEditView; + ScintillaEditView **_ppEditView = nullptr; void updateLinesNumbers() const; @@ -88,4 +80,3 @@ private : }; -#endif //GOTILINE_DLG_H diff --git a/PowerEditor/src/ScitillaComponent/Printer.h b/PowerEditor/src/ScitillaComponent/Printer.h index 91e2fb86..6f0fbc1d 100644 --- a/PowerEditor/src/ScitillaComponent/Printer.h +++ b/PowerEditor/src/ScitillaComponent/Printer.h @@ -57,10 +57,10 @@ public : private : PRINTDLG _pdlg; - ScintillaEditView *_pSEView; - size_t _startPos; - size_t _endPos; - size_t _nbPageTotal; + ScintillaEditView *_pSEView = nullptr; + size_t _startPos = 0; + size_t _endPos = 0; + size_t _nbPageTotal =0; }; #endif //PRINTER_H diff --git a/PowerEditor/src/ScitillaComponent/ScintillaEditView.cpp b/PowerEditor/src/ScitillaComponent/ScintillaEditView.cpp index 269d99d6..1e9eadf6 100644 --- a/PowerEditor/src/ScitillaComponent/ScintillaEditView.cpp +++ b/PowerEditor/src/ScitillaComponent/ScintillaEditView.cpp @@ -320,7 +320,6 @@ LRESULT ScintillaEditView::scintillaNew_Proc(HWND hwnd, UINT Message, WPARAM wPa //Have to perform the scroll first, because the first/last line do not get updated untill after the scroll has been parsed LRESULT scrollResult = ::CallWindowProc(_scintillaDefaultProc, hwnd, Message, wParam, lParam); return scrollResult; - break; } case WM_IME_REQUEST: diff --git a/PowerEditor/src/ScitillaComponent/ScintillaEditView.h b/PowerEditor/src/ScitillaComponent/ScintillaEditView.h index 27308cca..ead5fef8 100644 --- a/PowerEditor/src/ScitillaComponent/ScintillaEditView.h +++ b/PowerEditor/src/ScitillaComponent/ScintillaEditView.h @@ -26,41 +26,17 @@ // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -#ifndef SCINTILLA_EDIT_VIEW_H -#define SCINTILLA_EDIT_VIEW_H +#pragma once + -#ifndef SCINTILLA_H #include "Scintilla.h" -#endif //SCINTILLA_H - -#ifndef SCINTILLA_REF_H #include "ScintillaRef.h" -#endif //SCINTILLA_REF_H - -#ifndef SCILEXER_H #include "SciLexer.h" -#endif //SCILEXER_H - -#ifndef BUFFER_H #include "Buffer.h" -#endif //BUFFER_H - -#ifndef COLORS_H #include "colors.h" -#endif //COLORS_H - -#ifndef USER_DEFINE_H #include "UserDefineDialog.h" -#endif //USER_DEFINE_H - -#ifndef XPM_ICON_H #include "xpm_icons.h" -#endif //XPM_ICON_H -/* -#ifndef RESOURCE_H -#include "resource.h" -#endif //RESOURCE_H -*/ + #ifndef WM_MOUSEWHEEL #define WM_MOUSEWHEEL 0x020A @@ -204,10 +180,7 @@ class ScintillaEditView : public Window { friend class Finder; public: - ScintillaEditView() - : Window(), _pScintillaFunc(NULL),_pScintillaPtr(NULL), - _lineNumbersShown(false), _wrapRestoreNeeded(false), _beginSelectPosition(-1) - { + ScintillaEditView(): Window() { ++_refCount; }; @@ -656,26 +629,26 @@ protected: static LRESULT CALLBACK scintillaStatic_Proc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam); LRESULT scintillaNew_Proc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam); - SCINTILLA_FUNC _pScintillaFunc; - SCINTILLA_PTR _pScintillaPtr; + SCINTILLA_FUNC _pScintillaFunc = nullptr; + SCINTILLA_PTR _pScintillaPtr = nullptr; static WNDPROC _scintillaDefaultProc; - CallWindowProcFunc _callWindowProc; + CallWindowProcFunc _callWindowProc = nullptr; BufferID attachDefaultDoc(); //Store the current buffer so it can be retrieved later - BufferID _currentBufferID; - Buffer * _currentBuffer; + BufferID _currentBufferID = nullptr; + Buffer * _currentBuffer = nullptr; - NppParameters *_pParameter; - int _codepage; - bool _lineNumbersShown; - bool _wrapRestoreNeeded; + NppParameters *_pParameter = nullptr; + int _codepage = CP_ACP; + bool _lineNumbersShown = false; + bool _wrapRestoreNeeded = false; typedef std::unordered_map StyleMap; typedef std::unordered_map BufferStyleMap; BufferStyleMap _hotspotStyles; - int _beginSelectPosition; + int _beginSelectPosition = -1; //Lexers and Styling void restyleBuffer(); @@ -925,4 +898,3 @@ protected: bool expandWordSelection(); }; -#endif //SCINTILLA_EDIT_VIEW_H diff --git a/PowerEditor/src/ScitillaComponent/SmartHighlighter.h b/PowerEditor/src/ScitillaComponent/SmartHighlighter.h index 01b30a7d..3a8d20e9 100644 --- a/PowerEditor/src/ScitillaComponent/SmartHighlighter.h +++ b/PowerEditor/src/ScitillaComponent/SmartHighlighter.h @@ -33,7 +33,7 @@ class FindReplaceDlg; class SmartHighlighter { public: - SmartHighlighter(FindReplaceDlg * pFRDlg); + explicit SmartHighlighter(FindReplaceDlg * pFRDlg); void highlightView(ScintillaEditView * pHighlightView); private: FindReplaceDlg * _pFRDlg; diff --git a/PowerEditor/src/ScitillaComponent/UserDefineDialog.cpp b/PowerEditor/src/ScitillaComponent/UserDefineDialog.cpp index 30869296..c1b47d06 100644 --- a/PowerEditor/src/ScitillaComponent/UserDefineDialog.cpp +++ b/PowerEditor/src/ScitillaComponent/UserDefineDialog.cpp @@ -938,7 +938,7 @@ void SymbolsStyleDialog::setKeywords2List(int id) } } -UserDefineDialog::UserDefineDialog(): SharedParametersDialog(), _status(UNDOCK), _yScrollPos(0), _prevHightVal(0), _isDirty(false) +UserDefineDialog::UserDefineDialog(): SharedParametersDialog() { _pCurrentUserLang = new UserLangContainer(); @@ -1148,7 +1148,7 @@ INT_PTR CALLBACK UserDefineDialog::run_dlgProc(UINT message, WPARAM wParam, LPAR case WM_HSCROLL: { - if ((HWND)lParam == ::GetDlgItem(_hSelf, IDC_UD_PERCENTAGE_SLIDER)) + if (reinterpret_cast(lParam) == ::GetDlgItem(_hSelf, IDC_UD_PERCENTAGE_SLIDER)) { int percent = static_cast(::SendDlgItemMessage(_hSelf, IDC_UD_PERCENTAGE_SLIDER, TBM_GETPOS, 0, 0)); pNppParam->SetTransparent(_hSelf, percent); diff --git a/PowerEditor/src/ScitillaComponent/UserDefineDialog.h b/PowerEditor/src/ScitillaComponent/UserDefineDialog.h index 5adb25d2..822b5ddd 100644 --- a/PowerEditor/src/ScitillaComponent/UserDefineDialog.h +++ b/PowerEditor/src/ScitillaComponent/UserDefineDialog.h @@ -24,23 +24,14 @@ // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -#ifndef USER_DEFINE_H -#define USER_DEFINE_H -#ifndef USERDEFINE_RC_H + +#pragma once + #include "UserDefineResource.h" -#endif //USERDEFINE_RC_H -#ifndef CONTROLS_TAB_H #include "ControlsTab.h" -#endif //CONTROLS_TAB_H -#ifndef COLOUR_PICKER_H #include "ColourPicker.h" -#endif //COLOUR_PICKER_H -#ifndef PARAMETERS_H #include "Parameters.h" -#endif //PARAMETERS_H -#ifndef URLCTRL_INCLUDED #include "URLCtrl.h" -#endif// URLCTRL_INCLUDED #include "tchar.h" #include "SciLexer.h" #include @@ -391,12 +382,12 @@ private : KeyWordsStyleDialog _keyWordsStyleDlg; CommentStyleDialog _commentStyleDlg; SymbolsStyleDialog _symbolsStyleDlg; - bool _status; + bool _status = UNDOCK; RECT _dlgPos; - int _currentHight; - int _yScrollPos; - int _prevHightVal; - bool _isDirty; + int _currentHight = 0; + int _yScrollPos = 0; + int _prevHightVal = 0; + bool _isDirty = false; void getActualPosSize() { ::GetWindowRect(_hSelf, &_dlgPos); _dlgPos.right -= _dlgPos.left; @@ -420,17 +411,21 @@ public : _textValue = text2Set; _txtLen = txtLen; }; + long doDialog() { - return long(::DialogBoxParam(_hInst, MAKEINTRESOURCE(IDD_STRING_DLG), _hParent, dlgProc, (LPARAM)this)); + return long(::DialogBoxParam(_hInst, MAKEINTRESOURCE(IDD_STRING_DLG), _hParent, dlgProc, reinterpret_cast(this))); }; + virtual void destroy() {}; + protected : INT_PTR CALLBACK run_dlgProc(UINT Message, WPARAM wParam, LPARAM); + private : generic_string _title; generic_string _textValue; generic_string _static; - int _txtLen; + int _txtLen = 0; }; class StylerDlg @@ -451,7 +446,7 @@ public: }; long doDialog() { - return long (::DialogBoxParam(_hInst, MAKEINTRESOURCE(IDD_STYLER_POPUP_DLG), _parent, dlgProc, (LPARAM)this)); + return long(::DialogBoxParam(_hInst, MAKEINTRESOURCE(IDD_STYLER_POPUP_DLG), _parent, dlgProc, reinterpret_cast(this))); }; static INT_PTR CALLBACK dlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam); @@ -464,4 +459,3 @@ public: ColourPicker * _pBgColour; Style _initialStyle; }; -#endif //USER_DEFINE_H diff --git a/PowerEditor/src/ScitillaComponent/columnEditor.h b/PowerEditor/src/ScitillaComponent/columnEditor.h index 9ce5c37a..694a6c2a 100644 --- a/PowerEditor/src/ScitillaComponent/columnEditor.h +++ b/PowerEditor/src/ScitillaComponent/columnEditor.h @@ -70,7 +70,7 @@ protected : private : - ScintillaEditView **_ppEditView; + ScintillaEditView **_ppEditView = nullptr; }; diff --git a/PowerEditor/src/ScitillaComponent/xmlMatchedTagsHighlighter.h b/PowerEditor/src/ScitillaComponent/xmlMatchedTagsHighlighter.h index dcaf18f0..91f1c482 100644 --- a/PowerEditor/src/ScitillaComponent/xmlMatchedTagsHighlighter.h +++ b/PowerEditor/src/ScitillaComponent/xmlMatchedTagsHighlighter.h @@ -37,7 +37,7 @@ class ScintillaEditView; class XmlMatchedTagsHighlighter { public: - XmlMatchedTagsHighlighter(ScintillaEditView *pEditView):_pEditView(pEditView){}; + explicit XmlMatchedTagsHighlighter(ScintillaEditView *pEditView):_pEditView(pEditView){}; void tagMatch(bool doHiliteAttr); private: diff --git a/PowerEditor/src/WinControls/AnsiCharPanel/ListView.h b/PowerEditor/src/WinControls/AnsiCharPanel/ListView.h index 1f4dc53a..bd07e10e 100644 --- a/PowerEditor/src/WinControls/AnsiCharPanel/ListView.h +++ b/PowerEditor/src/WinControls/AnsiCharPanel/ListView.h @@ -47,7 +47,7 @@ public: generic_string getAscii(unsigned char value); protected: - int _codepage; + int _codepage = -1; WNDPROC _defaultProc; LRESULT runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam); diff --git a/PowerEditor/src/WinControls/AnsiCharPanel/ansiCharPanel.h b/PowerEditor/src/WinControls/AnsiCharPanel/ansiCharPanel.h index f4735fb5..bbb043f6 100644 --- a/PowerEditor/src/WinControls/AnsiCharPanel/ansiCharPanel.h +++ b/PowerEditor/src/WinControls/AnsiCharPanel/ansiCharPanel.h @@ -77,7 +77,7 @@ protected: virtual INT_PTR CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam); private: - ScintillaEditView **_ppEditView; + ScintillaEditView **_ppEditView = nullptr; ListView _listView; }; #endif // ANSICHARPANEL_H diff --git a/PowerEditor/src/WinControls/ClipboardHistory/clipboardHistoryPanel.cpp b/PowerEditor/src/WinControls/ClipboardHistory/clipboardHistoryPanel.cpp index 6b29e341..7e263386 100644 --- a/PowerEditor/src/WinControls/ClipboardHistory/clipboardHistoryPanel.cpp +++ b/PowerEditor/src/WinControls/ClipboardHistory/clipboardHistoryPanel.cpp @@ -207,8 +207,8 @@ INT_PTR CALLBACK ClipboardHistoryPanel::run_dlgProc(UINT message, WPARAM wParam, } case WM_CHANGECBCHAIN: - if (_hwndNextCbViewer == (HWND)wParam) - _hwndNextCbViewer = (HWND)lParam; + if (_hwndNextCbViewer == reinterpret_cast(wParam)) + _hwndNextCbViewer = reinterpret_cast(lParam); else if (_hwndNextCbViewer) ::SendMessage(_hwndNextCbViewer, message, wParam, lParam); return TRUE; diff --git a/PowerEditor/src/WinControls/ClipboardHistory/clipboardHistoryPanel.h b/PowerEditor/src/WinControls/ClipboardHistory/clipboardHistoryPanel.h index 0f112dbf..3293908a 100644 --- a/PowerEditor/src/WinControls/ClipboardHistory/clipboardHistoryPanel.h +++ b/PowerEditor/src/WinControls/ClipboardHistory/clipboardHistoryPanel.h @@ -46,7 +46,7 @@ class ScintillaEditView; class ByteArray { public: ByteArray():_pBytes(NULL), _length(0) {}; - ByteArray(ClipboardData cd); + explicit ByteArray(ClipboardData cd); ~ByteArray() { if (_pBytes) diff --git a/PowerEditor/src/WinControls/ColourPicker/ColourPicker.cpp b/PowerEditor/src/WinControls/ColourPicker/ColourPicker.cpp index a526f36a..8a0f2f0f 100644 --- a/PowerEditor/src/WinControls/ColourPicker/ColourPicker.cpp +++ b/PowerEditor/src/WinControls/ColourPicker/ColourPicker.cpp @@ -147,7 +147,6 @@ LRESULT ColourPicker::runProc(UINT Message, WPARAM wParam, LPARAM lParam) HDC dc = (HDC)wParam; drawBackground(dc); return TRUE; - break; } case WM_PAINT: diff --git a/PowerEditor/src/WinControls/ColourPicker/ColourPopup.cpp b/PowerEditor/src/WinControls/ColourPicker/ColourPopup.cpp index c1d79092..7a13c8f2 100644 --- a/PowerEditor/src/WinControls/ColourPicker/ColourPopup.cpp +++ b/PowerEditor/src/WinControls/ColourPicker/ColourPopup.cpp @@ -43,7 +43,7 @@ DWORD colourItems[] = { void ColourPopup::create(int dialogID) { - _hSelf = ::CreateDialogParam(_hInst, MAKEINTRESOURCE(dialogID), _hParent, dlgProc, (LPARAM)this); + _hSelf = ::CreateDialogParam(_hInst, MAKEINTRESOURCE(dialogID), _hParent, dlgProc, reinterpret_cast(this)); if (!_hSelf) { @@ -60,7 +60,7 @@ INT_PTR CALLBACK ColourPopup::dlgProc(HWND hwnd, UINT message, WPARAM wParam, LP case WM_MEASUREITEM: { RECT rc; - LPMEASUREITEMSTRUCT lpmis = (LPMEASUREITEMSTRUCT) lParam; + LPMEASUREITEMSTRUCT lpmis = reinterpret_cast(lParam); ::GetWindowRect(::GetDlgItem(hwnd, lpmis->CtlID), &rc); lpmis->itemHeight = (rc.bottom-rc.top)/6; lpmis->itemWidth = (rc.right-rc.left)/8; @@ -96,8 +96,8 @@ INT_PTR CALLBACK ColourPopup::run_dlgProc(UINT message, WPARAM wParam, LPARAM lP int nColor; for (nColor = 0 ; nColor < int(sizeof(colourItems)/sizeof(DWORD)) ; ++nColor) { - ::SendDlgItemMessage(_hSelf, IDC_COLOUR_LIST, LB_ADDSTRING, nColor, (LPARAM) ""); - ::SendDlgItemMessage(_hSelf, IDC_COLOUR_LIST, LB_SETITEMDATA , nColor, (LPARAM) colourItems[nColor]); + ::SendDlgItemMessage(_hSelf, IDC_COLOUR_LIST, LB_ADDSTRING, nColor, reinterpret_cast("")); + ::SendDlgItemMessage(_hSelf, IDC_COLOUR_LIST, LB_SETITEMDATA, nColor, static_cast(colourItems[nColor])); } return TRUE; } @@ -218,8 +218,8 @@ INT_PTR CALLBACK ColourPopup::run_dlgProc(UINT message, WPARAM wParam, LPARAM lP { if (HIWORD(wParam) == LBN_SELCHANGE) { - auto i = ::SendMessage((HWND)lParam, LB_GETCURSEL, 0L, 0L); - _colour = static_cast(::SendMessage((HWND)lParam, LB_GETITEMDATA, i, 0L)); + auto i = ::SendMessage(reinterpret_cast(lParam), LB_GETCURSEL, 0L, 0L); + _colour = static_cast(::SendMessage(reinterpret_cast(lParam), LB_GETITEMDATA, i, 0L)); ::SendMessage(_hParent, WM_PICKUP_COLOR, _colour, 0); return TRUE; @@ -233,8 +233,7 @@ INT_PTR CALLBACK ColourPopup::run_dlgProc(UINT message, WPARAM wParam, LPARAM lP case WM_ACTIVATE : { if (LOWORD(wParam) == WA_INACTIVE) - //if (!isColourChooserLaunched) - ::SendMessage(_hParent, WM_PICKUP_CANCEL, 0, 0); + ::SendMessage(_hParent, WM_PICKUP_CANCEL, 0, 0); return TRUE; } diff --git a/PowerEditor/src/WinControls/ColourPicker/WordStyleDlg.cpp b/PowerEditor/src/WinControls/ColourPicker/WordStyleDlg.cpp index c25945cb..d0187196 100644 --- a/PowerEditor/src/WinControls/ColourPicker/WordStyleDlg.cpp +++ b/PowerEditor/src/WinControls/ColourPicker/WordStyleDlg.cpp @@ -183,7 +183,7 @@ INT_PTR CALLBACK WordStyleDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM l case WM_HSCROLL : { - if ((HWND)lParam == ::GetDlgItem(_hSelf, IDC_SC_PERCENTAGE_SLIDER)) + if (reinterpret_cast(lParam) == ::GetDlgItem(_hSelf, IDC_SC_PERCENTAGE_SLIDER)) { int percent = static_cast(::SendDlgItemMessage(_hSelf, IDC_SC_PERCENTAGE_SLIDER, TBM_GETPOS, 0, 0)); (NppParameters::getInstance())->SetTransparent(_hSelf, percent); @@ -416,7 +416,7 @@ INT_PTR CALLBACK WordStyleDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM l case CPN_COLOURPICKED: { - if ((HWND)lParam == _pFgColour->getHSelf()) + if (reinterpret_cast(lParam) == _pFgColour->getHSelf()) { updateColour(C_FOREGROUND); notifyDataModified(); @@ -428,7 +428,7 @@ INT_PTR CALLBACK WordStyleDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM l apply(); return TRUE; } - else if ((HWND)lParam == _pBgColour->getHSelf()) + else if (reinterpret_cast(lParam) == _pBgColour->getHSelf()) { updateColour(C_BACKGROUND); notifyDataModified(); diff --git a/PowerEditor/src/WinControls/ColourPicker/WordStyleDlg.h b/PowerEditor/src/WinControls/ColourPicker/WordStyleDlg.h index 7bbbbb12..53a26167 100644 --- a/PowerEditor/src/WinControls/ColourPicker/WordStyleDlg.h +++ b/PowerEditor/src/WinControls/ColourPicker/WordStyleDlg.h @@ -69,7 +69,7 @@ private : class WordStyleDlg : public StaticDialog { public : - WordStyleDlg():_isDirty(false), _isThemeDirty(false), _restoreInvalid(false), /*_isSync(true),*/ _isShownGOCtrls(false){}; + WordStyleDlg() {}; void init(HINSTANCE hInst, HWND parent) { Window::init(hInst, parent); @@ -119,13 +119,12 @@ public : }; - private : - ColourPicker *_pFgColour; - ColourPicker *_pBgColour; + ColourPicker *_pFgColour = nullptr; + ColourPicker *_pBgColour = nullptr; - int _currentLexerIndex; - int _currentThemeIndex; + int _currentLexerIndex = -1; + int _currentThemeIndex = -1; HWND _hCheckBold; HWND _hCheckItalic; @@ -148,14 +147,13 @@ private : LexerStylerArray _styles2restored; StyleArray _gstyles2restored; GlobalOverride _gOverride2restored; - bool _restoreInvalid; + bool _restoreInvalid = false; ColourStaticTextHooker colourHooker; - bool _isDirty; - bool _isThemeDirty; - //bool _isSync; - bool _isShownGOCtrls; + bool _isDirty = false; + bool _isThemeDirty = false; + bool _isShownGOCtrls = false; INT_PTR CALLBACK run_dlgProc(UINT Message, WPARAM wParam, LPARAM lParam); diff --git a/PowerEditor/src/WinControls/DockingWnd/Docking.h b/PowerEditor/src/WinControls/DockingWnd/Docking.h index 4ee00fe2..f4b2af49 100644 --- a/PowerEditor/src/WinControls/DockingWnd/Docking.h +++ b/PowerEditor/src/WinControls/DockingWnd/Docking.h @@ -26,8 +26,7 @@ // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -#ifndef DOCKING_H -#define DOCKING_H +#pragma once #include @@ -84,5 +83,3 @@ typedef struct { #define HIT_TEST_THICKNESS 20 #define SPLITTER_WIDTH 4 - -#endif // DOCKING_H diff --git a/PowerEditor/src/WinControls/DockingWnd/DockingCont.cpp b/PowerEditor/src/WinControls/DockingWnd/DockingCont.cpp index 339b214a..3166d321 100644 --- a/PowerEditor/src/WinControls/DockingWnd/DockingCont.cpp +++ b/PowerEditor/src/WinControls/DockingWnd/DockingCont.cpp @@ -339,7 +339,7 @@ LRESULT DockingCont::runProcCaption(HWND hwnd, UINT Message, WPARAM wParam, LPAR case WM_LBUTTONDBLCLK: { if (isInRect(hwnd, LOWORD(lParam), HIWORD(lParam)) == posCaption) - ::SendMessage(_hParent, DMM_FLOATALL, 0, (LPARAM)this); + ::SendMessage(_hParent, DMM_FLOATALL, 0, reinterpret_cast(this)); focusClient(); return TRUE; @@ -1463,6 +1463,6 @@ void DockingCont::focusClient() LPARAM DockingCont::NotifyParent(UINT message) { - return ::SendMessage(_hParent, message, 0, (LPARAM)this); + return ::SendMessage(_hParent, message, 0, reinterpret_cast(this)); } diff --git a/PowerEditor/src/WinControls/DockingWnd/DockingCont.h b/PowerEditor/src/WinControls/DockingWnd/DockingCont.h index 9a2daa63..70246f10 100644 --- a/PowerEditor/src/WinControls/DockingWnd/DockingCont.h +++ b/PowerEditor/src/WinControls/DockingWnd/DockingCont.h @@ -26,17 +26,9 @@ // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -#ifndef DOCKINGCONT -#define DOCKINGCONT - -#ifndef RESOURCE_H +#pragma once #include "resource.h" -#endif //RESOURCE_H - -#ifndef DOCKING_H #include "Docking.h" -#endif //DOCKING_H - #include #include "StaticDialog.h" #include "Common.h" @@ -243,6 +235,3 @@ private: std::vector _vTbData; }; - - -#endif // DOCKINGCONT diff --git a/PowerEditor/src/WinControls/DockingWnd/DockingDlgInterface.h b/PowerEditor/src/WinControls/DockingWnd/DockingDlgInterface.h index 230a24ce..249a4706 100644 --- a/PowerEditor/src/WinControls/DockingWnd/DockingDlgInterface.h +++ b/PowerEditor/src/WinControls/DockingWnd/DockingDlgInterface.h @@ -25,16 +25,10 @@ // along with this program; if not, write to the Free Software -#ifndef DOCKINGDLGINTERFACE_H -#define DOCKINGDLGINTERFACE_H +#pragma once -#ifndef DOCKING_RESOURCE_H #include "dockingResource.h" -#endif //DOCKING_RESOURCE_H - -#ifndef DOCKING_H #include "Docking.h" -#endif //DOCKING_H #include #include @@ -47,17 +41,13 @@ class DockingDlgInterface : public StaticDialog { public: DockingDlgInterface() = default; - - explicit DockingDlgInterface(int dlgID) - : _dlgID(dlgID) - {} - + explicit DockingDlgInterface(int dlgID): _dlgID(dlgID) {} virtual void init(HINSTANCE hInst, HWND parent) { StaticDialog::init(hInst, parent); TCHAR temp[MAX_PATH]; - ::GetModuleFileName((HMODULE)hInst, temp, MAX_PATH); + ::GetModuleFileName(reinterpret_cast(hInst), temp, MAX_PATH); _moduleName = ::PathFindFileName(temp); } @@ -71,7 +61,7 @@ public: // user information data->hClient = _hSelf; - data->pszName = (TCHAR *)_pluginName.c_str(); + data->pszName = _pluginName.c_str(); // supported features by plugin data->uMask = 0; @@ -82,17 +72,16 @@ public: virtual void updateDockingDlg() { - ::SendMessage(_hParent, NPPM_DMMUPDATEDISPINFO, 0, (LPARAM)_hSelf); + ::SendMessage(_hParent, NPPM_DMMUPDATEDISPINFO, 0, reinterpret_cast(_hSelf)); } virtual void destroy() {} virtual void setBackgroundColor(COLORREF) {} - virtual void setForegroundColor(COLORREF) {} virtual void display(bool toShow = true) const { - ::SendMessage(_hParent, toShow?NPPM_DMMSHOW:NPPM_DMMHIDE, 0, (LPARAM)_hSelf); + ::SendMessage(_hParent, toShow ? NPPM_DMMSHOW : NPPM_DMMHIDE, 0, reinterpret_cast(_hSelf)); } bool isClosed() const { @@ -115,7 +104,7 @@ protected : case WM_NOTIFY: { - LPNMHDR pnmh = (LPNMHDR)lParam; + LPNMHDR pnmh = reinterpret_cast(lParam); if (pnmh->hwndFrom == _hParent) { @@ -157,5 +146,3 @@ protected : generic_string _pluginName; bool _isClosed = false; }; - -#endif // DOCKINGDLGINTERFACE_H diff --git a/PowerEditor/src/WinControls/DockingWnd/DockingManager.cpp b/PowerEditor/src/WinControls/DockingWnd/DockingManager.cpp index 5cc51595..d59294aa 100644 --- a/PowerEditor/src/WinControls/DockingWnd/DockingManager.cpp +++ b/PowerEditor/src/WinControls/DockingWnd/DockingManager.cpp @@ -75,8 +75,6 @@ LRESULT CALLBACK FocusWndProc(int nCode, WPARAM wParam, LPARAM lParam) DockingManager::DockingManager() { - _isInitialized = FALSE; - _hImageList = NULL; memset(_iContMap, -1, CONT_MAP_MAX * sizeof(int)); _iContMap[0] = CONT_LEFT; @@ -297,7 +295,7 @@ LRESULT DockingManager::runProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM l for (int iCont = 0; iCont < DOCKCONT_MAX; ++iCont) { - if (_vSplitter[iCont]->getHSelf() == (HWND)lParam) + if (_vSplitter[iCont]->getHSelf() == reinterpret_cast(lParam)) { switch (iCont) { @@ -384,7 +382,7 @@ LRESULT DockingManager::runProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM l { for (size_t uImageCnt = 0, len = _vImageList.size(); uImageCnt < len; ++uImageCnt) { - if ((HWND)lParam == _vImageList[uImageCnt]) + if (reinterpret_cast(lParam) == _vImageList[uImageCnt]) { return uImageCnt; } diff --git a/PowerEditor/src/WinControls/DockingWnd/DockingManager.h b/PowerEditor/src/WinControls/DockingWnd/DockingManager.h index 6af6d98a..ea8d8a48 100644 --- a/PowerEditor/src/WinControls/DockingWnd/DockingManager.h +++ b/PowerEditor/src/WinControls/DockingWnd/DockingManager.h @@ -25,29 +25,19 @@ // along with this program; if not, write to the Free Software // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - -#ifndef DOCKINGMANAGER_H -#define DOCKINGMANAGER_H +#pragma once #include #include #include #include "Window.h" - -#ifndef DOCKINGCONT #include "DockingCont.h" -#endif //DOCKINGCONT - -class DockingSplitter; - -#ifndef SPLITTER_CONTAINER_H #include "SplitterContainer.h" -#endif //SPLITTER_CONTAINER_H - #define DSPC_CLASS_NAME TEXT("dockingManager") #define CONT_MAP_MAX 50 +class DockingSplitter; class DockingManager : public Window { @@ -120,20 +110,19 @@ private : BOOL ContExists(size_t iCont); int FindEmptyContainer(); LRESULT SendNotify(HWND hWnd, UINT message); - + private: - Window **_ppWindow; + Window **_ppWindow = nullptr; RECT _rcWork; RECT _rect; - Window **_ppMainWindow; - std::vector _vImageList; - HIMAGELIST _hImageList; - std::vector _vContainer; + Window **_ppMainWindow = nullptr; + std::vector _vImageList; + HIMAGELIST _hImageList = nullptr; + std::vector _vContainer; tDockMgr _dockData; static BOOL _isRegistered; - BOOL _isInitialized; + BOOL _isInitialized = FALSE; int _iContMap[CONT_MAP_MAX]; std::vector _vSplitter; }; -#endif //DOCKINGMANAGER_H diff --git a/PowerEditor/src/WinControls/DockingWnd/Gripper.cpp b/PowerEditor/src/WinControls/DockingWnd/Gripper.cpp index 6e2c0b7d..32e96e53 100644 --- a/PowerEditor/src/WinControls/DockingWnd/Gripper.cpp +++ b/PowerEditor/src/WinControls/DockingWnd/Gripper.cpp @@ -327,7 +327,6 @@ void Gripper::onButtonUp() POINT ptBuf = {0,0}; RECT rc = {0}; RECT rcCorr = {0}; - DockingCont* pContMove = NULL; ::GetCursorPos(&pt); getMousePoints(&pt, &ptBuf); @@ -363,6 +362,8 @@ void Gripper::onButtonUp() /* correct rectangle position when mouse is not within */ DoCalcGripperRect(&rc, rcCorr, pt); + DockingCont* pContMove = NULL; + /* change location of toolbars */ if (_startMovingFromTab == TRUE) { diff --git a/PowerEditor/src/WinControls/DocumentMap/documentMap.h b/PowerEditor/src/WinControls/DocumentMap/documentMap.h index 32e9132c..f0942d54 100644 --- a/PowerEditor/src/WinControls/DocumentMap/documentMap.h +++ b/PowerEditor/src/WinControls/DocumentMap/documentMap.h @@ -26,13 +26,9 @@ // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -#ifndef DOCUMENTMAP_H -#define DOCUMENTMAP_H +#pragma once -#ifndef DOCKINGDLGINTERFACE_H #include "DockingDlgInterface.h" -#endif //DOCKINGDLGINTERFACE_H - #include "documentMap_rc.h" #define DM_PANELTITLE TEXT("Document Map") @@ -94,9 +90,7 @@ private : class DocumentMap : public DockingDlgInterface { public: - DocumentMap(): DockingDlgInterface(IDD_DOCUMENTMAP), _ppEditView(NULL),\ - _pScintillaEditView(NULL), id4dockingCont(DM_NOFOCUSWHILECLICKINGCAPTION) - {}; + DocumentMap(): DockingDlgInterface(IDD_DOCUMENTMAP) {}; void create(tTbData * data, bool isRTL = false) { DockingDlgInterface::create(data, isRTL); @@ -140,15 +134,12 @@ protected: int getEditorTextZoneWidth(); private: - ScintillaEditView **_ppEditView; - ScintillaEditView *_pScintillaEditView; + ScintillaEditView **_ppEditView = nullptr; + ScintillaEditView *_pScintillaEditView = nullptr; ViewZoneDlg _vzDlg; // for needToRecomputeWith function - int _displayZoom; - int _displayWidth; - generic_string id4dockingCont; + int _displayZoom = -1; + int _displayWidth = 0; + generic_string id4dockingCont = DM_NOFOCUSWHILECLICKINGCAPTION; }; - - -#endif // DOCUMENTMAP_H diff --git a/PowerEditor/src/WinControls/FindCharsInRange/FindCharsInRange.h b/PowerEditor/src/WinControls/FindCharsInRange/FindCharsInRange.h index 4c27c7ec..c09555d6 100644 --- a/PowerEditor/src/WinControls/FindCharsInRange/FindCharsInRange.h +++ b/PowerEditor/src/WinControls/FindCharsInRange/FindCharsInRange.h @@ -67,7 +67,7 @@ protected : virtual INT_PTR CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam); private : - ScintillaEditView **_ppEditView; + ScintillaEditView **_ppEditView = nullptr; bool findCharInRange(unsigned char beginRange, unsigned char endRange, int startPos, bool direction, bool wrap); bool getRangeFromUI(unsigned char & startRange, unsigned char & endRange); void getDirectionFromUI(bool & whichDirection, bool & isWrap); diff --git a/PowerEditor/src/WinControls/FunctionList/functionListPanel.cpp b/PowerEditor/src/WinControls/FunctionList/functionListPanel.cpp index 6dfdbec4..c81514cb 100644 --- a/PowerEditor/src/WinControls/FunctionList/functionListPanel.cpp +++ b/PowerEditor/src/WinControls/FunctionList/functionListPanel.cpp @@ -314,7 +314,6 @@ void FunctionListPanel::init(HINSTANCE hInst, HWND hPere, ScintillaEditView **pp { DockingDlgInterface::init(hInst, hPere); _ppEditView = ppEditView; - bool isOK = false; bool doLocalConf = (NppParameters::getInstance())->isLocal(); if (!doLocalConf) @@ -329,12 +328,12 @@ void FunctionListPanel::init(HINSTANCE hInst, HWND hPere, ScintillaEditView **pp if (PathFileExists(funcListDefaultXmlPath.c_str())) { ::CopyFile(funcListDefaultXmlPath.c_str(), funcListXmlPath.c_str(), TRUE); - isOK = _funcParserMgr.init(funcListXmlPath, ppEditView); + _funcParserMgr.init(funcListXmlPath, ppEditView); } } else { - isOK = _funcParserMgr.init(funcListXmlPath, ppEditView); + _funcParserMgr.init(funcListXmlPath, ppEditView); } } else @@ -343,11 +342,9 @@ void FunctionListPanel::init(HINSTANCE hInst, HWND hPere, ScintillaEditView **pp PathAppend(funcListDefaultXmlPath, TEXT("functionList.xml")); if (PathFileExists(funcListDefaultXmlPath.c_str())) { - isOK = _funcParserMgr.init(funcListDefaultXmlPath, ppEditView); + _funcParserMgr.init(funcListDefaultXmlPath, ppEditView); } } - - //return isOK; } bool FunctionListPanel::openSelection(const TreeView & treeView) diff --git a/PowerEditor/src/WinControls/FunctionList/functionParser.h b/PowerEditor/src/WinControls/FunctionList/functionParser.h index 8512d4a8..8c59bbe7 100644 --- a/PowerEditor/src/WinControls/FunctionList/functionParser.h +++ b/PowerEditor/src/WinControls/FunctionList/functionParser.h @@ -24,13 +24,13 @@ // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + #pragma once; + class ScintillaEditView; class TiXmlDocument; class TiXmlNode; - - struct foundInfo final { generic_string _data; @@ -78,7 +78,6 @@ private: generic_string _rangeExpr; generic_string _openSymbole; generic_string _closeSymbole; - generic_string _functionExpr; size_t getBodyClosePos(size_t begin, const TCHAR *bodyOpenSymbol, const TCHAR *bodyCloseSymbol, const std::vector< std::pair > & commentZones, ScintillaEditView **ppEditView); }; @@ -158,4 +157,4 @@ private: bool getZonePaserParameters(TiXmlNode *classRangeParser, generic_string &mainExprStr, generic_string &openSymboleStr, generic_string &closeSymboleStr, std::vector &classNameExprArray, generic_string &functionExprStr, std::vector &functionNameExprArray); bool getUnitPaserParameters(TiXmlNode *functionParser, generic_string &mainExprStr, std::vector &functionNameExprArray, std::vector &classNameExprArray); FunctionParser * getParser(const AssociationInfo & assoInfo); -}; \ No newline at end of file +}; diff --git a/PowerEditor/src/WinControls/Grid/ShortcutMapper.cpp b/PowerEditor/src/WinControls/Grid/ShortcutMapper.cpp index d8e2068a..fdafabc3 100644 --- a/PowerEditor/src/WinControls/Grid/ShortcutMapper.cpp +++ b/PowerEditor/src/WinControls/Grid/ShortcutMapper.cpp @@ -275,9 +275,9 @@ INT_PTR CALLBACK ShortcutMapper::run_dlgProc(UINT message, WPARAM wParam, LPARAM { //Get UserCommand corresponding to row vector & shortcuts = nppParam->getUserCommandList(); - UserCommand ucmd = shortcuts[row - 1], prevucmd = shortcuts[row - 1]; + UserCommand ucmd = shortcuts[row - 1]; ucmd.init(_hInst, _hSelf); - prevucmd = ucmd; + UserCommand prevucmd = ucmd; if (ucmd.doDialog() != -1 && prevucmd != ucmd) { //shortcut was altered @@ -296,9 +296,9 @@ INT_PTR CALLBACK ShortcutMapper::run_dlgProc(UINT message, WPARAM wParam, LPARAM { //Get PluginCmdShortcut corresponding to row vector & shortcuts = nppParam->getPluginCommandList(); - PluginCmdShortcut pcsc = shortcuts[row - 1], prevpcsc = shortcuts[row - 1]; + PluginCmdShortcut pcsc = shortcuts[row - 1]; pcsc.init(_hInst, _hSelf); - prevpcsc = pcsc; + PluginCmdShortcut prevpcsc = pcsc; if (pcsc.doDialog() != -1 && prevpcsc != pcsc) { //shortcut was altered diff --git a/PowerEditor/src/WinControls/Grid/ShortcutMapper.h b/PowerEditor/src/WinControls/Grid/ShortcutMapper.h index 76cc4c14..14201074 100644 --- a/PowerEditor/src/WinControls/Grid/ShortcutMapper.h +++ b/PowerEditor/src/WinControls/Grid/ShortcutMapper.h @@ -26,24 +26,12 @@ // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -#ifndef SHORTCUTMAPPER -#define SHORTCUTMAPPER +#pragma once -#ifndef BABYGRIDWRAPPER #include "BabyGridWrapper.h" -#endif// BABYGRIDWRAPPER - -#ifndef SHORTCUTMAPPER_RC_H #include "ShortcutMapper_rc.h" -#endif //SHORTCUTMAPPER_RC_H - -#ifndef SHORTCUTS_H #include "shortcut.h" -#endif// SHORTCUTS_H - -#ifndef CONTEXTMENU_H #include "ContextMenu.h" -#endif// CONTEXTMENU_H enum GridState {STATE_MENU, STATE_MACRO, STATE_USER, STATE_PLUGIN, STATE_SCINTILLA}; @@ -69,11 +57,11 @@ public: { DLGTEMPLATE *pMyDlgTemplate = NULL; HGLOBAL hMyDlgTemplate = makeRTLResource(IDD_SHORTCUTMAPPER_DLG, &pMyDlgTemplate); - ::DialogBoxIndirectParam(_hInst, pMyDlgTemplate, _hParent, dlgProc, (LPARAM)this); + ::DialogBoxIndirectParam(_hInst, pMyDlgTemplate, _hParent, dlgProc, reinterpret_cast(this)); ::GlobalFree(hMyDlgTemplate); } else - ::DialogBoxParam(_hInst, MAKEINTRESOURCE(IDD_SHORTCUTMAPPER_DLG), _hParent, dlgProc, (LPARAM)this); + ::DialogBoxParam(_hInst, MAKEINTRESOURCE(IDD_SHORTCUTMAPPER_DLG), _hParent, dlgProc, reinterpret_cast(this)); }; void getClientRect(RECT & rc) const; void translateTab(int index, const TCHAR * newname); @@ -96,4 +84,3 @@ private: void fillOutBabyGrid(); }; -#endif //SHORTCUTMAPPER diff --git a/PowerEditor/src/WinControls/ImageListSet/ImageListSet.h b/PowerEditor/src/WinControls/ImageListSet/ImageListSet.h index 6ebbea91..8dd09ec9 100644 --- a/PowerEditor/src/WinControls/ImageListSet/ImageListSet.h +++ b/PowerEditor/src/WinControls/ImageListSet/ImageListSet.h @@ -26,8 +26,7 @@ // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -#ifndef IMAGE_LIST_H -#define IMAGE_LIST_H +#pragma once #include #include @@ -39,7 +38,7 @@ const int nbMax = 45; class IconList { public : - IconList() : _hImglst(NULL) {}; + IconList() {}; void create(HINSTANCE hInst, int iconSize); void create(int iconSize, HINSTANCE hInst, int *iconIDArray, int iconIDArraySize); @@ -52,11 +51,11 @@ public : void setIconSize(int size) const; private : - HIMAGELIST _hImglst; - HINSTANCE _hInst; - int *_pIconIDArray; - int _iconIDArraySize; - int _iconSize; + HIMAGELIST _hImglst = nullptr; + HINSTANCE _hInst = nullptr; + int *_pIconIDArray = nullptr; + int _iconIDArraySize = 0; + int _iconSize = 0; }; typedef struct @@ -139,4 +138,3 @@ private : unsigned int _nbCmd; }; -#endif //IMAGE_LIST_H diff --git a/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp b/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp index 0e0c2040..975ff95d 100644 --- a/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp +++ b/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp @@ -637,7 +637,7 @@ INT_PTR CALLBACK MarginsDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lPa { HWND hCaretBlikRateSlider = ::GetDlgItem(_hSelf, IDC_CARETBLINKRATE_SLIDER); HWND hBorderWidthSlider = ::GetDlgItem(_hSelf, IDC_BORDERWIDTH_SLIDER); - if ((HWND)lParam == hCaretBlikRateSlider) + if (reinterpret_cast(lParam) == hCaretBlikRateSlider) { int blinkRate = (int)::SendMessage(hCaretBlikRateSlider, TBM_GETPOS, 0, 0); if (blinkRate == BLINKRATE_SLOWEST) @@ -646,7 +646,7 @@ INT_PTR CALLBACK MarginsDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lPa ::SendMessage(::GetParent(_hParent), NPPM_INTERNAL_SETCARETBLINKRATE, 0, 0); } - else if ((HWND)lParam == hBorderWidthSlider) + else if (reinterpret_cast(lParam) == hBorderWidthSlider) { int borderWidth = (int)::SendMessage(hBorderWidthSlider, TBM_GETPOS, 0, 0); ScintillaViewParams & svp = (ScintillaViewParams &)pNppParam->getSVP(); @@ -2912,12 +2912,9 @@ INT_PTR CALLBACK SettingsOnCloudDlg::run_dlgProc(UINT Message, WPARAM wParam, LP { case WM_INITDIALOG: { - // Default settings: no cloud - bool withCloud = false; - generic_string message = TEXT(""); - withCloud = nppGUI._cloudPath != TEXT(""); + bool withCloud = nppGUI._cloudPath != TEXT(""); if (withCloud) { // detect validation of path diff --git a/PowerEditor/src/WinControls/ProjectPanel/ProjectPanel.cpp b/PowerEditor/src/WinControls/ProjectPanel/ProjectPanel.cpp index 5bed9637..0d17a726 100644 --- a/PowerEditor/src/WinControls/ProjectPanel/ProjectPanel.cpp +++ b/PowerEditor/src/WinControls/ProjectPanel/ProjectPanel.cpp @@ -1202,10 +1202,10 @@ int FileRelocalizerDlg::doDialog(const TCHAR *fn, bool isRTL) { DLGTEMPLATE *pMyDlgTemplate = NULL; HGLOBAL hMyDlgTemplate = makeRTLResource(IDD_FILERELOCALIZER_DIALOG, &pMyDlgTemplate); - int result = static_cast(::DialogBoxIndirectParam(_hInst, pMyDlgTemplate, _hParent, dlgProc, (LPARAM)this)); + int result = static_cast(::DialogBoxIndirectParam(_hInst, pMyDlgTemplate, _hParent, dlgProc, reinterpret_cast(this))); ::GlobalFree(hMyDlgTemplate); return result; } - return static_cast(::DialogBoxParam(_hInst, MAKEINTRESOURCE(IDD_FILERELOCALIZER_DIALOG), _hParent, dlgProc, (LPARAM)this)); + return static_cast(::DialogBoxParam(_hInst, MAKEINTRESOURCE(IDD_FILERELOCALIZER_DIALOG), _hParent, dlgProc, reinterpret_cast(this))); } diff --git a/PowerEditor/src/WinControls/ReadDirectoryChanges/ReadDirectoryChangesPrivate.h b/PowerEditor/src/WinControls/ReadDirectoryChanges/ReadDirectoryChangesPrivate.h index 9fb07aa3..cd7beeb7 100644 --- a/PowerEditor/src/WinControls/ReadDirectoryChanges/ReadDirectoryChangesPrivate.h +++ b/PowerEditor/src/WinControls/ReadDirectoryChanges/ReadDirectoryChangesPrivate.h @@ -104,7 +104,7 @@ protected: class CReadChangesServer { public: - CReadChangesServer(CReadDirectoryChanges* pParent) + explicit CReadChangesServer(CReadDirectoryChanges* pParent) { m_bTerminate=false; m_nOutstandingRequests=0;m_pBase=pParent; } diff --git a/PowerEditor/src/WinControls/StaticDialog/RunDlg/RunDlg.h b/PowerEditor/src/WinControls/StaticDialog/RunDlg/RunDlg.h index a2d7a597..4503af71 100644 --- a/PowerEditor/src/WinControls/StaticDialog/RunDlg/RunDlg.h +++ b/PowerEditor/src/WinControls/StaticDialog/RunDlg/RunDlg.h @@ -43,8 +43,8 @@ void expandNppEnvironmentStrs(const TCHAR *strSrc, TCHAR *stringDest, size_t str class Command { public : Command(){}; - Command(TCHAR *cmd) : _cmdLine(cmd){}; - Command(generic_string cmd) : _cmdLine(cmd){}; + explicit Command(TCHAR *cmd) : _cmdLine(cmd){}; + explicit Command(generic_string cmd) : _cmdLine(cmd){}; HINSTANCE run(HWND hWnd); protected : diff --git a/PowerEditor/src/WinControls/TabBar/ControlsTab.h b/PowerEditor/src/WinControls/TabBar/ControlsTab.h index f105ea3e..286fbd59 100644 --- a/PowerEditor/src/WinControls/TabBar/ControlsTab.h +++ b/PowerEditor/src/WinControls/TabBar/ControlsTab.h @@ -26,14 +26,9 @@ // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -#ifndef CONTROLS_TAB_H -#define CONTROLS_TAB_H +#pragma once - -#ifndef TAB_BAR_H #include "TabBar.h" -#endif //TAB_BAR_H - #include "Window.h" #include "Common.h" @@ -82,9 +77,5 @@ public : private: WindowVector *_pWinVector = nullptr; int _current = 0; - bool _isVertical = false; }; - - -#endif //CONTROLS_TAB_H diff --git a/PowerEditor/src/WinControls/TabBar/TabBar.h b/PowerEditor/src/WinControls/TabBar/TabBar.h index e90657be..743b6c02 100644 --- a/PowerEditor/src/WinControls/TabBar/TabBar.h +++ b/PowerEditor/src/WinControls/TabBar/TabBar.h @@ -26,21 +26,14 @@ // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -#ifndef TAB_BAR_H -#define TAB_BAR_H +#pragma once #ifndef _WIN32_IE #define _WIN32_IE 0x0600 #endif //_WIN32_IE -#ifndef MENUCMDID_H #include "menuCmdID.h" -#endif //MENUCMDID_H - -#ifndef RESOURCE_H #include "resource.h" -#endif //RESOURCE_H - #include #include #include @@ -72,7 +65,7 @@ struct TBHDR class TabBar : public Window { public: - TabBar() : Window(), _nbItem(0), _hasImgLst(false), _hFont(NULL), _hLargeFont(NULL), _hVerticalFont(NULL), _hVerticalLargeFont(NULL){}; + TabBar() : Window() {}; virtual ~TabBar() {}; virtual void destroy(); virtual void init(HINSTANCE hInst, HWND hwnd, bool isVertical = false, bool isTraditional = false, bool isMultiLine = false); @@ -114,18 +107,18 @@ public: protected: - size_t _nbItem; - bool _hasImgLst; - HFONT _hFont; - HFONT _hLargeFont; - HFONT _hVerticalFont; - HFONT _hVerticalLargeFont; + size_t _nbItem = 0; + bool _hasImgLst = false; + HFONT _hFont = nullptr; + HFONT _hLargeFont = nullptr; + HFONT _hVerticalFont = nullptr; + HFONT _hVerticalLargeFont = nullptr; - int _ctrlID; - bool _isTraditional; + int _ctrlID = 0; + bool _isTraditional = false; - bool _isVertical; - bool _isMultiLine; + bool _isVertical = false; + bool _isMultiLine = false; long getRowCount() const { return long(::SendMessage(_hSelf, TCM_GETROWCOUNT, 0, 0)); @@ -148,8 +141,7 @@ struct CloseButtonZone class TabBarPlus : public TabBar { public : - TabBarPlus() : TabBar(), _isDragging(false), _tabBarDefaultProc(NULL), _currentHoverTabItem(-1),\ - _isCloseHover(false), _whichCloseClickDown(-1), _lmbdHit(false), _tooltips(NULL) {}; + TabBarPlus() : TabBar() {}; enum tabColourIndex { activeText, activeFocusedTop, activeUnfocusedTop, inactiveText, inactiveBg }; @@ -229,21 +221,21 @@ protected: // it's the boss to decide if we do the drag N drop static bool _doDragNDrop; // drag N drop members - bool _isDragging; - bool _isDraggingInside; - int _nSrcTab; - int _nTabDragged; + bool _isDragging = false; + bool _isDraggingInside = false; + int _nSrcTab = -1; + int _nTabDragged = -1; POINT _draggingPoint; // coordinate of Screen - WNDPROC _tabBarDefaultProc; + WNDPROC _tabBarDefaultProc = nullptr; RECT _currentHoverTabRect; - int _currentHoverTabItem; + int _currentHoverTabItem = -1; CloseButtonZone _closeButtonZone; - bool _isCloseHover; - int _whichCloseClickDown; - bool _lmbdHit; // Left Mouse Button Down Hit - HWND _tooltips; + bool _isCloseHover = false; + int _whichCloseClickDown = -1; + bool _lmbdHit = false; // Left Mouse Button Down Hit + HWND _tooltips = nullptr; LRESULT runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam); @@ -294,5 +286,3 @@ protected: (screenPoint.y >= parentZone.top) && (screenPoint.y <= parentZone.bottom)); } }; - -#endif // TAB_BAR_H diff --git a/PowerEditor/src/WinControls/TaskList/TaskList.h b/PowerEditor/src/WinControls/TaskList/TaskList.h index 1ab8664d..a87feed5 100644 --- a/PowerEditor/src/WinControls/TaskList/TaskList.h +++ b/PowerEditor/src/WinControls/TaskList/TaskList.h @@ -40,7 +40,7 @@ class TaskList : public Window { public: - TaskList() : Window(), _currentIndex(0), _hFont(NULL), _hFontSelected(NULL) { + TaskList() : Window() { _rc.left = 0; _rc.top = 0; _rc.right = 150; @@ -70,10 +70,10 @@ protected: return (((TaskList *)(::GetWindowLongPtr(hwnd, GWLP_USERDATA)))->runProc(hwnd, Message, wParam, lParam)); }; - HFONT _hFont; - HFONT _hFontSelected; - int _nbItem; - int _currentIndex; + HFONT _hFont = nullptr; + HFONT _hFontSelected = nullptr; + int _nbItem = 0; + int _currentIndex = 0; RECT _rc; }; diff --git a/PowerEditor/src/WinControls/TaskList/TaskListDlg.cpp b/PowerEditor/src/WinControls/TaskList/TaskListDlg.cpp index 326a16a3..dddcd038 100644 --- a/PowerEditor/src/WinControls/TaskList/TaskListDlg.cpp +++ b/PowerEditor/src/WinControls/TaskList/TaskListDlg.cpp @@ -47,11 +47,11 @@ LRESULT CALLBACK hookProc(UINT nCode, WPARAM wParam, LPARAM lParam) { DLGTEMPLATE *pMyDlgTemplate = NULL; HGLOBAL hMyDlgTemplate = makeRTLResource(IDD_VALUE_DLG, &pMyDlgTemplate); - int result = static_cast(::DialogBoxIndirectParam(_hInst, pMyDlgTemplate, _hParent, dlgProc, (LPARAM)this)); + int result = static_cast(::DialogBoxIndirectParam(_hInst, pMyDlgTemplate, _hParent, dlgProc, reinterpret_cast(this))); ::GlobalFree(hMyDlgTemplate); return result; } - return static_cast(::DialogBoxParam(_hInst, MAKEINTRESOURCE(IDD_TASKLIST_DLG), _hParent, dlgProc, (LPARAM)this)); + return static_cast(::DialogBoxParam(_hInst, MAKEINTRESOURCE(IDD_TASKLIST_DLG), _hParent, dlgProc, reinterpret_cast(this))); } INT_PTR CALLBACK TaskListDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lParam) diff --git a/PowerEditor/src/WinControls/TaskList/TaskListDlg.h b/PowerEditor/src/WinControls/TaskList/TaskListDlg.h index e11343e4..fff2ecdd 100644 --- a/PowerEditor/src/WinControls/TaskList/TaskListDlg.h +++ b/PowerEditor/src/WinControls/TaskList/TaskListDlg.h @@ -26,37 +26,23 @@ // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -#ifndef TASKLISTDLG_H -#define TASKLISTDLG_H +#pragma once #include "Common.h" #include "StaticDialog.h" - -#ifndef TASKLISTDLGRC_H #include "TaskListDlg_rc.h" -#endif //TASKLISTDLGRC_H - -#ifndef TASKLIST_H #include "TaskList.h" -#endif //TASKLIST_H -/* -#ifndef IMAGE_LIST_H -#include "ImageListSet.h" -#endif //IMAGE_LIST_H -*/ -#ifndef NOTEPAD_PLUS_MSGS_H #include "Notepad_plus_msgs.h" -#endif //NOTEPAD_PLUS_MSGS_H #define TASKLIST_USER (WM_USER + 8000) - #define WM_GETTASKLISTINFO (TASKLIST_USER + 01) +#define WM_GETTASKLISTINFO (TASKLIST_USER + 01) struct TaskLstFnStatus { - int _iView; - int _docIndex; + int _iView = -1; + int _docIndex = 0; generic_string _fn; - int _status; - void *_bufID; + int _status = 0; + void *_bufID = nullptr; TaskLstFnStatus(generic_string str, int status) : _fn(str), _status(status){}; TaskLstFnStatus(int iView, int docIndex, generic_string str, int status, void *bufID) : _iView(iView), _docIndex(docIndex), _fn(str), _status(status), _bufID(bufID) {}; @@ -64,7 +50,7 @@ struct TaskLstFnStatus { struct TaskListInfo { std::vector _tlfsLst; - int _currentIndex; + int _currentIndex = -1; }; static HWND hWndServer = NULL; @@ -91,11 +77,9 @@ private : TaskList _taskList; TaskListInfo _taskListInfo; HIMAGELIST _hImalist; - bool _initDir; - HHOOK _hHooker; + bool _initDir = false; + HHOOK _hHooker = nullptr; void drawItem(LPDRAWITEMSTRUCT lpDrawItemStruct); }; - -#endif // TASKLISTDLG_H diff --git a/PowerEditor/src/WinControls/ToolBar/ToolBar.cpp b/PowerEditor/src/WinControls/ToolBar/ToolBar.cpp index 4f30307a..77f71d27 100644 --- a/PowerEditor/src/WinControls/ToolBar/ToolBar.cpp +++ b/PowerEditor/src/WinControls/ToolBar/ToolBar.cpp @@ -350,33 +350,38 @@ void ToolBar::registerDynBtn(UINT messageID, toolbarIcons* tIcon) } } -void ToolBar::doPopop(POINT chevPoint) { +void ToolBar::doPopop(POINT chevPoint) +{ //first find hidden buttons int width = Window::getWidth(); size_t start = 0; RECT btnRect = {0,0,0,0}; - while(start < _nrCurrentButtons) { + while(start < _nrCurrentButtons) + { ::SendMessage(_hSelf, TB_GETITEMRECT, start, (LPARAM)&btnRect); if(btnRect.right > width) break; ++start; } - if (start < _nrCurrentButtons) { //some buttons are hidden + if (start < _nrCurrentButtons) + { //some buttons are hidden HMENU menu = ::CreatePopupMenu(); - int cmd; generic_string text; - while (start < _nrCurrentButtons) { - cmd = _pTBB[start].idCommand; + while (start < _nrCurrentButtons) + { + int cmd = _pTBB[start].idCommand; getNameStrFromCmd(cmd, text); - if (_pTBB[start].idCommand != 0) { + if (_pTBB[start].idCommand != 0) + { if (::SendMessage(_hSelf, TB_ISBUTTONENABLED, cmd, 0) != 0) AppendMenu(menu, MF_ENABLED, cmd, text.c_str()); else AppendMenu(menu, MF_DISABLED|MF_GRAYED, cmd, text.c_str()); } else AppendMenu(menu, MF_SEPARATOR, 0, TEXT("")); + ++start; } TrackPopupMenu(menu, 0, chevPoint.x, chevPoint.y, 0, _hSelf, NULL); @@ -513,11 +518,10 @@ void ReBar::setGrayBackground(int id) int ReBar::getNewID() { int idToUse = REBAR_BAR_EXTERNAL; - int curVal = 0; size_t size = usedIDs.size(); for(size_t i = 0; i < size; ++i) { - curVal = usedIDs.at(i); + int curVal = usedIDs.at(i); if (curVal < idToUse) { continue; diff --git a/PowerEditor/src/WinControls/ToolBar/ToolBar.h b/PowerEditor/src/WinControls/ToolBar/ToolBar.h index 6db67f13..24cbe8f9 100644 --- a/PowerEditor/src/WinControls/ToolBar/ToolBar.h +++ b/PowerEditor/src/WinControls/ToolBar/ToolBar.h @@ -42,7 +42,7 @@ #define _WIN32_IE 0x0600 #endif //_WIN32_IE -enum toolBarStatusType {/*TB_HIDE, */TB_SMALL, TB_LARGE, TB_STANDARD}; +enum toolBarStatusType {TB_SMALL, TB_LARGE, TB_STANDARD}; typedef struct { @@ -67,7 +67,7 @@ class TiXmlNode; class ToolBar : public Window { public : - ToolBar():Window(), _pTBB(NULL), _nrButtons(0), _nrDynButtons(0), _nrTotalButtons(0), _nrCurrentButtons(0), _pRebar(NULL) {}; + ToolBar():Window() {}; virtual ~ToolBar(){}; void initTheme(TiXmlDocument *toolIconsDocRoot); @@ -117,19 +117,18 @@ public : void addToRebar(ReBar * rebar); private : - TBBUTTON *_pTBB; + TBBUTTON *_pTBB = nullptr; ToolBarIcons _toolBarIcons; - toolBarStatusType _state; + toolBarStatusType _state = TB_SMALL; std::vector _vDynBtnReg; - size_t _nrButtons; - size_t _nrDynButtons; - size_t _nrTotalButtons; - size_t _nrCurrentButtons; - ReBar * _pRebar; + size_t _nrButtons = 0; + size_t _nrDynButtons = 0; + size_t _nrTotalButtons = 0; + size_t _nrCurrentButtons = 0; + ReBar * _pRebar = nullptr; REBARBANDINFO _rbBand; std::vector _customIconVect; - TiXmlNode *_toolIcons; - + TiXmlNode *_toolIcons = nullptr; void setDefaultImageList() { ::SendMessage(_hSelf, TB_SETIMAGELIST , (WPARAM)0, (LPARAM)_toolBarIcons.getDefaultLst()); diff --git a/PowerEditor/src/WinControls/WindowsDlg/SizeableDlg.h b/PowerEditor/src/WinControls/WindowsDlg/SizeableDlg.h index 170f1204..5bf0922d 100644 --- a/PowerEditor/src/WinControls/WindowsDlg/SizeableDlg.h +++ b/PowerEditor/src/WinControls/WindowsDlg/SizeableDlg.h @@ -42,7 +42,7 @@ class SizeableDlg : public StaticDialog { typedef StaticDialog MyBaseClass; public: - SizeableDlg(WINRECT* pWinMap); + explicit SizeableDlg(WINRECT* pWinMap); protected: CWinMgr _winMgr; // window manager diff --git a/PowerEditor/src/WinControls/WindowsDlg/WinMgr.h b/PowerEditor/src/WinControls/WindowsDlg/WinMgr.h index dbfe934b..0442e095 100644 --- a/PowerEditor/src/WinControls/WindowsDlg/WinMgr.h +++ b/PowerEditor/src/WinControls/WindowsDlg/WinMgr.h @@ -225,7 +225,7 @@ struct NMWINMGR : public NMHDR { // class CWinMgr /*: public CObject*/ { public: - CWinMgr(WINRECT* map); + explicit CWinMgr(WINRECT* map); virtual ~CWinMgr(); virtual void GetWindowPositions(HWND hWnd); // load map from window posns diff --git a/PowerEditor/src/WinControls/WindowsDlg/WindowsDlg.cpp b/PowerEditor/src/WinControls/WindowsDlg/WindowsDlg.cpp index f9ecb197..4c4ca114 100644 --- a/PowerEditor/src/WinControls/WindowsDlg/WindowsDlg.cpp +++ b/PowerEditor/src/WinControls/WindowsDlg/WindowsDlg.cpp @@ -199,7 +199,7 @@ END_WINDOW_MAP() RECT WindowsDlg::_lastKnownLocation; -WindowsDlg::WindowsDlg() : MyBaseClass(WindowsDlgMap), _isSorted(false) +WindowsDlg::WindowsDlg() : MyBaseClass(WindowsDlgMap) { _szMinButton = SIZEZERO; _szMinListCtrl = SIZEZERO; @@ -429,7 +429,7 @@ void WindowsDlg::updateButtonState() int WindowsDlg::doDialog(TiXmlNodeA *dlgNode) { _dlgNode = dlgNode; - return (int)::DialogBoxParam(_hInst, MAKEINTRESOURCE(IDD_WINDOWS), _hParent, dlgProc, (LPARAM)this); + return (int)::DialogBoxParam(_hInst, MAKEINTRESOURCE(IDD_WINDOWS), _hParent, dlgProc, reinterpret_cast(this)); }; bool WindowsDlg::changeDlgLang() diff --git a/PowerEditor/src/WinControls/WindowsDlg/WindowsDlg.h b/PowerEditor/src/WinControls/WindowsDlg/WindowsDlg.h index 5f7dcd53..958472f5 100644 --- a/PowerEditor/src/WinControls/WindowsDlg/WindowsDlg.h +++ b/PowerEditor/src/WinControls/WindowsDlg/WindowsDlg.h @@ -26,8 +26,7 @@ // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -#ifndef WINDOWS_DLG_H -#define WINDOWS_DLG_H +#pragma once #include "SizeableDlg.h" #include "Common.h" @@ -91,15 +90,15 @@ protected : void updateButtonState(); void activateCurrent(); - HWND _hList; + HWND _hList = nullptr; static RECT _lastKnownLocation; SIZE _szMinButton; SIZE _szMinListCtrl; - DocTabView *_pTab; + DocTabView *_pTab = nullptr; std::vector _idxMap; - int _lastSort; - bool _isSorted; - TiXmlNodeA *_dlgNode; + int _lastSort = -1; + bool _isSorted = false; + TiXmlNodeA *_dlgNode = nullptr; private: virtual void init(HINSTANCE hInst, HWND parent); @@ -111,12 +110,9 @@ public: WindowsMenu(); ~WindowsMenu(); void init(HINSTANCE hInst, HMENU hMainMenu, const TCHAR *translation); - //void initMenu(HMENU hMenu, ScintillaEditView *pView); void initPopupMenu(HMENU hMenu, DocTabView *pTab); - //void uninitPopupMenu(HMENU hMenu, ScintillaEditView *pView); + private: HMENU _hMenu; }; - -#endif //WINDOWS_DLG_H diff --git a/PowerEditor/src/WinControls/shortcut/RunMacroDlg.h b/PowerEditor/src/WinControls/shortcut/RunMacroDlg.h index 4d6138ce..73c19356 100644 --- a/PowerEditor/src/WinControls/shortcut/RunMacroDlg.h +++ b/PowerEditor/src/WinControls/shortcut/RunMacroDlg.h @@ -27,13 +27,9 @@ // created by Daniel Volk mordorpost@volkarts.com -#ifndef RUN_MACRO_DLG_H -#define RUN_MACRO_DLG_H +#pragma once -#ifndef RUN_MACRO_DLG_RC_H #include "RunMacroDlg_rc.h" -#endif //RUN_MACRO_DLG_RC_H - #include "StaticDialog.h" #define RM_CANCEL -1 @@ -43,7 +39,7 @@ class RunMacroDlg : public StaticDialog { public : - RunMacroDlg() : StaticDialog(), _mode(RM_RUN_MULTI), _times(1) {}; + RunMacroDlg() : StaticDialog() {}; ~RunMacroDlg() { }; @@ -68,9 +64,7 @@ private : virtual INT_PTR CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam); void check(int); - int _mode; - int _times; - int _macroIndex; + int _mode = RM_RUN_MULTI; + int _times = 1; + int _macroIndex = 0; }; - -#endif //RUN_MACRO_DLG_H diff --git a/PowerEditor/src/WinControls/shortcut/shortcut.cpp b/PowerEditor/src/WinControls/shortcut/shortcut.cpp index 43440022..f5d7d15e 100644 --- a/PowerEditor/src/WinControls/shortcut/shortcut.cpp +++ b/PowerEditor/src/WinControls/shortcut/shortcut.cpp @@ -589,7 +589,7 @@ void Accelerator::updateMenuItemByCommand(CommandShortcut csc) // Ensure that the menu item checks set prior to this update remain in affect. UINT cmdFlags = GetMenuState(_hAccelMenu, cmdID, MF_BYCOMMAND ); - cmdFlags = MF_BYCOMMAND | (cmdFlags&MF_CHECKED) ? ( MF_CHECKED ) : ( MF_UNCHECKED ); + cmdFlags = MF_BYCOMMAND | ((cmdFlags&MF_CHECKED) ? MF_CHECKED : MF_UNCHECKED); ::ModifyMenu(_hAccelMenu, cmdID, cmdFlags, cmdID, csc.toMenuItemString().c_str()); } diff --git a/PowerEditor/src/WinControls/shortcut/shortcut.h b/PowerEditor/src/WinControls/shortcut/shortcut.h index 87c8cf85..2a5dddea 100644 --- a/PowerEditor/src/WinControls/shortcut/shortcut.h +++ b/PowerEditor/src/WinControls/shortcut/shortcut.h @@ -26,17 +26,10 @@ // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -#ifndef SHORTCUTS_H -#define SHORTCUTS_H +#pragma once -#ifndef IDD_SHORTCUT_DLG #include "shortcutRc.h" -#endif //IDD_SHORTCUT_DLG - -#ifndef SCINTILLA_H #include "Scintilla.h" -#endif //SCINTILLA_H - #include "StaticDialog.h" #include "Common.h" @@ -139,7 +132,7 @@ public: virtual INT_PTR doDialog() { - return ::DialogBoxParam(_hInst, MAKEINTRESOURCE(IDD_SHORTCUT_DLG), _hParent, dlgProc, (LPARAM)this); + return ::DialogBoxParam(_hInst, MAKEINTRESOURCE(IDD_SHORTCUT_DLG), _hParent, dlgProc, reinterpret_cast(this)); }; virtual bool isValid() const { //valid should only be used in cases where the shortcut isEnabled(). @@ -233,7 +226,7 @@ public: INT_PTR doDialog() { - return ::DialogBoxParam(_hInst, MAKEINTRESOURCE(IDD_SHORTCUTSCINT_DLG), _hParent, dlgProc, (LPARAM)this); + return ::DialogBoxParam(_hInst, MAKEINTRESOURCE(IDD_SHORTCUTSCINT_DLG), _hParent, dlgProc, reinterpret_cast(this)); }; //only compares the internal KeyCombos, nothing else @@ -277,15 +270,15 @@ class ScintillaEditView; struct recordedMacroStep { enum MacroTypeIndex {mtUseLParameter, mtUseSParameter, mtMenuCommand, mtSavedSnR}; - - int _message; - long _wParameter; - long _lParameter; + + int _message = 0; + long _wParameter = 0; + long _lParameter = 0; generic_string _sParameter; - MacroTypeIndex _macroType; + MacroTypeIndex _macroType = mtMenuCommand; recordedMacroStep(int iMessage, long wParam, long lParam, int codepage); - recordedMacroStep(int iCommandID) : _message(0), _wParameter(iCommandID), _lParameter(0), _macroType(mtMenuCommand) {}; + explicit recordedMacroStep(int iCommandID): _wParameter(iCommandID) {}; recordedMacroStep(int iMessage, long wParam, long lParam, const TCHAR *sParam, int type) : _message(iMessage), _wParameter(wParam), _lParameter(lParam), _macroType(MacroTypeIndex(type)){ @@ -391,5 +384,3 @@ private: void updateMenuItemByID(ScintillaKeyMap skm, int id); }; - -#endif //SHORTCUTS_H diff --git a/PowerEditor/src/lastRecentFileList.h b/PowerEditor/src/lastRecentFileList.h index 4d76b49a..4dc82672 100644 --- a/PowerEditor/src/lastRecentFileList.h +++ b/PowerEditor/src/lastRecentFileList.h @@ -26,19 +26,15 @@ // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -#ifndef LASTRECENTFILELIST_H -#define LASTRECENTFILELIST_H +#pragma once -#ifndef PARAMETERS_H #include "Parameters.h" -#endif //PARAMETERS_H - #include struct RecentItem { int _id = 0; generic_string _name; - RecentItem(const TCHAR * name) : _name(name) {}; + explicit RecentItem(const TCHAR * name) : _name(name) {}; }; typedef std::deque recentList; @@ -46,7 +42,7 @@ typedef std::deque recentList; class LastRecentFileList { public: - LastRecentFileList() : _hasSeparators(false), _size(0), _locked(false) { + LastRecentFileList() { _userMax = (NppParameters::getInstance())->getNbMaxRecentFile(); }; @@ -99,19 +95,19 @@ public: private: recentList _lrfl; - Accelerator *_pAccelerator; - int _userMax; - int _size; - int _nativeLangEncoding; + Accelerator *_pAccelerator = nullptr; + int _userMax = 0; + int _size = 0; + int _nativeLangEncoding = -1; // For the menu - HMENU _hParentMenu; - HMENU _hMenu; - int _posBase; - int _idBase; + HMENU _hParentMenu = nullptr; + HMENU _hMenu = nullptr; + int _posBase = -1; + int _idBase = -1; bool _idFreeArray[NB_MAX_LRF_FILE]; - bool _hasSeparators; - bool _locked; + bool _hasSeparators = false; + bool _locked = false; int find(const TCHAR *fn); @@ -119,4 +115,3 @@ private: void setAvailable(int id); }; -#endif //LASTRECENTFILELIST_H diff --git a/PowerEditor/src/lesDlgs.cpp b/PowerEditor/src/lesDlgs.cpp index a4fd3b34..3c087a5f 100644 --- a/PowerEditor/src/lesDlgs.cpp +++ b/PowerEditor/src/lesDlgs.cpp @@ -45,11 +45,11 @@ int ValueDlg::doDialog(POINT p, bool isRTL) { DLGTEMPLATE *pMyDlgTemplate = NULL; HGLOBAL hMyDlgTemplate = makeRTLResource(IDD_VALUE_DLG, &pMyDlgTemplate); - int result = static_cast(::DialogBoxIndirectParam(_hInst, pMyDlgTemplate, _hParent, dlgProc, (LPARAM)this)); + int result = static_cast(::DialogBoxIndirectParam(_hInst, pMyDlgTemplate, _hParent, dlgProc, reinterpret_cast(this))); ::GlobalFree(hMyDlgTemplate); return result; } - return static_cast(::DialogBoxParam(_hInst, MAKEINTRESOURCE(IDD_VALUE_DLG), _hParent, dlgProc, (LPARAM)this)); + return static_cast(::DialogBoxParam(_hInst, MAKEINTRESOURCE(IDD_VALUE_DLG), _hParent, dlgProc, reinterpret_cast(this))); }