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.
51 * - WM_QUERYNEWPALETTE
58 * - NM_RELEASEDCAPTURE
64 * Native uses (on each draw!!) SM_CYBORDER (or SM_CXBORDER for CCS_VERT)
65 * to set the size of the separator width (the value SEP_WIDTH_SIZE
66 * in here). Should be fixed!!
70 * Testing: set to 1 to make background brush *always* green
75 * 3. REBAR_MoveChildWindows should have a loop because more than
76 * one pass (together with the RBN_CHILDSIZEs) is made on
77 * at least RB_INSERTBAND
88 #include "wine/unicode.h"
95 #include "wine/debug.h"
97 WINE_DEFAULT_DEBUG_CHANNEL(rebar
);
107 UINT cxMinChild
; /* valid if _CHILDSIZE */
108 UINT cyMinChild
; /* valid if _CHILDSIZE */
109 UINT cx
; /* valid if _SIZE */
112 UINT cyChild
; /* valid if _CHILDSIZE */
113 UINT cyMaxChild
; /* valid if _CHILDSIZE */
114 UINT cyIntegral
; /* valid if _CHILDSIZE */
119 INT cxEffective
; /* current cx for band */
120 UINT cyHeader
; /* the height of the header */
121 UINT cxMinBand
; /* minimum cx for band */
122 UINT cyMinBand
; /* minimum cy for band */
124 UINT cyRowSoFar
; /* for RBS_VARHEIGHT - the height of the row if it would break on this band (set by _Layout) */
125 INT iRow
; /* zero-based index of the row this band assigned to */
126 UINT fStatus
; /* status flags, reset only by _Validate */
127 UINT fDraw
; /* drawing flags, reset only by _Layout */
128 UINT uCDret
; /* last return from NM_CUSTOMDRAW */
129 RECT rcBand
; /* calculated band rectangle - coordinates swapped for CCS_VERT */
130 RECT rcGripper
; /* calculated gripper rectangle */
131 RECT rcCapImage
; /* calculated caption image rectangle */
132 RECT rcCapText
; /* calculated caption text rectangle */
133 RECT rcChild
; /* calculated child rectangle */
134 RECT rcChevron
; /* calculated chevron rectangle */
141 #define HAS_GRIPPER 0x00000001
142 #define HAS_IMAGE 0x00000002
143 #define HAS_TEXT 0x00000004
146 #define DRAW_GRIPPER 0x00000001
147 #define DRAW_IMAGE 0x00000002
148 #define DRAW_TEXT 0x00000004
149 #define DRAW_CHEVRONHOT 0x00000040
150 #define DRAW_CHEVRONPUSHED 0x00000080
151 #define NTF_INVALIDATE 0x01000000
155 COLORREF clrBk
; /* background color */
156 COLORREF clrText
; /* text color */
157 COLORREF clrBtnText
; /* system color for BTNTEXT */
158 COLORREF clrBtnFace
; /* system color for BTNFACE */
159 HIMAGELIST himl
; /* handle to imagelist */
160 UINT uNumBands
; /* # of bands in rebar (first=0, last=uNumBands-1 */
161 UINT uNumRows
; /* # of rows of bands (first=1, last=uNumRows */
162 HWND hwndSelf
; /* handle of REBAR window itself */
163 HWND hwndToolTip
; /* handle to the tool tip control */
164 HWND hwndNotify
; /* notification window (parent) */
166 HFONT hFont
; /* handle to the rebar's font */
167 SIZE imageSize
; /* image size (image list) */
168 DWORD dwStyle
; /* window style */
169 DWORD orgStyle
; /* original style (dwStyle may change) */
170 SIZE calcSize
; /* calculated rebar size - coordinates swapped for CCS_VERT */
171 BOOL bUnicode
; /* TRUE if parent wants notify in W format */
172 BOOL DoRedraw
; /* TRUE to actually draw bands */
173 UINT fStatus
; /* Status flags (see below) */
174 HCURSOR hcurArrow
; /* handle to the arrow cursor */
175 HCURSOR hcurHorz
; /* handle to the EW cursor */
176 HCURSOR hcurVert
; /* handle to the NS cursor */
177 HCURSOR hcurDrag
; /* handle to the drag cursor */
178 INT iVersion
; /* version number */
179 POINT dragStart
; /* x,y of button down */
180 POINT dragNow
; /* x,y of this MouseMove */
181 INT iOldBand
; /* last band that had the mouse cursor over it */
182 INT ihitoffset
; /* offset of hotspot from gripper.left */
183 INT ichevronhotBand
; /* last band that had a hot chevron */
184 INT iGrabbedBand
;/* band number of band whose gripper was grabbed */
186 HDPA bands
; /* pointer to the array of rebar bands */
190 #define BEGIN_DRAG_ISSUED 0x00000001
191 #define SELF_RESIZE 0x00000002
192 #define BAND_NEEDS_REDRAW 0x00000020
194 /* used by Windows to mark that the header size has been set by the user and shouldn't be changed */
195 #define RBBS_UNDOC_FIXEDHEADER 0x40000000
197 /* ---- REBAR layout constants. Mostly determined by ---- */
198 /* ---- experiment on WIN 98. ---- */
200 /* Width (or height) of separators between bands (either horz. or */
201 /* vert.). True only if RBS_BANDBORDERS is set */
202 #define SEP_WIDTH_SIZE 2
203 #define SEP_WIDTH ((infoPtr->dwStyle & RBS_BANDBORDERS) ? SEP_WIDTH_SIZE : 0)
205 /* Blank (background color) space between Gripper (if present) */
206 /* and next item (image, text, or window). Always present */
207 #define REBAR_ALWAYS_SPACE 4
209 /* Blank (background color) space after Image (if present). */
210 #define REBAR_POST_IMAGE 2
212 /* Blank (background color) space after Text (if present). */
213 #define REBAR_POST_TEXT 4
215 /* Height of vertical gripper in a CCS_VERT rebar. */
216 #define GRIPPER_HEIGHT 16
218 /* Blank (background color) space before Gripper (if present). */
219 #define REBAR_PRE_GRIPPER 2
221 /* Width (of normal vertical gripper) or height (of horz. gripper) */
223 #define GRIPPER_WIDTH 3
225 /* Width of the chevron button if present */
226 #define CHEVRON_WIDTH 10
228 /* the gap between the child and the next band */
229 #define REBAR_POST_CHILD 4
231 /* Height of divider for Rebar if not disabled (CCS_NODIVIDER) */
232 /* either top or bottom */
233 #define REBAR_DIVIDER 2
235 /* height of a rebar without a child */
236 #define REBAR_NO_CHILD_HEIGHT 4
238 /* minimum vertical height of a normal bar */
239 /* or minimum width of a CCS_VERT bar - from experiment on Win2k */
240 #define REBAR_MINSIZE 23
242 /* This is the increment that is used over the band height */
243 #define REBARSPACE(a) ((a->fStyle & RBBS_CHILDEDGE) ? 2*REBAR_DIVIDER : 0)
245 /* ---- End of REBAR layout constants. ---- */
247 #define RB_GETBANDINFO_OLD (WM_USER+5) /* obsoleted after IE3, but we have to support it anyway */
249 /* The following define determines if a given band is hidden */
250 #define HIDDENBAND(a) (((a)->fStyle & RBBS_HIDDEN) || \
251 ((infoPtr->dwStyle & CCS_VERT) && \
252 ((a)->fStyle & RBBS_NOVERT)))
254 #define REBAR_GetInfoPtr(wndPtr) ((REBAR_INFO *)GetWindowLongPtrW (hwnd, 0))
256 static LRESULT
REBAR_NotifyFormat(REBAR_INFO
*infoPtr
, LPARAM lParam
);
257 static void REBAR_AutoSize(REBAR_INFO
*infoPtr
, BOOL needsLayout
);
259 /* no index check here */
260 static inline REBAR_BAND
* REBAR_GetBand(const REBAR_INFO
*infoPtr
, INT i
)
262 assert(i
>= 0 && i
< infoPtr
->uNumBands
);
263 return DPA_GetPtr(infoPtr
->bands
, i
);
266 /* "constant values" retrieved when DLL was initialized */
267 /* FIXME we do this when the classes are registered. */
268 static UINT mindragx
= 0;
269 static UINT mindragy
= 0;
271 static const char * const band_stylename
[] = {
272 "RBBS_BREAK", /* 0001 */
273 "RBBS_FIXEDSIZE", /* 0002 */
274 "RBBS_CHILDEDGE", /* 0004 */
275 "RBBS_HIDDEN", /* 0008 */
276 "RBBS_NOVERT", /* 0010 */
277 "RBBS_FIXEDBMP", /* 0020 */
278 "RBBS_VARIABLEHEIGHT", /* 0040 */
279 "RBBS_GRIPPERALWAYS", /* 0080 */
280 "RBBS_NOGRIPPER", /* 0100 */
283 static const char * const band_maskname
[] = {
284 "RBBIM_STYLE", /* 0x00000001 */
285 "RBBIM_COLORS", /* 0x00000002 */
286 "RBBIM_TEXT", /* 0x00000004 */
287 "RBBIM_IMAGE", /* 0x00000008 */
288 "RBBIM_CHILD", /* 0x00000010 */
289 "RBBIM_CHILDSIZE", /* 0x00000020 */
290 "RBBIM_SIZE", /* 0x00000040 */
291 "RBBIM_BACKGROUND", /* 0x00000080 */
292 "RBBIM_ID", /* 0x00000100 */
293 "RBBIM_IDEALSIZE", /* 0x00000200 */
294 "RBBIM_LPARAM", /* 0x00000400 */
295 "RBBIM_HEADERSIZE", /* 0x00000800 */
299 static CHAR line
[200];
301 static const WCHAR themeClass
[] = { 'R','e','b','a','r',0 };
304 REBAR_FmtStyle( UINT style
)
309 while (band_stylename
[i
]) {
310 if (style
& (1<<i
)) {
311 if (*line
!= 0) strcat(line
, " | ");
312 strcat(line
, band_stylename
[i
]);
321 REBAR_FmtMask( UINT mask
)
326 while (band_maskname
[i
]) {
328 if (*line
!= 0) strcat(line
, " | ");
329 strcat(line
, band_maskname
[i
]);
338 REBAR_DumpBandInfo(const REBARBANDINFOW
*pB
)
340 if( !TRACE_ON(rebar
) ) return;
341 TRACE("band info: ");
342 if (pB
->fMask
& RBBIM_ID
)
343 TRACE("ID=%u, ", pB
->wID
);
344 TRACE("size=%u, child=%p", pB
->cbSize
, pB
->hwndChild
);
345 if (pB
->fMask
& RBBIM_COLORS
)
346 TRACE(", clrF=0x%06x, clrB=0x%06x", pB
->clrFore
, pB
->clrBack
);
349 TRACE("band info: mask=0x%08x (%s)\n", pB
->fMask
, REBAR_FmtMask(pB
->fMask
));
350 if (pB
->fMask
& RBBIM_STYLE
)
351 TRACE("band info: style=0x%08x (%s)\n", pB
->fStyle
, REBAR_FmtStyle(pB
->fStyle
));
352 if (pB
->fMask
& (RBBIM_SIZE
| RBBIM_IDEALSIZE
| RBBIM_HEADERSIZE
| RBBIM_LPARAM
)) {
354 if (pB
->fMask
& RBBIM_SIZE
)
355 TRACE(" cx=%u", pB
->cx
);
356 if (pB
->fMask
& RBBIM_IDEALSIZE
)
357 TRACE(" xIdeal=%u", pB
->cxIdeal
);
358 if (pB
->fMask
& RBBIM_HEADERSIZE
)
359 TRACE(" xHeader=%u", pB
->cxHeader
);
360 if (pB
->fMask
& RBBIM_LPARAM
)
361 TRACE(" lParam=0x%08lx", pB
->lParam
);
364 if (pB
->fMask
& RBBIM_CHILDSIZE
)
365 TRACE("band info: xMin=%u, yMin=%u, yChild=%u, yMax=%u, yIntgl=%u\n",
367 pB
->cyMinChild
, pB
->cyChild
, pB
->cyMaxChild
, pB
->cyIntegral
);
371 REBAR_DumpBand (const REBAR_INFO
*iP
)
376 if(! TRACE_ON(rebar
) ) return;
378 TRACE("hwnd=%p: color=%08x/%08x, bands=%u, rows=%u, cSize=%d,%d\n",
379 iP
->hwndSelf
, iP
->clrText
, iP
->clrBk
, iP
->uNumBands
, iP
->uNumRows
,
380 iP
->calcSize
.cx
, iP
->calcSize
.cy
);
381 TRACE("hwnd=%p: flags=%08x, dragStart=%d,%d, dragNow=%d,%d, iGrabbedBand=%d\n",
382 iP
->hwndSelf
, iP
->fStatus
, iP
->dragStart
.x
, iP
->dragStart
.y
,
383 iP
->dragNow
.x
, iP
->dragNow
.y
,
385 TRACE("hwnd=%p: style=%08x, notify in Unicode=%s, redraw=%s\n",
386 iP
->hwndSelf
, iP
->dwStyle
, (iP
->bUnicode
)?"TRUE":"FALSE",
387 (iP
->DoRedraw
)?"TRUE":"FALSE");
388 for (i
= 0; i
< iP
->uNumBands
; i
++) {
389 pB
= REBAR_GetBand(iP
, i
);
390 TRACE("band # %u:", i
);
391 if (pB
->fMask
& RBBIM_ID
)
392 TRACE(" ID=%u", pB
->wID
);
393 if (pB
->fMask
& RBBIM_CHILD
)
394 TRACE(" child=%p", pB
->hwndChild
);
395 if (pB
->fMask
& RBBIM_COLORS
)
396 TRACE(" clrF=0x%06x clrB=0x%06x", pB
->clrFore
, pB
->clrBack
);
398 TRACE("band # %u: mask=0x%08x (%s)\n", i
, pB
->fMask
, REBAR_FmtMask(pB
->fMask
));
399 if (pB
->fMask
& RBBIM_STYLE
)
400 TRACE("band # %u: style=0x%08x (%s)\n",
401 i
, pB
->fStyle
, REBAR_FmtStyle(pB
->fStyle
));
402 TRACE("band # %u: xHeader=%u",
404 if (pB
->fMask
& (RBBIM_SIZE
| RBBIM_IDEALSIZE
| RBBIM_LPARAM
)) {
405 if (pB
->fMask
& RBBIM_SIZE
)
406 TRACE(" cx=%u", pB
->cx
);
407 if (pB
->fMask
& RBBIM_IDEALSIZE
)
408 TRACE(" xIdeal=%u", pB
->cxIdeal
);
409 if (pB
->fMask
& RBBIM_LPARAM
)
410 TRACE(" lParam=0x%08lx", pB
->lParam
);
414 TRACE("band # %u: xMin=%u, yMin=%u, yChild=%u, yMax=%u, yIntgl=%u\n",
415 i
, pB
->cxMinChild
, pB
->cyMinChild
, pB
->cyChild
, pB
->cyMaxChild
, pB
->cyIntegral
);
416 if (pB
->fMask
& RBBIM_TEXT
)
417 TRACE("band # %u: text=%s\n",
418 i
, (pB
->lpText
) ? debugstr_w(pB
->lpText
) : "(null)");
419 TRACE("band # %u: cxMinBand=%u, cxEffective=%u, cyMinBand=%u\n",
420 i
, pB
->cxMinBand
, pB
->cxEffective
, pB
->cyMinBand
);
421 TRACE("band # %u: fStatus=%08x, fDraw=%08x, Band=(%s), Grip=(%s)\n",
422 i
, pB
->fStatus
, pB
->fDraw
, wine_dbgstr_rect(&pB
->rcBand
),
423 wine_dbgstr_rect(&pB
->rcGripper
));
424 TRACE("band # %u: Img=(%s), Txt=(%s), Child=(%s)\n",
425 i
, wine_dbgstr_rect(&pB
->rcCapImage
),
426 wine_dbgstr_rect(&pB
->rcCapText
), wine_dbgstr_rect(&pB
->rcChild
));
431 /* dest can be equal to src */
432 static void translate_rect(const REBAR_INFO
*infoPtr
, RECT
*dest
, const RECT
*src
)
434 if (infoPtr
->dwStyle
& CCS_VERT
) {
437 dest
->left
= src
->top
;
441 dest
->right
= src
->bottom
;
448 static int get_rect_cx(const REBAR_INFO
*infoPtr
, const RECT
*lpRect
)
450 if (infoPtr
->dwStyle
& CCS_VERT
)
451 return lpRect
->bottom
- lpRect
->top
;
452 return lpRect
->right
- lpRect
->left
;
455 static int get_rect_cy(const REBAR_INFO
*infoPtr
, const RECT
*lpRect
)
457 if (infoPtr
->dwStyle
& CCS_VERT
)
458 return lpRect
->right
- lpRect
->left
;
459 return lpRect
->bottom
- lpRect
->top
;
462 static int round_child_height(const REBAR_BAND
*lpBand
, int cyHeight
)
465 if (lpBand
->cyIntegral
== 0)
467 cy
= max(cyHeight
- (int)lpBand
->cyMinChild
, 0);
468 cy
= lpBand
->cyMinChild
+ (cy
/lpBand
->cyIntegral
) * lpBand
->cyIntegral
;
469 cy
= min(cy
, lpBand
->cyMaxChild
);
473 static void update_min_band_height(const REBAR_INFO
*infoPtr
, REBAR_BAND
*lpBand
)
475 lpBand
->cyMinBand
= max(lpBand
->cyHeader
,
476 (lpBand
->hwndChild
? lpBand
->cyChild
+ REBARSPACE(lpBand
) : REBAR_NO_CHILD_HEIGHT
));
480 REBAR_DrawChevron (HDC hdc
, INT left
, INT top
, INT colorRef
)
485 if (!(hPen
= CreatePen( PS_SOLID
, 1, GetSysColor( colorRef
)))) return;
486 hOldPen
= SelectObject ( hdc
, hPen
);
489 MoveToEx (hdc
, x
, y
, NULL
);
490 LineTo (hdc
, x
+5, y
++); x
++;
491 MoveToEx (hdc
, x
, y
, NULL
);
492 LineTo (hdc
, x
+3, y
++); x
++;
493 MoveToEx (hdc
, x
, y
, NULL
);
494 LineTo (hdc
, x
+1, y
);
495 SelectObject( hdc
, hOldPen
);
496 DeleteObject( hPen
);
500 REBAR_GetNotifyParent (const REBAR_INFO
*infoPtr
)
504 parent
= infoPtr
->hwndNotify
;
506 parent
= GetParent (infoPtr
->hwndSelf
);
507 owner
= GetWindow (infoPtr
->hwndSelf
, GW_OWNER
);
508 if (owner
) parent
= owner
;
515 REBAR_Notify (NMHDR
*nmhdr
, const REBAR_INFO
*infoPtr
, UINT code
)
519 parent
= REBAR_GetNotifyParent (infoPtr
);
520 nmhdr
->idFrom
= GetDlgCtrlID (infoPtr
->hwndSelf
);
521 nmhdr
->hwndFrom
= infoPtr
->hwndSelf
;
524 TRACE("window %p, code=%08x, via %s\n", parent
, code
, (infoPtr
->bUnicode
)?"Unicode":"ANSI");
526 return SendMessageW(parent
, WM_NOTIFY
, nmhdr
->idFrom
, (LPARAM
)nmhdr
);
530 REBAR_Notify_NMREBAR (const REBAR_INFO
*infoPtr
, UINT uBand
, UINT code
)
532 NMREBAR notify_rebar
;
534 notify_rebar
.dwMask
= 0;
536 REBAR_BAND
*lpBand
= REBAR_GetBand(infoPtr
, uBand
);
538 if (lpBand
->fMask
& RBBIM_ID
) {
539 notify_rebar
.dwMask
|= RBNM_ID
;
540 notify_rebar
.wID
= lpBand
->wID
;
542 if (lpBand
->fMask
& RBBIM_LPARAM
) {
543 notify_rebar
.dwMask
|= RBNM_LPARAM
;
544 notify_rebar
.lParam
= lpBand
->lParam
;
546 if (lpBand
->fMask
& RBBIM_STYLE
) {
547 notify_rebar
.dwMask
|= RBNM_STYLE
;
548 notify_rebar
.fStyle
= lpBand
->fStyle
;
551 notify_rebar
.uBand
= uBand
;
552 return REBAR_Notify ((NMHDR
*)¬ify_rebar
, infoPtr
, code
);
556 REBAR_DrawBand (HDC hdc
, const REBAR_INFO
*infoPtr
, REBAR_BAND
*lpBand
)
561 HTHEME theme
= GetWindowTheme (infoPtr
->hwndSelf
);
564 translate_rect(infoPtr
, &rcBand
, &lpBand
->rcBand
);
566 if (lpBand
->fDraw
& DRAW_TEXT
) {
567 hOldFont
= SelectObject (hdc
, infoPtr
->hFont
);
568 oldBkMode
= SetBkMode (hdc
, TRANSPARENT
);
571 /* should test for CDRF_NOTIFYITEMDRAW here */
572 nmcd
.dwDrawStage
= CDDS_ITEMPREPAINT
;
575 nmcd
.rc
.right
= lpBand
->rcCapText
.right
;
576 nmcd
.rc
.bottom
= lpBand
->rcCapText
.bottom
;
577 nmcd
.dwItemSpec
= lpBand
->wID
;
579 nmcd
.lItemlParam
= lpBand
->lParam
;
580 lpBand
->uCDret
= REBAR_Notify ((NMHDR
*)&nmcd
, infoPtr
, NM_CUSTOMDRAW
);
581 if (lpBand
->uCDret
== CDRF_SKIPDEFAULT
) {
582 if (oldBkMode
!= TRANSPARENT
)
583 SetBkMode (hdc
, oldBkMode
);
584 SelectObject (hdc
, hOldFont
);
589 if (lpBand
->fDraw
& DRAW_GRIPPER
)
593 RECT rcGripper
= lpBand
->rcGripper
;
594 int partId
= (infoPtr
->dwStyle
& CCS_VERT
) ? RP_GRIPPERVERT
: RP_GRIPPER
;
595 GetThemeBackgroundExtent (theme
, hdc
, partId
, 0, &rcGripper
, &rcGripper
);
596 OffsetRect (&rcGripper
, lpBand
->rcGripper
.left
- rcGripper
.left
,
597 lpBand
->rcGripper
.top
- rcGripper
.top
);
598 DrawThemeBackground (theme
, hdc
, partId
, 0, &rcGripper
, NULL
);
601 DrawEdge (hdc
, &lpBand
->rcGripper
, BDR_RAISEDINNER
, BF_RECT
| BF_MIDDLE
);
604 /* draw caption image */
605 if (lpBand
->fDraw
& DRAW_IMAGE
) {
609 pt
.y
= (lpBand
->rcCapImage
.bottom
+ lpBand
->rcCapImage
.top
- infoPtr
->imageSize
.cy
)/2;
610 pt
.x
= (lpBand
->rcCapImage
.right
+ lpBand
->rcCapImage
.left
- infoPtr
->imageSize
.cx
)/2;
612 ImageList_Draw (infoPtr
->himl
, lpBand
->iImage
, hdc
,
617 /* draw caption text */
618 if (lpBand
->fDraw
& DRAW_TEXT
) {
619 /* need to handle CDRF_NEWFONT here */
620 INT oldBkMode
= SetBkMode (hdc
, TRANSPARENT
);
621 COLORREF oldcolor
= CLR_NONE
;
623 if (lpBand
->clrFore
!= CLR_NONE
) {
624 new = (lpBand
->clrFore
== CLR_DEFAULT
) ? infoPtr
->clrBtnText
:
626 oldcolor
= SetTextColor (hdc
, new);
628 DrawTextW (hdc
, lpBand
->lpText
, -1, &lpBand
->rcCapText
,
629 DT_CENTER
| DT_VCENTER
| DT_SINGLELINE
);
630 if (oldBkMode
!= TRANSPARENT
)
631 SetBkMode (hdc
, oldBkMode
);
632 if (lpBand
->clrFore
!= CLR_NONE
)
633 SetTextColor (hdc
, oldcolor
);
634 SelectObject (hdc
, hOldFont
);
637 if (!IsRectEmpty(&lpBand
->rcChevron
))
642 if (lpBand
->fDraw
& DRAW_CHEVRONPUSHED
)
643 stateId
= CHEVS_PRESSED
;
644 else if (lpBand
->fDraw
& DRAW_CHEVRONHOT
)
647 stateId
= CHEVS_NORMAL
;
648 DrawThemeBackground (theme
, hdc
, RP_CHEVRON
, stateId
, &lpBand
->rcChevron
, NULL
);
652 if (lpBand
->fDraw
& DRAW_CHEVRONPUSHED
)
654 DrawEdge(hdc
, &lpBand
->rcChevron
, BDR_SUNKENOUTER
, BF_RECT
| BF_MIDDLE
);
655 REBAR_DrawChevron(hdc
, lpBand
->rcChevron
.left
+1, lpBand
->rcChevron
.top
+ 11, COLOR_WINDOWFRAME
);
657 else if (lpBand
->fDraw
& DRAW_CHEVRONHOT
)
659 DrawEdge(hdc
, &lpBand
->rcChevron
, BDR_RAISEDINNER
, BF_RECT
| BF_MIDDLE
);
660 REBAR_DrawChevron(hdc
, lpBand
->rcChevron
.left
, lpBand
->rcChevron
.top
+ 10, COLOR_WINDOWFRAME
);
663 REBAR_DrawChevron(hdc
, lpBand
->rcChevron
.left
, lpBand
->rcChevron
.top
+ 10, COLOR_WINDOWFRAME
);
667 if (lpBand
->uCDret
== (CDRF_NOTIFYPOSTPAINT
| CDRF_NOTIFYITEMDRAW
)) {
668 nmcd
.dwDrawStage
= CDDS_ITEMPOSTPAINT
;
671 nmcd
.rc
.right
= lpBand
->rcCapText
.right
;
672 nmcd
.rc
.bottom
= lpBand
->rcCapText
.bottom
;
673 nmcd
.dwItemSpec
= lpBand
->wID
;
675 nmcd
.lItemlParam
= lpBand
->lParam
;
676 lpBand
->uCDret
= REBAR_Notify ((NMHDR
*)&nmcd
, infoPtr
, NM_CUSTOMDRAW
);
682 REBAR_Refresh (const REBAR_INFO
*infoPtr
, HDC hdc
)
687 if (!infoPtr
->DoRedraw
) return;
689 for (i
= 0; i
< infoPtr
->uNumBands
; i
++) {
690 lpBand
= REBAR_GetBand(infoPtr
, i
);
692 if (HIDDENBAND(lpBand
)) continue;
694 /* now draw the band */
695 TRACE("[%p] drawing band %i, flags=%08x\n",
696 infoPtr
->hwndSelf
, i
, lpBand
->fDraw
);
697 REBAR_DrawBand (hdc
, infoPtr
, lpBand
);
703 REBAR_CalcHorzBand (const REBAR_INFO
*infoPtr
, UINT rstart
, UINT rend
)
704 /* Function: this routine initializes all the rectangles in */
705 /* each band in a row to fit in the adjusted rcBand rect. */
706 /* *** Supports only Horizontal bars. *** */
712 for(i
=rstart
; i
<rend
; i
++){
713 lpBand
= REBAR_GetBand(infoPtr
, i
);
714 if (HIDDENBAND(lpBand
)) {
715 SetRect (&lpBand
->rcChild
,
716 lpBand
->rcBand
.right
, lpBand
->rcBand
.top
,
717 lpBand
->rcBand
.right
, lpBand
->rcBand
.bottom
);
721 /* set initial gripper rectangle */
722 SetRect (&lpBand
->rcGripper
, lpBand
->rcBand
.left
, lpBand
->rcBand
.top
,
723 lpBand
->rcBand
.left
, lpBand
->rcBand
.bottom
);
725 /* calculate gripper rectangle */
726 if ( lpBand
->fStatus
& HAS_GRIPPER
) {
727 lpBand
->fDraw
|= DRAW_GRIPPER
;
728 lpBand
->rcGripper
.left
+= REBAR_PRE_GRIPPER
;
729 lpBand
->rcGripper
.right
= lpBand
->rcGripper
.left
+ GRIPPER_WIDTH
;
730 lpBand
->rcGripper
.top
+= 2;
731 lpBand
->rcGripper
.bottom
-= 2;
733 SetRect (&lpBand
->rcCapImage
,
734 lpBand
->rcGripper
.right
+REBAR_ALWAYS_SPACE
, lpBand
->rcBand
.top
,
735 lpBand
->rcGripper
.right
+REBAR_ALWAYS_SPACE
, lpBand
->rcBand
.bottom
);
737 else { /* no gripper will be drawn */
739 if (lpBand
->fStatus
& (HAS_IMAGE
| HAS_TEXT
))
740 /* if no gripper but either image or text, then leave space */
741 xoff
= REBAR_ALWAYS_SPACE
;
742 SetRect (&lpBand
->rcCapImage
,
743 lpBand
->rcBand
.left
+xoff
, lpBand
->rcBand
.top
,
744 lpBand
->rcBand
.left
+xoff
, lpBand
->rcBand
.bottom
);
747 /* image is visible */
748 if (lpBand
->fStatus
& HAS_IMAGE
) {
749 lpBand
->fDraw
|= DRAW_IMAGE
;
750 lpBand
->rcCapImage
.right
+= infoPtr
->imageSize
.cx
;
751 lpBand
->rcCapImage
.bottom
= lpBand
->rcCapImage
.top
+ infoPtr
->imageSize
.cy
;
753 /* set initial caption text rectangle */
754 SetRect (&lpBand
->rcCapText
,
755 lpBand
->rcCapImage
.right
+REBAR_POST_IMAGE
, lpBand
->rcBand
.top
+1,
756 lpBand
->rcBand
.left
+lpBand
->cxHeader
, lpBand
->rcBand
.bottom
-1);
759 /* set initial caption text rectangle */
760 SetRect (&lpBand
->rcCapText
, lpBand
->rcCapImage
.right
, lpBand
->rcBand
.top
+1,
761 lpBand
->rcBand
.left
+lpBand
->cxHeader
, lpBand
->rcBand
.bottom
-1);
764 /* text is visible */
765 if ((lpBand
->fStatus
& HAS_TEXT
) && !(lpBand
->fStyle
& RBBS_HIDETITLE
)) {
766 lpBand
->fDraw
|= DRAW_TEXT
;
767 lpBand
->rcCapText
.right
= max(lpBand
->rcCapText
.left
,
768 lpBand
->rcCapText
.right
-REBAR_POST_TEXT
);
771 /* set initial child window rectangle if there is a child */
772 if (lpBand
->hwndChild
) {
774 lpBand
->rcChild
.left
= lpBand
->rcBand
.left
+ lpBand
->cxHeader
;
775 lpBand
->rcChild
.right
= lpBand
->rcBand
.right
- REBAR_POST_CHILD
;
777 if (lpBand
->cyChild
> 0) {
779 UINT yoff
= (lpBand
->rcBand
.bottom
- lpBand
->rcBand
.top
- lpBand
->cyChild
) / 2;
781 /* center child if height is known */
782 lpBand
->rcChild
.top
= lpBand
->rcBand
.top
+ yoff
;
783 lpBand
->rcChild
.bottom
= lpBand
->rcBand
.top
+ yoff
+ lpBand
->cyChild
;
786 lpBand
->rcChild
.top
= lpBand
->rcBand
.top
;
787 lpBand
->rcChild
.bottom
= lpBand
->rcBand
.bottom
;
790 if ((lpBand
->fStyle
& RBBS_USECHEVRON
) && (lpBand
->rcChild
.right
- lpBand
->rcChild
.left
< lpBand
->cxIdeal
))
792 lpBand
->rcChild
.right
-= CHEVRON_WIDTH
;
793 SetRect(&lpBand
->rcChevron
, lpBand
->rcChild
.right
,
794 lpBand
->rcChild
.top
, lpBand
->rcChild
.right
+ CHEVRON_WIDTH
,
795 lpBand
->rcChild
.bottom
);
799 SetRect (&lpBand
->rcChild
,
800 lpBand
->rcBand
.left
+lpBand
->cxHeader
, lpBand
->rcBand
.top
,
801 lpBand
->rcBand
.right
, lpBand
->rcBand
.bottom
);
804 /* flag if notify required and invalidate rectangle */
805 if (lpBand
->fDraw
& NTF_INVALIDATE
) {
806 TRACE("invalidating (%d,%d)-(%d,%d)\n",
809 lpBand
->rcBand
.right
+ SEP_WIDTH
,
810 lpBand
->rcBand
.bottom
+ SEP_WIDTH
);
811 lpBand
->fDraw
&= ~NTF_INVALIDATE
;
812 work
= lpBand
->rcBand
;
813 work
.right
+= SEP_WIDTH
;
814 work
.bottom
+= SEP_WIDTH
;
815 InvalidateRect(infoPtr
->hwndSelf
, &work
, TRUE
);
816 if (lpBand
->hwndChild
) InvalidateRect(lpBand
->hwndChild
, NULL
, TRUE
);
825 REBAR_CalcVertBand (const REBAR_INFO
*infoPtr
, UINT rstart
, UINT rend
)
826 /* Function: this routine initializes all the rectangles in */
827 /* each band in a row to fit in the adjusted rcBand rect. */
828 /* *** Supports only Vertical bars. *** */
834 for(i
=rstart
; i
<rend
; i
++){
836 lpBand
= REBAR_GetBand(infoPtr
, i
);
837 if (HIDDENBAND(lpBand
)) continue;
839 translate_rect(infoPtr
, &rcBand
, &lpBand
->rcBand
);
841 /* set initial gripper rectangle */
842 SetRect (&lpBand
->rcGripper
, rcBand
.left
, rcBand
.top
, rcBand
.right
, rcBand
.top
);
844 /* calculate gripper rectangle */
845 if (lpBand
->fStatus
& HAS_GRIPPER
) {
846 lpBand
->fDraw
|= DRAW_GRIPPER
;
848 if (infoPtr
->dwStyle
& RBS_VERTICALGRIPPER
) {
849 /* vertical gripper */
850 lpBand
->rcGripper
.left
+= 3;
851 lpBand
->rcGripper
.right
= lpBand
->rcGripper
.left
+ GRIPPER_WIDTH
;
852 lpBand
->rcGripper
.top
+= REBAR_PRE_GRIPPER
;
853 lpBand
->rcGripper
.bottom
= lpBand
->rcGripper
.top
+ GRIPPER_HEIGHT
;
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 /* horizontal gripper */
863 lpBand
->rcGripper
.left
+= 2;
864 lpBand
->rcGripper
.right
-= 2;
865 lpBand
->rcGripper
.top
+= REBAR_PRE_GRIPPER
;
866 lpBand
->rcGripper
.bottom
= lpBand
->rcGripper
.top
+ GRIPPER_WIDTH
;
868 /* initialize Caption image rectangle */
869 SetRect (&lpBand
->rcCapImage
, rcBand
.left
,
870 lpBand
->rcGripper
.bottom
+ REBAR_ALWAYS_SPACE
,
872 lpBand
->rcGripper
.bottom
+ REBAR_ALWAYS_SPACE
);
875 else { /* no gripper will be drawn */
877 if (lpBand
->fStatus
& (HAS_IMAGE
| HAS_TEXT
))
878 /* if no gripper but either image or text, then leave space */
879 xoff
= REBAR_ALWAYS_SPACE
;
880 /* initialize Caption image rectangle */
881 SetRect (&lpBand
->rcCapImage
,
882 rcBand
.left
, rcBand
.top
+xoff
,
883 rcBand
.right
, rcBand
.top
+xoff
);
886 /* image is visible */
887 if (lpBand
->fStatus
& HAS_IMAGE
) {
888 lpBand
->fDraw
|= DRAW_IMAGE
;
890 lpBand
->rcCapImage
.right
= lpBand
->rcCapImage
.left
+ infoPtr
->imageSize
.cx
;
891 lpBand
->rcCapImage
.bottom
+= infoPtr
->imageSize
.cy
;
893 /* set initial caption text rectangle */
894 SetRect (&lpBand
->rcCapText
,
895 rcBand
.left
, lpBand
->rcCapImage
.bottom
+REBAR_POST_IMAGE
,
896 rcBand
.right
, rcBand
.top
+lpBand
->cxHeader
);
899 /* set initial caption text rectangle */
900 SetRect (&lpBand
->rcCapText
,
901 rcBand
.left
, lpBand
->rcCapImage
.bottom
,
902 rcBand
.right
, rcBand
.top
+lpBand
->cxHeader
);
905 /* text is visible */
906 if ((lpBand
->fStatus
& HAS_TEXT
) && !(lpBand
->fStyle
& RBBS_HIDETITLE
)) {
907 lpBand
->fDraw
|= DRAW_TEXT
;
908 lpBand
->rcCapText
.bottom
= max(lpBand
->rcCapText
.top
,
909 lpBand
->rcCapText
.bottom
);
912 /* set initial child window rectangle if there is a child */
913 if (lpBand
->hwndChild
) {
914 int cxBand
= rcBand
.right
- rcBand
.left
;
915 xoff
= (cxBand
- lpBand
->cyChild
) / 2;
916 SetRect (&lpBand
->rcChild
,
917 rcBand
.left
+ xoff
, rcBand
.top
+ lpBand
->cxHeader
,
918 rcBand
.left
+ xoff
+ lpBand
->cyChild
, rcBand
.bottom
- REBAR_POST_CHILD
);
921 SetRect (&lpBand
->rcChild
,
922 rcBand
.left
, rcBand
.top
+lpBand
->cxHeader
,
923 rcBand
.right
, rcBand
.bottom
);
926 if (lpBand
->fDraw
& NTF_INVALIDATE
) {
927 TRACE("invalidating (%d,%d)-(%d,%d)\n",
930 rcBand
.right
+ SEP_WIDTH
,
931 rcBand
.bottom
+ SEP_WIDTH
);
932 lpBand
->fDraw
&= ~NTF_INVALIDATE
;
934 work
.bottom
+= SEP_WIDTH
;
935 work
.right
+= SEP_WIDTH
;
936 InvalidateRect(infoPtr
->hwndSelf
, &work
, TRUE
);
937 if (lpBand
->hwndChild
) InvalidateRect(lpBand
->hwndChild
, NULL
, TRUE
);
945 REBAR_ForceResize (REBAR_INFO
*infoPtr
)
946 /* Function: This changes the size of the REBAR window to that */
947 /* calculated by REBAR_Layout. */
949 INT x
, y
, width
, height
;
950 INT xedge
= 0, yedge
= 0;
953 TRACE("new size [%d x %d]\n", infoPtr
->calcSize
.cx
, infoPtr
->calcSize
.cy
);
955 if (infoPtr
->dwStyle
& CCS_NORESIZE
)
958 if (infoPtr
->dwStyle
& WS_BORDER
)
960 xedge
= GetSystemMetrics(SM_CXEDGE
);
961 yedge
= GetSystemMetrics(SM_CYEDGE
);
962 /* swap for CCS_VERT? */
965 /* compute rebar window rect in parent client coordinates */
966 GetWindowRect(infoPtr
->hwndSelf
, &rcSelf
);
967 MapWindowPoints(HWND_DESKTOP
, GetParent(infoPtr
->hwndSelf
), (LPPOINT
)&rcSelf
, 2);
968 translate_rect(infoPtr
, &rcSelf
, &rcSelf
);
970 height
= infoPtr
->calcSize
.cy
+ 2*yedge
;
971 if (!(infoPtr
->dwStyle
& CCS_NOPARENTALIGN
)) {
975 width
= infoPtr
->calcSize
.cx
+ 2*xedge
;
976 y
= 0; /* quiet compiler warning */
977 switch ( infoPtr
->dwStyle
& CCS_LAYOUT_MASK
) {
978 case 0: /* shouldn't happen - see NCCreate */
980 y
= ((infoPtr
->dwStyle
& CCS_NODIVIDER
) ? 0 : REBAR_DIVIDER
) - yedge
;
986 GetClientRect(GetParent(infoPtr
->hwndSelf
), &rcParent
);
987 translate_rect(infoPtr
, &rcParent
, &rcParent
);
988 y
= rcParent
.bottom
- infoPtr
->calcSize
.cy
- yedge
;
994 /* As on Windows if the CCS_NODIVIDER is not present the control will move
995 * 2 pixel down after every layout */
996 y
= rcSelf
.top
+ ((infoPtr
->dwStyle
& CCS_NODIVIDER
) ? 0 : REBAR_DIVIDER
);
997 width
= rcSelf
.right
- rcSelf
.left
;
1000 TRACE("hwnd %p, style=%08x, setting at (%d,%d) for (%d,%d)\n",
1001 infoPtr
->hwndSelf
, infoPtr
->dwStyle
, x
, y
, width
, height
);
1003 /* Set flag to ignore next WM_SIZE message and resize the window */
1004 infoPtr
->fStatus
|= SELF_RESIZE
;
1005 if ((infoPtr
->dwStyle
& CCS_VERT
) == 0)
1006 SetWindowPos(infoPtr
->hwndSelf
, 0, x
, y
, width
, height
, SWP_NOZORDER
);
1008 SetWindowPos(infoPtr
->hwndSelf
, 0, y
, x
, height
, width
, SWP_NOZORDER
);
1009 infoPtr
->fStatus
&= ~SELF_RESIZE
;
1014 REBAR_MoveChildWindows (const REBAR_INFO
*infoPtr
, UINT start
, UINT endplus
)
1016 static const WCHAR strComboBox
[] = { 'C','o','m','b','o','B','o','x',0 };
1018 WCHAR szClassName
[40];
1020 NMREBARCHILDSIZE rbcz
;
1023 if (!(deferpos
= BeginDeferWindowPos(infoPtr
->uNumBands
)))
1024 ERR("BeginDeferWindowPos returned NULL\n");
1026 for (i
= start
; i
< endplus
; i
++) {
1027 lpBand
= REBAR_GetBand(infoPtr
, i
);
1029 if (HIDDENBAND(lpBand
)) continue;
1030 if (lpBand
->hwndChild
) {
1031 TRACE("hwndChild = %p\n", lpBand
->hwndChild
);
1033 /* Always generate the RBN_CHILDSIZE even if child
1036 rbcz
.wID
= lpBand
->wID
;
1037 rbcz
.rcChild
= lpBand
->rcChild
;
1038 translate_rect(infoPtr
, &rbcz
.rcBand
, &lpBand
->rcBand
);
1039 if (infoPtr
->dwStyle
& CCS_VERT
)
1040 rbcz
.rcBand
.top
+= lpBand
->cxHeader
;
1042 rbcz
.rcBand
.left
+= lpBand
->cxHeader
;
1043 REBAR_Notify ((NMHDR
*)&rbcz
, infoPtr
, RBN_CHILDSIZE
);
1044 if (!EqualRect (&lpBand
->rcChild
, &rbcz
.rcChild
)) {
1045 TRACE("Child rect changed by NOTIFY for band %u\n", i
);
1046 TRACE(" from (%s) to (%s)\n",
1047 wine_dbgstr_rect(&lpBand
->rcChild
),
1048 wine_dbgstr_rect(&rbcz
.rcChild
));
1049 lpBand
->rcChild
= rbcz
.rcChild
; /* *** ??? */
1052 /* native (IE4 in "Favorites" frame **1) does:
1053 * SetRect (&rc, -1, -1, -1, -1)
1054 * EqualRect (&rc,band->rc???)
1056 * CopyRect (band->rc????, &rc)
1057 * set flag outside of loop
1060 GetClassNameW (lpBand
->hwndChild
, szClassName
, sizeof(szClassName
)/sizeof(szClassName
[0]));
1061 if (!lstrcmpW (szClassName
, strComboBox
) ||
1062 !lstrcmpW (szClassName
, WC_COMBOBOXEXW
)) {
1063 INT nEditHeight
, yPos
;
1066 /* special placement code for combo or comboex box */
1069 /* get size of edit line */
1070 GetWindowRect (lpBand
->hwndChild
, &rc
);
1071 nEditHeight
= rc
.bottom
- rc
.top
;
1072 yPos
= (lpBand
->rcChild
.bottom
+ lpBand
->rcChild
.top
- nEditHeight
)/2;
1074 /* center combo box inside child area */
1075 TRACE("moving child (Combo(Ex)) %p to (%d,%d) for (%d,%d)\n",
1077 lpBand
->rcChild
.left
, yPos
,
1078 lpBand
->rcChild
.right
- lpBand
->rcChild
.left
,
1080 deferpos
= DeferWindowPos (deferpos
, lpBand
->hwndChild
, HWND_TOP
,
1081 lpBand
->rcChild
.left
,
1082 /*lpBand->rcChild.top*/ yPos
,
1083 lpBand
->rcChild
.right
- lpBand
->rcChild
.left
,
1087 ERR("DeferWindowPos returned NULL\n");
1090 TRACE("moving child (Other) %p to (%d,%d) for (%d,%d)\n",
1092 lpBand
->rcChild
.left
, lpBand
->rcChild
.top
,
1093 lpBand
->rcChild
.right
- lpBand
->rcChild
.left
,
1094 lpBand
->rcChild
.bottom
- lpBand
->rcChild
.top
);
1095 deferpos
= DeferWindowPos (deferpos
, lpBand
->hwndChild
, HWND_TOP
,
1096 lpBand
->rcChild
.left
,
1097 lpBand
->rcChild
.top
,
1098 lpBand
->rcChild
.right
- lpBand
->rcChild
.left
,
1099 lpBand
->rcChild
.bottom
- lpBand
->rcChild
.top
,
1102 ERR("DeferWindowPos returned NULL\n");
1106 if (!EndDeferWindowPos(deferpos
))
1107 ERR("EndDeferWindowPos returned NULL\n");
1109 if (infoPtr
->DoRedraw
)
1110 UpdateWindow (infoPtr
->hwndSelf
);
1112 /* native (from **1 above) does:
1113 * UpdateWindow(rebar)
1115 * RBN_HEIGHTCHANGE if necessary
1116 * if ret from any EqualRect was 0
1117 * Goto "BeginDeferWindowPos"
1122 /* Returns the next visible band (the first visible band in [i+1; infoPtr->uNumBands) )
1123 * or infoPtr->uNumBands if none */
1124 static int next_visible(const REBAR_INFO
*infoPtr
, int i
)
1127 for (n
= i
+ 1; n
< infoPtr
->uNumBands
; n
++)
1128 if (!HIDDENBAND(REBAR_GetBand(infoPtr
, n
)))
1133 /* Returns the previous visible band (the last visible band in [0; i) )
1135 static int prev_visible(const REBAR_INFO
*infoPtr
, int i
)
1138 for (n
= i
- 1; n
>= 0; n
--)
1139 if (!HIDDENBAND(REBAR_GetBand(infoPtr
, n
)))
1144 /* Returns the first visible band or infoPtr->uNumBands if none */
1145 static int first_visible(const REBAR_INFO
*infoPtr
)
1147 return next_visible(infoPtr
, -1); /* this works*/
1150 /* Returns the first visible band for the given row (or iBand if none) */
1151 static int get_row_begin_for_band(const REBAR_INFO
*infoPtr
, INT iBand
)
1153 int iLastBand
= iBand
;
1154 int iRow
= REBAR_GetBand(infoPtr
, iBand
)->iRow
;
1155 while ((iBand
= prev_visible(infoPtr
, iBand
)) >= 0) {
1156 if (REBAR_GetBand(infoPtr
, iBand
)->iRow
!= iRow
)
1164 /* Returns the first visible band for the next row (or infoPtr->uNumBands if none) */
1165 static int get_row_end_for_band(const REBAR_INFO
*infoPtr
, INT iBand
)
1167 int iRow
= REBAR_GetBand(infoPtr
, iBand
)->iRow
;
1168 while ((iBand
= next_visible(infoPtr
, iBand
)) < infoPtr
->uNumBands
)
1169 if (REBAR_GetBand(infoPtr
, iBand
)->iRow
!= iRow
)
1174 /* Compute the rcBand.{left,right} from the cxEffective bands widths computed earlier.
1175 * iBeginBand must be visible */
1176 static void REBAR_SetRowRectsX(const REBAR_INFO
*infoPtr
, INT iBeginBand
, INT iEndBand
)
1179 for (i
= iBeginBand
; i
< iEndBand
; i
= next_visible(infoPtr
, i
))
1181 REBAR_BAND
*lpBand
= REBAR_GetBand(infoPtr
, i
);
1182 if (lpBand
->rcBand
.left
!= xPos
|| lpBand
->rcBand
.right
!= xPos
+ lpBand
->cxEffective
) {
1183 lpBand
->fDraw
|= NTF_INVALIDATE
;
1184 TRACE("Setting rect %d to %d,%d\n", i
, xPos
, xPos
+ lpBand
->cxEffective
);
1185 lpBand
->rcBand
.left
= xPos
;
1186 lpBand
->rcBand
.right
= xPos
+ lpBand
->cxEffective
;
1188 xPos
+= lpBand
->cxEffective
+ SEP_WIDTH
;
1192 /* The rationale of this function is probably as follows: if we have some space
1193 * to distribute we want to add it to a band on the right. However we don't want
1194 * to unminimize a minimized band so we search for a band that is big enough.
1195 * For some reason "big enough" is defined as bigger than the minimum size of the
1196 * first band in the row
1198 static REBAR_BAND
*REBAR_FindBandToGrow(const REBAR_INFO
*infoPtr
, INT iBeginBand
, INT iEndBand
)
1200 INT cxMinFirstBand
= 0, i
;
1202 cxMinFirstBand
= REBAR_GetBand(infoPtr
, iBeginBand
)->cxMinBand
;
1204 for (i
= prev_visible(infoPtr
, iEndBand
); i
>= iBeginBand
; i
= prev_visible(infoPtr
, i
))
1205 if (REBAR_GetBand(infoPtr
, i
)->cxEffective
> cxMinFirstBand
&&
1206 !(REBAR_GetBand(infoPtr
, i
)->fStyle
& RBBS_FIXEDSIZE
))
1210 for (i
= prev_visible(infoPtr
, iEndBand
); i
>= iBeginBand
; i
= prev_visible(infoPtr
, i
))
1211 if (REBAR_GetBand(infoPtr
, i
)->cxMinBand
== cxMinFirstBand
)
1214 TRACE("Extra space for row [%d..%d) should be added to band %d\n", iBeginBand
, iEndBand
, i
);
1215 return REBAR_GetBand(infoPtr
, i
);
1218 /* Try to shrink the visible bands in [iBeginBand; iEndBand) by cxShrink, starting from the right */
1219 static int REBAR_ShrinkBandsRTL(const REBAR_INFO
*infoPtr
, INT iBeginBand
, INT iEndBand
, INT cxShrink
, BOOL bEnforce
)
1224 TRACE("Shrinking bands [%d..%d) by %d, right-to-left\n", iBeginBand
, iEndBand
, cxShrink
);
1225 for (i
= prev_visible(infoPtr
, iEndBand
); i
>= iBeginBand
; i
= prev_visible(infoPtr
, i
))
1227 lpBand
= REBAR_GetBand(infoPtr
, i
);
1229 width
= max(lpBand
->cxEffective
- cxShrink
, (int)lpBand
->cxMinBand
);
1230 cxShrink
-= lpBand
->cxEffective
- width
;
1231 lpBand
->cxEffective
= width
;
1232 if (bEnforce
&& lpBand
->cx
> lpBand
->cxEffective
)
1233 lpBand
->cx
= lpBand
->cxEffective
;
1241 /* Try to shrink the visible bands in [iBeginBand; iEndBand) by cxShrink, starting from the left.
1242 * iBeginBand must be visible */
1243 static int REBAR_ShrinkBandsLTR(const REBAR_INFO
*infoPtr
, INT iBeginBand
, INT iEndBand
, INT cxShrink
, BOOL bEnforce
)
1248 TRACE("Shrinking bands [%d..%d) by %d, left-to-right\n", iBeginBand
, iEndBand
, cxShrink
);
1249 for (i
= iBeginBand
; i
< iEndBand
; i
= next_visible(infoPtr
, i
))
1251 lpBand
= REBAR_GetBand(infoPtr
, i
);
1253 width
= max(lpBand
->cxEffective
- cxShrink
, (int)lpBand
->cxMinBand
);
1254 cxShrink
-= lpBand
->cxEffective
- width
;
1255 lpBand
->cxEffective
= width
;
1257 lpBand
->cx
= lpBand
->cxEffective
;
1264 /* Tries to move a band to a given offset within a row. */
1265 static int REBAR_MoveBandToRowOffset(REBAR_INFO
*infoPtr
, INT iBand
, INT iFirstBand
,
1266 INT iLastBand
, INT xOff
, BOOL reorder
)
1268 REBAR_BAND
*insertBand
= REBAR_GetBand(infoPtr
, iBand
);
1270 const BOOL setBreak
= REBAR_GetBand(infoPtr
, iFirstBand
)->fStyle
& RBBS_BREAK
;
1272 /* Find the band's new position */
1275 /* Used during an LR band reorder drag */
1276 for (i
= iFirstBand
; i
< iLastBand
; i
= next_visible(infoPtr
, i
))
1280 xPos
+= REBAR_GetBand(infoPtr
, i
)->cxEffective
+ SEP_WIDTH
;
1285 /* Used during a UD band insertion drag */
1286 for (i
= iFirstBand
; i
< iLastBand
; i
= next_visible(infoPtr
, i
))
1288 const REBAR_BAND
*band
= REBAR_GetBand(infoPtr
, i
);
1289 if(xPos
+ band
->cxMinBand
/ 2 > xOff
)
1291 xPos
+= band
->cxEffective
+ SEP_WIDTH
;
1295 /* Move the band to its new position */
1296 DPA_DeletePtr(infoPtr
->bands
, iBand
);
1299 DPA_InsertPtr(infoPtr
->bands
, i
, insertBand
);
1301 /* Ensure only the last band has the RBBS_BREAK flag set */
1302 insertBand
->fStyle
&= ~RBBS_BREAK
;
1304 REBAR_GetBand(infoPtr
, iFirstBand
)->fStyle
|= RBBS_BREAK
;
1306 /* Return the currently grabbed band */
1307 if(infoPtr
->iGrabbedBand
== iBand
)
1309 infoPtr
->iGrabbedBand
= i
;
1315 /* Set the heights of the visible bands in [iBeginBand; iEndBand) to the max height. iBeginBand must be visible */
1316 static int REBAR_SetBandsHeight(const REBAR_INFO
*infoPtr
, INT iBeginBand
, INT iEndBand
, INT yStart
)
1321 int row
= REBAR_GetBand(infoPtr
, iBeginBand
)->iRow
;
1323 for (i
= iBeginBand
; i
< iEndBand
; i
= next_visible(infoPtr
, i
))
1325 lpBand
= REBAR_GetBand(infoPtr
, i
);
1326 lpBand
->cyRowSoFar
= yMaxHeight
;
1327 yMaxHeight
= max(yMaxHeight
, lpBand
->cyMinBand
);
1329 TRACE("Bands [%d; %d) height: %d\n", iBeginBand
, iEndBand
, yMaxHeight
);
1331 for (i
= iBeginBand
; i
< iEndBand
; i
= next_visible(infoPtr
, i
))
1333 lpBand
= REBAR_GetBand(infoPtr
, i
);
1334 /* we may be called for multiple rows if RBS_VARHEIGHT not set */
1335 if (lpBand
->iRow
!= row
) {
1336 yPos
+= yMaxHeight
+ SEP_WIDTH
;
1340 if (lpBand
->rcBand
.top
!= yPos
|| lpBand
->rcBand
.bottom
!= yPos
+ yMaxHeight
) {
1341 lpBand
->fDraw
|= NTF_INVALIDATE
;
1342 lpBand
->rcBand
.top
= yPos
;
1343 lpBand
->rcBand
.bottom
= yPos
+ yMaxHeight
;
1344 TRACE("Band %d: %s\n", i
, wine_dbgstr_rect(&lpBand
->rcBand
));
1347 return yPos
+ yMaxHeight
;
1350 /* Layout the row [iBeginBand; iEndBand). iBeginBand must be visible */
1351 static void REBAR_LayoutRow(const REBAR_INFO
*infoPtr
, int iBeginBand
, int iEndBand
, int cx
, int *piRow
, int *pyPos
)
1357 TRACE("Adjusting row [%d;%d). Width: %d\n", iBeginBand
, iEndBand
, cx
);
1358 for (i
= iBeginBand
; i
< iEndBand
; i
++)
1359 REBAR_GetBand(infoPtr
, i
)->iRow
= *piRow
;
1361 /* compute the extra space */
1362 for (i
= iBeginBand
; i
< iEndBand
; i
= next_visible(infoPtr
, i
))
1364 lpBand
= REBAR_GetBand(infoPtr
, i
);
1367 lpBand
->cxEffective
= max(lpBand
->cxMinBand
, lpBand
->cx
);
1368 width
+= lpBand
->cxEffective
;
1372 TRACE("Extra space: %d\n", extra
);
1374 int ret
= REBAR_ShrinkBandsRTL(infoPtr
, iBeginBand
, iEndBand
, -extra
, FALSE
);
1375 if (ret
> 0 && next_visible(infoPtr
, iBeginBand
) != iEndBand
) /* one band may be longer than expected... */
1376 ERR("Error layouting row %d - couldn't shrink for %d pixels (%d total shrink)\n", *piRow
, ret
, -extra
);
1379 lpBand
= REBAR_FindBandToGrow(infoPtr
, iBeginBand
, iEndBand
);
1380 lpBand
->cxEffective
+= extra
;
1383 REBAR_SetRowRectsX(infoPtr
, iBeginBand
, iEndBand
);
1384 if (infoPtr
->dwStyle
& RBS_VARHEIGHT
)
1387 *pyPos
+= SEP_WIDTH
;
1388 *pyPos
= REBAR_SetBandsHeight(infoPtr
, iBeginBand
, iEndBand
, *pyPos
);
1394 REBAR_Layout(REBAR_INFO
*infoPtr
)
1404 if (infoPtr
->dwStyle
& (CCS_NORESIZE
| CCS_NOPARENTALIGN
) || GetParent(infoPtr
->hwndSelf
) == NULL
)
1405 GetClientRect(infoPtr
->hwndSelf
, &rcAdj
);
1407 GetClientRect(GetParent(infoPtr
->hwndSelf
), &rcAdj
);
1408 TRACE("adjustment rect is (%s)\n", wine_dbgstr_rect(&rcAdj
));
1410 adjcx
= get_rect_cx(infoPtr
, &rcAdj
);
1412 if (infoPtr
->uNumBands
== 0) {
1413 TRACE("No bands - setting size to (0,%d), vert: %x\n", adjcx
, infoPtr
->dwStyle
& CCS_VERT
);
1414 infoPtr
->calcSize
.cx
= adjcx
;
1415 /* the calcSize.cy won't change for a 0 band rebar */
1416 infoPtr
->uNumRows
= 0;
1417 REBAR_ForceResize(infoPtr
);
1423 rowstart
= first_visible(infoPtr
);
1425 for (i
= rowstart
; i
< infoPtr
->uNumBands
; i
= next_visible(infoPtr
, i
))
1427 lpBand
= REBAR_GetBand(infoPtr
, i
);
1429 if (i
> rowstart
&& (lpBand
->fStyle
& RBBS_BREAK
|| xMin
+ lpBand
->cxMinBand
> adjcx
)) {
1430 TRACE("%s break on band %d\n", (lpBand
->fStyle
& RBBS_BREAK
? "Hard" : "Soft"), i
- 1);
1431 REBAR_LayoutRow(infoPtr
, rowstart
, i
, adjcx
, &row
, &yPos
);
1438 xMin
+= lpBand
->cxMinBand
;
1440 if (rowstart
< infoPtr
->uNumBands
)
1441 REBAR_LayoutRow(infoPtr
, rowstart
, infoPtr
->uNumBands
, adjcx
, &row
, &yPos
);
1443 if (!(infoPtr
->dwStyle
& RBS_VARHEIGHT
))
1444 yPos
= REBAR_SetBandsHeight(infoPtr
, first_visible(infoPtr
), infoPtr
->uNumBands
, 0);
1446 infoPtr
->uNumRows
= row
;
1448 if (infoPtr
->dwStyle
& CCS_VERT
)
1449 REBAR_CalcVertBand(infoPtr
, 0, infoPtr
->uNumBands
);
1451 REBAR_CalcHorzBand(infoPtr
, 0, infoPtr
->uNumBands
);
1452 /* now compute size of Rebar itself */
1453 oldSize
= infoPtr
->calcSize
;
1455 infoPtr
->calcSize
.cx
= adjcx
;
1456 infoPtr
->calcSize
.cy
= yPos
;
1457 TRACE("calcsize size=(%d, %d), origheight=(%d,%d)\n",
1458 infoPtr
->calcSize
.cx
, infoPtr
->calcSize
.cy
,
1459 oldSize
.cx
, oldSize
.cy
);
1461 REBAR_DumpBand (infoPtr
);
1462 REBAR_MoveChildWindows (infoPtr
, 0, infoPtr
->uNumBands
);
1463 REBAR_ForceResize (infoPtr
);
1465 /* note: after a RBN_HEIGHTCHANGE native sends once again all the RBN_CHILDSIZE
1466 * and does another ForceResize */
1467 if (oldSize
.cy
!= infoPtr
->calcSize
.cy
)
1470 REBAR_Notify(&heightchange
, infoPtr
, RBN_HEIGHTCHANGE
);
1471 REBAR_AutoSize(infoPtr
, FALSE
);
1475 /* iBeginBand must be visible */
1477 REBAR_SizeChildrenToHeight(const REBAR_INFO
*infoPtr
, int iBeginBand
, int iEndBand
, int extra
, BOOL
*fChanged
)
1483 TRACE("[%d;%d) by %d\n", iBeginBand
, iEndBand
, extra
);
1485 cyBandsOld
= REBAR_GetBand(infoPtr
, iBeginBand
)->rcBand
.bottom
-
1486 REBAR_GetBand(infoPtr
, iBeginBand
)->rcBand
.top
;
1487 for (i
= iBeginBand
; i
< iEndBand
; i
= next_visible(infoPtr
, i
))
1489 REBAR_BAND
*lpBand
= REBAR_GetBand(infoPtr
, i
);
1490 int cyMaxChild
= cyBandsOld
- REBARSPACE(lpBand
) + extra
;
1491 int cyChild
= round_child_height(lpBand
, cyMaxChild
);
1493 if (lpBand
->hwndChild
&& cyChild
!= lpBand
->cyChild
&& (lpBand
->fStyle
& RBBS_VARIABLEHEIGHT
))
1495 TRACE("Resizing %d: %d -> %d [%d]\n", i
, lpBand
->cyChild
, cyChild
, lpBand
->cyMaxChild
);
1497 lpBand
->cyChild
= cyChild
;
1498 lpBand
->fDraw
|= NTF_INVALIDATE
;
1499 update_min_band_height(infoPtr
, lpBand
);
1501 cyBandsNew
= max(cyBandsNew
, lpBand
->cyMinBand
);
1503 return cyBandsNew
- cyBandsOld
;
1506 /* worker function for RB_SIZETORECT and RBS_AUTOSIZE */
1508 REBAR_SizeToHeight(REBAR_INFO
*infoPtr
, int height
)
1510 int extra
= height
- infoPtr
->calcSize
.cy
; /* may be negative */
1511 BOOL fChanged
= FALSE
;
1512 UINT uNumRows
= infoPtr
->uNumRows
;
1515 if (uNumRows
== 0) /* avoid division by 0 */
1518 /* That's not exactly what Windows does but should be similar */
1520 /* Pass one: break-up/glue rows */
1523 for (i
= prev_visible(infoPtr
, infoPtr
->uNumBands
); i
> 0; i
= prev_visible(infoPtr
, i
))
1525 REBAR_BAND
*lpBand
= REBAR_GetBand(infoPtr
, i
);
1526 int cyBreakExtra
; /* additional cy for the rebar after a RBBS_BREAK on this band */
1528 height
= lpBand
->rcBand
.bottom
- lpBand
->rcBand
.top
;
1530 if (infoPtr
->dwStyle
& RBS_VARHEIGHT
)
1531 cyBreakExtra
= lpBand
->cyRowSoFar
; /* 'height' => 'lpBand->cyRowSoFar' + 'height'*/
1533 cyBreakExtra
= height
; /* 'height' => 'height' + 'height'*/
1534 cyBreakExtra
+= SEP_WIDTH
;
1536 if (extra
<= cyBreakExtra
/ 2)
1539 if (!(lpBand
->fStyle
& RBBS_BREAK
))
1541 TRACE("Adding break on band %d - extra %d -> %d\n", i
, extra
, extra
- cyBreakExtra
);
1542 lpBand
->fStyle
|= RBBS_BREAK
;
1543 lpBand
->fDraw
|= NTF_INVALIDATE
;
1545 extra
-= cyBreakExtra
;
1547 /* temporary change for _SizeControlsToHeight. The true values will be computed in _Layout */
1548 if (infoPtr
->dwStyle
& RBS_VARHEIGHT
)
1549 lpBand
->rcBand
.bottom
= lpBand
->rcBand
.top
+ lpBand
->cyMinBand
;
1553 /* TODO: else if (extra < 0) { try to remove some RBBS_BREAKs } */
1555 /* Pass two: increase/decrease control height */
1556 if (infoPtr
->dwStyle
& RBS_VARHEIGHT
)
1558 int i
= first_visible(infoPtr
);
1560 while (i
< infoPtr
->uNumBands
)
1562 REBAR_BAND
*lpBand
= REBAR_GetBand(infoPtr
, i
);
1563 int extraForRow
= extra
/ (int)(uNumRows
- iRow
);
1566 /* we can't use get_row_end_for_band as we might have added RBBS_BREAK in the first phase */
1567 for (rowEnd
= next_visible(infoPtr
, i
); rowEnd
< infoPtr
->uNumBands
; rowEnd
= next_visible(infoPtr
, rowEnd
))
1568 if (REBAR_GetBand(infoPtr
, rowEnd
)->iRow
!= lpBand
->iRow
||
1569 REBAR_GetBand(infoPtr
, rowEnd
)->fStyle
& RBBS_BREAK
)
1572 extra
-= REBAR_SizeChildrenToHeight(infoPtr
, i
, rowEnd
, extraForRow
, &fChanged
);
1573 TRACE("extra = %d\n", extra
);
1579 REBAR_SizeChildrenToHeight(infoPtr
, first_visible(infoPtr
), infoPtr
->uNumBands
, extra
/ infoPtr
->uNumRows
, &fChanged
);
1582 REBAR_Layout(infoPtr
);
1586 REBAR_AutoSize(REBAR_INFO
*infoPtr
, BOOL needsLayout
)
1589 NMRBAUTOSIZE autosize
;
1592 REBAR_Layout(infoPtr
);
1593 GetClientRect(infoPtr
->hwndSelf
, &rc
);
1594 REBAR_SizeToHeight(infoPtr
, get_rect_cy(infoPtr
, &rc
));
1595 GetClientRect(infoPtr
->hwndSelf
, &rcNew
);
1597 GetClientRect(infoPtr
->hwndSelf
, &autosize
.rcTarget
);
1598 autosize
.fChanged
= (memcmp(&rc
, &rcNew
, sizeof(RECT
)) == 0);
1599 autosize
.rcTarget
= rc
;
1600 autosize
.rcActual
= rcNew
;
1601 REBAR_Notify((NMHDR
*)&autosize
, infoPtr
, RBN_AUTOSIZE
);
1605 REBAR_ValidateBand (const REBAR_INFO
*infoPtr
, REBAR_BAND
*lpBand
)
1606 /* Function: This routine evaluates the band specs supplied */
1607 /* by the user and updates the following 5 fields in */
1608 /* the internal band structure: cxHeader, cyHeader, cxMinBand, cyMinBand, fStatus */
1611 UINT textheight
=0, imageheight
= 0;
1615 lpBand
->fStatus
= 0;
1616 lpBand
->cxMinBand
= 0;
1617 lpBand
->cyMinBand
= 0;
1619 /* Data coming in from users into the cx... and cy... fields */
1620 /* may be bad, just garbage, because the user never clears */
1621 /* the fields. RB_{SET|INSERT}BAND{A|W} just passes the data */
1622 /* along if the fields exist in the input area. Here we must */
1623 /* determine if the data is valid. I have no idea how MS does */
1624 /* the validation, but it does because the RB_GETBANDINFO */
1625 /* returns a 0 when I know the sample program passed in an */
1626 /* address. Here I will use the algorithm that if the value */
1627 /* is greater than 65535 then it is bad and replace it with */
1628 /* a zero. Feel free to improve the algorithm. - GA 12/2000 */
1629 if (lpBand
->cxMinChild
> 65535) lpBand
->cxMinChild
= 0;
1630 if (lpBand
->cyMinChild
> 65535) lpBand
->cyMinChild
= 0;
1631 if (lpBand
->cx
> 65535) lpBand
->cx
= 0;
1632 if (lpBand
->cyChild
> 65535) lpBand
->cyChild
= 0;
1633 if (lpBand
->cyIntegral
> 65535) lpBand
->cyIntegral
= 0;
1634 if (lpBand
->cxIdeal
> 65535) lpBand
->cxIdeal
= 0;
1635 if (lpBand
->cxHeader
> 65535) lpBand
->cxHeader
= 0;
1637 /* TODO : we could try return to the caller if a value changed so that */
1638 /* a REBAR_Layout is needed. Till now the caller should call it */
1639 /* it always (we should also check what native does) */
1641 /* Header is where the image, text and gripper exist */
1642 /* in the band and precede the child window. */
1644 /* count number of non-FIXEDSIZE and non-Hidden bands */
1646 for (i
=0; i
<infoPtr
->uNumBands
; i
++){
1647 tBand
= REBAR_GetBand(infoPtr
, i
);
1648 if (!HIDDENBAND(tBand
) && !(tBand
->fStyle
& RBBS_FIXEDSIZE
))
1652 /* calculate gripper rectangle */
1653 if ( (!(lpBand
->fStyle
& RBBS_NOGRIPPER
)) &&
1654 ( (lpBand
->fStyle
& RBBS_GRIPPERALWAYS
) ||
1655 ( !(lpBand
->fStyle
& RBBS_FIXEDSIZE
) && (nonfixed
> 1)))
1657 lpBand
->fStatus
|= HAS_GRIPPER
;
1658 if (infoPtr
->dwStyle
& CCS_VERT
)
1659 if (infoPtr
->dwStyle
& RBS_VERTICALGRIPPER
)
1660 header
+= (GRIPPER_HEIGHT
+ REBAR_PRE_GRIPPER
);
1662 header
+= (GRIPPER_WIDTH
+ REBAR_PRE_GRIPPER
);
1664 header
+= (REBAR_PRE_GRIPPER
+ GRIPPER_WIDTH
);
1665 /* Always have 4 pixels before anything else */
1666 header
+= REBAR_ALWAYS_SPACE
;
1669 /* image is visible */
1670 if (lpBand
->iImage
!= -1 && (infoPtr
->himl
)) {
1671 lpBand
->fStatus
|= HAS_IMAGE
;
1672 if (infoPtr
->dwStyle
& CCS_VERT
) {
1673 header
+= (infoPtr
->imageSize
.cy
+ REBAR_POST_IMAGE
);
1674 imageheight
= infoPtr
->imageSize
.cx
+ 4;
1677 header
+= (infoPtr
->imageSize
.cx
+ REBAR_POST_IMAGE
);
1678 imageheight
= infoPtr
->imageSize
.cy
+ 4;
1682 /* text is visible */
1683 if ((lpBand
->fMask
& RBBIM_TEXT
) && (lpBand
->lpText
) &&
1684 !(lpBand
->fStyle
& RBBS_HIDETITLE
)) {
1685 HDC hdc
= GetDC (0);
1686 HFONT hOldFont
= SelectObject (hdc
, infoPtr
->hFont
);
1689 lpBand
->fStatus
|= HAS_TEXT
;
1690 GetTextExtentPoint32W (hdc
, lpBand
->lpText
,
1691 lstrlenW (lpBand
->lpText
), &size
);
1692 header
+= ((infoPtr
->dwStyle
& CCS_VERT
) ? (size
.cy
+ REBAR_POST_TEXT
) : (size
.cx
+ REBAR_POST_TEXT
));
1693 textheight
= (infoPtr
->dwStyle
& CCS_VERT
) ? 0 : size
.cy
;
1695 SelectObject (hdc
, hOldFont
);
1699 /* if no gripper but either image or text, then leave space */
1700 if ((lpBand
->fStatus
& (HAS_IMAGE
| HAS_TEXT
)) &&
1701 !(lpBand
->fStatus
& HAS_GRIPPER
)) {
1702 header
+= REBAR_ALWAYS_SPACE
;
1705 /* check if user overrode the header value */
1706 if (!(lpBand
->fStyle
& RBBS_UNDOC_FIXEDHEADER
))
1707 lpBand
->cxHeader
= header
;
1708 lpBand
->cyHeader
= max(textheight
, imageheight
);
1710 /* Now compute minimum size of child window */
1711 update_min_band_height(infoPtr
, lpBand
); /* update lpBand->cyMinBand from cyHeader and cyChild*/
1713 lpBand
->cxMinBand
= lpBand
->cxMinChild
+ lpBand
->cxHeader
+ REBAR_POST_CHILD
;
1714 if (lpBand
->fStyle
& RBBS_USECHEVRON
&& lpBand
->cxMinChild
< lpBand
->cxIdeal
)
1715 lpBand
->cxMinBand
+= CHEVRON_WIDTH
;
1719 REBAR_CommonSetupBand(HWND hwnd
, const REBARBANDINFOW
*lprbbi
, REBAR_BAND
*lpBand
)
1720 /* Function: This routine copies the supplied values from */
1721 /* user input (lprbbi) to the internal band structure. */
1722 /* It returns the mask of what changed. */
1724 UINT uChanged
= 0x0;
1726 lpBand
->fMask
|= lprbbi
->fMask
;
1728 if( (lprbbi
->fMask
& RBBIM_STYLE
) &&
1729 (lpBand
->fStyle
!= lprbbi
->fStyle
) )
1731 lpBand
->fStyle
= lprbbi
->fStyle
;
1732 uChanged
|= RBBIM_STYLE
;
1735 if( (lprbbi
->fMask
& RBBIM_COLORS
) &&
1736 ( ( lpBand
->clrFore
!= lprbbi
->clrFore
) ||
1737 ( lpBand
->clrBack
!= lprbbi
->clrBack
) ) )
1739 lpBand
->clrFore
= lprbbi
->clrFore
;
1740 lpBand
->clrBack
= lprbbi
->clrBack
;
1741 uChanged
|= RBBIM_COLORS
;
1744 if( (lprbbi
->fMask
& RBBIM_IMAGE
) &&
1745 ( lpBand
->iImage
!= lprbbi
->iImage
) )
1747 lpBand
->iImage
= lprbbi
->iImage
;
1748 uChanged
|= RBBIM_IMAGE
;
1751 if( (lprbbi
->fMask
& RBBIM_CHILD
) &&
1752 (lprbbi
->hwndChild
!= lpBand
->hwndChild
) )
1754 if (lprbbi
->hwndChild
) {
1755 lpBand
->hwndChild
= lprbbi
->hwndChild
;
1756 lpBand
->hwndPrevParent
=
1757 SetParent (lpBand
->hwndChild
, hwnd
);
1758 /* below in trace from WinRAR */
1759 ShowWindow(lpBand
->hwndChild
, SW_SHOWNOACTIVATE
| SW_SHOWNORMAL
);
1760 /* above in trace from WinRAR */
1763 TRACE("child: %p prev parent: %p\n",
1764 lpBand
->hwndChild
, lpBand
->hwndPrevParent
);
1765 lpBand
->hwndChild
= 0;
1766 lpBand
->hwndPrevParent
= 0;
1768 uChanged
|= RBBIM_CHILD
;
1771 if( (lprbbi
->fMask
& RBBIM_CHILDSIZE
) &&
1772 ( (lpBand
->cxMinChild
!= lprbbi
->cxMinChild
) ||
1773 (lpBand
->cyMinChild
!= lprbbi
->cyMinChild
) ||
1774 ( (lprbbi
->cbSize
>= REBARBANDINFOA_V6_SIZE
&& (lpBand
->fStyle
& RBBS_VARIABLEHEIGHT
)) &&
1775 ( (lpBand
->cyChild
!= lprbbi
->cyChild
) ||
1776 (lpBand
->cyMaxChild
!= lprbbi
->cyMaxChild
) ||
1777 (lpBand
->cyIntegral
!= lprbbi
->cyIntegral
) ) ) ||
1778 ( (lprbbi
->cbSize
< REBARBANDINFOA_V6_SIZE
) &&
1779 ( (lpBand
->cyChild
||
1780 lpBand
->cyMaxChild
||
1781 lpBand
->cyIntegral
) ) ) ) )
1783 lpBand
->cxMinChild
= lprbbi
->cxMinChild
;
1784 lpBand
->cyMinChild
= lprbbi
->cyMinChild
;
1785 /* These fields where added in WIN32_IE == 0x400 and are set only for RBBS_VARIABLEHEIGHT bands */
1786 if (lprbbi
->cbSize
>= REBARBANDINFOA_V6_SIZE
&& (lpBand
->fStyle
& RBBS_VARIABLEHEIGHT
)) {
1787 lpBand
->cyMaxChild
= lprbbi
->cyMaxChild
;
1788 lpBand
->cyIntegral
= lprbbi
->cyIntegral
;
1790 lpBand
->cyChild
= round_child_height(lpBand
, lprbbi
->cyChild
); /* make (cyChild - cyMinChild) a multiple of cyIntergral */
1793 lpBand
->cyChild
= lpBand
->cyMinChild
;
1794 lpBand
->cyMaxChild
= 0x7fffffff;
1795 lpBand
->cyIntegral
= 0;
1797 uChanged
|= RBBIM_CHILDSIZE
;
1800 if( (lprbbi
->fMask
& RBBIM_SIZE
) &&
1801 (lpBand
->cx
!= lprbbi
->cx
) )
1803 lpBand
->cx
= lprbbi
->cx
;
1804 uChanged
|= RBBIM_SIZE
;
1807 if( (lprbbi
->fMask
& RBBIM_BACKGROUND
) &&
1808 ( lpBand
->hbmBack
!= lprbbi
->hbmBack
) )
1810 lpBand
->hbmBack
= lprbbi
->hbmBack
;
1811 uChanged
|= RBBIM_BACKGROUND
;
1814 if( (lprbbi
->fMask
& RBBIM_ID
) &&
1815 (lpBand
->wID
!= lprbbi
->wID
) )
1817 lpBand
->wID
= lprbbi
->wID
;
1818 uChanged
|= RBBIM_ID
;
1821 /* check for additional data */
1822 if (lprbbi
->cbSize
>= REBARBANDINFOA_V6_SIZE
) {
1823 if( (lprbbi
->fMask
& RBBIM_IDEALSIZE
) &&
1824 ( lpBand
->cxIdeal
!= lprbbi
->cxIdeal
) )
1826 lpBand
->cxIdeal
= lprbbi
->cxIdeal
;
1827 uChanged
|= RBBIM_IDEALSIZE
;
1830 if( (lprbbi
->fMask
& RBBIM_LPARAM
) &&
1831 (lpBand
->lParam
!= lprbbi
->lParam
) )
1833 lpBand
->lParam
= lprbbi
->lParam
;
1834 uChanged
|= RBBIM_LPARAM
;
1837 if( (lprbbi
->fMask
& RBBIM_HEADERSIZE
) &&
1838 (lpBand
->cxHeader
!= lprbbi
->cxHeader
) )
1840 lpBand
->cxHeader
= lprbbi
->cxHeader
;
1841 lpBand
->fStyle
|= RBBS_UNDOC_FIXEDHEADER
;
1842 uChanged
|= RBBIM_HEADERSIZE
;
1849 static LRESULT
REBAR_EraseBkGnd (const REBAR_INFO
*infoPtr
, HDC hdc
)
1850 /* Function: This erases the background rectangle by drawing */
1851 /* each band with its background color (or the default) and */
1852 /* draws each bands right separator if necessary. The row */
1853 /* separators are drawn on the first band of the next row. */
1859 COLORREF old
= CLR_NONE
, new;
1860 HTHEME theme
= GetWindowTheme (infoPtr
->hwndSelf
);
1862 GetClientRect (infoPtr
->hwndSelf
, &cr
);
1865 for(i
=0; i
<infoPtr
->uNumBands
; i
++) {
1867 lpBand
= REBAR_GetBand(infoPtr
, i
);
1868 if (HIDDENBAND(lpBand
)) continue;
1869 translate_rect(infoPtr
, &rcBand
, &lpBand
->rcBand
);
1871 /* draw band separator between rows */
1872 if (lpBand
->iRow
!= oldrow
) {
1873 oldrow
= lpBand
->iRow
;
1874 if (infoPtr
->dwStyle
& RBS_BANDBORDERS
) {
1877 if (infoPtr
->dwStyle
& CCS_VERT
) {
1878 rcRowSep
.right
+= SEP_WIDTH_SIZE
;
1879 rcRowSep
.bottom
= infoPtr
->calcSize
.cx
;
1881 DrawThemeEdge (theme
, hdc
, RP_BAND
, 0, &rcRowSep
, EDGE_ETCHED
, BF_RIGHT
, NULL
);
1883 DrawEdge (hdc
, &rcRowSep
, EDGE_ETCHED
, BF_RIGHT
);
1886 rcRowSep
.bottom
+= SEP_WIDTH_SIZE
;
1887 rcRowSep
.right
= infoPtr
->calcSize
.cx
;
1889 DrawThemeEdge (theme
, hdc
, RP_BAND
, 0, &rcRowSep
, EDGE_ETCHED
, BF_BOTTOM
, NULL
);
1891 DrawEdge (hdc
, &rcRowSep
, EDGE_ETCHED
, BF_BOTTOM
);
1893 TRACE ("drawing band separator bottom (%s)\n",
1894 wine_dbgstr_rect(&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 DrawThemeEdge (theme
, hdc
, RP_BAND
, 0, &rcSep
, EDGE_ETCHED
, BF_BOTTOM
, NULL
);
1908 DrawEdge (hdc
, &rcSep
, EDGE_ETCHED
, BF_BOTTOM
);
1911 rcSep
.right
= rcSep
.left
;
1912 rcSep
.left
-= SEP_WIDTH_SIZE
;
1914 DrawThemeEdge (theme
, hdc
, RP_BAND
, 0, &rcSep
, EDGE_ETCHED
, BF_RIGHT
, NULL
);
1916 DrawEdge (hdc
, &rcSep
, EDGE_ETCHED
, BF_RIGHT
);
1918 TRACE("drawing band separator right (%s)\n",
1919 wine_dbgstr_rect(&rcSep
));
1922 /* draw the actual background */
1923 if (lpBand
->clrBack
!= CLR_NONE
) {
1924 new = (lpBand
->clrBack
== CLR_DEFAULT
) ? infoPtr
->clrBtnFace
:
1927 /* testing only - make background green to see it */
1932 /* In the absence of documentation for Rebar vs. CLR_NONE,
1933 * we will use the default BtnFace color. Note documentation
1934 * exists for Listview and Imagelist.
1936 new = infoPtr
->clrBtnFace
;
1938 /* testing only - make background green to see it */
1945 /* When themed, the background color is ignored (but not a
1946 * background bitmap */
1947 DrawThemeBackground (theme
, hdc
, 0, 0, &cr
, &rcBand
);
1951 old
= SetBkColor (hdc
, new);
1952 TRACE("%s background color=0x%06x, band %s\n",
1953 (lpBand
->clrBack
== CLR_NONE
) ? "none" :
1954 ((lpBand
->clrBack
== CLR_DEFAULT
) ? "dft" : ""),
1955 GetBkColor(hdc
), wine_dbgstr_rect(&rcBand
));
1956 ExtTextOutW (hdc
, 0, 0, ETO_OPAQUE
, &rcBand
, NULL
, 0, 0);
1957 if (lpBand
->clrBack
!= CLR_NONE
)
1958 SetBkColor (hdc
, old
);
1965 REBAR_InternalHitTest (const REBAR_INFO
*infoPtr
, const POINT
*lpPt
, UINT
*pFlags
, INT
*pBand
)
1971 GetClientRect (infoPtr
->hwndSelf
, &rect
);
1973 *pFlags
= RBHT_NOWHERE
;
1974 if (PtInRect (&rect
, *lpPt
))
1976 if (infoPtr
->uNumBands
== 0) {
1977 *pFlags
= RBHT_NOWHERE
;
1984 /* somewhere inside */
1985 for (iCount
= 0; iCount
< infoPtr
->uNumBands
; iCount
++) {
1987 lpBand
= REBAR_GetBand(infoPtr
, iCount
);
1988 translate_rect(infoPtr
, &rcBand
, &lpBand
->rcBand
);
1989 if (HIDDENBAND(lpBand
)) continue;
1990 if (PtInRect (&rcBand
, *lpPt
)) {
1993 if (PtInRect (&lpBand
->rcGripper
, *lpPt
)) {
1994 *pFlags
= RBHT_GRABBER
;
1995 TRACE("ON GRABBER %d\n", iCount
);
1998 else if (PtInRect (&lpBand
->rcCapImage
, *lpPt
)) {
1999 *pFlags
= RBHT_CAPTION
;
2000 TRACE("ON CAPTION %d\n", iCount
);
2003 else if (PtInRect (&lpBand
->rcCapText
, *lpPt
)) {
2004 *pFlags
= RBHT_CAPTION
;
2005 TRACE("ON CAPTION %d\n", iCount
);
2008 else if (PtInRect (&lpBand
->rcChild
, *lpPt
)) {
2009 *pFlags
= RBHT_CLIENT
;
2010 TRACE("ON CLIENT %d\n", iCount
);
2013 else if (PtInRect (&lpBand
->rcChevron
, *lpPt
)) {
2014 *pFlags
= RBHT_CHEVRON
;
2015 TRACE("ON CHEVRON %d\n", iCount
);
2019 *pFlags
= RBHT_NOWHERE
;
2020 TRACE("NOWHERE %d\n", iCount
);
2026 *pFlags
= RBHT_NOWHERE
;
2035 *pFlags
= RBHT_NOWHERE
;
2044 REBAR_HandleLRDrag (REBAR_INFO
*infoPtr
, const POINT
*ptsmove
)
2045 /* Function: This will implement the functionality of a */
2046 /* Gripper drag within a row. It will not implement "out- */
2047 /* of-row" drags. (They are detected and handled in */
2048 /* REBAR_MouseMove.) */
2050 REBAR_BAND
*hitBand
;
2051 INT iHitBand
, iRowBegin
, iRowEnd
;
2052 INT movement
, xBand
, cxLeft
= 0;
2053 BOOL shrunkBands
= FALSE
;
2055 iHitBand
= infoPtr
->iGrabbedBand
;
2056 iRowBegin
= get_row_begin_for_band(infoPtr
, iHitBand
);
2057 iRowEnd
= get_row_end_for_band(infoPtr
, iHitBand
);
2058 hitBand
= REBAR_GetBand(infoPtr
, iHitBand
);
2060 xBand
= hitBand
->rcBand
.left
;
2061 movement
= (infoPtr
->dwStyle
&CCS_VERT
? ptsmove
->y
: ptsmove
->x
)
2062 - (xBand
+ REBAR_PRE_GRIPPER
- infoPtr
->ihitoffset
);
2064 /* Dragging the first band in a row cannot cause shrinking */
2065 if(iHitBand
!= iRowBegin
)
2068 cxLeft
= REBAR_ShrinkBandsRTL(infoPtr
, iRowBegin
, iHitBand
, -movement
, TRUE
);
2070 if(cxLeft
< -movement
)
2072 hitBand
->cxEffective
+= -movement
- cxLeft
;
2073 hitBand
->cx
= hitBand
->cxEffective
;
2077 } else if (movement
> 0) {
2080 if (prev_visible(infoPtr
, iHitBand
) >= 0)
2081 cxLeft
= REBAR_ShrinkBandsLTR(infoPtr
, iHitBand
, iRowEnd
, movement
, TRUE
);
2083 if(cxLeft
< movement
)
2085 REBAR_BAND
*lpPrev
= REBAR_GetBand(infoPtr
, prev_visible(infoPtr
, iHitBand
));
2086 lpPrev
->cxEffective
+= movement
- cxLeft
;
2087 lpPrev
->cx
= hitBand
->cxEffective
;
2096 /* It was not possible to move the band by shrinking bands.
2097 * Try relocating the band instead. */
2098 REBAR_MoveBandToRowOffset(infoPtr
, iHitBand
, iRowBegin
,
2099 iRowEnd
, xBand
+ movement
, TRUE
);
2102 REBAR_SetRowRectsX(infoPtr
, iRowBegin
, iRowEnd
);
2103 if (infoPtr
->dwStyle
& CCS_VERT
)
2104 REBAR_CalcVertBand(infoPtr
, 0, infoPtr
->uNumBands
);
2106 REBAR_CalcHorzBand(infoPtr
, 0, infoPtr
->uNumBands
);
2107 REBAR_MoveChildWindows(infoPtr
, iRowBegin
, iRowEnd
);
2111 REBAR_HandleUDDrag (REBAR_INFO
*infoPtr
, const POINT
*ptsmove
)
2113 INT yOff
= (infoPtr
->dwStyle
& CCS_VERT
) ? ptsmove
->x
: ptsmove
->y
;
2114 INT iHitBand
, iRowBegin
, iNextRowBegin
;
2115 REBAR_BAND
*hitBand
, *rowBeginBand
;
2117 if(infoPtr
->uNumBands
<= 0)
2118 ERR("There are no bands in this rebar\n");
2120 /* Up/down dragging can only occur when there is more than one
2121 * band in the rebar */
2122 if(infoPtr
->uNumBands
<= 1)
2125 iHitBand
= infoPtr
->iGrabbedBand
;
2126 hitBand
= REBAR_GetBand(infoPtr
, iHitBand
);
2128 /* If we're taking a band that has the RBBS_BREAK style set, this
2129 * style needs to be reapplied to the band that is going to become
2130 * the new start of the row. */
2131 if((hitBand
->fStyle
& RBBS_BREAK
) &&
2132 (iHitBand
< infoPtr
->uNumBands
- 1))
2133 REBAR_GetBand(infoPtr
, iHitBand
+ 1)->fStyle
|= RBBS_BREAK
;
2137 /* Place the band above the current top row */
2138 if(iHitBand
==0 && (infoPtr
->uNumBands
==1 || REBAR_GetBand(infoPtr
, 1)->fStyle
&RBBS_BREAK
))
2140 DPA_DeletePtr(infoPtr
->bands
, iHitBand
);
2141 hitBand
->fStyle
&= ~RBBS_BREAK
;
2142 REBAR_GetBand(infoPtr
, 0)->fStyle
|= RBBS_BREAK
;
2143 infoPtr
->iGrabbedBand
= DPA_InsertPtr(
2144 infoPtr
->bands
, 0, hitBand
);
2146 else if(yOff
> REBAR_GetBand(infoPtr
, infoPtr
->uNumBands
- 1)->rcBand
.bottom
)
2148 /* Place the band below the current bottom row */
2149 if(iHitBand
== infoPtr
->uNumBands
-1 && hitBand
->fStyle
&RBBS_BREAK
)
2151 DPA_DeletePtr(infoPtr
->bands
, iHitBand
);
2152 hitBand
->fStyle
|= RBBS_BREAK
;
2153 infoPtr
->iGrabbedBand
= DPA_InsertPtr(
2154 infoPtr
->bands
, infoPtr
->uNumBands
- 1, hitBand
);
2158 /* Place the band in the prexisting row the mouse is hovering over */
2159 iRowBegin
= first_visible(infoPtr
);
2160 while(iRowBegin
< infoPtr
->uNumBands
)
2162 iNextRowBegin
= get_row_end_for_band(infoPtr
, iRowBegin
);
2163 rowBeginBand
= REBAR_GetBand(infoPtr
, iRowBegin
);
2164 if(rowBeginBand
->rcBand
.bottom
> yOff
)
2166 REBAR_MoveBandToRowOffset(
2167 infoPtr
, iHitBand
, iRowBegin
, iNextRowBegin
,
2168 ((infoPtr
->dwStyle
& CCS_VERT
) ? ptsmove
->y
: ptsmove
->x
)
2169 - REBAR_PRE_GRIPPER
- infoPtr
->ihitoffset
, FALSE
);
2173 iRowBegin
= iNextRowBegin
;
2177 REBAR_Layout(infoPtr
);
2181 /* << REBAR_BeginDrag >> */
2185 REBAR_DeleteBand (REBAR_INFO
*infoPtr
, WPARAM wParam
)
2187 UINT uBand
= (UINT
)wParam
;
2190 if (uBand
>= infoPtr
->uNumBands
)
2193 TRACE("deleting band %u!\n", uBand
);
2194 lpBand
= REBAR_GetBand(infoPtr
, uBand
);
2195 REBAR_Notify_NMREBAR (infoPtr
, uBand
, RBN_DELETINGBAND
);
2196 /* TODO: a return of 1 should probably cancel the deletion */
2198 if (lpBand
->hwndChild
)
2199 ShowWindow(lpBand
->hwndChild
, SW_HIDE
);
2200 Free(lpBand
->lpText
);
2203 infoPtr
->uNumBands
--;
2204 DPA_DeletePtr(infoPtr
->bands
, uBand
);
2206 REBAR_Notify_NMREBAR (infoPtr
, -1, RBN_DELETEDBAND
);
2208 /* if only 1 band left the re-validate to possible eliminate gripper */
2209 if (infoPtr
->uNumBands
== 1)
2210 REBAR_ValidateBand (infoPtr
, REBAR_GetBand(infoPtr
, 0));
2212 REBAR_Layout(infoPtr
);
2218 /* << REBAR_DragMove >> */
2219 /* << REBAR_EndDrag >> */
2223 REBAR_GetBandBorders (const REBAR_INFO
*infoPtr
, UINT uBand
, RECT
*lpRect
)
2229 if (uBand
>= infoPtr
->uNumBands
)
2232 lpBand
= REBAR_GetBand(infoPtr
, uBand
);
2234 /* FIXME - the following values were determined by experimentation */
2235 /* with the REBAR Control Spy. I have guesses as to what the 4 and */
2236 /* 1 are, but I am not sure. There doesn't seem to be any actual */
2237 /* difference in size of the control area with and without the */
2239 if (infoPtr
->dwStyle
& RBS_BANDBORDERS
) {
2240 if (infoPtr
->dwStyle
& CCS_VERT
) {
2242 lpRect
->top
= lpBand
->cxHeader
+ 4;
2247 lpRect
->left
= lpBand
->cxHeader
+ 4;
2254 lpRect
->left
= lpBand
->cxHeader
;
2260 static inline LRESULT
2261 REBAR_GetBandCount (const REBAR_INFO
*infoPtr
)
2263 TRACE("band count %u!\n", infoPtr
->uNumBands
);
2265 return infoPtr
->uNumBands
;
2270 REBAR_GetBandInfoT(const REBAR_INFO
*infoPtr
, UINT uIndex
, LPREBARBANDINFOW lprbbi
, BOOL bUnicode
)
2274 if (!lprbbi
|| lprbbi
->cbSize
< REBARBANDINFOA_V3_SIZE
)
2277 if (uIndex
>= infoPtr
->uNumBands
)
2280 TRACE("index %u (bUnicode=%d)\n", uIndex
, bUnicode
);
2282 /* copy band information */
2283 lpBand
= REBAR_GetBand(infoPtr
, uIndex
);
2285 if (lprbbi
->fMask
& RBBIM_STYLE
)
2286 lprbbi
->fStyle
= lpBand
->fStyle
;
2288 if (lprbbi
->fMask
& RBBIM_COLORS
) {
2289 lprbbi
->clrFore
= lpBand
->clrFore
;
2290 lprbbi
->clrBack
= lpBand
->clrBack
;
2291 if (lprbbi
->clrBack
== CLR_DEFAULT
)
2292 lprbbi
->clrBack
= infoPtr
->clrBtnFace
;
2295 if (lprbbi
->fMask
& RBBIM_TEXT
) {
2297 Str_GetPtrW(lpBand
->lpText
, lprbbi
->lpText
, lprbbi
->cch
);
2299 Str_GetPtrWtoA(lpBand
->lpText
, (LPSTR
)lprbbi
->lpText
, lprbbi
->cch
);
2302 if (lprbbi
->fMask
& RBBIM_IMAGE
)
2303 lprbbi
->iImage
= lpBand
->iImage
;
2305 if (lprbbi
->fMask
& RBBIM_CHILD
)
2306 lprbbi
->hwndChild
= lpBand
->hwndChild
;
2308 if (lprbbi
->fMask
& RBBIM_CHILDSIZE
) {
2309 lprbbi
->cxMinChild
= lpBand
->cxMinChild
;
2310 lprbbi
->cyMinChild
= lpBand
->cyMinChild
;
2311 /* to make tests pass we follow Windows behaviour and allow to read these fields only
2312 * for RBBS_VARIABLEHEIGHTS bands */
2313 if (lprbbi
->cbSize
>= REBARBANDINFOW_V6_SIZE
&& (lpBand
->fStyle
& RBBS_VARIABLEHEIGHT
)) {
2314 lprbbi
->cyChild
= lpBand
->cyChild
;
2315 lprbbi
->cyMaxChild
= lpBand
->cyMaxChild
;
2316 lprbbi
->cyIntegral
= lpBand
->cyIntegral
;
2320 if (lprbbi
->fMask
& RBBIM_SIZE
)
2321 lprbbi
->cx
= lpBand
->cx
;
2323 if (lprbbi
->fMask
& RBBIM_BACKGROUND
)
2324 lprbbi
->hbmBack
= lpBand
->hbmBack
;
2326 if (lprbbi
->fMask
& RBBIM_ID
)
2327 lprbbi
->wID
= lpBand
->wID
;
2329 /* check for additional data */
2330 if (lprbbi
->cbSize
>= REBARBANDINFOW_V6_SIZE
) {
2331 if (lprbbi
->fMask
& RBBIM_IDEALSIZE
)
2332 lprbbi
->cxIdeal
= lpBand
->cxIdeal
;
2334 if (lprbbi
->fMask
& RBBIM_LPARAM
)
2335 lprbbi
->lParam
= lpBand
->lParam
;
2337 if (lprbbi
->fMask
& RBBIM_HEADERSIZE
)
2338 lprbbi
->cxHeader
= lpBand
->cxHeader
;
2341 REBAR_DumpBandInfo(lprbbi
);
2348 REBAR_GetBarHeight (const REBAR_INFO
*infoPtr
)
2352 nHeight
= infoPtr
->calcSize
.cy
;
2354 TRACE("height = %d\n", nHeight
);
2361 REBAR_GetBarInfo (const REBAR_INFO
*infoPtr
, LPREBARINFO lpInfo
)
2363 if (!lpInfo
|| lpInfo
->cbSize
< sizeof (REBARINFO
))
2366 TRACE("getting bar info!\n");
2368 if (infoPtr
->himl
) {
2369 lpInfo
->himl
= infoPtr
->himl
;
2370 lpInfo
->fMask
|= RBIM_IMAGELIST
;
2377 static inline LRESULT
2378 REBAR_GetBkColor (const REBAR_INFO
*infoPtr
)
2380 COLORREF clr
= infoPtr
->clrBk
;
2382 if (clr
== CLR_DEFAULT
)
2383 clr
= infoPtr
->clrBtnFace
;
2385 TRACE("background color 0x%06x!\n", clr
);
2391 /* << REBAR_GetColorScheme >> */
2392 /* << REBAR_GetDropTarget >> */
2396 REBAR_GetPalette (const REBAR_INFO
*infoPtr
)
2398 FIXME("empty stub!\n");
2405 REBAR_GetRect (const REBAR_INFO
*infoPtr
, INT iBand
, RECT
*lprc
)
2409 if (iBand
< 0 || iBand
>= infoPtr
->uNumBands
)
2414 lpBand
= REBAR_GetBand(infoPtr
, iBand
);
2415 /* For CCS_VERT the coordinates will be swapped - like on Windows */
2416 CopyRect (lprc
, &lpBand
->rcBand
);
2418 TRACE("band %d, (%s)\n", iBand
, wine_dbgstr_rect(lprc
));
2424 static inline LRESULT
2425 REBAR_GetRowCount (const REBAR_INFO
*infoPtr
)
2427 TRACE("%u\n", infoPtr
->uNumRows
);
2429 return infoPtr
->uNumRows
;
2434 REBAR_GetRowHeight (const REBAR_INFO
*infoPtr
, INT iRow
)
2440 for (i
=0; i
<infoPtr
->uNumBands
; i
++) {
2441 lpBand
= REBAR_GetBand(infoPtr
, i
);
2442 if (HIDDENBAND(lpBand
)) continue;
2443 if (lpBand
->iRow
!= iRow
) continue;
2444 j
= lpBand
->rcBand
.bottom
- lpBand
->rcBand
.top
;
2445 if (j
> ret
) ret
= j
;
2448 TRACE("row %d, height %d\n", iRow
, ret
);
2454 static inline LRESULT
2455 REBAR_GetTextColor (const REBAR_INFO
*infoPtr
)
2457 TRACE("text color 0x%06x!\n", infoPtr
->clrText
);
2459 return infoPtr
->clrText
;
2463 static inline LRESULT
2464 REBAR_GetToolTips (const REBAR_INFO
*infoPtr
)
2466 return (LRESULT
)infoPtr
->hwndToolTip
;
2470 static inline LRESULT
2471 REBAR_GetUnicodeFormat (const REBAR_INFO
*infoPtr
)
2473 TRACE("%s hwnd=%p\n",
2474 infoPtr
->bUnicode
? "TRUE" : "FALSE", infoPtr
->hwndSelf
);
2476 return infoPtr
->bUnicode
;
2480 static inline LRESULT
2481 REBAR_GetVersion (const REBAR_INFO
*infoPtr
)
2483 TRACE("version %d\n", infoPtr
->iVersion
);
2484 return infoPtr
->iVersion
;
2489 REBAR_HitTest (const REBAR_INFO
*infoPtr
, LPRBHITTESTINFO lprbht
)
2494 REBAR_InternalHitTest (infoPtr
, &lprbht
->pt
, &lprbht
->flags
, &lprbht
->iBand
);
2496 return lprbht
->iBand
;
2501 REBAR_IdToIndex (const REBAR_INFO
*infoPtr
, UINT uId
)
2505 if (infoPtr
->uNumBands
< 1)
2508 for (i
= 0; i
< infoPtr
->uNumBands
; i
++) {
2509 if (REBAR_GetBand(infoPtr
, i
)->wID
== uId
) {
2510 TRACE("id %u is band %u found!\n", uId
, i
);
2515 TRACE("id %u is not found\n", uId
);
2521 REBAR_InsertBandT(REBAR_INFO
*infoPtr
, INT iIndex
, const REBARBANDINFOW
*lprbbi
, BOOL bUnicode
)
2525 if (!lprbbi
|| lprbbi
->cbSize
< REBARBANDINFOA_V3_SIZE
)
2528 /* trace the index as signed to see the -1 */
2529 TRACE("insert band at %d (bUnicode=%d)!\n", iIndex
, bUnicode
);
2530 REBAR_DumpBandInfo(lprbbi
);
2532 if (!(lpBand
= Alloc(sizeof(REBAR_BAND
)))) return FALSE
;
2533 if ((iIndex
== -1) || (iIndex
> infoPtr
->uNumBands
))
2534 iIndex
= infoPtr
->uNumBands
;
2535 if (DPA_InsertPtr(infoPtr
->bands
, iIndex
, lpBand
) == -1)
2540 infoPtr
->uNumBands
++;
2542 TRACE("index %d!\n", iIndex
);
2544 /* initialize band */
2545 memset(lpBand
, 0, sizeof(*lpBand
));
2546 lpBand
->clrFore
= infoPtr
->clrText
;
2547 lpBand
->clrBack
= infoPtr
->clrBk
;
2548 lpBand
->iImage
= -1;
2550 REBAR_CommonSetupBand(infoPtr
->hwndSelf
, lprbbi
, lpBand
);
2552 /* Make sure the defaults for these are correct */
2553 if (lprbbi
->cbSize
< REBARBANDINFOA_V6_SIZE
|| !(lpBand
->fStyle
& RBBS_VARIABLEHEIGHT
)) {
2554 lpBand
->cyChild
= lpBand
->cyMinChild
;
2555 lpBand
->cyMaxChild
= 0x7fffffff;
2556 lpBand
->cyIntegral
= 0;
2559 if ((lprbbi
->fMask
& RBBIM_TEXT
) && (lprbbi
->lpText
)) {
2561 Str_SetPtrW(&lpBand
->lpText
, lprbbi
->lpText
);
2563 Str_SetPtrAtoW(&lpBand
->lpText
, (LPSTR
)lprbbi
->lpText
);
2566 REBAR_ValidateBand (infoPtr
, lpBand
);
2567 /* On insert of second band, revalidate band 1 to possible add gripper */
2568 if (infoPtr
->uNumBands
== 2)
2569 REBAR_ValidateBand (infoPtr
, REBAR_GetBand(infoPtr
, 0));
2571 REBAR_DumpBand (infoPtr
);
2573 REBAR_Layout(infoPtr
);
2574 InvalidateRect(infoPtr
->hwndSelf
, NULL
, TRUE
);
2581 REBAR_MaximizeBand (const REBAR_INFO
*infoPtr
, INT iBand
, LPARAM lParam
)
2584 int iRowBegin
, iRowEnd
;
2585 int cxDesired
, extra
, extraOrig
;
2589 if (infoPtr
->uNumBands
== 0 || iBand
< 0 || iBand
>= infoPtr
->uNumBands
) {
2591 ERR("Illegal MaximizeBand, requested=%d, current band count=%d\n",
2592 iBand
, infoPtr
->uNumBands
);
2596 lpBand
= REBAR_GetBand(infoPtr
, iBand
);
2598 if (lpBand
->fStyle
& RBBS_HIDDEN
)
2600 /* Windows is buggy and creates a hole */
2601 WARN("Ignoring maximize request on a hidden band (%d)\n", iBand
);
2605 cxIdealBand
= lpBand
->cxIdeal
+ lpBand
->cxHeader
+ REBAR_POST_CHILD
;
2606 if (lParam
&& (lpBand
->cxEffective
< cxIdealBand
))
2607 cxDesired
= cxIdealBand
;
2609 cxDesired
= infoPtr
->calcSize
.cx
;
2611 iRowBegin
= get_row_begin_for_band(infoPtr
, iBand
);
2612 iRowEnd
= get_row_end_for_band(infoPtr
, iBand
);
2613 extraOrig
= extra
= cxDesired
- lpBand
->cxEffective
;
2615 extra
= REBAR_ShrinkBandsRTL(infoPtr
, iRowBegin
, iBand
, extra
, TRUE
);
2617 extra
= REBAR_ShrinkBandsLTR(infoPtr
, next_visible(infoPtr
, iBand
), iRowEnd
, extra
, TRUE
);
2618 lpBand
->cxEffective
+= extraOrig
- extra
;
2619 lpBand
->cx
= lpBand
->cxEffective
;
2620 TRACE("(%d, %ld): Wanted size %d, obtained %d (shrink %d, %d)\n", iBand
, lParam
, cxDesired
, lpBand
->cx
, extraOrig
, extra
);
2621 REBAR_SetRowRectsX(infoPtr
, iRowBegin
, iRowEnd
);
2623 if (infoPtr
->dwStyle
& CCS_VERT
)
2624 REBAR_CalcVertBand(infoPtr
, iRowBegin
, iRowEnd
);
2626 REBAR_CalcHorzBand(infoPtr
, iRowBegin
, iRowEnd
);
2627 REBAR_MoveChildWindows(infoPtr
, iRowBegin
, iRowEnd
);
2634 REBAR_MinimizeBand (const REBAR_INFO
*infoPtr
, INT iBand
)
2637 int iPrev
, iRowBegin
, iRowEnd
;
2639 /* A "minimize" band is equivalent to "dragging" the gripper
2640 * of than band to the right till the band is only the size
2645 if (infoPtr
->uNumBands
== 0 || iBand
< 0 || iBand
>= infoPtr
->uNumBands
) {
2647 ERR("Illegal MinimizeBand, requested=%d, current band count=%d\n",
2648 iBand
, infoPtr
->uNumBands
);
2652 /* compute amount of movement and validate */
2653 lpBand
= REBAR_GetBand(infoPtr
, iBand
);
2655 if (lpBand
->fStyle
& RBBS_HIDDEN
)
2657 /* Windows is buggy and creates a hole/overlap */
2658 WARN("Ignoring minimize request on a hidden band (%d)\n", iBand
);
2662 iPrev
= prev_visible(infoPtr
, iBand
);
2663 /* if first band in row */
2664 if (iPrev
< 0 || REBAR_GetBand(infoPtr
, iPrev
)->iRow
!= lpBand
->iRow
) {
2665 int iNext
= next_visible(infoPtr
, iBand
);
2666 if (iNext
< infoPtr
->uNumBands
&& REBAR_GetBand(infoPtr
, iNext
)->iRow
== lpBand
->iRow
) {
2667 TRACE("(%d): Minimizing the first band in row is by maximizing the second\n", iBand
);
2668 REBAR_MaximizeBand(infoPtr
, iNext
, FALSE
);
2671 TRACE("(%d): Only one band in row - nothing to do\n", iBand
);
2675 REBAR_GetBand(infoPtr
, iPrev
)->cxEffective
+= lpBand
->cxEffective
- lpBand
->cxMinBand
;
2676 REBAR_GetBand(infoPtr
, iPrev
)->cx
= REBAR_GetBand(infoPtr
, iPrev
)->cxEffective
;
2677 lpBand
->cx
= lpBand
->cxEffective
= lpBand
->cxMinBand
;
2679 iRowBegin
= get_row_begin_for_band(infoPtr
, iBand
);
2680 iRowEnd
= get_row_end_for_band(infoPtr
, iBand
);
2681 REBAR_SetRowRectsX(infoPtr
, iRowBegin
, iRowEnd
);
2683 if (infoPtr
->dwStyle
& CCS_VERT
)
2684 REBAR_CalcVertBand(infoPtr
, iRowBegin
, iRowEnd
);
2686 REBAR_CalcHorzBand(infoPtr
, iRowBegin
, iRowEnd
);
2687 REBAR_MoveChildWindows(infoPtr
, iRowBegin
, iRowEnd
);
2693 REBAR_MoveBand (REBAR_INFO
*infoPtr
, INT iFrom
, INT iTo
)
2698 if ((infoPtr
->uNumBands
== 0) ||
2699 (iFrom
< 0) || iFrom
>= infoPtr
->uNumBands
||
2700 (iTo
< 0) || iTo
>= infoPtr
->uNumBands
) {
2702 ERR("Illegal MoveBand, from=%d, to=%d, current band count=%d\n",
2703 iFrom
, iTo
, infoPtr
->uNumBands
);
2707 lpBand
= REBAR_GetBand(infoPtr
, iFrom
);
2708 DPA_DeletePtr(infoPtr
->bands
, iFrom
);
2709 DPA_InsertPtr(infoPtr
->bands
, iTo
, lpBand
);
2711 TRACE("moved band %d to index %d\n", iFrom
, iTo
);
2712 REBAR_DumpBand (infoPtr
);
2714 /* **************************************************** */
2716 /* We do not do a REBAR_Layout here because the native */
2717 /* control does not do that. The actual layout and */
2718 /* repaint is done by the *next* real action, ex.: */
2719 /* RB_INSERTBAND, RB_DELETEBAND, RB_SIZETORECT, etc. */
2721 /* **************************************************** */
2727 /* return TRUE if two strings are different */
2729 REBAR_strdifW( LPCWSTR a
, LPCWSTR b
)
2731 return ( (a
&& !b
) || (b
&& !a
) || (a
&& b
&& lstrcmpW(a
, b
) ) );
2735 REBAR_SetBandInfoT(REBAR_INFO
*infoPtr
, INT iBand
, const REBARBANDINFOW
*lprbbi
, BOOL bUnicode
)
2740 if (!lprbbi
|| lprbbi
->cbSize
< REBARBANDINFOA_V3_SIZE
)
2743 if (iBand
>= infoPtr
->uNumBands
)
2746 TRACE("index %d\n", iBand
);
2747 REBAR_DumpBandInfo (lprbbi
);
2749 /* set band information */
2750 lpBand
= REBAR_GetBand(infoPtr
, iBand
);
2752 uChanged
= REBAR_CommonSetupBand (infoPtr
->hwndSelf
, lprbbi
, lpBand
);
2753 if (lprbbi
->fMask
& RBBIM_TEXT
) {
2756 Str_SetPtrW(&wstr
, lprbbi
->lpText
);
2758 Str_SetPtrAtoW(&wstr
, (LPSTR
)lprbbi
->lpText
);
2760 if (REBAR_strdifW(wstr
, lpBand
->lpText
)) {
2761 Free(lpBand
->lpText
);
2762 lpBand
->lpText
= wstr
;
2763 uChanged
|= RBBIM_TEXT
;
2769 REBAR_ValidateBand (infoPtr
, lpBand
);
2771 REBAR_DumpBand (infoPtr
);
2773 if (uChanged
& (RBBIM_CHILDSIZE
| RBBIM_SIZE
| RBBIM_STYLE
| RBBIM_IMAGE
)) {
2774 REBAR_Layout(infoPtr
);
2775 InvalidateRect(infoPtr
->hwndSelf
, NULL
, TRUE
);
2783 REBAR_SetBarInfo (REBAR_INFO
*infoPtr
, const REBARINFO
*lpInfo
)
2788 if (!lpInfo
|| lpInfo
->cbSize
< sizeof (REBARINFO
))
2791 TRACE("setting bar info!\n");
2793 if (lpInfo
->fMask
& RBIM_IMAGELIST
) {
2794 infoPtr
->himl
= lpInfo
->himl
;
2795 if (infoPtr
->himl
) {
2797 ImageList_GetIconSize (infoPtr
->himl
, &cx
, &cy
);
2798 infoPtr
->imageSize
.cx
= cx
;
2799 infoPtr
->imageSize
.cy
= cy
;
2802 infoPtr
->imageSize
.cx
= 0;
2803 infoPtr
->imageSize
.cy
= 0;
2805 TRACE("new image cx=%d, cy=%d\n", infoPtr
->imageSize
.cx
,
2806 infoPtr
->imageSize
.cy
);
2809 /* revalidate all bands to reset flags for images in headers of bands */
2810 for (i
=0; i
<infoPtr
->uNumBands
; i
++) {
2811 lpBand
= REBAR_GetBand(infoPtr
, i
);
2812 REBAR_ValidateBand (infoPtr
, lpBand
);
2820 REBAR_SetBkColor (REBAR_INFO
*infoPtr
, COLORREF clr
)
2824 clrTemp
= infoPtr
->clrBk
;
2825 infoPtr
->clrBk
= clr
;
2827 TRACE("background color 0x%06x!\n", infoPtr
->clrBk
);
2833 /* << REBAR_SetColorScheme >> */
2834 /* << REBAR_SetPalette >> */
2838 REBAR_SetParent (REBAR_INFO
*infoPtr
, HWND parent
)
2840 HWND hwndTemp
= infoPtr
->hwndNotify
;
2842 infoPtr
->hwndNotify
= parent
;
2844 return (LRESULT
)hwndTemp
;
2849 REBAR_SetTextColor (REBAR_INFO
*infoPtr
, COLORREF clr
)
2853 clrTemp
= infoPtr
->clrText
;
2854 infoPtr
->clrText
= clr
;
2856 TRACE("text color 0x%06x!\n", infoPtr
->clrText
);
2862 /* << REBAR_SetTooltips >> */
2865 static inline LRESULT
2866 REBAR_SetUnicodeFormat (REBAR_INFO
*infoPtr
, BOOL unicode
)
2868 BOOL bTemp
= infoPtr
->bUnicode
;
2870 TRACE("to %s hwnd=%p, was %s\n",
2871 unicode
? "TRUE" : "FALSE", infoPtr
->hwndSelf
,
2872 (bTemp
) ? "TRUE" : "FALSE");
2874 infoPtr
->bUnicode
= unicode
;
2881 REBAR_SetVersion (REBAR_INFO
*infoPtr
, INT iVersion
)
2883 INT iOldVersion
= infoPtr
->iVersion
;
2885 if (iVersion
> COMCTL32_VERSION
)
2888 infoPtr
->iVersion
= iVersion
;
2890 TRACE("new version %d\n", iVersion
);
2897 REBAR_ShowBand (REBAR_INFO
*infoPtr
, INT iBand
, BOOL show
)
2901 if (iBand
< 0 || iBand
>= infoPtr
->uNumBands
)
2904 lpBand
= REBAR_GetBand(infoPtr
, iBand
);
2907 TRACE("show band %d\n", iBand
);
2908 lpBand
->fStyle
= lpBand
->fStyle
& ~RBBS_HIDDEN
;
2909 if (IsWindow (lpBand
->hwndChild
))
2910 ShowWindow (lpBand
->hwndChild
, SW_SHOW
);
2913 TRACE("hide band %d\n", iBand
);
2914 lpBand
->fStyle
= lpBand
->fStyle
| RBBS_HIDDEN
;
2915 if (IsWindow (lpBand
->hwndChild
))
2916 ShowWindow (lpBand
->hwndChild
, SW_HIDE
);
2919 REBAR_Layout(infoPtr
);
2920 InvalidateRect(infoPtr
->hwndSelf
, NULL
, TRUE
);
2927 REBAR_SizeToRect (REBAR_INFO
*infoPtr
, const RECT
*lpRect
)
2929 if (!lpRect
) return FALSE
;
2931 TRACE("[%s]\n", wine_dbgstr_rect(lpRect
));
2932 REBAR_SizeToHeight(infoPtr
, get_rect_cy(infoPtr
, lpRect
));
2939 REBAR_Create (REBAR_INFO
*infoPtr
, LPCREATESTRUCTW cs
)
2943 if (TRACE_ON(rebar
)) {
2944 GetWindowRect(infoPtr
->hwndSelf
, &wnrc1
);
2945 GetClientRect(infoPtr
->hwndSelf
, &clrc1
);
2946 TRACE("window=(%s) client=(%s) cs=(%d,%d %dx%d)\n",
2947 wine_dbgstr_rect(&wnrc1
), wine_dbgstr_rect(&clrc1
),
2948 cs
->x
, cs
->y
, cs
->cx
, cs
->cy
);
2951 TRACE("created!\n");
2953 if (OpenThemeData (infoPtr
->hwndSelf
, themeClass
))
2955 /* native seems to clear WS_BORDER when themed */
2956 infoPtr
->dwStyle
&= ~WS_BORDER
;
2964 REBAR_Destroy (REBAR_INFO
*infoPtr
)
2969 /* clean up each band */
2970 for (i
= 0; i
< infoPtr
->uNumBands
; i
++) {
2971 lpBand
= REBAR_GetBand(infoPtr
, i
);
2973 /* delete text strings */
2974 Free (lpBand
->lpText
);
2975 lpBand
->lpText
= NULL
;
2976 /* destroy child window */
2977 DestroyWindow (lpBand
->hwndChild
);
2981 /* free band array */
2982 DPA_Destroy (infoPtr
->bands
);
2983 infoPtr
->bands
= NULL
;
2985 DestroyCursor (infoPtr
->hcurArrow
);
2986 DestroyCursor (infoPtr
->hcurHorz
);
2987 DestroyCursor (infoPtr
->hcurVert
);
2988 DestroyCursor (infoPtr
->hcurDrag
);
2989 if (infoPtr
->hDefaultFont
) DeleteObject (infoPtr
->hDefaultFont
);
2990 SetWindowLongPtrW (infoPtr
->hwndSelf
, 0, 0);
2992 CloseThemeData (GetWindowTheme (infoPtr
->hwndSelf
));
2994 /* free rebar info data */
2996 TRACE("destroyed!\n");
3001 REBAR_GetFont (const REBAR_INFO
*infoPtr
)
3003 return (LRESULT
)infoPtr
->hFont
;
3007 REBAR_PushChevron(const REBAR_INFO
*infoPtr
, UINT uBand
, LPARAM lParam
)
3009 if (uBand
< infoPtr
->uNumBands
)
3011 NMREBARCHEVRON nmrbc
;
3012 REBAR_BAND
*lpBand
= REBAR_GetBand(infoPtr
, uBand
);
3014 TRACE("Pressed chevron on band %u\n", uBand
);
3016 /* redraw chevron in pushed state */
3017 lpBand
->fDraw
|= DRAW_CHEVRONPUSHED
;
3018 RedrawWindow(infoPtr
->hwndSelf
, &lpBand
->rcChevron
,0,
3019 RDW_ERASE
|RDW_INVALIDATE
|RDW_UPDATENOW
);
3021 /* notify app so it can display a popup menu or whatever */
3022 nmrbc
.uBand
= uBand
;
3023 nmrbc
.wID
= lpBand
->wID
;
3024 nmrbc
.lParam
= lpBand
->lParam
;
3025 nmrbc
.rc
= lpBand
->rcChevron
;
3026 nmrbc
.lParamNM
= lParam
;
3027 REBAR_Notify((NMHDR
*)&nmrbc
, infoPtr
, RBN_CHEVRONPUSHED
);
3029 /* redraw chevron in previous state */
3030 lpBand
->fDraw
&= ~DRAW_CHEVRONPUSHED
;
3031 InvalidateRect(infoPtr
->hwndSelf
, &lpBand
->rcChevron
, TRUE
);
3039 REBAR_LButtonDown (REBAR_INFO
*infoPtr
, LPARAM lParam
)
3044 ptMouseDown
.x
= (short)LOWORD(lParam
);
3045 ptMouseDown
.y
= (short)HIWORD(lParam
);
3047 REBAR_InternalHitTest(infoPtr
, &ptMouseDown
, &htFlags
, &iHitBand
);
3049 if (htFlags
== RBHT_CHEVRON
)
3051 REBAR_PushChevron(infoPtr
, iHitBand
, 0);
3053 else if (htFlags
== RBHT_GRABBER
|| htFlags
== RBHT_CAPTION
)
3057 TRACE("Starting drag\n");
3059 lpBand
= REBAR_GetBand(infoPtr
, iHitBand
);
3061 SetCapture (infoPtr
->hwndSelf
);
3062 infoPtr
->iGrabbedBand
= iHitBand
;
3064 /* save off the LOWORD and HIWORD of lParam as initial x,y */
3065 infoPtr
->dragStart
.x
= (short)LOWORD(lParam
);
3066 infoPtr
->dragStart
.y
= (short)HIWORD(lParam
);
3067 infoPtr
->dragNow
= infoPtr
->dragStart
;
3068 if (infoPtr
->dwStyle
& CCS_VERT
)
3069 infoPtr
->ihitoffset
= infoPtr
->dragStart
.y
- (lpBand
->rcBand
.left
+ REBAR_PRE_GRIPPER
);
3071 infoPtr
->ihitoffset
= infoPtr
->dragStart
.x
- (lpBand
->rcBand
.left
+ REBAR_PRE_GRIPPER
);
3077 REBAR_LButtonUp (REBAR_INFO
*infoPtr
)
3079 if (infoPtr
->iGrabbedBand
>= 0)
3084 infoPtr
->dragStart
.x
= 0;
3085 infoPtr
->dragStart
.y
= 0;
3086 infoPtr
->dragNow
= infoPtr
->dragStart
;
3090 if (infoPtr
->fStatus
& BEGIN_DRAG_ISSUED
) {
3091 REBAR_Notify(&layout
, infoPtr
, RBN_LAYOUTCHANGED
);
3092 REBAR_Notify_NMREBAR (infoPtr
, infoPtr
->iGrabbedBand
, RBN_ENDDRAG
);
3093 infoPtr
->fStatus
&= ~BEGIN_DRAG_ISSUED
;
3096 infoPtr
->iGrabbedBand
= -1;
3098 GetClientRect(infoPtr
->hwndSelf
, &rect
);
3099 InvalidateRect(infoPtr
->hwndSelf
, NULL
, TRUE
);
3106 REBAR_MouseLeave (REBAR_INFO
*infoPtr
)
3108 if (infoPtr
->ichevronhotBand
>= 0)
3110 REBAR_BAND
*lpChevronBand
= REBAR_GetBand(infoPtr
, infoPtr
->ichevronhotBand
);
3111 if (lpChevronBand
->fDraw
& DRAW_CHEVRONHOT
)
3113 lpChevronBand
->fDraw
&= ~DRAW_CHEVRONHOT
;
3114 InvalidateRect(infoPtr
->hwndSelf
, &lpChevronBand
->rcChevron
, TRUE
);
3117 infoPtr
->iOldBand
= -1;
3118 infoPtr
->ichevronhotBand
= -2;
3124 REBAR_MouseMove (REBAR_INFO
*infoPtr
, LPARAM lParam
)
3126 REBAR_BAND
*lpChevronBand
;
3129 ptMove
.x
= (short)LOWORD(lParam
);
3130 ptMove
.y
= (short)HIWORD(lParam
);
3132 /* if we are currently dragging a band */
3133 if (infoPtr
->iGrabbedBand
>= 0)
3136 int yPtMove
= (infoPtr
->dwStyle
& CCS_VERT
? ptMove
.x
: ptMove
.y
);
3138 if (GetCapture() != infoPtr
->hwndSelf
)
3139 ERR("We are dragging but haven't got capture?!?\n");
3141 band
= REBAR_GetBand(infoPtr
, infoPtr
->iGrabbedBand
);
3143 /* if mouse did not move much, exit */
3144 if ((abs(ptMove
.x
- infoPtr
->dragNow
.x
) <= mindragx
) &&
3145 (abs(ptMove
.y
- infoPtr
->dragNow
.y
) <= mindragy
)) return 0;
3147 /* on first significant mouse movement, issue notify */
3148 if (!(infoPtr
->fStatus
& BEGIN_DRAG_ISSUED
)) {
3149 if (REBAR_Notify_NMREBAR (infoPtr
, -1, RBN_BEGINDRAG
)) {
3150 /* Notify returned TRUE - abort drag */
3151 infoPtr
->dragStart
.x
= 0;
3152 infoPtr
->dragStart
.y
= 0;
3153 infoPtr
->dragNow
= infoPtr
->dragStart
;
3154 infoPtr
->iGrabbedBand
= -1;
3158 infoPtr
->fStatus
|= BEGIN_DRAG_ISSUED
;
3161 /* Test for valid drag case - must not be first band in row */
3162 if ((yPtMove
< band
->rcBand
.top
) ||
3163 (yPtMove
> band
->rcBand
.bottom
)) {
3164 REBAR_HandleUDDrag (infoPtr
, &ptMove
);
3167 REBAR_HandleLRDrag (infoPtr
, &ptMove
);
3174 TRACKMOUSEEVENT trackinfo
;
3176 REBAR_InternalHitTest(infoPtr
, &ptMove
, &htFlags
, &iHitBand
);
3178 if (infoPtr
->iOldBand
>= 0 && infoPtr
->iOldBand
== infoPtr
->ichevronhotBand
)
3180 lpChevronBand
= REBAR_GetBand(infoPtr
, infoPtr
->ichevronhotBand
);
3181 if (lpChevronBand
->fDraw
& DRAW_CHEVRONHOT
)
3183 lpChevronBand
->fDraw
&= ~DRAW_CHEVRONHOT
;
3184 InvalidateRect(infoPtr
->hwndSelf
, &lpChevronBand
->rcChevron
, TRUE
);
3186 infoPtr
->ichevronhotBand
= -2;
3189 if (htFlags
== RBHT_CHEVRON
)
3191 /* fill in the TRACKMOUSEEVENT struct */
3192 trackinfo
.cbSize
= sizeof(TRACKMOUSEEVENT
);
3193 trackinfo
.dwFlags
= TME_QUERY
;
3194 trackinfo
.hwndTrack
= infoPtr
->hwndSelf
;
3195 trackinfo
.dwHoverTime
= 0;
3197 /* call _TrackMouseEvent to see if we are currently tracking for this hwnd */
3198 _TrackMouseEvent(&trackinfo
);
3200 /* Make sure tracking is enabled so we receive a WM_MOUSELEAVE message */
3201 if(!(trackinfo
.dwFlags
& TME_LEAVE
))
3203 trackinfo
.dwFlags
= TME_LEAVE
; /* notify upon leaving */
3205 /* call TRACKMOUSEEVENT so we receive a WM_MOUSELEAVE message */
3206 /* and can properly deactivate the hot chevron */
3207 _TrackMouseEvent(&trackinfo
);
3210 lpChevronBand
= REBAR_GetBand(infoPtr
, iHitBand
);
3211 if (!(lpChevronBand
->fDraw
& DRAW_CHEVRONHOT
))
3213 lpChevronBand
->fDraw
|= DRAW_CHEVRONHOT
;
3214 InvalidateRect(infoPtr
->hwndSelf
, &lpChevronBand
->rcChevron
, TRUE
);
3215 infoPtr
->ichevronhotBand
= iHitBand
;
3218 infoPtr
->iOldBand
= iHitBand
;
3225 static inline LRESULT
3226 REBAR_NCCalcSize (const REBAR_INFO
*infoPtr
, RECT
*rect
)
3230 if (infoPtr
->dwStyle
& WS_BORDER
) {
3231 rect
->left
= min(rect
->left
+ GetSystemMetrics(SM_CXEDGE
), rect
->right
);
3232 rect
->right
= max(rect
->right
- GetSystemMetrics(SM_CXEDGE
), rect
->left
);
3233 rect
->top
= min(rect
->top
+ GetSystemMetrics(SM_CYEDGE
), rect
->bottom
);
3234 rect
->bottom
= max(rect
->bottom
- GetSystemMetrics(SM_CYEDGE
), rect
->top
);
3236 else if ((theme
= GetWindowTheme (infoPtr
->hwndSelf
)))
3238 /* FIXME: should use GetThemeInt */
3239 rect
->top
= min(rect
->top
+ 1, rect
->bottom
);
3241 TRACE("new client=(%s)\n", wine_dbgstr_rect(rect
));
3247 REBAR_NCCreate (HWND hwnd
, const CREATESTRUCTW
*cs
)
3249 REBAR_INFO
*infoPtr
= REBAR_GetInfoPtr (hwnd
);
3251 NONCLIENTMETRICSW ncm
;
3255 ERR("Strange info structure pointer *not* NULL\n");
3259 if (TRACE_ON(rebar
)) {
3260 GetWindowRect(hwnd
, &wnrc1
);
3261 GetClientRect(hwnd
, &clrc1
);
3262 TRACE("window=(%s) client=(%s) cs=(%d,%d %dx%d)\n",
3263 wine_dbgstr_rect(&wnrc1
), wine_dbgstr_rect(&clrc1
),
3264 cs
->x
, cs
->y
, cs
->cx
, cs
->cy
);
3267 /* allocate memory for info structure */
3268 infoPtr
= Alloc (sizeof(REBAR_INFO
));
3269 SetWindowLongPtrW (hwnd
, 0, (DWORD_PTR
)infoPtr
);
3271 /* initialize info structure - initial values are 0 */
3272 infoPtr
->clrBk
= CLR_NONE
;
3273 infoPtr
->clrText
= CLR_NONE
;
3274 infoPtr
->clrBtnText
= comctl32_color
.clrBtnText
;
3275 infoPtr
->clrBtnFace
= comctl32_color
.clrBtnFace
;
3276 infoPtr
->iOldBand
= -1;
3277 infoPtr
->ichevronhotBand
= -2;
3278 infoPtr
->iGrabbedBand
= -1;
3279 infoPtr
->hwndSelf
= hwnd
;
3280 infoPtr
->DoRedraw
= TRUE
;
3281 infoPtr
->hcurArrow
= LoadCursorW (0, (LPWSTR
)IDC_ARROW
);
3282 infoPtr
->hcurHorz
= LoadCursorW (0, (LPWSTR
)IDC_SIZEWE
);
3283 infoPtr
->hcurVert
= LoadCursorW (0, (LPWSTR
)IDC_SIZENS
);
3284 infoPtr
->hcurDrag
= LoadCursorW (0, (LPWSTR
)IDC_SIZE
);
3285 infoPtr
->fStatus
= 0;
3286 infoPtr
->hFont
= GetStockObject (SYSTEM_FONT
);
3287 infoPtr
->bands
= DPA_Create(8);
3289 /* issue WM_NOTIFYFORMAT to get unicode status of parent */
3290 REBAR_NotifyFormat(infoPtr
, NF_REQUERY
);
3292 /* Stow away the original style */
3293 infoPtr
->orgStyle
= cs
->style
;
3294 /* add necessary styles to the requested styles */
3295 infoPtr
->dwStyle
= cs
->style
| WS_VISIBLE
;
3296 if ((infoPtr
->dwStyle
& CCS_LAYOUT_MASK
) == 0)
3297 infoPtr
->dwStyle
|= CCS_TOP
;
3298 SetWindowLongW (hwnd
, GWL_STYLE
, infoPtr
->dwStyle
);
3300 /* get font handle for Caption Font */
3301 ncm
.cbSize
= sizeof(ncm
);
3302 SystemParametersInfoW (SPI_GETNONCLIENTMETRICS
, ncm
.cbSize
, &ncm
, 0);
3303 /* if the font is bold, set to normal */
3304 if (ncm
.lfCaptionFont
.lfWeight
> FW_NORMAL
) {
3305 ncm
.lfCaptionFont
.lfWeight
= FW_NORMAL
;
3307 tfont
= CreateFontIndirectW (&ncm
.lfCaptionFont
);
3309 infoPtr
->hFont
= infoPtr
->hDefaultFont
= tfont
;
3313 GetSysColor (numerous);
3314 GetSysColorBrush (numerous) (see WM_SYSCOLORCHANGE);
3315 *GetStockObject (SYSTEM_FONT);
3316 *SetWindowLong (hwnd, 0, info ptr);
3318 *SetWindowLong (hwnd, GWL_STYLE, style+0x10000001);
3319 WS_VISIBLE = 0x10000000;
3320 CCS_TOP = 0x00000001;
3321 *SystemParametersInfo (SPI_GETNONCLIENTMETRICS...);
3322 *CreateFontIndirect (lfCaptionFont from above);
3324 SelectObject (hdc, fontabove);
3325 GetTextMetrics (hdc, ); guessing is tmHeight
3326 SelectObject (hdc, oldfont);
3329 MapWindowPoints (0, parent, rectabove, 2);
3332 ClientToScreen (clientrect);
3333 SetWindowPos (hwnd, 0, 0, 0, 0, 0, SWP_NOZORDER);
3340 REBAR_NCHitTest (const REBAR_INFO
*infoPtr
, LPARAM lParam
)
3346 LRESULT ret
= HTCLIENT
;
3349 * Differences from doc at MSDN (as observed with version 4.71 of
3351 * 1. doc says nmmouse.pt is in screen coord, trace shows client coord.
3352 * 2. if band is not identified .dwItemSpec is 0xffffffff.
3353 * 3. native always seems to return HTCLIENT if notify return is 0.
3356 clpt
.x
= (short)LOWORD(lParam
);
3357 clpt
.y
= (short)HIWORD(lParam
);
3358 ScreenToClient (infoPtr
->hwndSelf
, &clpt
);
3359 REBAR_InternalHitTest (infoPtr
, &clpt
, &scrap
,
3360 (INT
*)&nmmouse
.dwItemSpec
);
3361 nmmouse
.dwItemData
= 0;
3363 nmmouse
.dwHitInfo
= 0;
3364 if ((i
= REBAR_Notify((NMHDR
*) &nmmouse
, infoPtr
, NM_NCHITTEST
))) {
3365 TRACE("notify changed return value from %ld to %d\n",
3369 TRACE("returning %ld, client point (%d,%d)\n", ret
, clpt
.x
, clpt
.y
);
3375 REBAR_NCPaint (const REBAR_INFO
*infoPtr
)
3381 if (infoPtr
->dwStyle
& WS_MINIMIZE
)
3382 return 0; /* Nothing to do */
3384 if (infoPtr
->dwStyle
& WS_BORDER
) {
3386 /* adjust rectangle and draw the necessary edge */
3387 if (!(hdc
= GetDCEx( infoPtr
->hwndSelf
, 0, DCX_USESTYLE
| DCX_WINDOW
)))
3389 GetWindowRect (infoPtr
->hwndSelf
, &rcWindow
);
3390 OffsetRect (&rcWindow
, -rcWindow
.left
, -rcWindow
.top
);
3391 TRACE("rect (%s)\n", wine_dbgstr_rect(&rcWindow
));
3392 DrawEdge (hdc
, &rcWindow
, EDGE_ETCHED
, BF_RECT
);
3393 ReleaseDC( infoPtr
->hwndSelf
, hdc
);
3395 else if ((theme
= GetWindowTheme (infoPtr
->hwndSelf
)))
3397 /* adjust rectangle and draw the necessary edge */
3398 if (!(hdc
= GetDCEx( infoPtr
->hwndSelf
, 0, DCX_USESTYLE
| DCX_WINDOW
)))
3400 GetWindowRect (infoPtr
->hwndSelf
, &rcWindow
);
3401 OffsetRect (&rcWindow
, -rcWindow
.left
, -rcWindow
.top
);
3402 TRACE("rect (%s)\n", wine_dbgstr_rect(&rcWindow
));
3403 DrawThemeEdge (theme
, hdc
, 0, 0, &rcWindow
, BDR_RAISEDINNER
, BF_TOP
, NULL
);
3404 ReleaseDC( infoPtr
->hwndSelf
, hdc
);
3412 REBAR_NotifyFormat (REBAR_INFO
*infoPtr
, LPARAM cmd
)
3416 if (cmd
== NF_REQUERY
) {
3417 i
= SendMessageW(REBAR_GetNotifyParent (infoPtr
),
3418 WM_NOTIFYFORMAT
, (WPARAM
)infoPtr
->hwndSelf
, NF_QUERY
);
3419 if ((i
!= NFR_ANSI
) && (i
!= NFR_UNICODE
)) {
3420 ERR("wrong response to WM_NOTIFYFORMAT (%d), assuming ANSI\n", i
);
3423 infoPtr
->bUnicode
= (i
== NFR_UNICODE
) ? 1 : 0;
3426 return (LRESULT
)((infoPtr
->bUnicode
) ? NFR_UNICODE
: NFR_ANSI
);
3431 REBAR_Paint (const REBAR_INFO
*infoPtr
, HDC hdc
)
3434 TRACE("painting\n");
3435 REBAR_Refresh (infoPtr
, hdc
);
3438 hdc
= BeginPaint (infoPtr
->hwndSelf
, &ps
);
3439 TRACE("painting (%s)\n", wine_dbgstr_rect(&ps
.rcPaint
));
3441 /* Erase area of paint if requested */
3442 REBAR_EraseBkGnd (infoPtr
, hdc
);
3444 REBAR_Refresh (infoPtr
, hdc
);
3445 EndPaint (infoPtr
->hwndSelf
, &ps
);
3453 REBAR_SetCursor (const REBAR_INFO
*infoPtr
, LPARAM lParam
)
3458 TRACE("code=0x%X id=0x%X\n", LOWORD(lParam
), HIWORD(lParam
));
3461 ScreenToClient (infoPtr
->hwndSelf
, &pt
);
3463 REBAR_InternalHitTest (infoPtr
, &pt
, &flags
, NULL
);
3465 if (flags
== RBHT_GRABBER
) {
3466 if ((infoPtr
->dwStyle
& CCS_VERT
) &&
3467 !(infoPtr
->dwStyle
& RBS_VERTICALGRIPPER
))
3468 SetCursor (infoPtr
->hcurVert
);
3470 SetCursor (infoPtr
->hcurHorz
);
3472 else if (flags
!= RBHT_CLIENT
)
3473 SetCursor (infoPtr
->hcurArrow
);
3480 REBAR_SetFont (REBAR_INFO
*infoPtr
, HFONT font
)
3485 infoPtr
->hFont
= font
;
3487 /* revalidate all bands to change sizes of text in headers of bands */
3488 for (i
=0; i
<infoPtr
->uNumBands
; i
++) {
3489 lpBand
= REBAR_GetBand(infoPtr
, i
);
3490 REBAR_ValidateBand (infoPtr
, lpBand
);
3493 REBAR_Layout(infoPtr
);
3498 /*****************************************************
3500 * Handles the WM_SETREDRAW message.
3503 * According to testing V4.71 of COMCTL32 returns the
3504 * *previous* status of the redraw flag (either 0 or -1)
3505 * instead of the MSDN documented value of 0 if handled
3507 *****************************************************/
3508 static inline LRESULT
3509 REBAR_SetRedraw (REBAR_INFO
*infoPtr
, BOOL redraw
)
3511 BOOL oldredraw
= infoPtr
->DoRedraw
;
3513 TRACE("set to %s, fStatus=%08x\n",
3514 (redraw
) ? "TRUE" : "FALSE", infoPtr
->fStatus
);
3515 infoPtr
->DoRedraw
= redraw
;
3517 if (infoPtr
->fStatus
& BAND_NEEDS_REDRAW
) {
3518 REBAR_MoveChildWindows (infoPtr
, 0, infoPtr
->uNumBands
);
3519 REBAR_ForceResize (infoPtr
);
3520 InvalidateRect (infoPtr
->hwndSelf
, NULL
, TRUE
);
3522 infoPtr
->fStatus
&= ~BAND_NEEDS_REDRAW
;
3524 return (oldredraw
) ? -1 : 0;
3529 REBAR_Size (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
3531 TRACE("wParam=%lx, lParam=%lx\n", wParam
, lParam
);
3533 /* avoid _Layout resize recursion (but it shouldn't be infinite and it seems Windows does recurse) */
3534 if (infoPtr
->fStatus
& SELF_RESIZE
) {
3535 infoPtr
->fStatus
&= ~SELF_RESIZE
;
3536 TRACE("SELF_RESIZE was set, reset, fStatus=%08x lparam=%08lx\n",
3537 infoPtr
->fStatus
, lParam
);
3541 if (infoPtr
->dwStyle
& RBS_AUTOSIZE
)
3542 REBAR_AutoSize(infoPtr
, TRUE
);
3544 REBAR_Layout(infoPtr
);
3551 REBAR_StyleChanged (REBAR_INFO
*infoPtr
, INT nType
, const STYLESTRUCT
*lpStyle
)
3553 TRACE("current style=%08x, styleOld=%08x, style being set to=%08x\n",
3554 infoPtr
->dwStyle
, lpStyle
->styleOld
, lpStyle
->styleNew
);
3555 if (nType
== GWL_STYLE
)
3557 infoPtr
->orgStyle
= infoPtr
->dwStyle
= lpStyle
->styleNew
;
3558 if (GetWindowTheme (infoPtr
->hwndSelf
))
3559 infoPtr
->dwStyle
&= ~WS_BORDER
;
3560 /* maybe it should be COMMON_STYLES like in toolbar */
3561 if ((lpStyle
->styleNew
^ lpStyle
->styleOld
) & CCS_VERT
)
3562 REBAR_Layout(infoPtr
);
3567 /* update theme after a WM_THEMECHANGED message */
3568 static LRESULT
theme_changed (REBAR_INFO
* infoPtr
)
3570 HTHEME theme
= GetWindowTheme (infoPtr
->hwndSelf
);
3571 CloseThemeData (theme
);
3572 theme
= OpenThemeData (infoPtr
->hwndSelf
, themeClass
);
3573 /* WS_BORDER disappears when theming is enabled and reappears when
3575 infoPtr
->dwStyle
&= ~WS_BORDER
;
3576 infoPtr
->dwStyle
|= theme
? 0 : (infoPtr
->orgStyle
& WS_BORDER
);
3581 REBAR_WindowPosChanged (const REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
3586 ret
= DefWindowProcW(infoPtr
->hwndSelf
, WM_WINDOWPOSCHANGED
,
3588 GetWindowRect(infoPtr
->hwndSelf
, &rc
);
3589 TRACE("hwnd %p new pos (%s)\n", infoPtr
->hwndSelf
, wine_dbgstr_rect(&rc
));
3594 static LRESULT WINAPI
3595 REBAR_WindowProc (HWND hwnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
)
3597 REBAR_INFO
*infoPtr
= REBAR_GetInfoPtr (hwnd
);
3599 TRACE("hwnd=%p msg=%x wparam=%lx lparam=%lx\n",
3600 hwnd
, uMsg
, wParam
, lParam
);
3601 if (!infoPtr
&& (uMsg
!= WM_NCCREATE
))
3602 return DefWindowProcW (hwnd
, uMsg
, wParam
, lParam
);
3605 /* case RB_BEGINDRAG: */
3608 return REBAR_DeleteBand (infoPtr
, wParam
);
3610 /* case RB_DRAGMOVE: */
3611 /* case RB_ENDDRAG: */
3613 case RB_GETBANDBORDERS
:
3614 return REBAR_GetBandBorders (infoPtr
, wParam
, (LPRECT
)lParam
);
3616 case RB_GETBANDCOUNT
:
3617 return REBAR_GetBandCount (infoPtr
);
3619 case RB_GETBANDINFO_OLD
:
3620 case RB_GETBANDINFOA
:
3621 case RB_GETBANDINFOW
:
3622 return REBAR_GetBandInfoT(infoPtr
, wParam
, (LPREBARBANDINFOW
)lParam
,
3623 uMsg
== RB_GETBANDINFOW
);
3624 case RB_GETBARHEIGHT
:
3625 return REBAR_GetBarHeight (infoPtr
);
3628 return REBAR_GetBarInfo (infoPtr
, (LPREBARINFO
)lParam
);
3631 return REBAR_GetBkColor (infoPtr
);
3633 /* case RB_GETCOLORSCHEME: */
3634 /* case RB_GETDROPTARGET: */
3637 return REBAR_GetPalette (infoPtr
);
3640 return REBAR_GetRect (infoPtr
, wParam
, (LPRECT
)lParam
);
3642 case RB_GETROWCOUNT
:
3643 return REBAR_GetRowCount (infoPtr
);
3645 case RB_GETROWHEIGHT
:
3646 return REBAR_GetRowHeight (infoPtr
, wParam
);
3648 case RB_GETTEXTCOLOR
:
3649 return REBAR_GetTextColor (infoPtr
);
3651 case RB_GETTOOLTIPS
:
3652 return REBAR_GetToolTips (infoPtr
);
3654 case RB_GETUNICODEFORMAT
:
3655 return REBAR_GetUnicodeFormat (infoPtr
);
3657 case CCM_GETVERSION
:
3658 return REBAR_GetVersion (infoPtr
);
3661 return REBAR_HitTest (infoPtr
, (LPRBHITTESTINFO
)lParam
);
3664 return REBAR_IdToIndex (infoPtr
, wParam
);
3666 case RB_INSERTBANDA
:
3667 case RB_INSERTBANDW
:
3668 return REBAR_InsertBandT(infoPtr
, wParam
, (LPREBARBANDINFOW
)lParam
,
3669 uMsg
== RB_INSERTBANDW
);
3670 case RB_MAXIMIZEBAND
:
3671 return REBAR_MaximizeBand (infoPtr
, wParam
, lParam
);
3673 case RB_MINIMIZEBAND
:
3674 return REBAR_MinimizeBand (infoPtr
, wParam
);
3677 return REBAR_MoveBand (infoPtr
, wParam
, lParam
);
3679 case RB_PUSHCHEVRON
:
3680 return REBAR_PushChevron (infoPtr
, wParam
, lParam
);
3682 case RB_SETBANDINFOA
:
3683 case RB_SETBANDINFOW
:
3684 return REBAR_SetBandInfoT(infoPtr
, wParam
, (LPREBARBANDINFOW
)lParam
,
3685 uMsg
== RB_SETBANDINFOW
);
3687 return REBAR_SetBarInfo (infoPtr
, (LPREBARINFO
)lParam
);
3690 return REBAR_SetBkColor (infoPtr
, lParam
);
3692 /* case RB_SETCOLORSCHEME: */
3693 /* case RB_SETPALETTE: */
3696 return REBAR_SetParent (infoPtr
, (HWND
)wParam
);
3698 case RB_SETTEXTCOLOR
:
3699 return REBAR_SetTextColor (infoPtr
, lParam
);
3701 /* case RB_SETTOOLTIPS: */
3703 case RB_SETUNICODEFORMAT
:
3704 return REBAR_SetUnicodeFormat (infoPtr
, wParam
);
3706 case CCM_SETVERSION
:
3707 return REBAR_SetVersion (infoPtr
, (INT
)wParam
);
3710 return REBAR_ShowBand (infoPtr
, wParam
, lParam
);
3713 return REBAR_SizeToRect (infoPtr
, (LPCRECT
)lParam
);
3716 /* Messages passed to parent */
3720 return SendMessageW(REBAR_GetNotifyParent (infoPtr
), uMsg
, wParam
, lParam
);
3723 /* case WM_CHARTOITEM: supported according to ControlSpy */
3726 return REBAR_Create (infoPtr
, (LPCREATESTRUCTW
)lParam
);
3729 return REBAR_Destroy (infoPtr
);
3732 return REBAR_EraseBkGnd (infoPtr
, (HDC
)wParam
);
3735 return REBAR_GetFont (infoPtr
);
3737 /* case WM_LBUTTONDBLCLK: supported according to ControlSpy */
3739 case WM_LBUTTONDOWN
:
3740 return REBAR_LButtonDown (infoPtr
, lParam
);
3743 return REBAR_LButtonUp (infoPtr
);
3745 /* case WM_MEASUREITEM: supported according to ControlSpy */
3748 return REBAR_MouseMove (infoPtr
, lParam
);
3751 return REBAR_MouseLeave (infoPtr
);
3754 return REBAR_NCCalcSize (infoPtr
, (RECT
*)lParam
);
3757 return REBAR_NCCreate (hwnd
, (LPCREATESTRUCTW
)lParam
);
3760 return REBAR_NCHitTest (infoPtr
, lParam
);
3763 return REBAR_NCPaint (infoPtr
);
3765 case WM_NOTIFYFORMAT
:
3766 return REBAR_NotifyFormat (infoPtr
, lParam
);
3768 case WM_PRINTCLIENT
:
3770 return REBAR_Paint (infoPtr
, (HDC
)wParam
);
3772 /* case WM_PALETTECHANGED: supported according to ControlSpy */
3773 /* case WM_QUERYNEWPALETTE:supported according to ControlSpy */
3774 /* case WM_RBUTTONDOWN: supported according to ControlSpy */
3775 /* case WM_RBUTTONUP: supported according to ControlSpy */
3778 return REBAR_SetCursor (infoPtr
, lParam
);
3781 return REBAR_SetFont (infoPtr
, (HFONT
)wParam
);
3784 return REBAR_SetRedraw (infoPtr
, wParam
);
3787 return REBAR_Size (infoPtr
, wParam
, lParam
);
3789 case WM_STYLECHANGED
:
3790 return REBAR_StyleChanged (infoPtr
, wParam
, (LPSTYLESTRUCT
)lParam
);
3792 case WM_THEMECHANGED
:
3793 return theme_changed (infoPtr
);
3795 case WM_SYSCOLORCHANGE
:
3796 COMCTL32_RefreshSysColors();
3797 infoPtr
->clrBtnText
= comctl32_color
.clrBtnText
;
3798 infoPtr
->clrBtnFace
= comctl32_color
.clrBtnFace
;
3801 /* case WM_VKEYTOITEM: supported according to ControlSpy */
3802 /* case WM_WININICHANGE: */
3804 case WM_WINDOWPOSCHANGED
:
3805 return REBAR_WindowPosChanged (infoPtr
, wParam
, lParam
);
3808 if ((uMsg
>= WM_USER
) && (uMsg
< WM_APP
) && !COMCTL32_IsReflectedMessage(uMsg
))
3809 ERR("unknown msg %04x wp=%08lx lp=%08lx\n",
3810 uMsg
, wParam
, lParam
);
3811 return DefWindowProcW (hwnd
, uMsg
, wParam
, lParam
);
3817 REBAR_Register (void)
3821 ZeroMemory (&wndClass
, sizeof(WNDCLASSW
));
3822 wndClass
.style
= CS_GLOBALCLASS
| CS_DBLCLKS
;
3823 wndClass
.lpfnWndProc
= REBAR_WindowProc
;
3824 wndClass
.cbClsExtra
= 0;
3825 wndClass
.cbWndExtra
= sizeof(REBAR_INFO
*);
3826 wndClass
.hCursor
= 0;
3827 wndClass
.hbrBackground
= (HBRUSH
)(COLOR_BTNFACE
+ 1);
3829 wndClass
.hbrBackground
= CreateSolidBrush(RGB(0,128,0));
3831 wndClass
.lpszClassName
= REBARCLASSNAMEW
;
3833 RegisterClassW (&wndClass
);
3835 mindragx
= GetSystemMetrics (SM_CXDRAG
);
3836 mindragy
= GetSystemMetrics (SM_CYDRAG
);
3842 REBAR_Unregister (void)
3844 UnregisterClassW (REBARCLASSNAMEW
, NULL
);