Add dark mode to new column editor feature

Fix #13467, close #13468
This commit is contained in:
ozone10 2023-04-02 14:47:11 +02:00 committed by Don Ho
parent 0dff45568b
commit 810ceacb49
2 changed files with 15 additions and 9 deletions

View File

@ -1766,6 +1766,8 @@ namespace NppDarkMode
bool hasFocus = false;
const bool isWindowEnabled = ::IsWindowEnabled(hWnd) == TRUE;
// CBS_DROPDOWN text is handled by parent by WM_CTLCOLOREDIT
auto style = ::GetWindowLongPtr(hWnd, GWL_STYLE);
if ((style & CBS_DROPDOWNLIST) == CBS_DROPDOWNLIST)
@ -1792,7 +1794,7 @@ namespace NppDarkMode
auto index = static_cast<int>(::SendMessage(hWnd, CB_GETCURSEL, 0, 0));
if (index != CB_ERR)
{
::SetTextColor(hdc, NppDarkMode::getTextColor());
::SetTextColor(hdc, isWindowEnabled ? NppDarkMode::getTextColor() : NppDarkMode::getDisabledTextColor());
::SetBkColor(hdc, NppDarkMode::getBackgroundColor());
auto bufferLen = static_cast<size_t>(::SendMessage(hWnd, CB_GETLBTEXTLEN, index, 0));
TCHAR* buffer = new TCHAR[(bufferLen + 1)];
@ -1822,8 +1824,6 @@ namespace NppDarkMode
bool isHot = ::PtInRect(&rc, ptCursor);
bool isWindowEnabled = ::IsWindowEnabled(hWnd) == TRUE;
auto colorEnabledText = isHot ? NppDarkMode::getTextColor() : NppDarkMode::getDarkerTextColor();
::SetTextColor(hdc, isWindowEnabled ? colorEnabledText : NppDarkMode::getDisabledTextColor());
::SetBkColor(hdc, isHot ? NppDarkMode::getHotBackgroundColor() : NppDarkMode::getBackgroundColor());

View File

@ -88,6 +88,11 @@ intptr_t CALLBACK ColumnEditorDlg::run_dlgProc(UINT message, WPARAM wParam, LPAR
return NppDarkMode::onCtlColorSofter(reinterpret_cast<HDC>(wParam));
}
case WM_CTLCOLORLISTBOX:
{
return NppDarkMode::onCtlColor(reinterpret_cast<HDC>(wParam));
}
case WM_CTLCOLORDLG:
{
return NppDarkMode::onCtlColorDarker(reinterpret_cast<HDC>(wParam));
@ -100,7 +105,8 @@ intptr_t CALLBACK ColumnEditorDlg::run_dlgProc(UINT message, WPARAM wParam, LPAR
bool isStaticText = (dlgCtrlID == IDC_COL_INITNUM_STATIC ||
dlgCtrlID == IDC_COL_INCRNUM_STATIC ||
dlgCtrlID == IDC_COL_REPEATNUM_STATIC);
dlgCtrlID == IDC_COL_REPEATNUM_STATIC ||
dlgCtrlID == IDC_COL_LEADING_STATIC);
//set the static text colors to show enable/disable instead of ::EnableWindow which causes blurry text
if (isStaticText)
{
@ -154,8 +160,8 @@ intptr_t CALLBACK ColumnEditorDlg::run_dlgProc(UINT message, WPARAM wParam, LPAR
{
(*_ppEditView)->execute(SCI_BEGINUNDOACTION);
const int stringSize = 1024;
TCHAR str[stringSize];
constexpr int stringSize = 1024;
TCHAR str[stringSize]{};
bool isTextMode = (BST_CHECKED == ::SendDlgItemMessage(_hSelf, IDC_COL_TEXT_RADIO, BM_GETCHECK, 0, 0));
@ -467,7 +473,6 @@ void ColumnEditorDlg::switchTo(bool toText)
::EnableWindow(::GetDlgItem(_hSelf, IDC_COL_HEX_RADIO), !toText);
::EnableWindow(::GetDlgItem(_hSelf, IDC_COL_OCT_RADIO), !toText);
::EnableWindow(::GetDlgItem(_hSelf, IDC_COL_BIN_RADIO), !toText);
::EnableWindow(::GetDlgItem(_hSelf, IDC_COL_LEADING_STATIC), !toText);
::EnableWindow(::GetDlgItem(_hSelf, IDC_COL_LEADING_COMBO), !toText);
::SetFocus(toText?hText:hNum);
@ -475,6 +480,7 @@ void ColumnEditorDlg::switchTo(bool toText)
redrawDlgItem(IDC_COL_INITNUM_STATIC);
redrawDlgItem(IDC_COL_INCRNUM_STATIC);
redrawDlgItem(IDC_COL_REPEATNUM_STATIC);
redrawDlgItem(IDC_COL_LEADING_STATIC);
if (NppDarkMode::isEnabled())
{
@ -483,7 +489,7 @@ void ColumnEditorDlg::switchTo(bool toText)
}
}
UCHAR ColumnEditorDlg::getFormat()
UCHAR ColumnEditorDlg::getFormat()
{
UCHAR f = 0; // Dec by default
if (BST_CHECKED == ::SendDlgItemMessage(_hSelf, IDC_COL_HEX_RADIO, BM_GETCHECK, 0, 0))
@ -519,4 +525,4 @@ ColumnEditorParam::leadingChoice ColumnEditorDlg::getLeading()
}
}
return leading;
}
}