diff --git a/PowerEditor/src/NppDarkMode.cpp b/PowerEditor/src/NppDarkMode.cpp index 7b5479eb2..f9f6d71ca 100644 --- a/PowerEditor/src/NppDarkMode.cpp +++ b/PowerEditor/src/NppDarkMode.cpp @@ -1,4 +1,4 @@ -#include "nppDarkMode.h" +#include "NppDarkMode.h" #include "DarkMode/DarkMode.h" #include "DarkMode/UAHMenuBar.h" @@ -58,21 +58,26 @@ namespace NppDarkMode struct Pens { + HPEN darkerTextPen = nullptr; HPEN edgePen = nullptr; Pens(const Colors& colors) - : edgePen(::CreatePen(PS_SOLID, 1, colors.edge)) + : darkerTextPen(::CreatePen(PS_SOLID, 1, colors.darkerText)) + , edgePen(::CreatePen(PS_SOLID, 1, colors.edge)) {} ~Pens() { - ::DeleteObject(edgePen); edgePen = nullptr; + ::DeleteObject(darkerTextPen); darkerTextPen = nullptr; + ::DeleteObject(edgePen); edgePen = nullptr; } void change(const Colors& colors) { + ::DeleteObject(darkerTextPen); ::DeleteObject(edgePen); + darkerTextPen = ::CreatePen(PS_SOLID, 1, colors.darkerText); edgePen = ::CreatePen(PS_SOLID, 1, colors.edge); } @@ -369,6 +374,7 @@ namespace NppDarkMode HBRUSH getDarkerBackgroundBrush() { return getTheme()._brushes.pureBackground; } HBRUSH getErrorBackgroundBrush() { return getTheme()._brushes.errorBackground; } + HPEN getDarkerTextPen() { return getTheme()._pens.darkerTextPen; } HPEN getEdgePen() { return getTheme()._pens.edgePen; } void setBackgroundColor(COLORREF c) diff --git a/PowerEditor/src/NppDarkMode.h b/PowerEditor/src/NppDarkMode.h index ba765ff0d..744e07f5b 100644 --- a/PowerEditor/src/NppDarkMode.h +++ b/PowerEditor/src/NppDarkMode.h @@ -81,6 +81,7 @@ namespace NppDarkMode HBRUSH getHotBackgroundBrush(); HBRUSH getErrorBackgroundBrush(); + HPEN getDarkerTextPen(); HPEN getEdgePen(); void setBackgroundColor(COLORREF c); diff --git a/PowerEditor/src/WinControls/SplitterContainer/Splitter.cpp b/PowerEditor/src/WinControls/SplitterContainer/Splitter.cpp index 6aa63c649..ea2517b94 100644 --- a/PowerEditor/src/WinControls/SplitterContainer/Splitter.cpp +++ b/PowerEditor/src/WinControls/SplitterContainer/Splitter.cpp @@ -13,6 +13,7 @@ // // You should have received a copy of the GNU General Public License // along with this program. If not, see . + #include #include #include @@ -111,10 +112,10 @@ void Splitter::init( HINSTANCE hInst, HWND hPere, int splitterSize, double iSpli { wcex.hCursor = ::LoadCursor(NULL, IDC_ARROW); // if fixed spliter then choose default cursor type. - if (_dwFlags & SV_HORIZONTAL) - wcex.lpszClassName = TEXT("fxdnsspliter"); - else - wcex.lpszClassName = TEXT("fxdwespliter"); + if (_dwFlags & SV_HORIZONTAL) + wcex.lpszClassName = TEXT("fxdnsspliter"); + else + wcex.lpszClassName = TEXT("fxdwespliter"); } else { @@ -146,16 +147,16 @@ void Splitter::init( HINSTANCE hInst, HWND hPere, int splitterSize, double iSpli RegisterClassEx(&wcex); _isVerticalRegistered = true; } - else if ((_dwFlags & SV_HORIZONTAL)&&(!_isHorizontalFixedRegistered)) - { - RegisterClassEx(&wcex); - _isHorizontalFixedRegistered = true; - } - else if (isVertical()&&(!_isVerticalFixedRegistered)) - { - RegisterClassEx(&wcex); - _isVerticalFixedRegistered = true; - } + else if ((_dwFlags & SV_HORIZONTAL)&&(!_isHorizontalFixedRegistered)) + { + RegisterClassEx(&wcex); + _isHorizontalFixedRegistered = true; + } + else if (isVertical()&&(!_isVerticalFixedRegistered)) + { + RegisterClassEx(&wcex); + _isVerticalFixedRegistered = true; + } _hSelf = CreateWindowEx(dwExStyle, wcex.lpszClassName, TEXT(""), @@ -349,7 +350,7 @@ LRESULT CALLBACK Splitter::spliterWndProc(UINT uMsg, WPARAM wParam, LPARAM lPara RECT r; ::GetClientRect(_hParent, &r); - if (_dwFlags & SV_HORIZONTAL) + if (_dwFlags & SV_HORIZONTAL) { _rect.top = (r.bottom - _splitterSize) / 2; } @@ -359,7 +360,7 @@ LRESULT CALLBACK Splitter::spliterWndProc(UINT uMsg, WPARAM wParam, LPARAM lPara } _splitPercent = 50; - + ::SendMessage(_hParent, WM_RESIZE_CONTAINER, _rect.left, _rect.top); ::MoveWindow(_hSelf, _rect.left, _rect.top, _rect.right, _rect.bottom, FALSE); redraw(); @@ -398,8 +399,8 @@ LRESULT CALLBACK Splitter::spliterWndProc(UINT uMsg, WPARAM wParam, LPARAM lPara RECT rc = { 0 }; getClientRect(rc); - FillRect((HDC)wParam, &rc, NppDarkMode::getSofterBackgroundBrush()); - + ::FillRect(reinterpret_cast(wParam), &rc, NppDarkMode::getDarkerBackgroundBrush()); + return 1; } @@ -522,12 +523,22 @@ void Splitter::drawSplitter() bool isDarkMode = NppDarkMode::isEnabled(); + HBRUSH hBrush = nullptr; + HBRUSH hBrushTop = nullptr; + HPEN holdPen = nullptr; if (isDarkMode) { - static HPEN g_hpen = CreatePen(PS_SOLID, 1, NppDarkMode::getDarkerTextColor()); - holdPen = (HPEN)SelectObject(hdc, g_hpen); - FillRect(hdc, &rc, NppDarkMode::getSofterBackgroundBrush()); + hBrush = NppDarkMode::getBackgroundBrush(); + hBrushTop = NppDarkMode::getSofterBackgroundBrush(); + + holdPen = static_cast(::SelectObject(hdc, NppDarkMode::getDarkerTextPen())); + ::FillRect(hdc, &rc, NppDarkMode::getDarkerBackgroundBrush()); + } + else + { + hBrush = ::CreateSolidBrush(RGB(0xFF, 0xFF, 0xFF)); + hBrushTop = ::GetSysColorBrush(COLOR_3DSHADOW); } if ((_splitterSize >= 4) && (_dwFlags & SV_RESIZEWTHPERCNT)) @@ -560,7 +571,7 @@ void Splitter::drawSplitter() else bottom = rc.bottom; - while (!isDarkMode && rcToDraw1.bottom <= bottom) + while (rcToDraw1.bottom <= bottom) { if (isVertical()) { @@ -581,8 +592,8 @@ void Splitter::drawSplitter() while (rcToDraw1.right <= (isVertical() ? rc.right : rc.right - _clickZone2BR.right)) { - ::FillRect(hdc, &rcToDraw1, (HBRUSH)(RGB(0xFF, 0xFF, 0xFF))); - ::FillRect(hdc, &rcToDraw2, (HBRUSH)(COLOR_3DSHADOW+1)); + ::FillRect(hdc, &rcToDraw1, hBrush); + ::FillRect(hdc, &rcToDraw2, hBrushTop); rcToDraw2.left += 4; rcToDraw2.right += 4; @@ -601,7 +612,11 @@ void Splitter::drawSplitter() if (isDarkMode) { - SelectObject(hdc, holdPen); + ::SelectObject(hdc, holdPen); + } + else + { + ::DeleteObject(hBrush); } ::EndPaint(_hSelf, &ps); @@ -755,4 +770,3 @@ void Splitter::adjustZoneToDraw(RECT& rc2def, ZONE_TYPE whichZone) rc2def.right = x1; rc2def.bottom = y1; } -