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)
2925 ptMouseDown.x = (short)LOWORD(lParam);
2926 ptMouseDown.y = (short)HIWORD(lParam);
2928 REBAR_InternalHitTest(infoPtr, &ptMouseDown, &htFlags, &iHitBand);
2930 if (htFlags == RBHT_CHEVRON)
2932 REBAR_PushChevron(infoPtr, iHitBand, 0);
2934 else if (htFlags == RBHT_GRABBER || htFlags == RBHT_CAPTION)
2938 TRACE("Starting drag\n");
2940 lpBand = REBAR_GetBand(infoPtr, iHitBand);
2942 SetCapture (infoPtr->hwndSelf);
2943 infoPtr->iGrabbedBand = iHitBand;
2945 /* save off the LOWORD and HIWORD of lParam as initial x,y */
2946 infoPtr->dragStart.x = (short)LOWORD(lParam);
2947 infoPtr->dragStart.y = (short)HIWORD(lParam);
2948 infoPtr->dragNow = infoPtr->dragStart;
2949 if (infoPtr->dwStyle & CCS_VERT)
2950 infoPtr->ihitoffset = infoPtr->dragStart.y - (lpBand->rcBand.left + REBAR_PRE_GRIPPER);
2952 infoPtr->ihitoffset = infoPtr->dragStart.x - (lpBand->rcBand.left + REBAR_PRE_GRIPPER);
2958 REBAR_LButtonUp (REBAR_INFO *infoPtr)
2960 if (infoPtr->iGrabbedBand >= 0)
2965 infoPtr->dragStart.x = 0;
2966 infoPtr->dragStart.y = 0;
2967 infoPtr->dragNow = infoPtr->dragStart;
2971 if (infoPtr->fStatus & BEGIN_DRAG_ISSUED) {
2972 REBAR_Notify(&layout, infoPtr, RBN_LAYOUTCHANGED);
2973 REBAR_Notify_NMREBAR (infoPtr, infoPtr->iGrabbedBand, RBN_ENDDRAG);
2974 infoPtr->fStatus &= ~BEGIN_DRAG_ISSUED;
2977 infoPtr->iGrabbedBand = -1;
2979 GetClientRect(infoPtr->hwndSelf, &rect);
2980 InvalidateRect(infoPtr->hwndSelf, NULL, TRUE);
2987 REBAR_MouseLeave (REBAR_INFO *infoPtr)
2989 if (infoPtr->ichevronhotBand >= 0)
2991 REBAR_BAND *lpChevronBand = REBAR_GetBand(infoPtr, infoPtr->ichevronhotBand);
2992 if (lpChevronBand->fDraw & DRAW_CHEVRONHOT)
2994 lpChevronBand->fDraw &= ~DRAW_CHEVRONHOT;
2995 InvalidateRect(infoPtr->hwndSelf, &lpChevronBand->rcChevron, TRUE);
2998 infoPtr->iOldBand = -1;
2999 infoPtr->ichevronhotBand = -2;
3005 REBAR_MouseMove (REBAR_INFO *infoPtr, LPARAM lParam)
3007 REBAR_BAND *lpChevronBand;
3010 ptMove.x = (short)LOWORD(lParam);
3011 ptMove.y = (short)HIWORD(lParam);
3013 /* if we are currently dragging a band */
3014 if (infoPtr->iGrabbedBand >= 0)
3016 REBAR_BAND *band1 = NULL, *band2;
3017 int yPtMove = (infoPtr->dwStyle & CCS_VERT ? ptMove.x : ptMove.y);
3019 if (GetCapture() != infoPtr->hwndSelf)
3020 ERR("We are dragging but haven't got capture?!?\n");
3022 if (infoPtr->iGrabbedBand > 0)
3023 band1 = REBAR_GetBand(infoPtr, infoPtr->iGrabbedBand - 1);
3024 band2 = REBAR_GetBand(infoPtr, infoPtr->iGrabbedBand);
3026 /* if mouse did not move much, exit */
3027 if ((abs(ptMove.x - infoPtr->dragNow.x) <= mindragx) &&
3028 (abs(ptMove.y - infoPtr->dragNow.y) <= mindragy)) return 0;
3030 /* Test for valid drag case - must not be first band in row */
3031 if ((yPtMove < band2->rcBand.top) ||
3032 (yPtMove > band2->rcBand.bottom) ||
3033 ((infoPtr->iGrabbedBand > 0) && (band1->iRow != band2->iRow))) {
3034 FIXME("Cannot drag to other rows yet!!\n");
3037 REBAR_HandleLRDrag (infoPtr, &ptMove);
3044 TRACKMOUSEEVENT trackinfo;
3046 REBAR_InternalHitTest(infoPtr, &ptMove, &htFlags, &iHitBand);
3048 if (infoPtr->iOldBand >= 0 && infoPtr->iOldBand == infoPtr->ichevronhotBand)
3050 lpChevronBand = REBAR_GetBand(infoPtr, infoPtr->ichevronhotBand);
3051 if (lpChevronBand->fDraw & DRAW_CHEVRONHOT)
3053 lpChevronBand->fDraw &= ~DRAW_CHEVRONHOT;
3054 InvalidateRect(infoPtr->hwndSelf, &lpChevronBand->rcChevron, TRUE);
3056 infoPtr->ichevronhotBand = -2;
3059 if (htFlags == RBHT_CHEVRON)
3061 /* fill in the TRACKMOUSEEVENT struct */
3062 trackinfo.cbSize = sizeof(TRACKMOUSEEVENT);
3063 trackinfo.dwFlags = TME_QUERY;
3064 trackinfo.hwndTrack = infoPtr->hwndSelf;
3065 trackinfo.dwHoverTime = 0;
3067 /* call _TrackMouseEvent to see if we are currently tracking for this hwnd */
3068 _TrackMouseEvent(&trackinfo);
3070 /* Make sure tracking is enabled so we receive a WM_MOUSELEAVE message */
3071 if(!(trackinfo.dwFlags & TME_LEAVE))
3073 trackinfo.dwFlags = TME_LEAVE; /* notify upon leaving */
3075 /* call TRACKMOUSEEVENT so we receive a WM_MOUSELEAVE message */
3076 /* and can properly deactivate the hot chevron */
3077 _TrackMouseEvent(&trackinfo);
3080 lpChevronBand = REBAR_GetBand(infoPtr, iHitBand);
3081 if (!(lpChevronBand->fDraw & DRAW_CHEVRONHOT))
3083 lpChevronBand->fDraw |= DRAW_CHEVRONHOT;
3084 InvalidateRect(infoPtr->hwndSelf, &lpChevronBand->rcChevron, TRUE);
3085 infoPtr->ichevronhotBand = iHitBand;
3088 infoPtr->iOldBand = iHitBand;
3095 static inline LRESULT
3096 REBAR_NCCalcSize (const REBAR_INFO *infoPtr, RECT *rect)
3100 if (infoPtr->dwStyle & WS_BORDER) {
3101 rect->left = min(rect->left + GetSystemMetrics(SM_CXEDGE), rect->right);
3102 rect->right = max(rect->right - GetSystemMetrics(SM_CXEDGE), rect->left);
3103 rect->top = min(rect->top + GetSystemMetrics(SM_CYEDGE), rect->bottom);
3104 rect->bottom = max(rect->bottom - GetSystemMetrics(SM_CYEDGE), rect->top);
3106 else if ((theme = GetWindowTheme (infoPtr->hwndSelf)))
3108 /* FIXME: should use GetThemeInt */
3109 rect->top = min(rect->top + 1, rect->bottom);
3111 TRACE("new client=(%s)\n", wine_dbgstr_rect(rect));
3117 REBAR_NCCreate (HWND hwnd, LPCREATESTRUCTW cs)
3119 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
3121 NONCLIENTMETRICSW ncm;
3125 ERR("Strange info structure pointer *not* NULL\n");
3129 if (TRACE_ON(rebar)) {
3130 GetWindowRect(hwnd, &wnrc1);
3131 GetClientRect(hwnd, &clrc1);
3132 TRACE("window=(%s) client=(%s) cs=(%d,%d %dx%d)\n",
3133 wine_dbgstr_rect(&wnrc1), wine_dbgstr_rect(&clrc1),
3134 cs->x, cs->y, cs->cx, cs->cy);
3137 /* allocate memory for info structure */
3138 infoPtr = Alloc (sizeof(REBAR_INFO));
3139 SetWindowLongPtrW (hwnd, 0, (DWORD_PTR)infoPtr);
3141 /* initialize info structure - initial values are 0 */
3142 infoPtr->clrBk = CLR_NONE;
3143 infoPtr->clrText = CLR_NONE;
3144 infoPtr->clrBtnText = comctl32_color.clrBtnText;
3145 infoPtr->clrBtnFace = comctl32_color.clrBtnFace;
3146 infoPtr->iOldBand = -1;
3147 infoPtr->ichevronhotBand = -2;
3148 infoPtr->iGrabbedBand = -1;
3149 infoPtr->hwndSelf = hwnd;
3150 infoPtr->DoRedraw = TRUE;
3151 infoPtr->hcurArrow = LoadCursorW (0, (LPWSTR)IDC_ARROW);
3152 infoPtr->hcurHorz = LoadCursorW (0, (LPWSTR)IDC_SIZEWE);
3153 infoPtr->hcurVert = LoadCursorW (0, (LPWSTR)IDC_SIZENS);
3154 infoPtr->hcurDrag = LoadCursorW (0, (LPWSTR)IDC_SIZE);
3155 infoPtr->fStatus = 0;
3156 infoPtr->hFont = GetStockObject (SYSTEM_FONT);
3157 infoPtr->bands = DPA_Create(8);
3159 /* issue WM_NOTIFYFORMAT to get unicode status of parent */
3160 REBAR_NotifyFormat(infoPtr, NF_REQUERY);
3162 /* Stow away the original style */
3163 infoPtr->orgStyle = cs->style;
3164 /* add necessary styles to the requested styles */
3165 infoPtr->dwStyle = cs->style | WS_VISIBLE;
3166 if ((infoPtr->dwStyle & CCS_LAYOUT_MASK) == 0)
3167 infoPtr->dwStyle |= CCS_TOP;
3168 SetWindowLongW (hwnd, GWL_STYLE, infoPtr->dwStyle);
3170 /* get font handle for Caption Font */
3171 ncm.cbSize = sizeof(ncm);
3172 SystemParametersInfoW (SPI_GETNONCLIENTMETRICS, ncm.cbSize, &ncm, 0);
3173 /* if the font is bold, set to normal */
3174 if (ncm.lfCaptionFont.lfWeight > FW_NORMAL) {
3175 ncm.lfCaptionFont.lfWeight = FW_NORMAL;
3177 tfont = CreateFontIndirectW (&ncm.lfCaptionFont);
3179 infoPtr->hFont = infoPtr->hDefaultFont = tfont;
3183 GetSysColor (numerous);
3184 GetSysColorBrush (numerous) (see WM_SYSCOLORCHANGE);
3185 *GetStockObject (SYSTEM_FONT);
3186 *SetWindowLong (hwnd, 0, info ptr);
3188 *SetWindowLong (hwnd, GWL_STYLE, style+0x10000001);
3189 WS_VISIBLE = 0x10000000;
3190 CCS_TOP = 0x00000001;
3191 *SystemParametersInfo (SPI_GETNONCLIENTMETRICS...);
3192 *CreateFontIndirect (lfCaptionFont from above);
3194 SelectObject (hdc, fontabove);
3195 GetTextMetrics (hdc, ); guessing is tmHeight
3196 SelectObject (hdc, oldfont);
3199 MapWindowPoints (0, parent, rectabove, 2);
3202 ClientToScreen (clientrect);
3203 SetWindowPos (hwnd, 0, 0, 0, 0, 0, SWP_NOZORDER);
3210 REBAR_NCHitTest (const REBAR_INFO *infoPtr, LPARAM lParam)
3216 LRESULT ret = HTCLIENT;
3219 * Differences from doc at MSDN (as observed with version 4.71 of
3221 * 1. doc says nmmouse.pt is in screen coord, trace shows client coord.
3222 * 2. if band is not identified .dwItemSpec is 0xffffffff.
3223 * 3. native always seems to return HTCLIENT if notify return is 0.
3226 clpt.x = (short)LOWORD(lParam);
3227 clpt.y = (short)HIWORD(lParam);
3228 ScreenToClient (infoPtr->hwndSelf, &clpt);
3229 REBAR_InternalHitTest (infoPtr, &clpt, &scrap,
3230 (INT *)&nmmouse.dwItemSpec);
3231 nmmouse.dwItemData = 0;
3233 nmmouse.dwHitInfo = 0;
3234 if ((i = REBAR_Notify((NMHDR *) &nmmouse, infoPtr, NM_NCHITTEST))) {
3235 TRACE("notify changed return value from %ld to %d\n",
3239 TRACE("returning %ld, client point (%d,%d)\n", ret, clpt.x, clpt.y);
3245 REBAR_NCPaint (const REBAR_INFO *infoPtr)
3251 if (infoPtr->dwStyle & WS_MINIMIZE)
3252 return 0; /* Nothing to do */
3254 if (infoPtr->dwStyle & WS_BORDER) {
3256 /* adjust rectangle and draw the necessary edge */
3257 if (!(hdc = GetDCEx( infoPtr->hwndSelf, 0, DCX_USESTYLE | DCX_WINDOW )))
3259 GetWindowRect (infoPtr->hwndSelf, &rcWindow);
3260 OffsetRect (&rcWindow, -rcWindow.left, -rcWindow.top);
3261 TRACE("rect (%s)\n", wine_dbgstr_rect(&rcWindow));
3262 DrawEdge (hdc, &rcWindow, EDGE_ETCHED, BF_RECT);
3263 ReleaseDC( infoPtr->hwndSelf, hdc );
3265 else if ((theme = GetWindowTheme (infoPtr->hwndSelf)))
3267 /* adjust rectangle and draw the necessary edge */
3268 if (!(hdc = GetDCEx( infoPtr->hwndSelf, 0, DCX_USESTYLE | DCX_WINDOW )))
3270 GetWindowRect (infoPtr->hwndSelf, &rcWindow);
3271 OffsetRect (&rcWindow, -rcWindow.left, -rcWindow.top);
3272 TRACE("rect (%s)\n", wine_dbgstr_rect(&rcWindow));
3273 DrawThemeEdge (theme, hdc, 0, 0, &rcWindow, BDR_RAISEDINNER, BF_TOP, NULL);
3274 ReleaseDC( infoPtr->hwndSelf, hdc );
3282 REBAR_NotifyFormat (REBAR_INFO *infoPtr, LPARAM cmd)
3286 if (cmd == NF_REQUERY) {
3287 i = SendMessageW(REBAR_GetNotifyParent (infoPtr),
3288 WM_NOTIFYFORMAT, (WPARAM)infoPtr->hwndSelf, NF_QUERY);
3289 if ((i != NFR_ANSI) && (i != NFR_UNICODE)) {
3290 ERR("wrong response to WM_NOTIFYFORMAT (%d), assuming ANSI\n", i);
3293 infoPtr->bUnicode = (i == NFR_UNICODE) ? 1 : 0;
3296 return (LRESULT)((infoPtr->bUnicode) ? NFR_UNICODE : NFR_ANSI);
3301 REBAR_Paint (const REBAR_INFO *infoPtr, HDC hdc)
3304 TRACE("painting\n");
3305 REBAR_Refresh (infoPtr, hdc);
3308 hdc = BeginPaint (infoPtr->hwndSelf, &ps);
3309 TRACE("painting (%s)\n", wine_dbgstr_rect(&ps.rcPaint));
3311 /* Erase area of paint if requested */
3312 REBAR_InternalEraseBkGnd (infoPtr, hdc, &ps.rcPaint);
3314 REBAR_Refresh (infoPtr, hdc);
3315 EndPaint (infoPtr->hwndSelf, &ps);
3323 REBAR_SetCursor (const REBAR_INFO *infoPtr, LPARAM lParam)
3328 TRACE("code=0x%X id=0x%X\n", LOWORD(lParam), HIWORD(lParam));
3331 ScreenToClient (infoPtr->hwndSelf, &pt);
3333 REBAR_InternalHitTest (infoPtr, &pt, &flags, NULL);
3335 if (flags == RBHT_GRABBER) {
3336 if ((infoPtr->dwStyle & CCS_VERT) &&
3337 !(infoPtr->dwStyle & RBS_VERTICALGRIPPER))
3338 SetCursor (infoPtr->hcurVert);
3340 SetCursor (infoPtr->hcurHorz);
3342 else if (flags != RBHT_CLIENT)
3343 SetCursor (infoPtr->hcurArrow);
3350 REBAR_SetFont (REBAR_INFO *infoPtr, HFONT font)
3355 infoPtr->hFont = font;
3357 /* revalidate all bands to change sizes of text in headers of bands */
3358 for (i=0; i<infoPtr->uNumBands; i++) {
3359 lpBand = REBAR_GetBand(infoPtr, i);
3360 REBAR_ValidateBand (infoPtr, lpBand);
3363 REBAR_Layout(infoPtr);
3368 /*****************************************************
3370 * Handles the WM_SETREDRAW message.
3373 * According to testing V4.71 of COMCTL32 returns the
3374 * *previous* status of the redraw flag (either 0 or -1)
3375 * instead of the MSDN documented value of 0 if handled
3377 *****************************************************/
3378 static inline LRESULT
3379 REBAR_SetRedraw (REBAR_INFO *infoPtr, BOOL redraw)
3381 BOOL oldredraw = infoPtr->DoRedraw;
3383 TRACE("set to %s, fStatus=%08x\n",
3384 (redraw) ? "TRUE" : "FALSE", infoPtr->fStatus);
3385 infoPtr->DoRedraw = redraw;
3387 if (infoPtr->fStatus & BAND_NEEDS_REDRAW) {
3388 REBAR_MoveChildWindows (infoPtr, 0, infoPtr->uNumBands);
3389 REBAR_ForceResize (infoPtr);
3390 InvalidateRect (infoPtr->hwndSelf, 0, TRUE);
3392 infoPtr->fStatus &= ~BAND_NEEDS_REDRAW;
3394 return (oldredraw) ? -1 : 0;
3399 REBAR_Size (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3401 TRACE("wParam=%lx, lParam=%lx\n", wParam, lParam);
3403 /* avoid _Layout resize recursion (but it shouldn't be infinite and it seems Windows does recurse) */
3404 if (infoPtr->fStatus & SELF_RESIZE) {
3405 infoPtr->fStatus &= ~SELF_RESIZE;
3406 TRACE("SELF_RESIZE was set, reset, fStatus=%08x lparam=%08lx\n",
3407 infoPtr->fStatus, lParam);
3411 if (infoPtr->dwStyle & RBS_AUTOSIZE)
3412 REBAR_AutoSize(infoPtr, TRUE);
3414 REBAR_Layout(infoPtr);
3421 REBAR_StyleChanged (REBAR_INFO *infoPtr, INT nType, const STYLESTRUCT *lpStyle)
3423 TRACE("current style=%08x, styleOld=%08x, style being set to=%08x\n",
3424 infoPtr->dwStyle, lpStyle->styleOld, lpStyle->styleNew);
3425 if (nType == GWL_STYLE)
3427 infoPtr->orgStyle = infoPtr->dwStyle = lpStyle->styleNew;
3428 if (GetWindowTheme (infoPtr->hwndSelf))
3429 infoPtr->dwStyle &= ~WS_BORDER;
3430 /* maybe it should be COMMON_STYLES like in toolbar */
3431 if ((lpStyle->styleNew ^ lpStyle->styleOld) & CCS_VERT)
3432 REBAR_Layout(infoPtr);
3437 /* update theme after a WM_THEMECHANGED message */
3438 static LRESULT theme_changed (REBAR_INFO* infoPtr)
3440 HTHEME theme = GetWindowTheme (infoPtr->hwndSelf);
3441 CloseThemeData (theme);
3442 theme = OpenThemeData (infoPtr->hwndSelf, themeClass);
3443 /* WS_BORDER disappears when theming is enabled and reappears when
3445 infoPtr->dwStyle &= ~WS_BORDER;
3446 infoPtr->dwStyle |= theme ? 0 : (infoPtr->orgStyle & WS_BORDER);
3451 REBAR_WindowPosChanged (const REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3456 ret = DefWindowProcW(infoPtr->hwndSelf, WM_WINDOWPOSCHANGED,
3458 GetWindowRect(infoPtr->hwndSelf, &rc);
3459 TRACE("hwnd %p new pos (%s)\n", infoPtr->hwndSelf, wine_dbgstr_rect(&rc));
3464 static LRESULT WINAPI
3465 REBAR_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
3467 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
3469 TRACE("hwnd=%p msg=%x wparam=%lx lparam=%lx\n",
3470 hwnd, uMsg, wParam, lParam);
3471 if (!infoPtr && (uMsg != WM_NCCREATE))
3472 return DefWindowProcW (hwnd, uMsg, wParam, lParam);
3475 /* case RB_BEGINDRAG: */
3478 return REBAR_DeleteBand (infoPtr, wParam);
3480 /* case RB_DRAGMOVE: */
3481 /* case RB_ENDDRAG: */
3483 case RB_GETBANDBORDERS:
3484 return REBAR_GetBandBorders (infoPtr, wParam, (LPRECT)lParam);
3486 case RB_GETBANDCOUNT:
3487 return REBAR_GetBandCount (infoPtr);
3489 case RB_GETBANDINFO_OLD:
3490 case RB_GETBANDINFOA:
3491 case RB_GETBANDINFOW:
3492 return REBAR_GetBandInfoT(infoPtr, wParam, (LPREBARBANDINFOW)lParam,
3493 uMsg == RB_GETBANDINFOW);
3494 case RB_GETBARHEIGHT:
3495 return REBAR_GetBarHeight (infoPtr);
3498 return REBAR_GetBarInfo (infoPtr, (LPREBARINFO)lParam);
3501 return REBAR_GetBkColor (infoPtr);
3503 /* case RB_GETCOLORSCHEME: */
3504 /* case RB_GETDROPTARGET: */
3507 return REBAR_GetPalette (infoPtr);
3510 return REBAR_GetRect (infoPtr, wParam, (LPRECT)lParam);
3512 case RB_GETROWCOUNT:
3513 return REBAR_GetRowCount (infoPtr);
3515 case RB_GETROWHEIGHT:
3516 return REBAR_GetRowHeight (infoPtr, wParam);
3518 case RB_GETTEXTCOLOR:
3519 return REBAR_GetTextColor (infoPtr);
3521 case RB_GETTOOLTIPS:
3522 return REBAR_GetToolTips (infoPtr);
3524 case RB_GETUNICODEFORMAT:
3525 return REBAR_GetUnicodeFormat (infoPtr);
3527 case CCM_GETVERSION:
3528 return REBAR_GetVersion (infoPtr);
3531 return REBAR_HitTest (infoPtr, (LPRBHITTESTINFO)lParam);
3534 return REBAR_IdToIndex (infoPtr, wParam);
3536 case RB_INSERTBANDA:
3537 case RB_INSERTBANDW:
3538 return REBAR_InsertBandT(infoPtr, wParam, (LPREBARBANDINFOW)lParam,
3539 uMsg == RB_INSERTBANDW);
3540 case RB_MAXIMIZEBAND:
3541 return REBAR_MaximizeBand (infoPtr, wParam, lParam);
3543 case RB_MINIMIZEBAND:
3544 return REBAR_MinimizeBand (infoPtr, wParam);
3547 return REBAR_MoveBand (infoPtr, wParam, lParam);
3549 case RB_PUSHCHEVRON:
3550 return REBAR_PushChevron (infoPtr, wParam, lParam);
3552 case RB_SETBANDINFOA:
3553 case RB_SETBANDINFOW:
3554 return REBAR_SetBandInfoT(infoPtr, wParam, (LPREBARBANDINFOW)lParam,
3555 uMsg == RB_SETBANDINFOW);
3557 return REBAR_SetBarInfo (infoPtr, (LPREBARINFO)lParam);
3560 return REBAR_SetBkColor (infoPtr, lParam);
3562 /* case RB_SETCOLORSCHEME: */
3563 /* case RB_SETPALETTE: */
3566 return REBAR_SetParent (infoPtr, (HWND)wParam);
3568 case RB_SETTEXTCOLOR:
3569 return REBAR_SetTextColor (infoPtr, lParam);
3571 /* case RB_SETTOOLTIPS: */
3573 case RB_SETUNICODEFORMAT:
3574 return REBAR_SetUnicodeFormat (infoPtr, wParam);
3576 case CCM_SETVERSION:
3577 return REBAR_SetVersion (infoPtr, (INT)wParam);
3580 return REBAR_ShowBand (infoPtr, wParam, lParam);
3583 return REBAR_SizeToRect (infoPtr, (LPCRECT)lParam);
3586 /* Messages passed to parent */
3590 return SendMessageW(REBAR_GetNotifyParent (infoPtr), uMsg, wParam, lParam);
3593 /* case WM_CHARTOITEM: supported according to ControlSpy */
3596 return REBAR_Create (infoPtr, (LPCREATESTRUCTW)lParam);
3599 return REBAR_Destroy (infoPtr);
3602 return REBAR_EraseBkGnd (infoPtr, (HDC)wParam);
3605 return REBAR_GetFont (infoPtr);
3607 /* case WM_LBUTTONDBLCLK: supported according to ControlSpy */
3609 case WM_LBUTTONDOWN:
3610 return REBAR_LButtonDown (infoPtr, lParam);
3613 return REBAR_LButtonUp (infoPtr);
3615 /* case WM_MEASUREITEM: supported according to ControlSpy */
3618 return REBAR_MouseMove (infoPtr, lParam);
3621 return REBAR_MouseLeave (infoPtr);
3624 return REBAR_NCCalcSize (infoPtr, (RECT*)lParam);
3627 return REBAR_NCCreate (hwnd, (LPCREATESTRUCTW)lParam);
3630 return REBAR_NCHitTest (infoPtr, lParam);
3633 return REBAR_NCPaint (infoPtr);
3635 case WM_NOTIFYFORMAT:
3636 return REBAR_NotifyFormat (infoPtr, lParam);
3638 case WM_PRINTCLIENT:
3640 return REBAR_Paint (infoPtr, (HDC)wParam);
3642 /* case WM_PALETTECHANGED: supported according to ControlSpy */
3643 /* case WM_QUERYNEWPALETTE:supported according to ControlSpy */
3644 /* case WM_RBUTTONDOWN: supported according to ControlSpy */
3645 /* case WM_RBUTTONUP: supported according to ControlSpy */
3648 return REBAR_SetCursor (infoPtr, lParam);
3651 return REBAR_SetFont (infoPtr, (HFONT)wParam);
3654 return REBAR_SetRedraw (infoPtr, wParam);
3657 return REBAR_Size (infoPtr, wParam, lParam);
3659 case WM_STYLECHANGED:
3660 return REBAR_StyleChanged (infoPtr, wParam, (LPSTYLESTRUCT)lParam);
3662 case WM_THEMECHANGED:
3663 return theme_changed (infoPtr);
3665 case WM_SYSCOLORCHANGE:
3666 COMCTL32_RefreshSysColors();
3669 /* case WM_VKEYTOITEM: supported according to ControlSpy */
3670 /* case WM_WININICHANGE: */
3672 case WM_WINDOWPOSCHANGED:
3673 return REBAR_WindowPosChanged (infoPtr, wParam, lParam);
3676 if ((uMsg >= WM_USER) && (uMsg < WM_APP) && !COMCTL32_IsReflectedMessage(uMsg))
3677 ERR("unknown msg %04x wp=%08lx lp=%08lx\n",
3678 uMsg, wParam, lParam);
3679 return DefWindowProcW (hwnd, uMsg, wParam, lParam);
3685 REBAR_Register (void)
3689 ZeroMemory (&wndClass, sizeof(WNDCLASSW));
3690 wndClass.style = CS_GLOBALCLASS | CS_DBLCLKS;
3691 wndClass.lpfnWndProc = REBAR_WindowProc;
3692 wndClass.cbClsExtra = 0;
3693 wndClass.cbWndExtra = sizeof(REBAR_INFO *);
3694 wndClass.hCursor = 0;
3695 wndClass.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1);
3697 wndClass.hbrBackground = CreateSolidBrush(RGB(0,128,0));
3699 wndClass.lpszClassName = REBARCLASSNAMEW;
3701 RegisterClassW (&wndClass);
3703 mindragx = GetSystemMetrics (SM_CXDRAG);
3704 mindragy = GetSystemMetrics (SM_CYDRAG);
3710 REBAR_Unregister (void)
3712 UnregisterClassW (REBARCLASSNAMEW, NULL);