Fix light mode disabled text color using dark mode customized color

Light mode disabled static text was using customized dark mode disabled static text color, this PR fixes the problem.

Fix #11514, close #11515
This commit is contained in:
ozone10 2022-04-10 12:10:20 +02:00 committed by Don Ho
parent 721f994df8
commit 3afbf0ca14
4 changed files with 163 additions and 172 deletions

View File

@ -117,30 +117,31 @@ intptr_t CALLBACK RegExtDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lPa
}
case WM_CTLCOLORDLG:
case WM_CTLCOLORSTATIC:
{
LRESULT result = FALSE;
if (NppDarkMode::isEnabled())
{
result = NppDarkMode::onCtlColorDarker(reinterpret_cast<HDC>(wParam));
return NppDarkMode::onCtlColorDarker(reinterpret_cast<HDC>(wParam));
}
break;
}
case WM_CTLCOLORSTATIC:
{
auto hdcStatic = reinterpret_cast<HDC>(wParam);
auto dlgCtrlID = ::GetDlgCtrlID(reinterpret_cast<HWND>(lParam));
bool isStaticText = dlgCtrlID == IDC_SUPPORTEDEXTS_STATIC || dlgCtrlID == IDC_REGISTEREDEXTS_STATIC;
//set the static text colors to show enable/disable instead of ::EnableWindow which causes blurry text
if (
(HWND)lParam == ::GetDlgItem(_hSelf, IDC_SUPPORTEDEXTS_STATIC) ||
(HWND)lParam == ::GetDlgItem(_hSelf, IDC_REGISTEREDEXTS_STATIC)
)
if (isStaticText)
{
if (nppParam.isAdmin())
{
if (NppDarkMode::isEnabled())
SetTextColor((HDC)wParam, NppDarkMode::getTextColor());
else
SetTextColor((HDC)wParam, RGB(0, 0, 0));
}
else
SetTextColor((HDC)wParam, NppDarkMode::getDisabledTextColor());
return NppDarkMode::onCtlColorDarkerBGStaticText(hdcStatic, nppParam.isAdmin());
}
return result;
if (NppDarkMode::isEnabled())
{
return NppDarkMode::onCtlColorDarker(hdcStatic);
}
return FALSE;
}
case WM_PRINTCLIENT:

View File

@ -61,32 +61,34 @@ intptr_t CALLBACK ColumnEditorDlg::run_dlgProc(UINT message, WPARAM wParam, LPAR
}
case WM_CTLCOLORDLG:
case WM_CTLCOLORSTATIC:
{
LRESULT result = FALSE;
if (NppDarkMode::isEnabled())
{
result = NppDarkMode::onCtlColorDarker(reinterpret_cast<HDC>(wParam));
return NppDarkMode::onCtlColorDarker(reinterpret_cast<HDC>(wParam));
}
break;
}
if (
(HWND)lParam == ::GetDlgItem(_hSelf, IDC_COL_INITNUM_STATIC) ||
(HWND)lParam == ::GetDlgItem(_hSelf, IDC_COL_INCRNUM_STATIC) ||
(HWND)lParam == ::GetDlgItem(_hSelf, IDC_COL_REPEATNUM_STATIC)
)
case WM_CTLCOLORSTATIC:
{
auto hdcStatic = reinterpret_cast<HDC>(wParam);
auto dlgCtrlID = ::GetDlgCtrlID(reinterpret_cast<HWND>(lParam));
bool isStaticText = (dlgCtrlID == IDC_COL_INITNUM_STATIC ||
dlgCtrlID == IDC_COL_INCRNUM_STATIC ||
dlgCtrlID == IDC_COL_REPEATNUM_STATIC);
//set the static text colors to show enable/disable instead of ::EnableWindow which causes blurry text
if (isStaticText)
{
if (BST_CHECKED == ::SendDlgItemMessage(_hSelf, IDC_COL_NUM_RADIO, BM_GETCHECK, 0, 0))
{
if (NppDarkMode::isEnabled())
SetTextColor((HDC)wParam, NppDarkMode::getTextColor());
else
SetTextColor((HDC)wParam, RGB(0, 0, 0));
}
else
SetTextColor((HDC)wParam, NppDarkMode::getDisabledTextColor());
bool isTextEnabled = isCheckedOrNot(IDC_COL_NUM_RADIO);
return NppDarkMode::onCtlColorDarkerBGStaticText(hdcStatic, isTextEnabled);
}
return result;
if (NppDarkMode::isEnabled())
{
return NppDarkMode::onCtlColorDarker(hdcStatic);
}
return FALSE;
}
case WM_PRINTCLIENT:

