changeset 1978:a2a0a18678cd

Win: Improved the last commit so it handles custom color overrides not just dark mode.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Thu, 08 Aug 2019 18:15:00 +0000
parents 0467eb85a25b
children 290e661abb63
files win/dw.c
diffstat 1 files changed, 12 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/win/dw.c	Thu Aug 08 08:44:18 2019 +0000
+++ b/win/dw.c	Thu Aug 08 18:15:00 2019 +0000
@@ -3713,15 +3713,24 @@
             (cinfo && cinfo->fore != -1 && cinfo->fore != DW_CLR_DEFAULT &&
              cinfo->back !=- -1 && cinfo->back != DW_CLR_DEFAULT))
          {
+            ULONG fore = (cinfo && (cinfo->fore != -1 && cinfo->fore != DW_CLR_DEFAULT)) ? _internal_color(cinfo->fore) : DW_RGB_TRANSPARENT;
+            ULONG back = (cinfo && (cinfo->back != -1 && cinfo->back != DW_CLR_DEFAULT)) ? _internal_color(cinfo->back) : DW_RGB_TRANSPARENT;
+            HBRUSH hbrback, hbrfore;
+            hbrfore = fore != DW_RGB_TRANSPARENT ? CreateSolidBrush(RGB(DW_RED_VALUE(fore), DW_GREEN_VALUE(fore), DW_BLUE_VALUE(fore))) : NULL;
+            hbrback = back != DW_RGB_TRANSPARENT ? CreateSolidBrush(RGB(DW_RED_VALUE(back), DW_GREEN_VALUE(back), DW_BLUE_VALUE(back))) : NULL;
             /* Fill with the background color */
-            FillRect(hdcPaint, &rc, _DW_GetSysColorBrush(COLOR_3DFACE));
+            FillRect(hdcPaint, &rc, hbrback ? hbrback : _DW_GetSysColorBrush(COLOR_3DFACE));
             /* Dwaw a border around it */
-            FrameRect(hdcPaint, &rc, _DW_GetSysColorBrush(COLOR_WINDOWTEXT));
+            FrameRect(hdcPaint, &rc, hbrfore ? hbrfore : _DW_GetSysColorBrush(COLOR_WINDOWTEXT));
             SetRect(&rc, 3, 1, cx -1, cy - 1);
-            SetTextColor(hdcPaint, _DW_GetSysColor(COLOR_WINDOWTEXT));
+            SetTextColor(hdcPaint, fore != DW_RGB_TRANSPARENT ? RGB(DW_RED_VALUE(fore), DW_GREEN_VALUE(fore), DW_BLUE_VALUE(fore)) : _DW_GetSysColor(COLOR_WINDOWTEXT));
             SetBkMode(hdcPaint, TRANSPARENT);
             /* Draw the text in the middle */
             ExtTextOut(hdcPaint, 3, 1, ETO_CLIPPED, &rc, tempbuf, (UINT)_tcslen(tempbuf), NULL);
+            if(hbrfore)
+               DeleteObject(hbrfore);
+            if(hbrback)
+               DeleteObject(hbrback);
          }
          else
             DrawStatusText(hdcPaint, &rc, tempbuf, 0);