comparison win/dw.c @ 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 6c55d68fd08a
children a71ec02f3b70
comparison
equal deleted inserted replaced
1534:ad8181f70f31 1535:2913bb58f439
1058 if(!handle) 1058 if(!handle)
1059 return; 1059 return;
1060 1060
1061 GetClassName(handle, tmpbuf, 99); 1061 GetClassName(handle, tmpbuf, 99);
1062 1062
1063 if(strnicmp(tmpbuf, ClassName, strlen(ClassName))!=0) 1063 if(strnicmp(tmpbuf, ClassName, strlen(ClassName)+1)!=0)
1064 return; 1064 return;
1065 1065
1066 1066
1067 if(handle) 1067 if(handle)
1068 thisbox = (Box *)GetWindowLongPtr(handle, GWLP_USERDATA); 1068 thisbox = (Box *)GetWindowLongPtr(handle, GWLP_USERDATA);
2084 /* Now that any handlers are done... do normal processing */ 2084 /* Now that any handlers are done... do normal processing */
2085 switch( msg ) 2085 switch( msg )
2086 { 2086 {
2087 #ifdef AEROGLASS 2087 #ifdef AEROGLASS
2088 case WM_DWMCOMPOSITIONCHANGED: 2088 case WM_DWMCOMPOSITIONCHANGED:
2089 if(_DwmIsCompositionEnabled) 2089 {
2090 _DwmIsCompositionEnabled(&_dw_composition); 2090 DWORD styleex = GetWindowLongPtr(hWnd, GWL_EXSTYLE);
2091
2092 if(_DwmIsCompositionEnabled)
2093 _DwmIsCompositionEnabled(&_dw_composition);
2094
2095 /* If we are no longer compositing... disable layered windows */
2096 if(!_dw_composition && (styleex & WS_EX_LAYERED))
2097 {
2098 MARGINS mar = {0};
2099
2100 SetWindowLongPtr(hWnd, GWL_EXSTYLE, styleex & ~WS_EX_LAYERED);
2101 if(_DwmExtendFrameIntoClientArea)
2102 _DwmExtendFrameIntoClientArea(hWnd, &mar);
2103 }
2104 }
2091 break; 2105 break;
2106 #endif
2107 #ifdef AEROGLASS1
2092 case WM_ERASEBKGND: 2108 case WM_ERASEBKGND:
2093 if(_dw_composition) 2109 if(_dw_composition && (GetWindowLongPtr(hWnd, GWL_EXSTYLE) & WS_EX_LAYERED))
2094 { 2110 {
2095 static HBRUSH hbrush = 0; 2111 static HBRUSH hbrush = 0;
2096 RECT rect; 2112 RECT rect;
2097 2113
2098 if(!hbrush) 2114 if(!hbrush)
2099 hbrush = CreateSolidBrush(_dw_transparencykey); 2115 hbrush = CreateSolidBrush(_dw_transparencykey);
2100 2116
2101 GetClientRect(hWnd, &rect); 2117 GetClientRect(hWnd, &rect);
2102 FillRect((HDC)mp1, &rect, hbrush); 2118 FillRect((HDC)mp1, &rect, hbrush);
2103 } 2119 return TRUE;
2104 return TRUE; 2120 }
2121 break;
2105 #endif 2122 #endif
2106 case WM_PAINT: 2123 case WM_PAINT:
2107 { 2124 {
2108 PAINTSTRUCT ps; 2125 PAINTSTRUCT ps;
2109 2126
2264 case WM_MOUSEMOVE: 2281 case WM_MOUSEMOVE:
2265 _wndproc(hWnd, msg, mp1, mp2); 2282 _wndproc(hWnd, msg, mp1, mp2);
2266 break; 2283 break;
2267 #ifdef AEROGLASS 2284 #ifdef AEROGLASS
2268 case WM_ERASEBKGND: 2285 case WM_ERASEBKGND:
2269 if(_dw_composition) 2286 if(_dw_composition && (GetWindowLongPtr(_toplevel_window(hWnd), GWL_EXSTYLE) & WS_EX_LAYERED))
2270 { 2287 {
2271 static HBRUSH hbrush = 0; 2288 static HBRUSH hbrush = 0;
2272 RECT rect; 2289 RECT rect;
2273 2290
2274 if(!hbrush) 2291 if(!hbrush)
2275 hbrush = CreateSolidBrush(_dw_transparencykey); 2292 hbrush = CreateSolidBrush(_dw_transparencykey);
2276 2293
2277 GetClientRect(hWnd, &rect); 2294 GetClientRect(hWnd, &rect);
2278 FillRect((HDC)mp1, &rect, hbrush); 2295 FillRect((HDC)mp1, &rect, hbrush);
2279 } 2296 return TRUE;
2280 return TRUE; 2297 }
2298 break;
2281 #endif 2299 #endif
2282 case WM_PAINT: 2300 case WM_PAINT:
2283 { 2301 {
2284 ColorInfo *thiscinfo = (ColorInfo *)GetWindowLongPtr(hWnd, GWLP_USERDATA); 2302 ColorInfo *thiscinfo = (ColorInfo *)GetWindowLongPtr(hWnd, GWLP_USERDATA);
2285 2303
2731 { 2749 {
2732 case WM_CTLCOLORSTATIC: 2750 case WM_CTLCOLORSTATIC:
2733 case WM_CTLCOLORBTN: 2751 case WM_CTLCOLORBTN:
2734 case WM_CTLCOLORDLG: 2752 case WM_CTLCOLORDLG:
2735 { 2753 {
2736 if(_dw_composition && (!thiscinfo || (thiscinfo && 2754
2737 (thiscinfo->back == -1 || thiscinfo->back == DW_RGB_TRANSPARENT)))) 2755 if((_dw_composition && GetWindowLongPtr(_toplevel_window(hWnd), GWL_EXSTYLE) & WS_EX_LAYERED) &&
2756 (!thiscinfo || (thiscinfo && (thiscinfo->back == -1 || thiscinfo->back == DW_RGB_TRANSPARENT))))
2738 { 2757 {
2739 if(!(msg == WM_CTLCOLORSTATIC && SendMessage((HWND)mp2, STM_GETIMAGE, IMAGE_BITMAP, 0))) 2758 if(!(msg == WM_CTLCOLORSTATIC && SendMessage((HWND)mp2, STM_GETIMAGE, IMAGE_BITMAP, 0)))
2740 { 2759 {
2741 SetBkColor((HDC)mp1, _dw_transparencykey); 2760 SetBkColor((HDC)mp1, _dw_transparencykey);
2742 if(thiscinfo->hbrush) 2761 if(thiscinfo->hbrush)
4629 Box *newbox = calloc(sizeof(Box), 1); 4648 Box *newbox = calloc(sizeof(Box), 1);
4630 ULONG flStyleEx = 0; 4649 ULONG flStyleEx = 0;
4631 #ifdef AEROGLASS 4650 #ifdef AEROGLASS
4632 MARGINS mar = {-1}; 4651 MARGINS mar = {-1};
4633 4652
4634 if(_dw_composition) 4653 if(_dw_composition && (flStyle & DW_FCF_COMPOSITED))
4635 flStyleEx = WS_EX_LAYERED; 4654 flStyleEx = WS_EX_LAYERED;
4636 #endif 4655 #endif
4637 4656
4638 newbox->type = DW_VERT; 4657 newbox->type = DW_VERT;
4639 newbox->vsize = newbox->hsize = SIZEEXPAND; 4658 newbox->vsize = newbox->hsize = SIZEEXPAND;
4640 newbox->cinfo.fore = newbox->cinfo.back = -1; 4659 newbox->cinfo.fore = newbox->cinfo.back = -1;
4641 4660
4642 if(!(flStyle & WS_CAPTION)) 4661 if(!(flStyle & WS_CAPTION))
4643 flStyle |= WS_POPUPWINDOW; 4662 flStyle |= WS_POPUPWINDOW;
4644 4663
4645 if(flStyle & DW_FCF_TASKLIST) 4664 if(flStyle & DW_FCF_TASKLIST ||
4646 { 4665 flStyle & WS_VSCROLL /* This is deprecated and should go away in version 3? */)
4647 ULONG newflags = (flStyle | WS_CLIPCHILDREN) & ~DW_FCF_TASKLIST; 4666 {
4648 4667 hwndframe = CreateWindowEx(flStyleEx, ClassName, title, (flStyle | WS_CLIPCHILDREN) & 0xffdf0000, CW_USEDEFAULT, CW_USEDEFAULT,
4649 hwndframe = CreateWindowEx(flStyleEx, ClassName, title, newflags, CW_USEDEFAULT, CW_USEDEFAULT,
4650 0, 0, hwndOwner, NULL, DWInstance, NULL); 4668 0, 0, hwndOwner, NULL, DWInstance, NULL);
4651 } 4669 }
4652 else 4670 else
4653 { 4671 {
4654 flStyleEx |= WS_EX_TOOLWINDOW; 4672 flStyleEx |= WS_EX_TOOLWINDOW;
4655 4673
4656 hwndframe = CreateWindowEx(flStyleEx, ClassName, title, flStyle | WS_CLIPCHILDREN, CW_USEDEFAULT, CW_USEDEFAULT, 4674 hwndframe = CreateWindowEx(flStyleEx, ClassName, title, (flStyle | WS_CLIPCHILDREN) & 0xffff0000, CW_USEDEFAULT, CW_USEDEFAULT,
4657 0, 0, hwndOwner, NULL, DWInstance, NULL); 4675 0, 0, hwndOwner, NULL, DWInstance, NULL);
4658 } 4676 }
4659 SetWindowLongPtr(hwndframe, GWLP_USERDATA, (LONG_PTR)newbox); 4677 SetWindowLongPtr(hwndframe, GWLP_USERDATA, (LONG_PTR)newbox);
4660 4678
4661 if(hwndOwner) 4679 if(hwndOwner)
4662 SetParent(hwndframe, hwndOwner); 4680 SetParent(hwndframe, hwndOwner);
4663 4681
4664 #ifdef AEROGLASS 4682 #ifdef AEROGLASS
4665 /* Attempt to enable Aero glass background on the entire window */ 4683 /* Attempt to enable Aero glass background on the entire window */
4666 if(_DwmExtendFrameIntoClientArea && _dw_composition) 4684 if(_DwmExtendFrameIntoClientArea && _dw_composition && (flStyle & DW_FCF_COMPOSITED))
4667 { 4685 {
4668 SetLayeredWindowAttributes(hwndframe, _dw_transparencykey, 0, LWA_COLORKEY); 4686 SetLayeredWindowAttributes(hwndframe, _dw_transparencykey, 0, LWA_COLORKEY);
4669 _DwmExtendFrameIntoClientArea(hwndframe, &mar); 4687 _DwmExtendFrameIntoClientArea(hwndframe, &mar);
4670 } 4688 }
4671 #endif 4689 #endif
6871 */ 6889 */
6872 void API dw_window_set_style(HWND handle, ULONG style, ULONG mask) 6890 void API dw_window_set_style(HWND handle, ULONG style, ULONG mask)
6873 { 6891 {
6874 ULONG tmp, currentstyle; 6892 ULONG tmp, currentstyle;
6875 ColorInfo *cinfo; 6893 ColorInfo *cinfo;
6876 6894 char tmpbuf[100] = {0};
6895
6896 if(!handle)
6897 return;
6898
6877 if(handle < (HWND)65536) 6899 if(handle < (HWND)65536)
6878 { 6900 {
6879 char buffer[31] = {0}; 6901 char buffer[31] = {0};
6880 HMENU mymenu; 6902 HMENU mymenu;
6881 ULONG id = (ULONG)handle; 6903 ULONG id = (ULONG)handle;
6886 if(mymenu && IsMenu(mymenu)) 6908 if(mymenu && IsMenu(mymenu))
6887 dw_menu_item_set_state((HMENUI)mymenu, id, style & mask); 6909 dw_menu_item_set_state((HMENUI)mymenu, id, style & mask);
6888 return; 6910 return;
6889 } 6911 }
6890 6912
6913 GetClassName(handle, tmpbuf, 99);
6914
6891 currentstyle = GetWindowLong(handle, GWL_STYLE); 6915 currentstyle = GetWindowLong(handle, GWL_STYLE);
6892 cinfo = (ColorInfo *)GetWindowLongPtr(handle, GWLP_USERDATA); 6916 cinfo = (ColorInfo *)GetWindowLongPtr(handle, GWLP_USERDATA);
6893 6917
6894 tmp = currentstyle | mask; 6918 tmp = currentstyle | mask;
6895 tmp ^= mask; 6919 tmp ^= mask;
6896 tmp |= style; 6920 tmp |= style;
6897 6921
6898 /* We are using SS_NOPREFIX as a VCENTER flag */ 6922 if(strnicmp(tmpbuf, ClassName, strlen(ClassName)+1)==0)
6899 if(tmp & SS_NOPREFIX) 6923 {
6900 { 6924 tmp = tmp & 0xffff0000;
6901 6925 #ifdef AEROGLASS
6902 if(cinfo) 6926 if(mask & DW_FCF_COMPOSITED && _DwmExtendFrameIntoClientArea && _dw_composition)
6903 cinfo->vcenter = 1; 6927 {
6904 else 6928 DWORD styleex = GetWindowLongPtr(handle, GWL_EXSTYLE);
6905 { 6929
6906 cinfo = calloc(1, sizeof(ColorInfo)); 6930 if(style & DW_FCF_COMPOSITED)
6907 cinfo->fore = cinfo->back = -1; 6931 {
6908 cinfo->vcenter = 1; 6932 MARGINS mar = {-1};
6909 6933
6910 cinfo->pOldProc = SubclassWindow(handle, _colorwndproc); 6934 /* Attempt to enable Aero glass background on the entire window */
6911 SetWindowLongPtr(handle, GWLP_USERDATA, (LONG_PTR)cinfo); 6935 SetWindowLongPtr(handle, GWL_EXSTYLE, styleex | WS_EX_LAYERED);
6912 } 6936 SetLayeredWindowAttributes(handle, _dw_transparencykey, 0, LWA_COLORKEY);
6913 } 6937 _DwmExtendFrameIntoClientArea(handle, &mar);
6914 else if(cinfo) 6938 }
6915 cinfo->vcenter = 0; 6939 else
6940 {
6941 MARGINS mar = {0};
6942
6943 /* Remove Aero Glass */
6944 SetWindowLongPtr(handle, GWL_EXSTYLE, styleex & ~WS_EX_LAYERED);
6945 _DwmExtendFrameIntoClientArea(handle, &mar);
6946 }
6947 }
6948 #endif
6949 }
6950 else
6951 {
6952 /* We are using SS_NOPREFIX as a VCENTER flag */
6953 if(tmp & SS_NOPREFIX)
6954 {
6955
6956 if(cinfo)
6957 cinfo->vcenter = 1;
6958 else
6959 {
6960 cinfo = calloc(1, sizeof(ColorInfo));
6961 cinfo->fore = cinfo->back = -1;
6962 cinfo->vcenter = 1;
6963
6964 cinfo->pOldProc = SubclassWindow(handle, _colorwndproc);
6965 SetWindowLongPtr(handle, GWLP_USERDATA, (LONG_PTR)cinfo);
6966 }
6967 }
6968 else if(cinfo)
6969 cinfo->vcenter = 0;
6970 }
6916 6971
6917 SetWindowLong(handle, GWL_STYLE, tmp); 6972 SetWindowLong(handle, GWL_STYLE, tmp);
6918 } 6973 }
6919 6974
6920 /* Finds the physical ID from the reference ID */ 6975 /* Finds the physical ID from the reference ID */