Commit 3ad9f29e authored by Alexandre Julliard's avatar Alexandre Julliard

comctl32/pager: Don't rely on PGN_CALCSIZE to set the non-scrollable dimension of the control.

parent 7a78eed4
...@@ -205,22 +205,24 @@ PAGER_GetBkColor(const PAGER_INFO *infoPtr) ...@@ -205,22 +205,24 @@ PAGER_GetBkColor(const PAGER_INFO *infoPtr)
} }
static void static void
PAGER_CalcSize (const PAGER_INFO *infoPtr, INT* size, BOOL getWidth) PAGER_CalcSize( PAGER_INFO *infoPtr )
{ {
NMPGCALCSIZE nmpgcs; NMPGCALCSIZE nmpgcs;
ZeroMemory (&nmpgcs, sizeof (NMPGCALCSIZE)); ZeroMemory (&nmpgcs, sizeof (NMPGCALCSIZE));
nmpgcs.hdr.hwndFrom = infoPtr->hwndSelf; nmpgcs.hdr.hwndFrom = infoPtr->hwndSelf;
nmpgcs.hdr.idFrom = GetWindowLongPtrW (infoPtr->hwndSelf, GWLP_ID); nmpgcs.hdr.idFrom = GetWindowLongPtrW (infoPtr->hwndSelf, GWLP_ID);
nmpgcs.hdr.code = PGN_CALCSIZE; nmpgcs.hdr.code = PGN_CALCSIZE;
nmpgcs.dwFlag = getWidth ? PGF_CALCWIDTH : PGF_CALCHEIGHT; nmpgcs.dwFlag = (infoPtr->dwStyle & PGS_HORZ) ? PGF_CALCWIDTH : PGF_CALCHEIGHT;
nmpgcs.iWidth = getWidth ? *size : 0; nmpgcs.iWidth = infoPtr->nWidth;
nmpgcs.iHeight = getWidth ? 0 : *size; nmpgcs.iHeight = infoPtr->nHeight;
SendMessageW (infoPtr->hwndNotify, WM_NOTIFY, nmpgcs.hdr.idFrom, (LPARAM)&nmpgcs); SendMessageW (infoPtr->hwndNotify, WM_NOTIFY, nmpgcs.hdr.idFrom, (LPARAM)&nmpgcs);
*size = getWidth ? nmpgcs.iWidth : nmpgcs.iHeight; if (infoPtr->dwStyle & PGS_HORZ)
infoPtr->nWidth = nmpgcs.iWidth;
else
infoPtr->nHeight = nmpgcs.iHeight;
TRACE("[%p] PGN_CALCSIZE returns %s=%d\n", infoPtr->hwndSelf, TRACE("[%p] PGN_CALCSIZE returns %dx%d\n", infoPtr->hwndSelf, nmpgcs.iWidth, nmpgcs.iHeight );
getWidth ? "width" : "height", *size);
} }
static void static void
...@@ -281,16 +283,15 @@ PAGER_GetScrollRange(PAGER_INFO* infoPtr) ...@@ -281,16 +283,15 @@ PAGER_GetScrollRange(PAGER_INFO* infoPtr)
RECT wndRect; RECT wndRect;
GetWindowRect(infoPtr->hwndSelf, &wndRect); GetWindowRect(infoPtr->hwndSelf, &wndRect);
PAGER_CalcSize(infoPtr);
if (infoPtr->dwStyle & PGS_HORZ) if (infoPtr->dwStyle & PGS_HORZ)
{ {
wndSize = wndRect.right - wndRect.left; wndSize = wndRect.right - wndRect.left;
PAGER_CalcSize(infoPtr, &infoPtr->nWidth, TRUE);
childSize = infoPtr->nWidth; childSize = infoPtr->nWidth;
} }
else else
{ {
wndSize = wndRect.bottom - wndRect.top; wndSize = wndRect.bottom - wndRect.top;
PAGER_CalcSize(infoPtr, &infoPtr->nHeight, FALSE);
childSize = infoPtr->nHeight; childSize = infoPtr->nHeight;
} }
...@@ -415,68 +416,6 @@ PAGER_WindowPosChanging(PAGER_INFO* infoPtr, WINDOWPOS *winpos) ...@@ -415,68 +416,6 @@ PAGER_WindowPosChanging(PAGER_INFO* infoPtr, WINDOWPOS *winpos)
return DefWindowProcW (infoPtr->hwndSelf, WM_WINDOWPOSCHANGING, 0, (LPARAM)winpos); return DefWindowProcW (infoPtr->hwndSelf, WM_WINDOWPOSCHANGING, 0, (LPARAM)winpos);
} }
static INT
PAGER_SetFixedWidth(PAGER_INFO* infoPtr)
{
/* Must set the non-scrollable dimension to be less than the full height/width
* so that NCCalcSize is called. The Microsoft docs mention 3/4 factor for button
* size, and experimentation shows that the effect is almost right. */
RECT wndRect;
INT delta, h;
GetWindowRect(infoPtr->hwndSelf, &wndRect);
/* see what the app says for btn width */
PAGER_CalcSize(infoPtr, &infoPtr->nWidth, TRUE);
if (infoPtr->dwStyle & CCS_NORESIZE)
{
delta = wndRect.right - wndRect.left - infoPtr->nWidth;
if (delta > infoPtr->nButtonSize)
infoPtr->nWidth += 4 * infoPtr->nButtonSize / 3;
else if (delta > 0)
infoPtr->nWidth += infoPtr->nButtonSize / 3;
}
h = wndRect.bottom - wndRect.top + infoPtr->nButtonSize;
TRACE("[%p] infoPtr->nWidth set to %d\n",
infoPtr->hwndSelf, infoPtr->nWidth);
return h;
}
static INT
PAGER_SetFixedHeight(PAGER_INFO* infoPtr)
{
/* Must set the non-scrollable dimension to be less than the full height/width
* so that NCCalcSize is called. The Microsoft docs mention 3/4 factor for button
* size, and experimentation shows that the effect is almost right. */
RECT wndRect;
INT delta, w;
GetWindowRect(infoPtr->hwndSelf, &wndRect);
/* see what the app says for btn height */
PAGER_CalcSize(infoPtr, &infoPtr->nHeight, FALSE);
if (infoPtr->dwStyle & CCS_NORESIZE)
{
delta = wndRect.bottom - wndRect.top - infoPtr->nHeight;
if (delta > infoPtr->nButtonSize)
infoPtr->nHeight += infoPtr->nButtonSize;
else if (delta > 0)
infoPtr->nHeight += infoPtr->nButtonSize / 3;
}
w = wndRect.right - wndRect.left + infoPtr->nButtonSize;
TRACE("[%p] infoPtr->nHeight set to %d\n",
infoPtr->hwndSelf, infoPtr->nHeight);
return w;
}
/****************************************************************** /******************************************************************
* For the PGM_RECALCSIZE message (but not the other uses in * * For the PGM_RECALCSIZE message (but not the other uses in *
* this module), the native control does only the following: * * this module), the native control does only the following: *
...@@ -561,28 +500,14 @@ PAGER_SetButtonSize (PAGER_INFO* infoPtr, INT iButtonSize) ...@@ -561,28 +500,14 @@ PAGER_SetButtonSize (PAGER_INFO* infoPtr, INT iButtonSize)
static LRESULT static LRESULT
PAGER_SetChild (PAGER_INFO* infoPtr, HWND hwndChild) PAGER_SetChild (PAGER_INFO* infoPtr, HWND hwndChild)
{ {
INT hw;
infoPtr->hwndChild = IsWindow (hwndChild) ? hwndChild : 0; infoPtr->hwndChild = IsWindow (hwndChild) ? hwndChild : 0;
if (infoPtr->hwndChild) if (infoPtr->hwndChild)
{ {
TRACE("[%p] hwndChild=%p\n", infoPtr->hwndSelf, infoPtr->hwndChild); TRACE("[%p] hwndChild=%p\n", infoPtr->hwndSelf, infoPtr->hwndChild);
if (infoPtr->dwStyle & PGS_HORZ) { SetWindowPos(infoPtr->hwndSelf, 0, 0, 0, 0, 0,
hw = PAGER_SetFixedHeight(infoPtr); SWP_FRAMECHANGED | SWP_NOMOVE | SWP_NOZORDER | SWP_NOSIZE | SWP_NOACTIVATE);
/* adjust non-scrollable dimension to fit the child */
SetWindowPos(infoPtr->hwndSelf, 0, 0, 0, hw, infoPtr->nHeight,
SWP_FRAMECHANGED | SWP_NOMOVE | SWP_NOZORDER |
SWP_NOSIZE | SWP_NOACTIVATE);
}
else {
hw = PAGER_SetFixedWidth(infoPtr);
/* adjust non-scrollable dimension to fit the child */
SetWindowPos(infoPtr->hwndSelf, 0, 0, 0, infoPtr->nWidth, hw,
SWP_FRAMECHANGED | SWP_NOMOVE | SWP_NOZORDER |
SWP_NOSIZE | SWP_NOACTIVATE);
}
/* position child within the page scroller */ /* position child within the page scroller */
SetWindowPos(infoPtr->hwndChild, HWND_TOP, SetWindowPos(infoPtr->hwndChild, HWND_TOP,
...@@ -721,11 +646,12 @@ PAGER_NCCalcSize(PAGER_INFO* infoPtr, WPARAM wParam, LPRECT lpRect) ...@@ -721,11 +646,12 @@ PAGER_NCCalcSize(PAGER_INFO* infoPtr, WPARAM wParam, LPRECT lpRect)
MapWindowPoints (0, infoPtr->hwndSelf, (LPPOINT)&rcChild, 2); /* FIXME: RECT != 2 POINTS */ MapWindowPoints (0, infoPtr->hwndSelf, (LPPOINT)&rcChild, 2); /* FIXME: RECT != 2 POINTS */
GetWindowRect (infoPtr->hwndSelf, &rcWindow); GetWindowRect (infoPtr->hwndSelf, &rcWindow);
infoPtr->nWidth = lpRect->right - lpRect->left;
infoPtr->nHeight = lpRect->bottom - lpRect->top;
PAGER_CalcSize( infoPtr );
if (infoPtr->dwStyle & PGS_HORZ) if (infoPtr->dwStyle & PGS_HORZ)
{ {
infoPtr->nWidth = lpRect->right - lpRect->left;
PAGER_CalcSize (infoPtr, &infoPtr->nWidth, TRUE);
if (infoPtr->TLbtnState && (lpRect->left + infoPtr->nButtonSize < lpRect->right)) if (infoPtr->TLbtnState && (lpRect->left + infoPtr->nButtonSize < lpRect->right))
lpRect->left += infoPtr->nButtonSize; lpRect->left += infoPtr->nButtonSize;
if (infoPtr->BRbtnState && (lpRect->right - infoPtr->nButtonSize > lpRect->left)) if (infoPtr->BRbtnState && (lpRect->right - infoPtr->nButtonSize > lpRect->left))
...@@ -733,9 +659,6 @@ PAGER_NCCalcSize(PAGER_INFO* infoPtr, WPARAM wParam, LPRECT lpRect) ...@@ -733,9 +659,6 @@ PAGER_NCCalcSize(PAGER_INFO* infoPtr, WPARAM wParam, LPRECT lpRect)
} }
else else
{ {
infoPtr->nHeight = lpRect->bottom - lpRect->top;
PAGER_CalcSize (infoPtr, &infoPtr->nHeight, FALSE);
if (infoPtr->TLbtnState && (lpRect->top + infoPtr->nButtonSize < lpRect->bottom)) if (infoPtr->TLbtnState && (lpRect->top + infoPtr->nButtonSize < lpRect->bottom))
lpRect->top += infoPtr->nButtonSize; lpRect->top += infoPtr->nButtonSize;
if (infoPtr->BRbtnState && (lpRect->bottom - infoPtr->nButtonSize > lpRect->top)) if (infoPtr->BRbtnState && (lpRect->bottom - infoPtr->nButtonSize > lpRect->top))
......
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