mirror of
https://github.com/notepad-plus-plus/notepad-plus-plus.git
synced 2025-07-25 23:05:13 +02:00
GUI Enhancement: Docking Container & Function List
- prefer SystemParametersInfo fonts over DEFAULT_GUI_FONT - fix override warnings - add initializer Fix #13703, close #13704
This commit is contained in:
parent
e7f321f21a
commit
e2f1662c90
@ -87,7 +87,17 @@ DockingCont::DockingCont()
|
|||||||
|
|
||||||
DockingCont::~DockingCont()
|
DockingCont::~DockingCont()
|
||||||
{
|
{
|
||||||
|
if (_hFont != nullptr)
|
||||||
|
{
|
||||||
::DeleteObject(_hFont);
|
::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
|
//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);
|
display(willBeShown);
|
||||||
@ -520,7 +534,7 @@ void DockingCont::drawCaptionItem(DRAWITEMSTRUCT *pDrawItemStruct)
|
|||||||
rc.left += 2;
|
rc.left += 2;
|
||||||
rc.top += 1;
|
rc.top += 1;
|
||||||
rc.right -= 16;
|
rc.right -= 16;
|
||||||
hOldFont = (HFONT)::SelectObject(hDc, _hFont);
|
hOldFont = static_cast<HFONT>(::SelectObject(hDc, _hFontCaption));
|
||||||
::DrawText(hDc, _pszCaption.c_str(), length, &rc, DT_LEFT | DT_SINGLELINE | DT_VCENTER | DT_END_ELLIPSIS | DT_NOPREFIX);
|
::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...
|
// calculate text size and if its trankated...
|
||||||
@ -564,12 +578,18 @@ void DockingCont::drawCaptionItem(DRAWITEMSTRUCT *pDrawItemStruct)
|
|||||||
rc.right = rc.bottom - rc.top;
|
rc.right = rc.bottom - rc.top;
|
||||||
rc.bottom += 14;
|
rc.bottom += 14;
|
||||||
|
|
||||||
|
LOGFONT lf{ NppParameters::getDefaultGUIFont(NppParameters::DefaultFontType::smcaption) };
|
||||||
|
lf.lfEscapement = 900;
|
||||||
|
hFont = ::CreateFontIndirect(&lf);
|
||||||
|
if (hFont == nullptr)
|
||||||
|
{
|
||||||
hFont = ::CreateFont(12, 0, 90 * 10, 0,
|
hFont = ::CreateFont(12, 0, 90 * 10, 0,
|
||||||
FW_NORMAL, FALSE, FALSE, FALSE,
|
FW_NORMAL, FALSE, FALSE, FALSE,
|
||||||
ANSI_CHARSET, OUT_DEFAULT_PRECIS,
|
ANSI_CHARSET, OUT_DEFAULT_PRECIS,
|
||||||
CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,
|
CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,
|
||||||
DEFAULT_PITCH | FF_ROMAN,
|
DEFAULT_PITCH | FF_ROMAN,
|
||||||
TEXT("MS Shell Dlg"));
|
TEXT("MS Shell Dlg"));
|
||||||
|
}
|
||||||
|
|
||||||
hOldFont = (HFONT)::SelectObject(hDc, hFont);
|
hOldFont = (HFONT)::SelectObject(hDc, hFont);
|
||||||
::DrawText(hDc, _pszCaption.c_str(), length, &rc, DT_BOTTOM | DT_SINGLELINE | DT_END_ELLIPSIS | DT_NOPREFIX);
|
::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())
|
if (NppDarkMode::isEnabled())
|
||||||
{
|
{
|
||||||
::SelectObject(hDc, NppParameters::getInstance().getDefaultUIFont());
|
if (_hFont == nullptr)
|
||||||
|
{
|
||||||
|
LOGFONT lf{ NppParameters::getDefaultGUIFont() };
|
||||||
|
_hFont = ::CreateFontIndirect(&lf);
|
||||||
|
}
|
||||||
|
auto hOld = static_cast<HFONT>(::SelectObject(hDc, _hFont));
|
||||||
|
|
||||||
rc = pDrawItemStruct->rcItem;
|
rc = pDrawItemStruct->rcItem;
|
||||||
if (_isTopCaption == TRUE)
|
if (_isTopCaption == TRUE)
|
||||||
@ -607,7 +632,8 @@ void DockingCont::drawCaptionItem(DRAWITEMSTRUCT *pDrawItemStruct)
|
|||||||
::SetTextColor(hDc, RGB(0xFF, 0xFF, 0xFF));
|
::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
|
else
|
||||||
{
|
{
|
||||||
|
@ -180,6 +180,7 @@ private:
|
|||||||
|
|
||||||
// horizontal font for caption and tab
|
// horizontal font for caption and tab
|
||||||
HFONT _hFont = nullptr;
|
HFONT _hFont = nullptr;
|
||||||
|
HFONT _hFontCaption = nullptr;
|
||||||
|
|
||||||
// caption params
|
// caption params
|
||||||
BOOL _isTopCaption = FALSE;
|
BOOL _isTopCaption = FALSE;
|
||||||
@ -188,7 +189,7 @@ private:
|
|||||||
BOOL _isMouseDown = FALSE;
|
BOOL _isMouseDown = FALSE;
|
||||||
BOOL _isMouseClose = FALSE;
|
BOOL _isMouseClose = FALSE;
|
||||||
BOOL _isMouseOver = FALSE;
|
BOOL _isMouseOver = FALSE;
|
||||||
RECT _rcCaption = {};
|
RECT _rcCaption{};
|
||||||
|
|
||||||
// tab style
|
// tab style
|
||||||
BOOL _bDrawOgLine = FALSE;
|
BOOL _bDrawOgLine = FALSE;
|
||||||
|
@ -35,6 +35,12 @@ FunctionListPanel::~FunctionListPanel()
|
|||||||
{
|
{
|
||||||
delete s;
|
delete s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (_hFontSearchEdit != nullptr)
|
||||||
|
{
|
||||||
|
::DeleteObject(_hFontSearchEdit);
|
||||||
|
_hFontSearchEdit = nullptr;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FunctionListPanel::addEntry(const TCHAR *nodeName, const TCHAR *displayText, size_t pos)
|
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
|
else // only one processed element, so we conclude the result
|
||||||
{
|
{
|
||||||
TCHAR foundStr[1024];
|
TCHAR foundStr[1024]{};
|
||||||
|
|
||||||
(*_ppEditView)->getGenericText(foundStr, 1024, targetStart, targetEnd);
|
(*_ppEditView)->getGenericText(foundStr, 1024, targetStart, targetEnd);
|
||||||
|
|
||||||
@ -890,9 +896,16 @@ intptr_t CALLBACK FunctionListPanel::run_dlgProc(UINT message, WPARAM wParam, LP
|
|||||||
|
|
||||||
oldFunclstSearchEditProc = reinterpret_cast<WNDPROC>(::SetWindowLongPtr(_hSearchEdit, GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(funclstSearchEditProc)));
|
oldFunclstSearchEditProc = reinterpret_cast<WNDPROC>(::SetWindowLongPtr(_hSearchEdit, GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(funclstSearchEditProc)));
|
||||||
|
|
||||||
HFONT hf = (HFONT)::GetStockObject(DEFAULT_GUI_FONT);
|
if (_hFontSearchEdit == nullptr)
|
||||||
if (hf)
|
{
|
||||||
::SendMessage(_hSearchEdit, WM_SETFONT, reinterpret_cast<WPARAM>(hf), MAKELPARAM(TRUE, 0));
|
LOGFONT lf{ NppParameters::getDefaultGUIFont() };
|
||||||
|
_hFontSearchEdit = ::CreateFontIndirect(&lf);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_hFontSearchEdit != nullptr)
|
||||||
|
{
|
||||||
|
::SendMessage(_hSearchEdit, WM_SETFONT, reinterpret_cast<WPARAM>(_hFontSearchEdit), MAKELPARAM(TRUE, 0));
|
||||||
|
}
|
||||||
|
|
||||||
_treeView.init(_hInst, _hSelf, IDC_LIST_FUNCLIST);
|
_treeView.init(_hInst, _hSelf, IDC_LIST_FUNCLIST);
|
||||||
_treeView.setImageList(CX_BITMAP, CY_BITMAP, 3, IDI_FUNCLIST_ROOT, IDI_FUNCLIST_NODE, IDI_FUNCLIST_LEAF);
|
_treeView.setImageList(CX_BITMAP, CY_BITMAP, 3, IDI_FUNCLIST_ROOT, IDI_FUNCLIST_NODE, IDI_FUNCLIST_LEAF);
|
||||||
|
@ -75,15 +75,16 @@ public:
|
|||||||
|
|
||||||
void init(HINSTANCE hInst, HWND hPere, ScintillaEditView **ppEditView);
|
void init(HINSTANCE hInst, HWND hPere, ScintillaEditView **ppEditView);
|
||||||
|
|
||||||
virtual void display(bool toShow = true) const {
|
void display(bool toShow = true) const override {
|
||||||
DockingDlgInterface::display(toShow);
|
DockingDlgInterface::display(toShow);
|
||||||
};
|
};
|
||||||
|
|
||||||
virtual void setBackgroundColor(COLORREF bgColour) {
|
void setBackgroundColor(COLORREF bgColour) override {
|
||||||
TreeView_SetBkColor(_treeView.getHSelf(), bgColour);
|
TreeView_SetBkColor(_treeView.getHSelf(), bgColour);
|
||||||
TreeView_SetBkColor(_treeViewSearchResult.getHSelf(), bgColour);
|
TreeView_SetBkColor(_treeViewSearchResult.getHSelf(), bgColour);
|
||||||
};
|
};
|
||||||
virtual void setForegroundColor(COLORREF fgColour) {
|
|
||||||
|
void setForegroundColor(COLORREF fgColour) override {
|
||||||
TreeView_SetTextColor(_treeView.getHSelf(), fgColour);
|
TreeView_SetTextColor(_treeView.getHSelf(), fgColour);
|
||||||
TreeView_SetTextColor(_treeViewSearchResult.getHSelf(), fgColour);
|
TreeView_SetTextColor(_treeViewSearchResult.getHSelf(), fgColour);
|
||||||
};
|
};
|
||||||
@ -103,18 +104,19 @@ public:
|
|||||||
void searchFuncAndSwitchView();
|
void searchFuncAndSwitchView();
|
||||||
|
|
||||||
protected:
|
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;
|
HMENU _hPreferencesMenu = NULL;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
HWND _hToolbarMenu = nullptr;
|
HWND _hToolbarMenu = nullptr;
|
||||||
HWND _hSearchEdit = nullptr;
|
HWND _hSearchEdit = nullptr;
|
||||||
|
HFONT _hFontSearchEdit = nullptr;
|
||||||
|
|
||||||
TreeView *_pTreeView = nullptr;
|
TreeView *_pTreeView = nullptr;
|
||||||
TreeView _treeView;
|
TreeView _treeView;
|
||||||
TreeView _treeViewSearchResult;
|
TreeView _treeViewSearchResult;
|
||||||
|
|
||||||
SCROLLINFO si = {};
|
SCROLLINFO si{};
|
||||||
long _findLine = -1;
|
long _findLine = -1;
|
||||||
long _findEndLine = -1;
|
long _findEndLine = -1;
|
||||||
HTREEITEM _findItem = nullptr;
|
HTREEITEM _findItem = nullptr;
|
||||||
@ -144,4 +146,3 @@ private:
|
|||||||
void initPreferencesMenu();
|
void initPreferencesMenu();
|
||||||
void showPreferencesMenu();
|
void showPreferencesMenu();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user