mirror of
https://github.com/notepad-plus-plus/notepad-plus-plus.git
synced 2025-07-27 07:44:24 +02:00
Use edge colors in dark mode for listbox border
1. use edge colors in darkmode for edit control border. 2. tweaks to properly drawn listbox scrollbar, when using custom border. 3. disabled edge color to dark mode preference dialog. 4. use disabled edge color for disabled combobox. Fix #11207, fix #11376, close #11756
This commit is contained in:
parent
2c0134ef5a
commit
d65967deab
@ -913,6 +913,7 @@ The comments are here for explanation, it's not necessary to translate them.
|
||||
<Item id="7124" name="Edge"/>
|
||||
<Item id="7125" name="Link"/>
|
||||
<Item id="7126" name="Edge highlight"/>
|
||||
<Item id="7127" name="Edge disabled"/>
|
||||
<Item id="7130" name="Reset"/>
|
||||
<Item id="7135" name="Tones"/>
|
||||
</DarkMode>
|
||||
|
@ -526,6 +526,7 @@ enum Platform { PF_UNKNOWN, PF_X86, PF_X64, PF_IA64, PF_ARM64 };
|
||||
// COLORREF linkText = 0;
|
||||
// COLORREF edge = 0;
|
||||
// COLORREF hotEdge = 0;
|
||||
// COLORREF disabledEdge = 0;
|
||||
// };
|
||||
// }
|
||||
//
|
||||
|
@ -111,7 +111,7 @@ intptr_t CALLBACK RegExtDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lPa
|
||||
{
|
||||
if (NppDarkMode::isEnabled())
|
||||
{
|
||||
return NppDarkMode::onCtlColor(reinterpret_cast<HDC>(wParam));
|
||||
return NppDarkMode::onCtlColorListbox(wParam, lParam);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -2712,6 +2712,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
|
||||
currentColors->linkText = NppDarkMode::getLinkTextColor();
|
||||
currentColors->edge = NppDarkMode::getEdgeColor();
|
||||
currentColors->hotEdge = NppDarkMode::getHotEdgeColor();
|
||||
currentColors->disabledEdge = NppDarkMode::getDisabledEdgeColor();
|
||||
|
||||
return static_cast<LRESULT>(true);
|
||||
}
|
||||
|
@ -49,6 +49,7 @@ namespace NppDarkMode
|
||||
|
||||
HBRUSH edgeBrush = nullptr;
|
||||
HBRUSH hotEdgeBrush = nullptr;
|
||||
HBRUSH disabledEdgeBrush = nullptr;
|
||||
|
||||
Brushes(const Colors& colors)
|
||||
: background(::CreateSolidBrush(colors.background))
|
||||
@ -59,6 +60,7 @@ namespace NppDarkMode
|
||||
|
||||
, edgeBrush(::CreateSolidBrush(colors.edge))
|
||||
, hotEdgeBrush(::CreateSolidBrush(colors.hotEdge))
|
||||
, disabledEdgeBrush(::CreateSolidBrush(colors.disabledEdge))
|
||||
{}
|
||||
|
||||
~Brushes()
|
||||
@ -71,6 +73,7 @@ namespace NppDarkMode
|
||||
|
||||
::DeleteObject(edgeBrush); edgeBrush = nullptr;
|
||||
::DeleteObject(hotEdgeBrush); hotEdgeBrush = nullptr;
|
||||
::DeleteObject(disabledEdgeBrush); disabledEdgeBrush = nullptr;
|
||||
}
|
||||
|
||||
void change(const Colors& colors)
|
||||
@ -83,6 +86,7 @@ namespace NppDarkMode
|
||||
|
||||
::DeleteObject(edgeBrush);
|
||||
::DeleteObject(hotEdgeBrush);
|
||||
::DeleteObject(disabledEdgeBrush);
|
||||
|
||||
background = ::CreateSolidBrush(colors.background);
|
||||
softerBackground = ::CreateSolidBrush(colors.softerBackground);
|
||||
@ -92,6 +96,7 @@ namespace NppDarkMode
|
||||
|
||||
edgeBrush = ::CreateSolidBrush(colors.edge);
|
||||
hotEdgeBrush = ::CreateSolidBrush(colors.hotEdge);
|
||||
disabledEdgeBrush = ::CreateSolidBrush(colors.disabledEdge);
|
||||
}
|
||||
};
|
||||
|
||||
@ -100,11 +105,13 @@ namespace NppDarkMode
|
||||
HPEN darkerTextPen = nullptr;
|
||||
HPEN edgePen = nullptr;
|
||||
HPEN hotEdgePen = nullptr;
|
||||
HPEN disabledEdgePen = nullptr;
|
||||
|
||||
Pens(const Colors& colors)
|
||||
: darkerTextPen(::CreatePen(PS_SOLID, 1, colors.darkerText))
|
||||
, edgePen(::CreatePen(PS_SOLID, 1, colors.edge))
|
||||
, hotEdgePen(::CreatePen(PS_SOLID, 1, colors.hotEdge))
|
||||
, disabledEdgePen(::CreatePen(PS_SOLID, 1, colors.disabledEdge))
|
||||
{}
|
||||
|
||||
~Pens()
|
||||
@ -112,6 +119,7 @@ namespace NppDarkMode
|
||||
::DeleteObject(darkerTextPen); darkerTextPen = nullptr;
|
||||
::DeleteObject(edgePen); edgePen = nullptr;
|
||||
::DeleteObject(hotEdgePen); hotEdgePen = nullptr;
|
||||
::DeleteObject(disabledEdgePen); disabledEdgePen = nullptr;
|
||||
}
|
||||
|
||||
void change(const Colors& colors)
|
||||
@ -119,10 +127,12 @@ namespace NppDarkMode
|
||||
::DeleteObject(darkerTextPen);
|
||||
::DeleteObject(edgePen);
|
||||
::DeleteObject(hotEdgePen);
|
||||
::DeleteObject(disabledEdgePen);
|
||||
|
||||
darkerTextPen = ::CreatePen(PS_SOLID, 1, colors.darkerText);
|
||||
edgePen = ::CreatePen(PS_SOLID, 1, colors.edge);
|
||||
hotEdgePen = ::CreatePen(PS_SOLID, 1, colors.hotEdge);
|
||||
disabledEdgePen = ::CreatePen(PS_SOLID, 1, colors.disabledEdge);
|
||||
}
|
||||
|
||||
};
|
||||
@ -139,7 +149,8 @@ namespace NppDarkMode
|
||||
HEXRGB(0x808080), // disabledTextColor
|
||||
HEXRGB(0xFFFF00), // linkTextColor
|
||||
HEXRGB(0x646464), // edgeColor
|
||||
HEXRGB(0x9B9B9B) // hotEdgeColor
|
||||
HEXRGB(0x9B9B9B), // hotEdgeColor
|
||||
HEXRGB(0x484848) // disabledEdgeColor
|
||||
};
|
||||
|
||||
// red tone
|
||||
@ -154,7 +165,8 @@ namespace NppDarkMode
|
||||
HEXRGB(0x808080), // disabledTextColor
|
||||
HEXRGB(0xFFFF00), // linkTextColor
|
||||
HEXRGB(0x908080), // edgeColor
|
||||
HEXRGB(0xBBABAB) // hotEdgeColor
|
||||
HEXRGB(0xBBABAB), // hotEdgeColor
|
||||
HEXRGB(0x584848) // disabledEdgeColor
|
||||
};
|
||||
|
||||
// green tone
|
||||
@ -169,7 +181,8 @@ namespace NppDarkMode
|
||||
HEXRGB(0x808080), // disabledTextColor
|
||||
HEXRGB(0xFFFF00), // linkTextColor
|
||||
HEXRGB(0x809080), // edgeColor
|
||||
HEXRGB(0xABBBAB) // hotEdgeColor
|
||||
HEXRGB(0xABBBAB), // hotEdgeColor
|
||||
HEXRGB(0x485848) // disabledEdgeColor
|
||||
};
|
||||
|
||||
// blue tone
|
||||
@ -184,7 +197,8 @@ namespace NppDarkMode
|
||||
HEXRGB(0x808080), // disabledTextColor
|
||||
HEXRGB(0xFFFF00), // linkTextColor
|
||||
HEXRGB(0x8080A0), // edgeColor
|
||||
HEXRGB(0xABABCB) // hotEdgeColor
|
||||
HEXRGB(0xABABCB), // hotEdgeColor
|
||||
HEXRGB(0x484868) // disabledEdgeColor
|
||||
};
|
||||
|
||||
// purple tone
|
||||
@ -199,7 +213,8 @@ namespace NppDarkMode
|
||||
HEXRGB(0x808080), // disabledTextColor
|
||||
HEXRGB(0xFFFF00), // linkTextColor
|
||||
HEXRGB(0x9080A0), // edgeColor
|
||||
HEXRGB(0xBBABCB) // hotEdgeColor
|
||||
HEXRGB(0xBBABCB), // hotEdgeColor
|
||||
HEXRGB(0x584868) // disabledEdgeColor
|
||||
};
|
||||
|
||||
// cyan tone
|
||||
@ -214,7 +229,8 @@ namespace NppDarkMode
|
||||
HEXRGB(0x808080), // disabledTextColor
|
||||
HEXRGB(0xFFFF00), // linkTextColor
|
||||
HEXRGB(0x8090A0), // edgeColor
|
||||
HEXRGB(0xBBBBCB) // hotEdgeColor
|
||||
HEXRGB(0xBBBBCB), // hotEdgeColor
|
||||
HEXRGB(0x485868) // disabledEdgeColor
|
||||
};
|
||||
|
||||
// olive tone
|
||||
@ -229,7 +245,8 @@ namespace NppDarkMode
|
||||
HEXRGB(0x808080), // disabledTextColor
|
||||
HEXRGB(0xFFFF00), // linkTextColor
|
||||
HEXRGB(0x909080), // edgeColor
|
||||
HEXRGB(0xBBBBAB) // hotEdgeColor
|
||||
HEXRGB(0xBBBBAB), // hotEdgeColor
|
||||
HEXRGB(0x585848) // disabledEdgeColor
|
||||
};
|
||||
|
||||
// customized
|
||||
@ -244,7 +261,8 @@ namespace NppDarkMode
|
||||
HEXRGB(0x808080), // disabledTextColor
|
||||
HEXRGB(0xFFFF00), // linkTextColor
|
||||
HEXRGB(0x646464), // edgeColor
|
||||
HEXRGB(0x9B9B9B) // hotEdgeColor
|
||||
HEXRGB(0x9B9B9B), // hotEdgeColor
|
||||
HEXRGB(0x484848) // disabledEdgeColor
|
||||
};
|
||||
|
||||
ColorTone g_colorToneChoice = blackTone;
|
||||
@ -467,6 +485,7 @@ namespace NppDarkMode
|
||||
COLORREF getLinkTextColor() { return getTheme()._colors.linkText; }
|
||||
COLORREF getEdgeColor() { return getTheme()._colors.edge; }
|
||||
COLORREF getHotEdgeColor() { return getTheme()._colors.hotEdge; }
|
||||
COLORREF getDisabledEdgeColor() { return getTheme()._colors.disabledEdge; }
|
||||
|
||||
HBRUSH getBackgroundBrush() { return getTheme()._brushes.background; }
|
||||
HBRUSH getSofterBackgroundBrush() { return getTheme()._brushes.softerBackground; }
|
||||
@ -476,10 +495,12 @@ namespace NppDarkMode
|
||||
|
||||
HBRUSH getEdgeBrush() { return getTheme()._brushes.edgeBrush; }
|
||||
HBRUSH getHotEdgeBrush() { return getTheme()._brushes.hotEdgeBrush; }
|
||||
HBRUSH getDisabledEdgeBrush() { return getTheme()._brushes.disabledEdgeBrush; }
|
||||
|
||||
HPEN getDarkerTextPen() { return getTheme()._pens.darkerTextPen; }
|
||||
HPEN getEdgePen() { return getTheme()._pens.edgePen; }
|
||||
HPEN getHotEdgePen() { return getTheme()._pens.hotEdgePen; }
|
||||
HPEN getDisabledEdgePen() { return getTheme()._pens.disabledEdgePen; }
|
||||
|
||||
void setBackgroundColor(COLORREF c)
|
||||
{
|
||||
@ -558,6 +579,13 @@ namespace NppDarkMode
|
||||
getTheme().change(clrs);
|
||||
}
|
||||
|
||||
void setDisabledEdgeColor(COLORREF c)
|
||||
{
|
||||
Colors clrs = getTheme()._colors;
|
||||
clrs.disabledEdge = c;
|
||||
getTheme().change(clrs);
|
||||
}
|
||||
|
||||
Colors getDarkModeDefaultColors()
|
||||
{
|
||||
return darkColors;
|
||||
@ -775,7 +803,7 @@ namespace NppDarkMode
|
||||
::EnableDarkScrollBarForWindowAndChildren(hwnd);
|
||||
}
|
||||
|
||||
inline void paintRoundFrameRect(HDC hdc, const RECT rect, const HPEN hpen, int width, int height)
|
||||
void paintRoundFrameRect(HDC hdc, const RECT rect, const HPEN hpen, int width, int height)
|
||||
{
|
||||
auto holdBrush = ::SelectObject(hdc, ::GetStockObject(NULL_BRUSH));
|
||||
auto holdPen = ::SelectObject(hdc, hpen);
|
||||
@ -1114,7 +1142,7 @@ namespace NppDarkMode
|
||||
|
||||
//DrawThemeParentBackground(hwnd, hdc, &rcClient);
|
||||
//DrawThemeBackground(buttonData.hTheme, hdc, BP_GROUPBOX, iStateID, &rcBackground, nullptr);
|
||||
NppDarkMode::paintRoundFrameRect(hdc, rcBackground, NppDarkMode::getEdgePen(), 0, 0);
|
||||
NppDarkMode::paintRoundFrameRect(hdc, rcBackground, NppDarkMode::getEdgePen());
|
||||
|
||||
SelectClipRgn(hdc, nullptr);
|
||||
|
||||
@ -1365,6 +1393,167 @@ namespace NppDarkMode
|
||||
SetWindowSubclass(hwnd, TabSubclass, g_tabSubclassID, 0);
|
||||
}
|
||||
|
||||
constexpr UINT_PTR g_customBorderSubclassID = 42;
|
||||
|
||||
LRESULT CALLBACK CustomBorderSubclass(
|
||||
HWND hWnd,
|
||||
UINT uMsg,
|
||||
WPARAM wParam,
|
||||
LPARAM lParam,
|
||||
UINT_PTR uIdSubclass,
|
||||
DWORD_PTR dwRefData
|
||||
)
|
||||
{
|
||||
UNREFERENCED_PARAMETER(dwRefData);
|
||||
|
||||
static bool isHotStatic = false;
|
||||
|
||||
switch (uMsg)
|
||||
{
|
||||
case WM_NCPAINT:
|
||||
{
|
||||
if (!NppDarkMode::isEnabled())
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
DefSubclassProc(hWnd, uMsg, wParam, lParam);
|
||||
|
||||
HDC hdc = ::GetWindowDC(hWnd);
|
||||
RECT rcClient{};
|
||||
::GetClientRect(hWnd, &rcClient);
|
||||
rcClient.right += (2 * ::GetSystemMetrics(SM_CXEDGE));
|
||||
|
||||
auto style = ::GetWindowLongPtr(hWnd, GWL_STYLE);
|
||||
bool hasVerScrollbar = (style & WS_VSCROLL) == WS_VSCROLL;
|
||||
if (hasVerScrollbar)
|
||||
{
|
||||
rcClient.right += ::GetSystemMetrics(SM_CXVSCROLL);
|
||||
}
|
||||
|
||||
rcClient.bottom += (2 * ::GetSystemMetrics(SM_CYEDGE));
|
||||
|
||||
bool hasHorScrollbar = (style & WS_HSCROLL) == WS_HSCROLL;
|
||||
if (hasHorScrollbar)
|
||||
{
|
||||
rcClient.bottom += ::GetSystemMetrics(SM_CXHSCROLL);
|
||||
}
|
||||
|
||||
HPEN hPen = ::CreatePen(PS_SOLID, 1, NppDarkMode::getBackgroundColor());
|
||||
RECT rcInner = rcClient;
|
||||
::InflateRect(&rcInner, -1, -1);
|
||||
NppDarkMode::paintRoundFrameRect(hdc, rcInner, hPen);
|
||||
::DeleteObject(hPen);
|
||||
|
||||
bool hasFocus = ::GetFocus() == hWnd;
|
||||
|
||||
POINT ptCursor{};
|
||||
::GetCursorPos(&ptCursor);
|
||||
::ScreenToClient(hWnd, &ptCursor);
|
||||
|
||||
bool isHot = ::PtInRect(&rcClient, ptCursor);
|
||||
|
||||
bool isWindowEnabled = ::IsWindowEnabled(hWnd) == TRUE;
|
||||
HPEN hEnabledPen = ((isHotStatic && isHot) || hasFocus ? NppDarkMode::getHotEdgePen() : NppDarkMode::getEdgePen());
|
||||
|
||||
NppDarkMode::paintRoundFrameRect(hdc, rcClient, isWindowEnabled ? hEnabledPen : NppDarkMode::getDisabledEdgePen());
|
||||
|
||||
::ReleaseDC(hWnd, hdc);
|
||||
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_NCCALCSIZE:
|
||||
{
|
||||
if (!NppDarkMode::isEnabled())
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
auto lpRect = reinterpret_cast<LPRECT>(lParam);
|
||||
::InflateRect(lpRect, -(::GetSystemMetrics(SM_CXEDGE)), -(::GetSystemMetrics(SM_CYEDGE)));
|
||||
|
||||
auto style = ::GetWindowLongPtr(hWnd, GWL_STYLE);
|
||||
bool hasVerScrollbar = (style & WS_VSCROLL) == WS_VSCROLL;
|
||||
if (hasVerScrollbar)
|
||||
{
|
||||
lpRect->right -= ::GetSystemMetrics(SM_CXVSCROLL);
|
||||
}
|
||||
|
||||
bool hasHorScrollbar = (style & WS_HSCROLL) == WS_HSCROLL;
|
||||
if (hasHorScrollbar)
|
||||
{
|
||||
lpRect->bottom -= ::GetSystemMetrics(SM_CXHSCROLL);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_MOUSEMOVE:
|
||||
{
|
||||
if (!NppDarkMode::isEnabled())
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
if (::GetFocus() == hWnd)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
TRACKMOUSEEVENT tme{};
|
||||
tme.cbSize = sizeof(TRACKMOUSEEVENT);
|
||||
tme.dwFlags = TME_LEAVE;
|
||||
tme.hwndTrack = hWnd;
|
||||
tme.dwHoverTime = HOVER_DEFAULT;
|
||||
TrackMouseEvent(&tme);
|
||||
|
||||
if (!isHotStatic)
|
||||
{
|
||||
isHotStatic = true;
|
||||
::SetWindowPos(hWnd, nullptr, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_MOUSELEAVE:
|
||||
{
|
||||
if (!NppDarkMode::isEnabled())
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
if (isHotStatic)
|
||||
{
|
||||
isHotStatic = false;
|
||||
::SetWindowPos(hWnd, nullptr, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED);
|
||||
}
|
||||
|
||||
TRACKMOUSEEVENT tme{};
|
||||
tme.cbSize = sizeof(TRACKMOUSEEVENT);
|
||||
tme.dwFlags = TME_LEAVE | TME_CANCEL;
|
||||
tme.hwndTrack = hWnd;
|
||||
tme.dwHoverTime = HOVER_DEFAULT;
|
||||
TrackMouseEvent(&tme);
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_NCDESTROY:
|
||||
{
|
||||
RemoveWindowSubclass(hWnd, CustomBorderSubclass, uIdSubclass);
|
||||
}
|
||||
break;
|
||||
}
|
||||
return DefSubclassProc(hWnd, uMsg, wParam, lParam);
|
||||
}
|
||||
|
||||
void subclassCustomBorderForListBoxAndEditControls(HWND hwnd)
|
||||
{
|
||||
SetWindowSubclass(hwnd, CustomBorderSubclass, g_customBorderSubclassID, 0);
|
||||
}
|
||||
|
||||
constexpr UINT_PTR g_comboBoxSubclassID = 42;
|
||||
|
||||
LRESULT CALLBACK ComboBoxSubclass(
|
||||
@ -1448,7 +1637,10 @@ namespace NppDarkMode
|
||||
|
||||
bool isHot = ::PtInRect(&rc, ptCursor);
|
||||
|
||||
::SetTextColor(hdc, isHot ? NppDarkMode::getTextColor() : NppDarkMode::getDarkerTextColor());
|
||||
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());
|
||||
::ExtTextOut(hdc,
|
||||
rcArrow.left + (rcArrow.right - rcArrow.left) / 2 - dpiManager.scaleX(4),
|
||||
@ -1459,7 +1651,8 @@ namespace NppDarkMode
|
||||
nullptr);
|
||||
::SetBkColor(hdc, NppDarkMode::getBackgroundColor());
|
||||
|
||||
auto hSelectedPen = isHot || hasFocus ? NppDarkMode::getHotEdgePen() : NppDarkMode::getEdgePen();
|
||||
auto hEnabledPen = (isHot || hasFocus) ? NppDarkMode::getHotEdgePen() : NppDarkMode::getEdgePen();
|
||||
auto hSelectedPen = isWindowEnabled ? hEnabledPen : NppDarkMode::getDisabledEdgePen();
|
||||
auto holdPen = static_cast<HPEN>(::SelectObject(hdc, hSelectedPen));
|
||||
|
||||
POINT edge[] = {
|
||||
@ -1489,7 +1682,7 @@ namespace NppDarkMode
|
||||
|
||||
void subclassComboBoxControl(HWND hwnd)
|
||||
{
|
||||
DWORD_PTR hwndEditData = NULL;
|
||||
DWORD_PTR hwndEditData = 0;
|
||||
auto style = ::GetWindowLongPtr(hwnd, GWL_STYLE);
|
||||
if ((style & CBS_DROPDOWN) == CBS_DROPDOWN)
|
||||
{
|
||||
@ -1617,6 +1810,43 @@ namespace NppDarkMode
|
||||
SetWindowTheme(hwnd, p.themeClassName, nullptr);
|
||||
}
|
||||
|
||||
auto style = ::GetWindowLongPtr(hwnd, GWL_STYLE);
|
||||
bool isComboBox = (style & LBS_COMBOBOX) == LBS_COMBOBOX;
|
||||
auto exStyle = ::GetWindowLongPtr(hwnd, GWL_EXSTYLE);
|
||||
bool hasClientEdge = (exStyle & WS_EX_CLIENTEDGE) == WS_EX_CLIENTEDGE;
|
||||
|
||||
if (p.subclass && !isComboBox && hasClientEdge)
|
||||
{
|
||||
NppDarkMode::subclassCustomBorderForListBoxAndEditControls(hwnd);
|
||||
}
|
||||
|
||||
#ifndef __MINGW64__ // mingw build for 64 bit has issue with GetWindowSubclass, it is undefined
|
||||
|
||||
bool changed = false;
|
||||
if (::GetWindowSubclass(hwnd, CustomBorderSubclass, g_customBorderSubclassID, nullptr) == TRUE)
|
||||
{
|
||||
if (NppDarkMode::isEnabled())
|
||||
{
|
||||
if (hasClientEdge)
|
||||
{
|
||||
::SetWindowLongPtr(hwnd, GWL_EXSTYLE, exStyle & ~WS_EX_CLIENTEDGE);
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
else if (!hasClientEdge)
|
||||
{
|
||||
::SetWindowLongPtr(hwnd, GWL_EXSTYLE, exStyle | WS_EX_CLIENTEDGE);
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (changed)
|
||||
{
|
||||
::SetWindowPos(hwnd, nullptr, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED);
|
||||
}
|
||||
|
||||
#endif // !__MINGW64__
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@ -1630,6 +1860,40 @@ namespace NppDarkMode
|
||||
SetWindowTheme(hwnd, p.themeClassName, nullptr);
|
||||
}
|
||||
|
||||
auto exStyle = ::GetWindowLongPtr(hwnd, GWL_EXSTYLE);
|
||||
bool hasClientEdge = (exStyle & WS_EX_CLIENTEDGE) == WS_EX_CLIENTEDGE;
|
||||
if (p.subclass && hasClientEdge)
|
||||
{
|
||||
NppDarkMode::subclassCustomBorderForListBoxAndEditControls(hwnd);
|
||||
}
|
||||
|
||||
#ifndef __MINGW64__ // mingw build for 64 bit has issue with GetWindowSubclass, it is undefined
|
||||
|
||||
bool changed = false;
|
||||
if (::GetWindowSubclass(hwnd, CustomBorderSubclass, g_customBorderSubclassID, nullptr) == TRUE)
|
||||
{
|
||||
if (NppDarkMode::isEnabled())
|
||||
{
|
||||
if (hasClientEdge)
|
||||
{
|
||||
::SetWindowLongPtr(hwnd, GWL_EXSTYLE, exStyle & ~WS_EX_CLIENTEDGE);
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
else if (!hasClientEdge)
|
||||
{
|
||||
::SetWindowLongPtr(hwnd, GWL_EXSTYLE, exStyle | WS_EX_CLIENTEDGE);
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (changed)
|
||||
{
|
||||
::SetWindowPos(hwnd, nullptr, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED);
|
||||
}
|
||||
|
||||
#endif // !__MINGW64__
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@ -2192,13 +2456,8 @@ namespace NppDarkMode
|
||||
|
||||
if (!hasTheme)
|
||||
{
|
||||
auto holdPen = static_cast<HPEN>(::SelectObject(hdc, NppDarkMode::getEdgePen()));
|
||||
auto holdBrush = ::SelectObject(hdc, ::GetStockObject(NULL_BRUSH));
|
||||
::Rectangle(hdc, rcArrowLeft.left, rcArrowLeft.top, rcArrowLeft.right, rcArrowLeft.bottom);
|
||||
::Rectangle(hdc, rcArrowRight.left, rcArrowRight.top, rcArrowRight.right, rcArrowRight.bottom);
|
||||
|
||||
::SelectObject(hdc, holdPen);
|
||||
::SelectObject(hdc, holdBrush);
|
||||
NppDarkMode::paintRoundFrameRect(hdc, rcArrowLeft, NppDarkMode::getEdgePen());
|
||||
NppDarkMode::paintRoundFrameRect(hdc, rcArrowRight, NppDarkMode::getEdgePen());
|
||||
}
|
||||
|
||||
::SelectObject(hdc, holdFont);
|
||||
@ -2526,4 +2785,18 @@ namespace NppDarkMode
|
||||
::SetBkColor(hdc, NppDarkMode::getDarkerBackgroundColor());
|
||||
return reinterpret_cast<LRESULT>(NppDarkMode::getDarkerBackgroundBrush());
|
||||
}
|
||||
|
||||
INT_PTR onCtlColorListbox(WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
auto hdc = reinterpret_cast<HDC>(wParam);
|
||||
auto hwnd = reinterpret_cast<HWND>(lParam);
|
||||
|
||||
auto style = ::GetWindowLongPtr(hwnd, GWL_STYLE);
|
||||
bool isComboBox = (style & LBS_COMBOBOX) == LBS_COMBOBOX;
|
||||
if (!isComboBox && ::IsWindowEnabled(hwnd))
|
||||
{
|
||||
return static_cast<INT_PTR>(NppDarkMode::onCtlColorSofter(hdc));
|
||||
}
|
||||
return static_cast<INT_PTR>(NppDarkMode::onCtlColor(hdc));
|
||||
}
|
||||
}
|
||||
|
@ -42,6 +42,7 @@ namespace NppDarkMode
|
||||
COLORREF linkText = 0;
|
||||
COLORREF edge = 0;
|
||||
COLORREF hotEdge = 0;
|
||||
COLORREF disabledEdge = 0;
|
||||
};
|
||||
|
||||
struct Options
|
||||
@ -107,6 +108,7 @@ namespace NppDarkMode
|
||||
|
||||
COLORREF getEdgeColor();
|
||||
COLORREF getHotEdgeColor();
|
||||
COLORREF getDisabledEdgeColor();
|
||||
|
||||
HBRUSH getBackgroundBrush();
|
||||
HBRUSH getDarkerBackgroundBrush();
|
||||
@ -116,10 +118,12 @@ namespace NppDarkMode
|
||||
|
||||
HBRUSH getEdgeBrush();
|
||||
HBRUSH getHotEdgeBrush();
|
||||
HBRUSH getDisabledEdgeBrush();
|
||||
|
||||
HPEN getDarkerTextPen();
|
||||
HPEN getEdgePen();
|
||||
HPEN getHotEdgePen();
|
||||
HPEN getDisabledEdgePen();
|
||||
|
||||
void setBackgroundColor(COLORREF c);
|
||||
void setSofterBackgroundColor(COLORREF c);
|
||||
@ -132,6 +136,7 @@ namespace NppDarkMode
|
||||
void setLinkTextColor(COLORREF c);
|
||||
void setEdgeColor(COLORREF c);
|
||||
void setHotEdgeColor(COLORREF c);
|
||||
void setDisabledEdgeColor(COLORREF c);
|
||||
|
||||
Colors getDarkModeDefaultColors();
|
||||
void changeCustomTheme(const Colors& colors);
|
||||
@ -154,6 +159,8 @@ namespace NppDarkMode
|
||||
// enhancements to DarkMode.h
|
||||
void enableDarkScrollBarForWindowAndChildren(HWND hwnd);
|
||||
|
||||
inline void paintRoundFrameRect(HDC hdc, const RECT rect, const HPEN hpen, int width = 0, int height = 0);
|
||||
|
||||
void subclassButtonControl(HWND hwnd);
|
||||
void subclassGroupboxControl(HWND hwnd);
|
||||
void subclassTabControl(HWND hwnd);
|
||||
@ -191,4 +198,5 @@ namespace NppDarkMode
|
||||
LRESULT onCtlColorDarker(HDC hdc);
|
||||
LRESULT onCtlColorError(HDC hdc);
|
||||
LRESULT onCtlColorDarkerBGStaticText(HDC hdc, bool isTextEnabled);
|
||||
INT_PTR onCtlColorListbox(WPARAM wParam, LPARAM lParam);
|
||||
}
|
||||
|
@ -5599,6 +5599,10 @@ void NppParameters::feedGUIParameters(TiXmlNode *node)
|
||||
val = element->Attribute(TEXT("customColorHotEdge"), &i);
|
||||
if (val)
|
||||
_nppGUI._darkmode._customColors.hotEdge = i;
|
||||
|
||||
val = element->Attribute(TEXT("customColorDisabledEdge"), &i);
|
||||
if (val)
|
||||
_nppGUI._darkmode._customColors.disabledEdge = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -6698,6 +6702,7 @@ void NppParameters::createXmlTreeFromGUIParams()
|
||||
GUIConfigElement->SetAttribute(TEXT("customColorLinkText"), _nppGUI._darkmode._customColors.linkText);
|
||||
GUIConfigElement->SetAttribute(TEXT("customColorEdge"), _nppGUI._darkmode._customColors.edge);
|
||||
GUIConfigElement->SetAttribute(TEXT("customColorHotEdge"), _nppGUI._darkmode._customColors.hotEdge);
|
||||
GUIConfigElement->SetAttribute(TEXT("customColorDisabledEdge"), _nppGUI._darkmode._customColors.disabledEdge);
|
||||
}
|
||||
|
||||
// <GUIConfig name="ScintillaPrimaryView" lineNumberMargin="show" bookMarkMargin="show" indentGuideLine="show" folderMarkStyle="box" lineWrapMethod="aligned" currentLineHilitingShow="show" scrollBeyondLastLine="no" rightClickKeepsSelection="no" disableAdvancedScrolling="no" wrapSymbolShow="hide" Wrap="no" borderEdge="yes" edge="no" edgeNbColumn="80" zoom="0" zoom2="0" whiteSpaceShow="hide" eolShow="hide" borderWidth="2" smoothFont="no" />
|
||||
|
@ -81,8 +81,6 @@ intptr_t CALLBACK WordStyleDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM
|
||||
{
|
||||
NppParameters& nppParamInst = NppParameters::getInstance();
|
||||
|
||||
NppDarkMode::autoSubclassAndThemeChildControls(_hSelf);
|
||||
|
||||
_hCheckBold = ::GetDlgItem(_hSelf, IDC_BOLD_CHECK);
|
||||
_hCheckItalic = ::GetDlgItem(_hSelf, IDC_ITALIC_CHECK);
|
||||
_hCheckUnderline = ::GetDlgItem(_hSelf, IDC_UNDERLINE_CHECK);
|
||||
@ -151,6 +149,9 @@ intptr_t CALLBACK WordStyleDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM
|
||||
loadLangListFromNppParam();
|
||||
updateGlobalOverrideCtrls();
|
||||
setVisualFromStyleList();
|
||||
|
||||
NppDarkMode::autoSubclassAndThemeChildControls(_hSelf);
|
||||
|
||||
goToCenter();
|
||||
|
||||
return TRUE;
|
||||
@ -177,7 +178,7 @@ intptr_t CALLBACK WordStyleDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM
|
||||
{
|
||||
if (NppDarkMode::isEnabled())
|
||||
{
|
||||
return NppDarkMode::onCtlColor(reinterpret_cast<HDC>(wParam));
|
||||
return NppDarkMode::onCtlColorListbox(wParam, lParam);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -128,6 +128,7 @@ BEGIN
|
||||
LTEXT "Link",IDD_CUSTOMIZED_COLOR10_STATIC, 240,115,95,8
|
||||
LTEXT "Edge",IDD_CUSTOMIZED_COLOR9_STATIC,355,55,94,8
|
||||
LTEXT "Edge highlight",IDD_CUSTOMIZED_COLOR11_STATIC,355,75,94,8
|
||||
LTEXT "Edge disabled",IDD_CUSTOMIZED_COLOR12_STATIC,355,95,94,8
|
||||
PUSHBUTTON "Reset",IDD_CUSTOMIZED_RESET_BUTTON,252,155,45,14
|
||||
END
|
||||
|
||||
|
@ -217,7 +217,7 @@ intptr_t CALLBACK PreferenceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM
|
||||
{
|
||||
if (NppDarkMode::isEnabled())
|
||||
{
|
||||
return NppDarkMode::onCtlColor(reinterpret_cast<HDC>(wParam));
|
||||
return NppDarkMode::onCtlColorListbox(wParam, lParam);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -957,6 +957,7 @@ void DarkModeSubDlg::enableCustomizedColorCtrls(bool doEnable)
|
||||
::EnableWindow(_pEdgeColorPicker->getHSelf(), doEnable);
|
||||
::EnableWindow(_pLinkColorPicker->getHSelf(), doEnable);
|
||||
::EnableWindow(_pHotEdgeColorPicker->getHSelf(), doEnable);
|
||||
::EnableWindow(_pDisabledEdgeColorPicker->getHSelf(), doEnable);
|
||||
|
||||
::EnableWindow(::GetDlgItem(_hSelf, IDD_CUSTOMIZED_RESET_BUTTON), doEnable);
|
||||
|
||||
@ -973,6 +974,7 @@ void DarkModeSubDlg::enableCustomizedColorCtrls(bool doEnable)
|
||||
_pEdgeColorPicker->setColour(NppDarkMode::getEdgeColor());
|
||||
_pLinkColorPicker->setColour(NppDarkMode::getLinkTextColor());
|
||||
_pHotEdgeColorPicker->setColour(NppDarkMode::getHotEdgeColor());
|
||||
_pDisabledEdgeColorPicker->setColour(NppDarkMode::getDisabledEdgeColor());
|
||||
|
||||
redraw();
|
||||
}
|
||||
@ -1047,6 +1049,7 @@ intptr_t CALLBACK DarkModeSubDlg::run_dlgProc(UINT message, WPARAM wParam, LPARA
|
||||
_pEdgeColorPicker = new ColourPicker;
|
||||
_pLinkColorPicker = new ColourPicker;
|
||||
_pHotEdgeColorPicker = new ColourPicker;
|
||||
_pDisabledEdgeColorPicker = new ColourPicker;
|
||||
|
||||
_pBackgroundColorPicker->init(_hInst, _hSelf);
|
||||
_pSofterBackgroundColorPicker->init(_hInst, _hSelf);
|
||||
@ -1060,6 +1063,7 @@ intptr_t CALLBACK DarkModeSubDlg::run_dlgProc(UINT message, WPARAM wParam, LPARA
|
||||
_pEdgeColorPicker->init(_hInst, _hSelf);
|
||||
_pLinkColorPicker->init(_hInst, _hSelf);
|
||||
_pHotEdgeColorPicker->init(_hInst, _hSelf);
|
||||
_pDisabledEdgeColorPicker->init(_hInst, _hSelf);
|
||||
|
||||
int cpDynamicalWidth = NppParameters::getInstance()._dpiManager.scaleX(25);
|
||||
int cpDynamicalHeight = NppParameters::getInstance()._dpiManager.scaleY(25);
|
||||
@ -1075,6 +1079,7 @@ intptr_t CALLBACK DarkModeSubDlg::run_dlgProc(UINT message, WPARAM wParam, LPARA
|
||||
move2CtrlLeft(IDD_CUSTOMIZED_COLOR9_STATIC, _pEdgeColorPicker->getHSelf(), cpDynamicalWidth, cpDynamicalHeight);
|
||||
move2CtrlLeft(IDD_CUSTOMIZED_COLOR10_STATIC, _pLinkColorPicker->getHSelf(), cpDynamicalWidth, cpDynamicalHeight);
|
||||
move2CtrlLeft(IDD_CUSTOMIZED_COLOR11_STATIC, _pHotEdgeColorPicker->getHSelf(), cpDynamicalWidth, cpDynamicalHeight);
|
||||
move2CtrlLeft(IDD_CUSTOMIZED_COLOR12_STATIC, _pDisabledEdgeColorPicker->getHSelf(), cpDynamicalWidth, cpDynamicalHeight);
|
||||
|
||||
_pBackgroundColorPicker->display();
|
||||
_pSofterBackgroundColorPicker->display();
|
||||
@ -1087,6 +1092,7 @@ intptr_t CALLBACK DarkModeSubDlg::run_dlgProc(UINT message, WPARAM wParam, LPARA
|
||||
_pEdgeColorPicker->display();
|
||||
_pLinkColorPicker->display();
|
||||
_pHotEdgeColorPicker->display();
|
||||
_pDisabledEdgeColorPicker->display();
|
||||
|
||||
::EnableWindow(::GetDlgItem(_hSelf, IDC_RADIO_DARKMODE_BLACK), nppGUI._darkmode._isEnabled);
|
||||
::EnableWindow(::GetDlgItem(_hSelf, IDC_RADIO_DARKMODE_RED), nppGUI._darkmode._isEnabled);
|
||||
@ -1122,7 +1128,8 @@ intptr_t CALLBACK DarkModeSubDlg::run_dlgProc(UINT message, WPARAM wParam, LPARA
|
||||
dlgCtrlID == IDD_CUSTOMIZED_COLOR8_STATIC ||
|
||||
dlgCtrlID == IDD_CUSTOMIZED_COLOR9_STATIC ||
|
||||
dlgCtrlID == IDD_CUSTOMIZED_COLOR10_STATIC ||
|
||||
dlgCtrlID == IDD_CUSTOMIZED_COLOR11_STATIC);
|
||||
dlgCtrlID == IDD_CUSTOMIZED_COLOR11_STATIC ||
|
||||
dlgCtrlID == IDD_CUSTOMIZED_COLOR12_STATIC);
|
||||
//set the static text colors to show enable/disable instead of ::EnableWindow which causes blurry text
|
||||
if (isStaticText)
|
||||
{
|
||||
@ -1155,6 +1162,7 @@ intptr_t CALLBACK DarkModeSubDlg::run_dlgProc(UINT message, WPARAM wParam, LPARA
|
||||
_pEdgeColorPicker->destroy();
|
||||
_pLinkColorPicker->destroy();
|
||||
_pHotEdgeColorPicker->destroy();
|
||||
_pDisabledEdgeColorPicker->destroy();
|
||||
|
||||
delete _pBackgroundColorPicker;
|
||||
delete _pSofterBackgroundColorPicker;
|
||||
@ -1167,6 +1175,7 @@ intptr_t CALLBACK DarkModeSubDlg::run_dlgProc(UINT message, WPARAM wParam, LPARA
|
||||
delete _pEdgeColorPicker;
|
||||
delete _pLinkColorPicker;
|
||||
delete _pHotEdgeColorPicker;
|
||||
delete _pDisabledEdgeColorPicker;
|
||||
}
|
||||
|
||||
case WM_COMMAND:
|
||||
@ -1358,6 +1367,12 @@ intptr_t CALLBACK DarkModeSubDlg::run_dlgProc(UINT message, WPARAM wParam, LPARA
|
||||
NppDarkMode::setHotEdgeColor(c);
|
||||
nppGUI._darkmode._customColors.hotEdge = c;
|
||||
}
|
||||
else if (reinterpret_cast<HWND>(lParam) == _pDisabledEdgeColorPicker->getHSelf())
|
||||
{
|
||||
c = _pDisabledEdgeColorPicker->getColour();
|
||||
NppDarkMode::setDisabledEdgeColor(c);
|
||||
nppGUI._darkmode._customColors.disabledEdge = c;
|
||||
}
|
||||
else
|
||||
{
|
||||
return FALSE;
|
||||
@ -1395,6 +1410,7 @@ intptr_t CALLBACK DarkModeSubDlg::run_dlgProc(UINT message, WPARAM wParam, LPARA
|
||||
_pEdgeColorPicker->setColour(disabledColor);
|
||||
_pLinkColorPicker->setColour(disabledColor);
|
||||
_pHotEdgeColorPicker->setColour(disabledColor);
|
||||
_pDisabledEdgeColorPicker->setColour(disabledColor);
|
||||
|
||||
redraw();
|
||||
}
|
||||
@ -2519,7 +2535,7 @@ intptr_t CALLBACK LanguageSubDlg::run_dlgProc(UINT message, WPARAM wParam, LPARA
|
||||
{
|
||||
if (NppDarkMode::isEnabled())
|
||||
{
|
||||
return NppDarkMode::onCtlColor(reinterpret_cast<HDC>(wParam));
|
||||
return NppDarkMode::onCtlColorListbox(wParam, lParam);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -72,6 +72,7 @@ private:
|
||||
ColourPicker* _pEdgeColorPicker = nullptr;
|
||||
ColourPicker* _pLinkColorPicker = nullptr;
|
||||
ColourPicker* _pHotEdgeColorPicker = nullptr;
|
||||
ColourPicker* _pDisabledEdgeColorPicker = nullptr;
|
||||
|
||||
intptr_t CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam);
|
||||
void enableCustomizedColorCtrls(bool doEnable);
|
||||
|
@ -419,6 +419,7 @@
|
||||
#define IDD_CUSTOMIZED_COLOR9_STATIC (IDD_PREFERENCE_SUB_DARKMODE + 24)
|
||||
#define IDD_CUSTOMIZED_COLOR10_STATIC (IDD_PREFERENCE_SUB_DARKMODE + 25)
|
||||
#define IDD_CUSTOMIZED_COLOR11_STATIC (IDD_PREFERENCE_SUB_DARKMODE + 26)
|
||||
#define IDD_CUSTOMIZED_COLOR12_STATIC (IDD_PREFERENCE_SUB_DARKMODE + 27)
|
||||
#define IDD_CUSTOMIZED_RESET_BUTTON (IDD_PREFERENCE_SUB_DARKMODE + 30)
|
||||
#define IDC_DARKMODE_TONES_GB_STATIC (IDD_PREFERENCE_SUB_DARKMODE + 35)
|
||||
#endif //PREFERENCE_RC_H
|
||||
|
@ -1076,7 +1076,6 @@ intptr_t CALLBACK ScintillaKeyMap::run_dlgProc(UINT Message, WPARAM wParam, LPAR
|
||||
}
|
||||
|
||||
case WM_CTLCOLOREDIT:
|
||||
case WM_CTLCOLORLISTBOX:
|
||||
{
|
||||
if (NppDarkMode::isEnabled())
|
||||
{
|
||||
@ -1085,6 +1084,15 @@ intptr_t CALLBACK ScintillaKeyMap::run_dlgProc(UINT Message, WPARAM wParam, LPAR
|
||||
break;
|
||||
}
|
||||
|
||||
case WM_CTLCOLORLISTBOX:
|
||||
{
|
||||
if (NppDarkMode::isEnabled())
|
||||
{
|
||||
return NppDarkMode::onCtlColorListbox(wParam, lParam);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case WM_CTLCOLORDLG:
|
||||
case WM_CTLCOLORSTATIC:
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user