4 * Copyright 1998, 1999 Eric Kohl
5 * Copyright 2007, 2008 Mikolaj Zalewski
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
23 * This code was audited for completeness against the documented features
24 * of Comctl32.dll version 6.0 on Oct. 19, 2004, by Robert Shearman.
26 * Unless otherwise noted, we believe this code to be complete, as per
27 * the specification mentioned above.
28 * If you discover missing features or bugs please note them below.
51 * - WM_QUERYNEWPALETTE
59 * - NM_RELEASEDCAPTURE
65 * Native uses (on each draw!!) SM_CYBORDER (or SM_CXBORDER for CCS_VERT)
66 * to set the size of the separator width (the value SEP_WIDTH_SIZE
67 * in here). Should be fixed!!
71 * Testing: set to 1 to make background brush *always* green
76 * 3. REBAR_MoveChildWindows should have a loop because more than
77 * one pass (together with the RBN_CHILDSIZEs) is made on
78 * at least RB_INSERTBAND
88 #include "wine/unicode.h"
95 #include "wine/debug.h"
97 WINE_DEFAULT_DEBUG_CHANNEL(rebar
);
107 UINT cxMinChild
; /* valid if _CHILDSIZE */
108 UINT cyMinChild
; /* valid if _CHILDSIZE */
109 UINT cx
; /* valid if _SIZE */
112 UINT cyChild
; /* valid if _CHILDSIZE */
113 UINT cyMaxChild
; /* valid if _CHILDSIZE */
114 UINT cyIntegral
; /* valid if _CHILDSIZE */
119 INT cxEffective
; /* current cx for band */
120 UINT cyHeader
; /* the height of the header */
121 UINT cxMinBand
; /* minimum cx for band */
122 UINT cyMinBand
; /* minimum cy for band */
124 UINT cyRowSoFar
; /* for RBS_VARHEIGHT - the height of the row if it would break on this band (set by _Layout) */
125 INT iRow
; /* zero-based index of the row this band assigned to */
126 UINT fStatus
; /* status flags, reset only by _Validate */
127 UINT fDraw
; /* drawing flags, reset only by _Layout */
128 UINT uCDret
; /* last return from NM_CUSTOMDRAW */
129 RECT rcBand
; /* calculated band rectangle - coordinates swapped for CCS_VERT */
130 RECT rcGripper
; /* calculated gripper rectangle */
131 RECT rcCapImage
; /* calculated caption image rectangle */
132 RECT rcCapText
; /* calculated caption text rectangle */
133 RECT rcChild
; /* calculated child rectangle */
134 RECT rcChevron
; /* calculated chevron rectangle */
141 #define HAS_GRIPPER 0x00000001
142 #define HAS_IMAGE 0x00000002
143 #define HAS_TEXT 0x00000004
146 #define DRAW_GRIPPER 0x00000001
147 #define DRAW_IMAGE 0x00000002
148 #define DRAW_TEXT 0x00000004
149 #define DRAW_CHEVRONHOT 0x00000040
150 #define DRAW_CHEVRONPUSHED 0x00000080
151 #define NTF_INVALIDATE 0x01000000
155 COLORREF clrBk
; /* background color */
156 COLORREF clrText
; /* text color */
157 COLORREF clrBtnText
; /* system color for BTNTEXT */
158 COLORREF clrBtnFace
; /* system color for BTNFACE */
159 HIMAGELIST himl
; /* handle to imagelist */
160 UINT uNumBands
; /* # of bands in rebar (first=0, last=uNumBands-1 */
161 UINT uNumRows
; /* # of rows of bands (first=1, last=uNumRows */
162 HWND hwndSelf
; /* handle of REBAR window itself */
163 HWND hwndToolTip
; /* handle to the tool tip control */
164 HWND hwndNotify
; /* notification window (parent) */
166 HFONT hFont
; /* handle to the rebar's font */
167 SIZE imageSize
; /* image size (image list) */
168 DWORD dwStyle
; /* window style */
169 DWORD orgStyle
; /* original style (dwStyle may change) */
170 SIZE calcSize
; /* calculated rebar size - coordinates swapped for CCS_VERT */
171 BOOL bUnicode
; /* TRUE if parent wants notify in W format */
172 BOOL DoRedraw
; /* TRUE to actually draw bands */
173 UINT fStatus
; /* Status flags (see below) */
174 HCURSOR hcurArrow
; /* handle to the arrow cursor */
175 HCURSOR hcurHorz
; /* handle to the EW cursor */
176 HCURSOR hcurVert
; /* handle to the NS cursor */
177 HCURSOR hcurDrag
; /* handle to the drag cursor */
178 INT iVersion
; /* version number */
179 POINT dragStart
; /* x,y of button down */
180 POINT dragNow
; /* x,y of this MouseMove */
181 INT iOldBand
; /* last band that had the mouse cursor over it */
182 INT ihitoffset
; /* offset of hotspot from gripper.left */
183 INT ichevronhotBand
; /* last band that had a hot chevron */
184 INT iGrabbedBand
;/* band number of band whose gripper was grabbed */
186 REBAR_BAND
*bands
; /* pointer to the array of rebar bands */
190 #define BEGIN_DRAG_ISSUED 0x00000001
191 #define SELF_RESIZE 0x00000002
192 #define BAND_NEEDS_REDRAW 0x00000020
194 /* used by Windows to mark that the header size has been set by the user and shouldn't be changed */
195 #define RBBS_UNDOC_FIXEDHEADER 0x40000000
197 /* ---- REBAR layout constants. Mostly determined by ---- */
198 /* ---- experiment on WIN 98. ---- */
200 /* Width (or height) of separators between bands (either horz. or */
201 /* vert.). True only if RBS_BANDBORDERS is set */
202 #define SEP_WIDTH_SIZE 2
203 #define SEP_WIDTH ((infoPtr->dwStyle & RBS_BANDBORDERS) ? SEP_WIDTH_SIZE : 0)
205 /* Blank (background color) space between Gripper (if present) */
206 /* and next item (image, text, or window). Always present */
207 #define REBAR_ALWAYS_SPACE 4
209 /* Blank (background color) space after Image (if present). */
210 #define REBAR_POST_IMAGE 2
212 /* Blank (background color) space after Text (if present). */
213 #define REBAR_POST_TEXT 4
215 /* Height of vertical gripper in a CCS_VERT rebar. */
216 #define GRIPPER_HEIGHT 16
218 /* Blank (background color) space before Gripper (if present). */
219 #define REBAR_PRE_GRIPPER 2
221 /* Width (of normal vertical gripper) or height (of horz. gripper) */
223 #define GRIPPER_WIDTH 3
225 /* Width of the chevron button if present */
226 #define CHEVRON_WIDTH 10
228 /* the gap between the child and the next band */
229 #define REBAR_POST_CHILD 4
231 /* Height of divider for Rebar if not disabled (CCS_NODIVIDER) */
232 /* either top or bottom */
233 #define REBAR_DIVIDER 2
235 /* height of a rebar without a child */
236 #define REBAR_NO_CHILD_HEIGHT 4
238 /* minimum vertical height of a normal bar */
239 /* or minimum width of a CCS_VERT bar - from experiment on Win2k */
240 #define REBAR_MINSIZE 23
242 /* This is the increment that is used over the band height */
243 #define REBARSPACE(a) ((a->fStyle & RBBS_CHILDEDGE) ? 2*REBAR_DIVIDER : 0)
245 /* ---- End of REBAR layout constants. ---- */
247 #define RB_GETBANDINFO_OLD (WM_USER+5) /* obsoleted after IE3, but we have to support it anyway */
249 /* The following define determines if a given band is hidden */
250 #define HIDDENBAND(a) (((a)->fStyle & RBBS_HIDDEN) || \
251 ((infoPtr->dwStyle & CCS_VERT) && \
252 ((a)->fStyle & RBBS_NOVERT)))
254 #define REBAR_GetInfoPtr(wndPtr) ((REBAR_INFO *)GetWindowLongPtrW (hwnd, 0))
256 static LRESULT
REBAR_NotifyFormat(REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
);
257 static void REBAR_AutoSize(REBAR_INFO
*infoPtr
, BOOL needsLayout
);
259 /* "constant values" retrieved when DLL was initialized */
260 /* FIXME we do this when the classes are registered. */
261 static UINT mindragx
= 0;
262 static UINT mindragy
= 0;
264 static const char * const band_stylename
[] = {
265 "RBBS_BREAK", /* 0001 */
266 "RBBS_FIXEDSIZE", /* 0002 */
267 "RBBS_CHILDEDGE", /* 0004 */
268 "RBBS_HIDDEN", /* 0008 */
269 "RBBS_NOVERT", /* 0010 */
270 "RBBS_FIXEDBMP", /* 0020 */
271 "RBBS_VARIABLEHEIGHT", /* 0040 */
272 "RBBS_GRIPPERALWAYS", /* 0080 */
273 "RBBS_NOGRIPPER", /* 0100 */
276 static const char * const band_maskname
[] = {
277 "RBBIM_STYLE", /* 0x00000001 */
278 "RBBIM_COLORS", /* 0x00000002 */
279 "RBBIM_TEXT", /* 0x00000004 */
280 "RBBIM_IMAGE", /* 0x00000008 */
281 "RBBIM_CHILD", /* 0x00000010 */
282 "RBBIM_CHILDSIZE", /* 0x00000020 */
283 "RBBIM_SIZE", /* 0x00000040 */
284 "RBBIM_BACKGROUND", /* 0x00000080 */
285 "RBBIM_ID", /* 0x00000100 */
286 "RBBIM_IDEALSIZE", /* 0x00000200 */
287 "RBBIM_LPARAM", /* 0x00000400 */
288 "RBBIM_HEADERSIZE", /* 0x00000800 */
292 static CHAR line
[200];
294 static const WCHAR themeClass
[] = { 'R','e','b','a','r',0 };
297 REBAR_FmtStyle( UINT style
)
302 while (band_stylename
[i
]) {
303 if (style
& (1<<i
)) {
304 if (*line
!= 0) strcat(line
, " | ");
305 strcat(line
, band_stylename
[i
]);
314 REBAR_FmtMask( UINT mask
)
319 while (band_maskname
[i
]) {
321 if (*line
!= 0) strcat(line
, " | ");
322 strcat(line
, band_maskname
[i
]);
331 REBAR_DumpBandInfo(const REBARBANDINFOW
*pB
)
333 if( !TRACE_ON(rebar
) ) return;
334 TRACE("band info: ");
335 if (pB
->fMask
& RBBIM_ID
)
336 TRACE("ID=%u, ", pB
->wID
);
337 TRACE("size=%u, child=%p", pB
->cbSize
, pB
->hwndChild
);
338 if (pB
->fMask
& RBBIM_COLORS
)
339 TRACE(", clrF=0x%06x, clrB=0x%06x", pB
->clrFore
, pB
->clrBack
);
342 TRACE("band info: mask=0x%08x (%s)\n", pB
->fMask
, REBAR_FmtMask(pB
->fMask
));
343 if (pB
->fMask
& RBBIM_STYLE
)
344 TRACE("band info: style=0x%08x (%s)\n", pB
->fStyle
, REBAR_FmtStyle(pB
->fStyle
));
345 if (pB
->fMask
& (RBBIM_SIZE
| RBBIM_IDEALSIZE
| RBBIM_HEADERSIZE
| RBBIM_LPARAM
)) {
347 if (pB
->fMask
& RBBIM_SIZE
)
348 TRACE(" cx=%u", pB
->cx
);
349 if (pB
->fMask
& RBBIM_IDEALSIZE
)
350 TRACE(" xIdeal=%u", pB
->cxIdeal
);
351 if (pB
->fMask
& RBBIM_HEADERSIZE
)
352 TRACE(" xHeader=%u", pB
->cxHeader
);
353 if (pB
->fMask
& RBBIM_LPARAM
)
354 TRACE(" lParam=0x%08lx", pB
->lParam
);
357 if (pB
->fMask
& RBBIM_CHILDSIZE
)
358 TRACE("band info: xMin=%u, yMin=%u, yChild=%u, yMax=%u, yIntgl=%u\n",
360 pB
->cyMinChild
, pB
->cyChild
, pB
->cyMaxChild
, pB
->cyIntegral
);
364 REBAR_DumpBand (const REBAR_INFO
*iP
)
369 if(! TRACE_ON(rebar
) ) return;
371 TRACE("hwnd=%p: color=%08x/%08x, bands=%u, rows=%u, cSize=%d,%d\n",
372 iP
->hwndSelf
, iP
->clrText
, iP
->clrBk
, iP
->uNumBands
, iP
->uNumRows
,
373 iP
->calcSize
.cx
, iP
->calcSize
.cy
);
374 TRACE("hwnd=%p: flags=%08x, dragStart=%d,%d, dragNow=%d,%d, iGrabbedBand=%d\n",
375 iP
->hwndSelf
, iP
->fStatus
, iP
->dragStart
.x
, iP
->dragStart
.y
,
376 iP
->dragNow
.x
, iP
->dragNow
.y
,
378 TRACE("hwnd=%p: style=%08x, notify in Unicode=%s, redraw=%s\n",
379 iP
->hwndSelf
, iP
->dwStyle
, (iP
->bUnicode
)?"TRUE":"FALSE",
380 (iP
->DoRedraw
)?"TRUE":"FALSE");
381 for (i
= 0; i
< iP
->uNumBands
; i
++) {
383 TRACE("band # %u:", i
);
384 if (pB
->fMask
& RBBIM_ID
)
385 TRACE(" ID=%u", pB
->wID
);
386 if (pB
->fMask
& RBBIM_CHILD
)
387 TRACE(" child=%p", pB
->hwndChild
);
388 if (pB
->fMask
& RBBIM_COLORS
)
389 TRACE(" clrF=0x%06x clrB=0x%06x", pB
->clrFore
, pB
->clrBack
);
391 TRACE("band # %u: mask=0x%08x (%s)\n", i
, pB
->fMask
, REBAR_FmtMask(pB
->fMask
));
392 if (pB
->fMask
& RBBIM_STYLE
)
393 TRACE("band # %u: style=0x%08x (%s)\n",
394 i
, pB
->fStyle
, REBAR_FmtStyle(pB
->fStyle
));
395 TRACE("band # %u: xHeader=%u",
397 if (pB
->fMask
& (RBBIM_SIZE
| RBBIM_IDEALSIZE
| RBBIM_LPARAM
)) {
398 if (pB
->fMask
& RBBIM_SIZE
)
399 TRACE(" cx=%u", pB
->cx
);
400 if (pB
->fMask
& RBBIM_IDEALSIZE
)
401 TRACE(" xIdeal=%u", pB
->cxIdeal
);
402 if (pB
->fMask
& RBBIM_LPARAM
)
403 TRACE(" lParam=0x%08lx", pB
->lParam
);
407 TRACE("band # %u: xMin=%u, yMin=%u, yChild=%u, yMax=%u, yIntgl=%u\n",
408 i
, pB
->cxMinChild
, pB
->cyMinChild
, pB
->cyChild
, pB
->cyMaxChild
, pB
->cyIntegral
);
409 if (pB
->fMask
& RBBIM_TEXT
)
410 TRACE("band # %u: text=%s\n",
411 i
, (pB
->lpText
) ? debugstr_w(pB
->lpText
) : "(null)");
412 TRACE("band # %u: cxMinBand=%u, cxEffective=%u, cyMinBand=%u\n",
413 i
, pB
->cxMinBand
, pB
->cxEffective
, pB
->cyMinBand
);
414 TRACE("band # %u: fStatus=%08x, fDraw=%08x, Band=(%s), Grip=(%s)\n",
415 i
, pB
->fStatus
, pB
->fDraw
, wine_dbgstr_rect(&pB
->rcBand
),
416 wine_dbgstr_rect(&pB
->rcGripper
));
417 TRACE("band # %u: Img=(%s), Txt=(%s), Child=(%s)\n",
418 i
, wine_dbgstr_rect(&pB
->rcCapImage
),
419 wine_dbgstr_rect(&pB
->rcCapText
), wine_dbgstr_rect(&pB
->rcChild
));
424 /* dest can be equal to src */
425 static void translate_rect(const REBAR_INFO
*infoPtr
, RECT
*dest
, const RECT
*src
)
427 if (infoPtr
->dwStyle
& CCS_VERT
) {
430 dest
->left
= src
->top
;
434 dest
->right
= src
->bottom
;
441 static int get_rect_cx(const REBAR_INFO
*infoPtr
, const RECT
*lpRect
)
443 if (infoPtr
->dwStyle
& CCS_VERT
)
444 return lpRect
->bottom
- lpRect
->top
;
445 return lpRect
->right
- lpRect
->left
;
448 static int get_rect_cy(const REBAR_INFO
*infoPtr
, const RECT
*lpRect
)
450 if (infoPtr
->dwStyle
& CCS_VERT
)
451 return lpRect
->right
- lpRect
->left
;
452 return lpRect
->bottom
- lpRect
->top
;
455 static int round_child_height(REBAR_BAND
*lpBand
, int cyHeight
)
458 if (lpBand
->cyIntegral
== 0)
460 cy
= max(cyHeight
- (int)lpBand
->cyMinChild
, 0);
461 cy
= lpBand
->cyMinChild
+ (cy
/lpBand
->cyIntegral
) * lpBand
->cyIntegral
;
462 cy
= min(cy
, lpBand
->cyMaxChild
);
466 static void update_min_band_height(const REBAR_INFO
*infoPtr
, REBAR_BAND
*lpBand
)
468 lpBand
->cyMinBand
= max(lpBand
->cyHeader
,
469 (lpBand
->hwndChild
? lpBand
->cyChild
+ REBARSPACE(lpBand
) : REBAR_NO_CHILD_HEIGHT
));
473 REBAR_DrawChevron (HDC hdc
, INT left
, INT top
, INT colorRef
)
478 if (!(hPen
= CreatePen( PS_SOLID
, 1, GetSysColor( colorRef
)))) return;
479 hOldPen
= SelectObject ( hdc
, hPen
);
482 MoveToEx (hdc
, x
, y
, NULL
);
483 LineTo (hdc
, x
+5, y
++); x
++;
484 MoveToEx (hdc
, x
, y
, NULL
);
485 LineTo (hdc
, x
+3, y
++); x
++;
486 MoveToEx (hdc
, x
, y
, NULL
);
487 LineTo (hdc
, x
+1, y
++);
488 SelectObject( hdc
, hOldPen
);
489 DeleteObject( hPen
);
493 REBAR_GetNotifyParent (const REBAR_INFO
*infoPtr
)
497 parent
= infoPtr
->hwndNotify
;
499 parent
= GetParent (infoPtr
->hwndSelf
);
500 owner
= GetWindow (infoPtr
->hwndSelf
, GW_OWNER
);
501 if (owner
) parent
= owner
;
508 REBAR_Notify (NMHDR
*nmhdr
, const REBAR_INFO
*infoPtr
, UINT code
)
512 parent
= REBAR_GetNotifyParent (infoPtr
);
513 nmhdr
->idFrom
= GetDlgCtrlID (infoPtr
->hwndSelf
);
514 nmhdr
->hwndFrom
= infoPtr
->hwndSelf
;
517 TRACE("window %p, code=%08x, via %s\n", parent
, code
, (infoPtr
->bUnicode
)?"Unicode":"ANSI");
519 return SendMessageW(parent
, WM_NOTIFY
, nmhdr
->idFrom
, (LPARAM
)nmhdr
);
523 REBAR_Notify_NMREBAR (const REBAR_INFO
*infoPtr
, UINT uBand
, UINT code
)
525 NMREBAR notify_rebar
;
528 notify_rebar
.dwMask
= 0;
530 lpBand
= &infoPtr
->bands
[uBand
];
531 if (lpBand
->fMask
& RBBIM_ID
) {
532 notify_rebar
.dwMask
|= RBNM_ID
;
533 notify_rebar
.wID
= lpBand
->wID
;
535 if (lpBand
->fMask
& RBBIM_LPARAM
) {
536 notify_rebar
.dwMask
|= RBNM_LPARAM
;
537 notify_rebar
.lParam
= lpBand
->lParam
;
539 if (lpBand
->fMask
& RBBIM_STYLE
) {
540 notify_rebar
.dwMask
|= RBNM_STYLE
;
541 notify_rebar
.fStyle
= lpBand
->fStyle
;
544 notify_rebar
.uBand
= uBand
;
545 return REBAR_Notify ((NMHDR
*)¬ify_rebar
, infoPtr
, code
);
549 REBAR_DrawBand (HDC hdc
, const REBAR_INFO
*infoPtr
, REBAR_BAND
*lpBand
)
554 HTHEME theme
= GetWindowTheme (infoPtr
->hwndSelf
);
557 translate_rect(infoPtr
, &rcBand
, &lpBand
->rcBand
);
559 if (lpBand
->fDraw
& DRAW_TEXT
) {
560 hOldFont
= SelectObject (hdc
, infoPtr
->hFont
);
561 oldBkMode
= SetBkMode (hdc
, TRANSPARENT
);
564 /* should test for CDRF_NOTIFYITEMDRAW here */
565 nmcd
.dwDrawStage
= CDDS_ITEMPREPAINT
;
568 nmcd
.rc
.right
= lpBand
->rcCapText
.right
;
569 nmcd
.rc
.bottom
= lpBand
->rcCapText
.bottom
;
570 nmcd
.dwItemSpec
= lpBand
->wID
;
572 nmcd
.lItemlParam
= lpBand
->lParam
;
573 lpBand
->uCDret
= REBAR_Notify ((NMHDR
*)&nmcd
, infoPtr
, NM_CUSTOMDRAW
);
574 if (lpBand
->uCDret
== CDRF_SKIPDEFAULT
) {
575 if (oldBkMode
!= TRANSPARENT
)
576 SetBkMode (hdc
, oldBkMode
);
577 SelectObject (hdc
, hOldFont
);
582 if (lpBand
->fDraw
& DRAW_GRIPPER
)
586 RECT rcGripper
= lpBand
->rcGripper
;
587 int partId
= (infoPtr
->dwStyle
& CCS_VERT
) ? RP_GRIPPERVERT
: RP_GRIPPER
;
588 GetThemeBackgroundExtent (theme
, hdc
, partId
, 0, &rcGripper
, &rcGripper
);
589 OffsetRect (&rcGripper
, lpBand
->rcGripper
.left
- rcGripper
.left
,
590 lpBand
->rcGripper
.top
- rcGripper
.top
);
591 DrawThemeBackground (theme
, hdc
, partId
, 0, &rcGripper
, NULL
);
594 DrawEdge (hdc
, &lpBand
->rcGripper
, BDR_RAISEDINNER
, BF_RECT
| BF_MIDDLE
);
597 /* draw caption image */
598 if (lpBand
->fDraw
& DRAW_IMAGE
) {
602 pt
.y
= (lpBand
->rcCapImage
.bottom
+ lpBand
->rcCapImage
.top
- infoPtr
->imageSize
.cy
)/2;
603 pt
.x
= (lpBand
->rcCapImage
.right
+ lpBand
->rcCapImage
.left
- infoPtr
->imageSize
.cx
)/2;
605 ImageList_Draw (infoPtr
->himl
, lpBand
->iImage
, hdc
,
610 /* draw caption text */
611 if (lpBand
->fDraw
& DRAW_TEXT
) {
612 /* need to handle CDRF_NEWFONT here */
613 INT oldBkMode
= SetBkMode (hdc
, TRANSPARENT
);
614 COLORREF oldcolor
= CLR_NONE
;
616 if (lpBand
->clrFore
!= CLR_NONE
) {
617 new = (lpBand
->clrFore
== CLR_DEFAULT
) ? infoPtr
->clrBtnText
:
619 oldcolor
= SetTextColor (hdc
, new);
621 DrawTextW (hdc
, lpBand
->lpText
, -1, &lpBand
->rcCapText
,
622 DT_CENTER
| DT_VCENTER
| DT_SINGLELINE
);
623 if (oldBkMode
!= TRANSPARENT
)
624 SetBkMode (hdc
, oldBkMode
);
625 if (lpBand
->clrFore
!= CLR_NONE
)
626 SetTextColor (hdc
, oldcolor
);
627 SelectObject (hdc
, hOldFont
);
630 if (!IsRectEmpty(&lpBand
->rcChevron
))
635 if (lpBand
->fDraw
& DRAW_CHEVRONPUSHED
)
636 stateId
= CHEVS_PRESSED
;
637 else if (lpBand
->fDraw
& DRAW_CHEVRONHOT
)
640 stateId
= CHEVS_NORMAL
;
641 DrawThemeBackground (theme
, hdc
, RP_CHEVRON
, stateId
, &lpBand
->rcChevron
, NULL
);
645 if (lpBand
->fDraw
& DRAW_CHEVRONPUSHED
)
647 DrawEdge(hdc
, &lpBand
->rcChevron
, BDR_SUNKENOUTER
, BF_RECT
| BF_MIDDLE
);
648 REBAR_DrawChevron(hdc
, lpBand
->rcChevron
.left
+1, lpBand
->rcChevron
.top
+ 11, COLOR_WINDOWFRAME
);
650 else if (lpBand
->fDraw
& DRAW_CHEVRONHOT
)
652 DrawEdge(hdc
, &lpBand
->rcChevron
, BDR_RAISEDINNER
, BF_RECT
| BF_MIDDLE
);
653 REBAR_DrawChevron(hdc
, lpBand
->rcChevron
.left
, lpBand
->rcChevron
.top
+ 10, COLOR_WINDOWFRAME
);
656 REBAR_DrawChevron(hdc
, lpBand
->rcChevron
.left
, lpBand
->rcChevron
.top
+ 10, COLOR_WINDOWFRAME
);
660 if (lpBand
->uCDret
== (CDRF_NOTIFYPOSTPAINT
| CDRF_NOTIFYITEMDRAW
)) {
661 nmcd
.dwDrawStage
= CDDS_ITEMPOSTPAINT
;
664 nmcd
.rc
.right
= lpBand
->rcCapText
.right
;
665 nmcd
.rc
.bottom
= lpBand
->rcCapText
.bottom
;
666 nmcd
.dwItemSpec
= lpBand
->wID
;
668 nmcd
.lItemlParam
= lpBand
->lParam
;
669 lpBand
->uCDret
= REBAR_Notify ((NMHDR
*)&nmcd
, infoPtr
, NM_CUSTOMDRAW
);
675 REBAR_Refresh (const REBAR_INFO
*infoPtr
, HDC hdc
)
680 if (!infoPtr
->DoRedraw
) return;
682 for (i
= 0; i
< infoPtr
->uNumBands
; i
++) {
683 lpBand
= &infoPtr
->bands
[i
];
685 if (HIDDENBAND(lpBand
)) continue;
687 /* now draw the band */
688 TRACE("[%p] drawing band %i, flags=%08x\n",
689 infoPtr
->hwndSelf
, i
, lpBand
->fDraw
);
690 REBAR_DrawBand (hdc
, infoPtr
, lpBand
);
697 REBAR_CalcHorzBand (const REBAR_INFO
*infoPtr
, UINT rstart
, UINT rend
)
698 /* Function: this routine initializes all the rectangles in */
699 /* each band in a row to fit in the adjusted rcBand rect. */
700 /* *** Supports only Horizontal bars. *** */
706 for(i
=rstart
; i
<rend
; i
++){
707 lpBand
= &infoPtr
->bands
[i
];
708 if (HIDDENBAND(lpBand
)) {
709 SetRect (&lpBand
->rcChild
,
710 lpBand
->rcBand
.right
, lpBand
->rcBand
.top
,
711 lpBand
->rcBand
.right
, lpBand
->rcBand
.bottom
);
715 /* set initial gripper rectangle */
716 SetRect (&lpBand
->rcGripper
, lpBand
->rcBand
.left
, lpBand
->rcBand
.top
,
717 lpBand
->rcBand
.left
, lpBand
->rcBand
.bottom
);
719 /* calculate gripper rectangle */
720 if ( lpBand
->fStatus
& HAS_GRIPPER
) {
721 lpBand
->fDraw
|= DRAW_GRIPPER
;
722 lpBand
->rcGripper
.left
+= REBAR_PRE_GRIPPER
;
723 lpBand
->rcGripper
.right
= lpBand
->rcGripper
.left
+ GRIPPER_WIDTH
;
724 lpBand
->rcGripper
.top
+= 2;
725 lpBand
->rcGripper
.bottom
-= 2;
727 SetRect (&lpBand
->rcCapImage
,
728 lpBand
->rcGripper
.right
+REBAR_ALWAYS_SPACE
, lpBand
->rcBand
.top
,
729 lpBand
->rcGripper
.right
+REBAR_ALWAYS_SPACE
, lpBand
->rcBand
.bottom
);
731 else { /* no gripper will be drawn */
733 if (lpBand
->fStatus
& (HAS_IMAGE
| HAS_TEXT
))
734 /* if no gripper but either image or text, then leave space */
735 xoff
= REBAR_ALWAYS_SPACE
;
736 SetRect (&lpBand
->rcCapImage
,
737 lpBand
->rcBand
.left
+xoff
, lpBand
->rcBand
.top
,
738 lpBand
->rcBand
.left
+xoff
, lpBand
->rcBand
.bottom
);
741 /* image is visible */
742 if (lpBand
->fStatus
& HAS_IMAGE
) {
743 lpBand
->fDraw
|= DRAW_IMAGE
;
744 lpBand
->rcCapImage
.right
+= infoPtr
->imageSize
.cx
;
745 lpBand
->rcCapImage
.bottom
= lpBand
->rcCapImage
.top
+ infoPtr
->imageSize
.cy
;
747 /* set initial caption text rectangle */
748 SetRect (&lpBand
->rcCapText
,
749 lpBand
->rcCapImage
.right
+REBAR_POST_IMAGE
, lpBand
->rcBand
.top
+1,
750 lpBand
->rcBand
.left
+lpBand
->cxHeader
, lpBand
->rcBand
.bottom
-1);
753 /* set initial caption text rectangle */
754 SetRect (&lpBand
->rcCapText
, lpBand
->rcCapImage
.right
, lpBand
->rcBand
.top
+1,
755 lpBand
->rcBand
.left
+lpBand
->cxHeader
, lpBand
->rcBand
.bottom
-1);
758 /* text is visible */
759 if ((lpBand
->fStatus
& HAS_TEXT
) && !(lpBand
->fStyle
& RBBS_HIDETITLE
)) {
760 lpBand
->fDraw
|= DRAW_TEXT
;
761 lpBand
->rcCapText
.right
= max(lpBand
->rcCapText
.left
,
762 lpBand
->rcCapText
.right
-REBAR_POST_TEXT
);
765 /* set initial child window rectangle if there is a child */
766 if (lpBand
->hwndChild
!= NULL
) {
767 int cyBand
= lpBand
->rcBand
.bottom
- lpBand
->rcBand
.top
;
768 yoff
= (cyBand
- lpBand
->cyChild
) / 2;
769 SetRect (&lpBand
->rcChild
,
770 lpBand
->rcBand
.left
+ lpBand
->cxHeader
, lpBand
->rcBand
.top
+ yoff
,
771 lpBand
->rcBand
.right
- REBAR_POST_CHILD
, lpBand
->rcBand
.top
+ yoff
+ lpBand
->cyChild
);
772 if ((lpBand
->fStyle
& RBBS_USECHEVRON
) && (lpBand
->rcChild
.right
- lpBand
->rcChild
.left
< lpBand
->cxIdeal
))
774 lpBand
->rcChild
.right
-= CHEVRON_WIDTH
;
775 SetRect(&lpBand
->rcChevron
, lpBand
->rcChild
.right
,
776 lpBand
->rcChild
.top
, lpBand
->rcChild
.right
+ CHEVRON_WIDTH
,
777 lpBand
->rcChild
.bottom
);
781 SetRect (&lpBand
->rcChild
,
782 lpBand
->rcBand
.left
+lpBand
->cxHeader
, lpBand
->rcBand
.top
,
783 lpBand
->rcBand
.right
, lpBand
->rcBand
.bottom
);
786 /* flag if notify required and invalidate rectangle */
787 if (lpBand
->fDraw
& NTF_INVALIDATE
) {
788 TRACE("invalidating (%d,%d)-(%d,%d)\n",
791 lpBand
->rcBand
.right
+ SEP_WIDTH
,
792 lpBand
->rcBand
.bottom
+ SEP_WIDTH
);
793 lpBand
->fDraw
&= ~NTF_INVALIDATE
;
794 work
= lpBand
->rcBand
;
795 work
.right
+= SEP_WIDTH
;
796 work
.bottom
+= SEP_WIDTH
;
797 InvalidateRect(infoPtr
->hwndSelf
, &work
, TRUE
);
798 InvalidateRect(lpBand
->hwndChild
, NULL
, TRUE
);
807 REBAR_CalcVertBand (const REBAR_INFO
*infoPtr
, UINT rstart
, UINT rend
)
808 /* Function: this routine initializes all the rectangles in */
809 /* each band in a row to fit in the adjusted rcBand rect. */
810 /* *** Supports only Vertical bars. *** */
816 for(i
=rstart
; i
<rend
; i
++){
818 lpBand
= &infoPtr
->bands
[i
];
819 if (HIDDENBAND(lpBand
)) continue;
821 translate_rect(infoPtr
, &rcBand
, &lpBand
->rcBand
);
823 /* set initial gripper rectangle */
824 SetRect (&lpBand
->rcGripper
, rcBand
.left
, rcBand
.top
, rcBand
.right
, rcBand
.top
);
826 /* calculate gripper rectangle */
827 if (lpBand
->fStatus
& HAS_GRIPPER
) {
828 lpBand
->fDraw
|= DRAW_GRIPPER
;
830 if (infoPtr
->dwStyle
& RBS_VERTICALGRIPPER
) {
831 /* vertical gripper */
832 lpBand
->rcGripper
.left
+= 3;
833 lpBand
->rcGripper
.right
= lpBand
->rcGripper
.left
+ GRIPPER_WIDTH
;
834 lpBand
->rcGripper
.top
+= REBAR_PRE_GRIPPER
;
835 lpBand
->rcGripper
.bottom
= lpBand
->rcGripper
.top
+ GRIPPER_HEIGHT
;
837 /* initialize Caption image rectangle */
838 SetRect (&lpBand
->rcCapImage
, rcBand
.left
,
839 lpBand
->rcGripper
.bottom
+ REBAR_ALWAYS_SPACE
,
841 lpBand
->rcGripper
.bottom
+ REBAR_ALWAYS_SPACE
);
844 /* horizontal gripper */
845 lpBand
->rcGripper
.left
+= 2;
846 lpBand
->rcGripper
.right
-= 2;
847 lpBand
->rcGripper
.top
+= REBAR_PRE_GRIPPER
;
848 lpBand
->rcGripper
.bottom
= lpBand
->rcGripper
.top
+ GRIPPER_WIDTH
;
850 /* initialize Caption image rectangle */
851 SetRect (&lpBand
->rcCapImage
, rcBand
.left
,
852 lpBand
->rcGripper
.bottom
+ REBAR_ALWAYS_SPACE
,
854 lpBand
->rcGripper
.bottom
+ REBAR_ALWAYS_SPACE
);
857 else { /* no gripper will be drawn */
859 if (lpBand
->fStatus
& (HAS_IMAGE
| HAS_TEXT
))
860 /* if no gripper but either image or text, then leave space */
861 xoff
= REBAR_ALWAYS_SPACE
;
862 /* initialize Caption image rectangle */
863 SetRect (&lpBand
->rcCapImage
,
864 rcBand
.left
, rcBand
.top
+xoff
,
865 rcBand
.right
, rcBand
.top
+xoff
);
868 /* image is visible */
869 if (lpBand
->fStatus
& HAS_IMAGE
) {
870 lpBand
->fDraw
|= DRAW_IMAGE
;
872 lpBand
->rcCapImage
.right
= lpBand
->rcCapImage
.left
+ infoPtr
->imageSize
.cx
;
873 lpBand
->rcCapImage
.bottom
+= infoPtr
->imageSize
.cy
;
875 /* set initial caption text rectangle */
876 SetRect (&lpBand
->rcCapText
,
877 rcBand
.left
, lpBand
->rcCapImage
.bottom
+REBAR_POST_IMAGE
,
878 rcBand
.right
, rcBand
.top
+lpBand
->cxHeader
);
881 /* set initial caption text rectangle */
882 SetRect (&lpBand
->rcCapText
,
883 rcBand
.left
, lpBand
->rcCapImage
.bottom
,
884 rcBand
.right
, rcBand
.top
+lpBand
->cxHeader
);
887 /* text is visible */
888 if ((lpBand
->fStatus
& HAS_TEXT
) && !(lpBand
->fStyle
& RBBS_HIDETITLE
)) {
889 lpBand
->fDraw
|= DRAW_TEXT
;
890 lpBand
->rcCapText
.bottom
= max(lpBand
->rcCapText
.top
,
891 lpBand
->rcCapText
.bottom
);
894 /* set initial child window rectangle if there is a child */
895 if (lpBand
->hwndChild
!= NULL
) {
896 int cxBand
= rcBand
.right
- rcBand
.left
;
897 xoff
= (cxBand
- lpBand
->cyChild
) / 2;
898 SetRect (&lpBand
->rcChild
,
899 rcBand
.left
+ xoff
, rcBand
.top
+ lpBand
->cxHeader
,
900 rcBand
.left
+ xoff
+ lpBand
->cyChild
, rcBand
.bottom
- REBAR_POST_CHILD
);
903 SetRect (&lpBand
->rcChild
,
904 rcBand
.left
, rcBand
.top
+lpBand
->cxHeader
,
905 rcBand
.right
, rcBand
.bottom
);
908 if (lpBand
->fDraw
& NTF_INVALIDATE
) {
909 TRACE("invalidating (%d,%d)-(%d,%d)\n",
912 rcBand
.right
+ SEP_WIDTH
,
913 rcBand
.bottom
+ SEP_WIDTH
);
914 lpBand
->fDraw
&= ~NTF_INVALIDATE
;
916 work
.bottom
+= SEP_WIDTH
;
917 work
.right
+= SEP_WIDTH
;
918 InvalidateRect(infoPtr
->hwndSelf
, &work
, TRUE
);
919 InvalidateRect(lpBand
->hwndChild
, NULL
, TRUE
);
927 REBAR_ForceResize (REBAR_INFO
*infoPtr
)
928 /* Function: This changes the size of the REBAR window to that */
929 /* calculated by REBAR_Layout. */
931 INT x
, y
, width
, height
;
932 INT xedge
= 0, yedge
= 0;
935 TRACE("new size [%d x %d]\n", infoPtr
->calcSize
.cx
, infoPtr
->calcSize
.cy
);
937 if (infoPtr
->dwStyle
& CCS_NORESIZE
)
940 if (infoPtr
->dwStyle
& WS_BORDER
)
942 xedge
= GetSystemMetrics(SM_CXEDGE
);
943 yedge
= GetSystemMetrics(SM_CYEDGE
);
944 /* swap for CCS_VERT? */
947 /* compute rebar window rect in parent client coordinates */
948 GetWindowRect(infoPtr
->hwndSelf
, &rcSelf
);
949 MapWindowPoints(HWND_DESKTOP
, GetParent(infoPtr
->hwndSelf
), (LPPOINT
)&rcSelf
, 2);
950 translate_rect(infoPtr
, &rcSelf
, &rcSelf
);
952 height
= infoPtr
->calcSize
.cy
+ 2*yedge
;
953 if (!(infoPtr
->dwStyle
& CCS_NOPARENTALIGN
)) {
957 width
= infoPtr
->calcSize
.cx
+ 2*xedge
;
958 y
= 0; /* quiet compiler warning */
959 switch ( infoPtr
->dwStyle
& CCS_LAYOUT_MASK
) {
960 case 0: /* shouldn't happen - see NCCreate */
962 y
= ((infoPtr
->dwStyle
& CCS_NODIVIDER
) ? 0 : REBAR_DIVIDER
) - yedge
;
968 GetClientRect(GetParent(infoPtr
->hwndSelf
), &rcParent
);
969 translate_rect(infoPtr
, &rcParent
, &rcParent
);
970 y
= rcParent
.bottom
- infoPtr
->calcSize
.cy
- yedge
;
976 /* As on Windows if the CCS_NODIVIDER is not present the control will move
977 * 2 pixel down after every layout */
978 y
= rcSelf
.top
+ ((infoPtr
->dwStyle
& CCS_NODIVIDER
) ? 0 : REBAR_DIVIDER
);
979 width
= rcSelf
.right
- rcSelf
.left
;
982 TRACE("hwnd %p, style=%08x, setting at (%d,%d) for (%d,%d)\n",
983 infoPtr
->hwndSelf
, infoPtr
->dwStyle
, x
, y
, width
, height
);
985 /* Set flag to ignore next WM_SIZE message and resize the window */
986 infoPtr
->fStatus
|= SELF_RESIZE
;
987 if ((infoPtr
->dwStyle
& CCS_VERT
) == 0)
988 SetWindowPos(infoPtr
->hwndSelf
, 0, x
, y
, width
, height
, SWP_NOZORDER
);
990 SetWindowPos(infoPtr
->hwndSelf
, 0, y
, x
, height
, width
, SWP_NOZORDER
);
991 infoPtr
->fStatus
&= ~SELF_RESIZE
;
996 REBAR_MoveChildWindows (const REBAR_INFO
*infoPtr
, UINT start
, UINT endplus
)
998 static const WCHAR strComboBox
[] = { 'C','o','m','b','o','B','o','x',0 };
1000 WCHAR szClassName
[40];
1002 NMREBARCHILDSIZE rbcz
;
1005 if (!(deferpos
= BeginDeferWindowPos(infoPtr
->uNumBands
)))
1006 ERR("BeginDeferWindowPos returned NULL\n");
1008 for (i
= start
; i
< endplus
; i
++) {
1009 lpBand
= &infoPtr
->bands
[i
];
1011 if (HIDDENBAND(lpBand
)) continue;
1012 if (lpBand
->hwndChild
) {
1013 TRACE("hwndChild = %p\n", lpBand
->hwndChild
);
1015 /* Always generate the RBN_CHILDSIZE even if child
1018 rbcz
.wID
= lpBand
->wID
;
1019 rbcz
.rcChild
= lpBand
->rcChild
;
1020 translate_rect(infoPtr
, &rbcz
.rcBand
, &lpBand
->rcBand
);
1021 if (infoPtr
->dwStyle
& CCS_VERT
)
1022 rbcz
.rcBand
.top
+= lpBand
->cxHeader
;
1024 rbcz
.rcBand
.left
+= lpBand
->cxHeader
;
1025 REBAR_Notify ((NMHDR
*)&rbcz
, infoPtr
, RBN_CHILDSIZE
);
1026 if (!EqualRect (&lpBand
->rcChild
, &rbcz
.rcChild
)) {
1027 TRACE("Child rect changed by NOTIFY for band %u\n", i
);
1028 TRACE(" from (%s) to (%s)\n",
1029 wine_dbgstr_rect(&lpBand
->rcChild
),
1030 wine_dbgstr_rect(&rbcz
.rcChild
));
1031 lpBand
->rcChild
= rbcz
.rcChild
; /* *** ??? */
1034 /* native (IE4 in "Favorites" frame **1) does:
1035 * SetRect (&rc, -1, -1, -1, -1)
1036 * EqualRect (&rc,band->rc???)
1038 * CopyRect (band->rc????, &rc)
1039 * set flag outside of loop
1042 GetClassNameW (lpBand
->hwndChild
, szClassName
, sizeof(szClassName
)/sizeof(szClassName
[0]));
1043 if (!lstrcmpW (szClassName
, strComboBox
) ||
1044 !lstrcmpW (szClassName
, WC_COMBOBOXEXW
)) {
1045 INT nEditHeight
, yPos
;
1048 /* special placement code for combo or comboex box */
1051 /* get size of edit line */
1052 GetWindowRect (lpBand
->hwndChild
, &rc
);
1053 nEditHeight
= rc
.bottom
- rc
.top
;
1054 yPos
= (lpBand
->rcChild
.bottom
+ lpBand
->rcChild
.top
- nEditHeight
)/2;
1056 /* center combo box inside child area */
1057 TRACE("moving child (Combo(Ex)) %p to (%d,%d) for (%d,%d)\n",
1059 lpBand
->rcChild
.left
, yPos
,
1060 lpBand
->rcChild
.right
- lpBand
->rcChild
.left
,
1062 deferpos
= DeferWindowPos (deferpos
, lpBand
->hwndChild
, HWND_TOP
,
1063 lpBand
->rcChild
.left
,
1064 /*lpBand->rcChild.top*/ yPos
,
1065 lpBand
->rcChild
.right
- lpBand
->rcChild
.left
,
1069 ERR("DeferWindowPos returned NULL\n");
1072 TRACE("moving child (Other) %p to (%d,%d) for (%d,%d)\n",
1074 lpBand
->rcChild
.left
, lpBand
->rcChild
.top
,
1075 lpBand
->rcChild
.right
- lpBand
->rcChild
.left
,
1076 lpBand
->rcChild
.bottom
- lpBand
->rcChild
.top
);
1077 deferpos
= DeferWindowPos (deferpos
, lpBand
->hwndChild
, HWND_TOP
,
1078 lpBand
->rcChild
.left
,
1079 lpBand
->rcChild
.top
,
1080 lpBand
->rcChild
.right
- lpBand
->rcChild
.left
,
1081 lpBand
->rcChild
.bottom
- lpBand
->rcChild
.top
,
1084 ERR("DeferWindowPos returned NULL\n");
1088 if (!EndDeferWindowPos(deferpos
))
1089 ERR("EndDeferWindowPos returned NULL\n");
1091 if (infoPtr
->DoRedraw
)
1092 UpdateWindow (infoPtr
->hwndSelf
);
1094 /* native (from **1 above) does:
1095 * UpdateWindow(rebar)
1097 * RBN_HEIGHTCHANGE if necessary
1098 * if ret from any EqualRect was 0
1099 * Goto "BeginDeferWindowPos"
1104 /* Returns the next visible band (the first visible band in [i+1; infoPtr->uNumBands) )
1105 * or infoPtr->uNumBands if none */
1106 static int next_visible(const REBAR_INFO
*infoPtr
, int i
)
1109 for (n
= i
+ 1; n
< infoPtr
->uNumBands
; n
++)
1110 if (!HIDDENBAND(&infoPtr
->bands
[n
]))
1115 /* Returns the previous visible band (the last visible band in [0; i) )
1117 static int prev_visible(const REBAR_INFO
*infoPtr
, int i
)
1120 for (n
= i
- 1; n
>= 0; n
--)
1121 if (!HIDDENBAND(&infoPtr
->bands
[n
]))
1126 /* Returns the first visible band or infoPtr->uNumBands if none */
1127 static int first_visible(const REBAR_INFO
*infoPtr
)
1129 return next_visible(infoPtr
, -1); /* this works*/
1132 /* Returns the first visible band for the given row (or iBand if none) */
1133 static int get_row_begin_for_band(const REBAR_INFO
*infoPtr
, INT iBand
)
1135 int iLastBand
= iBand
;
1136 int iRow
= infoPtr
->bands
[iBand
].iRow
;
1137 while ((iBand
= prev_visible(infoPtr
, iBand
)) >= 0) {
1138 if (infoPtr
->bands
[iBand
].iRow
!= iRow
)
1146 /* Returns the first visible band for the next row (or infoPtr->uNumBands if none) */
1147 static int get_row_end_for_band(const REBAR_INFO
*infoPtr
, INT iBand
)
1149 int iRow
= infoPtr
->bands
[iBand
].iRow
;
1150 while ((iBand
= next_visible(infoPtr
, iBand
)) < infoPtr
->uNumBands
)
1151 if (infoPtr
->bands
[iBand
].iRow
!= iRow
)
1156 /* Compute the rcBand.{left,right} from the cxEffective bands widths computed earier.
1157 * iBeginBand must be visible */
1158 static void REBAR_SetRowRectsX(const REBAR_INFO
*infoPtr
, INT iBeginBand
, INT iEndBand
)
1161 for (i
= iBeginBand
; i
< iEndBand
; i
= next_visible(infoPtr
, i
))
1163 REBAR_BAND
*lpBand
= &infoPtr
->bands
[i
];
1165 lpBand
= &infoPtr
->bands
[i
];
1166 if (lpBand
->rcBand
.left
!= xPos
|| lpBand
->rcBand
.right
!= xPos
+ lpBand
->cxEffective
) {
1167 lpBand
->fDraw
|= NTF_INVALIDATE
;
1168 TRACE("Setting rect %d to %d,%d\n", i
, xPos
, xPos
+ lpBand
->cxEffective
);
1169 lpBand
->rcBand
.left
= xPos
;
1170 lpBand
->rcBand
.right
= xPos
+ lpBand
->cxEffective
;
1172 xPos
+= lpBand
->cxEffective
+ SEP_WIDTH
;
1176 /* The rationale of this function is probably as follows: if we have some space
1177 * to distribute we want to add it to a band on the right. However we don't want
1178 * to unminimize a minimized band so we search for a band that is big enough.
1179 * For some reason "big enough" is defined as bigger than the minimum size of the
1180 * first band in the row
1182 static REBAR_BAND
*REBAR_FindBandToGrow(const REBAR_INFO
*infoPtr
, INT iBeginBand
, INT iEndBand
)
1184 INT cxMinFirstBand
= 0, i
;
1186 cxMinFirstBand
= infoPtr
->bands
[iBeginBand
].cxMinBand
;
1188 for (i
= prev_visible(infoPtr
, iEndBand
); i
>= iBeginBand
; i
= prev_visible(infoPtr
, i
))
1189 if (infoPtr
->bands
[i
].cxEffective
> cxMinFirstBand
&& !(infoPtr
->bands
[i
].fStyle
&RBBS_FIXEDSIZE
))
1193 for (i
= prev_visible(infoPtr
, iEndBand
); i
>= iBeginBand
; i
= prev_visible(infoPtr
, i
))
1194 if (infoPtr
->bands
[i
].cxMinBand
== cxMinFirstBand
)
1197 TRACE("Extra space for row [%d..%d) should be added to band %d\n", iBeginBand
, iEndBand
, i
);
1198 return &infoPtr
->bands
[i
];
1201 /* Try to shrink the visible bands in [iBeginBand; iEndBand) by cxShrink, starting from the right */
1202 static int REBAR_ShrinkBandsRTL(const REBAR_INFO
*infoPtr
, INT iBeginBand
, INT iEndBand
, INT cxShrink
, BOOL bEnforce
)
1207 TRACE("Shrinking bands [%d..%d) by %d, right-to-left\n", iBeginBand
, iEndBand
, cxShrink
);
1208 for (i
= prev_visible(infoPtr
, iEndBand
); i
>= iBeginBand
; i
= prev_visible(infoPtr
, i
))
1210 lpBand
= &infoPtr
->bands
[i
];
1212 width
= max(lpBand
->cxEffective
- cxShrink
, (int)lpBand
->cxMinBand
);
1213 cxShrink
-= lpBand
->cxEffective
- width
;
1214 lpBand
->cxEffective
= width
;
1215 if (bEnforce
&& lpBand
->cx
> lpBand
->cxEffective
)
1216 lpBand
->cx
= lpBand
->cxEffective
;
1224 /* Try to shrink the visible bands in [iBeginBand; iEndBand) by cxShrink, starting from the left.
1225 * iBeginBand must be visible */
1226 static int REBAR_ShrinkBandsLTR(const REBAR_INFO
*infoPtr
, INT iBeginBand
, INT iEndBand
, INT cxShrink
, BOOL bEnforce
)
1231 TRACE("Shrinking bands [%d..%d) by %d, left-to-right\n", iBeginBand
, iEndBand
, cxShrink
);
1232 for (i
= iBeginBand
; i
< iEndBand
; i
= next_visible(infoPtr
, i
))
1234 lpBand
= &infoPtr
->bands
[i
];
1236 width
= max(lpBand
->cxEffective
- cxShrink
, (int)lpBand
->cxMinBand
);
1237 cxShrink
-= lpBand
->cxEffective
- width
;
1238 lpBand
->cxEffective
= width
;
1240 lpBand
->cx
= lpBand
->cxEffective
;
1247 /* Set the heights of the visible bands in [iBeginBand; iEndBand) to the max height. iBeginBand must be visible */
1248 static int REBAR_SetBandsHeight(const REBAR_INFO
*infoPtr
, INT iBeginBand
, INT iEndBand
, INT yStart
)
1253 int row
= infoPtr
->bands
[iBeginBand
].iRow
;
1255 for (i
= iBeginBand
; i
< iEndBand
; i
= next_visible(infoPtr
, i
))
1257 lpBand
= &infoPtr
->bands
[i
];
1258 lpBand
->cyRowSoFar
= yMaxHeight
;
1259 yMaxHeight
= max(yMaxHeight
, lpBand
->cyMinBand
);
1261 TRACE("Bands [%d; %d) height: %d\n", iBeginBand
, iEndBand
, yMaxHeight
);
1263 for (i
= iBeginBand
; i
< iEndBand
; i
= next_visible(infoPtr
, i
))
1265 lpBand
= &infoPtr
->bands
[i
];
1266 /* we may be called for multiple rows if RBS_VARHEIGHT not set */
1267 if (lpBand
->iRow
!= row
) {
1268 yPos
+= yMaxHeight
+ SEP_WIDTH
;
1272 if (lpBand
->rcBand
.top
!= yPos
|| lpBand
->rcBand
.bottom
!= yPos
+ yMaxHeight
) {
1273 lpBand
->fDraw
|= NTF_INVALIDATE
;
1274 lpBand
->rcBand
.top
= yPos
;
1275 lpBand
->rcBand
.bottom
= yPos
+ yMaxHeight
;
1276 TRACE("Band %d: %s\n", i
, wine_dbgstr_rect(&lpBand
->rcBand
));
1279 return yPos
+ yMaxHeight
;
1282 /* Layout the row [iBeginBand; iEndBand). iBeginBand must be visible */
1283 static void REBAR_LayoutRow(const REBAR_INFO
*infoPtr
, int iBeginBand
, int iEndBand
, int cx
, int *piRow
, int *pyPos
)
1289 TRACE("Adjusting row [%d;%d). Width: %d\n", iBeginBand
, iEndBand
, cx
);
1290 for (i
= iBeginBand
; i
< iEndBand
; i
++)
1291 infoPtr
->bands
[i
].iRow
= *piRow
;
1293 /* compute the extra space */
1294 for (i
= iBeginBand
; i
< iEndBand
; i
= next_visible(infoPtr
, i
))
1296 lpBand
= &infoPtr
->bands
[i
];
1299 lpBand
->cxEffective
= max(lpBand
->cxMinBand
, lpBand
->cx
);
1300 width
+= lpBand
->cxEffective
;
1304 TRACE("Extra space: %d\n", extra
);
1306 int ret
= REBAR_ShrinkBandsRTL(infoPtr
, iBeginBand
, iEndBand
, -extra
, FALSE
);
1307 if (ret
> 0 && next_visible(infoPtr
, iBeginBand
) != iEndBand
) /* one band may be longer than expected... */
1308 ERR("Error layouting row %d - couldn't shrink for %d pixels (%d total shrink)\n", *piRow
, ret
, -extra
);
1311 lpBand
= REBAR_FindBandToGrow(infoPtr
, iBeginBand
, iEndBand
);
1312 lpBand
->cxEffective
+= extra
;
1315 REBAR_SetRowRectsX(infoPtr
, iBeginBand
, iEndBand
);
1316 if (infoPtr
->dwStyle
& RBS_VARHEIGHT
)
1319 *pyPos
+= SEP_WIDTH
;
1320 *pyPos
= REBAR_SetBandsHeight(infoPtr
, iBeginBand
, iEndBand
, *pyPos
);
1326 REBAR_Layout(REBAR_INFO
*infoPtr
)
1336 if (infoPtr
->dwStyle
& (CCS_NORESIZE
| CCS_NOPARENTALIGN
) || GetParent(infoPtr
->hwndSelf
) == NULL
)
1337 GetClientRect(infoPtr
->hwndSelf
, &rcAdj
);
1339 GetClientRect(GetParent(infoPtr
->hwndSelf
), &rcAdj
);
1340 TRACE("adjustment rect is (%s)\n", wine_dbgstr_rect(&rcAdj
));
1342 adjcx
= get_rect_cx(infoPtr
, &rcAdj
);
1344 if (infoPtr
->uNumBands
== 0) {
1345 TRACE("No bands - setting size to (0,%d), vert: %lx\n", adjcx
, infoPtr
->dwStyle
& CCS_VERT
);
1346 infoPtr
->calcSize
.cx
= adjcx
;
1347 /* the calcSize.cy won't change for a 0 band rebar */
1348 infoPtr
->uNumRows
= 0;
1349 REBAR_ForceResize(infoPtr
);
1355 rowstart
= first_visible(infoPtr
);
1357 for (i
= rowstart
; i
< infoPtr
->uNumBands
; i
= next_visible(infoPtr
, i
))
1359 lpBand
= &infoPtr
->bands
[i
];
1361 if (i
> rowstart
&& (lpBand
->fStyle
& RBBS_BREAK
|| xMin
+ lpBand
->cxMinBand
> adjcx
)) {
1362 TRACE("%s break on band %d\n", (lpBand
->fStyle
& RBBS_BREAK
? "Hard" : "Soft"), i
- 1);
1363 REBAR_LayoutRow(infoPtr
, rowstart
, i
, adjcx
, &row
, &yPos
);
1370 xMin
+= lpBand
->cxMinBand
;
1372 REBAR_LayoutRow(infoPtr
, rowstart
, infoPtr
->uNumBands
, adjcx
, &row
, &yPos
);
1374 if (!(infoPtr
->dwStyle
& RBS_VARHEIGHT
))
1375 yPos
= REBAR_SetBandsHeight(infoPtr
, first_visible(infoPtr
), infoPtr
->uNumBands
, 0);
1377 infoPtr
->uNumRows
= row
;
1379 if (infoPtr
->dwStyle
& CCS_VERT
)
1380 REBAR_CalcVertBand(infoPtr
, 0, infoPtr
->uNumBands
);
1382 REBAR_CalcHorzBand(infoPtr
, 0, infoPtr
->uNumBands
);
1383 /* now compute size of Rebar itself */
1384 oldSize
= infoPtr
->calcSize
;
1386 infoPtr
->calcSize
.cx
= adjcx
;
1387 infoPtr
->calcSize
.cy
= yPos
;
1388 TRACE("calcsize size=(%d, %d), origheight=(%d,%d)\n",
1389 infoPtr
->calcSize
.cx
, infoPtr
->calcSize
.cy
,
1390 oldSize
.cx
, oldSize
.cy
);
1392 REBAR_DumpBand (infoPtr
);
1393 REBAR_MoveChildWindows (infoPtr
, 0, infoPtr
->uNumBands
);
1394 REBAR_ForceResize (infoPtr
);
1396 /* note: after a RBN_HEIGHTCHANGE native sends once again all the RBN_CHILDSIZE
1397 * and does another ForceResize */
1398 if (oldSize
.cy
!= infoPtr
->calcSize
.cy
)
1401 REBAR_Notify(&heightchange
, infoPtr
, RBN_HEIGHTCHANGE
);
1402 REBAR_AutoSize(infoPtr
, FALSE
);
1406 /* iBeginBand must be visible */
1408 REBAR_SizeChildrenToHeight(const REBAR_INFO
*infoPtr
, int iBeginBand
, int iEndBand
, int extra
, BOOL
*fChanged
)
1414 TRACE("[%d;%d) by %d\n", iBeginBand
, iEndBand
, extra
);
1416 cyBandsOld
= infoPtr
->bands
[iBeginBand
].rcBand
.bottom
- infoPtr
->bands
[iBeginBand
].rcBand
.top
;
1417 for (i
= iBeginBand
; i
< iEndBand
; i
= next_visible(infoPtr
, i
))
1419 REBAR_BAND
*lpBand
= &infoPtr
->bands
[i
];
1420 int cyMaxChild
= cyBandsOld
- REBARSPACE(lpBand
) + extra
;
1421 int cyChild
= round_child_height(lpBand
, cyMaxChild
);
1423 if (lpBand
->hwndChild
&& cyChild
!= lpBand
->cyChild
&& (lpBand
->fStyle
& RBBS_VARIABLEHEIGHT
))
1425 TRACE("Resizing %d: %d -> %d [%d]\n", i
, lpBand
->cyChild
, cyChild
, lpBand
->cyMaxChild
);
1427 lpBand
->cyChild
= cyChild
;
1428 lpBand
->fDraw
|= NTF_INVALIDATE
;
1429 update_min_band_height(infoPtr
, lpBand
);
1431 cyBandsNew
= max(cyBandsNew
, lpBand
->cyMinBand
);
1433 return cyBandsNew
- cyBandsOld
;
1436 /* worker function for RB_SIZETORECT and RBS_AUTOSIZE */
1438 REBAR_SizeToHeight(REBAR_INFO
*infoPtr
, int height
)
1440 int extra
= height
- infoPtr
->calcSize
.cy
; /* may be negative */
1441 BOOL fChanged
= FALSE
;
1442 UINT uNumRows
= infoPtr
->uNumRows
;
1445 /* That's not exactly what Windows does but should be similar */
1447 /* Pass one: break-up/glue rows */
1450 for (i
= prev_visible(infoPtr
, infoPtr
->uNumBands
); i
> 0; i
= prev_visible(infoPtr
, i
))
1452 REBAR_BAND
*lpBand
= &infoPtr
->bands
[i
];
1453 int height
= lpBand
->rcBand
.bottom
- lpBand
->rcBand
.top
;
1454 int cyBreakExtra
; /* additional cy for the rebar after a RBBS_BREAK on this band */
1456 if (infoPtr
->dwStyle
& RBS_VARHEIGHT
)
1457 cyBreakExtra
= lpBand
->cyRowSoFar
; /* 'height' => 'lpBand->cyRowSoFar' + 'height'*/
1459 cyBreakExtra
= height
; /* 'height' => 'height' + 'height'*/
1460 cyBreakExtra
+= SEP_WIDTH
;
1462 if (extra
<= cyBreakExtra
/ 2)
1465 if (!(lpBand
->fStyle
& RBBS_BREAK
))
1467 TRACE("Adding break on band %d - extra %d -> %d\n", i
, extra
, extra
- cyBreakExtra
);
1468 lpBand
->fStyle
|= RBBS_BREAK
;
1469 lpBand
->fDraw
|= NTF_INVALIDATE
;
1471 extra
-= cyBreakExtra
;
1473 /* temporary change for _SizeControlsToHeight. The true values will be computed in _Layout */
1474 if (infoPtr
->dwStyle
& RBS_VARHEIGHT
)
1475 lpBand
->rcBand
.bottom
= lpBand
->rcBand
.top
+ lpBand
->cyMinBand
;
1479 /* TODO: else if (extra < 0) { try to remove some RBBS_BREAKs } */
1481 /* Pass two: increase/decrease control height */
1482 if (infoPtr
->dwStyle
& RBS_VARHEIGHT
)
1484 int i
= first_visible(infoPtr
);
1486 while (i
< infoPtr
->uNumBands
)
1488 REBAR_BAND
*lpBand
= &infoPtr
->bands
[i
];
1489 int extraForRow
= extra
/ (int)(uNumRows
- iRow
);
1492 /* we can't use get_row_end_for_band as we might have added RBBS_BREAK in the first phase */
1493 for (rowEnd
= next_visible(infoPtr
, i
); rowEnd
< infoPtr
->uNumBands
; rowEnd
= next_visible(infoPtr
, rowEnd
))
1494 if (infoPtr
->bands
[rowEnd
].iRow
!= lpBand
->iRow
|| (infoPtr
->bands
[rowEnd
].fStyle
& RBBS_BREAK
))
1497 extra
-= REBAR_SizeChildrenToHeight(infoPtr
, i
, rowEnd
, extraForRow
, &fChanged
);
1498 TRACE("extra = %d\n", extra
);
1504 extra
-= REBAR_SizeChildrenToHeight(infoPtr
, first_visible(infoPtr
), infoPtr
->uNumBands
, extra
/ infoPtr
->uNumRows
, &fChanged
);
1507 REBAR_Layout(infoPtr
);
1511 REBAR_AutoSize(REBAR_INFO
*infoPtr
, BOOL needsLayout
)
1514 NMRBAUTOSIZE autosize
;
1516 GetClientRect(infoPtr
->hwndSelf
, &rc
);
1518 REBAR_Layout(infoPtr
);
1519 REBAR_SizeToHeight(infoPtr
, get_rect_cy(infoPtr
, &rc
));
1520 GetClientRect(infoPtr
->hwndSelf
, &rcNew
);
1522 GetClientRect(infoPtr
->hwndSelf
, &autosize
.rcTarget
);
1523 autosize
.fChanged
= (memcmp(&rc
, &rcNew
, sizeof(RECT
)) == 0);
1524 autosize
.rcTarget
= rc
;
1525 autosize
.rcActual
= rcNew
;
1526 REBAR_Notify((NMHDR
*)&autosize
, infoPtr
, RBN_AUTOSIZE
);
1530 REBAR_ValidateBand (const REBAR_INFO
*infoPtr
, REBAR_BAND
*lpBand
)
1531 /* Function: This routine evaluates the band specs supplied */
1532 /* by the user and updates the following 5 fields in */
1533 /* the internal band structure: cxHeader, cyHeader, cxMinBand, cyMinBand, fStatus */
1536 UINT textheight
=0, imageheight
= 0;
1540 lpBand
->fStatus
= 0;
1541 lpBand
->cxMinBand
= 0;
1542 lpBand
->cyMinBand
= 0;
1544 /* Data coming in from users into the cx... and cy... fields */
1545 /* may be bad, just garbage, because the user never clears */
1546 /* the fields. RB_{SET|INSERT}BAND{A|W} just passes the data */
1547 /* along if the fields exist in the input area. Here we must */
1548 /* determine if the data is valid. I have no idea how MS does */
1549 /* the validation, but it does because the RB_GETBANDINFO */
1550 /* returns a 0 when I know the sample program passed in an */
1551 /* address. Here I will use the algorithm that if the value */
1552 /* is greater than 65535 then it is bad and replace it with */
1553 /* a zero. Feel free to improve the algorithm. - GA 12/2000 */
1554 if (lpBand
->cxMinChild
> 65535) lpBand
->cxMinChild
= 0;
1555 if (lpBand
->cyMinChild
> 65535) lpBand
->cyMinChild
= 0;
1556 if (lpBand
->cx
> 65535) lpBand
->cx
= 0;
1557 if (lpBand
->cyChild
> 65535) lpBand
->cyChild
= 0;
1558 if (lpBand
->cyIntegral
> 65535) lpBand
->cyIntegral
= 0;
1559 if (lpBand
->cxIdeal
> 65535) lpBand
->cxIdeal
= 0;
1560 if (lpBand
->cxHeader
> 65535) lpBand
->cxHeader
= 0;
1562 /* TODO : we could try return to the caller if a value changed so that */
1563 /* a REBAR_Layout is needed. Till now the caller should call it */
1564 /* it always (we should also check what native does) */
1566 /* Header is where the image, text and gripper exist */
1567 /* in the band and precede the child window. */
1569 /* count number of non-FIXEDSIZE and non-Hidden bands */
1571 for (i
=0; i
<infoPtr
->uNumBands
; i
++){
1572 tBand
= &infoPtr
->bands
[i
];
1573 if (!HIDDENBAND(tBand
) && !(tBand
->fStyle
& RBBS_FIXEDSIZE
))
1577 /* calculate gripper rectangle */
1578 if ( (!(lpBand
->fStyle
& RBBS_NOGRIPPER
)) &&
1579 ( (lpBand
->fStyle
& RBBS_GRIPPERALWAYS
) ||
1580 ( !(lpBand
->fStyle
& RBBS_FIXEDSIZE
) && (nonfixed
> 1)))
1582 lpBand
->fStatus
|= HAS_GRIPPER
;
1583 if (infoPtr
->dwStyle
& CCS_VERT
)
1584 if (infoPtr
->dwStyle
& RBS_VERTICALGRIPPER
)
1585 header
+= (GRIPPER_HEIGHT
+ REBAR_PRE_GRIPPER
);
1587 header
+= (GRIPPER_WIDTH
+ REBAR_PRE_GRIPPER
);
1589 header
+= (REBAR_PRE_GRIPPER
+ GRIPPER_WIDTH
);
1590 /* Always have 4 pixels before anything else */
1591 header
+= REBAR_ALWAYS_SPACE
;
1594 /* image is visible */
1595 if (lpBand
->iImage
!= -1 && (infoPtr
->himl
)) {
1596 lpBand
->fStatus
|= HAS_IMAGE
;
1597 if (infoPtr
->dwStyle
& CCS_VERT
) {
1598 header
+= (infoPtr
->imageSize
.cy
+ REBAR_POST_IMAGE
);
1599 imageheight
= infoPtr
->imageSize
.cx
+ 4;
1602 header
+= (infoPtr
->imageSize
.cx
+ REBAR_POST_IMAGE
);
1603 imageheight
= infoPtr
->imageSize
.cy
+ 4;
1607 /* text is visible */
1608 if ((lpBand
->fMask
& RBBIM_TEXT
) && (lpBand
->lpText
) &&
1609 !(lpBand
->fStyle
& RBBS_HIDETITLE
)) {
1610 HDC hdc
= GetDC (0);
1611 HFONT hOldFont
= SelectObject (hdc
, infoPtr
->hFont
);
1614 lpBand
->fStatus
|= HAS_TEXT
;
1615 GetTextExtentPoint32W (hdc
, lpBand
->lpText
,
1616 lstrlenW (lpBand
->lpText
), &size
);
1617 header
+= ((infoPtr
->dwStyle
& CCS_VERT
) ? (size
.cy
+ REBAR_POST_TEXT
) : (size
.cx
+ REBAR_POST_TEXT
));
1618 textheight
= (infoPtr
->dwStyle
& CCS_VERT
) ? 0 : size
.cy
;
1620 SelectObject (hdc
, hOldFont
);
1624 /* if no gripper but either image or text, then leave space */
1625 if ((lpBand
->fStatus
& (HAS_IMAGE
| HAS_TEXT
)) &&
1626 !(lpBand
->fStatus
& HAS_GRIPPER
)) {
1627 header
+= REBAR_ALWAYS_SPACE
;
1630 /* check if user overrode the header value */
1631 if (!(lpBand
->fStyle
& RBBS_UNDOC_FIXEDHEADER
))
1632 lpBand
->cxHeader
= header
;
1633 lpBand
->cyHeader
= max(textheight
, imageheight
);
1635 /* Now compute minimum size of child window */
1636 update_min_band_height(infoPtr
, lpBand
); /* update lpBand->cyMinBand from cyHeader and cyChild*/
1638 lpBand
->cxMinBand
= lpBand
->cxMinChild
+ lpBand
->cxHeader
+ REBAR_POST_CHILD
;
1639 if (lpBand
->fStyle
& RBBS_USECHEVRON
&& lpBand
->cxMinChild
< lpBand
->cxIdeal
)
1640 lpBand
->cxMinBand
+= CHEVRON_WIDTH
;
1644 REBAR_CommonSetupBand(HWND hwnd
, const REBARBANDINFOW
*lprbbi
, REBAR_BAND
*lpBand
)
1645 /* Function: This routine copies the supplied values from */
1646 /* user input (lprbbi) to the internal band structure. */
1647 /* It returns true if something changed and false if not. */
1649 BOOL bChanged
= FALSE
;
1651 lpBand
->fMask
|= lprbbi
->fMask
;
1653 if( (lprbbi
->fMask
& RBBIM_STYLE
) &&
1654 (lpBand
->fStyle
!= lprbbi
->fStyle
) )
1656 lpBand
->fStyle
= lprbbi
->fStyle
;
1660 if( (lprbbi
->fMask
& RBBIM_COLORS
) &&
1661 ( ( lpBand
->clrFore
!= lprbbi
->clrFore
) ||
1662 ( lpBand
->clrBack
!= lprbbi
->clrBack
) ) )
1664 lpBand
->clrFore
= lprbbi
->clrFore
;
1665 lpBand
->clrBack
= lprbbi
->clrBack
;
1669 if( (lprbbi
->fMask
& RBBIM_IMAGE
) &&
1670 ( lpBand
->iImage
!= lprbbi
->iImage
) )
1672 lpBand
->iImage
= lprbbi
->iImage
;
1676 if( (lprbbi
->fMask
& RBBIM_CHILD
) &&
1677 (lprbbi
->hwndChild
!= lpBand
->hwndChild
) )
1679 if (lprbbi
->hwndChild
) {
1680 lpBand
->hwndChild
= lprbbi
->hwndChild
;
1681 lpBand
->hwndPrevParent
=
1682 SetParent (lpBand
->hwndChild
, hwnd
);
1683 /* below in trace from WinRAR */
1684 ShowWindow(lpBand
->hwndChild
, SW_SHOWNOACTIVATE
| SW_SHOWNORMAL
);
1685 /* above in trace from WinRAR */
1688 TRACE("child: %p prev parent: %p\n",
1689 lpBand
->hwndChild
, lpBand
->hwndPrevParent
);
1690 lpBand
->hwndChild
= 0;
1691 lpBand
->hwndPrevParent
= 0;
1696 if( (lprbbi
->fMask
& RBBIM_CHILDSIZE
) &&
1697 ( (lpBand
->cxMinChild
!= lprbbi
->cxMinChild
) ||
1698 (lpBand
->cyMinChild
!= lprbbi
->cyMinChild
) ||
1699 ( (lprbbi
->cbSize
>= sizeof (REBARBANDINFOA
)) &&
1700 ( (lpBand
->cyChild
!= lprbbi
->cyChild
) ||
1701 (lpBand
->cyMaxChild
!= lprbbi
->cyMaxChild
) ||
1702 (lpBand
->cyIntegral
!= lprbbi
->cyIntegral
) ) ) ||
1703 ( (lprbbi
->cbSize
< sizeof (REBARBANDINFOA
)) &&
1704 ( (lpBand
->cyChild
||
1705 lpBand
->cyMaxChild
||
1706 lpBand
->cyIntegral
) ) ) ) )
1708 lpBand
->cxMinChild
= lprbbi
->cxMinChild
;
1709 lpBand
->cyMinChild
= lprbbi
->cyMinChild
;
1710 /* These fields where added in WIN32_IE == 0x400 and are set only for RBBS_VARIABLEHEIGHT bands */
1711 if (lprbbi
->cbSize
>= sizeof (REBARBANDINFOA
) && (lpBand
->fStyle
& RBBS_VARIABLEHEIGHT
)) {
1712 lpBand
->cyMaxChild
= lprbbi
->cyMaxChild
;
1713 lpBand
->cyIntegral
= lprbbi
->cyIntegral
;
1715 lpBand
->cyChild
= round_child_height(lpBand
, lprbbi
->cyChild
); /* make (cyChild - cyMinChild) a multiple of cyIntergral */
1718 lpBand
->cyChild
= lpBand
->cyMinChild
;
1719 lpBand
->cyMaxChild
= 0x7fffffff;
1720 lpBand
->cyIntegral
= 0;
1725 if( (lprbbi
->fMask
& RBBIM_SIZE
) &&
1726 (lpBand
->cx
!= lprbbi
->cx
) )
1728 lpBand
->cx
= lprbbi
->cx
;
1732 if( (lprbbi
->fMask
& RBBIM_BACKGROUND
) &&
1733 ( lpBand
->hbmBack
!= lprbbi
->hbmBack
) )
1735 lpBand
->hbmBack
= lprbbi
->hbmBack
;
1739 if( (lprbbi
->fMask
& RBBIM_ID
) &&
1740 (lpBand
->wID
!= lprbbi
->wID
) )
1742 lpBand
->wID
= lprbbi
->wID
;
1746 /* check for additional data */
1747 if (lprbbi
->cbSize
>= sizeof (REBARBANDINFOA
)) {
1748 if( (lprbbi
->fMask
& RBBIM_IDEALSIZE
) &&
1749 ( lpBand
->cxIdeal
!= lprbbi
->cxIdeal
) )
1751 lpBand
->cxIdeal
= lprbbi
->cxIdeal
;
1755 if( (lprbbi
->fMask
& RBBIM_LPARAM
) &&
1756 (lpBand
->lParam
!= lprbbi
->lParam
) )
1758 lpBand
->lParam
= lprbbi
->lParam
;
1762 if( (lprbbi
->fMask
& RBBIM_HEADERSIZE
) &&
1763 (lpBand
->cxHeader
!= lprbbi
->cxHeader
) )
1765 lpBand
->cxHeader
= lprbbi
->cxHeader
;
1766 lpBand
->fStyle
|= RBBS_UNDOC_FIXEDHEADER
;
1775 REBAR_InternalEraseBkGnd (const REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
, const RECT
*clip
)
1776 /* Function: This erases the background rectangle by drawing */
1777 /* each band with its background color (or the default) and */
1778 /* draws each bands right separator if necessary. The row */
1779 /* separators are drawn on the first band of the next row. */
1784 HDC hdc
= (HDC
)wParam
;
1786 COLORREF old
= CLR_NONE
, new;
1787 HTHEME theme
= GetWindowTheme (infoPtr
->hwndSelf
);
1789 GetClientRect (infoPtr
->hwndSelf
, &cr
);
1792 for(i
=0; i
<infoPtr
->uNumBands
; i
++) {
1794 lpBand
= &infoPtr
->bands
[i
];
1795 if (HIDDENBAND(lpBand
)) continue;
1796 translate_rect(infoPtr
, &rcBand
, &lpBand
->rcBand
);
1798 /* draw band separator between rows */
1799 if (lpBand
->iRow
!= oldrow
) {
1800 oldrow
= lpBand
->iRow
;
1801 if (infoPtr
->dwStyle
& RBS_BANDBORDERS
) {
1804 if (infoPtr
->dwStyle
& CCS_VERT
) {
1805 rcRowSep
.right
+= SEP_WIDTH_SIZE
;
1806 rcRowSep
.bottom
= infoPtr
->calcSize
.cx
;
1808 DrawThemeEdge (theme
, hdc
, RP_BAND
, 0, &rcRowSep
, EDGE_ETCHED
, BF_RIGHT
, NULL
);
1810 DrawEdge (hdc
, &rcRowSep
, EDGE_ETCHED
, BF_RIGHT
);
1813 rcRowSep
.bottom
+= SEP_WIDTH_SIZE
;
1814 rcRowSep
.right
= infoPtr
->calcSize
.cx
;
1816 DrawThemeEdge (theme
, hdc
, RP_BAND
, 0, &rcRowSep
, EDGE_ETCHED
, BF_BOTTOM
, NULL
);
1818 DrawEdge (hdc
, &rcRowSep
, EDGE_ETCHED
, BF_BOTTOM
);
1820 TRACE ("drawing band separator bottom (%s)\n",
1821 wine_dbgstr_rect(&rcRowSep
));
1825 /* draw band separator between bands in a row */
1826 if (infoPtr
->dwStyle
& RBS_BANDBORDERS
&& lpBand
->rcBand
.left
> 0) {
1829 if (infoPtr
->dwStyle
& CCS_VERT
) {
1830 rcSep
.bottom
= rcSep
.top
;
1831 rcSep
.top
-= SEP_WIDTH_SIZE
;
1833 DrawThemeEdge (theme
, hdc
, RP_BAND
, 0, &rcSep
, EDGE_ETCHED
, BF_BOTTOM
, NULL
);
1835 DrawEdge (hdc
, &rcSep
, EDGE_ETCHED
, BF_BOTTOM
);
1838 rcSep
.right
= rcSep
.left
;
1839 rcSep
.left
-= SEP_WIDTH_SIZE
;
1841 DrawThemeEdge (theme
, hdc
, RP_BAND
, 0, &rcSep
, EDGE_ETCHED
, BF_RIGHT
, NULL
);
1843 DrawEdge (hdc
, &rcSep
, EDGE_ETCHED
, BF_RIGHT
);
1845 TRACE("drawing band separator right (%s)\n",
1846 wine_dbgstr_rect(&rcSep
));
1849 /* draw the actual background */
1850 if (lpBand
->clrBack
!= CLR_NONE
) {
1851 new = (lpBand
->clrBack
== CLR_DEFAULT
) ? infoPtr
->clrBtnFace
:
1854 /* testing only - make background green to see it */
1859 /* In the absence of documentation for Rebar vs. CLR_NONE,
1860 * we will use the default BtnFace color. Note documentation
1861 * exists for Listview and Imagelist.
1863 new = infoPtr
->clrBtnFace
;
1865 /* testing only - make background green to see it */
1872 /* When themed, the background color is ignored (but not a
1873 * background bitmap */
1874 DrawThemeBackground (theme
, hdc
, 0, 0, &cr
, &rcBand
);
1878 old
= SetBkColor (hdc
, new);
1879 TRACE("%s background color=0x%06x, band (%d,%d)-(%d,%d), clip (%d,%d)-(%d,%d)\n",
1880 (lpBand
->clrBack
== CLR_NONE
) ? "none" :
1881 ((lpBand
->clrBack
== CLR_DEFAULT
) ? "dft" : ""),
1883 rcBand
.left
,rcBand
.top
,
1884 rcBand
.right
,rcBand
.bottom
,
1885 clip
->left
, clip
->top
,
1886 clip
->right
, clip
->bottom
);
1887 ExtTextOutW (hdc
, 0, 0, ETO_OPAQUE
, &rcBand
, NULL
, 0, 0);
1888 if (lpBand
->clrBack
!= CLR_NONE
)
1889 SetBkColor (hdc
, old
);
1896 REBAR_InternalHitTest (const REBAR_INFO
*infoPtr
, const POINT
*lpPt
, UINT
*pFlags
, INT
*pBand
)
1902 GetClientRect (infoPtr
->hwndSelf
, &rect
);
1904 *pFlags
= RBHT_NOWHERE
;
1905 if (PtInRect (&rect
, *lpPt
))
1907 if (infoPtr
->uNumBands
== 0) {
1908 *pFlags
= RBHT_NOWHERE
;
1915 /* somewhere inside */
1916 for (iCount
= 0; iCount
< infoPtr
->uNumBands
; iCount
++) {
1918 lpBand
= &infoPtr
->bands
[iCount
];
1919 translate_rect(infoPtr
, &rcBand
, &lpBand
->rcBand
);
1920 if (HIDDENBAND(lpBand
)) continue;
1921 if (PtInRect (&rcBand
, *lpPt
)) {
1924 if (PtInRect (&lpBand
->rcGripper
, *lpPt
)) {
1925 *pFlags
= RBHT_GRABBER
;
1926 TRACE("ON GRABBER %d\n", iCount
);
1929 else if (PtInRect (&lpBand
->rcCapImage
, *lpPt
)) {
1930 *pFlags
= RBHT_CAPTION
;
1931 TRACE("ON CAPTION %d\n", iCount
);
1934 else if (PtInRect (&lpBand
->rcCapText
, *lpPt
)) {
1935 *pFlags
= RBHT_CAPTION
;
1936 TRACE("ON CAPTION %d\n", iCount
);
1939 else if (PtInRect (&lpBand
->rcChild
, *lpPt
)) {
1940 *pFlags
= RBHT_CLIENT
;
1941 TRACE("ON CLIENT %d\n", iCount
);
1944 else if (PtInRect (&lpBand
->rcChevron
, *lpPt
)) {
1945 *pFlags
= RBHT_CHEVRON
;
1946 TRACE("ON CHEVRON %d\n", iCount
);
1950 *pFlags
= RBHT_NOWHERE
;
1951 TRACE("NOWHERE %d\n", iCount
);
1957 *pFlags
= RBHT_NOWHERE
;
1966 *pFlags
= RBHT_NOWHERE
;
1975 REBAR_HandleLRDrag (REBAR_INFO
*infoPtr
, const POINT
*ptsmove
)
1976 /* Function: This will implement the functionality of a */
1977 /* Gripper drag within a row. It will not implement "out- */
1978 /* of-row" drags. (They are detected and handled in */
1979 /* REBAR_MouseMove.) */
1980 /* **** FIXME Switching order of bands in a row not **** */
1981 /* **** yet implemented. **** */
1983 REBAR_BAND
*hitBand
;
1984 INT iHitBand
, iRowBegin
, iRowEnd
;
1985 INT movement
, xBand
;
1987 /* on first significant mouse movement, issue notify */
1988 if (!(infoPtr
->fStatus
& BEGIN_DRAG_ISSUED
)) {
1989 if (REBAR_Notify_NMREBAR (infoPtr
, -1, RBN_BEGINDRAG
)) {
1990 /* Notify returned TRUE - abort drag */
1991 infoPtr
->dragStart
.x
= 0;
1992 infoPtr
->dragStart
.y
= 0;
1993 infoPtr
->dragNow
= infoPtr
->dragStart
;
1994 infoPtr
->iGrabbedBand
= -1;
1998 infoPtr
->fStatus
|= BEGIN_DRAG_ISSUED
;
2001 iHitBand
= infoPtr
->iGrabbedBand
;
2002 iRowBegin
= get_row_begin_for_band(infoPtr
, iHitBand
);
2003 iRowEnd
= get_row_end_for_band(infoPtr
, iHitBand
);
2004 hitBand
= &infoPtr
->bands
[iHitBand
];
2006 xBand
= hitBand
->rcBand
.left
;
2007 movement
= (infoPtr
->dwStyle
&CCS_VERT
? ptsmove
->y
: ptsmove
->x
)
2008 - (xBand
+ REBAR_PRE_GRIPPER
- infoPtr
->ihitoffset
);
2011 int cxLeft
= REBAR_ShrinkBandsRTL(infoPtr
, iRowBegin
, iHitBand
, -movement
, TRUE
);
2012 hitBand
->cxEffective
+= -movement
- cxLeft
;
2013 hitBand
->cx
= hitBand
->cxEffective
;
2014 } else if (movement
> 0) {
2015 int cxLeft
= REBAR_ShrinkBandsLTR(infoPtr
, iHitBand
, iRowEnd
, movement
, TRUE
);
2016 REBAR_BAND
*lpPrev
= &infoPtr
->bands
[prev_visible(infoPtr
, iHitBand
)];
2017 lpPrev
->cxEffective
+= movement
- cxLeft
;
2018 lpPrev
->cx
= lpPrev
->cxEffective
;
2021 REBAR_SetRowRectsX(infoPtr
, iRowBegin
, iRowEnd
);
2022 if (infoPtr
->dwStyle
& CCS_VERT
)
2023 REBAR_CalcVertBand(infoPtr
, 0, infoPtr
->uNumBands
);
2025 REBAR_CalcHorzBand(infoPtr
, 0, infoPtr
->uNumBands
);
2026 REBAR_MoveChildWindows(infoPtr
, iRowBegin
, iRowEnd
);
2031 /* << REBAR_BeginDrag >> */
2035 REBAR_DeleteBand (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
2037 UINT uBand
= (UINT
)wParam
;
2040 if (uBand
>= infoPtr
->uNumBands
)
2043 TRACE("deleting band %u!\n", uBand
);
2044 lpBand
= &infoPtr
->bands
[uBand
];
2045 REBAR_Notify_NMREBAR (infoPtr
, uBand
, RBN_DELETINGBAND
);
2046 /* TODO: a return of 1 should probably cancel the deletion */
2048 if (lpBand
->hwndChild
)
2049 ShowWindow(lpBand
->hwndChild
, SW_HIDE
);
2050 Free(lpBand
->lpText
);
2052 infoPtr
->uNumBands
--;
2053 memmove(&infoPtr
->bands
[uBand
], &infoPtr
->bands
[uBand
+1],
2054 (infoPtr
->uNumBands
- uBand
) * sizeof(REBAR_BAND
));
2055 infoPtr
->bands
= ReAlloc(infoPtr
->bands
, infoPtr
->uNumBands
* sizeof(REBAR_BAND
));
2057 REBAR_Notify_NMREBAR (infoPtr
, -1, RBN_DELETEDBAND
);
2059 /* if only 1 band left the re-validate to possible eliminate gripper */
2060 if (infoPtr
->uNumBands
== 1)
2061 REBAR_ValidateBand (infoPtr
, &infoPtr
->bands
[0]);
2063 REBAR_Layout(infoPtr
);
2069 /* << REBAR_DragMove >> */
2070 /* << REBAR_EndDrag >> */
2074 REBAR_GetBandBorders (const REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
2076 LPRECT lpRect
= (LPRECT
)lParam
;
2081 if ((UINT
)wParam
>= infoPtr
->uNumBands
)
2084 lpBand
= &infoPtr
->bands
[(UINT
)wParam
];
2086 /* FIXME - the following values were determined by experimentation */
2087 /* with the REBAR Control Spy. I have guesses as to what the 4 and */
2088 /* 1 are, but I am not sure. There doesn't seem to be any actual */
2089 /* difference in size of the control area with and without the */
2091 if (infoPtr
->dwStyle
& RBS_BANDBORDERS
) {
2092 if (infoPtr
->dwStyle
& CCS_VERT
) {
2094 lpRect
->top
= lpBand
->cxHeader
+ 4;
2099 lpRect
->left
= lpBand
->cxHeader
+ 4;
2106 lpRect
->left
= lpBand
->cxHeader
;
2112 static inline LRESULT
2113 REBAR_GetBandCount (const REBAR_INFO
*infoPtr
)
2115 TRACE("band count %u!\n", infoPtr
->uNumBands
);
2117 return infoPtr
->uNumBands
;
2122 REBAR_GetBandInfoT(const REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
, BOOL bUnicode
)
2124 LPREBARBANDINFOW lprbbi
= (LPREBARBANDINFOW
)lParam
;
2129 if (lprbbi
->cbSize
< REBARBANDINFOA_V3_SIZE
)
2131 if ((UINT
)wParam
>= infoPtr
->uNumBands
)
2134 TRACE("index %u (bUnicode=%d)\n", (UINT
)wParam
, bUnicode
);
2136 /* copy band information */
2137 lpBand
= &infoPtr
->bands
[(UINT
)wParam
];
2139 if (lprbbi
->fMask
& RBBIM_STYLE
)
2140 lprbbi
->fStyle
= lpBand
->fStyle
;
2142 if (lprbbi
->fMask
& RBBIM_COLORS
) {
2143 lprbbi
->clrFore
= lpBand
->clrFore
;
2144 lprbbi
->clrBack
= lpBand
->clrBack
;
2145 if (lprbbi
->clrBack
== CLR_DEFAULT
)
2146 lprbbi
->clrBack
= infoPtr
->clrBtnFace
;
2149 if (lprbbi
->fMask
& RBBIM_TEXT
) {
2151 Str_GetPtrW(lpBand
->lpText
, lprbbi
->lpText
, lprbbi
->cch
);
2153 Str_GetPtrWtoA(lpBand
->lpText
, (LPSTR
)lprbbi
->lpText
, lprbbi
->cch
);
2156 if (lprbbi
->fMask
& RBBIM_IMAGE
)
2157 lprbbi
->iImage
= lpBand
->iImage
;
2159 if (lprbbi
->fMask
& RBBIM_CHILD
)
2160 lprbbi
->hwndChild
= lpBand
->hwndChild
;
2162 if (lprbbi
->fMask
& RBBIM_CHILDSIZE
) {
2163 lprbbi
->cxMinChild
= lpBand
->cxMinChild
;
2164 lprbbi
->cyMinChild
= lpBand
->cyMinChild
;
2165 /* to make tests pass we follow Windows behaviour and allow to read these fields only
2166 * for RBBS_VARIABLEHEIGHTS bands */
2167 if (lprbbi
->cbSize
>= sizeof (REBARBANDINFOA
) && (lpBand
->fStyle
& RBBS_VARIABLEHEIGHT
)) {
2168 lprbbi
->cyChild
= lpBand
->cyChild
;
2169 lprbbi
->cyMaxChild
= lpBand
->cyMaxChild
;
2170 lprbbi
->cyIntegral
= lpBand
->cyIntegral
;
2174 if (lprbbi
->fMask
& RBBIM_SIZE
)
2175 lprbbi
->cx
= lpBand
->cx
;
2177 if (lprbbi
->fMask
& RBBIM_BACKGROUND
)
2178 lprbbi
->hbmBack
= lpBand
->hbmBack
;
2180 if (lprbbi
->fMask
& RBBIM_ID
)
2181 lprbbi
->wID
= lpBand
->wID
;
2183 /* check for additional data */
2184 if (lprbbi
->cbSize
>= sizeof (REBARBANDINFOA
)) {
2185 if (lprbbi
->fMask
& RBBIM_IDEALSIZE
)
2186 lprbbi
->cxIdeal
= lpBand
->cxIdeal
;
2188 if (lprbbi
->fMask
& RBBIM_LPARAM
)
2189 lprbbi
->lParam
= lpBand
->lParam
;
2191 if (lprbbi
->fMask
& RBBIM_HEADERSIZE
)
2192 lprbbi
->cxHeader
= lpBand
->cxHeader
;
2195 REBAR_DumpBandInfo(lprbbi
);
2202 REBAR_GetBarHeight (const REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
2206 nHeight
= infoPtr
->calcSize
.cy
;
2208 TRACE("height = %d\n", nHeight
);
2215 REBAR_GetBarInfo (const REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
2217 LPREBARINFO lpInfo
= (LPREBARINFO
)lParam
;
2222 if (lpInfo
->cbSize
< sizeof (REBARINFO
))
2225 TRACE("getting bar info!\n");
2227 if (infoPtr
->himl
) {
2228 lpInfo
->himl
= infoPtr
->himl
;
2229 lpInfo
->fMask
|= RBIM_IMAGELIST
;
2236 static inline LRESULT
2237 REBAR_GetBkColor (const REBAR_INFO
*infoPtr
)
2239 COLORREF clr
= infoPtr
->clrBk
;
2241 if (clr
== CLR_DEFAULT
)
2242 clr
= infoPtr
->clrBtnFace
;
2244 TRACE("background color 0x%06x!\n", clr
);
2250 /* << REBAR_GetColorScheme >> */
2251 /* << REBAR_GetDropTarget >> */
2255 REBAR_GetPalette (const REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
2257 FIXME("empty stub!\n");
2264 REBAR_GetRect (const REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
2266 INT iBand
= (INT
)wParam
;
2267 LPRECT lprc
= (LPRECT
)lParam
;
2270 if ((iBand
< 0) || ((UINT
)iBand
>= infoPtr
->uNumBands
))
2275 lpBand
= &infoPtr
->bands
[iBand
];
2276 /* For CCS_VERT the coordinates will be swapped - like on Windows */
2277 CopyRect (lprc
, &lpBand
->rcBand
);
2279 TRACE("band %d, (%s)\n", iBand
, wine_dbgstr_rect(lprc
));
2285 static inline LRESULT
2286 REBAR_GetRowCount (const REBAR_INFO
*infoPtr
)
2288 TRACE("%u\n", infoPtr
->uNumRows
);
2290 return infoPtr
->uNumRows
;
2295 REBAR_GetRowHeight (const REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
2297 INT iRow
= (INT
)wParam
;
2302 for (i
=0; i
<infoPtr
->uNumBands
; i
++) {
2303 lpBand
= &infoPtr
->bands
[i
];
2304 if (HIDDENBAND(lpBand
)) continue;
2305 if (lpBand
->iRow
!= iRow
) continue;
2306 j
= lpBand
->rcBand
.bottom
- lpBand
->rcBand
.top
;
2307 if (j
> ret
) ret
= j
;
2310 TRACE("row %d, height %d\n", iRow
, ret
);
2316 static inline LRESULT
2317 REBAR_GetTextColor (const REBAR_INFO
*infoPtr
)
2319 TRACE("text color 0x%06x!\n", infoPtr
->clrText
);
2321 return infoPtr
->clrText
;
2325 static inline LRESULT
2326 REBAR_GetToolTips (const REBAR_INFO
*infoPtr
)
2328 return (LRESULT
)infoPtr
->hwndToolTip
;
2332 static inline LRESULT
2333 REBAR_GetUnicodeFormat (const REBAR_INFO
*infoPtr
)
2335 TRACE("%s hwnd=%p\n",
2336 infoPtr
->bUnicode
? "TRUE" : "FALSE", infoPtr
->hwndSelf
);
2338 return infoPtr
->bUnicode
;
2342 static inline LRESULT
2343 REBAR_GetVersion (const REBAR_INFO
*infoPtr
)
2345 TRACE("version %d\n", infoPtr
->iVersion
);
2346 return infoPtr
->iVersion
;
2351 REBAR_HitTest (const REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
2353 LPRBHITTESTINFO lprbht
= (LPRBHITTESTINFO
)lParam
;
2358 REBAR_InternalHitTest (infoPtr
, &lprbht
->pt
, &lprbht
->flags
, &lprbht
->iBand
);
2360 return lprbht
->iBand
;
2365 REBAR_IdToIndex (const REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
2369 if (infoPtr
== NULL
)
2372 if (infoPtr
->uNumBands
< 1)
2375 for (i
= 0; i
< infoPtr
->uNumBands
; i
++) {
2376 if (infoPtr
->bands
[i
].wID
== (UINT
)wParam
) {
2377 TRACE("id %u is band %u found!\n", (UINT
)wParam
, i
);
2382 TRACE("id %u is not found\n", (UINT
)wParam
);
2388 REBAR_InsertBandT(REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
, BOOL bUnicode
)
2390 LPREBARBANDINFOW lprbbi
= (LPREBARBANDINFOW
)lParam
;
2391 UINT uIndex
= (UINT
)wParam
;
2394 if (infoPtr
== NULL
)
2398 if (lprbbi
->cbSize
< REBARBANDINFOA_V3_SIZE
)
2401 /* trace the index as signed to see the -1 */
2402 TRACE("insert band at %d (bUnicode=%d)!\n", (INT
)uIndex
, bUnicode
);
2403 REBAR_DumpBandInfo(lprbbi
);
2405 infoPtr
->bands
= ReAlloc(infoPtr
->bands
, (infoPtr
->uNumBands
+1) * sizeof(REBAR_BAND
));
2406 if (((INT
)uIndex
== -1) || (uIndex
> infoPtr
->uNumBands
))
2407 uIndex
= infoPtr
->uNumBands
;
2408 memmove(&infoPtr
->bands
[uIndex
+1], &infoPtr
->bands
[uIndex
],
2409 sizeof(REBAR_BAND
) * (infoPtr
->uNumBands
- uIndex
));
2410 infoPtr
->uNumBands
++;
2412 TRACE("index %u!\n", uIndex
);
2414 /* initialize band (infoPtr->bands[uIndex])*/
2415 lpBand
= &infoPtr
->bands
[uIndex
];
2416 ZeroMemory(lpBand
, sizeof(*lpBand
));
2417 lpBand
->clrFore
= infoPtr
->clrText
;
2418 lpBand
->clrBack
= infoPtr
->clrBk
;
2419 lpBand
->iImage
= -1;
2421 REBAR_CommonSetupBand(infoPtr
->hwndSelf
, lprbbi
, lpBand
);
2422 if ((lprbbi
->fMask
& RBBIM_TEXT
) && (lprbbi
->lpText
)) {
2424 Str_SetPtrW(&lpBand
->lpText
, lprbbi
->lpText
);
2426 Str_SetPtrAtoW(&lpBand
->lpText
, (LPSTR
)lprbbi
->lpText
);
2429 REBAR_ValidateBand (infoPtr
, lpBand
);
2430 /* On insert of second band, revalidate band 1 to possible add gripper */
2431 if (infoPtr
->uNumBands
== 2)
2432 REBAR_ValidateBand (infoPtr
, &infoPtr
->bands
[0]);
2434 REBAR_DumpBand (infoPtr
);
2436 REBAR_Layout(infoPtr
);
2437 InvalidateRect(infoPtr
->hwndSelf
, 0, TRUE
);
2444 REBAR_MaximizeBand (const REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
2447 UINT uBand
= (UINT
) wParam
;
2448 int iRowBegin
, iRowEnd
;
2449 int cxDesired
, extra
, extraOrig
;
2453 if ((infoPtr
->uNumBands
== 0) ||
2454 ((INT
)uBand
< 0) || (uBand
>= infoPtr
->uNumBands
)) {
2456 ERR("Illegal MaximizeBand, requested=%d, current band count=%d\n",
2457 (INT
)uBand
, infoPtr
->uNumBands
);
2461 lpBand
= &infoPtr
->bands
[uBand
];
2463 if (lpBand
->fStyle
& RBBS_HIDDEN
)
2465 /* Windows is buggy and creates a hole */
2466 WARN("Ignoring maximize request on a hidden band (%d)\n", uBand
);
2470 cxIdealBand
= lpBand
->cxIdeal
+ lpBand
->cxHeader
+ REBAR_POST_CHILD
;
2471 if (lParam
&& (lpBand
->cxEffective
< cxIdealBand
))
2472 cxDesired
= cxIdealBand
;
2474 cxDesired
= infoPtr
->calcSize
.cx
;
2476 iRowBegin
= get_row_begin_for_band(infoPtr
, uBand
);
2477 iRowEnd
= get_row_end_for_band(infoPtr
, uBand
);
2478 extraOrig
= extra
= cxDesired
- lpBand
->cxEffective
;
2480 extra
= REBAR_ShrinkBandsRTL(infoPtr
, iRowBegin
, uBand
, extra
, TRUE
);
2482 extra
= REBAR_ShrinkBandsLTR(infoPtr
, next_visible(infoPtr
, uBand
), iRowEnd
, extra
, TRUE
);
2483 lpBand
->cxEffective
+= extraOrig
- extra
;
2484 lpBand
->cx
= lpBand
->cxEffective
;
2485 TRACE("(%ld, %ld): Wanted size %d, obtained %d (shrink %d, %d)\n", wParam
, lParam
, cxDesired
, lpBand
->cx
, extraOrig
, extra
);
2486 REBAR_SetRowRectsX(infoPtr
, iRowBegin
, iRowEnd
);
2488 if (infoPtr
->dwStyle
& CCS_VERT
)
2489 REBAR_CalcVertBand(infoPtr
, iRowBegin
, iRowEnd
);
2491 REBAR_CalcHorzBand(infoPtr
, iRowBegin
, iRowEnd
);
2492 REBAR_MoveChildWindows(infoPtr
, iRowBegin
, iRowEnd
);
2499 REBAR_MinimizeBand (const REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
2502 UINT uBand
= (UINT
) wParam
;
2503 int iPrev
, iRowBegin
, iRowEnd
;
2505 /* A "minimize" band is equivalent to "dragging" the gripper
2506 * of than band to the right till the band is only the size
2511 if ((infoPtr
->uNumBands
== 0) ||
2512 ((INT
)uBand
< 0) || (uBand
>= infoPtr
->uNumBands
)) {
2514 ERR("Illegal MinimizeBand, requested=%d, current band count=%d\n",
2515 (INT
)uBand
, infoPtr
->uNumBands
);
2519 /* compute amount of movement and validate */
2520 lpBand
= &infoPtr
->bands
[uBand
];
2522 if (lpBand
->fStyle
& RBBS_HIDDEN
)
2524 /* Windows is buggy and creates a hole/overlap */
2525 WARN("Ignoring minimize request on a hidden band (%d)\n", uBand
);
2529 iPrev
= prev_visible(infoPtr
, uBand
);
2530 /* if first band in row */
2531 if (iPrev
< 0 || infoPtr
->bands
[iPrev
].iRow
!= lpBand
->iRow
) {
2532 int iNext
= next_visible(infoPtr
, uBand
);
2533 if (iNext
< infoPtr
->uNumBands
&& infoPtr
->bands
[iNext
].iRow
== lpBand
->iRow
) {
2534 TRACE("(%ld): Minimizing the first band in row is by maximizing the second\n", wParam
);
2535 REBAR_MaximizeBand(infoPtr
, iNext
, FALSE
);
2538 TRACE("(%ld): Only one band in row - nothing to do\n", wParam
);
2542 infoPtr
->bands
[iPrev
].cxEffective
+= lpBand
->cxEffective
- lpBand
->cxMinBand
;
2543 infoPtr
->bands
[iPrev
].cx
= infoPtr
->bands
[iPrev
].cxEffective
;
2544 lpBand
->cx
= lpBand
->cxEffective
= lpBand
->cxMinBand
;
2546 iRowBegin
= get_row_begin_for_band(infoPtr
, uBand
);
2547 iRowEnd
= get_row_end_for_band(infoPtr
, uBand
);
2548 REBAR_SetRowRectsX(infoPtr
, iRowBegin
, iRowEnd
);
2550 if (infoPtr
->dwStyle
& CCS_VERT
)
2551 REBAR_CalcVertBand(infoPtr
, iRowBegin
, iRowEnd
);
2553 REBAR_CalcHorzBand(infoPtr
, iRowBegin
, iRowEnd
);
2554 REBAR_MoveChildWindows(infoPtr
, iRowBegin
, iRowEnd
);
2560 REBAR_MoveBand (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
2562 REBAR_BAND
*oldBands
= infoPtr
->bands
;
2564 UINT uFrom
= (UINT
)wParam
;
2565 UINT uTo
= (UINT
)lParam
;
2568 if ((infoPtr
->uNumBands
== 0) ||
2569 ((INT
)uFrom
< 0) || (uFrom
>= infoPtr
->uNumBands
) ||
2570 ((INT
)uTo
< 0) || (uTo
>= infoPtr
->uNumBands
)) {
2572 ERR("Illegal MoveBand, from=%d, to=%d, current band count=%d\n",
2573 (INT
)uFrom
, (INT
)uTo
, infoPtr
->uNumBands
);
2577 /* save one to be moved */
2578 holder
= oldBands
[uFrom
];
2580 /* close up rest of bands (pseudo delete) */
2581 if (uFrom
< infoPtr
->uNumBands
- 1) {
2582 memcpy (&oldBands
[uFrom
], &oldBands
[uFrom
+1],
2583 (infoPtr
->uNumBands
- uFrom
- 1) * sizeof(REBAR_BAND
));
2586 /* allocate new space and copy rest of bands into it */
2588 (REBAR_BAND
*)Alloc ((infoPtr
->uNumBands
)*sizeof(REBAR_BAND
));
2590 /* pre insert copy */
2592 memcpy (&infoPtr
->bands
[0], &oldBands
[0],
2593 uTo
* sizeof(REBAR_BAND
));
2596 /* set moved band */
2597 infoPtr
->bands
[uTo
] = holder
;
2600 if (uTo
< infoPtr
->uNumBands
- 1) {
2601 memcpy (&infoPtr
->bands
[uTo
+1], &oldBands
[uTo
],
2602 (infoPtr
->uNumBands
- uTo
- 1) * sizeof(REBAR_BAND
));
2607 TRACE("moved band %d to index %d\n", uFrom
, uTo
);
2608 REBAR_DumpBand (infoPtr
);
2610 /* **************************************************** */
2612 /* We do not do a REBAR_Layout here because the native */
2613 /* control does not do that. The actual layout and */
2614 /* repaint is done by the *next* real action, ex.: */
2615 /* RB_INSERTBAND, RB_DELETEBAND, RB_SIZETORECT, etc. */
2617 /* **************************************************** */
2623 /* return TRUE if two strings are different */
2625 REBAR_strdifW( LPCWSTR a
, LPCWSTR b
)
2627 return ( (a
&& !b
) || (b
&& !a
) || (a
&& b
&& lstrcmpW(a
, b
) ) );
2631 REBAR_SetBandInfoT(REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
, BOOL bUnicode
)
2633 LPREBARBANDINFOW lprbbi
= (LPREBARBANDINFOW
)lParam
;
2639 if (lprbbi
->cbSize
< REBARBANDINFOA_V3_SIZE
)
2641 if ((UINT
)wParam
>= infoPtr
->uNumBands
)
2644 TRACE("index %u\n", (UINT
)wParam
);
2645 REBAR_DumpBandInfo (lprbbi
);
2647 /* set band information */
2648 lpBand
= &infoPtr
->bands
[(UINT
)wParam
];
2650 bChanged
= REBAR_CommonSetupBand (infoPtr
->hwndSelf
, lprbbi
, lpBand
);
2651 if (lprbbi
->fMask
& RBBIM_TEXT
) {
2654 Str_SetPtrW(&wstr
, lprbbi
->lpText
);
2656 Str_SetPtrAtoW(&wstr
, (LPSTR
)lprbbi
->lpText
);
2658 if (REBAR_strdifW(wstr
, lpBand
->lpText
)) {
2659 Free(lpBand
->lpText
);
2660 lpBand
->lpText
= wstr
;
2667 REBAR_ValidateBand (infoPtr
, lpBand
);
2669 REBAR_DumpBand (infoPtr
);
2671 if (bChanged
&& (lprbbi
->fMask
& (RBBIM_CHILDSIZE
| RBBIM_SIZE
| RBBIM_STYLE
| RBBIM_IMAGE
))) {
2672 REBAR_Layout(infoPtr
);
2673 InvalidateRect(infoPtr
->hwndSelf
, 0, 1);
2681 REBAR_SetBarInfo (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
2683 LPREBARINFO lpInfo
= (LPREBARINFO
)lParam
;
2690 if (lpInfo
->cbSize
< sizeof (REBARINFO
))
2693 TRACE("setting bar info!\n");
2695 if (lpInfo
->fMask
& RBIM_IMAGELIST
) {
2696 infoPtr
->himl
= lpInfo
->himl
;
2697 if (infoPtr
->himl
) {
2699 ImageList_GetIconSize (infoPtr
->himl
, &cx
, &cy
);
2700 infoPtr
->imageSize
.cx
= cx
;
2701 infoPtr
->imageSize
.cy
= cy
;
2704 infoPtr
->imageSize
.cx
= 0;
2705 infoPtr
->imageSize
.cy
= 0;
2707 TRACE("new image cx=%d, cy=%d\n", infoPtr
->imageSize
.cx
,
2708 infoPtr
->imageSize
.cy
);
2711 /* revalidate all bands to reset flags for images in headers of bands */
2712 for (i
=0; i
<infoPtr
->uNumBands
; i
++) {
2713 lpBand
= &infoPtr
->bands
[i
];
2714 REBAR_ValidateBand (infoPtr
, lpBand
);
2722 REBAR_SetBkColor (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
2726 clrTemp
= infoPtr
->clrBk
;
2727 infoPtr
->clrBk
= (COLORREF
)lParam
;
2729 TRACE("background color 0x%06x!\n", infoPtr
->clrBk
);
2735 /* << REBAR_SetColorScheme >> */
2736 /* << REBAR_SetPalette >> */
2740 REBAR_SetParent (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
2742 HWND hwndTemp
= infoPtr
->hwndNotify
;
2744 infoPtr
->hwndNotify
= (HWND
)wParam
;
2746 return (LRESULT
)hwndTemp
;
2751 REBAR_SetTextColor (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
2755 clrTemp
= infoPtr
->clrText
;
2756 infoPtr
->clrText
= (COLORREF
)lParam
;
2758 TRACE("text color 0x%06x!\n", infoPtr
->clrText
);
2764 /* << REBAR_SetTooltips >> */
2767 static inline LRESULT
2768 REBAR_SetUnicodeFormat (REBAR_INFO
*infoPtr
, WPARAM wParam
)
2770 BOOL bTemp
= infoPtr
->bUnicode
;
2772 TRACE("to %s hwnd=%p, was %s\n",
2773 ((BOOL
)wParam
) ? "TRUE" : "FALSE", infoPtr
->hwndSelf
,
2774 (bTemp
) ? "TRUE" : "FALSE");
2776 infoPtr
->bUnicode
= (BOOL
)wParam
;
2783 REBAR_SetVersion (REBAR_INFO
*infoPtr
, INT iVersion
)
2785 INT iOldVersion
= infoPtr
->iVersion
;
2787 if (iVersion
> COMCTL32_VERSION
)
2790 infoPtr
->iVersion
= iVersion
;
2792 TRACE("new version %d\n", iVersion
);
2799 REBAR_ShowBand (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
2803 if (((INT
)wParam
< 0) || ((INT
)wParam
> infoPtr
->uNumBands
))
2806 lpBand
= &infoPtr
->bands
[(INT
)wParam
];
2809 TRACE("show band %d\n", (INT
)wParam
);
2810 lpBand
->fStyle
= lpBand
->fStyle
& ~RBBS_HIDDEN
;
2811 if (IsWindow (lpBand
->hwndChild
))
2812 ShowWindow (lpBand
->hwndChild
, SW_SHOW
);
2815 TRACE("hide band %d\n", (INT
)wParam
);
2816 lpBand
->fStyle
= lpBand
->fStyle
| RBBS_HIDDEN
;
2817 if (IsWindow (lpBand
->hwndChild
))
2818 ShowWindow (lpBand
->hwndChild
, SW_HIDE
);
2821 REBAR_Layout(infoPtr
);
2822 InvalidateRect(infoPtr
->hwndSelf
, 0, 1);
2829 REBAR_SizeToRect (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
2831 LPRECT lpRect
= (LPRECT
)lParam
;
2836 TRACE("[%s]\n", wine_dbgstr_rect(lpRect
));
2837 REBAR_SizeToHeight(infoPtr
, get_rect_cy(infoPtr
, lpRect
));
2844 REBAR_Create (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
2846 LPCREATESTRUCTW cs
= (LPCREATESTRUCTW
) lParam
;
2850 if (TRACE_ON(rebar
)) {
2851 GetWindowRect(infoPtr
->hwndSelf
, &wnrc1
);
2852 GetClientRect(infoPtr
->hwndSelf
, &clrc1
);
2853 TRACE("window=(%s) client=(%s) cs=(%d,%d %dx%d)\n",
2854 wine_dbgstr_rect(&wnrc1
), wine_dbgstr_rect(&clrc1
),
2855 cs
->x
, cs
->y
, cs
->cx
, cs
->cy
);
2858 TRACE("created!\n");
2860 if ((theme
= OpenThemeData (infoPtr
->hwndSelf
, themeClass
)))
2862 /* native seems to clear WS_BORDER when themed */
2863 infoPtr
->dwStyle
&= ~WS_BORDER
;
2871 REBAR_Destroy (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
2877 /* free rebar bands */
2878 if ((infoPtr
->uNumBands
> 0) && infoPtr
->bands
) {
2879 /* clean up each band */
2880 for (i
= 0; i
< infoPtr
->uNumBands
; i
++) {
2881 lpBand
= &infoPtr
->bands
[i
];
2883 /* delete text strings */
2884 Free (lpBand
->lpText
);
2885 lpBand
->lpText
= NULL
;
2886 /* destroy child window */
2887 DestroyWindow (lpBand
->hwndChild
);
2890 /* free band array */
2891 Free (infoPtr
->bands
);
2892 infoPtr
->bands
= NULL
;
2895 DestroyCursor (infoPtr
->hcurArrow
);
2896 DestroyCursor (infoPtr
->hcurHorz
);
2897 DestroyCursor (infoPtr
->hcurVert
);
2898 DestroyCursor (infoPtr
->hcurDrag
);
2899 if(infoPtr
->hDefaultFont
) DeleteObject (infoPtr
->hDefaultFont
);
2900 SetWindowLongPtrW (infoPtr
->hwndSelf
, 0, 0);
2902 CloseThemeData (GetWindowTheme (infoPtr
->hwndSelf
));
2904 /* free rebar info data */
2906 TRACE("destroyed!\n");
2912 REBAR_EraseBkGnd (const REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
2916 if (GetClipBox ( (HDC
)wParam
, &cliprect
))
2917 return REBAR_InternalEraseBkGnd (infoPtr
, wParam
, lParam
, &cliprect
);
2923 REBAR_GetFont (const REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
2925 return (LRESULT
)infoPtr
->hFont
;
2929 REBAR_PushChevron(const REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
2931 if ((UINT
)wParam
< infoPtr
->uNumBands
)
2933 NMREBARCHEVRON nmrbc
;
2934 REBAR_BAND
*lpBand
= &infoPtr
->bands
[wParam
];
2936 TRACE("Pressed chevron on band %ld\n", wParam
);
2938 /* redraw chevron in pushed state */
2939 lpBand
->fDraw
|= DRAW_CHEVRONPUSHED
;
2940 RedrawWindow(infoPtr
->hwndSelf
, &lpBand
->rcChevron
,0,
2941 RDW_ERASE
|RDW_INVALIDATE
|RDW_UPDATENOW
);
2943 /* notify app so it can display a popup menu or whatever */
2944 nmrbc
.uBand
= wParam
;
2945 nmrbc
.wID
= lpBand
->wID
;
2946 nmrbc
.lParam
= lpBand
->lParam
;
2947 nmrbc
.rc
= lpBand
->rcChevron
;
2948 nmrbc
.lParamNM
= lParam
;
2949 REBAR_Notify((NMHDR
*)&nmrbc
, infoPtr
, RBN_CHEVRONPUSHED
);
2951 /* redraw chevron in previous state */
2952 lpBand
->fDraw
&= ~DRAW_CHEVRONPUSHED
;
2953 InvalidateRect(infoPtr
->hwndSelf
, &lpBand
->rcChevron
, TRUE
);
2961 REBAR_LButtonDown (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
2967 ptMouseDown
.x
= (short)LOWORD(lParam
);
2968 ptMouseDown
.y
= (short)HIWORD(lParam
);
2970 REBAR_InternalHitTest(infoPtr
, &ptMouseDown
, &htFlags
, &iHitBand
);
2971 lpBand
= &infoPtr
->bands
[iHitBand
];
2973 if (htFlags
== RBHT_CHEVRON
)
2975 REBAR_PushChevron(infoPtr
, iHitBand
, 0);
2977 else if (htFlags
== RBHT_GRABBER
|| htFlags
== RBHT_CAPTION
)
2979 TRACE("Starting drag\n");
2981 SetCapture (infoPtr
->hwndSelf
);
2982 infoPtr
->iGrabbedBand
= iHitBand
;
2984 /* save off the LOWORD and HIWORD of lParam as initial x,y */
2985 infoPtr
->dragStart
.x
= (short)LOWORD(lParam
);
2986 infoPtr
->dragStart
.y
= (short)HIWORD(lParam
);
2987 infoPtr
->dragNow
= infoPtr
->dragStart
;
2988 if (infoPtr
->dwStyle
& CCS_VERT
)
2989 infoPtr
->ihitoffset
= infoPtr
->dragStart
.y
- (lpBand
->rcBand
.left
+ REBAR_PRE_GRIPPER
);
2991 infoPtr
->ihitoffset
= infoPtr
->dragStart
.x
- (lpBand
->rcBand
.left
+ REBAR_PRE_GRIPPER
);
2997 REBAR_LButtonUp (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
2999 if (infoPtr
->iGrabbedBand
>= 0)
3004 infoPtr
->dragStart
.x
= 0;
3005 infoPtr
->dragStart
.y
= 0;
3006 infoPtr
->dragNow
= infoPtr
->dragStart
;
3010 if (infoPtr
->fStatus
& BEGIN_DRAG_ISSUED
) {
3011 REBAR_Notify(&layout
, infoPtr
, RBN_LAYOUTCHANGED
);
3012 REBAR_Notify_NMREBAR (infoPtr
, infoPtr
->iGrabbedBand
, RBN_ENDDRAG
);
3013 infoPtr
->fStatus
&= ~BEGIN_DRAG_ISSUED
;
3016 infoPtr
->iGrabbedBand
= -1;
3018 GetClientRect(infoPtr
->hwndSelf
, &rect
);
3019 InvalidateRect(infoPtr
->hwndSelf
, NULL
, TRUE
);
3026 REBAR_MouseLeave (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
3028 if (infoPtr
->ichevronhotBand
>= 0)
3030 REBAR_BAND
*lpChevronBand
= &infoPtr
->bands
[infoPtr
->ichevronhotBand
];
3031 if (lpChevronBand
->fDraw
& DRAW_CHEVRONHOT
)
3033 lpChevronBand
->fDraw
&= ~DRAW_CHEVRONHOT
;
3034 InvalidateRect(infoPtr
->hwndSelf
, &lpChevronBand
->rcChevron
, TRUE
);
3037 infoPtr
->iOldBand
= -1;
3038 infoPtr
->ichevronhotBand
= -2;
3044 REBAR_MouseMove (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
3046 REBAR_BAND
*lpChevronBand
;
3049 ptMove
.x
= (short)LOWORD(lParam
);
3050 ptMove
.y
= (short)HIWORD(lParam
);
3052 /* if we are currently dragging a band */
3053 if (infoPtr
->iGrabbedBand
>= 0)
3055 REBAR_BAND
*band1
, *band2
;
3056 int yPtMove
= (infoPtr
->dwStyle
& CCS_VERT
? ptMove
.x
: ptMove
.y
);
3058 if (GetCapture() != infoPtr
->hwndSelf
)
3059 ERR("We are dragging but haven't got capture?!?\n");
3061 band1
= &infoPtr
->bands
[infoPtr
->iGrabbedBand
-1];
3062 band2
= &infoPtr
->bands
[infoPtr
->iGrabbedBand
];
3064 /* if mouse did not move much, exit */
3065 if ((abs(ptMove
.x
- infoPtr
->dragNow
.x
) <= mindragx
) &&
3066 (abs(ptMove
.y
- infoPtr
->dragNow
.y
) <= mindragy
)) return 0;
3068 /* Test for valid drag case - must not be first band in row */
3069 if ((yPtMove
< band2
->rcBand
.top
) ||
3070 (yPtMove
> band2
->rcBand
.bottom
) ||
3071 ((infoPtr
->iGrabbedBand
> 0) && (band1
->iRow
!= band2
->iRow
))) {
3072 FIXME("Cannot drag to other rows yet!!\n");
3075 REBAR_HandleLRDrag (infoPtr
, &ptMove
);
3082 TRACKMOUSEEVENT trackinfo
;
3084 REBAR_InternalHitTest(infoPtr
, &ptMove
, &htFlags
, &iHitBand
);
3086 if (infoPtr
->iOldBand
>= 0 && infoPtr
->iOldBand
== infoPtr
->ichevronhotBand
)
3088 lpChevronBand
= &infoPtr
->bands
[infoPtr
->ichevronhotBand
];
3089 if (lpChevronBand
->fDraw
& DRAW_CHEVRONHOT
)
3091 lpChevronBand
->fDraw
&= ~DRAW_CHEVRONHOT
;
3092 InvalidateRect(infoPtr
->hwndSelf
, &lpChevronBand
->rcChevron
, TRUE
);
3094 infoPtr
->ichevronhotBand
= -2;
3097 if (htFlags
== RBHT_CHEVRON
)
3099 /* fill in the TRACKMOUSEEVENT struct */
3100 trackinfo
.cbSize
= sizeof(TRACKMOUSEEVENT
);
3101 trackinfo
.dwFlags
= TME_QUERY
;
3102 trackinfo
.hwndTrack
= infoPtr
->hwndSelf
;
3103 trackinfo
.dwHoverTime
= 0;
3105 /* call _TrackMouseEvent to see if we are currently tracking for this hwnd */
3106 _TrackMouseEvent(&trackinfo
);
3108 /* Make sure tracking is enabled so we receive a WM_MOUSELEAVE message */
3109 if(!(trackinfo
.dwFlags
& TME_LEAVE
))
3111 trackinfo
.dwFlags
= TME_LEAVE
; /* notify upon leaving */
3113 /* call TRACKMOUSEEVENT so we receive a WM_MOUSELEAVE message */
3114 /* and can properly deactivate the hot chevron */
3115 _TrackMouseEvent(&trackinfo
);
3118 lpChevronBand
= &infoPtr
->bands
[iHitBand
];
3119 if (!(lpChevronBand
->fDraw
& DRAW_CHEVRONHOT
))
3121 lpChevronBand
->fDraw
|= DRAW_CHEVRONHOT
;
3122 InvalidateRect(infoPtr
->hwndSelf
, &lpChevronBand
->rcChevron
, TRUE
);
3123 infoPtr
->ichevronhotBand
= iHitBand
;
3126 infoPtr
->iOldBand
= iHitBand
;
3133 static inline LRESULT
3134 REBAR_NCCalcSize (const REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
3137 RECT
*rect
= (RECT
*)lParam
;
3139 if (infoPtr
->dwStyle
& WS_BORDER
) {
3140 rect
->left
= min(rect
->left
+ GetSystemMetrics(SM_CXEDGE
), rect
->right
);
3141 rect
->right
= max(rect
->right
- GetSystemMetrics(SM_CXEDGE
), rect
->left
);
3142 rect
->top
= min(rect
->top
+ GetSystemMetrics(SM_CYEDGE
), rect
->bottom
);
3143 rect
->bottom
= max(rect
->bottom
- GetSystemMetrics(SM_CYEDGE
), rect
->top
);
3145 else if ((theme
= GetWindowTheme (infoPtr
->hwndSelf
)))
3147 /* FIXME: should use GetThemeInt */
3148 rect
->top
= min(rect
->top
+ 1, rect
->bottom
);
3150 TRACE("new client=(%s)\n", wine_dbgstr_rect(rect
));
3156 REBAR_NCCreate (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3158 LPCREATESTRUCTW cs
= (LPCREATESTRUCTW
) lParam
;
3159 REBAR_INFO
*infoPtr
= REBAR_GetInfoPtr (hwnd
);
3161 NONCLIENTMETRICSW ncm
;
3164 if (infoPtr
!= NULL
) {
3165 ERR("Strange info structure pointer *not* NULL\n");
3169 if (TRACE_ON(rebar
)) {
3170 GetWindowRect(hwnd
, &wnrc1
);
3171 GetClientRect(hwnd
, &clrc1
);
3172 TRACE("window=(%s) client=(%s) cs=(%d,%d %dx%d)\n",
3173 wine_dbgstr_rect(&wnrc1
), wine_dbgstr_rect(&clrc1
),
3174 cs
->x
, cs
->y
, cs
->cx
, cs
->cy
);
3177 /* allocate memory for info structure */
3178 infoPtr
= (REBAR_INFO
*)Alloc (sizeof(REBAR_INFO
));
3179 SetWindowLongPtrW (hwnd
, 0, (DWORD_PTR
)infoPtr
);
3181 /* initialize info structure - initial values are 0 */
3182 infoPtr
->clrBk
= CLR_NONE
;
3183 infoPtr
->clrText
= CLR_NONE
;
3184 infoPtr
->clrBtnText
= GetSysColor (COLOR_BTNTEXT
);
3185 infoPtr
->clrBtnFace
= GetSysColor (COLOR_BTNFACE
);
3186 infoPtr
->iOldBand
= -1;
3187 infoPtr
->ichevronhotBand
= -2;
3188 infoPtr
->iGrabbedBand
= -1;
3189 infoPtr
->hwndSelf
= hwnd
;
3190 infoPtr
->DoRedraw
= TRUE
;
3191 infoPtr
->hcurArrow
= LoadCursorW (0, (LPWSTR
)IDC_ARROW
);
3192 infoPtr
->hcurHorz
= LoadCursorW (0, (LPWSTR
)IDC_SIZEWE
);
3193 infoPtr
->hcurVert
= LoadCursorW (0, (LPWSTR
)IDC_SIZENS
);
3194 infoPtr
->hcurDrag
= LoadCursorW (0, (LPWSTR
)IDC_SIZE
);
3195 infoPtr
->fStatus
= 0;
3196 infoPtr
->hFont
= GetStockObject (SYSTEM_FONT
);
3198 /* issue WM_NOTIFYFORMAT to get unicode status of parent */
3199 REBAR_NotifyFormat(infoPtr
, 0, NF_REQUERY
);
3201 /* Stow away the original style */
3202 infoPtr
->orgStyle
= cs
->style
;
3203 /* add necessary styles to the requested styles */
3204 infoPtr
->dwStyle
= cs
->style
| WS_VISIBLE
;
3205 if ((infoPtr
->dwStyle
& CCS_LAYOUT_MASK
) == 0)
3206 infoPtr
->dwStyle
|= CCS_TOP
;
3207 SetWindowLongW (hwnd
, GWL_STYLE
, infoPtr
->dwStyle
);
3209 /* get font handle for Caption Font */
3210 ncm
.cbSize
= sizeof(ncm
);
3211 SystemParametersInfoW (SPI_GETNONCLIENTMETRICS
, ncm
.cbSize
, &ncm
, 0);
3212 /* if the font is bold, set to normal */
3213 if (ncm
.lfCaptionFont
.lfWeight
> FW_NORMAL
) {
3214 ncm
.lfCaptionFont
.lfWeight
= FW_NORMAL
;
3216 tfont
= CreateFontIndirectW (&ncm
.lfCaptionFont
);
3218 infoPtr
->hFont
= infoPtr
->hDefaultFont
= tfont
;
3222 GetSysColor (numerous);
3223 GetSysColorBrush (numerous) (see WM_SYSCOLORCHANGE);
3224 *GetStockObject (SYSTEM_FONT);
3225 *SetWindowLong (hwnd, 0, info ptr);
3227 *SetWindowLong (hwnd, GWL_STYLE, style+0x10000001);
3228 WS_VISIBLE = 0x10000000;
3229 CCS_TOP = 0x00000001;
3230 *SystemParametersInfo (SPI_GETNONCLIENTMETRICS...);
3231 *CreateFontIndirect (lfCaptionFont from above);
3233 SelectObject (hdc, fontabove);
3234 GetTextMetrics (hdc, ); guessing is tmHeight
3235 SelectObject (hdc, oldfont);
3238 MapWindowPoints (0, parent, rectabove, 2);
3241 ClientToScreen (clientrect);
3242 SetWindowPos (hwnd, 0, 0, 0, 0, 0, SWP_NOZORDER);
3249 REBAR_NCHitTest (const REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
3255 LRESULT ret
= HTCLIENT
;
3258 * Differences from doc at MSDN (as observed with version 4.71 of
3260 * 1. doc says nmmouse.pt is in screen coord, trace shows client coord.
3261 * 2. if band is not identified .dwItemSpec is 0xffffffff.
3262 * 3. native always seems to return HTCLIENT if notify return is 0.
3265 clpt
.x
= (short)LOWORD(lParam
);
3266 clpt
.y
= (short)HIWORD(lParam
);
3267 ScreenToClient (infoPtr
->hwndSelf
, &clpt
);
3268 REBAR_InternalHitTest (infoPtr
, &clpt
, &scrap
,
3269 (INT
*)&nmmouse
.dwItemSpec
);
3270 nmmouse
.dwItemData
= 0;
3272 nmmouse
.dwHitInfo
= 0;
3273 if ((i
= REBAR_Notify((NMHDR
*) &nmmouse
, infoPtr
, NM_NCHITTEST
))) {
3274 TRACE("notify changed return value from %ld to %d\n",
3278 TRACE("returning %ld, client point (%d,%d)\n", ret
, clpt
.x
, clpt
.y
);
3284 REBAR_NCPaint (const REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
3290 if (infoPtr
->dwStyle
& WS_MINIMIZE
)
3291 return 0; /* Nothing to do */
3293 if (infoPtr
->dwStyle
& WS_BORDER
) {
3295 /* adjust rectangle and draw the necessary edge */
3296 if (!(hdc
= GetDCEx( infoPtr
->hwndSelf
, 0, DCX_USESTYLE
| DCX_WINDOW
)))
3298 GetWindowRect (infoPtr
->hwndSelf
, &rcWindow
);
3299 OffsetRect (&rcWindow
, -rcWindow
.left
, -rcWindow
.top
);
3300 TRACE("rect (%s)\n", wine_dbgstr_rect(&rcWindow
));
3301 DrawEdge (hdc
, &rcWindow
, EDGE_ETCHED
, BF_RECT
);
3302 ReleaseDC( infoPtr
->hwndSelf
, hdc
);
3304 else if ((theme
= GetWindowTheme (infoPtr
->hwndSelf
)))
3306 /* adjust rectangle and draw the necessary edge */
3307 if (!(hdc
= GetDCEx( infoPtr
->hwndSelf
, 0, DCX_USESTYLE
| DCX_WINDOW
)))
3309 GetWindowRect (infoPtr
->hwndSelf
, &rcWindow
);
3310 OffsetRect (&rcWindow
, -rcWindow
.left
, -rcWindow
.top
);
3311 TRACE("rect (%s)\n", wine_dbgstr_rect(&rcWindow
));
3312 DrawThemeEdge (theme
, hdc
, 0, 0, &rcWindow
, BDR_RAISEDINNER
, BF_TOP
, NULL
);
3313 ReleaseDC( infoPtr
->hwndSelf
, hdc
);
3321 REBAR_NotifyFormat (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
3325 if (lParam
== NF_REQUERY
) {
3326 i
= SendMessageW(REBAR_GetNotifyParent (infoPtr
),
3327 WM_NOTIFYFORMAT
, (WPARAM
)infoPtr
->hwndSelf
, NF_QUERY
);
3328 if ((i
!= NFR_ANSI
) && (i
!= NFR_UNICODE
)) {
3329 ERR("wrong response to WM_NOTIFYFORMAT (%d), assuming ANSI\n", i
);
3332 infoPtr
->bUnicode
= (i
== NFR_UNICODE
) ? 1 : 0;
3335 return (LRESULT
)((infoPtr
->bUnicode
) ? NFR_UNICODE
: NFR_ANSI
);
3340 REBAR_Paint (const REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
3342 HDC hdc
= (HDC
)wParam
;
3345 TRACE("painting\n");
3346 REBAR_Refresh (infoPtr
, hdc
);
3349 hdc
= BeginPaint (infoPtr
->hwndSelf
, &ps
);
3350 TRACE("painting (%s)\n", wine_dbgstr_rect(&ps
.rcPaint
));
3352 /* Erase area of paint if requested */
3353 REBAR_InternalEraseBkGnd (infoPtr
, wParam
, lParam
, &ps
.rcPaint
);
3355 REBAR_Refresh (infoPtr
, hdc
);
3356 EndPaint (infoPtr
->hwndSelf
, &ps
);
3364 REBAR_SetCursor (const REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
3369 TRACE("code=0x%X id=0x%X\n", LOWORD(lParam
), HIWORD(lParam
));
3372 ScreenToClient (infoPtr
->hwndSelf
, &pt
);
3374 REBAR_InternalHitTest (infoPtr
, &pt
, &flags
, NULL
);
3376 if (flags
== RBHT_GRABBER
) {
3377 if ((infoPtr
->dwStyle
& CCS_VERT
) &&
3378 !(infoPtr
->dwStyle
& RBS_VERTICALGRIPPER
))
3379 SetCursor (infoPtr
->hcurVert
);
3381 SetCursor (infoPtr
->hcurHorz
);
3383 else if (flags
!= RBHT_CLIENT
)
3384 SetCursor (infoPtr
->hcurArrow
);
3391 REBAR_SetFont (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
3396 infoPtr
->hFont
= (HFONT
)wParam
;
3398 /* revalidate all bands to change sizes of text in headers of bands */
3399 for (i
=0; i
<infoPtr
->uNumBands
; i
++) {
3400 lpBand
= &infoPtr
->bands
[i
];
3401 REBAR_ValidateBand (infoPtr
, lpBand
);
3404 REBAR_Layout(infoPtr
);
3409 static inline LRESULT
3410 REBAR_SetRedraw (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
3411 /*****************************************************
3414 * Handles the WM_SETREDRAW message.
3417 * According to testing V4.71 of COMCTL32 returns the
3418 * *previous* status of the redraw flag (either 0 or -1)
3419 * instead of the MSDN documented value of 0 if handled
3421 *****************************************************/
3423 BOOL oldredraw
= infoPtr
->DoRedraw
;
3425 TRACE("set to %s, fStatus=%08x\n",
3426 (wParam
) ? "TRUE" : "FALSE", infoPtr
->fStatus
);
3427 infoPtr
->DoRedraw
= (BOOL
) wParam
;
3429 if (infoPtr
->fStatus
& BAND_NEEDS_REDRAW
) {
3430 REBAR_MoveChildWindows (infoPtr
, 0, infoPtr
->uNumBands
);
3431 REBAR_ForceResize (infoPtr
);
3432 InvalidateRect (infoPtr
->hwndSelf
, 0, TRUE
);
3434 infoPtr
->fStatus
&= ~BAND_NEEDS_REDRAW
;
3436 return (oldredraw
) ? -1 : 0;
3441 REBAR_Size (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
3443 TRACE("wParam=%lx, lParam=%lx\n", wParam
, lParam
);
3445 /* avoid _Layout resize recursion (but it shouldn't be infinite and it seems Windows does recurse) */
3446 if (infoPtr
->fStatus
& SELF_RESIZE
) {
3447 infoPtr
->fStatus
&= ~SELF_RESIZE
;
3448 TRACE("SELF_RESIZE was set, reset, fStatus=%08x lparam=%08lx\n",
3449 infoPtr
->fStatus
, lParam
);
3453 if (infoPtr
->dwStyle
& RBS_AUTOSIZE
)
3454 REBAR_AutoSize(infoPtr
, TRUE
);
3456 REBAR_Layout(infoPtr
);
3463 REBAR_StyleChanged (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
3465 STYLESTRUCT
*ss
= (STYLESTRUCT
*)lParam
;
3467 TRACE("current style=%08x, styleOld=%08x, style being set to=%08x\n",
3468 infoPtr
->dwStyle
, ss
->styleOld
, ss
->styleNew
);
3469 infoPtr
->orgStyle
= infoPtr
->dwStyle
= ss
->styleNew
;
3470 if (GetWindowTheme (infoPtr
->hwndSelf
))
3471 infoPtr
->dwStyle
&= ~WS_BORDER
;
3472 /* maybe it should be COMMON_STYLES like in toolbar */
3473 if ((ss
->styleNew
^ ss
->styleOld
) & CCS_VERT
)
3474 REBAR_Layout(infoPtr
);
3479 /* update theme after a WM_THEMECHANGED message */
3480 static LRESULT
theme_changed (REBAR_INFO
* infoPtr
)
3482 HTHEME theme
= GetWindowTheme (infoPtr
->hwndSelf
);
3483 CloseThemeData (theme
);
3484 theme
= OpenThemeData (infoPtr
->hwndSelf
, themeClass
);
3485 /* WS_BORDER disappears when theming is enabled and reappears when
3487 infoPtr
->dwStyle
&= ~WS_BORDER
;
3488 infoPtr
->dwStyle
|= theme
? 0 : (infoPtr
->orgStyle
& WS_BORDER
);
3493 REBAR_WindowPosChanged (const REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
3498 ret
= DefWindowProcW(infoPtr
->hwndSelf
, WM_WINDOWPOSCHANGED
,
3500 GetWindowRect(infoPtr
->hwndSelf
, &rc
);
3501 TRACE("hwnd %p new pos (%s)\n", infoPtr
->hwndSelf
, wine_dbgstr_rect(&rc
));
3506 static LRESULT WINAPI
3507 REBAR_WindowProc (HWND hwnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
)
3509 REBAR_INFO
*infoPtr
= REBAR_GetInfoPtr (hwnd
);
3511 TRACE("hwnd=%p msg=%x wparam=%lx lparam=%lx\n",
3512 hwnd
, uMsg
, wParam
, lParam
);
3513 if (!infoPtr
&& (uMsg
!= WM_NCCREATE
))
3514 return DefWindowProcW (hwnd
, uMsg
, wParam
, lParam
);
3517 /* case RB_BEGINDRAG: */
3520 return REBAR_DeleteBand (infoPtr
, wParam
, lParam
);
3522 /* case RB_DRAGMOVE: */
3523 /* case RB_ENDDRAG: */
3525 case RB_GETBANDBORDERS
:
3526 return REBAR_GetBandBorders (infoPtr
, wParam
, lParam
);
3528 case RB_GETBANDCOUNT
:
3529 return REBAR_GetBandCount (infoPtr
);
3531 case RB_GETBANDINFO_OLD
:
3532 case RB_GETBANDINFOA
:
3533 return REBAR_GetBandInfoT(infoPtr
, wParam
, lParam
, FALSE
);
3535 case RB_GETBANDINFOW
:
3536 return REBAR_GetBandInfoT(infoPtr
, wParam
, lParam
, TRUE
);
3538 case RB_GETBARHEIGHT
:
3539 return REBAR_GetBarHeight (infoPtr
, wParam
, lParam
);
3542 return REBAR_GetBarInfo (infoPtr
, wParam
, lParam
);
3545 return REBAR_GetBkColor (infoPtr
);
3547 /* case RB_GETCOLORSCHEME: */
3548 /* case RB_GETDROPTARGET: */
3551 return REBAR_GetPalette (infoPtr
, wParam
, lParam
);
3554 return REBAR_GetRect (infoPtr
, wParam
, lParam
);
3556 case RB_GETROWCOUNT
:
3557 return REBAR_GetRowCount (infoPtr
);
3559 case RB_GETROWHEIGHT
:
3560 return REBAR_GetRowHeight (infoPtr
, wParam
, lParam
);
3562 case RB_GETTEXTCOLOR
:
3563 return REBAR_GetTextColor (infoPtr
);
3565 case RB_GETTOOLTIPS
:
3566 return REBAR_GetToolTips (infoPtr
);
3568 case RB_GETUNICODEFORMAT
:
3569 return REBAR_GetUnicodeFormat (infoPtr
);
3571 case CCM_GETVERSION
:
3572 return REBAR_GetVersion (infoPtr
);
3575 return REBAR_HitTest (infoPtr
, wParam
, lParam
);
3578 return REBAR_IdToIndex (infoPtr
, wParam
, lParam
);
3580 case RB_INSERTBANDA
:
3581 return REBAR_InsertBandT(infoPtr
, wParam
, lParam
, FALSE
);
3583 case RB_INSERTBANDW
:
3584 return REBAR_InsertBandT(infoPtr
, wParam
, lParam
, TRUE
);
3586 case RB_MAXIMIZEBAND
:
3587 return REBAR_MaximizeBand (infoPtr
, wParam
, lParam
);
3589 case RB_MINIMIZEBAND
:
3590 return REBAR_MinimizeBand (infoPtr
, wParam
, lParam
);
3593 return REBAR_MoveBand (infoPtr
, wParam
, lParam
);
3595 case RB_PUSHCHEVRON
:
3596 return REBAR_PushChevron (infoPtr
, wParam
, lParam
);
3598 case RB_SETBANDINFOA
:
3599 return REBAR_SetBandInfoT(infoPtr
, wParam
, lParam
, FALSE
);
3601 case RB_SETBANDINFOW
:
3602 return REBAR_SetBandInfoT(infoPtr
, wParam
, lParam
, TRUE
);
3605 return REBAR_SetBarInfo (infoPtr
, wParam
, lParam
);
3608 return REBAR_SetBkColor (infoPtr
, wParam
, lParam
);
3610 /* case RB_SETCOLORSCHEME: */
3611 /* case RB_SETPALETTE: */
3612 /* return REBAR_GetPalette (infoPtr, wParam, lParam); */
3615 return REBAR_SetParent (infoPtr
, wParam
, lParam
);
3617 case RB_SETTEXTCOLOR
:
3618 return REBAR_SetTextColor (infoPtr
, wParam
, lParam
);
3620 /* case RB_SETTOOLTIPS: */
3622 case RB_SETUNICODEFORMAT
:
3623 return REBAR_SetUnicodeFormat (infoPtr
, wParam
);
3625 case CCM_SETVERSION
:
3626 return REBAR_SetVersion (infoPtr
, (INT
)wParam
);
3629 return REBAR_ShowBand (infoPtr
, wParam
, lParam
);
3632 return REBAR_SizeToRect (infoPtr
, wParam
, lParam
);
3635 /* Messages passed to parent */
3639 return SendMessageW(REBAR_GetNotifyParent (infoPtr
), uMsg
, wParam
, lParam
);
3642 /* case WM_CHARTOITEM: supported according to ControlSpy */
3645 return REBAR_Create (infoPtr
, wParam
, lParam
);
3648 return REBAR_Destroy (infoPtr
, wParam
, lParam
);
3651 return REBAR_EraseBkGnd (infoPtr
, wParam
, lParam
);
3654 return REBAR_GetFont (infoPtr
, wParam
, lParam
);
3656 /* case WM_LBUTTONDBLCLK: supported according to ControlSpy */
3658 case WM_LBUTTONDOWN
:
3659 return REBAR_LButtonDown (infoPtr
, wParam
, lParam
);
3662 return REBAR_LButtonUp (infoPtr
, wParam
, lParam
);
3664 /* case WM_MEASUREITEM: supported according to ControlSpy */
3667 return REBAR_MouseMove (infoPtr
, wParam
, lParam
);
3670 return REBAR_MouseLeave (infoPtr
, wParam
, lParam
);
3673 return REBAR_NCCalcSize (infoPtr
, wParam
, lParam
);
3676 return REBAR_NCCreate (hwnd
, wParam
, lParam
);
3679 return REBAR_NCHitTest (infoPtr
, wParam
, lParam
);
3682 return REBAR_NCPaint (infoPtr
, wParam
, lParam
);
3684 case WM_NOTIFYFORMAT
:
3685 return REBAR_NotifyFormat (infoPtr
, wParam
, lParam
);
3687 case WM_PRINTCLIENT
:
3689 return REBAR_Paint (infoPtr
, wParam
, lParam
);
3691 /* case WM_PALETTECHANGED: supported according to ControlSpy */
3692 /* case WM_QUERYNEWPALETTE:supported according to ControlSpy */
3693 /* case WM_RBUTTONDOWN: supported according to ControlSpy */
3694 /* case WM_RBUTTONUP: supported according to ControlSpy */
3697 return REBAR_SetCursor (infoPtr
, wParam
, lParam
);
3700 return REBAR_SetFont (infoPtr
, wParam
, lParam
);
3703 return REBAR_SetRedraw (infoPtr
, wParam
, lParam
);
3706 return REBAR_Size (infoPtr
, wParam
, lParam
);
3708 case WM_STYLECHANGED
:
3709 return REBAR_StyleChanged (infoPtr
, wParam
, lParam
);
3711 case WM_THEMECHANGED
:
3712 return theme_changed (infoPtr
);
3714 /* case WM_SYSCOLORCHANGE: supported according to ControlSpy */
3715 /* "Applications that have brushes using the existing system colors
3716 should delete those brushes and recreate them using the new
3717 system colors." per MSDN */
3719 /* case WM_VKEYTOITEM: supported according to ControlSpy */
3720 /* case WM_WININICHANGE: */
3722 case WM_WINDOWPOSCHANGED
:
3723 return REBAR_WindowPosChanged (infoPtr
, wParam
, lParam
);
3726 if ((uMsg
>= WM_USER
) && (uMsg
< WM_APP
))
3727 ERR("unknown msg %04x wp=%08lx lp=%08lx\n",
3728 uMsg
, wParam
, lParam
);
3729 return DefWindowProcW (hwnd
, uMsg
, wParam
, lParam
);
3735 REBAR_Register (void)
3739 ZeroMemory (&wndClass
, sizeof(WNDCLASSW
));
3740 wndClass
.style
= CS_GLOBALCLASS
| CS_DBLCLKS
;
3741 wndClass
.lpfnWndProc
= REBAR_WindowProc
;
3742 wndClass
.cbClsExtra
= 0;
3743 wndClass
.cbWndExtra
= sizeof(REBAR_INFO
*);
3744 wndClass
.hCursor
= 0;
3745 wndClass
.hbrBackground
= (HBRUSH
)(COLOR_BTNFACE
+ 1);
3747 wndClass
.hbrBackground
= CreateSolidBrush(RGB(0,128,0));
3749 wndClass
.lpszClassName
= REBARCLASSNAMEW
;
3751 RegisterClassW (&wndClass
);
3753 mindragx
= GetSystemMetrics (SM_CXDRAG
);
3754 mindragy
= GetSystemMetrics (SM_CYDRAG
);
3760 REBAR_Unregister (void)
3762 UnregisterClassW (REBARCLASSNAMEW
, NULL
);