2 * Testing: set to 1 to make background brush *always* green
8 * 2. At "FIXME: problem # 2" WinRAR:
9 * if "#if 1" then last band draws in separate row
10 * if "#if 0" then last band draws in previous row *** just like native ***
16 * 3. REBAR_MoveChildWindows should have a loop because more than
17 * one pass is made (together with the RBN_CHILDSIZEs) is made on
18 * at least RB_INSERTBAND
23 * Rebar control rev 8e
25 * Copyright 1998, 1999 Eric Kohl
27 * This library is free software; you can redistribute it and/or
28 * modify it under the terms of the GNU Lesser General Public
29 * License as published by the Free Software Foundation; either
30 * version 2.1 of the License, or (at your option) any later version.
32 * This library is distributed in the hope that it will be useful,
33 * but WITHOUT ANY WARRANTY; without even the implied warranty of
34 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
35 * Lesser General Public License for more details.
37 * You should have received a copy of the GNU Lesser General Public
38 * License along with this library; if not, write to the Free Software
39 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
42 * An author is needed! Any volunteers?
43 * I will only improve this control once in a while.
44 * Eric <ekohl@abo.rhein-zeitung.de>
47 * - vertical placement
48 * - ComboBox and ComboBoxEx placement
53 * - All notifications.
55 * Changes Guy Albertelli <galberte@neo.lrun.com>
57 * - Implement initial version of row grouping, row separators,
58 * text and background colors. Support additional messages.
59 * Support RBBS_BREAK. Implement ERASEBKGND and improve painting.
61 * - implement support for dragging Gripper left or right in a row. Supports
62 * WM_LBUTTONDOWN, WM_LBUTTONUP, and WM_MOUSEMOVE. Also support
65 * - Fix or implement notifications for RBN_HEIGHTCHANGE, RBN_CHILDSIZE.
66 * - Correct styles RBBS_NOGRIPPER, RBBS_GRIPPERALWAYS, and RBBS_FIXEDSIZE.
67 * - Fix algorithm for Layout and AdjustBand.
70 * - Fix algorithm for _Layout and _AdjustBand.
71 * - Fix or implement RBN_ENDDRAG, RB_MOVEBAND, WM_SETREDRAW,
72 * WM_STYLECHANGED, RB_MINIMIZEBAND, RBBS_VARIABLEHEIGHT, RBS_VARHEIGHT,
73 * RBBS_HIDDEN, WM_NOTIFYFORMAT, NM_NCHITTEST, WM_SETREDRAW, RBS_AUTOSIZE,
74 * WM_SETFONT, RBS_BORDERS
75 * - Create structures in WM_NCCREATE
76 * - Additional performance enhancements.
79 * 1. Create array of start and end band indexes by row and use.
80 * 2. Fix problem with REBAR_Layout Phase 2b to process only if only
82 * 3. Set the Caption Font (Regular) as default font for text.
83 * 4. Delete font handle on control distruction.
84 * 5. Add UpdateWindow call in _MoveChildWindows to match repainting done
86 * 6. Improve some traces.
87 * 7. Invalidate window rectangles after SetBandInfo, InsertBand, ShowBand
88 * so that repainting is correct.
89 * 8. Implement RB_MAXIMIZEBAND for the "ideal=TRUE" case.
90 * 9. Implement item custom draw notifications partially. Only done for
91 * ITEMPREPAINT and ITEMPOSTPAINT. (Used by IE4 for "Favorites" frame
92 * to draw the word "Favorites").
94 * 10. Handle CCS_NODIVIDER and fix WS_BORDER code.
95 * 11. Fix logic error in _AdjustBands where flag was set to valid band
96 * number (0) to indicate *no* band.
97 * 12. Fix CCS_VERT errors in _ForceResize, _NCCalcSize, and _NCPaint.
98 * 13. Support some special cases of CCS_TOP (and therefore CCS_LEFT),
99 * CCS_BOTTOM (and therefore CCS_RIGHT) and CCS_NOPARENTALIGN. Not
100 * at all sure whether this is all cases.
101 * 14. Handle returned value for the RBN_CHILDSIZE notify.
102 * 15. Implement RBBS_CHILDEDGE, and set each bands "offChild" at _Layout
104 * 16. Fix REBARSPACE. It should depend on CCS_NODIVIDER.
106 * 17. Fix determination of whether Gripper is needed in _ValidateBand.
107 * 18. Fix _AdjustBand processing of RBBS_FIXEDSIZE.
109 * 19. Fix problem in _Layout when all lengths are 0.
110 * 20. If CLR_NONE specified, we will use default BtnFace color when drawing.
111 * 21. Fix test in REBAR_Layout.
113 * 22. Add support for WM_WINDOWPOSCHANGED to save new origin of window.
114 * 23. Correct RBN_CHILDSIZE rect value for CCS_VERT rebar.
115 * 24. Do UpdateWindow only if doing redraws.
117 * 25. Adjust setting of offChild.cx based on RBBS_CHILDEDGE.
121 * 2. Following still not handled: RBBS_FIXEDBMP,
122 * RBBS_USECHEVRON, CCS_NORESIZE,
123 * CCS_NOMOVEX, CCS_NOMOVEY
124 * 3. Following are only partially handled:
125 * RBS_AUTOSIZE, RBBS_VARIABLEHEIGHT
126 * 5. Native uses (on each draw!!) SM_CYBORDER (or SM_CXBORDER for CCS_VERT)
127 * to set the size of the separator width (the value SEP_WIDTH_SIZE
128 * in here). Should be fixed!!
129 * 6. The following messages are not implemented:
130 * RB_BEGINDRAG, RB_DRAGMOVE, RB_ENDDRAG, RB_GETCOLORSCHEME,
131 * RB_GETDROPTARGET, RB_MAXIMIZEBAND,
132 * RB_SETCOLORSCHEME, RB_SETPALETTE, RB_SETTOOLTIPS
133 * WM_CHARTOITEM, WM_LBUTTONDBLCLK, WM_MEASUREITEM,
134 * WM_PALETTECHANGED, WM_PRINTCLIENT, WM_QUERYNEWPALETTE,
135 * WM_RBUTTONDOWN, WM_RBUTTONUP,
136 * WM_SYSCOLORCHANGE, WM_VKEYTOITEM, WM_WININICHANGE
137 * 7. The following notifications are not implemented:
138 * NM_CUSTOMDRAW, NM_RELEASEDCAPTURE
139 * RB_CHEVRONPUSHED, RBN_MINMAX
147 #include "wine/unicode.h"
148 #include "commctrl.h"
149 #include "wine/debug.h"
151 WINE_DEFAULT_DEBUG_CHANNEL(rebar);
161 UINT cxMinChild; /* valid if _CHILDSIZE */
162 UINT cyMinChild; /* valid if _CHILDSIZE */
163 UINT cx; /* valid if _SIZE */
166 UINT cyChild; /* valid if _CHILDSIZE */
167 UINT cyMaxChild; /* valid if _CHILDSIZE */
168 UINT cyIntegral; /* valid if _CHILDSIZE */
173 UINT lcx; /* minimum cx for band */
174 UINT ccx; /* current cx for band */
175 UINT hcx; /* maximum cx for band */
176 UINT lcy; /* minimum cy for band */
177 UINT ccy; /* current cy for band */
178 UINT hcy; /* maximum cy for band */
180 SIZE offChild; /* x,y offset if child is not FIXEDSIZE */
182 INT iRow; /* row this band assigned to */
183 UINT fStatus; /* status flags, reset only by _Validate */
184 UINT fDraw; /* drawing flags, reset only by _Layout */
185 UINT uCDret; /* last return from NM_CUSTOMDRAW */
186 RECT rcoldBand; /* previous calculated band rectangle */
187 RECT rcBand; /* calculated band rectangle */
188 RECT rcGripper; /* calculated gripper rectangle */
189 RECT rcCapImage; /* calculated caption image rectangle */
190 RECT rcCapText; /* calculated caption text rectangle */
191 RECT rcChild; /* calculated child rectangle */
198 #define HAS_GRIPPER 0x00000001
199 #define HAS_IMAGE 0x00000002
200 #define HAS_TEXT 0x00000004
203 #define DRAW_GRIPPER 0x00000001
204 #define DRAW_IMAGE 0x00000002
205 #define DRAW_TEXT 0x00000004
206 #define DRAW_RIGHTSEP 0x00000010
207 #define DRAW_BOTTOMSEP 0x00000020
208 #define NTF_INVALIDATE 0x01000000
212 INT istartband; /* index of first band in row */
213 INT iendband; /* index of last band in row */
219 COLORREF clrBk; /* background color */
220 COLORREF clrText; /* text color */
221 COLORREF clrBtnText; /* system color for BTNTEXT */
222 COLORREF clrBtnFace; /* system color for BTNFACE */
223 HIMAGELIST himl; /* handle to imagelist */
224 UINT uNumBands; /* # of bands in rebar (first=0, last=uNumBands-1 */
225 UINT uNumRows; /* # of rows of bands (first=1, last=uNumRows */
226 HWND hwndSelf; /* handle of REBAR window itself */
227 HWND hwndToolTip; /* handle to the tool tip control */
228 HWND hwndNotify; /* notification window (parent) */
230 HFONT hFont; /* handle to the rebar's font */
231 SIZE imageSize; /* image size (image list) */
232 DWORD dwStyle; /* window style */
233 SIZE calcSize; /* calculated rebar size */
234 SIZE oldSize; /* previous calculated rebar size */
235 BOOL bUnicode; /* TRUE if this window is W type */
236 BOOL NtfUnicode; /* TRUE if parent wants notify in W format */
237 BOOL DoRedraw; /* TRUE to acutally draw bands */
238 UINT fStatus; /* Status flags (see below) */
239 HCURSOR hcurArrow; /* handle to the arrow cursor */
240 HCURSOR hcurHorz; /* handle to the EW cursor */
241 HCURSOR hcurVert; /* handle to the NS cursor */
242 HCURSOR hcurDrag; /* handle to the drag cursor */
243 INT iVersion; /* version number */
244 POINTS dragStart; /* x,y of button down */
245 POINTS dragNow; /* x,y of this MouseMove */
246 INT ihitBand; /* band number of band whose gripper was grabbed */
247 INT ihitoffset; /* offset of hotspot from gripper.left */
248 POINT origin; /* left/upper corner of client */
250 REBAR_ROW *rows; /* pointer to row indexes */
251 REBAR_BAND *bands; /* pointer to the array of rebar bands */
255 #define BEGIN_DRAG_ISSUED 0x00000001
256 #define AUTO_RESIZE 0x00000002
257 #define RESIZE_ANYHOW 0x00000004
258 #define NTF_HGHTCHG 0x00000008
259 #define BAND_NEEDS_LAYOUT 0x00000010
260 #define BAND_NEEDS_REDRAW 0x00000020
261 #define CREATE_RUNNING 0x00000040
263 /* ---- REBAR layout constants. Mostly determined by ---- */
264 /* ---- experiment on WIN 98. ---- */
266 /* Width (or height) of separators between bands (either horz. or */
267 /* vert.). True only if RBS_BANDBORDERS is set */
268 #define SEP_WIDTH_SIZE 2
269 #define SEP_WIDTH ((infoPtr->dwStyle & RBS_BANDBORDERS) ? SEP_WIDTH_SIZE : 0)
271 /* Blank (background color) space between Gripper (if present) */
272 /* and next item (image, text, or window). Always present */
273 #define REBAR_ALWAYS_SPACE 4
275 /* Blank (background color) space after Image (if present). */
276 #define REBAR_POST_IMAGE 2
278 /* Blank (background color) space after Text (if present). */
279 #define REBAR_POST_TEXT 4
281 /* Height of vertical gripper in a CCS_VERT rebar. */
282 #define GRIPPER_HEIGHT 16
284 /* Blank (background color) space before Gripper (if present). */
285 #define REBAR_PRE_GRIPPER 2
287 /* Width (of normal vertical gripper) or height (of horz. gripper) */
289 #define GRIPPER_WIDTH 3
291 /* Height of divider for Rebar if not disabled (CCS_NODIVIDER) */
292 /* either top or bottom */
293 #define REBAR_DIVIDER 2
295 /* This is the increment that is used over the band height */
296 #define REBARSPACE(a) ((a->fStyle & RBBS_CHILDEDGE) ? 2*REBAR_DIVIDER : 0)
298 /* ---- End of REBAR layout constants. ---- */
301 /* The following 6 defines return the proper rcBand element */
302 /* depending on whether CCS_VERT was set. */
303 #define rcBlt(b) ((infoPtr->dwStyle & CCS_VERT) ? b->rcBand.top : b->rcBand.left)
304 #define rcBrb(b) ((infoPtr->dwStyle & CCS_VERT) ? b->rcBand.bottom : b->rcBand.right)
305 #define rcBw(b) ((infoPtr->dwStyle & CCS_VERT) ? (b->rcBand.bottom - b->rcBand.top) : \
306 (b->rcBand.right - b->rcBand.left))
307 #define ircBlt(b) ((infoPtr->dwStyle & CCS_VERT) ? b->rcBand.left : b->rcBand.top)
308 #define ircBrb(b) ((infoPtr->dwStyle & CCS_VERT) ? b->rcBand.right : b->rcBand.bottom)
309 #define ircBw(b) ((infoPtr->dwStyle & CCS_VERT) ? (b->rcBand.right - b->rcBand.left) : \
310 (b->rcBand.bottom - b->rcBand.top))
312 /* The following define determines if a given band is hidden */
313 #define HIDDENBAND(a) (((a)->fStyle & RBBS_HIDDEN) || \
314 ((infoPtr->dwStyle & CCS_VERT) && \
315 ((a)->fStyle & RBBS_NOVERT)))
317 /* The following defines adjust the right or left end of a rectangle */
318 #define READJ(b,i) do { if(infoPtr->dwStyle & CCS_VERT) b->rcBand.bottom+=(i); \
319 else b->rcBand.right += (i); } while(0)
320 #define LEADJ(b,i) do { if(infoPtr->dwStyle & CCS_VERT) b->rcBand.top+=(i); \
321 else b->rcBand.left += (i); } while(0)
324 #define REBAR_GetInfoPtr(wndPtr) ((REBAR_INFO *)GetWindowLongA (hwnd, 0))
327 /* "constant values" retrieved when DLL was initialized */
328 /* FIXME we do this when the classes are registered. */
329 static UINT mindragx = 0;
330 static UINT mindragy = 0;
332 static char *band_stylename[] = {
333 "RBBS_BREAK", /* 0001 */
334 "RBBS_FIXEDSIZE", /* 0002 */
335 "RBBS_CHILDEDGE", /* 0004 */
336 "RBBS_HIDDEN", /* 0008 */
337 "RBBS_NOVERT", /* 0010 */
338 "RBBS_FIXEDBMP", /* 0020 */
339 "RBBS_VARIABLEHEIGHT", /* 0040 */
340 "RBBS_GRIPPERALWAYS", /* 0080 */
341 "RBBS_NOGRIPPER", /* 0100 */
344 static char *band_maskname[] = {
345 "RBBIM_STYLE", /* 0x00000001 */
346 "RBBIM_COLORS", /* 0x00000002 */
347 "RBBIM_TEXT", /* 0x00000004 */
348 "RBBIM_IMAGE", /* 0x00000008 */
349 "RBBIM_CHILD", /* 0x00000010 */
350 "RBBIM_CHILDSIZE", /* 0x00000020 */
351 "RBBIM_SIZE", /* 0x00000040 */
352 "RBBIM_BACKGROUND", /* 0x00000080 */
353 "RBBIM_ID", /* 0x00000100 */
354 "RBBIM_IDEALSIZE", /* 0x00000200 */
355 "RBBIM_LPARAM", /* 0x00000400 */
356 "RBBIM_HEADERSIZE", /* 0x00000800 */
360 static CHAR line[200];
364 REBAR_FmtStyle( UINT style)
369 while (band_stylename[i]) {
370 if (style & (1<<i)) {
371 if (*line != 0) strcat(line, " | ");
372 strcat(line, band_stylename[i]);
381 REBAR_FmtMask( UINT mask)
386 while (band_maskname[i]) {
388 if (*line != 0) strcat(line, " | ");
389 strcat(line, band_maskname[i]);
398 REBAR_DumpBandInfo( LPREBARBANDINFOA pB)
400 if( !TRACE_ON(rebar) ) return;
401 TRACE("band info: ID=%u, size=%u, child=%p, clrF=0x%06lx, clrB=0x%06lx\n",
402 pB->wID, pB->cbSize, pB->hwndChild, pB->clrFore, pB->clrBack);
403 TRACE("band info: mask=0x%08x (%s)\n", pB->fMask, REBAR_FmtMask(pB->fMask));
404 if (pB->fMask & RBBIM_STYLE)
405 TRACE("band info: style=0x%08x (%s)\n", pB->fStyle, REBAR_FmtStyle(pB->fStyle));
406 if (pB->fMask & (RBBIM_SIZE | RBBIM_IDEALSIZE | RBBIM_HEADERSIZE | RBBIM_LPARAM )) {
408 if (pB->fMask & RBBIM_SIZE)
409 DPRINTF(" cx=%u", pB->cx);
410 if (pB->fMask & RBBIM_IDEALSIZE)
411 DPRINTF(" xIdeal=%u", pB->cxIdeal);
412 if (pB->fMask & RBBIM_HEADERSIZE)
413 DPRINTF(" xHeader=%u", pB->cxHeader);
414 if (pB->fMask & RBBIM_LPARAM)
415 DPRINTF(" lParam=0x%08lx", pB->lParam);
418 if (pB->fMask & RBBIM_CHILDSIZE)
419 TRACE("band info: xMin=%u, yMin=%u, yChild=%u, yMax=%u, yIntgl=%u\n",
421 pB->cyMinChild, pB->cyChild, pB->cyMaxChild, pB->cyIntegral);
425 REBAR_DumpBand (REBAR_INFO *iP)
430 if(! TRACE_ON(rebar) ) return;
432 TRACE("hwnd=%p: color=%08lx/%08lx, bands=%u, rows=%u, cSize=%ld,%ld\n",
433 iP->hwndSelf, iP->clrText, iP->clrBk, iP->uNumBands, iP->uNumRows,
434 iP->calcSize.cx, iP->calcSize.cy);
435 TRACE("hwnd=%p: flags=%08x, dragStart=%d,%d, dragNow=%d,%d, ihitBand=%d\n",
436 iP->hwndSelf, iP->fStatus, iP->dragStart.x, iP->dragStart.y,
437 iP->dragNow.x, iP->dragNow.y,
439 TRACE("hwnd=%p: style=%08lx, I'm Unicode=%s, notify in Unicode=%s, redraw=%s\n",
440 iP->hwndSelf, iP->dwStyle, (iP->bUnicode)?"TRUE":"FALSE",
441 (iP->NtfUnicode)?"TRUE":"FALSE", (iP->DoRedraw)?"TRUE":"FALSE");
442 for (i = 0; i < iP->uNumBands; i++) {
444 TRACE("band # %u: ID=%u, child=%p, row=%u, clrF=0x%06lx, clrB=0x%06lx\n",
445 i, pB->wID, pB->hwndChild, pB->iRow, pB->clrFore, pB->clrBack);
446 TRACE("band # %u: mask=0x%08x (%s)\n", i, pB->fMask, REBAR_FmtMask(pB->fMask));
447 if (pB->fMask & RBBIM_STYLE)
448 TRACE("band # %u: style=0x%08x (%s)\n",
449 i, pB->fStyle, REBAR_FmtStyle(pB->fStyle));
450 TRACE("band # %u: uMinH=%u xHeader=%u",
451 i, pB->uMinHeight, pB->cxHeader);
452 if (pB->fMask & (RBBIM_SIZE | RBBIM_IDEALSIZE | RBBIM_LPARAM )) {
453 if (pB->fMask & RBBIM_SIZE)
454 DPRINTF(" cx=%u", pB->cx);
455 if (pB->fMask & RBBIM_IDEALSIZE)
456 DPRINTF(" xIdeal=%u", pB->cxIdeal);
457 if (pB->fMask & RBBIM_LPARAM)
458 DPRINTF(" lParam=0x%08lx", pB->lParam);
462 TRACE("band # %u: xMin=%u, yMin=%u, yChild=%u, yMax=%u, yIntgl=%u\n",
463 i, pB->cxMinChild, pB->cyMinChild, pB->cyChild, pB->cyMaxChild, pB->cyIntegral);
464 if (pB->fMask & RBBIM_TEXT)
465 TRACE("band # %u: text=%s\n",
466 i, (pB->lpText) ? debugstr_w(pB->lpText) : "(null)");
467 TRACE("band # %u: lcx=%u, ccx=%u, hcx=%u, lcy=%u, ccy=%u, hcy=%u, offChild=%ld,%ld\n",
468 i, pB->lcx, pB->ccx, pB->hcx, pB->lcy, pB->ccy, pB->hcy, pB->offChild.cx, pB->offChild.cy);
469 TRACE("band # %u: fStatus=%08x, fDraw=%08x, Band=(%d,%d)-(%d,%d), Grip=(%d,%d)-(%d,%d)\n",
470 i, pB->fStatus, pB->fDraw,
471 pB->rcBand.left, pB->rcBand.top, pB->rcBand.right, pB->rcBand.bottom,
472 pB->rcGripper.left, pB->rcGripper.top, pB->rcGripper.right, pB->rcGripper.bottom);
473 TRACE("band # %u: Img=(%d,%d)-(%d,%d), Txt=(%d,%d)-(%d,%d), Child=(%d,%d)-(%d,%d)\n",
475 pB->rcCapImage.left, pB->rcCapImage.top, pB->rcCapImage.right, pB->rcCapImage.bottom,
476 pB->rcCapText.left, pB->rcCapText.top, pB->rcCapText.right, pB->rcCapText.bottom,
477 pB->rcChild.left, pB->rcChild.top, pB->rcChild.right, pB->rcChild.bottom);
484 REBAR_GetNotifyParent (REBAR_INFO *infoPtr)
488 parent = infoPtr->hwndNotify;
490 parent = GetParent (infoPtr->hwndSelf);
491 owner = GetWindow (infoPtr->hwndSelf, GW_OWNER);
492 if (owner) parent = owner;
499 REBAR_Notify (NMHDR *nmhdr, REBAR_INFO *infoPtr, UINT code)
503 parent = REBAR_GetNotifyParent (infoPtr);
504 nmhdr->idFrom = GetDlgCtrlID (infoPtr->hwndSelf);
505 nmhdr->hwndFrom = infoPtr->hwndSelf;
508 TRACE("window %p, code=%08x, %s\n", parent, code,
509 (infoPtr->NtfUnicode) ? "via Unicode" : "via ANSI");
511 if (infoPtr->NtfUnicode)
512 return SendMessageW (parent, WM_NOTIFY, (WPARAM) nmhdr->idFrom,
515 return SendMessageA (parent, WM_NOTIFY, (WPARAM) nmhdr->idFrom,
520 REBAR_Notify_NMREBAR (REBAR_INFO *infoPtr, UINT uBand, UINT code)
522 NMREBAR notify_rebar;
525 notify_rebar.dwMask = 0;
527 lpBand = &infoPtr->bands[uBand];
528 if (lpBand->fMask & RBBIM_ID) {
529 notify_rebar.dwMask |= RBNM_ID;
530 notify_rebar.wID = lpBand->wID;
532 if (lpBand->fMask & RBBIM_LPARAM) {
533 notify_rebar.dwMask |= RBNM_LPARAM;
534 notify_rebar.lParam = lpBand->lParam;
536 if (lpBand->fMask & RBBIM_STYLE) {
537 notify_rebar.dwMask |= RBNM_STYLE;
538 notify_rebar.fStyle = lpBand->fStyle;
541 notify_rebar.uBand = uBand;
542 return REBAR_Notify ((NMHDR *)¬ify_rebar, infoPtr, code);
546 REBAR_DrawBand (HDC hdc, REBAR_INFO *infoPtr, REBAR_BAND *lpBand)
552 if (lpBand->fDraw & DRAW_TEXT) {
553 hOldFont = SelectObject (hdc, infoPtr->hFont);
554 oldBkMode = SetBkMode (hdc, TRANSPARENT);
557 /* should test for CDRF_NOTIFYITEMDRAW here */
558 nmcd.dwDrawStage = CDDS_ITEMPREPAINT;
560 nmcd.rc = lpBand->rcBand;
561 nmcd.rc.right = lpBand->rcCapText.right;
562 nmcd.rc.bottom = lpBand->rcCapText.bottom;
563 nmcd.dwItemSpec = lpBand->wID;
565 nmcd.lItemlParam = lpBand->lParam;
566 lpBand->uCDret = REBAR_Notify ((NMHDR *)&nmcd, infoPtr, NM_CUSTOMDRAW);
567 if (lpBand->uCDret == CDRF_SKIPDEFAULT) {
568 if (oldBkMode != TRANSPARENT)
569 SetBkMode (hdc, oldBkMode);
570 SelectObject (hdc, hOldFont);
575 if (lpBand->fDraw & DRAW_GRIPPER)
576 DrawEdge (hdc, &lpBand->rcGripper, BDR_RAISEDINNER, BF_RECT | BF_MIDDLE);
578 /* draw caption image */
579 if (lpBand->fDraw & DRAW_IMAGE) {
583 pt.y = (lpBand->rcCapImage.bottom + lpBand->rcCapImage.top - infoPtr->imageSize.cy)/2;
584 pt.x = (lpBand->rcCapImage.right + lpBand->rcCapImage.left - infoPtr->imageSize.cx)/2;
586 ImageList_Draw (infoPtr->himl, lpBand->iImage, hdc,
591 /* draw caption text */
592 if (lpBand->fDraw & DRAW_TEXT) {
593 /* need to handle CDRF_NEWFONT here */
594 INT oldBkMode = SetBkMode (hdc, TRANSPARENT);
595 COLORREF oldcolor = CLR_NONE;
597 if (lpBand->clrFore != CLR_NONE) {
598 new = (lpBand->clrFore == CLR_DEFAULT) ? infoPtr->clrBtnText :
600 oldcolor = SetTextColor (hdc, new);
602 DrawTextW (hdc, lpBand->lpText, -1, &lpBand->rcCapText,
603 DT_CENTER | DT_VCENTER | DT_SINGLELINE);
604 if (oldBkMode != TRANSPARENT)
605 SetBkMode (hdc, oldBkMode);
606 if (lpBand->clrFore != CLR_NONE)
607 SetTextColor (hdc, oldcolor);
608 SelectObject (hdc, hOldFont);
611 if (lpBand->uCDret == (CDRF_NOTIFYPOSTPAINT | CDRF_NOTIFYITEMDRAW)) {
612 nmcd.dwDrawStage = CDDS_ITEMPOSTPAINT;
614 nmcd.rc = lpBand->rcBand;
615 nmcd.rc.right = lpBand->rcCapText.right;
616 nmcd.rc.bottom = lpBand->rcCapText.bottom;
617 nmcd.dwItemSpec = lpBand->wID;
619 nmcd.lItemlParam = lpBand->lParam;
620 lpBand->uCDret = REBAR_Notify ((NMHDR *)&nmcd, infoPtr, NM_CUSTOMDRAW);
626 REBAR_Refresh (REBAR_INFO *infoPtr, HDC hdc)
631 if (!infoPtr->DoRedraw) return;
633 oldrow = infoPtr->bands[0].iRow;
634 for (i = 0; i < infoPtr->uNumBands; i++) {
635 lpBand = &infoPtr->bands[i];
637 if (HIDDENBAND(lpBand)) continue;
639 /* now draw the band */
640 TRACE("[%p] drawing band %i, flags=%08x\n",
641 infoPtr->hwndSelf, i, lpBand->fDraw);
642 REBAR_DrawBand (hdc, infoPtr, lpBand);
649 REBAR_FixVert (REBAR_INFO *infoPtr, UINT rowstart, UINT rowend,
652 /* Cycle through bands in row and fix height of each band. */
653 /* Also determine whether each band has changed. */
655 /* all bands at desired size. */
656 /* start and end bands are *not* hidden */
661 for (i = (INT)rowstart; i<=(INT)rowend; i++) {
662 lpBand = &infoPtr->bands[i];
663 if (HIDDENBAND(lpBand)) continue;
665 /* adjust height of bands in row to "mcy" value */
666 if (infoPtr->dwStyle & CCS_VERT) {
667 if (lpBand->rcBand.right != lpBand->rcBand.left + mcy)
668 lpBand->rcBand.right = lpBand->rcBand.left + mcy;
671 if (lpBand->rcBand.bottom != lpBand->rcBand.top + mcy)
672 lpBand->rcBand.bottom = lpBand->rcBand.top + mcy;
676 /* mark whether we need to invalidate this band and trace */
677 if ((lpBand->rcoldBand.left !=lpBand->rcBand.left) ||
678 (lpBand->rcoldBand.top !=lpBand->rcBand.top) ||
679 (lpBand->rcoldBand.right !=lpBand->rcBand.right) ||
680 (lpBand->rcoldBand.bottom !=lpBand->rcBand.bottom)) {
681 lpBand->fDraw |= NTF_INVALIDATE;
682 TRACE("band %d row=%d: changed to (%d,%d)-(%d,%d) from (%d,%d)-(%d,%d)\n",
684 lpBand->rcBand.left, lpBand->rcBand.top,
685 lpBand->rcBand.right, lpBand->rcBand.bottom,
686 lpBand->rcoldBand.left, lpBand->rcoldBand.top,
687 lpBand->rcoldBand.right, lpBand->rcoldBand.bottom);
690 TRACE("band %d row=%d: unchanged (%d,%d)-(%d,%d)\n",
692 lpBand->rcBand.left, lpBand->rcBand.top,
693 lpBand->rcBand.right, lpBand->rcBand.bottom);
699 REBAR_AdjustBands (REBAR_INFO *infoPtr, UINT rowstart, UINT rowend,
701 /* Function: This routine distributes the extra space in a row. */
702 /* See algorithm below. */
704 /* all bands @ ->cxHeader size */
705 /* start and end bands are *not* hidden */
708 UINT x, xsep, extra, curwidth, fudge;
709 INT i, last_adjusted;
711 TRACE("start=%u, end=%u, max x=%d, max y=%d\n",
712 rowstart, rowend, maxx, mcy);
714 /* ******************* Phase 1 ************************ */
716 /* For each visible band with valid child */
717 /* a. inflate band till either all extra space used */
718 /* or band's ->ccx reached. */
719 /* If any band modified, add any space left to last band */
722 /* ****************************************************** */
723 lpBand = &infoPtr->bands[rowend];
724 extra = maxx - rcBrb(lpBand);
727 for (i=(INT)rowstart; i<=(INT)rowend; i++) {
728 lpBand = &infoPtr->bands[i];
729 if (HIDDENBAND(lpBand)) continue;
730 xsep = (x == 0) ? 0 : SEP_WIDTH;
731 curwidth = rcBw(lpBand);
733 /* set new left/top point */
734 if (infoPtr->dwStyle & CCS_VERT)
735 lpBand->rcBand.top = x + xsep;
737 lpBand->rcBand.left = x + xsep;
739 /* compute new width */
740 if ((lpBand->hwndChild && extra) && !(lpBand->fStyle & RBBS_FIXEDSIZE)) {
741 /* set to the "current" band size less the header */
744 if ((lpBand->fMask & RBBIM_SIZE) && (lpBand->cx > 0) &&
745 (fudge > curwidth)) {
746 TRACE("adjusting band %d by %d, fudge=%d, curwidth=%d, extra=%d\n",
747 i, fudge-curwidth, fudge, curwidth, extra);
748 if ((fudge - curwidth) > extra)
749 fudge = curwidth + extra;
750 extra -= (fudge - curwidth);
754 TRACE("adjusting band %d by %d, fudge=%d, curwidth=%d\n",
755 i, extra, fudge, curwidth);
761 /* set new right/bottom point */
762 if (infoPtr->dwStyle & CCS_VERT)
763 lpBand->rcBand.bottom = lpBand->rcBand.top + curwidth;
765 lpBand->rcBand.right = lpBand->rcBand.left + curwidth;
766 TRACE("Phase 1 band %d, (%d,%d)-(%d,%d), orig x=%d, xsep=%d\n",
767 i, lpBand->rcBand.left, lpBand->rcBand.top,
768 lpBand->rcBand.right, lpBand->rcBand.bottom, x, xsep);
771 if ((x >= maxx) || (last_adjusted != -1)) {
773 ERR("Phase 1 failed, x=%d, maxx=%d, start=%u, end=%u\n",
774 x, maxx, rowstart, rowend);
776 /* done, so spread extra space */
779 TRACE("Need to spread %d on last adjusted band %d\n",
780 fudge, last_adjusted);
781 for (i=(INT)last_adjusted; i<=(INT)rowend; i++) {
782 lpBand = &infoPtr->bands[i];
783 if (HIDDENBAND(lpBand)) continue;
785 /* set right/bottom point */
786 if (i != last_adjusted) {
787 if (infoPtr->dwStyle & CCS_VERT)
788 lpBand->rcBand.top += fudge;
790 lpBand->rcBand.left += fudge;
793 /* set left/bottom point */
794 if (infoPtr->dwStyle & CCS_VERT)
795 lpBand->rcBand.bottom += fudge;
797 lpBand->rcBand.right += fudge;
800 TRACE("Phase 1 succeeded, used x=%d\n", x);
801 REBAR_FixVert (infoPtr, rowstart, rowend, mcy);
805 /* ******************* Phase 2 ************************ */
807 /* Find first visible band, put all */
808 /* extra space there. */
810 /* ****************************************************** */
813 for (i=(INT)rowstart; i<=(INT)rowend; i++) {
814 lpBand = &infoPtr->bands[i];
815 if (HIDDENBAND(lpBand)) continue;
816 xsep = (x == 0) ? 0 : SEP_WIDTH;
817 curwidth = rcBw(lpBand);
819 /* set new left/top point */
820 if (infoPtr->dwStyle & CCS_VERT)
821 lpBand->rcBand.top = x + xsep;
823 lpBand->rcBand.left = x + xsep;
825 /* compute new width */
831 /* set new right/bottom point */
832 if (infoPtr->dwStyle & CCS_VERT)
833 lpBand->rcBand.bottom = lpBand->rcBand.top + curwidth;
835 lpBand->rcBand.right = lpBand->rcBand.left + curwidth;
836 TRACE("Phase 2 band %d, (%d,%d)-(%d,%d), orig x=%d, xsep=%d\n",
837 i, lpBand->rcBand.left, lpBand->rcBand.top,
838 lpBand->rcBand.right, lpBand->rcBand.bottom, x, xsep);
843 ERR("Phase 2 failed, x=%d, maxx=%d, start=%u, end=%u\n",
844 x, maxx, rowstart, rowend);
846 /* done, so spread extra space */
847 TRACE("Phase 2 succeeded, used x=%d\n", x);
848 REBAR_FixVert (infoPtr, rowstart, rowend, mcy);
852 /* ******************* Phase 3 ************************ */
853 /* at this point everything is back to ->cxHeader values */
854 /* and should not have gotten here. */
855 /* ****************************************************** */
857 lpBand = &infoPtr->bands[rowstart];
858 ERR("Serious problem adjusting row %d, start band %d, end band %d\n",
859 lpBand->iRow, rowstart, rowend);
860 REBAR_DumpBand (infoPtr);
866 REBAR_CalcHorzBand (REBAR_INFO *infoPtr, UINT rstart, UINT rend, BOOL notify)
867 /* Function: this routine initializes all the rectangles in */
868 /* each band in a row to fit in the adjusted rcBand rect. */
869 /* *** Supports only Horizontal bars. *** */
876 /* MS seems to use GetDlgCtrlID() for above GetWindowLong call */
877 parenthwnd = GetParent (infoPtr->hwndSelf);
879 for(i=rstart; i<rend; i++){
880 lpBand = &infoPtr->bands[i];
881 if (HIDDENBAND(lpBand)) {
882 SetRect (&lpBand->rcChild,
883 lpBand->rcBand.right, lpBand->rcBand.top,
884 lpBand->rcBand.right, lpBand->rcBand.bottom);
888 oldChild = lpBand->rcChild;
890 /* set initial gripper rectangle */
891 SetRect (&lpBand->rcGripper, lpBand->rcBand.left, lpBand->rcBand.top,
892 lpBand->rcBand.left, lpBand->rcBand.bottom);
894 /* calculate gripper rectangle */
895 if ( lpBand->fStatus & HAS_GRIPPER) {
896 lpBand->fDraw |= DRAW_GRIPPER;
897 lpBand->rcGripper.left += REBAR_PRE_GRIPPER;
898 lpBand->rcGripper.right = lpBand->rcGripper.left + GRIPPER_WIDTH;
899 lpBand->rcGripper.top += 2;
900 lpBand->rcGripper.bottom -= 2;
902 SetRect (&lpBand->rcCapImage,
903 lpBand->rcGripper.right+REBAR_ALWAYS_SPACE, lpBand->rcBand.top,
904 lpBand->rcGripper.right+REBAR_ALWAYS_SPACE, lpBand->rcBand.bottom);
906 else { /* no gripper will be drawn */
908 if (lpBand->fStatus & (HAS_IMAGE | HAS_TEXT))
909 /* if no gripper but either image or text, then leave space */
910 xoff = REBAR_ALWAYS_SPACE;
911 SetRect (&lpBand->rcCapImage,
912 lpBand->rcBand.left+xoff, lpBand->rcBand.top,
913 lpBand->rcBand.left+xoff, lpBand->rcBand.bottom);
916 /* image is visible */
917 if (lpBand->fStatus & HAS_IMAGE) {
918 lpBand->fDraw |= DRAW_IMAGE;
919 lpBand->rcCapImage.right += infoPtr->imageSize.cx;
920 lpBand->rcCapImage.bottom = lpBand->rcCapImage.top + infoPtr->imageSize.cy;
922 /* set initial caption text rectangle */
923 SetRect (&lpBand->rcCapText,
924 lpBand->rcCapImage.right+REBAR_POST_IMAGE, lpBand->rcBand.top+1,
925 lpBand->rcBand.left+lpBand->cxHeader, lpBand->rcBand.bottom-1);
926 /* update band height
927 if (lpBand->uMinHeight < infoPtr->imageSize.cy + 2) {
928 lpBand->uMinHeight = infoPtr->imageSize.cy + 2;
929 lpBand->rcBand.bottom = lpBand->rcBand.top + lpBand->uMinHeight;
933 /* set initial caption text rectangle */
934 SetRect (&lpBand->rcCapText, lpBand->rcCapImage.right, lpBand->rcBand.top+1,
935 lpBand->rcBand.left+lpBand->cxHeader, lpBand->rcBand.bottom-1);
938 /* text is visible */
939 if (lpBand->fStatus & HAS_TEXT) {
940 lpBand->fDraw |= DRAW_TEXT;
941 lpBand->rcCapText.right = max(lpBand->rcCapText.left,
942 lpBand->rcCapText.right-REBAR_POST_TEXT);
945 /* set initial child window rectangle if there is a child */
946 if (lpBand->fMask & RBBIM_CHILD) {
947 xoff = lpBand->offChild.cx;
948 yoff = lpBand->offChild.cy;
949 SetRect (&lpBand->rcChild,
950 lpBand->rcBand.left+lpBand->cxHeader, lpBand->rcBand.top+yoff,
951 lpBand->rcBand.right-xoff, lpBand->rcBand.bottom-yoff);
954 SetRect (&lpBand->rcChild,
955 lpBand->rcBand.left+lpBand->cxHeader, lpBand->rcBand.top,
956 lpBand->rcBand.right, lpBand->rcBand.bottom);
959 /* flag if notify required and invalidate rectangle */
961 ((oldChild.right-oldChild.left != lpBand->rcChild.right-lpBand->rcChild.left) ||
962 (oldChild.bottom-oldChild.top != lpBand->rcChild.bottom-lpBand->rcChild.top))) {
963 TRACE("Child rectangle changed for band %u\n", i);
964 TRACE(" from (%d,%d)-(%d,%d) to (%d,%d)-(%d,%d)\n",
965 oldChild.left, oldChild.top,
966 oldChild.right, oldChild.bottom,
967 lpBand->rcChild.left, lpBand->rcChild.top,
968 lpBand->rcChild.right, lpBand->rcChild.bottom);
970 if (lpBand->fDraw & NTF_INVALIDATE) {
971 TRACE("invalidating (%d,%d)-(%d,%d)\n",
974 lpBand->rcBand.right + ((lpBand->fDraw & DRAW_RIGHTSEP) ? SEP_WIDTH_SIZE : 0),
975 lpBand->rcBand.bottom + ((lpBand->fDraw & DRAW_BOTTOMSEP) ? SEP_WIDTH_SIZE : 0));
976 lpBand->fDraw &= ~NTF_INVALIDATE;
977 work = lpBand->rcBand;
978 if (lpBand->fDraw & DRAW_RIGHTSEP) work.right += SEP_WIDTH_SIZE;
979 if (lpBand->fDraw & DRAW_BOTTOMSEP) work.bottom += SEP_WIDTH_SIZE;
980 InvalidateRect(infoPtr->hwndSelf, &work, TRUE);
989 REBAR_CalcVertBand (REBAR_INFO *infoPtr, UINT rstart, UINT rend, BOOL notify)
990 /* Function: this routine initializes all the rectangles in */
991 /* each band in a row to fit in the adjusted rcBand rect. */
992 /* *** Supports only Vertical bars. *** */
999 /* MS seems to use GetDlgCtrlID() for above GetWindowLong call */
1000 parenthwnd = GetParent (infoPtr->hwndSelf);
1002 for(i=rstart; i<rend; i++){
1003 lpBand = &infoPtr->bands[i];
1004 if (HIDDENBAND(lpBand)) continue;
1005 oldChild = lpBand->rcChild;
1007 /* set initial gripper rectangle */
1008 SetRect (&lpBand->rcGripper, lpBand->rcBand.left, lpBand->rcBand.top,
1009 lpBand->rcBand.right, lpBand->rcBand.top);
1011 /* calculate gripper rectangle */
1012 if (lpBand->fStatus & HAS_GRIPPER) {
1013 lpBand->fDraw |= DRAW_GRIPPER;
1015 if (infoPtr->dwStyle & RBS_VERTICALGRIPPER) {
1016 /* vertical gripper */
1017 lpBand->rcGripper.left += 3;
1018 lpBand->rcGripper.right = lpBand->rcGripper.left + GRIPPER_WIDTH;
1019 lpBand->rcGripper.top += REBAR_PRE_GRIPPER;
1020 lpBand->rcGripper.bottom = lpBand->rcGripper.top + GRIPPER_HEIGHT;
1022 /* initialize Caption image rectangle */
1023 SetRect (&lpBand->rcCapImage, lpBand->rcBand.left,
1024 lpBand->rcGripper.bottom + REBAR_ALWAYS_SPACE,
1025 lpBand->rcBand.right,
1026 lpBand->rcGripper.bottom + REBAR_ALWAYS_SPACE);
1029 /* horizontal gripper */
1030 lpBand->rcGripper.left += 2;
1031 lpBand->rcGripper.right -= 2;
1032 lpBand->rcGripper.top += REBAR_PRE_GRIPPER;
1033 lpBand->rcGripper.bottom = lpBand->rcGripper.top + GRIPPER_WIDTH;
1035 /* initialize Caption image rectangle */
1036 SetRect (&lpBand->rcCapImage, lpBand->rcBand.left,
1037 lpBand->rcGripper.bottom + REBAR_ALWAYS_SPACE,
1038 lpBand->rcBand.right,
1039 lpBand->rcGripper.bottom + REBAR_ALWAYS_SPACE);
1042 else { /* no gripper will be drawn */
1044 if (lpBand->fStatus & (HAS_IMAGE | HAS_TEXT))
1045 /* if no gripper but either image or text, then leave space */
1046 xoff = REBAR_ALWAYS_SPACE;
1047 /* initialize Caption image rectangle */
1048 SetRect (&lpBand->rcCapImage,
1049 lpBand->rcBand.left, lpBand->rcBand.top+xoff,
1050 lpBand->rcBand.right, lpBand->rcBand.top+xoff);
1053 /* image is visible */
1054 if (lpBand->fStatus & HAS_IMAGE) {
1055 lpBand->fDraw |= DRAW_IMAGE;
1057 lpBand->rcCapImage.right = lpBand->rcCapImage.left + infoPtr->imageSize.cx;
1058 lpBand->rcCapImage.bottom += infoPtr->imageSize.cy;
1060 /* set initial caption text rectangle */
1061 SetRect (&lpBand->rcCapText,
1062 lpBand->rcBand.left, lpBand->rcCapImage.bottom+REBAR_POST_IMAGE,
1063 lpBand->rcBand.right, lpBand->rcBand.top+lpBand->cxHeader);
1064 /* update band height *
1065 if (lpBand->uMinHeight < infoPtr->imageSize.cx + 2) {
1066 lpBand->uMinHeight = infoPtr->imageSize.cx + 2;
1067 lpBand->rcBand.right = lpBand->rcBand.left + lpBand->uMinHeight;
1071 /* set initial caption text rectangle */
1072 SetRect (&lpBand->rcCapText,
1073 lpBand->rcBand.left, lpBand->rcCapImage.bottom,
1074 lpBand->rcBand.right, lpBand->rcBand.top+lpBand->cxHeader);
1077 /* text is visible */
1078 if (lpBand->fStatus & HAS_TEXT) {
1079 lpBand->fDraw |= DRAW_TEXT;
1080 lpBand->rcCapText.bottom = max(lpBand->rcCapText.top,
1081 lpBand->rcCapText.bottom);
1084 /* set initial child window rectangle if there is a child */
1085 if (lpBand->fMask & RBBIM_CHILD) {
1086 yoff = lpBand->offChild.cx;
1087 xoff = lpBand->offChild.cy;
1088 SetRect (&lpBand->rcChild,
1089 lpBand->rcBand.left+xoff, lpBand->rcBand.top+lpBand->cxHeader,
1090 lpBand->rcBand.right-xoff, lpBand->rcBand.bottom-yoff);
1093 SetRect (&lpBand->rcChild,
1094 lpBand->rcBand.left, lpBand->rcBand.top+lpBand->cxHeader,
1095 lpBand->rcBand.right, lpBand->rcBand.bottom);
1098 /* flag if notify required and invalidate rectangle */
1100 ((oldChild.right-oldChild.left != lpBand->rcChild.right-lpBand->rcChild.left) ||
1101 (oldChild.bottom-oldChild.top != lpBand->rcChild.bottom-lpBand->rcChild.top))) {
1102 TRACE("Child rectangle changed for band %u\n", i);
1103 TRACE(" from (%d,%d)-(%d,%d) to (%d,%d)-(%d,%d)\n",
1104 oldChild.left, oldChild.top,
1105 oldChild.right, oldChild.bottom,
1106 lpBand->rcChild.left, lpBand->rcChild.top,
1107 lpBand->rcChild.right, lpBand->rcChild.bottom);
1109 if (lpBand->fDraw & NTF_INVALIDATE) {
1110 TRACE("invalidating (%d,%d)-(%d,%d)\n",
1111 lpBand->rcBand.left,
1113 lpBand->rcBand.right + ((lpBand->fDraw & DRAW_BOTTOMSEP) ? SEP_WIDTH_SIZE : 0),
1114 lpBand->rcBand.bottom + ((lpBand->fDraw & DRAW_RIGHTSEP) ? SEP_WIDTH_SIZE : 0));
1115 lpBand->fDraw &= ~NTF_INVALIDATE;
1116 work = lpBand->rcBand;
1117 if (lpBand->fDraw & DRAW_RIGHTSEP) work.bottom += SEP_WIDTH_SIZE;
1118 if (lpBand->fDraw & DRAW_BOTTOMSEP) work.right += SEP_WIDTH_SIZE;
1119 InvalidateRect(infoPtr->hwndSelf, &work, TRUE);
1127 REBAR_ForceResize (REBAR_INFO *infoPtr)
1128 /* Function: This changes the size of the REBAR window to that */
1129 /* calculated by REBAR_Layout. */
1132 INT x, y, width, height;
1133 INT xedge = GetSystemMetrics(SM_CXEDGE);
1134 INT yedge = GetSystemMetrics(SM_CYEDGE);
1136 /* TEST TEST TEST */
1137 GetWindowRect (infoPtr->hwndSelf, &rc);
1138 /* END TEST END TEST END TEST */
1141 GetClientRect (infoPtr->hwndSelf, &rc);
1143 TRACE( " old [%ld x %ld], new [%ld x %ld], client [%d x %d]\n",
1144 infoPtr->oldSize.cx, infoPtr->oldSize.cy,
1145 infoPtr->calcSize.cx, infoPtr->calcSize.cy,
1146 rc.right, rc.bottom);
1148 /* If we need to shrink client, then skip size test */
1149 if ((infoPtr->calcSize.cy >= rc.bottom) &&
1150 (infoPtr->calcSize.cx >= rc.right)) {
1152 /* if size did not change then skip process */
1153 if ((infoPtr->oldSize.cx == infoPtr->calcSize.cx) &&
1154 (infoPtr->oldSize.cy == infoPtr->calcSize.cy) &&
1155 !(infoPtr->fStatus & RESIZE_ANYHOW))
1157 TRACE("skipping reset\n");
1162 infoPtr->fStatus &= ~RESIZE_ANYHOW;
1163 /* Set flag to ignore next WM_SIZE message */
1164 infoPtr->fStatus |= AUTO_RESIZE;
1171 if (infoPtr->dwStyle & WS_BORDER) {
1176 if (!(infoPtr->dwStyle & CCS_NOPARENTALIGN)) {
1177 INT mode = infoPtr->dwStyle & (CCS_VERT | CCS_TOP | CCS_BOTTOM);
1180 GetClientRect(GetParent(infoPtr->hwndSelf), &rcPcl);
1183 /* _TOP sets width to parents width */
1184 width += (rcPcl.right - rcPcl.left);
1185 height += infoPtr->calcSize.cy;
1186 x += ((infoPtr->dwStyle & WS_BORDER) ? -xedge : 0);
1187 y += ((infoPtr->dwStyle & WS_BORDER) ? -yedge : 0);
1188 y += ((infoPtr->dwStyle & CCS_NODIVIDER) ? 0 : REBAR_DIVIDER);
1191 /* FIXME: wrong wrong wrong */
1192 /* _BOTTOM sets width to parents width */
1193 width += (rcPcl.right - rcPcl.left);
1194 height += infoPtr->calcSize.cy;
1196 y = rcPcl.bottom - height + 1;
1199 /* _LEFT sets height to parents height */
1200 width += infoPtr->calcSize.cx;
1201 height += (rcPcl.bottom - rcPcl.top);
1202 x += ((infoPtr->dwStyle & WS_BORDER) ? -xedge : 0);
1203 x += ((infoPtr->dwStyle & CCS_NODIVIDER) ? 0 : REBAR_DIVIDER);
1204 y += ((infoPtr->dwStyle & WS_BORDER) ? -yedge : 0);
1207 /* FIXME: wrong wrong wrong */
1208 /* _RIGHT sets height to parents height */
1209 width += infoPtr->calcSize.cx;
1210 height += (rcPcl.bottom - rcPcl.top);
1211 x = rcPcl.right - width + 1;
1215 width += infoPtr->calcSize.cx;
1216 height += infoPtr->calcSize.cy;
1220 width += infoPtr->calcSize.cx;
1221 height += infoPtr->calcSize.cy;
1222 x = infoPtr->origin.x;
1223 y = infoPtr->origin.y;
1226 TRACE("hwnd %p, style=%08lx, setting at (%d,%d) for (%d,%d)\n",
1227 infoPtr->hwndSelf, infoPtr->dwStyle,
1228 x, y, width, height);
1229 SetWindowPos (infoPtr->hwndSelf, 0, x, y, width, height,
1235 REBAR_MoveChildWindows (REBAR_INFO *infoPtr, UINT start, UINT endplus)
1238 CHAR szClassName[40];
1240 NMREBARCHILDSIZE rbcz;
1244 if (!(deferpos = BeginDeferWindowPos(infoPtr->uNumBands)))
1245 ERR("BeginDeferWindowPos returned NULL\n");
1247 for (i = start; i < endplus; i++) {
1248 lpBand = &infoPtr->bands[i];
1250 if (HIDDENBAND(lpBand)) continue;
1251 if (lpBand->hwndChild) {
1252 TRACE("hwndChild = %p\n", lpBand->hwndChild);
1254 /* Always geterate the RBN_CHILDSIZE even it child
1257 rbcz.wID = lpBand->wID;
1258 rbcz.rcChild = lpBand->rcChild;
1259 rbcz.rcBand = lpBand->rcBand;
1260 if (infoPtr->dwStyle & CCS_VERT)
1261 rbcz.rcBand.top += lpBand->cxHeader;
1263 rbcz.rcBand.left += lpBand->cxHeader;
1264 REBAR_Notify ((NMHDR *)&rbcz, infoPtr, RBN_CHILDSIZE);
1265 if (!EqualRect (&lpBand->rcChild, &rbcz.rcChild)) {
1266 TRACE("Child rect changed by NOTIFY for band %u\n", i);
1267 TRACE(" from (%d,%d)-(%d,%d) to (%d,%d)-(%d,%d)\n",
1268 lpBand->rcChild.left, lpBand->rcChild.top,
1269 lpBand->rcChild.right, lpBand->rcChild.bottom,
1270 rbcz.rcChild.left, rbcz.rcChild.top,
1271 rbcz.rcChild.right, rbcz.rcChild.bottom);
1272 lpBand->rcChild = rbcz.rcChild; /* *** ??? */
1275 /* native (IE4 in "Favorites" frame **1) does:
1276 * SetRect (&rc, -1, -1, -1, -1)
1277 * EqualRect (&rc,band->rc???)
1279 * CopyRect (band->rc????, &rc)
1280 * set flag outside of loop
1283 GetClassNameA (lpBand->hwndChild, szClassName, 40);
1284 if (!lstrcmpA (szClassName, "ComboBox") ||
1285 !lstrcmpA (szClassName, WC_COMBOBOXEXA)) {
1286 INT nEditHeight, yPos;
1289 /* special placement code for combo or comboex box */
1292 /* get size of edit line */
1293 GetWindowRect (lpBand->hwndChild, &rc);
1294 nEditHeight = rc.bottom - rc.top;
1295 yPos = (lpBand->rcChild.bottom + lpBand->rcChild.top - nEditHeight)/2;
1297 /* center combo box inside child area */
1298 TRACE("moving child (Combo(Ex)) %p to (%d,%d) for (%d,%d)\n",
1300 lpBand->rcChild.left, yPos,
1301 lpBand->rcChild.right - lpBand->rcChild.left,
1303 deferpos = DeferWindowPos (deferpos, lpBand->hwndChild, HWND_TOP,
1304 lpBand->rcChild.left,
1305 /*lpBand->rcChild.top*/ yPos,
1306 lpBand->rcChild.right - lpBand->rcChild.left,
1310 ERR("DeferWindowPos returned NULL\n");
1313 TRACE("moving child (Other) %p to (%d,%d) for (%d,%d)\n",
1315 lpBand->rcChild.left, lpBand->rcChild.top,
1316 lpBand->rcChild.right - lpBand->rcChild.left,
1317 lpBand->rcChild.bottom - lpBand->rcChild.top);
1318 deferpos = DeferWindowPos (deferpos, lpBand->hwndChild, HWND_TOP,
1319 lpBand->rcChild.left,
1320 lpBand->rcChild.top,
1321 lpBand->rcChild.right - lpBand->rcChild.left,
1322 lpBand->rcChild.bottom - lpBand->rcChild.top,
1325 ERR("DeferWindowPos returned NULL\n");
1329 if (!EndDeferWindowPos(deferpos))
1330 ERR("EndDeferWindowPos returned NULL\n");
1332 if (infoPtr->DoRedraw)
1333 UpdateWindow (infoPtr->hwndSelf);
1335 if (infoPtr->fStatus & NTF_HGHTCHG) {
1336 infoPtr->fStatus &= ~NTF_HGHTCHG;
1337 REBAR_Notify (&heightchange, infoPtr, RBN_HEIGHTCHANGE);
1340 /* native (from **1 above) does:
1341 * UpdateWindow(rebar)
1343 * RBN_HEIGHTCHANGE if necessary
1344 * if ret from any EqualRect was 0
1345 * Goto "BeginDeferWindowPos"
1352 REBAR_Layout (REBAR_INFO *infoPtr, LPRECT lpRect, BOOL notify, BOOL resetclient)
1353 /* Function: This routine is resposible for laying out all */
1354 /* the bands in a rebar. It assigns each band to a row and*/
1355 /* determines when to start a new row. */
1357 REBAR_BAND *lpBand, *prevBand;
1358 RECT rcClient, rcAdj;
1359 INT initx, inity, x, y, cx, cxsep, mmcy, mcy, clientcx, clientcy;
1360 INT adjcx, adjcy, row, rightx, bottomy, origheight;
1361 UINT i, j, rowstart, origrows, cntonrow;
1364 if (!(infoPtr->fStatus & BAND_NEEDS_LAYOUT)) {
1365 TRACE("no layout done. No band changed.\n");
1366 REBAR_DumpBand (infoPtr);
1369 infoPtr->fStatus &= ~BAND_NEEDS_LAYOUT;
1370 if (!infoPtr->DoRedraw) infoPtr->fStatus |= BAND_NEEDS_REDRAW;
1372 GetClientRect (infoPtr->hwndSelf, &rcClient);
1373 TRACE("Client is (%d,%d)-(%d,%d)\n",
1374 rcClient.left, rcClient.top, rcClient.right, rcClient.bottom);
1378 TRACE("adjustment rect is (%d,%d)-(%d,%d)\n",
1379 rcAdj.left, rcAdj.top, rcAdj.right, rcAdj.bottom);
1382 CopyRect (&rcAdj, &rcClient);
1385 clientcx = rcClient.right - rcClient.left;
1386 clientcy = rcClient.bottom - rcClient.top;
1387 adjcx = rcAdj.right - rcAdj.left;
1388 adjcy = rcAdj.bottom - rcAdj.top;
1390 TRACE("window client rect will be set to adj rect\n");
1395 if (!infoPtr->DoRedraw && (clientcx == 0) && (clientcy == 0)) {
1396 ERR("no redraw and client is zero, skip layout\n");
1397 infoPtr->fStatus |= BAND_NEEDS_LAYOUT;
1401 /* save height of original control */
1402 if (infoPtr->dwStyle & CCS_VERT)
1403 origheight = infoPtr->calcSize.cx;
1405 origheight = infoPtr->calcSize.cy;
1406 origrows = infoPtr->uNumRows;
1411 /* ******* Start Phase 1 - all bands on row at minimum size ******* */
1413 TRACE("band loop constants, clientcx=%d, clientcy=%d, adjcx=%d, adjcy=%d\n",
1414 clientcx, clientcy, adjcx, adjcy);
1424 for (i = 0; i < infoPtr->uNumBands; i++) {
1425 lpBand = &infoPtr->bands[i];
1429 if (HIDDENBAND(lpBand)) continue;
1431 lpBand->rcoldBand = lpBand->rcBand;
1433 /* Set the offset of the child window */
1434 if ((lpBand->fMask & RBBIM_CHILD) &&
1435 !(lpBand->fStyle & RBBS_FIXEDSIZE)) {
1436 lpBand->offChild.cx = ((lpBand->fStyle & RBBS_CHILDEDGE) ? 4 : 0);
1438 lpBand->offChild.cy = ((lpBand->fStyle & RBBS_CHILDEDGE) ? 2 : 0);
1440 /* separator from previous band */
1441 cxsep = (cntonrow == 0) ? 0 : SEP_WIDTH;
1443 /* Header: includes gripper, text, image */
1444 cx = lpBand->cxHeader;
1445 if (lpBand->fStyle & RBBS_FIXEDSIZE) cx = lpBand->lcx;
1447 if (infoPtr->dwStyle & CCS_VERT)
1448 dobreak = (y + cx + cxsep > adjcy);
1450 dobreak = (x + cx + cxsep > adjcx);
1452 /* This is the check for whether we need to start a new row */
1453 if ( ( (lpBand->fStyle & RBBS_BREAK) && (i != 0) ) ||
1454 ( ((infoPtr->dwStyle & CCS_VERT) ? (y != 0) : (x != 0)) && dobreak)) {
1456 for (j = rowstart; j < i; j++) {
1458 lpB = &infoPtr->bands[j];
1459 if (infoPtr->dwStyle & CCS_VERT) {
1460 lpB->rcBand.right = lpB->rcBand.left + mcy;
1463 lpB->rcBand.bottom = lpB->rcBand.top + mcy;
1467 TRACE("P1 Spliting to new row %d on band %u\n", row+1, i);
1468 if (infoPtr->dwStyle & CCS_VERT) {
1470 x += (mcy + SEP_WIDTH);
1474 y += (mcy + SEP_WIDTH);
1486 if (mcy < lpBand->lcy + REBARSPACE(lpBand))
1487 mcy = lpBand->lcy + REBARSPACE(lpBand);
1489 /* if boundary rect specified then limit mcy */
1491 if (infoPtr->dwStyle & CCS_VERT) {
1492 if (x+mcy > adjcx) {
1494 TRACE("P1 row %u limiting mcy=%d, adjcx=%d, x=%d\n",
1499 if (y+mcy > adjcy) {
1501 TRACE("P1 row %u limiting mcy=%d, adjcy=%d, y=%d\n",
1507 TRACE("P1 band %u, row %d, x=%d, y=%d, cxsep=%d, cx=%d\n",
1510 if (infoPtr->dwStyle & CCS_VERT) {
1511 /* bound the bottom side if we have a bounding rectangle */
1513 bottomy = (lpRect) ? min(clientcy, y+cxsep+cx) : y+cxsep+cx;
1514 lpBand->rcBand.left = x;
1515 lpBand->rcBand.right = x + min(mcy,
1516 lpBand->lcy+REBARSPACE(lpBand));
1517 lpBand->rcBand.top = min(bottomy, y + cxsep);
1518 lpBand->rcBand.bottom = bottomy;
1519 lpBand->uMinHeight = lpBand->lcy;
1523 /* bound the right side if we have a bounding rectangle */
1524 rightx = (lpRect) ? min(clientcx, x+cxsep+cx) : x+cxsep+cx;
1526 lpBand->rcBand.left = min(rightx, x + cxsep);
1527 lpBand->rcBand.right = rightx;
1528 lpBand->rcBand.top = y;
1529 lpBand->rcBand.bottom = y + min(mcy,
1530 lpBand->lcy+REBARSPACE(lpBand));
1531 lpBand->uMinHeight = lpBand->lcy;
1534 TRACE("P1 band %u, row %d, (%d,%d)-(%d,%d)\n",
1536 lpBand->rcBand.left, lpBand->rcBand.top,
1537 lpBand->rcBand.right, lpBand->rcBand.bottom);
1541 } /* for (i = 0; i < infoPtr->uNumBands... */
1543 if (infoPtr->dwStyle & CCS_VERT)
1548 for (j = rowstart; j < infoPtr->uNumBands; j++) {
1549 lpBand = &infoPtr->bands[j];
1550 if (infoPtr->dwStyle & CCS_VERT) {
1551 lpBand->rcBand.right = lpBand->rcBand.left + mcy;
1554 lpBand->rcBand.bottom = lpBand->rcBand.top + mcy;
1558 if (infoPtr->uNumBands)
1559 infoPtr->uNumRows = row;
1561 /* ******* End Phase 1 - all bands on row at minimum size ******* */
1564 /* ******* Start Phase 1a - Adjust heights for RBS_VARHEIGHT off ******* */
1567 if (!(infoPtr->dwStyle & RBS_VARHEIGHT)) {
1570 /* get the max height of all bands */
1571 for (i=0; i<infoPtr->uNumBands; i++) {
1572 lpBand = &infoPtr->bands[i];
1573 if (HIDDENBAND(lpBand)) continue;
1574 if (infoPtr->dwStyle & CCS_VERT)
1575 mmcy = max(mmcy, lpBand->rcBand.right - lpBand->rcBand.left);
1577 mmcy = max(mmcy, lpBand->rcBand.bottom - lpBand->rcBand.top);
1580 /* now adjust all rectangles by using the height found above */
1583 for (i=0; i<infoPtr->uNumBands; i++) {
1584 lpBand = &infoPtr->bands[i];
1585 if (HIDDENBAND(lpBand)) continue;
1586 if (lpBand->iRow != row)
1587 xy += (mmcy + SEP_WIDTH);
1588 if (infoPtr->dwStyle & CCS_VERT) {
1589 lpBand->rcBand.left = xy;
1590 lpBand->rcBand.right = xy + mmcy;
1593 lpBand->rcBand.top = xy;
1594 lpBand->rcBand.bottom = xy + mmcy;
1598 /* set the x/y values to the correct maximum */
1599 if (infoPtr->dwStyle & CCS_VERT)
1605 /* ******* End Phase 1a - Adjust heights for RBS_VARHEIGHT off ******* */
1608 /* ******* Start Phase 2 - split rows till adjustment height full ******* */
1610 /* assumes that the following variables contain: */
1611 /* y/x current height/width of all rows */
1613 INT i, j, prev_rh, new_rh, adj_rh, prev_idx, current_idx;
1614 REBAR_BAND *prev, *current, *walk;
1616 /* FIXME: problem # 2 */
1617 if (((infoPtr->dwStyle & CCS_VERT) ?
1619 (x < adjcx) : (y < adjcy)
1621 (adjcx - x > 4) : (adjcy - y > 4)
1624 (infoPtr->uNumBands > 1)) {
1625 for (i=(INT)infoPtr->uNumBands-2; i>=0; i--) {
1626 TRACE("P2 adjcx=%d, adjcy=%d, x=%d, y=%d\n",
1627 adjcx, adjcy, x, y);
1629 /* find the current band (starts at i+1) */
1630 current = &infoPtr->bands[i+1];
1632 while (HIDDENBAND(current)) {
1634 if (i < 0) break; /* out of bands */
1635 current = &infoPtr->bands[i+1];
1638 if (i < 0) break; /* out of bands */
1640 /* now find the prev band (starts at i) */
1641 prev = &infoPtr->bands[i];
1643 while (HIDDENBAND(prev)) {
1645 if (i < 0) break; /* out of bands */
1646 prev = &infoPtr->bands[i];
1649 if (i < 0) break; /* out of bands */
1651 prev_rh = ircBw(prev);
1652 if (prev->iRow == current->iRow) {
1653 new_rh = (infoPtr->dwStyle & RBS_VARHEIGHT) ?
1654 current->lcy + REBARSPACE(current) :
1656 adj_rh = new_rh + SEP_WIDTH;
1657 infoPtr->uNumRows++;
1658 current->fDraw |= NTF_INVALIDATE;
1660 if (infoPtr->dwStyle & CCS_VERT) {
1661 current->rcBand.top = inity;
1662 current->rcBand.bottom = clientcy;
1663 current->rcBand.left += (prev_rh + SEP_WIDTH);
1664 current->rcBand.right = current->rcBand.left + new_rh;
1668 current->rcBand.left = initx;
1669 current->rcBand.right = clientcx;
1670 current->rcBand.top += (prev_rh + SEP_WIDTH);
1671 current->rcBand.bottom = current->rcBand.top + new_rh;
1674 TRACE("P2 moving band %d to own row at (%d,%d)-(%d,%d)\n",
1676 current->rcBand.left, current->rcBand.top,
1677 current->rcBand.right, current->rcBand.bottom);
1678 TRACE("P2 prev band %d at (%d,%d)-(%d,%d)\n",
1680 prev->rcBand.left, prev->rcBand.top,
1681 prev->rcBand.right, prev->rcBand.bottom);
1682 TRACE("P2 values: prev_rh=%d, new_rh=%d, adj_rh=%d\n",
1683 prev_rh, new_rh, adj_rh);
1684 /* for bands below current adjust row # and top/bottom */
1685 for (j = current_idx+1; j<infoPtr->uNumBands; j++) {
1686 walk = &infoPtr->bands[j];
1687 if (HIDDENBAND(walk)) continue;
1688 walk->fDraw |= NTF_INVALIDATE;
1690 if (infoPtr->dwStyle & CCS_VERT) {
1691 walk->rcBand.left += adj_rh;
1692 walk->rcBand.right += adj_rh;
1695 walk->rcBand.top += adj_rh;
1696 walk->rcBand.bottom += adj_rh;
1699 if ((infoPtr->dwStyle & CCS_VERT) ? (x >= adjcx) : (y >= adjcy))
1700 break; /* all done */
1706 /* ******* End Phase 2 - split rows till adjustment height full ******* */
1709 /* ******* Start Phase 2a - create array of start and end ******* */
1710 /* indexes by row */
1712 if (infoPtr->uNumRows != origrows) {
1713 if (infoPtr->rows) COMCTL32_Free (infoPtr->rows);
1714 infoPtr->rows = COMCTL32_Alloc (sizeof (REBAR_ROW) * infoPtr->uNumRows);
1718 for (i = 0; i < infoPtr->uNumBands; i++) {
1719 lpBand = &infoPtr->bands[i];
1720 if (HIDDENBAND(lpBand)) continue;
1722 if (lpBand->iRow > row) {
1724 infoPtr->rows[row-1].istartband = i;
1727 ERR("P2a bug!!!!!!\n");
1729 infoPtr->rows[row-1].iendband = i;
1732 for (i = 0; i < infoPtr->uNumRows; i++) {
1735 p = &infoPtr->rows[i];
1736 TRACE("P2a row %d, starts %d, ends %d\n",
1737 i+1, p->istartband, p->iendband);
1740 /* ******* End Phase 2a - create array of start and end ******* */
1741 /* indexes by row */
1744 /* ******* Start Phase 2b - adjust all bands for height full ******* */
1745 /* assumes that the following variables contain: */
1746 /* y/x current height/width of all rows */
1747 /* clientcy/clientcx height/width of client area */
1749 if (((infoPtr->dwStyle & CCS_VERT) ? clientcx > x : clientcy > y) &&
1750 infoPtr->uNumBands) {
1751 INT diff, i, iband, j;
1753 diff = (infoPtr->dwStyle & CCS_VERT) ? clientcx - x : clientcy - y;
1754 for (i = infoPtr->uNumRows; i >= 1; i--) {
1755 /* if row has more than 1 band, ignore row */
1756 if (infoPtr->rows[i-1].istartband != infoPtr->rows[i-1].iendband)
1758 /* point to only band in row */
1759 iband = infoPtr->rows[i-1].istartband;
1760 lpBand = &infoPtr->bands[iband];
1761 if(HIDDENBAND(lpBand)) continue;
1762 if (lpBand->fMask & RBBS_VARIABLEHEIGHT) continue;
1763 if (((INT)lpBand->cyMaxChild < 1) ||
1764 ((INT)lpBand->cyIntegral < 1)) {
1765 if (lpBand->cyMaxChild + lpBand->cyIntegral == 0) continue;
1766 ERR("P2b band %u RBBS_VARIABLEHEIGHT set but cyMax=%d, cyInt=%d\n",
1767 iband, lpBand->cyMaxChild, lpBand->cyIntegral);
1770 /* j is now the maximum height/width in the client area */
1771 j = ((diff / lpBand->cyIntegral) * lpBand->cyIntegral) +
1773 if (j > lpBand->cyMaxChild + REBARSPACE(lpBand))
1774 j = lpBand->cyMaxChild + REBARSPACE(lpBand);
1775 diff -= (j - ircBw(lpBand));
1776 if (infoPtr->dwStyle & CCS_VERT)
1777 lpBand->rcBand.right = lpBand->rcBand.left + j;
1779 lpBand->rcBand.bottom = lpBand->rcBand.top + j;
1780 TRACE("P2b band %d, row %d changed to (%d,%d)-(%d,%d)\n",
1781 iband, lpBand->iRow,
1782 lpBand->rcBand.left, lpBand->rcBand.top,
1783 lpBand->rcBand.right, lpBand->rcBand.bottom);
1784 if (diff <= 0) break;
1787 ERR("P2b allocated more than available, diff=%d\n", diff);
1790 if (infoPtr->dwStyle & CCS_VERT)
1791 x = clientcx - diff;
1793 y = clientcy - diff;
1796 /* ******* End Phase 2b - adjust all bands for height full ******* */
1799 /* ******* Start Phase 3 - adjust all bands for width full ******* */
1801 if (infoPtr->uNumBands) {
1804 /* If RBS_BANDBORDERS set then indicate to draw bottom separator */
1805 /* on all bands in all rows but last row. */
1806 /* Also indicate to draw the right separator for each band in */
1807 /* each row but the rightmost band. */
1808 if (infoPtr->dwStyle & RBS_BANDBORDERS) {
1810 for(i = 0; i < infoPtr->uNumRows; i++) {
1811 p = &infoPtr->rows[i];
1812 for (j = p->istartband; j <= p->iendband; j++) {
1813 lpBand = &infoPtr->bands[j];
1814 if (HIDDENBAND(lpBand)) continue;
1815 if (j != p->iendband)
1816 lpBand->fDraw |= DRAW_RIGHTSEP;
1817 if (i != infoPtr->uNumRows-1)
1818 lpBand->fDraw |= DRAW_BOTTOMSEP;
1823 /* Distribute the extra space on the horizontal and adjust */
1824 /* all bands in row to same height. */
1825 for (i=1; i<=infoPtr->uNumRows; i++) {
1826 p = &infoPtr->rows[i-1];
1829 TRACE("P3 processing row %d, starting band %d, ending band %d\n",
1830 i, p->istartband, p->iendband);
1832 /* Find the largest height of the bands in the row */
1833 for (j = p->istartband; j <= p->iendband; j++) {
1834 lpBand = &infoPtr->bands[j];
1835 if (HIDDENBAND(lpBand)) continue;
1836 if (mcy < ircBw(lpBand))
1837 mcy = ircBw(lpBand);
1840 REBAR_AdjustBands (infoPtr, p->istartband, p->iendband,
1841 (infoPtr->dwStyle & CCS_VERT) ?
1842 clientcy : clientcx, mcy);
1845 /* Calculate the other rectangles in each band */
1846 if (infoPtr->dwStyle & CCS_VERT) {
1847 REBAR_CalcVertBand (infoPtr, 0, infoPtr->uNumBands,
1851 REBAR_CalcHorzBand (infoPtr, 0, infoPtr->uNumBands,
1856 /* ******* End Phase 3 - adjust all bands for width full ******* */
1858 /* now compute size of Rebar itself */
1859 infoPtr->oldSize = infoPtr->calcSize;
1860 if (infoPtr->uNumBands == 0) {
1861 /* we have no bands, so make size the size of client */
1865 if (infoPtr->dwStyle & CCS_VERT) {
1866 infoPtr->calcSize.cx = x;
1867 infoPtr->calcSize.cy = clientcy;
1868 TRACE("vert, notify=%d, x=%d, origheight=%d\n",
1869 notify, x, origheight);
1870 if (notify && (x != origheight)) infoPtr->fStatus |= NTF_HGHTCHG;
1873 infoPtr->calcSize.cx = clientcx;
1874 infoPtr->calcSize.cy = y;
1875 TRACE("horz, notify=%d, y=%d, origheight=%d\n",
1876 notify, y, origheight);
1877 if (notify && (y != origheight)) infoPtr->fStatus |= NTF_HGHTCHG;
1880 REBAR_DumpBand (infoPtr);
1882 REBAR_MoveChildWindows (infoPtr, 0, infoPtr->uNumBands);
1884 REBAR_ForceResize (infoPtr);
1889 REBAR_ValidateBand (REBAR_INFO *infoPtr, REBAR_BAND *lpBand)
1890 /* Function: This routine evaluates the band specs supplied */
1891 /* by the user and updates the following 5 fields in */
1892 /* the internal band structure: cxHeader, lcx, lcy, hcx, hcy*/
1899 lpBand->fStatus = 0;
1907 /* Data comming in from users into the cx... and cy... fields */
1908 /* may be bad, just garbage, because the user never clears */
1909 /* the fields. RB_{SET|INSERT}BAND{A|W} just passes the data */
1910 /* along if the fields exist in the input area. Here we must */
1911 /* determine if the data is valid. I have no idea how MS does */
1912 /* the validation, but it does because the RB_GETBANDINFO */
1913 /* returns a 0 when I know the sample program passed in an */
1914 /* address. Here I will use the algorithim that if the value */
1915 /* is greater than 65535 then it is bad and replace it with */
1916 /* a zero. Feel free to improve the algorithim. - GA 12/2000 */
1917 if (lpBand->cxMinChild > 65535) lpBand->cxMinChild = 0;
1918 if (lpBand->cyMinChild > 65535) lpBand->cyMinChild = 0;
1919 if (lpBand->cx > 65535) lpBand->cx = 0;
1920 if (lpBand->cyChild > 65535) lpBand->cyChild = 0;
1921 if (lpBand->cyMaxChild > 65535) lpBand->cyMaxChild = 0;
1922 if (lpBand->cyIntegral > 65535) lpBand->cyIntegral = 0;
1923 if (lpBand->cxIdeal > 65535) lpBand->cxIdeal = 0;
1924 if (lpBand->cxHeader > 65535) lpBand->cxHeader = 0;
1926 /* FIXME: probably should only set NEEDS_LAYOUT flag when */
1927 /* values change. Till then always set it. */
1928 TRACE("setting NEEDS_LAYOUT\n");
1929 infoPtr->fStatus |= BAND_NEEDS_LAYOUT;
1931 /* Header is where the image, text and gripper exist */
1932 /* in the band and preceed the child window. */
1934 /* count number of non-FIXEDSIZE and non-Hidden bands */
1936 for (i=0; i<infoPtr->uNumBands; i++){
1937 tBand = &infoPtr->bands[i];
1938 if (!HIDDENBAND(tBand) && !(tBand->fStyle & RBBS_FIXEDSIZE))
1942 /* calculate gripper rectangle */
1943 if ( (!(lpBand->fStyle & RBBS_NOGRIPPER)) &&
1944 ( (lpBand->fStyle & RBBS_GRIPPERALWAYS) ||
1945 ( !(lpBand->fStyle & RBBS_FIXEDSIZE) && (nonfixed > 1)))
1947 lpBand->fStatus |= HAS_GRIPPER;
1948 if (infoPtr->dwStyle & CCS_VERT)
1949 if (infoPtr->dwStyle & RBS_VERTICALGRIPPER)
1950 header += (GRIPPER_HEIGHT + REBAR_PRE_GRIPPER);
1952 header += (GRIPPER_WIDTH + REBAR_PRE_GRIPPER);
1954 header += (REBAR_PRE_GRIPPER + GRIPPER_WIDTH);
1955 /* Always have 4 pixels before anything else */
1956 header += REBAR_ALWAYS_SPACE;
1959 /* image is visible */
1960 if ((lpBand->fMask & RBBIM_IMAGE) && (infoPtr->himl)) {
1961 lpBand->fStatus |= HAS_IMAGE;
1962 if (infoPtr->dwStyle & CCS_VERT) {
1963 header += (infoPtr->imageSize.cy + REBAR_POST_IMAGE);
1964 lpBand->lcy = infoPtr->imageSize.cx + 2;
1967 header += (infoPtr->imageSize.cx + REBAR_POST_IMAGE);
1968 lpBand->lcy = infoPtr->imageSize.cy + 2;
1972 /* text is visible */
1973 if ((lpBand->fMask & RBBIM_TEXT) && (lpBand->lpText)) {
1974 HDC hdc = GetDC (0);
1975 HFONT hOldFont = SelectObject (hdc, infoPtr->hFont);
1978 lpBand->fStatus |= HAS_TEXT;
1979 GetTextExtentPoint32W (hdc, lpBand->lpText,
1980 lstrlenW (lpBand->lpText), &size);
1981 header += ((infoPtr->dwStyle & CCS_VERT) ? (size.cy + REBAR_POST_TEXT) : (size.cx + REBAR_POST_TEXT));
1982 textheight = (infoPtr->dwStyle & CCS_VERT) ? 0 : size.cy;
1984 SelectObject (hdc, hOldFont);
1988 /* if no gripper but either image or text, then leave space */
1989 if ((lpBand->fStatus & (HAS_IMAGE | HAS_TEXT)) &&
1990 !(lpBand->fStatus & HAS_GRIPPER)) {
1991 header += REBAR_ALWAYS_SPACE;
1994 /* check if user overrode the header value */
1995 if (!(lpBand->fMask & RBBIM_HEADERSIZE))
1996 lpBand->cxHeader = header;
1999 /* Now compute minimum size of child window */
2000 lpBand->offChild.cx = 0;
2001 lpBand->offChild.cy = 0;
2002 lpBand->lcy = textheight;
2003 lpBand->ccy = lpBand->lcy;
2004 if (lpBand->fMask & RBBIM_CHILDSIZE) {
2005 lpBand->lcx = lpBand->cxMinChild;
2007 /* Set the .cy values for CHILDSIZE case */
2008 lpBand->lcy = max(lpBand->lcy, lpBand->cyMinChild);
2009 lpBand->ccy = lpBand->lcy;
2010 lpBand->hcy = lpBand->lcy;
2011 if (lpBand->cyMaxChild != 0xffffffff) {
2012 lpBand->hcy = lpBand->cyMaxChild;
2014 if (lpBand->cyChild != 0xffffffff)
2015 lpBand->ccy = max (lpBand->cyChild, lpBand->lcy);
2017 TRACE("_CHILDSIZE\n");
2019 if (lpBand->fMask & RBBIM_SIZE) {
2020 lpBand->hcx = max (lpBand->cx-lpBand->cxHeader, lpBand->lcx);
2024 lpBand->hcx = lpBand->lcx;
2025 lpBand->ccx = lpBand->hcx;
2027 /* make ->.cx include header size for _Layout */
2028 lpBand->lcx += lpBand->cxHeader;
2029 lpBand->ccx += lpBand->cxHeader;
2030 lpBand->hcx += lpBand->cxHeader;
2035 REBAR_CommonSetupBand (HWND hwnd, LPREBARBANDINFOA lprbbi, REBAR_BAND *lpBand)
2036 /* Function: This routine copies the supplied values from */
2037 /* user input (lprbbi) to the internal band structure. */
2039 lpBand->fMask |= lprbbi->fMask;
2041 if (lprbbi->fMask & RBBIM_STYLE)
2042 lpBand->fStyle = lprbbi->fStyle;
2044 if (lprbbi->fMask & RBBIM_COLORS) {
2045 lpBand->clrFore = lprbbi->clrFore;
2046 lpBand->clrBack = lprbbi->clrBack;
2049 if (lprbbi->fMask & RBBIM_IMAGE)
2050 lpBand->iImage = lprbbi->iImage;
2052 if (lprbbi->fMask & RBBIM_CHILD) {
2053 if (lprbbi->hwndChild) {
2054 lpBand->hwndChild = lprbbi->hwndChild;
2055 lpBand->hwndPrevParent =
2056 SetParent (lpBand->hwndChild, hwnd);
2057 /* below in trace fro WinRAR */
2058 ShowWindow(lpBand->hwndChild, SW_SHOWNOACTIVATE | SW_SHOWNORMAL);
2059 /* above in trace fro WinRAR */
2062 TRACE("child: %p prev parent: %p\n",
2063 lpBand->hwndChild, lpBand->hwndPrevParent);
2064 lpBand->hwndChild = 0;
2065 lpBand->hwndPrevParent = 0;
2069 if (lprbbi->fMask & RBBIM_CHILDSIZE) {
2070 lpBand->cxMinChild = lprbbi->cxMinChild;
2071 lpBand->cyMinChild = lprbbi->cyMinChild;
2072 if (lprbbi->cbSize >= sizeof (REBARBANDINFOA)) {
2073 lpBand->cyChild = lprbbi->cyChild;
2074 lpBand->cyMaxChild = lprbbi->cyMaxChild;
2075 lpBand->cyIntegral = lprbbi->cyIntegral;
2077 else { /* special case - these should be zeroed out since */
2078 /* RBBIM_CHILDSIZE added these in WIN32_IE >= 0x0400 */
2079 lpBand->cyChild = 0;
2080 lpBand->cyMaxChild = 0;
2081 lpBand->cyIntegral = 0;
2085 if (lprbbi->fMask & RBBIM_SIZE)
2086 lpBand->cx = lprbbi->cx;
2088 if (lprbbi->fMask & RBBIM_BACKGROUND)
2089 lpBand->hbmBack = lprbbi->hbmBack;
2091 if (lprbbi->fMask & RBBIM_ID)
2092 lpBand->wID = lprbbi->wID;
2094 /* check for additional data */
2095 if (lprbbi->cbSize >= sizeof (REBARBANDINFOA)) {
2096 if (lprbbi->fMask & RBBIM_IDEALSIZE)
2097 lpBand->cxIdeal = lprbbi->cxIdeal;
2099 if (lprbbi->fMask & RBBIM_LPARAM)
2100 lpBand->lParam = lprbbi->lParam;
2102 if (lprbbi->fMask & RBBIM_HEADERSIZE)
2103 lpBand->cxHeader = lprbbi->cxHeader;
2108 REBAR_InternalEraseBkGnd (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam, RECT *clip)
2109 /* Function: This erases the background rectangle by drawing */
2110 /* each band with its background color (or the default) and */
2111 /* draws each bands right separator if necessary. The row */
2112 /* separators are drawn on the first band of the next row. */
2116 HDC hdc = (HDC)wParam;
2118 COLORREF old = CLR_NONE, new;
2121 for(i=0; i<infoPtr->uNumBands; i++) {
2122 lpBand = &infoPtr->bands[i];
2123 if (HIDDENBAND(lpBand)) continue;
2125 /* draw band separator between rows */
2126 if (lpBand->iRow != oldrow) {
2127 oldrow = lpBand->iRow;
2128 if (lpBand->fDraw & DRAW_BOTTOMSEP) {
2130 rcRowSep = lpBand->rcBand;
2131 if (infoPtr->dwStyle & CCS_VERT) {
2132 rcRowSep.right += SEP_WIDTH_SIZE;
2133 rcRowSep.bottom = infoPtr->calcSize.cy;
2134 DrawEdge (hdc, &rcRowSep, EDGE_ETCHED, BF_RIGHT);
2137 rcRowSep.bottom += SEP_WIDTH_SIZE;
2138 rcRowSep.right = infoPtr->calcSize.cx;
2139 DrawEdge (hdc, &rcRowSep, EDGE_ETCHED, BF_BOTTOM);
2141 TRACE ("drawing band separator bottom (%d,%d)-(%d,%d)\n",
2142 rcRowSep.left, rcRowSep.top,
2143 rcRowSep.right, rcRowSep.bottom);
2147 /* draw band separator between bands in a row */
2148 if (lpBand->fDraw & DRAW_RIGHTSEP) {
2150 rcSep = lpBand->rcBand;
2151 if (infoPtr->dwStyle & CCS_VERT) {
2152 rcSep.bottom += SEP_WIDTH_SIZE;
2153 DrawEdge (hdc, &rcSep, EDGE_ETCHED, BF_BOTTOM);
2156 rcSep.right += SEP_WIDTH_SIZE;
2157 DrawEdge (hdc, &rcSep, EDGE_ETCHED, BF_RIGHT);
2159 TRACE("drawing band separator right (%d,%d)-(%d,%d)\n",
2160 rcSep.left, rcSep.top, rcSep.right, rcSep.bottom);
2163 /* draw the actual background */
2164 if (lpBand->clrBack != CLR_NONE) {
2165 new = (lpBand->clrBack == CLR_DEFAULT) ? infoPtr->clrBtnFace :
2168 /* testing only - make background green to see it */
2173 /* In the absence of documentation for Rebar vs. CLR_NONE,
2174 * we will use the default BtnFace color. Note documentation
2175 * exists for Listview and Imagelist.
2177 new = infoPtr->clrBtnFace;
2179 /* testing only - make background green to see it */
2183 old = SetBkColor (hdc, new);
2185 rect = lpBand->rcBand;
2186 TRACE("%s background color=0x%06lx, band (%d,%d)-(%d,%d), clip (%d,%d)-(%d,%d)\n",
2187 (lpBand->clrBack == CLR_NONE) ? "none" :
2188 ((lpBand->clrBack == CLR_DEFAULT) ? "dft" : ""),
2190 lpBand->rcBand.left,lpBand->rcBand.top,
2191 lpBand->rcBand.right,lpBand->rcBand.bottom,
2192 clip->left, clip->top,
2193 clip->right, clip->bottom);
2194 ExtTextOutA (hdc, 0, 0, ETO_OPAQUE, &rect, NULL, 0, 0);
2195 if (lpBand->clrBack != CLR_NONE)
2196 SetBkColor (hdc, old);
2202 REBAR_InternalHitTest (REBAR_INFO *infoPtr, LPPOINT lpPt, UINT *pFlags, INT *pBand)
2208 GetClientRect (infoPtr->hwndSelf, &rect);
2210 *pFlags = RBHT_NOWHERE;
2211 if (PtInRect (&rect, *lpPt))
2213 if (infoPtr->uNumBands == 0) {
2214 *pFlags = RBHT_NOWHERE;
2221 /* somewhere inside */
2222 infoPtr->ihitBand = -1;
2223 for (iCount = 0; iCount < infoPtr->uNumBands; iCount++) {
2224 lpBand = &infoPtr->bands[iCount];
2225 if (HIDDENBAND(lpBand)) continue;
2226 if (PtInRect (&lpBand->rcBand, *lpPt)) {
2229 if (PtInRect (&lpBand->rcGripper, *lpPt)) {
2230 *pFlags = RBHT_GRABBER;
2231 infoPtr->ihitBand = iCount;
2232 TRACE("ON GRABBER %d\n", iCount);
2235 else if (PtInRect (&lpBand->rcCapImage, *lpPt)) {
2236 *pFlags = RBHT_CAPTION;
2237 TRACE("ON CAPTION %d\n", iCount);
2240 else if (PtInRect (&lpBand->rcCapText, *lpPt)) {
2241 *pFlags = RBHT_CAPTION;
2242 TRACE("ON CAPTION %d\n", iCount);
2245 else if (PtInRect (&lpBand->rcChild, *lpPt)) {
2246 *pFlags = RBHT_CLIENT;
2247 TRACE("ON CLIENT %d\n", iCount);
2251 *pFlags = RBHT_NOWHERE;
2252 TRACE("NOWHERE %d\n", iCount);
2258 *pFlags = RBHT_NOWHERE;
2267 *pFlags = RBHT_NOWHERE;
2274 TRACE("flags=0x%X\n", *pFlags);
2280 REBAR_Shrink (REBAR_INFO *infoPtr, REBAR_BAND *band, INT movement, INT i)
2281 /* Function: This attempts to shrink the given band by the */
2282 /* the amount in "movement". A shrink to the left is indi- */
2283 /* cated by "movement" being negative. "i" is merely the */
2284 /* band index for trace messages. */
2286 INT Leadjust, Readjust, avail, ret;
2288 /* Note: a left drag is indicated by "movement" being negative. */
2289 /* Similarly, a right drag is indicated by "movement" */
2290 /* being positive. "movement" should never be 0, but if */
2291 /* it is then the band does not move. */
2293 avail = rcBw(band) - band->lcx;
2295 /* now compute the Left End adjustment factor and Right End */
2296 /* adjustment factor. They may be different if shrinking. */
2298 /* if this band is not shrinkable, then just move it */
2299 Leadjust = Readjust = movement;
2305 if (avail <= abs(movement)) {
2306 Readjust = movement;
2307 Leadjust = movement + avail;
2311 Readjust = movement;
2318 if (avail <= abs(movement)) {
2319 Leadjust = movement;
2320 Readjust = movement - avail;
2324 Leadjust = movement;
2331 /* Reasonability Check */
2332 if (rcBlt(band) + Leadjust < 0) {
2333 ERR("adjustment will fail, band %d: left=%d, right=%d, move=%d, rtn=%d\n",
2334 i, Leadjust, Readjust, movement, ret);
2337 LEADJ(band, Leadjust);
2338 READJ(band, Readjust);
2340 TRACE("band %d: left=%d, right=%d, move=%d, rtn=%d, rcBand=(%d,%d)-(%d,%d)\n",
2341 i, Leadjust, Readjust, movement, ret,
2342 band->rcBand.left, band->rcBand.top,
2343 band->rcBand.right, band->rcBand.bottom);
2349 REBAR_HandleLRDrag (REBAR_INFO *infoPtr, POINTS *ptsmove)
2350 /* Function: This will implement the functionality of a */
2351 /* Gripper drag within a row. It will not implement "out- */
2352 /* of-row" drags. (They are detected and handled in */
2353 /* REBAR_MouseMove.) */
2354 /* **** FIXME Switching order of bands in a row not **** */
2355 /* **** yet implemented. **** */
2357 REBAR_BAND *hitBand, *band, *mindBand, *maxdBand;
2359 INT imindBand = -1, imaxdBand, ihitBand, i, movement;
2360 INT RHeaderSum = 0, LHeaderSum = 0;
2363 /* on first significant mouse movement, issue notify */
2365 if (!(infoPtr->fStatus & BEGIN_DRAG_ISSUED)) {
2366 if (REBAR_Notify_NMREBAR (infoPtr, -1, RBN_BEGINDRAG)) {
2367 /* Notify returned TRUE - abort drag */
2368 infoPtr->dragStart.x = 0;
2369 infoPtr->dragStart.y = 0;
2370 infoPtr->dragNow = infoPtr->dragStart;
2371 infoPtr->ihitBand = -1;
2375 infoPtr->fStatus |= BEGIN_DRAG_ISSUED;
2378 ihitBand = infoPtr->ihitBand;
2379 hitBand = &infoPtr->bands[ihitBand];
2380 imaxdBand = ihitBand; /* to suppress warning message */
2382 /* find all the bands in the row of the one whose Gripper was seized */
2383 for (i=0; i<infoPtr->uNumBands; i++) {
2384 band = &infoPtr->bands[i];
2385 if (HIDDENBAND(band)) continue;
2386 if (band->iRow == hitBand->iRow) {
2388 if (imindBand == -1) imindBand = i;
2389 /* minimum size of each band is size of header plus */
2390 /* size of minimum child plus offset of child from header plus */
2391 /* a one to separate each band. */
2393 LHeaderSum += (band->lcx + SEP_WIDTH);
2395 RHeaderSum += (band->lcx + SEP_WIDTH);
2399 if (RHeaderSum) RHeaderSum -= SEP_WIDTH; /* no separator afterlast band */
2401 mindBand = &infoPtr->bands[imindBand];
2402 maxdBand = &infoPtr->bands[imaxdBand];
2404 if (imindBand == imaxdBand) return; /* nothing to drag agains */
2405 if (imindBand == ihitBand) return; /* first band in row, cant drag */
2407 /* limit movement to inside adjustable bands - Left */
2408 if ( (ptsmove->x < mindBand->rcBand.left) ||
2409 (ptsmove->x > maxdBand->rcBand.right) ||
2410 (ptsmove->y < mindBand->rcBand.top) ||
2411 (ptsmove->y > maxdBand->rcBand.bottom))
2412 return; /* should swap bands */
2414 if (infoPtr->dwStyle & CCS_VERT)
2415 movement = ptsmove->y - ((hitBand->rcBand.top+REBAR_PRE_GRIPPER) -
2416 infoPtr->ihitoffset);
2418 movement = ptsmove->x - ((hitBand->rcBand.left+REBAR_PRE_GRIPPER) -
2419 infoPtr->ihitoffset);
2420 infoPtr->dragNow = *ptsmove;
2422 TRACE("before: movement=%d (%d,%d), imindBand=%d, ihitBand=%d, imaxdBand=%d, LSum=%d, RSum=%d\n",
2423 movement, ptsmove->x, ptsmove->y, imindBand, ihitBand,
2424 imaxdBand, LHeaderSum, RHeaderSum);
2425 REBAR_DumpBand (infoPtr);
2429 /* *** Drag left/up *** */
2430 compress = rcBlt(hitBand) - rcBlt(mindBand) -
2432 if (compress < abs(movement)) {
2433 TRACE("limiting left drag, was %d changed to %d\n",
2434 movement, -compress);
2435 movement = -compress;
2438 for (i=ihitBand; i>=imindBand; i--) {
2439 band = &infoPtr->bands[i];
2440 if (HIDDENBAND(band)) continue;
2441 if (i == ihitBand) {
2442 LEADJ(band, movement);
2445 movement = REBAR_Shrink (infoPtr, band, movement, i);
2446 band->ccx = rcBw(band);
2452 /* *** Drag right/down *** */
2453 compress = rcBrb(maxdBand) - rcBlt(hitBand) -
2455 if (compress < abs(movement)) {
2456 TRACE("limiting right drag, was %d changed to %d\n",
2457 movement, compress);
2458 movement = compress;
2460 for (i=ihitBand-1; i<=imaxdBand; i++) {
2461 band = &infoPtr->bands[i];
2462 if (HIDDENBAND(band)) continue;
2465 READJ(band, movement);
2468 movement = REBAR_Shrink (infoPtr, band, movement, i);
2469 band->ccx = rcBw(band);
2473 /* recompute all rectangles */
2474 if (infoPtr->dwStyle & CCS_VERT) {
2475 REBAR_CalcVertBand (infoPtr, imindBand, imaxdBand+1,
2479 REBAR_CalcHorzBand (infoPtr, imindBand, imaxdBand+1,
2483 TRACE("bands after adjustment, see band # %d, %d\n",
2484 imindBand, imaxdBand);
2485 REBAR_DumpBand (infoPtr);
2488 mindBand->rcBand.left,
2489 mindBand->rcBand.top,
2490 maxdBand->rcBand.right,
2491 maxdBand->rcBand.bottom);
2493 REBAR_MoveChildWindows (infoPtr, imindBand, imaxdBand+1);
2495 InvalidateRect (infoPtr->hwndSelf, &newrect, TRUE);
2496 UpdateWindow (infoPtr->hwndSelf);
2502 /* << REBAR_BeginDrag >> */
2506 REBAR_DeleteBand (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
2508 UINT uBand = (UINT)wParam;
2512 if (uBand >= infoPtr->uNumBands)
2515 TRACE("deleting band %u!\n", uBand);
2516 lpBand = &infoPtr->bands[uBand];
2517 REBAR_Notify_NMREBAR (infoPtr, uBand, RBN_DELETINGBAND);
2519 if (infoPtr->uNumBands == 1) {
2520 TRACE(" simple delete!\n");
2521 if ((lpBand->fMask & RBBIM_CHILD) && lpBand->hwndChild)
2522 childhwnd = lpBand->hwndChild;
2523 COMCTL32_Free (infoPtr->bands);
2524 infoPtr->bands = NULL;
2525 infoPtr->uNumBands = 0;
2528 REBAR_BAND *oldBands = infoPtr->bands;
2529 TRACE("complex delete! [uBand=%u]\n", uBand);
2531 if ((lpBand->fMask & RBBIM_CHILD) && lpBand->hwndChild)
2532 childhwnd = lpBand->hwndChild;
2534 infoPtr->uNumBands--;
2535 infoPtr->bands = COMCTL32_Alloc (sizeof (REBAR_BAND) * infoPtr->uNumBands);
2537 memcpy (&infoPtr->bands[0], &oldBands[0],
2538 uBand * sizeof(REBAR_BAND));
2541 if (uBand < infoPtr->uNumBands) {
2542 memcpy (&infoPtr->bands[uBand], &oldBands[uBand+1],
2543 (infoPtr->uNumBands - uBand) * sizeof(REBAR_BAND));
2546 COMCTL32_Free (oldBands);
2550 ShowWindow (childhwnd, SW_HIDE);
2552 REBAR_Notify_NMREBAR (infoPtr, -1, RBN_DELETEDBAND);
2554 /* if only 1 band left the re-validate to possible eliminate gripper */
2555 if (infoPtr->uNumBands == 1)
2556 REBAR_ValidateBand (infoPtr, &infoPtr->bands[0]);
2558 TRACE("setting NEEDS_LAYOUT\n");
2559 infoPtr->fStatus |= BAND_NEEDS_LAYOUT;
2560 infoPtr->fStatus |= RESIZE_ANYHOW;
2561 REBAR_Layout (infoPtr, NULL, TRUE, FALSE);
2567 /* << REBAR_DragMove >> */
2568 /* << REBAR_EndDrag >> */
2572 REBAR_GetBandBorders (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
2574 LPRECT lpRect = (LPRECT)lParam;
2579 if ((UINT)wParam >= infoPtr->uNumBands)
2582 lpBand = &infoPtr->bands[(UINT)wParam];
2584 /* FIXME - the following values were determined by experimentation */
2585 /* with the REBAR Control Spy. I have guesses as to what the 4 and */
2586 /* 1 are, but I am not sure. There doesn't seem to be any actual */
2587 /* difference in size of the control area with and without the */
2589 if (infoPtr->dwStyle & RBS_BANDBORDERS) {
2590 if (infoPtr->dwStyle & CCS_VERT) {
2592 lpRect->top = lpBand->cxHeader + 4;
2597 lpRect->left = lpBand->cxHeader + 4;
2604 lpRect->left = lpBand->cxHeader;
2610 inline static LRESULT
2611 REBAR_GetBandCount (REBAR_INFO *infoPtr)
2613 TRACE("band count %u!\n", infoPtr->uNumBands);
2615 return infoPtr->uNumBands;
2620 REBAR_GetBandInfoA (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
2622 LPREBARBANDINFOA lprbbi = (LPREBARBANDINFOA)lParam;
2627 if (lprbbi->cbSize < REBARBANDINFO_V3_SIZEA)
2629 if ((UINT)wParam >= infoPtr->uNumBands)
2632 TRACE("index %u\n", (UINT)wParam);
2634 /* copy band information */
2635 lpBand = &infoPtr->bands[(UINT)wParam];
2637 if (lprbbi->fMask & RBBIM_STYLE)
2638 lprbbi->fStyle = lpBand->fStyle;
2640 if (lprbbi->fMask & RBBIM_COLORS) {
2641 lprbbi->clrFore = lpBand->clrFore;
2642 lprbbi->clrBack = lpBand->clrBack;
2643 if (lprbbi->clrBack == CLR_DEFAULT)
2644 lprbbi->clrBack = infoPtr->clrBtnFace;
2647 if ((lprbbi->fMask & RBBIM_TEXT) && (lprbbi->lpText)) {
2648 if (lpBand->lpText && (lpBand->fMask & RBBIM_TEXT))
2650 if (!WideCharToMultiByte( CP_ACP, 0, lpBand->lpText, -1,
2651 lprbbi->lpText, lprbbi->cch, NULL, NULL ))
2652 lprbbi->lpText[lprbbi->cch-1] = 0;
2655 *lprbbi->lpText = 0;
2658 if (lprbbi->fMask & RBBIM_IMAGE) {
2659 if (lpBand->fMask & RBBIM_IMAGE)
2660 lprbbi->iImage = lpBand->iImage;
2662 lprbbi->iImage = -1;
2665 if (lprbbi->fMask & RBBIM_CHILD)
2666 lprbbi->hwndChild = lpBand->hwndChild;
2668 if (lprbbi->fMask & RBBIM_CHILDSIZE) {
2669 lprbbi->cxMinChild = lpBand->cxMinChild;
2670 lprbbi->cyMinChild = lpBand->cyMinChild;
2671 if (lprbbi->cbSize >= sizeof (REBARBANDINFOA)) {
2672 lprbbi->cyChild = lpBand->cyChild;
2673 lprbbi->cyMaxChild = lpBand->cyMaxChild;
2674 lprbbi->cyIntegral = lpBand->cyIntegral;
2678 if (lprbbi->fMask & RBBIM_SIZE)
2679 lprbbi->cx = lpBand->cx;
2681 if (lprbbi->fMask & RBBIM_BACKGROUND)
2682 lprbbi->hbmBack = lpBand->hbmBack;
2684 if (lprbbi->fMask & RBBIM_ID)
2685 lprbbi->wID = lpBand->wID;
2687 /* check for additional data */
2688 if (lprbbi->cbSize >= sizeof (REBARBANDINFOA)) {
2689 if (lprbbi->fMask & RBBIM_IDEALSIZE)
2690 lprbbi->cxIdeal = lpBand->cxIdeal;
2692 if (lprbbi->fMask & RBBIM_LPARAM)
2693 lprbbi->lParam = lpBand->lParam;
2695 if (lprbbi->fMask & RBBIM_HEADERSIZE)
2696 lprbbi->cxHeader = lpBand->cxHeader;
2699 REBAR_DumpBandInfo (lprbbi);
2706 REBAR_GetBandInfoW (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
2708 LPREBARBANDINFOW lprbbi = (LPREBARBANDINFOW)lParam;
2713 if (lprbbi->cbSize < REBARBANDINFO_V3_SIZEW)
2715 if ((UINT)wParam >= infoPtr->uNumBands)
2718 TRACE("index %u\n", (UINT)wParam);
2720 /* copy band information */
2721 lpBand = &infoPtr->bands[(UINT)wParam];
2723 if (lprbbi->fMask & RBBIM_STYLE)
2724 lprbbi->fStyle = lpBand->fStyle;
2726 if (lprbbi->fMask & RBBIM_COLORS) {
2727 lprbbi->clrFore = lpBand->clrFore;
2728 lprbbi->clrBack = lpBand->clrBack;
2729 if (lprbbi->clrBack == CLR_DEFAULT)
2730 lprbbi->clrBack = infoPtr->clrBtnFace;
2733 if ((lprbbi->fMask & RBBIM_TEXT) && (lprbbi->lpText)) {
2734 if (lpBand->lpText && (lpBand->fMask & RBBIM_TEXT))
2735 lstrcpynW (lprbbi->lpText, lpBand->lpText, lprbbi->cch);
2737 *lprbbi->lpText = 0;
2740 if (lprbbi->fMask & RBBIM_IMAGE) {
2741 if (lpBand->fMask & RBBIM_IMAGE)
2742 lprbbi->iImage = lpBand->iImage;
2744 lprbbi->iImage = -1;
2747 if (lprbbi->fMask & RBBIM_CHILD)
2748 lprbbi->hwndChild = lpBand->hwndChild;
2750 if (lprbbi->fMask & RBBIM_CHILDSIZE) {
2751 lprbbi->cxMinChild = lpBand->cxMinChild;
2752 lprbbi->cyMinChild = lpBand->cyMinChild;
2753 if (lprbbi->cbSize >= sizeof (REBARBANDINFOW)) {
2754 lprbbi->cyChild = lpBand->cyChild;
2755 lprbbi->cyMaxChild = lpBand->cyMaxChild;
2756 lprbbi->cyIntegral = lpBand->cyIntegral;
2760 if (lprbbi->fMask & RBBIM_SIZE)
2761 lprbbi->cx = lpBand->cx;
2763 if (lprbbi->fMask & RBBIM_BACKGROUND)
2764 lprbbi->hbmBack = lpBand->hbmBack;
2766 if (lprbbi->fMask & RBBIM_ID)
2767 lprbbi->wID = lpBand->wID;
2769 /* check for additional data */
2770 if (lprbbi->cbSize >= sizeof (REBARBANDINFOW)) {
2771 if (lprbbi->fMask & RBBIM_IDEALSIZE)
2772 lprbbi->cxIdeal = lpBand->cxIdeal;
2774 if (lprbbi->fMask & RBBIM_LPARAM)
2775 lprbbi->lParam = lpBand->lParam;
2777 if (lprbbi->fMask & RBBIM_HEADERSIZE)
2778 lprbbi->cxHeader = lpBand->cxHeader;
2781 REBAR_DumpBandInfo ((LPREBARBANDINFOA)lprbbi);
2788 REBAR_GetBarHeight (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
2792 nHeight = (infoPtr->dwStyle & CCS_VERT) ? infoPtr->calcSize.cx : infoPtr->calcSize.cy;
2794 TRACE("height = %d\n", nHeight);
2801 REBAR_GetBarInfo (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
2803 LPREBARINFO lpInfo = (LPREBARINFO)lParam;
2808 if (lpInfo->cbSize < sizeof (REBARINFO))
2811 TRACE("getting bar info!\n");
2813 if (infoPtr->himl) {
2814 lpInfo->himl = infoPtr->himl;
2815 lpInfo->fMask |= RBIM_IMAGELIST;
2822 inline static LRESULT
2823 REBAR_GetBkColor (REBAR_INFO *infoPtr)
2825 COLORREF clr = infoPtr->clrBk;
2827 if (clr == CLR_DEFAULT)
2828 clr = infoPtr->clrBtnFace;
2830 TRACE("background color 0x%06lx!\n", clr);
2836 /* << REBAR_GetColorScheme >> */
2837 /* << REBAR_GetDropTarget >> */
2841 REBAR_GetPalette (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
2843 FIXME("empty stub!\n");
2850 REBAR_GetRect (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
2852 INT iBand = (INT)wParam;
2853 LPRECT lprc = (LPRECT)lParam;
2856 if ((iBand < 0) && ((UINT)iBand >= infoPtr->uNumBands))
2861 lpBand = &infoPtr->bands[iBand];
2862 CopyRect (lprc, &lpBand->rcBand);
2864 TRACE("band %d, (%d,%d)-(%d,%d)\n", iBand,
2865 lprc->left, lprc->top, lprc->right, lprc->bottom);
2871 inline static LRESULT
2872 REBAR_GetRowCount (REBAR_INFO *infoPtr)
2874 TRACE("%u\n", infoPtr->uNumRows);
2876 return infoPtr->uNumRows;
2881 REBAR_GetRowHeight (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
2883 INT iRow = (INT)wParam;
2888 for (i=0; i<infoPtr->uNumBands; i++) {
2889 lpBand = &infoPtr->bands[i];
2890 if (HIDDENBAND(lpBand)) continue;
2891 if (lpBand->iRow != iRow) continue;
2892 if (infoPtr->dwStyle & CCS_VERT)
2893 j = lpBand->rcBand.right - lpBand->rcBand.left;
2895 j = lpBand->rcBand.bottom - lpBand->rcBand.top;
2896 if (j > ret) ret = j;
2899 TRACE("row %d, height %d\n", iRow, ret);
2905 inline static LRESULT
2906 REBAR_GetTextColor (REBAR_INFO *infoPtr)
2908 TRACE("text color 0x%06lx!\n", infoPtr->clrText);
2910 return infoPtr->clrText;
2914 inline static LRESULT
2915 REBAR_GetToolTips (REBAR_INFO *infoPtr)
2917 return (LRESULT)infoPtr->hwndToolTip;
2921 inline static LRESULT
2922 REBAR_GetUnicodeFormat (REBAR_INFO *infoPtr)
2924 TRACE("%s hwnd=%p\n",
2925 infoPtr->bUnicode ? "TRUE" : "FALSE", infoPtr->hwndSelf);
2927 return infoPtr->bUnicode;
2931 inline static LRESULT
2932 REBAR_GetVersion (REBAR_INFO *infoPtr)
2934 TRACE("version %d\n", infoPtr->iVersion);
2935 return infoPtr->iVersion;
2940 REBAR_HitTest (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
2942 LPRBHITTESTINFO lprbht = (LPRBHITTESTINFO)lParam;
2947 REBAR_InternalHitTest (infoPtr, &lprbht->pt, &lprbht->flags, &lprbht->iBand);
2949 return lprbht->iBand;
2954 REBAR_IdToIndex (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
2958 if (infoPtr == NULL)
2961 if (infoPtr->uNumBands < 1)
2964 for (i = 0; i < infoPtr->uNumBands; i++) {
2965 if (infoPtr->bands[i].wID == (UINT)wParam) {
2966 TRACE("id %u is band %u found!\n", (UINT)wParam, i);
2971 TRACE("id %u is not found\n", (UINT)wParam);
2977 REBAR_InsertBandA (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
2979 LPREBARBANDINFOA lprbbi = (LPREBARBANDINFOA)lParam;
2980 UINT uIndex = (UINT)wParam;
2983 if (infoPtr == NULL)
2987 if (lprbbi->cbSize < REBARBANDINFO_V3_SIZEA)
2990 /* trace the index as signed to see the -1 */
2991 TRACE("insert band at %d!\n", (INT)uIndex);
2992 REBAR_DumpBandInfo (lprbbi);
2994 if (infoPtr->uNumBands == 0) {
2995 infoPtr->bands = (REBAR_BAND *)COMCTL32_Alloc (sizeof (REBAR_BAND));
2999 REBAR_BAND *oldBands = infoPtr->bands;
3001 (REBAR_BAND *)COMCTL32_Alloc ((infoPtr->uNumBands+1)*sizeof(REBAR_BAND));
3002 if (((INT)uIndex == -1) || (uIndex > infoPtr->uNumBands))
3003 uIndex = infoPtr->uNumBands;
3005 /* pre insert copy */
3007 memcpy (&infoPtr->bands[0], &oldBands[0],
3008 uIndex * sizeof(REBAR_BAND));
3012 if (uIndex < infoPtr->uNumBands - 1) {
3013 memcpy (&infoPtr->bands[uIndex+1], &oldBands[uIndex],
3014 (infoPtr->uNumBands - uIndex - 1) * sizeof(REBAR_BAND));
3017 COMCTL32_Free (oldBands);
3020 infoPtr->uNumBands++;
3022 TRACE("index %u!\n", uIndex);
3024 /* initialize band (infoPtr->bands[uIndex])*/
3025 lpBand = &infoPtr->bands[uIndex];
3027 lpBand->fStatus = 0;
3028 lpBand->clrFore = infoPtr->clrText;
3029 lpBand->clrBack = infoPtr->clrBk;
3030 lpBand->hwndChild = 0;
3031 lpBand->hwndPrevParent = 0;
3033 REBAR_CommonSetupBand (infoPtr->hwndSelf, lprbbi, lpBand);
3034 lpBand->lpText = NULL;
3035 if ((lprbbi->fMask & RBBIM_TEXT) && (lprbbi->lpText)) {
3036 INT len = MultiByteToWideChar( CP_ACP, 0, lprbbi->lpText, -1, NULL, 0 );
3038 lpBand->lpText = (LPWSTR)COMCTL32_Alloc (len*sizeof(WCHAR));
3039 MultiByteToWideChar( CP_ACP, 0, lprbbi->lpText, -1, lpBand->lpText, len );
3043 REBAR_ValidateBand (infoPtr, lpBand);
3044 /* On insert of second band, revalidate band 1 to possible add gripper */
3045 if (infoPtr->uNumBands == 2)
3046 REBAR_ValidateBand (infoPtr, &infoPtr->bands[0]);
3048 REBAR_DumpBand (infoPtr);
3050 REBAR_Layout (infoPtr, NULL, TRUE, FALSE);
3051 InvalidateRect(infoPtr->hwndSelf, 0, 1);
3058 REBAR_InsertBandW (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3060 LPREBARBANDINFOW lprbbi = (LPREBARBANDINFOW)lParam;
3061 UINT uIndex = (UINT)wParam;
3064 if (infoPtr == NULL)
3068 if (lprbbi->cbSize < REBARBANDINFO_V3_SIZEW)
3071 /* trace the index as signed to see the -1 */
3072 TRACE("insert band at %d!\n", (INT)uIndex);
3073 REBAR_DumpBandInfo ((LPREBARBANDINFOA)lprbbi);
3075 if (infoPtr->uNumBands == 0) {
3076 infoPtr->bands = (REBAR_BAND *)COMCTL32_Alloc (sizeof (REBAR_BAND));
3080 REBAR_BAND *oldBands = infoPtr->bands;
3082 (REBAR_BAND *)COMCTL32_Alloc ((infoPtr->uNumBands+1)*sizeof(REBAR_BAND));
3083 if (((INT)uIndex == -1) || (uIndex > infoPtr->uNumBands))
3084 uIndex = infoPtr->uNumBands;
3086 /* pre insert copy */
3088 memcpy (&infoPtr->bands[0], &oldBands[0],
3089 uIndex * sizeof(REBAR_BAND));
3093 if (uIndex < infoPtr->uNumBands - 1) {
3094 memcpy (&infoPtr->bands[uIndex+1], &oldBands[uIndex],
3095 (infoPtr->uNumBands - uIndex - 1) * sizeof(REBAR_BAND));
3098 COMCTL32_Free (oldBands);
3101 infoPtr->uNumBands++;
3103 TRACE("index %u!\n", uIndex);
3105 /* initialize band (infoPtr->bands[uIndex])*/
3106 lpBand = &infoPtr->bands[uIndex];
3108 lpBand->fStatus = 0;
3109 lpBand->clrFore = infoPtr->clrText;
3110 lpBand->clrBack = infoPtr->clrBk;
3111 lpBand->hwndChild = 0;
3112 lpBand->hwndPrevParent = 0;
3114 REBAR_CommonSetupBand (infoPtr->hwndSelf, (LPREBARBANDINFOA)lprbbi, lpBand);
3115 lpBand->lpText = NULL;
3116 if ((lprbbi->fMask & RBBIM_TEXT) && (lprbbi->lpText)) {
3117 INT len = lstrlenW (lprbbi->lpText);
3119 lpBand->lpText = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
3120 strcpyW (lpBand->lpText, lprbbi->lpText);
3124 REBAR_ValidateBand (infoPtr, lpBand);
3125 /* On insert of second band, revalidate band 1 to possible add gripper */
3126 if (infoPtr->uNumBands == 2)
3127 REBAR_ValidateBand (infoPtr, &infoPtr->bands[0]);
3129 REBAR_DumpBand (infoPtr);
3131 REBAR_Layout (infoPtr, NULL, TRUE, FALSE);
3132 InvalidateRect(infoPtr->hwndSelf, 0, 1);
3139 REBAR_MaximizeBand (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3142 UINT uBand = (UINT) wParam;
3145 if ((infoPtr->uNumBands == 0) ||
3146 ((INT)uBand < 0) || (uBand >= infoPtr->uNumBands)) {
3148 ERR("Illegal MaximizeBand, requested=%d, current band count=%d\n",
3149 (INT)uBand, infoPtr->uNumBands);
3153 lpBand = &infoPtr->bands[uBand];
3155 if (lParam && (lpBand->fMask & RBBIM_IDEALSIZE)) {
3156 /* handle setting ideal size */
3157 lpBand->ccx = lpBand->cxIdeal;
3160 /* handle setting to max */
3161 FIXME("(uBand = %u fIdeal = %s) case not coded\n",
3162 (UINT)wParam, lParam ? "TRUE" : "FALSE");
3166 infoPtr->fStatus |= BAND_NEEDS_LAYOUT;
3167 REBAR_Layout (infoPtr, 0, TRUE, TRUE);
3168 InvalidateRect (infoPtr->hwndSelf, 0, TRUE);
3176 REBAR_MinimizeBand (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3178 REBAR_BAND *band, *lpBand;
3179 UINT uBand = (UINT) wParam;
3181 INT imindBand, imaxdBand, iprevBand, startBand, endBand;
3184 /* A "minimize" band is equivalent to "dragging" the gripper
3185 * of than band to the right till the band is only the size
3190 if ((infoPtr->uNumBands == 0) ||
3191 ((INT)uBand < 0) || (uBand >= infoPtr->uNumBands)) {
3193 ERR("Illegal MinimizeBand, requested=%d, current band count=%d\n",
3194 (INT)uBand, infoPtr->uNumBands);
3198 /* compute amount of movement and validate */
3199 lpBand = &infoPtr->bands[uBand];
3201 if (infoPtr->dwStyle & CCS_VERT)
3202 movement = lpBand->rcBand.bottom - lpBand->rcBand.top -
3205 movement = lpBand->rcBand.right - lpBand->rcBand.left -
3208 ERR("something is wrong, band=(%d,%d)-(%d,%d), cxheader=%d\n",
3209 lpBand->rcBand.left, lpBand->rcBand.top,
3210 lpBand->rcBand.right, lpBand->rcBand.bottom,
3217 iprevBand = -1; /* to suppress warning message */
3219 /* find the first band in row of the one whose is being minimized */
3220 for (i=0; i<infoPtr->uNumBands; i++) {
3221 band = &infoPtr->bands[i];
3222 if (HIDDENBAND(band)) continue;
3223 if (band->iRow == lpBand->iRow) {
3225 if (imindBand == -1) imindBand = i;
3229 /* if the selected band is first in row then need to expand */
3230 /* next visible band */
3231 if (imindBand == uBand) {
3233 movement = -movement;
3234 /* find the first visible band to the right of the selected band */
3235 for (i=uBand+1; i<=imaxdBand; i++) {
3236 band = &infoPtr->bands[i];
3237 if (!HIDDENBAND(band)) {
3239 LEADJ(band, movement);
3240 band->ccx = rcBw(band);
3244 /* what case is this */
3245 if (iprevBand == -1) {
3246 ERR("no previous visible band\n");
3250 endBand = iprevBand;
3252 lpBand->rcBand.left,
3255 band->rcBand.bottom);
3257 /* otherwise expand previous visible band */
3260 /* find the first visible band to the left of the selected band */
3261 for (i=uBand-1; i>=imindBand; i--) {
3262 band = &infoPtr->bands[i];
3263 if (!HIDDENBAND(band)) {
3265 READJ(band, movement);
3266 band->ccx = rcBw(band);
3270 /* what case is this */
3271 if (iprevBand == -1) {
3272 ERR("no previous visible band\n");
3275 startBand = iprevBand;
3280 lpBand->rcBand.right,
3281 lpBand->rcBand.bottom);
3284 REBAR_Shrink (infoPtr, lpBand, movement, uBand);
3286 /* recompute all rectangles */
3287 if (infoPtr->dwStyle & CCS_VERT) {
3288 REBAR_CalcVertBand (infoPtr, startBand, endBand+1,
3292 REBAR_CalcHorzBand (infoPtr, startBand, endBand+1,
3296 TRACE("bands after minimize, see band # %d, %d\n",
3297 startBand, endBand);
3298 REBAR_DumpBand (infoPtr);
3300 REBAR_MoveChildWindows (infoPtr, startBand, endBand+1);
3302 InvalidateRect (infoPtr->hwndSelf, &newrect, TRUE);
3303 UpdateWindow (infoPtr->hwndSelf);
3309 REBAR_MoveBand (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3311 REBAR_BAND *oldBands = infoPtr->bands;
3313 UINT uFrom = (UINT)wParam;
3314 UINT uTo = (UINT)lParam;
3317 if ((infoPtr->uNumBands == 0) ||
3318 ((INT)uFrom < 0) || (uFrom >= infoPtr->uNumBands) ||
3319 ((INT)uTo < 0) || (uTo >= infoPtr->uNumBands)) {
3321 ERR("Illegal MoveBand, from=%d, to=%d, current band count=%d\n",
3322 (INT)uFrom, (INT)uTo, infoPtr->uNumBands);
3326 /* save one to be moved */
3327 memcpy (&holder, &oldBands[uFrom], sizeof(REBAR_BAND));
3329 /* close up rest of bands (psuedo delete) */
3330 if (uFrom < infoPtr->uNumBands - 1) {
3331 memcpy (&oldBands[uFrom], &oldBands[uFrom+1],
3332 (infoPtr->uNumBands - uFrom - 1) * sizeof(REBAR_BAND));
3335 /* allocate new space and copy rest of bands into it */
3337 (REBAR_BAND *)COMCTL32_Alloc ((infoPtr->uNumBands)*sizeof(REBAR_BAND));
3339 /* pre insert copy */
3341 memcpy (&infoPtr->bands[0], &oldBands[0],
3342 uTo * sizeof(REBAR_BAND));
3345 /* set moved band */
3346 memcpy (&infoPtr->bands[uTo], &holder, sizeof(REBAR_BAND));
3349 if (uTo < infoPtr->uNumBands - 1) {
3350 memcpy (&infoPtr->bands[uTo+1], &oldBands[uTo],
3351 (infoPtr->uNumBands - uTo - 1) * sizeof(REBAR_BAND));
3354 COMCTL32_Free (oldBands);
3356 TRACE("moved band %d to index %d\n", uFrom, uTo);
3357 REBAR_DumpBand (infoPtr);
3359 infoPtr->fStatus |= BAND_NEEDS_LAYOUT;
3360 /* **************************************************** */
3362 /* We do not do a REBAR_Layout here because the native */
3363 /* control does not do that. The actual layout and */
3364 /* repaint is done by the *next* real action, ex.: */
3365 /* RB_INSERTBAND, RB_DELETEBAND, RB_SIZETORECT, etc. */
3367 /* **************************************************** */
3374 REBAR_SetBandInfoA (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3376 LPREBARBANDINFOA lprbbi = (LPREBARBANDINFOA)lParam;
3381 if (lprbbi->cbSize < REBARBANDINFO_V3_SIZEA)
3383 if ((UINT)wParam >= infoPtr->uNumBands)
3386 TRACE("index %u\n", (UINT)wParam);
3387 REBAR_DumpBandInfo (lprbbi);
3389 /* set band information */
3390 lpBand = &infoPtr->bands[(UINT)wParam];
3392 REBAR_CommonSetupBand (infoPtr->hwndSelf, lprbbi, lpBand);
3393 if (lprbbi->fMask & RBBIM_TEXT) {
3394 if (lpBand->lpText) {
3395 COMCTL32_Free (lpBand->lpText);
3396 lpBand->lpText = NULL;
3398 if (lprbbi->lpText) {
3399 INT len = MultiByteToWideChar( CP_ACP, 0, lprbbi->lpText, -1, NULL, 0 );
3400 lpBand->lpText = (LPWSTR)COMCTL32_Alloc (len*sizeof(WCHAR));
3401 MultiByteToWideChar( CP_ACP, 0, lprbbi->lpText, -1, lpBand->lpText, len );
3405 REBAR_ValidateBand (infoPtr, lpBand);
3407 REBAR_DumpBand (infoPtr);
3409 if (lprbbi->fMask & (RBBIM_CHILDSIZE | RBBIM_SIZE)) {
3410 REBAR_Layout (infoPtr, NULL, TRUE, FALSE);
3411 InvalidateRect(infoPtr->hwndSelf, 0, 1);
3419 REBAR_SetBandInfoW (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3421 LPREBARBANDINFOW lprbbi = (LPREBARBANDINFOW)lParam;
3426 if (lprbbi->cbSize < REBARBANDINFO_V3_SIZEW)
3428 if ((UINT)wParam >= infoPtr->uNumBands)
3431 TRACE("index %u\n", (UINT)wParam);
3432 REBAR_DumpBandInfo ((LPREBARBANDINFOA)lprbbi);
3434 /* set band information */
3435 lpBand = &infoPtr->bands[(UINT)wParam];
3437 REBAR_CommonSetupBand (infoPtr->hwndSelf, (LPREBARBANDINFOA)lprbbi, lpBand);
3438 if (lprbbi->fMask & RBBIM_TEXT) {
3439 if (lpBand->lpText) {
3440 COMCTL32_Free (lpBand->lpText);
3441 lpBand->lpText = NULL;
3443 if (lprbbi->lpText) {
3444 INT len = lstrlenW (lprbbi->lpText);
3445 lpBand->lpText = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
3446 strcpyW (lpBand->lpText, lprbbi->lpText);
3450 REBAR_ValidateBand (infoPtr, lpBand);
3452 REBAR_DumpBand (infoPtr);
3454 if (lprbbi->fMask & (RBBIM_CHILDSIZE | RBBIM_SIZE)) {
3455 REBAR_Layout (infoPtr, NULL, TRUE, FALSE);
3456 InvalidateRect(infoPtr->hwndSelf, 0, 1);
3464 REBAR_SetBarInfo (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3466 LPREBARINFO lpInfo = (LPREBARINFO)lParam;
3473 if (lpInfo->cbSize < sizeof (REBARINFO))
3476 TRACE("setting bar info!\n");
3478 if (lpInfo->fMask & RBIM_IMAGELIST) {
3479 infoPtr->himl = lpInfo->himl;
3480 if (infoPtr->himl) {
3482 ImageList_GetIconSize (infoPtr->himl, &cx, &cy);
3483 infoPtr->imageSize.cx = cx;
3484 infoPtr->imageSize.cy = cy;
3487 infoPtr->imageSize.cx = 0;
3488 infoPtr->imageSize.cy = 0;
3490 TRACE("new image cx=%ld, cy=%ld\n", infoPtr->imageSize.cx,
3491 infoPtr->imageSize.cy);
3494 /* revalidate all bands to reset flags for images in headers of bands */
3495 for (i=0; i<infoPtr->uNumBands; i++) {
3496 lpBand = &infoPtr->bands[i];
3497 REBAR_ValidateBand (infoPtr, lpBand);
3505 REBAR_SetBkColor (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3509 clrTemp = infoPtr->clrBk;
3510 infoPtr->clrBk = (COLORREF)lParam;
3512 TRACE("background color 0x%06lx!\n", infoPtr->clrBk);
3518 /* << REBAR_SetColorScheme >> */
3519 /* << REBAR_SetPalette >> */
3523 REBAR_SetParent (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3525 HWND hwndTemp = infoPtr->hwndNotify;
3527 infoPtr->hwndNotify = (HWND)wParam;
3529 return (LRESULT)hwndTemp;
3534 REBAR_SetTextColor (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3538 clrTemp = infoPtr->clrText;
3539 infoPtr->clrText = (COLORREF)lParam;
3541 TRACE("text color 0x%06lx!\n", infoPtr->clrText);
3547 /* << REBAR_SetTooltips >> */
3550 inline static LRESULT
3551 REBAR_SetUnicodeFormat (REBAR_INFO *infoPtr, WPARAM wParam)
3553 BOOL bTemp = infoPtr->bUnicode;
3555 TRACE("to %s hwnd=%p, was %s\n",
3556 ((BOOL)wParam) ? "TRUE" : "FALSE", infoPtr->hwndSelf,
3557 (bTemp) ? "TRUE" : "FALSE");
3559 infoPtr->bUnicode = (BOOL)wParam;
3566 REBAR_SetVersion (REBAR_INFO *infoPtr, INT iVersion)
3568 INT iOldVersion = infoPtr->iVersion;
3570 if (iVersion > COMCTL32_VERSION)
3573 infoPtr->iVersion = iVersion;
3575 TRACE("new version %d\n", iVersion);
3582 REBAR_ShowBand (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3586 if (((INT)wParam < 0) || ((INT)wParam > infoPtr->uNumBands))
3589 lpBand = &infoPtr->bands[(INT)wParam];
3592 TRACE("show band %d\n", (INT)wParam);
3593 lpBand->fStyle = lpBand->fStyle & ~RBBS_HIDDEN;
3594 if (IsWindow (lpBand->hwndChild))
3595 ShowWindow (lpBand->hwndChild, SW_SHOW);
3598 TRACE("hide band %d\n", (INT)wParam);
3599 lpBand->fStyle = lpBand->fStyle | RBBS_HIDDEN;
3600 if (IsWindow (lpBand->hwndChild))
3601 ShowWindow (lpBand->hwndChild, SW_HIDE);
3604 REBAR_Layout (infoPtr, NULL, TRUE, FALSE);
3605 InvalidateRect(infoPtr->hwndSelf, 0, 1);
3612 REBAR_SizeToRect (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3614 LPRECT lpRect = (LPRECT)lParam;
3620 TRACE("[%d %d %d %d]\n",
3621 lpRect->left, lpRect->top, lpRect->right, lpRect->bottom);
3623 /* what is going on???? */
3624 GetWindowRect(infoPtr->hwndSelf, &t1);
3625 TRACE("window rect [%d %d %d %d]\n",
3626 t1.left, t1.top, t1.right, t1.bottom);
3627 GetClientRect(infoPtr->hwndSelf, &t1);
3628 TRACE("client rect [%d %d %d %d]\n",
3629 t1.left, t1.top, t1.right, t1.bottom);
3631 /* force full _Layout processing */
3632 TRACE("setting NEEDS_LAYOUT\n");
3633 infoPtr->fStatus |= BAND_NEEDS_LAYOUT;
3634 REBAR_Layout (infoPtr, lpRect, TRUE, FALSE);
3635 InvalidateRect (infoPtr->hwndSelf, NULL, TRUE);
3642 REBAR_Create (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3644 LPCREATESTRUCTA cs = (LPCREATESTRUCTA) lParam;
3647 if (TRACE_ON(rebar)) {
3648 GetWindowRect(infoPtr->hwndSelf, &wnrc1);
3649 GetClientRect(infoPtr->hwndSelf, &clrc1);
3650 TRACE("window=(%d,%d)-(%d,%d) client=(%d,%d)-(%d,%d) cs=(%d,%d %dx%d)\n",
3651 wnrc1.left, wnrc1.top, wnrc1.right, wnrc1.bottom,
3652 clrc1.left, clrc1.top, clrc1.right, clrc1.bottom,
3653 cs->x, cs->y, cs->cx, cs->cy);
3656 TRACE("created!\n");
3662 REBAR_Destroy (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3668 /* free rebar bands */
3669 if ((infoPtr->uNumBands > 0) && infoPtr->bands) {
3670 /* clean up each band */
3671 for (i = 0; i < infoPtr->uNumBands; i++) {
3672 lpBand = &infoPtr->bands[i];
3674 /* delete text strings */
3675 if (lpBand->lpText) {
3676 COMCTL32_Free (lpBand->lpText);
3677 lpBand->lpText = NULL;
3679 /* destroy child window */
3680 DestroyWindow (lpBand->hwndChild);
3683 /* free band array */
3684 COMCTL32_Free (infoPtr->bands);
3685 infoPtr->bands = NULL;
3688 DeleteObject (infoPtr->hcurArrow);
3689 DeleteObject (infoPtr->hcurHorz);
3690 DeleteObject (infoPtr->hcurVert);
3691 DeleteObject (infoPtr->hcurDrag);
3692 if(infoPtr->hDefaultFont) DeleteObject (infoPtr->hDefaultFont);
3693 SetWindowLongA (infoPtr->hwndSelf, 0, 0);
3695 /* free rebar info data */
3696 COMCTL32_Free (infoPtr);
3697 TRACE("destroyed!\n");
3703 REBAR_EraseBkGnd (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3707 if (GetClipBox ( (HDC)wParam, &cliprect))
3708 return REBAR_InternalEraseBkGnd (infoPtr, wParam, lParam, &cliprect);
3714 REBAR_GetFont (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3716 return (LRESULT)infoPtr->hFont;
3721 REBAR_LButtonDown (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3725 /* If InternalHitTest did not find a hit on the Gripper, */
3726 /* then ignore the button click. */
3727 if (infoPtr->ihitBand == -1) return 0;
3729 SetCapture (infoPtr->hwndSelf);
3731 /* save off the LOWORD and HIWORD of lParam as initial x,y */
3732 lpBand = &infoPtr->bands[infoPtr->ihitBand];
3733 infoPtr->dragStart = MAKEPOINTS(lParam);
3734 infoPtr->dragNow = infoPtr->dragStart;
3735 if (infoPtr->dwStyle & CCS_VERT)
3736 infoPtr->ihitoffset = infoPtr->dragStart.y - (lpBand->rcBand.top+REBAR_PRE_GRIPPER);
3738 infoPtr->ihitoffset = infoPtr->dragStart.x - (lpBand->rcBand.left+REBAR_PRE_GRIPPER);
3745 REBAR_LButtonUp (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3751 /* If InternalHitTest did not find a hit on the Gripper, */
3752 /* then ignore the button click. */
3753 if (infoPtr->ihitBand == -1) return 0;
3755 ihitBand = infoPtr->ihitBand;
3756 infoPtr->dragStart.x = 0;
3757 infoPtr->dragStart.y = 0;
3758 infoPtr->dragNow = infoPtr->dragStart;
3759 infoPtr->ihitBand = -1;
3763 if (infoPtr->fStatus & BEGIN_DRAG_ISSUED) {
3764 REBAR_Notify((NMHDR *) &layout, infoPtr, RBN_LAYOUTCHANGED);
3765 REBAR_Notify_NMREBAR (infoPtr, ihitBand, RBN_ENDDRAG);
3766 infoPtr->fStatus &= ~BEGIN_DRAG_ISSUED;
3769 GetClientRect(infoPtr->hwndSelf, &rect);
3770 InvalidateRect(infoPtr->hwndSelf, NULL, TRUE);
3777 REBAR_MouseMove (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3779 REBAR_BAND *band1, *band2;
3782 /* Validate entry as hit on Gripper has occurred */
3783 if (GetCapture() != infoPtr->hwndSelf) return 0;
3784 if (infoPtr->ihitBand == -1) return 0;
3786 ptsmove = MAKEPOINTS(lParam);
3788 /* if mouse did not move much, exit */
3789 if ((abs(ptsmove.x - infoPtr->dragNow.x) <= mindragx) &&
3790 (abs(ptsmove.y - infoPtr->dragNow.y) <= mindragy)) return 0;
3792 band1 = &infoPtr->bands[infoPtr->ihitBand-1];
3793 band2 = &infoPtr->bands[infoPtr->ihitBand];
3795 /* Test for valid drag case - must not be first band in row */
3796 if (infoPtr->dwStyle & CCS_VERT) {
3797 if ((ptsmove.x < band2->rcBand.left) ||
3798 (ptsmove.x > band2->rcBand.right) ||
3799 ((infoPtr->ihitBand > 0) && (band1->iRow != band2->iRow))) {
3800 FIXME("Cannot drag to other rows yet!!\n");
3803 REBAR_HandleLRDrag (infoPtr, &ptsmove);
3807 if ((ptsmove.y < band2->rcBand.top) ||
3808 (ptsmove.y > band2->rcBand.bottom) ||
3809 ((infoPtr->ihitBand > 0) && (band1->iRow != band2->iRow))) {
3810 FIXME("Cannot drag to other rows yet!!\n");
3813 REBAR_HandleLRDrag (infoPtr, &ptsmove);
3820 inline static LRESULT
3821 REBAR_NCCalcSize (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3823 if (infoPtr->dwStyle & WS_BORDER) {
3824 InflateRect((LPRECT)lParam, -GetSystemMetrics(SM_CXEDGE),
3825 -GetSystemMetrics(SM_CYEDGE));
3827 TRACE("new client=(%d,%d)-(%d,%d)\n",
3828 ((LPRECT)lParam)->left, ((LPRECT)lParam)->top,
3829 ((LPRECT)lParam)->right, ((LPRECT)lParam)->bottom);
3835 REBAR_NCCreate (HWND hwnd, WPARAM wParam, LPARAM lParam)
3837 LPCREATESTRUCTA cs = (LPCREATESTRUCTA) lParam;
3838 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
3840 NONCLIENTMETRICSA ncm;
3844 if (infoPtr != NULL) {
3845 ERR("Strange info structure pointer *not* NULL\n");
3849 if (TRACE_ON(rebar)) {
3850 GetWindowRect(hwnd, &wnrc1);
3851 GetClientRect(hwnd, &clrc1);
3852 TRACE("window=(%d,%d)-(%d,%d) client=(%d,%d)-(%d,%d) cs=(%d,%d %dx%d)\n",
3853 wnrc1.left, wnrc1.top, wnrc1.right, wnrc1.bottom,
3854 clrc1.left, clrc1.top, clrc1.right, clrc1.bottom,
3855 cs->x, cs->y, cs->cx, cs->cy);
3858 /* allocate memory for info structure */
3859 infoPtr = (REBAR_INFO *)COMCTL32_Alloc (sizeof(REBAR_INFO));
3860 SetWindowLongA (hwnd, 0, (DWORD)infoPtr);
3862 /* initialize info structure - initial values are 0 */
3863 infoPtr->clrBk = CLR_NONE;
3864 infoPtr->clrText = CLR_NONE;
3865 infoPtr->clrBtnText = GetSysColor (COLOR_BTNTEXT);
3866 infoPtr->clrBtnFace = GetSysColor (COLOR_BTNFACE);
3867 infoPtr->ihitBand = -1;
3868 infoPtr->hwndSelf = hwnd;
3869 infoPtr->DoRedraw = TRUE;
3870 infoPtr->hcurArrow = LoadCursorA (0, IDC_ARROWA);
3871 infoPtr->hcurHorz = LoadCursorA (0, IDC_SIZEWEA);
3872 infoPtr->hcurVert = LoadCursorA (0, IDC_SIZENSA);
3873 infoPtr->hcurDrag = LoadCursorA (0, IDC_SIZEA);
3874 infoPtr->bUnicode = IsWindowUnicode (hwnd);
3875 infoPtr->fStatus = CREATE_RUNNING;
3876 infoPtr->hFont = GetStockObject (SYSTEM_FONT);
3878 /* issue WM_NOTIFYFORMAT to get unicode status of parent */
3879 i = SendMessageA(REBAR_GetNotifyParent (infoPtr),
3880 WM_NOTIFYFORMAT, (WPARAM)hwnd, NF_QUERY);
3881 if ((i < NFR_ANSI) || (i > NFR_UNICODE)) {
3882 ERR("wrong response to WM_NOTIFYFORMAT (%d), assuming ANSI\n",
3886 infoPtr->NtfUnicode = (i == NFR_UNICODE) ? 1 : 0;
3888 /* add necessary styles to the requested styles */
3889 infoPtr->dwStyle = cs->style | WS_VISIBLE | CCS_TOP;
3890 SetWindowLongA (hwnd, GWL_STYLE, infoPtr->dwStyle);
3892 /* get font handle for Caption Font */
3893 ncm.cbSize = sizeof(NONCLIENTMETRICSA);
3894 SystemParametersInfoA (SPI_GETNONCLIENTMETRICS,
3895 ncm.cbSize, &ncm, 0);
3896 /* if the font is bold, set to normal */
3897 if (ncm.lfCaptionFont.lfWeight > FW_NORMAL) {
3898 ncm.lfCaptionFont.lfWeight = FW_NORMAL;
3900 tfont = CreateFontIndirectA (&ncm.lfCaptionFont);
3902 infoPtr->hFont = infoPtr->hDefaultFont = tfont;
3906 GetSysColor (numerous);
3907 GetSysColorBrush (numerous) (see WM_SYSCOLORCHANGE);
3908 *GetStockObject (SYSTEM_FONT);
3909 *SetWindowLong (hwnd, 0, info ptr);
3911 *SetWindowLong (hwnd, GWL_STYLE, style+0x10000001);
3912 WS_VISIBLE = 0x10000000;
3913 CCS_TOP = 0x00000001;
3914 *SystemParametersInfo (SPI_GETNONCLIENTMETRICS...);
3915 *CreateFontIndirect (lfCaptionFont from above);
3917 SelectObject (hdc, fontabove);
3918 GetTextMetrics (hdc, ); guessing is tmHeight
3919 SelectObject (hdc, oldfont);
3922 MapWindowPoints (0, parent, rectabove, 2);
3925 ClientToScreen (clientrect);
3926 SetWindowPos (hwnd, 0, 0, 0, 0, 0, SWP_NOZORDER);
3933 REBAR_NCHitTest (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3940 LRESULT ret = HTCLIENT;
3943 * Differences from doc at MSDN (as observed with version 4.71 of
3945 * 1. doc says nmmouse.pt is in screen coord, trace shows client coord.
3946 * 2. if band is not identified .dwItemSpec is 0xffffffff.
3947 * 3. native always seems to return HTCLIENT if notify return is 0.
3950 shortpt = MAKEPOINTS (lParam);
3951 POINTSTOPOINT(pt, shortpt);
3953 ScreenToClient (infoPtr->hwndSelf, &clpt);
3954 REBAR_InternalHitTest (infoPtr, &clpt, &scrap,
3955 (INT *)&nmmouse.dwItemSpec);
3956 nmmouse.dwItemData = 0;
3958 nmmouse.dwHitInfo = 0;
3959 if ((i = REBAR_Notify((NMHDR *) &nmmouse, infoPtr, NM_NCHITTEST))) {
3960 TRACE("notify changed return value from %ld to %d\n",
3964 TRACE("returning %ld, client point (%ld,%ld)\n", ret, clpt.x, clpt.y);
3970 REBAR_NCPaint (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3975 if (infoPtr->dwStyle & WS_MINIMIZE)
3976 return 0; /* Nothing to do */
3978 if (infoPtr->dwStyle & WS_BORDER) {
3980 /* adjust rectangle and draw the necessary edge */
3981 if (!(hdc = GetDCEx( infoPtr->hwndSelf, 0, DCX_USESTYLE | DCX_WINDOW )))
3983 GetWindowRect (infoPtr->hwndSelf, &rcWindow);
3984 OffsetRect (&rcWindow, -rcWindow.left, -rcWindow.top);
3985 TRACE("rect (%d,%d)-(%d,%d)\n",
3986 rcWindow.left, rcWindow.top,
3987 rcWindow.right, rcWindow.bottom);
3988 DrawEdge (hdc, &rcWindow, EDGE_ETCHED, BF_RECT);
3989 ReleaseDC( infoPtr->hwndSelf, hdc );
3997 REBAR_NotifyFormat (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
4001 if (lParam == NF_REQUERY) {
4002 i = SendMessageA(REBAR_GetNotifyParent (infoPtr),
4003 WM_NOTIFYFORMAT, (WPARAM)infoPtr->hwndSelf, NF_QUERY);
4004 if ((i < NFR_ANSI) || (i > NFR_UNICODE)) {
4005 ERR("wrong response to WM_NOTIFYFORMAT (%d), assuming ANSI\n",
4009 infoPtr->NtfUnicode = (i == NFR_UNICODE) ? 1 : 0;
4012 return (LRESULT)((infoPtr->bUnicode) ? NFR_UNICODE : NFR_ANSI);
4017 REBAR_Paint (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
4023 GetClientRect(infoPtr->hwndSelf, &rc);
4024 hdc = wParam==0 ? BeginPaint (infoPtr->hwndSelf, &ps) : (HDC)wParam;
4026 TRACE("painting (%d,%d)-(%d,%d) client (%d,%d)-(%d,%d)\n",
4027 ps.rcPaint.left, ps.rcPaint.top,
4028 ps.rcPaint.right, ps.rcPaint.bottom,
4029 rc.left, rc.top, rc.right, rc.bottom);
4032 /* Erase area of paint if requested */
4033 REBAR_InternalEraseBkGnd (infoPtr, wParam, lParam, &ps.rcPaint);
4036 REBAR_Refresh (infoPtr, hdc);
4038 EndPaint (infoPtr->hwndSelf, &ps);
4044 REBAR_SetCursor (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
4049 TRACE("code=0x%X id=0x%X\n", LOWORD(lParam), HIWORD(lParam));
4052 ScreenToClient (infoPtr->hwndSelf, &pt);
4054 REBAR_InternalHitTest (infoPtr, &pt, &flags, NULL);
4056 if (flags == RBHT_GRABBER) {
4057 if ((infoPtr->dwStyle & CCS_VERT) &&
4058 !(infoPtr->dwStyle & RBS_VERTICALGRIPPER))
4059 SetCursor (infoPtr->hcurVert);
4061 SetCursor (infoPtr->hcurHorz);
4063 else if (flags != RBHT_CLIENT)
4064 SetCursor (infoPtr->hcurArrow);
4071 REBAR_SetFont (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
4077 infoPtr->hFont = (HFONT)wParam;
4079 /* revalidate all bands to change sizes of text in headers of bands */
4080 for (i=0; i<infoPtr->uNumBands; i++) {
4081 lpBand = &infoPtr->bands[i];
4082 REBAR_ValidateBand (infoPtr, lpBand);
4086 if (LOWORD(lParam)) {
4087 GetClientRect (infoPtr->hwndSelf, &rcClient);
4088 REBAR_Layout (infoPtr, &rcClient, FALSE, TRUE);
4095 inline static LRESULT
4096 REBAR_SetRedraw (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
4097 /*****************************************************
4100 * Handles the WM_SETREDRAW message.
4103 * According to testing V4.71 of COMCTL32 returns the
4104 * *previous* status of the redraw flag (either 0 or -1)
4105 * instead of the MSDN documented value of 0 if handled
4107 *****************************************************/
4109 BOOL oldredraw = infoPtr->DoRedraw;
4111 TRACE("set to %s, fStatus=%08x\n",
4112 (wParam) ? "TRUE" : "FALSE", infoPtr->fStatus);
4113 infoPtr->DoRedraw = (BOOL) wParam;
4115 if (infoPtr->fStatus & BAND_NEEDS_REDRAW) {
4116 REBAR_MoveChildWindows (infoPtr, 0, infoPtr->uNumBands);
4117 REBAR_ForceResize (infoPtr);
4118 InvalidateRect (infoPtr->hwndSelf, 0, TRUE);
4120 infoPtr->fStatus &= ~BAND_NEEDS_REDRAW;
4122 return (oldredraw) ? -1 : 0;
4127 REBAR_Size (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
4131 /* auto resize deadlock check */
4132 if (infoPtr->fStatus & AUTO_RESIZE) {
4133 infoPtr->fStatus &= ~AUTO_RESIZE;
4134 TRACE("AUTO_RESIZE was set, reset, fStatus=%08x lparam=%08lx\n",
4135 infoPtr->fStatus, lParam);
4139 if (infoPtr->fStatus & CREATE_RUNNING) {
4140 /* still in CreateWindow */
4143 if ((INT)wParam != SIZE_RESTORED) {
4144 ERR("WM_SIZE in create and flags=%08x, lParam=%08lx\n",
4148 TRACE("still in CreateWindow\n");
4149 infoPtr->fStatus &= ~CREATE_RUNNING;
4150 GetWindowRect ( infoPtr->hwndSelf, &rcWin);
4151 TRACE("win rect (%d,%d)-(%d,%d)\n",
4152 rcWin.left, rcWin.top, rcWin.right, rcWin.bottom);
4154 if ((lParam == 0) && (rcWin.right-rcWin.left == 0) &&
4155 (rcWin.bottom-rcWin.top == 0)) {
4156 /* native control seems to do this */
4157 GetClientRect (GetParent(infoPtr->hwndSelf), &rcClient);
4158 TRACE("sizing rebar, message and client zero, parent client (%d,%d)\n",
4159 rcClient.right, rcClient.bottom);
4164 cx = rcWin.right - rcWin.left;
4165 cy = rcWin.bottom - rcWin.top;
4166 if ((cx == LOWORD(lParam)) && (cy == HIWORD(lParam))) {
4170 /* do the actual WM_SIZE request */
4171 GetClientRect (infoPtr->hwndSelf, &rcClient);
4172 TRACE("sizing rebar from (%ld,%ld) to (%d,%d), client (%d,%d)\n",
4173 infoPtr->calcSize.cx, infoPtr->calcSize.cy,
4174 LOWORD(lParam), HIWORD(lParam),
4175 rcClient.right, rcClient.bottom);
4179 if ((INT)wParam != SIZE_RESTORED) {
4180 ERR("WM_SIZE out of create and flags=%08x, lParam=%08lx\n",
4184 /* Handle cases when outside of the CreateWindow process */
4186 GetClientRect (infoPtr->hwndSelf, &rcClient);
4187 if ((lParam == 0) && (rcClient.right + rcClient.bottom != 0) &&
4188 (infoPtr->dwStyle & RBS_AUTOSIZE)) {
4189 /* on a WM_SIZE to zero and current client not zero and AUTOSIZE */
4190 /* native seems to use the current client rect for the size */
4191 infoPtr->fStatus |= BAND_NEEDS_LAYOUT;
4192 TRACE("sizing rebar to client (%d,%d) size is zero but AUTOSIZE set\n",
4193 rcClient.right, rcClient.bottom);
4196 TRACE("sizing rebar from (%ld,%ld) to (%d,%d), client (%d,%d)\n",
4197 infoPtr->calcSize.cx, infoPtr->calcSize.cy,
4198 LOWORD(lParam), HIWORD(lParam),
4199 rcClient.right, rcClient.bottom);
4203 if (infoPtr->dwStyle & RBS_AUTOSIZE) {
4204 NMRBAUTOSIZE autosize;
4206 GetClientRect(infoPtr->hwndSelf, &autosize.rcTarget);
4207 autosize.fChanged = 0; /* ??? */
4208 autosize.rcActual = autosize.rcTarget; /* ??? */
4209 REBAR_Notify((NMHDR *) &autosize, infoPtr, RBN_AUTOSIZE);
4210 TRACE("RBN_AUTOSIZE client=(%d,%d), lp=%08lx\n",
4211 autosize.rcTarget.right, autosize.rcTarget.bottom, lParam);
4214 if ((infoPtr->calcSize.cx != rcClient.right) ||
4215 (infoPtr->calcSize.cy != rcClient.bottom))
4216 infoPtr->fStatus |= BAND_NEEDS_LAYOUT;
4218 REBAR_Layout (infoPtr, &rcClient, TRUE, TRUE);
4219 infoPtr->fStatus &= ~AUTO_RESIZE;
4226 REBAR_StyleChanged (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
4228 STYLESTRUCT *ss = (STYLESTRUCT *)lParam;
4230 TRACE("current style=%08lx, styleOld=%08lx, style being set to=%08lx\n",
4231 infoPtr->dwStyle, ss->styleOld, ss->styleNew);
4232 infoPtr->dwStyle = ss->styleNew;
4239 REBAR_WindowPosChanged (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
4241 WINDOWPOS *lpwp = (WINDOWPOS *)lParam;
4245 /* Save the new origin of this window - used by _ForceResize */
4246 infoPtr->origin.x = lpwp->x;
4247 infoPtr->origin.y = lpwp->y;
4248 ret = DefWindowProcA(infoPtr->hwndSelf, WM_WINDOWPOSCHANGED,
4250 GetWindowRect(infoPtr->hwndSelf, &rc);
4251 TRACE("hwnd %p new pos (%d,%d)-(%d,%d)\n",
4252 infoPtr->hwndSelf, rc.left, rc.top, rc.right, rc.bottom);
4257 static LRESULT WINAPI
4258 REBAR_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
4260 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
4262 TRACE("hwnd=%p msg=%x wparam=%x lparam=%lx\n",
4263 hwnd, uMsg, wParam, lParam);
4264 if (!infoPtr && (uMsg != WM_NCCREATE))
4265 return DefWindowProcA (hwnd, uMsg, wParam, lParam);
4268 /* case RB_BEGINDRAG: */
4271 return REBAR_DeleteBand (infoPtr, wParam, lParam);
4273 /* case RB_DRAGMOVE: */
4274 /* case RB_ENDDRAG: */
4276 case RB_GETBANDBORDERS:
4277 return REBAR_GetBandBorders (infoPtr, wParam, lParam);
4279 case RB_GETBANDCOUNT:
4280 return REBAR_GetBandCount (infoPtr);
4282 case RB_GETBANDINFO: /* obsoleted after IE3, but we have to
4283 support it anyway. */
4284 case RB_GETBANDINFOA:
4285 return REBAR_GetBandInfoA (infoPtr, wParam, lParam);
4287 case RB_GETBANDINFOW:
4288 return REBAR_GetBandInfoW (infoPtr, wParam, lParam);
4290 case RB_GETBARHEIGHT:
4291 return REBAR_GetBarHeight (infoPtr, wParam, lParam);
4294 return REBAR_GetBarInfo (infoPtr, wParam, lParam);
4297 return REBAR_GetBkColor (infoPtr);
4299 /* case RB_GETCOLORSCHEME: */
4300 /* case RB_GETDROPTARGET: */
4303 return REBAR_GetPalette (infoPtr, wParam, lParam);
4306 return REBAR_GetRect (infoPtr, wParam, lParam);
4308 case RB_GETROWCOUNT:
4309 return REBAR_GetRowCount (infoPtr);
4311 case RB_GETROWHEIGHT:
4312 return REBAR_GetRowHeight (infoPtr, wParam, lParam);
4314 case RB_GETTEXTCOLOR:
4315 return REBAR_GetTextColor (infoPtr);
4317 case RB_GETTOOLTIPS:
4318 return REBAR_GetToolTips (infoPtr);
4320 case RB_GETUNICODEFORMAT:
4321 return REBAR_GetUnicodeFormat (infoPtr);
4323 case CCM_GETVERSION:
4324 return REBAR_GetVersion (infoPtr);
4327 return REBAR_HitTest (infoPtr, wParam, lParam);
4330 return REBAR_IdToIndex (infoPtr, wParam, lParam);
4332 case RB_INSERTBANDA:
4333 return REBAR_InsertBandA (infoPtr, wParam, lParam);
4335 case RB_INSERTBANDW:
4336 return REBAR_InsertBandW (infoPtr, wParam, lParam);
4338 case RB_MAXIMIZEBAND:
4339 return REBAR_MaximizeBand (infoPtr, wParam, lParam);
4341 case RB_MINIMIZEBAND:
4342 return REBAR_MinimizeBand (infoPtr, wParam, lParam);
4345 return REBAR_MoveBand (infoPtr, wParam, lParam);
4347 case RB_SETBANDINFOA:
4348 return REBAR_SetBandInfoA (infoPtr, wParam, lParam);
4350 case RB_SETBANDINFOW:
4351 return REBAR_SetBandInfoW (infoPtr, wParam, lParam);
4354 return REBAR_SetBarInfo (infoPtr, wParam, lParam);
4357 return REBAR_SetBkColor (infoPtr, wParam, lParam);
4359 /* case RB_SETCOLORSCHEME: */
4360 /* case RB_SETPALETTE: */
4361 /* return REBAR_GetPalette (infoPtr, wParam, lParam); */
4364 return REBAR_SetParent (infoPtr, wParam, lParam);
4366 case RB_SETTEXTCOLOR:
4367 return REBAR_SetTextColor (infoPtr, wParam, lParam);
4369 /* case RB_SETTOOLTIPS: */
4371 case RB_SETUNICODEFORMAT:
4372 return REBAR_SetUnicodeFormat (infoPtr, wParam);
4374 case CCM_SETVERSION:
4375 return REBAR_SetVersion (infoPtr, (INT)wParam);
4378 return REBAR_ShowBand (infoPtr, wParam, lParam);
4381 return REBAR_SizeToRect (infoPtr, wParam, lParam);
4384 /* Messages passed to parent */
4388 if (infoPtr->NtfUnicode)
4389 return SendMessageW (REBAR_GetNotifyParent (infoPtr),
4390 uMsg, wParam, lParam);
4392 return SendMessageA (REBAR_GetNotifyParent (infoPtr),
4393 uMsg, wParam, lParam);
4396 /* case WM_CHARTOITEM: supported according to ControlSpy */
4399 return REBAR_Create (infoPtr, wParam, lParam);
4402 return REBAR_Destroy (infoPtr, wParam, lParam);
4405 return REBAR_EraseBkGnd (infoPtr, wParam, lParam);
4408 return REBAR_GetFont (infoPtr, wParam, lParam);
4410 /* case WM_LBUTTONDBLCLK: supported according to ControlSpy */
4412 case WM_LBUTTONDOWN:
4413 return REBAR_LButtonDown (infoPtr, wParam, lParam);
4416 return REBAR_LButtonUp (infoPtr, wParam, lParam);
4418 /* case WM_MEASUREITEM: supported according to ControlSpy */
4421 return REBAR_MouseMove (infoPtr, wParam, lParam);
4424 return REBAR_NCCalcSize (infoPtr, wParam, lParam);
4427 return REBAR_NCCreate (hwnd, wParam, lParam);
4430 return REBAR_NCHitTest (infoPtr, wParam, lParam);
4433 return REBAR_NCPaint (infoPtr, wParam, lParam);
4435 case WM_NOTIFYFORMAT:
4436 return REBAR_NotifyFormat (infoPtr, wParam, lParam);
4439 return REBAR_Paint (infoPtr, wParam, lParam);
4441 /* case WM_PALETTECHANGED: supported according to ControlSpy */
4442 /* case WM_PRINTCLIENT: supported according to ControlSpy */
4443 /* case WM_QUERYNEWPALETTE:supported according to ControlSpy */
4444 /* case WM_RBUTTONDOWN: supported according to ControlSpy */
4445 /* case WM_RBUTTONUP: supported according to ControlSpy */
4448 return REBAR_SetCursor (infoPtr, wParam, lParam);
4451 return REBAR_SetFont (infoPtr, wParam, lParam);
4454 return REBAR_SetRedraw (infoPtr, wParam, lParam);
4457 return REBAR_Size (infoPtr, wParam, lParam);
4459 case WM_STYLECHANGED:
4460 return REBAR_StyleChanged (infoPtr, wParam, lParam);
4462 /* case WM_SYSCOLORCHANGE: supported according to ControlSpy */
4463 /* "Applications that have brushes using the existing system colors
4464 should delete those brushes and recreate them using the new
4465 system colors." per MSDN */
4467 /* case WM_VKEYTOITEM: supported according to ControlSpy */
4468 /* case WM_WININICHANGE: */
4470 case WM_WINDOWPOSCHANGED:
4471 return REBAR_WindowPosChanged (infoPtr, wParam, lParam);
4474 if ((uMsg >= WM_USER) && (uMsg < WM_APP))
4475 ERR("unknown msg %04x wp=%08x lp=%08lx\n",
4476 uMsg, wParam, lParam);
4477 return DefWindowProcA (hwnd, uMsg, wParam, lParam);
4484 REBAR_Register (void)
4488 ZeroMemory (&wndClass, sizeof(WNDCLASSA));
4489 wndClass.style = CS_GLOBALCLASS | CS_DBLCLKS;
4490 wndClass.lpfnWndProc = (WNDPROC)REBAR_WindowProc;
4491 wndClass.cbClsExtra = 0;
4492 wndClass.cbWndExtra = sizeof(REBAR_INFO *);
4493 wndClass.hCursor = 0;
4494 wndClass.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1);
4496 wndClass.hbrBackground = CreateSolidBrush(RGB(0,128,0));
4498 wndClass.lpszClassName = REBARCLASSNAMEA;
4500 RegisterClassA (&wndClass);
4502 mindragx = GetSystemMetrics (SM_CXDRAG);
4503 mindragy = GetSystemMetrics (SM_CYDRAG);
4509 REBAR_Unregister (void)
4511 UnregisterClassA (REBARCLASSNAMEA, NULL);