From d4bcec1c01d1a549416c38e9c7abd689c53ddcbf Mon Sep 17 00:00:00 2001 From: Don HO Date: Thu, 11 Aug 2016 22:20:30 +0200 Subject: [PATCH] Lost in Translation 3 --- PowerEditor/src/MISC/Common/Common.cpp | 10 ++-- PowerEditor/src/Notepad_plus.cpp | 4 +- PowerEditor/src/NppBigSwitch.cpp | 16 +++---- PowerEditor/src/Parameters.cpp | 20 ++++---- .../src/ScitillaComponent/AutoCompletion.cpp | 10 ++-- .../src/ScitillaComponent/FindReplaceDlg.cpp | 4 +- .../ScitillaComponent/ScintillaEditView.cpp | 4 +- .../ScitillaComponent/SmartHighlighter.cpp | 15 +++--- .../ScitillaComponent/UserDefineDialog.cpp | 7 +-- .../xmlMatchedTagsHighlighter.cpp | 4 +- PowerEditor/src/TinyXml/tinyXmlA/tinyxmlA.cpp | 6 +-- .../src/TinyXml/tinyXmlA/tinyxmlparserA.cpp | 34 +++++++------- PowerEditor/src/TinyXml/tinyxmlparser.cpp | 22 ++++----- .../WinControls/AnsiCharPanel/ListView.cpp | 10 ++-- .../AnsiCharPanel/ansiCharPanel.cpp | 4 +- .../clipboardHistoryPanel.cpp | 4 +- .../WinControls/ColourPicker/WordStyleDlg.cpp | 4 +- .../WinControls/FileBrowser/fileBrowser.cpp | 27 ++--------- .../FindCharsInRange/FindCharsInRange.cpp | 8 ++-- .../FunctionList/functionListPanel.cpp | 2 +- PowerEditor/src/WinControls/Grid/BabyGrid.cpp | 2 +- .../src/WinControls/Grid/BabyGridWrapper.cpp | 4 +- .../src/WinControls/Grid/ShortcutMapper.cpp | 6 ++- .../WinControls/Preference/preferenceDlg.cpp | 5 +- .../WinControls/ProjectPanel/ProjectPanel.cpp | 4 +- .../StaticDialog/RunDlg/RunDlg.cpp | 3 +- .../src/WinControls/StatusBar/StatusBar.cpp | 2 +- .../VerticalFileSwitcher.cpp | 2 +- .../VerticalFileSwitcherListView.cpp | 6 +-- .../src/WinControls/WindowsDlg/WinMgr.cpp | 2 +- .../src/WinControls/WindowsDlg/WinMgr.h | 4 +- .../src/WinControls/shortcut/shortcut.cpp | 46 +++++++++++-------- .../src/WinControls/shortcut/shortcut.h | 14 +++--- PowerEditor/src/lastRecentFileList.cpp | 2 +- PowerEditor/src/uchardet/CharDistribution.h | 4 +- PowerEditor/src/winmain.cpp | 4 +- 36 files changed, 161 insertions(+), 164 deletions(-) diff --git a/PowerEditor/src/MISC/Common/Common.cpp b/PowerEditor/src/MISC/Common/Common.cpp index 24f3bbe41..5e3600c9a 100644 --- a/PowerEditor/src/MISC/Common/Common.cpp +++ b/PowerEditor/src/MISC/Common/Common.cpp @@ -589,11 +589,11 @@ generic_string intToString(int val) // can't use abs here because std::numeric_limits::min() has no positive representation //val = std::abs(val); - vt.push_back('0' + (TCHAR)(std::abs(val % 10))); + vt.push_back('0' + static_cast(std::abs(val % 10))); val /= 10; while (val != 0) { - vt.push_back('0' + (TCHAR)(std::abs(val % 10))); + vt.push_back('0' + static_cast(std::abs(val % 10))); val /= 10; } @@ -608,11 +608,11 @@ generic_string uintToString(unsigned int val) { std::vector vt; - vt.push_back('0' + (TCHAR)(val % 10)); + vt.push_back('0' + static_cast(val % 10)); val /= 10; while (val != 0) { - vt.push_back('0' + (TCHAR)(val % 10)); + vt.push_back('0' + static_cast(val % 10)); val /= 10; } @@ -627,7 +627,7 @@ generic_string BuildMenuFileName(int filenameLen, unsigned int pos, const generi if (pos < 9) { strTemp.push_back('&'); - strTemp.push_back('1' + (TCHAR)pos); + strTemp.push_back('1' + static_cast(pos)); } else if (pos == 9) { diff --git a/PowerEditor/src/Notepad_plus.cpp b/PowerEditor/src/Notepad_plus.cpp index c0a514500..a79290157 100644 --- a/PowerEditor/src/Notepad_plus.cpp +++ b/PowerEditor/src/Notepad_plus.cpp @@ -2448,7 +2448,7 @@ int Notepad_plus::findMachedBracePos(size_t startPos, size_t endPos, char target int balance = 0; for (int i = int(startPos); i >= int(endPos); --i) { - char aChar = (char)_pEditView->execute(SCI_GETCHARAT, i); + char aChar = static_cast(_pEditView->execute(SCI_GETCHARAT, i)); if (aChar == targetSymbol) { if (balance == 0) @@ -2892,7 +2892,7 @@ size_t Notepad_plus::getSelectedCharNumber(UniMode u) size_t endpos = _pEditView->execute(SCI_GETLINESELENDPOSITION, j); for (size_t pos = stpos; pos < endpos; ++pos) { - unsigned char c = 0xf0 & (unsigned char)_pEditView->execute(SCI_GETCHARAT, pos); + unsigned char c = 0xf0 & static_cast(_pEditView->execute(SCI_GETCHARAT, pos)); if (c >= 0xc0) pos += utflen[(c & 0x30) >> 4]; ++result; diff --git a/PowerEditor/src/NppBigSwitch.cpp b/PowerEditor/src/NppBigSwitch.cpp index 322ac4caf..5f8ee7946 100644 --- a/PowerEditor/src/NppBigSwitch.cpp +++ b/PowerEditor/src/NppBigSwitch.cpp @@ -811,12 +811,12 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa if (lParam != 0) { - for (int idx = 0; idx < (int)tli->_tlfsLst.size(); ++idx) + for (size_t idx = 0; idx < tli->_tlfsLst.size(); ++idx) { if (tli->_tlfsLst[idx]._iView == currentView() && tli->_tlfsLst[idx]._docIndex == _pDocTab->getCurrentTabIndex()) { - tli->_currentIndex = idx; + tli->_currentIndex = static_cast(idx); break; } } @@ -830,12 +830,12 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa } else { - for (int idx = 0; idx < (int)tli->_tlfsLst.size(); ++idx) + for (size_t idx = 0; idx < tli->_tlfsLst.size(); ++idx) { - if(tli->_tlfsLst[idx]._iView == currentView() && - tli->_tlfsLst[idx]._docIndex == _pDocTab->getCurrentTabIndex()) + if (tli->_tlfsLst[idx]._iView == currentView() && + tli->_tlfsLst[idx]._docIndex == _pDocTab->getCurrentTabIndex()) { - tli->_currentIndex = idx; + tli->_currentIndex = static_cast(idx); break; } } @@ -1882,7 +1882,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa case NPPM_SETMENUITEMCHECK: { ::CheckMenuItem(_mainMenuHandle, static_cast(wParam), MF_BYCOMMAND | (static_cast(lParam) ? MF_CHECKED : MF_UNCHECKED)); - _toolBar.setCheck((int)wParam, bool(lParam != 0)); + _toolBar.setCheck(static_cast(wParam), lParam != 0); return TRUE; } @@ -2202,7 +2202,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa case WM_INITMENUPOPUP: { - _windowsMenu.initPopupMenu((HMENU)wParam, _pDocTab); + _windowsMenu.initPopupMenu(reinterpret_cast(wParam), _pDocTab); return TRUE; } diff --git a/PowerEditor/src/Parameters.cpp b/PowerEditor/src/Parameters.cpp index 5fbdac00f..45ae7bfbd 100644 --- a/PowerEditor/src/Parameters.cpp +++ b/PowerEditor/src/Parameters.cpp @@ -1710,7 +1710,7 @@ void NppParameters::initMenuKeys() for(int i = 0; i < nrCommands; ++i) { wkd = winKeyDefs[i]; - Shortcut sc((wkd.specialName?wkd.specialName:TEXT("")), wkd.isCtrl, wkd.isAlt, wkd.isShift, (unsigned char)wkd.vKey); + Shortcut sc((wkd.specialName ? wkd.specialName : TEXT("")), wkd.isCtrl, wkd.isAlt, wkd.isShift, static_cast(wkd.vKey)); _shortcuts.push_back( CommandShortcut(sc, wkd.functionId) ); } } @@ -1732,12 +1732,14 @@ void NppParameters::initScintillaKeys() { kc._isCtrl = skd.isCtrl; kc._isAlt = skd.isAlt; kc._isShift = skd.isShift; - kc._key = (unsigned char)skd.vKey; + kc._key = static_cast(skd.vKey); _scintillaKeyCommands[prevIndex].addKeyCombo(kc); } else { - _scintillaKeyCommands.push_back(ScintillaKeyMap(Shortcut(skd.name, skd.isCtrl, skd.isAlt, skd.isShift, (unsigned char)skd.vKey), skd.functionId, skd.redirFunctionId)); + Shortcut s = Shortcut(skd.name, skd.isCtrl, skd.isAlt, skd.isShift, static_cast(skd.vKey)); + ScintillaKeyMap sm = ScintillaKeyMap(s, skd.functionId, skd.redirFunctionId); + _scintillaKeyCommands.push_back(sm); ++prevIndex; } prevID = skd.functionId; @@ -2435,7 +2437,7 @@ void NppParameters::feedScintKeys(TiXmlNode *node) str = (nextNode->ToElement())->Attribute(TEXT("Key"), &key); if (!str) continue; - kc._key = (unsigned char)key; + kc._key = static_cast(key); _scintillaKeyCommands[i].addKeyCombo(kc); } break; @@ -2490,7 +2492,7 @@ bool NppParameters::getShortcuts(TiXmlNode *node, Shortcut & sc) if (!keyStr) return false; - sc = Shortcut(name, isCtrl, isAlt, isShift, (unsigned char)key); + sc = Shortcut(name, isCtrl, isAlt, isShift, static_cast(key)); return true; } @@ -2902,7 +2904,7 @@ void NppParameters::writeSession(const Session & session, const TCHAR *fileName) if (root) { TiXmlNode *sessionNode = root->InsertEndChild(TiXmlElement(TEXT("Session"))); - (sessionNode->ToElement())->SetAttribute(TEXT("activeView"), (int)session._activeView); + (sessionNode->ToElement())->SetAttribute(TEXT("activeView"), static_cast(session._activeView)); struct ViewElem { TiXmlNode *viewNode; @@ -2920,7 +2922,7 @@ void NppParameters::writeSession(const Session & session, const TCHAR *fileName) for (size_t k = 0; k < nbElem ; ++k) { - (viewElems[k].viewNode->ToElement())->SetAttribute(TEXT("activeIndex"), (int)viewElems[k].activeIndex); + (viewElems[k].viewNode->ToElement())->SetAttribute(TEXT("activeIndex"), static_cast(viewElems[k].activeIndex)); vector & viewSessionFiles = *(viewElems[k].viewFiles); for (size_t i = 0, len = viewElems[k].viewFiles->size(); i < len ; ++i) @@ -4637,12 +4639,12 @@ void NppParameters::feedGUIParameters(TiXmlNode *node) int leftmost = 0; element->Attribute(TEXT("leftmostDelimiter"), &leftmost); if(leftmost > 0 && leftmost < 256) - _nppGUI._leftmostDelimiter = (char)leftmost; + _nppGUI._leftmostDelimiter = static_cast(leftmost); int rightmost = 0; element->Attribute(TEXT("rightmostDelimiter"), &rightmost); if(rightmost > 0 && rightmost < 256) - _nppGUI._rightmostDelimiter = (char)rightmost; + _nppGUI._rightmostDelimiter = static_cast(rightmost); const TCHAR *delimiterSelectionOnEntireDocument = element->Attribute(TEXT("delimiterSelectionOnEntireDocument")); if(delimiterSelectionOnEntireDocument != NULL && !lstrcmp(delimiterSelectionOnEntireDocument, TEXT("yes"))) diff --git a/PowerEditor/src/ScitillaComponent/AutoCompletion.cpp b/PowerEditor/src/ScitillaComponent/AutoCompletion.cpp index c0ff618a9..48ba41c59 100644 --- a/PowerEditor/src/ScitillaComponent/AutoCompletion.cpp +++ b/PowerEditor/src/ScitillaComponent/AutoCompletion.cpp @@ -370,8 +370,8 @@ bool AutoCompletion::showFunctionComplete() void AutoCompletion::getCloseTag(char *closeTag, size_t closeTagSize, size_t caretPos, bool isHTML) { - char prev = (char)_pEditView->execute(SCI_GETCHARAT, caretPos - 2); - char prevprev = (char)_pEditView->execute(SCI_GETCHARAT, caretPos - 3); + char prev = static_cast(_pEditView->execute(SCI_GETCHARAT, caretPos - 2)); + char prevprev = static_cast(_pEditView->execute(SCI_GETCHARAT, caretPos - 3)); // Closing a tag (i.e. "-->") will be ignored if (prevprev == '-' && prev == '-') @@ -484,7 +484,7 @@ int InsertedMatchedChars::search(char startChar, char endChar, int posToDetect) for (int j = posToDetect; j <= endPos; ++j) { - char aChar = (char)_pEditView->execute(SCI_GETCHARAT, j); + char aChar = static_cast(_pEditView->execute(SCI_GETCHARAT, j)); if (aChar != ' ') // non space is not allowed { @@ -522,8 +522,8 @@ void AutoCompletion::insertMatchedChars(int character, const MatchedPairConf & m int caretPos = static_cast(_pEditView->execute(SCI_GETCURRENTPOS)); char *matchedChars = NULL; - char charPrev = (char)_pEditView->execute(SCI_GETCHARAT, caretPos - 2); - char charNext = (char)_pEditView->execute(SCI_GETCHARAT, caretPos); + char charPrev = static_cast(_pEditView->execute(SCI_GETCHARAT, caretPos - 2)); + char charNext = static_cast(_pEditView->execute(SCI_GETCHARAT, caretPos)); bool isCharPrevBlank = (charPrev == ' ' || charPrev == '\t' || charPrev == '\n' || charPrev == '\r' || charPrev == '\0'); int docLen = _pEditView->getCurrentDocLen(); diff --git a/PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp b/PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp index 390b847e8..659b9aea9 100644 --- a/PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp +++ b/PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp @@ -126,7 +126,7 @@ int Searching::convertExtendedToString(const TCHAR * query, TCHAR * result, int int res = 0; if (Searching::readBase(query+(i+1), &res, base, size)) { - result[j] = (TCHAR)res; + result[j] = static_cast(res); i += size; break; } @@ -157,7 +157,7 @@ int Searching::convertExtendedToString(const TCHAR * query, TCHAR * result, int bool Searching::readBase(const TCHAR * str, int * value, int base, int size) { int i = 0, temp = 0; *value = 0; - TCHAR max = '0' + (TCHAR)base - 1; + TCHAR max = '0' + static_cast(base) - 1; TCHAR current; while(i < size) { current = str[i]; diff --git a/PowerEditor/src/ScitillaComponent/ScintillaEditView.cpp b/PowerEditor/src/ScitillaComponent/ScintillaEditView.cpp index 667554b57..4ddca8b67 100644 --- a/PowerEditor/src/ScitillaComponent/ScintillaEditView.cpp +++ b/PowerEditor/src/ScitillaComponent/ScintillaEditView.cpp @@ -769,10 +769,10 @@ void ScintillaEditView::setUserLexer(const TCHAR *userLangName) execute(SCI_SETPROPERTY, reinterpret_cast("userDefine.decimalSeparator"), reinterpret_cast(intBuffer)); // at the end (position SCE_USER_KWLIST_TOTAL) send id values - itoa((int)userLangContainer->getName(), intBuffer, 10); // use numeric value of TCHAR pointer + itoa(reinterpret_cast(userLangContainer->getName()), intBuffer, 10); // use numeric value of TCHAR pointer execute(SCI_SETPROPERTY, reinterpret_cast("userDefine.udlName"), reinterpret_cast(intBuffer)); - itoa((int)_currentBufferID, intBuffer, 10); // use numeric value of BufferID pointer + itoa(reinterpret_cast(_currentBufferID), intBuffer, 10); // use numeric value of BufferID pointer execute(SCI_SETPROPERTY, reinterpret_cast("userDefine.currentBufferID"), reinterpret_cast(intBuffer)); for (int i = 0 ; i < SCE_USER_STYLE_TOTAL_STYLES ; ++i) diff --git a/PowerEditor/src/ScitillaComponent/SmartHighlighter.cpp b/PowerEditor/src/ScitillaComponent/SmartHighlighter.cpp index 256632636..11fb956c2 100644 --- a/PowerEditor/src/ScitillaComponent/SmartHighlighter.cpp +++ b/PowerEditor/src/ScitillaComponent/SmartHighlighter.cpp @@ -64,12 +64,13 @@ void SmartHighlighter::highlightView(ScintillaEditView * pHighlightView) auto originalEndPos = pHighlightView->execute(SCI_GETTARGETEND); // Get the range of text visible and highlight everything in it - int firstLine = static_cast(pHighlightView->execute(SCI_GETFIRSTVISIBLELINE)); - int nrLines = min((int)pHighlightView->execute(SCI_LINESONSCREEN), MAXLINEHIGHLIGHT ) + 1; - int lastLine = firstLine + nrLines; + auto firstLine = static_cast(pHighlightView->execute(SCI_GETFIRSTVISIBLELINE)); + auto nbLineOnScreen = pHighlightView->execute(SCI_LINESONSCREEN); + auto nrLines = min(nbLineOnScreen, MAXLINEHIGHLIGHT ) + 1; + auto lastLine = firstLine + nrLines; int startPos = 0; int endPos = 0; - int currentLine = firstLine; + auto currentLine = firstLine; int prevDocLineChecked = -1; //invalid start const NppGUI & nppGUI = NppParameters::getInstance()->getNppGUI(); @@ -87,12 +88,12 @@ void SmartHighlighter::highlightView(ScintillaEditView * pHighlightView) for(; currentLine < lastLine; ++currentLine) { - int docLine = (int)pHighlightView->execute(SCI_DOCLINEFROMVISIBLE, currentLine); + int docLine = static_cast(pHighlightView->execute(SCI_DOCLINEFROMVISIBLE, currentLine)); if (docLine == prevDocLineChecked) continue; //still on same line (wordwrap) prevDocLineChecked = docLine; - startPos = (int)pHighlightView->execute(SCI_POSITIONFROMLINE, docLine); - endPos = (int)pHighlightView->execute(SCI_POSITIONFROMLINE, docLine+1); + startPos = static_cast(pHighlightView->execute(SCI_POSITIONFROMLINE, docLine)); + endPos = static_cast(pHighlightView->execute(SCI_POSITIONFROMLINE, docLine + 1)); FindReplaceInfo frInfo; frInfo._txt2find = searchText; frInfo._startRange = startPos; diff --git a/PowerEditor/src/ScitillaComponent/UserDefineDialog.cpp b/PowerEditor/src/ScitillaComponent/UserDefineDialog.cpp index c73db2916..c4f0b6b2c 100644 --- a/PowerEditor/src/ScitillaComponent/UserDefineDialog.cpp +++ b/PowerEditor/src/ScitillaComponent/UserDefineDialog.cpp @@ -1240,9 +1240,9 @@ INT_PTR CALLBACK UserDefineDialog::run_dlgProc(UINT message, WPARAM wParam, LPAR //remove current language from langMenu HWND hNpp = ::GetParent(_hSelf); - HMENU m = (HMENU)::SendMessage(hNpp, NPPM_INTERNAL_GETMENU, 0, 0); + HMENU m = reinterpret_cast(::SendMessage(hNpp, NPPM_INTERNAL_GETMENU, 0, 0)); HMENU subMenu = ::GetSubMenu(m, MENUINDEX_LANGUAGE); - ::RemoveMenu(subMenu, IDM_LANG_USER + UINT(i), MF_BYCOMMAND); + ::RemoveMenu(subMenu, static_cast(IDM_LANG_USER + i), MF_BYCOMMAND); ::DrawMenuBar(hNpp); ::SendMessage(_hParent, WM_REMOVE_USERLANG, 0, reinterpret_cast(langName)); } @@ -1325,7 +1325,8 @@ INT_PTR CALLBACK UserDefineDialog::run_dlgProc(UINT message, WPARAM wParam, LPAR //add new language name in langMenu HWND hNpp = ::GetParent(_hSelf); - ::InsertMenu(::GetSubMenu((HMENU)::SendMessage(hNpp, NPPM_INTERNAL_GETMENU, 0, 0), MENUINDEX_LANGUAGE), IDM_LANG_USER + newIndex, MF_BYCOMMAND, IDM_LANG_USER + newIndex + 1, newName); + HMENU m = reinterpret_cast(::SendMessage(hNpp, NPPM_INTERNAL_GETMENU, 0, 0)); + ::InsertMenu(::GetSubMenu(m, MENUINDEX_LANGUAGE), IDM_LANG_USER + newIndex, MF_BYCOMMAND, IDM_LANG_USER + newIndex + 1, newName); ::DrawMenuBar(hNpp); } diff --git a/PowerEditor/src/ScitillaComponent/xmlMatchedTagsHighlighter.cpp b/PowerEditor/src/ScitillaComponent/xmlMatchedTagsHighlighter.cpp index c2020cecc..d0a3877cf 100644 --- a/PowerEditor/src/ScitillaComponent/xmlMatchedTagsHighlighter.cpp +++ b/PowerEditor/src/ScitillaComponent/xmlMatchedTagsHighlighter.cpp @@ -184,7 +184,7 @@ bool XmlMatchedTagsHighlighter::getXmlMatchedTagsPos(XmlMatchedTagsPos &xmlTags) // Checking for " or ' is actually wrong here, but it means it works better with invalid XML while(position < docLength && !isWhitespace(nextChar) && nextChar != '/' && nextChar != '>' && nextChar != '\"' && nextChar != '\'') { - tagName.push_back((char)nextChar); + tagName.push_back(static_cast(nextChar)); ++position; nextChar = static_cast(_pEditView->execute(SCI_GETCHARAT, position)); } @@ -284,7 +284,7 @@ bool XmlMatchedTagsHighlighter::getXmlMatchedTagsPos(XmlMatchedTagsPos &xmlTags) // Checking for " or ' is actually wrong here, but it means it works better with invalid XML while(position < docLength && !isWhitespace(nextChar) && nextChar != '/' && nextChar != '>' && nextChar != '\"' && nextChar != '\'' ) { - tagName.push_back((char)nextChar); + tagName.push_back(static_cast(nextChar)); ++position; nextChar = static_cast(_pEditView->execute(SCI_GETCHARAT, position)); } diff --git a/PowerEditor/src/TinyXml/tinyXmlA/tinyxmlA.cpp b/PowerEditor/src/TinyXml/tinyXmlA/tinyxmlA.cpp index c3affd576..ce5e72a4d 100644 --- a/PowerEditor/src/TinyXml/tinyXmlA/tinyxmlA.cpp +++ b/PowerEditor/src/TinyXml/tinyXmlA/tinyxmlA.cpp @@ -47,14 +47,14 @@ void TiXmlBaseA::PutString( const TIXMLA_STRING& str, TIXMLA_STRING* outString ) int c = str[i]; if ( c == '&' - && i < ( (int)str.length() - 2 ) + && i < ( static_cast(str.length()) - 2 ) && str[i+1] == '#' && str[i+2] == 'x' ) { // Hexadecimal character reference. // Pass through unchanged. // © -- copyright symbol, for example. - while ( i<(int)str.length() ) + while (i < static_cast(str.length())) { outString->append( str.c_str() + i, 1 ); ++i; @@ -98,7 +98,7 @@ void TiXmlBaseA::PutString( const TIXMLA_STRING& str, TIXMLA_STRING* outString ) } else { - char realc = (char) c; + char realc = static_cast(c); outString->append( &realc, 1 ); ++i; } diff --git a/PowerEditor/src/TinyXml/tinyXmlA/tinyxmlparserA.cpp b/PowerEditor/src/TinyXml/tinyXmlA/tinyxmlparserA.cpp index eb620cb42..4d1117666 100644 --- a/PowerEditor/src/TinyXml/tinyXmlA/tinyxmlparserA.cpp +++ b/PowerEditor/src/TinyXml/tinyXmlA/tinyxmlparserA.cpp @@ -175,7 +175,7 @@ const char* TiXmlBaseA::SkipWhiteSpace( const char* p ) int c = in->peek(); if ( !IsWhiteSpace( c ) ) return true; - *tag += (char)in->get(); + *tag += static_cast(in->get()); } } @@ -188,7 +188,7 @@ const char* TiXmlBaseA::SkipWhiteSpace( const char* p ) return true; in->get(); - *tag += (char)c; + *tag += static_cast(c); } return false; } @@ -204,7 +204,7 @@ const char* TiXmlBaseA::ReadName( const char* p, TIXMLA_STRING * name ) // hyphens, or colons. (Colons are valid ony for namespaces, // but tinyxml can't tell namespaces from names.) if ( p && *p - && ( isalpha( (unsigned char) *p ) || *p == '_' ) ) + && (isalpha(static_cast(*p)) || *p == '_')) { while( p && *p && ( isalnum( (unsigned char ) *p ) @@ -240,22 +240,22 @@ const char* TiXmlBaseA::GetEntity( const char* p, char* value ) { // Short, one value entity. if ( isalpha( *(p+3) ) ) - *value += ( (char)tolower( *(p+3) ) - 'a' + 10 ); + *value += (static_cast(tolower(*(p + 3))) - 'a' + 10); else - *value += ( (char)*(p+3) - '0' ); + *value += (static_cast(*(p + 3)) - '0'); return p+5; } else { // two value entity - if ( isalpha( *(p+3) ) ) *value += ((char) tolower( *(p+3) ) - 'a' + 10 ) * 16; - else *value += ((char) *(p+3) - '0' ) * 16; + if (isalpha(*(p + 3))) *value += (static_cast(tolower(*(p + 3))) - 'a' + 10) * 16; + else *value += (static_cast(*(p + 3)) - '0') * 16; if ( isalpha( *(p+4) ) ) - *value += ((char) tolower( *(p+4) ) - 'a' + 10 ); + *value += (static_cast(tolower(*(p + 4))) - 'a' + 10); else - *value += ((char) *(p+4) - '0' ); + *value += (static_cast(*(p + 4)) - '0'); return p+6; } @@ -403,7 +403,7 @@ void TiXmlDocumentA::StreamIn( TIXMLA_ISTREAM * in, TIXMLA_STRING * tag ) while ( in->good() && in->peek() != '>' ) { int c = in->get(); - (*tag) += (char) c; + (*tag) += static_cast(c); } if ( in->good() ) @@ -597,7 +597,7 @@ void TiXmlElementA::StreamIn (TIXMLA_ISTREAM * in, TIXMLA_STRING * tag) while( in->good() ) { int c = in->get(); - (*tag) += (char) c ; + (*tag) += static_cast(c); if ( c == '>' ) break; @@ -655,7 +655,7 @@ void TiXmlElementA::StreamIn (TIXMLA_ISTREAM * in, TIXMLA_STRING * tag) if ( c == '>' ) break; - *tag += (char)c; + *tag += static_cast(c); in->get(); if ( !firstCharFound && c != '<' && !IsWhiteSpace( c ) ) @@ -671,7 +671,7 @@ void TiXmlElementA::StreamIn (TIXMLA_ISTREAM * in, TIXMLA_STRING * tag) { int c = in->get(); assert( c == '>' ); - *tag += (char)c; + *tag += static_cast(c); // We are done, once we've found our closing tag. return; @@ -880,7 +880,7 @@ void TiXmlUnknownA::StreamIn( TIXMLA_ISTREAM * in, TIXMLA_STRING * tag ) while ( in->good() ) { int c = in->get(); - (*tag) += (char)c; + (*tag) += static_cast(c); if ( c == '>' ) { @@ -932,7 +932,7 @@ void TiXmlCommentA::StreamIn( TIXMLA_ISTREAM * in, TIXMLA_STRING * tag ) while ( in->good() ) { int c = in->get(); - (*tag) += (char)c; + (*tag) += static_cast(c); if ( c == '>' && tag->at( tag->length() - 2 ) == '-' @@ -1051,7 +1051,7 @@ void TiXmlTextA::StreamIn( TIXMLA_ISTREAM * in, TIXMLA_STRING * tag ) if ( c == '<' ) return; - (*tag) += (char)c; + (*tag) += static_cast(c); in->get(); } } @@ -1081,7 +1081,7 @@ void TiXmlDeclarationA::StreamIn( TIXMLA_ISTREAM * in, TIXMLA_STRING * tag ) while ( in->good() ) { int c = in->get(); - (*tag) += (char)c; + (*tag) += static_cast(c); if ( c == '>' ) { diff --git a/PowerEditor/src/TinyXml/tinyxmlparser.cpp b/PowerEditor/src/TinyXml/tinyxmlparser.cpp index f593876cf..3f2ee51b7 100644 --- a/PowerEditor/src/TinyXml/tinyxmlparser.cpp +++ b/PowerEditor/src/TinyXml/tinyxmlparser.cpp @@ -175,7 +175,7 @@ const TCHAR* TiXmlBase::SkipWhiteSpace( const TCHAR* p ) int c = in->peek(); if ( !IsWhiteSpace( c ) ) return true; - *tag += (TCHAR)in->get(); + *tag += static_cast(in->get()); } } @@ -188,7 +188,7 @@ const TCHAR* TiXmlBase::SkipWhiteSpace( const TCHAR* p ) return true; in->get(); - *tag += (TCHAR)c; + *tag += static_cast(c); } return false; } @@ -235,7 +235,7 @@ const TCHAR* TiXmlBase::GetEntity( const TCHAR* p, TCHAR* value ) int val; if (generic_sscanf(p+3, TEXT("%x"), &val) == 1) { - *value = (TCHAR)val; + *value = static_cast(val); return end + 1; } } @@ -383,7 +383,7 @@ void TiXmlDocument::StreamIn( TIXML_ISTREAM * in, TIXML_STRING * tag ) while ( in->good() && in->peek() != '>' ) { int c = in->get(); - (*tag) += (TCHAR) c; + (*tag) += static_cast(c); } if ( in->good() ) @@ -577,7 +577,7 @@ void TiXmlElement::StreamIn (TIXML_ISTREAM * in, TIXML_STRING * tag) while( in->good() ) { int c = in->get(); - (*tag) += (TCHAR) c ; + (*tag) += static_cast(c); if ( c == '>' ) break; @@ -635,7 +635,7 @@ void TiXmlElement::StreamIn (TIXML_ISTREAM * in, TIXML_STRING * tag) if ( c == '>' ) break; - *tag += (TCHAR)c; + *tag += static_cast(c); in->get(); if ( !firstCharFound && c != '<' && !IsWhiteSpace( c ) ) @@ -651,7 +651,7 @@ void TiXmlElement::StreamIn (TIXML_ISTREAM * in, TIXML_STRING * tag) { int c = in->get(); assert( c == '>' ); - *tag += (TCHAR)c; + *tag += static_cast(c); // We are done, once we've found our closing tag. return; @@ -860,7 +860,7 @@ void TiXmlUnknown::StreamIn( TIXML_ISTREAM * in, TIXML_STRING * tag ) while ( in->good() ) { int c = in->get(); - (*tag) += (TCHAR)c; + (*tag) += static_cast(c); if ( c == '>' ) { @@ -912,7 +912,7 @@ void TiXmlComment::StreamIn( TIXML_ISTREAM * in, TIXML_STRING * tag ) while ( in->good() ) { int c = in->get(); - (*tag) += (TCHAR)c; + (*tag) += static_cast(c); if ( c == '>' && tag->at( tag->length() - 2 ) == '-' @@ -1031,7 +1031,7 @@ void TiXmlText::StreamIn( TIXML_ISTREAM * in, TIXML_STRING * tag ) if ( c == '<' ) return; - (*tag) += (TCHAR)c; + (*tag) += static_cast(c); in->get(); } } @@ -1061,7 +1061,7 @@ void TiXmlDeclaration::StreamIn( TIXML_ISTREAM * in, TIXML_STRING * tag ) while ( in->good() ) { int c = in->get(); - (*tag) += (TCHAR)c; + (*tag) += static_cast(c); if ( c == '>' ) { diff --git a/PowerEditor/src/WinControls/AnsiCharPanel/ListView.cpp b/PowerEditor/src/WinControls/AnsiCharPanel/ListView.cpp index 81930ba86..0eb82e37e 100644 --- a/PowerEditor/src/WinControls/AnsiCharPanel/ListView.cpp +++ b/PowerEditor/src/WinControls/AnsiCharPanel/ListView.cpp @@ -55,9 +55,9 @@ void ListView::init(HINSTANCE hInst, HWND parent) 0, 0, _hParent, - (HMENU) NULL, + nullptr, hInst, - NULL); + nullptr); if (!_hSelf) { throw std::runtime_error("ListView::init : CreateWindowEx() function return null"); @@ -205,10 +205,10 @@ void ListView::setValues(int codepage) item.iSubItem = 0; ListView_InsertItem(_hSelf, &item); - ListView_SetItemText(_hSelf, i, 1, (LPTSTR)hex); + ListView_SetItemText(_hSelf, i, 1, hex); - generic_string s = getAscii((unsigned char)i); - ListView_SetItemText(_hSelf, i, 2, (LPTSTR)s.c_str()); + generic_string s = getAscii(static_cast(i)); + ListView_SetItemText(_hSelf, i, 2, const_cast(s.c_str())); } } diff --git a/PowerEditor/src/WinControls/AnsiCharPanel/ansiCharPanel.cpp b/PowerEditor/src/WinControls/AnsiCharPanel/ansiCharPanel.cpp index cdb8cd8d5..cc1c0d070 100644 --- a/PowerEditor/src/WinControls/AnsiCharPanel/ansiCharPanel.cpp +++ b/PowerEditor/src/WinControls/AnsiCharPanel/ansiCharPanel.cpp @@ -61,7 +61,7 @@ INT_PTR CALLBACK AnsiCharPanel::run_dlgProc(UINT message, WPARAM wParam, LPARAM if (i == -1) return TRUE; - insertChar((unsigned char)i); + insertChar(static_cast(i)); return TRUE; } @@ -76,7 +76,7 @@ INT_PTR CALLBACK AnsiCharPanel::run_dlgProc(UINT message, WPARAM wParam, LPARAM if (i == -1) return TRUE; - insertChar((unsigned char)i); + insertChar(static_cast(i)); return TRUE; } default: diff --git a/PowerEditor/src/WinControls/ClipboardHistory/clipboardHistoryPanel.cpp b/PowerEditor/src/WinControls/ClipboardHistory/clipboardHistoryPanel.cpp index b3cae2237..fa580f7ad 100644 --- a/PowerEditor/src/WinControls/ClipboardHistory/clipboardHistoryPanel.cpp +++ b/PowerEditor/src/WinControls/ClipboardHistory/clipboardHistoryPanel.cpp @@ -62,7 +62,7 @@ ClipboardData ClipboardHistoryPanel::getClipboadData() { for (size_t i = 0 ; i < (*lpLen) ; ++i) { - clipboardData.push_back((unsigned char)lpchar[i]); + clipboardData.push_back(static_cast(lpchar[i])); } GlobalUnlock(hglb); } @@ -73,7 +73,7 @@ ClipboardData ClipboardHistoryPanel::getClipboadData() int nbBytes = (lstrlenW(lpWchar) + 1) * sizeof(wchar_t); for (int i = 0 ; i < nbBytes ; ++i) { - clipboardData.push_back((unsigned char)lpchar[i]); + clipboardData.push_back(static_cast(lpchar[i])); } } GlobalUnlock(hglb); diff --git a/PowerEditor/src/WinControls/ColourPicker/WordStyleDlg.cpp b/PowerEditor/src/WinControls/ColourPicker/WordStyleDlg.cpp index 949588291..108f84951 100644 --- a/PowerEditor/src/WinControls/ColourPicker/WordStyleDlg.cpp +++ b/PowerEditor/src/WinControls/ColourPicker/WordStyleDlg.cpp @@ -148,8 +148,8 @@ INT_PTR CALLBACK WordStyleDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM l p1.x = p2.x = ((p1.x > p2.x)?p1.x:p2.x) + 10; p1.y -= 4; p2.y -= 4; - ::MoveWindow((HWND)_pFgColour->getHSelf(), p1.x, p1.y, 25, 25, TRUE); - ::MoveWindow((HWND)_pBgColour->getHSelf(), p2.x, p2.y, 25, 25, TRUE); + ::MoveWindow(reinterpret_cast(_pFgColour->getHSelf()), p1.x, p1.y, 25, 25, TRUE); + ::MoveWindow(reinterpret_cast(_pBgColour->getHSelf()), p2.x, p2.y, 25, 25, TRUE); _pFgColour->display(); _pBgColour->display(); diff --git a/PowerEditor/src/WinControls/FileBrowser/fileBrowser.cpp b/PowerEditor/src/WinControls/FileBrowser/fileBrowser.cpp index 7a40f9aeb..9797d678b 100644 --- a/PowerEditor/src/WinControls/FileBrowser/fileBrowser.cpp +++ b/PowerEditor/src/WinControls/FileBrowser/fileBrowser.cpp @@ -245,51 +245,34 @@ INT_PTR CALLBACK FileBrowser::run_dlgProc(UINT message, WPARAM wParam, LPARAM lP void FileBrowser::initPopupMenus() { - //NativeLangSpeaker *pNativeSpeaker = (NppParameters::getInstance())->getNativeLangSpeaker(); -/* - generic_string removeFolderFromFileBrowser = pNativeSpeaker->getProjectPanelLangMenuStr("FileBrowserContextMenu", IDM_FILEBROWSER_REMOVEROOTFOLDER, FB_REMOVEROOT); - generic_string edit_rename = pNativeSpeaker->getProjectPanelLangMenuStr("ProjectMenu", IDM_FILEBROWSER_RENAME, PM_EDITRENAME); - generic_string edit_addfolder = pNativeSpeaker->getProjectPanelLangMenuStr("ProjectMenu", IDM_FILEBROWSER_NEWFOLDER, PM_EDITNEWFOLDER); - generic_string edit_addfiles = pNativeSpeaker->getProjectPanelLangMenuStr("ProjectMenu", IDM_FILEBROWSER_ADDFILES, PM_EDITADDFILES); - - - edit_rename = pNativeSpeaker->getProjectPanelLangMenuStr("FolderMenu", IDM_FILEBROWSER_RENAME, PM_EDITRENAME); - edit_addfolder = pNativeSpeaker->getProjectPanelLangMenuStr("FolderMenu", IDM_FILEBROWSER_NEWFOLDER, PM_EDITNEWFOLDER); - edit_addfiles = pNativeSpeaker->getProjectPanelLangMenuStr("FolderMenu", IDM_FILEBROWSER_ADDFILES, PM_EDITADDFILES); - edit_remove = pNativeSpeaker->getProjectPanelLangMenuStr("FolderMenu", IDM_FILEBROWSER_DELETEFOLDER, PM_EDITREMOVE); -*/ _hGlobalMenu = ::CreatePopupMenu(); ::InsertMenu(_hGlobalMenu, 0, MF_BYCOMMAND, IDM_FILEBROWSER_ADDROOT, TEXT("Add")); ::InsertMenu(_hGlobalMenu, 0, MF_BYCOMMAND, IDM_FILEBROWSER_REMOVEALLROOTS, TEXT("Remove All")); _hRootMenu = ::CreatePopupMenu(); ::InsertMenu(_hRootMenu, 0, MF_BYCOMMAND, IDM_FILEBROWSER_REMOVEROOTFOLDER, TEXT("Remove")); - ::InsertMenu(_hRootMenu, 0, MF_BYCOMMAND, (UINT)-1, 0); + ::InsertMenu(_hRootMenu, 0, MF_BYCOMMAND, static_cast(-1), 0); ::InsertMenu(_hRootMenu, 0, MF_BYCOMMAND, IDM_FILEBROWSER_COPYEPATH, TEXT("Copy path")); ::InsertMenu(_hRootMenu, 0, MF_BYCOMMAND, IDM_FILEBROWSER_FINDINFILES, TEXT("Find in Files...")); - ::InsertMenu(_hRootMenu, 0, MF_BYCOMMAND, (UINT)-1, 0); + ::InsertMenu(_hRootMenu, 0, MF_BYCOMMAND, static_cast(-1), 0); ::InsertMenu(_hRootMenu, 0, MF_BYCOMMAND, IDM_FILEBROWSER_EXPLORERHERE, TEXT("Explorer here")); ::InsertMenu(_hRootMenu, 0, MF_BYCOMMAND, IDM_FILEBROWSER_CMDHERE, TEXT("CMD here")); _hFolderMenu = ::CreatePopupMenu(); ::InsertMenu(_hFolderMenu, 0, MF_BYCOMMAND, IDM_FILEBROWSER_COPYEPATH, TEXT("Copy path")); ::InsertMenu(_hFolderMenu, 0, MF_BYCOMMAND, IDM_FILEBROWSER_FINDINFILES, TEXT("Find in Files...")); - ::InsertMenu(_hFolderMenu, 0, MF_BYCOMMAND, (UINT)-1, 0); + ::InsertMenu(_hFolderMenu, 0, MF_BYCOMMAND, static_cast(-1), 0); ::InsertMenu(_hFolderMenu, 0, MF_BYCOMMAND, IDM_FILEBROWSER_EXPLORERHERE, TEXT("Explorer here")); ::InsertMenu(_hFolderMenu, 0, MF_BYCOMMAND, IDM_FILEBROWSER_CMDHERE, TEXT("CMD here")); - //::InsertMenu(_hFolderMenu, 0, MF_BYCOMMAND, IDM_FILEBROWSER_NEWFOLDER, edit_addfolder.c_str()); - //::InsertMenu(_hFolderMenu, 0, MF_BYCOMMAND, IDM_FILEBROWSER_ADDFILES, edit_addfiles.c_str()); _hFileMenu = ::CreatePopupMenu(); ::InsertMenu(_hFileMenu, 0, MF_BYCOMMAND, IDM_FILEBROWSER_OPENINNPP, TEXT("Open")); - ::InsertMenu(_hFileMenu, 0, MF_BYCOMMAND, (UINT)-1, 0); + ::InsertMenu(_hFileMenu, 0, MF_BYCOMMAND, static_cast(-1), 0); ::InsertMenu(_hFileMenu, 0, MF_BYCOMMAND, IDM_FILEBROWSER_COPYEPATH, TEXT("Copy path")); ::InsertMenu(_hFileMenu, 0, MF_BYCOMMAND, IDM_FILEBROWSER_SHELLEXECUTE, TEXT("Run by system")); - ::InsertMenu(_hFileMenu, 0, MF_BYCOMMAND, (UINT)-1, 0); + ::InsertMenu(_hFileMenu, 0, MF_BYCOMMAND, static_cast(-1), 0); ::InsertMenu(_hFileMenu, 0, MF_BYCOMMAND, IDM_FILEBROWSER_EXPLORERHERE, TEXT("Explorer here")); ::InsertMenu(_hFileMenu, 0, MF_BYCOMMAND, IDM_FILEBROWSER_CMDHERE, TEXT("CMD here")); - //::InsertMenu(_hFileMenu, 0, MF_BYCOMMAND, IDM_FILEBROWSER_DELETEFILE, edit_remove.c_str()); - //::InsertMenu(_hFileMenu, 0, MF_BYCOMMAND, IDM_FILEBROWSER_MODIFYFILEPATH, edit_modifyfile.c_str()); } diff --git a/PowerEditor/src/WinControls/FindCharsInRange/FindCharsInRange.cpp b/PowerEditor/src/WinControls/FindCharsInRange/FindCharsInRange.cpp index f703f8aa7..f22561253 100644 --- a/PowerEditor/src/WinControls/FindCharsInRange/FindCharsInRange.cpp +++ b/PowerEditor/src/WinControls/FindCharsInRange/FindCharsInRange.cpp @@ -95,7 +95,7 @@ bool FindCharsInRangeDlg::findCharInRange(unsigned char beginRange, unsigned cha (direction == dirDown)?i < totalSize:i >= 0 ; (direction == dirDown)?(++i):(--i)) { - if ((unsigned char)content[i] >= beginRange && (unsigned char)content[i] <= endRange) + if (static_cast(content[i]) >= beginRange && static_cast(content[i]) <= endRange) { found = i; break; @@ -110,7 +110,7 @@ bool FindCharsInRangeDlg::findCharInRange(unsigned char beginRange, unsigned cha (direction == dirDown)?i < totalSize:i >= 0 ; (direction == dirDown)?(++i):(--i)) { - if ((unsigned char)content[i] >= beginRange && (unsigned char)content[i] <= endRange) + if (static_cast(content[i]) >= beginRange && static_cast(content[i]) <= endRange) { found = i; break; @@ -164,8 +164,8 @@ bool FindCharsInRangeDlg::getRangeFromUI(unsigned char & startRange, unsigned ch return false; if (start > end) return false; - startRange = (unsigned char)start; - endRange = (unsigned char)end; + startRange = static_cast(start); + endRange = static_cast(end); return true; } diff --git a/PowerEditor/src/WinControls/FunctionList/functionListPanel.cpp b/PowerEditor/src/WinControls/FunctionList/functionListPanel.cpp index 030be8660..bde6b5002 100644 --- a/PowerEditor/src/WinControls/FunctionList/functionListPanel.cpp +++ b/PowerEditor/src/WinControls/FunctionList/functionListPanel.cpp @@ -572,7 +572,7 @@ INT_PTR CALLBACK FunctionListPanel::run_dlgProc(UINT message, WPARAM wParam, LPA // Create toolbar menu int style = WS_CHILD | WS_VISIBLE | CCS_ADJUSTABLE | TBSTYLE_AUTOSIZE | TBSTYLE_FLAT | TBSTYLE_LIST | TBSTYLE_TRANSPARENT | BTNS_AUTOSIZE | BTNS_SEP | TBSTYLE_TOOLTIPS; _hToolbarMenu = CreateWindowEx(0,TOOLBARCLASSNAME,NULL, style, - 0,0,0,0,_hSelf,(HMENU)0, _hInst, NULL); + 0,0,0,0,_hSelf,nullptr, _hInst, NULL); oldFunclstToolbarProc = reinterpret_cast(::SetWindowLongPtr(_hToolbarMenu, GWLP_WNDPROC, reinterpret_cast(funclstToolbarProc))); TBBUTTON tbButtons[3]; diff --git a/PowerEditor/src/WinControls/Grid/BabyGrid.cpp b/PowerEditor/src/WinControls/Grid/BabyGrid.cpp index 9bfd03a85..090245e02 100644 --- a/PowerEditor/src/WinControls/Grid/BabyGrid.cpp +++ b/PowerEditor/src/WinControls/Grid/BabyGrid.cpp @@ -1776,7 +1776,7 @@ LRESULT CALLBACK GridProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) LPBGcell=(_BGCELL*)wParam; if(OutOfRange(LPBGcell)) { - wParam=MAKEWPARAM((UINT)GetMenu(hWnd),BGN_OUTOFRANGE); + wParam = MAKEWPARAM(reinterpret_cast(GetMenu(hWnd)), BGN_OUTOFRANGE); lParam = 0; SendMessage(GetParent(hWnd),WM_COMMAND,wParam,lParam); ReturnValue = -1; diff --git a/PowerEditor/src/WinControls/Grid/BabyGridWrapper.cpp b/PowerEditor/src/WinControls/Grid/BabyGridWrapper.cpp index 9de2b10da..005feede5 100644 --- a/PowerEditor/src/WinControls/Grid/BabyGridWrapper.cpp +++ b/PowerEditor/src/WinControls/Grid/BabyGridWrapper.cpp @@ -44,7 +44,7 @@ void BabyGridWrapper::init(HINSTANCE hInst, HWND parent, int id) WS_CHILD | WS_VISIBLE | WS_TABSTOP,\ CW_USEDEFAULT, 0, CW_USEDEFAULT, 0,\ _hParent,\ - (HMENU)id,\ + reinterpret_cast(id), \ _hInst,\ - (LPVOID)NULL); + NULL); } diff --git a/PowerEditor/src/WinControls/Grid/ShortcutMapper.cpp b/PowerEditor/src/WinControls/Grid/ShortcutMapper.cpp index 06321b6ca..6bfb7aa81 100644 --- a/PowerEditor/src/WinControls/Grid/ShortcutMapper.cpp +++ b/PowerEditor/src/WinControls/Grid/ShortcutMapper.cpp @@ -557,7 +557,8 @@ INT_PTR CALLBACK ShortcutMapper::run_dlgProc(UINT message, WPARAM wParam, LPARAM // preparing to remove from menu posBase = 6; nbElem = theMacros.size(); - hMenu = ::GetSubMenu((HMENU)::SendMessage(_hParent, NPPM_INTERNAL_GETMENU, 0, 0), MENUINDEX_MACRO); + HMENU m = reinterpret_cast(::SendMessage(_hParent, NPPM_INTERNAL_GETMENU, 0, 0)); + hMenu = ::GetSubMenu(m, MENUINDEX_MACRO); modifCmd = IDM_SETTING_SHORTCUT_MAPPER_MACRO; for (size_t i = shortcutIndex ; i < nbElem ; ++i) //lower the IDs of the remaining items so there are no gaps { @@ -590,7 +591,8 @@ INT_PTR CALLBACK ShortcutMapper::run_dlgProc(UINT message, WPARAM wParam, LPARAM // preparing to remove from menu posBase = 2; nbElem = theUserCmds.size(); - hMenu = ::GetSubMenu((HMENU)::SendMessage(_hParent, NPPM_INTERNAL_GETMENU, 0, 0), MENUINDEX_RUN); + HMENU m = reinterpret_cast(::SendMessage(_hParent, NPPM_INTERNAL_GETMENU, 0, 0)); + hMenu = ::GetSubMenu(m, MENUINDEX_RUN); modifCmd = IDM_SETTING_SHORTCUT_MAPPER_RUN; for (size_t i = shortcutIndex ; i < nbElem ; ++i) //lower the IDs of the remaining items so there are no gaps { diff --git a/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp b/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp index d71e28b4f..13b7358ce 100644 --- a/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp +++ b/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp @@ -1715,7 +1715,8 @@ INT_PTR CALLBACK LangMenuDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lP if (LOWORD(wParam)==IDC_BUTTON_REMOVE) { - ::DeleteMenu((HMENU)::SendMessage(grandParent, NPPM_INTERNAL_GETMENU, 0, 0), lmi._cmdID, MF_BYCOMMAND); + HMENU menu2remove = reinterpret_cast(::SendMessage(grandParent, NPPM_INTERNAL_GETMENU, 0, 0)); + ::DeleteMenu(menu2remove, lmi._cmdID, MF_BYCOMMAND); } else { @@ -2810,7 +2811,7 @@ INT_PTR CALLBACK DelimiterSettingsDlg::run_dlgProc(UINT Message, WPARAM wParam, case WM_CTLCOLORSTATIC: { HDC hdcStatic = (HDC) wParam; - HWND hwnd = (HWND) lParam; + HWND hwnd = reinterpret_cast(lParam); if (hwnd == ::GetDlgItem(_hSelf, IDD_STATIC_BLABLA) || hwnd == ::GetDlgItem(_hSelf, IDD_STATIC_BLABLA2NDLINE)) { COLORREF bgColor = getCtrlBgColor(_hSelf); diff --git a/PowerEditor/src/WinControls/ProjectPanel/ProjectPanel.cpp b/PowerEditor/src/WinControls/ProjectPanel/ProjectPanel.cpp index 5f7714ae1..f10304c86 100644 --- a/PowerEditor/src/WinControls/ProjectPanel/ProjectPanel.cpp +++ b/PowerEditor/src/WinControls/ProjectPanel/ProjectPanel.cpp @@ -58,7 +58,7 @@ INT_PTR CALLBACK ProjectPanel::run_dlgProc(UINT message, WPARAM wParam, LPARAM l // Create toolbar menu int style = WS_CHILD | WS_VISIBLE | CCS_ADJUSTABLE | TBSTYLE_AUTOSIZE | TBSTYLE_FLAT | TBSTYLE_LIST; _hToolbarMenu = CreateWindowEx(0,TOOLBARCLASSNAME,NULL, style, - 0,0,0,0,_hSelf,(HMENU)0, _hInst, NULL); + 0,0,0,0,_hSelf, nullptr, _hInst, nullptr); TBBUTTON tbButtons[2]; NativeLangSpeaker *pNativeSpeaker = (NppParameters::getInstance())->getNativeLangSpeaker(); @@ -192,7 +192,7 @@ void ProjectPanel::initMenus() ::InsertMenu(_hWorkSpaceMenu, 0, MF_BYCOMMAND, IDM_PROJECT_SAVEWS, save_workspace.c_str()); ::InsertMenu(_hWorkSpaceMenu, 0, MF_BYCOMMAND, IDM_PROJECT_SAVEASWS, saveas_workspace.c_str()); ::InsertMenu(_hWorkSpaceMenu, 0, MF_BYCOMMAND, IDM_PROJECT_SAVEACOPYASWS, saveacopyas_workspace.c_str()); - ::InsertMenu(_hWorkSpaceMenu, 0, MF_BYCOMMAND, (UINT)-1, 0); + ::InsertMenu(_hWorkSpaceMenu, 0, MF_BYCOMMAND, static_cast(-1), 0); ::InsertMenu(_hWorkSpaceMenu, 0, MF_BYCOMMAND, IDM_PROJECT_NEWPROJECT, newproject_workspace.c_str()); generic_string edit_moveup = pNativeSpeaker->getProjectPanelLangMenuStr("ProjectMenu", IDM_PROJECT_MOVEUP, PM_MOVEUPENTRY); diff --git a/PowerEditor/src/WinControls/StaticDialog/RunDlg/RunDlg.cpp b/PowerEditor/src/WinControls/StaticDialog/RunDlg/RunDlg.cpp index be034256a..9a2204341 100644 --- a/PowerEditor/src/WinControls/StaticDialog/RunDlg/RunDlg.cpp +++ b/PowerEditor/src/WinControls/StaticDialog/RunDlg/RunDlg.cpp @@ -246,7 +246,8 @@ INT_PTR CALLBACK RunDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam) if (uc.doDialog() != -1) { - HMENU hRunMenu = ::GetSubMenu((HMENU)::SendMessage(_hParent, NPPM_INTERNAL_GETMENU, 0, 0), MENUINDEX_RUN); + HMENU mainMenu = reinterpret_cast(::SendMessage(_hParent, NPPM_INTERNAL_GETMENU, 0, 0)); + HMENU hRunMenu = ::GetSubMenu(mainMenu, MENUINDEX_RUN); int const posBase = 2; if (nbCmd == 0) diff --git a/PowerEditor/src/WinControls/StatusBar/StatusBar.cpp b/PowerEditor/src/WinControls/StatusBar/StatusBar.cpp index 6c9be9cb7..bc515e700 100644 --- a/PowerEditor/src/WinControls/StatusBar/StatusBar.cpp +++ b/PowerEditor/src/WinControls/StatusBar/StatusBar.cpp @@ -78,7 +78,7 @@ void StatusBar::init(HINSTANCE hInst, HWND hPere, int nbParts) _partWidthArray.clear(); if (nbParts > 0) - _partWidthArray.resize(nbParts, (int) defaultPartWidth); + _partWidthArray.resize(nbParts, defaultPartWidth); // Allocate an array for holding the right edge coordinates. if (_partWidthArray.size()) diff --git a/PowerEditor/src/WinControls/VerticalFileSwitcher/VerticalFileSwitcher.cpp b/PowerEditor/src/WinControls/VerticalFileSwitcher/VerticalFileSwitcher.cpp index bb7f7443d..cfdb0a411 100644 --- a/PowerEditor/src/WinControls/VerticalFileSwitcher/VerticalFileSwitcher.cpp +++ b/PowerEditor/src/WinControls/VerticalFileSwitcher/VerticalFileSwitcher.cpp @@ -249,7 +249,7 @@ int VerticalFileSwitcher::setHeaderOrder(LPNMLISTVIEW pnm_list_view) // this is the case our clicked column wasn't the one being sorted up until now // so first we need to iterate through all columns and send LVM_SETCOLUMN to them with fmt set to NOT include these HDFs - colHeader = (HWND)SendMessage(hListView,LVM_GETHEADER,0,0); + colHeader = reinterpret_cast(SendMessage(hListView, LVM_GETHEADER, 0, 0)); cols = static_cast(SendMessage(colHeader, HDM_GETITEMCOUNT, 0, 0)); for (q = 0; q < cols; ++q) { diff --git a/PowerEditor/src/WinControls/VerticalFileSwitcher/VerticalFileSwitcherListView.cpp b/PowerEditor/src/WinControls/VerticalFileSwitcher/VerticalFileSwitcherListView.cpp index b5d7005d8..9d089f4a6 100644 --- a/PowerEditor/src/WinControls/VerticalFileSwitcher/VerticalFileSwitcherListView.cpp +++ b/PowerEditor/src/WinControls/VerticalFileSwitcher/VerticalFileSwitcherListView.cpp @@ -58,9 +58,9 @@ void VerticalFileSwitcherListView::init(HINSTANCE hInst, HWND parent, HIMAGELIST 0, 0, _hParent, - (HMENU) NULL, + nullptr, hInst, - NULL); + nullptr); if (!_hSelf) { throw std::runtime_error("VerticalFileSwitcherListView::init : CreateWindowEx() function return null"); @@ -112,10 +112,8 @@ void VerticalFileSwitcherListView::initList() generic_string nameStr = pNativeSpeaker->getAttrNameStr(TEXT("Name"), FS_ROOTNODE, FS_CLMNNAME); - //insertColumn(nameStr.c_str(), 150, 0); insertColumn(nameStr.c_str(), (isExtColumn ? totalWidth - 50 : totalWidth), 0); - //bool isExtColumn = !nppParams->getNppGUI()._fileSwitcherWithoutExtColumn; if (isExtColumn) { generic_string extStr = pNativeSpeaker->getAttrNameStr(TEXT("Ext."), FS_ROOTNODE, FS_CLMNEXT); diff --git a/PowerEditor/src/WinControls/WindowsDlg/WinMgr.cpp b/PowerEditor/src/WinControls/WindowsDlg/WinMgr.cpp index faff01f74..36b649e73 100644 --- a/PowerEditor/src/WinControls/WindowsDlg/WinMgr.cpp +++ b/PowerEditor/src/WinControls/WindowsDlg/WinMgr.cpp @@ -121,7 +121,7 @@ WINRECT* CWinMgr::FindRect(int nID) { assert(m_map); for (WINRECT* w=m_map; !w->IsEnd(); ++w) { - if (w->GetID()==(UINT)nID) + if (w->GetID() == static_cast(nID)) return w; } return NULL; diff --git a/PowerEditor/src/WinControls/WindowsDlg/WinMgr.h b/PowerEditor/src/WinControls/WindowsDlg/WinMgr.h index 0442e0954..7e310ed97 100644 --- a/PowerEditor/src/WinControls/WindowsDlg/WinMgr.h +++ b/PowerEditor/src/WinControls/WindowsDlg/WinMgr.h @@ -58,11 +58,11 @@ inline RECT &OffsetRect(RECT& rc, POINT pt) { // handy functions to take the min or max of a SIZE inline SIZE minsize(SIZE a, SIZE b) { - return GetSize(min((UINT)a.cx,(UINT)b.cx),min((UINT)a.cy,(UINT)b.cy)); + return GetSize(min(a.cx, b.cx), min(a.cy, b.cy)); } inline SIZE maxsize(SIZE a, SIZE b) { - return GetSize(max((UINT)a.cx,(UINT)b.cx),max((UINT)a.cy,(UINT)b.cy)); + return GetSize(max(a.cx, b.cx), max(a.cy, b.cy)); } ////////////////// diff --git a/PowerEditor/src/WinControls/shortcut/shortcut.cpp b/PowerEditor/src/WinControls/shortcut/shortcut.cpp index 7d0b6c63b..54d6ccb56 100644 --- a/PowerEditor/src/WinControls/shortcut/shortcut.cpp +++ b/PowerEditor/src/WinControls/shortcut/shortcut.cpp @@ -332,7 +332,8 @@ void getNameStrFromCmd(DWORD cmd, generic_string & str) HWND hNotepad_plus = ::FindWindow(Notepad_plus_Window::getClassName(), NULL); const int commandSize = 64; TCHAR cmdName[commandSize]; - int nbChar = ::GetMenuString((HMENU)::SendMessage(hNotepad_plus, NPPM_INTERNAL_GETMENU, 0, 0), cmd, cmdName, commandSize, MF_BYCOMMAND); + HMENU m = reinterpret_cast(::SendMessage(hNotepad_plus, NPPM_INTERNAL_GETMENU, 0, 0)); + int nbChar = ::GetMenuString(m, cmd, cmdName, commandSize, MF_BYCOMMAND); if (!nbChar) return; bool fin = false; @@ -387,7 +388,7 @@ INT_PTR CALLBACK Shortcut::run_dlgProc(UINT Message, WPARAM wParam, LPARAM) ::SetDlgItemText(_hSelf, IDC_NAME_EDIT, getMenuName()); //display the menu name, with ampersands if (!_canModifyName) ::SendDlgItemMessage(_hSelf, IDC_NAME_EDIT, EM_SETREADONLY, TRUE, 0); - int textlen = (int)::SendDlgItemMessage(_hSelf, IDC_NAME_EDIT, WM_GETTEXTLENGTH, 0, 0); + auto textlen = ::SendDlgItemMessage(_hSelf, IDC_NAME_EDIT, WM_GETTEXTLENGTH, 0, 0); ::SendDlgItemMessage(_hSelf, IDC_CTRL_CHECK, BM_SETCHECK, _keyCombo._isCtrl?BST_CHECKED:BST_UNCHECKED, 0); ::SendDlgItemMessage(_hSelf, IDC_ALT_CHECK, BM_SETCHECK, _keyCombo._isAlt?BST_CHECKED:BST_UNCHECKED, 0); @@ -412,7 +413,7 @@ INT_PTR CALLBACK Shortcut::run_dlgProc(UINT Message, WPARAM wParam, LPARAM) case WM_COMMAND : { - int textlen = (int)::SendDlgItemMessage(_hSelf, IDC_NAME_EDIT, WM_GETTEXTLENGTH, 0, 0); + auto textlen = ::SendDlgItemMessage(_hSelf, IDC_NAME_EDIT, WM_GETTEXTLENGTH, 0, 0); switch (wParam) { case IDC_CTRL_CHECK : @@ -696,14 +697,15 @@ void recordedMacroStep::PlayBack(Window* pNotepad, ScintillaEditView *pEditView) } } -void ScintillaAccelerator::init(vector * vScintillas, HMENU hMenu, HWND menuParent) { +void ScintillaAccelerator::init(vector * vScintillas, HMENU hMenu, HWND menuParent) +{ _hAccelMenu = hMenu; _hMenuParent = menuParent; - size_t nr = vScintillas->size(); - for(size_t i = 0; i < nr; ++i) { + size_t nbScintilla = vScintillas->size(); + for (size_t i = 0; i < nbScintilla; ++i) + { _vScintillas.push_back(vScintillas->at(i)); } - _nrScintillas = (int)nr; } void ScintillaAccelerator::updateKeys() @@ -712,8 +714,8 @@ void ScintillaAccelerator::updateKeys() vector & map = pNppParam->getScintillaKeyList(); size_t mapSize = map.size(); size_t index; - - for(int i = 0; i < _nrScintillas; ++i) + size_t nb = nbScintillas(); + for (size_t i = 0; i < nb; ++i) { ::SendMessage(_vScintillas[i], SCI_CLEARALLCMDKEYS, 0, 0); for(int32_t j = static_cast(mapSize) - 1; j >= 0; j--) //reverse order, top of the list has highest priority @@ -762,11 +764,12 @@ void ScintillaAccelerator::updateMenuItemByID(ScintillaKeyMap skm, int id) } //This procedure uses _keyCombo as a temp. variable to store current settings which can then later be applied (by pressing OK) -void ScintillaKeyMap::applyToCurrentIndex() { - int index = (int)::SendDlgItemMessage(_hSelf, IDC_LIST_KEYS, LB_GETCURSEL, 0, 0); - if(index == LB_ERR) +void ScintillaKeyMap::applyToCurrentIndex() +{ + int index = static_cast(::SendDlgItemMessage(_hSelf, IDC_LIST_KEYS, LB_GETCURSEL, 0, 0)); + if (index == LB_ERR) return; - setKeyComboByIndex(index, _keyCombo); + setKeyComboByIndex(static_cast(index), _keyCombo); updateListItem(index); ::SendDlgItemMessage(_hSelf, IDC_LIST_KEYS, LB_SETCURSEL, index, 0); @@ -898,28 +901,33 @@ INT_PTR CALLBACK ScintillaKeyMap::run_dlgProc(UINT Message, WPARAM wParam, LPARA return TRUE; } - case IDC_BUTTON_RMVE: { + case IDC_BUTTON_RMVE: + { if (_size == 1) //cannot delete last shortcut return TRUE; auto i = ::SendDlgItemMessage(_hSelf, IDC_LIST_KEYS, LB_GETCURSEL, 0, 0); removeKeyComboByIndex(i); ::SendDlgItemMessage(_hSelf, IDC_LIST_KEYS, LB_DELETESTRING, i, 0); - if (i == (int)_size) + if (static_cast(i) == _size) i = _size - 1; ::SendDlgItemMessage(_hSelf, IDC_LIST_KEYS, LB_SETCURSEL, i, 0); showCurrentSettings(); validateDialog(); - return TRUE; } + return TRUE; + } - case IDC_BUTTON_APPLY: { + case IDC_BUTTON_APPLY: + { applyToCurrentIndex(); validateDialog(); - return TRUE; } + return TRUE; + } default: if (HIWORD(wParam) == CBN_SELCHANGE || HIWORD(wParam) == LBN_SELCHANGE) { - switch(LOWORD(wParam)) { + switch(LOWORD(wParam)) + { case IDC_KEY_COMBO: { auto i = ::SendDlgItemMessage(_hSelf, IDC_KEY_COMBO, CB_GETCURSEL, 0, 0); diff --git a/PowerEditor/src/WinControls/shortcut/shortcut.h b/PowerEditor/src/WinControls/shortcut/shortcut.h index e4f8d9c0b..24c1e5947 100644 --- a/PowerEditor/src/WinControls/shortcut/shortcut.h +++ b/PowerEditor/src/WinControls/shortcut/shortcut.h @@ -39,7 +39,7 @@ class NppParameters; void getKeyStrFromVal(UCHAR keyVal, generic_string & str); void getNameStrFromCmd(DWORD cmd, generic_string & str); -static int keyTranslate(int keyIn) { +static size_t keyTranslate(size_t keyIn) { switch (keyIn) { case VK_DOWN: return SCK_DOWN; case VK_UP: return SCK_UP; @@ -204,10 +204,10 @@ public: }; unsigned long getScintillaKeyID() const {return _scintillaKeyID;}; int getMenuCmdID() const {return _menuCmdID;}; - int toKeyDef(size_t index) const { + size_t toKeyDef(size_t index) const { KeyCombo kc = _keyCombos[index]; int keymod = (kc._isCtrl?SCMOD_CTRL:0) | (kc._isAlt?SCMOD_ALT:0) | (kc._isShift?SCMOD_SHIFT:0); - return keyTranslate((int)kc._key) + (keymod << 16); + return keyTranslate(kc._key) + (keymod << 16); }; KeyCombo getKeyComboByIndex(size_t index) const; @@ -373,15 +373,15 @@ private: class ScintillaAccelerator { //Handles accelerator keys for scintilla public: - ScintillaAccelerator() : _nrScintillas(0) {}; + ScintillaAccelerator() {}; void init(std::vector * vScintillas, HMENU hMenu, HWND menuParent); void updateKeys(); void updateKey(ScintillaKeyMap skmOld, ScintillaKeyMap skm); + size_t nbScintillas() { return _vScintillas.size(); }; private: - HMENU _hAccelMenu; - HWND _hMenuParent; + HMENU _hAccelMenu = nullptr; + HWND _hMenuParent = nullptr; std::vector _vScintillas; - int _nrScintillas; void updateMenuItemByID(ScintillaKeyMap skm, int id); }; diff --git a/PowerEditor/src/lastRecentFileList.cpp b/PowerEditor/src/lastRecentFileList.cpp index 8e6ba7412..84f9a768c 100644 --- a/PowerEditor/src/lastRecentFileList.cpp +++ b/PowerEditor/src/lastRecentFileList.cpp @@ -199,7 +199,7 @@ void LastRecentFileList::remove(size_t index) { if (_size == 0 || _locked) return; - if (index > -1 && index < (int)_lrfl.size()) + if (index < _lrfl.size()) { ::RemoveMenu(_hMenu, _lrfl.at(index)._id, MF_BYCOMMAND); setAvailable(_lrfl.at(index)._id); diff --git a/PowerEditor/src/uchardet/CharDistribution.h b/PowerEditor/src/uchardet/CharDistribution.h index e0d2daeaa..5b22295da 100644 --- a/PowerEditor/src/uchardet/CharDistribution.h +++ b/PowerEditor/src/uchardet/CharDistribution.h @@ -132,8 +132,8 @@ protected: // first byte range: 0xc4 -- 0xfe // second byte range: 0xa1 -- 0xfe //no validation needed here. State machine has done that - PRInt32 GetOrder(const char* str) - { if ((unsigned char)*str >= (unsigned char)0xc4) + PRInt32 GetOrder(const char* str) { + if ((unsigned char)*str >= (unsigned char)0xc4) return 94*((unsigned char)str[0]-(unsigned char)0xc4) + (unsigned char)str[1] - (unsigned char)0xa1; else return -1; diff --git a/PowerEditor/src/winmain.cpp b/PowerEditor/src/winmain.cpp index ad64dabe0..7569c92ed 100644 --- a/PowerEditor/src/winmain.cpp +++ b/PowerEditor/src/winmain.cpp @@ -523,7 +523,7 @@ DEVOMER*/ { TCHAR message[1024]; //TODO: sane number wsprintf(message, TEXT("An exception occured. Notepad++ cannot recover and must be shut down.\r\nThe exception details are as follows:\r\n") - TEXT("Code:\t0x%08X\r\nType:\t%S\r\nException address: 0x%08X"), ex.code(), ex.what(), (long)ex.where()); + TEXT("Code:\t0x%08X\r\nType:\t%S\r\nException address: 0x%08X"), ex.code(), ex.what(), reinterpret_cast(ex.where())); ::MessageBox(Notepad_plus_Window::gNppHWND, message, TEXT("Win32Exception"), MB_OK | MB_ICONERROR); mdump.writeDump(ex.info()); doException(notepad_plus_plus); @@ -539,5 +539,5 @@ DEVOMER*/ doException(notepad_plus_plus); } - return (UINT)msg.wParam; + return static_cast(msg.wParam); } \ No newline at end of file