diff --git a/PowerEditor/installer/nativeLang/english.xml b/PowerEditor/installer/nativeLang/english.xml index cc4a3b042..fafd8c6fc 100644 --- a/PowerEditor/installer/nativeLang/english.xml +++ b/PowerEditor/installer/nativeLang/english.xml @@ -1613,7 +1613,6 @@ Find in all files but exclude all folders log or logs recursively: - diff --git a/PowerEditor/src/WinControls/Preference/preference.rc b/PowerEditor/src/WinControls/Preference/preference.rc index e292df8b4..1cef4ad6c 100644 --- a/PowerEditor/src/WinControls/Preference/preference.rc +++ b/PowerEditor/src/WinControls/Preference/preference.rc @@ -249,14 +249,16 @@ BEGIN PUSHBUTTON "<-",IDC_BUTTON_RESTORE,132,107,25,14 CTEXT "Disabled items",IDC_DISABLEDITEMS_STATIC,167,31,72,8 LISTBOX IDC_LIST_DISABLEDLANG,164,44,78,120,LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP + GROUPBOX "Tab Settings",IDC_TABSETTING_GB_STATIC,275,0,130,172,BS_CENTER LISTBOX IDC_LIST_TABSETTNG,297,18,84,100,LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP + GROUPBOX "",IDC_GR_TABVALUE_STATIC,287,125,110,42,BS_CENTER CONTROL "Use default value",IDC_CHECK_DEFAULTTABVALUE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,283,125,85,10 - RTEXT "Tab size : ",IDC_TABSIZE_STATIC,288,138,58,8 - LTEXT "0",IDC_TABSIZEVAL_STATIC,348,138,18,8,WS_TABSTOP - LTEXT "0",IDC_TABSIZEVAL_DISABLE_STATIC,348,138,18,8 + RTEXT "Tab size: ",IDC_TABSIZE_STATIC,288,138,58,8 + EDITTEXT IDC_EDIT_TABSIZEVAL,348,136,14,12,ES_CENTER | ES_NUMBER | WS_TABSTOP CONTROL "Replace by space",IDC_CHECK_REPLACEBYSPACE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,295,149,100,10 + CONTROL "Treat backslash as escape character for SQL",IDC_CHECK_BACKSLASHISESCAPECHARACTERFORSQL, "Button",BS_AUTOCHECKBOX | WS_TABSTOP,37,175,217,10 END diff --git a/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp b/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp index f7db00b42..3dc9af039 100644 --- a/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp +++ b/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp @@ -2100,14 +2100,14 @@ intptr_t CALLBACK MiscSubDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM) { case IDC_EDIT_SESSIONFILEEXT: { - TCHAR sessionExt[MAX_PATH]; + TCHAR sessionExt[MAX_PATH] = { '\0' }; ::SendDlgItemMessage(_hSelf, IDC_EDIT_SESSIONFILEEXT, WM_GETTEXT, MAX_PATH, reinterpret_cast(sessionExt)); nppGUI._definedSessionExt = sessionExt; return TRUE; } case IDC_EDIT_WORKSPACEFILEEXT: { - TCHAR workspaceExt[MAX_PATH]; + TCHAR workspaceExt[MAX_PATH] = { '\0' }; ::SendDlgItemMessage(_hSelf, IDC_EDIT_WORKSPACEFILEEXT, WM_GETTEXT, MAX_PATH, reinterpret_cast(workspaceExt)); nppGUI._definedWorkspaceExt = workspaceExt; return TRUE; @@ -2826,10 +2826,7 @@ intptr_t CALLBACK LanguageSubDlg::run_dlgProc(UINT message, WPARAM wParam, LPARA // // Tab settings // - ::SetDlgItemInt(_hSelf, IDC_TABSIZEVAL_STATIC, nppGUI._tabSize, FALSE); - - _tabSizeVal.init(_hInst, _hSelf); - _tabSizeVal.create(::GetDlgItem(_hSelf, IDC_TABSIZEVAL_STATIC), IDC_TABSIZEVAL_STATIC); + ::SetDlgItemInt(_hSelf, IDC_EDIT_TABSIZEVAL, nppGUI._tabSize, FALSE); ::SendDlgItemMessage(_hSelf, IDC_CHECK_REPLACEBYSPACE, BM_SETCHECK, nppGUI._tabReplacedBySpace, 0); ::SendDlgItemMessage(_hSelf, IDC_LIST_TABSETTNG, LB_ADDSTRING, 0, reinterpret_cast(TEXT("[Default]"))); @@ -2842,31 +2839,44 @@ intptr_t CALLBACK LanguageSubDlg::run_dlgProc(UINT message, WPARAM wParam, LPARA ::SendDlgItemMessage(_hSelf, IDC_LIST_TABSETTNG, LB_SETCURSEL, index2Begin, 0); ::ShowWindow(::GetDlgItem(_hSelf, IDC_GR_TABVALUE_STATIC), SW_HIDE); ::ShowWindow(::GetDlgItem(_hSelf, IDC_CHECK_DEFAULTTABVALUE), SW_HIDE); - ::EnableWindow(::GetDlgItem(_hSelf, IDC_TABSIZEVAL_DISABLE_STATIC), FALSE); - ::ShowWindow(::GetDlgItem(_hSelf, IDC_TABSIZEVAL_DISABLE_STATIC), SW_HIDE); ::SendDlgItemMessage(_hSelf, IDC_CHECK_BACKSLASHISESCAPECHARACTERFORSQL, BM_SETCHECK, nppGUI._backSlashIsEscapeCharacterForSql, 0); return TRUE; } + case WM_CTLCOLOREDIT: + { + return NppDarkMode::onCtlColorSofter(reinterpret_cast(wParam)); + } + case WM_CTLCOLORLISTBOX: { - if (NppDarkMode::isEnabled()) - { - return NppDarkMode::onCtlColorListbox(wParam, lParam); - } - break; + return NppDarkMode::onCtlColorListbox(wParam, lParam); } case WM_CTLCOLORDLG: + { + return NppDarkMode::onCtlColorDarker(reinterpret_cast(wParam)); + } + case WM_CTLCOLORSTATIC: { - if (NppDarkMode::isEnabled()) + const int dlgCtrlID = ::GetDlgCtrlID(reinterpret_cast(lParam)); + const auto& hdcStatic = reinterpret_cast(wParam); + // handle blurry text with disabled states for the affected static controls + const size_t index = ::SendDlgItemMessage(_hSelf, IDC_LIST_TABSETTNG, LB_GETCURSEL, 0, 0); + if ((index > 0) && (dlgCtrlID == IDC_TABSIZE_STATIC)) { - return NppDarkMode::onCtlColorDarker(reinterpret_cast(wParam)); + const Lang* lang = nppParam.getLangFromIndex(index - 1); + if (lang == nullptr) + { + return NppDarkMode::onCtlColorDarker(hdcStatic); + } + const bool useDefaultTab = isCheckedOrNot(IDC_CHECK_DEFAULTTABVALUE); + return NppDarkMode::onCtlColorDarkerBGStaticText(hdcStatic, !useDefaultTab); } - break; + return NppDarkMode::onCtlColorDarker(hdcStatic); } case WM_PRINTCLIENT: @@ -2880,106 +2890,204 @@ intptr_t CALLBACK LanguageSubDlg::run_dlgProc(UINT message, WPARAM wParam, LPARA case WM_COMMAND : { - if (HIWORD(wParam) == LBN_SELCHANGE) - { - // Lang Menu - if (LOWORD(wParam) == IDC_LIST_DISABLEDLANG || LOWORD(wParam) == IDC_LIST_ENABLEDLANG) + switch (HIWORD(wParam)) + { + case LBN_SELCHANGE: { - int idButton2Enable; - int idButton2Disable; - - if (LOWORD(wParam) == IDC_LIST_ENABLEDLANG) + // Lang Menu + if (LOWORD(wParam) == IDC_LIST_DISABLEDLANG || LOWORD(wParam) == IDC_LIST_ENABLEDLANG) { - idButton2Enable = IDC_BUTTON_REMOVE; - idButton2Disable = IDC_BUTTON_RESTORE; - } - else //IDC_LIST_DISABLEDLANG - { - idButton2Enable = IDC_BUTTON_RESTORE; - idButton2Disable = IDC_BUTTON_REMOVE; - } + int idButton2Enable; + int idButton2Disable; - auto i = ::SendDlgItemMessage(_hSelf, LOWORD(wParam), LB_GETCURSEL, 0, 0); - if (i != LB_ERR) - { - ::EnableWindow(::GetDlgItem(_hSelf, idButton2Enable), TRUE); - int idListbox2Disable = (LOWORD(wParam)== IDC_LIST_ENABLEDLANG)?IDC_LIST_DISABLEDLANG:IDC_LIST_ENABLEDLANG; - ::SendDlgItemMessage(_hSelf, idListbox2Disable, LB_SETCURSEL, static_cast(-1), 0); - ::EnableWindow(::GetDlgItem(_hSelf, idButton2Disable), FALSE); - } - return TRUE; - - } - // Tab setting - else if (LOWORD(wParam) == IDC_LIST_TABSETTNG) - { - auto index = ::SendDlgItemMessage(_hSelf, IDC_LIST_TABSETTNG, LB_GETCURSEL, 0, 0); - if (index == LB_ERR) - return FALSE; - ::ShowWindow(::GetDlgItem(_hSelf, IDC_GR_TABVALUE_STATIC), index ? SW_SHOW : SW_HIDE); - ::ShowWindow(::GetDlgItem(_hSelf, IDC_CHECK_DEFAULTTABVALUE), index ? SW_SHOW : SW_HIDE); - - if (index) - { - Lang *lang = nppParam.getLangFromIndex(index - 1); - if (!lang) return FALSE; - bool useDefaultTab = (lang->_tabSize == -1 || lang->_tabSize == 0); - - ::SendMessage(::GetDlgItem(_hSelf, IDC_CHECK_DEFAULTTABVALUE), BM_SETCHECK, useDefaultTab, 0); - ::EnableWindow(::GetDlgItem(_hSelf, IDC_TABSIZE_STATIC), !useDefaultTab); - - int size = useDefaultTab ? nppGUI._tabSize : lang->_tabSize; - ::SetDlgItemInt(_hSelf, IDC_TABSIZEVAL_STATIC, size, FALSE); - ::SetDlgItemInt(_hSelf, IDC_TABSIZEVAL_DISABLE_STATIC, size, FALSE); - - ::EnableWindow(::GetDlgItem(_hSelf, IDC_TABSIZEVAL_STATIC), !useDefaultTab); - ::ShowWindow(::GetDlgItem(_hSelf, IDC_TABSIZEVAL_DISABLE_STATIC), useDefaultTab); - ::ShowWindow(::GetDlgItem(_hSelf, IDC_TABSIZEVAL_STATIC), !useDefaultTab); - ::SendMessage(::GetDlgItem(_hSelf, IDC_CHECK_REPLACEBYSPACE), BM_SETCHECK, useDefaultTab ? nppGUI._tabReplacedBySpace : lang->_isTabReplacedBySpace, 0); - ::EnableWindow(::GetDlgItem(_hSelf, IDC_CHECK_REPLACEBYSPACE), !useDefaultTab); - - if (!useDefaultTab) + if (LOWORD(wParam) == IDC_LIST_ENABLEDLANG) { - ::SetDlgItemInt(_hSelf, IDC_TABSIZEVAL_STATIC, lang->_tabSize, FALSE); - ::SendMessage(::GetDlgItem(_hSelf, IDC_CHECK_REPLACEBYSPACE), BM_SETCHECK, lang->_isTabReplacedBySpace, 0); + idButton2Enable = IDC_BUTTON_REMOVE; + idButton2Disable = IDC_BUTTON_RESTORE; + } + else //IDC_LIST_DISABLEDLANG + { + idButton2Enable = IDC_BUTTON_RESTORE; + idButton2Disable = IDC_BUTTON_REMOVE; + } + + auto i = ::SendDlgItemMessage(_hSelf, LOWORD(wParam), LB_GETCURSEL, 0, 0); + if (i != LB_ERR) + { + ::EnableWindow(::GetDlgItem(_hSelf, idButton2Enable), TRUE); + int idListbox2Disable = (LOWORD(wParam) == IDC_LIST_ENABLEDLANG) ? IDC_LIST_DISABLEDLANG : IDC_LIST_ENABLEDLANG; + ::SendDlgItemMessage(_hSelf, idListbox2Disable, LB_SETCURSEL, static_cast(-1), 0); + ::EnableWindow(::GetDlgItem(_hSelf, idButton2Disable), FALSE); + } + return TRUE; + + } + // Tab setting + else if (LOWORD(wParam) == IDC_LIST_TABSETTNG) + { + auto index = ::SendDlgItemMessage(_hSelf, IDC_LIST_TABSETTNG, LB_GETCURSEL, 0, 0); + if (index == LB_ERR) + return FALSE; + ::ShowWindow(::GetDlgItem(_hSelf, IDC_GR_TABVALUE_STATIC), index > 0 ? SW_SHOW : SW_HIDE); + ::ShowWindow(::GetDlgItem(_hSelf, IDC_CHECK_DEFAULTTABVALUE), index > 0 ? SW_SHOW : SW_HIDE); + + if (index > 0) + { + Lang* lang = nppParam.getLangFromIndex(index - 1); + if (!lang) return FALSE; + bool useDefaultTab = (lang->_tabSize == -1 || lang->_tabSize == 0); + + ::SendMessage(::GetDlgItem(_hSelf, IDC_CHECK_DEFAULTTABVALUE), BM_SETCHECK, useDefaultTab, 0); + + int size = useDefaultTab ? nppGUI._tabSize : lang->_tabSize; + ::SetDlgItemInt(_hSelf, IDC_EDIT_TABSIZEVAL, size, FALSE); + ::SendMessage(::GetDlgItem(_hSelf, IDC_CHECK_REPLACEBYSPACE), BM_SETCHECK, useDefaultTab ? nppGUI._tabReplacedBySpace : lang->_isTabReplacedBySpace, 0); + ::EnableWindow(::GetDlgItem(_hSelf, IDC_CHECK_REPLACEBYSPACE), !useDefaultTab); + ::EnableWindow(::GetDlgItem(_hSelf, IDC_EDIT_TABSIZEVAL), !useDefaultTab); + + if (!useDefaultTab) + { + ::SetDlgItemInt(_hSelf, IDC_EDIT_TABSIZEVAL, lang->_tabSize, FALSE); + ::SendMessage(::GetDlgItem(_hSelf, IDC_CHECK_REPLACEBYSPACE), BM_SETCHECK, lang->_isTabReplacedBySpace, 0); + } + } + else + { + ::SetDlgItemInt(_hSelf, IDC_EDIT_TABSIZEVAL, nppGUI._tabSize, FALSE); + ::EnableWindow(::GetDlgItem(_hSelf, IDC_CHECK_REPLACEBYSPACE), TRUE); + ::EnableWindow(::GetDlgItem(_hSelf, IDC_EDIT_TABSIZEVAL), TRUE); + ::SendMessage(::GetDlgItem(_hSelf, IDC_CHECK_REPLACEBYSPACE), BM_SETCHECK, nppGUI._tabReplacedBySpace, 0); + } + + redrawDlgItem(IDC_TABSIZE_STATIC); + + return TRUE; + } + + break; + } + + // Check if it is double click + case LBN_DBLCLK: + { + // Lang Menu + if (LOWORD(wParam) == IDC_LIST_DISABLEDLANG || LOWORD(wParam) == IDC_LIST_ENABLEDLANG) + { + // On double click an item, the item should be moved + // from one list to other list + + HWND(lParam) == ::GetDlgItem(_hSelf, IDC_LIST_ENABLEDLANG) ? + ::SendMessage(_hSelf, WM_COMMAND, IDC_BUTTON_REMOVE, 0) : + ::SendMessage(_hSelf, WM_COMMAND, IDC_BUTTON_RESTORE, 0); + return TRUE; + } + + // Tab setting - Double click is not used at this moment + /*else if (LOWORD(wParam) == IDC_LIST_TABSETTNG) + { + }*/ + + break; + } + + case EN_CHANGE: + { + switch (LOWORD(wParam)) + { + case IDC_EDIT_TABSIZEVAL: + { + const auto tabSize = ::GetDlgItemInt(_hSelf, IDC_EDIT_TABSIZEVAL, nullptr, FALSE); + if (tabSize < 1) + { + return FALSE; + } + + const bool useDefaultTab = isCheckedOrNot(IDC_CHECK_DEFAULTTABVALUE); + const size_t index = ::SendDlgItemMessage(_hSelf, IDC_LIST_TABSETTNG, LB_GETCURSEL, 0, 0); + if (!useDefaultTab && index > 0) + { + Lang* lang = nppParam.getLangFromIndex(index - 1); + if (lang == nullptr) + { + return FALSE; + } + + if (lang->_langID == L_JS) + { + Lang* ljs = nppParam.getLangFromID(L_JAVASCRIPT); + ljs->_tabSize = tabSize; + } + else if (lang->_langID == L_JAVASCRIPT) + { + Lang* ljavascript = nppParam.getLangFromID(L_JS); + ljavascript->_tabSize = tabSize; + } + + lang->_tabSize = tabSize; + + // write in langs.xml + nppParam.insertTabInfo(lang->getLangName(), lang->getTabInfo()); + } + else + { + nppGUI._tabSize = tabSize; + } + + ::SendMessage(::GetParent(_hParent), NPPM_INTERNAL_SETTING_TAB_SIZE, 0, 0); + return TRUE; + } + + default: + { + break; } } - else + break; + } + + case EN_KILLFOCUS: + { + switch (LOWORD(wParam)) { - ::EnableWindow(::GetDlgItem(_hSelf, IDC_TABSIZE_STATIC), TRUE); - ::EnableWindow(::GetDlgItem(_hSelf, IDC_TABSIZEVAL_STATIC), TRUE); - ::ShowWindow(::GetDlgItem(_hSelf, IDC_TABSIZEVAL_STATIC), SW_SHOW); - ::SetDlgItemInt(_hSelf, IDC_TABSIZEVAL_STATIC, nppGUI._tabSize, FALSE); - ::ShowWindow(::GetDlgItem(_hSelf, IDC_TABSIZEVAL_DISABLE_STATIC), SW_HIDE); - ::EnableWindow(::GetDlgItem(_hSelf, IDC_CHECK_REPLACEBYSPACE), TRUE); - ::SendMessage(::GetDlgItem(_hSelf, IDC_CHECK_REPLACEBYSPACE), BM_SETCHECK, nppGUI._tabReplacedBySpace, 0); + case IDC_EDIT_TABSIZEVAL: + { + const auto tabSize = ::GetDlgItemInt(_hSelf, IDC_EDIT_TABSIZEVAL, nullptr, FALSE); + + if (tabSize < 1) + { + const bool useDefaultTab = isCheckedOrNot(IDC_CHECK_DEFAULTTABVALUE); + const size_t index = ::SendDlgItemMessage(_hSelf, IDC_LIST_TABSETTNG, LB_GETCURSEL, 0, 0); + auto prevSize = nppGUI._tabSize; + if (!useDefaultTab && index > 0) + { + Lang* lang = nppParam.getLangFromIndex(index - 1); + if (lang != nullptr && lang->_tabSize > 0) + { + prevSize = lang->_tabSize; + } + } + + ::SetDlgItemInt(_hSelf, IDC_EDIT_TABSIZEVAL, prevSize, FALSE); + return TRUE; + } + return FALSE; + } + + default: + { + break; + } } - - return TRUE; - } - } - - // Check if it is double click - else if (HIWORD(wParam) == LBN_DBLCLK) - { - // Lang Menu - if (LOWORD(wParam) == IDC_LIST_DISABLEDLANG || LOWORD(wParam) == IDC_LIST_ENABLEDLANG) - { - // On double click an item, the item should be moved - // from one list to other list - - HWND(lParam) == ::GetDlgItem(_hSelf, IDC_LIST_ENABLEDLANG) ? - ::SendMessage(_hSelf, WM_COMMAND, IDC_BUTTON_REMOVE, 0) : - ::SendMessage(_hSelf, WM_COMMAND, IDC_BUTTON_RESTORE, 0); - return TRUE; + break; } - // Tab setting - Double click is not used at this moment - /*else if (LOWORD(wParam) == IDC_LIST_TABSETTNG) + default: { - }*/ + break; + } } + switch (wParam) { // @@ -3031,7 +3139,7 @@ intptr_t CALLBACK LanguageSubDlg::run_dlgProc(UINT message, WPARAM wParam, LPARA return TRUE; const size_t sL = 31; - TCHAR s[sL + 1]; + TCHAR s[sL + 1] = { '\0' }; auto lbTextLen = ::SendDlgItemMessage(_hSelf, list2Remove, LB_GETTEXTLEN, iRemove, 0); if (static_cast(lbTextLen) > sL) return TRUE; @@ -3101,56 +3209,6 @@ intptr_t CALLBACK LanguageSubDlg::run_dlgProc(UINT message, WPARAM wParam, LPARA return TRUE; } - // - // Tab setting - // - case IDC_TABSIZEVAL_STATIC: - { - generic_string staticText = pNativeSpeaker->getLocalizedStrFromID("language-tabsize", TEXT("Tab Size: ")); - ValueDlg tabSizeDlg; - tabSizeDlg.init(_hInst, _hParent, nppGUI._tabSize, staticText.c_str()); - POINT p; - ::GetCursorPos(&p); - int size = tabSizeDlg.doDialog(p); - - //Tab size 0 removal - if (size <= 0) return FALSE; - - ::SetDlgItemInt(_hSelf, IDC_TABSIZEVAL_STATIC, size, FALSE); - ::SetDlgItemInt(_hSelf, IDC_TABSIZEVAL_DISABLE_STATIC, size, FALSE); - - auto index = ::SendDlgItemMessage(_hSelf, IDC_LIST_TABSETTNG, LB_GETCURSEL, 0, 0); - if (index == LB_ERR) return FALSE; - - if (index != 0) - { - Lang *lang = nppParam.getLangFromIndex(index - 1); - if (!lang) return FALSE; - if (lang->_langID == L_JS) - { - Lang *ljs = nppParam.getLangFromID(L_JAVASCRIPT); - ljs->_tabSize = size; - } - else if (lang->_langID == L_JAVASCRIPT) - { - Lang *ljavascript = nppParam.getLangFromID(L_JS); - ljavascript->_tabSize = size; - } - - lang->_tabSize = size; - - // write in langs.xml - nppParam.insertTabInfo(lang->getLangName(), lang->getTabInfo()); - } - else - { - nppGUI._tabSize = size; - } - - ::SendMessage(::GetParent(_hParent), NPPM_INTERNAL_SETTING_TAB_SIZE, 0, 0); - return TRUE; - } - case IDC_CHECK_REPLACEBYSPACE: { bool isTabReplacedBySpace = BST_CHECKED == ::SendMessage(::GetDlgItem(_hSelf, IDC_CHECK_REPLACEBYSPACE), BM_GETCHECK, 0, 0); @@ -3189,8 +3247,8 @@ intptr_t CALLBACK LanguageSubDlg::run_dlgProc(UINT message, WPARAM wParam, LPARA case IDC_CHECK_DEFAULTTABVALUE: { - bool useDefaultTab = BST_CHECKED == ::SendMessage(::GetDlgItem(_hSelf, IDC_CHECK_DEFAULTTABVALUE), BM_GETCHECK, 0, 0); - auto index = ::SendDlgItemMessage(_hSelf, IDC_LIST_TABSETTNG, LB_GETCURSEL, 0, 0); + const bool useDefaultTab = isCheckedOrNot(IDC_CHECK_DEFAULTTABVALUE); + const auto index = ::SendDlgItemMessage(_hSelf, IDC_LIST_TABSETTNG, LB_GETCURSEL, 0, 0); if (index == LB_ERR || index == 0) // index == 0 shouldn't happen return FALSE; @@ -3203,22 +3261,31 @@ intptr_t CALLBACK LanguageSubDlg::run_dlgProc(UINT message, WPARAM wParam, LPARA lang->_isTabReplacedBySpace = useDefaultTab ? false : nppGUI._tabReplacedBySpace; //- set visual effect - ::EnableWindow(::GetDlgItem(_hSelf, IDC_TABSIZE_STATIC), !useDefaultTab); - ::SetDlgItemInt(_hSelf, IDC_TABSIZEVAL_STATIC, useDefaultTab ? nppGUI._tabSize : lang->_tabSize, FALSE); - ::EnableWindow(::GetDlgItem(_hSelf, IDC_TABSIZEVAL_STATIC), !useDefaultTab); - ::ShowWindow(::GetDlgItem(_hSelf, IDC_TABSIZEVAL_DISABLE_STATIC), useDefaultTab); - ::ShowWindow(::GetDlgItem(_hSelf, IDC_TABSIZEVAL_STATIC), !useDefaultTab); - ::SendMessage(::GetDlgItem(_hSelf, IDC_CHECK_REPLACEBYSPACE), BM_SETCHECK, useDefaultTab ? nppGUI._tabReplacedBySpace : lang->_isTabReplacedBySpace, 0); + ::SetDlgItemInt(_hSelf, IDC_EDIT_TABSIZEVAL, useDefaultTab ? nppGUI._tabSize : lang->_tabSize, FALSE); + setChecked(IDC_CHECK_REPLACEBYSPACE, useDefaultTab ? nppGUI._tabReplacedBySpace : lang->_isTabReplacedBySpace); ::EnableWindow(::GetDlgItem(_hSelf, IDC_CHECK_REPLACEBYSPACE), !useDefaultTab); + ::EnableWindow(::GetDlgItem(_hSelf, IDC_EDIT_TABSIZEVAL), !useDefaultTab); // write in langs.xml if (useDefaultTab) nppParam.insertTabInfo(lang->getLangName(), -1); + redrawDlgItem(IDC_TABSIZE_STATIC); + return TRUE; } + + default: + { + break; + } } } + + default: + { + break; + } } return FALSE; } diff --git a/PowerEditor/src/WinControls/Preference/preferenceDlg.h b/PowerEditor/src/WinControls/Preference/preferenceDlg.h index 25ec62bb7..f19c691b8 100644 --- a/PowerEditor/src/WinControls/Preference/preferenceDlg.h +++ b/PowerEditor/src/WinControls/Preference/preferenceDlg.h @@ -162,13 +162,9 @@ class LanguageSubDlg : public StaticDialog { public : LanguageSubDlg() = default; - virtual void destroy() { - _tabSizeVal.destroy(); - }; private : - LexerStylerArray _lsArray; - URLCtrl _tabSizeVal; + LexerStylerArray _lsArray; intptr_t CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam); std::vector _langList; }; diff --git a/PowerEditor/src/WinControls/Preference/preference_rc.h b/PowerEditor/src/WinControls/Preference/preference_rc.h index bde0e3a0d..67023ae26 100644 --- a/PowerEditor/src/WinControls/Preference/preference_rc.h +++ b/PowerEditor/src/WinControls/Preference/preference_rc.h @@ -210,7 +210,7 @@ #define IDC_MAXNBFILE_STATIC (IDD_PREFERENCE_SUB_MISC + 6) #define IDC_CHECK_MIN2SYSTRAY (IDD_PREFERENCE_SUB_MISC + 8) #define IDC_CHECK_REMEMBERSESSION (IDD_PREFERENCE_SUB_MISC + 9) - #define IDC_TABSIZEVAL_STATIC (IDD_PREFERENCE_SUB_MISC + 10) + //#define IDC_TABSIZEVAL_STATIC (IDD_PREFERENCE_SUB_MISC + 10) #define IDC_MAXNBFILEVAL_STATIC (IDD_PREFERENCE_SUB_MISC + 11) #define IDC_FILEAUTODETECTION_STATIC (IDD_PREFERENCE_SUB_MISC + 12) #define IDC_CHECK_UPDATESILENTLY (IDD_PREFERENCE_SUB_MISC + 13) @@ -306,7 +306,8 @@ #define IDC_LIST_TABSETTNG (IDD_PREFERENCE_SUB_LANGUAGE + 9) #define IDC_CHECK_DEFAULTTABVALUE (IDD_PREFERENCE_SUB_LANGUAGE + 10) #define IDC_GR_TABVALUE_STATIC (IDD_PREFERENCE_SUB_LANGUAGE + 11) - #define IDC_TABSIZEVAL_DISABLE_STATIC (IDD_PREFERENCE_SUB_LANGUAGE + 12) + //#define IDC_TABSIZEVAL_DISABLE_STATIC (IDD_PREFERENCE_SUB_LANGUAGE + 12) + #define IDC_EDIT_TABSIZEVAL (IDD_PREFERENCE_SUB_LANGUAGE + 13) #define IDD_PREFERENCE_SUB_HIGHLIGHTING 6550 //(IDD_PREFERENCE_BOX + 500) diff --git a/PowerEditor/src/WinControls/StaticDialog/StaticDialog.cpp b/PowerEditor/src/WinControls/StaticDialog/StaticDialog.cpp index 367776a0f..14eb6ac93 100644 --- a/PowerEditor/src/WinControls/StaticDialog/StaticDialog.cpp +++ b/PowerEditor/src/WinControls/StaticDialog/StaticDialog.cpp @@ -36,12 +36,24 @@ void StaticDialog::destroy() ::DestroyWindow(_hSelf); } +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); + ::InvalidateRect(_hSelf, &rcDlgItem, TRUE); + + if (forceUpdate) + ::UpdateWindow(hDlgItem); +} + POINT StaticDialog::getTopPoint(HWND hwnd, bool isLeft) const { - RECT rc; + RECT rc{}; ::GetWindowRect(hwnd, &rc); - POINT p; + POINT p{}; if (isLeft) p.x = rc.left; else @@ -54,9 +66,9 @@ POINT StaticDialog::getTopPoint(HWND hwnd, bool isLeft) const void StaticDialog::goToCenter() { - RECT rc; + RECT rc{}; ::GetClientRect(_hParent, &rc); - POINT center; + POINT center{}; center.x = rc.left + (rc.right - rc.left)/2; center.y = rc.top + (rc.bottom - rc.top)/2; ::ClientToScreen(_hParent, ¢er); @@ -73,7 +85,7 @@ void StaticDialog::display(bool toShow, bool enhancedPositioningCheckWhenShowing { if (enhancedPositioningCheckWhenShowing) { - RECT testPositionRc, candidateRc; + RECT testPositionRc{}, candidateRc{}; getWindowRect(testPositionRc); @@ -89,8 +101,8 @@ void StaticDialog::display(bool toShow, bool enhancedPositioningCheckWhenShowing { // If the user has switched from a dual monitor to a single monitor since we last // displayed the dialog, then ensure that it's still visible on the single monitor. - RECT workAreaRect = {}; - RECT rc = {}; + RECT workAreaRect{}; + RECT rc{}; ::SystemParametersInfo(SPI_GETWORKAREA, 0, &workAreaRect, 0); ::GetWindowRect(_hSelf, &rc); int newLeft = rc.left; @@ -119,7 +131,7 @@ RECT StaticDialog::getViewablePositionRect(RECT testPositionRc) const { HMONITOR hMon = ::MonitorFromRect(&testPositionRc, MONITOR_DEFAULTTONULL); - MONITORINFO mi; + MONITORINFO mi{}; mi.cbSize = sizeof(MONITORINFO); bool rectPosViewableWithoutChange = false; diff --git a/PowerEditor/src/WinControls/StaticDialog/StaticDialog.h b/PowerEditor/src/WinControls/StaticDialog/StaticDialog.h index a28f99297..bb938285c 100644 --- a/PowerEditor/src/WinControls/StaticDialog/StaticDialog.h +++ b/PowerEditor/src/WinControls/StaticDialog/StaticDialog.h @@ -47,6 +47,8 @@ public : return (_hSelf != NULL); } + void redrawDlgItem(const int nIDDlgItem, bool forceUpdate = false) const; + void goToCenter(); void display(bool toShow = true, bool enhancedPositioningCheckWhenShowing = false) const; @@ -65,10 +67,10 @@ public : ::SendDlgItemMessage(_hSelf, checkControlID, BM_SETCHECK, checkOrNot ? BST_CHECKED : BST_UNCHECKED, 0); } - virtual void destroy() override; + void destroy() override; protected: - RECT _rc = {}; + RECT _rc{}; static intptr_t CALLBACK dlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam); virtual intptr_t CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam) = 0;