comparison win/dw.c @ 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
comparison
equal deleted inserted replaced
1977:0467eb85a25b 1978:a2a0a18678cd
3711 */ 3711 */
3712 if((_DW_DARK_MODE_ALLOWED == 2 && _DW_DARK_MODE_ENABLED) || 3712 if((_DW_DARK_MODE_ALLOWED == 2 && _DW_DARK_MODE_ENABLED) ||
3713 (cinfo && cinfo->fore != -1 && cinfo->fore != DW_CLR_DEFAULT && 3713 (cinfo && cinfo->fore != -1 && cinfo->fore != DW_CLR_DEFAULT &&
3714 cinfo->back !=- -1 && cinfo->back != DW_CLR_DEFAULT)) 3714 cinfo->back !=- -1 && cinfo->back != DW_CLR_DEFAULT))
3715 { 3715 {
3716 ULONG fore = (cinfo && (cinfo->fore != -1 && cinfo->fore != DW_CLR_DEFAULT)) ? _internal_color(cinfo->fore) : DW_RGB_TRANSPARENT;
3717 ULONG back = (cinfo && (cinfo->back != -1 && cinfo->back != DW_CLR_DEFAULT)) ? _internal_color(cinfo->back) : DW_RGB_TRANSPARENT;
3718 HBRUSH hbrback, hbrfore;
3719 hbrfore = fore != DW_RGB_TRANSPARENT ? CreateSolidBrush(RGB(DW_RED_VALUE(fore), DW_GREEN_VALUE(fore), DW_BLUE_VALUE(fore))) : NULL;
3720 hbrback = back != DW_RGB_TRANSPARENT ? CreateSolidBrush(RGB(DW_RED_VALUE(back), DW_GREEN_VALUE(back), DW_BLUE_VALUE(back))) : NULL;
3716 /* Fill with the background color */ 3721 /* Fill with the background color */
3717 FillRect(hdcPaint, &rc, _DW_GetSysColorBrush(COLOR_3DFACE)); 3722 FillRect(hdcPaint, &rc, hbrback ? hbrback : _DW_GetSysColorBrush(COLOR_3DFACE));
3718 /* Dwaw a border around it */ 3723 /* Dwaw a border around it */
3719 FrameRect(hdcPaint, &rc, _DW_GetSysColorBrush(COLOR_WINDOWTEXT)); 3724 FrameRect(hdcPaint, &rc, hbrfore ? hbrfore : _DW_GetSysColorBrush(COLOR_WINDOWTEXT));
3720 SetRect(&rc, 3, 1, cx -1, cy - 1); 3725 SetRect(&rc, 3, 1, cx -1, cy - 1);
3721 SetTextColor(hdcPaint, _DW_GetSysColor(COLOR_WINDOWTEXT)); 3726 SetTextColor(hdcPaint, fore != DW_RGB_TRANSPARENT ? RGB(DW_RED_VALUE(fore), DW_GREEN_VALUE(fore), DW_BLUE_VALUE(fore)) : _DW_GetSysColor(COLOR_WINDOWTEXT));
3722 SetBkMode(hdcPaint, TRANSPARENT); 3727 SetBkMode(hdcPaint, TRANSPARENT);
3723 /* Draw the text in the middle */ 3728 /* Draw the text in the middle */
3724 ExtTextOut(hdcPaint, 3, 1, ETO_CLIPPED, &rc, tempbuf, (UINT)_tcslen(tempbuf), NULL); 3729 ExtTextOut(hdcPaint, 3, 1, ETO_CLIPPED, &rc, tempbuf, (UINT)_tcslen(tempbuf), NULL);
3730 if(hbrfore)
3731 DeleteObject(hbrfore);
3732 if(hbrback)
3733 DeleteObject(hbrback);
3725 } 3734 }
3726 else 3735 else
3727 DrawStatusText(hdcPaint, &rc, tempbuf, 0); 3736 DrawStatusText(hdcPaint, &rc, tempbuf, 0);
3728 if(hfont && oldfont) 3737 if(hfont && oldfont)
3729 SelectObject(hdcPaint, oldfont); 3738 SelectObject(hdcPaint, oldfont);