From f82e493cddcfa96268a65f5a67f21f0d9cafbb21 Mon Sep 17 00:00:00 2001 From: "Guy L. Albertelli" Date: Thu, 12 Oct 2000 23:09:01 +0000 Subject: [PATCH] Rewrite to support rows of bands. Draw separators between bands in rows and between rows. Support text and background color and color propagation. Improve layout code. Make fMask in internal structure the indicator of valid information. Fix size of grippers. Add debugging traces for future. --- dlls/comctl32/rebar.c | 1366 ++++++++++++++++++++++++++--------------- 1 file changed, 862 insertions(+), 504 deletions(-) diff --git a/dlls/comctl32/rebar.c b/dlls/comctl32/rebar.c index bc0e0f2be18..3b8b887e92b 100644 --- a/dlls/comctl32/rebar.c +++ b/dlls/comctl32/rebar.c @@ -1,5 +1,5 @@ /* - * Rebar control + * Rebar control rev 4a * * Copyright 1998, 1999 Eric Kohl * @@ -16,6 +16,26 @@ * - Display code. * - Some messages. * - All notifications. + + * Changes Guy Albertelli + * 1. Correct use of fStyle for fMask + * 2. Rewrite to support putting bands in rows, also supports GETROWCOUNT + * and GETROWHEIGHT. + * 3. Make fMask in internal band info indicate what is valid rather than -1. + * 4. Correct output of GETBANDINFO to match MS for iImage, lpText + * 5. Handle RBN_CHILDSIZE notification (not really working) + * 6. Draw separators between bands and fix size of grippers. + * 7. Draw separators between rows. + * 8. Support RBBS_BREAK if specified by user. + * 9. Support background color for band and draw the background. + * 10. Eliminated duplicate code in SetBandInfo[AW] and InsertBand[AW]. + * 11. Support text color and propagate colors from Bar to Band + * Still to do: + * 1. default row height should be the max height of all visible bands + * 2. Following still not handled: RBBS_FIXEDBMP, RBBS_CHILDEDGE, + * RBBS_VARIABLEHEIGHT, RBBS_USECHEVRON + * 3. GETBANDINFO seems to return correct colors in native but not here. + */ #include @@ -32,6 +52,7 @@ DEFAULT_DEBUG_CHANNEL(rebar); typedef struct { UINT fStyle; + UINT fMask; COLORREF clrFore; COLORREF clrBack; INT iImage; @@ -48,7 +69,13 @@ typedef struct LPARAM lParam; UINT cxHeader; + UINT lcx; /* minimum cx for band */ + UINT hcx; /* maximum cx for band */ + UINT lcy; /* minimum cy for band */ + UINT hcy; /* maximum cy for band */ + UINT uMinHeight; + INT iRow; /* row this band assigned to */ UINT fDraw; /* drawing flags */ RECT rcBand; /* calculated band rectangle */ RECT rcGripper; /* calculated gripper rectangle */ @@ -66,6 +93,7 @@ typedef struct COLORREF clrText; /* text color */ HIMAGELIST himl; /* handle to imagelist */ UINT uNumBands; /* number of bands in the rebar */ + UINT uNumRows; /* number of rows of bands */ HWND hwndToolTip; /* handle to the tool tip control */ HWND hwndNotify; /* notification window (parent) */ HFONT hFont; /* handle to the rebar's font */ @@ -89,35 +117,103 @@ typedef struct #define DRAW_IMAGE 2 #define DRAW_TEXT 4 #define DRAW_CHILD 8 +#define DRAW_SEP 16 -#define GRIPPER_WIDTH 13 - +#define GRIPPER_WIDTH 8 +#define GRIPPER_HEIGHT 16 +#define SEP_WIDTH 3 #define REBAR_GetInfoPtr(wndPtr) ((REBAR_INFO *)GetWindowLongA (hwnd, 0)) +static VOID +REBAR_DumpBandInfo( LPREBARBANDINFOA pB) +{ + TRACE("band info: ID=%u, size=%u, style=0x%08x, mask=0x%08x, child=%04x\n", + pB->wID, pB->cbSize, pB->fStyle, pB->fMask, pB->hwndChild); + TRACE("band info: cx=%u, xMin=%u, yMin=%u, yChild=%u, yMax=%u, yIntgl=%u\n", + pB->cx, pB->cxMinChild, + pB->cyMinChild, pB->cyChild, pB->cyMaxChild, pB->cyIntegral); + TRACE("band info: xIdeal=%u, xHeader=%u, lParam=0x%08lx, clrF=0x%06lx, clrB=0x%06lx\n", + pB->cxIdeal, pB->cxHeader, pB->lParam, pB->clrFore, pB->clrBack); +} static VOID -REBAR_DrawBand (HDC hdc, REBAR_INFO *infoPtr, REBAR_BAND *lpBand) +REBAR_DumpBand (HWND hwnd) +{ + REBAR_INFO *iP = REBAR_GetInfoPtr (hwnd); + REBAR_BAND *pB; + UINT i; + + if( TRACE_ON(rebar) ) { + + TRACE("hwnd=%04x: color=%08lx/%08lx, bands=%u, rows=%u, cSize=%ld,%ld\n", + hwnd, iP->clrText, iP->clrBk, iP->uNumBands, iP->uNumRows, + iP->calcSize.cx, iP->calcSize.cy); + for (i = 0; i < iP->uNumBands; i++) { + pB = &iP->bands[i]; + TRACE("band # %u: ID=%u, mask=0x%08x, style=0x%08x, child=%04x, row=%u\n", + i, pB->wID, pB->fMask, pB->fStyle, pB->hwndChild, pB->iRow); + TRACE("band # %u: xMin=%u, yMin=%u, cx=%u, yChild=%u, yMax=%u, yIntgl=%u, uMinH=%u,\n", + i, pB->cxMinChild, pB->cyMinChild, pB->cx, + pB->cyChild, pB->cyMaxChild, pB->cyIntegral, pB->uMinHeight); + TRACE("band # %u: header=%u, lcx=%u, hcx=%u, lcy=%u, hcy=%u\n", + i, pB->cxHeader, pB->lcx, pB->hcx, pB->lcy, pB->hcy); + TRACE("band # %u: fDraw=%08x, Band=(%d,%d)-(%d,%d), Grip=(%d,%d)-(%d,%d)\n", + i, pB->fDraw, + pB->rcBand.left, pB->rcBand.top, pB->rcBand.right, pB->rcBand.bottom, + pB->rcGripper.left, pB->rcGripper.top, pB->rcGripper.right, pB->rcGripper.bottom); + TRACE("band # %u: Img=(%d,%d)-(%d,%d), Txt=(%d,%d)-(%d,%d), Child=(%d,%d)-(%d,%d)\n", + i, + pB->rcCapImage.left, pB->rcCapImage.top, pB->rcCapImage.right, pB->rcCapImage.bottom, + pB->rcCapText.left, pB->rcCapText.top, pB->rcCapText.right, pB->rcCapText.bottom, + pB->rcChild.left, pB->rcChild.top, pB->rcChild.right, pB->rcChild.bottom); + } + + } +} + +static VOID +REBAR_DrawBand (HDC hdc, REBAR_INFO *infoPtr, REBAR_BAND *lpBand, DWORD dwStyle) { - DrawEdge (hdc, &lpBand->rcBand, BDR_RAISEDINNER, BF_MIDDLE); + /* draw separator */ + if (lpBand->fDraw & DRAW_SEP) { + RECT rcSep; + if (dwStyle & CCS_VERT) + SetRect (&rcSep, lpBand->rcBand.left-2, lpBand->rcBand.top-SEP_WIDTH, + lpBand->rcBand.right+2, lpBand->rcBand.top-1); + else + SetRect (&rcSep, lpBand->rcBand.left-SEP_WIDTH, lpBand->rcBand.top-2, + lpBand->rcBand.left-1, lpBand->rcBand.bottom+2); + TRACE("drawing band separator (%d,%d)-(%d,%d)\n", + rcSep.left, rcSep.top, rcSep.right, rcSep.bottom); + DrawEdge (hdc, &rcSep, EDGE_ETCHED, BF_LEFT | BF_TOP | BF_MIDDLE); + } /* draw background */ + if (lpBand->clrBack != CLR_NONE) { + HBRUSH brh = CreateSolidBrush (lpBand->clrBack); + TRACE("backround color=0x%06lx, rect (%d,%d)-(%d,%d)\n", + lpBand->clrBack, + lpBand->rcBand.left,lpBand->rcBand.top, + lpBand->rcBand.right,lpBand->rcBand.bottom); + FillRect (hdc, &lpBand->rcBand, brh); + DeleteObject (brh); + } /* draw gripper */ if (lpBand->fDraw & DRAW_GRIPPER) - DrawEdge (hdc, &lpBand->rcGripper, BDR_RAISEDINNER, BF_RECT | BF_MIDDLE); + DrawEdge (hdc, &lpBand->rcGripper, BDR_RAISEDINNER, BF_RECT | BF_MIDDLE); /* draw caption image */ if (lpBand->fDraw & DRAW_IMAGE) { - /* FIXME: center image */ POINT pt; + /* center image */ pt.y = (lpBand->rcCapImage.bottom + lpBand->rcCapImage.top - infoPtr->imageSize.cy)/2; pt.x = (lpBand->rcCapImage.right + lpBand->rcCapImage.left - infoPtr->imageSize.cx)/2; ImageList_Draw (infoPtr->himl, lpBand->iImage, hdc, -/* lpBand->rcCapImage.left, lpBand->rcCapImage.top, */ pt.x, pt.y, ILD_TRANSPARENT); } @@ -126,10 +222,15 @@ REBAR_DrawBand (HDC hdc, REBAR_INFO *infoPtr, REBAR_BAND *lpBand) if (lpBand->fDraw & DRAW_TEXT) { HFONT hOldFont = SelectObject (hdc, infoPtr->hFont); INT oldBkMode = SetBkMode (hdc, TRANSPARENT); + COLORREF oldcolor = CLR_NONE; + if (lpBand->clrFore != CLR_NONE) + oldcolor = SetTextColor (hdc, lpBand->clrFore); DrawTextW (hdc, lpBand->lpText, -1, &lpBand->rcCapText, DT_CENTER | DT_VCENTER | DT_SINGLELINE); if (oldBkMode != TRANSPARENT) SetBkMode (hdc, oldBkMode); + if (lpBand->clrFore != CLR_NONE) + SetTextColor (hdc, oldcolor); SelectObject (hdc, hOldFont); } } @@ -140,35 +241,150 @@ REBAR_Refresh (HWND hwnd, HDC hdc) { REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd); REBAR_BAND *lpBand; - UINT i; + UINT i, oldrow; + RECT rcRowSep; + DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE); + oldrow = infoPtr->bands[0].iRow; for (i = 0; i < infoPtr->uNumBands; i++) { lpBand = &infoPtr->bands[i]; if ((lpBand->fStyle & RBBS_HIDDEN) || - ((GetWindowLongA (hwnd, GWL_STYLE) & CCS_VERT) && + ((dwStyle & CCS_VERT) && (lpBand->fStyle & RBBS_NOVERT))) continue; - REBAR_DrawBand (hdc, infoPtr, lpBand); + /* if a new row then draw a separator */ + if (oldrow != lpBand->iRow) { + if (dwStyle & CCS_VERT) { + SetRect (&rcRowSep, lpBand->rcBand.left-2, 0, + lpBand->rcBand.left-1, infoPtr->calcSize.cy); + } + else { + SetRect (&rcRowSep, 0, lpBand->rcBand.top-2, + infoPtr->calcSize.cx, lpBand->rcBand.top-1); + } + TRACE ("drawing row sep (%d,%d)-(%d,%d)\n", + rcRowSep.left, rcRowSep.top, rcRowSep.right, rcRowSep.bottom); + DrawEdge (hdc, &rcRowSep, EDGE_ETCHED, BF_TOP|BF_LEFT); + oldrow = lpBand->iRow; + } + + /* now draw the band */ + REBAR_DrawBand (hdc, infoPtr, lpBand, dwStyle); } } - -static VOID -REBAR_CalcHorzBand (REBAR_INFO *infoPtr, REBAR_BAND *lpBand) +static void +REBAR_AdjustBands (REBAR_INFO *infoPtr, UINT rowstart, UINT rowend, + INT maxx, INT usedx, INT mcy, DWORD dwStyle) + /* Function: This routine distributes the extra space in a row */ + /* evenly over the adjustable bands in the row. It also makes */ + /* sure that all bands in the row are the same height. */ { - lpBand->fDraw = 0; + REBAR_BAND *lpBand; + UINT i, j; + INT incr, lastx=0; - /* set initial caption image rectangle */ - SetRect (&lpBand->rcCapImage, 0, 0, 0, 0); + TRACE("start=%u, end=%u, max x=%d, used x=%d, max y=%d\n", + rowstart, rowend, maxx, usedx, mcy); - /* image is visible */ - if ((lpBand->iImage > -1) && (infoPtr->himl)) { + j = 0; + for (i = rowstart; i<=rowend; i++) { + lpBand = &infoPtr->bands[i]; + if ((lpBand->fMask & RBBIM_CHILD) && lpBand->hwndChild && + !(lpBand->fStyle & RBBS_FIXEDSIZE)) + j++; + } + if (j) + incr = (maxx-usedx) / j; + else + incr = 0; + + TRACE("adjusting %u of %u bands in row, incr=%d\n", + j, rowend-rowstart+1, incr); + + for (i = rowstart; i<=rowend; i++) { + lpBand = &infoPtr->bands[i]; + if (dwStyle & CCS_VERT) { + lpBand->rcBand.bottom = lastx + + lpBand->rcBand.bottom - lpBand->rcBand.top; + if ((lpBand->fMask & RBBIM_CHILD) && lpBand->hwndChild && + !(lpBand->fStyle & RBBS_FIXEDSIZE)) { + /* if a child window exists and not fixed then widen it */ + lpBand->rcBand.bottom += incr; + } + lpBand->rcBand.top = lastx; + lastx = lpBand->rcBand.bottom + 1; + lpBand->rcBand.right = lpBand->rcBand.left + mcy; + } + else { + lpBand->rcBand.right = lastx + + lpBand->rcBand.right - lpBand->rcBand.left; + if ((lpBand->fMask & RBBIM_CHILD) && lpBand->hwndChild && + !(lpBand->fStyle & RBBS_FIXEDSIZE)) { + /* if a child window exists and not fixed then widen it */ + lpBand->rcBand.right += incr; + } + lpBand->rcBand.left = lastx; + lastx = lpBand->rcBand.right + 1; + lpBand->rcBand.bottom = lpBand->rcBand.top + mcy; + } + } + +} + +static void +REBAR_CalcHorzBand (HWND hwnd, REBAR_INFO *infoPtr, UINT rstart, UINT rend, BOOL notify, DWORD dwStyle) + /* Function: this routine initializes all the rectangles in */ + /* each band in a row to fit in the adjusted rcBand rect. */ + /* *** Supports only Horizontal bars. *** */ +{ + REBAR_BAND *lpBand; + UINT i, xoff, yoff; + NMREBARCHILDSIZE rbcz; + HWND parenthwnd; + RECT oldChild; + + rbcz.hdr.hwndFrom = hwnd; + rbcz.hdr.idFrom = GetWindowLongA (hwnd, GWL_ID); + /* MS seems to use GetDlgCtrlID() for above GetWindowLong call */ + parenthwnd = GetParent (hwnd); + + for(i=rstart; i<=rend; i++){ + lpBand = &infoPtr->bands[i]; + oldChild = lpBand->rcChild; + + /* set initial gripper rectangle */ + SetRect (&lpBand->rcGripper, lpBand->rcBand.left, lpBand->rcBand.top, + lpBand->rcBand.left, lpBand->rcBand.bottom); + + /* calculate gripper rectangle */ + if ((!(lpBand->fStyle & RBBS_NOGRIPPER)) && + (!(lpBand->fStyle & RBBS_FIXEDSIZE)) && + ((lpBand->fStyle & RBBS_GRIPPERALWAYS) || + (infoPtr->uNumBands > 1))) { + lpBand->fDraw |= DRAW_GRIPPER; + lpBand->rcGripper.left += 1; + lpBand->rcGripper.right = lpBand->rcGripper.left + 3; + lpBand->rcGripper.top += 3; + lpBand->rcGripper.bottom -= 3; + + SetRect (&lpBand->rcCapImage, lpBand->rcGripper.left + GRIPPER_WIDTH, + lpBand->rcBand.top, lpBand->rcGripper.left + GRIPPER_WIDTH, + lpBand->rcBand.bottom); + } + else { + SetRect (&lpBand->rcCapImage, lpBand->rcBand.left, lpBand->rcBand.top, + lpBand->rcBand.left, lpBand->rcBand.bottom); + } + + /* image is visible */ + if ((lpBand->fMask & RBBIM_IMAGE) && (infoPtr->himl)) { lpBand->fDraw |= DRAW_IMAGE; - lpBand->rcCapImage.right = lpBand->rcCapImage.left + infoPtr->imageSize.cx; + lpBand->rcCapImage.right += infoPtr->imageSize.cx; lpBand->rcCapImage.bottom = lpBand->rcCapImage.top + infoPtr->imageSize.cy; /* update band height */ @@ -176,16 +392,14 @@ REBAR_CalcHorzBand (REBAR_INFO *infoPtr, REBAR_BAND *lpBand) lpBand->uMinHeight = infoPtr->imageSize.cy + 2; lpBand->rcBand.bottom = lpBand->rcBand.top + lpBand->uMinHeight; } - } + } - /* set initial caption text rectangle */ - lpBand->rcCapText.left = lpBand->rcCapImage.right; - lpBand->rcCapText.top = lpBand->rcBand.top + 1; - lpBand->rcCapText.right = lpBand->rcCapText.left; - lpBand->rcCapText.bottom = lpBand->rcBand.bottom - 1; + /* set initial caption text rectangle */ + SetRect (&lpBand->rcCapText, lpBand->rcCapImage.right, lpBand->rcBand.top+1, + lpBand->rcCapImage.right, lpBand->rcBand.bottom-1); - /* text is visible */ - if (lpBand->lpText) { + /* text is visible */ + if ((lpBand->fMask & RBBIM_TEXT) && (lpBand->lpText)) { HDC hdc = GetDC (0); HFONT hOldFont = SelectObject (hdc, infoPtr->hFont); SIZE size; @@ -193,79 +407,151 @@ REBAR_CalcHorzBand (REBAR_INFO *infoPtr, REBAR_BAND *lpBand) lpBand->fDraw |= DRAW_TEXT; GetTextExtentPoint32W (hdc, lpBand->lpText, lstrlenW (lpBand->lpText), &size); - lpBand->rcCapText.right += size.cx; + lpBand->rcCapText.right += (size.cx + 2); SelectObject (hdc, hOldFont); ReleaseDC (0, hdc); + } + + /* set initial child window rectangle if there is a child */ + if (lpBand->fMask & RBBIM_CHILD) { + if (lpBand->fStyle & RBBS_FIXEDSIZE) { + xoff = 0; + yoff = 0; + } + else { + xoff = 4; + yoff = 2; + } + SetRect (&lpBand->rcChild, + lpBand->rcBand.left+lpBand->cxHeader+xoff, lpBand->rcBand.top+yoff, + lpBand->rcBand.right-xoff, lpBand->rcBand.bottom-yoff); + } + else { + SetRect (&lpBand->rcChild, + lpBand->rcBand.right, lpBand->rcBand.top, + lpBand->rcBand.right, lpBand->rcBand.bottom); + } + +#if 1 + /* do notify is child rectangle changed */ + if (notify && !EqualRect (&oldChild, &lpBand->rcChild)) { + TRACE("Child rectangle changed for band %u\n", i); + TRACE(" from (%d,%d)-(%d,%d) to (%d,%d)-(%d,%d)\n", + oldChild.left, oldChild.top, + oldChild.right, oldChild.bottom, + lpBand->rcChild.left, lpBand->rcChild.top, + lpBand->rcChild.right, lpBand->rcChild.bottom); + rbcz.hdr.code = RBN_CHILDSIZE; + rbcz.uBand = i; + rbcz.wID = lpBand->wID; + rbcz.rcChild = lpBand->rcChild; + rbcz.rcBand = lpBand->rcBand; + SendMessageA (parenthwnd, WM_NOTIFY, (WPARAM) rbcz.hdr.idFrom, + (LPARAM)&rbcz); + if (!EqualRect (&lpBand->rcChild, &rbcz.rcChild)) { + TRACE("Child rect changed by NOTIFY for band %u\n", i); + TRACE(" from (%d,%d)-(%d,%d) to (%d,%d)-(%d,%d)\n", + lpBand->rcChild.left, lpBand->rcChild.top, + lpBand->rcChild.right, lpBand->rcChild.bottom, + rbcz.rcChild.left, rbcz.rcChild.top, + rbcz.rcChild.right, rbcz.rcChild.bottom); + } + } +#endif + } - /* set initial child window rectangle */ - if (lpBand->fStyle & RBBS_FIXEDSIZE) { - lpBand->rcChild.left = lpBand->rcCapText.right; - lpBand->rcChild.top = lpBand->rcBand.top; - lpBand->rcChild.right = lpBand->rcBand.right; - lpBand->rcChild.bottom = lpBand->rcBand.bottom; - } - else { - lpBand->rcChild.left = lpBand->rcCapText.right + 4; - lpBand->rcChild.top = lpBand->rcBand.top + 2; - lpBand->rcChild.right = lpBand->rcBand.right - 4; - lpBand->rcChild.bottom = lpBand->rcBand.bottom - 2; - } - - /* calculate gripper rectangle */ - if ((!(lpBand->fStyle & RBBS_NOGRIPPER)) && - (!(lpBand->fStyle & RBBS_FIXEDSIZE)) && - ((lpBand->fStyle & RBBS_GRIPPERALWAYS) || - (infoPtr->uNumBands > 1))) { - lpBand->fDraw |= DRAW_GRIPPER; - lpBand->rcGripper.left = lpBand->rcBand.left + 3; - lpBand->rcGripper.right = lpBand->rcGripper.left + 3; - lpBand->rcGripper.top = lpBand->rcBand.top + 3; - lpBand->rcGripper.bottom = lpBand->rcBand.bottom - 3; - - /* move caption rectangles */ - OffsetRect (&lpBand->rcCapImage, GRIPPER_WIDTH, 0); - OffsetRect (&lpBand->rcCapText, GRIPPER_WIDTH, 0); - - /* adjust child rectangle */ - lpBand->rcChild.left += GRIPPER_WIDTH; - } - - } static VOID -REBAR_CalcVertBand (HWND hwnd, REBAR_INFO *infoPtr, REBAR_BAND *lpBand) +REBAR_CalcVertBand (HWND hwnd, REBAR_INFO *infoPtr, UINT rstart, UINT rend, BOOL notify, DWORD dwStyle) + /* Function: this routine initializes all the rectangles in */ + /* each band in a row to fit in the adjusted rcBand rect. */ + /* *** Supports only Vertical bars. *** */ { - lpBand->fDraw = 0; + REBAR_BAND *lpBand; + UINT i, xoff, yoff; + NMREBARCHILDSIZE rbcz; + HWND parenthwnd; + RECT oldChild; - /* set initial caption image rectangle */ - SetRect (&lpBand->rcCapImage, 0, 0, 0, 0); + rbcz.hdr.hwndFrom = hwnd; + rbcz.hdr.idFrom = GetWindowLongA (hwnd, GWL_ID); + /* MS seems to use GetDlgCtrlID() for above GetWindowLong call */ + parenthwnd = GetParent (hwnd); - /* image is visible */ - if ((lpBand->iImage > -1) && (infoPtr->himl)) { + for(i=rstart; i<=rend; i++){ + lpBand = &infoPtr->bands[i]; + oldChild = lpBand->rcChild; + + /* set initial gripper rectangle */ + SetRect (&lpBand->rcGripper, lpBand->rcBand.left, lpBand->rcBand.top, + lpBand->rcBand.right, lpBand->rcBand.top); + + /* calculate gripper rectangle */ + if ((!(lpBand->fStyle & RBBS_NOGRIPPER)) && + (!(lpBand->fStyle & RBBS_FIXEDSIZE)) && + ((lpBand->fStyle & RBBS_GRIPPERALWAYS) || + (infoPtr->uNumBands > 1))) { + lpBand->fDraw |= DRAW_GRIPPER; + + if (dwStyle & RBS_VERTICALGRIPPER) { + /* vertical gripper */ + lpBand->rcGripper.left += 3; + lpBand->rcGripper.right = lpBand->rcGripper.left + 3; + lpBand->rcGripper.top += 3; + lpBand->rcGripper.bottom = lpBand->rcGripper.top + GRIPPER_HEIGHT; + + /* initialize Caption image rectangle */ + SetRect (&lpBand->rcCapImage, lpBand->rcBand.left, + lpBand->rcGripper.top + GRIPPER_HEIGHT, + lpBand->rcBand.right, + lpBand->rcGripper.top + GRIPPER_HEIGHT); + } + else { + /* horizontal gripper */ + lpBand->rcGripper.left += 3; + lpBand->rcGripper.right -= 3; + lpBand->rcGripper.top += 3; + lpBand->rcGripper.bottom = lpBand->rcGripper.top + 3; + + /* initialize Caption image rectangle */ + SetRect (&lpBand->rcCapImage, lpBand->rcBand.left, + lpBand->rcGripper.top + GRIPPER_WIDTH, + lpBand->rcBand.right, + lpBand->rcGripper.top + GRIPPER_WIDTH); + } + } + else { + /* initialize Caption image rectangle */ + SetRect (&lpBand->rcCapImage, lpBand->rcBand.left, lpBand->rcBand.top, + lpBand->rcBand.right, lpBand->rcBand.top); + } + + /* image is visible */ + if ((lpBand->fMask & RBBIM_IMAGE) && (infoPtr->himl)) { lpBand->fDraw |= DRAW_IMAGE; - lpBand->rcCapImage.right = lpBand->rcCapImage.left + infoPtr->imageSize.cx; - lpBand->rcCapImage.bottom = lpBand->rcCapImage.top + infoPtr->imageSize.cy; + lpBand->rcCapImage.right += infoPtr->imageSize.cx; + lpBand->rcCapImage.bottom += infoPtr->imageSize.cy; - /* update band width */ + /* update band height */ if (lpBand->uMinHeight < infoPtr->imageSize.cx + 2) { lpBand->uMinHeight = infoPtr->imageSize.cx + 2; lpBand->rcBand.right = lpBand->rcBand.left + lpBand->uMinHeight; } - } + } - /* set initial caption text rectangle */ - lpBand->rcCapText.left = lpBand->rcBand.left + 1; - lpBand->rcCapText.top = lpBand->rcCapImage.bottom; - lpBand->rcCapText.right = lpBand->rcBand.right - 1; - lpBand->rcCapText.bottom = lpBand->rcCapText.top; + /* set initial caption text rectangle */ + lpBand->rcCapText.left = lpBand->rcBand.left + 1; + lpBand->rcCapText.top = lpBand->rcCapImage.bottom; + lpBand->rcCapText.right = lpBand->rcBand.right - 1; + lpBand->rcCapText.bottom = lpBand->rcCapText.top; - /* text is visible */ - if (lpBand->lpText) { + /* text is visible */ + if (lpBand->lpText) { HDC hdc = GetDC (0); HFONT hOldFont = SelectObject (hdc, infoPtr->hFont); SIZE size; @@ -273,150 +559,241 @@ REBAR_CalcVertBand (HWND hwnd, REBAR_INFO *infoPtr, REBAR_BAND *lpBand) lpBand->fDraw |= DRAW_TEXT; GetTextExtentPoint32W (hdc, lpBand->lpText, lstrlenW (lpBand->lpText), &size); -/* lpBand->rcCapText.right += size.cx; */ - lpBand->rcCapText.bottom += size.cy; + lpBand->rcCapText.bottom += (size.cy + 2); SelectObject (hdc, hOldFont); ReleaseDC (0, hdc); - } + } - /* set initial child window rectangle */ - if (lpBand->fStyle & RBBS_FIXEDSIZE) { - lpBand->rcChild.left = lpBand->rcBand.left; - lpBand->rcChild.top = lpBand->rcCapText.bottom; - lpBand->rcChild.right = lpBand->rcBand.right; - lpBand->rcChild.bottom = lpBand->rcBand.bottom; - } - else { - lpBand->rcChild.left = lpBand->rcBand.left + 2; - lpBand->rcChild.top = lpBand->rcCapText.bottom + 4; - lpBand->rcChild.right = lpBand->rcBand.right - 2; - lpBand->rcChild.bottom = lpBand->rcBand.bottom - 4; - } + /* set initial child window rectangle if there is a child */ + if (lpBand->fMask & RBBIM_CHILD) { + if (lpBand->fStyle & RBBS_FIXEDSIZE) { + xoff = 0; + yoff = 0; + } + else { + xoff = 2; + yoff = 4; + } + SetRect (&lpBand->rcChild, + lpBand->rcBand.left+xoff, + lpBand->rcBand.top+lpBand->cxHeader+yoff, + lpBand->rcBand.right-xoff, lpBand->rcBand.bottom-yoff); + } + else { + SetRect (&lpBand->rcChild, + lpBand->rcBand.right, lpBand->rcBand.top, + lpBand->rcBand.right, lpBand->rcBand.top); + } - /* calculate gripper rectangle */ - if ((!(lpBand->fStyle & RBBS_NOGRIPPER)) && - (!(lpBand->fStyle & RBBS_FIXEDSIZE)) && - ((lpBand->fStyle & RBBS_GRIPPERALWAYS) || - (infoPtr->uNumBands > 1))) { - lpBand->fDraw |= DRAW_GRIPPER; - - if (GetWindowLongA (hwnd, GWL_STYLE) & RBS_VERTICALGRIPPER) { - /* adjust band width */ - lpBand->rcBand.right += GRIPPER_WIDTH; - lpBand->uMinHeight += GRIPPER_WIDTH; - - lpBand->rcGripper.left = lpBand->rcBand.left + 3; - lpBand->rcGripper.right = lpBand->rcGripper.left + 3; - lpBand->rcGripper.top = lpBand->rcBand.top + 3; - lpBand->rcGripper.bottom = lpBand->rcBand.bottom - 3; - - /* move caption rectangles */ - OffsetRect (&lpBand->rcCapImage, GRIPPER_WIDTH, 0); - OffsetRect (&lpBand->rcCapText, GRIPPER_WIDTH, 0); - - /* adjust child rectangle */ - lpBand->rcChild.left += GRIPPER_WIDTH; +#if 1 + /* do notify is child rectangle changed */ + if (notify && !EqualRect (&oldChild, &lpBand->rcChild)) { + TRACE("Child rectangle changed for band %u\n", i); + TRACE(" from (%d,%d)-(%d,%d) to (%d,%d)-(%d,%d)\n", + oldChild.left, oldChild.top, + oldChild.right, oldChild.bottom, + lpBand->rcChild.left, lpBand->rcChild.top, + lpBand->rcChild.right, lpBand->rcChild.bottom); + rbcz.hdr.code = RBN_CHILDSIZE; + rbcz.uBand = i; + rbcz.wID = lpBand->wID; + rbcz.rcChild = lpBand->rcChild; + rbcz.rcBand = lpBand->rcBand; + SendMessageA (parenthwnd, WM_NOTIFY, (WPARAM) rbcz.hdr.idFrom, + (LPARAM)&rbcz); + if (!EqualRect (&lpBand->rcChild, &rbcz.rcChild)) { + TRACE("Child rect changed by NOTIFY for band %u\n", i); + TRACE(" from (%d,%d)-(%d,%d) to (%d,%d)-(%d,%d)\n", + lpBand->rcChild.left, lpBand->rcChild.top, + lpBand->rcChild.right, lpBand->rcChild.bottom, + rbcz.rcChild.left, rbcz.rcChild.top, + rbcz.rcChild.right, rbcz.rcChild.bottom); } - else { - lpBand->rcGripper.left = lpBand->rcBand.left + 3; - lpBand->rcGripper.right = lpBand->rcBand.right - 3; - lpBand->rcGripper.top = lpBand->rcBand.top + 3; - lpBand->rcGripper.bottom = lpBand->rcGripper.top + 3; + } +#endif - /* move caption rectangles */ - OffsetRect (&lpBand->rcCapImage, 0, GRIPPER_WIDTH); - OffsetRect (&lpBand->rcCapText, 0, GRIPPER_WIDTH); - - /* adjust child rectangle */ - lpBand->rcChild.top += GRIPPER_WIDTH; - } } } static VOID -REBAR_Layout (HWND hwnd, LPRECT lpRect) +REBAR_Layout (HWND hwnd, LPRECT lpRect, BOOL notify, BOOL resetclient) + /* Function: This routine is resposible for laying out all */ + /* the bands in a rebar. It assigns each band to a row and*/ + /* determines when to start a new row. */ { REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd); DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE); REBAR_BAND *lpBand; - RECT rcClient; - INT x, y, cx, cy; - UINT i; + RECT rcClient, rcAdj; + INT x, y, cx, cxsep, mcy, clientcx, clientcy, adjcx, adjcy, row, rightx, bottomy; + UINT i, rowstartband; + BOOL dobreak; - if (lpRect) - rcClient = *lpRect; - else - GetClientRect (hwnd, &rcClient); + GetClientRect (hwnd, &rcClient); + TRACE("Client is (%d,%d)-(%d,%d)\n", + rcClient.left, rcClient.top, rcClient.right, rcClient.bottom); - x = 0; - y = 0; - - if (dwStyle & CCS_VERT) { - cx = 20; /* FIXME: fixed height */ - cy = rcClient.bottom - rcClient.top; + if (lpRect) { + rcAdj = *lpRect; + TRACE("adjustment rect is (%d,%d)-(%d,%d)\n", + rcAdj.left, rcAdj.top, rcAdj.right, rcAdj.bottom); } else { - cx = rcClient.right - rcClient.left; - cy = 20; /* FIXME: fixed height */ + CopyRect (&rcAdj, &rcClient); } + clientcx = rcClient.right - rcClient.left; + clientcy = rcClient.bottom - rcClient.top; + adjcx = rcAdj.right - rcAdj.left; + adjcy = rcAdj.bottom - rcAdj.top; + if (resetclient) { + TRACE("window client rect will be set to adj rect\n"); + clientcx = adjcx; + clientcy = adjcy; + } + x = 0; + y = 0; + rowstartband = 0; + row = 1; + cx = 0; + mcy = 0; + for (i = 0; i < infoPtr->uNumBands; i++) { lpBand = &infoPtr->bands[i]; + lpBand->fDraw = 0; + lpBand->iRow = row; if ((lpBand->fStyle & RBBS_HIDDEN) || ((dwStyle & CCS_VERT) && (lpBand->fStyle & RBBS_NOVERT))) continue; + cxsep = (x==0) ? 0 : SEP_WIDTH; /* separator from previous band */ + cx = lpBand->cxHeader + /* Header: includes gripper, text, image */ + lpBand->hcx; /* coumpted size of child */ - if (dwStyle & CCS_VERT) { - if (lpBand->fStyle & RBBS_VARIABLEHEIGHT) - cx = lpBand->cyMaxChild; - else if (lpBand->fStyle & RBBIM_CHILDSIZE) - cx = lpBand->cyMinChild; - else - cx = 20; /* FIXME */ + if (dwStyle & CCS_VERT) + dobreak = (y + cx + cxsep > adjcy); + else + dobreak = (x + cx + cxsep > adjcx); + /* This is the check for whether we need to start a new row */ + if (((dwStyle & CCS_VERT) ? (y != 0) : (x != 0)) && + ((lpBand->fStyle & RBBS_BREAK) || + dobreak)) { + TRACE("Spliting to new row %d on band %u\n", row+1, i); - lpBand->rcBand.left = x; - lpBand->rcBand.right = x + cx; - lpBand->rcBand.top = y; - lpBand->rcBand.bottom = y + cy; - lpBand->uMinHeight = cx; + if (dwStyle & CCS_VERT) { + /* first adjust all bands in previous current row to */ + /* redistribute extra x pixels */ + REBAR_AdjustBands (infoPtr, rowstartband, i-1, + clientcy, y, mcy, dwStyle); + /* calculate band subrectangles and break to new row */ + REBAR_CalcVertBand (hwnd, infoPtr, rowstartband, i-1, + notify, dwStyle); + y = 0; + x += (mcy + 2); + } + else { + /* first adjust all bands in previous current row to */ + /* redistribute extra x pixels */ + REBAR_AdjustBands (infoPtr, rowstartband, i-1, + clientcx, x, mcy, dwStyle); + /* calculate band subrectangles and break to new row */ + REBAR_CalcHorzBand (hwnd, infoPtr, rowstartband, i-1, + notify, dwStyle); + x = 0; + y += (mcy + 2); + } + + /* FIXME: if not RBS_VARHEIGHT then find max */ + mcy = 0; + cxsep = 0; + row++; + rowstartband = i; + lpBand->iRow = row; } - else { - if (lpBand->fStyle & RBBS_VARIABLEHEIGHT) - cy = lpBand->cyMaxChild; - else if (lpBand->fStyle & RBBIM_CHILDSIZE) - cy = lpBand->cyMinChild; - else - cy = 20; /* FIXME */ - lpBand->rcBand.left = x; - lpBand->rcBand.right = x + cx; - lpBand->rcBand.top = y; - lpBand->rcBand.bottom = y + cy; - lpBand->uMinHeight = cy; + if (mcy < lpBand->lcy) mcy = lpBand->lcy; + + /* if boundary rect specified then limit mcy */ + if (lpRect) { + if (dwStyle & CCS_VERT) { + if (x+mcy > adjcx) { + mcy = adjcx - x; + TRACE("row %u limiting mcy=%d, adjcx=%d, x=%d\n", + i, mcy, adjcx, x); + } + } + else { + if (y+mcy > adjcy) { + mcy = adjcy - y; + TRACE("row %u limiting mcy=%d, adjcy=%d, y=%d\n", + i, mcy, adjcy, y); + } + } } if (dwStyle & CCS_VERT) { - REBAR_CalcVertBand (hwnd, infoPtr, lpBand); - x += lpBand->uMinHeight; + /* bound the bottom side if we have a bounding rectangle */ + lpBand->fDraw |= (y==0) ? 0 : DRAW_SEP; + rightx = clientcx; + bottomy = (lpRect) ? min(clientcy, y+cxsep+cx) : y+cxsep+cx; + lpBand->rcBand.left = x; + lpBand->rcBand.right = y + min(mcy, lpBand->lcy); + lpBand->rcBand.top = min(bottomy, y + cxsep); + lpBand->rcBand.bottom = bottomy; + lpBand->uMinHeight = lpBand->lcy; + y = bottomy; } else { - REBAR_CalcHorzBand (infoPtr, lpBand); - y += lpBand->uMinHeight; + /* bound the right side if we have a bounding rectangle */ + lpBand->fDraw |= (x==0) ? 0 : DRAW_SEP; + rightx = (lpRect) ? min(clientcx, x+cxsep+cx) : x+cxsep+cx; + bottomy = clientcy; + lpBand->rcBand.left = min(rightx, x + cxsep); + lpBand->rcBand.right = rightx; + lpBand->rcBand.top = y; + lpBand->rcBand.bottom = y + min(mcy, lpBand->lcy); + lpBand->uMinHeight = lpBand->lcy; + x = rightx; } + TRACE("band %u, row %d, (%d,%d)-(%d,%d)\n", + i, row, + lpBand->rcBand.left, lpBand->rcBand.top, + lpBand->rcBand.right, lpBand->rcBand.bottom); + } + if (infoPtr->uNumBands) { + infoPtr->uNumRows = row; + + if (dwStyle & CCS_VERT) { + REBAR_AdjustBands (infoPtr, rowstartband, infoPtr->uNumBands-1, + clientcy, y, mcy, dwStyle); + REBAR_CalcVertBand (hwnd, infoPtr, rowstartband, infoPtr->uNumBands-1, + notify, dwStyle); + x += mcy; + } + else { + REBAR_AdjustBands (infoPtr, rowstartband, infoPtr->uNumBands-1, + clientcx, x, mcy, dwStyle); + REBAR_CalcHorzBand (hwnd, infoPtr, rowstartband, infoPtr->uNumBands-1, + notify, dwStyle); + y += mcy; + } + } + + /* FIXME: if not RBS_VARHEIGHT then find max mcy and adj rect*/ if (dwStyle & CCS_VERT) { infoPtr->calcSize.cx = x; - infoPtr->calcSize.cy = rcClient.bottom - rcClient.top; + infoPtr->calcSize.cy = clientcy; } else { - infoPtr->calcSize.cx = rcClient.right - rcClient.left; + infoPtr->calcSize.cx = clientcx; infoPtr->calcSize.cy = y; } + REBAR_DumpBand (hwnd); } @@ -476,6 +853,11 @@ REBAR_MoveChildWindows (HWND hwnd) yPos = (lpBand->rcChild.bottom + lpBand->rcChild.top - nEditHeight)/2; /* center combo box inside child area */ + TRACE("moving child %04x to (%d,%d)-(%d,%d)\n", + lpBand->hwndChild, + lpBand->rcChild.left, yPos, + lpBand->rcChild.right - lpBand->rcChild.left, + nEditHeight); SetWindowPos (lpBand->hwndChild, HWND_TOP, lpBand->rcChild.left, /*lpBand->rcChild.top*/ yPos, lpBand->rcChild.right - lpBand->rcChild.left, @@ -497,6 +879,11 @@ REBAR_MoveChildWindows (HWND hwnd) yPos = (lpBand->rcChild.bottom + lpBand->rcChild.top - nEditHeight)/2; /* center combo box inside child area */ + TRACE("moving child %04x to (%d,%d)-(%d,%d)\n", + lpBand->hwndChild, + lpBand->rcChild.left, yPos, + lpBand->rcChild.right - lpBand->rcChild.left, + nEditHeight); SetWindowPos (lpBand->hwndChild, HWND_TOP, lpBand->rcChild.left, /*lpBand->rcChild.top*/ yPos, lpBand->rcChild.right - lpBand->rcChild.left, @@ -506,6 +893,11 @@ REBAR_MoveChildWindows (HWND hwnd) } #endif else { + TRACE("moving child %04x to (%d,%d)-(%d,%d)\n", + lpBand->hwndChild, + lpBand->rcChild.left, lpBand->rcChild.top, + lpBand->rcChild.right - lpBand->rcChild.left, + lpBand->rcChild.bottom - lpBand->rcChild.top); SetWindowPos (lpBand->hwndChild, HWND_TOP, lpBand->rcChild.left, lpBand->rcChild.top, lpBand->rcChild.right - lpBand->rcChild.left, @@ -517,6 +909,158 @@ REBAR_MoveChildWindows (HWND hwnd) } +static VOID +REBAR_ValidateBand (HWND hwnd, REBAR_INFO *infoPtr, REBAR_BAND *lpBand) + /* Function: This routine evaluates the band specs supplied */ + /* by the user and updates the following 5 fields in */ + /* the internal band structure: cxHeader, lcx, lcy, hcx, hcy*/ +{ + UINT header=0; + DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE); + + lpBand->lcx = 0; + lpBand->lcy = 0; + lpBand->hcx = 0; + lpBand->hcy = 0; + + /* Header is where the image, text and gripper exist */ + /* in the band and preceed the child window. */ + + /* calculate gripper rectangle */ + if ((!(lpBand->fStyle & RBBS_NOGRIPPER)) && + (!(lpBand->fStyle & RBBS_FIXEDSIZE)) && + ((lpBand->fStyle & RBBS_GRIPPERALWAYS) || + (infoPtr->uNumBands > 1))) { + if (dwStyle & CCS_VERT) + if (dwStyle & RBS_VERTICALGRIPPER) + header += (GRIPPER_HEIGHT + 3); + else + header += (GRIPPER_WIDTH + 3); + else + header += (GRIPPER_WIDTH + 1); + } + + /* image is visible */ + if ((lpBand->fMask & RBBIM_IMAGE) && (infoPtr->himl)) { + if (dwStyle & CCS_VERT) { + header += infoPtr->imageSize.cy; + lpBand->lcy = infoPtr->imageSize.cx + 2; + } + else { + header += infoPtr->imageSize.cx; + lpBand->lcy = infoPtr->imageSize.cy + 2; + } + } + + /* text is visible */ + if ((lpBand->fMask & RBBIM_TEXT) && (lpBand->lpText)) { + HDC hdc = GetDC (0); + HFONT hOldFont = SelectObject (hdc, infoPtr->hFont); + SIZE size; + + GetTextExtentPoint32W (hdc, lpBand->lpText, + lstrlenW (lpBand->lpText), &size); + header += ((dwStyle & CCS_VERT) ? (size.cy + 2) : (size.cx + 2)); + + SelectObject (hdc, hOldFont); + ReleaseDC (0, hdc); + } + + /* check if user overrode the header value */ + if (!(lpBand->fMask & RBBIM_HEADERSIZE)) + lpBand->cxHeader = header; + + + /* Now compute minimum size of child window */ + if (lpBand->fMask & RBBIM_CHILDSIZE) { + lpBand->lcx = lpBand->cxMinChild; + lpBand->lcy = lpBand->cyMinChild; + lpBand->hcy = lpBand->lcy; + if (lpBand->fStyle & RBBS_VARIABLEHEIGHT) { + lpBand->lcy = max (lpBand->cyChild, lpBand->lcy); + lpBand->hcy = lpBand->cyMaxChild; + } + TRACE("_CHILDSIZE\n"); + } + if (lpBand->fMask & RBBIM_SIZE) { + lpBand->hcx = max (lpBand->cx, lpBand->lcx); + TRACE("_SIZE\n"); + } + else + lpBand->hcx = lpBand->lcx; + +} + +static void +REBAR_CommonSetupBand (HWND hwnd, LPREBARBANDINFOA lprbbi, REBAR_BAND *lpBand) + /* Function: This routine copies the supplied values from */ + /* user input (lprbbi) to the internal band structure. */ +{ + lpBand->fMask |= lprbbi->fMask; + + if (lprbbi->fMask & RBBIM_STYLE) + lpBand->fStyle = lprbbi->fStyle; + + if (lprbbi->fMask & RBBIM_COLORS) { + lpBand->clrFore = lprbbi->clrFore; + lpBand->clrBack = lprbbi->clrBack; + } + + if (lprbbi->fMask & RBBIM_IMAGE) + lpBand->iImage = lprbbi->iImage; + + if (lprbbi->fMask & RBBIM_CHILD) { + if (lprbbi->hwndChild) { + lpBand->hwndChild = lprbbi->hwndChild; + lpBand->hwndPrevParent = + SetParent (lpBand->hwndChild, hwnd); + } + else { + TRACE("child: 0x%x prev parent: 0x%x\n", + lpBand->hwndChild, lpBand->hwndPrevParent); + lpBand->hwndChild = 0; + lpBand->hwndPrevParent = 0; + } + } + + if (lprbbi->fMask & RBBIM_CHILDSIZE) { + lpBand->cxMinChild = lprbbi->cxMinChild; + lpBand->cyMinChild = lprbbi->cyMinChild; + lpBand->cyMaxChild = lprbbi->cyMaxChild; + lpBand->cyChild = lprbbi->cyChild; + lpBand->cyIntegral = lprbbi->cyIntegral; + + /* FUDGE FUDGE GetWindowRect wrong for comboboxex FUDGE */ + /* fix for rebar.exe */ + if (lpBand->cyMinChild == 150) lpBand->cyMinChild = 25; + /* FUDGE FUDGE GetWindowRect wrong for comboboxex FUDGE */ + /* fix for iexplore.exe */ + if (lpBand->cyMinChild == 250) lpBand->cyMinChild = 25; + + } + + if (lprbbi->fMask & RBBIM_SIZE) + lpBand->cx = lprbbi->cx; + + if (lprbbi->fMask & RBBIM_BACKGROUND) + lpBand->hbmBack = lprbbi->hbmBack; + + if (lprbbi->fMask & RBBIM_ID) + lpBand->wID = lprbbi->wID; + + /* check for additional data */ + if (lprbbi->cbSize >= sizeof (REBARBANDINFOA)) { + if (lprbbi->fMask & RBBIM_IDEALSIZE) + lpBand->cxIdeal = lprbbi->cxIdeal; + + if (lprbbi->fMask & RBBIM_LPARAM) + lpBand->lParam = lprbbi->lParam; + + if (lprbbi->fMask & RBBIM_HEADERSIZE) + lpBand->cxHeader = lprbbi->cxHeader; + } +} + static void REBAR_InternalHitTest (HWND hwnd, LPPOINT lpPt, UINT *pFlags, INT *pBand) { @@ -633,7 +1177,7 @@ REBAR_DeleteBand (HWND hwnd, WPARAM wParam, LPARAM lParam) COMCTL32_Free (oldBands); } - REBAR_Layout (hwnd, NULL); + REBAR_Layout (hwnd, NULL, FALSE, FALSE); REBAR_ForceResize (hwnd); REBAR_MoveChildWindows (hwnd); @@ -659,12 +1203,15 @@ REBAR_GetBandBorders (HWND hwnd, WPARAM wParam, LPARAM lParam) lpBand = &infoPtr->bands[(UINT)wParam]; if (GetWindowLongA (hwnd, GWL_STYLE) & RBS_BANDBORDERS) { - + /*lpRect.left = ??? */ + /*lpRect.top = ??? */ + /*lpRect.right = ??? */ + /*lpRect.bottom = ??? */ } else { - + /*lpRect.left = ??? */ } - + FIXME("stub\n"); return 0; } @@ -705,15 +1252,23 @@ REBAR_GetBandInfoA (HWND hwnd, WPARAM wParam, LPARAM lParam) if (lprbbi->fMask & RBBIM_COLORS) { lprbbi->clrFore = lpBand->clrFore; lprbbi->clrBack = lpBand->clrBack; + if (lprbbi->clrBack == CLR_NONE) + lprbbi->clrBack = GetSysColor (COLOR_BTNFACE); } - if ((lprbbi->fMask & RBBIM_TEXT) && - (lprbbi->lpText) && (lpBand->lpText)) { - lstrcpynWtoA (lprbbi->lpText, lpBand->lpText, lprbbi->cch); + if ((lprbbi->fMask & RBBIM_TEXT) && (lprbbi->lpText)) { + if (lpBand->lpText && (lpBand->fMask & RBBIM_TEXT)) + lstrcpynWtoA (lprbbi->lpText, lpBand->lpText, lprbbi->cch); + else + *lprbbi->lpText = 0; } - if (lprbbi->fMask & RBBIM_IMAGE) + if (lprbbi->fMask & RBBIM_IMAGE) { + if (lpBand->fMask & RBBIM_IMAGE) lprbbi->iImage = lpBand->iImage; + else + lprbbi->iImage = -1; + } if (lprbbi->fMask & RBBIM_CHILD) lprbbi->hwndChild = lpBand->hwndChild; @@ -747,6 +1302,8 @@ REBAR_GetBandInfoA (HWND hwnd, WPARAM wParam, LPARAM lParam) lprbbi->cxHeader = lpBand->cxHeader; } + REBAR_DumpBandInfo (lprbbi); + return TRUE; } @@ -776,15 +1333,23 @@ REBAR_GetBandInfoW (HWND hwnd, WPARAM wParam, LPARAM lParam) if (lprbbi->fMask & RBBIM_COLORS) { lprbbi->clrFore = lpBand->clrFore; lprbbi->clrBack = lpBand->clrBack; + if (lprbbi->clrBack == CLR_NONE) + lprbbi->clrBack = GetSysColor (COLOR_BTNFACE); } - if ((lprbbi->fMask & RBBIM_TEXT) && - (lprbbi->lpText) && (lpBand->lpText)) { - lstrcpynW (lprbbi->lpText, lpBand->lpText, lprbbi->cch); + if ((lprbbi->fMask & RBBIM_TEXT) && (lprbbi->lpText)) { + if (lpBand->lpText && (lpBand->fMask & RBBIM_TEXT)) + lstrcpynW (lprbbi->lpText, lpBand->lpText, lprbbi->cch); + else + *lprbbi->lpText = 0; } - if (lprbbi->fMask & RBBIM_IMAGE) + if (lprbbi->fMask & RBBIM_IMAGE) { + if (lpBand->fMask & RBBIM_IMAGE) lprbbi->iImage = lpBand->iImage; + else + lprbbi->iImage = -1; + } if (lprbbi->fMask & RBBIM_CHILD) lprbbi->hwndChild = lpBand->hwndChild; @@ -818,6 +1383,8 @@ REBAR_GetBandInfoW (HWND hwnd, WPARAM wParam, LPARAM lParam) lprbbi->cxHeader = lpBand->cxHeader; } + REBAR_DumpBandInfo ((LPREBARBANDINFOA)lprbbi); + return TRUE; } @@ -828,14 +1395,9 @@ REBAR_GetBarHeight (HWND hwnd, WPARAM wParam, LPARAM lParam) REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd); INT nHeight; - REBAR_Layout (hwnd, NULL); nHeight = infoPtr->calcSize.cy; - if (GetWindowLongA (hwnd, GWL_STYLE) & WS_BORDER) - nHeight += (2 * GetSystemMetrics(SM_CYEDGE)); - - - FIXME("height = %d\n", nHeight); + TRACE("height = %d\n", nHeight); return nHeight; } @@ -868,10 +1430,14 @@ inline static LRESULT REBAR_GetBkColor (HWND hwnd) { REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd); + COLORREF clr = infoPtr->clrBk; - TRACE("background color 0x%06lx!\n", infoPtr->clrBk); + if (clr == CLR_NONE) + clr = GetSysColor (COLOR_BTNFACE); - return infoPtr->clrBk; + TRACE("background color 0x%06lx!\n", clr); + + return clr; } @@ -901,16 +1467,11 @@ REBAR_GetRect (HWND hwnd, WPARAM wParam, LPARAM lParam) if (!lprc) return FALSE; - TRACE("band %d\n", iBand); - lpBand = &infoPtr->bands[iBand]; CopyRect (lprc, &lpBand->rcBand); -/* - lprc->left = lpBand->rcBand.left; - lprc->top = lpBand->rcBand.top; - lprc->right = lpBand->rcBand.right; - lprc->bottom = lpBand->rcBand.bottom; -*/ + + TRACE("band %d, (%d,%d)-(%d,%d)\n", iBand, + lprc->left, lprc->top, lprc->right, lprc->bottom); return TRUE; } @@ -921,20 +1482,35 @@ REBAR_GetRowCount (HWND hwnd) { REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd); - FIXME("%u : semi stub!\n", infoPtr->uNumBands); + TRACE("%u\n", infoPtr->uNumRows); - return infoPtr->uNumBands; + return infoPtr->uNumRows; } static LRESULT REBAR_GetRowHeight (HWND hwnd, WPARAM wParam, LPARAM lParam) { -/* REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd); */ + REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd); + INT iRow = (INT)wParam; + int ret = 0; + int i, j = 0; + REBAR_BAND *lpBand; + DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE); - FIXME("-- height = 20: semi stub!\n"); + for (i=0; iuNumBands; i++) { + lpBand = &infoPtr->bands[i]; + if (lpBand->iRow != iRow) continue; + if (dwStyle & CCS_VERT) + j = lpBand->rcBand.right - lpBand->rcBand.left; + else + j = lpBand->rcBand.bottom - lpBand->rcBand.top; + if (j > ret) ret = j; + } - return 20; + TRACE("row %d, height %d\n", iRow, ret); + + return ret; } @@ -969,6 +1545,7 @@ inline static LRESULT REBAR_GetVersion (HWND hwnd) { REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd); + TRACE("version %d\n", infoPtr->iVersion); return infoPtr->iVersion; } @@ -1000,16 +1577,14 @@ REBAR_IdToIndex (HWND hwnd, WPARAM wParam, LPARAM lParam) if (infoPtr->uNumBands < 1) return -1; - TRACE("id %u\n", (UINT)wParam); - for (i = 0; i < infoPtr->uNumBands; i++) { if (infoPtr->bands[i].wID == (UINT)wParam) { - TRACE("band %u found!\n", i); + TRACE("id %u is band %u found!\n", (UINT)wParam, i); return i; } } - TRACE("no band found!\n"); + TRACE("id %u is not found\n", (UINT)wParam); return -1; } @@ -1029,7 +1604,9 @@ REBAR_InsertBandA (HWND hwnd, WPARAM wParam, LPARAM lParam) if (lprbbi->cbSize < REBARBANDINFO_V3_SIZEA) return FALSE; - TRACE("insert band at %u!\n", uIndex); + /* trace the index as signed to see the -1 */ + TRACE("insert band at %d!\n", (INT)uIndex); + REBAR_DumpBandInfo (lprbbi); if (infoPtr->uNumBands == 0) { infoPtr->bands = (REBAR_BAND *)COMCTL32_Alloc (sizeof (REBAR_BAND)); @@ -1063,19 +1640,14 @@ REBAR_InsertBandA (HWND hwnd, WPARAM wParam, LPARAM lParam) /* initialize band (infoPtr->bands[uIndex])*/ lpBand = &infoPtr->bands[uIndex]; + lpBand->fMask = 0; + lpBand->clrFore = infoPtr->clrText; + lpBand->clrBack = infoPtr->clrBk; + lpBand->hwndChild = 0; + lpBand->hwndPrevParent = 0; - if (lprbbi->fMask & RBBIM_STYLE) - lpBand->fStyle = lprbbi->fStyle; - - if (lprbbi->fMask & RBBIM_COLORS) { - lpBand->clrFore = lprbbi->clrFore; - lpBand->clrBack = lprbbi->clrBack; - } - else { - lpBand->clrFore = CLR_NONE; - lpBand->clrBack = CLR_NONE; - } - + REBAR_CommonSetupBand (hwnd, lprbbi, lpBand); + lpBand->lpText = NULL; if ((lprbbi->fMask & RBBIM_TEXT) && (lprbbi->lpText)) { INT len = lstrlenA (lprbbi->lpText); if (len > 0) { @@ -1084,58 +1656,11 @@ REBAR_InsertBandA (HWND hwnd, WPARAM wParam, LPARAM lParam) } } - if (lprbbi->fMask & RBBIM_IMAGE) - lpBand->iImage = lprbbi->iImage; - else - lpBand->iImage = -1; + REBAR_ValidateBand (hwnd, infoPtr, lpBand); - if (lprbbi->fMask & RBBIM_CHILD) { - TRACE("hwndChild = %x\n", lprbbi->hwndChild); - lpBand->hwndChild = lprbbi->hwndChild; - lpBand->hwndPrevParent = - SetParent (lpBand->hwndChild, hwnd); - } + REBAR_DumpBand (hwnd); - if (lprbbi->fMask & RBBIM_CHILDSIZE) { - lpBand->cxMinChild = lprbbi->cxMinChild; - lpBand->cyMinChild = lprbbi->cyMinChild; - lpBand->cyMaxChild = lprbbi->cyMaxChild; - lpBand->cyChild = lprbbi->cyChild; - lpBand->cyIntegral = lprbbi->cyIntegral; - } - else { - lpBand->cxMinChild = -1; - lpBand->cyMinChild = -1; - lpBand->cyMaxChild = -1; - lpBand->cyChild = -1; - lpBand->cyIntegral = -1; - } - - if (lprbbi->fMask & RBBIM_SIZE) - lpBand->cx = lprbbi->cx; - else - lpBand->cx = -1; - - if (lprbbi->fMask & RBBIM_BACKGROUND) - lpBand->hbmBack = lprbbi->hbmBack; - - if (lprbbi->fMask & RBBIM_ID) - lpBand->wID = lprbbi->wID; - - /* check for additional data */ - if (lprbbi->cbSize >= sizeof (REBARBANDINFOA)) { - if (lprbbi->fMask & RBBIM_IDEALSIZE) - lpBand->cxIdeal = lprbbi->cxIdeal; - - if (lprbbi->fMask & RBBIM_LPARAM) - lpBand->lParam = lprbbi->lParam; - - if (lprbbi->fMask & RBBIM_HEADERSIZE) - lpBand->cxHeader = lprbbi->cxHeader; - } - - - REBAR_Layout (hwnd, NULL); + REBAR_Layout (hwnd, NULL, FALSE, FALSE); REBAR_ForceResize (hwnd); REBAR_MoveChildWindows (hwnd); @@ -1158,7 +1683,9 @@ REBAR_InsertBandW (HWND hwnd, WPARAM wParam, LPARAM lParam) if (lprbbi->cbSize < REBARBANDINFO_V3_SIZEW) return FALSE; - TRACE("insert band at %u!\n", uIndex); + /* trace the index as signed to see the -1 */ + TRACE("insert band at %d!\n", (INT)uIndex); + REBAR_DumpBandInfo ((LPREBARBANDINFOA)lprbbi); if (infoPtr->uNumBands == 0) { infoPtr->bands = (REBAR_BAND *)COMCTL32_Alloc (sizeof (REBAR_BAND)); @@ -1192,19 +1719,14 @@ REBAR_InsertBandW (HWND hwnd, WPARAM wParam, LPARAM lParam) /* initialize band (infoPtr->bands[uIndex])*/ lpBand = &infoPtr->bands[uIndex]; + lpBand->fMask = 0; + lpBand->clrFore = infoPtr->clrText; + lpBand->clrBack = infoPtr->clrBk; + lpBand->hwndChild = 0; + lpBand->hwndPrevParent = 0; - if (lprbbi->fMask & RBBIM_STYLE) - lpBand->fStyle = lprbbi->fStyle; - - if (lprbbi->fMask & RBBIM_COLORS) { - lpBand->clrFore = lprbbi->clrFore; - lpBand->clrBack = lprbbi->clrBack; - } - else { - lpBand->clrFore = CLR_NONE; - lpBand->clrBack = CLR_NONE; - } - + REBAR_CommonSetupBand (hwnd, (LPREBARBANDINFOA)lprbbi, lpBand); + lpBand->lpText = NULL; if ((lprbbi->fMask & RBBIM_TEXT) && (lprbbi->lpText)) { INT len = lstrlenW (lprbbi->lpText); if (len > 0) { @@ -1213,58 +1735,11 @@ REBAR_InsertBandW (HWND hwnd, WPARAM wParam, LPARAM lParam) } } - if (lprbbi->fMask & RBBIM_IMAGE) - lpBand->iImage = lprbbi->iImage; - else - lpBand->iImage = -1; + REBAR_ValidateBand (hwnd, infoPtr, lpBand); - if (lprbbi->fMask & RBBIM_CHILD) { - TRACE("hwndChild = %x\n", lprbbi->hwndChild); - lpBand->hwndChild = lprbbi->hwndChild; - lpBand->hwndPrevParent = - SetParent (lpBand->hwndChild, hwnd); - } + REBAR_DumpBand (hwnd); - if (lprbbi->fMask & RBBIM_CHILDSIZE) { - lpBand->cxMinChild = lprbbi->cxMinChild; - lpBand->cyMinChild = lprbbi->cyMinChild; - lpBand->cyMaxChild = lprbbi->cyMaxChild; - lpBand->cyChild = lprbbi->cyChild; - lpBand->cyIntegral = lprbbi->cyIntegral; - } - else { - lpBand->cxMinChild = -1; - lpBand->cyMinChild = -1; - lpBand->cyMaxChild = -1; - lpBand->cyChild = -1; - lpBand->cyIntegral = -1; - } - - if (lprbbi->fMask & RBBIM_SIZE) - lpBand->cx = lprbbi->cx; - else - lpBand->cx = -1; - - if (lprbbi->fMask & RBBIM_BACKGROUND) - lpBand->hbmBack = lprbbi->hbmBack; - - if (lprbbi->fMask & RBBIM_ID) - lpBand->wID = lprbbi->wID; - - /* check for additional data */ - if (lprbbi->cbSize >= sizeof (REBARBANDINFOW)) { - if (lprbbi->fMask & RBBIM_IDEALSIZE) - lpBand->cxIdeal = lprbbi->cxIdeal; - - if (lprbbi->fMask & RBBIM_LPARAM) - lpBand->lParam = lprbbi->lParam; - - if (lprbbi->fMask & RBBIM_HEADERSIZE) - lpBand->cxHeader = lprbbi->cxHeader; - } - - - REBAR_Layout (hwnd, NULL); + REBAR_Layout (hwnd, NULL, FALSE, FALSE); REBAR_ForceResize (hwnd); REBAR_MoveChildWindows (hwnd); @@ -1325,18 +1800,12 @@ REBAR_SetBandInfoA (HWND hwnd, WPARAM wParam, LPARAM lParam) return FALSE; TRACE("index %u\n", (UINT)wParam); + REBAR_DumpBandInfo (lprbbi); /* set band information */ lpBand = &infoPtr->bands[(UINT)wParam]; - if (lprbbi->fMask & RBBIM_STYLE) - lpBand->fStyle = lprbbi->fStyle; - - if (lprbbi->fMask & RBBIM_COLORS) { - lpBand->clrFore = lprbbi->clrFore; - lpBand->clrBack = lprbbi->clrBack; - } - + REBAR_CommonSetupBand (hwnd, lprbbi, lpBand); if (lprbbi->fMask & RBBIM_TEXT) { if (lpBand->lpText) { COMCTL32_Free (lpBand->lpText); @@ -1349,56 +1818,16 @@ REBAR_SetBandInfoA (HWND hwnd, WPARAM wParam, LPARAM lParam) } } - if (lprbbi->fMask & RBBIM_IMAGE) - lpBand->iImage = lprbbi->iImage; + REBAR_ValidateBand (hwnd, infoPtr, lpBand); - if (lprbbi->fMask & RBBIM_CHILD) { - if (lprbbi->hwndChild) { - lpBand->hwndChild = lprbbi->hwndChild; - lpBand->hwndPrevParent = - SetParent (lpBand->hwndChild, hwnd); - } - else { - TRACE("child: 0x%x prev parent: 0x%x\n", - lpBand->hwndChild, lpBand->hwndPrevParent); - lpBand->hwndChild = 0; - lpBand->hwndPrevParent = 0; - } + REBAR_DumpBand (hwnd); + + if (lprbbi->fMask & (RBBIM_CHILDSIZE | RBBIM_SIZE)) { + REBAR_Layout (hwnd, NULL, TRUE, FALSE); + REBAR_ForceResize (hwnd); + REBAR_MoveChildWindows (hwnd); } - if (lprbbi->fMask & RBBIM_CHILDSIZE) { - lpBand->cxMinChild = lprbbi->cxMinChild; - lpBand->cyMinChild = lprbbi->cyMinChild; - lpBand->cyMaxChild = lprbbi->cyMaxChild; - lpBand->cyChild = lprbbi->cyChild; - lpBand->cyIntegral = lprbbi->cyIntegral; - } - - if (lprbbi->fMask & RBBIM_SIZE) - lpBand->cx = lprbbi->cx; - - if (lprbbi->fMask & RBBIM_BACKGROUND) - lpBand->hbmBack = lprbbi->hbmBack; - - if (lprbbi->fMask & RBBIM_ID) - lpBand->wID = lprbbi->wID; - - /* check for additional data */ - if (lprbbi->cbSize >= sizeof (REBARBANDINFOA)) { - if (lprbbi->fMask & RBBIM_IDEALSIZE) - lpBand->cxIdeal = lprbbi->cxIdeal; - - if (lprbbi->fMask & RBBIM_LPARAM) - lpBand->lParam = lprbbi->lParam; - - if (lprbbi->fMask & RBBIM_HEADERSIZE) - lpBand->cxHeader = lprbbi->cxHeader; - } - - REBAR_Layout (hwnd, NULL); - REBAR_ForceResize (hwnd); - REBAR_MoveChildWindows (hwnd); - return TRUE; } @@ -1418,18 +1847,12 @@ REBAR_SetBandInfoW (HWND hwnd, WPARAM wParam, LPARAM lParam) return FALSE; TRACE("index %u\n", (UINT)wParam); + REBAR_DumpBandInfo ((LPREBARBANDINFOA)lprbbi); /* set band information */ lpBand = &infoPtr->bands[(UINT)wParam]; - if (lprbbi->fMask & RBBIM_STYLE) - lpBand->fStyle = lprbbi->fStyle; - - if (lprbbi->fMask & RBBIM_COLORS) { - lpBand->clrFore = lprbbi->clrFore; - lpBand->clrBack = lprbbi->clrBack; - } - + REBAR_CommonSetupBand (hwnd, (LPREBARBANDINFOA)lprbbi, lpBand); if (lprbbi->fMask & RBBIM_TEXT) { if (lpBand->lpText) { COMCTL32_Free (lpBand->lpText); @@ -1442,56 +1865,16 @@ REBAR_SetBandInfoW (HWND hwnd, WPARAM wParam, LPARAM lParam) } } - if (lprbbi->fMask & RBBIM_IMAGE) - lpBand->iImage = lprbbi->iImage; + REBAR_ValidateBand (hwnd, infoPtr, lpBand); - if (lprbbi->fMask & RBBIM_CHILD) { - if (lprbbi->hwndChild) { - lpBand->hwndChild = lprbbi->hwndChild; - lpBand->hwndPrevParent = - SetParent (lpBand->hwndChild, hwnd); - } - else { - TRACE("child: 0x%x prev parent: 0x%x\n", - lpBand->hwndChild, lpBand->hwndPrevParent); - lpBand->hwndChild = 0; - lpBand->hwndPrevParent = 0; - } + REBAR_DumpBand (hwnd); + + if (lprbbi->fMask & (RBBIM_CHILDSIZE | RBBIM_SIZE)) { + REBAR_Layout (hwnd, NULL, TRUE, FALSE); + REBAR_ForceResize (hwnd); + REBAR_MoveChildWindows (hwnd); } - if (lprbbi->fMask & RBBIM_CHILDSIZE) { - lpBand->cxMinChild = lprbbi->cxMinChild; - lpBand->cyMinChild = lprbbi->cyMinChild; - lpBand->cyMaxChild = lprbbi->cyMaxChild; - lpBand->cyChild = lprbbi->cyChild; - lpBand->cyIntegral = lprbbi->cyIntegral; - } - - if (lprbbi->fMask & RBBIM_SIZE) - lpBand->cx = lprbbi->cx; - - if (lprbbi->fMask & RBBIM_BACKGROUND) - lpBand->hbmBack = lprbbi->hbmBack; - - if (lprbbi->fMask & RBBIM_ID) - lpBand->wID = lprbbi->wID; - - /* check for additional data */ - if (lprbbi->cbSize >= sizeof (REBARBANDINFOW)) { - if (lprbbi->fMask & RBBIM_IDEALSIZE) - lpBand->cxIdeal = lprbbi->cxIdeal; - - if (lprbbi->fMask & RBBIM_LPARAM) - lpBand->lParam = lprbbi->lParam; - - if (lprbbi->fMask & RBBIM_HEADERSIZE) - lpBand->cxHeader = lprbbi->cxHeader; - } - - REBAR_Layout (hwnd, NULL); - REBAR_ForceResize (hwnd); - REBAR_MoveChildWindows (hwnd); - return TRUE; } @@ -1522,6 +1905,8 @@ REBAR_SetBarInfo (HWND hwnd, WPARAM wParam, LPARAM lParam) infoPtr->imageSize.cx = 0; infoPtr->imageSize.cy = 0; } + TRACE("new image cx=%ld, cy=%ld\n", infoPtr->imageSize.cx, + infoPtr->imageSize.cy); } return TRUE; @@ -1598,6 +1983,8 @@ REBAR_SetVersion (HWND hwnd, INT iVersion) infoPtr->iVersion = iVersion; + TRACE("new version %d\n", iVersion); + return iOldVersion; } @@ -1626,7 +2013,7 @@ REBAR_ShowBand (HWND hwnd, WPARAM wParam, LPARAM lParam) ShowWindow (lpBand->hwndChild, SW_SHOW); } - REBAR_Layout (hwnd, NULL); + REBAR_Layout (hwnd, NULL, TRUE, FALSE); REBAR_ForceResize (hwnd); REBAR_MoveChildWindows (hwnd); @@ -1637,26 +2024,26 @@ REBAR_ShowBand (HWND hwnd, WPARAM wParam, LPARAM lParam) static LRESULT REBAR_SizeToRect (HWND hwnd, WPARAM wParam, LPARAM lParam) { - REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd); LPRECT lpRect = (LPRECT)lParam; + RECT t1; if (lpRect == NULL) - return FALSE; + return FALSE; - FIXME("layout change not implemented!\n"); - FIXME("[%d %d %d %d]\n", - lpRect->left, lpRect->top, lpRect->right, lpRect->bottom); + TRACE("[%d %d %d %d]\n", + lpRect->left, lpRect->top, lpRect->right, lpRect->bottom); -#if 0 - SetWindowPos (hwnd, 0, lpRect->left, lpRect->top, - lpRect->right - lpRect->left, lpRect->bottom - lpRect->top, - SWP_NOZORDER); -#endif - - infoPtr->calcSize.cx = lpRect->right - lpRect->left; - infoPtr->calcSize.cy = lpRect->bottom - lpRect->top; + /* what is going on???? */ + GetWindowRect(hwnd, &t1); + TRACE("window rect [%d %d %d %d]\n", + t1.left, t1.top, t1.right, t1.bottom); + GetClientRect(hwnd, &t1); + TRACE("client rect [%d %d %d %d]\n", + t1.left, t1.top, t1.right, t1.bottom); + REBAR_Layout (hwnd, lpRect, TRUE, FALSE); REBAR_ForceResize (hwnd); + REBAR_MoveChildWindows (hwnd); return TRUE; } @@ -1674,7 +2061,7 @@ REBAR_Create (HWND hwnd, WPARAM wParam, LPARAM lParam) /* initialize info structure */ infoPtr->iVersion = 0; infoPtr->clrBk = CLR_NONE; - infoPtr->clrText = RGB(0, 0, 0); + infoPtr->clrText = GetSysColor (COLOR_BTNTEXT); infoPtr->bAutoResize = FALSE; infoPtr->hcurArrow = LoadCursorA (0, IDC_ARROWA); @@ -1883,9 +2270,7 @@ static LRESULT REBAR_Size (HWND hwnd, WPARAM wParam, LPARAM lParam) { REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd); - /* DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE); */ - RECT rcParent; - /* INT32 x, y, cx, cy; */ + RECT rcClient; /* auto resize deadlock check */ if (infoPtr->bAutoResize) { @@ -1893,46 +2278,19 @@ REBAR_Size (HWND hwnd, WPARAM wParam, LPARAM lParam) return 0; } - TRACE("sizing rebar!\n"); - - /* get parent rectangle */ - GetClientRect (GetParent (hwnd), &rcParent); -/* - REBAR_Layout (hwnd, &rcParent); - - if (dwStyle & CCS_VERT) { - if (dwStyle & CCS_LEFT == CCS_LEFT) { - x = rcParent.left; - y = rcParent.top; - cx = infoPtr->calcSize.cx; - cy = infoPtr->calcSize.cy; - } - else { - x = rcParent.right - infoPtr->calcSize.cx; - y = rcParent.top; - cx = infoPtr->calcSize.cx; - cy = infoPtr->calcSize.cy; - } + GetClientRect (hwnd, &rcClient); + if ((lParam == 0) && (rcClient.right == 0) && (rcClient.bottom == 0)) { + /* native control seems to do this */ + GetClientRect (GetParent(hwnd), &rcClient); + TRACE("sizing rebar, message and client zero, parent client (%d,%d)\n", + rcClient.right, rcClient.bottom); } else { - if (dwStyle & CCS_TOP) { - x = rcParent.left; - y = rcParent.top; - cx = infoPtr->calcSize.cx; - cy = infoPtr->calcSize.cy; - } - else { - x = rcParent.left; - y = rcParent.bottom - infoPtr->calcSize.cy; - cx = infoPtr->calcSize.cx; - cy = infoPtr->calcSize.cy; - } + TRACE("sizing rebar to (%d,%d), client (%d,%d)\n", + LOWORD(lParam), HIWORD(lParam), rcClient.right, rcClient.bottom); } - SetWindowPos32 (hwnd, 0, x, y, cx, cy, - SWP_NOZORDER | SWP_SHOWWINDOW); -*/ - REBAR_Layout (hwnd, NULL); + REBAR_Layout (hwnd, &rcClient, FALSE, TRUE); REBAR_ForceResize (hwnd); REBAR_MoveChildWindows (hwnd);