changeset 1535:2913bb58f439

Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently... it enabled composited (translucent) windows on supported versions of Windows (7 and Vista). Deprecated the DW_FCF_VERTSCROLL and DW_FCF_HORZSCROLL flags... use scrollboxes instead. Removed a terrible hack of using the WS_VSCROLL flag to pass task list... applications require a recompile so we will still handle the old WS_VSCROLL flag until version 3.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Wed, 11 Jan 2012 05:36:00 +0000
parents ad8181f70f31
children a71ec02f3b70
files dw.h makefile.vc readme win/dw.c
diffstat 4 files changed, 106 insertions(+), 51 deletions(-) [+]
line wrap: on
line diff
--- a/dw.h	Mon Jan 09 16:04:00 2012 +0000
+++ b/dw.h	Wed Jan 11 05:36:00 2012 +0000
@@ -133,8 +133,6 @@
 #define DW_FCF_MINBUTTON         FCF_MINBUTTON
 #define DW_FCF_MAXBUTTON         FCF_MAXBUTTON
 #define DW_FCF_MINMAX            FCF_MINMAX
-#define DW_FCF_VERTSCROLL        FCF_VERTSCROLL
-#define DW_FCF_HORZSCROLL        FCF_HORZSCROLL
 #define DW_FCF_DLGBORDER         FCF_DLGBORDER
 #define DW_FCF_BORDER            FCF_BORDER
 #define DW_FCF_TASKLIST          FCF_TASKLIST
@@ -344,8 +342,6 @@
 #define DW_FCF_MINBUTTON         (1 << 2) /* NSMiniaturizableWindowMask */
 #define DW_FCF_MAXBUTTON         0
 #define DW_FCF_MINMAX            (1 << 2) /* NSMiniaturizableWindowMask */
-#define DW_FCF_VERTSCROLL        0
-#define DW_FCF_HORZSCROLL        0
 #define DW_FCF_DLGBORDER         0
 #define DW_FCF_BORDER            0
 #define DW_FCF_TASKLIST          0
@@ -525,11 +521,9 @@
 #define DW_FCF_MINBUTTON         WS_MINIMIZEBOX
 #define DW_FCF_MAXBUTTON         WS_MAXIMIZEBOX
 #define DW_FCF_MINMAX            (WS_MINIMIZEBOX|WS_MAXIMIZEBOX)
-#define DW_FCF_VERTSCROLL        WS_VSCROLL
-#define DW_FCF_HORZSCROLL        WS_HSCROLL
 #define DW_FCF_DLGBORDER         WS_DLGFRAME
 #define DW_FCF_BORDER            WS_BORDER
-#define DW_FCF_TASKLIST          WS_VSCROLL
+#define DW_FCF_TASKLIST          (1 << 1)
 #define DW_FCF_NOMOVEWITHOWNER   0
 #define DW_FCF_SYSMODAL          0
 #define DW_FCF_HIDEBUTTON        WS_MINIMIZEBOX
@@ -537,6 +531,7 @@
 #define DW_FCF_AUTOICON          0
 #define DW_FCF_MAXIMIZE          WS_MAXIMIZE
 #define DW_FCF_MINIMIZE          WS_MINIMIZE
+#define DW_FCF_COMPOSITED        1
 
 #define DW_CFA_BITMAPORICON      1
 #define DW_CFA_STRING            (1 << 1)
@@ -806,8 +801,6 @@
 #define DW_FCF_MINBUTTON         Ph_WM_RENDER_MIN
 #define DW_FCF_MAXBUTTON         Ph_WM_RENDER_MAX
 #define DW_FCF_MINMAX            (Ph_WM_RENDER_MIN|Ph_WM_RENDER_MAX)
-#define DW_FCF_VERTSCROLL        0
-#define DW_FCF_HORZSCROLL        0
 #define DW_FCF_DLGBORDER         0
 #define DW_FCF_BORDER            Ph_WM_RENDER_BORDER
 #define DW_FCF_TASKLIST          0
@@ -989,8 +982,6 @@
 #define DW_FCF_MINBUTTON         (1 << 4)
 #define DW_FCF_MAXBUTTON         (1 << 5)
 #define DW_FCF_MINMAX            (1 << 6)
