4 * Copyright 1998, 1999 Eric Kohl
5 * Copyright 2007, 2008 Mikolaj Zalewski
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
23 * This code was audited for completeness against the documented features
24 * of Comctl32.dll version 6.0 on Oct. 19, 2004, by Robert Shearman.
26 * Unless otherwise noted, we believe this code to be complete, as per
27 * the specification mentioned above.
28 * If you discover missing features or bugs please note them below.
51 * - WM_QUERYNEWPALETTE
59 * - NM_RELEASEDCAPTURE
65 * Native uses (on each draw!!) SM_CYBORDER (or SM_CXBORDER for CCS_VERT)
66 * to set the size of the separator width (the value SEP_WIDTH_SIZE
67 * in here). Should be fixed!!
71 * Testing: set to 1 to make background brush *always* green
76 * 3. REBAR_MoveChildWindows should have a loop because more than
77 * one pass (together with the RBN_CHILDSIZEs) is made on
78 * at least RB_INSERTBAND
89 #include "wine/unicode.h"
96 #include "wine/debug.h"
98 WINE_DEFAULT_DEBUG_CHANNEL(rebar);
108 UINT cxMinChild; /* valid if _CHILDSIZE */
109 UINT cyMinChild; /* valid if _CHILDSIZE */
110 UINT cx; /* valid if _SIZE */
113 UINT cyChild; /* valid if _CHILDSIZE */
114 UINT cyMaxChild; /* valid if _CHILDSIZE */
115 UINT cyIntegral; /* valid if _CHILDSIZE */
120 INT cxEffective; /* current cx for band */
121 UINT cyHeader; /* the height of the header */
122 UINT cxMinBand; /* minimum cx for band */
123 UINT cyMinBand; /* minimum cy for band */
125 UINT cyRowSoFar; /* for RBS_VARHEIGHT - the height of the row if it would break on this band (set by _Layout) */
126 INT iRow; /* zero-based index of the row this band assigned to */
127 UINT fStatus; /* status flags, reset only by _Validate */
128 UINT fDraw; /* drawing flags, reset only by _Layout */
129 UINT uCDret; /* last return from NM_CUSTOMDRAW */
130 RECT rcBand; /* calculated band rectangle - coordinates swapped for CCS_VERT */
131 RECT rcGripper; /* calculated gripper rectangle */
132 RECT rcCapImage; /* calculated caption image rectangle */
133 RECT rcCapText; /* calculated caption text rectangle */
134 RECT rcChild; /* calculated child rectangle */
135 RECT rcChevron; /* calculated chevron rectangle */
142 #define HAS_GRIPPER 0x00000001
143 #define HAS_IMAGE 0x00000002
144 #define HAS_TEXT 0x00000004
147 #define DRAW_GRIPPER 0x00000001
148 #define DRAW_IMAGE 0x00000002
149 #define DRAW_TEXT 0x00000004
150 #define DRAW_CHEVRONHOT 0x00000040
151 #define DRAW_CHEVRONPUSHED 0x00000080
152 #define NTF_INVALIDATE 0x01000000
156 COLORREF clrBk; /* background color */
157 COLORREF clrText; /* text color */
158 COLORREF clrBtnText; /* system color for BTNTEXT */
159 COLORREF clrBtnFace; /* system color for BTNFACE */
160 HIMAGELIST himl; /* handle to imagelist */
161 UINT uNumBands; /* # of bands in rebar (first=0, last=uNumBands-1 */
162 UINT uNumRows; /* # of rows of bands (first=1, last=uNumRows */
163 HWND hwndSelf; /* handle of REBAR window itself */
164 HWND hwndToolTip; /* handle to the tool tip control */
165 HWND hwndNotify; /* notification window (parent) */
167 HFONT hFont; /* handle to the rebar's font */
168 SIZE imageSize; /* image size (image list) */
169 DWORD dwStyle; /* window style */
170 DWORD orgStyle; /* original style (dwStyle may change) */
171 SIZE calcSize; /* calculated rebar size - coordinates swapped for CCS_VERT */
172 BOOL bUnicode; /* TRUE if parent wants notify in W format */
173 BOOL DoRedraw; /* TRUE to actually draw bands */
174 UINT fStatus; /* Status flags (see below) */
175 HCURSOR hcurArrow; /* handle to the arrow cursor */
176 HCURSOR hcurHorz; /* handle to the EW cursor */
177 HCURSOR hcurVert; /* handle to the NS cursor */
178 HCURSOR hcurDrag; /* handle to the drag cursor */
179 INT iVersion; /* version number */
180 POINT dragStart; /* x,y of button down */
181 POINT dragNow; /* x,y of this MouseMove */
182 INT iOldBand; /* last band that had the mouse cursor over it */
183 INT ihitoffset; /* offset of hotspot from gripper.left */
184 INT ichevronhotBand; /* last band that had a hot chevron */
185 INT iGrabbedBand;/* band number of band whose gripper was grabbed */
187 HDPA bands; /* pointer to the array of rebar bands */
191 #define BEGIN_DRAG_ISSUED 0x00000001
192 #define SELF_RESIZE 0x00000002
193 #define BAND_NEEDS_REDRAW 0x00000020
195 /* used by Windows to mark that the header size has been set by the user and shouldn't be changed */
196 #define RBBS_UNDOC_FIXEDHEADER 0x40000000
198 /* ---- REBAR layout constants. Mostly determined by ---- */
199 /* ---- experiment on WIN 98. ---- */
201 /* Width (or height) of separators between bands (either horz. or */
202 /* vert.). True only if RBS_BANDBORDERS is set */
203 #define SEP_WIDTH_SIZE 2
204 #define SEP_WIDTH ((infoPtr->dwStyle & RBS_BANDBORDERS) ? SEP_WIDTH_SIZE : 0)
206 /* Blank (background color) space between Gripper (if present) */
207 /* and next item (image, text, or window). Always present */
208 #define REBAR_ALWAYS_SPACE 4
210 /* Blank (background color) space after Image (if present). */
211 #define REBAR_POST_IMAGE 2
213 /* Blank (background color) space after Text (if present). */
214 #define REBAR_POST_TEXT 4
216 /* Height of vertical gripper in a CCS_VERT rebar. */
217 #define GRIPPER_HEIGHT 16
219 /* Blank (background color) space before Gripper (if present). */
220 #define REBAR_PRE_GRIPPER 2
222 /* Width (of normal vertical gripper) or height (of horz. gripper) */
224 #define GRIPPER_WIDTH 3
226 /* Width of the chevron button if present */
227 #define CHEVRON_WIDTH 10
229 /* the gap between the child and the next band */
230 #define REBAR_POST_CHILD 4
232 /* Height of divider for Rebar if not disabled (CCS_NODIVIDER) */
233 /* either top or bottom */
234 #define REBAR_DIVIDER 2
236 /* height of a rebar without a child */
237 #define REBAR_NO_CHILD_HEIGHT 4
239 /* minimum vertical height of a normal bar */
240 /* or minimum width of a CCS_VERT bar - from experiment on Win2k */
241 #define REBAR_MINSIZE 23
243 /* This is the increment that is used over the band height */
244 #define REBARSPACE(a) ((a->fStyle & RBBS_CHILDEDGE) ? 2*REBAR_DIVIDER : 0)
246 /* ---- End of REBAR layout constants. ---- */
248 #define RB_GETBANDINFO_OLD (WM_USER+5) /* obsoleted after IE3, but we have to support it anyway */
250 /* The following define determines if a given band is hidden */
251 #define HIDDENBAND(a) (((a)->fStyle & RBBS_HIDDEN) || \
252 ((infoPtr->dwStyle & CCS_VERT) && \
253 ((a)->fStyle & RBBS_NOVERT)))
255 #define REBAR_GetInfoPtr(wndPtr) ((REBAR_INFO *)GetWindowLongPtrW (hwnd, 0))
257 static LRESULT REBAR_NotifyFormat(REBAR_INFO *infoPtr, LPARAM lParam);
258 static void REBAR_AutoSize(REBAR_INFO *infoPtr, BOOL needsLayout);
260 /* no index check here */
261 static inline REBAR_BAND* REBAR_GetBand(const REBAR_INFO *infoPtr, INT i)
263 assert(i >= 0 && i < infoPtr->uNumBands);
264 return DPA_GetPtr(infoPtr->bands, i);
267 /* "constant values" retrieved when DLL was initialized */
268 /* FIXME we do this when the classes are registered. */
269 static UINT mindragx = 0;
270 static UINT mindragy = 0;
272 static const char * const band_stylename[] = {
273 "RBBS_BREAK", /* 0001 */
274 "RBBS_FIXEDSIZE", /* 0002 */
275 "RBBS_CHILDEDGE", /* 0004 */
276 "RBBS_HIDDEN", /* 0008 */
277 "RBBS_NOVERT", /* 0010 */
278 "RBBS_FIXEDBMP", /* 0020 */
279 "RBBS_VARIABLEHEIGHT", /* 0040 */
280 "RBBS_GRIPPERALWAYS", /* 0080 */
281 "RBBS_NOGRIPPER", /* 0100 */
284 static const char * const band_maskname[] = {
285 "RBBIM_STYLE", /* 0x00000001 */
286 "RBBIM_COLORS", /* 0x00000002 */
287 "RBBIM_TEXT", /* 0x00000004 */
288 "RBBIM_IMAGE", /* 0x00000008 */
289 "RBBIM_CHILD", /* 0x00000010 */
290 "RBBIM_CHILDSIZE", /* 0x00000020 */
291 "RBBIM_SIZE", /* 0x00000040 */
292 "RBBIM_BACKGROUND", /* 0x00000080 */
293 "RBBIM_ID", /* 0x00000100 */
294 "RBBIM_IDEALSIZE", /* 0x00000200 */
295 "RBBIM_LPARAM", /* 0x00000400 */
296 "RBBIM_HEADERSIZE", /* 0x00000800 */
300 static CHAR line[200];
302 static const WCHAR themeClass[] = { 'R','e','b','a','r',0 };
305 REBAR_FmtStyle( UINT style)
310 while (band_stylename[i]) {
311 if (style & (1<<i)) {
312 if (*line != 0) strcat(line, " | ");
313 strcat(line, band_stylename[i]);
322 REBAR_FmtMask( UINT mask)
327 while (band_maskname[i]) {
329 if (*line != 0) strcat(line, " | ");
330 strcat(line, band_maskname[i]);
339 REBAR_DumpBandInfo(const REBARBANDINFOW *pB)
341 if( !TRACE_ON(rebar) ) return;
342 TRACE("band info: ");
343 if (pB->fMask & RBBIM_ID)
344 TRACE("ID=%u, ", pB->wID);
345 TRACE("size=%u, child=%p", pB->cbSize, pB->hwndChild);
346 if (pB->fMask & RBBIM_COLORS)
347 TRACE(", clrF=0x%06x, clrB=0x%06x", pB->clrFore, pB->clrBack);
350 TRACE("band info: mask=0x%08x (%s)\n", pB->fMask, REBAR_FmtMask(pB->fMask));
351 if (pB->fMask & RBBIM_STYLE)
352 TRACE("band info: style=0x%08x (%s)\n", pB->fStyle, REBAR_FmtStyle(pB->fStyle));
353 if (pB->fMask & (RBBIM_SIZE | RBBIM_IDEALSIZE | RBBIM_HEADERSIZE | RBBIM_LPARAM )) {
355 if (pB->fMask & RBBIM_SIZE)
356 TRACE(" cx=%u", pB->cx);
357 if (pB->fMask & RBBIM_IDEALSIZE)
358 TRACE(" xIdeal=%u", pB->cxIdeal);
359 if (pB->fMask & RBBIM_HEADERSIZE)
360 TRACE(" xHeader=%u", pB->cxHeader);
361 if (pB->fMask & RBBIM_LPARAM)
362 TRACE(" lParam=0x%08lx", pB->lParam);
365 if (pB->fMask & RBBIM_CHILDSIZE)
366 TRACE("band info: xMin=%u, yMin=%u, yChild=%u, yMax=%u, yIntgl=%u\n",
368 pB->cyMinChild, pB->cyChild, pB->cyMaxChild, pB->cyIntegral);
372 REBAR_DumpBand (const REBAR_INFO *iP)
377 if(! TRACE_ON(rebar) ) return;
379 TRACE("hwnd=%p: color=%08x/%08x, bands=%u, rows=%u, cSize=%d,%d\n",
380 iP->hwndSelf, iP->clrText, iP->clrBk, iP->uNumBands, iP->uNumRows,
381 iP->calcSize.cx, iP->calcSize.cy);
382 TRACE("hwnd=%p: flags=%08x, dragStart=%d,%d, dragNow=%d,%d, iGrabbedBand=%d\n",
383 iP->hwndSelf, iP->fStatus, iP->dragStart.x, iP->dragStart.y,
384 iP->dragNow.x, iP->dragNow.y,
386 TRACE("hwnd=%p: style=%08x, notify in Unicode=%s, redraw=%s\n",
387 iP->hwndSelf, iP->dwStyle, (iP->bUnicode)?"TRUE":"FALSE",
388 (iP->DoRedraw)?"TRUE":"FALSE");
389 for (i = 0; i < iP->uNumBands; i++) {
390 pB = REBAR_GetBand(iP, i);
391 TRACE("band # %u:", i);
392 if (pB->fMask & RBBIM_ID)
393 TRACE(" ID=%u", pB->wID);
394 if (pB->fMask & RBBIM_CHILD)
395 TRACE(" child=%p", pB->hwndChild);
396 if (pB->fMask & RBBIM_COLORS)
397 TRACE(" clrF=0x%06x clrB=0x%06x", pB->clrFore, pB->clrBack);
399 TRACE("band # %u: mask=0x%08x (%s)\n", i, pB->fMask, REBAR_FmtMask(pB->fMask));
400 if (pB->fMask & RBBIM_STYLE)
401 TRACE("band # %u: style=0x%08x (%s)\n",
402 i, pB->fStyle, REBAR_FmtStyle(pB->fStyle));
403 TRACE("band # %u: xHeader=%u",
405 if (pB->fMask & (RBBIM_SIZE | RBBIM_IDEALSIZE | RBBIM_LPARAM )) {
406 if (pB->fMask & RBBIM_SIZE)
407 TRACE(" cx=%u", pB->cx);
408 if (pB->fMask & RBBIM_IDEALSIZE)
409 TRACE(" xIdeal=%u", pB->cxIdeal);
410 if (pB->fMask & RBBIM_LPARAM)
411 TRACE(" lParam=0x%08lx", pB->lParam);
415 TRACE("band # %u: xMin=%u, yMin=%u, yChild=%u, yMax=%u, yIntgl=%u\n",
416 i, pB->cxMinChild, pB->cyMinChild, pB->cyChild, pB->cyMaxChild, pB->cyIntegral);
417 if (pB->fMask & RBBIM_TEXT)
418 TRACE("band # %u: text=%s\n",
419 i, (pB->lpText) ? debugstr_w(pB->lpText) : "(null)");
420 TRACE("band # %u: cxMinBand=%u, cxEffective=%u, cyMinBand=%u\n",
421 i, pB->cxMinBand, pB->cxEffective, pB->cyMinBand);
422 TRACE("band # %u: fStatus=%08x, fDraw=%08x, Band=(%s), Grip=(%s)\n",
423 i, pB->fStatus, pB->fDraw, wine_dbgstr_rect(&pB->rcBand),
424 wine_dbgstr_rect(&pB->rcGripper));
425 TRACE("band # %u: Img=(%s), Txt=(%s), Child=(%s)\n",
426 i, wine_dbgstr_rect(&pB->rcCapImage),
427 wine_dbgstr_rect(&pB->rcCapText), wine_dbgstr_rect(&pB->rcChild));
432 /* dest can be equal to src */
433 static void translate_rect(const REBAR_INFO *infoPtr, RECT *dest, const RECT *src)
435 if (infoPtr->dwStyle & CCS_VERT) {
438 dest->left = src->top;
442 dest->right = src->bottom;
449 static int get_rect_cx(const REBAR_INFO *infoPtr, const RECT *lpRect)
451 if (infoPtr->dwStyle & CCS_VERT)
452 return lpRect->bottom - lpRect->top;
453 return lpRect->right - lpRect->left;
456 static int get_rect_cy(const REBAR_INFO *infoPtr, const RECT *lpRect)
458 if (infoPtr->dwStyle & CCS_VERT)
459 return lpRect->right - lpRect->left;
460 return lpRect->bottom - lpRect->top;
463 static int round_child_height(const REBAR_BAND *lpBand, int cyHeight)
466 if (lpBand->cyIntegral == 0)
468 cy = max(cyHeight - (int)lpBand->cyMinChild, 0);
469 cy = lpBand->cyMinChild + (cy/lpBand->cyIntegral) * lpBand->cyIntegral;
470 cy = min(cy, lpBand->cyMaxChild);
474 static void update_min_band_height(const REBAR_INFO *infoPtr, REBAR_BAND *lpBand)
476 lpBand->cyMinBand = max(lpBand->cyHeader,
477 (lpBand->hwndChild ? lpBand->cyChild + REBARSPACE(lpBand) : REBAR_NO_CHILD_HEIGHT));
481 REBAR_DrawChevron (HDC hdc, INT left, INT top, INT colorRef)
486 if (!(hPen = CreatePen( PS_SOLID, 1, GetSysColor( colorRef )))) return;
487 hOldPen = SelectObject ( hdc, hPen );
490 MoveToEx (hdc, x, y, NULL);
491 LineTo (hdc, x+5, y++); x++;
492 MoveToEx (hdc, x, y, NULL);
493 LineTo (hdc, x+3, y++); x++;
494 MoveToEx (hdc, x, y, NULL);
495 LineTo (hdc, x+1, y);
496 SelectObject( hdc, hOldPen );
497 DeleteObject( hPen );
501 REBAR_GetNotifyParent (const REBAR_INFO *infoPtr)
505 parent = infoPtr->hwndNotify;
507 parent = GetParent (infoPtr->hwndSelf);
508 owner = GetWindow (infoPtr->hwndSelf, GW_OWNER);
509 if (owner) parent = owner;
516 REBAR_Notify (NMHDR *nmhdr, const REBAR_INFO *infoPtr, UINT code)
520 parent = REBAR_GetNotifyParent (infoPtr);
521 nmhdr->idFrom = GetDlgCtrlID (infoPtr->hwndSelf);
522 nmhdr->hwndFrom = infoPtr->hwndSelf;
525 TRACE("window %p, code=%08x, via %s\n", parent, code, (infoPtr->bUnicode)?"Unicode":"ANSI");
527 return SendMessageW(parent, WM_NOTIFY, nmhdr->idFrom, (LPARAM)nmhdr);
531 REBAR_Notify_NMREBAR (const REBAR_INFO *infoPtr, UINT uBand, UINT code)
533 NMREBAR notify_rebar;
535 notify_rebar.dwMask = 0;
537 REBAR_BAND *lpBand = REBAR_GetBand(infoPtr, uBand);
539 if (lpBand->fMask & RBBIM_ID) {
540 notify_rebar.dwMask |= RBNM_ID;
541 notify_rebar.wID = lpBand->wID;
543 if (lpBand->fMask & RBBIM_LPARAM) {
544 notify_rebar.dwMask |= RBNM_LPARAM;
545 notify_rebar.lParam = lpBand->lParam;
547 if (lpBand->fMask & RBBIM_STYLE) {
548 notify_rebar.dwMask |= RBNM_STYLE;
549 notify_rebar.fStyle = lpBand->fStyle;
552 notify_rebar.uBand = uBand;
553 return REBAR_Notify ((NMHDR *)¬ify_rebar, infoPtr, code);
557 REBAR_DrawBand (HDC hdc, const REBAR_INFO *infoPtr, REBAR_BAND *lpBand)
562 HTHEME theme = GetWindowTheme (infoPtr->hwndSelf);
565 translate_rect(infoPtr, &rcBand, &lpBand->rcBand);
567 if (lpBand->fDraw & DRAW_TEXT) {
568 hOldFont = SelectObject (hdc, infoPtr->hFont);
569 oldBkMode = SetBkMode (hdc, TRANSPARENT);
572 /* should test for CDRF_NOTIFYITEMDRAW here */
573 nmcd.dwDrawStage = CDDS_ITEMPREPAINT;
576 nmcd.rc.right = lpBand->rcCapText.right;
577 nmcd.rc.bottom = lpBand->rcCapText.bottom;
578 nmcd.dwItemSpec = lpBand->wID;
580 nmcd.lItemlParam = lpBand->lParam;
581 lpBand->uCDret = REBAR_Notify ((NMHDR *)&nmcd, infoPtr, NM_CUSTOMDRAW);
582 if (lpBand->uCDret == CDRF_SKIPDEFAULT) {
583 if (oldBkMode != TRANSPARENT)
584 SetBkMode (hdc, oldBkMode);
585 SelectObject (hdc, hOldFont);
590 if (lpBand->fDraw & DRAW_GRIPPER)
594 RECT rcGripper = lpBand->rcGripper;
595 int partId = (infoPtr->dwStyle & CCS_VERT) ? RP_GRIPPERVERT : RP_GRIPPER;
596 GetThemeBackgroundExtent (theme, hdc, partId, 0, &rcGripper, &rcGripper);
597 OffsetRect (&rcGripper, lpBand->rcGripper.left - rcGripper.left,
598 lpBand->rcGripper.top - rcGripper.top);
599 DrawThemeBackground (theme, hdc, partId, 0, &rcGripper, NULL);
602 DrawEdge (hdc, &lpBand->rcGripper, BDR_RAISEDINNER, BF_RECT | BF_MIDDLE);
605 /* draw caption image */
606 if (lpBand->fDraw & DRAW_IMAGE) {
610 pt.y = (lpBand->rcCapImage.bottom + lpBand->rcCapImage.top - infoPtr->imageSize.cy)/2;
611 pt.x = (lpBand->rcCapImage.right + lpBand->rcCapImage.left - infoPtr->imageSize.cx)/2;
613 ImageList_Draw (infoPtr->himl, lpBand->iImage, hdc,
618 /* draw caption text */
619 if (lpBand->fDraw & DRAW_TEXT) {
620 /* need to handle CDRF_NEWFONT here */
621 INT oldBkMode = SetBkMode (hdc, TRANSPARENT);
622 COLORREF oldcolor = CLR_NONE;
624 if (lpBand->clrFore != CLR_NONE) {
625 new = (lpBand->clrFore == CLR_DEFAULT) ? infoPtr->clrBtnText :
627 oldcolor = SetTextColor (hdc, new);
629 DrawTextW (hdc, lpBand->lpText, -1, &lpBand->rcCapText,
630 DT_CENTER | DT_VCENTER | DT_SINGLELINE);
631 if (oldBkMode != TRANSPARENT)
632 SetBkMode (hdc, oldBkMode);
633 if (lpBand->clrFore != CLR_NONE)
634 SetTextColor (hdc, oldcolor);
635 SelectObject (hdc, hOldFont);
638 if (!IsRectEmpty(&lpBand->rcChevron))
643 if (lpBand->fDraw & DRAW_CHEVRONPUSHED)
644 stateId = CHEVS_PRESSED;
645 else if (lpBand->fDraw & DRAW_CHEVRONHOT)
648 stateId = CHEVS_NORMAL;
649 DrawThemeBackground (theme, hdc, RP_CHEVRON, stateId, &lpBand->rcChevron, NULL);
653 if (lpBand->fDraw & DRAW_CHEVRONPUSHED)
655 DrawEdge(hdc, &lpBand->rcChevron, BDR_SUNKENOUTER, BF_RECT | BF_MIDDLE);
656 REBAR_DrawChevron(hdc, lpBand->rcChevron.left+1, lpBand->rcChevron.top + 11, COLOR_WINDOWFRAME);
658 else if (lpBand->fDraw & DRAW_CHEVRONHOT)
660 DrawEdge(hdc, &lpBand->rcChevron, BDR_RAISEDINNER, BF_RECT | BF_MIDDLE);
661 REBAR_DrawChevron(hdc, lpBand->rcChevron.left, lpBand->rcChevron.top + 10, COLOR_WINDOWFRAME);
664 REBAR_DrawChevron(hdc, lpBand->rcChevron.left, lpBand->rcChevron.top + 10, COLOR_WINDOWFRAME);
668 if (lpBand->uCDret == (CDRF_NOTIFYPOSTPAINT | CDRF_NOTIFYITEMDRAW)) {
669 nmcd.dwDrawStage = CDDS_ITEMPOSTPAINT;
672 nmcd.rc.right = lpBand->rcCapText.right;
673 nmcd.rc.bottom = lpBand->rcCapText.bottom;
674 nmcd.dwItemSpec = lpBand->wID;
676 nmcd.lItemlParam = lpBand->lParam;
677 lpBand->uCDret = REBAR_Notify ((NMHDR *)&nmcd, infoPtr, NM_CUSTOMDRAW);
683 REBAR_Refresh (const REBAR_INFO *infoPtr, HDC hdc)
688 if (!infoPtr->DoRedraw) return;
690 for (i = 0; i < infoPtr->uNumBands; i++) {
691 lpBand = REBAR_GetBand(infoPtr, i);
693 if (HIDDENBAND(lpBand)) continue;
695 /* now draw the band */
696 TRACE("[%p] drawing band %i, flags=%08x\n",
697 infoPtr->hwndSelf, i, lpBand->fDraw);
698 REBAR_DrawBand (hdc, infoPtr, lpBand);
704 REBAR_CalcHorzBand (const REBAR_INFO *infoPtr, UINT rstart, UINT rend)
705 /* Function: this routine initializes all the rectangles in */
706 /* each band in a row to fit in the adjusted rcBand rect. */
707 /* *** Supports only Horizontal bars. *** */
713 for(i=rstart; i<rend; i++){
714 lpBand = REBAR_GetBand(infoPtr, i);
715 if (HIDDENBAND(lpBand)) {
716 SetRect (&lpBand->rcChild,
717 lpBand->rcBand.right, lpBand->rcBand.top,
718 lpBand->rcBand.right, lpBand->rcBand.bottom);
722 /* set initial gripper rectangle */
723 SetRect (&lpBand->rcGripper, lpBand->rcBand.left, lpBand->rcBand.top,
724 lpBand->rcBand.left, lpBand->rcBand.bottom);
726 /* calculate gripper rectangle */
727 if ( lpBand->fStatus & HAS_GRIPPER) {
728 lpBand->fDraw |= DRAW_GRIPPER;
729 lpBand->rcGripper.left += REBAR_PRE_GRIPPER;
730 lpBand->rcGripper.right = lpBand->rcGripper.left + GRIPPER_WIDTH;
731 lpBand->rcGripper.top += 2;
732 lpBand->rcGripper.bottom -= 2;
734 SetRect (&lpBand->rcCapImage,
735 lpBand->rcGripper.right+REBAR_ALWAYS_SPACE, lpBand->rcBand.top,
736 lpBand->rcGripper.right+REBAR_ALWAYS_SPACE, lpBand->rcBand.bottom);
738 else { /* no gripper will be drawn */
740 if (lpBand->fStatus & (HAS_IMAGE | HAS_TEXT))
741 /* if no gripper but either image or text, then leave space */
742 xoff = REBAR_ALWAYS_SPACE;
743 SetRect (&lpBand->rcCapImage,
744 lpBand->rcBand.left+xoff, lpBand->rcBand.top,
745 lpBand->rcBand.left+xoff, lpBand->rcBand.bottom);
748 /* image is visible */
749 if (lpBand->fStatus & HAS_IMAGE) {
750 lpBand->fDraw |= DRAW_IMAGE;
751 lpBand->rcCapImage.right += infoPtr->imageSize.cx;
752 lpBand->rcCapImage.bottom = lpBand->rcCapImage.top + infoPtr->imageSize.cy;
754 /* set initial caption text rectangle */
755 SetRect (&lpBand->rcCapText,
756 lpBand->rcCapImage.right+REBAR_POST_IMAGE, lpBand->rcBand.top+1,
757 lpBand->rcBand.left+lpBand->cxHeader, lpBand->rcBand.bottom-1);
760 /* set initial caption text rectangle */
761 SetRect (&lpBand->rcCapText, lpBand->rcCapImage.right, lpBand->rcBand.top+1,
762 lpBand->rcBand.left+lpBand->cxHeader, lpBand->rcBand.bottom-1);
765 /* text is visible */
766 if ((lpBand->fStatus & HAS_TEXT) && !(lpBand->fStyle & RBBS_HIDETITLE)) {
767 lpBand->fDraw |= DRAW_TEXT;
768 lpBand->rcCapText.right = max(lpBand->rcCapText.left,
769 lpBand->rcCapText.right-REBAR_POST_TEXT);
772 /* set initial child window rectangle if there is a child */
773 if (lpBand->hwndChild != NULL) {
774 int cyBand = lpBand->rcBand.bottom - lpBand->rcBand.top;
775 yoff = (cyBand - lpBand->cyChild) / 2;
776 SetRect (&lpBand->rcChild,
777 lpBand->rcBand.left + lpBand->cxHeader, lpBand->rcBand.top + yoff,
778 lpBand->rcBand.right - REBAR_POST_CHILD, lpBand->rcBand.top + yoff + lpBand->cyChild);
779 if ((lpBand->fStyle & RBBS_USECHEVRON) && (lpBand->rcChild.right - lpBand->rcChild.left < lpBand->cxIdeal))
781 lpBand->rcChild.right -= CHEVRON_WIDTH;
782 SetRect(&lpBand->rcChevron, lpBand->rcChild.right,
783 lpBand->rcChild.top, lpBand->rcChild.right + CHEVRON_WIDTH,
784 lpBand->rcChild.bottom);
788 SetRect (&lpBand->rcChild,
789 lpBand->rcBand.left+lpBand->cxHeader, lpBand->rcBand.top,
790 lpBand->rcBand.right, lpBand->rcBand.bottom);
793 /* flag if notify required and invalidate rectangle */
794 if (lpBand->fDraw & NTF_INVALIDATE) {
795 TRACE("invalidating (%d,%d)-(%d,%d)\n",
798 lpBand->rcBand.right + SEP_WIDTH,
799 lpBand->rcBand.bottom + SEP_WIDTH);
800 lpBand->fDraw &= ~NTF_INVALIDATE;
801 work = lpBand->rcBand;
802 work.right += SEP_WIDTH;
803 work.bottom += SEP_WIDTH;
804 InvalidateRect(infoPtr->hwndSelf, &work, TRUE);
805 if (lpBand->hwndChild) InvalidateRect(lpBand->hwndChild, NULL, TRUE);
814 REBAR_CalcVertBand (const REBAR_INFO *infoPtr, UINT rstart, UINT rend)
815 /* Function: this routine initializes all the rectangles in */
816 /* each band in a row to fit in the adjusted rcBand rect. */
817 /* *** Supports only Vertical bars. *** */
823 for(i=rstart; i<rend; i++){
825 lpBand = REBAR_GetBand(infoPtr, i);
826 if (HIDDENBAND(lpBand)) continue;
828 translate_rect(infoPtr, &rcBand, &lpBand->rcBand);
830 /* set initial gripper rectangle */
831 SetRect (&lpBand->rcGripper, rcBand.left, rcBand.top, rcBand.right, rcBand.top);
833 /* calculate gripper rectangle */
834 if (lpBand->fStatus & HAS_GRIPPER) {
835 lpBand->fDraw |= DRAW_GRIPPER;
837 if (infoPtr->dwStyle & RBS_VERTICALGRIPPER) {
838 /* vertical gripper */
839 lpBand->rcGripper.left += 3;
840 lpBand->rcGripper.right = lpBand->rcGripper.left + GRIPPER_WIDTH;
841 lpBand->rcGripper.top += REBAR_PRE_GRIPPER;
842 lpBand->rcGripper.bottom = lpBand->rcGripper.top + GRIPPER_HEIGHT;
844 /* initialize Caption image rectangle */
845 SetRect (&lpBand->rcCapImage, rcBand.left,
846 lpBand->rcGripper.bottom + REBAR_ALWAYS_SPACE,
848 lpBand->rcGripper.bottom + REBAR_ALWAYS_SPACE);
851 /* horizontal gripper */
852 lpBand->rcGripper.left += 2;
853 lpBand->rcGripper.right -= 2;
854 lpBand->rcGripper.top += REBAR_PRE_GRIPPER;
855 lpBand->rcGripper.bottom = lpBand->rcGripper.top + GRIPPER_WIDTH;
857 /* initialize Caption image rectangle */
858 SetRect (&lpBand->rcCapImage, rcBand.left,
859 lpBand->rcGripper.bottom + REBAR_ALWAYS_SPACE,
861 lpBand->rcGripper.bottom + REBAR_ALWAYS_SPACE);
864 else { /* no gripper will be drawn */
866 if (lpBand->fStatus & (HAS_IMAGE | HAS_TEXT))
867 /* if no gripper but either image or text, then leave space */
868 xoff = REBAR_ALWAYS_SPACE;
869 /* initialize Caption image rectangle */
870 SetRect (&lpBand->rcCapImage,
871 rcBand.left, rcBand.top+xoff,
872 rcBand.right, rcBand.top+xoff);
875 /* image is visible */
876 if (lpBand->fStatus & HAS_IMAGE) {
877 lpBand->fDraw |= DRAW_IMAGE;
879 lpBand->rcCapImage.right = lpBand->rcCapImage.left + infoPtr->imageSize.cx;
880 lpBand->rcCapImage.bottom += infoPtr->imageSize.cy;
882 /* set initial caption text rectangle */
883 SetRect (&lpBand->rcCapText,
884 rcBand.left, lpBand->rcCapImage.bottom+REBAR_POST_IMAGE,
885 rcBand.right, rcBand.top+lpBand->cxHeader);
888 /* set initial caption text rectangle */
889 SetRect (&lpBand->rcCapText,
890 rcBand.left, lpBand->rcCapImage.bottom,
891 rcBand.right, rcBand.top+lpBand->cxHeader);
894 /* text is visible */
895 if ((lpBand->fStatus & HAS_TEXT) && !(lpBand->fStyle & RBBS_HIDETITLE)) {
896 lpBand->fDraw |= DRAW_TEXT;
897 lpBand->rcCapText.bottom = max(lpBand->rcCapText.top,
898 lpBand->rcCapText.bottom);
901 /* set initial child window rectangle if there is a child */
902 if (lpBand->hwndChild) {
903 int cxBand = rcBand.right - rcBand.left;
904 xoff = (cxBand - lpBand->cyChild) / 2;
905 SetRect (&lpBand->rcChild,
906 rcBand.left + xoff, rcBand.top + lpBand->cxHeader,
907 rcBand.left + xoff + lpBand->cyChild, rcBand.bottom - REBAR_POST_CHILD);
910 SetRect (&lpBand->rcChild,
911 rcBand.left, rcBand.top+lpBand->cxHeader,
912 rcBand.right, rcBand.bottom);
915 if (lpBand->fDraw & NTF_INVALIDATE) {
916 TRACE("invalidating (%d,%d)-(%d,%d)\n",
919 rcBand.right + SEP_WIDTH,
920 rcBand.bottom + SEP_WIDTH);
921 lpBand->fDraw &= ~NTF_INVALIDATE;
923 work.bottom += SEP_WIDTH;
924 work.right += SEP_WIDTH;
925 InvalidateRect(infoPtr->hwndSelf, &work, TRUE);
926 if (lpBand->hwndChild) InvalidateRect(lpBand->hwndChild, NULL, TRUE);
934 REBAR_ForceResize (REBAR_INFO *infoPtr)
935 /* Function: This changes the size of the REBAR window to that */
936 /* calculated by REBAR_Layout. */
938 INT x, y, width, height;
939 INT xedge = 0, yedge = 0;
942 TRACE("new size [%d x %d]\n", infoPtr->calcSize.cx, infoPtr->calcSize.cy);
944 if (infoPtr->dwStyle & CCS_NORESIZE)
947 if (infoPtr->dwStyle & WS_BORDER)
949 xedge = GetSystemMetrics(SM_CXEDGE);
950 yedge = GetSystemMetrics(SM_CYEDGE);
951 /* swap for CCS_VERT? */
954 /* compute rebar window rect in parent client coordinates */
955 GetWindowRect(infoPtr->hwndSelf, &rcSelf);
956 MapWindowPoints(HWND_DESKTOP, GetParent(infoPtr->hwndSelf), (LPPOINT)&rcSelf, 2);
957 translate_rect(infoPtr, &rcSelf, &rcSelf);
959 height = infoPtr->calcSize.cy + 2*yedge;
960 if (!(infoPtr->dwStyle & CCS_NOPARENTALIGN)) {
964 width = infoPtr->calcSize.cx + 2*xedge;
965 y = 0; /* quiet compiler warning */
966 switch ( infoPtr->dwStyle & CCS_LAYOUT_MASK) {
967 case 0: /* shouldn't happen - see NCCreate */
969 y = ((infoPtr->dwStyle & CCS_NODIVIDER) ? 0 : REBAR_DIVIDER) - yedge;
975 GetClientRect(GetParent(infoPtr->hwndSelf), &rcParent);
976 translate_rect(infoPtr, &rcParent, &rcParent);
977 y = rcParent.bottom - infoPtr->calcSize.cy - yedge;
983 /* As on Windows if the CCS_NODIVIDER is not present the control will move
984 * 2 pixel down after every layout */
985 y = rcSelf.top + ((infoPtr->dwStyle & CCS_NODIVIDER) ? 0 : REBAR_DIVIDER);
986 width = rcSelf.right - rcSelf.left;
989 TRACE("hwnd %p, style=%08x, setting at (%d,%d) for (%d,%d)\n",
990 infoPtr->hwndSelf, infoPtr->dwStyle, x, y, width, height);
992 /* Set flag to ignore next WM_SIZE message and resize the window */
993 infoPtr->fStatus |= SELF_RESIZE;
994 if ((infoPtr->dwStyle & CCS_VERT) == 0)
995 SetWindowPos(infoPtr->hwndSelf, 0, x, y, width, height, SWP_NOZORDER);
997 SetWindowPos(infoPtr->hwndSelf, 0, y, x, height, width, SWP_NOZORDER);
998 infoPtr->fStatus &= ~SELF_RESIZE;
1003 REBAR_MoveChildWindows (const REBAR_INFO *infoPtr, UINT start, UINT endplus)
1005 static const WCHAR strComboBox[] = { 'C','o','m','b','o','B','o','x',0 };
1007 WCHAR szClassName[40];
1009 NMREBARCHILDSIZE rbcz;
1012 if (!(deferpos = BeginDeferWindowPos(infoPtr->uNumBands)))
1013 ERR("BeginDeferWindowPos returned NULL\n");
1015 for (i = start; i < endplus; i++) {
1016 lpBand = REBAR_GetBand(infoPtr, i);
1018 if (HIDDENBAND(lpBand)) continue;
1019 if (lpBand->hwndChild) {
1020 TRACE("hwndChild = %p\n", lpBand->hwndChild);
1022 /* Always generate the RBN_CHILDSIZE even if child
1025 rbcz.wID = lpBand->wID;
1026 rbcz.rcChild = lpBand->rcChild;
1027 translate_rect(infoPtr, &rbcz.rcBand, &lpBand->rcBand);
1028 if (infoPtr->dwStyle & CCS_VERT)
1029 rbcz.rcBand.top += lpBand->cxHeader;
1031 rbcz.rcBand.left += lpBand->cxHeader;
1032 REBAR_Notify ((NMHDR *)&rbcz, infoPtr, RBN_CHILDSIZE);
1033 if (!EqualRect (&lpBand->rcChild, &rbcz.rcChild)) {
1034 TRACE("Child rect changed by NOTIFY for band %u\n", i);
1035 TRACE(" from (%s) to (%s)\n",
1036 wine_dbgstr_rect(&lpBand->rcChild),
1037 wine_dbgstr_rect(&rbcz.rcChild));
1038 lpBand->rcChild = rbcz.rcChild; /* *** ??? */
1041 /* native (IE4 in "Favorites" frame **1) does:
1042 * SetRect (&rc, -1, -1, -1, -1)
1043 * EqualRect (&rc,band->rc???)
1045 * CopyRect (band->rc????, &rc)
1046 * set flag outside of loop
1049 GetClassNameW (lpBand->hwndChild, szClassName, sizeof(szClassName)/sizeof(szClassName[0]));
1050 if (!lstrcmpW (szClassName, strComboBox) ||
1051 !lstrcmpW (szClassName, WC_COMBOBOXEXW)) {
1052 INT nEditHeight, yPos;
1055 /* special placement code for combo or comboex box */
1058 /* get size of edit line */
1059 GetWindowRect (lpBand->hwndChild, &rc);
1060 nEditHeight = rc.bottom - rc.top;
1061 yPos = (lpBand->rcChild.bottom + lpBand->rcChild.top - nEditHeight)/2;
1063 /* center combo box inside child area */
1064 TRACE("moving child (Combo(Ex)) %p to (%d,%d) for (%d,%d)\n",
1066 lpBand->rcChild.left, yPos,
1067 lpBand->rcChild.right - lpBand->rcChild.left,
1069 deferpos = DeferWindowPos (deferpos, lpBand->hwndChild, HWND_TOP,
1070 lpBand->rcChild.left,
1071 /*lpBand->rcChild.top*/ yPos,
1072 lpBand->rcChild.right - lpBand->rcChild.left,
1076 ERR("DeferWindowPos returned NULL\n");
1079 TRACE("moving child (Other) %p to (%d,%d) for (%d,%d)\n",
1081 lpBand->rcChild.left, lpBand->rcChild.top,
1082 lpBand->rcChild.right - lpBand->rcChild.left,
1083 lpBand->rcChild.bottom - lpBand->rcChild.top);
1084 deferpos = DeferWindowPos (deferpos, lpBand->hwndChild, HWND_TOP,
1085 lpBand->rcChild.left,
1086 lpBand->rcChild.top,
1087 lpBand->rcChild.right - lpBand->rcChild.left,
1088 lpBand->rcChild.bottom - lpBand->rcChild.top,
1091 ERR("DeferWindowPos returned NULL\n");
1095 if (!EndDeferWindowPos(deferpos))
1096 ERR("EndDeferWindowPos returned NULL\n");
1098 if (infoPtr->DoRedraw)
1099 UpdateWindow (infoPtr->hwndSelf);
1101 /* native (from **1 above) does:
1102 * UpdateWindow(rebar)
1104 * RBN_HEIGHTCHANGE if necessary
1105 * if ret from any EqualRect was 0
1106 * Goto "BeginDeferWindowPos"
1111 /* Returns the next visible band (the first visible band in [i+1; infoPtr->uNumBands) )
1112 * or infoPtr->uNumBands if none */
1113 static int next_visible(const REBAR_INFO *infoPtr, int i)
1116 for (n = i + 1; n < infoPtr->uNumBands; n++)
1117 if (!HIDDENBAND(REBAR_GetBand(infoPtr, n)))
1122 /* Returns the previous visible band (the last visible band in [0; i) )
1124 static int prev_visible(const REBAR_INFO *infoPtr, int i)
1127 for (n = i - 1; n >= 0; n--)
1128 if (!HIDDENBAND(REBAR_GetBand(infoPtr, n)))
1133 /* Returns the first visible band or infoPtr->uNumBands if none */
1134 static int first_visible(const REBAR_INFO *infoPtr)
1136 return next_visible(infoPtr, -1); /* this works*/
1139 /* Returns the first visible band for the given row (or iBand if none) */
1140 static int get_row_begin_for_band(const REBAR_INFO *infoPtr, INT iBand)
1142 int iLastBand = iBand;
1143 int iRow = REBAR_GetBand(infoPtr, iBand)->iRow;
1144 while ((iBand = prev_visible(infoPtr, iBand)) >= 0) {
1145 if (REBAR_GetBand(infoPtr, iBand)->iRow != iRow)
1153 /* Returns the first visible band for the next row (or infoPtr->uNumBands if none) */
1154 static int get_row_end_for_band(const REBAR_INFO *infoPtr, INT iBand)
1156 int iRow = REBAR_GetBand(infoPtr, iBand)->iRow;
1157 while ((iBand = next_visible(infoPtr, iBand)) < infoPtr->uNumBands)
1158 if (REBAR_GetBand(infoPtr, iBand)->iRow != iRow)
1163 /* Compute the rcBand.{left,right} from the cxEffective bands widths computed earlier.
1164 * iBeginBand must be visible */
1165 static void REBAR_SetRowRectsX(const REBAR_INFO *infoPtr, INT iBeginBand, INT iEndBand)
1168 for (i = iBeginBand; i < iEndBand; i = next_visible(infoPtr, i))
1170 REBAR_BAND *lpBand = REBAR_GetBand(infoPtr, i);
1172 lpBand = REBAR_GetBand(infoPtr, i);
1173 if (lpBand->rcBand.left != xPos || lpBand->rcBand.right != xPos + lpBand->cxEffective) {
1174 lpBand->fDraw |= NTF_INVALIDATE;
1175 TRACE("Setting rect %d to %d,%d\n", i, xPos, xPos + lpBand->cxEffective);
1176 lpBand->rcBand.left = xPos;
1177 lpBand->rcBand.right = xPos + lpBand->cxEffective;
1179 xPos += lpBand->cxEffective + SEP_WIDTH;
1183 /* The rationale of this function is probably as follows: if we have some space
1184 * to distribute we want to add it to a band on the right. However we don't want
1185 * to unminimize a minimized band so we search for a band that is big enough.
1186 * For some reason "big enough" is defined as bigger than the minimum size of the
1187 * first band in the row
1189 static REBAR_BAND *REBAR_FindBandToGrow(const REBAR_INFO *infoPtr, INT iBeginBand, INT iEndBand)
1191 INT cxMinFirstBand = 0, i;
1193 cxMinFirstBand = REBAR_GetBand(infoPtr, iBeginBand)->cxMinBand;
1195 for (i = prev_visible(infoPtr, iEndBand); i >= iBeginBand; i = prev_visible(infoPtr, i))
1196 if (REBAR_GetBand(infoPtr, i)->cxEffective > cxMinFirstBand &&
1197 !(REBAR_GetBand(infoPtr, i)->fStyle & RBBS_FIXEDSIZE))
1201 for (i = prev_visible(infoPtr, iEndBand); i >= iBeginBand; i = prev_visible(infoPtr, i))
1202 if (REBAR_GetBand(infoPtr, i)->cxMinBand == cxMinFirstBand)
1205 TRACE("Extra space for row [%d..%d) should be added to band %d\n", iBeginBand, iEndBand, i);
1206 return REBAR_GetBand(infoPtr, i);
1209 /* Try to shrink the visible bands in [iBeginBand; iEndBand) by cxShrink, starting from the right */
1210 static int REBAR_ShrinkBandsRTL(const REBAR_INFO *infoPtr, INT iBeginBand, INT iEndBand, INT cxShrink, BOOL bEnforce)
1215 TRACE("Shrinking bands [%d..%d) by %d, right-to-left\n", iBeginBand, iEndBand, cxShrink);
1216 for (i = prev_visible(infoPtr, iEndBand); i >= iBeginBand; i = prev_visible(infoPtr, i))
1218 lpBand = REBAR_GetBand(infoPtr, i);
1220 width = max(lpBand->cxEffective - cxShrink, (int)lpBand->cxMinBand);
1221 cxShrink -= lpBand->cxEffective - width;
1222 lpBand->cxEffective = width;
1223 if (bEnforce && lpBand->cx > lpBand->cxEffective)
1224 lpBand->cx = lpBand->cxEffective;
1232 /* Try to shrink the visible bands in [iBeginBand; iEndBand) by cxShrink, starting from the left.
1233 * iBeginBand must be visible */
1234 static int REBAR_ShrinkBandsLTR(const REBAR_INFO *infoPtr, INT iBeginBand, INT iEndBand, INT cxShrink, BOOL bEnforce)
1239 TRACE("Shrinking bands [%d..%d) by %d, left-to-right\n", iBeginBand, iEndBand, cxShrink);
1240 for (i = iBeginBand; i < iEndBand; i = next_visible(infoPtr, i))
1242 lpBand = REBAR_GetBand(infoPtr, i);
1244 width = max(lpBand->cxEffective - cxShrink, (int)lpBand->cxMinBand);
1245 cxShrink -= lpBand->cxEffective - width;
1246 lpBand->cxEffective = width;
1248 lpBand->cx = lpBand->cxEffective;
1255 /* Set the heights of the visible bands in [iBeginBand; iEndBand) to the max height. iBeginBand must be visible */
1256 static int REBAR_SetBandsHeight(const REBAR_INFO *infoPtr, INT iBeginBand, INT iEndBand, INT yStart)
1261 int row = REBAR_GetBand(infoPtr, iBeginBand)->iRow;
1263 for (i = iBeginBand; i < iEndBand; i = next_visible(infoPtr, i))
1265 lpBand = REBAR_GetBand(infoPtr, i);
1266 lpBand->cyRowSoFar = yMaxHeight;
1267 yMaxHeight = max(yMaxHeight, lpBand->cyMinBand);
1269 TRACE("Bands [%d; %d) height: %d\n", iBeginBand, iEndBand, yMaxHeight);
1271 for (i = iBeginBand; i < iEndBand; i = next_visible(infoPtr, i))
1273 lpBand = REBAR_GetBand(infoPtr, i);
1274 /* we may be called for multiple rows if RBS_VARHEIGHT not set */
1275 if (lpBand->iRow != row) {
1276 yPos += yMaxHeight + SEP_WIDTH;
1280 if (lpBand->rcBand.top != yPos || lpBand->rcBand.bottom != yPos + yMaxHeight) {
1281 lpBand->fDraw |= NTF_INVALIDATE;
1282 lpBand->rcBand.top = yPos;
1283 lpBand->rcBand.bottom = yPos + yMaxHeight;
1284 TRACE("Band %d: %s\n", i, wine_dbgstr_rect(&lpBand->rcBand));
1287 return yPos + yMaxHeight;
1290 /* Layout the row [iBeginBand; iEndBand). iBeginBand must be visible */
1291 static void REBAR_LayoutRow(const REBAR_INFO *infoPtr, int iBeginBand, int iEndBand, int cx, int *piRow, int *pyPos)
1297 TRACE("Adjusting row [%d;%d). Width: %d\n", iBeginBand, iEndBand, cx);
1298 for (i = iBeginBand; i < iEndBand; i++)
1299 REBAR_GetBand(infoPtr, i)->iRow = *piRow;
1301 /* compute the extra space */
1302 for (i = iBeginBand; i < iEndBand; i = next_visible(infoPtr, i))
1304 lpBand = REBAR_GetBand(infoPtr, i);
1307 lpBand->cxEffective = max(lpBand->cxMinBand, lpBand->cx);
1308 width += lpBand->cxEffective;
1312 TRACE("Extra space: %d\n", extra);
1314 int ret = REBAR_ShrinkBandsRTL(infoPtr, iBeginBand, iEndBand, -extra, FALSE);
1315 if (ret > 0 && next_visible(infoPtr, iBeginBand) != iEndBand) /* one band may be longer than expected... */
1316 ERR("Error layouting row %d - couldn't shrink for %d pixels (%d total shrink)\n", *piRow, ret, -extra);
1319 lpBand = REBAR_FindBandToGrow(infoPtr, iBeginBand, iEndBand);
1320 lpBand->cxEffective += extra;
1323 REBAR_SetRowRectsX(infoPtr, iBeginBand, iEndBand);
1324 if (infoPtr->dwStyle & RBS_VARHEIGHT)
1327 *pyPos += SEP_WIDTH;
1328 *pyPos = REBAR_SetBandsHeight(infoPtr, iBeginBand, iEndBand, *pyPos);
1334 REBAR_Layout(REBAR_INFO *infoPtr)
1344 if (infoPtr->dwStyle & (CCS_NORESIZE | CCS_NOPARENTALIGN) || GetParent(infoPtr->hwndSelf) == NULL)
1345 GetClientRect(infoPtr->hwndSelf, &rcAdj);
1347 GetClientRect(GetParent(infoPtr->hwndSelf), &rcAdj);
1348 TRACE("adjustment rect is (%s)\n", wine_dbgstr_rect(&rcAdj));
1350 adjcx = get_rect_cx(infoPtr, &rcAdj);
1352 if (infoPtr->uNumBands == 0) {
1353 TRACE("No bands - setting size to (0,%d), vert: %lx\n", adjcx, infoPtr->dwStyle & CCS_VERT);
1354 infoPtr->calcSize.cx = adjcx;
1355 /* the calcSize.cy won't change for a 0 band rebar */
1356 infoPtr->uNumRows = 0;
1357 REBAR_ForceResize(infoPtr);
1363 rowstart = first_visible(infoPtr);
1365 for (i = rowstart; i < infoPtr->uNumBands; i = next_visible(infoPtr, i))
1367 lpBand = REBAR_GetBand(infoPtr, i);
1369 if (i > rowstart && (lpBand->fStyle & RBBS_BREAK || xMin + lpBand->cxMinBand > adjcx)) {
1370 TRACE("%s break on band %d\n", (lpBand->fStyle & RBBS_BREAK ? "Hard" : "Soft"), i - 1);
1371 REBAR_LayoutRow(infoPtr, rowstart, i, adjcx, &row, &yPos);
1378 xMin += lpBand->cxMinBand;
1380 if (rowstart < infoPtr->uNumBands)
1381 REBAR_LayoutRow(infoPtr, rowstart, infoPtr->uNumBands, adjcx, &row, &yPos);
1383 if (!(infoPtr->dwStyle & RBS_VARHEIGHT))
1384 yPos = REBAR_SetBandsHeight(infoPtr, first_visible(infoPtr), infoPtr->uNumBands, 0);
1386 infoPtr->uNumRows = row;
1388 if (infoPtr->dwStyle & CCS_VERT)
1389 REBAR_CalcVertBand(infoPtr, 0, infoPtr->uNumBands);
1391 REBAR_CalcHorzBand(infoPtr, 0, infoPtr->uNumBands);
1392 /* now compute size of Rebar itself */
1393 oldSize = infoPtr->calcSize;
1395 infoPtr->calcSize.cx = adjcx;
1396 infoPtr->calcSize.cy = yPos;
1397 TRACE("calcsize size=(%d, %d), origheight=(%d,%d)\n",
1398 infoPtr->calcSize.cx, infoPtr->calcSize.cy,
1399 oldSize.cx, oldSize.cy);
1401 REBAR_DumpBand (infoPtr);
1402 REBAR_MoveChildWindows (infoPtr, 0, infoPtr->uNumBands);
1403 REBAR_ForceResize (infoPtr);
1405 /* note: after a RBN_HEIGHTCHANGE native sends once again all the RBN_CHILDSIZE
1406 * and does another ForceResize */
1407 if (oldSize.cy != infoPtr->calcSize.cy)
1410 REBAR_Notify(&heightchange, infoPtr, RBN_HEIGHTCHANGE);
1411 REBAR_AutoSize(infoPtr, FALSE);
1415 /* iBeginBand must be visible */
1417 REBAR_SizeChildrenToHeight(const REBAR_INFO *infoPtr, int iBeginBand, int iEndBand, int extra, BOOL *fChanged)
1423 TRACE("[%d;%d) by %d\n", iBeginBand, iEndBand, extra);
1425 cyBandsOld = REBAR_GetBand(infoPtr, iBeginBand)->rcBand.bottom -
1426 REBAR_GetBand(infoPtr, iBeginBand)->rcBand.top;
1427 for (i = iBeginBand; i < iEndBand; i = next_visible(infoPtr, i))
1429 REBAR_BAND *lpBand = REBAR_GetBand(infoPtr, i);
1430 int cyMaxChild = cyBandsOld - REBARSPACE(lpBand) + extra;
1431 int cyChild = round_child_height(lpBand, cyMaxChild);
1433 if (lpBand->hwndChild && cyChild != lpBand->cyChild && (lpBand->fStyle & RBBS_VARIABLEHEIGHT))
1435 TRACE("Resizing %d: %d -> %d [%d]\n", i, lpBand->cyChild, cyChild, lpBand->cyMaxChild);
1437 lpBand->cyChild = cyChild;
1438 lpBand->fDraw |= NTF_INVALIDATE;
1439 update_min_band_height(infoPtr, lpBand);
1441 cyBandsNew = max(cyBandsNew, lpBand->cyMinBand);
1443 return cyBandsNew - cyBandsOld;
1446 /* worker function for RB_SIZETORECT and RBS_AUTOSIZE */
1448 REBAR_SizeToHeight(REBAR_INFO *infoPtr, int height)
1450 int extra = height - infoPtr->calcSize.cy; /* may be negative */
1451 BOOL fChanged = FALSE;
1452 UINT uNumRows = infoPtr->uNumRows;
1455 if (uNumRows == 0) /* avoid division by 0 */
1458 /* That's not exactly what Windows does but should be similar */
1460 /* Pass one: break-up/glue rows */
1463 for (i = prev_visible(infoPtr, infoPtr->uNumBands); i > 0; i = prev_visible(infoPtr, i))
1465 REBAR_BAND *lpBand = REBAR_GetBand(infoPtr, i);
1466 int height = lpBand->rcBand.bottom - lpBand->rcBand.top;
1467 int cyBreakExtra; /* additional cy for the rebar after a RBBS_BREAK on this band */
1469 if (infoPtr->dwStyle & RBS_VARHEIGHT)
1470 cyBreakExtra = lpBand->cyRowSoFar; /* 'height' => 'lpBand->cyRowSoFar' + 'height'*/
1472 cyBreakExtra = height; /* 'height' => 'height' + 'height'*/
1473 cyBreakExtra += SEP_WIDTH;
1475 if (extra <= cyBreakExtra / 2)
1478 if (!(lpBand->fStyle & RBBS_BREAK))
1480 TRACE("Adding break on band %d - extra %d -> %d\n", i, extra, extra - cyBreakExtra);
1481 lpBand->fStyle |= RBBS_BREAK;
1482 lpBand->fDraw |= NTF_INVALIDATE;
1484 extra -= cyBreakExtra;
1486 /* temporary change for _SizeControlsToHeight. The true values will be computed in _Layout */
1487 if (infoPtr->dwStyle & RBS_VARHEIGHT)
1488 lpBand->rcBand.bottom = lpBand->rcBand.top + lpBand->cyMinBand;
1492 /* TODO: else if (extra < 0) { try to remove some RBBS_BREAKs } */
1494 /* Pass two: increase/decrease control height */
1495 if (infoPtr->dwStyle & RBS_VARHEIGHT)
1497 int i = first_visible(infoPtr);
1499 while (i < infoPtr->uNumBands)
1501 REBAR_BAND *lpBand = REBAR_GetBand(infoPtr, i);
1502 int extraForRow = extra / (int)(uNumRows - iRow);
1505 /* we can't use get_row_end_for_band as we might have added RBBS_BREAK in the first phase */
1506 for (rowEnd = next_visible(infoPtr, i); rowEnd < infoPtr->uNumBands; rowEnd = next_visible(infoPtr, rowEnd))
1507 if (REBAR_GetBand(infoPtr, rowEnd)->iRow != lpBand->iRow ||
1508 REBAR_GetBand(infoPtr, rowEnd)->fStyle & RBBS_BREAK)
1511 extra -= REBAR_SizeChildrenToHeight(infoPtr, i, rowEnd, extraForRow, &fChanged);
1512 TRACE("extra = %d\n", extra);
1518 extra -= REBAR_SizeChildrenToHeight(infoPtr, first_visible(infoPtr), infoPtr->uNumBands, extra / infoPtr->uNumRows, &fChanged);
1521 REBAR_Layout(infoPtr);
1525 REBAR_AutoSize(REBAR_INFO *infoPtr, BOOL needsLayout)
1528 NMRBAUTOSIZE autosize;
1531 REBAR_Layout(infoPtr);
1532 GetClientRect(infoPtr->hwndSelf, &rc);
1533 REBAR_SizeToHeight(infoPtr, get_rect_cy(infoPtr, &rc));
1534 GetClientRect(infoPtr->hwndSelf, &rcNew);
1536 GetClientRect(infoPtr->hwndSelf, &autosize.rcTarget);
1537 autosize.fChanged = (memcmp(&rc, &rcNew, sizeof(RECT)) == 0);
1538 autosize.rcTarget = rc;
1539 autosize.rcActual = rcNew;
1540 REBAR_Notify((NMHDR *)&autosize, infoPtr, RBN_AUTOSIZE);
1544 REBAR_ValidateBand (const REBAR_INFO *infoPtr, REBAR_BAND *lpBand)
1545 /* Function: This routine evaluates the band specs supplied */
1546 /* by the user and updates the following 5 fields in */
1547 /* the internal band structure: cxHeader, cyHeader, cxMinBand, cyMinBand, fStatus */
1550 UINT textheight=0, imageheight = 0;
1554 lpBand->fStatus = 0;
1555 lpBand->cxMinBand = 0;
1556 lpBand->cyMinBand = 0;
1558 /* Data coming in from users into the cx... and cy... fields */
1559 /* may be bad, just garbage, because the user never clears */
1560 /* the fields. RB_{SET|INSERT}BAND{A|W} just passes the data */
1561 /* along if the fields exist in the input area. Here we must */
1562 /* determine if the data is valid. I have no idea how MS does */
1563 /* the validation, but it does because the RB_GETBANDINFO */
1564 /* returns a 0 when I know the sample program passed in an */
1565 /* address. Here I will use the algorithm that if the value */
1566 /* is greater than 65535 then it is bad and replace it with */
1567 /* a zero. Feel free to improve the algorithm. - GA 12/2000 */
1568 if (lpBand->cxMinChild > 65535) lpBand->cxMinChild = 0;
1569 if (lpBand->cyMinChild > 65535) lpBand->cyMinChild = 0;
1570 if (lpBand->cx > 65535) lpBand->cx = 0;
1571 if (lpBand->cyChild > 65535) lpBand->cyChild = 0;
1572 if (lpBand->cyIntegral > 65535) lpBand->cyIntegral = 0;
1573 if (lpBand->cxIdeal > 65535) lpBand->cxIdeal = 0;
1574 if (lpBand->cxHeader > 65535) lpBand->cxHeader = 0;
1576 /* TODO : we could try return to the caller if a value changed so that */
1577 /* a REBAR_Layout is needed. Till now the caller should call it */
1578 /* it always (we should also check what native does) */
1580 /* Header is where the image, text and gripper exist */
1581 /* in the band and precede the child window. */
1583 /* count number of non-FIXEDSIZE and non-Hidden bands */
1585 for (i=0; i<infoPtr->uNumBands; i++){
1586 tBand = REBAR_GetBand(infoPtr, i);
1587 if (!HIDDENBAND(tBand) && !(tBand->fStyle & RBBS_FIXEDSIZE))
1591 /* calculate gripper rectangle */
1592 if ( (!(lpBand->fStyle & RBBS_NOGRIPPER)) &&
1593 ( (lpBand->fStyle & RBBS_GRIPPERALWAYS) ||
1594 ( !(lpBand->fStyle & RBBS_FIXEDSIZE) && (nonfixed > 1)))
1596 lpBand->fStatus |= HAS_GRIPPER;
1597 if (infoPtr->dwStyle & CCS_VERT)
1598 if (infoPtr->dwStyle & RBS_VERTICALGRIPPER)
1599 header += (GRIPPER_HEIGHT + REBAR_PRE_GRIPPER);
1601 header += (GRIPPER_WIDTH + REBAR_PRE_GRIPPER);
1603 header += (REBAR_PRE_GRIPPER + GRIPPER_WIDTH);
1604 /* Always have 4 pixels before anything else */
1605 header += REBAR_ALWAYS_SPACE;
1608 /* image is visible */
1609 if (lpBand->iImage != -1 && (infoPtr->himl)) {
1610 lpBand->fStatus |= HAS_IMAGE;
1611 if (infoPtr->dwStyle & CCS_VERT) {
1612 header += (infoPtr->imageSize.cy + REBAR_POST_IMAGE);
1613 imageheight = infoPtr->imageSize.cx + 4;
1616 header += (infoPtr->imageSize.cx + REBAR_POST_IMAGE);
1617 imageheight = infoPtr->imageSize.cy + 4;
1621 /* text is visible */
1622 if ((lpBand->fMask & RBBIM_TEXT) && (lpBand->lpText) &&
1623 !(lpBand->fStyle & RBBS_HIDETITLE)) {
1624 HDC hdc = GetDC (0);
1625 HFONT hOldFont = SelectObject (hdc, infoPtr->hFont);
1628 lpBand->fStatus |= HAS_TEXT;
1629 GetTextExtentPoint32W (hdc, lpBand->lpText,
1630 lstrlenW (lpBand->lpText), &size);
1631 header += ((infoPtr->dwStyle & CCS_VERT) ? (size.cy + REBAR_POST_TEXT) : (size.cx + REBAR_POST_TEXT));
1632 textheight = (infoPtr->dwStyle & CCS_VERT) ? 0 : size.cy;
1634 SelectObject (hdc, hOldFont);
1638 /* if no gripper but either image or text, then leave space */
1639 if ((lpBand->fStatus & (HAS_IMAGE | HAS_TEXT)) &&
1640 !(lpBand->fStatus & HAS_GRIPPER)) {
1641 header += REBAR_ALWAYS_SPACE;
1644 /* check if user overrode the header value */
1645 if (!(lpBand->fStyle & RBBS_UNDOC_FIXEDHEADER))
1646 lpBand->cxHeader = header;
1647 lpBand->cyHeader = max(textheight, imageheight);
1649 /* Now compute minimum size of child window */
1650 update_min_band_height(infoPtr, lpBand); /* update lpBand->cyMinBand from cyHeader and cyChild*/
1652 lpBand->cxMinBand = lpBand->cxMinChild + lpBand->cxHeader + REBAR_POST_CHILD;
1653 if (lpBand->fStyle & RBBS_USECHEVRON && lpBand->cxMinChild < lpBand->cxIdeal)
1654 lpBand->cxMinBand += CHEVRON_WIDTH;
1658 REBAR_CommonSetupBand(HWND hwnd, const REBARBANDINFOW *lprbbi, REBAR_BAND *lpBand)
1659 /* Function: This routine copies the supplied values from */
1660 /* user input (lprbbi) to the internal band structure. */
1661 /* It returns the mask of what changed. */
1663 UINT uChanged = 0x0;
1665 lpBand->fMask |= lprbbi->fMask;
1667 if( (lprbbi->fMask & RBBIM_STYLE) &&
1668 (lpBand->fStyle != lprbbi->fStyle ) )
1670 lpBand->fStyle = lprbbi->fStyle;
1671 uChanged |= RBBIM_STYLE;
1674 if( (lprbbi->fMask & RBBIM_COLORS) &&
1675 ( ( lpBand->clrFore != lprbbi->clrFore ) ||
1676 ( lpBand->clrBack != lprbbi->clrBack ) ) )
1678 lpBand->clrFore = lprbbi->clrFore;
1679 lpBand->clrBack = lprbbi->clrBack;
1680 uChanged |= RBBIM_COLORS;
1683 if( (lprbbi->fMask & RBBIM_IMAGE) &&
1684 ( lpBand->iImage != lprbbi->iImage ) )
1686 lpBand->iImage = lprbbi->iImage;
1687 uChanged |= RBBIM_IMAGE;
1690 if( (lprbbi->fMask & RBBIM_CHILD) &&
1691 (lprbbi->hwndChild != lpBand->hwndChild ) )
1693 if (lprbbi->hwndChild) {
1694 lpBand->hwndChild = lprbbi->hwndChild;
1695 lpBand->hwndPrevParent =
1696 SetParent (lpBand->hwndChild, hwnd);
1697 /* below in trace from WinRAR */
1698 ShowWindow(lpBand->hwndChild, SW_SHOWNOACTIVATE | SW_SHOWNORMAL);
1699 /* above in trace from WinRAR */
1702 TRACE("child: %p prev parent: %p\n",
1703 lpBand->hwndChild, lpBand->hwndPrevParent);
1704 lpBand->hwndChild = 0;
1705 lpBand->hwndPrevParent = 0;
1707 uChanged |= RBBIM_CHILD;
1710 if( (lprbbi->fMask & RBBIM_CHILDSIZE) &&
1711 ( (lpBand->cxMinChild != lprbbi->cxMinChild) ||
1712 (lpBand->cyMinChild != lprbbi->cyMinChild ) ||
1713 ( (lprbbi->cbSize >= REBARBANDINFOA_V6_SIZE && (lpBand->fStyle & RBBS_VARIABLEHEIGHT)) &&
1714 ( (lpBand->cyChild != lprbbi->cyChild ) ||
1715 (lpBand->cyMaxChild != lprbbi->cyMaxChild ) ||
1716 (lpBand->cyIntegral != lprbbi->cyIntegral ) ) ) ||
1717 ( (lprbbi->cbSize < REBARBANDINFOA_V6_SIZE) &&
1718 ( (lpBand->cyChild ||
1719 lpBand->cyMaxChild ||
1720 lpBand->cyIntegral ) ) ) ) )
1722 lpBand->cxMinChild = lprbbi->cxMinChild;
1723 lpBand->cyMinChild = lprbbi->cyMinChild;
1724 /* These fields where added in WIN32_IE == 0x400 and are set only for RBBS_VARIABLEHEIGHT bands */
1725 if (lprbbi->cbSize >= REBARBANDINFOA_V6_SIZE && (lpBand->fStyle & RBBS_VARIABLEHEIGHT)) {
1726 lpBand->cyMaxChild = lprbbi->cyMaxChild;
1727 lpBand->cyIntegral = lprbbi->cyIntegral;
1729 lpBand->cyChild = round_child_height(lpBand, lprbbi->cyChild); /* make (cyChild - cyMinChild) a multiple of cyIntergral */
1732 lpBand->cyChild = lpBand->cyMinChild;
1733 lpBand->cyMaxChild = 0x7fffffff;
1734 lpBand->cyIntegral = 0;
1736 uChanged |= RBBIM_CHILDSIZE;
1739 if( (lprbbi->fMask & RBBIM_SIZE) &&
1740 (lpBand->cx != lprbbi->cx ) )
1742 lpBand->cx = lprbbi->cx;
1743 uChanged |= RBBIM_SIZE;
1746 if( (lprbbi->fMask & RBBIM_BACKGROUND) &&
1747 ( lpBand->hbmBack != lprbbi->hbmBack ) )
1749 lpBand->hbmBack = lprbbi->hbmBack;
1750 uChanged |= RBBIM_BACKGROUND;
1753 if( (lprbbi->fMask & RBBIM_ID) &&
1754 (lpBand->wID != lprbbi->wID ) )
1756 lpBand->wID = lprbbi->wID;
1757 uChanged |= RBBIM_ID;
1760 /* check for additional data */
1761 if (lprbbi->cbSize >= REBARBANDINFOA_V6_SIZE) {
1762 if( (lprbbi->fMask & RBBIM_IDEALSIZE) &&
1763 ( lpBand->cxIdeal != lprbbi->cxIdeal ) )
1765 lpBand->cxIdeal = lprbbi->cxIdeal;
1766 uChanged |= RBBIM_IDEALSIZE;
1769 if( (lprbbi->fMask & RBBIM_LPARAM) &&
1770 (lpBand->lParam != lprbbi->lParam ) )
1772 lpBand->lParam = lprbbi->lParam;
1773 uChanged |= RBBIM_LPARAM;
1776 if( (lprbbi->fMask & RBBIM_HEADERSIZE) &&
1777 (lpBand->cxHeader != lprbbi->cxHeader ) )
1779 lpBand->cxHeader = lprbbi->cxHeader;
1780 lpBand->fStyle |= RBBS_UNDOC_FIXEDHEADER;
1781 uChanged |= RBBIM_HEADERSIZE;
1789 REBAR_InternalEraseBkGnd (const REBAR_INFO *infoPtr, HDC hdc, const RECT *clip)
1790 /* Function: This erases the background rectangle by drawing */
1791 /* each band with its background color (or the default) and */
1792 /* draws each bands right separator if necessary. The row */
1793 /* separators are drawn on the first band of the next row. */
1799 COLORREF old = CLR_NONE, new;
1800 HTHEME theme = GetWindowTheme (infoPtr->hwndSelf);
1802 GetClientRect (infoPtr->hwndSelf, &cr);
1805 for(i=0; i<infoPtr->uNumBands; i++) {
1807 lpBand = REBAR_GetBand(infoPtr, i);
1808 if (HIDDENBAND(lpBand)) continue;
1809 translate_rect(infoPtr, &rcBand, &lpBand->rcBand);
1811 /* draw band separator between rows */
1812 if (lpBand->iRow != oldrow) {
1813 oldrow = lpBand->iRow;
1814 if (infoPtr->dwStyle & RBS_BANDBORDERS) {
1817 if (infoPtr->dwStyle & CCS_VERT) {
1818 rcRowSep.right += SEP_WIDTH_SIZE;
1819 rcRowSep.bottom = infoPtr->calcSize.cx;
1821 DrawThemeEdge (theme, hdc, RP_BAND, 0, &rcRowSep, EDGE_ETCHED, BF_RIGHT, NULL);
1823 DrawEdge (hdc, &rcRowSep, EDGE_ETCHED, BF_RIGHT);
1826 rcRowSep.bottom += SEP_WIDTH_SIZE;
1827 rcRowSep.right = infoPtr->calcSize.cx;
1829 DrawThemeEdge (theme, hdc, RP_BAND, 0, &rcRowSep, EDGE_ETCHED, BF_BOTTOM, NULL);
1831 DrawEdge (hdc, &rcRowSep, EDGE_ETCHED, BF_BOTTOM);
1833 TRACE ("drawing band separator bottom (%s)\n",
1834 wine_dbgstr_rect(&rcRowSep));
1838 /* draw band separator between bands in a row */
1839 if (infoPtr->dwStyle & RBS_BANDBORDERS && lpBand->rcBand.left > 0) {
1842 if (infoPtr->dwStyle & CCS_VERT) {
1843 rcSep.bottom = rcSep.top;
1844 rcSep.top -= SEP_WIDTH_SIZE;
1846 DrawThemeEdge (theme, hdc, RP_BAND, 0, &rcSep, EDGE_ETCHED, BF_BOTTOM, NULL);
1848 DrawEdge (hdc, &rcSep, EDGE_ETCHED, BF_BOTTOM);
1851 rcSep.right = rcSep.left;
1852 rcSep.left -= SEP_WIDTH_SIZE;
1854 DrawThemeEdge (theme, hdc, RP_BAND, 0, &rcSep, EDGE_ETCHED, BF_RIGHT, NULL);
1856 DrawEdge (hdc, &rcSep, EDGE_ETCHED, BF_RIGHT);
1858 TRACE("drawing band separator right (%s)\n",
1859 wine_dbgstr_rect(&rcSep));
1862 /* draw the actual background */
1863 if (lpBand->clrBack != CLR_NONE) {
1864 new = (lpBand->clrBack == CLR_DEFAULT) ? infoPtr->clrBtnFace :
1867 /* testing only - make background green to see it */
1872 /* In the absence of documentation for Rebar vs. CLR_NONE,
1873 * we will use the default BtnFace color. Note documentation
1874 * exists for Listview and Imagelist.
1876 new = infoPtr->clrBtnFace;
1878 /* testing only - make background green to see it */
1885 /* When themed, the background color is ignored (but not a
1886 * background bitmap */
1887 DrawThemeBackground (theme, hdc, 0, 0, &cr, &rcBand);
1891 old = SetBkColor (hdc, new);
1892 TRACE("%s background color=0x%06x, band (%d,%d)-(%d,%d), clip (%d,%d)-(%d,%d)\n",
1893 (lpBand->clrBack == CLR_NONE) ? "none" :
1894 ((lpBand->clrBack == CLR_DEFAULT) ? "dft" : ""),
1896 rcBand.left,rcBand.top,
1897 rcBand.right,rcBand.bottom,
1898 clip->left, clip->top,
1899 clip->right, clip->bottom);
1900 ExtTextOutW (hdc, 0, 0, ETO_OPAQUE, &rcBand, NULL, 0, 0);
1901 if (lpBand->clrBack != CLR_NONE)
1902 SetBkColor (hdc, old);
1909 REBAR_InternalHitTest (const REBAR_INFO *infoPtr, const POINT *lpPt, UINT *pFlags, INT *pBand)
1915 GetClientRect (infoPtr->hwndSelf, &rect);
1917 *pFlags = RBHT_NOWHERE;
1918 if (PtInRect (&rect, *lpPt))
1920 if (infoPtr->uNumBands == 0) {
1921 *pFlags = RBHT_NOWHERE;
1928 /* somewhere inside */
1929 for (iCount = 0; iCount < infoPtr->uNumBands; iCount++) {
1931 lpBand = REBAR_GetBand(infoPtr, iCount);
1932 translate_rect(infoPtr, &rcBand, &lpBand->rcBand);
1933 if (HIDDENBAND(lpBand)) continue;
1934 if (PtInRect (&rcBand, *lpPt)) {
1937 if (PtInRect (&lpBand->rcGripper, *lpPt)) {
1938 *pFlags = RBHT_GRABBER;
1939 TRACE("ON GRABBER %d\n", iCount);
1942 else if (PtInRect (&lpBand->rcCapImage, *lpPt)) {
1943 *pFlags = RBHT_CAPTION;
1944 TRACE("ON CAPTION %d\n", iCount);
1947 else if (PtInRect (&lpBand->rcCapText, *lpPt)) {
1948 *pFlags = RBHT_CAPTION;
1949 TRACE("ON CAPTION %d\n", iCount);
1952 else if (PtInRect (&lpBand->rcChild, *lpPt)) {
1953 *pFlags = RBHT_CLIENT;
1954 TRACE("ON CLIENT %d\n", iCount);
1957 else if (PtInRect (&lpBand->rcChevron, *lpPt)) {
1958 *pFlags = RBHT_CHEVRON;
1959 TRACE("ON CHEVRON %d\n", iCount);
1963 *pFlags = RBHT_NOWHERE;
1964 TRACE("NOWHERE %d\n", iCount);
1970 *pFlags = RBHT_NOWHERE;
1979 *pFlags = RBHT_NOWHERE;
1988 REBAR_HandleLRDrag (REBAR_INFO *infoPtr, const POINT *ptsmove)
1989 /* Function: This will implement the functionality of a */
1990 /* Gripper drag within a row. It will not implement "out- */
1991 /* of-row" drags. (They are detected and handled in */
1992 /* REBAR_MouseMove.) */
1993 /* **** FIXME Switching order of bands in a row not **** */
1994 /* **** yet implemented. **** */
1996 REBAR_BAND *hitBand;
1997 INT iHitBand, iRowBegin, iRowEnd;
1998 INT movement, xBand;
2000 /* on first significant mouse movement, issue notify */
2001 if (!(infoPtr->fStatus & BEGIN_DRAG_ISSUED)) {
2002 if (REBAR_Notify_NMREBAR (infoPtr, -1, RBN_BEGINDRAG)) {
2003 /* Notify returned TRUE - abort drag */
2004 infoPtr->dragStart.x = 0;
2005 infoPtr->dragStart.y = 0;
2006 infoPtr->dragNow = infoPtr->dragStart;
2007 infoPtr->iGrabbedBand = -1;
2011 infoPtr->fStatus |= BEGIN_DRAG_ISSUED;
2014 iHitBand = infoPtr->iGrabbedBand;
2015 iRowBegin = get_row_begin_for_band(infoPtr, iHitBand);
2016 iRowEnd = get_row_end_for_band(infoPtr, iHitBand);
2017 hitBand = REBAR_GetBand(infoPtr, iHitBand);
2019 xBand = hitBand->rcBand.left;
2020 movement = (infoPtr->dwStyle&CCS_VERT ? ptsmove->y : ptsmove->x)
2021 - (xBand + REBAR_PRE_GRIPPER - infoPtr->ihitoffset);
2024 INT cxLeft = REBAR_ShrinkBandsRTL(infoPtr, iRowBegin, iHitBand, -movement, TRUE);
2025 hitBand->cxEffective += -movement - cxLeft;
2026 hitBand->cx = hitBand->cxEffective;
2027 } else if (movement > 0) {
2030 if ((prev = prev_visible(infoPtr, iHitBand)) >= 0) {
2031 INT cxLeft = REBAR_ShrinkBandsLTR(infoPtr, iHitBand, iRowEnd, movement, TRUE);
2032 REBAR_BAND *lpPrev = REBAR_GetBand(infoPtr, prev_visible(infoPtr, iHitBand));
2033 lpPrev->cxEffective += movement - cxLeft;
2034 lpPrev->cx = lpPrev->cxEffective;
2038 REBAR_SetRowRectsX(infoPtr, iRowBegin, iRowEnd);
2039 if (infoPtr->dwStyle & CCS_VERT)
2040 REBAR_CalcVertBand(infoPtr, 0, infoPtr->uNumBands);
2042 REBAR_CalcHorzBand(infoPtr, 0, infoPtr->uNumBands);
2043 REBAR_MoveChildWindows(infoPtr, iRowBegin, iRowEnd);
2048 /* << REBAR_BeginDrag >> */
2052 REBAR_DeleteBand (REBAR_INFO *infoPtr, WPARAM wParam)
2054 UINT uBand = (UINT)wParam;
2057 if (uBand >= infoPtr->uNumBands)
2060 TRACE("deleting band %u!\n", uBand);
2061 lpBand = REBAR_GetBand(infoPtr, uBand);
2062 REBAR_Notify_NMREBAR (infoPtr, uBand, RBN_DELETINGBAND);
2063 /* TODO: a return of 1 should probably cancel the deletion */
2065 if (lpBand->hwndChild)
2066 ShowWindow(lpBand->hwndChild, SW_HIDE);
2067 Free(lpBand->lpText);
2070 infoPtr->uNumBands--;
2071 DPA_DeletePtr(infoPtr->bands, uBand);
2073 REBAR_Notify_NMREBAR (infoPtr, -1, RBN_DELETEDBAND);
2075 /* if only 1 band left the re-validate to possible eliminate gripper */
2076 if (infoPtr->uNumBands == 1)
2077 REBAR_ValidateBand (infoPtr, REBAR_GetBand(infoPtr, 0));
2079 REBAR_Layout(infoPtr);
2085 /* << REBAR_DragMove >> */
2086 /* << REBAR_EndDrag >> */
2090 REBAR_GetBandBorders (const REBAR_INFO *infoPtr, UINT uBand, RECT *lpRect)
2096 if (uBand >= infoPtr->uNumBands)
2099 lpBand = REBAR_GetBand(infoPtr, uBand);
2101 /* FIXME - the following values were determined by experimentation */
2102 /* with the REBAR Control Spy. I have guesses as to what the 4 and */
2103 /* 1 are, but I am not sure. There doesn't seem to be any actual */
2104 /* difference in size of the control area with and without the */
2106 if (infoPtr->dwStyle & RBS_BANDBORDERS) {
2107 if (infoPtr->dwStyle & CCS_VERT) {
2109 lpRect->top = lpBand->cxHeader + 4;
2114 lpRect->left = lpBand->cxHeader + 4;
2121 lpRect->left = lpBand->cxHeader;
2127 static inline LRESULT
2128 REBAR_GetBandCount (const REBAR_INFO *infoPtr)
2130 TRACE("band count %u!\n", infoPtr->uNumBands);
2132 return infoPtr->uNumBands;
2137 REBAR_GetBandInfoT(const REBAR_INFO *infoPtr, UINT uIndex, LPREBARBANDINFOW lprbbi, BOOL bUnicode)
2141 if (!lprbbi || lprbbi->cbSize < REBARBANDINFOA_V3_SIZE)
2144 if (uIndex >= infoPtr->uNumBands)
2147 TRACE("index %u (bUnicode=%d)\n", uIndex, bUnicode);
2149 /* copy band information */
2150 lpBand = REBAR_GetBand(infoPtr, uIndex);
2152 if (lprbbi->fMask & RBBIM_STYLE)
2153 lprbbi->fStyle = lpBand->fStyle;
2155 if (lprbbi->fMask & RBBIM_COLORS) {
2156 lprbbi->clrFore = lpBand->clrFore;
2157 lprbbi->clrBack = lpBand->clrBack;
2158 if (lprbbi->clrBack == CLR_DEFAULT)
2159 lprbbi->clrBack = infoPtr->clrBtnFace;
2162 if (lprbbi->fMask & RBBIM_TEXT) {
2164 Str_GetPtrW(lpBand->lpText, lprbbi->lpText, lprbbi->cch);
2166 Str_GetPtrWtoA(lpBand->lpText, (LPSTR)lprbbi->lpText, lprbbi->cch);
2169 if (lprbbi->fMask & RBBIM_IMAGE)
2170 lprbbi->iImage = lpBand->iImage;
2172 if (lprbbi->fMask & RBBIM_CHILD)
2173 lprbbi->hwndChild = lpBand->hwndChild;
2175 if (lprbbi->fMask & RBBIM_CHILDSIZE) {
2176 lprbbi->cxMinChild = lpBand->cxMinChild;
2177 lprbbi->cyMinChild = lpBand->cyMinChild;
2178 /* to make tests pass we follow Windows behaviour and allow to read these fields only
2179 * for RBBS_VARIABLEHEIGHTS bands */
2180 if (lprbbi->cbSize >= REBARBANDINFOW_V6_SIZE && (lpBand->fStyle & RBBS_VARIABLEHEIGHT)) {
2181 lprbbi->cyChild = lpBand->cyChild;
2182 lprbbi->cyMaxChild = lpBand->cyMaxChild;
2183 lprbbi->cyIntegral = lpBand->cyIntegral;
2187 if (lprbbi->fMask & RBBIM_SIZE)
2188 lprbbi->cx = lpBand->cx;
2190 if (lprbbi->fMask & RBBIM_BACKGROUND)
2191 lprbbi->hbmBack = lpBand->hbmBack;
2193 if (lprbbi->fMask & RBBIM_ID)
2194 lprbbi->wID = lpBand->wID;
2196 /* check for additional data */
2197 if (lprbbi->cbSize >= REBARBANDINFOW_V6_SIZE) {
2198 if (lprbbi->fMask & RBBIM_IDEALSIZE)
2199 lprbbi->cxIdeal = lpBand->cxIdeal;
2201 if (lprbbi->fMask & RBBIM_LPARAM)
2202 lprbbi->lParam = lpBand->lParam;
2204 if (lprbbi->fMask & RBBIM_HEADERSIZE)
2205 lprbbi->cxHeader = lpBand->cxHeader;
2208 REBAR_DumpBandInfo(lprbbi);
2215 REBAR_GetBarHeight (const REBAR_INFO *infoPtr)
2219 nHeight = infoPtr->calcSize.cy;
2221 TRACE("height = %d\n", nHeight);
2228 REBAR_GetBarInfo (const REBAR_INFO *infoPtr, LPREBARINFO lpInfo)
2230 if (!lpInfo || lpInfo->cbSize < sizeof (REBARINFO))
2233 TRACE("getting bar info!\n");
2235 if (infoPtr->himl) {
2236 lpInfo->himl = infoPtr->himl;
2237 lpInfo->fMask |= RBIM_IMAGELIST;
2244 static inline LRESULT
2245 REBAR_GetBkColor (const REBAR_INFO *infoPtr)
2247 COLORREF clr = infoPtr->clrBk;
2249 if (clr == CLR_DEFAULT)
2250 clr = infoPtr->clrBtnFace;
2252 TRACE("background color 0x%06x!\n", clr);
2258 /* << REBAR_GetColorScheme >> */
2259 /* << REBAR_GetDropTarget >> */
2263 REBAR_GetPalette (const REBAR_INFO *infoPtr)
2265 FIXME("empty stub!\n");
2272 REBAR_GetRect (const REBAR_INFO *infoPtr, INT iBand, RECT *lprc)
2276 if (iBand < 0 || iBand >= infoPtr->uNumBands)
2281 lpBand = REBAR_GetBand(infoPtr, iBand);
2282 /* For CCS_VERT the coordinates will be swapped - like on Windows */
2283 CopyRect (lprc, &lpBand->rcBand);
2285 TRACE("band %d, (%s)\n", iBand, wine_dbgstr_rect(lprc));
2291 static inline LRESULT
2292 REBAR_GetRowCount (const REBAR_INFO *infoPtr)
2294 TRACE("%u\n", infoPtr->uNumRows);
2296 return infoPtr->uNumRows;
2301 REBAR_GetRowHeight (const REBAR_INFO *infoPtr, INT iRow)
2307 for (i=0; i<infoPtr->uNumBands; i++) {
2308 lpBand = REBAR_GetBand(infoPtr, i);
2309 if (HIDDENBAND(lpBand)) continue;
2310 if (lpBand->iRow != iRow) continue;
2311 j = lpBand->rcBand.bottom - lpBand->rcBand.top;
2312 if (j > ret) ret = j;
2315 TRACE("row %d, height %d\n", iRow, ret);
2321 static inline LRESULT
2322 REBAR_GetTextColor (const REBAR_INFO *infoPtr)
2324 TRACE("text color 0x%06x!\n", infoPtr->clrText);
2326 return infoPtr->clrText;
2330 static inline LRESULT
2331 REBAR_GetToolTips (const REBAR_INFO *infoPtr)
2333 return (LRESULT)infoPtr->hwndToolTip;
2337 static inline LRESULT
2338 REBAR_GetUnicodeFormat (const REBAR_INFO *infoPtr)
2340 TRACE("%s hwnd=%p\n",
2341 infoPtr->bUnicode ? "TRUE" : "FALSE", infoPtr->hwndSelf);
2343 return infoPtr->bUnicode;
2347 static inline LRESULT
2348 REBAR_GetVersion (const REBAR_INFO *infoPtr)
2350 TRACE("version %d\n", infoPtr->iVersion);
2351 return infoPtr->iVersion;
2356 REBAR_HitTest (const REBAR_INFO *infoPtr, LPRBHITTESTINFO lprbht)
2361 REBAR_InternalHitTest (infoPtr, &lprbht->pt, &lprbht->flags, &lprbht->iBand);
2363 return lprbht->iBand;
2368 REBAR_IdToIndex (const REBAR_INFO *infoPtr, UINT uId)
2372 if (infoPtr->uNumBands < 1)
2375 for (i = 0; i < infoPtr->uNumBands; i++) {
2376 if (REBAR_GetBand(infoPtr, i)->wID == uId) {
2377 TRACE("id %u is band %u found!\n", uId, i);
2382 TRACE("id %u is not found\n", uId);
2388 REBAR_InsertBandT(REBAR_INFO *infoPtr, INT iIndex, LPREBARBANDINFOW lprbbi, BOOL bUnicode)
2392 if (!lprbbi || lprbbi->cbSize < REBARBANDINFOA_V3_SIZE)
2395 /* trace the index as signed to see the -1 */
2396 TRACE("insert band at %d (bUnicode=%d)!\n", iIndex, bUnicode);
2397 REBAR_DumpBandInfo(lprbbi);
2399 if (!(lpBand = Alloc(sizeof(REBAR_BAND)))) return FALSE;
2400 if ((iIndex == -1) || (iIndex > infoPtr->uNumBands))
2401 iIndex = infoPtr->uNumBands;
2402 if (DPA_InsertPtr(infoPtr->bands, iIndex, lpBand) == -1)
2407 infoPtr->uNumBands++;
2409 TRACE("index %d!\n", iIndex);
2411 /* initialize band */
2412 memset(lpBand, 0, sizeof(*lpBand));
2413 lpBand->clrFore = infoPtr->clrText == CLR_NONE ? infoPtr->clrBtnText :
2415 lpBand->clrBack = infoPtr->clrBk == CLR_NONE ? infoPtr->clrBtnFace :
2417 lpBand->iImage = -1;
2419 REBAR_CommonSetupBand(infoPtr->hwndSelf, lprbbi, lpBand);
2421 /* Make sure the defaults for these are correct */
2422 if (lprbbi->cbSize < REBARBANDINFOA_V6_SIZE || !(lpBand->fStyle & RBBS_VARIABLEHEIGHT)) {
2423 lpBand->cyChild = lpBand->cyMinChild;
2424 lpBand->cyMaxChild = 0x7fffffff;
2425 lpBand->cyIntegral = 0;
2428 if ((lprbbi->fMask & RBBIM_TEXT) && (lprbbi->lpText)) {
2430 Str_SetPtrW(&lpBand->lpText, lprbbi->lpText);
2432 Str_SetPtrAtoW(&lpBand->lpText, (LPSTR)lprbbi->lpText);
2435 REBAR_ValidateBand (infoPtr, lpBand);
2436 /* On insert of second band, revalidate band 1 to possible add gripper */
2437 if (infoPtr->uNumBands == 2)
2438 REBAR_ValidateBand (infoPtr, REBAR_GetBand(infoPtr, 0));
2440 REBAR_DumpBand (infoPtr);
2442 REBAR_Layout(infoPtr);
2443 InvalidateRect(infoPtr->hwndSelf, 0, TRUE);
2450 REBAR_MaximizeBand (const REBAR_INFO *infoPtr, INT iBand, LPARAM lParam)
2453 int iRowBegin, iRowEnd;
2454 int cxDesired, extra, extraOrig;
2458 if (infoPtr->uNumBands == 0 || iBand < 0 || iBand >= infoPtr->uNumBands) {
2460 ERR("Illegal MaximizeBand, requested=%d, current band count=%d\n",
2461 iBand, infoPtr->uNumBands);
2465 lpBand = REBAR_GetBand(infoPtr, iBand);
2467 if (lpBand->fStyle & RBBS_HIDDEN)
2469 /* Windows is buggy and creates a hole */
2470 WARN("Ignoring maximize request on a hidden band (%d)\n", iBand);
2474 cxIdealBand = lpBand->cxIdeal + lpBand->cxHeader + REBAR_POST_CHILD;
2475 if (lParam && (lpBand->cxEffective < cxIdealBand))
2476 cxDesired = cxIdealBand;
2478 cxDesired = infoPtr->calcSize.cx;
2480 iRowBegin = get_row_begin_for_band(infoPtr, iBand);
2481 iRowEnd = get_row_end_for_band(infoPtr, iBand);
2482 extraOrig = extra = cxDesired - lpBand->cxEffective;
2484 extra = REBAR_ShrinkBandsRTL(infoPtr, iRowBegin, iBand, extra, TRUE);
2486 extra = REBAR_ShrinkBandsLTR(infoPtr, next_visible(infoPtr, iBand), iRowEnd, extra, TRUE);
2487 lpBand->cxEffective += extraOrig - extra;
2488 lpBand->cx = lpBand->cxEffective;
2489 TRACE("(%d, %ld): Wanted size %d, obtained %d (shrink %d, %d)\n", iBand, lParam, cxDesired, lpBand->cx, extraOrig, extra);
2490 REBAR_SetRowRectsX(infoPtr, iRowBegin, iRowEnd);
2492 if (infoPtr->dwStyle & CCS_VERT)
2493 REBAR_CalcVertBand(infoPtr, iRowBegin, iRowEnd);
2495 REBAR_CalcHorzBand(infoPtr, iRowBegin, iRowEnd);
2496 REBAR_MoveChildWindows(infoPtr, iRowBegin, iRowEnd);
2503 REBAR_MinimizeBand (const REBAR_INFO *infoPtr, INT iBand)
2506 int iPrev, iRowBegin, iRowEnd;
2508 /* A "minimize" band is equivalent to "dragging" the gripper
2509 * of than band to the right till the band is only the size
2514 if (infoPtr->uNumBands == 0 || iBand < 0 || iBand >= infoPtr->uNumBands) {
2516 ERR("Illegal MinimizeBand, requested=%d, current band count=%d\n",
2517 iBand, infoPtr->uNumBands);
2521 /* compute amount of movement and validate */
2522 lpBand = REBAR_GetBand(infoPtr, iBand);
2524 if (lpBand->fStyle & RBBS_HIDDEN)
2526 /* Windows is buggy and creates a hole/overlap */
2527 WARN("Ignoring minimize request on a hidden band (%d)\n", iBand);
2531 iPrev = prev_visible(infoPtr, iBand);
2532 /* if first band in row */
2533 if (iPrev < 0 || REBAR_GetBand(infoPtr, iPrev)->iRow != lpBand->iRow) {
2534 int iNext = next_visible(infoPtr, iBand);
2535 if (iNext < infoPtr->uNumBands && REBAR_GetBand(infoPtr, iNext)->iRow == lpBand->iRow) {
2536 TRACE("(%d): Minimizing the first band in row is by maximizing the second\n", iBand);
2537 REBAR_MaximizeBand(infoPtr, iNext, FALSE);
2540 TRACE("(%d): Only one band in row - nothing to do\n", iBand);
2544 REBAR_GetBand(infoPtr, iPrev)->cxEffective += lpBand->cxEffective - lpBand->cxMinBand;
2545 REBAR_GetBand(infoPtr, iPrev)->cx = REBAR_GetBand(infoPtr, iPrev)->cxEffective;
2546 lpBand->cx = lpBand->cxEffective = lpBand->cxMinBand;
2548 iRowBegin = get_row_begin_for_band(infoPtr, iBand);
2549 iRowEnd = get_row_end_for_band(infoPtr, iBand);
2550 REBAR_SetRowRectsX(infoPtr, iRowBegin, iRowEnd);
2552 if (infoPtr->dwStyle & CCS_VERT)
2553 REBAR_CalcVertBand(infoPtr, iRowBegin, iRowEnd);
2555 REBAR_CalcHorzBand(infoPtr, iRowBegin, iRowEnd);
2556 REBAR_MoveChildWindows(infoPtr, iRowBegin, iRowEnd);
2562 REBAR_MoveBand (REBAR_INFO *infoPtr, INT iFrom, INT iTo)
2567 if ((infoPtr->uNumBands == 0) ||
2568 (iFrom < 0) || iFrom >= infoPtr->uNumBands ||
2569 (iTo < 0) || iTo >= infoPtr->uNumBands) {
2571 ERR("Illegal MoveBand, from=%d, to=%d, current band count=%d\n",
2572 iFrom, iTo, infoPtr->uNumBands);
2576 lpBand = REBAR_GetBand(infoPtr, iFrom);
2577 DPA_DeletePtr(infoPtr->bands, iFrom);
2578 DPA_InsertPtr(infoPtr->bands, iTo, lpBand);
2580 TRACE("moved band %d to index %d\n", iFrom, iTo);
2581 REBAR_DumpBand (infoPtr);
2583 /* **************************************************** */
2585 /* We do not do a REBAR_Layout here because the native */
2586 /* control does not do that. The actual layout and */
2587 /* repaint is done by the *next* real action, ex.: */
2588 /* RB_INSERTBAND, RB_DELETEBAND, RB_SIZETORECT, etc. */
2590 /* **************************************************** */
2596 /* return TRUE if two strings are different */
2598 REBAR_strdifW( LPCWSTR a, LPCWSTR b )
2600 return ( (a && !b) || (b && !a) || (a && b && lstrcmpW(a, b) ) );
2604 REBAR_SetBandInfoT(REBAR_INFO *infoPtr, INT iBand, LPREBARBANDINFOW lprbbi, BOOL bUnicode)
2609 if (!lprbbi || lprbbi->cbSize < REBARBANDINFOA_V3_SIZE)
2612 if (iBand >= infoPtr->uNumBands)
2615 TRACE("index %d\n", iBand);
2616 REBAR_DumpBandInfo (lprbbi);
2618 /* set band information */
2619 lpBand = REBAR_GetBand(infoPtr, iBand);
2621 uChanged = REBAR_CommonSetupBand (infoPtr->hwndSelf, lprbbi, lpBand);
2622 if (lprbbi->fMask & RBBIM_TEXT) {
2625 Str_SetPtrW(&wstr, lprbbi->lpText);
2627 Str_SetPtrAtoW(&wstr, (LPSTR)lprbbi->lpText);
2629 if (REBAR_strdifW(wstr, lpBand->lpText)) {
2630 Free(lpBand->lpText);
2631 lpBand->lpText = wstr;
2632 uChanged |= RBBIM_TEXT;
2638 REBAR_ValidateBand (infoPtr, lpBand);
2640 REBAR_DumpBand (infoPtr);
2642 if (uChanged & (RBBIM_CHILDSIZE | RBBIM_SIZE | RBBIM_STYLE | RBBIM_IMAGE)) {
2643 REBAR_Layout(infoPtr);
2644 InvalidateRect(infoPtr->hwndSelf, 0, 1);
2652 REBAR_SetBarInfo (REBAR_INFO *infoPtr, LPREBARINFO lpInfo)
2657 if (!lpInfo || lpInfo->cbSize < sizeof (REBARINFO))
2660 TRACE("setting bar info!\n");
2662 if (lpInfo->fMask & RBIM_IMAGELIST) {
2663 infoPtr->himl = lpInfo->himl;
2664 if (infoPtr->himl) {
2666 ImageList_GetIconSize (infoPtr->himl, &cx, &cy);
2667 infoPtr->imageSize.cx = cx;
2668 infoPtr->imageSize.cy = cy;
2671 infoPtr->imageSize.cx = 0;
2672 infoPtr->imageSize.cy = 0;
2674 TRACE("new image cx=%d, cy=%d\n", infoPtr->imageSize.cx,
2675 infoPtr->imageSize.cy);
2678 /* revalidate all bands to reset flags for images in headers of bands */
2679 for (i=0; i<infoPtr->uNumBands; i++) {
2680 lpBand = REBAR_GetBand(infoPtr, i);
2681 REBAR_ValidateBand (infoPtr, lpBand);
2689 REBAR_SetBkColor (REBAR_INFO *infoPtr, COLORREF clr)
2693 clrTemp = infoPtr->clrBk;
2694 infoPtr->clrBk = clr;
2696 TRACE("background color 0x%06x!\n", infoPtr->clrBk);
2702 /* << REBAR_SetColorScheme >> */
2703 /* << REBAR_SetPalette >> */
2707 REBAR_SetParent (REBAR_INFO *infoPtr, HWND parent)
2709 HWND hwndTemp = infoPtr->hwndNotify;
2711 infoPtr->hwndNotify = parent;
2713 return (LRESULT)hwndTemp;
2718 REBAR_SetTextColor (REBAR_INFO *infoPtr, COLORREF clr)
2722 clrTemp = infoPtr->clrText;
2723 infoPtr->clrText = clr;
2725 TRACE("text color 0x%06x!\n", infoPtr->clrText);
2731 /* << REBAR_SetTooltips >> */
2734 static inline LRESULT
2735 REBAR_SetUnicodeFormat (REBAR_INFO *infoPtr, BOOL unicode)
2737 BOOL bTemp = infoPtr->bUnicode;
2739 TRACE("to %s hwnd=%p, was %s\n",
2740 unicode ? "TRUE" : "FALSE", infoPtr->hwndSelf,
2741 (bTemp) ? "TRUE" : "FALSE");
2743 infoPtr->bUnicode = unicode;
2750 REBAR_SetVersion (REBAR_INFO *infoPtr, INT iVersion)
2752 INT iOldVersion = infoPtr->iVersion;
2754 if (iVersion > COMCTL32_VERSION)
2757 infoPtr->iVersion = iVersion;
2759 TRACE("new version %d\n", iVersion);
2766 REBAR_ShowBand (REBAR_INFO *infoPtr, INT iBand, BOOL show)
2770 if (iBand < 0 || iBand > infoPtr->uNumBands)
2773 lpBand = REBAR_GetBand(infoPtr, iBand);
2776 TRACE("show band %d\n", iBand);
2777 lpBand->fStyle = lpBand->fStyle & ~RBBS_HIDDEN;
2778 if (IsWindow (lpBand->hwndChild))
2779 ShowWindow (lpBand->hwndChild, SW_SHOW);
2782 TRACE("hide band %d\n", iBand);
2783 lpBand->fStyle = lpBand->fStyle | RBBS_HIDDEN;
2784 if (IsWindow (lpBand->hwndChild))
2785 ShowWindow (lpBand->hwndChild, SW_HIDE);
2788 REBAR_Layout(infoPtr);
2789 InvalidateRect(infoPtr->hwndSelf, 0, 1);
2796 REBAR_SizeToRect (REBAR_INFO *infoPtr, const RECT *lpRect)
2798 if (!lpRect) return FALSE;
2800 TRACE("[%s]\n", wine_dbgstr_rect(lpRect));
2801 REBAR_SizeToHeight(infoPtr, get_rect_cy(infoPtr, lpRect));
2808 REBAR_Create (REBAR_INFO *infoPtr, LPCREATESTRUCTW cs)
2812 if (TRACE_ON(rebar)) {
2813 GetWindowRect(infoPtr->hwndSelf, &wnrc1);
2814 GetClientRect(infoPtr->hwndSelf, &clrc1);
2815 TRACE("window=(%s) client=(%s) cs=(%d,%d %dx%d)\n",
2816 wine_dbgstr_rect(&wnrc1), wine_dbgstr_rect(&clrc1),
2817 cs->x, cs->y, cs->cx, cs->cy);
2820 TRACE("created!\n");
2822 if (OpenThemeData (infoPtr->hwndSelf, themeClass))
2824 /* native seems to clear WS_BORDER when themed */
2825 infoPtr->dwStyle &= ~WS_BORDER;
2833 REBAR_Destroy (REBAR_INFO *infoPtr)
2838 /* clean up each band */
2839 for (i = 0; i < infoPtr->uNumBands; i++) {
2840 lpBand = REBAR_GetBand(infoPtr, i);
2842 /* delete text strings */
2843 Free (lpBand->lpText);
2844 lpBand->lpText = NULL;
2845 /* destroy child window */
2846 DestroyWindow (lpBand->hwndChild);
2850 /* free band array */
2851 DPA_Destroy (infoPtr->bands);
2852 infoPtr->bands = NULL;
2854 DestroyCursor (infoPtr->hcurArrow);
2855 DestroyCursor (infoPtr->hcurHorz);
2856 DestroyCursor (infoPtr->hcurVert);
2857 DestroyCursor (infoPtr->hcurDrag);
2858 if (infoPtr->hDefaultFont) DeleteObject (infoPtr->hDefaultFont);
2859 SetWindowLongPtrW (infoPtr->hwndSelf, 0, 0);
2861 CloseThemeData (GetWindowTheme (infoPtr->hwndSelf));
2863 /* free rebar info data */
2865 TRACE("destroyed!\n");
2871 REBAR_EraseBkGnd (const REBAR_INFO *infoPtr, HDC hdc)
2875 if (GetClipBox ( hdc, &cliprect))
2876 return REBAR_InternalEraseBkGnd (infoPtr, hdc, &cliprect);
2882 REBAR_GetFont (const REBAR_INFO *infoPtr)
2884 return (LRESULT)infoPtr->hFont;
2888 REBAR_PushChevron(const REBAR_INFO *infoPtr, UINT uBand, LPARAM lParam)
2890 if (uBand < infoPtr->uNumBands)
2892 NMREBARCHEVRON nmrbc;
2893 REBAR_BAND *lpBand = REBAR_GetBand(infoPtr, uBand);
2895 TRACE("Pressed chevron on band %u\n", uBand);
2897 /* redraw chevron in pushed state */
2898 lpBand->fDraw |= DRAW_CHEVRONPUSHED;
2899 RedrawWindow(infoPtr->hwndSelf, &lpBand->rcChevron,0,
2900 RDW_ERASE|RDW_INVALIDATE|RDW_UPDATENOW);
2902 /* notify app so it can display a popup menu or whatever */
2903 nmrbc.uBand = uBand;
2904 nmrbc.wID = lpBand->wID;
2905 nmrbc.lParam = lpBand->lParam;
2906 nmrbc.rc = lpBand->rcChevron;
2907 nmrbc.lParamNM = lParam;
2908 REBAR_Notify((NMHDR*)&nmrbc, infoPtr, RBN_CHEVRONPUSHED);
2910 /* redraw chevron in previous state */
2911 lpBand->fDraw &= ~DRAW_CHEVRONPUSHED;
2912 InvalidateRect(infoPtr->hwndSelf, &lpBand->rcChevron, TRUE);
2920 REBAR_LButtonDown (REBAR_INFO *infoPtr, LPARAM lParam)
2926 ptMouseDown.x = (short)LOWORD(lParam);
2927 ptMouseDown.y = (short)HIWORD(lParam);
2929 REBAR_InternalHitTest(infoPtr, &ptMouseDown, &htFlags, &iHitBand);
2930 lpBand = REBAR_GetBand(infoPtr, iHitBand);
2932 if (htFlags == RBHT_CHEVRON)
2934 REBAR_PushChevron(infoPtr, iHitBand, 0);
2936 else if (htFlags == RBHT_GRABBER || htFlags == RBHT_CAPTION)
2938 TRACE("Starting drag\n");
2940 SetCapture (infoPtr->hwndSelf);
2941 infoPtr->iGrabbedBand = iHitBand;
2943 /* save off the LOWORD and HIWORD of lParam as initial x,y */
2944 infoPtr->dragStart.x = (short)LOWORD(lParam);
2945 infoPtr->dragStart.y = (short)HIWORD(lParam);
2946 infoPtr->dragNow = infoPtr->dragStart;
2947 if (infoPtr->dwStyle & CCS_VERT)
2948 infoPtr->ihitoffset = infoPtr->dragStart.y - (lpBand->rcBand.left + REBAR_PRE_GRIPPER);
2950 infoPtr->ihitoffset = infoPtr->dragStart.x - (lpBand->rcBand.left + REBAR_PRE_GRIPPER);
2956 REBAR_LButtonUp (REBAR_INFO *infoPtr)
2958 if (infoPtr->iGrabbedBand >= 0)
2963 infoPtr->dragStart.x = 0;
2964 infoPtr->dragStart.y = 0;
2965 infoPtr->dragNow = infoPtr->dragStart;
2969 if (infoPtr->fStatus & BEGIN_DRAG_ISSUED) {
2970 REBAR_Notify(&layout, infoPtr, RBN_LAYOUTCHANGED);
2971 REBAR_Notify_NMREBAR (infoPtr, infoPtr->iGrabbedBand, RBN_ENDDRAG);
2972 infoPtr->fStatus &= ~BEGIN_DRAG_ISSUED;
2975 infoPtr->iGrabbedBand = -1;
2977 GetClientRect(infoPtr->hwndSelf, &rect);
2978 InvalidateRect(infoPtr->hwndSelf, NULL, TRUE);
2985 REBAR_MouseLeave (REBAR_INFO *infoPtr)
2987 if (infoPtr->ichevronhotBand >= 0)
2989 REBAR_BAND *lpChevronBand = REBAR_GetBand(infoPtr, infoPtr->ichevronhotBand);
2990 if (lpChevronBand->fDraw & DRAW_CHEVRONHOT)
2992 lpChevronBand->fDraw &= ~DRAW_CHEVRONHOT;
2993 InvalidateRect(infoPtr->hwndSelf, &lpChevronBand->rcChevron, TRUE);
2996 infoPtr->iOldBand = -1;
2997 infoPtr->ichevronhotBand = -2;
3003 REBAR_MouseMove (REBAR_INFO *infoPtr, LPARAM lParam)
3005 REBAR_BAND *lpChevronBand;
3008 ptMove.x = (short)LOWORD(lParam);
3009 ptMove.y = (short)HIWORD(lParam);
3011 /* if we are currently dragging a band */
3012 if (infoPtr->iGrabbedBand >= 0)
3014 REBAR_BAND *band1 = NULL, *band2;
3015 int yPtMove = (infoPtr->dwStyle & CCS_VERT ? ptMove.x : ptMove.y);
3017 if (GetCapture() != infoPtr->hwndSelf)
3018 ERR("We are dragging but haven't got capture?!?\n");
3020 if (infoPtr->iGrabbedBand > 0)
3021 band1 = REBAR_GetBand(infoPtr, infoPtr->iGrabbedBand - 1);
3022 band2 = REBAR_GetBand(infoPtr, infoPtr->iGrabbedBand);
3024 /* if mouse did not move much, exit */
3025 if ((abs(ptMove.x - infoPtr->dragNow.x) <= mindragx) &&
3026 (abs(ptMove.y - infoPtr->dragNow.y) <= mindragy)) return 0;
3028 /* Test for valid drag case - must not be first band in row */
3029 if ((yPtMove < band2->rcBand.top) ||
3030 (yPtMove > band2->rcBand.bottom) ||
3031 ((infoPtr->iGrabbedBand > 0) && (band1->iRow != band2->iRow))) {
3032 FIXME("Cannot drag to other rows yet!!\n");
3035 REBAR_HandleLRDrag (infoPtr, &ptMove);
3042 TRACKMOUSEEVENT trackinfo;
3044 REBAR_InternalHitTest(infoPtr, &ptMove, &htFlags, &iHitBand);
3046 if (infoPtr->iOldBand >= 0 && infoPtr->iOldBand == infoPtr->ichevronhotBand)
3048 lpChevronBand = REBAR_GetBand(infoPtr, infoPtr->ichevronhotBand);
3049 if (lpChevronBand->fDraw & DRAW_CHEVRONHOT)
3051 lpChevronBand->fDraw &= ~DRAW_CHEVRONHOT;
3052 InvalidateRect(infoPtr->hwndSelf, &lpChevronBand->rcChevron, TRUE);
3054 infoPtr->ichevronhotBand = -2;
3057 if (htFlags == RBHT_CHEVRON)
3059 /* fill in the TRACKMOUSEEVENT struct */
3060 trackinfo.cbSize = sizeof(TRACKMOUSEEVENT);
3061 trackinfo.dwFlags = TME_QUERY;
3062 trackinfo.hwndTrack = infoPtr->hwndSelf;
3063 trackinfo.dwHoverTime = 0;
3065 /* call _TrackMouseEvent to see if we are currently tracking for this hwnd */
3066 _TrackMouseEvent(&trackinfo);
3068 /* Make sure tracking is enabled so we receive a WM_MOUSELEAVE message */
3069 if(!(trackinfo.dwFlags & TME_LEAVE))
3071 trackinfo.dwFlags = TME_LEAVE; /* notify upon leaving */
3073 /* call TRACKMOUSEEVENT so we receive a WM_MOUSELEAVE message */
3074 /* and can properly deactivate the hot chevron */
3075 _TrackMouseEvent(&trackinfo);
3078 lpChevronBand = REBAR_GetBand(infoPtr, iHitBand);
3079 if (!(lpChevronBand->fDraw & DRAW_CHEVRONHOT))
3081 lpChevronBand->fDraw |= DRAW_CHEVRONHOT;
3082 InvalidateRect(infoPtr->hwndSelf, &lpChevronBand->rcChevron, TRUE);
3083 infoPtr->ichevronhotBand = iHitBand;
3086 infoPtr->iOldBand = iHitBand;
3093 static inline LRESULT
3094 REBAR_NCCalcSize (const REBAR_INFO *infoPtr, RECT *rect)
3098 if (infoPtr->dwStyle & WS_BORDER) {
3099 rect->left = min(rect->left + GetSystemMetrics(SM_CXEDGE), rect->right);
3100 rect->right = max(rect->right - GetSystemMetrics(SM_CXEDGE), rect->left);
3101 rect->top = min(rect->top + GetSystemMetrics(SM_CYEDGE), rect->bottom);
3102 rect->bottom = max(rect->bottom - GetSystemMetrics(SM_CYEDGE), rect->top);
3104 else if ((theme = GetWindowTheme (infoPtr->hwndSelf)))
3106 /* FIXME: should use GetThemeInt */
3107 rect->top = min(rect->top + 1, rect->bottom);
3109 TRACE("new client=(%s)\n", wine_dbgstr_rect(rect));
3115 REBAR_NCCreate (HWND hwnd, LPCREATESTRUCTW cs)
3117 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
3119 NONCLIENTMETRICSW ncm;
3123 ERR("Strange info structure pointer *not* NULL\n");
3127 if (TRACE_ON(rebar)) {
3128 GetWindowRect(hwnd, &wnrc1);
3129 GetClientRect(hwnd, &clrc1);
3130 TRACE("window=(%s) client=(%s) cs=(%d,%d %dx%d)\n",
3131 wine_dbgstr_rect(&wnrc1), wine_dbgstr_rect(&clrc1),
3132 cs->x, cs->y, cs->cx, cs->cy);
3135 /* allocate memory for info structure */
3136 infoPtr = Alloc (sizeof(REBAR_INFO));
3137 SetWindowLongPtrW (hwnd, 0, (DWORD_PTR)infoPtr);
3139 /* initialize info structure - initial values are 0 */
3140 infoPtr->clrBk = CLR_NONE;
3141 infoPtr->clrText = CLR_NONE;
3142 infoPtr->clrBtnText = comctl32_color.clrBtnText;
3143 infoPtr->clrBtnFace = comctl32_color.clrBtnFace;
3144 infoPtr->iOldBand = -1;
3145 infoPtr->ichevronhotBand = -2;
3146 infoPtr->iGrabbedBand = -1;
3147 infoPtr->hwndSelf = hwnd;
3148 infoPtr->DoRedraw = TRUE;
3149 infoPtr->hcurArrow = LoadCursorW (0, (LPWSTR)IDC_ARROW);
3150 infoPtr->hcurHorz = LoadCursorW (0, (LPWSTR)IDC_SIZEWE);
3151 infoPtr->hcurVert = LoadCursorW (0, (LPWSTR)IDC_SIZENS);
3152 infoPtr->hcurDrag = LoadCursorW (0, (LPWSTR)IDC_SIZE);
3153 infoPtr->fStatus = 0;
3154 infoPtr->hFont = GetStockObject (SYSTEM_FONT);
3155 infoPtr->bands = DPA_Create(8);
3157 /* issue WM_NOTIFYFORMAT to get unicode status of parent */
3158 REBAR_NotifyFormat(infoPtr, NF_REQUERY);
3160 /* Stow away the original style */
3161 infoPtr->orgStyle = cs->style;
3162 /* add necessary styles to the requested styles */
3163 infoPtr->dwStyle = cs->style | WS_VISIBLE;
3164 if ((infoPtr->dwStyle & CCS_LAYOUT_MASK) == 0)
3165 infoPtr->dwStyle |= CCS_TOP;
3166 SetWindowLongW (hwnd, GWL_STYLE, infoPtr->dwStyle);
3168 /* get font handle for Caption Font */
3169 ncm.cbSize = sizeof(ncm);
3170 SystemParametersInfoW (SPI_GETNONCLIENTMETRICS, ncm.cbSize, &ncm, 0);
3171 /* if the font is bold, set to normal */
3172 if (ncm.lfCaptionFont.lfWeight > FW_NORMAL) {
3173 ncm.lfCaptionFont.lfWeight = FW_NORMAL;
3175 tfont = CreateFontIndirectW (&ncm.lfCaptionFont);
3177 infoPtr->hFont = infoPtr->hDefaultFont = tfont;
3181 GetSysColor (numerous);
3182 GetSysColorBrush (numerous) (see WM_SYSCOLORCHANGE);
3183 *GetStockObject (SYSTEM_FONT);
3184 *SetWindowLong (hwnd, 0, info ptr);
3186 *SetWindowLong (hwnd, GWL_STYLE, style+0x10000001);
3187 WS_VISIBLE = 0x10000000;
3188 CCS_TOP = 0x00000001;
3189 *SystemParametersInfo (SPI_GETNONCLIENTMETRICS...);
3190 *CreateFontIndirect (lfCaptionFont from above);
3192 SelectObject (hdc, fontabove);
3193 GetTextMetrics (hdc, ); guessing is tmHeight
3194 SelectObject (hdc, oldfont);
3197 MapWindowPoints (0, parent, rectabove, 2);
3200 ClientToScreen (clientrect);
3201 SetWindowPos (hwnd, 0, 0, 0, 0, 0, SWP_NOZORDER);
3208 REBAR_NCHitTest (const REBAR_INFO *infoPtr, LPARAM lParam)
3214 LRESULT ret = HTCLIENT;
3217 * Differences from doc at MSDN (as observed with version 4.71 of
3219 * 1. doc says nmmouse.pt is in screen coord, trace shows client coord.
3220 * 2. if band is not identified .dwItemSpec is 0xffffffff.
3221 * 3. native always seems to return HTCLIENT if notify return is 0.
3224 clpt.x = (short)LOWORD(lParam);
3225 clpt.y = (short)HIWORD(lParam);
3226 ScreenToClient (infoPtr->hwndSelf, &clpt);
3227 REBAR_InternalHitTest (infoPtr, &clpt, &scrap,
3228 (INT *)&nmmouse.dwItemSpec);
3229 nmmouse.dwItemData = 0;
3231 nmmouse.dwHitInfo = 0;
3232 if ((i = REBAR_Notify((NMHDR *) &nmmouse, infoPtr, NM_NCHITTEST))) {
3233 TRACE("notify changed return value from %ld to %d\n",
3237 TRACE("returning %ld, client point (%d,%d)\n", ret, clpt.x, clpt.y);
3243 REBAR_NCPaint (const REBAR_INFO *infoPtr)
3249 if (infoPtr->dwStyle & WS_MINIMIZE)
3250 return 0; /* Nothing to do */
3252 if (infoPtr->dwStyle & WS_BORDER) {
3254 /* adjust rectangle and draw the necessary edge */
3255 if (!(hdc = GetDCEx( infoPtr->hwndSelf, 0, DCX_USESTYLE | DCX_WINDOW )))
3257 GetWindowRect (infoPtr->hwndSelf, &rcWindow);
3258 OffsetRect (&rcWindow, -rcWindow.left, -rcWindow.top);
3259 TRACE("rect (%s)\n", wine_dbgstr_rect(&rcWindow));
3260 DrawEdge (hdc, &rcWindow, EDGE_ETCHED, BF_RECT);
3261 ReleaseDC( infoPtr->hwndSelf, hdc );
3263 else if ((theme = GetWindowTheme (infoPtr->hwndSelf)))
3265 /* adjust rectangle and draw the necessary edge */
3266 if (!(hdc = GetDCEx( infoPtr->hwndSelf, 0, DCX_USESTYLE | DCX_WINDOW )))
3268 GetWindowRect (infoPtr->hwndSelf, &rcWindow);
3269 OffsetRect (&rcWindow, -rcWindow.left, -rcWindow.top);
3270 TRACE("rect (%s)\n", wine_dbgstr_rect(&rcWindow));
3271 DrawThemeEdge (theme, hdc, 0, 0, &rcWindow, BDR_RAISEDINNER, BF_TOP, NULL);
3272 ReleaseDC( infoPtr->hwndSelf, hdc );
3280 REBAR_NotifyFormat (REBAR_INFO *infoPtr, LPARAM cmd)
3284 if (cmd == NF_REQUERY) {
3285 i = SendMessageW(REBAR_GetNotifyParent (infoPtr),
3286 WM_NOTIFYFORMAT, (WPARAM)infoPtr->hwndSelf, NF_QUERY);
3287 if ((i != NFR_ANSI) && (i != NFR_UNICODE)) {
3288 ERR("wrong response to WM_NOTIFYFORMAT (%d), assuming ANSI\n", i);
3291 infoPtr->bUnicode = (i == NFR_UNICODE) ? 1 : 0;
3294 return (LRESULT)((infoPtr->bUnicode) ? NFR_UNICODE : NFR_ANSI);
3299 REBAR_Paint (const REBAR_INFO *infoPtr, HDC hdc)
3302 TRACE("painting\n");
3303 REBAR_Refresh (infoPtr, hdc);
3306 hdc = BeginPaint (infoPtr->hwndSelf, &ps);
3307 TRACE("painting (%s)\n", wine_dbgstr_rect(&ps.rcPaint));
3309 /* Erase area of paint if requested */
3310 REBAR_InternalEraseBkGnd (infoPtr, hdc, &ps.rcPaint);
3312 REBAR_Refresh (infoPtr, hdc);
3313 EndPaint (infoPtr->hwndSelf, &ps);
3321 REBAR_SetCursor (const REBAR_INFO *infoPtr, LPARAM lParam)
3326 TRACE("code=0x%X id=0x%X\n", LOWORD(lParam), HIWORD(lParam));
3329 ScreenToClient (infoPtr->hwndSelf, &pt);
3331 REBAR_InternalHitTest (infoPtr, &pt, &flags, NULL);
3333 if (flags == RBHT_GRABBER) {
3334 if ((infoPtr->dwStyle & CCS_VERT) &&
3335 !(infoPtr->dwStyle & RBS_VERTICALGRIPPER))
3336 SetCursor (infoPtr->hcurVert);
3338 SetCursor (infoPtr->hcurHorz);
3340 else if (flags != RBHT_CLIENT)
3341 SetCursor (infoPtr->hcurArrow);
3348 REBAR_SetFont (REBAR_INFO *infoPtr, HFONT font)
3353 infoPtr->hFont = font;
3355 /* revalidate all bands to change sizes of text in headers of bands */
3356 for (i=0; i<infoPtr->uNumBands; i++) {
3357 lpBand = REBAR_GetBand(infoPtr, i);
3358 REBAR_ValidateBand (infoPtr, lpBand);
3361 REBAR_Layout(infoPtr);
3366 /*****************************************************
3368 * Handles the WM_SETREDRAW message.
3371 * According to testing V4.71 of COMCTL32 returns the
3372 * *previous* status of the redraw flag (either 0 or -1)
3373 * instead of the MSDN documented value of 0 if handled
3375 *****************************************************/
3376 static inline LRESULT
3377 REBAR_SetRedraw (REBAR_INFO *infoPtr, BOOL redraw)
3379 BOOL oldredraw = infoPtr->DoRedraw;
3381 TRACE("set to %s, fStatus=%08x\n",
3382 (redraw) ? "TRUE" : "FALSE", infoPtr->fStatus);
3383 infoPtr->DoRedraw = redraw;
3385 if (infoPtr->fStatus & BAND_NEEDS_REDRAW) {
3386 REBAR_MoveChildWindows (infoPtr, 0, infoPtr->uNumBands);
3387 REBAR_ForceResize (infoPtr);
3388 InvalidateRect (infoPtr->hwndSelf, 0, TRUE);
3390 infoPtr->fStatus &= ~BAND_NEEDS_REDRAW;
3392 return (oldredraw) ? -1 : 0;
3397 REBAR_Size (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3399 TRACE("wParam=%lx, lParam=%lx\n", wParam, lParam);
3401 /* avoid _Layout resize recursion (but it shouldn't be infinite and it seems Windows does recurse) */
3402 if (infoPtr->fStatus & SELF_RESIZE) {
3403 infoPtr->fStatus &= ~SELF_RESIZE;
3404 TRACE("SELF_RESIZE was set, reset, fStatus=%08x lparam=%08lx\n",
3405 infoPtr->fStatus, lParam);
3409 if (infoPtr->dwStyle & RBS_AUTOSIZE)
3410 REBAR_AutoSize(infoPtr, TRUE);
3412 REBAR_Layout(infoPtr);
3419 REBAR_StyleChanged (REBAR_INFO *infoPtr, INT nType, const STYLESTRUCT *lpStyle)
3421 TRACE("current style=%08x, styleOld=%08x, style being set to=%08x\n",
3422 infoPtr->dwStyle, lpStyle->styleOld, lpStyle->styleNew);
3423 if (nType == GWL_STYLE)
3425 infoPtr->orgStyle = infoPtr->dwStyle = lpStyle->styleNew;
3426 if (GetWindowTheme (infoPtr->hwndSelf))
3427 infoPtr->dwStyle &= ~WS_BORDER;
3428 /* maybe it should be COMMON_STYLES like in toolbar */
3429 if ((lpStyle->styleNew ^ lpStyle->styleOld) & CCS_VERT)
3430 REBAR_Layout(infoPtr);
3435 /* update theme after a WM_THEMECHANGED message */
3436 static LRESULT theme_changed (REBAR_INFO* infoPtr)
3438 HTHEME theme = GetWindowTheme (infoPtr->hwndSelf);
3439 CloseThemeData (theme);
3440 theme = OpenThemeData (infoPtr->hwndSelf, themeClass);
3441 /* WS_BORDER disappears when theming is enabled and reappears when
3443 infoPtr->dwStyle &= ~WS_BORDER;
3444 infoPtr->dwStyle |= theme ? 0 : (infoPtr->orgStyle & WS_BORDER);
3449 REBAR_WindowPosChanged (const REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3454 ret = DefWindowProcW(infoPtr->hwndSelf, WM_WINDOWPOSCHANGED,
3456 GetWindowRect(infoPtr->hwndSelf, &rc);
3457 TRACE("hwnd %p new pos (%s)\n", infoPtr->hwndSelf, wine_dbgstr_rect(&rc));
3462 static LRESULT WINAPI
3463 REBAR_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
3465 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
3467 TRACE("hwnd=%p msg=%x wparam=%lx lparam=%lx\n",
3468 hwnd, uMsg, wParam, lParam);
3469 if (!infoPtr && (uMsg != WM_NCCREATE))
3470 return DefWindowProcW (hwnd, uMsg, wParam, lParam);
3473 /* case RB_BEGINDRAG: */
3476 return REBAR_DeleteBand (infoPtr, wParam);
3478 /* case RB_DRAGMOVE: */
3479 /* case RB_ENDDRAG: */
3481 case RB_GETBANDBORDERS:
3482 return REBAR_GetBandBorders (infoPtr, wParam, (LPRECT)lParam);
3484 case RB_GETBANDCOUNT:
3485 return REBAR_GetBandCount (infoPtr);
3487 case RB_GETBANDINFO_OLD:
3488 case RB_GETBANDINFOA:
3489 case RB_GETBANDINFOW:
3490 return REBAR_GetBandInfoT(infoPtr, wParam, (LPREBARBANDINFOW)lParam,
3491 uMsg == RB_GETBANDINFOW);
3492 case RB_GETBARHEIGHT:
3493 return REBAR_GetBarHeight (infoPtr);
3496 return REBAR_GetBarInfo (infoPtr, (LPREBARINFO)lParam);
3499 return REBAR_GetBkColor (infoPtr);
3501 /* case RB_GETCOLORSCHEME: */
3502 /* case RB_GETDROPTARGET: */
3505 return REBAR_GetPalette (infoPtr);
3508 return REBAR_GetRect (infoPtr, wParam, (LPRECT)lParam);
3510 case RB_GETROWCOUNT:
3511 return REBAR_GetRowCount (infoPtr);
3513 case RB_GETROWHEIGHT:
3514 return REBAR_GetRowHeight (infoPtr, wParam);
3516 case RB_GETTEXTCOLOR:
3517 return REBAR_GetTextColor (infoPtr);
3519 case RB_GETTOOLTIPS:
3520 return REBAR_GetToolTips (infoPtr);
3522 case RB_GETUNICODEFORMAT:
3523 return REBAR_GetUnicodeFormat (infoPtr);
3525 case CCM_GETVERSION:
3526 return REBAR_GetVersion (infoPtr);
3529 return REBAR_HitTest (infoPtr, (LPRBHITTESTINFO)lParam);
3532 return REBAR_IdToIndex (infoPtr, wParam);
3534 case RB_INSERTBANDA:
3535 case RB_INSERTBANDW:
3536 return REBAR_InsertBandT(infoPtr, wParam, (LPREBARBANDINFOW)lParam,
3537 uMsg == RB_INSERTBANDW);
3538 case RB_MAXIMIZEBAND:
3539 return REBAR_MaximizeBand (infoPtr, wParam, lParam);
3541 case RB_MINIMIZEBAND:
3542 return REBAR_MinimizeBand (infoPtr, wParam);
3545 return REBAR_MoveBand (infoPtr, wParam, lParam);
3547 case RB_PUSHCHEVRON:
3548 return REBAR_PushChevron (infoPtr, wParam, lParam);
3550 case RB_SETBANDINFOA:
3551 case RB_SETBANDINFOW:
3552 return REBAR_SetBandInfoT(infoPtr, wParam, (LPREBARBANDINFOW)lParam,
3553 uMsg == RB_SETBANDINFOW);
3555 return REBAR_SetBarInfo (infoPtr, (LPREBARINFO)lParam);
3558 return REBAR_SetBkColor (infoPtr, lParam);
3560 /* case RB_SETCOLORSCHEME: */
3561 /* case RB_SETPALETTE: */
3564 return REBAR_SetParent (infoPtr, (HWND)wParam);
3566 case RB_SETTEXTCOLOR:
3567 return REBAR_SetTextColor (infoPtr, lParam);
3569 /* case RB_SETTOOLTIPS: */
3571 case RB_SETUNICODEFORMAT:
3572 return REBAR_SetUnicodeFormat (infoPtr, wParam);
3574 case CCM_SETVERSION:
3575 return REBAR_SetVersion (infoPtr, (INT)wParam);
3578 return REBAR_ShowBand (infoPtr, wParam, lParam);
3581 return REBAR_SizeToRect (infoPtr, (LPCRECT)lParam);
3584 /* Messages passed to parent */
3588 return SendMessageW(REBAR_GetNotifyParent (infoPtr), uMsg, wParam, lParam);
3591 /* case WM_CHARTOITEM: supported according to ControlSpy */
3594 return REBAR_Create (infoPtr, (LPCREATESTRUCTW)lParam);
3597 return REBAR_Destroy (infoPtr);
3600 return REBAR_EraseBkGnd (infoPtr, (HDC)wParam);
3603 return REBAR_GetFont (infoPtr);
3605 /* case WM_LBUTTONDBLCLK: supported according to ControlSpy */
3607 case WM_LBUTTONDOWN:
3608 return REBAR_LButtonDown (infoPtr, lParam);
3611 return REBAR_LButtonUp (infoPtr);
3613 /* case WM_MEASUREITEM: supported according to ControlSpy */
3616 return REBAR_MouseMove (infoPtr, lParam);
3619 return REBAR_MouseLeave (infoPtr);
3622 return REBAR_NCCalcSize (infoPtr, (RECT*)lParam);
3625 return REBAR_NCCreate (hwnd, (LPCREATESTRUCTW)lParam);
3628 return REBAR_NCHitTest (infoPtr, lParam);
3631 return REBAR_NCPaint (infoPtr);
3633 case WM_NOTIFYFORMAT:
3634 return REBAR_NotifyFormat (infoPtr, lParam);
3636 case WM_PRINTCLIENT:
3638 return REBAR_Paint (infoPtr, (HDC)wParam);
3640 /* case WM_PALETTECHANGED: supported according to ControlSpy */
3641 /* case WM_QUERYNEWPALETTE:supported according to ControlSpy */
3642 /* case WM_RBUTTONDOWN: supported according to ControlSpy */
3643 /* case WM_RBUTTONUP: supported according to ControlSpy */
3646 return REBAR_SetCursor (infoPtr, lParam);
3649 return REBAR_SetFont (infoPtr, (HFONT)wParam);
3652 return REBAR_SetRedraw (infoPtr, wParam);
3655 return REBAR_Size (infoPtr, wParam, lParam);
3657 case WM_STYLECHANGED:
3658 return REBAR_StyleChanged (infoPtr, wParam, (LPSTYLESTRUCT)lParam);
3660 case WM_THEMECHANGED:
3661 return theme_changed (infoPtr);
3663 case WM_SYSCOLORCHANGE:
3664 COMCTL32_RefreshSysColors();
3667 /* case WM_VKEYTOITEM: supported according to ControlSpy */
3668 /* case WM_WININICHANGE: */
3670 case WM_WINDOWPOSCHANGED:
3671 return REBAR_WindowPosChanged (infoPtr, wParam, lParam);
3674 if ((uMsg >= WM_USER) && (uMsg < WM_APP) && !COMCTL32_IsReflectedMessage(uMsg))
3675 ERR("unknown msg %04x wp=%08lx lp=%08lx\n",
3676 uMsg, wParam, lParam);
3677 return DefWindowProcW (hwnd, uMsg, wParam, lParam);
3683 REBAR_Register (void)
3687 ZeroMemory (&wndClass, sizeof(WNDCLASSW));
3688 wndClass.style = CS_GLOBALCLASS | CS_DBLCLKS;
3689 wndClass.lpfnWndProc = REBAR_WindowProc;
3690 wndClass.cbClsExtra = 0;
3691 wndClass.cbWndExtra = sizeof(REBAR_INFO *);
3692 wndClass.hCursor = 0;
3693 wndClass.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1);
3695 wndClass.hbrBackground = CreateSolidBrush(RGB(0,128,0));
3697 wndClass.lpszClassName = REBARCLASSNAMEW;
3699 RegisterClassW (&wndClass);
3701 mindragx = GetSystemMetrics (SM_CXDRAG);
3702 mindragy = GetSystemMetrics (SM_CYDRAG);
3708 REBAR_Unregister (void)
3710 UnregisterClassW (REBARCLASSNAMEW, NULL);