diff --git a/PowerEditor/src/Notepad_plus.cpp b/PowerEditor/src/Notepad_plus.cpp index 1da2c9dc9..b5cbd261d 100644 --- a/PowerEditor/src/Notepad_plus.cpp +++ b/PowerEditor/src/Notepad_plus.cpp @@ -369,7 +369,13 @@ LRESULT Notepad_plus::init(HWND hwnd) drawTabbarColoursFromStylerArray(); // Autocomplete list and calltip - drawAutocompleteColoursFromTheme(); + const Style* pStyle = NppParameters::getInstance().getGlobalStylers().findByID(STYLE_DEFAULT); + if (pStyle) + { + NppParameters::getInstance().setCurrentDefaultFgColor(pStyle->_fgColor); + NppParameters::getInstance().setCurrentDefaultBgColor(pStyle->_bgColor); + drawAutocompleteColoursFromTheme(pStyle->_fgColor, pStyle->_bgColor); + } AutoCompletion::drawAutocomplete(_pEditView); AutoCompletion::drawAutocomplete(_pNonEditView); @@ -5832,40 +5838,33 @@ void Notepad_plus::drawTabbarColoursFromStylerArray() TabBarPlus::setColour(stInact->_bgColor, TabBarPlus::inactiveBg); } -void Notepad_plus::drawAutocompleteColoursFromTheme() +void Notepad_plus::drawAutocompleteColoursFromTheme(COLORREF fgColor, COLORREF bgColor) { - // Update default fg/bg colors in Parameters for both internal/plugins docking dialog - const Style* pStyle = NppParameters::getInstance().getGlobalStylers().findByID(STYLE_DEFAULT); - if (pStyle) - { - NppParameters::getInstance().setCurrentDefaultFgColor(pStyle->_fgColor); - NppParameters::getInstance().setCurrentDefaultBgColor(pStyle->_bgColor); + int rbv = GetRValue(bgColor); + int gbv = GetGValue(bgColor); + int bbv = GetBValue(bgColor); - int rbv = GetRValue(pStyle->_bgColor); - int gbv = GetGValue(pStyle->_bgColor); - int bbv = GetBValue(pStyle->_bgColor); + int rfv = GetRValue(fgColor); + int gfv = GetGValue(fgColor); + int bfv = GetBValue(fgColor); - int rfv = GetRValue(pStyle->_fgColor); - int gfv = GetGValue(pStyle->_fgColor); - int bfv = GetBValue(pStyle->_fgColor); + COLORREF bgDarker = RGB(rbv - 20 <= 0 ? 0 : rbv - 20, gbv - 20 <= 0 ? 0 : gbv - 20, bbv - 20 <= 0 ? 0 : bbv - 20); - COLORREF bgDarker = RGB(rbv - 20 <= 0 ? 0 : rbv - 20, gbv - 20 <= 0 ? 0 : gbv - 20, bbv - 20 <= 0 ? 0 : bbv - 20); + if (bgColor == RGB(0, 0, 0)) // if the bg is pure black + bgDarker = RGB(20, 20, 20); // make bgDarker lighter for distinguishing between both - if (pStyle->_bgColor == RGB(0, 0, 0)) // if the bg is pure black - bgDarker = RGB(20, 20, 20); // make bgDarker lighter for distinguishing between both + COLORREF fgDarker = RGB(rfv - 20 <= 0 ? 0 : rfv - 20, gfv - 20 <= 0 ? 0 : gfv - 20, bfv - 20 <= 0 ? 0 : bfv - 20); + COLORREF fgLigher = RGB(rfv + 20 >= 255 ? 255 : rfv + 20, gfv + 20 >= 255 ? 255 : gfv + 20, bfv + 20 >= 255 ? 255 : bfv + 20); - COLORREF fgDarker = RGB(rfv - 20 <= 0 ? 0 : rfv - 20, gfv - 20 <= 0 ? 0 : gfv - 20, bfv - 20 <= 0 ? 0 : bfv - 20); - COLORREF fgLigher = RGB(rfv + 20 >= 255 ? 255 : rfv + 20, gfv + 20 >= 255 ? 255 : gfv + 20, bfv + 20 >= 255 ? 255 : bfv + 20); + AutoCompletion::setColour(bgDarker, AutoCompletion::AutocompleteColorIndex::autocompleteBg); + AutoCompletion::setColour(bgColor, AutoCompletion::AutocompleteColorIndex::selectedBg); + AutoCompletion::setColour(fgDarker, AutoCompletion::AutocompleteColorIndex::autocompleteText); + AutoCompletion::setColour(fgColor, AutoCompletion::AutocompleteColorIndex::selectedText); - AutoCompletion::setColour(bgDarker, AutoCompletion::AutocompleteColorIndex::autocompleteBg); - AutoCompletion::setColour(pStyle->_bgColor, AutoCompletion::AutocompleteColorIndex::selectedBg); - AutoCompletion::setColour(fgDarker, AutoCompletion::AutocompleteColorIndex::autocompleteText); - AutoCompletion::setColour(pStyle->_fgColor, AutoCompletion::AutocompleteColorIndex::selectedText); - - AutoCompletion::setColour(bgDarker, AutoCompletion::AutocompleteColorIndex::calltipBg); - AutoCompletion::setColour(fgDarker, AutoCompletion::AutocompleteColorIndex::calltipText); - AutoCompletion::setColour(fgLigher, AutoCompletion::AutocompleteColorIndex::calltipHighlight); - } + AutoCompletion::setColour(bgDarker, AutoCompletion::AutocompleteColorIndex::calltipBg); + AutoCompletion::setColour(fgDarker, AutoCompletion::AutocompleteColorIndex::calltipText); + AutoCompletion::setColour(fgLigher, AutoCompletion::AutocompleteColorIndex::calltipHighlight); + } void Notepad_plus::drawDocumentMapColoursFromStylerArray() diff --git a/PowerEditor/src/Notepad_plus.h b/PowerEditor/src/Notepad_plus.h index 3c1557c1c..df5aa4f17 100644 --- a/PowerEditor/src/Notepad_plus.h +++ b/PowerEditor/src/Notepad_plus.h @@ -585,7 +585,7 @@ private: Style * getStyleFromName(const TCHAR *styleName); bool dumpFiles(const TCHAR * outdir, const TCHAR * fileprefix = TEXT("")); //helper func void drawTabbarColoursFromStylerArray(); - void drawAutocompleteColoursFromTheme(); + void drawAutocompleteColoursFromTheme(COLORREF fgColor, COLORREF bgColor); void drawDocumentMapColoursFromStylerArray(); std::vector loadCommandlineParams(const TCHAR * commandLine, const CmdLineParams * pCmdParams) { diff --git a/PowerEditor/src/NppBigSwitch.cpp b/PowerEditor/src/NppBigSwitch.cpp index 75e430dd6..73a7d3cfe 100644 --- a/PowerEditor/src/NppBigSwitch.cpp +++ b/PowerEditor/src/NppBigSwitch.cpp @@ -1869,18 +1869,18 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa drawDocumentMapColoursFromStylerArray(); - drawAutocompleteColoursFromTheme(); - AutoCompletion::drawAutocomplete(_pEditView); - AutoCompletion::drawAutocomplete(_pNonEditView); - // Update default fg/bg colors in Parameters for both internal/plugins docking dialog - const Style * pStyle = NppParameters::getInstance().getGlobalStylers().findByID(STYLE_DEFAULT); + const Style* pStyle = NppParameters::getInstance().getGlobalStylers().findByID(STYLE_DEFAULT); if (pStyle) { NppParameters::getInstance().setCurrentDefaultFgColor(pStyle->_fgColor); NppParameters::getInstance().setCurrentDefaultBgColor(pStyle->_bgColor); + drawAutocompleteColoursFromTheme(pStyle->_fgColor, pStyle->_bgColor); } + AutoCompletion::drawAutocomplete(_pEditView); + AutoCompletion::drawAutocomplete(_pNonEditView); + NppDarkMode::calculateTreeViewStyle(); auto refreshOnlyTreeView = static_cast(TRUE); diff --git a/PowerEditor/src/NppDarkMode.cpp b/PowerEditor/src/NppDarkMode.cpp index b93ccb1b1..982f607da 100644 --- a/PowerEditor/src/NppDarkMode.cpp +++ b/PowerEditor/src/NppDarkMode.cpp @@ -1698,7 +1698,7 @@ namespace NppDarkMode } } - BOOL getAutocompleHandleProc(HWND hwnd, LPARAM /*lParam*/) + BOOL CALLBACK enumAutocompleteProc(HWND hwnd, LPARAM /*lParam*/) { constexpr size_t classNameLen = 16; TCHAR className[classNameLen]{}; @@ -1707,7 +1707,7 @@ namespace NppDarkMode (wcscmp(className, WC_LISTBOX) == 0)) { NppDarkMode::setDarkScrollBar(hwnd); - ::EnumChildWindows(hwnd, (WNDENUMPROC)getAutocompleHandleProc, 0); + ::EnumChildWindows(hwnd, (WNDENUMPROC)enumAutocompleteProc, 0); } return TRUE; @@ -1716,11 +1716,16 @@ namespace NppDarkMode // set dark scrollbar for autocomplete list void setDarkAutoCompletion() { - ::EnumThreadWindows(::GetCurrentThreadId(), (WNDENUMPROC)getAutocompleHandleProc, 0); + ::EnumThreadWindows(::GetCurrentThreadId(), (WNDENUMPROC)enumAutocompleteProc, 0); } LRESULT onCtlColor(HDC hdc) { + if (!NppDarkMode::isEnabled()) + { + return FALSE; + } + ::SetTextColor(hdc, NppDarkMode::getTextColor()); ::SetBkColor(hdc, NppDarkMode::getBackgroundColor()); return reinterpret_cast(NppDarkMode::getBackgroundBrush()); @@ -1728,6 +1733,11 @@ namespace NppDarkMode LRESULT onCtlColorSofter(HDC hdc) { + if (!NppDarkMode::isEnabled()) + { + return FALSE; + } + ::SetTextColor(hdc, NppDarkMode::getTextColor()); ::SetBkColor(hdc, NppDarkMode::getSofterBackgroundColor()); return reinterpret_cast(NppDarkMode::getSofterBackgroundBrush()); @@ -1735,6 +1745,11 @@ namespace NppDarkMode LRESULT onCtlColorDarker(HDC hdc) { + if (!NppDarkMode::isEnabled()) + { + return FALSE; + } + ::SetTextColor(hdc, NppDarkMode::getTextColor()); ::SetBkColor(hdc, NppDarkMode::getDarkerBackgroundColor()); return reinterpret_cast(NppDarkMode::getDarkerBackgroundBrush()); @@ -1742,6 +1757,11 @@ namespace NppDarkMode LRESULT onCtlColorError(HDC hdc) { + if (!NppDarkMode::isEnabled()) + { + return FALSE; + } + ::SetTextColor(hdc, NppDarkMode::getTextColor()); ::SetBkColor(hdc, NppDarkMode::getErrorBackgroundColor()); return reinterpret_cast(NppDarkMode::getErrorBackgroundBrush()); @@ -1749,19 +1769,14 @@ namespace NppDarkMode LRESULT onCtlColorDarkerBGStaticText(HDC hdc, bool isTextEnabled) { - LRESULT result = FALSE; - - if (NppDarkMode::isEnabled()) - { - ::SetTextColor(hdc, isTextEnabled ? NppDarkMode::getTextColor() : NppDarkMode::getDisabledTextColor()); - ::SetBkColor(hdc, NppDarkMode::getDarkerBackgroundColor()); - result = reinterpret_cast(NppDarkMode::getDarkerBackgroundBrush()); - } - else + if (!NppDarkMode::isEnabled()) { ::SetTextColor(hdc, ::GetSysColor(isTextEnabled ? COLOR_WINDOWTEXT : COLOR_GRAYTEXT)); + return FALSE; } - return result; + ::SetTextColor(hdc, isTextEnabled ? NppDarkMode::getTextColor() : NppDarkMode::getDisabledTextColor()); + ::SetBkColor(hdc, NppDarkMode::getDarkerBackgroundColor()); + return reinterpret_cast(NppDarkMode::getDarkerBackgroundBrush()); } } diff --git a/PowerEditor/src/NppDarkMode.h b/PowerEditor/src/NppDarkMode.h index 57c25e147..32649c3d7 100644 --- a/PowerEditor/src/NppDarkMode.h +++ b/PowerEditor/src/NppDarkMode.h @@ -165,7 +165,7 @@ namespace NppDarkMode void setTreeViewStyle(HWND hwnd); void setBorder(HWND hwnd, bool border = true); - BOOL getAutocompleHandleProc(HWND hwnd, LPARAM lParam); + BOOL CALLBACK enumAutocompleteProc(HWND hwnd, LPARAM lParam); void setDarkAutoCompletion(); LRESULT onCtlColor(HDC hdc); diff --git a/PowerEditor/src/WinControls/Grid/BabyGridWrapper.cpp b/PowerEditor/src/WinControls/Grid/BabyGridWrapper.cpp index d5cafcf53..d96db9381 100644 --- a/PowerEditor/src/WinControls/Grid/BabyGridWrapper.cpp +++ b/PowerEditor/src/WinControls/Grid/BabyGridWrapper.cpp @@ -28,10 +28,10 @@ void BabyGridWrapper::init(HINSTANCE hInst, HWND parent, int16_t id) if (!_isRegistered) RegisterGridClass(_hInst); - _hSelf = ::CreateWindowEx(WS_EX_CLIENTEDGE, - babyGridClassName,\ + _hSelf = ::CreateWindowEx(0, + babyGridClassName,\ TEXT(""),\ - WS_CHILD | WS_VISIBLE | WS_TABSTOP,\ + WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_BORDER,\ CW_USEDEFAULT, 0, CW_USEDEFAULT, 0,\ _hParent,\ reinterpret_cast(id), \ diff --git a/PowerEditor/src/WinControls/Grid/ShortcutMapper.cpp b/PowerEditor/src/WinControls/Grid/ShortcutMapper.cpp index 81ce28769..54a67d0a0 100644 --- a/PowerEditor/src/WinControls/Grid/ShortcutMapper.cpp +++ b/PowerEditor/src/WinControls/Grid/ShortcutMapper.cpp @@ -24,6 +24,7 @@ using namespace std; void ShortcutMapper::initTabs() { HWND hTab = _hTabCtrl = ::GetDlgItem(_hSelf, IDC_BABYGRID_TABBAR); + NppDarkMode::subclassTabControl(hTab); TCITEM tie; tie.mask = TCIF_TEXT; @@ -121,6 +122,8 @@ void ShortcutMapper::initBabyGrid() _babygrid.init(_hInst, _hSelf, IDD_BABYGRID_ID1); + NppDarkMode::setDarkScrollBar(_babygrid.getHSelf()); + _babygrid.setHeaderFont(_hGridFonts.at(GFONT_HEADER)); _babygrid.setRowFont(_hGridFonts.at(GFONT_ROWS)); @@ -422,6 +425,8 @@ intptr_t CALLBACK ShortcutMapper::run_dlgProc(UINT message, WPARAM wParam, LPARA _babygrid.display(); goToCenter(); + NppDarkMode::autoSubclassAndThemeChildControls(_hSelf); + RECT rect; Window::getClientRect(rect); _clientWidth = rect.right - rect.left; @@ -435,6 +440,33 @@ intptr_t CALLBACK ShortcutMapper::run_dlgProc(UINT message, WPARAM wParam, LPARA return TRUE; } + + case WM_CTLCOLOREDIT: + { + return NppDarkMode::onCtlColorSofter(reinterpret_cast(wParam)); + } + + case WM_CTLCOLORDLG: + case WM_CTLCOLORSTATIC: + { + return NppDarkMode::onCtlColorDarker(reinterpret_cast(wParam)); + } + + case WM_PRINTCLIENT: + { + if (NppDarkMode::isEnabled()) + { + return TRUE; + } + break; + } + + case NPPM_INTERNAL_REFRESHDARKMODE: + { + NppDarkMode::autoThemeChildControls(_hSelf); + return TRUE; + } + case WM_GETMINMAXINFO : { MINMAXINFO* mmi = (MINMAXINFO*)lParam; diff --git a/PowerEditor/src/WinControls/Grid/ShortcutMapper.rc b/PowerEditor/src/WinControls/Grid/ShortcutMapper.rc index 288d255a3..62ddf0749 100755 --- a/PowerEditor/src/WinControls/Grid/ShortcutMapper.rc +++ b/PowerEditor/src/WinControls/Grid/ShortcutMapper.rc @@ -29,11 +29,11 @@ CAPTION "Shortcut mapper" FONT 8, TEXT("MS Shell Dlg"), 400, 0, 0x1 BEGIN CONTROL "",IDC_BABYGRID_TABBAR,"SysTabControl32",WS_TABSTOP,4,6,384,12 - EDITTEXT IDC_BABYGRID_INFO, 4, 281, 440, 29, ES_MULTILINE | ES_AUTOHSCROLL | ES_READONLY | WS_VSCROLL | NOT WS_TABSTOP - RTEXT "Filter :", IDC_BABYGRID_STATIC, 4, 313, 25, 12 - EDITTEXT IDC_BABYGRID_FILTER, 30, 312, 415, 12, ES_AUTOHSCROLL | ES_WANTRETURN | NOT WS_BORDER, WS_EX_STATICEDGE - DEFPUSHBUTTON "Modify",IDM_BABYGRID_MODIFY,118,330,47,14 - DEFPUSHBUTTON "Clear",IDM_BABYGRID_CLEAR,172,330,47,14 - DEFPUSHBUTTON "Delete",IDM_BABYGRID_DELETE,226,330,47,14 + EDITTEXT IDC_BABYGRID_INFO,3,281,443,29,ES_MULTILINE | ES_AUTOHSCROLL | ES_READONLY | WS_VSCROLL | NOT WS_TABSTOP + RTEXT "Filter :", IDC_BABYGRID_STATIC,4,313,25,12 + EDITTEXT IDC_BABYGRID_FILTER,31,312,415,12,ES_AUTOHSCROLL | ES_WANTRETURN + PUSHBUTTON "Modify",IDM_BABYGRID_MODIFY,118,330,47,14 + PUSHBUTTON "Clear",IDM_BABYGRID_CLEAR,172,330,47,14 + PUSHBUTTON "Delete",IDM_BABYGRID_DELETE,226,330,47,14 DEFPUSHBUTTON "Close",IDOK,280,330,47,14 END