-#define DW_FCF_VERTSCROLL        (1 << 7)
-#define DW_FCF_HORZSCROLL        (1 << 8)
 #define DW_FCF_DLGBORDER         (1 << 9)
 #define DW_FCF_BORDER            (1 << 10)
 #define DW_FCF_TASKLIST          (1 << 12)
@@ -1348,6 +1339,8 @@
 #define BOXVERT DW_VERT
 #define DW_FCF_SHELLPOSITION     0
 #define DW_FCF_NOBYTEALIGN       0
+#define DW_FCF_VERTSCROLL        0
+#define DW_FCF_HORZSCROLL        0
 
 /* Scrolling constants */
 #define DW_SCROLL_UP 0
@@ -1425,6 +1418,10 @@
 #define DW_POINTER_TO_UINT(a) ((unsigned int)a)
 #endif
 
+#ifndef DW_FCF_COMPOSITED
+#define DW_FCF_COMPOSITED        0
+#endif
+
 #ifndef API
 #define API
 #endif
--- a/makefile.vc	Mon Jan 09 16:04:00 2012 +0000
+++ b/makefile.vc	Wed Jan 11 05:36:00 2012 +0000
@@ -58,7 +58,7 @@
 !endif
 
 CC = cl
-CFLAGS = -c $(PLATFORM_DEF) -D__WIN32__ -DMSVC -DGDIPLUS -DBUILD_DLL -DISOLATION_AWARE_ENABLED=1 -I$(SRCDIR)\platform -I$(SRCDIR) $(SVNVERSION)
+CFLAGS = -c $(PLATFORM_DEF) -D__WIN32__ -DMSVC -DGDIPLUS -DAEROGLASS -DBUILD_DLL -DISOLATION_AWARE_ENABLED=1 -I$(SRCDIR)\platform -I$(SRCDIR) $(SVNVERSION)
 LIBS = wsock32.lib kernel32.lib user32.lib comctl32.lib gdi32.lib advapi32.lib shell32.lib comdlg32.lib ole32.lib oleaut32.lib userenv.lib msimg32.lib gdiplus.lib
 RES =
 LINKFLAGS = -machine:$(TARGET_CPU) -manifest $(LINK_DEBUG)
--- a/readme	Mon Jan 09 16:04:00 2012 +0000
+++ b/readme	Wed Jan 11 05:36:00 2012 +0000
@@ -53,11 +53,14 @@
 Added DW_DRAW_NOAA which can be passed to dw_draw_*() API functions
    that accept the flags parameter to disable anti-aliasing.
 Added dw_main_quit() to cause the dw_main() message loop to return.
+Added DW_FCF_COMPOSITED to enable Aero Glass effects on Windows 7 and Vista.
 Fixed auto-sizing top-level windows on Windows; added on OS/2 and Mac.
 Fixed bubble help not being displayed on Windows.
 Fixed menu bar items remaining highlighted on Mac 10.6 and later.
 Fixed OS/2 and Windows showing windows during dw_window_set_pos/size().
-Deprecated DW_FCF_NOBYTEALIGN and DW_FCF_SHELLPOSITION flags.
+Deprecated DW_FCF_NOBYTEALIGN, DW_FCF_SHELLPOSITION, DW_FCF_HORZSCROLL and
+   DW_FCF_VERTSCROLL flags.
+
 
 Dynamic Windows Documentation is available at:
 
--- a/win/dw.c	Mon Jan 09 16:04:00 2012 +0000
+++ b/win/dw.c	Wed Jan 11 05:36:00 2012 +0000
@@ -1060,7 +1060,7 @@
 
    GetClassName(handle, tmpbuf, 99);
 
-   if(strnicmp(tmpbuf, ClassName, strlen(ClassName))!=0)
+   if(strnicmp(tmpbuf, ClassName, strlen(ClassName)+1)!=0)
       return;
 
 
