changeset 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 a806773066f6
children 775ea7d5f497
files dwcompat.h win/dw.c
diffstat 2 files changed, 51 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/dwcompat.h	Tue Aug 06 22:52:23 2019 +0000
+++ b/dwcompat.h	Wed Aug 07 00:25:15 2019 +0000
@@ -174,6 +174,7 @@
 #define stat(a, b) _stat64(a, b)
 #define dwstat __stat64
 #endif
+#include <direct.h>
 #else
 #include <dir.h>
 #include <dirent.h>
--- a/win/dw.c	Tue Aug 06 22:52:23 2019 +0000
+++ b/win/dw.c	Wed Aug 07 00:25:15 2019 +0000
@@ -746,10 +746,20 @@
    {
       if(_DW_DARK_MODE_ALLOWED == 2)
       {
-         if(_DW_DARK_MODE_ENABLED)
-            _SetWindowTheme(window, L"DarkMode_Explorer", NULL);
-         else
-            _SetWindowTheme(window, L"Explorer", NULL);
+#ifdef TOOLBAR
+         TCHAR tmpbuf[100] = {0};
+         
+         GetClassName(window, tmpbuf, 99);
+
+         /* Toolbar controls don't display properly with visual styles enabled */
+         if(_tcsnicmp(tmpbuf, TOOLBARCLASSNAME, _tcslen(TOOLBARCLASSNAME)+1) != 0)
+#endif
+         {
+            if(_DW_DARK_MODE_ENABLED)
+               _SetWindowTheme(window, L"DarkMode_Explorer", NULL);
+            else
+               _SetWindowTheme(window, L"Explorer", NULL);
+         }
       }
       return _AllowDarkModeForWindow(window, allow);
    }
@@ -3151,6 +3161,22 @@
    case WM_MOUSEMOVE:
       _wndproc(hWnd, msg, mp1, mp2);
       break;
+#ifdef AEROGLASS
+   case WM_THEMECHANGED:
+      if(_DW_DARK_MODE_ALLOWED == 2 && _DW_DARK_MODE_SUPPORTED)
+      {
+         if(!continfo || continfo->cinfo.back == -1 || continfo->cinfo.back == DW_CLR_DEFAULT)
+         {
+            COLORREF bk = _DW_GetSysColor(COLOR_WINDOW);
+
+            ListView_SetBkColor(hWnd, bk);
+            ListView_SetTextBkColor(hWnd, bk);
+         }
+         if(!continfo || continfo->cinfo.fore == -1 || continfo->cinfo.fore == DW_CLR_DEFAULT)
+            ListView_SetTextColor(hWnd, _DW_GetSysColor(COLOR_WINDOWTEXT));
+      }
+      break;
+#endif
    case WM_PAINT:
        if(continfo->cinfo.pOldProc && (continfo->even != DW_RGB_TRANSPARENT || continfo->odd != DW_RGB_TRANSPARENT))
        {
@@ -3326,6 +3352,25 @@
    return ret;
 }
 
+LRESULT CALLBACK _treewndproc(HWND hWnd, UINT msg, WPARAM mp1, LPARAM mp2)
+{
+#ifdef AEROGLASS
+   if(msg == WM_THEMECHANGED)
+   {
+      if(_DW_DARK_MODE_ALLOWED == 2 && _DW_DARK_MODE_SUPPORTED)
+      {
+         ContainerInfo *continfo = (ContainerInfo *)GetWindowLongPtr(hWnd, GWLP_USERDATA);
+         
+         if(!continfo || continfo->cinfo.back == -1 || continfo->cinfo.back == DW_CLR_DEFAULT)
+            TreeView_SetBkColor(hWnd, _DW_GetSysColor(COLOR_WINDOW));
+         if(!continfo || continfo->cinfo.fore == -1 || continfo->cinfo.fore == DW_CLR_DEFAULT)
+            TreeView_SetTextColor(hWnd, _DW_GetSysColor(COLOR_WINDOWTEXT));
+      }
+   }
+#endif
+   return _simplewndproc(hWnd, msg, mp1, mp2);
+}
+
 void _changebox(Box *thisbox, int percent, int type)
 {
    int z;
@@ -6102,7 +6147,7 @@
       return NULL;
    }
 
-   cinfo->cinfo.pOldProc = SubclassWindow(tmp, _simplewndproc);
+   cinfo->cinfo.pOldProc = SubclassWindow(tmp, _treewndproc);
    cinfo->cinfo.fore = cinfo->cinfo.back = -1;
    cinfo->odd = cinfo->even = DW_RGB_TRANSPARENT;