From: Zhiyi Zhang zzhang@codeweavers.com
--- dlls/comctl32/comctl32.h | 1 + dlls/comctl32/commctrl.c | 5 +++++ dlls/comctl32/header.c | 8 ++++---- 3 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/dlls/comctl32/comctl32.h b/dlls/comctl32/comctl32.h index de4b2dac956..ca68906be62 100644 --- a/dlls/comctl32/comctl32.h +++ b/dlls/comctl32/comctl32.h @@ -196,6 +196,7 @@ void COMCTL32_DrawInsertMark(HDC hDC, const RECT *lpRect, COLORREF clrInsertMark void COMCTL32_EnsureBitmapSize(HBITMAP *pBitmap, int cxMinWidth, int cyMinHeight, COLORREF crBackground); void COMCTL32_GetFontMetrics(HFONT hFont, TEXTMETRICW *ptm); BOOL COMCTL32_IsReflectedMessage(UINT uMsg); +BOOL COMCTL32_IsThemed(HWND hwnd); LRESULT COMCTL32_NCPaint(HWND hwnd, WPARAM wp, LPARAM lp, const WCHAR *theme_class); LRESULT COMCTL32_SetVersion(INT *current_version, INT new_version); LRESULT COMCTL32_ThemeChanged(HWND hwnd, const WCHAR *theme_class, BOOL invalidate, BOOL erase); diff --git a/dlls/comctl32/commctrl.c b/dlls/comctl32/commctrl.c index cf5f4b3256a..2aa31ca47f2 100644 --- a/dlls/comctl32/commctrl.c +++ b/dlls/comctl32/commctrl.c @@ -3206,3 +3206,8 @@ LRESULT COMCTL32_NCPaint(HWND hwnd, WPARAM wp, LPARAM lp, const WCHAR *theme_cla return DefWindowProcW(hwnd, WM_NCPAINT, wp, lp); #endif } + +BOOL COMCTL32_IsThemed(HWND hwnd) +{ + return !!GetWindowTheme(hwnd); +} diff --git a/dlls/comctl32/header.c b/dlls/comctl32/header.c index fd31b98eee3..fd00880c69c 100644 --- a/dlls/comctl32/header.c +++ b/dlls/comctl32/header.c @@ -306,7 +306,7 @@ 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 (GetWindowTheme(infoPtr->hwndSelf)) return; + if (COMCTL32_IsThemed(infoPtr->hwndSelf)) return;
if (!(infoPtr->dwStyle & HDS_FLAT)) { @@ -383,7 +383,7 @@ HEADER_DrawItem (HEADER_INFO *infoPtr, HDC hdc, INT iItem, BOOL bHotTrack, LRESU 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); + SetTextColor(hdc, (bHotTrack && !COMCTL32_IsThemed(infoPtr->hwndSelf)) ? comctl32_color.clrHighlight : comctl32_color.clrBtnText); SetBkColor(hdc, comctl32_color.clr3dFace);
if (lCDFlags & CDRF_NOTIFYITEMDRAW && !(phdi->fmt & HDF_OWNERDRAW)) @@ -633,7 +633,7 @@ HEADER_Refresh (HEADER_INFO *infoPtr, HDC hdc) hOldFont = SelectObject (hdc, hFont);
/* draw Background */ - if (infoPtr->uNumItem == 0 && theme == NULL) { + if (infoPtr->uNumItem == 0 && !COMCTL32_IsThemed(infoPtr->hwndSelf)) { hbrBk = GetSysColorBrush(COLOR_3DFACE); FillRect(hdc, &rect, hbrBk); } @@ -1878,7 +1878,7 @@ HEADER_MouseMove (HEADER_INFO *infoPtr, LPARAM lParam) /* With theming, hottracking is always enabled */ BOOL hotTrackEnabled = ((infoPtr->dwStyle & HDS_BUTTONS) && (infoPtr->dwStyle & HDS_HOTTRACK)) - || (GetWindowTheme (infoPtr->hwndSelf) != NULL); + || COMCTL32_IsThemed (infoPtr->hwndSelf); INT oldHotItem = infoPtr->iHotItem;
pt.x = (INT)(SHORT)LOWORD(lParam);
From: Zhiyi Zhang zzhang@codeweavers.com
--- dlls/comctl32/header.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-)
diff --git a/dlls/comctl32/header.c b/dlls/comctl32/header.c index fd00880c69c..3c8241111f9 100644 --- a/dlls/comctl32/header.c +++ b/dlls/comctl32/header.c @@ -363,6 +363,21 @@ static HRGN create_sort_arrow( INT x, INT y, INT h, BOOL is_up ) return rgn; }
+static void HEADER_GetItemTextRect(const HEADER_ITEM *item, HWND hwnd, HDC hdc, BOOL hot_track, RECT *rect) +{ + HTHEME theme = GetWindowTheme(hwnd); + + if (theme) + { + int state = item->bDown ? HIS_PRESSED : (hot_track ? HIS_HOT : HIS_NORMAL); + GetThemeTextExtent(theme, hdc, HP_HEADERITEM, state, item->pszText, -1, + DT_LEFT | DT_VCENTER | DT_SINGLELINE, NULL, rect); + return; + } + + DrawTextW(hdc, item->pszText, -1, rect, DT_LEFT | DT_VCENTER | DT_SINGLELINE | DT_CALCRECT); +} + static INT HEADER_DrawItem (HEADER_INFO *infoPtr, HDC hdc, INT iItem, BOOL bHotTrack, LRESULT lCDFlags) { @@ -462,14 +477,7 @@ HEADER_DrawItem (HEADER_INFO *infoPtr, HDC hdc, INT iItem, BOOL bHotTrack, LRESU RECT textRect;
SetRectEmpty(&textRect); - - if (theme) { - GetThemeTextExtent(theme, hdc, HP_HEADERITEM, state, phdi->pszText, -1, - DT_LEFT|DT_VCENTER|DT_SINGLELINE, NULL, &textRect); - } else { - DrawTextW (hdc, phdi->pszText, -1, - &textRect, DT_LEFT|DT_VCENTER|DT_SINGLELINE|DT_CALCRECT); - } + HEADER_GetItemTextRect(phdi, infoPtr->hwndSelf, hdc, bHotTrack, &textRect); cw = textRect.right - textRect.left + 2 * infoPtr->iMargin; }
From: Zhiyi Zhang zzhang@codeweavers.com
--- dlls/comctl32/header.c | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-)
diff --git a/dlls/comctl32/header.c b/dlls/comctl32/header.c index 3c8241111f9..1618fbf4116 100644 --- a/dlls/comctl32/header.c +++ b/dlls/comctl32/header.c @@ -378,15 +378,28 @@ static void HEADER_GetItemTextRect(const HEADER_ITEM *item, HWND hwnd, HDC hdc, DrawTextW(hdc, item->pszText, -1, rect, DT_LEFT | DT_VCENTER | DT_SINGLELINE | DT_CALCRECT); }
+static void HEADER_DrawItemText(const HEADER_ITEM *item, HWND hwnd, HDC hdc, BOOL hot_track, RECT *rect) +{ + HTHEME theme = GetWindowTheme(hwnd); + + if (theme) + { + int state = item->bDown ? HIS_PRESSED : (hot_track ? HIS_HOT : HIS_NORMAL); + DrawThemeText(theme, hdc, HP_HEADERITEM, state, item->pszText, -1, + DT_LEFT | DT_END_ELLIPSIS | DT_VCENTER | DT_SINGLELINE, 0, rect); + return; + } + + DrawTextW(hdc, item->pszText, -1, rect, DT_LEFT | DT_END_ELLIPSIS | DT_VCENTER | DT_SINGLELINE); +} + static INT HEADER_DrawItem (HEADER_INFO *infoPtr, HDC hdc, INT iItem, BOOL bHotTrack, LRESULT lCDFlags) { HEADER_ITEM *phdi = &infoPtr->items[iItem]; RECT r; INT oldBkMode; - HTHEME theme = GetWindowTheme (infoPtr->hwndSelf); NMCUSTOMDRAW nmcd; - int state = 0;
TRACE("DrawItem(iItem %d bHotTrack %d unicode flag %d)\n", iItem, bHotTrack, (infoPtr->nNotifyFormat == NFR_UNICODE));
@@ -394,9 +407,6 @@ HEADER_DrawItem (HEADER_INFO *infoPtr, HDC hdc, INT iItem, BOOL bHotTrack, LRESU if (r.right - r.left == 0) return phdi->rect.right;
- 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 && !COMCTL32_IsThemed(infoPtr->hwndSelf)) ? comctl32_color.clrHighlight : comctl32_color.clrBtnText); SetBkColor(hdc, comctl32_color.clr3dFace); @@ -587,14 +597,7 @@ HEADER_DrawItem (HEADER_INFO *infoPtr, HDC hdc, INT iItem, BOOL bHotTrack, LRESU oldBkMode = SetBkMode(hdc, TRANSPARENT); r.left = tx; r.right = tx + tw; - if (theme) { - DrawThemeText(theme, hdc, HP_HEADERITEM, state, phdi->pszText, - -1, DT_LEFT|DT_END_ELLIPSIS|DT_VCENTER|DT_SINGLELINE, - 0, &r); - } else { - DrawTextW (hdc, phdi->pszText, -1, - &r, DT_LEFT|DT_END_ELLIPSIS|DT_VCENTER|DT_SINGLELINE); - } + HEADER_DrawItemText(phdi, infoPtr->hwndSelf, hdc, bHotTrack, &r); if (oldBkMode != TRANSPARENT) SetBkMode(hdc, oldBkMode); }
From: Zhiyi Zhang zzhang@codeweavers.com
--- dlls/comctl32/header.c | 41 ++++++++++++++++++++++++----------------- 1 file changed, 24 insertions(+), 17 deletions(-)
diff --git a/dlls/comctl32/header.c b/dlls/comctl32/header.c index 1618fbf4116..cd41a6f0f15 100644 --- a/dlls/comctl32/header.c +++ b/dlls/comctl32/header.c @@ -619,6 +619,28 @@ HEADER_DrawHotDivider(const HEADER_INFO *infoPtr, HDC hdc) DeleteObject(brush); }
+static void HEADER_DrawRestBackground(HEADER_INFO *infoPtr, HDC hdc, RECT *rect) +{ + HTHEME theme = GetWindowTheme(infoPtr->hwndSelf); + + if (theme) + { + DrawThemeBackground(theme, hdc, HP_HEADERITEM, HIS_NORMAL, rect, NULL); + return; + } + + if (infoPtr->dwStyle & HDS_FLAT) + { + FillRect(hdc, rect, GetSysColorBrush(COLOR_3DFACE)); + return; + } + + if (infoPtr->dwStyle & HDS_BUTTONS) + DrawEdge(hdc, rect, EDGE_RAISED, BF_TOP | BF_LEFT | BF_BOTTOM | BF_SOFT | BF_MIDDLE); + else + DrawEdge(hdc, rect, EDGE_ETCHED, BF_BOTTOM | BF_MIDDLE); +} + static void HEADER_Refresh (HEADER_INFO *infoPtr, HDC hdc) { @@ -628,7 +650,6 @@ HEADER_Refresh (HEADER_INFO *infoPtr, HDC hdc) UINT i; INT x; LRESULT lCDFlags; - HTHEME theme = GetWindowTheme (infoPtr->hwndSelf);
if (!infoPtr->bRectsValid) HEADER_SetItemBounds(infoPtr); @@ -659,22 +680,8 @@ HEADER_Refresh (HEADER_INFO *infoPtr, HDC hdc)
rcRest = rect; rcRest.left = x; - if ((x <= rect.right) && RectVisible(hdc, &rcRest) && (infoPtr->uNumItem > 0)) { - if (theme != NULL) { - DrawThemeBackground(theme, hdc, HP_HEADERITEM, HIS_NORMAL, &rcRest, NULL); - } - else if (infoPtr->dwStyle & HDS_FLAT) { - hbrBk = GetSysColorBrush(COLOR_3DFACE); - FillRect(hdc, &rcRest, hbrBk); - } - else - { - if (infoPtr->dwStyle & HDS_BUTTONS) - DrawEdge (hdc, &rcRest, EDGE_RAISED, BF_TOP|BF_LEFT|BF_BOTTOM|BF_SOFT|BF_MIDDLE); - else - DrawEdge (hdc, &rcRest, EDGE_ETCHED, BF_BOTTOM|BF_MIDDLE); - } - } + if ((x <= rect.right) && RectVisible(hdc, &rcRest) && (infoPtr->uNumItem > 0)) + HEADER_DrawRestBackground(infoPtr, hdc, &rcRest);
if (infoPtr->iHotDivider != -1) HEADER_DrawHotDivider(infoPtr, hdc);
From: Zhiyi Zhang zzhang@codeweavers.com
--- dlls/comctl32/header.c | 41 ++++++++++++++++++----------------------- 1 file changed, 18 insertions(+), 23 deletions(-)
diff --git a/dlls/comctl32/header.c b/dlls/comctl32/header.c index cd41a6f0f15..a21f4bb9934 100644 --- a/dlls/comctl32/header.c +++ b/dlls/comctl32/header.c @@ -108,8 +108,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) @@ -288,19 +286,22 @@ 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) { + HBRUSH hbr; + +#if __WINE_COMCTL32_VERSION == 6 HTHEME theme = GetWindowTheme (infoPtr->hwndSelf);
if (theme) { int state = (item->bDown) ? HIS_PRESSED : (hottrack ? HIS_HOT : HIS_NORMAL); DrawThemeBackground (theme, hdc, HP_HEADERITEM, state, r, NULL); GetThemeBackgroundContentRect (theme, hdc, HP_HEADERITEM, state, r, r); + return; } - else - { - HBRUSH hbr = CreateSolidBrush(GetBkColor(hdc)); - FillRect(hdc, r, hbr); - DeleteObject(hbr); - } +#endif + + hbr = CreateSolidBrush(GetBkColor(hdc)); + FillRect(hdc, r, hbr); + DeleteObject(hbr); }
static void @@ -365,6 +366,7 @@ static HRGN create_sort_arrow( INT x, INT y, INT h, BOOL is_up )
static void HEADER_GetItemTextRect(const HEADER_ITEM *item, HWND hwnd, HDC hdc, BOOL hot_track, RECT *rect) { +#if __WINE_COMCTL32_VERSION == 6 HTHEME theme = GetWindowTheme(hwnd);
if (theme) @@ -374,12 +376,14 @@ static void HEADER_GetItemTextRect(const HEADER_ITEM *item, HWND hwnd, HDC hdc, DT_LEFT | DT_VCENTER | DT_SINGLELINE, NULL, rect); return; } +#endif
DrawTextW(hdc, item->pszText, -1, rect, DT_LEFT | DT_VCENTER | DT_SINGLELINE | DT_CALCRECT); }
static void HEADER_DrawItemText(const HEADER_ITEM *item, HWND hwnd, HDC hdc, BOOL hot_track, RECT *rect) { +#if __WINE_COMCTL32_VERSION == 6 HTHEME theme = GetWindowTheme(hwnd);
if (theme) @@ -389,6 +393,7 @@ static void HEADER_DrawItemText(const HEADER_ITEM *item, HWND hwnd, HDC hdc, BOO DT_LEFT | DT_END_ELLIPSIS | DT_VCENTER | DT_SINGLELINE, 0, rect); return; } +#endif
DrawTextW(hdc, item->pszText, -1, rect, DT_LEFT | DT_END_ELLIPSIS | DT_VCENTER | DT_SINGLELINE); } @@ -621,6 +626,7 @@ HEADER_DrawHotDivider(const HEADER_INFO *infoPtr, HDC hdc)
static void HEADER_DrawRestBackground(HEADER_INFO *infoPtr, HDC hdc, RECT *rect) { +#if __WINE_COMCTL32_VERSION == 6 HTHEME theme = GetWindowTheme(infoPtr->hwndSelf);
if (theme) @@ -628,6 +634,7 @@ static void HEADER_DrawRestBackground(HEADER_INFO *infoPtr, HDC hdc, RECT *rect) DrawThemeBackground(theme, hdc, HP_HEADERITEM, HIS_NORMAL, rect, NULL); return; } +#endif
if (infoPtr->dwStyle & HDS_FLAT) { @@ -1630,7 +1637,7 @@ HEADER_Create (HWND hwnd, const CREATESTRUCTW *lpcs) SelectObject (hdc, hOldFont); ReleaseDC (0, hdc);
- OpenThemeData(hwnd, themeClass); + COMCTL32_OpenThemeForWindow(hwnd, L"Header");
return 0; } @@ -1639,8 +1646,7 @@ HEADER_Create (HWND hwnd, const CREATESTRUCTW *lpcs) static LRESULT HEADER_Destroy (HEADER_INFO *infoPtr) { - HTHEME theme = GetWindowTheme(infoPtr->hwndSelf); - CloseThemeData(theme); + COMCTL32_CloseThemeForWindow(infoPtr->hwndSelf); return 0; }
@@ -1885,7 +1891,6 @@ HEADER_MouseLeave (HEADER_INFO *infoPtr) return 0; }
- static LRESULT HEADER_MouseMove (HEADER_INFO *infoPtr, LPARAM lParam) { @@ -2124,16 +2129,6 @@ static INT HEADER_StyleChanged(HEADER_INFO *infoPtr, WPARAM wStyleType, return 0; }
-/* 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); - InvalidateRect(infoPtr->hwndSelf, NULL, TRUE); - return 0; -} - static INT HEADER_SetFilterChangeTimeout(HEADER_INFO *infoPtr, INT timeout) { INT old_timeout = infoPtr->filter_change_timeout; @@ -2260,7 +2255,7 @@ HEADER_WindowProc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) return HEADER_Size (infoPtr);
case WM_THEMECHANGED: - return HEADER_ThemeChanged (infoPtr); + return COMCTL32_ThemeChanged (infoPtr->hwndSelf, L"Header", TRUE, TRUE);
case WM_PRINTCLIENT: case WM_PAINT:
From: Zhiyi Zhang zzhang@codeweavers.com
--- dlls/comctl32/hotkey.c | 46 +----------------------------------------- 1 file changed, 1 insertion(+), 45 deletions(-)
diff --git a/dlls/comctl32/hotkey.c b/dlls/comctl32/hotkey.c index 17e2b282cd6..484ab479c9f 100644 --- a/dlls/comctl32/hotkey.c +++ b/dlls/comctl32/hotkey.c @@ -423,50 +423,6 @@ HOTKEY_NCCreate (HWND hwnd, const CREATESTRUCTW *lpcs) return DefWindowProcW (infoPtr->hwndSelf, WM_NCCREATE, 0, (LPARAM)lpcs); }
-static LRESULT -HOTKEY_NCPaint (HWND hwnd, HRGN region) -{ - INT cxEdge, cyEdge; - HRGN clipRgn; - HTHEME theme; - LONG exStyle; - RECT r; - HDC dc; - - theme = OpenThemeDataForDpi(NULL, WC_EDITW, GetDpiForWindow(hwnd)); - if (!theme) - return DefWindowProcW(hwnd, WM_NCPAINT, (WPARAM)region, 0); - - exStyle = GetWindowLongW(hwnd, GWL_EXSTYLE); - if (!(exStyle & WS_EX_CLIENTEDGE)) - { - CloseThemeData(theme); - return DefWindowProcW(hwnd, WM_NCPAINT, (WPARAM)region, 0); - } - - cxEdge = GetSystemMetrics(SM_CXEDGE); - cyEdge = GetSystemMetrics(SM_CYEDGE); - GetWindowRect(hwnd, &r); - - /* New clipping region passed to default proc to exclude border */ - clipRgn = CreateRectRgn(r.left + cxEdge, r.top + cyEdge, r.right - cxEdge, r.bottom - cyEdge); - if (region != (HRGN)1) - CombineRgn(clipRgn, clipRgn, region, RGN_AND); - OffsetRect(&r, -r.left, -r.top); - - dc = GetDCEx(hwnd, region, DCX_WINDOW | DCX_INTERSECTRGN); - if (IsThemeBackgroundPartiallyTransparent(theme, 0, 0)) - DrawThemeParentBackground(hwnd, dc, &r); - DrawThemeBackground(theme, dc, 0, 0, &r, 0); - ReleaseDC(hwnd, dc); - CloseThemeData(theme); - - /* Call default proc to get the scrollbars etc. also painted */ - DefWindowProcW(hwnd, WM_NCPAINT, (WPARAM)clipRgn, 0); - DeleteObject(clipRgn); - return 0; -} - static LRESULT HOTKEY_SetFocus (HOTKEY_INFO *infoPtr) { @@ -568,7 +524,7 @@ HOTKEY_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) return HOTKEY_NCCreate (hwnd, (LPCREATESTRUCTW)lParam);
case WM_NCPAINT: - return HOTKEY_NCPaint (hwnd, (HRGN)wParam); + return COMCTL32_NCPaint (hwnd, wParam, lParam, WC_EDITW);
case WM_PRINTCLIENT: case WM_PAINT:
This merge request was approved by Nikolay Sivov.