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: %lx\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 extra
-= 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 DPA_DeletePtr(infoPtr
->bands
, iHitBand
);
2139 hitBand
->fStyle
&= RBBS_BREAK
;
2140 REBAR_GetBand(infoPtr
, 0)->fStyle
|= RBBS_BREAK
;
2141 infoPtr
->iGrabbedBand
= DPA_InsertPtr(
2142 infoPtr
->bands
, 0, hitBand
);
2144 else if(yOff
> REBAR_GetBand(infoPtr
, infoPtr
->uNumBands
- 1)->rcBand
.bottom
)
2146 /* Place the band below the current bottom row */
2147 DPA_DeletePtr(infoPtr
->bands
, iHitBand
);
2148 hitBand
->fStyle
|= RBBS_BREAK
;
2149 infoPtr
->iGrabbedBand
= DPA_InsertPtr(
2150 infoPtr
->bands
, infoPtr
->uNumBands
- 1, hitBand
);
2154 /* Place the band in the prexisting row the mouse is hovering over */
2155 iRowBegin
= first_visible(infoPtr
);
2156 while(iRowBegin
< infoPtr
->uNumBands
)
2158 iNextRowBegin
= get_row_end_for_band(infoPtr
, iRowBegin
);
2159 rowBeginBand
= REBAR_GetBand(infoPtr
, iRowBegin
);
2160 if(rowBeginBand
->rcBand
.bottom
> yOff
)
2162 REBAR_MoveBandToRowOffset(
2163 infoPtr
, iHitBand
, iRowBegin
, iNextRowBegin
,
2164 ((infoPtr
->dwStyle
& CCS_VERT
) ? ptsmove
->y
: ptsmove
->x
)
2165 - REBAR_PRE_GRIPPER
- infoPtr
->ihitoffset
, FALSE
);
2169 iRowBegin
= iNextRowBegin
;
2173 REBAR_Layout(infoPtr
);
2177 /* << REBAR_BeginDrag >> */
2181 REBAR_DeleteBand (REBAR_INFO
*infoPtr
, WPARAM wParam
)
2183 UINT uBand
= (UINT
)wParam
;
2186 if (uBand
>= infoPtr
->uNumBands
)
2189 TRACE("deleting band %u!\n", uBand
);
2190 lpBand
= REBAR_GetBand(infoPtr
, uBand
);
2191 REBAR_Notify_NMREBAR (infoPtr
, uBand
, RBN_DELETINGBAND
);
2192 /* TODO: a return of 1 should probably cancel the deletion */
2194 if (lpBand
->hwndChild
)
2195 ShowWindow(lpBand
->hwndChild
, SW_HIDE
);
2196 Free(lpBand
->lpText
);
2199 infoPtr
->uNumBands
--;
2200 DPA_DeletePtr(infoPtr
->bands
, uBand
);
2202 REBAR_Notify_NMREBAR (infoPtr
, -1, RBN_DELETEDBAND
);
2204 /* if only 1 band left the re-validate to possible eliminate gripper */
2205 if (infoPtr
->uNumBands
== 1)
2206 REBAR_ValidateBand (infoPtr
, REBAR_GetBand(infoPtr
, 0));
2208 REBAR_Layout(infoPtr
);
2214 /* << REBAR_DragMove >> */
2215 /* << REBAR_EndDrag >> */
2219 REBAR_GetBandBorders (const REBAR_INFO
*infoPtr
, UINT uBand
, RECT
*lpRect
)
2225 if (uBand
>= infoPtr
->uNumBands
)
2228 lpBand
= REBAR_GetBand(infoPtr
, uBand
);
2230 /* FIXME - the following values were determined by experimentation */
2231 /* with the REBAR Control Spy. I have guesses as to what the 4 and */
2232 /* 1 are, but I am not sure. There doesn't seem to be any actual */
2233 /* difference in size of the control area with and without the */
2235 if (infoPtr
->dwStyle
& RBS_BANDBORDERS
) {
2236 if (infoPtr
->dwStyle
& CCS_VERT
) {
2238 lpRect
->top
= lpBand
->cxHeader
+ 4;
2243 lpRect
->left
= lpBand
->cxHeader
+ 4;
2250 lpRect
->left
= lpBand
->cxHeader
;
2256 static inline LRESULT
2257 REBAR_GetBandCount (const REBAR_INFO
*infoPtr
)
2259 TRACE("band count %u!\n", infoPtr
->uNumBands
);
2261 return infoPtr
->uNumBands
;
2266 REBAR_GetBandInfoT(const REBAR_INFO
*infoPtr
, UINT uIndex
, LPREBARBANDINFOW lprbbi
, BOOL bUnicode
)
2270 if (!lprbbi
|| lprbbi
->cbSize
< REBARBANDINFOA_V3_SIZE
)
2273 if (uIndex
>= infoPtr
->uNumBands
)
2276 TRACE("index %u (bUnicode=%d)\n", uIndex
, bUnicode
);
2278 /* copy band information */
2279 lpBand
= REBAR_GetBand(infoPtr
, uIndex
);
2281 if (lprbbi
->fMask
& RBBIM_STYLE
)
2282 lprbbi
->fStyle
= lpBand
->fStyle
;
2284 if (lprbbi
->fMask
& RBBIM_COLORS
) {
2285 lprbbi
->clrFore
= lpBand
->clrFore
;
2286 lprbbi
->clrBack
= lpBand
->clrBack
;
2287 if (lprbbi
->clrBack
== CLR_DEFAULT
)
2288 lprbbi
->clrBack
= infoPtr
->clrBtnFace
;
2291 if (lprbbi
->fMask
& RBBIM_TEXT
) {
2293 Str_GetPtrW(lpBand
->lpText
, lprbbi
->lpText
, lprbbi
->cch
);
2295 Str_GetPtrWtoA(lpBand
->lpText
, (LPSTR
)lprbbi
->lpText
, lprbbi
->cch
);
2298 if (lprbbi
->fMask
& RBBIM_IMAGE
)
2299 lprbbi
->iImage
= lpBand
->iImage
;
2301 if (lprbbi
->fMask
& RBBIM_CHILD
)
2302 lprbbi
->hwndChild
= lpBand
->hwndChild
;
2304 if (lprbbi
->fMask
& RBBIM_CHILDSIZE
) {
2305 lprbbi
->cxMinChild
= lpBand
->cxMinChild
;
2306 lprbbi
->cyMinChild
= lpBand
->cyMinChild
;
2307 /* to make tests pass we follow Windows behaviour and allow to read these fields only
2308 * for RBBS_VARIABLEHEIGHTS bands */
2309 if (lprbbi
->cbSize
>= REBARBANDINFOW_V6_SIZE
&& (lpBand
->fStyle
& RBBS_VARIABLEHEIGHT
)) {
2310 lprbbi
->cyChild
= lpBand
->cyChild
;
2311 lprbbi
->cyMaxChild
= lpBand
->cyMaxChild
;
2312 lprbbi
->cyIntegral
= lpBand
->cyIntegral
;
2316 if (lprbbi
->fMask
& RBBIM_SIZE
)
2317 lprbbi
->cx
= lpBand
->cx
;
2319 if (lprbbi
->fMask
& RBBIM_BACKGROUND
)
2320 lprbbi
->hbmBack
= lpBand
->hbmBack
;
2322 if (lprbbi
->fMask
& RBBIM_ID
)
2323 lprbbi
->wID
= lpBand
->wID
;
2325 /* check for additional data */
2326 if (lprbbi
->cbSize
>= REBARBANDINFOW_V6_SIZE
) {
2327 if (lprbbi
->fMask
& RBBIM_IDEALSIZE
)
2328 lprbbi
->cxIdeal
= lpBand
->cxIdeal
;
2330 if (lprbbi
->fMask
& RBBIM_LPARAM
)
2331 lprbbi
->lParam
= lpBand
->lParam
;
2333 if (lprbbi
->fMask
& RBBIM_HEADERSIZE
)
2334 lprbbi
->cxHeader
= lpBand
->cxHeader
;
2337 REBAR_DumpBandInfo(lprbbi
);
2344 REBAR_GetBarHeight (const REBAR_INFO
*infoPtr
)
2348 nHeight
= infoPtr
->calcSize
.cy
;
2350 TRACE("height = %d\n", nHeight
);
2357 REBAR_GetBarInfo (const REBAR_INFO
*infoPtr
, LPREBARINFO lpInfo
)
2359 if (!lpInfo
|| lpInfo
->cbSize
< sizeof (REBARINFO
))
2362 TRACE("getting bar info!\n");
2364 if (infoPtr
->himl
) {
2365 lpInfo
->himl
= infoPtr
->himl
;
2366 lpInfo
->fMask
|= RBIM_IMAGELIST
;
2373 static inline LRESULT
2374 REBAR_GetBkColor (const REBAR_INFO
*infoPtr
)
2376 COLORREF clr
= infoPtr
->clrBk
;
2378 if (clr
== CLR_DEFAULT
)
2379 clr
= infoPtr
->clrBtnFace
;
2381 TRACE("background color 0x%06x!\n", clr
);
2387 /* << REBAR_GetColorScheme >> */
2388 /* << REBAR_GetDropTarget >> */
2392 REBAR_GetPalette (const REBAR_INFO
*infoPtr
)
2394 FIXME("empty stub!\n");
2401 REBAR_GetRect (const REBAR_INFO
*infoPtr
, INT iBand
, RECT
*lprc
)
2405 if (iBand
< 0 || iBand
>= infoPtr
->uNumBands
)
2410 lpBand
= REBAR_GetBand(infoPtr
, iBand
);
2411 /* For CCS_VERT the coordinates will be swapped - like on Windows */
2412 CopyRect (lprc
, &lpBand
->rcBand
);
2414 TRACE("band %d, (%s)\n", iBand
, wine_dbgstr_rect(lprc
));
2420 static inline LRESULT
2421 REBAR_GetRowCount (const REBAR_INFO
*infoPtr
)
2423 TRACE("%u\n", infoPtr
->uNumRows
);
2425 return infoPtr
->uNumRows
;
2430 REBAR_GetRowHeight (const REBAR_INFO
*infoPtr
, INT iRow
)
2436 for (i
=0; i
<infoPtr
->uNumBands
; i
++) {
2437 lpBand
= REBAR_GetBand(infoPtr
, i
);
2438 if (HIDDENBAND(lpBand
)) continue;
2439 if (lpBand
->iRow
!= iRow
) continue;
2440 j
= lpBand
->rcBand
.bottom
- lpBand
->rcBand
.top
;
2441 if (j
> ret
) ret
= j
;
2444 TRACE("row %d, height %d\n", iRow
, ret
);
2450 static inline LRESULT
2451 REBAR_GetTextColor (const REBAR_INFO
*infoPtr
)
2453 TRACE("text color 0x%06x!\n", infoPtr
->clrText
);
2455 return infoPtr
->clrText
;
2459 static inline LRESULT
2460 REBAR_GetToolTips (const REBAR_INFO
*infoPtr
)
2462 return (LRESULT
)infoPtr
->hwndToolTip
;
2466 static inline LRESULT
2467 REBAR_GetUnicodeFormat (const REBAR_INFO
*infoPtr
)
2469 TRACE("%s hwnd=%p\n",
2470 infoPtr
->bUnicode
? "TRUE" : "FALSE", infoPtr
->hwndSelf
);
2472 return infoPtr
->bUnicode
;
2476 static inline LRESULT
2477 REBAR_GetVersion (const REBAR_INFO
*infoPtr
)
2479 TRACE("version %d\n", infoPtr
->iVersion
);
2480 return infoPtr
->iVersion
;
2485 REBAR_HitTest (const REBAR_INFO
*infoPtr
, LPRBHITTESTINFO lprbht
)
2490 REBAR_InternalHitTest (infoPtr
, &lprbht
->pt
, &lprbht
->flags
, &lprbht
->iBand
);
2492 return lprbht
->iBand
;
2497 REBAR_IdToIndex (const REBAR_INFO
*infoPtr
, UINT uId
)
2501 if (infoPtr
->uNumBands
< 1)
2504 for (i
= 0; i
< infoPtr
->uNumBands
; i
++) {
2505 if (REBAR_GetBand(infoPtr
, i
)->wID
== uId
) {
2506 TRACE("id %u is band %u found!\n", uId
, i
);
2511 TRACE("id %u is not found\n", uId
);
2517 REBAR_InsertBandT(REBAR_INFO
*infoPtr
, INT iIndex
, const REBARBANDINFOW
*lprbbi
, BOOL bUnicode
)
2521 if (!lprbbi
|| lprbbi
->cbSize
< REBARBANDINFOA_V3_SIZE
)
2524 /* trace the index as signed to see the -1 */
2525 TRACE("insert band at %d (bUnicode=%d)!\n", iIndex
, bUnicode
);
2526 REBAR_DumpBandInfo(lprbbi
);
2528 if (!(lpBand
= Alloc(sizeof(REBAR_BAND
)))) return FALSE
;
2529 if ((iIndex
== -1) || (iIndex
> infoPtr
->uNumBands
))
2530 iIndex
= infoPtr
->uNumBands
;
2531 if (DPA_InsertPtr(infoPtr
->bands
, iIndex
, lpBand
) == -1)
2536 infoPtr
->uNumBands
++;
2538 TRACE("index %d!\n", iIndex
);
2540 /* initialize band */
2541 memset(lpBand
, 0, sizeof(*lpBand
));
2542 lpBand
->clrFore
= infoPtr
->clrText
;
2543 lpBand
->clrBack
= infoPtr
->clrBk
;
2544 lpBand
->iImage
= -1;
2546 REBAR_CommonSetupBand(infoPtr
->hwndSelf
, lprbbi
, lpBand
);
2548 /* Make sure the defaults for these are correct */
2549 if (lprbbi
->cbSize
< REBARBANDINFOA_V6_SIZE
|| !(lpBand
->fStyle
& RBBS_VARIABLEHEIGHT
)) {
2550 lpBand
->cyChild
= lpBand
->cyMinChild
;
2551 lpBand
->cyMaxChild
= 0x7fffffff;
2552 lpBand
->cyIntegral
= 0;
2555 if ((lprbbi
->fMask
& RBBIM_TEXT
) && (lprbbi
->lpText
)) {
2557 Str_SetPtrW(&lpBand
->lpText
, lprbbi
->lpText
);
2559 Str_SetPtrAtoW(&lpBand
->lpText
, (LPSTR
)lprbbi
->lpText
);
2562 REBAR_ValidateBand (infoPtr
, lpBand
);
2563 /* On insert of second band, revalidate band 1 to possible add gripper */
2564 if (infoPtr
->uNumBands
== 2)
2565 REBAR_ValidateBand (infoPtr
, REBAR_GetBand(infoPtr
, 0));
2567 REBAR_DumpBand (infoPtr
);
2569 REBAR_Layout(infoPtr
);
2570 InvalidateRect(infoPtr
->hwndSelf
, NULL
, TRUE
);
2577 REBAR_MaximizeBand (const REBAR_INFO
*infoPtr
, INT iBand
, LPARAM lParam
)
2580 int iRowBegin
, iRowEnd
;
2581 int cxDesired
, extra
, extraOrig
;
2585 if (infoPtr
->uNumBands
== 0 || iBand
< 0 || iBand
>= infoPtr
->uNumBands
) {
2587 ERR("Illegal MaximizeBand, requested=%d, current band count=%d\n",
2588 iBand
, infoPtr
->uNumBands
);
2592 lpBand
= REBAR_GetBand(infoPtr
, iBand
);
2594 if (lpBand
->fStyle
& RBBS_HIDDEN
)
2596 /* Windows is buggy and creates a hole */
2597 WARN("Ignoring maximize request on a hidden band (%d)\n", iBand
);
2601 cxIdealBand
= lpBand
->cxIdeal
+ lpBand
->cxHeader
+ REBAR_POST_CHILD
;
2602 if (lParam
&& (lpBand
->cxEffective
< cxIdealBand
))
2603 cxDesired
= cxIdealBand
;
2605 cxDesired
= infoPtr
->calcSize
.cx
;
2607 iRowBegin
= get_row_begin_for_band(infoPtr
, iBand
);
2608 iRowEnd
= get_row_end_for_band(infoPtr
, iBand
);
2609 extraOrig
= extra
= cxDesired
- lpBand
->cxEffective
;
2611 extra
= REBAR_ShrinkBandsRTL(infoPtr
, iRowBegin
, iBand
, extra
, TRUE
);
2613 extra
= REBAR_ShrinkBandsLTR(infoPtr
, next_visible(infoPtr
, iBand
), iRowEnd
, extra
, TRUE
);
2614 lpBand
->cxEffective
+= extraOrig
- extra
;
2615 lpBand
->cx
= lpBand
->cxEffective
;
2616 TRACE("(%d, %ld): Wanted size %d, obtained %d (shrink %d, %d)\n", iBand
, lParam
, cxDesired
, lpBand
->cx
, extraOrig
, extra
);
2617 REBAR_SetRowRectsX(infoPtr
, iRowBegin
, iRowEnd
);
2619 if (infoPtr
->dwStyle
& CCS_VERT
)
2620 REBAR_CalcVertBand(infoPtr
, iRowBegin
, iRowEnd
);
2622 REBAR_CalcHorzBand(infoPtr
, iRowBegin
, iRowEnd
);
2623 REBAR_MoveChildWindows(infoPtr
, iRowBegin
, iRowEnd
);
2630 REBAR_MinimizeBand (const REBAR_INFO
*infoPtr
, INT iBand
)
2633 int iPrev
, iRowBegin
, iRowEnd
;
2635 /* A "minimize" band is equivalent to "dragging" the gripper
2636 * of than band to the right till the band is only the size
2641 if (infoPtr
->uNumBands
== 0 || iBand
< 0 || iBand
>= infoPtr
->uNumBands
) {
2643 ERR("Illegal MinimizeBand, requested=%d, current band count=%d\n",
2644 iBand
, infoPtr
->uNumBands
);
2648 /* compute amount of movement and validate */
2649 lpBand
= REBAR_GetBand(infoPtr
, iBand
);
2651 if (lpBand
->fStyle
& RBBS_HIDDEN
)
2653 /* Windows is buggy and creates a hole/overlap */
2654 WARN("Ignoring minimize request on a hidden band (%d)\n", iBand
);
2658 iPrev
= prev_visible(infoPtr
, iBand
);
2659 /* if first band in row */
2660 if (iPrev
< 0 || REBAR_GetBand(infoPtr
, iPrev
)->iRow
!= lpBand
->iRow
) {
2661 int iNext
= next_visible(infoPtr
, iBand
);
2662 if (iNext
< infoPtr
->uNumBands
&& REBAR_GetBand(infoPtr
, iNext
)->iRow
== lpBand
->iRow
) {
2663 TRACE("(%d): Minimizing the first band in row is by maximizing the second\n", iBand
);
2664 REBAR_MaximizeBand(infoPtr
, iNext
, FALSE
);
2667 TRACE("(%d): Only one band in row - nothing to do\n", iBand
);
2671 REBAR_GetBand(infoPtr
, iPrev
)->cxEffective
+= lpBand
->cxEffective
- lpBand
->cxMinBand
;
2672 REBAR_GetBand(infoPtr
, iPrev
)->cx
= REBAR_GetBand(infoPtr
, iPrev
)->cxEffective
;
2673 lpBand
->cx
= lpBand
->cxEffective
= lpBand
->cxMinBand
;
2675 iRowBegin
= get_row_begin_for_band(infoPtr
, iBand
);
2676 iRowEnd
= get_row_end_for_band(infoPtr
, iBand
);
2677 REBAR_SetRowRectsX(infoPtr
, iRowBegin
, iRowEnd
);
2679 if (infoPtr
->dwStyle
& CCS_VERT
)
2680 REBAR_CalcVertBand(infoPtr
, iRowBegin
, iRowEnd
);
2682 REBAR_CalcHorzBand(infoPtr
, iRowBegin
, iRowEnd
);
2683 REBAR_MoveChildWindows(infoPtr
, iRowBegin
, iRowEnd
);
2689 REBAR_MoveBand (REBAR_INFO
*infoPtr
, INT iFrom
, INT iTo
)
2694 if ((infoPtr
->uNumBands
== 0) ||
2695 (iFrom
< 0) || iFrom
>= infoPtr
->uNumBands
||
2696 (iTo
< 0) || iTo
>= infoPtr
->uNumBands
) {
2698 ERR("Illegal MoveBand, from=%d, to=%d, current band count=%d\n",
2699 iFrom
, iTo
, infoPtr
->uNumBands
);
2703 lpBand
= REBAR_GetBand(infoPtr
, iFrom
);
2704 DPA_DeletePtr(infoPtr
->bands
, iFrom
);
2705 DPA_InsertPtr(infoPtr
->bands
, iTo
, lpBand
);
2707 TRACE("moved band %d to index %d\n", iFrom
, iTo
);
2708 REBAR_DumpBand (infoPtr
);
2710 /* **************************************************** */
2712 /* We do not do a REBAR_Layout here because the native */
2713 /* control does not do that. The actual layout and */
2714 /* repaint is done by the *next* real action, ex.: */
2715 /* RB_INSERTBAND, RB_DELETEBAND, RB_SIZETORECT, etc. */
2717 /* **************************************************** */
2723 /* return TRUE if two strings are different */
2725 REBAR_strdifW( LPCWSTR a
, LPCWSTR b
)
2727 return ( (a
&& !b
) || (b
&& !a
) || (a
&& b
&& lstrcmpW(a
, b
) ) );
2731 REBAR_SetBandInfoT(REBAR_INFO
*infoPtr
, INT iBand
, const REBARBANDINFOW
*lprbbi
, BOOL bUnicode
)
2736 if (!lprbbi
|| lprbbi
->cbSize
< REBARBANDINFOA_V3_SIZE
)
2739 if (iBand
>= infoPtr
->uNumBands
)
2742 TRACE("index %d\n", iBand
);
2743 REBAR_DumpBandInfo (lprbbi
);
2745 /* set band information */
2746 lpBand
= REBAR_GetBand(infoPtr
, iBand
);
2748 uChanged
= REBAR_CommonSetupBand (infoPtr
->hwndSelf
, lprbbi
, lpBand
);
2749 if (lprbbi
->fMask
& RBBIM_TEXT
) {
2752 Str_SetPtrW(&wstr
, lprbbi
->lpText
);
2754 Str_SetPtrAtoW(&wstr
, (LPSTR
)lprbbi
->lpText
);
2756 if (REBAR_strdifW(wstr
, lpBand
->lpText
)) {
2757 Free(lpBand
->lpText
);
2758 lpBand
->lpText
= wstr
;
2759 uChanged
|= RBBIM_TEXT
;
2765 REBAR_ValidateBand (infoPtr
, lpBand
);
2767 REBAR_DumpBand (infoPtr
);
2769 if (uChanged
& (RBBIM_CHILDSIZE
| RBBIM_SIZE
| RBBIM_STYLE
| RBBIM_IMAGE
)) {
2770 REBAR_Layout(infoPtr
);
2771 InvalidateRect(infoPtr
->hwndSelf
, NULL
, TRUE
);
2779 REBAR_SetBarInfo (REBAR_INFO
*infoPtr
, const REBARINFO
*lpInfo
)
2784 if (!lpInfo
|| lpInfo
->cbSize
< sizeof (REBARINFO
))
2787 TRACE("setting bar info!\n");
2789 if (lpInfo
->fMask
& RBIM_IMAGELIST
) {
2790 infoPtr
->himl
= lpInfo
->himl
;
2791 if (infoPtr
->himl
) {
2793 ImageList_GetIconSize (infoPtr
->himl
, &cx
, &cy
);
2794 infoPtr
->imageSize
.cx
= cx
;
2795 infoPtr
->imageSize
.cy
= cy
;
2798 infoPtr
->imageSize
.cx
= 0;
2799 infoPtr
->imageSize
.cy
= 0;
2801 TRACE("new image cx=%d, cy=%d\n", infoPtr
->imageSize
.cx
,
2802 infoPtr
->imageSize
.cy
);
2805 /* revalidate all bands to reset flags for images in headers of bands */
2806 for (i
=0; i
<infoPtr
->uNumBands
; i
++) {
2807 lpBand
= REBAR_GetBand(infoPtr
, i
);
2808 REBAR_ValidateBand (infoPtr
, lpBand
);
2816 REBAR_SetBkColor (REBAR_INFO
*infoPtr
, COLORREF clr
)
2820 clrTemp
= infoPtr
->clrBk
;
2821 infoPtr
->clrBk
= clr
;
2823 TRACE("background color 0x%06x!\n", infoPtr
->clrBk
);
2829 /* << REBAR_SetColorScheme >> */
2830 /* << REBAR_SetPalette >> */
2834 REBAR_SetParent (REBAR_INFO
*infoPtr
, HWND parent
)
2836 HWND hwndTemp
= infoPtr
->hwndNotify
;
2838 infoPtr
->hwndNotify
= parent
;
2840 return (LRESULT
)hwndTemp
;
2845 REBAR_SetTextColor (REBAR_INFO
*infoPtr
, COLORREF clr
)
2849 clrTemp
= infoPtr
->clrText
;
2850 infoPtr
->clrText
= clr
;
2852 TRACE("text color 0x%06x!\n", infoPtr
->clrText
);
2858 /* << REBAR_SetTooltips >> */
2861 static inline LRESULT
2862 REBAR_SetUnicodeFormat (REBAR_INFO
*infoPtr
, BOOL unicode
)
2864 BOOL bTemp
= infoPtr
->bUnicode
;
2866 TRACE("to %s hwnd=%p, was %s\n",
2867 unicode
? "TRUE" : "FALSE", infoPtr
->hwndSelf
,
2868 (bTemp
) ? "TRUE" : "FALSE");
2870 infoPtr
->bUnicode
= unicode
;
2877 REBAR_SetVersion (REBAR_INFO
*infoPtr
, INT iVersion
)
2879 INT iOldVersion
= infoPtr
->iVersion
;
2881 if (iVersion
> COMCTL32_VERSION
)
2884 infoPtr
->iVersion
= iVersion
;
2886 TRACE("new version %d\n", iVersion
);
2893 REBAR_ShowBand (REBAR_INFO
*infoPtr
, INT iBand
, BOOL show
)
2897 if (iBand
< 0 || iBand
>= infoPtr
->uNumBands
)
2900 lpBand
= REBAR_GetBand(infoPtr
, iBand
);
2903 TRACE("show band %d\n", iBand
);
2904 lpBand
->fStyle
= lpBand
->fStyle
& ~RBBS_HIDDEN
;
2905 if (IsWindow (lpBand
->hwndChild
))
2906 ShowWindow (lpBand
->hwndChild
, SW_SHOW
);
2909 TRACE("hide band %d\n", iBand
);
2910 lpBand
->fStyle
= lpBand
->fStyle
| RBBS_HIDDEN
;
2911 if (IsWindow (lpBand
->hwndChild
))
2912 ShowWindow (lpBand
->hwndChild
, SW_HIDE
);
2915 REBAR_Layout(infoPtr
);
2916 InvalidateRect(infoPtr
->hwndSelf
, NULL
, TRUE
);
2923 REBAR_SizeToRect (REBAR_INFO
*infoPtr
, const RECT
*lpRect
)
2925 if (!lpRect
) return FALSE
;
2927 TRACE("[%s]\n", wine_dbgstr_rect(lpRect
));
2928 REBAR_SizeToHeight(infoPtr
, get_rect_cy(infoPtr
, lpRect
));
2935 REBAR_Create (REBAR_INFO
*infoPtr
, LPCREATESTRUCTW cs
)
2939 if (TRACE_ON(rebar
)) {
2940 GetWindowRect(infoPtr
->hwndSelf
, &wnrc1
);
2941 GetClientRect(infoPtr
->hwndSelf
, &clrc1
);
2942 TRACE("window=(%s) client=(%s) cs=(%d,%d %dx%d)\n",
2943 wine_dbgstr_rect(&wnrc1
), wine_dbgstr_rect(&clrc1
),
2944 cs
->x
, cs
->y
, cs
->cx
, cs
->cy
);
2947 TRACE("created!\n");
2949 if (OpenThemeData (infoPtr
->hwndSelf
, themeClass
))
2951 /* native seems to clear WS_BORDER when themed */
2952 infoPtr
->dwStyle
&= ~WS_BORDER
;
2960 REBAR_Destroy (REBAR_INFO
*infoPtr
)
2965 /* clean up each band */
2966 for (i
= 0; i
< infoPtr
->uNumBands
; i
++) {
2967 lpBand
= REBAR_GetBand(infoPtr
, i
);
2969 /* delete text strings */
2970 Free (lpBand
->lpText
);
2971 lpBand
->lpText
= NULL
;
2972 /* destroy child window */
2973 DestroyWindow (lpBand
->hwndChild
);
2977 /* free band array */
2978 DPA_Destroy (infoPtr
->bands
);
2979 infoPtr
->bands
= NULL
;
2981 DestroyCursor (infoPtr
->hcurArrow
);
2982 DestroyCursor (infoPtr
->hcurHorz
);
2983 DestroyCursor (infoPtr
->hcurVert
);
2984 DestroyCursor (infoPtr
->hcurDrag
);
2985 if (infoPtr
->hDefaultFont
) DeleteObject (infoPtr
->hDefaultFont
);
2986 SetWindowLongPtrW (infoPtr
->hwndSelf
, 0, 0);
2988 CloseThemeData (GetWindowTheme (infoPtr
->hwndSelf
));
2990 /* free rebar info data */
2992 TRACE("destroyed!\n");
2997 REBAR_GetFont (const REBAR_INFO
*infoPtr
)
2999 return (LRESULT
)infoPtr
->hFont
;
3003 REBAR_PushChevron(const REBAR_INFO
*infoPtr
, UINT uBand
, LPARAM lParam
)
3005 if (uBand
< infoPtr
->uNumBands
)
3007 NMREBARCHEVRON nmrbc
;
3008 REBAR_BAND
*lpBand
= REBAR_GetBand(infoPtr
, uBand
);
3010 TRACE("Pressed chevron on band %u\n", uBand
);
3012 /* redraw chevron in pushed state */
3013 lpBand
->fDraw
|= DRAW_CHEVRONPUSHED
;
3014 RedrawWindow(infoPtr
->hwndSelf
, &lpBand
->rcChevron
,0,
3015 RDW_ERASE
|RDW_INVALIDATE
|RDW_UPDATENOW
);
3017 /* notify app so it can display a popup menu or whatever */
3018 nmrbc
.uBand
= uBand
;
3019 nmrbc
.wID
= lpBand
->wID
;
3020 nmrbc
.lParam
= lpBand
->lParam
;
3021 nmrbc
.rc
= lpBand
->rcChevron
;
3022 nmrbc
.lParamNM
= lParam
;
3023 REBAR_Notify((NMHDR
*)&nmrbc
, infoPtr
, RBN_CHEVRONPUSHED
);
3025 /* redraw chevron in previous state */
3026 lpBand
->fDraw
&= ~DRAW_CHEVRONPUSHED
;
3027 InvalidateRect(infoPtr
->hwndSelf
, &lpBand
->rcChevron
, TRUE
);
3035 REBAR_LButtonDown (REBAR_INFO
*infoPtr
, LPARAM lParam
)
3040 ptMouseDown
.x
= (short)LOWORD(lParam
);
3041 ptMouseDown
.y
= (short)HIWORD(lParam
);
3043 REBAR_InternalHitTest(infoPtr
, &ptMouseDown
, &htFlags
, &iHitBand
);
3045 if (htFlags
== RBHT_CHEVRON
)
3047 REBAR_PushChevron(infoPtr
, iHitBand
, 0);
3049 else if (htFlags
== RBHT_GRABBER
|| htFlags
== RBHT_CAPTION
)
3053 TRACE("Starting drag\n");
3055 lpBand
= REBAR_GetBand(infoPtr
, iHitBand
);
3057 SetCapture (infoPtr
->hwndSelf
);
3058 infoPtr
->iGrabbedBand
= iHitBand
;
3060 /* save off the LOWORD and HIWORD of lParam as initial x,y */
3061 infoPtr
->dragStart
.x
= (short)LOWORD(lParam
);
3062 infoPtr
->dragStart
.y
= (short)HIWORD(lParam
);
3063 infoPtr
->dragNow
= infoPtr
->dragStart
;
3064 if (infoPtr
->dwStyle
& CCS_VERT
)
3065 infoPtr
->ihitoffset
= infoPtr
->dragStart
.y
- (lpBand
->rcBand
.left
+ REBAR_PRE_GRIPPER
);
3067 infoPtr
->ihitoffset
= infoPtr
->dragStart
.x
- (lpBand
->rcBand
.left
+ REBAR_PRE_GRIPPER
);
3073 REBAR_LButtonUp (REBAR_INFO
*infoPtr
)
3075 if (infoPtr
->iGrabbedBand
>= 0)
3080 infoPtr
->dragStart
.x
= 0;
3081 infoPtr
->dragStart
.y
= 0;
3082 infoPtr
->dragNow
= infoPtr
->dragStart
;
3086 if (infoPtr
->fStatus
& BEGIN_DRAG_ISSUED
) {
3087 REBAR_Notify(&layout
, infoPtr
, RBN_LAYOUTCHANGED
);
3088 REBAR_Notify_NMREBAR (infoPtr
, infoPtr
->iGrabbedBand
, RBN_ENDDRAG
);
3089 infoPtr
->fStatus
&= ~BEGIN_DRAG_ISSUED
;
3092 infoPtr
->iGrabbedBand
= -1;
3094 GetClientRect(infoPtr
->hwndSelf
, &rect
);
3095 InvalidateRect(infoPtr
->hwndSelf
, NULL
, TRUE
);
3102 REBAR_MouseLeave (REBAR_INFO
*infoPtr
)
3104 if (infoPtr
->ichevronhotBand
>= 0)
3106 REBAR_BAND
*lpChevronBand
= REBAR_GetBand(infoPtr
, infoPtr
->ichevronhotBand
);
3107 if (lpChevronBand
->fDraw
& DRAW_CHEVRONHOT
)
3109 lpChevronBand
->fDraw
&= ~DRAW_CHEVRONHOT
;
3110 InvalidateRect(infoPtr
->hwndSelf
, &lpChevronBand
->rcChevron
, TRUE
);
3113 infoPtr
->iOldBand
= -1;
3114 infoPtr
->ichevronhotBand
= -2;
3120 REBAR_MouseMove (REBAR_INFO
*infoPtr
, LPARAM lParam
)
3122 REBAR_BAND
*lpChevronBand
;
3125 ptMove
.x
= (short)LOWORD(lParam
);
3126 ptMove
.y
= (short)HIWORD(lParam
);
3128 /* if we are currently dragging a band */
3129 if (infoPtr
->iGrabbedBand
>= 0)
3132 int yPtMove
= (infoPtr
->dwStyle
& CCS_VERT
? ptMove
.x
: ptMove
.y
);
3134 if (GetCapture() != infoPtr
->hwndSelf
)
3135 ERR("We are dragging but haven't got capture?!?\n");
3137 band
= REBAR_GetBand(infoPtr
, infoPtr
->iGrabbedBand
);
3139 /* if mouse did not move much, exit */
3140 if ((abs(ptMove
.x
- infoPtr
->dragNow
.x
) <= mindragx
) &&
3141 (abs(ptMove
.y
- infoPtr
->dragNow
.y
) <= mindragy
)) return 0;
3143 /* on first significant mouse movement, issue notify */
3144 if (!(infoPtr
->fStatus
& BEGIN_DRAG_ISSUED
)) {
3145 if (REBAR_Notify_NMREBAR (infoPtr
, -1, RBN_BEGINDRAG
)) {
3146 /* Notify returned TRUE - abort drag */
3147 infoPtr
->dragStart
.x
= 0;
3148 infoPtr
->dragStart
.y
= 0;
3149 infoPtr
->dragNow
= infoPtr
->dragStart
;
3150 infoPtr
->iGrabbedBand
= -1;
3154 infoPtr
->fStatus
|= BEGIN_DRAG_ISSUED
;
3157 /* Test for valid drag case - must not be first band in row */
3158 if ((yPtMove
< band
->rcBand
.top
) ||
3159 (yPtMove
> band
->rcBand
.bottom
)) {
3160 REBAR_HandleUDDrag (infoPtr
, &ptMove
);
3163 REBAR_HandleLRDrag (infoPtr
, &ptMove
);
3170 TRACKMOUSEEVENT trackinfo
;
3172 REBAR_InternalHitTest(infoPtr
, &ptMove
, &htFlags
, &iHitBand
);
3174 if (infoPtr
->iOldBand
>= 0 && infoPtr
->iOldBand
== infoPtr
->ichevronhotBand
)
3176 lpChevronBand
= REBAR_GetBand(infoPtr
, infoPtr
->ichevronhotBand
);
3177 if (lpChevronBand
->fDraw
& DRAW_CHEVRONHOT
)
3179 lpChevronBand
->fDraw
&= ~DRAW_CHEVRONHOT
;
3180 InvalidateRect(infoPtr
->hwndSelf
, &lpChevronBand
->rcChevron
, TRUE
);
3182 infoPtr
->ichevronhotBand
= -2;
3185 if (htFlags
== RBHT_CHEVRON
)
3187 /* fill in the TRACKMOUSEEVENT struct */
3188 trackinfo
.cbSize
= sizeof(TRACKMOUSEEVENT
);
3189 trackinfo
.dwFlags
= TME_QUERY
;
3190 trackinfo
.hwndTrack
= infoPtr
->hwndSelf
;
3191 trackinfo
.dwHoverTime
= 0;
3193 /* call _TrackMouseEvent to see if we are currently tracking for this hwnd */
3194 _TrackMouseEvent(&trackinfo
);
3196 /* Make sure tracking is enabled so we receive a WM_MOUSELEAVE message */
3197 if(!(trackinfo
.dwFlags
& TME_LEAVE
))
3199 trackinfo
.dwFlags
= TME_LEAVE
; /* notify upon leaving */
3201 /* call TRACKMOUSEEVENT so we receive a WM_MOUSELEAVE message */
3202 /* and can properly deactivate the hot chevron */
3203 _TrackMouseEvent(&trackinfo
);
3206 lpChevronBand
= REBAR_GetBand(infoPtr
, iHitBand
);
3207 if (!(lpChevronBand
->fDraw
& DRAW_CHEVRONHOT
))
3209 lpChevronBand
->fDraw
|= DRAW_CHEVRONHOT
;
3210 InvalidateRect(infoPtr
->hwndSelf
, &lpChevronBand
->rcChevron
, TRUE
);
3211 infoPtr
->ichevronhotBand
= iHitBand
;
3214 infoPtr
->iOldBand
= iHitBand
;
3221 static inline LRESULT
3222 REBAR_NCCalcSize (const REBAR_INFO
*infoPtr
, RECT
*rect
)
3226 if (infoPtr
->dwStyle
& WS_BORDER
) {
3227 rect
->left
= min(rect
->left
+ GetSystemMetrics(SM_CXEDGE
), rect
->right
);
3228 rect
->right
= max(rect
->right
- GetSystemMetrics(SM_CXEDGE
), rect
->left
);
3229 rect
->top
= min(rect
->top
+ GetSystemMetrics(SM_CYEDGE
), rect
->bottom
);
3230 rect
->bottom
= max(rect
->bottom
- GetSystemMetrics(SM_CYEDGE
), rect
->top
);
3232 else if ((theme
= GetWindowTheme (infoPtr
->hwndSelf
)))
3234 /* FIXME: should use GetThemeInt */
3235 rect
->top
= min(rect
->top
+ 1, rect
->bottom
);
3237 TRACE("new client=(%s)\n", wine_dbgstr_rect(rect
));
3243 REBAR_NCCreate (HWND hwnd
, const CREATESTRUCTW
*cs
)
3245 REBAR_INFO
*infoPtr
= REBAR_GetInfoPtr (hwnd
);
3247 NONCLIENTMETRICSW ncm
;
3251 ERR("Strange info structure pointer *not* NULL\n");
3255 if (TRACE_ON(rebar
)) {
3256 GetWindowRect(hwnd
, &wnrc1
);
3257 GetClientRect(hwnd
, &clrc1
);
3258 TRACE("window=(%s) client=(%s) cs=(%d,%d %dx%d)\n",
3259 wine_dbgstr_rect(&wnrc1
), wine_dbgstr_rect(&clrc1
),
3260 cs
->x
, cs
->y
, cs
->cx
, cs
->cy
);
3263 /* allocate memory for info structure */
3264 infoPtr
= Alloc (sizeof(REBAR_INFO
));
3265 SetWindowLongPtrW (hwnd
, 0, (DWORD_PTR
)infoPtr
);
3267 /* initialize info structure - initial values are 0 */
3268 infoPtr
->clrBk
= CLR_NONE
;
3269 infoPtr
->clrText
= CLR_NONE
;
3270 infoPtr
->clrBtnText
= comctl32_color
.clrBtnText
;
3271 infoPtr
->clrBtnFace
= comctl32_color
.clrBtnFace
;
3272 infoPtr
->iOldBand
= -1;
3273 infoPtr
->ichevronhotBand
= -2;
3274 infoPtr
->iGrabbedBand
= -1;
3275 infoPtr
->hwndSelf
= hwnd
;
3276 infoPtr
->DoRedraw
= TRUE
;
3277 infoPtr
->hcurArrow
= LoadCursorW (0, (LPWSTR
)IDC_ARROW
);
3278 infoPtr
->hcurHorz
= LoadCursorW (0, (LPWSTR
)IDC_SIZEWE
);
3279 infoPtr
->hcurVert
= LoadCursorW (0, (LPWSTR
)IDC_SIZENS
);
3280 infoPtr
->hcurDrag
= LoadCursorW (0, (LPWSTR
)IDC_SIZE
);
3281 infoPtr
->fStatus
= 0;
3282 infoPtr
->hFont
= GetStockObject (SYSTEM_FONT
);
3283 infoPtr
->bands
= DPA_Create(8);
3285 /* issue WM_NOTIFYFORMAT to get unicode status of parent */
3286 REBAR_NotifyFormat(infoPtr
, NF_REQUERY
);
3288 /* Stow away the original style */
3289 infoPtr
->orgStyle
= cs
->style
;
3290 /* add necessary styles to the requested styles */
3291 infoPtr
->dwStyle
= cs
->style
| WS_VISIBLE
;
3292 if ((infoPtr
->dwStyle
& CCS_LAYOUT_MASK
) == 0)
3293 infoPtr
->dwStyle
|= CCS_TOP
;
3294 SetWindowLongW (hwnd
, GWL_STYLE
, infoPtr
->dwStyle
);
3296 /* get font handle for Caption Font */
3297 ncm
.cbSize
= sizeof(ncm
);
3298 SystemParametersInfoW (SPI_GETNONCLIENTMETRICS
, ncm
.cbSize
, &ncm
, 0);
3299 /* if the font is bold, set to normal */
3300 if (ncm
.lfCaptionFont
.lfWeight
> FW_NORMAL
) {
3301 ncm
.lfCaptionFont
.lfWeight
= FW_NORMAL
;
3303 tfont
= CreateFontIndirectW (&ncm
.lfCaptionFont
);
3305 infoPtr
->hFont
= infoPtr
->hDefaultFont
= tfont
;
3309 GetSysColor (numerous);
3310 GetSysColorBrush (numerous) (see WM_SYSCOLORCHANGE);
3311 *GetStockObject (SYSTEM_FONT);
3312 *SetWindowLong (hwnd, 0, info ptr);
3314 *SetWindowLong (hwnd, GWL_STYLE, style+0x10000001);
3315 WS_VISIBLE = 0x10000000;
3316 CCS_TOP = 0x00000001;
3317 *SystemParametersInfo (SPI_GETNONCLIENTMETRICS...);
3318 *CreateFontIndirect (lfCaptionFont from above);
3320 SelectObject (hdc, fontabove);
3321 GetTextMetrics (hdc, ); guessing is tmHeight
3322 SelectObject (hdc, oldfont);
3325 MapWindowPoints (0, parent, rectabove, 2);
3328 ClientToScreen (clientrect);
3329 SetWindowPos (hwnd, 0, 0, 0, 0, 0, SWP_NOZORDER);
3336 REBAR_NCHitTest (const REBAR_INFO
*infoPtr
, LPARAM lParam
)
3342 LRESULT ret
= HTCLIENT
;
3345 * Differences from doc at MSDN (as observed with version 4.71 of
3347 * 1. doc says nmmouse.pt is in screen coord, trace shows client coord.
3348 * 2. if band is not identified .dwItemSpec is 0xffffffff.
3349 * 3. native always seems to return HTCLIENT if notify return is 0.
3352 clpt
.x
= (short)LOWORD(lParam
);
3353 clpt
.y
= (short)HIWORD(lParam
);
3354 ScreenToClient (infoPtr
->hwndSelf
, &clpt
);
3355 REBAR_InternalHitTest (infoPtr
, &clpt
, &scrap
,
3356 (INT
*)&nmmouse
.dwItemSpec
);
3357 nmmouse
.dwItemData
= 0;
3359 nmmouse
.dwHitInfo
= 0;
3360 if ((i
= REBAR_Notify((NMHDR
*) &nmmouse
, infoPtr
, NM_NCHITTEST
))) {
3361 TRACE("notify changed return value from %ld to %d\n",
3365 TRACE("returning %ld, client point (%d,%d)\n", ret
, clpt
.x
, clpt
.y
);
3371 REBAR_NCPaint (const REBAR_INFO
*infoPtr
)
3377 if (infoPtr
->dwStyle
& WS_MINIMIZE
)
3378 return 0; /* Nothing to do */
3380 if (infoPtr
->dwStyle
& WS_BORDER
) {
3382 /* adjust rectangle and draw the necessary edge */
3383 if (!(hdc
= GetDCEx( infoPtr
->hwndSelf
, 0, DCX_USESTYLE
| DCX_WINDOW
)))
3385 GetWindowRect (infoPtr
->hwndSelf
, &rcWindow
);
3386 OffsetRect (&rcWindow
, -rcWindow
.left
, -rcWindow
.top
);
3387 TRACE("rect (%s)\n", wine_dbgstr_rect(&rcWindow
));
3388 DrawEdge (hdc
, &rcWindow
, EDGE_ETCHED
, BF_RECT
);
3389 ReleaseDC( infoPtr
->hwndSelf
, hdc
);
3391 else if ((theme
= GetWindowTheme (infoPtr
->hwndSelf
)))
3393 /* adjust rectangle and draw the necessary edge */
3394 if (!(hdc
= GetDCEx( infoPtr
->hwndSelf
, 0, DCX_USESTYLE
| DCX_WINDOW
)))
3396 GetWindowRect (infoPtr
->hwndSelf
, &rcWindow
);
3397 OffsetRect (&rcWindow
, -rcWindow
.left
, -rcWindow
.top
);
3398 TRACE("rect (%s)\n", wine_dbgstr_rect(&rcWindow
));
3399 DrawThemeEdge (theme
, hdc
, 0, 0, &rcWindow
, BDR_RAISEDINNER
, BF_TOP
, NULL
);
3400 ReleaseDC( infoPtr
->hwndSelf
, hdc
);
3408 REBAR_NotifyFormat (REBAR_INFO
*infoPtr
, LPARAM cmd
)
3412 if (cmd
== NF_REQUERY
) {
3413 i
= SendMessageW(REBAR_GetNotifyParent (infoPtr
),
3414 WM_NOTIFYFORMAT
, (WPARAM
)infoPtr
->hwndSelf
, NF_QUERY
);
3415 if ((i
!= NFR_ANSI
) && (i
!= NFR_UNICODE
)) {
3416 ERR("wrong response to WM_NOTIFYFORMAT (%d), assuming ANSI\n", i
);
3419 infoPtr
->bUnicode
= (i
== NFR_UNICODE
) ? 1 : 0;
3422 return (LRESULT
)((infoPtr
->bUnicode
) ? NFR_UNICODE
: NFR_ANSI
);
3427 REBAR_Paint (const REBAR_INFO
*infoPtr
, HDC hdc
)
3430 TRACE("painting\n");
3431 REBAR_Refresh (infoPtr
, hdc
);
3434 hdc
= BeginPaint (infoPtr
->hwndSelf
, &ps
);
3435 TRACE("painting (%s)\n", wine_dbgstr_rect(&ps
.rcPaint
));
3437 /* Erase area of paint if requested */
3438 REBAR_EraseBkGnd (infoPtr
, hdc
);
3440 REBAR_Refresh (infoPtr
, hdc
);
3441 EndPaint (infoPtr
->hwndSelf
, &ps
);
3449 REBAR_SetCursor (const REBAR_INFO
*infoPtr
, LPARAM lParam
)
3454 TRACE("code=0x%X id=0x%X\n", LOWORD(lParam
), HIWORD(lParam
));
3457 ScreenToClient (infoPtr
->hwndSelf
, &pt
);
3459 REBAR_InternalHitTest (infoPtr
, &pt
, &flags
, NULL
);
3461 if (flags
== RBHT_GRABBER
) {
3462 if ((infoPtr
->dwStyle
& CCS_VERT
) &&
3463 !(infoPtr
->dwStyle
& RBS_VERTICALGRIPPER
))
3464 SetCursor (infoPtr
->hcurVert
);
3466 SetCursor (infoPtr
->hcurHorz
);
3468 else if (flags
!= RBHT_CLIENT
)
3469 SetCursor (infoPtr
->hcurArrow
);
3476 REBAR_SetFont (REBAR_INFO
*infoPtr
, HFONT font
)
3481 infoPtr
->hFont
= font
;
3483 /* revalidate all bands to change sizes of text in headers of bands */
3484 for (i
=0; i
<infoPtr
->uNumBands
; i
++) {
3485 lpBand
= REBAR_GetBand(infoPtr
, i
);
3486 REBAR_ValidateBand (infoPtr
, lpBand
);
3489 REBAR_Layout(infoPtr
);
3494 /*****************************************************
3496 * Handles the WM_SETREDRAW message.
3499 * According to testing V4.71 of COMCTL32 returns the
3500 * *previous* status of the redraw flag (either 0 or -1)
3501 * instead of the MSDN documented value of 0 if handled
3503 *****************************************************/
3504 static inline LRESULT
3505 REBAR_SetRedraw (REBAR_INFO
*infoPtr
, BOOL redraw
)
3507 BOOL oldredraw
= infoPtr
->DoRedraw
;
3509 TRACE("set to %s, fStatus=%08x\n",
3510 (redraw
) ? "TRUE" : "FALSE", infoPtr
->fStatus
);
3511 infoPtr
->DoRedraw
= redraw
;
3513 if (infoPtr
->fStatus
& BAND_NEEDS_REDRAW
) {
3514 REBAR_MoveChildWindows (infoPtr
, 0, infoPtr
->uNumBands
);
3515 REBAR_ForceResize (infoPtr
);
3516 InvalidateRect (infoPtr
->hwndSelf
, NULL
, TRUE
);
3518 infoPtr
->fStatus
&= ~BAND_NEEDS_REDRAW
;
3520 return (oldredraw
) ? -1 : 0;
3525 REBAR_Size (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
3527 TRACE("wParam=%lx, lParam=%lx\n", wParam
, lParam
);
3529 /* avoid _Layout resize recursion (but it shouldn't be infinite and it seems Windows does recurse) */
3530 if (infoPtr
->fStatus
& SELF_RESIZE
) {
3531 infoPtr
->fStatus
&= ~SELF_RESIZE
;
3532 TRACE("SELF_RESIZE was set, reset, fStatus=%08x lparam=%08lx\n",
3533 infoPtr
->fStatus
, lParam
);
3537 if (infoPtr
->dwStyle
& RBS_AUTOSIZE
)
3538 REBAR_AutoSize(infoPtr
, TRUE
);
3540 REBAR_Layout(infoPtr
);
3547 REBAR_StyleChanged (REBAR_INFO
*infoPtr
, INT nType
, const STYLESTRUCT
*lpStyle
)
3549 TRACE("current style=%08x, styleOld=%08x, style being set to=%08x\n",
3550 infoPtr
->dwStyle
, lpStyle
->styleOld
, lpStyle
->styleNew
);
3551 if (nType
== GWL_STYLE
)
3553 infoPtr
->orgStyle
= infoPtr
->dwStyle
= lpStyle
->styleNew
;
3554 if (GetWindowTheme (infoPtr
->hwndSelf
))
3555 infoPtr
->dwStyle
&= ~WS_BORDER
;
3556 /* maybe it should be COMMON_STYLES like in toolbar */
3557 if ((lpStyle
->styleNew
^ lpStyle
->styleOld
) & CCS_VERT
)
3558 REBAR_Layout(infoPtr
);
3563 /* update theme after a WM_THEMECHANGED message */
3564 static LRESULT
theme_changed (REBAR_INFO
* infoPtr
)
3566 HTHEME theme
= GetWindowTheme (infoPtr
->hwndSelf
);
3567 CloseThemeData (theme
);
3568 theme
= OpenThemeData (infoPtr
->hwndSelf
, themeClass
);
3569 /* WS_BORDER disappears when theming is enabled and reappears when
3571 infoPtr
->dwStyle
&= ~WS_BORDER
;
3572 infoPtr
->dwStyle
|= theme
? 0 : (infoPtr
->orgStyle
& WS_BORDER
);
3577 REBAR_WindowPosChanged (const REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
3582 ret
= DefWindowProcW(infoPtr
->hwndSelf
, WM_WINDOWPOSCHANGED
,
3584 GetWindowRect(infoPtr
->hwndSelf
, &rc
);
3585 TRACE("hwnd %p new pos (%s)\n", infoPtr
->hwndSelf
, wine_dbgstr_rect(&rc
));
3590 static LRESULT WINAPI
3591 REBAR_WindowProc (HWND hwnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
)
3593 REBAR_INFO
*infoPtr
= REBAR_GetInfoPtr (hwnd
);
3595 TRACE("hwnd=%p msg=%x wparam=%lx lparam=%lx\n",
3596 hwnd
, uMsg
, wParam
, lParam
);
3597 if (!infoPtr
&& (uMsg
!= WM_NCCREATE
))
3598 return DefWindowProcW (hwnd
, uMsg
, wParam
, lParam
);
3601 /* case RB_BEGINDRAG: */
3604 return REBAR_DeleteBand (infoPtr
, wParam
);
3606 /* case RB_DRAGMOVE: */
3607 /* case RB_ENDDRAG: */
3609 case RB_GETBANDBORDERS
:
3610 return REBAR_GetBandBorders (infoPtr
, wParam
, (LPRECT
)lParam
);
3612 case RB_GETBANDCOUNT
:
3613 return REBAR_GetBandCount (infoPtr
);
3615 case RB_GETBANDINFO_OLD
:
3616 case RB_GETBANDINFOA
:
3617 case RB_GETBANDINFOW
:
3618 return REBAR_GetBandInfoT(infoPtr
, wParam
, (LPREBARBANDINFOW
)lParam
,
3619 uMsg
== RB_GETBANDINFOW
);
3620 case RB_GETBARHEIGHT
:
3621 return REBAR_GetBarHeight (infoPtr
);
3624 return REBAR_GetBarInfo (infoPtr
, (LPREBARINFO
)lParam
);
3627 return REBAR_GetBkColor (infoPtr
);
3629 /* case RB_GETCOLORSCHEME: */
3630 /* case RB_GETDROPTARGET: */
3633 return REBAR_GetPalette (infoPtr
);
3636 return REBAR_GetRect (infoPtr
, wParam
, (LPRECT
)lParam
);
3638 case RB_GETROWCOUNT
:
3639 return REBAR_GetRowCount (infoPtr
);
3641 case RB_GETROWHEIGHT
:
3642 return REBAR_GetRowHeight (infoPtr
, wParam
);
3644 case RB_GETTEXTCOLOR
:
3645 return REBAR_GetTextColor (infoPtr
);
3647 case RB_GETTOOLTIPS
:
3648 return REBAR_GetToolTips (infoPtr
);
3650 case RB_GETUNICODEFORMAT
:
3651 return REBAR_GetUnicodeFormat (infoPtr
);
3653 case CCM_GETVERSION
:
3654 return REBAR_GetVersion (infoPtr
);
3657 return REBAR_HitTest (infoPtr
, (LPRBHITTESTINFO
)lParam
);
3660 return REBAR_IdToIndex (infoPtr
, wParam
);
3662 case RB_INSERTBANDA
:
3663 case RB_INSERTBANDW
:
3664 return REBAR_InsertBandT(infoPtr
, wParam
, (LPREBARBANDINFOW
)lParam
,
3665 uMsg
== RB_INSERTBANDW
);
3666 case RB_MAXIMIZEBAND
:
3667 return REBAR_MaximizeBand (infoPtr
, wParam
, lParam
);
3669 case RB_MINIMIZEBAND
:
3670 return REBAR_MinimizeBand (infoPtr
, wParam
);
3673 return REBAR_MoveBand (infoPtr
, wParam
, lParam
);
3675 case RB_PUSHCHEVRON
:
3676 return REBAR_PushChevron (infoPtr
, wParam
, lParam
);
3678 case RB_SETBANDINFOA
:
3679 case RB_SETBANDINFOW
:
3680 return REBAR_SetBandInfoT(infoPtr
, wParam
, (LPREBARBANDINFOW
)lParam
,
3681 uMsg
== RB_SETBANDINFOW
);
3683 return REBAR_SetBarInfo (infoPtr
, (LPREBARINFO
)lParam
);
3686 return REBAR_SetBkColor (infoPtr
, lParam
);
3688 /* case RB_SETCOLORSCHEME: */
3689 /* case RB_SETPALETTE: */
3692 return REBAR_SetParent (infoPtr
, (HWND
)wParam
);
3694 case RB_SETTEXTCOLOR
:
3695 return REBAR_SetTextColor (infoPtr
, lParam
);
3697 /* case RB_SETTOOLTIPS: */
3699 case RB_SETUNICODEFORMAT
:
3700 return REBAR_SetUnicodeFormat (infoPtr
, wParam
);
3702 case CCM_SETVERSION
:
3703 return REBAR_SetVersion (infoPtr
, (INT
)wParam
);
3706 return REBAR_ShowBand (infoPtr
, wParam
, lParam
);
3709 return REBAR_SizeToRect (infoPtr
, (LPCRECT
)lParam
);
3712 /* Messages passed to parent */
3716 return SendMessageW(REBAR_GetNotifyParent (infoPtr
), uMsg
, wParam
, lParam
);
3719 /* case WM_CHARTOITEM: supported according to ControlSpy */
3722 return REBAR_Create (infoPtr
, (LPCREATESTRUCTW
)lParam
);
3725 return REBAR_Destroy (infoPtr
);
3728 return REBAR_EraseBkGnd (infoPtr
, (HDC
)wParam
);
3731 return REBAR_GetFont (infoPtr
);
3733 /* case WM_LBUTTONDBLCLK: supported according to ControlSpy */
3735 case WM_LBUTTONDOWN
:
3736 return REBAR_LButtonDown (infoPtr
, lParam
);
3739 return REBAR_LButtonUp (infoPtr
);
3741 /* case WM_MEASUREITEM: supported according to ControlSpy */
3744 return REBAR_MouseMove (infoPtr
, lParam
);
3747 return REBAR_MouseLeave (infoPtr
);
3750 return REBAR_NCCalcSize (infoPtr
, (RECT
*)lParam
);
3753 return REBAR_NCCreate (hwnd
, (LPCREATESTRUCTW
)lParam
);
3756 return REBAR_NCHitTest (infoPtr
, lParam
);
3759 return REBAR_NCPaint (infoPtr
);
3761 case WM_NOTIFYFORMAT
:
3762 return REBAR_NotifyFormat (infoPtr
, lParam
);
3764 case WM_PRINTCLIENT
:
3766 return REBAR_Paint (infoPtr
, (HDC
)wParam
);
3768 /* case WM_PALETTECHANGED: supported according to ControlSpy */
3769 /* case WM_QUERYNEWPALETTE:supported according to ControlSpy */
3770 /* case WM_RBUTTONDOWN: supported according to ControlSpy */
3771 /* case WM_RBUTTONUP: supported according to ControlSpy */
3774 return REBAR_SetCursor (infoPtr
, lParam
);
3777 return REBAR_SetFont (infoPtr
, (HFONT
)wParam
);
3780 return REBAR_SetRedraw (infoPtr
, wParam
);
3783 return REBAR_Size (infoPtr
, wParam
, lParam
);
3785 case WM_STYLECHANGED
:
3786 return REBAR_StyleChanged (infoPtr
, wParam
, (LPSTYLESTRUCT
)lParam
);
3788 case WM_THEMECHANGED
:
3789 return theme_changed (infoPtr
);
3791 case WM_SYSCOLORCHANGE
:
3792 COMCTL32_RefreshSysColors();
3793 infoPtr
->clrBtnText
= comctl32_color
.clrBtnText
;
3794 infoPtr
->clrBtnFace
= comctl32_color
.clrBtnFace
;
3797 /* case WM_VKEYTOITEM: supported according to ControlSpy */
3798 /* case WM_WININICHANGE: */
3800 case WM_WINDOWPOSCHANGED
:
3801 return REBAR_WindowPosChanged (infoPtr
, wParam
, lParam
);
3804 if ((uMsg
>= WM_USER
) && (uMsg
< WM_APP
) && !COMCTL32_IsReflectedMessage(uMsg
))
3805 ERR("unknown msg %04x wp=%08lx lp=%08lx\n",
3806 uMsg
, wParam
, lParam
);
3807 return DefWindowProcW (hwnd
, uMsg
, wParam
, lParam
);
3813 REBAR_Register (void)
3817 ZeroMemory (&wndClass
, sizeof(WNDCLASSW
));
3818 wndClass
.style
= CS_GLOBALCLASS
| CS_DBLCLKS
;
3819 wndClass
.lpfnWndProc
= REBAR_WindowProc
;
3820 wndClass
.cbClsExtra
= 0;
3821 wndClass
.cbWndExtra
= sizeof(REBAR_INFO
*);
3822 wndClass
.hCursor
= 0;
3823 wndClass
.hbrBackground
= (HBRUSH
)(COLOR_BTNFACE
+ 1);
3825 wndClass
.hbrBackground
= CreateSolidBrush(RGB(0,128,0));
3827 wndClass
.lpszClassName
= REBARCLASSNAMEW
;
3829 RegisterClassW (&wndClass
);
3831 mindragx
= GetSystemMetrics (SM_CXDRAG
);
3832 mindragy
= GetSystemMetrics (SM_CYDRAG
);
3838 REBAR_Unregister (void)
3840 UnregisterClassW (REBARCLASSNAMEW
, NULL
);