diff --git a/PowerEditor/src/MISC/Common/Common.cpp b/PowerEditor/src/MISC/Common/Common.cpp index 97ccd119e..55725d97b 100644 --- a/PowerEditor/src/MISC/Common/Common.cpp +++ b/PowerEditor/src/MISC/Common/Common.cpp @@ -1497,3 +1497,22 @@ generic_string getDateTimeStrFrom(const generic_string& dateTimeFormat, const SY return {}; } + +// Don't forget to use DeleteObject(createdFont) before leaving the program +HFONT createFont(const TCHAR* fontName, int fontSize, bool isBold, HWND hDestParent) +{ + HDC hdc = GetDC(hDestParent); + + LOGFONT logFont = { 0 }; + logFont.lfHeight = -MulDiv(fontSize, GetDeviceCaps(hdc, LOGPIXELSY), 72); + if (isBold) + logFont.lfWeight = FW_BOLD; + + _tcscpy_s(logFont.lfFaceName, fontName); + + HFONT newFont = CreateFontIndirect(&logFont); + + ReleaseDC(hDestParent, hdc); + + return newFont; +} diff --git a/PowerEditor/src/MISC/Common/Common.h b/PowerEditor/src/MISC/Common/Common.h index c5898d74a..f22b94150 100644 --- a/PowerEditor/src/MISC/Common/Common.h +++ b/PowerEditor/src/MISC/Common/Common.h @@ -233,3 +233,5 @@ bool endsWith(const generic_string& s, const generic_string& suffix); int nbDigitsFromNbLines(size_t nbLines); generic_string getDateTimeStrFrom(const generic_string& dateTimeFormat, const SYSTEMTIME& st); + +HFONT createFont(const TCHAR* fontName, int fontSize, bool isBold, HWND hDestParent); diff --git a/PowerEditor/src/ScintillaComponent/Buffer.cpp b/PowerEditor/src/ScintillaComponent/Buffer.cpp index ba3f638a9..4e9723438 100644 --- a/PowerEditor/src/ScintillaComponent/Buffer.cpp +++ b/PowerEditor/src/ScintillaComponent/Buffer.cpp @@ -1476,7 +1476,7 @@ bool FileManager::loadFileData(Document doc, const TCHAR * filename, char* data, pNativeSpeaker->messageBox("FileTooBigToOpen", NULL, TEXT("File is too big to be opened by Notepad++"), - TEXT("File size problem"), + TEXT("Exception: File size problem"), MB_OK | MB_APPLMODAL); success = false; } diff --git a/PowerEditor/src/ScintillaComponent/FindReplaceDlg.cpp b/PowerEditor/src/ScintillaComponent/FindReplaceDlg.cpp index 36cb47fa5..20a491715 100644 --- a/PowerEditor/src/ScintillaComponent/FindReplaceDlg.cpp +++ b/PowerEditor/src/ScintillaComponent/FindReplaceDlg.cpp @@ -255,6 +255,9 @@ FindReplaceDlg::~FindReplaceDlg() if (_hMonospaceFont) ::DeleteObject(_hMonospaceFont); + if (_hLargerBolderFont) + ::DeleteObject(_hLargerBolderFont); + delete[] _uniFileName; } @@ -830,7 +833,7 @@ void FindReplaceDlg::resizeDialogElements(LONG newWidth) IDC_PERCENTAGE_SLIDER , IDC_REPLACEINSELECTION , IDC_IN_SELECTION_CHECK, IDD_FINDINFILES_BROWSE_BUTTON, IDCMARKALL, IDC_CLEAR_ALL, IDCCOUNTALL, IDC_FINDALL_OPENEDFILES, IDC_FINDALL_CURRENTFILE, - IDREPLACE, IDREPLACEALL,IDC_REPLACE_OPENEDFILES, IDD_FINDINFILES_FIND_BUTTON, IDD_FINDINFILES_REPLACEINFILES, IDOK, IDCANCEL, + IDREPLACE, IDREPLACEALL, IDD_FINDREPLACE_SWAP_BUTTON, IDC_REPLACE_OPENEDFILES, IDD_FINDINFILES_FIND_BUTTON, IDD_FINDINFILES_REPLACEINFILES, IDOK, IDCANCEL, IDC_FINDPREV, IDC_FINDNEXT, IDC_2_BUTTONS_MODE, IDC_COPY_MARKED_TEXT, IDD_FINDINFILES_REPLACEINPROJECTS }; @@ -986,18 +989,7 @@ INT_PTR CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM if ((NppParameters::getInstance()).getNppGUI()._monospacedFontFindDlg) { - const TCHAR* fontName = _T("Courier New"); - const long nFontSize = 8; - - HDC hdc = GetDC(_hSelf); - - LOGFONT logFont = { 0 }; - logFont.lfHeight = -MulDiv(nFontSize, GetDeviceCaps(hdc, LOGPIXELSY), 72); - _tcscpy_s(logFont.lfFaceName, fontName); - - _hMonospaceFont = CreateFontIndirect(&logFont); - - ReleaseDC(_hSelf, hdc); + _hMonospaceFont = createFont(TEXT("Courier New"), 8, false, _hSelf); SendMessage(hFindCombo, WM_SETFONT, (WPARAM)_hMonospaceFont, MAKELPARAM(true, 0)); SendMessage(hReplaceCombo, WM_SETFONT, (WPARAM)_hMonospaceFont, MAKELPARAM(true, 0)); @@ -1071,6 +1063,12 @@ INT_PTR CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM ::SetWindowTextW(::GetDlgItem(_hSelf, IDC_FINDPREV), TEXT("▲")); ::SetWindowTextW(::GetDlgItem(_hSelf, IDC_FINDNEXT), TEXT("▼ Find Next")); + ::SetWindowTextW(::GetDlgItem(_hSelf, IDD_FINDREPLACE_SWAP_BUTTON), TEXT("⇅")); + + // "⇅" enlargement + _hLargerBolderFont = createFont(TEXT("Courier New"), 14, true, _hSelf); + + SendMessage(::GetDlgItem(_hSelf, IDD_FINDREPLACE_SWAP_BUTTON), WM_SETFONT, (WPARAM)_hLargerBolderFont, MAKELPARAM(true, 0)); return TRUE; } @@ -1274,6 +1272,20 @@ INT_PTR CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM } return TRUE; + case IDD_FINDREPLACE_SWAP_BUTTON: + { + HWND hFindWhat = ::GetDlgItem(_hSelf, IDFINDWHAT); + generic_string findWhatText = getTextFromCombo(hFindWhat); + HWND hPlaceWith = ::GetDlgItem(_hSelf, IDREPLACEWITH); + generic_string replaceWithText = getTextFromCombo(hPlaceWith); + if ((!findWhatText.empty() || !replaceWithText.empty()) && (findWhatText != replaceWithText)) + { + ::SendMessage(hFindWhat, WM_SETTEXT, 0, reinterpret_cast(replaceWithText.c_str())); + ::SendMessage(hPlaceWith, WM_SETTEXT, 0, reinterpret_cast(findWhatText.c_str())); + } + } + return TRUE; + case IDM_SEARCH_FIND: enableReplaceFunc(false); // enable relace false so only find return TRUE; @@ -2906,6 +2918,7 @@ void FindReplaceDlg::enableReplaceFunc(bool isEnable) showFindDlgItem(ID_STATICTEXT_REPLACE, isEnable); showFindDlgItem(IDREPLACE, isEnable); showFindDlgItem(IDREPLACEWITH, isEnable); + showFindDlgItem(IDD_FINDREPLACE_SWAP_BUTTON, isEnable); showFindDlgItem(IDREPLACEALL, isEnable); showFindDlgItem(IDC_REPLACE_OPENEDFILES, isEnable); showFindDlgItem(IDC_REPLACEINSELECTION); @@ -2987,6 +3000,7 @@ void FindReplaceDlg::enableFindInFilesControls(bool isEnable, bool projectPanels { showFindDlgItem(ID_STATICTEXT_REPLACE); showFindDlgItem(IDREPLACEWITH); + showFindDlgItem(IDD_FINDREPLACE_SWAP_BUTTON); } showFindDlgItem(IDD_FINDINFILES_REPLACEINFILES, isEnable && (!projectPanels)); showFindDlgItem(IDD_FINDINFILES_REPLACEINPROJECTS, isEnable && projectPanels); @@ -3678,6 +3692,7 @@ void FindReplaceDlg::enableMarkFunc() showFindDlgItem(ID_STATICTEXT_REPLACE, false); showFindDlgItem(IDREPLACE, false); showFindDlgItem(IDREPLACEWITH, false); + showFindDlgItem(IDD_FINDREPLACE_SWAP_BUTTON, false); showFindDlgItem(IDREPLACEALL, false); showFindDlgItem(IDC_REPLACE_OPENEDFILES, false); showFindDlgItem(IDC_REPLACEINSELECTION, false); diff --git a/PowerEditor/src/ScintillaComponent/FindReplaceDlg.h b/PowerEditor/src/ScintillaComponent/FindReplaceDlg.h index 327dc48dd..04439682e 100644 --- a/PowerEditor/src/ScintillaComponent/FindReplaceDlg.h +++ b/PowerEditor/src/ScintillaComponent/FindReplaceDlg.h @@ -400,6 +400,7 @@ private : int _statusbarTooltipIconSize = 0; HFONT _hMonospaceFont = nullptr; + HFONT _hLargerBolderFont = nullptr; std::map _controlEnableMap; diff --git a/PowerEditor/src/ScintillaComponent/FindReplaceDlg.rc b/PowerEditor/src/ScintillaComponent/FindReplaceDlg.rc index 3fa357c2c..9cff135a5 100644 --- a/PowerEditor/src/ScintillaComponent/FindReplaceDlg.rc +++ b/PowerEditor/src/ScintillaComponent/FindReplaceDlg.rc @@ -24,15 +24,16 @@ EXSTYLE WS_EX_DLGMODALFRAME | WS_EX_WINDOWEDGE CAPTION "Replace" FONT 8, "MS Shell Dlg", 0, 0, 0x0 BEGIN - RTEXT "&Find what :",IDFINDWHAT_STATIC,6,22,75,8 - COMBOBOX IDFINDWHAT,83,20,178,150,CBS_DROPDOWN | CBS_AUTOHSCROLL | WS_TABSTOP - RTEXT "Rep&lace with :",ID_STATICTEXT_REPLACE,6,40,75,8 - COMBOBOX IDREPLACEWITH,83,38,178,50,CBS_DROPDOWN | CBS_AUTOHSCROLL | WS_TABSTOP - RTEXT "Filter&s :",IDD_FINDINFILES_FILTERS_STATIC,27,58,53,8, SS_NOTIFY - COMBOBOX IDD_FINDINFILES_FILTERS_COMBO,83,56,178,150,CBS_DROPDOWN | CBS_AUTOHSCROLL | WS_TABSTOP - RTEXT "Dir&ectory :",IDD_FINDINFILES_DIR_STATIC,7,76,40,8 + RTEXT "&Find what :",IDFINDWHAT_STATIC,0,21,75,8 + COMBOBOX IDFINDWHAT,76,20,170,150,CBS_DROPDOWN | CBS_AUTOHSCROLL | WS_TABSTOP + RTEXT "Rep&lace with :",ID_STATICTEXT_REPLACE,0,39,75,8 + COMBOBOX IDREPLACEWITH,76,38,170,50,CBS_DROPDOWN | CBS_AUTOHSCROLL | WS_TABSTOP + PUSHBUTTON "",IDD_FINDREPLACE_SWAP_BUTTON,249,26,13,17 + RTEXT "Filter&s :",IDD_FINDINFILES_FILTERS_STATIC,0,57,75,8, SS_NOTIFY + COMBOBOX IDD_FINDINFILES_FILTERS_COMBO,76,56,170,150,CBS_DROPDOWN | CBS_AUTOHSCROLL | WS_TABSTOP + RTEXT "Dir&ectory :",IDD_FINDINFILES_DIR_STATIC,7,75,40,8 COMBOBOX IDD_FINDINFILES_DIR_COMBO,49,74,190,150,CBS_DROPDOWN | CBS_AUTOHSCROLL | WS_TABSTOP - PUSHBUTTON "...",IDD_FINDINFILES_BROWSE_BUTTON,245,74,15,13 + PUSHBUTTON "...",IDD_FINDINFILES_BROWSE_BUTTON,245,72,15,13 CONTROL "Follow current doc.",IDD_FINDINFILES_FOLDERFOLLOWSDOC_CHECK, "Button",BS_AUTOCHECKBOX | WS_TABSTOP,270,73,94,15 CONTROL "In all su&b-folders",IDD_FINDINFILES_RECURSIVE_CHECK, diff --git a/PowerEditor/src/ScintillaComponent/FindReplaceDlg_rc.h b/PowerEditor/src/ScintillaComponent/FindReplaceDlg_rc.h index 128e34f9a..76a719ddb 100644 --- a/PowerEditor/src/ScintillaComponent/FindReplaceDlg_rc.h +++ b/PowerEditor/src/ScintillaComponent/FindReplaceDlg_rc.h @@ -33,6 +33,7 @@ #define IDUNSLASH 1607 #define IDREPLACE 1608 #define IDREPLACEALL 1609 +#define IDD_FINDREPLACE_SWAP_BUTTON 1610 #define ID_STATICTEXT_REPLACE 1611 //#define IDDIRECTIONUP 1612 //#define IDDIRECTIONDOWN 1613 @@ -69,8 +70,8 @@ //#define IDC_FINDINFILES 1637 #define IDC_FINDINFILES_LAUNCH 1638 #define IDC_GETCURRENTDOCTYPE 1639 +//#define IDSWITCH 1640 #define IDC_FINDALL_CURRENTFILE 1641 -//#define IDSWITCH 1640 #define IDD_FINDINFILES_DLG 1650 #define IDD_FINDINFILES_BROWSE_BUTTON 1651