Fix disabled checkboxes in dark mode

Fix the following issue:
https://community.notepad-plus-plus.org/topic/21228/notepad-v8-release-candidate-2?_=1622335986466

Close #9919
This commit is contained in:
Adam D. Walling 2021-05-28 15:40:28 -04:00 committed by Don HO
parent 46b3e3c7b2
commit ceca91557b
2 changed files with 19 additions and 1 deletions

View File

@ -25,6 +25,7 @@ namespace NppDarkMode
COLORREF text = 0; COLORREF text = 0;
COLORREF darkerText = 0; COLORREF darkerText = 0;
COLORREF disabledText = 0;
COLORREF edge = 0; COLORREF edge = 0;
}; };
@ -62,6 +63,7 @@ namespace NppDarkMode
HEXRGB(0xB00000), // errorBackground HEXRGB(0xB00000), // errorBackground
HEXRGB(0xE0E0E0), // textColor HEXRGB(0xE0E0E0), // textColor
HEXRGB(0xC0C0C0), // darkerTextColor HEXRGB(0xC0C0C0), // darkerTextColor
HEXRGB(0x707070), // disabledTextColor
HEXRGB(0x808080), // edgeColor HEXRGB(0x808080), // edgeColor
}; };
@ -195,6 +197,7 @@ namespace NppDarkMode
COLORREF getErrorBackgroundColor() { return getTheme().colors.errorBackground; } COLORREF getErrorBackgroundColor() { return getTheme().colors.errorBackground; }
COLORREF getTextColor() { return getTheme().colors.text; } COLORREF getTextColor() { return getTheme().colors.text; }
COLORREF getDarkerTextColor() { return getTheme().colors.darkerText; } COLORREF getDarkerTextColor() { return getTheme().colors.darkerText; }
COLORREF getDisabledTextColor() { return getTheme().colors.disabledText; }
COLORREF getEdgeColor() { return getTheme().colors.edge; } COLORREF getEdgeColor() { return getTheme().colors.edge; }
HBRUSH getBackgroundBrush() { return getTheme().brushes.background; } HBRUSH getBackgroundBrush() { return getTheme().brushes.background; }
@ -465,6 +468,11 @@ namespace NppDarkMode
DTTOPTS dtto = { sizeof(DTTOPTS), DTT_TEXTCOLOR }; DTTOPTS dtto = { sizeof(DTTOPTS), DTT_TEXTCOLOR };
dtto.crText = NppDarkMode::getTextColor(); dtto.crText = NppDarkMode::getTextColor();
if (nStyle & WS_DISABLED)
{
dtto.crText = NppDarkMode::getDisabledTextColor();
}
DrawThemeTextEx(hTheme, hdc, iPartID, iStateID, szText, -1, dtFlags, &rcText, &dtto); DrawThemeTextEx(hTheme, hdc, iPartID, iStateID, szText, -1, dtFlags, &rcText, &dtto);
if ((nState & BST_FOCUS) && !(uiState & UISF_HIDEFOCUS)) if ((nState & BST_FOCUS) && !(uiState & UISF_HIDEFOCUS))
@ -620,6 +628,15 @@ namespace NppDarkMode
case WM_DESTROY: case WM_DESTROY:
BufferedPaintStopAllAnimations(hWnd); BufferedPaintStopAllAnimations(hWnd);
break; break;
case WM_ENABLE:
if (NppDarkMode::isEnabled())
{
// skip the button's normal wndproc so it won't redraw out of wm_paint
LRESULT lr = DefWindowProc(hWnd, uMsg, wParam, lParam);
InvalidateRect(hWnd, nullptr, FALSE);
return lr;
}
break;
} }
return DefSubclassProc(hWnd, uMsg, wParam, lParam); return DefSubclassProc(hWnd, uMsg, wParam, lParam);
} }

View File

@ -40,6 +40,7 @@ namespace NppDarkMode
COLORREF getTextColor(); COLORREF getTextColor();
COLORREF getDarkerTextColor(); COLORREF getDarkerTextColor();
COLORREF getDisabledTextColor();
COLORREF getEdgeColor(); COLORREF getEdgeColor();
HBRUSH getBackgroundBrush(); HBRUSH getBackgroundBrush();