Commit bd7bdbce authored by Vitaliy Margolen's avatar Vitaliy Margolen Committed by Alexandre Julliard

Fix setting size of tab control.

parent cf4ca4e2
...@@ -79,7 +79,7 @@ typedef struct ...@@ -79,7 +79,7 @@ typedef struct
BOOL DoRedraw; /* flag for redrawing when tab contents is changed*/ BOOL DoRedraw; /* flag for redrawing when tab contents is changed*/
BOOL needsScrolling; /* TRUE if the size of the tabs is greater than BOOL needsScrolling; /* TRUE if the size of the tabs is greater than
* the size of the control */ * the size of the control */
BOOL fSizeSet; /* was the size of the tabs explicitly set? */ BOOL fHeightSet; /* was the height of the tabs explicitly set? */
BOOL bUnicode; /* Unicode control? */ BOOL bUnicode; /* Unicode control? */
HWND hwndUpDown; /* Updown control used for scrolling */ HWND hwndUpDown; /* Updown control used for scrolling */
} TAB_INFO; } TAB_INFO;
...@@ -1102,7 +1102,7 @@ static void TAB_SetItemBounds (HWND hwnd) ...@@ -1102,7 +1102,7 @@ static void TAB_SetItemBounds (HWND hwnd)
curItemLeftPos = 0; curItemLeftPos = 0;
curItemRowCount = infoPtr->uNumItem ? 1 : 0; curItemRowCount = infoPtr->uNumItem ? 1 : 0;
if (!(lStyle & TCS_FIXEDWIDTH) && !((lStyle & TCS_OWNERDRAWFIXED) && infoPtr->fSizeSet) ) if (!(infoPtr->fHeightSet))
{ {
int item_height; int item_height;
int icon_height = 0; int icon_height = 0;
...@@ -1139,7 +1139,7 @@ static void TAB_SetItemBounds (HWND hwnd) ...@@ -1139,7 +1139,7 @@ static void TAB_SetItemBounds (HWND hwnd)
/* Set the leftmost position of the tab. */ /* Set the leftmost position of the tab. */
infoPtr->items[curItem].rect.left = curItemLeftPos; infoPtr->items[curItem].rect.left = curItemLeftPos;
if ( (lStyle & TCS_FIXEDWIDTH) || ((lStyle & TCS_OWNERDRAWFIXED) && infoPtr->fSizeSet)) if ( lStyle & (TCS_FIXEDWIDTH | TCS_OWNERDRAWFIXED) )
{ {
infoPtr->items[curItem].rect.right = infoPtr->items[curItem].rect.left + infoPtr->items[curItem].rect.right = infoPtr->items[curItem].rect.left +
infoPtr->tabWidth + infoPtr->tabWidth +
...@@ -1793,7 +1793,7 @@ static void TAB_DrawItem( ...@@ -1793,7 +1793,7 @@ static void TAB_DrawItem(
if (iItem == infoPtr->iSelected) if (iItem == infoPtr->iSelected)
{ {
/* Background color */ /* Background color */
if (!((lStyle & TCS_OWNERDRAWFIXED) && infoPtr->fSizeSet)) if (!(lStyle & TCS_OWNERDRAWFIXED))
{ {
DeleteObject(hbr); DeleteObject(hbr);
hbr = GetSysColorBrush(COLOR_SCROLLBAR); hbr = GetSysColorBrush(COLOR_SCROLLBAR);
...@@ -2385,15 +2385,20 @@ TAB_Paint (HWND hwnd, WPARAM wParam) ...@@ -2385,15 +2385,20 @@ TAB_Paint (HWND hwnd, WPARAM wParam)
HDC hdc; HDC hdc;
PAINTSTRUCT ps; PAINTSTRUCT ps;
hdc = wParam== 0 ? BeginPaint (hwnd, &ps) : (HDC)wParam; if (wParam == 0)
{
TRACE("erase %d, rect=(%ld,%ld)-(%ld,%ld)\n", hdc = BeginPaint (hwnd, &ps);
ps.fErase, TRACE("erase %d, rect=(%ld,%ld)-(%ld,%ld)\n",
ps.rcPaint.left,ps.rcPaint.top,ps.rcPaint.right,ps.rcPaint.bottom); ps.fErase,
ps.rcPaint.left,ps.rcPaint.top,ps.rcPaint.right,ps.rcPaint.bottom);
if (ps.fErase) if (ps.fErase)
TAB_EraseBackground (hwnd, hdc); TAB_EraseBackground (hwnd, hdc);
} else {
hdc = (HDC)wParam;
}
TAB_Refresh (hwnd, hdc); TAB_Refresh (hwnd, hdc);
if(!wParam) if(!wParam)
...@@ -2557,20 +2562,34 @@ TAB_SetItemSize (HWND hwnd, WPARAM wParam, LPARAM lParam) ...@@ -2557,20 +2562,34 @@ TAB_SetItemSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
TAB_INFO *infoPtr = TAB_GetInfoPtr(hwnd); TAB_INFO *infoPtr = TAB_GetInfoPtr(hwnd);
LONG lStyle = GetWindowLongA(hwnd, GWL_STYLE); LONG lStyle = GetWindowLongA(hwnd, GWL_STYLE);
LONG lResult = 0; LONG lResult = 0;
BOOL bNeedPaint = FALSE;
TRACE("\n"); lResult = MAKELONG(infoPtr->tabWidth, infoPtr->tabHeight);
if ((lStyle & TCS_FIXEDWIDTH) || (lStyle & TCS_OWNERDRAWFIXED))
/* UNDOCUMENTED: If requested Width or Height is 0 this means that program wants to use auto size. */
if ((lStyle & (TCS_FIXEDWIDTH | TCS_OWNERDRAWFIXED)) &&
(infoPtr->tabWidth != (INT)LOWORD(lParam)))
{ {
lResult = MAKELONG(infoPtr->tabWidth, infoPtr->tabHeight); infoPtr->tabWidth = max((INT)LOWORD(lParam), infoPtr->tabMinWidth);
/* UNDOCUMENTED: If requested Width or Height is 0 this means that program wants to use default. */ bNeedPaint = TRUE;
if (LOWORD(lParam)) infoPtr->tabWidth = max((INT)LOWORD(lParam), infoPtr->tabMinWidth);
if (HIWORD(lParam)) infoPtr->tabHeight = (INT)HIWORD(lParam);
TRACE("was h=%d,w=%d, now h=%d,w=%d\n",
HIWORD(lResult), LOWORD(lResult),
infoPtr->tabHeight, infoPtr->tabWidth);
} }
infoPtr->fSizeSet = TRUE;
if (infoPtr->tabHeight != (INT)HIWORD(lParam))
{
if ((infoPtr->fHeightSet = ((INT)HIWORD(lParam) != 0)))
infoPtr->tabHeight = (INT)HIWORD(lParam);
else
TAB_SetItemBounds(hwnd);
bNeedPaint = TRUE;
}
TRACE("was h=%d,w=%d, now h=%d,w=%d\n",
HIWORD(lResult), LOWORD(lResult),
infoPtr->tabHeight, infoPtr->tabWidth);
if (bNeedPaint)
RedrawWindow(hwnd, NULL, NULL, RDW_ERASE | RDW_INVALIDATE | RDW_UPDATENOW);
return lResult; return lResult;
} }
...@@ -2966,7 +2985,7 @@ TAB_Create (HWND hwnd, WPARAM wParam, LPARAM lParam) ...@@ -2966,7 +2985,7 @@ TAB_Create (HWND hwnd, WPARAM wParam, LPARAM lParam)
infoPtr->needsScrolling = FALSE; infoPtr->needsScrolling = FALSE;
infoPtr->hwndUpDown = 0; infoPtr->hwndUpDown = 0;
infoPtr->leftmostVisible = 0; infoPtr->leftmostVisible = 0;
infoPtr->fSizeSet = FALSE; infoPtr->fHeightSet = FALSE;
infoPtr->bUnicode = IsWindowUnicode (hwnd); infoPtr->bUnicode = IsWindowUnicode (hwnd);
TRACE("Created tab control, hwnd [%p]\n", hwnd); TRACE("Created tab control, hwnd [%p]\n", hwnd);
......
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