Enhance combobox & edit field in dark mode

1. Allow function list search to use dark mode error background.
2. Make combobox more dark and allow to use custom colors (borders, arrow head and background).
3. Use dark listbox in combobox.

Fix #10178, close  #10179
pull/10199/head
ozone10 2021-07-16 21:32:53 +02:00 committed by Don Ho
parent aa69711d4c
commit 81b21aae2a
4 changed files with 402 additions and 244 deletions

View File

@ -1,4 +1,4 @@
#include "nppDarkMode.h" #include "nppDarkMode.h"
#include "DarkMode/DarkMode.h" #include "DarkMode/DarkMode.h"
#include "DarkMode/UAHMenuBar.h" #include "DarkMode/UAHMenuBar.h"
@ -117,7 +117,6 @@ namespace NppDarkMode
HEXRGB(0x809080) // edgeColor HEXRGB(0x809080) // edgeColor
}; };
// blue tone // blue tone
static const Colors darkBlueColors{ static const Colors darkBlueColors{
HEXRGB(0x202040), // background HEXRGB(0x202040), // background
@ -1223,6 +1222,109 @@ namespace NppDarkMode
SetWindowSubclass(hwnd, TabSubclass, g_tabSubclassID, 0); SetWindowSubclass(hwnd, TabSubclass, g_tabSubclassID, 0);
} }
constexpr UINT_PTR g_comboBoxSubclassID = 42;
LRESULT CALLBACK ComboBoxSubclass(
HWND hWnd,
UINT uMsg,
WPARAM wParam,
LPARAM lParam,
UINT_PTR uIdSubclass,
DWORD_PTR /*dwRefData*/
)
{
switch (uMsg)
{
case WM_PAINT:
{
if (!NppDarkMode::isEnabled())
{
break;
}
RECT rc = { 0 };
::GetClientRect(hWnd, &rc);
PAINTSTRUCT ps;
auto hdc = ::BeginPaint(hWnd, &ps);
auto holdPen = static_cast<HPEN>(::SelectObject(hdc, NppDarkMode::getEdgePen()));
::SelectObject(hdc, reinterpret_cast<HFONT>(::SendMessage(hWnd, WM_GETFONT, 0, 0)));
::SetBkColor(hdc, NppDarkMode::getBackgroundColor());
::SelectObject(hdc, ::GetStockObject(NULL_BRUSH)); // to avoid text flicker, use only border
::Rectangle(hdc, 0, 0, rc.right, rc.bottom);
auto holdBrush = ::SelectObject(hdc, NppDarkMode::getBackgroundBrush());
// CBS_DROPDOWN text is handled by parent by WM_CTLCOLOREDIT
auto style = ::GetWindowLongPtr(hWnd, GWL_STYLE);
if ((style & CBS_DROPDOWNLIST) == CBS_DROPDOWNLIST)
{
auto index = static_cast<int>(::SendMessage(hWnd, CB_GETCURSEL, 0, 0));
if (index != CB_ERR)
{
::SetTextColor(hdc, NppDarkMode::getTextColor());
auto bufferLen = static_cast<size_t>(::SendMessage(hWnd, CB_GETLBTEXTLEN, index, 0));
TCHAR* buffer = new TCHAR[(bufferLen + 1)];
::SendMessage(hWnd, CB_GETLBTEXT, index, reinterpret_cast<LPARAM>(buffer));
RECT textRc = rc;
textRc.left += NppParameters::getInstance()._dpiManager.scaleX(4);
textRc.right -= NppParameters::getInstance()._dpiManager.scaleX(23);
::DrawText(hdc, buffer, -1, &textRc, DT_EDITCONTROL | DT_NOPREFIX | DT_LEFT | DT_VCENTER | DT_SINGLELINE);
delete[]buffer;
}
}
RECT arrowRc = {
rc.right - NppParameters::getInstance()._dpiManager.scaleX(17), rc.top + 1,
rc.right - 1, rc.bottom - 1
};
POINT ptCursor = { 0 };
::GetCursorPos(&ptCursor);
ScreenToClient(hWnd, &ptCursor);
bool isHot = PtInRect(&rc, ptCursor);
::SetTextColor(hdc, isHot ? NppDarkMode::getTextColor() : NppDarkMode::getDarkerTextColor());
::SetBkColor(hdc, isHot ? NppDarkMode::getHotBackgroundColor() : NppDarkMode::getBackgroundColor());
::ExtTextOut(hdc,
rc.right - NppParameters::getInstance()._dpiManager.scaleX(13),
rc.top + 4,
ETO_OPAQUE | ETO_CLIPPED,
&arrowRc, L"˅",
1,
nullptr);
::SetBkColor(hdc, NppDarkMode::getBackgroundColor());
POINT edge[] = {
{rc.right - NppParameters::getInstance()._dpiManager.scaleX(18), rc.top + 1},
{rc.right - NppParameters::getInstance()._dpiManager.scaleX(18), rc.bottom - 1}
};
::Polyline(hdc, edge, _countof(edge));
::SelectObject(hdc, holdPen);
::SelectObject(hdc, holdBrush);
::EndPaint(hWnd, &ps);
return 0;
}
case WM_NCDESTROY:
{
::RemoveWindowSubclass(hWnd, ComboBoxSubclass, uIdSubclass);
break;
}
}
return DefSubclassProc(hWnd, uMsg, wParam, lParam);
}
void subclassComboBoxControl(HWND hwnd)
{
SetWindowSubclass(hwnd, ComboBoxSubclass, g_comboBoxSubclassID, 0);
}
void autoSubclassAndThemeChildControls(HWND hwndParent, bool subclass, bool theme) void autoSubclassAndThemeChildControls(HWND hwndParent, bool subclass, bool theme)
{ {
struct Params struct Params
@ -1233,44 +1335,57 @@ namespace NppDarkMode
}; };
Params p{ Params p{
NppDarkMode::isEnabled() ? L"DarkMode_Explorer" : L"Button" NppDarkMode::isEnabled() ? L"DarkMode_Explorer" : nullptr
, subclass , subclass
, theme , theme
}; };
EnumChildWindows(hwndParent, [](HWND hwnd, LPARAM lParam) { EnumChildWindows(hwndParent, [](HWND hwnd, LPARAM lParam) {
auto& p = *reinterpret_cast<Params*>(lParam); auto& p = *reinterpret_cast<Params*>(lParam);
wchar_t className[16] = { 0 }; const size_t classNameLen = 16;
GetClassName(hwnd, className, 9); TCHAR className[classNameLen] = { 0 };
if (wcscmp(className, L"Button")) GetClassName(hwnd, className, classNameLen);
if (wcscmp(className, WC_COMBOBOX) == 0)
{ {
auto style = ::GetWindowLongPtr(hwnd, GWL_STYLE);
if ((style & CBS_DROPDOWNLIST) == CBS_DROPDOWNLIST || (style & CBS_DROPDOWN) == CBS_DROPDOWN)
{
NppDarkMode::subclassComboBoxControl(hwnd);
}
return TRUE; return TRUE;
} }
DWORD nButtonStyle = (DWORD)GetWindowLong(hwnd, GWL_STYLE) & 0xF;
switch (nButtonStyle) if (wcscmp(className, WC_BUTTON) == 0)
{ {
case BS_CHECKBOX: auto nButtonStyle = ::GetWindowLongPtr(hwnd, GWL_STYLE) & 0xF;
case BS_AUTOCHECKBOX: switch (nButtonStyle)
case BS_RADIOBUTTON:
case BS_AUTORADIOBUTTON:
if (p.subclass)
{ {
NppDarkMode::subclassButtonControl(hwnd); case BS_CHECKBOX:
case BS_AUTOCHECKBOX:
case BS_RADIOBUTTON:
case BS_AUTORADIOBUTTON:
if (p.subclass)
{
NppDarkMode::subclassButtonControl(hwnd);
}
break;
case BS_GROUPBOX:
if (p.subclass)
{
NppDarkMode::subclassGroupboxControl(hwnd);
}
break;
case BS_DEFPUSHBUTTON:
case BS_PUSHBUTTON:
if (p.theme)
{
SetWindowTheme(hwnd, p.themeClassName, nullptr);
}
break;
} }
break; return TRUE;
case BS_GROUPBOX:
if (p.subclass)
{
NppDarkMode::subclassGroupboxControl(hwnd);
}
break;
case BS_DEFPUSHBUTTON:
case BS_PUSHBUTTON:
if (p.theme)
{
SetWindowTheme(hwnd, p.themeClassName, nullptr);
}
break;
} }
return TRUE; return TRUE;
}, reinterpret_cast<LPARAM>(&p)); }, reinterpret_cast<LPARAM>(&p));
@ -1381,4 +1496,25 @@ namespace NppDarkMode
{ {
SetWindowTheme(hwnd, nullptr, nullptr); SetWindowTheme(hwnd, nullptr, nullptr);
} }
LRESULT onCtlColor(HDC hdc)
{
::SetTextColor(hdc, NppDarkMode::getTextColor());
::SetBkColor(hdc, NppDarkMode::getBackgroundColor());
return reinterpret_cast<LRESULT>(NppDarkMode::getBackgroundBrush());
}
LRESULT onCtlColorSofter(HDC hdc)
{
::SetTextColor(hdc, NppDarkMode::getTextColor());
::SetBkColor(hdc, NppDarkMode::getSofterBackgroundColor());
return reinterpret_cast<LRESULT>(NppDarkMode::getSofterBackgroundBrush());
}
LRESULT onCtlColorError(HDC hdc)
{
::SetTextColor(hdc, NppDarkMode::getTextColor());
::SetBkColor(hdc, NppDarkMode::getErrorBackgroundColor());
return reinterpret_cast<LRESULT>(NppDarkMode::getErrorBackgroundBrush());
}
} }