View File

@ -192,73 +192,54 @@ intptr_t CALLBACK WordStyleDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM
case WM_CTLCOLORSTATIC:
{
LRESULT result = FALSE;
if (NppDarkMode::isEnabled())
{
HWND hwnd = reinterpret_cast<HWND>(lParam);
if (hwnd == ::GetDlgItem(_hSelf, IDC_DEF_EXT_EDIT) || hwnd == ::GetDlgItem(_hSelf, IDC_DEF_KEYWORDS_EDIT))
{
result = NppDarkMode::onCtlColor(reinterpret_cast<HDC>(wParam));
}
else
{
result = NppDarkMode::onCtlColorDarker(reinterpret_cast<HDC>(wParam));
}
}
auto hdcStatic = reinterpret_cast<HDC>(wParam);
auto dlgCtrlID = ::GetDlgCtrlID(reinterpret_cast<HWND>(lParam));
if (
(HWND)lParam == ::GetDlgItem(_hSelf, IDC_FG_STATIC) ||
(HWND)lParam == ::GetDlgItem(_hSelf, IDC_BG_STATIC) ||
(HWND)lParam == ::GetDlgItem(_hSelf, IDC_FONTNAME_STATIC) ||
(HWND)lParam == ::GetDlgItem(_hSelf, IDC_FONTSIZE_STATIC)
)
bool isStaticText = (dlgCtrlID == IDC_FG_STATIC ||
dlgCtrlID == IDC_BG_STATIC ||
dlgCtrlID == IDC_FONTNAME_STATIC ||
dlgCtrlID == IDC_FONTSIZE_STATIC);
//set the static text colors to show enable/disable instead of ::EnableWindow which causes blurry text
if (isStaticText)
{
Style& style = getCurrentStyler();
bool isEnable = false;
bool isTextEnabled = false;
if ((HWND)lParam == ::GetDlgItem(_hSelf, IDC_FG_STATIC))
if (dlgCtrlID == IDC_FG_STATIC)
{
if (HIBYTE(HIWORD(style._fgColor)) != 0xFF)
isEnable = true;
isTextEnabled = HIBYTE(HIWORD(style._fgColor)) != 0xFF;
// Selected text colour style
if (style._styleDesc == TEXT("Selected text colour"))
{
isEnable = false; // disable by default for "Selected text colour" style
if (NppParameters::getInstance().isSelectFgColorEnabled())
isEnable = true;
isTextEnabled = NppParameters::getInstance().isSelectFgColorEnabled();
}
}
else if ((HWND)lParam == ::GetDlgItem(_hSelf, IDC_BG_STATIC))
else if (dlgCtrlID == IDC_BG_STATIC)
{
if (HIBYTE(HIWORD(style._bgColor)) != 0xFF)
isEnable = true;
isTextEnabled = HIBYTE(HIWORD(style._bgColor)) != 0xFF;
}
else if ((HWND)lParam == ::GetDlgItem(_hSelf, IDC_FONTNAME_STATIC))
else if (dlgCtrlID == IDC_FONTNAME_STATIC)
{
if (!style._fontName.empty())
isEnable = true;
isTextEnabled = !style._fontName.empty();
}
else if ((HWND)lParam == ::GetDlgItem(_hSelf, IDC_FONTSIZE_STATIC))
else if (dlgCtrlID == IDC_FONTSIZE_STATIC)
{
if (style._fontSize != STYLE_NOT_USED && style._fontSize < 100) // style._fontSize has only 2 digits
isEnable = true;
isTextEnabled = style._fontSize != STYLE_NOT_USED && style._fontSize < 100; // style._fontSize has only 2 digits
}
if (isEnable)
{
if (NppDarkMode::isEnabled())
SetTextColor((HDC)wParam, NppDarkMode::getTextColor());
else
SetTextColor((HDC)wParam, RGB(0, 0, 0));
}
else
SetTextColor((HDC)wParam, NppDarkMode::getDisabledTextColor());
return NppDarkMode::onCtlColorDarkerBGStaticText(hdcStatic, isTextEnabled);
}
return result;
if (NppDarkMode::isEnabled())
{
if (dlgCtrlID == IDC_DEF_EXT_EDIT || dlgCtrlID == IDC_DEF_KEYWORDS_EDIT)
{
return NppDarkMode::onCtlColor(hdcStatic);
}
return NppDarkMode::onCtlColorDarker(hdcStatic);
}
return FALSE;
}
case WM_PRINTCLIENT:

