Add dark mode support to ColourPicker/ColourPopup's ChooseColor dialog

Fix #12148, close #12158
pull/12160/head
blu3mania 2022-09-12 17:22:48 -04:00 committed by Don Ho
parent 1646ea6139
commit d03b11ebf8
2 changed files with 61 additions and 1 deletions

View File

@ -223,7 +223,8 @@ intptr_t CALLBACK ColourPopup::run_dlgProc(UINT message, WPARAM wParam, LPARAM l
cc.lpCustColors = (LPDWORD) acrCustClr;
cc.rgbResult = _colour;
cc.Flags = CC_FULLOPEN | CC_RGBINIT;
cc.lpfnHook = chooseColorDlgProc;
cc.Flags = CC_FULLOPEN | CC_RGBINIT | CC_ENABLEHOOK;
display(false);
@ -265,3 +266,61 @@ intptr_t CALLBACK ColourPopup::run_dlgProc(UINT message, WPARAM wParam, LPARAM l
}
return FALSE;
}
uintptr_t CALLBACK ColourPopup::chooseColorDlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM)
{
switch (message)
{
case WM_INITDIALOG:
{
if (NppDarkMode::isExperimentalSupported())
{
NppDarkMode::setDarkTitleBar(hwnd);
}
NppDarkMode::autoSubclassAndThemeChildControls(hwnd);
break;
}
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 = {};
::GetClientRect(hwnd, &rc);
::FillRect(reinterpret_cast<HDC>(wParam), &rc, NppDarkMode::getDarkerBackgroundBrush());
return TRUE;
}
break;
}
}
return FALSE;
}

View File

@ -63,4 +63,5 @@ private :
static intptr_t CALLBACK dlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
intptr_t CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam);
static uintptr_t CALLBACK chooseColorDlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
};