Mercurial > dwindows
comparison win/dw.c @ 1977:0467eb85a25b
Win: We now draw status windows ourselves in dark mode and use DrawStatusText() otherwise.
Additionally added a separate notebook window procedure for eventual drawing changes.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Thu, 08 Aug 2019 08:44:18 +0000 |
parents | 775ea7d5f497 |
children | a2a0a18678cd |
comparison
equal
deleted
inserted
replaced
1976:775ea7d5f497 | 1977:0467eb85a25b |
---|---|
694 _ForceDark, | 694 _ForceDark, |
695 _ForceLight, | 695 _ForceLight, |
696 _Max | 696 _Max |
697 } _PreferredAppMode; | 697 } _PreferredAppMode; |
698 | 698 |
699 int CompareStringOrdinal(LPCWCH lpString1, int cchCount1, LPCWCH lpString2, int cchCount2, BOOL bIgnoreCase); | |
699 HTHEME (WINAPI * _OpenNcThemeData)(HWND, LPCWSTR) = NULL; | 700 HTHEME (WINAPI * _OpenNcThemeData)(HWND, LPCWSTR) = NULL; |
700 VOID (WINAPI * _RefreshImmersiveColorPolicyState)(VOID) = NULL; | 701 VOID (WINAPI * _RefreshImmersiveColorPolicyState)(VOID) = NULL; |
701 BOOL (WINAPI * _GetIsImmersiveColorUsingHighContrast)(IMMERSIVE_HC_CACHE_MODE) = NULL; | 702 BOOL (WINAPI * _GetIsImmersiveColorUsingHighContrast)(IMMERSIVE_HC_CACHE_MODE) = NULL; |
702 BOOL (WINAPI * _ShouldAppsUseDarkMode)(VOID) = NULL; | 703 BOOL (WINAPI * _ShouldAppsUseDarkMode)(VOID) = NULL; |
703 BOOL (WINAPI * _AllowDarkModeForWindow)(HWND, BOOL) = NULL; | 704 BOOL (WINAPI * _AllowDarkModeForWindow)(HWND, BOOL) = NULL; |
704 BOOL (WINAPI * _AllowDarkModeForApp)(BOOL) = NULL; | 705 BOOL (WINAPI * _AllowDarkModeForApp)(BOOL) = NULL; |
705 _PreferredAppMode (WINAPI * _SetPreferredAppMode)(_PreferredAppMode) = NULL; | 706 _PreferredAppMode (WINAPI * _SetPreferredAppMode)(_PreferredAppMode) = NULL; |
706 BOOL (WINAPI * _IsDarkModeAllowedForWindow)(HWND) = NULL; | 707 BOOL (WINAPI * _IsDarkModeAllowedForWindow)(HWND) = NULL; |
707 BOOL (WINAPI * _ShouldSystemUseDarkMode)(VOID) = NULL; | 708 BOOL (WINAPI * _ShouldSystemUseDarkMode)(VOID) = NULL; |
709 | |
710 BOOL IsHighContrast(VOID) | |
711 { | |
712 HIGHCONTRASTW highContrast = { sizeof(highContrast) }; | |
713 if(SystemParametersInfoW(SPI_GETHIGHCONTRAST, sizeof(highContrast), &highContrast, FALSE)) | |
714 return highContrast.dwFlags & HCF_HIGHCONTRASTON; | |
715 return FALSE; | |
716 } | |
708 | 717 |
709 void _dw_init_dark_mode(void) | 718 void _dw_init_dark_mode(void) |
710 { | 719 { |
711 if(_DW_DARK_MODE_ALLOWED && dwVersion && huxtheme) | 720 if(_DW_DARK_MODE_ALLOWED && dwVersion && huxtheme) |
712 { | 721 { |
761 _SetWindowTheme(window, L"Explorer", NULL); | 770 _SetWindowTheme(window, L"Explorer", NULL); |
762 } | 771 } |
763 } | 772 } |
764 return _AllowDarkModeForWindow(window, allow); | 773 return _AllowDarkModeForWindow(window, allow); |
765 } | 774 } |
766 return FALSE; | |
767 } | |
768 | |
769 BOOL IsHighContrast(VOID) | |
770 { | |
771 HIGHCONTRASTW highContrast = { sizeof(highContrast) }; | |
772 if(SystemParametersInfoW(SPI_GETHIGHCONTRAST, sizeof(highContrast), &highContrast, FALSE)) | |
773 return highContrast.dwFlags & HCF_HIGHCONTRASTON; | |
774 return FALSE; | 775 return FALSE; |
775 } | 776 } |
776 | 777 |
777 BOOL IsColorSchemeChangeMessage(LPARAM lParam) | 778 BOOL IsColorSchemeChangeMessage(LPARAM lParam) |
778 { | 779 { |
3025 case WM_CTLCOLORMSGBOX: | 3026 case WM_CTLCOLORMSGBOX: |
3026 case WM_CTLCOLORSCROLLBAR: | 3027 case WM_CTLCOLORSCROLLBAR: |
3027 case WM_CTLCOLORDLG: | 3028 case WM_CTLCOLORDLG: |
3028 { | 3029 { |
3029 ColorInfo *thiscinfo = (ColorInfo *)GetWindowLongPtr((HWND)mp2, GWLP_USERDATA); | 3030 ColorInfo *thiscinfo = (ColorInfo *)GetWindowLongPtr((HWND)mp2, GWLP_USERDATA); |
3031 | |
3030 if(thiscinfo && thiscinfo->fore != -1 && thiscinfo->back != -1) | 3032 if(thiscinfo && thiscinfo->fore != -1 && thiscinfo->back != -1) |
3031 { | 3033 { |
3032 int thisback = thiscinfo->back; | 3034 int thisback = thiscinfo->back; |
3033 | 3035 |
3034 /* Handle foreground */ | 3036 /* Handle foreground */ |
3388 } | 3390 } |
3389 #endif | 3391 #endif |
3390 return _simplewndproc(hWnd, msg, mp1, mp2); | 3392 return _simplewndproc(hWnd, msg, mp1, mp2); |
3391 } | 3393 } |
3392 | 3394 |
3395 LRESULT CALLBACK _notebookwndproc(HWND hWnd, UINT msg, WPARAM mp1, LPARAM mp2) | |
3396 { | |
3397 #ifdef AEROGLASS | |
3398 if(msg == WM_ERASEBKGND) | |
3399 { | |
3400 if(_DW_DARK_MODE_ALLOWED == 2 && _DW_DARK_MODE_SUPPORTED) | |
3401 { | |
3402 HDC hdc; | |
3403 RECT rc; | |
3404 | |
3405 hdc=(HDC)mp1; | |
3406 GetClientRect(hWnd, &rc); | |
3407 FillRect(hdc, &rc, _DW_GetSysColorBrush(COLOR_3DFACE)); | |
3408 return (LRESULT)TRUE; | |
3409 } | |
3410 } | |
3411 #endif | |
3412 return _simplewndproc(hWnd, msg, mp1, mp2); | |
3413 } | |
3414 | |
3393 void _changebox(Box *thisbox, int percent, int type) | 3415 void _changebox(Box *thisbox, int percent, int type) |
3394 { | 3416 { |
3395 int z; | 3417 int z; |
3396 | 3418 |
3397 for(z=0;z<thisbox->count;z++) | 3419 for(z=0;z<thisbox->count;z++) |
3679 GetWindowText(hwnd, tempbuf, 1024); | 3701 GetWindowText(hwnd, tempbuf, 1024); |
3680 | 3702 |
3681 hdcPaint = BeginPaint(hwnd, &ps); | 3703 hdcPaint = BeginPaint(hwnd, &ps); |
3682 if(hfont) | 3704 if(hfont) |
3683 oldfont = (HFONT)SelectObject(hdcPaint, hfont); | 3705 oldfont = (HFONT)SelectObject(hdcPaint, hfont); |
3684 rc.top = rc.left = 0; | 3706 |
3685 rc.right = cx; | 3707 SetRect(&rc, 0, 0, cx, cy); |
3686 rc.bottom = cy; | 3708 |
3687 DrawStatusText(hdcPaint, &rc, tempbuf, 0); | 3709 /* If we are in full dark mode, or we have custom colors selected... |
3710 * we will draw the status window ourselves... otherwise DrawStatusText() | |
3711 */ | |
3712 if((_DW_DARK_MODE_ALLOWED == 2 && _DW_DARK_MODE_ENABLED) || | |
3713 (cinfo && cinfo->fore != -1 && cinfo->fore != DW_CLR_DEFAULT && | |
3714 cinfo->back !=- -1 && cinfo->back != DW_CLR_DEFAULT)) | |
3715 { | |
3716 /* Fill with the background color */ | |
3717 FillRect(hdcPaint, &rc, _DW_GetSysColorBrush(COLOR_3DFACE)); | |
3718 /* Dwaw a border around it */ | |
3719 FrameRect(hdcPaint, &rc, _DW_GetSysColorBrush(COLOR_WINDOWTEXT)); | |
3720 SetRect(&rc, 3, 1, cx -1, cy - 1); | |
3721 SetTextColor(hdcPaint, _DW_GetSysColor(COLOR_WINDOWTEXT)); | |
3722 SetBkMode(hdcPaint, TRANSPARENT); | |
3723 /* Draw the text in the middle */ | |
3724 ExtTextOut(hdcPaint, 3, 1, ETO_CLIPPED, &rc, tempbuf, (UINT)_tcslen(tempbuf), NULL); | |
3725 } | |
3726 else | |
3727 DrawStatusText(hdcPaint, &rc, tempbuf, 0); | |
3688 if(hfont && oldfont) | 3728 if(hfont && oldfont) |
3689 SelectObject(hdcPaint, oldfont); | 3729 SelectObject(hdcPaint, oldfont); |
3690 if(hfont) | 3730 if(hfont) |
3691 DeleteObject(hfont); | 3731 DeleteObject(hfont); |
3692 EndPaint(hwnd, &ps); | 3732 EndPaint(hwnd, &ps); |
5709 DW_HWND_OBJECT, | 5749 DW_HWND_OBJECT, |
5710 (HMENU)(uintptr_t)id, | 5750 (HMENU)(uintptr_t)id, |
5711 DWInstance, | 5751 DWInstance, |
5712 NULL); | 5752 NULL); |
5713 cinfo->fore = cinfo->back = -1; | 5753 cinfo->fore = cinfo->back = -1; |
5714 cinfo->pOldProc = SubclassWindow(tmp, _simplewndproc); | 5754 cinfo->pOldProc = SubclassWindow(tmp, _notebookwndproc); |
5715 SetWindowLongPtr(tmp, GWLP_USERDATA, (LONG_PTR)cinfo); | 5755 SetWindowLongPtr(tmp, GWLP_USERDATA, (LONG_PTR)cinfo); |
5716 dw_window_set_data(tmp, "_dw_array", (void *)array); | 5756 dw_window_set_data(tmp, "_dw_array", (void *)array); |
5717 dw_window_set_font(tmp, DefaultFont); | 5757 dw_window_set_font(tmp, DefaultFont); |
5718 return tmp; | 5758 return tmp; |
5719 } | 5759 } |