Commit 9b06ec73 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

comctl32/tab: Cache window GWL_STYLE style.

parent 27ebfdb8
...@@ -120,6 +120,7 @@ typedef struct ...@@ -120,6 +120,7 @@ typedef struct
DWORD exStyle; /* Extended style used, currently: DWORD exStyle; /* Extended style used, currently:
TCS_EX_FLATSEPARATORS, TCS_EX_REGISTERDROP */ TCS_EX_FLATSEPARATORS, TCS_EX_REGISTERDROP */
DWORD dwStyle; /* the cached window GWL_STYLE */
} TAB_INFO; } TAB_INFO;
/****************************************************************************** /******************************************************************************
...@@ -264,7 +265,7 @@ static LRESULT TAB_SetCurFocus (TAB_INFO *infoPtr, INT iItem) ...@@ -264,7 +265,7 @@ static LRESULT TAB_SetCurFocus (TAB_INFO *infoPtr, INT iItem)
if (iItem < 0) if (iItem < 0)
infoPtr->uFocus = -1; infoPtr->uFocus = -1;
else if (iItem < infoPtr->uNumItem) { else if (iItem < infoPtr->uNumItem) {
if (GetWindowLongW(infoPtr->hwnd, GWL_STYLE) & TCS_BUTTONS) { if (infoPtr->dwStyle & TCS_BUTTONS) {
FIXME("Should set input focus\n"); FIXME("Should set input focus\n");
} else { } else {
int oldFocus = infoPtr->uFocus; int oldFocus = infoPtr->uFocus;
...@@ -321,12 +322,12 @@ static BOOL TAB_InternalGetItemRect( ...@@ -321,12 +322,12 @@ static BOOL TAB_InternalGetItemRect(
RECT* selectedRect) RECT* selectedRect)
{ {
RECT tmpItemRect,clientRect; RECT tmpItemRect,clientRect;
LONG lStyle = GetWindowLongW(infoPtr->hwnd, GWL_STYLE);
/* Perform a sanity check and a trivial visibility check. */ /* Perform a sanity check and a trivial visibility check. */
if ( (infoPtr->uNumItem <= 0) || if ( (infoPtr->uNumItem <= 0) ||
(itemIndex >= infoPtr->uNumItem) || (itemIndex >= infoPtr->uNumItem) ||
(!((lStyle & TCS_MULTILINE) || (lStyle & TCS_VERTICAL)) && (itemIndex < infoPtr->leftmostVisible)) ) (!(((infoPtr->dwStyle & TCS_MULTILINE) || (infoPtr->dwStyle & TCS_VERTICAL))) &&
(itemIndex < infoPtr->leftmostVisible)))
{ {
TRACE("Not Visible\n"); TRACE("Not Visible\n");
/* need to initialize these to empty rects */ /* need to initialize these to empty rects */
...@@ -353,28 +354,28 @@ static BOOL TAB_InternalGetItemRect( ...@@ -353,28 +354,28 @@ static BOOL TAB_InternalGetItemRect(
/* calculate the times bottom and top based on the row */ /* calculate the times bottom and top based on the row */
GetClientRect(infoPtr->hwnd, &clientRect); GetClientRect(infoPtr->hwnd, &clientRect);
if ((lStyle & TCS_BOTTOM) && (lStyle & TCS_VERTICAL)) if ((infoPtr->dwStyle & TCS_BOTTOM) && (infoPtr->dwStyle & TCS_VERTICAL))
{ {
itemRect->right = clientRect.right - SELECTED_TAB_OFFSET - itemRect->left * infoPtr->tabHeight - itemRect->right = clientRect.right - SELECTED_TAB_OFFSET - itemRect->left * infoPtr->tabHeight -
((lStyle & TCS_BUTTONS) ? itemRect->left * BUTTON_SPACINGX : 0); ((infoPtr->dwStyle & TCS_BUTTONS) ? itemRect->left * BUTTON_SPACINGX : 0);
itemRect->left = itemRect->right - infoPtr->tabHeight; itemRect->left = itemRect->right - infoPtr->tabHeight;
} }
else if (lStyle & TCS_VERTICAL) else if (infoPtr->dwStyle & TCS_VERTICAL)
{ {
itemRect->left = clientRect.left + SELECTED_TAB_OFFSET + itemRect->left * infoPtr->tabHeight + itemRect->left = clientRect.left + SELECTED_TAB_OFFSET + itemRect->left * infoPtr->tabHeight +
((lStyle & TCS_BUTTONS) ? itemRect->left * BUTTON_SPACINGX : 0); ((infoPtr->dwStyle & TCS_BUTTONS) ? itemRect->left * BUTTON_SPACINGX : 0);
itemRect->right = itemRect->left + infoPtr->tabHeight; itemRect->right = itemRect->left + infoPtr->tabHeight;
} }
else if (lStyle & TCS_BOTTOM) else if (infoPtr->dwStyle & TCS_BOTTOM)
{ {
itemRect->bottom = clientRect.bottom - itemRect->top * infoPtr->tabHeight - itemRect->bottom = clientRect.bottom - itemRect->top * infoPtr->tabHeight -
((lStyle & TCS_BUTTONS) ? itemRect->top * BUTTON_SPACINGY : SELECTED_TAB_OFFSET); ((infoPtr->dwStyle & TCS_BUTTONS) ? itemRect->top * BUTTON_SPACINGY : SELECTED_TAB_OFFSET);
itemRect->top = itemRect->bottom - infoPtr->tabHeight; itemRect->top = itemRect->bottom - infoPtr->tabHeight;
} }
else /* not TCS_BOTTOM and not TCS_VERTICAL */ else /* not TCS_BOTTOM and not TCS_VERTICAL */
{ {
itemRect->top = clientRect.top + itemRect->top * infoPtr->tabHeight + itemRect->top = clientRect.top + itemRect->top * infoPtr->tabHeight +
((lStyle & TCS_BUTTONS) ? itemRect->top * BUTTON_SPACINGY : SELECTED_TAB_OFFSET); ((infoPtr->dwStyle & TCS_BUTTONS) ? itemRect->top * BUTTON_SPACINGY : SELECTED_TAB_OFFSET);
itemRect->bottom = itemRect->top + infoPtr->tabHeight; itemRect->bottom = itemRect->top + infoPtr->tabHeight;
} }
...@@ -382,7 +383,7 @@ static BOOL TAB_InternalGetItemRect( ...@@ -382,7 +383,7 @@ static BOOL TAB_InternalGetItemRect(
* "scroll" it to make sure the item at the very left of the * "scroll" it to make sure the item at the very left of the
* tab control is the leftmost visible tab. * tab control is the leftmost visible tab.
*/ */
if(lStyle & TCS_VERTICAL) if(infoPtr->dwStyle & TCS_VERTICAL)
{ {
OffsetRect(itemRect, OffsetRect(itemRect,
0, 0,
...@@ -419,23 +420,23 @@ static BOOL TAB_InternalGetItemRect( ...@@ -419,23 +420,23 @@ static BOOL TAB_InternalGetItemRect(
CopyRect(selectedRect, itemRect); CopyRect(selectedRect, itemRect);
/* The rectangle of a selected item is a bit wider. */ /* The rectangle of a selected item is a bit wider. */
if(lStyle & TCS_VERTICAL) if(infoPtr->dwStyle & TCS_VERTICAL)
InflateRect(selectedRect, 0, SELECTED_TAB_OFFSET); InflateRect(selectedRect, 0, SELECTED_TAB_OFFSET);
else else
InflateRect(selectedRect, SELECTED_TAB_OFFSET, 0); InflateRect(selectedRect, SELECTED_TAB_OFFSET, 0);
/* If it also a bit higher. */ /* If it also a bit higher. */
if ((lStyle & TCS_BOTTOM) && (lStyle & TCS_VERTICAL)) if ((infoPtr->dwStyle & TCS_BOTTOM) && (infoPtr->dwStyle & TCS_VERTICAL))
{ {
selectedRect->left -= 2; /* the border is thicker on the right */ selectedRect->left -= 2; /* the border is thicker on the right */
selectedRect->right += SELECTED_TAB_OFFSET; selectedRect->right += SELECTED_TAB_OFFSET;
} }
else if (lStyle & TCS_VERTICAL) else if (infoPtr->dwStyle & TCS_VERTICAL)
{ {
selectedRect->left -= SELECTED_TAB_OFFSET; selectedRect->left -= SELECTED_TAB_OFFSET;
selectedRect->right += 1; selectedRect->right += 1;
} }
else if (lStyle & TCS_BOTTOM) else if (infoPtr->dwStyle & TCS_BOTTOM)
{ {
selectedRect->bottom += SELECTED_TAB_OFFSET; selectedRect->bottom += SELECTED_TAB_OFFSET;
} }
...@@ -447,7 +448,7 @@ static BOOL TAB_InternalGetItemRect( ...@@ -447,7 +448,7 @@ static BOOL TAB_InternalGetItemRect(
} }
/* Check for visibility */ /* Check for visibility */
if (lStyle & TCS_VERTICAL) if (infoPtr->dwStyle & TCS_VERTICAL)
return (itemRect->top < clientRect.bottom) && (itemRect->bottom > clientRect.top); return (itemRect->top < clientRect.bottom) && (itemRect->bottom > clientRect.top);
else else
return (itemRect->left < clientRect.right) && (itemRect->right > clientRect.left); return (itemRect->left < clientRect.right) && (itemRect->right > clientRect.left);
...@@ -585,13 +586,12 @@ TAB_LButtonDown (TAB_INFO *infoPtr, WPARAM wParam, LPARAM lParam) ...@@ -585,13 +586,12 @@ TAB_LButtonDown (TAB_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
POINT pt; POINT pt;
INT newItem; INT newItem;
UINT dummy; UINT dummy;
LONG lStyle = GetWindowLongW(infoPtr->hwnd, GWL_STYLE);
if (infoPtr->hwndToolTip) if (infoPtr->hwndToolTip)
TAB_RelayEvent (infoPtr->hwndToolTip, infoPtr->hwnd, TAB_RelayEvent (infoPtr->hwndToolTip, infoPtr->hwnd,
WM_LBUTTONDOWN, wParam, lParam); WM_LBUTTONDOWN, wParam, lParam);
if (GetWindowLongW(infoPtr->hwnd, GWL_STYLE) & TCS_FOCUSONBUTTONDOWN ) { if (infoPtr->dwStyle & TCS_FOCUSONBUTTONDOWN) {
SetFocus (infoPtr->hwnd); SetFocus (infoPtr->hwnd);
} }
...@@ -608,7 +608,7 @@ TAB_LButtonDown (TAB_INFO *infoPtr, WPARAM wParam, LPARAM lParam) ...@@ -608,7 +608,7 @@ TAB_LButtonDown (TAB_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
if ((newItem != -1) && (infoPtr->iSelected != newItem)) if ((newItem != -1) && (infoPtr->iSelected != newItem))
{ {
if ((lStyle & TCS_BUTTONS) && (lStyle & TCS_MULTISELECT) && if ((infoPtr->dwStyle & TCS_BUTTONS) && (infoPtr->dwStyle & TCS_MULTISELECT) &&
(wParam & MK_CONTROL)) (wParam & MK_CONTROL))
{ {
RECT r; RECT r;
...@@ -782,8 +782,7 @@ TAB_RecalcHotTrack ...@@ -782,8 +782,7 @@ TAB_RecalcHotTrack
if (out_redrawEnter != NULL) if (out_redrawEnter != NULL)
*out_redrawEnter = -1; *out_redrawEnter = -1;
if ((GetWindowLongW(infoPtr->hwnd, GWL_STYLE) & TCS_HOTTRACK) if ((infoPtr->dwStyle & TCS_HOTTRACK) || GetWindowTheme(infoPtr->hwnd))
|| GetWindowTheme (infoPtr->hwnd))
{ {
POINT pt; POINT pt;
UINT flags; UINT flags;
...@@ -875,7 +874,6 @@ TAB_MouseMove (TAB_INFO *infoPtr, WPARAM wParam, LPARAM lParam) ...@@ -875,7 +874,6 @@ TAB_MouseMove (TAB_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
*/ */
static LRESULT TAB_AdjustRect(const TAB_INFO *infoPtr, WPARAM fLarger, LPRECT prc) static LRESULT TAB_AdjustRect(const TAB_INFO *infoPtr, WPARAM fLarger, LPRECT prc)
{ {
DWORD lStyle = GetWindowLongW(infoPtr->hwnd, GWL_STYLE);
LONG *iRightBottom, *iLeftTop; LONG *iRightBottom, *iLeftTop;
TRACE ("hwnd=%p fLarger=%ld (%s)\n", infoPtr->hwnd, fLarger, TRACE ("hwnd=%p fLarger=%ld (%s)\n", infoPtr->hwnd, fLarger,
...@@ -883,7 +881,7 @@ static LRESULT TAB_AdjustRect(const TAB_INFO *infoPtr, WPARAM fLarger, LPRECT pr ...@@ -883,7 +881,7 @@ static LRESULT TAB_AdjustRect(const TAB_INFO *infoPtr, WPARAM fLarger, LPRECT pr
if (!prc) return -1; if (!prc) return -1;
if(lStyle & TCS_VERTICAL) if(infoPtr->dwStyle & TCS_VERTICAL)
{ {
iRightBottom = &(prc->right); iRightBottom = &(prc->right);
iLeftTop = &(prc->left); iLeftTop = &(prc->left);
...@@ -897,11 +895,11 @@ static LRESULT TAB_AdjustRect(const TAB_INFO *infoPtr, WPARAM fLarger, LPRECT pr ...@@ -897,11 +895,11 @@ static LRESULT TAB_AdjustRect(const TAB_INFO *infoPtr, WPARAM fLarger, LPRECT pr
if (fLarger) /* Go from display rectangle */ if (fLarger) /* Go from display rectangle */
{ {
/* Add the height of the tabs. */ /* Add the height of the tabs. */
if (lStyle & TCS_BOTTOM) if (infoPtr->dwStyle & TCS_BOTTOM)
*iRightBottom += infoPtr->tabHeight * infoPtr->uNumRows; *iRightBottom += infoPtr->tabHeight * infoPtr->uNumRows;
else else
*iLeftTop -= infoPtr->tabHeight * infoPtr->uNumRows + *iLeftTop -= infoPtr->tabHeight * infoPtr->uNumRows +
((lStyle & TCS_BUTTONS)? 3 * (infoPtr->uNumRows - 1) : 0); ((infoPtr->dwStyle & TCS_BUTTONS)? 3 * (infoPtr->uNumRows - 1) : 0);
/* Inflate the rectangle for the padding */ /* Inflate the rectangle for the padding */
InflateRect(prc, DISPLAY_AREA_PADDINGX, DISPLAY_AREA_PADDINGY); InflateRect(prc, DISPLAY_AREA_PADDINGX, DISPLAY_AREA_PADDINGY);
...@@ -918,11 +916,11 @@ static LRESULT TAB_AdjustRect(const TAB_INFO *infoPtr, WPARAM fLarger, LPRECT pr ...@@ -918,11 +916,11 @@ static LRESULT TAB_AdjustRect(const TAB_INFO *infoPtr, WPARAM fLarger, LPRECT pr
InflateRect(prc, -DISPLAY_AREA_PADDINGX, -DISPLAY_AREA_PADDINGY); InflateRect(prc, -DISPLAY_AREA_PADDINGX, -DISPLAY_AREA_PADDINGY);
/* Remove the height of the tabs. */ /* Remove the height of the tabs. */
if (lStyle & TCS_BOTTOM) if (infoPtr->dwStyle & TCS_BOTTOM)
*iRightBottom -= infoPtr->tabHeight * infoPtr->uNumRows; *iRightBottom -= infoPtr->tabHeight * infoPtr->uNumRows;
else else
*iLeftTop += (infoPtr->tabHeight) * infoPtr->uNumRows + *iLeftTop += (infoPtr->tabHeight) * infoPtr->uNumRows +
((lStyle & TCS_BUTTONS)? 3 * (infoPtr->uNumRows - 1) : 0); ((infoPtr->dwStyle & TCS_BUTTONS)? 3 * (infoPtr->uNumRows - 1) : 0);
} }
return 0; return 0;
...@@ -1074,7 +1072,6 @@ static void TAB_SetupScrolling( ...@@ -1074,7 +1072,6 @@ static void TAB_SetupScrolling(
*/ */
static void TAB_SetItemBounds (TAB_INFO *infoPtr) static void TAB_SetItemBounds (TAB_INFO *infoPtr)
{ {
LONG lStyle = GetWindowLongW(infoPtr->hwnd, GWL_STYLE);
TEXTMETRICW fontMetrics; TEXTMETRICW fontMetrics;
UINT curItem; UINT curItem;
INT curItemLeftPos; INT curItemLeftPos;
...@@ -1105,7 +1102,7 @@ static void TAB_SetItemBounds (TAB_INFO *infoPtr) ...@@ -1105,7 +1102,7 @@ static void TAB_SetItemBounds (TAB_INFO *infoPtr)
/* if TCS_VERTICAL then swap the height and width so this code places the /* if TCS_VERTICAL then swap the height and width so this code places the
tabs along the top of the rectangle and we can just rotate them after tabs along the top of the rectangle and we can just rotate them after
rather than duplicate all of the below code */ rather than duplicate all of the below code */
if(lStyle & TCS_VERTICAL) if(infoPtr->dwStyle & TCS_VERTICAL)
{ {
iTemp = clientRect.bottom; iTemp = clientRect.bottom;
clientRect.bottom = clientRect.right; clientRect.bottom = clientRect.right;
...@@ -1143,7 +1140,7 @@ static void TAB_SetItemBounds (TAB_INFO *infoPtr) ...@@ -1143,7 +1140,7 @@ static void TAB_SetItemBounds (TAB_INFO *infoPtr)
* selected item + extra space for the selected item. * selected item + extra space for the selected item.
*/ */
infoPtr->tabHeight = item_height + infoPtr->tabHeight = item_height +
((lStyle & TCS_BUTTONS) ? 2 : 1) * ((infoPtr->dwStyle & TCS_BUTTONS) ? 2 : 1) *
infoPtr->uVItemPadding; infoPtr->uVItemPadding;
TRACE("tabH=%d, tmH=%d, iconh=%d\n", TRACE("tabH=%d, tmH=%d, iconh=%d\n",
...@@ -1157,7 +1154,7 @@ static void TAB_SetItemBounds (TAB_INFO *infoPtr) ...@@ -1157,7 +1154,7 @@ static void TAB_SetItemBounds (TAB_INFO *infoPtr)
{ {
ImageList_GetIconSize(infoPtr->himl, &icon_width, 0); ImageList_GetIconSize(infoPtr->himl, &icon_width, 0);
if (lStyle & TCS_FIXEDWIDTH) if (infoPtr->dwStyle & TCS_FIXEDWIDTH)
icon_width += 4; icon_width += 4;
else else
/* Add padding if icon is present */ /* Add padding if icon is present */
...@@ -1171,7 +1168,7 @@ static void TAB_SetItemBounds (TAB_INFO *infoPtr) ...@@ -1171,7 +1168,7 @@ static void TAB_SetItemBounds (TAB_INFO *infoPtr)
/* Set the leftmost position of the tab. */ /* Set the leftmost position of the tab. */
curr->rect.left = curItemLeftPos; curr->rect.left = curItemLeftPos;
if (lStyle & TCS_FIXEDWIDTH) if (infoPtr->dwStyle & TCS_FIXEDWIDTH)
{ {
curr->rect.right = curr->rect.left + curr->rect.right = curr->rect.left +
max(infoPtr->tabWidth, icon_width); max(infoPtr->tabWidth, icon_width);
...@@ -1219,7 +1216,7 @@ static void TAB_SetItemBounds (TAB_INFO *infoPtr) ...@@ -1219,7 +1216,7 @@ static void TAB_SetItemBounds (TAB_INFO *infoPtr)
* *
*/ */
if (((lStyle & TCS_MULTILINE) || (lStyle & TCS_VERTICAL)) && if (((infoPtr->dwStyle & TCS_MULTILINE) || (infoPtr->dwStyle & TCS_VERTICAL)) &&
(curr->rect.right > (curr->rect.right >
(clientRect.right - CONTROL_BORDER_SIZEX - DISPLAY_AREA_PADDINGX))) (clientRect.right - CONTROL_BORDER_SIZEX - DISPLAY_AREA_PADDINGX)))
{ {
...@@ -1240,17 +1237,17 @@ static void TAB_SetItemBounds (TAB_INFO *infoPtr) ...@@ -1240,17 +1237,17 @@ static void TAB_SetItemBounds (TAB_INFO *infoPtr)
* The leftmost position of the next item is the rightmost position * The leftmost position of the next item is the rightmost position
* of this one. * of this one.
*/ */
if (lStyle & TCS_BUTTONS) if (infoPtr->dwStyle & TCS_BUTTONS)
{ {
curItemLeftPos = curr->rect.right + BUTTON_SPACINGX; curItemLeftPos = curr->rect.right + BUTTON_SPACINGX;
if (lStyle & TCS_FLATBUTTONS) if (infoPtr->dwStyle & TCS_FLATBUTTONS)
curItemLeftPos += FLAT_BTN_SPACINGX; curItemLeftPos += FLAT_BTN_SPACINGX;
} }
else else
curItemLeftPos = curr->rect.right; curItemLeftPos = curr->rect.right;
} }
if (!((lStyle & TCS_MULTILINE) || (lStyle & TCS_VERTICAL))) if (!((infoPtr->dwStyle & TCS_MULTILINE) || (infoPtr->dwStyle & TCS_VERTICAL)))
{ {
/* /*
* Check if we need a scrolling control. * Check if we need a scrolling control.
...@@ -1276,8 +1273,8 @@ static void TAB_SetItemBounds (TAB_INFO *infoPtr) ...@@ -1276,8 +1273,8 @@ static void TAB_SetItemBounds (TAB_INFO *infoPtr)
infoPtr->uNumRows = curItemRowCount; infoPtr->uNumRows = curItemRowCount;
/* Arrange all tabs evenly if style says so */ /* Arrange all tabs evenly if style says so */
if (!(lStyle & TCS_RAGGEDRIGHT) && if (!(infoPtr->dwStyle & TCS_RAGGEDRIGHT) &&
((lStyle & TCS_MULTILINE) || (lStyle & TCS_VERTICAL)) && ((infoPtr->dwStyle & TCS_MULTILINE) || (infoPtr->dwStyle & TCS_VERTICAL)) &&
(infoPtr->uNumItem > 0) && (infoPtr->uNumItem > 0) &&
(infoPtr->uNumRows > 1)) (infoPtr->uNumRows > 1))
{ {
...@@ -1312,7 +1309,7 @@ static void TAB_SetItemBounds (TAB_INFO *infoPtr) ...@@ -1312,7 +1309,7 @@ static void TAB_SetItemBounds (TAB_INFO *infoPtr)
/* move to the next row, reset our current item left position and */ /* move to the next row, reset our current item left position and */
/* the count of items on this row */ /* the count of items on this row */
if (lStyle & TCS_VERTICAL) { if (infoPtr->dwStyle & TCS_VERTICAL) {
/* Vert: Add the remaining tabs in the *last* remainder rows */ /* Vert: Add the remaining tabs in the *last* remainder rows */
if (iCount >= ((iRow>=(INT)infoPtr->uNumRows - remTab)?tabPerRow + 1:tabPerRow)) { if (iCount >= ((iRow>=(INT)infoPtr->uNumRows - remTab)?tabPerRow + 1:tabPerRow)) {
iRow++; iRow++;
...@@ -1332,10 +1329,10 @@ static void TAB_SetItemBounds (TAB_INFO *infoPtr) ...@@ -1332,10 +1329,10 @@ static void TAB_SetItemBounds (TAB_INFO *infoPtr)
curr->rect.left += curItemLeftPos; curr->rect.left += curItemLeftPos;
curr->rect.right += curItemLeftPos; curr->rect.right += curItemLeftPos;
curr->rect.top = iRow; curr->rect.top = iRow;
if (lStyle & TCS_BUTTONS) if (infoPtr->dwStyle & TCS_BUTTONS)
{ {
curItemLeftPos = curr->rect.right + 1; curItemLeftPos = curr->rect.right + 1;
if (lStyle & TCS_FLATBUTTONS) if (infoPtr->dwStyle & TCS_FLATBUTTONS)
curItemLeftPos += FLAT_BTN_SPACINGX; curItemLeftPos += FLAT_BTN_SPACINGX;
} }
else else
...@@ -1418,7 +1415,7 @@ static void TAB_SetItemBounds (TAB_INFO *infoPtr) ...@@ -1418,7 +1415,7 @@ static void TAB_SetItemBounds (TAB_INFO *infoPtr)
} }
/* if TCS_VERTICAL rotate the tabs so they are along the side of the clientRect */ /* if TCS_VERTICAL rotate the tabs so they are along the side of the clientRect */
if(lStyle & TCS_VERTICAL) if(infoPtr->dwStyle & TCS_VERTICAL)
{ {
RECT rcOriginal; RECT rcOriginal;
for(iIndex = 0; iIndex < infoPtr->uNumItem; iIndex++) for(iIndex = 0; iIndex < infoPtr->uNumItem; iIndex++)
...@@ -1447,17 +1444,16 @@ static void TAB_SetItemBounds (TAB_INFO *infoPtr) ...@@ -1447,17 +1444,16 @@ static void TAB_SetItemBounds (TAB_INFO *infoPtr)
static void static void
TAB_EraseTabInterior(const TAB_INFO *infoPtr, HDC hdc, INT iItem, const RECT *drawRect) TAB_EraseTabInterior(const TAB_INFO *infoPtr, HDC hdc, INT iItem, const RECT *drawRect)
{ {
LONG lStyle = GetWindowLongW(infoPtr->hwnd, GWL_STYLE);
HBRUSH hbr = CreateSolidBrush (comctl32_color.clrBtnFace); HBRUSH hbr = CreateSolidBrush (comctl32_color.clrBtnFace);
BOOL deleteBrush = TRUE; BOOL deleteBrush = TRUE;
RECT rTemp = *drawRect; RECT rTemp = *drawRect;
if (lStyle & TCS_BUTTONS) if (infoPtr->dwStyle & TCS_BUTTONS)
{ {
if (iItem == infoPtr->iSelected) if (iItem == infoPtr->iSelected)
{ {
/* Background color */ /* Background color */
if (!(lStyle & TCS_OWNERDRAWFIXED)) if (!(infoPtr->dwStyle & TCS_OWNERDRAWFIXED))
{ {
DeleteObject(hbr); DeleteObject(hbr);
hbr = GetSysColorBrush(COLOR_SCROLLBAR); hbr = GetSysColorBrush(COLOR_SCROLLBAR);
...@@ -1478,7 +1474,7 @@ TAB_EraseTabInterior(const TAB_INFO *infoPtr, HDC hdc, INT iItem, const RECT *dr ...@@ -1478,7 +1474,7 @@ TAB_EraseTabInterior(const TAB_INFO *infoPtr, HDC hdc, INT iItem, const RECT *dr
} }
else /* ! selected */ else /* ! selected */
{ {
if (lStyle & TCS_FLATBUTTONS) if (infoPtr->dwStyle & TCS_FLATBUTTONS)
{ {
InflateRect(&rTemp, 2, 2); InflateRect(&rTemp, 2, 2);
FillRect(hdc, &rTemp, hbr); FillRect(hdc, &rTemp, hbr);
...@@ -1522,8 +1518,6 @@ TAB_EraseTabInterior(const TAB_INFO *infoPtr, HDC hdc, INT iItem, const RECT *dr ...@@ -1522,8 +1518,6 @@ TAB_EraseTabInterior(const TAB_INFO *infoPtr, HDC hdc, INT iItem, const RECT *dr
static void static void
TAB_DrawItemInterior(const TAB_INFO *infoPtr, HDC hdc, INT iItem, RECT *drawRect) TAB_DrawItemInterior(const TAB_INFO *infoPtr, HDC hdc, INT iItem, RECT *drawRect)
{ {
LONG lStyle = GetWindowLongW(infoPtr->hwnd, GWL_STYLE);
RECT localRect; RECT localRect;
HPEN htextPen; HPEN htextPen;
...@@ -1560,7 +1554,7 @@ TAB_DrawItemInterior(const TAB_INFO *infoPtr, HDC hdc, INT iItem, RECT *drawRect ...@@ -1560,7 +1554,7 @@ TAB_DrawItemInterior(const TAB_INFO *infoPtr, HDC hdc, INT iItem, RECT *drawRect
else else
*drawRect = itemRect; *drawRect = itemRect;
if (lStyle & TCS_BUTTONS) if (infoPtr->dwStyle & TCS_BUTTONS)
{ {
if (iItem == infoPtr->iSelected) if (iItem == infoPtr->iSelected)
{ {
...@@ -1568,14 +1562,14 @@ TAB_DrawItemInterior(const TAB_INFO *infoPtr, HDC hdc, INT iItem, RECT *drawRect ...@@ -1568,14 +1562,14 @@ TAB_DrawItemInterior(const TAB_INFO *infoPtr, HDC hdc, INT iItem, RECT *drawRect
drawRect->top += 4; drawRect->top += 4;
drawRect->right -= 4; drawRect->right -= 4;
if (lStyle & TCS_VERTICAL) if (infoPtr->dwStyle & TCS_VERTICAL)
{ {
if (!(lStyle & TCS_BOTTOM)) drawRect->right += 1; if (!(infoPtr->dwStyle & TCS_BOTTOM)) drawRect->right += 1;
drawRect->bottom -= 4; drawRect->bottom -= 4;
} }
else else
{ {
if (lStyle & TCS_BOTTOM) if (infoPtr->dwStyle & TCS_BOTTOM)
{ {
drawRect->top -= 2; drawRect->top -= 2;
drawRect->bottom -= 4; drawRect->bottom -= 4;
...@@ -1594,7 +1588,7 @@ TAB_DrawItemInterior(const TAB_INFO *infoPtr, HDC hdc, INT iItem, RECT *drawRect ...@@ -1594,7 +1588,7 @@ TAB_DrawItemInterior(const TAB_INFO *infoPtr, HDC hdc, INT iItem, RECT *drawRect
} }
else else
{ {
if ((lStyle & TCS_VERTICAL) && (lStyle & TCS_BOTTOM)) if ((infoPtr->dwStyle & TCS_VERTICAL) && (infoPtr->dwStyle & TCS_BOTTOM))
{ {
if (iItem != infoPtr->iSelected) if (iItem != infoPtr->iSelected)
{ {
...@@ -1603,7 +1597,7 @@ TAB_DrawItemInterior(const TAB_INFO *infoPtr, HDC hdc, INT iItem, RECT *drawRect ...@@ -1603,7 +1597,7 @@ TAB_DrawItemInterior(const TAB_INFO *infoPtr, HDC hdc, INT iItem, RECT *drawRect
drawRect->bottom -= 2; drawRect->bottom -= 2;
} }
} }
else if (lStyle & TCS_VERTICAL) else if (infoPtr->dwStyle & TCS_VERTICAL)
{ {
if (iItem == infoPtr->iSelected) if (iItem == infoPtr->iSelected)
{ {
...@@ -1616,7 +1610,7 @@ TAB_DrawItemInterior(const TAB_INFO *infoPtr, HDC hdc, INT iItem, RECT *drawRect ...@@ -1616,7 +1610,7 @@ TAB_DrawItemInterior(const TAB_INFO *infoPtr, HDC hdc, INT iItem, RECT *drawRect
drawRect->bottom -= 2; drawRect->bottom -= 2;
} }
} }
else if (lStyle & TCS_BOTTOM) else if (infoPtr->dwStyle & TCS_BOTTOM)
{ {
if (iItem == infoPtr->iSelected) if (iItem == infoPtr->iSelected)
{ {
...@@ -1648,15 +1642,15 @@ TAB_DrawItemInterior(const TAB_INFO *infoPtr, HDC hdc, INT iItem, RECT *drawRect ...@@ -1648,15 +1642,15 @@ TAB_DrawItemInterior(const TAB_INFO *infoPtr, HDC hdc, INT iItem, RECT *drawRect
TAB_EraseTabInterior (infoPtr, hdc, iItem, drawRect); TAB_EraseTabInterior (infoPtr, hdc, iItem, drawRect);
/* Draw the focus rectangle */ /* Draw the focus rectangle */
if (!(lStyle & TCS_FOCUSNEVER) && if (!(infoPtr->dwStyle & TCS_FOCUSNEVER) &&
(GetFocus() == infoPtr->hwnd) && (GetFocus() == infoPtr->hwnd) &&
(iItem == infoPtr->uFocus) ) (iItem == infoPtr->uFocus) )
{ {
RECT rFocus = *drawRect; RECT rFocus = *drawRect;
InflateRect(&rFocus, -3, -3); InflateRect(&rFocus, -3, -3);
if (lStyle & TCS_BOTTOM && !(lStyle & TCS_VERTICAL)) if (infoPtr->dwStyle & TCS_BOTTOM && !(infoPtr->dwStyle & TCS_VERTICAL))
rFocus.top -= 3; rFocus.top -= 3;
if (lStyle & TCS_BUTTONS) if (infoPtr->dwStyle & TCS_BUTTONS)
{ {
rFocus.left -= 3; rFocus.left -= 3;
rFocus.top -= 3; rFocus.top -= 3;
...@@ -1676,10 +1670,10 @@ TAB_DrawItemInterior(const TAB_INFO *infoPtr, HDC hdc, INT iItem, RECT *drawRect ...@@ -1676,10 +1670,10 @@ TAB_DrawItemInterior(const TAB_INFO *infoPtr, HDC hdc, INT iItem, RECT *drawRect
* Setup for text output * Setup for text output
*/ */
oldBkMode = SetBkMode(hdc, TRANSPARENT); oldBkMode = SetBkMode(hdc, TRANSPARENT);
if (!GetWindowTheme (infoPtr->hwnd) || (lStyle & TCS_BUTTONS)) if (!GetWindowTheme (infoPtr->hwnd) || (infoPtr->dwStyle & TCS_BUTTONS))
{ {
if ((lStyle & TCS_HOTTRACK) && (iItem == infoPtr->iHotTracked) && if ((infoPtr->dwStyle & TCS_HOTTRACK) && (iItem == infoPtr->iHotTracked) &&
!(lStyle & TCS_FLATBUTTONS)) !(infoPtr->dwStyle & TCS_FLATBUTTONS))
SetTextColor(hdc, comctl32_color.clrHighlight); SetTextColor(hdc, comctl32_color.clrHighlight);
else if (TAB_GetItem(infoPtr, iItem)->dwState & TCIS_HIGHLIGHTED) else if (TAB_GetItem(infoPtr, iItem)->dwState & TCIS_HIGHLIGHTED)
SetTextColor(hdc, comctl32_color.clrHighlightText); SetTextColor(hdc, comctl32_color.clrHighlightText);
...@@ -1690,7 +1684,7 @@ TAB_DrawItemInterior(const TAB_INFO *infoPtr, HDC hdc, INT iItem, RECT *drawRect ...@@ -1690,7 +1684,7 @@ TAB_DrawItemInterior(const TAB_INFO *infoPtr, HDC hdc, INT iItem, RECT *drawRect
/* /*
* if owner draw, tell the owner to draw * if owner draw, tell the owner to draw
*/ */
if ((lStyle & TCS_OWNERDRAWFIXED) && GetParent(infoPtr->hwnd)) if ((infoPtr->dwStyle & TCS_OWNERDRAWFIXED) && GetParent(infoPtr->hwnd))
{ {
DRAWITEMSTRUCT dis; DRAWITEMSTRUCT dis;
UINT id; UINT id;
...@@ -1764,7 +1758,7 @@ TAB_DrawItemInterior(const TAB_INFO *infoPtr, HDC hdc, INT iItem, RECT *drawRect ...@@ -1764,7 +1758,7 @@ TAB_DrawItemInterior(const TAB_INFO *infoPtr, HDC hdc, INT iItem, RECT *drawRect
ImageList_GetIconSize(infoPtr->himl, &cx, &cy); ImageList_GetIconSize(infoPtr->himl, &cx, &cy);
if(lStyle & TCS_VERTICAL) if(infoPtr->dwStyle & TCS_VERTICAL)
{ {
center_offset_h = ((drawRect->bottom - drawRect->top) - (cy + infoPtr->uHItemPadding + (rcText.right - rcText.left))) / 2; center_offset_h = ((drawRect->bottom - drawRect->top) - (cy + infoPtr->uHItemPadding + (rcText.right - rcText.left))) / 2;
center_offset_v = ((drawRect->right - drawRect->left) - cx) / 2; center_offset_v = ((drawRect->right - drawRect->left) - cx) / 2;
...@@ -1781,7 +1775,7 @@ TAB_DrawItemInterior(const TAB_INFO *infoPtr, HDC hdc, INT iItem, RECT *drawRect ...@@ -1781,7 +1775,7 @@ TAB_DrawItemInterior(const TAB_INFO *infoPtr, HDC hdc, INT iItem, RECT *drawRect
else else
center_offset_v += infoPtr->uVItemPadding / 2; center_offset_v += infoPtr->uVItemPadding / 2;
if (lStyle & TCS_FIXEDWIDTH && lStyle & (TCS_FORCELABELLEFT | TCS_FORCEICONLEFT)) if (infoPtr->dwStyle & TCS_FIXEDWIDTH && infoPtr->dwStyle & (TCS_FORCELABELLEFT | TCS_FORCEICONLEFT))
center_offset_h = infoPtr->uHItemPadding; center_offset_h = infoPtr->uHItemPadding;
if (center_offset_h < 2) if (center_offset_h < 2)
...@@ -1794,7 +1788,7 @@ TAB_DrawItemInterior(const TAB_INFO *infoPtr, HDC hdc, INT iItem, RECT *drawRect ...@@ -1794,7 +1788,7 @@ TAB_DrawItemInterior(const TAB_INFO *infoPtr, HDC hdc, INT iItem, RECT *drawRect
debugstr_w(item->pszText), center_offset_h, center_offset_v, debugstr_w(item->pszText), center_offset_h, center_offset_v,
wine_dbgstr_rect(drawRect), (rcText.right-rcText.left)); wine_dbgstr_rect(drawRect), (rcText.right-rcText.left));
if((lStyle & TCS_VERTICAL) && (lStyle & TCS_BOTTOM)) if((infoPtr->dwStyle & TCS_VERTICAL) && (infoPtr->dwStyle & TCS_BOTTOM))
{ {
rcImage.top = drawRect->top + center_offset_h; rcImage.top = drawRect->top + center_offset_h;
/* if tab is TCS_VERTICAL and TCS_BOTTOM, the text is drawn from the */ /* if tab is TCS_VERTICAL and TCS_BOTTOM, the text is drawn from the */
...@@ -1803,7 +1797,7 @@ TAB_DrawItemInterior(const TAB_INFO *infoPtr, HDC hdc, INT iItem, RECT *drawRect ...@@ -1803,7 +1797,7 @@ TAB_DrawItemInterior(const TAB_INFO *infoPtr, HDC hdc, INT iItem, RECT *drawRect
rcImage.left = drawRect->right - cx - center_offset_v; rcImage.left = drawRect->right - cx - center_offset_v;
drawRect->top += cy + infoPtr->uHItemPadding; drawRect->top += cy + infoPtr->uHItemPadding;
} }
else if(lStyle & TCS_VERTICAL) else if(infoPtr->dwStyle & TCS_VERTICAL)
{ {
rcImage.top = drawRect->bottom - cy - center_offset_h; rcImage.top = drawRect->bottom - cy - center_offset_h;
rcImage.left = drawRect->left + center_offset_v; rcImage.left = drawRect->left + center_offset_v;
...@@ -1830,17 +1824,17 @@ TAB_DrawItemInterior(const TAB_INFO *infoPtr, HDC hdc, INT iItem, RECT *drawRect ...@@ -1830,17 +1824,17 @@ TAB_DrawItemInterior(const TAB_INFO *infoPtr, HDC hdc, INT iItem, RECT *drawRect
} }
/* Now position text */ /* Now position text */
if (lStyle & TCS_FIXEDWIDTH && lStyle & TCS_FORCELABELLEFT) if (infoPtr->dwStyle & TCS_FIXEDWIDTH && infoPtr->dwStyle & TCS_FORCELABELLEFT)
center_offset_h = infoPtr->uHItemPadding; center_offset_h = infoPtr->uHItemPadding;
else else
if(lStyle & TCS_VERTICAL) if(infoPtr->dwStyle & TCS_VERTICAL)
center_offset_h = ((drawRect->bottom - drawRect->top) - (rcText.right - rcText.left)) / 2; center_offset_h = ((drawRect->bottom - drawRect->top) - (rcText.right - rcText.left)) / 2;
else else
center_offset_h = ((drawRect->right - drawRect->left) - (rcText.right - rcText.left)) / 2; center_offset_h = ((drawRect->right - drawRect->left) - (rcText.right - rcText.left)) / 2;
if(lStyle & TCS_VERTICAL) if(infoPtr->dwStyle & TCS_VERTICAL)
{ {
if(lStyle & TCS_BOTTOM) if(infoPtr->dwStyle & TCS_BOTTOM)
drawRect->top+=center_offset_h; drawRect->top+=center_offset_h;
else else
drawRect->bottom-=center_offset_h; drawRect->bottom-=center_offset_h;
...@@ -1862,13 +1856,13 @@ TAB_DrawItemInterior(const TAB_INFO *infoPtr, HDC hdc, INT iItem, RECT *drawRect ...@@ -1862,13 +1856,13 @@ TAB_DrawItemInterior(const TAB_INFO *infoPtr, HDC hdc, INT iItem, RECT *drawRect
if (center_offset_v < 0) if (center_offset_v < 0)
center_offset_v = 0; center_offset_v = 0;
if(lStyle & TCS_VERTICAL) if(infoPtr->dwStyle & TCS_VERTICAL)
drawRect->left += center_offset_v; drawRect->left += center_offset_v;
else else
drawRect->top += center_offset_v; drawRect->top += center_offset_v;
/* Draw the text */ /* Draw the text */
if(lStyle & TCS_VERTICAL) /* if we are vertical rotate the text and each character */ if(infoPtr->dwStyle & TCS_VERTICAL) /* if we are vertical rotate the text and each character */
{ {
static const WCHAR ArialW[] = { 'A','r','i','a','l',0 }; static const WCHAR ArialW[] = { 'A','r','i','a','l',0 };
LOGFONTW logfont; LOGFONTW logfont;
...@@ -1876,7 +1870,7 @@ TAB_DrawItemInterior(const TAB_INFO *infoPtr, HDC hdc, INT iItem, RECT *drawRect ...@@ -1876,7 +1870,7 @@ TAB_DrawItemInterior(const TAB_INFO *infoPtr, HDC hdc, INT iItem, RECT *drawRect
INT nEscapement = 900; INT nEscapement = 900;
INT nOrientation = 900; INT nOrientation = 900;
if(lStyle & TCS_BOTTOM) if(infoPtr->dwStyle & TCS_BOTTOM)
{ {
nEscapement = -900; nEscapement = -900;
nOrientation = -900; nOrientation = -900;
...@@ -1907,8 +1901,8 @@ TAB_DrawItemInterior(const TAB_INFO *infoPtr, HDC hdc, INT iItem, RECT *drawRect ...@@ -1907,8 +1901,8 @@ TAB_DrawItemInterior(const TAB_INFO *infoPtr, HDC hdc, INT iItem, RECT *drawRect
if (item->pszText) if (item->pszText)
{ {
ExtTextOutW(hdc, ExtTextOutW(hdc,
(lStyle & TCS_BOTTOM) ? drawRect->right : drawRect->left, (infoPtr->dwStyle & TCS_BOTTOM) ? drawRect->right : drawRect->left,
(!(lStyle & TCS_BOTTOM)) ? drawRect->bottom : drawRect->top, (!(infoPtr->dwStyle & TCS_BOTTOM)) ? drawRect->bottom : drawRect->top,
ETO_CLIPPED, ETO_CLIPPED,
drawRect, drawRect,
item->pszText, item->pszText,
...@@ -1955,7 +1949,6 @@ TAB_DrawItemInterior(const TAB_INFO *infoPtr, HDC hdc, INT iItem, RECT *drawRect ...@@ -1955,7 +1949,6 @@ TAB_DrawItemInterior(const TAB_INFO *infoPtr, HDC hdc, INT iItem, RECT *drawRect
*/ */
static void TAB_DrawItem(const TAB_INFO *infoPtr, HDC hdc, INT iItem) static void TAB_DrawItem(const TAB_INFO *infoPtr, HDC hdc, INT iItem)
{ {
LONG lStyle = GetWindowLongW(infoPtr->hwnd, GWL_STYLE);
RECT itemRect; RECT itemRect;
RECT selectedRect; RECT selectedRect;
BOOL isVisible; BOOL isVisible;
...@@ -1993,13 +1986,13 @@ static void TAB_DrawItem(const TAB_INFO *infoPtr, HDC hdc, INT iItem) ...@@ -1993,13 +1986,13 @@ static void TAB_DrawItem(const TAB_INFO *infoPtr, HDC hdc, INT iItem)
bkgnd = comctl32_color.clrBtnFace; bkgnd = comctl32_color.clrBtnFace;
corner = comctl32_color.clrBtnFace; corner = comctl32_color.clrBtnFace;
if (lStyle & TCS_BUTTONS) if (infoPtr->dwStyle & TCS_BUTTONS)
{ {
/* Get item rectangle */ /* Get item rectangle */
r = itemRect; r = itemRect;
/* Separators between flat buttons */ /* Separators between flat buttons */
if ((lStyle & TCS_FLATBUTTONS) && (infoPtr->exStyle & TCS_EX_FLATSEPARATORS)) if ((infoPtr->dwStyle & TCS_FLATBUTTONS) && (infoPtr->exStyle & TCS_EX_FLATSEPARATORS))
{ {
r1 = r; r1 = r;
r1.right += (FLAT_BTN_SPACINGX -2); r1.right += (FLAT_BTN_SPACINGX -2);
...@@ -2019,7 +2012,7 @@ static void TAB_DrawItem(const TAB_INFO *infoPtr, HDC hdc, INT iItem) ...@@ -2019,7 +2012,7 @@ static void TAB_DrawItem(const TAB_INFO *infoPtr, HDC hdc, INT iItem)
if (state & TCIS_BUTTONPRESSED) if (state & TCIS_BUTTONPRESSED)
DrawEdge(hdc, &r, EDGE_SUNKEN, BF_SOFT|BF_RECT); DrawEdge(hdc, &r, EDGE_SUNKEN, BF_SOFT|BF_RECT);
else else
if (!(lStyle & TCS_FLATBUTTONS)) if (!(infoPtr->dwStyle & TCS_FLATBUTTONS))
DrawEdge(hdc, &r, EDGE_RAISED, BF_SOFT|BF_RECT); DrawEdge(hdc, &r, EDGE_RAISED, BF_SOFT|BF_RECT);
} }
} }
...@@ -2050,7 +2043,7 @@ static void TAB_DrawItem(const TAB_INFO *infoPtr, HDC hdc, INT iItem) ...@@ -2050,7 +2043,7 @@ static void TAB_DrawItem(const TAB_INFO *infoPtr, HDC hdc, INT iItem)
* However, since in Wine apps may get themed that did not opt in via * 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 */ * a manifest avoid theming when we know the result will be wrong */
if ((theme = GetWindowTheme (infoPtr->hwnd)) if ((theme = GetWindowTheme (infoPtr->hwnd))
&& ((lStyle & (TCS_VERTICAL | TCS_BOTTOM)) == 0)) && ((infoPtr->dwStyle & (TCS_VERTICAL | TCS_BOTTOM)) == 0))
{ {
static const int partIds[8] = { static const int partIds[8] = {
/* Normal item */ /* Normal item */
...@@ -2091,7 +2084,7 @@ static void TAB_DrawItem(const TAB_INFO *infoPtr, HDC hdc, INT iItem) ...@@ -2091,7 +2084,7 @@ static void TAB_DrawItem(const TAB_INFO *infoPtr, HDC hdc, INT iItem)
DrawThemeBackground (theme, hdc, partIds[partIndex], stateId, &r, NULL); DrawThemeBackground (theme, hdc, partIds[partIndex], stateId, &r, NULL);
GetThemeBackgroundContentRect (theme, hdc, partIds[partIndex], stateId, &r, &r); GetThemeBackgroundContentRect (theme, hdc, partIds[partIndex], stateId, &r, &r);
} }
else if(lStyle & TCS_VERTICAL) else if(infoPtr->dwStyle & TCS_VERTICAL)
{ {
/* These are for adjusting the drawing of a Selected tab */ /* These are for adjusting the drawing of a Selected tab */
/* The initial values are for the normal case of non-Selected */ /* The initial values are for the normal case of non-Selected */
...@@ -2107,7 +2100,7 @@ static void TAB_DrawItem(const TAB_INFO *infoPtr, HDC hdc, INT iItem) ...@@ -2107,7 +2100,7 @@ static void TAB_DrawItem(const TAB_INFO *infoPtr, HDC hdc, INT iItem)
fillRect.bottom -= CONTROL_BORDER_SIZEY; fillRect.bottom -= CONTROL_BORDER_SIZEY;
} }
if (lStyle & TCS_BOTTOM) if (infoPtr->dwStyle & TCS_BOTTOM)
{ {
/* Adjust both rectangles to match native */ /* Adjust both rectangles to match native */
r.left += (1-ZZ); r.left += (1-ZZ);
...@@ -2194,7 +2187,7 @@ static void TAB_DrawItem(const TAB_INFO *infoPtr, HDC hdc, INT iItem) ...@@ -2194,7 +2187,7 @@ static void TAB_DrawItem(const TAB_INFO *infoPtr, HDC hdc, INT iItem)
fillRect.right -= CONTROL_BORDER_SIZEX; fillRect.right -= CONTROL_BORDER_SIZEX;
} }
if (lStyle & TCS_BOTTOM) if (infoPtr->dwStyle & TCS_BOTTOM)
{ {
/* Adjust both rectangles for topmost row */ /* Adjust both rectangles for topmost row */
if (TAB_GetItem(infoPtr, iItem)->rect.top == infoPtr->uNumRows-1) if (TAB_GetItem(infoPtr, iItem)->rect.top == infoPtr->uNumRows-1)
...@@ -2303,7 +2296,6 @@ static void TAB_DrawItem(const TAB_INFO *infoPtr, HDC hdc, INT iItem) ...@@ -2303,7 +2296,6 @@ static void TAB_DrawItem(const TAB_INFO *infoPtr, HDC hdc, INT iItem)
static void TAB_DrawBorder(const TAB_INFO *infoPtr, HDC hdc) static void TAB_DrawBorder(const TAB_INFO *infoPtr, HDC hdc)
{ {
RECT rect; RECT rect;
DWORD lStyle = GetWindowLongW(infoPtr->hwnd, GWL_STYLE);
HTHEME theme = GetWindowTheme (infoPtr->hwnd); HTHEME theme = GetWindowTheme (infoPtr->hwnd);
GetClientRect (infoPtr->hwnd, &rect); GetClientRect (infoPtr->hwnd, &rect);
...@@ -2314,11 +2306,11 @@ static void TAB_DrawBorder(const TAB_INFO *infoPtr, HDC hdc) ...@@ -2314,11 +2306,11 @@ static void TAB_DrawBorder(const TAB_INFO *infoPtr, HDC hdc)
if (infoPtr->uNumItem) if (infoPtr->uNumItem)
{ {
if ((lStyle & TCS_BOTTOM) && !(lStyle & TCS_VERTICAL)) if ((infoPtr->dwStyle & TCS_BOTTOM) && !(infoPtr->dwStyle & TCS_VERTICAL))
rect.bottom -= infoPtr->tabHeight * infoPtr->uNumRows + CONTROL_BORDER_SIZEX; rect.bottom -= infoPtr->tabHeight * infoPtr->uNumRows + CONTROL_BORDER_SIZEX;
else if((lStyle & TCS_BOTTOM) && (lStyle & TCS_VERTICAL)) else if((infoPtr->dwStyle & TCS_BOTTOM) && (infoPtr->dwStyle & TCS_VERTICAL))
rect.right -= infoPtr->tabHeight * infoPtr->uNumRows + CONTROL_BORDER_SIZEX; rect.right -= infoPtr->tabHeight * infoPtr->uNumRows + CONTROL_BORDER_SIZEX;
else if(lStyle & TCS_VERTICAL) else if(infoPtr->dwStyle & TCS_VERTICAL)
rect.left += infoPtr->tabHeight * infoPtr->uNumRows + CONTROL_BORDER_SIZEX; rect.left += infoPtr->tabHeight * infoPtr->uNumRows + CONTROL_BORDER_SIZEX;
else /* not TCS_VERTICAL and not TCS_BOTTOM */ else /* not TCS_VERTICAL and not TCS_BOTTOM */
rect.top += infoPtr->tabHeight * infoPtr->uNumRows + CONTROL_BORDER_SIZEX; rect.top += infoPtr->tabHeight * infoPtr->uNumRows + CONTROL_BORDER_SIZEX;
...@@ -2337,7 +2329,7 @@ static void TAB_DrawBorder(const TAB_INFO *infoPtr, HDC hdc) ...@@ -2337,7 +2329,7 @@ static void TAB_DrawBorder(const TAB_INFO *infoPtr, HDC hdc)
* *
* This method repaints the tab control.. * This method repaints the tab control..
*/ */
static void TAB_Refresh (TAB_INFO *infoPtr, HDC hdc) static void TAB_Refresh (const TAB_INFO *infoPtr, HDC hdc)
{ {
HFONT hOldFont; HFONT hOldFont;
INT i; INT i;
...@@ -2347,7 +2339,7 @@ static void TAB_Refresh (TAB_INFO *infoPtr, HDC hdc) ...@@ -2347,7 +2339,7 @@ static void TAB_Refresh (TAB_INFO *infoPtr, HDC hdc)
hOldFont = SelectObject (hdc, infoPtr->hFont); hOldFont = SelectObject (hdc, infoPtr->hFont);
if (GetWindowLongW(infoPtr->hwnd, GWL_STYLE) & TCS_BUTTONS) if (infoPtr->dwStyle & TCS_BUTTONS)
{ {
for (i = 0; i < infoPtr->uNumItem; i++) for (i = 0; i < infoPtr->uNumItem; i++)
TAB_DrawItem (infoPtr, hdc, i); TAB_DrawItem (infoPtr, hdc, i);
...@@ -2393,18 +2385,17 @@ static void TAB_EnsureSelectionVisible( ...@@ -2393,18 +2385,17 @@ static void TAB_EnsureSelectionVisible(
TAB_INFO* infoPtr) TAB_INFO* infoPtr)
{ {
INT iSelected = infoPtr->iSelected; INT iSelected = infoPtr->iSelected;
LONG lStyle = GetWindowLongW(infoPtr->hwnd, GWL_STYLE);
INT iOrigLeftmostVisible = infoPtr->leftmostVisible; INT iOrigLeftmostVisible = infoPtr->leftmostVisible;
/* set the items row to the bottommost row or topmost row depending on /* set the items row to the bottommost row or topmost row depending on
* style */ * style */
if ((infoPtr->uNumRows > 1) && !(lStyle & TCS_BUTTONS)) if ((infoPtr->uNumRows > 1) && !(infoPtr->dwStyle & TCS_BUTTONS))
{ {
TAB_ITEM *selected = TAB_GetItem(infoPtr, iSelected); TAB_ITEM *selected = TAB_GetItem(infoPtr, iSelected);
INT newselected; INT newselected;
INT iTargetRow; INT iTargetRow;
if(lStyle & TCS_VERTICAL) if(infoPtr->dwStyle & TCS_VERTICAL)
newselected = selected->rect.left; newselected = selected->rect.left;
else else
newselected = selected->rect.top; newselected = selected->rect.top;
...@@ -2416,7 +2407,7 @@ static void TAB_EnsureSelectionVisible( ...@@ -2416,7 +2407,7 @@ static void TAB_EnsureSelectionVisible(
if (newselected != iTargetRow) if (newselected != iTargetRow)
{ {
UINT i; UINT i;
if(lStyle & TCS_VERTICAL) if(infoPtr->dwStyle & TCS_VERTICAL)
{ {
for (i=0; i < infoPtr->uNumItem; i++) for (i=0; i < infoPtr->uNumItem; i++)
{ {
...@@ -2455,7 +2446,7 @@ static void TAB_EnsureSelectionVisible( ...@@ -2455,7 +2446,7 @@ static void TAB_EnsureSelectionVisible(
* Do the trivial cases first. * Do the trivial cases first.
*/ */
if ( (!infoPtr->needsScrolling) || if ( (!infoPtr->needsScrolling) ||
(infoPtr->hwndUpDown==0) || (lStyle & TCS_VERTICAL)) (infoPtr->hwndUpDown==0) || (infoPtr->dwStyle & TCS_VERTICAL))
return; return;
if (infoPtr->leftmostVisible >= iSelected) if (infoPtr->leftmostVisible >= iSelected)
...@@ -2512,7 +2503,6 @@ static void TAB_EnsureSelectionVisible( ...@@ -2512,7 +2503,6 @@ static void TAB_EnsureSelectionVisible(
static void TAB_InvalidateTabArea(const TAB_INFO *infoPtr) static void TAB_InvalidateTabArea(const TAB_INFO *infoPtr)
{ {
RECT clientRect, rInvalidate, rAdjClient; RECT clientRect, rInvalidate, rAdjClient;
DWORD lStyle = GetWindowLongW(infoPtr->hwnd, GWL_STYLE);
INT lastRow = infoPtr->uNumRows - 1; INT lastRow = infoPtr->uNumRows - 1;
RECT rect; RECT rect;
...@@ -2525,19 +2515,19 @@ static void TAB_InvalidateTabArea(const TAB_INFO *infoPtr) ...@@ -2525,19 +2515,19 @@ static void TAB_InvalidateTabArea(const TAB_INFO *infoPtr)
TAB_AdjustRect(infoPtr, 0, &rAdjClient); TAB_AdjustRect(infoPtr, 0, &rAdjClient);
TAB_InternalGetItemRect(infoPtr, infoPtr->uNumItem-1 , &rect, NULL); TAB_InternalGetItemRect(infoPtr, infoPtr->uNumItem-1 , &rect, NULL);
if ((lStyle & TCS_BOTTOM) && (lStyle & TCS_VERTICAL)) if ((infoPtr->dwStyle & TCS_BOTTOM) && (infoPtr->dwStyle & TCS_VERTICAL))
{ {
rInvalidate.left = rAdjClient.right; rInvalidate.left = rAdjClient.right;
if (infoPtr->uNumRows == 1) if (infoPtr->uNumRows == 1)
rInvalidate.bottom = clientRect.top + rect.bottom + 2 * SELECTED_TAB_OFFSET; rInvalidate.bottom = clientRect.top + rect.bottom + 2 * SELECTED_TAB_OFFSET;
} }
else if(lStyle & TCS_VERTICAL) else if(infoPtr->dwStyle & TCS_VERTICAL)
{ {
rInvalidate.right = rAdjClient.left; rInvalidate.right = rAdjClient.left;
if (infoPtr->uNumRows == 1) if (infoPtr->uNumRows == 1)
rInvalidate.bottom = clientRect.top + rect.bottom + 2 * SELECTED_TAB_OFFSET; rInvalidate.bottom = clientRect.top + rect.bottom + 2 * SELECTED_TAB_OFFSET;
} }
else if (lStyle & TCS_BOTTOM) else if (infoPtr->dwStyle & TCS_BOTTOM)
{ {
rInvalidate.top = rAdjClient.bottom; rInvalidate.top = rAdjClient.bottom;
if (infoPtr->uNumRows == 1) if (infoPtr->uNumRows == 1)
...@@ -2679,14 +2669,13 @@ TAB_InsertItemT (TAB_INFO *infoPtr, WPARAM wParam, LPARAM lParam, BOOL bUnicode) ...@@ -2679,14 +2669,13 @@ TAB_InsertItemT (TAB_INFO *infoPtr, WPARAM wParam, LPARAM lParam, BOOL bUnicode)
static LRESULT static LRESULT
TAB_SetItemSize (TAB_INFO *infoPtr, LPARAM lParam) TAB_SetItemSize (TAB_INFO *infoPtr, LPARAM lParam)
{ {
LONG lStyle = GetWindowLongW(infoPtr->hwnd, GWL_STYLE);
LONG lResult = 0; LONG lResult = 0;
BOOL bNeedPaint = FALSE; BOOL bNeedPaint = FALSE;
lResult = MAKELONG(infoPtr->tabWidth, infoPtr->tabHeight); lResult = MAKELONG(infoPtr->tabWidth, infoPtr->tabHeight);
/* UNDOCUMENTED: If requested Width or Height is 0 this means that program wants to use auto size. */ /* UNDOCUMENTED: If requested Width or Height is 0 this means that program wants to use auto size. */
if (lStyle & TCS_FIXEDWIDTH && (infoPtr->tabWidth != (INT)LOWORD(lParam))) if (infoPtr->dwStyle & TCS_FIXEDWIDTH && (infoPtr->tabWidth != (INT)LOWORD(lParam)))
{ {
infoPtr->tabWidth = (INT)LOWORD(lParam); infoPtr->tabWidth = (INT)LOWORD(lParam);
bNeedPaint = TRUE; bNeedPaint = TRUE;
...@@ -3050,9 +3039,10 @@ static LRESULT TAB_Create (HWND hwnd, LPARAM lParam) ...@@ -3050,9 +3039,10 @@ static LRESULT TAB_Create (HWND hwnd, LPARAM lParam)
dwStyle = GetWindowLongW(hwnd, GWL_STYLE); dwStyle = GetWindowLongW(hwnd, GWL_STYLE);
SetWindowLongW(hwnd, GWL_STYLE, dwStyle|WS_CLIPSIBLINGS); SetWindowLongW(hwnd, GWL_STYLE, dwStyle|WS_CLIPSIBLINGS);
infoPtr->dwStyle = dwStyle | WS_CLIPSIBLINGS;
infoPtr->exStyle = (dwStyle & TCS_FLATBUTTONS) ? TCS_EX_FLATSEPARATORS : 0; infoPtr->exStyle = (dwStyle & TCS_FLATBUTTONS) ? TCS_EX_FLATSEPARATORS : 0;
if (dwStyle & TCS_TOOLTIPS) { if (infoPtr->dwStyle & TCS_TOOLTIPS) {
/* Create tooltip control */ /* Create tooltip control */
infoPtr->hwndToolTip = infoPtr->hwndToolTip =
CreateWindowExW (0, TOOLTIPS_CLASSW, NULL, WS_POPUP, CreateWindowExW (0, TOOLTIPS_CLASSW, NULL, WS_POPUP,
...@@ -3091,11 +3081,11 @@ static LRESULT TAB_Create (HWND hwnd, LPARAM lParam) ...@@ -3091,11 +3081,11 @@ static LRESULT TAB_Create (HWND hwnd, LPARAM lParam)
* selected item + extra space for the selected item. * selected item + extra space for the selected item.
*/ */
infoPtr->tabHeight = fontMetrics.tmHeight + SELECTED_TAB_OFFSET + infoPtr->tabHeight = fontMetrics.tmHeight + SELECTED_TAB_OFFSET +
((dwStyle & TCS_BUTTONS) ? 2 : 1) * ((infoPtr->dwStyle & TCS_BUTTONS) ? 2 : 1) *
infoPtr->uVItemPadding; infoPtr->uVItemPadding;
/* Initialize the width of a tab. */ /* Initialize the width of a tab. */
if (dwStyle & TCS_FIXEDWIDTH) if (infoPtr->dwStyle & TCS_FIXEDWIDTH)
infoPtr->tabWidth = GetDeviceCaps(hdc, LOGPIXELSX); infoPtr->tabWidth = GetDeviceCaps(hdc, LOGPIXELSX);
infoPtr->tabMinWidth = -1; infoPtr->tabMinWidth = -1;
...@@ -3239,11 +3229,10 @@ TAB_GetExtendedStyle (const TAB_INFO *infoPtr) ...@@ -3239,11 +3229,10 @@ TAB_GetExtendedStyle (const TAB_INFO *infoPtr)
static LRESULT static LRESULT
TAB_DeselectAll (TAB_INFO *infoPtr, BOOL excludesel) TAB_DeselectAll (TAB_INFO *infoPtr, BOOL excludesel)
{ {
LONG style = GetWindowLongW(infoPtr->hwnd, GWL_STYLE);
BOOL paint = FALSE; BOOL paint = FALSE;
INT i, selected = infoPtr->iSelected; INT i, selected = infoPtr->iSelected;
if (!(style & TCS_BUTTONS)) if (!(infoPtr->dwStyle & TCS_BUTTONS))
return 0; return 0;
for (i = 0; i < infoPtr->uNumItem; i++) for (i = 0; i < infoPtr->uNumItem; i++)
...@@ -3269,6 +3258,34 @@ TAB_DeselectAll (TAB_INFO *infoPtr, BOOL excludesel) ...@@ -3269,6 +3258,34 @@ TAB_DeselectAll (TAB_INFO *infoPtr, BOOL excludesel)
return 0; return 0;
} }
/***
* DESCRIPTION:
* Processes WM_STYLECHANGED messages.
*
* PARAMETER(S):
* [I] infoPtr : valid pointer to the tab data structure
* [I] wStyleType : window style type (normal or extended)
* [I] lpss : window style information
*
* RETURN:
* Zero
*/
static INT TAB_StyleChanged(TAB_INFO *infoPtr, WPARAM wStyleType,
const STYLESTRUCT *lpss)
{
TRACE("(styletype=%lx, styleOld=0x%08x, styleNew=0x%08x)\n",
wStyleType, lpss->styleOld, lpss->styleNew);
if (wStyleType != GWL_STYLE) return 0;
infoPtr->dwStyle = lpss->styleNew;
TAB_SetItemBounds (infoPtr);
InvalidateRect(infoPtr->hwnd, NULL, TRUE);
return 0;
}
static LRESULT WINAPI static LRESULT WINAPI
TAB_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) TAB_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{ {
...@@ -3414,9 +3431,7 @@ TAB_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) ...@@ -3414,9 +3431,7 @@ TAB_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
return TAB_OnHScroll(infoPtr, (int)LOWORD(wParam), (int)HIWORD(wParam)); return TAB_OnHScroll(infoPtr, (int)LOWORD(wParam), (int)HIWORD(wParam));
case WM_STYLECHANGED: case WM_STYLECHANGED:
TAB_SetItemBounds (infoPtr); return TAB_StyleChanged(infoPtr, wParam, (LPSTYLESTRUCT)lParam);
InvalidateRect(hwnd, NULL, TRUE);
return 0;
case WM_SYSCOLORCHANGE: case WM_SYSCOLORCHANGE:
COMCTL32_RefreshSysColors(); COMCTL32_RefreshSysColors();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment