From 6086e819fd5ba90995d49829af4404e1093e80a0 Mon Sep 17 00:00:00 2001 From: Ashfaaq18 Date: Sat, 19 Mar 2022 01:31:49 +0530 Subject: [PATCH] Fix dark mode disabled static text color in Column Editor and Style configurator Fix #11407, close #11409 --- .../src/ScintillaComponent/columnEditor.cpp | 30 ++++++-- .../WinControls/ColourPicker/WordStyleDlg.cpp | 74 +++++++++++++++++-- .../WinControls/ColourPicker/WordStyleDlg.h | 20 ----- 3 files changed, 90 insertions(+), 34 deletions(-) diff --git a/PowerEditor/src/ScintillaComponent/columnEditor.cpp b/PowerEditor/src/ScintillaComponent/columnEditor.cpp index c1ec83095..75322d5c4 100644 --- a/PowerEditor/src/ScintillaComponent/columnEditor.cpp +++ b/PowerEditor/src/ScintillaComponent/columnEditor.cpp @@ -36,7 +36,7 @@ void ColumnEditorDlg::display(bool toShow) const ::SetFocus(::GetDlgItem(_hSelf, ID_GOLINE_EDIT)); } -intptr_t CALLBACK ColumnEditorDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM) +intptr_t CALLBACK ColumnEditorDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam) { switch (message) { @@ -63,11 +63,30 @@ intptr_t CALLBACK ColumnEditorDlg::run_dlgProc(UINT message, WPARAM wParam, LPAR case WM_CTLCOLORDLG: case WM_CTLCOLORSTATIC: { + LRESULT result = FALSE; if (NppDarkMode::isEnabled()) { - return NppDarkMode::onCtlColorDarker(reinterpret_cast(wParam)); + result = NppDarkMode::onCtlColorDarker(reinterpret_cast(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) + ) + { + 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()); + } + + return result; } case WM_PRINTCLIENT: @@ -333,11 +352,8 @@ void ColumnEditorDlg::switchTo(bool toText) HWND hNum = ::GetDlgItem(_hSelf, IDC_COL_INITNUM_EDIT); ::SendDlgItemMessage(_hSelf, IDC_COL_NUM_RADIO, BM_SETCHECK, !toText, 0); - ::EnableWindow(::GetDlgItem(_hSelf, IDC_COL_INITNUM_STATIC), !toText); ::EnableWindow(hNum, !toText); - ::EnableWindow(::GetDlgItem(_hSelf, IDC_COL_INCRNUM_STATIC), !toText); ::EnableWindow(::GetDlgItem(_hSelf, IDC_COL_INCREASENUM_EDIT), !toText); - ::EnableWindow(::GetDlgItem(_hSelf, IDC_COL_REPEATNUM_STATIC), !toText); ::EnableWindow(::GetDlgItem(_hSelf, IDC_COL_REPEATNUM_EDIT), !toText); ::EnableWindow(::GetDlgItem(_hSelf, IDC_COL_DEC_RADIO), !toText); ::EnableWindow(::GetDlgItem(_hSelf, IDC_COL_HEX_RADIO), !toText); @@ -346,6 +362,8 @@ void ColumnEditorDlg::switchTo(bool toText) ::EnableWindow(::GetDlgItem(_hSelf, IDC_COL_LEADZERO_CHECK), !toText); ::SetFocus(toText?hText:hNum); + + redraw(); } UCHAR ColumnEditorDlg::getFormat() diff --git a/PowerEditor/src/WinControls/ColourPicker/WordStyleDlg.cpp b/PowerEditor/src/WinControls/ColourPicker/WordStyleDlg.cpp index 57e82fe61..0a24bdbab 100644 --- a/PowerEditor/src/WinControls/ColourPicker/WordStyleDlg.cpp +++ b/PowerEditor/src/WinControls/ColourPicker/WordStyleDlg.cpp @@ -192,19 +192,73 @@ intptr_t CALLBACK WordStyleDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM case WM_CTLCOLORSTATIC: { + LRESULT result = FALSE; if (NppDarkMode::isEnabled()) { HWND hwnd = reinterpret_cast(lParam); if (hwnd == ::GetDlgItem(_hSelf, IDC_DEF_EXT_EDIT) || hwnd == ::GetDlgItem(_hSelf, IDC_DEF_KEYWORDS_EDIT)) { - return NppDarkMode::onCtlColor(reinterpret_cast(wParam)); + result = NppDarkMode::onCtlColor(reinterpret_cast(wParam)); } else { - return NppDarkMode::onCtlColorDarker(reinterpret_cast(wParam)); + result = NppDarkMode::onCtlColorDarker(reinterpret_cast(wParam)); } } - break; + + + 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) + ) + { + Style& style = getCurrentStyler(); + bool isEnable = false; + + if ((HWND)lParam == ::GetDlgItem(_hSelf, IDC_FG_STATIC)) + { + if (HIBYTE(HIWORD(style._fgColor)) != 0xFF) + isEnable = true; + + // 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; + } + } + else if ((HWND)lParam == ::GetDlgItem(_hSelf, IDC_BG_STATIC)) + { + if (HIBYTE(HIWORD(style._bgColor)) != 0xFF) + isEnable = true; + } + else if ((HWND)lParam == ::GetDlgItem(_hSelf, IDC_FONTNAME_STATIC)) + { + if (!style._fontName.empty()) + isEnable = true; + } + else if ((HWND)lParam == ::GetDlgItem(_hSelf, IDC_FONTSIZE_STATIC)) + { + if (style._fontSize != STYLE_NOT_USED && style._fontSize < 100) // style._fontSize has only 2 digits + isEnable = true; + } + + 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 result; } case WM_PRINTCLIENT: @@ -883,7 +937,8 @@ void WordStyleDlg::setVisualFromStyleList() if (NppParameters::getInstance().isSelectFgColorEnabled()) isEnable = true; } - enableFg(isEnable); + ::EnableWindow(_pFgColour->getHSelf(), isEnable); + InvalidateRect(_hFgColourStaticText, NULL, FALSE); isEnable = false; if (HIBYTE(HIWORD(style._bgColor)) != 0xFF) @@ -892,7 +947,8 @@ void WordStyleDlg::setVisualFromStyleList() _pBgColour->setEnabled((style._colorStyle & COLORSTYLE_BACKGROUND) != 0); isEnable = true; } - enableBg(isEnable); + ::EnableWindow(_pBgColour->getHSelf(), isEnable); + InvalidateRect(_hBgColourStaticText, NULL, FALSE); //-- font name isEnable = false; @@ -909,7 +965,8 @@ void WordStyleDlg::setVisualFromStyleList() iFontName = 0; } ::SendMessage(_hFontNameCombo, CB_SETCURSEL, iFontName, 0); - enableFontName(isEnable); + ::EnableWindow(_hFontNameCombo, isEnable); + InvalidateRect(_hFontNameStaticText, NULL, FALSE); //-- font size isEnable = false; @@ -923,8 +980,9 @@ void WordStyleDlg::setVisualFromStyleList() isEnable = true; } ::SendMessage(_hFontSizeCombo, CB_SETCURSEL, iFontSize, 0); - enableFontSize(isEnable); - + ::EnableWindow(_hFontSizeCombo, isEnable); + InvalidateRect(_hFontSizeStaticText, NULL, FALSE); + //-- font style : bold & italic isEnable = false; if (style._fontStyle != STYLE_NOT_USED) diff --git a/PowerEditor/src/WinControls/ColourPicker/WordStyleDlg.h b/PowerEditor/src/WinControls/ColourPicker/WordStyleDlg.h index e3b9caf89..fdfe9569f 100644 --- a/PowerEditor/src/WinControls/ColourPicker/WordStyleDlg.h +++ b/PowerEditor/src/WinControls/ColourPicker/WordStyleDlg.h @@ -177,26 +177,6 @@ private : void loadLangListFromNppParam(); - void enableFg(bool isEnable) { - ::EnableWindow(_pFgColour->getHSelf(), isEnable); - ::EnableWindow(_hFgColourStaticText, isEnable); - }; - - void enableBg(bool isEnable) { - ::EnableWindow(_pBgColour->getHSelf(), isEnable); - ::EnableWindow(_hBgColourStaticText, isEnable); - }; - - void enableFontName(bool isEnable) { - ::EnableWindow(_hFontNameCombo, isEnable); - ::EnableWindow(_hFontNameStaticText, isEnable); - }; - - void enableFontSize(bool isEnable) { - ::EnableWindow(_hFontSizeCombo, isEnable); - ::EnableWindow(_hFontSizeStaticText, isEnable); - }; - void enableFontStyle(bool isEnable) { ::EnableWindow(_hCheckBold, isEnable); ::EnableWindow(_hCheckItalic, isEnable);