diff --git a/PowerEditor/src/WinControls/DockingWnd/DockingCont.cpp b/PowerEditor/src/WinControls/DockingWnd/DockingCont.cpp index 7666e9782..87e98d408 100644 --- a/PowerEditor/src/WinControls/DockingWnd/DockingCont.cpp +++ b/PowerEditor/src/WinControls/DockingWnd/DockingCont.cpp @@ -87,7 +87,17 @@ DockingCont::DockingCont() DockingCont::~DockingCont() { - ::DeleteObject(_hFont); + if (_hFont != nullptr) + { + ::DeleteObject(_hFont); + _hFont = nullptr; + } + + if (_hFontCaption != nullptr) + { + ::DeleteObject(_hFontCaption); + _hFontCaption = nullptr; + } } @@ -114,7 +124,11 @@ void DockingCont::doDialog(bool willBeShown, bool isFloating) } //If you want defualt GUI font - _hFont = (HFONT)GetStockObject(DEFAULT_GUI_FONT); + LOGFONT lfTab{ NppParameters::getDefaultGUIFont() }; + _hFont = ::CreateFontIndirect(&lfTab); + + LOGFONT lfCaption{ NppParameters::getDefaultGUIFont(NppParameters::DefaultFontType::smcaption) }; + _hFontCaption = ::CreateFontIndirect(&lfCaption); } display(willBeShown); @@ -520,7 +534,7 @@ void DockingCont::drawCaptionItem(DRAWITEMSTRUCT *pDrawItemStruct) rc.left += 2; rc.top += 1; rc.right -= 16; - hOldFont = (HFONT)::SelectObject(hDc, _hFont); + hOldFont = static_cast(::SelectObject(hDc, _hFontCaption)); ::DrawText(hDc, _pszCaption.c_str(), length, &rc, DT_LEFT | DT_SINGLELINE | DT_VCENTER | DT_END_ELLIPSIS | DT_NOPREFIX); // calculate text size and if its trankated... @@ -564,12 +578,18 @@ void DockingCont::drawCaptionItem(DRAWITEMSTRUCT *pDrawItemStruct) rc.right = rc.bottom - rc.top; rc.bottom += 14; - hFont = ::CreateFont(12, 0, 90 * 10, 0, - FW_NORMAL, FALSE, FALSE, FALSE, - ANSI_CHARSET, OUT_DEFAULT_PRECIS, - CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, - DEFAULT_PITCH | FF_ROMAN, - TEXT("MS Shell Dlg")); + LOGFONT lf{ NppParameters::getDefaultGUIFont(NppParameters::DefaultFontType::smcaption) }; + lf.lfEscapement = 900; + hFont = ::CreateFontIndirect(&lf); + if (hFont == nullptr) + { + hFont = ::CreateFont(12, 0, 90 * 10, 0, + FW_NORMAL, FALSE, FALSE, FALSE, + ANSI_CHARSET, OUT_DEFAULT_PRECIS, + CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, + DEFAULT_PITCH | FF_ROMAN, + TEXT("MS Shell Dlg")); + } hOldFont = (HFONT)::SelectObject(hDc, hFont); ::DrawText(hDc, _pszCaption.c_str(), length, &rc, DT_BOTTOM | DT_SINGLELINE | DT_END_ELLIPSIS | DT_NOPREFIX); @@ -590,7 +610,12 @@ void DockingCont::drawCaptionItem(DRAWITEMSTRUCT *pDrawItemStruct) if (NppDarkMode::isEnabled()) { - ::SelectObject(hDc, NppParameters::getInstance().getDefaultUIFont()); + if (_hFont == nullptr) + { + LOGFONT lf{ NppParameters::getDefaultGUIFont() }; + _hFont = ::CreateFontIndirect(&lf); + } + auto hOld = static_cast(::SelectObject(hDc, _hFont)); rc = pDrawItemStruct->rcItem; if (_isTopCaption == TRUE) @@ -607,7 +632,8 @@ void DockingCont::drawCaptionItem(DRAWITEMSTRUCT *pDrawItemStruct) ::SetTextColor(hDc, RGB(0xFF, 0xFF, 0xFF)); } - ::DrawText(hDc, L"x", 1, &rc, DT_VCENTER | DT_CENTER | DT_SINGLELINE); + ::DrawText(hDc, L"✕", 1, &rc, DT_VCENTER | DT_CENTER | DT_SINGLELINE); + ::SelectObject(hDc, hOld); } else { @@ -1632,7 +1658,7 @@ void DockingCont::selectTab(int iTab) if (iItem == iTab && pszMaxTxt) { // fake here an icon before text ... - szText = TEXT(" "); + szText = TEXT(" "); szText += pszMaxTxt; } tcItem.pszText = (TCHAR *)szText.c_str(); diff --git a/PowerEditor/src/WinControls/DockingWnd/DockingCont.h b/PowerEditor/src/WinControls/DockingWnd/DockingCont.h index bfc914630..abbe6c08d 100644 --- a/PowerEditor/src/WinControls/DockingWnd/DockingCont.h +++ b/PowerEditor/src/WinControls/DockingWnd/DockingCont.h @@ -180,6 +180,7 @@ private: // horizontal font for caption and tab HFONT _hFont = nullptr; + HFONT _hFontCaption = nullptr; // caption params BOOL _isTopCaption = FALSE; @@ -188,7 +189,7 @@ private: BOOL _isMouseDown = FALSE; BOOL _isMouseClose = FALSE; BOOL _isMouseOver = FALSE; - RECT _rcCaption = {}; + RECT _rcCaption{}; // tab style BOOL _bDrawOgLine = FALSE; diff --git a/PowerEditor/src/WinControls/FunctionList/functionListPanel.cpp b/PowerEditor/src/WinControls/FunctionList/functionListPanel.cpp index d5309a83c..7c23e0abc 100644 --- a/PowerEditor/src/WinControls/FunctionList/functionListPanel.cpp +++ b/PowerEditor/src/WinControls/FunctionList/functionListPanel.cpp @@ -35,6 +35,12 @@ FunctionListPanel::~FunctionListPanel() { delete s; } + + if (_hFontSearchEdit != nullptr) + { + ::DeleteObject(_hFontSearchEdit); + _hFontSearchEdit = nullptr; + } } void FunctionListPanel::addEntry(const TCHAR *nodeName, const TCHAR *displayText, size_t pos) @@ -155,7 +161,7 @@ generic_string FunctionListPanel::parseSubLevel(size_t begin, size_t end, std::v } else // only one processed element, so we conclude the result { - TCHAR foundStr[1024]; + TCHAR foundStr[1024]{}; (*_ppEditView)->getGenericText(foundStr, 1024, targetStart, targetEnd); @@ -890,9 +896,16 @@ intptr_t CALLBACK FunctionListPanel::run_dlgProc(UINT message, WPARAM wParam, LP oldFunclstSearchEditProc = reinterpret_cast(::SetWindowLongPtr(_hSearchEdit, GWLP_WNDPROC, reinterpret_cast(funclstSearchEditProc))); - HFONT hf = (HFONT)::GetStockObject(DEFAULT_GUI_FONT); - if (hf) - ::SendMessage(_hSearchEdit, WM_SETFONT, reinterpret_cast(hf), MAKELPARAM(TRUE, 0)); + if (_hFontSearchEdit == nullptr) + { + LOGFONT lf{ NppParameters::getDefaultGUIFont() }; + _hFontSearchEdit = ::CreateFontIndirect(&lf); + } + + if (_hFontSearchEdit != nullptr) + { + ::SendMessage(_hSearchEdit, WM_SETFONT, reinterpret_cast(_hFontSearchEdit), MAKELPARAM(TRUE, 0)); + } _treeView.init(_hInst, _hSelf, IDC_LIST_FUNCLIST); _treeView.setImageList(CX_BITMAP, CY_BITMAP, 3, IDI_FUNCLIST_ROOT, IDI_FUNCLIST_NODE, IDI_FUNCLIST_LEAF); diff --git a/PowerEditor/src/WinControls/FunctionList/functionListPanel.h b/PowerEditor/src/WinControls/FunctionList/functionListPanel.h index 35b8f2096..775526864 100644 --- a/PowerEditor/src/WinControls/FunctionList/functionListPanel.h +++ b/PowerEditor/src/WinControls/FunctionList/functionListPanel.h @@ -75,18 +75,19 @@ public: void init(HINSTANCE hInst, HWND hPere, ScintillaEditView **ppEditView); - virtual void display(bool toShow = true) const { - DockingDlgInterface::display(toShow); - }; + void display(bool toShow = true) const override { + DockingDlgInterface::display(toShow); + }; - virtual void setBackgroundColor(COLORREF bgColour) { + void setBackgroundColor(COLORREF bgColour) override { TreeView_SetBkColor(_treeView.getHSelf(), bgColour); TreeView_SetBkColor(_treeViewSearchResult.getHSelf(), bgColour); - }; - virtual void setForegroundColor(COLORREF fgColour) { + }; + + void setForegroundColor(COLORREF fgColour) override { TreeView_SetTextColor(_treeView.getHSelf(), fgColour); TreeView_SetTextColor(_treeViewSearchResult.getHSelf(), fgColour); - }; + }; void setParent(HWND parent2set){ _hParent = parent2set; @@ -103,18 +104,19 @@ public: void searchFuncAndSwitchView(); 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; HMENU _hPreferencesMenu = NULL; private: HWND _hToolbarMenu = nullptr; HWND _hSearchEdit = nullptr; + HFONT _hFontSearchEdit = nullptr; TreeView *_pTreeView = nullptr; TreeView _treeView; TreeView _treeViewSearchResult; - SCROLLINFO si = {}; + SCROLLINFO si{}; long _findLine = -1; long _findEndLine = -1; HTREEITEM _findItem = nullptr; @@ -144,4 +146,3 @@ private: void initPreferencesMenu(); void showPreferencesMenu(); }; -