From dde38183d3407f0b39ee67260da255bde51b324c Mon Sep 17 00:00:00 2001 From: Don HO Date: Thu, 17 Oct 2019 14:16:10 +0200 Subject: [PATCH] Make monospaced font in Find dialog optional Default value is disabled (old behaviour). --- PowerEditor/src/Parameters.cpp | 5 +++ PowerEditor/src/Parameters.h | 2 +- .../src/ScitillaComponent/FindReplaceDlg.cpp | 35 ++++++++++--------- .../src/WinControls/Preference/preference.rc | 1 + .../WinControls/Preference/preferenceDlg.cpp | 7 ++++ .../WinControls/Preference/preference_rc.h | 1 + 6 files changed, 34 insertions(+), 17 deletions(-) diff --git a/PowerEditor/src/Parameters.cpp b/PowerEditor/src/Parameters.cpp index df4c43e1..20f64930 100644 --- a/PowerEditor/src/Parameters.cpp +++ b/PowerEditor/src/Parameters.cpp @@ -5076,6 +5076,10 @@ void NppParameters::feedGUIParameters(TiXmlNode *node) if (optNameBackSlashEscape && !lstrcmp(optNameBackSlashEscape, TEXT("no"))) _nppGUI._backSlashIsEscapeCharacterForSql = false; + const TCHAR * optNameMonoFont = element->Attribute(TEXT("monospacedFontFinfDlg")); + if (optNameMonoFont && !lstrcmp(optNameMonoFont, TEXT("no"))) + _nppGUI._monospacedFontFinfDlg = false; + const TCHAR * optNameNewStyleSaveDlg = element->Attribute(TEXT("newStyleSaveDlg")); if (optNameNewStyleSaveDlg) _nppGUI._useNewStyleSaveDlg = (lstrcmp(optNameNewStyleSaveDlg, TEXT("yes")) == 0); @@ -5832,6 +5836,7 @@ void NppParameters::createXmlTreeFromGUIParams() GUIConfigElement->SetAttribute(TEXT("fileSwitcherWithoutExtColumn"), _nppGUI._fileSwitcherWithoutExtColumn ? TEXT("yes") : TEXT("no")); GUIConfigElement->SetAttribute(TEXT("backSlashIsEscapeCharacterForSql"), _nppGUI._backSlashIsEscapeCharacterForSql ? TEXT("yes") : TEXT("no")); + GUIConfigElement->SetAttribute(TEXT("monospacedFontFinfDlg"), _nppGUI._monospacedFontFinfDlg ? TEXT("yes") : TEXT("no")); GUIConfigElement->SetAttribute(TEXT("newStyleSaveDlg"), _nppGUI._useNewStyleSaveDlg ? TEXT("yes") : TEXT("no")); GUIConfigElement->SetAttribute(TEXT("isFolderDroppedOpenFiles"), _nppGUI._isFolderDroppedOpenFiles ? TEXT("yes") : TEXT("no")); GUIConfigElement->SetAttribute(TEXT("docPeekOnTab"), _nppGUI._isDocPeekOnTab ? TEXT("yes") : TEXT("no")); diff --git a/PowerEditor/src/Parameters.h b/PowerEditor/src/Parameters.h index 7f658605..924ec982 100644 --- a/PowerEditor/src/Parameters.h +++ b/PowerEditor/src/Parameters.h @@ -824,7 +824,7 @@ struct NppGUI final char _rightmostDelimiter = ')'; bool _delimiterSelectionOnEntireDocument = false; bool _backSlashIsEscapeCharacterForSql = true; - + bool _monospacedFontFinfDlg = false; bool _isWordCharDefault = true; std::string _customWordChars; diff --git a/PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp b/PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp index 9816fcd8..efcca2e6 100644 --- a/PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp +++ b/PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp @@ -794,28 +794,31 @@ INT_PTR CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM case WM_INITDIALOG : { - HWND hFindCombo = ::GetDlgItem(_hSelf, IDFINDWHAT); - HWND hReplaceCombo = ::GetDlgItem(_hSelf, IDREPLACEWITH); - HWND hFiltersCombo = ::GetDlgItem(_hSelf, IDD_FINDINFILES_FILTERS_COMBO); - HWND hDirCombo = ::GetDlgItem(_hSelf, IDD_FINDINFILES_DIR_COMBO); + if ((NppParameters::getInstance()).getNppGUI()._monospacedFontFinfDlg) + { + HWND hFindCombo = ::GetDlgItem(_hSelf, IDFINDWHAT); + HWND hReplaceCombo = ::GetDlgItem(_hSelf, IDREPLACEWITH); + HWND hFiltersCombo = ::GetDlgItem(_hSelf, IDD_FINDINFILES_FILTERS_COMBO); + HWND hDirCombo = ::GetDlgItem(_hSelf, IDD_FINDINFILES_DIR_COMBO); - const TCHAR* fontName = _T("Courier New"); - const long nFontSize = 8; + const TCHAR* fontName = _T("Courier New"); + const long nFontSize = 8; - HDC hdc = GetDC(_hSelf); + HDC hdc = GetDC(_hSelf); - LOGFONT logFont = { 0 }; - logFont.lfHeight = -MulDiv(nFontSize, GetDeviceCaps(hdc, LOGPIXELSY), 72); - _tcscpy_s(logFont.lfFaceName, fontName); + LOGFONT logFont = { 0 }; + logFont.lfHeight = -MulDiv(nFontSize, GetDeviceCaps(hdc, LOGPIXELSY), 72); + _tcscpy_s(logFont.lfFaceName, fontName); - _hMonospaceFont = CreateFontIndirect(&logFont); + _hMonospaceFont = CreateFontIndirect(&logFont); - ReleaseDC(_hSelf, hdc); + ReleaseDC(_hSelf, hdc); - SendMessage(hFindCombo, WM_SETFONT, (WPARAM)_hMonospaceFont, MAKELPARAM(true, 0)); - SendMessage(hReplaceCombo, WM_SETFONT, (WPARAM)_hMonospaceFont, MAKELPARAM(true, 0)); - SendMessage(hFiltersCombo, WM_SETFONT, (WPARAM)_hMonospaceFont, MAKELPARAM(true, 0)); - SendMessage(hDirCombo, WM_SETFONT, (WPARAM)_hMonospaceFont, MAKELPARAM(true, 0)); + SendMessage(hFindCombo, WM_SETFONT, (WPARAM)_hMonospaceFont, MAKELPARAM(true, 0)); + SendMessage(hReplaceCombo, WM_SETFONT, (WPARAM)_hMonospaceFont, MAKELPARAM(true, 0)); + SendMessage(hFiltersCombo, WM_SETFONT, (WPARAM)_hMonospaceFont, MAKELPARAM(true, 0)); + SendMessage(hDirCombo, WM_SETFONT, (WPARAM)_hMonospaceFont, MAKELPARAM(true, 0)); + } RECT arc; ::GetWindowRect(::GetDlgItem(_hSelf, IDCANCEL), &arc); diff --git a/PowerEditor/src/WinControls/Preference/preference.rc b/PowerEditor/src/WinControls/Preference/preference.rc index aafaa743..80e68706 100644 --- a/PowerEditor/src/WinControls/Preference/preference.rc +++ b/PowerEditor/src/WinControls/Preference/preference.rc @@ -126,6 +126,7 @@ BEGIN CONTROL "Auto-indent",IDC_CHECK_MAINTAININDENT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,37,113,217,10 CONTROL "Minimize to system tray",IDC_CHECK_MIN2SYSTRAY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,37,128,217,10 CONTROL "Show only filename in title bar",IDC_CHECK_SHORTTITLE, "Button",BS_AUTOCHECKBOX | BS_MULTILINE | WS_TABSTOP,37,143,217,10 + CONTROL "Use Monospaced font in Find dialog (Need to restart Notepad++)",IDC_CHECK_MONOSPACEDFONT_FINDDLG, "Button",BS_AUTOCHECKBOX | WS_TABSTOP,37,158,217,10 CONTROL "Enable Notepad++ auto-updater",IDC_CHECK_AUTOUPDATE, "Button",BS_AUTOCHECKBOX | BS_MULTILINE | WS_TABSTOP,37,173,217,10 CONTROL "Enable",IDC_CHECK_CLICKABLELINK_ENABLE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,267,15,140,10 CONTROL "No underline",IDC_CHECK_CLICKABLELINK_NOUNDERLINE, "Button",BS_AUTOCHECKBOX | WS_TABSTOP,267,28,140,10 diff --git a/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp b/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp index 0ced5907..3501253b 100644 --- a/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp +++ b/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp @@ -913,6 +913,7 @@ INT_PTR CALLBACK SettingsDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM) ::SendDlgItemMessage(_hSelf, IDC_CHECK_MIN2SYSTRAY, BM_SETCHECK, nppGUI._isMinimizedToTray, 0); ::SendDlgItemMessage(_hSelf, IDC_CHECK_DETECTENCODING, BM_SETCHECK, nppGUI._detectEncoding, 0); ::SendDlgItemMessage(_hSelf, IDC_CHECK_AUTOUPDATE, BM_SETCHECK, nppGUI._autoUpdateOpt._doAutoUpdate, 0); + ::SendDlgItemMessage(_hSelf, IDC_CHECK_MONOSPACEDFONT_FINDDLG, BM_SETCHECK, nppGUI._monospacedFontFinfDlg, 0); ::SendDlgItemMessage(_hSelf, IDC_CHECK_ENABLEDOCPEEKER, BM_SETCHECK, nppGUI._isDocPeekOnTab ? BST_CHECKED : BST_UNCHECKED, 0); ::SendDlgItemMessage(_hSelf, IDC_CHECK_ENABLEDOCPEEKONMAP, BM_SETCHECK, nppGUI._isDocPeekOnMap ? BST_CHECKED : BST_UNCHECKED, 0); @@ -1071,6 +1072,12 @@ INT_PTR CALLBACK SettingsDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM) return TRUE; } + case IDC_CHECK_MONOSPACEDFONT_FINDDLG: + { + nppGUI._monospacedFontFinfDlg = isCheckedOrNot(IDC_CHECK_MONOSPACEDFONT_FINDDLG); + return TRUE; + } + case IDC_CHECK_ENABLEDOCPEEKER: { nppGUI._isDocPeekOnTab = isCheckedOrNot(IDC_CHECK_ENABLEDOCPEEKER); diff --git a/PowerEditor/src/WinControls/Preference/preference_rc.h b/PowerEditor/src/WinControls/Preference/preference_rc.h index 8dcbbe55..51ad7dce 100644 --- a/PowerEditor/src/WinControls/Preference/preference_rc.h +++ b/PowerEditor/src/WinControls/Preference/preference_rc.h @@ -168,6 +168,7 @@ #define IDC_MAXNBFILEVAL_STATIC (IDD_PREFERENCE_SETTING_BOX + 11) #define IDC_FILEAUTODETECTION_STATIC (IDD_PREFERENCE_SETTING_BOX + 12) #define IDC_CHECK_UPDATESILENTLY (IDD_PREFERENCE_SETTING_BOX + 13) + #define IDC_CHECK_MONOSPACEDFONT_FINDDLG (IDD_PREFERENCE_SETTING_BOX + 14) #define IDC_RADIO_BKNONE (IDD_PREFERENCE_SETTING_BOX + 15) #define IDC_RADIO_BKSIMPLE (IDD_PREFERENCE_SETTING_BOX + 16) #define IDC_RADIO_BKVERBOSE (IDD_PREFERENCE_SETTING_BOX + 17)