4 * Copyright 1998, 1999 Eric Kohl
5 * Copyright 2007, 2008 Mikolaj Zalewski
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
23 * This code was audited for completeness against the documented features
24 * of Comctl32.dll version 6.0 on Oct. 19, 2004, by Robert Shearman.
26 * Unless otherwise noted, we believe this code to be complete, as per
27 * the specification mentioned above.
28 * If you discover missing features or bugs please note them below.
50 * - WM_QUERYNEWPALETTE
58 * - NM_RELEASEDCAPTURE
64 * Native uses (on each draw!!) SM_CYBORDER (or SM_CXBORDER for CCS_VERT)
65 * to set the size of the separator width (the value SEP_WIDTH_SIZE
66 * in here). Should be fixed!!
70 * Testing: set to 1 to make background brush *always* green
75 * 3. REBAR_MoveChildWindows should have a loop because more than
76 * one pass (together with the RBN_CHILDSIZEs) is made on
77 * at least RB_INSERTBAND
88 #include "wine/unicode.h"
95 #include "wine/debug.h"
97 WINE_DEFAULT_DEBUG_CHANNEL(rebar
);
107 UINT cxMinChild
; /* valid if _CHILDSIZE */
108 UINT cyMinChild
; /* valid if _CHILDSIZE */
109 UINT cx
; /* valid if _SIZE */
112 UINT cyChild
; /* valid if _CHILDSIZE */
113 UINT cyMaxChild
; /* valid if _CHILDSIZE */
114 UINT cyIntegral
; /* valid if _CHILDSIZE */
119 INT cxEffective
; /* current cx for band */
120 UINT cyHeader
; /* the height of the header */
121 UINT cxMinBand
; /* minimum cx for band */
122 UINT cyMinBand
; /* minimum cy for band */
124 UINT cyRowSoFar
; /* for RBS_VARHEIGHT - the height of the row if it would break on this band (set by _Layout) */
125 INT iRow
; /* zero-based index of the row this band assigned to */
126 UINT fStatus
; /* status flags, reset only by _Validate */
127 UINT fDraw
; /* drawing flags, reset only by _Layout */
128 UINT uCDret
; /* last return from NM_CUSTOMDRAW */
129 RECT rcBand
; /* calculated band rectangle - coordinates swapped for CCS_VERT */
130 RECT rcGripper
; /* calculated gripper rectangle */
131 RECT rcCapImage
; /* calculated caption image rectangle */
132 RECT rcCapText
; /* calculated caption text rectangle */
133 RECT rcChild
; /* calculated child rectangle */
134 RECT rcChevron
; /* calculated chevron rectangle */
140 /* has a value of: 0, CCS_TOP, CCS_NOMOVEY, CCS_BOTTOM */
141 #define CCS_LAYOUT_MASK 0x3
144 #define HAS_GRIPPER 0x00000001
145 #define HAS_IMAGE 0x00000002
146 #define HAS_TEXT 0x00000004
149 #define DRAW_GRIPPER 0x00000001
150 #define DRAW_IMAGE 0x00000002
151 #define DRAW_TEXT 0x00000004
152 #define DRAW_CHEVRONHOT 0x00000040
153 #define DRAW_CHEVRONPUSHED 0x00000080
154 #define NTF_INVALIDATE 0x01000000
158 COLORREF clrBk
; /* background color */
159 COLORREF clrText
; /* text color */
160 COLORREF clrBtnText
; /* system color for BTNTEXT */
161 COLORREF clrBtnFace
; /* system color for BTNFACE */
162 HIMAGELIST himl
; /* handle to imagelist */
163 UINT uNumBands
; /* # of bands in rebar (first=0, last=uNumBands-1 */
164 UINT uNumRows
; /* # of rows of bands (first=1, last=uNumRows */
165 HWND hwndSelf
; /* handle of REBAR window itself */
166 HWND hwndToolTip
; /* handle to the tool tip control */
167 HWND hwndNotify
; /* notification window (parent) */
169 HFONT hFont
; /* handle to the rebar's font */
170 SIZE imageSize
; /* image size (image list) */
171 DWORD dwStyle
; /* window style */
172 DWORD orgStyle
; /* original style (dwStyle may change) */
173 SIZE calcSize
; /* calculated rebar size - coordinates swapped for CCS_VERT */
174 BOOL bUnicode
; /* TRUE if parent wants notify in W format */
175 BOOL DoRedraw
; /* TRUE to actually draw bands */
176 UINT fStatus
; /* Status flags (see below) */
177 HCURSOR hcurArrow
; /* handle to the arrow cursor */
178 HCURSOR hcurHorz
; /* handle to the EW cursor */
179 HCURSOR hcurVert
; /* handle to the NS cursor */
180 HCURSOR hcurDrag
; /* handle to the drag cursor */
181 INT iVersion
; /* version number */
182 POINT dragStart
; /* x,y of button down */
183 POINT dragNow
; /* x,y of this MouseMove */
184 INT iOldBand
; /* last band that had the mouse cursor over it */
185 INT ihitoffset
; /* offset of hotspot from gripper.left */
186 INT ichevronhotBand
; /* last band that had a hot chevron */
187 INT iGrabbedBand
;/* band number of band whose gripper was grabbed */
189 HDPA bands
; /* pointer to the array of rebar bands */
193 #define BEGIN_DRAG_ISSUED 0x00000001
194 #define SELF_RESIZE 0x00000002
195 #define BAND_NEEDS_REDRAW 0x00000020
197 /* used by Windows to mark that the header size has been set by the user and shouldn't be changed */
198 #define RBBS_UNDOC_FIXEDHEADER 0x40000000
200 /* ---- REBAR layout constants. Mostly determined by ---- */
201 /* ---- experiment on WIN 98. ---- */
203 /* Width (or height) of separators between bands (either horz. or */
204 /* vert.). True only if RBS_BANDBORDERS is set */
205 #define SEP_WIDTH_SIZE 2
206 #define SEP_WIDTH ((infoPtr->dwStyle & RBS_BANDBORDERS) ? SEP_WIDTH_SIZE : 0)
208 /* Blank (background color) space between Gripper (if present) */
209 /* and next item (image, text, or window). Always present */
210 #define REBAR_ALWAYS_SPACE 4
212 /* Blank (background color) space after Image (if present). */
213 #define REBAR_POST_IMAGE 2
215 /* Blank (background color) space after Text (if present). */
216 #define REBAR_POST_TEXT 4
218 /* Height of vertical gripper in a CCS_VERT rebar. */
219 #define GRIPPER_HEIGHT 16
221 /* Blank (background color) space before Gripper (if present). */
222 #define REBAR_PRE_GRIPPER 2
224 /* Width (of normal vertical gripper) or height (of horz. gripper) */
226 #define GRIPPER_WIDTH 3
228 /* Width of the chevron button if present */
229 #define CHEVRON_WIDTH 10
231 /* the gap between the child and the next band */
232 #define REBAR_POST_CHILD 4
234 /* Height of divider for Rebar if not disabled (CCS_NODIVIDER) */
235 /* either top or bottom */
236 #define REBAR_DIVIDER 2
238 /* height of a rebar without a child */
239 #define REBAR_NO_CHILD_HEIGHT 4
241 /* minimum vertical height of a normal bar */
242 /* or minimum width of a CCS_VERT bar - from experiment on Win2k */
243 #define REBAR_MINSIZE 23
245 /* This is the increment that is used over the band height */
246 #define REBARSPACE(a) ((a->fStyle & RBBS_CHILDEDGE) ? 2*REBAR_DIVIDER : 0)
248 /* ---- End of REBAR layout constants. ---- */
250 #define RB_GETBANDINFO_OLD (WM_USER+5) /* obsoleted after IE3, but we have to support it anyway */
252 /* The following define determines if a given band is hidden */
253 #define HIDDENBAND(a) (((a)->fStyle & RBBS_HIDDEN) || \
254 ((infoPtr->dwStyle & CCS_VERT) && \
255 ((a)->fStyle & RBBS_NOVERT)))
257 #define REBAR_GetInfoPtr(wndPtr) ((REBAR_INFO *)GetWindowLongPtrW (hwnd, 0))
259 static LRESULT
REBAR_NotifyFormat(REBAR_INFO
*infoPtr
, LPARAM lParam
);
260 static void REBAR_AutoSize(REBAR_INFO
*infoPtr
, BOOL needsLayout
);
262 /* no index check here */
263 static inline REBAR_BAND
* REBAR_GetBand(const REBAR_INFO
*infoPtr
, INT i
)
265 assert(i
>= 0 && i
< infoPtr
->uNumBands
);
266 return DPA_GetPtr(infoPtr
->bands
, i
);
269 /* "constant values" retrieved when DLL was initialized */
270 /* FIXME we do this when the classes are registered. */
271 static UINT mindragx
= 0;
272 static UINT mindragy
= 0;
274 static const char * const band_stylename
[] = {
275 "RBBS_BREAK", /* 0001 */
276 "RBBS_FIXEDSIZE", /* 0002 */
277 "RBBS_CHILDEDGE", /* 0004 */
278 "RBBS_HIDDEN", /* 0008 */
279 "RBBS_NOVERT", /* 0010 */
280 "RBBS_FIXEDBMP", /* 0020 */
281 "RBBS_VARIABLEHEIGHT", /* 0040 */
282 "RBBS_GRIPPERALWAYS", /* 0080 */
283 "RBBS_NOGRIPPER", /* 0100 */
284 "RBBS_USECHEVRON", /* 0200 */
285 "RBBS_HIDETITLE", /* 0400 */
286 "RBBS_TOPALIGN", /* 0800 */
289 static const char * const band_maskname
[] = {
290 "RBBIM_STYLE", /* 0x00000001 */
291 "RBBIM_COLORS", /* 0x00000002 */
292 "RBBIM_TEXT", /* 0x00000004 */
293 "RBBIM_IMAGE", /* 0x00000008 */
294 "RBBIM_CHILD", /* 0x00000010 */
295 "RBBIM_CHILDSIZE", /* 0x00000020 */
296 "RBBIM_SIZE", /* 0x00000040 */
297 "RBBIM_BACKGROUND", /* 0x00000080 */
298 "RBBIM_ID", /* 0x00000100 */
299 "RBBIM_IDEALSIZE", /* 0x00000200 */
300 "RBBIM_LPARAM", /* 0x00000400 */
301 "RBBIM_HEADERSIZE", /* 0x00000800 */
302 "RBBIM_CHEVRONLOCATION", /* 0x00001000 */
303 "RBBIM_CHEVRONSTATE", /* 0x00002000 */
307 static const WCHAR themeClass
[] = { 'R','e','b','a','r',0 };
310 REBAR_FmtStyle(char *buffer
, UINT style
)
315 while (band_stylename
[i
]) {
316 if (style
& (1<<i
)) {
317 if (*buffer
) strcat(buffer
, " | ");
318 strcat(buffer
, band_stylename
[i
]);
327 REBAR_FmtMask(char *buffer
, UINT mask
)
332 while (band_maskname
[i
]) {
334 if (*buffer
) strcat(buffer
, " | ");
335 strcat(buffer
, band_maskname
[i
]);
344 REBAR_DumpBandInfo(const REBARBANDINFOW
*pB
)
348 if( !TRACE_ON(rebar
) ) return;
349 TRACE("band info: ");
350 if (pB
->fMask
& RBBIM_ID
)
351 TRACE("ID=%u, ", pB
->wID
);
352 TRACE("size=%u, child=%p", pB
->cbSize
, pB
->hwndChild
);
353 if (pB
->fMask
& RBBIM_COLORS
)
354 TRACE(", clrF=0x%06x, clrB=0x%06x", pB
->clrFore
, pB
->clrBack
);
357 TRACE("band info: mask=0x%08x (%s)\n", pB
->fMask
, REBAR_FmtMask(buff
, pB
->fMask
));
358 if (pB
->fMask
& RBBIM_STYLE
)
359 TRACE("band info: style=0x%08x (%s)\n", pB
->fStyle
, REBAR_FmtStyle(buff
, pB
->fStyle
));
360 if (pB
->fMask
& (RBBIM_SIZE
| RBBIM_IDEALSIZE
| RBBIM_HEADERSIZE
| RBBIM_LPARAM
)) {
362 if (pB
->fMask
& RBBIM_SIZE
)
363 TRACE(" cx=%u", pB
->cx
);
364 if (pB
->fMask
& RBBIM_IDEALSIZE
)
365 TRACE(" xIdeal=%u", pB
->cxIdeal
);
366 if (pB
->fMask
& RBBIM_HEADERSIZE
)
367 TRACE(" xHeader=%u", pB
->cxHeader
);
368 if (pB
->fMask
& RBBIM_LPARAM
)
369 TRACE(" lParam=0x%08lx", pB
->lParam
);
372 if (pB
->fMask
& RBBIM_CHILDSIZE
)
373 TRACE("band info: xMin=%u, yMin=%u, yChild=%u, yMax=%u, yIntgl=%u\n",
375 pB
->cyMinChild
, pB
->cyChild
, pB
->cyMaxChild
, pB
->cyIntegral
);
379 REBAR_DumpBand (const REBAR_INFO
*iP
)
385 if(! TRACE_ON(rebar
) ) return;
387 TRACE("hwnd=%p: color=%08x/%08x, bands=%u, rows=%u, cSize=%d,%d\n",
388 iP
->hwndSelf
, iP
->clrText
, iP
->clrBk
, iP
->uNumBands
, iP
->uNumRows
,
389 iP
->calcSize
.cx
, iP
->calcSize
.cy
);
390 TRACE("hwnd=%p: flags=%08x, dragStart=%d,%d, dragNow=%d,%d, iGrabbedBand=%d\n",
391 iP
->hwndSelf
, iP
->fStatus
, iP
->dragStart
.x
, iP
->dragStart
.y
,
392 iP
->dragNow
.x
, iP
->dragNow
.y
,
394 TRACE("hwnd=%p: style=%08x, notify in Unicode=%s, redraw=%s\n",
395 iP
->hwndSelf
, iP
->dwStyle
, (iP
->bUnicode
)?"TRUE":"FALSE",
396 (iP
->DoRedraw
)?"TRUE":"FALSE");
397 for (i
= 0; i
< iP
->uNumBands
; i
++) {
398 pB
= REBAR_GetBand(iP
, i
);
399 TRACE("band # %u:", i
);
400 if (pB
->fMask
& RBBIM_ID
)
401 TRACE(" ID=%u", pB
->wID
);
402 if (pB
->fMask
& RBBIM_CHILD
)
403 TRACE(" child=%p", pB
->hwndChild
);
404 if (pB
->fMask
& RBBIM_COLORS
)
405 TRACE(" clrF=0x%06x clrB=0x%06x", pB
->clrFore
, pB
->clrBack
);
407 TRACE("band # %u: mask=0x%08x (%s)\n", i
, pB
->fMask
, REBAR_FmtMask(buff
, pB
->fMask
));
408 if (pB
->fMask
& RBBIM_STYLE
)
409 TRACE("band # %u: style=0x%08x (%s)\n", i
, pB
->fStyle
, REBAR_FmtStyle(buff
, pB
->fStyle
));
410 TRACE("band # %u: xHeader=%u",
412 if (pB
->fMask
& (RBBIM_SIZE
| RBBIM_IDEALSIZE
| RBBIM_LPARAM
)) {
413 if (pB
->fMask
& RBBIM_SIZE
)
414 TRACE(" cx=%u", pB
->cx
);
415 if (pB
->fMask
& RBBIM_IDEALSIZE
)
416 TRACE(" xIdeal=%u", pB
->cxIdeal
);
417 if (pB
->fMask
& RBBIM_LPARAM
)
418 TRACE(" lParam=0x%08lx", pB
->lParam
);
422 TRACE("band # %u: xMin=%u, yMin=%u, yChild=%u, yMax=%u, yIntgl=%u\n",
423 i
, pB
->cxMinChild
, pB
->cyMinChild
, pB
->cyChild
, pB
->cyMaxChild
, pB
->cyIntegral
);
424 if (pB
->fMask
& RBBIM_TEXT
)
425 TRACE("band # %u: text=%s\n",
426 i
, (pB
->lpText
) ? debugstr_w(pB
->lpText
) : "(null)");
427 TRACE("band # %u: cxMinBand=%u, cxEffective=%u, cyMinBand=%u\n",
428 i
, pB
->cxMinBand
, pB
->cxEffective
, pB
->cyMinBand
);
429 TRACE("band # %u: fStatus=%08x, fDraw=%08x, Band=(%s), Grip=(%s)\n",
430 i
, pB
->fStatus
, pB
->fDraw
, wine_dbgstr_rect(&pB
->rcBand
),
431 wine_dbgstr_rect(&pB
->rcGripper
));
432 TRACE("band # %u: Img=(%s), Txt=(%s), Child=(%s)\n",
433 i
, wine_dbgstr_rect(&pB
->rcCapImage
),
434 wine_dbgstr_rect(&pB
->rcCapText
), wine_dbgstr_rect(&pB
->rcChild
));
439 /* dest can be equal to src */
440 static void translate_rect(const REBAR_INFO
*infoPtr
, RECT
*dest
, const RECT
*src
)
442 if (infoPtr
->dwStyle
& CCS_VERT
) {
445 dest
->left
= src
->top
;
449 dest
->right
= src
->bottom
;
456 static int get_rect_cx(const REBAR_INFO
*infoPtr
, const RECT
*lpRect
)
458 if (infoPtr
->dwStyle
& CCS_VERT
)
459 return lpRect
->bottom
- lpRect
->top
;
460 return lpRect
->right
- lpRect
->left
;
463 static int get_rect_cy(const REBAR_INFO
*infoPtr
, const RECT
*lpRect
)
465 if (infoPtr
->dwStyle
& CCS_VERT
)
466 return lpRect
->right
- lpRect
->left
;
467 return lpRect
->bottom
- lpRect
->top
;
470 static int round_child_height(const REBAR_BAND
*lpBand
, int cyHeight
)
473 if (lpBand
->cyIntegral
== 0)
475 cy
= max(cyHeight
- (int)lpBand
->cyMinChild
, 0);
476 cy
= lpBand
->cyMinChild
+ (cy
/lpBand
->cyIntegral
) * lpBand
->cyIntegral
;
477 cy
= min(cy
, lpBand
->cyMaxChild
);
481 static void update_min_band_height(const REBAR_INFO
*infoPtr
, REBAR_BAND
*lpBand
)
483 lpBand
->cyMinBand
= max(lpBand
->cyHeader
,
484 (lpBand
->hwndChild
? lpBand
->cyChild
+ REBARSPACE(lpBand
) : REBAR_NO_CHILD_HEIGHT
));
488 REBAR_DrawChevron (HDC hdc
, INT left
, INT top
, INT colorRef
)
493 if (!(hPen
= CreatePen( PS_SOLID
, 1, GetSysColor( colorRef
)))) return;
494 hOldPen
= SelectObject ( hdc
, hPen
);
497 MoveToEx (hdc
, x
, y
, NULL
);
498 LineTo (hdc
, x
+5, y
++); x
++;
499 MoveToEx (hdc
, x
, y
, NULL
);
500 LineTo (hdc
, x
+3, y
++); x
++;
501 MoveToEx (hdc
, x
, y
, NULL
);
502 LineTo (hdc
, x
+1, y
);
503 SelectObject( hdc
, hOldPen
);
504 DeleteObject( hPen
);
508 REBAR_GetNotifyParent (const REBAR_INFO
*infoPtr
)
512 parent
= infoPtr
->hwndNotify
;
514 parent
= GetParent (infoPtr
->hwndSelf
);
515 owner
= GetWindow (infoPtr
->hwndSelf
, GW_OWNER
);
516 if (owner
) parent
= owner
;
523 REBAR_Notify (NMHDR
*nmhdr
, const REBAR_INFO
*infoPtr
, UINT code
)
527 parent
= REBAR_GetNotifyParent (infoPtr
);
528 nmhdr
->idFrom
= GetDlgCtrlID (infoPtr
->hwndSelf
);
529 nmhdr
->hwndFrom
= infoPtr
->hwndSelf
;
532 TRACE("window %p, code=%08x, via %s\n", parent
, code
, (infoPtr
->bUnicode
)?"Unicode":"ANSI");
534 return SendMessageW(parent
, WM_NOTIFY
, nmhdr
->idFrom
, (LPARAM
)nmhdr
);
538 REBAR_Notify_NMREBAR (const REBAR_INFO
*infoPtr
, UINT uBand
, UINT code
)
540 NMREBAR notify_rebar
;
542 notify_rebar
.dwMask
= 0;
544 REBAR_BAND
*lpBand
= REBAR_GetBand(infoPtr
, uBand
);
546 if (lpBand
->fMask
& RBBIM_ID
) {
547 notify_rebar
.dwMask
|= RBNM_ID
;
548 notify_rebar
.wID
= lpBand
->wID
;
550 if (lpBand
->fMask
& RBBIM_LPARAM
) {
551 notify_rebar
.dwMask
|= RBNM_LPARAM
;
552 notify_rebar
.lParam
= lpBand
->lParam
;
554 if (lpBand
->fMask
& RBBIM_STYLE
) {
555 notify_rebar
.dwMask
|= RBNM_STYLE
;
556 notify_rebar
.fStyle
= lpBand
->fStyle
;
559 notify_rebar
.uBand
= uBand
;
560 return REBAR_Notify ((NMHDR
*)¬ify_rebar
, infoPtr
, code
);
564 REBAR_DrawBand (HDC hdc
, const REBAR_INFO
*infoPtr
, REBAR_BAND
*lpBand
)
569 HTHEME theme
= GetWindowTheme (infoPtr
->hwndSelf
);
572 translate_rect(infoPtr
, &rcBand
, &lpBand
->rcBand
);
574 if (lpBand
->fDraw
& DRAW_TEXT
) {
575 hOldFont
= SelectObject (hdc
, infoPtr
->hFont
);
576 oldBkMode
= SetBkMode (hdc
, TRANSPARENT
);
579 /* should test for CDRF_NOTIFYITEMDRAW here */
580 nmcd
.dwDrawStage
= CDDS_ITEMPREPAINT
;
583 nmcd
.rc
.right
= lpBand
->rcCapText
.right
;
584 nmcd
.rc
.bottom
= lpBand
->rcCapText
.bottom
;
585 nmcd
.dwItemSpec
= lpBand
->wID
;
587 nmcd
.lItemlParam
= lpBand
->lParam
;
588 lpBand
->uCDret
= REBAR_Notify ((NMHDR
*)&nmcd
, infoPtr
, NM_CUSTOMDRAW
);
589 if (lpBand
->uCDret
== CDRF_SKIPDEFAULT
) {
590 if (oldBkMode
!= TRANSPARENT
)
591 SetBkMode (hdc
, oldBkMode
);
592 SelectObject (hdc
, hOldFont
);
597 if (lpBand
->fDraw
& DRAW_GRIPPER
)
601 RECT rcGripper
= lpBand
->rcGripper
;
602 int partId
= (infoPtr
->dwStyle
& CCS_VERT
) ? RP_GRIPPERVERT
: RP_GRIPPER
;
603 GetThemeBackgroundExtent (theme
, hdc
, partId
, 0, &rcGripper
, &rcGripper
);
604 OffsetRect (&rcGripper
, lpBand
->rcGripper
.left
- rcGripper
.left
,
605 lpBand
->rcGripper
.top
- rcGripper
.top
);
606 DrawThemeBackground (theme
, hdc
, partId
, 0, &rcGripper
, NULL
);
609 DrawEdge (hdc
, &lpBand
->rcGripper
, BDR_RAISEDINNER
, BF_RECT
| BF_MIDDLE
);
612 /* draw caption image */
613 if (lpBand
->fDraw
& DRAW_IMAGE
) {
617 pt
.y
= (lpBand
->rcCapImage
.bottom
+ lpBand
->rcCapImage
.top
- infoPtr
->imageSize
.cy
)/2;
618 pt
.x
= (lpBand
->rcCapImage
.right
+ lpBand
->rcCapImage
.left
- infoPtr
->imageSize
.cx
)/2;
620 ImageList_Draw (infoPtr
->himl
, lpBand
->iImage
, hdc
,
625 /* draw caption text */
626 if (lpBand
->fDraw
& DRAW_TEXT
) {
627 /* need to handle CDRF_NEWFONT here */
628 INT oldBkMode
= SetBkMode (hdc
, TRANSPARENT
);
629 COLORREF oldcolor
= CLR_NONE
;
631 if (lpBand
->clrFore
!= CLR_NONE
) {
632 new = (lpBand
->clrFore
== CLR_DEFAULT
) ? infoPtr
->clrBtnText
:
634 oldcolor
= SetTextColor (hdc
, new);
636 DrawTextW (hdc
, lpBand
->lpText
, -1, &lpBand
->rcCapText
,
637 DT_CENTER
| DT_VCENTER
| DT_SINGLELINE
);
638 if (oldBkMode
!= TRANSPARENT
)
639 SetBkMode (hdc
, oldBkMode
);
640 if (lpBand
->clrFore
!= CLR_NONE
)
641 SetTextColor (hdc
, oldcolor
);
642 SelectObject (hdc
, hOldFont
);
645 if (!IsRectEmpty(&lpBand
->rcChevron
))
650 if (lpBand
->fDraw
& DRAW_CHEVRONPUSHED
)
651 stateId
= CHEVS_PRESSED
;
652 else if (lpBand
->fDraw
& DRAW_CHEVRONHOT
)
655 stateId
= CHEVS_NORMAL
;
656 DrawThemeBackground (theme
, hdc
, RP_CHEVRON
, stateId
, &lpBand
->rcChevron
, NULL
);
660 if (lpBand
->fDraw
& DRAW_CHEVRONPUSHED
)
662 DrawEdge(hdc
, &lpBand
->rcChevron
, BDR_SUNKENOUTER
, BF_RECT
| BF_MIDDLE
);
663 REBAR_DrawChevron(hdc
, lpBand
->rcChevron
.left
+1, lpBand
->rcChevron
.top
+ 11, COLOR_WINDOWFRAME
);
665 else if (lpBand
->fDraw
& DRAW_CHEVRONHOT
)
667 DrawEdge(hdc
, &lpBand
->rcChevron
, BDR_RAISEDINNER
, BF_RECT
| BF_MIDDLE
);
668 REBAR_DrawChevron(hdc
, lpBand
->rcChevron
.left
, lpBand
->rcChevron
.top
+ 10, COLOR_WINDOWFRAME
);
671 REBAR_DrawChevron(hdc
, lpBand
->rcChevron
.left
, lpBand
->rcChevron
.top
+ 10, COLOR_WINDOWFRAME
);
675 if (lpBand
->uCDret
== (CDRF_NOTIFYPOSTPAINT
| CDRF_NOTIFYITEMDRAW
)) {
676 nmcd
.dwDrawStage
= CDDS_ITEMPOSTPAINT
;
679 nmcd
.rc
.right
= lpBand
->rcCapText
.right
;
680 nmcd
.rc
.bottom
= lpBand
->rcCapText
.bottom
;
681 nmcd
.dwItemSpec
= lpBand
->wID
;
683 nmcd
.lItemlParam
= lpBand
->lParam
;
684 lpBand
->uCDret
= REBAR_Notify ((NMHDR
*)&nmcd
, infoPtr
, NM_CUSTOMDRAW
);
690 REBAR_Refresh (const REBAR_INFO
*infoPtr
, HDC hdc
)
695 if (!infoPtr
->DoRedraw
) return;
697 for (i
= 0; i
< infoPtr
->uNumBands
; i
++) {
698 lpBand
= REBAR_GetBand(infoPtr
, i
);
700 if (HIDDENBAND(lpBand
)) continue;
702 /* now draw the band */
703 TRACE("[%p] drawing band %i, flags=%08x\n",
704 infoPtr
->hwndSelf
, i
, lpBand
->fDraw
);
705 REBAR_DrawBand (hdc
, infoPtr
, lpBand
);
711 REBAR_CalcHorzBand (const REBAR_INFO
*infoPtr
, UINT rstart
, UINT rend
)
712 /* Function: this routine initializes all the rectangles in */
713 /* each band in a row to fit in the adjusted rcBand rect. */
714 /* *** Supports only Horizontal bars. *** */
720 for(i
=rstart
; i
<rend
; i
++){
721 lpBand
= REBAR_GetBand(infoPtr
, i
);
722 if (HIDDENBAND(lpBand
)) {
723 SetRect (&lpBand
->rcChild
,
724 lpBand
->rcBand
.right
, lpBand
->rcBand
.top
,
725 lpBand
->rcBand
.right
, lpBand
->rcBand
.bottom
);
729 /* set initial gripper rectangle */
730 SetRect (&lpBand
->rcGripper
, lpBand
->rcBand
.left
, lpBand
->rcBand
.top
,
731 lpBand
->rcBand
.left
, lpBand
->rcBand
.bottom
);
733 /* calculate gripper rectangle */
734 if ( lpBand
->fStatus
& HAS_GRIPPER
) {
735 lpBand
->fDraw
|= DRAW_GRIPPER
;
736 lpBand
->rcGripper
.left
+= REBAR_PRE_GRIPPER
;
737 lpBand
->rcGripper
.right
= lpBand
->rcGripper
.left
+ GRIPPER_WIDTH
;
738 InflateRect(&lpBand
->rcGripper
, 0, -2);
740 SetRect (&lpBand
->rcCapImage
,
741 lpBand
->rcGripper
.right
+REBAR_ALWAYS_SPACE
, lpBand
->rcBand
.top
,
742 lpBand
->rcGripper
.right
+REBAR_ALWAYS_SPACE
, lpBand
->rcBand
.bottom
);
744 else { /* no gripper will be drawn */
746 if (lpBand
->fStatus
& (HAS_IMAGE
| HAS_TEXT
))
747 /* if no gripper but either image or text, then leave space */
748 xoff
= REBAR_ALWAYS_SPACE
;
749 SetRect (&lpBand
->rcCapImage
,
750 lpBand
->rcBand
.left
+xoff
, lpBand
->rcBand
.top
,
751 lpBand
->rcBand
.left
+xoff
, lpBand
->rcBand
.bottom
);
754 /* image is visible */
755 if (lpBand
->fStatus
& HAS_IMAGE
) {
756 lpBand
->fDraw
|= DRAW_IMAGE
;
757 lpBand
->rcCapImage
.right
+= infoPtr
->imageSize
.cx
;
758 lpBand
->rcCapImage
.bottom
= lpBand
->rcCapImage
.top
+ infoPtr
->imageSize
.cy
;
760 /* set initial caption text rectangle */
761 SetRect (&lpBand
->rcCapText
,
762 lpBand
->rcCapImage
.right
+REBAR_POST_IMAGE
, lpBand
->rcBand
.top
+1,
763 lpBand
->rcBand
.left
+lpBand
->cxHeader
, lpBand
->rcBand
.bottom
-1);
766 /* set initial caption text rectangle */
767 SetRect (&lpBand
->rcCapText
, lpBand
->rcCapImage
.right
, lpBand
->rcBand
.top
+1,
768 lpBand
->rcBand
.left
+lpBand
->cxHeader
, lpBand
->rcBand
.bottom
-1);
771 /* text is visible */
772 if ((lpBand
->fStatus
& HAS_TEXT
) && !(lpBand
->fStyle
& RBBS_HIDETITLE
)) {
773 lpBand
->fDraw
|= DRAW_TEXT
;
774 lpBand
->rcCapText
.right
= max(lpBand
->rcCapText
.left
,
775 lpBand
->rcCapText
.right
-REBAR_POST_TEXT
);
778 /* set initial child window rectangle if there is a child */
779 if (lpBand
->hwndChild
) {
781 lpBand
->rcChild
.left
= lpBand
->rcBand
.left
+ lpBand
->cxHeader
;
782 lpBand
->rcChild
.right
= lpBand
->rcBand
.right
- REBAR_POST_CHILD
;
784 if (lpBand
->cyChild
> 0) {
786 UINT yoff
= (lpBand
->rcBand
.bottom
- lpBand
->rcBand
.top
- lpBand
->cyChild
) / 2;
788 /* center child if height is known */
789 lpBand
->rcChild
.top
= lpBand
->rcBand
.top
+ yoff
;
790 lpBand
->rcChild
.bottom
= lpBand
->rcBand
.top
+ yoff
+ lpBand
->cyChild
;
793 lpBand
->rcChild
.top
= lpBand
->rcBand
.top
;
794 lpBand
->rcChild
.bottom
= lpBand
->rcBand
.bottom
;
797 if ((lpBand
->fStyle
& RBBS_USECHEVRON
) && (lpBand
->rcChild
.right
- lpBand
->rcChild
.left
< lpBand
->cxIdeal
))
799 lpBand
->rcChild
.right
-= CHEVRON_WIDTH
;
800 SetRect(&lpBand
->rcChevron
, lpBand
->rcChild
.right
,
801 lpBand
->rcChild
.top
, lpBand
->rcChild
.right
+ CHEVRON_WIDTH
,
802 lpBand
->rcChild
.bottom
);
806 SetRect (&lpBand
->rcChild
,
807 lpBand
->rcBand
.left
+lpBand
->cxHeader
, lpBand
->rcBand
.top
,
808 lpBand
->rcBand
.right
, lpBand
->rcBand
.bottom
);
811 /* flag if notify required and invalidate rectangle */
812 if (lpBand
->fDraw
& NTF_INVALIDATE
) {
813 lpBand
->fDraw
&= ~NTF_INVALIDATE
;
814 work
= lpBand
->rcBand
;
815 work
.right
+= SEP_WIDTH
;
816 work
.bottom
+= SEP_WIDTH
;
817 TRACE("invalidating %s\n", wine_dbgstr_rect(&work
));
818 InvalidateRect(infoPtr
->hwndSelf
, &work
, TRUE
);
819 if (lpBand
->hwndChild
) InvalidateRect(lpBand
->hwndChild
, NULL
, TRUE
);
828 REBAR_CalcVertBand (const REBAR_INFO
*infoPtr
, UINT rstart
, UINT rend
)
829 /* Function: this routine initializes all the rectangles in */
830 /* each band in a row to fit in the adjusted rcBand rect. */
831 /* *** Supports only Vertical bars. *** */
837 for(i
=rstart
; i
<rend
; i
++){
839 lpBand
= REBAR_GetBand(infoPtr
, i
);
840 if (HIDDENBAND(lpBand
)) continue;
842 translate_rect(infoPtr
, &rcBand
, &lpBand
->rcBand
);
844 /* set initial gripper rectangle */
845 SetRect (&lpBand
->rcGripper
, rcBand
.left
, rcBand
.top
, rcBand
.right
, rcBand
.top
);
847 /* calculate gripper rectangle */
848 if (lpBand
->fStatus
& HAS_GRIPPER
) {
849 lpBand
->fDraw
|= DRAW_GRIPPER
;
851 if (infoPtr
->dwStyle
& RBS_VERTICALGRIPPER
) {
852 /* vertical gripper */
853 lpBand
->rcGripper
.left
+= 3;
854 lpBand
->rcGripper
.right
= lpBand
->rcGripper
.left
+ GRIPPER_WIDTH
;
855 lpBand
->rcGripper
.top
+= REBAR_PRE_GRIPPER
;
856 lpBand
->rcGripper
.bottom
= lpBand
->rcGripper
.top
+ GRIPPER_HEIGHT
;
858 /* initialize Caption image rectangle */
859 SetRect (&lpBand
->rcCapImage
, rcBand
.left
,
860 lpBand
->rcGripper
.bottom
+ REBAR_ALWAYS_SPACE
,
862 lpBand
->rcGripper
.bottom
+ REBAR_ALWAYS_SPACE
);
865 /* horizontal gripper */
866 InflateRect(&lpBand
->rcGripper
, -2, 0);
867 lpBand
->rcGripper
.top
+= REBAR_PRE_GRIPPER
;
868 lpBand
->rcGripper
.bottom
= lpBand
->rcGripper
.top
+ GRIPPER_WIDTH
;
870 /* initialize Caption image rectangle */
871 SetRect (&lpBand
->rcCapImage
, rcBand
.left
,
872 lpBand
->rcGripper
.bottom
+ REBAR_ALWAYS_SPACE
,
874 lpBand
->rcGripper
.bottom
+ REBAR_ALWAYS_SPACE
);
877 else { /* no gripper will be drawn */
879 if (lpBand
->fStatus
& (HAS_IMAGE
| HAS_TEXT
))
880 /* if no gripper but either image or text, then leave space */
881 xoff
= REBAR_ALWAYS_SPACE
;
882 /* initialize Caption image rectangle */
883 SetRect (&lpBand
->rcCapImage
,
884 rcBand
.left
, rcBand
.top
+xoff
,
885 rcBand
.right
, rcBand
.top
+xoff
);
888 /* image is visible */
889 if (lpBand
->fStatus
& HAS_IMAGE
) {
890 lpBand
->fDraw
|= DRAW_IMAGE
;
892 lpBand
->rcCapImage
.right
= lpBand
->rcCapImage
.left
+ infoPtr
->imageSize
.cx
;
893 lpBand
->rcCapImage
.bottom
+= infoPtr
->imageSize
.cy
;
895 /* set initial caption text rectangle */
896 SetRect (&lpBand
->rcCapText
,
897 rcBand
.left
, lpBand
->rcCapImage
.bottom
+REBAR_POST_IMAGE
,
898 rcBand
.right
, rcBand
.top
+lpBand
->cxHeader
);
901 /* set initial caption text rectangle */
902 SetRect (&lpBand
->rcCapText
,
903 rcBand
.left
, lpBand
->rcCapImage
.bottom
,
904 rcBand
.right
, rcBand
.top
+lpBand
->cxHeader
);
907 /* text is visible */
908 if ((lpBand
->fStatus
& HAS_TEXT
) && !(lpBand
->fStyle
& RBBS_HIDETITLE
)) {
909 lpBand
->fDraw
|= DRAW_TEXT
;
910 lpBand
->rcCapText
.bottom
= max(lpBand
->rcCapText
.top
,
911 lpBand
->rcCapText
.bottom
);
914 /* set initial child window rectangle if there is a child */
915 if (lpBand
->hwndChild
) {
916 int cxBand
= rcBand
.right
- rcBand
.left
;
917 xoff
= (cxBand
- lpBand
->cyChild
) / 2;
918 SetRect (&lpBand
->rcChild
,
919 rcBand
.left
+ xoff
, rcBand
.top
+ lpBand
->cxHeader
,
920 rcBand
.left
+ xoff
+ lpBand
->cyChild
, rcBand
.bottom
- REBAR_POST_CHILD
);
923 SetRect (&lpBand
->rcChild
,
924 rcBand
.left
, rcBand
.top
+lpBand
->cxHeader
,
925 rcBand
.right
, rcBand
.bottom
);
928 if (lpBand
->fDraw
& NTF_INVALIDATE
) {
929 lpBand
->fDraw
&= ~NTF_INVALIDATE
;
931 work
.bottom
+= SEP_WIDTH
;
932 work
.right
+= SEP_WIDTH
;
933 TRACE("invalidating %s\n", wine_dbgstr_rect(&work
));
934 InvalidateRect(infoPtr
->hwndSelf
, &work
, TRUE
);
935 if (lpBand
->hwndChild
) InvalidateRect(lpBand
->hwndChild
, NULL
, TRUE
);
943 REBAR_ForceResize (REBAR_INFO
*infoPtr
)
944 /* Function: This changes the size of the REBAR window to that */
945 /* calculated by REBAR_Layout. */
947 INT x
, y
, width
, height
;
948 INT xedge
= 0, yedge
= 0;
951 TRACE("new size [%d x %d]\n", infoPtr
->calcSize
.cx
, infoPtr
->calcSize
.cy
);
953 if (infoPtr
->dwStyle
& CCS_NORESIZE
)
956 if (infoPtr
->dwStyle
& WS_BORDER
)
958 xedge
= GetSystemMetrics(SM_CXEDGE
);
959 yedge
= GetSystemMetrics(SM_CYEDGE
);
960 /* swap for CCS_VERT? */
963 /* compute rebar window rect in parent client coordinates */
964 GetWindowRect(infoPtr
->hwndSelf
, &rcSelf
);
965 MapWindowPoints(HWND_DESKTOP
, GetParent(infoPtr
->hwndSelf
), (LPPOINT
)&rcSelf
, 2);
966 translate_rect(infoPtr
, &rcSelf
, &rcSelf
);
968 height
= infoPtr
->calcSize
.cy
+ 2*yedge
;
969 if (!(infoPtr
->dwStyle
& CCS_NOPARENTALIGN
)) {
973 width
= infoPtr
->calcSize
.cx
+ 2*xedge
;
974 y
= 0; /* quiet compiler warning */
975 switch ( infoPtr
->dwStyle
& CCS_LAYOUT_MASK
) {
976 case 0: /* shouldn't happen - see NCCreate */
978 y
= ((infoPtr
->dwStyle
& CCS_NODIVIDER
) ? 0 : REBAR_DIVIDER
) - yedge
;
984 GetClientRect(GetParent(infoPtr
->hwndSelf
), &rcParent
);
985 translate_rect(infoPtr
, &rcParent
, &rcParent
);
986 y
= rcParent
.bottom
- infoPtr
->calcSize
.cy
- yedge
;
992 /* As on Windows if the CCS_NODIVIDER is not present the control will move
993 * 2 pixel down after every layout */
994 y
= rcSelf
.top
+ ((infoPtr
->dwStyle
& CCS_NODIVIDER
) ? 0 : REBAR_DIVIDER
);
995 width
= rcSelf
.right
- rcSelf
.left
;
998 TRACE("hwnd %p, style=%08x, setting at (%d,%d) for (%d,%d)\n",
999 infoPtr
->hwndSelf
, infoPtr
->dwStyle
, x
, y
, width
, height
);
1001 /* Set flag to ignore next WM_SIZE message and resize the window */
1002 infoPtr
->fStatus
|= SELF_RESIZE
;
1003 if ((infoPtr
->dwStyle
& CCS_VERT
) == 0)
1004 SetWindowPos(infoPtr
->hwndSelf
, 0, x
, y
, width
, height
, SWP_NOZORDER
);
1006 SetWindowPos(infoPtr
->hwndSelf
, 0, y
, x
, height
, width
, SWP_NOZORDER
);
1007 infoPtr
->fStatus
&= ~SELF_RESIZE
;
1012 REBAR_MoveChildWindows (const REBAR_INFO
*infoPtr
, UINT start
, UINT endplus
)
1014 static const WCHAR strComboBox
[] = { 'C','o','m','b','o','B','o','x',0 };
1016 WCHAR szClassName
[40];
1018 NMREBARCHILDSIZE rbcz
;
1021 if (!(deferpos
= BeginDeferWindowPos(infoPtr
->uNumBands
)))
1022 ERR("BeginDeferWindowPos returned NULL\n");
1024 for (i
= start
; i
< endplus
; i
++) {
1025 lpBand
= REBAR_GetBand(infoPtr
, i
);
1027 if (HIDDENBAND(lpBand
)) continue;
1028 if (lpBand
->hwndChild
) {
1029 TRACE("hwndChild = %p\n", lpBand
->hwndChild
);
1031 /* Always generate the RBN_CHILDSIZE even if child
1034 rbcz
.wID
= lpBand
->wID
;
1035 rbcz
.rcChild
= lpBand
->rcChild
;
1036 translate_rect(infoPtr
, &rbcz
.rcBand
, &lpBand
->rcBand
);
1037 if (infoPtr
->dwStyle
& CCS_VERT
)
1038 rbcz
.rcBand
.top
+= lpBand
->cxHeader
;
1040 rbcz
.rcBand
.left
+= lpBand
->cxHeader
;
1041 REBAR_Notify ((NMHDR
*)&rbcz
, infoPtr
, RBN_CHILDSIZE
);
1042 if (!EqualRect (&lpBand
->rcChild
, &rbcz
.rcChild
)) {
1043 TRACE("Child rect changed by NOTIFY for band %u\n", i
);
1044 TRACE(" from (%s) to (%s)\n",
1045 wine_dbgstr_rect(&lpBand
->rcChild
),
1046 wine_dbgstr_rect(&rbcz
.rcChild
));
1047 lpBand
->rcChild
= rbcz
.rcChild
; /* *** ??? */
1050 GetClassNameW (lpBand
->hwndChild
, szClassName
, ARRAY_SIZE(szClassName
));
1051 if (!lstrcmpW (szClassName
, strComboBox
) ||
1052 !lstrcmpW (szClassName
, WC_COMBOBOXEXW
)) {
1053 INT nEditHeight
, yPos
;
1056 /* special placement code for combo or comboex box */
1059 /* get size of edit line */
1060 GetWindowRect (lpBand
->hwndChild
, &rc
);
1061 nEditHeight
= rc
.bottom
- rc
.top
;
1062 yPos
= (lpBand
->rcChild
.bottom
+ lpBand
->rcChild
.top
- nEditHeight
)/2;
1064 /* center combo box inside child area */
1065 TRACE("moving child (Combo(Ex)) %p to (%d,%d) for (%d,%d)\n",
1067 lpBand
->rcChild
.left
, yPos
,
1068 lpBand
->rcChild
.right
- lpBand
->rcChild
.left
,
1070 deferpos
= DeferWindowPos (deferpos
, lpBand
->hwndChild
, HWND_TOP
,
1071 lpBand
->rcChild
.left
,
1072 /*lpBand->rcChild.top*/ yPos
,
1073 lpBand
->rcChild
.right
- lpBand
->rcChild
.left
,
1077 ERR("DeferWindowPos returned NULL\n");
1080 TRACE("moving child (Other) %p to (%d,%d) for (%d,%d)\n",
1082 lpBand
->rcChild
.left
, lpBand
->rcChild
.top
,
1083 lpBand
->rcChild
.right
- lpBand
->rcChild
.left
,
1084 lpBand
->rcChild
.bottom
- lpBand
->rcChild
.top
);
1085 deferpos
= DeferWindowPos (deferpos
, lpBand
->hwndChild
, HWND_TOP
,
1086 lpBand
->rcChild
.left
,
1087 lpBand
->rcChild
.top
,
1088 lpBand
->rcChild
.right
- lpBand
->rcChild
.left
,
1089 lpBand
->rcChild
.bottom
- lpBand
->rcChild
.top
,
1092 ERR("DeferWindowPos returned NULL\n");
1096 if (!EndDeferWindowPos(deferpos
))
1097 ERR("EndDeferWindowPos returned NULL\n");
1099 if (infoPtr
->DoRedraw
)
1100 UpdateWindow (infoPtr
->hwndSelf
);
1103 /* Returns the next visible band (the first visible band in [i+1; infoPtr->uNumBands) )
1104 * or infoPtr->uNumBands if none */
1105 static int next_visible(const REBAR_INFO
*infoPtr
, int i
)
1108 for (n
= i
+ 1; n
< infoPtr
->uNumBands
; n
++)
1109 if (!HIDDENBAND(REBAR_GetBand(infoPtr
, n
)))
1114 /* Returns the previous visible band (the last visible band in [0; i) )
1116 static int prev_visible(const REBAR_INFO
*infoPtr
, int i
)
1119 for (n
= i
- 1; n
>= 0; n
--)
1120 if (!HIDDENBAND(REBAR_GetBand(infoPtr
, n
)))
1125 /* Returns the first visible band or infoPtr->uNumBands if none */
1126 static int first_visible(const REBAR_INFO
*infoPtr
)
1128 return next_visible(infoPtr
, -1); /* this works*/
1131 /* Returns the first visible band for the given row (or iBand if none) */
1132 static int get_row_begin_for_band(const REBAR_INFO
*infoPtr
, INT iBand
)
1134 int iLastBand
= iBand
;
1135 int iRow
= REBAR_GetBand(infoPtr
, iBand
)->iRow
;
1136 while ((iBand
= prev_visible(infoPtr
, iBand
)) >= 0) {
1137 if (REBAR_GetBand(infoPtr
, iBand
)->iRow
!= iRow
)
1145 /* Returns the first visible band for the next row (or infoPtr->uNumBands if none) */
1146 static int get_row_end_for_band(const REBAR_INFO
*infoPtr
, INT iBand
)
1148 int iRow
= REBAR_GetBand(infoPtr
, iBand
)->iRow
;
1149 while ((iBand
= next_visible(infoPtr
, iBand
)) < infoPtr
->uNumBands
)
1150 if (REBAR_GetBand(infoPtr
, iBand
)->iRow
!= iRow
)
1155 /* Compute the rcBand.{left,right} from the cxEffective bands widths computed earlier.
1156 * iBeginBand must be visible */
1157 static void REBAR_SetRowRectsX(const REBAR_INFO
*infoPtr
, INT iBeginBand
, INT iEndBand
)
1160 for (i
= iBeginBand
; i
< iEndBand
; i
= next_visible(infoPtr
, i
))
1162 REBAR_BAND
*lpBand
= REBAR_GetBand(infoPtr
, i
);
1163 if (lpBand
->rcBand
.left
!= xPos
|| lpBand
->rcBand
.right
!= xPos
+ lpBand
->cxEffective
) {
1164 lpBand
->fDraw
|= NTF_INVALIDATE
;
1165 TRACE("Setting rect %d to %d,%d\n", i
, xPos
, xPos
+ lpBand
->cxEffective
);
1166 lpBand
->rcBand
.left
= xPos
;
1167 lpBand
->rcBand
.right
= xPos
+ lpBand
->cxEffective
;
1169 xPos
+= lpBand
->cxEffective
+ SEP_WIDTH
;
1173 /* The rationale of this function is probably as follows: if we have some space
1174 * to distribute we want to add it to a band on the right. However we don't want
1175 * to unminimize a minimized band so we search for a band that is big enough.
1176 * For some reason "big enough" is defined as bigger than the minimum size of the
1177 * first band in the row
1179 static REBAR_BAND
*REBAR_FindBandToGrow(const REBAR_INFO
*infoPtr
, INT iBeginBand
, INT iEndBand
)
1181 INT cxMinFirstBand
= 0, i
;
1183 cxMinFirstBand
= REBAR_GetBand(infoPtr
, iBeginBand
)->cxMinBand
;
1185 for (i
= prev_visible(infoPtr
, iEndBand
); i
>= iBeginBand
; i
= prev_visible(infoPtr
, i
))
1186 if (REBAR_GetBand(infoPtr
, i
)->cxEffective
> cxMinFirstBand
&&
1187 !(REBAR_GetBand(infoPtr
, i
)->fStyle
& RBBS_FIXEDSIZE
))
1191 for (i
= prev_visible(infoPtr
, iEndBand
); i
>= iBeginBand
; i
= prev_visible(infoPtr
, i
))
1192 if (REBAR_GetBand(infoPtr
, i
)->cxMinBand
== cxMinFirstBand
)
1195 TRACE("Extra space for row [%d..%d) should be added to band %d\n", iBeginBand
, iEndBand
, i
);
1196 return REBAR_GetBand(infoPtr
, i
);
1199 /* Try to shrink the visible bands in [iBeginBand; iEndBand) by cxShrink, starting from the right */
1200 static int REBAR_ShrinkBandsRTL(const REBAR_INFO
*infoPtr
, INT iBeginBand
, INT iEndBand
, INT cxShrink
, BOOL bEnforce
)
1205 TRACE("Shrinking bands [%d..%d) by %d, right-to-left\n", iBeginBand
, iEndBand
, cxShrink
);
1206 for (i
= prev_visible(infoPtr
, iEndBand
); i
>= iBeginBand
; i
= prev_visible(infoPtr
, i
))
1208 lpBand
= REBAR_GetBand(infoPtr
, i
);
1210 width
= max(lpBand
->cxEffective
- cxShrink
, (int)lpBand
->cxMinBand
);
1211 cxShrink
-= lpBand
->cxEffective
- width
;
1212 lpBand
->cxEffective
= width
;
1213 if (bEnforce
&& lpBand
->cx
> lpBand
->cxEffective
)
1214 lpBand
->cx
= lpBand
->cxEffective
;
1222 /* Try to shrink the visible bands in [iBeginBand; iEndBand) by cxShrink, starting from the left.
1223 * iBeginBand must be visible */
1224 static int REBAR_ShrinkBandsLTR(const REBAR_INFO
*infoPtr
, INT iBeginBand
, INT iEndBand
, INT cxShrink
, BOOL bEnforce
)
1229 TRACE("Shrinking bands [%d..%d) by %d, left-to-right\n", iBeginBand
, iEndBand
, cxShrink
);
1230 for (i
= iBeginBand
; i
< iEndBand
; i
= next_visible(infoPtr
, i
))
1232 lpBand
= REBAR_GetBand(infoPtr
, i
);
1234 width
= max(lpBand
->cxEffective
- cxShrink
, (int)lpBand
->cxMinBand
);
1235 cxShrink
-= lpBand
->cxEffective
- width
;
1236 lpBand
->cxEffective
= width
;
1238 lpBand
->cx
= lpBand
->cxEffective
;
1245 /* Tries to move a band to a given offset within a row. */
1246 static int REBAR_MoveBandToRowOffset(REBAR_INFO
*infoPtr
, INT iBand
, INT iFirstBand
,
1247 INT iLastBand
, INT xOff
, BOOL reorder
)
1249 REBAR_BAND
*insertBand
= REBAR_GetBand(infoPtr
, iBand
);
1251 const BOOL setBreak
= REBAR_GetBand(infoPtr
, iFirstBand
)->fStyle
& RBBS_BREAK
;
1253 /* Find the band's new position */
1256 /* Used during an LR band reorder drag */
1257 for (i
= iFirstBand
; i
< iLastBand
; i
= next_visible(infoPtr
, i
))
1261 xPos
+= REBAR_GetBand(infoPtr
, i
)->cxEffective
+ SEP_WIDTH
;
1266 /* Used during a UD band insertion drag */
1267 for (i
= iFirstBand
; i
< iLastBand
; i
= next_visible(infoPtr
, i
))
1269 const REBAR_BAND
*band
= REBAR_GetBand(infoPtr
, i
);
1270 if(xPos
+ band
->cxMinBand
/ 2 > xOff
)
1272 xPos
+= band
->cxEffective
+ SEP_WIDTH
;
1276 /* Move the band to its new position */
1277 DPA_DeletePtr(infoPtr
->bands
, iBand
);
1280 DPA_InsertPtr(infoPtr
->bands
, i
, insertBand
);
1282 /* Ensure only the last band has the RBBS_BREAK flag set */
1283 insertBand
->fStyle
&= ~RBBS_BREAK
;
1285 REBAR_GetBand(infoPtr
, iFirstBand
)->fStyle
|= RBBS_BREAK
;
1287 /* Return the currently grabbed band */
1288 if(infoPtr
->iGrabbedBand
== iBand
)
1290 infoPtr
->iGrabbedBand
= i
;
1296 /* Set the heights of the visible bands in [iBeginBand; iEndBand) to the max height. iBeginBand must be visible */
1297 static int REBAR_SetBandsHeight(const REBAR_INFO
*infoPtr
, INT iBeginBand
, INT iEndBand
, INT yStart
)
1302 int row
= REBAR_GetBand(infoPtr
, iBeginBand
)->iRow
;
1304 for (i
= iBeginBand
; i
< iEndBand
; i
= next_visible(infoPtr
, i
))
1306 lpBand
= REBAR_GetBand(infoPtr
, i
);
1307 lpBand
->cyRowSoFar
= yMaxHeight
;
1308 yMaxHeight
= max(yMaxHeight
, lpBand
->cyMinBand
);
1310 TRACE("Bands [%d; %d) height: %d\n", iBeginBand
, iEndBand
, yMaxHeight
);
1312 for (i
= iBeginBand
; i
< iEndBand
; i
= next_visible(infoPtr
, i
))
1314 lpBand
= REBAR_GetBand(infoPtr
, i
);
1315 /* we may be called for multiple rows if RBS_VARHEIGHT not set */
1316 if (lpBand
->iRow
!= row
) {
1317 yPos
+= yMaxHeight
+ SEP_WIDTH
;
1321 if (lpBand
->rcBand
.top
!= yPos
|| lpBand
->rcBand
.bottom
!= yPos
+ yMaxHeight
) {
1322 lpBand
->fDraw
|= NTF_INVALIDATE
;
1323 lpBand
->rcBand
.top
= yPos
;
1324 lpBand
->rcBand
.bottom
= yPos
+ yMaxHeight
;
1325 TRACE("Band %d: %s\n", i
, wine_dbgstr_rect(&lpBand
->rcBand
));
1328 return yPos
+ yMaxHeight
;
1331 /* Layout the row [iBeginBand; iEndBand). iBeginBand must be visible */
1332 static void REBAR_LayoutRow(const REBAR_INFO
*infoPtr
, int iBeginBand
, int iEndBand
, int cx
, int *piRow
, int *pyPos
)
1338 TRACE("Adjusting row [%d;%d). Width: %d\n", iBeginBand
, iEndBand
, cx
);
1339 for (i
= iBeginBand
; i
< iEndBand
; i
++)
1340 REBAR_GetBand(infoPtr
, i
)->iRow
= *piRow
;
1342 /* compute the extra space */
1343 for (i
= iBeginBand
; i
< iEndBand
; i
= next_visible(infoPtr
, i
))
1345 lpBand
= REBAR_GetBand(infoPtr
, i
);
1348 lpBand
->cxEffective
= max(lpBand
->cxMinBand
, lpBand
->cx
);
1349 width
+= lpBand
->cxEffective
;
1353 TRACE("Extra space: %d\n", extra
);
1355 int ret
= REBAR_ShrinkBandsRTL(infoPtr
, iBeginBand
, iEndBand
, -extra
, FALSE
);
1356 if (ret
> 0 && next_visible(infoPtr
, iBeginBand
) != iEndBand
) /* one band may be longer than expected... */
1357 ERR("Error layouting row %d - couldn't shrink for %d pixels (%d total shrink)\n", *piRow
, ret
, -extra
);
1360 lpBand
= REBAR_FindBandToGrow(infoPtr
, iBeginBand
, iEndBand
);
1361 lpBand
->cxEffective
+= extra
;
1364 REBAR_SetRowRectsX(infoPtr
, iBeginBand
, iEndBand
);
1365 if (infoPtr
->dwStyle
& RBS_VARHEIGHT
)
1368 *pyPos
+= SEP_WIDTH
;
1369 *pyPos
= REBAR_SetBandsHeight(infoPtr
, iBeginBand
, iEndBand
, *pyPos
);
1375 REBAR_Layout(REBAR_INFO
*infoPtr
)
1385 if (infoPtr
->dwStyle
& (CCS_NORESIZE
| CCS_NOPARENTALIGN
) || GetParent(infoPtr
->hwndSelf
) == NULL
)
1386 GetClientRect(infoPtr
->hwndSelf
, &rcAdj
);
1388 GetClientRect(GetParent(infoPtr
->hwndSelf
), &rcAdj
);
1389 TRACE("adjustment rect is (%s)\n", wine_dbgstr_rect(&rcAdj
));
1391 adjcx
= get_rect_cx(infoPtr
, &rcAdj
);
1393 if (infoPtr
->uNumBands
== 0) {
1394 TRACE("No bands - setting size to (0,%d), style: %x\n", adjcx
, infoPtr
->dwStyle
);
1395 infoPtr
->calcSize
.cx
= adjcx
;
1396 /* the calcSize.cy won't change for a 0 band rebar */
1397 infoPtr
->uNumRows
= 0;
1398 REBAR_ForceResize(infoPtr
);
1404 rowstart
= first_visible(infoPtr
);
1406 for (i
= rowstart
; i
< infoPtr
->uNumBands
; i
= next_visible(infoPtr
, i
))
1408 lpBand
= REBAR_GetBand(infoPtr
, i
);
1410 if (i
> rowstart
&& (lpBand
->fStyle
& RBBS_BREAK
|| xMin
+ lpBand
->cxMinBand
> adjcx
)) {
1411 TRACE("%s break on band %d\n", (lpBand
->fStyle
& RBBS_BREAK
? "Hard" : "Soft"), i
- 1);
1412 REBAR_LayoutRow(infoPtr
, rowstart
, i
, adjcx
, &row
, &yPos
);
1419 xMin
+= lpBand
->cxMinBand
;
1421 if (rowstart
< infoPtr
->uNumBands
)
1422 REBAR_LayoutRow(infoPtr
, rowstart
, infoPtr
->uNumBands
, adjcx
, &row
, &yPos
);
1424 if (!(infoPtr
->dwStyle
& RBS_VARHEIGHT
))
1425 yPos
= REBAR_SetBandsHeight(infoPtr
, first_visible(infoPtr
), infoPtr
->uNumBands
, 0);
1427 infoPtr
->uNumRows
= row
;
1429 if (infoPtr
->dwStyle
& CCS_VERT
)
1430 REBAR_CalcVertBand(infoPtr
, 0, infoPtr
->uNumBands
);
1432 REBAR_CalcHorzBand(infoPtr
, 0, infoPtr
->uNumBands
);
1433 /* now compute size of Rebar itself */
1434 oldSize
= infoPtr
->calcSize
;
1436 infoPtr
->calcSize
.cx
= adjcx
;
1437 infoPtr
->calcSize
.cy
= yPos
;
1438 TRACE("calcsize size=(%d, %d), origheight=(%d,%d)\n",
1439 infoPtr
->calcSize
.cx
, infoPtr
->calcSize
.cy
,
1440 oldSize
.cx
, oldSize
.cy
);
1442 REBAR_DumpBand (infoPtr
);
1443 REBAR_MoveChildWindows (infoPtr
, 0, infoPtr
->uNumBands
);
1444 REBAR_ForceResize (infoPtr
);
1446 /* note: after a RBN_HEIGHTCHANGE native sends once again all the RBN_CHILDSIZE
1447 * and does another ForceResize */
1448 if (oldSize
.cy
!= infoPtr
->calcSize
.cy
)
1451 REBAR_Notify(&heightchange
, infoPtr
, RBN_HEIGHTCHANGE
);
1452 REBAR_AutoSize(infoPtr
, FALSE
);
1456 /* iBeginBand must be visible */
1458 REBAR_SizeChildrenToHeight(const REBAR_INFO
*infoPtr
, int iBeginBand
, int iEndBand
, int extra
, BOOL
*fChanged
)
1464 TRACE("[%d;%d) by %d\n", iBeginBand
, iEndBand
, extra
);
1466 cyBandsOld
= REBAR_GetBand(infoPtr
, iBeginBand
)->rcBand
.bottom
-
1467 REBAR_GetBand(infoPtr
, iBeginBand
)->rcBand
.top
;
1468 for (i
= iBeginBand
; i
< iEndBand
; i
= next_visible(infoPtr
, i
))
1470 REBAR_BAND
*lpBand
= REBAR_GetBand(infoPtr
, i
);
1471 int cyMaxChild
= cyBandsOld
- REBARSPACE(lpBand
) + extra
;
1472 int cyChild
= round_child_height(lpBand
, cyMaxChild
);
1474 if (lpBand
->hwndChild
&& cyChild
!= lpBand
->cyChild
&& (lpBand
->fStyle
& RBBS_VARIABLEHEIGHT
))
1476 TRACE("Resizing %d: %d -> %d [%d]\n", i
, lpBand
->cyChild
, cyChild
, lpBand
->cyMaxChild
);
1478 lpBand
->cyChild
= cyChild
;
1479 lpBand
->fDraw
|= NTF_INVALIDATE
;
1480 update_min_band_height(infoPtr
, lpBand
);
1482 cyBandsNew
= max(cyBandsNew
, lpBand
->cyMinBand
);
1484 return cyBandsNew
- cyBandsOld
;
1487 /* worker function for RB_SIZETORECT and RBS_AUTOSIZE */
1489 REBAR_SizeToHeight(REBAR_INFO
*infoPtr
, int height
)
1491 int extra
= height
- infoPtr
->calcSize
.cy
; /* may be negative */
1492 BOOL fChanged
= FALSE
;
1493 UINT uNumRows
= infoPtr
->uNumRows
;
1496 if (uNumRows
== 0) /* avoid division by 0 */
1499 /* That's not exactly what Windows does but should be similar */
1501 /* Pass one: break-up/glue rows */
1504 for (i
= prev_visible(infoPtr
, infoPtr
->uNumBands
); i
> 0; i
= prev_visible(infoPtr
, i
))
1506 REBAR_BAND
*lpBand
= REBAR_GetBand(infoPtr
, i
);
1507 int cyBreakExtra
; /* additional cy for the rebar after a RBBS_BREAK on this band */
1509 height
= lpBand
->rcBand
.bottom
- lpBand
->rcBand
.top
;
1511 if (infoPtr
->dwStyle
& RBS_VARHEIGHT
)
1512 cyBreakExtra
= lpBand
->cyRowSoFar
; /* 'height' => 'lpBand->cyRowSoFar' + 'height'*/
1514 cyBreakExtra
= height
; /* 'height' => 'height' + 'height'*/
1515 cyBreakExtra
+= SEP_WIDTH
;
1517 if (extra
<= cyBreakExtra
/ 2)
1520 if (!(lpBand
->fStyle
& RBBS_BREAK
))
1522 TRACE("Adding break on band %d - extra %d -> %d\n", i
, extra
, extra
- cyBreakExtra
);
1523 lpBand
->fStyle
|= RBBS_BREAK
;
1524 lpBand
->fDraw
|= NTF_INVALIDATE
;
1526 extra
-= cyBreakExtra
;
1528 /* temporary change for _SizeControlsToHeight. The true values will be computed in _Layout */
1529 if (infoPtr
->dwStyle
& RBS_VARHEIGHT
)
1530 lpBand
->rcBand
.bottom
= lpBand
->rcBand
.top
+ lpBand
->cyMinBand
;
1534 /* TODO: else if (extra < 0) { try to remove some RBBS_BREAKs } */
1536 /* Pass two: increase/decrease control height */
1537 if (infoPtr
->dwStyle
& RBS_VARHEIGHT
)
1539 int i
= first_visible(infoPtr
);
1541 while (i
< infoPtr
->uNumBands
)
1543 REBAR_BAND
*lpBand
= REBAR_GetBand(infoPtr
, i
);
1544 int extraForRow
= extra
/ (int)(uNumRows
- iRow
);
1547 /* we can't use get_row_end_for_band as we might have added RBBS_BREAK in the first phase */
1548 for (rowEnd
= next_visible(infoPtr
, i
); rowEnd
< infoPtr
->uNumBands
; rowEnd
= next_visible(infoPtr
, rowEnd
))
1549 if (REBAR_GetBand(infoPtr
, rowEnd
)->iRow
!= lpBand
->iRow
||
1550 REBAR_GetBand(infoPtr
, rowEnd
)->fStyle
& RBBS_BREAK
)
1553 extra
-= REBAR_SizeChildrenToHeight(infoPtr
, i
, rowEnd
, extraForRow
, &fChanged
);
1554 TRACE("extra = %d\n", extra
);
1560 REBAR_SizeChildrenToHeight(infoPtr
, first_visible(infoPtr
), infoPtr
->uNumBands
, extra
/ infoPtr
->uNumRows
, &fChanged
);
1563 REBAR_Layout(infoPtr
);
1567 REBAR_AutoSize(REBAR_INFO
*infoPtr
, BOOL needsLayout
)
1570 NMRBAUTOSIZE autosize
;
1573 REBAR_Layout(infoPtr
);
1574 GetClientRect(infoPtr
->hwndSelf
, &rc
);
1575 REBAR_SizeToHeight(infoPtr
, get_rect_cy(infoPtr
, &rc
));
1576 GetClientRect(infoPtr
->hwndSelf
, &rcNew
);
1578 GetClientRect(infoPtr
->hwndSelf
, &autosize
.rcTarget
);
1579 autosize
.fChanged
= EqualRect(&rc
, &rcNew
);
1580 autosize
.rcTarget
= rc
;
1581 autosize
.rcActual
= rcNew
;
1582 REBAR_Notify((NMHDR
*)&autosize
, infoPtr
, RBN_AUTOSIZE
);
1586 REBAR_ValidateBand (const REBAR_INFO
*infoPtr
, REBAR_BAND
*lpBand
)
1587 /* Function: This routine evaluates the band specs supplied */
1588 /* by the user and updates the following 5 fields in */
1589 /* the internal band structure: cxHeader, cyHeader, cxMinBand, cyMinBand, fStatus */
1592 UINT textheight
=0, imageheight
= 0;
1596 lpBand
->fStatus
= 0;
1597 lpBand
->cxMinBand
= 0;
1598 lpBand
->cyMinBand
= 0;
1600 /* Data coming in from users into the cx... and cy... fields */
1601 /* may be bad, just garbage, because the user never clears */
1602 /* the fields. RB_{SET|INSERT}BAND{A|W} just passes the data */
1603 /* along if the fields exist in the input area. Here we must */
1604 /* determine if the data is valid. I have no idea how MS does */
1605 /* the validation, but it does because the RB_GETBANDINFO */
1606 /* returns a 0 when I know the sample program passed in an */
1607 /* address. Here I will use the algorithm that if the value */
1608 /* is greater than 65535 then it is bad and replace it with */
1609 /* a zero. Feel free to improve the algorithm. - GA 12/2000 */
1610 if (lpBand
->cxMinChild
> 65535) lpBand
->cxMinChild
= 0;
1611 if (lpBand
->cyMinChild
> 65535) lpBand
->cyMinChild
= 0;
1612 if (lpBand
->cx
> 65535) lpBand
->cx
= 0;
1613 if (lpBand
->cyChild
> 65535) lpBand
->cyChild
= 0;
1614 if (lpBand
->cyIntegral
> 65535) lpBand
->cyIntegral
= 0;
1615 if (lpBand
->cxIdeal
> 65535) lpBand
->cxIdeal
= 0;
1616 if (lpBand
->cxHeader
> 65535) lpBand
->cxHeader
= 0;
1618 /* TODO : we could try return to the caller if a value changed so that */
1619 /* a REBAR_Layout is needed. Till now the caller should call it */
1620 /* it always (we should also check what native does) */
1622 /* Header is where the image, text and gripper exist */
1623 /* in the band and precede the child window. */
1625 /* count number of non-FIXEDSIZE and non-Hidden bands */
1627 for (i
=0; i
<infoPtr
->uNumBands
; i
++){
1628 tBand
= REBAR_GetBand(infoPtr
, i
);
1629 if (!HIDDENBAND(tBand
) && !(tBand
->fStyle
& RBBS_FIXEDSIZE
))
1633 /* calculate gripper rectangle */
1634 if ( (!(lpBand
->fStyle
& RBBS_NOGRIPPER
)) &&
1635 ( (lpBand
->fStyle
& RBBS_GRIPPERALWAYS
) ||
1636 ( !(lpBand
->fStyle
& RBBS_FIXEDSIZE
) && (nonfixed
> 1)))
1638 lpBand
->fStatus
|= HAS_GRIPPER
;
1639 if (infoPtr
->dwStyle
& CCS_VERT
)
1640 if (infoPtr
->dwStyle
& RBS_VERTICALGRIPPER
)
1641 header
+= (GRIPPER_HEIGHT
+ REBAR_PRE_GRIPPER
);
1643 header
+= (GRIPPER_WIDTH
+ REBAR_PRE_GRIPPER
);
1645 header
+= (REBAR_PRE_GRIPPER
+ GRIPPER_WIDTH
);
1646 /* Always have 4 pixels before anything else */
1647 header
+= REBAR_ALWAYS_SPACE
;
1650 /* image is visible */
1651 if (lpBand
->iImage
!= -1 && (infoPtr
->himl
)) {
1652 lpBand
->fStatus
|= HAS_IMAGE
;
1653 if (infoPtr
->dwStyle
& CCS_VERT
) {
1654 header
+= (infoPtr
->imageSize
.cy
+ REBAR_POST_IMAGE
);
1655 imageheight
= infoPtr
->imageSize
.cx
+ 4;
1658 header
+= (infoPtr
->imageSize
.cx
+ REBAR_POST_IMAGE
);
1659 imageheight
= infoPtr
->imageSize
.cy
+ 4;
1663 /* text is visible */
1664 if ((lpBand
->fMask
& RBBIM_TEXT
) && (lpBand
->lpText
) &&
1665 !(lpBand
->fStyle
& RBBS_HIDETITLE
)) {
1666 HDC hdc
= GetDC (0);
1667 HFONT hOldFont
= SelectObject (hdc
, infoPtr
->hFont
);
1670 lpBand
->fStatus
|= HAS_TEXT
;
1671 GetTextExtentPoint32W (hdc
, lpBand
->lpText
,
1672 lstrlenW (lpBand
->lpText
), &size
);
1673 header
+= ((infoPtr
->dwStyle
& CCS_VERT
) ? (size
.cy
+ REBAR_POST_TEXT
) : (size
.cx
+ REBAR_POST_TEXT
));
1674 textheight
= (infoPtr
->dwStyle
& CCS_VERT
) ? 0 : size
.cy
;
1676 SelectObject (hdc
, hOldFont
);
1680 /* if no gripper but either image or text, then leave space */
1681 if ((lpBand
->fStatus
& (HAS_IMAGE
| HAS_TEXT
)) &&
1682 !(lpBand
->fStatus
& HAS_GRIPPER
)) {
1683 header
+= REBAR_ALWAYS_SPACE
;
1686 /* check if user overrode the header value */
1687 if (!(lpBand
->fStyle
& RBBS_UNDOC_FIXEDHEADER
))
1688 lpBand
->cxHeader
= header
;
1689 lpBand
->cyHeader
= max(textheight
, imageheight
);
1691 /* Now compute minimum size of child window */
1692 update_min_band_height(infoPtr
, lpBand
); /* update lpBand->cyMinBand from cyHeader and cyChild*/
1694 lpBand
->cxMinBand
= lpBand
->cxMinChild
+ lpBand
->cxHeader
+ REBAR_POST_CHILD
;
1695 if (lpBand
->fStyle
& RBBS_USECHEVRON
&& lpBand
->cxMinChild
< lpBand
->cxIdeal
)
1696 lpBand
->cxMinBand
+= CHEVRON_WIDTH
;
1700 REBAR_CommonSetupBand(HWND hwnd
, const REBARBANDINFOW
*lprbbi
, REBAR_BAND
*lpBand
)
1701 /* Function: This routine copies the supplied values from */
1702 /* user input (lprbbi) to the internal band structure. */
1703 /* It returns the mask of what changed. */
1705 UINT uChanged
= 0x0;
1707 lpBand
->fMask
|= lprbbi
->fMask
;
1709 if( (lprbbi
->fMask
& RBBIM_STYLE
) &&
1710 (lpBand
->fStyle
!= lprbbi
->fStyle
) )
1712 lpBand
->fStyle
= lprbbi
->fStyle
;
1713 uChanged
|= RBBIM_STYLE
;
1716 if( (lprbbi
->fMask
& RBBIM_COLORS
) &&
1717 ( ( lpBand
->clrFore
!= lprbbi
->clrFore
) ||
1718 ( lpBand
->clrBack
!= lprbbi
->clrBack
) ) )
1720 lpBand
->clrFore
= lprbbi
->clrFore
;
1721 lpBand
->clrBack
= lprbbi
->clrBack
;
1722 uChanged
|= RBBIM_COLORS
;
1725 if( (lprbbi
->fMask
& RBBIM_IMAGE
) &&
1726 ( lpBand
->iImage
!= lprbbi
->iImage
) )
1728 lpBand
->iImage
= lprbbi
->iImage
;
1729 uChanged
|= RBBIM_IMAGE
;
1732 if( (lprbbi
->fMask
& RBBIM_CHILD
) &&
1733 (lprbbi
->hwndChild
!= lpBand
->hwndChild
) )
1735 if (lprbbi
->hwndChild
) {
1736 lpBand
->hwndChild
= lprbbi
->hwndChild
;
1737 lpBand
->hwndPrevParent
=
1738 SetParent (lpBand
->hwndChild
, hwnd
);
1739 /* below in trace from WinRAR */
1740 ShowWindow(lpBand
->hwndChild
, SW_SHOWNOACTIVATE
| SW_SHOWNORMAL
);
1741 /* above in trace from WinRAR */
1744 TRACE("child: %p prev parent: %p\n",
1745 lpBand
->hwndChild
, lpBand
->hwndPrevParent
);
1746 lpBand
->hwndChild
= 0;
1747 lpBand
->hwndPrevParent
= 0;
1749 uChanged
|= RBBIM_CHILD
;
1752 if( (lprbbi
->fMask
& RBBIM_CHILDSIZE
) &&
1753 ( (lpBand
->cxMinChild
!= lprbbi
->cxMinChild
) ||
1754 (lpBand
->cyMinChild
!= lprbbi
->cyMinChild
) ||
1755 ( (lprbbi
->cbSize
>= REBARBANDINFOA_V6_SIZE
&& (lpBand
->fStyle
& RBBS_VARIABLEHEIGHT
)) &&
1756 ( (lpBand
->cyChild
!= lprbbi
->cyChild
) ||
1757 (lpBand
->cyMaxChild
!= lprbbi
->cyMaxChild
) ||
1758 (lpBand
->cyIntegral
!= lprbbi
->cyIntegral
) ) ) ||
1759 ( (lprbbi
->cbSize
< REBARBANDINFOA_V6_SIZE
) &&
1760 ( (lpBand
->cyChild
||
1761 lpBand
->cyMaxChild
||
1762 lpBand
->cyIntegral
) ) ) ) )
1764 lpBand
->cxMinChild
= lprbbi
->cxMinChild
;
1765 lpBand
->cyMinChild
= lprbbi
->cyMinChild
;
1766 /* These fields where added in WIN32_IE == 0x400 and are set only for RBBS_VARIABLEHEIGHT bands */
1767 if (lprbbi
->cbSize
>= REBARBANDINFOA_V6_SIZE
&& (lpBand
->fStyle
& RBBS_VARIABLEHEIGHT
)) {
1768 lpBand
->cyMaxChild
= lprbbi
->cyMaxChild
;
1769 lpBand
->cyIntegral
= lprbbi
->cyIntegral
;
1771 lpBand
->cyChild
= round_child_height(lpBand
, lprbbi
->cyChild
); /* make (cyChild - cyMinChild) a multiple of cyIntergral */
1774 lpBand
->cyChild
= lpBand
->cyMinChild
;
1775 lpBand
->cyMaxChild
= 0x7fffffff;
1776 lpBand
->cyIntegral
= 0;
1778 uChanged
|= RBBIM_CHILDSIZE
;
1781 if( (lprbbi
->fMask
& RBBIM_SIZE
) &&
1782 (lpBand
->cx
!= lprbbi
->cx
) )
1784 lpBand
->cx
= lprbbi
->cx
;
1785 uChanged
|= RBBIM_SIZE
;
1788 if( (lprbbi
->fMask
& RBBIM_BACKGROUND
) &&
1789 ( lpBand
->hbmBack
!= lprbbi
->hbmBack
) )
1791 lpBand
->hbmBack
= lprbbi
->hbmBack
;
1792 uChanged
|= RBBIM_BACKGROUND
;
1795 if( (lprbbi
->fMask
& RBBIM_ID
) &&
1796 (lpBand
->wID
!= lprbbi
->wID
) )
1798 lpBand
->wID
= lprbbi
->wID
;
1799 uChanged
|= RBBIM_ID
;
1802 /* check for additional data */
1803 if (lprbbi
->cbSize
>= REBARBANDINFOA_V6_SIZE
) {
1804 if( (lprbbi
->fMask
& RBBIM_IDEALSIZE
) &&
1805 ( lpBand
->cxIdeal
!= lprbbi
->cxIdeal
) )
1807 lpBand
->cxIdeal
= lprbbi
->cxIdeal
;
1808 uChanged
|= RBBIM_IDEALSIZE
;
1811 if( (lprbbi
->fMask
& RBBIM_LPARAM
) &&
1812 (lpBand
->lParam
!= lprbbi
->lParam
) )
1814 lpBand
->lParam
= lprbbi
->lParam
;
1815 uChanged
|= RBBIM_LPARAM
;
1818 if( (lprbbi
->fMask
& RBBIM_HEADERSIZE
) &&
1819 (lpBand
->cxHeader
!= lprbbi
->cxHeader
) )
1821 lpBand
->cxHeader
= lprbbi
->cxHeader
;
1822 lpBand
->fStyle
|= RBBS_UNDOC_FIXEDHEADER
;
1823 uChanged
|= RBBIM_HEADERSIZE
;
1830 static LRESULT
REBAR_EraseBkGnd (const REBAR_INFO
*infoPtr
, HDC hdc
)
1831 /* Function: This erases the background rectangle by drawing */
1832 /* each band with its background color (or the default) and */
1833 /* draws each bands right separator if necessary. The row */
1834 /* separators are drawn on the first band of the next row. */
1840 COLORREF old
= CLR_NONE
, new;
1841 HTHEME theme
= GetWindowTheme (infoPtr
->hwndSelf
);
1843 GetClientRect (infoPtr
->hwndSelf
, &cr
);
1846 for(i
=0; i
<infoPtr
->uNumBands
; i
++) {
1848 lpBand
= REBAR_GetBand(infoPtr
, i
);
1849 if (HIDDENBAND(lpBand
)) continue;
1850 translate_rect(infoPtr
, &rcBand
, &lpBand
->rcBand
);
1852 /* draw band separator between rows */
1853 if (lpBand
->iRow
!= oldrow
) {
1854 oldrow
= lpBand
->iRow
;
1855 if (infoPtr
->dwStyle
& RBS_BANDBORDERS
) {
1858 if (infoPtr
->dwStyle
& CCS_VERT
) {
1859 rcRowSep
.right
+= SEP_WIDTH_SIZE
;
1860 rcRowSep
.bottom
= infoPtr
->calcSize
.cx
;
1862 DrawThemeEdge (theme
, hdc
, RP_BAND
, 0, &rcRowSep
, EDGE_ETCHED
, BF_RIGHT
, NULL
);
1864 DrawEdge (hdc
, &rcRowSep
, EDGE_ETCHED
, BF_RIGHT
);
1867 rcRowSep
.bottom
+= SEP_WIDTH_SIZE
;
1868 rcRowSep
.right
= infoPtr
->calcSize
.cx
;
1870 DrawThemeEdge (theme
, hdc
, RP_BAND
, 0, &rcRowSep
, EDGE_ETCHED
, BF_BOTTOM
, NULL
);
1872 DrawEdge (hdc
, &rcRowSep
, EDGE_ETCHED
, BF_BOTTOM
);
1874 TRACE ("drawing band separator bottom (%s)\n",
1875 wine_dbgstr_rect(&rcRowSep
));
1879 /* draw band separator between bands in a row */
1880 if (infoPtr
->dwStyle
& RBS_BANDBORDERS
&& lpBand
->rcBand
.left
> 0) {
1883 if (infoPtr
->dwStyle
& CCS_VERT
) {
1884 rcSep
.bottom
= rcSep
.top
;
1885 rcSep
.top
-= SEP_WIDTH_SIZE
;
1887 DrawThemeEdge (theme
, hdc
, RP_BAND
, 0, &rcSep
, EDGE_ETCHED
, BF_BOTTOM
, NULL
);
1889 DrawEdge (hdc
, &rcSep
, EDGE_ETCHED
, BF_BOTTOM
);
1892 rcSep
.right
= rcSep
.left
;
1893 rcSep
.left
-= SEP_WIDTH_SIZE
;
1895 DrawThemeEdge (theme
, hdc
, RP_BAND
, 0, &rcSep
, EDGE_ETCHED
, BF_RIGHT
, NULL
);
1897 DrawEdge (hdc
, &rcSep
, EDGE_ETCHED
, BF_RIGHT
);
1899 TRACE("drawing band separator right (%s)\n",
1900 wine_dbgstr_rect(&rcSep
));
1903 /* draw the actual background */
1904 if (lpBand
->clrBack
!= CLR_NONE
) {
1905 new = (lpBand
->clrBack
== CLR_DEFAULT
) ? infoPtr
->clrBtnFace
:
1908 /* testing only - make background green to see it */
1913 /* In the absence of documentation for Rebar vs. CLR_NONE,
1914 * we will use the default BtnFace color. Note documentation
1915 * exists for Listview and Imagelist.
1917 new = infoPtr
->clrBtnFace
;
1919 /* testing only - make background green to see it */
1926 /* When themed, the background color is ignored (but not a
1927 * background bitmap */
1928 DrawThemeBackground (theme
, hdc
, 0, 0, &cr
, &rcBand
);
1932 old
= SetBkColor (hdc
, new);
1933 TRACE("%s background color=0x%06x, band %s\n",
1934 (lpBand
->clrBack
== CLR_NONE
) ? "none" :
1935 ((lpBand
->clrBack
== CLR_DEFAULT
) ? "dft" : ""),
1936 GetBkColor(hdc
), wine_dbgstr_rect(&rcBand
));
1937 ExtTextOutW (hdc
, 0, 0, ETO_OPAQUE
, &rcBand
, NULL
, 0, 0);
1938 if (lpBand
->clrBack
!= CLR_NONE
)
1939 SetBkColor (hdc
, old
);
1946 REBAR_InternalHitTest (const REBAR_INFO
*infoPtr
, const POINT
*lpPt
, UINT
*pFlags
, INT
*pBand
)
1952 GetClientRect (infoPtr
->hwndSelf
, &rect
);
1954 *pFlags
= RBHT_NOWHERE
;
1955 if (PtInRect (&rect
, *lpPt
))
1957 if (infoPtr
->uNumBands
== 0) {
1958 *pFlags
= RBHT_NOWHERE
;
1965 /* somewhere inside */
1966 for (iCount
= 0; iCount
< infoPtr
->uNumBands
; iCount
++) {
1968 lpBand
= REBAR_GetBand(infoPtr
, iCount
);
1969 translate_rect(infoPtr
, &rcBand
, &lpBand
->rcBand
);
1970 if (HIDDENBAND(lpBand
)) continue;
1971 if (PtInRect (&rcBand
, *lpPt
)) {
1974 if (PtInRect (&lpBand
->rcGripper
, *lpPt
)) {
1975 *pFlags
= RBHT_GRABBER
;
1976 TRACE("ON GRABBER %d\n", iCount
);
1979 else if (PtInRect (&lpBand
->rcCapImage
, *lpPt
)) {
1980 *pFlags
= RBHT_CAPTION
;
1981 TRACE("ON CAPTION %d\n", iCount
);
1984 else if (PtInRect (&lpBand
->rcCapText
, *lpPt
)) {
1985 *pFlags
= RBHT_CAPTION
;
1986 TRACE("ON CAPTION %d\n", iCount
);
1989 else if (PtInRect (&lpBand
->rcChild
, *lpPt
)) {
1990 *pFlags
= RBHT_CLIENT
;
1991 TRACE("ON CLIENT %d\n", iCount
);
1994 else if (PtInRect (&lpBand
->rcChevron
, *lpPt
)) {
1995 *pFlags
= RBHT_CHEVRON
;
1996 TRACE("ON CHEVRON %d\n", iCount
);
2000 *pFlags
= RBHT_NOWHERE
;
2001 TRACE("NOWHERE %d\n", iCount
);
2007 *pFlags
= RBHT_NOWHERE
;
2016 *pFlags
= RBHT_NOWHERE
;
2025 REBAR_HandleLRDrag (REBAR_INFO
*infoPtr
, const POINT
*ptsmove
)
2026 /* Function: This will implement the functionality of a */
2027 /* Gripper drag within a row. It will not implement "out- */
2028 /* of-row" drags. (They are detected and handled in */
2029 /* REBAR_MouseMove.) */
2031 REBAR_BAND
*hitBand
;
2032 INT iHitBand
, iRowBegin
, iRowEnd
;
2033 INT movement
, xBand
, cxLeft
= 0;
2034 BOOL shrunkBands
= FALSE
;
2036 iHitBand
= infoPtr
->iGrabbedBand
;
2037 iRowBegin
= get_row_begin_for_band(infoPtr
, iHitBand
);
2038 iRowEnd
= get_row_end_for_band(infoPtr
, iHitBand
);
2039 hitBand
= REBAR_GetBand(infoPtr
, iHitBand
);
2041 xBand
= hitBand
->rcBand
.left
;
2042 movement
= (infoPtr
->dwStyle
&CCS_VERT
? ptsmove
->y
: ptsmove
->x
)
2043 - (xBand
+ REBAR_PRE_GRIPPER
- infoPtr
->ihitoffset
);
2045 /* Dragging the first band in a row cannot cause shrinking */
2046 if(iHitBand
!= iRowBegin
)
2049 cxLeft
= REBAR_ShrinkBandsRTL(infoPtr
, iRowBegin
, iHitBand
, -movement
, TRUE
);
2051 if(cxLeft
< -movement
)
2053 hitBand
->cxEffective
+= -movement
- cxLeft
;
2054 hitBand
->cx
= hitBand
->cxEffective
;
2058 } else if (movement
> 0) {
2061 if (prev_visible(infoPtr
, iHitBand
) >= 0)
2062 cxLeft
= REBAR_ShrinkBandsLTR(infoPtr
, iHitBand
, iRowEnd
, movement
, TRUE
);
2064 if(cxLeft
< movement
)
2066 REBAR_BAND
*lpPrev
= REBAR_GetBand(infoPtr
, prev_visible(infoPtr
, iHitBand
));
2067 lpPrev
->cxEffective
+= movement
- cxLeft
;
2068 lpPrev
->cx
= hitBand
->cxEffective
;
2077 /* It was not possible to move the band by shrinking bands.
2078 * Try relocating the band instead. */
2079 REBAR_MoveBandToRowOffset(infoPtr
, iHitBand
, iRowBegin
,
2080 iRowEnd
, xBand
+ movement
, TRUE
);
2083 REBAR_SetRowRectsX(infoPtr
, iRowBegin
, iRowEnd
);
2084 if (infoPtr
->dwStyle
& CCS_VERT
)
2085 REBAR_CalcVertBand(infoPtr
, 0, infoPtr
->uNumBands
);
2087 REBAR_CalcHorzBand(infoPtr
, 0, infoPtr
->uNumBands
);
2088 REBAR_MoveChildWindows(infoPtr
, iRowBegin
, iRowEnd
);
2092 REBAR_HandleUDDrag (REBAR_INFO
*infoPtr
, const POINT
*ptsmove
)
2094 INT yOff
= (infoPtr
->dwStyle
& CCS_VERT
) ? ptsmove
->x
: ptsmove
->y
;
2095 INT iHitBand
, iRowBegin
, iNextRowBegin
;
2096 REBAR_BAND
*hitBand
, *rowBeginBand
;
2098 if(infoPtr
->uNumBands
<= 0)
2099 ERR("There are no bands in this rebar\n");
2101 /* Up/down dragging can only occur when there is more than one
2102 * band in the rebar */
2103 if(infoPtr
->uNumBands
<= 1)
2106 iHitBand
= infoPtr
->iGrabbedBand
;
2107 hitBand
= REBAR_GetBand(infoPtr
, iHitBand
);
2109 /* If we're taking a band that has the RBBS_BREAK style set, this
2110 * style needs to be reapplied to the band that is going to become
2111 * the new start of the row. */
2112 if((hitBand
->fStyle
& RBBS_BREAK
) &&
2113 (iHitBand
< infoPtr
->uNumBands
- 1))
2114 REBAR_GetBand(infoPtr
, iHitBand
+ 1)->fStyle
|= RBBS_BREAK
;
2118 /* Place the band above the current top row */
2119 if(iHitBand
==0 && (infoPtr
->uNumBands
==1 || REBAR_GetBand(infoPtr
, 1)->fStyle
&RBBS_BREAK
))
2121 DPA_DeletePtr(infoPtr
->bands
, iHitBand
);
2122 hitBand
->fStyle
&= ~RBBS_BREAK
;
2123 REBAR_GetBand(infoPtr
, 0)->fStyle
|= RBBS_BREAK
;
2124 infoPtr
->iGrabbedBand
= DPA_InsertPtr(
2125 infoPtr
->bands
, 0, hitBand
);
2127 else if(yOff
> REBAR_GetBand(infoPtr
, infoPtr
->uNumBands
- 1)->rcBand
.bottom
)
2129 /* Place the band below the current bottom row */
2130 if(iHitBand
== infoPtr
->uNumBands
-1 && hitBand
->fStyle
&RBBS_BREAK
)
2132 DPA_DeletePtr(infoPtr
->bands
, iHitBand
);
2133 hitBand
->fStyle
|= RBBS_BREAK
;
2134 infoPtr
->iGrabbedBand
= DPA_InsertPtr(
2135 infoPtr
->bands
, infoPtr
->uNumBands
- 1, hitBand
);
2139 /* Place the band in the prexisting row the mouse is hovering over */
2140 iRowBegin
= first_visible(infoPtr
);
2141 while(iRowBegin
< infoPtr
->uNumBands
)
2143 iNextRowBegin
= get_row_end_for_band(infoPtr
, iRowBegin
);
2144 rowBeginBand
= REBAR_GetBand(infoPtr
, iRowBegin
);
2145 if(rowBeginBand
->rcBand
.bottom
> yOff
)
2147 REBAR_MoveBandToRowOffset(
2148 infoPtr
, iHitBand
, iRowBegin
, iNextRowBegin
,
2149 ((infoPtr
->dwStyle
& CCS_VERT
) ? ptsmove
->y
: ptsmove
->x
)
2150 - REBAR_PRE_GRIPPER
- infoPtr
->ihitoffset
, FALSE
);
2154 iRowBegin
= iNextRowBegin
;
2158 REBAR_Layout(infoPtr
);
2162 /* << REBAR_BeginDrag >> */
2166 REBAR_DeleteBand (REBAR_INFO
*infoPtr
, WPARAM wParam
)
2168 UINT uBand
= (UINT
)wParam
;
2171 if (uBand
>= infoPtr
->uNumBands
)
2174 TRACE("deleting band %u!\n", uBand
);
2175 lpBand
= REBAR_GetBand(infoPtr
, uBand
);
2176 REBAR_Notify_NMREBAR (infoPtr
, uBand
, RBN_DELETINGBAND
);
2177 /* TODO: a return of 1 should probably cancel the deletion */
2179 if (lpBand
->hwndChild
)
2180 ShowWindow(lpBand
->hwndChild
, SW_HIDE
);
2181 Free(lpBand
->lpText
);
2184 infoPtr
->uNumBands
--;
2185 DPA_DeletePtr(infoPtr
->bands
, uBand
);
2187 REBAR_Notify_NMREBAR (infoPtr
, -1, RBN_DELETEDBAND
);
2189 /* if only 1 band left the re-validate to possible eliminate gripper */
2190 if (infoPtr
->uNumBands
== 1)
2191 REBAR_ValidateBand (infoPtr
, REBAR_GetBand(infoPtr
, 0));
2193 REBAR_Layout(infoPtr
);
2199 /* << REBAR_DragMove >> */
2200 /* << REBAR_EndDrag >> */
2204 REBAR_GetBandBorders (const REBAR_INFO
*infoPtr
, UINT uBand
, RECT
*lpRect
)
2210 if (uBand
>= infoPtr
->uNumBands
)
2213 lpBand
= REBAR_GetBand(infoPtr
, uBand
);
2215 /* FIXME - the following values were determined by experimentation */
2216 /* with the REBAR Control Spy. I have guesses as to what the 4 and */
2217 /* 1 are, but I am not sure. There doesn't seem to be any actual */
2218 /* difference in size of the control area with and without the */
2220 if (infoPtr
->dwStyle
& RBS_BANDBORDERS
) {
2221 if (infoPtr
->dwStyle
& CCS_VERT
) {
2223 lpRect
->top
= lpBand
->cxHeader
+ 4;
2228 lpRect
->left
= lpBand
->cxHeader
+ 4;
2235 lpRect
->left
= lpBand
->cxHeader
;
2241 static inline LRESULT
2242 REBAR_GetBandCount (const REBAR_INFO
*infoPtr
)
2244 TRACE("band count %u!\n", infoPtr
->uNumBands
);
2246 return infoPtr
->uNumBands
;
2251 REBAR_GetBandInfoT(const REBAR_INFO
*infoPtr
, UINT uIndex
, LPREBARBANDINFOW lprbbi
, BOOL bUnicode
)
2255 if (!lprbbi
|| lprbbi
->cbSize
< REBARBANDINFOA_V3_SIZE
)
2258 if (uIndex
>= infoPtr
->uNumBands
)
2261 TRACE("index %u (bUnicode=%d)\n", uIndex
, bUnicode
);
2263 /* copy band information */
2264 lpBand
= REBAR_GetBand(infoPtr
, uIndex
);
2266 if (lprbbi
->fMask
& RBBIM_STYLE
)
2267 lprbbi
->fStyle
= lpBand
->fStyle
;
2269 if (lprbbi
->fMask
& RBBIM_COLORS
) {
2270 lprbbi
->clrFore
= lpBand
->clrFore
;
2271 lprbbi
->clrBack
= lpBand
->clrBack
;
2272 if (lprbbi
->clrBack
== CLR_DEFAULT
)
2273 lprbbi
->clrBack
= infoPtr
->clrBtnFace
;
2276 if (lprbbi
->fMask
& RBBIM_TEXT
) {
2278 Str_GetPtrW(lpBand
->lpText
, lprbbi
->lpText
, lprbbi
->cch
);
2280 Str_GetPtrWtoA(lpBand
->lpText
, (LPSTR
)lprbbi
->lpText
, lprbbi
->cch
);
2283 if (lprbbi
->fMask
& RBBIM_IMAGE
)
2284 lprbbi
->iImage
= lpBand
->iImage
;
2286 if (lprbbi
->fMask
& RBBIM_CHILD
)
2287 lprbbi
->hwndChild
= lpBand
->hwndChild
;
2289 if (lprbbi
->fMask
& RBBIM_CHILDSIZE
) {
2290 lprbbi
->cxMinChild
= lpBand
->cxMinChild
;
2291 lprbbi
->cyMinChild
= lpBand
->cyMinChild
;
2292 /* to make tests pass we follow Windows' behaviour and allow reading these fields only
2293 * for RBBS_VARIABLEHEIGHTS bands */
2294 if (lprbbi
->cbSize
>= REBARBANDINFOW_V6_SIZE
&& (lpBand
->fStyle
& RBBS_VARIABLEHEIGHT
)) {
2295 lprbbi
->cyChild
= lpBand
->cyChild
;
2296 lprbbi
->cyMaxChild
= lpBand
->cyMaxChild
;
2297 lprbbi
->cyIntegral
= lpBand
->cyIntegral
;
2301 if (lprbbi
->fMask
& RBBIM_SIZE
)
2302 lprbbi
->cx
= lpBand
->cx
;
2304 if (lprbbi
->fMask
& RBBIM_BACKGROUND
)
2305 lprbbi
->hbmBack
= lpBand
->hbmBack
;
2307 if (lprbbi
->fMask
& RBBIM_ID
)
2308 lprbbi
->wID
= lpBand
->wID
;
2310 /* check for additional data */
2311 if (lprbbi
->cbSize
>= REBARBANDINFOW_V6_SIZE
) {
2312 if (lprbbi
->fMask
& RBBIM_IDEALSIZE
)
2313 lprbbi
->cxIdeal
= lpBand
->cxIdeal
;
2315 if (lprbbi
->fMask
& RBBIM_LPARAM
)
2316 lprbbi
->lParam
= lpBand
->lParam
;
2318 if (lprbbi
->fMask
& RBBIM_HEADERSIZE
)
2319 lprbbi
->cxHeader
= lpBand
->cxHeader
;
2322 REBAR_DumpBandInfo(lprbbi
);
2329 REBAR_GetBarHeight (const REBAR_INFO
*infoPtr
)
2333 nHeight
= infoPtr
->calcSize
.cy
;
2335 TRACE("height = %d\n", nHeight
);
2342 REBAR_GetBarInfo (const REBAR_INFO
*infoPtr
, LPREBARINFO lpInfo
)
2344 if (!lpInfo
|| lpInfo
->cbSize
< sizeof (REBARINFO
))
2347 TRACE("getting bar info!\n");
2349 if (infoPtr
->himl
) {
2350 lpInfo
->himl
= infoPtr
->himl
;
2351 lpInfo
->fMask
|= RBIM_IMAGELIST
;
2358 static inline LRESULT
2359 REBAR_GetBkColor (const REBAR_INFO
*infoPtr
)
2361 COLORREF clr
= infoPtr
->clrBk
;
2363 if (clr
== CLR_DEFAULT
)
2364 clr
= infoPtr
->clrBtnFace
;
2366 TRACE("background color 0x%06x!\n", clr
);
2372 /* << REBAR_GetColorScheme >> */
2373 /* << REBAR_GetDropTarget >> */
2377 REBAR_GetPalette (const REBAR_INFO
*infoPtr
)
2379 FIXME("empty stub!\n");
2386 REBAR_GetRect (const REBAR_INFO
*infoPtr
, INT iBand
, RECT
*lprc
)
2390 if (iBand
< 0 || iBand
>= infoPtr
->uNumBands
)
2395 lpBand
= REBAR_GetBand(infoPtr
, iBand
);
2396 /* For CCS_VERT the coordinates will be swapped - like on Windows */
2397 *lprc
= lpBand
->rcBand
;
2399 TRACE("band %d, (%s)\n", iBand
, wine_dbgstr_rect(lprc
));
2405 static inline LRESULT
2406 REBAR_GetRowCount (const REBAR_INFO
*infoPtr
)
2408 TRACE("%u\n", infoPtr
->uNumRows
);
2410 return infoPtr
->uNumRows
;
2415 REBAR_GetRowHeight (const REBAR_INFO
*infoPtr
, INT iRow
)
2421 for (i
=0; i
<infoPtr
->uNumBands
; i
++) {
2422 lpBand
= REBAR_GetBand(infoPtr
, i
);
2423 if (HIDDENBAND(lpBand
)) continue;
2424 if (lpBand
->iRow
!= iRow
) continue;
2425 j
= lpBand
->rcBand
.bottom
- lpBand
->rcBand
.top
;
2426 if (j
> ret
) ret
= j
;
2429 TRACE("row %d, height %d\n", iRow
, ret
);
2435 static inline LRESULT
2436 REBAR_GetTextColor (const REBAR_INFO
*infoPtr
)
2438 TRACE("text color 0x%06x!\n", infoPtr
->clrText
);
2440 return infoPtr
->clrText
;
2444 static inline LRESULT
2445 REBAR_GetToolTips (const REBAR_INFO
*infoPtr
)
2447 return (LRESULT
)infoPtr
->hwndToolTip
;
2451 static inline LRESULT
2452 REBAR_GetUnicodeFormat (const REBAR_INFO
*infoPtr
)
2454 TRACE("%s hwnd=%p\n",
2455 infoPtr
->bUnicode
? "TRUE" : "FALSE", infoPtr
->hwndSelf
);
2457 return infoPtr
->bUnicode
;
2461 static inline LRESULT
2462 REBAR_GetVersion (const REBAR_INFO
*infoPtr
)
2464 TRACE("version %d\n", infoPtr
->iVersion
);
2465 return infoPtr
->iVersion
;
2470 REBAR_HitTest (const REBAR_INFO
*infoPtr
, LPRBHITTESTINFO lprbht
)
2475 REBAR_InternalHitTest (infoPtr
, &lprbht
->pt
, &lprbht
->flags
, &lprbht
->iBand
);
2477 return lprbht
->iBand
;
2482 REBAR_IdToIndex (const REBAR_INFO
*infoPtr
, UINT uId
)
2486 if (infoPtr
->uNumBands
< 1)
2489 for (i
= 0; i
< infoPtr
->uNumBands
; i
++) {
2490 if (REBAR_GetBand(infoPtr
, i
)->wID
== uId
) {
2491 TRACE("id %u is band %u found!\n", uId
, i
);
2496 TRACE("id %u is not found\n", uId
);
2502 REBAR_InsertBandT(REBAR_INFO
*infoPtr
, INT iIndex
, const REBARBANDINFOW
*lprbbi
, BOOL bUnicode
)
2506 if (!lprbbi
|| lprbbi
->cbSize
< REBARBANDINFOA_V3_SIZE
)
2509 /* trace the index as signed to see the -1 */
2510 TRACE("insert band at %d (bUnicode=%d)!\n", iIndex
, bUnicode
);
2511 REBAR_DumpBandInfo(lprbbi
);
2513 if (!(lpBand
= Alloc(sizeof(REBAR_BAND
)))) return FALSE
;
2514 if ((iIndex
== -1) || (iIndex
> infoPtr
->uNumBands
))
2515 iIndex
= infoPtr
->uNumBands
;
2516 if (DPA_InsertPtr(infoPtr
->bands
, iIndex
, lpBand
) == -1)
2521 infoPtr
->uNumBands
++;
2523 TRACE("index %d!\n", iIndex
);
2525 /* initialize band */
2526 memset(lpBand
, 0, sizeof(*lpBand
));
2527 lpBand
->clrFore
= infoPtr
->clrText
== CLR_NONE
? infoPtr
->clrBtnText
:
2529 lpBand
->clrBack
= infoPtr
->clrBk
== CLR_NONE
? infoPtr
->clrBtnFace
:
2531 lpBand
->iImage
= -1;
2533 REBAR_CommonSetupBand(infoPtr
->hwndSelf
, lprbbi
, lpBand
);
2535 /* Make sure the defaults for these are correct */
2536 if (lprbbi
->cbSize
< REBARBANDINFOA_V6_SIZE
|| !(lpBand
->fStyle
& RBBS_VARIABLEHEIGHT
)) {
2537 lpBand
->cyChild
= lpBand
->cyMinChild
;
2538 lpBand
->cyMaxChild
= 0x7fffffff;
2539 lpBand
->cyIntegral
= 0;
2542 if ((lprbbi
->fMask
& RBBIM_TEXT
) && (lprbbi
->lpText
)) {
2544 Str_SetPtrW(&lpBand
->lpText
, lprbbi
->lpText
);
2546 Str_SetPtrAtoW(&lpBand
->lpText
, (LPSTR
)lprbbi
->lpText
);
2549 REBAR_ValidateBand (infoPtr
, lpBand
);
2550 /* On insert of second band, revalidate band 1 to possible add gripper */
2551 if (infoPtr
->uNumBands
== 2)
2552 REBAR_ValidateBand (infoPtr
, REBAR_GetBand(infoPtr
, 0));
2554 REBAR_DumpBand (infoPtr
);
2556 REBAR_Layout(infoPtr
);
2557 InvalidateRect(infoPtr
->hwndSelf
, NULL
, TRUE
);
2564 REBAR_MaximizeBand (const REBAR_INFO
*infoPtr
, INT iBand
, LPARAM lParam
)
2567 int iRowBegin
, iRowEnd
;
2568 int cxDesired
, extra
, extraOrig
;
2572 if (infoPtr
->uNumBands
== 0 || iBand
< 0 || iBand
>= infoPtr
->uNumBands
) {
2574 ERR("Illegal MaximizeBand, requested=%d, current band count=%d\n",
2575 iBand
, infoPtr
->uNumBands
);
2579 lpBand
= REBAR_GetBand(infoPtr
, iBand
);
2581 if (lpBand
->fStyle
& RBBS_HIDDEN
)
2583 /* Windows is buggy and creates a hole */
2584 WARN("Ignoring maximize request on a hidden band (%d)\n", iBand
);
2588 cxIdealBand
= lpBand
->cxIdeal
+ lpBand
->cxHeader
+ REBAR_POST_CHILD
;
2589 if (lParam
&& (lpBand
->cxEffective
< cxIdealBand
))
2590 cxDesired
= cxIdealBand
;
2592 cxDesired
= infoPtr
->calcSize
.cx
;
2594 iRowBegin
= get_row_begin_for_band(infoPtr
, iBand
);
2595 iRowEnd
= get_row_end_for_band(infoPtr
, iBand
);
2596 extraOrig
= extra
= cxDesired
- lpBand
->cxEffective
;
2598 extra
= REBAR_ShrinkBandsRTL(infoPtr
, iRowBegin
, iBand
, extra
, TRUE
);
2600 extra
= REBAR_ShrinkBandsLTR(infoPtr
, next_visible(infoPtr
, iBand
), iRowEnd
, extra
, TRUE
);
2601 lpBand
->cxEffective
+= extraOrig
- extra
;
2602 lpBand
->cx
= lpBand
->cxEffective
;
2603 TRACE("(%d, %ld): Wanted size %d, obtained %d (shrink %d, %d)\n", iBand
, lParam
, cxDesired
, lpBand
->cx
, extraOrig
, extra
);
2604 REBAR_SetRowRectsX(infoPtr
, iRowBegin
, iRowEnd
);
2606 if (infoPtr
->dwStyle
& CCS_VERT
)
2607 REBAR_CalcVertBand(infoPtr
, iRowBegin
, iRowEnd
);
2609 REBAR_CalcHorzBand(infoPtr
, iRowBegin
, iRowEnd
);
2610 REBAR_MoveChildWindows(infoPtr
, iRowBegin
, iRowEnd
);
2617 REBAR_MinimizeBand (const REBAR_INFO
*infoPtr
, INT iBand
)
2620 int iPrev
, iRowBegin
, iRowEnd
;
2622 /* A "minimize" band is equivalent to "dragging" the gripper
2623 * of than band to the right till the band is only the size
2628 if (infoPtr
->uNumBands
== 0 || iBand
< 0 || iBand
>= infoPtr
->uNumBands
) {
2630 ERR("Illegal MinimizeBand, requested=%d, current band count=%d\n",
2631 iBand
, infoPtr
->uNumBands
);
2635 /* compute amount of movement and validate */
2636 lpBand
= REBAR_GetBand(infoPtr
, iBand
);
2638 if (lpBand
->fStyle
& RBBS_HIDDEN
)
2640 /* Windows is buggy and creates a hole/overlap */
2641 WARN("Ignoring minimize request on a hidden band (%d)\n", iBand
);
2645 iPrev
= prev_visible(infoPtr
, iBand
);
2646 /* if first band in row */
2647 if (iPrev
< 0 || REBAR_GetBand(infoPtr
, iPrev
)->iRow
!= lpBand
->iRow
) {
2648 int iNext
= next_visible(infoPtr
, iBand
);
2649 if (iNext
< infoPtr
->uNumBands
&& REBAR_GetBand(infoPtr
, iNext
)->iRow
== lpBand
->iRow
) {
2650 TRACE("(%d): Minimizing the first band in row is by maximizing the second\n", iBand
);
2651 REBAR_MaximizeBand(infoPtr
, iNext
, FALSE
);
2654 TRACE("(%d): Only one band in row - nothing to do\n", iBand
);
2658 REBAR_GetBand(infoPtr
, iPrev
)->cxEffective
+= lpBand
->cxEffective
- lpBand
->cxMinBand
;
2659 REBAR_GetBand(infoPtr
, iPrev
)->cx
= REBAR_GetBand(infoPtr
, iPrev
)->cxEffective
;
2660 lpBand
->cx
= lpBand
->cxEffective
= lpBand
->cxMinBand
;
2662 iRowBegin
= get_row_begin_for_band(infoPtr
, iBand
);
2663 iRowEnd
= get_row_end_for_band(infoPtr
, iBand
);
2664 REBAR_SetRowRectsX(infoPtr
, iRowBegin
, iRowEnd
);
2666 if (infoPtr
->dwStyle
& CCS_VERT
)
2667 REBAR_CalcVertBand(infoPtr
, iRowBegin
, iRowEnd
);
2669 REBAR_CalcHorzBand(infoPtr
, iRowBegin
, iRowEnd
);
2670 REBAR_MoveChildWindows(infoPtr
, iRowBegin
, iRowEnd
);
2676 REBAR_MoveBand (REBAR_INFO
*infoPtr
, INT iFrom
, INT iTo
)
2681 if ((infoPtr
->uNumBands
== 0) ||
2682 (iFrom
< 0) || iFrom
>= infoPtr
->uNumBands
||
2683 (iTo
< 0) || iTo
>= infoPtr
->uNumBands
) {
2685 ERR("Illegal MoveBand, from=%d, to=%d, current band count=%d\n",
2686 iFrom
, iTo
, infoPtr
->uNumBands
);
2690 lpBand
= REBAR_GetBand(infoPtr
, iFrom
);
2691 DPA_DeletePtr(infoPtr
->bands
, iFrom
);
2692 DPA_InsertPtr(infoPtr
->bands
, iTo
, lpBand
);
2694 TRACE("moved band %d to index %d\n", iFrom
, iTo
);
2695 REBAR_DumpBand (infoPtr
);
2697 /* **************************************************** */
2699 /* We do not do a REBAR_Layout here because the native */
2700 /* control does not do that. The actual layout and */
2701 /* repaint is done by the *next* real action, ex.: */
2702 /* RB_INSERTBAND, RB_DELETEBAND, RB_SIZETORECT, etc. */
2704 /* **************************************************** */
2710 /* return TRUE if two strings are different */
2712 REBAR_strdifW( LPCWSTR a
, LPCWSTR b
)
2714 return ( (a
&& !b
) || (b
&& !a
) || (a
&& b
&& lstrcmpW(a
, b
) ) );
2718 REBAR_SetBandInfoT(REBAR_INFO
*infoPtr
, INT iBand
, const REBARBANDINFOW
*lprbbi
, BOOL bUnicode
)
2723 if (!lprbbi
|| lprbbi
->cbSize
< REBARBANDINFOA_V3_SIZE
)
2726 if (iBand
>= infoPtr
->uNumBands
)
2729 TRACE("index %d\n", iBand
);
2730 REBAR_DumpBandInfo (lprbbi
);
2732 /* set band information */
2733 lpBand
= REBAR_GetBand(infoPtr
, iBand
);
2735 uChanged
= REBAR_CommonSetupBand (infoPtr
->hwndSelf
, lprbbi
, lpBand
);
2736 if (lprbbi
->fMask
& RBBIM_TEXT
) {
2739 Str_SetPtrW(&wstr
, lprbbi
->lpText
);
2741 Str_SetPtrAtoW(&wstr
, (LPSTR
)lprbbi
->lpText
);
2743 if (REBAR_strdifW(wstr
, lpBand
->lpText
)) {
2744 Free(lpBand
->lpText
);
2745 lpBand
->lpText
= wstr
;
2746 uChanged
|= RBBIM_TEXT
;
2752 REBAR_ValidateBand (infoPtr
, lpBand
);
2754 REBAR_DumpBand (infoPtr
);
2756 if (uChanged
& (RBBIM_CHILDSIZE
| RBBIM_SIZE
| RBBIM_STYLE
| RBBIM_IMAGE
)) {
2757 REBAR_Layout(infoPtr
);
2758 InvalidateRect(infoPtr
->hwndSelf
, NULL
, TRUE
);
2766 REBAR_SetBarInfo (REBAR_INFO
*infoPtr
, const REBARINFO
*lpInfo
)
2771 if (!lpInfo
|| lpInfo
->cbSize
< sizeof (REBARINFO
))
2774 TRACE("setting bar info!\n");
2776 if (lpInfo
->fMask
& RBIM_IMAGELIST
) {
2777 infoPtr
->himl
= lpInfo
->himl
;
2778 if (infoPtr
->himl
) {
2780 ImageList_GetIconSize (infoPtr
->himl
, &cx
, &cy
);
2781 infoPtr
->imageSize
.cx
= cx
;
2782 infoPtr
->imageSize
.cy
= cy
;
2785 infoPtr
->imageSize
.cx
= 0;
2786 infoPtr
->imageSize
.cy
= 0;
2788 TRACE("new image cx=%d, cy=%d\n", infoPtr
->imageSize
.cx
,
2789 infoPtr
->imageSize
.cy
);
2792 /* revalidate all bands to reset flags for images in headers of bands */
2793 for (i
=0; i
<infoPtr
->uNumBands
; i
++) {
2794 lpBand
= REBAR_GetBand(infoPtr
, i
);
2795 REBAR_ValidateBand (infoPtr
, lpBand
);
2803 REBAR_SetBkColor (REBAR_INFO
*infoPtr
, COLORREF clr
)
2807 clrTemp
= infoPtr
->clrBk
;
2808 infoPtr
->clrBk
= clr
;
2810 TRACE("background color 0x%06x!\n", infoPtr
->clrBk
);
2816 /* << REBAR_SetColorScheme >> */
2817 /* << REBAR_SetPalette >> */
2821 REBAR_SetParent (REBAR_INFO
*infoPtr
, HWND parent
)
2823 HWND hwndTemp
= infoPtr
->hwndNotify
;
2825 infoPtr
->hwndNotify
= parent
;
2827 return (LRESULT
)hwndTemp
;
2832 REBAR_SetTextColor (REBAR_INFO
*infoPtr
, COLORREF clr
)
2836 clrTemp
= infoPtr
->clrText
;
2837 infoPtr
->clrText
= clr
;
2839 TRACE("text color 0x%06x!\n", infoPtr
->clrText
);
2845 /* << REBAR_SetTooltips >> */
2848 static inline LRESULT
2849 REBAR_SetUnicodeFormat (REBAR_INFO
*infoPtr
, BOOL unicode
)
2851 BOOL bTemp
= infoPtr
->bUnicode
;
2853 TRACE("to %s hwnd=%p, was %s\n",
2854 unicode
? "TRUE" : "FALSE", infoPtr
->hwndSelf
,
2855 (bTemp
) ? "TRUE" : "FALSE");
2857 infoPtr
->bUnicode
= unicode
;
2864 REBAR_SetVersion (REBAR_INFO
*infoPtr
, INT iVersion
)
2866 INT iOldVersion
= infoPtr
->iVersion
;
2868 if (iVersion
> COMCTL32_VERSION
)
2871 infoPtr
->iVersion
= iVersion
;
2873 TRACE("new version %d\n", iVersion
);
2880 REBAR_ShowBand (REBAR_INFO
*infoPtr
, INT iBand
, BOOL show
)
2884 if (iBand
< 0 || iBand
>= infoPtr
->uNumBands
)
2887 lpBand
= REBAR_GetBand(infoPtr
, iBand
);
2890 TRACE("show band %d\n", iBand
);
2891 lpBand
->fStyle
= lpBand
->fStyle
& ~RBBS_HIDDEN
;
2892 if (IsWindow (lpBand
->hwndChild
))
2893 ShowWindow (lpBand
->hwndChild
, SW_SHOW
);
2896 TRACE("hide band %d\n", iBand
);
2897 lpBand
->fStyle
= lpBand
->fStyle
| RBBS_HIDDEN
;
2898 if (IsWindow (lpBand
->hwndChild
))
2899 ShowWindow (lpBand
->hwndChild
, SW_HIDE
);
2902 REBAR_Layout(infoPtr
);
2903 InvalidateRect(infoPtr
->hwndSelf
, NULL
, TRUE
);
2910 REBAR_SizeToRect (REBAR_INFO
*infoPtr
, const RECT
*lpRect
)
2912 if (!lpRect
) return FALSE
;
2914 TRACE("[%s]\n", wine_dbgstr_rect(lpRect
));
2915 REBAR_SizeToHeight(infoPtr
, get_rect_cy(infoPtr
, lpRect
));
2922 REBAR_Create (REBAR_INFO
*infoPtr
, LPCREATESTRUCTW cs
)
2926 if (TRACE_ON(rebar
)) {
2927 GetWindowRect(infoPtr
->hwndSelf
, &wnrc1
);
2928 GetClientRect(infoPtr
->hwndSelf
, &clrc1
);
2929 TRACE("window=(%s) client=(%s) cs=(%d,%d %dx%d)\n",
2930 wine_dbgstr_rect(&wnrc1
), wine_dbgstr_rect(&clrc1
),
2931 cs
->x
, cs
->y
, cs
->cx
, cs
->cy
);
2934 TRACE("created!\n");
2936 if (OpenThemeData (infoPtr
->hwndSelf
, themeClass
))
2938 /* native seems to clear WS_BORDER when themed */
2939 infoPtr
->dwStyle
&= ~WS_BORDER
;
2947 REBAR_Destroy (REBAR_INFO
*infoPtr
)
2952 /* clean up each band */
2953 for (i
= 0; i
< infoPtr
->uNumBands
; i
++) {
2954 lpBand
= REBAR_GetBand(infoPtr
, i
);
2956 /* delete text strings */
2957 Free (lpBand
->lpText
);
2958 lpBand
->lpText
= NULL
;
2959 /* destroy child window */
2960 DestroyWindow (lpBand
->hwndChild
);
2964 /* free band array */
2965 DPA_Destroy (infoPtr
->bands
);
2966 infoPtr
->bands
= NULL
;
2968 DestroyCursor (infoPtr
->hcurArrow
);
2969 DestroyCursor (infoPtr
->hcurHorz
);
2970 DestroyCursor (infoPtr
->hcurVert
);
2971 DestroyCursor (infoPtr
->hcurDrag
);
2972 if (infoPtr
->hDefaultFont
) DeleteObject (infoPtr
->hDefaultFont
);
2973 SetWindowLongPtrW (infoPtr
->hwndSelf
, 0, 0);
2975 CloseThemeData (GetWindowTheme (infoPtr
->hwndSelf
));
2977 /* free rebar info data */
2979 TRACE("destroyed!\n");
2984 REBAR_GetFont (const REBAR_INFO
*infoPtr
)
2986 return (LRESULT
)infoPtr
->hFont
;
2990 REBAR_PushChevron(const REBAR_INFO
*infoPtr
, UINT uBand
, LPARAM lParam
)
2992 if (uBand
< infoPtr
->uNumBands
)
2994 NMREBARCHEVRON nmrbc
;
2995 REBAR_BAND
*lpBand
= REBAR_GetBand(infoPtr
, uBand
);
2997 TRACE("Pressed chevron on band %u\n", uBand
);
2999 /* redraw chevron in pushed state */
3000 lpBand
->fDraw
|= DRAW_CHEVRONPUSHED
;
3001 RedrawWindow(infoPtr
->hwndSelf
, &lpBand
->rcChevron
,0,
3002 RDW_ERASE
|RDW_INVALIDATE
|RDW_UPDATENOW
);
3004 /* notify app so it can display a popup menu or whatever */
3005 nmrbc
.uBand
= uBand
;
3006 nmrbc
.wID
= lpBand
->wID
;
3007 nmrbc
.lParam
= lpBand
->lParam
;
3008 nmrbc
.rc
= lpBand
->rcChevron
;
3009 nmrbc
.lParamNM
= lParam
;
3010 REBAR_Notify((NMHDR
*)&nmrbc
, infoPtr
, RBN_CHEVRONPUSHED
);
3012 /* redraw chevron in previous state */
3013 lpBand
->fDraw
&= ~DRAW_CHEVRONPUSHED
;
3014 InvalidateRect(infoPtr
->hwndSelf
, &lpBand
->rcChevron
, TRUE
);
3022 REBAR_LButtonDown (REBAR_INFO
*infoPtr
, LPARAM lParam
)
3027 ptMouseDown
.x
= (short)LOWORD(lParam
);
3028 ptMouseDown
.y
= (short)HIWORD(lParam
);
3030 REBAR_InternalHitTest(infoPtr
, &ptMouseDown
, &htFlags
, &iHitBand
);
3032 if (htFlags
== RBHT_CHEVRON
)
3034 REBAR_PushChevron(infoPtr
, iHitBand
, 0);
3036 else if (htFlags
== RBHT_GRABBER
|| htFlags
== RBHT_CAPTION
)
3040 TRACE("Starting drag\n");
3042 lpBand
= REBAR_GetBand(infoPtr
, iHitBand
);
3044 SetCapture (infoPtr
->hwndSelf
);
3045 infoPtr
->iGrabbedBand
= iHitBand
;
3047 /* save off the LOWORD and HIWORD of lParam as initial x,y */
3048 infoPtr
->dragStart
.x
= (short)LOWORD(lParam
);
3049 infoPtr
->dragStart
.y
= (short)HIWORD(lParam
);
3050 infoPtr
->dragNow
= infoPtr
->dragStart
;
3051 if (infoPtr
->dwStyle
& CCS_VERT
)
3052 infoPtr
->ihitoffset
= infoPtr
->dragStart
.y
- (lpBand
->rcBand
.left
+ REBAR_PRE_GRIPPER
);
3054 infoPtr
->ihitoffset
= infoPtr
->dragStart
.x
- (lpBand
->rcBand
.left
+ REBAR_PRE_GRIPPER
);
3060 REBAR_LButtonUp (REBAR_INFO
*infoPtr
)
3062 if (infoPtr
->iGrabbedBand
>= 0)
3067 infoPtr
->dragStart
.x
= 0;
3068 infoPtr
->dragStart
.y
= 0;
3069 infoPtr
->dragNow
= infoPtr
->dragStart
;
3073 if (infoPtr
->fStatus
& BEGIN_DRAG_ISSUED
) {
3074 REBAR_Notify(&layout
, infoPtr
, RBN_LAYOUTCHANGED
);
3075 REBAR_Notify_NMREBAR (infoPtr
, infoPtr
->iGrabbedBand
, RBN_ENDDRAG
);
3076 infoPtr
->fStatus
&= ~BEGIN_DRAG_ISSUED
;
3079 infoPtr
->iGrabbedBand
= -1;
3081 GetClientRect(infoPtr
->hwndSelf
, &rect
);
3082 InvalidateRect(infoPtr
->hwndSelf
, NULL
, TRUE
);
3089 REBAR_MouseLeave (REBAR_INFO
*infoPtr
)
3091 if (infoPtr
->ichevronhotBand
>= 0)
3093 REBAR_BAND
*lpChevronBand
= REBAR_GetBand(infoPtr
, infoPtr
->ichevronhotBand
);
3094 if (lpChevronBand
->fDraw
& DRAW_CHEVRONHOT
)
3096 lpChevronBand
->fDraw
&= ~DRAW_CHEVRONHOT
;
3097 InvalidateRect(infoPtr
->hwndSelf
, &lpChevronBand
->rcChevron
, TRUE
);
3100 infoPtr
->iOldBand
= -1;
3101 infoPtr
->ichevronhotBand
= -2;
3107 REBAR_MouseMove (REBAR_INFO
*infoPtr
, LPARAM lParam
)
3109 REBAR_BAND
*lpChevronBand
;
3112 ptMove
.x
= (short)LOWORD(lParam
);
3113 ptMove
.y
= (short)HIWORD(lParam
);
3115 /* if we are currently dragging a band */
3116 if (infoPtr
->iGrabbedBand
>= 0)
3119 int yPtMove
= (infoPtr
->dwStyle
& CCS_VERT
? ptMove
.x
: ptMove
.y
);
3121 if (GetCapture() != infoPtr
->hwndSelf
)
3122 ERR("We are dragging but haven't got capture?!?\n");
3124 band
= REBAR_GetBand(infoPtr
, infoPtr
->iGrabbedBand
);
3126 /* if mouse did not move much, exit */
3127 if ((abs(ptMove
.x
- infoPtr
->dragNow
.x
) <= mindragx
) &&
3128 (abs(ptMove
.y
- infoPtr
->dragNow
.y
) <= mindragy
)) return 0;
3130 /* on first significant mouse movement, issue notify */
3131 if (!(infoPtr
->fStatus
& BEGIN_DRAG_ISSUED
)) {
3132 if (REBAR_Notify_NMREBAR (infoPtr
, -1, RBN_BEGINDRAG
)) {
3133 /* Notify returned TRUE - abort drag */
3134 infoPtr
->dragStart
.x
= 0;
3135 infoPtr
->dragStart
.y
= 0;
3136 infoPtr
->dragNow
= infoPtr
->dragStart
;
3137 infoPtr
->iGrabbedBand
= -1;
3141 infoPtr
->fStatus
|= BEGIN_DRAG_ISSUED
;
3144 /* Test for valid drag case - must not be first band in row */
3145 if ((yPtMove
< band
->rcBand
.top
) ||
3146 (yPtMove
> band
->rcBand
.bottom
)) {
3147 REBAR_HandleUDDrag (infoPtr
, &ptMove
);
3150 REBAR_HandleLRDrag (infoPtr
, &ptMove
);
3157 TRACKMOUSEEVENT trackinfo
;
3159 REBAR_InternalHitTest(infoPtr
, &ptMove
, &htFlags
, &iHitBand
);
3161 if (infoPtr
->iOldBand
>= 0 && infoPtr
->iOldBand
== infoPtr
->ichevronhotBand
)
3163 lpChevronBand
= REBAR_GetBand(infoPtr
, infoPtr
->ichevronhotBand
);
3164 if (lpChevronBand
->fDraw
& DRAW_CHEVRONHOT
)
3166 lpChevronBand
->fDraw
&= ~DRAW_CHEVRONHOT
;
3167 InvalidateRect(infoPtr
->hwndSelf
, &lpChevronBand
->rcChevron
, TRUE
);
3169 infoPtr
->ichevronhotBand
= -2;
3172 if (htFlags
== RBHT_CHEVRON
)
3174 /* fill in the TRACKMOUSEEVENT struct */
3175 trackinfo
.cbSize
= sizeof(TRACKMOUSEEVENT
);
3176 trackinfo
.dwFlags
= TME_QUERY
;
3177 trackinfo
.hwndTrack
= infoPtr
->hwndSelf
;
3178 trackinfo
.dwHoverTime
= 0;
3180 /* call _TrackMouseEvent to see if we are currently tracking for this hwnd */
3181 _TrackMouseEvent(&trackinfo
);
3183 /* Make sure tracking is enabled so we receive a WM_MOUSELEAVE message */
3184 if(!(trackinfo
.dwFlags
& TME_LEAVE
))
3186 trackinfo
.dwFlags
= TME_LEAVE
; /* notify upon leaving */
3188 /* call TRACKMOUSEEVENT so we receive a WM_MOUSELEAVE message */
3189 /* and can properly deactivate the hot chevron */
3190 _TrackMouseEvent(&trackinfo
);
3193 lpChevronBand
= REBAR_GetBand(infoPtr
, iHitBand
);
3194 if (!(lpChevronBand
->fDraw
& DRAW_CHEVRONHOT
))
3196 lpChevronBand
->fDraw
|= DRAW_CHEVRONHOT
;
3197 InvalidateRect(infoPtr
->hwndSelf
, &lpChevronBand
->rcChevron
, TRUE
);
3198 infoPtr
->ichevronhotBand
= iHitBand
;
3201 infoPtr
->iOldBand
= iHitBand
;
3208 static inline LRESULT
3209 REBAR_NCCalcSize (const REBAR_INFO
*infoPtr
, RECT
*rect
)
3213 if (infoPtr
->dwStyle
& WS_BORDER
) {
3214 rect
->left
= min(rect
->left
+ GetSystemMetrics(SM_CXEDGE
), rect
->right
);
3215 rect
->right
= max(rect
->right
- GetSystemMetrics(SM_CXEDGE
), rect
->left
);
3216 rect
->top
= min(rect
->top
+ GetSystemMetrics(SM_CYEDGE
), rect
->bottom
);
3217 rect
->bottom
= max(rect
->bottom
- GetSystemMetrics(SM_CYEDGE
), rect
->top
);
3219 else if ((theme
= GetWindowTheme (infoPtr
->hwndSelf
)))
3221 /* FIXME: should use GetThemeInt */
3222 rect
->top
= min(rect
->top
+ 1, rect
->bottom
);
3224 TRACE("new client=(%s)\n", wine_dbgstr_rect(rect
));
3230 REBAR_NCCreate (HWND hwnd
, const CREATESTRUCTW
*cs
)
3232 REBAR_INFO
*infoPtr
= REBAR_GetInfoPtr (hwnd
);
3234 NONCLIENTMETRICSW ncm
;
3238 ERR("Strange info structure pointer *not* NULL\n");
3242 if (TRACE_ON(rebar
)) {
3243 GetWindowRect(hwnd
, &wnrc1
);
3244 GetClientRect(hwnd
, &clrc1
);
3245 TRACE("window=(%s) client=(%s) cs=(%d,%d %dx%d)\n",
3246 wine_dbgstr_rect(&wnrc1
), wine_dbgstr_rect(&clrc1
),
3247 cs
->x
, cs
->y
, cs
->cx
, cs
->cy
);
3250 /* allocate memory for info structure */
3251 infoPtr
= Alloc (sizeof(REBAR_INFO
));
3252 SetWindowLongPtrW (hwnd
, 0, (DWORD_PTR
)infoPtr
);
3254 /* initialize info structure - initial values are 0 */
3255 infoPtr
->clrBk
= CLR_NONE
;
3256 infoPtr
->clrText
= CLR_NONE
;
3257 infoPtr
->clrBtnText
= comctl32_color
.clrBtnText
;
3258 infoPtr
->clrBtnFace
= comctl32_color
.clrBtnFace
;
3259 infoPtr
->iOldBand
= -1;
3260 infoPtr
->ichevronhotBand
= -2;
3261 infoPtr
->iGrabbedBand
= -1;
3262 infoPtr
->hwndSelf
= hwnd
;
3263 infoPtr
->DoRedraw
= TRUE
;
3264 infoPtr
->hcurArrow
= LoadCursorW (0, (LPWSTR
)IDC_ARROW
);
3265 infoPtr
->hcurHorz
= LoadCursorW (0, (LPWSTR
)IDC_SIZEWE
);
3266 infoPtr
->hcurVert
= LoadCursorW (0, (LPWSTR
)IDC_SIZENS
);
3267 infoPtr
->hcurDrag
= LoadCursorW (0, (LPWSTR
)IDC_SIZE
);
3268 infoPtr
->fStatus
= 0;
3269 infoPtr
->hFont
= GetStockObject (SYSTEM_FONT
);
3270 infoPtr
->bands
= DPA_Create(8);
3272 /* issue WM_NOTIFYFORMAT to get unicode status of parent */
3273 REBAR_NotifyFormat(infoPtr
, NF_REQUERY
);
3275 /* Stow away the original style */
3276 infoPtr
->orgStyle
= cs
->style
;
3277 /* add necessary styles to the requested styles */
3278 infoPtr
->dwStyle
= cs
->style
| WS_VISIBLE
;
3279 if ((infoPtr
->dwStyle
& CCS_LAYOUT_MASK
) == 0)
3280 infoPtr
->dwStyle
|= CCS_TOP
;
3281 SetWindowLongW (hwnd
, GWL_STYLE
, infoPtr
->dwStyle
);
3283 /* get font handle for Caption Font */
3284 ncm
.cbSize
= sizeof(ncm
);
3285 SystemParametersInfoW (SPI_GETNONCLIENTMETRICS
, ncm
.cbSize
, &ncm
, 0);
3286 /* if the font is bold, set to normal */
3287 if (ncm
.lfCaptionFont
.lfWeight
> FW_NORMAL
) {
3288 ncm
.lfCaptionFont
.lfWeight
= FW_NORMAL
;
3290 tfont
= CreateFontIndirectW (&ncm
.lfCaptionFont
);
3292 infoPtr
->hFont
= infoPtr
->hDefaultFont
= tfont
;
3300 REBAR_NCHitTest (const REBAR_INFO
*infoPtr
, LPARAM lParam
)
3306 LRESULT ret
= HTCLIENT
;
3309 * Differences from doc at MSDN (as observed with version 4.71 of
3311 * 1. doc says nmmouse.pt is in screen coord, trace shows client coord.
3312 * 2. if band is not identified .dwItemSpec is 0xffffffff.
3313 * 3. native always seems to return HTCLIENT if notify return is 0.
3316 clpt
.x
= (short)LOWORD(lParam
);
3317 clpt
.y
= (short)HIWORD(lParam
);
3318 ScreenToClient (infoPtr
->hwndSelf
, &clpt
);
3319 REBAR_InternalHitTest (infoPtr
, &clpt
, &scrap
,
3320 (INT
*)&nmmouse
.dwItemSpec
);
3321 nmmouse
.dwItemData
= 0;
3323 nmmouse
.dwHitInfo
= 0;
3324 if ((i
= REBAR_Notify((NMHDR
*) &nmmouse
, infoPtr
, NM_NCHITTEST
))) {
3325 TRACE("notify changed return value from %ld to %d\n",
3329 TRACE("returning %ld, client point %s\n", ret
, wine_dbgstr_point(&clpt
));
3335 REBAR_NCPaint (const REBAR_INFO
*infoPtr
)
3341 if (infoPtr
->dwStyle
& WS_MINIMIZE
)
3342 return 0; /* Nothing to do */
3344 if (infoPtr
->dwStyle
& WS_BORDER
) {
3346 /* adjust rectangle and draw the necessary edge */
3347 if (!(hdc
= GetDCEx( infoPtr
->hwndSelf
, 0, DCX_USESTYLE
| DCX_WINDOW
)))
3349 GetWindowRect (infoPtr
->hwndSelf
, &rcWindow
);
3350 OffsetRect (&rcWindow
, -rcWindow
.left
, -rcWindow
.top
);
3351 TRACE("rect (%s)\n", wine_dbgstr_rect(&rcWindow
));
3352 DrawEdge (hdc
, &rcWindow
, EDGE_ETCHED
, BF_RECT
);
3353 ReleaseDC( infoPtr
->hwndSelf
, hdc
);
3355 else if ((theme
= GetWindowTheme (infoPtr
->hwndSelf
)))
3357 /* adjust rectangle and draw the necessary edge */
3358 if (!(hdc
= GetDCEx( infoPtr
->hwndSelf
, 0, DCX_USESTYLE
| DCX_WINDOW
)))
3360 GetWindowRect (infoPtr
->hwndSelf
, &rcWindow
);
3361 OffsetRect (&rcWindow
, -rcWindow
.left
, -rcWindow
.top
);
3362 TRACE("rect (%s)\n", wine_dbgstr_rect(&rcWindow
));
3363 DrawThemeEdge (theme
, hdc
, 0, 0, &rcWindow
, BDR_RAISEDINNER
, BF_TOP
, NULL
);
3364 ReleaseDC( infoPtr
->hwndSelf
, hdc
);
3372 REBAR_NotifyFormat (REBAR_INFO
*infoPtr
, LPARAM cmd
)
3376 if (cmd
== NF_REQUERY
) {
3377 i
= SendMessageW(REBAR_GetNotifyParent (infoPtr
),
3378 WM_NOTIFYFORMAT
, (WPARAM
)infoPtr
->hwndSelf
, NF_QUERY
);
3379 if ((i
!= NFR_ANSI
) && (i
!= NFR_UNICODE
)) {
3380 ERR("wrong response to WM_NOTIFYFORMAT (%d), assuming ANSI\n", i
);
3383 infoPtr
->bUnicode
= (i
== NFR_UNICODE
);
3386 return (LRESULT
)((infoPtr
->bUnicode
) ? NFR_UNICODE
: NFR_ANSI
);
3391 REBAR_Paint (const REBAR_INFO
*infoPtr
, HDC hdc
)
3394 TRACE("painting\n");
3395 REBAR_Refresh (infoPtr
, hdc
);
3398 hdc
= BeginPaint (infoPtr
->hwndSelf
, &ps
);
3399 TRACE("painting (%s)\n", wine_dbgstr_rect(&ps
.rcPaint
));
3401 /* Erase area of paint if requested */
3402 REBAR_EraseBkGnd (infoPtr
, hdc
);
3404 REBAR_Refresh (infoPtr
, hdc
);
3405 EndPaint (infoPtr
->hwndSelf
, &ps
);
3413 REBAR_SetCursor (const REBAR_INFO
*infoPtr
, LPARAM lParam
)
3418 TRACE("code=0x%X id=0x%X\n", LOWORD(lParam
), HIWORD(lParam
));
3421 ScreenToClient (infoPtr
->hwndSelf
, &pt
);
3423 REBAR_InternalHitTest (infoPtr
, &pt
, &flags
, NULL
);
3425 if (flags
== RBHT_GRABBER
) {
3426 if ((infoPtr
->dwStyle
& CCS_VERT
) &&
3427 !(infoPtr
->dwStyle
& RBS_VERTICALGRIPPER
))
3428 SetCursor (infoPtr
->hcurVert
);
3430 SetCursor (infoPtr
->hcurHorz
);
3432 else if (flags
!= RBHT_CLIENT
)
3433 SetCursor (infoPtr
->hcurArrow
);
3440 REBAR_SetFont (REBAR_INFO
*infoPtr
, HFONT font
)
3445 infoPtr
->hFont
= font
;
3447 /* revalidate all bands to change sizes of text in headers of bands */
3448 for (i
=0; i
<infoPtr
->uNumBands
; i
++) {
3449 lpBand
= REBAR_GetBand(infoPtr
, i
);
3450 REBAR_ValidateBand (infoPtr
, lpBand
);
3453 REBAR_Layout(infoPtr
);
3458 /*****************************************************
3460 * Handles the WM_SETREDRAW message.
3463 * According to testing V4.71 of COMCTL32 returns the
3464 * *previous* status of the redraw flag (either 0 or -1)
3465 * instead of the MSDN documented value of 0 if handled
3467 *****************************************************/
3468 static inline LRESULT
3469 REBAR_SetRedraw (REBAR_INFO
*infoPtr
, BOOL redraw
)
3471 BOOL oldredraw
= infoPtr
->DoRedraw
;
3473 TRACE("set to %s, fStatus=%08x\n",
3474 (redraw
) ? "TRUE" : "FALSE", infoPtr
->fStatus
);
3475 infoPtr
->DoRedraw
= redraw
;
3477 if (infoPtr
->fStatus
& BAND_NEEDS_REDRAW
) {
3478 REBAR_MoveChildWindows (infoPtr
, 0, infoPtr
->uNumBands
);
3479 REBAR_ForceResize (infoPtr
);
3480 InvalidateRect (infoPtr
->hwndSelf
, NULL
, TRUE
);
3482 infoPtr
->fStatus
&= ~BAND_NEEDS_REDRAW
;
3484 return (oldredraw
) ? -1 : 0;
3489 REBAR_Size (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
3491 TRACE("wParam=%lx, lParam=%lx\n", wParam
, lParam
);
3493 /* avoid _Layout resize recursion (but it shouldn't be infinite and it seems Windows does recurse) */
3494 if (infoPtr
->fStatus
& SELF_RESIZE
) {
3495 infoPtr
->fStatus
&= ~SELF_RESIZE
;
3496 TRACE("SELF_RESIZE was set, reset, fStatus=%08x lparam=%08lx\n",
3497 infoPtr
->fStatus
, lParam
);
3501 if (infoPtr
->dwStyle
& RBS_AUTOSIZE
)
3502 REBAR_AutoSize(infoPtr
, TRUE
);
3504 REBAR_Layout(infoPtr
);
3511 REBAR_StyleChanged (REBAR_INFO
*infoPtr
, INT nType
, const STYLESTRUCT
*lpStyle
)
3513 TRACE("current style=%08x, styleOld=%08x, style being set to=%08x\n",
3514 infoPtr
->dwStyle
, lpStyle
->styleOld
, lpStyle
->styleNew
);
3515 if (nType
== GWL_STYLE
)
3517 infoPtr
->orgStyle
= infoPtr
->dwStyle
= lpStyle
->styleNew
;
3518 if (GetWindowTheme (infoPtr
->hwndSelf
))
3519 infoPtr
->dwStyle
&= ~WS_BORDER
;
3520 /* maybe it should be COMMON_STYLES like in toolbar */
3521 if ((lpStyle
->styleNew
^ lpStyle
->styleOld
) & CCS_VERT
)
3522 REBAR_Layout(infoPtr
);
3527 /* update theme after a WM_THEMECHANGED message */
3528 static LRESULT
theme_changed (REBAR_INFO
* infoPtr
)
3530 HTHEME theme
= GetWindowTheme (infoPtr
->hwndSelf
);
3531 CloseThemeData (theme
);
3532 theme
= OpenThemeData (infoPtr
->hwndSelf
, themeClass
);
3533 /* WS_BORDER disappears when theming is enabled and reappears when
3535 infoPtr
->dwStyle
&= ~WS_BORDER
;
3536 infoPtr
->dwStyle
|= theme
? 0 : (infoPtr
->orgStyle
& WS_BORDER
);
3541 REBAR_WindowPosChanged (const REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
3546 ret
= DefWindowProcW(infoPtr
->hwndSelf
, WM_WINDOWPOSCHANGED
,
3548 GetWindowRect(infoPtr
->hwndSelf
, &rc
);
3549 TRACE("hwnd %p new pos (%s)\n", infoPtr
->hwndSelf
, wine_dbgstr_rect(&rc
));
3554 static LRESULT WINAPI
3555 REBAR_WindowProc (HWND hwnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
)
3557 REBAR_INFO
*infoPtr
= REBAR_GetInfoPtr (hwnd
);
3559 TRACE("hwnd=%p msg=%x wparam=%lx lparam=%lx\n",
3560 hwnd
, uMsg
, wParam
, lParam
);
3561 if (!infoPtr
&& (uMsg
!= WM_NCCREATE
))
3562 return DefWindowProcW (hwnd
, uMsg
, wParam
, lParam
);
3565 /* case RB_BEGINDRAG: */
3568 return REBAR_DeleteBand (infoPtr
, wParam
);
3570 /* case RB_DRAGMOVE: */
3571 /* case RB_ENDDRAG: */
3573 case RB_GETBANDBORDERS
:
3574 return REBAR_GetBandBorders (infoPtr
, wParam
, (LPRECT
)lParam
);
3576 case RB_GETBANDCOUNT
:
3577 return REBAR_GetBandCount (infoPtr
);
3579 case RB_GETBANDINFO_OLD
:
3580 case RB_GETBANDINFOA
:
3581 case RB_GETBANDINFOW
:
3582 return REBAR_GetBandInfoT(infoPtr
, wParam
, (LPREBARBANDINFOW
)lParam
,
3583 uMsg
== RB_GETBANDINFOW
);
3584 case RB_GETBARHEIGHT
:
3585 return REBAR_GetBarHeight (infoPtr
);
3588 return REBAR_GetBarInfo (infoPtr
, (LPREBARINFO
)lParam
);
3591 return REBAR_GetBkColor (infoPtr
);
3593 /* case RB_GETCOLORSCHEME: */
3594 /* case RB_GETDROPTARGET: */
3597 return REBAR_GetPalette (infoPtr
);
3600 return REBAR_GetRect (infoPtr
, wParam
, (LPRECT
)lParam
);
3602 case RB_GETROWCOUNT
:
3603 return REBAR_GetRowCount (infoPtr
);
3605 case RB_GETROWHEIGHT
:
3606 return REBAR_GetRowHeight (infoPtr
, wParam
);
3608 case RB_GETTEXTCOLOR
:
3609 return REBAR_GetTextColor (infoPtr
);
3611 case RB_GETTOOLTIPS
:
3612 return REBAR_GetToolTips (infoPtr
);
3614 case RB_GETUNICODEFORMAT
:
3615 return REBAR_GetUnicodeFormat (infoPtr
);
3617 case CCM_GETVERSION
:
3618 return REBAR_GetVersion (infoPtr
);
3621 return REBAR_HitTest (infoPtr
, (LPRBHITTESTINFO
)lParam
);
3624 return REBAR_IdToIndex (infoPtr
, wParam
);
3626 case RB_INSERTBANDA
:
3627 case RB_INSERTBANDW
:
3628 return REBAR_InsertBandT(infoPtr
, wParam
, (LPREBARBANDINFOW
)lParam
,
3629 uMsg
== RB_INSERTBANDW
);
3630 case RB_MAXIMIZEBAND
:
3631 return REBAR_MaximizeBand (infoPtr
, wParam
, lParam
);
3633 case RB_MINIMIZEBAND
:
3634 return REBAR_MinimizeBand (infoPtr
, wParam
);
3637 return REBAR_MoveBand (infoPtr
, wParam
, lParam
);
3639 case RB_PUSHCHEVRON
:
3640 return REBAR_PushChevron (infoPtr
, wParam
, lParam
);
3642 case RB_SETBANDINFOA
:
3643 case RB_SETBANDINFOW
:
3644 return REBAR_SetBandInfoT(infoPtr
, wParam
, (LPREBARBANDINFOW
)lParam
,
3645 uMsg
== RB_SETBANDINFOW
);
3647 return REBAR_SetBarInfo (infoPtr
, (LPREBARINFO
)lParam
);
3650 return REBAR_SetBkColor (infoPtr
, lParam
);
3652 /* case RB_SETCOLORSCHEME: */
3653 /* case RB_SETPALETTE: */
3656 return REBAR_SetParent (infoPtr
, (HWND
)wParam
);
3658 case RB_SETTEXTCOLOR
:
3659 return REBAR_SetTextColor (infoPtr
, lParam
);
3661 /* case RB_SETTOOLTIPS: */
3663 case RB_SETUNICODEFORMAT
:
3664 return REBAR_SetUnicodeFormat (infoPtr
, wParam
);
3666 case CCM_SETVERSION
:
3667 return REBAR_SetVersion (infoPtr
, (INT
)wParam
);
3670 return REBAR_ShowBand (infoPtr
, wParam
, lParam
);
3673 return REBAR_SizeToRect (infoPtr
, (LPCRECT
)lParam
);
3676 /* Messages passed to parent */
3680 case WM_MEASUREITEM
:
3681 return SendMessageW(REBAR_GetNotifyParent (infoPtr
), uMsg
, wParam
, lParam
);
3684 /* case WM_CHARTOITEM: supported according to ControlSpy */
3687 return REBAR_Create (infoPtr
, (LPCREATESTRUCTW
)lParam
);
3690 return REBAR_Destroy (infoPtr
);
3693 return REBAR_EraseBkGnd (infoPtr
, (HDC
)wParam
);
3696 return REBAR_GetFont (infoPtr
);
3698 /* case WM_LBUTTONDBLCLK: supported according to ControlSpy */
3700 case WM_LBUTTONDOWN
:
3701 return REBAR_LButtonDown (infoPtr
, lParam
);
3704 return REBAR_LButtonUp (infoPtr
);
3707 return REBAR_MouseMove (infoPtr
, lParam
);
3710 return REBAR_MouseLeave (infoPtr
);
3713 return REBAR_NCCalcSize (infoPtr
, (RECT
*)lParam
);
3716 return REBAR_NCCreate (hwnd
, (LPCREATESTRUCTW
)lParam
);
3719 return REBAR_NCHitTest (infoPtr
, lParam
);
3722 return REBAR_NCPaint (infoPtr
);
3724 case WM_NOTIFYFORMAT
:
3725 return REBAR_NotifyFormat (infoPtr
, lParam
);
3727 case WM_PRINTCLIENT
:
3729 return REBAR_Paint (infoPtr
, (HDC
)wParam
);
3731 /* case WM_PALETTECHANGED: supported according to ControlSpy */
3732 /* case WM_QUERYNEWPALETTE:supported according to ControlSpy */
3733 /* case WM_RBUTTONDOWN: supported according to ControlSpy */
3734 /* case WM_RBUTTONUP: supported according to ControlSpy */
3737 return REBAR_SetCursor (infoPtr
, lParam
);
3740 return REBAR_SetFont (infoPtr
, (HFONT
)wParam
);
3743 return REBAR_SetRedraw (infoPtr
, wParam
);
3746 return REBAR_Size (infoPtr
, wParam
, lParam
);
3748 case WM_STYLECHANGED
:
3749 return REBAR_StyleChanged (infoPtr
, wParam
, (LPSTYLESTRUCT
)lParam
);
3751 case WM_THEMECHANGED
:
3752 return theme_changed (infoPtr
);
3754 case WM_SYSCOLORCHANGE
:
3755 COMCTL32_RefreshSysColors();
3758 /* case WM_VKEYTOITEM: supported according to ControlSpy */
3759 /* case WM_WININICHANGE: */
3761 case WM_WINDOWPOSCHANGED
:
3762 return REBAR_WindowPosChanged (infoPtr
, wParam
, lParam
);
3765 if ((uMsg
>= WM_USER
) && (uMsg
< WM_APP
) && !COMCTL32_IsReflectedMessage(uMsg
))
3766 ERR("unknown msg %04x wp=%08lx lp=%08lx\n",
3767 uMsg
, wParam
, lParam
);
3768 return DefWindowProcW (hwnd
, uMsg
, wParam
, lParam
);
3774 REBAR_Register (void)
3778 ZeroMemory (&wndClass
, sizeof(WNDCLASSW
));
3779 wndClass
.style
= CS_GLOBALCLASS
| CS_DBLCLKS
;
3780 wndClass
.lpfnWndProc
= REBAR_WindowProc
;
3781 wndClass
.cbClsExtra
= 0;
3782 wndClass
.cbWndExtra
= sizeof(REBAR_INFO
*);
3783 wndClass
.hCursor
= 0;
3784 wndClass
.hbrBackground
= (HBRUSH
)(COLOR_BTNFACE
+ 1);
3786 wndClass
.hbrBackground
= CreateSolidBrush(RGB(0,128,0));
3788 wndClass
.lpszClassName
= REBARCLASSNAMEW
;
3790 RegisterClassW (&wndClass
);
3792 mindragx
= GetSystemMetrics (SM_CXDRAG
);
3793 mindragy
= GetSystemMetrics (SM_CYDRAG
);
3799 REBAR_Unregister (void)
3801 UnregisterClassW (REBARCLASSNAMEW
, NULL
);