diff --git a/PowerEditor/installer/nativeLang/english.xml b/PowerEditor/installer/nativeLang/english.xml index 0a1666f8d..563b19a0f 100644 --- a/PowerEditor/installer/nativeLang/english.xml +++ b/PowerEditor/installer/nativeLang/english.xml @@ -547,12 +547,12 @@ Translation note: - - - - - - + + + + + + diff --git a/PowerEditor/installer/nativeLang/english_customizable.xml b/PowerEditor/installer/nativeLang/english_customizable.xml index 22784ac58..74cd93a59 100644 --- a/PowerEditor/installer/nativeLang/english_customizable.xml +++ b/PowerEditor/installer/nativeLang/english_customizable.xml @@ -547,12 +547,12 @@ Translation note: - - - - - - + + + + + + diff --git a/PowerEditor/src/WinControls/PluginsAdmin/pluginsAdmin.cpp b/PowerEditor/src/WinControls/PluginsAdmin/pluginsAdmin.cpp index cf8cef3a4..f9288499d 100644 --- a/PowerEditor/src/WinControls/PluginsAdmin/pluginsAdmin.cpp +++ b/PowerEditor/src/WinControls/PluginsAdmin/pluginsAdmin.cpp @@ -127,7 +127,7 @@ void PluginsAdminDlg::create(int dialogID, bool isRTL, bool msgDestParent) StaticDialog::create(dialogID, isRTL, msgDestParent); - RECT rect; + RECT rect{}; getClientRect(rect); _tab.init(_hInst, _hSelf, false, true); NppDarkMode::subclassTabControl(_tab.getHSelf()); @@ -146,124 +146,53 @@ void PluginsAdminDlg::create(int dialogID, bool isRTL, bool msgDestParent) _tab.insertAtEnd(installed); _tab.insertAtEnd(incompatible); - rect.bottom -= dpiManager.scaleY(105); + RECT rcDesc{}; + getMappedChildRect(IDC_PLUGINADM_EDIT, rcDesc); + + const long margeX = ::GetSystemMetrics(SM_CXEDGE); + const long margeY = tabDpiDynamicalHeight; + + rect.bottom = rcDesc.bottom + margeY; _tab.reSizeTo(rect); _tab.display(); - const long marge = dpiManager.scaleX(10); - const int topMarge = dpiManager.scaleY(42); + RECT rcSearch{}; + getMappedChildRect(IDC_PLUGINADM_SEARCH_EDIT, rcSearch); - HWND hResearchLabel = ::GetDlgItem(_hSelf, IDC_PLUGINADM_SEARCH_STATIC); - RECT researchLabelRect; - ::GetClientRect(hResearchLabel, &researchLabelRect); - researchLabelRect.left = rect.left + marge; - long leftCusor = researchLabelRect.left + researchLabelRect.right; - researchLabelRect.top = topMarge + dpiManager.scaleY(4); - ::MoveWindow(hResearchLabel, researchLabelRect.left, researchLabelRect.top, researchLabelRect.right, researchLabelRect.bottom, TRUE); - ::InvalidateRect(hResearchLabel, nullptr, TRUE); - - HWND hResearchEdit = ::GetDlgItem(_hSelf, IDC_PLUGINADM_SEARCH_EDIT); - RECT researchEditRect; - ::GetClientRect(hResearchEdit, &researchEditRect); - researchEditRect.left = leftCusor; - leftCusor += researchEditRect.right; - researchEditRect.top = topMarge + dpiManager.scaleX(1); - ::MoveWindow(hResearchEdit, researchEditRect.left, researchEditRect.top, researchEditRect.right, researchEditRect.bottom, TRUE); - ::InvalidateRect(hResearchEdit, nullptr, TRUE); - - HWND hNextButton = ::GetDlgItem(_hSelf, IDC_PLUGINADM_RESEARCH_NEXT); - RECT researchNextRect; - ::GetClientRect(hNextButton, &researchNextRect); - researchNextRect.left = leftCusor + marge; - leftCusor = researchNextRect.left + researchNextRect.right; - researchNextRect.top = topMarge; - ::MoveWindow(hNextButton, researchNextRect.left, researchNextRect.top, researchNextRect.right, researchNextRect.bottom, TRUE); - ::InvalidateRect(hNextButton, nullptr, TRUE); - - HWND hActionButton = ::GetDlgItem(_hSelf, IDC_PLUGINADM_INSTALL); - RECT actionRect; - ::GetClientRect(hActionButton, &actionRect); - long w = actionRect.right - actionRect.left; - actionRect.left = rect.right - w - marge; - actionRect.top = topMarge; - ::MoveWindow(hActionButton, actionRect.left, actionRect.top, actionRect.right, actionRect.bottom, TRUE); - ::InvalidateRect(hActionButton, nullptr, TRUE); - - hActionButton = ::GetDlgItem(_hSelf, IDC_PLUGINADM_UPDATE); - ::MoveWindow(hActionButton, actionRect.left, actionRect.top, actionRect.right, actionRect.bottom, TRUE); - ::InvalidateRect(hActionButton, nullptr, TRUE); - - hActionButton = ::GetDlgItem(_hSelf, IDC_PLUGINADM_REMOVE); - ::MoveWindow(hActionButton, actionRect.left, actionRect.top, actionRect.right, actionRect.bottom, TRUE); - ::InvalidateRect(hActionButton, nullptr, TRUE); - - long actionZoneHeight = dpiManager.scaleY(50); - rect.top += actionZoneHeight; - rect.bottom -= actionZoneHeight; - - RECT listRect = rect; - RECT descRect = rect; - - long descHeight = rect.bottom / 3 - marge; - long listHeight = (rect.bottom / 3) * 2 - marge * 3; - - listRect.top += marge; - listRect.bottom = listHeight; - listRect.left += marge; - listRect.right -= marge * 2; - - descRect.top += listHeight + marge * 3; - descRect.bottom = descHeight; - descRect.left += marge; - descRect.right -= marge * 2; + RECT listRect{ + rcDesc.left - margeX, + rcSearch.bottom + margeY, + rcDesc.right + ::GetSystemMetrics(SM_CXVSCROLL) + margeX, + rcDesc.top - margeY + }; NppParameters& nppParam = NppParameters::getInstance(); NativeLangSpeaker *pNativeSpeaker = nppParam.getNativeLangSpeaker(); generic_string pluginStr = pNativeSpeaker->getAttrNameStr(TEXT("Plugin"), "PluginAdmin", "Plugin"); generic_string vesionStr = pNativeSpeaker->getAttrNameStr(TEXT("Version"), "PluginAdmin", "Version"); - COLORREF fgColor = (NppParameters::getInstance()).getCurrentDefaultFgColor(); - COLORREF bgColor = (NppParameters::getInstance()).getCurrentDefaultBgColor(); + const COLORREF fgColor = nppParam.getCurrentDefaultFgColor(); + const COLORREF bgColor = nppParam.getCurrentDefaultBgColor(); - _availableList.addColumn(columnInfo(pluginStr, nppParam._dpiManager.scaleX(200))); - _availableList.addColumn(columnInfo(vesionStr, nppParam._dpiManager.scaleX(100))); - _availableList.setViewStyleOption(LVS_EX_CHECKBOXES); - _availableList.initView(_hInst, _hSelf); - ListView_SetBkColor(_availableList.getViewHwnd(), bgColor); - ListView_SetTextBkColor(_availableList.getViewHwnd(), bgColor); - ListView_SetTextColor(_availableList.getViewHwnd(), fgColor); - _availableList.reSizeView(listRect); - - _updateList.addColumn(columnInfo(pluginStr, nppParam._dpiManager.scaleX(200))); - _updateList.addColumn(columnInfo(vesionStr, nppParam._dpiManager.scaleX(100))); - _updateList.setViewStyleOption(LVS_EX_CHECKBOXES); - _updateList.initView(_hInst, _hSelf); - ListView_SetBkColor(_updateList.getViewHwnd(), bgColor); - ListView_SetTextBkColor(_updateList.getViewHwnd(), bgColor); - ListView_SetTextColor(_updateList.getViewHwnd(), fgColor); - _updateList.reSizeView(listRect); + const size_t szColVer = dpiManager.scaleX(100); + const size_t szColName = szColVer * 2; - _installedList.addColumn(columnInfo(pluginStr, nppParam._dpiManager.scaleX(200))); - _installedList.addColumn(columnInfo(vesionStr, nppParam._dpiManager.scaleX(100))); - _installedList.setViewStyleOption(LVS_EX_CHECKBOXES); - _installedList.initView(_hInst, _hSelf); - ListView_SetBkColor(_installedList.getViewHwnd(), bgColor); - ListView_SetTextBkColor(_installedList.getViewHwnd(), bgColor); - ListView_SetTextColor(_installedList.getViewHwnd(), fgColor); - _installedList.reSizeView(listRect); + auto initListView = [&](PluginViewList& list) -> void { + list.addColumn(columnInfo(pluginStr, szColName)); + list.addColumn(columnInfo(vesionStr, szColVer)); + list.setViewStyleOption(LVS_EX_CHECKBOXES); + list.initView(_hInst, _hSelf); + const HWND hList = list.getViewHwnd(); + ListView_SetBkColor(hList, bgColor); + ListView_SetTextBkColor(hList, bgColor); + ListView_SetTextColor(hList, fgColor); + list.reSizeView(listRect); + }; - _incompatibleList.addColumn(columnInfo(pluginStr, nppParam._dpiManager.scaleX(200))); - _incompatibleList.addColumn(columnInfo(vesionStr, nppParam._dpiManager.scaleX(100))); - _incompatibleList.initView(_hInst, _hSelf); - ListView_SetBkColor(_incompatibleList.getViewHwnd(), bgColor); - ListView_SetTextBkColor(_incompatibleList.getViewHwnd(), bgColor); - ListView_SetTextColor(_incompatibleList.getViewHwnd(), fgColor); - _incompatibleList.reSizeView(listRect); - - - HWND hDesc = ::GetDlgItem(_hSelf, IDC_PLUGINADM_EDIT); - ::MoveWindow(hDesc, descRect.left, descRect.top, descRect.right, descRect.bottom, TRUE); - ::InvalidateRect(hDesc, nullptr, TRUE); + initListView(_availableList); + initListView(_updateList); + initListView(_installedList); + initListView(_incompatibleList); switchDialog(0); @@ -276,7 +205,7 @@ void PluginsAdminDlg::create(int dialogID, bool isRTL, bool msgDestParent) _repoLink.init(_hInst, _hSelf); _repoLink.create(::GetDlgItem(_hSelf, IDC_PLUGINLIST_ADDR), TEXT("https://github.com/notepad-plus-plus/nppPluginList")); - goToCenter(); + goToCenter(SWP_SHOWWINDOW | SWP_NOSIZE); } void PluginsAdminDlg::collectNppCurrentStatusInfos() @@ -296,7 +225,7 @@ vector PluginViewList::fromUiIndexesToPluginInfos(const std:: std::vector r; size_t nb = _ui.nbItem(); - for (auto i : uiIndexes) + for (const auto &i : uiIndexes) { if (i < nb) { @@ -353,7 +282,7 @@ bool PluginsAdminDlg::exitToInstallRemovePlugins(Operation op, const vector_folderName == folderName) { @@ -1066,8 +995,8 @@ bool PluginsAdminDlg::checkUpdates() // begin insentive-case search from the second key-in character bool PluginsAdminDlg::searchInPlugins(bool isNextMode) const { - const int maxLen = 256; - TCHAR txt2search[maxLen]; + constexpr int maxLen = 256; + TCHAR txt2search[maxLen]{}; ::GetDlgItemText(_hSelf, IDC_PLUGINADM_SEARCH_EDIT, txt2search, maxLen); if (lstrlen(txt2search) < 2) return false; @@ -1210,35 +1139,24 @@ intptr_t CALLBACK PluginsAdminDlg::run_dlgProc(UINT message, WPARAM wParam, LPAR { case WM_CTLCOLOREDIT: { - if (NppDarkMode::isEnabled()) - { - return NppDarkMode::onCtlColorSofter(reinterpret_cast(wParam)); - } - break; + return NppDarkMode::onCtlColorSofter(reinterpret_cast(wParam)); } case WM_CTLCOLORDLG: { - if (NppDarkMode::isEnabled()) - { - return NppDarkMode::onCtlColorDarker(reinterpret_cast(wParam)); - } - break; + return NppDarkMode::onCtlColorDarker(reinterpret_cast(wParam)); } case WM_CTLCOLORSTATIC: { if (NppDarkMode::isEnabled()) { - HWND hwnd = reinterpret_cast(lParam); - if (hwnd == ::GetDlgItem(_hSelf, IDC_PLUGINADM_EDIT)) + const int dlgCtrlID = ::GetDlgCtrlID(reinterpret_cast(lParam)); + if (dlgCtrlID == IDC_PLUGINADM_EDIT) { return NppDarkMode::onCtlColor(reinterpret_cast(wParam)); } - else - { - return NppDarkMode::onCtlColorDarker(reinterpret_cast(wParam)); - } + return NppDarkMode::onCtlColorDarker(reinterpret_cast(wParam)); } break; } @@ -1319,13 +1237,13 @@ intptr_t CALLBACK PluginsAdminDlg::run_dlgProc(UINT message, WPARAM wParam, LPAR switchDialog(indexClicked); } } - else if (pnmh->hwndFrom == _availableList.getViewHwnd() || + else if (pnmh->hwndFrom == _availableList.getViewHwnd() || pnmh->hwndFrom == _updateList.getViewHwnd() || pnmh->hwndFrom == _installedList.getViewHwnd() || pnmh->hwndFrom == _incompatibleList.getViewHwnd()) { - PluginViewList* pViewList; - int buttonID; + PluginViewList* pViewList = nullptr; + int buttonID = 0; if (pnmh->hwndFrom == _availableList.getViewHwnd()) { diff --git a/PowerEditor/src/WinControls/PluginsAdmin/pluginsAdmin.h b/PowerEditor/src/WinControls/PluginsAdmin/pluginsAdmin.h index 32bb2f345..6bf16fa8d 100644 --- a/PowerEditor/src/WinControls/PluginsAdmin/pluginsAdmin.h +++ b/PowerEditor/src/WinControls/PluginsAdmin/pluginsAdmin.h @@ -99,7 +99,7 @@ public: PluginViewList() = default; ~PluginViewList() { _ui.destroy(); - for (auto i : _list) + for (auto& i : _list) { delete i; } @@ -114,7 +114,7 @@ public: void setSelection(int index) const { _ui.setSelection(index); }; void initView(HINSTANCE hInst, HWND parent) { _ui.init(hInst, parent); }; void addColumn(const columnInfo & column2Add) { _ui.addColumn(column2Add); }; - void reSizeView(RECT & rc) { _ui.reSizeTo(rc); } + void reSizeView(RECT & rc) { _ui.reSizeToWH(rc); } void setViewStyleOption(int32_t extraStyle) { _ui.setStyleOption(extraStyle); }; size_t nbItem() const { return _ui.nbItem(); }; PluginUpdateInfo* getPluginInfoFromUiIndex(size_t index) const { return reinterpret_cast(_ui.getLParamFromIndex(static_cast(index))); }; @@ -145,24 +145,15 @@ public : PluginsAdminDlg(); ~PluginsAdminDlg() = default; - void init(HINSTANCE hInst, HWND parent) { - Window::init(hInst, parent); - }; + void create(int dialogID, bool isRTL = false, bool msgDestParent = true) override; - virtual void create(int dialogID, bool isRTL = false, bool msgDestParent = true); - - void doDialog(bool isRTL = false) { - if (!isCreated()) + void doDialog(bool isRTL = false) { + if (!isCreated()) { create(IDD_PLUGINSADMIN_DLG, isRTL); } - - if (!::IsWindowVisible(_hSelf)) - { - - } - display(); - }; + display(); + }; bool initFromJson(); @@ -188,7 +179,7 @@ public : }; protected: - virtual intptr_t CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam); + intptr_t CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam) override; private : generic_string _updaterDir; diff --git a/PowerEditor/src/WinControls/PluginsAdmin/pluginsAdmin.rc b/PowerEditor/src/WinControls/PluginsAdmin/pluginsAdmin.rc index d59f4fb8c..bcc455076 100644 --- a/PowerEditor/src/WinControls/PluginsAdmin/pluginsAdmin.rc +++ b/PowerEditor/src/WinControls/PluginsAdmin/pluginsAdmin.rc @@ -18,25 +18,21 @@ #include "windows.h" #include "pluginsAdminRes.h" -#ifndef IDC_STATIC -#define IDC_STATIC -1 -#endif - -IDD_PLUGINSADMIN_DLG DIALOGEX 36, 44, 500, 300 +IDD_PLUGINSADMIN_DLG DIALOGEX 0, 0, 500, 265 STYLE DS_SETFONT | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU EXSTYLE WS_EX_DLGMODALFRAME | WS_EX_WINDOWEDGE CAPTION "Plugins Admin" FONT 8, "MS Shell Dlg", 0, 0, 0x0 BEGIN - RTEXT "Search: ",IDC_PLUGINADM_SEARCH_STATIC,50,38,50,8 - EDITTEXT IDC_PLUGINADM_SEARCH_EDIT,160,35,150,14,ES_AUTOHSCROLL - PUSHBUTTON "Next", IDC_PLUGINADM_RESEARCH_NEXT,332,35,57,14 - PUSHBUTTON "Install", IDC_PLUGINADM_INSTALL,432,35,57,14 - PUSHBUTTON "Update", IDC_PLUGINADM_UPDATE,432,35,57,14 - PUSHBUTTON "Remove", IDC_PLUGINADM_REMOVE,432,35,57,14 - EDITTEXT IDC_PLUGINADM_EDIT,30,160,220,80,ES_MULTILINE | ES_AUTOVSCROLL | ES_READONLY | WS_BORDER | WS_VSCROLL - RTEXT "Plugin list version: ", IDC_PLUGINLIST_VERSION_STATIC,350,242,120,14 - RTEXT "", IDC_PLUGINLIST_VERSIONNUMBER_STATIC,467,242,22,14 - RTEXT "Plugin list repository",IDC_PLUGINLIST_ADDR,369,257,120,14 - PUSHBUTTON "Close", IDCANCEL, 225, 270, 57, 14 + RTEXT "&Search:",IDC_PLUGINADM_SEARCH_STATIC,16,20,50,8 + EDITTEXT IDC_PLUGINADM_SEARCH_EDIT,69,19,150,12,ES_AUTOHSCROLL + PUSHBUTTON "&Next",IDC_PLUGINADM_RESEARCH_NEXT,222,18,60,14 + PUSHBUTTON "&Install",IDC_PLUGINADM_INSTALL,432,18,60,14 + PUSHBUTTON "&Update",IDC_PLUGINADM_UPDATE,432,18,60,14 + PUSHBUTTON "&Remove",IDC_PLUGINADM_REMOVE,432,18,60,14 + EDITTEXT IDC_PLUGINADM_EDIT,8,167,484,60,ES_MULTILINE | ES_AUTOVSCROLL | ES_READONLY | WS_VSCROLL + RTEXT "Plugin list version:",IDC_PLUGINLIST_VERSION_STATIC,348,234,120,8 + RTEXT "",IDC_PLUGINLIST_VERSIONNUMBER_STATIC,467,234,22,8 + RTEXT "Plugin list repository",IDC_PLUGINLIST_ADDR,369,247,120,14 + PUSHBUTTON "Close",IDCANCEL,220,245,60,14 END diff --git a/PowerEditor/src/WinControls/StaticDialog/StaticDialog.cpp b/PowerEditor/src/WinControls/StaticDialog/StaticDialog.cpp index b231089d5..25d3cc831 100644 --- a/PowerEditor/src/WinControls/StaticDialog/StaticDialog.cpp +++ b/PowerEditor/src/WinControls/StaticDialog/StaticDialog.cpp @@ -36,12 +36,23 @@ void StaticDialog::destroy() ::DestroyWindow(_hSelf); } +void StaticDialog::getMappedChildRect(HWND hChild, RECT& rcChild) const +{ + ::GetClientRect(hChild, &rcChild); + ::MapWindowPoints(hChild, _hSelf, reinterpret_cast(&rcChild), 2); +} + +void StaticDialog::getMappedChildRect(int idChild, RECT& rcChild) const +{ + const HWND hChild = ::GetDlgItem(_hSelf, idChild); + getMappedChildRect(hChild, rcChild); +} + void StaticDialog::redrawDlgItem(const int nIDDlgItem, bool forceUpdate) const { RECT rcDlgItem{}; const HWND hDlgItem = ::GetDlgItem(_hSelf, nIDDlgItem); - ::GetClientRect(hDlgItem, &rcDlgItem); - ::MapWindowPoints(hDlgItem, _hSelf, reinterpret_cast(&rcDlgItem), 2); + getMappedChildRect(hDlgItem, rcDlgItem); ::InvalidateRect(_hSelf, &rcDlgItem, TRUE); if (forceUpdate) diff --git a/PowerEditor/src/WinControls/StaticDialog/StaticDialog.h b/PowerEditor/src/WinControls/StaticDialog/StaticDialog.h index b00aa491a..aba41befc 100644 --- a/PowerEditor/src/WinControls/StaticDialog/StaticDialog.h +++ b/PowerEditor/src/WinControls/StaticDialog/StaticDialog.h @@ -43,10 +43,12 @@ public : virtual void create(int dialogID, bool isRTL = false, bool msgDestParent = true); - virtual bool isCreated() const { - return (_hSelf != NULL); + virtual bool isCreated() const { + return (_hSelf != nullptr); } + void getMappedChildRect(HWND hChild, RECT& rcChild) const; + void getMappedChildRect(int idChild, RECT& rcChild) const; void redrawDlgItem(const int nIDDlgItem, bool forceUpdate = false) const; void goToCenter(UINT swpFlags = SWP_SHOWWINDOW);