comparison win/dw.c @ 1975:b2cb0ef3ec3d

Win: Added partial or full dark mode support for containers, trees and toolbars. Fixed a warning due to a failure to include dirent.h for getcwd(). Tree and container now support foreground and background colors. Container header and stripe colors still need work. Toolbar widgets must not have a style set to function properly, so skip them.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Wed, 07 Aug 2019 00:25:15 +0000
parents 69d0b37082d0
children 775ea7d5f497
comparison
equal deleted inserted replaced
1974:a806773066f6 1975:b2cb0ef3ec3d
744 { 744 {
745 if(_DW_DARK_MODE_SUPPORTED) 745 if(_DW_DARK_MODE_SUPPORTED)
746 { 746 {
747 if(_DW_DARK_MODE_ALLOWED == 2) 747 if(_DW_DARK_MODE_ALLOWED == 2)
748 { 748 {
749 if(_DW_DARK_MODE_ENABLED) 749 #ifdef TOOLBAR
750 _SetWindowTheme(window, L"DarkMode_Explorer", NULL); 750 TCHAR tmpbuf[100] = {0};
751 else 751
752 _SetWindowTheme(window, L"Explorer", NULL); 752 GetClassName(window, tmpbuf, 99);
753
754 /* Toolbar controls don't display properly with visual styles enabled */
755 if(_tcsnicmp(tmpbuf, TOOLBARCLASSNAME, _tcslen(TOOLBARCLASSNAME)+1) != 0)
756 #endif
757 {
758 if(_DW_DARK_MODE_ENABLED)
759 _SetWindowTheme(window, L"DarkMode_Explorer", NULL);
760 else
761 _SetWindowTheme(window, L"Explorer", NULL);
762 }
753 } 763 }
754 return _AllowDarkModeForWindow(window, allow); 764 return _AllowDarkModeForWindow(window, allow);
755 } 765 }
756 return FALSE; 766 return FALSE;
757 } 767 }
3149 case WM_COMMAND: 3159 case WM_COMMAND:
3150 case WM_NOTIFY: 3160 case WM_NOTIFY:
3151 case WM_MOUSEMOVE: 3161 case WM_MOUSEMOVE:
3152 _wndproc(hWnd, msg, mp1, mp2); 3162 _wndproc(hWnd, msg, mp1, mp2);
3153 break; 3163 break;
3164 #ifdef AEROGLASS
3165 case WM_THEMECHANGED:
3166 if(_DW_DARK_MODE_ALLOWED == 2 && _DW_DARK_MODE_SUPPORTED)
3167 {
3168 if(!continfo || continfo->cinfo.back == -1 || continfo->cinfo.back == DW_CLR_DEFAULT)
3169 {
3170 COLORREF bk = _DW_GetSysColor(COLOR_WINDOW);
3171
3172 ListView_SetBkColor(hWnd, bk);
3173 ListView_SetTextBkColor(hWnd, bk);
3174 }
3175 if(!continfo || continfo->cinfo.fore == -1 || continfo->cinfo.fore == DW_CLR_DEFAULT)
3176 ListView_SetTextColor(hWnd, _DW_GetSysColor(COLOR_WINDOWTEXT));
3177 }
3178 break;
3179 #endif
3154 case WM_PAINT: 3180 case WM_PAINT:
3155 if(continfo->cinfo.pOldProc && (continfo->even != DW_RGB_TRANSPARENT || continfo->odd != DW_RGB_TRANSPARENT)) 3181 if(continfo->cinfo.pOldProc && (continfo->even != DW_RGB_TRANSPARENT || continfo->odd != DW_RGB_TRANSPARENT))
3156 { 3182 {
3157 RECT rectUpd, rectDestin, rectThis, *rect = &rectThis; 3183 RECT rectUpd, rectDestin, rectThis, *rect = &rectThis;
3158 int iItems, iTop, i; 3184 int iItems, iTop, i;
3322 if(!cinfo || !cinfo->cinfo.pOldProc) 3348 if(!cinfo || !cinfo->cinfo.pOldProc)
3323 return DefWindowProc(hWnd, msg, mp1, mp2); 3349 return DefWindowProc(hWnd, msg, mp1, mp2);
3324 return CallWindowProc(cinfo->cinfo.pOldProc, hWnd, msg, mp1, mp2); 3350 return CallWindowProc(cinfo->cinfo.pOldProc, hWnd, msg, mp1, mp2);
3325 } 3351 }
3326 return ret; 3352 return ret;
3353 }
3354
3355 LRESULT CALLBACK _treewndproc(HWND hWnd, UINT msg, WPARAM mp1, LPARAM mp2)
3356 {
3357 #ifdef AEROGLASS
3358 if(msg == WM_THEMECHANGED)
3359 {
3360 if(_DW_DARK_MODE_ALLOWED == 2 && _DW_DARK_MODE_SUPPORTED)
3361 {
3362 ContainerInfo *continfo = (ContainerInfo *)GetWindowLongPtr(hWnd, GWLP_USERDATA);
3363
3364 if(!continfo || continfo->cinfo.back == -1 || continfo->cinfo.back == DW_CLR_DEFAULT)
3365 TreeView_SetBkColor(hWnd, _DW_GetSysColor(COLOR_WINDOW));
3366 if(!continfo || continfo->cinfo.fore == -1 || continfo->cinfo.fore == DW_CLR_DEFAULT)
3367 TreeView_SetTextColor(hWnd, _DW_GetSysColor(COLOR_WINDOWTEXT));
3368 }
3369 }
3370 #endif
3371 return _simplewndproc(hWnd, msg, mp1, mp2);
3327 } 3372 }
3328 3373
3329 void _changebox(Box *thisbox, int percent, int type) 3374 void _changebox(Box *thisbox, int percent, int type)
3330 { 3375 {
3331 int z; 3376 int z;
6100 { 6145 {
6101 DestroyWindow(tmp); 6146 DestroyWindow(tmp);
6102 return NULL; 6147 return NULL;
6103 } 6148 }
6104 6149
6105 cinfo->cinfo.pOldProc = SubclassWindow(tmp, _simplewndproc); 6150 cinfo->cinfo.pOldProc = SubclassWindow(tmp, _treewndproc);
6106 cinfo->cinfo.fore = cinfo->cinfo.back = -1; 6151 cinfo->cinfo.fore = cinfo->cinfo.back = -1;
6107 cinfo->odd = cinfo->even = DW_RGB_TRANSPARENT; 6152 cinfo->odd = cinfo->even = DW_RGB_TRANSPARENT;
6108 6153
6109 SetWindowLongPtr(tmp, GWLP_USERDATA, (LONG_PTR)cinfo); 6154 SetWindowLongPtr(tmp, GWLP_USERDATA, (LONG_PTR)cinfo);
6110 dw_window_set_font(tmp, DefaultFont); 6155 dw_window_set_font(tmp, DefaultFont);