Apply dark mode on all find dialogs

1. Apply dark mode on find in finder dialog.
2. Apply dark mode on progress window (searching in files).
3. Make color more consistent for incremental search.
4. Use different border style for incremental search.
5. Set border for finder for docking panel consistency.

Fix #10233, close #10234
This commit is contained in:
ozone10 2021-07-24 14:17:40 +02:00 committed by Don Ho
parent 5b9e3b6406
commit 89d835a56f
5 changed files with 132 additions and 4 deletions

View File

@ -7575,6 +7575,9 @@ void Notepad_plus::refreshDarkMode()
RedrawWindow(_pPublicInterface->getHSelf(), nullptr, nullptr, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME | RDW_ALLCHILDREN);
SendMessage(_pPublicInterface->getHSelf(), NPPM_INTERNAL_CHANGETABBAEICONS, 0, NppDarkMode::isEnabled() ? 2 : 0);
::SendMessage(_findInFinderDlg.getHSelf(), NPPM_INTERNAL_REFRESHDARKMODE, 0, 0);
::RedrawWindow(_findInFinderDlg.getHSelf(), nullptr, nullptr, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME | RDW_ALLCHILDREN);
toolBarStatusType state = _toolBar.getState();
switch (state)
{

View File

@ -1563,7 +1563,7 @@ namespace NppDarkMode
HWND hHeader = ListView_GetHeader(hwnd);
NppDarkMode::allowDarkModeForWindow(hHeader, useDark);
SetWindowTheme(hHeader, L"ItemsView", nullptr);
SetWindowTheme(hHeader, useDark ? L"ItemsView" : nullptr, nullptr);
NppDarkMode::allowDarkModeForWindow(hwnd, useDark);
SetWindowTheme(hwnd, L"Explorer", nullptr);
@ -1587,6 +1587,30 @@ namespace NppDarkMode
SetWindowTheme(hwnd, nullptr, nullptr);
}
void setBorder(HWND hwnd, bool border)
{
auto style = static_cast<long>(::GetWindowLongPtr(hwnd, GWL_STYLE));
bool hasBorder = (style & WS_BORDER) == WS_BORDER;
bool change = false;
if (!hasBorder && border)
{
style |= WS_BORDER;
change = true;
}
else if (hasBorder && !border)
{
style &= ~WS_BORDER;
change = true;
}
if (change)
{
::SetWindowLongPtr(hwnd, GWL_STYLE, style);
::SetWindowPos(hwnd, nullptr, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED);
}
}
LRESULT onCtlColor(HDC hdc)
{
::SetTextColor(hdc, NppDarkMode::getTextColor());

View File

@ -153,6 +153,7 @@ namespace NppDarkMode
void disableVisualStyle(HWND hwnd, bool doDisable);
void setTreeViewStyle(HWND hwnd);
void setBorder(HWND hwnd, bool border = true);
LRESULT onCtlColor(HDC hdc);
LRESULT onCtlColorSofter(HDC hdc);

View File

@ -712,10 +712,61 @@ INT_PTR CALLBACK FindInFinderDlg::run_dlgProc(UINT message, WPARAM wParam, LPARA
{
NativeLangSpeaker *pNativeSpeaker = (NppParameters::getInstance()).getNativeLangSpeaker();
pNativeSpeaker->changeDlgLang(_hSelf, "FindInFinder");
EnableThemeDialogTexture(_hSelf, ETDT_ENABLETAB);
NppDarkMode::autoSubclassAndThemeChildControls(_hSelf);
initFromOptions();
}
return TRUE;
case WM_CTLCOLOREDIT:
{
if (NppDarkMode::isEnabled())
{
return NppDarkMode::onCtlColorSofter(reinterpret_cast<HDC>(wParam));
}
break;
}
case WM_CTLCOLORLISTBOX:
case WM_CTLCOLORDLG:
case WM_CTLCOLORSTATIC:
{
if (NppDarkMode::isEnabled())
{
return NppDarkMode::onCtlColorDarker(reinterpret_cast<HDC>(wParam));
}
break;
}
case WM_PRINTCLIENT:
{
if (NppDarkMode::isEnabled())
{
return TRUE;
}
break;
}
case WM_ERASEBKGND:
{
if (NppDarkMode::isEnabled())
{
RECT rc = { 0 };
getClientRect(rc);
::FillRect(reinterpret_cast<HDC>(wParam), &rc, NppDarkMode::getDarkerBackgroundBrush());
return TRUE;
}
break;
}
case NPPM_INTERNAL_REFRESHDARKMODE:
{
NppDarkMode::autoThemeChildControls(_hSelf);
return TRUE;
}
case WM_COMMAND:
{
switch (LOWORD(wParam))
@ -767,6 +818,7 @@ INT_PTR CALLBACK FindInFinderDlg::run_dlgProc(UINT message, WPARAM wParam, LPARA
default:
return FALSE;
}
return FALSE;
}
@ -896,6 +948,11 @@ INT_PTR CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM
NppDarkMode::setDarkTooltips(_2ButtonsTip, NppDarkMode::ToolTipsType::tooltip);
NppDarkMode::setDarkTooltips(_filterTip, NppDarkMode::ToolTipsType::tooltip);
if (_statusbarTooltipWnd)
{
NppDarkMode::setDarkTooltips(_statusbarTooltipWnd, NppDarkMode::ToolTipsType::tooltip);
}
HWND finder = getHFindResults();
if (finder)
{
@ -3769,6 +3826,8 @@ void FindReplaceDlg::drawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
rect.right = rect.left + s;
rect.bottom = rect.top + s;
_statusbarTooltipWnd = CreateToolTipRect(1, _statusBar.getHSelf(), _hInst, const_cast<PTSTR>(_statusbarTooltipMsg.c_str()), rect);
NppDarkMode::setDarkTooltips(_statusbarTooltipWnd, NppDarkMode::ToolTipsType::tooltip);
}
}
else
@ -4188,6 +4247,8 @@ void Finder::setFinderStyle()
// Set global styles for the finder
_scintView.performGlobalStyles();
NppDarkMode::setBorder(_scintView.getHSelf());
// Set current line background color for the finder
const TCHAR * lexerName = ScintillaEditView::langNames[L_SEARCHRESULT].lexerName;
LexerStyler *pStyler = (NppParameters::getInstance().getLStylerArray()).getLexerStylerByName(lexerName);
@ -4490,7 +4551,7 @@ INT_PTR CALLBACK FindIncrementDlg::run_dlgProc(UINT message, WPARAM wParam, LPAR
return DefWindowProc(getHSelf(), message, wParam, lParam);
}
return NppDarkMode::onCtlColor(reinterpret_cast<HDC>(wParam));
return NppDarkMode::onCtlColorDarker(reinterpret_cast<HDC>(wParam));
}
case NPPM_INTERNAL_REFRESHDARKMODE:
@ -4503,6 +4564,7 @@ INT_PTR CALLBACK FindIncrementDlg::run_dlgProc(UINT message, WPARAM wParam, LPAR
{
LRESULT lr = DefWindowProc(getHSelf(), message, wParam, lParam);
NppDarkMode::setBorder(::GetDlgItem(getHSelf(), IDC_INCFINDTEXT));
NppDarkMode::autoSubclassAndThemeChildControls(getHSelf());
return lr;
}
@ -4608,7 +4670,7 @@ INT_PTR CALLBACK FindIncrementDlg::run_dlgProc(UINT message, WPARAM wParam, LPAR
{
RECT rcClient = { 0 };
GetClientRect(_hSelf, &rcClient);
FillRect((HDC)wParam, &rcClient, NppDarkMode::getBackgroundBrush());
::FillRect(reinterpret_cast<HDC>(wParam), &rcClient, NppDarkMode::getDarkerBackgroundBrush());
return TRUE;
}
else
@ -4875,6 +4937,17 @@ int Progress::createProgressWindow()
_hwnd, NULL, _hInst, NULL);
SendMessage(_hPBar, PBM_SETRANGE, 0, MAKELPARAM(0, 100));
// Set border so user can distinguish easier progress bar,
// especially, when getBackgroundColor is very similar or same
// as getDarkerBackgroundColor
NppDarkMode::setBorder(_hPBar, NppDarkMode::isEnabled());
NppDarkMode::disableVisualStyle(_hPBar, NppDarkMode::isEnabled());
if (NppDarkMode::isEnabled())
{
::SendMessage(_hPBar, PBM_SETBKCOLOR, 0, static_cast<LPARAM>(NppDarkMode::getBackgroundColor()));
::SendMessage(_hPBar, PBM_SETBARCOLOR, 0, static_cast<LPARAM>(NppDarkMode::getDarkerTextColor()));
}
_hBtn = ::CreateWindowEx(0, TEXT("BUTTON"), TEXT("Cancel"),
WS_CHILD | WS_VISIBLE | BS_DEFPUSHBUTTON | BS_TEXT,
(width - cBTNwidth) / 2, height - cBTNheight - 5,
@ -4883,6 +4956,9 @@ int Progress::createProgressWindow()
if (hf)
::SendMessage(_hBtn, WM_SETFONT, reinterpret_cast<WPARAM>(hf), MAKELPARAM(TRUE, 0));
NppDarkMode::autoSubclassAndThemeChildControls(_hwnd);
NppDarkMode::setDarkTitleBar(_hwnd);
::ShowWindow(_hwnd, SW_SHOWNORMAL);
::UpdateWindow(_hwnd);
@ -4974,6 +5050,30 @@ LRESULT APIENTRY Progress::wndProc(HWND hwnd, UINT umsg, WPARAM wparam, LPARAM l
return 0;
}
case WM_CTLCOLORDLG:
case WM_CTLCOLORSTATIC:
{
if (NppDarkMode::isEnabled())
{
return NppDarkMode::onCtlColorDarker(reinterpret_cast<HDC>(wparam));
}
break;
}
case WM_ERASEBKGND:
{
if (NppDarkMode::isEnabled())
{
RECT rc = { 0 };
GetClientRect(hwnd, &rc);
::FillRect(reinterpret_cast<HDC>(wparam), &rc, NppDarkMode::getDarkerBackgroundBrush());
return TRUE;
}
break;
}
case WM_SETFOCUS:
{
Progress* pw = reinterpret_cast<Progress*>(static_cast<LONG_PTR>

View File

@ -93,7 +93,7 @@ FONT 8, TEXT("MS Shell Dlg")
BEGIN
PUSHBUTTON "X",IDCANCEL,2,3,16,14
RTEXT "Find :",IDC_INCSTATIC,20,6,25,12
EDITTEXT IDC_INCFINDTEXT,45,6,175,10,ES_AUTOHSCROLL | ES_WANTRETURN | NOT WS_BORDER | WS_TABSTOP, WS_EX_STATICEDGE
EDITTEXT IDC_INCFINDTEXT,45,6,175,10,ES_AUTOHSCROLL | ES_WANTRETURN | NOT WS_BORDER | WS_TABSTOP
PUSHBUTTON "<",IDC_INCFINDPREVOK,223,3,16,14, WS_TABSTOP
PUSHBUTTON ">",IDC_INCFINDNXTOK,243,3,16,14, WS_TABSTOP
CONTROL "&Highlight all", IDC_INCFINDHILITEALL,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,270,5,65,12