4 * Copyright 1998, 1999 Eric Kohl
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 * This code was audited for completeness against the documented features
23 * of Comctl32.dll version 6.0 on Oct. 19, 2004, by Robert Shearman.
25 * Unless otherwise noted, we believe this code to be complete, as per
26 * the specification mentioned above.
27 * If you discover missing features or bugs please note them below.
53 * - WM_QUERYNEWPALETTE
61 * - NM_RELEASEDCAPTURE
67 * Native uses (on each draw!!) SM_CYBORDER (or SM_CXBORDER for CCS_VERT)
68 * to set the size of the separator width (the value SEP_WIDTH_SIZE
69 * in here). Should be fixed!!
73 * Testing: set to 1 to make background brush *always* green
79 * 2. At "FIXME: problem # 2" WinRAR:
80 * if "#if 1" then last band draws in separate row
81 * if "#if 0" then last band draws in previous row *** just like native ***
87 * 3. REBAR_MoveChildWindows should have a loop because more than
88 * one pass is made (together with the RBN_CHILDSIZEs) is made on
89 * at least RB_INSERTBAND
99 #include "wine/unicode.h"
102 #include "commctrl.h"
103 #include "comctl32.h"
105 #include "tmschema.h"
106 #include "wine/debug.h"
108 WINE_DEFAULT_DEBUG_CHANNEL(rebar
);
118 UINT cxMinChild
; /* valid if _CHILDSIZE */
119 UINT cyMinChild
; /* valid if _CHILDSIZE */
120 UINT cx
; /* valid if _SIZE */
123 UINT cyChild
; /* valid if _CHILDSIZE */
124 UINT cyMaxChild
; /* valid if _CHILDSIZE */
125 UINT cyIntegral
; /* valid if _CHILDSIZE */
130 UINT lcx
; /* minimum cx for band */
131 UINT ccx
; /* current cx for band */
132 UINT hcx
; /* maximum cx for band */
133 UINT lcy
; /* minimum cy for band */
134 UINT ccy
; /* current cy for band */
135 UINT hcy
; /* maximum cy for band */
137 SIZE offChild
; /* x,y offset if child is not FIXEDSIZE */
139 INT iRow
; /* zero-based index of the row this band assigned to */
140 UINT fStatus
; /* status flags, reset only by _Validate */
141 UINT fDraw
; /* drawing flags, reset only by _Layout */
142 UINT uCDret
; /* last return from NM_CUSTOMDRAW */
143 RECT rcoldBand
; /* previous calculated band rectangle */
144 RECT rcBand
; /* calculated band rectangle */
145 RECT rcGripper
; /* calculated gripper rectangle */
146 RECT rcCapImage
; /* calculated caption image rectangle */
147 RECT rcCapText
; /* calculated caption text rectangle */
148 RECT rcChild
; /* calculated child rectangle */
149 RECT rcChevron
; /* calculated chevron rectangle */
156 #define HAS_GRIPPER 0x00000001
157 #define HAS_IMAGE 0x00000002
158 #define HAS_TEXT 0x00000004
161 #define DRAW_GRIPPER 0x00000001
162 #define DRAW_IMAGE 0x00000002
163 #define DRAW_TEXT 0x00000004
164 #define DRAW_RIGHTSEP 0x00000010
165 #define DRAW_BOTTOMSEP 0x00000020
166 #define DRAW_CHEVRONHOT 0x00000040
167 #define DRAW_CHEVRONPUSHED 0x00000080
168 #define DRAW_LAST_IN_ROW 0x00000100
169 #define DRAW_FIRST_IN_ROW 0x00000200
170 #define NTF_INVALIDATE 0x01000000
174 COLORREF clrBk
; /* background color */
175 COLORREF clrText
; /* text color */
176 COLORREF clrBtnText
; /* system color for BTNTEXT */
177 COLORREF clrBtnFace
; /* system color for BTNFACE */
178 HIMAGELIST himl
; /* handle to imagelist */
179 UINT uNumBands
; /* # of bands in rebar (first=0, last=uNumBands-1 */
180 UINT uNumRows
; /* # of rows of bands (first=1, last=uNumRows */
181 HWND hwndSelf
; /* handle of REBAR window itself */
182 HWND hwndToolTip
; /* handle to the tool tip control */
183 HWND hwndNotify
; /* notification window (parent) */
185 HFONT hFont
; /* handle to the rebar's font */
186 SIZE imageSize
; /* image size (image list) */
187 DWORD dwStyle
; /* window style */
188 DWORD orgStyle
; /* original style (dwStyle may change) */
189 SIZE calcSize
; /* calculated rebar size */
190 SIZE oldSize
; /* previous calculated rebar size */
191 BOOL bUnicode
; /* TRUE if this window is W type */
192 BOOL NtfUnicode
; /* TRUE if parent wants notify in W format */
193 BOOL DoRedraw
; /* TRUE to acutally draw bands */
194 UINT fStatus
; /* Status flags (see below) */
195 HCURSOR hcurArrow
; /* handle to the arrow cursor */
196 HCURSOR hcurHorz
; /* handle to the EW cursor */
197 HCURSOR hcurVert
; /* handle to the NS cursor */
198 HCURSOR hcurDrag
; /* handle to the drag cursor */
199 INT iVersion
; /* version number */
200 POINT dragStart
; /* x,y of button down */
201 POINT dragNow
; /* x,y of this MouseMove */
202 INT iOldBand
; /* last band that had the mouse cursor over it */
203 INT ihitoffset
; /* offset of hotspot from gripper.left */
204 POINT origin
; /* left/upper corner of client */
205 INT ichevronhotBand
; /* last band that had a hot chevron */
206 INT iGrabbedBand
;/* band number of band whose gripper was grabbed */
208 REBAR_BAND
*bands
; /* pointer to the array of rebar bands */
212 #define BEGIN_DRAG_ISSUED 0x00000001
213 #define AUTO_RESIZE 0x00000002
214 #define RESIZE_ANYHOW 0x00000004
215 #define NTF_HGHTCHG 0x00000008
216 #define BAND_NEEDS_LAYOUT 0x00000010
217 #define BAND_NEEDS_REDRAW 0x00000020
218 #define CREATE_RUNNING 0x00000040
220 /* ---- REBAR layout constants. Mostly determined by ---- */
221 /* ---- experiment on WIN 98. ---- */
223 /* Width (or height) of separators between bands (either horz. or */
224 /* vert.). True only if RBS_BANDBORDERS is set */
225 #define SEP_WIDTH_SIZE 2
226 #define SEP_WIDTH ((infoPtr->dwStyle & RBS_BANDBORDERS) ? SEP_WIDTH_SIZE : 0)
228 /* Blank (background color) space between Gripper (if present) */
229 /* and next item (image, text, or window). Always present */
230 #define REBAR_ALWAYS_SPACE 4
232 /* Blank (background color) space after Image (if present). */
233 #define REBAR_POST_IMAGE 2
235 /* Blank (background color) space after Text (if present). */
236 #define REBAR_POST_TEXT 4
238 /* Height of vertical gripper in a CCS_VERT rebar. */
239 #define GRIPPER_HEIGHT 16
241 /* Blank (background color) space before Gripper (if present). */
242 #define REBAR_PRE_GRIPPER 2
244 /* Width (of normal vertical gripper) or height (of horz. gripper) */
246 #define GRIPPER_WIDTH 3
248 /* Width of the chevron button if present */
249 #define CHEVRON_WIDTH 10
251 /* Height of divider for Rebar if not disabled (CCS_NODIVIDER) */
252 /* either top or bottom */
253 #define REBAR_DIVIDER 2
255 /* minimium vertical height of a normal bar */
256 /* or minimum width of a CCS_VERT bar - from experiment on Win2k */
257 #define REBAR_MINSIZE 23
259 /* This is the increment that is used over the band height */
260 #define REBARSPACE(a) ((a->fStyle & RBBS_CHILDEDGE) ? 2*REBAR_DIVIDER : 0)
262 /* ---- End of REBAR layout constants. ---- */
264 #define RB_GETBANDINFO_OLD (WM_USER+5) /* obsoleted after IE3, but we have to support it anyway */
266 /* The following 6 defines return the proper rcBand element */
267 /* depending on whether CCS_VERT was set. */
268 #define rcBlt(b) ((infoPtr->dwStyle & CCS_VERT) ? b->rcBand.top : b->rcBand.left)
269 #define rcBrb(b) ((infoPtr->dwStyle & CCS_VERT) ? b->rcBand.bottom : b->rcBand.right)
270 #define rcBw(b) ((infoPtr->dwStyle & CCS_VERT) ? (b->rcBand.bottom - b->rcBand.top) : \
271 (b->rcBand.right - b->rcBand.left))
272 #define ircBlt(b) ((infoPtr->dwStyle & CCS_VERT) ? b->rcBand.left : b->rcBand.top)
273 #define ircBrb(b) ((infoPtr->dwStyle & CCS_VERT) ? b->rcBand.right : b->rcBand.bottom)
274 #define ircBw(b) ((infoPtr->dwStyle & CCS_VERT) ? (b->rcBand.right - b->rcBand.left) : \
275 (b->rcBand.bottom - b->rcBand.top))
277 /* The following define determines if a given band is hidden */
278 #define HIDDENBAND(a) (((a)->fStyle & RBBS_HIDDEN) || \
279 ((infoPtr->dwStyle & CCS_VERT) && \
280 ((a)->fStyle & RBBS_NOVERT)))
282 /* The following defines adjust the right or left end of a rectangle */
283 #define READJ(b,i) do { if(infoPtr->dwStyle & CCS_VERT) b->rcBand.bottom+=(i); \
284 else b->rcBand.right += (i); } while(0)
285 #define LEADJ(b,i) do { if(infoPtr->dwStyle & CCS_VERT) b->rcBand.top+=(i); \
286 else b->rcBand.left += (i); } while(0)
289 #define REBAR_GetInfoPtr(wndPtr) ((REBAR_INFO *)GetWindowLongPtrW (hwnd, 0))
292 /* "constant values" retrieved when DLL was initialized */
293 /* FIXME we do this when the classes are registered. */
294 static UINT mindragx
= 0;
295 static UINT mindragy
= 0;
297 static const char *band_stylename
[] = {
298 "RBBS_BREAK", /* 0001 */
299 "RBBS_FIXEDSIZE", /* 0002 */
300 "RBBS_CHILDEDGE", /* 0004 */
301 "RBBS_HIDDEN", /* 0008 */
302 "RBBS_NOVERT", /* 0010 */
303 "RBBS_FIXEDBMP", /* 0020 */
304 "RBBS_VARIABLEHEIGHT", /* 0040 */
305 "RBBS_GRIPPERALWAYS", /* 0080 */
306 "RBBS_NOGRIPPER", /* 0100 */
309 static const char *band_maskname
[] = {
310 "RBBIM_STYLE", /* 0x00000001 */
311 "RBBIM_COLORS", /* 0x00000002 */
312 "RBBIM_TEXT", /* 0x00000004 */
313 "RBBIM_IMAGE", /* 0x00000008 */
314 "RBBIM_CHILD", /* 0x00000010 */
315 "RBBIM_CHILDSIZE", /* 0x00000020 */
316 "RBBIM_SIZE", /* 0x00000040 */
317 "RBBIM_BACKGROUND", /* 0x00000080 */
318 "RBBIM_ID", /* 0x00000100 */
319 "RBBIM_IDEALSIZE", /* 0x00000200 */
320 "RBBIM_LPARAM", /* 0x00000400 */
321 "RBBIM_HEADERSIZE", /* 0x00000800 */
325 static CHAR line
[200];
327 static const WCHAR themeClass
[] = { 'R','e','b','a','r',0 };
330 REBAR_FmtStyle( UINT style
)
335 while (band_stylename
[i
]) {
336 if (style
& (1<<i
)) {
337 if (*line
!= 0) strcat(line
, " | ");
338 strcat(line
, band_stylename
[i
]);
347 REBAR_FmtMask( UINT mask
)
352 while (band_maskname
[i
]) {
354 if (*line
!= 0) strcat(line
, " | ");
355 strcat(line
, band_maskname
[i
]);
364 REBAR_DumpBandInfo( LPREBARBANDINFOA pB
)
366 if( !TRACE_ON(rebar
) ) return;
367 TRACE("band info: ");
368 if (pB
->fMask
& RBBIM_ID
)
369 TRACE("ID=%u, ", pB
->wID
);
370 TRACE("size=%u, child=%p", pB
->cbSize
, pB
->hwndChild
);
371 if (pB
->fMask
& RBBIM_COLORS
)
372 TRACE(", clrF=0x%06lx, clrB=0x%06lx", pB
->clrFore
, pB
->clrBack
);
375 TRACE("band info: mask=0x%08x (%s)\n", pB
->fMask
, REBAR_FmtMask(pB
->fMask
));
376 if (pB
->fMask
& RBBIM_STYLE
)
377 TRACE("band info: style=0x%08x (%s)\n", pB
->fStyle
, REBAR_FmtStyle(pB
->fStyle
));
378 if (pB
->fMask
& (RBBIM_SIZE
| RBBIM_IDEALSIZE
| RBBIM_HEADERSIZE
| RBBIM_LPARAM
)) {
380 if (pB
->fMask
& RBBIM_SIZE
)
381 TRACE(" cx=%u", pB
->cx
);
382 if (pB
->fMask
& RBBIM_IDEALSIZE
)
383 TRACE(" xIdeal=%u", pB
->cxIdeal
);
384 if (pB
->fMask
& RBBIM_HEADERSIZE
)
385 TRACE(" xHeader=%u", pB
->cxHeader
);
386 if (pB
->fMask
& RBBIM_LPARAM
)
387 TRACE(" lParam=0x%08lx", pB
->lParam
);
390 if (pB
->fMask
& RBBIM_CHILDSIZE
)
391 TRACE("band info: xMin=%u, yMin=%u, yChild=%u, yMax=%u, yIntgl=%u\n",
393 pB
->cyMinChild
, pB
->cyChild
, pB
->cyMaxChild
, pB
->cyIntegral
);
397 REBAR_DumpBand (REBAR_INFO
*iP
)
402 if(! TRACE_ON(rebar
) ) return;
404 TRACE("hwnd=%p: color=%08lx/%08lx, bands=%u, rows=%u, cSize=%ld,%ld\n",
405 iP
->hwndSelf
, iP
->clrText
, iP
->clrBk
, iP
->uNumBands
, iP
->uNumRows
,
406 iP
->calcSize
.cx
, iP
->calcSize
.cy
);
407 TRACE("hwnd=%p: flags=%08x, dragStart=%ld,%ld, dragNow=%ld,%ld, iGrabbedBand=%d\n",
408 iP
->hwndSelf
, iP
->fStatus
, iP
->dragStart
.x
, iP
->dragStart
.y
,
409 iP
->dragNow
.x
, iP
->dragNow
.y
,
411 TRACE("hwnd=%p: style=%08lx, I'm Unicode=%s, notify in Unicode=%s, redraw=%s\n",
412 iP
->hwndSelf
, iP
->dwStyle
, (iP
->bUnicode
)?"TRUE":"FALSE",
413 (iP
->NtfUnicode
)?"TRUE":"FALSE", (iP
->DoRedraw
)?"TRUE":"FALSE");
414 for (i
= 0; i
< iP
->uNumBands
; i
++) {
416 TRACE("band # %u:", i
);
417 if (pB
->fMask
& RBBIM_ID
)
418 TRACE(" ID=%u", pB
->wID
);
419 if (pB
->fMask
& RBBIM_CHILD
)
420 TRACE(" child=%p", pB
->hwndChild
);
421 if (pB
->fMask
& RBBIM_COLORS
)
422 TRACE(" clrF=0x%06lx clrB=0x%06lx", pB
->clrFore
, pB
->clrBack
);
424 TRACE("band # %u: mask=0x%08x (%s)\n", i
, pB
->fMask
, REBAR_FmtMask(pB
->fMask
));
425 if (pB
->fMask
& RBBIM_STYLE
)
426 TRACE("band # %u: style=0x%08x (%s)\n",
427 i
, pB
->fStyle
, REBAR_FmtStyle(pB
->fStyle
));
428 TRACE("band # %u: uMinH=%u xHeader=%u",
429 i
, pB
->uMinHeight
, pB
->cxHeader
);
430 if (pB
->fMask
& (RBBIM_SIZE
| RBBIM_IDEALSIZE
| RBBIM_LPARAM
)) {
431 if (pB
->fMask
& RBBIM_SIZE
)
432 TRACE(" cx=%u", pB
->cx
);
433 if (pB
->fMask
& RBBIM_IDEALSIZE
)
434 TRACE(" xIdeal=%u", pB
->cxIdeal
);
435 if (pB
->fMask
& RBBIM_LPARAM
)
436 TRACE(" lParam=0x%08lx", pB
->lParam
);
440 TRACE("band # %u: xMin=%u, yMin=%u, yChild=%u, yMax=%u, yIntgl=%u\n",
441 i
, pB
->cxMinChild
, pB
->cyMinChild
, pB
->cyChild
, pB
->cyMaxChild
, pB
->cyIntegral
);
442 if (pB
->fMask
& RBBIM_TEXT
)
443 TRACE("band # %u: text=%s\n",
444 i
, (pB
->lpText
) ? debugstr_w(pB
->lpText
) : "(null)");
445 TRACE("band # %u: lcx=%u, ccx=%u, hcx=%u, lcy=%u, ccy=%u, hcy=%u, offChild=%ld,%ld\n",
446 i
, pB
->lcx
, pB
->ccx
, pB
->hcx
, pB
->lcy
, pB
->ccy
, pB
->hcy
, pB
->offChild
.cx
, pB
->offChild
.cy
);
447 TRACE("band # %u: fStatus=%08x, fDraw=%08x, Band=(%ld,%ld)-(%ld,%ld), Grip=(%ld,%ld)-(%ld,%ld)\n",
448 i
, pB
->fStatus
, pB
->fDraw
,
449 pB
->rcBand
.left
, pB
->rcBand
.top
, pB
->rcBand
.right
, pB
->rcBand
.bottom
,
450 pB
->rcGripper
.left
, pB
->rcGripper
.top
, pB
->rcGripper
.right
, pB
->rcGripper
.bottom
);
451 TRACE("band # %u: Img=(%ld,%ld)-(%ld,%ld), Txt=(%ld,%ld)-(%ld,%ld), Child=(%ld,%ld)-(%ld,%ld)\n",
453 pB
->rcCapImage
.left
, pB
->rcCapImage
.top
, pB
->rcCapImage
.right
, pB
->rcCapImage
.bottom
,
454 pB
->rcCapText
.left
, pB
->rcCapText
.top
, pB
->rcCapText
.right
, pB
->rcCapText
.bottom
,
455 pB
->rcChild
.left
, pB
->rcChild
.top
, pB
->rcChild
.right
, pB
->rcChild
.bottom
);
461 REBAR_DrawChevron (HDC hdc
, INT left
, INT top
, INT colorRef
)
466 if (!(hPen
= CreatePen( PS_SOLID
, 1, GetSysColor( colorRef
)))) return;
467 hOldPen
= SelectObject ( hdc
, hPen
);
470 MoveToEx (hdc
, x
, y
, NULL
);
471 LineTo (hdc
, x
+5, y
++); x
++;
472 MoveToEx (hdc
, x
, y
, NULL
);
473 LineTo (hdc
, x
+3, y
++); x
++;
474 MoveToEx (hdc
, x
, y
, NULL
);
475 LineTo (hdc
, x
+1, y
++);
476 SelectObject( hdc
, hOldPen
);
477 DeleteObject( hPen
);
481 REBAR_GetNotifyParent (REBAR_INFO
*infoPtr
)
485 parent
= infoPtr
->hwndNotify
;
487 parent
= GetParent (infoPtr
->hwndSelf
);
488 owner
= GetWindow (infoPtr
->hwndSelf
, GW_OWNER
);
489 if (owner
) parent
= owner
;
496 REBAR_Notify (NMHDR
*nmhdr
, REBAR_INFO
*infoPtr
, UINT code
)
500 parent
= REBAR_GetNotifyParent (infoPtr
);
501 nmhdr
->idFrom
= GetDlgCtrlID (infoPtr
->hwndSelf
);
502 nmhdr
->hwndFrom
= infoPtr
->hwndSelf
;
505 TRACE("window %p, code=%08x, %s\n", parent
, code
,
506 (infoPtr
->NtfUnicode
) ? "via Unicode" : "via ANSI");
508 if (infoPtr
->NtfUnicode
)
509 return SendMessageW (parent
, WM_NOTIFY
, (WPARAM
) nmhdr
->idFrom
,
512 return SendMessageA (parent
, WM_NOTIFY
, (WPARAM
) nmhdr
->idFrom
,
517 REBAR_Notify_NMREBAR (REBAR_INFO
*infoPtr
, UINT uBand
, UINT code
)
519 NMREBAR notify_rebar
;
522 notify_rebar
.dwMask
= 0;
524 lpBand
= &infoPtr
->bands
[uBand
];
525 if (lpBand
->fMask
& RBBIM_ID
) {
526 notify_rebar
.dwMask
|= RBNM_ID
;
527 notify_rebar
.wID
= lpBand
->wID
;
529 if (lpBand
->fMask
& RBBIM_LPARAM
) {
530 notify_rebar
.dwMask
|= RBNM_LPARAM
;
531 notify_rebar
.lParam
= lpBand
->lParam
;
533 if (lpBand
->fMask
& RBBIM_STYLE
) {
534 notify_rebar
.dwMask
|= RBNM_STYLE
;
535 notify_rebar
.fStyle
= lpBand
->fStyle
;
538 notify_rebar
.uBand
= uBand
;
539 return REBAR_Notify ((NMHDR
*)¬ify_rebar
, infoPtr
, code
);
543 REBAR_DrawBand (HDC hdc
, REBAR_INFO
*infoPtr
, REBAR_BAND
*lpBand
)
548 HTHEME theme
= GetWindowTheme (infoPtr
->hwndSelf
);
550 if (lpBand
->fDraw
& DRAW_TEXT
) {
551 hOldFont
= SelectObject (hdc
, infoPtr
->hFont
);
552 oldBkMode
= SetBkMode (hdc
, TRANSPARENT
);
555 /* should test for CDRF_NOTIFYITEMDRAW here */
556 nmcd
.dwDrawStage
= CDDS_ITEMPREPAINT
;
558 nmcd
.rc
= lpBand
->rcBand
;
559 nmcd
.rc
.right
= lpBand
->rcCapText
.right
;
560 nmcd
.rc
.bottom
= lpBand
->rcCapText
.bottom
;
561 nmcd
.dwItemSpec
= lpBand
->wID
;
563 nmcd
.lItemlParam
= lpBand
->lParam
;
564 lpBand
->uCDret
= REBAR_Notify ((NMHDR
*)&nmcd
, infoPtr
, NM_CUSTOMDRAW
);
565 if (lpBand
->uCDret
== CDRF_SKIPDEFAULT
) {
566 if (oldBkMode
!= TRANSPARENT
)
567 SetBkMode (hdc
, oldBkMode
);
568 SelectObject (hdc
, hOldFont
);
573 if (lpBand
->fDraw
& DRAW_GRIPPER
)
577 RECT rcGripper
= lpBand
->rcGripper
;
578 int partId
= (infoPtr
->dwStyle
& CCS_VERT
) ? RP_GRIPPERVERT
: RP_GRIPPER
;
579 GetThemeBackgroundExtent (theme
, hdc
, partId
, 0, &rcGripper
, &rcGripper
);
580 OffsetRect (&rcGripper
, lpBand
->rcGripper
.left
- rcGripper
.left
,
581 lpBand
->rcGripper
.top
- rcGripper
.top
);
582 DrawThemeBackground (theme
, hdc
, partId
, 0, &rcGripper
, NULL
);
585 DrawEdge (hdc
, &lpBand
->rcGripper
, BDR_RAISEDINNER
, BF_RECT
| BF_MIDDLE
);
588 /* draw caption image */
589 if (lpBand
->fDraw
& DRAW_IMAGE
) {
593 pt
.y
= (lpBand
->rcCapImage
.bottom
+ lpBand
->rcCapImage
.top
- infoPtr
->imageSize
.cy
)/2;
594 pt
.x
= (lpBand
->rcCapImage
.right
+ lpBand
->rcCapImage
.left
- infoPtr
->imageSize
.cx
)/2;
596 ImageList_Draw (infoPtr
->himl
, lpBand
->iImage
, hdc
,
601 /* draw caption text */
602 if (lpBand
->fDraw
& DRAW_TEXT
) {
603 /* need to handle CDRF_NEWFONT here */
604 INT oldBkMode
= SetBkMode (hdc
, TRANSPARENT
);
605 COLORREF oldcolor
= CLR_NONE
;
607 if (lpBand
->clrFore
!= CLR_NONE
) {
608 new = (lpBand
->clrFore
== CLR_DEFAULT
) ? infoPtr
->clrBtnText
:
610 oldcolor
= SetTextColor (hdc
, new);
612 DrawTextW (hdc
, lpBand
->lpText
, -1, &lpBand
->rcCapText
,
613 DT_CENTER
| DT_VCENTER
| DT_SINGLELINE
);
614 if (oldBkMode
!= TRANSPARENT
)
615 SetBkMode (hdc
, oldBkMode
);
616 if (lpBand
->clrFore
!= CLR_NONE
)
617 SetTextColor (hdc
, oldcolor
);
618 SelectObject (hdc
, hOldFont
);
621 if (!IsRectEmpty(&lpBand
->rcChevron
))
626 if (lpBand
->fDraw
& DRAW_CHEVRONPUSHED
)
627 stateId
= CHEVS_PRESSED
;
628 else if (lpBand
->fDraw
& DRAW_CHEVRONHOT
)
631 stateId
= CHEVS_NORMAL
;
632 DrawThemeBackground (theme
, hdc
, RP_CHEVRON
, stateId
, &lpBand
->rcChevron
, NULL
);
636 if (lpBand
->fDraw
& DRAW_CHEVRONPUSHED
)
638 DrawEdge(hdc
, &lpBand
->rcChevron
, BDR_SUNKENOUTER
, BF_RECT
| BF_MIDDLE
);
639 REBAR_DrawChevron(hdc
, lpBand
->rcChevron
.left
+1, lpBand
->rcChevron
.top
+ 11, COLOR_WINDOWFRAME
);
641 else if (lpBand
->fDraw
& DRAW_CHEVRONHOT
)
643 DrawEdge(hdc
, &lpBand
->rcChevron
, BDR_RAISEDINNER
, BF_RECT
| BF_MIDDLE
);
644 REBAR_DrawChevron(hdc
, lpBand
->rcChevron
.left
, lpBand
->rcChevron
.top
+ 10, COLOR_WINDOWFRAME
);
647 REBAR_DrawChevron(hdc
, lpBand
->rcChevron
.left
, lpBand
->rcChevron
.top
+ 10, COLOR_WINDOWFRAME
);
651 if (lpBand
->uCDret
== (CDRF_NOTIFYPOSTPAINT
| CDRF_NOTIFYITEMDRAW
)) {
652 nmcd
.dwDrawStage
= CDDS_ITEMPOSTPAINT
;
654 nmcd
.rc
= lpBand
->rcBand
;
655 nmcd
.rc
.right
= lpBand
->rcCapText
.right
;
656 nmcd
.rc
.bottom
= lpBand
->rcCapText
.bottom
;
657 nmcd
.dwItemSpec
= lpBand
->wID
;
659 nmcd
.lItemlParam
= lpBand
->lParam
;
660 lpBand
->uCDret
= REBAR_Notify ((NMHDR
*)&nmcd
, infoPtr
, NM_CUSTOMDRAW
);
666 REBAR_Refresh (REBAR_INFO
*infoPtr
, HDC hdc
)
671 if (!infoPtr
->DoRedraw
) return;
673 for (i
= 0; i
< infoPtr
->uNumBands
; i
++) {
674 lpBand
= &infoPtr
->bands
[i
];
676 if (HIDDENBAND(lpBand
)) continue;
678 /* now draw the band */
679 TRACE("[%p] drawing band %i, flags=%08x\n",
680 infoPtr
->hwndSelf
, i
, lpBand
->fDraw
);
681 REBAR_DrawBand (hdc
, infoPtr
, lpBand
);
688 REBAR_FixVert (REBAR_INFO
*infoPtr
, UINT rowstart
, UINT rowend
,
691 /* Cycle through bands in row and fix height of each band. */
692 /* Also determine whether each band has changed. */
694 /* all bands at desired size. */
695 /* start and end bands are *not* hidden */
700 for (i
= (INT
)rowstart
; i
<=(INT
)rowend
; i
++) {
701 lpBand
= &infoPtr
->bands
[i
];
702 if (HIDDENBAND(lpBand
)) continue;
704 /* adjust height of bands in row to "mcy" value */
705 if (infoPtr
->dwStyle
& CCS_VERT
) {
706 if (lpBand
->rcBand
.right
!= lpBand
->rcBand
.left
+ mcy
)
707 lpBand
->rcBand
.right
= lpBand
->rcBand
.left
+ mcy
;
710 if (lpBand
->rcBand
.bottom
!= lpBand
->rcBand
.top
+ mcy
)
711 lpBand
->rcBand
.bottom
= lpBand
->rcBand
.top
+ mcy
;
715 /* mark whether we need to invalidate this band and trace */
716 if ((lpBand
->rcoldBand
.left
!=lpBand
->rcBand
.left
) ||
717 (lpBand
->rcoldBand
.top
!=lpBand
->rcBand
.top
) ||
718 (lpBand
->rcoldBand
.right
!=lpBand
->rcBand
.right
) ||
719 (lpBand
->rcoldBand
.bottom
!=lpBand
->rcBand
.bottom
)) {
720 lpBand
->fDraw
|= NTF_INVALIDATE
;
721 TRACE("band %d row=%d: changed to (%ld,%ld)-(%ld,%ld) from (%ld,%ld)-(%ld,%ld)\n",
723 lpBand
->rcBand
.left
, lpBand
->rcBand
.top
,
724 lpBand
->rcBand
.right
, lpBand
->rcBand
.bottom
,
725 lpBand
->rcoldBand
.left
, lpBand
->rcoldBand
.top
,
726 lpBand
->rcoldBand
.right
, lpBand
->rcoldBand
.bottom
);
729 TRACE("band %d row=%d: unchanged (%ld,%ld)-(%ld,%ld)\n",
731 lpBand
->rcBand
.left
, lpBand
->rcBand
.top
,
732 lpBand
->rcBand
.right
, lpBand
->rcBand
.bottom
);
738 REBAR_AdjustBands (REBAR_INFO
*infoPtr
, UINT rowstart
, UINT rowend
,
740 /* Function: This routine distributes the extra space in a row. */
741 /* See algorithm below. */
743 /* all bands @ ->cxHeader size */
744 /* start and end bands are *not* hidden */
747 UINT xsep
, extra
, curwidth
, fudge
;
748 INT x
, i
, last_adjusted
;
750 TRACE("start=%u, end=%u, max x=%d, max y=%d\n",
751 rowstart
, rowend
, maxx
, mcy
);
753 /* ******************* Phase 1 ************************ */
755 /* For each visible band with valid child */
756 /* a. inflate band till either all extra space used */
757 /* or band's ->ccx reached. */
758 /* If any band modified, add any space left to last band */
761 /* ****************************************************** */
762 lpBand
= &infoPtr
->bands
[rowend
];
763 extra
= maxx
- rcBrb(lpBand
);
766 for (i
=(INT
)rowstart
; i
<=(INT
)rowend
; i
++) {
767 lpBand
= &infoPtr
->bands
[i
];
768 if (HIDDENBAND(lpBand
)) continue;
769 xsep
= (x
== 0) ? 0 : SEP_WIDTH
;
770 curwidth
= rcBw(lpBand
);
772 /* set new left/top point */
773 if (infoPtr
->dwStyle
& CCS_VERT
)
774 lpBand
->rcBand
.top
= x
+ xsep
;
776 lpBand
->rcBand
.left
= x
+ xsep
;
778 /* compute new width */
779 if ((lpBand
->hwndChild
&& extra
) && !(lpBand
->fStyle
& RBBS_FIXEDSIZE
)) {
780 /* set to the "current" band size less the header */
783 if ((lpBand
->fMask
& RBBIM_SIZE
) && (lpBand
->cx
> 0) &&
784 (fudge
> curwidth
)) {
785 TRACE("adjusting band %d by %d, fudge=%d, curwidth=%d, extra=%d\n",
786 i
, fudge
-curwidth
, fudge
, curwidth
, extra
);
787 if ((fudge
- curwidth
) > extra
)
788 fudge
= curwidth
+ extra
;
789 extra
-= (fudge
- curwidth
);
793 TRACE("adjusting band %d by %d, fudge=%d, curwidth=%d\n",
794 i
, extra
, fudge
, curwidth
);
800 /* set new right/bottom point */
801 if (infoPtr
->dwStyle
& CCS_VERT
)
802 lpBand
->rcBand
.bottom
= lpBand
->rcBand
.top
+ curwidth
;
804 lpBand
->rcBand
.right
= lpBand
->rcBand
.left
+ curwidth
;
805 TRACE("Phase 1 band %d, (%ld,%ld)-(%ld,%ld), orig x=%d, xsep=%d\n",
806 i
, lpBand
->rcBand
.left
, lpBand
->rcBand
.top
,
807 lpBand
->rcBand
.right
, lpBand
->rcBand
.bottom
, x
, xsep
);
810 if ((x
>= maxx
) || (last_adjusted
!= -1)) {
812 ERR("Phase 1 failed, x=%d, maxx=%d, start=%u, end=%u\n",
813 x
, maxx
, rowstart
, rowend
);
815 /* done, so spread extra space */
818 TRACE("Need to spread %d on last adjusted band %d\n",
819 fudge
, last_adjusted
);
820 for (i
=(INT
)last_adjusted
; i
<=(INT
)rowend
; i
++) {
821 lpBand
= &infoPtr
->bands
[i
];
822 if (HIDDENBAND(lpBand
)) continue;
824 /* set right/bottom point */
825 if (i
!= last_adjusted
) {
826 if (infoPtr
->dwStyle
& CCS_VERT
)
827 lpBand
->rcBand
.top
+= fudge
;
829 lpBand
->rcBand
.left
+= fudge
;
832 /* set left/bottom point */
833 if (infoPtr
->dwStyle
& CCS_VERT
)
834 lpBand
->rcBand
.bottom
+= fudge
;
836 lpBand
->rcBand
.right
+= fudge
;
839 TRACE("Phase 1 succeeded, used x=%d\n", x
);
840 REBAR_FixVert (infoPtr
, rowstart
, rowend
, mcy
);
844 /* ******************* Phase 2 ************************ */
846 /* Find first visible band, put all */
847 /* extra space there. */
849 /* ****************************************************** */
852 for (i
=(INT
)rowstart
; i
<=(INT
)rowend
; i
++) {
853 lpBand
= &infoPtr
->bands
[i
];
854 if (HIDDENBAND(lpBand
)) continue;
855 xsep
= (x
== 0) ? 0 : SEP_WIDTH
;
856 curwidth
= rcBw(lpBand
);
858 /* set new left/top point */
859 if (infoPtr
->dwStyle
& CCS_VERT
)
860 lpBand
->rcBand
.top
= x
+ xsep
;
862 lpBand
->rcBand
.left
= x
+ xsep
;
864 /* compute new width */
870 /* set new right/bottom point */
871 if (infoPtr
->dwStyle
& CCS_VERT
)
872 lpBand
->rcBand
.bottom
= lpBand
->rcBand
.top
+ curwidth
;
874 lpBand
->rcBand
.right
= lpBand
->rcBand
.left
+ curwidth
;
875 TRACE("Phase 2 band %d, (%ld,%ld)-(%ld,%ld), orig x=%d, xsep=%d\n",
876 i
, lpBand
->rcBand
.left
, lpBand
->rcBand
.top
,
877 lpBand
->rcBand
.right
, lpBand
->rcBand
.bottom
, x
, xsep
);
882 ERR("Phase 2 failed, x=%d, maxx=%d, start=%u, end=%u\n",
883 x
, maxx
, rowstart
, rowend
);
885 /* done, so spread extra space */
886 TRACE("Phase 2 succeeded, used x=%d\n", x
);
887 REBAR_FixVert (infoPtr
, rowstart
, rowend
, mcy
);
891 /* ******************* Phase 3 ************************ */
892 /* at this point everything is back to ->cxHeader values */
893 /* and should not have gotten here. */
894 /* ****************************************************** */
896 lpBand
= &infoPtr
->bands
[rowstart
];
897 ERR("Serious problem adjusting row %d, start band %d, end band %d\n",
898 lpBand
->iRow
, rowstart
, rowend
);
899 REBAR_DumpBand (infoPtr
);
905 REBAR_CalcHorzBand (REBAR_INFO
*infoPtr
, UINT rstart
, UINT rend
, BOOL notify
)
906 /* Function: this routine initializes all the rectangles in */
907 /* each band in a row to fit in the adjusted rcBand rect. */
908 /* *** Supports only Horizontal bars. *** */
915 /* MS seems to use GetDlgCtrlID() for above GetWindowLong call */
916 parenthwnd
= GetParent (infoPtr
->hwndSelf
);
918 for(i
=rstart
; i
<rend
; i
++){
919 lpBand
= &infoPtr
->bands
[i
];
920 if (HIDDENBAND(lpBand
)) {
921 SetRect (&lpBand
->rcChild
,
922 lpBand
->rcBand
.right
, lpBand
->rcBand
.top
,
923 lpBand
->rcBand
.right
, lpBand
->rcBand
.bottom
);
927 oldChild
= lpBand
->rcChild
;
929 /* set initial gripper rectangle */
930 SetRect (&lpBand
->rcGripper
, lpBand
->rcBand
.left
, lpBand
->rcBand
.top
,
931 lpBand
->rcBand
.left
, lpBand
->rcBand
.bottom
);
933 /* calculate gripper rectangle */
934 if ( lpBand
->fStatus
& HAS_GRIPPER
) {
935 lpBand
->fDraw
|= DRAW_GRIPPER
;
936 lpBand
->rcGripper
.left
+= REBAR_PRE_GRIPPER
;
937 lpBand
->rcGripper
.right
= lpBand
->rcGripper
.left
+ GRIPPER_WIDTH
;
938 lpBand
->rcGripper
.top
+= 2;
939 lpBand
->rcGripper
.bottom
-= 2;
941 SetRect (&lpBand
->rcCapImage
,
942 lpBand
->rcGripper
.right
+REBAR_ALWAYS_SPACE
, lpBand
->rcBand
.top
,
943 lpBand
->rcGripper
.right
+REBAR_ALWAYS_SPACE
, lpBand
->rcBand
.bottom
);
945 else { /* no gripper will be drawn */
947 if (lpBand
->fStatus
& (HAS_IMAGE
| HAS_TEXT
))
948 /* if no gripper but either image or text, then leave space */
949 xoff
= REBAR_ALWAYS_SPACE
;
950 SetRect (&lpBand
->rcCapImage
,
951 lpBand
->rcBand
.left
+xoff
, lpBand
->rcBand
.top
,
952 lpBand
->rcBand
.left
+xoff
, lpBand
->rcBand
.bottom
);
955 /* image is visible */
956 if (lpBand
->fStatus
& HAS_IMAGE
) {
957 lpBand
->fDraw
|= DRAW_IMAGE
;
958 lpBand
->rcCapImage
.right
+= infoPtr
->imageSize
.cx
;
959 lpBand
->rcCapImage
.bottom
= lpBand
->rcCapImage
.top
+ infoPtr
->imageSize
.cy
;
961 /* set initial caption text rectangle */
962 SetRect (&lpBand
->rcCapText
,
963 lpBand
->rcCapImage
.right
+REBAR_POST_IMAGE
, lpBand
->rcBand
.top
+1,
964 lpBand
->rcBand
.left
+lpBand
->cxHeader
, lpBand
->rcBand
.bottom
-1);
965 /* update band height
966 if (lpBand->uMinHeight < infoPtr->imageSize.cy + 2) {
967 lpBand->uMinHeight = infoPtr->imageSize.cy + 2;
968 lpBand->rcBand.bottom = lpBand->rcBand.top + lpBand->uMinHeight;
972 /* set initial caption text rectangle */
973 SetRect (&lpBand
->rcCapText
, lpBand
->rcCapImage
.right
, lpBand
->rcBand
.top
+1,
974 lpBand
->rcBand
.left
+lpBand
->cxHeader
, lpBand
->rcBand
.bottom
-1);
977 /* text is visible */
978 if ((lpBand
->fStatus
& HAS_TEXT
) && !(lpBand
->fStyle
& RBBS_HIDETITLE
)) {
979 lpBand
->fDraw
|= DRAW_TEXT
;
980 lpBand
->rcCapText
.right
= max(lpBand
->rcCapText
.left
,
981 lpBand
->rcCapText
.right
-REBAR_POST_TEXT
);
984 /* set initial child window rectangle if there is a child */
985 if (lpBand
->fMask
& RBBIM_CHILD
) {
986 xoff
= lpBand
->offChild
.cx
;
987 yoff
= lpBand
->offChild
.cy
;
988 SetRect (&lpBand
->rcChild
,
989 lpBand
->rcBand
.left
+lpBand
->cxHeader
, lpBand
->rcBand
.top
+yoff
,
990 lpBand
->rcBand
.right
-xoff
, lpBand
->rcBand
.bottom
-yoff
);
991 if ((lpBand
->fStyle
& RBBS_USECHEVRON
) && (lpBand
->rcChild
.right
- lpBand
->rcChild
.left
< lpBand
->cxIdeal
))
993 lpBand
->rcChild
.right
-= CHEVRON_WIDTH
;
994 SetRect(&lpBand
->rcChevron
, lpBand
->rcChild
.right
,
995 lpBand
->rcChild
.top
, lpBand
->rcChild
.right
+ CHEVRON_WIDTH
,
996 lpBand
->rcChild
.bottom
);
1000 SetRect (&lpBand
->rcChild
,
1001 lpBand
->rcBand
.left
+lpBand
->cxHeader
, lpBand
->rcBand
.top
,
1002 lpBand
->rcBand
.right
, lpBand
->rcBand
.bottom
);
1005 /* flag if notify required and invalidate rectangle */
1007 ((oldChild
.right
-oldChild
.left
!= lpBand
->rcChild
.right
-lpBand
->rcChild
.left
) ||
1008 (oldChild
.bottom
-oldChild
.top
!= lpBand
->rcChild
.bottom
-lpBand
->rcChild
.top
))) {
1009 TRACE("Child rectangle changed for band %u\n", i
);
1010 TRACE(" from (%ld,%ld)-(%ld,%ld) to (%ld,%ld)-(%ld,%ld)\n",
1011 oldChild
.left
, oldChild
.top
,
1012 oldChild
.right
, oldChild
.bottom
,
1013 lpBand
->rcChild
.left
, lpBand
->rcChild
.top
,
1014 lpBand
->rcChild
.right
, lpBand
->rcChild
.bottom
);
1016 if (lpBand
->fDraw
& NTF_INVALIDATE
) {
1017 TRACE("invalidating (%ld,%ld)-(%ld,%ld)\n",
1018 lpBand
->rcBand
.left
,
1020 lpBand
->rcBand
.right
+ ((lpBand
->fDraw
& DRAW_RIGHTSEP
) ? SEP_WIDTH_SIZE
: 0),
1021 lpBand
->rcBand
.bottom
+ ((lpBand
->fDraw
& DRAW_BOTTOMSEP
) ? SEP_WIDTH_SIZE
: 0));
1022 lpBand
->fDraw
&= ~NTF_INVALIDATE
;
1023 work
= lpBand
->rcBand
;
1024 if (lpBand
->fDraw
& DRAW_RIGHTSEP
) work
.right
+= SEP_WIDTH_SIZE
;
1025 if (lpBand
->fDraw
& DRAW_BOTTOMSEP
) work
.bottom
+= SEP_WIDTH_SIZE
;
1026 InvalidateRect(infoPtr
->hwndSelf
, &work
, TRUE
);
1035 REBAR_CalcVertBand (REBAR_INFO
*infoPtr
, UINT rstart
, UINT rend
, BOOL notify
)
1036 /* Function: this routine initializes all the rectangles in */
1037 /* each band in a row to fit in the adjusted rcBand rect. */
1038 /* *** Supports only Vertical bars. *** */
1043 RECT oldChild
, work
;
1045 /* MS seems to use GetDlgCtrlID() for above GetWindowLong call */
1046 parenthwnd
= GetParent (infoPtr
->hwndSelf
);
1048 for(i
=rstart
; i
<rend
; i
++){
1049 lpBand
= &infoPtr
->bands
[i
];
1050 if (HIDDENBAND(lpBand
)) continue;
1051 oldChild
= lpBand
->rcChild
;
1053 /* set initial gripper rectangle */
1054 SetRect (&lpBand
->rcGripper
, lpBand
->rcBand
.left
, lpBand
->rcBand
.top
,
1055 lpBand
->rcBand
.right
, lpBand
->rcBand
.top
);
1057 /* calculate gripper rectangle */
1058 if (lpBand
->fStatus
& HAS_GRIPPER
) {
1059 lpBand
->fDraw
|= DRAW_GRIPPER
;
1061 if (infoPtr
->dwStyle
& RBS_VERTICALGRIPPER
) {
1062 /* vertical gripper */
1063 lpBand
->rcGripper
.left
+= 3;
1064 lpBand
->rcGripper
.right
= lpBand
->rcGripper
.left
+ GRIPPER_WIDTH
;
1065 lpBand
->rcGripper
.top
+= REBAR_PRE_GRIPPER
;
1066 lpBand
->rcGripper
.bottom
= lpBand
->rcGripper
.top
+ GRIPPER_HEIGHT
;
1068 /* initialize Caption image rectangle */
1069 SetRect (&lpBand
->rcCapImage
, lpBand
->rcBand
.left
,
1070 lpBand
->rcGripper
.bottom
+ REBAR_ALWAYS_SPACE
,
1071 lpBand
->rcBand
.right
,
1072 lpBand
->rcGripper
.bottom
+ REBAR_ALWAYS_SPACE
);
1075 /* horizontal gripper */
1076 lpBand
->rcGripper
.left
+= 2;
1077 lpBand
->rcGripper
.right
-= 2;
1078 lpBand
->rcGripper
.top
+= REBAR_PRE_GRIPPER
;
1079 lpBand
->rcGripper
.bottom
= lpBand
->rcGripper
.top
+ GRIPPER_WIDTH
;
1081 /* initialize Caption image rectangle */
1082 SetRect (&lpBand
->rcCapImage
, lpBand
->rcBand
.left
,
1083 lpBand
->rcGripper
.bottom
+ REBAR_ALWAYS_SPACE
,
1084 lpBand
->rcBand
.right
,
1085 lpBand
->rcGripper
.bottom
+ REBAR_ALWAYS_SPACE
);
1088 else { /* no gripper will be drawn */
1090 if (lpBand
->fStatus
& (HAS_IMAGE
| HAS_TEXT
))
1091 /* if no gripper but either image or text, then leave space */
1092 xoff
= REBAR_ALWAYS_SPACE
;
1093 /* initialize Caption image rectangle */
1094 SetRect (&lpBand
->rcCapImage
,
1095 lpBand
->rcBand
.left
, lpBand
->rcBand
.top
+xoff
,
1096 lpBand
->rcBand
.right
, lpBand
->rcBand
.top
+xoff
);
1099 /* image is visible */
1100 if (lpBand
->fStatus
& HAS_IMAGE
) {
1101 lpBand
->fDraw
|= DRAW_IMAGE
;
1103 lpBand
->rcCapImage
.right
= lpBand
->rcCapImage
.left
+ infoPtr
->imageSize
.cx
;
1104 lpBand
->rcCapImage
.bottom
+= infoPtr
->imageSize
.cy
;
1106 /* set initial caption text rectangle */
1107 SetRect (&lpBand
->rcCapText
,
1108 lpBand
->rcBand
.left
, lpBand
->rcCapImage
.bottom
+REBAR_POST_IMAGE
,
1109 lpBand
->rcBand
.right
, lpBand
->rcBand
.top
+lpBand
->cxHeader
);
1110 /* update band height *
1111 if (lpBand->uMinHeight < infoPtr->imageSize.cx + 2) {
1112 lpBand->uMinHeight = infoPtr->imageSize.cx + 2;
1113 lpBand->rcBand.right = lpBand->rcBand.left + lpBand->uMinHeight;
1117 /* set initial caption text rectangle */
1118 SetRect (&lpBand
->rcCapText
,
1119 lpBand
->rcBand
.left
, lpBand
->rcCapImage
.bottom
,
1120 lpBand
->rcBand
.right
, lpBand
->rcBand
.top
+lpBand
->cxHeader
);
1123 /* text is visible */
1124 if ((lpBand
->fStatus
& HAS_TEXT
) && !(lpBand
->fStyle
& RBBS_HIDETITLE
)) {
1125 lpBand
->fDraw
|= DRAW_TEXT
;
1126 lpBand
->rcCapText
.bottom
= max(lpBand
->rcCapText
.top
,
1127 lpBand
->rcCapText
.bottom
);
1130 /* set initial child window rectangle if there is a child */
1131 if (lpBand
->fMask
& RBBIM_CHILD
) {
1132 yoff
= lpBand
->offChild
.cx
;
1133 xoff
= lpBand
->offChild
.cy
;
1134 SetRect (&lpBand
->rcChild
,
1135 lpBand
->rcBand
.left
+xoff
, lpBand
->rcBand
.top
+lpBand
->cxHeader
,
1136 lpBand
->rcBand
.right
-xoff
, lpBand
->rcBand
.bottom
-yoff
);
1139 SetRect (&lpBand
->rcChild
,
1140 lpBand
->rcBand
.left
, lpBand
->rcBand
.top
+lpBand
->cxHeader
,
1141 lpBand
->rcBand
.right
, lpBand
->rcBand
.bottom
);
1144 /* flag if notify required and invalidate rectangle */
1146 ((oldChild
.right
-oldChild
.left
!= lpBand
->rcChild
.right
-lpBand
->rcChild
.left
) ||
1147 (oldChild
.bottom
-oldChild
.top
!= lpBand
->rcChild
.bottom
-lpBand
->rcChild
.top
))) {
1148 TRACE("Child rectangle changed for band %u\n", i
);
1149 TRACE(" from (%ld,%ld)-(%ld,%ld) to (%ld,%ld)-(%ld,%ld)\n",
1150 oldChild
.left
, oldChild
.top
,
1151 oldChild
.right
, oldChild
.bottom
,
1152 lpBand
->rcChild
.left
, lpBand
->rcChild
.top
,
1153 lpBand
->rcChild
.right
, lpBand
->rcChild
.bottom
);
1155 if (lpBand
->fDraw
& NTF_INVALIDATE
) {
1156 TRACE("invalidating (%ld,%ld)-(%ld,%ld)\n",
1157 lpBand
->rcBand
.left
,
1159 lpBand
->rcBand
.right
+ ((lpBand
->fDraw
& DRAW_BOTTOMSEP
) ? SEP_WIDTH_SIZE
: 0),
1160 lpBand
->rcBand
.bottom
+ ((lpBand
->fDraw
& DRAW_RIGHTSEP
) ? SEP_WIDTH_SIZE
: 0));
1161 lpBand
->fDraw
&= ~NTF_INVALIDATE
;
1162 work
= lpBand
->rcBand
;
1163 if (lpBand
->fDraw
& DRAW_RIGHTSEP
) work
.bottom
+= SEP_WIDTH_SIZE
;
1164 if (lpBand
->fDraw
& DRAW_BOTTOMSEP
) work
.right
+= SEP_WIDTH_SIZE
;
1165 InvalidateRect(infoPtr
->hwndSelf
, &work
, TRUE
);
1173 REBAR_ForceResize (REBAR_INFO
*infoPtr
)
1174 /* Function: This changes the size of the REBAR window to that */
1175 /* calculated by REBAR_Layout. */
1178 INT x
, y
, width
, height
;
1179 INT xedge
= GetSystemMetrics(SM_CXEDGE
);
1180 INT yedge
= GetSystemMetrics(SM_CYEDGE
);
1182 GetClientRect (infoPtr
->hwndSelf
, &rc
);
1184 TRACE( " old [%ld x %ld], new [%ld x %ld], client [%ld x %ld]\n",
1185 infoPtr
->oldSize
.cx
, infoPtr
->oldSize
.cy
,
1186 infoPtr
->calcSize
.cx
, infoPtr
->calcSize
.cy
,
1187 rc
.right
, rc
.bottom
);
1189 /* If we need to shrink client, then skip size test */
1190 if ((infoPtr
->calcSize
.cy
>= rc
.bottom
) &&
1191 (infoPtr
->calcSize
.cx
>= rc
.right
)) {
1193 /* if size did not change then skip process */
1194 if ((infoPtr
->oldSize
.cx
== infoPtr
->calcSize
.cx
) &&
1195 (infoPtr
->oldSize
.cy
== infoPtr
->calcSize
.cy
) &&
1196 !(infoPtr
->fStatus
& RESIZE_ANYHOW
))
1198 TRACE("skipping reset\n");
1203 infoPtr
->fStatus
&= ~RESIZE_ANYHOW
;
1204 /* Set flag to ignore next WM_SIZE message */
1205 infoPtr
->fStatus
|= AUTO_RESIZE
;
1212 if (infoPtr
->dwStyle
& WS_BORDER
) {
1217 if (!(infoPtr
->dwStyle
& CCS_NOPARENTALIGN
)) {
1218 INT mode
= infoPtr
->dwStyle
& (CCS_VERT
| CCS_TOP
| CCS_BOTTOM
);
1221 GetClientRect(GetParent(infoPtr
->hwndSelf
), &rcPcl
);
1224 /* _TOP sets width to parents width */
1225 width
+= (rcPcl
.right
- rcPcl
.left
);
1226 height
+= infoPtr
->calcSize
.cy
;
1227 x
+= ((infoPtr
->dwStyle
& WS_BORDER
) ? -xedge
: 0);
1228 y
+= ((infoPtr
->dwStyle
& WS_BORDER
) ? -yedge
: 0);
1229 y
+= ((infoPtr
->dwStyle
& CCS_NODIVIDER
) ? 0 : REBAR_DIVIDER
);
1232 /* FIXME: wrong wrong wrong */
1233 /* _BOTTOM sets width to parents width */
1234 width
+= (rcPcl
.right
- rcPcl
.left
);
1235 height
+= infoPtr
->calcSize
.cy
;
1237 y
= rcPcl
.bottom
- height
+ 1;
1240 /* _LEFT sets height to parents height */
1241 width
+= infoPtr
->calcSize
.cx
;
1242 height
+= (rcPcl
.bottom
- rcPcl
.top
);
1243 x
+= ((infoPtr
->dwStyle
& WS_BORDER
) ? -xedge
: 0);
1244 x
+= ((infoPtr
->dwStyle
& CCS_NODIVIDER
) ? 0 : REBAR_DIVIDER
);
1245 y
+= ((infoPtr
->dwStyle
& WS_BORDER
) ? -yedge
: 0);
1248 /* FIXME: wrong wrong wrong */
1249 /* _RIGHT sets height to parents height */
1250 width
+= infoPtr
->calcSize
.cx
;
1251 height
+= (rcPcl
.bottom
- rcPcl
.top
);
1252 x
= rcPcl
.right
- width
+ 1;
1256 width
+= infoPtr
->calcSize
.cx
;
1257 height
+= infoPtr
->calcSize
.cy
;
1261 width
+= infoPtr
->calcSize
.cx
;
1262 height
+= infoPtr
->calcSize
.cy
;
1263 x
= infoPtr
->origin
.x
;
1264 y
= infoPtr
->origin
.y
;
1267 TRACE("hwnd %p, style=%08lx, setting at (%d,%d) for (%d,%d)\n",
1268 infoPtr
->hwndSelf
, infoPtr
->dwStyle
,
1269 x
, y
, width
, height
);
1270 SetWindowPos (infoPtr
->hwndSelf
, 0, x
, y
, width
, height
,
1272 infoPtr
->fStatus
&= ~AUTO_RESIZE
;
1277 REBAR_MoveChildWindows (REBAR_INFO
*infoPtr
, UINT start
, UINT endplus
)
1279 static const WCHAR strComboBox
[] = { 'C','o','m','b','o','B','o','x',0 };
1281 WCHAR szClassName
[40];
1283 NMREBARCHILDSIZE rbcz
;
1287 if (!(deferpos
= BeginDeferWindowPos(infoPtr
->uNumBands
)))
1288 ERR("BeginDeferWindowPos returned NULL\n");
1290 for (i
= start
; i
< endplus
; i
++) {
1291 lpBand
= &infoPtr
->bands
[i
];
1293 if (HIDDENBAND(lpBand
)) continue;
1294 if (lpBand
->hwndChild
) {
1295 TRACE("hwndChild = %p\n", lpBand
->hwndChild
);
1297 /* Always geterate the RBN_CHILDSIZE even it child
1300 rbcz
.wID
= lpBand
->wID
;
1301 rbcz
.rcChild
= lpBand
->rcChild
;
1302 rbcz
.rcBand
= lpBand
->rcBand
;
1303 if (infoPtr
->dwStyle
& CCS_VERT
)
1304 rbcz
.rcBand
.top
+= lpBand
->cxHeader
;
1306 rbcz
.rcBand
.left
+= lpBand
->cxHeader
;
1307 REBAR_Notify ((NMHDR
*)&rbcz
, infoPtr
, RBN_CHILDSIZE
);
1308 if (!EqualRect (&lpBand
->rcChild
, &rbcz
.rcChild
)) {
1309 TRACE("Child rect changed by NOTIFY for band %u\n", i
);
1310 TRACE(" from (%ld,%ld)-(%ld,%ld) to (%ld,%ld)-(%ld,%ld)\n",
1311 lpBand
->rcChild
.left
, lpBand
->rcChild
.top
,
1312 lpBand
->rcChild
.right
, lpBand
->rcChild
.bottom
,
1313 rbcz
.rcChild
.left
, rbcz
.rcChild
.top
,
1314 rbcz
.rcChild
.right
, rbcz
.rcChild
.bottom
);
1315 lpBand
->rcChild
= rbcz
.rcChild
; /* *** ??? */
1318 /* native (IE4 in "Favorites" frame **1) does:
1319 * SetRect (&rc, -1, -1, -1, -1)
1320 * EqualRect (&rc,band->rc???)
1322 * CopyRect (band->rc????, &rc)
1323 * set flag outside of loop
1326 GetClassNameW (lpBand
->hwndChild
, szClassName
, sizeof(szClassName
)/sizeof(szClassName
[0]));
1327 if (!lstrcmpW (szClassName
, strComboBox
) ||
1328 !lstrcmpW (szClassName
, WC_COMBOBOXEXW
)) {
1329 INT nEditHeight
, yPos
;
1332 /* special placement code for combo or comboex box */
1335 /* get size of edit line */
1336 GetWindowRect (lpBand
->hwndChild
, &rc
);
1337 nEditHeight
= rc
.bottom
- rc
.top
;
1338 yPos
= (lpBand
->rcChild
.bottom
+ lpBand
->rcChild
.top
- nEditHeight
)/2;
1340 /* center combo box inside child area */
1341 TRACE("moving child (Combo(Ex)) %p to (%ld,%d) for (%ld,%d)\n",
1343 lpBand
->rcChild
.left
, yPos
,
1344 lpBand
->rcChild
.right
- lpBand
->rcChild
.left
,
1346 deferpos
= DeferWindowPos (deferpos
, lpBand
->hwndChild
, HWND_TOP
,
1347 lpBand
->rcChild
.left
,
1348 /*lpBand->rcChild.top*/ yPos
,
1349 lpBand
->rcChild
.right
- lpBand
->rcChild
.left
,
1353 ERR("DeferWindowPos returned NULL\n");
1356 TRACE("moving child (Other) %p to (%ld,%ld) for (%ld,%ld)\n",
1358 lpBand
->rcChild
.left
, lpBand
->rcChild
.top
,
1359 lpBand
->rcChild
.right
- lpBand
->rcChild
.left
,
1360 lpBand
->rcChild
.bottom
- lpBand
->rcChild
.top
);
1361 deferpos
= DeferWindowPos (deferpos
, lpBand
->hwndChild
, HWND_TOP
,
1362 lpBand
->rcChild
.left
,
1363 lpBand
->rcChild
.top
,
1364 lpBand
->rcChild
.right
- lpBand
->rcChild
.left
,
1365 lpBand
->rcChild
.bottom
- lpBand
->rcChild
.top
,
1368 ERR("DeferWindowPos returned NULL\n");
1372 if (!EndDeferWindowPos(deferpos
))
1373 ERR("EndDeferWindowPos returned NULL\n");
1375 if (infoPtr
->DoRedraw
)
1376 UpdateWindow (infoPtr
->hwndSelf
);
1378 if (infoPtr
->fStatus
& NTF_HGHTCHG
) {
1379 infoPtr
->fStatus
&= ~NTF_HGHTCHG
;
1381 * We need to force a resize here, because some applications
1382 * try to get the rebar size during processing of the
1383 * RBN_HEIGHTCHANGE notification.
1385 REBAR_ForceResize (infoPtr
);
1386 REBAR_Notify (&heightchange
, infoPtr
, RBN_HEIGHTCHANGE
);
1389 /* native (from **1 above) does:
1390 * UpdateWindow(rebar)
1392 * RBN_HEIGHTCHANGE if necessary
1393 * if ret from any EqualRect was 0
1394 * Goto "BeginDeferWindowPos"
1401 REBAR_Layout (REBAR_INFO
*infoPtr
, LPRECT lpRect
, BOOL notify
, BOOL resetclient
)
1402 /* Function: This routine is resposible for laying out all */
1403 /* the bands in a rebar. It assigns each band to a row and*/
1404 /* determines when to start a new row. */
1406 REBAR_BAND
*lpBand
, *prevBand
;
1407 RECT rcClient
, rcAdj
;
1408 INT initx
, inity
, x
, y
, cx
, cxsep
, mmcy
, mcy
, clientcx
, clientcy
;
1409 INT adjcx
, adjcy
, row
, rightx
, bottomy
, origheight
;
1410 UINT i
, j
, rowstart
, origrows
, cntonrow
;
1413 if (!(infoPtr
->fStatus
& BAND_NEEDS_LAYOUT
)) {
1414 TRACE("no layout done. No band changed.\n");
1415 REBAR_DumpBand (infoPtr
);
1418 infoPtr
->fStatus
&= ~BAND_NEEDS_LAYOUT
;
1419 if (!infoPtr
->DoRedraw
) infoPtr
->fStatus
|= BAND_NEEDS_REDRAW
;
1421 GetClientRect (infoPtr
->hwndSelf
, &rcClient
);
1422 TRACE("Client is (%ld,%ld)-(%ld,%ld)\n",
1423 rcClient
.left
, rcClient
.top
, rcClient
.right
, rcClient
.bottom
);
1427 TRACE("adjustment rect is (%ld,%ld)-(%ld,%ld)\n",
1428 rcAdj
.left
, rcAdj
.top
, rcAdj
.right
, rcAdj
.bottom
);
1431 CopyRect (&rcAdj
, &rcClient
);
1434 clientcx
= rcClient
.right
- rcClient
.left
;
1435 clientcy
= rcClient
.bottom
- rcClient
.top
;
1436 adjcx
= rcAdj
.right
- rcAdj
.left
;
1437 adjcy
= rcAdj
.bottom
- rcAdj
.top
;
1439 TRACE("window client rect will be set to adj rect\n");
1444 if (!infoPtr
->DoRedraw
&& (clientcx
== 0) && (clientcy
== 0)) {
1445 ERR("no redraw and client is zero, skip layout\n");
1446 infoPtr
->fStatus
|= BAND_NEEDS_LAYOUT
;
1450 /* save height of original control */
1451 if (infoPtr
->dwStyle
& CCS_VERT
)
1452 origheight
= infoPtr
->calcSize
.cx
;
1454 origheight
= infoPtr
->calcSize
.cy
;
1455 origrows
= infoPtr
->uNumRows
;
1460 /* ******* Start Phase 1 - all bands on row at minimum size ******* */
1462 TRACE("band loop constants, clientcx=%d, clientcy=%d, adjcx=%d, adjcy=%d\n",
1463 clientcx
, clientcy
, adjcx
, adjcy
);
1473 for (i
= 0; i
< infoPtr
->uNumBands
; i
++) {
1474 lpBand
= &infoPtr
->bands
[i
];
1478 SetRectEmpty(&lpBand
->rcChevron
);
1480 if (HIDDENBAND(lpBand
)) continue;
1482 lpBand
->rcoldBand
= lpBand
->rcBand
;
1484 /* Set the offset of the child window */
1485 if ((lpBand
->fMask
& RBBIM_CHILD
) &&
1486 !(lpBand
->fStyle
& RBBS_FIXEDSIZE
)) {
1487 lpBand
->offChild
.cx
= ((lpBand
->fStyle
& RBBS_CHILDEDGE
) ? 4 : 0);
1489 lpBand
->offChild
.cy
= ((lpBand
->fStyle
& RBBS_CHILDEDGE
) ? 2 : 0);
1491 /* separator from previous band */
1492 cxsep
= (cntonrow
== 0) ? 0 : SEP_WIDTH
;
1495 if (infoPtr
->dwStyle
& CCS_VERT
)
1496 dobreak
= (y
+ cx
+ cxsep
> adjcy
);
1498 dobreak
= (x
+ cx
+ cxsep
> adjcx
);
1500 /* This is the check for whether we need to start a new row */
1501 if ( ( (lpBand
->fStyle
& RBBS_BREAK
) && (i
!= 0) ) ||
1502 ( ((infoPtr
->dwStyle
& CCS_VERT
) ? (y
!= 0) : (x
!= 0)) && dobreak
)) {
1504 for (j
= rowstart
; j
< i
; j
++) {
1506 lpB
= &infoPtr
->bands
[j
];
1507 if (infoPtr
->dwStyle
& CCS_VERT
) {
1508 lpB
->rcBand
.right
= lpB
->rcBand
.left
+ mcy
;
1511 lpB
->rcBand
.bottom
= lpB
->rcBand
.top
+ mcy
;
1515 TRACE("P1 Spliting to new row %d on band %u\n", row
+1, i
);
1516 if (infoPtr
->dwStyle
& CCS_VERT
) {
1518 x
+= (mcy
+ SEP_WIDTH
);
1522 y
+= (mcy
+ SEP_WIDTH
);
1534 if (mcy
< lpBand
->lcy
+ REBARSPACE(lpBand
))
1535 mcy
= lpBand
->lcy
+ REBARSPACE(lpBand
);
1537 /* if boundary rect specified then limit mcy */
1539 if (infoPtr
->dwStyle
& CCS_VERT
) {
1540 if (x
+mcy
> adjcx
) {
1542 TRACE("P1 row %u limiting mcy=%d, adjcx=%d, x=%d\n",
1547 if (y
+mcy
> adjcy
) {
1549 TRACE("P1 row %u limiting mcy=%d, adjcy=%d, y=%d\n",
1555 TRACE("P1 band %u, row %d, x=%d, y=%d, cxsep=%d, cx=%d\n",
1558 if (infoPtr
->dwStyle
& CCS_VERT
) {
1559 /* bound the bottom side if we have a bounding rectangle */
1561 bottomy
= (lpRect
) ? min(clientcy
, y
+cxsep
+cx
) : y
+cxsep
+cx
;
1562 lpBand
->rcBand
.left
= x
;
1563 lpBand
->rcBand
.right
= x
+ min(mcy
,
1564 lpBand
->lcy
+REBARSPACE(lpBand
));
1565 lpBand
->rcBand
.top
= min(bottomy
, y
+ cxsep
);
1566 lpBand
->rcBand
.bottom
= bottomy
;
1567 lpBand
->uMinHeight
= lpBand
->lcy
;
1571 /* bound the right side if we have a bounding rectangle */
1572 rightx
= (lpRect
) ? min(clientcx
, x
+cxsep
+cx
) : x
+cxsep
+cx
;
1574 lpBand
->rcBand
.left
= min(rightx
, x
+ cxsep
);
1575 lpBand
->rcBand
.right
= rightx
;
1576 lpBand
->rcBand
.top
= y
;
1577 lpBand
->rcBand
.bottom
= y
+ min(mcy
,
1578 lpBand
->lcy
+REBARSPACE(lpBand
));
1579 lpBand
->uMinHeight
= lpBand
->lcy
;
1582 TRACE("P1 band %u, row %d, (%ld,%ld)-(%ld,%ld)\n",
1584 lpBand
->rcBand
.left
, lpBand
->rcBand
.top
,
1585 lpBand
->rcBand
.right
, lpBand
->rcBand
.bottom
);
1589 } /* for (i = 0; i < infoPtr->uNumBands... */
1591 if (infoPtr
->dwStyle
& CCS_VERT
)
1596 for (j
= rowstart
; j
< infoPtr
->uNumBands
; j
++) {
1597 lpBand
= &infoPtr
->bands
[j
];
1598 if (infoPtr
->dwStyle
& CCS_VERT
) {
1599 lpBand
->rcBand
.right
= lpBand
->rcBand
.left
+ mcy
;
1602 lpBand
->rcBand
.bottom
= lpBand
->rcBand
.top
+ mcy
;
1606 if (infoPtr
->uNumBands
)
1607 infoPtr
->uNumRows
= row
+ 1;
1609 /* ******* End Phase 1 - all bands on row at minimum size ******* */
1612 /* ******* Start Phase 1a - Adjust heights for RBS_VARHEIGHT off ******* */
1615 if (!(infoPtr
->dwStyle
& RBS_VARHEIGHT
)) {
1618 /* get the max height of all bands */
1619 for (i
=0; i
<infoPtr
->uNumBands
; i
++) {
1620 lpBand
= &infoPtr
->bands
[i
];
1621 if (HIDDENBAND(lpBand
)) continue;
1622 if (infoPtr
->dwStyle
& CCS_VERT
)
1623 mmcy
= max(mmcy
, lpBand
->rcBand
.right
- lpBand
->rcBand
.left
);
1625 mmcy
= max(mmcy
, lpBand
->rcBand
.bottom
- lpBand
->rcBand
.top
);
1628 /* now adjust all rectangles by using the height found above */
1631 for (i
=0; i
<infoPtr
->uNumBands
; i
++) {
1632 lpBand
= &infoPtr
->bands
[i
];
1633 if (HIDDENBAND(lpBand
)) continue;
1634 if (lpBand
->iRow
!= row
)
1635 xy
+= (mmcy
+ SEP_WIDTH
);
1636 if (infoPtr
->dwStyle
& CCS_VERT
) {
1637 lpBand
->rcBand
.left
= xy
;
1638 lpBand
->rcBand
.right
= xy
+ mmcy
;
1641 lpBand
->rcBand
.top
= xy
;
1642 lpBand
->rcBand
.bottom
= xy
+ mmcy
;
1646 /* set the x/y values to the correct maximum */
1647 if (infoPtr
->dwStyle
& CCS_VERT
)
1653 /* ******* End Phase 1a - Adjust heights for RBS_VARHEIGHT off ******* */
1656 /* ******* Start Phase 2 - split rows till adjustment height full ******* */
1658 /* assumes that the following variables contain: */
1659 /* y/x current height/width of all rows */
1661 INT i
, prev_rh
, new_rh
, adj_rh
, prev_idx
, current_idx
;
1662 REBAR_BAND
*prev
, *current
, *walk
;
1665 /* FIXME: problem # 2 */
1666 if (((infoPtr
->dwStyle
& CCS_VERT
) ?
1668 (x
< adjcx
) : (y
< adjcy
)
1670 (adjcx
- x
> 5) : (adjcy
- y
> 4)
1673 (infoPtr
->uNumBands
> 1)) {
1674 for (i
=(INT
)infoPtr
->uNumBands
-2; i
>=0; i
--) {
1675 TRACE("P2 adjcx=%d, adjcy=%d, x=%d, y=%d\n",
1676 adjcx
, adjcy
, x
, y
);
1678 /* find the current band (starts at i+1) */
1679 current
= &infoPtr
->bands
[i
+1];
1681 while (HIDDENBAND(current
)) {
1683 if (i
< 0) break; /* out of bands */
1684 current
= &infoPtr
->bands
[i
+1];
1687 if (i
< 0) break; /* out of bands */
1689 /* now find the prev band (starts at i) */
1690 prev
= &infoPtr
->bands
[i
];
1692 while (HIDDENBAND(prev
)) {
1694 if (i
< 0) break; /* out of bands */
1695 prev
= &infoPtr
->bands
[i
];
1698 if (i
< 0) break; /* out of bands */
1700 prev_rh
= ircBw(prev
);
1701 if (prev
->iRow
== current
->iRow
) {
1702 new_rh
= (infoPtr
->dwStyle
& RBS_VARHEIGHT
) ?
1703 current
->lcy
+ REBARSPACE(current
) :
1705 adj_rh
= new_rh
+ SEP_WIDTH
;
1706 infoPtr
->uNumRows
++;
1707 current
->fDraw
|= NTF_INVALIDATE
;
1709 if (infoPtr
->dwStyle
& CCS_VERT
) {
1710 current
->rcBand
.top
= inity
;
1711 current
->rcBand
.bottom
= clientcy
;
1712 current
->rcBand
.left
+= (prev_rh
+ SEP_WIDTH
);
1713 current
->rcBand
.right
= current
->rcBand
.left
+ new_rh
;
1717 current
->rcBand
.left
= initx
;
1718 current
->rcBand
.right
= clientcx
;
1719 current
->rcBand
.top
+= (prev_rh
+ SEP_WIDTH
);
1720 current
->rcBand
.bottom
= current
->rcBand
.top
+ new_rh
;
1723 TRACE("P2 moving band %d to own row at (%ld,%ld)-(%ld,%ld)\n",
1725 current
->rcBand
.left
, current
->rcBand
.top
,
1726 current
->rcBand
.right
, current
->rcBand
.bottom
);
1727 TRACE("P2 prev band %d at (%ld,%ld)-(%ld,%ld)\n",
1729 prev
->rcBand
.left
, prev
->rcBand
.top
,
1730 prev
->rcBand
.right
, prev
->rcBand
.bottom
);
1731 TRACE("P2 values: prev_rh=%d, new_rh=%d, adj_rh=%d\n",
1732 prev_rh
, new_rh
, adj_rh
);
1733 /* for bands below current adjust row # and top/bottom */
1734 for (j
= current_idx
+1; j
<infoPtr
->uNumBands
; j
++) {
1735 walk
= &infoPtr
->bands
[j
];
1736 if (HIDDENBAND(walk
)) continue;
1737 walk
->fDraw
|= NTF_INVALIDATE
;
1739 if (infoPtr
->dwStyle
& CCS_VERT
) {
1740 walk
->rcBand
.left
+= adj_rh
;
1741 walk
->rcBand
.right
+= adj_rh
;
1744 walk
->rcBand
.top
+= adj_rh
;
1745 walk
->rcBand
.bottom
+= adj_rh
;
1748 if ((infoPtr
->dwStyle
& CCS_VERT
) ? (x
>= adjcx
) : (y
>= adjcy
))
1749 break; /* all done */
1755 /* ******* End Phase 2 - split rows till adjustment height full ******* */
1758 /* ******* Start Phase 2a - mark first and last band in each ******* */
1761 for (i
= 0; i
< infoPtr
->uNumBands
; i
++) {
1762 lpBand
= &infoPtr
->bands
[i
];
1763 if (HIDDENBAND(lpBand
))
1766 lpBand
->fDraw
|= DRAW_FIRST_IN_ROW
;
1769 else if( prevBand
->iRow
== lpBand
->iRow
)
1772 prevBand
->fDraw
|= DRAW_LAST_IN_ROW
;
1773 lpBand
->fDraw
|= DRAW_FIRST_IN_ROW
;
1778 prevBand
->fDraw
|= DRAW_LAST_IN_ROW
;
1780 /* ******* End Phase 2a - mark first and last band in each ******* */
1783 /* ******* Start Phase 2b - adjust all bands for height full ******* */
1784 /* assumes that the following variables contain: */
1785 /* y/x current height/width of all rows */
1786 /* clientcy/clientcx height/width of client area */
1788 if (((infoPtr
->dwStyle
& CCS_VERT
) ? clientcx
> x
: clientcy
> y
) &&
1789 infoPtr
->uNumBands
) {
1793 diff
= (infoPtr
->dwStyle
& CCS_VERT
) ? clientcx
- x
: clientcy
- y
;
1795 /* iterate backwards thru the rows */
1796 for (i
= infoPtr
->uNumBands
-1; i
>=0; i
--) {
1797 lpBand
= &infoPtr
->bands
[i
];
1798 if(HIDDENBAND(lpBand
)) continue;
1800 /* if row has more than 1 band, ignore it */
1801 if( !(lpBand
->fDraw
&DRAW_FIRST_IN_ROW
) )
1803 if( !(lpBand
->fDraw
&DRAW_LAST_IN_ROW
) )
1806 /* FIXME: this next line is wrong, but fixing it to be inverted causes IE's sidebars to be the wrong size */
1807 if (lpBand
->fMask
& RBBS_VARIABLEHEIGHT
) continue;
1808 if (((INT
)lpBand
->cyMaxChild
< 1) ||
1809 ((INT
)lpBand
->cyIntegral
< 1)) {
1810 if (lpBand
->cyMaxChild
+ lpBand
->cyIntegral
== 0) continue;
1811 ERR("P2b band %u RBBS_VARIABLEHEIGHT set but cyMax=%d, cyInt=%d\n",
1812 i
, lpBand
->cyMaxChild
, lpBand
->cyIntegral
);
1815 /* j is now the maximum height/width in the client area */
1816 j
= ((diff
/ lpBand
->cyIntegral
) * lpBand
->cyIntegral
) +
1818 if (j
> lpBand
->cyMaxChild
+ REBARSPACE(lpBand
))
1819 j
= lpBand
->cyMaxChild
+ REBARSPACE(lpBand
);
1820 diff
-= (j
- ircBw(lpBand
));
1821 if (infoPtr
->dwStyle
& CCS_VERT
)
1822 lpBand
->rcBand
.right
= lpBand
->rcBand
.left
+ j
;
1824 lpBand
->rcBand
.bottom
= lpBand
->rcBand
.top
+ j
;
1825 TRACE("P2b band %d, row %d changed to (%ld,%ld)-(%ld,%ld)\n",
1827 lpBand
->rcBand
.left
, lpBand
->rcBand
.top
,
1828 lpBand
->rcBand
.right
, lpBand
->rcBand
.bottom
);
1829 if (diff
<= 0) break;
1832 ERR("P2b allocated more than available, diff=%d\n", diff
);
1835 if (infoPtr
->dwStyle
& CCS_VERT
)
1836 x
= clientcx
- diff
;
1838 y
= clientcy
- diff
;
1841 /* ******* End Phase 2b - adjust all bands for height full ******* */
1844 /* ******* Start Phase 3 - adjust all bands for width full ******* */
1846 if (infoPtr
->uNumBands
) {
1849 /* If RBS_BANDBORDERS set then indicate to draw bottom separator */
1850 /* on all bands in all rows but last row. */
1851 /* Also indicate to draw the right separator for each band in */
1852 /* each row but the rightmost band. */
1853 if (infoPtr
->dwStyle
& RBS_BANDBORDERS
) {
1855 for (i
=0; i
<infoPtr
->uNumBands
; i
++) {
1856 lpBand
= &infoPtr
->bands
[i
];
1857 if (HIDDENBAND(lpBand
))
1860 /* not righthand bands */
1861 if( !(lpBand
->fDraw
& DRAW_LAST_IN_ROW
) )
1862 lpBand
->fDraw
|= DRAW_RIGHTSEP
;
1864 /* not the last row */
1865 if( lpBand
->iRow
!= infoPtr
->uNumRows
)
1866 lpBand
->fDraw
|= DRAW_BOTTOMSEP
;
1870 /* Distribute the extra space on the horizontal and adjust */
1871 /* all bands in row to same height. */
1874 for (i
=0; i
<infoPtr
->uNumBands
; i
++) {
1876 lpBand
= &infoPtr
->bands
[i
];
1878 if( lpBand
->fDraw
& DRAW_FIRST_IN_ROW
)
1884 if ( (mcy
< ircBw(lpBand
)) && !HIDDENBAND(lpBand
) )
1885 mcy
= ircBw(lpBand
);
1887 if( lpBand
->fDraw
& DRAW_LAST_IN_ROW
)
1889 TRACE("P3 processing row %d, starting band %d, ending band %d\n",
1890 lpBand
->iRow
, startband
, i
);
1892 ERR("Last band %d with no first, row %d\n", i
, lpBand
->iRow
);
1894 REBAR_AdjustBands (infoPtr
, startband
, i
,
1895 (infoPtr
->dwStyle
& CCS_VERT
) ?
1896 clientcy
: clientcx
, mcy
);
1900 /* Calculate the other rectangles in each band */
1901 if (infoPtr
->dwStyle
& CCS_VERT
) {
1902 REBAR_CalcVertBand (infoPtr
, 0, infoPtr
->uNumBands
,
1906 REBAR_CalcHorzBand (infoPtr
, 0, infoPtr
->uNumBands
,
1911 /* ******* End Phase 3 - adjust all bands for width full ******* */
1913 /* now compute size of Rebar itself */
1914 infoPtr
->oldSize
= infoPtr
->calcSize
;
1915 if (infoPtr
->uNumBands
== 0) {
1916 /* we have no bands, so make size the size of client */
1920 if (infoPtr
->dwStyle
& CCS_VERT
) {
1921 if( x
< REBAR_MINSIZE
)
1923 infoPtr
->calcSize
.cx
= x
;
1924 infoPtr
->calcSize
.cy
= clientcy
;
1925 TRACE("vert, notify=%d, x=%d, origheight=%d\n",
1926 notify
, x
, origheight
);
1927 if (notify
&& (x
!= origheight
)) infoPtr
->fStatus
|= NTF_HGHTCHG
;
1930 if( y
< REBAR_MINSIZE
)
1932 infoPtr
->calcSize
.cx
= clientcx
;
1933 infoPtr
->calcSize
.cy
= y
;
1934 TRACE("horz, notify=%d, y=%d, origheight=%d\n",
1935 notify
, y
, origheight
);
1936 if (notify
&& (y
!= origheight
)) infoPtr
->fStatus
|= NTF_HGHTCHG
;
1939 REBAR_DumpBand (infoPtr
);
1941 REBAR_MoveChildWindows (infoPtr
, 0, infoPtr
->uNumBands
);
1943 REBAR_ForceResize (infoPtr
);
1948 REBAR_ValidateBand (REBAR_INFO
*infoPtr
, REBAR_BAND
*lpBand
)
1949 /* Function: This routine evaluates the band specs supplied */
1950 /* by the user and updates the following 5 fields in */
1951 /* the internal band structure: cxHeader, lcx, lcy, hcx, hcy*/
1958 lpBand
->fStatus
= 0;
1966 /* Data comming in from users into the cx... and cy... fields */
1967 /* may be bad, just garbage, because the user never clears */
1968 /* the fields. RB_{SET|INSERT}BAND{A|W} just passes the data */
1969 /* along if the fields exist in the input area. Here we must */
1970 /* determine if the data is valid. I have no idea how MS does */
1971 /* the validation, but it does because the RB_GETBANDINFO */
1972 /* returns a 0 when I know the sample program passed in an */
1973 /* address. Here I will use the algorithim that if the value */
1974 /* is greater than 65535 then it is bad and replace it with */
1975 /* a zero. Feel free to improve the algorithim. - GA 12/2000 */
1976 if (lpBand
->cxMinChild
> 65535) lpBand
->cxMinChild
= 0;
1977 if (lpBand
->cyMinChild
> 65535) lpBand
->cyMinChild
= 0;
1978 if (lpBand
->cx
> 65535) lpBand
->cx
= 0;
1979 if (lpBand
->cyChild
> 65535) lpBand
->cyChild
= 0;
1980 if (lpBand
->cyMaxChild
> 65535) lpBand
->cyMaxChild
= 0;
1981 if (lpBand
->cyIntegral
> 65535) lpBand
->cyIntegral
= 0;
1982 if (lpBand
->cxIdeal
> 65535) lpBand
->cxIdeal
= 0;
1983 if (lpBand
->cxHeader
> 65535) lpBand
->cxHeader
= 0;
1985 /* FIXME: probably should only set NEEDS_LAYOUT flag when */
1986 /* values change. Till then always set it. */
1987 TRACE("setting NEEDS_LAYOUT\n");
1988 infoPtr
->fStatus
|= BAND_NEEDS_LAYOUT
;
1990 /* Header is where the image, text and gripper exist */
1991 /* in the band and precede the child window. */
1993 /* count number of non-FIXEDSIZE and non-Hidden bands */
1995 for (i
=0; i
<infoPtr
->uNumBands
; i
++){
1996 tBand
= &infoPtr
->bands
[i
];
1997 if (!HIDDENBAND(tBand
) && !(tBand
->fStyle
& RBBS_FIXEDSIZE
))
2001 /* calculate gripper rectangle */
2002 if ( (!(lpBand
->fStyle
& RBBS_NOGRIPPER
)) &&
2003 ( (lpBand
->fStyle
& RBBS_GRIPPERALWAYS
) ||
2004 ( !(lpBand
->fStyle
& RBBS_FIXEDSIZE
) && (nonfixed
> 1)))
2006 lpBand
->fStatus
|= HAS_GRIPPER
;
2007 if (infoPtr
->dwStyle
& CCS_VERT
)
2008 if (infoPtr
->dwStyle
& RBS_VERTICALGRIPPER
)
2009 header
+= (GRIPPER_HEIGHT
+ REBAR_PRE_GRIPPER
);
2011 header
+= (GRIPPER_WIDTH
+ REBAR_PRE_GRIPPER
);
2013 header
+= (REBAR_PRE_GRIPPER
+ GRIPPER_WIDTH
);
2014 /* Always have 4 pixels before anything else */
2015 header
+= REBAR_ALWAYS_SPACE
;
2018 /* image is visible */
2019 if ((lpBand
->fMask
& RBBIM_IMAGE
) && (infoPtr
->himl
)) {
2020 lpBand
->fStatus
|= HAS_IMAGE
;
2021 if (infoPtr
->dwStyle
& CCS_VERT
) {
2022 header
+= (infoPtr
->imageSize
.cy
+ REBAR_POST_IMAGE
);
2023 lpBand
->lcy
= infoPtr
->imageSize
.cx
+ 2;
2026 header
+= (infoPtr
->imageSize
.cx
+ REBAR_POST_IMAGE
);
2027 lpBand
->lcy
= infoPtr
->imageSize
.cy
+ 2;
2031 /* text is visible */
2032 if ((lpBand
->fMask
& RBBIM_TEXT
) && (lpBand
->lpText
) &&
2033 !(lpBand
->fStyle
& RBBS_HIDETITLE
)) {
2034 HDC hdc
= GetDC (0);
2035 HFONT hOldFont
= SelectObject (hdc
, infoPtr
->hFont
);
2038 lpBand
->fStatus
|= HAS_TEXT
;
2039 GetTextExtentPoint32W (hdc
, lpBand
->lpText
,
2040 lstrlenW (lpBand
->lpText
), &size
);
2041 header
+= ((infoPtr
->dwStyle
& CCS_VERT
) ? (size
.cy
+ REBAR_POST_TEXT
) : (size
.cx
+ REBAR_POST_TEXT
));
2042 textheight
= (infoPtr
->dwStyle
& CCS_VERT
) ? 0 : size
.cy
;
2044 SelectObject (hdc
, hOldFont
);
2048 /* if no gripper but either image or text, then leave space */
2049 if ((lpBand
->fStatus
& (HAS_IMAGE
| HAS_TEXT
)) &&
2050 !(lpBand
->fStatus
& HAS_GRIPPER
)) {
2051 header
+= REBAR_ALWAYS_SPACE
;
2054 /* check if user overrode the header value */
2055 if (!(lpBand
->fMask
& RBBIM_HEADERSIZE
))
2056 lpBand
->cxHeader
= header
;
2059 /* Now compute minimum size of child window */
2060 lpBand
->offChild
.cx
= 0;
2061 lpBand
->offChild
.cy
= 0;
2062 lpBand
->lcy
= textheight
;
2063 lpBand
->ccy
= lpBand
->lcy
;
2064 if (lpBand
->fMask
& RBBIM_CHILDSIZE
) {
2065 lpBand
->lcx
= lpBand
->cxMinChild
;
2067 /* Set the .cy values for CHILDSIZE case */
2068 lpBand
->lcy
= max(lpBand
->lcy
, lpBand
->cyMinChild
);
2069 lpBand
->ccy
= lpBand
->lcy
;
2070 lpBand
->hcy
= lpBand
->lcy
;
2071 if (lpBand
->cyMaxChild
!= 0xffffffff) {
2072 lpBand
->hcy
= lpBand
->cyMaxChild
;
2074 if (lpBand
->cyChild
!= 0xffffffff)
2075 lpBand
->ccy
= max (lpBand
->cyChild
, lpBand
->lcy
);
2077 TRACE("_CHILDSIZE\n");
2079 if (lpBand
->fMask
& RBBIM_SIZE
) {
2080 lpBand
->hcx
= max (lpBand
->cx
-lpBand
->cxHeader
, lpBand
->lcx
);
2084 lpBand
->hcx
= lpBand
->lcx
;
2085 lpBand
->ccx
= lpBand
->hcx
;
2087 /* make ->.cx include header size for _Layout */
2088 lpBand
->lcx
+= lpBand
->cxHeader
;
2089 lpBand
->ccx
+= lpBand
->cxHeader
;
2090 lpBand
->hcx
+= lpBand
->cxHeader
;
2095 REBAR_CommonSetupBand (HWND hwnd
, LPREBARBANDINFOA lprbbi
, REBAR_BAND
*lpBand
)
2096 /* Function: This routine copies the supplied values from */
2097 /* user input (lprbbi) to the internal band structure. */
2098 /* It returns true if something changed and false if not. */
2100 BOOL bChanged
= FALSE
;
2102 lpBand
->fMask
|= lprbbi
->fMask
;
2104 if( (lprbbi
->fMask
& RBBIM_STYLE
) &&
2105 (lpBand
->fStyle
!= lprbbi
->fStyle
) )
2107 lpBand
->fStyle
= lprbbi
->fStyle
;
2111 if( (lprbbi
->fMask
& RBBIM_COLORS
) &&
2112 ( ( lpBand
->clrFore
!= lprbbi
->clrFore
) ||
2113 ( lpBand
->clrBack
!= lprbbi
->clrBack
) ) )
2115 lpBand
->clrFore
= lprbbi
->clrFore
;
2116 lpBand
->clrBack
= lprbbi
->clrBack
;
2120 if( (lprbbi
->fMask
& RBBIM_IMAGE
) &&
2121 ( lpBand
->iImage
!= lprbbi
->iImage
) )
2123 lpBand
->iImage
= lprbbi
->iImage
;
2127 if( (lprbbi
->fMask
& RBBIM_CHILD
) &&
2128 (lprbbi
->hwndChild
!= lpBand
->hwndChild
) )
2130 if (lprbbi
->hwndChild
) {
2131 lpBand
->hwndChild
= lprbbi
->hwndChild
;
2132 lpBand
->hwndPrevParent
=
2133 SetParent (lpBand
->hwndChild
, hwnd
);
2134 /* below in trace from WinRAR */
2135 ShowWindow(lpBand
->hwndChild
, SW_SHOWNOACTIVATE
| SW_SHOWNORMAL
);
2136 /* above in trace from WinRAR */
2139 TRACE("child: %p prev parent: %p\n",
2140 lpBand
->hwndChild
, lpBand
->hwndPrevParent
);
2141 lpBand
->hwndChild
= 0;
2142 lpBand
->hwndPrevParent
= 0;
2147 if( (lprbbi
->fMask
& RBBIM_CHILDSIZE
) &&
2148 ( (lpBand
->cxMinChild
!= lprbbi
->cxMinChild
) ||
2149 (lpBand
->cyMinChild
!= lprbbi
->cyMinChild
) ||
2150 ( (lprbbi
->cbSize
>= sizeof (REBARBANDINFOA
)) &&
2151 ( (lpBand
->cyChild
!= lprbbi
->cyChild
) ||
2152 (lpBand
->cyMaxChild
!= lprbbi
->cyMaxChild
) ||
2153 (lpBand
->cyIntegral
!= lprbbi
->cyIntegral
) ) ) ||
2154 ( (lprbbi
->cbSize
< sizeof (REBARBANDINFOA
)) &&
2155 ( (lpBand
->cyChild
||
2156 lpBand
->cyMaxChild
||
2157 lpBand
->cyIntegral
) ) ) ) )
2159 lpBand
->cxMinChild
= lprbbi
->cxMinChild
;
2160 lpBand
->cyMinChild
= lprbbi
->cyMinChild
;
2161 if (lprbbi
->cbSize
>= sizeof (REBARBANDINFOA
)) {
2162 lpBand
->cyChild
= lprbbi
->cyChild
;
2163 lpBand
->cyMaxChild
= lprbbi
->cyMaxChild
;
2164 lpBand
->cyIntegral
= lprbbi
->cyIntegral
;
2166 else { /* special case - these should be zeroed out since */
2167 /* RBBIM_CHILDSIZE added these in WIN32_IE >= 0x0400 */
2168 lpBand
->cyChild
= 0;
2169 lpBand
->cyMaxChild
= 0;
2170 lpBand
->cyIntegral
= 0;
2175 if( (lprbbi
->fMask
& RBBIM_SIZE
) &&
2176 (lpBand
->cx
!= lprbbi
->cx
) )
2178 lpBand
->cx
= lprbbi
->cx
;
2182 if( (lprbbi
->fMask
& RBBIM_BACKGROUND
) &&
2183 ( lpBand
->hbmBack
!= lprbbi
->hbmBack
) )
2185 lpBand
->hbmBack
= lprbbi
->hbmBack
;
2189 if( (lprbbi
->fMask
& RBBIM_ID
) &&
2190 (lpBand
->wID
!= lprbbi
->wID
) )
2192 lpBand
->wID
= lprbbi
->wID
;
2196 /* check for additional data */
2197 if (lprbbi
->cbSize
>= sizeof (REBARBANDINFOA
)) {
2198 if( (lprbbi
->fMask
& RBBIM_IDEALSIZE
) &&
2199 ( lpBand
->cxIdeal
!= lprbbi
->cxIdeal
) )
2201 lpBand
->cxIdeal
= lprbbi
->cxIdeal
;
2205 if( (lprbbi
->fMask
& RBBIM_LPARAM
) &&
2206 (lpBand
->lParam
!= lprbbi
->lParam
) )
2208 lpBand
->lParam
= lprbbi
->lParam
;
2212 if( (lprbbi
->fMask
& RBBIM_HEADERSIZE
) &&
2213 (lpBand
->cxHeader
!= lprbbi
->cxHeader
) )
2215 lpBand
->cxHeader
= lprbbi
->cxHeader
;
2224 REBAR_InternalEraseBkGnd (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
, RECT
*clip
)
2225 /* Function: This erases the background rectangle by drawing */
2226 /* each band with its background color (or the default) and */
2227 /* draws each bands right separator if necessary. The row */
2228 /* separators are drawn on the first band of the next row. */
2233 HDC hdc
= (HDC
)wParam
;
2235 COLORREF old
= CLR_NONE
, new;
2236 HTHEME theme
= GetWindowTheme (infoPtr
->hwndSelf
);
2238 GetClientRect (infoPtr
->hwndSelf
, &cr
);
2241 for(i
=0; i
<infoPtr
->uNumBands
; i
++) {
2242 lpBand
= &infoPtr
->bands
[i
];
2243 if (HIDDENBAND(lpBand
)) continue;
2245 /* draw band separator between rows */
2246 if (lpBand
->iRow
!= oldrow
) {
2247 oldrow
= lpBand
->iRow
;
2248 if (lpBand
->fDraw
& DRAW_BOTTOMSEP
) {
2250 rcRowSep
= lpBand
->rcBand
;
2251 if (infoPtr
->dwStyle
& CCS_VERT
) {
2252 rcRowSep
.right
+= SEP_WIDTH_SIZE
;
2253 rcRowSep
.bottom
= infoPtr
->calcSize
.cy
;
2255 DrawThemeEdge (theme
, hdc
, RP_BAND
, 0, &rcRowSep
, EDGE_ETCHED
, BF_RIGHT
, NULL
);
2257 DrawEdge (hdc
, &rcRowSep
, EDGE_ETCHED
, BF_RIGHT
);
2260 rcRowSep
.bottom
+= SEP_WIDTH_SIZE
;
2261 rcRowSep
.right
= infoPtr
->calcSize
.cx
;
2263 DrawThemeEdge (theme
, hdc
, RP_BAND
, 0, &rcRowSep
, EDGE_ETCHED
, BF_BOTTOM
, NULL
);
2265 DrawEdge (hdc
, &rcRowSep
, EDGE_ETCHED
, BF_BOTTOM
);
2267 TRACE ("drawing band separator bottom (%ld,%ld)-(%ld,%ld)\n",
2268 rcRowSep
.left
, rcRowSep
.top
,
2269 rcRowSep
.right
, rcRowSep
.bottom
);
2273 /* draw band separator between bands in a row */
2274 if (lpBand
->fDraw
& DRAW_RIGHTSEP
) {
2276 rcSep
= lpBand
->rcBand
;
2277 if (infoPtr
->dwStyle
& CCS_VERT
) {
2278 rcSep
.bottom
+= SEP_WIDTH_SIZE
;
2280 DrawThemeEdge (theme
, hdc
, RP_BAND
, 0, &rcSep
, EDGE_ETCHED
, BF_BOTTOM
, NULL
);
2282 DrawEdge (hdc
, &rcSep
, EDGE_ETCHED
, BF_BOTTOM
);
2285 rcSep
.right
+= SEP_WIDTH_SIZE
;
2287 DrawThemeEdge (theme
, hdc
, RP_BAND
, 0, &rcSep
, EDGE_ETCHED
, BF_RIGHT
, NULL
);
2289 DrawEdge (hdc
, &rcSep
, EDGE_ETCHED
, BF_RIGHT
);
2291 TRACE("drawing band separator right (%ld,%ld)-(%ld,%ld)\n",
2292 rcSep
.left
, rcSep
.top
, rcSep
.right
, rcSep
.bottom
);
2295 /* draw the actual background */
2296 if (lpBand
->clrBack
!= CLR_NONE
) {
2297 new = (lpBand
->clrBack
== CLR_DEFAULT
) ? infoPtr
->clrBtnFace
:
2300 /* testing only - make background green to see it */
2305 /* In the absence of documentation for Rebar vs. CLR_NONE,
2306 * we will use the default BtnFace color. Note documentation
2307 * exists for Listview and Imagelist.
2309 new = infoPtr
->clrBtnFace
;
2311 /* testing only - make background green to see it */
2316 rect
= lpBand
->rcBand
;
2320 /* When themed, the background color is ignored (but not a
2321 * background bitmap */
2322 DrawThemeBackground (theme
, hdc
, 0, 0, &cr
, &rect
);
2326 old
= SetBkColor (hdc
, new);
2327 TRACE("%s background color=0x%06lx, band (%ld,%ld)-(%ld,%ld), clip (%ld,%ld)-(%ld,%ld)\n",
2328 (lpBand
->clrBack
== CLR_NONE
) ? "none" :
2329 ((lpBand
->clrBack
== CLR_DEFAULT
) ? "dft" : ""),
2331 lpBand
->rcBand
.left
,lpBand
->rcBand
.top
,
2332 lpBand
->rcBand
.right
,lpBand
->rcBand
.bottom
,
2333 clip
->left
, clip
->top
,
2334 clip
->right
, clip
->bottom
);
2335 ExtTextOutW (hdc
, 0, 0, ETO_OPAQUE
, &rect
, NULL
, 0, 0);
2336 if (lpBand
->clrBack
!= CLR_NONE
)
2337 SetBkColor (hdc
, old
);
2344 REBAR_InternalHitTest (REBAR_INFO
*infoPtr
, const LPPOINT lpPt
, UINT
*pFlags
, INT
*pBand
)
2350 GetClientRect (infoPtr
->hwndSelf
, &rect
);
2352 *pFlags
= RBHT_NOWHERE
;
2353 if (PtInRect (&rect
, *lpPt
))
2355 if (infoPtr
->uNumBands
== 0) {
2356 *pFlags
= RBHT_NOWHERE
;
2363 /* somewhere inside */
2364 for (iCount
= 0; iCount
< infoPtr
->uNumBands
; iCount
++) {
2365 lpBand
= &infoPtr
->bands
[iCount
];
2366 if (HIDDENBAND(lpBand
)) continue;
2367 if (PtInRect (&lpBand
->rcBand
, *lpPt
)) {
2370 if (PtInRect (&lpBand
->rcGripper
, *lpPt
)) {
2371 *pFlags
= RBHT_GRABBER
;
2372 TRACE("ON GRABBER %d\n", iCount
);
2375 else if (PtInRect (&lpBand
->rcCapImage
, *lpPt
)) {
2376 *pFlags
= RBHT_CAPTION
;
2377 TRACE("ON CAPTION %d\n", iCount
);
2380 else if (PtInRect (&lpBand
->rcCapText
, *lpPt
)) {
2381 *pFlags
= RBHT_CAPTION
;
2382 TRACE("ON CAPTION %d\n", iCount
);
2385 else if (PtInRect (&lpBand
->rcChild
, *lpPt
)) {
2386 *pFlags
= RBHT_CLIENT
;
2387 TRACE("ON CLIENT %d\n", iCount
);
2390 else if (PtInRect (&lpBand
->rcChevron
, *lpPt
)) {
2391 *pFlags
= RBHT_CHEVRON
;
2392 TRACE("ON CHEVRON %d\n", iCount
);
2396 *pFlags
= RBHT_NOWHERE
;
2397 TRACE("NOWHERE %d\n", iCount
);
2403 *pFlags
= RBHT_NOWHERE
;
2412 *pFlags
= RBHT_NOWHERE
;
2422 REBAR_Shrink (REBAR_INFO
*infoPtr
, REBAR_BAND
*band
, INT movement
, INT i
)
2423 /* Function: This attempts to shrink the given band by the */
2424 /* the amount in "movement". A shrink to the left is indi- */
2425 /* cated by "movement" being negative. "i" is merely the */
2426 /* band index for trace messages. */
2428 INT Leadjust
, Readjust
, avail
, ret
;
2430 /* Note: a left drag is indicated by "movement" being negative. */
2431 /* Similarly, a right drag is indicated by "movement" */
2432 /* being positive. "movement" should never be 0, but if */
2433 /* it is then the band does not move. */
2435 avail
= rcBw(band
) - band
->lcx
;
2437 /* now compute the Left End adjustment factor and Right End */
2438 /* adjustment factor. They may be different if shrinking. */
2440 /* if this band is not shrinkable, then just move it */
2441 Leadjust
= Readjust
= movement
;
2447 if (avail
<= abs(movement
)) {
2448 Readjust
= movement
;
2449 Leadjust
= movement
+ avail
;
2453 Readjust
= movement
;
2460 if (avail
<= abs(movement
)) {
2461 Leadjust
= movement
;
2462 Readjust
= movement
- avail
;
2466 Leadjust
= movement
;
2473 /* Reasonability Check */
2474 if (rcBlt(band
) + Leadjust
< 0) {
2475 ERR("adjustment will fail, band %d: left=%d, right=%d, move=%d, rtn=%d\n",
2476 i
, Leadjust
, Readjust
, movement
, ret
);
2479 LEADJ(band
, Leadjust
);
2480 READJ(band
, Readjust
);
2482 TRACE("band %d: left=%d, right=%d, move=%d, rtn=%d, rcBand=(%ld,%ld)-(%ld,%ld)\n",
2483 i
, Leadjust
, Readjust
, movement
, ret
,
2484 band
->rcBand
.left
, band
->rcBand
.top
,
2485 band
->rcBand
.right
, band
->rcBand
.bottom
);
2491 REBAR_HandleLRDrag (REBAR_INFO
*infoPtr
, const POINT
*ptsmove
)
2492 /* Function: This will implement the functionality of a */
2493 /* Gripper drag within a row. It will not implement "out- */
2494 /* of-row" drags. (They are detected and handled in */
2495 /* REBAR_MouseMove.) */
2496 /* **** FIXME Switching order of bands in a row not **** */
2497 /* **** yet implemented. **** */
2499 REBAR_BAND
*hitBand
, *band
, *mindBand
, *maxdBand
;
2501 INT imindBand
= -1, imaxdBand
, ihitBand
, i
, movement
;
2502 INT RHeaderSum
= 0, LHeaderSum
= 0;
2505 /* on first significant mouse movement, issue notify */
2507 if (!(infoPtr
->fStatus
& BEGIN_DRAG_ISSUED
)) {
2508 if (REBAR_Notify_NMREBAR (infoPtr
, -1, RBN_BEGINDRAG
)) {
2509 /* Notify returned TRUE - abort drag */
2510 infoPtr
->dragStart
.x
= 0;
2511 infoPtr
->dragStart
.y
= 0;
2512 infoPtr
->dragNow
= infoPtr
->dragStart
;
2513 infoPtr
->iGrabbedBand
= -1;
2517 infoPtr
->fStatus
|= BEGIN_DRAG_ISSUED
;
2520 ihitBand
= infoPtr
->iGrabbedBand
;
2521 hitBand
= &infoPtr
->bands
[ihitBand
];
2522 imaxdBand
= ihitBand
; /* to suppress warning message */
2524 /* find all the bands in the row of the one whose Gripper was seized */
2525 for (i
=0; i
<infoPtr
->uNumBands
; i
++) {
2526 band
= &infoPtr
->bands
[i
];
2527 if (HIDDENBAND(band
)) continue;
2528 if (band
->iRow
== hitBand
->iRow
) {
2530 if (imindBand
== -1) imindBand
= i
;
2531 /* minimum size of each band is size of header plus */
2532 /* size of minimum child plus offset of child from header plus */
2533 /* one to separate each band. */
2535 LHeaderSum
+= (band
->lcx
+ SEP_WIDTH
);
2537 RHeaderSum
+= (band
->lcx
+ SEP_WIDTH
);
2541 if (RHeaderSum
) RHeaderSum
-= SEP_WIDTH
; /* no separator after last band */
2543 mindBand
= &infoPtr
->bands
[imindBand
];
2544 maxdBand
= &infoPtr
->bands
[imaxdBand
];
2546 if (imindBand
== imaxdBand
) return; /* nothing to drag against */
2547 if (imindBand
== ihitBand
) return; /* first band in row, can't drag */
2549 /* limit movement to inside adjustable bands - Left */
2550 if ( (ptsmove
->x
< mindBand
->rcBand
.left
) ||
2551 (ptsmove
->x
> maxdBand
->rcBand
.right
) ||
2552 (ptsmove
->y
< mindBand
->rcBand
.top
) ||
2553 (ptsmove
->y
> maxdBand
->rcBand
.bottom
))
2554 return; /* should swap bands */
2556 if (infoPtr
->dwStyle
& CCS_VERT
)
2557 movement
= ptsmove
->y
- ((hitBand
->rcBand
.top
+REBAR_PRE_GRIPPER
) -
2558 infoPtr
->ihitoffset
);
2560 movement
= ptsmove
->x
- ((hitBand
->rcBand
.left
+REBAR_PRE_GRIPPER
) -
2561 infoPtr
->ihitoffset
);
2562 infoPtr
->dragNow
= *ptsmove
;
2564 TRACE("before: movement=%d (%ld,%ld), imindBand=%d, ihitBand=%d, imaxdBand=%d, LSum=%d, RSum=%d\n",
2565 movement
, ptsmove
->x
, ptsmove
->y
, imindBand
, ihitBand
,
2566 imaxdBand
, LHeaderSum
, RHeaderSum
);
2567 REBAR_DumpBand (infoPtr
);
2571 /* *** Drag left/up *** */
2572 compress
= rcBlt(hitBand
) - rcBlt(mindBand
) -
2574 if (compress
< abs(movement
)) {
2575 TRACE("limiting left drag, was %d changed to %d\n",
2576 movement
, -compress
);
2577 movement
= -compress
;
2580 for (i
=ihitBand
; i
>=imindBand
; i
--) {
2581 band
= &infoPtr
->bands
[i
];
2582 if (HIDDENBAND(band
)) continue;
2583 if (i
== ihitBand
) {
2584 LEADJ(band
, movement
);
2587 movement
= REBAR_Shrink (infoPtr
, band
, movement
, i
);
2588 band
->ccx
= rcBw(band
);
2594 /* *** Drag right/down *** */
2595 compress
= rcBrb(maxdBand
) - rcBlt(hitBand
) -
2597 if (compress
< abs(movement
)) {
2598 TRACE("limiting right drag, was %d changed to %d\n",
2599 movement
, compress
);
2600 movement
= compress
;
2602 for (i
=ihitBand
-1; i
<=imaxdBand
; i
++) {
2603 band
= &infoPtr
->bands
[i
];
2604 if (HIDDENBAND(band
)) continue;
2607 READJ(band
, movement
);
2610 movement
= REBAR_Shrink (infoPtr
, band
, movement
, i
);
2611 band
->ccx
= rcBw(band
);
2615 /* recompute all rectangles */
2616 if (infoPtr
->dwStyle
& CCS_VERT
) {
2617 REBAR_CalcVertBand (infoPtr
, imindBand
, imaxdBand
+1,
2621 REBAR_CalcHorzBand (infoPtr
, imindBand
, imaxdBand
+1,
2625 TRACE("bands after adjustment, see band # %d, %d\n",
2626 imindBand
, imaxdBand
);
2627 REBAR_DumpBand (infoPtr
);
2630 mindBand
->rcBand
.left
,
2631 mindBand
->rcBand
.top
,
2632 maxdBand
->rcBand
.right
,
2633 maxdBand
->rcBand
.bottom
);
2635 REBAR_MoveChildWindows (infoPtr
, imindBand
, imaxdBand
+1);
2637 InvalidateRect (infoPtr
->hwndSelf
, &newrect
, TRUE
);
2638 UpdateWindow (infoPtr
->hwndSelf
);
2644 /* << REBAR_BeginDrag >> */
2648 REBAR_DeleteBand (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
2650 UINT uBand
= (UINT
)wParam
;
2654 if (uBand
>= infoPtr
->uNumBands
)
2657 TRACE("deleting band %u!\n", uBand
);
2658 lpBand
= &infoPtr
->bands
[uBand
];
2659 REBAR_Notify_NMREBAR (infoPtr
, uBand
, RBN_DELETINGBAND
);
2661 if (infoPtr
->uNumBands
== 1) {
2662 TRACE(" simple delete!\n");
2663 if ((lpBand
->fMask
& RBBIM_CHILD
) && lpBand
->hwndChild
)
2664 childhwnd
= lpBand
->hwndChild
;
2665 Free (infoPtr
->bands
);
2666 infoPtr
->bands
= NULL
;
2667 infoPtr
->uNumBands
= 0;
2670 REBAR_BAND
*oldBands
= infoPtr
->bands
;
2671 TRACE("complex delete! [uBand=%u]\n", uBand
);
2673 if ((lpBand
->fMask
& RBBIM_CHILD
) && lpBand
->hwndChild
)
2674 childhwnd
= lpBand
->hwndChild
;
2676 infoPtr
->uNumBands
--;
2677 infoPtr
->bands
= Alloc (sizeof (REBAR_BAND
) * infoPtr
->uNumBands
);
2679 memcpy (&infoPtr
->bands
[0], &oldBands
[0],
2680 uBand
* sizeof(REBAR_BAND
));
2683 if (uBand
< infoPtr
->uNumBands
) {
2684 memcpy (&infoPtr
->bands
[uBand
], &oldBands
[uBand
+1],
2685 (infoPtr
->uNumBands
- uBand
) * sizeof(REBAR_BAND
));
2692 ShowWindow (childhwnd
, SW_HIDE
);
2694 REBAR_Notify_NMREBAR (infoPtr
, -1, RBN_DELETEDBAND
);
2696 /* if only 1 band left the re-validate to possible eliminate gripper */
2697 if (infoPtr
->uNumBands
== 1)
2698 REBAR_ValidateBand (infoPtr
, &infoPtr
->bands
[0]);
2700 TRACE("setting NEEDS_LAYOUT\n");
2701 infoPtr
->fStatus
|= BAND_NEEDS_LAYOUT
;
2702 infoPtr
->fStatus
|= RESIZE_ANYHOW
;
2703 REBAR_Layout (infoPtr
, NULL
, TRUE
, FALSE
);
2709 /* << REBAR_DragMove >> */
2710 /* << REBAR_EndDrag >> */
2714 REBAR_GetBandBorders (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
2716 LPRECT lpRect
= (LPRECT
)lParam
;
2721 if ((UINT
)wParam
>= infoPtr
->uNumBands
)
2724 lpBand
= &infoPtr
->bands
[(UINT
)wParam
];
2726 /* FIXME - the following values were determined by experimentation */
2727 /* with the REBAR Control Spy. I have guesses as to what the 4 and */
2728 /* 1 are, but I am not sure. There doesn't seem to be any actual */
2729 /* difference in size of the control area with and without the */
2731 if (infoPtr
->dwStyle
& RBS_BANDBORDERS
) {
2732 if (infoPtr
->dwStyle
& CCS_VERT
) {
2734 lpRect
->top
= lpBand
->cxHeader
+ 4;
2739 lpRect
->left
= lpBand
->cxHeader
+ 4;
2746 lpRect
->left
= lpBand
->cxHeader
;
2752 inline static LRESULT
2753 REBAR_GetBandCount (REBAR_INFO
*infoPtr
)
2755 TRACE("band count %u!\n", infoPtr
->uNumBands
);
2757 return infoPtr
->uNumBands
;
2762 REBAR_GetBandInfoA (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
2764 LPREBARBANDINFOA lprbbi
= (LPREBARBANDINFOA
)lParam
;
2769 if (lprbbi
->cbSize
< REBARBANDINFOA_V3_SIZE
)
2771 if ((UINT
)wParam
>= infoPtr
->uNumBands
)
2774 TRACE("index %u\n", (UINT
)wParam
);
2776 /* copy band information */
2777 lpBand
= &infoPtr
->bands
[(UINT
)wParam
];
2779 if (lprbbi
->fMask
& RBBIM_STYLE
)
2780 lprbbi
->fStyle
= lpBand
->fStyle
;
2782 if (lprbbi
->fMask
& RBBIM_COLORS
) {
2783 lprbbi
->clrFore
= lpBand
->clrFore
;
2784 lprbbi
->clrBack
= lpBand
->clrBack
;
2785 if (lprbbi
->clrBack
== CLR_DEFAULT
)
2786 lprbbi
->clrBack
= infoPtr
->clrBtnFace
;
2789 if ((lprbbi
->fMask
& RBBIM_TEXT
) && (lprbbi
->lpText
)) {
2790 if (lpBand
->lpText
&& (lpBand
->fMask
& RBBIM_TEXT
))
2792 if (!WideCharToMultiByte( CP_ACP
, 0, lpBand
->lpText
, -1,
2793 lprbbi
->lpText
, lprbbi
->cch
, NULL
, NULL
))
2794 lprbbi
->lpText
[lprbbi
->cch
-1] = 0;
2797 *lprbbi
->lpText
= 0;
2800 if (lprbbi
->fMask
& RBBIM_IMAGE
) {
2801 if (lpBand
->fMask
& RBBIM_IMAGE
)
2802 lprbbi
->iImage
= lpBand
->iImage
;
2804 lprbbi
->iImage
= -1;
2807 if (lprbbi
->fMask
& RBBIM_CHILD
)
2808 lprbbi
->hwndChild
= lpBand
->hwndChild
;
2810 if (lprbbi
->fMask
& RBBIM_CHILDSIZE
) {
2811 lprbbi
->cxMinChild
= lpBand
->cxMinChild
;
2812 lprbbi
->cyMinChild
= lpBand
->cyMinChild
;
2813 if (lprbbi
->cbSize
>= sizeof (REBARBANDINFOA
)) {
2814 lprbbi
->cyChild
= lpBand
->cyChild
;
2815 lprbbi
->cyMaxChild
= lpBand
->cyMaxChild
;
2816 lprbbi
->cyIntegral
= lpBand
->cyIntegral
;
2820 if (lprbbi
->fMask
& RBBIM_SIZE
)
2821 lprbbi
->cx
= lpBand
->cx
;
2823 if (lprbbi
->fMask
& RBBIM_BACKGROUND
)
2824 lprbbi
->hbmBack
= lpBand
->hbmBack
;
2826 if (lprbbi
->fMask
& RBBIM_ID
)
2827 lprbbi
->wID
= lpBand
->wID
;
2829 /* check for additional data */
2830 if (lprbbi
->cbSize
>= sizeof (REBARBANDINFOA
)) {
2831 if (lprbbi
->fMask
& RBBIM_IDEALSIZE
)
2832 lprbbi
->cxIdeal
= lpBand
->cxIdeal
;
2834 if (lprbbi
->fMask
& RBBIM_LPARAM
)
2835 lprbbi
->lParam
= lpBand
->lParam
;
2837 if (lprbbi
->fMask
& RBBIM_HEADERSIZE
)
2838 lprbbi
->cxHeader
= lpBand
->cxHeader
;
2841 REBAR_DumpBandInfo (lprbbi
);
2848 REBAR_GetBandInfoW (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
2850 LPREBARBANDINFOW lprbbi
= (LPREBARBANDINFOW
)lParam
;
2855 if (lprbbi
->cbSize
< REBARBANDINFOW_V3_SIZE
)
2857 if ((UINT
)wParam
>= infoPtr
->uNumBands
)
2860 TRACE("index %u\n", (UINT
)wParam
);
2862 /* copy band information */
2863 lpBand
= &infoPtr
->bands
[(UINT
)wParam
];
2865 if (lprbbi
->fMask
& RBBIM_STYLE
)
2866 lprbbi
->fStyle
= lpBand
->fStyle
;
2868 if (lprbbi
->fMask
& RBBIM_COLORS
) {
2869 lprbbi
->clrFore
= lpBand
->clrFore
;
2870 lprbbi
->clrBack
= lpBand
->clrBack
;
2871 if (lprbbi
->clrBack
== CLR_DEFAULT
)
2872 lprbbi
->clrBack
= infoPtr
->clrBtnFace
;
2875 if ((lprbbi
->fMask
& RBBIM_TEXT
) && (lprbbi
->lpText
)) {
2876 if (lpBand
->lpText
&& (lpBand
->fMask
& RBBIM_TEXT
))
2877 lstrcpynW (lprbbi
->lpText
, lpBand
->lpText
, lprbbi
->cch
);
2879 *lprbbi
->lpText
= 0;
2882 if (lprbbi
->fMask
& RBBIM_IMAGE
) {
2883 if (lpBand
->fMask
& RBBIM_IMAGE
)
2884 lprbbi
->iImage
= lpBand
->iImage
;
2886 lprbbi
->iImage
= -1;
2889 if (lprbbi
->fMask
& RBBIM_CHILD
)
2890 lprbbi
->hwndChild
= lpBand
->hwndChild
;
2892 if (lprbbi
->fMask
& RBBIM_CHILDSIZE
) {
2893 lprbbi
->cxMinChild
= lpBand
->cxMinChild
;
2894 lprbbi
->cyMinChild
= lpBand
->cyMinChild
;
2895 if (lprbbi
->cbSize
>= sizeof (REBARBANDINFOW
)) {
2896 lprbbi
->cyChild
= lpBand
->cyChild
;
2897 lprbbi
->cyMaxChild
= lpBand
->cyMaxChild
;
2898 lprbbi
->cyIntegral
= lpBand
->cyIntegral
;
2902 if (lprbbi
->fMask
& RBBIM_SIZE
)
2903 lprbbi
->cx
= lpBand
->cx
;
2905 if (lprbbi
->fMask
& RBBIM_BACKGROUND
)
2906 lprbbi
->hbmBack
= lpBand
->hbmBack
;
2908 if (lprbbi
->fMask
& RBBIM_ID
)
2909 lprbbi
->wID
= lpBand
->wID
;
2911 /* check for additional data */
2912 if (lprbbi
->cbSize
>= sizeof (REBARBANDINFOW
)) {
2913 if (lprbbi
->fMask
& RBBIM_IDEALSIZE
)
2914 lprbbi
->cxIdeal
= lpBand
->cxIdeal
;
2916 if (lprbbi
->fMask
& RBBIM_LPARAM
)
2917 lprbbi
->lParam
= lpBand
->lParam
;
2919 if (lprbbi
->fMask
& RBBIM_HEADERSIZE
)
2920 lprbbi
->cxHeader
= lpBand
->cxHeader
;
2923 REBAR_DumpBandInfo ((LPREBARBANDINFOA
)lprbbi
);
2930 REBAR_GetBarHeight (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
2934 nHeight
= (infoPtr
->dwStyle
& CCS_VERT
) ? infoPtr
->calcSize
.cx
: infoPtr
->calcSize
.cy
;
2936 TRACE("height = %d\n", nHeight
);
2943 REBAR_GetBarInfo (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
2945 LPREBARINFO lpInfo
= (LPREBARINFO
)lParam
;
2950 if (lpInfo
->cbSize
< sizeof (REBARINFO
))
2953 TRACE("getting bar info!\n");
2955 if (infoPtr
->himl
) {
2956 lpInfo
->himl
= infoPtr
->himl
;
2957 lpInfo
->fMask
|= RBIM_IMAGELIST
;
2964 inline static LRESULT
2965 REBAR_GetBkColor (REBAR_INFO
*infoPtr
)
2967 COLORREF clr
= infoPtr
->clrBk
;
2969 if (clr
== CLR_DEFAULT
)
2970 clr
= infoPtr
->clrBtnFace
;
2972 TRACE("background color 0x%06lx!\n", clr
);
2978 /* << REBAR_GetColorScheme >> */
2979 /* << REBAR_GetDropTarget >> */
2983 REBAR_GetPalette (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
2985 FIXME("empty stub!\n");
2992 REBAR_GetRect (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
2994 INT iBand
= (INT
)wParam
;
2995 LPRECT lprc
= (LPRECT
)lParam
;
2998 if ((iBand
< 0) && ((UINT
)iBand
>= infoPtr
->uNumBands
))
3003 lpBand
= &infoPtr
->bands
[iBand
];
3004 CopyRect (lprc
, &lpBand
->rcBand
);
3006 TRACE("band %d, (%ld,%ld)-(%ld,%ld)\n", iBand
,
3007 lprc
->left
, lprc
->top
, lprc
->right
, lprc
->bottom
);
3013 inline static LRESULT
3014 REBAR_GetRowCount (REBAR_INFO
*infoPtr
)
3016 TRACE("%u\n", infoPtr
->uNumRows
);
3018 return infoPtr
->uNumRows
;
3023 REBAR_GetRowHeight (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
3025 INT iRow
= (INT
)wParam
;
3030 for (i
=0; i
<infoPtr
->uNumBands
; i
++) {
3031 lpBand
= &infoPtr
->bands
[i
];
3032 if (HIDDENBAND(lpBand
)) continue;
3033 if (lpBand
->iRow
!= iRow
) continue;
3034 if (infoPtr
->dwStyle
& CCS_VERT
)
3035 j
= lpBand
->rcBand
.right
- lpBand
->rcBand
.left
;
3037 j
= lpBand
->rcBand
.bottom
- lpBand
->rcBand
.top
;
3038 if (j
> ret
) ret
= j
;
3041 TRACE("row %d, height %d\n", iRow
, ret
);
3047 inline static LRESULT
3048 REBAR_GetTextColor (REBAR_INFO
*infoPtr
)
3050 TRACE("text color 0x%06lx!\n", infoPtr
->clrText
);
3052 return infoPtr
->clrText
;
3056 inline static LRESULT
3057 REBAR_GetToolTips (REBAR_INFO
*infoPtr
)
3059 return (LRESULT
)infoPtr
->hwndToolTip
;
3063 inline static LRESULT
3064 REBAR_GetUnicodeFormat (REBAR_INFO
*infoPtr
)
3066 TRACE("%s hwnd=%p\n",
3067 infoPtr
->bUnicode
? "TRUE" : "FALSE", infoPtr
->hwndSelf
);
3069 return infoPtr
->bUnicode
;
3073 inline static LRESULT
3074 REBAR_GetVersion (REBAR_INFO
*infoPtr
)
3076 TRACE("version %d\n", infoPtr
->iVersion
);
3077 return infoPtr
->iVersion
;
3082 REBAR_HitTest (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
3084 LPRBHITTESTINFO lprbht
= (LPRBHITTESTINFO
)lParam
;
3089 REBAR_InternalHitTest (infoPtr
, &lprbht
->pt
, &lprbht
->flags
, &lprbht
->iBand
);
3091 return lprbht
->iBand
;
3096 REBAR_IdToIndex (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
3100 if (infoPtr
== NULL
)
3103 if (infoPtr
->uNumBands
< 1)
3106 for (i
= 0; i
< infoPtr
->uNumBands
; i
++) {
3107 if (infoPtr
->bands
[i
].wID
== (UINT
)wParam
) {
3108 TRACE("id %u is band %u found!\n", (UINT
)wParam
, i
);
3113 TRACE("id %u is not found\n", (UINT
)wParam
);
3119 REBAR_InsertBandA (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
3121 LPREBARBANDINFOA lprbbi
= (LPREBARBANDINFOA
)lParam
;
3122 UINT uIndex
= (UINT
)wParam
;
3125 if (infoPtr
== NULL
)
3129 if (lprbbi
->cbSize
< REBARBANDINFOA_V3_SIZE
)
3132 /* trace the index as signed to see the -1 */
3133 TRACE("insert band at %d!\n", (INT
)uIndex
);
3134 REBAR_DumpBandInfo (lprbbi
);
3136 if (infoPtr
->uNumBands
== 0) {
3137 infoPtr
->bands
= (REBAR_BAND
*)Alloc (sizeof (REBAR_BAND
));
3141 REBAR_BAND
*oldBands
= infoPtr
->bands
;
3143 (REBAR_BAND
*)Alloc ((infoPtr
->uNumBands
+1)*sizeof(REBAR_BAND
));
3144 if (((INT
)uIndex
== -1) || (uIndex
> infoPtr
->uNumBands
))
3145 uIndex
= infoPtr
->uNumBands
;
3147 /* pre insert copy */
3149 memcpy (&infoPtr
->bands
[0], &oldBands
[0],
3150 uIndex
* sizeof(REBAR_BAND
));
3154 if (uIndex
< infoPtr
->uNumBands
) {
3155 memcpy (&infoPtr
->bands
[uIndex
+1], &oldBands
[uIndex
],
3156 (infoPtr
->uNumBands
- uIndex
) * sizeof(REBAR_BAND
));
3162 infoPtr
->uNumBands
++;
3164 TRACE("index %u!\n", uIndex
);
3166 /* initialize band (infoPtr->bands[uIndex])*/
3167 lpBand
= &infoPtr
->bands
[uIndex
];
3169 lpBand
->fStatus
= 0;
3170 lpBand
->clrFore
= infoPtr
->clrText
;
3171 lpBand
->clrBack
= infoPtr
->clrBk
;
3172 lpBand
->hwndChild
= 0;
3173 lpBand
->hwndPrevParent
= 0;
3175 REBAR_CommonSetupBand (infoPtr
->hwndSelf
, lprbbi
, lpBand
);
3176 lpBand
->lpText
= NULL
;
3177 if ((lprbbi
->fMask
& RBBIM_TEXT
) && (lprbbi
->lpText
)) {
3178 INT len
= MultiByteToWideChar( CP_ACP
, 0, lprbbi
->lpText
, -1, NULL
, 0 );
3180 lpBand
->lpText
= (LPWSTR
)Alloc (len
*sizeof(WCHAR
));
3181 MultiByteToWideChar( CP_ACP
, 0, lprbbi
->lpText
, -1, lpBand
->lpText
, len
);
3185 REBAR_ValidateBand (infoPtr
, lpBand
);
3186 /* On insert of second band, revalidate band 1 to possible add gripper */
3187 if (infoPtr
->uNumBands
== 2)
3188 REBAR_ValidateBand (infoPtr
, &infoPtr
->bands
[0]);
3190 REBAR_DumpBand (infoPtr
);
3192 REBAR_Layout (infoPtr
, NULL
, TRUE
, FALSE
);
3193 InvalidateRect(infoPtr
->hwndSelf
, 0, 1);
3200 REBAR_InsertBandW (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
3202 LPREBARBANDINFOW lprbbi
= (LPREBARBANDINFOW
)lParam
;
3203 UINT uIndex
= (UINT
)wParam
;
3206 if (infoPtr
== NULL
)
3210 if (lprbbi
->cbSize
< REBARBANDINFOW_V3_SIZE
)
3213 /* trace the index as signed to see the -1 */
3214 TRACE("insert band at %d!\n", (INT
)uIndex
);
3215 REBAR_DumpBandInfo ((LPREBARBANDINFOA
)lprbbi
);
3217 if (infoPtr
->uNumBands
== 0) {
3218 infoPtr
->bands
= (REBAR_BAND
*)Alloc (sizeof (REBAR_BAND
));
3222 REBAR_BAND
*oldBands
= infoPtr
->bands
;
3224 (REBAR_BAND
*)Alloc ((infoPtr
->uNumBands
+1)*sizeof(REBAR_BAND
));
3225 if (((INT
)uIndex
== -1) || (uIndex
> infoPtr
->uNumBands
))
3226 uIndex
= infoPtr
->uNumBands
;
3228 /* pre insert copy */
3230 memcpy (&infoPtr
->bands
[0], &oldBands
[0],
3231 uIndex
* sizeof(REBAR_BAND
));
3235 if (uIndex
<= infoPtr
->uNumBands
- 1) {
3236 memcpy (&infoPtr
->bands
[uIndex
+1], &oldBands
[uIndex
],
3237 (infoPtr
->uNumBands
- uIndex
) * sizeof(REBAR_BAND
));
3243 infoPtr
->uNumBands
++;
3245 TRACE("index %u!\n", uIndex
);
3247 /* initialize band (infoPtr->bands[uIndex])*/
3248 lpBand
= &infoPtr
->bands
[uIndex
];
3250 lpBand
->fStatus
= 0;
3251 lpBand
->clrFore
= infoPtr
->clrText
;
3252 lpBand
->clrBack
= infoPtr
->clrBk
;
3253 lpBand
->hwndChild
= 0;
3254 lpBand
->hwndPrevParent
= 0;
3256 REBAR_CommonSetupBand (infoPtr
->hwndSelf
, (LPREBARBANDINFOA
)lprbbi
, lpBand
);
3257 lpBand
->lpText
= NULL
;
3258 if ((lprbbi
->fMask
& RBBIM_TEXT
) && (lprbbi
->lpText
)) {
3259 INT len
= lstrlenW (lprbbi
->lpText
);
3261 lpBand
->lpText
= (LPWSTR
)Alloc ((len
+ 1)*sizeof(WCHAR
));
3262 strcpyW (lpBand
->lpText
, lprbbi
->lpText
);
3266 REBAR_ValidateBand (infoPtr
, lpBand
);
3267 /* On insert of second band, revalidate band 1 to possible add gripper */
3268 if (infoPtr
->uNumBands
== 2)
3269 REBAR_ValidateBand (infoPtr
, &infoPtr
->bands
[uIndex
? 0 : 1]);
3271 REBAR_DumpBand (infoPtr
);
3273 REBAR_Layout (infoPtr
, NULL
, TRUE
, FALSE
);
3274 InvalidateRect(infoPtr
->hwndSelf
, 0, 1);
3281 REBAR_MaximizeBand (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
3284 UINT uBand
= (UINT
) wParam
;
3287 if ((infoPtr
->uNumBands
== 0) ||
3288 ((INT
)uBand
< 0) || (uBand
>= infoPtr
->uNumBands
)) {
3290 ERR("Illegal MaximizeBand, requested=%d, current band count=%d\n",
3291 (INT
)uBand
, infoPtr
->uNumBands
);
3295 lpBand
= &infoPtr
->bands
[uBand
];
3297 if (lParam
&& (lpBand
->fMask
& RBBIM_IDEALSIZE
)) {
3298 /* handle setting ideal size */
3299 lpBand
->ccx
= lpBand
->cxIdeal
;
3302 /* handle setting to max */
3303 FIXME("(uBand = %u fIdeal = %s) case not coded\n",
3304 (UINT
)wParam
, lParam
? "TRUE" : "FALSE");
3308 infoPtr
->fStatus
|= BAND_NEEDS_LAYOUT
;
3309 REBAR_Layout (infoPtr
, 0, TRUE
, TRUE
);
3310 InvalidateRect (infoPtr
->hwndSelf
, 0, TRUE
);
3318 REBAR_MinimizeBand (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
3320 REBAR_BAND
*band
, *lpBand
;
3321 UINT uBand
= (UINT
) wParam
;
3323 INT imindBand
, imaxdBand
, iprevBand
, startBand
, endBand
;
3326 /* A "minimize" band is equivalent to "dragging" the gripper
3327 * of than band to the right till the band is only the size
3332 if ((infoPtr
->uNumBands
== 0) ||
3333 ((INT
)uBand
< 0) || (uBand
>= infoPtr
->uNumBands
)) {
3335 ERR("Illegal MinimizeBand, requested=%d, current band count=%d\n",
3336 (INT
)uBand
, infoPtr
->uNumBands
);
3340 /* compute amount of movement and validate */
3341 lpBand
= &infoPtr
->bands
[uBand
];
3343 if (infoPtr
->dwStyle
& CCS_VERT
)
3344 movement
= lpBand
->rcBand
.bottom
- lpBand
->rcBand
.top
-
3347 movement
= lpBand
->rcBand
.right
- lpBand
->rcBand
.left
-
3350 ERR("something is wrong, band=(%ld,%ld)-(%ld,%ld), cxheader=%d\n",
3351 lpBand
->rcBand
.left
, lpBand
->rcBand
.top
,
3352 lpBand
->rcBand
.right
, lpBand
->rcBand
.bottom
,
3359 iprevBand
= -1; /* to suppress warning message */
3361 /* find the first band in row of the one whose is being minimized */
3362 for (i
=0; i
<infoPtr
->uNumBands
; i
++) {
3363 band
= &infoPtr
->bands
[i
];
3364 if (HIDDENBAND(band
)) continue;
3365 if (band
->iRow
== lpBand
->iRow
) {
3367 if (imindBand
== -1) imindBand
= i
;
3371 /* if the selected band is first in row then need to expand */
3372 /* next visible band */
3373 if (imindBand
== uBand
) {
3375 movement
= -movement
;
3376 /* find the first visible band to the right of the selected band */
3377 for (i
=uBand
+1; i
<=imaxdBand
; i
++) {
3378 band
= &infoPtr
->bands
[i
];
3379 if (!HIDDENBAND(band
)) {
3381 LEADJ(band
, movement
);
3382 band
->ccx
= rcBw(band
);
3386 /* what case is this */
3387 if (iprevBand
== -1) {
3388 ERR("no previous visible band\n");
3392 endBand
= iprevBand
;
3394 lpBand
->rcBand
.left
,
3397 band
->rcBand
.bottom
);
3399 /* otherwise expand previous visible band */
3402 /* find the first visible band to the left of the selected band */
3403 for (i
=uBand
-1; i
>=imindBand
; i
--) {
3404 band
= &infoPtr
->bands
[i
];
3405 if (!HIDDENBAND(band
)) {
3407 READJ(band
, movement
);
3408 band
->ccx
= rcBw(band
);
3412 /* what case is this */
3413 if (iprevBand
== -1) {
3414 ERR("no previous visible band\n");
3417 startBand
= iprevBand
;
3422 lpBand
->rcBand
.right
,
3423 lpBand
->rcBand
.bottom
);
3426 REBAR_Shrink (infoPtr
, lpBand
, movement
, uBand
);
3428 /* recompute all rectangles */
3429 if (infoPtr
->dwStyle
& CCS_VERT
) {
3430 REBAR_CalcVertBand (infoPtr
, startBand
, endBand
+1,
3434 REBAR_CalcHorzBand (infoPtr
, startBand
, endBand
+1,
3438 TRACE("bands after minimize, see band # %d, %d\n",
3439 startBand
, endBand
);
3440 REBAR_DumpBand (infoPtr
);
3442 REBAR_MoveChildWindows (infoPtr
, startBand
, endBand
+1);
3444 InvalidateRect (infoPtr
->hwndSelf
, &newrect
, TRUE
);
3445 UpdateWindow (infoPtr
->hwndSelf
);
3451 REBAR_MoveBand (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
3453 REBAR_BAND
*oldBands
= infoPtr
->bands
;
3455 UINT uFrom
= (UINT
)wParam
;
3456 UINT uTo
= (UINT
)lParam
;
3459 if ((infoPtr
->uNumBands
== 0) ||
3460 ((INT
)uFrom
< 0) || (uFrom
>= infoPtr
->uNumBands
) ||
3461 ((INT
)uTo
< 0) || (uTo
>= infoPtr
->uNumBands
)) {
3463 ERR("Illegal MoveBand, from=%d, to=%d, current band count=%d\n",
3464 (INT
)uFrom
, (INT
)uTo
, infoPtr
->uNumBands
);
3468 /* save one to be moved */
3469 memcpy (&holder
, &oldBands
[uFrom
], sizeof(REBAR_BAND
));
3471 /* close up rest of bands (pseudo delete) */
3472 if (uFrom
< infoPtr
->uNumBands
- 1) {
3473 memcpy (&oldBands
[uFrom
], &oldBands
[uFrom
+1],
3474 (infoPtr
->uNumBands
- uFrom
- 1) * sizeof(REBAR_BAND
));
3477 /* allocate new space and copy rest of bands into it */
3479 (REBAR_BAND
*)Alloc ((infoPtr
->uNumBands
)*sizeof(REBAR_BAND
));
3481 /* pre insert copy */
3483 memcpy (&infoPtr
->bands
[0], &oldBands
[0],
3484 uTo
* sizeof(REBAR_BAND
));
3487 /* set moved band */
3488 memcpy (&infoPtr
->bands
[uTo
], &holder
, sizeof(REBAR_BAND
));
3491 if (uTo
< infoPtr
->uNumBands
- 1) {
3492 memcpy (&infoPtr
->bands
[uTo
+1], &oldBands
[uTo
],
3493 (infoPtr
->uNumBands
- uTo
- 1) * sizeof(REBAR_BAND
));
3498 TRACE("moved band %d to index %d\n", uFrom
, uTo
);
3499 REBAR_DumpBand (infoPtr
);
3501 infoPtr
->fStatus
|= BAND_NEEDS_LAYOUT
;
3502 /* **************************************************** */
3504 /* We do not do a REBAR_Layout here because the native */
3505 /* control does not do that. The actual layout and */
3506 /* repaint is done by the *next* real action, ex.: */
3507 /* RB_INSERTBAND, RB_DELETEBAND, RB_SIZETORECT, etc. */
3509 /* **************************************************** */
3515 /* return TRUE if two strings are different */
3517 REBAR_strdifW( LPCWSTR a
, LPCWSTR b
)
3519 return ( (a
&& !b
) || (b
&& !a
) || (a
&& b
&& lstrcmpW(a
, b
) ) );
3523 REBAR_SetBandInfoA (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
3525 LPREBARBANDINFOA lprbbi
= (LPREBARBANDINFOA
)lParam
;
3531 if (lprbbi
->cbSize
< REBARBANDINFOA_V3_SIZE
)
3533 if ((UINT
)wParam
>= infoPtr
->uNumBands
)
3536 TRACE("index %u\n", (UINT
)wParam
);
3537 REBAR_DumpBandInfo (lprbbi
);
3539 /* set band information */
3540 lpBand
= &infoPtr
->bands
[(UINT
)wParam
];
3542 bChanged
= REBAR_CommonSetupBand (infoPtr
->hwndSelf
, lprbbi
, lpBand
);
3543 if (lprbbi
->fMask
& RBBIM_TEXT
) {
3549 len
= MultiByteToWideChar( CP_ACP
, 0, lprbbi
->lpText
, -1, NULL
, 0 );
3551 wstr
= (LPWSTR
)Alloc (len
*sizeof(WCHAR
));
3553 MultiByteToWideChar( CP_ACP
, 0, lprbbi
->lpText
, -1, wstr
, len
);
3555 if (REBAR_strdifW(lpBand
->lpText
, wstr
)) {
3556 if (lpBand
->lpText
) {
3557 Free (lpBand
->lpText
);
3558 lpBand
->lpText
= NULL
;
3561 lpBand
->lpText
= wstr
;
3570 REBAR_ValidateBand (infoPtr
, lpBand
);
3572 REBAR_DumpBand (infoPtr
);
3574 if (bChanged
&& (lprbbi
->fMask
& (RBBIM_CHILDSIZE
| RBBIM_SIZE
))) {
3575 REBAR_Layout (infoPtr
, NULL
, TRUE
, FALSE
);
3576 InvalidateRect(infoPtr
->hwndSelf
, 0, 1);
3583 REBAR_SetBandInfoW (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
3585 LPREBARBANDINFOW lprbbi
= (LPREBARBANDINFOW
)lParam
;
3591 if (lprbbi
->cbSize
< REBARBANDINFOW_V3_SIZE
)
3593 if ((UINT
)wParam
>= infoPtr
->uNumBands
)
3596 TRACE("index %u\n", (UINT
)wParam
);
3597 REBAR_DumpBandInfo ((LPREBARBANDINFOA
)lprbbi
);
3599 /* set band information */
3600 lpBand
= &infoPtr
->bands
[(UINT
)wParam
];
3602 bChanged
= REBAR_CommonSetupBand (infoPtr
->hwndSelf
, (LPREBARBANDINFOA
)lprbbi
, lpBand
);
3603 if( (lprbbi
->fMask
& RBBIM_TEXT
) &&
3604 REBAR_strdifW( lpBand
->lpText
, lprbbi
->lpText
) ) {
3605 if (lpBand
->lpText
) {
3606 Free (lpBand
->lpText
);
3607 lpBand
->lpText
= NULL
;
3609 if (lprbbi
->lpText
) {
3610 INT len
= lstrlenW (lprbbi
->lpText
);
3613 lpBand
->lpText
= (LPWSTR
)Alloc ((len
+ 1)*sizeof(WCHAR
));
3614 strcpyW (lpBand
->lpText
, lprbbi
->lpText
);
3620 REBAR_ValidateBand (infoPtr
, lpBand
);
3622 REBAR_DumpBand (infoPtr
);
3624 if ( bChanged
&& (lprbbi
->fMask
& (RBBIM_CHILDSIZE
| RBBIM_SIZE
)) ) {
3625 REBAR_Layout (infoPtr
, NULL
, TRUE
, FALSE
);
3626 InvalidateRect(infoPtr
->hwndSelf
, 0, 1);
3634 REBAR_SetBarInfo (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
3636 LPREBARINFO lpInfo
= (LPREBARINFO
)lParam
;
3643 if (lpInfo
->cbSize
< sizeof (REBARINFO
))
3646 TRACE("setting bar info!\n");
3648 if (lpInfo
->fMask
& RBIM_IMAGELIST
) {
3649 infoPtr
->himl
= lpInfo
->himl
;
3650 if (infoPtr
->himl
) {
3652 ImageList_GetIconSize (infoPtr
->himl
, &cx
, &cy
);
3653 infoPtr
->imageSize
.cx
= cx
;
3654 infoPtr
->imageSize
.cy
= cy
;
3657 infoPtr
->imageSize
.cx
= 0;
3658 infoPtr
->imageSize
.cy
= 0;
3660 TRACE("new image cx=%ld, cy=%ld\n", infoPtr
->imageSize
.cx
,
3661 infoPtr
->imageSize
.cy
);
3664 /* revalidate all bands to reset flags for images in headers of bands */
3665 for (i
=0; i
<infoPtr
->uNumBands
; i
++) {
3666 lpBand
= &infoPtr
->bands
[i
];
3667 REBAR_ValidateBand (infoPtr
, lpBand
);
3675 REBAR_SetBkColor (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
3679 clrTemp
= infoPtr
->clrBk
;
3680 infoPtr
->clrBk
= (COLORREF
)lParam
;
3682 TRACE("background color 0x%06lx!\n", infoPtr
->clrBk
);
3688 /* << REBAR_SetColorScheme >> */
3689 /* << REBAR_SetPalette >> */
3693 REBAR_SetParent (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
3695 HWND hwndTemp
= infoPtr
->hwndNotify
;
3697 infoPtr
->hwndNotify
= (HWND
)wParam
;
3699 return (LRESULT
)hwndTemp
;
3704 REBAR_SetTextColor (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
3708 clrTemp
= infoPtr
->clrText
;
3709 infoPtr
->clrText
= (COLORREF
)lParam
;
3711 TRACE("text color 0x%06lx!\n", infoPtr
->clrText
);
3717 /* << REBAR_SetTooltips >> */
3720 inline static LRESULT
3721 REBAR_SetUnicodeFormat (REBAR_INFO
*infoPtr
, WPARAM wParam
)
3723 BOOL bTemp
= infoPtr
->bUnicode
;
3725 TRACE("to %s hwnd=%p, was %s\n",
3726 ((BOOL
)wParam
) ? "TRUE" : "FALSE", infoPtr
->hwndSelf
,
3727 (bTemp
) ? "TRUE" : "FALSE");
3729 infoPtr
->bUnicode
= (BOOL
)wParam
;
3736 REBAR_SetVersion (REBAR_INFO
*infoPtr
, INT iVersion
)
3738 INT iOldVersion
= infoPtr
->iVersion
;
3740 if (iVersion
> COMCTL32_VERSION
)
3743 infoPtr
->iVersion
= iVersion
;
3745 TRACE("new version %d\n", iVersion
);
3752 REBAR_ShowBand (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
3756 if (((INT
)wParam
< 0) || ((INT
)wParam
> infoPtr
->uNumBands
))
3759 lpBand
= &infoPtr
->bands
[(INT
)wParam
];
3762 TRACE("show band %d\n", (INT
)wParam
);
3763 lpBand
->fStyle
= lpBand
->fStyle
& ~RBBS_HIDDEN
;
3764 if (IsWindow (lpBand
->hwndChild
))
3765 ShowWindow (lpBand
->hwndChild
, SW_SHOW
);
3768 TRACE("hide band %d\n", (INT
)wParam
);
3769 lpBand
->fStyle
= lpBand
->fStyle
| RBBS_HIDDEN
;
3770 if (IsWindow (lpBand
->hwndChild
))
3771 ShowWindow (lpBand
->hwndChild
, SW_HIDE
);
3774 infoPtr
->fStatus
|= BAND_NEEDS_LAYOUT
;
3775 REBAR_Layout (infoPtr
, NULL
, TRUE
, FALSE
);
3776 InvalidateRect(infoPtr
->hwndSelf
, 0, 1);
3783 REBAR_SizeToRect (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
3785 LPRECT lpRect
= (LPRECT
)lParam
;
3791 TRACE("[%ld %ld %ld %ld]\n",
3792 lpRect
->left
, lpRect
->top
, lpRect
->right
, lpRect
->bottom
);
3794 /* what is going on???? */
3795 GetWindowRect(infoPtr
->hwndSelf
, &t1
);
3796 TRACE("window rect [%ld %ld %ld %ld]\n",
3797 t1
.left
, t1
.top
, t1
.right
, t1
.bottom
);
3798 GetClientRect(infoPtr
->hwndSelf
, &t1
);
3799 TRACE("client rect [%ld %ld %ld %ld]\n",
3800 t1
.left
, t1
.top
, t1
.right
, t1
.bottom
);
3802 /* force full _Layout processing */
3803 TRACE("setting NEEDS_LAYOUT\n");
3804 infoPtr
->fStatus
|= BAND_NEEDS_LAYOUT
;
3805 REBAR_Layout (infoPtr
, lpRect
, TRUE
, FALSE
);
3806 InvalidateRect (infoPtr
->hwndSelf
, NULL
, TRUE
);
3813 REBAR_Create (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
3815 LPCREATESTRUCTW cs
= (LPCREATESTRUCTW
) lParam
;
3819 if (TRACE_ON(rebar
)) {
3820 GetWindowRect(infoPtr
->hwndSelf
, &wnrc1
);
3821 GetClientRect(infoPtr
->hwndSelf
, &clrc1
);
3822 TRACE("window=(%ld,%ld)-(%ld,%ld) client=(%ld,%ld)-(%ld,%ld) cs=(%d,%d %dx%d)\n",
3823 wnrc1
.left
, wnrc1
.top
, wnrc1
.right
, wnrc1
.bottom
,
3824 clrc1
.left
, clrc1
.top
, clrc1
.right
, clrc1
.bottom
,
3825 cs
->x
, cs
->y
, cs
->cx
, cs
->cy
);
3828 TRACE("created!\n");
3830 if ((theme
= OpenThemeData (infoPtr
->hwndSelf
, themeClass
)))
3832 /* native seems to clear WS_BORDER when themed */
3833 infoPtr
->dwStyle
&= ~WS_BORDER
;
3841 REBAR_Destroy (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
3847 /* free rebar bands */
3848 if ((infoPtr
->uNumBands
> 0) && infoPtr
->bands
) {
3849 /* clean up each band */
3850 for (i
= 0; i
< infoPtr
->uNumBands
; i
++) {
3851 lpBand
= &infoPtr
->bands
[i
];
3853 /* delete text strings */
3854 if (lpBand
->lpText
) {
3855 Free (lpBand
->lpText
);
3856 lpBand
->lpText
= NULL
;
3858 /* destroy child window */
3859 DestroyWindow (lpBand
->hwndChild
);
3862 /* free band array */
3863 Free (infoPtr
->bands
);
3864 infoPtr
->bands
= NULL
;
3867 DestroyCursor (infoPtr
->hcurArrow
);
3868 DestroyCursor (infoPtr
->hcurHorz
);
3869 DestroyCursor (infoPtr
->hcurVert
);
3870 DestroyCursor (infoPtr
->hcurDrag
);
3871 if(infoPtr
->hDefaultFont
) DeleteObject (infoPtr
->hDefaultFont
);
3872 SetWindowLongPtrW (infoPtr
->hwndSelf
, 0, 0);
3874 CloseThemeData (GetWindowTheme (infoPtr
->hwndSelf
));
3876 /* free rebar info data */
3878 TRACE("destroyed!\n");
3884 REBAR_EraseBkGnd (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
3888 if (GetClipBox ( (HDC
)wParam
, &cliprect
))
3889 return REBAR_InternalEraseBkGnd (infoPtr
, wParam
, lParam
, &cliprect
);
3895 REBAR_GetFont (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
3897 return (LRESULT
)infoPtr
->hFont
;
3901 REBAR_PushChevron(REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
3903 if (wParam
>= 0 && (UINT
)wParam
< infoPtr
->uNumBands
)
3905 NMREBARCHEVRON nmrbc
;
3906 REBAR_BAND
*lpBand
= &infoPtr
->bands
[wParam
];
3908 TRACE("Pressed chevron on band %d\n", wParam
);
3910 /* redraw chevron in pushed state */
3911 lpBand
->fDraw
|= DRAW_CHEVRONPUSHED
;
3912 RedrawWindow(infoPtr
->hwndSelf
, &lpBand
->rcChevron
,0,
3913 RDW_ERASE
|RDW_INVALIDATE
|RDW_UPDATENOW
);
3915 /* notify app so it can display a popup menu or whatever */
3916 nmrbc
.uBand
= wParam
;
3917 nmrbc
.wID
= lpBand
->wID
;
3918 nmrbc
.lParam
= lpBand
->lParam
;
3919 nmrbc
.rc
= lpBand
->rcChevron
;
3920 nmrbc
.lParamNM
= lParam
;
3921 REBAR_Notify((NMHDR
*)&nmrbc
, infoPtr
, RBN_CHEVRONPUSHED
);
3923 /* redraw chevron in previous state */
3924 lpBand
->fDraw
&= ~DRAW_CHEVRONPUSHED
;
3925 InvalidateRect(infoPtr
->hwndSelf
, &lpBand
->rcChevron
, TRUE
);
3933 REBAR_LButtonDown (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
3939 ptMouseDown
.x
= (INT
)LOWORD(lParam
);
3940 ptMouseDown
.y
= (INT
)HIWORD(lParam
);
3942 REBAR_InternalHitTest(infoPtr
, &ptMouseDown
, &htFlags
, &iHitBand
);
3943 lpBand
= &infoPtr
->bands
[iHitBand
];
3945 if (htFlags
== RBHT_CHEVRON
)
3947 REBAR_PushChevron(infoPtr
, iHitBand
, 0);
3949 else if (htFlags
== RBHT_GRABBER
|| htFlags
== RBHT_CAPTION
)
3951 TRACE("Starting drag\n");
3953 SetCapture (infoPtr
->hwndSelf
);
3954 infoPtr
->iGrabbedBand
= iHitBand
;
3956 /* save off the LOWORD and HIWORD of lParam as initial x,y */
3957 infoPtr
->dragStart
.x
= (short)LOWORD(lParam
);
3958 infoPtr
->dragStart
.y
= (short)HIWORD(lParam
);
3959 infoPtr
->dragNow
= infoPtr
->dragStart
;
3960 if (infoPtr
->dwStyle
& CCS_VERT
)
3961 infoPtr
->ihitoffset
= infoPtr
->dragStart
.y
- (lpBand
->rcBand
.top
+REBAR_PRE_GRIPPER
);
3963 infoPtr
->ihitoffset
= infoPtr
->dragStart
.x
- (lpBand
->rcBand
.left
+REBAR_PRE_GRIPPER
);
3969 REBAR_LButtonUp (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
3971 if (infoPtr
->iGrabbedBand
>= 0)
3976 infoPtr
->dragStart
.x
= 0;
3977 infoPtr
->dragStart
.y
= 0;
3978 infoPtr
->dragNow
= infoPtr
->dragStart
;
3982 if (infoPtr
->fStatus
& BEGIN_DRAG_ISSUED
) {
3983 REBAR_Notify(&layout
, infoPtr
, RBN_LAYOUTCHANGED
);
3984 REBAR_Notify_NMREBAR (infoPtr
, infoPtr
->iGrabbedBand
, RBN_ENDDRAG
);
3985 infoPtr
->fStatus
&= ~BEGIN_DRAG_ISSUED
;
3988 infoPtr
->iGrabbedBand
= -1;
3990 GetClientRect(infoPtr
->hwndSelf
, &rect
);
3991 InvalidateRect(infoPtr
->hwndSelf
, NULL
, TRUE
);
3998 REBAR_MouseLeave (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
4000 if (infoPtr
->ichevronhotBand
>= 0)
4002 REBAR_BAND
*lpChevronBand
= &infoPtr
->bands
[infoPtr
->ichevronhotBand
];
4003 if (lpChevronBand
->fDraw
& DRAW_CHEVRONHOT
)
4005 lpChevronBand
->fDraw
&= ~DRAW_CHEVRONHOT
;
4006 InvalidateRect(infoPtr
->hwndSelf
, &lpChevronBand
->rcChevron
, TRUE
);
4009 infoPtr
->iOldBand
= -1;
4010 infoPtr
->ichevronhotBand
= -2;
4016 REBAR_MouseMove (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
4018 REBAR_BAND
*lpChevronBand
;
4021 ptMove
.x
= (short)LOWORD(lParam
);
4022 ptMove
.y
= (short)HIWORD(lParam
);
4024 /* if we are currently dragging a band */
4025 if (infoPtr
->iGrabbedBand
>= 0)
4027 REBAR_BAND
*band1
, *band2
;
4029 if (GetCapture() != infoPtr
->hwndSelf
)
4030 ERR("We are dragging but haven't got capture?!?\n");
4032 band1
= &infoPtr
->bands
[infoPtr
->iGrabbedBand
-1];
4033 band2
= &infoPtr
->bands
[infoPtr
->iGrabbedBand
];
4035 /* if mouse did not move much, exit */
4036 if ((abs(ptMove
.x
- infoPtr
->dragNow
.x
) <= mindragx
) &&
4037 (abs(ptMove
.y
- infoPtr
->dragNow
.y
) <= mindragy
)) return 0;
4039 /* Test for valid drag case - must not be first band in row */
4040 if (infoPtr
->dwStyle
& CCS_VERT
) {
4041 if ((ptMove
.x
< band2
->rcBand
.left
) ||
4042 (ptMove
.x
> band2
->rcBand
.right
) ||
4043 ((infoPtr
->iGrabbedBand
> 0) && (band1
->iRow
!= band2
->iRow
))) {
4044 FIXME("Cannot drag to other rows yet!!\n");
4047 REBAR_HandleLRDrag (infoPtr
, &ptMove
);
4051 if ((ptMove
.y
< band2
->rcBand
.top
) ||
4052 (ptMove
.y
> band2
->rcBand
.bottom
) ||
4053 ((infoPtr
->iGrabbedBand
> 0) && (band1
->iRow
!= band2
->iRow
))) {
4054 FIXME("Cannot drag to other rows yet!!\n");
4057 REBAR_HandleLRDrag (infoPtr
, &ptMove
);
4065 TRACKMOUSEEVENT trackinfo
;
4067 REBAR_InternalHitTest(infoPtr
, &ptMove
, &htFlags
, &iHitBand
);
4069 if (infoPtr
->iOldBand
>= 0 && infoPtr
->iOldBand
== infoPtr
->ichevronhotBand
)
4071 lpChevronBand
= &infoPtr
->bands
[infoPtr
->ichevronhotBand
];
4072 if (lpChevronBand
->fDraw
& DRAW_CHEVRONHOT
)
4074 lpChevronBand
->fDraw
&= ~DRAW_CHEVRONHOT
;
4075 InvalidateRect(infoPtr
->hwndSelf
, &lpChevronBand
->rcChevron
, TRUE
);
4077 infoPtr
->ichevronhotBand
= -2;
4080 if (htFlags
== RBHT_CHEVRON
)
4082 /* fill in the TRACKMOUSEEVENT struct */
4083 trackinfo
.cbSize
= sizeof(TRACKMOUSEEVENT
);
4084 trackinfo
.dwFlags
= TME_QUERY
;
4085 trackinfo
.hwndTrack
= infoPtr
->hwndSelf
;
4086 trackinfo
.dwHoverTime
= 0;
4088 /* call _TrackMouseEvent to see if we are currently tracking for this hwnd */
4089 _TrackMouseEvent(&trackinfo
);
4091 /* Make sure tracking is enabled so we receive a WM_MOUSELEAVE message */
4092 if(!(trackinfo
.dwFlags
& TME_LEAVE
))
4094 trackinfo
.dwFlags
= TME_LEAVE
; /* notify upon leaving */
4096 /* call TRACKMOUSEEVENT so we receive a WM_MOUSELEAVE message */
4097 /* and can properly deactivate the hot chevron */
4098 _TrackMouseEvent(&trackinfo
);
4101 lpChevronBand
= &infoPtr
->bands
[iHitBand
];
4102 if (!(lpChevronBand
->fDraw
& DRAW_CHEVRONHOT
))
4104 lpChevronBand
->fDraw
|= DRAW_CHEVRONHOT
;
4105 InvalidateRect(infoPtr
->hwndSelf
, &lpChevronBand
->rcChevron
, TRUE
);
4106 infoPtr
->ichevronhotBand
= iHitBand
;
4109 infoPtr
->iOldBand
= iHitBand
;
4116 inline static LRESULT
4117 REBAR_NCCalcSize (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
4120 if (infoPtr
->dwStyle
& WS_BORDER
) {
4121 InflateRect((LPRECT
)lParam
, -GetSystemMetrics(SM_CXEDGE
),
4122 -GetSystemMetrics(SM_CYEDGE
));
4124 else if ((theme
= GetWindowTheme (infoPtr
->hwndSelf
)))
4126 ((LPRECT
)lParam
)->top
++;
4128 TRACE("new client=(%ld,%ld)-(%ld,%ld)\n",
4129 ((LPRECT
)lParam
)->left
, ((LPRECT
)lParam
)->top
,
4130 ((LPRECT
)lParam
)->right
, ((LPRECT
)lParam
)->bottom
);
4136 REBAR_NCCreate (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4138 LPCREATESTRUCTW cs
= (LPCREATESTRUCTW
) lParam
;
4139 REBAR_INFO
*infoPtr
= REBAR_GetInfoPtr (hwnd
);
4141 NONCLIENTMETRICSW ncm
;
4145 if (infoPtr
!= NULL
) {
4146 ERR("Strange info structure pointer *not* NULL\n");
4150 if (TRACE_ON(rebar
)) {
4151 GetWindowRect(hwnd
, &wnrc1
);
4152 GetClientRect(hwnd
, &clrc1
);
4153 TRACE("window=(%ld,%ld)-(%ld,%ld) client=(%ld,%ld)-(%ld,%ld) cs=(%d,%d %dx%d)\n",
4154 wnrc1
.left
, wnrc1
.top
, wnrc1
.right
, wnrc1
.bottom
,
4155 clrc1
.left
, clrc1
.top
, clrc1
.right
, clrc1
.bottom
,
4156 cs
->x
, cs
->y
, cs
->cx
, cs
->cy
);
4159 /* allocate memory for info structure */
4160 infoPtr
= (REBAR_INFO
*)Alloc (sizeof(REBAR_INFO
));
4161 SetWindowLongPtrW (hwnd
, 0, (DWORD_PTR
)infoPtr
);
4163 /* initialize info structure - initial values are 0 */
4164 infoPtr
->clrBk
= CLR_NONE
;
4165 infoPtr
->clrText
= CLR_NONE
;
4166 infoPtr
->clrBtnText
= GetSysColor (COLOR_BTNTEXT
);
4167 infoPtr
->clrBtnFace
= GetSysColor (COLOR_BTNFACE
);
4168 infoPtr
->iOldBand
= -1;
4169 infoPtr
->ichevronhotBand
= -2;
4170 infoPtr
->iGrabbedBand
= -1;
4171 infoPtr
->hwndSelf
= hwnd
;
4172 infoPtr
->DoRedraw
= TRUE
;
4173 infoPtr
->hcurArrow
= LoadCursorW (0, (LPWSTR
)IDC_ARROW
);
4174 infoPtr
->hcurHorz
= LoadCursorW (0, (LPWSTR
)IDC_SIZEWE
);
4175 infoPtr
->hcurVert
= LoadCursorW (0, (LPWSTR
)IDC_SIZENS
);
4176 infoPtr
->hcurDrag
= LoadCursorW (0, (LPWSTR
)IDC_SIZE
);
4177 infoPtr
->bUnicode
= IsWindowUnicode (hwnd
);
4178 infoPtr
->fStatus
= CREATE_RUNNING
;
4179 infoPtr
->hFont
= GetStockObject (SYSTEM_FONT
);
4181 /* issue WM_NOTIFYFORMAT to get unicode status of parent */
4182 i
= SendMessageW(REBAR_GetNotifyParent (infoPtr
),
4183 WM_NOTIFYFORMAT
, (WPARAM
)hwnd
, NF_QUERY
);
4184 if ((i
< NFR_ANSI
) || (i
> NFR_UNICODE
)) {
4185 ERR("wrong response to WM_NOTIFYFORMAT (%d), assuming ANSI\n", i
);
4188 infoPtr
->NtfUnicode
= (i
== NFR_UNICODE
) ? 1 : 0;
4190 /* Stow away the original style */
4191 infoPtr
->orgStyle
= cs
->style
;
4192 /* add necessary styles to the requested styles */
4193 infoPtr
->dwStyle
= cs
->style
| WS_VISIBLE
| CCS_TOP
;
4194 SetWindowLongW (hwnd
, GWL_STYLE
, infoPtr
->dwStyle
);
4196 /* get font handle for Caption Font */
4197 ncm
.cbSize
= sizeof(ncm
);
4198 SystemParametersInfoW (SPI_GETNONCLIENTMETRICS
, ncm
.cbSize
, &ncm
, 0);
4199 /* if the font is bold, set to normal */
4200 if (ncm
.lfCaptionFont
.lfWeight
> FW_NORMAL
) {
4201 ncm
.lfCaptionFont
.lfWeight
= FW_NORMAL
;
4203 tfont
= CreateFontIndirectW (&ncm
.lfCaptionFont
);
4205 infoPtr
->hFont
= infoPtr
->hDefaultFont
= tfont
;
4209 GetSysColor (numerous);
4210 GetSysColorBrush (numerous) (see WM_SYSCOLORCHANGE);
4211 *GetStockObject (SYSTEM_FONT);
4212 *SetWindowLong (hwnd, 0, info ptr);
4214 *SetWindowLong (hwnd, GWL_STYLE, style+0x10000001);
4215 WS_VISIBLE = 0x10000000;
4216 CCS_TOP = 0x00000001;
4217 *SystemParametersInfo (SPI_GETNONCLIENTMETRICS...);
4218 *CreateFontIndirect (lfCaptionFont from above);
4220 SelectObject (hdc, fontabove);
4221 GetTextMetrics (hdc, ); guessing is tmHeight
4222 SelectObject (hdc, oldfont);
4225 MapWindowPoints (0, parent, rectabove, 2);
4228 ClientToScreen (clientrect);
4229 SetWindowPos (hwnd, 0, 0, 0, 0, 0, SWP_NOZORDER);
4236 REBAR_NCHitTest (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
4242 LRESULT ret
= HTCLIENT
;
4245 * Differences from doc at MSDN (as observed with version 4.71 of
4247 * 1. doc says nmmouse.pt is in screen coord, trace shows client coord.
4248 * 2. if band is not identified .dwItemSpec is 0xffffffff.
4249 * 3. native always seems to return HTCLIENT if notify return is 0.
4252 clpt
.x
= (short)LOWORD(lParam
);
4253 clpt
.y
= (short)HIWORD(lParam
);
4254 ScreenToClient (infoPtr
->hwndSelf
, &clpt
);
4255 REBAR_InternalHitTest (infoPtr
, &clpt
, &scrap
,
4256 (INT
*)&nmmouse
.dwItemSpec
);
4257 nmmouse
.dwItemData
= 0;
4259 nmmouse
.dwHitInfo
= 0;
4260 if ((i
= REBAR_Notify((NMHDR
*) &nmmouse
, infoPtr
, NM_NCHITTEST
))) {
4261 TRACE("notify changed return value from %ld to %d\n",
4265 TRACE("returning %ld, client point (%ld,%ld)\n", ret
, clpt
.x
, clpt
.y
);
4271 REBAR_NCPaint (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
4277 if (infoPtr
->dwStyle
& WS_MINIMIZE
)
4278 return 0; /* Nothing to do */
4280 if (infoPtr
->dwStyle
& WS_BORDER
) {
4282 /* adjust rectangle and draw the necessary edge */
4283 if (!(hdc
= GetDCEx( infoPtr
->hwndSelf
, 0, DCX_USESTYLE
| DCX_WINDOW
)))
4285 GetWindowRect (infoPtr
->hwndSelf
, &rcWindow
);
4286 OffsetRect (&rcWindow
, -rcWindow
.left
, -rcWindow
.top
);
4287 TRACE("rect (%ld,%ld)-(%ld,%ld)\n",
4288 rcWindow
.left
, rcWindow
.top
,
4289 rcWindow
.right
, rcWindow
.bottom
);
4290 DrawEdge (hdc
, &rcWindow
, EDGE_ETCHED
, BF_RECT
);
4291 ReleaseDC( infoPtr
->hwndSelf
, hdc
);
4293 else if ((theme
= GetWindowTheme (infoPtr
->hwndSelf
)))
4295 /* adjust rectangle and draw the necessary edge */
4296 if (!(hdc
= GetDCEx( infoPtr
->hwndSelf
, 0, DCX_USESTYLE
| DCX_WINDOW
)))
4298 GetWindowRect (infoPtr
->hwndSelf
, &rcWindow
);
4299 OffsetRect (&rcWindow
, -rcWindow
.left
, -rcWindow
.top
);
4300 TRACE("rect (%ld,%ld)-(%ld,%ld)\n",
4301 rcWindow
.left
, rcWindow
.top
,
4302 rcWindow
.right
, rcWindow
.bottom
);
4303 DrawThemeEdge (theme
, hdc
, 0, 0, &rcWindow
, BDR_RAISEDINNER
, BF_TOP
, NULL
);
4304 ReleaseDC( infoPtr
->hwndSelf
, hdc
);
4312 REBAR_NotifyFormat (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
4316 if (lParam
== NF_REQUERY
) {
4317 i
= SendMessageW(REBAR_GetNotifyParent (infoPtr
),
4318 WM_NOTIFYFORMAT
, (WPARAM
)infoPtr
->hwndSelf
, NF_QUERY
);
4319 if ((i
< NFR_ANSI
) || (i
> NFR_UNICODE
)) {
4320 ERR("wrong response to WM_NOTIFYFORMAT (%d), assuming ANSI\n", i
);
4323 infoPtr
->NtfUnicode
= (i
== NFR_UNICODE
) ? 1 : 0;
4326 return (LRESULT
)((infoPtr
->bUnicode
) ? NFR_UNICODE
: NFR_ANSI
);
4331 REBAR_Paint (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
4337 GetClientRect(infoPtr
->hwndSelf
, &rc
);
4338 hdc
= wParam
==0 ? BeginPaint (infoPtr
->hwndSelf
, &ps
) : (HDC
)wParam
;
4340 TRACE("painting (%ld,%ld)-(%ld,%ld) client (%ld,%ld)-(%ld,%ld)\n",
4341 ps
.rcPaint
.left
, ps
.rcPaint
.top
,
4342 ps
.rcPaint
.right
, ps
.rcPaint
.bottom
,
4343 rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
4346 /* Erase area of paint if requested */
4347 REBAR_InternalEraseBkGnd (infoPtr
, wParam
, lParam
, &ps
.rcPaint
);
4350 REBAR_Refresh (infoPtr
, hdc
);
4352 EndPaint (infoPtr
->hwndSelf
, &ps
);
4358 REBAR_SetCursor (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
4363 TRACE("code=0x%X id=0x%X\n", LOWORD(lParam
), HIWORD(lParam
));
4366 ScreenToClient (infoPtr
->hwndSelf
, &pt
);
4368 REBAR_InternalHitTest (infoPtr
, &pt
, &flags
, NULL
);
4370 if (flags
== RBHT_GRABBER
) {
4371 if ((infoPtr
->dwStyle
& CCS_VERT
) &&
4372 !(infoPtr
->dwStyle
& RBS_VERTICALGRIPPER
))
4373 SetCursor (infoPtr
->hcurVert
);
4375 SetCursor (infoPtr
->hcurHorz
);
4377 else if (flags
!= RBHT_CLIENT
)
4378 SetCursor (infoPtr
->hcurArrow
);
4385 REBAR_SetFont (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
4391 infoPtr
->hFont
= (HFONT
)wParam
;
4393 /* revalidate all bands to change sizes of text in headers of bands */
4394 for (i
=0; i
<infoPtr
->uNumBands
; i
++) {
4395 lpBand
= &infoPtr
->bands
[i
];
4396 REBAR_ValidateBand (infoPtr
, lpBand
);
4400 if (LOWORD(lParam
)) {
4401 GetClientRect (infoPtr
->hwndSelf
, &rcClient
);
4402 REBAR_Layout (infoPtr
, &rcClient
, FALSE
, TRUE
);
4409 inline static LRESULT
4410 REBAR_SetRedraw (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
4411 /*****************************************************
4414 * Handles the WM_SETREDRAW message.
4417 * According to testing V4.71 of COMCTL32 returns the
4418 * *previous* status of the redraw flag (either 0 or -1)
4419 * instead of the MSDN documented value of 0 if handled
4421 *****************************************************/
4423 BOOL oldredraw
= infoPtr
->DoRedraw
;
4425 TRACE("set to %s, fStatus=%08x\n",
4426 (wParam
) ? "TRUE" : "FALSE", infoPtr
->fStatus
);
4427 infoPtr
->DoRedraw
= (BOOL
) wParam
;
4429 if (infoPtr
->fStatus
& BAND_NEEDS_REDRAW
) {
4430 REBAR_MoveChildWindows (infoPtr
, 0, infoPtr
->uNumBands
);
4431 REBAR_ForceResize (infoPtr
);
4432 InvalidateRect (infoPtr
->hwndSelf
, 0, TRUE
);
4434 infoPtr
->fStatus
&= ~BAND_NEEDS_REDRAW
;
4436 return (oldredraw
) ? -1 : 0;
4441 REBAR_Size (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
4445 /* auto resize deadlock check */
4446 if (infoPtr
->fStatus
& AUTO_RESIZE
) {
4447 infoPtr
->fStatus
&= ~AUTO_RESIZE
;
4448 TRACE("AUTO_RESIZE was set, reset, fStatus=%08x lparam=%08lx\n",
4449 infoPtr
->fStatus
, lParam
);
4453 if (infoPtr
->fStatus
& CREATE_RUNNING
) {
4454 /* still in CreateWindow */
4457 if ((INT
)wParam
!= SIZE_RESTORED
) {
4458 ERR("WM_SIZE in create and flags=%08x, lParam=%08lx\n",
4462 TRACE("still in CreateWindow\n");
4463 infoPtr
->fStatus
&= ~CREATE_RUNNING
;
4464 GetWindowRect ( infoPtr
->hwndSelf
, &rcWin
);
4465 TRACE("win rect (%ld,%ld)-(%ld,%ld)\n",
4466 rcWin
.left
, rcWin
.top
, rcWin
.right
, rcWin
.bottom
);
4468 if ((lParam
== 0) && (rcWin
.right
-rcWin
.left
== 0) &&
4469 (rcWin
.bottom
-rcWin
.top
== 0)) {
4470 /* native control seems to do this */
4471 GetClientRect (GetParent(infoPtr
->hwndSelf
), &rcClient
);
4472 TRACE("sizing rebar, message and client zero, parent client (%ld,%ld)\n",
4473 rcClient
.right
, rcClient
.bottom
);
4478 cx
= rcWin
.right
- rcWin
.left
;
4479 cy
= rcWin
.bottom
- rcWin
.top
;
4480 if ((cx
== LOWORD(lParam
)) && (cy
== HIWORD(lParam
))) {
4484 /* do the actual WM_SIZE request */
4485 GetClientRect (infoPtr
->hwndSelf
, &rcClient
);
4486 TRACE("sizing rebar from (%ld,%ld) to (%d,%d), client (%ld,%ld)\n",
4487 infoPtr
->calcSize
.cx
, infoPtr
->calcSize
.cy
,
4488 LOWORD(lParam
), HIWORD(lParam
),
4489 rcClient
.right
, rcClient
.bottom
);
4493 if ((INT
)wParam
!= SIZE_RESTORED
) {
4494 ERR("WM_SIZE out of create and flags=%08x, lParam=%08lx\n",
4498 /* Handle cases when outside of the CreateWindow process */
4500 GetClientRect (infoPtr
->hwndSelf
, &rcClient
);
4501 if ((lParam
== 0) && (rcClient
.right
+ rcClient
.bottom
!= 0) &&
4502 (infoPtr
->dwStyle
& RBS_AUTOSIZE
)) {
4503 /* on a WM_SIZE to zero and current client not zero and AUTOSIZE */
4504 /* native seems to use the current client rect for the size */
4505 infoPtr
->fStatus
|= BAND_NEEDS_LAYOUT
;
4506 TRACE("sizing rebar to client (%ld,%ld) size is zero but AUTOSIZE set\n",
4507 rcClient
.right
, rcClient
.bottom
);
4510 TRACE("sizing rebar from (%ld,%ld) to (%d,%d), client (%ld,%ld)\n",
4511 infoPtr
->calcSize
.cx
, infoPtr
->calcSize
.cy
,
4512 LOWORD(lParam
), HIWORD(lParam
),
4513 rcClient
.right
, rcClient
.bottom
);
4517 if (infoPtr
->dwStyle
& RBS_AUTOSIZE
) {
4518 NMRBAUTOSIZE autosize
;
4520 GetClientRect(infoPtr
->hwndSelf
, &autosize
.rcTarget
);
4521 autosize
.fChanged
= 0; /* ??? */
4522 autosize
.rcActual
= autosize
.rcTarget
; /* ??? */
4523 REBAR_Notify((NMHDR
*) &autosize
, infoPtr
, RBN_AUTOSIZE
);
4524 TRACE("RBN_AUTOSIZE client=(%ld,%ld), lp=%08lx\n",
4525 autosize
.rcTarget
.right
, autosize
.rcTarget
.bottom
, lParam
);
4528 if ((infoPtr
->calcSize
.cx
!= rcClient
.right
) ||
4529 (infoPtr
->calcSize
.cy
!= rcClient
.bottom
))
4530 infoPtr
->fStatus
|= BAND_NEEDS_LAYOUT
;
4532 REBAR_Layout (infoPtr
, &rcClient
, TRUE
, TRUE
);
4539 REBAR_StyleChanged (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
4541 STYLESTRUCT
*ss
= (STYLESTRUCT
*)lParam
;
4543 TRACE("current style=%08lx, styleOld=%08lx, style being set to=%08lx\n",
4544 infoPtr
->dwStyle
, ss
->styleOld
, ss
->styleNew
);
4545 infoPtr
->orgStyle
= infoPtr
->dwStyle
= ss
->styleNew
;
4546 if (GetWindowTheme (infoPtr
->hwndSelf
))
4547 infoPtr
->dwStyle
&= ~WS_BORDER
;
4552 /* update theme after a WM_THEMECHANGED message */
4553 static LRESULT
theme_changed (REBAR_INFO
* infoPtr
)
4555 HTHEME theme
= GetWindowTheme (infoPtr
->hwndSelf
);
4556 CloseThemeData (theme
);
4557 theme
= OpenThemeData (infoPtr
->hwndSelf
, themeClass
);
4558 /* WS_BORDER disappears when theming is enabled and reappears when
4560 infoPtr
->dwStyle
&= ~WS_BORDER
;
4561 infoPtr
->dwStyle
|= theme
? 0 : (infoPtr
->orgStyle
& WS_BORDER
);
4566 REBAR_WindowPosChanged (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
4568 WINDOWPOS
*lpwp
= (WINDOWPOS
*)lParam
;
4572 /* Save the new origin of this window - used by _ForceResize */
4573 infoPtr
->origin
.x
= lpwp
->x
;
4574 infoPtr
->origin
.y
= lpwp
->y
;
4575 ret
= DefWindowProcW(infoPtr
->hwndSelf
, WM_WINDOWPOSCHANGED
,
4577 GetWindowRect(infoPtr
->hwndSelf
, &rc
);
4578 TRACE("hwnd %p new pos (%ld,%ld)-(%ld,%ld)\n",
4579 infoPtr
->hwndSelf
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
4584 static LRESULT WINAPI
4585 REBAR_WindowProc (HWND hwnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
)
4587 REBAR_INFO
*infoPtr
= REBAR_GetInfoPtr (hwnd
);
4589 TRACE("hwnd=%p msg=%x wparam=%x lparam=%lx\n",
4590 hwnd
, uMsg
, wParam
, lParam
);
4591 if (!infoPtr
&& (uMsg
!= WM_NCCREATE
))
4592 return DefWindowProcW (hwnd
, uMsg
, wParam
, lParam
);
4595 /* case RB_BEGINDRAG: */
4598 return REBAR_DeleteBand (infoPtr
, wParam
, lParam
);
4600 /* case RB_DRAGMOVE: */
4601 /* case RB_ENDDRAG: */
4603 case RB_GETBANDBORDERS
:
4604 return REBAR_GetBandBorders (infoPtr
, wParam
, lParam
);
4606 case RB_GETBANDCOUNT
:
4607 return REBAR_GetBandCount (infoPtr
);
4609 case RB_GETBANDINFO_OLD
:
4610 case RB_GETBANDINFOA
:
4611 return REBAR_GetBandInfoA (infoPtr
, wParam
, lParam
);
4613 case RB_GETBANDINFOW
:
4614 return REBAR_GetBandInfoW (infoPtr
, wParam
, lParam
);
4616 case RB_GETBARHEIGHT
:
4617 return REBAR_GetBarHeight (infoPtr
, wParam
, lParam
);
4620 return REBAR_GetBarInfo (infoPtr
, wParam
, lParam
);
4623 return REBAR_GetBkColor (infoPtr
);
4625 /* case RB_GETCOLORSCHEME: */
4626 /* case RB_GETDROPTARGET: */
4629 return REBAR_GetPalette (infoPtr
, wParam
, lParam
);
4632 return REBAR_GetRect (infoPtr
, wParam
, lParam
);
4634 case RB_GETROWCOUNT
:
4635 return REBAR_GetRowCount (infoPtr
);
4637 case RB_GETROWHEIGHT
:
4638 return REBAR_GetRowHeight (infoPtr
, wParam
, lParam
);
4640 case RB_GETTEXTCOLOR
:
4641 return REBAR_GetTextColor (infoPtr
);
4643 case RB_GETTOOLTIPS
:
4644 return REBAR_GetToolTips (infoPtr
);
4646 case RB_GETUNICODEFORMAT
:
4647 return REBAR_GetUnicodeFormat (infoPtr
);
4649 case CCM_GETVERSION
:
4650 return REBAR_GetVersion (infoPtr
);
4653 return REBAR_HitTest (infoPtr
, wParam
, lParam
);
4656 return REBAR_IdToIndex (infoPtr
, wParam
, lParam
);
4658 case RB_INSERTBANDA
:
4659 return REBAR_InsertBandA (infoPtr
, wParam
, lParam
);
4661 case RB_INSERTBANDW
:
4662 return REBAR_InsertBandW (infoPtr
, wParam
, lParam
);
4664 case RB_MAXIMIZEBAND
:
4665 return REBAR_MaximizeBand (infoPtr
, wParam
, lParam
);
4667 case RB_MINIMIZEBAND
:
4668 return REBAR_MinimizeBand (infoPtr
, wParam
, lParam
);
4671 return REBAR_MoveBand (infoPtr
, wParam
, lParam
);
4673 case RB_PUSHCHEVRON
:
4674 return REBAR_PushChevron (infoPtr
, wParam
, lParam
);
4676 case RB_SETBANDINFOA
:
4677 return REBAR_SetBandInfoA (infoPtr
, wParam
, lParam
);
4679 case RB_SETBANDINFOW
:
4680 return REBAR_SetBandInfoW (infoPtr
, wParam
, lParam
);
4683 return REBAR_SetBarInfo (infoPtr
, wParam
, lParam
);
4686 return REBAR_SetBkColor (infoPtr
, wParam
, lParam
);
4688 /* case RB_SETCOLORSCHEME: */
4689 /* case RB_SETPALETTE: */
4690 /* return REBAR_GetPalette (infoPtr, wParam, lParam); */
4693 return REBAR_SetParent (infoPtr
, wParam
, lParam
);
4695 case RB_SETTEXTCOLOR
:
4696 return REBAR_SetTextColor (infoPtr
, wParam
, lParam
);
4698 /* case RB_SETTOOLTIPS: */
4700 case RB_SETUNICODEFORMAT
:
4701 return REBAR_SetUnicodeFormat (infoPtr
, wParam
);
4703 case CCM_SETVERSION
:
4704 return REBAR_SetVersion (infoPtr
, (INT
)wParam
);
4707 return REBAR_ShowBand (infoPtr
, wParam
, lParam
);
4710 return REBAR_SizeToRect (infoPtr
, wParam
, lParam
);
4713 /* Messages passed to parent */
4717 if (infoPtr
->NtfUnicode
)
4718 return SendMessageW (REBAR_GetNotifyParent (infoPtr
),
4719 uMsg
, wParam
, lParam
);
4721 return SendMessageA (REBAR_GetNotifyParent (infoPtr
),
4722 uMsg
, wParam
, lParam
);
4725 /* case WM_CHARTOITEM: supported according to ControlSpy */
4728 return REBAR_Create (infoPtr
, wParam
, lParam
);
4731 return REBAR_Destroy (infoPtr
, wParam
, lParam
);
4734 return REBAR_EraseBkGnd (infoPtr
, wParam
, lParam
);
4737 return REBAR_GetFont (infoPtr
, wParam
, lParam
);
4739 /* case WM_LBUTTONDBLCLK: supported according to ControlSpy */
4741 case WM_LBUTTONDOWN
:
4742 return REBAR_LButtonDown (infoPtr
, wParam
, lParam
);
4745 return REBAR_LButtonUp (infoPtr
, wParam
, lParam
);
4747 /* case WM_MEASUREITEM: supported according to ControlSpy */
4750 return REBAR_MouseMove (infoPtr
, wParam
, lParam
);
4753 return REBAR_MouseLeave (infoPtr
, wParam
, lParam
);
4756 return REBAR_NCCalcSize (infoPtr
, wParam
, lParam
);
4759 return REBAR_NCCreate (hwnd
, wParam
, lParam
);
4762 return REBAR_NCHitTest (infoPtr
, wParam
, lParam
);
4765 return REBAR_NCPaint (infoPtr
, wParam
, lParam
);
4767 case WM_NOTIFYFORMAT
:
4768 return REBAR_NotifyFormat (infoPtr
, wParam
, lParam
);
4770 case WM_PRINTCLIENT
:
4772 return REBAR_Paint (infoPtr
, wParam
, lParam
);
4774 /* case WM_PALETTECHANGED: supported according to ControlSpy */
4775 /* case WM_QUERYNEWPALETTE:supported according to ControlSpy */
4776 /* case WM_RBUTTONDOWN: supported according to ControlSpy */
4777 /* case WM_RBUTTONUP: supported according to ControlSpy */
4780 return REBAR_SetCursor (infoPtr
, wParam
, lParam
);
4783 return REBAR_SetFont (infoPtr
, wParam
, lParam
);
4786 return REBAR_SetRedraw (infoPtr
, wParam
, lParam
);
4789 return REBAR_Size (infoPtr
, wParam
, lParam
);
4791 case WM_STYLECHANGED
:
4792 return REBAR_StyleChanged (infoPtr
, wParam
, lParam
);
4794 case WM_THEMECHANGED
:
4795 return theme_changed (infoPtr
);
4797 /* case WM_SYSCOLORCHANGE: supported according to ControlSpy */
4798 /* "Applications that have brushes using the existing system colors
4799 should delete those brushes and recreate them using the new
4800 system colors." per MSDN */
4802 /* case WM_VKEYTOITEM: supported according to ControlSpy */
4803 /* case WM_WININICHANGE: */
4805 case WM_WINDOWPOSCHANGED
:
4806 return REBAR_WindowPosChanged (infoPtr
, wParam
, lParam
);
4809 if ((uMsg
>= WM_USER
) && (uMsg
< WM_APP
))
4810 ERR("unknown msg %04x wp=%08x lp=%08lx\n",
4811 uMsg
, wParam
, lParam
);
4812 return DefWindowProcW (hwnd
, uMsg
, wParam
, lParam
);
4818 REBAR_Register (void)
4822 ZeroMemory (&wndClass
, sizeof(WNDCLASSW
));
4823 wndClass
.style
= CS_GLOBALCLASS
| CS_DBLCLKS
;
4824 wndClass
.lpfnWndProc
= REBAR_WindowProc
;
4825 wndClass
.cbClsExtra
= 0;
4826 wndClass
.cbWndExtra
= sizeof(REBAR_INFO
*);
4827 wndClass
.hCursor
= 0;
4828 wndClass
.hbrBackground
= (HBRUSH
)(COLOR_BTNFACE
+ 1);
4830 wndClass
.hbrBackground
= CreateSolidBrush(RGB(0,128,0));
4832 wndClass
.lpszClassName
= REBARCLASSNAMEW
;
4834 RegisterClassW (&wndClass
);
4836 mindragx
= GetSystemMetrics (SM_CXDRAG
);
4837 mindragy
= GetSystemMetrics (SM_CYDRAG
);
4843 REBAR_Unregister (void)
4845 UnregisterClassW (REBARCLASSNAMEW
, NULL
);