Apply dark mode on Style Configurator

Create link text color to be used too in about, debug and preference dialog.

Fix #10226, close #10227
This commit is contained in:
ozone10 2021-07-22 18:45:28 +02:00 committed by Don Ho
parent 3e69de4879
commit e627de438b
3 changed files with 74 additions and 4 deletions

View File

@ -93,6 +93,7 @@ namespace NppDarkMode
HEXRGB(0xE0E0E0), // textColor
HEXRGB(0xC0C0C0), // darkerTextColor
HEXRGB(0x808080), // disabledTextColor
HEXRGB(0xFFFF00), // linkTextColor
HEXRGB(0x646464) // edgeColor
};
@ -106,6 +107,7 @@ namespace NppDarkMode
HEXRGB(0xE0E0E0), // textColor
HEXRGB(0xC0C0C0), // darkerTextColor
HEXRGB(0x808080), // disabledTextColor
HEXRGB(0xFFFF00), // linkTextColor
HEXRGB(0x908080) // edgeColor
};
@ -119,6 +121,7 @@ namespace NppDarkMode
HEXRGB(0xE0E0E0), // textColor
HEXRGB(0xC0C0C0), // darkerTextColor
HEXRGB(0x808080), // disabledTextColor
HEXRGB(0xFFFF00), // linkTextColor
HEXRGB(0x809080) // edgeColor
};
@ -132,6 +135,7 @@ namespace NppDarkMode
HEXRGB(0xE0E0E0), // textColor
HEXRGB(0xC0C0C0), // darkerTextColor
HEXRGB(0x808080), // disabledTextColor
HEXRGB(0xFFFF00), // linkTextColor
HEXRGB(0x8080A0) // edgeColor
};
@ -145,6 +149,7 @@ namespace NppDarkMode
HEXRGB(0xE0E0E0), // textColor
HEXRGB(0xC0C0C0), // darkerTextColor
HEXRGB(0x808080), // disabledTextColor
HEXRGB(0xFFFF00), // linkTextColor
HEXRGB(0x9080A0) // edgeColor
};
@ -158,6 +163,7 @@ namespace NppDarkMode
HEXRGB(0xE0E0E0), // textColor
HEXRGB(0xC0C0C0), // darkerTextColor
HEXRGB(0x808080), // disabledTextColor
HEXRGB(0xFFFF00), // linkTextColor
HEXRGB(0x8090A0) // edgeColor
};
@ -171,6 +177,7 @@ namespace NppDarkMode
HEXRGB(0xE0E0E0), // textColor
HEXRGB(0xC0C0C0), // darkerTextColor
HEXRGB(0x808080), // disabledTextColor
HEXRGB(0xFFFF00), // linkTextColor
HEXRGB(0x909080) // edgeColor
};
@ -184,6 +191,7 @@ namespace NppDarkMode
HEXRGB(0xE0E0E0), // textColor
HEXRGB(0xC0C0C0), // darkerTextColor
HEXRGB(0x808080), // disabledTextColor
HEXRGB(0xFFFF00), // linkTextColor
HEXRGB(0x646464) // edgeColor
};
@ -366,6 +374,7 @@ namespace NppDarkMode
COLORREF getTextColor() { return getTheme()._colors.text; }
COLORREF getDarkerTextColor() { return getTheme()._colors.darkerText; }
COLORREF getDisabledTextColor() { return getTheme()._colors.disabledText; }
COLORREF getLinkTextColor() { return getTheme()._colors.linkText; }
COLORREF getEdgeColor() { return getTheme()._colors.edge; }
HBRUSH getBackgroundBrush() { return getTheme()._brushes.background; }
@ -433,6 +442,13 @@ namespace NppDarkMode
getTheme().change(clrs);
}
void setLinkTextColor(COLORREF c)
{
Colors clrs = getTheme()._colors;
clrs.linkText = c;
getTheme().change(clrs);
}
void setEdgeColor(COLORREF c)
{
Colors clrs = getTheme()._colors;
@ -1512,8 +1528,8 @@ namespace NppDarkMode
if (NppDarkMode::isEnabled())
{
scheme.clrBtnHighlight = NppDarkMode::getBackgroundColor();
scheme.clrBtnShadow = NppDarkMode::getBackgroundColor();
scheme.clrBtnHighlight = NppDarkMode::getDarkerBackgroundColor();
scheme.clrBtnShadow = NppDarkMode::getDarkerBackgroundColor();
}
else
{

View File

@ -23,6 +23,7 @@ namespace NppDarkMode
COLORREF text = 0;
COLORREF darkerText = 0;
COLORREF disabledText = 0;
COLORREF linkText = 0;
COLORREF edge = 0;
};
@ -73,6 +74,8 @@ namespace NppDarkMode
COLORREF getTextColor();
COLORREF getDarkerTextColor();
COLORREF getDisabledTextColor();
COLORREF getLinkTextColor();
COLORREF getEdgeColor();
HBRUSH getBackgroundBrush();
@ -92,6 +95,7 @@ namespace NppDarkMode
void setTextColor(COLORREF c);
void setDarkerTextColor(COLORREF c);
void setDisabledTextColor(COLORREF c);
void setLinkTextColor(COLORREF c);
void setEdgeColor(COLORREF c);
Colors getDarkModeDefaultColors();

View File

@ -37,6 +37,11 @@ LRESULT CALLBACK ColourStaticTextHooker::colourStaticProc(HWND hwnd, UINT Messag
::SetTextColor(hdc, _colour);
if (NppDarkMode::isEnabled())
{
::SetBkColor(hdc, NppDarkMode::getDarkerBackgroundColor());
}
// Get the default GUI font
HFONT hf = (HFONT)::GetStockObject(DEFAULT_GUI_FONT);
@ -76,6 +81,8 @@ INT_PTR CALLBACK WordStyleDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM l
{
NppParameters& nppParamInst = NppParameters::getInstance();
NppDarkMode::autoSubclassAndThemeChildControls(_hSelf);
_hCheckBold = ::GetDlgItem(_hSelf, IDC_BOLD_CHECK);
_hCheckItalic = ::GetDlgItem(_hSelf, IDC_ITALIC_CHECK);
_hCheckUnderline = ::GetDlgItem(_hSelf, IDC_UNDERLINE_CHECK);
@ -165,6 +172,49 @@ INT_PTR CALLBACK WordStyleDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM l
return TRUE;
}
case WM_CTLCOLOREDIT:
{
if (NppDarkMode::isEnabled())
{
HWND hwnd = reinterpret_cast<HWND>(lParam);
if (hwnd == ::GetDlgItem(_hSelf, IDC_USER_EXT_EDIT) || hwnd == ::GetDlgItem(_hSelf, IDC_USER_KEYWORDS_EDIT))
{
return NppDarkMode::onCtlColorSofter(reinterpret_cast<HDC>(wParam));
}
else
{
return NppDarkMode::onCtlColor(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 NPPM_INTERNAL_REFRESHDARKMODE:
{
NppDarkMode::autoThemeChildControls(_hSelf);
return TRUE;
}
case WM_DESTROY:
{
_pFgColour->destroy();
@ -452,7 +502,7 @@ INT_PTR CALLBACK WordStyleDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM l
default :
return FALSE;
}
//return FALSE;
return FALSE;
}
void WordStyleDlg::loadLangListFromNppParam()
@ -736,7 +786,7 @@ void WordStyleDlg::setVisualFromStyleList()
//--Warning text
//bool showWarning = ((_currentLexerIndex == 0) && (style._styleID == STYLE_DEFAULT));//?SW_SHOW:SW_HIDE;
COLORREF c = RGB(0x00, 0x00, 0xFF);
COLORREF c = NppDarkMode::isEnabled() ? NppDarkMode::getLinkTextColor() : RGB(0x00, 0x00, 0xFF);
const size_t strLen = 256;
TCHAR str[strLen + 1];