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
94 #include "wine/debug.h"
96 WINE_DEFAULT_DEBUG_CHANNEL(rebar
);
106 UINT cxMinChild
; /* valid if _CHILDSIZE */
107 UINT cyMinChild
; /* valid if _CHILDSIZE */
108 UINT cx
; /* valid if _SIZE */
111 UINT cyChild
; /* valid if _CHILDSIZE */
112 UINT cyMaxChild
; /* valid if _CHILDSIZE */
113 UINT cyIntegral
; /* valid if _CHILDSIZE */
118 INT cxEffective
; /* current cx for band */
119 UINT cyHeader
; /* the height of the header */
120 UINT cxMinBand
; /* minimum cx for band */
121 UINT cyMinBand
; /* minimum cy for band */
123 UINT cyRowSoFar
; /* for RBS_VARHEIGHT - the height of the row if it would break on this band (set by _Layout) */
124 INT iRow
; /* zero-based index of the row this band assigned to */
125 UINT fStatus
; /* status flags, reset only by _Validate */
126 UINT fDraw
; /* drawing flags, reset only by _Layout */
127 UINT uCDret
; /* last return from NM_CUSTOMDRAW */
128 RECT rcBand
; /* calculated band rectangle - coordinates swapped for CCS_VERT */
129 RECT rcGripper
; /* calculated gripper rectangle */
130 RECT rcCapImage
; /* calculated caption image rectangle */
131 RECT rcCapText
; /* calculated caption text rectangle */
132 RECT rcChild
; /* calculated child rectangle */
133 RECT rcChevron
; /* calculated chevron rectangle */
139 /* has a value of: 0, CCS_TOP, CCS_NOMOVEY, CCS_BOTTOM */
140 #define CCS_LAYOUT_MASK 0x3
143 #define HAS_GRIPPER 0x00000001
144 #define HAS_IMAGE 0x00000002
145 #define HAS_TEXT 0x00000004
148 #define DRAW_GRIPPER 0x00000001
149 #define DRAW_IMAGE 0x00000002
150 #define DRAW_TEXT 0x00000004
151 #define DRAW_CHEVRONHOT 0x00000040
152 #define DRAW_CHEVRONPUSHED 0x00000080
153 #define NTF_INVALIDATE 0x01000000
157 COLORREF clrBk
; /* background color */
158 COLORREF clrText
; /* text color */
159 COLORREF clrBtnText
; /* system color for BTNTEXT */
160 COLORREF clrBtnFace
; /* system color for BTNFACE */
161 HIMAGELIST himl
; /* handle to imagelist */
162 UINT uNumBands
; /* # of bands in rebar (first=0, last=uNumBands-1 */
163 UINT uNumRows
; /* # of rows of bands (first=1, last=uNumRows */
164 HWND hwndSelf
; /* handle of REBAR window itself */
165 HWND hwndToolTip
; /* handle to the tool tip control */
166 HWND hwndNotify
; /* notification window (parent) */
168 HFONT hFont
; /* handle to the rebar's font */
169 SIZE imageSize
; /* image size (image list) */
170 DWORD dwStyle
; /* window style */
171 DWORD orgStyle
; /* original style (dwStyle may change) */
172 SIZE calcSize
; /* calculated rebar size - coordinates swapped for CCS_VERT */
173 BOOL bUnicode
; /* TRUE if parent wants notify in W format */
174 BOOL DoRedraw
; /* TRUE to actually draw bands */
175 UINT fStatus
; /* Status flags (see below) */
176 HCURSOR hcurArrow
; /* handle to the arrow cursor */
177 HCURSOR hcurHorz
; /* handle to the EW cursor */
178 HCURSOR hcurVert
; /* handle to the NS cursor */
179 HCURSOR hcurDrag
; /* handle to the drag cursor */
180 INT iVersion
; /* version number */
181 POINT dragStart
; /* x,y of button down */
182 POINT dragNow
; /* x,y of this MouseMove */
183 INT iOldBand
; /* last band that had the mouse cursor over it */
184 INT ihitoffset
; /* offset of hotspot from gripper.left */
185 INT ichevronhotBand
; /* last band that had a hot chevron */
186 INT iGrabbedBand
;/* band number of band whose gripper was grabbed */
188 HDPA bands
; /* pointer to the array of rebar bands */
192 #define BEGIN_DRAG_ISSUED 0x00000001
193 #define SELF_RESIZE 0x00000002
194 #define BAND_NEEDS_REDRAW 0x00000020
196 /* used by Windows to mark that the header size has been set by the user and shouldn't be changed */
197 #define RBBS_UNDOC_FIXEDHEADER 0x40000000
199 /* ---- REBAR layout constants. Mostly determined by ---- */
200 /* ---- experiment on WIN 98. ---- */
202 /* Width (or height) of separators between bands (either horz. or */
203 /* vert.). True only if RBS_BANDBORDERS is set */
204 #define SEP_WIDTH_SIZE 2
205 #define SEP_WIDTH ((infoPtr->dwStyle & RBS_BANDBORDERS) ? SEP_WIDTH_SIZE : 0)
207 /* Blank (background color) space between Gripper (if present) */
208 /* and next item (image, text, or window). Always present */
209 #define REBAR_ALWAYS_SPACE 4
211 /* Blank (background color) space after Image (if present). */
212 #define REBAR_POST_IMAGE 2
214 /* Blank (background color) space after Text (if present). */
215 #define REBAR_POST_TEXT 4
217 /* Height of vertical gripper in a CCS_VERT rebar. */
218 #define GRIPPER_HEIGHT 16
220 /* Blank (background color) space before Gripper (if present). */
221 #define REBAR_PRE_GRIPPER 2
223 /* Width (of normal vertical gripper) or height (of horz. gripper) */
225 #define GRIPPER_WIDTH 3
227 /* Width of the chevron button if present */
228 #define CHEVRON_WIDTH 10
230 /* the gap between the child and the next band */
231 #define REBAR_POST_CHILD 4
233 /* Height of divider for Rebar if not disabled (CCS_NODIVIDER) */
234 /* either top or bottom */
235 #define REBAR_DIVIDER 2
237 /* height of a rebar without a child */
238 #define REBAR_NO_CHILD_HEIGHT 4
240 /* minimum vertical height of a normal bar */
241 /* or minimum width of a CCS_VERT bar - from experiment on Win2k */
242 #define REBAR_MINSIZE 23
244 /* This is the increment that is used over the band height */
245 #define REBARSPACE(a) ((a->fStyle & RBBS_CHILDEDGE) ? 2*REBAR_DIVIDER : 0)
247 /* ---- End of REBAR layout constants. ---- */
249 #define RB_GETBANDINFO_OLD (WM_USER+5) /* obsoleted after IE3, but we have to support it anyway */
251 /* The following define determines if a given band is hidden */
252 #define HIDDENBAND(a) (((a)->fStyle & RBBS_HIDDEN) || \
253 ((infoPtr->dwStyle & CCS_VERT) && \
254 ((a)->fStyle & RBBS_NOVERT)))
256 #define REBAR_GetInfoPtr(wndPtr) ((REBAR_INFO *)GetWindowLongPtrW (hwnd, 0))
258 static LRESULT
REBAR_NotifyFormat(REBAR_INFO
*infoPtr
, LPARAM lParam
);
259 static void REBAR_AutoSize(REBAR_INFO
*infoPtr
, BOOL needsLayout
);
261 /* no index check here */
262 static inline REBAR_BAND
* REBAR_GetBand(const REBAR_INFO
*infoPtr
, INT i
)
264 assert(i
>= 0 && i
< infoPtr
->uNumBands
);
265 return DPA_GetPtr(infoPtr
->bands
, i
);
268 /* "constant values" retrieved when DLL was initialized */
269 /* FIXME we do this when the classes are registered. */
270 static UINT mindragx
= 0;
271 static UINT mindragy
= 0;
273 static const char * const band_stylename
[] = {
274 "RBBS_BREAK", /* 0001 */
275 "RBBS_FIXEDSIZE", /* 0002 */
276 "RBBS_CHILDEDGE", /* 0004 */
277 "RBBS_HIDDEN", /* 0008 */
278 "RBBS_NOVERT", /* 0010 */
279 "RBBS_FIXEDBMP", /* 0020 */
280 "RBBS_VARIABLEHEIGHT", /* 0040 */
281 "RBBS_GRIPPERALWAYS", /* 0080 */
282 "RBBS_NOGRIPPER", /* 0100 */
283 "RBBS_USECHEVRON", /* 0200 */
284 "RBBS_HIDETITLE", /* 0400 */
285 "RBBS_TOPALIGN", /* 0800 */
288 static const char * const band_maskname
[] = {
289 "RBBIM_STYLE", /* 0x00000001 */
290 "RBBIM_COLORS", /* 0x00000002 */
291 "RBBIM_TEXT", /* 0x00000004 */
292 "RBBIM_IMAGE", /* 0x00000008 */
293 "RBBIM_CHILD", /* 0x00000010 */
294 "RBBIM_CHILDSIZE", /* 0x00000020 */
295 "RBBIM_SIZE", /* 0x00000040 */
296 "RBBIM_BACKGROUND", /* 0x00000080 */
297 "RBBIM_ID", /* 0x00000100 */
298 "RBBIM_IDEALSIZE", /* 0x00000200 */
299 "RBBIM_LPARAM", /* 0x00000400 */
300 "RBBIM_HEADERSIZE", /* 0x00000800 */
301 "RBBIM_CHEVRONLOCATION", /* 0x00001000 */
302 "RBBIM_CHEVRONSTATE", /* 0x00002000 */
305 static const WCHAR themeClass
[] = L
"Rebar";
308 REBAR_FmtStyle(char *buffer
, UINT style
)
313 while (band_stylename
[i
]) {
314 if (style
& (1<<i
)) {
315 if (*buffer
) strcat(buffer
, " | ");
316 strcat(buffer
, band_stylename
[i
]);
325 REBAR_FmtMask(char *buffer
, UINT mask
)
330 while (band_maskname
[i
]) {
332 if (*buffer
) strcat(buffer
, " | ");
333 strcat(buffer
, band_maskname
[i
]);
342 REBAR_DumpBandInfo(const REBARBANDINFOW
*pB
)
346 if( !TRACE_ON(rebar
) ) return;
347 TRACE("band info: ");
348 if (pB
->fMask
& RBBIM_ID
)
349 TRACE("ID=%u, ", pB
->wID
);
350 TRACE("size=%u, child=%p", pB
->cbSize
, pB
->hwndChild
);
351 if (pB
->fMask
& RBBIM_COLORS
)
352 TRACE(", clrF=%#lx, clrB=%#lx", pB
->clrFore
, pB
->clrBack
);
355 TRACE("band info: mask=0x%08x (%s)\n", pB
->fMask
, REBAR_FmtMask(buff
, pB
->fMask
));
356 if (pB
->fMask
& RBBIM_STYLE
)
357 TRACE("band info: style=0x%08x (%s)\n", pB
->fStyle
, REBAR_FmtStyle(buff
, pB
->fStyle
));
358 if (pB
->fMask
& (RBBIM_SIZE
| RBBIM_IDEALSIZE
| RBBIM_HEADERSIZE
| RBBIM_LPARAM
)) {
360 if (pB
->fMask
& RBBIM_SIZE
)
361 TRACE(" cx=%u", pB
->cx
);
362 if (pB
->fMask
& RBBIM_IDEALSIZE
)
363 TRACE(" xIdeal=%u", pB
->cxIdeal
);
364 if (pB
->fMask
& RBBIM_HEADERSIZE
)
365 TRACE(" xHeader=%u", pB
->cxHeader
);
366 if (pB
->fMask
& RBBIM_LPARAM
)
367 TRACE(" lParam %Ix", pB
->lParam
);
370 if (pB
->fMask
& RBBIM_CHILDSIZE
)
371 TRACE("band info: xMin=%u, yMin=%u, yChild=%u, yMax=%u, yIntgl=%u\n",
373 pB
->cyMinChild
, pB
->cyChild
, pB
->cyMaxChild
, pB
->cyIntegral
);
377 REBAR_DumpBand (const REBAR_INFO
*iP
)
383 if(! TRACE_ON(rebar
) ) return;
385 TRACE("hwnd=%p: color=%#lx/%#lx, bands=%u, rows=%u, cSize=%ld,%ld\n",
386 iP
->hwndSelf
, iP
->clrText
, iP
->clrBk
, iP
->uNumBands
, iP
->uNumRows
,
387 iP
->calcSize
.cx
, iP
->calcSize
.cy
);
388 TRACE("hwnd=%p: flags=%#x, dragStart=%ld,%ld, dragNow=%ld,%ld, iGrabbedBand=%d\n",
389 iP
->hwndSelf
, iP
->fStatus
, iP
->dragStart
.x
, iP
->dragStart
.y
,
390 iP
->dragNow
.x
, iP
->dragNow
.y
,
392 TRACE("hwnd=%p: style=%#lx, notify in Unicode=%s, redraw=%s\n",
393 iP
->hwndSelf
, iP
->dwStyle
, (iP
->bUnicode
)?"TRUE":"FALSE",
394 (iP
->DoRedraw
)?"TRUE":"FALSE");
395 for (i
= 0; i
< iP
->uNumBands
; i
++) {
396 pB
= REBAR_GetBand(iP
, i
);
397 TRACE("band # %u:", i
);
398 if (pB
->fMask
& RBBIM_ID
)
399 TRACE(" ID=%u", pB
->wID
);
400 if (pB
->fMask
& RBBIM_CHILD
)
401 TRACE(" child=%p", pB
->hwndChild
);
402 if (pB
->fMask
& RBBIM_COLORS
)
403 TRACE(" clrF=%#lx clrB=%#lx", pB
->clrFore
, pB
->clrBack
);
405 TRACE("band # %u: mask=0x%08x (%s)\n", i
, pB
->fMask
, REBAR_FmtMask(buff
, pB
->fMask
));
406 if (pB
->fMask
& RBBIM_STYLE
)
407 TRACE("band # %u: style=0x%08x (%s)\n", i
, pB
->fStyle
, REBAR_FmtStyle(buff
, pB
->fStyle
));
408 TRACE("band # %u: xHeader=%u",
410 if (pB
->fMask
& (RBBIM_SIZE
| RBBIM_IDEALSIZE
| RBBIM_LPARAM
)) {
411 if (pB
->fMask
& RBBIM_SIZE
)
412 TRACE(" cx=%u", pB
->cx
);
413 if (pB
->fMask
& RBBIM_IDEALSIZE
)
414 TRACE(" xIdeal=%u", pB
->cxIdeal
);
415 if (pB
->fMask
& RBBIM_LPARAM
)
416 TRACE(" lParam %Ix", pB
->lParam
);
420 TRACE("band # %u: xMin=%u, yMin=%u, yChild=%u, yMax=%u, yIntgl=%u\n",
421 i
, pB
->cxMinChild
, pB
->cyMinChild
, pB
->cyChild
, pB
->cyMaxChild
, pB
->cyIntegral
);
422 if (pB
->fMask
& RBBIM_TEXT
)
423 TRACE("band # %u: text=%s\n",
424 i
, (pB
->lpText
) ? debugstr_w(pB
->lpText
) : "(null)");
425 TRACE("band # %u: cxMinBand=%u, cxEffective=%u, cyMinBand=%u\n",
426 i
, pB
->cxMinBand
, pB
->cxEffective
, pB
->cyMinBand
);
427 TRACE("band # %u: fStatus=%08x, fDraw=%08x, Band=(%s), Grip=(%s)\n",
428 i
, pB
->fStatus
, pB
->fDraw
, wine_dbgstr_rect(&pB
->rcBand
),
429 wine_dbgstr_rect(&pB
->rcGripper
));
430 TRACE("band # %u: Img=(%s), Txt=(%s), Child=(%s)\n",
431 i
, wine_dbgstr_rect(&pB
->rcCapImage
),
432 wine_dbgstr_rect(&pB
->rcCapText
), wine_dbgstr_rect(&pB
->rcChild
));
437 /* dest can be equal to src */
438 static void translate_rect(const REBAR_INFO
*infoPtr
, RECT
*dest
, const RECT
*src
)
440 if (infoPtr
->dwStyle
& CCS_VERT
) {
443 dest
->left
= src
->top
;
447 dest
->right
= src
->bottom
;
454 static int get_rect_cx(const REBAR_INFO
*infoPtr
, const RECT
*lpRect
)
456 if (infoPtr
->dwStyle
& CCS_VERT
)
457 return lpRect
->bottom
- lpRect
->top
;
458 return lpRect
->right
- lpRect
->left
;
461 static int get_rect_cy(const REBAR_INFO
*infoPtr
, const RECT
*lpRect
)
463 if (infoPtr
->dwStyle
& CCS_VERT
)
464 return lpRect
->right
- lpRect
->left
;
465 return lpRect
->bottom
- lpRect
->top
;
468 static int round_child_height(const REBAR_BAND
*lpBand
, int cyHeight
)
471 if (lpBand
->cyIntegral
== 0)
473 cy
= max(cyHeight
- (int)lpBand
->cyMinChild
, 0);
474 cy
= lpBand
->cyMinChild
+ (cy
/lpBand
->cyIntegral
) * lpBand
->cyIntegral
;
475 cy
= min(cy
, lpBand
->cyMaxChild
);
479 static void update_min_band_height(const REBAR_INFO
*infoPtr
, REBAR_BAND
*lpBand
)
481 lpBand
->cyMinBand
= max(lpBand
->cyHeader
,
482 (lpBand
->hwndChild
? lpBand
->cyChild
+ REBARSPACE(lpBand
) : REBAR_NO_CHILD_HEIGHT
));
486 REBAR_DrawChevron (HDC hdc
, INT left
, INT top
, INT colorRef
)
491 if (!(hPen
= CreatePen( PS_SOLID
, 1, GetSysColor( colorRef
)))) return;
492 hOldPen
= SelectObject ( hdc
, hPen
);
495 MoveToEx (hdc
, x
, y
, NULL
);
496 LineTo (hdc
, x
+5, y
++); x
++;
497 MoveToEx (hdc
, x
, y
, NULL
);
498 LineTo (hdc
, x
+3, y
++); x
++;
499 MoveToEx (hdc
, x
, y
, NULL
);
500 LineTo (hdc
, x
+1, y
);
501 SelectObject( hdc
, hOldPen
);
502 DeleteObject( hPen
);
506 REBAR_GetNotifyParent (const REBAR_INFO
*infoPtr
)
510 parent
= infoPtr
->hwndNotify
;
512 parent
= GetParent (infoPtr
->hwndSelf
);
513 owner
= GetWindow (infoPtr
->hwndSelf
, GW_OWNER
);
514 if (owner
) parent
= owner
;
521 REBAR_Notify (NMHDR
*nmhdr
, const REBAR_INFO
*infoPtr
, UINT code
)
525 parent
= REBAR_GetNotifyParent (infoPtr
);
526 nmhdr
->idFrom
= GetDlgCtrlID (infoPtr
->hwndSelf
);
527 nmhdr
->hwndFrom
= infoPtr
->hwndSelf
;
530 TRACE("window %p, code=%08x, via %s\n", parent
, code
, (infoPtr
->bUnicode
)?"Unicode":"ANSI");
532 return SendMessageW(parent
, WM_NOTIFY
, nmhdr
->idFrom
, (LPARAM
)nmhdr
);
536 REBAR_Notify_NMREBAR (const REBAR_INFO
*infoPtr
, UINT uBand
, UINT code
)
538 NMREBAR notify_rebar
;
540 notify_rebar
.dwMask
= 0;
542 REBAR_BAND
*lpBand
= REBAR_GetBand(infoPtr
, uBand
);
544 if (lpBand
->fMask
& RBBIM_ID
) {
545 notify_rebar
.dwMask
|= RBNM_ID
;
546 notify_rebar
.wID
= lpBand
->wID
;
548 if (lpBand
->fMask
& RBBIM_LPARAM
) {
549 notify_rebar
.dwMask
|= RBNM_LPARAM
;
550 notify_rebar
.lParam
= lpBand
->lParam
;
552 if (lpBand
->fMask
& RBBIM_STYLE
) {
553 notify_rebar
.dwMask
|= RBNM_STYLE
;
554 notify_rebar
.fStyle
= lpBand
->fStyle
;
557 notify_rebar
.uBand
= uBand
;
558 return REBAR_Notify ((NMHDR
*)¬ify_rebar
, infoPtr
, code
);
562 REBAR_DrawBand (HDC hdc
, const REBAR_INFO
*infoPtr
, REBAR_BAND
*lpBand
)
567 HTHEME theme
= GetWindowTheme (infoPtr
->hwndSelf
);
570 translate_rect(infoPtr
, &rcBand
, &lpBand
->rcBand
);
572 if (lpBand
->fDraw
& DRAW_TEXT
) {
573 hOldFont
= SelectObject (hdc
, infoPtr
->hFont
);
574 oldBkMode
= SetBkMode (hdc
, TRANSPARENT
);
577 /* should test for CDRF_NOTIFYITEMDRAW here */
578 nmcd
.dwDrawStage
= CDDS_ITEMPREPAINT
;
581 nmcd
.rc
.right
= lpBand
->rcCapText
.right
;
582 nmcd
.rc
.bottom
= lpBand
->rcCapText
.bottom
;
583 nmcd
.dwItemSpec
= lpBand
->wID
;
585 nmcd
.lItemlParam
= lpBand
->lParam
;
586 lpBand
->uCDret
= REBAR_Notify ((NMHDR
*)&nmcd
, infoPtr
, NM_CUSTOMDRAW
);
587 if (lpBand
->uCDret
== CDRF_SKIPDEFAULT
) {
588 if (oldBkMode
!= TRANSPARENT
)
589 SetBkMode (hdc
, oldBkMode
);
590 SelectObject (hdc
, hOldFont
);
595 if (lpBand
->fDraw
& DRAW_GRIPPER
)
599 RECT rcGripper
= lpBand
->rcGripper
;
600 int partId
= (infoPtr
->dwStyle
& CCS_VERT
) ? RP_GRIPPERVERT
: RP_GRIPPER
;
601 GetThemeBackgroundExtent (theme
, hdc
, partId
, 0, &rcGripper
, &rcGripper
);
602 OffsetRect (&rcGripper
, lpBand
->rcGripper
.left
- rcGripper
.left
,
603 lpBand
->rcGripper
.top
- rcGripper
.top
);
604 DrawThemeBackground (theme
, hdc
, partId
, 0, &rcGripper
, NULL
);
607 DrawEdge (hdc
, &lpBand
->rcGripper
, BDR_RAISEDINNER
, BF_RECT
| BF_MIDDLE
);
610 /* draw caption image */
611 if (lpBand
->fDraw
& DRAW_IMAGE
) {
615 pt
.y
= (lpBand
->rcCapImage
.bottom
+ lpBand
->rcCapImage
.top
- infoPtr
->imageSize
.cy
)/2;
616 pt
.x
= (lpBand
->rcCapImage
.right
+ lpBand
->rcCapImage
.left
- infoPtr
->imageSize
.cx
)/2;
618 ImageList_Draw (infoPtr
->himl
, lpBand
->iImage
, hdc
,
623 /* draw caption text */
624 if (lpBand
->fDraw
& DRAW_TEXT
) {
625 /* need to handle CDRF_NEWFONT here */
626 INT oldBkMode
= SetBkMode (hdc
, TRANSPARENT
);
627 COLORREF oldcolor
= CLR_NONE
;
629 if (lpBand
->clrFore
!= CLR_NONE
) {
630 new = (lpBand
->clrFore
== CLR_DEFAULT
) ? infoPtr
->clrBtnText
:
632 oldcolor
= SetTextColor (hdc
, new);
634 DrawTextW (hdc
, lpBand
->lpText
, -1, &lpBand
->rcCapText
,
635 DT_CENTER
| DT_VCENTER
| DT_SINGLELINE
);
636 if (oldBkMode
!= TRANSPARENT
)
637 SetBkMode (hdc
, oldBkMode
);
638 if (lpBand
->clrFore
!= CLR_NONE
)
639 SetTextColor (hdc
, oldcolor
);
640 SelectObject (hdc
, hOldFont
);
643 if (!IsRectEmpty(&lpBand
->rcChevron
))
648 if (lpBand
->fDraw
& DRAW_CHEVRONPUSHED
)
649 stateId
= CHEVS_PRESSED
;
650 else if (lpBand
->fDraw
& DRAW_CHEVRONHOT
)
653 stateId
= CHEVS_NORMAL
;
654 DrawThemeBackground (theme
, hdc
, RP_CHEVRON
, stateId
, &lpBand
->rcChevron
, NULL
);
658 if (lpBand
->fDraw
& DRAW_CHEVRONPUSHED
)
660 DrawEdge(hdc
, &lpBand
->rcChevron
, BDR_SUNKENOUTER
, BF_RECT
| BF_MIDDLE
);
661 REBAR_DrawChevron(hdc
, lpBand
->rcChevron
.left
+1, lpBand
->rcChevron
.top
+ 11, COLOR_WINDOWFRAME
);
663 else if (lpBand
->fDraw
& DRAW_CHEVRONHOT
)
665 DrawEdge(hdc
, &lpBand
->rcChevron
, BDR_RAISEDINNER
, BF_RECT
| BF_MIDDLE
);
666 REBAR_DrawChevron(hdc
, lpBand
->rcChevron
.left
, lpBand
->rcChevron
.top
+ 10, COLOR_WINDOWFRAME
);
669 REBAR_DrawChevron(hdc
, lpBand
->rcChevron
.left
, lpBand
->rcChevron
.top
+ 10, COLOR_WINDOWFRAME
);
673 if (lpBand
->uCDret
== (CDRF_NOTIFYPOSTPAINT
| CDRF_NOTIFYITEMDRAW
)) {
674 nmcd
.dwDrawStage
= CDDS_ITEMPOSTPAINT
;
677 nmcd
.rc
.right
= lpBand
->rcCapText
.right
;
678 nmcd
.rc
.bottom
= lpBand
->rcCapText
.bottom
;
679 nmcd
.dwItemSpec
= lpBand
->wID
;
681 nmcd
.lItemlParam
= lpBand
->lParam
;
682 lpBand
->uCDret
= REBAR_Notify ((NMHDR
*)&nmcd
, infoPtr
, NM_CUSTOMDRAW
);
688 REBAR_Refresh (const REBAR_INFO
*infoPtr
, HDC hdc
)
693 if (!infoPtr
->DoRedraw
) return;
695 for (i
= 0; i
< infoPtr
->uNumBands
; i
++) {
696 lpBand
= REBAR_GetBand(infoPtr
, i
);
698 if (HIDDENBAND(lpBand
)) continue;
700 /* now draw the band */
701 TRACE("[%p] drawing band %i, flags=%08x\n",
702 infoPtr
->hwndSelf
, i
, lpBand
->fDraw
);
703 REBAR_DrawBand (hdc
, infoPtr
, lpBand
);
709 REBAR_CalcHorzBand (const REBAR_INFO
*infoPtr
, UINT rstart
, UINT rend
)
710 /* Function: this routine initializes all the rectangles in */
711 /* each band in a row to fit in the adjusted rcBand rect. */
712 /* *** Supports only Horizontal bars. *** */
718 for(i
=rstart
; i
<rend
; i
++){
719 lpBand
= REBAR_GetBand(infoPtr
, i
);
720 if (HIDDENBAND(lpBand
)) {
721 SetRect (&lpBand
->rcChild
,
722 lpBand
->rcBand
.right
, lpBand
->rcBand
.top
,
723 lpBand
->rcBand
.right
, lpBand
->rcBand
.bottom
);
727 /* set initial gripper rectangle */
728 SetRect (&lpBand
->rcGripper
, lpBand
->rcBand
.left
, lpBand
->rcBand
.top
,
729 lpBand
->rcBand
.left
, lpBand
->rcBand
.bottom
);
731 /* calculate gripper rectangle */
732 if ( lpBand
->fStatus
& HAS_GRIPPER
) {
733 lpBand
->fDraw
|= DRAW_GRIPPER
;
734 lpBand
->rcGripper
.left
+= REBAR_PRE_GRIPPER
;
735 lpBand
->rcGripper
.right
= lpBand
->rcGripper
.left
+ GRIPPER_WIDTH
;
736 InflateRect(&lpBand
->rcGripper
, 0, -2);
738 SetRect (&lpBand
->rcCapImage
,
739 lpBand
->rcGripper
.right
+REBAR_ALWAYS_SPACE
, lpBand
->rcBand
.top
,
740 lpBand
->rcGripper
.right
+REBAR_ALWAYS_SPACE
, lpBand
->rcBand
.bottom
);
742 else { /* no gripper will be drawn */
744 if (lpBand
->fStatus
& (HAS_IMAGE
| HAS_TEXT
))
745 /* if no gripper but either image or text, then leave space */
746 xoff
= REBAR_ALWAYS_SPACE
;
747 SetRect (&lpBand
->rcCapImage
,
748 lpBand
->rcBand
.left
+xoff
, lpBand
->rcBand
.top
,
749 lpBand
->rcBand
.left
+xoff
, lpBand
->rcBand
.bottom
);
752 /* image is visible */
753 if (lpBand
->fStatus
& HAS_IMAGE
) {
754 lpBand
->fDraw
|= DRAW_IMAGE
;
755 lpBand
->rcCapImage
.right
+= infoPtr
->imageSize
.cx
;
756 lpBand
->rcCapImage
.bottom
= lpBand
->rcCapImage
.top
+ infoPtr
->imageSize
.cy
;
758 /* set initial caption text rectangle */
759 SetRect (&lpBand
->rcCapText
,
760 lpBand
->rcCapImage
.right
+REBAR_POST_IMAGE
, lpBand
->rcBand
.top
+1,
761 lpBand
->rcBand
.left
+lpBand
->cxHeader
, lpBand
->rcBand
.bottom
-1);
764 /* set initial caption text rectangle */
765 SetRect (&lpBand
->rcCapText
, lpBand
->rcCapImage
.right
, lpBand
->rcBand
.top
+1,
766 lpBand
->rcBand
.left
+lpBand
->cxHeader
, lpBand
->rcBand
.bottom
-1);
769 /* text is visible */
770 if ((lpBand
->fStatus
& HAS_TEXT
) && !(lpBand
->fStyle
& RBBS_HIDETITLE
)) {
771 lpBand
->fDraw
|= DRAW_TEXT
;
772 lpBand
->rcCapText
.right
= max(lpBand
->rcCapText
.left
,
773 lpBand
->rcCapText
.right
-REBAR_POST_TEXT
);
776 /* set initial child window rectangle if there is a child */
777 if (lpBand
->hwndChild
) {
779 lpBand
->rcChild
.left
= lpBand
->rcBand
.left
+ lpBand
->cxHeader
;
780 lpBand
->rcChild
.right
= lpBand
->rcBand
.right
- REBAR_POST_CHILD
;
782 if (lpBand
->cyChild
> 0) {
784 UINT yoff
= (lpBand
->rcBand
.bottom
- lpBand
->rcBand
.top
- lpBand
->cyChild
) / 2;
786 /* center child if height is known */
787 lpBand
->rcChild
.top
= lpBand
->rcBand
.top
+ yoff
;
788 lpBand
->rcChild
.bottom
= lpBand
->rcBand
.top
+ yoff
+ lpBand
->cyChild
;
791 lpBand
->rcChild
.top
= lpBand
->rcBand
.top
;
792 lpBand
->rcChild
.bottom
= lpBand
->rcBand
.bottom
;
795 if ((lpBand
->fStyle
& RBBS_USECHEVRON
) && (lpBand
->rcChild
.right
- lpBand
->rcChild
.left
< lpBand
->cxIdeal
))
797 lpBand
->rcChild
.right
-= CHEVRON_WIDTH
;
798 SetRect(&lpBand
->rcChevron
, lpBand
->rcChild
.right
,
799 lpBand
->rcChild
.top
, lpBand
->rcChild
.right
+ CHEVRON_WIDTH
,
800 lpBand
->rcChild
.bottom
);
803 SetRectEmpty(&lpBand
->rcChevron
);
806 SetRect (&lpBand
->rcChild
,
807 lpBand
->rcBand
.left
+lpBand
->cxHeader
, lpBand
->rcBand
.top
,
808 lpBand
->rcBand
.right
, lpBand
->rcBand
.bottom
);
811 /* flag if notify required and invalidate rectangle */
812 if (lpBand
->fDraw
& NTF_INVALIDATE
) {
813 lpBand
->fDraw
&= ~NTF_INVALIDATE
;
814 work
= lpBand
->rcBand
;
815 work
.right
+= SEP_WIDTH
;
816 work
.bottom
+= SEP_WIDTH
;
817 TRACE("invalidating %s\n", wine_dbgstr_rect(&work
));
818 InvalidateRect(infoPtr
->hwndSelf
, &work
, TRUE
);
819 if (lpBand
->hwndChild
) InvalidateRect(lpBand
->hwndChild
, NULL
, TRUE
);
828 REBAR_CalcVertBand (const REBAR_INFO
*infoPtr
, UINT rstart
, UINT rend
)
829 /* Function: this routine initializes all the rectangles in */
830 /* each band in a row to fit in the adjusted rcBand rect. */
831 /* *** Supports only Vertical bars. *** */
837 for(i
=rstart
; i
<rend
; i
++){
839 lpBand
= REBAR_GetBand(infoPtr
, i
);
840 if (HIDDENBAND(lpBand
)) continue;
842 translate_rect(infoPtr
, &rcBand
, &lpBand
->rcBand
);
844 /* set initial gripper rectangle */
845 SetRect (&lpBand
->rcGripper
, rcBand
.left
, rcBand
.top
, rcBand
.right
, rcBand
.top
);
847 /* calculate gripper rectangle */
848 if (lpBand
->fStatus
& HAS_GRIPPER
) {
849 lpBand
->fDraw
|= DRAW_GRIPPER
;
851 if (infoPtr
->dwStyle
& RBS_VERTICALGRIPPER
) {
852 /* vertical gripper */
853 lpBand
->rcGripper
.left
+= 3;
854 lpBand
->rcGripper
.right
= lpBand
->rcGripper
.left
+ GRIPPER_WIDTH
;
855 lpBand
->rcGripper
.top
+= REBAR_PRE_GRIPPER
;
856 lpBand
->rcGripper
.bottom
= lpBand
->rcGripper
.top
+ GRIPPER_HEIGHT
;
858 /* initialize Caption image rectangle */
859 SetRect (&lpBand
->rcCapImage
, rcBand
.left
,
860 lpBand
->rcGripper
.bottom
+ REBAR_ALWAYS_SPACE
,
862 lpBand
->rcGripper
.bottom
+ REBAR_ALWAYS_SPACE
);
865 /* horizontal gripper */
866 InflateRect(&lpBand
->rcGripper
, -2, 0);
867 lpBand
->rcGripper
.top
+= REBAR_PRE_GRIPPER
;
868 lpBand
->rcGripper
.bottom
= lpBand
->rcGripper
.top
+ GRIPPER_WIDTH
;
870 /* initialize Caption image rectangle */
871 SetRect (&lpBand
->rcCapImage
, rcBand
.left
,
872 lpBand
->rcGripper
.bottom
+ REBAR_ALWAYS_SPACE
,
874 lpBand
->rcGripper
.bottom
+ REBAR_ALWAYS_SPACE
);
877 else { /* no gripper will be drawn */
879 if (lpBand
->fStatus
& (HAS_IMAGE
| HAS_TEXT
))
880 /* if no gripper but either image or text, then leave space */
881 xoff
= REBAR_ALWAYS_SPACE
;
882 /* initialize Caption image rectangle */
883 SetRect (&lpBand
->rcCapImage
,
884 rcBand
.left
, rcBand
.top
+xoff
,
885 rcBand
.right
, rcBand
.top
+xoff
);
888 /* image is visible */
889 if (lpBand
->fStatus
& HAS_IMAGE
) {
890 lpBand
->fDraw
|= DRAW_IMAGE
;
892 lpBand
->rcCapImage
.right
= lpBand
->rcCapImage
.left
+ infoPtr
->imageSize
.cx
;
893 lpBand
->rcCapImage
.bottom
+= infoPtr
->imageSize
.cy
;
895 /* set initial caption text rectangle */
896 SetRect (&lpBand
->rcCapText
,
897 rcBand
.left
, lpBand
->rcCapImage
.bottom
+REBAR_POST_IMAGE
,
898 rcBand
.right
, rcBand
.top
+lpBand
->cxHeader
);
901 /* set initial caption text rectangle */
902 SetRect (&lpBand
->rcCapText
,
903 rcBand
.left
, lpBand
->rcCapImage
.bottom
,
904 rcBand
.right
, rcBand
.top
+lpBand
->cxHeader
);
907 /* text is visible */
908 if ((lpBand
->fStatus
& HAS_TEXT
) && !(lpBand
->fStyle
& RBBS_HIDETITLE
)) {
909 lpBand
->fDraw
|= DRAW_TEXT
;
910 lpBand
->rcCapText
.bottom
= max(lpBand
->rcCapText
.top
,
911 lpBand
->rcCapText
.bottom
);
914 /* set initial child window rectangle if there is a child */
915 if (lpBand
->hwndChild
) {
916 int cxBand
= rcBand
.right
- rcBand
.left
;
917 xoff
= (cxBand
- lpBand
->cyChild
) / 2;
918 SetRect (&lpBand
->rcChild
,
919 rcBand
.left
+ xoff
, rcBand
.top
+ lpBand
->cxHeader
,
920 rcBand
.left
+ xoff
+ lpBand
->cyChild
, rcBand
.bottom
- REBAR_POST_CHILD
);
923 SetRect (&lpBand
->rcChild
,
924 rcBand
.left
, rcBand
.top
+lpBand
->cxHeader
,
925 rcBand
.right
, rcBand
.bottom
);
928 if (lpBand
->fDraw
& NTF_INVALIDATE
) {
929 lpBand
->fDraw
&= ~NTF_INVALIDATE
;
931 work
.bottom
+= SEP_WIDTH
;
932 work
.right
+= SEP_WIDTH
;
933 TRACE("invalidating %s\n", wine_dbgstr_rect(&work
));
934 InvalidateRect(infoPtr
->hwndSelf
, &work
, TRUE
);
935 if (lpBand
->hwndChild
) InvalidateRect(lpBand
->hwndChild
, NULL
, TRUE
);
943 REBAR_ForceResize (REBAR_INFO
*infoPtr
)
944 /* Function: This changes the size of the REBAR window to that */
945 /* calculated by REBAR_Layout. */
947 INT x
, y
, width
, height
;
948 INT xedge
= 0, yedge
= 0;
951 TRACE("new size [%ld x %ld]\n", infoPtr
->calcSize
.cx
, infoPtr
->calcSize
.cy
);
953 if (infoPtr
->dwStyle
& CCS_NORESIZE
)
956 if (infoPtr
->dwStyle
& WS_BORDER
)
958 xedge
= GetSystemMetrics(SM_CXEDGE
);
959 yedge
= GetSystemMetrics(SM_CYEDGE
);
960 /* swap for CCS_VERT? */
963 /* compute rebar window rect in parent client coordinates */
964 GetWindowRect(infoPtr
->hwndSelf
, &rcSelf
);
965 MapWindowPoints(HWND_DESKTOP
, GetParent(infoPtr
->hwndSelf
), (LPPOINT
)&rcSelf
, 2);
966 translate_rect(infoPtr
, &rcSelf
, &rcSelf
);
968 height
= infoPtr
->calcSize
.cy
+ 2*yedge
;
969 if (!(infoPtr
->dwStyle
& CCS_NOPARENTALIGN
)) {
973 width
= infoPtr
->calcSize
.cx
+ 2*xedge
;
974 y
= 0; /* quiet compiler warning */
975 switch ( infoPtr
->dwStyle
& CCS_LAYOUT_MASK
) {
976 case 0: /* shouldn't happen - see NCCreate */
978 y
= ((infoPtr
->dwStyle
& CCS_NODIVIDER
) ? 0 : REBAR_DIVIDER
) - yedge
;
984 GetClientRect(GetParent(infoPtr
->hwndSelf
), &rcParent
);
985 translate_rect(infoPtr
, &rcParent
, &rcParent
);
986 y
= rcParent
.bottom
- infoPtr
->calcSize
.cy
- yedge
;
992 /* As on Windows if the CCS_NODIVIDER is not present the control will move
993 * 2 pixel down after every layout */
994 y
= rcSelf
.top
+ ((infoPtr
->dwStyle
& CCS_NODIVIDER
) ? 0 : REBAR_DIVIDER
);
995 width
= rcSelf
.right
- rcSelf
.left
;
998 TRACE("hwnd %p, style %#lx, setting at (%d,%d) for (%d,%d)\n", infoPtr
->hwndSelf
, infoPtr
->dwStyle
,
999 x
, y
, width
, height
);
1001 /* Set flag to ignore next WM_SIZE message and resize the window */
1002 infoPtr
->fStatus
|= SELF_RESIZE
;
1003 if ((infoPtr
->dwStyle
& CCS_VERT
) == 0)
1004 SetWindowPos(infoPtr
->hwndSelf
, 0, x
, y
, width
, height
, SWP_NOZORDER
);
1006 SetWindowPos(infoPtr
->hwndSelf
, 0, y
, x
, height
, width
, SWP_NOZORDER
);
1007 infoPtr
->fStatus
&= ~SELF_RESIZE
;
1012 REBAR_MoveChildWindows (const REBAR_INFO
*infoPtr
, UINT start
, UINT endplus
)
1015 WCHAR szClassName
[40];
1017 NMREBARCHILDSIZE rbcz
;
1020 if (!(deferpos
= BeginDeferWindowPos(infoPtr
->uNumBands
)))
1021 ERR("BeginDeferWindowPos returned NULL\n");
1023 for (i
= start
; i
< endplus
; i
++) {
1024 lpBand
= REBAR_GetBand(infoPtr
, i
);
1026 if (HIDDENBAND(lpBand
)) continue;
1027 if (lpBand
->hwndChild
) {
1028 TRACE("hwndChild = %p\n", lpBand
->hwndChild
);
1030 /* Always generate the RBN_CHILDSIZE even if child
1033 rbcz
.wID
= lpBand
->wID
;
1034 rbcz
.rcChild
= lpBand
->rcChild
;
1035 translate_rect(infoPtr
, &rbcz
.rcBand
, &lpBand
->rcBand
);
1036 if (infoPtr
->dwStyle
& CCS_VERT
)
1037 rbcz
.rcBand
.top
+= lpBand
->cxHeader
;
1039 rbcz
.rcBand
.left
+= lpBand
->cxHeader
;
1040 REBAR_Notify ((NMHDR
*)&rbcz
, infoPtr
, RBN_CHILDSIZE
);
1041 if (!EqualRect (&lpBand
->rcChild
, &rbcz
.rcChild
)) {
1042 TRACE("Child rect changed by NOTIFY for band %u\n", i
);
1043 TRACE(" from (%s) to (%s)\n",
1044 wine_dbgstr_rect(&lpBand
->rcChild
),
1045 wine_dbgstr_rect(&rbcz
.rcChild
));
1046 lpBand
->rcChild
= rbcz
.rcChild
; /* *** ??? */
1049 GetClassNameW (lpBand
->hwndChild
, szClassName
, ARRAY_SIZE(szClassName
));
1050 if (!lstrcmpW (szClassName
, WC_COMBOBOXW
) ||
1051 !lstrcmpW (szClassName
, WC_COMBOBOXEXW
)) {
1052 INT nEditHeight
, yPos
;
1055 /* special placement code for combo or comboex box */
1058 /* get size of edit line */
1059 GetWindowRect (lpBand
->hwndChild
, &rc
);
1060 nEditHeight
= rc
.bottom
- rc
.top
;
1061 yPos
= (lpBand
->rcChild
.bottom
+ lpBand
->rcChild
.top
- nEditHeight
)/2;
1063 /* center combo box inside child area */
1064 TRACE("moving child (Combo(Ex)) %p to (%ld,%d) for (%ld,%d)\n",
1066 lpBand
->rcChild
.left
, yPos
,
1067 lpBand
->rcChild
.right
- lpBand
->rcChild
.left
,
1069 deferpos
= DeferWindowPos (deferpos
, lpBand
->hwndChild
, HWND_TOP
,
1070 lpBand
->rcChild
.left
,
1071 /*lpBand->rcChild.top*/ yPos
,
1072 lpBand
->rcChild
.right
- lpBand
->rcChild
.left
,
1076 ERR("DeferWindowPos returned NULL\n");
1079 TRACE("moving child (Other) %p to (%ld,%ld) for (%ld,%ld)\n",
1081 lpBand
->rcChild
.left
, lpBand
->rcChild
.top
,
1082 lpBand
->rcChild
.right
- lpBand
->rcChild
.left
,
1083 lpBand
->rcChild
.bottom
- lpBand
->rcChild
.top
);
1084 deferpos
= DeferWindowPos (deferpos
, lpBand
->hwndChild
, HWND_TOP
,
1085 lpBand
->rcChild
.left
,
1086 lpBand
->rcChild
.top
,
1087 lpBand
->rcChild
.right
- lpBand
->rcChild
.left
,
1088 lpBand
->rcChild
.bottom
- lpBand
->rcChild
.top
,
1091 ERR("DeferWindowPos returned NULL\n");
1095 if (!EndDeferWindowPos(deferpos
))
1096 ERR("EndDeferWindowPos returned NULL\n");
1098 if (infoPtr
->DoRedraw
)
1099 UpdateWindow (infoPtr
->hwndSelf
);
1102 /* Returns the next visible band (the first visible band in [i+1; infoPtr->uNumBands) )
1103 * or infoPtr->uNumBands if none */
1104 static int next_visible(const REBAR_INFO
*infoPtr
, int i
)
1107 for (n
= i
+ 1; n
< infoPtr
->uNumBands
; n
++)
1108 if (!HIDDENBAND(REBAR_GetBand(infoPtr
, n
)))
1113 /* Returns the previous visible band (the last visible band in [0; i) )
1115 static int prev_visible(const REBAR_INFO
*infoPtr
, int i
)
1118 for (n
= i
- 1; n
>= 0; n
--)
1119 if (!HIDDENBAND(REBAR_GetBand(infoPtr
, n
)))
1124 /* Returns the first visible band or infoPtr->uNumBands if none */
1125 static int first_visible(const REBAR_INFO
*infoPtr
)
1127 return next_visible(infoPtr
, -1); /* this works*/
1130 /* Returns the first visible band for the given row (or iBand if none) */
1131 static int get_row_begin_for_band(const REBAR_INFO
*infoPtr
, INT iBand
)
1133 int iLastBand
= iBand
;
1134 int iRow
= REBAR_GetBand(infoPtr
, iBand
)->iRow
;
1135 while ((iBand
= prev_visible(infoPtr
, iBand
)) >= 0) {
1136 if (REBAR_GetBand(infoPtr
, iBand
)->iRow
!= iRow
)
1144 /* Returns the first visible band for the next row (or infoPtr->uNumBands if none) */
1145 static int get_row_end_for_band(const REBAR_INFO
*infoPtr
, INT iBand
)
1147 int iRow
= REBAR_GetBand(infoPtr
, iBand
)->iRow
;
1148 while ((iBand
= next_visible(infoPtr
, iBand
)) < infoPtr
->uNumBands
)
1149 if (REBAR_GetBand(infoPtr
, iBand
)->iRow
!= iRow
)
1154 /* Compute the rcBand.{left,right} from the cxEffective bands widths computed earlier.
1155 * iBeginBand must be visible */
1156 static void REBAR_SetRowRectsX(const REBAR_INFO
*infoPtr
, INT iBeginBand
, INT iEndBand
)
1159 for (i
= iBeginBand
; i
< iEndBand
; i
= next_visible(infoPtr
, i
))
1161 REBAR_BAND
*lpBand
= REBAR_GetBand(infoPtr
, i
);
1162 if (lpBand
->rcBand
.left
!= xPos
|| lpBand
->rcBand
.right
!= xPos
+ lpBand
->cxEffective
) {
1163 lpBand
->fDraw
|= NTF_INVALIDATE
;
1164 TRACE("Setting rect %d to %d,%d\n", i
, xPos
, xPos
+ lpBand
->cxEffective
);
1165 lpBand
->rcBand
.left
= xPos
;
1166 lpBand
->rcBand
.right
= xPos
+ lpBand
->cxEffective
;
1168 xPos
+= lpBand
->cxEffective
+ SEP_WIDTH
;
1172 /* The rationale of this function is probably as follows: if we have some space
1173 * to distribute we want to add it to a band on the right. However we don't want
1174 * to unminimize a minimized band so we search for a band that is big enough.
1175 * For some reason "big enough" is defined as bigger than the minimum size of the
1176 * first band in the row
1178 static REBAR_BAND
*REBAR_FindBandToGrow(const REBAR_INFO
*infoPtr
, INT iBeginBand
, INT iEndBand
)
1180 INT cxMinFirstBand
= 0, i
;
1182 cxMinFirstBand
= REBAR_GetBand(infoPtr
, iBeginBand
)->cxMinBand
;
1184 for (i
= prev_visible(infoPtr
, iEndBand
); i
>= iBeginBand
; i
= prev_visible(infoPtr
, i
))
1185 if (REBAR_GetBand(infoPtr
, i
)->cxEffective
> cxMinFirstBand
&&
1186 !(REBAR_GetBand(infoPtr
, i
)->fStyle
& RBBS_FIXEDSIZE
))
1190 for (i
= prev_visible(infoPtr
, iEndBand
); i
>= iBeginBand
; i
= prev_visible(infoPtr
, i
))
1191 if (REBAR_GetBand(infoPtr
, i
)->cxMinBand
== cxMinFirstBand
)
1194 TRACE("Extra space for row [%d..%d) should be added to band %d\n", iBeginBand
, iEndBand
, i
);
1195 return REBAR_GetBand(infoPtr
, i
);
1198 /* Try to shrink the visible bands in [iBeginBand; iEndBand) by cxShrink, starting from the right */
1199 static int REBAR_ShrinkBandsRTL(const REBAR_INFO
*infoPtr
, INT iBeginBand
, INT iEndBand
, INT cxShrink
, BOOL bEnforce
)
1204 TRACE("Shrinking bands [%d..%d) by %d, right-to-left\n", iBeginBand
, iEndBand
, cxShrink
);
1205 for (i
= prev_visible(infoPtr
, iEndBand
); i
>= iBeginBand
; i
= prev_visible(infoPtr
, i
))
1207 lpBand
= REBAR_GetBand(infoPtr
, i
);
1209 width
= max(lpBand
->cxEffective
- cxShrink
, (int)lpBand
->cxMinBand
);
1210 cxShrink
-= lpBand
->cxEffective
- width
;
1211 lpBand
->cxEffective
= width
;
1212 if (bEnforce
&& lpBand
->cx
> lpBand
->cxEffective
)
1213 lpBand
->cx
= lpBand
->cxEffective
;
1221 /* Try to shrink the visible bands in [iBeginBand; iEndBand) by cxShrink, starting from the left.
1222 * iBeginBand must be visible */
1223 static int REBAR_ShrinkBandsLTR(const REBAR_INFO
*infoPtr
, INT iBeginBand
, INT iEndBand
, INT cxShrink
, BOOL bEnforce
)
1228 TRACE("Shrinking bands [%d..%d) by %d, left-to-right\n", iBeginBand
, iEndBand
, cxShrink
);
1229 for (i
= iBeginBand
; i
< iEndBand
; i
= next_visible(infoPtr
, i
))
1231 lpBand
= REBAR_GetBand(infoPtr
, i
);
1233 width
= max(lpBand
->cxEffective
- cxShrink
, (int)lpBand
->cxMinBand
);
1234 cxShrink
-= lpBand
->cxEffective
- width
;
1235 lpBand
->cxEffective
= width
;
1237 lpBand
->cx
= lpBand
->cxEffective
;
1244 /* Tries to move a band to a given offset within a row. */
1245 static int REBAR_MoveBandToRowOffset(REBAR_INFO
*infoPtr
, INT iBand
, INT iFirstBand
,
1246 INT iLastBand
, INT xOff
, BOOL reorder
)
1248 REBAR_BAND
*insertBand
= REBAR_GetBand(infoPtr
, iBand
);
1250 const BOOL setBreak
= REBAR_GetBand(infoPtr
, iFirstBand
)->fStyle
& RBBS_BREAK
;
1252 /* Find the band's new position */
1255 /* Used during an LR band reorder drag */
1256 for (i
= iFirstBand
; i
< iLastBand
; i
= next_visible(infoPtr
, i
))
1260 xPos
+= REBAR_GetBand(infoPtr
, i
)->cxEffective
+ SEP_WIDTH
;
1265 /* Used during a UD band insertion drag */
1266 for (i
= iFirstBand
; i
< iLastBand
; i
= next_visible(infoPtr
, i
))
1268 const REBAR_BAND
*band
= REBAR_GetBand(infoPtr
, i
);
1269 if(xPos
+ band
->cxMinBand
/ 2 > xOff
)
1271 xPos
+= band
->cxEffective
+ SEP_WIDTH
;
1275 /* Move the band to its new position */
1276 DPA_DeletePtr(infoPtr
->bands
, iBand
);
1279 DPA_InsertPtr(infoPtr
->bands
, i
, insertBand
);
1281 /* Ensure only the last band has the RBBS_BREAK flag set */
1282 insertBand
->fStyle
&= ~RBBS_BREAK
;
1284 REBAR_GetBand(infoPtr
, iFirstBand
)->fStyle
|= RBBS_BREAK
;
1286 /* Return the currently grabbed band */
1287 if(infoPtr
->iGrabbedBand
== iBand
)
1289 infoPtr
->iGrabbedBand
= i
;
1295 /* Set the heights of the visible bands in [iBeginBand; iEndBand) to the max height. iBeginBand must be visible */
1296 static int REBAR_SetBandsHeight(const REBAR_INFO
*infoPtr
, INT iBeginBand
, INT iEndBand
, INT yStart
)
1303 for (i
= iBeginBand
; i
< iEndBand
; i
= next_visible(infoPtr
, i
))
1305 lpBand
= REBAR_GetBand(infoPtr
, i
);
1306 lpBand
->cyRowSoFar
= yMaxHeight
;
1307 yMaxHeight
= max(yMaxHeight
, lpBand
->cyMinBand
);
1309 TRACE("Bands [%d; %d) height: %d\n", iBeginBand
, iEndBand
, yMaxHeight
);
1311 row
= iBeginBand
< iEndBand
? REBAR_GetBand(infoPtr
, iBeginBand
)->iRow
: 0;
1313 for (i
= iBeginBand
; i
< iEndBand
; i
= next_visible(infoPtr
, i
))
1315 lpBand
= REBAR_GetBand(infoPtr
, i
);
1316 /* we may be called for multiple rows if RBS_VARHEIGHT not set */
1317 if (lpBand
->iRow
!= row
) {
1318 yPos
+= yMaxHeight
+ SEP_WIDTH
;
1322 if (lpBand
->rcBand
.top
!= yPos
|| lpBand
->rcBand
.bottom
!= yPos
+ yMaxHeight
) {
1323 lpBand
->fDraw
|= NTF_INVALIDATE
;
1324 lpBand
->rcBand
.top
= yPos
;
1325 lpBand
->rcBand
.bottom
= yPos
+ yMaxHeight
;
1326 TRACE("Band %d: %s\n", i
, wine_dbgstr_rect(&lpBand
->rcBand
));
1329 return yPos
+ yMaxHeight
;
1332 /* Layout the row [iBeginBand; iEndBand). iBeginBand must be visible */
1333 static void REBAR_LayoutRow(const REBAR_INFO
*infoPtr
, int iBeginBand
, int iEndBand
, int cx
, int *piRow
, int *pyPos
)
1339 TRACE("Adjusting row [%d;%d). Width: %d\n", iBeginBand
, iEndBand
, cx
);
1340 for (i
= iBeginBand
; i
< iEndBand
; i
++)
1341 REBAR_GetBand(infoPtr
, i
)->iRow
= *piRow
;
1343 /* compute the extra space */
1344 for (i
= iBeginBand
; i
< iEndBand
; i
= next_visible(infoPtr
, i
))
1346 lpBand
= REBAR_GetBand(infoPtr
, i
);
1349 lpBand
->cxEffective
= max(lpBand
->cxMinBand
, lpBand
->cx
);
1350 width
+= lpBand
->cxEffective
;
1354 TRACE("Extra space: %d\n", extra
);
1356 int ret
= REBAR_ShrinkBandsRTL(infoPtr
, iBeginBand
, iEndBand
, -extra
, FALSE
);
1357 if (ret
> 0 && next_visible(infoPtr
, iBeginBand
) != iEndBand
) /* one band may be longer than expected... */
1358 ERR("Error layouting row %d - couldn't shrink for %d pixels (%d total shrink)\n", *piRow
, ret
, -extra
);
1361 lpBand
= REBAR_FindBandToGrow(infoPtr
, iBeginBand
, iEndBand
);
1362 lpBand
->cxEffective
+= extra
;
1365 REBAR_SetRowRectsX(infoPtr
, iBeginBand
, iEndBand
);
1366 if (infoPtr
->dwStyle
& RBS_VARHEIGHT
)
1369 *pyPos
+= SEP_WIDTH
;
1370 *pyPos
= REBAR_SetBandsHeight(infoPtr
, iBeginBand
, iEndBand
, *pyPos
);
1376 REBAR_Layout(REBAR_INFO
*infoPtr
)
1386 if (infoPtr
->dwStyle
& (CCS_NORESIZE
| CCS_NOPARENTALIGN
) || GetParent(infoPtr
->hwndSelf
) == NULL
)
1387 GetClientRect(infoPtr
->hwndSelf
, &rcAdj
);
1389 GetClientRect(GetParent(infoPtr
->hwndSelf
), &rcAdj
);
1390 TRACE("adjustment rect is (%s)\n", wine_dbgstr_rect(&rcAdj
));
1392 adjcx
= get_rect_cx(infoPtr
, &rcAdj
);
1394 if (infoPtr
->uNumBands
== 0) {
1395 TRACE("No bands - setting size to (0,%d), style: %#lx\n", adjcx
, infoPtr
->dwStyle
);
1396 infoPtr
->calcSize
.cx
= adjcx
;
1397 /* the calcSize.cy won't change for a 0 band rebar */
1398 infoPtr
->uNumRows
= 0;
1399 REBAR_ForceResize(infoPtr
);
1405 rowstart
= first_visible(infoPtr
);
1407 for (i
= rowstart
; i
< infoPtr
->uNumBands
; i
= next_visible(infoPtr
, i
))
1409 lpBand
= REBAR_GetBand(infoPtr
, i
);
1411 if (i
> rowstart
&& (lpBand
->fStyle
& RBBS_BREAK
|| xMin
+ lpBand
->cxMinBand
> adjcx
)) {
1412 TRACE("%s break on band %d\n", (lpBand
->fStyle
& RBBS_BREAK
? "Hard" : "Soft"), i
- 1);
1413 REBAR_LayoutRow(infoPtr
, rowstart
, i
, adjcx
, &row
, &yPos
);
1420 xMin
+= lpBand
->cxMinBand
;
1422 if (rowstart
< infoPtr
->uNumBands
)
1423 REBAR_LayoutRow(infoPtr
, rowstart
, infoPtr
->uNumBands
, adjcx
, &row
, &yPos
);
1425 if (!(infoPtr
->dwStyle
& RBS_VARHEIGHT
))
1426 yPos
= REBAR_SetBandsHeight(infoPtr
, first_visible(infoPtr
), infoPtr
->uNumBands
, 0);
1428 infoPtr
->uNumRows
= row
;
1430 if (infoPtr
->dwStyle
& CCS_VERT
)
1431 REBAR_CalcVertBand(infoPtr
, 0, infoPtr
->uNumBands
);
1433 REBAR_CalcHorzBand(infoPtr
, 0, infoPtr
->uNumBands
);
1434 /* now compute size of Rebar itself */
1435 oldSize
= infoPtr
->calcSize
;
1437 infoPtr
->calcSize
.cx
= adjcx
;
1438 infoPtr
->calcSize
.cy
= yPos
;
1439 TRACE("calcsize size=(%ld, %ld), origheight=(%ld,%ld)\n", infoPtr
->calcSize
.cx
, infoPtr
->calcSize
.cy
,
1440 oldSize
.cx
, oldSize
.cy
);
1442 REBAR_DumpBand (infoPtr
);
1443 REBAR_MoveChildWindows (infoPtr
, 0, infoPtr
->uNumBands
);
1444 REBAR_ForceResize (infoPtr
);
1446 /* note: after a RBN_HEIGHTCHANGE native sends once again all the RBN_CHILDSIZE
1447 * and does another ForceResize */
1448 if (oldSize
.cy
!= infoPtr
->calcSize
.cy
)
1451 REBAR_Notify(&heightchange
, infoPtr
, RBN_HEIGHTCHANGE
);
1452 REBAR_AutoSize(infoPtr
, FALSE
);
1456 /* iBeginBand must be visible */
1458 REBAR_SizeChildrenToHeight(const REBAR_INFO
*infoPtr
, int iBeginBand
, int iEndBand
, int extra
, BOOL
*fChanged
)
1464 TRACE("[%d;%d) by %d\n", iBeginBand
, iEndBand
, extra
);
1466 cyBandsOld
= REBAR_GetBand(infoPtr
, iBeginBand
)->rcBand
.bottom
-
1467 REBAR_GetBand(infoPtr
, iBeginBand
)->rcBand
.top
;
1468 for (i
= iBeginBand
; i
< iEndBand
; i
= next_visible(infoPtr
, i
))
1470 REBAR_BAND
*lpBand
= REBAR_GetBand(infoPtr
, i
);
1471 int cyMaxChild
= cyBandsOld
- REBARSPACE(lpBand
) + extra
;
1472 int cyChild
= round_child_height(lpBand
, cyMaxChild
);
1474 if (lpBand
->hwndChild
&& cyChild
!= lpBand
->cyChild
&& (lpBand
->fStyle
& RBBS_VARIABLEHEIGHT
))
1476 TRACE("Resizing %d: %d -> %d [%d]\n", i
, lpBand
->cyChild
, cyChild
, lpBand
->cyMaxChild
);
1478 lpBand
->cyChild
= cyChild
;
1479 lpBand
->fDraw
|= NTF_INVALIDATE
;
1480 update_min_band_height(infoPtr
, lpBand
);
1482 cyBandsNew
= max(cyBandsNew
, lpBand
->cyMinBand
);
1484 return cyBandsNew
- cyBandsOld
;
1487 /* worker function for RB_SIZETORECT and RBS_AUTOSIZE */
1489 REBAR_SizeToHeight(REBAR_INFO
*infoPtr
, int height
)
1491 int extra
= height
- infoPtr
->calcSize
.cy
; /* may be negative */
1492 BOOL fChanged
= FALSE
;
1493 UINT uNumRows
= infoPtr
->uNumRows
;
1496 if (uNumRows
== 0) /* avoid division by 0 */
1499 /* That's not exactly what Windows does but should be similar */
1501 /* Pass one: break-up/glue rows */
1504 for (i
= prev_visible(infoPtr
, infoPtr
->uNumBands
); i
> 0; i
= prev_visible(infoPtr
, i
))
1506 REBAR_BAND
*lpBand
= REBAR_GetBand(infoPtr
, i
);
1507 int cyBreakExtra
; /* additional cy for the rebar after a RBBS_BREAK on this band */
1509 height
= lpBand
->rcBand
.bottom
- lpBand
->rcBand
.top
;
1511 if (infoPtr
->dwStyle
& RBS_VARHEIGHT
)
1512 cyBreakExtra
= lpBand
->cyRowSoFar
; /* 'height' => 'lpBand->cyRowSoFar' + 'height'*/
1514 cyBreakExtra
= height
; /* 'height' => 'height' + 'height'*/
1515 cyBreakExtra
+= SEP_WIDTH
;
1517 if (extra
<= cyBreakExtra
/ 2)
1520 if (!(lpBand
->fStyle
& RBBS_BREAK
))
1522 TRACE("Adding break on band %d - extra %d -> %d\n", i
, extra
, extra
- cyBreakExtra
);
1523 lpBand
->fStyle
|= RBBS_BREAK
;
1524 lpBand
->fDraw
|= NTF_INVALIDATE
;
1526 extra
-= cyBreakExtra
;
1528 /* temporary change for _SizeControlsToHeight. The true values will be computed in _Layout */
1529 if (infoPtr
->dwStyle
& RBS_VARHEIGHT
)
1530 lpBand
->rcBand
.bottom
= lpBand
->rcBand
.top
+ lpBand
->cyMinBand
;
1534 /* TODO: else if (extra < 0) { try to remove some RBBS_BREAKs } */
1536 /* Pass two: increase/decrease control height */
1537 if (infoPtr
->dwStyle
& RBS_VARHEIGHT
)
1539 int i
= first_visible(infoPtr
);
1541 while (i
< infoPtr
->uNumBands
)
1543 REBAR_BAND
*lpBand
= REBAR_GetBand(infoPtr
, i
);
1544 int extraForRow
= extra
/ (int)(uNumRows
- iRow
);
1547 /* we can't use get_row_end_for_band as we might have added RBBS_BREAK in the first phase */
1548 for (rowEnd
= next_visible(infoPtr
, i
); rowEnd
< infoPtr
->uNumBands
; rowEnd
= next_visible(infoPtr
, rowEnd
))
1549 if (REBAR_GetBand(infoPtr
, rowEnd
)->iRow
!= lpBand
->iRow
||
1550 REBAR_GetBand(infoPtr
, rowEnd
)->fStyle
& RBBS_BREAK
)
1553 extra
-= REBAR_SizeChildrenToHeight(infoPtr
, i
, rowEnd
, extraForRow
, &fChanged
);
1554 TRACE("extra = %d\n", extra
);
1560 REBAR_SizeChildrenToHeight(infoPtr
, first_visible(infoPtr
), infoPtr
->uNumBands
, extra
/ infoPtr
->uNumRows
, &fChanged
);
1563 REBAR_Layout(infoPtr
);
1567 REBAR_AutoSize(REBAR_INFO
*infoPtr
, BOOL needsLayout
)
1570 NMRBAUTOSIZE autosize
;
1573 REBAR_Layout(infoPtr
);
1574 GetClientRect(infoPtr
->hwndSelf
, &rc
);
1575 REBAR_SizeToHeight(infoPtr
, get_rect_cy(infoPtr
, &rc
));
1576 GetClientRect(infoPtr
->hwndSelf
, &rcNew
);
1578 GetClientRect(infoPtr
->hwndSelf
, &autosize
.rcTarget
);
1579 autosize
.fChanged
= EqualRect(&rc
, &rcNew
);
1580 autosize
.rcTarget
= rc
;
1581 autosize
.rcActual
= rcNew
;
1582 REBAR_Notify((NMHDR
*)&autosize
, infoPtr
, RBN_AUTOSIZE
);
1586 REBAR_ValidateBand (const REBAR_INFO
*infoPtr
, REBAR_BAND
*lpBand
)
1587 /* Function: This routine evaluates the band specs supplied */
1588 /* by the user and updates the following 5 fields in */
1589 /* the internal band structure: cxHeader, cyHeader, cxMinBand, cyMinBand, fStatus */
1592 UINT textheight
=0, imageheight
= 0;
1596 lpBand
->fStatus
= 0;
1597 lpBand
->cxMinBand
= 0;
1598 lpBand
->cyMinBand
= 0;
1600 /* Data coming in from users into the cx... and cy... fields */
1601 /* may be bad, just garbage, because the user never clears */
1602 /* the fields. RB_{SET|INSERT}BAND{A|W} just passes the data */
1603 /* along if the fields exist in the input area. Here we must */
1604 /* determine if the data is valid. I have no idea how MS does */
1605 /* the validation, but it does because the RB_GETBANDINFO */
1606 /* returns a 0 when I know the sample program passed in an */
1607 /* address. Here I will use the algorithm that if the value */
1608 /* is greater than 65535 then it is bad and replace it with */
1609 /* a zero. Feel free to improve the algorithm. - GA 12/2000 */
1610 if (lpBand
->cxMinChild
> 65535) lpBand
->cxMinChild
= 0;
1611 if (lpBand
->cyMinChild
> 65535) lpBand
->cyMinChild
= 0;
1612 if (lpBand
->cx
> 65535) lpBand
->cx
= 0;
1613 if (lpBand
->cyChild
> 65535) lpBand
->cyChild
= 0;
1614 if (lpBand
->cyIntegral
> 65535) lpBand
->cyIntegral
= 0;
1615 if (lpBand
->cxIdeal
> 65535) lpBand
->cxIdeal
= 0;
1616 if (lpBand
->cxHeader
> 65535) lpBand
->cxHeader
= 0;
1618 /* TODO : we could try return to the caller if a value changed so that */
1619 /* a REBAR_Layout is needed. Till now the caller should call it */
1620 /* it always (we should also check what native does) */
1622 /* Header is where the image, text and gripper exist */
1623 /* in the band and precede the child window. */
1625 /* count number of non-FIXEDSIZE and non-Hidden bands */
1627 for (i
=0; i
<infoPtr
->uNumBands
; i
++){
1628 tBand
= REBAR_GetBand(infoPtr
, i
);
1629 if (!HIDDENBAND(tBand
) && !(tBand
->fStyle
& RBBS_FIXEDSIZE
))
1633 /* calculate gripper rectangle */
1634 if ( (!(lpBand
->fStyle
& RBBS_NOGRIPPER
)) &&
1635 ( (lpBand
->fStyle
& RBBS_GRIPPERALWAYS
) ||
1636 ( !(lpBand
->fStyle
& RBBS_FIXEDSIZE
) && (nonfixed
> 1)))
1638 lpBand
->fStatus
|= HAS_GRIPPER
;
1639 if (infoPtr
->dwStyle
& CCS_VERT
)
1640 if (infoPtr
->dwStyle
& RBS_VERTICALGRIPPER
)
1641 header
+= (GRIPPER_HEIGHT
+ REBAR_PRE_GRIPPER
);
1643 header
+= (GRIPPER_WIDTH
+ REBAR_PRE_GRIPPER
);
1645 header
+= (REBAR_PRE_GRIPPER
+ GRIPPER_WIDTH
);
1646 /* Always have 4 pixels before anything else */
1647 header
+= REBAR_ALWAYS_SPACE
;
1650 /* image is visible */
1651 if (lpBand
->iImage
!= -1 && (infoPtr
->himl
)) {
1652 lpBand
->fStatus
|= HAS_IMAGE
;
1653 if (infoPtr
->dwStyle
& CCS_VERT
) {
1654 header
+= (infoPtr
->imageSize
.cy
+ REBAR_POST_IMAGE
);
1655 imageheight
= infoPtr
->imageSize
.cx
+ 4;
1658 header
+= (infoPtr
->imageSize
.cx
+ REBAR_POST_IMAGE
);
1659 imageheight
= infoPtr
->imageSize
.cy
+ 4;
1663 /* text is visible */
1664 if ((lpBand
->fMask
& RBBIM_TEXT
) && (lpBand
->lpText
) &&
1665 !(lpBand
->fStyle
& RBBS_HIDETITLE
)) {
1666 HDC hdc
= GetDC (0);
1667 HFONT hOldFont
= SelectObject (hdc
, infoPtr
->hFont
);
1670 lpBand
->fStatus
|= HAS_TEXT
;
1671 GetTextExtentPoint32W (hdc
, lpBand
->lpText
,
1672 lstrlenW (lpBand
->lpText
), &size
);
1673 header
+= ((infoPtr
->dwStyle
& CCS_VERT
) ? (size
.cy
+ REBAR_POST_TEXT
) : (size
.cx
+ REBAR_POST_TEXT
));
1674 textheight
= (infoPtr
->dwStyle
& CCS_VERT
) ? 0 : size
.cy
;
1676 SelectObject (hdc
, hOldFont
);
1680 /* if no gripper but either image or text, then leave space */
1681 if ((lpBand
->fStatus
& (HAS_IMAGE
| HAS_TEXT
)) &&
1682 !(lpBand
->fStatus
& HAS_GRIPPER
)) {
1683 header
+= REBAR_ALWAYS_SPACE
;
1686 /* check if user overrode the header value */
1687 if (!(lpBand
->fStyle
& RBBS_UNDOC_FIXEDHEADER
))
1688 lpBand
->cxHeader
= header
;
1689 lpBand
->cyHeader
= max(textheight
, imageheight
);
1691 /* Now compute minimum size of child window */
1692 update_min_band_height(infoPtr
, lpBand
); /* update lpBand->cyMinBand from cyHeader and cyChild*/
1694 lpBand
->cxMinBand
= lpBand
->cxMinChild
+ lpBand
->cxHeader
+ REBAR_POST_CHILD
;
1695 if (lpBand
->fStyle
& RBBS_USECHEVRON
&& lpBand
->cxMinChild
< lpBand
->cxIdeal
)
1696 lpBand
->cxMinBand
+= CHEVRON_WIDTH
;
1700 REBAR_CommonSetupBand(HWND hwnd
, const REBARBANDINFOW
*lprbbi
, REBAR_BAND
*lpBand
)
1701 /* Function: This routine copies the supplied values from */
1702 /* user input (lprbbi) to the internal band structure. */
1703 /* It returns the mask of what changed. */
1705 UINT uChanged
= 0x0;
1707 lpBand
->fMask
|= lprbbi
->fMask
;
1709 if( (lprbbi
->fMask
& RBBIM_STYLE
) &&
1710 (lpBand
->fStyle
!= lprbbi
->fStyle
) )
1712 lpBand
->fStyle
= lprbbi
->fStyle
;
1713 uChanged
|= RBBIM_STYLE
;
1716 if( (lprbbi
->fMask
& RBBIM_COLORS
) &&
1717 ( ( lpBand
->clrFore
!= lprbbi
->clrFore
) ||
1718 ( lpBand
->clrBack
!= lprbbi
->clrBack
) ) )
1720 lpBand
->clrFore
= lprbbi
->clrFore
;
1721 lpBand
->clrBack
= lprbbi
->clrBack
;
1722 uChanged
|= RBBIM_COLORS
;
1725 if( (lprbbi
->fMask
& RBBIM_IMAGE
) &&
1726 ( lpBand
->iImage
!= lprbbi
->iImage
) )
1728 lpBand
->iImage
= lprbbi
->iImage
;
1729 uChanged
|= RBBIM_IMAGE
;
1732 if( (lprbbi
->fMask
& RBBIM_CHILD
) &&
1733 (lprbbi
->hwndChild
!= lpBand
->hwndChild
) )
1735 if (lprbbi
->hwndChild
) {
1736 lpBand
->hwndChild
= lprbbi
->hwndChild
;
1737 lpBand
->hwndPrevParent
=
1738 SetParent (lpBand
->hwndChild
, hwnd
);
1739 /* below in trace from WinRAR */
1740 ShowWindow(lpBand
->hwndChild
, SW_SHOWNOACTIVATE
| SW_SHOWNORMAL
);
1741 /* above in trace from WinRAR */
1744 TRACE("child: %p prev parent: %p\n",
1745 lpBand
->hwndChild
, lpBand
->hwndPrevParent
);
1746 lpBand
->hwndChild
= 0;
1747 lpBand
->hwndPrevParent
= 0;
1749 uChanged
|= RBBIM_CHILD
;
1752 if( (lprbbi
->fMask
& RBBIM_CHILDSIZE
) &&
1753 ( (lpBand
->cxMinChild
!= lprbbi
->cxMinChild
) ||
1754 (lpBand
->cyMinChild
!= lprbbi
->cyMinChild
) ||
1755 ( (lprbbi
->cbSize
>= REBARBANDINFOA_V6_SIZE
&& (lpBand
->fStyle
& RBBS_VARIABLEHEIGHT
)) &&
1756 ( (lpBand
->cyChild
!= lprbbi
->cyChild
) ||
1757 (lpBand
->cyMaxChild
!= lprbbi
->cyMaxChild
) ||
1758 (lpBand
->cyIntegral
!= lprbbi
->cyIntegral
) ) ) ||
1759 ( (lprbbi
->cbSize
< REBARBANDINFOA_V6_SIZE
) &&
1760 ( (lpBand
->cyChild
||
1761 lpBand
->cyMaxChild
||
1762 lpBand
->cyIntegral
) ) ) ) )
1764 lpBand
->cxMinChild
= lprbbi
->cxMinChild
;
1765 lpBand
->cyMinChild
= lprbbi
->cyMinChild
;
1766 /* These fields where added in WIN32_IE == 0x400 and are set only for RBBS_VARIABLEHEIGHT bands */
1767 if (lprbbi
->cbSize
>= REBARBANDINFOA_V6_SIZE
&& (lpBand
->fStyle
& RBBS_VARIABLEHEIGHT
)) {
1768 lpBand
->cyMaxChild
= lprbbi
->cyMaxChild
;
1769 lpBand
->cyIntegral
= lprbbi
->cyIntegral
;
1771 lpBand
->cyChild
= round_child_height(lpBand
, lprbbi
->cyChild
); /* make (cyChild - cyMinChild) a multiple of cyIntergral */
1774 lpBand
->cyChild
= lpBand
->cyMinChild
;
1775 lpBand
->cyMaxChild
= 0x7fffffff;
1776 lpBand
->cyIntegral
= 0;
1778 uChanged
|= RBBIM_CHILDSIZE
;
1781 if( (lprbbi
->fMask
& RBBIM_SIZE
) &&
1782 (lpBand
->cx
!= lprbbi
->cx
) )
1784 lpBand
->cx
= lprbbi
->cx
;
1785 uChanged
|= RBBIM_SIZE
;
1788 if( (lprbbi
->fMask
& RBBIM_BACKGROUND
) &&
1789 ( lpBand
->hbmBack
!= lprbbi
->hbmBack
) )
1791 lpBand
->hbmBack
= lprbbi
->hbmBack
;
1792 uChanged
|= RBBIM_BACKGROUND
;
1795 if( (lprbbi
->fMask
& RBBIM_ID
) &&
1796 (lpBand
->wID
!= lprbbi
->wID
) )
1798 lpBand
->wID
= lprbbi
->wID
;
1799 uChanged
|= RBBIM_ID
;
1802 /* check for additional data */
1803 if (lprbbi
->cbSize
>= REBARBANDINFOA_V6_SIZE
) {
1804 if( (lprbbi
->fMask
& RBBIM_IDEALSIZE
) &&
1805 ( lpBand
->cxIdeal
!= lprbbi
->cxIdeal
) )
1807 lpBand
->cxIdeal
= lprbbi
->cxIdeal
;
1808 uChanged
|= RBBIM_IDEALSIZE
;
1811 if( (lprbbi
->fMask
& RBBIM_LPARAM
) &&
1812 (lpBand
->lParam
!= lprbbi
->lParam
) )
1814 lpBand
->lParam
= lprbbi
->lParam
;
1815 uChanged
|= RBBIM_LPARAM
;
1818 if( (lprbbi
->fMask
& RBBIM_HEADERSIZE
) &&
1819 (lpBand
->cxHeader
!= lprbbi
->cxHeader
) )
1821 lpBand
->cxHeader
= lprbbi
->cxHeader
;
1822 lpBand
->fStyle
|= RBBS_UNDOC_FIXEDHEADER
;
1823 uChanged
|= RBBIM_HEADERSIZE
;
1830 static LRESULT
REBAR_EraseBkGnd (const REBAR_INFO
*infoPtr
, HDC hdc
)
1831 /* Function: This erases the background rectangle by drawing */
1832 /* each band with its background color (or the default) and */
1833 /* draws each bands right separator if necessary. The row */
1834 /* separators are drawn on the first band of the next row. */
1840 COLORREF old
= CLR_NONE
, new;
1841 HTHEME theme
= GetWindowTheme (infoPtr
->hwndSelf
);
1843 GetClientRect (infoPtr
->hwndSelf
, &cr
);
1846 for(i
=0; i
<infoPtr
->uNumBands
; i
++) {
1848 lpBand
= REBAR_GetBand(infoPtr
, i
);
1849 if (HIDDENBAND(lpBand
)) continue;
1850 translate_rect(infoPtr
, &rcBand
, &lpBand
->rcBand
);
1852 /* draw band separator between rows */
1853 if (lpBand
->iRow
!= oldrow
) {
1854 oldrow
= lpBand
->iRow
;
1855 if (infoPtr
->dwStyle
& RBS_BANDBORDERS
) {
1858 if (infoPtr
->dwStyle
& CCS_VERT
) {
1859 rcRowSep
.right
+= SEP_WIDTH_SIZE
;
1860 rcRowSep
.bottom
= infoPtr
->calcSize
.cx
;
1862 DrawThemeEdge (theme
, hdc
, RP_BAND
, 0, &rcRowSep
, EDGE_ETCHED
, BF_RIGHT
, NULL
);
1864 DrawEdge (hdc
, &rcRowSep
, EDGE_ETCHED
, BF_RIGHT
);
1867 rcRowSep
.bottom
+= SEP_WIDTH_SIZE
;
1868 rcRowSep
.right
= infoPtr
->calcSize
.cx
;
1870 DrawThemeEdge (theme
, hdc
, RP_BAND
, 0, &rcRowSep
, EDGE_ETCHED
, BF_BOTTOM
, NULL
);
1872 DrawEdge (hdc
, &rcRowSep
, EDGE_ETCHED
, BF_BOTTOM
);
1874 TRACE ("drawing band separator bottom (%s)\n",
1875 wine_dbgstr_rect(&rcRowSep
));
1879 /* draw band separator between bands in a row */
1880 if (infoPtr
->dwStyle
& RBS_BANDBORDERS
&& lpBand
->rcBand
.left
> 0) {
1883 if (infoPtr
->dwStyle
& CCS_VERT
) {
1884 rcSep
.bottom
= rcSep
.top
;
1885 rcSep
.top
-= SEP_WIDTH_SIZE
;
1887 DrawThemeEdge (theme
, hdc
, RP_BAND
, 0, &rcSep
, EDGE_ETCHED
, BF_BOTTOM
, NULL
);
1889 DrawEdge (hdc
, &rcSep
, EDGE_ETCHED
, BF_BOTTOM
);
1892 rcSep
.right
= rcSep
.left
;
1893 rcSep
.left
-= SEP_WIDTH_SIZE
;
1895 DrawThemeEdge (theme
, hdc
, RP_BAND
, 0, &rcSep
, EDGE_ETCHED
, BF_RIGHT
, NULL
);
1897 DrawEdge (hdc
, &rcSep
, EDGE_ETCHED
, BF_RIGHT
);
1899 TRACE("drawing band separator right (%s)\n",
1900 wine_dbgstr_rect(&rcSep
));
1903 /* draw the actual background */
1904 if (lpBand
->clrBack
!= CLR_NONE
) {
1905 new = (lpBand
->clrBack
== CLR_DEFAULT
) ? infoPtr
->clrBtnFace
:
1908 /* testing only - make background green to see it */
1913 /* In the absence of documentation for Rebar vs. CLR_NONE,
1914 * we will use the default BtnFace color. Note documentation
1915 * exists for Listview and Imagelist.
1917 new = infoPtr
->clrBtnFace
;
1919 /* testing only - make background green to see it */
1926 /* When themed, the background color is ignored (but not a
1927 * background bitmap */
1928 DrawThemeBackground (theme
, hdc
, 0, 0, &cr
, &rcBand
);
1932 old
= SetBkColor (hdc
, new);
1933 TRACE("%s background color %#lx, band %s\n",
1934 (lpBand
->clrBack
== CLR_NONE
) ? "none" :
1935 ((lpBand
->clrBack
== CLR_DEFAULT
) ? "dft" : ""),
1936 GetBkColor(hdc
), wine_dbgstr_rect(&rcBand
));
1937 ExtTextOutW (hdc
, 0, 0, ETO_OPAQUE
, &rcBand
, NULL
, 0, 0);
1938 if (lpBand
->clrBack
!= CLR_NONE
)
1939 SetBkColor (hdc
, old
);
1946 REBAR_InternalHitTest (const REBAR_INFO
*infoPtr
, const POINT
*lpPt
, UINT
*pFlags
, INT
*pBand
)
1952 GetClientRect (infoPtr
->hwndSelf
, &rect
);
1954 *pFlags
= RBHT_NOWHERE
;
1955 if (PtInRect (&rect
, *lpPt
))
1957 if (infoPtr
->uNumBands
== 0) {
1958 *pFlags
= RBHT_NOWHERE
;
1965 /* somewhere inside */
1966 for (iCount
= 0; iCount
< infoPtr
->uNumBands
; iCount
++) {
1968 lpBand
= REBAR_GetBand(infoPtr
, iCount
);
1969 translate_rect(infoPtr
, &rcBand
, &lpBand
->rcBand
);
1970 if (HIDDENBAND(lpBand
)) continue;
1971 if (PtInRect (&rcBand
, *lpPt
)) {
1974 if (PtInRect (&lpBand
->rcGripper
, *lpPt
)) {
1975 *pFlags
= RBHT_GRABBER
;
1976 TRACE("ON GRABBER %d\n", iCount
);
1979 else if (PtInRect (&lpBand
->rcCapImage
, *lpPt
)) {
1980 *pFlags
= RBHT_CAPTION
;
1981 TRACE("ON CAPTION %d\n", iCount
);
1984 else if (PtInRect (&lpBand
->rcCapText
, *lpPt
)) {
1985 *pFlags
= RBHT_CAPTION
;
1986 TRACE("ON CAPTION %d\n", iCount
);
1989 else if (PtInRect (&lpBand
->rcChild
, *lpPt
)) {
1990 *pFlags
= RBHT_CLIENT
;
1991 TRACE("ON CLIENT %d\n", iCount
);
1994 else if (PtInRect (&lpBand
->rcChevron
, *lpPt
)) {
1995 *pFlags
= RBHT_CHEVRON
;
1996 TRACE("ON CHEVRON %d\n", iCount
);
2000 *pFlags
= RBHT_NOWHERE
;
2001 TRACE("NOWHERE %d\n", iCount
);
2007 *pFlags
= RBHT_NOWHERE
;
2016 *pFlags
= RBHT_NOWHERE
;
2025 REBAR_HandleLRDrag (REBAR_INFO
*infoPtr
, const POINT
*ptsmove
)
2026 /* Function: This will implement the functionality of a */
2027 /* Gripper drag within a row. It will not implement "out- */
2028 /* of-row" drags. (They are detected and handled in */
2029 /* REBAR_MouseMove.) */
2031 REBAR_BAND
*hitBand
;
2032 INT iHitBand
, iRowBegin
, iRowEnd
;
2033 INT movement
, xBand
, cxLeft
= 0;
2034 BOOL shrunkBands
= FALSE
;
2036 iHitBand
= infoPtr
->iGrabbedBand
;
2037 iRowBegin
= get_row_begin_for_band(infoPtr
, iHitBand
);
2038 iRowEnd
= get_row_end_for_band(infoPtr
, iHitBand
);
2039 hitBand
= REBAR_GetBand(infoPtr
, iHitBand
);
2041 xBand
= hitBand
->rcBand
.left
;
2042 movement
= (infoPtr
->dwStyle
&CCS_VERT
? ptsmove
->y
: ptsmove
->x
)
2043 - (xBand
+ REBAR_PRE_GRIPPER
- infoPtr
->ihitoffset
);
2045 /* Dragging the first band in a row cannot cause shrinking */
2046 if(iHitBand
!= iRowBegin
)
2049 cxLeft
= REBAR_ShrinkBandsRTL(infoPtr
, iRowBegin
, iHitBand
, -movement
, TRUE
);
2051 if(cxLeft
< -movement
)
2053 hitBand
->cxEffective
+= -movement
- cxLeft
;
2054 hitBand
->cx
= hitBand
->cxEffective
;
2058 } else if (movement
> 0) {
2061 if (prev_visible(infoPtr
, iHitBand
) >= 0)
2062 cxLeft
= REBAR_ShrinkBandsLTR(infoPtr
, iHitBand
, iRowEnd
, movement
, TRUE
);
2064 if(cxLeft
< movement
)
2066 REBAR_BAND
*lpPrev
= REBAR_GetBand(infoPtr
, prev_visible(infoPtr
, iHitBand
));
2067 lpPrev
->cxEffective
+= movement
- cxLeft
;
2068 lpPrev
->cx
= hitBand
->cxEffective
;
2077 /* It was not possible to move the band by shrinking bands.
2078 * Try relocating the band instead. */
2079 REBAR_MoveBandToRowOffset(infoPtr
, iHitBand
, iRowBegin
,
2080 iRowEnd
, xBand
+ movement
, TRUE
);
2083 REBAR_SetRowRectsX(infoPtr
, iRowBegin
, iRowEnd
);
2084 if (infoPtr
->dwStyle
& CCS_VERT
)
2085 REBAR_CalcVertBand(infoPtr
, 0, infoPtr
->uNumBands
);
2087 REBAR_CalcHorzBand(infoPtr
, 0, infoPtr
->uNumBands
);
2088 REBAR_MoveChildWindows(infoPtr
, iRowBegin
, iRowEnd
);
2092 REBAR_HandleUDDrag (REBAR_INFO
*infoPtr
, const POINT
*ptsmove
)
2094 INT yOff
= (infoPtr
->dwStyle
& CCS_VERT
) ? ptsmove
->x
: ptsmove
->y
;
2095 INT iHitBand
, iRowBegin
, iNextRowBegin
;
2096 REBAR_BAND
*hitBand
, *rowBeginBand
;
2098 if(infoPtr
->uNumBands
<= 0)
2099 ERR("There are no bands in this rebar\n");
2101 /* Up/down dragging can only occur when there is more than one
2102 * band in the rebar */
2103 if(infoPtr
->uNumBands
<= 1)
2106 iHitBand
= infoPtr
->iGrabbedBand
;
2107 hitBand
= REBAR_GetBand(infoPtr
, iHitBand
);
2109 /* If we're taking a band that has the RBBS_BREAK style set, this
2110 * style needs to be reapplied to the band that is going to become
2111 * the new start of the row. */
2112 if((hitBand
->fStyle
& RBBS_BREAK
) &&
2113 (iHitBand
< infoPtr
->uNumBands
- 1))
2114 REBAR_GetBand(infoPtr
, iHitBand
+ 1)->fStyle
|= RBBS_BREAK
;
2118 /* Place the band above the current top row */
2119 if(iHitBand
==0 && (infoPtr
->uNumBands
==1 || REBAR_GetBand(infoPtr
, 1)->fStyle
&RBBS_BREAK
))
2121 DPA_DeletePtr(infoPtr
->bands
, iHitBand
);
2122 hitBand
->fStyle
&= ~RBBS_BREAK
;
2123 REBAR_GetBand(infoPtr
, 0)->fStyle
|= RBBS_BREAK
;
2124 infoPtr
->iGrabbedBand
= DPA_InsertPtr(
2125 infoPtr
->bands
, 0, hitBand
);
2127 else if(yOff
> REBAR_GetBand(infoPtr
, infoPtr
->uNumBands
- 1)->rcBand
.bottom
)
2129 /* Place the band below the current bottom row */
2130 if(iHitBand
== infoPtr
->uNumBands
-1 && hitBand
->fStyle
&RBBS_BREAK
)
2132 DPA_DeletePtr(infoPtr
->bands
, iHitBand
);
2133 hitBand
->fStyle
|= RBBS_BREAK
;
2134 infoPtr
->iGrabbedBand
= DPA_InsertPtr(
2135 infoPtr
->bands
, infoPtr
->uNumBands
- 1, hitBand
);
2139 /* Place the band in the preexisting row the mouse is hovering over */
2140 iRowBegin
= first_visible(infoPtr
);
2141 while(iRowBegin
< infoPtr
->uNumBands
)
2143 iNextRowBegin
= get_row_end_for_band(infoPtr
, iRowBegin
);
2144 rowBeginBand
= REBAR_GetBand(infoPtr
, iRowBegin
);
2145 if(rowBeginBand
->rcBand
.bottom
> yOff
)
2147 REBAR_MoveBandToRowOffset(
2148 infoPtr
, iHitBand
, iRowBegin
, iNextRowBegin
,
2149 ((infoPtr
->dwStyle
& CCS_VERT
) ? ptsmove
->y
: ptsmove
->x
)
2150 - REBAR_PRE_GRIPPER
- infoPtr
->ihitoffset
, FALSE
);
2154 iRowBegin
= iNextRowBegin
;
2158 REBAR_Layout(infoPtr
);
2162 /* << REBAR_BeginDrag >> */
2166 REBAR_DeleteBand (REBAR_INFO
*infoPtr
, WPARAM wParam
)
2168 UINT uBand
= (UINT
)wParam
;
2171 if (uBand
>= infoPtr
->uNumBands
)
2174 TRACE("deleting band %u!\n", uBand
);
2175 lpBand
= REBAR_GetBand(infoPtr
, uBand
);
2176 REBAR_Notify_NMREBAR (infoPtr
, uBand
, RBN_DELETINGBAND
);
2177 /* TODO: a return of 1 should probably cancel the deletion */
2179 if (lpBand
->hwndChild
)
2180 ShowWindow(lpBand
->hwndChild
, SW_HIDE
);
2181 Free(lpBand
->lpText
);
2184 infoPtr
->uNumBands
--;
2185 DPA_DeletePtr(infoPtr
->bands
, uBand
);
2187 REBAR_Notify_NMREBAR (infoPtr
, -1, RBN_DELETEDBAND
);
2189 /* if only 1 band left the re-validate to possible eliminate gripper */
2190 if (infoPtr
->uNumBands
== 1)
2191 REBAR_ValidateBand (infoPtr
, REBAR_GetBand(infoPtr
, 0));
2193 REBAR_Layout(infoPtr
);
2199 /* << REBAR_DragMove >> */
2200 /* << REBAR_EndDrag >> */
2204 REBAR_GetBandBorders (const REBAR_INFO
*infoPtr
, UINT uBand
, RECT
*lpRect
)
2210 if (uBand
>= infoPtr
->uNumBands
)
2213 lpBand
= REBAR_GetBand(infoPtr
, uBand
);
2215 /* FIXME - the following values were determined by experimentation */
2216 /* with the REBAR Control Spy. I have guesses as to what the 4 and */
2217 /* 1 are, but I am not sure. There doesn't seem to be any actual */
2218 /* difference in size of the control area with and without the */
2220 if (infoPtr
->dwStyle
& RBS_BANDBORDERS
) {
2221 if (infoPtr
->dwStyle
& CCS_VERT
) {
2223 lpRect
->top
= lpBand
->cxHeader
+ 4;
2228 lpRect
->left
= lpBand
->cxHeader
+ 4;
2235 lpRect
->left
= lpBand
->cxHeader
;
2241 static inline LRESULT
2242 REBAR_GetBandCount (const REBAR_INFO
*infoPtr
)
2244 TRACE("band count %u!\n", infoPtr
->uNumBands
);
2246 return infoPtr
->uNumBands
;
2251 REBAR_GetBandInfoT(const REBAR_INFO
*infoPtr
, UINT uIndex
, LPREBARBANDINFOW lprbbi
, BOOL bUnicode
)
2255 if (!lprbbi
|| lprbbi
->cbSize
< REBARBANDINFOA_V3_SIZE
)
2258 if (uIndex
>= infoPtr
->uNumBands
)
2261 TRACE("index %u (bUnicode=%d)\n", uIndex
, bUnicode
);
2263 /* copy band information */
2264 lpBand
= REBAR_GetBand(infoPtr
, uIndex
);
2266 if (lprbbi
->fMask
& RBBIM_STYLE
)
2267 lprbbi
->fStyle
= lpBand
->fStyle
;
2269 if (lprbbi
->fMask
& RBBIM_COLORS
) {
2270 lprbbi
->clrFore
= lpBand
->clrFore
;
2271 lprbbi
->clrBack
= lpBand
->clrBack
;
2272 if (lprbbi
->clrBack
== CLR_DEFAULT
)
2273 lprbbi
->clrBack
= infoPtr
->clrBtnFace
;
2276 if (lprbbi
->fMask
& RBBIM_TEXT
) {
2278 Str_GetPtrW(lpBand
->lpText
, lprbbi
->lpText
, lprbbi
->cch
);
2280 Str_GetPtrWtoA(lpBand
->lpText
, (LPSTR
)lprbbi
->lpText
, lprbbi
->cch
);
2283 if (lprbbi
->fMask
& RBBIM_IMAGE
)
2284 lprbbi
->iImage
= lpBand
->iImage
;
2286 if (lprbbi
->fMask
& RBBIM_CHILD
)
2287 lprbbi
->hwndChild
= lpBand
->hwndChild
;
2289 if (lprbbi
->fMask
& RBBIM_CHILDSIZE
) {
2290 lprbbi
->cxMinChild
= lpBand
->cxMinChild
;
2291 lprbbi
->cyMinChild
= lpBand
->cyMinChild
;
2292 /* to make tests pass we follow Windows' behaviour and allow reading these fields only
2293 * for RBBS_VARIABLEHEIGHTS bands */
2294 if (lprbbi
->cbSize
>= REBARBANDINFOW_V6_SIZE
&& (lpBand
->fStyle
& RBBS_VARIABLEHEIGHT
)) {
2295 lprbbi
->cyChild
= lpBand
->cyChild
;
2296 lprbbi
->cyMaxChild
= lpBand
->cyMaxChild
;
2297 lprbbi
->cyIntegral
= lpBand
->cyIntegral
;
2301 if (lprbbi
->fMask
& RBBIM_SIZE
)
2302 lprbbi
->cx
= lpBand
->cx
;
2304 if (lprbbi
->fMask
& RBBIM_BACKGROUND
)
2305 lprbbi
->hbmBack
= lpBand
->hbmBack
;
2307 if (lprbbi
->fMask
& RBBIM_ID
)
2308 lprbbi
->wID
= lpBand
->wID
;
2310 /* check for additional data */
2311 if (lprbbi
->cbSize
>= REBARBANDINFOW_V6_SIZE
) {
2312 if (lprbbi
->fMask
& RBBIM_IDEALSIZE
)
2313 lprbbi
->cxIdeal
= lpBand
->cxIdeal
;
2315 if (lprbbi
->fMask
& RBBIM_LPARAM
)
2316 lprbbi
->lParam
= lpBand
->lParam
;
2318 if (lprbbi
->fMask
& RBBIM_HEADERSIZE
)
2319 lprbbi
->cxHeader
= lpBand
->cxHeader
;
2322 REBAR_DumpBandInfo(lprbbi
);
2329 REBAR_GetBarHeight (const REBAR_INFO
*infoPtr
)
2333 nHeight
= infoPtr
->calcSize
.cy
;
2335 TRACE("height = %d\n", nHeight
);
2342 REBAR_GetBarInfo (const REBAR_INFO
*infoPtr
, LPREBARINFO lpInfo
)
2344 if (!lpInfo
|| lpInfo
->cbSize
< sizeof (REBARINFO
))
2347 TRACE("getting bar info!\n");
2349 if (infoPtr
->himl
) {
2350 lpInfo
->himl
= infoPtr
->himl
;
2351 lpInfo
->fMask
|= RBIM_IMAGELIST
;
2358 static inline LRESULT
2359 REBAR_GetBkColor (const REBAR_INFO
*infoPtr
)
2361 COLORREF clr
= infoPtr
->clrBk
;
2363 if (clr
== CLR_DEFAULT
)
2364 clr
= infoPtr
->clrBtnFace
;
2366 TRACE("background color %#lx\n", clr
);
2372 /* << REBAR_GetColorScheme >> */
2373 /* << REBAR_GetDropTarget >> */
2377 REBAR_GetPalette (const REBAR_INFO
*infoPtr
)
2379 FIXME("empty stub!\n");
2386 REBAR_GetRect (const REBAR_INFO
*infoPtr
, INT iBand
, RECT
*lprc
)
2390 if (iBand
< 0 || iBand
>= infoPtr
->uNumBands
)
2395 lpBand
= REBAR_GetBand(infoPtr
, iBand
);
2396 /* For CCS_VERT the coordinates will be swapped - like on Windows */
2397 *lprc
= lpBand
->rcBand
;
2399 TRACE("band %d, (%s)\n", iBand
, wine_dbgstr_rect(lprc
));
2405 static inline LRESULT
2406 REBAR_GetRowCount (const REBAR_INFO
*infoPtr
)
2408 TRACE("%u\n", infoPtr
->uNumRows
);
2410 return infoPtr
->uNumRows
;
2415 REBAR_GetRowHeight (const REBAR_INFO
*infoPtr
, INT iRow
)
2421 for (i
=0; i
<infoPtr
->uNumBands
; i
++) {
2422 lpBand
= REBAR_GetBand(infoPtr
, i
);
2423 if (HIDDENBAND(lpBand
)) continue;
2424 if (lpBand
->iRow
!= iRow
) continue;
2425 j
= lpBand
->rcBand
.bottom
- lpBand
->rcBand
.top
;
2426 if (j
> ret
) ret
= j
;
2429 TRACE("row %d, height %d\n", iRow
, ret
);
2435 static inline LRESULT
2436 REBAR_GetTextColor (const REBAR_INFO
*infoPtr
)
2438 TRACE("text color %#lx\n", infoPtr
->clrText
);
2440 return infoPtr
->clrText
;
2444 static inline LRESULT
2445 REBAR_GetToolTips (const REBAR_INFO
*infoPtr
)
2447 return (LRESULT
)infoPtr
->hwndToolTip
;
2451 static inline LRESULT
2452 REBAR_GetUnicodeFormat (const REBAR_INFO
*infoPtr
)
2454 TRACE("%s hwnd=%p\n",
2455 infoPtr
->bUnicode
? "TRUE" : "FALSE", infoPtr
->hwndSelf
);
2457 return infoPtr
->bUnicode
;
2461 static inline LRESULT
2462 REBAR_GetVersion (const REBAR_INFO
*infoPtr
)
2464 TRACE("version %d\n", infoPtr
->iVersion
);
2465 return infoPtr
->iVersion
;
2470 REBAR_HitTest (const REBAR_INFO
*infoPtr
, LPRBHITTESTINFO lprbht
)
2475 REBAR_InternalHitTest (infoPtr
, &lprbht
->pt
, &lprbht
->flags
, &lprbht
->iBand
);
2477 return lprbht
->iBand
;
2482 REBAR_IdToIndex (const REBAR_INFO
*infoPtr
, UINT uId
)
2486 if (infoPtr
->uNumBands
< 1)
2489 for (i
= 0; i
< infoPtr
->uNumBands
; i
++) {
2490 if (REBAR_GetBand(infoPtr
, i
)->wID
== uId
) {
2491 TRACE("id %u is band %u found!\n", uId
, i
);
2496 TRACE("id %u is not found\n", uId
);
2502 REBAR_InsertBandT(REBAR_INFO
*infoPtr
, INT iIndex
, const REBARBANDINFOW
*lprbbi
, BOOL bUnicode
)
2506 if (!lprbbi
|| lprbbi
->cbSize
< REBARBANDINFOA_V3_SIZE
)
2509 /* trace the index as signed to see the -1 */
2510 TRACE("insert band at %d (bUnicode=%d)!\n", iIndex
, bUnicode
);
2511 REBAR_DumpBandInfo(lprbbi
);
2513 if (!(lpBand
= Alloc(sizeof(REBAR_BAND
)))) return FALSE
;
2514 if ((iIndex
== -1) || (iIndex
> infoPtr
->uNumBands
))
2515 iIndex
= infoPtr
->uNumBands
;
2516 if (DPA_InsertPtr(infoPtr
->bands
, iIndex
, lpBand
) == -1)
2521 infoPtr
->uNumBands
++;
2523 TRACE("index %d!\n", iIndex
);
2525 /* initialize band */
2526 memset(lpBand
, 0, sizeof(*lpBand
));
2527 lpBand
->clrFore
= infoPtr
->clrText
== CLR_NONE
? infoPtr
->clrBtnText
:
2529 lpBand
->clrBack
= infoPtr
->clrBk
== CLR_NONE
? infoPtr
->clrBtnFace
:
2531 lpBand
->iImage
= -1;
2533 REBAR_CommonSetupBand(infoPtr
->hwndSelf
, lprbbi
, lpBand
);
2535 /* Make sure the defaults for these are correct */
2536 if (lprbbi
->cbSize
< REBARBANDINFOA_V6_SIZE
|| !(lpBand
->fStyle
& RBBS_VARIABLEHEIGHT
)) {
2537 lpBand
->cyChild
= lpBand
->cyMinChild
;
2538 lpBand
->cyMaxChild
= 0x7fffffff;
2539 lpBand
->cyIntegral
= 0;
2542 if ((lprbbi
->fMask
& RBBIM_TEXT
) && (lprbbi
->lpText
)) {
2544 Str_SetPtrW(&lpBand
->lpText
, lprbbi
->lpText
);
2546 Str_SetPtrAtoW(&lpBand
->lpText
, (LPSTR
)lprbbi
->lpText
);
2549 REBAR_ValidateBand (infoPtr
, lpBand
);
2550 /* On insert of second band, revalidate band 1 to possible add gripper */
2551 if (infoPtr
->uNumBands
== 2)
2552 REBAR_ValidateBand (infoPtr
, REBAR_GetBand(infoPtr
, 0));
2554 REBAR_DumpBand (infoPtr
);
2556 REBAR_Layout(infoPtr
);
2557 InvalidateRect(infoPtr
->hwndSelf
, NULL
, TRUE
);
2564 REBAR_MaximizeBand (const REBAR_INFO
*infoPtr
, INT iBand
, LPARAM lParam
)
2567 int iRowBegin
, iRowEnd
;
2568 int cxDesired
, extra
, extraOrig
;
2572 if (infoPtr
->uNumBands
== 0 || iBand
< 0 || iBand
>= infoPtr
->uNumBands
) {
2574 ERR("Illegal MaximizeBand, requested=%d, current band count=%d\n",
2575 iBand
, infoPtr
->uNumBands
);
2579 lpBand
= REBAR_GetBand(infoPtr
, iBand
);
2581 if (lpBand
->fStyle
& RBBS_HIDDEN
)
2583 /* Windows is buggy and creates a hole */
2584 WARN("Ignoring maximize request on a hidden band (%d)\n", iBand
);
2588 cxIdealBand
= lpBand
->cxIdeal
+ lpBand
->cxHeader
+ REBAR_POST_CHILD
;
2589 if (lParam
&& (lpBand
->cxEffective
< cxIdealBand
))
2590 cxDesired
= cxIdealBand
;
2592 cxDesired
= infoPtr
->calcSize
.cx
;
2594 iRowBegin
= get_row_begin_for_band(infoPtr
, iBand
);
2595 iRowEnd
= get_row_end_for_band(infoPtr
, iBand
);
2596 extraOrig
= extra
= cxDesired
- lpBand
->cxEffective
;
2598 extra
= REBAR_ShrinkBandsRTL(infoPtr
, iRowBegin
, iBand
, extra
, TRUE
);
2600 extra
= REBAR_ShrinkBandsLTR(infoPtr
, next_visible(infoPtr
, iBand
), iRowEnd
, extra
, TRUE
);
2601 lpBand
->cxEffective
+= extraOrig
- extra
;
2602 lpBand
->cx
= lpBand
->cxEffective
;
2603 TRACE("(%d, %Id): Wanted size %d, obtained %d (shrink %d, %d)\n", iBand
, lParam
, cxDesired
, lpBand
->cx
, extraOrig
, extra
);
2604 REBAR_SetRowRectsX(infoPtr
, iRowBegin
, iRowEnd
);
2606 if (infoPtr
->dwStyle
& CCS_VERT
)
2607 REBAR_CalcVertBand(infoPtr
, iRowBegin
, iRowEnd
);
2609 REBAR_CalcHorzBand(infoPtr
, iRowBegin
, iRowEnd
);
2610 REBAR_MoveChildWindows(infoPtr
, iRowBegin
, iRowEnd
);
2617 REBAR_MinimizeBand (const REBAR_INFO
*infoPtr
, INT iBand
)
2620 int iPrev
, iRowBegin
, iRowEnd
;
2622 /* A "minimize" band is equivalent to "dragging" the gripper
2623 * of than band to the right till the band is only the size
2628 if (infoPtr
->uNumBands
== 0 || iBand
< 0 || iBand
>= infoPtr
->uNumBands
) {
2630 ERR("Illegal MinimizeBand, requested=%d, current band count=%d\n",
2631 iBand
, infoPtr
->uNumBands
);
2635 /* compute amount of movement and validate */
2636 lpBand
= REBAR_GetBand(infoPtr
, iBand
);
2638 if (lpBand
->fStyle
& RBBS_HIDDEN
)
2640 /* Windows is buggy and creates a hole/overlap */
2641 WARN("Ignoring minimize request on a hidden band (%d)\n", iBand
);
2645 iPrev
= prev_visible(infoPtr
, iBand
);
2646 /* if first band in row */
2647 if (iPrev
< 0 || REBAR_GetBand(infoPtr
, iPrev
)->iRow
!= lpBand
->iRow
) {
2648 int iNext
= next_visible(infoPtr
, iBand
);
2649 if (iNext
< infoPtr
->uNumBands
&& REBAR_GetBand(infoPtr
, iNext
)->iRow
== lpBand
->iRow
) {
2650 TRACE("(%d): Minimizing the first band in row is by maximizing the second\n", iBand
);
2651 REBAR_MaximizeBand(infoPtr
, iNext
, FALSE
);
2654 TRACE("(%d): Only one band in row - nothing to do\n", iBand
);
2658 REBAR_GetBand(infoPtr
, iPrev
)->cxEffective
+= lpBand
->cxEffective
- lpBand
->cxMinBand
;
2659 REBAR_GetBand(infoPtr
, iPrev
)->cx
= REBAR_GetBand(infoPtr
, iPrev
)->cxEffective
;
2660 lpBand
->cx
= lpBand
->cxEffective
= lpBand
->cxMinBand
;
2662 iRowBegin
= get_row_begin_for_band(infoPtr
, iBand
);
2663 iRowEnd
= get_row_end_for_band(infoPtr
, iBand
);
2664 REBAR_SetRowRectsX(infoPtr
, iRowBegin
, iRowEnd
);
2666 if (infoPtr
->dwStyle
& CCS_VERT
)
2667 REBAR_CalcVertBand(infoPtr
, iRowBegin
, iRowEnd
);
2669 REBAR_CalcHorzBand(infoPtr
, iRowBegin
, iRowEnd
);
2670 REBAR_MoveChildWindows(infoPtr
, iRowBegin
, iRowEnd
);
2676 REBAR_MoveBand (REBAR_INFO
*infoPtr
, INT iFrom
, INT iTo
)
2681 if ((infoPtr
->uNumBands
== 0) ||
2682 (iFrom
< 0) || iFrom
>= infoPtr
->uNumBands
||
2683 (iTo
< 0) || iTo
>= infoPtr
->uNumBands
) {
2685 ERR("Illegal MoveBand, from=%d, to=%d, current band count=%d\n",
2686 iFrom
, iTo
, infoPtr
->uNumBands
);
2690 lpBand
= REBAR_GetBand(infoPtr
, iFrom
);
2691 DPA_DeletePtr(infoPtr
->bands
, iFrom
);
2692 DPA_InsertPtr(infoPtr
->bands
, iTo
, lpBand
);
2694 TRACE("moved band %d to index %d\n", iFrom
, iTo
);
2695 REBAR_DumpBand (infoPtr
);
2697 /* **************************************************** */
2699 /* We do not do a REBAR_Layout here because the native */
2700 /* control does not do that. The actual layout and */
2701 /* repaint is done by the *next* real action, ex.: */
2702 /* RB_INSERTBAND, RB_DELETEBAND, RB_SIZETORECT, etc. */
2704 /* **************************************************** */
2710 /* return TRUE if two strings are different */
2712 REBAR_strdifW( LPCWSTR a
, LPCWSTR b
)
2714 return ( (a
&& !b
) || (b
&& !a
) || (a
&& b
&& lstrcmpW(a
, b
) ) );
2718 REBAR_SetBandInfoT(REBAR_INFO
*infoPtr
, INT iBand
, const REBARBANDINFOW
*lprbbi
, BOOL bUnicode
)
2723 if (!lprbbi
|| lprbbi
->cbSize
< REBARBANDINFOA_V3_SIZE
)
2726 if (iBand
>= infoPtr
->uNumBands
)
2729 TRACE("index %d\n", iBand
);
2730 REBAR_DumpBandInfo (lprbbi
);
2732 /* set band information */
2733 lpBand
= REBAR_GetBand(infoPtr
, iBand
);
2735 uChanged
= REBAR_CommonSetupBand (infoPtr
->hwndSelf
, lprbbi
, lpBand
);
2736 if (lprbbi
->fMask
& RBBIM_TEXT
) {
2739 Str_SetPtrW(&wstr
, lprbbi
->lpText
);
2741 Str_SetPtrAtoW(&wstr
, (LPSTR
)lprbbi
->lpText
);
2743 if (REBAR_strdifW(wstr
, lpBand
->lpText
)) {
2744 Free(lpBand
->lpText
);
2745 lpBand
->lpText
= wstr
;
2746 uChanged
|= RBBIM_TEXT
;
2752 REBAR_ValidateBand (infoPtr
, lpBand
);
2754 REBAR_DumpBand (infoPtr
);
2756 if (uChanged
& (RBBIM_CHILDSIZE
| RBBIM_SIZE
| RBBIM_STYLE
| RBBIM_IMAGE
)) {
2757 REBAR_Layout(infoPtr
);
2758 InvalidateRect(infoPtr
->hwndSelf
, NULL
, TRUE
);
2766 REBAR_SetBarInfo (REBAR_INFO
*infoPtr
, const REBARINFO
*lpInfo
)
2771 if (!lpInfo
|| lpInfo
->cbSize
< sizeof (REBARINFO
))
2774 TRACE("setting bar info!\n");
2776 if (lpInfo
->fMask
& RBIM_IMAGELIST
) {
2777 infoPtr
->himl
= lpInfo
->himl
;
2778 if (infoPtr
->himl
) {
2780 ImageList_GetIconSize (infoPtr
->himl
, &cx
, &cy
);
2781 infoPtr
->imageSize
.cx
= cx
;
2782 infoPtr
->imageSize
.cy
= cy
;
2785 infoPtr
->imageSize
.cx
= 0;
2786 infoPtr
->imageSize
.cy
= 0;
2788 TRACE("new image cx=%ld, cy=%ld\n", infoPtr
->imageSize
.cx
, infoPtr
->imageSize
.cy
);
2791 /* revalidate all bands to reset flags for images in headers of bands */
2792 for (i
=0; i
<infoPtr
->uNumBands
; i
++) {
2793 lpBand
= REBAR_GetBand(infoPtr
, i
);
2794 REBAR_ValidateBand (infoPtr
, lpBand
);
2802 REBAR_SetBkColor (REBAR_INFO
*infoPtr
, COLORREF clr
)
2806 clrTemp
= infoPtr
->clrBk
;
2807 infoPtr
->clrBk
= clr
;
2809 TRACE("background color %#lx\n", infoPtr
->clrBk
);
2815 /* << REBAR_SetColorScheme >> */
2816 /* << REBAR_SetPalette >> */
2820 REBAR_SetParent (REBAR_INFO
*infoPtr
, HWND parent
)
2822 HWND hwndTemp
= infoPtr
->hwndNotify
;
2824 infoPtr
->hwndNotify
= parent
;
2826 return (LRESULT
)hwndTemp
;
2831 REBAR_SetTextColor (REBAR_INFO
*infoPtr
, COLORREF clr
)
2835 clrTemp
= infoPtr
->clrText
;
2836 infoPtr
->clrText
= clr
;
2838 TRACE("text color %#lx\n", infoPtr
->clrText
);
2844 /* << REBAR_SetTooltips >> */
2847 static inline LRESULT
2848 REBAR_SetUnicodeFormat (REBAR_INFO
*infoPtr
, BOOL unicode
)
2850 BOOL bTemp
= infoPtr
->bUnicode
;
2852 TRACE("to %s hwnd=%p, was %s\n",
2853 unicode
? "TRUE" : "FALSE", infoPtr
->hwndSelf
,
2854 (bTemp
) ? "TRUE" : "FALSE");
2856 infoPtr
->bUnicode
= unicode
;
2863 REBAR_SetVersion (REBAR_INFO
*infoPtr
, INT iVersion
)
2865 INT iOldVersion
= infoPtr
->iVersion
;
2867 if (iVersion
> COMCTL32_VERSION
)
2870 infoPtr
->iVersion
= iVersion
;
2872 TRACE("new version %d\n", iVersion
);
2879 REBAR_ShowBand (REBAR_INFO
*infoPtr
, INT iBand
, BOOL show
)
2883 if (iBand
< 0 || iBand
>= infoPtr
->uNumBands
)
2886 lpBand
= REBAR_GetBand(infoPtr
, iBand
);
2889 TRACE("show band %d\n", iBand
);
2890 lpBand
->fStyle
= lpBand
->fStyle
& ~RBBS_HIDDEN
;
2891 if (IsWindow (lpBand
->hwndChild
))
2892 ShowWindow (lpBand
->hwndChild
, SW_SHOW
);
2895 TRACE("hide band %d\n", iBand
);
2896 lpBand
->fStyle
= lpBand
->fStyle
| RBBS_HIDDEN
;
2897 if (IsWindow (lpBand
->hwndChild
))
2898 ShowWindow (lpBand
->hwndChild
, SW_HIDE
);
2901 REBAR_Layout(infoPtr
);
2902 InvalidateRect(infoPtr
->hwndSelf
, NULL
, TRUE
);
2909 REBAR_SizeToRect (REBAR_INFO
*infoPtr
, const RECT
*lpRect
)
2911 if (!lpRect
) return FALSE
;
2913 TRACE("[%s]\n", wine_dbgstr_rect(lpRect
));
2914 REBAR_SizeToHeight(infoPtr
, get_rect_cy(infoPtr
, lpRect
));
2921 REBAR_Create (REBAR_INFO
*infoPtr
, LPCREATESTRUCTW cs
)
2925 if (TRACE_ON(rebar
)) {
2926 GetWindowRect(infoPtr
->hwndSelf
, &wnrc1
);
2927 GetClientRect(infoPtr
->hwndSelf
, &clrc1
);
2928 TRACE("window=(%s) client=(%s) cs=(%d,%d %dx%d)\n",
2929 wine_dbgstr_rect(&wnrc1
), wine_dbgstr_rect(&clrc1
),
2930 cs
->x
, cs
->y
, cs
->cx
, cs
->cy
);
2933 OpenThemeData(infoPtr
->hwndSelf
, themeClass
);
2935 TRACE("created!\n");
2941 REBAR_Destroy (REBAR_INFO
*infoPtr
)
2946 /* clean up each band */
2947 for (i
= 0; i
< infoPtr
->uNumBands
; i
++) {
2948 lpBand
= REBAR_GetBand(infoPtr
, i
);
2950 /* delete text strings */
2951 Free (lpBand
->lpText
);
2952 lpBand
->lpText
= NULL
;
2953 /* destroy child window */
2954 DestroyWindow (lpBand
->hwndChild
);
2958 /* free band array */
2959 DPA_Destroy (infoPtr
->bands
);
2960 infoPtr
->bands
= NULL
;
2962 DestroyCursor (infoPtr
->hcurArrow
);
2963 DestroyCursor (infoPtr
->hcurHorz
);
2964 DestroyCursor (infoPtr
->hcurVert
);
2965 DestroyCursor (infoPtr
->hcurDrag
);
2966 if (infoPtr
->hDefaultFont
) DeleteObject (infoPtr
->hDefaultFont
);
2967 SetWindowLongPtrW (infoPtr
->hwndSelf
, 0, 0);
2969 CloseThemeData (GetWindowTheme (infoPtr
->hwndSelf
));
2971 /* free rebar info data */
2973 TRACE("destroyed!\n");
2978 REBAR_GetFont (const REBAR_INFO
*infoPtr
)
2980 return (LRESULT
)infoPtr
->hFont
;
2984 REBAR_PushChevron(const REBAR_INFO
*infoPtr
, UINT uBand
, LPARAM lParam
)
2986 if (uBand
< infoPtr
->uNumBands
)
2988 NMREBARCHEVRON nmrbc
;
2989 REBAR_BAND
*lpBand
= REBAR_GetBand(infoPtr
, uBand
);
2991 TRACE("Pressed chevron on band %u\n", uBand
);
2993 /* redraw chevron in pushed state */
2994 lpBand
->fDraw
|= DRAW_CHEVRONPUSHED
;
2995 RedrawWindow(infoPtr
->hwndSelf
, &lpBand
->rcChevron
,0,
2996 RDW_ERASE
|RDW_INVALIDATE
|RDW_UPDATENOW
);
2998 /* notify app so it can display a popup menu or whatever */
2999 nmrbc
.uBand
= uBand
;
3000 nmrbc
.wID
= lpBand
->wID
;
3001 nmrbc
.lParam
= lpBand
->lParam
;
3002 nmrbc
.rc
= lpBand
->rcChevron
;
3003 nmrbc
.lParamNM
= lParam
;
3004 REBAR_Notify((NMHDR
*)&nmrbc
, infoPtr
, RBN_CHEVRONPUSHED
);
3006 /* redraw chevron in previous state */
3007 lpBand
->fDraw
&= ~DRAW_CHEVRONPUSHED
;
3008 InvalidateRect(infoPtr
->hwndSelf
, &lpBand
->rcChevron
, TRUE
);
3016 REBAR_LButtonDown (REBAR_INFO
*infoPtr
, LPARAM lParam
)
3021 ptMouseDown
.x
= (short)LOWORD(lParam
);
3022 ptMouseDown
.y
= (short)HIWORD(lParam
);
3024 REBAR_InternalHitTest(infoPtr
, &ptMouseDown
, &htFlags
, &iHitBand
);
3026 if (htFlags
== RBHT_CHEVRON
)
3028 REBAR_PushChevron(infoPtr
, iHitBand
, 0);
3030 else if (htFlags
== RBHT_GRABBER
|| htFlags
== RBHT_CAPTION
)
3034 TRACE("Starting drag\n");
3036 lpBand
= REBAR_GetBand(infoPtr
, iHitBand
);
3038 SetCapture (infoPtr
->hwndSelf
);
3039 infoPtr
->iGrabbedBand
= iHitBand
;
3041 /* save off the LOWORD and HIWORD of lParam as initial x,y */
3042 infoPtr
->dragStart
.x
= (short)LOWORD(lParam
);
3043 infoPtr
->dragStart
.y
= (short)HIWORD(lParam
);
3044 infoPtr
->dragNow
= infoPtr
->dragStart
;
3045 if (infoPtr
->dwStyle
& CCS_VERT
)
3046 infoPtr
->ihitoffset
= infoPtr
->dragStart
.y
- (lpBand
->rcBand
.left
+ REBAR_PRE_GRIPPER
);
3048 infoPtr
->ihitoffset
= infoPtr
->dragStart
.x
- (lpBand
->rcBand
.left
+ REBAR_PRE_GRIPPER
);
3054 REBAR_LButtonUp (REBAR_INFO
*infoPtr
)
3056 if (infoPtr
->iGrabbedBand
>= 0)
3061 infoPtr
->dragStart
.x
= 0;
3062 infoPtr
->dragStart
.y
= 0;
3063 infoPtr
->dragNow
= infoPtr
->dragStart
;
3067 if (infoPtr
->fStatus
& BEGIN_DRAG_ISSUED
) {
3068 REBAR_Notify(&layout
, infoPtr
, RBN_LAYOUTCHANGED
);
3069 REBAR_Notify_NMREBAR (infoPtr
, infoPtr
->iGrabbedBand
, RBN_ENDDRAG
);
3070 infoPtr
->fStatus
&= ~BEGIN_DRAG_ISSUED
;
3073 infoPtr
->iGrabbedBand
= -1;
3075 GetClientRect(infoPtr
->hwndSelf
, &rect
);
3076 InvalidateRect(infoPtr
->hwndSelf
, NULL
, TRUE
);
3083 REBAR_MouseLeave (REBAR_INFO
*infoPtr
)
3085 if (infoPtr
->ichevronhotBand
>= 0)
3087 REBAR_BAND
*lpChevronBand
= REBAR_GetBand(infoPtr
, infoPtr
->ichevronhotBand
);
3088 if (lpChevronBand
->fDraw
& DRAW_CHEVRONHOT
)
3090 lpChevronBand
->fDraw
&= ~DRAW_CHEVRONHOT
;
3091 InvalidateRect(infoPtr
->hwndSelf
, &lpChevronBand
->rcChevron
, TRUE
);
3094 infoPtr
->iOldBand
= -1;
3095 infoPtr
->ichevronhotBand
= -2;
3101 REBAR_MouseMove (REBAR_INFO
*infoPtr
, LPARAM lParam
)
3103 REBAR_BAND
*lpChevronBand
;
3106 ptMove
.x
= (short)LOWORD(lParam
);
3107 ptMove
.y
= (short)HIWORD(lParam
);
3109 /* if we are currently dragging a band */
3110 if (infoPtr
->iGrabbedBand
>= 0)
3113 int yPtMove
= (infoPtr
->dwStyle
& CCS_VERT
? ptMove
.x
: ptMove
.y
);
3115 if (GetCapture() != infoPtr
->hwndSelf
)
3116 ERR("We are dragging but haven't got capture?!?\n");
3118 band
= REBAR_GetBand(infoPtr
, infoPtr
->iGrabbedBand
);
3120 /* if mouse did not move much, exit */
3121 if ((abs(ptMove
.x
- infoPtr
->dragNow
.x
) <= mindragx
) &&
3122 (abs(ptMove
.y
- infoPtr
->dragNow
.y
) <= mindragy
)) return 0;
3124 /* on first significant mouse movement, issue notify */
3125 if (!(infoPtr
->fStatus
& BEGIN_DRAG_ISSUED
)) {
3126 if (REBAR_Notify_NMREBAR (infoPtr
, -1, RBN_BEGINDRAG
)) {
3127 /* Notify returned TRUE - abort drag */
3128 infoPtr
->dragStart
.x
= 0;
3129 infoPtr
->dragStart
.y
= 0;
3130 infoPtr
->dragNow
= infoPtr
->dragStart
;
3131 infoPtr
->iGrabbedBand
= -1;
3135 infoPtr
->fStatus
|= BEGIN_DRAG_ISSUED
;
3138 /* Test for valid drag case - must not be first band in row */
3139 if ((yPtMove
< band
->rcBand
.top
) ||
3140 (yPtMove
> band
->rcBand
.bottom
)) {
3141 REBAR_HandleUDDrag (infoPtr
, &ptMove
);
3144 REBAR_HandleLRDrag (infoPtr
, &ptMove
);
3151 TRACKMOUSEEVENT trackinfo
;
3153 REBAR_InternalHitTest(infoPtr
, &ptMove
, &htFlags
, &iHitBand
);
3155 if (infoPtr
->iOldBand
>= 0 && infoPtr
->iOldBand
== infoPtr
->ichevronhotBand
)
3157 lpChevronBand
= REBAR_GetBand(infoPtr
, infoPtr
->ichevronhotBand
);
3158 if (lpChevronBand
->fDraw
& DRAW_CHEVRONHOT
)
3160 lpChevronBand
->fDraw
&= ~DRAW_CHEVRONHOT
;
3161 InvalidateRect(infoPtr
->hwndSelf
, &lpChevronBand
->rcChevron
, TRUE
);
3163 infoPtr
->ichevronhotBand
= -2;
3166 if (htFlags
== RBHT_CHEVRON
)
3168 /* fill in the TRACKMOUSEEVENT struct */
3169 trackinfo
.cbSize
= sizeof(TRACKMOUSEEVENT
);
3170 trackinfo
.dwFlags
= TME_QUERY
;
3171 trackinfo
.hwndTrack
= infoPtr
->hwndSelf
;
3172 trackinfo
.dwHoverTime
= 0;
3174 /* call _TrackMouseEvent to see if we are currently tracking for this hwnd */
3175 _TrackMouseEvent(&trackinfo
);
3177 /* Make sure tracking is enabled so we receive a WM_MOUSELEAVE message */
3178 if(!(trackinfo
.dwFlags
& TME_LEAVE
))
3180 trackinfo
.dwFlags
= TME_LEAVE
; /* notify upon leaving */
3182 /* call TRACKMOUSEEVENT so we receive a WM_MOUSELEAVE message */
3183 /* and can properly deactivate the hot chevron */
3184 _TrackMouseEvent(&trackinfo
);
3187 lpChevronBand
= REBAR_GetBand(infoPtr
, iHitBand
);
3188 if (!(lpChevronBand
->fDraw
& DRAW_CHEVRONHOT
))
3190 lpChevronBand
->fDraw
|= DRAW_CHEVRONHOT
;
3191 InvalidateRect(infoPtr
->hwndSelf
, &lpChevronBand
->rcChevron
, TRUE
);
3192 infoPtr
->ichevronhotBand
= iHitBand
;
3195 infoPtr
->iOldBand
= iHitBand
;
3202 static inline LRESULT
3203 REBAR_NCCalcSize (const REBAR_INFO
*infoPtr
, RECT
*rect
)
3205 if (infoPtr
->dwStyle
& WS_BORDER
) {
3206 rect
->left
= min(rect
->left
+ GetSystemMetrics(SM_CXEDGE
), rect
->right
);
3207 rect
->right
= max(rect
->right
- GetSystemMetrics(SM_CXEDGE
), rect
->left
);
3208 rect
->top
= min(rect
->top
+ GetSystemMetrics(SM_CYEDGE
), rect
->bottom
);
3209 rect
->bottom
= max(rect
->bottom
- GetSystemMetrics(SM_CYEDGE
), rect
->top
);
3212 TRACE("new client=(%s)\n", wine_dbgstr_rect(rect
));
3218 REBAR_NCCreate (HWND hwnd
, const CREATESTRUCTW
*cs
)
3220 REBAR_INFO
*infoPtr
= REBAR_GetInfoPtr (hwnd
);
3222 NONCLIENTMETRICSW ncm
;
3226 ERR("Strange info structure pointer *not* NULL\n");
3230 if (TRACE_ON(rebar
)) {
3231 GetWindowRect(hwnd
, &wnrc1
);
3232 GetClientRect(hwnd
, &clrc1
);
3233 TRACE("window=(%s) client=(%s) cs=(%d,%d %dx%d)\n",
3234 wine_dbgstr_rect(&wnrc1
), wine_dbgstr_rect(&clrc1
),
3235 cs
->x
, cs
->y
, cs
->cx
, cs
->cy
);
3238 /* allocate memory for info structure */
3239 infoPtr
= Alloc (sizeof(REBAR_INFO
));
3240 SetWindowLongPtrW (hwnd
, 0, (DWORD_PTR
)infoPtr
);
3242 /* initialize info structure - initial values are 0 */
3243 infoPtr
->clrBk
= CLR_NONE
;
3244 infoPtr
->clrText
= CLR_NONE
;
3245 infoPtr
->clrBtnText
= comctl32_color
.clrBtnText
;
3246 infoPtr
->clrBtnFace
= comctl32_color
.clrBtnFace
;
3247 infoPtr
->iOldBand
= -1;
3248 infoPtr
->ichevronhotBand
= -2;
3249 infoPtr
->iGrabbedBand
= -1;
3250 infoPtr
->hwndSelf
= hwnd
;
3251 infoPtr
->DoRedraw
= TRUE
;
3252 infoPtr
->hcurArrow
= LoadCursorW (0, (LPWSTR
)IDC_ARROW
);
3253 infoPtr
->hcurHorz
= LoadCursorW (0, (LPWSTR
)IDC_SIZEWE
);
3254 infoPtr
->hcurVert
= LoadCursorW (0, (LPWSTR
)IDC_SIZENS
);
3255 infoPtr
->hcurDrag
= LoadCursorW (0, (LPWSTR
)IDC_SIZE
);
3256 infoPtr
->fStatus
= 0;
3257 infoPtr
->hFont
= GetStockObject (SYSTEM_FONT
);
3258 infoPtr
->bands
= DPA_Create(8);
3260 /* issue WM_NOTIFYFORMAT to get unicode status of parent */
3261 REBAR_NotifyFormat(infoPtr
, NF_REQUERY
);
3263 /* Stow away the original style */
3264 infoPtr
->orgStyle
= cs
->style
;
3265 /* add necessary styles to the requested styles */
3266 infoPtr
->dwStyle
= cs
->style
| WS_VISIBLE
;
3267 if ((infoPtr
->dwStyle
& CCS_LAYOUT_MASK
) == 0)
3268 infoPtr
->dwStyle
|= CCS_TOP
;
3269 SetWindowLongW (hwnd
, GWL_STYLE
, infoPtr
->dwStyle
);
3271 /* get font handle for Caption Font */
3272 ncm
.cbSize
= sizeof(ncm
);
3273 SystemParametersInfoW (SPI_GETNONCLIENTMETRICS
, ncm
.cbSize
, &ncm
, 0);
3274 /* if the font is bold, set to normal */
3275 if (ncm
.lfCaptionFont
.lfWeight
> FW_NORMAL
) {
3276 ncm
.lfCaptionFont
.lfWeight
= FW_NORMAL
;
3278 tfont
= CreateFontIndirectW (&ncm
.lfCaptionFont
);
3280 infoPtr
->hFont
= infoPtr
->hDefaultFont
= tfont
;
3288 REBAR_NCHitTest (const REBAR_INFO
*infoPtr
, LPARAM lParam
)
3294 LRESULT ret
= HTCLIENT
;
3297 * Differences from doc at MSDN (as observed with version 4.71 of
3299 * 1. doc says nmmouse.pt is in screen coord, trace shows client coord.
3300 * 2. if band is not identified .dwItemSpec is 0xffffffff.
3301 * 3. native always seems to return HTCLIENT if notify return is 0.
3304 clpt
.x
= (short)LOWORD(lParam
);
3305 clpt
.y
= (short)HIWORD(lParam
);
3306 ScreenToClient (infoPtr
->hwndSelf
, &clpt
);
3307 REBAR_InternalHitTest (infoPtr
, &clpt
, &scrap
,
3308 (INT
*)&nmmouse
.dwItemSpec
);
3309 nmmouse
.dwItemData
= 0;
3311 nmmouse
.dwHitInfo
= 0;
3312 if ((i
= REBAR_Notify((NMHDR
*) &nmmouse
, infoPtr
, NM_NCHITTEST
)))
3314 TRACE("notify changed return value from %Id to %d\n", ret
, i
);
3317 TRACE("returning %Id, client point %s\n", ret
, wine_dbgstr_point(&clpt
));
3323 REBAR_NCPaint (const REBAR_INFO
*infoPtr
)
3329 if (infoPtr
->dwStyle
& WS_MINIMIZE
)
3330 return 0; /* Nothing to do */
3332 if (infoPtr
->dwStyle
& WS_BORDER
) {
3334 /* adjust rectangle and draw the necessary edge */
3335 if (!(hdc
= GetDCEx( infoPtr
->hwndSelf
, 0, DCX_USESTYLE
| DCX_WINDOW
)))
3337 GetWindowRect (infoPtr
->hwndSelf
, &rcWindow
);
3338 OffsetRect (&rcWindow
, -rcWindow
.left
, -rcWindow
.top
);
3339 TRACE("rect (%s)\n", wine_dbgstr_rect(&rcWindow
));
3340 DrawEdge (hdc
, &rcWindow
, EDGE_ETCHED
, BF_RECT
);
3341 ReleaseDC( infoPtr
->hwndSelf
, hdc
);
3343 else if ((theme
= GetWindowTheme (infoPtr
->hwndSelf
)))
3345 /* adjust rectangle and draw the necessary edge */
3346 if (!(hdc
= GetDCEx( infoPtr
->hwndSelf
, 0, DCX_USESTYLE
| DCX_WINDOW
)))
3348 GetWindowRect (infoPtr
->hwndSelf
, &rcWindow
);
3349 OffsetRect (&rcWindow
, -rcWindow
.left
, -rcWindow
.top
);
3350 TRACE("rect (%s)\n", wine_dbgstr_rect(&rcWindow
));
3351 DrawThemeEdge (theme
, hdc
, 0, 0, &rcWindow
, BDR_RAISEDINNER
, BF_TOP
, NULL
);
3352 ReleaseDC( infoPtr
->hwndSelf
, hdc
);
3360 REBAR_NotifyFormat (REBAR_INFO
*infoPtr
, LPARAM cmd
)
3364 if (cmd
== NF_REQUERY
) {
3365 i
= SendMessageW(REBAR_GetNotifyParent (infoPtr
),
3366 WM_NOTIFYFORMAT
, (WPARAM
)infoPtr
->hwndSelf
, NF_QUERY
);
3367 if ((i
!= NFR_ANSI
) && (i
!= NFR_UNICODE
)) {
3368 ERR("wrong response to WM_NOTIFYFORMAT (%d), assuming ANSI\n", i
);
3371 infoPtr
->bUnicode
= (i
== NFR_UNICODE
);
3374 return (LRESULT
)((infoPtr
->bUnicode
) ? NFR_UNICODE
: NFR_ANSI
);
3379 REBAR_Paint (const REBAR_INFO
*infoPtr
, HDC hdc
)
3382 TRACE("painting\n");
3383 REBAR_Refresh (infoPtr
, hdc
);
3386 hdc
= BeginPaint (infoPtr
->hwndSelf
, &ps
);
3387 TRACE("painting (%s)\n", wine_dbgstr_rect(&ps
.rcPaint
));
3389 /* Erase area of paint if requested */
3390 REBAR_EraseBkGnd (infoPtr
, hdc
);
3392 REBAR_Refresh (infoPtr
, hdc
);
3393 EndPaint (infoPtr
->hwndSelf
, &ps
);
3401 REBAR_SetCursor (const REBAR_INFO
*infoPtr
, LPARAM lParam
)
3406 TRACE("code=0x%X id=0x%X\n", LOWORD(lParam
), HIWORD(lParam
));
3409 ScreenToClient (infoPtr
->hwndSelf
, &pt
);
3411 REBAR_InternalHitTest (infoPtr
, &pt
, &flags
, NULL
);
3413 if (flags
== RBHT_GRABBER
) {
3414 if ((infoPtr
->dwStyle
& CCS_VERT
) &&
3415 !(infoPtr
->dwStyle
& RBS_VERTICALGRIPPER
))
3416 SetCursor (infoPtr
->hcurVert
);
3418 SetCursor (infoPtr
->hcurHorz
);
3420 else if (flags
!= RBHT_CLIENT
)
3421 SetCursor (infoPtr
->hcurArrow
);
3428 REBAR_SetFont (REBAR_INFO
*infoPtr
, HFONT font
)
3433 infoPtr
->hFont
= font
;
3435 /* revalidate all bands to change sizes of text in headers of bands */
3436 for (i
=0; i
<infoPtr
->uNumBands
; i
++) {
3437 lpBand
= REBAR_GetBand(infoPtr
, i
);
3438 REBAR_ValidateBand (infoPtr
, lpBand
);
3441 REBAR_Layout(infoPtr
);
3446 /*****************************************************
3448 * Handles the WM_SETREDRAW message.
3451 * According to testing V4.71 of COMCTL32 returns the
3452 * *previous* status of the redraw flag (either 0 or -1)
3453 * instead of the MSDN documented value of 0 if handled
3455 *****************************************************/
3456 static inline LRESULT
3457 REBAR_SetRedraw (REBAR_INFO
*infoPtr
, BOOL redraw
)
3459 BOOL oldredraw
= infoPtr
->DoRedraw
;
3461 TRACE("set to %s, fStatus=%08x\n",
3462 (redraw
) ? "TRUE" : "FALSE", infoPtr
->fStatus
);
3463 infoPtr
->DoRedraw
= redraw
;
3465 if (infoPtr
->fStatus
& BAND_NEEDS_REDRAW
) {
3466 REBAR_MoveChildWindows (infoPtr
, 0, infoPtr
->uNumBands
);
3467 REBAR_ForceResize (infoPtr
);
3468 InvalidateRect (infoPtr
->hwndSelf
, NULL
, TRUE
);
3470 infoPtr
->fStatus
&= ~BAND_NEEDS_REDRAW
;
3472 return (oldredraw
) ? -1 : 0;
3477 REBAR_Size (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
3479 TRACE("wParam %Ix, lParam %Ix\n", wParam
, lParam
);
3481 /* avoid _Layout resize recursion (but it shouldn't be infinite and it seems Windows does recurse) */
3482 if (infoPtr
->fStatus
& SELF_RESIZE
) {
3483 infoPtr
->fStatus
&= ~SELF_RESIZE
;
3484 TRACE("SELF_RESIZE was set, reset, fStatus=%08x lparam %Ix\n", infoPtr
->fStatus
, lParam
);
3488 if (infoPtr
->dwStyle
& RBS_AUTOSIZE
)
3489 REBAR_AutoSize(infoPtr
, TRUE
);
3491 REBAR_Layout(infoPtr
);
3498 REBAR_StyleChanged (REBAR_INFO
*infoPtr
, INT nType
, const STYLESTRUCT
*lpStyle
)
3500 TRACE("current style %#lx, styleOld %#lx, style being set to %#lx\n",
3501 infoPtr
->dwStyle
, lpStyle
->styleOld
, lpStyle
->styleNew
);
3502 if (nType
== GWL_STYLE
)
3504 infoPtr
->orgStyle
= infoPtr
->dwStyle
= lpStyle
->styleNew
;
3505 /* maybe it should be COMMON_STYLES like in toolbar */
3506 if ((lpStyle
->styleNew
^ lpStyle
->styleOld
) & CCS_VERT
)
3507 REBAR_Layout(infoPtr
);
3512 /* update theme after a WM_THEMECHANGED message */
3513 static LRESULT
theme_changed (REBAR_INFO
* infoPtr
)
3515 HTHEME theme
= GetWindowTheme (infoPtr
->hwndSelf
);
3516 CloseThemeData (theme
);
3517 OpenThemeData(infoPtr
->hwndSelf
, themeClass
);
3522 REBAR_WindowPosChanged (const REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
3527 ret
= DefWindowProcW(infoPtr
->hwndSelf
, WM_WINDOWPOSCHANGED
,
3529 GetWindowRect(infoPtr
->hwndSelf
, &rc
);
3530 TRACE("hwnd %p new pos (%s)\n", infoPtr
->hwndSelf
, wine_dbgstr_rect(&rc
));
3535 static LRESULT WINAPI
3536 REBAR_WindowProc (HWND hwnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
)
3538 REBAR_INFO
*infoPtr
= REBAR_GetInfoPtr (hwnd
);
3540 TRACE("hwnd %p, msg %x, wparam %Ix, lparam %Ix\n", hwnd
, uMsg
, wParam
, lParam
);
3542 if (!infoPtr
&& (uMsg
!= WM_NCCREATE
))
3543 return DefWindowProcW (hwnd
, uMsg
, wParam
, lParam
);
3546 /* case RB_BEGINDRAG: */
3549 return REBAR_DeleteBand (infoPtr
, wParam
);
3551 /* case RB_DRAGMOVE: */
3552 /* case RB_ENDDRAG: */
3554 case RB_GETBANDBORDERS
:
3555 return REBAR_GetBandBorders (infoPtr
, wParam
, (LPRECT
)lParam
);
3557 case RB_GETBANDCOUNT
:
3558 return REBAR_GetBandCount (infoPtr
);
3560 case RB_GETBANDINFO_OLD
:
3561 case RB_GETBANDINFOA
:
3562 case RB_GETBANDINFOW
:
3563 return REBAR_GetBandInfoT(infoPtr
, wParam
, (LPREBARBANDINFOW
)lParam
,
3564 uMsg
== RB_GETBANDINFOW
);
3565 case RB_GETBARHEIGHT
:
3566 return REBAR_GetBarHeight (infoPtr
);
3569 return REBAR_GetBarInfo (infoPtr
, (LPREBARINFO
)lParam
);
3572 return REBAR_GetBkColor (infoPtr
);
3574 /* case RB_GETCOLORSCHEME: */
3575 /* case RB_GETDROPTARGET: */
3578 return REBAR_GetPalette (infoPtr
);
3581 return REBAR_GetRect (infoPtr
, wParam
, (LPRECT
)lParam
);
3583 case RB_GETROWCOUNT
:
3584 return REBAR_GetRowCount (infoPtr
);
3586 case RB_GETROWHEIGHT
:
3587 return REBAR_GetRowHeight (infoPtr
, wParam
);
3589 case RB_GETTEXTCOLOR
:
3590 return REBAR_GetTextColor (infoPtr
);
3592 case RB_GETTOOLTIPS
:
3593 return REBAR_GetToolTips (infoPtr
);
3595 case RB_GETUNICODEFORMAT
:
3596 return REBAR_GetUnicodeFormat (infoPtr
);
3598 case CCM_GETVERSION
:
3599 return REBAR_GetVersion (infoPtr
);
3602 return REBAR_HitTest (infoPtr
, (LPRBHITTESTINFO
)lParam
);
3605 return REBAR_IdToIndex (infoPtr
, wParam
);
3607 case RB_INSERTBANDA
:
3608 case RB_INSERTBANDW
:
3609 return REBAR_InsertBandT(infoPtr
, wParam
, (LPREBARBANDINFOW
)lParam
,
3610 uMsg
== RB_INSERTBANDW
);
3611 case RB_MAXIMIZEBAND
:
3612 return REBAR_MaximizeBand (infoPtr
, wParam
, lParam
);
3614 case RB_MINIMIZEBAND
:
3615 return REBAR_MinimizeBand (infoPtr
, wParam
);
3618 return REBAR_MoveBand (infoPtr
, wParam
, lParam
);
3620 case RB_PUSHCHEVRON
:
3621 return REBAR_PushChevron (infoPtr
, wParam
, lParam
);
3623 case RB_SETBANDINFOA
:
3624 case RB_SETBANDINFOW
:
3625 return REBAR_SetBandInfoT(infoPtr
, wParam
, (LPREBARBANDINFOW
)lParam
,
3626 uMsg
== RB_SETBANDINFOW
);
3628 return REBAR_SetBarInfo (infoPtr
, (LPREBARINFO
)lParam
);
3631 return REBAR_SetBkColor (infoPtr
, lParam
);
3633 /* case RB_SETCOLORSCHEME: */
3634 /* case RB_SETPALETTE: */
3637 return REBAR_SetParent (infoPtr
, (HWND
)wParam
);
3639 case RB_SETTEXTCOLOR
:
3640 return REBAR_SetTextColor (infoPtr
, lParam
);
3642 /* case RB_SETTOOLTIPS: */
3644 case RB_SETUNICODEFORMAT
:
3645 return REBAR_SetUnicodeFormat (infoPtr
, wParam
);
3647 case CCM_SETVERSION
:
3648 return REBAR_SetVersion (infoPtr
, (INT
)wParam
);
3651 return REBAR_ShowBand (infoPtr
, wParam
, lParam
);
3654 return REBAR_SizeToRect (infoPtr
, (LPCRECT
)lParam
);
3657 /* Messages passed to parent */
3661 case WM_MEASUREITEM
:
3662 return SendMessageW(REBAR_GetNotifyParent (infoPtr
), uMsg
, wParam
, lParam
);
3665 /* case WM_CHARTOITEM: supported according to ControlSpy */
3668 return REBAR_Create (infoPtr
, (LPCREATESTRUCTW
)lParam
);
3671 return REBAR_Destroy (infoPtr
);
3674 return REBAR_EraseBkGnd (infoPtr
, (HDC
)wParam
);
3677 return REBAR_GetFont (infoPtr
);
3679 /* case WM_LBUTTONDBLCLK: supported according to ControlSpy */
3681 case WM_LBUTTONDOWN
:
3682 return REBAR_LButtonDown (infoPtr
, lParam
);
3685 return REBAR_LButtonUp (infoPtr
);
3688 return REBAR_MouseMove (infoPtr
, lParam
);
3691 return REBAR_MouseLeave (infoPtr
);
3694 return REBAR_NCCalcSize (infoPtr
, (RECT
*)lParam
);
3697 return REBAR_NCCreate (hwnd
, (LPCREATESTRUCTW
)lParam
);
3700 return REBAR_NCHitTest (infoPtr
, lParam
);
3703 return REBAR_NCPaint (infoPtr
);
3705 case WM_NOTIFYFORMAT
:
3706 return REBAR_NotifyFormat (infoPtr
, lParam
);
3708 case WM_PRINTCLIENT
:
3710 return REBAR_Paint (infoPtr
, (HDC
)wParam
);
3712 /* case WM_PALETTECHANGED: supported according to ControlSpy */
3713 /* case WM_QUERYNEWPALETTE:supported according to ControlSpy */
3714 /* case WM_RBUTTONDOWN: supported according to ControlSpy */
3715 /* case WM_RBUTTONUP: supported according to ControlSpy */
3718 return REBAR_SetCursor (infoPtr
, lParam
);
3721 return REBAR_SetFont (infoPtr
, (HFONT
)wParam
);
3724 return REBAR_SetRedraw (infoPtr
, wParam
);
3727 return REBAR_Size (infoPtr
, wParam
, lParam
);
3729 case WM_STYLECHANGED
:
3730 return REBAR_StyleChanged (infoPtr
, wParam
, (LPSTYLESTRUCT
)lParam
);
3732 case WM_THEMECHANGED
:
3733 return theme_changed (infoPtr
);
3735 case WM_SYSCOLORCHANGE
:
3736 COMCTL32_RefreshSysColors();
3739 /* case WM_VKEYTOITEM: supported according to ControlSpy */
3740 /* case WM_WININICHANGE: */
3742 case WM_WINDOWPOSCHANGED
:
3743 return REBAR_WindowPosChanged (infoPtr
, wParam
, lParam
);
3746 if ((uMsg
>= WM_USER
) && (uMsg
< WM_APP
) && !COMCTL32_IsReflectedMessage(uMsg
))
3747 ERR("unknown msg %04x, wp %Ix, lp %Ix\n", uMsg
, wParam
, lParam
);
3748 return DefWindowProcW (hwnd
, uMsg
, wParam
, lParam
);
3754 REBAR_Register (void)
3758 ZeroMemory (&wndClass
, sizeof(WNDCLASSW
));
3759 wndClass
.style
= CS_GLOBALCLASS
| CS_DBLCLKS
;
3760 wndClass
.lpfnWndProc
= REBAR_WindowProc
;
3761 wndClass
.cbClsExtra
= 0;
3762 wndClass
.cbWndExtra
= sizeof(REBAR_INFO
*);
3763 wndClass
.hCursor
= 0;
3764 wndClass
.hbrBackground
= (HBRUSH
)(COLOR_BTNFACE
+ 1);
3766 wndClass
.hbrBackground
= CreateSolidBrush(RGB(0,128,0));
3768 wndClass
.lpszClassName
= REBARCLASSNAMEW
;
3770 RegisterClassW (&wndClass
);
3772 mindragx
= GetSystemMetrics (SM_CXDRAG
);
3773 mindragy
= GetSystemMetrics (SM_CYDRAG
);
3779 REBAR_Unregister (void)
3781 UnregisterClassW (REBARCLASSNAMEW
, NULL
);