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 8d
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.
119 * 2. Following still not handled: RBBS_FIXEDBMP,
120 * RBBS_USECHEVRON, CCS_NORESIZE,
121 * CCS_NOMOVEX, CCS_NOMOVEY
122 * 3. Following are only partially handled:
123 * RBS_AUTOSIZE, RBBS_VARIABLEHEIGHT
124 * 5. Native uses (on each draw!!) SM_CYBORDER (or SM_CXBORDER for CCS_VERT)
125 * to set the size of the separator width (the value SEP_WIDTH_SIZE
126 * in here). Should be fixed!!
127 * 6. The following messages are not implemented:
128 * RB_BEGINDRAG, RB_DRAGMOVE, RB_ENDDRAG, RB_GETCOLORSCHEME,
129 * RB_GETDROPTARGET, RB_MAXIMIZEBAND,
130 * RB_SETCOLORSCHEME, RB_SETPALETTE, RB_SETTOOLTIPS
131 * WM_CHARTOITEM, WM_LBUTTONDBLCLK, WM_MEASUREITEM,
132 * WM_PALETTECHANGED, WM_PRINTCLIENT, WM_QUERYNEWPALETTE,
133 * WM_RBUTTONDOWN, WM_RBUTTONUP,
134 * WM_SYSCOLORCHANGE, WM_VKEYTOITEM, WM_WININICHANGE
135 * 7. The following notifications are not implemented:
136 * NM_CUSTOMDRAW, NM_RELEASEDCAPTURE
137 * RB_CHEVRONPUSHED, RBN_MINMAX
145 #include "wine/unicode.h"
146 #include "commctrl.h"
147 /* #include "spy.h" */
148 #include "wine/debug.h"
150 WINE_DEFAULT_DEBUG_CHANNEL(rebar);
160 UINT cxMinChild; /* valid if _CHILDSIZE */
161 UINT cyMinChild; /* valid if _CHILDSIZE */
162 UINT cx; /* valid if _SIZE */
165 UINT cyChild; /* valid if _CHILDSIZE */
166 UINT cyMaxChild; /* valid if _CHILDSIZE */
167 UINT cyIntegral; /* valid if _CHILDSIZE */
172 UINT lcx; /* minimum cx for band */
173 UINT ccx; /* current cx for band */
174 UINT hcx; /* maximum cx for band */
175 UINT lcy; /* minimum cy for band */
176 UINT ccy; /* current cy for band */
177 UINT hcy; /* maximum cy for band */
179 SIZE offChild; /* x,y offset if child is not FIXEDSIZE */
181 INT iRow; /* row this band assigned to */
182 UINT fStatus; /* status flags, reset only by _Validate */
183 UINT fDraw; /* drawing flags, reset only by _Layout */
184 UINT uCDret; /* last return from NM_CUSTOMDRAW */
185 RECT rcoldBand; /* previous calculated band rectangle */
186 RECT rcBand; /* calculated band rectangle */
187 RECT rcGripper; /* calculated gripper rectangle */
188 RECT rcCapImage; /* calculated caption image rectangle */
189 RECT rcCapText; /* calculated caption text rectangle */
190 RECT rcChild; /* calculated child rectangle */
197 #define HAS_GRIPPER 0x00000001
198 #define HAS_IMAGE 0x00000002
199 #define HAS_TEXT 0x00000004
202 #define DRAW_GRIPPER 0x00000001
203 #define DRAW_IMAGE 0x00000002
204 #define DRAW_TEXT 0x00000004
205 #define DRAW_RIGHTSEP 0x00000010
206 #define DRAW_BOTTOMSEP 0x00000020
207 #define NTF_INVALIDATE 0x01000000
211 INT istartband; /* index of first band in row */
212 INT iendband; /* index of last band in row */
218 COLORREF clrBk; /* background color */
219 COLORREF clrText; /* text color */
220 COLORREF clrBtnText; /* system color for BTNTEXT */
221 COLORREF clrBtnFace; /* system color for BTNFACE */
222 HIMAGELIST himl; /* handle to imagelist */
223 UINT uNumBands; /* # of bands in rebar (first=0, last=uNumBands-1 */
224 UINT uNumRows; /* # of rows of bands (first=1, last=uNumRows */
225 HWND hwndSelf; /* handle of REBAR window itself */
226 HWND hwndToolTip; /* handle to the tool tip control */
227 HWND hwndNotify; /* notification window (parent) */
229 HFONT hFont; /* handle to the rebar's font */
230 SIZE imageSize; /* image size (image list) */
231 DWORD dwStyle; /* window style */
232 SIZE calcSize; /* calculated rebar size */
233 SIZE oldSize; /* previous calculated rebar size */
234 BOOL bUnicode; /* TRUE if this window is W type */
235 BOOL NtfUnicode; /* TRUE if parent wants notify in W format */
236 BOOL DoRedraw; /* TRUE to acutally draw bands */
237 UINT fStatus; /* Status flags (see below) */
238 HCURSOR hcurArrow; /* handle to the arrow cursor */
239 HCURSOR hcurHorz; /* handle to the EW cursor */
240 HCURSOR hcurVert; /* handle to the NS cursor */
241 HCURSOR hcurDrag; /* handle to the drag cursor */
242 INT iVersion; /* version number */
243 POINTS dragStart; /* x,y of button down */
244 POINTS dragNow; /* x,y of this MouseMove */
245 INT ihitBand; /* band number of band whose gripper was grabbed */
246 INT ihitoffset; /* offset of hotspot from gripper.left */
247 POINT origin; /* left/upper corner of client */
249 REBAR_ROW *rows; /* pointer to row indexes */
250 REBAR_BAND *bands; /* pointer to the array of rebar bands */
254 #define BEGIN_DRAG_ISSUED 0x00000001
255 #define AUTO_RESIZE 0x00000002
256 #define RESIZE_ANYHOW 0x00000004
257 #define NTF_HGHTCHG 0x00000008
258 #define BAND_NEEDS_LAYOUT 0x00000010
259 #define BAND_NEEDS_REDRAW 0x00000020
260 #define CREATE_RUNNING 0x00000040
262 /* ---- REBAR layout constants. Mostly determined by ---- */
263 /* ---- experiment on WIN 98. ---- */
265 /* Width (or height) of separators between bands (either horz. or */
266 /* vert.). True only if RBS_BANDBORDERS is set */
267 #define SEP_WIDTH_SIZE 2
268 #define SEP_WIDTH ((infoPtr->dwStyle & RBS_BANDBORDERS) ? SEP_WIDTH_SIZE : 0)
270 /* Blank (background color) space between Gripper (if present) */
271 /* and next item (image, text, or window). Always present */
272 #define REBAR_ALWAYS_SPACE 4
274 /* Blank (background color) space after Image (if present). */
275 #define REBAR_POST_IMAGE 2
277 /* Blank (background color) space after Text (if present). */
278 #define REBAR_POST_TEXT 4
280 /* Height of vertical gripper in a CCS_VERT rebar. */
281 #define GRIPPER_HEIGHT 16
283 /* Blank (background color) space before Gripper (if present). */
284 #define REBAR_PRE_GRIPPER 2
286 /* Width (of normal vertical gripper) or height (of horz. gripper) */
288 #define GRIPPER_WIDTH 3
290 /* Height of divider for Rebar if not disabled (CCS_NODIVIDER) */
291 /* either top or bottom */
292 #define REBAR_DIVIDER 2
294 /* This is the increment that is used over the band height */
295 #define REBARSPACE(a) ((a->fStyle & RBBS_CHILDEDGE) ? 2*REBAR_DIVIDER : 0)
297 /* ---- End of REBAR layout constants. ---- */
300 /* The following 6 defines return the proper rcBand element */
301 /* depending on whether CCS_VERT was set. */
302 #define rcBlt(b) ((infoPtr->dwStyle & CCS_VERT) ? b->rcBand.top : b->rcBand.left)
303 #define rcBrb(b) ((infoPtr->dwStyle & CCS_VERT) ? b->rcBand.bottom : b->rcBand.right)
304 #define rcBw(b) ((infoPtr->dwStyle & CCS_VERT) ? (b->rcBand.bottom - b->rcBand.top) : \
305 (b->rcBand.right - b->rcBand.left))
306 #define ircBlt(b) ((infoPtr->dwStyle & CCS_VERT) ? b->rcBand.left : b->rcBand.top)
307 #define ircBrb(b) ((infoPtr->dwStyle & CCS_VERT) ? b->rcBand.right : b->rcBand.bottom)
308 #define ircBw(b) ((infoPtr->dwStyle & CCS_VERT) ? (b->rcBand.right - b->rcBand.left) : \
309 (b->rcBand.bottom - b->rcBand.top))
311 /* The following define determines if a given band is hidden */
312 #define HIDDENBAND(a) (((a)->fStyle & RBBS_HIDDEN) || \
313 ((infoPtr->dwStyle & CCS_VERT) && \
314 ((a)->fStyle & RBBS_NOVERT)))
316 /* The following defines adjust the right or left end of a rectangle */
317 #define READJ(b,i) {if(infoPtr->dwStyle & CCS_VERT) b->rcBand.bottom+=(i); \
318 else b->rcBand.right += (i);}
319 #define LEADJ(b,i) {if(infoPtr->dwStyle & CCS_VERT) b->rcBand.top+=(i); \
320 else b->rcBand.left += (i);}
323 #define REBAR_GetInfoPtr(wndPtr) ((REBAR_INFO *)GetWindowLongA (hwnd, 0))
326 /* "constant values" retrieved when DLL was initialized */
327 /* FIXME we do this when the classes are registered. */
328 static UINT mindragx = 0;
329 static UINT mindragy = 0;
331 static char *band_stylename[] = {
332 "RBBS_BREAK", /* 0001 */
333 "RBBS_FIXEDSIZE", /* 0002 */
334 "RBBS_CHILDEDGE", /* 0004 */
335 "RBBS_HIDDEN", /* 0008 */
336 "RBBS_NOVERT", /* 0010 */
337 "RBBS_FIXEDBMP", /* 0020 */
338 "RBBS_VARIABLEHEIGHT", /* 0040 */
339 "RBBS_GRIPPERALWAYS", /* 0080 */
340 "RBBS_NOGRIPPER", /* 0100 */
343 static char *band_maskname[] = {
344 "RBBIM_STYLE", /* 0x00000001 */
345 "RBBIM_COLORS", /* 0x00000002 */
346 "RBBIM_TEXT", /* 0x00000004 */
347 "RBBIM_IMAGE", /* 0x00000008 */
348 "RBBIM_CHILD", /* 0x00000010 */
349 "RBBIM_CHILDSIZE", /* 0x00000020 */
350 "RBBIM_SIZE", /* 0x00000040 */
351 "RBBIM_BACKGROUND", /* 0x00000080 */
352 "RBBIM_ID", /* 0x00000100 */
353 "RBBIM_IDEALSIZE", /* 0x00000200 */
354 "RBBIM_LPARAM", /* 0x00000400 */
355 "RBBIM_HEADERSIZE", /* 0x00000800 */
359 static CHAR line[200];
363 REBAR_FmtStyle( UINT style)
368 while (band_stylename[i]) {
369 if (style & (1<<i)) {
370 if (*line != 0) strcat(line, " | ");
371 strcat(line, band_stylename[i]);
380 REBAR_FmtMask( UINT mask)
385 while (band_maskname[i]) {
387 if (*line != 0) strcat(line, " | ");
388 strcat(line, band_maskname[i]);
397 REBAR_DumpBandInfo( LPREBARBANDINFOA pB)
399 if( !TRACE_ON(rebar) ) return;
400 TRACE("band info: ID=%u, size=%u, child=%04x, clrF=0x%06lx, clrB=0x%06lx\n",
401 pB->wID, pB->cbSize, pB->hwndChild, pB->clrFore, pB->clrBack);
402 TRACE("band info: mask=0x%08x (%s)\n", pB->fMask, REBAR_FmtMask(pB->fMask));
403 if (pB->fMask & RBBIM_STYLE)
404 TRACE("band info: style=0x%08x (%s)\n", pB->fStyle, REBAR_FmtStyle(pB->fStyle));
405 if (pB->fMask & (RBBIM_SIZE | RBBIM_IDEALSIZE | RBBIM_HEADERSIZE | RBBIM_LPARAM )) {
407 if (pB->fMask & RBBIM_SIZE)
408 DPRINTF(" cx=%u", pB->cx);
409 if (pB->fMask & RBBIM_IDEALSIZE)
410 DPRINTF(" xIdeal=%u", pB->cxIdeal);
411 if (pB->fMask & RBBIM_HEADERSIZE)
412 DPRINTF(" xHeader=%u", pB->cxHeader);
413 if (pB->fMask & RBBIM_LPARAM)
414 DPRINTF(" lParam=0x%08lx", pB->lParam);
417 if (pB->fMask & RBBIM_CHILDSIZE)
418 TRACE("band info: xMin=%u, yMin=%u, yChild=%u, yMax=%u, yIntgl=%u\n",
420 pB->cyMinChild, pB->cyChild, pB->cyMaxChild, pB->cyIntegral);
424 REBAR_DumpBand (REBAR_INFO *iP)
429 if(! TRACE_ON(rebar) ) return;
431 TRACE("hwnd=%04x: color=%08lx/%08lx, bands=%u, rows=%u, cSize=%ld,%ld\n",
432 iP->hwndSelf, iP->clrText, iP->clrBk, iP->uNumBands, iP->uNumRows,
433 iP->calcSize.cx, iP->calcSize.cy);
434 TRACE("hwnd=%04x: flags=%08x, dragStart=%d,%d, dragNow=%d,%d, ihitBand=%d\n",
435 iP->hwndSelf, iP->fStatus, iP->dragStart.x, iP->dragStart.y,
436 iP->dragNow.x, iP->dragNow.y,
438 TRACE("hwnd=%04x: style=%08lx, I'm Unicode=%s, notify in Unicode=%s, redraw=%s\n",
439 iP->hwndSelf, iP->dwStyle, (iP->bUnicode)?"TRUE":"FALSE",
440 (iP->NtfUnicode)?"TRUE":"FALSE", (iP->DoRedraw)?"TRUE":"FALSE");
441 for (i = 0; i < iP->uNumBands; i++) {
443 TRACE("band # %u: ID=%u, child=%04x, row=%u, clrF=0x%06lx, clrB=0x%06lx\n",
444 i, pB->wID, pB->hwndChild, pB->iRow, pB->clrFore, pB->clrBack);
445 TRACE("band # %u: mask=0x%08x (%s)\n", i, pB->fMask, REBAR_FmtMask(pB->fMask));
446 if (pB->fMask & RBBIM_STYLE)
447 TRACE("band # %u: style=0x%08x (%s)\n",
448 i, pB->fStyle, REBAR_FmtStyle(pB->fStyle));
449 TRACE("band # %u: uMinH=%u xHeader=%u",
450 i, pB->uMinHeight, pB->cxHeader);
451 if (pB->fMask & (RBBIM_SIZE | RBBIM_IDEALSIZE | RBBIM_LPARAM )) {
452 if (pB->fMask & RBBIM_SIZE)
453 DPRINTF(" cx=%u", pB->cx);
454 if (pB->fMask & RBBIM_IDEALSIZE)
455 DPRINTF(" xIdeal=%u", pB->cxIdeal);
456 if (pB->fMask & RBBIM_LPARAM)
457 DPRINTF(" lParam=0x%08lx", pB->lParam);
461 TRACE("band # %u: xMin=%u, yMin=%u, yChild=%u, yMax=%u, yIntgl=%u\n",
462 i, pB->cxMinChild, pB->cyMinChild, pB->cyChild, pB->cyMaxChild, pB->cyIntegral);
463 if (pB->fMask & RBBIM_TEXT)
464 TRACE("band # %u: text=%s\n",
465 i, (pB->lpText) ? debugstr_w(pB->lpText) : "(null)");
466 TRACE("band # %u: lcx=%u, ccx=%u, hcx=%u, lcy=%u, ccy=%u, hcy=%u, offChild=%ld,%ld\n",
467 i, pB->lcx, pB->ccx, pB->hcx, pB->lcy, pB->ccy, pB->hcy, pB->offChild.cx, pB->offChild.cy);
468 TRACE("band # %u: fStatus=%08x, fDraw=%08x, Band=(%d,%d)-(%d,%d), Grip=(%d,%d)-(%d,%d)\n",
469 i, pB->fStatus, pB->fDraw,
470 pB->rcBand.left, pB->rcBand.top, pB->rcBand.right, pB->rcBand.bottom,
471 pB->rcGripper.left, pB->rcGripper.top, pB->rcGripper.right, pB->rcGripper.bottom);
472 TRACE("band # %u: Img=(%d,%d)-(%d,%d), Txt=(%d,%d)-(%d,%d), Child=(%d,%d)-(%d,%d)\n",
474 pB->rcCapImage.left, pB->rcCapImage.top, pB->rcCapImage.right, pB->rcCapImage.bottom,
475 pB->rcCapText.left, pB->rcCapText.top, pB->rcCapText.right, pB->rcCapText.bottom,
476 pB->rcChild.left, pB->rcChild.top, pB->rcChild.right, pB->rcChild.bottom);
483 REBAR_GetNotifyParent (REBAR_INFO *infoPtr)
487 parent = infoPtr->hwndNotify;
489 parent = GetParent (infoPtr->hwndSelf);
490 owner = GetWindow (infoPtr->hwndSelf, GW_OWNER);
491 if (owner) parent = owner;
498 REBAR_Notify (NMHDR *nmhdr, REBAR_INFO *infoPtr, UINT code)
502 parent = REBAR_GetNotifyParent (infoPtr);
503 nmhdr->idFrom = GetDlgCtrlID (infoPtr->hwndSelf);
504 nmhdr->hwndFrom = infoPtr->hwndSelf;
507 TRACE("window %04x, code=%08x, %s\n", parent, code,
508 (infoPtr->NtfUnicode) ? "via Unicode" : "via ANSI");
510 if (infoPtr->NtfUnicode)
511 return SendMessageW (parent, WM_NOTIFY, (WPARAM) nmhdr->idFrom,
514 return SendMessageA (parent, WM_NOTIFY, (WPARAM) nmhdr->idFrom,
519 REBAR_Notify_NMREBAR (REBAR_INFO *infoPtr, UINT uBand, UINT code)
521 NMREBAR notify_rebar;
524 notify_rebar.dwMask = 0;
526 lpBand = &infoPtr->bands[uBand];
527 if (lpBand->fMask & RBBIM_ID) {
528 notify_rebar.dwMask |= RBNM_ID;
529 notify_rebar.wID = lpBand->wID;
531 if (lpBand->fMask & RBBIM_LPARAM) {
532 notify_rebar.dwMask |= RBNM_LPARAM;
533 notify_rebar.lParam = lpBand->lParam;
535 if (lpBand->fMask & RBBIM_STYLE) {
536 notify_rebar.dwMask |= RBNM_STYLE;
537 notify_rebar.fStyle = lpBand->fStyle;
540 notify_rebar.uBand = uBand;
541 return REBAR_Notify ((NMHDR *)¬ify_rebar, infoPtr, code);
545 REBAR_DrawBand (HDC hdc, REBAR_INFO *infoPtr, REBAR_BAND *lpBand)
551 if (lpBand->fDraw & DRAW_TEXT) {
552 hOldFont = SelectObject (hdc, infoPtr->hFont);
553 oldBkMode = SetBkMode (hdc, TRANSPARENT);
556 /* should test for CDRF_NOTIFYITEMDRAW here */
557 nmcd.dwDrawStage = CDDS_ITEMPREPAINT;
559 nmcd.rc = lpBand->rcBand;
560 nmcd.rc.right = lpBand->rcCapText.right;
561 nmcd.rc.bottom = lpBand->rcCapText.bottom;
562 nmcd.dwItemSpec = lpBand->wID;
564 nmcd.lItemlParam = lpBand->lParam;
565 lpBand->uCDret = REBAR_Notify ((NMHDR *)&nmcd, infoPtr, NM_CUSTOMDRAW);
566 if (lpBand->uCDret == CDRF_SKIPDEFAULT) {
567 if (oldBkMode != TRANSPARENT)
568 SetBkMode (hdc, oldBkMode);
569 SelectObject (hdc, hOldFont);
574 if (lpBand->fDraw & DRAW_GRIPPER)
575 DrawEdge (hdc, &lpBand->rcGripper, BDR_RAISEDINNER, BF_RECT | BF_MIDDLE);
577 /* draw caption image */
578 if (lpBand->fDraw & DRAW_IMAGE) {
582 pt.y = (lpBand->rcCapImage.bottom + lpBand->rcCapImage.top - infoPtr->imageSize.cy)/2;
583 pt.x = (lpBand->rcCapImage.right + lpBand->rcCapImage.left - infoPtr->imageSize.cx)/2;
585 ImageList_Draw (infoPtr->himl, lpBand->iImage, hdc,
590 /* draw caption text */
591 if (lpBand->fDraw & DRAW_TEXT) {
592 /* need to handle CDRF_NEWFONT here */
593 INT oldBkMode = SetBkMode (hdc, TRANSPARENT);
594 COLORREF oldcolor = CLR_NONE;
596 if (lpBand->clrFore != CLR_NONE) {
597 new = (lpBand->clrFore == CLR_DEFAULT) ? infoPtr->clrBtnText :
599 oldcolor = SetTextColor (hdc, new);
601 DrawTextW (hdc, lpBand->lpText, -1, &lpBand->rcCapText,
602 DT_CENTER | DT_VCENTER | DT_SINGLELINE);
603 if (oldBkMode != TRANSPARENT)
604 SetBkMode (hdc, oldBkMode);
605 if (lpBand->clrFore != CLR_NONE)
606 SetTextColor (hdc, oldcolor);
607 SelectObject (hdc, hOldFont);
610 if (lpBand->uCDret == (CDRF_NOTIFYPOSTPAINT | CDRF_NOTIFYITEMDRAW)) {
611 nmcd.dwDrawStage = CDDS_ITEMPOSTPAINT;
613 nmcd.rc = lpBand->rcBand;
614 nmcd.rc.right = lpBand->rcCapText.right;
615 nmcd.rc.bottom = lpBand->rcCapText.bottom;
616 nmcd.dwItemSpec = lpBand->wID;
618 nmcd.lItemlParam = lpBand->lParam;
619 lpBand->uCDret = REBAR_Notify ((NMHDR *)&nmcd, infoPtr, NM_CUSTOMDRAW);
625 REBAR_Refresh (REBAR_INFO *infoPtr, HDC hdc)
630 if (!infoPtr->DoRedraw) return;
632 oldrow = infoPtr->bands[0].iRow;
633 for (i = 0; i < infoPtr->uNumBands; i++) {
634 lpBand = &infoPtr->bands[i];
636 if (HIDDENBAND(lpBand)) continue;
638 /* now draw the band */
639 TRACE("[%04x] drawing band %i, flags=%08x\n",
640 infoPtr->hwndSelf, i, lpBand->fDraw);
641 REBAR_DrawBand (hdc, infoPtr, lpBand);
648 REBAR_FixVert (REBAR_INFO *infoPtr, UINT rowstart, UINT rowend,
651 /* Cycle through bands in row and fix height of each band. */
652 /* Also determine whether each band has changed. */
654 /* all bands at desired size. */
655 /* start and end bands are *not* hidden */
660 for (i = (INT)rowstart; i<=(INT)rowend; i++) {
661 lpBand = &infoPtr->bands[i];
662 if (HIDDENBAND(lpBand)) continue;
664 /* adjust height of bands in row to "mcy" value */
665 if (infoPtr->dwStyle & CCS_VERT) {
666 if (lpBand->rcBand.right != lpBand->rcBand.left + mcy)
667 lpBand->rcBand.right = lpBand->rcBand.left + mcy;
670 if (lpBand->rcBand.bottom != lpBand->rcBand.top + mcy)
671 lpBand->rcBand.bottom = lpBand->rcBand.top + mcy;
675 /* mark whether we need to invalidate this band and trace */
676 if ((lpBand->rcoldBand.left !=lpBand->rcBand.left) ||
677 (lpBand->rcoldBand.top !=lpBand->rcBand.top) ||
678 (lpBand->rcoldBand.right !=lpBand->rcBand.right) ||
679 (lpBand->rcoldBand.bottom !=lpBand->rcBand.bottom)) {
680 lpBand->fDraw |= NTF_INVALIDATE;
681 TRACE("band %d row=%d: changed to (%d,%d)-(%d,%d) from (%d,%d)-(%d,%d)\n",
683 lpBand->rcBand.left, lpBand->rcBand.top,
684 lpBand->rcBand.right, lpBand->rcBand.bottom,
685 lpBand->rcoldBand.left, lpBand->rcoldBand.top,
686 lpBand->rcoldBand.right, lpBand->rcoldBand.bottom);
689 TRACE("band %d row=%d: unchanged (%d,%d)-(%d,%d)\n",
691 lpBand->rcBand.left, lpBand->rcBand.top,
692 lpBand->rcBand.right, lpBand->rcBand.bottom);
698 REBAR_AdjustBands (REBAR_INFO *infoPtr, UINT rowstart, UINT rowend,
700 /* Function: This routine distributes the extra space in a row. */
701 /* See algorithm below. */
703 /* all bands @ ->cxHeader size */
704 /* start and end bands are *not* hidden */
707 UINT x, xsep, extra, curwidth, fudge;
708 INT i, last_adjusted;
710 TRACE("start=%u, end=%u, max x=%d, max y=%d\n",
711 rowstart, rowend, maxx, mcy);
713 /* ******************* Phase 1 ************************ */
715 /* For each visible band with valid child */
716 /* a. inflate band till either all extra space used */
717 /* or band's ->ccx reached. */
718 /* If any band modified, add any space left to last band */
721 /* ****************************************************** */
722 lpBand = &infoPtr->bands[rowend];
723 extra = maxx - rcBrb(lpBand);
726 for (i=(INT)rowstart; i<=(INT)rowend; i++) {
727 lpBand = &infoPtr->bands[i];
728 if (HIDDENBAND(lpBand)) continue;
729 xsep = (x == 0) ? 0 : SEP_WIDTH;
730 curwidth = rcBw(lpBand);
732 /* set new left/top point */
733 if (infoPtr->dwStyle & CCS_VERT)
734 lpBand->rcBand.top = x + xsep;
736 lpBand->rcBand.left = x + xsep;
738 /* compute new width */
739 if ((lpBand->hwndChild && extra) && !(lpBand->fStyle & RBBS_FIXEDSIZE)) {
740 /* set to the "current" band size less the header */
743 if ((lpBand->fMask & RBBIM_SIZE) && (lpBand->cx > 0) &&
744 (fudge > curwidth)) {
745 TRACE("adjusting band %d by %d, fudge=%d, curwidth=%d, extra=%d\n",
746 i, fudge-curwidth, fudge, curwidth, extra);
747 if ((fudge - curwidth) > extra)
748 fudge = curwidth + extra;
749 extra -= (fudge - curwidth);
753 TRACE("adjusting band %d by %d, fudge=%d, curwidth=%d\n",
754 i, extra, fudge, curwidth);
760 /* set new right/bottom point */
761 if (infoPtr->dwStyle & CCS_VERT)
762 lpBand->rcBand.bottom = lpBand->rcBand.top + curwidth;
764 lpBand->rcBand.right = lpBand->rcBand.left + curwidth;
765 TRACE("Phase 1 band %d, (%d,%d)-(%d,%d), orig x=%d, xsep=%d\n",
766 i, lpBand->rcBand.left, lpBand->rcBand.top,
767 lpBand->rcBand.right, lpBand->rcBand.bottom, x, xsep);
770 if ((x >= maxx) || (last_adjusted != -1)) {
772 ERR("Phase 1 failed, x=%d, maxx=%d, start=%u, end=%u\n",
773 x, maxx, rowstart, rowend);
775 /* done, so spread extra space */
778 TRACE("Need to spread %d on last adjusted band %d\n",
779 fudge, last_adjusted);
780 for (i=(INT)last_adjusted; i<=(INT)rowend; i++) {
781 lpBand = &infoPtr->bands[i];
782 if (HIDDENBAND(lpBand)) continue;
784 /* set right/bottom point */
785 if (i != last_adjusted) {
786 if (infoPtr->dwStyle & CCS_VERT)
787 lpBand->rcBand.top += fudge;
789 lpBand->rcBand.left += fudge;
792 /* set left/bottom point */
793 if (infoPtr->dwStyle & CCS_VERT)
794 lpBand->rcBand.bottom += fudge;
796 lpBand->rcBand.right += fudge;
799 TRACE("Phase 1 succeeded, used x=%d\n", x);
800 REBAR_FixVert (infoPtr, rowstart, rowend, mcy);
804 /* ******************* Phase 2 ************************ */
806 /* Find first visible band, put all */
807 /* extra space there. */
809 /* ****************************************************** */
812 for (i=(INT)rowstart; i<=(INT)rowend; i++) {
813 lpBand = &infoPtr->bands[i];
814 if (HIDDENBAND(lpBand)) continue;
815 xsep = (x == 0) ? 0 : SEP_WIDTH;
816 curwidth = rcBw(lpBand);
818 /* set new left/top point */
819 if (infoPtr->dwStyle & CCS_VERT)
820 lpBand->rcBand.top = x + xsep;
822 lpBand->rcBand.left = x + xsep;
824 /* compute new width */
830 /* set new right/bottom point */
831 if (infoPtr->dwStyle & CCS_VERT)
832 lpBand->rcBand.bottom = lpBand->rcBand.top + curwidth;
834 lpBand->rcBand.right = lpBand->rcBand.left + curwidth;
835 TRACE("Phase 2 band %d, (%d,%d)-(%d,%d), orig x=%d, xsep=%d\n",
836 i, lpBand->rcBand.left, lpBand->rcBand.top,
837 lpBand->rcBand.right, lpBand->rcBand.bottom, x, xsep);
842 ERR("Phase 2 failed, x=%d, maxx=%d, start=%u, end=%u\n",
843 x, maxx, rowstart, rowend);
845 /* done, so spread extra space */
846 TRACE("Phase 2 succeeded, used x=%d\n", x);
847 REBAR_FixVert (infoPtr, rowstart, rowend, mcy);
851 /* ******************* Phase 3 ************************ */
852 /* at this point everything is back to ->cxHeader values */
853 /* and should not have gotten here. */
854 /* ****************************************************** */
856 lpBand = &infoPtr->bands[rowstart];
857 ERR("Serious problem adjusting row %d, start band %d, end band %d\n",
858 lpBand->iRow, rowstart, rowend);
859 REBAR_DumpBand (infoPtr);
865 REBAR_CalcHorzBand (REBAR_INFO *infoPtr, UINT rstart, UINT rend, BOOL notify)
866 /* Function: this routine initializes all the rectangles in */
867 /* each band in a row to fit in the adjusted rcBand rect. */
868 /* *** Supports only Horizontal bars. *** */
875 /* MS seems to use GetDlgCtrlID() for above GetWindowLong call */
876 parenthwnd = GetParent (infoPtr->hwndSelf);
878 for(i=rstart; i<rend; i++){
879 lpBand = &infoPtr->bands[i];
880 if (HIDDENBAND(lpBand)) {
881 SetRect (&lpBand->rcChild,
882 lpBand->rcBand.right, lpBand->rcBand.top,
883 lpBand->rcBand.right, lpBand->rcBand.bottom);
887 oldChild = lpBand->rcChild;
889 /* set initial gripper rectangle */
890 SetRect (&lpBand->rcGripper, lpBand->rcBand.left, lpBand->rcBand.top,
891 lpBand->rcBand.left, lpBand->rcBand.bottom);
893 /* calculate gripper rectangle */
894 if ( lpBand->fStatus & HAS_GRIPPER) {
895 lpBand->fDraw |= DRAW_GRIPPER;
896 lpBand->rcGripper.left += REBAR_PRE_GRIPPER;
897 lpBand->rcGripper.right = lpBand->rcGripper.left + GRIPPER_WIDTH;
898 lpBand->rcGripper.top += 2;
899 lpBand->rcGripper.bottom -= 2;
901 SetRect (&lpBand->rcCapImage,
902 lpBand->rcGripper.right+REBAR_ALWAYS_SPACE, lpBand->rcBand.top,
903 lpBand->rcGripper.right+REBAR_ALWAYS_SPACE, lpBand->rcBand.bottom);
905 else { /* no gripper will be drawn */
907 if (lpBand->fStatus & (HAS_IMAGE | HAS_TEXT))
908 /* if no gripper but either image or text, then leave space */
909 xoff = REBAR_ALWAYS_SPACE;
910 SetRect (&lpBand->rcCapImage,
911 lpBand->rcBand.left+xoff, lpBand->rcBand.top,
912 lpBand->rcBand.left+xoff, lpBand->rcBand.bottom);
915 /* image is visible */
916 if (lpBand->fStatus & HAS_IMAGE) {
917 lpBand->fDraw |= DRAW_IMAGE;
918 lpBand->rcCapImage.right += infoPtr->imageSize.cx;
919 lpBand->rcCapImage.bottom = lpBand->rcCapImage.top + infoPtr->imageSize.cy;
921 /* set initial caption text rectangle */
922 SetRect (&lpBand->rcCapText,
923 lpBand->rcCapImage.right+REBAR_POST_IMAGE, lpBand->rcBand.top+1,
924 lpBand->rcBand.left+lpBand->cxHeader, lpBand->rcBand.bottom-1);
925 /* update band height
926 if (lpBand->uMinHeight < infoPtr->imageSize.cy + 2) {
927 lpBand->uMinHeight = infoPtr->imageSize.cy + 2;
928 lpBand->rcBand.bottom = lpBand->rcBand.top + lpBand->uMinHeight;
932 /* set initial caption text rectangle */
933 SetRect (&lpBand->rcCapText, lpBand->rcCapImage.right, lpBand->rcBand.top+1,
934 lpBand->rcBand.left+lpBand->cxHeader, lpBand->rcBand.bottom-1);
937 /* text is visible */
938 if (lpBand->fStatus & HAS_TEXT) {
939 lpBand->fDraw |= DRAW_TEXT;
940 lpBand->rcCapText.right = max(lpBand->rcCapText.left,
941 lpBand->rcCapText.right-REBAR_POST_TEXT);
944 /* set initial child window rectangle if there is a child */
945 if (lpBand->fMask & RBBIM_CHILD) {
946 xoff = lpBand->offChild.cx;
947 yoff = lpBand->offChild.cy;
948 SetRect (&lpBand->rcChild,
949 lpBand->rcBand.left+lpBand->cxHeader, lpBand->rcBand.top+yoff,
950 lpBand->rcBand.right-xoff, lpBand->rcBand.bottom-yoff);
953 SetRect (&lpBand->rcChild,
954 lpBand->rcBand.left+lpBand->cxHeader, lpBand->rcBand.top,
955 lpBand->rcBand.right, lpBand->rcBand.bottom);
958 /* flag if notify required and invalidate rectangle */
960 ((oldChild.right-oldChild.left != lpBand->rcChild.right-lpBand->rcChild.left) ||
961 (oldChild.bottom-oldChild.top != lpBand->rcChild.bottom-lpBand->rcChild.top))) {
962 TRACE("Child rectangle changed for band %u\n", i);
963 TRACE(" from (%d,%d)-(%d,%d) to (%d,%d)-(%d,%d)\n",
964 oldChild.left, oldChild.top,
965 oldChild.right, oldChild.bottom,
966 lpBand->rcChild.left, lpBand->rcChild.top,
967 lpBand->rcChild.right, lpBand->rcChild.bottom);
969 if (lpBand->fDraw & NTF_INVALIDATE) {
970 TRACE("invalidating (%d,%d)-(%d,%d)\n",
973 lpBand->rcBand.right + ((lpBand->fDraw & DRAW_RIGHTSEP) ? SEP_WIDTH_SIZE : 0),
974 lpBand->rcBand.bottom + ((lpBand->fDraw & DRAW_BOTTOMSEP) ? SEP_WIDTH_SIZE : 0));
975 lpBand->fDraw &= ~NTF_INVALIDATE;
976 work = lpBand->rcBand;
977 if (lpBand->fDraw & DRAW_RIGHTSEP) work.right += SEP_WIDTH_SIZE;
978 if (lpBand->fDraw & DRAW_BOTTOMSEP) work.bottom += SEP_WIDTH_SIZE;
979 InvalidateRect(infoPtr->hwndSelf, &work, TRUE);
988 REBAR_CalcVertBand (REBAR_INFO *infoPtr, UINT rstart, UINT rend, BOOL notify)
989 /* Function: this routine initializes all the rectangles in */
990 /* each band in a row to fit in the adjusted rcBand rect. */
991 /* *** Supports only Vertical bars. *** */
998 /* MS seems to use GetDlgCtrlID() for above GetWindowLong call */
999 parenthwnd = GetParent (infoPtr->hwndSelf);
1001 for(i=rstart; i<rend; i++){
1002 lpBand = &infoPtr->bands[i];
1003 if (HIDDENBAND(lpBand)) continue;
1004 oldChild = lpBand->rcChild;
1006 /* set initial gripper rectangle */
1007 SetRect (&lpBand->rcGripper, lpBand->rcBand.left, lpBand->rcBand.top,
1008 lpBand->rcBand.right, lpBand->rcBand.top);
1010 /* calculate gripper rectangle */
1011 if (lpBand->fStatus & HAS_GRIPPER) {
1012 lpBand->fDraw |= DRAW_GRIPPER;
1014 if (infoPtr->dwStyle & RBS_VERTICALGRIPPER) {
1015 /* vertical gripper */
1016 lpBand->rcGripper.left += 3;
1017 lpBand->rcGripper.right = lpBand->rcGripper.left + GRIPPER_WIDTH;
1018 lpBand->rcGripper.top += REBAR_PRE_GRIPPER;
1019 lpBand->rcGripper.bottom = lpBand->rcGripper.top + GRIPPER_HEIGHT;
1021 /* initialize Caption image rectangle */
1022 SetRect (&lpBand->rcCapImage, lpBand->rcBand.left,
1023 lpBand->rcGripper.bottom + REBAR_ALWAYS_SPACE,
1024 lpBand->rcBand.right,
1025 lpBand->rcGripper.bottom + REBAR_ALWAYS_SPACE);
1028 /* horizontal gripper */
1029 lpBand->rcGripper.left += 2;
1030 lpBand->rcGripper.right -= 2;
1031 lpBand->rcGripper.top += REBAR_PRE_GRIPPER;
1032 lpBand->rcGripper.bottom = lpBand->rcGripper.top + GRIPPER_WIDTH;
1034 /* initialize Caption image rectangle */
1035 SetRect (&lpBand->rcCapImage, lpBand->rcBand.left,
1036 lpBand->rcGripper.bottom + REBAR_ALWAYS_SPACE,
1037 lpBand->rcBand.right,
1038 lpBand->rcGripper.bottom + REBAR_ALWAYS_SPACE);
1041 else { /* no gripper will be drawn */
1043 if (lpBand->fStatus & (HAS_IMAGE | HAS_TEXT))
1044 /* if no gripper but either image or text, then leave space */
1045 xoff = REBAR_ALWAYS_SPACE;
1046 /* initialize Caption image rectangle */
1047 SetRect (&lpBand->rcCapImage,
1048 lpBand->rcBand.left, lpBand->rcBand.top+xoff,
1049 lpBand->rcBand.right, lpBand->rcBand.top+xoff);
1052 /* image is visible */
1053 if (lpBand->fStatus & HAS_IMAGE) {
1054 lpBand->fDraw |= DRAW_IMAGE;
1056 lpBand->rcCapImage.right = lpBand->rcCapImage.left + infoPtr->imageSize.cx;
1057 lpBand->rcCapImage.bottom += infoPtr->imageSize.cy;
1059 /* set initial caption text rectangle */
1060 SetRect (&lpBand->rcCapText,
1061 lpBand->rcBand.left, lpBand->rcCapImage.bottom+REBAR_POST_IMAGE,
1062 lpBand->rcBand.right, lpBand->rcBand.top+lpBand->cxHeader);
1063 /* update band height *
1064 if (lpBand->uMinHeight < infoPtr->imageSize.cx + 2) {
1065 lpBand->uMinHeight = infoPtr->imageSize.cx + 2;
1066 lpBand->rcBand.right = lpBand->rcBand.left + lpBand->uMinHeight;
1070 /* set initial caption text rectangle */
1071 SetRect (&lpBand->rcCapText,
1072 lpBand->rcBand.left, lpBand->rcCapImage.bottom,
1073 lpBand->rcBand.right, lpBand->rcBand.top+lpBand->cxHeader);
1076 /* text is visible */
1077 if (lpBand->fStatus & HAS_TEXT) {
1078 lpBand->fDraw |= DRAW_TEXT;
1079 lpBand->rcCapText.bottom = max(lpBand->rcCapText.top,
1080 lpBand->rcCapText.bottom);
1083 /* set initial child window rectangle if there is a child */
1084 if (lpBand->fMask & RBBIM_CHILD) {
1085 yoff = lpBand->offChild.cx;
1086 xoff = lpBand->offChild.cy;
1087 SetRect (&lpBand->rcChild,
1088 lpBand->rcBand.left+xoff, lpBand->rcBand.top+lpBand->cxHeader,
1089 lpBand->rcBand.right-xoff, lpBand->rcBand.bottom-yoff);
1092 SetRect (&lpBand->rcChild,
1093 lpBand->rcBand.left, lpBand->rcBand.top+lpBand->cxHeader,
1094 lpBand->rcBand.right, lpBand->rcBand.bottom);
1097 /* flag if notify required and invalidate rectangle */
1099 ((oldChild.right-oldChild.left != lpBand->rcChild.right-lpBand->rcChild.left) ||
1100 (oldChild.bottom-oldChild.top != lpBand->rcChild.bottom-lpBand->rcChild.top))) {
1101 TRACE("Child rectangle changed for band %u\n", i);
1102 TRACE(" from (%d,%d)-(%d,%d) to (%d,%d)-(%d,%d)\n",
1103 oldChild.left, oldChild.top,
1104 oldChild.right, oldChild.bottom,
1105 lpBand->rcChild.left, lpBand->rcChild.top,
1106 lpBand->rcChild.right, lpBand->rcChild.bottom);
1108 if (lpBand->fDraw & NTF_INVALIDATE) {
1109 TRACE("invalidating (%d,%d)-(%d,%d)\n",
1110 lpBand->rcBand.left,
1112 lpBand->rcBand.right + ((lpBand->fDraw & DRAW_BOTTOMSEP) ? SEP_WIDTH_SIZE : 0),
1113 lpBand->rcBand.bottom + ((lpBand->fDraw & DRAW_RIGHTSEP) ? SEP_WIDTH_SIZE : 0));
1114 lpBand->fDraw &= ~NTF_INVALIDATE;
1115 work = lpBand->rcBand;
1116 if (lpBand->fDraw & DRAW_RIGHTSEP) work.bottom += SEP_WIDTH_SIZE;
1117 if (lpBand->fDraw & DRAW_BOTTOMSEP) work.right += SEP_WIDTH_SIZE;
1118 InvalidateRect(infoPtr->hwndSelf, &work, TRUE);
1126 REBAR_ForceResize (REBAR_INFO *infoPtr)
1127 /* Function: This changes the size of the REBAR window to that */
1128 /* calculated by REBAR_Layout. */
1131 INT x, y, width, height;
1132 INT xedge = GetSystemMetrics(SM_CXEDGE);
1133 INT yedge = GetSystemMetrics(SM_CYEDGE);
1135 /* TEST TEST TEST */
1136 GetWindowRect (infoPtr->hwndSelf, &rc);
1137 /* END TEST END TEST END TEST */
1140 GetClientRect (infoPtr->hwndSelf, &rc);
1142 TRACE( " old [%ld x %ld], new [%ld x %ld], client [%d x %d]\n",
1143 infoPtr->oldSize.cx, infoPtr->oldSize.cy,
1144 infoPtr->calcSize.cx, infoPtr->calcSize.cy,
1145 rc.right, rc.bottom);
1147 /* If we need to shrink client, then skip size test */
1148 if ((infoPtr->calcSize.cy >= rc.bottom) &&
1149 (infoPtr->calcSize.cx >= rc.right)) {
1151 /* if size did not change then skip process */
1152 if ((infoPtr->oldSize.cx == infoPtr->calcSize.cx) &&
1153 (infoPtr->oldSize.cy == infoPtr->calcSize.cy) &&
1154 !(infoPtr->fStatus & RESIZE_ANYHOW))
1156 TRACE("skipping reset\n");
1161 infoPtr->fStatus &= ~RESIZE_ANYHOW;
1162 /* Set flag to ignore next WM_SIZE message */
1163 infoPtr->fStatus |= AUTO_RESIZE;
1170 if (infoPtr->dwStyle & WS_BORDER) {
1175 if (!(infoPtr->dwStyle & CCS_NOPARENTALIGN)) {
1176 INT mode = infoPtr->dwStyle & (CCS_VERT | CCS_TOP | CCS_BOTTOM);
1179 GetClientRect(GetParent(infoPtr->hwndSelf), &rcPcl);
1182 /* _TOP sets width to parents width */
1183 width += (rcPcl.right - rcPcl.left);
1184 height += infoPtr->calcSize.cy;
1185 x += ((infoPtr->dwStyle & WS_BORDER) ? -xedge : 0);
1186 y += ((infoPtr->dwStyle & WS_BORDER) ? -yedge : 0);
1187 y += ((infoPtr->dwStyle & CCS_NODIVIDER) ? 0 : REBAR_DIVIDER);
1190 /* FIXME: wrong wrong wrong */
1191 /* _BOTTOM sets width to parents width */
1192 width += (rcPcl.right - rcPcl.left);
1193 height += infoPtr->calcSize.cy;
1195 y = rcPcl.bottom - height + 1;
1198 /* _LEFT sets height to parents height */
1199 width += infoPtr->calcSize.cx;
1200 height += (rcPcl.bottom - rcPcl.top);
1201 x += ((infoPtr->dwStyle & WS_BORDER) ? -xedge : 0);
1202 x += ((infoPtr->dwStyle & CCS_NODIVIDER) ? 0 : REBAR_DIVIDER);
1203 y += ((infoPtr->dwStyle & WS_BORDER) ? -yedge : 0);
1206 /* FIXME: wrong wrong wrong */
1207 /* _RIGHT sets height to parents height */
1208 width += infoPtr->calcSize.cx;
1209 height += (rcPcl.bottom - rcPcl.top);
1210 x = rcPcl.right - width + 1;
1214 width += infoPtr->calcSize.cx;
1215 height += infoPtr->calcSize.cy;
1219 width += infoPtr->calcSize.cx;
1220 height += infoPtr->calcSize.cy;
1221 x = infoPtr->origin.x;
1222 y = infoPtr->origin.y;
1225 TRACE("hwnd %08x, style=%08lx, setting at (%d,%d) for (%d,%d)\n",
1226 infoPtr->hwndSelf, infoPtr->dwStyle,
1227 x, y, width, height);
1228 SetWindowPos (infoPtr->hwndSelf, 0, x, y, width, height,
1234 REBAR_MoveChildWindows (REBAR_INFO *infoPtr, UINT start, UINT endplus)
1237 CHAR szClassName[40];
1239 NMREBARCHILDSIZE rbcz;
1243 if (!(deferpos = BeginDeferWindowPos(infoPtr->uNumBands)))
1244 ERR("BeginDeferWindowPos returned NULL\n");
1246 for (i = start; i < endplus; i++) {
1247 lpBand = &infoPtr->bands[i];
1249 if (HIDDENBAND(lpBand)) continue;
1250 if (lpBand->hwndChild) {
1251 TRACE("hwndChild = %x\n", lpBand->hwndChild);
1253 /* Always geterate the RBN_CHILDSIZE even it child
1256 rbcz.wID = lpBand->wID;
1257 rbcz.rcChild = lpBand->rcChild;
1258 rbcz.rcBand = lpBand->rcBand;
1259 if (infoPtr->dwStyle & CCS_VERT)
1260 rbcz.rcBand.top += lpBand->cxHeader;
1262 rbcz.rcBand.left += lpBand->cxHeader;
1263 REBAR_Notify ((NMHDR *)&rbcz, infoPtr, RBN_CHILDSIZE);
1264 if (!EqualRect (&lpBand->rcChild, &rbcz.rcChild)) {
1265 TRACE("Child rect changed by NOTIFY for band %u\n", i);
1266 TRACE(" from (%d,%d)-(%d,%d) to (%d,%d)-(%d,%d)\n",
1267 lpBand->rcChild.left, lpBand->rcChild.top,
1268 lpBand->rcChild.right, lpBand->rcChild.bottom,
1269 rbcz.rcChild.left, rbcz.rcChild.top,
1270 rbcz.rcChild.right, rbcz.rcChild.bottom);
1271 lpBand->rcChild = rbcz.rcChild; /* *** ??? */
1274 /* native (IE4 in "Favorites" frame **1) does:
1275 * SetRect (&rc, -1, -1, -1, -1)
1276 * EqualRect (&rc,band->rc???)
1278 * CopyRect (band->rc????, &rc)
1279 * set flag outside of loop
1282 GetClassNameA (lpBand->hwndChild, szClassName, 40);
1283 if (!lstrcmpA (szClassName, "ComboBox") ||
1284 !lstrcmpA (szClassName, WC_COMBOBOXEXA)) {
1285 INT nEditHeight, yPos;
1288 /* special placement code for combo or comboex box */
1291 /* get size of edit line */
1292 GetWindowRect (lpBand->hwndChild, &rc);
1293 nEditHeight = rc.bottom - rc.top;
1294 yPos = (lpBand->rcChild.bottom + lpBand->rcChild.top - nEditHeight)/2;
1296 /* center combo box inside child area */
1297 TRACE("moving child (Combo(Ex)) %04x to (%d,%d) for (%d,%d)\n",
1299 lpBand->rcChild.left, yPos,
1300 lpBand->rcChild.right - lpBand->rcChild.left,
1302 deferpos = DeferWindowPos (deferpos, lpBand->hwndChild, HWND_TOP,
1303 lpBand->rcChild.left,
1304 /*lpBand->rcChild.top*/ yPos,
1305 lpBand->rcChild.right - lpBand->rcChild.left,
1309 ERR("DeferWindowPos returned NULL\n");
1312 TRACE("moving child (Other) %04x to (%d,%d) for (%d,%d)\n",
1314 lpBand->rcChild.left, lpBand->rcChild.top,
1315 lpBand->rcChild.right - lpBand->rcChild.left,
1316 lpBand->rcChild.bottom - lpBand->rcChild.top);
1317 deferpos = DeferWindowPos (deferpos, lpBand->hwndChild, HWND_TOP,
1318 lpBand->rcChild.left,
1319 lpBand->rcChild.top,
1320 lpBand->rcChild.right - lpBand->rcChild.left,
1321 lpBand->rcChild.bottom - lpBand->rcChild.top,
1324 ERR("DeferWindowPos returned NULL\n");
1328 if (!EndDeferWindowPos(deferpos))
1329 ERR("EndDeferWindowPos returned NULL\n");
1331 if (infoPtr->DoRedraw)
1332 UpdateWindow (infoPtr->hwndSelf);
1334 if (infoPtr->fStatus & NTF_HGHTCHG) {
1335 infoPtr->fStatus &= ~NTF_HGHTCHG;
1336 REBAR_Notify (&heightchange, infoPtr, RBN_HEIGHTCHANGE);
1339 /* native (from **1 above) does:
1340 * UpdateWindow(rebar)
1342 * RBN_HEIGHTCHANGE if necessary
1343 * if ret from any EqualRect was 0
1344 * Goto "BeginDeferWindowPos"
1351 REBAR_Layout (REBAR_INFO *infoPtr, LPRECT lpRect, BOOL notify, BOOL resetclient)
1352 /* Function: This routine is resposible for laying out all */
1353 /* the bands in a rebar. It assigns each band to a row and*/
1354 /* determines when to start a new row. */
1356 REBAR_BAND *lpBand, *prevBand;
1357 RECT rcClient, rcAdj;
1358 INT initx, inity, x, y, cx, cxsep, mmcy, mcy, clientcx, clientcy;
1359 INT adjcx, adjcy, row, rightx, bottomy, origheight;
1360 UINT i, j, rowstart, origrows, cntonrow;
1363 if (!(infoPtr->fStatus & BAND_NEEDS_LAYOUT)) {
1364 TRACE("no layout done. No band changed.\n");
1365 REBAR_DumpBand (infoPtr);
1368 infoPtr->fStatus &= ~BAND_NEEDS_LAYOUT;
1369 if (!infoPtr->DoRedraw) infoPtr->fStatus |= BAND_NEEDS_REDRAW;
1371 GetClientRect (infoPtr->hwndSelf, &rcClient);
1372 TRACE("Client is (%d,%d)-(%d,%d)\n",
1373 rcClient.left, rcClient.top, rcClient.right, rcClient.bottom);
1377 TRACE("adjustment rect is (%d,%d)-(%d,%d)\n",
1378 rcAdj.left, rcAdj.top, rcAdj.right, rcAdj.bottom);
1381 CopyRect (&rcAdj, &rcClient);
1384 clientcx = rcClient.right - rcClient.left;
1385 clientcy = rcClient.bottom - rcClient.top;
1386 adjcx = rcAdj.right - rcAdj.left;
1387 adjcy = rcAdj.bottom - rcAdj.top;
1389 TRACE("window client rect will be set to adj rect\n");
1394 if (!infoPtr->DoRedraw && (clientcx == 0) && (clientcy == 0)) {
1395 ERR("no redraw and client is zero, skip layout\n");
1396 infoPtr->fStatus |= BAND_NEEDS_LAYOUT;
1400 /* save height of original control */
1401 if (infoPtr->dwStyle & CCS_VERT)
1402 origheight = infoPtr->calcSize.cx;
1404 origheight = infoPtr->calcSize.cy;
1405 origrows = infoPtr->uNumRows;
1410 /* ******* Start Phase 1 - all bands on row at minimum size ******* */
1412 TRACE("band loop constants, clientcx=%d, clientcy=%d, adjcx=%d, adjcy=%d\n",
1413 clientcx, clientcy, adjcx, adjcy);
1423 for (i = 0; i < infoPtr->uNumBands; i++) {
1424 lpBand = &infoPtr->bands[i];
1428 if (HIDDENBAND(lpBand)) continue;
1430 lpBand->rcoldBand = lpBand->rcBand;
1432 /* Set the offset of the child window */
1433 if ((lpBand->fMask & RBBIM_CHILD) &&
1434 !(lpBand->fStyle & RBBS_FIXEDSIZE)) {
1435 lpBand->offChild.cx = 4; /* ??? */
1437 lpBand->offChild.cy = ((lpBand->fStyle & RBBS_CHILDEDGE) ? 2 : 0);
1439 /* separator from previous band */
1440 cxsep = (cntonrow == 0) ? 0 : SEP_WIDTH;
1442 /* Header: includes gripper, text, image */
1443 cx = lpBand->cxHeader;
1444 if (lpBand->fStyle & RBBS_FIXEDSIZE) cx = lpBand->lcx;
1446 if (infoPtr->dwStyle & CCS_VERT)
1447 dobreak = (y + cx + cxsep > adjcy);
1449 dobreak = (x + cx + cxsep > adjcx);
1451 /* This is the check for whether we need to start a new row */
1452 if ( ( (lpBand->fStyle & RBBS_BREAK) && (i != 0) ) ||
1453 ( ((infoPtr->dwStyle & CCS_VERT) ? (y != 0) : (x != 0)) && dobreak)) {
1455 for (j = rowstart; j < i; j++) {
1457 lpB = &infoPtr->bands[j];
1458 if (infoPtr->dwStyle & CCS_VERT) {
1459 lpB->rcBand.right = lpB->rcBand.left + mcy;
1462 lpB->rcBand.bottom = lpB->rcBand.top + mcy;
1466 TRACE("P1 Spliting to new row %d on band %u\n", row+1, i);
1467 if (infoPtr->dwStyle & CCS_VERT) {
1469 x += (mcy + SEP_WIDTH);
1473 y += (mcy + SEP_WIDTH);
1485 if (mcy < lpBand->lcy + REBARSPACE(lpBand))
1486 mcy = lpBand->lcy + REBARSPACE(lpBand);
1488 /* if boundary rect specified then limit mcy */
1490 if (infoPtr->dwStyle & CCS_VERT) {
1491 if (x+mcy > adjcx) {
1493 TRACE("P1 row %u limiting mcy=%d, adjcx=%d, x=%d\n",
1498 if (y+mcy > adjcy) {
1500 TRACE("P1 row %u limiting mcy=%d, adjcy=%d, y=%d\n",
1506 TRACE("P1 band %u, row %d, x=%d, y=%d, cxsep=%d, cx=%d\n",
1509 if (infoPtr->dwStyle & CCS_VERT) {
1510 /* bound the bottom side if we have a bounding rectangle */
1512 bottomy = (lpRect) ? min(clientcy, y+cxsep+cx) : y+cxsep+cx;
1513 lpBand->rcBand.left = x;
1514 lpBand->rcBand.right = x + min(mcy,
1515 lpBand->lcy+REBARSPACE(lpBand));
1516 lpBand->rcBand.top = min(bottomy, y + cxsep);
1517 lpBand->rcBand.bottom = bottomy;
1518 lpBand->uMinHeight = lpBand->lcy;
1522 /* bound the right side if we have a bounding rectangle */
1523 rightx = (lpRect) ? min(clientcx, x+cxsep+cx) : x+cxsep+cx;
1525 lpBand->rcBand.left = min(rightx, x + cxsep);
1526 lpBand->rcBand.right = rightx;
1527 lpBand->rcBand.top = y;
1528 lpBand->rcBand.bottom = y + min(mcy,
1529 lpBand->lcy+REBARSPACE(lpBand));
1530 lpBand->uMinHeight = lpBand->lcy;
1533 TRACE("P1 band %u, row %d, (%d,%d)-(%d,%d)\n",
1535 lpBand->rcBand.left, lpBand->rcBand.top,
1536 lpBand->rcBand.right, lpBand->rcBand.bottom);
1540 } /* for (i = 0; i < infoPtr->uNumBands... */
1542 if (infoPtr->dwStyle & CCS_VERT)
1547 for (j = rowstart; j < infoPtr->uNumBands; j++) {
1548 lpBand = &infoPtr->bands[j];
1549 if (infoPtr->dwStyle & CCS_VERT) {
1550 lpBand->rcBand.right = lpBand->rcBand.left + mcy;
1553 lpBand->rcBand.bottom = lpBand->rcBand.top + mcy;
1557 if (infoPtr->uNumBands)
1558 infoPtr->uNumRows = row;
1560 /* ******* End Phase 1 - all bands on row at minimum size ******* */
1563 /* ******* Start Phase 1a - Adjust heights for RBS_VARHEIGHT off ******* */
1566 if (!(infoPtr->dwStyle & RBS_VARHEIGHT)) {
1569 /* get the max height of all bands */
1570 for (i=0; i<infoPtr->uNumBands; i++) {
1571 lpBand = &infoPtr->bands[i];
1572 if (HIDDENBAND(lpBand)) continue;
1573 if (infoPtr->dwStyle & CCS_VERT)
1574 mmcy = max(mmcy, lpBand->rcBand.right - lpBand->rcBand.left);
1576 mmcy = max(mmcy, lpBand->rcBand.bottom - lpBand->rcBand.top);
1579 /* now adjust all rectangles by using the height found above */
1582 for (i=0; i<infoPtr->uNumBands; i++) {
1583 lpBand = &infoPtr->bands[i];
1584 if (HIDDENBAND(lpBand)) continue;
1585 if (lpBand->iRow != row)
1586 xy += (mmcy + SEP_WIDTH);
1587 if (infoPtr->dwStyle & CCS_VERT) {
1588 lpBand->rcBand.left = xy;
1589 lpBand->rcBand.right = xy + mmcy;
1592 lpBand->rcBand.top = xy;
1593 lpBand->rcBand.bottom = xy + mmcy;
1597 /* set the x/y values to the correct maximum */
1598 if (infoPtr->dwStyle & CCS_VERT)
1604 /* ******* End Phase 1a - Adjust heights for RBS_VARHEIGHT off ******* */
1607 /* ******* Start Phase 2 - split rows till adjustment height full ******* */
1609 /* assumes that the following variables contain: */
1610 /* y/x current height/width of all rows */
1612 INT i, j, prev_rh, new_rh, adj_rh, prev_idx, current_idx;
1613 REBAR_BAND *prev, *current, *walk;
1615 /* FIXME: problem # 2 */
1616 if (((infoPtr->dwStyle & CCS_VERT) ?
1618 (x < adjcx) : (y < adjcy)
1620 (adjcx - x > 4) : (adjcy - y > 4)
1623 (infoPtr->uNumBands > 1)) {
1624 for (i=(INT)infoPtr->uNumBands-2; i>=0; i--) {
1625 TRACE("P2 adjcx=%d, adjcy=%d, x=%d, y=%d\n",
1626 adjcx, adjcy, x, y);
1628 /* find the current band (starts at i+1) */
1629 current = &infoPtr->bands[i+1];
1631 while (HIDDENBAND(current)) {
1633 if (i < 0) break; /* out of bands */
1634 current = &infoPtr->bands[i+1];
1637 if (i < 0) break; /* out of bands */
1639 /* now find the prev band (starts at i) */
1640 prev = &infoPtr->bands[i];
1642 while (HIDDENBAND(prev)) {
1644 if (i < 0) break; /* out of bands */
1645 prev = &infoPtr->bands[i];
1648 if (i < 0) break; /* out of bands */
1650 prev_rh = ircBw(prev);
1651 if (prev->iRow == current->iRow) {
1652 new_rh = (infoPtr->dwStyle & RBS_VARHEIGHT) ?
1653 current->lcy + REBARSPACE(current) :
1655 adj_rh = new_rh + SEP_WIDTH;
1656 infoPtr->uNumRows++;
1657 current->fDraw |= NTF_INVALIDATE;
1659 if (infoPtr->dwStyle & CCS_VERT) {
1660 current->rcBand.top = inity;
1661 current->rcBand.bottom = clientcy;
1662 current->rcBand.left += (prev_rh + SEP_WIDTH);
1663 current->rcBand.right = current->rcBand.left + new_rh;
1667 current->rcBand.left = initx;
1668 current->rcBand.right = clientcx;
1669 current->rcBand.top += (prev_rh + SEP_WIDTH);
1670 current->rcBand.bottom = current->rcBand.top + new_rh;
1673 TRACE("P2 moving band %d to own row at (%d,%d)-(%d,%d)\n",
1675 current->rcBand.left, current->rcBand.top,
1676 current->rcBand.right, current->rcBand.bottom);
1677 TRACE("P2 prev band %d at (%d,%d)-(%d,%d)\n",
1679 prev->rcBand.left, prev->rcBand.top,
1680 prev->rcBand.right, prev->rcBand.bottom);
1681 TRACE("P2 values: prev_rh=%d, new_rh=%d, adj_rh=%d\n",
1682 prev_rh, new_rh, adj_rh);
1683 /* for bands below current adjust row # and top/bottom */
1684 for (j = current_idx+1; j<infoPtr->uNumBands; j++) {
1685 walk = &infoPtr->bands[j];
1686 if (HIDDENBAND(walk)) continue;
1687 walk->fDraw |= NTF_INVALIDATE;
1689 if (infoPtr->dwStyle & CCS_VERT) {
1690 walk->rcBand.left += adj_rh;
1691 walk->rcBand.right += adj_rh;
1694 walk->rcBand.top += adj_rh;
1695 walk->rcBand.bottom += adj_rh;
1698 if ((infoPtr->dwStyle & CCS_VERT) ? (x >= adjcx) : (y >= adjcy))
1699 break; /* all done */
1705 /* ******* End Phase 2 - split rows till adjustment height full ******* */
1708 /* ******* Start Phase 2a - create array of start and end ******* */
1709 /* indexes by row */
1711 if (infoPtr->uNumRows != origrows) {
1712 if (infoPtr->rows) COMCTL32_Free (infoPtr->rows);
1713 infoPtr->rows = COMCTL32_Alloc (sizeof (REBAR_ROW) * infoPtr->uNumRows);
1717 for (i = 0; i < infoPtr->uNumBands; i++) {
1718 lpBand = &infoPtr->bands[i];
1719 if (HIDDENBAND(lpBand)) continue;
1721 if (lpBand->iRow > row) {
1723 infoPtr->rows[row-1].istartband = i;
1726 ERR("P2a bug!!!!!!\n");
1728 infoPtr->rows[row-1].iendband = i;
1731 for (i = 0; i < infoPtr->uNumRows; i++) {
1734 p = &infoPtr->rows[i];
1735 TRACE("P2a row %d, starts %d, ends %d\n",
1736 i+1, p->istartband, p->iendband);
1739 /* ******* End Phase 2a - create array of start and end ******* */
1740 /* indexes by row */
1743 /* ******* Start Phase 2b - adjust all bands for height full ******* */
1744 /* assumes that the following variables contain: */
1745 /* y/x current height/width of all rows */
1746 /* clientcy/clientcx height/width of client area */
1748 if (((infoPtr->dwStyle & CCS_VERT) ? clientcx > x : clientcy > y) &&
1749 infoPtr->uNumBands) {
1750 INT diff, i, iband, j;
1752 diff = (infoPtr->dwStyle & CCS_VERT) ? clientcx - x : clientcy - y;
1753 for (i = infoPtr->uNumRows; i >= 1; i--) {
1754 /* if row has more than 1 band, ignore row */
1755 if (infoPtr->rows[i-1].istartband != infoPtr->rows[i-1].iendband)
1757 /* point to only band in row */
1758 iband = infoPtr->rows[i-1].istartband;
1759 lpBand = &infoPtr->bands[iband];
1760 if(HIDDENBAND(lpBand)) continue;
1761 if (lpBand->fMask & RBBS_VARIABLEHEIGHT) continue;
1762 if (((INT)lpBand->cyMaxChild < 1) ||
1763 ((INT)lpBand->cyIntegral < 1)) {
1764 if (lpBand->cyMaxChild + lpBand->cyIntegral == 0) continue;
1765 ERR("P2b band %u RBBS_VARIABLEHEIGHT set but cyMax=%d, cyInt=%d\n",
1766 iband, lpBand->cyMaxChild, lpBand->cyIntegral);
1769 /* j is now the maximum height/width in the client area */
1770 j = ((diff / lpBand->cyIntegral) * lpBand->cyIntegral) +
1772 if (j > lpBand->cyMaxChild + REBARSPACE(lpBand))
1773 j = lpBand->cyMaxChild + REBARSPACE(lpBand);
1774 diff -= (j - ircBw(lpBand));
1775 if (infoPtr->dwStyle & CCS_VERT)
1776 lpBand->rcBand.right = lpBand->rcBand.left + j;
1778 lpBand->rcBand.bottom = lpBand->rcBand.top + j;
1779 TRACE("P2b band %d, row %d changed to (%d,%d)-(%d,%d)\n",
1780 iband, lpBand->iRow,
1781 lpBand->rcBand.left, lpBand->rcBand.top,
1782 lpBand->rcBand.right, lpBand->rcBand.bottom);
1783 if (diff <= 0) break;
1786 ERR("P2b allocated more than available, diff=%d\n", diff);
1789 if (infoPtr->dwStyle & CCS_VERT)
1790 x = clientcx - diff;
1792 y = clientcy - diff;
1795 /* ******* End Phase 2b - adjust all bands for height full ******* */
1798 /* ******* Start Phase 3 - adjust all bands for width full ******* */
1800 if (infoPtr->uNumBands) {
1803 /* If RBS_BANDBORDERS set then indicate to draw bottom separator */
1804 /* on all bands in all rows but last row. */
1805 /* Also indicate to draw the right separator for each band in */
1806 /* each row but the rightmost band. */
1807 if (infoPtr->dwStyle & RBS_BANDBORDERS) {
1809 for(i = 0; i < infoPtr->uNumRows; i++) {
1810 p = &infoPtr->rows[i];
1811 for (j = p->istartband; j <= p->iendband; j++) {
1812 lpBand = &infoPtr->bands[j];
1813 if (HIDDENBAND(lpBand)) continue;
1814 if (j != p->iendband)
1815 lpBand->fDraw |= DRAW_RIGHTSEP;
1816 if (i != infoPtr->uNumRows-1)
1817 lpBand->fDraw |= DRAW_BOTTOMSEP;
1822 /* Distribute the extra space on the horizontal and adjust */
1823 /* all bands in row to same height. */
1824 for (i=1; i<=infoPtr->uNumRows; i++) {
1825 p = &infoPtr->rows[i-1];
1828 TRACE("P3 processing row %d, starting band %d, ending band %d\n",
1829 i, p->istartband, p->iendband);
1831 /* Find the largest height of the bands in the row */
1832 for (j = p->istartband; j <= p->iendband; j++) {
1833 lpBand = &infoPtr->bands[j];
1834 if (HIDDENBAND(lpBand)) continue;
1835 if (mcy < ircBw(lpBand))
1836 mcy = ircBw(lpBand);
1839 REBAR_AdjustBands (infoPtr, p->istartband, p->iendband,
1840 (infoPtr->dwStyle & CCS_VERT) ?
1841 clientcy : clientcx, mcy);
1844 /* Calculate the other rectangles in each band */
1845 if (infoPtr->dwStyle & CCS_VERT) {
1846 REBAR_CalcVertBand (infoPtr, 0, infoPtr->uNumBands,
1850 REBAR_CalcHorzBand (infoPtr, 0, infoPtr->uNumBands,
1855 /* ******* End Phase 3 - adjust all bands for width full ******* */
1857 /* now compute size of Rebar itself */
1858 infoPtr->oldSize = infoPtr->calcSize;
1859 if (infoPtr->uNumBands == 0) {
1860 /* we have no bands, so make size the size of client */
1864 if (infoPtr->dwStyle & CCS_VERT) {
1865 infoPtr->calcSize.cx = x;
1866 infoPtr->calcSize.cy = clientcy;
1867 TRACE("vert, notify=%d, x=%d, origheight=%d\n",
1868 notify, x, origheight);
1869 if (notify && (x != origheight)) infoPtr->fStatus |= NTF_HGHTCHG;
1872 infoPtr->calcSize.cx = clientcx;
1873 infoPtr->calcSize.cy = y;
1874 TRACE("horz, notify=%d, y=%d, origheight=%d\n",
1875 notify, y, origheight);
1876 if (notify && (y != origheight)) infoPtr->fStatus |= NTF_HGHTCHG;
1879 REBAR_DumpBand (infoPtr);
1881 REBAR_MoveChildWindows (infoPtr, 0, infoPtr->uNumBands);
1883 REBAR_ForceResize (infoPtr);
1888 REBAR_ValidateBand (REBAR_INFO *infoPtr, REBAR_BAND *lpBand)
1889 /* Function: This routine evaluates the band specs supplied */
1890 /* by the user and updates the following 5 fields in */
1891 /* the internal band structure: cxHeader, lcx, lcy, hcx, hcy*/
1898 lpBand->fStatus = 0;
1906 /* Data comming in from users into the cx... and cy... fields */
1907 /* may be bad, just garbage, because the user never clears */
1908 /* the fields. RB_{SET|INSERT}BAND{A|W} just passes the data */
1909 /* along if the fields exist in the input area. Here we must */
1910 /* determine if the data is valid. I have no idea how MS does */
1911 /* the validation, but it does because the RB_GETBANDINFO */
1912 /* returns a 0 when I know the sample program passed in an */
1913 /* address. Here I will use the algorithim that if the value */
1914 /* is greater than 65535 then it is bad and replace it with */
1915 /* a zero. Feel free to improve the algorithim. - GA 12/2000 */
1916 if (lpBand->cxMinChild > 65535) lpBand->cxMinChild = 0;
1917 if (lpBand->cyMinChild > 65535) lpBand->cyMinChild = 0;
1918 if (lpBand->cx > 65535) lpBand->cx = 0;
1919 if (lpBand->cyChild > 65535) lpBand->cyChild = 0;
1920 if (lpBand->cyMaxChild > 65535) lpBand->cyMaxChild = 0;
1921 if (lpBand->cyIntegral > 65535) lpBand->cyIntegral = 0;
1922 if (lpBand->cxIdeal > 65535) lpBand->cxIdeal = 0;
1923 if (lpBand->cxHeader > 65535) lpBand->cxHeader = 0;
1925 /* FIXME: probably should only set NEEDS_LAYOUT flag when */
1926 /* values change. Till then always set it. */
1927 TRACE("setting NEEDS_LAYOUT\n");
1928 infoPtr->fStatus |= BAND_NEEDS_LAYOUT;
1930 /* Header is where the image, text and gripper exist */
1931 /* in the band and preceed the child window. */
1933 /* count number of non-FIXEDSIZE and non-Hidden bands */
1935 for (i=0; i<infoPtr->uNumBands; i++){
1936 tBand = &infoPtr->bands[i];
1937 if (!HIDDENBAND(tBand) && !(tBand->fStyle & RBBS_FIXEDSIZE))
1941 /* calculate gripper rectangle */
1942 if ( (!(lpBand->fStyle & RBBS_NOGRIPPER)) &&
1943 ( (lpBand->fStyle & RBBS_GRIPPERALWAYS) ||
1944 ( !(lpBand->fStyle & RBBS_FIXEDSIZE) && (nonfixed > 1)))
1946 lpBand->fStatus |= HAS_GRIPPER;
1947 if (infoPtr->dwStyle & CCS_VERT)
1948 if (infoPtr->dwStyle & RBS_VERTICALGRIPPER)
1949 header += (GRIPPER_HEIGHT + REBAR_PRE_GRIPPER);
1951 header += (GRIPPER_WIDTH + REBAR_PRE_GRIPPER);
1953 header += (REBAR_PRE_GRIPPER + GRIPPER_WIDTH);
1954 /* Always have 4 pixels before anything else */
1955 header += REBAR_ALWAYS_SPACE;
1958 /* image is visible */
1959 if ((lpBand->fMask & RBBIM_IMAGE) && (infoPtr->himl)) {
1960 lpBand->fStatus |= HAS_IMAGE;
1961 if (infoPtr->dwStyle & CCS_VERT) {
1962 header += (infoPtr->imageSize.cy + REBAR_POST_IMAGE);
1963 lpBand->lcy = infoPtr->imageSize.cx + 2;
1966 header += (infoPtr->imageSize.cx + REBAR_POST_IMAGE);
1967 lpBand->lcy = infoPtr->imageSize.cy + 2;
1971 /* text is visible */
1972 if ((lpBand->fMask & RBBIM_TEXT) && (lpBand->lpText)) {
1973 HDC hdc = GetDC (0);
1974 HFONT hOldFont = SelectObject (hdc, infoPtr->hFont);
1977 lpBand->fStatus |= HAS_TEXT;
1978 GetTextExtentPoint32W (hdc, lpBand->lpText,
1979 lstrlenW (lpBand->lpText), &size);
1980 header += ((infoPtr->dwStyle & CCS_VERT) ? (size.cy + REBAR_POST_TEXT) : (size.cx + REBAR_POST_TEXT));
1981 textheight = (infoPtr->dwStyle & CCS_VERT) ? 0 : size.cy;
1983 SelectObject (hdc, hOldFont);
1987 /* if no gripper but either image or text, then leave space */
1988 if ((lpBand->fStatus & (HAS_IMAGE | HAS_TEXT)) &&
1989 !(lpBand->fStatus & HAS_GRIPPER)) {
1990 header += REBAR_ALWAYS_SPACE;
1993 /* check if user overrode the header value */
1994 if (!(lpBand->fMask & RBBIM_HEADERSIZE))
1995 lpBand->cxHeader = header;
1998 /* Now compute minimum size of child window */
1999 lpBand->offChild.cx = 0;
2000 lpBand->offChild.cy = 0;
2001 lpBand->lcy = textheight;
2002 lpBand->ccy = lpBand->lcy;
2003 if (lpBand->fMask & RBBIM_CHILDSIZE) {
2004 lpBand->lcx = lpBand->cxMinChild;
2006 /* Set the .cy values for CHILDSIZE case */
2007 lpBand->lcy = max(lpBand->lcy, lpBand->cyMinChild);
2008 lpBand->ccy = lpBand->lcy;
2009 lpBand->hcy = lpBand->lcy;
2010 if (lpBand->cyMaxChild != 0xffffffff) {
2011 lpBand->hcy = lpBand->cyMaxChild;
2013 if (lpBand->cyChild != 0xffffffff)
2014 lpBand->ccy = max (lpBand->cyChild, lpBand->lcy);
2016 TRACE("_CHILDSIZE\n");
2018 if (lpBand->fMask & RBBIM_SIZE) {
2019 lpBand->hcx = max (lpBand->cx-lpBand->cxHeader, lpBand->lcx);
2023 lpBand->hcx = lpBand->lcx;
2024 lpBand->ccx = lpBand->hcx;
2026 /* make ->.cx include header size for _Layout */
2027 lpBand->lcx += lpBand->cxHeader;
2028 lpBand->ccx += lpBand->cxHeader;
2029 lpBand->hcx += lpBand->cxHeader;
2034 REBAR_CommonSetupBand (HWND hwnd, LPREBARBANDINFOA lprbbi, REBAR_BAND *lpBand)
2035 /* Function: This routine copies the supplied values from */
2036 /* user input (lprbbi) to the internal band structure. */
2038 lpBand->fMask |= lprbbi->fMask;
2040 if (lprbbi->fMask & RBBIM_STYLE)
2041 lpBand->fStyle = lprbbi->fStyle;
2043 if (lprbbi->fMask & RBBIM_COLORS) {
2044 lpBand->clrFore = lprbbi->clrFore;
2045 lpBand->clrBack = lprbbi->clrBack;
2048 if (lprbbi->fMask & RBBIM_IMAGE)
2049 lpBand->iImage = lprbbi->iImage;
2051 if (lprbbi->fMask & RBBIM_CHILD) {
2052 if (lprbbi->hwndChild) {
2053 lpBand->hwndChild = lprbbi->hwndChild;
2054 lpBand->hwndPrevParent =
2055 SetParent (lpBand->hwndChild, hwnd);
2056 /* below in trace fro WinRAR */
2057 ShowWindow(lpBand->hwndChild, SW_SHOWNOACTIVATE | SW_SHOWNORMAL);
2058 /* above in trace fro WinRAR */
2061 TRACE("child: 0x%x prev parent: 0x%x\n",
2062 lpBand->hwndChild, lpBand->hwndPrevParent);
2063 lpBand->hwndChild = 0;
2064 lpBand->hwndPrevParent = 0;
2068 if (lprbbi->fMask & RBBIM_CHILDSIZE) {
2069 lpBand->cxMinChild = lprbbi->cxMinChild;
2070 lpBand->cyMinChild = lprbbi->cyMinChild;
2071 if (lprbbi->cbSize >= sizeof (REBARBANDINFOA)) {
2072 lpBand->cyChild = lprbbi->cyChild;
2073 lpBand->cyMaxChild = lprbbi->cyMaxChild;
2074 lpBand->cyIntegral = lprbbi->cyIntegral;
2076 else { /* special case - these should be zeroed out since */
2077 /* RBBIM_CHILDSIZE added these in WIN32_IE >= 0x0400 */
2078 lpBand->cyChild = 0;
2079 lpBand->cyMaxChild = 0;
2080 lpBand->cyIntegral = 0;
2084 if (lprbbi->fMask & RBBIM_SIZE)
2085 lpBand->cx = lprbbi->cx;
2087 if (lprbbi->fMask & RBBIM_BACKGROUND)
2088 lpBand->hbmBack = lprbbi->hbmBack;
2090 if (lprbbi->fMask & RBBIM_ID)
2091 lpBand->wID = lprbbi->wID;
2093 /* check for additional data */
2094 if (lprbbi->cbSize >= sizeof (REBARBANDINFOA)) {
2095 if (lprbbi->fMask & RBBIM_IDEALSIZE)
2096 lpBand->cxIdeal = lprbbi->cxIdeal;
2098 if (lprbbi->fMask & RBBIM_LPARAM)
2099 lpBand->lParam = lprbbi->lParam;
2101 if (lprbbi->fMask & RBBIM_HEADERSIZE)
2102 lpBand->cxHeader = lprbbi->cxHeader;
2107 REBAR_InternalEraseBkGnd (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam, RECT *clip)
2108 /* Function: This erases the background rectangle by drawing */
2109 /* each band with its background color (or the default) and */
2110 /* draws each bands right separator if necessary. The row */
2111 /* separators are drawn on the first band of the next row. */
2115 HDC hdc = (HDC)wParam;
2117 COLORREF old = CLR_NONE, new;
2120 for(i=0; i<infoPtr->uNumBands; i++) {
2121 lpBand = &infoPtr->bands[i];
2122 if (HIDDENBAND(lpBand)) continue;
2124 /* draw band separator between rows */
2125 if (lpBand->iRow != oldrow) {
2126 oldrow = lpBand->iRow;
2127 if (lpBand->fDraw & DRAW_BOTTOMSEP) {
2129 rcRowSep = lpBand->rcBand;
2130 if (infoPtr->dwStyle & CCS_VERT) {
2131 rcRowSep.right += SEP_WIDTH_SIZE;
2132 rcRowSep.bottom = infoPtr->calcSize.cy;
2133 DrawEdge (hdc, &rcRowSep, EDGE_ETCHED, BF_RIGHT);
2136 rcRowSep.bottom += SEP_WIDTH_SIZE;
2137 rcRowSep.right = infoPtr->calcSize.cx;
2138 DrawEdge (hdc, &rcRowSep, EDGE_ETCHED, BF_BOTTOM);
2140 TRACE ("drawing band separator bottom (%d,%d)-(%d,%d)\n",
2141 rcRowSep.left, rcRowSep.top,
2142 rcRowSep.right, rcRowSep.bottom);
2146 /* draw band separator between bands in a row */
2147 if (lpBand->fDraw & DRAW_RIGHTSEP) {
2149 rcSep = lpBand->rcBand;
2150 if (infoPtr->dwStyle & CCS_VERT) {
2151 rcSep.bottom += SEP_WIDTH_SIZE;
2152 DrawEdge (hdc, &rcSep, EDGE_ETCHED, BF_BOTTOM);
2155 rcSep.right += SEP_WIDTH_SIZE;
2156 DrawEdge (hdc, &rcSep, EDGE_ETCHED, BF_RIGHT);
2158 TRACE("drawing band separator right (%d,%d)-(%d,%d)\n",
2159 rcSep.left, rcSep.top, rcSep.right, rcSep.bottom);
2162 /* draw the actual background */
2163 if (lpBand->clrBack != CLR_NONE) {
2164 new = (lpBand->clrBack == CLR_DEFAULT) ? infoPtr->clrBtnFace :
2167 /* testing only - make background green to see it */
2172 /* In the absence of documentation for Rebar vs. CLR_NONE,
2173 * we will use the default BtnFace color. Note documentation
2174 * exists for Listview and Imagelist.
2176 new = infoPtr->clrBtnFace;
2178 /* testing only - make background green to see it */
2182 old = SetBkColor (hdc, new);
2184 rect = lpBand->rcBand;
2185 TRACE("%s background color=0x%06lx, band (%d,%d)-(%d,%d), clip (%d,%d)-(%d,%d)\n",
2186 (lpBand->clrBack == CLR_NONE) ? "none" :
2187 ((lpBand->clrBack == CLR_DEFAULT) ? "dft" : ""),
2189 lpBand->rcBand.left,lpBand->rcBand.top,
2190 lpBand->rcBand.right,lpBand->rcBand.bottom,
2191 clip->left, clip->top,
2192 clip->right, clip->bottom);
2193 ExtTextOutA (hdc, 0, 0, ETO_OPAQUE, &rect, NULL, 0, 0);
2194 if (lpBand->clrBack != CLR_NONE)
2195 SetBkColor (hdc, old);
2201 REBAR_InternalHitTest (REBAR_INFO *infoPtr, LPPOINT lpPt, UINT *pFlags, INT *pBand)
2207 GetClientRect (infoPtr->hwndSelf, &rect);
2209 *pFlags = RBHT_NOWHERE;
2210 if (PtInRect (&rect, *lpPt))
2212 if (infoPtr->uNumBands == 0) {
2213 *pFlags = RBHT_NOWHERE;
2220 /* somewhere inside */
2221 infoPtr->ihitBand = -1;
2222 for (iCount = 0; iCount < infoPtr->uNumBands; iCount++) {
2223 lpBand = &infoPtr->bands[iCount];
2224 if (HIDDENBAND(lpBand)) continue;
2225 if (PtInRect (&lpBand->rcBand, *lpPt)) {
2228 if (PtInRect (&lpBand->rcGripper, *lpPt)) {
2229 *pFlags = RBHT_GRABBER;
2230 infoPtr->ihitBand = iCount;
2231 TRACE("ON GRABBER %d\n", iCount);
2234 else if (PtInRect (&lpBand->rcCapImage, *lpPt)) {
2235 *pFlags = RBHT_CAPTION;
2236 TRACE("ON CAPTION %d\n", iCount);
2239 else if (PtInRect (&lpBand->rcCapText, *lpPt)) {
2240 *pFlags = RBHT_CAPTION;
2241 TRACE("ON CAPTION %d\n", iCount);
2244 else if (PtInRect (&lpBand->rcChild, *lpPt)) {
2245 *pFlags = RBHT_CLIENT;
2246 TRACE("ON CLIENT %d\n", iCount);
2250 *pFlags = RBHT_NOWHERE;
2251 TRACE("NOWHERE %d\n", iCount);
2257 *pFlags = RBHT_NOWHERE;
2266 *pFlags = RBHT_NOWHERE;
2273 TRACE("flags=0x%X\n", *pFlags);
2279 REBAR_Shrink (REBAR_INFO *infoPtr, REBAR_BAND *band, INT movement, INT i)
2280 /* Function: This attempts to shrink the given band by the */
2281 /* the amount in "movement". A shrink to the left is indi- */
2282 /* cated by "movement" being negative. "i" is merely the */
2283 /* band index for trace messages. */
2285 INT Leadjust, Readjust, avail, ret;
2287 /* Note: a left drag is indicated by "movement" being negative. */
2288 /* Similarly, a right drag is indicated by "movement" */
2289 /* being positive. "movement" should never be 0, but if */
2290 /* it is then the band does not move. */
2292 avail = rcBw(band) - band->lcx;
2294 /* now compute the Left End adjustment factor and Right End */
2295 /* adjustment factor. They may be different if shrinking. */
2297 /* if this band is not shrinkable, then just move it */
2298 Leadjust = Readjust = movement;
2304 if (avail <= abs(movement)) {
2305 Readjust = movement;
2306 Leadjust = movement + avail;
2310 Readjust = movement;
2317 if (avail <= abs(movement)) {
2318 Leadjust = movement;
2319 Readjust = movement - avail;
2323 Leadjust = movement;
2330 /* Reasonability Check */
2331 if (rcBlt(band) + Leadjust < 0) {
2332 ERR("adjustment will fail, band %d: left=%d, right=%d, move=%d, rtn=%d\n",
2333 i, Leadjust, Readjust, movement, ret);
2336 LEADJ(band, Leadjust);
2337 READJ(band, Readjust);
2339 TRACE("band %d: left=%d, right=%d, move=%d, rtn=%d, rcBand=(%d,%d)-(%d,%d)\n",
2340 i, Leadjust, Readjust, movement, ret,
2341 band->rcBand.left, band->rcBand.top,
2342 band->rcBand.right, band->rcBand.bottom);
2348 REBAR_HandleLRDrag (REBAR_INFO *infoPtr, POINTS *ptsmove)
2349 /* Function: This will implement the functionality of a */
2350 /* Gripper drag within a row. It will not implement "out- */
2351 /* of-row" drags. (They are detected and handled in */
2352 /* REBAR_MouseMove.) */
2353 /* **** FIXME Switching order of bands in a row not **** */
2354 /* **** yet implemented. **** */
2356 REBAR_BAND *hitBand, *band, *mindBand, *maxdBand;
2358 INT imindBand = -1, imaxdBand, ihitBand, i, movement;
2359 INT RHeaderSum = 0, LHeaderSum = 0;
2362 /* on first significant mouse movement, issue notify */
2364 if (!(infoPtr->fStatus & BEGIN_DRAG_ISSUED)) {
2365 if (REBAR_Notify_NMREBAR (infoPtr, -1, RBN_BEGINDRAG)) {
2366 /* Notify returned TRUE - abort drag */
2367 infoPtr->dragStart.x = 0;
2368 infoPtr->dragStart.y = 0;
2369 infoPtr->dragNow = infoPtr->dragStart;
2370 infoPtr->ihitBand = -1;
2374 infoPtr->fStatus |= BEGIN_DRAG_ISSUED;
2377 ihitBand = infoPtr->ihitBand;
2378 hitBand = &infoPtr->bands[ihitBand];
2379 imaxdBand = ihitBand; /* to suppress warning message */
2381 /* find all the bands in the row of the one whose Gripper was seized */
2382 for (i=0; i<infoPtr->uNumBands; i++) {
2383 band = &infoPtr->bands[i];
2384 if (HIDDENBAND(band)) continue;
2385 if (band->iRow == hitBand->iRow) {
2387 if (imindBand == -1) imindBand = i;
2388 /* minimum size of each band is size of header plus */
2389 /* size of minimum child plus offset of child from header plus */
2390 /* a one to separate each band. */
2392 LHeaderSum += (band->lcx + SEP_WIDTH);
2394 RHeaderSum += (band->lcx + SEP_WIDTH);
2398 if (RHeaderSum) RHeaderSum -= SEP_WIDTH; /* no separator afterlast band */
2400 mindBand = &infoPtr->bands[imindBand];
2401 maxdBand = &infoPtr->bands[imaxdBand];
2403 if (imindBand == imaxdBand) return; /* nothing to drag agains */
2404 if (imindBand == ihitBand) return; /* first band in row, cant drag */
2406 /* limit movement to inside adjustable bands - Left */
2407 if ( (ptsmove->x < mindBand->rcBand.left) ||
2408 (ptsmove->x > maxdBand->rcBand.right) ||
2409 (ptsmove->y < mindBand->rcBand.top) ||
2410 (ptsmove->y > maxdBand->rcBand.bottom))
2411 return; /* should swap bands */
2413 if (infoPtr->dwStyle & CCS_VERT)
2414 movement = ptsmove->y - ((hitBand->rcBand.top+REBAR_PRE_GRIPPER) -
2415 infoPtr->ihitoffset);
2417 movement = ptsmove->x - ((hitBand->rcBand.left+REBAR_PRE_GRIPPER) -
2418 infoPtr->ihitoffset);
2419 infoPtr->dragNow = *ptsmove;
2421 TRACE("before: movement=%d (%d,%d), imindBand=%d, ihitBand=%d, imaxdBand=%d, LSum=%d, RSum=%d\n",
2422 movement, ptsmove->x, ptsmove->y, imindBand, ihitBand,
2423 imaxdBand, LHeaderSum, RHeaderSum);
2424 REBAR_DumpBand (infoPtr);
2428 /* *** Drag left/up *** */
2429 compress = rcBlt(hitBand) - rcBlt(mindBand) -
2431 if (compress < abs(movement)) {
2432 TRACE("limiting left drag, was %d changed to %d\n",
2433 movement, -compress);
2434 movement = -compress;
2437 for (i=ihitBand; i>=imindBand; i--) {
2438 band = &infoPtr->bands[i];
2439 if (HIDDENBAND(band)) continue;
2440 if (i == ihitBand) {
2441 LEADJ(band, movement)
2444 movement = REBAR_Shrink (infoPtr, band, movement, i);
2445 band->ccx = rcBw(band);
2451 /* *** Drag right/down *** */
2452 compress = rcBrb(maxdBand) - rcBlt(hitBand) -
2454 if (compress < abs(movement)) {
2455 TRACE("limiting right drag, was %d changed to %d\n",
2456 movement, compress);
2457 movement = compress;
2459 for (i=ihitBand-1; i<=imaxdBand; i++) {
2460 band = &infoPtr->bands[i];
2461 if (HIDDENBAND(band)) continue;
2464 READJ(band, movement)
2467 movement = REBAR_Shrink (infoPtr, band, movement, i);
2468 band->ccx = rcBw(band);
2472 /* recompute all rectangles */
2473 if (infoPtr->dwStyle & CCS_VERT) {
2474 REBAR_CalcVertBand (infoPtr, imindBand, imaxdBand+1,
2478 REBAR_CalcHorzBand (infoPtr, imindBand, imaxdBand+1,
2482 TRACE("bands after adjustment, see band # %d, %d\n",
2483 imindBand, imaxdBand);
2484 REBAR_DumpBand (infoPtr);
2487 mindBand->rcBand.left,
2488 mindBand->rcBand.top,
2489 maxdBand->rcBand.right,
2490 maxdBand->rcBand.bottom);
2492 REBAR_MoveChildWindows (infoPtr, imindBand, imaxdBand+1);
2494 InvalidateRect (infoPtr->hwndSelf, &newrect, TRUE);
2495 UpdateWindow (infoPtr->hwndSelf);
2501 /* << REBAR_BeginDrag >> */
2505 REBAR_DeleteBand (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
2507 UINT uBand = (UINT)wParam;
2511 if (uBand >= infoPtr->uNumBands)
2514 TRACE("deleting band %u!\n", uBand);
2515 lpBand = &infoPtr->bands[uBand];
2516 REBAR_Notify_NMREBAR (infoPtr, uBand, RBN_DELETINGBAND);
2518 if (infoPtr->uNumBands == 1) {
2519 TRACE(" simple delete!\n");
2520 if ((lpBand->fMask & RBBIM_CHILD) && lpBand->hwndChild)
2521 childhwnd = lpBand->hwndChild;
2522 COMCTL32_Free (infoPtr->bands);
2523 infoPtr->bands = NULL;
2524 infoPtr->uNumBands = 0;
2527 REBAR_BAND *oldBands = infoPtr->bands;
2528 TRACE("complex delete! [uBand=%u]\n", uBand);
2530 if ((lpBand->fMask & RBBIM_CHILD) && lpBand->hwndChild)
2531 childhwnd = lpBand->hwndChild;
2533 infoPtr->uNumBands--;
2534 infoPtr->bands = COMCTL32_Alloc (sizeof (REBAR_BAND) * infoPtr->uNumBands);
2536 memcpy (&infoPtr->bands[0], &oldBands[0],
2537 uBand * sizeof(REBAR_BAND));
2540 if (uBand < infoPtr->uNumBands) {
2541 memcpy (&infoPtr->bands[uBand], &oldBands[uBand+1],
2542 (infoPtr->uNumBands - uBand) * sizeof(REBAR_BAND));
2545 COMCTL32_Free (oldBands);
2549 ShowWindow (childhwnd, SW_HIDE);
2551 REBAR_Notify_NMREBAR (infoPtr, -1, RBN_DELETEDBAND);
2553 /* if only 1 band left the re-validate to possible eliminate gripper */
2554 if (infoPtr->uNumBands == 1)
2555 REBAR_ValidateBand (infoPtr, &infoPtr->bands[0]);
2557 TRACE("setting NEEDS_LAYOUT\n");
2558 infoPtr->fStatus |= BAND_NEEDS_LAYOUT;
2559 infoPtr->fStatus |= RESIZE_ANYHOW;
2560 REBAR_Layout (infoPtr, NULL, TRUE, FALSE);
2566 /* << REBAR_DragMove >> */
2567 /* << REBAR_EndDrag >> */
2571 REBAR_GetBandBorders (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
2573 LPRECT lpRect = (LPRECT)lParam;
2578 if ((UINT)wParam >= infoPtr->uNumBands)
2581 lpBand = &infoPtr->bands[(UINT)wParam];
2583 /* FIXME - the following values were determined by experimentation */
2584 /* with the REBAR Control Spy. I have guesses as to what the 4 and */
2585 /* 1 are, but I am not sure. There doesn't seem to be any actual */
2586 /* difference in size of the control area with and without the */
2588 if (infoPtr->dwStyle & RBS_BANDBORDERS) {
2589 if (infoPtr->dwStyle & CCS_VERT) {
2591 lpRect->top = lpBand->cxHeader + 4;
2596 lpRect->left = lpBand->cxHeader + 4;
2603 lpRect->left = lpBand->cxHeader;
2609 inline static LRESULT
2610 REBAR_GetBandCount (REBAR_INFO *infoPtr)
2612 TRACE("band count %u!\n", infoPtr->uNumBands);
2614 return infoPtr->uNumBands;
2619 REBAR_GetBandInfoA (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
2621 LPREBARBANDINFOA lprbbi = (LPREBARBANDINFOA)lParam;
2626 if (lprbbi->cbSize < REBARBANDINFO_V3_SIZEA)
2628 if ((UINT)wParam >= infoPtr->uNumBands)
2631 TRACE("index %u\n", (UINT)wParam);
2633 /* copy band information */
2634 lpBand = &infoPtr->bands[(UINT)wParam];
2636 if (lprbbi->fMask & RBBIM_STYLE)
2637 lprbbi->fStyle = lpBand->fStyle;
2639 if (lprbbi->fMask & RBBIM_COLORS) {
2640 lprbbi->clrFore = lpBand->clrFore;
2641 lprbbi->clrBack = lpBand->clrBack;
2642 if (lprbbi->clrBack == CLR_DEFAULT)
2643 lprbbi->clrBack = infoPtr->clrBtnFace;
2646 if ((lprbbi->fMask & RBBIM_TEXT) && (lprbbi->lpText)) {
2647 if (lpBand->lpText && (lpBand->fMask & RBBIM_TEXT))
2649 if (!WideCharToMultiByte( CP_ACP, 0, lpBand->lpText, -1,
2650 lprbbi->lpText, lprbbi->cch, NULL, NULL ))
2651 lprbbi->lpText[lprbbi->cch-1] = 0;
2654 *lprbbi->lpText = 0;
2657 if (lprbbi->fMask & RBBIM_IMAGE) {
2658 if (lpBand->fMask & RBBIM_IMAGE)
2659 lprbbi->iImage = lpBand->iImage;
2661 lprbbi->iImage = -1;
2664 if (lprbbi->fMask & RBBIM_CHILD)
2665 lprbbi->hwndChild = lpBand->hwndChild;
2667 if (lprbbi->fMask & RBBIM_CHILDSIZE) {
2668 lprbbi->cxMinChild = lpBand->cxMinChild;
2669 lprbbi->cyMinChild = lpBand->cyMinChild;
2670 if (lprbbi->cbSize >= sizeof (REBARBANDINFOA)) {
2671 lprbbi->cyChild = lpBand->cyChild;
2672 lprbbi->cyMaxChild = lpBand->cyMaxChild;
2673 lprbbi->cyIntegral = lpBand->cyIntegral;
2677 if (lprbbi->fMask & RBBIM_SIZE)
2678 lprbbi->cx = lpBand->cx;
2680 if (lprbbi->fMask & RBBIM_BACKGROUND)
2681 lprbbi->hbmBack = lpBand->hbmBack;
2683 if (lprbbi->fMask & RBBIM_ID)
2684 lprbbi->wID = lpBand->wID;
2686 /* check for additional data */
2687 if (lprbbi->cbSize >= sizeof (REBARBANDINFOA)) {
2688 if (lprbbi->fMask & RBBIM_IDEALSIZE)
2689 lprbbi->cxIdeal = lpBand->cxIdeal;
2691 if (lprbbi->fMask & RBBIM_LPARAM)
2692 lprbbi->lParam = lpBand->lParam;
2694 if (lprbbi->fMask & RBBIM_HEADERSIZE)
2695 lprbbi->cxHeader = lpBand->cxHeader;
2698 REBAR_DumpBandInfo (lprbbi);
2705 REBAR_GetBandInfoW (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
2707 LPREBARBANDINFOW lprbbi = (LPREBARBANDINFOW)lParam;
2712 if (lprbbi->cbSize < REBARBANDINFO_V3_SIZEW)
2714 if ((UINT)wParam >= infoPtr->uNumBands)
2717 TRACE("index %u\n", (UINT)wParam);
2719 /* copy band information */
2720 lpBand = &infoPtr->bands[(UINT)wParam];
2722 if (lprbbi->fMask & RBBIM_STYLE)
2723 lprbbi->fStyle = lpBand->fStyle;
2725 if (lprbbi->fMask & RBBIM_COLORS) {
2726 lprbbi->clrFore = lpBand->clrFore;
2727 lprbbi->clrBack = lpBand->clrBack;
2728 if (lprbbi->clrBack == CLR_DEFAULT)
2729 lprbbi->clrBack = infoPtr->clrBtnFace;
2732 if ((lprbbi->fMask & RBBIM_TEXT) && (lprbbi->lpText)) {
2733 if (lpBand->lpText && (lpBand->fMask & RBBIM_TEXT))
2734 lstrcpynW (lprbbi->lpText, lpBand->lpText, lprbbi->cch);
2736 *lprbbi->lpText = 0;
2739 if (lprbbi->fMask & RBBIM_IMAGE) {
2740 if (lpBand->fMask & RBBIM_IMAGE)
2741 lprbbi->iImage = lpBand->iImage;
2743 lprbbi->iImage = -1;
2746 if (lprbbi->fMask & RBBIM_CHILD)
2747 lprbbi->hwndChild = lpBand->hwndChild;
2749 if (lprbbi->fMask & RBBIM_CHILDSIZE) {
2750 lprbbi->cxMinChild = lpBand->cxMinChild;
2751 lprbbi->cyMinChild = lpBand->cyMinChild;
2752 if (lprbbi->cbSize >= sizeof (REBARBANDINFOW)) {
2753 lprbbi->cyChild = lpBand->cyChild;
2754 lprbbi->cyMaxChild = lpBand->cyMaxChild;
2755 lprbbi->cyIntegral = lpBand->cyIntegral;
2759 if (lprbbi->fMask & RBBIM_SIZE)
2760 lprbbi->cx = lpBand->cx;
2762 if (lprbbi->fMask & RBBIM_BACKGROUND)
2763 lprbbi->hbmBack = lpBand->hbmBack;
2765 if (lprbbi->fMask & RBBIM_ID)
2766 lprbbi->wID = lpBand->wID;
2768 /* check for additional data */
2769 if (lprbbi->cbSize >= sizeof (REBARBANDINFOW)) {
2770 if (lprbbi->fMask & RBBIM_IDEALSIZE)
2771 lprbbi->cxIdeal = lpBand->cxIdeal;
2773 if (lprbbi->fMask & RBBIM_LPARAM)
2774 lprbbi->lParam = lpBand->lParam;
2776 if (lprbbi->fMask & RBBIM_HEADERSIZE)
2777 lprbbi->cxHeader = lpBand->cxHeader;
2780 REBAR_DumpBandInfo ((LPREBARBANDINFOA)lprbbi);
2787 REBAR_GetBarHeight (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
2791 nHeight = (infoPtr->dwStyle & CCS_VERT) ? infoPtr->calcSize.cx : infoPtr->calcSize.cy;
2793 TRACE("height = %d\n", nHeight);
2800 REBAR_GetBarInfo (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
2802 LPREBARINFO lpInfo = (LPREBARINFO)lParam;
2807 if (lpInfo->cbSize < sizeof (REBARINFO))
2810 TRACE("getting bar info!\n");
2812 if (infoPtr->himl) {
2813 lpInfo->himl = infoPtr->himl;
2814 lpInfo->fMask |= RBIM_IMAGELIST;
2821 inline static LRESULT
2822 REBAR_GetBkColor (REBAR_INFO *infoPtr)
2824 COLORREF clr = infoPtr->clrBk;
2826 if (clr == CLR_DEFAULT)
2827 clr = infoPtr->clrBtnFace;
2829 TRACE("background color 0x%06lx!\n", clr);
2835 /* << REBAR_GetColorScheme >> */
2836 /* << REBAR_GetDropTarget >> */
2840 REBAR_GetPalette (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
2842 FIXME("empty stub!\n");
2849 REBAR_GetRect (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
2851 INT iBand = (INT)wParam;
2852 LPRECT lprc = (LPRECT)lParam;
2855 if ((iBand < 0) && ((UINT)iBand >= infoPtr->uNumBands))
2860 lpBand = &infoPtr->bands[iBand];
2861 CopyRect (lprc, &lpBand->rcBand);
2863 TRACE("band %d, (%d,%d)-(%d,%d)\n", iBand,
2864 lprc->left, lprc->top, lprc->right, lprc->bottom);
2870 inline static LRESULT
2871 REBAR_GetRowCount (REBAR_INFO *infoPtr)
2873 TRACE("%u\n", infoPtr->uNumRows);
2875 return infoPtr->uNumRows;
2880 REBAR_GetRowHeight (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
2882 INT iRow = (INT)wParam;
2887 for (i=0; i<infoPtr->uNumBands; i++) {
2888 lpBand = &infoPtr->bands[i];
2889 if (HIDDENBAND(lpBand)) continue;
2890 if (lpBand->iRow != iRow) continue;
2891 if (infoPtr->dwStyle & CCS_VERT)
2892 j = lpBand->rcBand.right - lpBand->rcBand.left;
2894 j = lpBand->rcBand.bottom - lpBand->rcBand.top;
2895 if (j > ret) ret = j;
2898 TRACE("row %d, height %d\n", iRow, ret);
2904 inline static LRESULT
2905 REBAR_GetTextColor (REBAR_INFO *infoPtr)
2907 TRACE("text color 0x%06lx!\n", infoPtr->clrText);
2909 return infoPtr->clrText;
2913 inline static LRESULT
2914 REBAR_GetToolTips (REBAR_INFO *infoPtr)
2916 return infoPtr->hwndToolTip;
2920 inline static LRESULT
2921 REBAR_GetUnicodeFormat (REBAR_INFO *infoPtr)
2923 TRACE("%s hwnd=0x%x\n",
2924 infoPtr->bUnicode ? "TRUE" : "FALSE", infoPtr->hwndSelf);
2926 return infoPtr->bUnicode;
2930 inline static LRESULT
2931 REBAR_GetVersion (REBAR_INFO *infoPtr)
2933 TRACE("version %d\n", infoPtr->iVersion);
2934 return infoPtr->iVersion;
2939 REBAR_HitTest (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
2941 LPRBHITTESTINFO lprbht = (LPRBHITTESTINFO)lParam;
2946 REBAR_InternalHitTest (infoPtr, &lprbht->pt, &lprbht->flags, &lprbht->iBand);
2948 return lprbht->iBand;
2953 REBAR_IdToIndex (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
2957 if (infoPtr == NULL)
2960 if (infoPtr->uNumBands < 1)
2963 for (i = 0; i < infoPtr->uNumBands; i++) {
2964 if (infoPtr->bands[i].wID == (UINT)wParam) {
2965 TRACE("id %u is band %u found!\n", (UINT)wParam, i);
2970 TRACE("id %u is not found\n", (UINT)wParam);
2976 REBAR_InsertBandA (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
2978 LPREBARBANDINFOA lprbbi = (LPREBARBANDINFOA)lParam;
2979 UINT uIndex = (UINT)wParam;
2982 if (infoPtr == NULL)
2986 if (lprbbi->cbSize < REBARBANDINFO_V3_SIZEA)
2989 /* trace the index as signed to see the -1 */
2990 TRACE("insert band at %d!\n", (INT)uIndex);
2991 REBAR_DumpBandInfo (lprbbi);
2993 if (infoPtr->uNumBands == 0) {
2994 infoPtr->bands = (REBAR_BAND *)COMCTL32_Alloc (sizeof (REBAR_BAND));
2998 REBAR_BAND *oldBands = infoPtr->bands;
3000 (REBAR_BAND *)COMCTL32_Alloc ((infoPtr->uNumBands+1)*sizeof(REBAR_BAND));
3001 if (((INT)uIndex == -1) || (uIndex > infoPtr->uNumBands))
3002 uIndex = infoPtr->uNumBands;
3004 /* pre insert copy */
3006 memcpy (&infoPtr->bands[0], &oldBands[0],
3007 uIndex * sizeof(REBAR_BAND));
3011 if (uIndex < infoPtr->uNumBands - 1) {
3012 memcpy (&infoPtr->bands[uIndex+1], &oldBands[uIndex],
3013 (infoPtr->uNumBands - uIndex - 1) * sizeof(REBAR_BAND));
3016 COMCTL32_Free (oldBands);
3019 infoPtr->uNumBands++;
3021 TRACE("index %u!\n", uIndex);
3023 /* initialize band (infoPtr->bands[uIndex])*/
3024 lpBand = &infoPtr->bands[uIndex];
3026 lpBand->fStatus = 0;
3027 lpBand->clrFore = infoPtr->clrText;
3028 lpBand->clrBack = infoPtr->clrBk;
3029 lpBand->hwndChild = 0;
3030 lpBand->hwndPrevParent = 0;
3032 REBAR_CommonSetupBand (infoPtr->hwndSelf, lprbbi, lpBand);
3033 lpBand->lpText = NULL;
3034 if ((lprbbi->fMask & RBBIM_TEXT) && (lprbbi->lpText)) {
3035 INT len = MultiByteToWideChar( CP_ACP, 0, lprbbi->lpText, -1, NULL, 0 );
3037 lpBand->lpText = (LPWSTR)COMCTL32_Alloc (len*sizeof(WCHAR));
3038 MultiByteToWideChar( CP_ACP, 0, lprbbi->lpText, -1, lpBand->lpText, len );
3042 REBAR_ValidateBand (infoPtr, lpBand);
3043 /* On insert of second band, revalidate band 1 to possible add gripper */
3044 if (infoPtr->uNumBands == 2)
3045 REBAR_ValidateBand (infoPtr, &infoPtr->bands[0]);
3047 REBAR_DumpBand (infoPtr);
3049 REBAR_Layout (infoPtr, NULL, TRUE, FALSE);
3050 InvalidateRect(infoPtr->hwndSelf, 0, 1);
3057 REBAR_InsertBandW (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3059 LPREBARBANDINFOW lprbbi = (LPREBARBANDINFOW)lParam;
3060 UINT uIndex = (UINT)wParam;
3063 if (infoPtr == NULL)
3067 if (lprbbi->cbSize < REBARBANDINFO_V3_SIZEW)
3070 /* trace the index as signed to see the -1 */
3071 TRACE("insert band at %d!\n", (INT)uIndex);
3072 REBAR_DumpBandInfo ((LPREBARBANDINFOA)lprbbi);
3074 if (infoPtr->uNumBands == 0) {
3075 infoPtr->bands = (REBAR_BAND *)COMCTL32_Alloc (sizeof (REBAR_BAND));
3079 REBAR_BAND *oldBands = infoPtr->bands;
3081 (REBAR_BAND *)COMCTL32_Alloc ((infoPtr->uNumBands+1)*sizeof(REBAR_BAND));
3082 if (((INT)uIndex == -1) || (uIndex > infoPtr->uNumBands))
3083 uIndex = infoPtr->uNumBands;
3085 /* pre insert copy */
3087 memcpy (&infoPtr->bands[0], &oldBands[0],
3088 uIndex * sizeof(REBAR_BAND));
3092 if (uIndex < infoPtr->uNumBands - 1) {
3093 memcpy (&infoPtr->bands[uIndex+1], &oldBands[uIndex],
3094 (infoPtr->uNumBands - uIndex - 1) * sizeof(REBAR_BAND));
3097 COMCTL32_Free (oldBands);
3100 infoPtr->uNumBands++;
3102 TRACE("index %u!\n", uIndex);
3104 /* initialize band (infoPtr->bands[uIndex])*/
3105 lpBand = &infoPtr->bands[uIndex];
3107 lpBand->fStatus = 0;
3108 lpBand->clrFore = infoPtr->clrText;
3109 lpBand->clrBack = infoPtr->clrBk;
3110 lpBand->hwndChild = 0;
3111 lpBand->hwndPrevParent = 0;
3113 REBAR_CommonSetupBand (infoPtr->hwndSelf, (LPREBARBANDINFOA)lprbbi, lpBand);
3114 lpBand->lpText = NULL;
3115 if ((lprbbi->fMask & RBBIM_TEXT) && (lprbbi->lpText)) {
3116 INT len = lstrlenW (lprbbi->lpText);
3118 lpBand->lpText = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
3119 strcpyW (lpBand->lpText, lprbbi->lpText);
3123 REBAR_ValidateBand (infoPtr, lpBand);
3124 /* On insert of second band, revalidate band 1 to possible add gripper */
3125 if (infoPtr->uNumBands == 2)
3126 REBAR_ValidateBand (infoPtr, &infoPtr->bands[0]);
3128 REBAR_DumpBand (infoPtr);
3130 REBAR_Layout (infoPtr, NULL, TRUE, FALSE);
3131 InvalidateRect(infoPtr->hwndSelf, 0, 1);
3138 REBAR_MaximizeBand (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3141 UINT uBand = (UINT) wParam;
3144 if ((infoPtr->uNumBands == 0) ||
3145 ((INT)uBand < 0) || (uBand >= infoPtr->uNumBands)) {
3147 ERR("Illegal MaximizeBand, requested=%d, current band count=%d\n",
3148 (INT)uBand, infoPtr->uNumBands);
3152 lpBand = &infoPtr->bands[uBand];
3154 if (lParam && (lpBand->fMask & RBBIM_IDEALSIZE)) {
3155 /* handle setting ideal size */
3156 lpBand->ccx = lpBand->cxIdeal;
3159 /* handle setting to max */
3160 FIXME("(uBand = %u fIdeal = %s) case not coded\n",
3161 (UINT)wParam, lParam ? "TRUE" : "FALSE");
3165 infoPtr->fStatus |= BAND_NEEDS_LAYOUT;
3166 REBAR_Layout (infoPtr, 0, TRUE, TRUE);
3167 InvalidateRect (infoPtr->hwndSelf, 0, TRUE);
3175 REBAR_MinimizeBand (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3177 REBAR_BAND *band, *lpBand;
3178 UINT uBand = (UINT) wParam;
3180 INT imindBand, imaxdBand, iprevBand, startBand, endBand;
3183 /* A "minimize" band is equivalent to "dragging" the gripper
3184 * of than band to the right till the band is only the size
3189 if ((infoPtr->uNumBands == 0) ||
3190 ((INT)uBand < 0) || (uBand >= infoPtr->uNumBands)) {
3192 ERR("Illegal MinimizeBand, requested=%d, current band count=%d\n",
3193 (INT)uBand, infoPtr->uNumBands);
3197 /* compute amount of movement and validate */
3198 lpBand = &infoPtr->bands[uBand];
3200 if (infoPtr->dwStyle & CCS_VERT)
3201 movement = lpBand->rcBand.bottom - lpBand->rcBand.top -
3204 movement = lpBand->rcBand.right - lpBand->rcBand.left -
3207 ERR("something is wrong, band=(%d,%d)-(%d,%d), cxheader=%d\n",
3208 lpBand->rcBand.left, lpBand->rcBand.top,
3209 lpBand->rcBand.right, lpBand->rcBand.bottom,
3216 iprevBand = -1; /* to suppress warning message */
3218 /* find the first band in row of the one whose is being minimized */
3219 for (i=0; i<infoPtr->uNumBands; i++) {
3220 band = &infoPtr->bands[i];
3221 if (HIDDENBAND(band)) continue;
3222 if (band->iRow == lpBand->iRow) {
3224 if (imindBand == -1) imindBand = i;
3228 /* if the selected band is first in row then need to expand */
3229 /* next visible band */
3230 if (imindBand == uBand) {
3232 movement = -movement;
3233 /* find the first visible band to the right of the selected band */
3234 for (i=uBand+1; i<=imaxdBand; i++) {
3235 band = &infoPtr->bands[i];
3236 if (!HIDDENBAND(band)) {
3238 LEADJ(band, movement);
3239 band->ccx = rcBw(band);
3243 /* what case is this */
3244 if (iprevBand == -1) {
3245 ERR("no previous visible band\n");
3249 endBand = iprevBand;
3251 lpBand->rcBand.left,
3254 band->rcBand.bottom);
3256 /* otherwise expand previous visible band */
3259 /* find the first visible band to the left of the selected band */
3260 for (i=uBand-1; i>=imindBand; i--) {
3261 band = &infoPtr->bands[i];
3262 if (!HIDDENBAND(band)) {
3264 READJ(band, movement);
3265 band->ccx = rcBw(band);
3269 /* what case is this */
3270 if (iprevBand == -1) {
3271 ERR("no previous visible band\n");
3274 startBand = iprevBand;
3279 lpBand->rcBand.right,
3280 lpBand->rcBand.bottom);
3283 REBAR_Shrink (infoPtr, lpBand, movement, uBand);
3285 /* recompute all rectangles */
3286 if (infoPtr->dwStyle & CCS_VERT) {
3287 REBAR_CalcVertBand (infoPtr, startBand, endBand+1,
3291 REBAR_CalcHorzBand (infoPtr, startBand, endBand+1,
3295 TRACE("bands after minimize, see band # %d, %d\n",
3296 startBand, endBand);
3297 REBAR_DumpBand (infoPtr);
3299 REBAR_MoveChildWindows (infoPtr, startBand, endBand+1);
3301 InvalidateRect (infoPtr->hwndSelf, &newrect, TRUE);
3302 UpdateWindow (infoPtr->hwndSelf);
3308 REBAR_MoveBand (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3310 REBAR_BAND *oldBands = infoPtr->bands;
3312 UINT uFrom = (UINT)wParam;
3313 UINT uTo = (UINT)lParam;
3316 if ((infoPtr->uNumBands == 0) ||
3317 ((INT)uFrom < 0) || (uFrom >= infoPtr->uNumBands) ||
3318 ((INT)uTo < 0) || (uTo >= infoPtr->uNumBands)) {
3320 ERR("Illegal MoveBand, from=%d, to=%d, current band count=%d\n",
3321 (INT)uFrom, (INT)uTo, infoPtr->uNumBands);
3325 /* save one to be moved */
3326 memcpy (&holder, &oldBands[uFrom], sizeof(REBAR_BAND));
3328 /* close up rest of bands (psuedo delete) */
3329 if (uFrom < infoPtr->uNumBands - 1) {
3330 memcpy (&oldBands[uFrom], &oldBands[uFrom+1],
3331 (infoPtr->uNumBands - uFrom - 1) * sizeof(REBAR_BAND));
3334 /* allocate new space and copy rest of bands into it */
3336 (REBAR_BAND *)COMCTL32_Alloc ((infoPtr->uNumBands)*sizeof(REBAR_BAND));
3338 /* pre insert copy */
3340 memcpy (&infoPtr->bands[0], &oldBands[0],
3341 uTo * sizeof(REBAR_BAND));
3344 /* set moved band */
3345 memcpy (&infoPtr->bands[uTo], &holder, sizeof(REBAR_BAND));
3348 if (uTo < infoPtr->uNumBands - 1) {
3349 memcpy (&infoPtr->bands[uTo+1], &oldBands[uTo],
3350 (infoPtr->uNumBands - uTo - 1) * sizeof(REBAR_BAND));
3353 COMCTL32_Free (oldBands);
3355 TRACE("moved band %d to index %d\n", uFrom, uTo);
3356 REBAR_DumpBand (infoPtr);
3358 infoPtr->fStatus |= BAND_NEEDS_LAYOUT;
3359 /* **************************************************** */
3361 /* We do not do a REBAR_Layout here because the native */
3362 /* control does not do that. The actual layout and */
3363 /* repaint is done by the *next* real action, ex.: */
3364 /* RB_INSERTBAND, RB_DELETEBAND, RB_SIZETORECT, etc. */
3366 /* **************************************************** */
3373 REBAR_SetBandInfoA (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3375 LPREBARBANDINFOA lprbbi = (LPREBARBANDINFOA)lParam;
3380 if (lprbbi->cbSize < REBARBANDINFO_V3_SIZEA)
3382 if ((UINT)wParam >= infoPtr->uNumBands)
3385 TRACE("index %u\n", (UINT)wParam);
3386 REBAR_DumpBandInfo (lprbbi);
3388 /* set band information */
3389 lpBand = &infoPtr->bands[(UINT)wParam];
3391 REBAR_CommonSetupBand (infoPtr->hwndSelf, lprbbi, lpBand);
3392 if (lprbbi->fMask & RBBIM_TEXT) {
3393 if (lpBand->lpText) {
3394 COMCTL32_Free (lpBand->lpText);
3395 lpBand->lpText = NULL;
3397 if (lprbbi->lpText) {
3398 INT len = MultiByteToWideChar( CP_ACP, 0, lprbbi->lpText, -1, NULL, 0 );
3399 lpBand->lpText = (LPWSTR)COMCTL32_Alloc (len*sizeof(WCHAR));
3400 MultiByteToWideChar( CP_ACP, 0, lprbbi->lpText, -1, lpBand->lpText, len );
3404 REBAR_ValidateBand (infoPtr, lpBand);
3406 REBAR_DumpBand (infoPtr);
3408 if (lprbbi->fMask & (RBBIM_CHILDSIZE | RBBIM_SIZE)) {
3409 REBAR_Layout (infoPtr, NULL, TRUE, FALSE);
3410 InvalidateRect(infoPtr->hwndSelf, 0, 1);
3418 REBAR_SetBandInfoW (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3420 LPREBARBANDINFOW lprbbi = (LPREBARBANDINFOW)lParam;
3425 if (lprbbi->cbSize < REBARBANDINFO_V3_SIZEW)
3427 if ((UINT)wParam >= infoPtr->uNumBands)
3430 TRACE("index %u\n", (UINT)wParam);
3431 REBAR_DumpBandInfo ((LPREBARBANDINFOA)lprbbi);
3433 /* set band information */
3434 lpBand = &infoPtr->bands[(UINT)wParam];
3436 REBAR_CommonSetupBand (infoPtr->hwndSelf, (LPREBARBANDINFOA)lprbbi, lpBand);
3437 if (lprbbi->fMask & RBBIM_TEXT) {
3438 if (lpBand->lpText) {
3439 COMCTL32_Free (lpBand->lpText);
3440 lpBand->lpText = NULL;
3442 if (lprbbi->lpText) {
3443 INT len = lstrlenW (lprbbi->lpText);
3444 lpBand->lpText = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
3445 strcpyW (lpBand->lpText, lprbbi->lpText);
3449 REBAR_ValidateBand (infoPtr, lpBand);
3451 REBAR_DumpBand (infoPtr);
3453 if (lprbbi->fMask & (RBBIM_CHILDSIZE | RBBIM_SIZE)) {
3454 REBAR_Layout (infoPtr, NULL, TRUE, FALSE);
3455 InvalidateRect(infoPtr->hwndSelf, 0, 1);
3463 REBAR_SetBarInfo (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3465 LPREBARINFO lpInfo = (LPREBARINFO)lParam;
3472 if (lpInfo->cbSize < sizeof (REBARINFO))
3475 TRACE("setting bar info!\n");
3477 if (lpInfo->fMask & RBIM_IMAGELIST) {
3478 infoPtr->himl = lpInfo->himl;
3479 if (infoPtr->himl) {
3481 ImageList_GetIconSize (infoPtr->himl, &cx, &cy);
3482 infoPtr->imageSize.cx = cx;
3483 infoPtr->imageSize.cy = cy;
3486 infoPtr->imageSize.cx = 0;
3487 infoPtr->imageSize.cy = 0;
3489 TRACE("new image cx=%ld, cy=%ld\n", infoPtr->imageSize.cx,
3490 infoPtr->imageSize.cy);
3493 /* revalidate all bands to reset flags for images in headers of bands */
3494 for (i=0; i<infoPtr->uNumBands; i++) {
3495 lpBand = &infoPtr->bands[i];
3496 REBAR_ValidateBand (infoPtr, lpBand);
3504 REBAR_SetBkColor (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3508 clrTemp = infoPtr->clrBk;
3509 infoPtr->clrBk = (COLORREF)lParam;
3511 TRACE("background color 0x%06lx!\n", infoPtr->clrBk);
3517 /* << REBAR_SetColorScheme >> */
3518 /* << REBAR_SetPalette >> */
3522 REBAR_SetParent (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3524 HWND hwndTemp = infoPtr->hwndNotify;
3526 infoPtr->hwndNotify = (HWND)wParam;
3528 return (LRESULT)hwndTemp;
3533 REBAR_SetTextColor (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3537 clrTemp = infoPtr->clrText;
3538 infoPtr->clrText = (COLORREF)lParam;
3540 TRACE("text color 0x%06lx!\n", infoPtr->clrText);
3546 /* << REBAR_SetTooltips >> */
3549 inline static LRESULT
3550 REBAR_SetUnicodeFormat (REBAR_INFO *infoPtr, WPARAM wParam)
3552 BOOL bTemp = infoPtr->bUnicode;
3554 TRACE("to %s hwnd=0x%04x, was %s\n",
3555 ((BOOL)wParam) ? "TRUE" : "FALSE", infoPtr->hwndSelf,
3556 (bTemp) ? "TRUE" : "FALSE");
3558 infoPtr->bUnicode = (BOOL)wParam;
3565 REBAR_SetVersion (REBAR_INFO *infoPtr, INT iVersion)
3567 INT iOldVersion = infoPtr->iVersion;
3569 if (iVersion > COMCTL32_VERSION)
3572 infoPtr->iVersion = iVersion;
3574 TRACE("new version %d\n", iVersion);
3581 REBAR_ShowBand (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3585 if (((INT)wParam < 0) || ((INT)wParam > infoPtr->uNumBands))
3588 lpBand = &infoPtr->bands[(INT)wParam];
3591 TRACE("show band %d\n", (INT)wParam);
3592 lpBand->fStyle = lpBand->fStyle & ~RBBS_HIDDEN;
3593 if (IsWindow (lpBand->hwndChild))
3594 ShowWindow (lpBand->hwndChild, SW_SHOW);
3597 TRACE("hide band %d\n", (INT)wParam);
3598 lpBand->fStyle = lpBand->fStyle | RBBS_HIDDEN;
3599 if (IsWindow (lpBand->hwndChild))
3600 ShowWindow (lpBand->hwndChild, SW_HIDE);
3603 REBAR_Layout (infoPtr, NULL, TRUE, FALSE);
3604 InvalidateRect(infoPtr->hwndSelf, 0, 1);
3611 REBAR_SizeToRect (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3613 LPRECT lpRect = (LPRECT)lParam;
3619 TRACE("[%d %d %d %d]\n",
3620 lpRect->left, lpRect->top, lpRect->right, lpRect->bottom);
3622 /* what is going on???? */
3623 GetWindowRect(infoPtr->hwndSelf, &t1);
3624 TRACE("window rect [%d %d %d %d]\n",
3625 t1.left, t1.top, t1.right, t1.bottom);
3626 GetClientRect(infoPtr->hwndSelf, &t1);
3627 TRACE("client rect [%d %d %d %d]\n",
3628 t1.left, t1.top, t1.right, t1.bottom);
3630 /* force full _Layout processing */
3631 TRACE("setting NEEDS_LAYOUT\n");
3632 infoPtr->fStatus |= BAND_NEEDS_LAYOUT;
3633 REBAR_Layout (infoPtr, lpRect, TRUE, FALSE);
3634 InvalidateRect (infoPtr->hwndSelf, NULL, TRUE);
3641 REBAR_Create (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3643 LPCREATESTRUCTA cs = (LPCREATESTRUCTA) lParam;
3646 if (TRACE_ON(rebar)) {
3647 GetWindowRect(infoPtr->hwndSelf, &wnrc1);
3648 GetClientRect(infoPtr->hwndSelf, &clrc1);
3649 TRACE("window=(%d,%d)-(%d,%d) client=(%d,%d)-(%d,%d) cs=(%d,%d %dx%d)\n",
3650 wnrc1.left, wnrc1.top, wnrc1.right, wnrc1.bottom,
3651 clrc1.left, clrc1.top, clrc1.right, clrc1.bottom,
3652 cs->x, cs->y, cs->cx, cs->cy);
3655 TRACE("created!\n");
3661 REBAR_Destroy (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3667 /* free rebar bands */
3668 if ((infoPtr->uNumBands > 0) && infoPtr->bands) {
3669 /* clean up each band */
3670 for (i = 0; i < infoPtr->uNumBands; i++) {
3671 lpBand = &infoPtr->bands[i];
3673 /* delete text strings */
3674 if (lpBand->lpText) {
3675 COMCTL32_Free (lpBand->lpText);
3676 lpBand->lpText = NULL;
3678 /* destroy child window */
3679 DestroyWindow (lpBand->hwndChild);
3682 /* free band array */
3683 COMCTL32_Free (infoPtr->bands);
3684 infoPtr->bands = NULL;
3687 DeleteObject (infoPtr->hcurArrow);
3688 DeleteObject (infoPtr->hcurHorz);
3689 DeleteObject (infoPtr->hcurVert);
3690 DeleteObject (infoPtr->hcurDrag);
3691 if(infoPtr->hDefaultFont) DeleteObject (infoPtr->hDefaultFont);
3692 SetWindowLongA (infoPtr->hwndSelf, 0, 0);
3694 /* free rebar info data */
3695 COMCTL32_Free (infoPtr);
3696 TRACE("destroyed!\n");
3702 REBAR_EraseBkGnd (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3706 if (GetClipBox ( (HDC)wParam, &cliprect))
3707 return REBAR_InternalEraseBkGnd (infoPtr, wParam, lParam, &cliprect);
3713 REBAR_GetFont (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3715 return (LRESULT)infoPtr->hFont;
3720 REBAR_LButtonDown (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3724 /* If InternalHitTest did not find a hit on the Gripper, */
3725 /* then ignore the button click. */
3726 if (infoPtr->ihitBand == -1) return 0;
3728 SetCapture (infoPtr->hwndSelf);
3730 /* save off the LOWORD and HIWORD of lParam as initial x,y */
3731 lpBand = &infoPtr->bands[infoPtr->ihitBand];
3732 infoPtr->dragStart = MAKEPOINTS(lParam);
3733 infoPtr->dragNow = infoPtr->dragStart;
3734 if (infoPtr->dwStyle & CCS_VERT)
3735 infoPtr->ihitoffset = infoPtr->dragStart.y - (lpBand->rcBand.top+REBAR_PRE_GRIPPER);
3737 infoPtr->ihitoffset = infoPtr->dragStart.x - (lpBand->rcBand.left+REBAR_PRE_GRIPPER);
3744 REBAR_LButtonUp (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3750 /* If InternalHitTest did not find a hit on the Gripper, */
3751 /* then ignore the button click. */
3752 if (infoPtr->ihitBand == -1) return 0;
3754 ihitBand = infoPtr->ihitBand;
3755 infoPtr->dragStart.x = 0;
3756 infoPtr->dragStart.y = 0;
3757 infoPtr->dragNow = infoPtr->dragStart;
3758 infoPtr->ihitBand = -1;
3762 if (infoPtr->fStatus & BEGIN_DRAG_ISSUED) {
3763 REBAR_Notify((NMHDR *) &layout, infoPtr, RBN_LAYOUTCHANGED);
3764 REBAR_Notify_NMREBAR (infoPtr, ihitBand, RBN_ENDDRAG);
3765 infoPtr->fStatus &= ~BEGIN_DRAG_ISSUED;
3768 GetClientRect(infoPtr->hwndSelf, &rect);
3769 InvalidateRect(infoPtr->hwndSelf, NULL, TRUE);
3776 REBAR_MouseMove (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3778 REBAR_BAND *band1, *band2;
3781 /* Validate entry as hit on Gripper has occurred */
3782 if (GetCapture() != infoPtr->hwndSelf) return 0;
3783 if (infoPtr->ihitBand == -1) return 0;
3785 ptsmove = MAKEPOINTS(lParam);
3787 /* if mouse did not move much, exit */
3788 if ((abs(ptsmove.x - infoPtr->dragNow.x) <= mindragx) &&
3789 (abs(ptsmove.y - infoPtr->dragNow.y) <= mindragy)) return 0;
3791 band1 = &infoPtr->bands[infoPtr->ihitBand-1];
3792 band2 = &infoPtr->bands[infoPtr->ihitBand];
3794 /* Test for valid drag case - must not be first band in row */
3795 if (infoPtr->dwStyle & CCS_VERT) {
3796 if ((ptsmove.x < band2->rcBand.left) ||
3797 (ptsmove.x > band2->rcBand.right) ||
3798 ((infoPtr->ihitBand > 0) && (band1->iRow != band2->iRow))) {
3799 FIXME("Cannot drag to other rows yet!!\n");
3802 REBAR_HandleLRDrag (infoPtr, &ptsmove);
3806 if ((ptsmove.y < band2->rcBand.top) ||
3807 (ptsmove.y > band2->rcBand.bottom) ||
3808 ((infoPtr->ihitBand > 0) && (band1->iRow != band2->iRow))) {
3809 FIXME("Cannot drag to other rows yet!!\n");
3812 REBAR_HandleLRDrag (infoPtr, &ptsmove);
3819 inline static LRESULT
3820 REBAR_NCCalcSize (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3822 if (infoPtr->dwStyle & WS_BORDER) {
3823 InflateRect((LPRECT)lParam, -GetSystemMetrics(SM_CXEDGE),
3824 -GetSystemMetrics(SM_CYEDGE));
3826 TRACE("new client=(%d,%d)-(%d,%d)\n",
3827 ((LPRECT)lParam)->left, ((LPRECT)lParam)->top,
3828 ((LPRECT)lParam)->right, ((LPRECT)lParam)->bottom);
3834 REBAR_NCCreate (HWND hwnd, WPARAM wParam, LPARAM lParam)
3836 LPCREATESTRUCTA cs = (LPCREATESTRUCTA) lParam;
3837 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
3839 NONCLIENTMETRICSA ncm;
3843 if (infoPtr != NULL) {
3844 ERR("Strange info structure pointer *not* NULL\n");
3848 if (TRACE_ON(rebar)) {
3849 GetWindowRect(hwnd, &wnrc1);
3850 GetClientRect(hwnd, &clrc1);
3851 TRACE("window=(%d,%d)-(%d,%d) client=(%d,%d)-(%d,%d) cs=(%d,%d %dx%d)\n",
3852 wnrc1.left, wnrc1.top, wnrc1.right, wnrc1.bottom,
3853 clrc1.left, clrc1.top, clrc1.right, clrc1.bottom,
3854 cs->x, cs->y, cs->cx, cs->cy);
3857 /* allocate memory for info structure */
3858 infoPtr = (REBAR_INFO *)COMCTL32_Alloc (sizeof(REBAR_INFO));
3859 SetWindowLongA (hwnd, 0, (DWORD)infoPtr);
3861 /* initialize info structure - initial values are 0 */
3862 infoPtr->clrBk = CLR_NONE;
3863 infoPtr->clrText = CLR_NONE;
3864 infoPtr->clrBtnText = GetSysColor (COLOR_BTNTEXT);
3865 infoPtr->clrBtnFace = GetSysColor (COLOR_BTNFACE);
3866 infoPtr->ihitBand = -1;
3867 infoPtr->hwndSelf = hwnd;
3868 infoPtr->DoRedraw = TRUE;
3869 infoPtr->hcurArrow = LoadCursorA (0, IDC_ARROWA);
3870 infoPtr->hcurHorz = LoadCursorA (0, IDC_SIZEWEA);
3871 infoPtr->hcurVert = LoadCursorA (0, IDC_SIZENSA);
3872 infoPtr->hcurDrag = LoadCursorA (0, IDC_SIZEA);
3873 infoPtr->bUnicode = IsWindowUnicode (hwnd);
3874 infoPtr->fStatus = CREATE_RUNNING;
3875 infoPtr->hFont = GetStockObject (SYSTEM_FONT);
3877 /* issue WM_NOTIFYFORMAT to get unicode status of parent */
3878 i = SendMessageA(REBAR_GetNotifyParent (infoPtr),
3879 WM_NOTIFYFORMAT, hwnd, NF_QUERY);
3880 if ((i < NFR_ANSI) || (i > NFR_UNICODE)) {
3881 ERR("wrong response to WM_NOTIFYFORMAT (%d), assuming ANSI\n",
3885 infoPtr->NtfUnicode = (i == NFR_UNICODE) ? 1 : 0;
3887 /* add necessary styles to the requested styles */
3888 infoPtr->dwStyle = cs->style | WS_VISIBLE | CCS_TOP;
3889 SetWindowLongA (hwnd, GWL_STYLE, infoPtr->dwStyle);
3891 /* get font handle for Caption Font */
3892 ncm.cbSize = sizeof(NONCLIENTMETRICSA);
3893 SystemParametersInfoA (SPI_GETNONCLIENTMETRICS,
3894 ncm.cbSize, &ncm, 0);
3895 /* if the font is bold, set to normal */
3896 if (ncm.lfCaptionFont.lfWeight > FW_NORMAL) {
3897 ncm.lfCaptionFont.lfWeight = FW_NORMAL;
3899 tfont = CreateFontIndirectA (&ncm.lfCaptionFont);
3901 infoPtr->hFont = infoPtr->hDefaultFont = tfont;
3905 GetSysColor (numerous);
3906 GetSysColorBrush (numerous) (see WM_SYSCOLORCHANGE);
3907 *GetStockObject (SYSTEM_FONT);
3908 *SetWindowLong (hwnd, 0, info ptr);
3910 *SetWindowLong (hwnd, GWL_STYLE, style+0x10000001);
3911 WS_VISIBLE = 0x10000000;
3912 CCS_TOP = 0x00000001;
3913 *SystemParametersInfo (SPI_GETNONCLIENTMETRICS...);
3914 *CreateFontIndirect (lfCaptionFont from above);
3916 SelectObject (hdc, fontabove);
3917 GetTextMetrics (hdc, ); guessing is tmHeight
3918 SelectObject (hdc, oldfont);
3921 MapWindowPoints (0, parent, rectabove, 2);
3924 ClientToScreen (clientrect);
3925 SetWindowPos (hwnd, 0, 0, 0, 0, 0, SWP_NOZORDER);
3932 REBAR_NCHitTest (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3939 LRESULT ret = HTCLIENT;
3942 * Differences from doc at MSDN (as observed with version 4.71 of
3944 * 1. doc says nmmouse.pt is in screen coord, trace shows client coord.
3945 * 2. if band is not identified .dwItemSpec is 0xffffffff.
3946 * 3. native always seems to return HTCLIENT if notify return is 0.
3949 shortpt = MAKEPOINTS (lParam);
3950 POINTSTOPOINT(pt, shortpt);
3952 ScreenToClient (infoPtr->hwndSelf, &clpt);
3953 REBAR_InternalHitTest (infoPtr, &clpt, &scrap,
3954 (INT *)&nmmouse.dwItemSpec);
3955 nmmouse.dwItemData = 0;
3957 nmmouse.dwHitInfo = 0;
3958 if ((i = REBAR_Notify((NMHDR *) &nmmouse, infoPtr, NM_NCHITTEST))) {
3959 TRACE("notify changed return value from %ld to %d\n",
3963 TRACE("returning %ld, client point (%ld,%ld)\n", ret, clpt.x, clpt.y);
3969 REBAR_NCPaint (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3974 if (infoPtr->dwStyle & WS_MINIMIZE)
3975 return 0; /* Nothing to do */
3977 if (infoPtr->dwStyle & WS_BORDER) {
3979 /* adjust rectangle and draw the necessary edge */
3980 if (!(hdc = GetDCEx( infoPtr->hwndSelf, 0, DCX_USESTYLE | DCX_WINDOW )))
3982 GetWindowRect (infoPtr->hwndSelf, &rcWindow);
3983 OffsetRect (&rcWindow, -rcWindow.left, -rcWindow.top);
3984 TRACE("rect (%d,%d)-(%d,%d)\n",
3985 rcWindow.left, rcWindow.top,
3986 rcWindow.right, rcWindow.bottom);
3987 DrawEdge (hdc, &rcWindow, EDGE_ETCHED, BF_RECT);
3988 ReleaseDC( infoPtr->hwndSelf, hdc );
3996 REBAR_NotifyFormat (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
4000 if (lParam == NF_REQUERY) {
4001 i = SendMessageA(REBAR_GetNotifyParent (infoPtr),
4002 WM_NOTIFYFORMAT, infoPtr->hwndSelf, NF_QUERY);
4003 if ((i < NFR_ANSI) || (i > NFR_UNICODE)) {
4004 ERR("wrong response to WM_NOTIFYFORMAT (%d), assuming ANSI\n",
4008 infoPtr->NtfUnicode = (i == NFR_UNICODE) ? 1 : 0;
4011 return (LRESULT)((infoPtr->bUnicode) ? NFR_UNICODE : NFR_ANSI);
4016 REBAR_Paint (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
4022 GetClientRect(infoPtr->hwndSelf, &rc);
4023 hdc = wParam==0 ? BeginPaint (infoPtr->hwndSelf, &ps) : (HDC)wParam;
4025 TRACE("painting (%d,%d)-(%d,%d) client (%d,%d)-(%d,%d)\n",
4026 ps.rcPaint.left, ps.rcPaint.top,
4027 ps.rcPaint.right, ps.rcPaint.bottom,
4028 rc.left, rc.top, rc.right, rc.bottom);
4031 /* Erase area of paint if requested */
4032 REBAR_InternalEraseBkGnd (infoPtr, wParam, lParam, &ps.rcPaint);
4035 REBAR_Refresh (infoPtr, hdc);
4037 EndPaint (infoPtr->hwndSelf, &ps);
4043 REBAR_SetCursor (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
4048 TRACE("code=0x%X id=0x%X\n", LOWORD(lParam), HIWORD(lParam));
4051 ScreenToClient (infoPtr->hwndSelf, &pt);
4053 REBAR_InternalHitTest (infoPtr, &pt, &flags, NULL);
4055 if (flags == RBHT_GRABBER) {
4056 if ((infoPtr->dwStyle & CCS_VERT) &&
4057 !(infoPtr->dwStyle & RBS_VERTICALGRIPPER))
4058 SetCursor (infoPtr->hcurVert);
4060 SetCursor (infoPtr->hcurHorz);
4062 else if (flags != RBHT_CLIENT)
4063 SetCursor (infoPtr->hcurArrow);
4070 REBAR_SetFont (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
4076 infoPtr->hFont = (HFONT)wParam;
4078 /* revalidate all bands to change sizes of text in headers of bands */
4079 for (i=0; i<infoPtr->uNumBands; i++) {
4080 lpBand = &infoPtr->bands[i];
4081 REBAR_ValidateBand (infoPtr, lpBand);
4085 if (LOWORD(lParam)) {
4086 GetClientRect (infoPtr->hwndSelf, &rcClient);
4087 REBAR_Layout (infoPtr, &rcClient, FALSE, TRUE);
4094 inline static LRESULT
4095 REBAR_SetRedraw (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
4096 /*****************************************************
4099 * Handles the WM_SETREDRAW message.
4102 * According to testing V4.71 of COMCTL32 returns the
4103 * *previous* status of the redraw flag (either 0 or -1)
4104 * instead of the MSDN documented value of 0 if handled
4106 *****************************************************/
4108 BOOL oldredraw = infoPtr->DoRedraw;
4110 TRACE("set to %s, fStatus=%08x\n",
4111 (wParam) ? "TRUE" : "FALSE", infoPtr->fStatus);
4112 infoPtr->DoRedraw = (BOOL) wParam;
4114 if (infoPtr->fStatus & BAND_NEEDS_REDRAW) {
4115 REBAR_MoveChildWindows (infoPtr, 0, infoPtr->uNumBands);
4116 REBAR_ForceResize (infoPtr);
4117 InvalidateRect (infoPtr->hwndSelf, 0, TRUE);
4119 infoPtr->fStatus &= ~BAND_NEEDS_REDRAW;
4121 return (oldredraw) ? -1 : 0;
4126 REBAR_Size (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
4130 /* auto resize deadlock check */
4131 if (infoPtr->fStatus & AUTO_RESIZE) {
4132 infoPtr->fStatus &= ~AUTO_RESIZE;
4133 TRACE("AUTO_RESIZE was set, reset, fStatus=%08x lparam=%08lx\n",
4134 infoPtr->fStatus, lParam);
4138 if (infoPtr->fStatus & CREATE_RUNNING) {
4139 /* still in CreateWindow */
4142 if ((INT)wParam != SIZE_RESTORED) {
4143 ERR("WM_SIZE in create and flags=%08x, lParam=%08lx\n",
4147 TRACE("still in CreateWindow\n");
4148 infoPtr->fStatus &= ~CREATE_RUNNING;
4149 GetWindowRect ( infoPtr->hwndSelf, &rcWin);
4150 TRACE("win rect (%d,%d)-(%d,%d)\n",
4151 rcWin.left, rcWin.top, rcWin.right, rcWin.bottom);
4153 if ((lParam == 0) && (rcWin.right-rcWin.left == 0) &&
4154 (rcWin.bottom-rcWin.top == 0)) {
4155 /* native control seems to do this */
4156 GetClientRect (GetParent(infoPtr->hwndSelf), &rcClient);
4157 TRACE("sizing rebar, message and client zero, parent client (%d,%d)\n",
4158 rcClient.right, rcClient.bottom);
4163 cx = rcWin.right - rcWin.left;
4164 cy = rcWin.bottom - rcWin.top;
4165 if ((cx == LOWORD(lParam)) && (cy == HIWORD(lParam))) {
4169 /* do the actual WM_SIZE request */
4170 GetClientRect (infoPtr->hwndSelf, &rcClient);
4171 TRACE("sizing rebar from (%ld,%ld) to (%d,%d), client (%d,%d)\n",
4172 infoPtr->calcSize.cx, infoPtr->calcSize.cy,
4173 LOWORD(lParam), HIWORD(lParam),
4174 rcClient.right, rcClient.bottom);
4178 if ((INT)wParam != SIZE_RESTORED) {
4179 ERR("WM_SIZE out of create and flags=%08x, lParam=%08lx\n",
4183 /* Handle cases when outside of the CreateWindow process */
4185 GetClientRect (infoPtr->hwndSelf, &rcClient);
4186 if ((lParam == 0) && (rcClient.right + rcClient.bottom != 0) &&
4187 (infoPtr->dwStyle & RBS_AUTOSIZE)) {
4188 /* on a WM_SIZE to zero and current client not zero and AUTOSIZE */
4189 /* native seems to use the current client rect for the size */
4190 infoPtr->fStatus |= BAND_NEEDS_LAYOUT;
4191 TRACE("sizing rebar to client (%d,%d) size is zero but AUTOSIZE set\n",
4192 rcClient.right, rcClient.bottom);
4195 TRACE("sizing rebar from (%ld,%ld) to (%d,%d), client (%d,%d)\n",
4196 infoPtr->calcSize.cx, infoPtr->calcSize.cy,
4197 LOWORD(lParam), HIWORD(lParam),
4198 rcClient.right, rcClient.bottom);
4202 if (infoPtr->dwStyle & RBS_AUTOSIZE) {
4203 NMRBAUTOSIZE autosize;
4205 GetClientRect(infoPtr->hwndSelf, &autosize.rcTarget);
4206 autosize.fChanged = 0; /* ??? */
4207 autosize.rcActual = autosize.rcTarget; /* ??? */
4208 REBAR_Notify((NMHDR *) &autosize, infoPtr, RBN_AUTOSIZE);
4209 TRACE("RBN_AUTOSIZE client=(%d,%d), lp=%08lx\n",
4210 autosize.rcTarget.right, autosize.rcTarget.bottom, lParam);
4213 if ((infoPtr->calcSize.cx != rcClient.right) ||
4214 (infoPtr->calcSize.cy != rcClient.bottom))
4215 infoPtr->fStatus |= BAND_NEEDS_LAYOUT;
4217 REBAR_Layout (infoPtr, &rcClient, TRUE, TRUE);
4218 infoPtr->fStatus &= ~AUTO_RESIZE;
4225 REBAR_StyleChanged (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
4227 STYLESTRUCT *ss = (STYLESTRUCT *)lParam;
4229 TRACE("current style=%08lx, styleOld=%08lx, style being set to=%08lx\n",
4230 infoPtr->dwStyle, ss->styleOld, ss->styleNew);
4231 infoPtr->dwStyle = ss->styleNew;
4238 REBAR_WindowPosChanged (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
4240 WINDOWPOS *lpwp = (WINDOWPOS *)lParam;
4244 /* Save the new origin of this window - used by _ForceResize */
4245 infoPtr->origin.x = lpwp->x;
4246 infoPtr->origin.y = lpwp->y;
4247 ret = DefWindowProcA(infoPtr->hwndSelf, WM_WINDOWPOSCHANGED,
4249 GetWindowRect(infoPtr->hwndSelf, &rc);
4250 TRACE("hwnd %08x new pos (%d,%d)-(%d,%d)\n",
4251 infoPtr->hwndSelf, rc.left, rc.top, rc.right, rc.bottom);
4256 static LRESULT WINAPI
4257 REBAR_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
4259 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
4261 TRACE("hwnd=%x msg=%x wparam=%x lparam=%lx\n",
4262 hwnd, uMsg, /* SPY_GetMsgName(uMsg), */ wParam, lParam);
4263 if (!infoPtr && (uMsg != WM_NCCREATE))
4264 return DefWindowProcA (hwnd, uMsg, wParam, lParam);
4267 /* case RB_BEGINDRAG: */
4270 return REBAR_DeleteBand (infoPtr, wParam, lParam);
4272 /* case RB_DRAGMOVE: */
4273 /* case RB_ENDDRAG: */
4275 case RB_GETBANDBORDERS:
4276 return REBAR_GetBandBorders (infoPtr, wParam, lParam);
4278 case RB_GETBANDCOUNT:
4279 return REBAR_GetBandCount (infoPtr);
4281 case RB_GETBANDINFO: /* obsoleted after IE3, but we have to
4282 support it anyway. */
4283 case RB_GETBANDINFOA:
4284 return REBAR_GetBandInfoA (infoPtr, wParam, lParam);
4286 case RB_GETBANDINFOW:
4287 return REBAR_GetBandInfoW (infoPtr, wParam, lParam);
4289 case RB_GETBARHEIGHT:
4290 return REBAR_GetBarHeight (infoPtr, wParam, lParam);
4293 return REBAR_GetBarInfo (infoPtr, wParam, lParam);
4296 return REBAR_GetBkColor (infoPtr);
4298 /* case RB_GETCOLORSCHEME: */
4299 /* case RB_GETDROPTARGET: */
4302 return REBAR_GetPalette (infoPtr, wParam, lParam);
4305 return REBAR_GetRect (infoPtr, wParam, lParam);
4307 case RB_GETROWCOUNT:
4308 return REBAR_GetRowCount (infoPtr);
4310 case RB_GETROWHEIGHT:
4311 return REBAR_GetRowHeight (infoPtr, wParam, lParam);
4313 case RB_GETTEXTCOLOR:
4314 return REBAR_GetTextColor (infoPtr);
4316 case RB_GETTOOLTIPS:
4317 return REBAR_GetToolTips (infoPtr);
4319 case RB_GETUNICODEFORMAT:
4320 return REBAR_GetUnicodeFormat (infoPtr);
4322 case CCM_GETVERSION:
4323 return REBAR_GetVersion (infoPtr);
4326 return REBAR_HitTest (infoPtr, wParam, lParam);
4329 return REBAR_IdToIndex (infoPtr, wParam, lParam);
4331 case RB_INSERTBANDA:
4332 return REBAR_InsertBandA (infoPtr, wParam, lParam);
4334 case RB_INSERTBANDW:
4335 return REBAR_InsertBandW (infoPtr, wParam, lParam);
4337 case RB_MAXIMIZEBAND:
4338 return REBAR_MaximizeBand (infoPtr, wParam, lParam);
4340 case RB_MINIMIZEBAND:
4341 return REBAR_MinimizeBand (infoPtr, wParam, lParam);
4344 return REBAR_MoveBand (infoPtr, wParam, lParam);
4346 case RB_SETBANDINFOA:
4347 return REBAR_SetBandInfoA (infoPtr, wParam, lParam);
4349 case RB_SETBANDINFOW:
4350 return REBAR_SetBandInfoW (infoPtr, wParam, lParam);
4353 return REBAR_SetBarInfo (infoPtr, wParam, lParam);
4356 return REBAR_SetBkColor (infoPtr, wParam, lParam);
4358 /* case RB_SETCOLORSCHEME: */
4359 /* case RB_SETPALETTE: */
4360 /* return REBAR_GetPalette (infoPtr, wParam, lParam); */
4363 return REBAR_SetParent (infoPtr, wParam, lParam);
4365 case RB_SETTEXTCOLOR:
4366 return REBAR_SetTextColor (infoPtr, wParam, lParam);
4368 /* case RB_SETTOOLTIPS: */
4370 case RB_SETUNICODEFORMAT:
4371 return REBAR_SetUnicodeFormat (infoPtr, wParam);
4373 case CCM_SETVERSION:
4374 return REBAR_SetVersion (infoPtr, (INT)wParam);
4377 return REBAR_ShowBand (infoPtr, wParam, lParam);
4380 return REBAR_SizeToRect (infoPtr, wParam, lParam);
4383 /* Messages passed to parent */
4387 if (infoPtr->NtfUnicode)
4388 return SendMessageW (REBAR_GetNotifyParent (infoPtr),
4389 uMsg, wParam, lParam);
4391 return SendMessageA (REBAR_GetNotifyParent (infoPtr),
4392 uMsg, wParam, lParam);
4395 /* case WM_CHARTOITEM: supported according to ControlSpy */
4398 return REBAR_Create (infoPtr, wParam, lParam);
4401 return REBAR_Destroy (infoPtr, wParam, lParam);
4404 return REBAR_EraseBkGnd (infoPtr, wParam, lParam);
4407 return REBAR_GetFont (infoPtr, wParam, lParam);
4409 /* case WM_LBUTTONDBLCLK: supported according to ControlSpy */
4411 case WM_LBUTTONDOWN:
4412 return REBAR_LButtonDown (infoPtr, wParam, lParam);
4415 return REBAR_LButtonUp (infoPtr, wParam, lParam);
4417 /* case WM_MEASUREITEM: supported according to ControlSpy */
4420 return REBAR_MouseMove (infoPtr, wParam, lParam);
4423 return REBAR_NCCalcSize (infoPtr, wParam, lParam);
4426 return REBAR_NCCreate (hwnd, wParam, lParam);
4429 return REBAR_NCHitTest (infoPtr, wParam, lParam);
4432 return REBAR_NCPaint (infoPtr, wParam, lParam);
4434 case WM_NOTIFYFORMAT:
4435 return REBAR_NotifyFormat (infoPtr, wParam, lParam);
4438 return REBAR_Paint (infoPtr, wParam, lParam);
4440 /* case WM_PALETTECHANGED: supported according to ControlSpy */
4441 /* case WM_PRINTCLIENT: supported according to ControlSpy */
4442 /* case WM_QUERYNEWPALETTE:supported according to ControlSpy */
4443 /* case WM_RBUTTONDOWN: supported according to ControlSpy */
4444 /* case WM_RBUTTONUP: supported according to ControlSpy */
4447 return REBAR_SetCursor (infoPtr, wParam, lParam);
4450 return REBAR_SetFont (infoPtr, wParam, lParam);
4453 return REBAR_SetRedraw (infoPtr, wParam, lParam);
4456 return REBAR_Size (infoPtr, wParam, lParam);
4458 case WM_STYLECHANGED:
4459 return REBAR_StyleChanged (infoPtr, wParam, lParam);
4461 /* case WM_SYSCOLORCHANGE: supported according to ControlSpy */
4462 /* "Applications that have brushes using the existing system colors
4463 should delete those brushes and recreate them using the new
4464 system colors." per MSDN */
4466 /* case WM_VKEYTOITEM: supported according to ControlSpy */
4467 /* case WM_WININICHANGE: */
4469 case WM_WINDOWPOSCHANGED:
4470 return REBAR_WindowPosChanged (infoPtr, wParam, lParam);
4473 if (uMsg >= WM_USER)
4474 ERR("unknown msg %04x wp=%08x lp=%08lx\n",
4475 uMsg, wParam, lParam);
4476 return DefWindowProcA (hwnd, uMsg, wParam, lParam);
4483 REBAR_Register (void)
4487 ZeroMemory (&wndClass, sizeof(WNDCLASSA));
4488 wndClass.style = CS_GLOBALCLASS | CS_DBLCLKS;
4489 wndClass.lpfnWndProc = (WNDPROC)REBAR_WindowProc;
4490 wndClass.cbClsExtra = 0;
4491 wndClass.cbWndExtra = sizeof(REBAR_INFO *);
4492 wndClass.hCursor = 0;
4493 wndClass.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1);
4495 wndClass.hbrBackground = CreateSolidBrush(RGB(0,128,0));
4497 wndClass.lpszClassName = REBARCLASSNAMEA;
4499 RegisterClassA (&wndClass);
4501 mindragx = GetSystemMetrics (SM_CXDRAG);
4502 mindragy = GetSystemMetrics (SM_CYDRAG);
4508 REBAR_Unregister (void)
4510 UnregisterClassA (REBARCLASSNAMEA, (HINSTANCE)NULL);