4 * Copyright 1998, 1999 Eric Kohl
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 * This code was audited for completeness against the documented features
22 * of Comctl32.dll version 6.0 on Oct. 19, 2004, by Robert Shearman.
24 * Unless otherwise noted, we believe this code to be complete, as per
25 * the specification mentioned above.
26 * If you discover missing features or bugs please note them below.
53 * - WM_QUERYNEWPALETTE
61 * - NM_RELEASEDCAPTURE
67 * Native uses (on each draw!!) SM_CYBORDER (or SM_CXBORDER for CCS_VERT)
68 * to set the size of the separator width (the value SEP_WIDTH_SIZE
69 * in here). Should be fixed!!
73 * Testing: set to 1 to make background brush *always* green
79 * 2. At "FIXME: problem # 2" WinRAR:
80 * if "#if 1" then last band draws in separate row
81 * if "#if 0" then last band draws in previous row *** just like native ***
87 * 3. REBAR_MoveChildWindows should have a loop because more than
88 * one pass is made (together with the RBN_CHILDSIZEs) is made on
89 * at least RB_INSERTBAND
99 #include "wine/unicode.h"
102 #include "commctrl.h"
103 #include "comctl32.h"
104 #include "wine/debug.h"
106 WINE_DEFAULT_DEBUG_CHANNEL(rebar);
116 UINT cxMinChild; /* valid if _CHILDSIZE */
117 UINT cyMinChild; /* valid if _CHILDSIZE */
118 UINT cx; /* valid if _SIZE */
121 UINT cyChild; /* valid if _CHILDSIZE */
122 UINT cyMaxChild; /* valid if _CHILDSIZE */
123 UINT cyIntegral; /* valid if _CHILDSIZE */
128 UINT lcx; /* minimum cx for band */
129 UINT ccx; /* current cx for band */
130 UINT hcx; /* maximum cx for band */
131 UINT lcy; /* minimum cy for band */
132 UINT ccy; /* current cy for band */
133 UINT hcy; /* maximum cy for band */
135 SIZE offChild; /* x,y offset if child is not FIXEDSIZE */
137 INT iRow; /* row this band assigned to */
138 UINT fStatus; /* status flags, reset only by _Validate */
139 UINT fDraw; /* drawing flags, reset only by _Layout */
140 UINT uCDret; /* last return from NM_CUSTOMDRAW */
141 RECT rcoldBand; /* previous calculated band rectangle */
142 RECT rcBand; /* calculated band rectangle */
143 RECT rcGripper; /* calculated gripper rectangle */
144 RECT rcCapImage; /* calculated caption image rectangle */
145 RECT rcCapText; /* calculated caption text rectangle */
146 RECT rcChild; /* calculated child rectangle */
147 RECT rcChevron; /* calculated chevron rectangle */
154 #define HAS_GRIPPER 0x00000001
155 #define HAS_IMAGE 0x00000002
156 #define HAS_TEXT 0x00000004
159 #define DRAW_GRIPPER 0x00000001
160 #define DRAW_IMAGE 0x00000002
161 #define DRAW_TEXT 0x00000004
162 #define DRAW_RIGHTSEP 0x00000010
163 #define DRAW_BOTTOMSEP 0x00000020
164 #define DRAW_CHEVRONHOT 0x00000040
165 #define DRAW_CHEVRONPUSHED 0x00000080
166 #define DRAW_LAST_IN_ROW 0x00000100
167 #define DRAW_FIRST_IN_ROW 0x00000200
168 #define NTF_INVALIDATE 0x01000000
172 COLORREF clrBk; /* background color */
173 COLORREF clrText; /* text color */
174 COLORREF clrBtnText; /* system color for BTNTEXT */
175 COLORREF clrBtnFace; /* system color for BTNFACE */
176 HIMAGELIST himl; /* handle to imagelist */
177 UINT uNumBands; /* # of bands in rebar (first=0, last=uNumBands-1 */
178 UINT uNumRows; /* # of rows of bands (first=1, last=uNumRows */
179 HWND hwndSelf; /* handle of REBAR window itself */
180 HWND hwndToolTip; /* handle to the tool tip control */
181 HWND hwndNotify; /* notification window (parent) */
183 HFONT hFont; /* handle to the rebar's font */
184 SIZE imageSize; /* image size (image list) */
185 DWORD dwStyle; /* window style */
186 SIZE calcSize; /* calculated rebar size */
187 SIZE oldSize; /* previous calculated rebar size */
188 BOOL bUnicode; /* TRUE if this window is W type */
189 BOOL NtfUnicode; /* TRUE if parent wants notify in W format */
190 BOOL DoRedraw; /* TRUE to acutally draw bands */
191 UINT fStatus; /* Status flags (see below) */
192 HCURSOR hcurArrow; /* handle to the arrow cursor */
193 HCURSOR hcurHorz; /* handle to the EW cursor */
194 HCURSOR hcurVert; /* handle to the NS cursor */
195 HCURSOR hcurDrag; /* handle to the drag cursor */
196 INT iVersion; /* version number */
197 POINTS dragStart; /* x,y of button down */
198 POINTS dragNow; /* x,y of this MouseMove */
199 INT iOldBand; /* last band that had the mouse cursor over it */
200 INT ihitoffset; /* offset of hotspot from gripper.left */
201 POINT origin; /* left/upper corner of client */
202 INT ichevronhotBand; /* last band that had a hot chevron */
203 INT iGrabbedBand;/* band number of band whose gripper was grabbed */
205 REBAR_BAND *bands; /* pointer to the array of rebar bands */
209 #define BEGIN_DRAG_ISSUED 0x00000001
210 #define AUTO_RESIZE 0x00000002
211 #define RESIZE_ANYHOW 0x00000004
212 #define NTF_HGHTCHG 0x00000008
213 #define BAND_NEEDS_LAYOUT 0x00000010
214 #define BAND_NEEDS_REDRAW 0x00000020
215 #define CREATE_RUNNING 0x00000040
217 /* ---- REBAR layout constants. Mostly determined by ---- */
218 /* ---- experiment on WIN 98. ---- */
220 /* Width (or height) of separators between bands (either horz. or */
221 /* vert.). True only if RBS_BANDBORDERS is set */
222 #define SEP_WIDTH_SIZE 2
223 #define SEP_WIDTH ((infoPtr->dwStyle & RBS_BANDBORDERS) ? SEP_WIDTH_SIZE : 0)
225 /* Blank (background color) space between Gripper (if present) */
226 /* and next item (image, text, or window). Always present */
227 #define REBAR_ALWAYS_SPACE 4
229 /* Blank (background color) space after Image (if present). */
230 #define REBAR_POST_IMAGE 2
232 /* Blank (background color) space after Text (if present). */
233 #define REBAR_POST_TEXT 4
235 /* Height of vertical gripper in a CCS_VERT rebar. */
236 #define GRIPPER_HEIGHT 16
238 /* Blank (background color) space before Gripper (if present). */
239 #define REBAR_PRE_GRIPPER 2
241 /* Width (of normal vertical gripper) or height (of horz. gripper) */
243 #define GRIPPER_WIDTH 3
245 /* Width of the chevron button if present */
246 #define CHEVRON_WIDTH 10
248 /* Height of divider for Rebar if not disabled (CCS_NODIVIDER) */
249 /* either top or bottom */
250 #define REBAR_DIVIDER 2
252 /* minimium vertical height of a normal bar */
253 /* or minimum width of a CCS_VERT bar - from experiment on Win2k */
254 #define REBAR_MINSIZE 23
256 /* This is the increment that is used over the band height */
257 #define REBARSPACE(a) ((a->fStyle & RBBS_CHILDEDGE) ? 2*REBAR_DIVIDER : 0)
259 /* ---- End of REBAR layout constants. ---- */
261 #define RB_GETBANDINFO_OLD (WM_USER+5) /* obsoleted after IE3, but we have to support it anyway */
263 /* The following 6 defines return the proper rcBand element */
264 /* depending on whether CCS_VERT was set. */
265 #define rcBlt(b) ((infoPtr->dwStyle & CCS_VERT) ? b->rcBand.top : b->rcBand.left)
266 #define rcBrb(b) ((infoPtr->dwStyle & CCS_VERT) ? b->rcBand.bottom : b->rcBand.right)
267 #define rcBw(b) ((infoPtr->dwStyle & CCS_VERT) ? (b->rcBand.bottom - b->rcBand.top) : \
268 (b->rcBand.right - b->rcBand.left))
269 #define ircBlt(b) ((infoPtr->dwStyle & CCS_VERT) ? b->rcBand.left : b->rcBand.top)
270 #define ircBrb(b) ((infoPtr->dwStyle & CCS_VERT) ? b->rcBand.right : b->rcBand.bottom)
271 #define ircBw(b) ((infoPtr->dwStyle & CCS_VERT) ? (b->rcBand.right - b->rcBand.left) : \
272 (b->rcBand.bottom - b->rcBand.top))
274 /* The following define determines if a given band is hidden */
275 #define HIDDENBAND(a) (((a)->fStyle & RBBS_HIDDEN) || \
276 ((infoPtr->dwStyle & CCS_VERT) && \
277 ((a)->fStyle & RBBS_NOVERT)))
279 /* The following defines adjust the right or left end of a rectangle */
280 #define READJ(b,i) do { if(infoPtr->dwStyle & CCS_VERT) b->rcBand.bottom+=(i); \
281 else b->rcBand.right += (i); } while(0)
282 #define LEADJ(b,i) do { if(infoPtr->dwStyle & CCS_VERT) b->rcBand.top+=(i); \
283 else b->rcBand.left += (i); } while(0)
286 #define REBAR_GetInfoPtr(wndPtr) ((REBAR_INFO *)GetWindowLongPtrW (hwnd, 0))
289 /* "constant values" retrieved when DLL was initialized */
290 /* FIXME we do this when the classes are registered. */
291 static UINT mindragx = 0;
292 static UINT mindragy = 0;
294 static const char *band_stylename[] = {
295 "RBBS_BREAK", /* 0001 */
296 "RBBS_FIXEDSIZE", /* 0002 */
297 "RBBS_CHILDEDGE", /* 0004 */
298 "RBBS_HIDDEN", /* 0008 */
299 "RBBS_NOVERT", /* 0010 */
300 "RBBS_FIXEDBMP", /* 0020 */
301 "RBBS_VARIABLEHEIGHT", /* 0040 */
302 "RBBS_GRIPPERALWAYS", /* 0080 */
303 "RBBS_NOGRIPPER", /* 0100 */
306 static const char *band_maskname[] = {
307 "RBBIM_STYLE", /* 0x00000001 */
308 "RBBIM_COLORS", /* 0x00000002 */
309 "RBBIM_TEXT", /* 0x00000004 */
310 "RBBIM_IMAGE", /* 0x00000008 */
311 "RBBIM_CHILD", /* 0x00000010 */
312 "RBBIM_CHILDSIZE", /* 0x00000020 */
313 "RBBIM_SIZE", /* 0x00000040 */
314 "RBBIM_BACKGROUND", /* 0x00000080 */
315 "RBBIM_ID", /* 0x00000100 */
316 "RBBIM_IDEALSIZE", /* 0x00000200 */
317 "RBBIM_LPARAM", /* 0x00000400 */
318 "RBBIM_HEADERSIZE", /* 0x00000800 */
322 static CHAR line[200];
326 REBAR_FmtStyle( UINT style)
331 while (band_stylename[i]) {
332 if (style & (1<<i)) {
333 if (*line != 0) strcat(line, " | ");
334 strcat(line, band_stylename[i]);
343 REBAR_FmtMask( UINT mask)
348 while (band_maskname[i]) {
350 if (*line != 0) strcat(line, " | ");
351 strcat(line, band_maskname[i]);
360 REBAR_DumpBandInfo( LPREBARBANDINFOA pB)
362 if( !TRACE_ON(rebar) ) return;
363 TRACE("band info: ID=%u, size=%u, child=%p, clrF=0x%06lx, clrB=0x%06lx\n",
364 pB->wID, pB->cbSize, pB->hwndChild, pB->clrFore, pB->clrBack);
365 TRACE("band info: mask=0x%08x (%s)\n", pB->fMask, REBAR_FmtMask(pB->fMask));
366 if (pB->fMask & RBBIM_STYLE)
367 TRACE("band info: style=0x%08x (%s)\n", pB->fStyle, REBAR_FmtStyle(pB->fStyle));
368 if (pB->fMask & (RBBIM_SIZE | RBBIM_IDEALSIZE | RBBIM_HEADERSIZE | RBBIM_LPARAM )) {
370 if (pB->fMask & RBBIM_SIZE)
371 TRACE(" cx=%u", pB->cx);
372 if (pB->fMask & RBBIM_IDEALSIZE)
373 TRACE(" xIdeal=%u", pB->cxIdeal);
374 if (pB->fMask & RBBIM_HEADERSIZE)
375 TRACE(" xHeader=%u", pB->cxHeader);
376 if (pB->fMask & RBBIM_LPARAM)
377 TRACE(" lParam=0x%08lx", pB->lParam);
380 if (pB->fMask & RBBIM_CHILDSIZE)
381 TRACE("band info: xMin=%u, yMin=%u, yChild=%u, yMax=%u, yIntgl=%u\n",
383 pB->cyMinChild, pB->cyChild, pB->cyMaxChild, pB->cyIntegral);
387 REBAR_DumpBand (REBAR_INFO *iP)
392 if(! TRACE_ON(rebar) ) return;
394 TRACE("hwnd=%p: color=%08lx/%08lx, bands=%u, rows=%u, cSize=%ld,%ld\n",
395 iP->hwndSelf, iP->clrText, iP->clrBk, iP->uNumBands, iP->uNumRows,
396 iP->calcSize.cx, iP->calcSize.cy);
397 TRACE("hwnd=%p: flags=%08x, dragStart=%d,%d, dragNow=%d,%d, iGrabbedBand=%d\n",
398 iP->hwndSelf, iP->fStatus, iP->dragStart.x, iP->dragStart.y,
399 iP->dragNow.x, iP->dragNow.y,
401 TRACE("hwnd=%p: style=%08lx, I'm Unicode=%s, notify in Unicode=%s, redraw=%s\n",
402 iP->hwndSelf, iP->dwStyle, (iP->bUnicode)?"TRUE":"FALSE",
403 (iP->NtfUnicode)?"TRUE":"FALSE", (iP->DoRedraw)?"TRUE":"FALSE");
404 for (i = 0; i < iP->uNumBands; i++) {
406 TRACE("band # %u: ID=%u, child=%p, row=%u, clrF=0x%06lx, clrB=0x%06lx\n",
407 i, pB->wID, pB->hwndChild, pB->iRow, pB->clrFore, pB->clrBack);
408 TRACE("band # %u: mask=0x%08x (%s)\n", i, pB->fMask, REBAR_FmtMask(pB->fMask));
409 if (pB->fMask & RBBIM_STYLE)
410 TRACE("band # %u: style=0x%08x (%s)\n",
411 i, pB->fStyle, REBAR_FmtStyle(pB->fStyle));
412 TRACE("band # %u: uMinH=%u xHeader=%u",
413 i, pB->uMinHeight, pB->cxHeader);
414 if (pB->fMask & (RBBIM_SIZE | RBBIM_IDEALSIZE | RBBIM_LPARAM )) {
415 if (pB->fMask & RBBIM_SIZE)
416 TRACE(" cx=%u", pB->cx);
417 if (pB->fMask & RBBIM_IDEALSIZE)
418 TRACE(" xIdeal=%u", pB->cxIdeal);
419 if (pB->fMask & RBBIM_LPARAM)
420 TRACE(" lParam=0x%08lx", pB->lParam);
424 TRACE("band # %u: xMin=%u, yMin=%u, yChild=%u, yMax=%u, yIntgl=%u\n",
425 i, pB->cxMinChild, pB->cyMinChild, pB->cyChild, pB->cyMaxChild, pB->cyIntegral);
426 if (pB->fMask & RBBIM_TEXT)
427 TRACE("band # %u: text=%s\n",
428 i, (pB->lpText) ? debugstr_w(pB->lpText) : "(null)");
429 TRACE("band # %u: lcx=%u, ccx=%u, hcx=%u, lcy=%u, ccy=%u, hcy=%u, offChild=%ld,%ld\n",
430 i, pB->lcx, pB->ccx, pB->hcx, pB->lcy, pB->ccy, pB->hcy, pB->offChild.cx, pB->offChild.cy);
431 TRACE("band # %u: fStatus=%08x, fDraw=%08x, Band=(%ld,%ld)-(%ld,%ld), Grip=(%ld,%ld)-(%ld,%ld)\n",
432 i, pB->fStatus, pB->fDraw,
433 pB->rcBand.left, pB->rcBand.top, pB->rcBand.right, pB->rcBand.bottom,
434 pB->rcGripper.left, pB->rcGripper.top, pB->rcGripper.right, pB->rcGripper.bottom);
435 TRACE("band # %u: Img=(%ld,%ld)-(%ld,%ld), Txt=(%ld,%ld)-(%ld,%ld), Child=(%ld,%ld)-(%ld,%ld)\n",
437 pB->rcCapImage.left, pB->rcCapImage.top, pB->rcCapImage.right, pB->rcCapImage.bottom,
438 pB->rcCapText.left, pB->rcCapText.top, pB->rcCapText.right, pB->rcCapText.bottom,
439 pB->rcChild.left, pB->rcChild.top, pB->rcChild.right, pB->rcChild.bottom);
445 REBAR_DrawChevron (HDC hdc, INT left, INT top, INT colorRef)
450 if (!(hPen = CreatePen( PS_SOLID, 1, GetSysColor( colorRef )))) return;
451 hOldPen = SelectObject ( hdc, hPen );
454 MoveToEx (hdc, x, y, NULL);
455 LineTo (hdc, x+5, y++); x++;
456 MoveToEx (hdc, x, y, NULL);
457 LineTo (hdc, x+3, y++); x++;
458 MoveToEx (hdc, x, y, NULL);
459 LineTo (hdc, x+1, y++);
460 SelectObject( hdc, hOldPen );
461 DeleteObject( hPen );
465 REBAR_GetNotifyParent (REBAR_INFO *infoPtr)
469 parent = infoPtr->hwndNotify;
471 parent = GetParent (infoPtr->hwndSelf);
472 owner = GetWindow (infoPtr->hwndSelf, GW_OWNER);
473 if (owner) parent = owner;
480 REBAR_Notify (NMHDR *nmhdr, REBAR_INFO *infoPtr, UINT code)
484 parent = REBAR_GetNotifyParent (infoPtr);
485 nmhdr->idFrom = GetDlgCtrlID (infoPtr->hwndSelf);
486 nmhdr->hwndFrom = infoPtr->hwndSelf;
489 TRACE("window %p, code=%08x, %s\n", parent, code,
490 (infoPtr->NtfUnicode) ? "via Unicode" : "via ANSI");
492 if (infoPtr->NtfUnicode)
493 return SendMessageW (parent, WM_NOTIFY, (WPARAM) nmhdr->idFrom,
496 return SendMessageA (parent, WM_NOTIFY, (WPARAM) nmhdr->idFrom,
501 REBAR_Notify_NMREBAR (REBAR_INFO *infoPtr, UINT uBand, UINT code)
503 NMREBAR notify_rebar;
506 notify_rebar.dwMask = 0;
508 lpBand = &infoPtr->bands[uBand];
509 if (lpBand->fMask & RBBIM_ID) {
510 notify_rebar.dwMask |= RBNM_ID;
511 notify_rebar.wID = lpBand->wID;
513 if (lpBand->fMask & RBBIM_LPARAM) {
514 notify_rebar.dwMask |= RBNM_LPARAM;
515 notify_rebar.lParam = lpBand->lParam;
517 if (lpBand->fMask & RBBIM_STYLE) {
518 notify_rebar.dwMask |= RBNM_STYLE;
519 notify_rebar.fStyle = lpBand->fStyle;
522 notify_rebar.uBand = uBand;
523 return REBAR_Notify ((NMHDR *)¬ify_rebar, infoPtr, code);
527 REBAR_DrawBand (HDC hdc, REBAR_INFO *infoPtr, REBAR_BAND *lpBand)
533 if (lpBand->fDraw & DRAW_TEXT) {
534 hOldFont = SelectObject (hdc, infoPtr->hFont);
535 oldBkMode = SetBkMode (hdc, TRANSPARENT);
538 /* should test for CDRF_NOTIFYITEMDRAW here */
539 nmcd.dwDrawStage = CDDS_ITEMPREPAINT;
541 nmcd.rc = lpBand->rcBand;
542 nmcd.rc.right = lpBand->rcCapText.right;
543 nmcd.rc.bottom = lpBand->rcCapText.bottom;
544 nmcd.dwItemSpec = lpBand->wID;
546 nmcd.lItemlParam = lpBand->lParam;
547 lpBand->uCDret = REBAR_Notify ((NMHDR *)&nmcd, infoPtr, NM_CUSTOMDRAW);
548 if (lpBand->uCDret == CDRF_SKIPDEFAULT) {
549 if (oldBkMode != TRANSPARENT)
550 SetBkMode (hdc, oldBkMode);
551 SelectObject (hdc, hOldFont);
556 if (lpBand->fDraw & DRAW_GRIPPER)
557 DrawEdge (hdc, &lpBand->rcGripper, BDR_RAISEDINNER, BF_RECT | BF_MIDDLE);
559 /* draw caption image */
560 if (lpBand->fDraw & DRAW_IMAGE) {
564 pt.y = (lpBand->rcCapImage.bottom + lpBand->rcCapImage.top - infoPtr->imageSize.cy)/2;
565 pt.x = (lpBand->rcCapImage.right + lpBand->rcCapImage.left - infoPtr->imageSize.cx)/2;
567 ImageList_Draw (infoPtr->himl, lpBand->iImage, hdc,
572 /* draw caption text */
573 if (lpBand->fDraw & DRAW_TEXT) {
574 /* need to handle CDRF_NEWFONT here */
575 INT oldBkMode = SetBkMode (hdc, TRANSPARENT);
576 COLORREF oldcolor = CLR_NONE;
578 if (lpBand->clrFore != CLR_NONE) {
579 new = (lpBand->clrFore == CLR_DEFAULT) ? infoPtr->clrBtnText :
581 oldcolor = SetTextColor (hdc, new);
583 DrawTextW (hdc, lpBand->lpText, -1, &lpBand->rcCapText,
584 DT_CENTER | DT_VCENTER | DT_SINGLELINE);
585 if (oldBkMode != TRANSPARENT)
586 SetBkMode (hdc, oldBkMode);
587 if (lpBand->clrFore != CLR_NONE)
588 SetTextColor (hdc, oldcolor);
589 SelectObject (hdc, hOldFont);
592 if (!IsRectEmpty(&lpBand->rcChevron))
594 if (lpBand->fDraw & DRAW_CHEVRONPUSHED)
596 DrawEdge(hdc, &lpBand->rcChevron, BDR_SUNKENOUTER, BF_RECT | BF_MIDDLE);
597 REBAR_DrawChevron(hdc, lpBand->rcChevron.left+1, lpBand->rcChevron.top + 11, COLOR_WINDOWFRAME);
599 else if (lpBand->fDraw & DRAW_CHEVRONHOT)
601 DrawEdge(hdc, &lpBand->rcChevron, BDR_RAISEDINNER, BF_RECT | BF_MIDDLE);
602 REBAR_DrawChevron(hdc, lpBand->rcChevron.left, lpBand->rcChevron.top + 10, COLOR_WINDOWFRAME);
605 REBAR_DrawChevron(hdc, lpBand->rcChevron.left, lpBand->rcChevron.top + 10, COLOR_WINDOWFRAME);
608 if (lpBand->uCDret == (CDRF_NOTIFYPOSTPAINT | CDRF_NOTIFYITEMDRAW)) {
609 nmcd.dwDrawStage = CDDS_ITEMPOSTPAINT;
611 nmcd.rc = lpBand->rcBand;
612 nmcd.rc.right = lpBand->rcCapText.right;
613 nmcd.rc.bottom = lpBand->rcCapText.bottom;
614 nmcd.dwItemSpec = lpBand->wID;
616 nmcd.lItemlParam = lpBand->lParam;
617 lpBand->uCDret = REBAR_Notify ((NMHDR *)&nmcd, infoPtr, NM_CUSTOMDRAW);
623 REBAR_Refresh (REBAR_INFO *infoPtr, HDC hdc)
628 if (!infoPtr->DoRedraw) return;
630 for (i = 0; i < infoPtr->uNumBands; i++) {
631 lpBand = &infoPtr->bands[i];
633 if (HIDDENBAND(lpBand)) continue;
635 /* now draw the band */
636 TRACE("[%p] drawing band %i, flags=%08x\n",
637 infoPtr->hwndSelf, i, lpBand->fDraw);
638 REBAR_DrawBand (hdc, infoPtr, lpBand);
645 REBAR_FixVert (REBAR_INFO *infoPtr, UINT rowstart, UINT rowend,
648 /* Cycle through bands in row and fix height of each band. */
649 /* Also determine whether each band has changed. */
651 /* all bands at desired size. */
652 /* start and end bands are *not* hidden */
657 for (i = (INT)rowstart; i<=(INT)rowend; i++) {
658 lpBand = &infoPtr->bands[i];
659 if (HIDDENBAND(lpBand)) continue;
661 /* adjust height of bands in row to "mcy" value */
662 if (infoPtr->dwStyle & CCS_VERT) {
663 if (lpBand->rcBand.right != lpBand->rcBand.left + mcy)
664 lpBand->rcBand.right = lpBand->rcBand.left + mcy;
667 if (lpBand->rcBand.bottom != lpBand->rcBand.top + mcy)
668 lpBand->rcBand.bottom = lpBand->rcBand.top + mcy;
672 /* mark whether we need to invalidate this band and trace */
673 if ((lpBand->rcoldBand.left !=lpBand->rcBand.left) ||
674 (lpBand->rcoldBand.top !=lpBand->rcBand.top) ||
675 (lpBand->rcoldBand.right !=lpBand->rcBand.right) ||
676 (lpBand->rcoldBand.bottom !=lpBand->rcBand.bottom)) {
677 lpBand->fDraw |= NTF_INVALIDATE;
678 TRACE("band %d row=%d: changed to (%ld,%ld)-(%ld,%ld) from (%ld,%ld)-(%ld,%ld)\n",
680 lpBand->rcBand.left, lpBand->rcBand.top,
681 lpBand->rcBand.right, lpBand->rcBand.bottom,
682 lpBand->rcoldBand.left, lpBand->rcoldBand.top,
683 lpBand->rcoldBand.right, lpBand->rcoldBand.bottom);
686 TRACE("band %d row=%d: unchanged (%ld,%ld)-(%ld,%ld)\n",
688 lpBand->rcBand.left, lpBand->rcBand.top,
689 lpBand->rcBand.right, lpBand->rcBand.bottom);
695 REBAR_AdjustBands (REBAR_INFO *infoPtr, UINT rowstart, UINT rowend,
697 /* Function: This routine distributes the extra space in a row. */
698 /* See algorithm below. */
700 /* all bands @ ->cxHeader size */
701 /* start and end bands are *not* hidden */
704 UINT xsep, extra, curwidth, fudge;
705 INT x, i, last_adjusted;
707 TRACE("start=%u, end=%u, max x=%d, max y=%d\n",
708 rowstart, rowend, maxx, mcy);
710 /* ******************* Phase 1 ************************ */
712 /* For each visible band with valid child */
713 /* a. inflate band till either all extra space used */
714 /* or band's ->ccx reached. */
715 /* If any band modified, add any space left to last band */
718 /* ****************************************************** */
719 lpBand = &infoPtr->bands[rowend];
720 extra = maxx - rcBrb(lpBand);
723 for (i=(INT)rowstart; i<=(INT)rowend; i++) {
724 lpBand = &infoPtr->bands[i];
725 if (HIDDENBAND(lpBand)) continue;
726 xsep = (x == 0) ? 0 : SEP_WIDTH;
727 curwidth = rcBw(lpBand);
729 /* set new left/top point */
730 if (infoPtr->dwStyle & CCS_VERT)
731 lpBand->rcBand.top = x + xsep;
733 lpBand->rcBand.left = x + xsep;
735 /* compute new width */
736 if ((lpBand->hwndChild && extra) && !(lpBand->fStyle & RBBS_FIXEDSIZE)) {
737 /* set to the "current" band size less the header */
740 if ((lpBand->fMask & RBBIM_SIZE) && (lpBand->cx > 0) &&
741 (fudge > curwidth)) {
742 TRACE("adjusting band %d by %d, fudge=%d, curwidth=%d, extra=%d\n",
743 i, fudge-curwidth, fudge, curwidth, extra);
744 if ((fudge - curwidth) > extra)
745 fudge = curwidth + extra;
746 extra -= (fudge - curwidth);
750 TRACE("adjusting band %d by %d, fudge=%d, curwidth=%d\n",
751 i, extra, fudge, curwidth);
757 /* set new right/bottom point */
758 if (infoPtr->dwStyle & CCS_VERT)
759 lpBand->rcBand.bottom = lpBand->rcBand.top + curwidth;
761 lpBand->rcBand.right = lpBand->rcBand.left + curwidth;
762 TRACE("Phase 1 band %d, (%ld,%ld)-(%ld,%ld), orig x=%d, xsep=%d\n",
763 i, lpBand->rcBand.left, lpBand->rcBand.top,
764 lpBand->rcBand.right, lpBand->rcBand.bottom, x, xsep);
767 if ((x >= maxx) || (last_adjusted != -1)) {
769 ERR("Phase 1 failed, x=%d, maxx=%d, start=%u, end=%u\n",
770 x, maxx, rowstart, rowend);
772 /* done, so spread extra space */
775 TRACE("Need to spread %d on last adjusted band %d\n",
776 fudge, last_adjusted);
777 for (i=(INT)last_adjusted; i<=(INT)rowend; i++) {
778 lpBand = &infoPtr->bands[i];
779 if (HIDDENBAND(lpBand)) continue;
781 /* set right/bottom point */
782 if (i != last_adjusted) {
783 if (infoPtr->dwStyle & CCS_VERT)
784 lpBand->rcBand.top += fudge;
786 lpBand->rcBand.left += fudge;
789 /* set left/bottom point */
790 if (infoPtr->dwStyle & CCS_VERT)
791 lpBand->rcBand.bottom += fudge;
793 lpBand->rcBand.right += fudge;
796 TRACE("Phase 1 succeeded, used x=%d\n", x);
797 REBAR_FixVert (infoPtr, rowstart, rowend, mcy);
801 /* ******************* Phase 2 ************************ */
803 /* Find first visible band, put all */
804 /* extra space there. */
806 /* ****************************************************** */
809 for (i=(INT)rowstart; i<=(INT)rowend; i++) {
810 lpBand = &infoPtr->bands[i];
811 if (HIDDENBAND(lpBand)) continue;
812 xsep = (x == 0) ? 0 : SEP_WIDTH;
813 curwidth = rcBw(lpBand);
815 /* set new left/top point */
816 if (infoPtr->dwStyle & CCS_VERT)
817 lpBand->rcBand.top = x + xsep;
819 lpBand->rcBand.left = x + xsep;
821 /* compute new width */
827 /* set new right/bottom point */
828 if (infoPtr->dwStyle & CCS_VERT)
829 lpBand->rcBand.bottom = lpBand->rcBand.top + curwidth;
831 lpBand->rcBand.right = lpBand->rcBand.left + curwidth;
832 TRACE("Phase 2 band %d, (%ld,%ld)-(%ld,%ld), orig x=%d, xsep=%d\n",
833 i, lpBand->rcBand.left, lpBand->rcBand.top,
834 lpBand->rcBand.right, lpBand->rcBand.bottom, x, xsep);
839 ERR("Phase 2 failed, x=%d, maxx=%d, start=%u, end=%u\n",
840 x, maxx, rowstart, rowend);
842 /* done, so spread extra space */
843 TRACE("Phase 2 succeeded, used x=%d\n", x);
844 REBAR_FixVert (infoPtr, rowstart, rowend, mcy);
848 /* ******************* Phase 3 ************************ */
849 /* at this point everything is back to ->cxHeader values */
850 /* and should not have gotten here. */
851 /* ****************************************************** */
853 lpBand = &infoPtr->bands[rowstart];
854 ERR("Serious problem adjusting row %d, start band %d, end band %d\n",
855 lpBand->iRow, rowstart, rowend);
856 REBAR_DumpBand (infoPtr);
862 REBAR_CalcHorzBand (REBAR_INFO *infoPtr, UINT rstart, UINT rend, BOOL notify)
863 /* Function: this routine initializes all the rectangles in */
864 /* each band in a row to fit in the adjusted rcBand rect. */
865 /* *** Supports only Horizontal bars. *** */
872 /* MS seems to use GetDlgCtrlID() for above GetWindowLong call */
873 parenthwnd = GetParent (infoPtr->hwndSelf);
875 for(i=rstart; i<rend; i++){
876 lpBand = &infoPtr->bands[i];
877 if (HIDDENBAND(lpBand)) {
878 SetRect (&lpBand->rcChild,
879 lpBand->rcBand.right, lpBand->rcBand.top,
880 lpBand->rcBand.right, lpBand->rcBand.bottom);
884 oldChild = lpBand->rcChild;
886 /* set initial gripper rectangle */
887 SetRect (&lpBand->rcGripper, lpBand->rcBand.left, lpBand->rcBand.top,
888 lpBand->rcBand.left, lpBand->rcBand.bottom);
890 /* calculate gripper rectangle */
891 if ( lpBand->fStatus & HAS_GRIPPER) {
892 lpBand->fDraw |= DRAW_GRIPPER;
893 lpBand->rcGripper.left += REBAR_PRE_GRIPPER;
894 lpBand->rcGripper.right = lpBand->rcGripper.left + GRIPPER_WIDTH;
895 lpBand->rcGripper.top += 2;
896 lpBand->rcGripper.bottom -= 2;
898 SetRect (&lpBand->rcCapImage,
899 lpBand->rcGripper.right+REBAR_ALWAYS_SPACE, lpBand->rcBand.top,
900 lpBand->rcGripper.right+REBAR_ALWAYS_SPACE, lpBand->rcBand.bottom);
902 else { /* no gripper will be drawn */
904 if (lpBand->fStatus & (HAS_IMAGE | HAS_TEXT))
905 /* if no gripper but either image or text, then leave space */
906 xoff = REBAR_ALWAYS_SPACE;
907 SetRect (&lpBand->rcCapImage,
908 lpBand->rcBand.left+xoff, lpBand->rcBand.top,
909 lpBand->rcBand.left+xoff, lpBand->rcBand.bottom);
912 /* image is visible */
913 if (lpBand->fStatus & HAS_IMAGE) {
914 lpBand->fDraw |= DRAW_IMAGE;
915 lpBand->rcCapImage.right += infoPtr->imageSize.cx;
916 lpBand->rcCapImage.bottom = lpBand->rcCapImage.top + infoPtr->imageSize.cy;
918 /* set initial caption text rectangle */
919 SetRect (&lpBand->rcCapText,
920 lpBand->rcCapImage.right+REBAR_POST_IMAGE, lpBand->rcBand.top+1,
921 lpBand->rcBand.left+lpBand->cxHeader, lpBand->rcBand.bottom-1);
922 /* update band height
923 if (lpBand->uMinHeight < infoPtr->imageSize.cy + 2) {
924 lpBand->uMinHeight = infoPtr->imageSize.cy + 2;
925 lpBand->rcBand.bottom = lpBand->rcBand.top + lpBand->uMinHeight;
929 /* set initial caption text rectangle */
930 SetRect (&lpBand->rcCapText, lpBand->rcCapImage.right, lpBand->rcBand.top+1,
931 lpBand->rcBand.left+lpBand->cxHeader, lpBand->rcBand.bottom-1);
934 /* text is visible */
935 if ((lpBand->fStatus & HAS_TEXT) && !(lpBand->fStyle & RBBS_HIDETITLE)) {
936 lpBand->fDraw |= DRAW_TEXT;
937 lpBand->rcCapText.right = max(lpBand->rcCapText.left,
938 lpBand->rcCapText.right-REBAR_POST_TEXT);
941 /* set initial child window rectangle if there is a child */
942 if (lpBand->fMask & RBBIM_CHILD) {
943 xoff = lpBand->offChild.cx;
944 yoff = lpBand->offChild.cy;
945 SetRect (&lpBand->rcChild,
946 lpBand->rcBand.left+lpBand->cxHeader, lpBand->rcBand.top+yoff,
947 lpBand->rcBand.right-xoff, lpBand->rcBand.bottom-yoff);
948 if ((lpBand->fStyle & RBBS_USECHEVRON) && (lpBand->rcChild.right - lpBand->rcChild.left < lpBand->cxIdeal))
950 lpBand->rcChild.right -= CHEVRON_WIDTH;
951 SetRect(&lpBand->rcChevron, lpBand->rcChild.right,
952 lpBand->rcChild.top, lpBand->rcChild.right + CHEVRON_WIDTH,
953 lpBand->rcChild.bottom);
957 SetRect (&lpBand->rcChild,
958 lpBand->rcBand.left+lpBand->cxHeader, lpBand->rcBand.top,
959 lpBand->rcBand.right, lpBand->rcBand.bottom);
962 /* flag if notify required and invalidate rectangle */
964 ((oldChild.right-oldChild.left != lpBand->rcChild.right-lpBand->rcChild.left) ||
965 (oldChild.bottom-oldChild.top != lpBand->rcChild.bottom-lpBand->rcChild.top))) {
966 TRACE("Child rectangle changed for band %u\n", i);
967 TRACE(" from (%ld,%ld)-(%ld,%ld) to (%ld,%ld)-(%ld,%ld)\n",
968 oldChild.left, oldChild.top,
969 oldChild.right, oldChild.bottom,
970 lpBand->rcChild.left, lpBand->rcChild.top,
971 lpBand->rcChild.right, lpBand->rcChild.bottom);
973 if (lpBand->fDraw & NTF_INVALIDATE) {
974 TRACE("invalidating (%ld,%ld)-(%ld,%ld)\n",
977 lpBand->rcBand.right + ((lpBand->fDraw & DRAW_RIGHTSEP) ? SEP_WIDTH_SIZE : 0),
978 lpBand->rcBand.bottom + ((lpBand->fDraw & DRAW_BOTTOMSEP) ? SEP_WIDTH_SIZE : 0));
979 lpBand->fDraw &= ~NTF_INVALIDATE;
980 work = lpBand->rcBand;
981 if (lpBand->fDraw & DRAW_RIGHTSEP) work.right += SEP_WIDTH_SIZE;
982 if (lpBand->fDraw & DRAW_BOTTOMSEP) work.bottom += SEP_WIDTH_SIZE;
983 InvalidateRect(infoPtr->hwndSelf, &work, TRUE);
992 REBAR_CalcVertBand (REBAR_INFO *infoPtr, UINT rstart, UINT rend, BOOL notify)
993 /* Function: this routine initializes all the rectangles in */
994 /* each band in a row to fit in the adjusted rcBand rect. */
995 /* *** Supports only Vertical bars. *** */
1000 RECT oldChild, work;
1002 /* MS seems to use GetDlgCtrlID() for above GetWindowLong call */
1003 parenthwnd = GetParent (infoPtr->hwndSelf);
1005 for(i=rstart; i<rend; i++){
1006 lpBand = &infoPtr->bands[i];
1007 if (HIDDENBAND(lpBand)) continue;
1008 oldChild = lpBand->rcChild;
1010 /* set initial gripper rectangle */
1011 SetRect (&lpBand->rcGripper, lpBand->rcBand.left, lpBand->rcBand.top,
1012 lpBand->rcBand.right, lpBand->rcBand.top);
1014 /* calculate gripper rectangle */
1015 if (lpBand->fStatus & HAS_GRIPPER) {
1016 lpBand->fDraw |= DRAW_GRIPPER;
1018 if (infoPtr->dwStyle & RBS_VERTICALGRIPPER) {
1019 /* vertical gripper */
1020 lpBand->rcGripper.left += 3;
1021 lpBand->rcGripper.right = lpBand->rcGripper.left + GRIPPER_WIDTH;
1022 lpBand->rcGripper.top += REBAR_PRE_GRIPPER;
1023 lpBand->rcGripper.bottom = lpBand->rcGripper.top + GRIPPER_HEIGHT;
1025 /* initialize Caption image rectangle */
1026 SetRect (&lpBand->rcCapImage, lpBand->rcBand.left,
1027 lpBand->rcGripper.bottom + REBAR_ALWAYS_SPACE,
1028 lpBand->rcBand.right,
1029 lpBand->rcGripper.bottom + REBAR_ALWAYS_SPACE);
1032 /* horizontal gripper */
1033 lpBand->rcGripper.left += 2;
1034 lpBand->rcGripper.right -= 2;
1035 lpBand->rcGripper.top += REBAR_PRE_GRIPPER;
1036 lpBand->rcGripper.bottom = lpBand->rcGripper.top + GRIPPER_WIDTH;
1038 /* initialize Caption image rectangle */
1039 SetRect (&lpBand->rcCapImage, lpBand->rcBand.left,
1040 lpBand->rcGripper.bottom + REBAR_ALWAYS_SPACE,
1041 lpBand->rcBand.right,
1042 lpBand->rcGripper.bottom + REBAR_ALWAYS_SPACE);
1045 else { /* no gripper will be drawn */
1047 if (lpBand->fStatus & (HAS_IMAGE | HAS_TEXT))
1048 /* if no gripper but either image or text, then leave space */
1049 xoff = REBAR_ALWAYS_SPACE;
1050 /* initialize Caption image rectangle */
1051 SetRect (&lpBand->rcCapImage,
1052 lpBand->rcBand.left, lpBand->rcBand.top+xoff,
1053 lpBand->rcBand.right, lpBand->rcBand.top+xoff);
1056 /* image is visible */
1057 if (lpBand->fStatus & HAS_IMAGE) {
1058 lpBand->fDraw |= DRAW_IMAGE;
1060 lpBand->rcCapImage.right = lpBand->rcCapImage.left + infoPtr->imageSize.cx;
1061 lpBand->rcCapImage.bottom += infoPtr->imageSize.cy;
1063 /* set initial caption text rectangle */
1064 SetRect (&lpBand->rcCapText,
1065 lpBand->rcBand.left, lpBand->rcCapImage.bottom+REBAR_POST_IMAGE,
1066 lpBand->rcBand.right, lpBand->rcBand.top+lpBand->cxHeader);
1067 /* update band height *
1068 if (lpBand->uMinHeight < infoPtr->imageSize.cx + 2) {
1069 lpBand->uMinHeight = infoPtr->imageSize.cx + 2;
1070 lpBand->rcBand.right = lpBand->rcBand.left + lpBand->uMinHeight;
1074 /* set initial caption text rectangle */
1075 SetRect (&lpBand->rcCapText,
1076 lpBand->rcBand.left, lpBand->rcCapImage.bottom,
1077 lpBand->rcBand.right, lpBand->rcBand.top+lpBand->cxHeader);
1080 /* text is visible */
1081 if ((lpBand->fStatus & HAS_TEXT) && !(lpBand->fStyle & RBBS_HIDETITLE)) {
1082 lpBand->fDraw |= DRAW_TEXT;
1083 lpBand->rcCapText.bottom = max(lpBand->rcCapText.top,
1084 lpBand->rcCapText.bottom);
1087 /* set initial child window rectangle if there is a child */
1088 if (lpBand->fMask & RBBIM_CHILD) {
1089 yoff = lpBand->offChild.cx;
1090 xoff = lpBand->offChild.cy;
1091 SetRect (&lpBand->rcChild,
1092 lpBand->rcBand.left+xoff, lpBand->rcBand.top+lpBand->cxHeader,
1093 lpBand->rcBand.right-xoff, lpBand->rcBand.bottom-yoff);
1096 SetRect (&lpBand->rcChild,
1097 lpBand->rcBand.left, lpBand->rcBand.top+lpBand->cxHeader,
1098 lpBand->rcBand.right, lpBand->rcBand.bottom);
1101 /* flag if notify required and invalidate rectangle */
1103 ((oldChild.right-oldChild.left != lpBand->rcChild.right-lpBand->rcChild.left) ||
1104 (oldChild.bottom-oldChild.top != lpBand->rcChild.bottom-lpBand->rcChild.top))) {
1105 TRACE("Child rectangle changed for band %u\n", i);
1106 TRACE(" from (%ld,%ld)-(%ld,%ld) to (%ld,%ld)-(%ld,%ld)\n",
1107 oldChild.left, oldChild.top,
1108 oldChild.right, oldChild.bottom,
1109 lpBand->rcChild.left, lpBand->rcChild.top,
1110 lpBand->rcChild.right, lpBand->rcChild.bottom);
1112 if (lpBand->fDraw & NTF_INVALIDATE) {
1113 TRACE("invalidating (%ld,%ld)-(%ld,%ld)\n",
1114 lpBand->rcBand.left,
1116 lpBand->rcBand.right + ((lpBand->fDraw & DRAW_BOTTOMSEP) ? SEP_WIDTH_SIZE : 0),
1117 lpBand->rcBand.bottom + ((lpBand->fDraw & DRAW_RIGHTSEP) ? SEP_WIDTH_SIZE : 0));
1118 lpBand->fDraw &= ~NTF_INVALIDATE;
1119 work = lpBand->rcBand;
1120 if (lpBand->fDraw & DRAW_RIGHTSEP) work.bottom += SEP_WIDTH_SIZE;
1121 if (lpBand->fDraw & DRAW_BOTTOMSEP) work.right += SEP_WIDTH_SIZE;
1122 InvalidateRect(infoPtr->hwndSelf, &work, TRUE);
1130 REBAR_ForceResize (REBAR_INFO *infoPtr)
1131 /* Function: This changes the size of the REBAR window to that */
1132 /* calculated by REBAR_Layout. */
1135 INT x, y, width, height;
1136 INT xedge = GetSystemMetrics(SM_CXEDGE);
1137 INT yedge = GetSystemMetrics(SM_CYEDGE);
1139 GetClientRect (infoPtr->hwndSelf, &rc);
1141 TRACE( " old [%ld x %ld], new [%ld x %ld], client [%ld x %ld]\n",
1142 infoPtr->oldSize.cx, infoPtr->oldSize.cy,
1143 infoPtr->calcSize.cx, infoPtr->calcSize.cy,
1144 rc.right, rc.bottom);
1146 /* If we need to shrink client, then skip size test */
1147 if ((infoPtr->calcSize.cy >= rc.bottom) &&
1148 (infoPtr->calcSize.cx >= rc.right)) {
1150 /* if size did not change then skip process */
1151 if ((infoPtr->oldSize.cx == infoPtr->calcSize.cx) &&
1152 (infoPtr->oldSize.cy == infoPtr->calcSize.cy) &&
1153 !(infoPtr->fStatus & RESIZE_ANYHOW))
1155 TRACE("skipping reset\n");
1160 infoPtr->fStatus &= ~RESIZE_ANYHOW;
1161 /* Set flag to ignore next WM_SIZE message */
1162 infoPtr->fStatus |= AUTO_RESIZE;
1169 if (infoPtr->dwStyle & WS_BORDER) {
1174 if (!(infoPtr->dwStyle & CCS_NOPARENTALIGN)) {
1175 INT mode = infoPtr->dwStyle & (CCS_VERT | CCS_TOP | CCS_BOTTOM);
1178 GetClientRect(GetParent(infoPtr->hwndSelf), &rcPcl);
1181 /* _TOP sets width to parents width */
1182 width += (rcPcl.right - rcPcl.left);
1183 height += infoPtr->calcSize.cy;
1184 x += ((infoPtr->dwStyle & WS_BORDER) ? -xedge : 0);
1185 y += ((infoPtr->dwStyle & WS_BORDER) ? -yedge : 0);
1186 y += ((infoPtr->dwStyle & CCS_NODIVIDER) ? 0 : REBAR_DIVIDER);
1189 /* FIXME: wrong wrong wrong */
1190 /* _BOTTOM sets width to parents width */
1191 width += (rcPcl.right - rcPcl.left);
1192 height += infoPtr->calcSize.cy;
1194 y = rcPcl.bottom - height + 1;
1197 /* _LEFT sets height to parents height */
1198 width += infoPtr->calcSize.cx;
1199 height += (rcPcl.bottom - rcPcl.top);
1200 x += ((infoPtr->dwStyle & WS_BORDER) ? -xedge : 0);
1201 x += ((infoPtr->dwStyle & CCS_NODIVIDER) ? 0 : REBAR_DIVIDER);
1202 y += ((infoPtr->dwStyle & WS_BORDER) ? -yedge : 0);
1205 /* FIXME: wrong wrong wrong */
1206 /* _RIGHT sets height to parents height */
1207 width += infoPtr->calcSize.cx;
1208 height += (rcPcl.bottom - rcPcl.top);
1209 x = rcPcl.right - width + 1;
1213 width += infoPtr->calcSize.cx;
1214 height += infoPtr->calcSize.cy;
1218 width += infoPtr->calcSize.cx;
1219 height += infoPtr->calcSize.cy;
1220 x = infoPtr->origin.x;
1221 y = infoPtr->origin.y;
1224 TRACE("hwnd %p, style=%08lx, setting at (%d,%d) for (%d,%d)\n",
1225 infoPtr->hwndSelf, infoPtr->dwStyle,
1226 x, y, width, height);
1227 SetWindowPos (infoPtr->hwndSelf, 0, x, y, width, height,
1229 infoPtr->fStatus &= ~AUTO_RESIZE;
1234 REBAR_MoveChildWindows (REBAR_INFO *infoPtr, UINT start, UINT endplus)
1237 CHAR szClassName[40];
1239 NMREBARCHILDSIZE rbcz;
1243 if (!(deferpos = BeginDeferWindowPos(infoPtr->uNumBands)))
1244 ERR("BeginDeferWindowPos returned NULL\n");
1246 for (i = start; i < endplus; i++) {
1247 lpBand = &infoPtr->bands[i];
1249 if (HIDDENBAND(lpBand)) continue;
1250 if (lpBand->hwndChild) {
1251 TRACE("hwndChild = %p\n", lpBand->hwndChild);
1253 /* Always geterate the RBN_CHILDSIZE even it child
1256 rbcz.wID = lpBand->wID;
1257 rbcz.rcChild = lpBand->rcChild;
1258 rbcz.rcBand = lpBand->rcBand;
1259 if (infoPtr->dwStyle & CCS_VERT)
1260 rbcz.rcBand.top += lpBand->cxHeader;
1262 rbcz.rcBand.left += lpBand->cxHeader;
1263 REBAR_Notify ((NMHDR *)&rbcz, infoPtr, RBN_CHILDSIZE);
1264 if (!EqualRect (&lpBand->rcChild, &rbcz.rcChild)) {
1265 TRACE("Child rect changed by NOTIFY for band %u\n", i);
1266 TRACE(" from (%ld,%ld)-(%ld,%ld) to (%ld,%ld)-(%ld,%ld)\n",
1267 lpBand->rcChild.left, lpBand->rcChild.top,
1268 lpBand->rcChild.right, lpBand->rcChild.bottom,
1269 rbcz.rcChild.left, rbcz.rcChild.top,
1270 rbcz.rcChild.right, rbcz.rcChild.bottom);
1271 lpBand->rcChild = rbcz.rcChild; /* *** ??? */
1274 /* native (IE4 in "Favorites" frame **1) does:
1275 * SetRect (&rc, -1, -1, -1, -1)
1276 * EqualRect (&rc,band->rc???)
1278 * CopyRect (band->rc????, &rc)
1279 * set flag outside of loop
1282 GetClassNameA (lpBand->hwndChild, szClassName, 40);
1283 if (!lstrcmpA (szClassName, "ComboBox") ||
1284 !lstrcmpA (szClassName, WC_COMBOBOXEXA)) {
1285 INT nEditHeight, yPos;
1288 /* special placement code for combo or comboex box */
1291 /* get size of edit line */
1292 GetWindowRect (lpBand->hwndChild, &rc);
1293 nEditHeight = rc.bottom - rc.top;
1294 yPos = (lpBand->rcChild.bottom + lpBand->rcChild.top - nEditHeight)/2;
1296 /* center combo box inside child area */
1297 TRACE("moving child (Combo(Ex)) %p to (%ld,%d) for (%ld,%d)\n",
1299 lpBand->rcChild.left, yPos,
1300 lpBand->rcChild.right - lpBand->rcChild.left,
1302 deferpos = DeferWindowPos (deferpos, lpBand->hwndChild, HWND_TOP,
1303 lpBand->rcChild.left,
1304 /*lpBand->rcChild.top*/ yPos,
1305 lpBand->rcChild.right - lpBand->rcChild.left,
1309 ERR("DeferWindowPos returned NULL\n");
1312 TRACE("moving child (Other) %p to (%ld,%ld) for (%ld,%ld)\n",
1314 lpBand->rcChild.left, lpBand->rcChild.top,
1315 lpBand->rcChild.right - lpBand->rcChild.left,
1316 lpBand->rcChild.bottom - lpBand->rcChild.top);
1317 deferpos = DeferWindowPos (deferpos, lpBand->hwndChild, HWND_TOP,
1318 lpBand->rcChild.left,
1319 lpBand->rcChild.top,
1320 lpBand->rcChild.right - lpBand->rcChild.left,
1321 lpBand->rcChild.bottom - lpBand->rcChild.top,
1324 ERR("DeferWindowPos returned NULL\n");
1328 if (!EndDeferWindowPos(deferpos))
1329 ERR("EndDeferWindowPos returned NULL\n");
1331 if (infoPtr->DoRedraw)
1332 UpdateWindow (infoPtr->hwndSelf);
1334 if (infoPtr->fStatus & NTF_HGHTCHG) {
1335 infoPtr->fStatus &= ~NTF_HGHTCHG;
1337 * We need to force a resize here, because some applications
1338 * try to get the rebar size during processing of the
1339 * RBN_HEIGHTCHANGE notification.
1341 REBAR_ForceResize (infoPtr);
1342 REBAR_Notify (&heightchange, infoPtr, RBN_HEIGHTCHANGE);
1345 /* native (from **1 above) does:
1346 * UpdateWindow(rebar)
1348 * RBN_HEIGHTCHANGE if necessary
1349 * if ret from any EqualRect was 0
1350 * Goto "BeginDeferWindowPos"
1357 REBAR_Layout (REBAR_INFO *infoPtr, LPRECT lpRect, BOOL notify, BOOL resetclient)
1358 /* Function: This routine is resposible for laying out all */
1359 /* the bands in a rebar. It assigns each band to a row and*/
1360 /* determines when to start a new row. */
1362 REBAR_BAND *lpBand, *prevBand;
1363 RECT rcClient, rcAdj;
1364 INT initx, inity, x, y, cx, cxsep, mmcy, mcy, clientcx, clientcy;
1365 INT adjcx, adjcy, row, rightx, bottomy, origheight;
1366 UINT i, j, rowstart, origrows, cntonrow;
1369 if (!(infoPtr->fStatus & BAND_NEEDS_LAYOUT)) {
1370 TRACE("no layout done. No band changed.\n");
1371 REBAR_DumpBand (infoPtr);
1374 infoPtr->fStatus &= ~BAND_NEEDS_LAYOUT;
1375 if (!infoPtr->DoRedraw) infoPtr->fStatus |= BAND_NEEDS_REDRAW;
1377 GetClientRect (infoPtr->hwndSelf, &rcClient);
1378 TRACE("Client is (%ld,%ld)-(%ld,%ld)\n",
1379 rcClient.left, rcClient.top, rcClient.right, rcClient.bottom);
1383 TRACE("adjustment rect is (%ld,%ld)-(%ld,%ld)\n",
1384 rcAdj.left, rcAdj.top, rcAdj.right, rcAdj.bottom);
1387 CopyRect (&rcAdj, &rcClient);
1390 clientcx = rcClient.right - rcClient.left;
1391 clientcy = rcClient.bottom - rcClient.top;
1392 adjcx = rcAdj.right - rcAdj.left;
1393 adjcy = rcAdj.bottom - rcAdj.top;
1395 TRACE("window client rect will be set to adj rect\n");
1400 if (!infoPtr->DoRedraw && (clientcx == 0) && (clientcy == 0)) {
1401 ERR("no redraw and client is zero, skip layout\n");
1402 infoPtr->fStatus |= BAND_NEEDS_LAYOUT;
1406 /* save height of original control */
1407 if (infoPtr->dwStyle & CCS_VERT)
1408 origheight = infoPtr->calcSize.cx;
1410 origheight = infoPtr->calcSize.cy;
1411 origrows = infoPtr->uNumRows;
1416 /* ******* Start Phase 1 - all bands on row at minimum size ******* */
1418 TRACE("band loop constants, clientcx=%d, clientcy=%d, adjcx=%d, adjcy=%d\n",
1419 clientcx, clientcy, adjcx, adjcy);
1429 for (i = 0; i < infoPtr->uNumBands; i++) {
1430 lpBand = &infoPtr->bands[i];
1434 SetRectEmpty(&lpBand->rcChevron);
1436 if (HIDDENBAND(lpBand)) continue;
1438 lpBand->rcoldBand = lpBand->rcBand;
1440 /* Set the offset of the child window */
1441 if ((lpBand->fMask & RBBIM_CHILD) &&
1442 !(lpBand->fStyle & RBBS_FIXEDSIZE)) {
1443 lpBand->offChild.cx = ((lpBand->fStyle & RBBS_CHILDEDGE) ? 4 : 0);
1445 lpBand->offChild.cy = ((lpBand->fStyle & RBBS_CHILDEDGE) ? 2 : 0);
1447 /* separator from previous band */
1448 cxsep = (cntonrow == 0) ? 0 : SEP_WIDTH;
1451 if (infoPtr->dwStyle & CCS_VERT)
1452 dobreak = (y + cx + cxsep > adjcy);
1454 dobreak = (x + cx + cxsep > adjcx);
1456 /* This is the check for whether we need to start a new row */
1457 if ( ( (lpBand->fStyle & RBBS_BREAK) && (i != 0) ) ||
1458 ( ((infoPtr->dwStyle & CCS_VERT) ? (y != 0) : (x != 0)) && dobreak)) {
1460 for (j = rowstart; j < i; j++) {
1462 lpB = &infoPtr->bands[j];
1463 if (infoPtr->dwStyle & CCS_VERT) {
1464 lpB->rcBand.right = lpB->rcBand.left + mcy;
1467 lpB->rcBand.bottom = lpB->rcBand.top + mcy;
1471 TRACE("P1 Spliting to new row %d on band %u\n", row+1, i);
1472 if (infoPtr->dwStyle & CCS_VERT) {
1474 x += (mcy + SEP_WIDTH);
1478 y += (mcy + SEP_WIDTH);
1490 if (mcy < lpBand->lcy + REBARSPACE(lpBand))
1491 mcy = lpBand->lcy + REBARSPACE(lpBand);
1493 /* if boundary rect specified then limit mcy */
1495 if (infoPtr->dwStyle & CCS_VERT) {
1496 if (x+mcy > adjcx) {
1498 TRACE("P1 row %u limiting mcy=%d, adjcx=%d, x=%d\n",
1503 if (y+mcy > adjcy) {
1505 TRACE("P1 row %u limiting mcy=%d, adjcy=%d, y=%d\n",
1511 TRACE("P1 band %u, row %d, x=%d, y=%d, cxsep=%d, cx=%d\n",
1514 if (infoPtr->dwStyle & CCS_VERT) {
1515 /* bound the bottom side if we have a bounding rectangle */
1517 bottomy = (lpRect) ? min(clientcy, y+cxsep+cx) : y+cxsep+cx;
1518 lpBand->rcBand.left = x;
1519 lpBand->rcBand.right = x + min(mcy,
1520 lpBand->lcy+REBARSPACE(lpBand));
1521 lpBand->rcBand.top = min(bottomy, y + cxsep);
1522 lpBand->rcBand.bottom = bottomy;
1523 lpBand->uMinHeight = lpBand->lcy;
1527 /* bound the right side if we have a bounding rectangle */
1528 rightx = (lpRect) ? min(clientcx, x+cxsep+cx) : x+cxsep+cx;
1530 lpBand->rcBand.left = min(rightx, x + cxsep);
1531 lpBand->rcBand.right = rightx;
1532 lpBand->rcBand.top = y;
1533 lpBand->rcBand.bottom = y + min(mcy,
1534 lpBand->lcy+REBARSPACE(lpBand));
1535 lpBand->uMinHeight = lpBand->lcy;
1538 TRACE("P1 band %u, row %d, (%ld,%ld)-(%ld,%ld)\n",
1540 lpBand->rcBand.left, lpBand->rcBand.top,
1541 lpBand->rcBand.right, lpBand->rcBand.bottom);
1545 } /* for (i = 0; i < infoPtr->uNumBands... */
1547 if (infoPtr->dwStyle & CCS_VERT)
1552 for (j = rowstart; j < infoPtr->uNumBands; j++) {
1553 lpBand = &infoPtr->bands[j];
1554 if (infoPtr->dwStyle & CCS_VERT) {
1555 lpBand->rcBand.right = lpBand->rcBand.left + mcy;
1558 lpBand->rcBand.bottom = lpBand->rcBand.top + mcy;
1562 if (infoPtr->uNumBands)
1563 infoPtr->uNumRows = row;
1565 /* ******* End Phase 1 - all bands on row at minimum size ******* */
1568 /* ******* Start Phase 1a - Adjust heights for RBS_VARHEIGHT off ******* */
1571 if (!(infoPtr->dwStyle & RBS_VARHEIGHT)) {
1574 /* get the max height of all bands */
1575 for (i=0; i<infoPtr->uNumBands; i++) {
1576 lpBand = &infoPtr->bands[i];
1577 if (HIDDENBAND(lpBand)) continue;
1578 if (infoPtr->dwStyle & CCS_VERT)
1579 mmcy = max(mmcy, lpBand->rcBand.right - lpBand->rcBand.left);
1581 mmcy = max(mmcy, lpBand->rcBand.bottom - lpBand->rcBand.top);
1584 /* now adjust all rectangles by using the height found above */
1587 for (i=0; i<infoPtr->uNumBands; i++) {
1588 lpBand = &infoPtr->bands[i];
1589 if (HIDDENBAND(lpBand)) continue;
1590 if (lpBand->iRow != row)
1591 xy += (mmcy + SEP_WIDTH);
1592 if (infoPtr->dwStyle & CCS_VERT) {
1593 lpBand->rcBand.left = xy;
1594 lpBand->rcBand.right = xy + mmcy;
1597 lpBand->rcBand.top = xy;
1598 lpBand->rcBand.bottom = xy + mmcy;
1602 /* set the x/y values to the correct maximum */
1603 if (infoPtr->dwStyle & CCS_VERT)
1609 /* ******* End Phase 1a - Adjust heights for RBS_VARHEIGHT off ******* */
1612 /* ******* Start Phase 2 - split rows till adjustment height full ******* */
1614 /* assumes that the following variables contain: */
1615 /* y/x current height/width of all rows */
1617 INT i, prev_rh, new_rh, adj_rh, prev_idx, current_idx;
1618 REBAR_BAND *prev, *current, *walk;
1621 /* FIXME: problem # 2 */
1622 if (((infoPtr->dwStyle & CCS_VERT) ?
1624 (x < adjcx) : (y < adjcy)
1626 (adjcx - x > 5) : (adjcy - y > 4)
1629 (infoPtr->uNumBands > 1)) {
1630 for (i=(INT)infoPtr->uNumBands-2; i>=0; i--) {
1631 TRACE("P2 adjcx=%d, adjcy=%d, x=%d, y=%d\n",
1632 adjcx, adjcy, x, y);
1634 /* find the current band (starts at i+1) */
1635 current = &infoPtr->bands[i+1];
1637 while (HIDDENBAND(current)) {
1639 if (i < 0) break; /* out of bands */
1640 current = &infoPtr->bands[i+1];
1643 if (i < 0) break; /* out of bands */
1645 /* now find the prev band (starts at i) */
1646 prev = &infoPtr->bands[i];
1648 while (HIDDENBAND(prev)) {
1650 if (i < 0) break; /* out of bands */
1651 prev = &infoPtr->bands[i];
1654 if (i < 0) break; /* out of bands */
1656 prev_rh = ircBw(prev);
1657 if (prev->iRow == current->iRow) {
1658 new_rh = (infoPtr->dwStyle & RBS_VARHEIGHT) ?
1659 current->lcy + REBARSPACE(current) :
1661 adj_rh = new_rh + SEP_WIDTH;
1662 infoPtr->uNumRows++;
1663 current->fDraw |= NTF_INVALIDATE;
1665 if (infoPtr->dwStyle & CCS_VERT) {
1666 current->rcBand.top = inity;
1667 current->rcBand.bottom = clientcy;
1668 current->rcBand.left += (prev_rh + SEP_WIDTH);
1669 current->rcBand.right = current->rcBand.left + new_rh;
1673 current->rcBand.left = initx;
1674 current->rcBand.right = clientcx;
1675 current->rcBand.top += (prev_rh + SEP_WIDTH);
1676 current->rcBand.bottom = current->rcBand.top + new_rh;
1679 TRACE("P2 moving band %d to own row at (%ld,%ld)-(%ld,%ld)\n",
1681 current->rcBand.left, current->rcBand.top,
1682 current->rcBand.right, current->rcBand.bottom);
1683 TRACE("P2 prev band %d at (%ld,%ld)-(%ld,%ld)\n",
1685 prev->rcBand.left, prev->rcBand.top,
1686 prev->rcBand.right, prev->rcBand.bottom);
1687 TRACE("P2 values: prev_rh=%d, new_rh=%d, adj_rh=%d\n",
1688 prev_rh, new_rh, adj_rh);
1689 /* for bands below current adjust row # and top/bottom */
1690 for (j = current_idx+1; j<infoPtr->uNumBands; j++) {
1691 walk = &infoPtr->bands[j];
1692 if (HIDDENBAND(walk)) continue;
1693 walk->fDraw |= NTF_INVALIDATE;
1695 if (infoPtr->dwStyle & CCS_VERT) {
1696 walk->rcBand.left += adj_rh;
1697 walk->rcBand.right += adj_rh;
1700 walk->rcBand.top += adj_rh;
1701 walk->rcBand.bottom += adj_rh;
1704 if ((infoPtr->dwStyle & CCS_VERT) ? (x >= adjcx) : (y >= adjcy))
1705 break; /* all done */
1711 /* ******* End Phase 2 - split rows till adjustment height full ******* */
1714 /* ******* Start Phase 2a - mark first and last band in each ******* */
1717 for (i = 0; i < infoPtr->uNumBands; i++) {
1718 lpBand = &infoPtr->bands[i];
1719 if (HIDDENBAND(lpBand))
1722 lpBand->fDraw |= DRAW_FIRST_IN_ROW;
1725 else if( prevBand->iRow == lpBand->iRow )
1728 prevBand->fDraw |= DRAW_LAST_IN_ROW;
1729 lpBand->fDraw |= DRAW_FIRST_IN_ROW;
1734 prevBand->fDraw |= DRAW_LAST_IN_ROW;
1736 /* ******* End Phase 2a - mark first and last band in each ******* */
1739 /* ******* Start Phase 2b - adjust all bands for height full ******* */
1740 /* assumes that the following variables contain: */
1741 /* y/x current height/width of all rows */
1742 /* clientcy/clientcx height/width of client area */
1744 if (((infoPtr->dwStyle & CCS_VERT) ? clientcx > x : clientcy > y) &&
1745 infoPtr->uNumBands) {
1749 diff = (infoPtr->dwStyle & CCS_VERT) ? clientcx - x : clientcy - y;
1751 /* iterate backwards thru the rows */
1752 for (i = infoPtr->uNumBands-1; i>=0; i--) {
1753 lpBand = &infoPtr->bands[i];
1754 if(HIDDENBAND(lpBand)) continue;
1756 /* if row has more than 1 band, ignore it */
1757 if( !(lpBand->fDraw&DRAW_FIRST_IN_ROW) )
1759 if( !(lpBand->fDraw&DRAW_LAST_IN_ROW) )
1762 if (lpBand->fMask & RBBS_VARIABLEHEIGHT) continue;
1763 if (((INT)lpBand->cyMaxChild < 1) ||
1764 ((INT)lpBand->cyIntegral < 1)) {
1765 if (lpBand->cyMaxChild + lpBand->cyIntegral == 0) continue;
1766 ERR("P2b band %u RBBS_VARIABLEHEIGHT set but cyMax=%d, cyInt=%d\n",
1767 i, lpBand->cyMaxChild, lpBand->cyIntegral);
1770 /* j is now the maximum height/width in the client area */
1771 j = ((diff / lpBand->cyIntegral) * lpBand->cyIntegral) +
1773 if (j > lpBand->cyMaxChild + REBARSPACE(lpBand))
1774 j = lpBand->cyMaxChild + REBARSPACE(lpBand);
1775 diff -= (j - ircBw(lpBand));
1776 if (infoPtr->dwStyle & CCS_VERT)
1777 lpBand->rcBand.right = lpBand->rcBand.left + j;
1779 lpBand->rcBand.bottom = lpBand->rcBand.top + j;
1780 TRACE("P2b band %d, row %d changed to (%ld,%ld)-(%ld,%ld)\n",
1782 lpBand->rcBand.left, lpBand->rcBand.top,
1783 lpBand->rcBand.right, lpBand->rcBand.bottom);
1784 if (diff <= 0) break;
1787 ERR("P2b allocated more than available, diff=%d\n", diff);
1790 if (infoPtr->dwStyle & CCS_VERT)
1791 x = clientcx - diff;
1793 y = clientcy - diff;
1796 /* ******* End Phase 2b - adjust all bands for height full ******* */
1799 /* ******* Start Phase 3 - adjust all bands for width full ******* */
1801 if (infoPtr->uNumBands) {
1804 /* If RBS_BANDBORDERS set then indicate to draw bottom separator */
1805 /* on all bands in all rows but last row. */
1806 /* Also indicate to draw the right separator for each band in */
1807 /* each row but the rightmost band. */
1808 if (infoPtr->dwStyle & RBS_BANDBORDERS) {
1810 for (i=0; i<infoPtr->uNumBands; i++) {
1811 lpBand = &infoPtr->bands[i];
1812 if (HIDDENBAND(lpBand))
1815 /* not righthand bands */
1816 if( !(lpBand->fDraw & DRAW_LAST_IN_ROW) )
1817 lpBand->fDraw |= DRAW_RIGHTSEP;
1819 /* not the last row */
1820 if( lpBand->iRow != infoPtr->uNumRows )
1821 lpBand->fDraw |= DRAW_BOTTOMSEP;
1825 /* Distribute the extra space on the horizontal and adjust */
1826 /* all bands in row to same height. */
1829 for (i=0; i<infoPtr->uNumBands; i++) {
1831 lpBand = &infoPtr->bands[i];
1833 if( lpBand->fDraw & DRAW_FIRST_IN_ROW )
1839 if ( (mcy < ircBw(lpBand)) && !HIDDENBAND(lpBand) )
1840 mcy = ircBw(lpBand);
1842 if( lpBand->fDraw & DRAW_LAST_IN_ROW )
1844 TRACE("P3 processing row %d, starting band %d, ending band %d\n",
1845 lpBand->iRow, startband, i);
1847 ERR("Last band %d with no first, row %d\n", i, lpBand->iRow);
1849 REBAR_AdjustBands (infoPtr, startband, i,
1850 (infoPtr->dwStyle & CCS_VERT) ?
1851 clientcy : clientcx, mcy);
1855 /* Calculate the other rectangles in each band */
1856 if (infoPtr->dwStyle & CCS_VERT) {
1857 REBAR_CalcVertBand (infoPtr, 0, infoPtr->uNumBands,
1861 REBAR_CalcHorzBand (infoPtr, 0, infoPtr->uNumBands,
1866 /* ******* End Phase 3 - adjust all bands for width full ******* */
1868 /* now compute size of Rebar itself */
1869 infoPtr->oldSize = infoPtr->calcSize;
1870 if (infoPtr->uNumBands == 0) {
1871 /* we have no bands, so make size the size of client */
1875 if (infoPtr->dwStyle & CCS_VERT) {
1876 if( x < REBAR_MINSIZE )
1878 infoPtr->calcSize.cx = x;
1879 infoPtr->calcSize.cy = clientcy;
1880 TRACE("vert, notify=%d, x=%d, origheight=%d\n",
1881 notify, x, origheight);
1882 if (notify && (x != origheight)) infoPtr->fStatus |= NTF_HGHTCHG;
1885 if( y < REBAR_MINSIZE )
1887 infoPtr->calcSize.cx = clientcx;
1888 infoPtr->calcSize.cy = y;
1889 TRACE("horz, notify=%d, y=%d, origheight=%d\n",
1890 notify, y, origheight);
1891 if (notify && (y != origheight)) infoPtr->fStatus |= NTF_HGHTCHG;
1894 REBAR_DumpBand (infoPtr);
1896 REBAR_MoveChildWindows (infoPtr, 0, infoPtr->uNumBands);
1898 REBAR_ForceResize (infoPtr);
1903 REBAR_ValidateBand (REBAR_INFO *infoPtr, REBAR_BAND *lpBand)
1904 /* Function: This routine evaluates the band specs supplied */
1905 /* by the user and updates the following 5 fields in */
1906 /* the internal band structure: cxHeader, lcx, lcy, hcx, hcy*/
1913 lpBand->fStatus = 0;
1921 /* Data comming in from users into the cx... and cy... fields */
1922 /* may be bad, just garbage, because the user never clears */
1923 /* the fields. RB_{SET|INSERT}BAND{A|W} just passes the data */
1924 /* along if the fields exist in the input area. Here we must */
1925 /* determine if the data is valid. I have no idea how MS does */
1926 /* the validation, but it does because the RB_GETBANDINFO */
1927 /* returns a 0 when I know the sample program passed in an */
1928 /* address. Here I will use the algorithim that if the value */
1929 /* is greater than 65535 then it is bad and replace it with */
1930 /* a zero. Feel free to improve the algorithim. - GA 12/2000 */
1931 if (lpBand->cxMinChild > 65535) lpBand->cxMinChild = 0;
1932 if (lpBand->cyMinChild > 65535) lpBand->cyMinChild = 0;
1933 if (lpBand->cx > 65535) lpBand->cx = 0;
1934 if (lpBand->cyChild > 65535) lpBand->cyChild = 0;
1935 if (lpBand->cyMaxChild > 65535) lpBand->cyMaxChild = 0;
1936 if (lpBand->cyIntegral > 65535) lpBand->cyIntegral = 0;
1937 if (lpBand->cxIdeal > 65535) lpBand->cxIdeal = 0;
1938 if (lpBand->cxHeader > 65535) lpBand->cxHeader = 0;
1940 /* FIXME: probably should only set NEEDS_LAYOUT flag when */
1941 /* values change. Till then always set it. */
1942 TRACE("setting NEEDS_LAYOUT\n");
1943 infoPtr->fStatus |= BAND_NEEDS_LAYOUT;
1945 /* Header is where the image, text and gripper exist */
1946 /* in the band and preceed the child window. */
1948 /* count number of non-FIXEDSIZE and non-Hidden bands */
1950 for (i=0; i<infoPtr->uNumBands; i++){
1951 tBand = &infoPtr->bands[i];
1952 if (!HIDDENBAND(tBand) && !(tBand->fStyle & RBBS_FIXEDSIZE))
1956 /* calculate gripper rectangle */
1957 if ( (!(lpBand->fStyle & RBBS_NOGRIPPER)) &&
1958 ( (lpBand->fStyle & RBBS_GRIPPERALWAYS) ||
1959 ( !(lpBand->fStyle & RBBS_FIXEDSIZE) && (nonfixed > 1)))
1961 lpBand->fStatus |= HAS_GRIPPER;
1962 if (infoPtr->dwStyle & CCS_VERT)
1963 if (infoPtr->dwStyle & RBS_VERTICALGRIPPER)
1964 header += (GRIPPER_HEIGHT + REBAR_PRE_GRIPPER);
1966 header += (GRIPPER_WIDTH + REBAR_PRE_GRIPPER);
1968 header += (REBAR_PRE_GRIPPER + GRIPPER_WIDTH);
1969 /* Always have 4 pixels before anything else */
1970 header += REBAR_ALWAYS_SPACE;
1973 /* image is visible */
1974 if ((lpBand->fMask & RBBIM_IMAGE) && (infoPtr->himl)) {
1975 lpBand->fStatus |= HAS_IMAGE;
1976 if (infoPtr->dwStyle & CCS_VERT) {
1977 header += (infoPtr->imageSize.cy + REBAR_POST_IMAGE);
1978 lpBand->lcy = infoPtr->imageSize.cx + 2;
1981 header += (infoPtr->imageSize.cx + REBAR_POST_IMAGE);
1982 lpBand->lcy = infoPtr->imageSize.cy + 2;
1986 /* text is visible */
1987 if ((lpBand->fMask & RBBIM_TEXT) && (lpBand->lpText) &&
1988 !(lpBand->fStyle & RBBS_HIDETITLE)) {
1989 HDC hdc = GetDC (0);
1990 HFONT hOldFont = SelectObject (hdc, infoPtr->hFont);
1993 lpBand->fStatus |= HAS_TEXT;
1994 GetTextExtentPoint32W (hdc, lpBand->lpText,
1995 lstrlenW (lpBand->lpText), &size);
1996 header += ((infoPtr->dwStyle & CCS_VERT) ? (size.cy + REBAR_POST_TEXT) : (size.cx + REBAR_POST_TEXT));
1997 textheight = (infoPtr->dwStyle & CCS_VERT) ? 0 : size.cy;
1999 SelectObject (hdc, hOldFont);
2003 /* if no gripper but either image or text, then leave space */
2004 if ((lpBand->fStatus & (HAS_IMAGE | HAS_TEXT)) &&
2005 !(lpBand->fStatus & HAS_GRIPPER)) {
2006 header += REBAR_ALWAYS_SPACE;
2009 /* check if user overrode the header value */
2010 if (!(lpBand->fMask & RBBIM_HEADERSIZE))
2011 lpBand->cxHeader = header;
2014 /* Now compute minimum size of child window */
2015 lpBand->offChild.cx = 0;
2016 lpBand->offChild.cy = 0;
2017 lpBand->lcy = textheight;
2018 lpBand->ccy = lpBand->lcy;
2019 if (lpBand->fMask & RBBIM_CHILDSIZE) {
2020 lpBand->lcx = lpBand->cxMinChild;
2022 /* Set the .cy values for CHILDSIZE case */
2023 lpBand->lcy = max(lpBand->lcy, lpBand->cyMinChild);
2024 lpBand->ccy = lpBand->lcy;
2025 lpBand->hcy = lpBand->lcy;
2026 if (lpBand->cyMaxChild != 0xffffffff) {
2027 lpBand->hcy = lpBand->cyMaxChild;
2029 if (lpBand->cyChild != 0xffffffff)
2030 lpBand->ccy = max (lpBand->cyChild, lpBand->lcy);
2032 TRACE("_CHILDSIZE\n");
2034 if (lpBand->fMask & RBBIM_SIZE) {
2035 lpBand->hcx = max (lpBand->cx-lpBand->cxHeader, lpBand->lcx);
2039 lpBand->hcx = lpBand->lcx;
2040 lpBand->ccx = lpBand->hcx;
2042 /* make ->.cx include header size for _Layout */
2043 lpBand->lcx += lpBand->cxHeader;
2044 lpBand->ccx += lpBand->cxHeader;
2045 lpBand->hcx += lpBand->cxHeader;
2050 REBAR_CommonSetupBand (HWND hwnd, LPREBARBANDINFOA lprbbi, REBAR_BAND *lpBand)
2051 /* Function: This routine copies the supplied values from */
2052 /* user input (lprbbi) to the internal band structure. */
2053 /* It returns true if something changed and false if not. */
2055 BOOL bChanged = FALSE;
2057 lpBand->fMask |= lprbbi->fMask;
2059 if( (lprbbi->fMask & RBBIM_STYLE) &&
2060 (lpBand->fStyle != lprbbi->fStyle ) )
2062 lpBand->fStyle = lprbbi->fStyle;
2066 if( (lprbbi->fMask & RBBIM_COLORS) &&
2067 ( ( lpBand->clrFore != lprbbi->clrFore ) ||
2068 ( lpBand->clrBack != lprbbi->clrBack ) ) )
2070 lpBand->clrFore = lprbbi->clrFore;
2071 lpBand->clrBack = lprbbi->clrBack;
2075 if( (lprbbi->fMask & RBBIM_IMAGE) &&
2076 ( lpBand->iImage != lprbbi->iImage ) )
2078 lpBand->iImage = lprbbi->iImage;
2082 if( (lprbbi->fMask & RBBIM_CHILD) &&
2083 (lprbbi->hwndChild != lpBand->hwndChild ) )
2085 if (lprbbi->hwndChild) {
2086 lpBand->hwndChild = lprbbi->hwndChild;
2087 lpBand->hwndPrevParent =
2088 SetParent (lpBand->hwndChild, hwnd);
2089 /* below in trace fro WinRAR */
2090 ShowWindow(lpBand->hwndChild, SW_SHOWNOACTIVATE | SW_SHOWNORMAL);
2091 /* above in trace fro WinRAR */
2094 TRACE("child: %p prev parent: %p\n",
2095 lpBand->hwndChild, lpBand->hwndPrevParent);
2096 lpBand->hwndChild = 0;
2097 lpBand->hwndPrevParent = 0;
2102 if( (lprbbi->fMask & RBBIM_CHILDSIZE) &&
2103 ( (lpBand->cxMinChild != lprbbi->cxMinChild) ||
2104 (lpBand->cyMinChild != lprbbi->cyMinChild ) ||
2105 ( (lprbbi->cbSize >= sizeof (REBARBANDINFOA)) &&
2106 ( (lpBand->cyChild != lprbbi->cyChild ) ||
2107 (lpBand->cyMaxChild != lprbbi->cyMaxChild ) ||
2108 (lpBand->cyIntegral != lprbbi->cyIntegral ) ) ) ||
2109 ( (lprbbi->cbSize < sizeof (REBARBANDINFOA)) &&
2110 ( (lpBand->cyChild ||
2111 lpBand->cyMaxChild ||
2112 lpBand->cyIntegral ) ) ) ) )
2114 lpBand->cxMinChild = lprbbi->cxMinChild;
2115 lpBand->cyMinChild = lprbbi->cyMinChild;
2116 if (lprbbi->cbSize >= sizeof (REBARBANDINFOA)) {
2117 lpBand->cyChild = lprbbi->cyChild;
2118 lpBand->cyMaxChild = lprbbi->cyMaxChild;
2119 lpBand->cyIntegral = lprbbi->cyIntegral;
2121 else { /* special case - these should be zeroed out since */
2122 /* RBBIM_CHILDSIZE added these in WIN32_IE >= 0x0400 */
2123 lpBand->cyChild = 0;
2124 lpBand->cyMaxChild = 0;
2125 lpBand->cyIntegral = 0;
2130 if( (lprbbi->fMask & RBBIM_SIZE) &&
2131 (lpBand->cx != lprbbi->cx ) )
2133 lpBand->cx = lprbbi->cx;
2137 if( (lprbbi->fMask & RBBIM_BACKGROUND) &&
2138 ( lpBand->hbmBack != lprbbi->hbmBack ) )
2140 lpBand->hbmBack = lprbbi->hbmBack;
2144 if( (lprbbi->fMask & RBBIM_ID) &&
2145 (lpBand->wID != lprbbi->wID ) )
2147 lpBand->wID = lprbbi->wID;
2151 /* check for additional data */
2152 if (lprbbi->cbSize >= sizeof (REBARBANDINFOA)) {
2153 if( (lprbbi->fMask & RBBIM_IDEALSIZE) &&
2154 ( lpBand->cxIdeal != lprbbi->cxIdeal ) )
2156 lpBand->cxIdeal = lprbbi->cxIdeal;
2160 if( (lprbbi->fMask & RBBIM_LPARAM) &&
2161 (lpBand->lParam != lprbbi->lParam ) )
2163 lpBand->lParam = lprbbi->lParam;
2167 if( (lprbbi->fMask & RBBIM_HEADERSIZE) &&
2168 (lpBand->cxHeader != lprbbi->cxHeader ) )
2170 lpBand->cxHeader = lprbbi->cxHeader;
2179 REBAR_InternalEraseBkGnd (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam, RECT *clip)
2180 /* Function: This erases the background rectangle by drawing */
2181 /* each band with its background color (or the default) and */
2182 /* draws each bands right separator if necessary. The row */
2183 /* separators are drawn on the first band of the next row. */
2188 HDC hdc = (HDC)wParam;
2190 COLORREF old = CLR_NONE, new;
2193 for(i=0; i<infoPtr->uNumBands; i++) {
2194 lpBand = &infoPtr->bands[i];
2195 if (HIDDENBAND(lpBand)) continue;
2197 /* draw band separator between rows */
2198 if (lpBand->iRow != oldrow) {
2199 oldrow = lpBand->iRow;
2200 if (lpBand->fDraw & DRAW_BOTTOMSEP) {
2202 rcRowSep = lpBand->rcBand;
2203 if (infoPtr->dwStyle & CCS_VERT) {
2204 rcRowSep.right += SEP_WIDTH_SIZE;
2205 rcRowSep.bottom = infoPtr->calcSize.cy;
2206 DrawEdge (hdc, &rcRowSep, EDGE_ETCHED, BF_RIGHT);
2209 rcRowSep.bottom += SEP_WIDTH_SIZE;
2210 rcRowSep.right = infoPtr->calcSize.cx;
2211 DrawEdge (hdc, &rcRowSep, EDGE_ETCHED, BF_BOTTOM);
2213 TRACE ("drawing band separator bottom (%ld,%ld)-(%ld,%ld)\n",
2214 rcRowSep.left, rcRowSep.top,
2215 rcRowSep.right, rcRowSep.bottom);
2219 /* draw band separator between bands in a row */
2220 if (lpBand->fDraw & DRAW_RIGHTSEP) {
2222 rcSep = lpBand->rcBand;
2223 if (infoPtr->dwStyle & CCS_VERT) {
2224 rcSep.bottom += SEP_WIDTH_SIZE;
2225 DrawEdge (hdc, &rcSep, EDGE_ETCHED, BF_BOTTOM);
2228 rcSep.right += SEP_WIDTH_SIZE;
2229 DrawEdge (hdc, &rcSep, EDGE_ETCHED, BF_RIGHT);
2231 TRACE("drawing band separator right (%ld,%ld)-(%ld,%ld)\n",
2232 rcSep.left, rcSep.top, rcSep.right, rcSep.bottom);
2235 /* draw the actual background */
2236 if (lpBand->clrBack != CLR_NONE) {
2237 new = (lpBand->clrBack == CLR_DEFAULT) ? infoPtr->clrBtnFace :
2240 /* testing only - make background green to see it */
2245 /* In the absence of documentation for Rebar vs. CLR_NONE,
2246 * we will use the default BtnFace color. Note documentation
2247 * exists for Listview and Imagelist.
2249 new = infoPtr->clrBtnFace;
2251 /* testing only - make background green to see it */
2255 old = SetBkColor (hdc, new);
2257 rect = lpBand->rcBand;
2258 TRACE("%s background color=0x%06lx, band (%ld,%ld)-(%ld,%ld), clip (%ld,%ld)-(%ld,%ld)\n",
2259 (lpBand->clrBack == CLR_NONE) ? "none" :
2260 ((lpBand->clrBack == CLR_DEFAULT) ? "dft" : ""),
2262 lpBand->rcBand.left,lpBand->rcBand.top,
2263 lpBand->rcBand.right,lpBand->rcBand.bottom,
2264 clip->left, clip->top,
2265 clip->right, clip->bottom);
2266 ExtTextOutA (hdc, 0, 0, ETO_OPAQUE, &rect, NULL, 0, 0);
2267 if (lpBand->clrBack != CLR_NONE)
2268 SetBkColor (hdc, old);
2274 REBAR_InternalHitTest (REBAR_INFO *infoPtr, const LPPOINT lpPt, UINT *pFlags, INT *pBand)
2280 GetClientRect (infoPtr->hwndSelf, &rect);
2282 *pFlags = RBHT_NOWHERE;
2283 if (PtInRect (&rect, *lpPt))
2285 if (infoPtr->uNumBands == 0) {
2286 *pFlags = RBHT_NOWHERE;
2293 /* somewhere inside */
2294 for (iCount = 0; iCount < infoPtr->uNumBands; iCount++) {
2295 lpBand = &infoPtr->bands[iCount];
2296 if (HIDDENBAND(lpBand)) continue;
2297 if (PtInRect (&lpBand->rcBand, *lpPt)) {
2300 if (PtInRect (&lpBand->rcGripper, *lpPt)) {
2301 *pFlags = RBHT_GRABBER;
2302 TRACE("ON GRABBER %d\n", iCount);
2305 else if (PtInRect (&lpBand->rcCapImage, *lpPt)) {
2306 *pFlags = RBHT_CAPTION;
2307 TRACE("ON CAPTION %d\n", iCount);
2310 else if (PtInRect (&lpBand->rcCapText, *lpPt)) {
2311 *pFlags = RBHT_CAPTION;
2312 TRACE("ON CAPTION %d\n", iCount);
2315 else if (PtInRect (&lpBand->rcChild, *lpPt)) {
2316 *pFlags = RBHT_CLIENT;
2317 TRACE("ON CLIENT %d\n", iCount);
2320 else if (PtInRect (&lpBand->rcChevron, *lpPt)) {
2321 *pFlags = RBHT_CHEVRON;
2322 TRACE("ON CHEVRON %d\n", iCount);
2326 *pFlags = RBHT_NOWHERE;
2327 TRACE("NOWHERE %d\n", iCount);
2333 *pFlags = RBHT_NOWHERE;
2342 *pFlags = RBHT_NOWHERE;
2352 REBAR_Shrink (REBAR_INFO *infoPtr, REBAR_BAND *band, INT movement, INT i)
2353 /* Function: This attempts to shrink the given band by the */
2354 /* the amount in "movement". A shrink to the left is indi- */
2355 /* cated by "movement" being negative. "i" is merely the */
2356 /* band index for trace messages. */
2358 INT Leadjust, Readjust, avail, ret;
2360 /* Note: a left drag is indicated by "movement" being negative. */
2361 /* Similarly, a right drag is indicated by "movement" */
2362 /* being positive. "movement" should never be 0, but if */
2363 /* it is then the band does not move. */
2365 avail = rcBw(band) - band->lcx;
2367 /* now compute the Left End adjustment factor and Right End */
2368 /* adjustment factor. They may be different if shrinking. */
2370 /* if this band is not shrinkable, then just move it */
2371 Leadjust = Readjust = movement;
2377 if (avail <= abs(movement)) {
2378 Readjust = movement;
2379 Leadjust = movement + avail;
2383 Readjust = movement;
2390 if (avail <= abs(movement)) {
2391 Leadjust = movement;
2392 Readjust = movement - avail;
2396 Leadjust = movement;
2403 /* Reasonability Check */
2404 if (rcBlt(band) + Leadjust < 0) {
2405 ERR("adjustment will fail, band %d: left=%d, right=%d, move=%d, rtn=%d\n",
2406 i, Leadjust, Readjust, movement, ret);
2409 LEADJ(band, Leadjust);
2410 READJ(band, Readjust);
2412 TRACE("band %d: left=%d, right=%d, move=%d, rtn=%d, rcBand=(%ld,%ld)-(%ld,%ld)\n",
2413 i, Leadjust, Readjust, movement, ret,
2414 band->rcBand.left, band->rcBand.top,
2415 band->rcBand.right, band->rcBand.bottom);
2421 REBAR_HandleLRDrag (REBAR_INFO *infoPtr, POINTS *ptsmove)
2422 /* Function: This will implement the functionality of a */
2423 /* Gripper drag within a row. It will not implement "out- */
2424 /* of-row" drags. (They are detected and handled in */
2425 /* REBAR_MouseMove.) */
2426 /* **** FIXME Switching order of bands in a row not **** */
2427 /* **** yet implemented. **** */
2429 REBAR_BAND *hitBand, *band, *mindBand, *maxdBand;
2431 INT imindBand = -1, imaxdBand, ihitBand, i, movement;
2432 INT RHeaderSum = 0, LHeaderSum = 0;
2435 /* on first significant mouse movement, issue notify */
2437 if (!(infoPtr->fStatus & BEGIN_DRAG_ISSUED)) {
2438 if (REBAR_Notify_NMREBAR (infoPtr, -1, RBN_BEGINDRAG)) {
2439 /* Notify returned TRUE - abort drag */
2440 infoPtr->dragStart.x = 0;
2441 infoPtr->dragStart.y = 0;
2442 infoPtr->dragNow = infoPtr->dragStart;
2443 infoPtr->iGrabbedBand = -1;
2447 infoPtr->fStatus |= BEGIN_DRAG_ISSUED;
2450 ihitBand = infoPtr->iGrabbedBand;
2451 hitBand = &infoPtr->bands[ihitBand];
2452 imaxdBand = ihitBand; /* to suppress warning message */
2454 /* find all the bands in the row of the one whose Gripper was seized */
2455 for (i=0; i<infoPtr->uNumBands; i++) {
2456 band = &infoPtr->bands[i];
2457 if (HIDDENBAND(band)) continue;
2458 if (band->iRow == hitBand->iRow) {
2460 if (imindBand == -1) imindBand = i;
2461 /* minimum size of each band is size of header plus */
2462 /* size of minimum child plus offset of child from header plus */
2463 /* a one to separate each band. */
2465 LHeaderSum += (band->lcx + SEP_WIDTH);
2467 RHeaderSum += (band->lcx + SEP_WIDTH);
2471 if (RHeaderSum) RHeaderSum -= SEP_WIDTH; /* no separator after last band */
2473 mindBand = &infoPtr->bands[imindBand];
2474 maxdBand = &infoPtr->bands[imaxdBand];
2476 if (imindBand == imaxdBand) return; /* nothing to drag against */
2477 if (imindBand == ihitBand) return; /* first band in row, can't drag */
2479 /* limit movement to inside adjustable bands - Left */
2480 if ( (ptsmove->x < mindBand->rcBand.left) ||
2481 (ptsmove->x > maxdBand->rcBand.right) ||
2482 (ptsmove->y < mindBand->rcBand.top) ||
2483 (ptsmove->y > maxdBand->rcBand.bottom))
2484 return; /* should swap bands */
2486 if (infoPtr->dwStyle & CCS_VERT)
2487 movement = ptsmove->y - ((hitBand->rcBand.top+REBAR_PRE_GRIPPER) -
2488 infoPtr->ihitoffset);
2490 movement = ptsmove->x - ((hitBand->rcBand.left+REBAR_PRE_GRIPPER) -
2491 infoPtr->ihitoffset);
2492 infoPtr->dragNow = *ptsmove;
2494 TRACE("before: movement=%d (%d,%d), imindBand=%d, ihitBand=%d, imaxdBand=%d, LSum=%d, RSum=%d\n",
2495 movement, ptsmove->x, ptsmove->y, imindBand, ihitBand,
2496 imaxdBand, LHeaderSum, RHeaderSum);
2497 REBAR_DumpBand (infoPtr);
2501 /* *** Drag left/up *** */
2502 compress = rcBlt(hitBand) - rcBlt(mindBand) -
2504 if (compress < abs(movement)) {
2505 TRACE("limiting left drag, was %d changed to %d\n",
2506 movement, -compress);
2507 movement = -compress;
2510 for (i=ihitBand; i>=imindBand; i--) {
2511 band = &infoPtr->bands[i];
2512 if (HIDDENBAND(band)) continue;
2513 if (i == ihitBand) {
2514 LEADJ(band, movement);
2517 movement = REBAR_Shrink (infoPtr, band, movement, i);
2518 band->ccx = rcBw(band);
2524 /* *** Drag right/down *** */
2525 compress = rcBrb(maxdBand) - rcBlt(hitBand) -
2527 if (compress < abs(movement)) {
2528 TRACE("limiting right drag, was %d changed to %d\n",
2529 movement, compress);
2530 movement = compress;
2532 for (i=ihitBand-1; i<=imaxdBand; i++) {
2533 band = &infoPtr->bands[i];
2534 if (HIDDENBAND(band)) continue;
2537 READJ(band, movement);
2540 movement = REBAR_Shrink (infoPtr, band, movement, i);
2541 band->ccx = rcBw(band);
2545 /* recompute all rectangles */
2546 if (infoPtr->dwStyle & CCS_VERT) {
2547 REBAR_CalcVertBand (infoPtr, imindBand, imaxdBand+1,
2551 REBAR_CalcHorzBand (infoPtr, imindBand, imaxdBand+1,
2555 TRACE("bands after adjustment, see band # %d, %d\n",
2556 imindBand, imaxdBand);
2557 REBAR_DumpBand (infoPtr);
2560 mindBand->rcBand.left,
2561 mindBand->rcBand.top,
2562 maxdBand->rcBand.right,
2563 maxdBand->rcBand.bottom);
2565 REBAR_MoveChildWindows (infoPtr, imindBand, imaxdBand+1);
2567 InvalidateRect (infoPtr->hwndSelf, &newrect, TRUE);
2568 UpdateWindow (infoPtr->hwndSelf);
2574 /* << REBAR_BeginDrag >> */
2578 REBAR_DeleteBand (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
2580 UINT uBand = (UINT)wParam;
2584 if (uBand >= infoPtr->uNumBands)
2587 TRACE("deleting band %u!\n", uBand);
2588 lpBand = &infoPtr->bands[uBand];
2589 REBAR_Notify_NMREBAR (infoPtr, uBand, RBN_DELETINGBAND);
2591 if (infoPtr->uNumBands == 1) {
2592 TRACE(" simple delete!\n");
2593 if ((lpBand->fMask & RBBIM_CHILD) && lpBand->hwndChild)
2594 childhwnd = lpBand->hwndChild;
2595 Free (infoPtr->bands);
2596 infoPtr->bands = NULL;
2597 infoPtr->uNumBands = 0;
2600 REBAR_BAND *oldBands = infoPtr->bands;
2601 TRACE("complex delete! [uBand=%u]\n", uBand);
2603 if ((lpBand->fMask & RBBIM_CHILD) && lpBand->hwndChild)
2604 childhwnd = lpBand->hwndChild;
2606 infoPtr->uNumBands--;
2607 infoPtr->bands = Alloc (sizeof (REBAR_BAND) * infoPtr->uNumBands);
2609 memcpy (&infoPtr->bands[0], &oldBands[0],
2610 uBand * sizeof(REBAR_BAND));
2613 if (uBand < infoPtr->uNumBands) {
2614 memcpy (&infoPtr->bands[uBand], &oldBands[uBand+1],
2615 (infoPtr->uNumBands - uBand) * sizeof(REBAR_BAND));
2622 ShowWindow (childhwnd, SW_HIDE);
2624 REBAR_Notify_NMREBAR (infoPtr, -1, RBN_DELETEDBAND);
2626 /* if only 1 band left the re-validate to possible eliminate gripper */
2627 if (infoPtr->uNumBands == 1)
2628 REBAR_ValidateBand (infoPtr, &infoPtr->bands[0]);
2630 TRACE("setting NEEDS_LAYOUT\n");
2631 infoPtr->fStatus |= BAND_NEEDS_LAYOUT;
2632 infoPtr->fStatus |= RESIZE_ANYHOW;
2633 REBAR_Layout (infoPtr, NULL, TRUE, FALSE);
2639 /* << REBAR_DragMove >> */
2640 /* << REBAR_EndDrag >> */
2644 REBAR_GetBandBorders (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
2646 LPRECT lpRect = (LPRECT)lParam;
2651 if ((UINT)wParam >= infoPtr->uNumBands)
2654 lpBand = &infoPtr->bands[(UINT)wParam];
2656 /* FIXME - the following values were determined by experimentation */
2657 /* with the REBAR Control Spy. I have guesses as to what the 4 and */
2658 /* 1 are, but I am not sure. There doesn't seem to be any actual */
2659 /* difference in size of the control area with and without the */
2661 if (infoPtr->dwStyle & RBS_BANDBORDERS) {
2662 if (infoPtr->dwStyle & CCS_VERT) {
2664 lpRect->top = lpBand->cxHeader + 4;
2669 lpRect->left = lpBand->cxHeader + 4;
2676 lpRect->left = lpBand->cxHeader;
2682 inline static LRESULT
2683 REBAR_GetBandCount (REBAR_INFO *infoPtr)
2685 TRACE("band count %u!\n", infoPtr->uNumBands);
2687 return infoPtr->uNumBands;
2692 REBAR_GetBandInfoA (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
2694 LPREBARBANDINFOA lprbbi = (LPREBARBANDINFOA)lParam;
2699 if (lprbbi->cbSize < REBARBANDINFOA_V3_SIZE)
2701 if ((UINT)wParam >= infoPtr->uNumBands)
2704 TRACE("index %u\n", (UINT)wParam);
2706 /* copy band information */
2707 lpBand = &infoPtr->bands[(UINT)wParam];
2709 if (lprbbi->fMask & RBBIM_STYLE)
2710 lprbbi->fStyle = lpBand->fStyle;
2712 if (lprbbi->fMask & RBBIM_COLORS) {
2713 lprbbi->clrFore = lpBand->clrFore;
2714 lprbbi->clrBack = lpBand->clrBack;
2715 if (lprbbi->clrBack == CLR_DEFAULT)
2716 lprbbi->clrBack = infoPtr->clrBtnFace;
2719 if ((lprbbi->fMask & RBBIM_TEXT) && (lprbbi->lpText)) {
2720 if (lpBand->lpText && (lpBand->fMask & RBBIM_TEXT))
2722 if (!WideCharToMultiByte( CP_ACP, 0, lpBand->lpText, -1,
2723 lprbbi->lpText, lprbbi->cch, NULL, NULL ))
2724 lprbbi->lpText[lprbbi->cch-1] = 0;
2727 *lprbbi->lpText = 0;
2730 if (lprbbi->fMask & RBBIM_IMAGE) {
2731 if (lpBand->fMask & RBBIM_IMAGE)
2732 lprbbi->iImage = lpBand->iImage;
2734 lprbbi->iImage = -1;
2737 if (lprbbi->fMask & RBBIM_CHILD)
2738 lprbbi->hwndChild = lpBand->hwndChild;
2740 if (lprbbi->fMask & RBBIM_CHILDSIZE) {
2741 lprbbi->cxMinChild = lpBand->cxMinChild;
2742 lprbbi->cyMinChild = lpBand->cyMinChild;
2743 if (lprbbi->cbSize >= sizeof (REBARBANDINFOA)) {
2744 lprbbi->cyChild = lpBand->cyChild;
2745 lprbbi->cyMaxChild = lpBand->cyMaxChild;
2746 lprbbi->cyIntegral = lpBand->cyIntegral;
2750 if (lprbbi->fMask & RBBIM_SIZE)
2751 lprbbi->cx = lpBand->cx;
2753 if (lprbbi->fMask & RBBIM_BACKGROUND)
2754 lprbbi->hbmBack = lpBand->hbmBack;
2756 if (lprbbi->fMask & RBBIM_ID)
2757 lprbbi->wID = lpBand->wID;
2759 /* check for additional data */
2760 if (lprbbi->cbSize >= sizeof (REBARBANDINFOA)) {
2761 if (lprbbi->fMask & RBBIM_IDEALSIZE)
2762 lprbbi->cxIdeal = lpBand->cxIdeal;
2764 if (lprbbi->fMask & RBBIM_LPARAM)
2765 lprbbi->lParam = lpBand->lParam;
2767 if (lprbbi->fMask & RBBIM_HEADERSIZE)
2768 lprbbi->cxHeader = lpBand->cxHeader;
2771 REBAR_DumpBandInfo (lprbbi);
2778 REBAR_GetBandInfoW (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
2780 LPREBARBANDINFOW lprbbi = (LPREBARBANDINFOW)lParam;
2785 if (lprbbi->cbSize < REBARBANDINFOW_V3_SIZE)
2787 if ((UINT)wParam >= infoPtr->uNumBands)
2790 TRACE("index %u\n", (UINT)wParam);
2792 /* copy band information */
2793 lpBand = &infoPtr->bands[(UINT)wParam];
2795 if (lprbbi->fMask & RBBIM_STYLE)
2796 lprbbi->fStyle = lpBand->fStyle;
2798 if (lprbbi->fMask & RBBIM_COLORS) {
2799 lprbbi->clrFore = lpBand->clrFore;
2800 lprbbi->clrBack = lpBand->clrBack;
2801 if (lprbbi->clrBack == CLR_DEFAULT)
2802 lprbbi->clrBack = infoPtr->clrBtnFace;
2805 if ((lprbbi->fMask & RBBIM_TEXT) && (lprbbi->lpText)) {
2806 if (lpBand->lpText && (lpBand->fMask & RBBIM_TEXT))
2807 lstrcpynW (lprbbi->lpText, lpBand->lpText, lprbbi->cch);
2809 *lprbbi->lpText = 0;
2812 if (lprbbi->fMask & RBBIM_IMAGE) {
2813 if (lpBand->fMask & RBBIM_IMAGE)
2814 lprbbi->iImage = lpBand->iImage;
2816 lprbbi->iImage = -1;
2819 if (lprbbi->fMask & RBBIM_CHILD)
2820 lprbbi->hwndChild = lpBand->hwndChild;
2822 if (lprbbi->fMask & RBBIM_CHILDSIZE) {
2823 lprbbi->cxMinChild = lpBand->cxMinChild;
2824 lprbbi->cyMinChild = lpBand->cyMinChild;
2825 if (lprbbi->cbSize >= sizeof (REBARBANDINFOW)) {
2826 lprbbi->cyChild = lpBand->cyChild;
2827 lprbbi->cyMaxChild = lpBand->cyMaxChild;
2828 lprbbi->cyIntegral = lpBand->cyIntegral;
2832 if (lprbbi->fMask & RBBIM_SIZE)
2833 lprbbi->cx = lpBand->cx;
2835 if (lprbbi->fMask & RBBIM_BACKGROUND)
2836 lprbbi->hbmBack = lpBand->hbmBack;
2838 if (lprbbi->fMask & RBBIM_ID)
2839 lprbbi->wID = lpBand->wID;
2841 /* check for additional data */
2842 if (lprbbi->cbSize >= sizeof (REBARBANDINFOW)) {
2843 if (lprbbi->fMask & RBBIM_IDEALSIZE)
2844 lprbbi->cxIdeal = lpBand->cxIdeal;
2846 if (lprbbi->fMask & RBBIM_LPARAM)
2847 lprbbi->lParam = lpBand->lParam;
2849 if (lprbbi->fMask & RBBIM_HEADERSIZE)
2850 lprbbi->cxHeader = lpBand->cxHeader;
2853 REBAR_DumpBandInfo ((LPREBARBANDINFOA)lprbbi);
2860 REBAR_GetBarHeight (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
2864 nHeight = (infoPtr->dwStyle & CCS_VERT) ? infoPtr->calcSize.cx : infoPtr->calcSize.cy;
2866 TRACE("height = %d\n", nHeight);
2873 REBAR_GetBarInfo (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
2875 LPREBARINFO lpInfo = (LPREBARINFO)lParam;
2880 if (lpInfo->cbSize < sizeof (REBARINFO))
2883 TRACE("getting bar info!\n");
2885 if (infoPtr->himl) {
2886 lpInfo->himl = infoPtr->himl;
2887 lpInfo->fMask |= RBIM_IMAGELIST;
2894 inline static LRESULT
2895 REBAR_GetBkColor (REBAR_INFO *infoPtr)
2897 COLORREF clr = infoPtr->clrBk;
2899 if (clr == CLR_DEFAULT)
2900 clr = infoPtr->clrBtnFace;
2902 TRACE("background color 0x%06lx!\n", clr);
2908 /* << REBAR_GetColorScheme >> */
2909 /* << REBAR_GetDropTarget >> */
2913 REBAR_GetPalette (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
2915 FIXME("empty stub!\n");
2922 REBAR_GetRect (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
2924 INT iBand = (INT)wParam;
2925 LPRECT lprc = (LPRECT)lParam;
2928 if ((iBand < 0) && ((UINT)iBand >= infoPtr->uNumBands))
2933 lpBand = &infoPtr->bands[iBand];
2934 CopyRect (lprc, &lpBand->rcBand);
2936 TRACE("band %d, (%ld,%ld)-(%ld,%ld)\n", iBand,
2937 lprc->left, lprc->top, lprc->right, lprc->bottom);
2943 inline static LRESULT
2944 REBAR_GetRowCount (REBAR_INFO *infoPtr)
2946 TRACE("%u\n", infoPtr->uNumRows);
2948 return infoPtr->uNumRows;
2953 REBAR_GetRowHeight (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
2955 INT iRow = (INT)wParam;
2960 for (i=0; i<infoPtr->uNumBands; i++) {
2961 lpBand = &infoPtr->bands[i];
2962 if (HIDDENBAND(lpBand)) continue;
2963 if (lpBand->iRow != iRow) continue;
2964 if (infoPtr->dwStyle & CCS_VERT)
2965 j = lpBand->rcBand.right - lpBand->rcBand.left;
2967 j = lpBand->rcBand.bottom - lpBand->rcBand.top;
2968 if (j > ret) ret = j;
2971 TRACE("row %d, height %d\n", iRow, ret);
2977 inline static LRESULT
2978 REBAR_GetTextColor (REBAR_INFO *infoPtr)
2980 TRACE("text color 0x%06lx!\n", infoPtr->clrText);
2982 return infoPtr->clrText;
2986 inline static LRESULT
2987 REBAR_GetToolTips (REBAR_INFO *infoPtr)
2989 return (LRESULT)infoPtr->hwndToolTip;
2993 inline static LRESULT
2994 REBAR_GetUnicodeFormat (REBAR_INFO *infoPtr)
2996 TRACE("%s hwnd=%p\n",
2997 infoPtr->bUnicode ? "TRUE" : "FALSE", infoPtr->hwndSelf);
2999 return infoPtr->bUnicode;
3003 inline static LRESULT
3004 REBAR_GetVersion (REBAR_INFO *infoPtr)
3006 TRACE("version %d\n", infoPtr->iVersion);
3007 return infoPtr->iVersion;
3012 REBAR_HitTest (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3014 LPRBHITTESTINFO lprbht = (LPRBHITTESTINFO)lParam;
3019 REBAR_InternalHitTest (infoPtr, &lprbht->pt, &lprbht->flags, &lprbht->iBand);
3021 return lprbht->iBand;
3026 REBAR_IdToIndex (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3030 if (infoPtr == NULL)
3033 if (infoPtr->uNumBands < 1)
3036 for (i = 0; i < infoPtr->uNumBands; i++) {
3037 if (infoPtr->bands[i].wID == (UINT)wParam) {
3038 TRACE("id %u is band %u found!\n", (UINT)wParam, i);
3043 TRACE("id %u is not found\n", (UINT)wParam);
3049 REBAR_InsertBandA (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3051 LPREBARBANDINFOA lprbbi = (LPREBARBANDINFOA)lParam;
3052 UINT uIndex = (UINT)wParam;
3055 if (infoPtr == NULL)
3059 if (lprbbi->cbSize < REBARBANDINFOA_V3_SIZE)
3062 /* trace the index as signed to see the -1 */
3063 TRACE("insert band at %d!\n", (INT)uIndex);
3064 REBAR_DumpBandInfo (lprbbi);
3066 if (infoPtr->uNumBands == 0) {
3067 infoPtr->bands = (REBAR_BAND *)Alloc (sizeof (REBAR_BAND));
3071 REBAR_BAND *oldBands = infoPtr->bands;
3073 (REBAR_BAND *)Alloc ((infoPtr->uNumBands+1)*sizeof(REBAR_BAND));
3074 if (((INT)uIndex == -1) || (uIndex > infoPtr->uNumBands))
3075 uIndex = infoPtr->uNumBands;
3077 /* pre insert copy */
3079 memcpy (&infoPtr->bands[0], &oldBands[0],
3080 uIndex * sizeof(REBAR_BAND));
3084 if (uIndex < infoPtr->uNumBands) {
3085 memcpy (&infoPtr->bands[uIndex+1], &oldBands[uIndex],
3086 (infoPtr->uNumBands - uIndex) * sizeof(REBAR_BAND));
3092 infoPtr->uNumBands++;
3094 TRACE("index %u!\n", uIndex);
3096 /* initialize band (infoPtr->bands[uIndex])*/
3097 lpBand = &infoPtr->bands[uIndex];
3099 lpBand->fStatus = 0;
3100 lpBand->clrFore = infoPtr->clrText;
3101 lpBand->clrBack = infoPtr->clrBk;
3102 lpBand->hwndChild = 0;
3103 lpBand->hwndPrevParent = 0;
3105 REBAR_CommonSetupBand (infoPtr->hwndSelf, lprbbi, lpBand);
3106 lpBand->lpText = NULL;
3107 if ((lprbbi->fMask & RBBIM_TEXT) && (lprbbi->lpText)) {
3108 INT len = MultiByteToWideChar( CP_ACP, 0, lprbbi->lpText, -1, NULL, 0 );
3110 lpBand->lpText = (LPWSTR)Alloc (len*sizeof(WCHAR));
3111 MultiByteToWideChar( CP_ACP, 0, lprbbi->lpText, -1, lpBand->lpText, len );
3115 REBAR_ValidateBand (infoPtr, lpBand);
3116 /* On insert of second band, revalidate band 1 to possible add gripper */
3117 if (infoPtr->uNumBands == 2)
3118 REBAR_ValidateBand (infoPtr, &infoPtr->bands[0]);
3120 REBAR_DumpBand (infoPtr);
3122 REBAR_Layout (infoPtr, NULL, TRUE, FALSE);
3123 InvalidateRect(infoPtr->hwndSelf, 0, 1);
3130 REBAR_InsertBandW (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3132 LPREBARBANDINFOW lprbbi = (LPREBARBANDINFOW)lParam;
3133 UINT uIndex = (UINT)wParam;
3136 if (infoPtr == NULL)
3140 if (lprbbi->cbSize < REBARBANDINFOW_V3_SIZE)
3143 /* trace the index as signed to see the -1 */
3144 TRACE("insert band at %d!\n", (INT)uIndex);
3145 REBAR_DumpBandInfo ((LPREBARBANDINFOA)lprbbi);
3147 if (infoPtr->uNumBands == 0) {
3148 infoPtr->bands = (REBAR_BAND *)Alloc (sizeof (REBAR_BAND));
3152 REBAR_BAND *oldBands = infoPtr->bands;
3154 (REBAR_BAND *)Alloc ((infoPtr->uNumBands+1)*sizeof(REBAR_BAND));
3155 if (((INT)uIndex == -1) || (uIndex > infoPtr->uNumBands))
3156 uIndex = infoPtr->uNumBands;
3158 /* pre insert copy */
3160 memcpy (&infoPtr->bands[0], &oldBands[0],
3161 uIndex * sizeof(REBAR_BAND));
3165 if (uIndex <= infoPtr->uNumBands - 1) {
3166 memcpy (&infoPtr->bands[uIndex+1], &oldBands[uIndex],
3167 (infoPtr->uNumBands - uIndex) * sizeof(REBAR_BAND));
3173 infoPtr->uNumBands++;
3175 TRACE("index %u!\n", uIndex);
3177 /* initialize band (infoPtr->bands[uIndex])*/
3178 lpBand = &infoPtr->bands[uIndex];
3180 lpBand->fStatus = 0;
3181 lpBand->clrFore = infoPtr->clrText;
3182 lpBand->clrBack = infoPtr->clrBk;
3183 lpBand->hwndChild = 0;
3184 lpBand->hwndPrevParent = 0;
3186 REBAR_CommonSetupBand (infoPtr->hwndSelf, (LPREBARBANDINFOA)lprbbi, lpBand);
3187 lpBand->lpText = NULL;
3188 if ((lprbbi->fMask & RBBIM_TEXT) && (lprbbi->lpText)) {
3189 INT len = lstrlenW (lprbbi->lpText);
3191 lpBand->lpText = (LPWSTR)Alloc ((len + 1)*sizeof(WCHAR));
3192 strcpyW (lpBand->lpText, lprbbi->lpText);
3196 REBAR_ValidateBand (infoPtr, lpBand);
3197 /* On insert of second band, revalidate band 1 to possible add gripper */
3198 if (infoPtr->uNumBands == 2)
3199 REBAR_ValidateBand (infoPtr, &infoPtr->bands[uIndex ? 0 : 1]);
3201 REBAR_DumpBand (infoPtr);
3203 REBAR_Layout (infoPtr, NULL, TRUE, FALSE);
3204 InvalidateRect(infoPtr->hwndSelf, 0, 1);
3211 REBAR_MaximizeBand (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3214 UINT uBand = (UINT) wParam;
3217 if ((infoPtr->uNumBands == 0) ||
3218 ((INT)uBand < 0) || (uBand >= infoPtr->uNumBands)) {
3220 ERR("Illegal MaximizeBand, requested=%d, current band count=%d\n",
3221 (INT)uBand, infoPtr->uNumBands);
3225 lpBand = &infoPtr->bands[uBand];
3227 if (lParam && (lpBand->fMask & RBBIM_IDEALSIZE)) {
3228 /* handle setting ideal size */
3229 lpBand->ccx = lpBand->cxIdeal;
3232 /* handle setting to max */
3233 FIXME("(uBand = %u fIdeal = %s) case not coded\n",
3234 (UINT)wParam, lParam ? "TRUE" : "FALSE");
3238 infoPtr->fStatus |= BAND_NEEDS_LAYOUT;
3239 REBAR_Layout (infoPtr, 0, TRUE, TRUE);
3240 InvalidateRect (infoPtr->hwndSelf, 0, TRUE);
3248 REBAR_MinimizeBand (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3250 REBAR_BAND *band, *lpBand;
3251 UINT uBand = (UINT) wParam;
3253 INT imindBand, imaxdBand, iprevBand, startBand, endBand;
3256 /* A "minimize" band is equivalent to "dragging" the gripper
3257 * of than band to the right till the band is only the size
3262 if ((infoPtr->uNumBands == 0) ||
3263 ((INT)uBand < 0) || (uBand >= infoPtr->uNumBands)) {
3265 ERR("Illegal MinimizeBand, requested=%d, current band count=%d\n",
3266 (INT)uBand, infoPtr->uNumBands);
3270 /* compute amount of movement and validate */
3271 lpBand = &infoPtr->bands[uBand];
3273 if (infoPtr->dwStyle & CCS_VERT)
3274 movement = lpBand->rcBand.bottom - lpBand->rcBand.top -
3277 movement = lpBand->rcBand.right - lpBand->rcBand.left -
3280 ERR("something is wrong, band=(%ld,%ld)-(%ld,%ld), cxheader=%d\n",
3281 lpBand->rcBand.left, lpBand->rcBand.top,
3282 lpBand->rcBand.right, lpBand->rcBand.bottom,
3289 iprevBand = -1; /* to suppress warning message */
3291 /* find the first band in row of the one whose is being minimized */
3292 for (i=0; i<infoPtr->uNumBands; i++) {
3293 band = &infoPtr->bands[i];
3294 if (HIDDENBAND(band)) continue;
3295 if (band->iRow == lpBand->iRow) {
3297 if (imindBand == -1) imindBand = i;
3301 /* if the selected band is first in row then need to expand */
3302 /* next visible band */
3303 if (imindBand == uBand) {
3305 movement = -movement;
3306 /* find the first visible band to the right of the selected band */
3307 for (i=uBand+1; i<=imaxdBand; i++) {
3308 band = &infoPtr->bands[i];
3309 if (!HIDDENBAND(band)) {
3311 LEADJ(band, movement);
3312 band->ccx = rcBw(band);
3316 /* what case is this */
3317 if (iprevBand == -1) {
3318 ERR("no previous visible band\n");
3322 endBand = iprevBand;
3324 lpBand->rcBand.left,
3327 band->rcBand.bottom);
3329 /* otherwise expand previous visible band */
3332 /* find the first visible band to the left of the selected band */
3333 for (i=uBand-1; i>=imindBand; i--) {
3334 band = &infoPtr->bands[i];
3335 if (!HIDDENBAND(band)) {
3337 READJ(band, movement);
3338 band->ccx = rcBw(band);
3342 /* what case is this */
3343 if (iprevBand == -1) {
3344 ERR("no previous visible band\n");
3347 startBand = iprevBand;
3352 lpBand->rcBand.right,
3353 lpBand->rcBand.bottom);
3356 REBAR_Shrink (infoPtr, lpBand, movement, uBand);
3358 /* recompute all rectangles */
3359 if (infoPtr->dwStyle & CCS_VERT) {
3360 REBAR_CalcVertBand (infoPtr, startBand, endBand+1,
3364 REBAR_CalcHorzBand (infoPtr, startBand, endBand+1,
3368 TRACE("bands after minimize, see band # %d, %d\n",
3369 startBand, endBand);
3370 REBAR_DumpBand (infoPtr);
3372 REBAR_MoveChildWindows (infoPtr, startBand, endBand+1);
3374 InvalidateRect (infoPtr->hwndSelf, &newrect, TRUE);
3375 UpdateWindow (infoPtr->hwndSelf);
3381 REBAR_MoveBand (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3383 REBAR_BAND *oldBands = infoPtr->bands;
3385 UINT uFrom = (UINT)wParam;
3386 UINT uTo = (UINT)lParam;
3389 if ((infoPtr->uNumBands == 0) ||
3390 ((INT)uFrom < 0) || (uFrom >= infoPtr->uNumBands) ||
3391 ((INT)uTo < 0) || (uTo >= infoPtr->uNumBands)) {
3393 ERR("Illegal MoveBand, from=%d, to=%d, current band count=%d\n",
3394 (INT)uFrom, (INT)uTo, infoPtr->uNumBands);
3398 /* save one to be moved */
3399 memcpy (&holder, &oldBands[uFrom], sizeof(REBAR_BAND));
3401 /* close up rest of bands (pseudo delete) */
3402 if (uFrom < infoPtr->uNumBands - 1) {
3403 memcpy (&oldBands[uFrom], &oldBands[uFrom+1],
3404 (infoPtr->uNumBands - uFrom - 1) * sizeof(REBAR_BAND));
3407 /* allocate new space and copy rest of bands into it */
3409 (REBAR_BAND *)Alloc ((infoPtr->uNumBands)*sizeof(REBAR_BAND));
3411 /* pre insert copy */
3413 memcpy (&infoPtr->bands[0], &oldBands[0],
3414 uTo * sizeof(REBAR_BAND));
3417 /* set moved band */
3418 memcpy (&infoPtr->bands[uTo], &holder, sizeof(REBAR_BAND));
3421 if (uTo < infoPtr->uNumBands - 1) {
3422 memcpy (&infoPtr->bands[uTo+1], &oldBands[uTo],
3423 (infoPtr->uNumBands - uTo - 1) * sizeof(REBAR_BAND));
3428 TRACE("moved band %d to index %d\n", uFrom, uTo);
3429 REBAR_DumpBand (infoPtr);
3431 infoPtr->fStatus |= BAND_NEEDS_LAYOUT;
3432 /* **************************************************** */
3434 /* We do not do a REBAR_Layout here because the native */
3435 /* control does not do that. The actual layout and */
3436 /* repaint is done by the *next* real action, ex.: */
3437 /* RB_INSERTBAND, RB_DELETEBAND, RB_SIZETORECT, etc. */
3439 /* **************************************************** */
3445 /* return TRUE if two strings are different */
3447 REBAR_strdifW( LPCWSTR a, LPCWSTR b )
3449 return ( (a && !b) || (b && !a) || (a && b && lstrcmpW(a, b) ) );
3453 REBAR_SetBandInfoA (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3455 LPREBARBANDINFOA lprbbi = (LPREBARBANDINFOA)lParam;
3461 if (lprbbi->cbSize < REBARBANDINFOA_V3_SIZE)
3463 if ((UINT)wParam >= infoPtr->uNumBands)
3466 TRACE("index %u\n", (UINT)wParam);
3467 REBAR_DumpBandInfo (lprbbi);
3469 /* set band information */
3470 lpBand = &infoPtr->bands[(UINT)wParam];
3472 bChanged = REBAR_CommonSetupBand (infoPtr->hwndSelf, lprbbi, lpBand);
3473 if (lprbbi->fMask & RBBIM_TEXT) {
3479 len = MultiByteToWideChar( CP_ACP, 0, lprbbi->lpText, -1, NULL, 0 );
3481 wstr = (LPWSTR)Alloc (len*sizeof(WCHAR));
3483 MultiByteToWideChar( CP_ACP, 0, lprbbi->lpText, -1, wstr, len );
3485 if (REBAR_strdifW(lpBand->lpText, wstr)) {
3486 if (lpBand->lpText) {
3487 Free (lpBand->lpText);
3488 lpBand->lpText = NULL;
3491 lpBand->lpText = wstr;
3500 REBAR_ValidateBand (infoPtr, lpBand);
3502 REBAR_DumpBand (infoPtr);
3504 if (bChanged && (lprbbi->fMask & (RBBIM_CHILDSIZE | RBBIM_SIZE))) {
3505 REBAR_Layout (infoPtr, NULL, TRUE, FALSE);
3506 InvalidateRect(infoPtr->hwndSelf, 0, 1);
3513 REBAR_SetBandInfoW (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3515 LPREBARBANDINFOW lprbbi = (LPREBARBANDINFOW)lParam;
3521 if (lprbbi->cbSize < REBARBANDINFOW_V3_SIZE)
3523 if ((UINT)wParam >= infoPtr->uNumBands)
3526 TRACE("index %u\n", (UINT)wParam);
3527 REBAR_DumpBandInfo ((LPREBARBANDINFOA)lprbbi);
3529 /* set band information */
3530 lpBand = &infoPtr->bands[(UINT)wParam];
3532 bChanged = REBAR_CommonSetupBand (infoPtr->hwndSelf, (LPREBARBANDINFOA)lprbbi, lpBand);
3533 if( (lprbbi->fMask & RBBIM_TEXT) &&
3534 REBAR_strdifW( lpBand->lpText, lprbbi->lpText ) ) {
3535 if (lpBand->lpText) {
3536 Free (lpBand->lpText);
3537 lpBand->lpText = NULL;
3539 if (lprbbi->lpText) {
3540 INT len = lstrlenW (lprbbi->lpText);
3543 lpBand->lpText = (LPWSTR)Alloc ((len + 1)*sizeof(WCHAR));
3544 strcpyW (lpBand->lpText, lprbbi->lpText);
3550 REBAR_ValidateBand (infoPtr, lpBand);
3552 REBAR_DumpBand (infoPtr);
3554 if ( bChanged && (lprbbi->fMask & (RBBIM_CHILDSIZE | RBBIM_SIZE)) ) {
3555 REBAR_Layout (infoPtr, NULL, TRUE, FALSE);
3556 InvalidateRect(infoPtr->hwndSelf, 0, 1);
3564 REBAR_SetBarInfo (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3566 LPREBARINFO lpInfo = (LPREBARINFO)lParam;
3573 if (lpInfo->cbSize < sizeof (REBARINFO))
3576 TRACE("setting bar info!\n");
3578 if (lpInfo->fMask & RBIM_IMAGELIST) {
3579 infoPtr->himl = lpInfo->himl;
3580 if (infoPtr->himl) {
3582 ImageList_GetIconSize (infoPtr->himl, &cx, &cy);
3583 infoPtr->imageSize.cx = cx;
3584 infoPtr->imageSize.cy = cy;
3587 infoPtr->imageSize.cx = 0;
3588 infoPtr->imageSize.cy = 0;
3590 TRACE("new image cx=%ld, cy=%ld\n", infoPtr->imageSize.cx,
3591 infoPtr->imageSize.cy);
3594 /* revalidate all bands to reset flags for images in headers of bands */
3595 for (i=0; i<infoPtr->uNumBands; i++) {
3596 lpBand = &infoPtr->bands[i];
3597 REBAR_ValidateBand (infoPtr, lpBand);
3605 REBAR_SetBkColor (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3609 clrTemp = infoPtr->clrBk;
3610 infoPtr->clrBk = (COLORREF)lParam;
3612 TRACE("background color 0x%06lx!\n", infoPtr->clrBk);
3618 /* << REBAR_SetColorScheme >> */
3619 /* << REBAR_SetPalette >> */
3623 REBAR_SetParent (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3625 HWND hwndTemp = infoPtr->hwndNotify;
3627 infoPtr->hwndNotify = (HWND)wParam;
3629 return (LRESULT)hwndTemp;
3634 REBAR_SetTextColor (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3638 clrTemp = infoPtr->clrText;
3639 infoPtr->clrText = (COLORREF)lParam;
3641 TRACE("text color 0x%06lx!\n", infoPtr->clrText);
3647 /* << REBAR_SetTooltips >> */
3650 inline static LRESULT
3651 REBAR_SetUnicodeFormat (REBAR_INFO *infoPtr, WPARAM wParam)
3653 BOOL bTemp = infoPtr->bUnicode;
3655 TRACE("to %s hwnd=%p, was %s\n",
3656 ((BOOL)wParam) ? "TRUE" : "FALSE", infoPtr->hwndSelf,
3657 (bTemp) ? "TRUE" : "FALSE");
3659 infoPtr->bUnicode = (BOOL)wParam;
3666 REBAR_SetVersion (REBAR_INFO *infoPtr, INT iVersion)
3668 INT iOldVersion = infoPtr->iVersion;
3670 if (iVersion > COMCTL32_VERSION)
3673 infoPtr->iVersion = iVersion;
3675 TRACE("new version %d\n", iVersion);
3682 REBAR_ShowBand (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3686 if (((INT)wParam < 0) || ((INT)wParam > infoPtr->uNumBands))
3689 lpBand = &infoPtr->bands[(INT)wParam];
3692 TRACE("show band %d\n", (INT)wParam);
3693 lpBand->fStyle = lpBand->fStyle & ~RBBS_HIDDEN;
3694 if (IsWindow (lpBand->hwndChild))
3695 ShowWindow (lpBand->hwndChild, SW_SHOW);
3698 TRACE("hide band %d\n", (INT)wParam);
3699 lpBand->fStyle = lpBand->fStyle | RBBS_HIDDEN;
3700 if (IsWindow (lpBand->hwndChild))
3701 ShowWindow (lpBand->hwndChild, SW_HIDE);
3704 infoPtr->fStatus |= BAND_NEEDS_LAYOUT;
3705 REBAR_Layout (infoPtr, NULL, TRUE, FALSE);
3706 InvalidateRect(infoPtr->hwndSelf, 0, 1);
3713 REBAR_SizeToRect (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3715 LPRECT lpRect = (LPRECT)lParam;
3721 TRACE("[%ld %ld %ld %ld]\n",
3722 lpRect->left, lpRect->top, lpRect->right, lpRect->bottom);
3724 /* what is going on???? */
3725 GetWindowRect(infoPtr->hwndSelf, &t1);
3726 TRACE("window rect [%ld %ld %ld %ld]\n",
3727 t1.left, t1.top, t1.right, t1.bottom);
3728 GetClientRect(infoPtr->hwndSelf, &t1);
3729 TRACE("client rect [%ld %ld %ld %ld]\n",
3730 t1.left, t1.top, t1.right, t1.bottom);
3732 /* force full _Layout processing */
3733 TRACE("setting NEEDS_LAYOUT\n");
3734 infoPtr->fStatus |= BAND_NEEDS_LAYOUT;
3735 REBAR_Layout (infoPtr, lpRect, TRUE, FALSE);
3736 InvalidateRect (infoPtr->hwndSelf, NULL, TRUE);
3743 REBAR_Create (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3745 LPCREATESTRUCTA cs = (LPCREATESTRUCTA) lParam;
3748 if (TRACE_ON(rebar)) {
3749 GetWindowRect(infoPtr->hwndSelf, &wnrc1);
3750 GetClientRect(infoPtr->hwndSelf, &clrc1);
3751 TRACE("window=(%ld,%ld)-(%ld,%ld) client=(%ld,%ld)-(%ld,%ld) cs=(%d,%d %dx%d)\n",
3752 wnrc1.left, wnrc1.top, wnrc1.right, wnrc1.bottom,
3753 clrc1.left, clrc1.top, clrc1.right, clrc1.bottom,
3754 cs->x, cs->y, cs->cx, cs->cy);
3757 TRACE("created!\n");
3763 REBAR_Destroy (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3769 /* free rebar bands */
3770 if ((infoPtr->uNumBands > 0) && infoPtr->bands) {
3771 /* clean up each band */
3772 for (i = 0; i < infoPtr->uNumBands; i++) {
3773 lpBand = &infoPtr->bands[i];
3775 /* delete text strings */
3776 if (lpBand->lpText) {
3777 Free (lpBand->lpText);
3778 lpBand->lpText = NULL;
3780 /* destroy child window */
3781 DestroyWindow (lpBand->hwndChild);
3784 /* free band array */
3785 Free (infoPtr->bands);
3786 infoPtr->bands = NULL;
3789 DeleteObject (infoPtr->hcurArrow);
3790 DeleteObject (infoPtr->hcurHorz);
3791 DeleteObject (infoPtr->hcurVert);
3792 DeleteObject (infoPtr->hcurDrag);
3793 if(infoPtr->hDefaultFont) DeleteObject (infoPtr->hDefaultFont);
3794 SetWindowLongPtrW (infoPtr->hwndSelf, 0, 0);
3796 /* free rebar info data */
3798 TRACE("destroyed!\n");
3804 REBAR_EraseBkGnd (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3808 if (GetClipBox ( (HDC)wParam, &cliprect))
3809 return REBAR_InternalEraseBkGnd (infoPtr, wParam, lParam, &cliprect);
3815 REBAR_GetFont (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3817 return (LRESULT)infoPtr->hFont;
3821 REBAR_PushChevron(REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3823 if (wParam >= 0 && (UINT)wParam < infoPtr->uNumBands)
3825 NMREBARCHEVRON nmrbc;
3826 REBAR_BAND *lpBand = &infoPtr->bands[wParam];
3828 TRACE("Pressed chevron on band %d\n", wParam);
3830 /* redraw chevron in pushed state */
3831 lpBand->fDraw |= DRAW_CHEVRONPUSHED;
3832 RedrawWindow(infoPtr->hwndSelf, &lpBand->rcChevron,0,
3833 RDW_ERASE|RDW_INVALIDATE|RDW_UPDATENOW);
3835 /* notify app so it can display a popup menu or whatever */
3836 nmrbc.uBand = wParam;
3837 nmrbc.wID = lpBand->wID;
3838 nmrbc.lParam = lpBand->lParam;
3839 nmrbc.rc = lpBand->rcChevron;
3840 nmrbc.lParamNM = lParam;
3841 REBAR_Notify((NMHDR*)&nmrbc, infoPtr, RBN_CHEVRONPUSHED);
3843 /* redraw chevron in previous state */
3844 lpBand->fDraw &= ~DRAW_CHEVRONPUSHED;
3845 InvalidateRect(infoPtr->hwndSelf, &lpBand->rcChevron, TRUE);
3853 REBAR_LButtonDown (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3859 ptMouseDown.x = (INT)LOWORD(lParam);
3860 ptMouseDown.y = (INT)HIWORD(lParam);
3862 REBAR_InternalHitTest(infoPtr, &ptMouseDown, &htFlags, &iHitBand);
3863 lpBand = &infoPtr->bands[iHitBand];
3865 if (htFlags == RBHT_CHEVRON)
3867 REBAR_PushChevron(infoPtr, iHitBand, 0);
3869 else if (htFlags == RBHT_GRABBER || htFlags == RBHT_CAPTION)
3871 TRACE("Starting drag\n");
3873 SetCapture (infoPtr->hwndSelf);
3874 infoPtr->iGrabbedBand = iHitBand;
3876 /* save off the LOWORD and HIWORD of lParam as initial x,y */
3877 infoPtr->dragStart = MAKEPOINTS(lParam);
3878 infoPtr->dragNow = infoPtr->dragStart;
3879 if (infoPtr->dwStyle & CCS_VERT)
3880 infoPtr->ihitoffset = infoPtr->dragStart.y - (lpBand->rcBand.top+REBAR_PRE_GRIPPER);
3882 infoPtr->ihitoffset = infoPtr->dragStart.x - (lpBand->rcBand.left+REBAR_PRE_GRIPPER);
3888 REBAR_LButtonUp (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3890 if (infoPtr->iGrabbedBand >= 0)
3895 infoPtr->dragStart.x = 0;
3896 infoPtr->dragStart.y = 0;
3897 infoPtr->dragNow = infoPtr->dragStart;
3901 if (infoPtr->fStatus & BEGIN_DRAG_ISSUED) {
3902 REBAR_Notify(&layout, infoPtr, RBN_LAYOUTCHANGED);
3903 REBAR_Notify_NMREBAR (infoPtr, infoPtr->iGrabbedBand, RBN_ENDDRAG);
3904 infoPtr->fStatus &= ~BEGIN_DRAG_ISSUED;
3907 infoPtr->iGrabbedBand = -1;
3909 GetClientRect(infoPtr->hwndSelf, &rect);
3910 InvalidateRect(infoPtr->hwndSelf, NULL, TRUE);
3917 REBAR_MouseLeave (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3919 if (infoPtr->ichevronhotBand >= 0)
3921 REBAR_BAND *lpChevronBand = &infoPtr->bands[infoPtr->ichevronhotBand];
3922 if (lpChevronBand->fDraw & DRAW_CHEVRONHOT)
3924 lpChevronBand->fDraw &= ~DRAW_CHEVRONHOT;
3925 InvalidateRect(infoPtr->hwndSelf, &lpChevronBand->rcChevron, TRUE);
3928 infoPtr->iOldBand = -1;
3929 infoPtr->ichevronhotBand = -2;
3935 REBAR_MouseMove (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3937 REBAR_BAND *lpChevronBand;
3940 ptsmove = MAKEPOINTS(lParam);
3942 /* if we are currently dragging a band */
3943 if (infoPtr->iGrabbedBand >= 0)
3945 REBAR_BAND *band1, *band2;
3947 if (GetCapture() != infoPtr->hwndSelf)
3948 ERR("We are dragging but haven't got capture?!?\n");
3950 band1 = &infoPtr->bands[infoPtr->iGrabbedBand-1];
3951 band2 = &infoPtr->bands[infoPtr->iGrabbedBand];
3953 /* if mouse did not move much, exit */
3954 if ((abs(ptsmove.x - infoPtr->dragNow.x) <= mindragx) &&
3955 (abs(ptsmove.y - infoPtr->dragNow.y) <= mindragy)) return 0;
3957 /* Test for valid drag case - must not be first band in row */
3958 if (infoPtr->dwStyle & CCS_VERT) {
3959 if ((ptsmove.x < band2->rcBand.left) ||
3960 (ptsmove.x > band2->rcBand.right) ||
3961 ((infoPtr->iGrabbedBand > 0) && (band1->iRow != band2->iRow))) {
3962 FIXME("Cannot drag to other rows yet!!\n");
3965 REBAR_HandleLRDrag (infoPtr, &ptsmove);
3969 if ((ptsmove.y < band2->rcBand.top) ||
3970 (ptsmove.y > band2->rcBand.bottom) ||
3971 ((infoPtr->iGrabbedBand > 0) && (band1->iRow != band2->iRow))) {
3972 FIXME("Cannot drag to other rows yet!!\n");
3975 REBAR_HandleLRDrag (infoPtr, &ptsmove);
3984 TRACKMOUSEEVENT trackinfo;
3986 ptMove.x = (INT)ptsmove.x;
3987 ptMove.y = (INT)ptsmove.y;
3988 REBAR_InternalHitTest(infoPtr, &ptMove, &htFlags, &iHitBand);
3990 if (infoPtr->iOldBand >= 0 && infoPtr->iOldBand == infoPtr->ichevronhotBand)
3992 lpChevronBand = &infoPtr->bands[infoPtr->ichevronhotBand];
3993 if (lpChevronBand->fDraw & DRAW_CHEVRONHOT)
3995 lpChevronBand->fDraw &= ~DRAW_CHEVRONHOT;
3996 InvalidateRect(infoPtr->hwndSelf, &lpChevronBand->rcChevron, TRUE);
3998 infoPtr->ichevronhotBand = -2;
4001 if (htFlags == RBHT_CHEVRON)
4003 /* fill in the TRACKMOUSEEVENT struct */
4004 trackinfo.cbSize = sizeof(TRACKMOUSEEVENT);
4005 trackinfo.dwFlags = TME_QUERY;
4006 trackinfo.hwndTrack = infoPtr->hwndSelf;
4007 trackinfo.dwHoverTime = 0;
4009 /* call _TrackMouseEvent to see if we are currently tracking for this hwnd */
4010 _TrackMouseEvent(&trackinfo);
4012 /* Make sure tracking is enabled so we receive a WM_MOUSELEAVE message */
4013 if(!(trackinfo.dwFlags & TME_LEAVE))
4015 trackinfo.dwFlags = TME_LEAVE; /* notify upon leaving */
4017 /* call TRACKMOUSEEVENT so we receive a WM_MOUSELEAVE message */
4018 /* and can properly deactivate the hot chevron */
4019 _TrackMouseEvent(&trackinfo);
4022 lpChevronBand = &infoPtr->bands[iHitBand];
4023 if (!(lpChevronBand->fDraw & DRAW_CHEVRONHOT))
4025 lpChevronBand->fDraw |= DRAW_CHEVRONHOT;
4026 InvalidateRect(infoPtr->hwndSelf, &lpChevronBand->rcChevron, TRUE);
4027 infoPtr->ichevronhotBand = iHitBand;
4030 infoPtr->iOldBand = iHitBand;
4037 inline static LRESULT
4038 REBAR_NCCalcSize (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
4040 if (infoPtr->dwStyle & WS_BORDER) {
4041 InflateRect((LPRECT)lParam, -GetSystemMetrics(SM_CXEDGE),
4042 -GetSystemMetrics(SM_CYEDGE));
4044 TRACE("new client=(%ld,%ld)-(%ld,%ld)\n",
4045 ((LPRECT)lParam)->left, ((LPRECT)lParam)->top,
4046 ((LPRECT)lParam)->right, ((LPRECT)lParam)->bottom);
4052 REBAR_NCCreate (HWND hwnd, WPARAM wParam, LPARAM lParam)
4054 LPCREATESTRUCTA cs = (LPCREATESTRUCTA) lParam;
4055 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
4057 NONCLIENTMETRICSA ncm;
4061 if (infoPtr != NULL) {
4062 ERR("Strange info structure pointer *not* NULL\n");
4066 if (TRACE_ON(rebar)) {
4067 GetWindowRect(hwnd, &wnrc1);
4068 GetClientRect(hwnd, &clrc1);
4069 TRACE("window=(%ld,%ld)-(%ld,%ld) client=(%ld,%ld)-(%ld,%ld) cs=(%d,%d %dx%d)\n",
4070 wnrc1.left, wnrc1.top, wnrc1.right, wnrc1.bottom,
4071 clrc1.left, clrc1.top, clrc1.right, clrc1.bottom,
4072 cs->x, cs->y, cs->cx, cs->cy);
4075 /* allocate memory for info structure */
4076 infoPtr = (REBAR_INFO *)Alloc (sizeof(REBAR_INFO));
4077 SetWindowLongPtrW (hwnd, 0, (DWORD_PTR)infoPtr);
4079 /* initialize info structure - initial values are 0 */
4080 infoPtr->clrBk = CLR_NONE;
4081 infoPtr->clrText = CLR_NONE;
4082 infoPtr->clrBtnText = GetSysColor (COLOR_BTNTEXT);
4083 infoPtr->clrBtnFace = GetSysColor (COLOR_BTNFACE);
4084 infoPtr->iOldBand = -1;
4085 infoPtr->ichevronhotBand = -2;
4086 infoPtr->iGrabbedBand = -1;
4087 infoPtr->hwndSelf = hwnd;
4088 infoPtr->DoRedraw = TRUE;
4089 infoPtr->hcurArrow = LoadCursorA (0, (LPSTR)IDC_ARROW);
4090 infoPtr->hcurHorz = LoadCursorA (0, (LPSTR)IDC_SIZEWE);
4091 infoPtr->hcurVert = LoadCursorA (0, (LPSTR)IDC_SIZENS);
4092 infoPtr->hcurDrag = LoadCursorA (0, (LPSTR)IDC_SIZE);
4093 infoPtr->bUnicode = IsWindowUnicode (hwnd);
4094 infoPtr->fStatus = CREATE_RUNNING;
4095 infoPtr->hFont = GetStockObject (SYSTEM_FONT);
4097 /* issue WM_NOTIFYFORMAT to get unicode status of parent */
4098 i = SendMessageA(REBAR_GetNotifyParent (infoPtr),
4099 WM_NOTIFYFORMAT, (WPARAM)hwnd, NF_QUERY);
4100 if ((i < NFR_ANSI) || (i > NFR_UNICODE)) {
4101 ERR("wrong response to WM_NOTIFYFORMAT (%d), assuming ANSI\n",
4105 infoPtr->NtfUnicode = (i == NFR_UNICODE) ? 1 : 0;
4107 /* add necessary styles to the requested styles */
4108 infoPtr->dwStyle = cs->style | WS_VISIBLE | CCS_TOP;
4109 SetWindowLongA (hwnd, GWL_STYLE, infoPtr->dwStyle);
4111 /* get font handle for Caption Font */
4112 ncm.cbSize = sizeof(NONCLIENTMETRICSA);
4113 SystemParametersInfoA (SPI_GETNONCLIENTMETRICS,
4114 ncm.cbSize, &ncm, 0);
4115 /* if the font is bold, set to normal */
4116 if (ncm.lfCaptionFont.lfWeight > FW_NORMAL) {
4117 ncm.lfCaptionFont.lfWeight = FW_NORMAL;
4119 tfont = CreateFontIndirectA (&ncm.lfCaptionFont);
4121 infoPtr->hFont = infoPtr->hDefaultFont = tfont;
4125 GetSysColor (numerous);
4126 GetSysColorBrush (numerous) (see WM_SYSCOLORCHANGE);
4127 *GetStockObject (SYSTEM_FONT);
4128 *SetWindowLong (hwnd, 0, info ptr);
4130 *SetWindowLong (hwnd, GWL_STYLE, style+0x10000001);
4131 WS_VISIBLE = 0x10000000;
4132 CCS_TOP = 0x00000001;
4133 *SystemParametersInfo (SPI_GETNONCLIENTMETRICS...);
4134 *CreateFontIndirect (lfCaptionFont from above);
4136 SelectObject (hdc, fontabove);
4137 GetTextMetrics (hdc, ); guessing is tmHeight
4138 SelectObject (hdc, oldfont);
4141 MapWindowPoints (0, parent, rectabove, 2);
4144 ClientToScreen (clientrect);
4145 SetWindowPos (hwnd, 0, 0, 0, 0, 0, SWP_NOZORDER);
4152 REBAR_NCHitTest (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
4159 LRESULT ret = HTCLIENT;
4162 * Differences from doc at MSDN (as observed with version 4.71 of
4164 * 1. doc says nmmouse.pt is in screen coord, trace shows client coord.
4165 * 2. if band is not identified .dwItemSpec is 0xffffffff.
4166 * 3. native always seems to return HTCLIENT if notify return is 0.
4169 shortpt = MAKEPOINTS (lParam);
4170 POINTSTOPOINT(pt, shortpt);
4172 ScreenToClient (infoPtr->hwndSelf, &clpt);
4173 REBAR_InternalHitTest (infoPtr, &clpt, &scrap,
4174 (INT *)&nmmouse.dwItemSpec);
4175 nmmouse.dwItemData = 0;
4177 nmmouse.dwHitInfo = 0;
4178 if ((i = REBAR_Notify((NMHDR *) &nmmouse, infoPtr, NM_NCHITTEST))) {
4179 TRACE("notify changed return value from %ld to %d\n",
4183 TRACE("returning %ld, client point (%ld,%ld)\n", ret, clpt.x, clpt.y);
4189 REBAR_NCPaint (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
4194 if (infoPtr->dwStyle & WS_MINIMIZE)
4195 return 0; /* Nothing to do */
4197 if (infoPtr->dwStyle & WS_BORDER) {
4199 /* adjust rectangle and draw the necessary edge */
4200 if (!(hdc = GetDCEx( infoPtr->hwndSelf, 0, DCX_USESTYLE | DCX_WINDOW )))
4202 GetWindowRect (infoPtr->hwndSelf, &rcWindow);
4203 OffsetRect (&rcWindow, -rcWindow.left, -rcWindow.top);
4204 TRACE("rect (%ld,%ld)-(%ld,%ld)\n",
4205 rcWindow.left, rcWindow.top,
4206 rcWindow.right, rcWindow.bottom);
4207 DrawEdge (hdc, &rcWindow, EDGE_ETCHED, BF_RECT);
4208 ReleaseDC( infoPtr->hwndSelf, hdc );
4216 REBAR_NotifyFormat (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
4220 if (lParam == NF_REQUERY) {
4221 i = SendMessageA(REBAR_GetNotifyParent (infoPtr),
4222 WM_NOTIFYFORMAT, (WPARAM)infoPtr->hwndSelf, NF_QUERY);
4223 if ((i < NFR_ANSI) || (i > NFR_UNICODE)) {
4224 ERR("wrong response to WM_NOTIFYFORMAT (%d), assuming ANSI\n",
4228 infoPtr->NtfUnicode = (i == NFR_UNICODE) ? 1 : 0;
4231 return (LRESULT)((infoPtr->bUnicode) ? NFR_UNICODE : NFR_ANSI);
4236 REBAR_Paint (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
4242 GetClientRect(infoPtr->hwndSelf, &rc);
4243 hdc = wParam==0 ? BeginPaint (infoPtr->hwndSelf, &ps) : (HDC)wParam;
4245 TRACE("painting (%ld,%ld)-(%ld,%ld) client (%ld,%ld)-(%ld,%ld)\n",
4246 ps.rcPaint.left, ps.rcPaint.top,
4247 ps.rcPaint.right, ps.rcPaint.bottom,
4248 rc.left, rc.top, rc.right, rc.bottom);
4251 /* Erase area of paint if requested */
4252 REBAR_InternalEraseBkGnd (infoPtr, wParam, lParam, &ps.rcPaint);
4255 REBAR_Refresh (infoPtr, hdc);
4257 EndPaint (infoPtr->hwndSelf, &ps);
4263 REBAR_SetCursor (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
4268 TRACE("code=0x%X id=0x%X\n", LOWORD(lParam), HIWORD(lParam));
4271 ScreenToClient (infoPtr->hwndSelf, &pt);
4273 REBAR_InternalHitTest (infoPtr, &pt, &flags, NULL);
4275 if (flags == RBHT_GRABBER) {
4276 if ((infoPtr->dwStyle & CCS_VERT) &&
4277 !(infoPtr->dwStyle & RBS_VERTICALGRIPPER))
4278 SetCursor (infoPtr->hcurVert);
4280 SetCursor (infoPtr->hcurHorz);
4282 else if (flags != RBHT_CLIENT)
4283 SetCursor (infoPtr->hcurArrow);
4290 REBAR_SetFont (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
4296 infoPtr->hFont = (HFONT)wParam;
4298 /* revalidate all bands to change sizes of text in headers of bands */
4299 for (i=0; i<infoPtr->uNumBands; i++) {
4300 lpBand = &infoPtr->bands[i];
4301 REBAR_ValidateBand (infoPtr, lpBand);
4305 if (LOWORD(lParam)) {
4306 GetClientRect (infoPtr->hwndSelf, &rcClient);
4307 REBAR_Layout (infoPtr, &rcClient, FALSE, TRUE);
4314 inline static LRESULT
4315 REBAR_SetRedraw (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
4316 /*****************************************************
4319 * Handles the WM_SETREDRAW message.
4322 * According to testing V4.71 of COMCTL32 returns the
4323 * *previous* status of the redraw flag (either 0 or -1)
4324 * instead of the MSDN documented value of 0 if handled
4326 *****************************************************/
4328 BOOL oldredraw = infoPtr->DoRedraw;
4330 TRACE("set to %s, fStatus=%08x\n",
4331 (wParam) ? "TRUE" : "FALSE", infoPtr->fStatus);
4332 infoPtr->DoRedraw = (BOOL) wParam;
4334 if (infoPtr->fStatus & BAND_NEEDS_REDRAW) {
4335 REBAR_MoveChildWindows (infoPtr, 0, infoPtr->uNumBands);
4336 REBAR_ForceResize (infoPtr);
4337 InvalidateRect (infoPtr->hwndSelf, 0, TRUE);
4339 infoPtr->fStatus &= ~BAND_NEEDS_REDRAW;
4341 return (oldredraw) ? -1 : 0;
4346 REBAR_Size (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
4350 /* auto resize deadlock check */
4351 if (infoPtr->fStatus & AUTO_RESIZE) {
4352 infoPtr->fStatus &= ~AUTO_RESIZE;
4353 TRACE("AUTO_RESIZE was set, reset, fStatus=%08x lparam=%08lx\n",
4354 infoPtr->fStatus, lParam);
4358 if (infoPtr->fStatus & CREATE_RUNNING) {
4359 /* still in CreateWindow */
4362 if ((INT)wParam != SIZE_RESTORED) {
4363 ERR("WM_SIZE in create and flags=%08x, lParam=%08lx\n",
4367 TRACE("still in CreateWindow\n");
4368 infoPtr->fStatus &= ~CREATE_RUNNING;
4369 GetWindowRect ( infoPtr->hwndSelf, &rcWin);
4370 TRACE("win rect (%ld,%ld)-(%ld,%ld)\n",
4371 rcWin.left, rcWin.top, rcWin.right, rcWin.bottom);
4373 if ((lParam == 0) && (rcWin.right-rcWin.left == 0) &&
4374 (rcWin.bottom-rcWin.top == 0)) {
4375 /* native control seems to do this */
4376 GetClientRect (GetParent(infoPtr->hwndSelf), &rcClient);
4377 TRACE("sizing rebar, message and client zero, parent client (%ld,%ld)\n",
4378 rcClient.right, rcClient.bottom);
4383 cx = rcWin.right - rcWin.left;
4384 cy = rcWin.bottom - rcWin.top;
4385 if ((cx == LOWORD(lParam)) && (cy == HIWORD(lParam))) {
4389 /* do the actual WM_SIZE request */
4390 GetClientRect (infoPtr->hwndSelf, &rcClient);
4391 TRACE("sizing rebar from (%ld,%ld) to (%d,%d), client (%ld,%ld)\n",
4392 infoPtr->calcSize.cx, infoPtr->calcSize.cy,
4393 LOWORD(lParam), HIWORD(lParam),
4394 rcClient.right, rcClient.bottom);
4398 if ((INT)wParam != SIZE_RESTORED) {
4399 ERR("WM_SIZE out of create and flags=%08x, lParam=%08lx\n",
4403 /* Handle cases when outside of the CreateWindow process */
4405 GetClientRect (infoPtr->hwndSelf, &rcClient);
4406 if ((lParam == 0) && (rcClient.right + rcClient.bottom != 0) &&
4407 (infoPtr->dwStyle & RBS_AUTOSIZE)) {
4408 /* on a WM_SIZE to zero and current client not zero and AUTOSIZE */
4409 /* native seems to use the current client rect for the size */
4410 infoPtr->fStatus |= BAND_NEEDS_LAYOUT;
4411 TRACE("sizing rebar to client (%ld,%ld) size is zero but AUTOSIZE set\n",
4412 rcClient.right, rcClient.bottom);
4415 TRACE("sizing rebar from (%ld,%ld) to (%d,%d), client (%ld,%ld)\n",
4416 infoPtr->calcSize.cx, infoPtr->calcSize.cy,
4417 LOWORD(lParam), HIWORD(lParam),
4418 rcClient.right, rcClient.bottom);
4422 if (infoPtr->dwStyle & RBS_AUTOSIZE) {
4423 NMRBAUTOSIZE autosize;
4425 GetClientRect(infoPtr->hwndSelf, &autosize.rcTarget);
4426 autosize.fChanged = 0; /* ??? */
4427 autosize.rcActual = autosize.rcTarget; /* ??? */
4428 REBAR_Notify((NMHDR *) &autosize, infoPtr, RBN_AUTOSIZE);
4429 TRACE("RBN_AUTOSIZE client=(%ld,%ld), lp=%08lx\n",
4430 autosize.rcTarget.right, autosize.rcTarget.bottom, lParam);
4433 if ((infoPtr->calcSize.cx != rcClient.right) ||
4434 (infoPtr->calcSize.cy != rcClient.bottom))
4435 infoPtr->fStatus |= BAND_NEEDS_LAYOUT;
4437 REBAR_Layout (infoPtr, &rcClient, TRUE, TRUE);
4444 REBAR_StyleChanged (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
4446 STYLESTRUCT *ss = (STYLESTRUCT *)lParam;
4448 TRACE("current style=%08lx, styleOld=%08lx, style being set to=%08lx\n",
4449 infoPtr->dwStyle, ss->styleOld, ss->styleNew);
4450 infoPtr->dwStyle = ss->styleNew;
4457 REBAR_WindowPosChanged (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
4459 WINDOWPOS *lpwp = (WINDOWPOS *)lParam;
4463 /* Save the new origin of this window - used by _ForceResize */
4464 infoPtr->origin.x = lpwp->x;
4465 infoPtr->origin.y = lpwp->y;
4466 ret = DefWindowProcA(infoPtr->hwndSelf, WM_WINDOWPOSCHANGED,
4468 GetWindowRect(infoPtr->hwndSelf, &rc);
4469 TRACE("hwnd %p new pos (%ld,%ld)-(%ld,%ld)\n",
4470 infoPtr->hwndSelf, rc.left, rc.top, rc.right, rc.bottom);
4475 static LRESULT WINAPI
4476 REBAR_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
4478 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
4480 TRACE("hwnd=%p msg=%x wparam=%x lparam=%lx\n",
4481 hwnd, uMsg, wParam, lParam);
4482 if (!infoPtr && (uMsg != WM_NCCREATE))
4483 return DefWindowProcA (hwnd, uMsg, wParam, lParam);
4486 /* case RB_BEGINDRAG: */
4489 return REBAR_DeleteBand (infoPtr, wParam, lParam);
4491 /* case RB_DRAGMOVE: */
4492 /* case RB_ENDDRAG: */
4494 case RB_GETBANDBORDERS:
4495 return REBAR_GetBandBorders (infoPtr, wParam, lParam);
4497 case RB_GETBANDCOUNT:
4498 return REBAR_GetBandCount (infoPtr);
4500 case RB_GETBANDINFO_OLD:
4501 case RB_GETBANDINFOA:
4502 return REBAR_GetBandInfoA (infoPtr, wParam, lParam);
4504 case RB_GETBANDINFOW:
4505 return REBAR_GetBandInfoW (infoPtr, wParam, lParam);
4507 case RB_GETBARHEIGHT:
4508 return REBAR_GetBarHeight (infoPtr, wParam, lParam);
4511 return REBAR_GetBarInfo (infoPtr, wParam, lParam);
4514 return REBAR_GetBkColor (infoPtr);
4516 /* case RB_GETCOLORSCHEME: */
4517 /* case RB_GETDROPTARGET: */
4520 return REBAR_GetPalette (infoPtr, wParam, lParam);
4523 return REBAR_GetRect (infoPtr, wParam, lParam);
4525 case RB_GETROWCOUNT:
4526 return REBAR_GetRowCount (infoPtr);
4528 case RB_GETROWHEIGHT:
4529 return REBAR_GetRowHeight (infoPtr, wParam, lParam);
4531 case RB_GETTEXTCOLOR:
4532 return REBAR_GetTextColor (infoPtr);
4534 case RB_GETTOOLTIPS:
4535 return REBAR_GetToolTips (infoPtr);
4537 case RB_GETUNICODEFORMAT:
4538 return REBAR_GetUnicodeFormat (infoPtr);
4540 case CCM_GETVERSION:
4541 return REBAR_GetVersion (infoPtr);
4544 return REBAR_HitTest (infoPtr, wParam, lParam);
4547 return REBAR_IdToIndex (infoPtr, wParam, lParam);
4549 case RB_INSERTBANDA:
4550 return REBAR_InsertBandA (infoPtr, wParam, lParam);
4552 case RB_INSERTBANDW:
4553 return REBAR_InsertBandW (infoPtr, wParam, lParam);
4555 case RB_MAXIMIZEBAND:
4556 return REBAR_MaximizeBand (infoPtr, wParam, lParam);
4558 case RB_MINIMIZEBAND:
4559 return REBAR_MinimizeBand (infoPtr, wParam, lParam);
4562 return REBAR_MoveBand (infoPtr, wParam, lParam);
4564 case RB_PUSHCHEVRON:
4565 return REBAR_PushChevron (infoPtr, wParam, lParam);
4567 case RB_SETBANDINFOA:
4568 return REBAR_SetBandInfoA (infoPtr, wParam, lParam);
4570 case RB_SETBANDINFOW:
4571 return REBAR_SetBandInfoW (infoPtr, wParam, lParam);
4574 return REBAR_SetBarInfo (infoPtr, wParam, lParam);
4577 return REBAR_SetBkColor (infoPtr, wParam, lParam);
4579 /* case RB_SETCOLORSCHEME: */
4580 /* case RB_SETPALETTE: */
4581 /* return REBAR_GetPalette (infoPtr, wParam, lParam); */
4584 return REBAR_SetParent (infoPtr, wParam, lParam);
4586 case RB_SETTEXTCOLOR:
4587 return REBAR_SetTextColor (infoPtr, wParam, lParam);
4589 /* case RB_SETTOOLTIPS: */
4591 case RB_SETUNICODEFORMAT:
4592 return REBAR_SetUnicodeFormat (infoPtr, wParam);
4594 case CCM_SETVERSION:
4595 return REBAR_SetVersion (infoPtr, (INT)wParam);
4598 return REBAR_ShowBand (infoPtr, wParam, lParam);
4601 return REBAR_SizeToRect (infoPtr, wParam, lParam);
4604 /* Messages passed to parent */
4608 if (infoPtr->NtfUnicode)
4609 return SendMessageW (REBAR_GetNotifyParent (infoPtr),
4610 uMsg, wParam, lParam);
4612 return SendMessageA (REBAR_GetNotifyParent (infoPtr),
4613 uMsg, wParam, lParam);
4616 /* case WM_CHARTOITEM: supported according to ControlSpy */
4619 return REBAR_Create (infoPtr, wParam, lParam);
4622 return REBAR_Destroy (infoPtr, wParam, lParam);
4625 return REBAR_EraseBkGnd (infoPtr, wParam, lParam);
4628 return REBAR_GetFont (infoPtr, wParam, lParam);
4630 /* case WM_LBUTTONDBLCLK: supported according to ControlSpy */
4632 case WM_LBUTTONDOWN:
4633 return REBAR_LButtonDown (infoPtr, wParam, lParam);
4636 return REBAR_LButtonUp (infoPtr, wParam, lParam);
4638 /* case WM_MEASUREITEM: supported according to ControlSpy */
4641 return REBAR_MouseMove (infoPtr, wParam, lParam);
4644 return REBAR_MouseLeave (infoPtr, wParam, lParam);
4647 return REBAR_NCCalcSize (infoPtr, wParam, lParam);
4650 return REBAR_NCCreate (hwnd, wParam, lParam);
4653 return REBAR_NCHitTest (infoPtr, wParam, lParam);
4656 return REBAR_NCPaint (infoPtr, wParam, lParam);
4658 case WM_NOTIFYFORMAT:
4659 return REBAR_NotifyFormat (infoPtr, wParam, lParam);
4662 return REBAR_Paint (infoPtr, wParam, lParam);
4664 /* case WM_PALETTECHANGED: supported according to ControlSpy */
4665 /* case WM_PRINTCLIENT: supported according to ControlSpy */
4666 /* case WM_QUERYNEWPALETTE:supported according to ControlSpy */
4667 /* case WM_RBUTTONDOWN: supported according to ControlSpy */
4668 /* case WM_RBUTTONUP: supported according to ControlSpy */
4671 return REBAR_SetCursor (infoPtr, wParam, lParam);
4674 return REBAR_SetFont (infoPtr, wParam, lParam);
4677 return REBAR_SetRedraw (infoPtr, wParam, lParam);
4680 return REBAR_Size (infoPtr, wParam, lParam);
4682 case WM_STYLECHANGED:
4683 return REBAR_StyleChanged (infoPtr, wParam, lParam);
4685 /* case WM_SYSCOLORCHANGE: supported according to ControlSpy */
4686 /* "Applications that have brushes using the existing system colors
4687 should delete those brushes and recreate them using the new
4688 system colors." per MSDN */
4690 /* case WM_VKEYTOITEM: supported according to ControlSpy */
4691 /* case WM_WININICHANGE: */
4693 case WM_WINDOWPOSCHANGED:
4694 return REBAR_WindowPosChanged (infoPtr, wParam, lParam);
4697 if ((uMsg >= WM_USER) && (uMsg < WM_APP))
4698 ERR("unknown msg %04x wp=%08x lp=%08lx\n",
4699 uMsg, wParam, lParam);
4700 return DefWindowProcA (hwnd, uMsg, wParam, lParam);
4707 REBAR_Register (void)
4711 ZeroMemory (&wndClass, sizeof(WNDCLASSA));
4712 wndClass.style = CS_GLOBALCLASS | CS_DBLCLKS;
4713 wndClass.lpfnWndProc = (WNDPROC)REBAR_WindowProc;
4714 wndClass.cbClsExtra = 0;
4715 wndClass.cbWndExtra = sizeof(REBAR_INFO *);
4716 wndClass.hCursor = 0;
4717 wndClass.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1);
4719 wndClass.hbrBackground = CreateSolidBrush(RGB(0,128,0));
4721 wndClass.lpszClassName = REBARCLASSNAMEA;
4723 RegisterClassA (&wndClass);
4725 mindragx = GetSystemMetrics (SM_CXDRAG);
4726 mindragy = GetSystemMetrics (SM_CYDRAG);
4732 REBAR_Unregister (void)
4734 UnregisterClassA (REBARCLASSNAMEA, NULL);