@@ -2086,11 +2086,27 @@
    {
 #ifdef AEROGLASS   
    case WM_DWMCOMPOSITIONCHANGED:
-      if(_DwmIsCompositionEnabled)
-         _DwmIsCompositionEnabled(&_dw_composition);
+      {
+         DWORD styleex = GetWindowLongPtr(hWnd, GWL_EXSTYLE);
+         
+         if(_DwmIsCompositionEnabled)
+            _DwmIsCompositionEnabled(&_dw_composition);
+         
+         /* If we are no longer compositing... disable layered windows */
+         if(!_dw_composition && (styleex & WS_EX_LAYERED))
+         {
+            MARGINS mar = {0};
+            
+            SetWindowLongPtr(hWnd, GWL_EXSTYLE, styleex & ~WS_EX_LAYERED);
+            if(_DwmExtendFrameIntoClientArea)
+               _DwmExtendFrameIntoClientArea(hWnd, &mar);
+         }
+      }
       break;
+#endif
+#ifdef AEROGLASS1      
    case WM_ERASEBKGND: 
-      if(_dw_composition)
+      if(_dw_composition && (GetWindowLongPtr(hWnd, GWL_EXSTYLE) & WS_EX_LAYERED))
       {
          static HBRUSH hbrush = 0;
          RECT rect;
@@ -2100,8 +2116,9 @@
             
          GetClientRect(hWnd, &rect);
          FillRect((HDC)mp1, &rect, hbrush);
-      }
-      return TRUE;
+         return TRUE;
+      }
+      break;
 #endif      
    case WM_PAINT:
       {
@@ -2266,7 +2283,7 @@
       break;
 #ifdef AEROGLASS   
    case WM_ERASEBKGND: 
-      if(_dw_composition)
+      if(_dw_composition && (GetWindowLongPtr(_toplevel_window(hWnd), GWL_EXSTYLE) & WS_EX_LAYERED))
       {
          static HBRUSH hbrush = 0;
          RECT rect;
@@ -2276,8 +2293,9 @@
             
          GetClientRect(hWnd, &rect);
          FillRect((HDC)mp1, &rect, hbrush);
-      }
-      return TRUE;
+         return TRUE;
+      }
+      break;
 #endif      
    case WM_PAINT:
       {
@@ -2733,8 +2751,9 @@
                case WM_CTLCOLORBTN:
                case WM_CTLCOLORDLG:
                   {
-                     if(_dw_composition && (!thiscinfo || (thiscinfo && 
-                        (thiscinfo->back == -1 || thiscinfo->back == DW_RGB_TRANSPARENT))))
+                     
+                     if((_dw_composition && GetWindowLongPtr(_toplevel_window(hWnd), GWL_EXSTYLE) & WS_EX_LAYERED) && 
+                        (!thiscinfo || (thiscinfo && (thiscinfo->back == -1 || thiscinfo->back == DW_RGB_TRANSPARENT))))
                      {
                         if(!(msg == WM_CTLCOLORSTATIC && SendMessage((HWND)mp2, STM_GETIMAGE, IMAGE_BITMAP, 0)))
                         {
@@ -4631,7 +4650,7 @@
 #ifdef AEROGLASS
    MARGINS mar = {-1};
    
-   if(_dw_composition)
+   if(_dw_composition && (flStyle & DW_FCF_COMPOSITED))
       flStyleEx = WS_EX_LAYERED;
 #endif
 
@@ -4642,18 +4661,17 @@
    if(!(flStyle & WS_CAPTION))
       flStyle |= WS_POPUPWINDOW;
 
-   if(flStyle & DW_FCF_TASKLIST)
-   {
-      ULONG newflags = (flStyle | WS_CLIPCHILDREN) & ~DW_FCF_TASKLIST;
-
-      hwndframe = CreateWindowEx(flStyleEx, ClassName, title, newflags, CW_USEDEFAULT, CW_USEDEFAULT,
+   if(flStyle & DW_FCF_TASKLIST ||
+      flStyle & WS_VSCROLL /* This is deprecated and should go away in version 3? */)
+   {
+      hwndframe = CreateWindowEx(flStyleEx, ClassName, title, (flStyle | WS_CLIPCHILDREN) & 0xffdf0000, CW_USEDEFAULT, CW_USEDEFAULT,
                            0, 0, hwndOwner, NULL, DWInstance, NULL);
    }
    else
    {
       flStyleEx |= WS_EX_TOOLWINDOW;
 
-      hwndframe = CreateWindowEx(flStyleEx, ClassName, title, flStyle | WS_CLIPCHILDREN, CW_USEDEFAULT, CW_USEDEFAULT,
+      hwndframe = CreateWindowEx(flStyleEx, ClassName, title, (flStyle | WS_CLIPCHILDREN) & 0xffff0000, CW_USEDEFAULT, CW_USEDEFAULT,
                            0, 0, hwndOwner, NULL, DWInstance, NULL);
    }
    SetWindowLongPtr(hwndframe, GWLP_USERDATA, (LONG_PTR)newbox);
@@ -4663,7 +4681,7 @@
 
 #ifdef AEROGLASS
    /* Attempt to enable Aero glass background on the entire window */
-   if(_DwmExtendFrameIntoClientArea && _dw_composition)
+   if(_DwmExtendFrameIntoClientArea && _dw_composition && (flStyle & DW_FCF_COMPOSITED))
    {
       SetLayeredWindowAttributes(hwndframe, _dw_transparencykey, 0, LWA_COLORKEY);
       _DwmExtendFrameIntoClientArea(hwndframe, &mar);
@@ -6873,7 +6891,11 @@
 {
    ULONG tmp, currentstyle;
    ColorInfo *cinfo;
-   
+   char tmpbuf[100] = {0};
+
+   if(!handle)
+      return;
+
    if(handle < (HWND)65536)
    {
       char buffer[31] = {0};
@@ -6888,6 +6910,8 @@
       return;
    }
    
+   GetClassName(handle, tmpbuf, 99);
+
    currentstyle = GetWindowLong(handle, GWL_STYLE);
    cinfo = (ColorInfo *)GetWindowLongPtr(handle, GWLP_USERDATA);
 
@@ -6895,24 +6919,55 @@
    tmp ^= mask;
    tmp |= style;
 
-   /* We are using SS_NOPREFIX as a VCENTER flag */
-   if(tmp & SS_NOPREFIX)
-   {
-
-      if(cinfo)
-         cinfo->vcenter = 1;
-      else
-      {
-         cinfo = calloc(1, sizeof(ColorInfo));
-         cinfo->fore = cinfo->back = -1;
-         cinfo->vcenter = 1;
-
-         cinfo->pOldProc = SubclassWindow(handle, _colorwndproc);
-         SetWindowLongPtr(handle, GWLP_USERDATA, (LONG_PTR)cinfo);
-      }
-   }
-   else if(cinfo)
-      cinfo->vcenter = 0;
+   if(strnicmp(tmpbuf, ClassName, strlen(ClassName)+1)==0)
+   {
+      tmp = tmp & 0xffff0000;
+#ifdef AEROGLASS      
+      if(mask & DW_FCF_COMPOSITED && _DwmExtendFrameIntoClientArea && _dw_composition)
+      {
+         DWORD styleex = GetWindowLongPtr(handle, GWL_EXSTYLE);
+         
+         if(style & DW_FCF_COMPOSITED)
+         {
+            MARGINS mar = {-1};
+            
+            /* Attempt to enable Aero glass background on the entire window */
+            SetWindowLongPtr(handle, GWL_EXSTYLE, styleex | WS_EX_LAYERED);
+            SetLayeredWindowAttributes(handle, _dw_transparencykey, 0, LWA_COLORKEY);
+            _DwmExtendFrameIntoClientArea(handle, &mar);
+         }
+         else
+         {
+            MARGINS mar = {0};
+            
+            /* Remove Aero Glass */
+            SetWindowLongPtr(handle, GWL_EXSTYLE, styleex & ~WS_EX_LAYERED);
+            _DwmExtendFrameIntoClientArea(handle, &mar);
+         }
+      }
+#endif      
+   }
+   else
+   {
+      /* We are using SS_NOPREFIX as a VCENTER flag */
+      if(tmp & SS_NOPREFIX)
+      {
+
+         if(cinfo)
+            cinfo->vcenter = 1;
+         else
+         {
+            cinfo = calloc(1, sizeof(ColorInfo));
+            cinfo->fore = cinfo->back = -1;
+            cinfo->vcenter = 1;
+
+            cinfo->pOldProc = SubclassWindow(handle, _colorwndproc);
+            SetWindowLongPtr(handle, GWLP_USERDATA, (LONG_PTR)cinfo);
+         }
+      }
+      else if(cinfo)
+         cinfo->vcenter = 0;
+   }
 
    SetWindowLong(handle, GWL_STYLE, tmp);
 }