4 * Copyright 1998, 1999 Eric Kohl
5 * Copyright 2007, 2008 Mikolaj Zalewski
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
23 * This code was audited for completeness against the documented features
24 * of Comctl32.dll version 6.0 on Oct. 19, 2004, by Robert Shearman.
26 * Unless otherwise noted, we believe this code to be complete, as per
27 * the specification mentioned above.
28 * If you discover missing features or bugs please note them below.
50 * - WM_QUERYNEWPALETTE
57 * - NM_RELEASEDCAPTURE
63 * Native uses (on each draw!!) SM_CYBORDER (or SM_CXBORDER for CCS_VERT)
64 * to set the size of the separator width (the value SEP_WIDTH_SIZE
65 * in here). Should be fixed!!
69 * Testing: set to 1 to make background brush *always* green
74 * 3. REBAR_MoveChildWindows should have a loop because more than
75 * one pass (together with the RBN_CHILDSIZEs) is made on
76 * at least RB_INSERTBAND
81 WINE_DEFAULT_DEBUG_CHANNEL(rebar
);
91 UINT cxMinChild
; /* valid if _CHILDSIZE */
92 UINT cyMinChild
; /* valid if _CHILDSIZE */
93 UINT cx
; /* valid if _SIZE */
96 UINT cyChild
; /* valid if _CHILDSIZE */
97 UINT cyMaxChild
; /* valid if _CHILDSIZE */
98 UINT cyIntegral
; /* valid if _CHILDSIZE */
103 INT cxEffective
; /* current cx for band */
104 UINT cyHeader
; /* the height of the header */
105 UINT cxMinBand
; /* minimum cx for band */
106 UINT cyMinBand
; /* minimum cy for band */
108 UINT cyRowSoFar
; /* for RBS_VARHEIGHT - the height of the row if it would break on this band (set by _Layout) */
109 INT iRow
; /* zero-based index of the row this band assigned to */
110 UINT fStatus
; /* status flags, reset only by _Validate */
111 UINT fDraw
; /* drawing flags, reset only by _Layout */
112 UINT uCDret
; /* last return from NM_CUSTOMDRAW */
113 RECT rcBand
; /* calculated band rectangle - coordinates swapped for CCS_VERT */
114 RECT rcGripper
; /* calculated gripper rectangle */
115 RECT rcCapImage
; /* calculated caption image rectangle */
116 RECT rcCapText
; /* calculated caption text rectangle */
117 RECT rcChild
; /* calculated child rectangle */
118 RECT rcChevron
; /* calculated chevron rectangle */
124 /* has a value of: 0, CCS_TOP, CCS_NOMOVEY, CCS_BOTTOM */
125 #define CCS_LAYOUT_MASK 0x3
128 #define HAS_GRIPPER 0x00000001
129 #define HAS_IMAGE 0x00000002
130 #define HAS_TEXT 0x00000004
133 #define DRAW_GRIPPER 0x00000001
134 #define DRAW_IMAGE 0x00000002
135 #define DRAW_TEXT 0x00000004
136 #define DRAW_CHEVRONHOT 0x00000040
137 #define DRAW_CHEVRONPUSHED 0x00000080
138 #define NTF_INVALIDATE 0x01000000
142 COLORREF clrBk
; /* background color */
143 COLORREF clrText
; /* text color */
144 COLORREF clrBtnText
; /* system color for BTNTEXT */
145 COLORREF clrBtnFace
; /* system color for BTNFACE */
146 HIMAGELIST himl
; /* handle to imagelist */
147 UINT uNumBands
; /* # of bands in rebar (first=0, last=uNumBands-1 */
148 UINT uNumRows
; /* # of rows of bands (first=1, last=uNumRows */
149 HWND hwndSelf
; /* handle of REBAR window itself */
150 HWND hwndToolTip
; /* handle to the tool tip control */
151 HWND hwndNotify
; /* notification window (parent) */
153 HFONT hFont
; /* handle to the rebar's font */
154 SIZE imageSize
; /* image size (image list) */
155 DWORD dwStyle
; /* window style */
156 DWORD orgStyle
; /* original style (dwStyle may change) */
157 SIZE calcSize
; /* calculated rebar size - coordinates swapped for CCS_VERT */
158 BOOL bUnicode
; /* TRUE if parent wants notify in W format */
159 BOOL DoRedraw
; /* TRUE to actually draw bands */
160 UINT fStatus
; /* Status flags (see below) */
161 HCURSOR hcurArrow
; /* handle to the arrow cursor */
162 HCURSOR hcurHorz
; /* handle to the EW cursor */
163 HCURSOR hcurVert
; /* handle to the NS cursor */
164 HCURSOR hcurDrag
; /* handle to the drag cursor */
165 INT iVersion
; /* version number */
166 POINT dragStart
; /* x,y of button down */
167 POINT dragNow
; /* x,y of this MouseMove */
168 INT iOldBand
; /* last band that had the mouse cursor over it */
169 INT ihitoffset
; /* offset of hotspot from gripper.left */
170 INT ichevronhotBand
; /* last band that had a hot chevron */
171 INT iGrabbedBand
;/* band number of band whose gripper was grabbed */
173 HDPA bands
; /* pointer to the array of rebar bands */
177 #define BEGIN_DRAG_ISSUED 0x00000001
178 #define SELF_RESIZE 0x00000002
179 #define BAND_NEEDS_REDRAW 0x00000020
181 /* used by Windows to mark that the header size has been set by the user and shouldn't be changed */
182 #define RBBS_UNDOC_FIXEDHEADER 0x40000000
184 /* ---- REBAR layout constants. Mostly determined by ---- */
185 /* ---- experiment on WIN 98. ---- */
187 /* Width (or height) of separators between bands (either horz. or */
188 /* vert.). True only if RBS_BANDBORDERS is set */
189 #define SEP_WIDTH_SIZE 2
190 #define SEP_WIDTH ((infoPtr->dwStyle & RBS_BANDBORDERS) ? SEP_WIDTH_SIZE : 0)
192 /* Blank (background color) space between Gripper (if present) */
193 /* and next item (image, text, or window). Always present */
194 #define REBAR_ALWAYS_SPACE 4
196 /* Blank (background color) space after Image (if present). */
197 #define REBAR_POST_IMAGE 2
199 /* Blank (background color) space after Text (if present). */
200 #define REBAR_POST_TEXT 4
202 /* Height of vertical gripper in a CCS_VERT rebar. */
203 #define GRIPPER_HEIGHT 16
205 /* Blank (background color) space before Gripper (if present). */
206 #define REBAR_PRE_GRIPPER 2
208 /* Width (of normal vertical gripper) or height (of horz. gripper) */
210 #define GRIPPER_WIDTH 3
212 /* Width of the chevron button if present */
213 #define CHEVRON_WIDTH 10
215 /* the gap between the child and the next band */
216 #define REBAR_POST_CHILD 4
218 /* Height of divider for Rebar if not disabled (CCS_NODIVIDER) */
219 /* either top or bottom */
220 #define REBAR_DIVIDER 2
222 /* height of a rebar without a child */
223 #define REBAR_NO_CHILD_HEIGHT 4
225 /* minimum vertical height of a normal bar */
226 /* or minimum width of a CCS_VERT bar - from experiment on Win2k */
227 #define REBAR_MINSIZE 23
229 /* This is the increment that is used over the band height */
230 #define REBARSPACE(a) ((a->fStyle & RBBS_CHILDEDGE) ? 2*REBAR_DIVIDER : 0)
232 /* ---- End of REBAR layout constants. ---- */
234 #define RB_GETBANDINFO_OLD (WM_USER+5) /* obsoleted after IE3, but we have to support it anyway */
236 /* The following define determines if a given band is hidden */
237 #define HIDDENBAND(a) (((a)->fStyle & RBBS_HIDDEN) || \
238 ((infoPtr->dwStyle & CCS_VERT) && \
239 ((a)->fStyle & RBBS_NOVERT)))
241 #define REBAR_GetInfoPtr(wndPtr) ((REBAR_INFO *)GetWindowLongPtrW (hwnd, 0))
243 static LRESULT
REBAR_NotifyFormat(REBAR_INFO
*infoPtr
, LPARAM lParam
);
244 static void REBAR_AutoSize(REBAR_INFO
*infoPtr
, BOOL needsLayout
);
246 /* no index check here */
247 static inline REBAR_BAND
* REBAR_GetBand(const REBAR_INFO
*infoPtr
, INT i
)
249 assert(i
>= 0 && i
< infoPtr
->uNumBands
);
250 return DPA_GetPtr(infoPtr
->bands
, i
);
253 /* "constant values" retrieved when DLL was initialized */
254 /* FIXME we do this when the classes are registered. */
255 static UINT mindragx
= 0;
256 static UINT mindragy
= 0;
258 static const char * const band_stylename
[] = {
259 "RBBS_BREAK", /* 0001 */
260 "RBBS_FIXEDSIZE", /* 0002 */
261 "RBBS_CHILDEDGE", /* 0004 */
262 "RBBS_HIDDEN", /* 0008 */
263 "RBBS_NOVERT", /* 0010 */
264 "RBBS_FIXEDBMP", /* 0020 */
265 "RBBS_VARIABLEHEIGHT", /* 0040 */
266 "RBBS_GRIPPERALWAYS", /* 0080 */
267 "RBBS_NOGRIPPER", /* 0100 */
270 static const char * const band_maskname
[] = {
271 "RBBIM_STYLE", /* 0x00000001 */
272 "RBBIM_COLORS", /* 0x00000002 */
273 "RBBIM_TEXT", /* 0x00000004 */
274 "RBBIM_IMAGE", /* 0x00000008 */
275 "RBBIM_CHILD", /* 0x00000010 */
276 "RBBIM_CHILDSIZE", /* 0x00000020 */
277 "RBBIM_SIZE", /* 0x00000040 */
278 "RBBIM_BACKGROUND", /* 0x00000080 */
279 "RBBIM_ID", /* 0x00000100 */
280 "RBBIM_IDEALSIZE", /* 0x00000200 */
281 "RBBIM_LPARAM", /* 0x00000400 */
282 "RBBIM_HEADERSIZE", /* 0x00000800 */
286 static CHAR line
[200];
288 static const WCHAR themeClass
[] = { 'R','e','b','a','r',0 };
291 REBAR_FmtStyle( UINT style
)
296 while (band_stylename
[i
]) {
297 if (style
& (1<<i
)) {
298 if (*line
!= 0) strcat(line
, " | ");
299 strcat(line
, band_stylename
[i
]);
308 REBAR_FmtMask( UINT mask
)
313 while (band_maskname
[i
]) {
315 if (*line
!= 0) strcat(line
, " | ");
316 strcat(line
, band_maskname
[i
]);
325 REBAR_DumpBandInfo(const REBARBANDINFOW
*pB
)
327 if( !TRACE_ON(rebar
) ) return;
328 TRACE("band info: ");
329 if (pB
->fMask
& RBBIM_ID
)
330 TRACE("ID=%u, ", pB
->wID
);
331 TRACE("size=%u, child=%p", pB
->cbSize
, pB
->hwndChild
);
332 if (pB
->fMask
& RBBIM_COLORS
)
333 TRACE(", clrF=0x%06x, clrB=0x%06x", pB
->clrFore
, pB
->clrBack
);
336 TRACE("band info: mask=0x%08x (%s)\n", pB
->fMask
, REBAR_FmtMask(pB
->fMask
));
337 if (pB
->fMask
& RBBIM_STYLE
)
338 TRACE("band info: style=0x%08x (%s)\n", pB
->fStyle
, REBAR_FmtStyle(pB
->fStyle
));
339 if (pB
->fMask
& (RBBIM_SIZE
| RBBIM_IDEALSIZE
| RBBIM_HEADERSIZE
| RBBIM_LPARAM
)) {
341 if (pB
->fMask
& RBBIM_SIZE
)
342 TRACE(" cx=%u", pB
->cx
);
343 if (pB
->fMask
& RBBIM_IDEALSIZE
)
344 TRACE(" xIdeal=%u", pB
->cxIdeal
);
345 if (pB
->fMask
& RBBIM_HEADERSIZE
)
346 TRACE(" xHeader=%u", pB
->cxHeader
);
347 if (pB
->fMask
& RBBIM_LPARAM
)
348 TRACE(" lParam=0x%08lx", pB
->lParam
);
351 if (pB
->fMask
& RBBIM_CHILDSIZE
)
352 TRACE("band info: xMin=%u, yMin=%u, yChild=%u, yMax=%u, yIntgl=%u\n",
354 pB
->cyMinChild
, pB
->cyChild
, pB
->cyMaxChild
, pB
->cyIntegral
);
358 REBAR_DumpBand (const REBAR_INFO
*iP
)
363 if(! TRACE_ON(rebar
) ) return;
365 TRACE("hwnd=%p: color=%08x/%08x, bands=%u, rows=%u, cSize=%d,%d\n",
366 iP
->hwndSelf
, iP
->clrText
, iP
->clrBk
, iP
->uNumBands
, iP
->uNumRows
,
367 iP
->calcSize
.cx
, iP
->calcSize
.cy
);
368 TRACE("hwnd=%p: flags=%08x, dragStart=%d,%d, dragNow=%d,%d, iGrabbedBand=%d\n",
369 iP
->hwndSelf
, iP
->fStatus
, iP
->dragStart
.x
, iP
->dragStart
.y
,
370 iP
->dragNow
.x
, iP
->dragNow
.y
,
372 TRACE("hwnd=%p: style=%08x, notify in Unicode=%s, redraw=%s\n",
373 iP
->hwndSelf
, iP
->dwStyle
, (iP
->bUnicode
)?"TRUE":"FALSE",
374 (iP
->DoRedraw
)?"TRUE":"FALSE");
375 for (i
= 0; i
< iP
->uNumBands
; i
++) {
376 pB
= REBAR_GetBand(iP
, i
);
377 TRACE("band # %u:", i
);
378 if (pB
->fMask
& RBBIM_ID
)
379 TRACE(" ID=%u", pB
->wID
);
380 if (pB
->fMask
& RBBIM_CHILD
)
381 TRACE(" child=%p", pB
->hwndChild
);
382 if (pB
->fMask
& RBBIM_COLORS
)
383 TRACE(" clrF=0x%06x clrB=0x%06x", pB
->clrFore
, pB
->clrBack
);
385 TRACE("band # %u: mask=0x%08x (%s)\n", i
, pB
->fMask
, REBAR_FmtMask(pB
->fMask
));
386 if (pB
->fMask
& RBBIM_STYLE
)
387 TRACE("band # %u: style=0x%08x (%s)\n",
388 i
, pB
->fStyle
, REBAR_FmtStyle(pB
->fStyle
));
389 TRACE("band # %u: xHeader=%u",
391 if (pB
->fMask
& (RBBIM_SIZE
| RBBIM_IDEALSIZE
| RBBIM_LPARAM
)) {
392 if (pB
->fMask
& RBBIM_SIZE
)
393 TRACE(" cx=%u", pB
->cx
);
394 if (pB
->fMask
& RBBIM_IDEALSIZE
)
395 TRACE(" xIdeal=%u", pB
->cxIdeal
);
396 if (pB
->fMask
& RBBIM_LPARAM
)
397 TRACE(" lParam=0x%08lx", pB
->lParam
);
401 TRACE("band # %u: xMin=%u, yMin=%u, yChild=%u, yMax=%u, yIntgl=%u\n",
402 i
, pB
->cxMinChild
, pB
->cyMinChild
, pB
->cyChild
, pB
->cyMaxChild
, pB
->cyIntegral
);
403 if (pB
->fMask
& RBBIM_TEXT
)
404 TRACE("band # %u: text=%s\n",
405 i
, (pB
->lpText
) ? debugstr_w(pB
->lpText
) : "(null)");
406 TRACE("band # %u: cxMinBand=%u, cxEffective=%u, cyMinBand=%u\n",
407 i
, pB
->cxMinBand
, pB
->cxEffective
, pB
->cyMinBand
);
408 TRACE("band # %u: fStatus=%08x, fDraw=%08x, Band=(%s), Grip=(%s)\n",
409 i
, pB
->fStatus
, pB
->fDraw
, wine_dbgstr_rect(&pB
->rcBand
),
410 wine_dbgstr_rect(&pB
->rcGripper
));
411 TRACE("band # %u: Img=(%s), Txt=(%s), Child=(%s)\n",
412 i
, wine_dbgstr_rect(&pB
->rcCapImage
),
413 wine_dbgstr_rect(&pB
->rcCapText
), wine_dbgstr_rect(&pB
->rcChild
));
418 /* dest can be equal to src */
419 static void translate_rect(const REBAR_INFO
*infoPtr
, RECT
*dest
, const RECT
*src
)
421 if (infoPtr
->dwStyle
& CCS_VERT
) {
424 dest
->left
= src
->top
;
428 dest
->right
= src
->bottom
;
435 static int get_rect_cx(const REBAR_INFO
*infoPtr
, const RECT
*lpRect
)
437 if (infoPtr
->dwStyle
& CCS_VERT
)
438 return lpRect
->bottom
- lpRect
->top
;
439 return lpRect
->right
- lpRect
->left
;
442 static int get_rect_cy(const REBAR_INFO
*infoPtr
, const RECT
*lpRect
)
444 if (infoPtr
->dwStyle
& CCS_VERT
)
445 return lpRect
->right
- lpRect
->left
;
446 return lpRect
->bottom
- lpRect
->top
;
449 static int round_child_height(const REBAR_BAND
*lpBand
, int cyHeight
)
452 if (lpBand
->cyIntegral
== 0)
454 cy
= max(cyHeight
- (int)lpBand
->cyMinChild
, 0);
455 cy
= lpBand
->cyMinChild
+ (cy
/lpBand
->cyIntegral
) * lpBand
->cyIntegral
;
456 cy
= min(cy
, lpBand
->cyMaxChild
);
460 static void update_min_band_height(const REBAR_INFO
*infoPtr
, REBAR_BAND
*lpBand
)
462 lpBand
->cyMinBand
= max(lpBand
->cyHeader
,
463 (lpBand
->hwndChild
? lpBand
->cyChild
+ REBARSPACE(lpBand
) : REBAR_NO_CHILD_HEIGHT
));
467 REBAR_DrawChevron (HDC hdc
, INT left
, INT top
, INT colorRef
)
472 if (!(hPen
= CreatePen( PS_SOLID
, 1, GetSysColor( colorRef
)))) return;
473 hOldPen
= SelectObject ( hdc
, hPen
);
476 MoveToEx (hdc
, x
, y
, NULL
);
477 LineTo (hdc
, x
+5, y
++); x
++;
478 MoveToEx (hdc
, x
, y
, NULL
);
479 LineTo (hdc
, x
+3, y
++); x
++;
480 MoveToEx (hdc
, x
, y
, NULL
);
481 LineTo (hdc
, x
+1, y
);
482 SelectObject( hdc
, hOldPen
);
483 DeleteObject( hPen
);
487 REBAR_GetNotifyParent (const REBAR_INFO
*infoPtr
)
491 parent
= infoPtr
->hwndNotify
;
493 parent
= GetParent (infoPtr
->hwndSelf
);
494 owner
= GetWindow (infoPtr
->hwndSelf
, GW_OWNER
);
495 if (owner
) parent
= owner
;
502 REBAR_Notify (NMHDR
*nmhdr
, const REBAR_INFO
*infoPtr
, UINT code
)
506 parent
= REBAR_GetNotifyParent (infoPtr
);
507 nmhdr
->idFrom
= GetDlgCtrlID (infoPtr
->hwndSelf
);
508 nmhdr
->hwndFrom
= infoPtr
->hwndSelf
;
511 TRACE("window %p, code=%08x, via %s\n", parent
, code
, (infoPtr
->bUnicode
)?"Unicode":"ANSI");
513 return SendMessageW(parent
, WM_NOTIFY
, nmhdr
->idFrom
, (LPARAM
)nmhdr
);
517 REBAR_Notify_NMREBAR (const REBAR_INFO
*infoPtr
, UINT uBand
, UINT code
)
519 NMREBAR notify_rebar
;
521 notify_rebar
.dwMask
= 0;
523 REBAR_BAND
*lpBand
= REBAR_GetBand(infoPtr
, uBand
);
525 if (lpBand
->fMask
& RBBIM_ID
) {
526 notify_rebar
.dwMask
|= RBNM_ID
;
527 notify_rebar
.wID
= lpBand
->wID
;
529 if (lpBand
->fMask
& RBBIM_LPARAM
) {
530 notify_rebar
.dwMask
|= RBNM_LPARAM
;
531 notify_rebar
.lParam
= lpBand
->lParam
;
533 if (lpBand
->fMask
& RBBIM_STYLE
) {
534 notify_rebar
.dwMask
|= RBNM_STYLE
;
535 notify_rebar
.fStyle
= lpBand
->fStyle
;
538 notify_rebar
.uBand
= uBand
;
539 return REBAR_Notify ((NMHDR
*)¬ify_rebar
, infoPtr
, code
);
543 REBAR_DrawBand (HDC hdc
, const REBAR_INFO
*infoPtr
, REBAR_BAND
*lpBand
)
548 HTHEME theme
= GetWindowTheme (infoPtr
->hwndSelf
);
551 translate_rect(infoPtr
, &rcBand
, &lpBand
->rcBand
);
553 if (lpBand
->fDraw
& DRAW_TEXT
) {
554 hOldFont
= SelectObject (hdc
, infoPtr
->hFont
);
555 oldBkMode
= SetBkMode (hdc
, TRANSPARENT
);
558 /* should test for CDRF_NOTIFYITEMDRAW here */
559 nmcd
.dwDrawStage
= CDDS_ITEMPREPAINT
;
562 nmcd
.rc
.right
= lpBand
->rcCapText
.right
;
563 nmcd
.rc
.bottom
= lpBand
->rcCapText
.bottom
;
564 nmcd
.dwItemSpec
= lpBand
->wID
;
566 nmcd
.lItemlParam
= lpBand
->lParam
;
567 lpBand
->uCDret
= REBAR_Notify ((NMHDR
*)&nmcd
, infoPtr
, NM_CUSTOMDRAW
);
568 if (lpBand
->uCDret
== CDRF_SKIPDEFAULT
) {
569 if (oldBkMode
!= TRANSPARENT
)
570 SetBkMode (hdc
, oldBkMode
);
571 SelectObject (hdc
, hOldFont
);
576 if (lpBand
->fDraw
& DRAW_GRIPPER
)
580 RECT rcGripper
= lpBand
->rcGripper
;
581 int partId
= (infoPtr
->dwStyle
& CCS_VERT
) ? RP_GRIPPERVERT
: RP_GRIPPER
;
582 GetThemeBackgroundExtent (theme
, hdc
, partId
, 0, &rcGripper
, &rcGripper
);
583 OffsetRect (&rcGripper
, lpBand
->rcGripper
.left
- rcGripper
.left
,
584 lpBand
->rcGripper
.top
- rcGripper
.top
);
585 DrawThemeBackground (theme
, hdc
, partId
, 0, &rcGripper
, NULL
);
588 DrawEdge (hdc
, &lpBand
->rcGripper
, BDR_RAISEDINNER
, BF_RECT
| BF_MIDDLE
);
591 /* draw caption image */
592 if (lpBand
->fDraw
& DRAW_IMAGE
) {
596 pt
.y
= (lpBand
->rcCapImage
.bottom
+ lpBand
->rcCapImage
.top
- infoPtr
->imageSize
.cy
)/2;
597 pt
.x
= (lpBand
->rcCapImage
.right
+ lpBand
->rcCapImage
.left
- infoPtr
->imageSize
.cx
)/2;
599 ImageList_Draw (infoPtr
->himl
, lpBand
->iImage
, hdc
,
604 /* draw caption text */
605 if (lpBand
->fDraw
& DRAW_TEXT
) {
606 /* need to handle CDRF_NEWFONT here */
607 INT oldBkMode
= SetBkMode (hdc
, TRANSPARENT
);
608 COLORREF oldcolor
= CLR_NONE
;
610 if (lpBand
->clrFore
!= CLR_NONE
) {
611 new = (lpBand
->clrFore
== CLR_DEFAULT
) ? infoPtr
->clrBtnText
:
613 oldcolor
= SetTextColor (hdc
, new);
615 DrawTextW (hdc
, lpBand
->lpText
, -1, &lpBand
->rcCapText
,
616 DT_CENTER
| DT_VCENTER
| DT_SINGLELINE
);
617 if (oldBkMode
!= TRANSPARENT
)
618 SetBkMode (hdc
, oldBkMode
);
619 if (lpBand
->clrFore
!= CLR_NONE
)
620 SetTextColor (hdc
, oldcolor
);
621 SelectObject (hdc
, hOldFont
);
624 if (!IsRectEmpty(&lpBand
->rcChevron
))
629 if (lpBand
->fDraw
& DRAW_CHEVRONPUSHED
)
630 stateId
= CHEVS_PRESSED
;
631 else if (lpBand
->fDraw
& DRAW_CHEVRONHOT
)
634 stateId
= CHEVS_NORMAL
;
635 DrawThemeBackground (theme
, hdc
, RP_CHEVRON
, stateId
, &lpBand
->rcChevron
, NULL
);
639 if (lpBand
->fDraw
& DRAW_CHEVRONPUSHED
)
641 DrawEdge(hdc
, &lpBand
->rcChevron
, BDR_SUNKENOUTER
, BF_RECT
| BF_MIDDLE
);
642 REBAR_DrawChevron(hdc
, lpBand
->rcChevron
.left
+1, lpBand
->rcChevron
.top
+ 11, COLOR_WINDOWFRAME
);
644 else if (lpBand
->fDraw
& DRAW_CHEVRONHOT
)
646 DrawEdge(hdc
, &lpBand
->rcChevron
, BDR_RAISEDINNER
, BF_RECT
| BF_MIDDLE
);
647 REBAR_DrawChevron(hdc
, lpBand
->rcChevron
.left
, lpBand
->rcChevron
.top
+ 10, COLOR_WINDOWFRAME
);
650 REBAR_DrawChevron(hdc
, lpBand
->rcChevron
.left
, lpBand
->rcChevron
.top
+ 10, COLOR_WINDOWFRAME
);
654 if (lpBand
->uCDret
== (CDRF_NOTIFYPOSTPAINT
| CDRF_NOTIFYITEMDRAW
)) {
655 nmcd
.dwDrawStage
= CDDS_ITEMPOSTPAINT
;
658 nmcd
.rc
.right
= lpBand
->rcCapText
.right
;
659 nmcd
.rc
.bottom
= lpBand
->rcCapText
.bottom
;
660 nmcd
.dwItemSpec
= lpBand
->wID
;
662 nmcd
.lItemlParam
= lpBand
->lParam
;
663 lpBand
->uCDret
= REBAR_Notify ((NMHDR
*)&nmcd
, infoPtr
, NM_CUSTOMDRAW
);
669 REBAR_Refresh (const REBAR_INFO
*infoPtr
, HDC hdc
)
674 if (!infoPtr
->DoRedraw
) return;
676 for (i
= 0; i
< infoPtr
->uNumBands
; i
++) {
677 lpBand
= REBAR_GetBand(infoPtr
, i
);
679 if (HIDDENBAND(lpBand
)) continue;
681 /* now draw the band */
682 TRACE("[%p] drawing band %i, flags=%08x\n",
683 infoPtr
->hwndSelf
, i
, lpBand
->fDraw
);
684 REBAR_DrawBand (hdc
, infoPtr
, lpBand
);
690 REBAR_CalcHorzBand (const REBAR_INFO
*infoPtr
, UINT rstart
, UINT rend
)
691 /* Function: this routine initializes all the rectangles in */
692 /* each band in a row to fit in the adjusted rcBand rect. */
693 /* *** Supports only Horizontal bars. *** */
699 for(i
=rstart
; i
<rend
; i
++){
700 lpBand
= REBAR_GetBand(infoPtr
, i
);
701 if (HIDDENBAND(lpBand
)) {
702 SetRect (&lpBand
->rcChild
,
703 lpBand
->rcBand
.right
, lpBand
->rcBand
.top
,
704 lpBand
->rcBand
.right
, lpBand
->rcBand
.bottom
);
708 /* set initial gripper rectangle */
709 SetRect (&lpBand
->rcGripper
, lpBand
->rcBand
.left
, lpBand
->rcBand
.top
,
710 lpBand
->rcBand
.left
, lpBand
->rcBand
.bottom
);
712 /* calculate gripper rectangle */
713 if ( lpBand
->fStatus
& HAS_GRIPPER
) {
714 lpBand
->fDraw
|= DRAW_GRIPPER
;
715 lpBand
->rcGripper
.left
+= REBAR_PRE_GRIPPER
;
716 lpBand
->rcGripper
.right
= lpBand
->rcGripper
.left
+ GRIPPER_WIDTH
;
717 lpBand
->rcGripper
.top
+= 2;
718 lpBand
->rcGripper
.bottom
-= 2;
720 SetRect (&lpBand
->rcCapImage
,
721 lpBand
->rcGripper
.right
+REBAR_ALWAYS_SPACE
, lpBand
->rcBand
.top
,
722 lpBand
->rcGripper
.right
+REBAR_ALWAYS_SPACE
, lpBand
->rcBand
.bottom
);
724 else { /* no gripper will be drawn */
726 if (lpBand
->fStatus
& (HAS_IMAGE
| HAS_TEXT
))
727 /* if no gripper but either image or text, then leave space */
728 xoff
= REBAR_ALWAYS_SPACE
;
729 SetRect (&lpBand
->rcCapImage
,
730 lpBand
->rcBand
.left
+xoff
, lpBand
->rcBand
.top
,
731 lpBand
->rcBand
.left
+xoff
, lpBand
->rcBand
.bottom
);
734 /* image is visible */
735 if (lpBand
->fStatus
& HAS_IMAGE
) {
736 lpBand
->fDraw
|= DRAW_IMAGE
;
737 lpBand
->rcCapImage
.right
+= infoPtr
->imageSize
.cx
;
738 lpBand
->rcCapImage
.bottom
= lpBand
->rcCapImage
.top
+ infoPtr
->imageSize
.cy
;
740 /* set initial caption text rectangle */
741 SetRect (&lpBand
->rcCapText
,
742 lpBand
->rcCapImage
.right
+REBAR_POST_IMAGE
, lpBand
->rcBand
.top
+1,
743 lpBand
->rcBand
.left
+lpBand
->cxHeader
, lpBand
->rcBand
.bottom
-1);
746 /* set initial caption text rectangle */
747 SetRect (&lpBand
->rcCapText
, lpBand
->rcCapImage
.right
, lpBand
->rcBand
.top
+1,
748 lpBand
->rcBand
.left
+lpBand
->cxHeader
, lpBand
->rcBand
.bottom
-1);
751 /* text is visible */
752 if ((lpBand
->fStatus
& HAS_TEXT
) && !(lpBand
->fStyle
& RBBS_HIDETITLE
)) {
753 lpBand
->fDraw
|= DRAW_TEXT
;
754 lpBand
->rcCapText
.right
= max(lpBand
->rcCapText
.left
,
755 lpBand
->rcCapText
.right
-REBAR_POST_TEXT
);
758 /* set initial child window rectangle if there is a child */
759 if (lpBand
->hwndChild
) {
761 lpBand
->rcChild
.left
= lpBand
->rcBand
.left
+ lpBand
->cxHeader
;
762 lpBand
->rcChild
.right
= lpBand
->rcBand
.right
- REBAR_POST_CHILD
;
764 if (lpBand
->cyChild
> 0) {
766 UINT yoff
= (lpBand
->rcBand
.bottom
- lpBand
->rcBand
.top
- lpBand
->cyChild
) / 2;
768 /* center child if height is known */
769 lpBand
->rcChild
.top
= lpBand
->rcBand
.top
+ yoff
;
770 lpBand
->rcChild
.bottom
= lpBand
->rcBand
.top
+ yoff
+ lpBand
->cyChild
;
773 lpBand
->rcChild
.top
= lpBand
->rcBand
.top
;
774 lpBand
->rcChild
.bottom
= lpBand
->rcBand
.bottom
;
777 if ((lpBand
->fStyle
& RBBS_USECHEVRON
) && (lpBand
->rcChild
.right
- lpBand
->rcChild
.left
< lpBand
->cxIdeal
))
779 lpBand
->rcChild
.right
-= CHEVRON_WIDTH
;
780 SetRect(&lpBand
->rcChevron
, lpBand
->rcChild
.right
,
781 lpBand
->rcChild
.top
, lpBand
->rcChild
.right
+ CHEVRON_WIDTH
,
782 lpBand
->rcChild
.bottom
);
786 SetRect (&lpBand
->rcChild
,
787 lpBand
->rcBand
.left
+lpBand
->cxHeader
, lpBand
->rcBand
.top
,
788 lpBand
->rcBand
.right
, lpBand
->rcBand
.bottom
);
791 /* flag if notify required and invalidate rectangle */
792 if (lpBand
->fDraw
& NTF_INVALIDATE
) {
793 TRACE("invalidating (%d,%d)-(%d,%d)\n",
796 lpBand
->rcBand
.right
+ SEP_WIDTH
,
797 lpBand
->rcBand
.bottom
+ SEP_WIDTH
);
798 lpBand
->fDraw
&= ~NTF_INVALIDATE
;
799 work
= lpBand
->rcBand
;
800 work
.right
+= SEP_WIDTH
;
801 work
.bottom
+= SEP_WIDTH
;
802 InvalidateRect(infoPtr
->hwndSelf
, &work
, TRUE
);
803 if (lpBand
->hwndChild
) InvalidateRect(lpBand
->hwndChild
, NULL
, TRUE
);
812 REBAR_CalcVertBand (const REBAR_INFO
*infoPtr
, UINT rstart
, UINT rend
)
813 /* Function: this routine initializes all the rectangles in */
814 /* each band in a row to fit in the adjusted rcBand rect. */
815 /* *** Supports only Vertical bars. *** */
821 for(i
=rstart
; i
<rend
; i
++){
823 lpBand
= REBAR_GetBand(infoPtr
, i
);
824 if (HIDDENBAND(lpBand
)) continue;
826 translate_rect(infoPtr
, &rcBand
, &lpBand
->rcBand
);
828 /* set initial gripper rectangle */
829 SetRect (&lpBand
->rcGripper
, rcBand
.left
, rcBand
.top
, rcBand
.right
, rcBand
.top
);
831 /* calculate gripper rectangle */
832 if (lpBand
->fStatus
& HAS_GRIPPER
) {
833 lpBand
->fDraw
|= DRAW_GRIPPER
;
835 if (infoPtr
->dwStyle
& RBS_VERTICALGRIPPER
) {
836 /* vertical gripper */
837 lpBand
->rcGripper
.left
+= 3;
838 lpBand
->rcGripper
.right
= lpBand
->rcGripper
.left
+ GRIPPER_WIDTH
;
839 lpBand
->rcGripper
.top
+= REBAR_PRE_GRIPPER
;
840 lpBand
->rcGripper
.bottom
= lpBand
->rcGripper
.top
+ GRIPPER_HEIGHT
;
842 /* initialize Caption image rectangle */
843 SetRect (&lpBand
->rcCapImage
, rcBand
.left
,
844 lpBand
->rcGripper
.bottom
+ REBAR_ALWAYS_SPACE
,
846 lpBand
->rcGripper
.bottom
+ REBAR_ALWAYS_SPACE
);
849 /* horizontal gripper */
850 lpBand
->rcGripper
.left
+= 2;
851 lpBand
->rcGripper
.right
-= 2;
852 lpBand
->rcGripper
.top
+= REBAR_PRE_GRIPPER
;
853 lpBand
->rcGripper
.bottom
= lpBand
->rcGripper
.top
+ GRIPPER_WIDTH
;
855 /* initialize Caption image rectangle */
856 SetRect (&lpBand
->rcCapImage
, rcBand
.left
,
857 lpBand
->rcGripper
.bottom
+ REBAR_ALWAYS_SPACE
,
859 lpBand
->rcGripper
.bottom
+ REBAR_ALWAYS_SPACE
);
862 else { /* no gripper will be drawn */
864 if (lpBand
->fStatus
& (HAS_IMAGE
| HAS_TEXT
))
865 /* if no gripper but either image or text, then leave space */
866 xoff
= REBAR_ALWAYS_SPACE
;
867 /* initialize Caption image rectangle */
868 SetRect (&lpBand
->rcCapImage
,
869 rcBand
.left
, rcBand
.top
+xoff
,
870 rcBand
.right
, rcBand
.top
+xoff
);
873 /* image is visible */
874 if (lpBand
->fStatus
& HAS_IMAGE
) {
875 lpBand
->fDraw
|= DRAW_IMAGE
;
877 lpBand
->rcCapImage
.right
= lpBand
->rcCapImage
.left
+ infoPtr
->imageSize
.cx
;
878 lpBand
->rcCapImage
.bottom
+= infoPtr
->imageSize
.cy
;
880 /* set initial caption text rectangle */
881 SetRect (&lpBand
->rcCapText
,
882 rcBand
.left
, lpBand
->rcCapImage
.bottom
+REBAR_POST_IMAGE
,
883 rcBand
.right
, rcBand
.top
+lpBand
->cxHeader
);
886 /* set initial caption text rectangle */
887 SetRect (&lpBand
->rcCapText
,
888 rcBand
.left
, lpBand
->rcCapImage
.bottom
,
889 rcBand
.right
, rcBand
.top
+lpBand
->cxHeader
);
892 /* text is visible */
893 if ((lpBand
->fStatus
& HAS_TEXT
) && !(lpBand
->fStyle
& RBBS_HIDETITLE
)) {
894 lpBand
->fDraw
|= DRAW_TEXT
;
895 lpBand
->rcCapText
.bottom
= max(lpBand
->rcCapText
.top
,
896 lpBand
->rcCapText
.bottom
);
899 /* set initial child window rectangle if there is a child */
900 if (lpBand
->hwndChild
) {
901 int cxBand
= rcBand
.right
- rcBand
.left
;
902 xoff
= (cxBand
- lpBand
->cyChild
) / 2;
903 SetRect (&lpBand
->rcChild
,
904 rcBand
.left
+ xoff
, rcBand
.top
+ lpBand
->cxHeader
,
905 rcBand
.left
+ xoff
+ lpBand
->cyChild
, rcBand
.bottom
- REBAR_POST_CHILD
);
908 SetRect (&lpBand
->rcChild
,
909 rcBand
.left
, rcBand
.top
+lpBand
->cxHeader
,
910 rcBand
.right
, rcBand
.bottom
);
913 if (lpBand
->fDraw
& NTF_INVALIDATE
) {
914 TRACE("invalidating (%d,%d)-(%d,%d)\n",
917 rcBand
.right
+ SEP_WIDTH
,
918 rcBand
.bottom
+ SEP_WIDTH
);
919 lpBand
->fDraw
&= ~NTF_INVALIDATE
;
921 work
.bottom
+= SEP_WIDTH
;
922 work
.right
+= SEP_WIDTH
;
923 InvalidateRect(infoPtr
->hwndSelf
, &work
, TRUE
);
924 if (lpBand
->hwndChild
) InvalidateRect(lpBand
->hwndChild
, NULL
, TRUE
);
932 REBAR_ForceResize (REBAR_INFO
*infoPtr
)
933 /* Function: This changes the size of the REBAR window to that */
934 /* calculated by REBAR_Layout. */
936 INT x
, y
, width
, height
;
937 INT xedge
= 0, yedge
= 0;
940 TRACE("new size [%d x %d]\n", infoPtr
->calcSize
.cx
, infoPtr
->calcSize
.cy
);
942 if (infoPtr
->dwStyle
& CCS_NORESIZE
)
945 if (infoPtr
->dwStyle
& WS_BORDER
)
947 xedge
= GetSystemMetrics(SM_CXEDGE
);
948 yedge
= GetSystemMetrics(SM_CYEDGE
);
949 /* swap for CCS_VERT? */
952 /* compute rebar window rect in parent client coordinates */
953 GetWindowRect(infoPtr
->hwndSelf
, &rcSelf
);
954 MapWindowPoints(HWND_DESKTOP
, GetParent(infoPtr
->hwndSelf
), (LPPOINT
)&rcSelf
, 2);
955 translate_rect(infoPtr
, &rcSelf
, &rcSelf
);
957 height
= infoPtr
->calcSize
.cy
+ 2*yedge
;
958 if (!(infoPtr
->dwStyle
& CCS_NOPARENTALIGN
)) {
962 width
= infoPtr
->calcSize
.cx
+ 2*xedge
;
963 y
= 0; /* quiet compiler warning */
964 switch ( infoPtr
->dwStyle
& CCS_LAYOUT_MASK
) {
965 case 0: /* shouldn't happen - see NCCreate */
967 y
= ((infoPtr
->dwStyle
& CCS_NODIVIDER
) ? 0 : REBAR_DIVIDER
) - yedge
;
973 GetClientRect(GetParent(infoPtr
->hwndSelf
), &rcParent
);
974 translate_rect(infoPtr
, &rcParent
, &rcParent
);
975 y
= rcParent
.bottom
- infoPtr
->calcSize
.cy
- yedge
;
981 /* As on Windows if the CCS_NODIVIDER is not present the control will move
982 * 2 pixel down after every layout */
983 y
= rcSelf
.top
+ ((infoPtr
->dwStyle
& CCS_NODIVIDER
) ? 0 : REBAR_DIVIDER
);
984 width
= rcSelf
.right
- rcSelf
.left
;
987 TRACE("hwnd %p, style=%08x, setting at (%d,%d) for (%d,%d)\n",
988 infoPtr
->hwndSelf
, infoPtr
->dwStyle
, x
, y
, width
, height
);
990 /* Set flag to ignore next WM_SIZE message and resize the window */
991 infoPtr
->fStatus
|= SELF_RESIZE
;
992 if ((infoPtr
->dwStyle
& CCS_VERT
) == 0)
993 SetWindowPos(infoPtr
->hwndSelf
, 0, x
, y
, width
, height
, SWP_NOZORDER
);
995 SetWindowPos(infoPtr
->hwndSelf
, 0, y
, x
, height
, width
, SWP_NOZORDER
);
996 infoPtr
->fStatus
&= ~SELF_RESIZE
;
1001 REBAR_MoveChildWindows (const REBAR_INFO
*infoPtr
, UINT start
, UINT endplus
)
1003 static const WCHAR strComboBox
[] = { 'C','o','m','b','o','B','o','x',0 };
1005 WCHAR szClassName
[40];
1007 NMREBARCHILDSIZE rbcz
;
1010 if (!(deferpos
= BeginDeferWindowPos(infoPtr
->uNumBands
)))
1011 ERR("BeginDeferWindowPos returned NULL\n");
1013 for (i
= start
; i
< endplus
; i
++) {
1014 lpBand
= REBAR_GetBand(infoPtr
, i
);
1016 if (HIDDENBAND(lpBand
)) continue;
1017 if (lpBand
->hwndChild
) {
1018 TRACE("hwndChild = %p\n", lpBand
->hwndChild
);
1020 /* Always generate the RBN_CHILDSIZE even if child
1023 rbcz
.wID
= lpBand
->wID
;
1024 rbcz
.rcChild
= lpBand
->rcChild
;
1025 translate_rect(infoPtr
, &rbcz
.rcBand
, &lpBand
->rcBand
);
1026 if (infoPtr
->dwStyle
& CCS_VERT
)
1027 rbcz
.rcBand
.top
+= lpBand
->cxHeader
;
1029 rbcz
.rcBand
.left
+= lpBand
->cxHeader
;
1030 REBAR_Notify ((NMHDR
*)&rbcz
, infoPtr
, RBN_CHILDSIZE
);
1031 if (!EqualRect (&lpBand
->rcChild
, &rbcz
.rcChild
)) {
1032 TRACE("Child rect changed by NOTIFY for band %u\n", i
);
1033 TRACE(" from (%s) to (%s)\n",
1034 wine_dbgstr_rect(&lpBand
->rcChild
),
1035 wine_dbgstr_rect(&rbcz
.rcChild
));
1036 lpBand
->rcChild
= rbcz
.rcChild
; /* *** ??? */
1039 GetClassNameW (lpBand
->hwndChild
, szClassName
, sizeof(szClassName
)/sizeof(szClassName
[0]));
1040 if (!lstrcmpW (szClassName
, strComboBox
) ||
1041 !lstrcmpW (szClassName
, WC_COMBOBOXEXW
)) {
1042 INT nEditHeight
, yPos
;
1045 /* special placement code for combo or comboex box */
1048 /* get size of edit line */
1049 GetWindowRect (lpBand
->hwndChild
, &rc
);
1050 nEditHeight
= rc
.bottom
- rc
.top
;
1051 yPos
= (lpBand
->rcChild
.bottom
+ lpBand
->rcChild
.top
- nEditHeight
)/2;
1053 /* center combo box inside child area */
1054 TRACE("moving child (Combo(Ex)) %p to (%d,%d) for (%d,%d)\n",
1056 lpBand
->rcChild
.left
, yPos
,
1057 lpBand
->rcChild
.right
- lpBand
->rcChild
.left
,
1059 deferpos
= DeferWindowPos (deferpos
, lpBand
->hwndChild
, HWND_TOP
,
1060 lpBand
->rcChild
.left
,
1061 /*lpBand->rcChild.top*/ yPos
,
1062 lpBand
->rcChild
.right
- lpBand
->rcChild
.left
,
1066 ERR("DeferWindowPos returned NULL\n");
1069 TRACE("moving child (Other) %p to (%d,%d) for (%d,%d)\n",
1071 lpBand
->rcChild
.left
, lpBand
->rcChild
.top
,
1072 lpBand
->rcChild
.right
- lpBand
->rcChild
.left
,
1073 lpBand
->rcChild
.bottom
- lpBand
->rcChild
.top
);
1074 deferpos
= DeferWindowPos (deferpos
, lpBand
->hwndChild
, HWND_TOP
,
1075 lpBand
->rcChild
.left
,
1076 lpBand
->rcChild
.top
,
1077 lpBand
->rcChild
.right
- lpBand
->rcChild
.left
,
1078 lpBand
->rcChild
.bottom
- lpBand
->rcChild
.top
,
1081 ERR("DeferWindowPos returned NULL\n");
1085 if (!EndDeferWindowPos(deferpos
))
1086 ERR("EndDeferWindowPos returned NULL\n");
1088 if (infoPtr
->DoRedraw
)
1089 UpdateWindow (infoPtr
->hwndSelf
);
1092 /* Returns the next visible band (the first visible band in [i+1; infoPtr->uNumBands) )
1093 * or infoPtr->uNumBands if none */
1094 static int next_visible(const REBAR_INFO
*infoPtr
, int i
)
1097 for (n
= i
+ 1; n
< infoPtr
->uNumBands
; n
++)
1098 if (!HIDDENBAND(REBAR_GetBand(infoPtr
, n
)))
1103 /* Returns the previous visible band (the last visible band in [0; i) )
1105 static int prev_visible(const REBAR_INFO
*infoPtr
, int i
)
1108 for (n
= i
- 1; n
>= 0; n
--)
1109 if (!HIDDENBAND(REBAR_GetBand(infoPtr
, n
)))
1114 /* Returns the first visible band or infoPtr->uNumBands if none */
1115 static int first_visible(const REBAR_INFO
*infoPtr
)
1117 return next_visible(infoPtr
, -1); /* this works*/
1120 /* Returns the first visible band for the given row (or iBand if none) */
1121 static int get_row_begin_for_band(const REBAR_INFO
*infoPtr
, INT iBand
)
1123 int iLastBand
= iBand
;
1124 int iRow
= REBAR_GetBand(infoPtr
, iBand
)->iRow
;
1125 while ((iBand
= prev_visible(infoPtr
, iBand
)) >= 0) {
1126 if (REBAR_GetBand(infoPtr
, iBand
)->iRow
!= iRow
)
1134 /* Returns the first visible band for the next row (or infoPtr->uNumBands if none) */
1135 static int get_row_end_for_band(const REBAR_INFO
*infoPtr
, INT iBand
)
1137 int iRow
= REBAR_GetBand(infoPtr
, iBand
)->iRow
;
1138 while ((iBand
= next_visible(infoPtr
, iBand
)) < infoPtr
->uNumBands
)
1139 if (REBAR_GetBand(infoPtr
, iBand
)->iRow
!= iRow
)
1144 /* Compute the rcBand.{left,right} from the cxEffective bands widths computed earlier.
1145 * iBeginBand must be visible */
1146 static void REBAR_SetRowRectsX(const REBAR_INFO
*infoPtr
, INT iBeginBand
, INT iEndBand
)
1149 for (i
= iBeginBand
; i
< iEndBand
; i
= next_visible(infoPtr
, i
))
1151 REBAR_BAND
*lpBand
= REBAR_GetBand(infoPtr
, i
);
1152 if (lpBand
->rcBand
.left
!= xPos
|| lpBand
->rcBand
.right
!= xPos
+ lpBand
->cxEffective
) {
1153 lpBand
->fDraw
|= NTF_INVALIDATE
;
1154 TRACE("Setting rect %d to %d,%d\n", i
, xPos
, xPos
+ lpBand
->cxEffective
);
1155 lpBand
->rcBand
.left
= xPos
;
1156 lpBand
->rcBand
.right
= xPos
+ lpBand
->cxEffective
;
1158 xPos
+= lpBand
->cxEffective
+ SEP_WIDTH
;
1162 /* The rationale of this function is probably as follows: if we have some space
1163 * to distribute we want to add it to a band on the right. However we don't want
1164 * to unminimize a minimized band so we search for a band that is big enough.
1165 * For some reason "big enough" is defined as bigger than the minimum size of the
1166 * first band in the row
1168 static REBAR_BAND
*REBAR_FindBandToGrow(const REBAR_INFO
*infoPtr
, INT iBeginBand
, INT iEndBand
)
1170 INT cxMinFirstBand
= 0, i
;
1172 cxMinFirstBand
= REBAR_GetBand(infoPtr
, iBeginBand
)->cxMinBand
;
1174 for (i
= prev_visible(infoPtr
, iEndBand
); i
>= iBeginBand
; i
= prev_visible(infoPtr
, i
))
1175 if (REBAR_GetBand(infoPtr
, i
)->cxEffective
> cxMinFirstBand
&&
1176 !(REBAR_GetBand(infoPtr
, i
)->fStyle
& RBBS_FIXEDSIZE
))
1180 for (i
= prev_visible(infoPtr
, iEndBand
); i
>= iBeginBand
; i
= prev_visible(infoPtr
, i
))
1181 if (REBAR_GetBand(infoPtr
, i
)->cxMinBand
== cxMinFirstBand
)
1184 TRACE("Extra space for row [%d..%d) should be added to band %d\n", iBeginBand
, iEndBand
, i
);
1185 return REBAR_GetBand(infoPtr
, i
);
1188 /* Try to shrink the visible bands in [iBeginBand; iEndBand) by cxShrink, starting from the right */
1189 static int REBAR_ShrinkBandsRTL(const REBAR_INFO
*infoPtr
, INT iBeginBand
, INT iEndBand
, INT cxShrink
, BOOL bEnforce
)
1194 TRACE("Shrinking bands [%d..%d) by %d, right-to-left\n", iBeginBand
, iEndBand
, cxShrink
);
1195 for (i
= prev_visible(infoPtr
, iEndBand
); i
>= iBeginBand
; i
= prev_visible(infoPtr
, i
))
1197 lpBand
= REBAR_GetBand(infoPtr
, i
);
1199 width
= max(lpBand
->cxEffective
- cxShrink
, (int)lpBand
->cxMinBand
);
1200 cxShrink
-= lpBand
->cxEffective
- width
;
1201 lpBand
->cxEffective
= width
;
1202 if (bEnforce
&& lpBand
->cx
> lpBand
->cxEffective
)
1203 lpBand
->cx
= lpBand
->cxEffective
;
1211 /* Try to shrink the visible bands in [iBeginBand; iEndBand) by cxShrink, starting from the left.
1212 * iBeginBand must be visible */
1213 static int REBAR_ShrinkBandsLTR(const REBAR_INFO
*infoPtr
, INT iBeginBand
, INT iEndBand
, INT cxShrink
, BOOL bEnforce
)
1218 TRACE("Shrinking bands [%d..%d) by %d, left-to-right\n", iBeginBand
, iEndBand
, cxShrink
);
1219 for (i
= iBeginBand
; i
< iEndBand
; i
= next_visible(infoPtr
, i
))
1221 lpBand
= REBAR_GetBand(infoPtr
, i
);
1223 width
= max(lpBand
->cxEffective
- cxShrink
, (int)lpBand
->cxMinBand
);
1224 cxShrink
-= lpBand
->cxEffective
- width
;
1225 lpBand
->cxEffective
= width
;
1227 lpBand
->cx
= lpBand
->cxEffective
;
1234 /* Tries to move a band to a given offset within a row. */
1235 static int REBAR_MoveBandToRowOffset(REBAR_INFO
*infoPtr
, INT iBand
, INT iFirstBand
,
1236 INT iLastBand
, INT xOff
, BOOL reorder
)
1238 REBAR_BAND
*insertBand
= REBAR_GetBand(infoPtr
, iBand
);
1240 const BOOL setBreak
= REBAR_GetBand(infoPtr
, iFirstBand
)->fStyle
& RBBS_BREAK
;
1242 /* Find the band's new position */
1245 /* Used during an LR band reorder drag */
1246 for (i
= iFirstBand
; i
< iLastBand
; i
= next_visible(infoPtr
, i
))
1250 xPos
+= REBAR_GetBand(infoPtr
, i
)->cxEffective
+ SEP_WIDTH
;
1255 /* Used during a UD band insertion drag */
1256 for (i
= iFirstBand
; i
< iLastBand
; i
= next_visible(infoPtr
, i
))
1258 const REBAR_BAND
*band
= REBAR_GetBand(infoPtr
, i
);
1259 if(xPos
+ band
->cxMinBand
/ 2 > xOff
)
1261 xPos
+= band
->cxEffective
+ SEP_WIDTH
;
1265 /* Move the band to its new position */
1266 DPA_DeletePtr(infoPtr
->bands
, iBand
);
1269 DPA_InsertPtr(infoPtr
->bands
, i
, insertBand
);
1271 /* Ensure only the last band has the RBBS_BREAK flag set */
1272 insertBand
->fStyle
&= ~RBBS_BREAK
;
1274 REBAR_GetBand(infoPtr
, iFirstBand
)->fStyle
|= RBBS_BREAK
;
1276 /* Return the currently grabbed band */
1277 if(infoPtr
->iGrabbedBand
== iBand
)
1279 infoPtr
->iGrabbedBand
= i
;
1285 /* Set the heights of the visible bands in [iBeginBand; iEndBand) to the max height. iBeginBand must be visible */
1286 static int REBAR_SetBandsHeight(const REBAR_INFO
*infoPtr
, INT iBeginBand
, INT iEndBand
, INT yStart
)
1291 int row
= REBAR_GetBand(infoPtr
, iBeginBand
)->iRow
;
1293 for (i
= iBeginBand
; i
< iEndBand
; i
= next_visible(infoPtr
, i
))
1295 lpBand
= REBAR_GetBand(infoPtr
, i
);
1296 lpBand
->cyRowSoFar
= yMaxHeight
;
1297 yMaxHeight
= max(yMaxHeight
, lpBand
->cyMinBand
);
1299 TRACE("Bands [%d; %d) height: %d\n", iBeginBand
, iEndBand
, yMaxHeight
);
1301 for (i
= iBeginBand
; i
< iEndBand
; i
= next_visible(infoPtr
, i
))
1303 lpBand
= REBAR_GetBand(infoPtr
, i
);
1304 /* we may be called for multiple rows if RBS_VARHEIGHT not set */
1305 if (lpBand
->iRow
!= row
) {
1306 yPos
+= yMaxHeight
+ SEP_WIDTH
;
1310 if (lpBand
->rcBand
.top
!= yPos
|| lpBand
->rcBand
.bottom
!= yPos
+ yMaxHeight
) {
1311 lpBand
->fDraw
|= NTF_INVALIDATE
;
1312 lpBand
->rcBand
.top
= yPos
;
1313 lpBand
->rcBand
.bottom
= yPos
+ yMaxHeight
;
1314 TRACE("Band %d: %s\n", i
, wine_dbgstr_rect(&lpBand
->rcBand
));
1317 return yPos
+ yMaxHeight
;
1320 /* Layout the row [iBeginBand; iEndBand). iBeginBand must be visible */
1321 static void REBAR_LayoutRow(const REBAR_INFO
*infoPtr
, int iBeginBand
, int iEndBand
, int cx
, int *piRow
, int *pyPos
)
1327 TRACE("Adjusting row [%d;%d). Width: %d\n", iBeginBand
, iEndBand
, cx
);
1328 for (i
= iBeginBand
; i
< iEndBand
; i
++)
1329 REBAR_GetBand(infoPtr
, i
)->iRow
= *piRow
;
1331 /* compute the extra space */
1332 for (i
= iBeginBand
; i
< iEndBand
; i
= next_visible(infoPtr
, i
))
1334 lpBand
= REBAR_GetBand(infoPtr
, i
);
1337 lpBand
->cxEffective
= max(lpBand
->cxMinBand
, lpBand
->cx
);
1338 width
+= lpBand
->cxEffective
;
1342 TRACE("Extra space: %d\n", extra
);
1344 int ret
= REBAR_ShrinkBandsRTL(infoPtr
, iBeginBand
, iEndBand
, -extra
, FALSE
);
1345 if (ret
> 0 && next_visible(infoPtr
, iBeginBand
) != iEndBand
) /* one band may be longer than expected... */
1346 ERR("Error layouting row %d - couldn't shrink for %d pixels (%d total shrink)\n", *piRow
, ret
, -extra
);
1349 lpBand
= REBAR_FindBandToGrow(infoPtr
, iBeginBand
, iEndBand
);
1350 lpBand
->cxEffective
+= extra
;
1353 REBAR_SetRowRectsX(infoPtr
, iBeginBand
, iEndBand
);
1354 if (infoPtr
->dwStyle
& RBS_VARHEIGHT
)
1357 *pyPos
+= SEP_WIDTH
;
1358 *pyPos
= REBAR_SetBandsHeight(infoPtr
, iBeginBand
, iEndBand
, *pyPos
);
1364 REBAR_Layout(REBAR_INFO
*infoPtr
)
1374 if (infoPtr
->dwStyle
& (CCS_NORESIZE
| CCS_NOPARENTALIGN
) || GetParent(infoPtr
->hwndSelf
) == NULL
)
1375 GetClientRect(infoPtr
->hwndSelf
, &rcAdj
);
1377 GetClientRect(GetParent(infoPtr
->hwndSelf
), &rcAdj
);
1378 TRACE("adjustment rect is (%s)\n", wine_dbgstr_rect(&rcAdj
));
1380 adjcx
= get_rect_cx(infoPtr
, &rcAdj
);
1382 if (infoPtr
->uNumBands
== 0) {
1383 TRACE("No bands - setting size to (0,%d), style: %x\n", adjcx
, infoPtr
->dwStyle
);
1384 infoPtr
->calcSize
.cx
= adjcx
;
1385 /* the calcSize.cy won't change for a 0 band rebar */
1386 infoPtr
->uNumRows
= 0;
1387 REBAR_ForceResize(infoPtr
);
1393 rowstart
= first_visible(infoPtr
);
1395 for (i
= rowstart
; i
< infoPtr
->uNumBands
; i
= next_visible(infoPtr
, i
))
1397 lpBand
= REBAR_GetBand(infoPtr
, i
);
1399 if (i
> rowstart
&& (lpBand
->fStyle
& RBBS_BREAK
|| xMin
+ lpBand
->cxMinBand
> adjcx
)) {
1400 TRACE("%s break on band %d\n", (lpBand
->fStyle
& RBBS_BREAK
? "Hard" : "Soft"), i
- 1);
1401 REBAR_LayoutRow(infoPtr
, rowstart
, i
, adjcx
, &row
, &yPos
);
1408 xMin
+= lpBand
->cxMinBand
;
1410 if (rowstart
< infoPtr
->uNumBands
)
1411 REBAR_LayoutRow(infoPtr
, rowstart
, infoPtr
->uNumBands
, adjcx
, &row
, &yPos
);
1413 if (!(infoPtr
->dwStyle
& RBS_VARHEIGHT
))
1414 yPos
= REBAR_SetBandsHeight(infoPtr
, first_visible(infoPtr
), infoPtr
->uNumBands
, 0);
1416 infoPtr
->uNumRows
= row
;
1418 if (infoPtr
->dwStyle
& CCS_VERT
)
1419 REBAR_CalcVertBand(infoPtr
, 0, infoPtr
->uNumBands
);
1421 REBAR_CalcHorzBand(infoPtr
, 0, infoPtr
->uNumBands
);
1422 /* now compute size of Rebar itself */
1423 oldSize
= infoPtr
->calcSize
;
1425 infoPtr
->calcSize
.cx
= adjcx
;
1426 infoPtr
->calcSize
.cy
= yPos
;
1427 TRACE("calcsize size=(%d, %d), origheight=(%d,%d)\n",
1428 infoPtr
->calcSize
.cx
, infoPtr
->calcSize
.cy
,
1429 oldSize
.cx
, oldSize
.cy
);
1431 REBAR_DumpBand (infoPtr
);
1432 REBAR_MoveChildWindows (infoPtr
, 0, infoPtr
->uNumBands
);
1433 REBAR_ForceResize (infoPtr
);
1435 /* note: after a RBN_HEIGHTCHANGE native sends once again all the RBN_CHILDSIZE
1436 * and does another ForceResize */
1437 if (oldSize
.cy
!= infoPtr
->calcSize
.cy
)
1440 REBAR_Notify(&heightchange
, infoPtr
, RBN_HEIGHTCHANGE
);
1441 REBAR_AutoSize(infoPtr
, FALSE
);
1445 /* iBeginBand must be visible */
1447 REBAR_SizeChildrenToHeight(const REBAR_INFO
*infoPtr
, int iBeginBand
, int iEndBand
, int extra
, BOOL
*fChanged
)
1453 TRACE("[%d;%d) by %d\n", iBeginBand
, iEndBand
, extra
);
1455 cyBandsOld
= REBAR_GetBand(infoPtr
, iBeginBand
)->rcBand
.bottom
-
1456 REBAR_GetBand(infoPtr
, iBeginBand
)->rcBand
.top
;
1457 for (i
= iBeginBand
; i
< iEndBand
; i
= next_visible(infoPtr
, i
))
1459 REBAR_BAND
*lpBand
= REBAR_GetBand(infoPtr
, i
);
1460 int cyMaxChild
= cyBandsOld
- REBARSPACE(lpBand
) + extra
;
1461 int cyChild
= round_child_height(lpBand
, cyMaxChild
);
1463 if (lpBand
->hwndChild
&& cyChild
!= lpBand
->cyChild
&& (lpBand
->fStyle
& RBBS_VARIABLEHEIGHT
))
1465 TRACE("Resizing %d: %d -> %d [%d]\n", i
, lpBand
->cyChild
, cyChild
, lpBand
->cyMaxChild
);
1467 lpBand
->cyChild
= cyChild
;
1468 lpBand
->fDraw
|= NTF_INVALIDATE
;
1469 update_min_band_height(infoPtr
, lpBand
);
1471 cyBandsNew
= max(cyBandsNew
, lpBand
->cyMinBand
);
1473 return cyBandsNew
- cyBandsOld
;
1476 /* worker function for RB_SIZETORECT and RBS_AUTOSIZE */
1478 REBAR_SizeToHeight(REBAR_INFO
*infoPtr
, int height
)
1480 int extra
= height
- infoPtr
->calcSize
.cy
; /* may be negative */
1481 BOOL fChanged
= FALSE
;
1482 UINT uNumRows
= infoPtr
->uNumRows
;
1485 if (uNumRows
== 0) /* avoid division by 0 */
1488 /* That's not exactly what Windows does but should be similar */
1490 /* Pass one: break-up/glue rows */
1493 for (i
= prev_visible(infoPtr
, infoPtr
->uNumBands
); i
> 0; i
= prev_visible(infoPtr
, i
))
1495 REBAR_BAND
*lpBand
= REBAR_GetBand(infoPtr
, i
);
1496 int cyBreakExtra
; /* additional cy for the rebar after a RBBS_BREAK on this band */
1498 height
= lpBand
->rcBand
.bottom
- lpBand
->rcBand
.top
;
1500 if (infoPtr
->dwStyle
& RBS_VARHEIGHT
)
1501 cyBreakExtra
= lpBand
->cyRowSoFar
; /* 'height' => 'lpBand->cyRowSoFar' + 'height'*/
1503 cyBreakExtra
= height
; /* 'height' => 'height' + 'height'*/
1504 cyBreakExtra
+= SEP_WIDTH
;
1506 if (extra
<= cyBreakExtra
/ 2)
1509 if (!(lpBand
->fStyle
& RBBS_BREAK
))
1511 TRACE("Adding break on band %d - extra %d -> %d\n", i
, extra
, extra
- cyBreakExtra
);
1512 lpBand
->fStyle
|= RBBS_BREAK
;
1513 lpBand
->fDraw
|= NTF_INVALIDATE
;
1515 extra
-= cyBreakExtra
;
1517 /* temporary change for _SizeControlsToHeight. The true values will be computed in _Layout */
1518 if (infoPtr
->dwStyle
& RBS_VARHEIGHT
)
1519 lpBand
->rcBand
.bottom
= lpBand
->rcBand
.top
+ lpBand
->cyMinBand
;
1523 /* TODO: else if (extra < 0) { try to remove some RBBS_BREAKs } */
1525 /* Pass two: increase/decrease control height */
1526 if (infoPtr
->dwStyle
& RBS_VARHEIGHT
)
1528 int i
= first_visible(infoPtr
);
1530 while (i
< infoPtr
->uNumBands
)
1532 REBAR_BAND
*lpBand
= REBAR_GetBand(infoPtr
, i
);
1533 int extraForRow
= extra
/ (int)(uNumRows
- iRow
);
1536 /* we can't use get_row_end_for_band as we might have added RBBS_BREAK in the first phase */
1537 for (rowEnd
= next_visible(infoPtr
, i
); rowEnd
< infoPtr
->uNumBands
; rowEnd
= next_visible(infoPtr
, rowEnd
))
1538 if (REBAR_GetBand(infoPtr
, rowEnd
)->iRow
!= lpBand
->iRow
||
1539 REBAR_GetBand(infoPtr
, rowEnd
)->fStyle
& RBBS_BREAK
)
1542 extra
-= REBAR_SizeChildrenToHeight(infoPtr
, i
, rowEnd
, extraForRow
, &fChanged
);
1543 TRACE("extra = %d\n", extra
);
1549 REBAR_SizeChildrenToHeight(infoPtr
, first_visible(infoPtr
), infoPtr
->uNumBands
, extra
/ infoPtr
->uNumRows
, &fChanged
);
1552 REBAR_Layout(infoPtr
);
1556 REBAR_AutoSize(REBAR_INFO
*infoPtr
, BOOL needsLayout
)
1559 NMRBAUTOSIZE autosize
;
1562 REBAR_Layout(infoPtr
);
1563 GetClientRect(infoPtr
->hwndSelf
, &rc
);
1564 REBAR_SizeToHeight(infoPtr
, get_rect_cy(infoPtr
, &rc
));
1565 GetClientRect(infoPtr
->hwndSelf
, &rcNew
);
1567 GetClientRect(infoPtr
->hwndSelf
, &autosize
.rcTarget
);
1568 autosize
.fChanged
= (memcmp(&rc
, &rcNew
, sizeof(RECT
)) == 0);
1569 autosize
.rcTarget
= rc
;
1570 autosize
.rcActual
= rcNew
;
1571 REBAR_Notify((NMHDR
*)&autosize
, infoPtr
, RBN_AUTOSIZE
);
1575 REBAR_ValidateBand (const REBAR_INFO
*infoPtr
, REBAR_BAND
*lpBand
)
1576 /* Function: This routine evaluates the band specs supplied */
1577 /* by the user and updates the following 5 fields in */
1578 /* the internal band structure: cxHeader, cyHeader, cxMinBand, cyMinBand, fStatus */
1581 UINT textheight
=0, imageheight
= 0;
1585 lpBand
->fStatus
= 0;
1586 lpBand
->cxMinBand
= 0;
1587 lpBand
->cyMinBand
= 0;
1589 /* Data coming in from users into the cx... and cy... fields */
1590 /* may be bad, just garbage, because the user never clears */
1591 /* the fields. RB_{SET|INSERT}BAND{A|W} just passes the data */
1592 /* along if the fields exist in the input area. Here we must */
1593 /* determine if the data is valid. I have no idea how MS does */
1594 /* the validation, but it does because the RB_GETBANDINFO */
1595 /* returns a 0 when I know the sample program passed in an */
1596 /* address. Here I will use the algorithm that if the value */
1597 /* is greater than 65535 then it is bad and replace it with */
1598 /* a zero. Feel free to improve the algorithm. - GA 12/2000 */
1599 if (lpBand
->cxMinChild
> 65535) lpBand
->cxMinChild
= 0;
1600 if (lpBand
->cyMinChild
> 65535) lpBand
->cyMinChild
= 0;
1601 if (lpBand
->cx
> 65535) lpBand
->cx
= 0;
1602 if (lpBand
->cyChild
> 65535) lpBand
->cyChild
= 0;
1603 if (lpBand
->cyIntegral
> 65535) lpBand
->cyIntegral
= 0;
1604 if (lpBand
->cxIdeal
> 65535) lpBand
->cxIdeal
= 0;
1605 if (lpBand
->cxHeader
> 65535) lpBand
->cxHeader
= 0;
1607 /* TODO : we could try return to the caller if a value changed so that */
1608 /* a REBAR_Layout is needed. Till now the caller should call it */
1609 /* it always (we should also check what native does) */
1611 /* Header is where the image, text and gripper exist */
1612 /* in the band and precede the child window. */
1614 /* count number of non-FIXEDSIZE and non-Hidden bands */
1616 for (i
=0; i
<infoPtr
->uNumBands
; i
++){
1617 tBand
= REBAR_GetBand(infoPtr
, i
);
1618 if (!HIDDENBAND(tBand
) && !(tBand
->fStyle
& RBBS_FIXEDSIZE
))
1622 /* calculate gripper rectangle */
1623 if ( (!(lpBand
->fStyle
& RBBS_NOGRIPPER
)) &&
1624 ( (lpBand
->fStyle
& RBBS_GRIPPERALWAYS
) ||
1625 ( !(lpBand
->fStyle
& RBBS_FIXEDSIZE
) && (nonfixed
> 1)))
1627 lpBand
->fStatus
|= HAS_GRIPPER
;
1628 if (infoPtr
->dwStyle
& CCS_VERT
)
1629 if (infoPtr
->dwStyle
& RBS_VERTICALGRIPPER
)
1630 header
+= (GRIPPER_HEIGHT
+ REBAR_PRE_GRIPPER
);
1632 header
+= (GRIPPER_WIDTH
+ REBAR_PRE_GRIPPER
);
1634 header
+= (REBAR_PRE_GRIPPER
+ GRIPPER_WIDTH
);
1635 /* Always have 4 pixels before anything else */
1636 header
+= REBAR_ALWAYS_SPACE
;
1639 /* image is visible */
1640 if (lpBand
->iImage
!= -1 && (infoPtr
->himl
)) {
1641 lpBand
->fStatus
|= HAS_IMAGE
;
1642 if (infoPtr
->dwStyle
& CCS_VERT
) {
1643 header
+= (infoPtr
->imageSize
.cy
+ REBAR_POST_IMAGE
);
1644 imageheight
= infoPtr
->imageSize
.cx
+ 4;
1647 header
+= (infoPtr
->imageSize
.cx
+ REBAR_POST_IMAGE
);
1648 imageheight
= infoPtr
->imageSize
.cy
+ 4;
1652 /* text is visible */
1653 if ((lpBand
->fMask
& RBBIM_TEXT
) && (lpBand
->lpText
) &&
1654 !(lpBand
->fStyle
& RBBS_HIDETITLE
)) {
1655 HDC hdc
= GetDC (0);
1656 HFONT hOldFont
= SelectObject (hdc
, infoPtr
->hFont
);
1659 lpBand
->fStatus
|= HAS_TEXT
;
1660 GetTextExtentPoint32W (hdc
, lpBand
->lpText
,
1661 lstrlenW (lpBand
->lpText
), &size
);
1662 header
+= ((infoPtr
->dwStyle
& CCS_VERT
) ? (size
.cy
+ REBAR_POST_TEXT
) : (size
.cx
+ REBAR_POST_TEXT
));
1663 textheight
= (infoPtr
->dwStyle
& CCS_VERT
) ? 0 : size
.cy
;
1665 SelectObject (hdc
, hOldFont
);
1669 /* if no gripper but either image or text, then leave space */
1670 if ((lpBand
->fStatus
& (HAS_IMAGE
| HAS_TEXT
)) &&
1671 !(lpBand
->fStatus
& HAS_GRIPPER
)) {
1672 header
+= REBAR_ALWAYS_SPACE
;
1675 /* check if user overrode the header value */
1676 if (!(lpBand
->fStyle
& RBBS_UNDOC_FIXEDHEADER
))
1677 lpBand
->cxHeader
= header
;
1678 lpBand
->cyHeader
= max(textheight
, imageheight
);
1680 /* Now compute minimum size of child window */
1681 update_min_band_height(infoPtr
, lpBand
); /* update lpBand->cyMinBand from cyHeader and cyChild*/
1683 lpBand
->cxMinBand
= lpBand
->cxMinChild
+ lpBand
->cxHeader
+ REBAR_POST_CHILD
;
1684 if (lpBand
->fStyle
& RBBS_USECHEVRON
&& lpBand
->cxMinChild
< lpBand
->cxIdeal
)
1685 lpBand
->cxMinBand
+= CHEVRON_WIDTH
;
1689 REBAR_CommonSetupBand(HWND hwnd
, const REBARBANDINFOW
*lprbbi
, REBAR_BAND
*lpBand
)
1690 /* Function: This routine copies the supplied values from */
1691 /* user input (lprbbi) to the internal band structure. */
1692 /* It returns the mask of what changed. */
1694 UINT uChanged
= 0x0;
1696 lpBand
->fMask
|= lprbbi
->fMask
;
1698 if( (lprbbi
->fMask
& RBBIM_STYLE
) &&
1699 (lpBand
->fStyle
!= lprbbi
->fStyle
) )
1701 lpBand
->fStyle
= lprbbi
->fStyle
;
1702 uChanged
|= RBBIM_STYLE
;
1705 if( (lprbbi
->fMask
& RBBIM_COLORS
) &&
1706 ( ( lpBand
->clrFore
!= lprbbi
->clrFore
) ||
1707 ( lpBand
->clrBack
!= lprbbi
->clrBack
) ) )
1709 lpBand
->clrFore
= lprbbi
->clrFore
;
1710 lpBand
->clrBack
= lprbbi
->clrBack
;
1711 uChanged
|= RBBIM_COLORS
;
1714 if( (lprbbi
->fMask
& RBBIM_IMAGE
) &&
1715 ( lpBand
->iImage
!= lprbbi
->iImage
) )
1717 lpBand
->iImage
= lprbbi
->iImage
;
1718 uChanged
|= RBBIM_IMAGE
;
1721 if( (lprbbi
->fMask
& RBBIM_CHILD
) &&
1722 (lprbbi
->hwndChild
!= lpBand
->hwndChild
) )
1724 if (lprbbi
->hwndChild
) {
1725 lpBand
->hwndChild
= lprbbi
->hwndChild
;
1726 lpBand
->hwndPrevParent
=
1727 SetParent (lpBand
->hwndChild
, hwnd
);
1728 /* below in trace from WinRAR */
1729 ShowWindow(lpBand
->hwndChild
, SW_SHOWNOACTIVATE
| SW_SHOWNORMAL
);
1730 /* above in trace from WinRAR */
1733 TRACE("child: %p prev parent: %p\n",
1734 lpBand
->hwndChild
, lpBand
->hwndPrevParent
);
1735 lpBand
->hwndChild
= 0;
1736 lpBand
->hwndPrevParent
= 0;
1738 uChanged
|= RBBIM_CHILD
;
1741 if( (lprbbi
->fMask
& RBBIM_CHILDSIZE
) &&
1742 ( (lpBand
->cxMinChild
!= lprbbi
->cxMinChild
) ||
1743 (lpBand
->cyMinChild
!= lprbbi
->cyMinChild
) ||
1744 ( (lprbbi
->cbSize
>= REBARBANDINFOA_V6_SIZE
&& (lpBand
->fStyle
& RBBS_VARIABLEHEIGHT
)) &&
1745 ( (lpBand
->cyChild
!= lprbbi
->cyChild
) ||
1746 (lpBand
->cyMaxChild
!= lprbbi
->cyMaxChild
) ||
1747 (lpBand
->cyIntegral
!= lprbbi
->cyIntegral
) ) ) ||
1748 ( (lprbbi
->cbSize
< REBARBANDINFOA_V6_SIZE
) &&
1749 ( (lpBand
->cyChild
||
1750 lpBand
->cyMaxChild
||
1751 lpBand
->cyIntegral
) ) ) ) )
1753 lpBand
->cxMinChild
= lprbbi
->cxMinChild
;
1754 lpBand
->cyMinChild
= lprbbi
->cyMinChild
;
1755 /* These fields where added in WIN32_IE == 0x400 and are set only for RBBS_VARIABLEHEIGHT bands */
1756 if (lprbbi
->cbSize
>= REBARBANDINFOA_V6_SIZE
&& (lpBand
->fStyle
& RBBS_VARIABLEHEIGHT
)) {
1757 lpBand
->cyMaxChild
= lprbbi
->cyMaxChild
;
1758 lpBand
->cyIntegral
= lprbbi
->cyIntegral
;
1760 lpBand
->cyChild
= round_child_height(lpBand
, lprbbi
->cyChild
); /* make (cyChild - cyMinChild) a multiple of cyIntergral */
1763 lpBand
->cyChild
= lpBand
->cyMinChild
;
1764 lpBand
->cyMaxChild
= 0x7fffffff;
1765 lpBand
->cyIntegral
= 0;
1767 uChanged
|= RBBIM_CHILDSIZE
;
1770 if( (lprbbi
->fMask
& RBBIM_SIZE
) &&
1771 (lpBand
->cx
!= lprbbi
->cx
) )
1773 lpBand
->cx
= lprbbi
->cx
;
1774 uChanged
|= RBBIM_SIZE
;
1777 if( (lprbbi
->fMask
& RBBIM_BACKGROUND
) &&
1778 ( lpBand
->hbmBack
!= lprbbi
->hbmBack
) )
1780 lpBand
->hbmBack
= lprbbi
->hbmBack
;
1781 uChanged
|= RBBIM_BACKGROUND
;
1784 if( (lprbbi
->fMask
& RBBIM_ID
) &&
1785 (lpBand
->wID
!= lprbbi
->wID
) )
1787 lpBand
->wID
= lprbbi
->wID
;
1788 uChanged
|= RBBIM_ID
;
1791 /* check for additional data */
1792 if (lprbbi
->cbSize
>= REBARBANDINFOA_V6_SIZE
) {
1793 if( (lprbbi
->fMask
& RBBIM_IDEALSIZE
) &&
1794 ( lpBand
->cxIdeal
!= lprbbi
->cxIdeal
) )
1796 lpBand
->cxIdeal
= lprbbi
->cxIdeal
;
1797 uChanged
|= RBBIM_IDEALSIZE
;
1800 if( (lprbbi
->fMask
& RBBIM_LPARAM
) &&
1801 (lpBand
->lParam
!= lprbbi
->lParam
) )
1803 lpBand
->lParam
= lprbbi
->lParam
;
1804 uChanged
|= RBBIM_LPARAM
;
1807 if( (lprbbi
->fMask
& RBBIM_HEADERSIZE
) &&
1808 (lpBand
->cxHeader
!= lprbbi
->cxHeader
) )
1810 lpBand
->cxHeader
= lprbbi
->cxHeader
;
1811 lpBand
->fStyle
|= RBBS_UNDOC_FIXEDHEADER
;
1812 uChanged
|= RBBIM_HEADERSIZE
;
1819 static LRESULT
REBAR_EraseBkGnd (const REBAR_INFO
*infoPtr
, HDC hdc
)
1820 /* Function: This erases the background rectangle by drawing */
1821 /* each band with its background color (or the default) and */
1822 /* draws each bands right separator if necessary. The row */
1823 /* separators are drawn on the first band of the next row. */
1829 COLORREF old
= CLR_NONE
, new;
1830 HTHEME theme
= GetWindowTheme (infoPtr
->hwndSelf
);
1835 GetClientRect (infoPtr
->hwndSelf
, &cr
);
1841 if (IsThemeBackgroundPartiallyTransparent(theme
, RP_BACKGROUND
, 0))
1843 DrawThemeParentBackground (infoPtr
->hwndSelf
, hdc
, &cr
);
1845 DrawThemeBackground (theme
, hdc
, 0, 0, &cr
, NULL
);
1848 hrgn
= CreateRectRgn(cr
.left
, cr
.top
, cr
.right
, cr
.bottom
);
1853 for(i
=0; i
<infoPtr
->uNumBands
; i
++) {
1860 lpBand
= REBAR_GetBand(infoPtr
, i
);
1861 if (HIDDENBAND(lpBand
)) continue;
1862 translate_rect(infoPtr
, &rcBand
, &lpBand
->rcBand
);
1865 rcBandReal
= rcBand
;
1868 /* draw band separator between rows */
1869 if (lpBand
->iRow
!= oldrow
) {
1870 oldrow
= lpBand
->iRow
;
1871 if (infoPtr
->dwStyle
& RBS_BANDBORDERS
) {
1874 if (infoPtr
->dwStyle
& CCS_VERT
) {
1875 rcRowSep
.right
+= SEP_WIDTH_SIZE
;
1876 rcRowSep
.bottom
= infoPtr
->calcSize
.cx
;
1878 DrawThemeEdge (theme
, hdc
, RP_BAND
, 0, &rcRowSep
, EDGE_ETCHED
, BF_RIGHT
, NULL
);
1880 DrawEdge (hdc
, &rcRowSep
, EDGE_ETCHED
, BF_RIGHT
);
1883 rcRowSep
.bottom
+= SEP_WIDTH_SIZE
;
1884 rcRowSep
.right
= infoPtr
->calcSize
.cx
;
1886 DrawThemeEdge (theme
, hdc
, RP_BAND
, 0, &rcRowSep
, EDGE_ETCHED
, BF_BOTTOM
, NULL
);
1888 DrawEdge (hdc
, &rcRowSep
, EDGE_ETCHED
, BF_BOTTOM
);
1890 TRACE ("drawing band separator bottom (%s)\n",
1891 wine_dbgstr_rect(&rcRowSep
));
1893 rcBandReal
= rcRowSep
;
1898 /* draw band separator between bands in a row */
1899 if (infoPtr
->dwStyle
& RBS_BANDBORDERS
&& lpBand
->rcBand
.left
> 0) {
1902 if (infoPtr
->dwStyle
& CCS_VERT
) {
1903 rcSep
.bottom
= rcSep
.top
;
1904 rcSep
.top
-= SEP_WIDTH_SIZE
;
1906 rcBandReal
.top
-= SEP_WIDTH_SIZE
;
1909 DrawThemeEdge (theme
, hdc
, RP_BAND
, 0, &rcSep
, EDGE_ETCHED
, BF_BOTTOM
, NULL
);
1911 DrawEdge (hdc
, &rcSep
, EDGE_ETCHED
, BF_BOTTOM
);
1914 rcSep
.right
= rcSep
.left
;
1915 rcSep
.left
-= SEP_WIDTH_SIZE
;
1917 rcBandReal
.left
-= SEP_WIDTH_SIZE
;
1920 DrawThemeEdge (theme
, hdc
, RP_BAND
, 0, &rcSep
, EDGE_ETCHED
, BF_RIGHT
, NULL
);
1922 DrawEdge (hdc
, &rcSep
, EDGE_ETCHED
, BF_RIGHT
);
1924 TRACE("drawing band separator right (%s)\n",
1925 wine_dbgstr_rect(&rcSep
));
1928 /* draw the actual background */
1929 if (lpBand
->clrBack
!= CLR_NONE
) {
1930 new = (lpBand
->clrBack
== CLR_DEFAULT
) ? infoPtr
->clrBtnFace
:
1933 /* testing only - make background green to see it */
1938 /* In the absence of documentation for Rebar vs. CLR_NONE,
1939 * we will use the default BtnFace color. Note documentation
1940 * exists for Listview and Imagelist.
1942 new = infoPtr
->clrBtnFace
;
1944 /* testing only - make background green to see it */
1954 /* When themed, the background color is ignored (but not a
1955 * background bitmap */
1956 DrawThemeBackground (theme
, hdc
, 0, 0, &cr
, &rcBand
);
1961 old
= SetBkColor (hdc
, new);
1962 TRACE("%s background color=0x%06x, band %s\n",
1963 (lpBand
->clrBack
== CLR_NONE
) ? "none" :
1964 ((lpBand
->clrBack
== CLR_DEFAULT
) ? "dft" : ""),
1965 GetBkColor(hdc
), wine_dbgstr_rect(&rcBand
));
1966 ExtTextOutW (hdc
, 0, 0, ETO_OPAQUE
, &rcBand
, NULL
, 0, 0);
1967 if (lpBand
->clrBack
!= CLR_NONE
)
1968 SetBkColor (hdc
, old
);
1972 hrgnBand
= CreateRectRgn(rcBandReal
.left
, rcBandReal
.top
, rcBandReal
.right
, rcBandReal
.bottom
);
1973 CombineRgn(hrgn
, hrgn
, hrgnBand
, RGN_DIFF
);
1974 DeleteObject(hrgnBand
);
1983 //FIXME: Apparently painting the remaining area is a v6 feature
1984 HBRUSH hbrush
= CreateSolidBrush(new);
1985 FillRgn(hdc
, hrgn
, hbrush
);
1986 DeleteObject(hbrush
);
1994 REBAR_InternalHitTest (const REBAR_INFO
*infoPtr
, const POINT
*lpPt
, UINT
*pFlags
, INT
*pBand
)
2000 GetClientRect (infoPtr
->hwndSelf
, &rect
);
2002 *pFlags
= RBHT_NOWHERE
;
2003 if (PtInRect (&rect
, *lpPt
))
2005 if (infoPtr
->uNumBands
== 0) {
2006 *pFlags
= RBHT_NOWHERE
;
2013 /* somewhere inside */
2014 for (iCount
= 0; iCount
< infoPtr
->uNumBands
; iCount
++) {
2016 lpBand
= REBAR_GetBand(infoPtr
, iCount
);
2017 translate_rect(infoPtr
, &rcBand
, &lpBand
->rcBand
);
2018 if (HIDDENBAND(lpBand
)) continue;
2019 if (PtInRect (&rcBand
, *lpPt
)) {
2022 if (PtInRect (&lpBand
->rcGripper
, *lpPt
)) {
2023 *pFlags
= RBHT_GRABBER
;
2024 TRACE("ON GRABBER %d\n", iCount
);
2027 else if (PtInRect (&lpBand
->rcCapImage
, *lpPt
)) {
2028 *pFlags
= RBHT_CAPTION
;
2029 TRACE("ON CAPTION %d\n", iCount
);
2032 else if (PtInRect (&lpBand
->rcCapText
, *lpPt
)) {
2033 *pFlags
= RBHT_CAPTION
;
2034 TRACE("ON CAPTION %d\n", iCount
);
2037 else if (PtInRect (&lpBand
->rcChild
, *lpPt
)) {
2038 *pFlags
= RBHT_CLIENT
;
2039 TRACE("ON CLIENT %d\n", iCount
);
2042 else if (PtInRect (&lpBand
->rcChevron
, *lpPt
)) {
2043 *pFlags
= RBHT_CHEVRON
;
2044 TRACE("ON CHEVRON %d\n", iCount
);
2048 *pFlags
= RBHT_NOWHERE
;
2049 TRACE("NOWHERE %d\n", iCount
);
2055 *pFlags
= RBHT_NOWHERE
;
2064 *pFlags
= RBHT_NOWHERE
;
2073 REBAR_HandleLRDrag (REBAR_INFO
*infoPtr
, const POINT
*ptsmove
)
2074 /* Function: This will implement the functionality of a */
2075 /* Gripper drag within a row. It will not implement "out- */
2076 /* of-row" drags. (They are detected and handled in */
2077 /* REBAR_MouseMove.) */
2079 REBAR_BAND
*hitBand
;
2080 INT iHitBand
, iRowBegin
, iRowEnd
;
2081 INT movement
, xBand
, cxLeft
= 0;
2082 BOOL shrunkBands
= FALSE
;
2084 iHitBand
= infoPtr
->iGrabbedBand
;
2085 iRowBegin
= get_row_begin_for_band(infoPtr
, iHitBand
);
2086 iRowEnd
= get_row_end_for_band(infoPtr
, iHitBand
);
2087 hitBand
= REBAR_GetBand(infoPtr
, iHitBand
);
2089 xBand
= hitBand
->rcBand
.left
;
2090 movement
= (infoPtr
->dwStyle
&CCS_VERT
? ptsmove
->y
: ptsmove
->x
)
2091 - (xBand
+ REBAR_PRE_GRIPPER
- infoPtr
->ihitoffset
);
2093 /* Dragging the first band in a row cannot cause shrinking */
2094 if(iHitBand
!= iRowBegin
)
2097 cxLeft
= REBAR_ShrinkBandsRTL(infoPtr
, iRowBegin
, iHitBand
, -movement
, TRUE
);
2099 if(cxLeft
< -movement
)
2101 hitBand
->cxEffective
+= -movement
- cxLeft
;
2102 hitBand
->cx
= hitBand
->cxEffective
;
2106 } else if (movement
> 0) {
2109 if (prev_visible(infoPtr
, iHitBand
) >= 0)
2110 cxLeft
= REBAR_ShrinkBandsLTR(infoPtr
, iHitBand
, iRowEnd
, movement
, TRUE
);
2112 if(cxLeft
< movement
)
2114 REBAR_BAND
*lpPrev
= REBAR_GetBand(infoPtr
, prev_visible(infoPtr
, iHitBand
));
2115 lpPrev
->cxEffective
+= movement
- cxLeft
;
2116 lpPrev
->cx
= hitBand
->cxEffective
;
2125 /* It was not possible to move the band by shrinking bands.
2126 * Try relocating the band instead. */
2127 REBAR_MoveBandToRowOffset(infoPtr
, iHitBand
, iRowBegin
,
2128 iRowEnd
, xBand
+ movement
, TRUE
);
2131 REBAR_SetRowRectsX(infoPtr
, iRowBegin
, iRowEnd
);
2132 if (infoPtr
->dwStyle
& CCS_VERT
)
2133 REBAR_CalcVertBand(infoPtr
, 0, infoPtr
->uNumBands
);
2135 REBAR_CalcHorzBand(infoPtr
, 0, infoPtr
->uNumBands
);
2136 REBAR_MoveChildWindows(infoPtr
, iRowBegin
, iRowEnd
);
2140 REBAR_HandleUDDrag (REBAR_INFO
*infoPtr
, const POINT
*ptsmove
)
2142 INT yOff
= (infoPtr
->dwStyle
& CCS_VERT
) ? ptsmove
->x
: ptsmove
->y
;
2143 INT iHitBand
, iRowBegin
, iNextRowBegin
;
2144 REBAR_BAND
*hitBand
, *rowBeginBand
;
2146 if(infoPtr
->uNumBands
<= 0)
2147 ERR("There are no bands in this rebar\n");
2149 /* Up/down dragging can only occur when there is more than one
2150 * band in the rebar */
2151 if(infoPtr
->uNumBands
<= 1)
2154 iHitBand
= infoPtr
->iGrabbedBand
;
2155 hitBand
= REBAR_GetBand(infoPtr
, iHitBand
);
2157 /* If we're taking a band that has the RBBS_BREAK style set, this
2158 * style needs to be reapplied to the band that is going to become
2159 * the new start of the row. */
2160 if((hitBand
->fStyle
& RBBS_BREAK
) &&
2161 (iHitBand
< infoPtr
->uNumBands
- 1))
2162 REBAR_GetBand(infoPtr
, iHitBand
+ 1)->fStyle
|= RBBS_BREAK
;
2166 /* Place the band above the current top row */
2167 if(iHitBand
==0 && (infoPtr
->uNumBands
==1 || REBAR_GetBand(infoPtr
, 1)->fStyle
&RBBS_BREAK
))
2169 DPA_DeletePtr(infoPtr
->bands
, iHitBand
);
2170 hitBand
->fStyle
&= ~RBBS_BREAK
;
2171 REBAR_GetBand(infoPtr
, 0)->fStyle
|= RBBS_BREAK
;
2172 infoPtr
->iGrabbedBand
= DPA_InsertPtr(
2173 infoPtr
->bands
, 0, hitBand
);
2175 else if(yOff
> REBAR_GetBand(infoPtr
, infoPtr
->uNumBands
- 1)->rcBand
.bottom
)
2177 /* Place the band below the current bottom row */
2178 if(iHitBand
== infoPtr
->uNumBands
-1 && hitBand
->fStyle
&RBBS_BREAK
)
2180 DPA_DeletePtr(infoPtr
->bands
, iHitBand
);
2181 hitBand
->fStyle
|= RBBS_BREAK
;
2182 infoPtr
->iGrabbedBand
= DPA_InsertPtr(
2183 infoPtr
->bands
, infoPtr
->uNumBands
- 1, hitBand
);
2187 /* Place the band in the prexisting row the mouse is hovering over */
2188 iRowBegin
= first_visible(infoPtr
);
2189 while(iRowBegin
< infoPtr
->uNumBands
)
2191 iNextRowBegin
= get_row_end_for_band(infoPtr
, iRowBegin
);
2192 rowBeginBand
= REBAR_GetBand(infoPtr
, iRowBegin
);
2193 if(rowBeginBand
->rcBand
.bottom
> yOff
)
2195 REBAR_MoveBandToRowOffset(
2196 infoPtr
, iHitBand
, iRowBegin
, iNextRowBegin
,
2197 ((infoPtr
->dwStyle
& CCS_VERT
) ? ptsmove
->y
: ptsmove
->x
)
2198 - REBAR_PRE_GRIPPER
- infoPtr
->ihitoffset
, FALSE
);
2202 iRowBegin
= iNextRowBegin
;
2206 REBAR_Layout(infoPtr
);
2210 /* << REBAR_BeginDrag >> */
2214 REBAR_DeleteBand (REBAR_INFO
*infoPtr
, WPARAM wParam
)
2216 UINT uBand
= (UINT
)wParam
;
2219 if (uBand
>= infoPtr
->uNumBands
)
2222 TRACE("deleting band %u!\n", uBand
);
2223 lpBand
= REBAR_GetBand(infoPtr
, uBand
);
2224 REBAR_Notify_NMREBAR (infoPtr
, uBand
, RBN_DELETINGBAND
);
2225 /* TODO: a return of 1 should probably cancel the deletion */
2227 if (lpBand
->hwndChild
)
2228 ShowWindow(lpBand
->hwndChild
, SW_HIDE
);
2229 Free(lpBand
->lpText
);
2232 infoPtr
->uNumBands
--;
2233 DPA_DeletePtr(infoPtr
->bands
, uBand
);
2235 REBAR_Notify_NMREBAR (infoPtr
, -1, RBN_DELETEDBAND
);
2237 /* if only 1 band left the re-validate to possible eliminate gripper */
2238 if (infoPtr
->uNumBands
== 1)
2239 REBAR_ValidateBand (infoPtr
, REBAR_GetBand(infoPtr
, 0));
2241 REBAR_Layout(infoPtr
);
2247 /* << REBAR_DragMove >> */
2248 /* << REBAR_EndDrag >> */
2252 REBAR_GetBandBorders (const REBAR_INFO
*infoPtr
, UINT uBand
, RECT
*lpRect
)
2258 if (uBand
>= infoPtr
->uNumBands
)
2261 lpBand
= REBAR_GetBand(infoPtr
, uBand
);
2263 /* FIXME - the following values were determined by experimentation */
2264 /* with the REBAR Control Spy. I have guesses as to what the 4 and */
2265 /* 1 are, but I am not sure. There doesn't seem to be any actual */
2266 /* difference in size of the control area with and without the */
2268 if (infoPtr
->dwStyle
& RBS_BANDBORDERS
) {
2269 if (infoPtr
->dwStyle
& CCS_VERT
) {
2271 lpRect
->top
= lpBand
->cxHeader
+ 4;
2276 lpRect
->left
= lpBand
->cxHeader
+ 4;
2283 lpRect
->left
= lpBand
->cxHeader
;
2289 static inline LRESULT
2290 REBAR_GetBandCount (const REBAR_INFO
*infoPtr
)
2292 TRACE("band count %u!\n", infoPtr
->uNumBands
);
2294 return infoPtr
->uNumBands
;
2299 REBAR_GetBandInfoT(const REBAR_INFO
*infoPtr
, UINT uIndex
, LPREBARBANDINFOW lprbbi
, BOOL bUnicode
)
2303 if (!lprbbi
|| lprbbi
->cbSize
< REBARBANDINFOA_V3_SIZE
)
2306 if (uIndex
>= infoPtr
->uNumBands
)
2309 TRACE("index %u (bUnicode=%d)\n", uIndex
, bUnicode
);
2311 /* copy band information */
2312 lpBand
= REBAR_GetBand(infoPtr
, uIndex
);
2314 if (lprbbi
->fMask
& RBBIM_STYLE
)
2315 lprbbi
->fStyle
= lpBand
->fStyle
;
2317 if (lprbbi
->fMask
& RBBIM_COLORS
) {
2318 lprbbi
->clrFore
= lpBand
->clrFore
;
2319 lprbbi
->clrBack
= lpBand
->clrBack
;
2320 if (lprbbi
->clrBack
== CLR_DEFAULT
)
2321 lprbbi
->clrBack
= infoPtr
->clrBtnFace
;
2324 if (lprbbi
->fMask
& RBBIM_TEXT
) {
2326 Str_GetPtrW(lpBand
->lpText
, lprbbi
->lpText
, lprbbi
->cch
);
2328 Str_GetPtrWtoA(lpBand
->lpText
, (LPSTR
)lprbbi
->lpText
, lprbbi
->cch
);
2331 if (lprbbi
->fMask
& RBBIM_IMAGE
)
2332 lprbbi
->iImage
= lpBand
->iImage
;
2334 if (lprbbi
->fMask
& RBBIM_CHILD
)
2335 lprbbi
->hwndChild
= lpBand
->hwndChild
;
2337 if (lprbbi
->fMask
& RBBIM_CHILDSIZE
) {
2338 lprbbi
->cxMinChild
= lpBand
->cxMinChild
;
2339 lprbbi
->cyMinChild
= lpBand
->cyMinChild
;
2340 /* to make tests pass we follow Windows behaviour and allow to read these fields only
2341 * for RBBS_VARIABLEHEIGHTS bands */
2342 if (lprbbi
->cbSize
>= REBARBANDINFOW_V6_SIZE
&& (lpBand
->fStyle
& RBBS_VARIABLEHEIGHT
)) {
2343 lprbbi
->cyChild
= lpBand
->cyChild
;
2344 lprbbi
->cyMaxChild
= lpBand
->cyMaxChild
;
2345 lprbbi
->cyIntegral
= lpBand
->cyIntegral
;
2349 if (lprbbi
->fMask
& RBBIM_SIZE
)
2350 lprbbi
->cx
= lpBand
->cx
;
2352 if (lprbbi
->fMask
& RBBIM_BACKGROUND
)
2353 lprbbi
->hbmBack
= lpBand
->hbmBack
;
2355 if (lprbbi
->fMask
& RBBIM_ID
)
2356 lprbbi
->wID
= lpBand
->wID
;
2358 /* check for additional data */
2359 if (lprbbi
->cbSize
>= REBARBANDINFOW_V6_SIZE
) {
2360 if (lprbbi
->fMask
& RBBIM_IDEALSIZE
)
2361 lprbbi
->cxIdeal
= lpBand
->cxIdeal
;
2363 if (lprbbi
->fMask
& RBBIM_LPARAM
)
2364 lprbbi
->lParam
= lpBand
->lParam
;
2366 if (lprbbi
->fMask
& RBBIM_HEADERSIZE
)
2367 lprbbi
->cxHeader
= lpBand
->cxHeader
;
2370 REBAR_DumpBandInfo(lprbbi
);
2377 REBAR_GetBarHeight (const REBAR_INFO
*infoPtr
)
2381 nHeight
= infoPtr
->calcSize
.cy
;
2383 TRACE("height = %d\n", nHeight
);
2390 REBAR_GetBarInfo (const REBAR_INFO
*infoPtr
, LPREBARINFO lpInfo
)
2392 if (!lpInfo
|| lpInfo
->cbSize
< sizeof (REBARINFO
))
2395 TRACE("getting bar info!\n");
2397 if (infoPtr
->himl
) {
2398 lpInfo
->himl
= infoPtr
->himl
;
2399 lpInfo
->fMask
|= RBIM_IMAGELIST
;
2406 static inline LRESULT
2407 REBAR_GetBkColor (const REBAR_INFO
*infoPtr
)
2409 COLORREF clr
= infoPtr
->clrBk
;
2411 if (clr
== CLR_DEFAULT
)
2412 clr
= infoPtr
->clrBtnFace
;
2414 TRACE("background color 0x%06x!\n", clr
);
2420 /* << REBAR_GetColorScheme >> */
2421 /* << REBAR_GetDropTarget >> */
2425 REBAR_GetPalette (const REBAR_INFO
*infoPtr
)
2427 FIXME("empty stub!\n");
2434 REBAR_GetRect (const REBAR_INFO
*infoPtr
, INT iBand
, RECT
*lprc
)
2438 if (iBand
< 0 || iBand
>= infoPtr
->uNumBands
)
2443 lpBand
= REBAR_GetBand(infoPtr
, iBand
);
2444 /* For CCS_VERT the coordinates will be swapped - like on Windows */
2445 CopyRect (lprc
, &lpBand
->rcBand
);
2447 TRACE("band %d, (%s)\n", iBand
, wine_dbgstr_rect(lprc
));
2453 static inline LRESULT
2454 REBAR_GetRowCount (const REBAR_INFO
*infoPtr
)
2456 TRACE("%u\n", infoPtr
->uNumRows
);
2458 return infoPtr
->uNumRows
;
2463 REBAR_GetRowHeight (const REBAR_INFO
*infoPtr
, INT iRow
)
2469 for (i
=0; i
<infoPtr
->uNumBands
; i
++) {
2470 lpBand
= REBAR_GetBand(infoPtr
, i
);
2471 if (HIDDENBAND(lpBand
)) continue;
2472 if (lpBand
->iRow
!= iRow
) continue;
2473 j
= lpBand
->rcBand
.bottom
- lpBand
->rcBand
.top
;
2474 if (j
> ret
) ret
= j
;
2477 TRACE("row %d, height %d\n", iRow
, ret
);
2483 static inline LRESULT
2484 REBAR_GetTextColor (const REBAR_INFO
*infoPtr
)
2486 TRACE("text color 0x%06x!\n", infoPtr
->clrText
);
2488 return infoPtr
->clrText
;
2492 static inline LRESULT
2493 REBAR_GetToolTips (const REBAR_INFO
*infoPtr
)
2495 return (LRESULT
)infoPtr
->hwndToolTip
;
2499 static inline LRESULT
2500 REBAR_GetUnicodeFormat (const REBAR_INFO
*infoPtr
)
2502 TRACE("%s hwnd=%p\n",
2503 infoPtr
->bUnicode
? "TRUE" : "FALSE", infoPtr
->hwndSelf
);
2505 return infoPtr
->bUnicode
;
2509 static inline LRESULT
2510 REBAR_GetVersion (const REBAR_INFO
*infoPtr
)
2512 TRACE("version %d\n", infoPtr
->iVersion
);
2513 return infoPtr
->iVersion
;
2518 REBAR_HitTest (const REBAR_INFO
*infoPtr
, LPRBHITTESTINFO lprbht
)
2523 REBAR_InternalHitTest (infoPtr
, &lprbht
->pt
, &lprbht
->flags
, &lprbht
->iBand
);
2525 return lprbht
->iBand
;
2530 REBAR_IdToIndex (const REBAR_INFO
*infoPtr
, UINT uId
)
2534 if (infoPtr
->uNumBands
< 1)
2537 for (i
= 0; i
< infoPtr
->uNumBands
; i
++) {
2538 if (REBAR_GetBand(infoPtr
, i
)->wID
== uId
) {
2539 TRACE("id %u is band %u found!\n", uId
, i
);
2544 TRACE("id %u is not found\n", uId
);
2550 REBAR_InsertBandT(REBAR_INFO
*infoPtr
, INT iIndex
, const REBARBANDINFOW
*lprbbi
, BOOL bUnicode
)
2554 if (!lprbbi
|| lprbbi
->cbSize
< REBARBANDINFOA_V3_SIZE
)
2557 /* trace the index as signed to see the -1 */
2558 TRACE("insert band at %d (bUnicode=%d)!\n", iIndex
, bUnicode
);
2559 REBAR_DumpBandInfo(lprbbi
);
2561 if (!(lpBand
= Alloc(sizeof(REBAR_BAND
)))) return FALSE
;
2562 if ((iIndex
== -1) || (iIndex
> infoPtr
->uNumBands
))
2563 iIndex
= infoPtr
->uNumBands
;
2564 if (DPA_InsertPtr(infoPtr
->bands
, iIndex
, lpBand
) == -1)
2569 infoPtr
->uNumBands
++;
2571 TRACE("index %d!\n", iIndex
);
2573 /* initialize band */
2574 memset(lpBand
, 0, sizeof(*lpBand
));
2575 lpBand
->clrFore
= infoPtr
->clrText
== CLR_NONE
? infoPtr
->clrBtnText
:
2577 lpBand
->clrBack
= infoPtr
->clrBk
== CLR_NONE
? infoPtr
->clrBtnFace
:
2579 lpBand
->iImage
= -1;
2581 REBAR_CommonSetupBand(infoPtr
->hwndSelf
, lprbbi
, lpBand
);
2583 /* Make sure the defaults for these are correct */
2584 if (lprbbi
->cbSize
< REBARBANDINFOA_V6_SIZE
|| !(lpBand
->fStyle
& RBBS_VARIABLEHEIGHT
)) {
2585 lpBand
->cyChild
= lpBand
->cyMinChild
;
2586 lpBand
->cyMaxChild
= 0x7fffffff;
2587 lpBand
->cyIntegral
= 0;
2590 if ((lprbbi
->fMask
& RBBIM_TEXT
) && (lprbbi
->lpText
)) {
2592 Str_SetPtrW(&lpBand
->lpText
, lprbbi
->lpText
);
2594 Str_SetPtrAtoW(&lpBand
->lpText
, (LPSTR
)lprbbi
->lpText
);
2597 REBAR_ValidateBand (infoPtr
, lpBand
);
2598 /* On insert of second band, revalidate band 1 to possible add gripper */
2599 if (infoPtr
->uNumBands
== 2)
2600 REBAR_ValidateBand (infoPtr
, REBAR_GetBand(infoPtr
, 0));
2602 REBAR_DumpBand (infoPtr
);
2604 REBAR_Layout(infoPtr
);
2605 InvalidateRect(infoPtr
->hwndSelf
, NULL
, TRUE
);
2612 REBAR_MaximizeBand (const REBAR_INFO
*infoPtr
, INT iBand
, LPARAM lParam
)
2615 int iRowBegin
, iRowEnd
;
2616 int cxDesired
, extra
, extraOrig
;
2620 if (infoPtr
->uNumBands
== 0 || iBand
< 0 || iBand
>= infoPtr
->uNumBands
) {
2622 ERR("Illegal MaximizeBand, requested=%d, current band count=%d\n",
2623 iBand
, infoPtr
->uNumBands
);
2627 lpBand
= REBAR_GetBand(infoPtr
, iBand
);
2629 if (lpBand
->fStyle
& RBBS_HIDDEN
)
2631 /* Windows is buggy and creates a hole */
2632 WARN("Ignoring maximize request on a hidden band (%d)\n", iBand
);
2636 cxIdealBand
= lpBand
->cxIdeal
+ lpBand
->cxHeader
+ REBAR_POST_CHILD
;
2637 if (lParam
&& (lpBand
->cxEffective
< cxIdealBand
))
2638 cxDesired
= cxIdealBand
;
2640 cxDesired
= infoPtr
->calcSize
.cx
;
2642 iRowBegin
= get_row_begin_for_band(infoPtr
, iBand
);
2643 iRowEnd
= get_row_end_for_band(infoPtr
, iBand
);
2644 extraOrig
= extra
= cxDesired
- lpBand
->cxEffective
;
2646 extra
= REBAR_ShrinkBandsRTL(infoPtr
, iRowBegin
, iBand
, extra
, TRUE
);
2648 extra
= REBAR_ShrinkBandsLTR(infoPtr
, next_visible(infoPtr
, iBand
), iRowEnd
, extra
, TRUE
);
2649 lpBand
->cxEffective
+= extraOrig
- extra
;
2650 lpBand
->cx
= lpBand
->cxEffective
;
2651 TRACE("(%d, %ld): Wanted size %d, obtained %d (shrink %d, %d)\n", iBand
, lParam
, cxDesired
, lpBand
->cx
, extraOrig
, extra
);
2652 REBAR_SetRowRectsX(infoPtr
, iRowBegin
, iRowEnd
);
2654 if (infoPtr
->dwStyle
& CCS_VERT
)
2655 REBAR_CalcVertBand(infoPtr
, iRowBegin
, iRowEnd
);
2657 REBAR_CalcHorzBand(infoPtr
, iRowBegin
, iRowEnd
);
2658 REBAR_MoveChildWindows(infoPtr
, iRowBegin
, iRowEnd
);
2665 REBAR_MinimizeBand (const REBAR_INFO
*infoPtr
, INT iBand
)
2668 int iPrev
, iRowBegin
, iRowEnd
;
2670 /* A "minimize" band is equivalent to "dragging" the gripper
2671 * of than band to the right till the band is only the size
2676 if (infoPtr
->uNumBands
== 0 || iBand
< 0 || iBand
>= infoPtr
->uNumBands
) {
2678 ERR("Illegal MinimizeBand, requested=%d, current band count=%d\n",
2679 iBand
, infoPtr
->uNumBands
);
2683 /* compute amount of movement and validate */
2684 lpBand
= REBAR_GetBand(infoPtr
, iBand
);
2686 if (lpBand
->fStyle
& RBBS_HIDDEN
)
2688 /* Windows is buggy and creates a hole/overlap */
2689 WARN("Ignoring minimize request on a hidden band (%d)\n", iBand
);
2693 iPrev
= prev_visible(infoPtr
, iBand
);
2694 /* if first band in row */
2695 if (iPrev
< 0 || REBAR_GetBand(infoPtr
, iPrev
)->iRow
!= lpBand
->iRow
) {
2696 int iNext
= next_visible(infoPtr
, iBand
);
2697 if (iNext
< infoPtr
->uNumBands
&& REBAR_GetBand(infoPtr
, iNext
)->iRow
== lpBand
->iRow
) {
2698 TRACE("(%d): Minimizing the first band in row is by maximizing the second\n", iBand
);
2699 REBAR_MaximizeBand(infoPtr
, iNext
, FALSE
);
2702 TRACE("(%d): Only one band in row - nothing to do\n", iBand
);
2706 REBAR_GetBand(infoPtr
, iPrev
)->cxEffective
+= lpBand
->cxEffective
- lpBand
->cxMinBand
;
2707 REBAR_GetBand(infoPtr
, iPrev
)->cx
= REBAR_GetBand(infoPtr
, iPrev
)->cxEffective
;
2708 lpBand
->cx
= lpBand
->cxEffective
= lpBand
->cxMinBand
;
2710 iRowBegin
= get_row_begin_for_band(infoPtr
, iBand
);
2711 iRowEnd
= get_row_end_for_band(infoPtr
, iBand
);
2712 REBAR_SetRowRectsX(infoPtr
, iRowBegin
, iRowEnd
);
2714 if (infoPtr
->dwStyle
& CCS_VERT
)
2715 REBAR_CalcVertBand(infoPtr
, iRowBegin
, iRowEnd
);
2717 REBAR_CalcHorzBand(infoPtr
, iRowBegin
, iRowEnd
);
2718 REBAR_MoveChildWindows(infoPtr
, iRowBegin
, iRowEnd
);
2724 REBAR_MoveBand (REBAR_INFO
*infoPtr
, INT iFrom
, INT iTo
)
2729 if ((infoPtr
->uNumBands
== 0) ||
2730 (iFrom
< 0) || iFrom
>= infoPtr
->uNumBands
||
2731 (iTo
< 0) || iTo
>= infoPtr
->uNumBands
) {
2733 ERR("Illegal MoveBand, from=%d, to=%d, current band count=%d\n",
2734 iFrom
, iTo
, infoPtr
->uNumBands
);
2738 lpBand
= REBAR_GetBand(infoPtr
, iFrom
);
2739 DPA_DeletePtr(infoPtr
->bands
, iFrom
);
2740 DPA_InsertPtr(infoPtr
->bands
, iTo
, lpBand
);
2742 TRACE("moved band %d to index %d\n", iFrom
, iTo
);
2743 REBAR_DumpBand (infoPtr
);
2745 /* **************************************************** */
2747 /* We do not do a REBAR_Layout here because the native */
2748 /* control does not do that. The actual layout and */
2749 /* repaint is done by the *next* real action, ex.: */
2750 /* RB_INSERTBAND, RB_DELETEBAND, RB_SIZETORECT, etc. */
2752 /* **************************************************** */
2758 /* return TRUE if two strings are different */
2760 REBAR_strdifW( LPCWSTR a
, LPCWSTR b
)
2762 return ( (a
&& !b
) || (b
&& !a
) || (a
&& b
&& lstrcmpW(a
, b
) ) );
2766 REBAR_SetBandInfoT(REBAR_INFO
*infoPtr
, INT iBand
, const REBARBANDINFOW
*lprbbi
, BOOL bUnicode
)
2771 if (!lprbbi
|| lprbbi
->cbSize
< REBARBANDINFOA_V3_SIZE
)
2774 if (iBand
>= infoPtr
->uNumBands
)
2777 TRACE("index %d\n", iBand
);
2778 REBAR_DumpBandInfo (lprbbi
);
2780 /* set band information */
2781 lpBand
= REBAR_GetBand(infoPtr
, iBand
);
2783 uChanged
= REBAR_CommonSetupBand (infoPtr
->hwndSelf
, lprbbi
, lpBand
);
2784 if (lprbbi
->fMask
& RBBIM_TEXT
) {
2787 Str_SetPtrW(&wstr
, lprbbi
->lpText
);
2789 Str_SetPtrAtoW(&wstr
, (LPSTR
)lprbbi
->lpText
);
2791 if (REBAR_strdifW(wstr
, lpBand
->lpText
)) {
2792 Free(lpBand
->lpText
);
2793 lpBand
->lpText
= wstr
;
2794 uChanged
|= RBBIM_TEXT
;
2800 REBAR_ValidateBand (infoPtr
, lpBand
);
2802 REBAR_DumpBand (infoPtr
);
2804 if (uChanged
& (RBBIM_CHILDSIZE
| RBBIM_SIZE
| RBBIM_STYLE
| RBBIM_IMAGE
)) {
2805 REBAR_Layout(infoPtr
);
2806 InvalidateRect(infoPtr
->hwndSelf
, NULL
, TRUE
);
2814 REBAR_SetBarInfo (REBAR_INFO
*infoPtr
, const REBARINFO
*lpInfo
)
2819 if (!lpInfo
|| lpInfo
->cbSize
< sizeof (REBARINFO
))
2822 TRACE("setting bar info!\n");
2824 if (lpInfo
->fMask
& RBIM_IMAGELIST
) {
2825 infoPtr
->himl
= lpInfo
->himl
;
2826 if (infoPtr
->himl
) {
2828 ImageList_GetIconSize (infoPtr
->himl
, &cx
, &cy
);
2829 infoPtr
->imageSize
.cx
= cx
;
2830 infoPtr
->imageSize
.cy
= cy
;
2833 infoPtr
->imageSize
.cx
= 0;
2834 infoPtr
->imageSize
.cy
= 0;
2836 TRACE("new image cx=%d, cy=%d\n", infoPtr
->imageSize
.cx
,
2837 infoPtr
->imageSize
.cy
);
2840 /* revalidate all bands to reset flags for images in headers of bands */
2841 for (i
=0; i
<infoPtr
->uNumBands
; i
++) {
2842 lpBand
= REBAR_GetBand(infoPtr
, i
);
2843 REBAR_ValidateBand (infoPtr
, lpBand
);
2851 REBAR_SetBkColor (REBAR_INFO
*infoPtr
, COLORREF clr
)
2855 clrTemp
= infoPtr
->clrBk
;
2856 infoPtr
->clrBk
= clr
;
2858 TRACE("background color 0x%06x!\n", infoPtr
->clrBk
);
2864 /* << REBAR_SetColorScheme >> */
2865 /* << REBAR_SetPalette >> */
2869 REBAR_SetParent (REBAR_INFO
*infoPtr
, HWND parent
)
2871 HWND hwndTemp
= infoPtr
->hwndNotify
;
2873 infoPtr
->hwndNotify
= parent
;
2875 return (LRESULT
)hwndTemp
;
2880 REBAR_SetTextColor (REBAR_INFO
*infoPtr
, COLORREF clr
)
2884 clrTemp
= infoPtr
->clrText
;
2885 infoPtr
->clrText
= clr
;
2887 TRACE("text color 0x%06x!\n", infoPtr
->clrText
);
2893 /* << REBAR_SetTooltips >> */
2896 static inline LRESULT
2897 REBAR_SetUnicodeFormat (REBAR_INFO
*infoPtr
, BOOL unicode
)
2899 BOOL bTemp
= infoPtr
->bUnicode
;
2901 TRACE("to %s hwnd=%p, was %s\n",
2902 unicode
? "TRUE" : "FALSE", infoPtr
->hwndSelf
,
2903 (bTemp
) ? "TRUE" : "FALSE");
2905 infoPtr
->bUnicode
= unicode
;
2912 REBAR_SetVersion (REBAR_INFO
*infoPtr
, INT iVersion
)
2914 INT iOldVersion
= infoPtr
->iVersion
;
2916 if (iVersion
> COMCTL32_VERSION
)
2919 infoPtr
->iVersion
= iVersion
;
2921 TRACE("new version %d\n", iVersion
);
2928 REBAR_ShowBand (REBAR_INFO
*infoPtr
, INT iBand
, BOOL show
)
2932 if (iBand
< 0 || iBand
>= infoPtr
->uNumBands
)
2935 lpBand
= REBAR_GetBand(infoPtr
, iBand
);
2938 TRACE("show band %d\n", iBand
);
2939 lpBand
->fStyle
= lpBand
->fStyle
& ~RBBS_HIDDEN
;
2940 if (IsWindow (lpBand
->hwndChild
))
2941 ShowWindow (lpBand
->hwndChild
, SW_SHOW
);
2944 TRACE("hide band %d\n", iBand
);
2945 lpBand
->fStyle
= lpBand
->fStyle
| RBBS_HIDDEN
;
2946 if (IsWindow (lpBand
->hwndChild
))
2947 ShowWindow (lpBand
->hwndChild
, SW_HIDE
);
2950 REBAR_Layout(infoPtr
);
2951 InvalidateRect(infoPtr
->hwndSelf
, NULL
, TRUE
);
2958 REBAR_SizeToRect (REBAR_INFO
*infoPtr
, WPARAM flags
, RECT
*lpRect
)
2960 if (!lpRect
) return FALSE
;
2962 TRACE("[%s]\n", wine_dbgstr_rect(lpRect
));
2963 REBAR_SizeToHeight(infoPtr
, get_rect_cy(infoPtr
, lpRect
));
2966 /* Note that this undocumented flag is available on comctl32 v6 or later */
2967 if ((flags
& RBSTR_CHANGERECT
) != 0)
2970 GetClientRect(infoPtr
->hwndSelf
, &rcRebar
);
2971 lpRect
->bottom
= lpRect
->top
+ (rcRebar
.bottom
- rcRebar
.top
);
2980 REBAR_Create (REBAR_INFO
*infoPtr
, LPCREATESTRUCTW cs
)
2984 if (TRACE_ON(rebar
)) {
2985 GetWindowRect(infoPtr
->hwndSelf
, &wnrc1
);
2986 GetClientRect(infoPtr
->hwndSelf
, &clrc1
);
2987 TRACE("window=(%s) client=(%s) cs=(%d,%d %dx%d)\n",
2988 wine_dbgstr_rect(&wnrc1
), wine_dbgstr_rect(&clrc1
),
2989 cs
->x
, cs
->y
, cs
->cx
, cs
->cy
);
2992 TRACE("created!\n");
2994 if (OpenThemeData (infoPtr
->hwndSelf
, themeClass
))
2996 /* native seems to clear WS_BORDER when themed */
2997 infoPtr
->dwStyle
&= ~WS_BORDER
;
3005 REBAR_Destroy (REBAR_INFO
*infoPtr
)
3010 /* clean up each band */
3011 for (i
= 0; i
< infoPtr
->uNumBands
; i
++) {
3012 lpBand
= REBAR_GetBand(infoPtr
, i
);
3014 /* delete text strings */
3015 Free (lpBand
->lpText
);
3016 lpBand
->lpText
= NULL
;
3017 /* destroy child window */
3018 DestroyWindow (lpBand
->hwndChild
);
3022 /* free band array */
3023 DPA_Destroy (infoPtr
->bands
);
3024 infoPtr
->bands
= NULL
;
3026 DestroyCursor (infoPtr
->hcurArrow
);
3027 DestroyCursor (infoPtr
->hcurHorz
);
3028 DestroyCursor (infoPtr
->hcurVert
);
3029 DestroyCursor (infoPtr
->hcurDrag
);
3030 if (infoPtr
->hDefaultFont
) DeleteObject (infoPtr
->hDefaultFont
);
3031 SetWindowLongPtrW (infoPtr
->hwndSelf
, 0, 0);
3033 CloseThemeData (GetWindowTheme (infoPtr
->hwndSelf
));
3035 /* free rebar info data */
3037 TRACE("destroyed!\n");
3042 REBAR_GetFont (const REBAR_INFO
*infoPtr
)
3044 return (LRESULT
)infoPtr
->hFont
;
3048 REBAR_PushChevron(const REBAR_INFO
*infoPtr
, UINT uBand
, LPARAM lParam
)
3050 if (uBand
< infoPtr
->uNumBands
)
3052 NMREBARCHEVRON nmrbc
;
3053 REBAR_BAND
*lpBand
= REBAR_GetBand(infoPtr
, uBand
);
3055 TRACE("Pressed chevron on band %u\n", uBand
);
3057 /* redraw chevron in pushed state */
3058 lpBand
->fDraw
|= DRAW_CHEVRONPUSHED
;
3059 RedrawWindow(infoPtr
->hwndSelf
, &lpBand
->rcChevron
,0,
3060 RDW_ERASE
|RDW_INVALIDATE
|RDW_UPDATENOW
);
3062 /* notify app so it can display a popup menu or whatever */
3063 nmrbc
.uBand
= uBand
;
3064 nmrbc
.wID
= lpBand
->wID
;
3065 nmrbc
.lParam
= lpBand
->lParam
;
3066 nmrbc
.rc
= lpBand
->rcChevron
;
3067 nmrbc
.lParamNM
= lParam
;
3068 REBAR_Notify((NMHDR
*)&nmrbc
, infoPtr
, RBN_CHEVRONPUSHED
);
3070 /* redraw chevron in previous state */
3071 lpBand
->fDraw
&= ~DRAW_CHEVRONPUSHED
;
3072 InvalidateRect(infoPtr
->hwndSelf
, &lpBand
->rcChevron
, TRUE
);
3080 REBAR_LButtonDown (REBAR_INFO
*infoPtr
, LPARAM lParam
)
3085 ptMouseDown
.x
= (short)LOWORD(lParam
);
3086 ptMouseDown
.y
= (short)HIWORD(lParam
);
3088 REBAR_InternalHitTest(infoPtr
, &ptMouseDown
, &htFlags
, &iHitBand
);
3090 if (htFlags
== RBHT_CHEVRON
)
3092 REBAR_PushChevron(infoPtr
, iHitBand
, 0);
3094 else if (htFlags
== RBHT_GRABBER
|| htFlags
== RBHT_CAPTION
)
3098 TRACE("Starting drag\n");
3100 lpBand
= REBAR_GetBand(infoPtr
, iHitBand
);
3102 SetCapture (infoPtr
->hwndSelf
);
3103 infoPtr
->iGrabbedBand
= iHitBand
;
3105 /* save off the LOWORD and HIWORD of lParam as initial x,y */
3106 infoPtr
->dragStart
.x
= (short)LOWORD(lParam
);
3107 infoPtr
->dragStart
.y
= (short)HIWORD(lParam
);
3108 infoPtr
->dragNow
= infoPtr
->dragStart
;
3109 if (infoPtr
->dwStyle
& CCS_VERT
)
3110 infoPtr
->ihitoffset
= infoPtr
->dragStart
.y
- (lpBand
->rcBand
.left
+ REBAR_PRE_GRIPPER
);
3112 infoPtr
->ihitoffset
= infoPtr
->dragStart
.x
- (lpBand
->rcBand
.left
+ REBAR_PRE_GRIPPER
);
3118 REBAR_LButtonUp (REBAR_INFO
*infoPtr
)
3120 if (infoPtr
->iGrabbedBand
>= 0)
3125 infoPtr
->dragStart
.x
= 0;
3126 infoPtr
->dragStart
.y
= 0;
3127 infoPtr
->dragNow
= infoPtr
->dragStart
;
3131 if (infoPtr
->fStatus
& BEGIN_DRAG_ISSUED
) {
3132 REBAR_Notify(&layout
, infoPtr
, RBN_LAYOUTCHANGED
);
3133 REBAR_Notify_NMREBAR (infoPtr
, infoPtr
->iGrabbedBand
, RBN_ENDDRAG
);
3134 infoPtr
->fStatus
&= ~BEGIN_DRAG_ISSUED
;
3137 infoPtr
->iGrabbedBand
= -1;
3139 GetClientRect(infoPtr
->hwndSelf
, &rect
);
3140 InvalidateRect(infoPtr
->hwndSelf
, NULL
, TRUE
);
3147 REBAR_MouseLeave (REBAR_INFO
*infoPtr
)
3149 if (infoPtr
->ichevronhotBand
>= 0)
3151 REBAR_BAND
*lpChevronBand
= REBAR_GetBand(infoPtr
, infoPtr
->ichevronhotBand
);
3152 if (lpChevronBand
->fDraw
& DRAW_CHEVRONHOT
)
3154 lpChevronBand
->fDraw
&= ~DRAW_CHEVRONHOT
;
3155 InvalidateRect(infoPtr
->hwndSelf
, &lpChevronBand
->rcChevron
, TRUE
);
3158 infoPtr
->iOldBand
= -1;
3159 infoPtr
->ichevronhotBand
= -2;
3165 REBAR_MouseMove (REBAR_INFO
*infoPtr
, LPARAM lParam
)
3167 REBAR_BAND
*lpChevronBand
;
3170 ptMove
.x
= (short)LOWORD(lParam
);
3171 ptMove
.y
= (short)HIWORD(lParam
);
3173 /* if we are currently dragging a band */
3174 if (infoPtr
->iGrabbedBand
>= 0)
3177 int yPtMove
= (infoPtr
->dwStyle
& CCS_VERT
? ptMove
.x
: ptMove
.y
);
3179 if (GetCapture() != infoPtr
->hwndSelf
)
3180 ERR("We are dragging but haven't got capture?!?\n");
3182 band
= REBAR_GetBand(infoPtr
, infoPtr
->iGrabbedBand
);
3184 /* if mouse did not move much, exit */
3185 if ((abs(ptMove
.x
- infoPtr
->dragNow
.x
) <= mindragx
) &&
3186 (abs(ptMove
.y
- infoPtr
->dragNow
.y
) <= mindragy
)) return 0;
3188 /* on first significant mouse movement, issue notify */
3189 if (!(infoPtr
->fStatus
& BEGIN_DRAG_ISSUED
)) {
3190 if (REBAR_Notify_NMREBAR (infoPtr
, -1, RBN_BEGINDRAG
)) {
3191 /* Notify returned TRUE - abort drag */
3192 infoPtr
->dragStart
.x
= 0;
3193 infoPtr
->dragStart
.y
= 0;
3194 infoPtr
->dragNow
= infoPtr
->dragStart
;
3195 infoPtr
->iGrabbedBand
= -1;
3199 infoPtr
->fStatus
|= BEGIN_DRAG_ISSUED
;
3202 /* Test for valid drag case - must not be first band in row */
3203 if ((yPtMove
< band
->rcBand
.top
) ||
3204 (yPtMove
> band
->rcBand
.bottom
)) {
3205 REBAR_HandleUDDrag (infoPtr
, &ptMove
);
3208 REBAR_HandleLRDrag (infoPtr
, &ptMove
);
3215 TRACKMOUSEEVENT trackinfo
;
3217 REBAR_InternalHitTest(infoPtr
, &ptMove
, &htFlags
, &iHitBand
);
3219 if (infoPtr
->iOldBand
>= 0 && infoPtr
->iOldBand
== infoPtr
->ichevronhotBand
)
3221 lpChevronBand
= REBAR_GetBand(infoPtr
, infoPtr
->ichevronhotBand
);
3222 if (lpChevronBand
->fDraw
& DRAW_CHEVRONHOT
)
3224 lpChevronBand
->fDraw
&= ~DRAW_CHEVRONHOT
;
3225 InvalidateRect(infoPtr
->hwndSelf
, &lpChevronBand
->rcChevron
, TRUE
);
3227 infoPtr
->ichevronhotBand
= -2;
3230 if (htFlags
== RBHT_CHEVRON
)
3232 /* fill in the TRACKMOUSEEVENT struct */
3233 trackinfo
.cbSize
= sizeof(TRACKMOUSEEVENT
);
3234 trackinfo
.dwFlags
= TME_QUERY
;
3235 trackinfo
.hwndTrack
= infoPtr
->hwndSelf
;
3236 trackinfo
.dwHoverTime
= 0;
3238 /* call _TrackMouseEvent to see if we are currently tracking for this hwnd */
3239 _TrackMouseEvent(&trackinfo
);
3241 /* Make sure tracking is enabled so we receive a WM_MOUSELEAVE message */
3242 if(!(trackinfo
.dwFlags
& TME_LEAVE
))
3244 trackinfo
.dwFlags
= TME_LEAVE
; /* notify upon leaving */
3246 /* call TRACKMOUSEEVENT so we receive a WM_MOUSELEAVE message */
3247 /* and can properly deactivate the hot chevron */
3248 _TrackMouseEvent(&trackinfo
);
3251 lpChevronBand
= REBAR_GetBand(infoPtr
, iHitBand
);
3252 if (!(lpChevronBand
->fDraw
& DRAW_CHEVRONHOT
))
3254 lpChevronBand
->fDraw
|= DRAW_CHEVRONHOT
;
3255 InvalidateRect(infoPtr
->hwndSelf
, &lpChevronBand
->rcChevron
, TRUE
);
3256 infoPtr
->ichevronhotBand
= iHitBand
;
3259 infoPtr
->iOldBand
= iHitBand
;
3266 static inline LRESULT
3267 REBAR_NCCalcSize (const REBAR_INFO
*infoPtr
, RECT
*rect
)
3271 if (infoPtr
->dwStyle
& WS_BORDER
) {
3272 rect
->left
= min(rect
->left
+ GetSystemMetrics(SM_CXEDGE
), rect
->right
);
3273 rect
->right
= max(rect
->right
- GetSystemMetrics(SM_CXEDGE
), rect
->left
);
3274 rect
->top
= min(rect
->top
+ GetSystemMetrics(SM_CYEDGE
), rect
->bottom
);
3275 rect
->bottom
= max(rect
->bottom
- GetSystemMetrics(SM_CYEDGE
), rect
->top
);
3277 else if ((theme
= GetWindowTheme (infoPtr
->hwndSelf
)))
3279 /* FIXME: should use GetThemeInt */
3281 rect
->top
= (rect
->top
+ 1 < rect
->bottom
) ? rect
->top
: rect
->bottom
;
3283 rect
->top
= min(rect
->top
+ 1, rect
->bottom
);
3286 TRACE("new client=(%s)\n", wine_dbgstr_rect(rect
));
3292 REBAR_NCCreate (HWND hwnd
, const CREATESTRUCTW
*cs
)
3294 REBAR_INFO
*infoPtr
= REBAR_GetInfoPtr (hwnd
);
3296 NONCLIENTMETRICSW ncm
;
3300 ERR("Strange info structure pointer *not* NULL\n");
3304 if (TRACE_ON(rebar
)) {
3305 GetWindowRect(hwnd
, &wnrc1
);
3306 GetClientRect(hwnd
, &clrc1
);
3307 TRACE("window=(%s) client=(%s) cs=(%d,%d %dx%d)\n",
3308 wine_dbgstr_rect(&wnrc1
), wine_dbgstr_rect(&clrc1
),
3309 cs
->x
, cs
->y
, cs
->cx
, cs
->cy
);
3312 /* allocate memory for info structure */
3313 infoPtr
= Alloc (sizeof(REBAR_INFO
));
3314 SetWindowLongPtrW (hwnd
, 0, (DWORD_PTR
)infoPtr
);
3316 /* initialize info structure - initial values are 0 */
3317 infoPtr
->clrBk
= CLR_NONE
;
3318 infoPtr
->clrText
= CLR_NONE
;
3319 infoPtr
->clrBtnText
= comctl32_color
.clrBtnText
;
3320 infoPtr
->clrBtnFace
= comctl32_color
.clrBtnFace
;
3321 infoPtr
->iOldBand
= -1;
3322 infoPtr
->ichevronhotBand
= -2;
3323 infoPtr
->iGrabbedBand
= -1;
3324 infoPtr
->hwndSelf
= hwnd
;
3325 infoPtr
->DoRedraw
= TRUE
;
3326 infoPtr
->hcurArrow
= LoadCursorW (0, (LPWSTR
)IDC_ARROW
);
3327 infoPtr
->hcurHorz
= LoadCursorW (0, (LPWSTR
)IDC_SIZEWE
);
3328 infoPtr
->hcurVert
= LoadCursorW (0, (LPWSTR
)IDC_SIZENS
);
3329 infoPtr
->hcurDrag
= LoadCursorW (0, (LPWSTR
)IDC_SIZE
);
3330 infoPtr
->fStatus
= 0;
3331 infoPtr
->hFont
= GetStockObject (SYSTEM_FONT
);
3332 infoPtr
->bands
= DPA_Create(8);
3334 /* issue WM_NOTIFYFORMAT to get unicode status of parent */
3335 REBAR_NotifyFormat(infoPtr
, NF_REQUERY
);
3337 /* Stow away the original style */
3338 infoPtr
->orgStyle
= cs
->style
;
3339 /* add necessary styles to the requested styles */
3340 infoPtr
->dwStyle
= cs
->style
| WS_VISIBLE
;
3341 if ((infoPtr
->dwStyle
& CCS_LAYOUT_MASK
) == 0)
3342 infoPtr
->dwStyle
|= CCS_TOP
;
3343 SetWindowLongW (hwnd
, GWL_STYLE
, infoPtr
->dwStyle
);
3345 /* get font handle for Caption Font */
3346 ncm
.cbSize
= sizeof(ncm
);
3347 SystemParametersInfoW (SPI_GETNONCLIENTMETRICS
, ncm
.cbSize
, &ncm
, 0);
3348 /* if the font is bold, set to normal */
3349 if (ncm
.lfCaptionFont
.lfWeight
> FW_NORMAL
) {
3350 ncm
.lfCaptionFont
.lfWeight
= FW_NORMAL
;
3352 tfont
= CreateFontIndirectW (&ncm
.lfCaptionFont
);
3354 infoPtr
->hFont
= infoPtr
->hDefaultFont
= tfont
;
3362 REBAR_NCHitTest (const REBAR_INFO
*infoPtr
, LPARAM lParam
)
3368 LRESULT ret
= HTCLIENT
;
3371 * Differences from doc at MSDN (as observed with version 4.71 of
3373 * 1. doc says nmmouse.pt is in screen coord, trace shows client coord.
3374 * 2. if band is not identified .dwItemSpec is 0xffffffff.
3375 * 3. native always seems to return HTCLIENT if notify return is 0.
3378 clpt
.x
= (short)LOWORD(lParam
);
3379 clpt
.y
= (short)HIWORD(lParam
);
3380 ScreenToClient (infoPtr
->hwndSelf
, &clpt
);
3381 REBAR_InternalHitTest (infoPtr
, &clpt
, &scrap
,
3382 (INT
*)&nmmouse
.dwItemSpec
);
3383 nmmouse
.dwItemData
= 0;
3385 nmmouse
.dwHitInfo
= 0;
3386 if ((i
= REBAR_Notify((NMHDR
*) &nmmouse
, infoPtr
, NM_NCHITTEST
))) {
3387 TRACE("notify changed return value from %ld to %d\n",
3391 TRACE("returning %ld, client point (%d,%d)\n", ret
, clpt
.x
, clpt
.y
);
3397 REBAR_NCPaint (const REBAR_INFO
*infoPtr
)
3403 if (infoPtr
->dwStyle
& WS_MINIMIZE
)
3404 return 0; /* Nothing to do */
3406 if (infoPtr
->dwStyle
& WS_BORDER
) {
3408 /* adjust rectangle and draw the necessary edge */
3409 if (!(hdc
= GetDCEx( infoPtr
->hwndSelf
, 0, DCX_USESTYLE
| DCX_WINDOW
)))
3411 GetWindowRect (infoPtr
->hwndSelf
, &rcWindow
);
3412 OffsetRect (&rcWindow
, -rcWindow
.left
, -rcWindow
.top
);
3413 TRACE("rect (%s)\n", wine_dbgstr_rect(&rcWindow
));
3414 DrawEdge (hdc
, &rcWindow
, EDGE_ETCHED
, BF_RECT
);
3415 ReleaseDC( infoPtr
->hwndSelf
, hdc
);
3417 else if ((theme
= GetWindowTheme (infoPtr
->hwndSelf
)))
3419 /* adjust rectangle and draw the necessary edge */
3420 if (!(hdc
= GetDCEx( infoPtr
->hwndSelf
, 0, DCX_USESTYLE
| DCX_WINDOW
)))
3422 GetWindowRect (infoPtr
->hwndSelf
, &rcWindow
);
3423 OffsetRect (&rcWindow
, -rcWindow
.left
, -rcWindow
.top
);
3424 TRACE("rect (%s)\n", wine_dbgstr_rect(&rcWindow
));
3425 DrawThemeEdge (theme
, hdc
, 0, 0, &rcWindow
, BDR_RAISEDINNER
, BF_TOP
, NULL
);
3426 ReleaseDC( infoPtr
->hwndSelf
, hdc
);
3434 REBAR_NotifyFormat (REBAR_INFO
*infoPtr
, LPARAM cmd
)
3438 if (cmd
== NF_REQUERY
) {
3439 i
= SendMessageW(REBAR_GetNotifyParent (infoPtr
),
3440 WM_NOTIFYFORMAT
, (WPARAM
)infoPtr
->hwndSelf
, NF_QUERY
);
3441 if ((i
!= NFR_ANSI
) && (i
!= NFR_UNICODE
)) {
3442 ERR("wrong response to WM_NOTIFYFORMAT (%d), assuming ANSI\n", i
);
3445 infoPtr
->bUnicode
= (i
== NFR_UNICODE
);
3448 return (LRESULT
)((infoPtr
->bUnicode
) ? NFR_UNICODE
: NFR_ANSI
);
3453 REBAR_Paint (const REBAR_INFO
*infoPtr
, HDC hdc
)
3456 TRACE("painting\n");
3457 REBAR_Refresh (infoPtr
, hdc
);
3460 hdc
= BeginPaint (infoPtr
->hwndSelf
, &ps
);
3461 TRACE("painting (%s)\n", wine_dbgstr_rect(&ps
.rcPaint
));
3463 /* Erase area of paint if requested */
3464 REBAR_EraseBkGnd (infoPtr
, hdc
);
3466 REBAR_Refresh (infoPtr
, hdc
);
3467 EndPaint (infoPtr
->hwndSelf
, &ps
);
3475 REBAR_SetCursor (const REBAR_INFO
*infoPtr
, LPARAM lParam
)
3480 TRACE("code=0x%X id=0x%X\n", LOWORD(lParam
), HIWORD(lParam
));
3483 ScreenToClient (infoPtr
->hwndSelf
, &pt
);
3485 REBAR_InternalHitTest (infoPtr
, &pt
, &flags
, NULL
);
3487 if (flags
== RBHT_GRABBER
) {
3488 if ((infoPtr
->dwStyle
& CCS_VERT
) &&
3489 !(infoPtr
->dwStyle
& RBS_VERTICALGRIPPER
))
3490 SetCursor (infoPtr
->hcurVert
);
3492 SetCursor (infoPtr
->hcurHorz
);
3494 else if (flags
!= RBHT_CLIENT
)
3495 SetCursor (infoPtr
->hcurArrow
);
3502 REBAR_SetFont (REBAR_INFO
*infoPtr
, HFONT font
)
3507 infoPtr
->hFont
= font
;
3509 /* revalidate all bands to change sizes of text in headers of bands */
3510 for (i
=0; i
<infoPtr
->uNumBands
; i
++) {
3511 lpBand
= REBAR_GetBand(infoPtr
, i
);
3512 REBAR_ValidateBand (infoPtr
, lpBand
);
3515 REBAR_Layout(infoPtr
);
3520 /*****************************************************
3522 * Handles the WM_SETREDRAW message.
3525 * According to testing V4.71 of COMCTL32 returns the
3526 * *previous* status of the redraw flag (either 0 or -1)
3527 * instead of the MSDN documented value of 0 if handled
3529 *****************************************************/
3530 static inline LRESULT
3531 REBAR_SetRedraw (REBAR_INFO
*infoPtr
, BOOL redraw
)
3533 BOOL oldredraw
= infoPtr
->DoRedraw
;
3535 TRACE("set to %s, fStatus=%08x\n",
3536 (redraw
) ? "TRUE" : "FALSE", infoPtr
->fStatus
);
3537 infoPtr
->DoRedraw
= redraw
;
3539 if (infoPtr
->fStatus
& BAND_NEEDS_REDRAW
) {
3540 REBAR_MoveChildWindows (infoPtr
, 0, infoPtr
->uNumBands
);
3541 REBAR_ForceResize (infoPtr
);
3542 InvalidateRect (infoPtr
->hwndSelf
, NULL
, TRUE
);
3544 infoPtr
->fStatus
&= ~BAND_NEEDS_REDRAW
;
3546 return (oldredraw
) ? -1 : 0;
3551 REBAR_Size (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
3553 TRACE("wParam=%lx, lParam=%lx\n", wParam
, lParam
);
3555 /* avoid _Layout resize recursion (but it shouldn't be infinite and it seems Windows does recurse) */
3556 if (infoPtr
->fStatus
& SELF_RESIZE
) {
3557 infoPtr
->fStatus
&= ~SELF_RESIZE
;
3558 TRACE("SELF_RESIZE was set, reset, fStatus=%08x lparam=%08lx\n",
3559 infoPtr
->fStatus
, lParam
);
3563 if (infoPtr
->dwStyle
& RBS_AUTOSIZE
)
3564 REBAR_AutoSize(infoPtr
, TRUE
);
3566 REBAR_Layout(infoPtr
);
3573 REBAR_StyleChanged (REBAR_INFO
*infoPtr
, INT nType
, const STYLESTRUCT
*lpStyle
)
3575 TRACE("current style=%08x, styleOld=%08x, style being set to=%08x\n",
3576 infoPtr
->dwStyle
, lpStyle
->styleOld
, lpStyle
->styleNew
);
3577 if (nType
== GWL_STYLE
)
3579 infoPtr
->orgStyle
= infoPtr
->dwStyle
= lpStyle
->styleNew
;
3580 if (GetWindowTheme (infoPtr
->hwndSelf
))
3581 infoPtr
->dwStyle
&= ~WS_BORDER
;
3582 /* maybe it should be COMMON_STYLES like in toolbar */
3583 if ((lpStyle
->styleNew
^ lpStyle
->styleOld
) & CCS_VERT
)
3584 REBAR_Layout(infoPtr
);
3589 /* update theme after a WM_THEMECHANGED message */
3590 static LRESULT
theme_changed (REBAR_INFO
* infoPtr
)
3592 HTHEME theme
= GetWindowTheme (infoPtr
->hwndSelf
);
3593 CloseThemeData (theme
);
3594 theme
= OpenThemeData (infoPtr
->hwndSelf
, themeClass
);
3595 /* WS_BORDER disappears when theming is enabled and reappears when
3597 infoPtr
->dwStyle
&= ~WS_BORDER
;
3598 infoPtr
->dwStyle
|= theme
? 0 : (infoPtr
->orgStyle
& WS_BORDER
);
3603 REBAR_WindowPosChanged (const REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
3608 ret
= DefWindowProcW(infoPtr
->hwndSelf
, WM_WINDOWPOSCHANGED
,
3610 GetWindowRect(infoPtr
->hwndSelf
, &rc
);
3611 TRACE("hwnd %p new pos (%s)\n", infoPtr
->hwndSelf
, wine_dbgstr_rect(&rc
));
3616 static LRESULT WINAPI
3617 REBAR_WindowProc (HWND hwnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
)
3619 REBAR_INFO
*infoPtr
= REBAR_GetInfoPtr (hwnd
);
3621 TRACE("hwnd=%p msg=%x wparam=%lx lparam=%lx\n",
3622 hwnd
, uMsg
, wParam
, lParam
);
3623 if (!infoPtr
&& (uMsg
!= WM_NCCREATE
))
3624 return DefWindowProcW (hwnd
, uMsg
, wParam
, lParam
);
3627 /* case RB_BEGINDRAG: */
3630 return REBAR_DeleteBand (infoPtr
, wParam
);
3632 /* case RB_DRAGMOVE: */
3633 /* case RB_ENDDRAG: */
3635 case RB_GETBANDBORDERS
:
3636 return REBAR_GetBandBorders (infoPtr
, wParam
, (LPRECT
)lParam
);
3638 case RB_GETBANDCOUNT
:
3639 return REBAR_GetBandCount (infoPtr
);
3641 case RB_GETBANDINFO_OLD
:
3642 case RB_GETBANDINFOA
:
3643 case RB_GETBANDINFOW
:
3644 return REBAR_GetBandInfoT(infoPtr
, wParam
, (LPREBARBANDINFOW
)lParam
,
3645 uMsg
== RB_GETBANDINFOW
);
3646 case RB_GETBARHEIGHT
:
3647 return REBAR_GetBarHeight (infoPtr
);
3650 return REBAR_GetBarInfo (infoPtr
, (LPREBARINFO
)lParam
);
3653 return REBAR_GetBkColor (infoPtr
);
3655 /* case RB_GETCOLORSCHEME: */
3656 /* case RB_GETDROPTARGET: */
3659 return REBAR_GetPalette (infoPtr
);
3662 return REBAR_GetRect (infoPtr
, wParam
, (LPRECT
)lParam
);
3664 case RB_GETROWCOUNT
:
3665 return REBAR_GetRowCount (infoPtr
);
3667 case RB_GETROWHEIGHT
:
3668 return REBAR_GetRowHeight (infoPtr
, wParam
);
3670 case RB_GETTEXTCOLOR
:
3671 return REBAR_GetTextColor (infoPtr
);
3673 case RB_GETTOOLTIPS
:
3674 return REBAR_GetToolTips (infoPtr
);
3676 case RB_GETUNICODEFORMAT
:
3677 return REBAR_GetUnicodeFormat (infoPtr
);
3679 case CCM_GETVERSION
:
3680 return REBAR_GetVersion (infoPtr
);
3683 return REBAR_HitTest (infoPtr
, (LPRBHITTESTINFO
)lParam
);
3686 return REBAR_IdToIndex (infoPtr
, wParam
);
3688 case RB_INSERTBANDA
:
3689 case RB_INSERTBANDW
:
3690 return REBAR_InsertBandT(infoPtr
, wParam
, (LPREBARBANDINFOW
)lParam
,
3691 uMsg
== RB_INSERTBANDW
);
3692 case RB_MAXIMIZEBAND
:
3693 return REBAR_MaximizeBand (infoPtr
, wParam
, lParam
);
3695 case RB_MINIMIZEBAND
:
3696 return REBAR_MinimizeBand (infoPtr
, wParam
);
3699 return REBAR_MoveBand (infoPtr
, wParam
, lParam
);
3701 case RB_PUSHCHEVRON
:
3702 return REBAR_PushChevron (infoPtr
, wParam
, lParam
);
3704 case RB_SETBANDINFOA
:
3705 case RB_SETBANDINFOW
:
3706 return REBAR_SetBandInfoT(infoPtr
, wParam
, (LPREBARBANDINFOW
)lParam
,
3707 uMsg
== RB_SETBANDINFOW
);
3709 return REBAR_SetBarInfo (infoPtr
, (LPREBARINFO
)lParam
);
3712 return REBAR_SetBkColor (infoPtr
, lParam
);
3714 /* case RB_SETCOLORSCHEME: */
3715 /* case RB_SETPALETTE: */
3718 return REBAR_SetParent (infoPtr
, (HWND
)wParam
);
3720 case RB_SETTEXTCOLOR
:
3721 return REBAR_SetTextColor (infoPtr
, lParam
);
3723 /* case RB_SETTOOLTIPS: */
3725 case RB_SETUNICODEFORMAT
:
3726 return REBAR_SetUnicodeFormat (infoPtr
, wParam
);
3728 case CCM_SETVERSION
:
3729 return REBAR_SetVersion (infoPtr
, (INT
)wParam
);
3732 return REBAR_ShowBand (infoPtr
, wParam
, lParam
);
3735 return REBAR_SizeToRect (infoPtr
, wParam
, (LPRECT
)lParam
);
3738 /* Messages passed to parent */
3742 case WM_MEASUREITEM
:
3743 return SendMessageW(REBAR_GetNotifyParent (infoPtr
), uMsg
, wParam
, lParam
);
3746 /* case WM_CHARTOITEM: supported according to ControlSpy */
3749 return REBAR_Create (infoPtr
, (LPCREATESTRUCTW
)lParam
);
3752 return REBAR_Destroy (infoPtr
);
3755 return REBAR_EraseBkGnd (infoPtr
, (HDC
)wParam
);
3758 return REBAR_GetFont (infoPtr
);
3760 /* case WM_LBUTTONDBLCLK: supported according to ControlSpy */
3762 case WM_LBUTTONDOWN
:
3763 return REBAR_LButtonDown (infoPtr
, lParam
);
3766 return REBAR_LButtonUp (infoPtr
);
3769 return REBAR_MouseMove (infoPtr
, lParam
);
3772 return REBAR_MouseLeave (infoPtr
);
3775 return REBAR_NCCalcSize (infoPtr
, (RECT
*)lParam
);
3778 return REBAR_NCCreate (hwnd
, (LPCREATESTRUCTW
)lParam
);
3781 return REBAR_NCHitTest (infoPtr
, lParam
);
3784 return REBAR_NCPaint (infoPtr
);
3786 case WM_NOTIFYFORMAT
:
3787 return REBAR_NotifyFormat (infoPtr
, lParam
);
3789 case WM_PRINTCLIENT
:
3791 return REBAR_Paint (infoPtr
, (HDC
)wParam
);
3793 /* case WM_PALETTECHANGED: supported according to ControlSpy */
3794 /* case WM_QUERYNEWPALETTE:supported according to ControlSpy */
3795 /* case WM_RBUTTONDOWN: supported according to ControlSpy */
3796 /* case WM_RBUTTONUP: supported according to ControlSpy */
3799 return REBAR_SetCursor (infoPtr
, lParam
);
3802 return REBAR_SetFont (infoPtr
, (HFONT
)wParam
);
3805 return REBAR_SetRedraw (infoPtr
, wParam
);
3808 return REBAR_Size (infoPtr
, wParam
, lParam
);
3810 case WM_STYLECHANGED
:
3811 return REBAR_StyleChanged (infoPtr
, wParam
, (LPSTYLESTRUCT
)lParam
);
3813 case WM_THEMECHANGED
:
3814 return theme_changed (infoPtr
);
3816 case WM_SYSCOLORCHANGE
:
3817 COMCTL32_RefreshSysColors();
3819 /* r51522 - Properly support WM_SYSCOLORCHANGE */
3820 infoPtr
->clrBtnText
= comctl32_color
.clrBtnText
;
3821 infoPtr
->clrBtnFace
= comctl32_color
.clrBtnFace
;
3825 /* case WM_VKEYTOITEM: supported according to ControlSpy */
3826 /* case WM_WININICHANGE: */
3828 case WM_WINDOWPOSCHANGED
:
3829 return REBAR_WindowPosChanged (infoPtr
, wParam
, lParam
);
3832 if ((uMsg
>= WM_USER
) && (uMsg
< WM_APP
) && !COMCTL32_IsReflectedMessage(uMsg
))
3833 ERR("unknown msg %04x wp=%08lx lp=%08lx\n",
3834 uMsg
, wParam
, lParam
);
3835 return DefWindowProcW (hwnd
, uMsg
, wParam
, lParam
);
3841 REBAR_Register (void)
3845 ZeroMemory (&wndClass
, sizeof(WNDCLASSW
));
3846 wndClass
.style
= CS_GLOBALCLASS
| CS_DBLCLKS
;
3847 wndClass
.lpfnWndProc
= REBAR_WindowProc
;
3848 wndClass
.cbClsExtra
= 0;
3849 wndClass
.cbWndExtra
= sizeof(REBAR_INFO
*);
3850 wndClass
.hCursor
= 0;
3851 wndClass
.hbrBackground
= (HBRUSH
)(COLOR_BTNFACE
+ 1);
3853 wndClass
.hbrBackground
= CreateSolidBrush(RGB(0,128,0));
3855 wndClass
.lpszClassName
= REBARCLASSNAMEW
;
3857 RegisterClassW (&wndClass
);
3859 mindragx
= GetSystemMetrics (SM_CXDRAG
);
3860 mindragy
= GetSystemMetrics (SM_CYDRAG
);
3866 REBAR_Unregister (void)
3868 UnregisterClassW (REBARCLASSNAMEW
, NULL
);