View File

@ -118,6 +118,7 @@ namespace NppDarkMode
void subclassGroupboxControl(HWND hwnd); void subclassGroupboxControl(HWND hwnd);
void subclassToolbarControl(HWND hwnd); void subclassToolbarControl(HWND hwnd);
void subclassTabControl(HWND hwnd); void subclassTabControl(HWND hwnd);
void subclassComboBoxControl(HWND hwnd);
void autoSubclassAndThemeChildControls(HWND hwndParent, bool subclass = true, bool theme = true); void autoSubclassAndThemeChildControls(HWND hwndParent, bool subclass = true, bool theme = true);
void autoThemeChildControls(HWND hwndParent); void autoThemeChildControls(HWND hwndParent);
@ -131,4 +132,8 @@ namespace NppDarkMode
void disableVisualStyle(HWND hwnd, bool doDisable); void disableVisualStyle(HWND hwnd, bool doDisable);
void setTreeViewStyle(HWND hwnd); void setTreeViewStyle(HWND hwnd);
LRESULT onCtlColor(HDC hdc);
LRESULT onCtlColorSofter(HDC hdc);
LRESULT onCtlColorError(HDC hdc);
} }

View File

@ -325,7 +325,7 @@ void FindReplaceDlg::fillFindHistory()
fillComboHistory(IDFINDWHAT, findHistory._findHistoryFinds); fillComboHistory(IDFINDWHAT, findHistory._findHistoryFinds);
fillComboHistory(IDREPLACEWITH, findHistory._findHistoryReplaces); fillComboHistory(IDREPLACEWITH, findHistory._findHistoryReplaces);
fillComboHistory(IDD_FINDINFILES_FILTERS_COMBO, findHistory._findHistoryFilters); fillComboHistory(IDD_FINDINFILES_FILTERS_COMBO, findHistory._findHistoryFilters);
fillComboHistory(IDD_FINDINFILES_DIR_COMBO, findHistory._findHistoryPaths); fillComboHistory(IDD_FINDINFILES_DIR_COMBO, findHistory._findHistoryPaths);
::SendDlgItemMessage(_hSelf, IDWRAP, BM_SETCHECK, findHistory._isWrap, 0); ::SendDlgItemMessage(_hSelf, IDWRAP, BM_SETCHECK, findHistory._isWrap, 0);
::SendDlgItemMessage(_hSelf, IDWHOLEWORD, BM_SETCHECK, findHistory._isMatchWord, 0); ::SendDlgItemMessage(_hSelf, IDWHOLEWORD, BM_SETCHECK, findHistory._isMatchWord, 0);
@ -334,7 +334,7 @@ void FindReplaceDlg::fillFindHistory()
::SendDlgItemMessage(_hSelf, IDD_FINDINFILES_INHIDDENDIR_CHECK, BM_SETCHECK, findHistory._isFifInHiddenFolder, 0); ::SendDlgItemMessage(_hSelf, IDD_FINDINFILES_INHIDDENDIR_CHECK, BM_SETCHECK, findHistory._isFifInHiddenFolder, 0);
::SendDlgItemMessage(_hSelf, IDD_FINDINFILES_RECURSIVE_CHECK, BM_SETCHECK, findHistory._isFifRecuisive, 0); ::SendDlgItemMessage(_hSelf, IDD_FINDINFILES_RECURSIVE_CHECK, BM_SETCHECK, findHistory._isFifRecuisive, 0);
::SendDlgItemMessage(_hSelf, IDD_FINDINFILES_FOLDERFOLLOWSDOC_CHECK, BM_SETCHECK, findHistory._isFolderFollowDoc, 0); ::SendDlgItemMessage(_hSelf, IDD_FINDINFILES_FOLDERFOLLOWSDOC_CHECK, BM_SETCHECK, findHistory._isFolderFollowDoc, 0);
::SendDlgItemMessage(_hSelf, IDD_FINDINFILES_PROJECT1_CHECK, BM_SETCHECK, findHistory._isFifProjectPanel_1, 0); ::SendDlgItemMessage(_hSelf, IDD_FINDINFILES_PROJECT1_CHECK, BM_SETCHECK, findHistory._isFifProjectPanel_1, 0);
::SendDlgItemMessage(_hSelf, IDD_FINDINFILES_PROJECT2_CHECK, BM_SETCHECK, findHistory._isFifProjectPanel_2, 0); ::SendDlgItemMessage(_hSelf, IDD_FINDINFILES_PROJECT2_CHECK, BM_SETCHECK, findHistory._isFifProjectPanel_2, 0);
@ -850,30 +850,44 @@ INT_PTR CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM
} }
case WM_CTLCOLOREDIT: case WM_CTLCOLOREDIT:
{
if (NppDarkMode::isEnabled())
{
return NppDarkMode::onCtlColorSofter(reinterpret_cast<HDC>(wParam));
}
break;
}
case WM_CTLCOLORDLG: case WM_CTLCOLORDLG:
case WM_CTLCOLORSTATIC: case WM_CTLCOLORSTATIC:
case WM_CTLCOLORLISTBOX:
{ {
if (!NppDarkMode::isEnabled()) if (NppDarkMode::isEnabled())
{ {
break; return NppDarkMode::onCtlColor(reinterpret_cast<HDC>(wParam));
} }
break;
SetTextColor((HDC)wParam, NppDarkMode::getTextColor());
SetBkColor((HDC)wParam, NppDarkMode::getBackgroundColor());
return (LRESULT)NppDarkMode::getBackgroundBrush();
} }
case WM_PRINTCLIENT: case WM_PRINTCLIENT:
{
if (NppDarkMode::isEnabled())
{
return TRUE;
}
break;
}
case WM_ERASEBKGND: case WM_ERASEBKGND:
{ {
if (!NppDarkMode::isEnabled()) if (NppDarkMode::isEnabled())
{ {
break; RECT rc = { 0 };
getClientRect(rc);
FillRect(reinterpret_cast<HDC>(wParam), &rc, NppDarkMode::getBackgroundBrush());
return TRUE;
} }
RECT rc = { 0 }; break;
getClientRect(rc);
FillRect((HDC)wParam, &rc, NppDarkMode::getBackgroundBrush());
SetWindowLongPtr(_hSelf, DWLP_MSGRESULT, TRUE);
return TRUE;
} }
case NPPM_INTERNAL_REFRESHDARKMODE: case NPPM_INTERNAL_REFRESHDARKMODE:
@ -1248,8 +1262,8 @@ INT_PTR CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM
if (_currentStatus == FIND_DLG) if (_currentStatus == FIND_DLG)
{ {
setStatusbarMessage(TEXT(""), FSNoMessage); setStatusbarMessage(TEXT(""), FSNoMessage);
HWND hFindCombo = ::GetDlgItem(_hSelf, IDFINDWHAT); HWND hFindCombo = ::GetDlgItem(_hSelf, IDFINDWHAT);
combo2ExtendedMode(IDFINDWHAT); combo2ExtendedMode(IDFINDWHAT);
_options._str2Search = getTextFromCombo(hFindCombo); _options._str2Search = getTextFromCombo(hFindCombo);
updateCombo(IDFINDWHAT); updateCombo(IDFINDWHAT);
@ -1265,7 +1279,7 @@ INT_PTR CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM
{ {
setStatusbarMessage(TEXT(""), FSNoMessage); setStatusbarMessage(TEXT(""), FSNoMessage);
HWND hFindCombo = ::GetDlgItem(_hSelf, IDFINDWHAT); HWND hFindCombo = ::GetDlgItem(_hSelf, IDFINDWHAT);
combo2ExtendedMode(IDFINDWHAT); combo2ExtendedMode(IDFINDWHAT);
_options._str2Search = getTextFromCombo(hFindCombo); _options._str2Search = getTextFromCombo(hFindCombo);
updateCombo(IDFINDWHAT); updateCombo(IDFINDWHAT);
@ -1744,17 +1758,17 @@ INT_PTR CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM
} }
return TRUE; return TRUE;
case IDD_FINDINFILES_FOLDERFOLLOWSDOC_CHECK : case IDD_FINDINFILES_FOLDERFOLLOWSDOC_CHECK :
{ {
if (_currentStatus == FINDINFILES_DLG) if (_currentStatus == FINDINFILES_DLG)
findHistory._isFolderFollowDoc = isCheckedOrNot(IDD_FINDINFILES_FOLDERFOLLOWSDOC_CHECK); findHistory._isFolderFollowDoc = isCheckedOrNot(IDD_FINDINFILES_FOLDERFOLLOWSDOC_CHECK);
if (findHistory._isFolderFollowDoc) if (findHistory._isFolderFollowDoc)
{ {
NppParameters& nppParam = NppParameters::getInstance(); NppParameters& nppParam = NppParameters::getInstance();
const TCHAR * dir = nppParam.getWorkingDir(); const TCHAR * dir = nppParam.getWorkingDir();
::SetDlgItemText(_hSelf, IDD_FINDINFILES_DIR_COMBO, dir); ::SetDlgItemText(_hSelf, IDD_FINDINFILES_DIR_COMBO, dir);
} }
} }
return TRUE; return TRUE;
@ -2473,10 +2487,10 @@ int FindReplaceDlg::processRange(ProcessOperation op, FindReplaceInfo & findRepl
} }
if (processed) ++nbProcessed; if (processed) ++nbProcessed;
// After the processing of the last string occurrence the search loop should be stopped // After the processing of the last string occurrence the search loop should be stopped
// This helps to avoid the endless replacement during the EOL ("$") searching // This helps to avoid the endless replacement during the EOL ("$") searching
if (targetStart + foundTextLen == findReplaceInfo._endRange) if (targetStart + foundTextLen == findReplaceInfo._endRange)
break; break;
findReplaceInfo._startRange = targetStart + foundTextLen + replaceDelta; //search from result onwards findReplaceInfo._startRange = targetStart + foundTextLen + replaceDelta; //search from result onwards
findReplaceInfo._endRange += replaceDelta; //adjust end of range in case of replace findReplaceInfo._endRange += replaceDelta; //adjust end of range in case of replace
@ -3498,7 +3512,7 @@ void FindReplaceDlg::doDialog(DIALOG_TYPE whichType, bool isRTL, bool toShow)
enableReplaceFunc(whichType == REPLACE_DLG); enableReplaceFunc(whichType == REPLACE_DLG);
::SetFocus(::GetDlgItem(_hSelf, IDFINDWHAT)); ::SetFocus(::GetDlgItem(_hSelf, IDFINDWHAT));
display(toShow, true); display(toShow, true);
} }
LRESULT FAR PASCAL FindReplaceDlg::finderProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) LRESULT FAR PASCAL FindReplaceDlg::finderProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
@ -3623,40 +3637,40 @@ void FindReplaceDlg::combo2ExtendedMode(int comboID)
generic_string str2transform = getTextFromCombo(hFindCombo); generic_string str2transform = getTextFromCombo(hFindCombo);
// Count the number of character '\n' and '\r' // Count the number of character '\n' and '\r'
size_t nbEOL = 0; size_t nbEOL = 0;
size_t str2transformLen = lstrlen(str2transform.c_str()); size_t str2transformLen = lstrlen(str2transform.c_str());
for (size_t i = 0 ; i < str2transformLen ; ++i) for (size_t i = 0 ; i < str2transformLen ; ++i)
{ {
if (str2transform[i] == '\r' || str2transform[i] == '\n') if (str2transform[i] == '\r' || str2transform[i] == '\n')
++nbEOL; ++nbEOL;
} }
if (nbEOL) if (nbEOL)
{ {
TCHAR * newBuffer = new TCHAR[str2transformLen + nbEOL*2 + 1]; TCHAR * newBuffer = new TCHAR[str2transformLen + nbEOL*2 + 1];
int j = 0; int j = 0;
for (size_t i = 0 ; i < str2transformLen ; ++i) for (size_t i = 0 ; i < str2transformLen ; ++i)
{ {
if (str2transform[i] == '\r') if (str2transform[i] == '\r')
{ {
newBuffer[j++] = '\\'; newBuffer[j++] = '\\';
newBuffer[j++] = 'r'; newBuffer[j++] = 'r';
} }
else if (str2transform[i] == '\n') else if (str2transform[i] == '\n')
{ {
newBuffer[j++] = '\\'; newBuffer[j++] = '\\';
newBuffer[j++] = 'n'; newBuffer[j++] = 'n';
} }
else else
{ {
newBuffer[j++] = str2transform[i]; newBuffer[j++] = str2transform[i];
} }
} }
newBuffer[j++] = '\0'; newBuffer[j++] = '\0';
setSearchText(newBuffer); setSearchText(newBuffer);
_options._searchType = FindExtended; _options._searchType = FindExtended;
::SendDlgItemMessage(_hSelf, IDNORMAL, BM_SETCHECK, FALSE, 0); ::SendDlgItemMessage(_hSelf, IDNORMAL, BM_SETCHECK, FALSE, 0);
::SendDlgItemMessage(_hSelf, IDEXTENDED, BM_SETCHECK, TRUE, 0); ::SendDlgItemMessage(_hSelf, IDEXTENDED, BM_SETCHECK, TRUE, 0);
::SendDlgItemMessage(_hSelf, IDREGEXP, BM_SETCHECK, FALSE, 0); ::SendDlgItemMessage(_hSelf, IDREGEXP, BM_SETCHECK, FALSE, 0);
@ -4190,11 +4204,11 @@ void Finder::setFinderStyle()
// Override foreground & background colour by default foreground & background coulour // Override foreground & background colour by default foreground & background coulour
StyleArray & stylers = NppParameters::getInstance().getMiscStylerArray(); StyleArray & stylers = NppParameters::getInstance().getMiscStylerArray();
int iStyleDefault = stylers.getStylerIndexByID(STYLE_DEFAULT); int iStyleDefault = stylers.getStylerIndexByID(STYLE_DEFAULT);
if (iStyleDefault != -1) if (iStyleDefault != -1)
{ {
Style & styleDefault = stylers.getStyler(iStyleDefault); Style & styleDefault = stylers.getStyler(iStyleDefault);
_scintView.setStyle(styleDefault); _scintView.setStyle(styleDefault);
GlobalOverride & go = NppParameters::getInstance().getGlobalOverrideStyle(); GlobalOverride & go = NppParameters::getInstance().getGlobalOverrideStyle();
if (go.isEnable()) if (go.isEnable())
@ -4216,7 +4230,7 @@ void Finder::setFinderStyle()
_scintView.execute(SCI_STYLESETFORE, SCE_SEARCHRESULT_DEFAULT, styleDefault._fgColor); _scintView.execute(SCI_STYLESETFORE, SCE_SEARCHRESULT_DEFAULT, styleDefault._fgColor);
_scintView.execute(SCI_STYLESETBACK, SCE_SEARCHRESULT_DEFAULT, styleDefault._bgColor); _scintView.execute(SCI_STYLESETBACK, SCE_SEARCHRESULT_DEFAULT, styleDefault._bgColor);
} }
_scintView.execute(SCI_COLOURISE, 0, -1); _scintView.execute(SCI_COLOURISE, 0, -1);
@ -4442,19 +4456,17 @@ INT_PTR CALLBACK FindIncrementDlg::run_dlgProc(UINT message, WPARAM wParam, LPAR
// Make edit field red if not found // Make edit field red if not found
case WM_CTLCOLOREDIT : case WM_CTLCOLOREDIT :
{ {
auto hdc = reinterpret_cast<HDC>(wParam);
if (NppDarkMode::isEnabled()) if (NppDarkMode::isEnabled())
{ {
if (FSNotFound != getFindStatus()) if (FSNotFound != getFindStatus())
{ {
SetTextColor((HDC)wParam, NppDarkMode::getTextColor()); return NppDarkMode::onCtlColorSofter(hdc);
SetBkColor((HDC)wParam, NppDarkMode::getBackgroundColor());
return (LRESULT)NppDarkMode::getBackgroundBrush();
} }
else // text not found else // text not found
{ {
SetTextColor((HDC)wParam, NppDarkMode::getTextColor()); return NppDarkMode::onCtlColorError(hdc);
SetBkColor((HDC)wParam, NppDarkMode::getErrorBackgroundColor());
return (LRESULT)NppDarkMode::getErrorBackgroundBrush();
} }
} }
@ -4465,9 +4477,9 @@ INT_PTR CALLBACK FindIncrementDlg::run_dlgProc(UINT message, WPARAM wParam, LPAR
return FALSE; // text found, use the default color return FALSE; // text found, use the default color
// text not found // text not found
SetTextColor((HDC)wParam, TXT_COLOR); SetTextColor(hdc, TXT_COLOR);
SetBkColor((HDC)wParam, BCKGRD_COLOR); SetBkColor(hdc, BCKGRD_COLOR);
return (LRESULT)hBrushBackground; return reinterpret_cast<LRESULT>(hBrushBackground);
} }
case WM_CTLCOLORDLG: case WM_CTLCOLORDLG:
@ -4478,9 +4490,7 @@ INT_PTR CALLBACK FindIncrementDlg::run_dlgProc(UINT message, WPARAM wParam, LPAR
return DefWindowProc(getHSelf(), message, wParam, lParam); return DefWindowProc(getHSelf(), message, wParam, lParam);
} }
SetTextColor((HDC)wParam, NppDarkMode::getTextColor()); return NppDarkMode::onCtlColor(reinterpret_cast<HDC>(wParam));
SetBkColor((HDC)wParam, NppDarkMode::getBackgroundColor());
return (LRESULT)NppDarkMode::getBackgroundBrush();
} }
case NPPM_INTERNAL_REFRESHDARKMODE: case NPPM_INTERNAL_REFRESHDARKMODE:
@ -4642,9 +4652,9 @@ void FindIncrementDlg::setFindStatus(FindStatus iStatus, int nbCounted)
{ {
static TCHAR findCount[128] = TEXT(""); static TCHAR findCount[128] = TEXT("");
static const TCHAR * const findStatus[] = { findCount, // FSFound static const TCHAR * const findStatus[] = { findCount, // FSFound
TEXT("Phrase not found"), //FSNotFound TEXT("Phrase not found"), //FSNotFound
TEXT("Reached top of page, continued from bottom"), // FSTopReached TEXT("Reached top of page, continued from bottom"), // FSTopReached
TEXT("Reached end of page, continued from top")}; // FSEndReached TEXT("Reached end of page, continued from top")}; // FSEndReached
if (nbCounted <= 0) if (nbCounted <= 0)
findCount[0] = '\0'; findCount[0] = '\0';
else if (nbCounted == 1) else if (nbCounted == 1)

View File

@ -769,24 +769,31 @@ INT_PTR CALLBACK FunctionListPanel::run_dlgProc(UINT message, WPARAM wParam, LPA
} }
} }
auto hdc = reinterpret_cast<HDC>(wParam);
if (NppDarkMode::isEnabled())
{
if (textFound)
{
return NppDarkMode::onCtlColorSofter(hdc);
}
else // text not found
{
return NppDarkMode::onCtlColorError(hdc);
}
}
if (textFound) if (textFound)
{ {
if (NppDarkMode::isEnabled()) return FALSE;
{
SetTextColor((HDC)wParam, NppDarkMode::getTextColor());
SetBkColor((HDC)wParam, NppDarkMode::getBackgroundColor());
return (LRESULT)NppDarkMode::getBackgroundBrush();
}
else
return FALSE;
} }
// text not found // text not found
// if the text not found modify the background color of the editor // if the text not found modify the background color of the editor
static HBRUSH hBrushBackground = CreateSolidBrush(BCKGRD_COLOR); static HBRUSH hBrushBackground = CreateSolidBrush(BCKGRD_COLOR);
SetTextColor((HDC)wParam, TXT_COLOR); SetTextColor(hdc, TXT_COLOR);
SetBkColor((HDC)wParam, BCKGRD_COLOR); SetBkColor(hdc, BCKGRD_COLOR);
return (LRESULT)hBrushBackground; return reinterpret_cast<LRESULT>(hBrushBackground);
} }
case WM_INITDIALOG : case WM_INITDIALOG :
@ -798,7 +805,7 @@ INT_PTR CALLBACK FunctionListPanel::run_dlgProc(UINT message, WPARAM wParam, LPA
// Create toolbar menu // Create toolbar menu
int style = WS_CHILD | WS_VISIBLE | CCS_ADJUSTABLE | TBSTYLE_AUTOSIZE | TBSTYLE_FLAT | TBSTYLE_LIST | TBSTYLE_TRANSPARENT | BTNS_AUTOSIZE | BTNS_SEP | TBSTYLE_TOOLTIPS; int style = WS_CHILD | WS_VISIBLE | CCS_ADJUSTABLE | TBSTYLE_AUTOSIZE | TBSTYLE_FLAT | TBSTYLE_LIST | TBSTYLE_TRANSPARENT | BTNS_AUTOSIZE | BTNS_SEP | TBSTYLE_TOOLTIPS;
_hToolbarMenu = CreateWindowEx(0,TOOLBARCLASSNAME,NULL, style, _hToolbarMenu = CreateWindowEx(0,TOOLBARCLASSNAME,NULL, style,
0,0,0,0,_hSelf,nullptr, _hInst, NULL); 0,0,0,0,_hSelf,nullptr, _hInst, NULL);
NppDarkMode::setDarkTooltips(_hToolbarMenu, NppDarkMode::ToolTipsType::toolbar); NppDarkMode::setDarkTooltips(_hToolbarMenu, NppDarkMode::ToolTipsType::toolbar);
NppDarkMode::setDarkLineAbovePanelToolbar(_hToolbarMenu); NppDarkMode::setDarkLineAbovePanelToolbar(_hToolbarMenu);
@ -845,9 +852,9 @@ INT_PTR CALLBACK FunctionListPanel::run_dlgProc(UINT message, WPARAM wParam, LPA
_reloadTipStr = pNativeSpeaker->getAttrNameStr(_reloadTipStr.c_str(), FL_FUCTIONLISTROOTNODE, FL_RELOADLOCALNODENAME); _reloadTipStr = pNativeSpeaker->getAttrNameStr(_reloadTipStr.c_str(), FL_FUCTIONLISTROOTNODE, FL_RELOADLOCALNODENAME);
_hSearchEdit = CreateWindowEx(0, L"Edit", NULL, _hSearchEdit = CreateWindowEx(0, L"Edit", NULL,
WS_CHILD | WS_BORDER | WS_VISIBLE | ES_AUTOVSCROLL, WS_CHILD | WS_BORDER | WS_VISIBLE | ES_AUTOVSCROLL,
2, 2, editWidth, editHeight, 2, 2, editWidth, editHeight,
_hToolbarMenu, reinterpret_cast<HMENU>(IDC_SEARCHFIELD_FUNCLIST), _hInst, 0 ); _hToolbarMenu, reinterpret_cast<HMENU>(IDC_SEARCHFIELD_FUNCLIST), _hInst, 0 );
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)));