From: Zhiyi Zhang zzhang@codeweavers.com
--- dlls/comctl32/header.c | 60 +++++++++++++++++++++++++++++++++++------- 1 file changed, 51 insertions(+), 9 deletions(-)
diff --git a/dlls/comctl32/header.c b/dlls/comctl32/header.c index 354ca615500..89df914c02d 100644 --- a/dlls/comctl32/header.c +++ b/dlls/comctl32/header.c @@ -38,8 +38,10 @@ #include "winnls.h" #include "commctrl.h" #include "comctl32.h" +#if __WINE_COMCTL32_VERSION == 6 #include "vssym32.h" #include "uxtheme.h" +#endif #include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(header); @@ -110,8 +112,6 @@ static void HEADER_FreeCallbackItems(HEADER_ITEM *lpItem); static LRESULT HEADER_SendNotify(const HEADER_INFO *infoPtr, UINT code, NMHDR *hdr); static LRESULT HEADER_SendCtrlCustomDraw(const HEADER_INFO *infoPtr, DWORD dwDrawStage, HDC hdc, const RECT *rect);
-static const WCHAR themeClass[] = L"Header"; - static void HEADER_StoreHDItemInHeader(HEADER_ITEM *lpItem, UINT mask, const HDITEMW *phdi, BOOL fUnicode) { if (mask & HDI_UNSUPPORTED_FIELDS) @@ -290,6 +290,7 @@ static void HEADER_GetHotDividerRect(const HEADER_INFO *infoPtr, RECT *r) static void HEADER_FillItemFrame(HEADER_INFO *infoPtr, HDC hdc, RECT *r, const HEADER_ITEM *item, BOOL hottrack) { +#if __WINE_COMCTL32_VERSION == 6 HTHEME theme = GetWindowTheme (infoPtr->hwndSelf);
if (theme) { @@ -298,6 +299,7 @@ HEADER_FillItemFrame(HEADER_INFO *infoPtr, HDC hdc, RECT *r, const HEADER_ITEM * GetThemeBackgroundContentRect (theme, hdc, HP_HEADERITEM, state, r, r); } else +#endif { HBRUSH hbr = CreateSolidBrush(GetBkColor(hdc)); FillRect(hdc, r, hbr); @@ -308,7 +310,9 @@ HEADER_FillItemFrame(HEADER_INFO *infoPtr, HDC hdc, RECT *r, const HEADER_ITEM * static void HEADER_DrawItemFrame(HEADER_INFO *infoPtr, HDC hdc, RECT *r, const HEADER_ITEM *item) { +#if __WINE_COMCTL32_VERSION == 6 if (GetWindowTheme(infoPtr->hwndSelf)) return; +#endif
if (!(infoPtr->dwStyle & HDS_FLAT)) { @@ -371,9 +375,11 @@ HEADER_DrawItem (HEADER_INFO *infoPtr, HDC hdc, INT iItem, BOOL bHotTrack, LRESU HEADER_ITEM *phdi = &infoPtr->items[iItem]; RECT r; INT oldBkMode; - HTHEME theme = GetWindowTheme (infoPtr->hwndSelf); NMCUSTOMDRAW nmcd; +#if __WINE_COMCTL32_VERSION == 6 + HTHEME theme = GetWindowTheme (infoPtr->hwndSelf); int state = 0; +#endif
TRACE("DrawItem(iItem %d bHotTrack %d unicode flag %d)\n", iItem, bHotTrack, (infoPtr->nNotifyFormat == NFR_UNICODE));
@@ -381,11 +387,15 @@ HEADER_DrawItem (HEADER_INFO *infoPtr, HDC hdc, INT iItem, BOOL bHotTrack, LRESU if (r.right - r.left == 0) return phdi->rect.right;
+#if __WINE_COMCTL32_VERSION == 6 if (theme) state = (phdi->bDown) ? HIS_PRESSED : (bHotTrack ? HIS_HOT : HIS_NORMAL);
/* Set the colors before sending NM_CUSTOMDRAW so that it can change them */ SetTextColor(hdc, (bHotTrack && !theme) ? comctl32_color.clrHighlight : comctl32_color.clrBtnText); +#else + SetTextColor(hdc, bHotTrack ? comctl32_color.clrHighlight : comctl32_color.clrBtnText); +#endif SetBkColor(hdc, comctl32_color.clr3dFace);
if (lCDFlags & CDRF_NOTIFYITEMDRAW && !(phdi->fmt & HDF_OWNERDRAW)) @@ -465,10 +475,14 @@ HEADER_DrawItem (HEADER_INFO *infoPtr, HDC hdc, INT iItem, BOOL bHotTrack, LRESU
SetRectEmpty(&textRect);
+#if __WINE_COMCTL32_VERSION == 6 if (theme) { GetThemeTextExtent(theme, hdc, HP_HEADERITEM, state, phdi->pszText, -1, DT_LEFT|DT_VCENTER|DT_SINGLELINE, NULL, &textRect); - } else { + } + else +#endif + { DrawTextW (hdc, phdi->pszText, -1, &textRect, DT_LEFT|DT_VCENTER|DT_SINGLELINE|DT_CALCRECT); } @@ -581,11 +595,15 @@ HEADER_DrawItem (HEADER_INFO *infoPtr, HDC hdc, INT iItem, BOOL bHotTrack, LRESU oldBkMode = SetBkMode(hdc, TRANSPARENT); r.left = tx; r.right = tx + tw; +#if __WINE_COMCTL32_VERSION == 6 if (theme) { DrawThemeText(theme, hdc, HP_HEADERITEM, state, phdi->pszText, -1, DT_LEFT|DT_END_ELLIPSIS|DT_VCENTER|DT_SINGLELINE, 0, &r); - } else { + } + else +#endif + { DrawTextW (hdc, phdi->pszText, -1, &r, DT_LEFT|DT_END_ELLIPSIS|DT_VCENTER|DT_SINGLELINE); } @@ -619,7 +637,9 @@ HEADER_Refresh (HEADER_INFO *infoPtr, HDC hdc) UINT i; INT x; LRESULT lCDFlags; +#if __WINE_COMCTL32_VERSION == 6 HTHEME theme = GetWindowTheme (infoPtr->hwndSelf); +#endif
if (!infoPtr->bRectsValid) HEADER_SetItemBounds(infoPtr); @@ -635,7 +655,12 @@ HEADER_Refresh (HEADER_INFO *infoPtr, HDC hdc) hOldFont = SelectObject (hdc, hFont);
/* draw Background */ - if (infoPtr->uNumItem == 0 && theme == NULL) { +#if __WINE_COMCTL32_VERSION == 6 + if (infoPtr->uNumItem == 0 && theme == NULL) +#else + if (infoPtr->uNumItem == 0) +#endif + { hbrBk = GetSysColorBrush(COLOR_3DFACE); FillRect(hdc, &rect, hbrBk); } @@ -651,10 +676,15 @@ HEADER_Refresh (HEADER_INFO *infoPtr, HDC hdc) rcRest = rect; rcRest.left = x; if ((x <= rect.right) && RectVisible(hdc, &rcRest) && (infoPtr->uNumItem > 0)) { +#if __WINE_COMCTL32_VERSION == 6 if (theme != NULL) { DrawThemeBackground(theme, hdc, HP_HEADERITEM, HIS_NORMAL, &rcRest, NULL); } - else if (infoPtr->dwStyle & HDS_FLAT) { + else if (infoPtr->dwStyle & HDS_FLAT) +#else + if (infoPtr->dwStyle & HDS_FLAT) +#endif + { hbrBk = GetSysColorBrush(COLOR_3DFACE); FillRect(hdc, &rcRest, hbrBk); } @@ -1614,7 +1644,9 @@ HEADER_Create (HWND hwnd, const CREATESTRUCTW *lpcs) SelectObject (hdc, hOldFont); ReleaseDC (0, hdc);
- OpenThemeData(hwnd, themeClass); +#if __WINE_COMCTL32_VERSION == 6 + OpenThemeData(hwnd, L"Header"); +#endif
return 0; } @@ -1623,8 +1655,10 @@ HEADER_Create (HWND hwnd, const CREATESTRUCTW *lpcs) static LRESULT HEADER_Destroy (HEADER_INFO *infoPtr) { +#if __WINE_COMCTL32_VERSION == 6 HTHEME theme = GetWindowTheme(infoPtr->hwndSelf); CloseThemeData(theme); +#endif return 0; }
@@ -1877,10 +1911,14 @@ HEADER_MouseMove (HEADER_INFO *infoPtr, LPARAM lParam) UINT flags; INT nItem, nWidth; HDC hdc; +#if __WINE_COMCTL32_VERSION == 6 /* With theming, hottracking is always enabled */ BOOL hotTrackEnabled = ((infoPtr->dwStyle & HDS_BUTTONS) && (infoPtr->dwStyle & HDS_HOTTRACK)) || (GetWindowTheme (infoPtr->hwndSelf) != NULL); +#else + BOOL hotTrackEnabled = infoPtr->dwStyle & HDS_BUTTONS && infoPtr->dwStyle & HDS_HOTTRACK; +#endif INT oldHotItem = infoPtr->iHotItem;
pt.x = (INT)(SHORT)LOWORD(lParam); @@ -2108,15 +2146,17 @@ static INT HEADER_StyleChanged(HEADER_INFO *infoPtr, WPARAM wStyleType, return 0; }
+#if __WINE_COMCTL32_VERSION == 6 /* Update the theme handle after a theme change */ static LRESULT HEADER_ThemeChanged(const HEADER_INFO *infoPtr) { HTHEME theme = GetWindowTheme(infoPtr->hwndSelf); CloseThemeData(theme); - OpenThemeData(infoPtr->hwndSelf, themeClass); + OpenThemeData(infoPtr->hwndSelf, L"Header"); InvalidateRect(infoPtr->hwndSelf, NULL, TRUE); return 0; } +#endif
static INT HEADER_SetFilterChangeTimeout(HEADER_INFO *infoPtr, INT timeout) { @@ -2243,8 +2283,10 @@ HEADER_WindowProc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) case WM_SIZE: return HEADER_Size (infoPtr);
+#if __WINE_COMCTL32_VERSION == 6 case WM_THEMECHANGED: return HEADER_ThemeChanged (infoPtr); +#endif
case WM_PRINTCLIENT: case WM_PAINT: