3 * 2. At "FIXME: problem # 2" WinRAR:
4 * if "#if 1" then last band draws in separate row
5 * if "#if 0" then last band draws in previous row *** just like native ***
11 * Rebar control rev 7e
13 * Copyright 1998, 1999 Eric Kohl
16 * An author is needed! Any volunteers?
17 * I will only improve this control once in a while.
18 * Eric <ekohl@abo.rhein-zeitung.de>
21 * - vertical placement
22 * - ComboBox and ComboBoxEx placement
27 * - All notifications.
29 * Changes Guy Albertelli <galberte@neo.lrun.com>
31 * - Implement initial version of row grouping, row separators,
32 * text and background colors. Support additional messages.
33 * Support RBBS_BREAK. Implement ERASEBKGND and improve painting.
35 * - implement support for dragging Gripper left or right in a row. Supports
36 * WM_LBUTTONDOWN, WM_LBUTTONUP, and WM_MOUSEMOVE. Also support
39 * - Fix or implement notifications for RBN_HEIGHTCHANGE, RBN_CHILDSIZE.
40 * - Correct styles RBBS_NOGRIPPER, RBBS_GRIPPERALWAYS, and RBBS_FIXEDSIZE.
41 * - Fix algorithm for Layout and AdjustBand.
44 * 1. Redesign _Layout to better emulate native.
45 * a. Flag rebar when a band needs to be (and all bands) need to
46 * go through rest of _Layout
47 * 2. Fix RBN_ENDDRAG contents.
48 * 3. REBAR_ForceResize changed to handle shrink of client.
50 * 4. Support RBBS_HIDDEN in _Layout (phase 2 & 3), _InternalEraseBkgnd,
51 * and _InternalHitTest
52 * 5. Support RBS_VARHEIGHT.
53 * 6. Rewrite _AdjustBands with new algorithm.
55 * 7. Format mask and style with labels.
56 * 8. Move calls to _ForceResize and _MoveChildWindows into _Layout to
57 * centralize processing.
58 * 9. Pass "infoPtr" to all routines instead of "hwnd" to eliminate extra
59 * calls to GetWindowLongA.
60 * 10. Use _MoveChildWindows in _HandleLRDrag.
61 * 11. Another rewrite of _AdjustBands with new algorithm.
62 * 12. Correct drawing of rebar borders and handling of RBS_BORDERS.
64 * 13. Support WM_NOTIFYFORMAT (both incoming and outgoing) and do
65 * WM_NOTIFY correctly based on results.
66 * 14. Implement WM_SETREDRAW.
67 * 15. Native WM_ERASEBKGND draws horz and vert separators between bands and
68 * rows, and fills in the background color for each band. The gripper,
69 * image, and text for each band is drawn by the WM_PAINT process. Change
72 * 16. RBBS_FIXEDSIZE should not affect _AdjustBands. (Found by Mike McCormack
73 * in WinZip - Thanks!)
74 * 17. Implement WM_NCCREATE to set necessary additional styles and move most
75 * of creation stuff to it like native control.
76 * 18. WM_SETFONT should redraw only if LOWORD is TRUE.
77 * 19. Implement WM_NCHITTEST to send notify to parent of NM_NCHITTEST.
78 * 20. Cleaned up dead and/or testing code.
79 * 21. Support RB_MOVEBAND.
80 * 22. Support WM_STYLECHANGED and remove all (or most) of the GetWindowLong
82 * 23. Support RB_MINIMIZEBAND.
83 * 24. RBBS_HIDDEN (and the CCS_VERT+RBBS_NOVERT case) should be supported
84 * by all routines now.
88 * 2. Following still not handled: RBBS_FIXEDBMP, RBBS_CHILDEDGE,
90 * 5. Native uses (on each draw!!) SM_CYBORDER (or SM_CXBORDER for CCS_VERT)
91 * to set the size of the separator width (the value SEP_WIDTH_SIZE
92 * in here). Should be fixed!!
93 * 6. The following messages are not implemented:
94 * RB_BEGINDRAG, RB_DRAGMOVE, RB_ENDDRAG, RB_GETCOLORSCHEME,
95 * RB_GETDROPTARGET, RB_MAXIMIZEBAND,
96 * RB_SETCOLORSCHEME, RB_SETPALETTE, RB_SETTOOLTIPS
97 * WM_CHARTOITEM, WM_LBUTTONDBLCLK, WM_MEASUREITEM,
98 * WM_PALETTECHANGED, WM_PRINTCLIENT, WM_QUERYNEWPALETTE,
99 * WM_RBUTTONDOWN, WM_RBUTTONUP,
100 * WM_SYSCOLORCHANGE, WM_VKEYTOITEM, WM_WININICHANGE
101 * 7. The following notifications are not implemented:
102 * NM_CUSTOMDRAW, NM_RELEASEDCAPTURE
103 * RB_CHEVRONPUSHED, RBN_MINMAX
111 #include "wine/unicode.h"
112 #include "commctrl.h"
113 /* #include "spy.h" */
114 #include "debugtools.h"
116 DEFAULT_DEBUG_CHANNEL(rebar);
126 UINT cxMinChild; /* valid if _CHILDSIZE */
127 UINT cyMinChild; /* valid if _CHILDSIZE */
128 UINT cx; /* valid if _SIZE */
131 UINT cyChild; /* valid if _CHILDSIZE */
132 UINT cyMaxChild; /* valid if _CHILDSIZE */
133 UINT cyIntegral; /* valid if _CHILDSIZE */
138 UINT lcx; /* minimum cx for band */
139 UINT ccx; /* current cx for band */
140 UINT hcx; /* maximum cx for band */
141 UINT lcy; /* minimum cy for band */
142 UINT ccy; /* current cy for band */
143 UINT hcy; /* maximum cy for band */
145 SIZE offChild; /* x,y offset if child is not FIXEDSIZE */
147 INT iRow; /* row this band assigned to */
148 UINT fStatus; /* status flags, reset only by _Validate */
149 UINT fDraw; /* drawing flags, reset only by _Layout */
150 RECT rcoldBand; /* previous calculated band rectangle */
151 RECT rcBand; /* calculated band rectangle */
152 RECT rcGripper; /* calculated gripper rectangle */
153 RECT rcCapImage; /* calculated caption image rectangle */
154 RECT rcCapText; /* calculated caption text rectangle */
155 RECT rcChild; /* calculated child rectangle */
162 #define HAS_GRIPPER 0x00000001
163 #define HAS_IMAGE 0x00000002
164 #define HAS_TEXT 0x00000004
167 #define DRAW_GRIPPER 0x00000001
168 #define DRAW_IMAGE 0x00000002
169 #define DRAW_TEXT 0x00000004
170 #define DRAW_RIGHTSEP 0x00000010
171 #define DRAW_BOTTOMSEP 0x00000020
172 #define NTF_INVALIDATE 0x01000000
177 COLORREF clrBk; /* background color */
178 COLORREF clrText; /* text color */
179 COLORREF clrBtnFace; /* system color for BTNFACE */
180 HIMAGELIST himl; /* handle to imagelist */
181 UINT uNumBands; /* # of bands in rebar (first=0, last=uNumRows-1 */
182 UINT uNumRows; /* # of rows of bands (first=1, last=uNumRows */
183 HWND hwndSelf; /* handle of REBAR window itself */
184 HWND hwndToolTip; /* handle to the tool tip control */
185 HWND hwndNotify; /* notification window (parent) */
186 HFONT hFont; /* handle to the rebar's font */
187 SIZE imageSize; /* image size (image list) */
188 DWORD dwStyle; /* window style */
189 SIZE calcSize; /* calculated rebar size */
190 SIZE oldSize; /* previous calculated rebar size */
191 BOOL bUnicode; /* TRUE if this window is W type */
192 BOOL NtfUnicode; /* TRUE if parent wants notify in W format */
193 BOOL DoRedraw; /* TRUE to acutally draw bands */
194 UINT fStatus; /* Status flags (see below) */
195 HCURSOR hcurArrow; /* handle to the arrow cursor */
196 HCURSOR hcurHorz; /* handle to the EW cursor */
197 HCURSOR hcurVert; /* handle to the NS cursor */
198 HCURSOR hcurDrag; /* handle to the drag cursor */
199 INT iVersion; /* version number */
200 POINTS dragStart; /* x,y of button down */
201 POINTS dragNow; /* x,y of this MouseMove */
202 INT ihitBand; /* band number of band whose gripper was grabbed */
203 INT ihitoffset; /* offset of hotspot from gripper.left */
205 REBAR_BAND *bands; /* pointer to the array of rebar bands */
209 #define BEGIN_DRAG_ISSUED 0x00000001
210 #define AUTO_RESIZE 0x00000002
211 #define RESIZE_ANYHOW 0x00000004
212 #define NTF_HGHTCHG 0x00000008
213 #define BAND_NEEDS_LAYOUT 0x00000010
215 /* ---- REBAR layout constants. Mostly determined by ---- */
216 /* ---- experiment on WIN 98. ---- */
218 /* Width (or height) of separators between bands (either horz. or */
219 /* vert.). True only if RBS_BANDBORDERS is set */
220 #define SEP_WIDTH_SIZE 2
221 #define SEP_WIDTH ((infoPtr->dwStyle & RBS_BANDBORDERS) ? SEP_WIDTH_SIZE : 0)
223 /* Blank (background color) space between Gripper (if present) */
224 /* and next item (image, text, or window). Always present */
225 #define REBAR_ALWAYS_SPACE 4
227 /* Blank (background color) space after Image (if present). */
228 #define REBAR_POST_IMAGE 2
230 /* Blank (background color) space after Text (if present). */
231 #define REBAR_POST_TEXT 4
233 /* Height of vertical gripper in a CCS_VERT rebar. */
234 #define GRIPPER_HEIGHT 16
236 /* Blank (background color) space before Gripper (if present). */
237 #define REBAR_PRE_GRIPPER 2
239 /* Width (of normal vertical gripper) or height (of horz. gripper) */
241 #define GRIPPER_WIDTH 3
243 /* This is the increment that is used over the band height */
244 /* Determined by experiment. */
247 /* ---- End of REBAR layout constants. ---- */
250 /* The following 6 defines return the proper rcBand element */
251 /* depending on whether CCS_VERT was set. */
252 #define rcBlt(b) ((infoPtr->dwStyle & CCS_VERT) ? b->rcBand.top : b->rcBand.left)
253 #define rcBrb(b) ((infoPtr->dwStyle & CCS_VERT) ? b->rcBand.bottom : b->rcBand.right)
254 #define rcBw(b) ((infoPtr->dwStyle & CCS_VERT) ? (b->rcBand.bottom - b->rcBand.top) : \
255 (b->rcBand.right - b->rcBand.left))
256 #define ircBlt(b) ((infoPtr->dwStyle & CCS_VERT) ? b->rcBand.left : b->rcBand.top)
257 #define ircBrb(b) ((infoPtr->dwStyle & CCS_VERT) ? b->rcBand.right : b->rcBand.bottom)
258 #define ircBw(b) ((infoPtr->dwStyle & CCS_VERT) ? (b->rcBand.right - b->rcBand.left) : \
259 (b->rcBand.bottom - b->rcBand.top))
261 /* The following define determines if a given band is hidden */
262 #define HIDDENBAND(a) (((a)->fStyle & RBBS_HIDDEN) || \
263 ((infoPtr->dwStyle & CCS_VERT) && \
264 ((a)->fStyle & RBBS_NOVERT)))
266 /* The following defines adjust the right or left end of a rectangle */
267 #define READJ(b,i) {if(infoPtr->dwStyle & CCS_VERT) b->rcBand.bottom+=(i); \
268 else b->rcBand.right += (i);}
269 #define LEADJ(b,i) {if(infoPtr->dwStyle & CCS_VERT) b->rcBand.top+=(i); \
270 else b->rcBand.left += (i);}
273 #define REBAR_GetInfoPtr(wndPtr) ((REBAR_INFO *)GetWindowLongA (hwnd, 0))
276 /* "constant values" retrieved when DLL was initialized */
277 /* FIXME we do this when the classes are registered. */
278 static UINT mindragx = 0;
279 static UINT mindragy = 0;
281 static char *band_stylename[] = {
282 "RBBS_BREAK", /* 0001 */
283 "RBBS_FIXEDSIZE", /* 0002 */
284 "RBBS_CHILDEDGE", /* 0004 */
285 "RBBS_HIDDEN", /* 0008 */
286 "RBBS_NOVERT", /* 0010 */
287 "RBBS_FIXEDBMP", /* 0020 */
288 "RBBS_VARIABLEHEIGHT", /* 0040 */
289 "RBBS_GRIPPERALWAYS", /* 0080 */
290 "RBBS_NOGRIPPER", /* 0100 */
293 static char *band_maskname[] = {
294 "RBBIM_STYLE", /* 0x00000001 */
295 "RBBIM_COLORS", /* 0x00000002 */
296 "RBBIM_TEXT", /* 0x00000004 */
297 "RBBIM_IMAGE", /* 0x00000008 */
298 "RBBIM_CHILD", /* 0x00000010 */
299 "RBBIM_CHILDSIZE", /* 0x00000020 */
300 "RBBIM_SIZE", /* 0x00000040 */
301 "RBBIM_BACKGROUND", /* 0x00000080 */
302 "RBBIM_ID", /* 0x00000100 */
303 "RBBIM_IDEALSIZE", /* 0x00000200 */
304 "RBBIM_LPARAM", /* 0x00000400 */
305 "RBBIM_HEADERSIZE", /* 0x00000800 */
309 static CHAR line[200];
313 REBAR_FmtStyle( UINT style)
318 while (band_stylename[i]) {
319 if (style & (1<<i)) {
320 if (*line != 0) strcat(line, " | ");
321 strcat(line, band_stylename[i]);
330 REBAR_FmtMask( UINT mask)
335 while (band_maskname[i]) {
337 if (*line != 0) strcat(line, " | ");
338 strcat(line, band_maskname[i]);
347 REBAR_DumpBandInfo( LPREBARBANDINFOA pB)
349 if( !TRACE_ON(rebar) ) return;
350 TRACE("band info: ID=%u, size=%u, child=%04x, clrF=0x%06lx, clrB=0x%06lx\n",
351 pB->wID, pB->cbSize, pB->hwndChild, pB->clrFore, pB->clrBack);
352 TRACE("band info: mask=0x%08x (%s)\n", pB->fMask, REBAR_FmtMask(pB->fMask));
353 if (pB->fMask & RBBIM_STYLE)
354 TRACE("band info: style=0x%08x (%s)\n", pB->fStyle, REBAR_FmtStyle(pB->fStyle));
355 if (pB->fMask & (RBBIM_SIZE | RBBIM_IDEALSIZE | RBBIM_HEADERSIZE | RBBIM_LPARAM )) {
357 if (pB->fMask & RBBIM_SIZE)
358 DPRINTF(" cx=%u", pB->cx);
359 if (pB->fMask & RBBIM_IDEALSIZE)
360 DPRINTF(" xIdeal=%u", pB->cxIdeal);
361 if (pB->fMask & RBBIM_HEADERSIZE)
362 DPRINTF(" xHeader=%u", pB->cxHeader);
363 if (pB->fMask & RBBIM_LPARAM)
364 DPRINTF(" lParam=0x%08lx", pB->lParam);
367 if (pB->fMask & RBBIM_CHILDSIZE)
368 TRACE("band info: xMin=%u, yMin=%u, yChild=%u, yMax=%u, yIntgl=%u\n",
370 pB->cyMinChild, pB->cyChild, pB->cyMaxChild, pB->cyIntegral);
374 REBAR_DumpBand (REBAR_INFO *iP)
379 if(! TRACE_ON(rebar) ) return;
381 TRACE("hwnd=%04x: color=%08lx/%08lx, bands=%u, rows=%u, cSize=%ld,%ld\n",
382 iP->hwndSelf, iP->clrText, iP->clrBk, iP->uNumBands, iP->uNumRows,
383 iP->calcSize.cx, iP->calcSize.cy);
384 TRACE("hwnd=%04x: flags=%08x, dragStart=%d,%d, dragNow=%d,%d, ihitBand=%d\n",
385 iP->hwndSelf, iP->fStatus, iP->dragStart.x, iP->dragStart.y,
386 iP->dragNow.x, iP->dragNow.y,
388 for (i = 0; i < iP->uNumBands; i++) {
390 TRACE("band # %u: ID=%u, child=%04x, row=%u, clrF=0x%06lx, clrB=0x%06lx\n",
391 i, pB->wID, pB->hwndChild, pB->iRow, pB->clrFore, pB->clrBack);
392 TRACE("band # %u: mask=0x%08x (%s)\n", i, pB->fMask, REBAR_FmtMask(pB->fMask));
393 if (pB->fMask & RBBIM_STYLE)
394 TRACE("band # %u: style=0x%08x (%s)\n",
395 i, pB->fStyle, REBAR_FmtStyle(pB->fStyle));
396 TRACE("band # %u: uMinH=%u xHeader=%u",
397 i, pB->uMinHeight, pB->cxHeader);
398 if (pB->fMask & (RBBIM_SIZE | RBBIM_IDEALSIZE | RBBIM_LPARAM )) {
399 if (pB->fMask & RBBIM_SIZE)
400 DPRINTF(" cx=%u", pB->cx);
401 if (pB->fMask & RBBIM_IDEALSIZE)
402 DPRINTF(" xIdeal=%u", pB->cxIdeal);
403 if (pB->fMask & RBBIM_LPARAM)
404 DPRINTF(" lParam=0x%08lx", pB->lParam);
408 TRACE("band # %u: xMin=%u, yMin=%u, yChild=%u, yMax=%u, yIntgl=%u\n",
409 i, pB->cxMinChild, pB->cyMinChild, pB->cyChild, pB->cyMaxChild, pB->cyIntegral);
410 TRACE("band # %u: lcx=%u, ccx=%u, hcx=%u, lcy=%u, ccy=%u, hcy=%u, offChild=%ld,%ld\n",
411 i, pB->lcx, pB->ccx, pB->hcx, pB->lcy, pB->ccy, pB->hcy, pB->offChild.cx, pB->offChild.cy);
412 TRACE("band # %u: fStatus=%08x, fDraw=%08x, Band=(%d,%d)-(%d,%d), Grip=(%d,%d)-(%d,%d)\n",
413 i, pB->fStatus, pB->fDraw,
414 pB->rcBand.left, pB->rcBand.top, pB->rcBand.right, pB->rcBand.bottom,
415 pB->rcGripper.left, pB->rcGripper.top, pB->rcGripper.right, pB->rcGripper.bottom);
416 TRACE("band # %u: Img=(%d,%d)-(%d,%d), Txt=(%d,%d)-(%d,%d), Child=(%d,%d)-(%d,%d)\n",
418 pB->rcCapImage.left, pB->rcCapImage.top, pB->rcCapImage.right, pB->rcCapImage.bottom,
419 pB->rcCapText.left, pB->rcCapText.top, pB->rcCapText.right, pB->rcCapText.bottom,
420 pB->rcChild.left, pB->rcChild.top, pB->rcChild.right, pB->rcChild.bottom);
427 REBAR_GetNotifyParent (REBAR_INFO *infoPtr)
431 parent = infoPtr->hwndNotify;
433 parent = GetParent (infoPtr->hwndSelf);
434 owner = GetWindow (infoPtr->hwndSelf, GW_OWNER);
435 if (owner) parent = owner;
442 REBAR_Notify (NMHDR *nmhdr, REBAR_INFO *infoPtr, UINT code)
446 parent = REBAR_GetNotifyParent (infoPtr);
447 nmhdr->idFrom = GetDlgCtrlID (infoPtr->hwndSelf);
448 nmhdr->hwndFrom = infoPtr->hwndSelf;
451 TRACE("window %04x, code=%08x, %s\n", parent, code,
452 (infoPtr->NtfUnicode) ? "via Unicode" : "via ANSI");
454 if (infoPtr->NtfUnicode)
455 return SendMessageW (parent, WM_NOTIFY, (WPARAM) nmhdr->idFrom,
458 return SendMessageA (parent, WM_NOTIFY, (WPARAM) nmhdr->idFrom,
463 REBAR_Notify_NMREBAR (REBAR_INFO *infoPtr, UINT uBand, UINT code)
465 NMREBAR notify_rebar;
468 notify_rebar.dwMask = 0;
470 lpBand = &infoPtr->bands[uBand];
471 if (lpBand->fMask & RBBIM_ID) {
472 notify_rebar.dwMask |= RBNM_ID;
473 notify_rebar.wID = lpBand->wID;
475 if (lpBand->fMask & RBBIM_LPARAM) {
476 notify_rebar.dwMask |= RBNM_LPARAM;
477 notify_rebar.lParam = lpBand->lParam;
479 if (lpBand->fMask & RBBIM_STYLE) {
480 notify_rebar.dwMask |= RBNM_STYLE;
481 notify_rebar.fStyle = lpBand->fStyle;
484 notify_rebar.uBand = uBand;
485 return REBAR_Notify ((NMHDR *)¬ify_rebar, infoPtr, code);
489 REBAR_DrawBand (HDC hdc, REBAR_INFO *infoPtr, REBAR_BAND *lpBand)
494 if (lpBand->fDraw & DRAW_GRIPPER)
495 DrawEdge (hdc, &lpBand->rcGripper, BDR_RAISEDINNER, BF_RECT | BF_MIDDLE);
497 /* draw caption image */
498 if (lpBand->fDraw & DRAW_IMAGE) {
502 pt.y = (lpBand->rcCapImage.bottom + lpBand->rcCapImage.top - infoPtr->imageSize.cy)/2;
503 pt.x = (lpBand->rcCapImage.right + lpBand->rcCapImage.left - infoPtr->imageSize.cx)/2;
505 ImageList_Draw (infoPtr->himl, lpBand->iImage, hdc,
510 /* draw caption text */
511 if (lpBand->fDraw & DRAW_TEXT) {
512 HFONT hOldFont = SelectObject (hdc, infoPtr->hFont);
513 INT oldBkMode = SetBkMode (hdc, TRANSPARENT);
514 COLORREF oldcolor = CLR_NONE;
515 if (lpBand->clrFore != CLR_NONE)
516 oldcolor = SetTextColor (hdc, lpBand->clrFore);
517 DrawTextW (hdc, lpBand->lpText, -1, &lpBand->rcCapText,
518 DT_CENTER | DT_VCENTER | DT_SINGLELINE);
519 if (oldBkMode != TRANSPARENT)
520 SetBkMode (hdc, oldBkMode);
521 if (lpBand->clrFore != CLR_NONE)
522 SetTextColor (hdc, oldcolor);
523 SelectObject (hdc, hOldFont);
529 REBAR_Refresh (REBAR_INFO *infoPtr, HDC hdc)
534 if (!infoPtr->DoRedraw) return;
536 oldrow = infoPtr->bands[0].iRow;
537 for (i = 0; i < infoPtr->uNumBands; i++) {
538 lpBand = &infoPtr->bands[i];
540 if (HIDDENBAND(lpBand)) continue;
542 /* now draw the band */
543 REBAR_DrawBand (hdc, infoPtr, lpBand);
550 REBAR_FixVert (REBAR_INFO *infoPtr, UINT rowstart, UINT rowend,
553 /* Cycle through bands in row and fix height of each band. */
554 /* Also determine whether each band has changed. */
556 /* all bands at desired size. */
557 /* start and end bands are *not* hidden */
562 for (i = (INT)rowstart; i<=(INT)rowend; i++) {
563 lpBand = &infoPtr->bands[i];
564 if (HIDDENBAND(lpBand)) continue;
566 /* adjust height of bands in row to "mcy" value */
567 if (infoPtr->dwStyle & CCS_VERT) {
568 if (lpBand->rcBand.right != lpBand->rcBand.left + mcy)
569 lpBand->rcBand.right = lpBand->rcBand.left + mcy;
572 if (lpBand->rcBand.bottom != lpBand->rcBand.top + mcy)
573 lpBand->rcBand.bottom = lpBand->rcBand.top + mcy;
577 /* mark whether we need to invalidate this band and trace */
578 if ((lpBand->rcoldBand.left !=lpBand->rcBand.left) ||
579 (lpBand->rcoldBand.top !=lpBand->rcBand.top) ||
580 (lpBand->rcoldBand.right !=lpBand->rcBand.right) ||
581 (lpBand->rcoldBand.bottom !=lpBand->rcBand.bottom)) {
582 lpBand->fDraw |= NTF_INVALIDATE;
583 TRACE("band %d row=%d: changed to (%d,%d)-(%d,%d) from (%d,%d)-(%d,%d)\n",
585 lpBand->rcBand.left, lpBand->rcBand.top,
586 lpBand->rcBand.right, lpBand->rcBand.bottom,
587 lpBand->rcoldBand.left, lpBand->rcoldBand.top,
588 lpBand->rcoldBand.right, lpBand->rcoldBand.bottom);
591 TRACE("band %d row=%d: unchanged (%d,%d)-(%d,%d)\n",
593 lpBand->rcBand.left, lpBand->rcBand.top,
594 lpBand->rcBand.right, lpBand->rcBand.bottom);
600 REBAR_AdjustBands (REBAR_INFO *infoPtr, UINT rowstart, UINT rowend,
602 /* Function: This routine distributes the extra space in a row. */
603 /* See algorithm below. */
605 /* all bands @ ->cxHeader size */
606 /* start and end bands are *not* hidden */
609 UINT x, xsep, extra, curwidth, fudge;
610 INT i, last_adjusted;
612 TRACE("start=%u, end=%u, max x=%d, max y=%d\n",
613 rowstart, rowend, maxx, mcy);
615 /* ******************* Phase 1 ************************ */
617 /* For each visible band with valid child */
618 /* a. inflate band till either all extra space used */
619 /* or band's ->ccx reached. */
620 /* If any band modified, add any space left to last band */
623 /* ****************************************************** */
624 lpBand = &infoPtr->bands[rowend];
625 extra = maxx - rcBrb(lpBand);
628 for (i=(INT)rowstart; i<=(INT)rowend; i++) {
629 lpBand = &infoPtr->bands[i];
630 if (HIDDENBAND(lpBand)) continue;
631 xsep = (x == 0) ? 0 : SEP_WIDTH;
632 curwidth = rcBw(lpBand);
634 /* set new left/top point */
635 if (infoPtr->dwStyle & CCS_VERT)
636 lpBand->rcBand.top = x + xsep;
638 lpBand->rcBand.left = x + xsep;
640 /* compute new width */
641 if (lpBand->hwndChild && extra) {
642 /* set to the "current" band size less the header */
645 if ((lpBand->fMask & RBBIM_SIZE) && (lpBand->cx > 0) &&
646 (fudge > curwidth)) {
647 TRACE("adjusting band %d by %d, fudge=%d, curwidth=%d, extra=%d\n",
648 i, fudge-curwidth, fudge, curwidth, extra);
649 if ((fudge - curwidth) > extra)
650 fudge = curwidth + extra;
651 extra -= (fudge - curwidth);
655 TRACE("adjusting band %d by %d, fudge=%d, curwidth=%d\n",
656 i, extra, fudge, curwidth);
662 /* set new right/bottom point */
663 if (infoPtr->dwStyle & CCS_VERT)
664 lpBand->rcBand.bottom = lpBand->rcBand.top + curwidth;
666 lpBand->rcBand.right = lpBand->rcBand.left + curwidth;
667 TRACE("Phase 1 band %d, (%d,%d)-(%d,%d), orig x=%d, xsep=%d\n",
668 i, lpBand->rcBand.left, lpBand->rcBand.top,
669 lpBand->rcBand.right, lpBand->rcBand.bottom, x, xsep);
672 if ((x >= maxx) || last_adjusted) {
674 ERR("Phase 1 failed, x=%d, maxx=%d\n", x, maxx);
676 /* done, so spread extra space */
679 TRACE("Need to spread %d on last adjusted band %d\n",
680 fudge, last_adjusted);
681 for (i=(INT)last_adjusted; i<=(INT)rowend; i++) {
682 lpBand = &infoPtr->bands[i];
683 if (HIDDENBAND(lpBand)) continue;
685 /* set right/bottom point */
686 if (i != last_adjusted) {
687 if (infoPtr->dwStyle & CCS_VERT)
688 lpBand->rcBand.top += fudge;
690 lpBand->rcBand.left += fudge;
693 /* set left/bottom point */
694 if (infoPtr->dwStyle & CCS_VERT)
695 lpBand->rcBand.bottom += fudge;
697 lpBand->rcBand.right += fudge;
700 TRACE("Phase 1 succeeded, used x=%d\n", x);
701 REBAR_FixVert (infoPtr, rowstart, rowend, mcy);
705 /* ******************* Phase 2 ************************ */
707 /* Find first visible band, put all */
708 /* extra space there. */
710 /* ****************************************************** */
713 for (i=(INT)rowstart; i<=(INT)rowend; i++) {
714 lpBand = &infoPtr->bands[i];
715 if (HIDDENBAND(lpBand)) continue;
716 xsep = (x == 0) ? 0 : SEP_WIDTH;
717 curwidth = rcBw(lpBand);
719 /* set new left/top point */
720 if (infoPtr->dwStyle & CCS_VERT)
721 lpBand->rcBand.top = x + xsep;
723 lpBand->rcBand.left = x + xsep;
725 /* compute new width */
731 /* set new right/bottom point */
732 if (infoPtr->dwStyle & CCS_VERT)
733 lpBand->rcBand.bottom = lpBand->rcBand.top + curwidth;
735 lpBand->rcBand.right = lpBand->rcBand.left + curwidth;
736 TRACE("Phase 2 band %d, (%d,%d)-(%d,%d), orig x=%d, xsep=%d\n",
737 i, lpBand->rcBand.left, lpBand->rcBand.top,
738 lpBand->rcBand.right, lpBand->rcBand.bottom, x, xsep);
743 ERR("Phase 2 failed, x=%d, maxx=%d\n", x, maxx);
745 /* done, so spread extra space */
746 TRACE("Phase 2 succeeded, used x=%d\n", x);
747 REBAR_FixVert (infoPtr, rowstart, rowend, mcy);
751 /* ******************* Phase 3 ************************ */
752 /* at this point everything is back to ->cxHeader values */
753 /* and should not have gotten here. */
754 /* ****************************************************** */
756 lpBand = &infoPtr->bands[rowstart];
757 ERR("Serious problem adjusting row %d, start band %d, end band %d\n",
758 lpBand->iRow, rowstart, rowend);
759 REBAR_DumpBand (infoPtr);
765 REBAR_CalcHorzBand (REBAR_INFO *infoPtr, UINT rstart, UINT rend, BOOL notify)
766 /* Function: this routine initializes all the rectangles in */
767 /* each band in a row to fit in the adjusted rcBand rect. */
768 /* *** Supports only Horizontal bars. *** */
775 /* MS seems to use GetDlgCtrlID() for above GetWindowLong call */
776 parenthwnd = GetParent (infoPtr->hwndSelf);
778 for(i=rstart; i<rend; i++){
779 lpBand = &infoPtr->bands[i];
780 if (HIDDENBAND(lpBand)) {
781 SetRect (&lpBand->rcChild,
782 lpBand->rcBand.right, lpBand->rcBand.top,
783 lpBand->rcBand.right, lpBand->rcBand.bottom);
787 oldChild = lpBand->rcChild;
789 /* set initial gripper rectangle */
790 SetRect (&lpBand->rcGripper, lpBand->rcBand.left, lpBand->rcBand.top,
791 lpBand->rcBand.left, lpBand->rcBand.bottom);
793 /* calculate gripper rectangle */
794 if ( lpBand->fStatus & HAS_GRIPPER) {
795 lpBand->fDraw |= DRAW_GRIPPER;
796 lpBand->rcGripper.left += REBAR_PRE_GRIPPER;
797 lpBand->rcGripper.right = lpBand->rcGripper.left + GRIPPER_WIDTH;
798 lpBand->rcGripper.top += 2;
799 lpBand->rcGripper.bottom -= 2;
801 SetRect (&lpBand->rcCapImage,
802 lpBand->rcGripper.right+REBAR_ALWAYS_SPACE, lpBand->rcBand.top,
803 lpBand->rcGripper.right+REBAR_ALWAYS_SPACE, lpBand->rcBand.bottom);
805 else { /* no gripper will be drawn */
807 if (lpBand->fStatus & (HAS_IMAGE | HAS_TEXT))
808 /* if no gripper but either image or text, then leave space */
809 xoff = REBAR_ALWAYS_SPACE;
810 SetRect (&lpBand->rcCapImage,
811 lpBand->rcBand.left+xoff, lpBand->rcBand.top,
812 lpBand->rcBand.left+xoff, lpBand->rcBand.bottom);
815 /* image is visible */
816 if (lpBand->fStatus & HAS_IMAGE) {
817 lpBand->fDraw |= DRAW_IMAGE;
818 lpBand->rcCapImage.right += infoPtr->imageSize.cx;
819 lpBand->rcCapImage.bottom = lpBand->rcCapImage.top + infoPtr->imageSize.cy;
821 /* set initial caption text rectangle */
822 SetRect (&lpBand->rcCapText,
823 lpBand->rcCapImage.right+REBAR_POST_IMAGE, lpBand->rcBand.top+1,
824 lpBand->rcBand.left+lpBand->cxHeader, lpBand->rcBand.bottom-1);
825 /* update band height
826 if (lpBand->uMinHeight < infoPtr->imageSize.cy + 2) {
827 lpBand->uMinHeight = infoPtr->imageSize.cy + 2;
828 lpBand->rcBand.bottom = lpBand->rcBand.top + lpBand->uMinHeight;
832 /* set initial caption text rectangle */
833 SetRect (&lpBand->rcCapText, lpBand->rcCapImage.right, lpBand->rcBand.top+1,
834 lpBand->rcBand.left+lpBand->cxHeader, lpBand->rcBand.bottom-1);
837 /* text is visible */
838 if (lpBand->fStatus & HAS_TEXT) {
839 lpBand->fDraw |= DRAW_TEXT;
840 lpBand->rcCapText.right = max(lpBand->rcCapText.left,
841 lpBand->rcCapText.right-REBAR_POST_TEXT);
844 /* set initial child window rectangle if there is a child */
845 if (lpBand->fMask & RBBIM_CHILD) {
846 xoff = lpBand->offChild.cx;
847 yoff = lpBand->offChild.cy;
848 SetRect (&lpBand->rcChild,
849 lpBand->rcBand.left+lpBand->cxHeader, lpBand->rcBand.top+yoff,
850 lpBand->rcBand.right-xoff, lpBand->rcBand.bottom-yoff);
853 SetRect (&lpBand->rcChild,
854 lpBand->rcBand.left+lpBand->cxHeader, lpBand->rcBand.top,
855 lpBand->rcBand.right, lpBand->rcBand.bottom);
858 /* flag if notify required and invalidate rectangle */
860 ((oldChild.right-oldChild.left != lpBand->rcChild.right-lpBand->rcChild.left) ||
861 (oldChild.bottom-oldChild.top != lpBand->rcChild.bottom-lpBand->rcChild.top))) {
862 TRACE("Child rectangle changed for band %u\n", i);
863 TRACE(" from (%d,%d)-(%d,%d) to (%d,%d)-(%d,%d)\n",
864 oldChild.left, oldChild.top,
865 oldChild.right, oldChild.bottom,
866 lpBand->rcChild.left, lpBand->rcChild.top,
867 lpBand->rcChild.right, lpBand->rcChild.bottom);
869 if (lpBand->fDraw & NTF_INVALIDATE) {
870 TRACE("invalidating (%d,%d)-(%d,%d)\n",
873 lpBand->rcBand.right + ((lpBand->fDraw & DRAW_RIGHTSEP) ? SEP_WIDTH_SIZE : 0),
874 lpBand->rcBand.bottom + ((lpBand->fDraw & DRAW_BOTTOMSEP) ? SEP_WIDTH_SIZE : 0));
875 lpBand->fDraw &= ~NTF_INVALIDATE;
876 work = lpBand->rcBand;
877 if (lpBand->fDraw & DRAW_RIGHTSEP) work.right += SEP_WIDTH_SIZE;
878 if (lpBand->fDraw & DRAW_BOTTOMSEP) work.bottom += SEP_WIDTH_SIZE;
879 InvalidateRect(infoPtr->hwndSelf, &work, TRUE);
888 REBAR_CalcVertBand (REBAR_INFO *infoPtr, UINT rstart, UINT rend, BOOL notify)
889 /* Function: this routine initializes all the rectangles in */
890 /* each band in a row to fit in the adjusted rcBand rect. */
891 /* *** Supports only Vertical bars. *** */
898 /* MS seems to use GetDlgCtrlID() for above GetWindowLong call */
899 parenthwnd = GetParent (infoPtr->hwndSelf);
901 for(i=rstart; i<rend; i++){
902 lpBand = &infoPtr->bands[i];
903 if (HIDDENBAND(lpBand)) continue;
904 oldChild = lpBand->rcChild;
906 /* set initial gripper rectangle */
907 SetRect (&lpBand->rcGripper, lpBand->rcBand.left, lpBand->rcBand.top,
908 lpBand->rcBand.right, lpBand->rcBand.top);
910 /* calculate gripper rectangle */
911 if (lpBand->fStatus & HAS_GRIPPER) {
912 lpBand->fDraw |= DRAW_GRIPPER;
914 if (infoPtr->dwStyle & RBS_VERTICALGRIPPER) {
915 /* vertical gripper */
916 lpBand->rcGripper.left += 3;
917 lpBand->rcGripper.right = lpBand->rcGripper.left + GRIPPER_WIDTH;
918 lpBand->rcGripper.top += REBAR_PRE_GRIPPER;
919 lpBand->rcGripper.bottom = lpBand->rcGripper.top + GRIPPER_HEIGHT;
921 /* initialize Caption image rectangle */
922 SetRect (&lpBand->rcCapImage, lpBand->rcBand.left,
923 lpBand->rcGripper.bottom + REBAR_ALWAYS_SPACE,
924 lpBand->rcBand.right,
925 lpBand->rcGripper.bottom + REBAR_ALWAYS_SPACE);
928 /* horizontal gripper */
929 lpBand->rcGripper.left += 3;
930 lpBand->rcGripper.right -= 3;
931 lpBand->rcGripper.top += REBAR_PRE_GRIPPER;
932 lpBand->rcGripper.bottom = lpBand->rcGripper.top + GRIPPER_WIDTH;
934 /* initialize Caption image rectangle */
935 SetRect (&lpBand->rcCapImage, lpBand->rcBand.left,
936 lpBand->rcGripper.bottom + REBAR_ALWAYS_SPACE,
937 lpBand->rcBand.right,
938 lpBand->rcGripper.bottom + REBAR_ALWAYS_SPACE);
941 else { /* no gripper will be drawn */
943 if (lpBand->fStatus & (HAS_IMAGE | HAS_TEXT))
944 /* if no gripper but either image or text, then leave space */
945 xoff = REBAR_ALWAYS_SPACE;
946 /* initialize Caption image rectangle */
947 SetRect (&lpBand->rcCapImage,
948 lpBand->rcBand.left, lpBand->rcBand.top+xoff,
949 lpBand->rcBand.right, lpBand->rcBand.top+xoff);
952 /* image is visible */
953 if (lpBand->fStatus & HAS_IMAGE) {
954 lpBand->fDraw |= DRAW_IMAGE;
956 lpBand->rcCapImage.right = lpBand->rcCapImage.left + infoPtr->imageSize.cx;
957 lpBand->rcCapImage.bottom += infoPtr->imageSize.cy;
959 /* set initial caption text rectangle */
960 SetRect (&lpBand->rcCapText,
961 lpBand->rcBand.left, lpBand->rcCapImage.bottom+REBAR_POST_IMAGE,
962 lpBand->rcBand.right, lpBand->rcBand.top+lpBand->cxHeader);
963 /* update band height *
964 if (lpBand->uMinHeight < infoPtr->imageSize.cx + 2) {
965 lpBand->uMinHeight = infoPtr->imageSize.cx + 2;
966 lpBand->rcBand.right = lpBand->rcBand.left + lpBand->uMinHeight;
970 /* set initial caption text rectangle */
971 SetRect (&lpBand->rcCapText,
972 lpBand->rcBand.left, lpBand->rcCapImage.bottom,
973 lpBand->rcBand.right, lpBand->rcBand.top+lpBand->cxHeader);
976 /* text is visible */
977 if (lpBand->fStatus & HAS_TEXT) {
978 lpBand->fDraw |= DRAW_TEXT;
979 lpBand->rcCapText.bottom = max(lpBand->rcCapText.top,
980 lpBand->rcCapText.bottom-REBAR_POST_TEXT);
983 /* set initial child window rectangle if there is a child */
984 if (lpBand->fMask & RBBIM_CHILD) {
985 yoff = lpBand->offChild.cx;
986 xoff = lpBand->offChild.cy;
987 SetRect (&lpBand->rcChild,
988 lpBand->rcBand.left+xoff, lpBand->rcBand.top+lpBand->cxHeader,
989 lpBand->rcBand.right-xoff, lpBand->rcBand.bottom-yoff);
992 SetRect (&lpBand->rcChild,
993 lpBand->rcBand.left, lpBand->rcBand.top+lpBand->cxHeader,
994 lpBand->rcBand.right, lpBand->rcBand.bottom);
997 /* flag if notify required and invalidate rectangle */
999 ((oldChild.right-oldChild.left != lpBand->rcChild.right-lpBand->rcChild.left) ||
1000 (oldChild.bottom-oldChild.top != lpBand->rcChild.bottom-lpBand->rcChild.top))) {
1001 TRACE("Child rectangle changed for band %u\n", i);
1002 TRACE(" from (%d,%d)-(%d,%d) to (%d,%d)-(%d,%d)\n",
1003 oldChild.left, oldChild.top,
1004 oldChild.right, oldChild.bottom,
1005 lpBand->rcChild.left, lpBand->rcChild.top,
1006 lpBand->rcChild.right, lpBand->rcChild.bottom);
1008 if (lpBand->fDraw & NTF_INVALIDATE) {
1009 TRACE("invalidating (%d,%d)-(%d,%d)\n",
1010 lpBand->rcBand.left,
1012 lpBand->rcBand.right + ((lpBand->fDraw & DRAW_BOTTOMSEP) ? SEP_WIDTH_SIZE : 0),
1013 lpBand->rcBand.bottom + ((lpBand->fDraw & DRAW_RIGHTSEP) ? SEP_WIDTH_SIZE : 0));
1014 lpBand->fDraw &= ~NTF_INVALIDATE;
1015 work = lpBand->rcBand;
1016 if (lpBand->fDraw & DRAW_RIGHTSEP) work.bottom += SEP_WIDTH_SIZE;
1017 if (lpBand->fDraw & DRAW_BOTTOMSEP) work.right += SEP_WIDTH_SIZE;
1018 InvalidateRect(infoPtr->hwndSelf, &work, TRUE);
1026 REBAR_ForceResize (REBAR_INFO *infoPtr)
1027 /* Function: This changes the size of the REBAR window to that */
1028 /* calculated by REBAR_Layout. */
1032 /* TEST TEST TEST */
1033 GetWindowRect (infoPtr->hwndSelf, &rc);
1034 /* END TEST END TEST END TEST */
1037 GetClientRect (infoPtr->hwndSelf, &rc);
1039 TRACE( " old [%ld x %ld], new [%ld x %ld], client [%d x %d]\n",
1040 infoPtr->oldSize.cx, infoPtr->oldSize.cy,
1041 infoPtr->calcSize.cx, infoPtr->calcSize.cy,
1042 rc.right, rc.bottom);
1044 /* If we need to shrink client, then skip size test */
1045 if ((infoPtr->calcSize.cy >= rc.bottom) &&
1046 (infoPtr->calcSize.cx >= rc.right)) {
1048 /* if size did not change then skip process */
1049 if ((infoPtr->oldSize.cx == infoPtr->calcSize.cx) &&
1050 (infoPtr->oldSize.cy == infoPtr->calcSize.cy) &&
1051 !(infoPtr->fStatus & RESIZE_ANYHOW))
1053 TRACE("skipping reset\n");
1058 infoPtr->fStatus &= ~RESIZE_ANYHOW;
1059 /* Set flag to ignore next WM_SIZE message */
1060 infoPtr->fStatus |= AUTO_RESIZE;
1064 rc.right = infoPtr->calcSize.cx;
1065 rc.bottom = infoPtr->calcSize.cy;
1067 InflateRect (&rc, 0, GetSystemMetrics(SM_CYEDGE));
1068 /* see comments in _NCCalcSize for reason below is not done */
1070 if (GetWindowLongA (infoPtr->hwndSelf, GWL_STYLE) & WS_BORDER) {
1071 InflateRect (&rc, GetSystemMetrics(SM_CXEDGE), GetSystemMetrics(SM_CYEDGE));
1075 TRACE("setting to (0,0)-(%d,%d)\n",
1076 rc.right - rc.left, rc.bottom - rc.top);
1077 SetWindowPos (infoPtr->hwndSelf, 0, 0, 0,
1078 rc.right - rc.left, rc.bottom - rc.top,
1079 SWP_NOMOVE | SWP_NOZORDER | SWP_SHOWWINDOW);
1084 REBAR_MoveChildWindows (REBAR_INFO *infoPtr, UINT start, UINT endplus)
1087 CHAR szClassName[40];
1089 NMREBARCHILDSIZE rbcz;
1093 if (!(deferpos = BeginDeferWindowPos(infoPtr->uNumBands)))
1094 ERR("BeginDeferWindowPos returned NULL\n");
1096 for (i = start; i < endplus; i++) {
1097 lpBand = &infoPtr->bands[i];
1099 if (HIDDENBAND(lpBand)) continue;
1100 if (lpBand->hwndChild) {
1101 TRACE("hwndChild = %x\n", lpBand->hwndChild);
1103 /* Always geterate the RBN_CHILDSIZE even it child
1106 rbcz.wID = lpBand->wID;
1107 rbcz.rcChild = lpBand->rcChild;
1108 rbcz.rcBand = lpBand->rcBand;
1109 rbcz.rcBand.left += lpBand->cxHeader;
1110 REBAR_Notify ((NMHDR *)&rbcz, infoPtr, RBN_CHILDSIZE);
1111 if (!EqualRect (&lpBand->rcChild, &rbcz.rcChild)) {
1112 TRACE("Child rect changed by NOTIFY for band %u\n", i);
1113 TRACE(" from (%d,%d)-(%d,%d) to (%d,%d)-(%d,%d)\n",
1114 lpBand->rcChild.left, lpBand->rcChild.top,
1115 lpBand->rcChild.right, lpBand->rcChild.bottom,
1116 rbcz.rcChild.left, rbcz.rcChild.top,
1117 rbcz.rcChild.right, rbcz.rcChild.bottom);
1120 GetClassNameA (lpBand->hwndChild, szClassName, 40);
1121 if (!lstrcmpA (szClassName, "ComboBox") ||
1122 !lstrcmpA (szClassName, WC_COMBOBOXEXA)) {
1123 INT nEditHeight, yPos;
1126 /* special placement code for combo or comboex box */
1129 /* get size of edit line */
1130 GetWindowRect (lpBand->hwndChild, &rc);
1131 nEditHeight = rc.bottom - rc.top;
1132 yPos = (lpBand->rcChild.bottom + lpBand->rcChild.top - nEditHeight)/2;
1134 /* center combo box inside child area */
1135 TRACE("moving child (Combo(Ex)) %04x to (%d,%d)-(%d,%d)\n",
1137 lpBand->rcChild.left, yPos,
1138 lpBand->rcChild.right - lpBand->rcChild.left,
1140 deferpos = DeferWindowPos (deferpos, lpBand->hwndChild, HWND_TOP,
1141 lpBand->rcChild.left,
1142 /*lpBand->rcChild.top*/ yPos,
1143 lpBand->rcChild.right - lpBand->rcChild.left,
1147 ERR("DeferWindowPos returned NULL\n");
1150 TRACE("moving child (Other) %04x to (%d,%d)-(%d,%d)\n",
1152 lpBand->rcChild.left, lpBand->rcChild.top,
1153 lpBand->rcChild.right - lpBand->rcChild.left,
1154 lpBand->rcChild.bottom - lpBand->rcChild.top);
1155 deferpos = DeferWindowPos (deferpos, lpBand->hwndChild, HWND_TOP,
1156 lpBand->rcChild.left,
1157 lpBand->rcChild.top,
1158 lpBand->rcChild.right - lpBand->rcChild.left,
1159 lpBand->rcChild.bottom - lpBand->rcChild.top,
1162 ERR("DeferWindowPos returned NULL\n");
1166 if (!EndDeferWindowPos(deferpos))
1167 ERR("EndDeferWindowPos returned NULL\n");
1168 if (infoPtr->fStatus & NTF_HGHTCHG) {
1169 infoPtr->fStatus &= ~NTF_HGHTCHG;
1170 REBAR_Notify (&heightchange, infoPtr, RBN_HEIGHTCHANGE);
1176 REBAR_Layout (REBAR_INFO *infoPtr, LPRECT lpRect, BOOL notify, BOOL resetclient)
1177 /* Function: This routine is resposible for laying out all */
1178 /* the bands in a rebar. It assigns each band to a row and*/
1179 /* determines when to start a new row. */
1181 REBAR_BAND *lpBand, *prevBand;
1182 RECT rcClient, rcAdj;
1183 INT x, y, cx, cxsep, mmcy, mcy, clientcx, clientcy;
1184 INT adjcx, adjcy, row, rightx, bottomy, origheight;
1185 UINT i, j, rowstart;
1188 if (!(infoPtr->fStatus & BAND_NEEDS_LAYOUT)) {
1189 TRACE("no layout done. No band changed.\n");
1190 REBAR_DumpBand (infoPtr);
1193 infoPtr->fStatus &= ~BAND_NEEDS_LAYOUT;
1195 GetClientRect (infoPtr->hwndSelf, &rcClient);
1196 TRACE("Client is (%d,%d)-(%d,%d)\n",
1197 rcClient.left, rcClient.top, rcClient.right, rcClient.bottom);
1201 TRACE("adjustment rect is (%d,%d)-(%d,%d)\n",
1202 rcAdj.left, rcAdj.top, rcAdj.right, rcAdj.bottom);
1205 CopyRect (&rcAdj, &rcClient);
1208 clientcx = rcClient.right - rcClient.left;
1209 clientcy = rcClient.bottom - rcClient.top;
1210 adjcx = rcAdj.right - rcAdj.left;
1211 adjcy = rcAdj.bottom - rcAdj.top;
1213 TRACE("window client rect will be set to adj rect\n");
1218 /* save height of original control */
1219 if (infoPtr->dwStyle & CCS_VERT)
1220 origheight = infoPtr->calcSize.cx;
1222 origheight = infoPtr->calcSize.cy;
1225 /* ******* Start Phase 1 - all bands on row at minimum size ******* */
1235 for (i = 0; i < infoPtr->uNumBands; i++) {
1236 lpBand = &infoPtr->bands[i];
1240 if (HIDDENBAND(lpBand)) continue;
1242 lpBand->rcoldBand = lpBand->rcBand;
1244 /* separator from previous band */
1245 cxsep = ( ((infoPtr->dwStyle & CCS_VERT) ? y : x)==0) ? 0 : SEP_WIDTH;
1247 /* Header: includes gripper, text, image */
1248 cx = lpBand->cxHeader;
1249 if (lpBand->fStyle & RBBS_FIXEDSIZE) cx = lpBand->lcx;
1251 if (infoPtr->dwStyle & CCS_VERT)
1252 dobreak = (y + cx + cxsep > adjcy);
1254 dobreak = (x + cx + cxsep > adjcx);
1256 /* This is the check for whether we need to start a new row */
1257 if ( ( (lpBand->fStyle & RBBS_BREAK) && (i != 0) ) ||
1258 ( ((infoPtr->dwStyle & CCS_VERT) ? (y != 0) : (x != 0)) && dobreak)) {
1260 for (j = rowstart; j < i; j++) {
1262 lpB = &infoPtr->bands[j];
1263 if (infoPtr->dwStyle & CCS_VERT) {
1264 lpB->rcBand.right = lpB->rcBand.left + mcy;
1267 lpB->rcBand.bottom = lpB->rcBand.top + mcy;
1271 TRACE("Spliting to new row %d on band %u\n", row+1, i);
1272 if (infoPtr->dwStyle & CCS_VERT) {
1274 x += (mcy + SEP_WIDTH);
1278 y += (mcy + SEP_WIDTH);
1289 if (mcy < lpBand->lcy + REBARSPACE) mcy = lpBand->lcy + REBARSPACE;
1291 /* if boundary rect specified then limit mcy */
1293 if (infoPtr->dwStyle & CCS_VERT) {
1294 if (x+mcy > adjcx) {
1296 TRACE("row %u limiting mcy=%d, adjcx=%d, x=%d\n",
1301 if (y+mcy > adjcy) {
1303 TRACE("row %u limiting mcy=%d, adjcy=%d, y=%d\n",
1309 if (infoPtr->dwStyle & CCS_VERT) {
1310 /* bound the bottom side if we have a bounding rectangle */
1312 bottomy = (lpRect) ? min(clientcy, y+cxsep+cx) : y+cxsep+cx;
1313 lpBand->rcBand.left = x;
1314 lpBand->rcBand.right = x + min(mcy, lpBand->lcy+REBARSPACE);
1315 lpBand->rcBand.top = min(bottomy, y + cxsep);
1316 lpBand->rcBand.bottom = bottomy;
1317 lpBand->uMinHeight = lpBand->lcy;
1321 /* bound the right side if we have a bounding rectangle */
1322 rightx = (lpRect) ? min(clientcx, x+cxsep+cx) : x+cxsep+cx;
1324 lpBand->rcBand.left = min(rightx, x + cxsep);
1325 lpBand->rcBand.right = rightx;
1326 lpBand->rcBand.top = y;
1327 lpBand->rcBand.bottom = y + min(mcy, lpBand->lcy+REBARSPACE);
1328 lpBand->uMinHeight = lpBand->lcy;
1331 TRACE("band %u, row %d, (%d,%d)-(%d,%d)\n",
1333 lpBand->rcBand.left, lpBand->rcBand.top,
1334 lpBand->rcBand.right, lpBand->rcBand.bottom);
1337 } /* for (i = 0; i < infoPtr->uNumBands... */
1339 if (infoPtr->dwStyle & CCS_VERT)
1344 for (j = rowstart; j < infoPtr->uNumBands; j++) {
1345 lpBand = &infoPtr->bands[j];
1346 if (infoPtr->dwStyle & CCS_VERT) {
1347 lpBand->rcBand.right = lpBand->rcBand.left + mcy;
1350 lpBand->rcBand.bottom = lpBand->rcBand.top + mcy;
1354 if (infoPtr->uNumBands)
1355 infoPtr->uNumRows = row;
1357 /* ******* End Phase 1 - all bands on row at minimum size ******* */
1360 /* ******* Start Phase 1a - Adjust heights for RBS_VARHEIGHT off ******* */
1363 if (!(infoPtr->dwStyle & RBS_VARHEIGHT)) {
1366 /* get the max height of all bands */
1367 for (i=0; i<infoPtr->uNumBands; i++) {
1368 lpBand = &infoPtr->bands[i];
1369 if (HIDDENBAND(lpBand)) continue;
1370 if (infoPtr->dwStyle & CCS_VERT)
1371 mmcy = max(mmcy, lpBand->rcBand.right - lpBand->rcBand.left);
1373 mmcy = max(mmcy, lpBand->rcBand.bottom - lpBand->rcBand.top);
1376 /* now adjust all rectangles by using the height found above */
1379 for (i=0; i<infoPtr->uNumBands; i++) {
1380 lpBand = &infoPtr->bands[i];
1381 if (HIDDENBAND(lpBand)) continue;
1382 if (lpBand->iRow != row)
1383 xy += (mmcy + SEP_WIDTH);
1384 if (infoPtr->dwStyle & CCS_VERT) {
1385 lpBand->rcBand.left = xy;
1386 lpBand->rcBand.right = xy + mmcy;
1389 lpBand->rcBand.top = xy;
1390 lpBand->rcBand.bottom = xy + mmcy;
1394 /* set the x/y values to the correct maximum */
1395 if (infoPtr->dwStyle & CCS_VERT)
1401 /* ******* End Phase 1a - Adjust heights for RBS_VARHEIGHT off ******* */
1404 /* ******* Start Phase 2 - split rows till adjustment height full ******* */
1406 /* assumes that the following variables contain: */
1407 /* y/x current height/width of all rows */
1409 INT i, j, prev_rh, new_rh, adj_rh, prev_idx, current_idx;
1410 REBAR_BAND *prev, *current, *walk;
1412 /* FIXME: problem # 2 */
1413 if (((infoPtr->dwStyle & CCS_VERT) ?
1415 (x < adjcx) : (y < adjcy)
1417 (adjcx - x > 4) : (adjcy - y > 4)
1420 (infoPtr->uNumBands > 1)) {
1421 for (i=(INT)infoPtr->uNumBands-2; i>=0; i--) {
1422 TRACE("adjcx=%d, adjcy=%d, x=%d, y=%d\n",
1423 adjcx, adjcy, x, y);
1425 /* find the current band (starts at i+1) */
1426 current = &infoPtr->bands[i+1];
1428 while (HIDDENBAND(current)) {
1430 if (i < 0) break; /* out of bands */
1431 current = &infoPtr->bands[i+1];
1434 if (i < 0) break; /* out of bands */
1436 /* now find the prev band (starts at i) */
1437 prev = &infoPtr->bands[i];
1439 while (HIDDENBAND(prev)) {
1441 if (i < 0) break; /* out of bands */
1442 prev = &infoPtr->bands[i];
1445 if (i < 0) break; /* out of bands */
1447 prev_rh = ircBw(prev);
1448 if (prev->iRow == current->iRow) {
1449 new_rh = (infoPtr->dwStyle & RBS_VARHEIGHT) ?
1450 current->lcy + REBARSPACE :
1452 adj_rh = new_rh + SEP_WIDTH;
1453 infoPtr->uNumRows++;
1454 current->fDraw |= NTF_INVALIDATE;
1456 if (infoPtr->dwStyle & CCS_VERT) {
1457 current->rcBand.top = 0;
1458 current->rcBand.bottom = clientcy;
1459 current->rcBand.left += (prev_rh + SEP_WIDTH);
1460 current->rcBand.right = current->rcBand.left + new_rh;
1464 current->rcBand.left = 0;
1465 current->rcBand.right = clientcx;
1466 current->rcBand.top += (prev_rh + SEP_WIDTH);
1467 current->rcBand.bottom = current->rcBand.top + new_rh;
1470 TRACE("moving band %d to own row at (%d,%d)-(%d,%d)\n",
1472 current->rcBand.left, current->rcBand.top,
1473 current->rcBand.right, current->rcBand.bottom);
1474 TRACE("prev band %d at (%d,%d)-(%d,%d)\n",
1476 prev->rcBand.left, prev->rcBand.top,
1477 prev->rcBand.right, prev->rcBand.bottom);
1478 TRACE("values: prev_rh=%d, new_rh=%d, adj_rh=%d\n",
1479 prev_rh, new_rh, adj_rh);
1480 /* for bands below current adjust row # and top/bottom */
1481 for (j = current_idx+1; j<infoPtr->uNumBands; j++) {
1482 walk = &infoPtr->bands[j];
1483 if (HIDDENBAND(walk)) continue;
1484 walk->fDraw |= NTF_INVALIDATE;
1486 if (infoPtr->dwStyle & CCS_VERT) {
1487 walk->rcBand.left += adj_rh;
1488 walk->rcBand.right += adj_rh;
1491 walk->rcBand.top += adj_rh;
1492 walk->rcBand.bottom += adj_rh;
1495 if ((infoPtr->dwStyle & CCS_VERT) ? (x >= adjcx) : (y >= adjcy))
1496 break; /* all done */
1502 /* ******* End Phase 2 - split rows till adjustment height full ******* */
1505 /* ******* Start Phase 3 - adjust all bands for width full ******* */
1507 if (infoPtr->uNumBands) {
1508 INT bandnum, bandnum_start, bandnum_end;
1510 /* If RBS_BANDBORDERS set then indicate to draw bottom separator */
1511 /* on all bands in all rows but last row. */
1512 /* Also indicate to draw the right separator for each band in */
1513 /* each row but the rightmost band. */
1514 if (infoPtr->dwStyle & RBS_BANDBORDERS) {
1515 REBAR_BAND *prevband;
1520 for (i = 0; i < infoPtr->uNumBands; i++) {
1521 lpBand = &infoPtr->bands[i];
1522 if (HIDDENBAND(lpBand)) continue;
1524 if (lpBand->iRow < infoPtr->uNumRows)
1525 lpBand->fDraw |= DRAW_BOTTOMSEP;
1527 if (lpBand->iRow != currow) prevband = NULL;
1528 currow = lpBand->iRow;
1529 if (prevband) prevband->fDraw |= DRAW_RIGHTSEP;
1534 /* Distribute the extra space on the horizontal and adjust */
1535 /* all bands in row to same height. */
1537 for (i=1; i<=infoPtr->uNumRows; i++) {
1541 TRACE("processing row %d, starting band %d\n", i, bandnum);
1543 lpBand = &infoPtr->bands[bandnum];
1544 if ((bandnum >= infoPtr->uNumBands) ||
1545 ((lpBand->iRow != i) &&
1546 !HIDDENBAND(lpBand))) {
1547 if ((bandnum_start == -1) ||
1548 (bandnum_end == -1)) {
1549 ERR("logic error? bands=%d, rows=%d, start=%d, end=%d\n",
1550 infoPtr->uNumBands, infoPtr->uNumRows,
1551 (INT)bandnum_start, (INT)bandnum_end);
1552 ERR(" current row=%d, band=%d\n",
1556 REBAR_AdjustBands (infoPtr, bandnum_start, bandnum_end,
1557 (infoPtr->dwStyle & CCS_VERT) ?
1558 clientcy : clientcx, mcy);
1561 if (!HIDDENBAND(lpBand)) {
1562 if (bandnum_start == -1) bandnum_start = bandnum;
1563 if (bandnum_end < bandnum) bandnum_end = bandnum;
1564 if (mcy < ircBw(lpBand))
1565 mcy = ircBw(lpBand);
1568 TRACE("point 1, bandnum=%d\n", bandnum);
1570 TRACE("point 2, i=%d, numrows=%d, bandnum=%d\n",
1571 i, infoPtr->uNumRows, bandnum);
1575 /* Calculate the other rectangles in each band */
1576 if (infoPtr->dwStyle & CCS_VERT) {
1577 REBAR_CalcVertBand (infoPtr, 0, infoPtr->uNumBands,
1581 REBAR_CalcHorzBand (infoPtr, 0, infoPtr->uNumBands,
1586 /* ******* End Phase 3 - adjust all bands for width full ******* */
1588 /* now compute size of Rebar itself */
1589 infoPtr->oldSize = infoPtr->calcSize;
1590 if (infoPtr->dwStyle & CCS_VERT) {
1591 infoPtr->calcSize.cx = x;
1592 infoPtr->calcSize.cy = clientcy;
1593 TRACE("vert, notify=%d, x=%d, origheight=%d\n",
1594 notify, x, origheight);
1595 if (notify && (x != origheight)) infoPtr->fStatus |= NTF_HGHTCHG;
1598 infoPtr->calcSize.cx = clientcx;
1599 infoPtr->calcSize.cy = y;
1600 TRACE("horz, notify=%d, y=%d, origheight=%d\n",
1601 notify, y, origheight);
1602 if (notify && (y != origheight)) infoPtr->fStatus |= NTF_HGHTCHG;
1605 REBAR_DumpBand (infoPtr);
1607 REBAR_MoveChildWindows (infoPtr, 0, infoPtr->uNumBands);
1609 REBAR_ForceResize (infoPtr);
1614 REBAR_ValidateBand (REBAR_INFO *infoPtr, REBAR_BAND *lpBand)
1615 /* Function: This routine evaluates the band specs supplied */
1616 /* by the user and updates the following 5 fields in */
1617 /* the internal band structure: cxHeader, lcx, lcy, hcx, hcy*/
1622 lpBand->fStatus = 0;
1630 /* Data comming in from users into the cx... and cy... fields */
1631 /* may be bad, just garbage, because the user never clears */
1632 /* the fields. RB_{SET|INSERT}BAND{A|W} just passes the data */
1633 /* along if the fields exist in the input area. Here we must */
1634 /* determine if the data is valid. I have no idea how MS does */
1635 /* the validation, but it does because the RB_GETBANDINFO */
1636 /* returns a 0 when I know the sample program passed in an */
1637 /* address. Here I will use the algorithim that if the value */
1638 /* is greater than 65535 then it is bad and replace it with */
1639 /* a zero. Feel free to improve the algorithim. - GA 12/2000 */
1640 if (lpBand->cxMinChild > 65535) lpBand->cxMinChild = 0;
1641 if (lpBand->cyMinChild > 65535) lpBand->cyMinChild = 0;
1642 if (lpBand->cx > 65535) lpBand->cx = 0;
1643 if (lpBand->cyChild > 65535) lpBand->cyChild = 0;
1644 if (lpBand->cyMaxChild > 65535) lpBand->cyMaxChild = 0;
1645 if (lpBand->cyIntegral > 65535) lpBand->cyIntegral = 0;
1646 if (lpBand->cxIdeal > 65535) lpBand->cxIdeal = 0;
1647 if (lpBand->cxHeader > 65535) lpBand->cxHeader = 0;
1649 /* FIXME: probably should only set NEEDS_LAYOUT flag when */
1650 /* values change. Till then always set it. */
1651 TRACE("setting NEEDS_LAYOUT\n");
1652 infoPtr->fStatus |= BAND_NEEDS_LAYOUT;
1654 /* Header is where the image, text and gripper exist */
1655 /* in the band and preceed the child window. */
1657 /* calculate gripper rectangle */
1658 if ( (!(lpBand->fStyle & RBBS_NOGRIPPER)) &&
1659 ( (lpBand->fStyle & RBBS_GRIPPERALWAYS) ||
1660 ( !(lpBand->fStyle & RBBS_FIXEDSIZE) && (infoPtr->uNumBands > 1)))
1662 lpBand->fStatus |= HAS_GRIPPER;
1663 if (infoPtr->dwStyle & CCS_VERT)
1664 if (infoPtr->dwStyle & RBS_VERTICALGRIPPER)
1665 header += (GRIPPER_HEIGHT + REBAR_PRE_GRIPPER);
1667 header += (GRIPPER_WIDTH + REBAR_PRE_GRIPPER);
1669 header += (REBAR_PRE_GRIPPER + GRIPPER_WIDTH);
1670 /* Always have 4 pixels before anything else */
1671 header += REBAR_ALWAYS_SPACE;
1674 /* image is visible */
1675 if ((lpBand->fMask & RBBIM_IMAGE) && (infoPtr->himl)) {
1676 lpBand->fStatus |= HAS_IMAGE;
1677 if (infoPtr->dwStyle & CCS_VERT) {
1678 header += (infoPtr->imageSize.cy + REBAR_POST_IMAGE);
1679 lpBand->lcy = infoPtr->imageSize.cx + 2;
1682 header += (infoPtr->imageSize.cx + REBAR_POST_IMAGE);
1683 lpBand->lcy = infoPtr->imageSize.cy + 2;
1687 /* text is visible */
1688 if ((lpBand->fMask & RBBIM_TEXT) && (lpBand->lpText)) {
1689 HDC hdc = GetDC (0);
1690 HFONT hOldFont = SelectObject (hdc, infoPtr->hFont);
1693 lpBand->fStatus |= HAS_TEXT;
1694 GetTextExtentPoint32W (hdc, lpBand->lpText,
1695 lstrlenW (lpBand->lpText), &size);
1696 header += ((infoPtr->dwStyle & CCS_VERT) ? (size.cy + REBAR_POST_TEXT) : (size.cx + REBAR_POST_TEXT));
1697 textheight = (infoPtr->dwStyle & CCS_VERT) ? 0 : size.cy;
1699 SelectObject (hdc, hOldFont);
1703 /* if no gripper but either image or text, then leave space */
1704 if ((lpBand->fStatus & (HAS_IMAGE | HAS_TEXT)) &&
1705 !(lpBand->fStatus & HAS_GRIPPER)) {
1706 header += REBAR_ALWAYS_SPACE;
1709 /* check if user overrode the header value */
1710 if (!(lpBand->fMask & RBBIM_HEADERSIZE))
1711 lpBand->cxHeader = header;
1714 /* Now compute minimum size of child window */
1715 lpBand->offChild.cx = 0;
1716 lpBand->offChild.cy = 0;
1717 lpBand->lcy = textheight;
1718 lpBand->ccy = lpBand->lcy;
1719 if (lpBand->fMask & RBBIM_CHILDSIZE) {
1720 if (!(lpBand->fStyle & RBBS_FIXEDSIZE)) {
1721 lpBand->offChild.cx = 4;
1722 lpBand->offChild.cy = 2;
1724 lpBand->lcx = lpBand->cxMinChild;
1726 /* Set the .cy values for CHILDSIZE case */
1727 lpBand->lcy = max(lpBand->lcy, lpBand->cyMinChild);
1728 lpBand->ccy = lpBand->lcy;
1729 lpBand->hcy = lpBand->lcy;
1730 if (lpBand->cyMaxChild != 0xffffffff) {
1731 lpBand->hcy = lpBand->cyMaxChild;
1733 if (lpBand->cyChild != 0xffffffff)
1734 lpBand->ccy = max (lpBand->cyChild, lpBand->lcy);
1736 TRACE("_CHILDSIZE\n");
1738 if (lpBand->fMask & RBBIM_SIZE) {
1739 lpBand->hcx = max (lpBand->cx-lpBand->cxHeader, lpBand->lcx);
1743 lpBand->hcx = lpBand->lcx;
1744 lpBand->ccx = lpBand->hcx;
1746 /* make ->.cx include header size for _Layout */
1747 lpBand->lcx += lpBand->cxHeader;
1748 lpBand->ccx += lpBand->cxHeader;
1749 lpBand->hcx += lpBand->cxHeader;
1754 REBAR_CommonSetupBand (HWND hwnd, LPREBARBANDINFOA lprbbi, REBAR_BAND *lpBand)
1755 /* Function: This routine copies the supplied values from */
1756 /* user input (lprbbi) to the internal band structure. */
1758 lpBand->fMask |= lprbbi->fMask;
1760 if (lprbbi->fMask & RBBIM_STYLE)
1761 lpBand->fStyle = lprbbi->fStyle;
1763 if (lprbbi->fMask & RBBIM_COLORS) {
1764 lpBand->clrFore = lprbbi->clrFore;
1765 lpBand->clrBack = lprbbi->clrBack;
1768 if (lprbbi->fMask & RBBIM_IMAGE)
1769 lpBand->iImage = lprbbi->iImage;
1771 if (lprbbi->fMask & RBBIM_CHILD) {
1772 if (lprbbi->hwndChild) {
1773 lpBand->hwndChild = lprbbi->hwndChild;
1774 lpBand->hwndPrevParent =
1775 SetParent (lpBand->hwndChild, hwnd);
1776 /* below in trace fro WinRAR */
1777 ShowWindow(lpBand->hwndChild, SW_SHOWNOACTIVATE | SW_SHOWNORMAL);
1778 /* above in trace fro WinRAR */
1781 TRACE("child: 0x%x prev parent: 0x%x\n",
1782 lpBand->hwndChild, lpBand->hwndPrevParent);
1783 lpBand->hwndChild = 0;
1784 lpBand->hwndPrevParent = 0;
1788 if (lprbbi->fMask & RBBIM_CHILDSIZE) {
1789 lpBand->cxMinChild = lprbbi->cxMinChild;
1790 lpBand->cyMinChild = lprbbi->cyMinChild;
1791 if (lprbbi->cbSize >= sizeof (REBARBANDINFOA)) {
1792 lpBand->cyChild = lprbbi->cyChild;
1793 lpBand->cyMaxChild = lprbbi->cyMaxChild;
1794 lpBand->cyIntegral = lprbbi->cyIntegral;
1796 else { /* special case - these should be zeroed out since */
1797 /* RBBIM_CHILDSIZE added these in WIN32_IE >= 0x0400 */
1798 lpBand->cyChild = 0;
1799 lpBand->cyMaxChild = 0;
1800 lpBand->cyIntegral = 0;
1804 if (lprbbi->fMask & RBBIM_SIZE)
1805 lpBand->cx = lprbbi->cx;
1807 if (lprbbi->fMask & RBBIM_BACKGROUND)
1808 lpBand->hbmBack = lprbbi->hbmBack;
1810 if (lprbbi->fMask & RBBIM_ID)
1811 lpBand->wID = lprbbi->wID;
1813 /* check for additional data */
1814 if (lprbbi->cbSize >= sizeof (REBARBANDINFOA)) {
1815 if (lprbbi->fMask & RBBIM_IDEALSIZE)
1816 lpBand->cxIdeal = lprbbi->cxIdeal;
1818 if (lprbbi->fMask & RBBIM_LPARAM)
1819 lpBand->lParam = lprbbi->lParam;
1821 if (lprbbi->fMask & RBBIM_HEADERSIZE)
1822 lpBand->cxHeader = lprbbi->cxHeader;
1827 REBAR_InternalEraseBkGnd (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam, RECT *clip)
1828 /* Function: This erases the background rectangle by drawing */
1829 /* each band with its background color (or the default) and */
1830 /* draws each bands right separator if necessary. The row */
1831 /* separators are drawn on the first band of the next row. */
1835 HDC hdc = (HDC)wParam;
1840 for(i=0; i<infoPtr->uNumBands; i++) {
1841 lpBand = &infoPtr->bands[i];
1842 if (HIDDENBAND(lpBand)) continue;
1844 /* draw band separator between rows */
1845 if (lpBand->iRow != oldrow) {
1846 oldrow = lpBand->iRow;
1847 if (lpBand->fDraw & DRAW_BOTTOMSEP) {
1849 rcRowSep = lpBand->rcBand;
1850 if (infoPtr->dwStyle & CCS_VERT) {
1851 rcRowSep.right += SEP_WIDTH_SIZE;
1852 rcRowSep.bottom = infoPtr->calcSize.cy;
1853 DrawEdge (hdc, &rcRowSep, EDGE_ETCHED, BF_RIGHT);
1856 rcRowSep.bottom += SEP_WIDTH_SIZE;
1857 rcRowSep.right = infoPtr->calcSize.cx;
1858 DrawEdge (hdc, &rcRowSep, EDGE_ETCHED, BF_BOTTOM);
1860 TRACE ("drawing band separator bottom (%d,%d)-(%d,%d)\n",
1861 rcRowSep.left, rcRowSep.top,
1862 rcRowSep.right, rcRowSep.bottom);
1866 /* draw band separator between bands in a row */
1867 if (lpBand->fDraw & DRAW_RIGHTSEP) {
1869 rcSep = lpBand->rcBand;
1870 if (infoPtr->dwStyle & CCS_VERT) {
1871 rcSep.bottom += SEP_WIDTH_SIZE;
1872 DrawEdge (hdc, &rcSep, EDGE_ETCHED, BF_BOTTOM);
1875 rcSep.right += SEP_WIDTH_SIZE;
1876 DrawEdge (hdc, &rcSep, EDGE_ETCHED, BF_RIGHT);
1878 TRACE("drawing band separator right (%d,%d)-(%d,%d)\n",
1879 rcSep.left, rcSep.top, rcSep.right, rcSep.bottom);
1882 /* draw the actual background */
1883 if (lpBand->clrBack != CLR_NONE)
1884 new = lpBand->clrBack;
1886 new = infoPtr->clrBtnFace;
1887 rect = lpBand->rcBand;
1888 old = SetBkColor (hdc, new);
1889 TRACE("%s backround color=0x%06lx, band (%d,%d)-(%d,%d), clip (%d,%d)-(%d,%d)\n",
1890 (lpBand->clrBack == CLR_NONE) ? "std" : "",
1892 lpBand->rcBand.left,lpBand->rcBand.top,
1893 lpBand->rcBand.right,lpBand->rcBand.bottom,
1894 clip->left, clip->top,
1895 clip->right, clip->bottom);
1896 ExtTextOutA (hdc, 0, 0, ETO_OPAQUE, &rect, NULL, 0, 0);
1897 SetBkColor (hdc, old);
1903 REBAR_InternalHitTest (REBAR_INFO *infoPtr, LPPOINT lpPt, UINT *pFlags, INT *pBand)
1909 GetClientRect (infoPtr->hwndSelf, &rect);
1911 *pFlags = RBHT_NOWHERE;
1912 if (PtInRect (&rect, *lpPt))
1914 if (infoPtr->uNumBands == 0) {
1915 *pFlags = RBHT_NOWHERE;
1922 /* somewhere inside */
1923 infoPtr->ihitBand = -1;
1924 for (iCount = 0; iCount < infoPtr->uNumBands; iCount++) {
1925 lpBand = &infoPtr->bands[iCount];
1926 if (HIDDENBAND(lpBand)) continue;
1927 if (PtInRect (&lpBand->rcBand, *lpPt)) {
1930 if (PtInRect (&lpBand->rcGripper, *lpPt)) {
1931 *pFlags = RBHT_GRABBER;
1932 infoPtr->ihitBand = iCount;
1933 TRACE("ON GRABBER %d\n", iCount);
1936 else if (PtInRect (&lpBand->rcCapImage, *lpPt)) {
1937 *pFlags = RBHT_CAPTION;
1938 TRACE("ON CAPTION %d\n", iCount);
1941 else if (PtInRect (&lpBand->rcCapText, *lpPt)) {
1942 *pFlags = RBHT_CAPTION;
1943 TRACE("ON CAPTION %d\n", iCount);
1946 else if (PtInRect (&lpBand->rcChild, *lpPt)) {
1947 *pFlags = RBHT_CLIENT;
1948 TRACE("ON CLIENT %d\n", iCount);
1952 *pFlags = RBHT_NOWHERE;
1953 TRACE("NOWHERE %d\n", iCount);
1959 *pFlags = RBHT_NOWHERE;
1968 *pFlags = RBHT_NOWHERE;
1975 TRACE("flags=0x%X\n", *pFlags);
1981 REBAR_Shrink (REBAR_INFO *infoPtr, REBAR_BAND *band, INT movement, INT i)
1982 /* Function: This attempts to shrink the given band by the */
1983 /* the amount in "movement". A shrink to the left is indi- */
1984 /* cated by "movement" being negative. "i" is merely the */
1985 /* band index for trace messages. */
1987 INT Leadjust, Readjust, avail, ret;
1989 /* Note: a left drag is indicated by "movement" being negative. */
1990 /* Similarly, a right drag is indicated by "movement" */
1991 /* being positive. "movement" should never be 0, but if */
1992 /* it is then the band does not move. */
1994 avail = rcBw(band) - band->lcx;
1996 /* now compute the Left End adjustment factor and Right End */
1997 /* adjustment factor. They may be different if shrinking. */
1999 /* if this band is not shrinkable, then just move it */
2000 Leadjust = Readjust = movement;
2006 if (avail <= abs(movement)) {
2007 Readjust = movement;
2008 Leadjust = movement + avail;
2012 Readjust = movement;
2019 if (avail <= abs(movement)) {
2020 Leadjust = movement;
2021 Readjust = movement - avail;
2025 Leadjust = movement;
2032 /* Reasonability Check */
2033 if (rcBlt(band) + Leadjust < 0) {
2034 ERR("adjustment will fail, band %d: left=%d, right=%d, move=%d, rtn=%d\n",
2035 i, Leadjust, Readjust, movement, ret);
2038 LEADJ(band, Leadjust);
2039 READJ(band, Readjust);
2041 TRACE("band %d: left=%d, right=%d, move=%d, rtn=%d, rcBand=(%d,%d)-(%d,%d)\n",
2042 i, Leadjust, Readjust, movement, ret,
2043 band->rcBand.left, band->rcBand.top,
2044 band->rcBand.right, band->rcBand.bottom);
2050 REBAR_HandleLRDrag (REBAR_INFO *infoPtr, POINTS *ptsmove)
2051 /* Function: This will implement the functionality of a */
2052 /* Gripper drag within a row. It will not implement "out- */
2053 /* of-row" drags. (They are detected and handled in */
2054 /* REBAR_MouseMove.) */
2055 /* **** FIXME Switching order of bands in a row not **** */
2056 /* **** yet implemented. **** */
2058 REBAR_BAND *hitBand, *band, *mindBand, *maxdBand;
2060 INT imindBand = -1, imaxdBand, ihitBand, i, movement;
2061 INT RHeaderSum = 0, LHeaderSum = 0;
2064 /* on first significant mouse movement, issue notify */
2066 if (!(infoPtr->fStatus & BEGIN_DRAG_ISSUED)) {
2067 if (REBAR_Notify_NMREBAR (infoPtr, -1, RBN_BEGINDRAG)) {
2068 /* Notify returned TRUE - abort drag */
2069 infoPtr->dragStart.x = 0;
2070 infoPtr->dragStart.y = 0;
2071 infoPtr->dragNow = infoPtr->dragStart;
2072 infoPtr->ihitBand = -1;
2076 infoPtr->fStatus |= BEGIN_DRAG_ISSUED;
2079 ihitBand = infoPtr->ihitBand;
2080 hitBand = &infoPtr->bands[ihitBand];
2081 imaxdBand = ihitBand; /* to suppress warning message */
2083 /* find all the bands in the row of the one whose Gripper was seized */
2084 for (i=0; i<infoPtr->uNumBands; i++) {
2085 band = &infoPtr->bands[i];
2086 if (HIDDENBAND(band)) continue;
2087 if (band->iRow == hitBand->iRow) {
2089 if (imindBand == -1) imindBand = i;
2090 /* minimum size of each band is size of header plus */
2091 /* size of minimum child plus offset of child from header plus */
2092 /* a one to separate each band. */
2094 LHeaderSum += (band->lcx + SEP_WIDTH);
2096 RHeaderSum += (band->lcx + SEP_WIDTH);
2100 if (RHeaderSum) RHeaderSum -= SEP_WIDTH; /* no separator afterlast band */
2102 mindBand = &infoPtr->bands[imindBand];
2103 maxdBand = &infoPtr->bands[imaxdBand];
2105 if (imindBand == imaxdBand) return; /* nothing to drag agains */
2106 if (imindBand == ihitBand) return; /* first band in row, cant drag */
2108 /* limit movement to inside adjustable bands - Left */
2109 if ( (ptsmove->x < mindBand->rcBand.left) ||
2110 (ptsmove->x > maxdBand->rcBand.right) ||
2111 (ptsmove->y < mindBand->rcBand.top) ||
2112 (ptsmove->y > maxdBand->rcBand.bottom))
2113 return; /* should swap bands */
2115 if (infoPtr->dwStyle & CCS_VERT)
2116 movement = ptsmove->y - ((hitBand->rcBand.top+REBAR_PRE_GRIPPER) -
2117 infoPtr->ihitoffset);
2119 movement = ptsmove->x - ((hitBand->rcBand.left+REBAR_PRE_GRIPPER) -
2120 infoPtr->ihitoffset);
2121 infoPtr->dragNow = *ptsmove;
2123 TRACE("before: movement=%d (%d,%d), imindBand=%d, ihitBand=%d, imaxdBand=%d, LSum=%d, RSum=%d\n",
2124 movement, ptsmove->x, ptsmove->y, imindBand, ihitBand,
2125 imaxdBand, LHeaderSum, RHeaderSum);
2126 REBAR_DumpBand (infoPtr);
2130 /* *** Drag left/up *** */
2131 compress = rcBlt(hitBand) - rcBlt(mindBand) -
2133 if (compress < abs(movement)) {
2134 TRACE("limiting left drag, was %d changed to %d\n",
2135 movement, -compress);
2136 movement = -compress;
2139 for (i=ihitBand; i>=imindBand; i--) {
2140 band = &infoPtr->bands[i];
2141 if (HIDDENBAND(band)) continue;
2142 if (i == ihitBand) {
2143 LEADJ(band, movement)
2146 movement = REBAR_Shrink (infoPtr, band, movement, i);
2147 band->ccx = rcBw(band);
2153 /* *** Drag right/down *** */
2154 compress = rcBrb(maxdBand) - rcBlt(hitBand) -
2156 if (compress < abs(movement)) {
2157 TRACE("limiting right drag, was %d changed to %d\n",
2158 movement, compress);
2159 movement = compress;
2161 for (i=ihitBand-1; i<=imaxdBand; i++) {
2162 band = &infoPtr->bands[i];
2163 if (HIDDENBAND(band)) continue;
2166 READJ(band, movement)
2169 movement = REBAR_Shrink (infoPtr, band, movement, i);
2170 band->ccx = rcBw(band);
2174 /* recompute all rectangles */
2175 if (infoPtr->dwStyle & CCS_VERT) {
2176 REBAR_CalcVertBand (infoPtr, imindBand, imaxdBand+1,
2180 REBAR_CalcHorzBand (infoPtr, imindBand, imaxdBand+1,
2184 TRACE("bands after adjustment, see band # %d, %d\n",
2185 imindBand, imaxdBand);
2186 REBAR_DumpBand (infoPtr);
2189 mindBand->rcBand.left,
2190 mindBand->rcBand.top,
2191 maxdBand->rcBand.right,
2192 maxdBand->rcBand.bottom);
2194 REBAR_MoveChildWindows (infoPtr, imindBand, imaxdBand+1);
2196 InvalidateRect (infoPtr->hwndSelf, &newrect, TRUE);
2197 UpdateWindow (infoPtr->hwndSelf);
2203 /* << REBAR_BeginDrag >> */
2207 REBAR_DeleteBand (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
2209 UINT uBand = (UINT)wParam;
2213 if (uBand >= infoPtr->uNumBands)
2216 TRACE("deleting band %u!\n", uBand);
2217 lpBand = &infoPtr->bands[uBand];
2218 REBAR_Notify_NMREBAR (infoPtr, uBand, RBN_DELETINGBAND);
2220 if (infoPtr->uNumBands == 1) {
2221 TRACE(" simple delete!\n");
2222 if ((lpBand->fMask & RBBIM_CHILD) && lpBand->hwndChild)
2223 childhwnd = lpBand->hwndChild;
2224 COMCTL32_Free (infoPtr->bands);
2225 infoPtr->bands = NULL;
2226 infoPtr->uNumBands = 0;
2229 REBAR_BAND *oldBands = infoPtr->bands;
2230 TRACE("complex delete! [uBand=%u]\n", uBand);
2232 if ((lpBand->fMask & RBBIM_CHILD) && lpBand->hwndChild)
2233 childhwnd = lpBand->hwndChild;
2235 infoPtr->uNumBands--;
2236 infoPtr->bands = COMCTL32_Alloc (sizeof (REBAR_BAND) * infoPtr->uNumBands);
2238 memcpy (&infoPtr->bands[0], &oldBands[0],
2239 uBand * sizeof(REBAR_BAND));
2242 if (uBand < infoPtr->uNumBands) {
2243 memcpy (&infoPtr->bands[uBand], &oldBands[uBand+1],
2244 (infoPtr->uNumBands - uBand) * sizeof(REBAR_BAND));
2247 COMCTL32_Free (oldBands);
2251 ShowWindow (childhwnd, SW_HIDE);
2253 REBAR_Notify_NMREBAR (infoPtr, -1, RBN_DELETEDBAND);
2255 /* if only 1 band left the re-validate to possible eliminate gripper */
2256 if (infoPtr->uNumBands == 1)
2257 REBAR_ValidateBand (infoPtr, &infoPtr->bands[0]);
2259 TRACE("setting NEEDS_LAYOUT\n");
2260 infoPtr->fStatus |= BAND_NEEDS_LAYOUT;
2261 infoPtr->fStatus |= RESIZE_ANYHOW;
2262 REBAR_Layout (infoPtr, NULL, TRUE, FALSE);
2268 /* << REBAR_DragMove >> */
2269 /* << REBAR_EndDrag >> */
2273 REBAR_GetBandBorders (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
2275 LPRECT lpRect = (LPRECT)lParam;
2280 if ((UINT)wParam >= infoPtr->uNumBands)
2283 lpBand = &infoPtr->bands[(UINT)wParam];
2285 /* FIXME - the following values were determined by experimentation */
2286 /* with the REBAR Control Spy. I have guesses as to what the 4 and */
2287 /* 1 are, but I am not sure. There doesn't seem to be any actual */
2288 /* difference in size of the control area with and without the */
2290 if (infoPtr->dwStyle & RBS_BANDBORDERS) {
2291 if (infoPtr->dwStyle & CCS_VERT) {
2293 lpRect->top = lpBand->cxHeader + 4;
2298 lpRect->left = lpBand->cxHeader + 4;
2305 lpRect->left = lpBand->cxHeader;
2311 inline static LRESULT
2312 REBAR_GetBandCount (REBAR_INFO *infoPtr)
2314 TRACE("band count %u!\n", infoPtr->uNumBands);
2316 return infoPtr->uNumBands;
2321 REBAR_GetBandInfoA (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
2323 LPREBARBANDINFOA lprbbi = (LPREBARBANDINFOA)lParam;
2328 if (lprbbi->cbSize < REBARBANDINFO_V3_SIZEA)
2330 if ((UINT)wParam >= infoPtr->uNumBands)
2333 TRACE("index %u\n", (UINT)wParam);
2335 /* copy band information */
2336 lpBand = &infoPtr->bands[(UINT)wParam];
2338 if (lprbbi->fMask & RBBIM_STYLE)
2339 lprbbi->fStyle = lpBand->fStyle;
2341 if (lprbbi->fMask & RBBIM_COLORS) {
2342 lprbbi->clrFore = lpBand->clrFore;
2343 lprbbi->clrBack = lpBand->clrBack;
2344 if (lprbbi->clrBack == CLR_NONE)
2345 lprbbi->clrBack = infoPtr->clrBtnFace;
2348 if ((lprbbi->fMask & RBBIM_TEXT) && (lprbbi->lpText)) {
2349 if (lpBand->lpText && (lpBand->fMask & RBBIM_TEXT))
2351 if (!WideCharToMultiByte( CP_ACP, 0, lpBand->lpText, -1,
2352 lprbbi->lpText, lprbbi->cch, NULL, NULL ))
2353 lprbbi->lpText[lprbbi->cch-1] = 0;
2356 *lprbbi->lpText = 0;
2359 if (lprbbi->fMask & RBBIM_IMAGE) {
2360 if (lpBand->fMask & RBBIM_IMAGE)
2361 lprbbi->iImage = lpBand->iImage;
2363 lprbbi->iImage = -1;
2366 if (lprbbi->fMask & RBBIM_CHILD)
2367 lprbbi->hwndChild = lpBand->hwndChild;
2369 if (lprbbi->fMask & RBBIM_CHILDSIZE) {
2370 lprbbi->cxMinChild = lpBand->cxMinChild;
2371 lprbbi->cyMinChild = lpBand->cyMinChild;
2372 if (lprbbi->cbSize >= sizeof (REBARBANDINFOA)) {
2373 lprbbi->cyChild = lpBand->cyChild;
2374 lprbbi->cyMaxChild = lpBand->cyMaxChild;
2375 lprbbi->cyIntegral = lpBand->cyIntegral;
2379 if (lprbbi->fMask & RBBIM_SIZE)
2380 lprbbi->cx = lpBand->cx;
2382 if (lprbbi->fMask & RBBIM_BACKGROUND)
2383 lprbbi->hbmBack = lpBand->hbmBack;
2385 if (lprbbi->fMask & RBBIM_ID)
2386 lprbbi->wID = lpBand->wID;
2388 /* check for additional data */
2389 if (lprbbi->cbSize >= sizeof (REBARBANDINFOA)) {
2390 if (lprbbi->fMask & RBBIM_IDEALSIZE)
2391 lprbbi->cxIdeal = lpBand->cxIdeal;
2393 if (lprbbi->fMask & RBBIM_LPARAM)
2394 lprbbi->lParam = lpBand->lParam;
2396 if (lprbbi->fMask & RBBIM_HEADERSIZE)
2397 lprbbi->cxHeader = lpBand->cxHeader;
2400 REBAR_DumpBandInfo (lprbbi);
2407 REBAR_GetBandInfoW (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
2409 LPREBARBANDINFOW lprbbi = (LPREBARBANDINFOW)lParam;
2414 if (lprbbi->cbSize < REBARBANDINFO_V3_SIZEW)
2416 if ((UINT)wParam >= infoPtr->uNumBands)
2419 TRACE("index %u\n", (UINT)wParam);
2421 /* copy band information */
2422 lpBand = &infoPtr->bands[(UINT)wParam];
2424 if (lprbbi->fMask & RBBIM_STYLE)
2425 lprbbi->fStyle = lpBand->fStyle;
2427 if (lprbbi->fMask & RBBIM_COLORS) {
2428 lprbbi->clrFore = lpBand->clrFore;
2429 lprbbi->clrBack = lpBand->clrBack;
2430 if (lprbbi->clrBack == CLR_NONE)
2431 lprbbi->clrBack = infoPtr->clrBtnFace;
2434 if ((lprbbi->fMask & RBBIM_TEXT) && (lprbbi->lpText)) {
2435 if (lpBand->lpText && (lpBand->fMask & RBBIM_TEXT))
2436 lstrcpynW (lprbbi->lpText, lpBand->lpText, lprbbi->cch);
2438 *lprbbi->lpText = 0;
2441 if (lprbbi->fMask & RBBIM_IMAGE) {
2442 if (lpBand->fMask & RBBIM_IMAGE)
2443 lprbbi->iImage = lpBand->iImage;
2445 lprbbi->iImage = -1;
2448 if (lprbbi->fMask & RBBIM_CHILD)
2449 lprbbi->hwndChild = lpBand->hwndChild;
2451 if (lprbbi->fMask & RBBIM_CHILDSIZE) {
2452 lprbbi->cxMinChild = lpBand->cxMinChild;
2453 lprbbi->cyMinChild = lpBand->cyMinChild;
2454 if (lprbbi->cbSize >= sizeof (REBARBANDINFOW)) {
2455 lprbbi->cyChild = lpBand->cyChild;
2456 lprbbi->cyMaxChild = lpBand->cyMaxChild;
2457 lprbbi->cyIntegral = lpBand->cyIntegral;
2461 if (lprbbi->fMask & RBBIM_SIZE)
2462 lprbbi->cx = lpBand->cx;
2464 if (lprbbi->fMask & RBBIM_BACKGROUND)
2465 lprbbi->hbmBack = lpBand->hbmBack;
2467 if (lprbbi->fMask & RBBIM_ID)
2468 lprbbi->wID = lpBand->wID;
2470 /* check for additional data */
2471 if (lprbbi->cbSize >= sizeof (REBARBANDINFOW)) {
2472 if (lprbbi->fMask & RBBIM_IDEALSIZE)
2473 lprbbi->cxIdeal = lpBand->cxIdeal;
2475 if (lprbbi->fMask & RBBIM_LPARAM)
2476 lprbbi->lParam = lpBand->lParam;
2478 if (lprbbi->fMask & RBBIM_HEADERSIZE)
2479 lprbbi->cxHeader = lpBand->cxHeader;
2482 REBAR_DumpBandInfo ((LPREBARBANDINFOA)lprbbi);
2489 REBAR_GetBarHeight (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
2493 nHeight = (infoPtr->dwStyle & CCS_VERT) ? infoPtr->calcSize.cx : infoPtr->calcSize.cy;
2495 TRACE("height = %d\n", nHeight);
2502 REBAR_GetBarInfo (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
2504 LPREBARINFO lpInfo = (LPREBARINFO)lParam;
2509 if (lpInfo->cbSize < sizeof (REBARINFO))
2512 TRACE("getting bar info!\n");
2514 if (infoPtr->himl) {
2515 lpInfo->himl = infoPtr->himl;
2516 lpInfo->fMask |= RBIM_IMAGELIST;
2523 inline static LRESULT
2524 REBAR_GetBkColor (REBAR_INFO *infoPtr)
2526 COLORREF clr = infoPtr->clrBk;
2528 if (clr == CLR_NONE)
2529 clr = infoPtr->clrBtnFace;
2531 TRACE("background color 0x%06lx!\n", clr);
2537 /* << REBAR_GetColorScheme >> */
2538 /* << REBAR_GetDropTarget >> */
2542 REBAR_GetPalette (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
2544 FIXME("empty stub!\n");
2551 REBAR_GetRect (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
2553 INT iBand = (INT)wParam;
2554 LPRECT lprc = (LPRECT)lParam;
2557 if ((iBand < 0) && ((UINT)iBand >= infoPtr->uNumBands))
2562 lpBand = &infoPtr->bands[iBand];
2563 CopyRect (lprc, &lpBand->rcBand);
2565 TRACE("band %d, (%d,%d)-(%d,%d)\n", iBand,
2566 lprc->left, lprc->top, lprc->right, lprc->bottom);
2572 inline static LRESULT
2573 REBAR_GetRowCount (REBAR_INFO *infoPtr)
2575 TRACE("%u\n", infoPtr->uNumRows);
2577 return infoPtr->uNumRows;
2582 REBAR_GetRowHeight (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
2584 INT iRow = (INT)wParam;
2589 for (i=0; i<infoPtr->uNumBands; i++) {
2590 lpBand = &infoPtr->bands[i];
2591 if (HIDDENBAND(lpBand)) continue;
2592 if (lpBand->iRow != iRow) continue;
2593 if (infoPtr->dwStyle & CCS_VERT)
2594 j = lpBand->rcBand.right - lpBand->rcBand.left;
2596 j = lpBand->rcBand.bottom - lpBand->rcBand.top;
2597 if (j > ret) ret = j;
2600 TRACE("row %d, height %d\n", iRow, ret);
2606 inline static LRESULT
2607 REBAR_GetTextColor (REBAR_INFO *infoPtr)
2609 TRACE("text color 0x%06lx!\n", infoPtr->clrText);
2611 return infoPtr->clrText;
2615 inline static LRESULT
2616 REBAR_GetToolTips (REBAR_INFO *infoPtr)
2618 return infoPtr->hwndToolTip;
2622 inline static LRESULT
2623 REBAR_GetUnicodeFormat (REBAR_INFO *infoPtr)
2625 TRACE("%s hwnd=0x%x\n",
2626 infoPtr->bUnicode ? "TRUE" : "FALSE", infoPtr->hwndSelf);
2628 return infoPtr->bUnicode;
2632 inline static LRESULT
2633 REBAR_GetVersion (REBAR_INFO *infoPtr)
2635 TRACE("version %d\n", infoPtr->iVersion);
2636 return infoPtr->iVersion;
2641 REBAR_HitTest (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
2643 LPRBHITTESTINFO lprbht = (LPRBHITTESTINFO)lParam;
2648 REBAR_InternalHitTest (infoPtr, &lprbht->pt, &lprbht->flags, &lprbht->iBand);
2650 return lprbht->iBand;
2655 REBAR_IdToIndex (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
2659 if (infoPtr == NULL)
2662 if (infoPtr->uNumBands < 1)
2665 for (i = 0; i < infoPtr->uNumBands; i++) {
2666 if (infoPtr->bands[i].wID == (UINT)wParam) {
2667 TRACE("id %u is band %u found!\n", (UINT)wParam, i);
2672 TRACE("id %u is not found\n", (UINT)wParam);
2678 REBAR_InsertBandA (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
2680 LPREBARBANDINFOA lprbbi = (LPREBARBANDINFOA)lParam;
2681 UINT uIndex = (UINT)wParam;
2684 if (infoPtr == NULL)
2688 if (lprbbi->cbSize < REBARBANDINFO_V3_SIZEA)
2691 /* trace the index as signed to see the -1 */
2692 TRACE("insert band at %d!\n", (INT)uIndex);
2693 REBAR_DumpBandInfo (lprbbi);
2695 if (infoPtr->uNumBands == 0) {
2696 infoPtr->bands = (REBAR_BAND *)COMCTL32_Alloc (sizeof (REBAR_BAND));
2700 REBAR_BAND *oldBands = infoPtr->bands;
2702 (REBAR_BAND *)COMCTL32_Alloc ((infoPtr->uNumBands+1)*sizeof(REBAR_BAND));
2703 if (((INT)uIndex == -1) || (uIndex > infoPtr->uNumBands))
2704 uIndex = infoPtr->uNumBands;
2706 /* pre insert copy */
2708 memcpy (&infoPtr->bands[0], &oldBands[0],
2709 uIndex * sizeof(REBAR_BAND));
2713 if (uIndex < infoPtr->uNumBands - 1) {
2714 memcpy (&infoPtr->bands[uIndex+1], &oldBands[uIndex],
2715 (infoPtr->uNumBands - uIndex - 1) * sizeof(REBAR_BAND));
2718 COMCTL32_Free (oldBands);
2721 infoPtr->uNumBands++;
2723 TRACE("index %u!\n", uIndex);
2725 /* initialize band (infoPtr->bands[uIndex])*/
2726 lpBand = &infoPtr->bands[uIndex];
2728 lpBand->fStatus = 0;
2729 lpBand->clrFore = infoPtr->clrText;
2730 lpBand->clrBack = infoPtr->clrBk;
2731 lpBand->hwndChild = 0;
2732 lpBand->hwndPrevParent = 0;
2734 REBAR_CommonSetupBand (infoPtr->hwndSelf, lprbbi, lpBand);
2735 lpBand->lpText = NULL;
2736 if ((lprbbi->fMask & RBBIM_TEXT) && (lprbbi->lpText)) {
2737 INT len = MultiByteToWideChar( CP_ACP, 0, lprbbi->lpText, -1, NULL, 0 );
2739 lpBand->lpText = (LPWSTR)COMCTL32_Alloc (len*sizeof(WCHAR));
2740 MultiByteToWideChar( CP_ACP, 0, lprbbi->lpText, -1, lpBand->lpText, len );
2744 REBAR_ValidateBand (infoPtr, lpBand);
2745 /* On insert of second band, revalidate band 1 to possible add gripper */
2746 if (infoPtr->uNumBands == 2)
2747 REBAR_ValidateBand (infoPtr, &infoPtr->bands[0]);
2749 REBAR_DumpBand (infoPtr);
2751 REBAR_Layout (infoPtr, NULL, TRUE, FALSE);
2758 REBAR_InsertBandW (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
2760 LPREBARBANDINFOW lprbbi = (LPREBARBANDINFOW)lParam;
2761 UINT uIndex = (UINT)wParam;
2764 if (infoPtr == NULL)
2768 if (lprbbi->cbSize < REBARBANDINFO_V3_SIZEW)
2771 /* trace the index as signed to see the -1 */
2772 TRACE("insert band at %d!\n", (INT)uIndex);
2773 REBAR_DumpBandInfo ((LPREBARBANDINFOA)lprbbi);
2775 if (infoPtr->uNumBands == 0) {
2776 infoPtr->bands = (REBAR_BAND *)COMCTL32_Alloc (sizeof (REBAR_BAND));
2780 REBAR_BAND *oldBands = infoPtr->bands;
2782 (REBAR_BAND *)COMCTL32_Alloc ((infoPtr->uNumBands+1)*sizeof(REBAR_BAND));
2783 if (((INT)uIndex == -1) || (uIndex > infoPtr->uNumBands))
2784 uIndex = infoPtr->uNumBands;
2786 /* pre insert copy */
2788 memcpy (&infoPtr->bands[0], &oldBands[0],
2789 uIndex * sizeof(REBAR_BAND));
2793 if (uIndex < infoPtr->uNumBands - 1) {
2794 memcpy (&infoPtr->bands[uIndex+1], &oldBands[uIndex],
2795 (infoPtr->uNumBands - uIndex - 1) * sizeof(REBAR_BAND));
2798 COMCTL32_Free (oldBands);
2801 infoPtr->uNumBands++;
2803 TRACE("index %u!\n", uIndex);
2805 /* initialize band (infoPtr->bands[uIndex])*/
2806 lpBand = &infoPtr->bands[uIndex];
2808 lpBand->fStatus = 0;
2809 lpBand->clrFore = infoPtr->clrText;
2810 lpBand->clrBack = infoPtr->clrBk;
2811 lpBand->hwndChild = 0;
2812 lpBand->hwndPrevParent = 0;
2814 REBAR_CommonSetupBand (infoPtr->hwndSelf, (LPREBARBANDINFOA)lprbbi, lpBand);
2815 lpBand->lpText = NULL;
2816 if ((lprbbi->fMask & RBBIM_TEXT) && (lprbbi->lpText)) {
2817 INT len = lstrlenW (lprbbi->lpText);
2819 lpBand->lpText = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
2820 strcpyW (lpBand->lpText, lprbbi->lpText);
2824 REBAR_ValidateBand (infoPtr, lpBand);
2825 /* On insert of second band, revalidate band 1 to possible add gripper */
2826 if (infoPtr->uNumBands == 2)
2827 REBAR_ValidateBand (infoPtr, &infoPtr->bands[0]);
2829 REBAR_DumpBand (infoPtr);
2831 REBAR_Layout (infoPtr, NULL, TRUE, FALSE);
2838 REBAR_MaximizeBand (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
2840 FIXME("(uBand = %u fIdeal = %s) stub\n",
2841 (UINT)wParam, lParam ? "TRUE" : "FALSE");
2849 REBAR_MinimizeBand (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
2851 REBAR_BAND *band, *lpBand;
2852 UINT uBand = (UINT) wParam;
2854 INT imindBand, imaxdBand, iprevBand, startBand, endBand;
2857 /* A "minimize" band is equivalent to "dragging" the gripper
2858 * of than band to the right till the band is only the size
2863 if ((infoPtr->uNumBands == 0) ||
2864 ((INT)uBand < 0) || (uBand >= infoPtr->uNumBands)) {
2866 ERR("Illegal MinimizeBand, requested=%d, current band count=%d\n",
2867 (INT)uBand, infoPtr->uNumBands);
2871 /* compute amount of movement and validate */
2872 lpBand = &infoPtr->bands[uBand];
2874 if (infoPtr->dwStyle & CCS_VERT)
2875 movement = lpBand->rcBand.bottom - lpBand->rcBand.top -
2878 movement = lpBand->rcBand.right - lpBand->rcBand.left -
2881 ERR("something is wrong, band=(%d,%d)-(%d,%d), cxheader=%d\n",
2882 lpBand->rcBand.left, lpBand->rcBand.top,
2883 lpBand->rcBand.right, lpBand->rcBand.bottom,
2890 iprevBand = -1; /* to suppress warning message */
2892 /* find the first band in row of the one whose is being minimized */
2893 for (i=0; i<infoPtr->uNumBands; i++) {
2894 band = &infoPtr->bands[i];
2895 if (HIDDENBAND(band)) continue;
2896 if (band->iRow == lpBand->iRow) {
2898 if (imindBand == -1) imindBand = i;
2902 /* if the selected band is first in row then need to expand */
2903 /* next visible band */
2904 if (imindBand == uBand) {
2906 movement = -movement;
2907 /* find the first visible band to the right of the selected band */
2908 for (i=uBand+1; i<=imaxdBand; i++) {
2909 band = &infoPtr->bands[i];
2910 if (!HIDDENBAND(band)) {
2912 LEADJ(band, movement);
2913 band->ccx = rcBw(band);
2917 /* what case is this */
2918 if (iprevBand == -1) {
2919 ERR("no previous visible band\n");
2923 endBand = iprevBand;
2925 lpBand->rcBand.left,
2928 band->rcBand.bottom);
2930 /* otherwise expand previous visible band */
2933 /* find the first visible band to the left of the selected band */
2934 for (i=uBand-1; i>=imindBand; i--) {
2935 band = &infoPtr->bands[i];
2936 if (!HIDDENBAND(band)) {
2938 READJ(band, movement);
2939 band->ccx = rcBw(band);
2943 /* what case is this */
2944 if (iprevBand == -1) {
2945 ERR("no previous visible band\n");
2948 startBand = iprevBand;
2953 lpBand->rcBand.right,
2954 lpBand->rcBand.bottom);
2957 REBAR_Shrink (infoPtr, lpBand, movement, uBand);
2959 /* recompute all rectangles */
2960 if (infoPtr->dwStyle & CCS_VERT) {
2961 REBAR_CalcVertBand (infoPtr, startBand, endBand+1,
2965 REBAR_CalcHorzBand (infoPtr, startBand, endBand+1,
2969 TRACE("bands after minimize, see band # %d, %d\n",
2970 startBand, endBand);
2971 REBAR_DumpBand (infoPtr);
2973 REBAR_MoveChildWindows (infoPtr, startBand, endBand+1);
2975 InvalidateRect (infoPtr->hwndSelf, &newrect, TRUE);
2976 UpdateWindow (infoPtr->hwndSelf);
2982 REBAR_MoveBand (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
2984 REBAR_BAND *oldBands = infoPtr->bands;
2986 UINT uFrom = (UINT)wParam;
2987 UINT uTo = (UINT)lParam;
2990 if ((infoPtr->uNumBands == 0) ||
2991 ((INT)uFrom < 0) || (uFrom >= infoPtr->uNumBands) ||
2992 ((INT)uTo < 0) || (uTo >= infoPtr->uNumBands)) {
2994 ERR("Illegal MoveBand, from=%d, to=%d, current band count=%d\n",
2995 (INT)uFrom, (INT)uTo, infoPtr->uNumBands);
2999 /* save one to be moved */
3000 memcpy (&holder, &oldBands[uFrom], sizeof(REBAR_BAND));
3002 /* close up rest of bands (psuedo delete) */
3003 if (uFrom < infoPtr->uNumBands - 1) {
3004 memcpy (&oldBands[uFrom], &oldBands[uFrom+1],
3005 (infoPtr->uNumBands - uFrom - 1) * sizeof(REBAR_BAND));
3008 /* allocate new space and copy rest of bands into it */
3010 (REBAR_BAND *)COMCTL32_Alloc ((infoPtr->uNumBands)*sizeof(REBAR_BAND));
3012 /* pre insert copy */
3014 memcpy (&infoPtr->bands[0], &oldBands[0],
3015 uTo * sizeof(REBAR_BAND));
3018 /* set moved band */
3019 memcpy (&infoPtr->bands[uTo], &holder, sizeof(REBAR_BAND));
3022 if (uTo < infoPtr->uNumBands - 1) {
3023 memcpy (&infoPtr->bands[uTo+1], &oldBands[uTo],
3024 (infoPtr->uNumBands - uTo - 1) * sizeof(REBAR_BAND));
3027 COMCTL32_Free (oldBands);
3029 TRACE("moved band %d to index %d\n", uFrom, uTo);
3030 REBAR_DumpBand (infoPtr);
3032 infoPtr->fStatus |= BAND_NEEDS_LAYOUT;
3033 /* **************************************************** */
3035 /* We do not do a REBAR_Layout here because the native */
3036 /* control does not do that. The actual layout and */
3037 /* repaint is done by the *next* real action, ex.: */
3038 /* RB_INSERTBAND, RB_DELETEBAND, RB_SIZETORECT, etc. */
3040 /* **************************************************** */
3047 REBAR_SetBandInfoA (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3049 LPREBARBANDINFOA lprbbi = (LPREBARBANDINFOA)lParam;
3054 if (lprbbi->cbSize < REBARBANDINFO_V3_SIZEA)
3056 if ((UINT)wParam >= infoPtr->uNumBands)
3059 TRACE("index %u\n", (UINT)wParam);
3060 REBAR_DumpBandInfo (lprbbi);
3062 /* set band information */
3063 lpBand = &infoPtr->bands[(UINT)wParam];
3065 REBAR_CommonSetupBand (infoPtr->hwndSelf, lprbbi, lpBand);
3066 if (lprbbi->fMask & RBBIM_TEXT) {
3067 if (lpBand->lpText) {
3068 COMCTL32_Free (lpBand->lpText);
3069 lpBand->lpText = NULL;
3071 if (lprbbi->lpText) {
3072 INT len = MultiByteToWideChar( CP_ACP, 0, lprbbi->lpText, -1, NULL, 0 );
3073 lpBand->lpText = (LPWSTR)COMCTL32_Alloc (len*sizeof(WCHAR));
3074 MultiByteToWideChar( CP_ACP, 0, lprbbi->lpText, -1, lpBand->lpText, len );
3078 REBAR_ValidateBand (infoPtr, lpBand);
3080 REBAR_DumpBand (infoPtr);
3082 if (lprbbi->fMask & (RBBIM_CHILDSIZE | RBBIM_SIZE))
3083 REBAR_Layout (infoPtr, NULL, TRUE, FALSE);
3090 REBAR_SetBandInfoW (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3092 LPREBARBANDINFOW lprbbi = (LPREBARBANDINFOW)lParam;
3097 if (lprbbi->cbSize < REBARBANDINFO_V3_SIZEW)
3099 if ((UINT)wParam >= infoPtr->uNumBands)
3102 TRACE("index %u\n", (UINT)wParam);
3103 REBAR_DumpBandInfo ((LPREBARBANDINFOA)lprbbi);
3105 /* set band information */
3106 lpBand = &infoPtr->bands[(UINT)wParam];
3108 REBAR_CommonSetupBand (infoPtr->hwndSelf, (LPREBARBANDINFOA)lprbbi, lpBand);
3109 if (lprbbi->fMask & RBBIM_TEXT) {
3110 if (lpBand->lpText) {
3111 COMCTL32_Free (lpBand->lpText);
3112 lpBand->lpText = NULL;
3114 if (lprbbi->lpText) {
3115 INT len = lstrlenW (lprbbi->lpText);
3116 lpBand->lpText = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
3117 strcpyW (lpBand->lpText, lprbbi->lpText);
3121 REBAR_ValidateBand (infoPtr, lpBand);
3123 REBAR_DumpBand (infoPtr);
3125 if (lprbbi->fMask & (RBBIM_CHILDSIZE | RBBIM_SIZE))
3126 REBAR_Layout (infoPtr, NULL, TRUE, FALSE);
3133 REBAR_SetBarInfo (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3135 LPREBARINFO lpInfo = (LPREBARINFO)lParam;
3142 if (lpInfo->cbSize < sizeof (REBARINFO))
3145 TRACE("setting bar info!\n");
3147 if (lpInfo->fMask & RBIM_IMAGELIST) {
3148 infoPtr->himl = lpInfo->himl;
3149 if (infoPtr->himl) {
3151 ImageList_GetIconSize (infoPtr->himl, &cx, &cy);
3152 infoPtr->imageSize.cx = cx;
3153 infoPtr->imageSize.cy = cy;
3156 infoPtr->imageSize.cx = 0;
3157 infoPtr->imageSize.cy = 0;
3159 TRACE("new image cx=%ld, cy=%ld\n", infoPtr->imageSize.cx,
3160 infoPtr->imageSize.cy);
3163 /* revalidate all bands to reset flags for images in headers of bands */
3164 for (i=0; i<infoPtr->uNumBands; i++) {
3165 lpBand = &infoPtr->bands[i];
3166 REBAR_ValidateBand (infoPtr, lpBand);
3174 REBAR_SetBkColor (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3178 clrTemp = infoPtr->clrBk;
3179 infoPtr->clrBk = (COLORREF)lParam;
3181 TRACE("background color 0x%06lx!\n", infoPtr->clrBk);
3187 /* << REBAR_SetColorScheme >> */
3188 /* << REBAR_SetPalette >> */
3192 REBAR_SetParent (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3194 HWND hwndTemp = infoPtr->hwndNotify;
3196 infoPtr->hwndNotify = (HWND)wParam;
3198 return (LRESULT)hwndTemp;
3203 REBAR_SetTextColor (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3207 clrTemp = infoPtr->clrText;
3208 infoPtr->clrText = (COLORREF)lParam;
3210 TRACE("text color 0x%06lx!\n", infoPtr->clrText);
3216 /* << REBAR_SetTooltips >> */
3219 inline static LRESULT
3220 REBAR_SetUnicodeFormat (REBAR_INFO *infoPtr, WPARAM wParam)
3222 BOOL bTemp = infoPtr->bUnicode;
3224 TRACE("to %s hwnd=0x%04x, was %s\n",
3225 ((BOOL)wParam) ? "TRUE" : "FALSE", infoPtr->hwndSelf,
3226 (bTemp) ? "TRUE" : "FALSE");
3228 infoPtr->bUnicode = (BOOL)wParam;
3235 REBAR_SetVersion (REBAR_INFO *infoPtr, INT iVersion)
3237 INT iOldVersion = infoPtr->iVersion;
3239 if (iVersion > COMCTL32_VERSION)
3242 infoPtr->iVersion = iVersion;
3244 TRACE("new version %d\n", iVersion);
3251 REBAR_ShowBand (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3255 if (((INT)wParam < 0) || ((INT)wParam > infoPtr->uNumBands))
3258 lpBand = &infoPtr->bands[(INT)wParam];
3261 TRACE("show band %d\n", (INT)wParam);
3262 lpBand->fStyle = lpBand->fStyle & ~RBBS_HIDDEN;
3263 if (IsWindow (lpBand->hwndChild))
3264 ShowWindow (lpBand->hwndChild, SW_SHOW);
3267 TRACE("hide band %d\n", (INT)wParam);
3268 lpBand->fStyle = lpBand->fStyle | RBBS_HIDDEN;
3269 if (IsWindow (lpBand->hwndChild))
3270 ShowWindow (lpBand->hwndChild, SW_HIDE);
3273 REBAR_Layout (infoPtr, NULL, TRUE, FALSE);
3280 REBAR_SizeToRect (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3282 LPRECT lpRect = (LPRECT)lParam;
3288 TRACE("[%d %d %d %d]\n",
3289 lpRect->left, lpRect->top, lpRect->right, lpRect->bottom);
3291 /* what is going on???? */
3292 GetWindowRect(infoPtr->hwndSelf, &t1);
3293 TRACE("window rect [%d %d %d %d]\n",
3294 t1.left, t1.top, t1.right, t1.bottom);
3295 GetClientRect(infoPtr->hwndSelf, &t1);
3296 TRACE("client rect [%d %d %d %d]\n",
3297 t1.left, t1.top, t1.right, t1.bottom);
3299 /* force full _Layout processing */
3300 TRACE("setting NEEDS_LAYOUT\n");
3301 infoPtr->fStatus |= BAND_NEEDS_LAYOUT;
3302 REBAR_Layout (infoPtr, lpRect, TRUE, FALSE);
3303 InvalidateRect (infoPtr->hwndSelf, NULL, TRUE);
3310 REBAR_Create (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3312 LPCREATESTRUCTA cs = (LPCREATESTRUCTA) lParam;
3315 if (TRACE_ON(rebar)) {
3316 GetWindowRect(infoPtr->hwndSelf, &wnrc1);
3317 GetClientRect(infoPtr->hwndSelf, &clrc1);
3318 TRACE("window=(%d,%d)-(%d,%d) client=(%d,%d)-(%d,%d) cs=(%d,%d %dx%d)\n",
3319 wnrc1.left, wnrc1.top, wnrc1.right, wnrc1.bottom,
3320 clrc1.left, clrc1.top, clrc1.right, clrc1.bottom,
3321 cs->x, cs->y, cs->cx, cs->cy);
3324 if (GetWindowLongA (infoPtr->hwndSelf, GWL_STYLE) & RBS_AUTOSIZE)
3325 FIXME("style RBS_AUTOSIZE set!\n");
3327 TRACE("created!\n");
3333 REBAR_Destroy (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3339 /* free rebar bands */
3340 if ((infoPtr->uNumBands > 0) && infoPtr->bands) {
3341 /* clean up each band */
3342 for (i = 0; i < infoPtr->uNumBands; i++) {
3343 lpBand = &infoPtr->bands[i];
3345 /* delete text strings */
3346 if (lpBand->lpText) {
3347 COMCTL32_Free (lpBand->lpText);
3348 lpBand->lpText = NULL;
3350 /* destroy child window */
3351 DestroyWindow (lpBand->hwndChild);
3354 /* free band array */
3355 COMCTL32_Free (infoPtr->bands);
3356 infoPtr->bands = NULL;
3359 DeleteObject (infoPtr->hcurArrow);
3360 DeleteObject (infoPtr->hcurHorz);
3361 DeleteObject (infoPtr->hcurVert);
3362 DeleteObject (infoPtr->hcurDrag);
3363 SetWindowLongA (infoPtr->hwndSelf, 0, 0);
3365 /* free rebar info data */
3366 COMCTL32_Free (infoPtr);
3367 TRACE("destroyed!\n");
3373 REBAR_EraseBkGnd (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3377 if (GetClipBox ( (HDC)wParam, &cliprect))
3378 return REBAR_InternalEraseBkGnd (infoPtr, wParam, lParam, &cliprect);
3384 REBAR_GetFont (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3386 return (LRESULT)infoPtr->hFont;
3391 REBAR_LButtonDown (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3395 /* If InternalHitTest did not find a hit on the Gripper, */
3396 /* then ignore the button click. */
3397 if (infoPtr->ihitBand == -1) return 0;
3399 SetCapture (infoPtr->hwndSelf);
3401 /* save off the LOWORD and HIWORD of lParam as initial x,y */
3402 lpBand = &infoPtr->bands[infoPtr->ihitBand];
3403 infoPtr->dragStart = MAKEPOINTS(lParam);
3404 infoPtr->dragNow = infoPtr->dragStart;
3405 if (infoPtr->dwStyle & CCS_VERT)
3406 infoPtr->ihitoffset = infoPtr->dragStart.y - (lpBand->rcBand.top+REBAR_PRE_GRIPPER);
3408 infoPtr->ihitoffset = infoPtr->dragStart.x - (lpBand->rcBand.left+REBAR_PRE_GRIPPER);
3415 REBAR_LButtonUp (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3421 /* If InternalHitTest did not find a hit on the Gripper, */
3422 /* then ignore the button click. */
3423 if (infoPtr->ihitBand == -1) return 0;
3425 ihitBand = infoPtr->ihitBand;
3426 infoPtr->dragStart.x = 0;
3427 infoPtr->dragStart.y = 0;
3428 infoPtr->dragNow = infoPtr->dragStart;
3429 infoPtr->ihitBand = -1;
3433 if (infoPtr->fStatus & BEGIN_DRAG_ISSUED) {
3434 REBAR_Notify((NMHDR *) &layout, infoPtr, RBN_LAYOUTCHANGED);
3435 REBAR_Notify_NMREBAR (infoPtr, ihitBand, RBN_ENDDRAG);
3436 infoPtr->fStatus &= ~BEGIN_DRAG_ISSUED;
3439 GetClientRect(infoPtr->hwndSelf, &rect);
3440 InvalidateRect(infoPtr->hwndSelf, NULL, TRUE);
3447 REBAR_MouseMove (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3449 REBAR_BAND *band1, *band2;
3452 /* Validate entry as hit on Gripper has occured */
3453 if (GetCapture() != infoPtr->hwndSelf) return 0;
3454 if (infoPtr->ihitBand == -1) return 0;
3456 ptsmove = MAKEPOINTS(lParam);
3458 /* if mouse did not move much, exit */
3459 if ((abs(ptsmove.x - infoPtr->dragNow.x) <= mindragx) &&
3460 (abs(ptsmove.y - infoPtr->dragNow.y) <= mindragy)) return 0;
3462 band1 = &infoPtr->bands[infoPtr->ihitBand-1];
3463 band2 = &infoPtr->bands[infoPtr->ihitBand];
3465 /* Test for valid drag case - must not be first band in row */
3466 if (infoPtr->dwStyle & CCS_VERT) {
3467 if ((ptsmove.x < band2->rcBand.left) ||
3468 (ptsmove.x > band2->rcBand.right) ||
3469 ((infoPtr->ihitBand > 0) && (band1->iRow != band2->iRow))) {
3470 FIXME("Cannot drag to other rows yet!!\n");
3473 REBAR_HandleLRDrag (infoPtr, &ptsmove);
3477 if ((ptsmove.y < band2->rcBand.top) ||
3478 (ptsmove.y > band2->rcBand.bottom) ||
3479 ((infoPtr->ihitBand > 0) && (band1->iRow != band2->iRow))) {
3480 FIXME("Cannot drag to other rows yet!!\n");
3483 REBAR_HandleLRDrag (infoPtr, &ptsmove);
3490 inline static LRESULT
3491 REBAR_NCCalcSize (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3493 ((LPRECT)lParam)->top += GetSystemMetrics(SM_CYEDGE);
3494 ((LPRECT)lParam)->bottom -= GetSystemMetrics(SM_CYEDGE);
3496 /* While the code below seems to be the reasonable way of */
3497 /* handling the WS_BORDER style, the native version (as */
3498 /* of 4.71 seems to only do the above. Go figure!! */
3500 if (GetWindowLongA (infoPtr->hwndSelf, GWL_STYLE) & WS_BORDER) {
3501 ((LPRECT)lParam)->left += GetSystemMetrics(SM_CXEDGE);
3502 ((LPRECT)lParam)->top += GetSystemMetrics(SM_CYEDGE);
3503 ((LPRECT)lParam)->right -= GetSystemMetrics(SM_CXEDGE);
3504 ((LPRECT)lParam)->bottom -= GetSystemMetrics(SM_CYEDGE);
3513 REBAR_NCCreate (HWND hwnd, WPARAM wParam, LPARAM lParam)
3515 LPCREATESTRUCTA cs = (LPCREATESTRUCTA) lParam;
3516 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
3520 if (infoPtr != NULL) {
3521 ERR("Strange info structure pointer *not* NULL\n");
3525 if (TRACE_ON(rebar)) {
3526 GetWindowRect(hwnd, &wnrc1);
3527 GetClientRect(hwnd, &clrc1);
3528 TRACE("window=(%d,%d)-(%d,%d) client=(%d,%d)-(%d,%d) cs=(%d,%d %dx%d)\n",
3529 wnrc1.left, wnrc1.top, wnrc1.right, wnrc1.bottom,
3530 clrc1.left, clrc1.top, clrc1.right, clrc1.bottom,
3531 cs->x, cs->y, cs->cx, cs->cy);
3534 /* allocate memory for info structure */
3535 infoPtr = (REBAR_INFO *)COMCTL32_Alloc (sizeof(REBAR_INFO));
3536 SetWindowLongA (hwnd, 0, (DWORD)infoPtr);
3538 /* initialize info structure - initial values are 0 */
3539 infoPtr->clrBk = CLR_NONE;
3540 infoPtr->clrText = GetSysColor (COLOR_BTNTEXT);
3541 infoPtr->clrBtnFace = GetSysColor (COLOR_BTNFACE);
3542 infoPtr->ihitBand = -1;
3543 infoPtr->hwndSelf = hwnd;
3544 infoPtr->DoRedraw = TRUE;
3545 infoPtr->hcurArrow = LoadCursorA (0, IDC_ARROWA);
3546 infoPtr->hcurHorz = LoadCursorA (0, IDC_SIZEWEA);
3547 infoPtr->hcurVert = LoadCursorA (0, IDC_SIZENSA);
3548 infoPtr->hcurDrag = LoadCursorA (0, IDC_SIZEA);
3549 infoPtr->bUnicode = IsWindowUnicode (hwnd);
3551 /* issue WM_NOTIFYFORMAT to get unicode status of parent */
3552 i = SendMessageA(REBAR_GetNotifyParent (infoPtr),
3553 WM_NOTIFYFORMAT, hwnd, NF_QUERY);
3554 if ((i < NFR_ANSI) || (i > NFR_UNICODE)) {
3555 ERR("wrong response to WM_NOTIFYFORMAT (%d), assuming ANSI\n",
3559 infoPtr->NtfUnicode = (i == NFR_UNICODE) ? 1 : 0;
3561 /* add necessary styles to the requested styles */
3562 infoPtr->dwStyle = cs->style | WS_VISIBLE | CCS_TOP;
3563 SetWindowLongA (hwnd, GWL_STYLE, infoPtr->dwStyle);
3566 GetSysColor (numerous);
3567 GetSysColorBrush (numerous) (see WM_SYSCOLORCHANGE);
3568 GetStockObject (SYSTEM_FONT);
3569 *SetWindowLong (hwnd, 0, info ptr);
3571 *SetWindowLong (hwnd, GWL_STYLE, style+0x10000001);
3572 WS_VISIBLE = 0x10000000;
3573 CCS_TOP = 0x00000001;
3574 SystemParametersInfo (SPI_GETNONCLIENTMETRICS...);
3575 CreateFontIndirect (lfCaptionFont from above);
3577 SelectObject (hdc, fontabove);
3578 GetTextMetrics (hdc, ); guessing is tmHeight
3579 SelectObject (hdc, oldfont);
3582 MapWindowPoints (0, parent, rectabove, 2);
3585 ClientToScreen (clientrect);
3586 SetWindowPos (hwnd, 0, 0, 0, 0, 0, SWP_NOZORDER);
3593 REBAR_NCHitTest (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3600 LRESULT ret = HTCLIENT;
3603 * Differences from doc at MSDN (as observed with version 4.71 of
3605 * 1. doc says nmmouse.pt is in screen coord, trace shows client coord.
3606 * 2. if band is not identified .dwItemSpec is 0xffffffff.
3607 * 3. native always seems to return HTCLIENT if notify return is 0.
3610 shortpt = MAKEPOINTS (lParam);
3611 POINTSTOPOINT(pt, shortpt);
3613 ScreenToClient (infoPtr->hwndSelf, &clpt);
3614 REBAR_InternalHitTest (infoPtr, &clpt, &scrap,
3615 (INT *)&nmmouse.dwItemSpec);
3616 nmmouse.dwItemData = 0;
3618 nmmouse.dwHitInfo = 0;
3619 if ((i = REBAR_Notify((NMHDR *) &nmmouse, infoPtr, NM_NCHITTEST))) {
3620 TRACE("notify changed return value from %ld to %d\n",
3624 TRACE("returning %ld, client point (%ld,%ld)\n", ret, clpt.x, clpt.y);
3630 REBAR_NCPaint (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3635 if (infoPtr->dwStyle & WS_MINIMIZE)
3636 return 0; /* Nothing to do */
3638 DefWindowProcA (infoPtr->hwndSelf, WM_NCPAINT, wParam, lParam);
3640 if (!(hdc = GetDCEx( infoPtr->hwndSelf, 0, DCX_USESTYLE | DCX_WINDOW )))
3643 if (infoPtr->dwStyle & WS_BORDER) {
3644 GetWindowRect (infoPtr->hwndSelf, &rcWindow);
3645 OffsetRect (&rcWindow, -rcWindow.left, -rcWindow.top);
3646 TRACE("rect (%d,%d)-(%d,%d)\n",
3647 rcWindow.left, rcWindow.top,
3648 rcWindow.right, rcWindow.bottom);
3649 /* see comments in _NCCalcSize for reason this is not done */
3650 /* DrawEdge (hdc, &rcWindow, EDGE_ETCHED, BF_RECT); */
3651 DrawEdge (hdc, &rcWindow, EDGE_ETCHED, BF_TOP | BF_BOTTOM);
3654 ReleaseDC( infoPtr->hwndSelf, hdc );
3661 REBAR_NotifyFormat (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3665 if (lParam == NF_REQUERY) {
3666 i = SendMessageA(REBAR_GetNotifyParent (infoPtr),
3667 WM_NOTIFYFORMAT, infoPtr->hwndSelf, NF_QUERY);
3668 if ((i < NFR_ANSI) || (i > NFR_UNICODE)) {
3669 ERR("wrong response to WM_NOTIFYFORMAT (%d), assuming ANSI\n",
3673 infoPtr->NtfUnicode = (i == NFR_UNICODE) ? 1 : 0;
3676 return (LRESULT)((infoPtr->bUnicode) ? NFR_UNICODE : NFR_ANSI);
3681 REBAR_Paint (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3687 GetClientRect(infoPtr->hwndSelf, &rc);
3688 hdc = wParam==0 ? BeginPaint (infoPtr->hwndSelf, &ps) : (HDC)wParam;
3690 TRACE("painting (%d,%d)-(%d,%d) client (%d,%d)-(%d,%d)\n",
3691 ps.rcPaint.left, ps.rcPaint.top,
3692 ps.rcPaint.right, ps.rcPaint.bottom,
3693 rc.left, rc.top, rc.right, rc.bottom);
3696 /* Erase area of paint if requested */
3697 REBAR_InternalEraseBkGnd (infoPtr, wParam, lParam, &ps.rcPaint);
3700 REBAR_Refresh (infoPtr, hdc);
3702 EndPaint (infoPtr->hwndSelf, &ps);
3708 REBAR_SetCursor (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3713 TRACE("code=0x%X id=0x%X\n", LOWORD(lParam), HIWORD(lParam));
3716 ScreenToClient (infoPtr->hwndSelf, &pt);
3718 REBAR_InternalHitTest (infoPtr, &pt, &flags, NULL);
3720 if (flags == RBHT_GRABBER) {
3721 if ((infoPtr->dwStyle & CCS_VERT) &&
3722 !(infoPtr->dwStyle & RBS_VERTICALGRIPPER))
3723 SetCursor (infoPtr->hcurVert);
3725 SetCursor (infoPtr->hcurHorz);
3727 else if (flags != RBHT_CLIENT)
3728 SetCursor (infoPtr->hcurArrow);
3735 REBAR_SetFont (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3741 infoPtr->hFont = (HFONT)wParam;
3743 /* revalidate all bands to change sizes of text in headers of bands */
3744 for (i=0; i<infoPtr->uNumBands; i++) {
3745 lpBand = &infoPtr->bands[i];
3746 REBAR_ValidateBand (infoPtr, lpBand);
3750 if (LOWORD(lParam)) {
3751 GetClientRect (infoPtr->hwndSelf, &rcClient);
3752 REBAR_Layout (infoPtr, &rcClient, FALSE, TRUE);
3759 inline static LRESULT
3760 REBAR_SetRedraw (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3762 TRACE("set to %s\n", (wParam) ? "TRUE" : "FALSE");
3763 infoPtr->DoRedraw = (BOOL) wParam;
3769 REBAR_Size (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3773 /* auto resize deadlock check */
3774 if (infoPtr->fStatus & AUTO_RESIZE) {
3775 infoPtr->fStatus &= ~AUTO_RESIZE;
3776 TRACE("AUTO_RESIZE was set, reset, fStatus=%08x lparam=%08lx\n",
3777 infoPtr->fStatus, lParam);
3778 if (infoPtr->dwStyle & RBS_AUTOSIZE) {
3779 NMRBAUTOSIZE autosize;
3781 GetClientRect(infoPtr->hwndSelf, &autosize.rcTarget);
3782 autosize.fChanged = 0; /* ??? */
3783 autosize.rcActual = autosize.rcTarget; /* ??? */
3784 REBAR_Notify((NMHDR *) &autosize, infoPtr, RBN_AUTOSIZE);
3785 TRACE("RBN_AUTOSIZE client=%d, lp=%08lx\n",
3786 autosize.rcTarget.bottom, lParam);
3791 GetClientRect (infoPtr->hwndSelf, &rcClient);
3792 if ((lParam == 0) && (rcClient.right == 0) && (rcClient.bottom == 0)) {
3793 /* native control seems to do this */
3794 GetClientRect (GetParent(infoPtr->hwndSelf), &rcClient);
3795 TRACE("sizing rebar, message and client zero, parent client (%d,%d)\n",
3796 rcClient.right, rcClient.bottom);
3799 TRACE("sizing rebar from (%ld,%ld) to (%d,%d), client (%d,%d)\n",
3800 infoPtr->calcSize.cx, infoPtr->calcSize.cy,
3801 LOWORD(lParam), HIWORD(lParam),
3802 rcClient.right, rcClient.bottom);
3805 if ((infoPtr->calcSize.cx != rcClient.right) ||
3806 (infoPtr->calcSize.cy != rcClient.bottom))
3807 infoPtr->fStatus |= BAND_NEEDS_LAYOUT;
3809 REBAR_Layout (infoPtr, &rcClient, TRUE, TRUE);
3810 infoPtr->fStatus &= ~AUTO_RESIZE;
3817 REBAR_StyleChanged (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3819 STYLESTRUCT *ss = (STYLESTRUCT *)lParam;
3821 TRACE("current style=%08lx, styleOld=%08lx, style being set to=%08lx\n",
3822 infoPtr->dwStyle, ss->styleOld, ss->styleNew);
3823 infoPtr->dwStyle = ss->styleNew;
3828 static LRESULT WINAPI
3829 REBAR_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
3831 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
3833 TRACE("hwnd=%x msg=%x wparam=%x lparam=%lx\n",
3834 hwnd, uMsg, /* SPY_GetMsgName(uMsg), */ wParam, lParam);
3835 if (!infoPtr && (uMsg != WM_NCCREATE))
3836 return DefWindowProcA (hwnd, uMsg, wParam, lParam);
3839 /* case RB_BEGINDRAG: */
3842 return REBAR_DeleteBand (infoPtr, wParam, lParam);
3844 /* case RB_DRAGMOVE: */
3845 /* case RB_ENDDRAG: */
3847 case RB_GETBANDBORDERS:
3848 return REBAR_GetBandBorders (infoPtr, wParam, lParam);
3850 case RB_GETBANDCOUNT:
3851 return REBAR_GetBandCount (infoPtr);
3853 case RB_GETBANDINFO: /* obsoleted after IE3, but we have to
3854 support it anyway. */
3855 case RB_GETBANDINFOA:
3856 return REBAR_GetBandInfoA (infoPtr, wParam, lParam);
3858 case RB_GETBANDINFOW:
3859 return REBAR_GetBandInfoW (infoPtr, wParam, lParam);
3861 case RB_GETBARHEIGHT:
3862 return REBAR_GetBarHeight (infoPtr, wParam, lParam);
3865 return REBAR_GetBarInfo (infoPtr, wParam, lParam);
3868 return REBAR_GetBkColor (infoPtr);
3870 /* case RB_GETCOLORSCHEME: */
3871 /* case RB_GETDROPTARGET: */
3874 return REBAR_GetPalette (infoPtr, wParam, lParam);
3877 return REBAR_GetRect (infoPtr, wParam, lParam);
3879 case RB_GETROWCOUNT:
3880 return REBAR_GetRowCount (infoPtr);
3882 case RB_GETROWHEIGHT:
3883 return REBAR_GetRowHeight (infoPtr, wParam, lParam);
3885 case RB_GETTEXTCOLOR:
3886 return REBAR_GetTextColor (infoPtr);
3888 case RB_GETTOOLTIPS:
3889 return REBAR_GetToolTips (infoPtr);
3891 case RB_GETUNICODEFORMAT:
3892 return REBAR_GetUnicodeFormat (infoPtr);
3894 case CCM_GETVERSION:
3895 return REBAR_GetVersion (infoPtr);
3898 return REBAR_HitTest (infoPtr, wParam, lParam);
3901 return REBAR_IdToIndex (infoPtr, wParam, lParam);
3903 case RB_INSERTBANDA:
3904 return REBAR_InsertBandA (infoPtr, wParam, lParam);
3906 case RB_INSERTBANDW:
3907 return REBAR_InsertBandW (infoPtr, wParam, lParam);
3909 case RB_MAXIMIZEBAND:
3910 return REBAR_MaximizeBand (infoPtr, wParam, lParam);
3912 case RB_MINIMIZEBAND:
3913 return REBAR_MinimizeBand (infoPtr, wParam, lParam);
3916 return REBAR_MoveBand (infoPtr, wParam, lParam);
3918 case RB_SETBANDINFOA:
3919 return REBAR_SetBandInfoA (infoPtr, wParam, lParam);
3921 case RB_SETBANDINFOW:
3922 return REBAR_SetBandInfoW (infoPtr, wParam, lParam);
3925 return REBAR_SetBarInfo (infoPtr, wParam, lParam);
3928 return REBAR_SetBkColor (infoPtr, wParam, lParam);
3930 /* case RB_SETCOLORSCHEME: */
3931 /* case RB_SETPALETTE: */
3932 /* return REBAR_GetPalette (infoPtr, wParam, lParam); */
3935 return REBAR_SetParent (infoPtr, wParam, lParam);
3937 case RB_SETTEXTCOLOR:
3938 return REBAR_SetTextColor (infoPtr, wParam, lParam);
3940 /* case RB_SETTOOLTIPS: */
3942 case RB_SETUNICODEFORMAT:
3943 return REBAR_SetUnicodeFormat (infoPtr, wParam);
3945 case CCM_SETVERSION:
3946 return REBAR_SetVersion (infoPtr, (INT)wParam);
3949 return REBAR_ShowBand (infoPtr, wParam, lParam);
3952 return REBAR_SizeToRect (infoPtr, wParam, lParam);
3955 /* Messages passed to parent */
3959 if (infoPtr->NtfUnicode)
3960 return SendMessageW (REBAR_GetNotifyParent (infoPtr),
3961 uMsg, wParam, lParam);
3963 return SendMessageA (REBAR_GetNotifyParent (infoPtr),
3964 uMsg, wParam, lParam);
3967 /* case WM_CHARTOITEM: supported according to ControlSpy */
3970 return REBAR_Create (infoPtr, wParam, lParam);
3973 return REBAR_Destroy (infoPtr, wParam, lParam);
3976 return REBAR_EraseBkGnd (infoPtr, wParam, lParam);
3979 return REBAR_GetFont (infoPtr, wParam, lParam);
3981 /* case WM_LBUTTONDBLCLK: supported according to ControlSpy */
3983 case WM_LBUTTONDOWN:
3984 return REBAR_LButtonDown (infoPtr, wParam, lParam);
3987 return REBAR_LButtonUp (infoPtr, wParam, lParam);
3989 /* case WM_MEASUREITEM: supported according to ControlSpy */
3992 return REBAR_MouseMove (infoPtr, wParam, lParam);
3995 return REBAR_NCCalcSize (infoPtr, wParam, lParam);
3998 return REBAR_NCCreate (hwnd, wParam, lParam);
4001 return REBAR_NCHitTest (infoPtr, wParam, lParam);
4004 return REBAR_NCPaint (infoPtr, wParam, lParam);
4006 case WM_NOTIFYFORMAT:
4007 return REBAR_NotifyFormat (infoPtr, wParam, lParam);
4010 return REBAR_Paint (infoPtr, wParam, lParam);
4012 /* case WM_PALETTECHANGED: supported according to ControlSpy */
4013 /* case WM_PRINTCLIENT: supported according to ControlSpy */
4014 /* case WM_QUERYNEWPALETTE:supported according to ControlSpy */
4015 /* case WM_RBUTTONDOWN: supported according to ControlSpy */
4016 /* case WM_RBUTTONUP: supported according to ControlSpy */
4019 return REBAR_SetCursor (infoPtr, wParam, lParam);
4022 return REBAR_SetFont (infoPtr, wParam, lParam);
4025 return REBAR_SetRedraw (infoPtr, wParam, lParam);
4028 return REBAR_Size (infoPtr, wParam, lParam);
4030 case WM_STYLECHANGED:
4031 return REBAR_StyleChanged (infoPtr, wParam, lParam);
4033 /* case WM_SYSCOLORCHANGE: supported according to ControlSpy */
4034 /* "Applications that have brushes using the existing system colors
4035 should delete those brushes and recreate them using the new
4036 system colors." per MSDN */
4038 /* case WM_VKEYTOITEM: supported according to ControlSpy */
4039 /* case WM_WININICHANGE: */
4042 if (uMsg >= WM_USER)
4043 ERR("unknown msg %04x wp=%08x lp=%08lx\n",
4044 uMsg, wParam, lParam);
4045 return DefWindowProcA (hwnd, uMsg, wParam, lParam);
4052 REBAR_Register (void)
4056 ZeroMemory (&wndClass, sizeof(WNDCLASSA));
4057 wndClass.style = CS_GLOBALCLASS | CS_DBLCLKS;
4058 wndClass.lpfnWndProc = (WNDPROC)REBAR_WindowProc;
4059 wndClass.cbClsExtra = 0;
4060 wndClass.cbWndExtra = sizeof(REBAR_INFO *);
4061 wndClass.hCursor = 0;
4062 wndClass.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1);
4063 wndClass.lpszClassName = REBARCLASSNAMEA;
4065 RegisterClassA (&wndClass);
4067 mindragx = GetSystemMetrics (SM_CXDRAG);
4068 mindragy = GetSystemMetrics (SM_CYDRAG);
4074 REBAR_Unregister (void)
4076 UnregisterClassA (REBARCLASSNAMEA, (HINSTANCE)NULL);