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.
51 * - WM_QUERYNEWPALETTE
59 * - NM_RELEASEDCAPTURE
65 * Native uses (on each draw!!) SM_CYBORDER (or SM_CXBORDER for CCS_VERT)
66 * to set the size of the separator width (the value SEP_WIDTH_SIZE
67 * in here). Should be fixed!!
71 * Testing: set to 1 to make background brush *always* green
76 * 3. REBAR_MoveChildWindows should have a loop because more than
77 * one pass is made (together with the RBN_CHILDSIZEs) is made on
78 * at least RB_INSERTBAND
88 #include "wine/unicode.h"
95 #include "wine/debug.h"
97 WINE_DEFAULT_DEBUG_CHANNEL(rebar
);
107 UINT cxMinChild
; /* valid if _CHILDSIZE */
108 UINT cyMinChild
; /* valid if _CHILDSIZE */
109 UINT cx
; /* valid if _SIZE */
112 UINT cyChild
; /* valid if _CHILDSIZE */
113 UINT cyMaxChild
; /* valid if _CHILDSIZE */
114 UINT cyIntegral
; /* valid if _CHILDSIZE */
119 INT cxEffective
; /* current cx for band */
120 UINT lcx
; /* minimum cx for band */
121 UINT lcy
; /* minimum cy for band */
123 INT iRow
; /* zero-based index of the row this band assigned to */
124 UINT fStatus
; /* status flags, reset only by _Validate */
125 UINT fDraw
; /* drawing flags, reset only by _Layout */
126 UINT uCDret
; /* last return from NM_CUSTOMDRAW */
127 RECT rcBand
; /* calculated band rectangle - coordinates swapped for CCS_VERT */
128 RECT rcGripper
; /* calculated gripper rectangle */
129 RECT rcCapImage
; /* calculated caption image rectangle */
130 RECT rcCapText
; /* calculated caption text rectangle */
131 RECT rcChild
; /* calculated child rectangle */
132 RECT rcChevron
; /* calculated chevron rectangle */
139 #define HAS_GRIPPER 0x00000001
140 #define HAS_IMAGE 0x00000002
141 #define HAS_TEXT 0x00000004
144 #define DRAW_GRIPPER 0x00000001
145 #define DRAW_IMAGE 0x00000002
146 #define DRAW_TEXT 0x00000004
147 #define DRAW_CHEVRONHOT 0x00000040
148 #define DRAW_CHEVRONPUSHED 0x00000080
149 #define NTF_INVALIDATE 0x01000000
153 COLORREF clrBk
; /* background color */
154 COLORREF clrText
; /* text color */
155 COLORREF clrBtnText
; /* system color for BTNTEXT */
156 COLORREF clrBtnFace
; /* system color for BTNFACE */
157 HIMAGELIST himl
; /* handle to imagelist */
158 UINT uNumBands
; /* # of bands in rebar (first=0, last=uNumBands-1 */
159 UINT uNumRows
; /* # of rows of bands (first=1, last=uNumRows */
160 HWND hwndSelf
; /* handle of REBAR window itself */
161 HWND hwndToolTip
; /* handle to the tool tip control */
162 HWND hwndNotify
; /* notification window (parent) */
164 HFONT hFont
; /* handle to the rebar's font */
165 SIZE imageSize
; /* image size (image list) */
166 DWORD dwStyle
; /* window style */
167 DWORD orgStyle
; /* original style (dwStyle may change) */
168 SIZE calcSize
; /* calculated rebar size - coordinates swapped for CCS_VERT */
169 BOOL bUnicode
; /* TRUE if parent wants notify in W format */
170 BOOL DoRedraw
; /* TRUE to acutally draw bands */
171 UINT fStatus
; /* Status flags (see below) */
172 HCURSOR hcurArrow
; /* handle to the arrow cursor */
173 HCURSOR hcurHorz
; /* handle to the EW cursor */
174 HCURSOR hcurVert
; /* handle to the NS cursor */
175 HCURSOR hcurDrag
; /* handle to the drag cursor */
176 INT iVersion
; /* version number */
177 POINT dragStart
; /* x,y of button down */
178 POINT dragNow
; /* x,y of this MouseMove */
179 INT iOldBand
; /* last band that had the mouse cursor over it */
180 INT ihitoffset
; /* offset of hotspot from gripper.left */
181 INT ichevronhotBand
; /* last band that had a hot chevron */
182 INT iGrabbedBand
;/* band number of band whose gripper was grabbed */
184 REBAR_BAND
*bands
; /* pointer to the array of rebar bands */
188 #define BEGIN_DRAG_ISSUED 0x00000001
189 #define AUTO_RESIZE 0x00000002
190 #define BAND_NEEDS_REDRAW 0x00000020
192 /* used by Windows to mark that the header size has been set by the user and shouldn't be changed */
193 #define RBBS_UNDOC_FIXEDHEADER 0x40000000
195 /* ---- REBAR layout constants. Mostly determined by ---- */
196 /* ---- experiment on WIN 98. ---- */
198 /* Width (or height) of separators between bands (either horz. or */
199 /* vert.). True only if RBS_BANDBORDERS is set */
200 #define SEP_WIDTH_SIZE 2
201 #define SEP_WIDTH ((infoPtr->dwStyle & RBS_BANDBORDERS) ? SEP_WIDTH_SIZE : 0)
203 /* Blank (background color) space between Gripper (if present) */
204 /* and next item (image, text, or window). Always present */
205 #define REBAR_ALWAYS_SPACE 4
207 /* Blank (background color) space after Image (if present). */
208 #define REBAR_POST_IMAGE 2
210 /* Blank (background color) space after Text (if present). */
211 #define REBAR_POST_TEXT 4
213 /* Height of vertical gripper in a CCS_VERT rebar. */
214 #define GRIPPER_HEIGHT 16
216 /* Blank (background color) space before Gripper (if present). */
217 #define REBAR_PRE_GRIPPER 2
219 /* Width (of normal vertical gripper) or height (of horz. gripper) */
221 #define GRIPPER_WIDTH 3
223 /* Width of the chevron button if present */
224 #define CHEVRON_WIDTH 10
226 /* the gap between the child and the next band */
227 #define REBAR_POST_CHILD 4
229 /* Height of divider for Rebar if not disabled (CCS_NODIVIDER) */
230 /* either top or bottom */
231 #define REBAR_DIVIDER 2
233 /* height of a rebar without a child */
234 #define REBAR_NO_CHILD_HEIGHT 4
236 /* minimium vertical height of a normal bar */
237 /* or minimum width of a CCS_VERT bar - from experiment on Win2k */
238 #define REBAR_MINSIZE 23
240 /* This is the increment that is used over the band height */
241 #define REBARSPACE(a) ((a->fStyle & RBBS_CHILDEDGE) ? 2*REBAR_DIVIDER : 0)
243 /* ---- End of REBAR layout constants. ---- */
245 #define RB_GETBANDINFO_OLD (WM_USER+5) /* obsoleted after IE3, but we have to support it anyway */
247 /* The following define determines if a given band is hidden */
248 #define HIDDENBAND(a) (((a)->fStyle & RBBS_HIDDEN) || \
249 ((infoPtr->dwStyle & CCS_VERT) && \
250 ((a)->fStyle & RBBS_NOVERT)))
252 #define REBAR_GetInfoPtr(wndPtr) ((REBAR_INFO *)GetWindowLongPtrW (hwnd, 0))
254 static LRESULT
REBAR_NotifyFormat(REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
);
257 /* "constant values" retrieved when DLL was initialized */
258 /* FIXME we do this when the classes are registered. */
259 static UINT mindragx
= 0;
260 static UINT mindragy
= 0;
262 static const char * const band_stylename
[] = {
263 "RBBS_BREAK", /* 0001 */
264 "RBBS_FIXEDSIZE", /* 0002 */
265 "RBBS_CHILDEDGE", /* 0004 */
266 "RBBS_HIDDEN", /* 0008 */
267 "RBBS_NOVERT", /* 0010 */
268 "RBBS_FIXEDBMP", /* 0020 */
269 "RBBS_VARIABLEHEIGHT", /* 0040 */
270 "RBBS_GRIPPERALWAYS", /* 0080 */
271 "RBBS_NOGRIPPER", /* 0100 */
274 static const char * const band_maskname
[] = {
275 "RBBIM_STYLE", /* 0x00000001 */
276 "RBBIM_COLORS", /* 0x00000002 */
277 "RBBIM_TEXT", /* 0x00000004 */
278 "RBBIM_IMAGE", /* 0x00000008 */
279 "RBBIM_CHILD", /* 0x00000010 */
280 "RBBIM_CHILDSIZE", /* 0x00000020 */
281 "RBBIM_SIZE", /* 0x00000040 */
282 "RBBIM_BACKGROUND", /* 0x00000080 */
283 "RBBIM_ID", /* 0x00000100 */
284 "RBBIM_IDEALSIZE", /* 0x00000200 */
285 "RBBIM_LPARAM", /* 0x00000400 */
286 "RBBIM_HEADERSIZE", /* 0x00000800 */
290 static CHAR line
[200];
292 static const WCHAR themeClass
[] = { 'R','e','b','a','r',0 };
295 REBAR_FmtStyle( UINT style
)
300 while (band_stylename
[i
]) {
301 if (style
& (1<<i
)) {
302 if (*line
!= 0) strcat(line
, " | ");
303 strcat(line
, band_stylename
[i
]);
312 REBAR_FmtMask( UINT mask
)
317 while (band_maskname
[i
]) {
319 if (*line
!= 0) strcat(line
, " | ");
320 strcat(line
, band_maskname
[i
]);
329 REBAR_DumpBandInfo(const REBARBANDINFOW
*pB
)
331 if( !TRACE_ON(rebar
) ) return;
332 TRACE("band info: ");
333 if (pB
->fMask
& RBBIM_ID
)
334 TRACE("ID=%u, ", pB
->wID
);
335 TRACE("size=%u, child=%p", pB
->cbSize
, pB
->hwndChild
);
336 if (pB
->fMask
& RBBIM_COLORS
)
337 TRACE(", clrF=0x%06x, clrB=0x%06x", pB
->clrFore
, pB
->clrBack
);
340 TRACE("band info: mask=0x%08x (%s)\n", pB
->fMask
, REBAR_FmtMask(pB
->fMask
));
341 if (pB
->fMask
& RBBIM_STYLE
)
342 TRACE("band info: style=0x%08x (%s)\n", pB
->fStyle
, REBAR_FmtStyle(pB
->fStyle
));
343 if (pB
->fMask
& (RBBIM_SIZE
| RBBIM_IDEALSIZE
| RBBIM_HEADERSIZE
| RBBIM_LPARAM
)) {
345 if (pB
->fMask
& RBBIM_SIZE
)
346 TRACE(" cx=%u", pB
->cx
);
347 if (pB
->fMask
& RBBIM_IDEALSIZE
)
348 TRACE(" xIdeal=%u", pB
->cxIdeal
);
349 if (pB
->fMask
& RBBIM_HEADERSIZE
)
350 TRACE(" xHeader=%u", pB
->cxHeader
);
351 if (pB
->fMask
& RBBIM_LPARAM
)
352 TRACE(" lParam=0x%08lx", pB
->lParam
);
355 if (pB
->fMask
& RBBIM_CHILDSIZE
)
356 TRACE("band info: xMin=%u, yMin=%u, yChild=%u, yMax=%u, yIntgl=%u\n",
358 pB
->cyMinChild
, pB
->cyChild
, pB
->cyMaxChild
, pB
->cyIntegral
);
362 REBAR_DumpBand (const REBAR_INFO
*iP
)
367 if(! TRACE_ON(rebar
) ) return;
369 TRACE("hwnd=%p: color=%08x/%08x, bands=%u, rows=%u, cSize=%d,%d\n",
370 iP
->hwndSelf
, iP
->clrText
, iP
->clrBk
, iP
->uNumBands
, iP
->uNumRows
,
371 iP
->calcSize
.cx
, iP
->calcSize
.cy
);
372 TRACE("hwnd=%p: flags=%08x, dragStart=%d,%d, dragNow=%d,%d, iGrabbedBand=%d\n",
373 iP
->hwndSelf
, iP
->fStatus
, iP
->dragStart
.x
, iP
->dragStart
.y
,
374 iP
->dragNow
.x
, iP
->dragNow
.y
,
376 TRACE("hwnd=%p: style=%08x, notify in Unicode=%s, redraw=%s\n",
377 iP
->hwndSelf
, iP
->dwStyle
, (iP
->bUnicode
)?"TRUE":"FALSE",
378 (iP
->DoRedraw
)?"TRUE":"FALSE");
379 for (i
= 0; i
< iP
->uNumBands
; i
++) {
381 TRACE("band # %u:", i
);
382 if (pB
->fMask
& RBBIM_ID
)
383 TRACE(" ID=%u", pB
->wID
);
384 if (pB
->fMask
& RBBIM_CHILD
)
385 TRACE(" child=%p", pB
->hwndChild
);
386 if (pB
->fMask
& RBBIM_COLORS
)
387 TRACE(" clrF=0x%06x clrB=0x%06x", pB
->clrFore
, pB
->clrBack
);
389 TRACE("band # %u: mask=0x%08x (%s)\n", i
, pB
->fMask
, REBAR_FmtMask(pB
->fMask
));
390 if (pB
->fMask
& RBBIM_STYLE
)
391 TRACE("band # %u: style=0x%08x (%s)\n",
392 i
, pB
->fStyle
, REBAR_FmtStyle(pB
->fStyle
));
393 TRACE("band # %u: xHeader=%u",
395 if (pB
->fMask
& (RBBIM_SIZE
| RBBIM_IDEALSIZE
| RBBIM_LPARAM
)) {
396 if (pB
->fMask
& RBBIM_SIZE
)
397 TRACE(" cx=%u", pB
->cx
);
398 if (pB
->fMask
& RBBIM_IDEALSIZE
)
399 TRACE(" xIdeal=%u", pB
->cxIdeal
);
400 if (pB
->fMask
& RBBIM_LPARAM
)
401 TRACE(" lParam=0x%08lx", pB
->lParam
);
405 TRACE("band # %u: xMin=%u, yMin=%u, yChild=%u, yMax=%u, yIntgl=%u\n",
406 i
, pB
->cxMinChild
, pB
->cyMinChild
, pB
->cyChild
, pB
->cyMaxChild
, pB
->cyIntegral
);
407 if (pB
->fMask
& RBBIM_TEXT
)
408 TRACE("band # %u: text=%s\n",
409 i
, (pB
->lpText
) ? debugstr_w(pB
->lpText
) : "(null)");
410 TRACE("band # %u: lcx=%u, cxEffective=%u, lcy=%u\n",
411 i
, pB
->lcx
, pB
->cxEffective
, pB
->lcy
);
412 TRACE("band # %u: fStatus=%08x, fDraw=%08x, Band=(%d,%d)-(%d,%d), Grip=(%d,%d)-(%d,%d)\n",
413 i
, pB
->fStatus
, pB
->fDraw
,
414 pB
->rcBand
.left
, pB
->rcBand
.top
, pB
->rcBand
.right
, pB
->rcBand
.bottom
,
415 pB
->rcGripper
.left
, pB
->rcGripper
.top
, pB
->rcGripper
.right
, pB
->rcGripper
.bottom
);
416 TRACE("band # %u: Img=(%d,%d)-(%d,%d), Txt=(%d,%d)-(%d,%d), Child=(%d,%d)-(%d,%d)\n",
418 pB
->rcCapImage
.left
, pB
->rcCapImage
.top
, pB
->rcCapImage
.right
, pB
->rcCapImage
.bottom
,
419 pB
->rcCapText
.left
, pB
->rcCapText
.top
, pB
->rcCapText
.right
, pB
->rcCapText
.bottom
,
420 pB
->rcChild
.left
, pB
->rcChild
.top
, pB
->rcChild
.right
, pB
->rcChild
.bottom
);
425 /* dest can be equal to src */
426 static void translate_rect(const REBAR_INFO
*infoPtr
, RECT
*dest
, const RECT
*src
)
428 if (infoPtr
->dwStyle
& CCS_VERT
) {
431 dest
->left
= src
->top
;
435 dest
->right
= src
->bottom
;
442 static int get_rect_cx(const REBAR_INFO
*infoPtr
, const RECT
*lpRect
)
444 if (infoPtr
->dwStyle
& CCS_VERT
)
445 return lpRect
->bottom
- lpRect
->top
;
446 return lpRect
->right
- lpRect
->left
;
449 static int get_rect_cy(const REBAR_INFO
*infoPtr
, const RECT
*lpRect
)
451 if (infoPtr
->dwStyle
& CCS_VERT
)
452 return lpRect
->right
- lpRect
->left
;
453 return lpRect
->bottom
- lpRect
->top
;
456 static void round_child_height(REBAR_BAND
*lpBand
, int cyHeight
)
459 if (lpBand
->cyIntegral
== 0)
461 cy
= max(cyHeight
- (int)lpBand
->cyMinChild
, 0);
462 cy
= lpBand
->cyMinChild
+ (cy
/lpBand
->cyIntegral
) * lpBand
->cyIntegral
;
463 cy
= min(cy
, lpBand
->cyMaxChild
);
464 lpBand
->cyChild
= cy
;
468 REBAR_DrawChevron (HDC hdc
, INT left
, INT top
, INT colorRef
)
473 if (!(hPen
= CreatePen( PS_SOLID
, 1, GetSysColor( colorRef
)))) return;
474 hOldPen
= SelectObject ( hdc
, hPen
);
477 MoveToEx (hdc
, x
, y
, NULL
);
478 LineTo (hdc
, x
+5, y
++); x
++;
479 MoveToEx (hdc
, x
, y
, NULL
);
480 LineTo (hdc
, x
+3, y
++); x
++;
481 MoveToEx (hdc
, x
, y
, NULL
);
482 LineTo (hdc
, x
+1, y
++);
483 SelectObject( hdc
, hOldPen
);
484 DeleteObject( hPen
);
488 REBAR_GetNotifyParent (const REBAR_INFO
*infoPtr
)
492 parent
= infoPtr
->hwndNotify
;
494 parent
= GetParent (infoPtr
->hwndSelf
);
495 owner
= GetWindow (infoPtr
->hwndSelf
, GW_OWNER
);
496 if (owner
) parent
= owner
;
503 REBAR_Notify (NMHDR
*nmhdr
, const REBAR_INFO
*infoPtr
, UINT code
)
507 parent
= REBAR_GetNotifyParent (infoPtr
);
508 nmhdr
->idFrom
= GetDlgCtrlID (infoPtr
->hwndSelf
);
509 nmhdr
->hwndFrom
= infoPtr
->hwndSelf
;
512 TRACE("window %p, code=%08x, via %s\n", parent
, code
, (infoPtr
->bUnicode
)?"Unicode":"ANSI");
514 return SendMessageW(parent
, WM_NOTIFY
, (WPARAM
)nmhdr
->idFrom
, (LPARAM
)nmhdr
);
518 REBAR_Notify_NMREBAR (const REBAR_INFO
*infoPtr
, UINT uBand
, UINT code
)
520 NMREBAR notify_rebar
;
523 notify_rebar
.dwMask
= 0;
525 lpBand
= &infoPtr
->bands
[uBand
];
526 if (lpBand
->fMask
& RBBIM_ID
) {
527 notify_rebar
.dwMask
|= RBNM_ID
;
528 notify_rebar
.wID
= lpBand
->wID
;
530 if (lpBand
->fMask
& RBBIM_LPARAM
) {
531 notify_rebar
.dwMask
|= RBNM_LPARAM
;
532 notify_rebar
.lParam
= lpBand
->lParam
;
534 if (lpBand
->fMask
& RBBIM_STYLE
) {
535 notify_rebar
.dwMask
|= RBNM_STYLE
;
536 notify_rebar
.fStyle
= lpBand
->fStyle
;
539 notify_rebar
.uBand
= uBand
;
540 return REBAR_Notify ((NMHDR
*)¬ify_rebar
, infoPtr
, code
);
544 REBAR_DrawBand (HDC hdc
, const REBAR_INFO
*infoPtr
, REBAR_BAND
*lpBand
)
549 HTHEME theme
= GetWindowTheme (infoPtr
->hwndSelf
);
552 translate_rect(infoPtr
, &rcBand
, &lpBand
->rcBand
);
554 if (lpBand
->fDraw
& DRAW_TEXT
) {
555 hOldFont
= SelectObject (hdc
, infoPtr
->hFont
);
556 oldBkMode
= SetBkMode (hdc
, TRANSPARENT
);
559 /* should test for CDRF_NOTIFYITEMDRAW here */
560 nmcd
.dwDrawStage
= CDDS_ITEMPREPAINT
;
563 nmcd
.rc
.right
= lpBand
->rcCapText
.right
;
564 nmcd
.rc
.bottom
= lpBand
->rcCapText
.bottom
;
565 nmcd
.dwItemSpec
= lpBand
->wID
;
567 nmcd
.lItemlParam
= lpBand
->lParam
;
568 lpBand
->uCDret
= REBAR_Notify ((NMHDR
*)&nmcd
, infoPtr
, NM_CUSTOMDRAW
);
569 if (lpBand
->uCDret
== CDRF_SKIPDEFAULT
) {
570 if (oldBkMode
!= TRANSPARENT
)
571 SetBkMode (hdc
, oldBkMode
);
572 SelectObject (hdc
, hOldFont
);
577 if (lpBand
->fDraw
& DRAW_GRIPPER
)
581 RECT rcGripper
= lpBand
->rcGripper
;
582 int partId
= (infoPtr
->dwStyle
& CCS_VERT
) ? RP_GRIPPERVERT
: RP_GRIPPER
;
583 GetThemeBackgroundExtent (theme
, hdc
, partId
, 0, &rcGripper
, &rcGripper
);
584 OffsetRect (&rcGripper
, lpBand
->rcGripper
.left
- rcGripper
.left
,
585 lpBand
->rcGripper
.top
- rcGripper
.top
);
586 DrawThemeBackground (theme
, hdc
, partId
, 0, &rcGripper
, NULL
);
589 DrawEdge (hdc
, &lpBand
->rcGripper
, BDR_RAISEDINNER
, BF_RECT
| BF_MIDDLE
);
592 /* draw caption image */
593 if (lpBand
->fDraw
& DRAW_IMAGE
) {
597 pt
.y
= (lpBand
->rcCapImage
.bottom
+ lpBand
->rcCapImage
.top
- infoPtr
->imageSize
.cy
)/2;
598 pt
.x
= (lpBand
->rcCapImage
.right
+ lpBand
->rcCapImage
.left
- infoPtr
->imageSize
.cx
)/2;
600 ImageList_Draw (infoPtr
->himl
, lpBand
->iImage
, hdc
,
605 /* draw caption text */
606 if (lpBand
->fDraw
& DRAW_TEXT
) {
607 /* need to handle CDRF_NEWFONT here */
608 INT oldBkMode
= SetBkMode (hdc
, TRANSPARENT
);
609 COLORREF oldcolor
= CLR_NONE
;
611 if (lpBand
->clrFore
!= CLR_NONE
) {
612 new = (lpBand
->clrFore
== CLR_DEFAULT
) ? infoPtr
->clrBtnText
:
614 oldcolor
= SetTextColor (hdc
, new);
616 DrawTextW (hdc
, lpBand
->lpText
, -1, &lpBand
->rcCapText
,
617 DT_CENTER
| DT_VCENTER
| DT_SINGLELINE
);
618 if (oldBkMode
!= TRANSPARENT
)
619 SetBkMode (hdc
, oldBkMode
);
620 if (lpBand
->clrFore
!= CLR_NONE
)
621 SetTextColor (hdc
, oldcolor
);
622 SelectObject (hdc
, hOldFont
);
625 if (!IsRectEmpty(&lpBand
->rcChevron
))
630 if (lpBand
->fDraw
& DRAW_CHEVRONPUSHED
)
631 stateId
= CHEVS_PRESSED
;
632 else if (lpBand
->fDraw
& DRAW_CHEVRONHOT
)
635 stateId
= CHEVS_NORMAL
;
636 DrawThemeBackground (theme
, hdc
, RP_CHEVRON
, stateId
, &lpBand
->rcChevron
, NULL
);
640 if (lpBand
->fDraw
& DRAW_CHEVRONPUSHED
)
642 DrawEdge(hdc
, &lpBand
->rcChevron
, BDR_SUNKENOUTER
, BF_RECT
| BF_MIDDLE
);
643 REBAR_DrawChevron(hdc
, lpBand
->rcChevron
.left
+1, lpBand
->rcChevron
.top
+ 11, COLOR_WINDOWFRAME
);
645 else if (lpBand
->fDraw
& DRAW_CHEVRONHOT
)
647 DrawEdge(hdc
, &lpBand
->rcChevron
, BDR_RAISEDINNER
, BF_RECT
| BF_MIDDLE
);
648 REBAR_DrawChevron(hdc
, lpBand
->rcChevron
.left
, lpBand
->rcChevron
.top
+ 10, COLOR_WINDOWFRAME
);
651 REBAR_DrawChevron(hdc
, lpBand
->rcChevron
.left
, lpBand
->rcChevron
.top
+ 10, COLOR_WINDOWFRAME
);
655 if (lpBand
->uCDret
== (CDRF_NOTIFYPOSTPAINT
| CDRF_NOTIFYITEMDRAW
)) {
656 nmcd
.dwDrawStage
= CDDS_ITEMPOSTPAINT
;
659 nmcd
.rc
.right
= lpBand
->rcCapText
.right
;
660 nmcd
.rc
.bottom
= lpBand
->rcCapText
.bottom
;
661 nmcd
.dwItemSpec
= lpBand
->wID
;
663 nmcd
.lItemlParam
= lpBand
->lParam
;
664 lpBand
->uCDret
= REBAR_Notify ((NMHDR
*)&nmcd
, infoPtr
, NM_CUSTOMDRAW
);
670 REBAR_Refresh (const REBAR_INFO
*infoPtr
, HDC hdc
)
675 if (!infoPtr
->DoRedraw
) return;
677 for (i
= 0; i
< infoPtr
->uNumBands
; i
++) {
678 lpBand
= &infoPtr
->bands
[i
];
680 if (HIDDENBAND(lpBand
)) continue;
682 /* now draw the band */
683 TRACE("[%p] drawing band %i, flags=%08x\n",
684 infoPtr
->hwndSelf
, i
, lpBand
->fDraw
);
685 REBAR_DrawBand (hdc
, infoPtr
, lpBand
);
692 REBAR_CalcHorzBand (const REBAR_INFO
*infoPtr
, UINT rstart
, UINT rend
)
693 /* Function: this routine initializes all the rectangles in */
694 /* each band in a row to fit in the adjusted rcBand rect. */
695 /* *** Supports only Horizontal bars. *** */
701 for(i
=rstart
; i
<rend
; i
++){
702 lpBand
= &infoPtr
->bands
[i
];
703 if (HIDDENBAND(lpBand
)) {
704 SetRect (&lpBand
->rcChild
,
705 lpBand
->rcBand
.right
, lpBand
->rcBand
.top
,
706 lpBand
->rcBand
.right
, lpBand
->rcBand
.bottom
);
710 /* set initial gripper rectangle */
711 SetRect (&lpBand
->rcGripper
, lpBand
->rcBand
.left
, lpBand
->rcBand
.top
,
712 lpBand
->rcBand
.left
, lpBand
->rcBand
.bottom
);
714 /* calculate gripper rectangle */
715 if ( lpBand
->fStatus
& HAS_GRIPPER
) {
716 lpBand
->fDraw
|= DRAW_GRIPPER
;
717 lpBand
->rcGripper
.left
+= REBAR_PRE_GRIPPER
;
718 lpBand
->rcGripper
.right
= lpBand
->rcGripper
.left
+ GRIPPER_WIDTH
;
719 lpBand
->rcGripper
.top
+= 2;
720 lpBand
->rcGripper
.bottom
-= 2;
722 SetRect (&lpBand
->rcCapImage
,
723 lpBand
->rcGripper
.right
+REBAR_ALWAYS_SPACE
, lpBand
->rcBand
.top
,
724 lpBand
->rcGripper
.right
+REBAR_ALWAYS_SPACE
, lpBand
->rcBand
.bottom
);
726 else { /* no gripper will be drawn */
728 if (lpBand
->fStatus
& (HAS_IMAGE
| HAS_TEXT
))
729 /* if no gripper but either image or text, then leave space */
730 xoff
= REBAR_ALWAYS_SPACE
;
731 SetRect (&lpBand
->rcCapImage
,
732 lpBand
->rcBand
.left
+xoff
, lpBand
->rcBand
.top
,
733 lpBand
->rcBand
.left
+xoff
, lpBand
->rcBand
.bottom
);
736 /* image is visible */
737 if (lpBand
->fStatus
& HAS_IMAGE
) {
738 lpBand
->fDraw
|= DRAW_IMAGE
;
739 lpBand
->rcCapImage
.right
+= infoPtr
->imageSize
.cx
;
740 lpBand
->rcCapImage
.bottom
= lpBand
->rcCapImage
.top
+ infoPtr
->imageSize
.cy
;
742 /* set initial caption text rectangle */
743 SetRect (&lpBand
->rcCapText
,
744 lpBand
->rcCapImage
.right
+REBAR_POST_IMAGE
, lpBand
->rcBand
.top
+1,
745 lpBand
->rcBand
.left
+lpBand
->cxHeader
, lpBand
->rcBand
.bottom
-1);
748 /* set initial caption text rectangle */
749 SetRect (&lpBand
->rcCapText
, lpBand
->rcCapImage
.right
, lpBand
->rcBand
.top
+1,
750 lpBand
->rcBand
.left
+lpBand
->cxHeader
, lpBand
->rcBand
.bottom
-1);
753 /* text is visible */
754 if ((lpBand
->fStatus
& HAS_TEXT
) && !(lpBand
->fStyle
& RBBS_HIDETITLE
)) {
755 lpBand
->fDraw
|= DRAW_TEXT
;
756 lpBand
->rcCapText
.right
= max(lpBand
->rcCapText
.left
,
757 lpBand
->rcCapText
.right
-REBAR_POST_TEXT
);
760 /* set initial child window rectangle if there is a child */
761 if (lpBand
->hwndChild
!= NULL
) {
762 int cyBand
= lpBand
->rcBand
.bottom
- lpBand
->rcBand
.top
;
763 yoff
= (cyBand
- lpBand
->cyChild
) / 2;
764 SetRect (&lpBand
->rcChild
,
765 lpBand
->rcBand
.left
+ lpBand
->cxHeader
, lpBand
->rcBand
.top
+ yoff
,
766 lpBand
->rcBand
.right
- REBAR_POST_CHILD
, lpBand
->rcBand
.top
+ yoff
+ lpBand
->cyChild
);
767 if ((lpBand
->fStyle
& RBBS_USECHEVRON
) && (lpBand
->rcChild
.right
- lpBand
->rcChild
.left
< lpBand
->cxIdeal
))
769 lpBand
->rcChild
.right
-= CHEVRON_WIDTH
;
770 SetRect(&lpBand
->rcChevron
, lpBand
->rcChild
.right
,
771 lpBand
->rcChild
.top
, lpBand
->rcChild
.right
+ CHEVRON_WIDTH
,
772 lpBand
->rcChild
.bottom
);
776 SetRect (&lpBand
->rcChild
,
777 lpBand
->rcBand
.left
+lpBand
->cxHeader
, lpBand
->rcBand
.top
,
778 lpBand
->rcBand
.right
, lpBand
->rcBand
.bottom
);
781 /* flag if notify required and invalidate rectangle */
782 if (lpBand
->fDraw
& NTF_INVALIDATE
) {
783 TRACE("invalidating (%d,%d)-(%d,%d)\n",
786 lpBand
->rcBand
.right
+ SEP_WIDTH
,
787 lpBand
->rcBand
.bottom
+ SEP_WIDTH
);
788 lpBand
->fDraw
&= ~NTF_INVALIDATE
;
789 work
= lpBand
->rcBand
;
790 work
.right
+= SEP_WIDTH
;
791 work
.bottom
+= SEP_WIDTH
;
792 InvalidateRect(infoPtr
->hwndSelf
, &work
, TRUE
);
801 REBAR_CalcVertBand (const REBAR_INFO
*infoPtr
, UINT rstart
, UINT rend
)
802 /* Function: this routine initializes all the rectangles in */
803 /* each band in a row to fit in the adjusted rcBand rect. */
804 /* *** Supports only Vertical bars. *** */
810 for(i
=rstart
; i
<rend
; i
++){
812 lpBand
= &infoPtr
->bands
[i
];
813 if (HIDDENBAND(lpBand
)) continue;
815 translate_rect(infoPtr
, &rcBand
, &lpBand
->rcBand
);
817 /* set initial gripper rectangle */
818 SetRect (&lpBand
->rcGripper
, rcBand
.left
, rcBand
.top
, rcBand
.right
, rcBand
.top
);
820 /* calculate gripper rectangle */
821 if (lpBand
->fStatus
& HAS_GRIPPER
) {
822 lpBand
->fDraw
|= DRAW_GRIPPER
;
824 if (infoPtr
->dwStyle
& RBS_VERTICALGRIPPER
) {
825 /* vertical gripper */
826 lpBand
->rcGripper
.left
+= 3;
827 lpBand
->rcGripper
.right
= lpBand
->rcGripper
.left
+ GRIPPER_WIDTH
;
828 lpBand
->rcGripper
.top
+= REBAR_PRE_GRIPPER
;
829 lpBand
->rcGripper
.bottom
= lpBand
->rcGripper
.top
+ GRIPPER_HEIGHT
;
831 /* initialize Caption image rectangle */
832 SetRect (&lpBand
->rcCapImage
, rcBand
.left
,
833 lpBand
->rcGripper
.bottom
+ REBAR_ALWAYS_SPACE
,
835 lpBand
->rcGripper
.bottom
+ REBAR_ALWAYS_SPACE
);
838 /* horizontal gripper */
839 lpBand
->rcGripper
.left
+= 2;
840 lpBand
->rcGripper
.right
-= 2;
841 lpBand
->rcGripper
.top
+= REBAR_PRE_GRIPPER
;
842 lpBand
->rcGripper
.bottom
= lpBand
->rcGripper
.top
+ GRIPPER_WIDTH
;
844 /* initialize Caption image rectangle */
845 SetRect (&lpBand
->rcCapImage
, rcBand
.left
,
846 lpBand
->rcGripper
.bottom
+ REBAR_ALWAYS_SPACE
,
848 lpBand
->rcGripper
.bottom
+ REBAR_ALWAYS_SPACE
);
851 else { /* no gripper will be drawn */
853 if (lpBand
->fStatus
& (HAS_IMAGE
| HAS_TEXT
))
854 /* if no gripper but either image or text, then leave space */
855 xoff
= REBAR_ALWAYS_SPACE
;
856 /* initialize Caption image rectangle */
857 SetRect (&lpBand
->rcCapImage
,
858 rcBand
.left
, rcBand
.top
+xoff
,
859 rcBand
.right
, rcBand
.top
+xoff
);
862 /* image is visible */
863 if (lpBand
->fStatus
& HAS_IMAGE
) {
864 lpBand
->fDraw
|= DRAW_IMAGE
;
866 lpBand
->rcCapImage
.right
= lpBand
->rcCapImage
.left
+ infoPtr
->imageSize
.cx
;
867 lpBand
->rcCapImage
.bottom
+= infoPtr
->imageSize
.cy
;
869 /* set initial caption text rectangle */
870 SetRect (&lpBand
->rcCapText
,
871 rcBand
.left
, lpBand
->rcCapImage
.bottom
+REBAR_POST_IMAGE
,
872 rcBand
.right
, rcBand
.top
+lpBand
->cxHeader
);
875 /* set initial caption text rectangle */
876 SetRect (&lpBand
->rcCapText
,
877 rcBand
.left
, lpBand
->rcCapImage
.bottom
,
878 rcBand
.right
, rcBand
.top
+lpBand
->cxHeader
);
881 /* text is visible */
882 if ((lpBand
->fStatus
& HAS_TEXT
) && !(lpBand
->fStyle
& RBBS_HIDETITLE
)) {
883 lpBand
->fDraw
|= DRAW_TEXT
;
884 lpBand
->rcCapText
.bottom
= max(lpBand
->rcCapText
.top
,
885 lpBand
->rcCapText
.bottom
);
888 /* set initial child window rectangle if there is a child */
889 if (lpBand
->hwndChild
!= NULL
) {
890 int cxBand
= rcBand
.right
- rcBand
.left
;
891 xoff
= (cxBand
- lpBand
->cyChild
) / 2;
892 SetRect (&lpBand
->rcChild
,
893 rcBand
.left
+ xoff
, rcBand
.top
+ lpBand
->cxHeader
,
894 rcBand
.left
+ xoff
+ lpBand
->cyChild
, rcBand
.bottom
- REBAR_POST_CHILD
);
897 SetRect (&lpBand
->rcChild
,
898 rcBand
.left
, rcBand
.top
+lpBand
->cxHeader
,
899 rcBand
.right
, rcBand
.bottom
);
902 if (lpBand
->fDraw
& NTF_INVALIDATE
) {
903 TRACE("invalidating (%d,%d)-(%d,%d)\n",
906 rcBand
.right
+ SEP_WIDTH
,
907 rcBand
.bottom
+ SEP_WIDTH
);
908 lpBand
->fDraw
&= ~NTF_INVALIDATE
;
910 work
.bottom
+= SEP_WIDTH
;
911 work
.right
+= SEP_WIDTH
;
912 InvalidateRect(infoPtr
->hwndSelf
, &work
, TRUE
);
920 REBAR_ForceResize (REBAR_INFO
*infoPtr
)
921 /* Function: This changes the size of the REBAR window to that */
922 /* calculated by REBAR_Layout. */
924 INT x
, y
, width
, height
;
925 INT xedge
= 0, yedge
= 0;
928 TRACE("new size [%d x %d]\n", infoPtr
->calcSize
.cx
, infoPtr
->calcSize
.cy
);
930 if (infoPtr
->dwStyle
& CCS_NORESIZE
)
933 if (infoPtr
->dwStyle
& WS_BORDER
)
935 xedge
= GetSystemMetrics(SM_CXEDGE
);
936 yedge
= GetSystemMetrics(SM_CYEDGE
);
937 /* swap for CCS_VERT? */
940 /* compute rebar window rect in parent client coordinates */
941 GetWindowRect(infoPtr
->hwndSelf
, &rcSelf
);
942 MapWindowPoints(HWND_DESKTOP
, GetParent(infoPtr
->hwndSelf
), (LPPOINT
)&rcSelf
, 2);
943 translate_rect(infoPtr
, &rcSelf
, &rcSelf
);
945 height
= infoPtr
->calcSize
.cy
+ 2*yedge
;
946 if (!(infoPtr
->dwStyle
& CCS_NOPARENTALIGN
)) {
950 width
= infoPtr
->calcSize
.cx
+ 2*xedge
;
951 y
= 0; /* quiet compiler warning */
952 switch ( infoPtr
->dwStyle
& CCS_LAYOUT_MASK
) {
953 case 0: /* shouldn't happen - see NCCreate */
955 y
= ((infoPtr
->dwStyle
& CCS_NODIVIDER
) ? 0 : REBAR_DIVIDER
) - yedge
;
961 GetClientRect(GetParent(infoPtr
->hwndSelf
), &rcParent
);
962 translate_rect(infoPtr
, &rcParent
, &rcParent
);
963 y
= rcParent
.bottom
- infoPtr
->calcSize
.cy
- yedge
;
969 /* As on Windows if the CCS_NODIVIDER is not present the control will move
970 * 2 pixel down after every layout */
971 y
= rcSelf
.top
+ ((infoPtr
->dwStyle
& CCS_NODIVIDER
) ? 0 : REBAR_DIVIDER
);
972 width
= rcSelf
.right
- rcSelf
.left
;
975 TRACE("hwnd %p, style=%08x, setting at (%d,%d) for (%d,%d)\n",
976 infoPtr
->hwndSelf
, infoPtr
->dwStyle
, x
, y
, width
, height
);
978 /* Set flag to ignore next WM_SIZE message and resize the window */
979 infoPtr
->fStatus
|= AUTO_RESIZE
;
980 if ((infoPtr
->dwStyle
& CCS_VERT
) == 0)
981 SetWindowPos(infoPtr
->hwndSelf
, 0, x
, y
, width
, height
, SWP_NOZORDER
);
983 SetWindowPos(infoPtr
->hwndSelf
, 0, y
, x
, height
, width
, SWP_NOZORDER
);
984 infoPtr
->fStatus
&= ~AUTO_RESIZE
;
989 REBAR_MoveChildWindows (const REBAR_INFO
*infoPtr
, UINT start
, UINT endplus
)
991 static const WCHAR strComboBox
[] = { 'C','o','m','b','o','B','o','x',0 };
993 WCHAR szClassName
[40];
995 NMREBARCHILDSIZE rbcz
;
998 if (!(deferpos
= BeginDeferWindowPos(infoPtr
->uNumBands
)))
999 ERR("BeginDeferWindowPos returned NULL\n");
1001 for (i
= start
; i
< endplus
; i
++) {
1002 lpBand
= &infoPtr
->bands
[i
];
1004 if (HIDDENBAND(lpBand
)) continue;
1005 if (lpBand
->hwndChild
) {
1006 TRACE("hwndChild = %p\n", lpBand
->hwndChild
);
1008 /* Always geterate the RBN_CHILDSIZE even it child
1011 rbcz
.wID
= lpBand
->wID
;
1012 rbcz
.rcChild
= lpBand
->rcChild
;
1013 translate_rect(infoPtr
, &rbcz
.rcBand
, &lpBand
->rcBand
);
1014 if (infoPtr
->dwStyle
& CCS_VERT
)
1015 rbcz
.rcBand
.top
+= lpBand
->cxHeader
;
1017 rbcz
.rcBand
.left
+= lpBand
->cxHeader
;
1018 REBAR_Notify ((NMHDR
*)&rbcz
, infoPtr
, RBN_CHILDSIZE
);
1019 if (!EqualRect (&lpBand
->rcChild
, &rbcz
.rcChild
)) {
1020 TRACE("Child rect changed by NOTIFY for band %u\n", i
);
1021 TRACE(" from (%d,%d)-(%d,%d) to (%d,%d)-(%d,%d)\n",
1022 lpBand
->rcChild
.left
, lpBand
->rcChild
.top
,
1023 lpBand
->rcChild
.right
, lpBand
->rcChild
.bottom
,
1024 rbcz
.rcChild
.left
, rbcz
.rcChild
.top
,
1025 rbcz
.rcChild
.right
, rbcz
.rcChild
.bottom
);
1026 lpBand
->rcChild
= rbcz
.rcChild
; /* *** ??? */
1029 /* native (IE4 in "Favorites" frame **1) does:
1030 * SetRect (&rc, -1, -1, -1, -1)
1031 * EqualRect (&rc,band->rc???)
1033 * CopyRect (band->rc????, &rc)
1034 * set flag outside of loop
1037 GetClassNameW (lpBand
->hwndChild
, szClassName
, sizeof(szClassName
)/sizeof(szClassName
[0]));
1038 if (!lstrcmpW (szClassName
, strComboBox
) ||
1039 !lstrcmpW (szClassName
, WC_COMBOBOXEXW
)) {
1040 INT nEditHeight
, yPos
;
1043 /* special placement code for combo or comboex box */
1046 /* get size of edit line */
1047 GetWindowRect (lpBand
->hwndChild
, &rc
);
1048 nEditHeight
= rc
.bottom
- rc
.top
;
1049 yPos
= (lpBand
->rcChild
.bottom
+ lpBand
->rcChild
.top
- nEditHeight
)/2;
1051 /* center combo box inside child area */
1052 TRACE("moving child (Combo(Ex)) %p to (%d,%d) for (%d,%d)\n",
1054 lpBand
->rcChild
.left
, yPos
,
1055 lpBand
->rcChild
.right
- lpBand
->rcChild
.left
,
1057 deferpos
= DeferWindowPos (deferpos
, lpBand
->hwndChild
, HWND_TOP
,
1058 lpBand
->rcChild
.left
,
1059 /*lpBand->rcChild.top*/ yPos
,
1060 lpBand
->rcChild
.right
- lpBand
->rcChild
.left
,
1064 ERR("DeferWindowPos returned NULL\n");
1067 TRACE("moving child (Other) %p to (%d,%d) for (%d,%d)\n",
1069 lpBand
->rcChild
.left
, lpBand
->rcChild
.top
,
1070 lpBand
->rcChild
.right
- lpBand
->rcChild
.left
,
1071 lpBand
->rcChild
.bottom
- lpBand
->rcChild
.top
);
1072 deferpos
= DeferWindowPos (deferpos
, lpBand
->hwndChild
, HWND_TOP
,
1073 lpBand
->rcChild
.left
,
1074 lpBand
->rcChild
.top
,
1075 lpBand
->rcChild
.right
- lpBand
->rcChild
.left
,
1076 lpBand
->rcChild
.bottom
- lpBand
->rcChild
.top
,
1079 ERR("DeferWindowPos returned NULL\n");
1083 if (!EndDeferWindowPos(deferpos
))
1084 ERR("EndDeferWindowPos returned NULL\n");
1086 if (infoPtr
->DoRedraw
)
1087 UpdateWindow (infoPtr
->hwndSelf
);
1089 /* native (from **1 above) does:
1090 * UpdateWindow(rebar)
1092 * RBN_HEIGHTCHANGE if necessary
1093 * if ret from any EqualRect was 0
1094 * Goto "BeginDeferWindowPos"
1099 static int next_band(const REBAR_INFO
*infoPtr
, int i
)
1102 for (n
= i
+ 1; n
< infoPtr
->uNumBands
; n
++)
1103 if (!HIDDENBAND(&infoPtr
->bands
[n
]))
1108 static int prev_band(const REBAR_INFO
*infoPtr
, int i
)
1111 for (n
= i
- 1; n
>= 0; n
--)
1112 if (!HIDDENBAND(&infoPtr
->bands
[n
]))
1117 static int get_row_begin_for_band(const REBAR_INFO
*infoPtr
, INT iBand
)
1119 int iLastBand
= iBand
;
1120 int iRow
= infoPtr
->bands
[iBand
].iRow
;
1121 while ((iBand
= prev_band(infoPtr
, iBand
)) >= 0) {
1122 if (infoPtr
->bands
[iBand
].iRow
!= iRow
)
1130 static int get_row_end_for_band(const REBAR_INFO
*infoPtr
, INT iBand
)
1132 int iRow
= infoPtr
->bands
[iBand
].iRow
;
1133 while ((iBand
= next_band(infoPtr
, iBand
)) < infoPtr
->uNumBands
)
1134 if (infoPtr
->bands
[iBand
].iRow
!= iRow
)
1139 static void REBAR_SetRowRectsX(const REBAR_INFO
*infoPtr
, INT iBeginBand
, INT iEndBand
)
1142 for (i
= iBeginBand
; i
< iEndBand
; i
= next_band(infoPtr
, i
))
1144 REBAR_BAND
*lpBand
= &infoPtr
->bands
[i
];
1146 lpBand
= &infoPtr
->bands
[i
];
1147 if (lpBand
->rcBand
.left
!= xPos
|| lpBand
->rcBand
.right
!= xPos
+ lpBand
->cxEffective
) {
1148 lpBand
->fDraw
|= NTF_INVALIDATE
;
1149 TRACE("Setting rect %d to %d,%d\n", i
, xPos
, xPos
+ lpBand
->cxEffective
);
1150 lpBand
->rcBand
.left
= xPos
;
1151 lpBand
->rcBand
.right
= xPos
+ lpBand
->cxEffective
;
1153 xPos
+= lpBand
->cxEffective
+ SEP_WIDTH
;
1157 /* The rationale of this function is probably as follows: if we have some space
1158 * to distribute we want to add it to a band on the right. However we don't want
1159 * to unminimize a minimized band so we search for a band that is big enough.
1160 * For some reason "big enough" is defined as bigger than the minimum size of the
1161 * first band in the row
1163 static REBAR_BAND
*REBAR_FindBandToGrow(const REBAR_INFO
*infoPtr
, INT iBeginBand
, INT iEndBand
)
1167 iLcx
= infoPtr
->bands
[iBeginBand
].lcx
;
1169 for (i
= prev_band(infoPtr
, iEndBand
); i
>= iBeginBand
; i
= prev_band(infoPtr
, i
))
1170 if (infoPtr
->bands
[i
].cxEffective
> iLcx
&& !(infoPtr
->bands
[i
].fStyle
&RBBS_FIXEDSIZE
))
1174 for (i
= prev_band(infoPtr
, iEndBand
); i
>= iBeginBand
; i
= prev_band(infoPtr
, i
))
1175 if (infoPtr
->bands
[i
].lcx
== iLcx
)
1178 TRACE("Extra space for row [%d..%d) should be added to band %d\n", iBeginBand
, iEndBand
, i
);
1179 return &infoPtr
->bands
[i
];
1182 static int REBAR_ShrinkBandsRTL(const REBAR_INFO
*infoPtr
, INT iBeginBand
, INT iEndBand
, INT cxShrink
, BOOL bEnforce
)
1187 TRACE("Shrinking bands [%d..%d) by %d, right-to-left\n", iBeginBand
, iEndBand
, cxShrink
);
1188 for (i
= prev_band(infoPtr
, iEndBand
); i
>= iBeginBand
; i
= prev_band(infoPtr
, i
))
1190 lpBand
= &infoPtr
->bands
[i
];
1192 width
= max(lpBand
->cxEffective
- cxShrink
, (int)lpBand
->lcx
);
1193 cxShrink
-= lpBand
->cxEffective
- width
;
1194 lpBand
->cxEffective
= width
;
1195 if (bEnforce
&& lpBand
->cx
> lpBand
->cxEffective
)
1196 lpBand
->cx
= lpBand
->cxEffective
;
1204 static int REBAR_ShrinkBandsLTR(const REBAR_INFO
*infoPtr
, INT iBeginBand
, INT iEndBand
, INT cxShrink
, BOOL bEnforce
)
1209 TRACE("Shrinking bands [%d..%d) by %d, left-to-right\n", iBeginBand
, iEndBand
, cxShrink
);
1210 for (i
= iBeginBand
; i
< iEndBand
; i
= next_band(infoPtr
, i
))
1212 lpBand
= &infoPtr
->bands
[i
];
1214 width
= max(lpBand
->cxEffective
- cxShrink
, (int)lpBand
->lcx
);
1215 cxShrink
-= lpBand
->cxEffective
- width
;
1216 lpBand
->cxEffective
= width
;
1218 lpBand
->cx
= lpBand
->cxEffective
;
1225 static int REBAR_SetBandsHeight(const REBAR_INFO
*infoPtr
, INT iBeginBand
, INT iEndBand
, INT yStart
)
1230 int row
= infoPtr
->bands
[iBeginBand
].iRow
;
1232 for (i
= iBeginBand
; i
< iEndBand
; i
= next_band(infoPtr
, i
))
1234 lpBand
= &infoPtr
->bands
[i
];
1235 yMaxHeight
= max(yMaxHeight
, lpBand
->lcy
);
1237 TRACE("Bands [%d; %d) height: %d\n", iBeginBand
, iEndBand
, yMaxHeight
);
1239 for (i
= iBeginBand
; i
< iEndBand
; i
= next_band(infoPtr
, i
))
1241 lpBand
= &infoPtr
->bands
[i
];
1242 /* we may be called for multiple rows if RBS_VARHEIGHT not set */
1243 if (lpBand
->iRow
!= row
) {
1244 yPos
+= yMaxHeight
+ SEP_WIDTH
;
1248 if (lpBand
->rcBand
.top
!= yPos
|| lpBand
->rcBand
.bottom
!= yPos
+ yMaxHeight
) {
1249 lpBand
->fDraw
|= NTF_INVALIDATE
;
1250 lpBand
->rcBand
.top
= yPos
;
1251 lpBand
->rcBand
.bottom
= yPos
+ yMaxHeight
;
1252 TRACE("Band %d: %s\n", i
, wine_dbgstr_rect(&lpBand
->rcBand
));
1255 return yPos
+ yMaxHeight
;
1258 static void REBAR_LayoutRow(const REBAR_INFO
*infoPtr
, int iBeginBand
, int iEndBand
, int cx
, int *piRow
, int *pyPos
)
1264 TRACE("Adjusting row [%d;%d). Width: %d\n", iBeginBand
, iEndBand
, cx
);
1265 for (i
= iBeginBand
; i
< iEndBand
; i
++)
1266 infoPtr
->bands
[i
].iRow
= *piRow
;
1268 /* compute the extra space */
1269 for (i
= iBeginBand
; i
< iEndBand
; i
= next_band(infoPtr
, i
))
1271 lpBand
= &infoPtr
->bands
[i
];
1274 lpBand
->cxEffective
= max(lpBand
->lcx
, lpBand
->cx
);
1275 width
+= lpBand
->cxEffective
;
1279 TRACE("Extra space: %d\n", extra
);
1281 int ret
= REBAR_ShrinkBandsRTL(infoPtr
, iBeginBand
, iEndBand
, -extra
, FALSE
);
1282 if (ret
> 0 && next_band(infoPtr
, iBeginBand
) != iEndBand
) /* one band may be longer than expected... */
1283 ERR("Error layouting row %d - couldn't shrink for %d pixels (%d total shrink)\n", *piRow
, ret
, -extra
);
1286 lpBand
= REBAR_FindBandToGrow(infoPtr
, iBeginBand
, iEndBand
);
1287 lpBand
->cxEffective
+= extra
;
1290 REBAR_SetRowRectsX(infoPtr
, iBeginBand
, iEndBand
);
1291 if (infoPtr
->dwStyle
& RBS_VARHEIGHT
)
1294 *pyPos
+= SEP_WIDTH
;
1295 *pyPos
= REBAR_SetBandsHeight(infoPtr
, iBeginBand
, iEndBand
, *pyPos
);
1301 REBAR_Layout(REBAR_INFO
*infoPtr
, const RECT
*lpRect
)
1306 INT adjcx
, adjcy
, i
;
1311 const INT yInit
= 0;
1316 cyTarget
= get_rect_cy(infoPtr
, lpRect
);
1317 } else if (infoPtr
->dwStyle
& (CCS_NORESIZE
| CCS_NOPARENTALIGN
) || GetParent(infoPtr
->hwndSelf
) == NULL
)
1318 GetClientRect(infoPtr
->hwndSelf
, &rcAdj
);
1320 GetClientRect(GetParent(infoPtr
->hwndSelf
), &rcAdj
);
1321 TRACE("adjustment rect is (%d,%d)-(%d,%d)\n", rcAdj
.left
, rcAdj
.top
, rcAdj
.right
, rcAdj
.bottom
);
1323 adjcx
= get_rect_cx(infoPtr
, &rcAdj
);
1324 adjcy
= get_rect_cy(infoPtr
, &rcAdj
);
1326 if (infoPtr
->uNumBands
== 0) {
1327 TRACE("No bands - setting size to (0,%d), vert: %lx\n", adjcx
, infoPtr
->dwStyle
& CCS_VERT
);
1328 infoPtr
->calcSize
.cx
= adjcx
;
1329 /* the calcSize.cy won't change for a 0 band rebar */
1330 infoPtr
->uNumRows
= 0;
1331 REBAR_ForceResize(infoPtr
);
1339 for (i
= 0; i
< infoPtr
->uNumBands
; i
++)
1341 lpBand
= &infoPtr
->bands
[i
];
1342 if (HIDDENBAND(lpBand
)) continue;
1344 if (i
> rowstart
&& (lpBand
->fStyle
& RBBS_BREAK
|| xMin
+ lpBand
->lcx
> adjcx
)) {
1345 TRACE("%s break on band %d\n", (lpBand
->fStyle
& RBBS_BREAK
? "Hard" : "Soft"), i
- 1);
1346 REBAR_LayoutRow(infoPtr
, rowstart
, i
, adjcx
, &row
, &yPos
);
1353 xMin
+= lpBand
->lcx
;
1355 REBAR_LayoutRow(infoPtr
, rowstart
, infoPtr
->uNumBands
, adjcx
, &row
, &yPos
);
1357 if (!(infoPtr
->dwStyle
& RBS_VARHEIGHT
))
1358 yPos
= REBAR_SetBandsHeight(infoPtr
, 0, infoPtr
->uNumBands
, yInit
);
1360 infoPtr
->uNumRows
= row
;
1362 if (infoPtr
->dwStyle
& CCS_VERT
)
1363 REBAR_CalcVertBand(infoPtr
, 0, infoPtr
->uNumBands
);
1365 REBAR_CalcHorzBand(infoPtr
, 0, infoPtr
->uNumBands
);
1366 /* now compute size of Rebar itself */
1367 oldSize
= infoPtr
->calcSize
;
1369 infoPtr
->calcSize
.cx
= adjcx
;
1370 infoPtr
->calcSize
.cy
= yPos
;
1371 TRACE("calcsize size=(%d, %d), origheight=(%d,%d)\n",
1372 infoPtr
->calcSize
.cx
, infoPtr
->calcSize
.cy
,
1373 oldSize
.cx
, oldSize
.cy
);
1375 REBAR_DumpBand (infoPtr
);
1376 REBAR_MoveChildWindows (infoPtr
, 0, infoPtr
->uNumBands
);
1377 REBAR_ForceResize (infoPtr
);
1379 /* note: after a RBN_HEIGHTCHANGE native sends once again all the RBN_CHILDSIZE
1380 * and does another ForceResize */
1381 if (oldSize
.cy
!= infoPtr
->calcSize
.cy
)
1384 REBAR_Notify(&heightchange
, infoPtr
, RBN_HEIGHTCHANGE
);
1390 REBAR_ValidateBand (const REBAR_INFO
*infoPtr
, REBAR_BAND
*lpBand
)
1391 /* Function: This routine evaluates the band specs supplied */
1392 /* by the user and updates the following 5 fields in */
1393 /* the internal band structure: cxHeader, lcx, lcy, hcx, hcy*/
1400 lpBand
->fStatus
= 0;
1404 /* Data coming in from users into the cx... and cy... fields */
1405 /* may be bad, just garbage, because the user never clears */
1406 /* the fields. RB_{SET|INSERT}BAND{A|W} just passes the data */
1407 /* along if the fields exist in the input area. Here we must */
1408 /* determine if the data is valid. I have no idea how MS does */
1409 /* the validation, but it does because the RB_GETBANDINFO */
1410 /* returns a 0 when I know the sample program passed in an */
1411 /* address. Here I will use the algorithm that if the value */
1412 /* is greater than 65535 then it is bad and replace it with */
1413 /* a zero. Feel free to improve the algorithm. - GA 12/2000 */
1414 if (lpBand
->cxMinChild
> 65535) lpBand
->cxMinChild
= 0;
1415 if (lpBand
->cyMinChild
> 65535) lpBand
->cyMinChild
= 0;
1416 if (lpBand
->cx
> 65535) lpBand
->cx
= 0;
1417 if (lpBand
->cyChild
> 65535) lpBand
->cyChild
= 0;
1418 if (lpBand
->cyIntegral
> 65535) lpBand
->cyIntegral
= 0;
1419 if (lpBand
->cxIdeal
> 65535) lpBand
->cxIdeal
= 0;
1420 if (lpBand
->cxHeader
> 65535) lpBand
->cxHeader
= 0;
1422 /* TODO : we could try return to the caller if a value changed so that */
1423 /* a REBAR_Layout is needed. Till now the caller should call it */
1424 /* it always (we should also check what native does) */
1426 /* Header is where the image, text and gripper exist */
1427 /* in the band and precede the child window. */
1429 /* count number of non-FIXEDSIZE and non-Hidden bands */
1431 for (i
=0; i
<infoPtr
->uNumBands
; i
++){
1432 tBand
= &infoPtr
->bands
[i
];
1433 if (!HIDDENBAND(tBand
) && !(tBand
->fStyle
& RBBS_FIXEDSIZE
))
1437 /* calculate gripper rectangle */
1438 if ( (!(lpBand
->fStyle
& RBBS_NOGRIPPER
)) &&
1439 ( (lpBand
->fStyle
& RBBS_GRIPPERALWAYS
) ||
1440 ( !(lpBand
->fStyle
& RBBS_FIXEDSIZE
) && (nonfixed
> 1)))
1442 lpBand
->fStatus
|= HAS_GRIPPER
;
1443 if (infoPtr
->dwStyle
& CCS_VERT
)
1444 if (infoPtr
->dwStyle
& RBS_VERTICALGRIPPER
)
1445 header
+= (GRIPPER_HEIGHT
+ REBAR_PRE_GRIPPER
);
1447 header
+= (GRIPPER_WIDTH
+ REBAR_PRE_GRIPPER
);
1449 header
+= (REBAR_PRE_GRIPPER
+ GRIPPER_WIDTH
);
1450 /* Always have 4 pixels before anything else */
1451 header
+= REBAR_ALWAYS_SPACE
;
1454 /* image is visible */
1455 if ((lpBand
->fMask
& RBBIM_IMAGE
) && (infoPtr
->himl
)) {
1456 lpBand
->fStatus
|= HAS_IMAGE
;
1457 if (infoPtr
->dwStyle
& CCS_VERT
) {
1458 header
+= (infoPtr
->imageSize
.cy
+ REBAR_POST_IMAGE
);
1459 lpBand
->lcy
= infoPtr
->imageSize
.cx
+ 2;
1462 header
+= (infoPtr
->imageSize
.cx
+ REBAR_POST_IMAGE
);
1463 lpBand
->lcy
= infoPtr
->imageSize
.cy
+ 2;
1467 /* text is visible */
1468 if ((lpBand
->fMask
& RBBIM_TEXT
) && (lpBand
->lpText
) &&
1469 !(lpBand
->fStyle
& RBBS_HIDETITLE
)) {
1470 HDC hdc
= GetDC (0);
1471 HFONT hOldFont
= SelectObject (hdc
, infoPtr
->hFont
);
1474 lpBand
->fStatus
|= HAS_TEXT
;
1475 GetTextExtentPoint32W (hdc
, lpBand
->lpText
,
1476 lstrlenW (lpBand
->lpText
), &size
);
1477 header
+= ((infoPtr
->dwStyle
& CCS_VERT
) ? (size
.cy
+ REBAR_POST_TEXT
) : (size
.cx
+ REBAR_POST_TEXT
));
1478 textheight
= (infoPtr
->dwStyle
& CCS_VERT
) ? 0 : size
.cy
;
1480 SelectObject (hdc
, hOldFont
);
1484 /* if no gripper but either image or text, then leave space */
1485 if ((lpBand
->fStatus
& (HAS_IMAGE
| HAS_TEXT
)) &&
1486 !(lpBand
->fStatus
& HAS_GRIPPER
)) {
1487 header
+= REBAR_ALWAYS_SPACE
;
1490 /* check if user overrode the header value */
1491 if (!(lpBand
->fStyle
& RBBS_UNDOC_FIXEDHEADER
))
1492 lpBand
->cxHeader
= header
;
1495 /* Now compute minimum size of child window */
1496 lpBand
->lcy
= textheight
;
1497 if (lpBand
->hwndChild
!= NULL
) {
1498 /* Set the .cy values for CHILDSIZE case */
1499 lpBand
->lcy
= max(lpBand
->lcy
, lpBand
->cyChild
+ REBARSPACE(lpBand
));
1500 TRACE("_CHILDSIZE\n");
1503 lpBand
->lcy
= max(lpBand
->lcy
, REBAR_NO_CHILD_HEIGHT
);
1505 lpBand
->lcx
= lpBand
->cxMinChild
+ lpBand
->cxHeader
+ REBAR_POST_CHILD
;
1506 if (lpBand
->fStyle
& RBBS_USECHEVRON
&& lpBand
->cxMinChild
< lpBand
->cxIdeal
)
1507 lpBand
->lcx
+= CHEVRON_WIDTH
;
1511 REBAR_CommonSetupBand(HWND hwnd
, const REBARBANDINFOW
*lprbbi
, REBAR_BAND
*lpBand
)
1512 /* Function: This routine copies the supplied values from */
1513 /* user input (lprbbi) to the internal band structure. */
1514 /* It returns true if something changed and false if not. */
1516 BOOL bChanged
= FALSE
;
1518 lpBand
->fMask
|= lprbbi
->fMask
;
1520 if( (lprbbi
->fMask
& RBBIM_STYLE
) &&
1521 (lpBand
->fStyle
!= lprbbi
->fStyle
) )
1523 lpBand
->fStyle
= lprbbi
->fStyle
;
1527 if( (lprbbi
->fMask
& RBBIM_COLORS
) &&
1528 ( ( lpBand
->clrFore
!= lprbbi
->clrFore
) ||
1529 ( lpBand
->clrBack
!= lprbbi
->clrBack
) ) )
1531 lpBand
->clrFore
= lprbbi
->clrFore
;
1532 lpBand
->clrBack
= lprbbi
->clrBack
;
1536 if( (lprbbi
->fMask
& RBBIM_IMAGE
) &&
1537 ( lpBand
->iImage
!= lprbbi
->iImage
) )
1539 lpBand
->iImage
= lprbbi
->iImage
;
1543 if( (lprbbi
->fMask
& RBBIM_CHILD
) &&
1544 (lprbbi
->hwndChild
!= lpBand
->hwndChild
) )
1546 if (lprbbi
->hwndChild
) {
1547 lpBand
->hwndChild
= lprbbi
->hwndChild
;
1548 lpBand
->hwndPrevParent
=
1549 SetParent (lpBand
->hwndChild
, hwnd
);
1550 /* below in trace from WinRAR */
1551 ShowWindow(lpBand
->hwndChild
, SW_SHOWNOACTIVATE
| SW_SHOWNORMAL
);
1552 /* above in trace from WinRAR */
1555 TRACE("child: %p prev parent: %p\n",
1556 lpBand
->hwndChild
, lpBand
->hwndPrevParent
);
1557 lpBand
->hwndChild
= 0;
1558 lpBand
->hwndPrevParent
= 0;
1563 if( (lprbbi
->fMask
& RBBIM_CHILDSIZE
) &&
1564 ( (lpBand
->cxMinChild
!= lprbbi
->cxMinChild
) ||
1565 (lpBand
->cyMinChild
!= lprbbi
->cyMinChild
) ||
1566 ( (lprbbi
->cbSize
>= sizeof (REBARBANDINFOA
)) &&
1567 ( (lpBand
->cyChild
!= lprbbi
->cyChild
) ||
1568 (lpBand
->cyMaxChild
!= lprbbi
->cyMaxChild
) ||
1569 (lpBand
->cyIntegral
!= lprbbi
->cyIntegral
) ) ) ||
1570 ( (lprbbi
->cbSize
< sizeof (REBARBANDINFOA
)) &&
1571 ( (lpBand
->cyChild
||
1572 lpBand
->cyMaxChild
||
1573 lpBand
->cyIntegral
) ) ) ) )
1575 lpBand
->cxMinChild
= lprbbi
->cxMinChild
;
1576 lpBand
->cyMinChild
= lprbbi
->cyMinChild
;
1577 /* These fields where added in WIN32_IE == 0x400 and are set only for RBBS_VARIABLEHEIGHT bands */
1578 if (lprbbi
->cbSize
>= sizeof (REBARBANDINFOA
) && (lpBand
->fStyle
& RBBS_VARIABLEHEIGHT
)) {
1579 lpBand
->cyMaxChild
= lprbbi
->cyMaxChild
;
1580 lpBand
->cyIntegral
= lprbbi
->cyIntegral
;
1582 lpBand
->cyChild
= lpBand
->cyMinChild
;
1583 round_child_height(lpBand
, lprbbi
->cyChild
); /* try to increase cyChild */
1586 lpBand
->cyChild
= lpBand
->cyMinChild
;
1587 lpBand
->cyMaxChild
= 0x7fffffff;
1588 lpBand
->cyIntegral
= 0;
1593 if( (lprbbi
->fMask
& RBBIM_SIZE
) &&
1594 (lpBand
->cx
!= lprbbi
->cx
) )
1596 lpBand
->cx
= lprbbi
->cx
;
1600 if( (lprbbi
->fMask
& RBBIM_BACKGROUND
) &&
1601 ( lpBand
->hbmBack
!= lprbbi
->hbmBack
) )
1603 lpBand
->hbmBack
= lprbbi
->hbmBack
;
1607 if( (lprbbi
->fMask
& RBBIM_ID
) &&
1608 (lpBand
->wID
!= lprbbi
->wID
) )
1610 lpBand
->wID
= lprbbi
->wID
;
1614 /* check for additional data */
1615 if (lprbbi
->cbSize
>= sizeof (REBARBANDINFOA
)) {
1616 if( (lprbbi
->fMask
& RBBIM_IDEALSIZE
) &&
1617 ( lpBand
->cxIdeal
!= lprbbi
->cxIdeal
) )
1619 lpBand
->cxIdeal
= lprbbi
->cxIdeal
;
1623 if( (lprbbi
->fMask
& RBBIM_LPARAM
) &&
1624 (lpBand
->lParam
!= lprbbi
->lParam
) )
1626 lpBand
->lParam
= lprbbi
->lParam
;
1630 if( (lprbbi
->fMask
& RBBIM_HEADERSIZE
) &&
1631 (lpBand
->cxHeader
!= lprbbi
->cxHeader
) )
1633 lpBand
->cxHeader
= lprbbi
->cxHeader
;
1634 lpBand
->fStyle
|= RBBS_UNDOC_FIXEDHEADER
;
1643 REBAR_InternalEraseBkGnd (const REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
, const RECT
*clip
)
1644 /* Function: This erases the background rectangle by drawing */
1645 /* each band with its background color (or the default) and */
1646 /* draws each bands right separator if necessary. The row */
1647 /* separators are drawn on the first band of the next row. */
1652 HDC hdc
= (HDC
)wParam
;
1654 COLORREF old
= CLR_NONE
, new;
1655 HTHEME theme
= GetWindowTheme (infoPtr
->hwndSelf
);
1657 GetClientRect (infoPtr
->hwndSelf
, &cr
);
1660 for(i
=0; i
<infoPtr
->uNumBands
; i
++) {
1662 lpBand
= &infoPtr
->bands
[i
];
1663 if (HIDDENBAND(lpBand
)) continue;
1664 translate_rect(infoPtr
, &rcBand
, &lpBand
->rcBand
);
1666 /* draw band separator between rows */
1667 if (lpBand
->iRow
!= oldrow
) {
1668 oldrow
= lpBand
->iRow
;
1669 if (infoPtr
->dwStyle
& RBS_BANDBORDERS
) {
1672 if (infoPtr
->dwStyle
& CCS_VERT
) {
1673 rcRowSep
.right
+= SEP_WIDTH_SIZE
;
1674 rcRowSep
.bottom
= infoPtr
->calcSize
.cx
;
1676 DrawThemeEdge (theme
, hdc
, RP_BAND
, 0, &rcRowSep
, EDGE_ETCHED
, BF_RIGHT
, NULL
);
1678 DrawEdge (hdc
, &rcRowSep
, EDGE_ETCHED
, BF_RIGHT
);
1681 rcRowSep
.bottom
+= SEP_WIDTH_SIZE
;
1682 rcRowSep
.right
= infoPtr
->calcSize
.cx
;
1684 DrawThemeEdge (theme
, hdc
, RP_BAND
, 0, &rcRowSep
, EDGE_ETCHED
, BF_BOTTOM
, NULL
);
1686 DrawEdge (hdc
, &rcRowSep
, EDGE_ETCHED
, BF_BOTTOM
);
1688 TRACE ("drawing band separator bottom (%d,%d)-(%d,%d)\n",
1689 rcRowSep
.left
, rcRowSep
.top
,
1690 rcRowSep
.right
, rcRowSep
.bottom
);
1694 /* draw band separator between bands in a row */
1695 if (infoPtr
->dwStyle
& RBS_BANDBORDERS
&& lpBand
->rcBand
.left
> 0) {
1698 if (infoPtr
->dwStyle
& CCS_VERT
) {
1699 rcSep
.bottom
= rcSep
.top
;
1700 rcSep
.top
-= SEP_WIDTH_SIZE
;
1702 DrawThemeEdge (theme
, hdc
, RP_BAND
, 0, &rcSep
, EDGE_ETCHED
, BF_BOTTOM
, NULL
);
1704 DrawEdge (hdc
, &rcSep
, EDGE_ETCHED
, BF_BOTTOM
);
1707 rcSep
.right
= rcSep
.left
;
1708 rcSep
.left
-= SEP_WIDTH_SIZE
;
1710 DrawThemeEdge (theme
, hdc
, RP_BAND
, 0, &rcSep
, EDGE_ETCHED
, BF_RIGHT
, NULL
);
1712 DrawEdge (hdc
, &rcSep
, EDGE_ETCHED
, BF_RIGHT
);
1714 TRACE("drawing band separator right (%d,%d)-(%d,%d)\n",
1715 rcSep
.left
, rcSep
.top
, rcSep
.right
, rcSep
.bottom
);
1718 /* draw the actual background */
1719 if (lpBand
->clrBack
!= CLR_NONE
) {
1720 new = (lpBand
->clrBack
== CLR_DEFAULT
) ? infoPtr
->clrBtnFace
:
1723 /* testing only - make background green to see it */
1728 /* In the absence of documentation for Rebar vs. CLR_NONE,
1729 * we will use the default BtnFace color. Note documentation
1730 * exists for Listview and Imagelist.
1732 new = infoPtr
->clrBtnFace
;
1734 /* testing only - make background green to see it */
1741 /* When themed, the background color is ignored (but not a
1742 * background bitmap */
1743 DrawThemeBackground (theme
, hdc
, 0, 0, &cr
, &rcBand
);
1747 old
= SetBkColor (hdc
, new);
1748 TRACE("%s background color=0x%06x, band (%d,%d)-(%d,%d), clip (%d,%d)-(%d,%d)\n",
1749 (lpBand
->clrBack
== CLR_NONE
) ? "none" :
1750 ((lpBand
->clrBack
== CLR_DEFAULT
) ? "dft" : ""),
1752 rcBand
.left
,rcBand
.top
,
1753 rcBand
.right
,rcBand
.bottom
,
1754 clip
->left
, clip
->top
,
1755 clip
->right
, clip
->bottom
);
1756 ExtTextOutW (hdc
, 0, 0, ETO_OPAQUE
, &rcBand
, NULL
, 0, 0);
1757 if (lpBand
->clrBack
!= CLR_NONE
)
1758 SetBkColor (hdc
, old
);
1765 REBAR_InternalHitTest (const REBAR_INFO
*infoPtr
, const POINT
*lpPt
, UINT
*pFlags
, INT
*pBand
)
1771 GetClientRect (infoPtr
->hwndSelf
, &rect
);
1773 *pFlags
= RBHT_NOWHERE
;
1774 if (PtInRect (&rect
, *lpPt
))
1776 if (infoPtr
->uNumBands
== 0) {
1777 *pFlags
= RBHT_NOWHERE
;
1784 /* somewhere inside */
1785 for (iCount
= 0; iCount
< infoPtr
->uNumBands
; iCount
++) {
1787 lpBand
= &infoPtr
->bands
[iCount
];
1788 translate_rect(infoPtr
, &rcBand
, &lpBand
->rcBand
);
1789 if (HIDDENBAND(lpBand
)) continue;
1790 if (PtInRect (&rcBand
, *lpPt
)) {
1793 if (PtInRect (&lpBand
->rcGripper
, *lpPt
)) {
1794 *pFlags
= RBHT_GRABBER
;
1795 TRACE("ON GRABBER %d\n", iCount
);
1798 else if (PtInRect (&lpBand
->rcCapImage
, *lpPt
)) {
1799 *pFlags
= RBHT_CAPTION
;
1800 TRACE("ON CAPTION %d\n", iCount
);
1803 else if (PtInRect (&lpBand
->rcCapText
, *lpPt
)) {
1804 *pFlags
= RBHT_CAPTION
;
1805 TRACE("ON CAPTION %d\n", iCount
);
1808 else if (PtInRect (&lpBand
->rcChild
, *lpPt
)) {
1809 *pFlags
= RBHT_CLIENT
;
1810 TRACE("ON CLIENT %d\n", iCount
);
1813 else if (PtInRect (&lpBand
->rcChevron
, *lpPt
)) {
1814 *pFlags
= RBHT_CHEVRON
;
1815 TRACE("ON CHEVRON %d\n", iCount
);
1819 *pFlags
= RBHT_NOWHERE
;
1820 TRACE("NOWHERE %d\n", iCount
);
1826 *pFlags
= RBHT_NOWHERE
;
1835 *pFlags
= RBHT_NOWHERE
;
1844 REBAR_HandleLRDrag (REBAR_INFO
*infoPtr
, const POINT
*ptsmove
)
1845 /* Function: This will implement the functionality of a */
1846 /* Gripper drag within a row. It will not implement "out- */
1847 /* of-row" drags. (They are detected and handled in */
1848 /* REBAR_MouseMove.) */
1849 /* **** FIXME Switching order of bands in a row not **** */
1850 /* **** yet implemented. **** */
1852 REBAR_BAND
*hitBand
;
1853 INT iHitBand
, iRowBegin
, iRowEnd
;
1854 INT movement
, xBand
;
1856 /* on first significant mouse movement, issue notify */
1857 if (!(infoPtr
->fStatus
& BEGIN_DRAG_ISSUED
)) {
1858 if (REBAR_Notify_NMREBAR (infoPtr
, -1, RBN_BEGINDRAG
)) {
1859 /* Notify returned TRUE - abort drag */
1860 infoPtr
->dragStart
.x
= 0;
1861 infoPtr
->dragStart
.y
= 0;
1862 infoPtr
->dragNow
= infoPtr
->dragStart
;
1863 infoPtr
->iGrabbedBand
= -1;
1867 infoPtr
->fStatus
|= BEGIN_DRAG_ISSUED
;
1870 iHitBand
= infoPtr
->iGrabbedBand
;
1871 iRowBegin
= get_row_begin_for_band(infoPtr
, iHitBand
);
1872 iRowEnd
= get_row_end_for_band(infoPtr
, iHitBand
);
1873 hitBand
= &infoPtr
->bands
[iHitBand
];
1875 xBand
= hitBand
->rcBand
.left
;
1876 movement
= (infoPtr
->dwStyle
&CCS_VERT
? ptsmove
->y
: ptsmove
->x
)
1877 - (xBand
+ REBAR_PRE_GRIPPER
- infoPtr
->ihitoffset
);
1880 int cxLeft
= REBAR_ShrinkBandsRTL(infoPtr
, iRowBegin
, iHitBand
, -movement
, TRUE
);
1881 hitBand
->cxEffective
+= -movement
- cxLeft
;
1882 hitBand
->cx
= hitBand
->cxEffective
;
1883 } else if (movement
> 0) {
1884 int cxLeft
= REBAR_ShrinkBandsLTR(infoPtr
, iHitBand
, iRowEnd
, movement
, TRUE
);
1885 REBAR_BAND
*lpPrev
= &infoPtr
->bands
[prev_band(infoPtr
, iHitBand
)];
1886 lpPrev
->cxEffective
+= movement
- cxLeft
;
1887 lpPrev
->cx
= lpPrev
->cxEffective
;
1890 REBAR_SetRowRectsX(infoPtr
, iRowBegin
, iRowEnd
);
1891 if (infoPtr
->dwStyle
& CCS_VERT
)
1892 REBAR_CalcVertBand(infoPtr
, 0, infoPtr
->uNumBands
);
1894 REBAR_CalcHorzBand(infoPtr
, 0, infoPtr
->uNumBands
);
1895 REBAR_MoveChildWindows(infoPtr
, iRowBegin
, iRowEnd
);
1900 /* << REBAR_BeginDrag >> */
1904 REBAR_DeleteBand (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
1906 UINT uBand
= (UINT
)wParam
;
1909 if (uBand
>= infoPtr
->uNumBands
)
1912 TRACE("deleting band %u!\n", uBand
);
1913 lpBand
= &infoPtr
->bands
[uBand
];
1914 REBAR_Notify_NMREBAR (infoPtr
, uBand
, RBN_DELETINGBAND
);
1915 /* TODO: a return of 1 should probably cancel the deletion */
1917 if (lpBand
->hwndChild
)
1918 ShowWindow(lpBand
->hwndChild
, SW_HIDE
);
1919 Free(lpBand
->lpText
);
1921 infoPtr
->uNumBands
--;
1922 memmove(&infoPtr
->bands
[uBand
], &infoPtr
->bands
[uBand
+1],
1923 (infoPtr
->uNumBands
- uBand
) * sizeof(REBAR_BAND
));
1924 infoPtr
->bands
= ReAlloc(infoPtr
->bands
, infoPtr
->uNumBands
* sizeof(REBAR_BAND
));
1926 REBAR_Notify_NMREBAR (infoPtr
, -1, RBN_DELETEDBAND
);
1928 /* if only 1 band left the re-validate to possible eliminate gripper */
1929 if (infoPtr
->uNumBands
== 1)
1930 REBAR_ValidateBand (infoPtr
, &infoPtr
->bands
[0]);
1932 REBAR_Layout(infoPtr
, NULL
);
1938 /* << REBAR_DragMove >> */
1939 /* << REBAR_EndDrag >> */
1943 REBAR_GetBandBorders (const REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
1945 LPRECT lpRect
= (LPRECT
)lParam
;
1950 if ((UINT
)wParam
>= infoPtr
->uNumBands
)
1953 lpBand
= &infoPtr
->bands
[(UINT
)wParam
];
1955 /* FIXME - the following values were determined by experimentation */
1956 /* with the REBAR Control Spy. I have guesses as to what the 4 and */
1957 /* 1 are, but I am not sure. There doesn't seem to be any actual */
1958 /* difference in size of the control area with and without the */
1960 if (infoPtr
->dwStyle
& RBS_BANDBORDERS
) {
1961 if (infoPtr
->dwStyle
& CCS_VERT
) {
1963 lpRect
->top
= lpBand
->cxHeader
+ 4;
1968 lpRect
->left
= lpBand
->cxHeader
+ 4;
1975 lpRect
->left
= lpBand
->cxHeader
;
1981 static inline LRESULT
1982 REBAR_GetBandCount (const REBAR_INFO
*infoPtr
)
1984 TRACE("band count %u!\n", infoPtr
->uNumBands
);
1986 return infoPtr
->uNumBands
;
1991 REBAR_GetBandInfoT(const REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
, BOOL bUnicode
)
1993 LPREBARBANDINFOW lprbbi
= (LPREBARBANDINFOW
)lParam
;
1998 if (lprbbi
->cbSize
< REBARBANDINFOA_V3_SIZE
)
2000 if ((UINT
)wParam
>= infoPtr
->uNumBands
)
2003 TRACE("index %u (bUnicode=%d)\n", (UINT
)wParam
, bUnicode
);
2005 /* copy band information */
2006 lpBand
= &infoPtr
->bands
[(UINT
)wParam
];
2008 if (lprbbi
->fMask
& RBBIM_STYLE
)
2009 lprbbi
->fStyle
= lpBand
->fStyle
;
2011 if (lprbbi
->fMask
& RBBIM_COLORS
) {
2012 lprbbi
->clrFore
= lpBand
->clrFore
;
2013 lprbbi
->clrBack
= lpBand
->clrBack
;
2014 if (lprbbi
->clrBack
== CLR_DEFAULT
)
2015 lprbbi
->clrBack
= infoPtr
->clrBtnFace
;
2018 if (lprbbi
->fMask
& RBBIM_TEXT
) {
2020 Str_GetPtrW(lpBand
->lpText
, lprbbi
->lpText
, lprbbi
->cch
);
2022 Str_GetPtrWtoA(lpBand
->lpText
, (LPSTR
)lprbbi
->lpText
, lprbbi
->cch
);
2025 if (lprbbi
->fMask
& RBBIM_IMAGE
)
2026 lprbbi
->iImage
= lpBand
->iImage
;
2028 if (lprbbi
->fMask
& RBBIM_CHILD
)
2029 lprbbi
->hwndChild
= lpBand
->hwndChild
;
2031 if (lprbbi
->fMask
& RBBIM_CHILDSIZE
) {
2032 lprbbi
->cxMinChild
= lpBand
->cxMinChild
;
2033 lprbbi
->cyMinChild
= lpBand
->cyMinChild
;
2034 /* to make tests pass we follow Windows behaviour and allow to read these fields only
2035 * for RBBS_VARIABLEHEIGHTS bands */
2036 if (lprbbi
->cbSize
>= sizeof (REBARBANDINFOA
) && (lpBand
->fStyle
& RBBS_VARIABLEHEIGHT
)) {
2037 lprbbi
->cyChild
= lpBand
->cyChild
;
2038 lprbbi
->cyMaxChild
= lpBand
->cyMaxChild
;
2039 lprbbi
->cyIntegral
= lpBand
->cyIntegral
;
2043 if (lprbbi
->fMask
& RBBIM_SIZE
)
2044 lprbbi
->cx
= lpBand
->cx
;
2046 if (lprbbi
->fMask
& RBBIM_BACKGROUND
)
2047 lprbbi
->hbmBack
= lpBand
->hbmBack
;
2049 if (lprbbi
->fMask
& RBBIM_ID
)
2050 lprbbi
->wID
= lpBand
->wID
;
2052 /* check for additional data */
2053 if (lprbbi
->cbSize
>= sizeof (REBARBANDINFOA
)) {
2054 if (lprbbi
->fMask
& RBBIM_IDEALSIZE
)
2055 lprbbi
->cxIdeal
= lpBand
->cxIdeal
;
2057 if (lprbbi
->fMask
& RBBIM_LPARAM
)
2058 lprbbi
->lParam
= lpBand
->lParam
;
2060 if (lprbbi
->fMask
& RBBIM_HEADERSIZE
)
2061 lprbbi
->cxHeader
= lpBand
->cxHeader
;
2064 REBAR_DumpBandInfo(lprbbi
);
2071 REBAR_GetBarHeight (const REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
2075 nHeight
= infoPtr
->calcSize
.cy
;
2077 TRACE("height = %d\n", nHeight
);
2084 REBAR_GetBarInfo (const REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
2086 LPREBARINFO lpInfo
= (LPREBARINFO
)lParam
;
2091 if (lpInfo
->cbSize
< sizeof (REBARINFO
))
2094 TRACE("getting bar info!\n");
2096 if (infoPtr
->himl
) {
2097 lpInfo
->himl
= infoPtr
->himl
;
2098 lpInfo
->fMask
|= RBIM_IMAGELIST
;
2105 static inline LRESULT
2106 REBAR_GetBkColor (const REBAR_INFO
*infoPtr
)
2108 COLORREF clr
= infoPtr
->clrBk
;
2110 if (clr
== CLR_DEFAULT
)
2111 clr
= infoPtr
->clrBtnFace
;
2113 TRACE("background color 0x%06x!\n", clr
);
2119 /* << REBAR_GetColorScheme >> */
2120 /* << REBAR_GetDropTarget >> */
2124 REBAR_GetPalette (const REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
2126 FIXME("empty stub!\n");
2133 REBAR_GetRect (const REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
2135 INT iBand
= (INT
)wParam
;
2136 LPRECT lprc
= (LPRECT
)lParam
;
2139 if ((iBand
< 0) || ((UINT
)iBand
>= infoPtr
->uNumBands
))
2144 lpBand
= &infoPtr
->bands
[iBand
];
2145 /* For CCS_VERT the coordintes will be swapped - like on Windows */
2146 CopyRect (lprc
, &lpBand
->rcBand
);
2148 TRACE("band %d, (%d,%d)-(%d,%d)\n", iBand
,
2149 lprc
->left
, lprc
->top
, lprc
->right
, lprc
->bottom
);
2155 static inline LRESULT
2156 REBAR_GetRowCount (const REBAR_INFO
*infoPtr
)
2158 TRACE("%u\n", infoPtr
->uNumRows
);
2160 return infoPtr
->uNumRows
;
2165 REBAR_GetRowHeight (const REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
2167 INT iRow
= (INT
)wParam
;
2172 for (i
=0; i
<infoPtr
->uNumBands
; i
++) {
2173 lpBand
= &infoPtr
->bands
[i
];
2174 if (HIDDENBAND(lpBand
)) continue;
2175 if (lpBand
->iRow
!= iRow
) continue;
2176 j
= lpBand
->rcBand
.bottom
- lpBand
->rcBand
.top
;
2177 if (j
> ret
) ret
= j
;
2180 TRACE("row %d, height %d\n", iRow
, ret
);
2186 static inline LRESULT
2187 REBAR_GetTextColor (const REBAR_INFO
*infoPtr
)
2189 TRACE("text color 0x%06x!\n", infoPtr
->clrText
);
2191 return infoPtr
->clrText
;
2195 static inline LRESULT
2196 REBAR_GetToolTips (const REBAR_INFO
*infoPtr
)
2198 return (LRESULT
)infoPtr
->hwndToolTip
;
2202 static inline LRESULT
2203 REBAR_GetUnicodeFormat (const REBAR_INFO
*infoPtr
)
2205 TRACE("%s hwnd=%p\n",
2206 infoPtr
->bUnicode
? "TRUE" : "FALSE", infoPtr
->hwndSelf
);
2208 return infoPtr
->bUnicode
;
2212 static inline LRESULT
2213 REBAR_GetVersion (const REBAR_INFO
*infoPtr
)
2215 TRACE("version %d\n", infoPtr
->iVersion
);
2216 return infoPtr
->iVersion
;
2221 REBAR_HitTest (const REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
2223 LPRBHITTESTINFO lprbht
= (LPRBHITTESTINFO
)lParam
;
2228 REBAR_InternalHitTest (infoPtr
, &lprbht
->pt
, &lprbht
->flags
, &lprbht
->iBand
);
2230 return lprbht
->iBand
;
2235 REBAR_IdToIndex (const REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
2239 if (infoPtr
== NULL
)
2242 if (infoPtr
->uNumBands
< 1)
2245 for (i
= 0; i
< infoPtr
->uNumBands
; i
++) {
2246 if (infoPtr
->bands
[i
].wID
== (UINT
)wParam
) {
2247 TRACE("id %u is band %u found!\n", (UINT
)wParam
, i
);
2252 TRACE("id %u is not found\n", (UINT
)wParam
);
2258 REBAR_InsertBandT(REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
, BOOL bUnicode
)
2260 LPREBARBANDINFOW lprbbi
= (LPREBARBANDINFOW
)lParam
;
2261 UINT uIndex
= (UINT
)wParam
;
2264 if (infoPtr
== NULL
)
2268 if (lprbbi
->cbSize
< REBARBANDINFOA_V3_SIZE
)
2271 /* trace the index as signed to see the -1 */
2272 TRACE("insert band at %d (bUnicode=%d)!\n", (INT
)uIndex
, bUnicode
);
2273 REBAR_DumpBandInfo(lprbbi
);
2275 infoPtr
->bands
= ReAlloc(infoPtr
->bands
, (infoPtr
->uNumBands
+1) * sizeof(REBAR_BAND
));
2276 if (((INT
)uIndex
== -1) || (uIndex
> infoPtr
->uNumBands
))
2277 uIndex
= infoPtr
->uNumBands
;
2278 memmove(&infoPtr
->bands
[uIndex
+1], &infoPtr
->bands
[uIndex
],
2279 sizeof(REBAR_BAND
) * (infoPtr
->uNumBands
- uIndex
));
2280 infoPtr
->uNumBands
++;
2282 TRACE("index %u!\n", uIndex
);
2284 /* initialize band (infoPtr->bands[uIndex])*/
2285 lpBand
= &infoPtr
->bands
[uIndex
];
2286 ZeroMemory(lpBand
, sizeof(*lpBand
));
2287 lpBand
->clrFore
= infoPtr
->clrText
;
2288 lpBand
->clrBack
= infoPtr
->clrBk
;
2289 lpBand
->iImage
= -1;
2291 REBAR_CommonSetupBand(infoPtr
->hwndSelf
, lprbbi
, lpBand
);
2292 if ((lprbbi
->fMask
& RBBIM_TEXT
) && (lprbbi
->lpText
)) {
2294 Str_SetPtrW(&lpBand
->lpText
, lprbbi
->lpText
);
2296 Str_SetPtrAtoW(&lpBand
->lpText
, (LPSTR
)lprbbi
->lpText
);
2299 REBAR_ValidateBand (infoPtr
, lpBand
);
2300 /* On insert of second band, revalidate band 1 to possible add gripper */
2301 if (infoPtr
->uNumBands
== 2)
2302 REBAR_ValidateBand (infoPtr
, &infoPtr
->bands
[0]);
2304 REBAR_DumpBand (infoPtr
);
2306 REBAR_Layout(infoPtr
, NULL
);
2307 InvalidateRect(infoPtr
->hwndSelf
, 0, TRUE
);
2314 REBAR_MaximizeBand (const REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
2317 UINT uBand
= (UINT
) wParam
;
2318 int iRowBegin
, iRowEnd
;
2319 int cxDesired
, extra
, extraOrig
;
2323 if ((infoPtr
->uNumBands
== 0) ||
2324 ((INT
)uBand
< 0) || (uBand
>= infoPtr
->uNumBands
)) {
2326 ERR("Illegal MaximizeBand, requested=%d, current band count=%d\n",
2327 (INT
)uBand
, infoPtr
->uNumBands
);
2331 lpBand
= &infoPtr
->bands
[uBand
];
2333 cxIdealBand
= lpBand
->cxIdeal
+ lpBand
->cxHeader
+ REBAR_POST_CHILD
;
2334 if (lParam
&& (lpBand
->cxEffective
< cxIdealBand
))
2335 cxDesired
= cxIdealBand
;
2337 cxDesired
= infoPtr
->calcSize
.cx
;
2339 iRowBegin
= get_row_begin_for_band(infoPtr
, uBand
);
2340 iRowEnd
= get_row_end_for_band(infoPtr
, uBand
);
2341 extraOrig
= extra
= cxDesired
- lpBand
->cxEffective
;
2343 extra
= REBAR_ShrinkBandsRTL(infoPtr
, iRowBegin
, uBand
, extra
, TRUE
);
2345 extra
= REBAR_ShrinkBandsLTR(infoPtr
, next_band(infoPtr
, uBand
), iRowEnd
, extra
, TRUE
);
2346 lpBand
->cxEffective
+= extraOrig
- extra
;
2347 lpBand
->cx
= lpBand
->cxEffective
;
2348 TRACE("(%ld, %ld): Wanted size %d, obtained %d (shrink %d, %d)\n", wParam
, lParam
, cxDesired
, lpBand
->cx
, extraOrig
, extra
);
2349 REBAR_SetRowRectsX(infoPtr
, iRowBegin
, iRowEnd
);
2351 if (infoPtr
->dwStyle
& CCS_VERT
)
2352 REBAR_CalcVertBand(infoPtr
, iRowBegin
, iRowEnd
);
2354 REBAR_CalcHorzBand(infoPtr
, iRowBegin
, iRowEnd
);
2355 REBAR_MoveChildWindows(infoPtr
, iRowBegin
, iRowEnd
);
2362 REBAR_MinimizeBand (const REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
2365 UINT uBand
= (UINT
) wParam
;
2366 int iPrev
, iRowBegin
, iRowEnd
;
2368 /* A "minimize" band is equivalent to "dragging" the gripper
2369 * of than band to the right till the band is only the size
2374 if ((infoPtr
->uNumBands
== 0) ||
2375 ((INT
)uBand
< 0) || (uBand
>= infoPtr
->uNumBands
)) {
2377 ERR("Illegal MinimizeBand, requested=%d, current band count=%d\n",
2378 (INT
)uBand
, infoPtr
->uNumBands
);
2382 /* compute amount of movement and validate */
2383 lpBand
= &infoPtr
->bands
[uBand
];
2384 iPrev
= prev_band(infoPtr
, uBand
);
2385 /* if first band in row */
2386 if (iPrev
< 0 || infoPtr
->bands
[iPrev
].iRow
!= lpBand
->iRow
) {
2387 int iNext
= next_band(infoPtr
, uBand
);
2388 if (iNext
< infoPtr
->uNumBands
&& infoPtr
->bands
[iNext
].iRow
== lpBand
->iRow
) {
2389 TRACE("(%ld): Minimizing the first band in row is by maximizing the second\n", wParam
);
2390 REBAR_MaximizeBand(infoPtr
, iNext
, FALSE
);
2393 TRACE("(%ld): Only one band in row - nothing to do\n", wParam
);
2397 infoPtr
->bands
[iPrev
].cxEffective
+= lpBand
->cxEffective
- lpBand
->lcx
;
2398 infoPtr
->bands
[iPrev
].cx
= infoPtr
->bands
[iPrev
].cxEffective
;
2399 lpBand
->cx
= lpBand
->cxEffective
= lpBand
->lcx
;
2401 iRowBegin
= get_row_begin_for_band(infoPtr
, uBand
);
2402 iRowEnd
= get_row_end_for_band(infoPtr
, uBand
);
2403 REBAR_SetRowRectsX(infoPtr
, iRowBegin
, iRowEnd
);
2405 if (infoPtr
->dwStyle
& CCS_VERT
)
2406 REBAR_CalcVertBand(infoPtr
, iRowBegin
, iRowEnd
);
2408 REBAR_CalcHorzBand(infoPtr
, iRowBegin
, iRowEnd
);
2409 REBAR_MoveChildWindows(infoPtr
, iRowBegin
, iRowEnd
);
2415 REBAR_MoveBand (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
2417 REBAR_BAND
*oldBands
= infoPtr
->bands
;
2419 UINT uFrom
= (UINT
)wParam
;
2420 UINT uTo
= (UINT
)lParam
;
2423 if ((infoPtr
->uNumBands
== 0) ||
2424 ((INT
)uFrom
< 0) || (uFrom
>= infoPtr
->uNumBands
) ||
2425 ((INT
)uTo
< 0) || (uTo
>= infoPtr
->uNumBands
)) {
2427 ERR("Illegal MoveBand, from=%d, to=%d, current band count=%d\n",
2428 (INT
)uFrom
, (INT
)uTo
, infoPtr
->uNumBands
);
2432 /* save one to be moved */
2433 memcpy (&holder
, &oldBands
[uFrom
], sizeof(REBAR_BAND
));
2435 /* close up rest of bands (pseudo delete) */
2436 if (uFrom
< infoPtr
->uNumBands
- 1) {
2437 memcpy (&oldBands
[uFrom
], &oldBands
[uFrom
+1],
2438 (infoPtr
->uNumBands
- uFrom
- 1) * sizeof(REBAR_BAND
));
2441 /* allocate new space and copy rest of bands into it */
2443 (REBAR_BAND
*)Alloc ((infoPtr
->uNumBands
)*sizeof(REBAR_BAND
));
2445 /* pre insert copy */
2447 memcpy (&infoPtr
->bands
[0], &oldBands
[0],
2448 uTo
* sizeof(REBAR_BAND
));
2451 /* set moved band */
2452 memcpy (&infoPtr
->bands
[uTo
], &holder
, sizeof(REBAR_BAND
));
2455 if (uTo
< infoPtr
->uNumBands
- 1) {
2456 memcpy (&infoPtr
->bands
[uTo
+1], &oldBands
[uTo
],
2457 (infoPtr
->uNumBands
- uTo
- 1) * sizeof(REBAR_BAND
));
2462 TRACE("moved band %d to index %d\n", uFrom
, uTo
);
2463 REBAR_DumpBand (infoPtr
);
2465 /* **************************************************** */
2467 /* We do not do a REBAR_Layout here because the native */
2468 /* control does not do that. The actual layout and */
2469 /* repaint is done by the *next* real action, ex.: */
2470 /* RB_INSERTBAND, RB_DELETEBAND, RB_SIZETORECT, etc. */
2472 /* **************************************************** */
2478 /* return TRUE if two strings are different */
2480 REBAR_strdifW( LPCWSTR a
, LPCWSTR b
)
2482 return ( (a
&& !b
) || (b
&& !a
) || (a
&& b
&& lstrcmpW(a
, b
) ) );
2486 REBAR_SetBandInfoT(REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
, BOOL bUnicode
)
2488 LPREBARBANDINFOW lprbbi
= (LPREBARBANDINFOW
)lParam
;
2494 if (lprbbi
->cbSize
< REBARBANDINFOA_V3_SIZE
)
2496 if ((UINT
)wParam
>= infoPtr
->uNumBands
)
2499 TRACE("index %u\n", (UINT
)wParam
);
2500 REBAR_DumpBandInfo (lprbbi
);
2502 /* set band information */
2503 lpBand
= &infoPtr
->bands
[(UINT
)wParam
];
2505 bChanged
= REBAR_CommonSetupBand (infoPtr
->hwndSelf
, lprbbi
, lpBand
);
2506 if (lprbbi
->fMask
& RBBIM_TEXT
) {
2509 Str_SetPtrW(&wstr
, lprbbi
->lpText
);
2511 Str_SetPtrAtoW(&wstr
, (LPSTR
)lprbbi
->lpText
);
2513 if (REBAR_strdifW(wstr
, lprbbi
->lpText
)) {
2514 Free(lpBand
->lpText
);
2515 lpBand
->lpText
= wstr
;
2522 REBAR_ValidateBand (infoPtr
, lpBand
);
2524 REBAR_DumpBand (infoPtr
);
2526 if (bChanged
&& (lprbbi
->fMask
& (RBBIM_CHILDSIZE
| RBBIM_SIZE
| RBBIM_STYLE
))) {
2527 REBAR_Layout(infoPtr
, NULL
);
2528 InvalidateRect(infoPtr
->hwndSelf
, 0, 1);
2536 REBAR_SetBarInfo (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
2538 LPREBARINFO lpInfo
= (LPREBARINFO
)lParam
;
2545 if (lpInfo
->cbSize
< sizeof (REBARINFO
))
2548 TRACE("setting bar info!\n");
2550 if (lpInfo
->fMask
& RBIM_IMAGELIST
) {
2551 infoPtr
->himl
= lpInfo
->himl
;
2552 if (infoPtr
->himl
) {
2554 ImageList_GetIconSize (infoPtr
->himl
, &cx
, &cy
);
2555 infoPtr
->imageSize
.cx
= cx
;
2556 infoPtr
->imageSize
.cy
= cy
;
2559 infoPtr
->imageSize
.cx
= 0;
2560 infoPtr
->imageSize
.cy
= 0;
2562 TRACE("new image cx=%d, cy=%d\n", infoPtr
->imageSize
.cx
,
2563 infoPtr
->imageSize
.cy
);
2566 /* revalidate all bands to reset flags for images in headers of bands */
2567 for (i
=0; i
<infoPtr
->uNumBands
; i
++) {
2568 lpBand
= &infoPtr
->bands
[i
];
2569 REBAR_ValidateBand (infoPtr
, lpBand
);
2577 REBAR_SetBkColor (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
2581 clrTemp
= infoPtr
->clrBk
;
2582 infoPtr
->clrBk
= (COLORREF
)lParam
;
2584 TRACE("background color 0x%06x!\n", infoPtr
->clrBk
);
2590 /* << REBAR_SetColorScheme >> */
2591 /* << REBAR_SetPalette >> */
2595 REBAR_SetParent (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
2597 HWND hwndTemp
= infoPtr
->hwndNotify
;
2599 infoPtr
->hwndNotify
= (HWND
)wParam
;
2601 return (LRESULT
)hwndTemp
;
2606 REBAR_SetTextColor (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
2610 clrTemp
= infoPtr
->clrText
;
2611 infoPtr
->clrText
= (COLORREF
)lParam
;
2613 TRACE("text color 0x%06x!\n", infoPtr
->clrText
);
2619 /* << REBAR_SetTooltips >> */
2622 static inline LRESULT
2623 REBAR_SetUnicodeFormat (REBAR_INFO
*infoPtr
, WPARAM wParam
)
2625 BOOL bTemp
= infoPtr
->bUnicode
;
2627 TRACE("to %s hwnd=%p, was %s\n",
2628 ((BOOL
)wParam
) ? "TRUE" : "FALSE", infoPtr
->hwndSelf
,
2629 (bTemp
) ? "TRUE" : "FALSE");
2631 infoPtr
->bUnicode
= (BOOL
)wParam
;
2638 REBAR_SetVersion (REBAR_INFO
*infoPtr
, INT iVersion
)
2640 INT iOldVersion
= infoPtr
->iVersion
;
2642 if (iVersion
> COMCTL32_VERSION
)
2645 infoPtr
->iVersion
= iVersion
;
2647 TRACE("new version %d\n", iVersion
);
2654 REBAR_ShowBand (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
2658 if (((INT
)wParam
< 0) || ((INT
)wParam
> infoPtr
->uNumBands
))
2661 lpBand
= &infoPtr
->bands
[(INT
)wParam
];
2664 TRACE("show band %d\n", (INT
)wParam
);
2665 lpBand
->fStyle
= lpBand
->fStyle
& ~RBBS_HIDDEN
;
2666 if (IsWindow (lpBand
->hwndChild
))
2667 ShowWindow (lpBand
->hwndChild
, SW_SHOW
);
2670 TRACE("hide band %d\n", (INT
)wParam
);
2671 lpBand
->fStyle
= lpBand
->fStyle
| RBBS_HIDDEN
;
2672 if (IsWindow (lpBand
->hwndChild
))
2673 ShowWindow (lpBand
->hwndChild
, SW_HIDE
);
2676 REBAR_Layout(infoPtr
, NULL
);
2677 InvalidateRect(infoPtr
->hwndSelf
, 0, 1);
2684 REBAR_SizeToRect (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
2686 LPRECT lpRect
= (LPRECT
)lParam
;
2692 TRACE("[%d %d %d %d]\n",
2693 lpRect
->left
, lpRect
->top
, lpRect
->right
, lpRect
->bottom
);
2695 /* what is going on???? */
2696 GetWindowRect(infoPtr
->hwndSelf
, &t1
);
2697 TRACE("window rect [%d %d %d %d]\n",
2698 t1
.left
, t1
.top
, t1
.right
, t1
.bottom
);
2699 GetClientRect(infoPtr
->hwndSelf
, &t1
);
2700 TRACE("client rect [%d %d %d %d]\n",
2701 t1
.left
, t1
.top
, t1
.right
, t1
.bottom
);
2703 /* force full _Layout processing */
2704 REBAR_Layout(infoPtr
, lpRect
);
2705 InvalidateRect (infoPtr
->hwndSelf
, NULL
, TRUE
);
2712 REBAR_Create (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
2714 LPCREATESTRUCTW cs
= (LPCREATESTRUCTW
) lParam
;
2718 if (TRACE_ON(rebar
)) {
2719 GetWindowRect(infoPtr
->hwndSelf
, &wnrc1
);
2720 GetClientRect(infoPtr
->hwndSelf
, &clrc1
);
2721 TRACE("window=(%d,%d)-(%d,%d) client=(%d,%d)-(%d,%d) cs=(%d,%d %dx%d)\n",
2722 wnrc1
.left
, wnrc1
.top
, wnrc1
.right
, wnrc1
.bottom
,
2723 clrc1
.left
, clrc1
.top
, clrc1
.right
, clrc1
.bottom
,
2724 cs
->x
, cs
->y
, cs
->cx
, cs
->cy
);
2727 TRACE("created!\n");
2729 if ((theme
= OpenThemeData (infoPtr
->hwndSelf
, themeClass
)))
2731 /* native seems to clear WS_BORDER when themed */
2732 infoPtr
->dwStyle
&= ~WS_BORDER
;
2740 REBAR_Destroy (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
2746 /* free rebar bands */
2747 if ((infoPtr
->uNumBands
> 0) && infoPtr
->bands
) {
2748 /* clean up each band */
2749 for (i
= 0; i
< infoPtr
->uNumBands
; i
++) {
2750 lpBand
= &infoPtr
->bands
[i
];
2752 /* delete text strings */
2753 Free (lpBand
->lpText
);
2754 lpBand
->lpText
= NULL
;
2755 /* destroy child window */
2756 DestroyWindow (lpBand
->hwndChild
);
2759 /* free band array */
2760 Free (infoPtr
->bands
);
2761 infoPtr
->bands
= NULL
;
2764 DestroyCursor (infoPtr
->hcurArrow
);
2765 DestroyCursor (infoPtr
->hcurHorz
);
2766 DestroyCursor (infoPtr
->hcurVert
);
2767 DestroyCursor (infoPtr
->hcurDrag
);
2768 if(infoPtr
->hDefaultFont
) DeleteObject (infoPtr
->hDefaultFont
);
2769 SetWindowLongPtrW (infoPtr
->hwndSelf
, 0, 0);
2771 CloseThemeData (GetWindowTheme (infoPtr
->hwndSelf
));
2773 /* free rebar info data */
2775 TRACE("destroyed!\n");
2781 REBAR_EraseBkGnd (const REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
2785 if (GetClipBox ( (HDC
)wParam
, &cliprect
))
2786 return REBAR_InternalEraseBkGnd (infoPtr
, wParam
, lParam
, &cliprect
);
2792 REBAR_GetFont (const REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
2794 return (LRESULT
)infoPtr
->hFont
;
2798 REBAR_PushChevron(const REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
2800 if (wParam
>= 0 && (UINT
)wParam
< infoPtr
->uNumBands
)
2802 NMREBARCHEVRON nmrbc
;
2803 REBAR_BAND
*lpBand
= &infoPtr
->bands
[wParam
];
2805 TRACE("Pressed chevron on band %ld\n", wParam
);
2807 /* redraw chevron in pushed state */
2808 lpBand
->fDraw
|= DRAW_CHEVRONPUSHED
;
2809 RedrawWindow(infoPtr
->hwndSelf
, &lpBand
->rcChevron
,0,
2810 RDW_ERASE
|RDW_INVALIDATE
|RDW_UPDATENOW
);
2812 /* notify app so it can display a popup menu or whatever */
2813 nmrbc
.uBand
= wParam
;
2814 nmrbc
.wID
= lpBand
->wID
;
2815 nmrbc
.lParam
= lpBand
->lParam
;
2816 nmrbc
.rc
= lpBand
->rcChevron
;
2817 nmrbc
.lParamNM
= lParam
;
2818 REBAR_Notify((NMHDR
*)&nmrbc
, infoPtr
, RBN_CHEVRONPUSHED
);
2820 /* redraw chevron in previous state */
2821 lpBand
->fDraw
&= ~DRAW_CHEVRONPUSHED
;
2822 InvalidateRect(infoPtr
->hwndSelf
, &lpBand
->rcChevron
, TRUE
);
2830 REBAR_LButtonDown (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
2836 ptMouseDown
.x
= (short)LOWORD(lParam
);
2837 ptMouseDown
.y
= (short)HIWORD(lParam
);
2839 REBAR_InternalHitTest(infoPtr
, &ptMouseDown
, &htFlags
, &iHitBand
);
2840 lpBand
= &infoPtr
->bands
[iHitBand
];
2842 if (htFlags
== RBHT_CHEVRON
)
2844 REBAR_PushChevron(infoPtr
, iHitBand
, 0);
2846 else if (htFlags
== RBHT_GRABBER
|| htFlags
== RBHT_CAPTION
)
2848 TRACE("Starting drag\n");
2850 SetCapture (infoPtr
->hwndSelf
);
2851 infoPtr
->iGrabbedBand
= iHitBand
;
2853 /* save off the LOWORD and HIWORD of lParam as initial x,y */
2854 infoPtr
->dragStart
.x
= (short)LOWORD(lParam
);
2855 infoPtr
->dragStart
.y
= (short)HIWORD(lParam
);
2856 infoPtr
->dragNow
= infoPtr
->dragStart
;
2857 if (infoPtr
->dwStyle
& CCS_VERT
)
2858 infoPtr
->ihitoffset
= infoPtr
->dragStart
.y
- (lpBand
->rcBand
.left
+ REBAR_PRE_GRIPPER
);
2860 infoPtr
->ihitoffset
= infoPtr
->dragStart
.x
- (lpBand
->rcBand
.left
+ REBAR_PRE_GRIPPER
);
2866 REBAR_LButtonUp (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
2868 if (infoPtr
->iGrabbedBand
>= 0)
2873 infoPtr
->dragStart
.x
= 0;
2874 infoPtr
->dragStart
.y
= 0;
2875 infoPtr
->dragNow
= infoPtr
->dragStart
;
2879 if (infoPtr
->fStatus
& BEGIN_DRAG_ISSUED
) {
2880 REBAR_Notify(&layout
, infoPtr
, RBN_LAYOUTCHANGED
);
2881 REBAR_Notify_NMREBAR (infoPtr
, infoPtr
->iGrabbedBand
, RBN_ENDDRAG
);
2882 infoPtr
->fStatus
&= ~BEGIN_DRAG_ISSUED
;
2885 infoPtr
->iGrabbedBand
= -1;
2887 GetClientRect(infoPtr
->hwndSelf
, &rect
);
2888 InvalidateRect(infoPtr
->hwndSelf
, NULL
, TRUE
);
2895 REBAR_MouseLeave (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
2897 if (infoPtr
->ichevronhotBand
>= 0)
2899 REBAR_BAND
*lpChevronBand
= &infoPtr
->bands
[infoPtr
->ichevronhotBand
];
2900 if (lpChevronBand
->fDraw
& DRAW_CHEVRONHOT
)
2902 lpChevronBand
->fDraw
&= ~DRAW_CHEVRONHOT
;
2903 InvalidateRect(infoPtr
->hwndSelf
, &lpChevronBand
->rcChevron
, TRUE
);
2906 infoPtr
->iOldBand
= -1;
2907 infoPtr
->ichevronhotBand
= -2;
2913 REBAR_MouseMove (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
2915 REBAR_BAND
*lpChevronBand
;
2918 ptMove
.x
= (short)LOWORD(lParam
);
2919 ptMove
.y
= (short)HIWORD(lParam
);
2921 /* if we are currently dragging a band */
2922 if (infoPtr
->iGrabbedBand
>= 0)
2924 REBAR_BAND
*band1
, *band2
;
2925 int yPtMove
= (infoPtr
->dwStyle
& CCS_VERT
? ptMove
.x
: ptMove
.y
);
2927 if (GetCapture() != infoPtr
->hwndSelf
)
2928 ERR("We are dragging but haven't got capture?!?\n");
2930 band1
= &infoPtr
->bands
[infoPtr
->iGrabbedBand
-1];
2931 band2
= &infoPtr
->bands
[infoPtr
->iGrabbedBand
];
2933 /* if mouse did not move much, exit */
2934 if ((abs(ptMove
.x
- infoPtr
->dragNow
.x
) <= mindragx
) &&
2935 (abs(ptMove
.y
- infoPtr
->dragNow
.y
) <= mindragy
)) return 0;
2937 /* Test for valid drag case - must not be first band in row */
2938 if ((yPtMove
< band2
->rcBand
.top
) ||
2939 (yPtMove
> band2
->rcBand
.bottom
) ||
2940 ((infoPtr
->iGrabbedBand
> 0) && (band1
->iRow
!= band2
->iRow
))) {
2941 FIXME("Cannot drag to other rows yet!!\n");
2944 REBAR_HandleLRDrag (infoPtr
, &ptMove
);
2951 TRACKMOUSEEVENT trackinfo
;
2953 REBAR_InternalHitTest(infoPtr
, &ptMove
, &htFlags
, &iHitBand
);
2955 if (infoPtr
->iOldBand
>= 0 && infoPtr
->iOldBand
== infoPtr
->ichevronhotBand
)
2957 lpChevronBand
= &infoPtr
->bands
[infoPtr
->ichevronhotBand
];
2958 if (lpChevronBand
->fDraw
& DRAW_CHEVRONHOT
)
2960 lpChevronBand
->fDraw
&= ~DRAW_CHEVRONHOT
;
2961 InvalidateRect(infoPtr
->hwndSelf
, &lpChevronBand
->rcChevron
, TRUE
);
2963 infoPtr
->ichevronhotBand
= -2;
2966 if (htFlags
== RBHT_CHEVRON
)
2968 /* fill in the TRACKMOUSEEVENT struct */
2969 trackinfo
.cbSize
= sizeof(TRACKMOUSEEVENT
);
2970 trackinfo
.dwFlags
= TME_QUERY
;
2971 trackinfo
.hwndTrack
= infoPtr
->hwndSelf
;
2972 trackinfo
.dwHoverTime
= 0;
2974 /* call _TrackMouseEvent to see if we are currently tracking for this hwnd */
2975 _TrackMouseEvent(&trackinfo
);
2977 /* Make sure tracking is enabled so we receive a WM_MOUSELEAVE message */
2978 if(!(trackinfo
.dwFlags
& TME_LEAVE
))
2980 trackinfo
.dwFlags
= TME_LEAVE
; /* notify upon leaving */
2982 /* call TRACKMOUSEEVENT so we receive a WM_MOUSELEAVE message */
2983 /* and can properly deactivate the hot chevron */
2984 _TrackMouseEvent(&trackinfo
);
2987 lpChevronBand
= &infoPtr
->bands
[iHitBand
];
2988 if (!(lpChevronBand
->fDraw
& DRAW_CHEVRONHOT
))
2990 lpChevronBand
->fDraw
|= DRAW_CHEVRONHOT
;
2991 InvalidateRect(infoPtr
->hwndSelf
, &lpChevronBand
->rcChevron
, TRUE
);
2992 infoPtr
->ichevronhotBand
= iHitBand
;
2995 infoPtr
->iOldBand
= iHitBand
;
3002 static inline LRESULT
3003 REBAR_NCCalcSize (const REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
3006 RECT
*rect
= (RECT
*)lParam
;
3008 if (infoPtr
->dwStyle
& WS_BORDER
) {
3009 rect
->left
= min(rect
->left
+ GetSystemMetrics(SM_CXEDGE
), rect
->right
);
3010 rect
->right
= max(rect
->right
- GetSystemMetrics(SM_CXEDGE
), rect
->left
);
3011 rect
->top
= min(rect
->top
+ GetSystemMetrics(SM_CYEDGE
), rect
->bottom
);
3012 rect
->bottom
= max(rect
->bottom
- GetSystemMetrics(SM_CYEDGE
), rect
->top
);
3014 else if ((theme
= GetWindowTheme (infoPtr
->hwndSelf
)))
3016 /* FIXME: should use GetThemeInt */
3017 rect
->top
= min(rect
->top
+ 1, rect
->bottom
);
3019 TRACE("new client=(%d,%d)-(%d,%d)\n", rect
->left
, rect
->top
, rect
->right
, rect
->bottom
);
3025 REBAR_NCCreate (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3027 LPCREATESTRUCTW cs
= (LPCREATESTRUCTW
) lParam
;
3028 REBAR_INFO
*infoPtr
= REBAR_GetInfoPtr (hwnd
);
3030 NONCLIENTMETRICSW ncm
;
3033 if (infoPtr
!= NULL
) {
3034 ERR("Strange info structure pointer *not* NULL\n");
3038 if (TRACE_ON(rebar
)) {
3039 GetWindowRect(hwnd
, &wnrc1
);
3040 GetClientRect(hwnd
, &clrc1
);
3041 TRACE("window=(%d,%d)-(%d,%d) client=(%d,%d)-(%d,%d) cs=(%d,%d %dx%d)\n",
3042 wnrc1
.left
, wnrc1
.top
, wnrc1
.right
, wnrc1
.bottom
,
3043 clrc1
.left
, clrc1
.top
, clrc1
.right
, clrc1
.bottom
,
3044 cs
->x
, cs
->y
, cs
->cx
, cs
->cy
);
3047 /* allocate memory for info structure */
3048 infoPtr
= (REBAR_INFO
*)Alloc (sizeof(REBAR_INFO
));
3049 SetWindowLongPtrW (hwnd
, 0, (DWORD_PTR
)infoPtr
);
3051 /* initialize info structure - initial values are 0 */
3052 infoPtr
->clrBk
= CLR_NONE
;
3053 infoPtr
->clrText
= CLR_NONE
;
3054 infoPtr
->clrBtnText
= GetSysColor (COLOR_BTNTEXT
);
3055 infoPtr
->clrBtnFace
= GetSysColor (COLOR_BTNFACE
);
3056 infoPtr
->iOldBand
= -1;
3057 infoPtr
->ichevronhotBand
= -2;
3058 infoPtr
->iGrabbedBand
= -1;
3059 infoPtr
->hwndSelf
= hwnd
;
3060 infoPtr
->DoRedraw
= TRUE
;
3061 infoPtr
->hcurArrow
= LoadCursorW (0, (LPWSTR
)IDC_ARROW
);
3062 infoPtr
->hcurHorz
= LoadCursorW (0, (LPWSTR
)IDC_SIZEWE
);
3063 infoPtr
->hcurVert
= LoadCursorW (0, (LPWSTR
)IDC_SIZENS
);
3064 infoPtr
->hcurDrag
= LoadCursorW (0, (LPWSTR
)IDC_SIZE
);
3065 infoPtr
->fStatus
= 0;
3066 infoPtr
->hFont
= GetStockObject (SYSTEM_FONT
);
3068 /* issue WM_NOTIFYFORMAT to get unicode status of parent */
3069 REBAR_NotifyFormat(infoPtr
, 0, NF_REQUERY
);
3071 /* Stow away the original style */
3072 infoPtr
->orgStyle
= cs
->style
;
3073 /* add necessary styles to the requested styles */
3074 infoPtr
->dwStyle
= cs
->style
| WS_VISIBLE
;
3075 if ((infoPtr
->dwStyle
& CCS_LAYOUT_MASK
) == 0)
3076 infoPtr
->dwStyle
|= CCS_TOP
;
3077 SetWindowLongW (hwnd
, GWL_STYLE
, infoPtr
->dwStyle
);
3079 /* get font handle for Caption Font */
3080 ncm
.cbSize
= sizeof(ncm
);
3081 SystemParametersInfoW (SPI_GETNONCLIENTMETRICS
, ncm
.cbSize
, &ncm
, 0);
3082 /* if the font is bold, set to normal */
3083 if (ncm
.lfCaptionFont
.lfWeight
> FW_NORMAL
) {
3084 ncm
.lfCaptionFont
.lfWeight
= FW_NORMAL
;
3086 tfont
= CreateFontIndirectW (&ncm
.lfCaptionFont
);
3088 infoPtr
->hFont
= infoPtr
->hDefaultFont
= tfont
;
3092 GetSysColor (numerous);
3093 GetSysColorBrush (numerous) (see WM_SYSCOLORCHANGE);
3094 *GetStockObject (SYSTEM_FONT);
3095 *SetWindowLong (hwnd, 0, info ptr);
3097 *SetWindowLong (hwnd, GWL_STYLE, style+0x10000001);
3098 WS_VISIBLE = 0x10000000;
3099 CCS_TOP = 0x00000001;
3100 *SystemParametersInfo (SPI_GETNONCLIENTMETRICS...);
3101 *CreateFontIndirect (lfCaptionFont from above);
3103 SelectObject (hdc, fontabove);
3104 GetTextMetrics (hdc, ); guessing is tmHeight
3105 SelectObject (hdc, oldfont);
3108 MapWindowPoints (0, parent, rectabove, 2);
3111 ClientToScreen (clientrect);
3112 SetWindowPos (hwnd, 0, 0, 0, 0, 0, SWP_NOZORDER);
3119 REBAR_NCHitTest (const REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
3125 LRESULT ret
= HTCLIENT
;
3128 * Differences from doc at MSDN (as observed with version 4.71 of
3130 * 1. doc says nmmouse.pt is in screen coord, trace shows client coord.
3131 * 2. if band is not identified .dwItemSpec is 0xffffffff.
3132 * 3. native always seems to return HTCLIENT if notify return is 0.
3135 clpt
.x
= (short)LOWORD(lParam
);
3136 clpt
.y
= (short)HIWORD(lParam
);
3137 ScreenToClient (infoPtr
->hwndSelf
, &clpt
);
3138 REBAR_InternalHitTest (infoPtr
, &clpt
, &scrap
,
3139 (INT
*)&nmmouse
.dwItemSpec
);
3140 nmmouse
.dwItemData
= 0;
3142 nmmouse
.dwHitInfo
= 0;
3143 if ((i
= REBAR_Notify((NMHDR
*) &nmmouse
, infoPtr
, NM_NCHITTEST
))) {
3144 TRACE("notify changed return value from %ld to %d\n",
3148 TRACE("returning %ld, client point (%d,%d)\n", ret
, clpt
.x
, clpt
.y
);
3154 REBAR_NCPaint (const REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
3160 if (infoPtr
->dwStyle
& WS_MINIMIZE
)
3161 return 0; /* Nothing to do */
3163 if (infoPtr
->dwStyle
& WS_BORDER
) {
3165 /* adjust rectangle and draw the necessary edge */
3166 if (!(hdc
= GetDCEx( infoPtr
->hwndSelf
, 0, DCX_USESTYLE
| DCX_WINDOW
)))
3168 GetWindowRect (infoPtr
->hwndSelf
, &rcWindow
);
3169 OffsetRect (&rcWindow
, -rcWindow
.left
, -rcWindow
.top
);
3170 TRACE("rect (%d,%d)-(%d,%d)\n",
3171 rcWindow
.left
, rcWindow
.top
,
3172 rcWindow
.right
, rcWindow
.bottom
);
3173 DrawEdge (hdc
, &rcWindow
, EDGE_ETCHED
, BF_RECT
);
3174 ReleaseDC( infoPtr
->hwndSelf
, hdc
);
3176 else if ((theme
= GetWindowTheme (infoPtr
->hwndSelf
)))
3178 /* adjust rectangle and draw the necessary edge */
3179 if (!(hdc
= GetDCEx( infoPtr
->hwndSelf
, 0, DCX_USESTYLE
| DCX_WINDOW
)))
3181 GetWindowRect (infoPtr
->hwndSelf
, &rcWindow
);
3182 OffsetRect (&rcWindow
, -rcWindow
.left
, -rcWindow
.top
);
3183 TRACE("rect (%d,%d)-(%d,%d)\n",
3184 rcWindow
.left
, rcWindow
.top
,
3185 rcWindow
.right
, rcWindow
.bottom
);
3186 DrawThemeEdge (theme
, hdc
, 0, 0, &rcWindow
, BDR_RAISEDINNER
, BF_TOP
, NULL
);
3187 ReleaseDC( infoPtr
->hwndSelf
, hdc
);
3195 REBAR_NotifyFormat (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
3199 if (lParam
== NF_REQUERY
) {
3200 i
= SendMessageW(REBAR_GetNotifyParent (infoPtr
),
3201 WM_NOTIFYFORMAT
, (WPARAM
)infoPtr
->hwndSelf
, NF_QUERY
);
3202 if ((i
!= NFR_ANSI
) && (i
!= NFR_UNICODE
)) {
3203 ERR("wrong response to WM_NOTIFYFORMAT (%d), assuming ANSI\n", i
);
3206 infoPtr
->bUnicode
= (i
== NFR_UNICODE
) ? 1 : 0;
3209 return (LRESULT
)((infoPtr
->bUnicode
) ? NFR_UNICODE
: NFR_ANSI
);
3214 REBAR_Paint (const REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
3220 GetClientRect(infoPtr
->hwndSelf
, &rc
);
3221 hdc
= wParam
==0 ? BeginPaint (infoPtr
->hwndSelf
, &ps
) : (HDC
)wParam
;
3223 TRACE("painting (%d,%d)-(%d,%d) client (%d,%d)-(%d,%d)\n",
3224 ps
.rcPaint
.left
, ps
.rcPaint
.top
,
3225 ps
.rcPaint
.right
, ps
.rcPaint
.bottom
,
3226 rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
3229 /* Erase area of paint if requested */
3230 REBAR_InternalEraseBkGnd (infoPtr
, wParam
, lParam
, &ps
.rcPaint
);
3233 REBAR_Refresh (infoPtr
, hdc
);
3235 EndPaint (infoPtr
->hwndSelf
, &ps
);
3241 REBAR_SetCursor (const REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
3246 TRACE("code=0x%X id=0x%X\n", LOWORD(lParam
), HIWORD(lParam
));
3249 ScreenToClient (infoPtr
->hwndSelf
, &pt
);
3251 REBAR_InternalHitTest (infoPtr
, &pt
, &flags
, NULL
);
3253 if (flags
== RBHT_GRABBER
) {
3254 if ((infoPtr
->dwStyle
& CCS_VERT
) &&
3255 !(infoPtr
->dwStyle
& RBS_VERTICALGRIPPER
))
3256 SetCursor (infoPtr
->hcurVert
);
3258 SetCursor (infoPtr
->hcurHorz
);
3260 else if (flags
!= RBHT_CLIENT
)
3261 SetCursor (infoPtr
->hcurArrow
);
3268 REBAR_SetFont (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
3273 infoPtr
->hFont
= (HFONT
)wParam
;
3275 /* revalidate all bands to change sizes of text in headers of bands */
3276 for (i
=0; i
<infoPtr
->uNumBands
; i
++) {
3277 lpBand
= &infoPtr
->bands
[i
];
3278 REBAR_ValidateBand (infoPtr
, lpBand
);
3281 REBAR_Layout(infoPtr
, NULL
);
3286 static inline LRESULT
3287 REBAR_SetRedraw (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
3288 /*****************************************************
3291 * Handles the WM_SETREDRAW message.
3294 * According to testing V4.71 of COMCTL32 returns the
3295 * *previous* status of the redraw flag (either 0 or -1)
3296 * instead of the MSDN documented value of 0 if handled
3298 *****************************************************/
3300 BOOL oldredraw
= infoPtr
->DoRedraw
;
3302 TRACE("set to %s, fStatus=%08x\n",
3303 (wParam
) ? "TRUE" : "FALSE", infoPtr
->fStatus
);
3304 infoPtr
->DoRedraw
= (BOOL
) wParam
;
3306 if (infoPtr
->fStatus
& BAND_NEEDS_REDRAW
) {
3307 REBAR_MoveChildWindows (infoPtr
, 0, infoPtr
->uNumBands
);
3308 REBAR_ForceResize (infoPtr
);
3309 InvalidateRect (infoPtr
->hwndSelf
, 0, TRUE
);
3311 infoPtr
->fStatus
&= ~BAND_NEEDS_REDRAW
;
3313 return (oldredraw
) ? -1 : 0;
3318 REBAR_Size (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
3320 TRACE("wParam=%lx, lParam=%lx\n", wParam
, lParam
);
3322 /* avoid auto resize infinite recursion */
3323 if (infoPtr
->fStatus
& AUTO_RESIZE
) {
3324 infoPtr
->fStatus
&= ~AUTO_RESIZE
;
3325 TRACE("AUTO_RESIZE was set, reset, fStatus=%08x lparam=%08lx\n",
3326 infoPtr
->fStatus
, lParam
);
3331 if (infoPtr
->dwStyle
& RBS_AUTOSIZE
) {
3332 NMRBAUTOSIZE autosize
;
3334 GetClientRect(infoPtr
->hwndSelf
, &autosize
.rcTarget
);
3335 autosize
.fChanged
= 0; /* ??? */
3336 autosize
.rcActual
= autosize
.rcTarget
; /* ??? */
3337 REBAR_Notify((NMHDR
*) &autosize
, infoPtr
, RBN_AUTOSIZE
);
3338 TRACE("RBN_AUTOSIZE client=(%d,%d), lp=%08lx\n",
3339 autosize
.rcTarget
.right
, autosize
.rcTarget
.bottom
, lParam
);
3342 REBAR_Layout(infoPtr
, NULL
);
3349 REBAR_StyleChanged (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
3351 STYLESTRUCT
*ss
= (STYLESTRUCT
*)lParam
;
3353 TRACE("current style=%08x, styleOld=%08x, style being set to=%08x\n",
3354 infoPtr
->dwStyle
, ss
->styleOld
, ss
->styleNew
);
3355 infoPtr
->orgStyle
= infoPtr
->dwStyle
= ss
->styleNew
;
3356 if (GetWindowTheme (infoPtr
->hwndSelf
))
3357 infoPtr
->dwStyle
&= ~WS_BORDER
;
3358 /* maybe it should be COMMON_STYLES like in toolbar */
3359 if ((ss
->styleNew
^ ss
->styleOld
) & CCS_VERT
)
3360 REBAR_Layout(infoPtr
, NULL
);
3365 /* update theme after a WM_THEMECHANGED message */
3366 static LRESULT
theme_changed (REBAR_INFO
* infoPtr
)
3368 HTHEME theme
= GetWindowTheme (infoPtr
->hwndSelf
);
3369 CloseThemeData (theme
);
3370 theme
= OpenThemeData (infoPtr
->hwndSelf
, themeClass
);
3371 /* WS_BORDER disappears when theming is enabled and reappears when
3373 infoPtr
->dwStyle
&= ~WS_BORDER
;
3374 infoPtr
->dwStyle
|= theme
? 0 : (infoPtr
->orgStyle
& WS_BORDER
);
3379 REBAR_WindowPosChanged (const REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
3384 ret
= DefWindowProcW(infoPtr
->hwndSelf
, WM_WINDOWPOSCHANGED
,
3386 GetWindowRect(infoPtr
->hwndSelf
, &rc
);
3387 TRACE("hwnd %p new pos (%d,%d)-(%d,%d)\n",
3388 infoPtr
->hwndSelf
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
3393 static LRESULT WINAPI
3394 REBAR_WindowProc (HWND hwnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
)
3396 REBAR_INFO
*infoPtr
= REBAR_GetInfoPtr (hwnd
);
3398 TRACE("hwnd=%p msg=%x wparam=%lx lparam=%lx\n",
3399 hwnd
, uMsg
, wParam
, lParam
);
3400 if (!infoPtr
&& (uMsg
!= WM_NCCREATE
))
3401 return DefWindowProcW (hwnd
, uMsg
, wParam
, lParam
);
3404 /* case RB_BEGINDRAG: */
3407 return REBAR_DeleteBand (infoPtr
, wParam
, lParam
);
3409 /* case RB_DRAGMOVE: */
3410 /* case RB_ENDDRAG: */
3412 case RB_GETBANDBORDERS
:
3413 return REBAR_GetBandBorders (infoPtr
, wParam
, lParam
);
3415 case RB_GETBANDCOUNT
:
3416 return REBAR_GetBandCount (infoPtr
);
3418 case RB_GETBANDINFO_OLD
:
3419 case RB_GETBANDINFOA
:
3420 return REBAR_GetBandInfoT(infoPtr
, wParam
, lParam
, FALSE
);
3422 case RB_GETBANDINFOW
:
3423 return REBAR_GetBandInfoT(infoPtr
, wParam
, lParam
, TRUE
);
3425 case RB_GETBARHEIGHT
:
3426 return REBAR_GetBarHeight (infoPtr
, wParam
, lParam
);
3429 return REBAR_GetBarInfo (infoPtr
, wParam
, lParam
);
3432 return REBAR_GetBkColor (infoPtr
);
3434 /* case RB_GETCOLORSCHEME: */
3435 /* case RB_GETDROPTARGET: */
3438 return REBAR_GetPalette (infoPtr
, wParam
, lParam
);
3441 return REBAR_GetRect (infoPtr
, wParam
, lParam
);
3443 case RB_GETROWCOUNT
:
3444 return REBAR_GetRowCount (infoPtr
);
3446 case RB_GETROWHEIGHT
:
3447 return REBAR_GetRowHeight (infoPtr
, wParam
, lParam
);
3449 case RB_GETTEXTCOLOR
:
3450 return REBAR_GetTextColor (infoPtr
);
3452 case RB_GETTOOLTIPS
:
3453 return REBAR_GetToolTips (infoPtr
);
3455 case RB_GETUNICODEFORMAT
:
3456 return REBAR_GetUnicodeFormat (infoPtr
);
3458 case CCM_GETVERSION
:
3459 return REBAR_GetVersion (infoPtr
);
3462 return REBAR_HitTest (infoPtr
, wParam
, lParam
);
3465 return REBAR_IdToIndex (infoPtr
, wParam
, lParam
);
3467 case RB_INSERTBANDA
:
3468 return REBAR_InsertBandT(infoPtr
, wParam
, lParam
, FALSE
);
3470 case RB_INSERTBANDW
:
3471 return REBAR_InsertBandT(infoPtr
, wParam
, lParam
, TRUE
);
3473 case RB_MAXIMIZEBAND
:
3474 return REBAR_MaximizeBand (infoPtr
, wParam
, lParam
);
3476 case RB_MINIMIZEBAND
:
3477 return REBAR_MinimizeBand (infoPtr
, wParam
, lParam
);
3480 return REBAR_MoveBand (infoPtr
, wParam
, lParam
);
3482 case RB_PUSHCHEVRON
:
3483 return REBAR_PushChevron (infoPtr
, wParam
, lParam
);
3485 case RB_SETBANDINFOA
:
3486 return REBAR_SetBandInfoT(infoPtr
, wParam
, lParam
, FALSE
);
3488 case RB_SETBANDINFOW
:
3489 return REBAR_SetBandInfoT(infoPtr
, wParam
, lParam
, TRUE
);
3492 return REBAR_SetBarInfo (infoPtr
, wParam
, lParam
);
3495 return REBAR_SetBkColor (infoPtr
, wParam
, lParam
);
3497 /* case RB_SETCOLORSCHEME: */
3498 /* case RB_SETPALETTE: */
3499 /* return REBAR_GetPalette (infoPtr, wParam, lParam); */
3502 return REBAR_SetParent (infoPtr
, wParam
, lParam
);
3504 case RB_SETTEXTCOLOR
:
3505 return REBAR_SetTextColor (infoPtr
, wParam
, lParam
);
3507 /* case RB_SETTOOLTIPS: */
3509 case RB_SETUNICODEFORMAT
:
3510 return REBAR_SetUnicodeFormat (infoPtr
, wParam
);
3512 case CCM_SETVERSION
:
3513 return REBAR_SetVersion (infoPtr
, (INT
)wParam
);
3516 return REBAR_ShowBand (infoPtr
, wParam
, lParam
);
3519 return REBAR_SizeToRect (infoPtr
, wParam
, lParam
);
3522 /* Messages passed to parent */
3526 return SendMessageW(REBAR_GetNotifyParent (infoPtr
), uMsg
, wParam
, lParam
);
3529 /* case WM_CHARTOITEM: supported according to ControlSpy */
3532 return REBAR_Create (infoPtr
, wParam
, lParam
);
3535 return REBAR_Destroy (infoPtr
, wParam
, lParam
);
3538 return REBAR_EraseBkGnd (infoPtr
, wParam
, lParam
);
3541 return REBAR_GetFont (infoPtr
, wParam
, lParam
);
3543 /* case WM_LBUTTONDBLCLK: supported according to ControlSpy */
3545 case WM_LBUTTONDOWN
:
3546 return REBAR_LButtonDown (infoPtr
, wParam
, lParam
);
3549 return REBAR_LButtonUp (infoPtr
, wParam
, lParam
);
3551 /* case WM_MEASUREITEM: supported according to ControlSpy */
3554 return REBAR_MouseMove (infoPtr
, wParam
, lParam
);
3557 return REBAR_MouseLeave (infoPtr
, wParam
, lParam
);
3560 return REBAR_NCCalcSize (infoPtr
, wParam
, lParam
);
3563 return REBAR_NCCreate (hwnd
, wParam
, lParam
);
3566 return REBAR_NCHitTest (infoPtr
, wParam
, lParam
);
3569 return REBAR_NCPaint (infoPtr
, wParam
, lParam
);
3571 case WM_NOTIFYFORMAT
:
3572 return REBAR_NotifyFormat (infoPtr
, wParam
, lParam
);
3574 case WM_PRINTCLIENT
:
3576 return REBAR_Paint (infoPtr
, wParam
, lParam
);
3578 /* case WM_PALETTECHANGED: supported according to ControlSpy */
3579 /* case WM_QUERYNEWPALETTE:supported according to ControlSpy */
3580 /* case WM_RBUTTONDOWN: supported according to ControlSpy */
3581 /* case WM_RBUTTONUP: supported according to ControlSpy */
3584 return REBAR_SetCursor (infoPtr
, wParam
, lParam
);
3587 return REBAR_SetFont (infoPtr
, wParam
, lParam
);
3590 return REBAR_SetRedraw (infoPtr
, wParam
, lParam
);
3593 return REBAR_Size (infoPtr
, wParam
, lParam
);
3595 case WM_STYLECHANGED
:
3596 return REBAR_StyleChanged (infoPtr
, wParam
, lParam
);
3598 case WM_THEMECHANGED
:
3599 return theme_changed (infoPtr
);
3601 /* case WM_SYSCOLORCHANGE: supported according to ControlSpy */
3602 /* "Applications that have brushes using the existing system colors
3603 should delete those brushes and recreate them using the new
3604 system colors." per MSDN */
3606 /* case WM_VKEYTOITEM: supported according to ControlSpy */
3607 /* case WM_WININICHANGE: */
3609 case WM_WINDOWPOSCHANGED
:
3610 return REBAR_WindowPosChanged (infoPtr
, wParam
, lParam
);
3613 if ((uMsg
>= WM_USER
) && (uMsg
< WM_APP
))
3614 ERR("unknown msg %04x wp=%08lx lp=%08lx\n",
3615 uMsg
, wParam
, lParam
);
3616 return DefWindowProcW (hwnd
, uMsg
, wParam
, lParam
);
3622 REBAR_Register (void)
3626 ZeroMemory (&wndClass
, sizeof(WNDCLASSW
));
3627 wndClass
.style
= CS_GLOBALCLASS
| CS_DBLCLKS
;
3628 wndClass
.lpfnWndProc
= REBAR_WindowProc
;
3629 wndClass
.cbClsExtra
= 0;
3630 wndClass
.cbWndExtra
= sizeof(REBAR_INFO
*);
3631 wndClass
.hCursor
= 0;
3632 wndClass
.hbrBackground
= (HBRUSH
)(COLOR_BTNFACE
+ 1);
3634 wndClass
.hbrBackground
= CreateSolidBrush(RGB(0,128,0));
3636 wndClass
.lpszClassName
= REBARCLASSNAMEW
;
3638 RegisterClassW (&wndClass
);
3640 mindragx
= GetSystemMetrics (SM_CXDRAG
);
3641 mindragy
= GetSystemMetrics (SM_CYDRAG
);
3647 REBAR_Unregister (void)
3649 UnregisterClassW (REBARCLASSNAMEW
, NULL
);