4 * Copyright 1998, 1999 Eric Kohl
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 * This code was audited for completeness against the documented features
23 * of Comctl32.dll version 6.0 on Oct. 19, 2004, by Robert Shearman.
25 * Unless otherwise noted, we believe this code to be complete, as per
26 * the specification mentioned above.
27 * If you discover missing features or bugs please note them below.
53 * - WM_QUERYNEWPALETTE
61 * - NM_RELEASEDCAPTURE
67 * Native uses (on each draw!!) SM_CYBORDER (or SM_CXBORDER for CCS_VERT)
68 * to set the size of the separator width (the value SEP_WIDTH_SIZE
69 * in here). Should be fixed!!
73 * Testing: set to 1 to make background brush *always* green
79 * 2. At "FIXME: problem # 2" WinRAR:
80 * if "#if 1" then last band draws in separate row
81 * if "#if 0" then last band draws in previous row *** just like native ***
87 * 3. REBAR_MoveChildWindows should have a loop because more than
88 * one pass is made (together with the RBN_CHILDSIZEs) is made on
89 * at least RB_INSERTBAND
99 #include "wine/unicode.h"
102 #include "commctrl.h"
103 #include "comctl32.h"
105 #include "tmschema.h"
106 #include "wine/debug.h"
108 WINE_DEFAULT_DEBUG_CHANNEL(rebar);
118 UINT cxMinChild; /* valid if _CHILDSIZE */
119 UINT cyMinChild; /* valid if _CHILDSIZE */
120 UINT cx; /* valid if _SIZE */
123 UINT cyChild; /* valid if _CHILDSIZE */
124 UINT cyMaxChild; /* valid if _CHILDSIZE */
125 UINT cyIntegral; /* valid if _CHILDSIZE */
130 UINT lcx; /* minimum cx for band */
131 UINT ccx; /* current cx for band */
132 UINT hcx; /* maximum cx for band */
133 UINT lcy; /* minimum cy for band */
134 UINT ccy; /* current cy for band */
135 UINT hcy; /* maximum cy for band */
137 SIZE offChild; /* x,y offset if child is not FIXEDSIZE */
139 INT iRow; /* zero-based index of the row this band assigned to */
140 UINT fStatus; /* status flags, reset only by _Validate */
141 UINT fDraw; /* drawing flags, reset only by _Layout */
142 UINT uCDret; /* last return from NM_CUSTOMDRAW */
143 RECT rcoldBand; /* previous calculated band rectangle */
144 RECT rcBand; /* calculated band rectangle */
145 RECT rcGripper; /* calculated gripper rectangle */
146 RECT rcCapImage; /* calculated caption image rectangle */
147 RECT rcCapText; /* calculated caption text rectangle */
148 RECT rcChild; /* calculated child rectangle */
149 RECT rcChevron; /* calculated chevron rectangle */
156 #define HAS_GRIPPER 0x00000001
157 #define HAS_IMAGE 0x00000002
158 #define HAS_TEXT 0x00000004
161 #define DRAW_GRIPPER 0x00000001
162 #define DRAW_IMAGE 0x00000002
163 #define DRAW_TEXT 0x00000004
164 #define DRAW_RIGHTSEP 0x00000010
165 #define DRAW_BOTTOMSEP 0x00000020
166 #define DRAW_CHEVRONHOT 0x00000040
167 #define DRAW_CHEVRONPUSHED 0x00000080
168 #define DRAW_LAST_IN_ROW 0x00000100
169 #define DRAW_FIRST_IN_ROW 0x00000200
170 #define NTF_INVALIDATE 0x01000000
174 COLORREF clrBk; /* background color */
175 COLORREF clrText; /* text color */
176 COLORREF clrBtnText; /* system color for BTNTEXT */
177 COLORREF clrBtnFace; /* system color for BTNFACE */
178 HIMAGELIST himl; /* handle to imagelist */
179 UINT uNumBands; /* # of bands in rebar (first=0, last=uNumBands-1 */
180 UINT uNumRows; /* # of rows of bands (first=1, last=uNumRows */
181 HWND hwndSelf; /* handle of REBAR window itself */
182 HWND hwndToolTip; /* handle to the tool tip control */
183 HWND hwndNotify; /* notification window (parent) */
185 HFONT hFont; /* handle to the rebar's font */
186 SIZE imageSize; /* image size (image list) */
187 DWORD dwStyle; /* window style */
188 DWORD orgStyle; /* original style (dwStyle may change) */
189 SIZE calcSize; /* calculated rebar size */
190 SIZE oldSize; /* previous calculated rebar size */
191 BOOL bUnicode; /* TRUE if parent wants notify in W format */
192 BOOL DoRedraw; /* TRUE to acutally draw bands */
193 UINT fStatus; /* Status flags (see below) */
194 HCURSOR hcurArrow; /* handle to the arrow cursor */
195 HCURSOR hcurHorz; /* handle to the EW cursor */
196 HCURSOR hcurVert; /* handle to the NS cursor */
197 HCURSOR hcurDrag; /* handle to the drag cursor */
198 INT iVersion; /* version number */
199 POINT dragStart; /* x,y of button down */
200 POINT dragNow; /* x,y of this MouseMove */
201 INT iOldBand; /* last band that had the mouse cursor over it */
202 INT ihitoffset; /* offset of hotspot from gripper.left */
203 POINT origin; /* left/upper corner of client */
204 INT ichevronhotBand; /* last band that had a hot chevron */
205 INT iGrabbedBand;/* band number of band whose gripper was grabbed */
207 REBAR_BAND *bands; /* pointer to the array of rebar bands */
211 #define BEGIN_DRAG_ISSUED 0x00000001
212 #define AUTO_RESIZE 0x00000002
213 #define RESIZE_ANYHOW 0x00000004
214 #define NTF_HGHTCHG 0x00000008
215 #define BAND_NEEDS_LAYOUT 0x00000010
216 #define BAND_NEEDS_REDRAW 0x00000020
217 #define CREATE_RUNNING 0x00000040
219 /* used by Windows to mark that the header size has been set by the user and shouldn't be changed */
220 #define RBBS_UNDOC_FIXEDHEADER 0x40000000
222 /* ---- REBAR layout constants. Mostly determined by ---- */
223 /* ---- experiment on WIN 98. ---- */
225 /* Width (or height) of separators between bands (either horz. or */
226 /* vert.). True only if RBS_BANDBORDERS is set */
227 #define SEP_WIDTH_SIZE 2
228 #define SEP_WIDTH ((infoPtr->dwStyle & RBS_BANDBORDERS) ? SEP_WIDTH_SIZE : 0)
230 /* Blank (background color) space between Gripper (if present) */
231 /* and next item (image, text, or window). Always present */
232 #define REBAR_ALWAYS_SPACE 4
234 /* Blank (background color) space after Image (if present). */
235 #define REBAR_POST_IMAGE 2
237 /* Blank (background color) space after Text (if present). */
238 #define REBAR_POST_TEXT 4
240 /* Height of vertical gripper in a CCS_VERT rebar. */
241 #define GRIPPER_HEIGHT 16
243 /* Blank (background color) space before Gripper (if present). */
244 #define REBAR_PRE_GRIPPER 2
246 /* Width (of normal vertical gripper) or height (of horz. gripper) */
248 #define GRIPPER_WIDTH 3
250 /* Width of the chevron button if present */
251 #define CHEVRON_WIDTH 10
253 /* Height of divider for Rebar if not disabled (CCS_NODIVIDER) */
254 /* either top or bottom */
255 #define REBAR_DIVIDER 2
257 /* minimium vertical height of a normal bar */
258 /* or minimum width of a CCS_VERT bar - from experiment on Win2k */
259 #define REBAR_MINSIZE 23
261 /* This is the increment that is used over the band height */
262 #define REBARSPACE(a) ((a->fStyle & RBBS_CHILDEDGE) ? 2*REBAR_DIVIDER : 0)
264 /* ---- End of REBAR layout constants. ---- */
266 #define RB_GETBANDINFO_OLD (WM_USER+5) /* obsoleted after IE3, but we have to support it anyway */
268 /* The following 6 defines return the proper rcBand element */
269 /* depending on whether CCS_VERT was set. */
270 #define rcBlt(b) ((infoPtr->dwStyle & CCS_VERT) ? b->rcBand.top : b->rcBand.left)
271 #define rcBrb(b) ((infoPtr->dwStyle & CCS_VERT) ? b->rcBand.bottom : b->rcBand.right)
272 #define rcBw(b) ((infoPtr->dwStyle & CCS_VERT) ? (b->rcBand.bottom - b->rcBand.top) : \
273 (b->rcBand.right - b->rcBand.left))
274 #define ircBlt(b) ((infoPtr->dwStyle & CCS_VERT) ? b->rcBand.left : b->rcBand.top)
275 #define ircBrb(b) ((infoPtr->dwStyle & CCS_VERT) ? b->rcBand.right : b->rcBand.bottom)
276 #define ircBw(b) ((infoPtr->dwStyle & CCS_VERT) ? (b->rcBand.right - b->rcBand.left) : \
277 (b->rcBand.bottom - b->rcBand.top))
279 /* The following define determines if a given band is hidden */
280 #define HIDDENBAND(a) (((a)->fStyle & RBBS_HIDDEN) || \
281 ((infoPtr->dwStyle & CCS_VERT) && \
282 ((a)->fStyle & RBBS_NOVERT)))
284 /* The following defines adjust the right or left end of a rectangle */
285 #define READJ(b,i) do { if(infoPtr->dwStyle & CCS_VERT) b->rcBand.bottom+=(i); \
286 else b->rcBand.right += (i); } while(0)
287 #define LEADJ(b,i) do { if(infoPtr->dwStyle & CCS_VERT) b->rcBand.top+=(i); \
288 else b->rcBand.left += (i); } while(0)
291 #define REBAR_GetInfoPtr(wndPtr) ((REBAR_INFO *)GetWindowLongPtrW (hwnd, 0))
293 static LRESULT REBAR_NotifyFormat(REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam);
296 /* "constant values" retrieved when DLL was initialized */
297 /* FIXME we do this when the classes are registered. */
298 static UINT mindragx = 0;
299 static UINT mindragy = 0;
301 static const char * const band_stylename[] = {
302 "RBBS_BREAK", /* 0001 */
303 "RBBS_FIXEDSIZE", /* 0002 */
304 "RBBS_CHILDEDGE", /* 0004 */
305 "RBBS_HIDDEN", /* 0008 */
306 "RBBS_NOVERT", /* 0010 */
307 "RBBS_FIXEDBMP", /* 0020 */
308 "RBBS_VARIABLEHEIGHT", /* 0040 */
309 "RBBS_GRIPPERALWAYS", /* 0080 */
310 "RBBS_NOGRIPPER", /* 0100 */
313 static const char * const band_maskname[] = {
314 "RBBIM_STYLE", /* 0x00000001 */
315 "RBBIM_COLORS", /* 0x00000002 */
316 "RBBIM_TEXT", /* 0x00000004 */
317 "RBBIM_IMAGE", /* 0x00000008 */
318 "RBBIM_CHILD", /* 0x00000010 */
319 "RBBIM_CHILDSIZE", /* 0x00000020 */
320 "RBBIM_SIZE", /* 0x00000040 */
321 "RBBIM_BACKGROUND", /* 0x00000080 */
322 "RBBIM_ID", /* 0x00000100 */
323 "RBBIM_IDEALSIZE", /* 0x00000200 */
324 "RBBIM_LPARAM", /* 0x00000400 */
325 "RBBIM_HEADERSIZE", /* 0x00000800 */
329 static CHAR line[200];
331 static const WCHAR themeClass[] = { 'R','e','b','a','r',0 };
334 REBAR_FmtStyle( UINT style)
339 while (band_stylename[i]) {
340 if (style & (1<<i)) {
341 if (*line != 0) strcat(line, " | ");
342 strcat(line, band_stylename[i]);
351 REBAR_FmtMask( UINT mask)
356 while (band_maskname[i]) {
358 if (*line != 0) strcat(line, " | ");
359 strcat(line, band_maskname[i]);
368 REBAR_DumpBandInfo(LPREBARBANDINFOW pB)
370 if( !TRACE_ON(rebar) ) return;
371 TRACE("band info: ");
372 if (pB->fMask & RBBIM_ID)
373 TRACE("ID=%u, ", pB->wID);
374 TRACE("size=%u, child=%p", pB->cbSize, pB->hwndChild);
375 if (pB->fMask & RBBIM_COLORS)
376 TRACE(", clrF=0x%06x, clrB=0x%06x", pB->clrFore, pB->clrBack);
379 TRACE("band info: mask=0x%08x (%s)\n", pB->fMask, REBAR_FmtMask(pB->fMask));
380 if (pB->fMask & RBBIM_STYLE)
381 TRACE("band info: style=0x%08x (%s)\n", pB->fStyle, REBAR_FmtStyle(pB->fStyle));
382 if (pB->fMask & (RBBIM_SIZE | RBBIM_IDEALSIZE | RBBIM_HEADERSIZE | RBBIM_LPARAM )) {
384 if (pB->fMask & RBBIM_SIZE)
385 TRACE(" cx=%u", pB->cx);
386 if (pB->fMask & RBBIM_IDEALSIZE)
387 TRACE(" xIdeal=%u", pB->cxIdeal);
388 if (pB->fMask & RBBIM_HEADERSIZE)
389 TRACE(" xHeader=%u", pB->cxHeader);
390 if (pB->fMask & RBBIM_LPARAM)
391 TRACE(" lParam=0x%08lx", pB->lParam);
394 if (pB->fMask & RBBIM_CHILDSIZE)
395 TRACE("band info: xMin=%u, yMin=%u, yChild=%u, yMax=%u, yIntgl=%u\n",
397 pB->cyMinChild, pB->cyChild, pB->cyMaxChild, pB->cyIntegral);
401 REBAR_DumpBand (REBAR_INFO *iP)
406 if(! TRACE_ON(rebar) ) return;
408 TRACE("hwnd=%p: color=%08x/%08x, bands=%u, rows=%u, cSize=%d,%d\n",
409 iP->hwndSelf, iP->clrText, iP->clrBk, iP->uNumBands, iP->uNumRows,
410 iP->calcSize.cx, iP->calcSize.cy);
411 TRACE("hwnd=%p: flags=%08x, dragStart=%d,%d, dragNow=%d,%d, iGrabbedBand=%d\n",
412 iP->hwndSelf, iP->fStatus, iP->dragStart.x, iP->dragStart.y,
413 iP->dragNow.x, iP->dragNow.y,
415 TRACE("hwnd=%p: style=%08x, notify in Unicode=%s, redraw=%s\n",
416 iP->hwndSelf, iP->dwStyle, (iP->bUnicode)?"TRUE":"FALSE",
417 (iP->DoRedraw)?"TRUE":"FALSE");
418 for (i = 0; i < iP->uNumBands; i++) {
420 TRACE("band # %u:", i);
421 if (pB->fMask & RBBIM_ID)
422 TRACE(" ID=%u", pB->wID);
423 if (pB->fMask & RBBIM_CHILD)
424 TRACE(" child=%p", pB->hwndChild);
425 if (pB->fMask & RBBIM_COLORS)
426 TRACE(" clrF=0x%06x clrB=0x%06x", pB->clrFore, pB->clrBack);
428 TRACE("band # %u: mask=0x%08x (%s)\n", i, pB->fMask, REBAR_FmtMask(pB->fMask));
429 if (pB->fMask & RBBIM_STYLE)
430 TRACE("band # %u: style=0x%08x (%s)\n",
431 i, pB->fStyle, REBAR_FmtStyle(pB->fStyle));
432 TRACE("band # %u: uMinH=%u xHeader=%u",
433 i, pB->uMinHeight, pB->cxHeader);
434 if (pB->fMask & (RBBIM_SIZE | RBBIM_IDEALSIZE | RBBIM_LPARAM )) {
435 if (pB->fMask & RBBIM_SIZE)
436 TRACE(" cx=%u", pB->cx);
437 if (pB->fMask & RBBIM_IDEALSIZE)
438 TRACE(" xIdeal=%u", pB->cxIdeal);
439 if (pB->fMask & RBBIM_LPARAM)
440 TRACE(" lParam=0x%08lx", pB->lParam);
444 TRACE("band # %u: xMin=%u, yMin=%u, yChild=%u, yMax=%u, yIntgl=%u\n",
445 i, pB->cxMinChild, pB->cyMinChild, pB->cyChild, pB->cyMaxChild, pB->cyIntegral);
446 if (pB->fMask & RBBIM_TEXT)
447 TRACE("band # %u: text=%s\n",
448 i, (pB->lpText) ? debugstr_w(pB->lpText) : "(null)");
449 TRACE("band # %u: lcx=%u, ccx=%u, hcx=%u, lcy=%u, ccy=%u, hcy=%u, offChild=%d,%d\n",
450 i, pB->lcx, pB->ccx, pB->hcx, pB->lcy, pB->ccy, pB->hcy, pB->offChild.cx, pB->offChild.cy);
451 TRACE("band # %u: fStatus=%08x, fDraw=%08x, Band=(%d,%d)-(%d,%d), Grip=(%d,%d)-(%d,%d)\n",
452 i, pB->fStatus, pB->fDraw,
453 pB->rcBand.left, pB->rcBand.top, pB->rcBand.right, pB->rcBand.bottom,
454 pB->rcGripper.left, pB->rcGripper.top, pB->rcGripper.right, pB->rcGripper.bottom);
455 TRACE("band # %u: Img=(%d,%d)-(%d,%d), Txt=(%d,%d)-(%d,%d), Child=(%d,%d)-(%d,%d)\n",
457 pB->rcCapImage.left, pB->rcCapImage.top, pB->rcCapImage.right, pB->rcCapImage.bottom,
458 pB->rcCapText.left, pB->rcCapText.top, pB->rcCapText.right, pB->rcCapText.bottom,
459 pB->rcChild.left, pB->rcChild.top, pB->rcChild.right, pB->rcChild.bottom);
465 REBAR_DrawChevron (HDC hdc, INT left, INT top, INT colorRef)
470 if (!(hPen = CreatePen( PS_SOLID, 1, GetSysColor( colorRef )))) return;
471 hOldPen = SelectObject ( hdc, hPen );
474 MoveToEx (hdc, x, y, NULL);
475 LineTo (hdc, x+5, y++); x++;
476 MoveToEx (hdc, x, y, NULL);
477 LineTo (hdc, x+3, y++); x++;
478 MoveToEx (hdc, x, y, NULL);
479 LineTo (hdc, x+1, y++);
480 SelectObject( hdc, hOldPen );
481 DeleteObject( hPen );
485 REBAR_GetNotifyParent (REBAR_INFO *infoPtr)
489 parent = infoPtr->hwndNotify;
491 parent = GetParent (infoPtr->hwndSelf);
492 owner = GetWindow (infoPtr->hwndSelf, GW_OWNER);
493 if (owner) parent = owner;
500 REBAR_Notify (NMHDR *nmhdr, REBAR_INFO *infoPtr, UINT code)
504 parent = REBAR_GetNotifyParent (infoPtr);
505 nmhdr->idFrom = GetDlgCtrlID (infoPtr->hwndSelf);
506 nmhdr->hwndFrom = infoPtr->hwndSelf;
509 TRACE("window %p, code=%08x, via %s\n", parent, code, (infoPtr->bUnicode)?"Unicode":"ANSI");
511 return SendMessageW(parent, WM_NOTIFY, (WPARAM)nmhdr->idFrom, (LPARAM)nmhdr);
515 REBAR_Notify_NMREBAR (REBAR_INFO *infoPtr, UINT uBand, UINT code)
517 NMREBAR notify_rebar;
520 notify_rebar.dwMask = 0;
522 lpBand = &infoPtr->bands[uBand];
523 if (lpBand->fMask & RBBIM_ID) {
524 notify_rebar.dwMask |= RBNM_ID;
525 notify_rebar.wID = lpBand->wID;
527 if (lpBand->fMask & RBBIM_LPARAM) {
528 notify_rebar.dwMask |= RBNM_LPARAM;
529 notify_rebar.lParam = lpBand->lParam;
531 if (lpBand->fMask & RBBIM_STYLE) {
532 notify_rebar.dwMask |= RBNM_STYLE;
533 notify_rebar.fStyle = lpBand->fStyle;
536 notify_rebar.uBand = uBand;
537 return REBAR_Notify ((NMHDR *)¬ify_rebar, infoPtr, code);
541 REBAR_DrawBand (HDC hdc, REBAR_INFO *infoPtr, REBAR_BAND *lpBand)
546 HTHEME theme = GetWindowTheme (infoPtr->hwndSelf);
548 if (lpBand->fDraw & DRAW_TEXT) {
549 hOldFont = SelectObject (hdc, infoPtr->hFont);
550 oldBkMode = SetBkMode (hdc, TRANSPARENT);
553 /* should test for CDRF_NOTIFYITEMDRAW here */
554 nmcd.dwDrawStage = CDDS_ITEMPREPAINT;
556 nmcd.rc = lpBand->rcBand;
557 nmcd.rc.right = lpBand->rcCapText.right;
558 nmcd.rc.bottom = lpBand->rcCapText.bottom;
559 nmcd.dwItemSpec = lpBand->wID;
561 nmcd.lItemlParam = lpBand->lParam;
562 lpBand->uCDret = REBAR_Notify ((NMHDR *)&nmcd, infoPtr, NM_CUSTOMDRAW);
563 if (lpBand->uCDret == CDRF_SKIPDEFAULT) {
564 if (oldBkMode != TRANSPARENT)
565 SetBkMode (hdc, oldBkMode);
566 SelectObject (hdc, hOldFont);
571 if (lpBand->fDraw & DRAW_GRIPPER)
575 RECT rcGripper = lpBand->rcGripper;
576 int partId = (infoPtr->dwStyle & CCS_VERT) ? RP_GRIPPERVERT : RP_GRIPPER;
577 GetThemeBackgroundExtent (theme, hdc, partId, 0, &rcGripper, &rcGripper);
578 OffsetRect (&rcGripper, lpBand->rcGripper.left - rcGripper.left,
579 lpBand->rcGripper.top - rcGripper.top);
580 DrawThemeBackground (theme, hdc, partId, 0, &rcGripper, NULL);
583 DrawEdge (hdc, &lpBand->rcGripper, BDR_RAISEDINNER, BF_RECT | BF_MIDDLE);
586 /* draw caption image */
587 if (lpBand->fDraw & DRAW_IMAGE) {
591 pt.y = (lpBand->rcCapImage.bottom + lpBand->rcCapImage.top - infoPtr->imageSize.cy)/2;
592 pt.x = (lpBand->rcCapImage.right + lpBand->rcCapImage.left - infoPtr->imageSize.cx)/2;
594 ImageList_Draw (infoPtr->himl, lpBand->iImage, hdc,
599 /* draw caption text */
600 if (lpBand->fDraw & DRAW_TEXT) {
601 /* need to handle CDRF_NEWFONT here */
602 INT oldBkMode = SetBkMode (hdc, TRANSPARENT);
603 COLORREF oldcolor = CLR_NONE;
605 if (lpBand->clrFore != CLR_NONE) {
606 new = (lpBand->clrFore == CLR_DEFAULT) ? infoPtr->clrBtnText :
608 oldcolor = SetTextColor (hdc, new);
610 DrawTextW (hdc, lpBand->lpText, -1, &lpBand->rcCapText,
611 DT_CENTER | DT_VCENTER | DT_SINGLELINE);
612 if (oldBkMode != TRANSPARENT)
613 SetBkMode (hdc, oldBkMode);
614 if (lpBand->clrFore != CLR_NONE)
615 SetTextColor (hdc, oldcolor);
616 SelectObject (hdc, hOldFont);
619 if (!IsRectEmpty(&lpBand->rcChevron))
624 if (lpBand->fDraw & DRAW_CHEVRONPUSHED)
625 stateId = CHEVS_PRESSED;
626 else if (lpBand->fDraw & DRAW_CHEVRONHOT)
629 stateId = CHEVS_NORMAL;
630 DrawThemeBackground (theme, hdc, RP_CHEVRON, stateId, &lpBand->rcChevron, NULL);
634 if (lpBand->fDraw & DRAW_CHEVRONPUSHED)
636 DrawEdge(hdc, &lpBand->rcChevron, BDR_SUNKENOUTER, BF_RECT | BF_MIDDLE);
637 REBAR_DrawChevron(hdc, lpBand->rcChevron.left+1, lpBand->rcChevron.top + 11, COLOR_WINDOWFRAME);
639 else if (lpBand->fDraw & DRAW_CHEVRONHOT)
641 DrawEdge(hdc, &lpBand->rcChevron, BDR_RAISEDINNER, BF_RECT | BF_MIDDLE);
642 REBAR_DrawChevron(hdc, lpBand->rcChevron.left, lpBand->rcChevron.top + 10, COLOR_WINDOWFRAME);
645 REBAR_DrawChevron(hdc, lpBand->rcChevron.left, lpBand->rcChevron.top + 10, COLOR_WINDOWFRAME);
649 if (lpBand->uCDret == (CDRF_NOTIFYPOSTPAINT | CDRF_NOTIFYITEMDRAW)) {
650 nmcd.dwDrawStage = CDDS_ITEMPOSTPAINT;
652 nmcd.rc = lpBand->rcBand;
653 nmcd.rc.right = lpBand->rcCapText.right;
654 nmcd.rc.bottom = lpBand->rcCapText.bottom;
655 nmcd.dwItemSpec = lpBand->wID;
657 nmcd.lItemlParam = lpBand->lParam;
658 lpBand->uCDret = REBAR_Notify ((NMHDR *)&nmcd, infoPtr, NM_CUSTOMDRAW);
664 REBAR_Refresh (REBAR_INFO *infoPtr, HDC hdc)
669 if (!infoPtr->DoRedraw) return;
671 for (i = 0; i < infoPtr->uNumBands; i++) {
672 lpBand = &infoPtr->bands[i];
674 if (HIDDENBAND(lpBand)) continue;
676 /* now draw the band */
677 TRACE("[%p] drawing band %i, flags=%08x\n",
678 infoPtr->hwndSelf, i, lpBand->fDraw);
679 REBAR_DrawBand (hdc, infoPtr, lpBand);
686 REBAR_FixVert (REBAR_INFO *infoPtr, UINT rowstart, UINT rowend,
689 /* Cycle through bands in row and fix height of each band. */
690 /* Also determine whether each band has changed. */
692 /* all bands at desired size. */
693 /* start and end bands are *not* hidden */
698 for (i = (INT)rowstart; i<=(INT)rowend; i++) {
699 lpBand = &infoPtr->bands[i];
700 if (HIDDENBAND(lpBand)) continue;
702 /* adjust height of bands in row to "mcy" value */
703 if (infoPtr->dwStyle & CCS_VERT) {
704 if (lpBand->rcBand.right != lpBand->rcBand.left + mcy)
705 lpBand->rcBand.right = lpBand->rcBand.left + mcy;
708 if (lpBand->rcBand.bottom != lpBand->rcBand.top + mcy)
709 lpBand->rcBand.bottom = lpBand->rcBand.top + mcy;
713 /* mark whether we need to invalidate this band and trace */
714 if ((lpBand->rcoldBand.left !=lpBand->rcBand.left) ||
715 (lpBand->rcoldBand.top !=lpBand->rcBand.top) ||
716 (lpBand->rcoldBand.right !=lpBand->rcBand.right) ||
717 (lpBand->rcoldBand.bottom !=lpBand->rcBand.bottom)) {
718 lpBand->fDraw |= NTF_INVALIDATE;
719 TRACE("band %d row=%d: changed to (%d,%d)-(%d,%d) from (%d,%d)-(%d,%d)\n",
721 lpBand->rcBand.left, lpBand->rcBand.top,
722 lpBand->rcBand.right, lpBand->rcBand.bottom,
723 lpBand->rcoldBand.left, lpBand->rcoldBand.top,
724 lpBand->rcoldBand.right, lpBand->rcoldBand.bottom);
727 TRACE("band %d row=%d: unchanged (%d,%d)-(%d,%d)\n",
729 lpBand->rcBand.left, lpBand->rcBand.top,
730 lpBand->rcBand.right, lpBand->rcBand.bottom);
736 REBAR_AdjustBands (REBAR_INFO *infoPtr, UINT rowstart, UINT rowend,
738 /* Function: This routine distributes the extra space in a row. */
739 /* See algorithm below. */
741 /* all bands @ ->cxHeader size */
742 /* start and end bands are *not* hidden */
745 UINT xsep, extra, curwidth, fudge;
746 INT x, i, last_adjusted;
748 TRACE("start=%u, end=%u, max x=%d, max y=%d\n",
749 rowstart, rowend, maxx, mcy);
751 /* ******************* Phase 1 ************************ */
753 /* For each visible band with valid child */
754 /* a. inflate band till either all extra space used */
755 /* or band's ->ccx reached. */
756 /* If any band modified, add any space left to last band */
759 /* ****************************************************** */
760 lpBand = &infoPtr->bands[rowend];
761 extra = maxx - rcBrb(lpBand);
764 for (i=(INT)rowstart; i<=(INT)rowend; i++) {
765 lpBand = &infoPtr->bands[i];
766 if (HIDDENBAND(lpBand)) continue;
767 xsep = (x == 0) ? 0 : SEP_WIDTH;
768 curwidth = rcBw(lpBand);
770 /* set new left/top point */
771 if (infoPtr->dwStyle & CCS_VERT)
772 lpBand->rcBand.top = x + xsep;
774 lpBand->rcBand.left = x + xsep;
776 /* compute new width */
777 if ((lpBand->hwndChild && extra) && !(lpBand->fStyle & RBBS_FIXEDSIZE)) {
778 /* set to the "current" band size less the header */
781 if ((lpBand->fMask & RBBIM_SIZE) && (lpBand->cx > 0) &&
782 (fudge > curwidth)) {
783 TRACE("adjusting band %d by %d, fudge=%d, curwidth=%d, extra=%d\n",
784 i, fudge-curwidth, fudge, curwidth, extra);
785 if ((fudge - curwidth) > extra)
786 fudge = curwidth + extra;
787 extra -= (fudge - curwidth);
791 TRACE("adjusting band %d by %d, fudge=%d, curwidth=%d\n",
792 i, extra, fudge, curwidth);
798 /* set new right/bottom point */
799 if (infoPtr->dwStyle & CCS_VERT)
800 lpBand->rcBand.bottom = lpBand->rcBand.top + curwidth;
802 lpBand->rcBand.right = lpBand->rcBand.left + curwidth;
803 TRACE("Phase 1 band %d, (%d,%d)-(%d,%d), orig x=%d, xsep=%d\n",
804 i, lpBand->rcBand.left, lpBand->rcBand.top,
805 lpBand->rcBand.right, lpBand->rcBand.bottom, x, xsep);
808 if ((x >= maxx) || (last_adjusted != -1)) {
810 ERR("Phase 1 failed, x=%d, maxx=%d, start=%u, end=%u\n",
811 x, maxx, rowstart, rowend);
813 /* done, so spread extra space */
816 TRACE("Need to spread %d on last adjusted band %d\n",
817 fudge, last_adjusted);
818 for (i=(INT)last_adjusted; i<=(INT)rowend; i++) {
819 lpBand = &infoPtr->bands[i];
820 if (HIDDENBAND(lpBand)) continue;
822 /* set right/bottom point */
823 if (i != last_adjusted) {
824 if (infoPtr->dwStyle & CCS_VERT)
825 lpBand->rcBand.top += fudge;
827 lpBand->rcBand.left += fudge;
830 /* set left/bottom point */
831 if (infoPtr->dwStyle & CCS_VERT)
832 lpBand->rcBand.bottom += fudge;
834 lpBand->rcBand.right += fudge;
837 TRACE("Phase 1 succeeded, used x=%d\n", x);
838 REBAR_FixVert (infoPtr, rowstart, rowend, mcy);
842 /* ******************* Phase 2 ************************ */
844 /* Find first visible band, put all */
845 /* extra space there. */
847 /* ****************************************************** */
850 for (i=(INT)rowstart; i<=(INT)rowend; i++) {
851 lpBand = &infoPtr->bands[i];
852 if (HIDDENBAND(lpBand)) continue;
853 xsep = (x == 0) ? 0 : SEP_WIDTH;
854 curwidth = rcBw(lpBand);
856 /* set new left/top point */
857 if (infoPtr->dwStyle & CCS_VERT)
858 lpBand->rcBand.top = x + xsep;
860 lpBand->rcBand.left = x + xsep;
862 /* compute new width */
868 /* set new right/bottom point */
869 if (infoPtr->dwStyle & CCS_VERT)
870 lpBand->rcBand.bottom = lpBand->rcBand.top + curwidth;
872 lpBand->rcBand.right = lpBand->rcBand.left + curwidth;
873 TRACE("Phase 2 band %d, (%d,%d)-(%d,%d), orig x=%d, xsep=%d\n",
874 i, lpBand->rcBand.left, lpBand->rcBand.top,
875 lpBand->rcBand.right, lpBand->rcBand.bottom, x, xsep);
880 ERR("Phase 2 failed, x=%d, maxx=%d, start=%u, end=%u\n",
881 x, maxx, rowstart, rowend);
883 /* done, so spread extra space */
884 TRACE("Phase 2 succeeded, used x=%d\n", x);
885 REBAR_FixVert (infoPtr, rowstart, rowend, mcy);
889 /* ******************* Phase 3 ************************ */
890 /* at this point everything is back to ->cxHeader values */
891 /* and should not have gotten here. */
892 /* ****************************************************** */
894 lpBand = &infoPtr->bands[rowstart];
895 ERR("Serious problem adjusting row %d, start band %d, end band %d\n",
896 lpBand->iRow, rowstart, rowend);
897 REBAR_DumpBand (infoPtr);
903 REBAR_CalcHorzBand (REBAR_INFO *infoPtr, UINT rstart, UINT rend, BOOL notify)
904 /* Function: this routine initializes all the rectangles in */
905 /* each band in a row to fit in the adjusted rcBand rect. */
906 /* *** Supports only Horizontal bars. *** */
913 /* MS seems to use GetDlgCtrlID() for above GetWindowLong call */
914 parenthwnd = GetParent (infoPtr->hwndSelf);
916 for(i=rstart; i<rend; i++){
917 lpBand = &infoPtr->bands[i];
918 if (HIDDENBAND(lpBand)) {
919 SetRect (&lpBand->rcChild,
920 lpBand->rcBand.right, lpBand->rcBand.top,
921 lpBand->rcBand.right, lpBand->rcBand.bottom);
925 oldChild = lpBand->rcChild;
927 /* set initial gripper rectangle */
928 SetRect (&lpBand->rcGripper, lpBand->rcBand.left, lpBand->rcBand.top,
929 lpBand->rcBand.left, lpBand->rcBand.bottom);
931 /* calculate gripper rectangle */
932 if ( lpBand->fStatus & HAS_GRIPPER) {
933 lpBand->fDraw |= DRAW_GRIPPER;
934 lpBand->rcGripper.left += REBAR_PRE_GRIPPER;
935 lpBand->rcGripper.right = lpBand->rcGripper.left + GRIPPER_WIDTH;
936 lpBand->rcGripper.top += 2;
937 lpBand->rcGripper.bottom -= 2;
939 SetRect (&lpBand->rcCapImage,
940 lpBand->rcGripper.right+REBAR_ALWAYS_SPACE, lpBand->rcBand.top,
941 lpBand->rcGripper.right+REBAR_ALWAYS_SPACE, lpBand->rcBand.bottom);
943 else { /* no gripper will be drawn */
945 if (lpBand->fStatus & (HAS_IMAGE | HAS_TEXT))
946 /* if no gripper but either image or text, then leave space */
947 xoff = REBAR_ALWAYS_SPACE;
948 SetRect (&lpBand->rcCapImage,
949 lpBand->rcBand.left+xoff, lpBand->rcBand.top,
950 lpBand->rcBand.left+xoff, lpBand->rcBand.bottom);
953 /* image is visible */
954 if (lpBand->fStatus & HAS_IMAGE) {
955 lpBand->fDraw |= DRAW_IMAGE;
956 lpBand->rcCapImage.right += infoPtr->imageSize.cx;
957 lpBand->rcCapImage.bottom = lpBand->rcCapImage.top + infoPtr->imageSize.cy;
959 /* set initial caption text rectangle */
960 SetRect (&lpBand->rcCapText,
961 lpBand->rcCapImage.right+REBAR_POST_IMAGE, lpBand->rcBand.top+1,
962 lpBand->rcBand.left+lpBand->cxHeader, lpBand->rcBand.bottom-1);
963 /* update band height
964 if (lpBand->uMinHeight < infoPtr->imageSize.cy + 2) {
965 lpBand->uMinHeight = infoPtr->imageSize.cy + 2;
966 lpBand->rcBand.bottom = lpBand->rcBand.top + lpBand->uMinHeight;
970 /* set initial caption text rectangle */
971 SetRect (&lpBand->rcCapText, lpBand->rcCapImage.right, lpBand->rcBand.top+1,
972 lpBand->rcBand.left+lpBand->cxHeader, lpBand->rcBand.bottom-1);
975 /* text is visible */
976 if ((lpBand->fStatus & HAS_TEXT) && !(lpBand->fStyle & RBBS_HIDETITLE)) {
977 lpBand->fDraw |= DRAW_TEXT;
978 lpBand->rcCapText.right = max(lpBand->rcCapText.left,
979 lpBand->rcCapText.right-REBAR_POST_TEXT);
982 /* set initial child window rectangle if there is a child */
983 if (lpBand->fMask & RBBIM_CHILD) {
984 xoff = lpBand->offChild.cx;
985 yoff = lpBand->offChild.cy;
986 SetRect (&lpBand->rcChild,
987 lpBand->rcBand.left+lpBand->cxHeader, lpBand->rcBand.top+yoff,
988 lpBand->rcBand.right-xoff, lpBand->rcBand.bottom-yoff);
989 if ((lpBand->fStyle & RBBS_USECHEVRON) && (lpBand->rcChild.right - lpBand->rcChild.left < lpBand->cxIdeal))
991 lpBand->rcChild.right -= CHEVRON_WIDTH;
992 SetRect(&lpBand->rcChevron, lpBand->rcChild.right,
993 lpBand->rcChild.top, lpBand->rcChild.right + CHEVRON_WIDTH,
994 lpBand->rcChild.bottom);
998 SetRect (&lpBand->rcChild,
999 lpBand->rcBand.left+lpBand->cxHeader, lpBand->rcBand.top,
1000 lpBand->rcBand.right, lpBand->rcBand.bottom);
1003 /* flag if notify required and invalidate rectangle */
1005 ((oldChild.right-oldChild.left != lpBand->rcChild.right-lpBand->rcChild.left) ||
1006 (oldChild.bottom-oldChild.top != lpBand->rcChild.bottom-lpBand->rcChild.top))) {
1007 TRACE("Child rectangle changed for band %u\n", i);
1008 TRACE(" from (%d,%d)-(%d,%d) to (%d,%d)-(%d,%d)\n",
1009 oldChild.left, oldChild.top,
1010 oldChild.right, oldChild.bottom,
1011 lpBand->rcChild.left, lpBand->rcChild.top,
1012 lpBand->rcChild.right, lpBand->rcChild.bottom);
1014 if (lpBand->fDraw & NTF_INVALIDATE) {
1015 TRACE("invalidating (%d,%d)-(%d,%d)\n",
1016 lpBand->rcBand.left,
1018 lpBand->rcBand.right + ((lpBand->fDraw & DRAW_RIGHTSEP) ? SEP_WIDTH_SIZE : 0),
1019 lpBand->rcBand.bottom + ((lpBand->fDraw & DRAW_BOTTOMSEP) ? SEP_WIDTH_SIZE : 0));
1020 lpBand->fDraw &= ~NTF_INVALIDATE;
1021 work = lpBand->rcBand;
1022 if (lpBand->fDraw & DRAW_RIGHTSEP) work.right += SEP_WIDTH_SIZE;
1023 if (lpBand->fDraw & DRAW_BOTTOMSEP) work.bottom += SEP_WIDTH_SIZE;
1024 InvalidateRect(infoPtr->hwndSelf, &work, TRUE);
1033 REBAR_CalcVertBand (REBAR_INFO *infoPtr, UINT rstart, UINT rend, BOOL notify)
1034 /* Function: this routine initializes all the rectangles in */
1035 /* each band in a row to fit in the adjusted rcBand rect. */
1036 /* *** Supports only Vertical bars. *** */
1041 RECT oldChild, work;
1043 /* MS seems to use GetDlgCtrlID() for above GetWindowLong call */
1044 parenthwnd = GetParent (infoPtr->hwndSelf);
1046 for(i=rstart; i<rend; i++){
1047 lpBand = &infoPtr->bands[i];
1048 if (HIDDENBAND(lpBand)) continue;
1049 oldChild = lpBand->rcChild;
1051 /* set initial gripper rectangle */
1052 SetRect (&lpBand->rcGripper, lpBand->rcBand.left, lpBand->rcBand.top,
1053 lpBand->rcBand.right, lpBand->rcBand.top);
1055 /* calculate gripper rectangle */
1056 if (lpBand->fStatus & HAS_GRIPPER) {
1057 lpBand->fDraw |= DRAW_GRIPPER;
1059 if (infoPtr->dwStyle & RBS_VERTICALGRIPPER) {
1060 /* vertical gripper */
1061 lpBand->rcGripper.left += 3;
1062 lpBand->rcGripper.right = lpBand->rcGripper.left + GRIPPER_WIDTH;
1063 lpBand->rcGripper.top += REBAR_PRE_GRIPPER;
1064 lpBand->rcGripper.bottom = lpBand->rcGripper.top + GRIPPER_HEIGHT;
1066 /* initialize Caption image rectangle */
1067 SetRect (&lpBand->rcCapImage, lpBand->rcBand.left,
1068 lpBand->rcGripper.bottom + REBAR_ALWAYS_SPACE,
1069 lpBand->rcBand.right,
1070 lpBand->rcGripper.bottom + REBAR_ALWAYS_SPACE);
1073 /* horizontal gripper */
1074 lpBand->rcGripper.left += 2;
1075 lpBand->rcGripper.right -= 2;
1076 lpBand->rcGripper.top += REBAR_PRE_GRIPPER;
1077 lpBand->rcGripper.bottom = lpBand->rcGripper.top + GRIPPER_WIDTH;
1079 /* initialize Caption image rectangle */
1080 SetRect (&lpBand->rcCapImage, lpBand->rcBand.left,
1081 lpBand->rcGripper.bottom + REBAR_ALWAYS_SPACE,
1082 lpBand->rcBand.right,
1083 lpBand->rcGripper.bottom + REBAR_ALWAYS_SPACE);
1086 else { /* no gripper will be drawn */
1088 if (lpBand->fStatus & (HAS_IMAGE | HAS_TEXT))
1089 /* if no gripper but either image or text, then leave space */
1090 xoff = REBAR_ALWAYS_SPACE;
1091 /* initialize Caption image rectangle */
1092 SetRect (&lpBand->rcCapImage,
1093 lpBand->rcBand.left, lpBand->rcBand.top+xoff,
1094 lpBand->rcBand.right, lpBand->rcBand.top+xoff);
1097 /* image is visible */
1098 if (lpBand->fStatus & HAS_IMAGE) {
1099 lpBand->fDraw |= DRAW_IMAGE;
1101 lpBand->rcCapImage.right = lpBand->rcCapImage.left + infoPtr->imageSize.cx;
1102 lpBand->rcCapImage.bottom += infoPtr->imageSize.cy;
1104 /* set initial caption text rectangle */
1105 SetRect (&lpBand->rcCapText,
1106 lpBand->rcBand.left, lpBand->rcCapImage.bottom+REBAR_POST_IMAGE,
1107 lpBand->rcBand.right, lpBand->rcBand.top+lpBand->cxHeader);
1108 /* update band height *
1109 if (lpBand->uMinHeight < infoPtr->imageSize.cx + 2) {
1110 lpBand->uMinHeight = infoPtr->imageSize.cx + 2;
1111 lpBand->rcBand.right = lpBand->rcBand.left + lpBand->uMinHeight;
1115 /* set initial caption text rectangle */
1116 SetRect (&lpBand->rcCapText,
1117 lpBand->rcBand.left, lpBand->rcCapImage.bottom,
1118 lpBand->rcBand.right, lpBand->rcBand.top+lpBand->cxHeader);
1121 /* text is visible */
1122 if ((lpBand->fStatus & HAS_TEXT) && !(lpBand->fStyle & RBBS_HIDETITLE)) {
1123 lpBand->fDraw |= DRAW_TEXT;
1124 lpBand->rcCapText.bottom = max(lpBand->rcCapText.top,
1125 lpBand->rcCapText.bottom);
1128 /* set initial child window rectangle if there is a child */
1129 if (lpBand->fMask & RBBIM_CHILD) {
1130 yoff = lpBand->offChild.cx;
1131 xoff = lpBand->offChild.cy;
1132 SetRect (&lpBand->rcChild,
1133 lpBand->rcBand.left+xoff, lpBand->rcBand.top+lpBand->cxHeader,
1134 lpBand->rcBand.right-xoff, lpBand->rcBand.bottom-yoff);
1137 SetRect (&lpBand->rcChild,
1138 lpBand->rcBand.left, lpBand->rcBand.top+lpBand->cxHeader,
1139 lpBand->rcBand.right, lpBand->rcBand.bottom);
1142 /* flag if notify required and invalidate rectangle */
1144 ((oldChild.right-oldChild.left != lpBand->rcChild.right-lpBand->rcChild.left) ||
1145 (oldChild.bottom-oldChild.top != lpBand->rcChild.bottom-lpBand->rcChild.top))) {
1146 TRACE("Child rectangle changed for band %u\n", i);
1147 TRACE(" from (%d,%d)-(%d,%d) to (%d,%d)-(%d,%d)\n",
1148 oldChild.left, oldChild.top,
1149 oldChild.right, oldChild.bottom,
1150 lpBand->rcChild.left, lpBand->rcChild.top,
1151 lpBand->rcChild.right, lpBand->rcChild.bottom);
1153 if (lpBand->fDraw & NTF_INVALIDATE) {
1154 TRACE("invalidating (%d,%d)-(%d,%d)\n",
1155 lpBand->rcBand.left,
1157 lpBand->rcBand.right + ((lpBand->fDraw & DRAW_BOTTOMSEP) ? SEP_WIDTH_SIZE : 0),
1158 lpBand->rcBand.bottom + ((lpBand->fDraw & DRAW_RIGHTSEP) ? SEP_WIDTH_SIZE : 0));
1159 lpBand->fDraw &= ~NTF_INVALIDATE;
1160 work = lpBand->rcBand;
1161 if (lpBand->fDraw & DRAW_RIGHTSEP) work.bottom += SEP_WIDTH_SIZE;
1162 if (lpBand->fDraw & DRAW_BOTTOMSEP) work.right += SEP_WIDTH_SIZE;
1163 InvalidateRect(infoPtr->hwndSelf, &work, TRUE);
1171 REBAR_ForceResize (REBAR_INFO *infoPtr)
1172 /* Function: This changes the size of the REBAR window to that */
1173 /* calculated by REBAR_Layout. */
1176 INT x, y, width, height;
1177 INT xedge = GetSystemMetrics(SM_CXEDGE);
1178 INT yedge = GetSystemMetrics(SM_CYEDGE);
1180 GetClientRect (infoPtr->hwndSelf, &rc);
1182 TRACE( " old [%d x %d], new [%d x %d], client [%d x %d]\n",
1183 infoPtr->oldSize.cx, infoPtr->oldSize.cy,
1184 infoPtr->calcSize.cx, infoPtr->calcSize.cy,
1185 rc.right, rc.bottom);
1187 /* If we need to shrink client, then skip size test */
1188 if ((infoPtr->calcSize.cy >= rc.bottom) &&
1189 (infoPtr->calcSize.cx >= rc.right)) {
1191 /* if size did not change then skip process */
1192 if ((infoPtr->oldSize.cx == infoPtr->calcSize.cx) &&
1193 (infoPtr->oldSize.cy == infoPtr->calcSize.cy) &&
1194 !(infoPtr->fStatus & RESIZE_ANYHOW))
1196 TRACE("skipping reset\n");
1201 infoPtr->fStatus &= ~RESIZE_ANYHOW;
1202 /* Set flag to ignore next WM_SIZE message */
1203 infoPtr->fStatus |= AUTO_RESIZE;
1210 if (infoPtr->dwStyle & WS_BORDER) {
1215 if (!(infoPtr->dwStyle & CCS_NOPARENTALIGN)) {
1216 INT mode = infoPtr->dwStyle & (CCS_VERT | CCS_TOP | CCS_BOTTOM);
1219 GetClientRect(GetParent(infoPtr->hwndSelf), &rcPcl);
1222 /* _TOP sets width to parents width */
1223 width += (rcPcl.right - rcPcl.left);
1224 height += infoPtr->calcSize.cy;
1225 x += ((infoPtr->dwStyle & WS_BORDER) ? -xedge : 0);
1226 y += ((infoPtr->dwStyle & WS_BORDER) ? -yedge : 0);
1227 y += ((infoPtr->dwStyle & CCS_NODIVIDER) ? 0 : REBAR_DIVIDER);
1230 /* FIXME: wrong wrong wrong */
1231 /* _BOTTOM sets width to parents width */
1232 width += (rcPcl.right - rcPcl.left);
1233 height += infoPtr->calcSize.cy;
1235 y = rcPcl.bottom - height + 1;
1238 /* _LEFT sets height to parents height */
1239 width += infoPtr->calcSize.cx;
1240 height += (rcPcl.bottom - rcPcl.top);
1241 x += ((infoPtr->dwStyle & WS_BORDER) ? -xedge : 0);
1242 x += ((infoPtr->dwStyle & CCS_NODIVIDER) ? 0 : REBAR_DIVIDER);
1243 y += ((infoPtr->dwStyle & WS_BORDER) ? -yedge : 0);
1246 /* FIXME: wrong wrong wrong */
1247 /* _RIGHT sets height to parents height */
1248 width += infoPtr->calcSize.cx;
1249 height += (rcPcl.bottom - rcPcl.top);
1250 x = rcPcl.right - width + 1;
1254 width += infoPtr->calcSize.cx;
1255 height += infoPtr->calcSize.cy;
1259 width += infoPtr->calcSize.cx;
1260 height += infoPtr->calcSize.cy;
1261 x = infoPtr->origin.x;
1262 y = infoPtr->origin.y;
1265 TRACE("hwnd %p, style=%08x, setting at (%d,%d) for (%d,%d)\n",
1266 infoPtr->hwndSelf, infoPtr->dwStyle,
1267 x, y, width, height);
1268 SetWindowPos (infoPtr->hwndSelf, 0, x, y, width, height,
1270 infoPtr->fStatus &= ~AUTO_RESIZE;
1275 REBAR_MoveChildWindows (REBAR_INFO *infoPtr, UINT start, UINT endplus)
1277 static const WCHAR strComboBox[] = { 'C','o','m','b','o','B','o','x',0 };
1279 WCHAR szClassName[40];
1281 NMREBARCHILDSIZE rbcz;
1285 if (!(deferpos = BeginDeferWindowPos(infoPtr->uNumBands)))
1286 ERR("BeginDeferWindowPos returned NULL\n");
1288 for (i = start; i < endplus; i++) {
1289 lpBand = &infoPtr->bands[i];
1291 if (HIDDENBAND(lpBand)) continue;
1292 if (lpBand->hwndChild) {
1293 TRACE("hwndChild = %p\n", lpBand->hwndChild);
1295 /* Always geterate the RBN_CHILDSIZE even it child
1298 rbcz.wID = lpBand->wID;
1299 rbcz.rcChild = lpBand->rcChild;
1300 rbcz.rcBand = lpBand->rcBand;
1301 if (infoPtr->dwStyle & CCS_VERT)
1302 rbcz.rcBand.top += lpBand->cxHeader;
1304 rbcz.rcBand.left += lpBand->cxHeader;
1305 REBAR_Notify ((NMHDR *)&rbcz, infoPtr, RBN_CHILDSIZE);
1306 if (!EqualRect (&lpBand->rcChild, &rbcz.rcChild)) {
1307 TRACE("Child rect changed by NOTIFY for band %u\n", i);
1308 TRACE(" from (%d,%d)-(%d,%d) to (%d,%d)-(%d,%d)\n",
1309 lpBand->rcChild.left, lpBand->rcChild.top,
1310 lpBand->rcChild.right, lpBand->rcChild.bottom,
1311 rbcz.rcChild.left, rbcz.rcChild.top,
1312 rbcz.rcChild.right, rbcz.rcChild.bottom);
1313 lpBand->rcChild = rbcz.rcChild; /* *** ??? */
1316 /* native (IE4 in "Favorites" frame **1) does:
1317 * SetRect (&rc, -1, -1, -1, -1)
1318 * EqualRect (&rc,band->rc???)
1320 * CopyRect (band->rc????, &rc)
1321 * set flag outside of loop
1324 GetClassNameW (lpBand->hwndChild, szClassName, sizeof(szClassName)/sizeof(szClassName[0]));
1325 if (!lstrcmpW (szClassName, strComboBox) ||
1326 !lstrcmpW (szClassName, WC_COMBOBOXEXW)) {
1327 INT nEditHeight, yPos;
1330 /* special placement code for combo or comboex box */
1333 /* get size of edit line */
1334 GetWindowRect (lpBand->hwndChild, &rc);
1335 nEditHeight = rc.bottom - rc.top;
1336 yPos = (lpBand->rcChild.bottom + lpBand->rcChild.top - nEditHeight)/2;
1338 /* center combo box inside child area */
1339 TRACE("moving child (Combo(Ex)) %p to (%d,%d) for (%d,%d)\n",
1341 lpBand->rcChild.left, yPos,
1342 lpBand->rcChild.right - lpBand->rcChild.left,
1344 deferpos = DeferWindowPos (deferpos, lpBand->hwndChild, HWND_TOP,
1345 lpBand->rcChild.left,
1346 /*lpBand->rcChild.top*/ yPos,
1347 lpBand->rcChild.right - lpBand->rcChild.left,
1351 ERR("DeferWindowPos returned NULL\n");
1354 TRACE("moving child (Other) %p to (%d,%d) for (%d,%d)\n",
1356 lpBand->rcChild.left, lpBand->rcChild.top,
1357 lpBand->rcChild.right - lpBand->rcChild.left,
1358 lpBand->rcChild.bottom - lpBand->rcChild.top);
1359 deferpos = DeferWindowPos (deferpos, lpBand->hwndChild, HWND_TOP,
1360 lpBand->rcChild.left,
1361 lpBand->rcChild.top,
1362 lpBand->rcChild.right - lpBand->rcChild.left,
1363 lpBand->rcChild.bottom - lpBand->rcChild.top,
1366 ERR("DeferWindowPos returned NULL\n");
1370 if (!EndDeferWindowPos(deferpos))
1371 ERR("EndDeferWindowPos returned NULL\n");
1373 if (infoPtr->DoRedraw)
1374 UpdateWindow (infoPtr->hwndSelf);
1376 if (infoPtr->fStatus & NTF_HGHTCHG) {
1377 infoPtr->fStatus &= ~NTF_HGHTCHG;
1379 * We need to force a resize here, because some applications
1380 * try to get the rebar size during processing of the
1381 * RBN_HEIGHTCHANGE notification.
1383 REBAR_ForceResize (infoPtr);
1384 REBAR_Notify (&heightchange, infoPtr, RBN_HEIGHTCHANGE);
1387 /* native (from **1 above) does:
1388 * UpdateWindow(rebar)
1390 * RBN_HEIGHTCHANGE if necessary
1391 * if ret from any EqualRect was 0
1392 * Goto "BeginDeferWindowPos"
1399 REBAR_Layout (REBAR_INFO *infoPtr, LPRECT lpRect, BOOL notify, BOOL resetclient)
1400 /* Function: This routine is resposible for laying out all */
1401 /* the bands in a rebar. It assigns each band to a row and*/
1402 /* determines when to start a new row. */
1404 REBAR_BAND *lpBand, *prevBand;
1405 RECT rcClient, rcAdj;
1406 INT initx, inity, x, y, cx, cxsep, mmcy, mcy, clientcx, clientcy;
1407 INT adjcx, adjcy, row, rightx, bottomy, origheight;
1408 UINT i, j, rowstart, origrows, cntonrow;
1411 if (!(infoPtr->fStatus & BAND_NEEDS_LAYOUT)) {
1412 TRACE("no layout done. No band changed.\n");
1413 REBAR_DumpBand (infoPtr);
1416 infoPtr->fStatus &= ~BAND_NEEDS_LAYOUT;
1417 if (!infoPtr->DoRedraw) infoPtr->fStatus |= BAND_NEEDS_REDRAW;
1419 GetClientRect (infoPtr->hwndSelf, &rcClient);
1420 TRACE("Client is (%d,%d)-(%d,%d)\n",
1421 rcClient.left, rcClient.top, rcClient.right, rcClient.bottom);
1425 TRACE("adjustment rect is (%d,%d)-(%d,%d)\n",
1426 rcAdj.left, rcAdj.top, rcAdj.right, rcAdj.bottom);
1429 CopyRect (&rcAdj, &rcClient);
1432 clientcx = rcClient.right - rcClient.left;
1433 clientcy = rcClient.bottom - rcClient.top;
1434 adjcx = rcAdj.right - rcAdj.left;
1435 adjcy = rcAdj.bottom - rcAdj.top;
1437 TRACE("window client rect will be set to adj rect\n");
1442 if (!infoPtr->DoRedraw && (clientcx == 0) && (clientcy == 0)) {
1443 ERR("no redraw and client is zero, skip layout\n");
1444 infoPtr->fStatus |= BAND_NEEDS_LAYOUT;
1448 /* save height of original control */
1449 if (infoPtr->dwStyle & CCS_VERT)
1450 origheight = infoPtr->calcSize.cx;
1452 origheight = infoPtr->calcSize.cy;
1453 origrows = infoPtr->uNumRows;
1458 /* ******* Start Phase 1 - all bands on row at minimum size ******* */
1460 TRACE("band loop constants, clientcx=%d, clientcy=%d, adjcx=%d, adjcy=%d\n",
1461 clientcx, clientcy, adjcx, adjcy);
1471 for (i = 0; i < infoPtr->uNumBands; i++) {
1472 lpBand = &infoPtr->bands[i];
1476 SetRectEmpty(&lpBand->rcChevron);
1478 if (HIDDENBAND(lpBand)) continue;
1480 lpBand->rcoldBand = lpBand->rcBand;
1482 /* Set the offset of the child window */
1483 if ((lpBand->fMask & RBBIM_CHILD) &&
1484 !(lpBand->fStyle & RBBS_FIXEDSIZE)) {
1485 lpBand->offChild.cx = ((lpBand->fStyle & RBBS_CHILDEDGE) ? 4 : 0);
1487 lpBand->offChild.cy = ((lpBand->fStyle & RBBS_CHILDEDGE) ? 2 : 0);
1489 /* separator from previous band */
1490 cxsep = (cntonrow == 0) ? 0 : SEP_WIDTH;
1493 /* In native, 0 as one of the coordinates means no limit */
1494 if (infoPtr->dwStyle & CCS_VERT)
1495 dobreak = (adjcy && (y + cx + cxsep > adjcy));
1497 dobreak = (adjcx && (x + cx + cxsep > adjcx));
1499 /* This is the check for whether we need to start a new row */
1500 if ( ( (lpBand->fStyle & RBBS_BREAK) && (i != 0) ) ||
1501 ( ((infoPtr->dwStyle & CCS_VERT) ? (y != 0) : (x != 0)) && dobreak)) {
1503 for (j = rowstart; j < i; j++) {
1505 lpB = &infoPtr->bands[j];
1506 if (infoPtr->dwStyle & CCS_VERT) {
1507 lpB->rcBand.right = lpB->rcBand.left + mcy;
1510 lpB->rcBand.bottom = lpB->rcBand.top + mcy;
1514 TRACE("P1 Spliting to new row %d on band %u\n", row+1, i);
1515 if (infoPtr->dwStyle & CCS_VERT) {
1517 x += (mcy + SEP_WIDTH);
1521 y += (mcy + SEP_WIDTH);
1533 if (mcy < lpBand->lcy + REBARSPACE(lpBand))
1534 mcy = lpBand->lcy + REBARSPACE(lpBand);
1536 /* if boundary rect specified then limit mcy */
1538 if (infoPtr->dwStyle & CCS_VERT) {
1539 if (adjcx && (x+mcy > adjcx)) {
1541 TRACE("P1 row %u limiting mcy=%d, adjcx=%d, x=%d\n",
1546 if (adjcy && (y+mcy > adjcy)) {
1548 TRACE("P1 row %u limiting mcy=%d, adjcy=%d, y=%d\n",
1554 TRACE("P1 band %u, row %d, x=%d, y=%d, cxsep=%d, cx=%d\n",
1557 if (infoPtr->dwStyle & CCS_VERT) {
1558 /* bound the bottom side if we have a bounding rectangle */
1560 bottomy = (lpRect) ? min(clientcy, y+cxsep+cx) : y+cxsep+cx;
1561 lpBand->rcBand.left = x;
1562 lpBand->rcBand.right = x + min(mcy,
1563 lpBand->lcy+REBARSPACE(lpBand));
1564 lpBand->rcBand.top = min(bottomy, y + cxsep);
1565 lpBand->rcBand.bottom = bottomy;
1566 lpBand->uMinHeight = lpBand->lcy;
1570 /* bound the right side if we have a bounding rectangle */
1571 rightx = (lpRect) ? min(clientcx, x+cxsep+cx) : x+cxsep+cx;
1573 lpBand->rcBand.left = min(rightx, x + cxsep);
1574 lpBand->rcBand.right = rightx;
1575 lpBand->rcBand.top = y;
1576 lpBand->rcBand.bottom = y + min(mcy,
1577 lpBand->lcy+REBARSPACE(lpBand));
1578 lpBand->uMinHeight = lpBand->lcy;
1581 TRACE("P1 band %u, row %d, (%d,%d)-(%d,%d)\n",
1583 lpBand->rcBand.left, lpBand->rcBand.top,
1584 lpBand->rcBand.right, lpBand->rcBand.bottom);
1588 } /* for (i = 0; i < infoPtr->uNumBands... */
1590 if (infoPtr->dwStyle & CCS_VERT)
1595 for (j = rowstart; j < infoPtr->uNumBands; j++) {
1596 lpBand = &infoPtr->bands[j];
1597 if (infoPtr->dwStyle & CCS_VERT) {
1598 lpBand->rcBand.right = lpBand->rcBand.left + mcy;
1601 lpBand->rcBand.bottom = lpBand->rcBand.top + mcy;
1605 if (infoPtr->uNumBands)
1606 infoPtr->uNumRows = row + 1;
1608 /* ******* End Phase 1 - all bands on row at minimum size ******* */
1611 /* ******* Start Phase 1a - Adjust heights for RBS_VARHEIGHT off ******* */
1614 if (!(infoPtr->dwStyle & RBS_VARHEIGHT)) {
1617 /* get the max height of all bands */
1618 for (i=0; i<infoPtr->uNumBands; i++) {
1619 lpBand = &infoPtr->bands[i];
1620 if (HIDDENBAND(lpBand)) continue;
1621 if (infoPtr->dwStyle & CCS_VERT)
1622 mmcy = max(mmcy, lpBand->rcBand.right - lpBand->rcBand.left);
1624 mmcy = max(mmcy, lpBand->rcBand.bottom - lpBand->rcBand.top);
1627 /* now adjust all rectangles by using the height found above */
1630 for (i=0; i<infoPtr->uNumBands; i++) {
1631 lpBand = &infoPtr->bands[i];
1632 if (HIDDENBAND(lpBand)) continue;
1633 if (lpBand->iRow != row)
1634 xy += (mmcy + SEP_WIDTH);
1635 if (infoPtr->dwStyle & CCS_VERT) {
1636 lpBand->rcBand.left = xy;
1637 lpBand->rcBand.right = xy + mmcy;
1640 lpBand->rcBand.top = xy;
1641 lpBand->rcBand.bottom = xy + mmcy;
1645 /* set the x/y values to the correct maximum */
1646 if (infoPtr->dwStyle & CCS_VERT)
1652 /* ******* End Phase 1a - Adjust heights for RBS_VARHEIGHT off ******* */
1655 /* ******* Start Phase 2 - split rows till adjustment height full ******* */
1657 /* assumes that the following variables contain: */
1658 /* y/x current height/width of all rows */
1659 /* adjcy/adjcx adjustment height/width or 0 (as small as possible) */
1660 if (lpRect && ((infoPtr->dwStyle & CCS_VERT) ? adjcx : adjcy)) {
1661 INT i, prev_rh, new_rh, adj_rh, prev_idx, current_idx;
1662 REBAR_BAND *prev, *current, *walk;
1665 /* FIXME: problem # 2 */
1666 if (((infoPtr->dwStyle & CCS_VERT) ?
1668 (x < adjcx) : (y < adjcy)
1670 (adjcx - x > 5) : (adjcy - y > 4)
1673 (infoPtr->uNumBands > 1)) {
1674 for (i=(INT)infoPtr->uNumBands-2; i>=0; i--) {
1675 TRACE("P2 adjcx=%d, adjcy=%d, x=%d, y=%d\n",
1676 adjcx, adjcy, x, y);
1678 /* find the current band (starts at i+1) */
1679 current = &infoPtr->bands[i+1];
1681 while (HIDDENBAND(current)) {
1683 if (i < 0) break; /* out of bands */
1684 current = &infoPtr->bands[i+1];
1687 if (i < 0) break; /* out of bands */
1689 /* now find the prev band (starts at i) */
1690 prev = &infoPtr->bands[i];
1692 while (HIDDENBAND(prev)) {
1694 if (i < 0) break; /* out of bands */
1695 prev = &infoPtr->bands[i];
1698 if (i < 0) break; /* out of bands */
1700 prev_rh = ircBw(prev);
1701 if (prev->iRow == current->iRow) {
1702 new_rh = (infoPtr->dwStyle & RBS_VARHEIGHT) ?
1703 current->lcy + REBARSPACE(current) :
1705 adj_rh = new_rh + SEP_WIDTH;
1706 infoPtr->uNumRows++;
1707 current->fDraw |= NTF_INVALIDATE;
1709 if (infoPtr->dwStyle & CCS_VERT) {
1710 current->rcBand.top = inity;
1711 current->rcBand.bottom = clientcy;
1712 current->rcBand.left += (prev_rh + SEP_WIDTH);
1713 current->rcBand.right = current->rcBand.left + new_rh;
1717 current->rcBand.left = initx;
1718 current->rcBand.right = clientcx;
1719 current->rcBand.top += (prev_rh + SEP_WIDTH);
1720 current->rcBand.bottom = current->rcBand.top + new_rh;
1723 TRACE("P2 moving band %d to own row at (%d,%d)-(%d,%d)\n",
1725 current->rcBand.left, current->rcBand.top,
1726 current->rcBand.right, current->rcBand.bottom);
1727 TRACE("P2 prev band %d at (%d,%d)-(%d,%d)\n",
1729 prev->rcBand.left, prev->rcBand.top,
1730 prev->rcBand.right, prev->rcBand.bottom);
1731 TRACE("P2 values: prev_rh=%d, new_rh=%d, adj_rh=%d\n",
1732 prev_rh, new_rh, adj_rh);
1733 /* for bands below current adjust row # and top/bottom */
1734 for (j = current_idx+1; j<infoPtr->uNumBands; j++) {
1735 walk = &infoPtr->bands[j];
1736 if (HIDDENBAND(walk)) continue;
1737 walk->fDraw |= NTF_INVALIDATE;
1739 if (infoPtr->dwStyle & CCS_VERT) {
1740 walk->rcBand.left += adj_rh;
1741 walk->rcBand.right += adj_rh;
1744 walk->rcBand.top += adj_rh;
1745 walk->rcBand.bottom += adj_rh;
1748 if ((infoPtr->dwStyle & CCS_VERT) ? (x >= adjcx) : (y >= adjcy))
1749 break; /* all done */
1755 /* ******* End Phase 2 - split rows till adjustment height full ******* */
1758 /* ******* Start Phase 2a - mark first and last band in each ******* */
1761 for (i = 0; i < infoPtr->uNumBands; i++) {
1762 lpBand = &infoPtr->bands[i];
1763 if (HIDDENBAND(lpBand))
1766 lpBand->fDraw |= DRAW_FIRST_IN_ROW;
1769 else if( prevBand->iRow == lpBand->iRow )
1772 prevBand->fDraw |= DRAW_LAST_IN_ROW;
1773 lpBand->fDraw |= DRAW_FIRST_IN_ROW;
1778 prevBand->fDraw |= DRAW_LAST_IN_ROW;
1780 /* ******* End Phase 2a - mark first and last band in each ******* */
1783 /* ******* Start Phase 2b - adjust all bands for height full ******* */
1784 /* assumes that the following variables contain: */
1785 /* y/x current height/width of all rows */
1786 /* clientcy/clientcx height/width of client area */
1788 if (((infoPtr->dwStyle & CCS_VERT) ? clientcx > x : clientcy > y) &&
1789 infoPtr->uNumBands) {
1793 diff = (infoPtr->dwStyle & CCS_VERT) ? clientcx - x : clientcy - y;
1795 /* iterate backwards thru the rows */
1796 for (i = infoPtr->uNumBands-1; i>=0; i--) {
1797 lpBand = &infoPtr->bands[i];
1798 if(HIDDENBAND(lpBand)) continue;
1800 /* if row has more than 1 band, ignore it */
1801 if( !(lpBand->fDraw&DRAW_FIRST_IN_ROW) )
1803 if( !(lpBand->fDraw&DRAW_LAST_IN_ROW) )
1806 /* FIXME: this next line is wrong, but fixing it to be inverted causes IE's sidebars to be the wrong size */
1807 if (lpBand->fMask & RBBS_VARIABLEHEIGHT) continue;
1808 if (((INT)lpBand->cyMaxChild < 1) ||
1809 ((INT)lpBand->cyIntegral < 1)) {
1810 if (lpBand->cyMaxChild + lpBand->cyIntegral == 0) continue;
1811 ERR("P2b band %u RBBS_VARIABLEHEIGHT set but cyMax=%d, cyInt=%d\n",
1812 i, lpBand->cyMaxChild, lpBand->cyIntegral);
1815 /* j is now the maximum height/width in the client area */
1816 j = ((diff / lpBand->cyIntegral) * lpBand->cyIntegral) +
1818 if (j > lpBand->cyMaxChild + REBARSPACE(lpBand))
1819 j = lpBand->cyMaxChild + REBARSPACE(lpBand);
1820 diff -= (j - ircBw(lpBand));
1821 if (infoPtr->dwStyle & CCS_VERT)
1822 lpBand->rcBand.right = lpBand->rcBand.left + j;
1824 lpBand->rcBand.bottom = lpBand->rcBand.top + j;
1825 TRACE("P2b band %d, row %d changed to (%d,%d)-(%d,%d)\n",
1827 lpBand->rcBand.left, lpBand->rcBand.top,
1828 lpBand->rcBand.right, lpBand->rcBand.bottom);
1829 if (diff <= 0) break;
1832 ERR("P2b allocated more than available, diff=%d\n", diff);
1835 if (infoPtr->dwStyle & CCS_VERT)
1836 x = clientcx - diff;
1838 y = clientcy - diff;
1841 /* ******* End Phase 2b - adjust all bands for height full ******* */
1844 /* ******* Start Phase 3 - adjust all bands for width full ******* */
1846 if (infoPtr->uNumBands) {
1849 /* If RBS_BANDBORDERS set then indicate to draw bottom separator */
1850 /* on all bands in all rows but last row. */
1851 /* Also indicate to draw the right separator for each band in */
1852 /* each row but the rightmost band. */
1853 if (infoPtr->dwStyle & RBS_BANDBORDERS) {
1855 for (i=0; i<infoPtr->uNumBands; i++) {
1856 lpBand = &infoPtr->bands[i];
1857 if (HIDDENBAND(lpBand))
1860 /* not righthand bands */
1861 if( !(lpBand->fDraw & DRAW_LAST_IN_ROW) )
1862 lpBand->fDraw |= DRAW_RIGHTSEP;
1864 /* not the last row */
1865 if( lpBand->iRow != infoPtr->uNumRows )
1866 lpBand->fDraw |= DRAW_BOTTOMSEP;
1870 /* Distribute the extra space on the horizontal and adjust */
1871 /* all bands in row to same height. */
1874 for (i=0; i<infoPtr->uNumBands; i++) {
1876 lpBand = &infoPtr->bands[i];
1878 if( lpBand->fDraw & DRAW_FIRST_IN_ROW )
1884 if ( (mcy < ircBw(lpBand)) && !HIDDENBAND(lpBand) )
1885 mcy = ircBw(lpBand);
1887 if( lpBand->fDraw & DRAW_LAST_IN_ROW )
1889 TRACE("P3 processing row %d, starting band %d, ending band %d\n",
1890 lpBand->iRow, startband, i);
1892 ERR("Last band %d with no first, row %d\n", i, lpBand->iRow);
1894 REBAR_AdjustBands (infoPtr, startband, i,
1895 (infoPtr->dwStyle & CCS_VERT) ?
1896 clientcy : clientcx, mcy);
1900 /* Calculate the other rectangles in each band */
1901 if (infoPtr->dwStyle & CCS_VERT) {
1902 REBAR_CalcVertBand (infoPtr, 0, infoPtr->uNumBands,
1906 REBAR_CalcHorzBand (infoPtr, 0, infoPtr->uNumBands,
1911 /* ******* End Phase 3 - adjust all bands for width full ******* */
1913 /* now compute size of Rebar itself */
1914 infoPtr->oldSize = infoPtr->calcSize;
1915 if (infoPtr->uNumBands == 0) {
1916 /* we have no bands, so make size the size of client */
1920 if (infoPtr->dwStyle & CCS_VERT) {
1921 if( infoPtr->uNumBands != 0 && x < REBAR_MINSIZE )
1923 infoPtr->calcSize.cx = x;
1924 infoPtr->calcSize.cy = clientcy;
1925 TRACE("vert, notify=%d, x=%d, origheight=%d\n",
1926 notify, x, origheight);
1927 if (notify && (x != origheight)) infoPtr->fStatus |= NTF_HGHTCHG;
1930 if( infoPtr->uNumBands != 0 && y < REBAR_MINSIZE )
1932 infoPtr->calcSize.cx = clientcx;
1933 infoPtr->calcSize.cy = y;
1934 TRACE("horz, notify=%d, y=%d, origheight=%d\n",
1935 notify, y, origheight);
1936 if (notify && (y != origheight)) infoPtr->fStatus |= NTF_HGHTCHG;
1939 REBAR_DumpBand (infoPtr);
1941 REBAR_MoveChildWindows (infoPtr, 0, infoPtr->uNumBands);
1943 REBAR_ForceResize (infoPtr);
1948 REBAR_ValidateBand (REBAR_INFO *infoPtr, REBAR_BAND *lpBand)
1949 /* Function: This routine evaluates the band specs supplied */
1950 /* by the user and updates the following 5 fields in */
1951 /* the internal band structure: cxHeader, lcx, lcy, hcx, hcy*/
1958 lpBand->fStatus = 0;
1966 /* Data coming in from users into the cx... and cy... fields */
1967 /* may be bad, just garbage, because the user never clears */
1968 /* the fields. RB_{SET|INSERT}BAND{A|W} just passes the data */
1969 /* along if the fields exist in the input area. Here we must */
1970 /* determine if the data is valid. I have no idea how MS does */
1971 /* the validation, but it does because the RB_GETBANDINFO */
1972 /* returns a 0 when I know the sample program passed in an */
1973 /* address. Here I will use the algorithm that if the value */
1974 /* is greater than 65535 then it is bad and replace it with */
1975 /* a zero. Feel free to improve the algorithm. - GA 12/2000 */
1976 if (lpBand->cxMinChild > 65535) lpBand->cxMinChild = 0;
1977 if (lpBand->cyMinChild > 65535) lpBand->cyMinChild = 0;
1978 if (lpBand->cx > 65535) lpBand->cx = 0;
1979 if (lpBand->cyChild > 65535) lpBand->cyChild = 0;
1980 if (lpBand->cyMaxChild > 65535) lpBand->cyMaxChild = 0;
1981 if (lpBand->cyIntegral > 65535) lpBand->cyIntegral = 0;
1982 if (lpBand->cxIdeal > 65535) lpBand->cxIdeal = 0;
1983 if (lpBand->cxHeader > 65535) lpBand->cxHeader = 0;
1985 /* FIXME: probably should only set NEEDS_LAYOUT flag when */
1986 /* values change. Till then always set it. */
1987 TRACE("setting NEEDS_LAYOUT\n");
1988 infoPtr->fStatus |= BAND_NEEDS_LAYOUT;
1990 /* Header is where the image, text and gripper exist */
1991 /* in the band and precede the child window. */
1993 /* count number of non-FIXEDSIZE and non-Hidden bands */
1995 for (i=0; i<infoPtr->uNumBands; i++){
1996 tBand = &infoPtr->bands[i];
1997 if (!HIDDENBAND(tBand) && !(tBand->fStyle & RBBS_FIXEDSIZE))
2001 /* calculate gripper rectangle */
2002 if ( (!(lpBand->fStyle & RBBS_NOGRIPPER)) &&
2003 ( (lpBand->fStyle & RBBS_GRIPPERALWAYS) ||
2004 ( !(lpBand->fStyle & RBBS_FIXEDSIZE) && (nonfixed > 1)))
2006 lpBand->fStatus |= HAS_GRIPPER;
2007 if (infoPtr->dwStyle & CCS_VERT)
2008 if (infoPtr->dwStyle & RBS_VERTICALGRIPPER)
2009 header += (GRIPPER_HEIGHT + REBAR_PRE_GRIPPER);
2011 header += (GRIPPER_WIDTH + REBAR_PRE_GRIPPER);
2013 header += (REBAR_PRE_GRIPPER + GRIPPER_WIDTH);
2014 /* Always have 4 pixels before anything else */
2015 header += REBAR_ALWAYS_SPACE;
2018 /* image is visible */
2019 if ((lpBand->fMask & RBBIM_IMAGE) && (infoPtr->himl)) {
2020 lpBand->fStatus |= HAS_IMAGE;
2021 if (infoPtr->dwStyle & CCS_VERT) {
2022 header += (infoPtr->imageSize.cy + REBAR_POST_IMAGE);
2023 lpBand->lcy = infoPtr->imageSize.cx + 2;
2026 header += (infoPtr->imageSize.cx + REBAR_POST_IMAGE);
2027 lpBand->lcy = infoPtr->imageSize.cy + 2;
2031 /* text is visible */
2032 if ((lpBand->fMask & RBBIM_TEXT) && (lpBand->lpText) &&
2033 !(lpBand->fStyle & RBBS_HIDETITLE)) {
2034 HDC hdc = GetDC (0);
2035 HFONT hOldFont = SelectObject (hdc, infoPtr->hFont);
2038 lpBand->fStatus |= HAS_TEXT;
2039 GetTextExtentPoint32W (hdc, lpBand->lpText,
2040 lstrlenW (lpBand->lpText), &size);
2041 header += ((infoPtr->dwStyle & CCS_VERT) ? (size.cy + REBAR_POST_TEXT) : (size.cx + REBAR_POST_TEXT));
2042 textheight = (infoPtr->dwStyle & CCS_VERT) ? 0 : size.cy;
2044 SelectObject (hdc, hOldFont);
2048 /* if no gripper but either image or text, then leave space */
2049 if ((lpBand->fStatus & (HAS_IMAGE | HAS_TEXT)) &&
2050 !(lpBand->fStatus & HAS_GRIPPER)) {
2051 header += REBAR_ALWAYS_SPACE;
2054 /* check if user overrode the header value */
2055 if (!(lpBand->fStyle & RBBS_UNDOC_FIXEDHEADER))
2056 lpBand->cxHeader = header;
2059 /* Now compute minimum size of child window */
2060 lpBand->offChild.cx = 0;
2061 lpBand->offChild.cy = 0;
2062 lpBand->lcy = textheight;
2063 lpBand->ccy = lpBand->lcy;
2064 if (lpBand->fMask & RBBIM_CHILDSIZE) {
2065 lpBand->lcx = lpBand->cxMinChild;
2067 /* Set the .cy values for CHILDSIZE case */
2068 lpBand->lcy = max(lpBand->lcy, lpBand->cyMinChild);
2069 lpBand->ccy = lpBand->lcy;
2070 lpBand->hcy = lpBand->lcy;
2071 if (lpBand->cyMaxChild != 0xffffffff) {
2072 lpBand->hcy = lpBand->cyMaxChild;
2074 if (lpBand->cyChild != 0xffffffff)
2075 lpBand->ccy = max (lpBand->cyChild, lpBand->lcy);
2077 TRACE("_CHILDSIZE\n");
2079 if (lpBand->fMask & RBBIM_SIZE) {
2080 lpBand->hcx = max (lpBand->cx-lpBand->cxHeader, lpBand->lcx);
2084 lpBand->hcx = lpBand->lcx;
2085 lpBand->ccx = lpBand->hcx;
2087 /* make ->.cx include header size for _Layout */
2088 lpBand->lcx += lpBand->cxHeader;
2089 lpBand->ccx += lpBand->cxHeader;
2090 lpBand->hcx += lpBand->cxHeader;
2095 REBAR_CommonSetupBand(HWND hwnd, LPREBARBANDINFOW lprbbi, REBAR_BAND *lpBand)
2096 /* Function: This routine copies the supplied values from */
2097 /* user input (lprbbi) to the internal band structure. */
2098 /* It returns true if something changed and false if not. */
2100 BOOL bChanged = FALSE;
2102 lpBand->fMask |= lprbbi->fMask;
2104 if( (lprbbi->fMask & RBBIM_STYLE) &&
2105 (lpBand->fStyle != lprbbi->fStyle ) )
2107 lpBand->fStyle = lprbbi->fStyle;
2111 if( (lprbbi->fMask & RBBIM_COLORS) &&
2112 ( ( lpBand->clrFore != lprbbi->clrFore ) ||
2113 ( lpBand->clrBack != lprbbi->clrBack ) ) )
2115 lpBand->clrFore = lprbbi->clrFore;
2116 lpBand->clrBack = lprbbi->clrBack;
2120 if( (lprbbi->fMask & RBBIM_IMAGE) &&
2121 ( lpBand->iImage != lprbbi->iImage ) )
2123 lpBand->iImage = lprbbi->iImage;
2127 if( (lprbbi->fMask & RBBIM_CHILD) &&
2128 (lprbbi->hwndChild != lpBand->hwndChild ) )
2130 if (lprbbi->hwndChild) {
2131 lpBand->hwndChild = lprbbi->hwndChild;
2132 lpBand->hwndPrevParent =
2133 SetParent (lpBand->hwndChild, hwnd);
2134 /* below in trace from WinRAR */
2135 ShowWindow(lpBand->hwndChild, SW_SHOWNOACTIVATE | SW_SHOWNORMAL);
2136 /* above in trace from WinRAR */
2139 TRACE("child: %p prev parent: %p\n",
2140 lpBand->hwndChild, lpBand->hwndPrevParent);
2141 lpBand->hwndChild = 0;
2142 lpBand->hwndPrevParent = 0;
2147 if( (lprbbi->fMask & RBBIM_CHILDSIZE) &&
2148 ( (lpBand->cxMinChild != lprbbi->cxMinChild) ||
2149 (lpBand->cyMinChild != lprbbi->cyMinChild ) ||
2150 ( (lprbbi->cbSize >= sizeof (REBARBANDINFOA)) &&
2151 ( (lpBand->cyChild != lprbbi->cyChild ) ||
2152 (lpBand->cyMaxChild != lprbbi->cyMaxChild ) ||
2153 (lpBand->cyIntegral != lprbbi->cyIntegral ) ) ) ||
2154 ( (lprbbi->cbSize < sizeof (REBARBANDINFOA)) &&
2155 ( (lpBand->cyChild ||
2156 lpBand->cyMaxChild ||
2157 lpBand->cyIntegral ) ) ) ) )
2159 lpBand->cxMinChild = lprbbi->cxMinChild;
2160 lpBand->cyMinChild = lprbbi->cyMinChild;
2161 if (lprbbi->cbSize >= sizeof (REBARBANDINFOA)) {
2162 lpBand->cyChild = lprbbi->cyChild;
2163 lpBand->cyMaxChild = lprbbi->cyMaxChild;
2164 lpBand->cyIntegral = lprbbi->cyIntegral;
2166 else { /* special case - these should be zeroed out since */
2167 /* RBBIM_CHILDSIZE added these in WIN32_IE >= 0x0400 */
2168 lpBand->cyChild = 0;
2169 lpBand->cyMaxChild = 0;
2170 lpBand->cyIntegral = 0;
2175 if( (lprbbi->fMask & RBBIM_SIZE) &&
2176 (lpBand->cx != lprbbi->cx ) )
2178 lpBand->cx = lprbbi->cx;
2182 if( (lprbbi->fMask & RBBIM_BACKGROUND) &&
2183 ( lpBand->hbmBack != lprbbi->hbmBack ) )
2185 lpBand->hbmBack = lprbbi->hbmBack;
2189 if( (lprbbi->fMask & RBBIM_ID) &&
2190 (lpBand->wID != lprbbi->wID ) )
2192 lpBand->wID = lprbbi->wID;
2196 /* check for additional data */
2197 if (lprbbi->cbSize >= sizeof (REBARBANDINFOA)) {
2198 if( (lprbbi->fMask & RBBIM_IDEALSIZE) &&
2199 ( lpBand->cxIdeal != lprbbi->cxIdeal ) )
2201 lpBand->cxIdeal = lprbbi->cxIdeal;
2205 if( (lprbbi->fMask & RBBIM_LPARAM) &&
2206 (lpBand->lParam != lprbbi->lParam ) )
2208 lpBand->lParam = lprbbi->lParam;
2212 if( (lprbbi->fMask & RBBIM_HEADERSIZE) &&
2213 (lpBand->cxHeader != lprbbi->cxHeader ) )
2215 lpBand->cxHeader = lprbbi->cxHeader;
2216 lpBand->fStyle |= RBBS_UNDOC_FIXEDHEADER;
2225 REBAR_InternalEraseBkGnd (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam, RECT *clip)
2226 /* Function: This erases the background rectangle by drawing */
2227 /* each band with its background color (or the default) and */
2228 /* draws each bands right separator if necessary. The row */
2229 /* separators are drawn on the first band of the next row. */
2234 HDC hdc = (HDC)wParam;
2236 COLORREF old = CLR_NONE, new;
2237 HTHEME theme = GetWindowTheme (infoPtr->hwndSelf);
2239 GetClientRect (infoPtr->hwndSelf, &cr);
2242 for(i=0; i<infoPtr->uNumBands; i++) {
2243 lpBand = &infoPtr->bands[i];
2244 if (HIDDENBAND(lpBand)) continue;
2246 /* draw band separator between rows */
2247 if (lpBand->iRow != oldrow) {
2248 oldrow = lpBand->iRow;
2249 if (lpBand->fDraw & DRAW_BOTTOMSEP) {
2251 rcRowSep = lpBand->rcBand;
2252 if (infoPtr->dwStyle & CCS_VERT) {
2253 rcRowSep.right += SEP_WIDTH_SIZE;
2254 rcRowSep.bottom = infoPtr->calcSize.cy;
2256 DrawThemeEdge (theme, hdc, RP_BAND, 0, &rcRowSep, EDGE_ETCHED, BF_RIGHT, NULL);
2258 DrawEdge (hdc, &rcRowSep, EDGE_ETCHED, BF_RIGHT);
2261 rcRowSep.bottom += SEP_WIDTH_SIZE;
2262 rcRowSep.right = infoPtr->calcSize.cx;
2264 DrawThemeEdge (theme, hdc, RP_BAND, 0, &rcRowSep, EDGE_ETCHED, BF_BOTTOM, NULL);
2266 DrawEdge (hdc, &rcRowSep, EDGE_ETCHED, BF_BOTTOM);
2268 TRACE ("drawing band separator bottom (%d,%d)-(%d,%d)\n",
2269 rcRowSep.left, rcRowSep.top,
2270 rcRowSep.right, rcRowSep.bottom);
2274 /* draw band separator between bands in a row */
2275 if (lpBand->fDraw & DRAW_RIGHTSEP) {
2277 rcSep = lpBand->rcBand;
2278 if (infoPtr->dwStyle & CCS_VERT) {
2279 rcSep.bottom += SEP_WIDTH_SIZE;
2281 DrawThemeEdge (theme, hdc, RP_BAND, 0, &rcSep, EDGE_ETCHED, BF_BOTTOM, NULL);
2283 DrawEdge (hdc, &rcSep, EDGE_ETCHED, BF_BOTTOM);
2286 rcSep.right += SEP_WIDTH_SIZE;
2288 DrawThemeEdge (theme, hdc, RP_BAND, 0, &rcSep, EDGE_ETCHED, BF_RIGHT, NULL);
2290 DrawEdge (hdc, &rcSep, EDGE_ETCHED, BF_RIGHT);
2292 TRACE("drawing band separator right (%d,%d)-(%d,%d)\n",
2293 rcSep.left, rcSep.top, rcSep.right, rcSep.bottom);
2296 /* draw the actual background */
2297 if (lpBand->clrBack != CLR_NONE) {
2298 new = (lpBand->clrBack == CLR_DEFAULT) ? infoPtr->clrBtnFace :
2301 /* testing only - make background green to see it */
2306 /* In the absence of documentation for Rebar vs. CLR_NONE,
2307 * we will use the default BtnFace color. Note documentation
2308 * exists for Listview and Imagelist.
2310 new = infoPtr->clrBtnFace;
2312 /* testing only - make background green to see it */
2317 rect = lpBand->rcBand;
2321 /* When themed, the background color is ignored (but not a
2322 * background bitmap */
2323 DrawThemeBackground (theme, hdc, 0, 0, &cr, &rect);
2327 old = SetBkColor (hdc, new);
2328 TRACE("%s background color=0x%06x, band (%d,%d)-(%d,%d), clip (%d,%d)-(%d,%d)\n",
2329 (lpBand->clrBack == CLR_NONE) ? "none" :
2330 ((lpBand->clrBack == CLR_DEFAULT) ? "dft" : ""),
2332 lpBand->rcBand.left,lpBand->rcBand.top,
2333 lpBand->rcBand.right,lpBand->rcBand.bottom,
2334 clip->left, clip->top,
2335 clip->right, clip->bottom);
2336 ExtTextOutW (hdc, 0, 0, ETO_OPAQUE, &rect, NULL, 0, 0);
2337 if (lpBand->clrBack != CLR_NONE)
2338 SetBkColor (hdc, old);
2345 REBAR_InternalHitTest (REBAR_INFO *infoPtr, const LPPOINT lpPt, UINT *pFlags, INT *pBand)
2351 GetClientRect (infoPtr->hwndSelf, &rect);
2353 *pFlags = RBHT_NOWHERE;
2354 if (PtInRect (&rect, *lpPt))
2356 if (infoPtr->uNumBands == 0) {
2357 *pFlags = RBHT_NOWHERE;
2364 /* somewhere inside */
2365 for (iCount = 0; iCount < infoPtr->uNumBands; iCount++) {
2366 lpBand = &infoPtr->bands[iCount];
2367 if (HIDDENBAND(lpBand)) continue;
2368 if (PtInRect (&lpBand->rcBand, *lpPt)) {
2371 if (PtInRect (&lpBand->rcGripper, *lpPt)) {
2372 *pFlags = RBHT_GRABBER;
2373 TRACE("ON GRABBER %d\n", iCount);
2376 else if (PtInRect (&lpBand->rcCapImage, *lpPt)) {
2377 *pFlags = RBHT_CAPTION;
2378 TRACE("ON CAPTION %d\n", iCount);
2381 else if (PtInRect (&lpBand->rcCapText, *lpPt)) {
2382 *pFlags = RBHT_CAPTION;
2383 TRACE("ON CAPTION %d\n", iCount);
2386 else if (PtInRect (&lpBand->rcChild, *lpPt)) {
2387 *pFlags = RBHT_CLIENT;
2388 TRACE("ON CLIENT %d\n", iCount);
2391 else if (PtInRect (&lpBand->rcChevron, *lpPt)) {
2392 *pFlags = RBHT_CHEVRON;
2393 TRACE("ON CHEVRON %d\n", iCount);
2397 *pFlags = RBHT_NOWHERE;
2398 TRACE("NOWHERE %d\n", iCount);
2404 *pFlags = RBHT_NOWHERE;
2413 *pFlags = RBHT_NOWHERE;
2423 REBAR_Shrink (REBAR_INFO *infoPtr, REBAR_BAND *band, INT movement, INT i)
2424 /* Function: This attempts to shrink the given band by the */
2425 /* the amount in "movement". A shrink to the left is indi- */
2426 /* cated by "movement" being negative. "i" is merely the */
2427 /* band index for trace messages. */
2429 INT Leadjust, Readjust, avail, ret;
2431 /* Note: a left drag is indicated by "movement" being negative. */
2432 /* Similarly, a right drag is indicated by "movement" */
2433 /* being positive. "movement" should never be 0, but if */
2434 /* it is then the band does not move. */
2436 avail = rcBw(band) - band->lcx;
2438 /* now compute the Left End adjustment factor and Right End */
2439 /* adjustment factor. They may be different if shrinking. */
2441 /* if this band is not shrinkable, then just move it */
2442 Leadjust = Readjust = movement;
2448 if (avail <= abs(movement)) {
2449 Readjust = movement;
2450 Leadjust = movement + avail;
2454 Readjust = movement;
2461 if (avail <= abs(movement)) {
2462 Leadjust = movement;
2463 Readjust = movement - avail;
2467 Leadjust = movement;
2474 /* Reasonability Check */
2475 if (rcBlt(band) + Leadjust < 0) {
2476 ERR("adjustment will fail, band %d: left=%d, right=%d, move=%d, rtn=%d\n",
2477 i, Leadjust, Readjust, movement, ret);
2480 LEADJ(band, Leadjust);
2481 READJ(band, Readjust);
2483 TRACE("band %d: left=%d, right=%d, move=%d, rtn=%d, rcBand=(%d,%d)-(%d,%d)\n",
2484 i, Leadjust, Readjust, movement, ret,
2485 band->rcBand.left, band->rcBand.top,
2486 band->rcBand.right, band->rcBand.bottom);
2492 REBAR_HandleLRDrag (REBAR_INFO *infoPtr, const POINT *ptsmove)
2493 /* Function: This will implement the functionality of a */
2494 /* Gripper drag within a row. It will not implement "out- */
2495 /* of-row" drags. (They are detected and handled in */
2496 /* REBAR_MouseMove.) */
2497 /* **** FIXME Switching order of bands in a row not **** */
2498 /* **** yet implemented. **** */
2500 REBAR_BAND *hitBand, *band, *mindBand, *maxdBand;
2502 INT imindBand = -1, imaxdBand, ihitBand, i, movement;
2503 INT RHeaderSum = 0, LHeaderSum = 0;
2506 /* on first significant mouse movement, issue notify */
2508 if (!(infoPtr->fStatus & BEGIN_DRAG_ISSUED)) {
2509 if (REBAR_Notify_NMREBAR (infoPtr, -1, RBN_BEGINDRAG)) {
2510 /* Notify returned TRUE - abort drag */
2511 infoPtr->dragStart.x = 0;
2512 infoPtr->dragStart.y = 0;
2513 infoPtr->dragNow = infoPtr->dragStart;
2514 infoPtr->iGrabbedBand = -1;
2518 infoPtr->fStatus |= BEGIN_DRAG_ISSUED;
2521 ihitBand = infoPtr->iGrabbedBand;
2522 hitBand = &infoPtr->bands[ihitBand];
2523 imaxdBand = ihitBand; /* to suppress warning message */
2525 /* find all the bands in the row of the one whose Gripper was seized */
2526 for (i=0; i<infoPtr->uNumBands; i++) {
2527 band = &infoPtr->bands[i];
2528 if (HIDDENBAND(band)) continue;
2529 if (band->iRow == hitBand->iRow) {
2531 if (imindBand == -1) imindBand = i;
2532 /* minimum size of each band is size of header plus */
2533 /* size of minimum child plus offset of child from header plus */
2534 /* one to separate each band. */
2536 LHeaderSum += (band->lcx + SEP_WIDTH);
2538 RHeaderSum += (band->lcx + SEP_WIDTH);
2542 if (RHeaderSum) RHeaderSum -= SEP_WIDTH; /* no separator after last band */
2544 mindBand = &infoPtr->bands[imindBand];
2545 maxdBand = &infoPtr->bands[imaxdBand];
2547 if (imindBand == imaxdBand) return; /* nothing to drag against */
2548 if (imindBand == ihitBand) return; /* first band in row, can't drag */
2550 /* limit movement to inside adjustable bands - Left */
2551 if ( (ptsmove->x < mindBand->rcBand.left) ||
2552 (ptsmove->x > maxdBand->rcBand.right) ||
2553 (ptsmove->y < mindBand->rcBand.top) ||
2554 (ptsmove->y > maxdBand->rcBand.bottom))
2555 return; /* should swap bands */
2557 if (infoPtr->dwStyle & CCS_VERT)
2558 movement = ptsmove->y - ((hitBand->rcBand.top+REBAR_PRE_GRIPPER) -
2559 infoPtr->ihitoffset);
2561 movement = ptsmove->x - ((hitBand->rcBand.left+REBAR_PRE_GRIPPER) -
2562 infoPtr->ihitoffset);
2563 infoPtr->dragNow = *ptsmove;
2565 TRACE("before: movement=%d (%d,%d), imindBand=%d, ihitBand=%d, imaxdBand=%d, LSum=%d, RSum=%d\n",
2566 movement, ptsmove->x, ptsmove->y, imindBand, ihitBand,
2567 imaxdBand, LHeaderSum, RHeaderSum);
2568 REBAR_DumpBand (infoPtr);
2572 /* *** Drag left/up *** */
2573 compress = rcBlt(hitBand) - rcBlt(mindBand) -
2575 if (compress < abs(movement)) {
2576 TRACE("limiting left drag, was %d changed to %d\n",
2577 movement, -compress);
2578 movement = -compress;
2581 for (i=ihitBand; i>=imindBand; i--) {
2582 band = &infoPtr->bands[i];
2583 if (HIDDENBAND(band)) continue;
2584 if (i == ihitBand) {
2585 LEADJ(band, movement);
2588 movement = REBAR_Shrink (infoPtr, band, movement, i);
2589 band->ccx = rcBw(band);
2595 /* *** Drag right/down *** */
2596 compress = rcBrb(maxdBand) - rcBlt(hitBand) -
2598 if (compress < abs(movement)) {
2599 TRACE("limiting right drag, was %d changed to %d\n",
2600 movement, compress);
2601 movement = compress;
2603 for (i=ihitBand-1; i<=imaxdBand; i++) {
2604 band = &infoPtr->bands[i];
2605 if (HIDDENBAND(band)) continue;
2608 READJ(band, movement);
2611 movement = REBAR_Shrink (infoPtr, band, movement, i);
2612 band->ccx = rcBw(band);
2616 /* recompute all rectangles */
2617 if (infoPtr->dwStyle & CCS_VERT) {
2618 REBAR_CalcVertBand (infoPtr, imindBand, imaxdBand+1,
2622 REBAR_CalcHorzBand (infoPtr, imindBand, imaxdBand+1,
2626 TRACE("bands after adjustment, see band # %d, %d\n",
2627 imindBand, imaxdBand);
2628 REBAR_DumpBand (infoPtr);
2631 mindBand->rcBand.left,
2632 mindBand->rcBand.top,
2633 maxdBand->rcBand.right,
2634 maxdBand->rcBand.bottom);
2636 REBAR_MoveChildWindows (infoPtr, imindBand, imaxdBand+1);
2638 InvalidateRect (infoPtr->hwndSelf, &newrect, TRUE);
2639 UpdateWindow (infoPtr->hwndSelf);
2645 /* << REBAR_BeginDrag >> */
2649 REBAR_DeleteBand (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
2651 UINT uBand = (UINT)wParam;
2654 if (uBand >= infoPtr->uNumBands)
2657 TRACE("deleting band %u!\n", uBand);
2658 lpBand = &infoPtr->bands[uBand];
2659 REBAR_Notify_NMREBAR (infoPtr, uBand, RBN_DELETINGBAND);
2660 /* TODO: a return of 1 should probably cancel the deletion */
2662 if (lpBand->hwndChild)
2663 ShowWindow(lpBand->hwndChild, SW_HIDE);
2664 Free(lpBand->lpText);
2666 infoPtr->uNumBands--;
2667 memmove(&infoPtr->bands[uBand], &infoPtr->bands[uBand+1],
2668 (infoPtr->uNumBands - uBand) * sizeof(REBAR_BAND));
2669 infoPtr->bands = ReAlloc(infoPtr->bands, infoPtr->uNumBands * sizeof(REBAR_BAND));
2671 REBAR_Notify_NMREBAR (infoPtr, -1, RBN_DELETEDBAND);
2673 /* if only 1 band left the re-validate to possible eliminate gripper */
2674 if (infoPtr->uNumBands == 1)
2675 REBAR_ValidateBand (infoPtr, &infoPtr->bands[0]);
2677 TRACE("setting NEEDS_LAYOUT\n");
2678 infoPtr->fStatus |= BAND_NEEDS_LAYOUT;
2679 infoPtr->fStatus |= RESIZE_ANYHOW;
2680 REBAR_Layout (infoPtr, NULL, TRUE, FALSE);
2686 /* << REBAR_DragMove >> */
2687 /* << REBAR_EndDrag >> */
2691 REBAR_GetBandBorders (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
2693 LPRECT lpRect = (LPRECT)lParam;
2698 if ((UINT)wParam >= infoPtr->uNumBands)
2701 lpBand = &infoPtr->bands[(UINT)wParam];
2703 /* FIXME - the following values were determined by experimentation */
2704 /* with the REBAR Control Spy. I have guesses as to what the 4 and */
2705 /* 1 are, but I am not sure. There doesn't seem to be any actual */
2706 /* difference in size of the control area with and without the */
2708 if (infoPtr->dwStyle & RBS_BANDBORDERS) {
2709 if (infoPtr->dwStyle & CCS_VERT) {
2711 lpRect->top = lpBand->cxHeader + 4;
2716 lpRect->left = lpBand->cxHeader + 4;
2723 lpRect->left = lpBand->cxHeader;
2729 inline static LRESULT
2730 REBAR_GetBandCount (REBAR_INFO *infoPtr)
2732 TRACE("band count %u!\n", infoPtr->uNumBands);
2734 return infoPtr->uNumBands;
2739 REBAR_GetBandInfoT(REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam, BOOL bUnicode)
2741 LPREBARBANDINFOW lprbbi = (LPREBARBANDINFOW)lParam;
2746 if (lprbbi->cbSize < REBARBANDINFOA_V3_SIZE)
2748 if ((UINT)wParam >= infoPtr->uNumBands)
2751 TRACE("index %u (bUnicode=%d)\n", (UINT)wParam, bUnicode);
2753 /* copy band information */
2754 lpBand = &infoPtr->bands[(UINT)wParam];
2756 if (lprbbi->fMask & RBBIM_STYLE)
2757 lprbbi->fStyle = lpBand->fStyle;
2759 if (lprbbi->fMask & RBBIM_COLORS) {
2760 lprbbi->clrFore = lpBand->clrFore;
2761 lprbbi->clrBack = lpBand->clrBack;
2762 if (lprbbi->clrBack == CLR_DEFAULT)
2763 lprbbi->clrBack = infoPtr->clrBtnFace;
2766 if (lprbbi->fMask & RBBIM_TEXT) {
2768 Str_GetPtrW(lpBand->lpText, lprbbi->lpText, lprbbi->cch);
2770 Str_GetPtrWtoA(lpBand->lpText, (LPSTR)lprbbi->lpText, lprbbi->cch);
2773 if (lprbbi->fMask & RBBIM_IMAGE)
2774 lprbbi->iImage = lpBand->iImage;
2776 if (lprbbi->fMask & RBBIM_CHILD)
2777 lprbbi->hwndChild = lpBand->hwndChild;
2779 if (lprbbi->fMask & RBBIM_CHILDSIZE) {
2780 lprbbi->cxMinChild = lpBand->cxMinChild;
2781 lprbbi->cyMinChild = lpBand->cyMinChild;
2782 if (lprbbi->cbSize >= sizeof (REBARBANDINFOA)) {
2783 lprbbi->cyChild = lpBand->cyChild;
2784 lprbbi->cyMaxChild = lpBand->cyMaxChild;
2785 lprbbi->cyIntegral = lpBand->cyIntegral;
2789 if (lprbbi->fMask & RBBIM_SIZE)
2790 lprbbi->cx = lpBand->cx;
2792 if (lprbbi->fMask & RBBIM_BACKGROUND)
2793 lprbbi->hbmBack = lpBand->hbmBack;
2795 if (lprbbi->fMask & RBBIM_ID)
2796 lprbbi->wID = lpBand->wID;
2798 /* check for additional data */
2799 if (lprbbi->cbSize >= sizeof (REBARBANDINFOA)) {
2800 if (lprbbi->fMask & RBBIM_IDEALSIZE)
2801 lprbbi->cxIdeal = lpBand->cxIdeal;
2803 if (lprbbi->fMask & RBBIM_LPARAM)
2804 lprbbi->lParam = lpBand->lParam;
2806 if (lprbbi->fMask & RBBIM_HEADERSIZE)
2807 lprbbi->cxHeader = lpBand->cxHeader;
2810 REBAR_DumpBandInfo(lprbbi);
2817 REBAR_GetBarHeight (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
2821 nHeight = (infoPtr->dwStyle & CCS_VERT) ? infoPtr->calcSize.cx : infoPtr->calcSize.cy;
2823 TRACE("height = %d\n", nHeight);
2830 REBAR_GetBarInfo (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
2832 LPREBARINFO lpInfo = (LPREBARINFO)lParam;
2837 if (lpInfo->cbSize < sizeof (REBARINFO))
2840 TRACE("getting bar info!\n");
2842 if (infoPtr->himl) {
2843 lpInfo->himl = infoPtr->himl;
2844 lpInfo->fMask |= RBIM_IMAGELIST;
2851 inline static LRESULT
2852 REBAR_GetBkColor (REBAR_INFO *infoPtr)
2854 COLORREF clr = infoPtr->clrBk;
2856 if (clr == CLR_DEFAULT)
2857 clr = infoPtr->clrBtnFace;
2859 TRACE("background color 0x%06x!\n", clr);
2865 /* << REBAR_GetColorScheme >> */
2866 /* << REBAR_GetDropTarget >> */
2870 REBAR_GetPalette (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
2872 FIXME("empty stub!\n");
2879 REBAR_GetRect (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
2881 INT iBand = (INT)wParam;
2882 LPRECT lprc = (LPRECT)lParam;
2885 if ((iBand < 0) && ((UINT)iBand >= infoPtr->uNumBands))
2890 lpBand = &infoPtr->bands[iBand];
2891 CopyRect (lprc, &lpBand->rcBand);
2893 TRACE("band %d, (%d,%d)-(%d,%d)\n", iBand,
2894 lprc->left, lprc->top, lprc->right, lprc->bottom);
2900 inline static LRESULT
2901 REBAR_GetRowCount (REBAR_INFO *infoPtr)
2903 TRACE("%u\n", infoPtr->uNumRows);
2905 return infoPtr->uNumRows;
2910 REBAR_GetRowHeight (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
2912 INT iRow = (INT)wParam;
2917 for (i=0; i<infoPtr->uNumBands; i++) {
2918 lpBand = &infoPtr->bands[i];
2919 if (HIDDENBAND(lpBand)) continue;
2920 if (lpBand->iRow != iRow) continue;
2921 if (infoPtr->dwStyle & CCS_VERT)
2922 j = lpBand->rcBand.right - lpBand->rcBand.left;
2924 j = lpBand->rcBand.bottom - lpBand->rcBand.top;
2925 if (j > ret) ret = j;
2928 TRACE("row %d, height %d\n", iRow, ret);
2934 inline static LRESULT
2935 REBAR_GetTextColor (REBAR_INFO *infoPtr)
2937 TRACE("text color 0x%06x!\n", infoPtr->clrText);
2939 return infoPtr->clrText;
2943 inline static LRESULT
2944 REBAR_GetToolTips (REBAR_INFO *infoPtr)
2946 return (LRESULT)infoPtr->hwndToolTip;
2950 inline static LRESULT
2951 REBAR_GetUnicodeFormat (REBAR_INFO *infoPtr)
2953 TRACE("%s hwnd=%p\n",
2954 infoPtr->bUnicode ? "TRUE" : "FALSE", infoPtr->hwndSelf);
2956 return infoPtr->bUnicode;
2960 inline static LRESULT
2961 REBAR_GetVersion (REBAR_INFO *infoPtr)
2963 TRACE("version %d\n", infoPtr->iVersion);
2964 return infoPtr->iVersion;
2969 REBAR_HitTest (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
2971 LPRBHITTESTINFO lprbht = (LPRBHITTESTINFO)lParam;
2976 REBAR_InternalHitTest (infoPtr, &lprbht->pt, &lprbht->flags, &lprbht->iBand);
2978 return lprbht->iBand;
2983 REBAR_IdToIndex (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
2987 if (infoPtr == NULL)
2990 if (infoPtr->uNumBands < 1)
2993 for (i = 0; i < infoPtr->uNumBands; i++) {
2994 if (infoPtr->bands[i].wID == (UINT)wParam) {
2995 TRACE("id %u is band %u found!\n", (UINT)wParam, i);
3000 TRACE("id %u is not found\n", (UINT)wParam);
3006 REBAR_InsertBandT(REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam, BOOL bUnicode)
3008 LPREBARBANDINFOW lprbbi = (LPREBARBANDINFOW)lParam;
3009 UINT uIndex = (UINT)wParam;
3012 if (infoPtr == NULL)
3016 if (lprbbi->cbSize < REBARBANDINFOA_V3_SIZE)
3019 /* trace the index as signed to see the -1 */
3020 TRACE("insert band at %d (bUnicode=%d)!\n", (INT)uIndex, bUnicode);
3021 REBAR_DumpBandInfo(lprbbi);
3023 infoPtr->bands = ReAlloc(infoPtr->bands, (infoPtr->uNumBands+1) * sizeof(REBAR_BAND));
3024 if (((INT)uIndex == -1) || (uIndex > infoPtr->uNumBands))
3025 uIndex = infoPtr->uNumBands;
3026 memmove(&infoPtr->bands[uIndex+1], &infoPtr->bands[uIndex],
3027 sizeof(REBAR_BAND) * (infoPtr->uNumBands - uIndex));
3028 infoPtr->uNumBands++;
3030 TRACE("index %u!\n", uIndex);
3032 /* initialize band (infoPtr->bands[uIndex])*/
3033 lpBand = &infoPtr->bands[uIndex];
3034 ZeroMemory(lpBand, sizeof(*lpBand));
3035 lpBand->clrFore = infoPtr->clrText;
3036 lpBand->clrBack = infoPtr->clrBk;
3037 lpBand->iImage = -1;
3039 REBAR_CommonSetupBand(infoPtr->hwndSelf, lprbbi, lpBand);
3040 if ((lprbbi->fMask & RBBIM_TEXT) && (lprbbi->lpText)) {
3042 Str_SetPtrW(&lpBand->lpText, lprbbi->lpText);
3044 Str_SetPtrAtoW(&lpBand->lpText, (LPSTR)lprbbi->lpText);
3047 REBAR_ValidateBand (infoPtr, lpBand);
3048 /* On insert of second band, revalidate band 1 to possible add gripper */
3049 if (infoPtr->uNumBands == 2)
3050 REBAR_ValidateBand (infoPtr, &infoPtr->bands[0]);
3052 REBAR_DumpBand (infoPtr);
3054 REBAR_Layout (infoPtr, NULL, TRUE, FALSE);
3055 InvalidateRect(infoPtr->hwndSelf, 0, TRUE);
3062 REBAR_MaximizeBand (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3065 UINT uBand = (UINT) wParam;
3068 if ((infoPtr->uNumBands == 0) ||
3069 ((INT)uBand < 0) || (uBand >= infoPtr->uNumBands)) {
3071 ERR("Illegal MaximizeBand, requested=%d, current band count=%d\n",
3072 (INT)uBand, infoPtr->uNumBands);
3076 lpBand = &infoPtr->bands[uBand];
3078 if (lParam && (lpBand->fMask & RBBIM_IDEALSIZE)) {
3079 /* handle setting ideal size */
3080 lpBand->ccx = lpBand->cxIdeal;
3083 /* handle setting to max */
3084 FIXME("(uBand = %u fIdeal = %s) case not coded\n",
3085 (UINT)wParam, lParam ? "TRUE" : "FALSE");
3089 infoPtr->fStatus |= BAND_NEEDS_LAYOUT;
3090 REBAR_Layout (infoPtr, 0, TRUE, TRUE);
3091 InvalidateRect (infoPtr->hwndSelf, 0, TRUE);
3099 REBAR_MinimizeBand (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3101 REBAR_BAND *band, *lpBand;
3102 UINT uBand = (UINT) wParam;
3104 INT imindBand, imaxdBand, iprevBand, startBand, endBand;
3107 /* A "minimize" band is equivalent to "dragging" the gripper
3108 * of than band to the right till the band is only the size
3113 if ((infoPtr->uNumBands == 0) ||
3114 ((INT)uBand < 0) || (uBand >= infoPtr->uNumBands)) {
3116 ERR("Illegal MinimizeBand, requested=%d, current band count=%d\n",
3117 (INT)uBand, infoPtr->uNumBands);
3121 /* compute amount of movement and validate */
3122 lpBand = &infoPtr->bands[uBand];
3124 if (infoPtr->dwStyle & CCS_VERT)
3125 movement = lpBand->rcBand.bottom - lpBand->rcBand.top -
3128 movement = lpBand->rcBand.right - lpBand->rcBand.left -
3131 ERR("something is wrong, band=(%d,%d)-(%d,%d), cxheader=%d\n",
3132 lpBand->rcBand.left, lpBand->rcBand.top,
3133 lpBand->rcBand.right, lpBand->rcBand.bottom,
3140 iprevBand = -1; /* to suppress warning message */
3142 /* find the first band in row of the one whose is being minimized */
3143 for (i=0; i<infoPtr->uNumBands; i++) {
3144 band = &infoPtr->bands[i];
3145 if (HIDDENBAND(band)) continue;
3146 if (band->iRow == lpBand->iRow) {
3148 if (imindBand == -1) imindBand = i;
3152 /* if the selected band is first in row then need to expand */
3153 /* next visible band */
3154 if (imindBand == uBand) {
3156 movement = -movement;
3157 /* find the first visible band to the right of the selected band */
3158 for (i=uBand+1; i<=imaxdBand; i++) {
3159 band = &infoPtr->bands[i];
3160 if (!HIDDENBAND(band)) {
3162 LEADJ(band, movement);
3163 band->ccx = rcBw(band);
3167 /* what case is this */
3168 if (iprevBand == -1) {
3169 ERR("no previous visible band\n");
3173 endBand = iprevBand;
3175 lpBand->rcBand.left,
3178 band->rcBand.bottom);
3180 /* otherwise expand previous visible band */
3183 /* find the first visible band to the left of the selected band */
3184 for (i=uBand-1; i>=imindBand; i--) {
3185 band = &infoPtr->bands[i];
3186 if (!HIDDENBAND(band)) {
3188 READJ(band, movement);
3189 band->ccx = rcBw(band);
3193 /* what case is this */
3194 if (iprevBand == -1) {
3195 ERR("no previous visible band\n");
3198 startBand = iprevBand;
3203 lpBand->rcBand.right,
3204 lpBand->rcBand.bottom);
3207 REBAR_Shrink (infoPtr, lpBand, movement, uBand);
3209 /* recompute all rectangles */
3210 if (infoPtr->dwStyle & CCS_VERT) {
3211 REBAR_CalcVertBand (infoPtr, startBand, endBand+1,
3215 REBAR_CalcHorzBand (infoPtr, startBand, endBand+1,
3219 TRACE("bands after minimize, see band # %d, %d\n",
3220 startBand, endBand);
3221 REBAR_DumpBand (infoPtr);
3223 REBAR_MoveChildWindows (infoPtr, startBand, endBand+1);
3225 InvalidateRect (infoPtr->hwndSelf, &newrect, TRUE);
3226 UpdateWindow (infoPtr->hwndSelf);
3232 REBAR_MoveBand (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3234 REBAR_BAND *oldBands = infoPtr->bands;
3236 UINT uFrom = (UINT)wParam;
3237 UINT uTo = (UINT)lParam;
3240 if ((infoPtr->uNumBands == 0) ||
3241 ((INT)uFrom < 0) || (uFrom >= infoPtr->uNumBands) ||
3242 ((INT)uTo < 0) || (uTo >= infoPtr->uNumBands)) {
3244 ERR("Illegal MoveBand, from=%d, to=%d, current band count=%d\n",
3245 (INT)uFrom, (INT)uTo, infoPtr->uNumBands);
3249 /* save one to be moved */
3250 memcpy (&holder, &oldBands[uFrom], sizeof(REBAR_BAND));
3252 /* close up rest of bands (pseudo delete) */
3253 if (uFrom < infoPtr->uNumBands - 1) {
3254 memcpy (&oldBands[uFrom], &oldBands[uFrom+1],
3255 (infoPtr->uNumBands - uFrom - 1) * sizeof(REBAR_BAND));
3258 /* allocate new space and copy rest of bands into it */
3260 (REBAR_BAND *)Alloc ((infoPtr->uNumBands)*sizeof(REBAR_BAND));
3262 /* pre insert copy */
3264 memcpy (&infoPtr->bands[0], &oldBands[0],
3265 uTo * sizeof(REBAR_BAND));
3268 /* set moved band */
3269 memcpy (&infoPtr->bands[uTo], &holder, sizeof(REBAR_BAND));
3272 if (uTo < infoPtr->uNumBands - 1) {
3273 memcpy (&infoPtr->bands[uTo+1], &oldBands[uTo],
3274 (infoPtr->uNumBands - uTo - 1) * sizeof(REBAR_BAND));
3279 TRACE("moved band %d to index %d\n", uFrom, uTo);
3280 REBAR_DumpBand (infoPtr);
3282 infoPtr->fStatus |= BAND_NEEDS_LAYOUT;
3283 /* **************************************************** */
3285 /* We do not do a REBAR_Layout here because the native */
3286 /* control does not do that. The actual layout and */
3287 /* repaint is done by the *next* real action, ex.: */
3288 /* RB_INSERTBAND, RB_DELETEBAND, RB_SIZETORECT, etc. */
3290 /* **************************************************** */
3296 /* return TRUE if two strings are different */
3298 REBAR_strdifW( LPCWSTR a, LPCWSTR b )
3300 return ( (a && !b) || (b && !a) || (a && b && lstrcmpW(a, b) ) );
3304 REBAR_SetBandInfoT(REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam, BOOL bUnicode)
3306 LPREBARBANDINFOW lprbbi = (LPREBARBANDINFOW)lParam;
3312 if (lprbbi->cbSize < REBARBANDINFOA_V3_SIZE)
3314 if ((UINT)wParam >= infoPtr->uNumBands)
3317 TRACE("index %u\n", (UINT)wParam);
3318 REBAR_DumpBandInfo (lprbbi);
3320 /* set band information */
3321 lpBand = &infoPtr->bands[(UINT)wParam];
3323 bChanged = REBAR_CommonSetupBand (infoPtr->hwndSelf, lprbbi, lpBand);
3324 if (lprbbi->fMask & RBBIM_TEXT) {
3327 Str_SetPtrW(&wstr, lprbbi->lpText);
3329 Str_SetPtrAtoW(&wstr, (LPSTR)lprbbi->lpText);
3331 if (REBAR_strdifW(wstr, lprbbi->lpText)) {
3332 Free(lpBand->lpText);
3333 lpBand->lpText = wstr;
3340 REBAR_ValidateBand (infoPtr, lpBand);
3342 REBAR_DumpBand (infoPtr);
3344 if (bChanged && (lprbbi->fMask & (RBBIM_CHILDSIZE | RBBIM_SIZE))) {
3345 REBAR_Layout (infoPtr, NULL, TRUE, FALSE);
3346 InvalidateRect(infoPtr->hwndSelf, 0, 1);
3354 REBAR_SetBarInfo (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3356 LPREBARINFO lpInfo = (LPREBARINFO)lParam;
3363 if (lpInfo->cbSize < sizeof (REBARINFO))
3366 TRACE("setting bar info!\n");
3368 if (lpInfo->fMask & RBIM_IMAGELIST) {
3369 infoPtr->himl = lpInfo->himl;
3370 if (infoPtr->himl) {
3372 ImageList_GetIconSize (infoPtr->himl, &cx, &cy);
3373 infoPtr->imageSize.cx = cx;
3374 infoPtr->imageSize.cy = cy;
3377 infoPtr->imageSize.cx = 0;
3378 infoPtr->imageSize.cy = 0;
3380 TRACE("new image cx=%d, cy=%d\n", infoPtr->imageSize.cx,
3381 infoPtr->imageSize.cy);
3384 /* revalidate all bands to reset flags for images in headers of bands */
3385 for (i=0; i<infoPtr->uNumBands; i++) {
3386 lpBand = &infoPtr->bands[i];
3387 REBAR_ValidateBand (infoPtr, lpBand);
3395 REBAR_SetBkColor (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3399 clrTemp = infoPtr->clrBk;
3400 infoPtr->clrBk = (COLORREF)lParam;
3402 TRACE("background color 0x%06x!\n", infoPtr->clrBk);
3408 /* << REBAR_SetColorScheme >> */
3409 /* << REBAR_SetPalette >> */
3413 REBAR_SetParent (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3415 HWND hwndTemp = infoPtr->hwndNotify;
3417 infoPtr->hwndNotify = (HWND)wParam;
3419 return (LRESULT)hwndTemp;
3424 REBAR_SetTextColor (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3428 clrTemp = infoPtr->clrText;
3429 infoPtr->clrText = (COLORREF)lParam;
3431 TRACE("text color 0x%06x!\n", infoPtr->clrText);
3437 /* << REBAR_SetTooltips >> */
3440 inline static LRESULT
3441 REBAR_SetUnicodeFormat (REBAR_INFO *infoPtr, WPARAM wParam)
3443 BOOL bTemp = infoPtr->bUnicode;
3445 TRACE("to %s hwnd=%p, was %s\n",
3446 ((BOOL)wParam) ? "TRUE" : "FALSE", infoPtr->hwndSelf,
3447 (bTemp) ? "TRUE" : "FALSE");
3449 infoPtr->bUnicode = (BOOL)wParam;
3456 REBAR_SetVersion (REBAR_INFO *infoPtr, INT iVersion)
3458 INT iOldVersion = infoPtr->iVersion;
3460 if (iVersion > COMCTL32_VERSION)
3463 infoPtr->iVersion = iVersion;
3465 TRACE("new version %d\n", iVersion);
3472 REBAR_ShowBand (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3476 if (((INT)wParam < 0) || ((INT)wParam > infoPtr->uNumBands))
3479 lpBand = &infoPtr->bands[(INT)wParam];
3482 TRACE("show band %d\n", (INT)wParam);
3483 lpBand->fStyle = lpBand->fStyle & ~RBBS_HIDDEN;
3484 if (IsWindow (lpBand->hwndChild))
3485 ShowWindow (lpBand->hwndChild, SW_SHOW);
3488 TRACE("hide band %d\n", (INT)wParam);
3489 lpBand->fStyle = lpBand->fStyle | RBBS_HIDDEN;
3490 if (IsWindow (lpBand->hwndChild))
3491 ShowWindow (lpBand->hwndChild, SW_HIDE);
3494 infoPtr->fStatus |= BAND_NEEDS_LAYOUT;
3495 REBAR_Layout (infoPtr, NULL, TRUE, FALSE);
3496 InvalidateRect(infoPtr->hwndSelf, 0, 1);
3503 REBAR_SizeToRect (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3505 LPRECT lpRect = (LPRECT)lParam;
3511 TRACE("[%d %d %d %d]\n",
3512 lpRect->left, lpRect->top, lpRect->right, lpRect->bottom);
3514 /* what is going on???? */
3515 GetWindowRect(infoPtr->hwndSelf, &t1);
3516 TRACE("window rect [%d %d %d %d]\n",
3517 t1.left, t1.top, t1.right, t1.bottom);
3518 GetClientRect(infoPtr->hwndSelf, &t1);
3519 TRACE("client rect [%d %d %d %d]\n",
3520 t1.left, t1.top, t1.right, t1.bottom);
3522 /* force full _Layout processing */
3523 TRACE("setting NEEDS_LAYOUT\n");
3524 infoPtr->fStatus |= BAND_NEEDS_LAYOUT;
3525 REBAR_Layout (infoPtr, lpRect, TRUE, FALSE);
3526 InvalidateRect (infoPtr->hwndSelf, NULL, TRUE);
3533 REBAR_Create (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3535 LPCREATESTRUCTW cs = (LPCREATESTRUCTW) lParam;
3539 if (TRACE_ON(rebar)) {
3540 GetWindowRect(infoPtr->hwndSelf, &wnrc1);
3541 GetClientRect(infoPtr->hwndSelf, &clrc1);
3542 TRACE("window=(%d,%d)-(%d,%d) client=(%d,%d)-(%d,%d) cs=(%d,%d %dx%d)\n",
3543 wnrc1.left, wnrc1.top, wnrc1.right, wnrc1.bottom,
3544 clrc1.left, clrc1.top, clrc1.right, clrc1.bottom,
3545 cs->x, cs->y, cs->cx, cs->cy);
3548 TRACE("created!\n");
3550 if ((theme = OpenThemeData (infoPtr->hwndSelf, themeClass)))
3552 /* native seems to clear WS_BORDER when themed */
3553 infoPtr->dwStyle &= ~WS_BORDER;
3561 REBAR_Destroy (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3567 /* free rebar bands */
3568 if ((infoPtr->uNumBands > 0) && infoPtr->bands) {
3569 /* clean up each band */
3570 for (i = 0; i < infoPtr->uNumBands; i++) {
3571 lpBand = &infoPtr->bands[i];
3573 /* delete text strings */
3574 if (lpBand->lpText) {
3575 Free (lpBand->lpText);
3576 lpBand->lpText = NULL;
3578 /* destroy child window */
3579 DestroyWindow (lpBand->hwndChild);
3582 /* free band array */
3583 Free (infoPtr->bands);
3584 infoPtr->bands = NULL;
3587 DestroyCursor (infoPtr->hcurArrow);
3588 DestroyCursor (infoPtr->hcurHorz);
3589 DestroyCursor (infoPtr->hcurVert);
3590 DestroyCursor (infoPtr->hcurDrag);
3591 if(infoPtr->hDefaultFont) DeleteObject (infoPtr->hDefaultFont);
3592 SetWindowLongPtrW (infoPtr->hwndSelf, 0, 0);
3594 CloseThemeData (GetWindowTheme (infoPtr->hwndSelf));
3596 /* free rebar info data */
3598 TRACE("destroyed!\n");
3604 REBAR_EraseBkGnd (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3608 if (GetClipBox ( (HDC)wParam, &cliprect))
3609 return REBAR_InternalEraseBkGnd (infoPtr, wParam, lParam, &cliprect);
3615 REBAR_GetFont (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3617 return (LRESULT)infoPtr->hFont;
3621 REBAR_PushChevron(REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3623 if (wParam >= 0 && (UINT)wParam < infoPtr->uNumBands)
3625 NMREBARCHEVRON nmrbc;
3626 REBAR_BAND *lpBand = &infoPtr->bands[wParam];
3628 TRACE("Pressed chevron on band %d\n", wParam);
3630 /* redraw chevron in pushed state */
3631 lpBand->fDraw |= DRAW_CHEVRONPUSHED;
3632 RedrawWindow(infoPtr->hwndSelf, &lpBand->rcChevron,0,
3633 RDW_ERASE|RDW_INVALIDATE|RDW_UPDATENOW);
3635 /* notify app so it can display a popup menu or whatever */
3636 nmrbc.uBand = wParam;
3637 nmrbc.wID = lpBand->wID;
3638 nmrbc.lParam = lpBand->lParam;
3639 nmrbc.rc = lpBand->rcChevron;
3640 nmrbc.lParamNM = lParam;
3641 REBAR_Notify((NMHDR*)&nmrbc, infoPtr, RBN_CHEVRONPUSHED);
3643 /* redraw chevron in previous state */
3644 lpBand->fDraw &= ~DRAW_CHEVRONPUSHED;
3645 InvalidateRect(infoPtr->hwndSelf, &lpBand->rcChevron, TRUE);
3653 REBAR_LButtonDown (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3659 ptMouseDown.x = (short)LOWORD(lParam);
3660 ptMouseDown.y = (short)HIWORD(lParam);
3662 REBAR_InternalHitTest(infoPtr, &ptMouseDown, &htFlags, &iHitBand);
3663 lpBand = &infoPtr->bands[iHitBand];
3665 if (htFlags == RBHT_CHEVRON)
3667 REBAR_PushChevron(infoPtr, iHitBand, 0);
3669 else if (htFlags == RBHT_GRABBER || htFlags == RBHT_CAPTION)
3671 TRACE("Starting drag\n");
3673 SetCapture (infoPtr->hwndSelf);
3674 infoPtr->iGrabbedBand = iHitBand;
3676 /* save off the LOWORD and HIWORD of lParam as initial x,y */
3677 infoPtr->dragStart.x = (short)LOWORD(lParam);
3678 infoPtr->dragStart.y = (short)HIWORD(lParam);
3679 infoPtr->dragNow = infoPtr->dragStart;
3680 if (infoPtr->dwStyle & CCS_VERT)
3681 infoPtr->ihitoffset = infoPtr->dragStart.y - (lpBand->rcBand.top+REBAR_PRE_GRIPPER);
3683 infoPtr->ihitoffset = infoPtr->dragStart.x - (lpBand->rcBand.left+REBAR_PRE_GRIPPER);
3689 REBAR_LButtonUp (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3691 if (infoPtr->iGrabbedBand >= 0)
3696 infoPtr->dragStart.x = 0;
3697 infoPtr->dragStart.y = 0;
3698 infoPtr->dragNow = infoPtr->dragStart;
3702 if (infoPtr->fStatus & BEGIN_DRAG_ISSUED) {
3703 REBAR_Notify(&layout, infoPtr, RBN_LAYOUTCHANGED);
3704 REBAR_Notify_NMREBAR (infoPtr, infoPtr->iGrabbedBand, RBN_ENDDRAG);
3705 infoPtr->fStatus &= ~BEGIN_DRAG_ISSUED;
3708 infoPtr->iGrabbedBand = -1;
3710 GetClientRect(infoPtr->hwndSelf, &rect);
3711 InvalidateRect(infoPtr->hwndSelf, NULL, TRUE);
3718 REBAR_MouseLeave (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3720 if (infoPtr->ichevronhotBand >= 0)
3722 REBAR_BAND *lpChevronBand = &infoPtr->bands[infoPtr->ichevronhotBand];
3723 if (lpChevronBand->fDraw & DRAW_CHEVRONHOT)
3725 lpChevronBand->fDraw &= ~DRAW_CHEVRONHOT;
3726 InvalidateRect(infoPtr->hwndSelf, &lpChevronBand->rcChevron, TRUE);
3729 infoPtr->iOldBand = -1;
3730 infoPtr->ichevronhotBand = -2;
3736 REBAR_MouseMove (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3738 REBAR_BAND *lpChevronBand;
3741 ptMove.x = (short)LOWORD(lParam);
3742 ptMove.y = (short)HIWORD(lParam);
3744 /* if we are currently dragging a band */
3745 if (infoPtr->iGrabbedBand >= 0)
3747 REBAR_BAND *band1, *band2;
3749 if (GetCapture() != infoPtr->hwndSelf)
3750 ERR("We are dragging but haven't got capture?!?\n");
3752 band1 = &infoPtr->bands[infoPtr->iGrabbedBand-1];
3753 band2 = &infoPtr->bands[infoPtr->iGrabbedBand];
3755 /* if mouse did not move much, exit */
3756 if ((abs(ptMove.x - infoPtr->dragNow.x) <= mindragx) &&
3757 (abs(ptMove.y - infoPtr->dragNow.y) <= mindragy)) return 0;
3759 /* Test for valid drag case - must not be first band in row */
3760 if (infoPtr->dwStyle & CCS_VERT) {
3761 if ((ptMove.x < band2->rcBand.left) ||
3762 (ptMove.x > band2->rcBand.right) ||
3763 ((infoPtr->iGrabbedBand > 0) && (band1->iRow != band2->iRow))) {
3764 FIXME("Cannot drag to other rows yet!!\n");
3767 REBAR_HandleLRDrag (infoPtr, &ptMove);
3771 if ((ptMove.y < band2->rcBand.top) ||
3772 (ptMove.y > band2->rcBand.bottom) ||
3773 ((infoPtr->iGrabbedBand > 0) && (band1->iRow != band2->iRow))) {
3774 FIXME("Cannot drag to other rows yet!!\n");
3777 REBAR_HandleLRDrag (infoPtr, &ptMove);
3785 TRACKMOUSEEVENT trackinfo;
3787 REBAR_InternalHitTest(infoPtr, &ptMove, &htFlags, &iHitBand);
3789 if (infoPtr->iOldBand >= 0 && infoPtr->iOldBand == infoPtr->ichevronhotBand)
3791 lpChevronBand = &infoPtr->bands[infoPtr->ichevronhotBand];
3792 if (lpChevronBand->fDraw & DRAW_CHEVRONHOT)
3794 lpChevronBand->fDraw &= ~DRAW_CHEVRONHOT;
3795 InvalidateRect(infoPtr->hwndSelf, &lpChevronBand->rcChevron, TRUE);
3797 infoPtr->ichevronhotBand = -2;
3800 if (htFlags == RBHT_CHEVRON)
3802 /* fill in the TRACKMOUSEEVENT struct */
3803 trackinfo.cbSize = sizeof(TRACKMOUSEEVENT);
3804 trackinfo.dwFlags = TME_QUERY;
3805 trackinfo.hwndTrack = infoPtr->hwndSelf;
3806 trackinfo.dwHoverTime = 0;
3808 /* call _TrackMouseEvent to see if we are currently tracking for this hwnd */
3809 _TrackMouseEvent(&trackinfo);
3811 /* Make sure tracking is enabled so we receive a WM_MOUSELEAVE message */
3812 if(!(trackinfo.dwFlags & TME_LEAVE))
3814 trackinfo.dwFlags = TME_LEAVE; /* notify upon leaving */
3816 /* call TRACKMOUSEEVENT so we receive a WM_MOUSELEAVE message */
3817 /* and can properly deactivate the hot chevron */
3818 _TrackMouseEvent(&trackinfo);
3821 lpChevronBand = &infoPtr->bands[iHitBand];
3822 if (!(lpChevronBand->fDraw & DRAW_CHEVRONHOT))
3824 lpChevronBand->fDraw |= DRAW_CHEVRONHOT;
3825 InvalidateRect(infoPtr->hwndSelf, &lpChevronBand->rcChevron, TRUE);
3826 infoPtr->ichevronhotBand = iHitBand;
3829 infoPtr->iOldBand = iHitBand;
3836 inline static LRESULT
3837 REBAR_NCCalcSize (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3840 RECT *rect = (RECT *)lParam;
3842 if (infoPtr->dwStyle & WS_BORDER) {
3843 rect->left = min(rect->left + GetSystemMetrics(SM_CXEDGE), rect->right);
3844 rect->right = max(rect->right - GetSystemMetrics(SM_CXEDGE), rect->left);
3845 rect->top = min(rect->top + GetSystemMetrics(SM_CYEDGE), rect->bottom);
3846 rect->bottom = max(rect->bottom - GetSystemMetrics(SM_CYEDGE), rect->top);
3848 else if ((theme = GetWindowTheme (infoPtr->hwndSelf)))
3850 /* FIXME: should use GetThemeInt */
3851 rect->top = min(rect->top + 1, rect->bottom);
3853 TRACE("new client=(%d,%d)-(%d,%d)\n", rect->left, rect->top, rect->right, rect->bottom);
3859 REBAR_NCCreate (HWND hwnd, WPARAM wParam, LPARAM lParam)
3861 LPCREATESTRUCTW cs = (LPCREATESTRUCTW) lParam;
3862 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
3864 NONCLIENTMETRICSW ncm;
3867 if (infoPtr != NULL) {
3868 ERR("Strange info structure pointer *not* NULL\n");
3872 if (TRACE_ON(rebar)) {
3873 GetWindowRect(hwnd, &wnrc1);
3874 GetClientRect(hwnd, &clrc1);
3875 TRACE("window=(%d,%d)-(%d,%d) client=(%d,%d)-(%d,%d) cs=(%d,%d %dx%d)\n",
3876 wnrc1.left, wnrc1.top, wnrc1.right, wnrc1.bottom,
3877 clrc1.left, clrc1.top, clrc1.right, clrc1.bottom,
3878 cs->x, cs->y, cs->cx, cs->cy);
3881 /* allocate memory for info structure */
3882 infoPtr = (REBAR_INFO *)Alloc (sizeof(REBAR_INFO));
3883 SetWindowLongPtrW (hwnd, 0, (DWORD_PTR)infoPtr);
3885 /* initialize info structure - initial values are 0 */
3886 infoPtr->clrBk = CLR_NONE;
3887 infoPtr->clrText = CLR_NONE;
3888 infoPtr->clrBtnText = GetSysColor (COLOR_BTNTEXT);
3889 infoPtr->clrBtnFace = GetSysColor (COLOR_BTNFACE);
3890 infoPtr->iOldBand = -1;
3891 infoPtr->ichevronhotBand = -2;
3892 infoPtr->iGrabbedBand = -1;
3893 infoPtr->hwndSelf = hwnd;
3894 infoPtr->DoRedraw = TRUE;
3895 infoPtr->hcurArrow = LoadCursorW (0, (LPWSTR)IDC_ARROW);
3896 infoPtr->hcurHorz = LoadCursorW (0, (LPWSTR)IDC_SIZEWE);
3897 infoPtr->hcurVert = LoadCursorW (0, (LPWSTR)IDC_SIZENS);
3898 infoPtr->hcurDrag = LoadCursorW (0, (LPWSTR)IDC_SIZE);
3899 infoPtr->fStatus = CREATE_RUNNING;
3900 infoPtr->hFont = GetStockObject (SYSTEM_FONT);
3902 /* issue WM_NOTIFYFORMAT to get unicode status of parent */
3903 REBAR_NotifyFormat(infoPtr, 0, NF_REQUERY);
3905 /* Stow away the original style */
3906 infoPtr->orgStyle = cs->style;
3907 /* add necessary styles to the requested styles */
3908 infoPtr->dwStyle = cs->style | WS_VISIBLE | CCS_TOP;
3909 SetWindowLongW (hwnd, GWL_STYLE, infoPtr->dwStyle);
3911 /* get font handle for Caption Font */
3912 ncm.cbSize = sizeof(ncm);
3913 SystemParametersInfoW (SPI_GETNONCLIENTMETRICS, ncm.cbSize, &ncm, 0);
3914 /* if the font is bold, set to normal */
3915 if (ncm.lfCaptionFont.lfWeight > FW_NORMAL) {
3916 ncm.lfCaptionFont.lfWeight = FW_NORMAL;
3918 tfont = CreateFontIndirectW (&ncm.lfCaptionFont);
3920 infoPtr->hFont = infoPtr->hDefaultFont = tfont;
3924 GetSysColor (numerous);
3925 GetSysColorBrush (numerous) (see WM_SYSCOLORCHANGE);
3926 *GetStockObject (SYSTEM_FONT);
3927 *SetWindowLong (hwnd, 0, info ptr);
3929 *SetWindowLong (hwnd, GWL_STYLE, style+0x10000001);
3930 WS_VISIBLE = 0x10000000;
3931 CCS_TOP = 0x00000001;
3932 *SystemParametersInfo (SPI_GETNONCLIENTMETRICS...);
3933 *CreateFontIndirect (lfCaptionFont from above);
3935 SelectObject (hdc, fontabove);
3936 GetTextMetrics (hdc, ); guessing is tmHeight
3937 SelectObject (hdc, oldfont);
3940 MapWindowPoints (0, parent, rectabove, 2);
3943 ClientToScreen (clientrect);
3944 SetWindowPos (hwnd, 0, 0, 0, 0, 0, SWP_NOZORDER);
3951 REBAR_NCHitTest (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3957 LRESULT ret = HTCLIENT;
3960 * Differences from doc at MSDN (as observed with version 4.71 of
3962 * 1. doc says nmmouse.pt is in screen coord, trace shows client coord.
3963 * 2. if band is not identified .dwItemSpec is 0xffffffff.
3964 * 3. native always seems to return HTCLIENT if notify return is 0.
3967 clpt.x = (short)LOWORD(lParam);
3968 clpt.y = (short)HIWORD(lParam);
3969 ScreenToClient (infoPtr->hwndSelf, &clpt);
3970 REBAR_InternalHitTest (infoPtr, &clpt, &scrap,
3971 (INT *)&nmmouse.dwItemSpec);
3972 nmmouse.dwItemData = 0;
3974 nmmouse.dwHitInfo = 0;
3975 if ((i = REBAR_Notify((NMHDR *) &nmmouse, infoPtr, NM_NCHITTEST))) {
3976 TRACE("notify changed return value from %ld to %d\n",
3980 TRACE("returning %ld, client point (%d,%d)\n", ret, clpt.x, clpt.y);
3986 REBAR_NCPaint (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
3992 if (infoPtr->dwStyle & WS_MINIMIZE)
3993 return 0; /* Nothing to do */
3995 if (infoPtr->dwStyle & WS_BORDER) {
3997 /* adjust rectangle and draw the necessary edge */
3998 if (!(hdc = GetDCEx( infoPtr->hwndSelf, 0, DCX_USESTYLE | DCX_WINDOW )))
4000 GetWindowRect (infoPtr->hwndSelf, &rcWindow);
4001 OffsetRect (&rcWindow, -rcWindow.left, -rcWindow.top);
4002 TRACE("rect (%d,%d)-(%d,%d)\n",
4003 rcWindow.left, rcWindow.top,
4004 rcWindow.right, rcWindow.bottom);
4005 DrawEdge (hdc, &rcWindow, EDGE_ETCHED, BF_RECT);
4006 ReleaseDC( infoPtr->hwndSelf, hdc );
4008 else if ((theme = GetWindowTheme (infoPtr->hwndSelf)))
4010 /* adjust rectangle and draw the necessary edge */
4011 if (!(hdc = GetDCEx( infoPtr->hwndSelf, 0, DCX_USESTYLE | DCX_WINDOW )))
4013 GetWindowRect (infoPtr->hwndSelf, &rcWindow);
4014 OffsetRect (&rcWindow, -rcWindow.left, -rcWindow.top);
4015 TRACE("rect (%d,%d)-(%d,%d)\n",
4016 rcWindow.left, rcWindow.top,
4017 rcWindow.right, rcWindow.bottom);
4018 DrawThemeEdge (theme, hdc, 0, 0, &rcWindow, BDR_RAISEDINNER, BF_TOP, NULL);
4019 ReleaseDC( infoPtr->hwndSelf, hdc );
4027 REBAR_NotifyFormat (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
4031 if (lParam == NF_REQUERY) {
4032 i = SendMessageW(REBAR_GetNotifyParent (infoPtr),
4033 WM_NOTIFYFORMAT, (WPARAM)infoPtr->hwndSelf, NF_QUERY);
4034 if ((i != NFR_ANSI) && (i != NFR_UNICODE)) {
4035 ERR("wrong response to WM_NOTIFYFORMAT (%d), assuming ANSI\n", i);
4038 infoPtr->bUnicode = (i == NFR_UNICODE) ? 1 : 0;
4041 return (LRESULT)((infoPtr->bUnicode) ? NFR_UNICODE : NFR_ANSI);
4046 REBAR_Paint (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
4052 GetClientRect(infoPtr->hwndSelf, &rc);
4053 hdc = wParam==0 ? BeginPaint (infoPtr->hwndSelf, &ps) : (HDC)wParam;
4055 TRACE("painting (%d,%d)-(%d,%d) client (%d,%d)-(%d,%d)\n",
4056 ps.rcPaint.left, ps.rcPaint.top,
4057 ps.rcPaint.right, ps.rcPaint.bottom,
4058 rc.left, rc.top, rc.right, rc.bottom);
4061 /* Erase area of paint if requested */
4062 REBAR_InternalEraseBkGnd (infoPtr, wParam, lParam, &ps.rcPaint);
4065 REBAR_Refresh (infoPtr, hdc);
4067 EndPaint (infoPtr->hwndSelf, &ps);
4073 REBAR_SetCursor (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
4078 TRACE("code=0x%X id=0x%X\n", LOWORD(lParam), HIWORD(lParam));
4081 ScreenToClient (infoPtr->hwndSelf, &pt);
4083 REBAR_InternalHitTest (infoPtr, &pt, &flags, NULL);
4085 if (flags == RBHT_GRABBER) {
4086 if ((infoPtr->dwStyle & CCS_VERT) &&
4087 !(infoPtr->dwStyle & RBS_VERTICALGRIPPER))
4088 SetCursor (infoPtr->hcurVert);
4090 SetCursor (infoPtr->hcurHorz);
4092 else if (flags != RBHT_CLIENT)
4093 SetCursor (infoPtr->hcurArrow);
4100 REBAR_SetFont (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
4106 infoPtr->hFont = (HFONT)wParam;
4108 /* revalidate all bands to change sizes of text in headers of bands */
4109 for (i=0; i<infoPtr->uNumBands; i++) {
4110 lpBand = &infoPtr->bands[i];
4111 REBAR_ValidateBand (infoPtr, lpBand);
4115 if (LOWORD(lParam)) {
4116 GetClientRect (infoPtr->hwndSelf, &rcClient);
4117 REBAR_Layout (infoPtr, &rcClient, FALSE, TRUE);
4124 inline static LRESULT
4125 REBAR_SetRedraw (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
4126 /*****************************************************
4129 * Handles the WM_SETREDRAW message.
4132 * According to testing V4.71 of COMCTL32 returns the
4133 * *previous* status of the redraw flag (either 0 or -1)
4134 * instead of the MSDN documented value of 0 if handled
4136 *****************************************************/
4138 BOOL oldredraw = infoPtr->DoRedraw;
4140 TRACE("set to %s, fStatus=%08x\n",
4141 (wParam) ? "TRUE" : "FALSE", infoPtr->fStatus);
4142 infoPtr->DoRedraw = (BOOL) wParam;
4144 if (infoPtr->fStatus & BAND_NEEDS_REDRAW) {
4145 REBAR_MoveChildWindows (infoPtr, 0, infoPtr->uNumBands);
4146 REBAR_ForceResize (infoPtr);
4147 InvalidateRect (infoPtr->hwndSelf, 0, TRUE);
4149 infoPtr->fStatus &= ~BAND_NEEDS_REDRAW;
4151 return (oldredraw) ? -1 : 0;
4156 REBAR_Size (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
4160 /* auto resize deadlock check */
4161 if (infoPtr->fStatus & AUTO_RESIZE) {
4162 infoPtr->fStatus &= ~AUTO_RESIZE;
4163 TRACE("AUTO_RESIZE was set, reset, fStatus=%08x lparam=%08lx\n",
4164 infoPtr->fStatus, lParam);
4168 if (infoPtr->fStatus & CREATE_RUNNING) {
4169 /* still in CreateWindow */
4172 if ((INT)wParam != SIZE_RESTORED) {
4173 ERR("WM_SIZE in create and flags=%08x, lParam=%08lx\n",
4177 TRACE("still in CreateWindow\n");
4178 infoPtr->fStatus &= ~CREATE_RUNNING;
4179 GetWindowRect ( infoPtr->hwndSelf, &rcWin);
4180 TRACE("win rect (%d,%d)-(%d,%d)\n",
4181 rcWin.left, rcWin.top, rcWin.right, rcWin.bottom);
4183 if ((lParam == 0) && (rcWin.right-rcWin.left == 0) &&
4184 (rcWin.bottom-rcWin.top == 0)) {
4185 /* native control seems to do this */
4186 GetClientRect (GetParent(infoPtr->hwndSelf), &rcClient);
4187 TRACE("sizing rebar, message and client zero, parent client (%d,%d)\n",
4188 rcClient.right, rcClient.bottom);
4193 cx = rcWin.right - rcWin.left;
4194 cy = rcWin.bottom - rcWin.top;
4195 if ((cx == LOWORD(lParam)) && (cy == HIWORD(lParam))) {
4199 /* do the actual WM_SIZE request */
4200 GetClientRect (infoPtr->hwndSelf, &rcClient);
4201 TRACE("sizing rebar from (%d,%d) to (%d,%d), client (%d,%d)\n",
4202 infoPtr->calcSize.cx, infoPtr->calcSize.cy,
4203 LOWORD(lParam), HIWORD(lParam),
4204 rcClient.right, rcClient.bottom);
4208 if ((INT)wParam != SIZE_RESTORED) {
4209 ERR("WM_SIZE out of create and flags=%08x, lParam=%08lx\n",
4213 /* Handle cases when outside of the CreateWindow process */
4215 GetClientRect (infoPtr->hwndSelf, &rcClient);
4216 if ((lParam == 0) && (rcClient.right + rcClient.bottom != 0) &&
4217 (infoPtr->dwStyle & RBS_AUTOSIZE)) {
4218 /* on a WM_SIZE to zero and current client not zero and AUTOSIZE */
4219 /* native seems to use the current parent width for the size */
4220 infoPtr->fStatus |= BAND_NEEDS_LAYOUT;
4221 GetClientRect (GetParent(infoPtr->hwndSelf), &rcClient);
4222 if (infoPtr->dwStyle & CCS_VERT)
4225 rcClient.bottom = 0;
4226 TRACE("sizing rebar to parent (%d,%d) size is zero but AUTOSIZE set\n",
4227 rcClient.right, rcClient.bottom);
4230 TRACE("sizing rebar from (%d,%d) to (%d,%d), client (%d,%d)\n",
4231 infoPtr->calcSize.cx, infoPtr->calcSize.cy,
4232 LOWORD(lParam), HIWORD(lParam),
4233 rcClient.right, rcClient.bottom);
4237 if (infoPtr->dwStyle & RBS_AUTOSIZE) {
4238 NMRBAUTOSIZE autosize;
4240 GetClientRect(infoPtr->hwndSelf, &autosize.rcTarget);
4241 autosize.fChanged = 0; /* ??? */
4242 autosize.rcActual = autosize.rcTarget; /* ??? */
4243 REBAR_Notify((NMHDR *) &autosize, infoPtr, RBN_AUTOSIZE);
4244 TRACE("RBN_AUTOSIZE client=(%d,%d), lp=%08lx\n",
4245 autosize.rcTarget.right, autosize.rcTarget.bottom, lParam);
4248 if ((infoPtr->calcSize.cx != rcClient.right) ||
4249 (infoPtr->calcSize.cy != rcClient.bottom))
4250 infoPtr->fStatus |= BAND_NEEDS_LAYOUT;
4252 REBAR_Layout (infoPtr, &rcClient, TRUE, TRUE);
4259 REBAR_StyleChanged (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
4261 STYLESTRUCT *ss = (STYLESTRUCT *)lParam;
4263 TRACE("current style=%08x, styleOld=%08x, style being set to=%08x\n",
4264 infoPtr->dwStyle, ss->styleOld, ss->styleNew);
4265 infoPtr->orgStyle = infoPtr->dwStyle = ss->styleNew;
4266 if (GetWindowTheme (infoPtr->hwndSelf))
4267 infoPtr->dwStyle &= ~WS_BORDER;
4272 /* update theme after a WM_THEMECHANGED message */
4273 static LRESULT theme_changed (REBAR_INFO* infoPtr)
4275 HTHEME theme = GetWindowTheme (infoPtr->hwndSelf);
4276 CloseThemeData (theme);
4277 theme = OpenThemeData (infoPtr->hwndSelf, themeClass);
4278 /* WS_BORDER disappears when theming is enabled and reappears when
4280 infoPtr->dwStyle &= ~WS_BORDER;
4281 infoPtr->dwStyle |= theme ? 0 : (infoPtr->orgStyle & WS_BORDER);
4286 REBAR_WindowPosChanged (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
4288 WINDOWPOS *lpwp = (WINDOWPOS *)lParam;
4292 /* Save the new origin of this window - used by _ForceResize */
4293 infoPtr->origin.x = lpwp->x;
4294 infoPtr->origin.y = lpwp->y;
4295 ret = DefWindowProcW(infoPtr->hwndSelf, WM_WINDOWPOSCHANGED,
4297 GetWindowRect(infoPtr->hwndSelf, &rc);
4298 TRACE("hwnd %p new pos (%d,%d)-(%d,%d)\n",
4299 infoPtr->hwndSelf, rc.left, rc.top, rc.right, rc.bottom);
4304 static LRESULT WINAPI
4305 REBAR_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
4307 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
4309 TRACE("hwnd=%p msg=%x wparam=%x lparam=%lx\n",
4310 hwnd, uMsg, wParam, lParam);
4311 if (!infoPtr && (uMsg != WM_NCCREATE))
4312 return DefWindowProcW (hwnd, uMsg, wParam, lParam);
4315 /* case RB_BEGINDRAG: */
4318 return REBAR_DeleteBand (infoPtr, wParam, lParam);
4320 /* case RB_DRAGMOVE: */
4321 /* case RB_ENDDRAG: */
4323 case RB_GETBANDBORDERS:
4324 return REBAR_GetBandBorders (infoPtr, wParam, lParam);
4326 case RB_GETBANDCOUNT:
4327 return REBAR_GetBandCount (infoPtr);
4329 case RB_GETBANDINFO_OLD:
4330 case RB_GETBANDINFOA:
4331 return REBAR_GetBandInfoT(infoPtr, wParam, lParam, FALSE);
4333 case RB_GETBANDINFOW:
4334 return REBAR_GetBandInfoT(infoPtr, wParam, lParam, TRUE);
4336 case RB_GETBARHEIGHT:
4337 return REBAR_GetBarHeight (infoPtr, wParam, lParam);
4340 return REBAR_GetBarInfo (infoPtr, wParam, lParam);
4343 return REBAR_GetBkColor (infoPtr);
4345 /* case RB_GETCOLORSCHEME: */
4346 /* case RB_GETDROPTARGET: */
4349 return REBAR_GetPalette (infoPtr, wParam, lParam);
4352 return REBAR_GetRect (infoPtr, wParam, lParam);
4354 case RB_GETROWCOUNT:
4355 return REBAR_GetRowCount (infoPtr);
4357 case RB_GETROWHEIGHT:
4358 return REBAR_GetRowHeight (infoPtr, wParam, lParam);
4360 case RB_GETTEXTCOLOR:
4361 return REBAR_GetTextColor (infoPtr);
4363 case RB_GETTOOLTIPS:
4364 return REBAR_GetToolTips (infoPtr);
4366 case RB_GETUNICODEFORMAT:
4367 return REBAR_GetUnicodeFormat (infoPtr);
4369 case CCM_GETVERSION:
4370 return REBAR_GetVersion (infoPtr);
4373 return REBAR_HitTest (infoPtr, wParam, lParam);
4376 return REBAR_IdToIndex (infoPtr, wParam, lParam);
4378 case RB_INSERTBANDA:
4379 return REBAR_InsertBandT(infoPtr, wParam, lParam, FALSE);
4381 case RB_INSERTBANDW:
4382 return REBAR_InsertBandT(infoPtr, wParam, lParam, TRUE);
4384 case RB_MAXIMIZEBAND:
4385 return REBAR_MaximizeBand (infoPtr, wParam, lParam);
4387 case RB_MINIMIZEBAND:
4388 return REBAR_MinimizeBand (infoPtr, wParam, lParam);
4391 return REBAR_MoveBand (infoPtr, wParam, lParam);
4393 case RB_PUSHCHEVRON:
4394 return REBAR_PushChevron (infoPtr, wParam, lParam);
4396 case RB_SETBANDINFOA:
4397 return REBAR_SetBandInfoT(infoPtr, wParam, lParam, FALSE);
4399 case RB_SETBANDINFOW:
4400 return REBAR_SetBandInfoT(infoPtr, wParam, lParam, TRUE);
4403 return REBAR_SetBarInfo (infoPtr, wParam, lParam);
4406 return REBAR_SetBkColor (infoPtr, wParam, lParam);
4408 /* case RB_SETCOLORSCHEME: */
4409 /* case RB_SETPALETTE: */
4410 /* return REBAR_GetPalette (infoPtr, wParam, lParam); */
4413 return REBAR_SetParent (infoPtr, wParam, lParam);
4415 case RB_SETTEXTCOLOR:
4416 return REBAR_SetTextColor (infoPtr, wParam, lParam);
4418 /* case RB_SETTOOLTIPS: */
4420 case RB_SETUNICODEFORMAT:
4421 return REBAR_SetUnicodeFormat (infoPtr, wParam);
4423 case CCM_SETVERSION:
4424 return REBAR_SetVersion (infoPtr, (INT)wParam);
4427 return REBAR_ShowBand (infoPtr, wParam, lParam);
4430 return REBAR_SizeToRect (infoPtr, wParam, lParam);
4433 /* Messages passed to parent */
4437 return SendMessageW(REBAR_GetNotifyParent (infoPtr), uMsg, wParam, lParam);
4440 /* case WM_CHARTOITEM: supported according to ControlSpy */
4443 return REBAR_Create (infoPtr, wParam, lParam);
4446 return REBAR_Destroy (infoPtr, wParam, lParam);
4449 return REBAR_EraseBkGnd (infoPtr, wParam, lParam);
4452 return REBAR_GetFont (infoPtr, wParam, lParam);
4454 /* case WM_LBUTTONDBLCLK: supported according to ControlSpy */
4456 case WM_LBUTTONDOWN:
4457 return REBAR_LButtonDown (infoPtr, wParam, lParam);
4460 return REBAR_LButtonUp (infoPtr, wParam, lParam);
4462 /* case WM_MEASUREITEM: supported according to ControlSpy */
4465 return REBAR_MouseMove (infoPtr, wParam, lParam);
4468 return REBAR_MouseLeave (infoPtr, wParam, lParam);
4471 return REBAR_NCCalcSize (infoPtr, wParam, lParam);
4474 return REBAR_NCCreate (hwnd, wParam, lParam);
4477 return REBAR_NCHitTest (infoPtr, wParam, lParam);
4480 return REBAR_NCPaint (infoPtr, wParam, lParam);
4482 case WM_NOTIFYFORMAT:
4483 return REBAR_NotifyFormat (infoPtr, wParam, lParam);
4485 case WM_PRINTCLIENT:
4487 return REBAR_Paint (infoPtr, wParam, lParam);
4489 /* case WM_PALETTECHANGED: supported according to ControlSpy */
4490 /* case WM_QUERYNEWPALETTE:supported according to ControlSpy */
4491 /* case WM_RBUTTONDOWN: supported according to ControlSpy */
4492 /* case WM_RBUTTONUP: supported according to ControlSpy */
4495 return REBAR_SetCursor (infoPtr, wParam, lParam);
4498 return REBAR_SetFont (infoPtr, wParam, lParam);
4501 return REBAR_SetRedraw (infoPtr, wParam, lParam);
4504 return REBAR_Size (infoPtr, wParam, lParam);
4506 case WM_STYLECHANGED:
4507 return REBAR_StyleChanged (infoPtr, wParam, lParam);
4509 case WM_THEMECHANGED:
4510 return theme_changed (infoPtr);
4512 /* case WM_SYSCOLORCHANGE: supported according to ControlSpy */
4513 /* "Applications that have brushes using the existing system colors
4514 should delete those brushes and recreate them using the new
4515 system colors." per MSDN */
4517 /* case WM_VKEYTOITEM: supported according to ControlSpy */
4518 /* case WM_WININICHANGE: */
4520 case WM_WINDOWPOSCHANGED:
4521 return REBAR_WindowPosChanged (infoPtr, wParam, lParam);
4524 if ((uMsg >= WM_USER) && (uMsg < WM_APP))
4525 ERR("unknown msg %04x wp=%08x lp=%08lx\n",
4526 uMsg, wParam, lParam);
4527 return DefWindowProcW (hwnd, uMsg, wParam, lParam);
4533 REBAR_Register (void)
4537 ZeroMemory (&wndClass, sizeof(WNDCLASSW));
4538 wndClass.style = CS_GLOBALCLASS | CS_DBLCLKS;
4539 wndClass.lpfnWndProc = REBAR_WindowProc;
4540 wndClass.cbClsExtra = 0;
4541 wndClass.cbWndExtra = sizeof(REBAR_INFO *);
4542 wndClass.hCursor = 0;
4543 wndClass.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1);
4545 wndClass.hbrBackground = CreateSolidBrush(RGB(0,128,0));
4547 wndClass.lpszClassName = REBARCLASSNAMEW;
4549 RegisterClassW (&wndClass);
4551 mindragx = GetSystemMetrics (SM_CXDRAG);
4552 mindragy = GetSystemMetrics (SM_CYDRAG);
4558 REBAR_Unregister (void)
4560 UnregisterClassW (REBARCLASSNAMEW, NULL);