4 * Copyright 1998, 1999 Eric Kohl
5 * Copyright 2007, 2008 Mikolaj Zalewski
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
23 * This code was audited for completeness against the documented features
24 * of Comctl32.dll version 6.0 on Oct. 19, 2004, by Robert Shearman.
26 * Unless otherwise noted, we believe this code to be complete, as per
27 * the specification mentioned above.
28 * If you discover missing features or bugs please note them below.
50 * - WM_QUERYNEWPALETTE
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 */
140 /* has a value of: 0, CCS_TOP, CCS_NOMOVEY, CCS_BOTTOM */
141 #define CCS_LAYOUT_MASK 0x3
144 #define HAS_GRIPPER 0x00000001
145 #define HAS_IMAGE 0x00000002
146 #define HAS_TEXT 0x00000004
149 #define DRAW_GRIPPER 0x00000001
150 #define DRAW_IMAGE 0x00000002
151 #define DRAW_TEXT 0x00000004
152 #define DRAW_CHEVRONHOT 0x00000040
153 #define DRAW_CHEVRONPUSHED 0x00000080
154 #define NTF_INVALIDATE 0x01000000
158 COLORREF clrBk
; /* background color */
159 COLORREF clrText
; /* text color */
160 COLORREF clrBtnText
; /* system color for BTNTEXT */
161 COLORREF clrBtnFace
; /* system color for BTNFACE */
162 HIMAGELIST himl
; /* handle to imagelist */
163 UINT uNumBands
; /* # of bands in rebar (first=0, last=uNumBands-1 */
164 UINT uNumRows
; /* # of rows of bands (first=1, last=uNumRows */
165 HWND hwndSelf
; /* handle of REBAR window itself */
166 HWND hwndToolTip
; /* handle to the tool tip control */
167 HWND hwndNotify
; /* notification window (parent) */
169 HFONT hFont
; /* handle to the rebar's font */
170 SIZE imageSize
; /* image size (image list) */
171 DWORD dwStyle
; /* window style */
172 DWORD orgStyle
; /* original style (dwStyle may change) */
173 SIZE calcSize
; /* calculated rebar size - coordinates swapped for CCS_VERT */
174 BOOL bUnicode
; /* TRUE if parent wants notify in W format */
175 BOOL DoRedraw
; /* TRUE to actually draw bands */
176 UINT fStatus
; /* Status flags (see below) */
177 HCURSOR hcurArrow
; /* handle to the arrow cursor */
178 HCURSOR hcurHorz
; /* handle to the EW cursor */
179 HCURSOR hcurVert
; /* handle to the NS cursor */
180 HCURSOR hcurDrag
; /* handle to the drag cursor */
181 INT iVersion
; /* version number */
182 POINT dragStart
; /* x,y of button down */
183 POINT dragNow
; /* x,y of this MouseMove */
184 INT iOldBand
; /* last band that had the mouse cursor over it */
185 INT ihitoffset
; /* offset of hotspot from gripper.left */
186 INT ichevronhotBand
; /* last band that had a hot chevron */
187 INT iGrabbedBand
;/* band number of band whose gripper was grabbed */
189 HDPA bands
; /* pointer to the array of rebar bands */
193 #define BEGIN_DRAG_ISSUED 0x00000001
194 #define SELF_RESIZE 0x00000002
195 #define BAND_NEEDS_REDRAW 0x00000020
197 /* used by Windows to mark that the header size has been set by the user and shouldn't be changed */
198 #define RBBS_UNDOC_FIXEDHEADER 0x40000000
200 /* ---- REBAR layout constants. Mostly determined by ---- */
201 /* ---- experiment on WIN 98. ---- */
203 /* Width (or height) of separators between bands (either horz. or */
204 /* vert.). True only if RBS_BANDBORDERS is set */
205 #define SEP_WIDTH_SIZE 2
206 #define SEP_WIDTH ((infoPtr->dwStyle & RBS_BANDBORDERS) ? SEP_WIDTH_SIZE : 0)
208 /* Blank (background color) space between Gripper (if present) */
209 /* and next item (image, text, or window). Always present */
210 #define REBAR_ALWAYS_SPACE 4
212 /* Blank (background color) space after Image (if present). */
213 #define REBAR_POST_IMAGE 2
215 /* Blank (background color) space after Text (if present). */
216 #define REBAR_POST_TEXT 4
218 /* Height of vertical gripper in a CCS_VERT rebar. */
219 #define GRIPPER_HEIGHT 16
221 /* Blank (background color) space before Gripper (if present). */
222 #define REBAR_PRE_GRIPPER 2
224 /* Width (of normal vertical gripper) or height (of horz. gripper) */
226 #define GRIPPER_WIDTH 3
228 /* Width of the chevron button if present */
229 #define CHEVRON_WIDTH 10
231 /* the gap between the child and the next band */
232 #define REBAR_POST_CHILD 4
234 /* Height of divider for Rebar if not disabled (CCS_NODIVIDER) */
235 /* either top or bottom */
236 #define REBAR_DIVIDER 2
238 /* height of a rebar without a child */
239 #define REBAR_NO_CHILD_HEIGHT 4
241 /* minimum vertical height of a normal bar */
242 /* or minimum width of a CCS_VERT bar - from experiment on Win2k */
243 #define REBAR_MINSIZE 23
245 /* This is the increment that is used over the band height */
246 #define REBARSPACE(a) ((a->fStyle & RBBS_CHILDEDGE) ? 2*REBAR_DIVIDER : 0)
248 /* ---- End of REBAR layout constants. ---- */
250 #define RB_GETBANDINFO_OLD (WM_USER+5) /* obsoleted after IE3, but we have to support it anyway */
252 /* The following define determines if a given band is hidden */
253 #define HIDDENBAND(a) (((a)->fStyle & RBBS_HIDDEN) || \
254 ((infoPtr->dwStyle & CCS_VERT) && \
255 ((a)->fStyle & RBBS_NOVERT)))
257 #define REBAR_GetInfoPtr(wndPtr) ((REBAR_INFO *)GetWindowLongPtrW (hwnd, 0))
259 static LRESULT
REBAR_NotifyFormat(REBAR_INFO
*infoPtr
, LPARAM lParam
);
260 static void REBAR_AutoSize(REBAR_INFO
*infoPtr
, BOOL needsLayout
);
262 /* no index check here */
263 static inline REBAR_BAND
* REBAR_GetBand(const REBAR_INFO
*infoPtr
, INT i
)
265 assert(i
>= 0 && i
< infoPtr
->uNumBands
);
266 return DPA_GetPtr(infoPtr
->bands
, i
);
269 /* "constant values" retrieved when DLL was initialized */
270 /* FIXME we do this when the classes are registered. */
271 static UINT mindragx
= 0;
272 static UINT mindragy
= 0;
274 static const char * const band_stylename
[] = {
275 "RBBS_BREAK", /* 0001 */
276 "RBBS_FIXEDSIZE", /* 0002 */
277 "RBBS_CHILDEDGE", /* 0004 */
278 "RBBS_HIDDEN", /* 0008 */
279 "RBBS_NOVERT", /* 0010 */
280 "RBBS_FIXEDBMP", /* 0020 */
281 "RBBS_VARIABLEHEIGHT", /* 0040 */
282 "RBBS_GRIPPERALWAYS", /* 0080 */
283 "RBBS_NOGRIPPER", /* 0100 */
286 static const char * const band_maskname
[] = {
287 "RBBIM_STYLE", /* 0x00000001 */
288 "RBBIM_COLORS", /* 0x00000002 */
289 "RBBIM_TEXT", /* 0x00000004 */
290 "RBBIM_IMAGE", /* 0x00000008 */
291 "RBBIM_CHILD", /* 0x00000010 */
292 "RBBIM_CHILDSIZE", /* 0x00000020 */
293 "RBBIM_SIZE", /* 0x00000040 */
294 "RBBIM_BACKGROUND", /* 0x00000080 */
295 "RBBIM_ID", /* 0x00000100 */
296 "RBBIM_IDEALSIZE", /* 0x00000200 */
297 "RBBIM_LPARAM", /* 0x00000400 */
298 "RBBIM_HEADERSIZE", /* 0x00000800 */
302 static CHAR line
[200];
304 static const WCHAR themeClass
[] = { 'R','e','b','a','r',0 };
307 REBAR_FmtStyle( UINT style
)
312 while (band_stylename
[i
]) {
313 if (style
& (1<<i
)) {
314 if (*line
!= 0) strcat(line
, " | ");
315 strcat(line
, band_stylename
[i
]);
324 REBAR_FmtMask( UINT mask
)
329 while (band_maskname
[i
]) {
331 if (*line
!= 0) strcat(line
, " | ");
332 strcat(line
, band_maskname
[i
]);
341 REBAR_DumpBandInfo(const REBARBANDINFOW
*pB
)
343 if( !TRACE_ON(rebar
) ) return;
344 TRACE("band info: ");
345 if (pB
->fMask
& RBBIM_ID
)
346 TRACE("ID=%u, ", pB
->wID
);
347 TRACE("size=%u, child=%p", pB
->cbSize
, pB
->hwndChild
);
348 if (pB
->fMask
& RBBIM_COLORS
)
349 TRACE(", clrF=0x%06x, clrB=0x%06x", pB
->clrFore
, pB
->clrBack
);
352 TRACE("band info: mask=0x%08x (%s)\n", pB
->fMask
, REBAR_FmtMask(pB
->fMask
));
353 if (pB
->fMask
& RBBIM_STYLE
)
354 TRACE("band info: style=0x%08x (%s)\n", pB
->fStyle
, REBAR_FmtStyle(pB
->fStyle
));
355 if (pB
->fMask
& (RBBIM_SIZE
| RBBIM_IDEALSIZE
| RBBIM_HEADERSIZE
| RBBIM_LPARAM
)) {
357 if (pB
->fMask
& RBBIM_SIZE
)
358 TRACE(" cx=%u", pB
->cx
);
359 if (pB
->fMask
& RBBIM_IDEALSIZE
)
360 TRACE(" xIdeal=%u", pB
->cxIdeal
);
361 if (pB
->fMask
& RBBIM_HEADERSIZE
)
362 TRACE(" xHeader=%u", pB
->cxHeader
);
363 if (pB
->fMask
& RBBIM_LPARAM
)
364 TRACE(" lParam=0x%08lx", pB
->lParam
);
367 if (pB
->fMask
& RBBIM_CHILDSIZE
)
368 TRACE("band info: xMin=%u, yMin=%u, yChild=%u, yMax=%u, yIntgl=%u\n",
370 pB
->cyMinChild
, pB
->cyChild
, pB
->cyMaxChild
, pB
->cyIntegral
);
374 REBAR_DumpBand (const REBAR_INFO
*iP
)
379 if(! TRACE_ON(rebar
) ) return;
381 TRACE("hwnd=%p: color=%08x/%08x, bands=%u, rows=%u, cSize=%d,%d\n",
382 iP
->hwndSelf
, iP
->clrText
, iP
->clrBk
, iP
->uNumBands
, iP
->uNumRows
,
383 iP
->calcSize
.cx
, iP
->calcSize
.cy
);
384 TRACE("hwnd=%p: flags=%08x, dragStart=%d,%d, dragNow=%d,%d, iGrabbedBand=%d\n",
385 iP
->hwndSelf
, iP
->fStatus
, iP
->dragStart
.x
, iP
->dragStart
.y
,
386 iP
->dragNow
.x
, iP
->dragNow
.y
,
388 TRACE("hwnd=%p: style=%08x, notify in Unicode=%s, redraw=%s\n",
389 iP
->hwndSelf
, iP
->dwStyle
, (iP
->bUnicode
)?"TRUE":"FALSE",
390 (iP
->DoRedraw
)?"TRUE":"FALSE");
391 for (i
= 0; i
< iP
->uNumBands
; i
++) {
392 pB
= REBAR_GetBand(iP
, i
);
393 TRACE("band # %u:", i
);
394 if (pB
->fMask
& RBBIM_ID
)
395 TRACE(" ID=%u", pB
->wID
);
396 if (pB
->fMask
& RBBIM_CHILD
)
397 TRACE(" child=%p", pB
->hwndChild
);
398 if (pB
->fMask
& RBBIM_COLORS
)
399 TRACE(" clrF=0x%06x clrB=0x%06x", pB
->clrFore
, pB
->clrBack
);
401 TRACE("band # %u: mask=0x%08x (%s)\n", i
, pB
->fMask
, REBAR_FmtMask(pB
->fMask
));
402 if (pB
->fMask
& RBBIM_STYLE
)
403 TRACE("band # %u: style=0x%08x (%s)\n",
404 i
, pB
->fStyle
, REBAR_FmtStyle(pB
->fStyle
));
405 TRACE("band # %u: xHeader=%u",
407 if (pB
->fMask
& (RBBIM_SIZE
| RBBIM_IDEALSIZE
| RBBIM_LPARAM
)) {
408 if (pB
->fMask
& RBBIM_SIZE
)
409 TRACE(" cx=%u", pB
->cx
);
410 if (pB
->fMask
& RBBIM_IDEALSIZE
)
411 TRACE(" xIdeal=%u", pB
->cxIdeal
);
412 if (pB
->fMask
& RBBIM_LPARAM
)
413 TRACE(" lParam=0x%08lx", pB
->lParam
);
417 TRACE("band # %u: xMin=%u, yMin=%u, yChild=%u, yMax=%u, yIntgl=%u\n",
418 i
, pB
->cxMinChild
, pB
->cyMinChild
, pB
->cyChild
, pB
->cyMaxChild
, pB
->cyIntegral
);
419 if (pB
->fMask
& RBBIM_TEXT
)
420 TRACE("band # %u: text=%s\n",
421 i
, (pB
->lpText
) ? debugstr_w(pB
->lpText
) : "(null)");
422 TRACE("band # %u: cxMinBand=%u, cxEffective=%u, cyMinBand=%u\n",
423 i
, pB
->cxMinBand
, pB
->cxEffective
, pB
->cyMinBand
);
424 TRACE("band # %u: fStatus=%08x, fDraw=%08x, Band=(%s), Grip=(%s)\n",
425 i
, pB
->fStatus
, pB
->fDraw
, wine_dbgstr_rect(&pB
->rcBand
),
426 wine_dbgstr_rect(&pB
->rcGripper
));
427 TRACE("band # %u: Img=(%s), Txt=(%s), Child=(%s)\n",
428 i
, wine_dbgstr_rect(&pB
->rcCapImage
),
429 wine_dbgstr_rect(&pB
->rcCapText
), wine_dbgstr_rect(&pB
->rcChild
));
434 /* dest can be equal to src */
435 static void translate_rect(const REBAR_INFO
*infoPtr
, RECT
*dest
, const RECT
*src
)
437 if (infoPtr
->dwStyle
& CCS_VERT
) {
440 dest
->left
= src
->top
;
444 dest
->right
= src
->bottom
;
451 static int get_rect_cx(const REBAR_INFO
*infoPtr
, const RECT
*lpRect
)
453 if (infoPtr
->dwStyle
& CCS_VERT
)
454 return lpRect
->bottom
- lpRect
->top
;
455 return lpRect
->right
- lpRect
->left
;
458 static int get_rect_cy(const REBAR_INFO
*infoPtr
, const RECT
*lpRect
)
460 if (infoPtr
->dwStyle
& CCS_VERT
)
461 return lpRect
->right
- lpRect
->left
;
462 return lpRect
->bottom
- lpRect
->top
;
465 static int round_child_height(const REBAR_BAND
*lpBand
, int cyHeight
)
468 if (lpBand
->cyIntegral
== 0)
470 cy
= max(cyHeight
- (int)lpBand
->cyMinChild
, 0);
471 cy
= lpBand
->cyMinChild
+ (cy
/lpBand
->cyIntegral
) * lpBand
->cyIntegral
;
472 cy
= min(cy
, lpBand
->cyMaxChild
);
476 static void update_min_band_height(const REBAR_INFO
*infoPtr
, REBAR_BAND
*lpBand
)
478 lpBand
->cyMinBand
= max(lpBand
->cyHeader
,
479 (lpBand
->hwndChild
? lpBand
->cyChild
+ REBARSPACE(lpBand
) : REBAR_NO_CHILD_HEIGHT
));
483 REBAR_DrawChevron (HDC hdc
, INT left
, INT top
, INT colorRef
)
488 if (!(hPen
= CreatePen( PS_SOLID
, 1, GetSysColor( colorRef
)))) return;
489 hOldPen
= SelectObject ( hdc
, hPen
);
492 MoveToEx (hdc
, x
, y
, NULL
);
493 LineTo (hdc
, x
+5, y
++); x
++;
494 MoveToEx (hdc
, x
, y
, NULL
);
495 LineTo (hdc
, x
+3, y
++); x
++;
496 MoveToEx (hdc
, x
, y
, NULL
);
497 LineTo (hdc
, x
+1, y
);
498 SelectObject( hdc
, hOldPen
);
499 DeleteObject( hPen
);
503 REBAR_GetNotifyParent (const REBAR_INFO
*infoPtr
)
507 parent
= infoPtr
->hwndNotify
;
509 parent
= GetParent (infoPtr
->hwndSelf
);
510 owner
= GetWindow (infoPtr
->hwndSelf
, GW_OWNER
);
511 if (owner
) parent
= owner
;
518 REBAR_Notify (NMHDR
*nmhdr
, const REBAR_INFO
*infoPtr
, UINT code
)
522 parent
= REBAR_GetNotifyParent (infoPtr
);
523 nmhdr
->idFrom
= GetDlgCtrlID (infoPtr
->hwndSelf
);
524 nmhdr
->hwndFrom
= infoPtr
->hwndSelf
;
527 TRACE("window %p, code=%08x, via %s\n", parent
, code
, (infoPtr
->bUnicode
)?"Unicode":"ANSI");
529 return SendMessageW(parent
, WM_NOTIFY
, nmhdr
->idFrom
, (LPARAM
)nmhdr
);
533 REBAR_Notify_NMREBAR (const REBAR_INFO
*infoPtr
, UINT uBand
, UINT code
)
535 NMREBAR notify_rebar
;
537 notify_rebar
.dwMask
= 0;
539 REBAR_BAND
*lpBand
= REBAR_GetBand(infoPtr
, uBand
);
541 if (lpBand
->fMask
& RBBIM_ID
) {
542 notify_rebar
.dwMask
|= RBNM_ID
;
543 notify_rebar
.wID
= lpBand
->wID
;
545 if (lpBand
->fMask
& RBBIM_LPARAM
) {
546 notify_rebar
.dwMask
|= RBNM_LPARAM
;
547 notify_rebar
.lParam
= lpBand
->lParam
;
549 if (lpBand
->fMask
& RBBIM_STYLE
) {
550 notify_rebar
.dwMask
|= RBNM_STYLE
;
551 notify_rebar
.fStyle
= lpBand
->fStyle
;
554 notify_rebar
.uBand
= uBand
;
555 return REBAR_Notify ((NMHDR
*)¬ify_rebar
, infoPtr
, code
);
559 REBAR_DrawBand (HDC hdc
, const REBAR_INFO
*infoPtr
, REBAR_BAND
*lpBand
)
564 HTHEME theme
= GetWindowTheme (infoPtr
->hwndSelf
);
567 translate_rect(infoPtr
, &rcBand
, &lpBand
->rcBand
);
569 if (lpBand
->fDraw
& DRAW_TEXT
) {
570 hOldFont
= SelectObject (hdc
, infoPtr
->hFont
);
571 oldBkMode
= SetBkMode (hdc
, TRANSPARENT
);
574 /* should test for CDRF_NOTIFYITEMDRAW here */
575 nmcd
.dwDrawStage
= CDDS_ITEMPREPAINT
;
578 nmcd
.rc
.right
= lpBand
->rcCapText
.right
;
579 nmcd
.rc
.bottom
= lpBand
->rcCapText
.bottom
;
580 nmcd
.dwItemSpec
= lpBand
->wID
;
582 nmcd
.lItemlParam
= lpBand
->lParam
;
583 lpBand
->uCDret
= REBAR_Notify ((NMHDR
*)&nmcd
, infoPtr
, NM_CUSTOMDRAW
);
584 if (lpBand
->uCDret
== CDRF_SKIPDEFAULT
) {
585 if (oldBkMode
!= TRANSPARENT
)
586 SetBkMode (hdc
, oldBkMode
);
587 SelectObject (hdc
, hOldFont
);
592 if (lpBand
->fDraw
& DRAW_GRIPPER
)
596 RECT rcGripper
= lpBand
->rcGripper
;
597 int partId
= (infoPtr
->dwStyle
& CCS_VERT
) ? RP_GRIPPERVERT
: RP_GRIPPER
;
598 GetThemeBackgroundExtent (theme
, hdc
, partId
, 0, &rcGripper
, &rcGripper
);
599 OffsetRect (&rcGripper
, lpBand
->rcGripper
.left
- rcGripper
.left
,
600 lpBand
->rcGripper
.top
- rcGripper
.top
);
601 DrawThemeBackground (theme
, hdc
, partId
, 0, &rcGripper
, NULL
);
604 DrawEdge (hdc
, &lpBand
->rcGripper
, BDR_RAISEDINNER
, BF_RECT
| BF_MIDDLE
);
607 /* draw caption image */
608 if (lpBand
->fDraw
& DRAW_IMAGE
) {
612 pt
.y
= (lpBand
->rcCapImage
.bottom
+ lpBand
->rcCapImage
.top
- infoPtr
->imageSize
.cy
)/2;
613 pt
.x
= (lpBand
->rcCapImage
.right
+ lpBand
->rcCapImage
.left
- infoPtr
->imageSize
.cx
)/2;
615 ImageList_Draw (infoPtr
->himl
, lpBand
->iImage
, hdc
,
620 /* draw caption text */
621 if (lpBand
->fDraw
& DRAW_TEXT
) {
622 /* need to handle CDRF_NEWFONT here */
623 INT oldBkMode
= SetBkMode (hdc
, TRANSPARENT
);
624 COLORREF oldcolor
= CLR_NONE
;
626 if (lpBand
->clrFore
!= CLR_NONE
) {
627 new = (lpBand
->clrFore
== CLR_DEFAULT
) ? infoPtr
->clrBtnText
:
629 oldcolor
= SetTextColor (hdc
, new);
631 DrawTextW (hdc
, lpBand
->lpText
, -1, &lpBand
->rcCapText
,
632 DT_CENTER
| DT_VCENTER
| DT_SINGLELINE
);
633 if (oldBkMode
!= TRANSPARENT
)
634 SetBkMode (hdc
, oldBkMode
);
635 if (lpBand
->clrFore
!= CLR_NONE
)
636 SetTextColor (hdc
, oldcolor
);
637 SelectObject (hdc
, hOldFont
);
640 if (!IsRectEmpty(&lpBand
->rcChevron
))
645 if (lpBand
->fDraw
& DRAW_CHEVRONPUSHED
)
646 stateId
= CHEVS_PRESSED
;
647 else if (lpBand
->fDraw
& DRAW_CHEVRONHOT
)
650 stateId
= CHEVS_NORMAL
;
651 DrawThemeBackground (theme
, hdc
, RP_CHEVRON
, stateId
, &lpBand
->rcChevron
, NULL
);
655 if (lpBand
->fDraw
& DRAW_CHEVRONPUSHED
)
657 DrawEdge(hdc
, &lpBand
->rcChevron
, BDR_SUNKENOUTER
, BF_RECT
| BF_MIDDLE
);
658 REBAR_DrawChevron(hdc
, lpBand
->rcChevron
.left
+1, lpBand
->rcChevron
.top
+ 11, COLOR_WINDOWFRAME
);
660 else if (lpBand
->fDraw
& DRAW_CHEVRONHOT
)
662 DrawEdge(hdc
, &lpBand
->rcChevron
, BDR_RAISEDINNER
, BF_RECT
| BF_MIDDLE
);
663 REBAR_DrawChevron(hdc
, lpBand
->rcChevron
.left
, lpBand
->rcChevron
.top
+ 10, COLOR_WINDOWFRAME
);
666 REBAR_DrawChevron(hdc
, lpBand
->rcChevron
.left
, lpBand
->rcChevron
.top
+ 10, COLOR_WINDOWFRAME
);
670 if (lpBand
->uCDret
== (CDRF_NOTIFYPOSTPAINT
| CDRF_NOTIFYITEMDRAW
)) {
671 nmcd
.dwDrawStage
= CDDS_ITEMPOSTPAINT
;
674 nmcd
.rc
.right
= lpBand
->rcCapText
.right
;
675 nmcd
.rc
.bottom
= lpBand
->rcCapText
.bottom
;
676 nmcd
.dwItemSpec
= lpBand
->wID
;
678 nmcd
.lItemlParam
= lpBand
->lParam
;
679 lpBand
->uCDret
= REBAR_Notify ((NMHDR
*)&nmcd
, infoPtr
, NM_CUSTOMDRAW
);
685 REBAR_Refresh (const REBAR_INFO
*infoPtr
, HDC hdc
)
690 if (!infoPtr
->DoRedraw
) return;
692 for (i
= 0; i
< infoPtr
->uNumBands
; i
++) {
693 lpBand
= REBAR_GetBand(infoPtr
, i
);
695 if (HIDDENBAND(lpBand
)) continue;
697 /* now draw the band */
698 TRACE("[%p] drawing band %i, flags=%08x\n",
699 infoPtr
->hwndSelf
, i
, lpBand
->fDraw
);
700 REBAR_DrawBand (hdc
, infoPtr
, lpBand
);
706 REBAR_CalcHorzBand (const REBAR_INFO
*infoPtr
, UINT rstart
, UINT rend
)
707 /* Function: this routine initializes all the rectangles in */
708 /* each band in a row to fit in the adjusted rcBand rect. */
709 /* *** Supports only Horizontal bars. *** */
715 for(i
=rstart
; i
<rend
; i
++){
716 lpBand
= REBAR_GetBand(infoPtr
, i
);
717 if (HIDDENBAND(lpBand
)) {
718 SetRect (&lpBand
->rcChild
,
719 lpBand
->rcBand
.right
, lpBand
->rcBand
.top
,
720 lpBand
->rcBand
.right
, lpBand
->rcBand
.bottom
);
724 /* set initial gripper rectangle */
725 SetRect (&lpBand
->rcGripper
, lpBand
->rcBand
.left
, lpBand
->rcBand
.top
,
726 lpBand
->rcBand
.left
, lpBand
->rcBand
.bottom
);
728 /* calculate gripper rectangle */
729 if ( lpBand
->fStatus
& HAS_GRIPPER
) {
730 lpBand
->fDraw
|= DRAW_GRIPPER
;
731 lpBand
->rcGripper
.left
+= REBAR_PRE_GRIPPER
;
732 lpBand
->rcGripper
.right
= lpBand
->rcGripper
.left
+ GRIPPER_WIDTH
;
733 InflateRect(&lpBand
->rcGripper
, 0, -2);
735 SetRect (&lpBand
->rcCapImage
,
736 lpBand
->rcGripper
.right
+REBAR_ALWAYS_SPACE
, lpBand
->rcBand
.top
,
737 lpBand
->rcGripper
.right
+REBAR_ALWAYS_SPACE
, lpBand
->rcBand
.bottom
);
739 else { /* no gripper will be drawn */
741 if (lpBand
->fStatus
& (HAS_IMAGE
| HAS_TEXT
))
742 /* if no gripper but either image or text, then leave space */
743 xoff
= REBAR_ALWAYS_SPACE
;
744 SetRect (&lpBand
->rcCapImage
,
745 lpBand
->rcBand
.left
+xoff
, lpBand
->rcBand
.top
,
746 lpBand
->rcBand
.left
+xoff
, lpBand
->rcBand
.bottom
);
749 /* image is visible */
750 if (lpBand
->fStatus
& HAS_IMAGE
) {
751 lpBand
->fDraw
|= DRAW_IMAGE
;
752 lpBand
->rcCapImage
.right
+= infoPtr
->imageSize
.cx
;
753 lpBand
->rcCapImage
.bottom
= lpBand
->rcCapImage
.top
+ infoPtr
->imageSize
.cy
;
755 /* set initial caption text rectangle */
756 SetRect (&lpBand
->rcCapText
,
757 lpBand
->rcCapImage
.right
+REBAR_POST_IMAGE
, lpBand
->rcBand
.top
+1,
758 lpBand
->rcBand
.left
+lpBand
->cxHeader
, lpBand
->rcBand
.bottom
-1);
761 /* set initial caption text rectangle */
762 SetRect (&lpBand
->rcCapText
, lpBand
->rcCapImage
.right
, lpBand
->rcBand
.top
+1,
763 lpBand
->rcBand
.left
+lpBand
->cxHeader
, lpBand
->rcBand
.bottom
-1);
766 /* text is visible */
767 if ((lpBand
->fStatus
& HAS_TEXT
) && !(lpBand
->fStyle
& RBBS_HIDETITLE
)) {
768 lpBand
->fDraw
|= DRAW_TEXT
;
769 lpBand
->rcCapText
.right
= max(lpBand
->rcCapText
.left
,
770 lpBand
->rcCapText
.right
-REBAR_POST_TEXT
);
773 /* set initial child window rectangle if there is a child */
774 if (lpBand
->hwndChild
) {
776 lpBand
->rcChild
.left
= lpBand
->rcBand
.left
+ lpBand
->cxHeader
;
777 lpBand
->rcChild
.right
= lpBand
->rcBand
.right
- REBAR_POST_CHILD
;
779 if (lpBand
->cyChild
> 0) {
781 UINT yoff
= (lpBand
->rcBand
.bottom
- lpBand
->rcBand
.top
- lpBand
->cyChild
) / 2;
783 /* center child if height is known */
784 lpBand
->rcChild
.top
= lpBand
->rcBand
.top
+ yoff
;
785 lpBand
->rcChild
.bottom
= lpBand
->rcBand
.top
+ yoff
+ lpBand
->cyChild
;
788 lpBand
->rcChild
.top
= lpBand
->rcBand
.top
;
789 lpBand
->rcChild
.bottom
= lpBand
->rcBand
.bottom
;
792 if ((lpBand
->fStyle
& RBBS_USECHEVRON
) && (lpBand
->rcChild
.right
- lpBand
->rcChild
.left
< lpBand
->cxIdeal
))
794 lpBand
->rcChild
.right
-= CHEVRON_WIDTH
;
795 SetRect(&lpBand
->rcChevron
, lpBand
->rcChild
.right
,
796 lpBand
->rcChild
.top
, lpBand
->rcChild
.right
+ CHEVRON_WIDTH
,
797 lpBand
->rcChild
.bottom
);
801 SetRect (&lpBand
->rcChild
,
802 lpBand
->rcBand
.left
+lpBand
->cxHeader
, lpBand
->rcBand
.top
,
803 lpBand
->rcBand
.right
, lpBand
->rcBand
.bottom
);
806 /* flag if notify required and invalidate rectangle */
807 if (lpBand
->fDraw
& NTF_INVALIDATE
) {
808 lpBand
->fDraw
&= ~NTF_INVALIDATE
;
809 work
= lpBand
->rcBand
;
810 work
.right
+= SEP_WIDTH
;
811 work
.bottom
+= SEP_WIDTH
;
812 TRACE("invalidating %s\n", wine_dbgstr_rect(&work
));
813 InvalidateRect(infoPtr
->hwndSelf
, &work
, TRUE
);
814 if (lpBand
->hwndChild
) InvalidateRect(lpBand
->hwndChild
, NULL
, TRUE
);
823 REBAR_CalcVertBand (const REBAR_INFO
*infoPtr
, UINT rstart
, UINT rend
)
824 /* Function: this routine initializes all the rectangles in */
825 /* each band in a row to fit in the adjusted rcBand rect. */
826 /* *** Supports only Vertical bars. *** */
832 for(i
=rstart
; i
<rend
; i
++){
834 lpBand
= REBAR_GetBand(infoPtr
, i
);
835 if (HIDDENBAND(lpBand
)) continue;
837 translate_rect(infoPtr
, &rcBand
, &lpBand
->rcBand
);
839 /* set initial gripper rectangle */
840 SetRect (&lpBand
->rcGripper
, rcBand
.left
, rcBand
.top
, rcBand
.right
, rcBand
.top
);
842 /* calculate gripper rectangle */
843 if (lpBand
->fStatus
& HAS_GRIPPER
) {
844 lpBand
->fDraw
|= DRAW_GRIPPER
;
846 if (infoPtr
->dwStyle
& RBS_VERTICALGRIPPER
) {
847 /* vertical gripper */
848 lpBand
->rcGripper
.left
+= 3;
849 lpBand
->rcGripper
.right
= lpBand
->rcGripper
.left
+ GRIPPER_WIDTH
;
850 lpBand
->rcGripper
.top
+= REBAR_PRE_GRIPPER
;
851 lpBand
->rcGripper
.bottom
= lpBand
->rcGripper
.top
+ GRIPPER_HEIGHT
;
853 /* initialize Caption image rectangle */
854 SetRect (&lpBand
->rcCapImage
, rcBand
.left
,
855 lpBand
->rcGripper
.bottom
+ REBAR_ALWAYS_SPACE
,
857 lpBand
->rcGripper
.bottom
+ REBAR_ALWAYS_SPACE
);
860 /* horizontal gripper */
861 InflateRect(&lpBand
->rcGripper
, -2, 0);
862 lpBand
->rcGripper
.top
+= REBAR_PRE_GRIPPER
;
863 lpBand
->rcGripper
.bottom
= lpBand
->rcGripper
.top
+ GRIPPER_WIDTH
;
865 /* initialize Caption image rectangle */
866 SetRect (&lpBand
->rcCapImage
, rcBand
.left
,
867 lpBand
->rcGripper
.bottom
+ REBAR_ALWAYS_SPACE
,
869 lpBand
->rcGripper
.bottom
+ REBAR_ALWAYS_SPACE
);
872 else { /* no gripper will be drawn */
874 if (lpBand
->fStatus
& (HAS_IMAGE
| HAS_TEXT
))
875 /* if no gripper but either image or text, then leave space */
876 xoff
= REBAR_ALWAYS_SPACE
;
877 /* initialize Caption image rectangle */
878 SetRect (&lpBand
->rcCapImage
,
879 rcBand
.left
, rcBand
.top
+xoff
,
880 rcBand
.right
, rcBand
.top
+xoff
);
883 /* image is visible */
884 if (lpBand
->fStatus
& HAS_IMAGE
) {
885 lpBand
->fDraw
|= DRAW_IMAGE
;
887 lpBand
->rcCapImage
.right
= lpBand
->rcCapImage
.left
+ infoPtr
->imageSize
.cx
;
888 lpBand
->rcCapImage
.bottom
+= infoPtr
->imageSize
.cy
;
890 /* set initial caption text rectangle */
891 SetRect (&lpBand
->rcCapText
,
892 rcBand
.left
, lpBand
->rcCapImage
.bottom
+REBAR_POST_IMAGE
,
893 rcBand
.right
, rcBand
.top
+lpBand
->cxHeader
);
896 /* set initial caption text rectangle */
897 SetRect (&lpBand
->rcCapText
,
898 rcBand
.left
, lpBand
->rcCapImage
.bottom
,
899 rcBand
.right
, rcBand
.top
+lpBand
->cxHeader
);
902 /* text is visible */
903 if ((lpBand
->fStatus
& HAS_TEXT
) && !(lpBand
->fStyle
& RBBS_HIDETITLE
)) {
904 lpBand
->fDraw
|= DRAW_TEXT
;
905 lpBand
->rcCapText
.bottom
= max(lpBand
->rcCapText
.top
,
906 lpBand
->rcCapText
.bottom
);
909 /* set initial child window rectangle if there is a child */
910 if (lpBand
->hwndChild
) {
911 int cxBand
= rcBand
.right
- rcBand
.left
;
912 xoff
= (cxBand
- lpBand
->cyChild
) / 2;
913 SetRect (&lpBand
->rcChild
,
914 rcBand
.left
+ xoff
, rcBand
.top
+ lpBand
->cxHeader
,
915 rcBand
.left
+ xoff
+ lpBand
->cyChild
, rcBand
.bottom
- REBAR_POST_CHILD
);
918 SetRect (&lpBand
->rcChild
,
919 rcBand
.left
, rcBand
.top
+lpBand
->cxHeader
,
920 rcBand
.right
, rcBand
.bottom
);
923 if (lpBand
->fDraw
& NTF_INVALIDATE
) {
924 lpBand
->fDraw
&= ~NTF_INVALIDATE
;
926 work
.bottom
+= SEP_WIDTH
;
927 work
.right
+= SEP_WIDTH
;
928 TRACE("invalidating %s\n", wine_dbgstr_rect(&work
));
929 InvalidateRect(infoPtr
->hwndSelf
, &work
, TRUE
);
930 if (lpBand
->hwndChild
) InvalidateRect(lpBand
->hwndChild
, NULL
, TRUE
);
938 REBAR_ForceResize (REBAR_INFO
*infoPtr
)
939 /* Function: This changes the size of the REBAR window to that */
940 /* calculated by REBAR_Layout. */
942 INT x
, y
, width
, height
;
943 INT xedge
= 0, yedge
= 0;
946 TRACE("new size [%d x %d]\n", infoPtr
->calcSize
.cx
, infoPtr
->calcSize
.cy
);
948 if (infoPtr
->dwStyle
& CCS_NORESIZE
)
951 if (infoPtr
->dwStyle
& WS_BORDER
)
953 xedge
= GetSystemMetrics(SM_CXEDGE
);
954 yedge
= GetSystemMetrics(SM_CYEDGE
);
955 /* swap for CCS_VERT? */
958 /* compute rebar window rect in parent client coordinates */
959 GetWindowRect(infoPtr
->hwndSelf
, &rcSelf
);
960 MapWindowPoints(HWND_DESKTOP
, GetParent(infoPtr
->hwndSelf
), (LPPOINT
)&rcSelf
, 2);
961 translate_rect(infoPtr
, &rcSelf
, &rcSelf
);
963 height
= infoPtr
->calcSize
.cy
+ 2*yedge
;
964 if (!(infoPtr
->dwStyle
& CCS_NOPARENTALIGN
)) {
968 width
= infoPtr
->calcSize
.cx
+ 2*xedge
;
969 y
= 0; /* quiet compiler warning */
970 switch ( infoPtr
->dwStyle
& CCS_LAYOUT_MASK
) {
971 case 0: /* shouldn't happen - see NCCreate */
973 y
= ((infoPtr
->dwStyle
& CCS_NODIVIDER
) ? 0 : REBAR_DIVIDER
) - yedge
;
979 GetClientRect(GetParent(infoPtr
->hwndSelf
), &rcParent
);
980 translate_rect(infoPtr
, &rcParent
, &rcParent
);
981 y
= rcParent
.bottom
- infoPtr
->calcSize
.cy
- yedge
;
987 /* As on Windows if the CCS_NODIVIDER is not present the control will move
988 * 2 pixel down after every layout */
989 y
= rcSelf
.top
+ ((infoPtr
->dwStyle
& CCS_NODIVIDER
) ? 0 : REBAR_DIVIDER
);
990 width
= rcSelf
.right
- rcSelf
.left
;
993 TRACE("hwnd %p, style=%08x, setting at (%d,%d) for (%d,%d)\n",
994 infoPtr
->hwndSelf
, infoPtr
->dwStyle
, x
, y
, width
, height
);
996 /* Set flag to ignore next WM_SIZE message and resize the window */
997 infoPtr
->fStatus
|= SELF_RESIZE
;
998 if ((infoPtr
->dwStyle
& CCS_VERT
) == 0)
999 SetWindowPos(infoPtr
->hwndSelf
, 0, x
, y
, width
, height
, SWP_NOZORDER
);
1001 SetWindowPos(infoPtr
->hwndSelf
, 0, y
, x
, height
, width
, SWP_NOZORDER
);
1002 infoPtr
->fStatus
&= ~SELF_RESIZE
;
1007 REBAR_MoveChildWindows (const REBAR_INFO
*infoPtr
, UINT start
, UINT endplus
)
1009 static const WCHAR strComboBox
[] = { 'C','o','m','b','o','B','o','x',0 };
1011 WCHAR szClassName
[40];
1013 NMREBARCHILDSIZE rbcz
;
1016 if (!(deferpos
= BeginDeferWindowPos(infoPtr
->uNumBands
)))
1017 ERR("BeginDeferWindowPos returned NULL\n");
1019 for (i
= start
; i
< endplus
; i
++) {
1020 lpBand
= REBAR_GetBand(infoPtr
, i
);
1022 if (HIDDENBAND(lpBand
)) continue;
1023 if (lpBand
->hwndChild
) {
1024 TRACE("hwndChild = %p\n", lpBand
->hwndChild
);
1026 /* Always generate the RBN_CHILDSIZE even if child
1029 rbcz
.wID
= lpBand
->wID
;
1030 rbcz
.rcChild
= lpBand
->rcChild
;
1031 translate_rect(infoPtr
, &rbcz
.rcBand
, &lpBand
->rcBand
);
1032 if (infoPtr
->dwStyle
& CCS_VERT
)
1033 rbcz
.rcBand
.top
+= lpBand
->cxHeader
;
1035 rbcz
.rcBand
.left
+= lpBand
->cxHeader
;
1036 REBAR_Notify ((NMHDR
*)&rbcz
, infoPtr
, RBN_CHILDSIZE
);
1037 if (!EqualRect (&lpBand
->rcChild
, &rbcz
.rcChild
)) {
1038 TRACE("Child rect changed by NOTIFY for band %u\n", i
);
1039 TRACE(" from (%s) to (%s)\n",
1040 wine_dbgstr_rect(&lpBand
->rcChild
),
1041 wine_dbgstr_rect(&rbcz
.rcChild
));
1042 lpBand
->rcChild
= rbcz
.rcChild
; /* *** ??? */
1045 GetClassNameW (lpBand
->hwndChild
, szClassName
, sizeof(szClassName
)/sizeof(szClassName
[0]));
1046 if (!lstrcmpW (szClassName
, strComboBox
) ||
1047 !lstrcmpW (szClassName
, WC_COMBOBOXEXW
)) {
1048 INT nEditHeight
, yPos
;
1051 /* special placement code for combo or comboex box */
1054 /* get size of edit line */
1055 GetWindowRect (lpBand
->hwndChild
, &rc
);
1056 nEditHeight
= rc
.bottom
- rc
.top
;
1057 yPos
= (lpBand
->rcChild
.bottom
+ lpBand
->rcChild
.top
- nEditHeight
)/2;
1059 /* center combo box inside child area */
1060 TRACE("moving child (Combo(Ex)) %p to (%d,%d) for (%d,%d)\n",
1062 lpBand
->rcChild
.left
, yPos
,
1063 lpBand
->rcChild
.right
- lpBand
->rcChild
.left
,
1065 deferpos
= DeferWindowPos (deferpos
, lpBand
->hwndChild
, HWND_TOP
,
1066 lpBand
->rcChild
.left
,
1067 /*lpBand->rcChild.top*/ yPos
,
1068 lpBand
->rcChild
.right
- lpBand
->rcChild
.left
,
1072 ERR("DeferWindowPos returned NULL\n");
1075 TRACE("moving child (Other) %p to (%d,%d) for (%d,%d)\n",
1077 lpBand
->rcChild
.left
, lpBand
->rcChild
.top
,
1078 lpBand
->rcChild
.right
- lpBand
->rcChild
.left
,
1079 lpBand
->rcChild
.bottom
- lpBand
->rcChild
.top
);
1080 deferpos
= DeferWindowPos (deferpos
, lpBand
->hwndChild
, HWND_TOP
,
1081 lpBand
->rcChild
.left
,
1082 lpBand
->rcChild
.top
,
1083 lpBand
->rcChild
.right
- lpBand
->rcChild
.left
,
1084 lpBand
->rcChild
.bottom
- lpBand
->rcChild
.top
,
1087 ERR("DeferWindowPos returned NULL\n");
1091 if (!EndDeferWindowPos(deferpos
))
1092 ERR("EndDeferWindowPos returned NULL\n");
1094 if (infoPtr
->DoRedraw
)
1095 UpdateWindow (infoPtr
->hwndSelf
);
1098 /* Returns the next visible band (the first visible band in [i+1; infoPtr->uNumBands) )
1099 * or infoPtr->uNumBands if none */
1100 static int next_visible(const REBAR_INFO
*infoPtr
, int i
)
1103 for (n
= i
+ 1; n
< infoPtr
->uNumBands
; n
++)
1104 if (!HIDDENBAND(REBAR_GetBand(infoPtr
, n
)))
1109 /* Returns the previous visible band (the last visible band in [0; i) )
1111 static int prev_visible(const REBAR_INFO
*infoPtr
, int i
)
1114 for (n
= i
- 1; n
>= 0; n
--)
1115 if (!HIDDENBAND(REBAR_GetBand(infoPtr
, n
)))
1120 /* Returns the first visible band or infoPtr->uNumBands if none */
1121 static int first_visible(const REBAR_INFO
*infoPtr
)
1123 return next_visible(infoPtr
, -1); /* this works*/
1126 /* Returns the first visible band for the given row (or iBand if none) */
1127 static int get_row_begin_for_band(const REBAR_INFO
*infoPtr
, INT iBand
)
1129 int iLastBand
= iBand
;
1130 int iRow
= REBAR_GetBand(infoPtr
, iBand
)->iRow
;
1131 while ((iBand
= prev_visible(infoPtr
, iBand
)) >= 0) {
1132 if (REBAR_GetBand(infoPtr
, iBand
)->iRow
!= iRow
)
1140 /* Returns the first visible band for the next row (or infoPtr->uNumBands if none) */
1141 static int get_row_end_for_band(const REBAR_INFO
*infoPtr
, INT iBand
)
1143 int iRow
= REBAR_GetBand(infoPtr
, iBand
)->iRow
;
1144 while ((iBand
= next_visible(infoPtr
, iBand
)) < infoPtr
->uNumBands
)
1145 if (REBAR_GetBand(infoPtr
, iBand
)->iRow
!= iRow
)
1150 /* Compute the rcBand.{left,right} from the cxEffective bands widths computed earlier.
1151 * iBeginBand must be visible */
1152 static void REBAR_SetRowRectsX(const REBAR_INFO
*infoPtr
, INT iBeginBand
, INT iEndBand
)
1155 for (i
= iBeginBand
; i
< iEndBand
; i
= next_visible(infoPtr
, i
))
1157 REBAR_BAND
*lpBand
= REBAR_GetBand(infoPtr
, i
);
1158 if (lpBand
->rcBand
.left
!= xPos
|| lpBand
->rcBand
.right
!= xPos
+ lpBand
->cxEffective
) {
1159 lpBand
->fDraw
|= NTF_INVALIDATE
;
1160 TRACE("Setting rect %d to %d,%d\n", i
, xPos
, xPos
+ lpBand
->cxEffective
);
1161 lpBand
->rcBand
.left
= xPos
;
1162 lpBand
->rcBand
.right
= xPos
+ lpBand
->cxEffective
;
1164 xPos
+= lpBand
->cxEffective
+ SEP_WIDTH
;
1168 /* The rationale of this function is probably as follows: if we have some space
1169 * to distribute we want to add it to a band on the right. However we don't want
1170 * to unminimize a minimized band so we search for a band that is big enough.
1171 * For some reason "big enough" is defined as bigger than the minimum size of the
1172 * first band in the row
1174 static REBAR_BAND
*REBAR_FindBandToGrow(const REBAR_INFO
*infoPtr
, INT iBeginBand
, INT iEndBand
)
1176 INT cxMinFirstBand
= 0, i
;
1178 cxMinFirstBand
= REBAR_GetBand(infoPtr
, iBeginBand
)->cxMinBand
;
1180 for (i
= prev_visible(infoPtr
, iEndBand
); i
>= iBeginBand
; i
= prev_visible(infoPtr
, i
))
1181 if (REBAR_GetBand(infoPtr
, i
)->cxEffective
> cxMinFirstBand
&&
1182 !(REBAR_GetBand(infoPtr
, i
)->fStyle
& RBBS_FIXEDSIZE
))
1186 for (i
= prev_visible(infoPtr
, iEndBand
); i
>= iBeginBand
; i
= prev_visible(infoPtr
, i
))
1187 if (REBAR_GetBand(infoPtr
, i
)->cxMinBand
== cxMinFirstBand
)
1190 TRACE("Extra space for row [%d..%d) should be added to band %d\n", iBeginBand
, iEndBand
, i
);
1191 return REBAR_GetBand(infoPtr
, i
);
1194 /* Try to shrink the visible bands in [iBeginBand; iEndBand) by cxShrink, starting from the right */
1195 static int REBAR_ShrinkBandsRTL(const REBAR_INFO
*infoPtr
, INT iBeginBand
, INT iEndBand
, INT cxShrink
, BOOL bEnforce
)
1200 TRACE("Shrinking bands [%d..%d) by %d, right-to-left\n", iBeginBand
, iEndBand
, cxShrink
);
1201 for (i
= prev_visible(infoPtr
, iEndBand
); i
>= iBeginBand
; i
= prev_visible(infoPtr
, i
))
1203 lpBand
= REBAR_GetBand(infoPtr
, i
);
1205 width
= max(lpBand
->cxEffective
- cxShrink
, (int)lpBand
->cxMinBand
);
1206 cxShrink
-= lpBand
->cxEffective
- width
;
1207 lpBand
->cxEffective
= width
;
1208 if (bEnforce
&& lpBand
->cx
> lpBand
->cxEffective
)
1209 lpBand
->cx
= lpBand
->cxEffective
;
1217 /* Try to shrink the visible bands in [iBeginBand; iEndBand) by cxShrink, starting from the left.
1218 * iBeginBand must be visible */
1219 static int REBAR_ShrinkBandsLTR(const REBAR_INFO
*infoPtr
, INT iBeginBand
, INT iEndBand
, INT cxShrink
, BOOL bEnforce
)
1224 TRACE("Shrinking bands [%d..%d) by %d, left-to-right\n", iBeginBand
, iEndBand
, cxShrink
);
1225 for (i
= iBeginBand
; i
< iEndBand
; i
= next_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
;
1233 lpBand
->cx
= lpBand
->cxEffective
;
1240 /* Tries to move a band to a given offset within a row. */
1241 static int REBAR_MoveBandToRowOffset(REBAR_INFO
*infoPtr
, INT iBand
, INT iFirstBand
,
1242 INT iLastBand
, INT xOff
, BOOL reorder
)
1244 REBAR_BAND
*insertBand
= REBAR_GetBand(infoPtr
, iBand
);
1246 const BOOL setBreak
= REBAR_GetBand(infoPtr
, iFirstBand
)->fStyle
& RBBS_BREAK
;
1248 /* Find the band's new position */
1251 /* Used during an LR band reorder drag */
1252 for (i
= iFirstBand
; i
< iLastBand
; i
= next_visible(infoPtr
, i
))
1256 xPos
+= REBAR_GetBand(infoPtr
, i
)->cxEffective
+ SEP_WIDTH
;
1261 /* Used during a UD band insertion drag */
1262 for (i
= iFirstBand
; i
< iLastBand
; i
= next_visible(infoPtr
, i
))
1264 const REBAR_BAND
*band
= REBAR_GetBand(infoPtr
, i
);
1265 if(xPos
+ band
->cxMinBand
/ 2 > xOff
)
1267 xPos
+= band
->cxEffective
+ SEP_WIDTH
;
1271 /* Move the band to its new position */
1272 DPA_DeletePtr(infoPtr
->bands
, iBand
);
1275 DPA_InsertPtr(infoPtr
->bands
, i
, insertBand
);
1277 /* Ensure only the last band has the RBBS_BREAK flag set */
1278 insertBand
->fStyle
&= ~RBBS_BREAK
;
1280 REBAR_GetBand(infoPtr
, iFirstBand
)->fStyle
|= RBBS_BREAK
;
1282 /* Return the currently grabbed band */
1283 if(infoPtr
->iGrabbedBand
== iBand
)
1285 infoPtr
->iGrabbedBand
= i
;
1291 /* Set the heights of the visible bands in [iBeginBand; iEndBand) to the max height. iBeginBand must be visible */
1292 static int REBAR_SetBandsHeight(const REBAR_INFO
*infoPtr
, INT iBeginBand
, INT iEndBand
, INT yStart
)
1297 int row
= REBAR_GetBand(infoPtr
, iBeginBand
)->iRow
;
1299 for (i
= iBeginBand
; i
< iEndBand
; i
= next_visible(infoPtr
, i
))
1301 lpBand
= REBAR_GetBand(infoPtr
, i
);
1302 lpBand
->cyRowSoFar
= yMaxHeight
;
1303 yMaxHeight
= max(yMaxHeight
, lpBand
->cyMinBand
);
1305 TRACE("Bands [%d; %d) height: %d\n", iBeginBand
, iEndBand
, yMaxHeight
);
1307 for (i
= iBeginBand
; i
< iEndBand
; i
= next_visible(infoPtr
, i
))
1309 lpBand
= REBAR_GetBand(infoPtr
, i
);
1310 /* we may be called for multiple rows if RBS_VARHEIGHT not set */
1311 if (lpBand
->iRow
!= row
) {
1312 yPos
+= yMaxHeight
+ SEP_WIDTH
;
1316 if (lpBand
->rcBand
.top
!= yPos
|| lpBand
->rcBand
.bottom
!= yPos
+ yMaxHeight
) {
1317 lpBand
->fDraw
|= NTF_INVALIDATE
;
1318 lpBand
->rcBand
.top
= yPos
;
1319 lpBand
->rcBand
.bottom
= yPos
+ yMaxHeight
;
1320 TRACE("Band %d: %s\n", i
, wine_dbgstr_rect(&lpBand
->rcBand
));
1323 return yPos
+ yMaxHeight
;
1326 /* Layout the row [iBeginBand; iEndBand). iBeginBand must be visible */
1327 static void REBAR_LayoutRow(const REBAR_INFO
*infoPtr
, int iBeginBand
, int iEndBand
, int cx
, int *piRow
, int *pyPos
)
1333 TRACE("Adjusting row [%d;%d). Width: %d\n", iBeginBand
, iEndBand
, cx
);
1334 for (i
= iBeginBand
; i
< iEndBand
; i
++)
1335 REBAR_GetBand(infoPtr
, i
)->iRow
= *piRow
;
1337 /* compute the extra space */
1338 for (i
= iBeginBand
; i
< iEndBand
; i
= next_visible(infoPtr
, i
))
1340 lpBand
= REBAR_GetBand(infoPtr
, i
);
1343 lpBand
->cxEffective
= max(lpBand
->cxMinBand
, lpBand
->cx
);
1344 width
+= lpBand
->cxEffective
;
1348 TRACE("Extra space: %d\n", extra
);
1350 int ret
= REBAR_ShrinkBandsRTL(infoPtr
, iBeginBand
, iEndBand
, -extra
, FALSE
);
1351 if (ret
> 0 && next_visible(infoPtr
, iBeginBand
) != iEndBand
) /* one band may be longer than expected... */
1352 ERR("Error layouting row %d - couldn't shrink for %d pixels (%d total shrink)\n", *piRow
, ret
, -extra
);
1355 lpBand
= REBAR_FindBandToGrow(infoPtr
, iBeginBand
, iEndBand
);
1356 lpBand
->cxEffective
+= extra
;
1359 REBAR_SetRowRectsX(infoPtr
, iBeginBand
, iEndBand
);
1360 if (infoPtr
->dwStyle
& RBS_VARHEIGHT
)
1363 *pyPos
+= SEP_WIDTH
;
1364 *pyPos
= REBAR_SetBandsHeight(infoPtr
, iBeginBand
, iEndBand
, *pyPos
);
1370 REBAR_Layout(REBAR_INFO
*infoPtr
)
1380 if (infoPtr
->dwStyle
& (CCS_NORESIZE
| CCS_NOPARENTALIGN
) || GetParent(infoPtr
->hwndSelf
) == NULL
)
1381 GetClientRect(infoPtr
->hwndSelf
, &rcAdj
);
1383 GetClientRect(GetParent(infoPtr
->hwndSelf
), &rcAdj
);
1384 TRACE("adjustment rect is (%s)\n", wine_dbgstr_rect(&rcAdj
));
1386 adjcx
= get_rect_cx(infoPtr
, &rcAdj
);
1388 if (infoPtr
->uNumBands
== 0) {
1389 TRACE("No bands - setting size to (0,%d), style: %x\n", adjcx
, infoPtr
->dwStyle
);
1390 infoPtr
->calcSize
.cx
= adjcx
;
1391 /* the calcSize.cy won't change for a 0 band rebar */
1392 infoPtr
->uNumRows
= 0;
1393 REBAR_ForceResize(infoPtr
);
1399 rowstart
= first_visible(infoPtr
);
1401 for (i
= rowstart
; i
< infoPtr
->uNumBands
; i
= next_visible(infoPtr
, i
))
1403 lpBand
= REBAR_GetBand(infoPtr
, i
);
1405 if (i
> rowstart
&& (lpBand
->fStyle
& RBBS_BREAK
|| xMin
+ lpBand
->cxMinBand
> adjcx
)) {
1406 TRACE("%s break on band %d\n", (lpBand
->fStyle
& RBBS_BREAK
? "Hard" : "Soft"), i
- 1);
1407 REBAR_LayoutRow(infoPtr
, rowstart
, i
, adjcx
, &row
, &yPos
);
1414 xMin
+= lpBand
->cxMinBand
;
1416 if (rowstart
< infoPtr
->uNumBands
)
1417 REBAR_LayoutRow(infoPtr
, rowstart
, infoPtr
->uNumBands
, adjcx
, &row
, &yPos
);
1419 if (!(infoPtr
->dwStyle
& RBS_VARHEIGHT
))
1420 yPos
= REBAR_SetBandsHeight(infoPtr
, first_visible(infoPtr
), infoPtr
->uNumBands
, 0);
1422 infoPtr
->uNumRows
= row
;
1424 if (infoPtr
->dwStyle
& CCS_VERT
)
1425 REBAR_CalcVertBand(infoPtr
, 0, infoPtr
->uNumBands
);
1427 REBAR_CalcHorzBand(infoPtr
, 0, infoPtr
->uNumBands
);
1428 /* now compute size of Rebar itself */
1429 oldSize
= infoPtr
->calcSize
;
1431 infoPtr
->calcSize
.cx
= adjcx
;
1432 infoPtr
->calcSize
.cy
= yPos
;
1433 TRACE("calcsize size=(%d, %d), origheight=(%d,%d)\n",
1434 infoPtr
->calcSize
.cx
, infoPtr
->calcSize
.cy
,
1435 oldSize
.cx
, oldSize
.cy
);
1437 REBAR_DumpBand (infoPtr
);
1438 REBAR_MoveChildWindows (infoPtr
, 0, infoPtr
->uNumBands
);
1439 REBAR_ForceResize (infoPtr
);
1441 /* note: after a RBN_HEIGHTCHANGE native sends once again all the RBN_CHILDSIZE
1442 * and does another ForceResize */
1443 if (oldSize
.cy
!= infoPtr
->calcSize
.cy
)
1446 REBAR_Notify(&heightchange
, infoPtr
, RBN_HEIGHTCHANGE
);
1447 REBAR_AutoSize(infoPtr
, FALSE
);
1451 /* iBeginBand must be visible */
1453 REBAR_SizeChildrenToHeight(const REBAR_INFO
*infoPtr
, int iBeginBand
, int iEndBand
, int extra
, BOOL
*fChanged
)
1459 TRACE("[%d;%d) by %d\n", iBeginBand
, iEndBand
, extra
);
1461 cyBandsOld
= REBAR_GetBand(infoPtr
, iBeginBand
)->rcBand
.bottom
-
1462 REBAR_GetBand(infoPtr
, iBeginBand
)->rcBand
.top
;
1463 for (i
= iBeginBand
; i
< iEndBand
; i
= next_visible(infoPtr
, i
))
1465 REBAR_BAND
*lpBand
= REBAR_GetBand(infoPtr
, i
);
1466 int cyMaxChild
= cyBandsOld
- REBARSPACE(lpBand
) + extra
;
1467 int cyChild
= round_child_height(lpBand
, cyMaxChild
);
1469 if (lpBand
->hwndChild
&& cyChild
!= lpBand
->cyChild
&& (lpBand
->fStyle
& RBBS_VARIABLEHEIGHT
))
1471 TRACE("Resizing %d: %d -> %d [%d]\n", i
, lpBand
->cyChild
, cyChild
, lpBand
->cyMaxChild
);
1473 lpBand
->cyChild
= cyChild
;
1474 lpBand
->fDraw
|= NTF_INVALIDATE
;
1475 update_min_band_height(infoPtr
, lpBand
);
1477 cyBandsNew
= max(cyBandsNew
, lpBand
->cyMinBand
);
1479 return cyBandsNew
- cyBandsOld
;
1482 /* worker function for RB_SIZETORECT and RBS_AUTOSIZE */
1484 REBAR_SizeToHeight(REBAR_INFO
*infoPtr
, int height
)
1486 int extra
= height
- infoPtr
->calcSize
.cy
; /* may be negative */
1487 BOOL fChanged
= FALSE
;
1488 UINT uNumRows
= infoPtr
->uNumRows
;
1491 if (uNumRows
== 0) /* avoid division by 0 */
1494 /* That's not exactly what Windows does but should be similar */
1496 /* Pass one: break-up/glue rows */
1499 for (i
= prev_visible(infoPtr
, infoPtr
->uNumBands
); i
> 0; i
= prev_visible(infoPtr
, i
))
1501 REBAR_BAND
*lpBand
= REBAR_GetBand(infoPtr
, i
);
1502 int cyBreakExtra
; /* additional cy for the rebar after a RBBS_BREAK on this band */
1504 height
= lpBand
->rcBand
.bottom
- lpBand
->rcBand
.top
;
1506 if (infoPtr
->dwStyle
& RBS_VARHEIGHT
)
1507 cyBreakExtra
= lpBand
->cyRowSoFar
; /* 'height' => 'lpBand->cyRowSoFar' + 'height'*/
1509 cyBreakExtra
= height
; /* 'height' => 'height' + 'height'*/
1510 cyBreakExtra
+= SEP_WIDTH
;
1512 if (extra
<= cyBreakExtra
/ 2)
1515 if (!(lpBand
->fStyle
& RBBS_BREAK
))
1517 TRACE("Adding break on band %d - extra %d -> %d\n", i
, extra
, extra
- cyBreakExtra
);
1518 lpBand
->fStyle
|= RBBS_BREAK
;
1519 lpBand
->fDraw
|= NTF_INVALIDATE
;
1521 extra
-= cyBreakExtra
;
1523 /* temporary change for _SizeControlsToHeight. The true values will be computed in _Layout */
1524 if (infoPtr
->dwStyle
& RBS_VARHEIGHT
)
1525 lpBand
->rcBand
.bottom
= lpBand
->rcBand
.top
+ lpBand
->cyMinBand
;
1529 /* TODO: else if (extra < 0) { try to remove some RBBS_BREAKs } */
1531 /* Pass two: increase/decrease control height */
1532 if (infoPtr
->dwStyle
& RBS_VARHEIGHT
)
1534 int i
= first_visible(infoPtr
);
1536 while (i
< infoPtr
->uNumBands
)
1538 REBAR_BAND
*lpBand
= REBAR_GetBand(infoPtr
, i
);
1539 int extraForRow
= extra
/ (int)(uNumRows
- iRow
);
1542 /* we can't use get_row_end_for_band as we might have added RBBS_BREAK in the first phase */
1543 for (rowEnd
= next_visible(infoPtr
, i
); rowEnd
< infoPtr
->uNumBands
; rowEnd
= next_visible(infoPtr
, rowEnd
))
1544 if (REBAR_GetBand(infoPtr
, rowEnd
)->iRow
!= lpBand
->iRow
||
1545 REBAR_GetBand(infoPtr
, rowEnd
)->fStyle
& RBBS_BREAK
)
1548 extra
-= REBAR_SizeChildrenToHeight(infoPtr
, i
, rowEnd
, extraForRow
, &fChanged
);
1549 TRACE("extra = %d\n", extra
);
1555 REBAR_SizeChildrenToHeight(infoPtr
, first_visible(infoPtr
), infoPtr
->uNumBands
, extra
/ infoPtr
->uNumRows
, &fChanged
);
1558 REBAR_Layout(infoPtr
);
1562 REBAR_AutoSize(REBAR_INFO
*infoPtr
, BOOL needsLayout
)
1565 NMRBAUTOSIZE autosize
;
1568 REBAR_Layout(infoPtr
);
1569 GetClientRect(infoPtr
->hwndSelf
, &rc
);
1570 REBAR_SizeToHeight(infoPtr
, get_rect_cy(infoPtr
, &rc
));
1571 GetClientRect(infoPtr
->hwndSelf
, &rcNew
);
1573 GetClientRect(infoPtr
->hwndSelf
, &autosize
.rcTarget
);
1574 autosize
.fChanged
= EqualRect(&rc
, &rcNew
);
1575 autosize
.rcTarget
= rc
;
1576 autosize
.rcActual
= rcNew
;
1577 REBAR_Notify((NMHDR
*)&autosize
, infoPtr
, RBN_AUTOSIZE
);
1581 REBAR_ValidateBand (const REBAR_INFO
*infoPtr
, REBAR_BAND
*lpBand
)
1582 /* Function: This routine evaluates the band specs supplied */
1583 /* by the user and updates the following 5 fields in */
1584 /* the internal band structure: cxHeader, cyHeader, cxMinBand, cyMinBand, fStatus */
1587 UINT textheight
=0, imageheight
= 0;
1591 lpBand
->fStatus
= 0;
1592 lpBand
->cxMinBand
= 0;
1593 lpBand
->cyMinBand
= 0;
1595 /* Data coming in from users into the cx... and cy... fields */
1596 /* may be bad, just garbage, because the user never clears */
1597 /* the fields. RB_{SET|INSERT}BAND{A|W} just passes the data */
1598 /* along if the fields exist in the input area. Here we must */
1599 /* determine if the data is valid. I have no idea how MS does */
1600 /* the validation, but it does because the RB_GETBANDINFO */
1601 /* returns a 0 when I know the sample program passed in an */
1602 /* address. Here I will use the algorithm that if the value */
1603 /* is greater than 65535 then it is bad and replace it with */
1604 /* a zero. Feel free to improve the algorithm. - GA 12/2000 */
1605 if (lpBand
->cxMinChild
> 65535) lpBand
->cxMinChild
= 0;
1606 if (lpBand
->cyMinChild
> 65535) lpBand
->cyMinChild
= 0;
1607 if (lpBand
->cx
> 65535) lpBand
->cx
= 0;
1608 if (lpBand
->cyChild
> 65535) lpBand
->cyChild
= 0;
1609 if (lpBand
->cyIntegral
> 65535) lpBand
->cyIntegral
= 0;
1610 if (lpBand
->cxIdeal
> 65535) lpBand
->cxIdeal
= 0;
1611 if (lpBand
->cxHeader
> 65535) lpBand
->cxHeader
= 0;
1613 /* TODO : we could try return to the caller if a value changed so that */
1614 /* a REBAR_Layout is needed. Till now the caller should call it */
1615 /* it always (we should also check what native does) */
1617 /* Header is where the image, text and gripper exist */
1618 /* in the band and precede the child window. */
1620 /* count number of non-FIXEDSIZE and non-Hidden bands */
1622 for (i
=0; i
<infoPtr
->uNumBands
; i
++){
1623 tBand
= REBAR_GetBand(infoPtr
, i
);
1624 if (!HIDDENBAND(tBand
) && !(tBand
->fStyle
& RBBS_FIXEDSIZE
))
1628 /* calculate gripper rectangle */
1629 if ( (!(lpBand
->fStyle
& RBBS_NOGRIPPER
)) &&
1630 ( (lpBand
->fStyle
& RBBS_GRIPPERALWAYS
) ||
1631 ( !(lpBand
->fStyle
& RBBS_FIXEDSIZE
) && (nonfixed
> 1)))
1633 lpBand
->fStatus
|= HAS_GRIPPER
;
1634 if (infoPtr
->dwStyle
& CCS_VERT
)
1635 if (infoPtr
->dwStyle
& RBS_VERTICALGRIPPER
)
1636 header
+= (GRIPPER_HEIGHT
+ REBAR_PRE_GRIPPER
);
1638 header
+= (GRIPPER_WIDTH
+ REBAR_PRE_GRIPPER
);
1640 header
+= (REBAR_PRE_GRIPPER
+ GRIPPER_WIDTH
);
1641 /* Always have 4 pixels before anything else */
1642 header
+= REBAR_ALWAYS_SPACE
;
1645 /* image is visible */
1646 if (lpBand
->iImage
!= -1 && (infoPtr
->himl
)) {
1647 lpBand
->fStatus
|= HAS_IMAGE
;
1648 if (infoPtr
->dwStyle
& CCS_VERT
) {
1649 header
+= (infoPtr
->imageSize
.cy
+ REBAR_POST_IMAGE
);
1650 imageheight
= infoPtr
->imageSize
.cx
+ 4;
1653 header
+= (infoPtr
->imageSize
.cx
+ REBAR_POST_IMAGE
);
1654 imageheight
= infoPtr
->imageSize
.cy
+ 4;
1658 /* text is visible */
1659 if ((lpBand
->fMask
& RBBIM_TEXT
) && (lpBand
->lpText
) &&
1660 !(lpBand
->fStyle
& RBBS_HIDETITLE
)) {
1661 HDC hdc
= GetDC (0);
1662 HFONT hOldFont
= SelectObject (hdc
, infoPtr
->hFont
);
1665 lpBand
->fStatus
|= HAS_TEXT
;
1666 GetTextExtentPoint32W (hdc
, lpBand
->lpText
,
1667 lstrlenW (lpBand
->lpText
), &size
);
1668 header
+= ((infoPtr
->dwStyle
& CCS_VERT
) ? (size
.cy
+ REBAR_POST_TEXT
) : (size
.cx
+ REBAR_POST_TEXT
));
1669 textheight
= (infoPtr
->dwStyle
& CCS_VERT
) ? 0 : size
.cy
;
1671 SelectObject (hdc
, hOldFont
);
1675 /* if no gripper but either image or text, then leave space */
1676 if ((lpBand
->fStatus
& (HAS_IMAGE
| HAS_TEXT
)) &&
1677 !(lpBand
->fStatus
& HAS_GRIPPER
)) {
1678 header
+= REBAR_ALWAYS_SPACE
;
1681 /* check if user overrode the header value */
1682 if (!(lpBand
->fStyle
& RBBS_UNDOC_FIXEDHEADER
))
1683 lpBand
->cxHeader
= header
;
1684 lpBand
->cyHeader
= max(textheight
, imageheight
);
1686 /* Now compute minimum size of child window */
1687 update_min_band_height(infoPtr
, lpBand
); /* update lpBand->cyMinBand from cyHeader and cyChild*/
1689 lpBand
->cxMinBand
= lpBand
->cxMinChild
+ lpBand
->cxHeader
+ REBAR_POST_CHILD
;
1690 if (lpBand
->fStyle
& RBBS_USECHEVRON
&& lpBand
->cxMinChild
< lpBand
->cxIdeal
)
1691 lpBand
->cxMinBand
+= CHEVRON_WIDTH
;
1695 REBAR_CommonSetupBand(HWND hwnd
, const REBARBANDINFOW
*lprbbi
, REBAR_BAND
*lpBand
)
1696 /* Function: This routine copies the supplied values from */
1697 /* user input (lprbbi) to the internal band structure. */
1698 /* It returns the mask of what changed. */
1700 UINT uChanged
= 0x0;
1702 lpBand
->fMask
|= lprbbi
->fMask
;
1704 if( (lprbbi
->fMask
& RBBIM_STYLE
) &&
1705 (lpBand
->fStyle
!= lprbbi
->fStyle
) )
1707 lpBand
->fStyle
= lprbbi
->fStyle
;
1708 uChanged
|= RBBIM_STYLE
;
1711 if( (lprbbi
->fMask
& RBBIM_COLORS
) &&
1712 ( ( lpBand
->clrFore
!= lprbbi
->clrFore
) ||
1713 ( lpBand
->clrBack
!= lprbbi
->clrBack
) ) )
1715 lpBand
->clrFore
= lprbbi
->clrFore
;
1716 lpBand
->clrBack
= lprbbi
->clrBack
;
1717 uChanged
|= RBBIM_COLORS
;
1720 if( (lprbbi
->fMask
& RBBIM_IMAGE
) &&
1721 ( lpBand
->iImage
!= lprbbi
->iImage
) )
1723 lpBand
->iImage
= lprbbi
->iImage
;
1724 uChanged
|= RBBIM_IMAGE
;
1727 if( (lprbbi
->fMask
& RBBIM_CHILD
) &&
1728 (lprbbi
->hwndChild
!= lpBand
->hwndChild
) )
1730 if (lprbbi
->hwndChild
) {
1731 lpBand
->hwndChild
= lprbbi
->hwndChild
;
1732 lpBand
->hwndPrevParent
=
1733 SetParent (lpBand
->hwndChild
, hwnd
);
1734 /* below in trace from WinRAR */
1735 ShowWindow(lpBand
->hwndChild
, SW_SHOWNOACTIVATE
| SW_SHOWNORMAL
);
1736 /* above in trace from WinRAR */
1739 TRACE("child: %p prev parent: %p\n",
1740 lpBand
->hwndChild
, lpBand
->hwndPrevParent
);
1741 lpBand
->hwndChild
= 0;
1742 lpBand
->hwndPrevParent
= 0;
1744 uChanged
|= RBBIM_CHILD
;
1747 if( (lprbbi
->fMask
& RBBIM_CHILDSIZE
) &&
1748 ( (lpBand
->cxMinChild
!= lprbbi
->cxMinChild
) ||
1749 (lpBand
->cyMinChild
!= lprbbi
->cyMinChild
) ||
1750 ( (lprbbi
->cbSize
>= REBARBANDINFOA_V6_SIZE
&& (lpBand
->fStyle
& RBBS_VARIABLEHEIGHT
)) &&
1751 ( (lpBand
->cyChild
!= lprbbi
->cyChild
) ||
1752 (lpBand
->cyMaxChild
!= lprbbi
->cyMaxChild
) ||
1753 (lpBand
->cyIntegral
!= lprbbi
->cyIntegral
) ) ) ||
1754 ( (lprbbi
->cbSize
< REBARBANDINFOA_V6_SIZE
) &&
1755 ( (lpBand
->cyChild
||
1756 lpBand
->cyMaxChild
||
1757 lpBand
->cyIntegral
) ) ) ) )
1759 lpBand
->cxMinChild
= lprbbi
->cxMinChild
;
1760 lpBand
->cyMinChild
= lprbbi
->cyMinChild
;
1761 /* These fields where added in WIN32_IE == 0x400 and are set only for RBBS_VARIABLEHEIGHT bands */
1762 if (lprbbi
->cbSize
>= REBARBANDINFOA_V6_SIZE
&& (lpBand
->fStyle
& RBBS_VARIABLEHEIGHT
)) {
1763 lpBand
->cyMaxChild
= lprbbi
->cyMaxChild
;
1764 lpBand
->cyIntegral
= lprbbi
->cyIntegral
;
1766 lpBand
->cyChild
= round_child_height(lpBand
, lprbbi
->cyChild
); /* make (cyChild - cyMinChild) a multiple of cyIntergral */
1769 lpBand
->cyChild
= lpBand
->cyMinChild
;
1770 lpBand
->cyMaxChild
= 0x7fffffff;
1771 lpBand
->cyIntegral
= 0;
1773 uChanged
|= RBBIM_CHILDSIZE
;
1776 if( (lprbbi
->fMask
& RBBIM_SIZE
) &&
1777 (lpBand
->cx
!= lprbbi
->cx
) )
1779 lpBand
->cx
= lprbbi
->cx
;
1780 uChanged
|= RBBIM_SIZE
;
1783 if( (lprbbi
->fMask
& RBBIM_BACKGROUND
) &&
1784 ( lpBand
->hbmBack
!= lprbbi
->hbmBack
) )
1786 lpBand
->hbmBack
= lprbbi
->hbmBack
;
1787 uChanged
|= RBBIM_BACKGROUND
;
1790 if( (lprbbi
->fMask
& RBBIM_ID
) &&
1791 (lpBand
->wID
!= lprbbi
->wID
) )
1793 lpBand
->wID
= lprbbi
->wID
;
1794 uChanged
|= RBBIM_ID
;
1797 /* check for additional data */
1798 if (lprbbi
->cbSize
>= REBARBANDINFOA_V6_SIZE
) {
1799 if( (lprbbi
->fMask
& RBBIM_IDEALSIZE
) &&
1800 ( lpBand
->cxIdeal
!= lprbbi
->cxIdeal
) )
1802 lpBand
->cxIdeal
= lprbbi
->cxIdeal
;
1803 uChanged
|= RBBIM_IDEALSIZE
;
1806 if( (lprbbi
->fMask
& RBBIM_LPARAM
) &&
1807 (lpBand
->lParam
!= lprbbi
->lParam
) )
1809 lpBand
->lParam
= lprbbi
->lParam
;
1810 uChanged
|= RBBIM_LPARAM
;
1813 if( (lprbbi
->fMask
& RBBIM_HEADERSIZE
) &&
1814 (lpBand
->cxHeader
!= lprbbi
->cxHeader
) )
1816 lpBand
->cxHeader
= lprbbi
->cxHeader
;
1817 lpBand
->fStyle
|= RBBS_UNDOC_FIXEDHEADER
;
1818 uChanged
|= RBBIM_HEADERSIZE
;
1825 static LRESULT
REBAR_EraseBkGnd (const REBAR_INFO
*infoPtr
, HDC hdc
)
1826 /* Function: This erases the background rectangle by drawing */
1827 /* each band with its background color (or the default) and */
1828 /* draws each bands right separator if necessary. The row */
1829 /* separators are drawn on the first band of the next row. */
1835 COLORREF old
= CLR_NONE
, new;
1836 HTHEME theme
= GetWindowTheme (infoPtr
->hwndSelf
);
1838 GetClientRect (infoPtr
->hwndSelf
, &cr
);
1841 for(i
=0; i
<infoPtr
->uNumBands
; i
++) {
1843 lpBand
= REBAR_GetBand(infoPtr
, i
);
1844 if (HIDDENBAND(lpBand
)) continue;
1845 translate_rect(infoPtr
, &rcBand
, &lpBand
->rcBand
);
1847 /* draw band separator between rows */
1848 if (lpBand
->iRow
!= oldrow
) {
1849 oldrow
= lpBand
->iRow
;
1850 if (infoPtr
->dwStyle
& RBS_BANDBORDERS
) {
1853 if (infoPtr
->dwStyle
& CCS_VERT
) {
1854 rcRowSep
.right
+= SEP_WIDTH_SIZE
;
1855 rcRowSep
.bottom
= infoPtr
->calcSize
.cx
;
1857 DrawThemeEdge (theme
, hdc
, RP_BAND
, 0, &rcRowSep
, EDGE_ETCHED
, BF_RIGHT
, NULL
);
1859 DrawEdge (hdc
, &rcRowSep
, EDGE_ETCHED
, BF_RIGHT
);
1862 rcRowSep
.bottom
+= SEP_WIDTH_SIZE
;
1863 rcRowSep
.right
= infoPtr
->calcSize
.cx
;
1865 DrawThemeEdge (theme
, hdc
, RP_BAND
, 0, &rcRowSep
, EDGE_ETCHED
, BF_BOTTOM
, NULL
);
1867 DrawEdge (hdc
, &rcRowSep
, EDGE_ETCHED
, BF_BOTTOM
);
1869 TRACE ("drawing band separator bottom (%s)\n",
1870 wine_dbgstr_rect(&rcRowSep
));
1874 /* draw band separator between bands in a row */
1875 if (infoPtr
->dwStyle
& RBS_BANDBORDERS
&& lpBand
->rcBand
.left
> 0) {
1878 if (infoPtr
->dwStyle
& CCS_VERT
) {
1879 rcSep
.bottom
= rcSep
.top
;
1880 rcSep
.top
-= SEP_WIDTH_SIZE
;
1882 DrawThemeEdge (theme
, hdc
, RP_BAND
, 0, &rcSep
, EDGE_ETCHED
, BF_BOTTOM
, NULL
);
1884 DrawEdge (hdc
, &rcSep
, EDGE_ETCHED
, BF_BOTTOM
);
1887 rcSep
.right
= rcSep
.left
;
1888 rcSep
.left
-= SEP_WIDTH_SIZE
;
1890 DrawThemeEdge (theme
, hdc
, RP_BAND
, 0, &rcSep
, EDGE_ETCHED
, BF_RIGHT
, NULL
);
1892 DrawEdge (hdc
, &rcSep
, EDGE_ETCHED
, BF_RIGHT
);
1894 TRACE("drawing band separator right (%s)\n",
1895 wine_dbgstr_rect(&rcSep
));
1898 /* draw the actual background */
1899 if (lpBand
->clrBack
!= CLR_NONE
) {
1900 new = (lpBand
->clrBack
== CLR_DEFAULT
) ? infoPtr
->clrBtnFace
:
1903 /* testing only - make background green to see it */
1908 /* In the absence of documentation for Rebar vs. CLR_NONE,
1909 * we will use the default BtnFace color. Note documentation
1910 * exists for Listview and Imagelist.
1912 new = infoPtr
->clrBtnFace
;
1914 /* testing only - make background green to see it */
1921 /* When themed, the background color is ignored (but not a
1922 * background bitmap */
1923 DrawThemeBackground (theme
, hdc
, 0, 0, &cr
, &rcBand
);
1927 old
= SetBkColor (hdc
, new);
1928 TRACE("%s background color=0x%06x, band %s\n",
1929 (lpBand
->clrBack
== CLR_NONE
) ? "none" :
1930 ((lpBand
->clrBack
== CLR_DEFAULT
) ? "dft" : ""),
1931 GetBkColor(hdc
), wine_dbgstr_rect(&rcBand
));
1932 ExtTextOutW (hdc
, 0, 0, ETO_OPAQUE
, &rcBand
, NULL
, 0, 0);
1933 if (lpBand
->clrBack
!= CLR_NONE
)
1934 SetBkColor (hdc
, old
);
1941 REBAR_InternalHitTest (const REBAR_INFO
*infoPtr
, const POINT
*lpPt
, UINT
*pFlags
, INT
*pBand
)
1947 GetClientRect (infoPtr
->hwndSelf
, &rect
);
1949 *pFlags
= RBHT_NOWHERE
;
1950 if (PtInRect (&rect
, *lpPt
))
1952 if (infoPtr
->uNumBands
== 0) {
1953 *pFlags
= RBHT_NOWHERE
;
1960 /* somewhere inside */
1961 for (iCount
= 0; iCount
< infoPtr
->uNumBands
; iCount
++) {
1963 lpBand
= REBAR_GetBand(infoPtr
, iCount
);
1964 translate_rect(infoPtr
, &rcBand
, &lpBand
->rcBand
);
1965 if (HIDDENBAND(lpBand
)) continue;
1966 if (PtInRect (&rcBand
, *lpPt
)) {
1969 if (PtInRect (&lpBand
->rcGripper
, *lpPt
)) {
1970 *pFlags
= RBHT_GRABBER
;
1971 TRACE("ON GRABBER %d\n", iCount
);
1974 else if (PtInRect (&lpBand
->rcCapImage
, *lpPt
)) {
1975 *pFlags
= RBHT_CAPTION
;
1976 TRACE("ON CAPTION %d\n", iCount
);
1979 else if (PtInRect (&lpBand
->rcCapText
, *lpPt
)) {
1980 *pFlags
= RBHT_CAPTION
;
1981 TRACE("ON CAPTION %d\n", iCount
);
1984 else if (PtInRect (&lpBand
->rcChild
, *lpPt
)) {
1985 *pFlags
= RBHT_CLIENT
;
1986 TRACE("ON CLIENT %d\n", iCount
);
1989 else if (PtInRect (&lpBand
->rcChevron
, *lpPt
)) {
1990 *pFlags
= RBHT_CHEVRON
;
1991 TRACE("ON CHEVRON %d\n", iCount
);
1995 *pFlags
= RBHT_NOWHERE
;
1996 TRACE("NOWHERE %d\n", iCount
);
2002 *pFlags
= RBHT_NOWHERE
;
2011 *pFlags
= RBHT_NOWHERE
;
2020 REBAR_HandleLRDrag (REBAR_INFO
*infoPtr
, const POINT
*ptsmove
)
2021 /* Function: This will implement the functionality of a */
2022 /* Gripper drag within a row. It will not implement "out- */
2023 /* of-row" drags. (They are detected and handled in */
2024 /* REBAR_MouseMove.) */
2026 REBAR_BAND
*hitBand
;
2027 INT iHitBand
, iRowBegin
, iRowEnd
;
2028 INT movement
, xBand
, cxLeft
= 0;
2029 BOOL shrunkBands
= FALSE
;
2031 iHitBand
= infoPtr
->iGrabbedBand
;
2032 iRowBegin
= get_row_begin_for_band(infoPtr
, iHitBand
);
2033 iRowEnd
= get_row_end_for_band(infoPtr
, iHitBand
);
2034 hitBand
= REBAR_GetBand(infoPtr
, iHitBand
);
2036 xBand
= hitBand
->rcBand
.left
;
2037 movement
= (infoPtr
->dwStyle
&CCS_VERT
? ptsmove
->y
: ptsmove
->x
)
2038 - (xBand
+ REBAR_PRE_GRIPPER
- infoPtr
->ihitoffset
);
2040 /* Dragging the first band in a row cannot cause shrinking */
2041 if(iHitBand
!= iRowBegin
)
2044 cxLeft
= REBAR_ShrinkBandsRTL(infoPtr
, iRowBegin
, iHitBand
, -movement
, TRUE
);
2046 if(cxLeft
< -movement
)
2048 hitBand
->cxEffective
+= -movement
- cxLeft
;
2049 hitBand
->cx
= hitBand
->cxEffective
;
2053 } else if (movement
> 0) {
2056 if (prev_visible(infoPtr
, iHitBand
) >= 0)
2057 cxLeft
= REBAR_ShrinkBandsLTR(infoPtr
, iHitBand
, iRowEnd
, movement
, TRUE
);
2059 if(cxLeft
< movement
)
2061 REBAR_BAND
*lpPrev
= REBAR_GetBand(infoPtr
, prev_visible(infoPtr
, iHitBand
));
2062 lpPrev
->cxEffective
+= movement
- cxLeft
;
2063 lpPrev
->cx
= hitBand
->cxEffective
;
2072 /* It was not possible to move the band by shrinking bands.
2073 * Try relocating the band instead. */
2074 REBAR_MoveBandToRowOffset(infoPtr
, iHitBand
, iRowBegin
,
2075 iRowEnd
, xBand
+ movement
, TRUE
);
2078 REBAR_SetRowRectsX(infoPtr
, iRowBegin
, iRowEnd
);
2079 if (infoPtr
->dwStyle
& CCS_VERT
)
2080 REBAR_CalcVertBand(infoPtr
, 0, infoPtr
->uNumBands
);
2082 REBAR_CalcHorzBand(infoPtr
, 0, infoPtr
->uNumBands
);
2083 REBAR_MoveChildWindows(infoPtr
, iRowBegin
, iRowEnd
);
2087 REBAR_HandleUDDrag (REBAR_INFO
*infoPtr
, const POINT
*ptsmove
)
2089 INT yOff
= (infoPtr
->dwStyle
& CCS_VERT
) ? ptsmove
->x
: ptsmove
->y
;
2090 INT iHitBand
, iRowBegin
, iNextRowBegin
;
2091 REBAR_BAND
*hitBand
, *rowBeginBand
;
2093 if(infoPtr
->uNumBands
<= 0)
2094 ERR("There are no bands in this rebar\n");
2096 /* Up/down dragging can only occur when there is more than one
2097 * band in the rebar */
2098 if(infoPtr
->uNumBands
<= 1)
2101 iHitBand
= infoPtr
->iGrabbedBand
;
2102 hitBand
= REBAR_GetBand(infoPtr
, iHitBand
);
2104 /* If we're taking a band that has the RBBS_BREAK style set, this
2105 * style needs to be reapplied to the band that is going to become
2106 * the new start of the row. */
2107 if((hitBand
->fStyle
& RBBS_BREAK
) &&
2108 (iHitBand
< infoPtr
->uNumBands
- 1))
2109 REBAR_GetBand(infoPtr
, iHitBand
+ 1)->fStyle
|= RBBS_BREAK
;
2113 /* Place the band above the current top row */
2114 if(iHitBand
==0 && (infoPtr
->uNumBands
==1 || REBAR_GetBand(infoPtr
, 1)->fStyle
&RBBS_BREAK
))
2116 DPA_DeletePtr(infoPtr
->bands
, iHitBand
);
2117 hitBand
->fStyle
&= ~RBBS_BREAK
;
2118 REBAR_GetBand(infoPtr
, 0)->fStyle
|= RBBS_BREAK
;
2119 infoPtr
->iGrabbedBand
= DPA_InsertPtr(
2120 infoPtr
->bands
, 0, hitBand
);
2122 else if(yOff
> REBAR_GetBand(infoPtr
, infoPtr
->uNumBands
- 1)->rcBand
.bottom
)
2124 /* Place the band below the current bottom row */
2125 if(iHitBand
== infoPtr
->uNumBands
-1 && hitBand
->fStyle
&RBBS_BREAK
)
2127 DPA_DeletePtr(infoPtr
->bands
, iHitBand
);
2128 hitBand
->fStyle
|= RBBS_BREAK
;
2129 infoPtr
->iGrabbedBand
= DPA_InsertPtr(
2130 infoPtr
->bands
, infoPtr
->uNumBands
- 1, hitBand
);
2134 /* Place the band in the prexisting row the mouse is hovering over */
2135 iRowBegin
= first_visible(infoPtr
);
2136 while(iRowBegin
< infoPtr
->uNumBands
)
2138 iNextRowBegin
= get_row_end_for_band(infoPtr
, iRowBegin
);
2139 rowBeginBand
= REBAR_GetBand(infoPtr
, iRowBegin
);
2140 if(rowBeginBand
->rcBand
.bottom
> yOff
)
2142 REBAR_MoveBandToRowOffset(
2143 infoPtr
, iHitBand
, iRowBegin
, iNextRowBegin
,
2144 ((infoPtr
->dwStyle
& CCS_VERT
) ? ptsmove
->y
: ptsmove
->x
)
2145 - REBAR_PRE_GRIPPER
- infoPtr
->ihitoffset
, FALSE
);
2149 iRowBegin
= iNextRowBegin
;
2153 REBAR_Layout(infoPtr
);
2157 /* << REBAR_BeginDrag >> */
2161 REBAR_DeleteBand (REBAR_INFO
*infoPtr
, WPARAM wParam
)
2163 UINT uBand
= (UINT
)wParam
;
2166 if (uBand
>= infoPtr
->uNumBands
)
2169 TRACE("deleting band %u!\n", uBand
);
2170 lpBand
= REBAR_GetBand(infoPtr
, uBand
);
2171 REBAR_Notify_NMREBAR (infoPtr
, uBand
, RBN_DELETINGBAND
);
2172 /* TODO: a return of 1 should probably cancel the deletion */
2174 if (lpBand
->hwndChild
)
2175 ShowWindow(lpBand
->hwndChild
, SW_HIDE
);
2176 Free(lpBand
->lpText
);
2179 infoPtr
->uNumBands
--;
2180 DPA_DeletePtr(infoPtr
->bands
, uBand
);
2182 REBAR_Notify_NMREBAR (infoPtr
, -1, RBN_DELETEDBAND
);
2184 /* if only 1 band left the re-validate to possible eliminate gripper */
2185 if (infoPtr
->uNumBands
== 1)
2186 REBAR_ValidateBand (infoPtr
, REBAR_GetBand(infoPtr
, 0));
2188 REBAR_Layout(infoPtr
);
2194 /* << REBAR_DragMove >> */
2195 /* << REBAR_EndDrag >> */
2199 REBAR_GetBandBorders (const REBAR_INFO
*infoPtr
, UINT uBand
, RECT
*lpRect
)
2205 if (uBand
>= infoPtr
->uNumBands
)
2208 lpBand
= REBAR_GetBand(infoPtr
, uBand
);
2210 /* FIXME - the following values were determined by experimentation */
2211 /* with the REBAR Control Spy. I have guesses as to what the 4 and */
2212 /* 1 are, but I am not sure. There doesn't seem to be any actual */
2213 /* difference in size of the control area with and without the */
2215 if (infoPtr
->dwStyle
& RBS_BANDBORDERS
) {
2216 if (infoPtr
->dwStyle
& CCS_VERT
) {
2218 lpRect
->top
= lpBand
->cxHeader
+ 4;
2223 lpRect
->left
= lpBand
->cxHeader
+ 4;
2230 lpRect
->left
= lpBand
->cxHeader
;
2236 static inline LRESULT
2237 REBAR_GetBandCount (const REBAR_INFO
*infoPtr
)
2239 TRACE("band count %u!\n", infoPtr
->uNumBands
);
2241 return infoPtr
->uNumBands
;
2246 REBAR_GetBandInfoT(const REBAR_INFO
*infoPtr
, UINT uIndex
, LPREBARBANDINFOW lprbbi
, BOOL bUnicode
)
2250 if (!lprbbi
|| lprbbi
->cbSize
< REBARBANDINFOA_V3_SIZE
)
2253 if (uIndex
>= infoPtr
->uNumBands
)
2256 TRACE("index %u (bUnicode=%d)\n", uIndex
, bUnicode
);
2258 /* copy band information */
2259 lpBand
= REBAR_GetBand(infoPtr
, uIndex
);
2261 if (lprbbi
->fMask
& RBBIM_STYLE
)
2262 lprbbi
->fStyle
= lpBand
->fStyle
;
2264 if (lprbbi
->fMask
& RBBIM_COLORS
) {
2265 lprbbi
->clrFore
= lpBand
->clrFore
;
2266 lprbbi
->clrBack
= lpBand
->clrBack
;
2267 if (lprbbi
->clrBack
== CLR_DEFAULT
)
2268 lprbbi
->clrBack
= infoPtr
->clrBtnFace
;
2271 if (lprbbi
->fMask
& RBBIM_TEXT
) {
2273 Str_GetPtrW(lpBand
->lpText
, lprbbi
->lpText
, lprbbi
->cch
);
2275 Str_GetPtrWtoA(lpBand
->lpText
, (LPSTR
)lprbbi
->lpText
, lprbbi
->cch
);
2278 if (lprbbi
->fMask
& RBBIM_IMAGE
)
2279 lprbbi
->iImage
= lpBand
->iImage
;
2281 if (lprbbi
->fMask
& RBBIM_CHILD
)
2282 lprbbi
->hwndChild
= lpBand
->hwndChild
;
2284 if (lprbbi
->fMask
& RBBIM_CHILDSIZE
) {
2285 lprbbi
->cxMinChild
= lpBand
->cxMinChild
;
2286 lprbbi
->cyMinChild
= lpBand
->cyMinChild
;
2287 /* to make tests pass we follow Windows' behaviour and allow reading these fields only
2288 * for RBBS_VARIABLEHEIGHTS bands */
2289 if (lprbbi
->cbSize
>= REBARBANDINFOW_V6_SIZE
&& (lpBand
->fStyle
& RBBS_VARIABLEHEIGHT
)) {
2290 lprbbi
->cyChild
= lpBand
->cyChild
;
2291 lprbbi
->cyMaxChild
= lpBand
->cyMaxChild
;
2292 lprbbi
->cyIntegral
= lpBand
->cyIntegral
;
2296 if (lprbbi
->fMask
& RBBIM_SIZE
)
2297 lprbbi
->cx
= lpBand
->cx
;
2299 if (lprbbi
->fMask
& RBBIM_BACKGROUND
)
2300 lprbbi
->hbmBack
= lpBand
->hbmBack
;
2302 if (lprbbi
->fMask
& RBBIM_ID
)
2303 lprbbi
->wID
= lpBand
->wID
;
2305 /* check for additional data */
2306 if (lprbbi
->cbSize
>= REBARBANDINFOW_V6_SIZE
) {
2307 if (lprbbi
->fMask
& RBBIM_IDEALSIZE
)
2308 lprbbi
->cxIdeal
= lpBand
->cxIdeal
;
2310 if (lprbbi
->fMask
& RBBIM_LPARAM
)
2311 lprbbi
->lParam
= lpBand
->lParam
;
2313 if (lprbbi
->fMask
& RBBIM_HEADERSIZE
)
2314 lprbbi
->cxHeader
= lpBand
->cxHeader
;
2317 REBAR_DumpBandInfo(lprbbi
);
2324 REBAR_GetBarHeight (const REBAR_INFO
*infoPtr
)
2328 nHeight
= infoPtr
->calcSize
.cy
;
2330 TRACE("height = %d\n", nHeight
);
2337 REBAR_GetBarInfo (const REBAR_INFO
*infoPtr
, LPREBARINFO lpInfo
)
2339 if (!lpInfo
|| lpInfo
->cbSize
< sizeof (REBARINFO
))
2342 TRACE("getting bar info!\n");
2344 if (infoPtr
->himl
) {
2345 lpInfo
->himl
= infoPtr
->himl
;
2346 lpInfo
->fMask
|= RBIM_IMAGELIST
;
2353 static inline LRESULT
2354 REBAR_GetBkColor (const REBAR_INFO
*infoPtr
)
2356 COLORREF clr
= infoPtr
->clrBk
;
2358 if (clr
== CLR_DEFAULT
)
2359 clr
= infoPtr
->clrBtnFace
;
2361 TRACE("background color 0x%06x!\n", clr
);
2367 /* << REBAR_GetColorScheme >> */
2368 /* << REBAR_GetDropTarget >> */
2372 REBAR_GetPalette (const REBAR_INFO
*infoPtr
)
2374 FIXME("empty stub!\n");
2381 REBAR_GetRect (const REBAR_INFO
*infoPtr
, INT iBand
, RECT
*lprc
)
2385 if (iBand
< 0 || iBand
>= infoPtr
->uNumBands
)
2390 lpBand
= REBAR_GetBand(infoPtr
, iBand
);
2391 /* For CCS_VERT the coordinates will be swapped - like on Windows */
2392 *lprc
= lpBand
->rcBand
;
2394 TRACE("band %d, (%s)\n", iBand
, wine_dbgstr_rect(lprc
));
2400 static inline LRESULT
2401 REBAR_GetRowCount (const REBAR_INFO
*infoPtr
)
2403 TRACE("%u\n", infoPtr
->uNumRows
);
2405 return infoPtr
->uNumRows
;
2410 REBAR_GetRowHeight (const REBAR_INFO
*infoPtr
, INT iRow
)
2416 for (i
=0; i
<infoPtr
->uNumBands
; i
++) {
2417 lpBand
= REBAR_GetBand(infoPtr
, i
);
2418 if (HIDDENBAND(lpBand
)) continue;
2419 if (lpBand
->iRow
!= iRow
) continue;
2420 j
= lpBand
->rcBand
.bottom
- lpBand
->rcBand
.top
;
2421 if (j
> ret
) ret
= j
;
2424 TRACE("row %d, height %d\n", iRow
, ret
);
2430 static inline LRESULT
2431 REBAR_GetTextColor (const REBAR_INFO
*infoPtr
)
2433 TRACE("text color 0x%06x!\n", infoPtr
->clrText
);
2435 return infoPtr
->clrText
;
2439 static inline LRESULT
2440 REBAR_GetToolTips (const REBAR_INFO
*infoPtr
)
2442 return (LRESULT
)infoPtr
->hwndToolTip
;
2446 static inline LRESULT
2447 REBAR_GetUnicodeFormat (const REBAR_INFO
*infoPtr
)
2449 TRACE("%s hwnd=%p\n",
2450 infoPtr
->bUnicode
? "TRUE" : "FALSE", infoPtr
->hwndSelf
);
2452 return infoPtr
->bUnicode
;
2456 static inline LRESULT
2457 REBAR_GetVersion (const REBAR_INFO
*infoPtr
)
2459 TRACE("version %d\n", infoPtr
->iVersion
);
2460 return infoPtr
->iVersion
;
2465 REBAR_HitTest (const REBAR_INFO
*infoPtr
, LPRBHITTESTINFO lprbht
)
2470 REBAR_InternalHitTest (infoPtr
, &lprbht
->pt
, &lprbht
->flags
, &lprbht
->iBand
);
2472 return lprbht
->iBand
;
2477 REBAR_IdToIndex (const REBAR_INFO
*infoPtr
, UINT uId
)
2481 if (infoPtr
->uNumBands
< 1)
2484 for (i
= 0; i
< infoPtr
->uNumBands
; i
++) {
2485 if (REBAR_GetBand(infoPtr
, i
)->wID
== uId
) {
2486 TRACE("id %u is band %u found!\n", uId
, i
);
2491 TRACE("id %u is not found\n", uId
);
2497 REBAR_InsertBandT(REBAR_INFO
*infoPtr
, INT iIndex
, const REBARBANDINFOW
*lprbbi
, BOOL bUnicode
)
2501 if (!lprbbi
|| lprbbi
->cbSize
< REBARBANDINFOA_V3_SIZE
)
2504 /* trace the index as signed to see the -1 */
2505 TRACE("insert band at %d (bUnicode=%d)!\n", iIndex
, bUnicode
);
2506 REBAR_DumpBandInfo(lprbbi
);
2508 if (!(lpBand
= Alloc(sizeof(REBAR_BAND
)))) return FALSE
;
2509 if ((iIndex
== -1) || (iIndex
> infoPtr
->uNumBands
))
2510 iIndex
= infoPtr
->uNumBands
;
2511 if (DPA_InsertPtr(infoPtr
->bands
, iIndex
, lpBand
) == -1)
2516 infoPtr
->uNumBands
++;
2518 TRACE("index %d!\n", iIndex
);
2520 /* initialize band */
2521 memset(lpBand
, 0, sizeof(*lpBand
));
2522 lpBand
->clrFore
= infoPtr
->clrText
== CLR_NONE
? infoPtr
->clrBtnText
:
2524 lpBand
->clrBack
= infoPtr
->clrBk
== CLR_NONE
? infoPtr
->clrBtnFace
:
2526 lpBand
->iImage
= -1;
2528 REBAR_CommonSetupBand(infoPtr
->hwndSelf
, lprbbi
, lpBand
);
2530 /* Make sure the defaults for these are correct */
2531 if (lprbbi
->cbSize
< REBARBANDINFOA_V6_SIZE
|| !(lpBand
->fStyle
& RBBS_VARIABLEHEIGHT
)) {
2532 lpBand
->cyChild
= lpBand
->cyMinChild
;
2533 lpBand
->cyMaxChild
= 0x7fffffff;
2534 lpBand
->cyIntegral
= 0;
2537 if ((lprbbi
->fMask
& RBBIM_TEXT
) && (lprbbi
->lpText
)) {
2539 Str_SetPtrW(&lpBand
->lpText
, lprbbi
->lpText
);
2541 Str_SetPtrAtoW(&lpBand
->lpText
, (LPSTR
)lprbbi
->lpText
);
2544 REBAR_ValidateBand (infoPtr
, lpBand
);
2545 /* On insert of second band, revalidate band 1 to possible add gripper */
2546 if (infoPtr
->uNumBands
== 2)
2547 REBAR_ValidateBand (infoPtr
, REBAR_GetBand(infoPtr
, 0));
2549 REBAR_DumpBand (infoPtr
);
2551 REBAR_Layout(infoPtr
);
2552 InvalidateRect(infoPtr
->hwndSelf
, NULL
, TRUE
);
2559 REBAR_MaximizeBand (const REBAR_INFO
*infoPtr
, INT iBand
, LPARAM lParam
)
2562 int iRowBegin
, iRowEnd
;
2563 int cxDesired
, extra
, extraOrig
;
2567 if (infoPtr
->uNumBands
== 0 || iBand
< 0 || iBand
>= infoPtr
->uNumBands
) {
2569 ERR("Illegal MaximizeBand, requested=%d, current band count=%d\n",
2570 iBand
, infoPtr
->uNumBands
);
2574 lpBand
= REBAR_GetBand(infoPtr
, iBand
);
2576 if (lpBand
->fStyle
& RBBS_HIDDEN
)
2578 /* Windows is buggy and creates a hole */
2579 WARN("Ignoring maximize request on a hidden band (%d)\n", iBand
);
2583 cxIdealBand
= lpBand
->cxIdeal
+ lpBand
->cxHeader
+ REBAR_POST_CHILD
;
2584 if (lParam
&& (lpBand
->cxEffective
< cxIdealBand
))
2585 cxDesired
= cxIdealBand
;
2587 cxDesired
= infoPtr
->calcSize
.cx
;
2589 iRowBegin
= get_row_begin_for_band(infoPtr
, iBand
);
2590 iRowEnd
= get_row_end_for_band(infoPtr
, iBand
);
2591 extraOrig
= extra
= cxDesired
- lpBand
->cxEffective
;
2593 extra
= REBAR_ShrinkBandsRTL(infoPtr
, iRowBegin
, iBand
, extra
, TRUE
);
2595 extra
= REBAR_ShrinkBandsLTR(infoPtr
, next_visible(infoPtr
, iBand
), iRowEnd
, extra
, TRUE
);
2596 lpBand
->cxEffective
+= extraOrig
- extra
;
2597 lpBand
->cx
= lpBand
->cxEffective
;
2598 TRACE("(%d, %ld): Wanted size %d, obtained %d (shrink %d, %d)\n", iBand
, lParam
, cxDesired
, lpBand
->cx
, extraOrig
, extra
);
2599 REBAR_SetRowRectsX(infoPtr
, iRowBegin
, iRowEnd
);
2601 if (infoPtr
->dwStyle
& CCS_VERT
)
2602 REBAR_CalcVertBand(infoPtr
, iRowBegin
, iRowEnd
);
2604 REBAR_CalcHorzBand(infoPtr
, iRowBegin
, iRowEnd
);
2605 REBAR_MoveChildWindows(infoPtr
, iRowBegin
, iRowEnd
);
2612 REBAR_MinimizeBand (const REBAR_INFO
*infoPtr
, INT iBand
)
2615 int iPrev
, iRowBegin
, iRowEnd
;
2617 /* A "minimize" band is equivalent to "dragging" the gripper
2618 * of than band to the right till the band is only the size
2623 if (infoPtr
->uNumBands
== 0 || iBand
< 0 || iBand
>= infoPtr
->uNumBands
) {
2625 ERR("Illegal MinimizeBand, requested=%d, current band count=%d\n",
2626 iBand
, infoPtr
->uNumBands
);
2630 /* compute amount of movement and validate */
2631 lpBand
= REBAR_GetBand(infoPtr
, iBand
);
2633 if (lpBand
->fStyle
& RBBS_HIDDEN
)
2635 /* Windows is buggy and creates a hole/overlap */
2636 WARN("Ignoring minimize request on a hidden band (%d)\n", iBand
);
2640 iPrev
= prev_visible(infoPtr
, iBand
);
2641 /* if first band in row */
2642 if (iPrev
< 0 || REBAR_GetBand(infoPtr
, iPrev
)->iRow
!= lpBand
->iRow
) {
2643 int iNext
= next_visible(infoPtr
, iBand
);
2644 if (iNext
< infoPtr
->uNumBands
&& REBAR_GetBand(infoPtr
, iNext
)->iRow
== lpBand
->iRow
) {
2645 TRACE("(%d): Minimizing the first band in row is by maximizing the second\n", iBand
);
2646 REBAR_MaximizeBand(infoPtr
, iNext
, FALSE
);
2649 TRACE("(%d): Only one band in row - nothing to do\n", iBand
);
2653 REBAR_GetBand(infoPtr
, iPrev
)->cxEffective
+= lpBand
->cxEffective
- lpBand
->cxMinBand
;
2654 REBAR_GetBand(infoPtr
, iPrev
)->cx
= REBAR_GetBand(infoPtr
, iPrev
)->cxEffective
;
2655 lpBand
->cx
= lpBand
->cxEffective
= lpBand
->cxMinBand
;
2657 iRowBegin
= get_row_begin_for_band(infoPtr
, iBand
);
2658 iRowEnd
= get_row_end_for_band(infoPtr
, iBand
);
2659 REBAR_SetRowRectsX(infoPtr
, iRowBegin
, iRowEnd
);
2661 if (infoPtr
->dwStyle
& CCS_VERT
)
2662 REBAR_CalcVertBand(infoPtr
, iRowBegin
, iRowEnd
);
2664 REBAR_CalcHorzBand(infoPtr
, iRowBegin
, iRowEnd
);
2665 REBAR_MoveChildWindows(infoPtr
, iRowBegin
, iRowEnd
);
2671 REBAR_MoveBand (REBAR_INFO
*infoPtr
, INT iFrom
, INT iTo
)
2676 if ((infoPtr
->uNumBands
== 0) ||
2677 (iFrom
< 0) || iFrom
>= infoPtr
->uNumBands
||
2678 (iTo
< 0) || iTo
>= infoPtr
->uNumBands
) {
2680 ERR("Illegal MoveBand, from=%d, to=%d, current band count=%d\n",
2681 iFrom
, iTo
, infoPtr
->uNumBands
);
2685 lpBand
= REBAR_GetBand(infoPtr
, iFrom
);
2686 DPA_DeletePtr(infoPtr
->bands
, iFrom
);
2687 DPA_InsertPtr(infoPtr
->bands
, iTo
, lpBand
);
2689 TRACE("moved band %d to index %d\n", iFrom
, iTo
);
2690 REBAR_DumpBand (infoPtr
);
2692 /* **************************************************** */
2694 /* We do not do a REBAR_Layout here because the native */
2695 /* control does not do that. The actual layout and */
2696 /* repaint is done by the *next* real action, ex.: */
2697 /* RB_INSERTBAND, RB_DELETEBAND, RB_SIZETORECT, etc. */
2699 /* **************************************************** */
2705 /* return TRUE if two strings are different */
2707 REBAR_strdifW( LPCWSTR a
, LPCWSTR b
)
2709 return ( (a
&& !b
) || (b
&& !a
) || (a
&& b
&& lstrcmpW(a
, b
) ) );
2713 REBAR_SetBandInfoT(REBAR_INFO
*infoPtr
, INT iBand
, const REBARBANDINFOW
*lprbbi
, BOOL bUnicode
)
2718 if (!lprbbi
|| lprbbi
->cbSize
< REBARBANDINFOA_V3_SIZE
)
2721 if (iBand
>= infoPtr
->uNumBands
)
2724 TRACE("index %d\n", iBand
);
2725 REBAR_DumpBandInfo (lprbbi
);
2727 /* set band information */
2728 lpBand
= REBAR_GetBand(infoPtr
, iBand
);
2730 uChanged
= REBAR_CommonSetupBand (infoPtr
->hwndSelf
, lprbbi
, lpBand
);
2731 if (lprbbi
->fMask
& RBBIM_TEXT
) {
2734 Str_SetPtrW(&wstr
, lprbbi
->lpText
);
2736 Str_SetPtrAtoW(&wstr
, (LPSTR
)lprbbi
->lpText
);
2738 if (REBAR_strdifW(wstr
, lpBand
->lpText
)) {
2739 Free(lpBand
->lpText
);
2740 lpBand
->lpText
= wstr
;
2741 uChanged
|= RBBIM_TEXT
;
2747 REBAR_ValidateBand (infoPtr
, lpBand
);
2749 REBAR_DumpBand (infoPtr
);
2751 if (uChanged
& (RBBIM_CHILDSIZE
| RBBIM_SIZE
| RBBIM_STYLE
| RBBIM_IMAGE
)) {
2752 REBAR_Layout(infoPtr
);
2753 InvalidateRect(infoPtr
->hwndSelf
, NULL
, TRUE
);
2761 REBAR_SetBarInfo (REBAR_INFO
*infoPtr
, const REBARINFO
*lpInfo
)
2766 if (!lpInfo
|| lpInfo
->cbSize
< sizeof (REBARINFO
))
2769 TRACE("setting bar info!\n");
2771 if (lpInfo
->fMask
& RBIM_IMAGELIST
) {
2772 infoPtr
->himl
= lpInfo
->himl
;
2773 if (infoPtr
->himl
) {
2775 ImageList_GetIconSize (infoPtr
->himl
, &cx
, &cy
);
2776 infoPtr
->imageSize
.cx
= cx
;
2777 infoPtr
->imageSize
.cy
= cy
;
2780 infoPtr
->imageSize
.cx
= 0;
2781 infoPtr
->imageSize
.cy
= 0;
2783 TRACE("new image cx=%d, cy=%d\n", infoPtr
->imageSize
.cx
,
2784 infoPtr
->imageSize
.cy
);
2787 /* revalidate all bands to reset flags for images in headers of bands */
2788 for (i
=0; i
<infoPtr
->uNumBands
; i
++) {
2789 lpBand
= REBAR_GetBand(infoPtr
, i
);
2790 REBAR_ValidateBand (infoPtr
, lpBand
);
2798 REBAR_SetBkColor (REBAR_INFO
*infoPtr
, COLORREF clr
)
2802 clrTemp
= infoPtr
->clrBk
;
2803 infoPtr
->clrBk
= clr
;
2805 TRACE("background color 0x%06x!\n", infoPtr
->clrBk
);
2811 /* << REBAR_SetColorScheme >> */
2812 /* << REBAR_SetPalette >> */
2816 REBAR_SetParent (REBAR_INFO
*infoPtr
, HWND parent
)
2818 HWND hwndTemp
= infoPtr
->hwndNotify
;
2820 infoPtr
->hwndNotify
= parent
;
2822 return (LRESULT
)hwndTemp
;
2827 REBAR_SetTextColor (REBAR_INFO
*infoPtr
, COLORREF clr
)
2831 clrTemp
= infoPtr
->clrText
;
2832 infoPtr
->clrText
= clr
;
2834 TRACE("text color 0x%06x!\n", infoPtr
->clrText
);
2840 /* << REBAR_SetTooltips >> */
2843 static inline LRESULT
2844 REBAR_SetUnicodeFormat (REBAR_INFO
*infoPtr
, BOOL unicode
)
2846 BOOL bTemp
= infoPtr
->bUnicode
;
2848 TRACE("to %s hwnd=%p, was %s\n",
2849 unicode
? "TRUE" : "FALSE", infoPtr
->hwndSelf
,
2850 (bTemp
) ? "TRUE" : "FALSE");
2852 infoPtr
->bUnicode
= unicode
;
2859 REBAR_SetVersion (REBAR_INFO
*infoPtr
, INT iVersion
)
2861 INT iOldVersion
= infoPtr
->iVersion
;
2863 if (iVersion
> COMCTL32_VERSION
)
2866 infoPtr
->iVersion
= iVersion
;
2868 TRACE("new version %d\n", iVersion
);
2875 REBAR_ShowBand (REBAR_INFO
*infoPtr
, INT iBand
, BOOL show
)
2879 if (iBand
< 0 || iBand
>= infoPtr
->uNumBands
)
2882 lpBand
= REBAR_GetBand(infoPtr
, iBand
);
2885 TRACE("show band %d\n", iBand
);
2886 lpBand
->fStyle
= lpBand
->fStyle
& ~RBBS_HIDDEN
;
2887 if (IsWindow (lpBand
->hwndChild
))
2888 ShowWindow (lpBand
->hwndChild
, SW_SHOW
);
2891 TRACE("hide band %d\n", iBand
);
2892 lpBand
->fStyle
= lpBand
->fStyle
| RBBS_HIDDEN
;
2893 if (IsWindow (lpBand
->hwndChild
))
2894 ShowWindow (lpBand
->hwndChild
, SW_HIDE
);
2897 REBAR_Layout(infoPtr
);
2898 InvalidateRect(infoPtr
->hwndSelf
, NULL
, TRUE
);
2905 REBAR_SizeToRect (REBAR_INFO
*infoPtr
, const RECT
*lpRect
)
2907 if (!lpRect
) return FALSE
;
2909 TRACE("[%s]\n", wine_dbgstr_rect(lpRect
));
2910 REBAR_SizeToHeight(infoPtr
, get_rect_cy(infoPtr
, lpRect
));
2917 REBAR_Create (REBAR_INFO
*infoPtr
, LPCREATESTRUCTW cs
)
2921 if (TRACE_ON(rebar
)) {
2922 GetWindowRect(infoPtr
->hwndSelf
, &wnrc1
);
2923 GetClientRect(infoPtr
->hwndSelf
, &clrc1
);
2924 TRACE("window=(%s) client=(%s) cs=(%d,%d %dx%d)\n",
2925 wine_dbgstr_rect(&wnrc1
), wine_dbgstr_rect(&clrc1
),
2926 cs
->x
, cs
->y
, cs
->cx
, cs
->cy
);
2929 TRACE("created!\n");
2931 if (OpenThemeData (infoPtr
->hwndSelf
, themeClass
))
2933 /* native seems to clear WS_BORDER when themed */
2934 infoPtr
->dwStyle
&= ~WS_BORDER
;
2942 REBAR_Destroy (REBAR_INFO
*infoPtr
)
2947 /* clean up each band */
2948 for (i
= 0; i
< infoPtr
->uNumBands
; i
++) {
2949 lpBand
= REBAR_GetBand(infoPtr
, i
);
2951 /* delete text strings */
2952 Free (lpBand
->lpText
);
2953 lpBand
->lpText
= NULL
;
2954 /* destroy child window */
2955 DestroyWindow (lpBand
->hwndChild
);
2959 /* free band array */
2960 DPA_Destroy (infoPtr
->bands
);
2961 infoPtr
->bands
= NULL
;
2963 DestroyCursor (infoPtr
->hcurArrow
);
2964 DestroyCursor (infoPtr
->hcurHorz
);
2965 DestroyCursor (infoPtr
->hcurVert
);
2966 DestroyCursor (infoPtr
->hcurDrag
);
2967 if (infoPtr
->hDefaultFont
) DeleteObject (infoPtr
->hDefaultFont
);
2968 SetWindowLongPtrW (infoPtr
->hwndSelf
, 0, 0);
2970 CloseThemeData (GetWindowTheme (infoPtr
->hwndSelf
));
2972 /* free rebar info data */
2974 TRACE("destroyed!\n");
2979 REBAR_GetFont (const REBAR_INFO
*infoPtr
)
2981 return (LRESULT
)infoPtr
->hFont
;
2985 REBAR_PushChevron(const REBAR_INFO
*infoPtr
, UINT uBand
, LPARAM lParam
)
2987 if (uBand
< infoPtr
->uNumBands
)
2989 NMREBARCHEVRON nmrbc
;
2990 REBAR_BAND
*lpBand
= REBAR_GetBand(infoPtr
, uBand
);
2992 TRACE("Pressed chevron on band %u\n", uBand
);
2994 /* redraw chevron in pushed state */
2995 lpBand
->fDraw
|= DRAW_CHEVRONPUSHED
;
2996 RedrawWindow(infoPtr
->hwndSelf
, &lpBand
->rcChevron
,0,
2997 RDW_ERASE
|RDW_INVALIDATE
|RDW_UPDATENOW
);
2999 /* notify app so it can display a popup menu or whatever */
3000 nmrbc
.uBand
= uBand
;
3001 nmrbc
.wID
= lpBand
->wID
;
3002 nmrbc
.lParam
= lpBand
->lParam
;
3003 nmrbc
.rc
= lpBand
->rcChevron
;
3004 nmrbc
.lParamNM
= lParam
;
3005 REBAR_Notify((NMHDR
*)&nmrbc
, infoPtr
, RBN_CHEVRONPUSHED
);
3007 /* redraw chevron in previous state */
3008 lpBand
->fDraw
&= ~DRAW_CHEVRONPUSHED
;
3009 InvalidateRect(infoPtr
->hwndSelf
, &lpBand
->rcChevron
, TRUE
);
3017 REBAR_LButtonDown (REBAR_INFO
*infoPtr
, LPARAM lParam
)
3022 ptMouseDown
.x
= (short)LOWORD(lParam
);
3023 ptMouseDown
.y
= (short)HIWORD(lParam
);
3025 REBAR_InternalHitTest(infoPtr
, &ptMouseDown
, &htFlags
, &iHitBand
);
3027 if (htFlags
== RBHT_CHEVRON
)
3029 REBAR_PushChevron(infoPtr
, iHitBand
, 0);
3031 else if (htFlags
== RBHT_GRABBER
|| htFlags
== RBHT_CAPTION
)
3035 TRACE("Starting drag\n");
3037 lpBand
= REBAR_GetBand(infoPtr
, iHitBand
);
3039 SetCapture (infoPtr
->hwndSelf
);
3040 infoPtr
->iGrabbedBand
= iHitBand
;
3042 /* save off the LOWORD and HIWORD of lParam as initial x,y */
3043 infoPtr
->dragStart
.x
= (short)LOWORD(lParam
);
3044 infoPtr
->dragStart
.y
= (short)HIWORD(lParam
);
3045 infoPtr
->dragNow
= infoPtr
->dragStart
;
3046 if (infoPtr
->dwStyle
& CCS_VERT
)
3047 infoPtr
->ihitoffset
= infoPtr
->dragStart
.y
- (lpBand
->rcBand
.left
+ REBAR_PRE_GRIPPER
);
3049 infoPtr
->ihitoffset
= infoPtr
->dragStart
.x
- (lpBand
->rcBand
.left
+ REBAR_PRE_GRIPPER
);
3055 REBAR_LButtonUp (REBAR_INFO
*infoPtr
)
3057 if (infoPtr
->iGrabbedBand
>= 0)
3062 infoPtr
->dragStart
.x
= 0;
3063 infoPtr
->dragStart
.y
= 0;
3064 infoPtr
->dragNow
= infoPtr
->dragStart
;
3068 if (infoPtr
->fStatus
& BEGIN_DRAG_ISSUED
) {
3069 REBAR_Notify(&layout
, infoPtr
, RBN_LAYOUTCHANGED
);
3070 REBAR_Notify_NMREBAR (infoPtr
, infoPtr
->iGrabbedBand
, RBN_ENDDRAG
);
3071 infoPtr
->fStatus
&= ~BEGIN_DRAG_ISSUED
;
3074 infoPtr
->iGrabbedBand
= -1;
3076 GetClientRect(infoPtr
->hwndSelf
, &rect
);
3077 InvalidateRect(infoPtr
->hwndSelf
, NULL
, TRUE
);
3084 REBAR_MouseLeave (REBAR_INFO
*infoPtr
)
3086 if (infoPtr
->ichevronhotBand
>= 0)
3088 REBAR_BAND
*lpChevronBand
= REBAR_GetBand(infoPtr
, infoPtr
->ichevronhotBand
);
3089 if (lpChevronBand
->fDraw
& DRAW_CHEVRONHOT
)
3091 lpChevronBand
->fDraw
&= ~DRAW_CHEVRONHOT
;
3092 InvalidateRect(infoPtr
->hwndSelf
, &lpChevronBand
->rcChevron
, TRUE
);
3095 infoPtr
->iOldBand
= -1;
3096 infoPtr
->ichevronhotBand
= -2;
3102 REBAR_MouseMove (REBAR_INFO
*infoPtr
, LPARAM lParam
)
3104 REBAR_BAND
*lpChevronBand
;
3107 ptMove
.x
= (short)LOWORD(lParam
);
3108 ptMove
.y
= (short)HIWORD(lParam
);
3110 /* if we are currently dragging a band */
3111 if (infoPtr
->iGrabbedBand
>= 0)
3114 int yPtMove
= (infoPtr
->dwStyle
& CCS_VERT
? ptMove
.x
: ptMove
.y
);
3116 if (GetCapture() != infoPtr
->hwndSelf
)
3117 ERR("We are dragging but haven't got capture?!?\n");
3119 band
= REBAR_GetBand(infoPtr
, infoPtr
->iGrabbedBand
);
3121 /* if mouse did not move much, exit */
3122 if ((abs(ptMove
.x
- infoPtr
->dragNow
.x
) <= mindragx
) &&
3123 (abs(ptMove
.y
- infoPtr
->dragNow
.y
) <= mindragy
)) return 0;
3125 /* on first significant mouse movement, issue notify */
3126 if (!(infoPtr
->fStatus
& BEGIN_DRAG_ISSUED
)) {
3127 if (REBAR_Notify_NMREBAR (infoPtr
, -1, RBN_BEGINDRAG
)) {
3128 /* Notify returned TRUE - abort drag */
3129 infoPtr
->dragStart
.x
= 0;
3130 infoPtr
->dragStart
.y
= 0;
3131 infoPtr
->dragNow
= infoPtr
->dragStart
;
3132 infoPtr
->iGrabbedBand
= -1;
3136 infoPtr
->fStatus
|= BEGIN_DRAG_ISSUED
;
3139 /* Test for valid drag case - must not be first band in row */
3140 if ((yPtMove
< band
->rcBand
.top
) ||
3141 (yPtMove
> band
->rcBand
.bottom
)) {
3142 REBAR_HandleUDDrag (infoPtr
, &ptMove
);
3145 REBAR_HandleLRDrag (infoPtr
, &ptMove
);
3152 TRACKMOUSEEVENT trackinfo
;
3154 REBAR_InternalHitTest(infoPtr
, &ptMove
, &htFlags
, &iHitBand
);
3156 if (infoPtr
->iOldBand
>= 0 && infoPtr
->iOldBand
== infoPtr
->ichevronhotBand
)
3158 lpChevronBand
= REBAR_GetBand(infoPtr
, infoPtr
->ichevronhotBand
);
3159 if (lpChevronBand
->fDraw
& DRAW_CHEVRONHOT
)
3161 lpChevronBand
->fDraw
&= ~DRAW_CHEVRONHOT
;
3162 InvalidateRect(infoPtr
->hwndSelf
, &lpChevronBand
->rcChevron
, TRUE
);
3164 infoPtr
->ichevronhotBand
= -2;
3167 if (htFlags
== RBHT_CHEVRON
)
3169 /* fill in the TRACKMOUSEEVENT struct */
3170 trackinfo
.cbSize
= sizeof(TRACKMOUSEEVENT
);
3171 trackinfo
.dwFlags
= TME_QUERY
;
3172 trackinfo
.hwndTrack
= infoPtr
->hwndSelf
;
3173 trackinfo
.dwHoverTime
= 0;
3175 /* call _TrackMouseEvent to see if we are currently tracking for this hwnd */
3176 _TrackMouseEvent(&trackinfo
);
3178 /* Make sure tracking is enabled so we receive a WM_MOUSELEAVE message */
3179 if(!(trackinfo
.dwFlags
& TME_LEAVE
))
3181 trackinfo
.dwFlags
= TME_LEAVE
; /* notify upon leaving */
3183 /* call TRACKMOUSEEVENT so we receive a WM_MOUSELEAVE message */
3184 /* and can properly deactivate the hot chevron */
3185 _TrackMouseEvent(&trackinfo
);
3188 lpChevronBand
= REBAR_GetBand(infoPtr
, iHitBand
);
3189 if (!(lpChevronBand
->fDraw
& DRAW_CHEVRONHOT
))
3191 lpChevronBand
->fDraw
|= DRAW_CHEVRONHOT
;
3192 InvalidateRect(infoPtr
->hwndSelf
, &lpChevronBand
->rcChevron
, TRUE
);
3193 infoPtr
->ichevronhotBand
= iHitBand
;
3196 infoPtr
->iOldBand
= iHitBand
;
3203 static inline LRESULT
3204 REBAR_NCCalcSize (const REBAR_INFO
*infoPtr
, RECT
*rect
)
3208 if (infoPtr
->dwStyle
& WS_BORDER
) {
3209 rect
->left
= min(rect
->left
+ GetSystemMetrics(SM_CXEDGE
), rect
->right
);
3210 rect
->right
= max(rect
->right
- GetSystemMetrics(SM_CXEDGE
), rect
->left
);
3211 rect
->top
= min(rect
->top
+ GetSystemMetrics(SM_CYEDGE
), rect
->bottom
);
3212 rect
->bottom
= max(rect
->bottom
- GetSystemMetrics(SM_CYEDGE
), rect
->top
);
3214 else if ((theme
= GetWindowTheme (infoPtr
->hwndSelf
)))
3216 /* FIXME: should use GetThemeInt */
3217 rect
->top
= min(rect
->top
+ 1, rect
->bottom
);
3219 TRACE("new client=(%s)\n", wine_dbgstr_rect(rect
));
3225 REBAR_NCCreate (HWND hwnd
, const CREATESTRUCTW
*cs
)
3227 REBAR_INFO
*infoPtr
= REBAR_GetInfoPtr (hwnd
);
3229 NONCLIENTMETRICSW ncm
;
3233 ERR("Strange info structure pointer *not* NULL\n");
3237 if (TRACE_ON(rebar
)) {
3238 GetWindowRect(hwnd
, &wnrc1
);
3239 GetClientRect(hwnd
, &clrc1
);
3240 TRACE("window=(%s) client=(%s) cs=(%d,%d %dx%d)\n",
3241 wine_dbgstr_rect(&wnrc1
), wine_dbgstr_rect(&clrc1
),
3242 cs
->x
, cs
->y
, cs
->cx
, cs
->cy
);
3245 /* allocate memory for info structure */
3246 infoPtr
= Alloc (sizeof(REBAR_INFO
));
3247 SetWindowLongPtrW (hwnd
, 0, (DWORD_PTR
)infoPtr
);
3249 /* initialize info structure - initial values are 0 */
3250 infoPtr
->clrBk
= CLR_NONE
;
3251 infoPtr
->clrText
= CLR_NONE
;
3252 infoPtr
->clrBtnText
= comctl32_color
.clrBtnText
;
3253 infoPtr
->clrBtnFace
= comctl32_color
.clrBtnFace
;
3254 infoPtr
->iOldBand
= -1;
3255 infoPtr
->ichevronhotBand
= -2;
3256 infoPtr
->iGrabbedBand
= -1;
3257 infoPtr
->hwndSelf
= hwnd
;
3258 infoPtr
->DoRedraw
= TRUE
;
3259 infoPtr
->hcurArrow
= LoadCursorW (0, (LPWSTR
)IDC_ARROW
);
3260 infoPtr
->hcurHorz
= LoadCursorW (0, (LPWSTR
)IDC_SIZEWE
);
3261 infoPtr
->hcurVert
= LoadCursorW (0, (LPWSTR
)IDC_SIZENS
);
3262 infoPtr
->hcurDrag
= LoadCursorW (0, (LPWSTR
)IDC_SIZE
);
3263 infoPtr
->fStatus
= 0;
3264 infoPtr
->hFont
= GetStockObject (SYSTEM_FONT
);
3265 infoPtr
->bands
= DPA_Create(8);
3267 /* issue WM_NOTIFYFORMAT to get unicode status of parent */
3268 REBAR_NotifyFormat(infoPtr
, NF_REQUERY
);
3270 /* Stow away the original style */
3271 infoPtr
->orgStyle
= cs
->style
;
3272 /* add necessary styles to the requested styles */
3273 infoPtr
->dwStyle
= cs
->style
| WS_VISIBLE
;
3274 if ((infoPtr
->dwStyle
& CCS_LAYOUT_MASK
) == 0)
3275 infoPtr
->dwStyle
|= CCS_TOP
;
3276 SetWindowLongW (hwnd
, GWL_STYLE
, infoPtr
->dwStyle
);
3278 /* get font handle for Caption Font */
3279 ncm
.cbSize
= sizeof(ncm
);
3280 SystemParametersInfoW (SPI_GETNONCLIENTMETRICS
, ncm
.cbSize
, &ncm
, 0);
3281 /* if the font is bold, set to normal */
3282 if (ncm
.lfCaptionFont
.lfWeight
> FW_NORMAL
) {
3283 ncm
.lfCaptionFont
.lfWeight
= FW_NORMAL
;
3285 tfont
= CreateFontIndirectW (&ncm
.lfCaptionFont
);
3287 infoPtr
->hFont
= infoPtr
->hDefaultFont
= tfont
;
3295 REBAR_NCHitTest (const REBAR_INFO
*infoPtr
, LPARAM lParam
)
3301 LRESULT ret
= HTCLIENT
;
3304 * Differences from doc at MSDN (as observed with version 4.71 of
3306 * 1. doc says nmmouse.pt is in screen coord, trace shows client coord.
3307 * 2. if band is not identified .dwItemSpec is 0xffffffff.
3308 * 3. native always seems to return HTCLIENT if notify return is 0.
3311 clpt
.x
= (short)LOWORD(lParam
);
3312 clpt
.y
= (short)HIWORD(lParam
);
3313 ScreenToClient (infoPtr
->hwndSelf
, &clpt
);
3314 REBAR_InternalHitTest (infoPtr
, &clpt
, &scrap
,
3315 (INT
*)&nmmouse
.dwItemSpec
);
3316 nmmouse
.dwItemData
= 0;
3318 nmmouse
.dwHitInfo
= 0;
3319 if ((i
= REBAR_Notify((NMHDR
*) &nmmouse
, infoPtr
, NM_NCHITTEST
))) {
3320 TRACE("notify changed return value from %ld to %d\n",
3324 TRACE("returning %ld, client point %s\n", ret
, wine_dbgstr_point(&clpt
));
3330 REBAR_NCPaint (const REBAR_INFO
*infoPtr
)
3336 if (infoPtr
->dwStyle
& WS_MINIMIZE
)
3337 return 0; /* Nothing to do */
3339 if (infoPtr
->dwStyle
& WS_BORDER
) {
3341 /* adjust rectangle and draw the necessary edge */
3342 if (!(hdc
= GetDCEx( infoPtr
->hwndSelf
, 0, DCX_USESTYLE
| DCX_WINDOW
)))
3344 GetWindowRect (infoPtr
->hwndSelf
, &rcWindow
);
3345 OffsetRect (&rcWindow
, -rcWindow
.left
, -rcWindow
.top
);
3346 TRACE("rect (%s)\n", wine_dbgstr_rect(&rcWindow
));
3347 DrawEdge (hdc
, &rcWindow
, EDGE_ETCHED
, BF_RECT
);
3348 ReleaseDC( infoPtr
->hwndSelf
, hdc
);
3350 else if ((theme
= GetWindowTheme (infoPtr
->hwndSelf
)))
3352 /* adjust rectangle and draw the necessary edge */
3353 if (!(hdc
= GetDCEx( infoPtr
->hwndSelf
, 0, DCX_USESTYLE
| DCX_WINDOW
)))
3355 GetWindowRect (infoPtr
->hwndSelf
, &rcWindow
);
3356 OffsetRect (&rcWindow
, -rcWindow
.left
, -rcWindow
.top
);
3357 TRACE("rect (%s)\n", wine_dbgstr_rect(&rcWindow
));
3358 DrawThemeEdge (theme
, hdc
, 0, 0, &rcWindow
, BDR_RAISEDINNER
, BF_TOP
, NULL
);
3359 ReleaseDC( infoPtr
->hwndSelf
, hdc
);
3367 REBAR_NotifyFormat (REBAR_INFO
*infoPtr
, LPARAM cmd
)
3371 if (cmd
== NF_REQUERY
) {
3372 i
= SendMessageW(REBAR_GetNotifyParent (infoPtr
),
3373 WM_NOTIFYFORMAT
, (WPARAM
)infoPtr
->hwndSelf
, NF_QUERY
);
3374 if ((i
!= NFR_ANSI
) && (i
!= NFR_UNICODE
)) {
3375 ERR("wrong response to WM_NOTIFYFORMAT (%d), assuming ANSI\n", i
);
3378 infoPtr
->bUnicode
= (i
== NFR_UNICODE
);
3381 return (LRESULT
)((infoPtr
->bUnicode
) ? NFR_UNICODE
: NFR_ANSI
);
3386 REBAR_Paint (const REBAR_INFO
*infoPtr
, HDC hdc
)
3389 TRACE("painting\n");
3390 REBAR_Refresh (infoPtr
, hdc
);
3393 hdc
= BeginPaint (infoPtr
->hwndSelf
, &ps
);
3394 TRACE("painting (%s)\n", wine_dbgstr_rect(&ps
.rcPaint
));
3396 /* Erase area of paint if requested */
3397 REBAR_EraseBkGnd (infoPtr
, hdc
);
3399 REBAR_Refresh (infoPtr
, hdc
);
3400 EndPaint (infoPtr
->hwndSelf
, &ps
);
3408 REBAR_SetCursor (const REBAR_INFO
*infoPtr
, LPARAM lParam
)
3413 TRACE("code=0x%X id=0x%X\n", LOWORD(lParam
), HIWORD(lParam
));
3416 ScreenToClient (infoPtr
->hwndSelf
, &pt
);
3418 REBAR_InternalHitTest (infoPtr
, &pt
, &flags
, NULL
);
3420 if (flags
== RBHT_GRABBER
) {
3421 if ((infoPtr
->dwStyle
& CCS_VERT
) &&
3422 !(infoPtr
->dwStyle
& RBS_VERTICALGRIPPER
))
3423 SetCursor (infoPtr
->hcurVert
);
3425 SetCursor (infoPtr
->hcurHorz
);
3427 else if (flags
!= RBHT_CLIENT
)
3428 SetCursor (infoPtr
->hcurArrow
);
3435 REBAR_SetFont (REBAR_INFO
*infoPtr
, HFONT font
)
3440 infoPtr
->hFont
= font
;
3442 /* revalidate all bands to change sizes of text in headers of bands */
3443 for (i
=0; i
<infoPtr
->uNumBands
; i
++) {
3444 lpBand
= REBAR_GetBand(infoPtr
, i
);
3445 REBAR_ValidateBand (infoPtr
, lpBand
);
3448 REBAR_Layout(infoPtr
);
3453 /*****************************************************
3455 * Handles the WM_SETREDRAW message.
3458 * According to testing V4.71 of COMCTL32 returns the
3459 * *previous* status of the redraw flag (either 0 or -1)
3460 * instead of the MSDN documented value of 0 if handled
3462 *****************************************************/
3463 static inline LRESULT
3464 REBAR_SetRedraw (REBAR_INFO
*infoPtr
, BOOL redraw
)
3466 BOOL oldredraw
= infoPtr
->DoRedraw
;
3468 TRACE("set to %s, fStatus=%08x\n",
3469 (redraw
) ? "TRUE" : "FALSE", infoPtr
->fStatus
);
3470 infoPtr
->DoRedraw
= redraw
;
3472 if (infoPtr
->fStatus
& BAND_NEEDS_REDRAW
) {
3473 REBAR_MoveChildWindows (infoPtr
, 0, infoPtr
->uNumBands
);
3474 REBAR_ForceResize (infoPtr
);
3475 InvalidateRect (infoPtr
->hwndSelf
, NULL
, TRUE
);
3477 infoPtr
->fStatus
&= ~BAND_NEEDS_REDRAW
;
3479 return (oldredraw
) ? -1 : 0;
3484 REBAR_Size (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
3486 TRACE("wParam=%lx, lParam=%lx\n", wParam
, lParam
);
3488 /* avoid _Layout resize recursion (but it shouldn't be infinite and it seems Windows does recurse) */
3489 if (infoPtr
->fStatus
& SELF_RESIZE
) {
3490 infoPtr
->fStatus
&= ~SELF_RESIZE
;
3491 TRACE("SELF_RESIZE was set, reset, fStatus=%08x lparam=%08lx\n",
3492 infoPtr
->fStatus
, lParam
);
3496 if (infoPtr
->dwStyle
& RBS_AUTOSIZE
)
3497 REBAR_AutoSize(infoPtr
, TRUE
);
3499 REBAR_Layout(infoPtr
);
3506 REBAR_StyleChanged (REBAR_INFO
*infoPtr
, INT nType
, const STYLESTRUCT
*lpStyle
)
3508 TRACE("current style=%08x, styleOld=%08x, style being set to=%08x\n",
3509 infoPtr
->dwStyle
, lpStyle
->styleOld
, lpStyle
->styleNew
);
3510 if (nType
== GWL_STYLE
)
3512 infoPtr
->orgStyle
= infoPtr
->dwStyle
= lpStyle
->styleNew
;
3513 if (GetWindowTheme (infoPtr
->hwndSelf
))
3514 infoPtr
->dwStyle
&= ~WS_BORDER
;
3515 /* maybe it should be COMMON_STYLES like in toolbar */
3516 if ((lpStyle
->styleNew
^ lpStyle
->styleOld
) & CCS_VERT
)
3517 REBAR_Layout(infoPtr
);
3522 /* update theme after a WM_THEMECHANGED message */
3523 static LRESULT
theme_changed (REBAR_INFO
* infoPtr
)
3525 HTHEME theme
= GetWindowTheme (infoPtr
->hwndSelf
);
3526 CloseThemeData (theme
);
3527 theme
= OpenThemeData (infoPtr
->hwndSelf
, themeClass
);
3528 /* WS_BORDER disappears when theming is enabled and reappears when
3530 infoPtr
->dwStyle
&= ~WS_BORDER
;
3531 infoPtr
->dwStyle
|= theme
? 0 : (infoPtr
->orgStyle
& WS_BORDER
);
3536 REBAR_WindowPosChanged (const REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
3541 ret
= DefWindowProcW(infoPtr
->hwndSelf
, WM_WINDOWPOSCHANGED
,
3543 GetWindowRect(infoPtr
->hwndSelf
, &rc
);
3544 TRACE("hwnd %p new pos (%s)\n", infoPtr
->hwndSelf
, wine_dbgstr_rect(&rc
));
3549 static LRESULT WINAPI
3550 REBAR_WindowProc (HWND hwnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
)
3552 REBAR_INFO
*infoPtr
= REBAR_GetInfoPtr (hwnd
);
3554 TRACE("hwnd=%p msg=%x wparam=%lx lparam=%lx\n",
3555 hwnd
, uMsg
, wParam
, lParam
);
3556 if (!infoPtr
&& (uMsg
!= WM_NCCREATE
))
3557 return DefWindowProcW (hwnd
, uMsg
, wParam
, lParam
);
3560 /* case RB_BEGINDRAG: */
3563 return REBAR_DeleteBand (infoPtr
, wParam
);
3565 /* case RB_DRAGMOVE: */
3566 /* case RB_ENDDRAG: */
3568 case RB_GETBANDBORDERS
:
3569 return REBAR_GetBandBorders (infoPtr
, wParam
, (LPRECT
)lParam
);
3571 case RB_GETBANDCOUNT
:
3572 return REBAR_GetBandCount (infoPtr
);
3574 case RB_GETBANDINFO_OLD
:
3575 case RB_GETBANDINFOA
:
3576 case RB_GETBANDINFOW
:
3577 return REBAR_GetBandInfoT(infoPtr
, wParam
, (LPREBARBANDINFOW
)lParam
,
3578 uMsg
== RB_GETBANDINFOW
);
3579 case RB_GETBARHEIGHT
:
3580 return REBAR_GetBarHeight (infoPtr
);
3583 return REBAR_GetBarInfo (infoPtr
, (LPREBARINFO
)lParam
);
3586 return REBAR_GetBkColor (infoPtr
);
3588 /* case RB_GETCOLORSCHEME: */
3589 /* case RB_GETDROPTARGET: */
3592 return REBAR_GetPalette (infoPtr
);
3595 return REBAR_GetRect (infoPtr
, wParam
, (LPRECT
)lParam
);
3597 case RB_GETROWCOUNT
:
3598 return REBAR_GetRowCount (infoPtr
);
3600 case RB_GETROWHEIGHT
:
3601 return REBAR_GetRowHeight (infoPtr
, wParam
);
3603 case RB_GETTEXTCOLOR
:
3604 return REBAR_GetTextColor (infoPtr
);
3606 case RB_GETTOOLTIPS
:
3607 return REBAR_GetToolTips (infoPtr
);
3609 case RB_GETUNICODEFORMAT
:
3610 return REBAR_GetUnicodeFormat (infoPtr
);
3612 case CCM_GETVERSION
:
3613 return REBAR_GetVersion (infoPtr
);
3616 return REBAR_HitTest (infoPtr
, (LPRBHITTESTINFO
)lParam
);
3619 return REBAR_IdToIndex (infoPtr
, wParam
);
3621 case RB_INSERTBANDA
:
3622 case RB_INSERTBANDW
:
3623 return REBAR_InsertBandT(infoPtr
, wParam
, (LPREBARBANDINFOW
)lParam
,
3624 uMsg
== RB_INSERTBANDW
);
3625 case RB_MAXIMIZEBAND
:
3626 return REBAR_MaximizeBand (infoPtr
, wParam
, lParam
);
3628 case RB_MINIMIZEBAND
:
3629 return REBAR_MinimizeBand (infoPtr
, wParam
);
3632 return REBAR_MoveBand (infoPtr
, wParam
, lParam
);
3634 case RB_PUSHCHEVRON
:
3635 return REBAR_PushChevron (infoPtr
, wParam
, lParam
);
3637 case RB_SETBANDINFOA
:
3638 case RB_SETBANDINFOW
:
3639 return REBAR_SetBandInfoT(infoPtr
, wParam
, (LPREBARBANDINFOW
)lParam
,
3640 uMsg
== RB_SETBANDINFOW
);
3642 return REBAR_SetBarInfo (infoPtr
, (LPREBARINFO
)lParam
);
3645 return REBAR_SetBkColor (infoPtr
, lParam
);
3647 /* case RB_SETCOLORSCHEME: */
3648 /* case RB_SETPALETTE: */
3651 return REBAR_SetParent (infoPtr
, (HWND
)wParam
);
3653 case RB_SETTEXTCOLOR
:
3654 return REBAR_SetTextColor (infoPtr
, lParam
);
3656 /* case RB_SETTOOLTIPS: */
3658 case RB_SETUNICODEFORMAT
:
3659 return REBAR_SetUnicodeFormat (infoPtr
, wParam
);
3661 case CCM_SETVERSION
:
3662 return REBAR_SetVersion (infoPtr
, (INT
)wParam
);
3665 return REBAR_ShowBand (infoPtr
, wParam
, lParam
);
3668 return REBAR_SizeToRect (infoPtr
, (LPCRECT
)lParam
);
3671 /* Messages passed to parent */
3675 case WM_MEASUREITEM
:
3676 return SendMessageW(REBAR_GetNotifyParent (infoPtr
), uMsg
, wParam
, lParam
);
3679 /* case WM_CHARTOITEM: supported according to ControlSpy */
3682 return REBAR_Create (infoPtr
, (LPCREATESTRUCTW
)lParam
);
3685 return REBAR_Destroy (infoPtr
);
3688 return REBAR_EraseBkGnd (infoPtr
, (HDC
)wParam
);
3691 return REBAR_GetFont (infoPtr
);
3693 /* case WM_LBUTTONDBLCLK: supported according to ControlSpy */
3695 case WM_LBUTTONDOWN
:
3696 return REBAR_LButtonDown (infoPtr
, lParam
);
3699 return REBAR_LButtonUp (infoPtr
);
3702 return REBAR_MouseMove (infoPtr
, lParam
);
3705 return REBAR_MouseLeave (infoPtr
);
3708 return REBAR_NCCalcSize (infoPtr
, (RECT
*)lParam
);
3711 return REBAR_NCCreate (hwnd
, (LPCREATESTRUCTW
)lParam
);
3714 return REBAR_NCHitTest (infoPtr
, lParam
);
3717 return REBAR_NCPaint (infoPtr
);
3719 case WM_NOTIFYFORMAT
:
3720 return REBAR_NotifyFormat (infoPtr
, lParam
);
3722 case WM_PRINTCLIENT
:
3724 return REBAR_Paint (infoPtr
, (HDC
)wParam
);
3726 /* case WM_PALETTECHANGED: supported according to ControlSpy */
3727 /* case WM_QUERYNEWPALETTE:supported according to ControlSpy */
3728 /* case WM_RBUTTONDOWN: supported according to ControlSpy */
3729 /* case WM_RBUTTONUP: supported according to ControlSpy */
3732 return REBAR_SetCursor (infoPtr
, lParam
);
3735 return REBAR_SetFont (infoPtr
, (HFONT
)wParam
);
3738 return REBAR_SetRedraw (infoPtr
, wParam
);
3741 return REBAR_Size (infoPtr
, wParam
, lParam
);
3743 case WM_STYLECHANGED
:
3744 return REBAR_StyleChanged (infoPtr
, wParam
, (LPSTYLESTRUCT
)lParam
);
3746 case WM_THEMECHANGED
:
3747 return theme_changed (infoPtr
);
3749 case WM_SYSCOLORCHANGE
:
3750 COMCTL32_RefreshSysColors();
3753 /* case WM_VKEYTOITEM: supported according to ControlSpy */
3754 /* case WM_WININICHANGE: */
3756 case WM_WINDOWPOSCHANGED
:
3757 return REBAR_WindowPosChanged (infoPtr
, wParam
, lParam
);
3760 if ((uMsg
>= WM_USER
) && (uMsg
< WM_APP
) && !COMCTL32_IsReflectedMessage(uMsg
))
3761 ERR("unknown msg %04x wp=%08lx lp=%08lx\n",
3762 uMsg
, wParam
, lParam
);
3763 return DefWindowProcW (hwnd
, uMsg
, wParam
, lParam
);
3769 REBAR_Register (void)
3773 ZeroMemory (&wndClass
, sizeof(WNDCLASSW
));
3774 wndClass
.style
= CS_GLOBALCLASS
| CS_DBLCLKS
;
3775 wndClass
.lpfnWndProc
= REBAR_WindowProc
;
3776 wndClass
.cbClsExtra
= 0;
3777 wndClass
.cbWndExtra
= sizeof(REBAR_INFO
*);
3778 wndClass
.hCursor
= 0;
3779 wndClass
.hbrBackground
= (HBRUSH
)(COLOR_BTNFACE
+ 1);
3781 wndClass
.hbrBackground
= CreateSolidBrush(RGB(0,128,0));
3783 wndClass
.lpszClassName
= REBARCLASSNAMEW
;
3785 RegisterClassW (&wndClass
);
3787 mindragx
= GetSystemMetrics (SM_CXDRAG
);
3788 mindragy
= GetSystemMetrics (SM_CYDRAG
);
3794 REBAR_Unregister (void)
3796 UnregisterClassW (REBARCLASSNAMEW
, NULL
);