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
147 #include "wine/unicode.h"
148 #include "commctrl.h"
149 /* #include "spy.h" */
150 #include "wine/debug.h"
152 WINE_DEFAULT_DEBUG_CHANNEL(rebar);
162 UINT cxMinChild; /* valid if _CHILDSIZE */
163 UINT cyMinChild; /* valid if _CHILDSIZE */
164 UINT cx; /* valid if _SIZE */
167 UINT cyChild; /* valid if _CHILDSIZE */
168 UINT cyMaxChild; /* valid if _CHILDSIZE */
169 UINT cyIntegral; /* valid if _CHILDSIZE */
174 UINT lcx; /* minimum cx for band */
175 UINT ccx; /* current cx for band */
176 UINT hcx; /* maximum cx for band */
177 UINT lcy; /* minimum cy for band */
178 UINT ccy; /* current cy for band */
179 UINT hcy; /* maximum cy for band */
181 SIZE offChild; /* x,y offset if child is not FIXEDSIZE */
183 INT iRow; /* row this band assigned to */
184 UINT fStatus; /* status flags, reset only by _Validate */
185 UINT fDraw; /* drawing flags, reset only by _Layout */
186 UINT uCDret; /* last return from NM_CUSTOMDRAW */
187 RECT rcoldBand; /* previous calculated band rectangle */
188 RECT rcBand; /* calculated band rectangle */
189 RECT rcGripper; /* calculated gripper rectangle */
190 RECT rcCapImage; /* calculated caption image rectangle */
191 RECT rcCapText; /* calculated caption text rectangle */
192 RECT rcChild; /* calculated child rectangle */
199 #define HAS_GRIPPER 0x00000001
200 #define HAS_IMAGE 0x00000002
201 #define HAS_TEXT 0x00000004
204 #define DRAW_GRIPPER 0x00000001
205 #define DRAW_IMAGE 0x00000002
206 #define DRAW_TEXT 0x00000004
207 #define DRAW_RIGHTSEP 0x00000010
208 #define DRAW_BOTTOMSEP 0x00000020
209 #define NTF_INVALIDATE 0x01000000
213 INT istartband; /* index of first band in row */
214 INT iendband; /* index of last band in row */
220 COLORREF clrBk; /* background color */
221 COLORREF clrText; /* text color */
222 COLORREF clrBtnText; /* system color for BTNTEXT */
223 COLORREF clrBtnFace; /* system color for BTNFACE */
224 HIMAGELIST himl; /* handle to imagelist */
225 UINT uNumBands; /* # of bands in rebar (first=0, last=uNumBands-1 */
226 UINT uNumRows; /* # of rows of bands (first=1, last=uNumRows */
227 HWND hwndSelf; /* handle of REBAR window itself */
228 HWND hwndToolTip; /* handle to the tool tip control */
229 HWND hwndNotify; /* notification window (parent) */
231 HFONT hFont; /* handle to the rebar's font */
232 SIZE imageSize; /* image size (image list) */
233 DWORD dwStyle; /* window style */
234 SIZE calcSize; /* calculated rebar size */
235 SIZE oldSize; /* previous calculated rebar size */
236 BOOL bUnicode; /* TRUE if this window is W type */
237 BOOL NtfUnicode; /* TRUE if parent wants notify in W format */
238 BOOL DoRedraw; /* TRUE to acutally draw bands */
239 UINT fStatus; /* Status flags (see below) */
240 HCURSOR hcurArrow; /* handle to the arrow cursor */
241 HCURSOR hcurHorz; /* handle to the EW cursor */
242 HCURSOR hcurVert; /* handle to the NS cursor */
243 HCURSOR hcurDrag; /* handle to the drag cursor */
244 INT iVersion; /* version number */
245 POINTS dragStart; /* x,y of button down */
246 POINTS dragNow; /* x,y of this MouseMove */
247 INT ihitBand; /* band number of band whose gripper was grabbed */
248 INT ihitoffset; /* offset of hotspot from gripper.left */
249 POINT origin; /* left/upper corner of client */
251 REBAR_ROW *rows; /* pointer to row indexes */
252 REBAR_BAND *bands; /* pointer to the array of rebar bands */
256 #define BEGIN_DRAG_ISSUED 0x00000001
257 #define AUTO_RESIZE 0x00000002
258 #define RESIZE_ANYHOW 0x00000004
259 #define NTF_HGHTCHG 0x00000008
260 #define BAND_NEEDS_LAYOUT 0x00000010
261 #define BAND_NEEDS_REDRAW 0x00000020
262 #define CREATE_RUNNING 0x00000040
264 /* ---- REBAR layout constants. Mostly determined by ---- */
265 /* ---- experiment on WIN 98. ---- */
267 /* Width (or height) of separators between bands (either horz. or */
268 /* vert.). True only if RBS_BANDBORDERS is set */
269 #define SEP_WIDTH_SIZE 2
270 #define SEP_WIDTH ((infoPtr->dwStyle & RBS_BANDBORDERS) ? SEP_WIDTH_SIZE : 0)
272 /* Blank (background color) space between Gripper (if present) */
273 /* and next item (image, text, or window). Always present */
274 #define REBAR_ALWAYS_SPACE 4
276 /* Blank (background color) space after Image (if present). */
277 #define REBAR_POST_IMAGE 2
279 /* Blank (background color) space after Text (if present). */
280 #define REBAR_POST_TEXT 4
282 /* Height of vertical gripper in a CCS_VERT rebar. */
283 #define GRIPPER_HEIGHT 16
285 /* Blank (background color) space before Gripper (if present). */
286 #define REBAR_PRE_GRIPPER 2
288 /* Width (of normal vertical gripper) or height (of horz. gripper) */
290 #define GRIPPER_WIDTH 3
292 /* Height of divider for Rebar if not disabled (CCS_NODIVIDER) */
293 /* either top or bottom */
294 #define REBAR_DIVIDER 2
296 /* This is the increment that is used over the band height */
297 #define REBARSPACE(a) ((a->fStyle & RBBS_CHILDEDGE) ? 2*REBAR_DIVIDER : 0)
299 /* ---- End of REBAR layout constants. ---- */
302 /* The following 6 defines return the proper rcBand element */
303 /* depending on whether CCS_VERT was set. */
304 #define rcBlt(b) ((infoPtr->dwStyle & CCS_VERT) ? b->rcBand.top : b->rcBand.left)
305 #define rcBrb(b) ((infoPtr->dwStyle & CCS_VERT) ? b->rcBand.bottom : b->rcBand.right)
306 #define rcBw(b) ((infoPtr->dwStyle & CCS_VERT) ? (b->rcBand.bottom - b->rcBand.top) : \
307 (b->rcBand.right - b->rcBand.left))
308 #define ircBlt(b) ((infoPtr->dwStyle & CCS_VERT) ? b->rcBand.left : b->rcBand.top)
309 #define ircBrb(b) ((infoPtr->dwStyle & CCS_VERT) ? b->rcBand.right : b->rcBand.bottom)
310 #define ircBw(b) ((infoPtr->dwStyle & CCS_VERT) ? (b->rcBand.right - b->rcBand.left) : \
311 (b->rcBand.bottom - b->rcBand.top))
313 /* The following define determines if a given band is hidden */
314 #define HIDDENBAND(a) (((a)->fStyle & RBBS_HIDDEN) || \
315 ((infoPtr->dwStyle & CCS_VERT) && \
316 ((a)->fStyle & RBBS_NOVERT)))
318 /* The following defines adjust the right or left end of a rectangle */
319 #define READJ(b,i) do { if(infoPtr->dwStyle & CCS_VERT) b->rcBand.bottom+=(i); \
320 else b->rcBand.right += (i); } while(0)
321 #define LEADJ(b,i) do { if(infoPtr->dwStyle & CCS_VERT) b->rcBand.top+=(i); \
322 else b->rcBand.left += (i); } while(0)
325 #define REBAR_GetInfoPtr(wndPtr) ((REBAR_INFO *)GetWindowLongA (hwnd, 0))
328 /* "constant values" retrieved when DLL was initialized */
329 /* FIXME we do this when the classes are registered. */
330 static UINT mindragx = 0;
331 static UINT mindragy = 0;
333 static char *band_stylename[] = {
334 "RBBS_BREAK", /* 0001 */
335 "RBBS_FIXEDSIZE", /* 0002 */
336 "RBBS_CHILDEDGE", /* 0004 */
337 "RBBS_HIDDEN", /* 0008 */
338 "RBBS_NOVERT", /* 0010 */
339 "RBBS_FIXEDBMP", /* 0020 */
340 "RBBS_VARIABLEHEIGHT", /* 0040 */
341 "RBBS_GRIPPERALWAYS", /* 0080 */
342 "RBBS_NOGRIPPER", /* 0100 */
345 static char *band_maskname[] = {
346 "RBBIM_STYLE", /* 0x00000001 */
347 "RBBIM_COLORS", /* 0x00000002 */
348 "RBBIM_TEXT", /* 0x00000004 */
349 "RBBIM_IMAGE", /* 0x00000008 */
350 "RBBIM_CHILD", /* 0x00000010 */
351 "RBBIM_CHILDSIZE", /* 0x00000020 */
352 "RBBIM_SIZE", /* 0x00000040 */
353 "RBBIM_BACKGROUND", /* 0x00000080 */
354 "RBBIM_ID", /* 0x00000100 */
355 "RBBIM_IDEALSIZE", /* 0x00000200 */
356 "RBBIM_LPARAM", /* 0x00000400 */
357 "RBBIM_HEADERSIZE", /* 0x00000800 */
361 static CHAR line[200];
365 REBAR_FmtStyle( UINT style)
370 while (band_stylename[i]) {
371 if (style & (1<<i)) {
372 if (*line != 0) strcat(line, " | ");
373 strcat(line, band_stylename[i]);
382 REBAR_FmtMask( UINT mask)
387 while (band_maskname[i]) {
389 if (*line != 0) strcat(line, " | ");
390 strcat(line, band_maskname[i]);
399 REBAR_DumpBandInfo( LPREBARBANDINFOA pB)
401 if( !TRACE_ON(rebar) ) return;
402 TRACE("band info: ID=%u, size=%u, child=%04x, clrF=0x%06lx, clrB=0x%06lx\n",
403 pB->wID, pB->cbSize, pB->hwndChild, pB->clrFore, pB->clrBack);
404 TRACE("band info: mask=0x%08x (%s)\n", pB->fMask, REBAR_FmtMask(pB->fMask));
405 if (pB->fMask & RBBIM_STYLE)
406 TRACE("band info: style=0x%08x (%s)\n", pB->fStyle, REBAR_FmtStyle(pB->fStyle));
407 if (pB->fMask & (RBBIM_SIZE | RBBIM_IDEALSIZE | RBBIM_HEADERSIZE | RBBIM_LPARAM )) {
409 if (pB->fMask & RBBIM_SIZE)
410 DPRINTF(" cx=%u", pB->cx);
411 if (pB->fMask & RBBIM_IDEALSIZE)
412 DPRINTF(" xIdeal=%u", pB->cxIdeal);
413 if (pB->fMask & RBBIM_HEADERSIZE)
414 DPRINTF(" xHeader=%u", pB->cxHeader);
415 if (pB->fMask & RBBIM_LPARAM)
416 DPRINTF(" lParam=0x%08lx", pB->lParam);
419 if (pB->fMask & RBBIM_CHILDSIZE)
420 TRACE("band info: xMin=%u, yMin=%u, yChild=%u, yMax=%u, yIntgl=%u\n",
422 pB->cyMinChild, pB->cyChild, pB->cyMaxChild, pB->cyIntegral);
426 REBAR_DumpBand (REBAR_INFO *iP)
431 if(! TRACE_ON(rebar) ) return;
433 TRACE("hwnd=%04x: color=%08lx/%08lx, bands=%u, rows=%u, cSize=%ld,%ld\n",
434 iP->hwndSelf, iP->clrText, iP->clrBk, iP->uNumBands, iP->uNumRows,
435 iP->calcSize.cx, iP->calcSize.cy);
436 TRACE("hwnd=%04x: flags=%08x, dragStart=%d,%d, dragNow=%d,%d, ihitBand=%d\n",
437 iP->hwndSelf, iP->fStatus, iP->dragStart.x, iP->dragStart.y,
438 iP->dragNow.x, iP->dragNow.y,
440 TRACE("hwnd=%04x: style=%08lx, I'm Unicode=%s, notify in Unicode=%s, redraw=%s\n",
441 iP->hwndSelf, iP->dwStyle, (iP->bUnicode)?"TRUE":"FALSE",
442 (iP->NtfUnicode)?"TRUE":"FALSE", (iP->DoRedraw)?"TRUE":"FALSE");
443 for (i = 0; i < iP->uNumBands; i++) {
445 TRACE("band # %u: ID=%u, child=%04x, row=%u, clrF=0x%06lx, clrB=0x%06lx\n",
446 i, pB->wID, pB->hwndChild, pB->iRow, pB->clrFore, pB->clrBack);
447 TRACE("band # %u: mask=0x%08x (%s)\n", i, pB->fMask, REBAR_FmtMask(pB->fMask));
448 if (pB->fMask & RBBIM_STYLE)
449 TRACE("band # %u: style=0x%08x (%s)\n",
450 i, pB->fStyle, REBAR_FmtStyle(pB->fStyle));
451 TRACE("band # %u: uMinH=%u xHeader=%u",
452 i, pB->uMinHeight, pB->cxHeader);
453 if (pB->fMask & (RBBIM_SIZE | RBBIM_IDEALSIZE | RBBIM_LPARAM )) {
454 if (pB->fMask & RBBIM_SIZE)
455 DPRINTF(" cx=%u", pB->cx);
456 if (pB->fMask & RBBIM_IDEALSIZE)
457 DPRINTF(" xIdeal=%u", pB->cxIdeal);
458 if (pB->fMask & RBBIM_LPARAM)
459 DPRINTF(" lParam=0x%08lx", pB->lParam);
463 TRACE("band # %u: xMin=%u, yMin=%u, yChild=%u, yMax=%u, yIntgl=%u\n",
464 i, pB->cxMinChild, pB->cyMinChild, pB->cyChild, pB->cyMaxChild, pB->cyIntegral);
465 if (pB->fMask & RBBIM_TEXT)
466 TRACE("band # %u: text=%s\n",
467 i, (pB->lpText) ? debugstr_w(pB->lpText) : "(null)");
468 TRACE("band # %u: lcx=%u, ccx=%u, hcx=%u, lcy=%u, ccy=%u, hcy=%u, offChild=%ld,%ld\n",
469 i, pB->lcx, pB->ccx, pB->hcx, pB->lcy, pB->ccy, pB->hcy, pB->offChild.cx, pB->offChild.cy);
470 TRACE("band # %u: fStatus=%08x, fDraw=%08x, Band=(%d,%d)-(%d,%d), Grip=(%d,%d)-(%d,%d)\n",
471 i, pB->fStatus, pB->fDraw,
472 pB->rcBand.left, pB->rcBand.top, pB->rcBand.right, pB->rcBand.bottom,
473 pB->rcGripper.left, pB->rcGripper.top, pB->rcGripper.right, pB->rcGripper.bottom);
474 TRACE("band # %u: Img=(%d,%d)-(%d,%d), Txt=(%d,%d)-(%d,%d), Child=(%d,%d)-(%d,%d)\n",
476 pB->rcCapImage.left, pB->rcCapImage.top, pB->rcCapImage.right, pB->rcCapImage.bottom,
477 pB->rcCapText.left, pB->rcCapText.top, pB->rcCapText.right, pB->rcCapText.bottom,
478 pB->rcChild.left, pB->rcChild.top, pB->rcChild.right, pB->rcChild.bottom);
485 REBAR_GetNotifyParent (REBAR_INFO *infoPtr)
489 parent = infoPtr->hwndNotify;
491 parent = GetParent (infoPtr->hwndSelf);
492 owner = GetWindow (infoPtr->hwndSelf, GW_OWNER);
493 if (owner) parent = owner;
500 REBAR_Notify (NMHDR *nmhdr, REBAR_INFO *infoPtr, UINT code)
504 parent = REBAR_GetNotifyParent (infoPtr);
505 nmhdr->idFrom = GetDlgCtrlID (infoPtr->hwndSelf);
506 nmhdr->hwndFrom = infoPtr->hwndSelf;
509 TRACE("window %04x, code=%08x, %s\n", parent, code,
510 (infoPtr->NtfUnicode) ? "via Unicode" : "via ANSI");
512 if (infoPtr->NtfUnicode)
513 return SendMessageW (parent, WM_NOTIFY, (WPARAM) nmhdr->idFrom,
516 return SendMessageA (parent, WM_NOTIFY, (WPARAM) nmhdr->idFrom,
521 REBAR_Notify_NMREBAR (REBAR_INFO *infoPtr, UINT uBand, UINT code)
523 NMREBAR notify_rebar;
526 notify_rebar.dwMask = 0;
528 lpBand = &infoPtr->bands[uBand];
529 if (lpBand->fMask & RBBIM_ID) {
530 notify_rebar.dwMask |= RBNM_ID;
531 notify_rebar.wID = lpBand->wID;
533 if (lpBand->fMask & RBBIM_LPARAM) {
534 notify_rebar.dwMask |= RBNM_LPARAM;
535 notify_rebar.lParam = lpBand->lParam;
537 if (lpBand->fMask & RBBIM_STYLE) {
538 notify_rebar.dwMask |= RBNM_STYLE;
539 notify_rebar.fStyle = lpBand->fStyle;
542 notify_rebar.uBand = uBand;
543 return REBAR_Notify ((NMHDR *)¬ify_rebar, infoPtr, code);
547 REBAR_DrawBand (HDC hdc, REBAR_INFO *infoPtr, REBAR_BAND *lpBand)
553 if (lpBand->fDraw & DRAW_TEXT) {
554 hOldFont = SelectObject (hdc, infoPtr->hFont);
555 oldBkMode = SetBkMode (hdc, TRANSPARENT);
558 /* should test for CDRF_NOTIFYITEMDRAW here */
559 nmcd.dwDrawStage = CDDS_ITEMPREPAINT;
561 nmcd.rc = lpBand->rcBand;
562 nmcd.rc.right = lpBand->rcCapText.right;
563 nmcd.rc.bottom = lpBand->rcCapText.bottom;
564 nmcd.dwItemSpec = lpBand->wID;
566 nmcd.lItemlParam = lpBand->lParam;
567 lpBand->uCDret = REBAR_Notify ((NMHDR *)&nmcd, infoPtr, NM_CUSTOMDRAW);
568 if (lpBand->uCDret == CDRF_SKIPDEFAULT) {
569 if (oldBkMode != TRANSPARENT)
570 SetBkMode (hdc, oldBkMode);
571 SelectObject (hdc, hOldFont);
576 if (lpBand->fDraw & DRAW_GRIPPER)
577 DrawEdge (hdc, &lpBand->rcGripper, BDR_RAISEDINNER, BF_RECT | BF_MIDDLE);
579 /* draw caption image */
580 if (lpBand->fDraw & DRAW_IMAGE) {
584 pt.y = (lpBand->rcCapImage.bottom + lpBand->rcCapImage.top - infoPtr->imageSize.cy)/2;
585 pt.x = (lpBand->rcCapImage.right + lpBand->rcCapImage.left - infoPtr->imageSize.cx)/2;
587 ImageList_Draw (infoPtr->himl, lpBand->iImage, hdc,
592 /* draw caption text */
593 if (lpBand->fDraw & DRAW_TEXT) {
594 /* need to handle CDRF_NEWFONT here */
595 INT oldBkMode = SetBkMode (hdc, TRANSPARENT);
596 COLORREF oldcolor = CLR_NONE;
598 if (lpBand->clrFore != CLR_NONE) {
599 new = (lpBand->clrFore == CLR_DEFAULT) ? infoPtr->clrBtnText :
601 oldcolor = SetTextColor (hdc, new);
603 DrawTextW (hdc, lpBand->lpText, -1, &lpBand->rcCapText,
604 DT_CENTER | DT_VCENTER | DT_SINGLELINE);
605 if (oldBkMode != TRANSPARENT)
606 SetBkMode (hdc, oldBkMode);
607 if (lpBand->clrFore != CLR_NONE)
608 SetTextColor (hdc, oldcolor);
609 SelectObject (hdc, hOldFont);
612 if (lpBand->uCDret == (CDRF_NOTIFYPOSTPAINT | CDRF_NOTIFYITEMDRAW)) {
613 nmcd.dwDrawStage = CDDS_ITEMPOSTPAINT;
615 nmcd.rc = lpBand->rcBand;
616 nmcd.rc.right = lpBand->rcCapText.right;
617 nmcd.rc.bottom = lpBand->rcCapText.bottom;
618 nmcd.dwItemSpec = lpBand->wID;
620 nmcd.lItemlParam = lpBand->lParam;
621 lpBand->uCDret = REBAR_Notify ((NMHDR *)&nmcd, infoPtr, NM_CUSTOMDRAW);
627 REBAR_Refresh (REBAR_INFO *infoPtr, HDC hdc)
632 if (!infoPtr->DoRedraw) return;
634 oldrow = infoPtr->bands[0].iRow;
635 for (i = 0; i < infoPtr->uNumBands; i++) {
636 lpBand = &infoPtr->bands[i];
638 if (HIDDENBAND(lpBand)) continue;
640 /* now draw the band */
641 TRACE("[%04x] drawing band %i, flags=%08x\n",
642 infoPtr->hwndSelf, i, lpBand->fDraw);
643 REBAR_DrawBand (hdc, infoPtr, lpBand);
650 REBAR_FixVert (REBAR_INFO *infoPtr, UINT rowstart, UINT rowend,
653 /* Cycle through bands in row and fix height of each band. */
654 /* Also determine whether each band has changed. */
656 /* all bands at desired size. */
657 /* start and end bands are *not* hidden */
662 for (i = (INT)rowstart; i<=(INT)rowend; i++) {
663 lpBand = &infoPtr->bands[i];
664 if (HIDDENBAND(lpBand)) continue;
666 /* adjust height of bands in row to "mcy" value */
667 if (infoPtr->dwStyle & CCS_VERT) {
668 if (lpBand->rcBand.right != lpBand->rcBand.left + mcy)
669 lpBand->rcBand.right = lpBand->rcBand.left + mcy;
672 if (lpBand->rcBand.bottom != lpBand->rcBand.top + mcy)
673 lpBand->rcBand.bottom = lpBand->rcBand.top + mcy;
677 /* mark whether we need to invalidate this band and trace */
678 if ((lpBand->rcoldBand.left !=lpBand->rcBand.left) ||
679 (lpBand->rcoldBand.top !=lpBand->rcBand.top) ||
680 (lpBand->rcoldBand.right !=lpBand->rcBand.right) ||
681 (lpBand->rcoldBand.bottom !=lpBand->rcBand.bottom)) {
682 lpBand->fDraw |= NTF_INVALIDATE;
683 TRACE("band %d row=%d: changed to (%d,%d)-(%d,%d) from (%d,%d)-(%d,%d)\n",
685 lpBand->rcBand.left, lpBand->rcBand.top,
686 lpBand->rcBand.right, lpBand->rcBand.bottom,
687 lpBand->rcoldBand.left, lpBand->rcoldBand.top,
688 lpBand->rcoldBand.right, lpBand->rcoldBand.bottom);
691 TRACE("band %d row=%d: unchanged (%d,%d)-(%d,%d)\n",
693 lpBand->rcBand.left, lpBand->rcBand.top,
694 lpBand->rcBand.right, lpBand->rcBand.bottom);
700 REBAR_AdjustBands (REBAR_INFO *infoPtr, UINT rowstart, UINT rowend,
702 /* Function: This routine distributes the extra space in a row. */
703 /* See algorithm below. */
705 /* all bands @ ->cxHeader size */
706 /* start and end bands are *not* hidden */
709 UINT x, xsep, extra, curwidth, fudge;
710 INT i, last_adjusted;
712 TRACE("start=%u, end=%u, max x=%d, max y=%d\n",
713 rowstart, rowend, maxx, mcy);
715 /* ******************* Phase 1 ************************ */
717 /* For each visible band with valid child */
718 /* a. inflate band till either all extra space used */
719 /* or band's ->ccx reached. */
720 /* If any band modified, add any space left to last band */
723 /* ****************************************************** */
724 lpBand = &infoPtr->bands[rowend];
725 extra = maxx - rcBrb(lpBand);
728 for (i=(INT)rowstart; i<=(INT)rowend; i++) {
729 lpBand = &infoPtr->bands[i];
730 if (HIDDENBAND(lpBand)) continue;
731 xsep = (x == 0) ? 0 : SEP_WIDTH;
732 curwidth = rcBw(lpBand);
734 /* set new left/top point */
735 if (infoPtr->dwStyle & CCS_VERT)
736 lpBand->rcBand.top = x + xsep;
738 lpBand->rcBand.left = x + xsep;
740 /* compute new width */
741 if ((lpBand->hwndChild && extra) && !(lpBand->fStyle & RBBS_FIXEDSIZE)) {
742 /* set to the "current" band size less the header */
745 if ((lpBand->fMask & RBBIM_SIZE) && (lpBand->cx > 0) &&
746 (fudge > curwidth)) {
747 TRACE("adjusting band %d by %d, fudge=%d, curwidth=%d, extra=%d\n",
748 i, fudge-curwidth, fudge, curwidth, extra);
749 if ((fudge - curwidth) > extra)
750 fudge = curwidth + extra;
751 extra -= (fudge - curwidth);
755 TRACE("adjusting band %d by %d, fudge=%d, curwidth=%d\n",
756 i, extra, fudge, curwidth);
762 /* set new right/bottom point */
763 if (infoPtr->dwStyle & CCS_VERT)
764 lpBand->rcBand.bottom = lpBand->rcBand.top + curwidth;
766 lpBand->rcBand.right = lpBand->rcBand.left + curwidth;
767 TRACE("Phase 1 band %d, (%d,%d)-(%d,%d), orig x=%d, xsep=%d\n",
768 i, lpBand->rcBand.left, lpBand->rcBand.top,
769 lpBand->rcBand.right, lpBand->rcBand.bottom, x, xsep);
772 if ((x >= maxx) || (last_adjusted != -1)) {
774 ERR("Phase 1 failed, x=%d, maxx=%d, start=%u, end=%u\n",
775 x, maxx, rowstart, rowend);
777 /* done, so spread extra space */
780 TRACE("Need to spread %d on last adjusted band %d\n",
781 fudge, last_adjusted);
782 for (i=(INT)last_adjusted; i<=(INT)rowend; i++) {
783 lpBand = &infoPtr->bands[i];
784 if (HIDDENBAND(lpBand)) continue;
786 /* set right/bottom point */
787 if (i != last_adjusted) {
788 if (infoPtr->dwStyle & CCS_VERT)
789 lpBand->rcBand.top += fudge;
791 lpBand->rcBand.left += fudge;
794 /* set left/bottom point */
795 if (infoPtr->dwStyle & CCS_VERT)
796 lpBand->rcBand.bottom += fudge;
798 lpBand->rcBand.right += fudge;
801 TRACE("Phase 1 succeeded, used x=%d\n", x);
802 REBAR_FixVert (infoPtr, rowstart, rowend, mcy);
806 /* ******************* Phase 2 ************************ */
808 /* Find first visible band, put all */
809 /* extra space there. */
811 /* ****************************************************** */
814 for (i=(INT)rowstart; i<=(INT)rowend; i++) {
815 lpBand = &infoPtr->bands[i];
816 if (HIDDENBAND(lpBand)) continue;
817 xsep = (x == 0) ? 0 : SEP_WIDTH;
818 curwidth = rcBw(lpBand);
820 /* set new left/top point */
821 if (infoPtr->dwStyle & CCS_VERT)
822 lpBand->rcBand.top = x + xsep;
824 lpBand->rcBand.left = x + xsep;
826 /* compute new width */
832 /* set new right/bottom point */
833 if (infoPtr->dwStyle & CCS_VERT)
834 lpBand->rcBand.bottom = lpBand->rcBand.top + curwidth;
836 lpBand->rcBand.right = lpBand->rcBand.left + curwidth;
837 TRACE("Phase 2 band %d, (%d,%d)-(%d,%d), orig x=%d, xsep=%d\n",
838 i, lpBand->rcBand.left, lpBand->rcBand.top,
839 lpBand->rcBand.right, lpBand->rcBand.bottom, x, xsep);
844 ERR("Phase 2 failed, x=%d, maxx=%d, start=%u, end=%u\n",
845 x, maxx, rowstart, rowend);
847 /* done, so spread extra space */
848 TRACE("Phase 2 succeeded, used x=%d\n", x);
849 REBAR_FixVert (infoPtr, rowstart, rowend, mcy);
853 /* ******************* Phase 3 ************************ */
854 /* at this point everything is back to ->cxHeader values */
855 /* and should not have gotten here. */
856 /* ****************************************************** */
858 lpBand = &infoPtr->bands[rowstart];
859 ERR("Serious problem adjusting row %d, start band %d, end band %d\n",
860 lpBand->iRow, rowstart, rowend);
861 REBAR_DumpBand (infoPtr);
867 REBAR_CalcHorzBand (REBAR_INFO *infoPtr, UINT rstart, UINT rend, BOOL notify)
868 /* Function: this routine initializes all the rectangles in */
869 /* each band in a row to fit in the adjusted rcBand rect. */
870 /* *** Supports only Horizontal bars. *** */
877 /* MS seems to use GetDlgCtrlID() for above GetWindowLong call */
878 parenthwnd = GetParent (infoPtr->hwndSelf);
880 for(i=rstart; i<rend; i++){
881 lpBand = &infoPtr->bands[i];
882 if (HIDDENBAND(lpBand)) {
883 SetRect (&lpBand->rcChild,
884 lpBand->rcBand.right, lpBand->rcBand.top,
885 lpBand->rcBand.right, lpBand->rcBand.bottom);
889 oldChild = lpBand->rcChild;
891 /* set initial gripper rectangle */
892 SetRect (&lpBand->rcGripper, lpBand->rcBand.left, lpBand->rcBand.top,
893 lpBand->rcBand.left, lpBand->rcBand.bottom);
895 /* calculate gripper rectangle */
896 if ( lpBand->fStatus & HAS_GRIPPER) {
897 lpBand->fDraw |= DRAW_GRIPPER;
898 lpBand->rcGripper.left += REBAR_PRE_GRIPPER;
899 lpBand->rcGripper.right = lpBand->rcGripper.left + GRIPPER_WIDTH;
900 lpBand->rcGripper.top += 2;
901 lpBand->rcGripper.bottom -= 2;
903 SetRect (&lpBand->rcCapImage,
904 lpBand->rcGripper.right+REBAR_ALWAYS_SPACE, lpBand->rcBand.top,
905 lpBand->rcGripper.right+REBAR_ALWAYS_SPACE, lpBand->rcBand.bottom);
907 else { /* no gripper will be drawn */
909 if (lpBand->fStatus & (HAS_IMAGE | HAS_TEXT))
910 /* if no gripper but either image or text, then leave space */
911 xoff = REBAR_ALWAYS_SPACE;
912 SetRect (&lpBand->rcCapImage,
913 lpBand->rcBand.left+xoff, lpBand->rcBand.top,
914 lpBand->rcBand.left+xoff, lpBand->rcBand.bottom);
917 /* image is visible */
918 if (lpBand->fStatus & HAS_IMAGE) {
919 lpBand->fDraw |= DRAW_IMAGE;
920 lpBand->rcCapImage.right += infoPtr->imageSize.cx;
921 lpBand->rcCapImage.bottom = lpBand->rcCapImage.top + infoPtr->imageSize.cy;
923 /* set initial caption text rectangle */
924 SetRect (&lpBand->rcCapText,
925 lpBand->rcCapImage.right+REBAR_POST_IMAGE, lpBand->rcBand.top+1,
926 lpBand->rcBand.left+lpBand->cxHeader, lpBand->rcBand.bottom-1);
927 /* update band height
928 if (lpBand->uMinHeight < infoPtr->imageSize.cy + 2) {
929 lpBand->uMinHeight = infoPtr->imageSize.cy + 2;
930 lpBand->rcBand.bottom = lpBand->rcBand.top + lpBand->uMinHeight;
934 /* set initial caption text rectangle */
935 SetRect (&lpBand->rcCapText, lpBand->rcCapImage.right, lpBand->rcBand.top+1,
936 lpBand->rcBand.left+lpBand->cxHeader, lpBand->rcBand.bottom-1);
939 /* text is visible */
940 if (lpBand->fStatus & HAS_TEXT) {
941 lpBand->fDraw |= DRAW_TEXT;
942 lpBand->rcCapText.right = max(lpBand->rcCapText.left,
943 lpBand->rcCapText.right-REBAR_POST_TEXT);
946 /* set initial child window rectangle if there is a child */
947 if (lpBand->fMask & RBBIM_CHILD) {
948 xoff = lpBand->offChild.cx;
949 yoff = lpBand->offChild.cy;
950 SetRect (&lpBand->rcChild,
951 lpBand->rcBand.left+lpBand->cxHeader, lpBand->rcBand.top+yoff,
952 lpBand->rcBand.right-xoff, lpBand->rcBand.bottom-yoff);
955 SetRect (&lpBand->rcChild,
956 lpBand->rcBand.left+lpBand->cxHeader, lpBand->rcBand.top,
957 lpBand->rcBand.right, lpBand->rcBand.bottom);
960 /* flag if notify required and invalidate rectangle */
962 ((oldChild.right-oldChild.left != lpBand->rcChild.right-lpBand->rcChild.left) ||
963 (oldChild.bottom-oldChild.top != lpBand->rcChild.bottom-lpBand->rcChild.top))) {
964 TRACE("Child rectangle changed for band %u\n", i);
965 TRACE(" from (%d,%d)-(%d,%d) to (%d,%d)-(%d,%d)\n",
966 oldChild.left, oldChild.top,
967 oldChild.right, oldChild.bottom,
968 lpBand->rcChild.left, lpBand->rcChild.top,
969 lpBand->rcChild.right, lpBand->rcChild.bottom);
971 if (lpBand->fDraw & NTF_INVALIDATE) {
972 TRACE("invalidating (%d,%d)-(%d,%d)\n",
975 lpBand->rcBand.right + ((lpBand->fDraw & DRAW_RIGHTSEP) ? SEP_WIDTH_SIZE : 0),
976 lpBand->rcBand.bottom + ((lpBand->fDraw & DRAW_BOTTOMSEP) ? SEP_WIDTH_SIZE : 0));
977 lpBand->fDraw &= ~NTF_INVALIDATE;
978 work = lpBand->rcBand;
979 if (lpBand->fDraw & DRAW_RIGHTSEP) work.right += SEP_WIDTH_SIZE;
980 if (lpBand->fDraw & DRAW_BOTTOMSEP) work.bottom += SEP_WIDTH_SIZE;
981 InvalidateRect(infoPtr->hwndSelf, &work, TRUE);
990 REBAR_CalcVertBand (REBAR_INFO *infoPtr, UINT rstart, UINT rend, BOOL notify)
991 /* Function: this routine initializes all the rectangles in */
992 /* each band in a row to fit in the adjusted rcBand rect. */
993 /* *** Supports only Vertical bars. *** */
1000 /* MS seems to use GetDlgCtrlID() for above GetWindowLong call */
1001 parenthwnd = GetParent (infoPtr->hwndSelf);
1003 for(i=rstart; i<rend; i++){
1004 lpBand = &infoPtr->bands[i];
1005 if (HIDDENBAND(lpBand)) continue;
1006 oldChild = lpBand->rcChild;
1008 /* set initial gripper rectangle */
1009 SetRect (&lpBand->rcGripper, lpBand->rcBand.left, lpBand->rcBand.top,
1010 lpBand->rcBand.right, lpBand->rcBand.top);
1012 /* calculate gripper rectangle */
1013 if (lpBand->fStatus & HAS_GRIPPER) {
1014 lpBand->fDraw |= DRAW_GRIPPER;
1016 if (infoPtr->dwStyle & RBS_VERTICALGRIPPER) {
1017 /* vertical gripper */
1018 lpBand->rcGripper.left += 3;
1019 lpBand->rcGripper.right = lpBand->rcGripper.left + GRIPPER_WIDTH;
1020 lpBand->rcGripper.top += REBAR_PRE_GRIPPER;
1021 lpBand->rcGripper.bottom = lpBand->rcGripper.top + GRIPPER_HEIGHT;
1023 /* initialize Caption image rectangle */
1024 SetRect (&lpBand->rcCapImage, lpBand->rcBand.left,
1025 lpBand->rcGripper.bottom + REBAR_ALWAYS_SPACE,
1026 lpBand->rcBand.right,
1027 lpBand->rcGripper.bottom + REBAR_ALWAYS_SPACE);
1030 /* horizontal gripper */
1031 lpBand->rcGripper.left += 2;
1032 lpBand->rcGripper.right -= 2;
1033 lpBand->rcGripper.top += REBAR_PRE_GRIPPER;
1034 lpBand->rcGripper.bottom = lpBand->rcGripper.top + GRIPPER_WIDTH;
1036 /* initialize Caption image rectangle */
1037 SetRect (&lpBand->rcCapImage, lpBand->rcBand.left,
1038 lpBand->rcGripper.bottom + REBAR_ALWAYS_SPACE,
1039 lpBand->rcBand.right,
1040 lpBand->rcGripper.bottom + REBAR_ALWAYS_SPACE);
1043 else { /* no gripper will be drawn */
1045 if (lpBand->fStatus & (HAS_IMAGE | HAS_TEXT))
1046 /* if no gripper but either image or text, then leave space */
1047 xoff = REBAR_ALWAYS_SPACE;
1048 /* initialize Caption image rectangle */
1049 SetRect (&lpBand->rcCapImage,
1050 lpBand->rcBand.left, lpBand->rcBand.top+xoff,
1051 lpBand->rcBand.right, lpBand->rcBand.top+xoff);
1054 /* image is visible */
1055 if (lpBand->fStatus & HAS_IMAGE) {
1056 lpBand->fDraw |= DRAW_IMAGE;
1058 lpBand->rcCapImage.right = lpBand->rcCapImage.left + infoPtr->imageSize.cx;
1059 lpBand->rcCapImage.bottom += infoPtr->imageSize.cy;
1061 /* set initial caption text rectangle */
1062 SetRect (&lpBand->rcCapText,
1063 lpBand->rcBand.left, lpBand->rcCapImage.bottom+REBAR_POST_IMAGE,
1064 lpBand->rcBand.right, lpBand->rcBand.top+lpBand->cxHeader);
1065 /* update band height *
1066 if (lpBand->uMinHeight < infoPtr->imageSize.cx + 2) {
1067 lpBand->uMinHeight = infoPtr->imageSize.cx + 2;
1068 lpBand->rcBand.right = lpBand->rcBand.left + lpBand->uMinHeight;
1072 /* set initial caption text rectangle */
1073 SetRect (&lpBand->rcCapText,
1074 lpBand->rcBand.left, lpBand->rcCapImage.bottom,
1075 lpBand->rcBand.right, lpBand->rcBand.top+lpBand->cxHeader);
1078 /* text is visible */
1079 if (lpBand->fStatus & HAS_TEXT) {
1080 lpBand->fDraw |= DRAW_TEXT;
1081 lpBand->rcCapText.bottom = max(lpBand->rcCapText.top,
1082 lpBand->rcCapText.bottom);
1085 /* set initial child window rectangle if there is a child */
1086 if (lpBand->fMask & RBBIM_CHILD) {
1087 yoff = lpBand->offChild.cx;
1088 xoff = lpBand->offChild.cy;
1089 SetRect (&lpBand->rcChild,
1090 lpBand->rcBand.left+xoff, lpBand->rcBand.top+lpBand->cxHeader,
1091 lpBand->rcBand.right-xoff, lpBand->rcBand.bottom-yoff);
1094 SetRect (&lpBand->rcChild,
1095 lpBand->rcBand.left, lpBand->rcBand.top+lpBand->cxHeader,
1096 lpBand->rcBand.right, lpBand->rcBand.bottom);
1099 /* flag if notify required and invalidate rectangle */
1101 ((oldChild.right-oldChild.left != lpBand->rcChild.right-lpBand->rcChild.left) ||
1102 (oldChild.bottom-oldChild.top != lpBand->rcChild.bottom-lpBand->rcChild.top))) {
1103 TRACE("Child rectangle changed for band %u\n", i);
1104 TRACE(" from (%d,%d)-(%d,%d) to (%d,%d)-(%d,%d)\n",
1105 oldChild.left, oldChild.top,
1106 oldChild.right, oldChild.bottom,
1107 lpBand->rcChild.left, lpBand->rcChild.top,
1108 lpBand->rcChild.right, lpBand->rcChild.bottom);
1110 if (lpBand->fDraw & NTF_INVALIDATE) {
1111 TRACE("invalidating (%d,%d)-(%d,%d)\n",
1112 lpBand->rcBand.left,
1114 lpBand->rcBand.right + ((lpBand->fDraw & DRAW_BOTTOMSEP) ? SEP_WIDTH_SIZE : 0),
1115 lpBand->rcBand.bottom + ((lpBand->fDraw & DRAW_RIGHTSEP) ? SEP_WIDTH_SIZE : 0));
1116 lpBand->fDraw &= ~NTF_INVALIDATE;
1117 work = lpBand->rcBand;
1118 if (lpBand->fDraw & DRAW_RIGHTSEP) work.bottom += SEP_WIDTH_SIZE;
1119 if (lpBand->fDraw & DRAW_BOTTOMSEP) work.right += SEP_WIDTH_SIZE;
1120 InvalidateRect(infoPtr->hwndSelf, &work, TRUE);
1128 REBAR_ForceResize (REBAR_INFO *infoPtr)
1129 /* Function: This changes the size of the REBAR window to that */
1130 /* calculated by REBAR_Layout. */
1133 INT x, y, width, height;
1134 INT xedge = GetSystemMetrics(SM_CXEDGE);
1135 INT yedge = GetSystemMetrics(SM_CYEDGE);
1137 /* TEST TEST TEST */
1138 GetWindowRect (infoPtr->hwndSelf, &rc);
1139 /* END TEST END TEST END TEST */
1142 GetClientRect (infoPtr->hwndSelf, &rc);
1144 TRACE( " old [%ld x %ld], new [%ld x %ld], client [%d x %d]\n",
1145 infoPtr->oldSize.cx, infoPtr->oldSize.cy,
1146 infoPtr->calcSize.cx, infoPtr->calcSize.cy,
1147 rc.right, rc.bottom);
1149 /* If we need to shrink client, then skip size test */
1150 if ((infoPtr->calcSize.cy >= rc.bottom) &&
1151 (infoPtr->calcSize.cx >= rc.right)) {
1153 /* if size did not change then skip process */
1154 if ((infoPtr->oldSize.cx == infoPtr->calcSize.cx) &&
1155 (infoPtr->oldSize.cy == infoPtr->calcSize.cy) &&
1156 !(infoPtr->fStatus & RESIZE_ANYHOW))
1158 TRACE("skipping reset\n");
1163 infoPtr->fStatus &= ~RESIZE_ANYHOW;
1164 /* Set flag to ignore next WM_SIZE message */
1165 infoPtr->fStatus |= AUTO_RESIZE;
1172 if (infoPtr->dwStyle & WS_BORDER) {
1177 if (!(infoPtr->dwStyle & CCS_NOPARENTALIGN)) {
1178 INT mode = infoPtr->dwStyle & (CCS_VERT | CCS_TOP | CCS_BOTTOM);
1181 GetClientRect(GetParent(infoPtr->hwndSelf), &rcPcl);
1184 /* _TOP sets width to parents width */
1185 width += (rcPcl.right - rcPcl.left);
1186 height += infoPtr->calcSize.cy;
1187 x += ((infoPtr->dwStyle & WS_BORDER) ? -xedge : 0);
1188 y += ((infoPtr->dwStyle & WS_BORDER) ? -yedge : 0);
1189 y += ((infoPtr->dwStyle & CCS_NODIVIDER) ? 0 : REBAR_DIVIDER);
1192 /* FIXME: wrong wrong wrong */
1193 /* _BOTTOM sets width to parents width */
1194 width += (rcPcl.right - rcPcl.left);
1195 height += infoPtr->calcSize.cy;
1197 y = rcPcl.bottom - height + 1;
1200 /* _LEFT sets height to parents height */
1201 width += infoPtr->calcSize.cx;
1202 height += (rcPcl.bottom - rcPcl.top);
1203 x += ((infoPtr->dwStyle & WS_BORDER) ? -xedge : 0);
1204 x += ((infoPtr->dwStyle & CCS_NODIVIDER) ? 0 : REBAR_DIVIDER);
1205 y += ((infoPtr->dwStyle & WS_BORDER) ? -yedge : 0);
1208 /* FIXME: wrong wrong wrong */
1209 /* _RIGHT sets height to parents height */
1210 width += infoPtr->calcSize.cx;
1211 height += (rcPcl.bottom - rcPcl.top);
1212 x = rcPcl.right - width + 1;
1216 width += infoPtr->calcSize.cx;
1217 height += infoPtr->calcSize.cy;
1221 width += infoPtr->calcSize.cx;
1222 height += infoPtr->calcSize.cy;
1223 x = infoPtr->origin.x;
1224 y = infoPtr->origin.y;
1227 TRACE("hwnd %08x, style=%08lx, setting at (%d,%d) for (%d,%d)\n",
1228 infoPtr->hwndSelf, infoPtr->dwStyle,
1229 x, y, width, height);
1230 SetWindowPos (infoPtr->hwndSelf, 0, x, y, width, height,
1236 REBAR_MoveChildWindows (REBAR_INFO *infoPtr, UINT start, UINT endplus)
1239 CHAR szClassName[40];
1241 NMREBARCHILDSIZE rbcz;
1245 if (!(deferpos = BeginDeferWindowPos(infoPtr->uNumBands)))
1246 ERR("BeginDeferWindowPos returned NULL\n");
1248 for (i = start; i < endplus; i++) {
1249 lpBand = &infoPtr->bands[i];
1251 if (HIDDENBAND(lpBand)) continue;
1252 if (lpBand->hwndChild) {
1253 TRACE("hwndChild = %x\n", lpBand->hwndChild);
1255 /* Always geterate the RBN_CHILDSIZE even it child
1258 rbcz.wID = lpBand->wID;
1259 rbcz.rcChild = lpBand->rcChild;
1260 rbcz.rcBand = lpBand->rcBand;
1261 if (infoPtr->dwStyle & CCS_VERT)
1262 rbcz.rcBand.top += lpBand->cxHeader;
1264 rbcz.rcBand.left += lpBand->cxHeader;
1265 REBAR_Notify ((NMHDR *)&rbcz, infoPtr, RBN_CHILDSIZE);
1266 if (!EqualRect (&lpBand->rcChild, &rbcz.rcChild)) {
1267 TRACE("Child rect changed by NOTIFY for band %u\n", i);
1268 TRACE(" from (%d,%d)-(%d,%d) to (%d,%d)-(%d,%d)\n",
1269 lpBand->rcChild.left, lpBand->rcChild.top,
1270 lpBand->rcChild.right, lpBand->rcChild.bottom,
1271 rbcz.rcChild.left, rbcz.rcChild.top,
1272 rbcz.rcChild.right, rbcz.rcChild.bottom);
1273 lpBand->rcChild = rbcz.rcChild; /* *** ??? */
1276 /* native (IE4 in "Favorites" frame **1) does:
1277 * SetRect (&rc, -1, -1, -1, -1)
1278 * EqualRect (&rc,band->rc???)
1280 * CopyRect (band->rc????, &rc)
1281 * set flag outside of loop
1284 GetClassNameA (lpBand->hwndChild, szClassName, 40);
1285 if (!lstrcmpA (szClassName, "ComboBox") ||
1286 !lstrcmpA (szClassName, WC_COMBOBOXEXA)) {
1287 INT nEditHeight, yPos;
1290 /* special placement code for combo or comboex box */
1293 /* get size of edit line */
1294 GetWindowRect (lpBand->hwndChild, &rc);
1295 nEditHeight = rc.bottom - rc.top;
1296 yPos = (lpBand->rcChild.bottom + lpBand->rcChild.top - nEditHeight)/2;
1298 /* center combo box inside child area */
1299 TRACE("moving child (Combo(Ex)) %04x to (%d,%d) for (%d,%d)\n",
1301 lpBand->rcChild.left, yPos,
1302 lpBand->rcChild.right - lpBand->rcChild.left,
1304 deferpos = DeferWindowPos (deferpos, lpBand->hwndChild, HWND_TOP,
1305 lpBand->rcChild.left,
1306 /*lpBand->rcChild.top*/ yPos,
1307 lpBand->rcChild.right - lpBand->rcChild.left,
1311 ERR("DeferWindowPos returned NULL\n");
1314 TRACE("moving child (Other) %04x to (%d,%d) for (%d,%d)\n",
1316 lpBand->rcChild.left, lpBand->rcChild.top,
1317 lpBand->rcChild.right - lpBand->rcChild.left,
1318 lpBand->rcChild.bottom - lpBand->rcChild.top);
1319 deferpos = DeferWindowPos (deferpos, lpBand->hwndChild, HWND_TOP,
1320 lpBand->rcChild.left,
1321 lpBand->rcChild.top,
1322 lpBand->rcChild.right - lpBand->rcChild.left,
1323 lpBand->rcChild.bottom - lpBand->rcChild.top,
1326 ERR("DeferWindowPos returned NULL\n");
1330 if (!EndDeferWindowPos(deferpos))
1331 ERR("EndDeferWindowPos returned NULL\n");
1333 if (infoPtr->DoRedraw)
1334 UpdateWindow (infoPtr->hwndSelf);
1336 if (infoPtr->fStatus & NTF_HGHTCHG) {
1337 infoPtr->fStatus &= ~NTF_HGHTCHG;
1338 REBAR_Notify (&heightchange, infoPtr, RBN_HEIGHTCHANGE);
1341 /* native (from **1 above) does:
1342 * UpdateWindow(rebar)
1344 * RBN_HEIGHTCHANGE if necessary
1345 * if ret from any EqualRect was 0
1346 * Goto "BeginDeferWindowPos"
1353 REBAR_Layout (REBAR_INFO *infoPtr, LPRECT lpRect, BOOL notify, BOOL resetclient)
1354 /* Function: This routine is resposible for laying out all */
1355 /* the bands in a rebar. It assigns each band to a row and*/
1356 /* determines when to start a new row. */
1358 REBAR_BAND *lpBand, *prevBand;
1359 RECT rcClient, rcAdj;
1360 INT initx, inity, x, y, cx, cxsep, mmcy, mcy, clientcx, clientcy;
1361 INT adjcx, adjcy, row, rightx, bottomy, origheight;
1362 UINT i, j, rowstart, origrows, cntonrow;
1365 if (!(infoPtr->fStatus & BAND_NEEDS_LAYOUT)) {
1366 TRACE("no layout done. No band changed.\n");
1367 REBAR_DumpBand (infoPtr);
1370 infoPtr->fStatus &= ~BAND_NEEDS_LAYOUT;
1371 if (!infoPtr->DoRedraw) infoPtr->fStatus |= BAND_NEEDS_REDRAW;
1373 GetClientRect (infoPtr->hwndSelf, &rcClient);
1374 TRACE("Client is (%d,%d)-(%d,%d)\n",
1375 rcClient.left, rcClient.top, rcClient.right, rcClient.bottom);
1379 TRACE("adjustment rect is (%d,%d)-(%d,%d)\n",
1380 rcAdj.left, rcAdj.top, rcAdj.right, rcAdj.bottom);
1383 CopyRect (&rcAdj, &rcClient);
1386 clientcx = rcClient.right - rcClient.left;
1387 clientcy = rcClient.bottom - rcClient.top;
1388 adjcx = rcAdj.right - rcAdj.left;
1389 adjcy = rcAdj.bottom - rcAdj.top;
1391 TRACE("window client rect will be set to adj rect\n");
1396 if (!infoPtr->DoRedraw && (clientcx == 0) && (clientcy == 0)) {
1397 ERR("no redraw and client is zero, skip layout\n");
1398 infoPtr->fStatus |= BAND_NEEDS_LAYOUT;
1402 /* save height of original control */
1403 if (infoPtr->dwStyle & CCS_VERT)
1404 origheight = infoPtr->calcSize.cx;
1406 origheight = infoPtr->calcSize.cy;
1407 origrows = infoPtr->uNumRows;
1412 /* ******* Start Phase 1 - all bands on row at minimum size ******* */
1414 TRACE("band loop constants, clientcx=%d, clientcy=%d, adjcx=%d, adjcy=%d\n",
1415 clientcx, clientcy, adjcx, adjcy);
1425 for (i = 0; i < infoPtr->uNumBands; i++) {
1426 lpBand = &infoPtr->bands[i];
1430 if (HIDDENBAND(lpBand)) continue;
1432 lpBand->rcoldBand = lpBand->rcBand;
1434 /* Set the offset of the child window */
1435 if ((lpBand->fMask & RBBIM_CHILD) &&
1436 !(lpBand->fStyle & RBBS_FIXEDSIZE)) {
1437 lpBand->offChild.cx = ((lpBand->fStyle & RBBS_CHILDEDGE) ? 4 : 0);
1439 lpBand->offChild.cy = ((lpBand->fStyle & RBBS_CHILDEDGE) ? 2 : 0);
1441 /* separator from previous band */
1442 cxsep = (cntonrow == 0) ? 0 : SEP_WIDTH;
1444 /* Header: includes gripper, text, image */
1445 cx = lpBand->cxHeader;
1446 if (lpBand->fStyle & RBBS_FIXEDSIZE) cx = lpBand->lcx;
1448 if (infoPtr->dwStyle & CCS_VERT)
1449 dobreak = (y + cx + cxsep > adjcy);
1451 dobreak = (x + cx + cxsep > adjcx);
1453 /* This is the check for whether we need to start a new row */
1454 if ( ( (lpBand->fStyle & RBBS_BREAK) && (i != 0) ) ||
1455 ( ((infoPtr->dwStyle & CCS_VERT) ? (y != 0) : (x != 0)) && dobreak)) {
1457 for (j = rowstart; j < i; j++) {
1459 lpB = &infoPtr->bands[j];
1460 if (infoPtr->dwStyle & CCS_VERT) {
1461 lpB->rcBand.right = lpB->rcBand.left + mcy;
1464 lpB->rcBand.bottom = lpB->rcBand.top + mcy;
1468 TRACE("P1 Spliting to new row %d on band %u\n", row+1, i);
1469 if (infoPtr->dwStyle & CCS_VERT) {
1471 x += (mcy + SEP_WIDTH);
1475 y += (mcy + SEP_WIDTH);
1487 if (mcy < lpBand->lcy + REBARSPACE(lpBand))
1488 mcy = lpBand->lcy + REBARSPACE(lpBand);
1490 /* if boundary rect specified then limit mcy */
1492 if (infoPtr->dwStyle & CCS_VERT) {
1493 if (x+mcy > adjcx) {
1495 TRACE("P1 row %u limiting mcy=%d, adjcx=%d, x=%d\n",
1500 if (y+mcy > adjcy) {
1502 TRACE("P1 row %u limiting mcy=%d, adjcy=%d, y=%d\n",
1508 TRACE("P1 band %u, row %d, x=%d, y=%d, cxsep=%d, cx=%d\n",
1511 if (infoPtr->dwStyle & CCS_VERT) {
1512 /* bound the bottom side if we have a bounding rectangle */
1514 bottomy = (lpRect) ? min(clientcy, y+cxsep+cx) : y+cxsep+cx;
1515 lpBand->rcBand.left = x;
1516 lpBand->rcBand.right = x + min(mcy,
1517 lpBand->lcy+REBARSPACE(lpBand));
1518 lpBand->rcBand.top = min(bottomy, y + cxsep);
1519 lpBand->rcBand.bottom = bottomy;
1520 lpBand->uMinHeight = lpBand->lcy;
1524 /* bound the right side if we have a bounding rectangle */
1525 rightx = (lpRect) ? min(clientcx, x+cxsep+cx) : x+cxsep+cx;
1527 lpBand->rcBand.left = min(rightx, x + cxsep);
1528 lpBand->rcBand.right = rightx;
1529 lpBand->rcBand.top = y;
1530 lpBand->rcBand.bottom = y + min(mcy,
1531 lpBand->lcy+REBARSPACE(lpBand));
1532 lpBand->uMinHeight = lpBand->lcy;
1535 TRACE("P1 band %u, row %d, (%d,%d)-(%d,%d)\n",
1537 lpBand->rcBand.left, lpBand->rcBand.top,
1538 lpBand->rcBand.right, lpBand->rcBand.bottom);
1542 } /* for (i = 0; i < infoPtr->uNumBands... */
1544 if (infoPtr->dwStyle & CCS_VERT)
1549 for (j = rowstart; j < infoPtr->uNumBands; j++) {
1550 lpBand = &infoPtr->bands[j];
1551 if (infoPtr->dwStyle & CCS_VERT) {
1552 lpBand->rcBand.right = lpBand->rcBand.left + mcy;
1555 lpBand->rcBand.bottom = lpBand->rcBand.top + mcy;
1559 if (infoPtr->uNumBands)
1560 infoPtr->uNumRows = row;
1562 /* ******* End Phase 1 - all bands on row at minimum size ******* */
1565 /* ******* Start Phase 1a - Adjust heights for RBS_VARHEIGHT off ******* */
1568 if (!(infoPtr->dwStyle & RBS_VARHEIGHT)) {
1571 /* get the max height of all bands */
1572 for (i=0; i<infoPtr->uNumBands; i++) {
1573 lpBand = &infoPtr->bands[i];
1574 if (HIDDENBAND(lpBand)) continue;
1575 if (infoPtr->dwStyle & CCS_VERT)
1576 mmcy = max(mmcy, lpBand->rcBand.right - lpBand->rcBand.left);
1578 mmcy = max(mmcy, lpBand->rcBand.bottom - lpBand->rcBand.top);
1581 /* now adjust all rectangles by using the height found above */
1584 for (i=0; i<infoPtr->uNumBands; i++) {
1585 lpBand = &infoPtr->bands[i];
1586 if (HIDDENBAND(lpBand)) continue;
1587 if (lpBand->iRow != row)
1588 xy += (mmcy + SEP_WIDTH);
1589 if (infoPtr->dwStyle & CCS_VERT) {
1590 lpBand->rcBand.left = xy;
1591 lpBand->rcBand.right = xy + mmcy;
1594 lpBand->rcBand.top = xy;
1595 lpBand->rcBand.bottom = xy + mmcy;
1599 /* set the x/y values to the correct maximum */
1600 if (infoPtr->dwStyle & CCS_VERT)
1606 /* ******* End Phase 1a - Adjust heights for RBS_VARHEIGHT off ******* */
1609 /* ******* Start Phase 2 - split rows till adjustment height full ******* */
1611 /* assumes that the following variables contain: */
1612 /* y/x current height/width of all rows */
1614 INT i, j, prev_rh, new_rh, adj_rh, prev_idx, current_idx;
1615 REBAR_BAND *prev, *current, *walk;
1617 /* FIXME: problem # 2 */
1618 if (((infoPtr->dwStyle & CCS_VERT) ?
1620 (x < adjcx) : (y < adjcy)
1622 (adjcx - x > 4) : (adjcy - y > 4)
1625 (infoPtr->uNumBands > 1)) {
1626 for (i=(INT)infoPtr->uNumBands-2; i>=0; i--) {
1627 TRACE("P2 adjcx=%d, adjcy=%d, x=%d, y=%d\n",
1628 adjcx, adjcy, x, y);
1630 /* find the current band (starts at i+1) */
1631 current = &infoPtr->bands[i+1];
1633 while (HIDDENBAND(current)) {
1635 if (i < 0) break; /* out of bands */
1636 current = &infoPtr->bands[i+1];
1639 if (i < 0) break; /* out of bands */
1641 /* now find the prev band (starts at i) */
1642 prev = &infoPtr->bands[i];
1644 while (HIDDENBAND(prev)) {
1646 if (i < 0) break; /* out of bands */
1647 prev = &infoPtr->bands[i];
1650 if (i < 0) break; /* out of bands */
1652 prev_rh = ircBw(prev);
1653 if (prev->iRow == current->iRow) {
1654 new_rh = (infoPtr->dwStyle & RBS_VARHEIGHT) ?
1655 current->lcy + REBARSPACE(current) :
1657 adj_rh = new_rh + SEP_WIDTH;
1658 infoPtr->uNumRows++;
1659 current->fDraw |= NTF_INVALIDATE;
1661 if (infoPtr->dwStyle & CCS_VERT) {
1662 current->rcBand.top = inity;
1663 current->rcBand.bottom = clientcy;
1664 current->rcBand.left += (prev_rh + SEP_WIDTH);
1665 current->rcBand.right = current->rcBand.left + new_rh;
1669 current->rcBand.left = initx;
1670 current->rcBand.right = clientcx;
1671 current->rcBand.top += (prev_rh + SEP_WIDTH);
1672 current->rcBand.bottom = current->rcBand.top + new_rh;
1675 TRACE("P2 moving band %d to own row at (%d,%d)-(%d,%d)\n",
1677 current->rcBand.left, current->rcBand.top,
1678 current->rcBand.right, current->rcBand.bottom);
1679 TRACE("P2 prev band %d at (%d,%d)-(%d,%d)\n",
1681 prev->rcBand.left, prev->rcBand.top,
1682 prev->rcBand.right, prev->rcBand.bottom);
1683 TRACE("P2 values: prev_rh=%d, new_rh=%d, adj_rh=%d\n",
1684 prev_rh, new_rh, adj_rh);
1685 /* for bands below current adjust row # and top/bottom */
1686 for (j = current_idx+1; j<infoPtr->uNumBands; j++) {
1687 walk = &infoPtr->bands[j];
1688 if (HIDDENBAND(walk)) continue;
1689 walk->fDraw |= NTF_INVALIDATE;
1691 if (infoPtr->dwStyle & CCS_VERT) {
1692 walk->rcBand.left += adj_rh;
1693 walk->rcBand.right += adj_rh;
1696 walk->rcBand.top += adj_rh;
1697 walk->rcBand.bottom += adj_rh;
1700 if ((infoPtr->dwStyle & CCS_VERT) ? (x >= adjcx) : (y >= adjcy))
1701 break; /* all done */
1707 /* ******* End Phase 2 - split rows till adjustment height full ******* */
1710 /* ******* Start Phase 2a - create array of start and end ******* */
1711 /* indexes by row */
1713 if (infoPtr->uNumRows != origrows) {
1714 if (infoPtr->rows) COMCTL32_Free (infoPtr->rows);
1715 infoPtr->rows = COMCTL32_Alloc (sizeof (REBAR_ROW) * infoPtr->uNumRows);
1719 for (i = 0; i < infoPtr->uNumBands; i++) {
1720 lpBand = &infoPtr->bands[i];
1721 if (HIDDENBAND(lpBand)) continue;
1723 if (lpBand->iRow > row) {
1725 infoPtr->rows[row-1].istartband = i;
1728 ERR("P2a bug!!!!!!\n");
1730 infoPtr->rows[row-1].iendband = i;
1733 for (i = 0; i < infoPtr->uNumRows; i++) {
1736 p = &infoPtr->rows[i];
1737 TRACE("P2a row %d, starts %d, ends %d\n",
1738 i+1, p->istartband, p->iendband);
1741 /* ******* End Phase 2a - create array of start and end ******* */
1742 /* indexes by row */
1745 /* ******* Start Phase 2b - adjust all bands for height full ******* */
1746 /* assumes that the following variables contain: */
1747 /* y/x current height/width of all rows */
1748 /* clientcy/clientcx height/width of client area */
1750 if (((infoPtr->dwStyle & CCS_VERT) ? clientcx > x : clientcy > y) &&
1751 infoPtr->uNumBands) {
1752 INT diff, i, iband, j;
1754 diff = (infoPtr->dwStyle & CCS_VERT) ? clientcx - x : clientcy - y;
1755 for (i = infoPtr->uNumRows; i >= 1; i--) {
1756 /* if row has more than 1 band, ignore row */
1757 if (infoPtr->rows[i-1].istartband != infoPtr->rows[i-1].iendband)
1759 /* point to only band in row */
1760 iband = infoPtr->rows[i-1].istartband;
1761 lpBand = &infoPtr->bands[iband];
1762 if(HIDDENBAND(lpBand)) continue;
1763 if (lpBand->fMask & RBBS_VARIABLEHEIGHT) continue;
1764 if (((INT)lpBand->cyMaxChild < 1) ||
1765 ((INT)lpBand->cyIntegral < 1)) {
1766 if (lpBand->cyMaxChild + lpBand->cyIntegral == 0) continue;
1767 ERR("P2b band %u RBBS_VARIABLEHEIGHT set but cyMax=%d, cyInt=%d\n",
1768 iband, lpBand->cyMaxChild, lpBand->cyIntegral);
1771 /* j is now the maximum height/width in the client area */
1772 j = ((diff / lpBand->cyIntegral) * lpBand->cyIntegral) +
1774 if (j > lpBand->cyMaxChild + REBARSPACE(lpBand))
1775 j = lpBand->cyMaxChild + REBARSPACE(lpBand);
1776 diff -= (j - ircBw(lpBand));
1777 if (infoPtr->dwStyle & CCS_VERT)
1778 lpBand->rcBand.right = lpBand->rcBand.left + j;
1780 lpBand->rcBand.bottom = lpBand->rcBand.top + j;
1781 TRACE("P2b band %d, row %d changed to (%d,%d)-(%d,%d)\n",
1782 iband, lpBand->iRow,
1783 lpBand->rcBand.left, lpBand->rcBand.top,
1784 lpBand->rcBand.right, lpBand->rcBand.bottom);
1785 if (diff <= 0) break;
1788 ERR("P2b allocated more than available, diff=%d\n", diff);
1791 if (infoPtr->dwStyle & CCS_VERT)
1792 x = clientcx - diff;
1794 y = clientcy - diff;
1797 /* ******* End Phase 2b - adjust all bands for height full ******* */
1800 /* ******* Start Phase 3 - adjust all bands for width full ******* */
1802 if (infoPtr->uNumBands) {
1805 /* If RBS_BANDBORDERS set then indicate to draw bottom separator */
1806 /* on all bands in all rows but last row. */
1807 /* Also indicate to draw the right separator for each band in */
1808 /* each row but the rightmost band. */
1809 if (infoPtr->dwStyle & RBS_BANDBORDERS) {
1811 for(i = 0; i < infoPtr->uNumRows; i++) {
1812 p = &infoPtr->rows[i];
1813 for (j = p->istartband; j <= p->iendband; j++) {
1814 lpBand = &infoPtr->bands[j];
1815 if (HIDDENBAND(lpBand)) continue;
1816 if (j != p->iendband)
1817 lpBand->fDraw |= DRAW_RIGHTSEP;
1818 if (i != infoPtr->uNumRows-1)
1819 lpBand->fDraw |= DRAW_BOTTOMSEP;
1824 /* Distribute the extra space on the horizontal and adjust */
1825 /* all bands in row to same height. */
1826 for (i=1; i<=infoPtr->uNumRows; i++) {
1827 p = &infoPtr->rows[i-1];
1830 TRACE("P3 processing row %d, starting band %d, ending band %d\n",
1831 i, p->istartband, p->iendband);
1833 /* Find the largest height of the bands in the row */
1834 for (j = p->istartband; j <= p->iendband; j++) {
1835 lpBand = &infoPtr->bands[j];
1836 if (HIDDENBAND(lpBand)) continue;
1837 if (mcy < ircBw(lpBand))
1838 mcy = ircBw(lpBand);
1841 REBAR_AdjustBands (infoPtr, p->istartband, p->iendband,
1842 (infoPtr->dwStyle & CCS_VERT) ?
1843 clientcy : clientcx, mcy);
1846 /* Calculate the other rectangles in each band */
1847 if (infoPtr->dwStyle & CCS_VERT) {
1848 REBAR_CalcVertBand (infoPtr, 0, infoPtr->uNumBands,
1852 REBAR_CalcHorzBand (infoPtr, 0, infoPtr->uNumBands,
1857 /* ******* End Phase 3 - adjust all bands for width full ******* */
1859 /* now compute size of Rebar itself */
1860 infoPtr->oldSize = infoPtr->calcSize;
1861 if (infoPtr->uNumBands == 0) {
1862 /* we have no bands, so make size the size of client */
1866 if (infoPtr->dwStyle & CCS_VERT) {
1867 infoPtr->calcSize.cx = x;
1868 infoPtr->calcSize.cy = clientcy;
1869 TRACE("vert, notify=%d, x=%d, origheight=%d\n",
1870 notify, x, origheight);
1871 if (notify && (x != origheight)) infoPtr->fStatus |= NTF_HGHTCHG;
1874 infoPtr->calcSize.cx = clientcx;
1875 infoPtr->calcSize.cy = y;
1876 TRACE("horz, notify=%d, y=%d, origheight=%d\n",
1877 notify, y, origheight);
1878 if (notify && (y != origheight)) infoPtr->fStatus |= NTF_HGHTCHG;
1881 REBAR_DumpBand (infoPtr);
1883 REBAR_MoveChildWindows (infoPtr, 0, infoPtr->uNumBands);
1885 REBAR_ForceResize (infoPtr);
1890 REBAR_ValidateBand (REBAR_INFO *infoPtr, REBAR_BAND *lpBand)
1891 /* Function: This routine evaluates the band specs supplied */
1892 /* by the user and updates the following 5 fields in */
1893 /* the internal band structure: cxHeader, lcx, lcy, hcx, hcy*/
1900 lpBand->fStatus = 0;
1908 /* Data comming in from users into the cx... and cy... fields */
1909 /* may be bad, just garbage, because the user never clears */
1910 /* the fields. RB_{SET|INSERT}BAND{A|W} just passes the data */
1911 /* along if the fields exist in the input area. Here we must */
1912 /* determine if the data is valid. I have no idea how MS does */
1913 /* the validation, but it does because the RB_GETBANDINFO */
1914 /* returns a 0 when I know the sample program passed in an */
1915 /* address. Here I will use the algorithim that if the value */
1916 /* is greater than 65535 then it is bad and replace it with */
1917 /* a zero. Feel free to improve the algorithim. - GA 12/2000 */
1918 if (lpBand->cxMinChild > 65535) lpBand->cxMinChild = 0;
1919 if (lpBand->cyMinChild > 65535) lpBand->cyMinChild = 0;
1920 if (lpBand->cx > 65535) lpBand->cx = 0;
1921 if (lpBand->cyChild > 65535) lpBand->cyChild = 0;
1922 if (lpBand->cyMaxChild > 65535) lpBand->cyMaxChild = 0;
1923 if (lpBand->cyIntegral > 65535) lpBand->cyIntegral = 0;
1924 if (lpBand->cxIdeal > 65535) lpBand->cxIdeal = 0;
1925 if (lpBand->cxHeader > 65535) lpBand->cxHeader = 0;
1927 /* FIXME: probably should only set NEEDS_LAYOUT flag when */
1928 /* values change. Till then always set it. */
1929 TRACE("setting NEEDS_LAYOUT\n");
1930 infoPtr->fStatus |= BAND_NEEDS_LAYOUT;
1932 /* Header is where the image, text and gripper exist */
1933 /* in the band and preceed the child window. */
1935 /* count number of non-FIXEDSIZE and non-Hidden bands */
1937 for (i=0; i<infoPtr->uNumBands; i++){
1938 tBand = &infoPtr->bands[i];
1939 if (!HIDDENBAND(tBand) && !(tBand->fStyle & RBBS_FIXEDSIZE))
1943 /* calculate gripper rectangle */
1944 if ( (!(lpBand->fStyle & RBBS_NOGRIPPER)) &&
1945 ( (lpBand->fStyle & RBBS_GRIPPERALWAYS) ||
1946 ( !(lpBand->fStyle & RBBS_FIXEDSIZE) && (nonfixed > 1)))
1948 lpBand->fStatus |= HAS_GRIPPER;
1949 if (infoPtr->dwStyle & CCS_VERT)
1950 if (infoPtr->dwStyle & RBS_VERTICALGRIPPER)
1951 header += (GRIPPER_HEIGHT + REBAR_PRE_GRIPPER);
1953 header += (GRIPPER_WIDTH + REBAR_PRE_GRIPPER);
1955 header += (REBAR_PRE_GRIPPER + GRIPPER_WIDTH);
1956 /* Always have 4 pixels before anything else */
1957 header += REBAR_ALWAYS_SPACE;
1960 /* image is visible */
1961 if ((lpBand->fMask & RBBIM_IMAGE) && (infoPtr->himl)) {
1962 lpBand->fStatus |= HAS_IMAGE;
1963 if (infoPtr->dwStyle & CCS_VERT) {
1964 header += (infoPtr->imageSize.cy + REBAR_POST_IMAGE);
1965 lpBand->lcy = infoPtr->imageSize.cx + 2;
1968 header += (infoPtr->imageSize.cx + REBAR_POST_IMAGE);
1969 lpBand->lcy = infoPtr->imageSize.cy + 2;
1973 /* text is visible */
1974 if ((lpBand->fMask & RBBIM_TEXT) && (lpBand->lpText)) {
1975 HDC hdc = GetDC (0);
1976 HFONT hOldFont = SelectObject (hdc, infoPtr->hFont);
1979 lpBand->fStatus |= HAS_TEXT;
1980 GetTextExtentPoint32W (hdc, lpBand->lpText,
1981 lstrlenW (lpBand->lpText), &size);
1982 header += ((infoPtr->dwStyle & CCS_VERT) ? (size.cy + REBAR_POST_TEXT) : (size.cx + REBAR_POST_TEXT));
1983 textheight = (infoPtr->dwStyle & CCS_VERT) ? 0 : size.cy;
1985 SelectObject (hdc, hOldFont);
1989 /* if no gripper but either image or text, then leave space */
1990 if ((lpBand->fStatus & (HAS_IMAGE | HAS_TEXT)) &&
1991 !(lpBand->fStatus & HAS_GRIPPER)) {
1992 header += REBAR_ALWAYS_SPACE;
1995 /* check if user overrode the header value */
1996 if (!(lpBand->fMask & RBBIM_HEADERSIZE))
1997 lpBand->cxHeader = header;
2000 /* Now compute minimum size of child window */
2001 lpBand->offChild.cx = 0;
2002 lpBand->offChild.cy = 0;
2003 lpBand->lcy = textheight;
2004 lpBand->ccy = lpBand->lcy;
2005 if (lpBand->fMask & RBBIM_CHILDSIZE) {
2006 lpBand->lcx = lpBand->cxMinChild;
2008 /* Set the .cy values for CHILDSIZE case */
2009 lpBand->lcy = max(lpBand->lcy, lpBand->cyMinChild);
2010 lpBand->ccy = lpBand->lcy;
2011 lpBand->hcy = lpBand->lcy;
2012 if (lpBand->cyMaxChild != 0xffffffff) {
2013 lpBand->hcy = lpBand->cyMaxChild;
2015 if (lpBand->cyChild != 0xffffffff)
2016 lpBand->ccy = max (lpBand->cyChild, lpBand->lcy);
2018 TRACE("_CHILDSIZE\n");
2020 if (lpBand->fMask & RBBIM_SIZE) {
2021 lpBand->hcx = max (lpBand->cx-lpBand->cxHeader, lpBand->lcx);
2025 lpBand->hcx = lpBand->lcx;
2026 lpBand->ccx = lpBand->hcx;
2028 /* make ->.cx include header size for _Layout */
2029 lpBand->lcx += lpBand->cxHeader;
2030 lpBand->ccx += lpBand->cxHeader;
2031 lpBand->hcx += lpBand->cxHeader;
2036 REBAR_CommonSetupBand (HWND hwnd, LPREBARBANDINFOA lprbbi, REBAR_BAND *lpBand)
2037 /* Function: This routine copies the supplied values from */
2038 /* user input (lprbbi) to the internal band structure. */
2040 lpBand->fMask |= lprbbi->fMask;
2042 if (lprbbi->fMask & RBBIM_STYLE)
2043 lpBand->fStyle = lprbbi->fStyle;
2045 if (lprbbi->fMask & RBBIM_COLORS) {
2046 lpBand->clrFore = lprbbi->clrFore;
2047 lpBand->clrBack = lprbbi->clrBack;
2050 if (lprbbi->fMask & RBBIM_IMAGE)
2051 lpBand->iImage = lprbbi->iImage;
2053 if (lprbbi->fMask & RBBIM_CHILD) {
2054 if (lprbbi->hwndChild) {
2055 lpBand->hwndChild = lprbbi->hwndChild;
2056 lpBand->hwndPrevParent =
2057 SetParent (lpBand->hwndChild, hwnd);
2058 /* below in trace fro WinRAR */
2059 ShowWindow(lpBand->hwndChild, SW_SHOWNOACTIVATE | SW_SHOWNORMAL);
2060 /* above in trace fro WinRAR */
2063 TRACE("child: 0x%x prev parent: 0x%x\n",
2064 lpBand->hwndChild, lpBand->hwndPrevParent);
2065 lpBand->hwndChild = 0;
2066 lpBand->hwndPrevParent = 0;
2070 if (lprbbi->fMask & RBBIM_CHILDSIZE) {
2071 lpBand->cxMinChild = lprbbi->cxMinChild;
2072 lpBand->cyMinChild = lprbbi->cyMinChild;
2073 if (lprbbi->cbSize >= sizeof (REBARBANDINFOA)) {
2074 lpBand->cyChild = lprbbi->cyChild;
2075 lpBand->cyMaxChild = lprbbi->cyMaxChild;
2076 lpBand->cyIntegral = lprbbi->cyIntegral;
2078 else { /* special case - these should be zeroed out since */
2079 /* RBBIM_CHILDSIZE added these in WIN32_IE >= 0x0400 */
2080 lpBand->cyChild = 0;
2081 lpBand->cyMaxChild = 0;
2082 lpBand->cyIntegral = 0;
2086 if (lprbbi->fMask & RBBIM_SIZE)
2087 lpBand->cx = lprbbi->cx;
2089 if (lprbbi->fMask & RBBIM_BACKGROUND)
2090 lpBand->hbmBack = lprbbi->hbmBack;
2092 if (lprbbi->fMask & RBBIM_ID)
2093 lpBand->wID = lprbbi->wID;
2095 /* check for additional data */
2096 if (lprbbi->cbSize >= sizeof (REBARBANDINFOA)) {
2097 if (lprbbi->fMask & RBBIM_IDEALSIZE)
2098 lpBand->cxIdeal = lprbbi->cxIdeal;
2100 if (lprbbi->fMask & RBBIM_LPARAM)
2101 lpBand->lParam = lprbbi->lParam;
2103 if (lprbbi->fMask & RBBIM_HEADERSIZE)
2104 lpBand->cxHeader = lprbbi->cxHeader;
2109 REBAR_InternalEraseBkGnd (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam, RECT *clip)
2110 /* Function: This erases the background rectangle by drawing */
2111 /* each band with its background color (or the default) and */
2112 /* draws each bands right separator if necessary. The row */
2113 /* separators are drawn on the first band of the next row. */
2117 HDC hdc = (HDC)wParam;
2119 COLORREF old = CLR_NONE, new;
2122 for(i=0; i<infoPtr->uNumBands; i++) {
2123 lpBand = &infoPtr->bands[i];
2124 if (HIDDENBAND(lpBand)) continue;
2126 /* draw band separator between rows */
2127 if (lpBand->iRow != oldrow) {
2128 oldrow = lpBand->iRow;
2129 if (lpBand->fDraw & DRAW_BOTTOMSEP) {
2131 rcRowSep = lpBand->rcBand;
2132 if (infoPtr->dwStyle & CCS_VERT) {
2133 rcRowSep.right += SEP_WIDTH_SIZE;
2134 rcRowSep.bottom = infoPtr->calcSize.cy;
2135 DrawEdge (hdc, &rcRowSep, EDGE_ETCHED, BF_RIGHT);
2138 rcRowSep.bottom += SEP_WIDTH_SIZE;
2139 rcRowSep.right = infoPtr->calcSize.cx;
2140 DrawEdge (hdc, &rcRowSep, EDGE_ETCHED, BF_BOTTOM);
2142 TRACE ("drawing band separator bottom (%d,%d)-(%d,%d)\n",
2143 rcRowSep.left, rcRowSep.top,
2144 rcRowSep.right, rcRowSep.bottom);
2148 /* draw band separator between bands in a row */
2149 if (lpBand->fDraw & DRAW_RIGHTSEP) {
2151 rcSep = lpBand->rcBand;
2152 if (infoPtr->dwStyle & CCS_VERT) {
2153 rcSep.bottom += SEP_WIDTH_SIZE;
2154 DrawEdge (hdc, &rcSep, EDGE_ETCHED, BF_BOTTOM);
2157 rcSep.right += SEP_WIDTH_SIZE;
2158 DrawEdge (hdc, &rcSep, EDGE_ETCHED, BF_RIGHT);
2160 TRACE("drawing band separator right (%d,%d)-(%d,%d)\n",
2161 rcSep.left, rcSep.top, rcSep.right, rcSep.bottom);
2164 /* draw the actual background */
2165 if (lpBand->clrBack != CLR_NONE) {
2166 new = (lpBand->clrBack == CLR_DEFAULT) ? infoPtr->clrBtnFace :
2169 /* testing only - make background green to see it */
2174 /* In the absence of documentation for Rebar vs. CLR_NONE,
2175 * we will use the default BtnFace color. Note documentation
2176 * exists for Listview and Imagelist.
2178 new = infoPtr->clrBtnFace;
2180 /* testing only - make background green to see it */
2184 old = SetBkColor (hdc, new);
2186 rect = lpBand->rcBand;
2187 TRACE("%s background color=0x%06lx, band (%d,%d)-(%d,%d), clip (%d,%d)-(%d,%d)\n",
2188 (lpBand->clrBack == CLR_NONE) ? "none" :
2189 ((lpBand->clrBack == CLR_DEFAULT) ? "dft" : ""),
2191 lpBand->rcBand.left,lpBand->rcBand.top,
2192 lpBand->rcBand.right,lpBand->rcBand.bottom,
2193 clip->left, clip->top,
2194 clip->right, clip->bottom);
2195 ExtTextOutA (hdc, 0, 0, ETO_OPAQUE, &rect, NULL, 0, 0);
2196 if (lpBand->clrBack != CLR_NONE)
2197 SetBkColor (hdc, old);
2203 REBAR_InternalHitTest (REBAR_INFO *infoPtr, LPPOINT lpPt, UINT *pFlags, INT *pBand)
2209 GetClientRect (infoPtr->hwndSelf, &rect);
2211 *pFlags = RBHT_NOWHERE;
2212 if (PtInRect (&rect, *lpPt))
2214 if (infoPtr->uNumBands == 0) {
2215 *pFlags = RBHT_NOWHERE;
2222 /* somewhere inside */
2223 infoPtr->ihitBand = -1;
2224 for (iCount = 0; iCount < infoPtr->uNumBands; iCount++) {
2225 lpBand = &infoPtr->bands[iCount];
2226 if (HIDDENBAND(lpBand)) continue;
2227 if (PtInRect (&lpBand->rcBand, *lpPt)) {
2230 if (PtInRect (&lpBand->rcGripper, *lpPt)) {
2231 *pFlags = RBHT_GRABBER;
2232 infoPtr->ihitBand = iCount;
2233 TRACE("ON GRABBER %d\n", iCount);
2236 else if (PtInRect (&lpBand->rcCapImage, *lpPt)) {
2237 *pFlags = RBHT_CAPTION;
2238 TRACE("ON CAPTION %d\n", iCount);
2241 else if (PtInRect (&lpBand->rcCapText, *lpPt)) {
2242 *pFlags = RBHT_CAPTION;
2243 TRACE("ON CAPTION %d\n", iCount);
2246 else if (PtInRect (&lpBand->rcChild, *lpPt)) {
2247 *pFlags = RBHT_CLIENT;
2248 TRACE("ON CLIENT %d\n", iCount);
2252 *pFlags = RBHT_NOWHERE;
2253 TRACE("NOWHERE %d\n", iCount);
2259 *pFlags = RBHT_NOWHERE;
2268 *pFlags = RBHT_NOWHERE;
2275 TRACE("flags=0x%X\n", *pFlags);
2281 REBAR_Shrink (REBAR_INFO *infoPtr, REBAR_BAND *band, INT movement, INT i)
2282 /* Function: This attempts to shrink the given band by the */
2283 /* the amount in "movement". A shrink to the left is indi- */
2284 /* cated by "movement" being negative. "i" is merely the */
2285 /* band index for trace messages. */
2287 INT Leadjust, Readjust, avail, ret;
2289 /* Note: a left drag is indicated by "movement" being negative. */
2290 /* Similarly, a right drag is indicated by "movement" */
2291 /* being positive. "movement" should never be 0, but if */
2292 /* it is then the band does not move. */
2294 avail = rcBw(band) - band->lcx;
2296 /* now compute the Left End adjustment factor and Right End */
2297 /* adjustment factor. They may be different if shrinking. */
2299 /* if this band is not shrinkable, then just move it */
2300 Leadjust = Readjust = movement;
2306 if (avail <= abs(movement)) {
2307 Readjust = movement;
2308 Leadjust = movement + avail;
2312 Readjust = movement;
2319 if (avail <= abs(movement)) {
2320 Leadjust = movement;
2321 Readjust = movement - avail;
2325 Leadjust = movement;
2332 /* Reasonability Check */
2333 if (rcBlt(band) + Leadjust < 0) {
2334 ERR("adjustment will fail, band %d: left=%d, right=%d, move=%d, rtn=%d\n",
2335 i, Leadjust, Readjust, movement, ret);
2338 LEADJ(band, Leadjust);
2339 READJ(band, Readjust);
2341 TRACE("band %d: left=%d, right=%d, move=%d, rtn=%d, rcBand=(%d,%d)-(%d,%d)\n",
2342 i, Leadjust, Readjust, movement, ret,
2343 band->rcBand.left, band->rcBand.top,
2344 band->rcBand.right, band->rcBand.bottom);
2350 REBAR_HandleLRDrag (REBAR_INFO *infoPtr, POINTS *ptsmove)
2351 /* Function: This will implement the functionality of a */
2352 /* Gripper drag within a row. It will not implement "out- */
2353 /* of-row" drags. (They are detected and handled in */
2354 /* REBAR_MouseMove.) */
2355 /* **** FIXME Switching order of bands in a row not **** */
2356 /* **** yet implemented. **** */
2358 REBAR_BAND *hitBand, *band, *mindBand, *maxdBand;
2360 INT imindBand = -1, imaxdBand, ihitBand, i, movement;
2361 INT RHeaderSum = 0, LHeaderSum = 0;
2364 /* on first significant mouse movement, issue notify */
2366 if (!(infoPtr->fStatus & BEGIN_DRAG_ISSUED)) {
2367 if (REBAR_Notify_NMREBAR (infoPtr, -1, RBN_BEGINDRAG)) {
2368 /* Notify returned TRUE - abort drag */
2369 infoPtr->dragStart.x = 0;
2370 infoPtr->dragStart.y = 0;
2371 infoPtr->dragNow = infoPtr->dragStart;
2372 infoPtr->ihitBand = -1;
2376 infoPtr->fStatus |= BEGIN_DRAG_ISSUED;
2379 ihitBand = infoPtr->ihitBand;
2380 hitBand = &infoPtr->bands[ihitBand];
2381 imaxdBand = ihitBand; /* to suppress warning message */
2383 /* find all the bands in the row of the one whose Gripper was seized */
2384 for (i=0; i<infoPtr->uNumBands; i++) {
2385 band = &infoPtr->bands[i];
2386 if (HIDDENBAND(band)) continue;
2387 if (band->iRow == hitBand->iRow) {
2389 if (imindBand == -1) imindBand = i;
2390 /* minimum size of each band is size of header plus */
2391 /* size of minimum child plus offset of child from header plus */
2392 /* a one to separate each band. */
2394 LHeaderSum += (band->lcx + SEP_WIDTH);
2396 RHeaderSum += (band->lcx + SEP_WIDTH);
2400 if (RHeaderSum) RHeaderSum -= SEP_WIDTH; /* no separator afterlast band */
2402 mindBand = &infoPtr->bands[imindBand];
2403 maxdBand = &infoPtr->bands[imaxdBand];
2405 if (imindBand == imaxdBand) return; /* nothing to drag agains */
2406 if (imindBand == ihitBand) return; /* first band in row, cant drag */
2408 /* limit movement to inside adjustable bands - Left */
2409 if ( (ptsmove->x < mindBand->rcBand.left) ||
2410 (ptsmove->x > maxdBand->rcBand.right) ||
2411 (ptsmove->y < mindBand->rcBand.top) ||
2412 (ptsmove->y > maxdBand->rcBand.bottom))
2413 return; /* should swap bands */
2415 if (infoPtr->dwStyle & CCS_VERT)
2416 movement = ptsmove->y - ((hitBand->rcBand.top+REBAR_PRE_GRIPPER) -
2417 infoPtr->ihitoffset);
2419 movement = ptsmove->x - ((hitBand->rcBand.left+REBAR_PRE_GRIPPER) -
2420 infoPtr->ihitoffset);
2421 infoPtr->dragNow = *ptsmove;
2423 TRACE("before: movement=%d (%d,%d), imindBand=%d, ihitBand=%d, imaxdBand=%d, LSum=%d, RSum=%d\n",
2424 movement, ptsmove->x, ptsmove->y, imindBand, ihitBand,
2425 imaxdBand, LHeaderSum, RHeaderSum);
2426 REBAR_DumpBand (infoPtr);
2430 /* *** Drag left/up *** */
2431 compress = rcBlt(hitBand) - rcBlt(mindBand) -
2433 if (compress < abs(movement)) {
2434 TRACE("limiting left drag, was %d changed to %d\n",
2435 movement, -compress);
2436 movement = -compress;
2439 for (i=ihitBand; i>=imindBand; i--) {
2440 band = &infoPtr->bands[i];
2441 if (HIDDENBAND(band)) continue;
2442 if (i == ihitBand) {
2443 LEADJ(band, movement);
2446 movement = REBAR_Shrink (infoPtr, band, movement, i);
2447 band->ccx = rcBw(band);
2453 /* *** Drag right/down *** */
2454 compress = rcBrb(maxdBand) - rcBlt(hitBand) -
2456 if (compress < abs(movement)) {
2457 TRACE("limiting right drag, was %d changed to %d\n",
2458 movement, compress);
2459 movement = compress;
2461 for (i=ihitBand-1; i<=imaxdBand; i++) {
2462 band = &infoPtr->bands[i];
2463 if (HIDDENBAND(band)) continue;
2466 READJ(band, movement);
2469 movement = REBAR_Shrink (infoPtr, band, movement, i);
2470 band->ccx = rcBw(band);
2474 /* recompute all rectangles */
2475 if (infoPtr->dwStyle & CCS_VERT) {
2476 REBAR_CalcVertBand (infoPtr, imindBand, imaxdBand+1,
2480 REBAR_CalcHorzBand (infoPtr, imindBand, imaxdBand+1,
2484 TRACE("bands after adjustment, see band # %d, %d\n",
2485 imindBand, imaxdBand);
2486 REBAR_DumpBand (infoPtr);
2489 mindBand->rcBand.left,
2490 mindBand->rcBand.top,
2491 maxdBand->rcBand.right,
2492 maxdBand->rcBand.bottom);
2494 REBAR_MoveChildWindows (infoPtr, imindBand, imaxdBand+1);
2496 InvalidateRect (infoPtr->hwndSelf, &newrect, TRUE);
2497 UpdateWindow (infoPtr->hwndSelf);
2503 /* << REBAR_BeginDrag >> */
2507 REBAR_DeleteBand (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
2509 UINT uBand = (UINT)wParam;
2513 if (uBand >= infoPtr->uNumBands)
2516 TRACE("deleting band %u!\n", uBand);
2517 lpBand = &infoPtr->bands[uBand];
2518 REBAR_Notify_NMREBAR (infoPtr, uBand, RBN_DELETINGBAND);
2520 if (infoPtr->uNumBands == 1) {
2521 TRACE(" simple delete!\n");
2522 if ((lpBand->fMask & RBBIM_CHILD) && lpBand->hwndChild)
2523 childhwnd = lpBand->hwndChild;
2524 COMCTL32_Free (infoPtr->bands);
2525 infoPtr->bands = NULL;
2526 infoPtr->uNumBands = 0;
2529 REBAR_BAND *oldBands = infoPtr->bands;
2530 TRACE("complex delete! [uBand=%u]\n", uBand);
2532 if ((lpBand->fMask & RBBIM_CHILD) && lpBand->hwndChild)
2533 childhwnd = lpBand->hwndChild;
2535 infoPtr->uNumBands--;
2536 infoPtr->bands = COMCTL32_Alloc (sizeof (REBAR_BAND) * infoPtr->uNumBands);
2538 memcpy (&infoPtr->bands[0], &oldBands[0],
2539 uBand * sizeof(REBAR_BAND));
2542 if (uBand < infoPtr->uNumBands) {
2543 memcpy (&infoPtr->bands[uBand], &oldBands[uBand+1],
2544 (infoPtr->uNumBands - uBand) * sizeof(REBAR_BAND));
2547 COMCTL32_Free (oldBands);
2551 ShowWindow (childhwnd, SW_HIDE);
2553 REBAR_Notify_NMREBAR (infoPtr, -1, RBN_DELETEDBAND);
2555 /* if only 1 band left the re-validate to possible eliminate gripper */
2556 if (infoPtr->uNumBands == 1)
2557 REBAR_ValidateBand (infoPtr, &infoPtr->bands[0]);
2559 TRACE("setting NEEDS_LAYOUT\n");
2560 infoPtr->fStatus |= BAND_NEEDS_LAYOUT;
2561 infoPtr->fStatus |= RESIZE_ANYHOW;
2562 REBAR_Layout (infoPtr, NULL, TRUE, FALSE);
2568 /* << REBAR_DragMove >> */
2569 /* << REBAR_EndDrag >> */
2573 REBAR_GetBandBorders (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
2575 LPRECT lpRect = (LPRECT)lParam;
2580 if ((UINT)wParam >= infoPtr->uNumBands)
2583 lpBand = &infoPtr->bands[(UINT)wParam];
2585 /* FIXME - the following values were determined by experimentation */
2586 /* with the REBAR Control Spy. I have guesses as to what the 4 and */
2587 /* 1 are, but I am not sure. There doesn't seem to be any actual */
2588 /* difference in size of the control area with and without the */
2590 if (infoPtr->dwStyle & RBS_BANDBORDERS) {
2591 if (infoPtr->dwStyle & CCS_VERT) {
2593 lpRect->top = lpBand->cxHeader + 4;
2598 lpRect->left = lpBand->cxHeader + 4;
2605 lpRect->left = lpBand->cxHeader;
2611 inline static LRESULT
2612 REBAR_GetBandCount (REBAR_INFO *infoPtr)
2614 TRACE("band count %u!\n", infoPtr->uNumBands);
2616 return infoPtr->uNumBands;
2621 REBAR_GetBandInfoA (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
2623 LPREBARBANDINFOA lprbbi = (LPREBARBANDINFOA)lParam;
2628 if (lprbbi->cbSize < REBARBANDINFO_V3_SIZEA)
2630 if ((UINT)wParam >= infoPtr->uNumBands)
2633 TRACE("index %u\n", (UINT)wParam);
2635 /* copy band information */
2636 lpBand = &infoPtr->bands[(UINT)wParam];
2638 if (lprbbi->fMask & RBBIM_STYLE)
2639 lprbbi->fStyle = lpBand->fStyle;
2641 if (lprbbi->fMask & RBBIM_COLORS) {
2642 lprbbi->clrFore = lpBand->clrFore;
2643 lprbbi->clrBack = lpBand->clrBack;
2644 if (lprbbi->clrBack == CLR_DEFAULT)
2645 lprbbi->clrBack = infoPtr->clrBtnFace;
2648 if ((lprbbi->fMask & RBBIM_TEXT) && (lprbbi->lpText)) {
2649 if (lpBand->lpText && (lpBand->fMask & RBBIM_TEXT))
2651 if (!WideCharToMultiByte( CP_ACP, 0, lpBand->lpText, -1,
2652 lprbbi->lpText, lprbbi->cch, NULL, NULL ))
2653 lprbbi->lpText[lprbbi->cch-1] = 0;
2656 *lprbbi->lpText = 0;
2659 if (lprbbi->fMask & RBBIM_IMAGE) {
2660 if (lpBand->fMask & RBBIM_IMAGE)
2661 lprbbi->iImage = lpBand->iImage;
2663 lprbbi->iImage = -1;
2666 if (lprbbi->fMask & RBBIM_CHILD)
2667 lprbbi->hwndChild = lpBand->hwndChild;
2669 if (lprbbi->fMask & RBBIM_CHILDSIZE) {
2670 lprbbi->cxMinChild = lpBand->cxMinChild;
2671 lprbbi->cyMinChild = lpBand->cyMinChild;
2672 if (lprbbi->cbSize >= sizeof (REBARBANDINFOA)) {
2673 lprbbi->cyChild = lpBand->cyChild;
2674 lprbbi->cyMaxChild = lpBand->cyMaxChild;
2675 lprbbi->cyIntegral = lpBand->cyIntegral;
2679 if (lprbbi->fMask & RBBIM_SIZE)
2680 lprbbi->cx = lpBand->cx;
2682 if (lprbbi->fMask & RBBIM_BACKGROUND)
2683 lprbbi->hbmBack = lpBand->hbmBack;
2685 if (lprbbi->fMask & RBBIM_ID)
2686 lprbbi->wID = lpBand->wID;
2688 /* check for additional data */
2689 if (lprbbi->cbSize >= sizeof (REBARBANDINFOA)) {
2690 if (lprbbi->fMask & RBBIM_IDEALSIZE)
2691 lprbbi->cxIdeal = lpBand->cxIdeal;
2693 if (lprbbi->fMask & RBBIM_LPARAM)
2694 lprbbi->lParam = lpBand->lParam;
2696 if (lprbbi->fMask & RBBIM_HEADERSIZE)
2697 lprbbi->cxHeader = lpBand->cxHeader;
2700 REBAR_DumpBandInfo (lprbbi);
2707 REBAR_GetBandInfoW (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
2709 LPREBARBANDINFOW lprbbi = (LPREBARBANDINFOW)lParam;
2714 if (lprbbi->cbSize < REBARBANDINFO_V3_SIZEW)
2716 if ((UINT)wParam >= infoPtr->uNumBands)
2719 TRACE("index %u\n", (UINT)wParam);
2721 /* copy band information */
2722 lpBand = &infoPtr->bands[(UINT)wParam];
2724 if (lprbbi->fMask & RBBIM_STYLE)
2725 lprbbi->fStyle = lpBand->fStyle;
2727 if (lprbbi->fMask & RBBIM_COLORS) {
2728 lprbbi->clrFore = lpBand->clrFore;
2729 lprbbi->clrBack = lpBand->clrBack;
2730 if (lprbbi->clrBack == CLR_DEFAULT)
2731 lprbbi->clrBack = infoPtr->clrBtnFace;
2734 if ((lprbbi->fMask & RBBIM_TEXT) && (lprbbi->lpText)) {
2735 if (lpBand->lpText && (lpBand->fMask & RBBIM_TEXT))
2736 lstrcpynW (lprbbi->lpText, lpBand->lpText, lprbbi->cch);
2738 *lprbbi->lpText = 0;
2741 if (lprbbi->fMask & RBBIM_IMAGE) {
2742 if (lpBand->fMask & RBBIM_IMAGE)
2743 lprbbi->iImage = lpBand->iImage;
2745 lprbbi->iImage = -1;
2748 if (lprbbi->fMask & RBBIM_CHILD)
2749 lprbbi->hwndChild = lpBand->hwndChild;
2751 if (lprbbi->fMask & RBBIM_CHILDSIZE) {
2752 lprbbi->cxMinChild = lpBand->cxMinChild;
2753 lprbbi->cyMinChild = lpBand->cyMinChild;
2754 if (lprbbi->cbSize >= sizeof (REBARBANDINFOW)) {
2755 lprbbi->cyChild = lpBand->cyChild;
2756 lprbbi->cyMaxChild = lpBand->cyMaxChild;
2757 lprbbi->cyIntegral = lpBand->cyIntegral;
2761 if (lprbbi->fMask & RBBIM_SIZE)
2762 lprbbi->cx = lpBand->cx;
2764 if (lprbbi->fMask & RBBIM_BACKGROUND)
2765 lprbbi->hbmBack = lpBand->hbmBack;
2767 if (lprbbi->fMask & RBBIM_ID)
2768 lprbbi->wID = lpBand->wID;
2770 /* check for additional data */
2771 if (lprbbi->cbSize >= sizeof (REBARBANDINFOW)) {
2772 if (lprbbi->fMask & RBBIM_IDEALSIZE)
2773 lprbbi->cxIdeal = lpBand->cxIdeal;
2775 if (lprbbi->fMask & RBBIM_LPARAM)
2776 lprbbi->lParam = lpBand->lParam;
2778 if (lprbbi->fMask & RBBIM_HEADERSIZE)
2779 lprbbi->cxHeader = lpBand->cxHeader;
2782 REBAR_DumpBandInfo ((LPREBARBANDINFOA)lprbbi);
2789 REBAR_GetBarHeight (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
2793 nHeight = (infoPtr->dwStyle & CCS_VERT) ? infoPtr->calcSize.cx : infoPtr->calcSize.cy;
2795 TRACE("height = %d\n", nHeight);
2802 REBAR_GetBarInfo (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
2804 LPREBARINFO lpInfo = (LPREBARINFO)lParam;
2809 if (lpInfo->cbSize < sizeof (REBARINFO))
2812 TRACE("getting bar info!\n");
2814 if (infoPtr->himl) {
2815 lpInfo->himl = infoPtr->himl;
2816 lpInfo->fMask |= RBIM_IMAGELIST;
2823 inline static LRESULT
2824 REBAR_GetBkColor (REBAR_INFO *infoPtr)
2826 COLORREF clr = infoPtr->clrBk;
2828 if (clr == CLR_DEFAULT)
2829 clr = infoPtr->clrBtnFace;
2831 TRACE("background color 0x%06lx!\n", clr);
2837 /* << REBAR_GetColorScheme >> */
2838 /* << REBAR_GetDropTarget >> */
2842 REBAR_GetPalette (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
2844 FIXME("empty stub!\n");
2851 REBAR_GetRect (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
2853 INT iBand = (INT)wParam;
2854 LPRECT lprc = (LPRECT)lParam;
2857 if ((iBand < 0) && ((UINT)iBand >= infoPtr->uNumBands))
2862 lpBand = &infoPtr->bands[iBand];
2863 CopyRect (lprc, &lpBand->rcBand);
2865 TRACE("band %d, (%d,%d)-(%d,%d)\n", iBand,
2866 lprc->left, lprc->top, lprc->right, lprc->bottom);
2872 inline static LRESULT
2873 REBAR_GetRowCount (REBAR_INFO *infoPtr)
2875 TRACE("%u\n", infoPtr->uNumRows);
2877 return infoPtr->uNumRows;
2882 REBAR_GetRowHeight (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
2884 INT iRow = (INT)wParam;
2889 for (i=0; i<infoPtr->uNumBands; i++) {
2890 lpBand = &infoPtr->bands[i];
2891 if (HIDDENBAND(lpBand)) continue;
2892 if (lpBand->iRow != iRow) continue;
2893 if (infoPtr->dwStyle & CCS_VERT)
2894 j = lpBand->rcBand.right - lpBand->rcBand.left;
2896 j = lpBand->rcBand.bottom - lpBand->rcBand.top;
2897 if (j > ret) ret = j;
2900 TRACE("row %d, height %d\n", iRow, ret);
2906 inline static LRESULT
2907 REBAR_GetTextColor (REBAR_INFO *infoPtr)
2909 TRACE("text color 0x%06lx!\n", infoPtr->clrText);
2911 return infoPtr->clrText;
2915 inline static LRESULT
2916 REBAR_GetToolTips (REBAR_INFO *infoPtr)
2918 return (LRESULT)infoPtr->hwndToolTip;
2922 inline static LRESULT
2923 REBAR_GetUnicodeFormat (REBAR_INFO *infoPtr)
2925 TRACE("%s hwnd=0x%x\n",
2926 infoPtr->bUnicode ? "TRUE" : "FALSE", infoPtr->hwndSelf);
2928 return infoPtr->bUnicode;
2932 inline static LRESULT
2933 REBAR_GetVersion (REBAR_INFO *infoPtr)
2935 TRACE("version %d\n", infoPtr->iVersion);
2936 return infoPtr->iVersion;
2941 REBAR_HitTest (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
2943 LPRBHITTESTINFO lprbht = (LPRBHITTESTINFO)lParam;
2948 REBAR_InternalHitTest (infoPtr, &lprbht->pt, &lprbht->flags, &lprbht->iBand);
2950 return lprbht->iBand;
2955 REBAR_IdToIndex (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
2959 if (infoPtr == NULL)
2962 if (infoPtr->uNumBands < 1)
2965 for (i = 0; i < infoPtr->uNumBands; i++) {
2966 if (infoPtr->bands[i].wID == (UINT)wParam) {
2967 TRACE("id %u is band %u found!\n", (UINT)wParam, i);
2972 TRACE("id %u is not found\n", (UINT)wParam);
2978 REBAR_InsertBandA (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
2980 LPREBARBANDINFOA lprbbi = (LPREBARBANDINFOA)lParam;
2981 UINT uIndex = (UINT)wParam;
2984 if (infoPtr == NULL)
2988 if (lprbbi->cbSize < REBARBANDINFO_V3_SIZEA)
2991 /* trace the index as signed to see the -1 */
2992 TRACE("insert band at %d!\n", (INT)uIndex);
2993 REBAR_DumpBandInfo (lprbbi);
2995 if (infoPtr->uNumBands == 0) {
2996 infoPtr->bands = (REBAR_BAND *)COMCTL32_Alloc (sizeof (REBAR_BAND));
3000 REBAR_BAND *oldBands = infoPtr->bands;
3002 (REBAR_BAND *)COMCTL32_Alloc ((infoPtr->uNumBands+1)*sizeof(REBAR_BAND));
3003 if (((INT)uIndex == -1) || (uIndex > infoPtr->uNumBands))
3004 uIndex = infoPtr->uNumBands;
3006 /* pre insert copy */
3008 memcpy (&infoPtr->bands[0], &oldBands[0],
3009 uIndex * sizeof(REBAR_BAND));
3013 if (uIndex < infoPtr->uNumBands - 1) {
3014 memcpy (&infoPtr->bands[uIndex+1], &oldBands[uIndex],
3015 (infoPtr->uNumBands - uIndex - 1) * sizeof(REBAR_BAND));
3018 COMCTL32_Free (oldBands);
3021 infoPtr->uNumBands++;
3023 TRACE("index %u!\n", uIndex);
3025 /* initialize band (infoPtr->bands[uIndex])*/
3026 lpBand = &infoPtr->bands[uIndex];
3028 lpBand->fStatus = 0;
3029 lpBand->clrFore = infoPtr->clrText;
3030 lpBand->clrBack = infoPtr->clrBk;
3031 lpBand->hwndChild = 0;
3032 lpBand->hwndPrevParent = 0;
3034 REBAR_CommonSetupBand (infoPtr->hwndSelf, lprbbi, lpBand);
3035 lpBand->lpText = NULL;
3036 if ((lprbbi->fMask & RBBIM_TEXT) && (lprbbi->lpText)) {
3037 INT len = MultiByteToWideChar( CP_ACP, 0, lprbbi->lpText, -1, NULL, 0 );
3039 lpBand->lpText = (LPWSTR)COMCTL32_Alloc (len*sizeof(WCHAR));
3040 MultiByteToWideChar( CP_ACP, 0, lprbbi->lpText, -1, lpBand->lpText, len );
3044 REBAR_ValidateBand (infoPtr, lpBand);
3045 /* On insert of second band, revalidate band 1 to possible add gripper */
3046 if (infoPtr->uNumBands == 2)
3047 REBAR_ValidateBand (infoPtr, &infoPtr->bands[0]);
3049 REBAR_DumpBand (infoPtr);
3051 REBAR_Layout (infoPtr, NULL, TRUE, FALSE);
3052 InvalidateRect(infoPtr->hwndSelf, 0, 1);
3059 REBAR_InsertBandW (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3061 LPREBARBANDINFOW lprbbi = (LPREBARBANDINFOW)lParam;
3062 UINT uIndex = (UINT)wParam;
3065 if (infoPtr == NULL)
3069 if (lprbbi->cbSize < REBARBANDINFO_V3_SIZEW)
3072 /* trace the index as signed to see the -1 */
3073 TRACE("insert band at %d!\n", (INT)uIndex);
3074 REBAR_DumpBandInfo ((LPREBARBANDINFOA)lprbbi);
3076 if (infoPtr->uNumBands == 0) {
3077 infoPtr->bands = (REBAR_BAND *)COMCTL32_Alloc (sizeof (REBAR_BAND));
3081 REBAR_BAND *oldBands = infoPtr->bands;
3083 (REBAR_BAND *)COMCTL32_Alloc ((infoPtr->uNumBands+1)*sizeof(REBAR_BAND));
3084 if (((INT)uIndex == -1) || (uIndex > infoPtr->uNumBands))
3085 uIndex = infoPtr->uNumBands;
3087 /* pre insert copy */
3089 memcpy (&infoPtr->bands[0], &oldBands[0],
3090 uIndex * sizeof(REBAR_BAND));
3094 if (uIndex < infoPtr->uNumBands - 1) {
3095 memcpy (&infoPtr->bands[uIndex+1], &oldBands[uIndex],
3096 (infoPtr->uNumBands - uIndex - 1) * sizeof(REBAR_BAND));
3099 COMCTL32_Free (oldBands);
3102 infoPtr->uNumBands++;
3104 TRACE("index %u!\n", uIndex);
3106 /* initialize band (infoPtr->bands[uIndex])*/
3107 lpBand = &infoPtr->bands[uIndex];
3109 lpBand->fStatus = 0;
3110 lpBand->clrFore = infoPtr->clrText;
3111 lpBand->clrBack = infoPtr->clrBk;
3112 lpBand->hwndChild = 0;
3113 lpBand->hwndPrevParent = 0;
3115 REBAR_CommonSetupBand (infoPtr->hwndSelf, (LPREBARBANDINFOA)lprbbi, lpBand);
3116 lpBand->lpText = NULL;
3117 if ((lprbbi->fMask & RBBIM_TEXT) && (lprbbi->lpText)) {
3118 INT len = lstrlenW (lprbbi->lpText);
3120 lpBand->lpText = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
3121 strcpyW (lpBand->lpText, lprbbi->lpText);
3125 REBAR_ValidateBand (infoPtr, lpBand);
3126 /* On insert of second band, revalidate band 1 to possible add gripper */
3127 if (infoPtr->uNumBands == 2)
3128 REBAR_ValidateBand (infoPtr, &infoPtr->bands[0]);
3130 REBAR_DumpBand (infoPtr);
3132 REBAR_Layout (infoPtr, NULL, TRUE, FALSE);
3133 InvalidateRect(infoPtr->hwndSelf, 0, 1);
3140 REBAR_MaximizeBand (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3143 UINT uBand = (UINT) wParam;
3146 if ((infoPtr->uNumBands == 0) ||
3147 ((INT)uBand < 0) || (uBand >= infoPtr->uNumBands)) {
3149 ERR("Illegal MaximizeBand, requested=%d, current band count=%d\n",
3150 (INT)uBand, infoPtr->uNumBands);
3154 lpBand = &infoPtr->bands[uBand];
3156 if (lParam && (lpBand->fMask & RBBIM_IDEALSIZE)) {
3157 /* handle setting ideal size */
3158 lpBand->ccx = lpBand->cxIdeal;
3161 /* handle setting to max */
3162 FIXME("(uBand = %u fIdeal = %s) case not coded\n",
3163 (UINT)wParam, lParam ? "TRUE" : "FALSE");
3167 infoPtr->fStatus |= BAND_NEEDS_LAYOUT;
3168 REBAR_Layout (infoPtr, 0, TRUE, TRUE);
3169 InvalidateRect (infoPtr->hwndSelf, 0, TRUE);
3177 REBAR_MinimizeBand (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3179 REBAR_BAND *band, *lpBand;
3180 UINT uBand = (UINT) wParam;
3182 INT imindBand, imaxdBand, iprevBand, startBand, endBand;
3185 /* A "minimize" band is equivalent to "dragging" the gripper
3186 * of than band to the right till the band is only the size
3191 if ((infoPtr->uNumBands == 0) ||
3192 ((INT)uBand < 0) || (uBand >= infoPtr->uNumBands)) {
3194 ERR("Illegal MinimizeBand, requested=%d, current band count=%d\n",
3195 (INT)uBand, infoPtr->uNumBands);
3199 /* compute amount of movement and validate */
3200 lpBand = &infoPtr->bands[uBand];
3202 if (infoPtr->dwStyle & CCS_VERT)
3203 movement = lpBand->rcBand.bottom - lpBand->rcBand.top -
3206 movement = lpBand->rcBand.right - lpBand->rcBand.left -
3209 ERR("something is wrong, band=(%d,%d)-(%d,%d), cxheader=%d\n",
3210 lpBand->rcBand.left, lpBand->rcBand.top,
3211 lpBand->rcBand.right, lpBand->rcBand.bottom,
3218 iprevBand = -1; /* to suppress warning message */
3220 /* find the first band in row of the one whose is being minimized */
3221 for (i=0; i<infoPtr->uNumBands; i++) {
3222 band = &infoPtr->bands[i];
3223 if (HIDDENBAND(band)) continue;
3224 if (band->iRow == lpBand->iRow) {
3226 if (imindBand == -1) imindBand = i;
3230 /* if the selected band is first in row then need to expand */
3231 /* next visible band */
3232 if (imindBand == uBand) {
3234 movement = -movement;
3235 /* find the first visible band to the right of the selected band */
3236 for (i=uBand+1; i<=imaxdBand; i++) {
3237 band = &infoPtr->bands[i];
3238 if (!HIDDENBAND(band)) {
3240 LEADJ(band, movement);
3241 band->ccx = rcBw(band);
3245 /* what case is this */
3246 if (iprevBand == -1) {
3247 ERR("no previous visible band\n");
3251 endBand = iprevBand;
3253 lpBand->rcBand.left,
3256 band->rcBand.bottom);
3258 /* otherwise expand previous visible band */
3261 /* find the first visible band to the left of the selected band */
3262 for (i=uBand-1; i>=imindBand; i--) {
3263 band = &infoPtr->bands[i];
3264 if (!HIDDENBAND(band)) {
3266 READJ(band, movement);
3267 band->ccx = rcBw(band);
3271 /* what case is this */
3272 if (iprevBand == -1) {
3273 ERR("no previous visible band\n");
3276 startBand = iprevBand;
3281 lpBand->rcBand.right,
3282 lpBand->rcBand.bottom);
3285 REBAR_Shrink (infoPtr, lpBand, movement, uBand);
3287 /* recompute all rectangles */
3288 if (infoPtr->dwStyle & CCS_VERT) {
3289 REBAR_CalcVertBand (infoPtr, startBand, endBand+1,
3293 REBAR_CalcHorzBand (infoPtr, startBand, endBand+1,
3297 TRACE("bands after minimize, see band # %d, %d\n",
3298 startBand, endBand);
3299 REBAR_DumpBand (infoPtr);
3301 REBAR_MoveChildWindows (infoPtr, startBand, endBand+1);
3303 InvalidateRect (infoPtr->hwndSelf, &newrect, TRUE);
3304 UpdateWindow (infoPtr->hwndSelf);
3310 REBAR_MoveBand (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3312 REBAR_BAND *oldBands = infoPtr->bands;
3314 UINT uFrom = (UINT)wParam;
3315 UINT uTo = (UINT)lParam;
3318 if ((infoPtr->uNumBands == 0) ||
3319 ((INT)uFrom < 0) || (uFrom >= infoPtr->uNumBands) ||
3320 ((INT)uTo < 0) || (uTo >= infoPtr->uNumBands)) {
3322 ERR("Illegal MoveBand, from=%d, to=%d, current band count=%d\n",
3323 (INT)uFrom, (INT)uTo, infoPtr->uNumBands);
3327 /* save one to be moved */
3328 memcpy (&holder, &oldBands[uFrom], sizeof(REBAR_BAND));
3330 /* close up rest of bands (psuedo delete) */
3331 if (uFrom < infoPtr->uNumBands - 1) {
3332 memcpy (&oldBands[uFrom], &oldBands[uFrom+1],
3333 (infoPtr->uNumBands - uFrom - 1) * sizeof(REBAR_BAND));
3336 /* allocate new space and copy rest of bands into it */
3338 (REBAR_BAND *)COMCTL32_Alloc ((infoPtr->uNumBands)*sizeof(REBAR_BAND));
3340 /* pre insert copy */
3342 memcpy (&infoPtr->bands[0], &oldBands[0],
3343 uTo * sizeof(REBAR_BAND));
3346 /* set moved band */
3347 memcpy (&infoPtr->bands[uTo], &holder, sizeof(REBAR_BAND));
3350 if (uTo < infoPtr->uNumBands - 1) {
3351 memcpy (&infoPtr->bands[uTo+1], &oldBands[uTo],
3352 (infoPtr->uNumBands - uTo - 1) * sizeof(REBAR_BAND));
3355 COMCTL32_Free (oldBands);
3357 TRACE("moved band %d to index %d\n", uFrom, uTo);
3358 REBAR_DumpBand (infoPtr);
3360 infoPtr->fStatus |= BAND_NEEDS_LAYOUT;
3361 /* **************************************************** */
3363 /* We do not do a REBAR_Layout here because the native */
3364 /* control does not do that. The actual layout and */
3365 /* repaint is done by the *next* real action, ex.: */
3366 /* RB_INSERTBAND, RB_DELETEBAND, RB_SIZETORECT, etc. */
3368 /* **************************************************** */
3375 REBAR_SetBandInfoA (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3377 LPREBARBANDINFOA lprbbi = (LPREBARBANDINFOA)lParam;
3382 if (lprbbi->cbSize < REBARBANDINFO_V3_SIZEA)
3384 if ((UINT)wParam >= infoPtr->uNumBands)
3387 TRACE("index %u\n", (UINT)wParam);
3388 REBAR_DumpBandInfo (lprbbi);
3390 /* set band information */
3391 lpBand = &infoPtr->bands[(UINT)wParam];
3393 REBAR_CommonSetupBand (infoPtr->hwndSelf, lprbbi, lpBand);
3394 if (lprbbi->fMask & RBBIM_TEXT) {
3395 if (lpBand->lpText) {
3396 COMCTL32_Free (lpBand->lpText);
3397 lpBand->lpText = NULL;
3399 if (lprbbi->lpText) {
3400 INT len = MultiByteToWideChar( CP_ACP, 0, lprbbi->lpText, -1, NULL, 0 );
3401 lpBand->lpText = (LPWSTR)COMCTL32_Alloc (len*sizeof(WCHAR));
3402 MultiByteToWideChar( CP_ACP, 0, lprbbi->lpText, -1, lpBand->lpText, len );
3406 REBAR_ValidateBand (infoPtr, lpBand);
3408 REBAR_DumpBand (infoPtr);
3410 if (lprbbi->fMask & (RBBIM_CHILDSIZE | RBBIM_SIZE)) {
3411 REBAR_Layout (infoPtr, NULL, TRUE, FALSE);
3412 InvalidateRect(infoPtr->hwndSelf, 0, 1);
3420 REBAR_SetBandInfoW (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3422 LPREBARBANDINFOW lprbbi = (LPREBARBANDINFOW)lParam;
3427 if (lprbbi->cbSize < REBARBANDINFO_V3_SIZEW)
3429 if ((UINT)wParam >= infoPtr->uNumBands)
3432 TRACE("index %u\n", (UINT)wParam);
3433 REBAR_DumpBandInfo ((LPREBARBANDINFOA)lprbbi);
3435 /* set band information */
3436 lpBand = &infoPtr->bands[(UINT)wParam];
3438 REBAR_CommonSetupBand (infoPtr->hwndSelf, (LPREBARBANDINFOA)lprbbi, lpBand);
3439 if (lprbbi->fMask & RBBIM_TEXT) {
3440 if (lpBand->lpText) {
3441 COMCTL32_Free (lpBand->lpText);
3442 lpBand->lpText = NULL;
3444 if (lprbbi->lpText) {
3445 INT len = lstrlenW (lprbbi->lpText);
3446 lpBand->lpText = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
3447 strcpyW (lpBand->lpText, lprbbi->lpText);
3451 REBAR_ValidateBand (infoPtr, lpBand);
3453 REBAR_DumpBand (infoPtr);
3455 if (lprbbi->fMask & (RBBIM_CHILDSIZE | RBBIM_SIZE)) {
3456 REBAR_Layout (infoPtr, NULL, TRUE, FALSE);
3457 InvalidateRect(infoPtr->hwndSelf, 0, 1);
3465 REBAR_SetBarInfo (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3467 LPREBARINFO lpInfo = (LPREBARINFO)lParam;
3474 if (lpInfo->cbSize < sizeof (REBARINFO))
3477 TRACE("setting bar info!\n");
3479 if (lpInfo->fMask & RBIM_IMAGELIST) {
3480 infoPtr->himl = lpInfo->himl;
3481 if (infoPtr->himl) {
3483 ImageList_GetIconSize (infoPtr->himl, &cx, &cy);
3484 infoPtr->imageSize.cx = cx;
3485 infoPtr->imageSize.cy = cy;
3488 infoPtr->imageSize.cx = 0;
3489 infoPtr->imageSize.cy = 0;
3491 TRACE("new image cx=%ld, cy=%ld\n", infoPtr->imageSize.cx,
3492 infoPtr->imageSize.cy);
3495 /* revalidate all bands to reset flags for images in headers of bands */
3496 for (i=0; i<infoPtr->uNumBands; i++) {
3497 lpBand = &infoPtr->bands[i];
3498 REBAR_ValidateBand (infoPtr, lpBand);
3506 REBAR_SetBkColor (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3510 clrTemp = infoPtr->clrBk;
3511 infoPtr->clrBk = (COLORREF)lParam;
3513 TRACE("background color 0x%06lx!\n", infoPtr->clrBk);
3519 /* << REBAR_SetColorScheme >> */
3520 /* << REBAR_SetPalette >> */
3524 REBAR_SetParent (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3526 HWND hwndTemp = infoPtr->hwndNotify;
3528 infoPtr->hwndNotify = (HWND)wParam;
3530 return (LRESULT)hwndTemp;
3535 REBAR_SetTextColor (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3539 clrTemp = infoPtr->clrText;
3540 infoPtr->clrText = (COLORREF)lParam;
3542 TRACE("text color 0x%06lx!\n", infoPtr->clrText);
3548 /* << REBAR_SetTooltips >> */
3551 inline static LRESULT
3552 REBAR_SetUnicodeFormat (REBAR_INFO *infoPtr, WPARAM wParam)
3554 BOOL bTemp = infoPtr->bUnicode;
3556 TRACE("to %s hwnd=0x%04x, was %s\n",
3557 ((BOOL)wParam) ? "TRUE" : "FALSE", infoPtr->hwndSelf,
3558 (bTemp) ? "TRUE" : "FALSE");
3560 infoPtr->bUnicode = (BOOL)wParam;
3567 REBAR_SetVersion (REBAR_INFO *infoPtr, INT iVersion)
3569 INT iOldVersion = infoPtr->iVersion;
3571 if (iVersion > COMCTL32_VERSION)
3574 infoPtr->iVersion = iVersion;
3576 TRACE("new version %d\n", iVersion);
3583 REBAR_ShowBand (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3587 if (((INT)wParam < 0) || ((INT)wParam > infoPtr->uNumBands))
3590 lpBand = &infoPtr->bands[(INT)wParam];
3593 TRACE("show band %d\n", (INT)wParam);
3594 lpBand->fStyle = lpBand->fStyle & ~RBBS_HIDDEN;
3595 if (IsWindow (lpBand->hwndChild))
3596 ShowWindow (lpBand->hwndChild, SW_SHOW);
3599 TRACE("hide band %d\n", (INT)wParam);
3600 lpBand->fStyle = lpBand->fStyle | RBBS_HIDDEN;
3601 if (IsWindow (lpBand->hwndChild))
3602 ShowWindow (lpBand->hwndChild, SW_HIDE);
3605 REBAR_Layout (infoPtr, NULL, TRUE, FALSE);
3606 InvalidateRect(infoPtr->hwndSelf, 0, 1);
3613 REBAR_SizeToRect (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3615 LPRECT lpRect = (LPRECT)lParam;
3621 TRACE("[%d %d %d %d]\n",
3622 lpRect->left, lpRect->top, lpRect->right, lpRect->bottom);
3624 /* what is going on???? */
3625 GetWindowRect(infoPtr->hwndSelf, &t1);
3626 TRACE("window rect [%d %d %d %d]\n",
3627 t1.left, t1.top, t1.right, t1.bottom);
3628 GetClientRect(infoPtr->hwndSelf, &t1);
3629 TRACE("client rect [%d %d %d %d]\n",
3630 t1.left, t1.top, t1.right, t1.bottom);
3632 /* force full _Layout processing */
3633 TRACE("setting NEEDS_LAYOUT\n");
3634 infoPtr->fStatus |= BAND_NEEDS_LAYOUT;
3635 REBAR_Layout (infoPtr, lpRect, TRUE, FALSE);
3636 InvalidateRect (infoPtr->hwndSelf, NULL, TRUE);
3643 REBAR_Create (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3645 LPCREATESTRUCTA cs = (LPCREATESTRUCTA) lParam;
3648 if (TRACE_ON(rebar)) {
3649 GetWindowRect(infoPtr->hwndSelf, &wnrc1);
3650 GetClientRect(infoPtr->hwndSelf, &clrc1);
3651 TRACE("window=(%d,%d)-(%d,%d) client=(%d,%d)-(%d,%d) cs=(%d,%d %dx%d)\n",
3652 wnrc1.left, wnrc1.top, wnrc1.right, wnrc1.bottom,
3653 clrc1.left, clrc1.top, clrc1.right, clrc1.bottom,
3654 cs->x, cs->y, cs->cx, cs->cy);
3657 TRACE("created!\n");
3663 REBAR_Destroy (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3669 /* free rebar bands */
3670 if ((infoPtr->uNumBands > 0) && infoPtr->bands) {
3671 /* clean up each band */
3672 for (i = 0; i < infoPtr->uNumBands; i++) {
3673 lpBand = &infoPtr->bands[i];
3675 /* delete text strings */
3676 if (lpBand->lpText) {
3677 COMCTL32_Free (lpBand->lpText);
3678 lpBand->lpText = NULL;
3680 /* destroy child window */
3681 DestroyWindow (lpBand->hwndChild);
3684 /* free band array */
3685 COMCTL32_Free (infoPtr->bands);
3686 infoPtr->bands = NULL;
3689 DeleteObject (infoPtr->hcurArrow);
3690 DeleteObject (infoPtr->hcurHorz);
3691 DeleteObject (infoPtr->hcurVert);
3692 DeleteObject (infoPtr->hcurDrag);
3693 if(infoPtr->hDefaultFont) DeleteObject (infoPtr->hDefaultFont);
3694 SetWindowLongA (infoPtr->hwndSelf, 0, 0);
3696 /* free rebar info data */
3697 COMCTL32_Free (infoPtr);
3698 TRACE("destroyed!\n");
3704 REBAR_EraseBkGnd (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3708 if (GetClipBox ( (HDC)wParam, &cliprect))
3709 return REBAR_InternalEraseBkGnd (infoPtr, wParam, lParam, &cliprect);
3715 REBAR_GetFont (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3717 return (LRESULT)infoPtr->hFont;
3722 REBAR_LButtonDown (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3726 /* If InternalHitTest did not find a hit on the Gripper, */
3727 /* then ignore the button click. */
3728 if (infoPtr->ihitBand == -1) return 0;
3730 SetCapture (infoPtr->hwndSelf);
3732 /* save off the LOWORD and HIWORD of lParam as initial x,y */
3733 lpBand = &infoPtr->bands[infoPtr->ihitBand];
3734 infoPtr->dragStart = MAKEPOINTS(lParam);
3735 infoPtr->dragNow = infoPtr->dragStart;
3736 if (infoPtr->dwStyle & CCS_VERT)
3737 infoPtr->ihitoffset = infoPtr->dragStart.y - (lpBand->rcBand.top+REBAR_PRE_GRIPPER);
3739 infoPtr->ihitoffset = infoPtr->dragStart.x - (lpBand->rcBand.left+REBAR_PRE_GRIPPER);
3746 REBAR_LButtonUp (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3752 /* If InternalHitTest did not find a hit on the Gripper, */
3753 /* then ignore the button click. */
3754 if (infoPtr->ihitBand == -1) return 0;
3756 ihitBand = infoPtr->ihitBand;
3757 infoPtr->dragStart.x = 0;
3758 infoPtr->dragStart.y = 0;
3759 infoPtr->dragNow = infoPtr->dragStart;
3760 infoPtr->ihitBand = -1;
3764 if (infoPtr->fStatus & BEGIN_DRAG_ISSUED) {
3765 REBAR_Notify((NMHDR *) &layout, infoPtr, RBN_LAYOUTCHANGED);
3766 REBAR_Notify_NMREBAR (infoPtr, ihitBand, RBN_ENDDRAG);
3767 infoPtr->fStatus &= ~BEGIN_DRAG_ISSUED;
3770 GetClientRect(infoPtr->hwndSelf, &rect);
3771 InvalidateRect(infoPtr->hwndSelf, NULL, TRUE);
3778 REBAR_MouseMove (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3780 REBAR_BAND *band1, *band2;
3783 /* Validate entry as hit on Gripper has occurred */
3784 if (GetCapture() != infoPtr->hwndSelf) return 0;
3785 if (infoPtr->ihitBand == -1) return 0;
3787 ptsmove = MAKEPOINTS(lParam);
3789 /* if mouse did not move much, exit */
3790 if ((abs(ptsmove.x - infoPtr->dragNow.x) <= mindragx) &&
3791 (abs(ptsmove.y - infoPtr->dragNow.y) <= mindragy)) return 0;
3793 band1 = &infoPtr->bands[infoPtr->ihitBand-1];
3794 band2 = &infoPtr->bands[infoPtr->ihitBand];
3796 /* Test for valid drag case - must not be first band in row */
3797 if (infoPtr->dwStyle & CCS_VERT) {
3798 if ((ptsmove.x < band2->rcBand.left) ||
3799 (ptsmove.x > band2->rcBand.right) ||
3800 ((infoPtr->ihitBand > 0) && (band1->iRow != band2->iRow))) {
3801 FIXME("Cannot drag to other rows yet!!\n");
3804 REBAR_HandleLRDrag (infoPtr, &ptsmove);
3808 if ((ptsmove.y < band2->rcBand.top) ||
3809 (ptsmove.y > band2->rcBand.bottom) ||
3810 ((infoPtr->ihitBand > 0) && (band1->iRow != band2->iRow))) {
3811 FIXME("Cannot drag to other rows yet!!\n");
3814 REBAR_HandleLRDrag (infoPtr, &ptsmove);
3821 inline static LRESULT
3822 REBAR_NCCalcSize (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3824 if (infoPtr->dwStyle & WS_BORDER) {
3825 InflateRect((LPRECT)lParam, -GetSystemMetrics(SM_CXEDGE),
3826 -GetSystemMetrics(SM_CYEDGE));
3828 TRACE("new client=(%d,%d)-(%d,%d)\n",
3829 ((LPRECT)lParam)->left, ((LPRECT)lParam)->top,
3830 ((LPRECT)lParam)->right, ((LPRECT)lParam)->bottom);
3836 REBAR_NCCreate (HWND hwnd, WPARAM wParam, LPARAM lParam)
3838 LPCREATESTRUCTA cs = (LPCREATESTRUCTA) lParam;
3839 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
3841 NONCLIENTMETRICSA ncm;
3845 if (infoPtr != NULL) {
3846 ERR("Strange info structure pointer *not* NULL\n");
3850 if (TRACE_ON(rebar)) {
3851 GetWindowRect(hwnd, &wnrc1);
3852 GetClientRect(hwnd, &clrc1);
3853 TRACE("window=(%d,%d)-(%d,%d) client=(%d,%d)-(%d,%d) cs=(%d,%d %dx%d)\n",
3854 wnrc1.left, wnrc1.top, wnrc1.right, wnrc1.bottom,
3855 clrc1.left, clrc1.top, clrc1.right, clrc1.bottom,
3856 cs->x, cs->y, cs->cx, cs->cy);
3859 /* allocate memory for info structure */
3860 infoPtr = (REBAR_INFO *)COMCTL32_Alloc (sizeof(REBAR_INFO));
3861 SetWindowLongA (hwnd, 0, (DWORD)infoPtr);
3863 /* initialize info structure - initial values are 0 */
3864 infoPtr->clrBk = CLR_NONE;
3865 infoPtr->clrText = CLR_NONE;
3866 infoPtr->clrBtnText = GetSysColor (COLOR_BTNTEXT);
3867 infoPtr->clrBtnFace = GetSysColor (COLOR_BTNFACE);
3868 infoPtr->ihitBand = -1;
3869 infoPtr->hwndSelf = hwnd;
3870 infoPtr->DoRedraw = TRUE;
3871 infoPtr->hcurArrow = LoadCursorA (0, IDC_ARROWA);
3872 infoPtr->hcurHorz = LoadCursorA (0, IDC_SIZEWEA);
3873 infoPtr->hcurVert = LoadCursorA (0, IDC_SIZENSA);
3874 infoPtr->hcurDrag = LoadCursorA (0, IDC_SIZEA);
3875 infoPtr->bUnicode = IsWindowUnicode (hwnd);
3876 infoPtr->fStatus = CREATE_RUNNING;
3877 infoPtr->hFont = GetStockObject (SYSTEM_FONT);
3879 /* issue WM_NOTIFYFORMAT to get unicode status of parent */
3880 i = SendMessageA(REBAR_GetNotifyParent (infoPtr),
3881 WM_NOTIFYFORMAT, (WPARAM)hwnd, NF_QUERY);
3882 if ((i < NFR_ANSI) || (i > NFR_UNICODE)) {
3883 ERR("wrong response to WM_NOTIFYFORMAT (%d), assuming ANSI\n",
3887 infoPtr->NtfUnicode = (i == NFR_UNICODE) ? 1 : 0;
3889 /* add necessary styles to the requested styles */
3890 infoPtr->dwStyle = cs->style | WS_VISIBLE | CCS_TOP;
3891 SetWindowLongA (hwnd, GWL_STYLE, infoPtr->dwStyle);
3893 /* get font handle for Caption Font */
3894 ncm.cbSize = sizeof(NONCLIENTMETRICSA);
3895 SystemParametersInfoA (SPI_GETNONCLIENTMETRICS,
3896 ncm.cbSize, &ncm, 0);
3897 /* if the font is bold, set to normal */
3898 if (ncm.lfCaptionFont.lfWeight > FW_NORMAL) {
3899 ncm.lfCaptionFont.lfWeight = FW_NORMAL;
3901 tfont = CreateFontIndirectA (&ncm.lfCaptionFont);
3903 infoPtr->hFont = infoPtr->hDefaultFont = tfont;
3907 GetSysColor (numerous);
3908 GetSysColorBrush (numerous) (see WM_SYSCOLORCHANGE);
3909 *GetStockObject (SYSTEM_FONT);
3910 *SetWindowLong (hwnd, 0, info ptr);
3912 *SetWindowLong (hwnd, GWL_STYLE, style+0x10000001);
3913 WS_VISIBLE = 0x10000000;
3914 CCS_TOP = 0x00000001;
3915 *SystemParametersInfo (SPI_GETNONCLIENTMETRICS...);
3916 *CreateFontIndirect (lfCaptionFont from above);
3918 SelectObject (hdc, fontabove);
3919 GetTextMetrics (hdc, ); guessing is tmHeight
3920 SelectObject (hdc, oldfont);
3923 MapWindowPoints (0, parent, rectabove, 2);
3926 ClientToScreen (clientrect);
3927 SetWindowPos (hwnd, 0, 0, 0, 0, 0, SWP_NOZORDER);
3934 REBAR_NCHitTest (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3941 LRESULT ret = HTCLIENT;
3944 * Differences from doc at MSDN (as observed with version 4.71 of
3946 * 1. doc says nmmouse.pt is in screen coord, trace shows client coord.
3947 * 2. if band is not identified .dwItemSpec is 0xffffffff.
3948 * 3. native always seems to return HTCLIENT if notify return is 0.
3951 shortpt = MAKEPOINTS (lParam);
3952 POINTSTOPOINT(pt, shortpt);
3954 ScreenToClient (infoPtr->hwndSelf, &clpt);
3955 REBAR_InternalHitTest (infoPtr, &clpt, &scrap,
3956 (INT *)&nmmouse.dwItemSpec);
3957 nmmouse.dwItemData = 0;
3959 nmmouse.dwHitInfo = 0;
3960 if ((i = REBAR_Notify((NMHDR *) &nmmouse, infoPtr, NM_NCHITTEST))) {
3961 TRACE("notify changed return value from %ld to %d\n",
3965 TRACE("returning %ld, client point (%ld,%ld)\n", ret, clpt.x, clpt.y);
3971 REBAR_NCPaint (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3976 if (infoPtr->dwStyle & WS_MINIMIZE)
3977 return 0; /* Nothing to do */
3979 if (infoPtr->dwStyle & WS_BORDER) {
3981 /* adjust rectangle and draw the necessary edge */
3982 if (!(hdc = GetDCEx( infoPtr->hwndSelf, 0, DCX_USESTYLE | DCX_WINDOW )))
3984 GetWindowRect (infoPtr->hwndSelf, &rcWindow);
3985 OffsetRect (&rcWindow, -rcWindow.left, -rcWindow.top);
3986 TRACE("rect (%d,%d)-(%d,%d)\n",
3987 rcWindow.left, rcWindow.top,
3988 rcWindow.right, rcWindow.bottom);
3989 DrawEdge (hdc, &rcWindow, EDGE_ETCHED, BF_RECT);
3990 ReleaseDC( infoPtr->hwndSelf, hdc );
3998 REBAR_NotifyFormat (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
4002 if (lParam == NF_REQUERY) {
4003 i = SendMessageA(REBAR_GetNotifyParent (infoPtr),
4004 WM_NOTIFYFORMAT, (WPARAM)infoPtr->hwndSelf, NF_QUERY);
4005 if ((i < NFR_ANSI) || (i > NFR_UNICODE)) {
4006 ERR("wrong response to WM_NOTIFYFORMAT (%d), assuming ANSI\n",
4010 infoPtr->NtfUnicode = (i == NFR_UNICODE) ? 1 : 0;
4013 return (LRESULT)((infoPtr->bUnicode) ? NFR_UNICODE : NFR_ANSI);
4018 REBAR_Paint (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
4024 GetClientRect(infoPtr->hwndSelf, &rc);
4025 hdc = wParam==0 ? BeginPaint (infoPtr->hwndSelf, &ps) : (HDC)wParam;
4027 TRACE("painting (%d,%d)-(%d,%d) client (%d,%d)-(%d,%d)\n",
4028 ps.rcPaint.left, ps.rcPaint.top,
4029 ps.rcPaint.right, ps.rcPaint.bottom,
4030 rc.left, rc.top, rc.right, rc.bottom);
4033 /* Erase area of paint if requested */
4034 REBAR_InternalEraseBkGnd (infoPtr, wParam, lParam, &ps.rcPaint);
4037 REBAR_Refresh (infoPtr, hdc);
4039 EndPaint (infoPtr->hwndSelf, &ps);
4045 REBAR_SetCursor (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
4050 TRACE("code=0x%X id=0x%X\n", LOWORD(lParam), HIWORD(lParam));
4053 ScreenToClient (infoPtr->hwndSelf, &pt);
4055 REBAR_InternalHitTest (infoPtr, &pt, &flags, NULL);
4057 if (flags == RBHT_GRABBER) {
4058 if ((infoPtr->dwStyle & CCS_VERT) &&
4059 !(infoPtr->dwStyle & RBS_VERTICALGRIPPER))
4060 SetCursor (infoPtr->hcurVert);
4062 SetCursor (infoPtr->hcurHorz);
4064 else if (flags != RBHT_CLIENT)
4065 SetCursor (infoPtr->hcurArrow);
4072 REBAR_SetFont (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
4078 infoPtr->hFont = (HFONT)wParam;
4080 /* revalidate all bands to change sizes of text in headers of bands */
4081 for (i=0; i<infoPtr->uNumBands; i++) {
4082 lpBand = &infoPtr->bands[i];
4083 REBAR_ValidateBand (infoPtr, lpBand);
4087 if (LOWORD(lParam)) {
4088 GetClientRect (infoPtr->hwndSelf, &rcClient);
4089 REBAR_Layout (infoPtr, &rcClient, FALSE, TRUE);
4096 inline static LRESULT
4097 REBAR_SetRedraw (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
4098 /*****************************************************
4101 * Handles the WM_SETREDRAW message.
4104 * According to testing V4.71 of COMCTL32 returns the
4105 * *previous* status of the redraw flag (either 0 or -1)
4106 * instead of the MSDN documented value of 0 if handled
4108 *****************************************************/
4110 BOOL oldredraw = infoPtr->DoRedraw;
4112 TRACE("set to %s, fStatus=%08x\n",
4113 (wParam) ? "TRUE" : "FALSE", infoPtr->fStatus);
4114 infoPtr->DoRedraw = (BOOL) wParam;
4116 if (infoPtr->fStatus & BAND_NEEDS_REDRAW) {
4117 REBAR_MoveChildWindows (infoPtr, 0, infoPtr->uNumBands);
4118 REBAR_ForceResize (infoPtr);
4119 InvalidateRect (infoPtr->hwndSelf, 0, TRUE);
4121 infoPtr->fStatus &= ~BAND_NEEDS_REDRAW;
4123 return (oldredraw) ? -1 : 0;
4128 REBAR_Size (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
4132 /* auto resize deadlock check */
4133 if (infoPtr->fStatus & AUTO_RESIZE) {
4134 infoPtr->fStatus &= ~AUTO_RESIZE;
4135 TRACE("AUTO_RESIZE was set, reset, fStatus=%08x lparam=%08lx\n",
4136 infoPtr->fStatus, lParam);
4140 if (infoPtr->fStatus & CREATE_RUNNING) {
4141 /* still in CreateWindow */
4144 if ((INT)wParam != SIZE_RESTORED) {
4145 ERR("WM_SIZE in create and flags=%08x, lParam=%08lx\n",
4149 TRACE("still in CreateWindow\n");
4150 infoPtr->fStatus &= ~CREATE_RUNNING;
4151 GetWindowRect ( infoPtr->hwndSelf, &rcWin);
4152 TRACE("win rect (%d,%d)-(%d,%d)\n",
4153 rcWin.left, rcWin.top, rcWin.right, rcWin.bottom);
4155 if ((lParam == 0) && (rcWin.right-rcWin.left == 0) &&
4156 (rcWin.bottom-rcWin.top == 0)) {
4157 /* native control seems to do this */
4158 GetClientRect (GetParent(infoPtr->hwndSelf), &rcClient);
4159 TRACE("sizing rebar, message and client zero, parent client (%d,%d)\n",
4160 rcClient.right, rcClient.bottom);
4165 cx = rcWin.right - rcWin.left;
4166 cy = rcWin.bottom - rcWin.top;
4167 if ((cx == LOWORD(lParam)) && (cy == HIWORD(lParam))) {
4171 /* do the actual WM_SIZE request */
4172 GetClientRect (infoPtr->hwndSelf, &rcClient);
4173 TRACE("sizing rebar from (%ld,%ld) to (%d,%d), client (%d,%d)\n",
4174 infoPtr->calcSize.cx, infoPtr->calcSize.cy,
4175 LOWORD(lParam), HIWORD(lParam),
4176 rcClient.right, rcClient.bottom);
4180 if ((INT)wParam != SIZE_RESTORED) {
4181 ERR("WM_SIZE out of create and flags=%08x, lParam=%08lx\n",
4185 /* Handle cases when outside of the CreateWindow process */
4187 GetClientRect (infoPtr->hwndSelf, &rcClient);
4188 if ((lParam == 0) && (rcClient.right + rcClient.bottom != 0) &&
4189 (infoPtr->dwStyle & RBS_AUTOSIZE)) {
4190 /* on a WM_SIZE to zero and current client not zero and AUTOSIZE */
4191 /* native seems to use the current client rect for the size */
4192 infoPtr->fStatus |= BAND_NEEDS_LAYOUT;
4193 TRACE("sizing rebar to client (%d,%d) size is zero but AUTOSIZE set\n",
4194 rcClient.right, rcClient.bottom);
4197 TRACE("sizing rebar from (%ld,%ld) to (%d,%d), client (%d,%d)\n",
4198 infoPtr->calcSize.cx, infoPtr->calcSize.cy,
4199 LOWORD(lParam), HIWORD(lParam),
4200 rcClient.right, rcClient.bottom);
4204 if (infoPtr->dwStyle & RBS_AUTOSIZE) {
4205 NMRBAUTOSIZE autosize;
4207 GetClientRect(infoPtr->hwndSelf, &autosize.rcTarget);
4208 autosize.fChanged = 0; /* ??? */
4209 autosize.rcActual = autosize.rcTarget; /* ??? */
4210 REBAR_Notify((NMHDR *) &autosize, infoPtr, RBN_AUTOSIZE);
4211 TRACE("RBN_AUTOSIZE client=(%d,%d), lp=%08lx\n",
4212 autosize.rcTarget.right, autosize.rcTarget.bottom, lParam);
4215 if ((infoPtr->calcSize.cx != rcClient.right) ||
4216 (infoPtr->calcSize.cy != rcClient.bottom))
4217 infoPtr->fStatus |= BAND_NEEDS_LAYOUT;
4219 REBAR_Layout (infoPtr, &rcClient, TRUE, TRUE);
4220 infoPtr->fStatus &= ~AUTO_RESIZE;
4227 REBAR_StyleChanged (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
4229 STYLESTRUCT *ss = (STYLESTRUCT *)lParam;
4231 TRACE("current style=%08lx, styleOld=%08lx, style being set to=%08lx\n",
4232 infoPtr->dwStyle, ss->styleOld, ss->styleNew);
4233 infoPtr->dwStyle = ss->styleNew;
4240 REBAR_WindowPosChanged (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
4242 WINDOWPOS *lpwp = (WINDOWPOS *)lParam;
4246 /* Save the new origin of this window - used by _ForceResize */
4247 infoPtr->origin.x = lpwp->x;
4248 infoPtr->origin.y = lpwp->y;
4249 ret = DefWindowProcA(infoPtr->hwndSelf, WM_WINDOWPOSCHANGED,
4251 GetWindowRect(infoPtr->hwndSelf, &rc);
4252 TRACE("hwnd %08x new pos (%d,%d)-(%d,%d)\n",
4253 infoPtr->hwndSelf, rc.left, rc.top, rc.right, rc.bottom);
4258 static LRESULT WINAPI
4259 REBAR_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
4261 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
4263 TRACE("hwnd=%x msg=%x wparam=%x lparam=%lx\n",
4264 hwnd, uMsg, /* SPY_GetMsgName(uMsg), */ wParam, lParam);
4265 if (!infoPtr && (uMsg != WM_NCCREATE))
4266 return DefWindowProcA (hwnd, uMsg, wParam, lParam);
4269 /* case RB_BEGINDRAG: */
4272 return REBAR_DeleteBand (infoPtr, wParam, lParam);
4274 /* case RB_DRAGMOVE: */
4275 /* case RB_ENDDRAG: */
4277 case RB_GETBANDBORDERS:
4278 return REBAR_GetBandBorders (infoPtr, wParam, lParam);
4280 case RB_GETBANDCOUNT:
4281 return REBAR_GetBandCount (infoPtr);
4283 case RB_GETBANDINFO: /* obsoleted after IE3, but we have to
4284 support it anyway. */
4285 case RB_GETBANDINFOA:
4286 return REBAR_GetBandInfoA (infoPtr, wParam, lParam);
4288 case RB_GETBANDINFOW:
4289 return REBAR_GetBandInfoW (infoPtr, wParam, lParam);
4291 case RB_GETBARHEIGHT:
4292 return REBAR_GetBarHeight (infoPtr, wParam, lParam);
4295 return REBAR_GetBarInfo (infoPtr, wParam, lParam);
4298 return REBAR_GetBkColor (infoPtr);
4300 /* case RB_GETCOLORSCHEME: */
4301 /* case RB_GETDROPTARGET: */
4304 return REBAR_GetPalette (infoPtr, wParam, lParam);
4307 return REBAR_GetRect (infoPtr, wParam, lParam);
4309 case RB_GETROWCOUNT:
4310 return REBAR_GetRowCount (infoPtr);
4312 case RB_GETROWHEIGHT:
4313 return REBAR_GetRowHeight (infoPtr, wParam, lParam);
4315 case RB_GETTEXTCOLOR:
4316 return REBAR_GetTextColor (infoPtr);
4318 case RB_GETTOOLTIPS:
4319 return REBAR_GetToolTips (infoPtr);
4321 case RB_GETUNICODEFORMAT:
4322 return REBAR_GetUnicodeFormat (infoPtr);
4324 case CCM_GETVERSION:
4325 return REBAR_GetVersion (infoPtr);
4328 return REBAR_HitTest (infoPtr, wParam, lParam);
4331 return REBAR_IdToIndex (infoPtr, wParam, lParam);
4333 case RB_INSERTBANDA:
4334 return REBAR_InsertBandA (infoPtr, wParam, lParam);
4336 case RB_INSERTBANDW:
4337 return REBAR_InsertBandW (infoPtr, wParam, lParam);
4339 case RB_MAXIMIZEBAND:
4340 return REBAR_MaximizeBand (infoPtr, wParam, lParam);
4342 case RB_MINIMIZEBAND:
4343 return REBAR_MinimizeBand (infoPtr, wParam, lParam);
4346 return REBAR_MoveBand (infoPtr, wParam, lParam);
4348 case RB_SETBANDINFOA:
4349 return REBAR_SetBandInfoA (infoPtr, wParam, lParam);
4351 case RB_SETBANDINFOW:
4352 return REBAR_SetBandInfoW (infoPtr, wParam, lParam);
4355 return REBAR_SetBarInfo (infoPtr, wParam, lParam);
4358 return REBAR_SetBkColor (infoPtr, wParam, lParam);
4360 /* case RB_SETCOLORSCHEME: */
4361 /* case RB_SETPALETTE: */
4362 /* return REBAR_GetPalette (infoPtr, wParam, lParam); */
4365 return REBAR_SetParent (infoPtr, wParam, lParam);
4367 case RB_SETTEXTCOLOR:
4368 return REBAR_SetTextColor (infoPtr, wParam, lParam);
4370 /* case RB_SETTOOLTIPS: */
4372 case RB_SETUNICODEFORMAT:
4373 return REBAR_SetUnicodeFormat (infoPtr, wParam);
4375 case CCM_SETVERSION:
4376 return REBAR_SetVersion (infoPtr, (INT)wParam);
4379 return REBAR_ShowBand (infoPtr, wParam, lParam);
4382 return REBAR_SizeToRect (infoPtr, wParam, lParam);
4385 /* Messages passed to parent */
4389 if (infoPtr->NtfUnicode)
4390 return SendMessageW (REBAR_GetNotifyParent (infoPtr),
4391 uMsg, wParam, lParam);
4393 return SendMessageA (REBAR_GetNotifyParent (infoPtr),
4394 uMsg, wParam, lParam);
4397 /* case WM_CHARTOITEM: supported according to ControlSpy */
4400 return REBAR_Create (infoPtr, wParam, lParam);
4403 return REBAR_Destroy (infoPtr, wParam, lParam);
4406 return REBAR_EraseBkGnd (infoPtr, wParam, lParam);
4409 return REBAR_GetFont (infoPtr, wParam, lParam);
4411 /* case WM_LBUTTONDBLCLK: supported according to ControlSpy */
4413 case WM_LBUTTONDOWN:
4414 return REBAR_LButtonDown (infoPtr, wParam, lParam);
4417 return REBAR_LButtonUp (infoPtr, wParam, lParam);
4419 /* case WM_MEASUREITEM: supported according to ControlSpy */
4422 return REBAR_MouseMove (infoPtr, wParam, lParam);
4425 return REBAR_NCCalcSize (infoPtr, wParam, lParam);
4428 return REBAR_NCCreate (hwnd, wParam, lParam);
4431 return REBAR_NCHitTest (infoPtr, wParam, lParam);
4434 return REBAR_NCPaint (infoPtr, wParam, lParam);
4436 case WM_NOTIFYFORMAT:
4437 return REBAR_NotifyFormat (infoPtr, wParam, lParam);
4440 return REBAR_Paint (infoPtr, wParam, lParam);
4442 /* case WM_PALETTECHANGED: supported according to ControlSpy */
4443 /* case WM_PRINTCLIENT: supported according to ControlSpy */
4444 /* case WM_QUERYNEWPALETTE:supported according to ControlSpy */
4445 /* case WM_RBUTTONDOWN: supported according to ControlSpy */
4446 /* case WM_RBUTTONUP: supported according to ControlSpy */
4449 return REBAR_SetCursor (infoPtr, wParam, lParam);
4452 return REBAR_SetFont (infoPtr, wParam, lParam);
4455 return REBAR_SetRedraw (infoPtr, wParam, lParam);
4458 return REBAR_Size (infoPtr, wParam, lParam);
4460 case WM_STYLECHANGED:
4461 return REBAR_StyleChanged (infoPtr, wParam, lParam);
4463 /* case WM_SYSCOLORCHANGE: supported according to ControlSpy */
4464 /* "Applications that have brushes using the existing system colors
4465 should delete those brushes and recreate them using the new
4466 system colors." per MSDN */
4468 /* case WM_VKEYTOITEM: supported according to ControlSpy */
4469 /* case WM_WININICHANGE: */
4471 case WM_WINDOWPOSCHANGED:
4472 return REBAR_WindowPosChanged (infoPtr, wParam, lParam);
4475 if ((uMsg >= WM_USER) && (uMsg < WM_APP))
4476 ERR("unknown msg %04x wp=%08x lp=%08lx\n",
4477 uMsg, wParam, lParam);
4478 return DefWindowProcA (hwnd, uMsg, wParam, lParam);
4485 REBAR_Register (void)
4489 ZeroMemory (&wndClass, sizeof(WNDCLASSA));
4490 wndClass.style = CS_GLOBALCLASS | CS_DBLCLKS;
4491 wndClass.lpfnWndProc = (WNDPROC)REBAR_WindowProc;
4492 wndClass.cbClsExtra = 0;
4493 wndClass.cbWndExtra = sizeof(REBAR_INFO *);
4494 wndClass.hCursor = 0;
4495 wndClass.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1);
4497 wndClass.hbrBackground = CreateSolidBrush(RGB(0,128,0));
4499 wndClass.lpszClassName = REBARCLASSNAMEA;
4501 RegisterClassA (&wndClass);
4503 mindragx = GetSystemMetrics (SM_CXDRAG);
4504 mindragy = GetSystemMetrics (SM_CYDRAG);
4510 REBAR_Unregister (void)
4512 UnregisterClassA (REBARCLASSNAMEA, (HINSTANCE)NULL);