2 * Testing: set to 1 to make background brush *always* green
8 * 2. At "FIXME: problem # 2" WinRAR:
9 * if "#if 1" then last band draws in separate row
10 * if "#if 0" then last band draws in previous row *** just like native ***
16 * 3. REBAR_MoveChildWindows should have a loop because more than
17 * one pass is made (together with the RBN_CHILDSIZEs) is made on
18 * at least RB_INSERTBAND
23 * Rebar control rev 8e
25 * Copyright 1998, 1999 Eric Kohl
27 * This library is free software; you can redistribute it and/or
28 * modify it under the terms of the GNU Lesser General Public
29 * License as published by the Free Software Foundation; either
30 * version 2.1 of the License, or (at your option) any later version.
32 * This library is distributed in the hope that it will be useful,
33 * but WITHOUT ANY WARRANTY; without even the implied warranty of
34 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
35 * Lesser General Public License for more details.
37 * You should have received a copy of the GNU Lesser General Public
38 * License along with this library; if not, write to the Free Software
39 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
42 * An author is needed! Any volunteers?
43 * I will only improve this control once in a while.
44 * Eric <ekohl@abo.rhein-zeitung.de>
47 * - vertical placement
48 * - ComboBox and ComboBoxEx placement
53 * - All notifications.
55 * Changes Guy Albertelli <galberte@neo.lrun.com>
57 * - Implement initial version of row grouping, row separators,
58 * text and background colors. Support additional messages.
59 * Support RBBS_BREAK. Implement ERASEBKGND and improve painting.
61 * - implement support for dragging Gripper left or right in a row. Supports
62 * WM_LBUTTONDOWN, WM_LBUTTONUP, and WM_MOUSEMOVE. Also support
65 * - Fix or implement notifications for RBN_HEIGHTCHANGE, RBN_CHILDSIZE.
66 * - Correct styles RBBS_NOGRIPPER, RBBS_GRIPPERALWAYS, and RBBS_FIXEDSIZE.
67 * - Fix algorithm for Layout and AdjustBand.
70 * - Fix algorithm for _Layout and _AdjustBand.
71 * - Fix or implement RBN_ENDDRAG, RB_MOVEBAND, WM_SETREDRAW,
72 * WM_STYLECHANGED, RB_MINIMIZEBAND, RBBS_VARIABLEHEIGHT, RBS_VARHEIGHT,
73 * RBBS_HIDDEN, WM_NOTIFYFORMAT, NM_NCHITTEST, WM_SETREDRAW, RBS_AUTOSIZE,
74 * WM_SETFONT, RBS_BORDERS
75 * - Create structures in WM_NCCREATE
76 * - Additional performance enhancements.
79 * 1. Create array of start and end band indexes by row and use.
80 * 2. Fix problem with REBAR_Layout Phase 2b to process only if only
82 * 3. Set the Caption Font (Regular) as default font for text.
83 * 4. Delete font handle on control distruction.
84 * 5. Add UpdateWindow call in _MoveChildWindows to match repainting done
86 * 6. Improve some traces.
87 * 7. Invalidate window rectangles after SetBandInfo, InsertBand, ShowBand
88 * so that repainting is correct.
89 * 8. Implement RB_MAXIMIZEBAND for the "ideal=TRUE" case.
90 * 9. Implement item custom draw notifications partially. Only done for
91 * ITEMPREPAINT and ITEMPOSTPAINT. (Used by IE4 for "Favorites" frame
92 * to draw the word "Favorites").
94 * 10. Handle CCS_NODIVIDER and fix WS_BORDER code.
95 * 11. Fix logic error in _AdjustBands where flag was set to valid band
96 * number (0) to indicate *no* band.
97 * 12. Fix CCS_VERT errors in _ForceResize, _NCCalcSize, and _NCPaint.
98 * 13. Support some special cases of CCS_TOP (and therefore CCS_LEFT),
99 * CCS_BOTTOM (and therefore CCS_RIGHT) and CCS_NOPARENTALIGN. Not
100 * at all sure whether this is all cases.
101 * 14. Handle returned value for the RBN_CHILDSIZE notify.
102 * 15. Implement RBBS_CHILDEDGE, and set each bands "offChild" at _Layout
104 * 16. Fix REBARSPACE. It should depend on CCS_NODIVIDER.
106 * 17. Fix determination of whether Gripper is needed in _ValidateBand.
107 * 18. Fix _AdjustBand processing of RBBS_FIXEDSIZE.
109 * 19. Fix problem in _Layout when all lengths are 0.
110 * 20. If CLR_NONE specified, we will use default BtnFace color when drawing.
111 * 21. Fix test in REBAR_Layout.
113 * 22. Add support for WM_WINDOWPOSCHANGED to save new origin of window.
114 * 23. Correct RBN_CHILDSIZE rect value for CCS_VERT rebar.
115 * 24. Do UpdateWindow only if doing redraws.
117 * 25. Adjust setting of offChild.cx based on RBBS_CHILDEDGE.
121 * 2. Following still not handled: RBBS_FIXEDBMP,
122 * RBBS_USECHEVRON, CCS_NORESIZE,
123 * CCS_NOMOVEX, CCS_NOMOVEY
124 * 3. Following are only partially handled:
125 * RBS_AUTOSIZE, RBBS_VARIABLEHEIGHT
126 * 5. Native uses (on each draw!!) SM_CYBORDER (or SM_CXBORDER for CCS_VERT)
127 * to set the size of the separator width (the value SEP_WIDTH_SIZE
128 * in here). Should be fixed!!
129 * 6. The following messages are not implemented:
130 * RB_BEGINDRAG, RB_DRAGMOVE, RB_ENDDRAG, RB_GETCOLORSCHEME,
131 * RB_GETDROPTARGET, RB_MAXIMIZEBAND,
132 * RB_SETCOLORSCHEME, RB_SETPALETTE, RB_SETTOOLTIPS
133 * WM_CHARTOITEM, WM_LBUTTONDBLCLK, WM_MEASUREITEM,
134 * WM_PALETTECHANGED, WM_PRINTCLIENT, WM_QUERYNEWPALETTE,
135 * WM_RBUTTONDOWN, WM_RBUTTONUP,
136 * WM_SYSCOLORCHANGE, WM_VKEYTOITEM, WM_WININICHANGE
137 * 7. The following notifications are not implemented:
138 * NM_CUSTOMDRAW, NM_RELEASEDCAPTURE
139 * RB_CHEVRONPUSHED, RBN_MINMAX
149 #include "wine/unicode.h"
152 #include "commctrl.h"
153 #include "wine/debug.h"
155 WINE_DEFAULT_DEBUG_CHANNEL(rebar);
165 UINT cxMinChild; /* valid if _CHILDSIZE */
166 UINT cyMinChild; /* valid if _CHILDSIZE */
167 UINT cx; /* valid if _SIZE */
170 UINT cyChild; /* valid if _CHILDSIZE */
171 UINT cyMaxChild; /* valid if _CHILDSIZE */
172 UINT cyIntegral; /* valid if _CHILDSIZE */
177 UINT lcx; /* minimum cx for band */
178 UINT ccx; /* current cx for band */
179 UINT hcx; /* maximum cx for band */
180 UINT lcy; /* minimum cy for band */
181 UINT ccy; /* current cy for band */
182 UINT hcy; /* maximum cy for band */
184 SIZE offChild; /* x,y offset if child is not FIXEDSIZE */
186 INT iRow; /* row this band assigned to */
187 UINT fStatus; /* status flags, reset only by _Validate */
188 UINT fDraw; /* drawing flags, reset only by _Layout */
189 UINT uCDret; /* last return from NM_CUSTOMDRAW */
190 RECT rcoldBand; /* previous calculated band rectangle */
191 RECT rcBand; /* calculated band rectangle */
192 RECT rcGripper; /* calculated gripper rectangle */
193 RECT rcCapImage; /* calculated caption image rectangle */
194 RECT rcCapText; /* calculated caption text rectangle */
195 RECT rcChild; /* calculated child rectangle */
202 #define HAS_GRIPPER 0x00000001
203 #define HAS_IMAGE 0x00000002
204 #define HAS_TEXT 0x00000004
207 #define DRAW_GRIPPER 0x00000001
208 #define DRAW_IMAGE 0x00000002
209 #define DRAW_TEXT 0x00000004
210 #define DRAW_RIGHTSEP 0x00000010
211 #define DRAW_BOTTOMSEP 0x00000020
212 #define NTF_INVALIDATE 0x01000000
216 INT istartband; /* index of first band in row */
217 INT iendband; /* index of last band in row */
223 COLORREF clrBk; /* background color */
224 COLORREF clrText; /* text color */
225 COLORREF clrBtnText; /* system color for BTNTEXT */
226 COLORREF clrBtnFace; /* system color for BTNFACE */
227 HIMAGELIST himl; /* handle to imagelist */
228 UINT uNumBands; /* # of bands in rebar (first=0, last=uNumBands-1 */
229 UINT uNumRows; /* # of rows of bands (first=1, last=uNumRows */
230 HWND hwndSelf; /* handle of REBAR window itself */
231 HWND hwndToolTip; /* handle to the tool tip control */
232 HWND hwndNotify; /* notification window (parent) */
234 HFONT hFont; /* handle to the rebar's font */
235 SIZE imageSize; /* image size (image list) */
236 DWORD dwStyle; /* window style */
237 SIZE calcSize; /* calculated rebar size */
238 SIZE oldSize; /* previous calculated rebar size */
239 BOOL bUnicode; /* TRUE if this window is W type */
240 BOOL NtfUnicode; /* TRUE if parent wants notify in W format */
241 BOOL DoRedraw; /* TRUE to acutally draw bands */
242 UINT fStatus; /* Status flags (see below) */
243 HCURSOR hcurArrow; /* handle to the arrow cursor */
244 HCURSOR hcurHorz; /* handle to the EW cursor */
245 HCURSOR hcurVert; /* handle to the NS cursor */
246 HCURSOR hcurDrag; /* handle to the drag cursor */
247 INT iVersion; /* version number */
248 POINTS dragStart; /* x,y of button down */
249 POINTS dragNow; /* x,y of this MouseMove */
250 INT ihitBand; /* band number of band whose gripper was grabbed */
251 INT ihitoffset; /* offset of hotspot from gripper.left */
252 POINT origin; /* left/upper corner of client */
254 REBAR_ROW *rows; /* pointer to row indexes */
255 REBAR_BAND *bands; /* pointer to the array of rebar bands */
259 #define BEGIN_DRAG_ISSUED 0x00000001
260 #define AUTO_RESIZE 0x00000002
261 #define RESIZE_ANYHOW 0x00000004
262 #define NTF_HGHTCHG 0x00000008
263 #define BAND_NEEDS_LAYOUT 0x00000010
264 #define BAND_NEEDS_REDRAW 0x00000020
265 #define CREATE_RUNNING 0x00000040
267 /* ---- REBAR layout constants. Mostly determined by ---- */
268 /* ---- experiment on WIN 98. ---- */
270 /* Width (or height) of separators between bands (either horz. or */
271 /* vert.). True only if RBS_BANDBORDERS is set */
272 #define SEP_WIDTH_SIZE 2
273 #define SEP_WIDTH ((infoPtr->dwStyle & RBS_BANDBORDERS) ? SEP_WIDTH_SIZE : 0)
275 /* Blank (background color) space between Gripper (if present) */
276 /* and next item (image, text, or window). Always present */
277 #define REBAR_ALWAYS_SPACE 4
279 /* Blank (background color) space after Image (if present). */
280 #define REBAR_POST_IMAGE 2
282 /* Blank (background color) space after Text (if present). */
283 #define REBAR_POST_TEXT 4
285 /* Height of vertical gripper in a CCS_VERT rebar. */
286 #define GRIPPER_HEIGHT 16
288 /* Blank (background color) space before Gripper (if present). */
289 #define REBAR_PRE_GRIPPER 2
291 /* Width (of normal vertical gripper) or height (of horz. gripper) */
293 #define GRIPPER_WIDTH 3
295 /* Height of divider for Rebar if not disabled (CCS_NODIVIDER) */
296 /* either top or bottom */
297 #define REBAR_DIVIDER 2
299 /* This is the increment that is used over the band height */
300 #define REBARSPACE(a) ((a->fStyle & RBBS_CHILDEDGE) ? 2*REBAR_DIVIDER : 0)
302 /* ---- End of REBAR layout constants. ---- */
305 /* The following 6 defines return the proper rcBand element */
306 /* depending on whether CCS_VERT was set. */
307 #define rcBlt(b) ((infoPtr->dwStyle & CCS_VERT) ? b->rcBand.top : b->rcBand.left)
308 #define rcBrb(b) ((infoPtr->dwStyle & CCS_VERT) ? b->rcBand.bottom : b->rcBand.right)
309 #define rcBw(b) ((infoPtr->dwStyle & CCS_VERT) ? (b->rcBand.bottom - b->rcBand.top) : \
310 (b->rcBand.right - b->rcBand.left))
311 #define ircBlt(b) ((infoPtr->dwStyle & CCS_VERT) ? b->rcBand.left : b->rcBand.top)
312 #define ircBrb(b) ((infoPtr->dwStyle & CCS_VERT) ? b->rcBand.right : b->rcBand.bottom)
313 #define ircBw(b) ((infoPtr->dwStyle & CCS_VERT) ? (b->rcBand.right - b->rcBand.left) : \
314 (b->rcBand.bottom - b->rcBand.top))
316 /* The following define determines if a given band is hidden */
317 #define HIDDENBAND(a) (((a)->fStyle & RBBS_HIDDEN) || \
318 ((infoPtr->dwStyle & CCS_VERT) && \
319 ((a)->fStyle & RBBS_NOVERT)))
321 /* The following defines adjust the right or left end of a rectangle */
322 #define READJ(b,i) do { if(infoPtr->dwStyle & CCS_VERT) b->rcBand.bottom+=(i); \
323 else b->rcBand.right += (i); } while(0)
324 #define LEADJ(b,i) do { if(infoPtr->dwStyle & CCS_VERT) b->rcBand.top+=(i); \
325 else b->rcBand.left += (i); } while(0)
328 #define REBAR_GetInfoPtr(wndPtr) ((REBAR_INFO *)GetWindowLongA (hwnd, 0))
331 /* "constant values" retrieved when DLL was initialized */
332 /* FIXME we do this when the classes are registered. */
333 static UINT mindragx = 0;
334 static UINT mindragy = 0;
336 static char *band_stylename[] = {
337 "RBBS_BREAK", /* 0001 */
338 "RBBS_FIXEDSIZE", /* 0002 */
339 "RBBS_CHILDEDGE", /* 0004 */
340 "RBBS_HIDDEN", /* 0008 */
341 "RBBS_NOVERT", /* 0010 */
342 "RBBS_FIXEDBMP", /* 0020 */
343 "RBBS_VARIABLEHEIGHT", /* 0040 */
344 "RBBS_GRIPPERALWAYS", /* 0080 */
345 "RBBS_NOGRIPPER", /* 0100 */
348 static char *band_maskname[] = {
349 "RBBIM_STYLE", /* 0x00000001 */
350 "RBBIM_COLORS", /* 0x00000002 */
351 "RBBIM_TEXT", /* 0x00000004 */
352 "RBBIM_IMAGE", /* 0x00000008 */
353 "RBBIM_CHILD", /* 0x00000010 */
354 "RBBIM_CHILDSIZE", /* 0x00000020 */
355 "RBBIM_SIZE", /* 0x00000040 */
356 "RBBIM_BACKGROUND", /* 0x00000080 */
357 "RBBIM_ID", /* 0x00000100 */
358 "RBBIM_IDEALSIZE", /* 0x00000200 */
359 "RBBIM_LPARAM", /* 0x00000400 */
360 "RBBIM_HEADERSIZE", /* 0x00000800 */
364 static CHAR line[200];
368 REBAR_FmtStyle( UINT style)
373 while (band_stylename[i]) {
374 if (style & (1<<i)) {
375 if (*line != 0) strcat(line, " | ");
376 strcat(line, band_stylename[i]);
385 REBAR_FmtMask( UINT mask)
390 while (band_maskname[i]) {
392 if (*line != 0) strcat(line, " | ");
393 strcat(line, band_maskname[i]);
402 REBAR_DumpBandInfo( LPREBARBANDINFOA pB)
404 if( !TRACE_ON(rebar) ) return;
405 TRACE("band info: ID=%u, size=%u, child=%p, clrF=0x%06lx, clrB=0x%06lx\n",
406 pB->wID, pB->cbSize, pB->hwndChild, pB->clrFore, pB->clrBack);
407 TRACE("band info: mask=0x%08x (%s)\n", pB->fMask, REBAR_FmtMask(pB->fMask));
408 if (pB->fMask & RBBIM_STYLE)
409 TRACE("band info: style=0x%08x (%s)\n", pB->fStyle, REBAR_FmtStyle(pB->fStyle));
410 if (pB->fMask & (RBBIM_SIZE | RBBIM_IDEALSIZE | RBBIM_HEADERSIZE | RBBIM_LPARAM )) {
412 if (pB->fMask & RBBIM_SIZE)
413 TRACE(" cx=%u", pB->cx);
414 if (pB->fMask & RBBIM_IDEALSIZE)
415 TRACE(" xIdeal=%u", pB->cxIdeal);
416 if (pB->fMask & RBBIM_HEADERSIZE)
417 TRACE(" xHeader=%u", pB->cxHeader);
418 if (pB->fMask & RBBIM_LPARAM)
419 TRACE(" lParam=0x%08lx", pB->lParam);
422 if (pB->fMask & RBBIM_CHILDSIZE)
423 TRACE("band info: xMin=%u, yMin=%u, yChild=%u, yMax=%u, yIntgl=%u\n",
425 pB->cyMinChild, pB->cyChild, pB->cyMaxChild, pB->cyIntegral);
429 REBAR_DumpBand (REBAR_INFO *iP)
434 if(! TRACE_ON(rebar) ) return;
436 TRACE("hwnd=%p: color=%08lx/%08lx, bands=%u, rows=%u, cSize=%ld,%ld\n",
437 iP->hwndSelf, iP->clrText, iP->clrBk, iP->uNumBands, iP->uNumRows,
438 iP->calcSize.cx, iP->calcSize.cy);
439 TRACE("hwnd=%p: flags=%08x, dragStart=%d,%d, dragNow=%d,%d, ihitBand=%d\n",
440 iP->hwndSelf, iP->fStatus, iP->dragStart.x, iP->dragStart.y,
441 iP->dragNow.x, iP->dragNow.y,
443 TRACE("hwnd=%p: style=%08lx, I'm Unicode=%s, notify in Unicode=%s, redraw=%s\n",
444 iP->hwndSelf, iP->dwStyle, (iP->bUnicode)?"TRUE":"FALSE",
445 (iP->NtfUnicode)?"TRUE":"FALSE", (iP->DoRedraw)?"TRUE":"FALSE");
446 for (i = 0; i < iP->uNumBands; i++) {
448 TRACE("band # %u: ID=%u, child=%p, row=%u, clrF=0x%06lx, clrB=0x%06lx\n",
449 i, pB->wID, pB->hwndChild, pB->iRow, pB->clrFore, pB->clrBack);
450 TRACE("band # %u: mask=0x%08x (%s)\n", i, pB->fMask, REBAR_FmtMask(pB->fMask));
451 if (pB->fMask & RBBIM_STYLE)
452 TRACE("band # %u: style=0x%08x (%s)\n",
453 i, pB->fStyle, REBAR_FmtStyle(pB->fStyle));
454 TRACE("band # %u: uMinH=%u xHeader=%u",
455 i, pB->uMinHeight, pB->cxHeader);
456 if (pB->fMask & (RBBIM_SIZE | RBBIM_IDEALSIZE | RBBIM_LPARAM )) {
457 if (pB->fMask & RBBIM_SIZE)
458 TRACE(" cx=%u", pB->cx);
459 if (pB->fMask & RBBIM_IDEALSIZE)
460 TRACE(" xIdeal=%u", pB->cxIdeal);
461 if (pB->fMask & RBBIM_LPARAM)
462 TRACE(" lParam=0x%08lx", pB->lParam);
466 TRACE("band # %u: xMin=%u, yMin=%u, yChild=%u, yMax=%u, yIntgl=%u\n",
467 i, pB->cxMinChild, pB->cyMinChild, pB->cyChild, pB->cyMaxChild, pB->cyIntegral);
468 if (pB->fMask & RBBIM_TEXT)
469 TRACE("band # %u: text=%s\n",
470 i, (pB->lpText) ? debugstr_w(pB->lpText) : "(null)");
471 TRACE("band # %u: lcx=%u, ccx=%u, hcx=%u, lcy=%u, ccy=%u, hcy=%u, offChild=%ld,%ld\n",
472 i, pB->lcx, pB->ccx, pB->hcx, pB->lcy, pB->ccy, pB->hcy, pB->offChild.cx, pB->offChild.cy);
473 TRACE("band # %u: fStatus=%08x, fDraw=%08x, Band=(%ld,%ld)-(%ld,%ld), Grip=(%ld,%ld)-(%ld,%ld)\n",
474 i, pB->fStatus, pB->fDraw,
475 pB->rcBand.left, pB->rcBand.top, pB->rcBand.right, pB->rcBand.bottom,
476 pB->rcGripper.left, pB->rcGripper.top, pB->rcGripper.right, pB->rcGripper.bottom);
477 TRACE("band # %u: Img=(%ld,%ld)-(%ld,%ld), Txt=(%ld,%ld)-(%ld,%ld), Child=(%ld,%ld)-(%ld,%ld)\n",
479 pB->rcCapImage.left, pB->rcCapImage.top, pB->rcCapImage.right, pB->rcCapImage.bottom,
480 pB->rcCapText.left, pB->rcCapText.top, pB->rcCapText.right, pB->rcCapText.bottom,
481 pB->rcChild.left, pB->rcChild.top, pB->rcChild.right, pB->rcChild.bottom);
488 REBAR_GetNotifyParent (REBAR_INFO *infoPtr)
492 parent = infoPtr->hwndNotify;
494 parent = GetParent (infoPtr->hwndSelf);
495 owner = GetWindow (infoPtr->hwndSelf, GW_OWNER);
496 if (owner) parent = owner;
503 REBAR_Notify (NMHDR *nmhdr, REBAR_INFO *infoPtr, UINT code)
507 parent = REBAR_GetNotifyParent (infoPtr);
508 nmhdr->idFrom = GetDlgCtrlID (infoPtr->hwndSelf);
509 nmhdr->hwndFrom = infoPtr->hwndSelf;
512 TRACE("window %p, code=%08x, %s\n", parent, code,
513 (infoPtr->NtfUnicode) ? "via Unicode" : "via ANSI");
515 if (infoPtr->NtfUnicode)
516 return SendMessageW (parent, WM_NOTIFY, (WPARAM) nmhdr->idFrom,
519 return SendMessageA (parent, WM_NOTIFY, (WPARAM) nmhdr->idFrom,
524 REBAR_Notify_NMREBAR (REBAR_INFO *infoPtr, UINT uBand, UINT code)
526 NMREBAR notify_rebar;
529 notify_rebar.dwMask = 0;
531 lpBand = &infoPtr->bands[uBand];
532 if (lpBand->fMask & RBBIM_ID) {
533 notify_rebar.dwMask |= RBNM_ID;
534 notify_rebar.wID = lpBand->wID;
536 if (lpBand->fMask & RBBIM_LPARAM) {
537 notify_rebar.dwMask |= RBNM_LPARAM;
538 notify_rebar.lParam = lpBand->lParam;
540 if (lpBand->fMask & RBBIM_STYLE) {
541 notify_rebar.dwMask |= RBNM_STYLE;
542 notify_rebar.fStyle = lpBand->fStyle;
545 notify_rebar.uBand = uBand;
546 return REBAR_Notify ((NMHDR *)¬ify_rebar, infoPtr, code);
550 REBAR_DrawBand (HDC hdc, REBAR_INFO *infoPtr, REBAR_BAND *lpBand)
556 if (lpBand->fDraw & DRAW_TEXT) {
557 hOldFont = SelectObject (hdc, infoPtr->hFont);
558 oldBkMode = SetBkMode (hdc, TRANSPARENT);
561 /* should test for CDRF_NOTIFYITEMDRAW here */
562 nmcd.dwDrawStage = CDDS_ITEMPREPAINT;
564 nmcd.rc = lpBand->rcBand;
565 nmcd.rc.right = lpBand->rcCapText.right;
566 nmcd.rc.bottom = lpBand->rcCapText.bottom;
567 nmcd.dwItemSpec = lpBand->wID;
569 nmcd.lItemlParam = lpBand->lParam;
570 lpBand->uCDret = REBAR_Notify ((NMHDR *)&nmcd, infoPtr, NM_CUSTOMDRAW);
571 if (lpBand->uCDret == CDRF_SKIPDEFAULT) {
572 if (oldBkMode != TRANSPARENT)
573 SetBkMode (hdc, oldBkMode);
574 SelectObject (hdc, hOldFont);
579 if (lpBand->fDraw & DRAW_GRIPPER)
580 DrawEdge (hdc, &lpBand->rcGripper, BDR_RAISEDINNER, BF_RECT | BF_MIDDLE);
582 /* draw caption image */
583 if (lpBand->fDraw & DRAW_IMAGE) {
587 pt.y = (lpBand->rcCapImage.bottom + lpBand->rcCapImage.top - infoPtr->imageSize.cy)/2;
588 pt.x = (lpBand->rcCapImage.right + lpBand->rcCapImage.left - infoPtr->imageSize.cx)/2;
590 ImageList_Draw (infoPtr->himl, lpBand->iImage, hdc,
595 /* draw caption text */
596 if (lpBand->fDraw & DRAW_TEXT) {
597 /* need to handle CDRF_NEWFONT here */
598 INT oldBkMode = SetBkMode (hdc, TRANSPARENT);
599 COLORREF oldcolor = CLR_NONE;
601 if (lpBand->clrFore != CLR_NONE) {
602 new = (lpBand->clrFore == CLR_DEFAULT) ? infoPtr->clrBtnText :
604 oldcolor = SetTextColor (hdc, new);
606 DrawTextW (hdc, lpBand->lpText, -1, &lpBand->rcCapText,
607 DT_CENTER | DT_VCENTER | DT_SINGLELINE);
608 if (oldBkMode != TRANSPARENT)
609 SetBkMode (hdc, oldBkMode);
610 if (lpBand->clrFore != CLR_NONE)
611 SetTextColor (hdc, oldcolor);
612 SelectObject (hdc, hOldFont);
615 if (lpBand->uCDret == (CDRF_NOTIFYPOSTPAINT | CDRF_NOTIFYITEMDRAW)) {
616 nmcd.dwDrawStage = CDDS_ITEMPOSTPAINT;
618 nmcd.rc = lpBand->rcBand;
619 nmcd.rc.right = lpBand->rcCapText.right;
620 nmcd.rc.bottom = lpBand->rcCapText.bottom;
621 nmcd.dwItemSpec = lpBand->wID;
623 nmcd.lItemlParam = lpBand->lParam;
624 lpBand->uCDret = REBAR_Notify ((NMHDR *)&nmcd, infoPtr, NM_CUSTOMDRAW);
630 REBAR_Refresh (REBAR_INFO *infoPtr, HDC hdc)
635 if (!infoPtr->DoRedraw) return;
637 oldrow = infoPtr->bands[0].iRow;
638 for (i = 0; i < infoPtr->uNumBands; i++) {
639 lpBand = &infoPtr->bands[i];
641 if (HIDDENBAND(lpBand)) continue;
643 /* now draw the band */
644 TRACE("[%p] drawing band %i, flags=%08x\n",
645 infoPtr->hwndSelf, i, lpBand->fDraw);
646 REBAR_DrawBand (hdc, infoPtr, lpBand);
653 REBAR_FixVert (REBAR_INFO *infoPtr, UINT rowstart, UINT rowend,
656 /* Cycle through bands in row and fix height of each band. */
657 /* Also determine whether each band has changed. */
659 /* all bands at desired size. */
660 /* start and end bands are *not* hidden */
665 for (i = (INT)rowstart; i<=(INT)rowend; i++) {
666 lpBand = &infoPtr->bands[i];
667 if (HIDDENBAND(lpBand)) continue;
669 /* adjust height of bands in row to "mcy" value */
670 if (infoPtr->dwStyle & CCS_VERT) {
671 if (lpBand->rcBand.right != lpBand->rcBand.left + mcy)
672 lpBand->rcBand.right = lpBand->rcBand.left + mcy;
675 if (lpBand->rcBand.bottom != lpBand->rcBand.top + mcy)
676 lpBand->rcBand.bottom = lpBand->rcBand.top + mcy;
680 /* mark whether we need to invalidate this band and trace */
681 if ((lpBand->rcoldBand.left !=lpBand->rcBand.left) ||
682 (lpBand->rcoldBand.top !=lpBand->rcBand.top) ||
683 (lpBand->rcoldBand.right !=lpBand->rcBand.right) ||
684 (lpBand->rcoldBand.bottom !=lpBand->rcBand.bottom)) {
685 lpBand->fDraw |= NTF_INVALIDATE;
686 TRACE("band %d row=%d: changed to (%ld,%ld)-(%ld,%ld) from (%ld,%ld)-(%ld,%ld)\n",
688 lpBand->rcBand.left, lpBand->rcBand.top,
689 lpBand->rcBand.right, lpBand->rcBand.bottom,
690 lpBand->rcoldBand.left, lpBand->rcoldBand.top,
691 lpBand->rcoldBand.right, lpBand->rcoldBand.bottom);
694 TRACE("band %d row=%d: unchanged (%ld,%ld)-(%ld,%ld)\n",
696 lpBand->rcBand.left, lpBand->rcBand.top,
697 lpBand->rcBand.right, lpBand->rcBand.bottom);
703 REBAR_AdjustBands (REBAR_INFO *infoPtr, UINT rowstart, UINT rowend,
705 /* Function: This routine distributes the extra space in a row. */
706 /* See algorithm below. */
708 /* all bands @ ->cxHeader size */
709 /* start and end bands are *not* hidden */
712 UINT x, xsep, extra, curwidth, fudge;
713 INT i, last_adjusted;
715 TRACE("start=%u, end=%u, max x=%d, max y=%d\n",
716 rowstart, rowend, maxx, mcy);
718 /* ******************* Phase 1 ************************ */
720 /* For each visible band with valid child */
721 /* a. inflate band till either all extra space used */
722 /* or band's ->ccx reached. */
723 /* If any band modified, add any space left to last band */
726 /* ****************************************************** */
727 lpBand = &infoPtr->bands[rowend];
728 extra = maxx - rcBrb(lpBand);
731 for (i=(INT)rowstart; i<=(INT)rowend; i++) {
732 lpBand = &infoPtr->bands[i];
733 if (HIDDENBAND(lpBand)) continue;
734 xsep = (x == 0) ? 0 : SEP_WIDTH;
735 curwidth = rcBw(lpBand);
737 /* set new left/top point */
738 if (infoPtr->dwStyle & CCS_VERT)
739 lpBand->rcBand.top = x + xsep;
741 lpBand->rcBand.left = x + xsep;
743 /* compute new width */
744 if ((lpBand->hwndChild && extra) && !(lpBand->fStyle & RBBS_FIXEDSIZE)) {
745 /* set to the "current" band size less the header */
748 if ((lpBand->fMask & RBBIM_SIZE) && (lpBand->cx > 0) &&
749 (fudge > curwidth)) {
750 TRACE("adjusting band %d by %d, fudge=%d, curwidth=%d, extra=%d\n",
751 i, fudge-curwidth, fudge, curwidth, extra);
752 if ((fudge - curwidth) > extra)
753 fudge = curwidth + extra;
754 extra -= (fudge - curwidth);
758 TRACE("adjusting band %d by %d, fudge=%d, curwidth=%d\n",
759 i, extra, fudge, curwidth);
765 /* set new right/bottom point */
766 if (infoPtr->dwStyle & CCS_VERT)
767 lpBand->rcBand.bottom = lpBand->rcBand.top + curwidth;
769 lpBand->rcBand.right = lpBand->rcBand.left + curwidth;
770 TRACE("Phase 1 band %d, (%ld,%ld)-(%ld,%ld), orig x=%d, xsep=%d\n",
771 i, lpBand->rcBand.left, lpBand->rcBand.top,
772 lpBand->rcBand.right, lpBand->rcBand.bottom, x, xsep);
775 if ((x >= maxx) || (last_adjusted != -1)) {
777 ERR("Phase 1 failed, x=%d, maxx=%d, start=%u, end=%u\n",
778 x, maxx, rowstart, rowend);
780 /* done, so spread extra space */
783 TRACE("Need to spread %d on last adjusted band %d\n",
784 fudge, last_adjusted);
785 for (i=(INT)last_adjusted; i<=(INT)rowend; i++) {
786 lpBand = &infoPtr->bands[i];
787 if (HIDDENBAND(lpBand)) continue;
789 /* set right/bottom point */
790 if (i != last_adjusted) {
791 if (infoPtr->dwStyle & CCS_VERT)
792 lpBand->rcBand.top += fudge;
794 lpBand->rcBand.left += fudge;
797 /* set left/bottom point */
798 if (infoPtr->dwStyle & CCS_VERT)
799 lpBand->rcBand.bottom += fudge;
801 lpBand->rcBand.right += fudge;
804 TRACE("Phase 1 succeeded, used x=%d\n", x);
805 REBAR_FixVert (infoPtr, rowstart, rowend, mcy);
809 /* ******************* Phase 2 ************************ */
811 /* Find first visible band, put all */
812 /* extra space there. */
814 /* ****************************************************** */
817 for (i=(INT)rowstart; i<=(INT)rowend; i++) {
818 lpBand = &infoPtr->bands[i];
819 if (HIDDENBAND(lpBand)) continue;
820 xsep = (x == 0) ? 0 : SEP_WIDTH;
821 curwidth = rcBw(lpBand);
823 /* set new left/top point */
824 if (infoPtr->dwStyle & CCS_VERT)
825 lpBand->rcBand.top = x + xsep;
827 lpBand->rcBand.left = x + xsep;
829 /* compute new width */
835 /* set new right/bottom point */
836 if (infoPtr->dwStyle & CCS_VERT)
837 lpBand->rcBand.bottom = lpBand->rcBand.top + curwidth;
839 lpBand->rcBand.right = lpBand->rcBand.left + curwidth;
840 TRACE("Phase 2 band %d, (%ld,%ld)-(%ld,%ld), orig x=%d, xsep=%d\n",
841 i, lpBand->rcBand.left, lpBand->rcBand.top,
842 lpBand->rcBand.right, lpBand->rcBand.bottom, x, xsep);
847 ERR("Phase 2 failed, x=%d, maxx=%d, start=%u, end=%u\n",
848 x, maxx, rowstart, rowend);
850 /* done, so spread extra space */
851 TRACE("Phase 2 succeeded, used x=%d\n", x);
852 REBAR_FixVert (infoPtr, rowstart, rowend, mcy);
856 /* ******************* Phase 3 ************************ */
857 /* at this point everything is back to ->cxHeader values */
858 /* and should not have gotten here. */
859 /* ****************************************************** */
861 lpBand = &infoPtr->bands[rowstart];
862 ERR("Serious problem adjusting row %d, start band %d, end band %d\n",
863 lpBand->iRow, rowstart, rowend);
864 REBAR_DumpBand (infoPtr);
870 REBAR_CalcHorzBand (REBAR_INFO *infoPtr, UINT rstart, UINT rend, BOOL notify)
871 /* Function: this routine initializes all the rectangles in */
872 /* each band in a row to fit in the adjusted rcBand rect. */
873 /* *** Supports only Horizontal bars. *** */
880 /* MS seems to use GetDlgCtrlID() for above GetWindowLong call */
881 parenthwnd = GetParent (infoPtr->hwndSelf);
883 for(i=rstart; i<rend; i++){
884 lpBand = &infoPtr->bands[i];
885 if (HIDDENBAND(lpBand)) {
886 SetRect (&lpBand->rcChild,
887 lpBand->rcBand.right, lpBand->rcBand.top,
888 lpBand->rcBand.right, lpBand->rcBand.bottom);
892 oldChild = lpBand->rcChild;
894 /* set initial gripper rectangle */
895 SetRect (&lpBand->rcGripper, lpBand->rcBand.left, lpBand->rcBand.top,
896 lpBand->rcBand.left, lpBand->rcBand.bottom);
898 /* calculate gripper rectangle */
899 if ( lpBand->fStatus & HAS_GRIPPER) {
900 lpBand->fDraw |= DRAW_GRIPPER;
901 lpBand->rcGripper.left += REBAR_PRE_GRIPPER;
902 lpBand->rcGripper.right = lpBand->rcGripper.left + GRIPPER_WIDTH;
903 lpBand->rcGripper.top += 2;
904 lpBand->rcGripper.bottom -= 2;
906 SetRect (&lpBand->rcCapImage,
907 lpBand->rcGripper.right+REBAR_ALWAYS_SPACE, lpBand->rcBand.top,
908 lpBand->rcGripper.right+REBAR_ALWAYS_SPACE, lpBand->rcBand.bottom);
910 else { /* no gripper will be drawn */
912 if (lpBand->fStatus & (HAS_IMAGE | HAS_TEXT))
913 /* if no gripper but either image or text, then leave space */
914 xoff = REBAR_ALWAYS_SPACE;
915 SetRect (&lpBand->rcCapImage,
916 lpBand->rcBand.left+xoff, lpBand->rcBand.top,
917 lpBand->rcBand.left+xoff, lpBand->rcBand.bottom);
920 /* image is visible */
921 if (lpBand->fStatus & HAS_IMAGE) {
922 lpBand->fDraw |= DRAW_IMAGE;
923 lpBand->rcCapImage.right += infoPtr->imageSize.cx;
924 lpBand->rcCapImage.bottom = lpBand->rcCapImage.top + infoPtr->imageSize.cy;
926 /* set initial caption text rectangle */
927 SetRect (&lpBand->rcCapText,
928 lpBand->rcCapImage.right+REBAR_POST_IMAGE, lpBand->rcBand.top+1,
929 lpBand->rcBand.left+lpBand->cxHeader, lpBand->rcBand.bottom-1);
930 /* update band height
931 if (lpBand->uMinHeight < infoPtr->imageSize.cy + 2) {
932 lpBand->uMinHeight = infoPtr->imageSize.cy + 2;
933 lpBand->rcBand.bottom = lpBand->rcBand.top + lpBand->uMinHeight;
937 /* set initial caption text rectangle */
938 SetRect (&lpBand->rcCapText, lpBand->rcCapImage.right, lpBand->rcBand.top+1,
939 lpBand->rcBand.left+lpBand->cxHeader, lpBand->rcBand.bottom-1);
942 /* text is visible */
943 if (lpBand->fStatus & HAS_TEXT) {
944 lpBand->fDraw |= DRAW_TEXT;
945 lpBand->rcCapText.right = max(lpBand->rcCapText.left,
946 lpBand->rcCapText.right-REBAR_POST_TEXT);
949 /* set initial child window rectangle if there is a child */
950 if (lpBand->fMask & RBBIM_CHILD) {
951 xoff = lpBand->offChild.cx;
952 yoff = lpBand->offChild.cy;
953 SetRect (&lpBand->rcChild,
954 lpBand->rcBand.left+lpBand->cxHeader, lpBand->rcBand.top+yoff,
955 lpBand->rcBand.right-xoff, lpBand->rcBand.bottom-yoff);
958 SetRect (&lpBand->rcChild,
959 lpBand->rcBand.left+lpBand->cxHeader, lpBand->rcBand.top,
960 lpBand->rcBand.right, lpBand->rcBand.bottom);
963 /* flag if notify required and invalidate rectangle */
965 ((oldChild.right-oldChild.left != lpBand->rcChild.right-lpBand->rcChild.left) ||
966 (oldChild.bottom-oldChild.top != lpBand->rcChild.bottom-lpBand->rcChild.top))) {
967 TRACE("Child rectangle changed for band %u\n", i);
968 TRACE(" from (%ld,%ld)-(%ld,%ld) to (%ld,%ld)-(%ld,%ld)\n",
969 oldChild.left, oldChild.top,
970 oldChild.right, oldChild.bottom,
971 lpBand->rcChild.left, lpBand->rcChild.top,
972 lpBand->rcChild.right, lpBand->rcChild.bottom);
974 if (lpBand->fDraw & NTF_INVALIDATE) {
975 TRACE("invalidating (%ld,%ld)-(%ld,%ld)\n",
978 lpBand->rcBand.right + ((lpBand->fDraw & DRAW_RIGHTSEP) ? SEP_WIDTH_SIZE : 0),
979 lpBand->rcBand.bottom + ((lpBand->fDraw & DRAW_BOTTOMSEP) ? SEP_WIDTH_SIZE : 0));
980 lpBand->fDraw &= ~NTF_INVALIDATE;
981 work = lpBand->rcBand;
982 if (lpBand->fDraw & DRAW_RIGHTSEP) work.right += SEP_WIDTH_SIZE;
983 if (lpBand->fDraw & DRAW_BOTTOMSEP) work.bottom += SEP_WIDTH_SIZE;
984 InvalidateRect(infoPtr->hwndSelf, &work, TRUE);
993 REBAR_CalcVertBand (REBAR_INFO *infoPtr, UINT rstart, UINT rend, BOOL notify)
994 /* Function: this routine initializes all the rectangles in */
995 /* each band in a row to fit in the adjusted rcBand rect. */
996 /* *** Supports only Vertical bars. *** */
1001 RECT oldChild, work;
1003 /* MS seems to use GetDlgCtrlID() for above GetWindowLong call */
1004 parenthwnd = GetParent (infoPtr->hwndSelf);
1006 for(i=rstart; i<rend; i++){
1007 lpBand = &infoPtr->bands[i];
1008 if (HIDDENBAND(lpBand)) continue;
1009 oldChild = lpBand->rcChild;
1011 /* set initial gripper rectangle */
1012 SetRect (&lpBand->rcGripper, lpBand->rcBand.left, lpBand->rcBand.top,
1013 lpBand->rcBand.right, lpBand->rcBand.top);
1015 /* calculate gripper rectangle */
1016 if (lpBand->fStatus & HAS_GRIPPER) {
1017 lpBand->fDraw |= DRAW_GRIPPER;
1019 if (infoPtr->dwStyle & RBS_VERTICALGRIPPER) {
1020 /* vertical gripper */
1021 lpBand->rcGripper.left += 3;
1022 lpBand->rcGripper.right = lpBand->rcGripper.left + GRIPPER_WIDTH;
1023 lpBand->rcGripper.top += REBAR_PRE_GRIPPER;
1024 lpBand->rcGripper.bottom = lpBand->rcGripper.top + GRIPPER_HEIGHT;
1026 /* initialize Caption image rectangle */
1027 SetRect (&lpBand->rcCapImage, lpBand->rcBand.left,
1028 lpBand->rcGripper.bottom + REBAR_ALWAYS_SPACE,
1029 lpBand->rcBand.right,
1030 lpBand->rcGripper.bottom + REBAR_ALWAYS_SPACE);
1033 /* horizontal gripper */
1034 lpBand->rcGripper.left += 2;
1035 lpBand->rcGripper.right -= 2;
1036 lpBand->rcGripper.top += REBAR_PRE_GRIPPER;
1037 lpBand->rcGripper.bottom = lpBand->rcGripper.top + GRIPPER_WIDTH;
1039 /* initialize Caption image rectangle */
1040 SetRect (&lpBand->rcCapImage, lpBand->rcBand.left,
1041 lpBand->rcGripper.bottom + REBAR_ALWAYS_SPACE,
1042 lpBand->rcBand.right,
1043 lpBand->rcGripper.bottom + REBAR_ALWAYS_SPACE);
1046 else { /* no gripper will be drawn */
1048 if (lpBand->fStatus & (HAS_IMAGE | HAS_TEXT))
1049 /* if no gripper but either image or text, then leave space */
1050 xoff = REBAR_ALWAYS_SPACE;
1051 /* initialize Caption image rectangle */
1052 SetRect (&lpBand->rcCapImage,
1053 lpBand->rcBand.left, lpBand->rcBand.top+xoff,
1054 lpBand->rcBand.right, lpBand->rcBand.top+xoff);
1057 /* image is visible */
1058 if (lpBand->fStatus & HAS_IMAGE) {
1059 lpBand->fDraw |= DRAW_IMAGE;
1061 lpBand->rcCapImage.right = lpBand->rcCapImage.left + infoPtr->imageSize.cx;
1062 lpBand->rcCapImage.bottom += infoPtr->imageSize.cy;
1064 /* set initial caption text rectangle */
1065 SetRect (&lpBand->rcCapText,
1066 lpBand->rcBand.left, lpBand->rcCapImage.bottom+REBAR_POST_IMAGE,
1067 lpBand->rcBand.right, lpBand->rcBand.top+lpBand->cxHeader);
1068 /* update band height *
1069 if (lpBand->uMinHeight < infoPtr->imageSize.cx + 2) {
1070 lpBand->uMinHeight = infoPtr->imageSize.cx + 2;
1071 lpBand->rcBand.right = lpBand->rcBand.left + lpBand->uMinHeight;
1075 /* set initial caption text rectangle */
1076 SetRect (&lpBand->rcCapText,
1077 lpBand->rcBand.left, lpBand->rcCapImage.bottom,
1078 lpBand->rcBand.right, lpBand->rcBand.top+lpBand->cxHeader);
1081 /* text is visible */
1082 if (lpBand->fStatus & HAS_TEXT) {
1083 lpBand->fDraw |= DRAW_TEXT;
1084 lpBand->rcCapText.bottom = max(lpBand->rcCapText.top,
1085 lpBand->rcCapText.bottom);
1088 /* set initial child window rectangle if there is a child */
1089 if (lpBand->fMask & RBBIM_CHILD) {
1090 yoff = lpBand->offChild.cx;
1091 xoff = lpBand->offChild.cy;
1092 SetRect (&lpBand->rcChild,
1093 lpBand->rcBand.left+xoff, lpBand->rcBand.top+lpBand->cxHeader,
1094 lpBand->rcBand.right-xoff, lpBand->rcBand.bottom-yoff);
1097 SetRect (&lpBand->rcChild,
1098 lpBand->rcBand.left, lpBand->rcBand.top+lpBand->cxHeader,
1099 lpBand->rcBand.right, lpBand->rcBand.bottom);
1102 /* flag if notify required and invalidate rectangle */
1104 ((oldChild.right-oldChild.left != lpBand->rcChild.right-lpBand->rcChild.left) ||
1105 (oldChild.bottom-oldChild.top != lpBand->rcChild.bottom-lpBand->rcChild.top))) {
1106 TRACE("Child rectangle changed for band %u\n", i);
1107 TRACE(" from (%ld,%ld)-(%ld,%ld) to (%ld,%ld)-(%ld,%ld)\n",
1108 oldChild.left, oldChild.top,
1109 oldChild.right, oldChild.bottom,
1110 lpBand->rcChild.left, lpBand->rcChild.top,
1111 lpBand->rcChild.right, lpBand->rcChild.bottom);
1113 if (lpBand->fDraw & NTF_INVALIDATE) {
1114 TRACE("invalidating (%ld,%ld)-(%ld,%ld)\n",
1115 lpBand->rcBand.left,
1117 lpBand->rcBand.right + ((lpBand->fDraw & DRAW_BOTTOMSEP) ? SEP_WIDTH_SIZE : 0),
1118 lpBand->rcBand.bottom + ((lpBand->fDraw & DRAW_RIGHTSEP) ? SEP_WIDTH_SIZE : 0));
1119 lpBand->fDraw &= ~NTF_INVALIDATE;
1120 work = lpBand->rcBand;
1121 if (lpBand->fDraw & DRAW_RIGHTSEP) work.bottom += SEP_WIDTH_SIZE;
1122 if (lpBand->fDraw & DRAW_BOTTOMSEP) work.right += SEP_WIDTH_SIZE;
1123 InvalidateRect(infoPtr->hwndSelf, &work, TRUE);
1131 REBAR_ForceResize (REBAR_INFO *infoPtr)
1132 /* Function: This changes the size of the REBAR window to that */
1133 /* calculated by REBAR_Layout. */
1136 INT x, y, width, height;
1137 INT xedge = GetSystemMetrics(SM_CXEDGE);
1138 INT yedge = GetSystemMetrics(SM_CYEDGE);
1140 /* TEST TEST TEST */
1141 GetWindowRect (infoPtr->hwndSelf, &rc);
1142 /* END TEST END TEST END TEST */
1145 GetClientRect (infoPtr->hwndSelf, &rc);
1147 TRACE( " old [%ld x %ld], new [%ld x %ld], client [%ld x %ld]\n",
1148 infoPtr->oldSize.cx, infoPtr->oldSize.cy,
1149 infoPtr->calcSize.cx, infoPtr->calcSize.cy,
1150 rc.right, rc.bottom);
1152 /* If we need to shrink client, then skip size test */
1153 if ((infoPtr->calcSize.cy >= rc.bottom) &&
1154 (infoPtr->calcSize.cx >= rc.right)) {
1156 /* if size did not change then skip process */
1157 if ((infoPtr->oldSize.cx == infoPtr->calcSize.cx) &&
1158 (infoPtr->oldSize.cy == infoPtr->calcSize.cy) &&
1159 !(infoPtr->fStatus & RESIZE_ANYHOW))
1161 TRACE("skipping reset\n");
1166 infoPtr->fStatus &= ~RESIZE_ANYHOW;
1167 /* Set flag to ignore next WM_SIZE message */
1168 infoPtr->fStatus |= AUTO_RESIZE;
1175 if (infoPtr->dwStyle & WS_BORDER) {
1180 if (!(infoPtr->dwStyle & CCS_NOPARENTALIGN)) {
1181 INT mode = infoPtr->dwStyle & (CCS_VERT | CCS_TOP | CCS_BOTTOM);
1184 GetClientRect(GetParent(infoPtr->hwndSelf), &rcPcl);
1187 /* _TOP sets width to parents width */
1188 width += (rcPcl.right - rcPcl.left);
1189 height += infoPtr->calcSize.cy;
1190 x += ((infoPtr->dwStyle & WS_BORDER) ? -xedge : 0);
1191 y += ((infoPtr->dwStyle & WS_BORDER) ? -yedge : 0);
1192 y += ((infoPtr->dwStyle & CCS_NODIVIDER) ? 0 : REBAR_DIVIDER);
1195 /* FIXME: wrong wrong wrong */
1196 /* _BOTTOM sets width to parents width */
1197 width += (rcPcl.right - rcPcl.left);
1198 height += infoPtr->calcSize.cy;
1200 y = rcPcl.bottom - height + 1;
1203 /* _LEFT sets height to parents height */
1204 width += infoPtr->calcSize.cx;
1205 height += (rcPcl.bottom - rcPcl.top);
1206 x += ((infoPtr->dwStyle & WS_BORDER) ? -xedge : 0);
1207 x += ((infoPtr->dwStyle & CCS_NODIVIDER) ? 0 : REBAR_DIVIDER);
1208 y += ((infoPtr->dwStyle & WS_BORDER) ? -yedge : 0);
1211 /* FIXME: wrong wrong wrong */
1212 /* _RIGHT sets height to parents height */
1213 width += infoPtr->calcSize.cx;
1214 height += (rcPcl.bottom - rcPcl.top);
1215 x = rcPcl.right - width + 1;
1219 width += infoPtr->calcSize.cx;
1220 height += infoPtr->calcSize.cy;
1224 width += infoPtr->calcSize.cx;
1225 height += infoPtr->calcSize.cy;
1226 x = infoPtr->origin.x;
1227 y = infoPtr->origin.y;
1230 TRACE("hwnd %p, style=%08lx, setting at (%d,%d) for (%d,%d)\n",
1231 infoPtr->hwndSelf, infoPtr->dwStyle,
1232 x, y, width, height);
1233 SetWindowPos (infoPtr->hwndSelf, 0, x, y, width, height,
1239 REBAR_MoveChildWindows (REBAR_INFO *infoPtr, UINT start, UINT endplus)
1242 CHAR szClassName[40];
1244 NMREBARCHILDSIZE rbcz;
1248 if (!(deferpos = BeginDeferWindowPos(infoPtr->uNumBands)))
1249 ERR("BeginDeferWindowPos returned NULL\n");
1251 for (i = start; i < endplus; i++) {
1252 lpBand = &infoPtr->bands[i];
1254 if (HIDDENBAND(lpBand)) continue;
1255 if (lpBand->hwndChild) {
1256 TRACE("hwndChild = %p\n", lpBand->hwndChild);
1258 /* Always geterate the RBN_CHILDSIZE even it child
1261 rbcz.wID = lpBand->wID;
1262 rbcz.rcChild = lpBand->rcChild;
1263 rbcz.rcBand = lpBand->rcBand;
1264 if (infoPtr->dwStyle & CCS_VERT)
1265 rbcz.rcBand.top += lpBand->cxHeader;
1267 rbcz.rcBand.left += lpBand->cxHeader;
1268 REBAR_Notify ((NMHDR *)&rbcz, infoPtr, RBN_CHILDSIZE);
1269 if (!EqualRect (&lpBand->rcChild, &rbcz.rcChild)) {
1270 TRACE("Child rect changed by NOTIFY for band %u\n", i);
1271 TRACE(" from (%ld,%ld)-(%ld,%ld) to (%ld,%ld)-(%ld,%ld)\n",
1272 lpBand->rcChild.left, lpBand->rcChild.top,
1273 lpBand->rcChild.right, lpBand->rcChild.bottom,
1274 rbcz.rcChild.left, rbcz.rcChild.top,
1275 rbcz.rcChild.right, rbcz.rcChild.bottom);
1276 lpBand->rcChild = rbcz.rcChild; /* *** ??? */
1279 /* native (IE4 in "Favorites" frame **1) does:
1280 * SetRect (&rc, -1, -1, -1, -1)
1281 * EqualRect (&rc,band->rc???)
1283 * CopyRect (band->rc????, &rc)
1284 * set flag outside of loop
1287 GetClassNameA (lpBand->hwndChild, szClassName, 40);
1288 if (!lstrcmpA (szClassName, "ComboBox") ||
1289 !lstrcmpA (szClassName, WC_COMBOBOXEXA)) {
1290 INT nEditHeight, yPos;
1293 /* special placement code for combo or comboex box */
1296 /* get size of edit line */
1297 GetWindowRect (lpBand->hwndChild, &rc);
1298 nEditHeight = rc.bottom - rc.top;
1299 yPos = (lpBand->rcChild.bottom + lpBand->rcChild.top - nEditHeight)/2;
1301 /* center combo box inside child area */
1302 TRACE("moving child (Combo(Ex)) %p to (%ld,%d) for (%ld,%d)\n",
1304 lpBand->rcChild.left, yPos,
1305 lpBand->rcChild.right - lpBand->rcChild.left,
1307 deferpos = DeferWindowPos (deferpos, lpBand->hwndChild, HWND_TOP,
1308 lpBand->rcChild.left,
1309 /*lpBand->rcChild.top*/ yPos,
1310 lpBand->rcChild.right - lpBand->rcChild.left,
1314 ERR("DeferWindowPos returned NULL\n");
1317 TRACE("moving child (Other) %p to (%ld,%ld) for (%ld,%ld)\n",
1319 lpBand->rcChild.left, lpBand->rcChild.top,
1320 lpBand->rcChild.right - lpBand->rcChild.left,
1321 lpBand->rcChild.bottom - lpBand->rcChild.top);
1322 deferpos = DeferWindowPos (deferpos, lpBand->hwndChild, HWND_TOP,
1323 lpBand->rcChild.left,
1324 lpBand->rcChild.top,
1325 lpBand->rcChild.right - lpBand->rcChild.left,
1326 lpBand->rcChild.bottom - lpBand->rcChild.top,
1329 ERR("DeferWindowPos returned NULL\n");
1333 if (!EndDeferWindowPos(deferpos))
1334 ERR("EndDeferWindowPos returned NULL\n");
1336 if (infoPtr->DoRedraw)
1337 UpdateWindow (infoPtr->hwndSelf);
1339 if (infoPtr->fStatus & NTF_HGHTCHG) {
1340 infoPtr->fStatus &= ~NTF_HGHTCHG;
1341 REBAR_Notify (&heightchange, infoPtr, RBN_HEIGHTCHANGE);
1344 /* native (from **1 above) does:
1345 * UpdateWindow(rebar)
1347 * RBN_HEIGHTCHANGE if necessary
1348 * if ret from any EqualRect was 0
1349 * Goto "BeginDeferWindowPos"
1356 REBAR_Layout (REBAR_INFO *infoPtr, LPRECT lpRect, BOOL notify, BOOL resetclient)
1357 /* Function: This routine is resposible for laying out all */
1358 /* the bands in a rebar. It assigns each band to a row and*/
1359 /* determines when to start a new row. */
1361 REBAR_BAND *lpBand, *prevBand;
1362 RECT rcClient, rcAdj;
1363 INT initx, inity, x, y, cx, cxsep, mmcy, mcy, clientcx, clientcy;
1364 INT adjcx, adjcy, row, rightx, bottomy, origheight;
1365 UINT i, j, rowstart, origrows, cntonrow;
1368 if (!(infoPtr->fStatus & BAND_NEEDS_LAYOUT)) {
1369 TRACE("no layout done. No band changed.\n");
1370 REBAR_DumpBand (infoPtr);
1373 infoPtr->fStatus &= ~BAND_NEEDS_LAYOUT;
1374 if (!infoPtr->DoRedraw) infoPtr->fStatus |= BAND_NEEDS_REDRAW;
1376 GetClientRect (infoPtr->hwndSelf, &rcClient);
1377 TRACE("Client is (%ld,%ld)-(%ld,%ld)\n",
1378 rcClient.left, rcClient.top, rcClient.right, rcClient.bottom);
1382 TRACE("adjustment rect is (%ld,%ld)-(%ld,%ld)\n",
1383 rcAdj.left, rcAdj.top, rcAdj.right, rcAdj.bottom);
1386 CopyRect (&rcAdj, &rcClient);
1389 clientcx = rcClient.right - rcClient.left;
1390 clientcy = rcClient.bottom - rcClient.top;
1391 adjcx = rcAdj.right - rcAdj.left;
1392 adjcy = rcAdj.bottom - rcAdj.top;
1394 TRACE("window client rect will be set to adj rect\n");
1399 if (!infoPtr->DoRedraw && (clientcx == 0) && (clientcy == 0)) {
1400 ERR("no redraw and client is zero, skip layout\n");
1401 infoPtr->fStatus |= BAND_NEEDS_LAYOUT;
1405 /* save height of original control */
1406 if (infoPtr->dwStyle & CCS_VERT)
1407 origheight = infoPtr->calcSize.cx;
1409 origheight = infoPtr->calcSize.cy;
1410 origrows = infoPtr->uNumRows;
1415 /* ******* Start Phase 1 - all bands on row at minimum size ******* */
1417 TRACE("band loop constants, clientcx=%d, clientcy=%d, adjcx=%d, adjcy=%d\n",
1418 clientcx, clientcy, adjcx, adjcy);
1428 for (i = 0; i < infoPtr->uNumBands; i++) {
1429 lpBand = &infoPtr->bands[i];
1433 if (HIDDENBAND(lpBand)) continue;
1435 lpBand->rcoldBand = lpBand->rcBand;
1437 /* Set the offset of the child window */
1438 if ((lpBand->fMask & RBBIM_CHILD) &&
1439 !(lpBand->fStyle & RBBS_FIXEDSIZE)) {
1440 lpBand->offChild.cx = ((lpBand->fStyle & RBBS_CHILDEDGE) ? 4 : 0);
1442 lpBand->offChild.cy = ((lpBand->fStyle & RBBS_CHILDEDGE) ? 2 : 0);
1444 /* separator from previous band */
1445 cxsep = (cntonrow == 0) ? 0 : SEP_WIDTH;
1447 /* Header: includes gripper, text, image */
1448 cx = lpBand->cxHeader;
1449 if (lpBand->fStyle & RBBS_FIXEDSIZE) cx = lpBand->lcx;
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 > 4) : (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 - create array of start and end ******* */
1715 /* indexes by row */
1717 if (infoPtr->uNumRows != origrows) {
1718 if (infoPtr->rows) COMCTL32_Free (infoPtr->rows);
1719 infoPtr->rows = COMCTL32_Alloc (sizeof (REBAR_ROW) * infoPtr->uNumRows);
1723 for (i = 0; i < infoPtr->uNumBands; i++) {
1724 lpBand = &infoPtr->bands[i];
1725 if (HIDDENBAND(lpBand)) continue;
1727 if (lpBand->iRow > row) {
1729 infoPtr->rows[row-1].istartband = i;
1732 ERR("P2a bug!!!!!!\n");
1734 infoPtr->rows[row-1].iendband = i;
1737 for (i = 0; i < infoPtr->uNumRows; i++) {
1740 p = &infoPtr->rows[i];
1741 TRACE("P2a row %d, starts %d, ends %d\n",
1742 i+1, p->istartband, p->iendband);
1745 /* ******* End Phase 2a - create array of start and end ******* */
1746 /* indexes by row */
1749 /* ******* Start Phase 2b - adjust all bands for height full ******* */
1750 /* assumes that the following variables contain: */
1751 /* y/x current height/width of all rows */
1752 /* clientcy/clientcx height/width of client area */
1754 if (((infoPtr->dwStyle & CCS_VERT) ? clientcx > x : clientcy > y) &&
1755 infoPtr->uNumBands) {
1759 diff = (infoPtr->dwStyle & CCS_VERT) ? clientcx - x : clientcy - y;
1760 for (i = infoPtr->uNumRows; i >= 1; i--) {
1761 /* if row has more than 1 band, ignore row */
1762 if (infoPtr->rows[i-1].istartband != infoPtr->rows[i-1].iendband)
1764 /* point to only band in row */
1765 iband = infoPtr->rows[i-1].istartband;
1766 lpBand = &infoPtr->bands[iband];
1767 if(HIDDENBAND(lpBand)) continue;
1768 if (lpBand->fMask & RBBS_VARIABLEHEIGHT) continue;
1769 if (((INT)lpBand->cyMaxChild < 1) ||
1770 ((INT)lpBand->cyIntegral < 1)) {
1771 if (lpBand->cyMaxChild + lpBand->cyIntegral == 0) continue;
1772 ERR("P2b band %u RBBS_VARIABLEHEIGHT set but cyMax=%d, cyInt=%d\n",
1773 iband, lpBand->cyMaxChild, lpBand->cyIntegral);
1776 /* j is now the maximum height/width in the client area */
1777 j = ((diff / lpBand->cyIntegral) * lpBand->cyIntegral) +
1779 if (j > lpBand->cyMaxChild + REBARSPACE(lpBand))
1780 j = lpBand->cyMaxChild + REBARSPACE(lpBand);
1781 diff -= (j - ircBw(lpBand));
1782 if (infoPtr->dwStyle & CCS_VERT)
1783 lpBand->rcBand.right = lpBand->rcBand.left + j;
1785 lpBand->rcBand.bottom = lpBand->rcBand.top + j;
1786 TRACE("P2b band %d, row %d changed to (%ld,%ld)-(%ld,%ld)\n",
1787 iband, lpBand->iRow,
1788 lpBand->rcBand.left, lpBand->rcBand.top,
1789 lpBand->rcBand.right, lpBand->rcBand.bottom);
1790 if (diff <= 0) break;
1793 ERR("P2b allocated more than available, diff=%d\n", diff);
1796 if (infoPtr->dwStyle & CCS_VERT)
1797 x = clientcx - diff;
1799 y = clientcy - diff;
1802 /* ******* End Phase 2b - adjust all bands for height full ******* */
1805 /* ******* Start Phase 3 - adjust all bands for width full ******* */
1807 if (infoPtr->uNumBands) {
1810 /* If RBS_BANDBORDERS set then indicate to draw bottom separator */
1811 /* on all bands in all rows but last row. */
1812 /* Also indicate to draw the right separator for each band in */
1813 /* each row but the rightmost band. */
1814 if (infoPtr->dwStyle & RBS_BANDBORDERS) {
1816 for(i = 0; i < infoPtr->uNumRows; i++) {
1817 p = &infoPtr->rows[i];
1818 for (j = p->istartband; j <= p->iendband; j++) {
1819 lpBand = &infoPtr->bands[j];
1820 if (HIDDENBAND(lpBand)) continue;
1821 if (j != p->iendband)
1822 lpBand->fDraw |= DRAW_RIGHTSEP;
1823 if (i != infoPtr->uNumRows-1)
1824 lpBand->fDraw |= DRAW_BOTTOMSEP;
1829 /* Distribute the extra space on the horizontal and adjust */
1830 /* all bands in row to same height. */
1831 for (i=1; i<=infoPtr->uNumRows; i++) {
1832 p = &infoPtr->rows[i-1];
1835 TRACE("P3 processing row %d, starting band %d, ending band %d\n",
1836 i, p->istartband, p->iendband);
1838 /* Find the largest height of the bands in the row */
1839 for (j = p->istartband; j <= p->iendband; j++) {
1840 lpBand = &infoPtr->bands[j];
1841 if (HIDDENBAND(lpBand)) continue;
1842 if (mcy < ircBw(lpBand))
1843 mcy = ircBw(lpBand);
1846 REBAR_AdjustBands (infoPtr, p->istartband, p->iendband,
1847 (infoPtr->dwStyle & CCS_VERT) ?
1848 clientcy : clientcx, mcy);
1851 /* Calculate the other rectangles in each band */
1852 if (infoPtr->dwStyle & CCS_VERT) {
1853 REBAR_CalcVertBand (infoPtr, 0, infoPtr->uNumBands,
1857 REBAR_CalcHorzBand (infoPtr, 0, infoPtr->uNumBands,
1862 /* ******* End Phase 3 - adjust all bands for width full ******* */
1864 /* now compute size of Rebar itself */
1865 infoPtr->oldSize = infoPtr->calcSize;
1866 if (infoPtr->uNumBands == 0) {
1867 /* we have no bands, so make size the size of client */
1871 if (infoPtr->dwStyle & CCS_VERT) {
1872 infoPtr->calcSize.cx = x;
1873 infoPtr->calcSize.cy = clientcy;
1874 TRACE("vert, notify=%d, x=%d, origheight=%d\n",
1875 notify, x, origheight);
1876 if (notify && (x != origheight)) infoPtr->fStatus |= NTF_HGHTCHG;
1879 infoPtr->calcSize.cx = clientcx;
1880 infoPtr->calcSize.cy = y;
1881 TRACE("horz, notify=%d, y=%d, origheight=%d\n",
1882 notify, y, origheight);
1883 if (notify && (y != origheight)) infoPtr->fStatus |= NTF_HGHTCHG;
1886 REBAR_DumpBand (infoPtr);
1888 REBAR_MoveChildWindows (infoPtr, 0, infoPtr->uNumBands);
1890 REBAR_ForceResize (infoPtr);
1895 REBAR_ValidateBand (REBAR_INFO *infoPtr, REBAR_BAND *lpBand)
1896 /* Function: This routine evaluates the band specs supplied */
1897 /* by the user and updates the following 5 fields in */
1898 /* the internal band structure: cxHeader, lcx, lcy, hcx, hcy*/
1905 lpBand->fStatus = 0;
1913 /* Data comming in from users into the cx... and cy... fields */
1914 /* may be bad, just garbage, because the user never clears */
1915 /* the fields. RB_{SET|INSERT}BAND{A|W} just passes the data */
1916 /* along if the fields exist in the input area. Here we must */
1917 /* determine if the data is valid. I have no idea how MS does */
1918 /* the validation, but it does because the RB_GETBANDINFO */
1919 /* returns a 0 when I know the sample program passed in an */
1920 /* address. Here I will use the algorithim that if the value */
1921 /* is greater than 65535 then it is bad and replace it with */
1922 /* a zero. Feel free to improve the algorithim. - GA 12/2000 */
1923 if (lpBand->cxMinChild > 65535) lpBand->cxMinChild = 0;
1924 if (lpBand->cyMinChild > 65535) lpBand->cyMinChild = 0;
1925 if (lpBand->cx > 65535) lpBand->cx = 0;
1926 if (lpBand->cyChild > 65535) lpBand->cyChild = 0;
1927 if (lpBand->cyMaxChild > 65535) lpBand->cyMaxChild = 0;
1928 if (lpBand->cyIntegral > 65535) lpBand->cyIntegral = 0;
1929 if (lpBand->cxIdeal > 65535) lpBand->cxIdeal = 0;
1930 if (lpBand->cxHeader > 65535) lpBand->cxHeader = 0;
1932 /* FIXME: probably should only set NEEDS_LAYOUT flag when */
1933 /* values change. Till then always set it. */
1934 TRACE("setting NEEDS_LAYOUT\n");
1935 infoPtr->fStatus |= BAND_NEEDS_LAYOUT;
1937 /* Header is where the image, text and gripper exist */
1938 /* in the band and preceed the child window. */
1940 /* count number of non-FIXEDSIZE and non-Hidden bands */
1942 for (i=0; i<infoPtr->uNumBands; i++){
1943 tBand = &infoPtr->bands[i];
1944 if (!HIDDENBAND(tBand) && !(tBand->fStyle & RBBS_FIXEDSIZE))
1948 /* calculate gripper rectangle */
1949 if ( (!(lpBand->fStyle & RBBS_NOGRIPPER)) &&
1950 ( (lpBand->fStyle & RBBS_GRIPPERALWAYS) ||
1951 ( !(lpBand->fStyle & RBBS_FIXEDSIZE) && (nonfixed > 1)))
1953 lpBand->fStatus |= HAS_GRIPPER;
1954 if (infoPtr->dwStyle & CCS_VERT)
1955 if (infoPtr->dwStyle & RBS_VERTICALGRIPPER)
1956 header += (GRIPPER_HEIGHT + REBAR_PRE_GRIPPER);
1958 header += (GRIPPER_WIDTH + REBAR_PRE_GRIPPER);
1960 header += (REBAR_PRE_GRIPPER + GRIPPER_WIDTH);
1961 /* Always have 4 pixels before anything else */
1962 header += REBAR_ALWAYS_SPACE;
1965 /* image is visible */
1966 if ((lpBand->fMask & RBBIM_IMAGE) && (infoPtr->himl)) {
1967 lpBand->fStatus |= HAS_IMAGE;
1968 if (infoPtr->dwStyle & CCS_VERT) {
1969 header += (infoPtr->imageSize.cy + REBAR_POST_IMAGE);
1970 lpBand->lcy = infoPtr->imageSize.cx + 2;
1973 header += (infoPtr->imageSize.cx + REBAR_POST_IMAGE);
1974 lpBand->lcy = infoPtr->imageSize.cy + 2;
1978 /* text is visible */
1979 if ((lpBand->fMask & RBBIM_TEXT) && (lpBand->lpText)) {
1980 HDC hdc = GetDC (0);
1981 HFONT hOldFont = SelectObject (hdc, infoPtr->hFont);
1984 lpBand->fStatus |= HAS_TEXT;
1985 GetTextExtentPoint32W (hdc, lpBand->lpText,
1986 lstrlenW (lpBand->lpText), &size);
1987 header += ((infoPtr->dwStyle & CCS_VERT) ? (size.cy + REBAR_POST_TEXT) : (size.cx + REBAR_POST_TEXT));
1988 textheight = (infoPtr->dwStyle & CCS_VERT) ? 0 : size.cy;
1990 SelectObject (hdc, hOldFont);
1994 /* if no gripper but either image or text, then leave space */
1995 if ((lpBand->fStatus & (HAS_IMAGE | HAS_TEXT)) &&
1996 !(lpBand->fStatus & HAS_GRIPPER)) {
1997 header += REBAR_ALWAYS_SPACE;
2000 /* check if user overrode the header value */
2001 if (!(lpBand->fMask & RBBIM_HEADERSIZE))
2002 lpBand->cxHeader = header;
2005 /* Now compute minimum size of child window */
2006 lpBand->offChild.cx = 0;
2007 lpBand->offChild.cy = 0;
2008 lpBand->lcy = textheight;
2009 lpBand->ccy = lpBand->lcy;
2010 if (lpBand->fMask & RBBIM_CHILDSIZE) {
2011 lpBand->lcx = lpBand->cxMinChild;
2013 /* Set the .cy values for CHILDSIZE case */
2014 lpBand->lcy = max(lpBand->lcy, lpBand->cyMinChild);
2015 lpBand->ccy = lpBand->lcy;
2016 lpBand->hcy = lpBand->lcy;
2017 if (lpBand->cyMaxChild != 0xffffffff) {
2018 lpBand->hcy = lpBand->cyMaxChild;
2020 if (lpBand->cyChild != 0xffffffff)
2021 lpBand->ccy = max (lpBand->cyChild, lpBand->lcy);
2023 TRACE("_CHILDSIZE\n");
2025 if (lpBand->fMask & RBBIM_SIZE) {
2026 lpBand->hcx = max (lpBand->cx-lpBand->cxHeader, lpBand->lcx);
2030 lpBand->hcx = lpBand->lcx;
2031 lpBand->ccx = lpBand->hcx;
2033 /* make ->.cx include header size for _Layout */
2034 lpBand->lcx += lpBand->cxHeader;
2035 lpBand->ccx += lpBand->cxHeader;
2036 lpBand->hcx += lpBand->cxHeader;
2041 REBAR_CommonSetupBand (HWND hwnd, LPREBARBANDINFOA lprbbi, REBAR_BAND *lpBand)
2042 /* Function: This routine copies the supplied values from */
2043 /* user input (lprbbi) to the internal band structure. */
2045 lpBand->fMask |= lprbbi->fMask;
2047 if (lprbbi->fMask & RBBIM_STYLE)
2048 lpBand->fStyle = lprbbi->fStyle;
2050 if (lprbbi->fMask & RBBIM_COLORS) {
2051 lpBand->clrFore = lprbbi->clrFore;
2052 lpBand->clrBack = lprbbi->clrBack;
2055 if (lprbbi->fMask & RBBIM_IMAGE)
2056 lpBand->iImage = lprbbi->iImage;
2058 if (lprbbi->fMask & RBBIM_CHILD) {
2059 if (lprbbi->hwndChild) {
2060 lpBand->hwndChild = lprbbi->hwndChild;
2061 lpBand->hwndPrevParent =
2062 SetParent (lpBand->hwndChild, hwnd);
2063 /* below in trace fro WinRAR */
2064 ShowWindow(lpBand->hwndChild, SW_SHOWNOACTIVATE | SW_SHOWNORMAL);
2065 /* above in trace fro WinRAR */
2068 TRACE("child: %p prev parent: %p\n",
2069 lpBand->hwndChild, lpBand->hwndPrevParent);
2070 lpBand->hwndChild = 0;
2071 lpBand->hwndPrevParent = 0;
2075 if (lprbbi->fMask & RBBIM_CHILDSIZE) {
2076 lpBand->cxMinChild = lprbbi->cxMinChild;
2077 lpBand->cyMinChild = lprbbi->cyMinChild;
2078 if (lprbbi->cbSize >= sizeof (REBARBANDINFOA)) {
2079 lpBand->cyChild = lprbbi->cyChild;
2080 lpBand->cyMaxChild = lprbbi->cyMaxChild;
2081 lpBand->cyIntegral = lprbbi->cyIntegral;
2083 else { /* special case - these should be zeroed out since */
2084 /* RBBIM_CHILDSIZE added these in WIN32_IE >= 0x0400 */
2085 lpBand->cyChild = 0;
2086 lpBand->cyMaxChild = 0;
2087 lpBand->cyIntegral = 0;
2091 if (lprbbi->fMask & RBBIM_SIZE)
2092 lpBand->cx = lprbbi->cx;
2094 if (lprbbi->fMask & RBBIM_BACKGROUND)
2095 lpBand->hbmBack = lprbbi->hbmBack;
2097 if (lprbbi->fMask & RBBIM_ID)
2098 lpBand->wID = lprbbi->wID;
2100 /* check for additional data */
2101 if (lprbbi->cbSize >= sizeof (REBARBANDINFOA)) {
2102 if (lprbbi->fMask & RBBIM_IDEALSIZE)
2103 lpBand->cxIdeal = lprbbi->cxIdeal;
2105 if (lprbbi->fMask & RBBIM_LPARAM)
2106 lpBand->lParam = lprbbi->lParam;
2108 if (lprbbi->fMask & RBBIM_HEADERSIZE)
2109 lpBand->cxHeader = lprbbi->cxHeader;
2114 REBAR_InternalEraseBkGnd (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam, RECT *clip)
2115 /* Function: This erases the background rectangle by drawing */
2116 /* each band with its background color (or the default) and */
2117 /* draws each bands right separator if necessary. The row */
2118 /* separators are drawn on the first band of the next row. */
2123 HDC hdc = (HDC)wParam;
2125 COLORREF old = CLR_NONE, new;
2128 for(i=0; i<infoPtr->uNumBands; i++) {
2129 lpBand = &infoPtr->bands[i];
2130 if (HIDDENBAND(lpBand)) continue;
2132 /* draw band separator between rows */
2133 if (lpBand->iRow != oldrow) {
2134 oldrow = lpBand->iRow;
2135 if (lpBand->fDraw & DRAW_BOTTOMSEP) {
2137 rcRowSep = lpBand->rcBand;
2138 if (infoPtr->dwStyle & CCS_VERT) {
2139 rcRowSep.right += SEP_WIDTH_SIZE;
2140 rcRowSep.bottom = infoPtr->calcSize.cy;
2141 DrawEdge (hdc, &rcRowSep, EDGE_ETCHED, BF_RIGHT);
2144 rcRowSep.bottom += SEP_WIDTH_SIZE;
2145 rcRowSep.right = infoPtr->calcSize.cx;
2146 DrawEdge (hdc, &rcRowSep, EDGE_ETCHED, BF_BOTTOM);
2148 TRACE ("drawing band separator bottom (%ld,%ld)-(%ld,%ld)\n",
2149 rcRowSep.left, rcRowSep.top,
2150 rcRowSep.right, rcRowSep.bottom);
2154 /* draw band separator between bands in a row */
2155 if (lpBand->fDraw & DRAW_RIGHTSEP) {
2157 rcSep = lpBand->rcBand;
2158 if (infoPtr->dwStyle & CCS_VERT) {
2159 rcSep.bottom += SEP_WIDTH_SIZE;
2160 DrawEdge (hdc, &rcSep, EDGE_ETCHED, BF_BOTTOM);
2163 rcSep.right += SEP_WIDTH_SIZE;
2164 DrawEdge (hdc, &rcSep, EDGE_ETCHED, BF_RIGHT);
2166 TRACE("drawing band separator right (%ld,%ld)-(%ld,%ld)\n",
2167 rcSep.left, rcSep.top, rcSep.right, rcSep.bottom);
2170 /* draw the actual background */
2171 if (lpBand->clrBack != CLR_NONE) {
2172 new = (lpBand->clrBack == CLR_DEFAULT) ? infoPtr->clrBtnFace :
2175 /* testing only - make background green to see it */
2180 /* In the absence of documentation for Rebar vs. CLR_NONE,
2181 * we will use the default BtnFace color. Note documentation
2182 * exists for Listview and Imagelist.
2184 new = infoPtr->clrBtnFace;
2186 /* testing only - make background green to see it */
2190 old = SetBkColor (hdc, new);
2192 rect = lpBand->rcBand;
2193 TRACE("%s background color=0x%06lx, band (%ld,%ld)-(%ld,%ld), clip (%ld,%ld)-(%ld,%ld)\n",
2194 (lpBand->clrBack == CLR_NONE) ? "none" :
2195 ((lpBand->clrBack == CLR_DEFAULT) ? "dft" : ""),
2197 lpBand->rcBand.left,lpBand->rcBand.top,
2198 lpBand->rcBand.right,lpBand->rcBand.bottom,
2199 clip->left, clip->top,
2200 clip->right, clip->bottom);
2201 ExtTextOutA (hdc, 0, 0, ETO_OPAQUE, &rect, NULL, 0, 0);
2202 if (lpBand->clrBack != CLR_NONE)
2203 SetBkColor (hdc, old);
2209 REBAR_InternalHitTest (REBAR_INFO *infoPtr, LPPOINT lpPt, UINT *pFlags, INT *pBand)
2215 GetClientRect (infoPtr->hwndSelf, &rect);
2217 *pFlags = RBHT_NOWHERE;
2218 if (PtInRect (&rect, *lpPt))
2220 if (infoPtr->uNumBands == 0) {
2221 *pFlags = RBHT_NOWHERE;
2228 /* somewhere inside */
2229 infoPtr->ihitBand = -1;
2230 for (iCount = 0; iCount < infoPtr->uNumBands; iCount++) {
2231 lpBand = &infoPtr->bands[iCount];
2232 if (HIDDENBAND(lpBand)) continue;
2233 if (PtInRect (&lpBand->rcBand, *lpPt)) {
2236 if (PtInRect (&lpBand->rcGripper, *lpPt)) {
2237 *pFlags = RBHT_GRABBER;
2238 infoPtr->ihitBand = iCount;
2239 TRACE("ON GRABBER %d\n", iCount);
2242 else if (PtInRect (&lpBand->rcCapImage, *lpPt)) {
2243 *pFlags = RBHT_CAPTION;
2244 TRACE("ON CAPTION %d\n", iCount);
2247 else if (PtInRect (&lpBand->rcCapText, *lpPt)) {
2248 *pFlags = RBHT_CAPTION;
2249 TRACE("ON CAPTION %d\n", iCount);
2252 else if (PtInRect (&lpBand->rcChild, *lpPt)) {
2253 *pFlags = RBHT_CLIENT;
2254 TRACE("ON CLIENT %d\n", iCount);
2258 *pFlags = RBHT_NOWHERE;
2259 TRACE("NOWHERE %d\n", iCount);
2265 *pFlags = RBHT_NOWHERE;
2274 *pFlags = RBHT_NOWHERE;
2284 REBAR_Shrink (REBAR_INFO *infoPtr, REBAR_BAND *band, INT movement, INT i)
2285 /* Function: This attempts to shrink the given band by the */
2286 /* the amount in "movement". A shrink to the left is indi- */
2287 /* cated by "movement" being negative. "i" is merely the */
2288 /* band index for trace messages. */
2290 INT Leadjust, Readjust, avail, ret;
2292 /* Note: a left drag is indicated by "movement" being negative. */
2293 /* Similarly, a right drag is indicated by "movement" */
2294 /* being positive. "movement" should never be 0, but if */
2295 /* it is then the band does not move. */
2297 avail = rcBw(band) - band->lcx;
2299 /* now compute the Left End adjustment factor and Right End */
2300 /* adjustment factor. They may be different if shrinking. */
2302 /* if this band is not shrinkable, then just move it */
2303 Leadjust = Readjust = movement;
2309 if (avail <= abs(movement)) {
2310 Readjust = movement;
2311 Leadjust = movement + avail;
2315 Readjust = movement;
2322 if (avail <= abs(movement)) {
2323 Leadjust = movement;
2324 Readjust = movement - avail;
2328 Leadjust = movement;
2335 /* Reasonability Check */
2336 if (rcBlt(band) + Leadjust < 0) {
2337 ERR("adjustment will fail, band %d: left=%d, right=%d, move=%d, rtn=%d\n",
2338 i, Leadjust, Readjust, movement, ret);
2341 LEADJ(band, Leadjust);
2342 READJ(band, Readjust);
2344 TRACE("band %d: left=%d, right=%d, move=%d, rtn=%d, rcBand=(%ld,%ld)-(%ld,%ld)\n",
2345 i, Leadjust, Readjust, movement, ret,
2346 band->rcBand.left, band->rcBand.top,
2347 band->rcBand.right, band->rcBand.bottom);
2353 REBAR_HandleLRDrag (REBAR_INFO *infoPtr, POINTS *ptsmove)
2354 /* Function: This will implement the functionality of a */
2355 /* Gripper drag within a row. It will not implement "out- */
2356 /* of-row" drags. (They are detected and handled in */
2357 /* REBAR_MouseMove.) */
2358 /* **** FIXME Switching order of bands in a row not **** */
2359 /* **** yet implemented. **** */
2361 REBAR_BAND *hitBand, *band, *mindBand, *maxdBand;
2363 INT imindBand = -1, imaxdBand, ihitBand, i, movement;
2364 INT RHeaderSum = 0, LHeaderSum = 0;
2367 /* on first significant mouse movement, issue notify */
2369 if (!(infoPtr->fStatus & BEGIN_DRAG_ISSUED)) {
2370 if (REBAR_Notify_NMREBAR (infoPtr, -1, RBN_BEGINDRAG)) {
2371 /* Notify returned TRUE - abort drag */
2372 infoPtr->dragStart.x = 0;
2373 infoPtr->dragStart.y = 0;
2374 infoPtr->dragNow = infoPtr->dragStart;
2375 infoPtr->ihitBand = -1;
2379 infoPtr->fStatus |= BEGIN_DRAG_ISSUED;
2382 ihitBand = infoPtr->ihitBand;
2383 hitBand = &infoPtr->bands[ihitBand];
2384 imaxdBand = ihitBand; /* to suppress warning message */
2386 /* find all the bands in the row of the one whose Gripper was seized */
2387 for (i=0; i<infoPtr->uNumBands; i++) {
2388 band = &infoPtr->bands[i];
2389 if (HIDDENBAND(band)) continue;
2390 if (band->iRow == hitBand->iRow) {
2392 if (imindBand == -1) imindBand = i;
2393 /* minimum size of each band is size of header plus */
2394 /* size of minimum child plus offset of child from header plus */
2395 /* a one to separate each band. */
2397 LHeaderSum += (band->lcx + SEP_WIDTH);
2399 RHeaderSum += (band->lcx + SEP_WIDTH);
2403 if (RHeaderSum) RHeaderSum -= SEP_WIDTH; /* no separator afterlast band */
2405 mindBand = &infoPtr->bands[imindBand];
2406 maxdBand = &infoPtr->bands[imaxdBand];
2408 if (imindBand == imaxdBand) return; /* nothing to drag agains */
2409 if (imindBand == ihitBand) return; /* first band in row, cant drag */
2411 /* limit movement to inside adjustable bands - Left */
2412 if ( (ptsmove->x < mindBand->rcBand.left) ||
2413 (ptsmove->x > maxdBand->rcBand.right) ||
2414 (ptsmove->y < mindBand->rcBand.top) ||
2415 (ptsmove->y > maxdBand->rcBand.bottom))
2416 return; /* should swap bands */
2418 if (infoPtr->dwStyle & CCS_VERT)
2419 movement = ptsmove->y - ((hitBand->rcBand.top+REBAR_PRE_GRIPPER) -
2420 infoPtr->ihitoffset);
2422 movement = ptsmove->x - ((hitBand->rcBand.left+REBAR_PRE_GRIPPER) -
2423 infoPtr->ihitoffset);
2424 infoPtr->dragNow = *ptsmove;
2426 TRACE("before: movement=%d (%d,%d), imindBand=%d, ihitBand=%d, imaxdBand=%d, LSum=%d, RSum=%d\n",
2427 movement, ptsmove->x, ptsmove->y, imindBand, ihitBand,
2428 imaxdBand, LHeaderSum, RHeaderSum);
2429 REBAR_DumpBand (infoPtr);
2433 /* *** Drag left/up *** */
2434 compress = rcBlt(hitBand) - rcBlt(mindBand) -
2436 if (compress < abs(movement)) {
2437 TRACE("limiting left drag, was %d changed to %d\n",
2438 movement, -compress);
2439 movement = -compress;
2442 for (i=ihitBand; i>=imindBand; i--) {
2443 band = &infoPtr->bands[i];
2444 if (HIDDENBAND(band)) continue;
2445 if (i == ihitBand) {
2446 LEADJ(band, movement);
2449 movement = REBAR_Shrink (infoPtr, band, movement, i);
2450 band->ccx = rcBw(band);
2456 /* *** Drag right/down *** */
2457 compress = rcBrb(maxdBand) - rcBlt(hitBand) -
2459 if (compress < abs(movement)) {
2460 TRACE("limiting right drag, was %d changed to %d\n",
2461 movement, compress);
2462 movement = compress;
2464 for (i=ihitBand-1; i<=imaxdBand; i++) {
2465 band = &infoPtr->bands[i];
2466 if (HIDDENBAND(band)) continue;
2469 READJ(band, movement);
2472 movement = REBAR_Shrink (infoPtr, band, movement, i);
2473 band->ccx = rcBw(band);
2477 /* recompute all rectangles */
2478 if (infoPtr->dwStyle & CCS_VERT) {
2479 REBAR_CalcVertBand (infoPtr, imindBand, imaxdBand+1,
2483 REBAR_CalcHorzBand (infoPtr, imindBand, imaxdBand+1,
2487 TRACE("bands after adjustment, see band # %d, %d\n",
2488 imindBand, imaxdBand);
2489 REBAR_DumpBand (infoPtr);
2492 mindBand->rcBand.left,
2493 mindBand->rcBand.top,
2494 maxdBand->rcBand.right,
2495 maxdBand->rcBand.bottom);
2497 REBAR_MoveChildWindows (infoPtr, imindBand, imaxdBand+1);
2499 InvalidateRect (infoPtr->hwndSelf, &newrect, TRUE);
2500 UpdateWindow (infoPtr->hwndSelf);
2506 /* << REBAR_BeginDrag >> */
2510 REBAR_DeleteBand (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
2512 UINT uBand = (UINT)wParam;
2516 if (uBand >= infoPtr->uNumBands)
2519 TRACE("deleting band %u!\n", uBand);
2520 lpBand = &infoPtr->bands[uBand];
2521 REBAR_Notify_NMREBAR (infoPtr, uBand, RBN_DELETINGBAND);
2523 if (infoPtr->uNumBands == 1) {
2524 TRACE(" simple delete!\n");
2525 if ((lpBand->fMask & RBBIM_CHILD) && lpBand->hwndChild)
2526 childhwnd = lpBand->hwndChild;
2527 COMCTL32_Free (infoPtr->bands);
2528 infoPtr->bands = NULL;
2529 infoPtr->uNumBands = 0;
2532 REBAR_BAND *oldBands = infoPtr->bands;
2533 TRACE("complex delete! [uBand=%u]\n", uBand);
2535 if ((lpBand->fMask & RBBIM_CHILD) && lpBand->hwndChild)
2536 childhwnd = lpBand->hwndChild;
2538 infoPtr->uNumBands--;
2539 infoPtr->bands = COMCTL32_Alloc (sizeof (REBAR_BAND) * infoPtr->uNumBands);
2541 memcpy (&infoPtr->bands[0], &oldBands[0],
2542 uBand * sizeof(REBAR_BAND));
2545 if (uBand < infoPtr->uNumBands) {
2546 memcpy (&infoPtr->bands[uBand], &oldBands[uBand+1],
2547 (infoPtr->uNumBands - uBand) * sizeof(REBAR_BAND));
2550 COMCTL32_Free (oldBands);
2554 ShowWindow (childhwnd, SW_HIDE);
2556 REBAR_Notify_NMREBAR (infoPtr, -1, RBN_DELETEDBAND);
2558 /* if only 1 band left the re-validate to possible eliminate gripper */
2559 if (infoPtr->uNumBands == 1)
2560 REBAR_ValidateBand (infoPtr, &infoPtr->bands[0]);
2562 TRACE("setting NEEDS_LAYOUT\n");
2563 infoPtr->fStatus |= BAND_NEEDS_LAYOUT;
2564 infoPtr->fStatus |= RESIZE_ANYHOW;
2565 REBAR_Layout (infoPtr, NULL, TRUE, FALSE);
2571 /* << REBAR_DragMove >> */
2572 /* << REBAR_EndDrag >> */
2576 REBAR_GetBandBorders (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
2578 LPRECT lpRect = (LPRECT)lParam;
2583 if ((UINT)wParam >= infoPtr->uNumBands)
2586 lpBand = &infoPtr->bands[(UINT)wParam];
2588 /* FIXME - the following values were determined by experimentation */
2589 /* with the REBAR Control Spy. I have guesses as to what the 4 and */
2590 /* 1 are, but I am not sure. There doesn't seem to be any actual */
2591 /* difference in size of the control area with and without the */
2593 if (infoPtr->dwStyle & RBS_BANDBORDERS) {
2594 if (infoPtr->dwStyle & CCS_VERT) {
2596 lpRect->top = lpBand->cxHeader + 4;
2601 lpRect->left = lpBand->cxHeader + 4;
2608 lpRect->left = lpBand->cxHeader;
2614 inline static LRESULT
2615 REBAR_GetBandCount (REBAR_INFO *infoPtr)
2617 TRACE("band count %u!\n", infoPtr->uNumBands);
2619 return infoPtr->uNumBands;
2624 REBAR_GetBandInfoA (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
2626 LPREBARBANDINFOA lprbbi = (LPREBARBANDINFOA)lParam;
2631 if (lprbbi->cbSize < REBARBANDINFO_V3_SIZEA)
2633 if ((UINT)wParam >= infoPtr->uNumBands)
2636 TRACE("index %u\n", (UINT)wParam);
2638 /* copy band information */
2639 lpBand = &infoPtr->bands[(UINT)wParam];
2641 if (lprbbi->fMask & RBBIM_STYLE)
2642 lprbbi->fStyle = lpBand->fStyle;
2644 if (lprbbi->fMask & RBBIM_COLORS) {
2645 lprbbi->clrFore = lpBand->clrFore;
2646 lprbbi->clrBack = lpBand->clrBack;
2647 if (lprbbi->clrBack == CLR_DEFAULT)
2648 lprbbi->clrBack = infoPtr->clrBtnFace;
2651 if ((lprbbi->fMask & RBBIM_TEXT) && (lprbbi->lpText)) {
2652 if (lpBand->lpText && (lpBand->fMask & RBBIM_TEXT))
2654 if (!WideCharToMultiByte( CP_ACP, 0, lpBand->lpText, -1,
2655 lprbbi->lpText, lprbbi->cch, NULL, NULL ))
2656 lprbbi->lpText[lprbbi->cch-1] = 0;
2659 *lprbbi->lpText = 0;
2662 if (lprbbi->fMask & RBBIM_IMAGE) {
2663 if (lpBand->fMask & RBBIM_IMAGE)
2664 lprbbi->iImage = lpBand->iImage;
2666 lprbbi->iImage = -1;
2669 if (lprbbi->fMask & RBBIM_CHILD)
2670 lprbbi->hwndChild = lpBand->hwndChild;
2672 if (lprbbi->fMask & RBBIM_CHILDSIZE) {
2673 lprbbi->cxMinChild = lpBand->cxMinChild;
2674 lprbbi->cyMinChild = lpBand->cyMinChild;
2675 if (lprbbi->cbSize >= sizeof (REBARBANDINFOA)) {
2676 lprbbi->cyChild = lpBand->cyChild;
2677 lprbbi->cyMaxChild = lpBand->cyMaxChild;
2678 lprbbi->cyIntegral = lpBand->cyIntegral;
2682 if (lprbbi->fMask & RBBIM_SIZE)
2683 lprbbi->cx = lpBand->cx;
2685 if (lprbbi->fMask & RBBIM_BACKGROUND)
2686 lprbbi->hbmBack = lpBand->hbmBack;
2688 if (lprbbi->fMask & RBBIM_ID)
2689 lprbbi->wID = lpBand->wID;
2691 /* check for additional data */
2692 if (lprbbi->cbSize >= sizeof (REBARBANDINFOA)) {
2693 if (lprbbi->fMask & RBBIM_IDEALSIZE)
2694 lprbbi->cxIdeal = lpBand->cxIdeal;
2696 if (lprbbi->fMask & RBBIM_LPARAM)
2697 lprbbi->lParam = lpBand->lParam;
2699 if (lprbbi->fMask & RBBIM_HEADERSIZE)
2700 lprbbi->cxHeader = lpBand->cxHeader;
2703 REBAR_DumpBandInfo (lprbbi);
2710 REBAR_GetBandInfoW (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
2712 LPREBARBANDINFOW lprbbi = (LPREBARBANDINFOW)lParam;
2717 if (lprbbi->cbSize < REBARBANDINFO_V3_SIZEW)
2719 if ((UINT)wParam >= infoPtr->uNumBands)
2722 TRACE("index %u\n", (UINT)wParam);
2724 /* copy band information */
2725 lpBand = &infoPtr->bands[(UINT)wParam];
2727 if (lprbbi->fMask & RBBIM_STYLE)
2728 lprbbi->fStyle = lpBand->fStyle;
2730 if (lprbbi->fMask & RBBIM_COLORS) {
2731 lprbbi->clrFore = lpBand->clrFore;
2732 lprbbi->clrBack = lpBand->clrBack;
2733 if (lprbbi->clrBack == CLR_DEFAULT)
2734 lprbbi->clrBack = infoPtr->clrBtnFace;
2737 if ((lprbbi->fMask & RBBIM_TEXT) && (lprbbi->lpText)) {
2738 if (lpBand->lpText && (lpBand->fMask & RBBIM_TEXT))
2739 lstrcpynW (lprbbi->lpText, lpBand->lpText, lprbbi->cch);
2741 *lprbbi->lpText = 0;
2744 if (lprbbi->fMask & RBBIM_IMAGE) {
2745 if (lpBand->fMask & RBBIM_IMAGE)
2746 lprbbi->iImage = lpBand->iImage;
2748 lprbbi->iImage = -1;
2751 if (lprbbi->fMask & RBBIM_CHILD)
2752 lprbbi->hwndChild = lpBand->hwndChild;
2754 if (lprbbi->fMask & RBBIM_CHILDSIZE) {
2755 lprbbi->cxMinChild = lpBand->cxMinChild;
2756 lprbbi->cyMinChild = lpBand->cyMinChild;
2757 if (lprbbi->cbSize >= sizeof (REBARBANDINFOW)) {
2758 lprbbi->cyChild = lpBand->cyChild;
2759 lprbbi->cyMaxChild = lpBand->cyMaxChild;
2760 lprbbi->cyIntegral = lpBand->cyIntegral;
2764 if (lprbbi->fMask & RBBIM_SIZE)
2765 lprbbi->cx = lpBand->cx;
2767 if (lprbbi->fMask & RBBIM_BACKGROUND)
2768 lprbbi->hbmBack = lpBand->hbmBack;
2770 if (lprbbi->fMask & RBBIM_ID)
2771 lprbbi->wID = lpBand->wID;
2773 /* check for additional data */
2774 if (lprbbi->cbSize >= sizeof (REBARBANDINFOW)) {
2775 if (lprbbi->fMask & RBBIM_IDEALSIZE)
2776 lprbbi->cxIdeal = lpBand->cxIdeal;
2778 if (lprbbi->fMask & RBBIM_LPARAM)
2779 lprbbi->lParam = lpBand->lParam;
2781 if (lprbbi->fMask & RBBIM_HEADERSIZE)
2782 lprbbi->cxHeader = lpBand->cxHeader;
2785 REBAR_DumpBandInfo ((LPREBARBANDINFOA)lprbbi);
2792 REBAR_GetBarHeight (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
2796 nHeight = (infoPtr->dwStyle & CCS_VERT) ? infoPtr->calcSize.cx : infoPtr->calcSize.cy;
2798 TRACE("height = %d\n", nHeight);
2805 REBAR_GetBarInfo (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
2807 LPREBARINFO lpInfo = (LPREBARINFO)lParam;
2812 if (lpInfo->cbSize < sizeof (REBARINFO))
2815 TRACE("getting bar info!\n");
2817 if (infoPtr->himl) {
2818 lpInfo->himl = infoPtr->himl;
2819 lpInfo->fMask |= RBIM_IMAGELIST;
2826 inline static LRESULT
2827 REBAR_GetBkColor (REBAR_INFO *infoPtr)
2829 COLORREF clr = infoPtr->clrBk;
2831 if (clr == CLR_DEFAULT)
2832 clr = infoPtr->clrBtnFace;
2834 TRACE("background color 0x%06lx!\n", clr);
2840 /* << REBAR_GetColorScheme >> */
2841 /* << REBAR_GetDropTarget >> */
2845 REBAR_GetPalette (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
2847 FIXME("empty stub!\n");
2854 REBAR_GetRect (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
2856 INT iBand = (INT)wParam;
2857 LPRECT lprc = (LPRECT)lParam;
2860 if ((iBand < 0) && ((UINT)iBand >= infoPtr->uNumBands))
2865 lpBand = &infoPtr->bands[iBand];
2866 CopyRect (lprc, &lpBand->rcBand);
2868 TRACE("band %d, (%ld,%ld)-(%ld,%ld)\n", iBand,
2869 lprc->left, lprc->top, lprc->right, lprc->bottom);
2875 inline static LRESULT
2876 REBAR_GetRowCount (REBAR_INFO *infoPtr)
2878 TRACE("%u\n", infoPtr->uNumRows);
2880 return infoPtr->uNumRows;
2885 REBAR_GetRowHeight (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
2887 INT iRow = (INT)wParam;
2892 for (i=0; i<infoPtr->uNumBands; i++) {
2893 lpBand = &infoPtr->bands[i];
2894 if (HIDDENBAND(lpBand)) continue;
2895 if (lpBand->iRow != iRow) continue;
2896 if (infoPtr->dwStyle & CCS_VERT)
2897 j = lpBand->rcBand.right - lpBand->rcBand.left;
2899 j = lpBand->rcBand.bottom - lpBand->rcBand.top;
2900 if (j > ret) ret = j;
2903 TRACE("row %d, height %d\n", iRow, ret);
2909 inline static LRESULT
2910 REBAR_GetTextColor (REBAR_INFO *infoPtr)
2912 TRACE("text color 0x%06lx!\n", infoPtr->clrText);
2914 return infoPtr->clrText;
2918 inline static LRESULT
2919 REBAR_GetToolTips (REBAR_INFO *infoPtr)
2921 return (LRESULT)infoPtr->hwndToolTip;
2925 inline static LRESULT
2926 REBAR_GetUnicodeFormat (REBAR_INFO *infoPtr)
2928 TRACE("%s hwnd=%p\n",
2929 infoPtr->bUnicode ? "TRUE" : "FALSE", infoPtr->hwndSelf);
2931 return infoPtr->bUnicode;
2935 inline static LRESULT
2936 REBAR_GetVersion (REBAR_INFO *infoPtr)
2938 TRACE("version %d\n", infoPtr->iVersion);
2939 return infoPtr->iVersion;
2944 REBAR_HitTest (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
2946 LPRBHITTESTINFO lprbht = (LPRBHITTESTINFO)lParam;
2951 REBAR_InternalHitTest (infoPtr, &lprbht->pt, &lprbht->flags, &lprbht->iBand);
2953 return lprbht->iBand;
2958 REBAR_IdToIndex (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
2962 if (infoPtr == NULL)
2965 if (infoPtr->uNumBands < 1)
2968 for (i = 0; i < infoPtr->uNumBands; i++) {
2969 if (infoPtr->bands[i].wID == (UINT)wParam) {
2970 TRACE("id %u is band %u found!\n", (UINT)wParam, i);
2975 TRACE("id %u is not found\n", (UINT)wParam);
2981 REBAR_InsertBandA (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
2983 LPREBARBANDINFOA lprbbi = (LPREBARBANDINFOA)lParam;
2984 UINT uIndex = (UINT)wParam;
2987 if (infoPtr == NULL)
2991 if (lprbbi->cbSize < REBARBANDINFO_V3_SIZEA)
2994 /* trace the index as signed to see the -1 */
2995 TRACE("insert band at %d!\n", (INT)uIndex);
2996 REBAR_DumpBandInfo (lprbbi);
2998 if (infoPtr->uNumBands == 0) {
2999 infoPtr->bands = (REBAR_BAND *)COMCTL32_Alloc (sizeof (REBAR_BAND));
3003 REBAR_BAND *oldBands = infoPtr->bands;
3005 (REBAR_BAND *)COMCTL32_Alloc ((infoPtr->uNumBands+1)*sizeof(REBAR_BAND));
3006 if (((INT)uIndex == -1) || (uIndex > infoPtr->uNumBands))
3007 uIndex = infoPtr->uNumBands;
3009 /* pre insert copy */
3011 memcpy (&infoPtr->bands[0], &oldBands[0],
3012 uIndex * sizeof(REBAR_BAND));
3016 if (uIndex < infoPtr->uNumBands - 1) {
3017 memcpy (&infoPtr->bands[uIndex+1], &oldBands[uIndex],
3018 (infoPtr->uNumBands - uIndex - 1) * sizeof(REBAR_BAND));
3021 COMCTL32_Free (oldBands);
3024 infoPtr->uNumBands++;
3026 TRACE("index %u!\n", uIndex);
3028 /* initialize band (infoPtr->bands[uIndex])*/
3029 lpBand = &infoPtr->bands[uIndex];
3031 lpBand->fStatus = 0;
3032 lpBand->clrFore = infoPtr->clrText;
3033 lpBand->clrBack = infoPtr->clrBk;
3034 lpBand->hwndChild = 0;
3035 lpBand->hwndPrevParent = 0;
3037 REBAR_CommonSetupBand (infoPtr->hwndSelf, lprbbi, lpBand);
3038 lpBand->lpText = NULL;
3039 if ((lprbbi->fMask & RBBIM_TEXT) && (lprbbi->lpText)) {
3040 INT len = MultiByteToWideChar( CP_ACP, 0, lprbbi->lpText, -1, NULL, 0 );
3042 lpBand->lpText = (LPWSTR)COMCTL32_Alloc (len*sizeof(WCHAR));
3043 MultiByteToWideChar( CP_ACP, 0, lprbbi->lpText, -1, lpBand->lpText, len );
3047 REBAR_ValidateBand (infoPtr, lpBand);
3048 /* On insert of second band, revalidate band 1 to possible add gripper */
3049 if (infoPtr->uNumBands == 2)
3050 REBAR_ValidateBand (infoPtr, &infoPtr->bands[0]);
3052 REBAR_DumpBand (infoPtr);
3054 REBAR_Layout (infoPtr, NULL, TRUE, FALSE);
3055 InvalidateRect(infoPtr->hwndSelf, 0, 1);
3062 REBAR_InsertBandW (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3064 LPREBARBANDINFOW lprbbi = (LPREBARBANDINFOW)lParam;
3065 UINT uIndex = (UINT)wParam;
3068 if (infoPtr == NULL)
3072 if (lprbbi->cbSize < REBARBANDINFO_V3_SIZEW)
3075 /* trace the index as signed to see the -1 */
3076 TRACE("insert band at %d!\n", (INT)uIndex);
3077 REBAR_DumpBandInfo ((LPREBARBANDINFOA)lprbbi);
3079 if (infoPtr->uNumBands == 0) {
3080 infoPtr->bands = (REBAR_BAND *)COMCTL32_Alloc (sizeof (REBAR_BAND));
3084 REBAR_BAND *oldBands = infoPtr->bands;
3086 (REBAR_BAND *)COMCTL32_Alloc ((infoPtr->uNumBands+1)*sizeof(REBAR_BAND));
3087 if (((INT)uIndex == -1) || (uIndex > infoPtr->uNumBands))
3088 uIndex = infoPtr->uNumBands;
3090 /* pre insert copy */
3092 memcpy (&infoPtr->bands[0], &oldBands[0],
3093 uIndex * sizeof(REBAR_BAND));
3097 if (uIndex < infoPtr->uNumBands - 1) {
3098 memcpy (&infoPtr->bands[uIndex+1], &oldBands[uIndex],
3099 (infoPtr->uNumBands - uIndex - 1) * sizeof(REBAR_BAND));
3102 COMCTL32_Free (oldBands);
3105 infoPtr->uNumBands++;
3107 TRACE("index %u!\n", uIndex);
3109 /* initialize band (infoPtr->bands[uIndex])*/
3110 lpBand = &infoPtr->bands[uIndex];
3112 lpBand->fStatus = 0;
3113 lpBand->clrFore = infoPtr->clrText;
3114 lpBand->clrBack = infoPtr->clrBk;
3115 lpBand->hwndChild = 0;
3116 lpBand->hwndPrevParent = 0;
3118 REBAR_CommonSetupBand (infoPtr->hwndSelf, (LPREBARBANDINFOA)lprbbi, lpBand);
3119 lpBand->lpText = NULL;
3120 if ((lprbbi->fMask & RBBIM_TEXT) && (lprbbi->lpText)) {
3121 INT len = lstrlenW (lprbbi->lpText);
3123 lpBand->lpText = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
3124 strcpyW (lpBand->lpText, lprbbi->lpText);
3128 REBAR_ValidateBand (infoPtr, lpBand);
3129 /* On insert of second band, revalidate band 1 to possible add gripper */
3130 if (infoPtr->uNumBands == 2)
3131 REBAR_ValidateBand (infoPtr, &infoPtr->bands[0]);
3133 REBAR_DumpBand (infoPtr);
3135 REBAR_Layout (infoPtr, NULL, TRUE, FALSE);
3136 InvalidateRect(infoPtr->hwndSelf, 0, 1);
3143 REBAR_MaximizeBand (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3146 UINT uBand = (UINT) wParam;
3149 if ((infoPtr->uNumBands == 0) ||
3150 ((INT)uBand < 0) || (uBand >= infoPtr->uNumBands)) {
3152 ERR("Illegal MaximizeBand, requested=%d, current band count=%d\n",
3153 (INT)uBand, infoPtr->uNumBands);
3157 lpBand = &infoPtr->bands[uBand];
3159 if (lParam && (lpBand->fMask & RBBIM_IDEALSIZE)) {
3160 /* handle setting ideal size */
3161 lpBand->ccx = lpBand->cxIdeal;
3164 /* handle setting to max */
3165 FIXME("(uBand = %u fIdeal = %s) case not coded\n",
3166 (UINT)wParam, lParam ? "TRUE" : "FALSE");
3170 infoPtr->fStatus |= BAND_NEEDS_LAYOUT;
3171 REBAR_Layout (infoPtr, 0, TRUE, TRUE);
3172 InvalidateRect (infoPtr->hwndSelf, 0, TRUE);
3180 REBAR_MinimizeBand (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3182 REBAR_BAND *band, *lpBand;
3183 UINT uBand = (UINT) wParam;
3185 INT imindBand, imaxdBand, iprevBand, startBand, endBand;
3188 /* A "minimize" band is equivalent to "dragging" the gripper
3189 * of than band to the right till the band is only the size
3194 if ((infoPtr->uNumBands == 0) ||
3195 ((INT)uBand < 0) || (uBand >= infoPtr->uNumBands)) {
3197 ERR("Illegal MinimizeBand, requested=%d, current band count=%d\n",
3198 (INT)uBand, infoPtr->uNumBands);
3202 /* compute amount of movement and validate */
3203 lpBand = &infoPtr->bands[uBand];
3205 if (infoPtr->dwStyle & CCS_VERT)
3206 movement = lpBand->rcBand.bottom - lpBand->rcBand.top -
3209 movement = lpBand->rcBand.right - lpBand->rcBand.left -
3212 ERR("something is wrong, band=(%ld,%ld)-(%ld,%ld), cxheader=%d\n",
3213 lpBand->rcBand.left, lpBand->rcBand.top,
3214 lpBand->rcBand.right, lpBand->rcBand.bottom,
3221 iprevBand = -1; /* to suppress warning message */
3223 /* find the first band in row of the one whose is being minimized */
3224 for (i=0; i<infoPtr->uNumBands; i++) {
3225 band = &infoPtr->bands[i];
3226 if (HIDDENBAND(band)) continue;
3227 if (band->iRow == lpBand->iRow) {
3229 if (imindBand == -1) imindBand = i;
3233 /* if the selected band is first in row then need to expand */
3234 /* next visible band */
3235 if (imindBand == uBand) {
3237 movement = -movement;
3238 /* find the first visible band to the right of the selected band */
3239 for (i=uBand+1; i<=imaxdBand; i++) {
3240 band = &infoPtr->bands[i];
3241 if (!HIDDENBAND(band)) {
3243 LEADJ(band, movement);
3244 band->ccx = rcBw(band);
3248 /* what case is this */
3249 if (iprevBand == -1) {
3250 ERR("no previous visible band\n");
3254 endBand = iprevBand;
3256 lpBand->rcBand.left,
3259 band->rcBand.bottom);
3261 /* otherwise expand previous visible band */
3264 /* find the first visible band to the left of the selected band */
3265 for (i=uBand-1; i>=imindBand; i--) {
3266 band = &infoPtr->bands[i];
3267 if (!HIDDENBAND(band)) {
3269 READJ(band, movement);
3270 band->ccx = rcBw(band);
3274 /* what case is this */
3275 if (iprevBand == -1) {
3276 ERR("no previous visible band\n");
3279 startBand = iprevBand;
3284 lpBand->rcBand.right,
3285 lpBand->rcBand.bottom);
3288 REBAR_Shrink (infoPtr, lpBand, movement, uBand);
3290 /* recompute all rectangles */
3291 if (infoPtr->dwStyle & CCS_VERT) {
3292 REBAR_CalcVertBand (infoPtr, startBand, endBand+1,
3296 REBAR_CalcHorzBand (infoPtr, startBand, endBand+1,
3300 TRACE("bands after minimize, see band # %d, %d\n",
3301 startBand, endBand);
3302 REBAR_DumpBand (infoPtr);
3304 REBAR_MoveChildWindows (infoPtr, startBand, endBand+1);
3306 InvalidateRect (infoPtr->hwndSelf, &newrect, TRUE);
3307 UpdateWindow (infoPtr->hwndSelf);
3313 REBAR_MoveBand (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3315 REBAR_BAND *oldBands = infoPtr->bands;
3317 UINT uFrom = (UINT)wParam;
3318 UINT uTo = (UINT)lParam;
3321 if ((infoPtr->uNumBands == 0) ||
3322 ((INT)uFrom < 0) || (uFrom >= infoPtr->uNumBands) ||
3323 ((INT)uTo < 0) || (uTo >= infoPtr->uNumBands)) {
3325 ERR("Illegal MoveBand, from=%d, to=%d, current band count=%d\n",
3326 (INT)uFrom, (INT)uTo, infoPtr->uNumBands);
3330 /* save one to be moved */
3331 memcpy (&holder, &oldBands[uFrom], sizeof(REBAR_BAND));
3333 /* close up rest of bands (psuedo delete) */
3334 if (uFrom < infoPtr->uNumBands - 1) {
3335 memcpy (&oldBands[uFrom], &oldBands[uFrom+1],
3336 (infoPtr->uNumBands - uFrom - 1) * sizeof(REBAR_BAND));
3339 /* allocate new space and copy rest of bands into it */
3341 (REBAR_BAND *)COMCTL32_Alloc ((infoPtr->uNumBands)*sizeof(REBAR_BAND));
3343 /* pre insert copy */
3345 memcpy (&infoPtr->bands[0], &oldBands[0],
3346 uTo * sizeof(REBAR_BAND));
3349 /* set moved band */
3350 memcpy (&infoPtr->bands[uTo], &holder, sizeof(REBAR_BAND));
3353 if (uTo < infoPtr->uNumBands - 1) {
3354 memcpy (&infoPtr->bands[uTo+1], &oldBands[uTo],
3355 (infoPtr->uNumBands - uTo - 1) * sizeof(REBAR_BAND));
3358 COMCTL32_Free (oldBands);
3360 TRACE("moved band %d to index %d\n", uFrom, uTo);
3361 REBAR_DumpBand (infoPtr);
3363 infoPtr->fStatus |= BAND_NEEDS_LAYOUT;
3364 /* **************************************************** */
3366 /* We do not do a REBAR_Layout here because the native */
3367 /* control does not do that. The actual layout and */
3368 /* repaint is done by the *next* real action, ex.: */
3369 /* RB_INSERTBAND, RB_DELETEBAND, RB_SIZETORECT, etc. */
3371 /* **************************************************** */
3378 REBAR_SetBandInfoA (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3380 LPREBARBANDINFOA lprbbi = (LPREBARBANDINFOA)lParam;
3385 if (lprbbi->cbSize < REBARBANDINFO_V3_SIZEA)
3387 if ((UINT)wParam >= infoPtr->uNumBands)
3390 TRACE("index %u\n", (UINT)wParam);
3391 REBAR_DumpBandInfo (lprbbi);
3393 /* set band information */
3394 lpBand = &infoPtr->bands[(UINT)wParam];
3396 REBAR_CommonSetupBand (infoPtr->hwndSelf, lprbbi, lpBand);
3397 if (lprbbi->fMask & RBBIM_TEXT) {
3398 if (lpBand->lpText) {
3399 COMCTL32_Free (lpBand->lpText);
3400 lpBand->lpText = NULL;
3402 if (lprbbi->lpText) {
3403 INT len = MultiByteToWideChar( CP_ACP, 0, lprbbi->lpText, -1, NULL, 0 );
3404 lpBand->lpText = (LPWSTR)COMCTL32_Alloc (len*sizeof(WCHAR));
3405 MultiByteToWideChar( CP_ACP, 0, lprbbi->lpText, -1, lpBand->lpText, len );
3409 REBAR_ValidateBand (infoPtr, lpBand);
3411 REBAR_DumpBand (infoPtr);
3413 if (lprbbi->fMask & (RBBIM_CHILDSIZE | RBBIM_SIZE)) {
3414 REBAR_Layout (infoPtr, NULL, TRUE, FALSE);
3415 InvalidateRect(infoPtr->hwndSelf, 0, 1);
3423 REBAR_SetBandInfoW (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3425 LPREBARBANDINFOW lprbbi = (LPREBARBANDINFOW)lParam;
3430 if (lprbbi->cbSize < REBARBANDINFO_V3_SIZEW)
3432 if ((UINT)wParam >= infoPtr->uNumBands)
3435 TRACE("index %u\n", (UINT)wParam);
3436 REBAR_DumpBandInfo ((LPREBARBANDINFOA)lprbbi);
3438 /* set band information */
3439 lpBand = &infoPtr->bands[(UINT)wParam];
3441 REBAR_CommonSetupBand (infoPtr->hwndSelf, (LPREBARBANDINFOA)lprbbi, lpBand);
3442 if (lprbbi->fMask & RBBIM_TEXT) {
3443 if (lpBand->lpText) {
3444 COMCTL32_Free (lpBand->lpText);
3445 lpBand->lpText = NULL;
3447 if (lprbbi->lpText) {
3448 INT len = lstrlenW (lprbbi->lpText);
3449 lpBand->lpText = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
3450 strcpyW (lpBand->lpText, lprbbi->lpText);
3454 REBAR_ValidateBand (infoPtr, lpBand);
3456 REBAR_DumpBand (infoPtr);
3458 if (lprbbi->fMask & (RBBIM_CHILDSIZE | RBBIM_SIZE)) {
3459 REBAR_Layout (infoPtr, NULL, TRUE, FALSE);
3460 InvalidateRect(infoPtr->hwndSelf, 0, 1);
3468 REBAR_SetBarInfo (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3470 LPREBARINFO lpInfo = (LPREBARINFO)lParam;
3477 if (lpInfo->cbSize < sizeof (REBARINFO))
3480 TRACE("setting bar info!\n");
3482 if (lpInfo->fMask & RBIM_IMAGELIST) {
3483 infoPtr->himl = lpInfo->himl;
3484 if (infoPtr->himl) {
3486 ImageList_GetIconSize (infoPtr->himl, &cx, &cy);
3487 infoPtr->imageSize.cx = cx;
3488 infoPtr->imageSize.cy = cy;
3491 infoPtr->imageSize.cx = 0;
3492 infoPtr->imageSize.cy = 0;
3494 TRACE("new image cx=%ld, cy=%ld\n", infoPtr->imageSize.cx,
3495 infoPtr->imageSize.cy);
3498 /* revalidate all bands to reset flags for images in headers of bands */
3499 for (i=0; i<infoPtr->uNumBands; i++) {
3500 lpBand = &infoPtr->bands[i];
3501 REBAR_ValidateBand (infoPtr, lpBand);
3509 REBAR_SetBkColor (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3513 clrTemp = infoPtr->clrBk;
3514 infoPtr->clrBk = (COLORREF)lParam;
3516 TRACE("background color 0x%06lx!\n", infoPtr->clrBk);
3522 /* << REBAR_SetColorScheme >> */
3523 /* << REBAR_SetPalette >> */
3527 REBAR_SetParent (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3529 HWND hwndTemp = infoPtr->hwndNotify;
3531 infoPtr->hwndNotify = (HWND)wParam;
3533 return (LRESULT)hwndTemp;
3538 REBAR_SetTextColor (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3542 clrTemp = infoPtr->clrText;
3543 infoPtr->clrText = (COLORREF)lParam;
3545 TRACE("text color 0x%06lx!\n", infoPtr->clrText);
3551 /* << REBAR_SetTooltips >> */
3554 inline static LRESULT
3555 REBAR_SetUnicodeFormat (REBAR_INFO *infoPtr, WPARAM wParam)
3557 BOOL bTemp = infoPtr->bUnicode;
3559 TRACE("to %s hwnd=%p, was %s\n",
3560 ((BOOL)wParam) ? "TRUE" : "FALSE", infoPtr->hwndSelf,
3561 (bTemp) ? "TRUE" : "FALSE");
3563 infoPtr->bUnicode = (BOOL)wParam;
3570 REBAR_SetVersion (REBAR_INFO *infoPtr, INT iVersion)
3572 INT iOldVersion = infoPtr->iVersion;
3574 if (iVersion > COMCTL32_VERSION)
3577 infoPtr->iVersion = iVersion;
3579 TRACE("new version %d\n", iVersion);
3586 REBAR_ShowBand (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3590 if (((INT)wParam < 0) || ((INT)wParam > infoPtr->uNumBands))
3593 lpBand = &infoPtr->bands[(INT)wParam];
3596 TRACE("show band %d\n", (INT)wParam);
3597 lpBand->fStyle = lpBand->fStyle & ~RBBS_HIDDEN;
3598 if (IsWindow (lpBand->hwndChild))
3599 ShowWindow (lpBand->hwndChild, SW_SHOW);
3602 TRACE("hide band %d\n", (INT)wParam);
3603 lpBand->fStyle = lpBand->fStyle | RBBS_HIDDEN;
3604 if (IsWindow (lpBand->hwndChild))
3605 ShowWindow (lpBand->hwndChild, SW_HIDE);
3608 REBAR_Layout (infoPtr, NULL, TRUE, FALSE);
3609 InvalidateRect(infoPtr->hwndSelf, 0, 1);
3616 REBAR_SizeToRect (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3618 LPRECT lpRect = (LPRECT)lParam;
3624 TRACE("[%ld %ld %ld %ld]\n",
3625 lpRect->left, lpRect->top, lpRect->right, lpRect->bottom);
3627 /* what is going on???? */
3628 GetWindowRect(infoPtr->hwndSelf, &t1);
3629 TRACE("window rect [%ld %ld %ld %ld]\n",
3630 t1.left, t1.top, t1.right, t1.bottom);
3631 GetClientRect(infoPtr->hwndSelf, &t1);
3632 TRACE("client rect [%ld %ld %ld %ld]\n",
3633 t1.left, t1.top, t1.right, t1.bottom);
3635 /* force full _Layout processing */
3636 TRACE("setting NEEDS_LAYOUT\n");
3637 infoPtr->fStatus |= BAND_NEEDS_LAYOUT;
3638 REBAR_Layout (infoPtr, lpRect, TRUE, FALSE);
3639 InvalidateRect (infoPtr->hwndSelf, NULL, TRUE);
3646 REBAR_Create (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3648 LPCREATESTRUCTA cs = (LPCREATESTRUCTA) lParam;
3651 if (TRACE_ON(rebar)) {
3652 GetWindowRect(infoPtr->hwndSelf, &wnrc1);
3653 GetClientRect(infoPtr->hwndSelf, &clrc1);
3654 TRACE("window=(%ld,%ld)-(%ld,%ld) client=(%ld,%ld)-(%ld,%ld) cs=(%d,%d %dx%d)\n",
3655 wnrc1.left, wnrc1.top, wnrc1.right, wnrc1.bottom,
3656 clrc1.left, clrc1.top, clrc1.right, clrc1.bottom,
3657 cs->x, cs->y, cs->cx, cs->cy);
3660 TRACE("created!\n");
3666 REBAR_Destroy (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3672 /* free rebar bands */
3673 if ((infoPtr->uNumBands > 0) && infoPtr->bands) {
3674 /* clean up each band */
3675 for (i = 0; i < infoPtr->uNumBands; i++) {
3676 lpBand = &infoPtr->bands[i];
3678 /* delete text strings */
3679 if (lpBand->lpText) {
3680 COMCTL32_Free (lpBand->lpText);
3681 lpBand->lpText = NULL;
3683 /* destroy child window */
3684 DestroyWindow (lpBand->hwndChild);
3687 /* free band array */
3688 COMCTL32_Free (infoPtr->bands);
3689 infoPtr->bands = NULL;
3692 DeleteObject (infoPtr->hcurArrow);
3693 DeleteObject (infoPtr->hcurHorz);
3694 DeleteObject (infoPtr->hcurVert);
3695 DeleteObject (infoPtr->hcurDrag);
3696 if(infoPtr->hDefaultFont) DeleteObject (infoPtr->hDefaultFont);
3697 SetWindowLongA (infoPtr->hwndSelf, 0, 0);
3699 /* free rebar info data */
3700 COMCTL32_Free (infoPtr);
3701 TRACE("destroyed!\n");
3707 REBAR_EraseBkGnd (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3711 if (GetClipBox ( (HDC)wParam, &cliprect))
3712 return REBAR_InternalEraseBkGnd (infoPtr, wParam, lParam, &cliprect);
3718 REBAR_GetFont (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3720 return (LRESULT)infoPtr->hFont;
3725 REBAR_LButtonDown (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3729 /* If InternalHitTest did not find a hit on the Gripper, */
3730 /* then ignore the button click. */
3731 if (infoPtr->ihitBand == -1) return 0;
3733 SetCapture (infoPtr->hwndSelf);
3735 /* save off the LOWORD and HIWORD of lParam as initial x,y */
3736 lpBand = &infoPtr->bands[infoPtr->ihitBand];
3737 infoPtr->dragStart = MAKEPOINTS(lParam);
3738 infoPtr->dragNow = infoPtr->dragStart;
3739 if (infoPtr->dwStyle & CCS_VERT)
3740 infoPtr->ihitoffset = infoPtr->dragStart.y - (lpBand->rcBand.top+REBAR_PRE_GRIPPER);
3742 infoPtr->ihitoffset = infoPtr->dragStart.x - (lpBand->rcBand.left+REBAR_PRE_GRIPPER);
3749 REBAR_LButtonUp (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3755 /* If InternalHitTest did not find a hit on the Gripper, */
3756 /* then ignore the button click. */
3757 if (infoPtr->ihitBand == -1) return 0;
3759 ihitBand = infoPtr->ihitBand;
3760 infoPtr->dragStart.x = 0;
3761 infoPtr->dragStart.y = 0;
3762 infoPtr->dragNow = infoPtr->dragStart;
3763 infoPtr->ihitBand = -1;
3767 if (infoPtr->fStatus & BEGIN_DRAG_ISSUED) {
3768 REBAR_Notify((NMHDR *) &layout, infoPtr, RBN_LAYOUTCHANGED);
3769 REBAR_Notify_NMREBAR (infoPtr, ihitBand, RBN_ENDDRAG);
3770 infoPtr->fStatus &= ~BEGIN_DRAG_ISSUED;
3773 GetClientRect(infoPtr->hwndSelf, &rect);
3774 InvalidateRect(infoPtr->hwndSelf, NULL, TRUE);
3781 REBAR_MouseMove (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3783 REBAR_BAND *band1, *band2;
3786 /* Validate entry as hit on Gripper has occurred */
3787 if (GetCapture() != infoPtr->hwndSelf) return 0;
3788 if (infoPtr->ihitBand == -1) return 0;
3790 ptsmove = MAKEPOINTS(lParam);
3792 /* if mouse did not move much, exit */
3793 if ((abs(ptsmove.x - infoPtr->dragNow.x) <= mindragx) &&
3794 (abs(ptsmove.y - infoPtr->dragNow.y) <= mindragy)) return 0;
3796 band1 = &infoPtr->bands[infoPtr->ihitBand-1];
3797 band2 = &infoPtr->bands[infoPtr->ihitBand];
3799 /* Test for valid drag case - must not be first band in row */
3800 if (infoPtr->dwStyle & CCS_VERT) {
3801 if ((ptsmove.x < band2->rcBand.left) ||
3802 (ptsmove.x > band2->rcBand.right) ||
3803 ((infoPtr->ihitBand > 0) && (band1->iRow != band2->iRow))) {
3804 FIXME("Cannot drag to other rows yet!!\n");
3807 REBAR_HandleLRDrag (infoPtr, &ptsmove);
3811 if ((ptsmove.y < band2->rcBand.top) ||
3812 (ptsmove.y > band2->rcBand.bottom) ||
3813 ((infoPtr->ihitBand > 0) && (band1->iRow != band2->iRow))) {
3814 FIXME("Cannot drag to other rows yet!!\n");
3817 REBAR_HandleLRDrag (infoPtr, &ptsmove);
3824 inline static LRESULT
3825 REBAR_NCCalcSize (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3827 if (infoPtr->dwStyle & WS_BORDER) {
3828 InflateRect((LPRECT)lParam, -GetSystemMetrics(SM_CXEDGE),
3829 -GetSystemMetrics(SM_CYEDGE));
3831 TRACE("new client=(%ld,%ld)-(%ld,%ld)\n",
3832 ((LPRECT)lParam)->left, ((LPRECT)lParam)->top,
3833 ((LPRECT)lParam)->right, ((LPRECT)lParam)->bottom);
3839 REBAR_NCCreate (HWND hwnd, WPARAM wParam, LPARAM lParam)
3841 LPCREATESTRUCTA cs = (LPCREATESTRUCTA) lParam;
3842 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
3844 NONCLIENTMETRICSA ncm;
3848 if (infoPtr != NULL) {
3849 ERR("Strange info structure pointer *not* NULL\n");
3853 if (TRACE_ON(rebar)) {
3854 GetWindowRect(hwnd, &wnrc1);
3855 GetClientRect(hwnd, &clrc1);
3856 TRACE("window=(%ld,%ld)-(%ld,%ld) client=(%ld,%ld)-(%ld,%ld) cs=(%d,%d %dx%d)\n",
3857 wnrc1.left, wnrc1.top, wnrc1.right, wnrc1.bottom,
3858 clrc1.left, clrc1.top, clrc1.right, clrc1.bottom,
3859 cs->x, cs->y, cs->cx, cs->cy);
3862 /* allocate memory for info structure */
3863 infoPtr = (REBAR_INFO *)COMCTL32_Alloc (sizeof(REBAR_INFO));
3864 SetWindowLongA (hwnd, 0, (DWORD)infoPtr);
3866 /* initialize info structure - initial values are 0 */
3867 infoPtr->clrBk = CLR_NONE;
3868 infoPtr->clrText = CLR_NONE;
3869 infoPtr->clrBtnText = GetSysColor (COLOR_BTNTEXT);
3870 infoPtr->clrBtnFace = GetSysColor (COLOR_BTNFACE);
3871 infoPtr->ihitBand = -1;
3872 infoPtr->hwndSelf = hwnd;
3873 infoPtr->DoRedraw = TRUE;
3874 infoPtr->hcurArrow = LoadCursorA (0, IDC_ARROWA);
3875 infoPtr->hcurHorz = LoadCursorA (0, IDC_SIZEWEA);
3876 infoPtr->hcurVert = LoadCursorA (0, IDC_SIZENSA);
3877 infoPtr->hcurDrag = LoadCursorA (0, IDC_SIZEA);
3878 infoPtr->bUnicode = IsWindowUnicode (hwnd);
3879 infoPtr->fStatus = CREATE_RUNNING;
3880 infoPtr->hFont = GetStockObject (SYSTEM_FONT);
3882 /* issue WM_NOTIFYFORMAT to get unicode status of parent */
3883 i = SendMessageA(REBAR_GetNotifyParent (infoPtr),
3884 WM_NOTIFYFORMAT, (WPARAM)hwnd, NF_QUERY);
3885 if ((i < NFR_ANSI) || (i > NFR_UNICODE)) {
3886 ERR("wrong response to WM_NOTIFYFORMAT (%d), assuming ANSI\n",
3890 infoPtr->NtfUnicode = (i == NFR_UNICODE) ? 1 : 0;
3892 /* add necessary styles to the requested styles */
3893 infoPtr->dwStyle = cs->style | WS_VISIBLE | CCS_TOP;
3894 SetWindowLongA (hwnd, GWL_STYLE, infoPtr->dwStyle);
3896 /* get font handle for Caption Font */
3897 ncm.cbSize = sizeof(NONCLIENTMETRICSA);
3898 SystemParametersInfoA (SPI_GETNONCLIENTMETRICS,
3899 ncm.cbSize, &ncm, 0);
3900 /* if the font is bold, set to normal */
3901 if (ncm.lfCaptionFont.lfWeight > FW_NORMAL) {
3902 ncm.lfCaptionFont.lfWeight = FW_NORMAL;
3904 tfont = CreateFontIndirectA (&ncm.lfCaptionFont);
3906 infoPtr->hFont = infoPtr->hDefaultFont = tfont;
3910 GetSysColor (numerous);
3911 GetSysColorBrush (numerous) (see WM_SYSCOLORCHANGE);
3912 *GetStockObject (SYSTEM_FONT);
3913 *SetWindowLong (hwnd, 0, info ptr);
3915 *SetWindowLong (hwnd, GWL_STYLE, style+0x10000001);
3916 WS_VISIBLE = 0x10000000;
3917 CCS_TOP = 0x00000001;
3918 *SystemParametersInfo (SPI_GETNONCLIENTMETRICS...);
3919 *CreateFontIndirect (lfCaptionFont from above);
3921 SelectObject (hdc, fontabove);
3922 GetTextMetrics (hdc, ); guessing is tmHeight
3923 SelectObject (hdc, oldfont);
3926 MapWindowPoints (0, parent, rectabove, 2);
3929 ClientToScreen (clientrect);
3930 SetWindowPos (hwnd, 0, 0, 0, 0, 0, SWP_NOZORDER);
3937 REBAR_NCHitTest (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3944 LRESULT ret = HTCLIENT;
3947 * Differences from doc at MSDN (as observed with version 4.71 of
3949 * 1. doc says nmmouse.pt is in screen coord, trace shows client coord.
3950 * 2. if band is not identified .dwItemSpec is 0xffffffff.
3951 * 3. native always seems to return HTCLIENT if notify return is 0.
3954 shortpt = MAKEPOINTS (lParam);
3955 POINTSTOPOINT(pt, shortpt);
3957 ScreenToClient (infoPtr->hwndSelf, &clpt);
3958 REBAR_InternalHitTest (infoPtr, &clpt, &scrap,
3959 (INT *)&nmmouse.dwItemSpec);
3960 nmmouse.dwItemData = 0;
3962 nmmouse.dwHitInfo = 0;
3963 if ((i = REBAR_Notify((NMHDR *) &nmmouse, infoPtr, NM_NCHITTEST))) {
3964 TRACE("notify changed return value from %ld to %d\n",
3968 TRACE("returning %ld, client point (%ld,%ld)\n", ret, clpt.x, clpt.y);
3974 REBAR_NCPaint (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3979 if (infoPtr->dwStyle & WS_MINIMIZE)
3980 return 0; /* Nothing to do */
3982 if (infoPtr->dwStyle & WS_BORDER) {
3984 /* adjust rectangle and draw the necessary edge */
3985 if (!(hdc = GetDCEx( infoPtr->hwndSelf, 0, DCX_USESTYLE | DCX_WINDOW )))
3987 GetWindowRect (infoPtr->hwndSelf, &rcWindow);
3988 OffsetRect (&rcWindow, -rcWindow.left, -rcWindow.top);
3989 TRACE("rect (%ld,%ld)-(%ld,%ld)\n",
3990 rcWindow.left, rcWindow.top,
3991 rcWindow.right, rcWindow.bottom);
3992 DrawEdge (hdc, &rcWindow, EDGE_ETCHED, BF_RECT);
3993 ReleaseDC( infoPtr->hwndSelf, hdc );
4001 REBAR_NotifyFormat (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
4005 if (lParam == NF_REQUERY) {
4006 i = SendMessageA(REBAR_GetNotifyParent (infoPtr),
4007 WM_NOTIFYFORMAT, (WPARAM)infoPtr->hwndSelf, NF_QUERY);
4008 if ((i < NFR_ANSI) || (i > NFR_UNICODE)) {
4009 ERR("wrong response to WM_NOTIFYFORMAT (%d), assuming ANSI\n",
4013 infoPtr->NtfUnicode = (i == NFR_UNICODE) ? 1 : 0;
4016 return (LRESULT)((infoPtr->bUnicode) ? NFR_UNICODE : NFR_ANSI);
4021 REBAR_Paint (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
4027 GetClientRect(infoPtr->hwndSelf, &rc);
4028 hdc = wParam==0 ? BeginPaint (infoPtr->hwndSelf, &ps) : (HDC)wParam;
4030 TRACE("painting (%ld,%ld)-(%ld,%ld) client (%ld,%ld)-(%ld,%ld)\n",
4031 ps.rcPaint.left, ps.rcPaint.top,
4032 ps.rcPaint.right, ps.rcPaint.bottom,
4033 rc.left, rc.top, rc.right, rc.bottom);
4036 /* Erase area of paint if requested */
4037 REBAR_InternalEraseBkGnd (infoPtr, wParam, lParam, &ps.rcPaint);
4040 REBAR_Refresh (infoPtr, hdc);
4042 EndPaint (infoPtr->hwndSelf, &ps);
4048 REBAR_SetCursor (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
4053 TRACE("code=0x%X id=0x%X\n", LOWORD(lParam), HIWORD(lParam));
4056 ScreenToClient (infoPtr->hwndSelf, &pt);
4058 REBAR_InternalHitTest (infoPtr, &pt, &flags, NULL);
4060 if (flags == RBHT_GRABBER) {
4061 if ((infoPtr->dwStyle & CCS_VERT) &&
4062 !(infoPtr->dwStyle & RBS_VERTICALGRIPPER))
4063 SetCursor (infoPtr->hcurVert);
4065 SetCursor (infoPtr->hcurHorz);
4067 else if (flags != RBHT_CLIENT)
4068 SetCursor (infoPtr->hcurArrow);
4075 REBAR_SetFont (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
4081 infoPtr->hFont = (HFONT)wParam;
4083 /* revalidate all bands to change sizes of text in headers of bands */
4084 for (i=0; i<infoPtr->uNumBands; i++) {
4085 lpBand = &infoPtr->bands[i];
4086 REBAR_ValidateBand (infoPtr, lpBand);
4090 if (LOWORD(lParam)) {
4091 GetClientRect (infoPtr->hwndSelf, &rcClient);
4092 REBAR_Layout (infoPtr, &rcClient, FALSE, TRUE);
4099 inline static LRESULT
4100 REBAR_SetRedraw (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
4101 /*****************************************************
4104 * Handles the WM_SETREDRAW message.
4107 * According to testing V4.71 of COMCTL32 returns the
4108 * *previous* status of the redraw flag (either 0 or -1)
4109 * instead of the MSDN documented value of 0 if handled
4111 *****************************************************/
4113 BOOL oldredraw = infoPtr->DoRedraw;
4115 TRACE("set to %s, fStatus=%08x\n",
4116 (wParam) ? "TRUE" : "FALSE", infoPtr->fStatus);
4117 infoPtr->DoRedraw = (BOOL) wParam;
4119 if (infoPtr->fStatus & BAND_NEEDS_REDRAW) {
4120 REBAR_MoveChildWindows (infoPtr, 0, infoPtr->uNumBands);
4121 REBAR_ForceResize (infoPtr);
4122 InvalidateRect (infoPtr->hwndSelf, 0, TRUE);
4124 infoPtr->fStatus &= ~BAND_NEEDS_REDRAW;
4126 return (oldredraw) ? -1 : 0;
4131 REBAR_Size (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
4135 /* auto resize deadlock check */
4136 if (infoPtr->fStatus & AUTO_RESIZE) {
4137 infoPtr->fStatus &= ~AUTO_RESIZE;
4138 TRACE("AUTO_RESIZE was set, reset, fStatus=%08x lparam=%08lx\n",
4139 infoPtr->fStatus, lParam);
4143 if (infoPtr->fStatus & CREATE_RUNNING) {
4144 /* still in CreateWindow */
4147 if ((INT)wParam != SIZE_RESTORED) {
4148 ERR("WM_SIZE in create and flags=%08x, lParam=%08lx\n",
4152 TRACE("still in CreateWindow\n");
4153 infoPtr->fStatus &= ~CREATE_RUNNING;
4154 GetWindowRect ( infoPtr->hwndSelf, &rcWin);
4155 TRACE("win rect (%ld,%ld)-(%ld,%ld)\n",
4156 rcWin.left, rcWin.top, rcWin.right, rcWin.bottom);
4158 if ((lParam == 0) && (rcWin.right-rcWin.left == 0) &&
4159 (rcWin.bottom-rcWin.top == 0)) {
4160 /* native control seems to do this */
4161 GetClientRect (GetParent(infoPtr->hwndSelf), &rcClient);
4162 TRACE("sizing rebar, message and client zero, parent client (%ld,%ld)\n",
4163 rcClient.right, rcClient.bottom);
4168 cx = rcWin.right - rcWin.left;
4169 cy = rcWin.bottom - rcWin.top;
4170 if ((cx == LOWORD(lParam)) && (cy == HIWORD(lParam))) {
4174 /* do the actual WM_SIZE request */
4175 GetClientRect (infoPtr->hwndSelf, &rcClient);
4176 TRACE("sizing rebar from (%ld,%ld) to (%d,%d), client (%ld,%ld)\n",
4177 infoPtr->calcSize.cx, infoPtr->calcSize.cy,
4178 LOWORD(lParam), HIWORD(lParam),
4179 rcClient.right, rcClient.bottom);
4183 if ((INT)wParam != SIZE_RESTORED) {
4184 ERR("WM_SIZE out of create and flags=%08x, lParam=%08lx\n",
4188 /* Handle cases when outside of the CreateWindow process */
4190 GetClientRect (infoPtr->hwndSelf, &rcClient);
4191 if ((lParam == 0) && (rcClient.right + rcClient.bottom != 0) &&
4192 (infoPtr->dwStyle & RBS_AUTOSIZE)) {
4193 /* on a WM_SIZE to zero and current client not zero and AUTOSIZE */
4194 /* native seems to use the current client rect for the size */
4195 infoPtr->fStatus |= BAND_NEEDS_LAYOUT;
4196 TRACE("sizing rebar to client (%ld,%ld) size is zero but AUTOSIZE set\n",
4197 rcClient.right, rcClient.bottom);
4200 TRACE("sizing rebar from (%ld,%ld) to (%d,%d), client (%ld,%ld)\n",
4201 infoPtr->calcSize.cx, infoPtr->calcSize.cy,
4202 LOWORD(lParam), HIWORD(lParam),
4203 rcClient.right, rcClient.bottom);
4207 if (infoPtr->dwStyle & RBS_AUTOSIZE) {
4208 NMRBAUTOSIZE autosize;
4210 GetClientRect(infoPtr->hwndSelf, &autosize.rcTarget);
4211 autosize.fChanged = 0; /* ??? */
4212 autosize.rcActual = autosize.rcTarget; /* ??? */
4213 REBAR_Notify((NMHDR *) &autosize, infoPtr, RBN_AUTOSIZE);
4214 TRACE("RBN_AUTOSIZE client=(%ld,%ld), lp=%08lx\n",
4215 autosize.rcTarget.right, autosize.rcTarget.bottom, lParam);
4218 if ((infoPtr->calcSize.cx != rcClient.right) ||
4219 (infoPtr->calcSize.cy != rcClient.bottom))
4220 infoPtr->fStatus |= BAND_NEEDS_LAYOUT;
4222 REBAR_Layout (infoPtr, &rcClient, TRUE, TRUE);
4223 infoPtr->fStatus &= ~AUTO_RESIZE;
4230 REBAR_StyleChanged (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
4232 STYLESTRUCT *ss = (STYLESTRUCT *)lParam;
4234 TRACE("current style=%08lx, styleOld=%08lx, style being set to=%08lx\n",
4235 infoPtr->dwStyle, ss->styleOld, ss->styleNew);
4236 infoPtr->dwStyle = ss->styleNew;
4243 REBAR_WindowPosChanged (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
4245 WINDOWPOS *lpwp = (WINDOWPOS *)lParam;
4249 /* Save the new origin of this window - used by _ForceResize */
4250 infoPtr->origin.x = lpwp->x;
4251 infoPtr->origin.y = lpwp->y;
4252 ret = DefWindowProcA(infoPtr->hwndSelf, WM_WINDOWPOSCHANGED,
4254 GetWindowRect(infoPtr->hwndSelf, &rc);
4255 TRACE("hwnd %p new pos (%ld,%ld)-(%ld,%ld)\n",
4256 infoPtr->hwndSelf, rc.left, rc.top, rc.right, rc.bottom);
4261 static LRESULT WINAPI
4262 REBAR_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
4264 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
4266 TRACE("hwnd=%p msg=%x wparam=%x lparam=%lx\n",
4267 hwnd, uMsg, wParam, lParam);
4268 if (!infoPtr && (uMsg != WM_NCCREATE))
4269 return DefWindowProcA (hwnd, uMsg, wParam, lParam);
4272 /* case RB_BEGINDRAG: */
4275 return REBAR_DeleteBand (infoPtr, wParam, lParam);
4277 /* case RB_DRAGMOVE: */
4278 /* case RB_ENDDRAG: */
4280 case RB_GETBANDBORDERS:
4281 return REBAR_GetBandBorders (infoPtr, wParam, lParam);
4283 case RB_GETBANDCOUNT:
4284 return REBAR_GetBandCount (infoPtr);
4286 case RB_GETBANDINFO: /* obsoleted after IE3, but we have to
4287 support it anyway. */
4288 case RB_GETBANDINFOA:
4289 return REBAR_GetBandInfoA (infoPtr, wParam, lParam);
4291 case RB_GETBANDINFOW:
4292 return REBAR_GetBandInfoW (infoPtr, wParam, lParam);
4294 case RB_GETBARHEIGHT:
4295 return REBAR_GetBarHeight (infoPtr, wParam, lParam);
4298 return REBAR_GetBarInfo (infoPtr, wParam, lParam);
4301 return REBAR_GetBkColor (infoPtr);
4303 /* case RB_GETCOLORSCHEME: */
4304 /* case RB_GETDROPTARGET: */
4307 return REBAR_GetPalette (infoPtr, wParam, lParam);
4310 return REBAR_GetRect (infoPtr, wParam, lParam);
4312 case RB_GETROWCOUNT:
4313 return REBAR_GetRowCount (infoPtr);
4315 case RB_GETROWHEIGHT:
4316 return REBAR_GetRowHeight (infoPtr, wParam, lParam);
4318 case RB_GETTEXTCOLOR:
4319 return REBAR_GetTextColor (infoPtr);
4321 case RB_GETTOOLTIPS:
4322 return REBAR_GetToolTips (infoPtr);
4324 case RB_GETUNICODEFORMAT:
4325 return REBAR_GetUnicodeFormat (infoPtr);
4327 case CCM_GETVERSION:
4328 return REBAR_GetVersion (infoPtr);
4331 return REBAR_HitTest (infoPtr, wParam, lParam);
4334 return REBAR_IdToIndex (infoPtr, wParam, lParam);
4336 case RB_INSERTBANDA:
4337 return REBAR_InsertBandA (infoPtr, wParam, lParam);
4339 case RB_INSERTBANDW:
4340 return REBAR_InsertBandW (infoPtr, wParam, lParam);
4342 case RB_MAXIMIZEBAND:
4343 return REBAR_MaximizeBand (infoPtr, wParam, lParam);
4345 case RB_MINIMIZEBAND:
4346 return REBAR_MinimizeBand (infoPtr, wParam, lParam);
4349 return REBAR_MoveBand (infoPtr, wParam, lParam);
4351 case RB_SETBANDINFOA:
4352 return REBAR_SetBandInfoA (infoPtr, wParam, lParam);
4354 case RB_SETBANDINFOW:
4355 return REBAR_SetBandInfoW (infoPtr, wParam, lParam);
4358 return REBAR_SetBarInfo (infoPtr, wParam, lParam);
4361 return REBAR_SetBkColor (infoPtr, wParam, lParam);
4363 /* case RB_SETCOLORSCHEME: */
4364 /* case RB_SETPALETTE: */
4365 /* return REBAR_GetPalette (infoPtr, wParam, lParam); */
4368 return REBAR_SetParent (infoPtr, wParam, lParam);
4370 case RB_SETTEXTCOLOR:
4371 return REBAR_SetTextColor (infoPtr, wParam, lParam);
4373 /* case RB_SETTOOLTIPS: */
4375 case RB_SETUNICODEFORMAT:
4376 return REBAR_SetUnicodeFormat (infoPtr, wParam);
4378 case CCM_SETVERSION:
4379 return REBAR_SetVersion (infoPtr, (INT)wParam);
4382 return REBAR_ShowBand (infoPtr, wParam, lParam);
4385 return REBAR_SizeToRect (infoPtr, wParam, lParam);
4388 /* Messages passed to parent */
4392 if (infoPtr->NtfUnicode)
4393 return SendMessageW (REBAR_GetNotifyParent (infoPtr),
4394 uMsg, wParam, lParam);
4396 return SendMessageA (REBAR_GetNotifyParent (infoPtr),
4397 uMsg, wParam, lParam);
4400 /* case WM_CHARTOITEM: supported according to ControlSpy */
4403 return REBAR_Create (infoPtr, wParam, lParam);
4406 return REBAR_Destroy (infoPtr, wParam, lParam);
4409 return REBAR_EraseBkGnd (infoPtr, wParam, lParam);
4412 return REBAR_GetFont (infoPtr, wParam, lParam);
4414 /* case WM_LBUTTONDBLCLK: supported according to ControlSpy */
4416 case WM_LBUTTONDOWN:
4417 return REBAR_LButtonDown (infoPtr, wParam, lParam);
4420 return REBAR_LButtonUp (infoPtr, wParam, lParam);
4422 /* case WM_MEASUREITEM: supported according to ControlSpy */
4425 return REBAR_MouseMove (infoPtr, wParam, lParam);
4428 return REBAR_NCCalcSize (infoPtr, wParam, lParam);
4431 return REBAR_NCCreate (hwnd, wParam, lParam);
4434 return REBAR_NCHitTest (infoPtr, wParam, lParam);
4437 return REBAR_NCPaint (infoPtr, wParam, lParam);
4439 case WM_NOTIFYFORMAT:
4440 return REBAR_NotifyFormat (infoPtr, wParam, lParam);
4443 return REBAR_Paint (infoPtr, wParam, lParam);
4445 /* case WM_PALETTECHANGED: supported according to ControlSpy */
4446 /* case WM_PRINTCLIENT: supported according to ControlSpy */
4447 /* case WM_QUERYNEWPALETTE:supported according to ControlSpy */
4448 /* case WM_RBUTTONDOWN: supported according to ControlSpy */
4449 /* case WM_RBUTTONUP: supported according to ControlSpy */
4452 return REBAR_SetCursor (infoPtr, wParam, lParam);
4455 return REBAR_SetFont (infoPtr, wParam, lParam);
4458 return REBAR_SetRedraw (infoPtr, wParam, lParam);
4461 return REBAR_Size (infoPtr, wParam, lParam);
4463 case WM_STYLECHANGED:
4464 return REBAR_StyleChanged (infoPtr, wParam, lParam);
4466 /* case WM_SYSCOLORCHANGE: supported according to ControlSpy */
4467 /* "Applications that have brushes using the existing system colors
4468 should delete those brushes and recreate them using the new
4469 system colors." per MSDN */
4471 /* case WM_VKEYTOITEM: supported according to ControlSpy */
4472 /* case WM_WININICHANGE: */
4474 case WM_WINDOWPOSCHANGED:
4475 return REBAR_WindowPosChanged (infoPtr, wParam, lParam);
4478 if ((uMsg >= WM_USER) && (uMsg < WM_APP))
4479 ERR("unknown msg %04x wp=%08x lp=%08lx\n",
4480 uMsg, wParam, lParam);
4481 return DefWindowProcA (hwnd, uMsg, wParam, lParam);
4488 REBAR_Register (void)
4492 ZeroMemory (&wndClass, sizeof(WNDCLASSA));
4493 wndClass.style = CS_GLOBALCLASS | CS_DBLCLKS;
4494 wndClass.lpfnWndProc = (WNDPROC)REBAR_WindowProc;
4495 wndClass.cbClsExtra = 0;
4496 wndClass.cbWndExtra = sizeof(REBAR_INFO *);
4497 wndClass.hCursor = 0;
4498 wndClass.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1);
4500 wndClass.hbrBackground = CreateSolidBrush(RGB(0,128,0));
4502 wndClass.lpszClassName = REBARCLASSNAMEA;
4504 RegisterClassA (&wndClass);
4506 mindragx = GetSystemMetrics (SM_CXDRAG);
4507 mindragy = GetSystemMetrics (SM_CYDRAG);
4513 REBAR_Unregister (void)
4515 UnregisterClassA (REBARCLASSNAMEA, NULL);