Skip to content

Commit

Permalink
chcol ListBox fix dynamic theme switching
Browse files Browse the repository at this point in the history
  • Loading branch information
DartVanya committed Dec 17, 2024
1 parent 3971519 commit 3f67f70
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 55 deletions.
40 changes: 22 additions & 18 deletions SystemInformer/chcol.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ typedef struct _COLUMNS_DIALOG_CONTEXT
HBRUSH BrushPushed;
HBRUSH BrushHot;
COLORREF TextColor;
HBRUSH BrushNormalDark;
HBRUSH BrushPushedDark;
HBRUSH BrushHotDark;
COLORREF TextColorDark;

HWND InactiveWindowHandle;
HWND ActiveWindowHandle;
Expand Down Expand Up @@ -256,20 +260,15 @@ INT_PTR CALLBACK PhpColumnsDlgProc(
Button_Enable(context->MoveUpHandle, FALSE);
Button_Enable(context->MoveDownHandle, FALSE);

if (PhEnableThemeSupport)
{
context->BrushNormal = CreateSolidBrush(PhThemeWindowBackgroundColor);
context->BrushHot = CreateSolidBrush(PhThemeWindowHighlightColor);
context->BrushPushed = CreateSolidBrush(PhThemeWindowHighlight2Color);
context->TextColor = PhThemeWindowTextColor;
}
else
{
context->BrushNormal = GetSysColorBrush(COLOR_WINDOW);
context->BrushHot = CreateSolidBrush(RGB(145, 201, 247));
context->BrushPushed = CreateSolidBrush(RGB(153, 209, 255));
context->TextColor = GetSysColor(COLOR_WINDOWTEXT);
}
context->BrushNormal = GetSysColorBrush(COLOR_WINDOW);
context->BrushHot = CreateSolidBrush(RGB(145, 201, 247));
context->BrushPushed = CreateSolidBrush(RGB(153, 209, 255));
context->TextColor = GetSysColor(COLOR_WINDOWTEXT);

context->BrushNormalDark = CreateSolidBrush(PhThemeWindowBackgroundColor);
context->BrushHotDark = CreateSolidBrush(PhThemeWindowHighlightColor);
context->BrushPushedDark = CreateSolidBrush(PhThemeWindowHighlight2Color);
context->TextColorDark = PhThemeWindowTextColor;

if (context->Type == PH_CONTROL_TYPE_TREE_NEW)
{
Expand Down Expand Up @@ -356,6 +355,12 @@ INT_PTR CALLBACK PhpColumnsDlgProc(
DeleteBrush(context->BrushHot);
if (context->BrushPushed)
DeleteBrush(context->BrushPushed);
if (context->BrushNormalDark)
DeleteBrush(context->BrushNormalDark);
if (context->BrushHotDark)
DeleteBrush(context->BrushHotDark);
if (context->BrushPushedDark)
DeleteBrush(context->BrushPushedDark);
if (context->ControlFont)
DeleteFont(context->ControlFont);
if (context->InactiveListArray)
Expand Down Expand Up @@ -693,16 +698,15 @@ INT_PTR CALLBACK PhpColumnsDlgProc(

if (isSelected || isFocused)
{
FillRect(bufferDc, &bufferRect, context->BrushHot);
FillRect(bufferDc, &bufferRect, PhEnableThemeSupport ? context->BrushHotDark : context->BrushHot);
//FrameRect(bufferDc, &bufferRect, PhGetStockBrush(BLACK_BRUSH));
SetTextColor(bufferDc, context->TextColor);
}
else
{
FillRect(bufferDc, &bufferRect, context->BrushNormal);
FillRect(bufferDc, &bufferRect, PhEnableThemeSupport ? context->BrushNormalDark : context->BrushNormal);
//FrameRect(bufferDc, &bufferRect, GetSysColorBrush(COLOR_HIGHLIGHTTEXT));
SetTextColor(bufferDc, context->TextColor);
}
SetTextColor(bufferDc, PhEnableThemeSupport ? context->TextColorDark : context->TextColor);

bufferRect.left += 5;
DrawText(
Expand Down
4 changes: 2 additions & 2 deletions phlib/colorbox.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ UINT_PTR CALLBACK PhpColorBoxDlgHookProc(

PhCenterWindow(hwndDlg, GetParent(hwndDlg));

if (context->EnableThemeSupport)
PhInitializeWindowThemeEx(hwndDlg, TRUE);
//if (context->EnableThemeSupport)
PhInitializeWindowTheme(hwndDlg);
}
break;
case WM_CTLCOLORBTN:
Expand Down
37 changes: 20 additions & 17 deletions plugins/ToolStatus/customizesb.c
Original file line number Diff line number Diff line change
Expand Up @@ -290,21 +290,15 @@ INT_PTR CALLBACK CustomizeStatusBarDialogProc(
context->WindowDpi = PhGetWindowDpi(hwndDlg);
context->FontHandle = PhCreateIconTitleFont(context->WindowDpi);

if (PhIsThemeSupportEnabled())
{
context->BrushNormal = CreateSolidBrush(PhGetIntegerSetting(L"ThemeWindowBackgroundColor"));
context->BrushHot = CreateSolidBrush(PhGetIntegerSetting(L"ThemeWindowHighlightColor"));
context->BrushPushed = CreateSolidBrush(PhGetIntegerSetting(L"ThemeWindowHighlight2Color"));
context->TextColor = PhGetIntegerSetting(L"ThemeWindowTextColor");
}
else
{
context->BrushNormal = GetSysColorBrush(COLOR_WINDOW);
context->BrushHot = CreateSolidBrush(RGB(145, 201, 247));
context->BrushPushed = CreateSolidBrush(RGB(153, 209, 255));
context->TextColor = GetSysColor(COLOR_WINDOWTEXT);
}
context->BrushNormal = GetSysColorBrush(COLOR_WINDOW);
context->BrushHot = CreateSolidBrush(RGB(145, 201, 247));
context->BrushPushed = CreateSolidBrush(RGB(153, 209, 255));
context->TextColor = GetSysColor(COLOR_WINDOWTEXT);

context->BrushNormalDark = CreateSolidBrush(PhGetIntegerSetting(L"ThemeWindowBackgroundColor"));
context->BrushHotDark = CreateSolidBrush(PhGetIntegerSetting(L"ThemeWindowHighlightColor"));
context->BrushPushedDark = CreateSolidBrush(PhGetIntegerSetting(L"ThemeWindowHighlight2Color"));
context->TextColorDark = PhGetIntegerSetting(L"ThemeWindowTextColor");

ListBox_SetItemHeight(context->AvailableListHandle, 0, PhGetDpi(22, context->WindowDpi)); // BitmapHeight
ListBox_SetItemHeight(context->CurrentListHandle, 0, PhGetDpi(22, context->WindowDpi)); // BitmapHeight
Expand All @@ -331,6 +325,15 @@ INT_PTR CALLBACK CustomizeStatusBarDialogProc(
if (context->BrushPushed)
DeleteBrush(context->BrushPushed);

if (context->BrushNormalDark)
DeleteBrush(context->BrushNormalDark);

if (context->BrushHotDark)
DeleteBrush(context->BrushHotDark);

if (context->BrushPushedDark)
DeleteBrush(context->BrushPushedDark);

if (context->FontHandle)
DeleteFont(context->FontHandle);
}
Expand Down Expand Up @@ -595,12 +598,12 @@ INT_PTR CALLBACK CustomizeStatusBarDialogProc(
SetBkMode(bufferDc, TRANSPARENT);

if (isSelected || isFocused)
FillRect(bufferDc, &bufferRect, context->BrushHot);
FillRect(bufferDc, &bufferRect, PhIsThemeSupportEnabled() ? context->BrushHotDark : context->BrushHot);
else
FillRect(bufferDc, &bufferRect, context->BrushNormal);
FillRect(bufferDc, &bufferRect, PhIsThemeSupportEnabled() ? context->BrushNormalDark : context->BrushNormal);

if (!button->IsVirtual)
SetTextColor(bufferDc, context->TextColor);
SetTextColor(bufferDc, PhIsThemeSupportEnabled() ? context->TextColorDark : context->TextColor);
else
SetTextColor(bufferDc, GetSysColor(COLOR_GRAYTEXT));

Expand Down
40 changes: 22 additions & 18 deletions plugins/ToolStatus/customizetb.c
Original file line number Diff line number Diff line change
Expand Up @@ -514,20 +514,15 @@ INT_PTR CALLBACK CustomizeToolbarDialogProc(
context->FontHandle = PhCreateIconTitleFont(context->WindowDpi);
context->CXWidth = PhGetDpi(16, context->WindowDpi);

if (PhIsThemeSupportEnabled())
{
context->BrushNormal = CreateSolidBrush(PhGetIntegerSetting(L"ThemeWindowBackgroundColor"));
context->BrushHot = CreateSolidBrush(PhGetIntegerSetting(L"ThemeWindowHighlightColor"));
context->BrushPushed = CreateSolidBrush(PhGetIntegerSetting(L"ThemeWindowHighlight2Color"));
context->TextColor = PhGetIntegerSetting(L"ThemeWindowTextColor");
}
else
{
context->BrushNormal = GetSysColorBrush(COLOR_WINDOW);
context->BrushHot = CreateSolidBrush(RGB(145, 201, 247));
context->BrushPushed = CreateSolidBrush(RGB(153, 209, 255));
context->TextColor = GetSysColor(COLOR_WINDOWTEXT);
}
context->BrushNormal = GetSysColorBrush(COLOR_WINDOW);
context->BrushHot = CreateSolidBrush(RGB(145, 201, 247));
context->BrushPushed = CreateSolidBrush(RGB(153, 209, 255));
context->TextColor = GetSysColor(COLOR_WINDOWTEXT);

context->BrushNormalDark = CreateSolidBrush(PhGetIntegerSetting(L"ThemeWindowBackgroundColor"));
context->BrushHotDark = CreateSolidBrush(PhGetIntegerSetting(L"ThemeWindowHighlightColor"));
context->BrushPushedDark = CreateSolidBrush(PhGetIntegerSetting(L"ThemeWindowHighlight2Color"));
context->TextColorDark = PhGetIntegerSetting(L"ThemeWindowTextColor");

ListBox_SetItemHeight(context->AvailableListHandle, 0, context->CXWidth + 6); // BitmapHeight
ListBox_SetItemHeight(context->CurrentListHandle, 0, context->CXWidth + 6); // BitmapHeight
Expand Down Expand Up @@ -555,6 +550,15 @@ INT_PTR CALLBACK CustomizeToolbarDialogProc(
if (context->BrushPushed)
DeleteBrush(context->BrushPushed);

if (context->BrushNormalDark)
DeleteBrush(context->BrushNormalDark);

if (context->BrushHotDark)
DeleteBrush(context->BrushHotDark);

if (context->BrushPushedDark)
DeleteBrush(context->BrushPushedDark);

if (context->FontHandle)
DeleteFont(context->FontHandle);
}
Expand Down Expand Up @@ -888,13 +892,13 @@ INT_PTR CALLBACK CustomizeToolbarDialogProc(
SelectFont(bufferDc, context->FontHandle);
SetBkMode(bufferDc, TRANSPARENT);

if (isFocused || isSelected)
FillRect(bufferDc, &bufferRect, context->BrushHot);
if (isSelected || isFocused)
FillRect(bufferDc, &bufferRect, PhIsThemeSupportEnabled() ? context->BrushHotDark : context->BrushHot);
else
FillRect(bufferDc, &bufferRect, context->BrushNormal);
FillRect(bufferDc, &bufferRect, PhIsThemeSupportEnabled() ? context->BrushNormalDark : context->BrushNormal);

if (!itemContext->IsVirtual)
SetTextColor(bufferDc, context->TextColor);
SetTextColor(bufferDc, PhIsThemeSupportEnabled() ? context->TextColorDark : context->TextColor);
else
SetTextColor(bufferDc, GetSysColor(COLOR_GRAYTEXT));

Expand Down
4 changes: 4 additions & 0 deletions plugins/ToolStatus/toolstatus.h
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,10 @@ typedef struct _CUSTOMIZE_CONTEXT
HBRUSH BrushPushed;
HBRUSH BrushHot;
COLORREF TextColor;
HBRUSH BrushNormalDark;
HBRUSH BrushPushedDark;
HBRUSH BrushHotDark;
COLORREF TextColorDark;

LONG WindowDpi;
INT CXWidth;
Expand Down

0 comments on commit 3f67f70

Please sign in to comment.