From: Zhiyi Zhang zzhang@codeweavers.com
--- dlls/comctl32/tab.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-)
diff --git a/dlls/comctl32/tab.c b/dlls/comctl32/tab.c index 535fac11120..9d5190696c7 100644 --- a/dlls/comctl32/tab.c +++ b/dlls/comctl32/tab.c @@ -2293,6 +2293,20 @@ static void TAB_DrawItem(const TAB_INFO *infoPtr, HDC hdc, INT iItem) } }
+static void TAB_DrawBorderBackground(const TAB_INFO *infoPtr, HDC hdc, RECT *rect) +{ + HTHEME theme = GetWindowTheme(infoPtr->hwnd); + + if (theme) + { + DrawThemeParentBackground(infoPtr->hwnd, hdc, rect); + DrawThemeBackground(theme, hdc, TABP_PANE, 0, rect, NULL); + return; + } + + DrawEdge(hdc, rect, EDGE_RAISED, BF_SOFT | BF_RECT); +} + /****************************************************************************** * TAB_DrawBorder * @@ -2302,7 +2316,6 @@ static void TAB_DrawItem(const TAB_INFO *infoPtr, HDC hdc, INT iItem) static void TAB_DrawBorder(const TAB_INFO *infoPtr, HDC hdc) { RECT rect; - HTHEME theme = GetWindowTheme (infoPtr->hwnd);
GetClientRect (infoPtr->hwnd, &rect);
@@ -2324,15 +2337,7 @@ static void TAB_DrawBorder(const TAB_INFO *infoPtr, HDC hdc)
TRACE("border=(%s)\n", wine_dbgstr_rect(&rect));
- if (theme) - { - DrawThemeParentBackground(infoPtr->hwnd, hdc, &rect); - DrawThemeBackground (theme, hdc, TABP_PANE, 0, &rect, NULL); - } - else - { - DrawEdge(hdc, &rect, EDGE_RAISED, BF_SOFT|BF_RECT); - } + TAB_DrawBorderBackground(infoPtr, hdc, &rect); }
/******************************************************************************
From: Zhiyi Zhang zzhang@codeweavers.com
--- dlls/comctl32/tab.c | 86 +++++++++++++++++++++++++-------------------- 1 file changed, 47 insertions(+), 39 deletions(-)
diff --git a/dlls/comctl32/tab.c b/dlls/comctl32/tab.c index 9d5190696c7..2b213153b18 100644 --- a/dlls/comctl32/tab.c +++ b/dlls/comctl32/tab.c @@ -1947,6 +1947,52 @@ TAB_DrawItemInterior(const TAB_INFO *infoPtr, HDC hdc, INT iItem, RECT *drawRect DeleteObject( htextPen ); }
+static void TAB_DrawItemThemeBackground(const TAB_INFO *infoPtr, HDC hdc, INT iItem, + const RECT *selectedRect, RECT *contentRect) +{ + static const int partIds[8] = + { + /* Normal item */ + TABP_TABITEM, + TABP_TABITEMLEFTEDGE, + TABP_TABITEMRIGHTEDGE, + TABP_TABITEMBOTHEDGE, + /* Selected tab */ + TABP_TOPTABITEM, + TABP_TOPTABITEMLEFTEDGE, + TABP_TOPTABITEMRIGHTEDGE, + TABP_TOPTABITEMBOTHEDGE, + }; + HTHEME theme = GetWindowTheme(infoPtr->hwnd); + int partIndex = 0, stateId = TIS_NORMAL; + RECT rect; + + /* selected and unselected tabs have different parts */ + if (iItem == infoPtr->iSelected) + partIndex += 4; + /* The part also differs on the position of a tab on a line. + * "Visually" determining the position works well enough. */ + GetClientRect(infoPtr->hwnd, &rect); + if (selectedRect->left == 0) + partIndex += 1; + if (selectedRect->right == rect.right) + partIndex += 2; + + if (iItem == infoPtr->iSelected) + stateId = TIS_SELECTED; + else if (iItem == infoPtr->iHotTracked) + stateId = TIS_HOT; + else if (iItem == infoPtr->uFocus) + stateId = TIS_FOCUSED; + + /* Adjust rectangle for bottommost row */ + if (TAB_GetItem(infoPtr, iItem)->rect.top == infoPtr->uNumRows - 1) + contentRect->bottom += 3; + + DrawThemeBackground(theme, hdc, partIds[partIndex], stateId, contentRect, NULL); + GetThemeBackgroundContentRect(theme, hdc, partIds[partIndex], stateId, contentRect, contentRect); +} + /****************************************************************************** * TAB_DrawItem * @@ -2050,45 +2096,7 @@ static void TAB_DrawItem(const TAB_INFO *infoPtr, HDC hdc, INT iItem) if ((theme = GetWindowTheme (infoPtr->hwnd)) && ((infoPtr->dwStyle & (TCS_VERTICAL | TCS_BOTTOM)) == 0)) { - static const int partIds[8] = { - /* Normal item */ - TABP_TABITEM, - TABP_TABITEMLEFTEDGE, - TABP_TABITEMRIGHTEDGE, - TABP_TABITEMBOTHEDGE, - /* Selected tab */ - TABP_TOPTABITEM, - TABP_TOPTABITEMLEFTEDGE, - TABP_TOPTABITEMRIGHTEDGE, - TABP_TOPTABITEMBOTHEDGE, - }; - int partIndex = 0; - int stateId = TIS_NORMAL; - - /* selected and unselected tabs have different parts */ - if (iItem == infoPtr->iSelected) - partIndex += 4; - /* The part also differs on the position of a tab on a line. - * "Visually" determining the position works well enough. */ - GetClientRect(infoPtr->hwnd, &r1); - if(selectedRect.left == 0) - partIndex += 1; - if(selectedRect.right == r1.right) - partIndex += 2; - - if (iItem == infoPtr->iSelected) - stateId = TIS_SELECTED; - else if (iItem == infoPtr->iHotTracked) - stateId = TIS_HOT; - else if (iItem == infoPtr->uFocus) - stateId = TIS_FOCUSED; - - /* Adjust rectangle for bottommost row */ - if (TAB_GetItem(infoPtr, iItem)->rect.top == infoPtr->uNumRows-1) - r.bottom += 3; - - DrawThemeBackground (theme, hdc, partIds[partIndex], stateId, &r, NULL); - GetThemeBackgroundContentRect (theme, hdc, partIds[partIndex], stateId, &r, &r); + TAB_DrawItemThemeBackground(infoPtr, hdc, iItem, &selectedRect, &r); } else if(infoPtr->dwStyle & TCS_VERTICAL) {
From: Zhiyi Zhang zzhang@codeweavers.com
--- dlls/comctl32/tab.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-)
diff --git a/dlls/comctl32/tab.c b/dlls/comctl32/tab.c index 2b213153b18..5ae60ad09ea 100644 --- a/dlls/comctl32/tab.c +++ b/dlls/comctl32/tab.c @@ -744,7 +744,7 @@ static inline void hottrack_refresh(const TAB_INFO *infoPtr, int tabIndex) { if (tabIndex == -1) return;
- if (GetWindowTheme (infoPtr->hwnd)) + if (COMCTL32_IsThemed(infoPtr->hwnd)) { RECT rect; TAB_InternalGetItemRect(infoPtr, tabIndex, &rect, NULL); @@ -834,7 +834,7 @@ TAB_RecalcHotTrack if (out_redrawEnter != NULL) *out_redrawEnter = -1;
- if ((infoPtr->dwStyle & TCS_HOTTRACK) || GetWindowTheme(infoPtr->hwnd)) + if ((infoPtr->dwStyle & TCS_HOTTRACK) || COMCTL32_IsThemed(infoPtr->hwnd)) { POINT pt; UINT flags; @@ -1518,7 +1518,7 @@ TAB_EraseTabInterior(const TAB_INFO *infoPtr, HDC hdc, INT iItem, const RECT *dr else /* !TCS_BUTTONS */ { InflateRect(&rTemp, -2, -2); - if (!GetWindowTheme (infoPtr->hwnd)) + if (!COMCTL32_IsThemed(infoPtr->hwnd)) FillRect(hdc, &rTemp, hbr); }
@@ -1690,7 +1690,7 @@ TAB_DrawItemInterior(const TAB_INFO *infoPtr, HDC hdc, INT iItem, RECT *drawRect * Setup for text output */ oldBkMode = SetBkMode(hdc, TRANSPARENT); - if (!GetWindowTheme (infoPtr->hwnd) || (infoPtr->dwStyle & TCS_BUTTONS)) + if (!COMCTL32_IsThemed(infoPtr->hwnd) || (infoPtr->dwStyle & TCS_BUTTONS)) { if ((infoPtr->dwStyle & TCS_HOTTRACK) && (iItem == infoPtr->iHotTracked) && !(infoPtr->dwStyle & TCS_FLATBUTTONS)) @@ -2007,7 +2007,6 @@ static void TAB_DrawItem(const TAB_INFO *infoPtr, HDC hdc, INT iItem) INT clRight = 0; INT clBottom = 0; COLORREF bkgnd, corner; - HTHEME theme;
/* * Get the rectangle for the item. @@ -2093,8 +2092,7 @@ static void TAB_DrawItem(const TAB_INFO *infoPtr, HDC hdc, INT iItem) * Windows draws even side or bottom tabs themed, with wacky results. * However, since in Wine apps may get themed that did not opt in via * a manifest avoid theming when we know the result will be wrong */ - if ((theme = GetWindowTheme (infoPtr->hwnd)) - && ((infoPtr->dwStyle & (TCS_VERTICAL | TCS_BOTTOM)) == 0)) + if (COMCTL32_IsThemed(infoPtr->hwnd) && ((infoPtr->dwStyle & (TCS_VERTICAL | TCS_BOTTOM)) == 0)) { TAB_DrawItemThemeBackground(infoPtr, hdc, iItem, &selectedRect, &r); }
From: Zhiyi Zhang zzhang@codeweavers.com
--- dlls/comctl32/tab.c | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-)
diff --git a/dlls/comctl32/tab.c b/dlls/comctl32/tab.c index 5ae60ad09ea..a83d6a5277d 100644 --- a/dlls/comctl32/tab.c +++ b/dlls/comctl32/tab.c @@ -148,8 +148,6 @@ typedef struct #define TAB_HOTTRACK_TIMER 1 #define TAB_HOTTRACK_TIMER_INTERVAL 100 /* milliseconds */
-static const WCHAR themeClass[] = L"Tab"; - static inline TAB_ITEM* TAB_GetItem(const TAB_INFO *infoPtr, INT i) { assert(i >= 0 && i < infoPtr->uNumItem); @@ -1950,6 +1948,7 @@ TAB_DrawItemInterior(const TAB_INFO *infoPtr, HDC hdc, INT iItem, RECT *drawRect static void TAB_DrawItemThemeBackground(const TAB_INFO *infoPtr, HDC hdc, INT iItem, const RECT *selectedRect, RECT *contentRect) { +#if __WINE_COMCTL32_VERSION == 6 static const int partIds[8] = { /* Normal item */ @@ -1991,6 +1990,7 @@ static void TAB_DrawItemThemeBackground(const TAB_INFO *infoPtr, HDC hdc, INT iI
DrawThemeBackground(theme, hdc, partIds[partIndex], stateId, contentRect, NULL); GetThemeBackgroundContentRect(theme, hdc, partIds[partIndex], stateId, contentRect, contentRect); +#endif /* __WINE_COMCTL32_VERSION == 6 */ }
/****************************************************************************** @@ -2301,6 +2301,7 @@ static void TAB_DrawItem(const TAB_INFO *infoPtr, HDC hdc, INT iItem)
static void TAB_DrawBorderBackground(const TAB_INFO *infoPtr, HDC hdc, RECT *rect) { +#if __WINE_COMCTL32_VERSION == 6 HTHEME theme = GetWindowTheme(infoPtr->hwnd);
if (theme) @@ -2309,6 +2310,7 @@ static void TAB_DrawBorderBackground(const TAB_INFO *infoPtr, HDC hdc, RECT *rec DrawThemeBackground(theme, hdc, TABP_PANE, 0, rect, NULL); return; } +#endif
DrawEdge(hdc, rect, EDGE_RAISED, BF_SOFT | BF_RECT); } @@ -3056,8 +3058,8 @@ static LRESULT TAB_Create (HWND hwnd, LPARAM lParam) } }
- OpenThemeData (infoPtr->hwnd, themeClass); - + COMCTL32_OpenThemeForWindow (infoPtr->hwnd, L"Tab"); + /* * We need to get text information so we need a DC and we need to select * a font. @@ -3118,22 +3120,12 @@ TAB_Destroy (TAB_INFO *infoPtr) if (infoPtr->iHotTracked >= 0) KillTimer(infoPtr->hwnd, TAB_HOTTRACK_TIMER);
- CloseThemeData (GetWindowTheme (infoPtr->hwnd)); + COMCTL32_CloseThemeForWindow (infoPtr->hwnd);
Free (infoPtr); return 0; }
-/* update theme after a WM_THEMECHANGED message */ -static LRESULT theme_changed(const TAB_INFO *infoPtr) -{ - HTHEME theme = GetWindowTheme (infoPtr->hwnd); - CloseThemeData (theme); - OpenThemeData (infoPtr->hwnd, themeClass); - InvalidateRect (infoPtr->hwnd, NULL, TRUE); - return 0; -} - static LRESULT TAB_NCCalcSize(WPARAM wParam) { if (!wParam) @@ -3434,7 +3426,7 @@ TAB_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) return 0;
case WM_THEMECHANGED: - return theme_changed (infoPtr); + return COMCTL32_ThemeChanged (infoPtr->hwnd, L"Tab", TRUE, TRUE);
case WM_KILLFOCUS: TAB_KillFocus(infoPtr);
This merge request was approved by Nikolay Sivov.