View File

@ -1024,40 +1024,41 @@ intptr_t CALLBACK DarkModeSubDlg::run_dlgProc(UINT message, WPARAM wParam, LPARA
}
case WM_CTLCOLORDLG:
case WM_CTLCOLORSTATIC:
{
LRESULT result = FALSE;
if (NppDarkMode::isEnabled())
{
result = NppDarkMode::onCtlColorDarker(reinterpret_cast<HDC>(wParam));
return NppDarkMode::onCtlColorDarker(reinterpret_cast<HDC>(wParam));
}
break;
}
case WM_CTLCOLORSTATIC:
{
auto hdcStatic = reinterpret_cast<HDC>(wParam);
auto dlgCtrlID = ::GetDlgCtrlID(reinterpret_cast<HWND>(lParam));
bool isStaticText = (dlgCtrlID == IDD_CUSTOMIZED_COLOR1_STATIC ||
dlgCtrlID == IDD_CUSTOMIZED_COLOR2_STATIC ||
dlgCtrlID == IDD_CUSTOMIZED_COLOR3_STATIC ||
dlgCtrlID == IDD_CUSTOMIZED_COLOR4_STATIC ||
dlgCtrlID == IDD_CUSTOMIZED_COLOR5_STATIC ||
dlgCtrlID == IDD_CUSTOMIZED_COLOR6_STATIC ||
dlgCtrlID == IDD_CUSTOMIZED_COLOR7_STATIC ||
dlgCtrlID == IDD_CUSTOMIZED_COLOR8_STATIC ||
dlgCtrlID == IDD_CUSTOMIZED_COLOR9_STATIC ||
dlgCtrlID == IDD_CUSTOMIZED_COLOR10_STATIC);
//set the static text colors to show enable/disable instead of ::EnableWindow which causes blurry text
if (
(HWND)lParam == ::GetDlgItem(_hSelf, IDD_CUSTOMIZED_COLOR1_STATIC) ||
(HWND)lParam == ::GetDlgItem(_hSelf, IDD_CUSTOMIZED_COLOR2_STATIC) ||
(HWND)lParam == ::GetDlgItem(_hSelf, IDD_CUSTOMIZED_COLOR3_STATIC) ||
(HWND)lParam == ::GetDlgItem(_hSelf, IDD_CUSTOMIZED_COLOR4_STATIC) ||
(HWND)lParam == ::GetDlgItem(_hSelf, IDD_CUSTOMIZED_COLOR5_STATIC) ||
(HWND)lParam == ::GetDlgItem(_hSelf, IDD_CUSTOMIZED_COLOR6_STATIC) ||
(HWND)lParam == ::GetDlgItem(_hSelf, IDD_CUSTOMIZED_COLOR7_STATIC) ||
(HWND)lParam == ::GetDlgItem(_hSelf, IDD_CUSTOMIZED_COLOR8_STATIC) ||
(HWND)lParam == ::GetDlgItem(_hSelf, IDD_CUSTOMIZED_COLOR9_STATIC) ||
(HWND)lParam == ::GetDlgItem(_hSelf, IDD_CUSTOMIZED_COLOR10_STATIC)
)
if (isStaticText)
{
if (nppGUI._darkmode._isEnabled && nppGUI._darkmode._colorTone == NppDarkMode::customizedTone)
{
if (NppDarkMode::isEnabled())
SetTextColor((HDC)wParam, NppDarkMode::getTextColor());
else
SetTextColor((HDC)wParam, RGB(0, 0, 0));
}
else
SetTextColor((HDC)wParam, NppDarkMode::getDisabledTextColor());
bool isTextEnabled = nppGUI._darkmode._isEnabled && nppGUI._darkmode._colorTone == NppDarkMode::customizedTone;
return NppDarkMode::onCtlColorDarkerBGStaticText(hdcStatic, isTextEnabled);
}
return result;
if (NppDarkMode::isEnabled())
{
return NppDarkMode::onCtlColorDarker(hdcStatic);
}
return FALSE;
}
case WM_PRINTCLIENT:
@ -3389,52 +3390,44 @@ intptr_t CALLBACK BackupSubDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM
}
case WM_CTLCOLORDLG:
case WM_CTLCOLORSTATIC:
{
LRESULT result = false;
if (NppDarkMode::isEnabled())
{
auto dlgCtrlID = ::GetDlgCtrlID(reinterpret_cast<HWND>(lParam));
return NppDarkMode::onCtlColorDarker(reinterpret_cast<HDC>(wParam));
}
break;
}
case WM_CTLCOLORSTATIC:
{
auto hdcStatic = reinterpret_cast<HDC>(wParam);
auto dlgCtrlID = ::GetDlgCtrlID(reinterpret_cast<HWND>(lParam));
bool isStaticText = (dlgCtrlID == IDD_BACKUPDIR_RESTORESESSION_STATIC1 ||
dlgCtrlID == IDD_BACKUPDIR_RESTORESESSION_STATIC2 ||
dlgCtrlID == IDD_BACKUPDIR_RESTORESESSION_PATHLABEL_STATIC);
//set the static text colors to show enable/disable instead of ::EnableWindow which causes blurry text
if (isStaticText)
{
bool isTextEnabled = isCheckedOrNot(IDC_BACKUPDIR_RESTORESESSION_CHECK);
return NppDarkMode::onCtlColorDarkerBGStaticText(hdcStatic, isTextEnabled);
}
if (dlgCtrlID == IDD_BACKUPDIR_STATIC)
{
bool isTextEnabled = !isCheckedOrNot(IDC_RADIO_BKNONE) && isCheckedOrNot(IDC_BACKUPDIR_CHECK);
return NppDarkMode::onCtlColorDarkerBGStaticText(hdcStatic, isTextEnabled);
}
if (NppDarkMode::isEnabled())
{
if (dlgCtrlID == IDD_BACKUPDIR_RESTORESESSION_PATH_EDIT)
{
result = NppDarkMode::onCtlColor(reinterpret_cast<HDC>(wParam));
return NppDarkMode::onCtlColor(hdcStatic);
}
result = NppDarkMode::onCtlColorDarker(reinterpret_cast<HDC>(wParam));
return NppDarkMode::onCtlColorDarker(hdcStatic);
}
//set the static text colors to show enable/disable instead of ::EnableWindow which causes blurry text
if ((HWND)lParam == ::GetDlgItem(_hSelf, IDD_BACKUPDIR_STATIC))
{
if (BST_CHECKED != ::SendDlgItemMessage(_hSelf, IDC_RADIO_BKNONE, BM_GETCHECK, 0, 0) &&
BST_CHECKED == ::SendDlgItemMessage(_hSelf, IDC_BACKUPDIR_CHECK, BM_GETCHECK, 0, 0))
{
if (NppDarkMode::isEnabled())
SetTextColor((HDC)wParam, NppDarkMode::getTextColor());
else
SetTextColor((HDC)wParam, RGB(0, 0, 0));
}
else
SetTextColor((HDC)wParam, NppDarkMode::getDisabledTextColor());
}
else if (
(HWND)lParam == ::GetDlgItem(_hSelf, IDD_BACKUPDIR_RESTORESESSION_STATIC1) ||
(HWND)lParam == ::GetDlgItem(_hSelf, IDD_BACKUPDIR_RESTORESESSION_STATIC2) ||
(HWND)lParam == ::GetDlgItem(_hSelf, IDD_BACKUPDIR_RESTORESESSION_PATHLABEL_STATIC)
)
{
if (isCheckedOrNot(IDC_BACKUPDIR_RESTORESESSION_CHECK))
{
if (NppDarkMode::isEnabled())
SetTextColor((HDC)wParam, NppDarkMode::getTextColor());
else
SetTextColor((HDC)wParam, RGB(0, 0, 0));
}
else
SetTextColor((HDC)wParam, NppDarkMode::getDisabledTextColor());
}
return result;
return FALSE;
}
case WM_PRINTCLIENT:
@ -3716,36 +3709,36 @@ intptr_t CALLBACK AutoCompletionSubDlg::run_dlgProc(UINT message, WPARAM wParam,
}
case WM_CTLCOLORDLG:
case WM_CTLCOLORSTATIC:
{
LRESULT result = FALSE;
if (NppDarkMode::isEnabled())
{
result = NppDarkMode::onCtlColorDarker(reinterpret_cast<HDC>(wParam));
return NppDarkMode::onCtlColorDarker(reinterpret_cast<HDC>(wParam));
}
//set the static text colors to show enable/disable instead of ::EnableWindow which causes blurry text
if (
(HWND)lParam == ::GetDlgItem(_hSelf, IDD_AUTOC_STATIC_FROM) ||
(HWND)lParam == ::GetDlgItem(_hSelf, IDD_AUTOC_STATIC_CHAR) ||
(HWND)lParam == ::GetDlgItem(_hSelf, IDD_AUTOC_STATIC_NOTE)
)
{
if (BST_CHECKED == ::SendDlgItemMessage(_hSelf, IDD_AUTOC_ENABLECHECK, BM_GETCHECK, 0, 0))
{
if (NppDarkMode::isEnabled())
SetTextColor((HDC)wParam, NppDarkMode::getTextColor());
else
SetTextColor((HDC)wParam, RGB(0, 0, 0));
break;
}
_nbCharVal.display(true);
}
else
{
SetTextColor((HDC)wParam, NppDarkMode::getDisabledTextColor());
_nbCharVal.display(false);
}
case WM_CTLCOLORSTATIC:
{
auto hdcStatic = reinterpret_cast<HDC>(wParam);
auto dlgCtrlID = ::GetDlgCtrlID(reinterpret_cast<HWND>(lParam));
bool isStaticText = (dlgCtrlID == IDD_AUTOC_STATIC_FROM ||
dlgCtrlID == IDD_AUTOC_STATIC_CHAR ||
dlgCtrlID == IDD_AUTOC_STATIC_NOTE);
//set the static text colors to show enable/disable instead of ::EnableWindow which causes blurry text
if (isStaticText)
{
bool isTextEnabled = isCheckedOrNot(IDD_AUTOC_ENABLECHECK);
auto result = NppDarkMode::onCtlColorDarkerBGStaticText(hdcStatic, isTextEnabled);
_nbCharVal.display(isTextEnabled);
return result;
}
return result;
if (NppDarkMode::isEnabled())
{
return NppDarkMode::onCtlColorDarker(hdcStatic);
}
return FALSE;
}
case WM_PRINTCLIENT:
@ -4505,8 +4498,22 @@ intptr_t CALLBACK CloudAndLinkSubDlg::run_dlgProc(UINT message, WPARAM wParam, L
case WM_CTLCOLORSTATIC:
{
bool isTextEnabled = isCheckedOrNot(IDC_CHECK_CLICKABLELINK_ENABLE) && ::GetDlgCtrlID(reinterpret_cast<HWND>(lParam)) == IDC_URISCHEMES_STATIC;
return NppDarkMode::onCtlColorDarkerBGStaticText(reinterpret_cast<HDC>(wParam), isTextEnabled);
auto hdcStatic = reinterpret_cast<HDC>(wParam);
auto dlgCtrlID = ::GetDlgCtrlID(reinterpret_cast<HWND>(lParam));
bool isStaticText = dlgCtrlID == IDC_URISCHEMES_STATIC;
//set the static text colors to show enable/disable instead of ::EnableWindow which causes blurry text
if (isStaticText)
{
bool isTextEnabled = isCheckedOrNot(IDC_CHECK_CLICKABLELINK_ENABLE);
return NppDarkMode::onCtlColorDarkerBGStaticText(hdcStatic, isTextEnabled);
}
if (NppDarkMode::isEnabled())
{
return NppDarkMode::onCtlColorDarker(hdcStatic);
}
return FALSE;
}
case WM_PRINTCLIENT: