comparison win/dw.c @ 1516:03c0eca3aaba

Glass window improvement on Windows... mostly usable... checkboxes, groupboxes and static text may need some care. Doesn't draw as nicely due to use of WM_ERASEBKGND but it looks cool. :)
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Thu, 29 Dec 2011 14:39:58 +0000
parents a26edf086082
children bd538277e1e8
comparison
equal deleted inserted replaced
1515:a26edf086082 1516:03c0eca3aaba
106 106
107 #ifdef AEROGLASS 107 #ifdef AEROGLASS
108 HRESULT (WINAPI *_DwmExtendFrameIntoClientArea)(HWND hWnd, const MARGINS *pMarInset) = 0; 108 HRESULT (WINAPI *_DwmExtendFrameIntoClientArea)(HWND hWnd, const MARGINS *pMarInset) = 0;
109 HRESULT (WINAPI *_DwmIsCompositionEnabled)(BOOL *pfEnabled) = 0; 109 HRESULT (WINAPI *_DwmIsCompositionEnabled)(BOOL *pfEnabled) = 0;
110 BOOL _dw_composition = FALSE; 110 BOOL _dw_composition = FALSE;
111 COLORREF _dw_transparencykey = RGB(200,201,202);
111 #endif 112 #endif
112 113
113 /* 114 /*
114 * MinGW Is missing a bunch of definitions 115 * MinGW Is missing a bunch of definitions
115 * so #define them here... 116 * so #define them here...
2090 { 2091 {
2091 static HBRUSH hbrush = 0; 2092 static HBRUSH hbrush = 0;
2092 RECT rect; 2093 RECT rect;
2093 2094
2094 if(!hbrush) 2095 if(!hbrush)
2095 hbrush = CreateSolidBrush(RGB(0,0,0)); 2096 hbrush = CreateSolidBrush(_dw_transparencykey);
2096 2097
2097 GetClientRect(hWnd, &rect); 2098 GetClientRect(hWnd, &rect);
2098 FillRect((HDC)mp1, &rect, hbrush); 2099 FillRect((HDC)mp1, &rect, hbrush);
2099 } 2100 }
2100 return TRUE; 2101 return TRUE;
2225 case WM_CTLCOLORBTN: 2226 case WM_CTLCOLORBTN:
2226 case WM_CTLCOLOREDIT: 2227 case WM_CTLCOLOREDIT:
2227 case WM_CTLCOLORMSGBOX: 2228 case WM_CTLCOLORMSGBOX:
2228 case WM_CTLCOLORSCROLLBAR: 2229 case WM_CTLCOLORSCROLLBAR:
2229 case WM_CTLCOLORDLG: 2230 case WM_CTLCOLORDLG:
2230 { 2231 return _colorwndproc(hWnd, msg, mp1, mp2);
2231 ColorInfo *thiscinfo = (ColorInfo *)GetWindowLongPtr((HWND)mp2, GWLP_USERDATA);
2232 if(thiscinfo && thiscinfo->fore != -1 && thiscinfo->back != -1)
2233 {
2234 /* Handle foreground */
2235 if(thiscinfo->fore > -1 && thiscinfo->fore < 18)
2236 {
2237 if(thiscinfo->fore != DW_CLR_DEFAULT)
2238 {
2239 SetTextColor((HDC)mp1, RGB(_red[thiscinfo->fore],
2240 _green[thiscinfo->fore],
2241 _blue[thiscinfo->fore]));
2242 }
2243 }
2244 else if((thiscinfo->fore & DW_RGB_COLOR) == DW_RGB_COLOR)
2245 {
2246 SetTextColor((HDC)mp1, RGB(DW_RED_VALUE(thiscinfo->fore),
2247 DW_GREEN_VALUE(thiscinfo->fore),
2248 DW_BLUE_VALUE(thiscinfo->fore)));
2249 }
2250 /* Handle background */
2251 if(thiscinfo->back > -1 && thiscinfo->back < 18)
2252 {
2253 if(thiscinfo->back == DW_CLR_DEFAULT)
2254 {
2255 HBRUSH hbr = GetSysColorBrush(COLOR_3DFACE);
2256
2257 SelectObject((HDC)mp1, hbr);
2258 return (LONG)hbr;
2259 }
2260 else
2261 {
2262 SetBkColor((HDC)mp1, RGB(_red[thiscinfo->back],
2263 _green[thiscinfo->back],
2264 _blue[thiscinfo->back]));
2265 if(thiscinfo->hbrush)
2266 DeleteObject(thiscinfo->hbrush);
2267 thiscinfo->hbrush = CreateSolidBrush(RGB(_red[thiscinfo->back],
2268 _green[thiscinfo->back],
2269 _blue[thiscinfo->back]));
2270 SelectObject((HDC)mp1, thiscinfo->hbrush);
2271 }
2272 return (LONG)thiscinfo->hbrush;
2273 }
2274 else if((thiscinfo->back & DW_RGB_COLOR) == DW_RGB_COLOR)
2275 {
2276 SetBkColor((HDC)mp1, RGB(DW_RED_VALUE(thiscinfo->back),
2277 DW_GREEN_VALUE(thiscinfo->back),
2278 DW_BLUE_VALUE(thiscinfo->back)));
2279 if(thiscinfo->hbrush)
2280 DeleteObject(thiscinfo->hbrush);
2281 thiscinfo->hbrush = CreateSolidBrush(RGB(DW_RED_VALUE(thiscinfo->back),
2282 DW_GREEN_VALUE(thiscinfo->back),
2283 DW_BLUE_VALUE(thiscinfo->back)));
2284 SelectObject((HDC)mp1, thiscinfo->hbrush);
2285 return (LONG)thiscinfo->hbrush;
2286 }
2287 }
2288 }
2289 break;
2290 } 2232 }
2291 if(result != -1) 2233 if(result != -1)
2292 { 2234 {
2293 /* Make sure any queued redraws are handled */ 2235 /* Make sure any queued redraws are handled */
2294 _dw_redraw(0, FALSE); 2236 _dw_redraw(0, FALSE);
2324 { 2266 {
2325 static HBRUSH hbrush = 0; 2267 static HBRUSH hbrush = 0;
2326 RECT rect; 2268 RECT rect;
2327 2269
2328 if(!hbrush) 2270 if(!hbrush)
2329 hbrush = CreateSolidBrush(RGB(0,0,0)); 2271 hbrush = CreateSolidBrush(_dw_transparencykey);
2330 2272
2331 GetClientRect(hWnd, &rect); 2273 GetClientRect(hWnd, &rect);
2332 FillRect((HDC)mp1, &rect, hbrush); 2274 FillRect((HDC)mp1, &rect, hbrush);
2333 } 2275 }
2334 return TRUE; 2276 return TRUE;
2785 { 2727 {
2786 case WM_CTLCOLORSTATIC: 2728 case WM_CTLCOLORSTATIC:
2787 case WM_CTLCOLORBTN: 2729 case WM_CTLCOLORBTN:
2788 case WM_CTLCOLORDLG: 2730 case WM_CTLCOLORDLG:
2789 { 2731 {
2790 if(thiscinfo && (thiscinfo->fore == -1 || thiscinfo->fore == DW_CLR_DEFAULT)) 2732 if(_dw_composition && (!thiscinfo || (thiscinfo &&
2791 SetTextColor((HDC)mp1, RGB(128,128,128)); 2733 (thiscinfo->back == -1 || thiscinfo->back == DW_RGB_TRANSPARENT))))
2792 if(thiscinfo && (thiscinfo->back == -1 || thiscinfo->back == DW_RGB_TRANSPARENT))
2793 { 2734 {
2794 SetBkMode((HDC)mp1, TRANSPARENT); 2735 SetBkMode((HDC)mp1, TRANSPARENT);
2795 if(thiscinfo->hbrush) 2736 if(thiscinfo && thiscinfo->hbrush)
2737 {
2796 DeleteObject(thiscinfo->hbrush); 2738 DeleteObject(thiscinfo->hbrush);
2797 thiscinfo->hbrush = 0; 2739 thiscinfo->hbrush = 0;
2740 }
2798 return (LONG)GetStockObject(NULL_BRUSH); 2741 return (LONG)GetStockObject(NULL_BRUSH);
2799 } 2742 }
2800 } 2743 }
2801 } 2744 }
2802 #endif 2745 #endif
2803 } 2746 }
2804 break; 2747 break;
2805 } 2748 }
2806 } 2749 }
2807 2750
2808 if(ret != TRUE) 2751 if(ret != TRUE)
3325 case WM_CTLCOLORBTN: 3268 case WM_CTLCOLORBTN:
3326 case WM_CTLCOLOREDIT: 3269 case WM_CTLCOLOREDIT:
3327 case WM_CTLCOLORMSGBOX: 3270 case WM_CTLCOLORMSGBOX:
3328 case WM_CTLCOLORSCROLLBAR: 3271 case WM_CTLCOLORSCROLLBAR:
3329 case WM_CTLCOLORDLG: 3272 case WM_CTLCOLORDLG:
3330 _wndproc(hwnd, msg, mp1, mp2); 3273 return _colorwndproc(hwnd, msg, mp1, mp2);
3331 break;
3332 case WM_SETFOCUS: 3274 case WM_SETFOCUS:
3333 _wndproc(hwnd, msg, mp1, mp2); 3275 _wndproc(hwnd, msg, mp1, mp2);
3334 break; 3276 break;
3335 case WM_LBUTTONUP: 3277 case WM_LBUTTONUP:
3336 { 3278 {
4669 HWND hwndframe; 4611 HWND hwndframe;
4670 Box *newbox = calloc(sizeof(Box), 1); 4612 Box *newbox = calloc(sizeof(Box), 1);
4671 ULONG flStyleEx = 0; 4613 ULONG flStyleEx = 0;
4672 #ifdef AEROGLASS 4614 #ifdef AEROGLASS
4673 MARGINS mar = {-1}; 4615 MARGINS mar = {-1};
4616
4617 if(_dw_composition)
4618 flStyleEx = WS_EX_LAYERED;
4674 #endif 4619 #endif
4675 4620
4676 newbox->type = DW_VERT; 4621 newbox->type = DW_VERT;
4677 newbox->vsize = newbox->hsize = SIZEEXPAND; 4622 newbox->vsize = newbox->hsize = SIZEEXPAND;
4678 newbox->cinfo.fore = newbox->cinfo.back = -1; 4623 newbox->cinfo.fore = newbox->cinfo.back = -1;
4699 if(hwndOwner) 4644 if(hwndOwner)
4700 SetParent(hwndframe, hwndOwner); 4645 SetParent(hwndframe, hwndOwner);
4701 4646
4702 #ifdef AEROGLASS 4647 #ifdef AEROGLASS
4703 /* Attempt to enable Aero glass background on the entire window */ 4648 /* Attempt to enable Aero glass background on the entire window */
4704 if(_DwmExtendFrameIntoClientArea) 4649 if(_DwmExtendFrameIntoClientArea && _dw_composition)
4650 {
4651 SetLayeredWindowAttributes(hwndframe, _dw_transparencykey, 0, LWA_COLORKEY);
4705 _DwmExtendFrameIntoClientArea(hwndframe, &mar); 4652 _DwmExtendFrameIntoClientArea(hwndframe, &mar);
4653 }
4706 #endif 4654 #endif
4707 4655
4708 return hwndframe; 4656 return hwndframe;
4709 } 4657 }
4710 4658
6076 0,0,0,0, 6024 0,0,0,0,
6077 DW_HWND_OBJECT, 6025 DW_HWND_OBJECT,
6078 (HMENU)id, 6026 (HMENU)id,
6079 DWInstance, 6027 DWInstance,
6080 NULL); 6028 NULL);
6081 cinfo->fore = cinfo->back = -1;
6082 cinfo->pOldProc = (WNDPROC)SubclassWindow(tmp, _BtProc); 6029 cinfo->pOldProc = (WNDPROC)SubclassWindow(tmp, _BtProc);
6083 SetWindowLongPtr(tmp, GWLP_USERDATA, (LONG_PTR)cinfo); 6030 SetWindowLongPtr(tmp, GWLP_USERDATA, (LONG_PTR)cinfo);
6084 dw_window_set_data(tmp, "_dw_checkbox", DW_INT_TO_POINTER(1)); 6031 dw_window_set_data(tmp, "_dw_checkbox", DW_INT_TO_POINTER(1));
6085 dw_window_set_font(tmp, DefaultFont); 6032 dw_window_set_font(tmp, DefaultFont);
6086 dw_window_set_color(tmp, DW_CLR_DEFAULT, DW_RGB_TRANSPARENT); 6033 dw_window_set_color(tmp, DW_CLR_DEFAULT, DW_RGB_TRANSPARENT);
6534 if ( height == 0 && vsize == FALSE ) 6481 if ( height == 0 && vsize == FALSE )
6535 dw_messagebox(funcname, DW_MB_OK|DW_MB_ERROR, "Height and expand Vertical both unset for box: %x item: %x",box,item); 6482 dw_messagebox(funcname, DW_MB_OK|DW_MB_ERROR, "Height and expand Vertical both unset for box: %x item: %x",box,item);
6536 6483
6537 tmpitem[index].type = TYPEITEM; 6484 tmpitem[index].type = TYPEITEM;
6538 } 6485 }
6539 #ifdef AEROGLASS
6540 if(_dw_composition)
6541 SetLayeredWindowAttributes(item, 0, 255, LWA_ALPHA);
6542 #endif
6543 } 6486 }
6544 6487
6545 tmpitem[index].hwnd = item; 6488 tmpitem[index].hwnd = item;
6546 tmpitem[index].origwidth = tmpitem[index].width = width; 6489 tmpitem[index].origwidth = tmpitem[index].width = width;
6547 tmpitem[index].origheight = tmpitem[index].height = height; 6490 tmpitem[index].origheight = tmpitem[index].height = height;