2 * Testing: set to 1 to make background brush *always* green
8 * 2. At "FIXME: problem # 2" WinRAR:
9 * if "#if 1" then last band draws in separate row
10 * if "#if 0" then last band draws in previous row *** just like native ***
16 * 3. REBAR_MoveChildWindows should have a loop because more than
17 * one pass is made (together with the RBN_CHILDSIZEs) is made on
18 * at least RB_INSERTBAND
23 * Rebar control rev 8e
25 * Copyright 1998, 1999 Eric Kohl
27 * This library is free software; you can redistribute it and/or
28 * modify it under the terms of the GNU Lesser General Public
29 * License as published by the Free Software Foundation; either
30 * version 2.1 of the License, or (at your option) any later version.
32 * This library is distributed in the hope that it will be useful,
33 * but WITHOUT ANY WARRANTY; without even the implied warranty of
34 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
35 * Lesser General Public License for more details.
37 * You should have received a copy of the GNU Lesser General Public
38 * License along with this library; if not, write to the Free Software
39 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
42 * An author is needed! Any volunteers?
43 * I will only improve this control once in a while.
44 * Eric <ekohl@abo.rhein-zeitung.de>
47 * - vertical placement
48 * - ComboBox and ComboBoxEx placement
53 * - All notifications.
55 * Changes Guy Albertelli <galberte@neo.lrun.com>
57 * - Implement initial version of row grouping, row separators,
58 * text and background colors. Support additional messages.
59 * Support RBBS_BREAK. Implement ERASEBKGND and improve painting.
61 * - implement support for dragging Gripper left or right in a row. Supports
62 * WM_LBUTTONDOWN, WM_LBUTTONUP, and WM_MOUSEMOVE. Also support
65 * - Fix or implement notifications for RBN_HEIGHTCHANGE, RBN_CHILDSIZE.
66 * - Correct styles RBBS_NOGRIPPER, RBBS_GRIPPERALWAYS, and RBBS_FIXEDSIZE.
67 * - Fix algorithm for Layout and AdjustBand.
70 * - Fix algorithm for _Layout and _AdjustBand.
71 * - Fix or implement RBN_ENDDRAG, RB_MOVEBAND, WM_SETREDRAW,
72 * WM_STYLECHANGED, RB_MINIMIZEBAND, RBBS_VARIABLEHEIGHT, RBS_VARHEIGHT,
73 * RBBS_HIDDEN, WM_NOTIFYFORMAT, NM_NCHITTEST, WM_SETREDRAW, RBS_AUTOSIZE,
74 * WM_SETFONT, RBS_BORDERS
75 * - Create structures in WM_NCCREATE
76 * - Additional performance enhancements.
79 * 1. Create array of start and end band indexes by row and use.
80 * 2. Fix problem with REBAR_Layout Phase 2b to process only if only
82 * 3. Set the Caption Font (Regular) as default font for text.
83 * 4. Delete font handle on control distruction.
84 * 5. Add UpdateWindow call in _MoveChildWindows to match repainting done
86 * 6. Improve some traces.
87 * 7. Invalidate window rectangles after SetBandInfo, InsertBand, ShowBand
88 * so that repainting is correct.
89 * 8. Implement RB_MAXIMIZEBAND for the "ideal=TRUE" case.
90 * 9. Implement item custom draw notifications partially. Only done for
91 * ITEMPREPAINT and ITEMPOSTPAINT. (Used by IE4 for "Favorites" frame
92 * to draw the word "Favorites").
94 * 10. Handle CCS_NODIVIDER and fix WS_BORDER code.
95 * 11. Fix logic error in _AdjustBands where flag was set to valid band
96 * number (0) to indicate *no* band.
97 * 12. Fix CCS_VERT errors in _ForceResize, _NCCalcSize, and _NCPaint.
98 * 13. Support some special cases of CCS_TOP (and therefore CCS_LEFT),
99 * CCS_BOTTOM (and therefore CCS_RIGHT) and CCS_NOPARENTALIGN. Not
100 * at all sure whether this is all cases.
101 * 14. Handle returned value for the RBN_CHILDSIZE notify.
102 * 15. Implement RBBS_CHILDEDGE, and set each bands "offChild" at _Layout
104 * 16. Fix REBARSPACE. It should depend on CCS_NODIVIDER.
106 * 17. Fix determination of whether Gripper is needed in _ValidateBand.
107 * 18. Fix _AdjustBand processing of RBBS_FIXEDSIZE.
109 * 19. Fix problem in _Layout when all lengths are 0.
110 * 20. If CLR_NONE specified, we will use default BtnFace color when drawing.
111 * 21. Fix test in REBAR_Layout.
113 * 22. Add support for WM_WINDOWPOSCHANGED to save new origin of window.
114 * 23. Correct RBN_CHILDSIZE rect value for CCS_VERT rebar.
115 * 24. Do UpdateWindow only if doing redraws.
117 * 25. Adjust setting of offChild.cx based on RBBS_CHILDEDGE.
121 * 2. Following still not handled: RBBS_FIXEDBMP,
123 * CCS_NOMOVEX, CCS_NOMOVEY
124 * 3. Following are only partially handled:
125 * RBS_AUTOSIZE, RBBS_VARIABLEHEIGHT
126 * 5. Native uses (on each draw!!) SM_CYBORDER (or SM_CXBORDER for CCS_VERT)
127 * to set the size of the separator width (the value SEP_WIDTH_SIZE
128 * in here). Should be fixed!!
129 * 6. The following messages are not implemented:
130 * RB_BEGINDRAG, RB_DRAGMOVE, RB_ENDDRAG, RB_GETCOLORSCHEME,
131 * RB_GETDROPTARGET, RB_MAXIMIZEBAND,
132 * RB_SETCOLORSCHEME, RB_SETPALETTE, RB_SETTOOLTIPS
133 * WM_CHARTOITEM, WM_LBUTTONDBLCLK, WM_MEASUREITEM,
134 * WM_PALETTECHANGED, WM_PRINTCLIENT, WM_QUERYNEWPALETTE,
135 * WM_RBUTTONDOWN, WM_RBUTTONUP,
136 * WM_SYSCOLORCHANGE, WM_VKEYTOITEM, WM_WININICHANGE
137 * 7. The following notifications are not implemented:
138 * NM_CUSTOMDRAW, NM_RELEASEDCAPTURE
149 #include "wine/unicode.h"
152 #include "commctrl.h"
153 #include "comctl32.h"
154 #include "wine/debug.h"
156 WINE_DEFAULT_DEBUG_CHANNEL(rebar
);
166 UINT cxMinChild
; /* valid if _CHILDSIZE */
167 UINT cyMinChild
; /* valid if _CHILDSIZE */
168 UINT cx
; /* valid if _SIZE */
171 UINT cyChild
; /* valid if _CHILDSIZE */
172 UINT cyMaxChild
; /* valid if _CHILDSIZE */
173 UINT cyIntegral
; /* valid if _CHILDSIZE */
178 UINT lcx
; /* minimum cx for band */
179 UINT ccx
; /* current cx for band */
180 UINT hcx
; /* maximum cx for band */
181 UINT lcy
; /* minimum cy for band */
182 UINT ccy
; /* current cy for band */
183 UINT hcy
; /* maximum cy for band */
185 SIZE offChild
; /* x,y offset if child is not FIXEDSIZE */
187 INT iRow
; /* row this band assigned to */
188 UINT fStatus
; /* status flags, reset only by _Validate */
189 UINT fDraw
; /* drawing flags, reset only by _Layout */
190 UINT uCDret
; /* last return from NM_CUSTOMDRAW */
191 RECT rcoldBand
; /* previous calculated band rectangle */
192 RECT rcBand
; /* calculated band rectangle */
193 RECT rcGripper
; /* calculated gripper rectangle */
194 RECT rcCapImage
; /* calculated caption image rectangle */
195 RECT rcCapText
; /* calculated caption text rectangle */
196 RECT rcChild
; /* calculated child rectangle */
197 RECT rcChevron
; /* calculated chevron rectangle */
204 #define HAS_GRIPPER 0x00000001
205 #define HAS_IMAGE 0x00000002
206 #define HAS_TEXT 0x00000004
209 #define DRAW_GRIPPER 0x00000001
210 #define DRAW_IMAGE 0x00000002
211 #define DRAW_TEXT 0x00000004
212 #define DRAW_RIGHTSEP 0x00000010
213 #define DRAW_BOTTOMSEP 0x00000020
214 #define DRAW_CHEVRONHOT 0x00000040
215 #define DRAW_CHEVRONPUSHED 0x00000080
216 #define NTF_INVALIDATE 0x01000000
220 INT istartband
; /* index of first band in row */
221 INT iendband
; /* index of last band in row */
227 COLORREF clrBk
; /* background color */
228 COLORREF clrText
; /* text color */
229 COLORREF clrBtnText
; /* system color for BTNTEXT */
230 COLORREF clrBtnFace
; /* system color for BTNFACE */
231 HIMAGELIST himl
; /* handle to imagelist */
232 UINT uNumBands
; /* # of bands in rebar (first=0, last=uNumBands-1 */
233 UINT uNumRows
; /* # of rows of bands (first=1, last=uNumRows */
234 HWND hwndSelf
; /* handle of REBAR window itself */
235 HWND hwndToolTip
; /* handle to the tool tip control */
236 HWND hwndNotify
; /* notification window (parent) */
238 HFONT hFont
; /* handle to the rebar's font */
239 SIZE imageSize
; /* image size (image list) */
240 DWORD dwStyle
; /* window style */
241 SIZE calcSize
; /* calculated rebar size */
242 SIZE oldSize
; /* previous calculated rebar size */
243 BOOL bUnicode
; /* TRUE if this window is W type */
244 BOOL NtfUnicode
; /* TRUE if parent wants notify in W format */
245 BOOL DoRedraw
; /* TRUE to acutally draw bands */
246 UINT fStatus
; /* Status flags (see below) */
247 HCURSOR hcurArrow
; /* handle to the arrow cursor */
248 HCURSOR hcurHorz
; /* handle to the EW cursor */
249 HCURSOR hcurVert
; /* handle to the NS cursor */
250 HCURSOR hcurDrag
; /* handle to the drag cursor */
251 INT iVersion
; /* version number */
252 POINTS dragStart
; /* x,y of button down */
253 POINTS dragNow
; /* x,y of this MouseMove */
254 INT iOldBand
; /* last band that had the mouse cursor over it */
255 INT ihitoffset
; /* offset of hotspot from gripper.left */
256 POINT origin
; /* left/upper corner of client */
257 INT ichevronhotBand
; /* last band that had a hot chevron */
258 INT iGrabbedBand
;/* band number of band whose gripper was grabbed */
260 REBAR_ROW
*rows
; /* pointer to row indexes */
261 REBAR_BAND
*bands
; /* pointer to the array of rebar bands */
265 #define BEGIN_DRAG_ISSUED 0x00000001
266 #define AUTO_RESIZE 0x00000002
267 #define RESIZE_ANYHOW 0x00000004
268 #define NTF_HGHTCHG 0x00000008
269 #define BAND_NEEDS_LAYOUT 0x00000010
270 #define BAND_NEEDS_REDRAW 0x00000020
271 #define CREATE_RUNNING 0x00000040
273 /* ---- REBAR layout constants. Mostly determined by ---- */
274 /* ---- experiment on WIN 98. ---- */
276 /* Width (or height) of separators between bands (either horz. or */
277 /* vert.). True only if RBS_BANDBORDERS is set */
278 #define SEP_WIDTH_SIZE 2
279 #define SEP_WIDTH ((infoPtr->dwStyle & RBS_BANDBORDERS) ? SEP_WIDTH_SIZE : 0)
281 /* Blank (background color) space between Gripper (if present) */
282 /* and next item (image, text, or window). Always present */
283 #define REBAR_ALWAYS_SPACE 4
285 /* Blank (background color) space after Image (if present). */
286 #define REBAR_POST_IMAGE 2
288 /* Blank (background color) space after Text (if present). */
289 #define REBAR_POST_TEXT 4
291 /* Height of vertical gripper in a CCS_VERT rebar. */
292 #define GRIPPER_HEIGHT 16
294 /* Blank (background color) space before Gripper (if present). */
295 #define REBAR_PRE_GRIPPER 2
297 /* Width (of normal vertical gripper) or height (of horz. gripper) */
299 #define GRIPPER_WIDTH 3
301 /* Width of the chevron button if present */
302 #define CHEVRON_WIDTH 10
304 /* Height of divider for Rebar if not disabled (CCS_NODIVIDER) */
305 /* either top or bottom */
306 #define REBAR_DIVIDER 2
308 /* This is the increment that is used over the band height */
309 #define REBARSPACE(a) ((a->fStyle & RBBS_CHILDEDGE) ? 2*REBAR_DIVIDER : 0)
311 /* ---- End of REBAR layout constants. ---- */
314 /* The following 6 defines return the proper rcBand element */
315 /* depending on whether CCS_VERT was set. */
316 #define rcBlt(b) ((infoPtr->dwStyle & CCS_VERT) ? b->rcBand.top : b->rcBand.left)
317 #define rcBrb(b) ((infoPtr->dwStyle & CCS_VERT) ? b->rcBand.bottom : b->rcBand.right)
318 #define rcBw(b) ((infoPtr->dwStyle & CCS_VERT) ? (b->rcBand.bottom - b->rcBand.top) : \
319 (b->rcBand.right - b->rcBand.left))
320 #define ircBlt(b) ((infoPtr->dwStyle & CCS_VERT) ? b->rcBand.left : b->rcBand.top)
321 #define ircBrb(b) ((infoPtr->dwStyle & CCS_VERT) ? b->rcBand.right : b->rcBand.bottom)
322 #define ircBw(b) ((infoPtr->dwStyle & CCS_VERT) ? (b->rcBand.right - b->rcBand.left) : \
323 (b->rcBand.bottom - b->rcBand.top))
325 /* The following define determines if a given band is hidden */
326 #define HIDDENBAND(a) (((a)->fStyle & RBBS_HIDDEN) || \
327 ((infoPtr->dwStyle & CCS_VERT) && \
328 ((a)->fStyle & RBBS_NOVERT)))
330 /* The following defines adjust the right or left end of a rectangle */
331 #define READJ(b,i) do { if(infoPtr->dwStyle & CCS_VERT) b->rcBand.bottom+=(i); \
332 else b->rcBand.right += (i); } while(0)
333 #define LEADJ(b,i) do { if(infoPtr->dwStyle & CCS_VERT) b->rcBand.top+=(i); \
334 else b->rcBand.left += (i); } while(0)
337 #define REBAR_GetInfoPtr(wndPtr) ((REBAR_INFO *)GetWindowLongA (hwnd, 0))
340 /* "constant values" retrieved when DLL was initialized */
341 /* FIXME we do this when the classes are registered. */
342 static UINT mindragx
= 0;
343 static UINT mindragy
= 0;
345 static const char *band_stylename
[] = {
346 "RBBS_BREAK", /* 0001 */
347 "RBBS_FIXEDSIZE", /* 0002 */
348 "RBBS_CHILDEDGE", /* 0004 */
349 "RBBS_HIDDEN", /* 0008 */
350 "RBBS_NOVERT", /* 0010 */
351 "RBBS_FIXEDBMP", /* 0020 */
352 "RBBS_VARIABLEHEIGHT", /* 0040 */
353 "RBBS_GRIPPERALWAYS", /* 0080 */
354 "RBBS_NOGRIPPER", /* 0100 */
357 static const char *band_maskname
[] = {
358 "RBBIM_STYLE", /* 0x00000001 */
359 "RBBIM_COLORS", /* 0x00000002 */
360 "RBBIM_TEXT", /* 0x00000004 */
361 "RBBIM_IMAGE", /* 0x00000008 */
362 "RBBIM_CHILD", /* 0x00000010 */
363 "RBBIM_CHILDSIZE", /* 0x00000020 */
364 "RBBIM_SIZE", /* 0x00000040 */
365 "RBBIM_BACKGROUND", /* 0x00000080 */
366 "RBBIM_ID", /* 0x00000100 */
367 "RBBIM_IDEALSIZE", /* 0x00000200 */
368 "RBBIM_LPARAM", /* 0x00000400 */
369 "RBBIM_HEADERSIZE", /* 0x00000800 */
373 static CHAR line
[200];
377 REBAR_FmtStyle( UINT style
)
382 while (band_stylename
[i
]) {
383 if (style
& (1<<i
)) {
384 if (*line
!= 0) strcat(line
, " | ");
385 strcat(line
, band_stylename
[i
]);
394 REBAR_FmtMask( UINT mask
)
399 while (band_maskname
[i
]) {
401 if (*line
!= 0) strcat(line
, " | ");
402 strcat(line
, band_maskname
[i
]);
411 REBAR_DumpBandInfo( LPREBARBANDINFOA pB
)
413 if( !TRACE_ON(rebar
) ) return;
414 TRACE("band info: ID=%u, size=%u, child=%p, clrF=0x%06lx, clrB=0x%06lx\n",
415 pB
->wID
, pB
->cbSize
, pB
->hwndChild
, pB
->clrFore
, pB
->clrBack
);
416 TRACE("band info: mask=0x%08x (%s)\n", pB
->fMask
, REBAR_FmtMask(pB
->fMask
));
417 if (pB
->fMask
& RBBIM_STYLE
)
418 TRACE("band info: style=0x%08x (%s)\n", pB
->fStyle
, REBAR_FmtStyle(pB
->fStyle
));
419 if (pB
->fMask
& (RBBIM_SIZE
| RBBIM_IDEALSIZE
| RBBIM_HEADERSIZE
| RBBIM_LPARAM
)) {
421 if (pB
->fMask
& RBBIM_SIZE
)
422 TRACE(" cx=%u", pB
->cx
);
423 if (pB
->fMask
& RBBIM_IDEALSIZE
)
424 TRACE(" xIdeal=%u", pB
->cxIdeal
);
425 if (pB
->fMask
& RBBIM_HEADERSIZE
)
426 TRACE(" xHeader=%u", pB
->cxHeader
);
427 if (pB
->fMask
& RBBIM_LPARAM
)
428 TRACE(" lParam=0x%08lx", pB
->lParam
);
431 if (pB
->fMask
& RBBIM_CHILDSIZE
)
432 TRACE("band info: xMin=%u, yMin=%u, yChild=%u, yMax=%u, yIntgl=%u\n",
434 pB
->cyMinChild
, pB
->cyChild
, pB
->cyMaxChild
, pB
->cyIntegral
);
438 REBAR_DumpBand (REBAR_INFO
*iP
)
443 if(! TRACE_ON(rebar
) ) return;
445 TRACE("hwnd=%p: color=%08lx/%08lx, bands=%u, rows=%u, cSize=%ld,%ld\n",
446 iP
->hwndSelf
, iP
->clrText
, iP
->clrBk
, iP
->uNumBands
, iP
->uNumRows
,
447 iP
->calcSize
.cx
, iP
->calcSize
.cy
);
448 TRACE("hwnd=%p: flags=%08x, dragStart=%d,%d, dragNow=%d,%d, iGrabbedBand=%d\n",
449 iP
->hwndSelf
, iP
->fStatus
, iP
->dragStart
.x
, iP
->dragStart
.y
,
450 iP
->dragNow
.x
, iP
->dragNow
.y
,
452 TRACE("hwnd=%p: style=%08lx, I'm Unicode=%s, notify in Unicode=%s, redraw=%s\n",
453 iP
->hwndSelf
, iP
->dwStyle
, (iP
->bUnicode
)?"TRUE":"FALSE",
454 (iP
->NtfUnicode
)?"TRUE":"FALSE", (iP
->DoRedraw
)?"TRUE":"FALSE");
455 for (i
= 0; i
< iP
->uNumBands
; i
++) {
457 TRACE("band # %u: ID=%u, child=%p, row=%u, clrF=0x%06lx, clrB=0x%06lx\n",
458 i
, pB
->wID
, pB
->hwndChild
, pB
->iRow
, pB
->clrFore
, pB
->clrBack
);
459 TRACE("band # %u: mask=0x%08x (%s)\n", i
, pB
->fMask
, REBAR_FmtMask(pB
->fMask
));
460 if (pB
->fMask
& RBBIM_STYLE
)
461 TRACE("band # %u: style=0x%08x (%s)\n",
462 i
, pB
->fStyle
, REBAR_FmtStyle(pB
->fStyle
));
463 TRACE("band # %u: uMinH=%u xHeader=%u",
464 i
, pB
->uMinHeight
, pB
->cxHeader
);
465 if (pB
->fMask
& (RBBIM_SIZE
| RBBIM_IDEALSIZE
| RBBIM_LPARAM
)) {
466 if (pB
->fMask
& RBBIM_SIZE
)
467 TRACE(" cx=%u", pB
->cx
);
468 if (pB
->fMask
& RBBIM_IDEALSIZE
)
469 TRACE(" xIdeal=%u", pB
->cxIdeal
);
470 if (pB
->fMask
& RBBIM_LPARAM
)
471 TRACE(" lParam=0x%08lx", pB
->lParam
);
475 TRACE("band # %u: xMin=%u, yMin=%u, yChild=%u, yMax=%u, yIntgl=%u\n",
476 i
, pB
->cxMinChild
, pB
->cyMinChild
, pB
->cyChild
, pB
->cyMaxChild
, pB
->cyIntegral
);
477 if (pB
->fMask
& RBBIM_TEXT
)
478 TRACE("band # %u: text=%s\n",
479 i
, (pB
->lpText
) ? debugstr_w(pB
->lpText
) : "(null)");
480 TRACE("band # %u: lcx=%u, ccx=%u, hcx=%u, lcy=%u, ccy=%u, hcy=%u, offChild=%ld,%ld\n",
481 i
, pB
->lcx
, pB
->ccx
, pB
->hcx
, pB
->lcy
, pB
->ccy
, pB
->hcy
, pB
->offChild
.cx
, pB
->offChild
.cy
);
482 TRACE("band # %u: fStatus=%08x, fDraw=%08x, Band=(%ld,%ld)-(%ld,%ld), Grip=(%ld,%ld)-(%ld,%ld)\n",
483 i
, pB
->fStatus
, pB
->fDraw
,
484 pB
->rcBand
.left
, pB
->rcBand
.top
, pB
->rcBand
.right
, pB
->rcBand
.bottom
,
485 pB
->rcGripper
.left
, pB
->rcGripper
.top
, pB
->rcGripper
.right
, pB
->rcGripper
.bottom
);
486 TRACE("band # %u: Img=(%ld,%ld)-(%ld,%ld), Txt=(%ld,%ld)-(%ld,%ld), Child=(%ld,%ld)-(%ld,%ld)\n",
488 pB
->rcCapImage
.left
, pB
->rcCapImage
.top
, pB
->rcCapImage
.right
, pB
->rcCapImage
.bottom
,
489 pB
->rcCapText
.left
, pB
->rcCapText
.top
, pB
->rcCapText
.right
, pB
->rcCapText
.bottom
,
490 pB
->rcChild
.left
, pB
->rcChild
.top
, pB
->rcChild
.right
, pB
->rcChild
.bottom
);
496 REBAR_DrawChevron (HDC hdc
, INT left
, INT top
, INT colorRef
)
501 if (!(hPen
= CreatePen( PS_SOLID
, 1, GetSysColor( colorRef
)))) return;
502 hOldPen
= SelectObject ( hdc
, hPen
);
505 MoveToEx (hdc
, x
, y
, NULL
);
506 LineTo (hdc
, x
+5, y
++); x
++;
507 MoveToEx (hdc
, x
, y
, NULL
);
508 LineTo (hdc
, x
+3, y
++); x
++;
509 MoveToEx (hdc
, x
, y
, NULL
);
510 LineTo (hdc
, x
+1, y
++);
511 SelectObject( hdc
, hOldPen
);
512 DeleteObject( hPen
);
516 REBAR_GetNotifyParent (REBAR_INFO
*infoPtr
)
520 parent
= infoPtr
->hwndNotify
;
522 parent
= GetParent (infoPtr
->hwndSelf
);
523 owner
= GetWindow (infoPtr
->hwndSelf
, GW_OWNER
);
524 if (owner
) parent
= owner
;
531 REBAR_Notify (NMHDR
*nmhdr
, REBAR_INFO
*infoPtr
, UINT code
)
535 parent
= REBAR_GetNotifyParent (infoPtr
);
536 nmhdr
->idFrom
= GetDlgCtrlID (infoPtr
->hwndSelf
);
537 nmhdr
->hwndFrom
= infoPtr
->hwndSelf
;
540 TRACE("window %p, code=%08x, %s\n", parent
, code
,
541 (infoPtr
->NtfUnicode
) ? "via Unicode" : "via ANSI");
543 if (infoPtr
->NtfUnicode
)
544 return SendMessageW (parent
, WM_NOTIFY
, (WPARAM
) nmhdr
->idFrom
,
547 return SendMessageA (parent
, WM_NOTIFY
, (WPARAM
) nmhdr
->idFrom
,
552 REBAR_Notify_NMREBAR (REBAR_INFO
*infoPtr
, UINT uBand
, UINT code
)
554 NMREBAR notify_rebar
;
557 notify_rebar
.dwMask
= 0;
559 lpBand
= &infoPtr
->bands
[uBand
];
560 if (lpBand
->fMask
& RBBIM_ID
) {
561 notify_rebar
.dwMask
|= RBNM_ID
;
562 notify_rebar
.wID
= lpBand
->wID
;
564 if (lpBand
->fMask
& RBBIM_LPARAM
) {
565 notify_rebar
.dwMask
|= RBNM_LPARAM
;
566 notify_rebar
.lParam
= lpBand
->lParam
;
568 if (lpBand
->fMask
& RBBIM_STYLE
) {
569 notify_rebar
.dwMask
|= RBNM_STYLE
;
570 notify_rebar
.fStyle
= lpBand
->fStyle
;
573 notify_rebar
.uBand
= uBand
;
574 return REBAR_Notify ((NMHDR
*)¬ify_rebar
, infoPtr
, code
);
578 REBAR_DrawBand (HDC hdc
, REBAR_INFO
*infoPtr
, REBAR_BAND
*lpBand
)
584 if (lpBand
->fDraw
& DRAW_TEXT
) {
585 hOldFont
= SelectObject (hdc
, infoPtr
->hFont
);
586 oldBkMode
= SetBkMode (hdc
, TRANSPARENT
);
589 /* should test for CDRF_NOTIFYITEMDRAW here */
590 nmcd
.dwDrawStage
= CDDS_ITEMPREPAINT
;
592 nmcd
.rc
= lpBand
->rcBand
;
593 nmcd
.rc
.right
= lpBand
->rcCapText
.right
;
594 nmcd
.rc
.bottom
= lpBand
->rcCapText
.bottom
;
595 nmcd
.dwItemSpec
= lpBand
->wID
;
597 nmcd
.lItemlParam
= lpBand
->lParam
;
598 lpBand
->uCDret
= REBAR_Notify ((NMHDR
*)&nmcd
, infoPtr
, NM_CUSTOMDRAW
);
599 if (lpBand
->uCDret
== CDRF_SKIPDEFAULT
) {
600 if (oldBkMode
!= TRANSPARENT
)
601 SetBkMode (hdc
, oldBkMode
);
602 SelectObject (hdc
, hOldFont
);
607 if (lpBand
->fDraw
& DRAW_GRIPPER
)
608 DrawEdge (hdc
, &lpBand
->rcGripper
, BDR_RAISEDINNER
, BF_RECT
| BF_MIDDLE
);
610 /* draw caption image */
611 if (lpBand
->fDraw
& DRAW_IMAGE
) {
615 pt
.y
= (lpBand
->rcCapImage
.bottom
+ lpBand
->rcCapImage
.top
- infoPtr
->imageSize
.cy
)/2;
616 pt
.x
= (lpBand
->rcCapImage
.right
+ lpBand
->rcCapImage
.left
- infoPtr
->imageSize
.cx
)/2;
618 ImageList_Draw (infoPtr
->himl
, lpBand
->iImage
, hdc
,
623 /* draw caption text */
624 if (lpBand
->fDraw
& DRAW_TEXT
) {
625 /* need to handle CDRF_NEWFONT here */
626 INT oldBkMode
= SetBkMode (hdc
, TRANSPARENT
);
627 COLORREF oldcolor
= CLR_NONE
;
629 if (lpBand
->clrFore
!= CLR_NONE
) {
630 new = (lpBand
->clrFore
== CLR_DEFAULT
) ? infoPtr
->clrBtnText
:
632 oldcolor
= SetTextColor (hdc
, new);
634 DrawTextW (hdc
, lpBand
->lpText
, -1, &lpBand
->rcCapText
,
635 DT_CENTER
| DT_VCENTER
| DT_SINGLELINE
);
636 if (oldBkMode
!= TRANSPARENT
)
637 SetBkMode (hdc
, oldBkMode
);
638 if (lpBand
->clrFore
!= CLR_NONE
)
639 SetTextColor (hdc
, oldcolor
);
640 SelectObject (hdc
, hOldFont
);
643 if (!IsRectEmpty(&lpBand
->rcChevron
))
645 if (lpBand
->fDraw
& DRAW_CHEVRONPUSHED
)
647 DrawEdge(hdc
, &lpBand
->rcChevron
, BDR_SUNKENOUTER
, BF_RECT
| BF_MIDDLE
);
648 REBAR_DrawChevron(hdc
, lpBand
->rcChevron
.left
+1, lpBand
->rcChevron
.top
+ 11, COLOR_WINDOWFRAME
);
650 else if (lpBand
->fDraw
& DRAW_CHEVRONHOT
)
652 DrawEdge(hdc
, &lpBand
->rcChevron
, BDR_RAISEDINNER
, BF_RECT
| BF_MIDDLE
);
653 REBAR_DrawChevron(hdc
, lpBand
->rcChevron
.left
, lpBand
->rcChevron
.top
+ 10, COLOR_WINDOWFRAME
);
656 REBAR_DrawChevron(hdc
, lpBand
->rcChevron
.left
, lpBand
->rcChevron
.top
+ 10, COLOR_WINDOWFRAME
);
659 if (lpBand
->uCDret
== (CDRF_NOTIFYPOSTPAINT
| CDRF_NOTIFYITEMDRAW
)) {
660 nmcd
.dwDrawStage
= CDDS_ITEMPOSTPAINT
;
662 nmcd
.rc
= lpBand
->rcBand
;
663 nmcd
.rc
.right
= lpBand
->rcCapText
.right
;
664 nmcd
.rc
.bottom
= lpBand
->rcCapText
.bottom
;
665 nmcd
.dwItemSpec
= lpBand
->wID
;
667 nmcd
.lItemlParam
= lpBand
->lParam
;
668 lpBand
->uCDret
= REBAR_Notify ((NMHDR
*)&nmcd
, infoPtr
, NM_CUSTOMDRAW
);
674 REBAR_Refresh (REBAR_INFO
*infoPtr
, HDC hdc
)
679 if (!infoPtr
->DoRedraw
) return;
681 oldrow
= infoPtr
->bands
[0].iRow
;
682 for (i
= 0; i
< infoPtr
->uNumBands
; i
++) {
683 lpBand
= &infoPtr
->bands
[i
];
685 if (HIDDENBAND(lpBand
)) continue;
687 /* now draw the band */
688 TRACE("[%p] drawing band %i, flags=%08x\n",
689 infoPtr
->hwndSelf
, i
, lpBand
->fDraw
);
690 REBAR_DrawBand (hdc
, infoPtr
, lpBand
);
697 REBAR_FixVert (REBAR_INFO
*infoPtr
, UINT rowstart
, UINT rowend
,
700 /* Cycle through bands in row and fix height of each band. */
701 /* Also determine whether each band has changed. */
703 /* all bands at desired size. */
704 /* start and end bands are *not* hidden */
709 for (i
= (INT
)rowstart
; i
<=(INT
)rowend
; i
++) {
710 lpBand
= &infoPtr
->bands
[i
];
711 if (HIDDENBAND(lpBand
)) continue;
713 /* adjust height of bands in row to "mcy" value */
714 if (infoPtr
->dwStyle
& CCS_VERT
) {
715 if (lpBand
->rcBand
.right
!= lpBand
->rcBand
.left
+ mcy
)
716 lpBand
->rcBand
.right
= lpBand
->rcBand
.left
+ mcy
;
719 if (lpBand
->rcBand
.bottom
!= lpBand
->rcBand
.top
+ mcy
)
720 lpBand
->rcBand
.bottom
= lpBand
->rcBand
.top
+ mcy
;
724 /* mark whether we need to invalidate this band and trace */
725 if ((lpBand
->rcoldBand
.left
!=lpBand
->rcBand
.left
) ||
726 (lpBand
->rcoldBand
.top
!=lpBand
->rcBand
.top
) ||
727 (lpBand
->rcoldBand
.right
!=lpBand
->rcBand
.right
) ||
728 (lpBand
->rcoldBand
.bottom
!=lpBand
->rcBand
.bottom
)) {
729 lpBand
->fDraw
|= NTF_INVALIDATE
;
730 TRACE("band %d row=%d: changed to (%ld,%ld)-(%ld,%ld) from (%ld,%ld)-(%ld,%ld)\n",
732 lpBand
->rcBand
.left
, lpBand
->rcBand
.top
,
733 lpBand
->rcBand
.right
, lpBand
->rcBand
.bottom
,
734 lpBand
->rcoldBand
.left
, lpBand
->rcoldBand
.top
,
735 lpBand
->rcoldBand
.right
, lpBand
->rcoldBand
.bottom
);
738 TRACE("band %d row=%d: unchanged (%ld,%ld)-(%ld,%ld)\n",
740 lpBand
->rcBand
.left
, lpBand
->rcBand
.top
,
741 lpBand
->rcBand
.right
, lpBand
->rcBand
.bottom
);
747 REBAR_AdjustBands (REBAR_INFO
*infoPtr
, UINT rowstart
, UINT rowend
,
749 /* Function: This routine distributes the extra space in a row. */
750 /* See algorithm below. */
752 /* all bands @ ->cxHeader size */
753 /* start and end bands are *not* hidden */
756 UINT x
, xsep
, extra
, curwidth
, fudge
;
757 INT i
, last_adjusted
;
759 TRACE("start=%u, end=%u, max x=%d, max y=%d\n",
760 rowstart
, rowend
, maxx
, mcy
);
762 /* ******************* Phase 1 ************************ */
764 /* For each visible band with valid child */
765 /* a. inflate band till either all extra space used */
766 /* or band's ->ccx reached. */
767 /* If any band modified, add any space left to last band */
770 /* ****************************************************** */
771 lpBand
= &infoPtr
->bands
[rowend
];
772 extra
= maxx
- rcBrb(lpBand
);
775 for (i
=(INT
)rowstart
; i
<=(INT
)rowend
; i
++) {
776 lpBand
= &infoPtr
->bands
[i
];
777 if (HIDDENBAND(lpBand
)) continue;
778 xsep
= (x
== 0) ? 0 : SEP_WIDTH
;
779 curwidth
= rcBw(lpBand
);
781 /* set new left/top point */
782 if (infoPtr
->dwStyle
& CCS_VERT
)
783 lpBand
->rcBand
.top
= x
+ xsep
;
785 lpBand
->rcBand
.left
= x
+ xsep
;
787 /* compute new width */
788 if ((lpBand
->hwndChild
&& extra
) && !(lpBand
->fStyle
& RBBS_FIXEDSIZE
)) {
789 /* set to the "current" band size less the header */
792 if ((lpBand
->fMask
& RBBIM_SIZE
) && (lpBand
->cx
> 0) &&
793 (fudge
> curwidth
)) {
794 TRACE("adjusting band %d by %d, fudge=%d, curwidth=%d, extra=%d\n",
795 i
, fudge
-curwidth
, fudge
, curwidth
, extra
);
796 if ((fudge
- curwidth
) > extra
)
797 fudge
= curwidth
+ extra
;
798 extra
-= (fudge
- curwidth
);
802 TRACE("adjusting band %d by %d, fudge=%d, curwidth=%d\n",
803 i
, extra
, fudge
, curwidth
);
809 /* set new right/bottom point */
810 if (infoPtr
->dwStyle
& CCS_VERT
)
811 lpBand
->rcBand
.bottom
= lpBand
->rcBand
.top
+ curwidth
;
813 lpBand
->rcBand
.right
= lpBand
->rcBand
.left
+ curwidth
;
814 TRACE("Phase 1 band %d, (%ld,%ld)-(%ld,%ld), orig x=%d, xsep=%d\n",
815 i
, lpBand
->rcBand
.left
, lpBand
->rcBand
.top
,
816 lpBand
->rcBand
.right
, lpBand
->rcBand
.bottom
, x
, xsep
);
819 if ((x
>= maxx
) || (last_adjusted
!= -1)) {
821 ERR("Phase 1 failed, x=%d, maxx=%d, start=%u, end=%u\n",
822 x
, maxx
, rowstart
, rowend
);
824 /* done, so spread extra space */
827 TRACE("Need to spread %d on last adjusted band %d\n",
828 fudge
, last_adjusted
);
829 for (i
=(INT
)last_adjusted
; i
<=(INT
)rowend
; i
++) {
830 lpBand
= &infoPtr
->bands
[i
];
831 if (HIDDENBAND(lpBand
)) continue;
833 /* set right/bottom point */
834 if (i
!= last_adjusted
) {
835 if (infoPtr
->dwStyle
& CCS_VERT
)
836 lpBand
->rcBand
.top
+= fudge
;
838 lpBand
->rcBand
.left
+= fudge
;
841 /* set left/bottom point */
842 if (infoPtr
->dwStyle
& CCS_VERT
)
843 lpBand
->rcBand
.bottom
+= fudge
;
845 lpBand
->rcBand
.right
+= fudge
;
848 TRACE("Phase 1 succeeded, used x=%d\n", x
);
849 REBAR_FixVert (infoPtr
, rowstart
, rowend
, mcy
);
853 /* ******************* Phase 2 ************************ */
855 /* Find first visible band, put all */
856 /* extra space there. */
858 /* ****************************************************** */
861 for (i
=(INT
)rowstart
; i
<=(INT
)rowend
; i
++) {
862 lpBand
= &infoPtr
->bands
[i
];
863 if (HIDDENBAND(lpBand
)) continue;
864 xsep
= (x
== 0) ? 0 : SEP_WIDTH
;
865 curwidth
= rcBw(lpBand
);
867 /* set new left/top point */
868 if (infoPtr
->dwStyle
& CCS_VERT
)
869 lpBand
->rcBand
.top
= x
+ xsep
;
871 lpBand
->rcBand
.left
= x
+ xsep
;
873 /* compute new width */
879 /* set new right/bottom point */
880 if (infoPtr
->dwStyle
& CCS_VERT
)
881 lpBand
->rcBand
.bottom
= lpBand
->rcBand
.top
+ curwidth
;
883 lpBand
->rcBand
.right
= lpBand
->rcBand
.left
+ curwidth
;
884 TRACE("Phase 2 band %d, (%ld,%ld)-(%ld,%ld), orig x=%d, xsep=%d\n",
885 i
, lpBand
->rcBand
.left
, lpBand
->rcBand
.top
,
886 lpBand
->rcBand
.right
, lpBand
->rcBand
.bottom
, x
, xsep
);
891 ERR("Phase 2 failed, x=%d, maxx=%d, start=%u, end=%u\n",
892 x
, maxx
, rowstart
, rowend
);
894 /* done, so spread extra space */
895 TRACE("Phase 2 succeeded, used x=%d\n", x
);
896 REBAR_FixVert (infoPtr
, rowstart
, rowend
, mcy
);
900 /* ******************* Phase 3 ************************ */
901 /* at this point everything is back to ->cxHeader values */
902 /* and should not have gotten here. */
903 /* ****************************************************** */
905 lpBand
= &infoPtr
->bands
[rowstart
];
906 ERR("Serious problem adjusting row %d, start band %d, end band %d\n",
907 lpBand
->iRow
, rowstart
, rowend
);
908 REBAR_DumpBand (infoPtr
);
914 REBAR_CalcHorzBand (REBAR_INFO
*infoPtr
, UINT rstart
, UINT rend
, BOOL notify
)
915 /* Function: this routine initializes all the rectangles in */
916 /* each band in a row to fit in the adjusted rcBand rect. */
917 /* *** Supports only Horizontal bars. *** */
924 /* MS seems to use GetDlgCtrlID() for above GetWindowLong call */
925 parenthwnd
= GetParent (infoPtr
->hwndSelf
);
927 for(i
=rstart
; i
<rend
; i
++){
928 lpBand
= &infoPtr
->bands
[i
];
929 if (HIDDENBAND(lpBand
)) {
930 SetRect (&lpBand
->rcChild
,
931 lpBand
->rcBand
.right
, lpBand
->rcBand
.top
,
932 lpBand
->rcBand
.right
, lpBand
->rcBand
.bottom
);
936 oldChild
= lpBand
->rcChild
;
938 /* set initial gripper rectangle */
939 SetRect (&lpBand
->rcGripper
, lpBand
->rcBand
.left
, lpBand
->rcBand
.top
,
940 lpBand
->rcBand
.left
, lpBand
->rcBand
.bottom
);
942 /* calculate gripper rectangle */
943 if ( lpBand
->fStatus
& HAS_GRIPPER
) {
944 lpBand
->fDraw
|= DRAW_GRIPPER
;
945 lpBand
->rcGripper
.left
+= REBAR_PRE_GRIPPER
;
946 lpBand
->rcGripper
.right
= lpBand
->rcGripper
.left
+ GRIPPER_WIDTH
;
947 lpBand
->rcGripper
.top
+= 2;
948 lpBand
->rcGripper
.bottom
-= 2;
950 SetRect (&lpBand
->rcCapImage
,
951 lpBand
->rcGripper
.right
+REBAR_ALWAYS_SPACE
, lpBand
->rcBand
.top
,
952 lpBand
->rcGripper
.right
+REBAR_ALWAYS_SPACE
, lpBand
->rcBand
.bottom
);
954 else { /* no gripper will be drawn */
956 if (lpBand
->fStatus
& (HAS_IMAGE
| HAS_TEXT
))
957 /* if no gripper but either image or text, then leave space */
958 xoff
= REBAR_ALWAYS_SPACE
;
959 SetRect (&lpBand
->rcCapImage
,
960 lpBand
->rcBand
.left
+xoff
, lpBand
->rcBand
.top
,
961 lpBand
->rcBand
.left
+xoff
, lpBand
->rcBand
.bottom
);
964 /* image is visible */
965 if (lpBand
->fStatus
& HAS_IMAGE
) {
966 lpBand
->fDraw
|= DRAW_IMAGE
;
967 lpBand
->rcCapImage
.right
+= infoPtr
->imageSize
.cx
;
968 lpBand
->rcCapImage
.bottom
= lpBand
->rcCapImage
.top
+ infoPtr
->imageSize
.cy
;
970 /* set initial caption text rectangle */
971 SetRect (&lpBand
->rcCapText
,
972 lpBand
->rcCapImage
.right
+REBAR_POST_IMAGE
, lpBand
->rcBand
.top
+1,
973 lpBand
->rcBand
.left
+lpBand
->cxHeader
, lpBand
->rcBand
.bottom
-1);
974 /* update band height
975 if (lpBand->uMinHeight < infoPtr->imageSize.cy + 2) {
976 lpBand->uMinHeight = infoPtr->imageSize.cy + 2;
977 lpBand->rcBand.bottom = lpBand->rcBand.top + lpBand->uMinHeight;
981 /* set initial caption text rectangle */
982 SetRect (&lpBand
->rcCapText
, lpBand
->rcCapImage
.right
, lpBand
->rcBand
.top
+1,
983 lpBand
->rcBand
.left
+lpBand
->cxHeader
, lpBand
->rcBand
.bottom
-1);
986 /* text is visible */
987 if (lpBand
->fStatus
& HAS_TEXT
) {
988 lpBand
->fDraw
|= DRAW_TEXT
;
989 lpBand
->rcCapText
.right
= max(lpBand
->rcCapText
.left
,
990 lpBand
->rcCapText
.right
-REBAR_POST_TEXT
);
993 /* set initial child window rectangle if there is a child */
994 if (lpBand
->fMask
& RBBIM_CHILD
) {
995 xoff
= lpBand
->offChild
.cx
;
996 yoff
= lpBand
->offChild
.cy
;
997 SetRect (&lpBand
->rcChild
,
998 lpBand
->rcBand
.left
+lpBand
->cxHeader
, lpBand
->rcBand
.top
+yoff
,
999 lpBand
->rcBand
.right
-xoff
, lpBand
->rcBand
.bottom
-yoff
);
1000 if ((lpBand
->fStyle
& RBBS_USECHEVRON
) && (lpBand
->rcChild
.right
- lpBand
->rcChild
.left
< lpBand
->cxIdeal
))
1002 lpBand
->rcChild
.right
-= CHEVRON_WIDTH
;
1003 SetRect(&lpBand
->rcChevron
, lpBand
->rcChild
.right
,
1004 lpBand
->rcChild
.top
, lpBand
->rcChild
.right
+ CHEVRON_WIDTH
,
1005 lpBand
->rcChild
.bottom
);
1009 SetRect (&lpBand
->rcChild
,
1010 lpBand
->rcBand
.left
+lpBand
->cxHeader
, lpBand
->rcBand
.top
,
1011 lpBand
->rcBand
.right
, lpBand
->rcBand
.bottom
);
1014 /* flag if notify required and invalidate rectangle */
1016 ((oldChild
.right
-oldChild
.left
!= lpBand
->rcChild
.right
-lpBand
->rcChild
.left
) ||
1017 (oldChild
.bottom
-oldChild
.top
!= lpBand
->rcChild
.bottom
-lpBand
->rcChild
.top
))) {
1018 TRACE("Child rectangle changed for band %u\n", i
);
1019 TRACE(" from (%ld,%ld)-(%ld,%ld) to (%ld,%ld)-(%ld,%ld)\n",
1020 oldChild
.left
, oldChild
.top
,
1021 oldChild
.right
, oldChild
.bottom
,
1022 lpBand
->rcChild
.left
, lpBand
->rcChild
.top
,
1023 lpBand
->rcChild
.right
, lpBand
->rcChild
.bottom
);
1025 if (lpBand
->fDraw
& NTF_INVALIDATE
) {
1026 TRACE("invalidating (%ld,%ld)-(%ld,%ld)\n",
1027 lpBand
->rcBand
.left
,
1029 lpBand
->rcBand
.right
+ ((lpBand
->fDraw
& DRAW_RIGHTSEP
) ? SEP_WIDTH_SIZE
: 0),
1030 lpBand
->rcBand
.bottom
+ ((lpBand
->fDraw
& DRAW_BOTTOMSEP
) ? SEP_WIDTH_SIZE
: 0));
1031 lpBand
->fDraw
&= ~NTF_INVALIDATE
;
1032 work
= lpBand
->rcBand
;
1033 if (lpBand
->fDraw
& DRAW_RIGHTSEP
) work
.right
+= SEP_WIDTH_SIZE
;
1034 if (lpBand
->fDraw
& DRAW_BOTTOMSEP
) work
.bottom
+= SEP_WIDTH_SIZE
;
1035 InvalidateRect(infoPtr
->hwndSelf
, &work
, TRUE
);
1044 REBAR_CalcVertBand (REBAR_INFO
*infoPtr
, UINT rstart
, UINT rend
, BOOL notify
)
1045 /* Function: this routine initializes all the rectangles in */
1046 /* each band in a row to fit in the adjusted rcBand rect. */
1047 /* *** Supports only Vertical bars. *** */
1052 RECT oldChild
, work
;
1054 /* MS seems to use GetDlgCtrlID() for above GetWindowLong call */
1055 parenthwnd
= GetParent (infoPtr
->hwndSelf
);
1057 for(i
=rstart
; i
<rend
; i
++){
1058 lpBand
= &infoPtr
->bands
[i
];
1059 if (HIDDENBAND(lpBand
)) continue;
1060 oldChild
= lpBand
->rcChild
;
1062 /* set initial gripper rectangle */
1063 SetRect (&lpBand
->rcGripper
, lpBand
->rcBand
.left
, lpBand
->rcBand
.top
,
1064 lpBand
->rcBand
.right
, lpBand
->rcBand
.top
);
1066 /* calculate gripper rectangle */
1067 if (lpBand
->fStatus
& HAS_GRIPPER
) {
1068 lpBand
->fDraw
|= DRAW_GRIPPER
;
1070 if (infoPtr
->dwStyle
& RBS_VERTICALGRIPPER
) {
1071 /* vertical gripper */
1072 lpBand
->rcGripper
.left
+= 3;
1073 lpBand
->rcGripper
.right
= lpBand
->rcGripper
.left
+ GRIPPER_WIDTH
;
1074 lpBand
->rcGripper
.top
+= REBAR_PRE_GRIPPER
;
1075 lpBand
->rcGripper
.bottom
= lpBand
->rcGripper
.top
+ GRIPPER_HEIGHT
;
1077 /* initialize Caption image rectangle */
1078 SetRect (&lpBand
->rcCapImage
, lpBand
->rcBand
.left
,
1079 lpBand
->rcGripper
.bottom
+ REBAR_ALWAYS_SPACE
,
1080 lpBand
->rcBand
.right
,
1081 lpBand
->rcGripper
.bottom
+ REBAR_ALWAYS_SPACE
);
1084 /* horizontal gripper */
1085 lpBand
->rcGripper
.left
+= 2;
1086 lpBand
->rcGripper
.right
-= 2;
1087 lpBand
->rcGripper
.top
+= REBAR_PRE_GRIPPER
;
1088 lpBand
->rcGripper
.bottom
= lpBand
->rcGripper
.top
+ GRIPPER_WIDTH
;
1090 /* initialize Caption image rectangle */
1091 SetRect (&lpBand
->rcCapImage
, lpBand
->rcBand
.left
,
1092 lpBand
->rcGripper
.bottom
+ REBAR_ALWAYS_SPACE
,
1093 lpBand
->rcBand
.right
,
1094 lpBand
->rcGripper
.bottom
+ REBAR_ALWAYS_SPACE
);
1097 else { /* no gripper will be drawn */
1099 if (lpBand
->fStatus
& (HAS_IMAGE
| HAS_TEXT
))
1100 /* if no gripper but either image or text, then leave space */
1101 xoff
= REBAR_ALWAYS_SPACE
;
1102 /* initialize Caption image rectangle */
1103 SetRect (&lpBand
->rcCapImage
,
1104 lpBand
->rcBand
.left
, lpBand
->rcBand
.top
+xoff
,
1105 lpBand
->rcBand
.right
, lpBand
->rcBand
.top
+xoff
);
1108 /* image is visible */
1109 if (lpBand
->fStatus
& HAS_IMAGE
) {
1110 lpBand
->fDraw
|= DRAW_IMAGE
;
1112 lpBand
->rcCapImage
.right
= lpBand
->rcCapImage
.left
+ infoPtr
->imageSize
.cx
;
1113 lpBand
->rcCapImage
.bottom
+= infoPtr
->imageSize
.cy
;
1115 /* set initial caption text rectangle */
1116 SetRect (&lpBand
->rcCapText
,
1117 lpBand
->rcBand
.left
, lpBand
->rcCapImage
.bottom
+REBAR_POST_IMAGE
,
1118 lpBand
->rcBand
.right
, lpBand
->rcBand
.top
+lpBand
->cxHeader
);
1119 /* update band height *
1120 if (lpBand->uMinHeight < infoPtr->imageSize.cx + 2) {
1121 lpBand->uMinHeight = infoPtr->imageSize.cx + 2;
1122 lpBand->rcBand.right = lpBand->rcBand.left + lpBand->uMinHeight;
1126 /* set initial caption text rectangle */
1127 SetRect (&lpBand
->rcCapText
,
1128 lpBand
->rcBand
.left
, lpBand
->rcCapImage
.bottom
,
1129 lpBand
->rcBand
.right
, lpBand
->rcBand
.top
+lpBand
->cxHeader
);
1132 /* text is visible */
1133 if (lpBand
->fStatus
& HAS_TEXT
) {
1134 lpBand
->fDraw
|= DRAW_TEXT
;
1135 lpBand
->rcCapText
.bottom
= max(lpBand
->rcCapText
.top
,
1136 lpBand
->rcCapText
.bottom
);
1139 /* set initial child window rectangle if there is a child */
1140 if (lpBand
->fMask
& RBBIM_CHILD
) {
1141 yoff
= lpBand
->offChild
.cx
;
1142 xoff
= lpBand
->offChild
.cy
;
1143 SetRect (&lpBand
->rcChild
,
1144 lpBand
->rcBand
.left
+xoff
, lpBand
->rcBand
.top
+lpBand
->cxHeader
,
1145 lpBand
->rcBand
.right
-xoff
, lpBand
->rcBand
.bottom
-yoff
);
1148 SetRect (&lpBand
->rcChild
,
1149 lpBand
->rcBand
.left
, lpBand
->rcBand
.top
+lpBand
->cxHeader
,
1150 lpBand
->rcBand
.right
, lpBand
->rcBand
.bottom
);
1153 /* flag if notify required and invalidate rectangle */
1155 ((oldChild
.right
-oldChild
.left
!= lpBand
->rcChild
.right
-lpBand
->rcChild
.left
) ||
1156 (oldChild
.bottom
-oldChild
.top
!= lpBand
->rcChild
.bottom
-lpBand
->rcChild
.top
))) {
1157 TRACE("Child rectangle changed for band %u\n", i
);
1158 TRACE(" from (%ld,%ld)-(%ld,%ld) to (%ld,%ld)-(%ld,%ld)\n",
1159 oldChild
.left
, oldChild
.top
,
1160 oldChild
.right
, oldChild
.bottom
,
1161 lpBand
->rcChild
.left
, lpBand
->rcChild
.top
,
1162 lpBand
->rcChild
.right
, lpBand
->rcChild
.bottom
);
1164 if (lpBand
->fDraw
& NTF_INVALIDATE
) {
1165 TRACE("invalidating (%ld,%ld)-(%ld,%ld)\n",
1166 lpBand
->rcBand
.left
,
1168 lpBand
->rcBand
.right
+ ((lpBand
->fDraw
& DRAW_BOTTOMSEP
) ? SEP_WIDTH_SIZE
: 0),
1169 lpBand
->rcBand
.bottom
+ ((lpBand
->fDraw
& DRAW_RIGHTSEP
) ? SEP_WIDTH_SIZE
: 0));
1170 lpBand
->fDraw
&= ~NTF_INVALIDATE
;
1171 work
= lpBand
->rcBand
;
1172 if (lpBand
->fDraw
& DRAW_RIGHTSEP
) work
.bottom
+= SEP_WIDTH_SIZE
;
1173 if (lpBand
->fDraw
& DRAW_BOTTOMSEP
) work
.right
+= SEP_WIDTH_SIZE
;
1174 InvalidateRect(infoPtr
->hwndSelf
, &work
, TRUE
);
1182 REBAR_ForceResize (REBAR_INFO
*infoPtr
)
1183 /* Function: This changes the size of the REBAR window to that */
1184 /* calculated by REBAR_Layout. */
1187 INT x
, y
, width
, height
;
1188 INT xedge
= GetSystemMetrics(SM_CXEDGE
);
1189 INT yedge
= GetSystemMetrics(SM_CYEDGE
);
1191 /* TEST TEST TEST */
1192 GetWindowRect (infoPtr
->hwndSelf
, &rc
);
1193 /* END TEST END TEST END TEST */
1196 GetClientRect (infoPtr
->hwndSelf
, &rc
);
1198 TRACE( " old [%ld x %ld], new [%ld x %ld], client [%ld x %ld]\n",
1199 infoPtr
->oldSize
.cx
, infoPtr
->oldSize
.cy
,
1200 infoPtr
->calcSize
.cx
, infoPtr
->calcSize
.cy
,
1201 rc
.right
, rc
.bottom
);
1203 /* If we need to shrink client, then skip size test */
1204 if ((infoPtr
->calcSize
.cy
>= rc
.bottom
) &&
1205 (infoPtr
->calcSize
.cx
>= rc
.right
)) {
1207 /* if size did not change then skip process */
1208 if ((infoPtr
->oldSize
.cx
== infoPtr
->calcSize
.cx
) &&
1209 (infoPtr
->oldSize
.cy
== infoPtr
->calcSize
.cy
) &&
1210 !(infoPtr
->fStatus
& RESIZE_ANYHOW
))
1212 TRACE("skipping reset\n");
1217 infoPtr
->fStatus
&= ~RESIZE_ANYHOW
;
1218 /* Set flag to ignore next WM_SIZE message */
1219 infoPtr
->fStatus
|= AUTO_RESIZE
;
1226 if (infoPtr
->dwStyle
& WS_BORDER
) {
1231 if (!(infoPtr
->dwStyle
& CCS_NOPARENTALIGN
)) {
1232 INT mode
= infoPtr
->dwStyle
& (CCS_VERT
| CCS_TOP
| CCS_BOTTOM
);
1235 GetClientRect(GetParent(infoPtr
->hwndSelf
), &rcPcl
);
1238 /* _TOP sets width to parents width */
1239 width
+= (rcPcl
.right
- rcPcl
.left
);
1240 height
+= infoPtr
->calcSize
.cy
;
1241 x
+= ((infoPtr
->dwStyle
& WS_BORDER
) ? -xedge
: 0);
1242 y
+= ((infoPtr
->dwStyle
& WS_BORDER
) ? -yedge
: 0);
1243 y
+= ((infoPtr
->dwStyle
& CCS_NODIVIDER
) ? 0 : REBAR_DIVIDER
);
1246 /* FIXME: wrong wrong wrong */
1247 /* _BOTTOM sets width to parents width */
1248 width
+= (rcPcl
.right
- rcPcl
.left
);
1249 height
+= infoPtr
->calcSize
.cy
;
1251 y
= rcPcl
.bottom
- height
+ 1;
1254 /* _LEFT sets height to parents height */
1255 width
+= infoPtr
->calcSize
.cx
;
1256 height
+= (rcPcl
.bottom
- rcPcl
.top
);
1257 x
+= ((infoPtr
->dwStyle
& WS_BORDER
) ? -xedge
: 0);
1258 x
+= ((infoPtr
->dwStyle
& CCS_NODIVIDER
) ? 0 : REBAR_DIVIDER
);
1259 y
+= ((infoPtr
->dwStyle
& WS_BORDER
) ? -yedge
: 0);
1262 /* FIXME: wrong wrong wrong */
1263 /* _RIGHT sets height to parents height */
1264 width
+= infoPtr
->calcSize
.cx
;
1265 height
+= (rcPcl
.bottom
- rcPcl
.top
);
1266 x
= rcPcl
.right
- width
+ 1;
1270 width
+= infoPtr
->calcSize
.cx
;
1271 height
+= infoPtr
->calcSize
.cy
;
1275 width
+= infoPtr
->calcSize
.cx
;
1276 height
+= infoPtr
->calcSize
.cy
;
1277 x
= infoPtr
->origin
.x
;
1278 y
= infoPtr
->origin
.y
;
1281 TRACE("hwnd %p, style=%08lx, setting at (%d,%d) for (%d,%d)\n",
1282 infoPtr
->hwndSelf
, infoPtr
->dwStyle
,
1283 x
, y
, width
, height
);
1284 SetWindowPos (infoPtr
->hwndSelf
, 0, x
, y
, width
, height
,
1290 REBAR_MoveChildWindows (REBAR_INFO
*infoPtr
, UINT start
, UINT endplus
)
1293 CHAR szClassName
[40];
1295 NMREBARCHILDSIZE rbcz
;
1299 if (!(deferpos
= BeginDeferWindowPos(infoPtr
->uNumBands
)))
1300 ERR("BeginDeferWindowPos returned NULL\n");
1302 for (i
= start
; i
< endplus
; i
++) {
1303 lpBand
= &infoPtr
->bands
[i
];
1305 if (HIDDENBAND(lpBand
)) continue;
1306 if (lpBand
->hwndChild
) {
1307 TRACE("hwndChild = %p\n", lpBand
->hwndChild
);
1309 /* Always geterate the RBN_CHILDSIZE even it child
1312 rbcz
.wID
= lpBand
->wID
;
1313 rbcz
.rcChild
= lpBand
->rcChild
;
1314 rbcz
.rcBand
= lpBand
->rcBand
;
1315 if (infoPtr
->dwStyle
& CCS_VERT
)
1316 rbcz
.rcBand
.top
+= lpBand
->cxHeader
;
1318 rbcz
.rcBand
.left
+= lpBand
->cxHeader
;
1319 REBAR_Notify ((NMHDR
*)&rbcz
, infoPtr
, RBN_CHILDSIZE
);
1320 if (!EqualRect (&lpBand
->rcChild
, &rbcz
.rcChild
)) {
1321 TRACE("Child rect changed by NOTIFY for band %u\n", i
);
1322 TRACE(" from (%ld,%ld)-(%ld,%ld) to (%ld,%ld)-(%ld,%ld)\n",
1323 lpBand
->rcChild
.left
, lpBand
->rcChild
.top
,
1324 lpBand
->rcChild
.right
, lpBand
->rcChild
.bottom
,
1325 rbcz
.rcChild
.left
, rbcz
.rcChild
.top
,
1326 rbcz
.rcChild
.right
, rbcz
.rcChild
.bottom
);
1327 lpBand
->rcChild
= rbcz
.rcChild
; /* *** ??? */
1330 /* native (IE4 in "Favorites" frame **1) does:
1331 * SetRect (&rc, -1, -1, -1, -1)
1332 * EqualRect (&rc,band->rc???)
1334 * CopyRect (band->rc????, &rc)
1335 * set flag outside of loop
1338 GetClassNameA (lpBand
->hwndChild
, szClassName
, 40);
1339 if (!lstrcmpA (szClassName
, "ComboBox") ||
1340 !lstrcmpA (szClassName
, WC_COMBOBOXEXA
)) {
1341 INT nEditHeight
, yPos
;
1344 /* special placement code for combo or comboex box */
1347 /* get size of edit line */
1348 GetWindowRect (lpBand
->hwndChild
, &rc
);
1349 nEditHeight
= rc
.bottom
- rc
.top
;
1350 yPos
= (lpBand
->rcChild
.bottom
+ lpBand
->rcChild
.top
- nEditHeight
)/2;
1352 /* center combo box inside child area */
1353 TRACE("moving child (Combo(Ex)) %p to (%ld,%d) for (%ld,%d)\n",
1355 lpBand
->rcChild
.left
, yPos
,
1356 lpBand
->rcChild
.right
- lpBand
->rcChild
.left
,
1358 deferpos
= DeferWindowPos (deferpos
, lpBand
->hwndChild
, HWND_TOP
,
1359 lpBand
->rcChild
.left
,
1360 /*lpBand->rcChild.top*/ yPos
,
1361 lpBand
->rcChild
.right
- lpBand
->rcChild
.left
,
1365 ERR("DeferWindowPos returned NULL\n");
1368 TRACE("moving child (Other) %p to (%ld,%ld) for (%ld,%ld)\n",
1370 lpBand
->rcChild
.left
, lpBand
->rcChild
.top
,
1371 lpBand
->rcChild
.right
- lpBand
->rcChild
.left
,
1372 lpBand
->rcChild
.bottom
- lpBand
->rcChild
.top
);
1373 deferpos
= DeferWindowPos (deferpos
, lpBand
->hwndChild
, HWND_TOP
,
1374 lpBand
->rcChild
.left
,
1375 lpBand
->rcChild
.top
,
1376 lpBand
->rcChild
.right
- lpBand
->rcChild
.left
,
1377 lpBand
->rcChild
.bottom
- lpBand
->rcChild
.top
,
1380 ERR("DeferWindowPos returned NULL\n");
1384 if (!EndDeferWindowPos(deferpos
))
1385 ERR("EndDeferWindowPos returned NULL\n");
1387 if (infoPtr
->DoRedraw
)
1388 UpdateWindow (infoPtr
->hwndSelf
);
1390 if (infoPtr
->fStatus
& NTF_HGHTCHG
) {
1391 infoPtr
->fStatus
&= ~NTF_HGHTCHG
;
1392 REBAR_Notify (&heightchange
, infoPtr
, RBN_HEIGHTCHANGE
);
1395 /* native (from **1 above) does:
1396 * UpdateWindow(rebar)
1398 * RBN_HEIGHTCHANGE if necessary
1399 * if ret from any EqualRect was 0
1400 * Goto "BeginDeferWindowPos"
1407 REBAR_Layout (REBAR_INFO
*infoPtr
, LPRECT lpRect
, BOOL notify
, BOOL resetclient
)
1408 /* Function: This routine is resposible for laying out all */
1409 /* the bands in a rebar. It assigns each band to a row and*/
1410 /* determines when to start a new row. */
1412 REBAR_BAND
*lpBand
, *prevBand
;
1413 RECT rcClient
, rcAdj
;
1414 INT initx
, inity
, x
, y
, cx
, cxsep
, mmcy
, mcy
, clientcx
, clientcy
;
1415 INT adjcx
, adjcy
, row
, rightx
, bottomy
, origheight
;
1416 UINT i
, j
, rowstart
, origrows
, cntonrow
;
1419 if (!(infoPtr
->fStatus
& BAND_NEEDS_LAYOUT
)) {
1420 TRACE("no layout done. No band changed.\n");
1421 REBAR_DumpBand (infoPtr
);
1424 infoPtr
->fStatus
&= ~BAND_NEEDS_LAYOUT
;
1425 if (!infoPtr
->DoRedraw
) infoPtr
->fStatus
|= BAND_NEEDS_REDRAW
;
1427 GetClientRect (infoPtr
->hwndSelf
, &rcClient
);
1428 TRACE("Client is (%ld,%ld)-(%ld,%ld)\n",
1429 rcClient
.left
, rcClient
.top
, rcClient
.right
, rcClient
.bottom
);
1433 TRACE("adjustment rect is (%ld,%ld)-(%ld,%ld)\n",
1434 rcAdj
.left
, rcAdj
.top
, rcAdj
.right
, rcAdj
.bottom
);
1437 CopyRect (&rcAdj
, &rcClient
);
1440 clientcx
= rcClient
.right
- rcClient
.left
;
1441 clientcy
= rcClient
.bottom
- rcClient
.top
;
1442 adjcx
= rcAdj
.right
- rcAdj
.left
;
1443 adjcy
= rcAdj
.bottom
- rcAdj
.top
;
1445 TRACE("window client rect will be set to adj rect\n");
1450 if (!infoPtr
->DoRedraw
&& (clientcx
== 0) && (clientcy
== 0)) {
1451 ERR("no redraw and client is zero, skip layout\n");
1452 infoPtr
->fStatus
|= BAND_NEEDS_LAYOUT
;
1456 /* save height of original control */
1457 if (infoPtr
->dwStyle
& CCS_VERT
)
1458 origheight
= infoPtr
->calcSize
.cx
;
1460 origheight
= infoPtr
->calcSize
.cy
;
1461 origrows
= infoPtr
->uNumRows
;
1466 /* ******* Start Phase 1 - all bands on row at minimum size ******* */
1468 TRACE("band loop constants, clientcx=%d, clientcy=%d, adjcx=%d, adjcy=%d\n",
1469 clientcx
, clientcy
, adjcx
, adjcy
);
1479 for (i
= 0; i
< infoPtr
->uNumBands
; i
++) {
1480 lpBand
= &infoPtr
->bands
[i
];
1484 SetRectEmpty(&lpBand
->rcChevron
);
1486 if (HIDDENBAND(lpBand
)) continue;
1488 lpBand
->rcoldBand
= lpBand
->rcBand
;
1490 /* Set the offset of the child window */
1491 if ((lpBand
->fMask
& RBBIM_CHILD
) &&
1492 !(lpBand
->fStyle
& RBBS_FIXEDSIZE
)) {
1493 lpBand
->offChild
.cx
= ((lpBand
->fStyle
& RBBS_CHILDEDGE
) ? 4 : 0);
1495 lpBand
->offChild
.cy
= ((lpBand
->fStyle
& RBBS_CHILDEDGE
) ? 2 : 0);
1497 /* separator from previous band */
1498 cxsep
= (cntonrow
== 0) ? 0 : SEP_WIDTH
;
1500 /* Header: includes gripper, text, image */
1501 cx
= lpBand
->cxHeader
;
1502 if (lpBand
->fStyle
& RBBS_FIXEDSIZE
) cx
= lpBand
->lcx
;
1504 if (infoPtr
->dwStyle
& CCS_VERT
)
1505 dobreak
= (y
+ cx
+ cxsep
> adjcy
);
1507 dobreak
= (x
+ cx
+ cxsep
> adjcx
);
1509 /* This is the check for whether we need to start a new row */
1510 if ( ( (lpBand
->fStyle
& RBBS_BREAK
) && (i
!= 0) ) ||
1511 ( ((infoPtr
->dwStyle
& CCS_VERT
) ? (y
!= 0) : (x
!= 0)) && dobreak
)) {
1513 for (j
= rowstart
; j
< i
; j
++) {
1515 lpB
= &infoPtr
->bands
[j
];
1516 if (infoPtr
->dwStyle
& CCS_VERT
) {
1517 lpB
->rcBand
.right
= lpB
->rcBand
.left
+ mcy
;
1520 lpB
->rcBand
.bottom
= lpB
->rcBand
.top
+ mcy
;
1524 TRACE("P1 Spliting to new row %d on band %u\n", row
+1, i
);
1525 if (infoPtr
->dwStyle
& CCS_VERT
) {
1527 x
+= (mcy
+ SEP_WIDTH
);
1531 y
+= (mcy
+ SEP_WIDTH
);
1543 if (mcy
< lpBand
->lcy
+ REBARSPACE(lpBand
))
1544 mcy
= lpBand
->lcy
+ REBARSPACE(lpBand
);
1546 /* if boundary rect specified then limit mcy */
1548 if (infoPtr
->dwStyle
& CCS_VERT
) {
1549 if (x
+mcy
> adjcx
) {
1551 TRACE("P1 row %u limiting mcy=%d, adjcx=%d, x=%d\n",
1556 if (y
+mcy
> adjcy
) {
1558 TRACE("P1 row %u limiting mcy=%d, adjcy=%d, y=%d\n",
1564 TRACE("P1 band %u, row %d, x=%d, y=%d, cxsep=%d, cx=%d\n",
1567 if (infoPtr
->dwStyle
& CCS_VERT
) {
1568 /* bound the bottom side if we have a bounding rectangle */
1570 bottomy
= (lpRect
) ? min(clientcy
, y
+cxsep
+cx
) : y
+cxsep
+cx
;
1571 lpBand
->rcBand
.left
= x
;
1572 lpBand
->rcBand
.right
= x
+ min(mcy
,
1573 lpBand
->lcy
+REBARSPACE(lpBand
));
1574 lpBand
->rcBand
.top
= min(bottomy
, y
+ cxsep
);
1575 lpBand
->rcBand
.bottom
= bottomy
;
1576 lpBand
->uMinHeight
= lpBand
->lcy
;
1580 /* bound the right side if we have a bounding rectangle */
1581 rightx
= (lpRect
) ? min(clientcx
, x
+cxsep
+cx
) : x
+cxsep
+cx
;
1583 lpBand
->rcBand
.left
= min(rightx
, x
+ cxsep
);
1584 lpBand
->rcBand
.right
= rightx
;
1585 lpBand
->rcBand
.top
= y
;
1586 lpBand
->rcBand
.bottom
= y
+ min(mcy
,
1587 lpBand
->lcy
+REBARSPACE(lpBand
));
1588 lpBand
->uMinHeight
= lpBand
->lcy
;
1591 TRACE("P1 band %u, row %d, (%ld,%ld)-(%ld,%ld)\n",
1593 lpBand
->rcBand
.left
, lpBand
->rcBand
.top
,
1594 lpBand
->rcBand
.right
, lpBand
->rcBand
.bottom
);
1598 } /* for (i = 0; i < infoPtr->uNumBands... */
1600 if (infoPtr
->dwStyle
& CCS_VERT
)
1605 for (j
= rowstart
; j
< infoPtr
->uNumBands
; j
++) {
1606 lpBand
= &infoPtr
->bands
[j
];
1607 if (infoPtr
->dwStyle
& CCS_VERT
) {
1608 lpBand
->rcBand
.right
= lpBand
->rcBand
.left
+ mcy
;
1611 lpBand
->rcBand
.bottom
= lpBand
->rcBand
.top
+ mcy
;
1615 if (infoPtr
->uNumBands
)
1616 infoPtr
->uNumRows
= row
;
1618 /* ******* End Phase 1 - all bands on row at minimum size ******* */
1621 /* ******* Start Phase 1a - Adjust heights for RBS_VARHEIGHT off ******* */
1624 if (!(infoPtr
->dwStyle
& RBS_VARHEIGHT
)) {
1627 /* get the max height of all bands */
1628 for (i
=0; i
<infoPtr
->uNumBands
; i
++) {
1629 lpBand
= &infoPtr
->bands
[i
];
1630 if (HIDDENBAND(lpBand
)) continue;
1631 if (infoPtr
->dwStyle
& CCS_VERT
)
1632 mmcy
= max(mmcy
, lpBand
->rcBand
.right
- lpBand
->rcBand
.left
);
1634 mmcy
= max(mmcy
, lpBand
->rcBand
.bottom
- lpBand
->rcBand
.top
);
1637 /* now adjust all rectangles by using the height found above */
1640 for (i
=0; i
<infoPtr
->uNumBands
; i
++) {
1641 lpBand
= &infoPtr
->bands
[i
];
1642 if (HIDDENBAND(lpBand
)) continue;
1643 if (lpBand
->iRow
!= row
)
1644 xy
+= (mmcy
+ SEP_WIDTH
);
1645 if (infoPtr
->dwStyle
& CCS_VERT
) {
1646 lpBand
->rcBand
.left
= xy
;
1647 lpBand
->rcBand
.right
= xy
+ mmcy
;
1650 lpBand
->rcBand
.top
= xy
;
1651 lpBand
->rcBand
.bottom
= xy
+ mmcy
;
1655 /* set the x/y values to the correct maximum */
1656 if (infoPtr
->dwStyle
& CCS_VERT
)
1662 /* ******* End Phase 1a - Adjust heights for RBS_VARHEIGHT off ******* */
1665 /* ******* Start Phase 2 - split rows till adjustment height full ******* */
1667 /* assumes that the following variables contain: */
1668 /* y/x current height/width of all rows */
1670 INT i
, prev_rh
, new_rh
, adj_rh
, prev_idx
, current_idx
;
1671 REBAR_BAND
*prev
, *current
, *walk
;
1674 /* FIXME: problem # 2 */
1675 if (((infoPtr
->dwStyle
& CCS_VERT
) ?
1677 (x
< adjcx
) : (y
< adjcy
)
1679 (adjcx
- x
> 4) : (adjcy
- y
> 4)
1682 (infoPtr
->uNumBands
> 1)) {
1683 for (i
=(INT
)infoPtr
->uNumBands
-2; i
>=0; i
--) {
1684 TRACE("P2 adjcx=%d, adjcy=%d, x=%d, y=%d\n",
1685 adjcx
, adjcy
, x
, y
);
1687 /* find the current band (starts at i+1) */
1688 current
= &infoPtr
->bands
[i
+1];
1690 while (HIDDENBAND(current
)) {
1692 if (i
< 0) break; /* out of bands */
1693 current
= &infoPtr
->bands
[i
+1];
1696 if (i
< 0) break; /* out of bands */
1698 /* now find the prev band (starts at i) */
1699 prev
= &infoPtr
->bands
[i
];
1701 while (HIDDENBAND(prev
)) {
1703 if (i
< 0) break; /* out of bands */
1704 prev
= &infoPtr
->bands
[i
];
1707 if (i
< 0) break; /* out of bands */
1709 prev_rh
= ircBw(prev
);
1710 if (prev
->iRow
== current
->iRow
) {
1711 new_rh
= (infoPtr
->dwStyle
& RBS_VARHEIGHT
) ?
1712 current
->lcy
+ REBARSPACE(current
) :
1714 adj_rh
= new_rh
+ SEP_WIDTH
;
1715 infoPtr
->uNumRows
++;
1716 current
->fDraw
|= NTF_INVALIDATE
;
1718 if (infoPtr
->dwStyle
& CCS_VERT
) {
1719 current
->rcBand
.top
= inity
;
1720 current
->rcBand
.bottom
= clientcy
;
1721 current
->rcBand
.left
+= (prev_rh
+ SEP_WIDTH
);
1722 current
->rcBand
.right
= current
->rcBand
.left
+ new_rh
;
1726 current
->rcBand
.left
= initx
;
1727 current
->rcBand
.right
= clientcx
;
1728 current
->rcBand
.top
+= (prev_rh
+ SEP_WIDTH
);
1729 current
->rcBand
.bottom
= current
->rcBand
.top
+ new_rh
;
1732 TRACE("P2 moving band %d to own row at (%ld,%ld)-(%ld,%ld)\n",
1734 current
->rcBand
.left
, current
->rcBand
.top
,
1735 current
->rcBand
.right
, current
->rcBand
.bottom
);
1736 TRACE("P2 prev band %d at (%ld,%ld)-(%ld,%ld)\n",
1738 prev
->rcBand
.left
, prev
->rcBand
.top
,
1739 prev
->rcBand
.right
, prev
->rcBand
.bottom
);
1740 TRACE("P2 values: prev_rh=%d, new_rh=%d, adj_rh=%d\n",
1741 prev_rh
, new_rh
, adj_rh
);
1742 /* for bands below current adjust row # and top/bottom */
1743 for (j
= current_idx
+1; j
<infoPtr
->uNumBands
; j
++) {
1744 walk
= &infoPtr
->bands
[j
];
1745 if (HIDDENBAND(walk
)) continue;
1746 walk
->fDraw
|= NTF_INVALIDATE
;
1748 if (infoPtr
->dwStyle
& CCS_VERT
) {
1749 walk
->rcBand
.left
+= adj_rh
;
1750 walk
->rcBand
.right
+= adj_rh
;
1753 walk
->rcBand
.top
+= adj_rh
;
1754 walk
->rcBand
.bottom
+= adj_rh
;
1757 if ((infoPtr
->dwStyle
& CCS_VERT
) ? (x
>= adjcx
) : (y
>= adjcy
))
1758 break; /* all done */
1764 /* ******* End Phase 2 - split rows till adjustment height full ******* */
1767 /* ******* Start Phase 2a - create array of start and end ******* */
1768 /* indexes by row */
1770 if (infoPtr
->uNumRows
!= origrows
) {
1771 if (infoPtr
->rows
) Free (infoPtr
->rows
);
1772 infoPtr
->rows
= Alloc (sizeof (REBAR_ROW
) * infoPtr
->uNumRows
);
1776 for (i
= 0; i
< infoPtr
->uNumBands
; i
++) {
1777 lpBand
= &infoPtr
->bands
[i
];
1778 if (HIDDENBAND(lpBand
)) continue;
1780 if (lpBand
->iRow
> row
) {
1782 infoPtr
->rows
[row
-1].istartband
= i
;
1785 ERR("P2a bug!!!!!!\n");
1787 infoPtr
->rows
[row
-1].iendband
= i
;
1790 for (i
= 0; i
< infoPtr
->uNumRows
; i
++) {
1793 p
= &infoPtr
->rows
[i
];
1794 TRACE("P2a row %d, starts %d, ends %d\n",
1795 i
+1, p
->istartband
, p
->iendband
);
1798 /* ******* End Phase 2a - create array of start and end ******* */
1799 /* indexes by row */
1802 /* ******* Start Phase 2b - adjust all bands for height full ******* */
1803 /* assumes that the following variables contain: */
1804 /* y/x current height/width of all rows */
1805 /* clientcy/clientcx height/width of client area */
1807 if (((infoPtr
->dwStyle
& CCS_VERT
) ? clientcx
> x
: clientcy
> y
) &&
1808 infoPtr
->uNumBands
) {
1812 diff
= (infoPtr
->dwStyle
& CCS_VERT
) ? clientcx
- x
: clientcy
- y
;
1813 for (i
= infoPtr
->uNumRows
; i
>= 1; i
--) {
1814 /* if row has more than 1 band, ignore row */
1815 if (infoPtr
->rows
[i
-1].istartband
!= infoPtr
->rows
[i
-1].iendband
)
1817 /* point to only band in row */
1818 iband
= infoPtr
->rows
[i
-1].istartband
;
1819 lpBand
= &infoPtr
->bands
[iband
];
1820 if(HIDDENBAND(lpBand
)) continue;
1821 if (lpBand
->fMask
& RBBS_VARIABLEHEIGHT
) continue;
1822 if (((INT
)lpBand
->cyMaxChild
< 1) ||
1823 ((INT
)lpBand
->cyIntegral
< 1)) {
1824 if (lpBand
->cyMaxChild
+ lpBand
->cyIntegral
== 0) continue;
1825 ERR("P2b band %u RBBS_VARIABLEHEIGHT set but cyMax=%d, cyInt=%d\n",
1826 iband
, lpBand
->cyMaxChild
, lpBand
->cyIntegral
);
1829 /* j is now the maximum height/width in the client area */
1830 j
= ((diff
/ lpBand
->cyIntegral
) * lpBand
->cyIntegral
) +
1832 if (j
> lpBand
->cyMaxChild
+ REBARSPACE(lpBand
))
1833 j
= lpBand
->cyMaxChild
+ REBARSPACE(lpBand
);
1834 diff
-= (j
- ircBw(lpBand
));
1835 if (infoPtr
->dwStyle
& CCS_VERT
)
1836 lpBand
->rcBand
.right
= lpBand
->rcBand
.left
+ j
;
1838 lpBand
->rcBand
.bottom
= lpBand
->rcBand
.top
+ j
;
1839 TRACE("P2b band %d, row %d changed to (%ld,%ld)-(%ld,%ld)\n",
1840 iband
, lpBand
->iRow
,
1841 lpBand
->rcBand
.left
, lpBand
->rcBand
.top
,
1842 lpBand
->rcBand
.right
, lpBand
->rcBand
.bottom
);
1843 if (diff
<= 0) break;
1846 ERR("P2b allocated more than available, diff=%d\n", diff
);
1849 if (infoPtr
->dwStyle
& CCS_VERT
)
1850 x
= clientcx
- diff
;
1852 y
= clientcy
- diff
;
1855 /* ******* End Phase 2b - adjust all bands for height full ******* */
1858 /* ******* Start Phase 3 - adjust all bands for width full ******* */
1860 if (infoPtr
->uNumBands
) {
1863 /* If RBS_BANDBORDERS set then indicate to draw bottom separator */
1864 /* on all bands in all rows but last row. */
1865 /* Also indicate to draw the right separator for each band in */
1866 /* each row but the rightmost band. */
1867 if (infoPtr
->dwStyle
& RBS_BANDBORDERS
) {
1869 for(i
= 0; i
< infoPtr
->uNumRows
; i
++) {
1870 p
= &infoPtr
->rows
[i
];
1871 for (j
= p
->istartband
; j
<= p
->iendband
; j
++) {
1872 lpBand
= &infoPtr
->bands
[j
];
1873 if (HIDDENBAND(lpBand
)) continue;
1874 if (j
!= p
->iendband
)
1875 lpBand
->fDraw
|= DRAW_RIGHTSEP
;
1876 if (i
!= infoPtr
->uNumRows
-1)
1877 lpBand
->fDraw
|= DRAW_BOTTOMSEP
;
1882 /* Distribute the extra space on the horizontal and adjust */
1883 /* all bands in row to same height. */
1884 for (i
=1; i
<=infoPtr
->uNumRows
; i
++) {
1885 p
= &infoPtr
->rows
[i
-1];
1888 TRACE("P3 processing row %d, starting band %d, ending band %d\n",
1889 i
, p
->istartband
, p
->iendband
);
1891 /* Find the largest height of the bands in the row */
1892 for (j
= p
->istartband
; j
<= p
->iendband
; j
++) {
1893 lpBand
= &infoPtr
->bands
[j
];
1894 if (HIDDENBAND(lpBand
)) continue;
1895 if (mcy
< ircBw(lpBand
))
1896 mcy
= ircBw(lpBand
);
1899 REBAR_AdjustBands (infoPtr
, p
->istartband
, p
->iendband
,
1900 (infoPtr
->dwStyle
& CCS_VERT
) ?
1901 clientcy
: clientcx
, mcy
);
1904 /* Calculate the other rectangles in each band */
1905 if (infoPtr
->dwStyle
& CCS_VERT
) {
1906 REBAR_CalcVertBand (infoPtr
, 0, infoPtr
->uNumBands
,
1910 REBAR_CalcHorzBand (infoPtr
, 0, infoPtr
->uNumBands
,
1915 /* ******* End Phase 3 - adjust all bands for width full ******* */
1917 /* now compute size of Rebar itself */
1918 infoPtr
->oldSize
= infoPtr
->calcSize
;
1919 if (infoPtr
->uNumBands
== 0) {
1920 /* we have no bands, so make size the size of client */
1924 if (infoPtr
->dwStyle
& CCS_VERT
) {
1925 infoPtr
->calcSize
.cx
= x
;
1926 infoPtr
->calcSize
.cy
= clientcy
;
1927 TRACE("vert, notify=%d, x=%d, origheight=%d\n",
1928 notify
, x
, origheight
);
1929 if (notify
&& (x
!= origheight
)) infoPtr
->fStatus
|= NTF_HGHTCHG
;
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 preceed 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 HDC hdc
= GetDC (0);
2034 HFONT hOldFont
= SelectObject (hdc
, infoPtr
->hFont
);
2037 lpBand
->fStatus
|= HAS_TEXT
;
2038 GetTextExtentPoint32W (hdc
, lpBand
->lpText
,
2039 lstrlenW (lpBand
->lpText
), &size
);
2040 header
+= ((infoPtr
->dwStyle
& CCS_VERT
) ? (size
.cy
+ REBAR_POST_TEXT
) : (size
.cx
+ REBAR_POST_TEXT
));
2041 textheight
= (infoPtr
->dwStyle
& CCS_VERT
) ? 0 : size
.cy
;
2043 SelectObject (hdc
, hOldFont
);
2047 /* if no gripper but either image or text, then leave space */
2048 if ((lpBand
->fStatus
& (HAS_IMAGE
| HAS_TEXT
)) &&
2049 !(lpBand
->fStatus
& HAS_GRIPPER
)) {
2050 header
+= REBAR_ALWAYS_SPACE
;
2053 /* check if user overrode the header value */
2054 if (!(lpBand
->fMask
& RBBIM_HEADERSIZE
))
2055 lpBand
->cxHeader
= header
;
2058 /* Now compute minimum size of child window */
2059 lpBand
->offChild
.cx
= 0;
2060 lpBand
->offChild
.cy
= 0;
2061 lpBand
->lcy
= textheight
;
2062 lpBand
->ccy
= lpBand
->lcy
;
2063 if (lpBand
->fMask
& RBBIM_CHILDSIZE
) {
2064 lpBand
->lcx
= lpBand
->cxMinChild
;
2066 /* Set the .cy values for CHILDSIZE case */
2067 lpBand
->lcy
= max(lpBand
->lcy
, lpBand
->cyMinChild
);
2068 lpBand
->ccy
= lpBand
->lcy
;
2069 lpBand
->hcy
= lpBand
->lcy
;
2070 if (lpBand
->cyMaxChild
!= 0xffffffff) {
2071 lpBand
->hcy
= lpBand
->cyMaxChild
;
2073 if (lpBand
->cyChild
!= 0xffffffff)
2074 lpBand
->ccy
= max (lpBand
->cyChild
, lpBand
->lcy
);
2076 TRACE("_CHILDSIZE\n");
2078 if (lpBand
->fMask
& RBBIM_SIZE
) {
2079 lpBand
->hcx
= max (lpBand
->cx
-lpBand
->cxHeader
, lpBand
->lcx
);
2083 lpBand
->hcx
= lpBand
->lcx
;
2084 lpBand
->ccx
= lpBand
->hcx
;
2086 /* make ->.cx include header size for _Layout */
2087 lpBand
->lcx
+= lpBand
->cxHeader
;
2088 lpBand
->ccx
+= lpBand
->cxHeader
;
2089 lpBand
->hcx
+= lpBand
->cxHeader
;
2094 REBAR_CommonSetupBand (HWND hwnd
, LPREBARBANDINFOA lprbbi
, REBAR_BAND
*lpBand
)
2095 /* Function: This routine copies the supplied values from */
2096 /* user input (lprbbi) to the internal band structure. */
2097 /* It returns true if something changed and false if not. */
2099 BOOL bChanged
= FALSE
;
2101 lpBand
->fMask
|= lprbbi
->fMask
;
2103 if( (lprbbi
->fMask
& RBBIM_STYLE
) &&
2104 (lpBand
->fStyle
!= lprbbi
->fStyle
) )
2106 lpBand
->fStyle
= lprbbi
->fStyle
;
2110 if( (lprbbi
->fMask
& RBBIM_COLORS
) &&
2111 ( ( lpBand
->clrFore
!= lprbbi
->clrFore
) ||
2112 ( lpBand
->clrBack
!= lprbbi
->clrBack
) ) )
2114 lpBand
->clrFore
= lprbbi
->clrFore
;
2115 lpBand
->clrBack
= lprbbi
->clrBack
;
2119 if( (lprbbi
->fMask
& RBBIM_IMAGE
) &&
2120 ( lpBand
->iImage
!= lprbbi
->iImage
) )
2122 lpBand
->iImage
= lprbbi
->iImage
;
2126 if( (lprbbi
->fMask
& RBBIM_CHILD
) &&
2127 (lprbbi
->hwndChild
!= lpBand
->hwndChild
) )
2129 if (lprbbi
->hwndChild
) {
2130 lpBand
->hwndChild
= lprbbi
->hwndChild
;
2131 lpBand
->hwndPrevParent
=
2132 SetParent (lpBand
->hwndChild
, hwnd
);
2133 /* below in trace fro WinRAR */
2134 ShowWindow(lpBand
->hwndChild
, SW_SHOWNOACTIVATE
| SW_SHOWNORMAL
);
2135 /* above in trace fro WinRAR */
2138 TRACE("child: %p prev parent: %p\n",
2139 lpBand
->hwndChild
, lpBand
->hwndPrevParent
);
2140 lpBand
->hwndChild
= 0;
2141 lpBand
->hwndPrevParent
= 0;
2146 if( (lprbbi
->fMask
& RBBIM_CHILDSIZE
) &&
2147 ( (lpBand
->cxMinChild
!= lprbbi
->cxMinChild
) ||
2148 (lpBand
->cyMinChild
!= lprbbi
->cyMinChild
) ||
2149 ( (lprbbi
->cbSize
>= sizeof (REBARBANDINFOA
)) &&
2150 ( (lpBand
->cyChild
!= lprbbi
->cyChild
) ||
2151 (lpBand
->cyMaxChild
!= lprbbi
->cyMaxChild
) ||
2152 (lpBand
->cyIntegral
!= lprbbi
->cyIntegral
) ) ) ||
2153 ( (lprbbi
->cbSize
< sizeof (REBARBANDINFOA
)) &&
2154 ( (lpBand
->cyChild
||
2155 lpBand
->cyMaxChild
||
2156 lpBand
->cyIntegral
) ) ) ) )
2158 lpBand
->cxMinChild
= lprbbi
->cxMinChild
;
2159 lpBand
->cyMinChild
= lprbbi
->cyMinChild
;
2160 if (lprbbi
->cbSize
>= sizeof (REBARBANDINFOA
)) {
2161 lpBand
->cyChild
= lprbbi
->cyChild
;
2162 lpBand
->cyMaxChild
= lprbbi
->cyMaxChild
;
2163 lpBand
->cyIntegral
= lprbbi
->cyIntegral
;
2165 else { /* special case - these should be zeroed out since */
2166 /* RBBIM_CHILDSIZE added these in WIN32_IE >= 0x0400 */
2167 lpBand
->cyChild
= 0;
2168 lpBand
->cyMaxChild
= 0;
2169 lpBand
->cyIntegral
= 0;
2174 if( (lprbbi
->fMask
& RBBIM_SIZE
) &&
2175 (lpBand
->cx
!= lprbbi
->cx
) )
2177 lpBand
->cx
= lprbbi
->cx
;
2181 if( (lprbbi
->fMask
& RBBIM_BACKGROUND
) &&
2182 ( lpBand
->hbmBack
!= lprbbi
->hbmBack
) )
2184 lpBand
->hbmBack
= lprbbi
->hbmBack
;
2188 if( (lprbbi
->fMask
& RBBIM_ID
) &&
2189 (lpBand
->wID
!= lprbbi
->wID
) )
2191 lpBand
->wID
= lprbbi
->wID
;
2195 /* check for additional data */
2196 if (lprbbi
->cbSize
>= sizeof (REBARBANDINFOA
)) {
2197 if( (lprbbi
->fMask
& RBBIM_IDEALSIZE
) &&
2198 ( lpBand
->cxIdeal
!= lprbbi
->cxIdeal
) )
2200 lpBand
->cxIdeal
= lprbbi
->cxIdeal
;
2204 if( (lprbbi
->fMask
& RBBIM_LPARAM
) &&
2205 (lpBand
->lParam
!= lprbbi
->lParam
) )
2207 lpBand
->lParam
= lprbbi
->lParam
;
2211 if( (lprbbi
->fMask
& RBBIM_HEADERSIZE
) &&
2212 (lpBand
->cxHeader
!= lprbbi
->cxHeader
) )
2214 lpBand
->cxHeader
= lprbbi
->cxHeader
;
2223 REBAR_InternalEraseBkGnd (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
, RECT
*clip
)
2224 /* Function: This erases the background rectangle by drawing */
2225 /* each band with its background color (or the default) and */
2226 /* draws each bands right separator if necessary. The row */
2227 /* separators are drawn on the first band of the next row. */
2232 HDC hdc
= (HDC
)wParam
;
2234 COLORREF old
= CLR_NONE
, new;
2237 for(i
=0; i
<infoPtr
->uNumBands
; i
++) {
2238 lpBand
= &infoPtr
->bands
[i
];
2239 if (HIDDENBAND(lpBand
)) continue;
2241 /* draw band separator between rows */
2242 if (lpBand
->iRow
!= oldrow
) {
2243 oldrow
= lpBand
->iRow
;
2244 if (lpBand
->fDraw
& DRAW_BOTTOMSEP
) {
2246 rcRowSep
= lpBand
->rcBand
;
2247 if (infoPtr
->dwStyle
& CCS_VERT
) {
2248 rcRowSep
.right
+= SEP_WIDTH_SIZE
;
2249 rcRowSep
.bottom
= infoPtr
->calcSize
.cy
;
2250 DrawEdge (hdc
, &rcRowSep
, EDGE_ETCHED
, BF_RIGHT
);
2253 rcRowSep
.bottom
+= SEP_WIDTH_SIZE
;
2254 rcRowSep
.right
= infoPtr
->calcSize
.cx
;
2255 DrawEdge (hdc
, &rcRowSep
, EDGE_ETCHED
, BF_BOTTOM
);
2257 TRACE ("drawing band separator bottom (%ld,%ld)-(%ld,%ld)\n",
2258 rcRowSep
.left
, rcRowSep
.top
,
2259 rcRowSep
.right
, rcRowSep
.bottom
);
2263 /* draw band separator between bands in a row */
2264 if (lpBand
->fDraw
& DRAW_RIGHTSEP
) {
2266 rcSep
= lpBand
->rcBand
;
2267 if (infoPtr
->dwStyle
& CCS_VERT
) {
2268 rcSep
.bottom
+= SEP_WIDTH_SIZE
;
2269 DrawEdge (hdc
, &rcSep
, EDGE_ETCHED
, BF_BOTTOM
);
2272 rcSep
.right
+= SEP_WIDTH_SIZE
;
2273 DrawEdge (hdc
, &rcSep
, EDGE_ETCHED
, BF_RIGHT
);
2275 TRACE("drawing band separator right (%ld,%ld)-(%ld,%ld)\n",
2276 rcSep
.left
, rcSep
.top
, rcSep
.right
, rcSep
.bottom
);
2279 /* draw the actual background */
2280 if (lpBand
->clrBack
!= CLR_NONE
) {
2281 new = (lpBand
->clrBack
== CLR_DEFAULT
) ? infoPtr
->clrBtnFace
:
2284 /* testing only - make background green to see it */
2289 /* In the absence of documentation for Rebar vs. CLR_NONE,
2290 * we will use the default BtnFace color. Note documentation
2291 * exists for Listview and Imagelist.
2293 new = infoPtr
->clrBtnFace
;
2295 /* testing only - make background green to see it */
2299 old
= SetBkColor (hdc
, new);
2301 rect
= lpBand
->rcBand
;
2302 TRACE("%s background color=0x%06lx, band (%ld,%ld)-(%ld,%ld), clip (%ld,%ld)-(%ld,%ld)\n",
2303 (lpBand
->clrBack
== CLR_NONE
) ? "none" :
2304 ((lpBand
->clrBack
== CLR_DEFAULT
) ? "dft" : ""),
2306 lpBand
->rcBand
.left
,lpBand
->rcBand
.top
,
2307 lpBand
->rcBand
.right
,lpBand
->rcBand
.bottom
,
2308 clip
->left
, clip
->top
,
2309 clip
->right
, clip
->bottom
);
2310 ExtTextOutA (hdc
, 0, 0, ETO_OPAQUE
, &rect
, NULL
, 0, 0);
2311 if (lpBand
->clrBack
!= CLR_NONE
)
2312 SetBkColor (hdc
, old
);
2318 REBAR_InternalHitTest (REBAR_INFO
*infoPtr
, const LPPOINT lpPt
, UINT
*pFlags
, INT
*pBand
)
2324 GetClientRect (infoPtr
->hwndSelf
, &rect
);
2326 *pFlags
= RBHT_NOWHERE
;
2327 if (PtInRect (&rect
, *lpPt
))
2329 if (infoPtr
->uNumBands
== 0) {
2330 *pFlags
= RBHT_NOWHERE
;
2337 /* somewhere inside */
2338 for (iCount
= 0; iCount
< infoPtr
->uNumBands
; iCount
++) {
2339 lpBand
= &infoPtr
->bands
[iCount
];
2340 if (HIDDENBAND(lpBand
)) continue;
2341 if (PtInRect (&lpBand
->rcBand
, *lpPt
)) {
2344 if (PtInRect (&lpBand
->rcGripper
, *lpPt
)) {
2345 *pFlags
= RBHT_GRABBER
;
2346 TRACE("ON GRABBER %d\n", iCount
);
2349 else if (PtInRect (&lpBand
->rcCapImage
, *lpPt
)) {
2350 *pFlags
= RBHT_CAPTION
;
2351 TRACE("ON CAPTION %d\n", iCount
);
2354 else if (PtInRect (&lpBand
->rcCapText
, *lpPt
)) {
2355 *pFlags
= RBHT_CAPTION
;
2356 TRACE("ON CAPTION %d\n", iCount
);
2359 else if (PtInRect (&lpBand
->rcChild
, *lpPt
)) {
2360 *pFlags
= RBHT_CLIENT
;
2361 TRACE("ON CLIENT %d\n", iCount
);
2364 else if (PtInRect (&lpBand
->rcChevron
, *lpPt
)) {
2365 *pFlags
= RBHT_CHEVRON
;
2366 TRACE("ON CHEVRON %d\n", iCount
);
2370 *pFlags
= RBHT_NOWHERE
;
2371 TRACE("NOWHERE %d\n", iCount
);
2377 *pFlags
= RBHT_NOWHERE
;
2386 *pFlags
= RBHT_NOWHERE
;
2396 REBAR_Shrink (REBAR_INFO
*infoPtr
, REBAR_BAND
*band
, INT movement
, INT i
)
2397 /* Function: This attempts to shrink the given band by the */
2398 /* the amount in "movement". A shrink to the left is indi- */
2399 /* cated by "movement" being negative. "i" is merely the */
2400 /* band index for trace messages. */
2402 INT Leadjust
, Readjust
, avail
, ret
;
2404 /* Note: a left drag is indicated by "movement" being negative. */
2405 /* Similarly, a right drag is indicated by "movement" */
2406 /* being positive. "movement" should never be 0, but if */
2407 /* it is then the band does not move. */
2409 avail
= rcBw(band
) - band
->lcx
;
2411 /* now compute the Left End adjustment factor and Right End */
2412 /* adjustment factor. They may be different if shrinking. */
2414 /* if this band is not shrinkable, then just move it */
2415 Leadjust
= Readjust
= movement
;
2421 if (avail
<= abs(movement
)) {
2422 Readjust
= movement
;
2423 Leadjust
= movement
+ avail
;
2427 Readjust
= movement
;
2434 if (avail
<= abs(movement
)) {
2435 Leadjust
= movement
;
2436 Readjust
= movement
- avail
;
2440 Leadjust
= movement
;
2447 /* Reasonability Check */
2448 if (rcBlt(band
) + Leadjust
< 0) {
2449 ERR("adjustment will fail, band %d: left=%d, right=%d, move=%d, rtn=%d\n",
2450 i
, Leadjust
, Readjust
, movement
, ret
);
2453 LEADJ(band
, Leadjust
);
2454 READJ(band
, Readjust
);
2456 TRACE("band %d: left=%d, right=%d, move=%d, rtn=%d, rcBand=(%ld,%ld)-(%ld,%ld)\n",
2457 i
, Leadjust
, Readjust
, movement
, ret
,
2458 band
->rcBand
.left
, band
->rcBand
.top
,
2459 band
->rcBand
.right
, band
->rcBand
.bottom
);
2465 REBAR_HandleLRDrag (REBAR_INFO
*infoPtr
, POINTS
*ptsmove
)
2466 /* Function: This will implement the functionality of a */
2467 /* Gripper drag within a row. It will not implement "out- */
2468 /* of-row" drags. (They are detected and handled in */
2469 /* REBAR_MouseMove.) */
2470 /* **** FIXME Switching order of bands in a row not **** */
2471 /* **** yet implemented. **** */
2473 REBAR_BAND
*hitBand
, *band
, *mindBand
, *maxdBand
;
2475 INT imindBand
= -1, imaxdBand
, ihitBand
, i
, movement
;
2476 INT RHeaderSum
= 0, LHeaderSum
= 0;
2479 /* on first significant mouse movement, issue notify */
2481 if (!(infoPtr
->fStatus
& BEGIN_DRAG_ISSUED
)) {
2482 if (REBAR_Notify_NMREBAR (infoPtr
, -1, RBN_BEGINDRAG
)) {
2483 /* Notify returned TRUE - abort drag */
2484 infoPtr
->dragStart
.x
= 0;
2485 infoPtr
->dragStart
.y
= 0;
2486 infoPtr
->dragNow
= infoPtr
->dragStart
;
2487 infoPtr
->iGrabbedBand
= -1;
2491 infoPtr
->fStatus
|= BEGIN_DRAG_ISSUED
;
2494 ihitBand
= infoPtr
->iGrabbedBand
;
2495 hitBand
= &infoPtr
->bands
[ihitBand
];
2496 imaxdBand
= ihitBand
; /* to suppress warning message */
2498 /* find all the bands in the row of the one whose Gripper was seized */
2499 for (i
=0; i
<infoPtr
->uNumBands
; i
++) {
2500 band
= &infoPtr
->bands
[i
];
2501 if (HIDDENBAND(band
)) continue;
2502 if (band
->iRow
== hitBand
->iRow
) {
2504 if (imindBand
== -1) imindBand
= i
;
2505 /* minimum size of each band is size of header plus */
2506 /* size of minimum child plus offset of child from header plus */
2507 /* a one to separate each band. */
2509 LHeaderSum
+= (band
->lcx
+ SEP_WIDTH
);
2511 RHeaderSum
+= (band
->lcx
+ SEP_WIDTH
);
2515 if (RHeaderSum
) RHeaderSum
-= SEP_WIDTH
; /* no separator afterlast band */
2517 mindBand
= &infoPtr
->bands
[imindBand
];
2518 maxdBand
= &infoPtr
->bands
[imaxdBand
];
2520 if (imindBand
== imaxdBand
) return; /* nothing to drag agains */
2521 if (imindBand
== ihitBand
) return; /* first band in row, cant drag */
2523 /* limit movement to inside adjustable bands - Left */
2524 if ( (ptsmove
->x
< mindBand
->rcBand
.left
) ||
2525 (ptsmove
->x
> maxdBand
->rcBand
.right
) ||
2526 (ptsmove
->y
< mindBand
->rcBand
.top
) ||
2527 (ptsmove
->y
> maxdBand
->rcBand
.bottom
))
2528 return; /* should swap bands */
2530 if (infoPtr
->dwStyle
& CCS_VERT
)
2531 movement
= ptsmove
->y
- ((hitBand
->rcBand
.top
+REBAR_PRE_GRIPPER
) -
2532 infoPtr
->ihitoffset
);
2534 movement
= ptsmove
->x
- ((hitBand
->rcBand
.left
+REBAR_PRE_GRIPPER
) -
2535 infoPtr
->ihitoffset
);
2536 infoPtr
->dragNow
= *ptsmove
;
2538 TRACE("before: movement=%d (%d,%d), imindBand=%d, ihitBand=%d, imaxdBand=%d, LSum=%d, RSum=%d\n",
2539 movement
, ptsmove
->x
, ptsmove
->y
, imindBand
, ihitBand
,
2540 imaxdBand
, LHeaderSum
, RHeaderSum
);
2541 REBAR_DumpBand (infoPtr
);
2545 /* *** Drag left/up *** */
2546 compress
= rcBlt(hitBand
) - rcBlt(mindBand
) -
2548 if (compress
< abs(movement
)) {
2549 TRACE("limiting left drag, was %d changed to %d\n",
2550 movement
, -compress
);
2551 movement
= -compress
;
2554 for (i
=ihitBand
; i
>=imindBand
; i
--) {
2555 band
= &infoPtr
->bands
[i
];
2556 if (HIDDENBAND(band
)) continue;
2557 if (i
== ihitBand
) {
2558 LEADJ(band
, movement
);
2561 movement
= REBAR_Shrink (infoPtr
, band
, movement
, i
);
2562 band
->ccx
= rcBw(band
);
2568 /* *** Drag right/down *** */
2569 compress
= rcBrb(maxdBand
) - rcBlt(hitBand
) -
2571 if (compress
< abs(movement
)) {
2572 TRACE("limiting right drag, was %d changed to %d\n",
2573 movement
, compress
);
2574 movement
= compress
;
2576 for (i
=ihitBand
-1; i
<=imaxdBand
; i
++) {
2577 band
= &infoPtr
->bands
[i
];
2578 if (HIDDENBAND(band
)) continue;
2581 READJ(band
, movement
);
2584 movement
= REBAR_Shrink (infoPtr
, band
, movement
, i
);
2585 band
->ccx
= rcBw(band
);
2589 /* recompute all rectangles */
2590 if (infoPtr
->dwStyle
& CCS_VERT
) {
2591 REBAR_CalcVertBand (infoPtr
, imindBand
, imaxdBand
+1,
2595 REBAR_CalcHorzBand (infoPtr
, imindBand
, imaxdBand
+1,
2599 TRACE("bands after adjustment, see band # %d, %d\n",
2600 imindBand
, imaxdBand
);
2601 REBAR_DumpBand (infoPtr
);
2604 mindBand
->rcBand
.left
,
2605 mindBand
->rcBand
.top
,
2606 maxdBand
->rcBand
.right
,
2607 maxdBand
->rcBand
.bottom
);
2609 REBAR_MoveChildWindows (infoPtr
, imindBand
, imaxdBand
+1);
2611 InvalidateRect (infoPtr
->hwndSelf
, &newrect
, TRUE
);
2612 UpdateWindow (infoPtr
->hwndSelf
);
2618 /* << REBAR_BeginDrag >> */
2622 REBAR_DeleteBand (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
2624 UINT uBand
= (UINT
)wParam
;
2628 if (uBand
>= infoPtr
->uNumBands
)
2631 TRACE("deleting band %u!\n", uBand
);
2632 lpBand
= &infoPtr
->bands
[uBand
];
2633 REBAR_Notify_NMREBAR (infoPtr
, uBand
, RBN_DELETINGBAND
);
2635 if (infoPtr
->uNumBands
== 1) {
2636 TRACE(" simple delete!\n");
2637 if ((lpBand
->fMask
& RBBIM_CHILD
) && lpBand
->hwndChild
)
2638 childhwnd
= lpBand
->hwndChild
;
2639 Free (infoPtr
->bands
);
2640 infoPtr
->bands
= NULL
;
2641 infoPtr
->uNumBands
= 0;
2644 REBAR_BAND
*oldBands
= infoPtr
->bands
;
2645 TRACE("complex delete! [uBand=%u]\n", uBand
);
2647 if ((lpBand
->fMask
& RBBIM_CHILD
) && lpBand
->hwndChild
)
2648 childhwnd
= lpBand
->hwndChild
;
2650 infoPtr
->uNumBands
--;
2651 infoPtr
->bands
= Alloc (sizeof (REBAR_BAND
) * infoPtr
->uNumBands
);
2653 memcpy (&infoPtr
->bands
[0], &oldBands
[0],
2654 uBand
* sizeof(REBAR_BAND
));
2657 if (uBand
< infoPtr
->uNumBands
) {
2658 memcpy (&infoPtr
->bands
[uBand
], &oldBands
[uBand
+1],
2659 (infoPtr
->uNumBands
- uBand
) * sizeof(REBAR_BAND
));
2666 ShowWindow (childhwnd
, SW_HIDE
);
2668 REBAR_Notify_NMREBAR (infoPtr
, -1, RBN_DELETEDBAND
);
2670 /* if only 1 band left the re-validate to possible eliminate gripper */
2671 if (infoPtr
->uNumBands
== 1)
2672 REBAR_ValidateBand (infoPtr
, &infoPtr
->bands
[0]);
2674 TRACE("setting NEEDS_LAYOUT\n");
2675 infoPtr
->fStatus
|= BAND_NEEDS_LAYOUT
;
2676 infoPtr
->fStatus
|= RESIZE_ANYHOW
;
2677 REBAR_Layout (infoPtr
, NULL
, TRUE
, FALSE
);
2683 /* << REBAR_DragMove >> */
2684 /* << REBAR_EndDrag >> */
2688 REBAR_GetBandBorders (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
2690 LPRECT lpRect
= (LPRECT
)lParam
;
2695 if ((UINT
)wParam
>= infoPtr
->uNumBands
)
2698 lpBand
= &infoPtr
->bands
[(UINT
)wParam
];
2700 /* FIXME - the following values were determined by experimentation */
2701 /* with the REBAR Control Spy. I have guesses as to what the 4 and */
2702 /* 1 are, but I am not sure. There doesn't seem to be any actual */
2703 /* difference in size of the control area with and without the */
2705 if (infoPtr
->dwStyle
& RBS_BANDBORDERS
) {
2706 if (infoPtr
->dwStyle
& CCS_VERT
) {
2708 lpRect
->top
= lpBand
->cxHeader
+ 4;
2713 lpRect
->left
= lpBand
->cxHeader
+ 4;
2720 lpRect
->left
= lpBand
->cxHeader
;
2726 inline static LRESULT
2727 REBAR_GetBandCount (REBAR_INFO
*infoPtr
)
2729 TRACE("band count %u!\n", infoPtr
->uNumBands
);
2731 return infoPtr
->uNumBands
;
2736 REBAR_GetBandInfoA (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
2738 LPREBARBANDINFOA lprbbi
= (LPREBARBANDINFOA
)lParam
;
2743 if (lprbbi
->cbSize
< REBARBANDINFOA_V3_SIZE
)
2745 if ((UINT
)wParam
>= infoPtr
->uNumBands
)
2748 TRACE("index %u\n", (UINT
)wParam
);
2750 /* copy band information */
2751 lpBand
= &infoPtr
->bands
[(UINT
)wParam
];
2753 if (lprbbi
->fMask
& RBBIM_STYLE
)
2754 lprbbi
->fStyle
= lpBand
->fStyle
;
2756 if (lprbbi
->fMask
& RBBIM_COLORS
) {
2757 lprbbi
->clrFore
= lpBand
->clrFore
;
2758 lprbbi
->clrBack
= lpBand
->clrBack
;
2759 if (lprbbi
->clrBack
== CLR_DEFAULT
)
2760 lprbbi
->clrBack
= infoPtr
->clrBtnFace
;
2763 if ((lprbbi
->fMask
& RBBIM_TEXT
) && (lprbbi
->lpText
)) {
2764 if (lpBand
->lpText
&& (lpBand
->fMask
& RBBIM_TEXT
))
2766 if (!WideCharToMultiByte( CP_ACP
, 0, lpBand
->lpText
, -1,
2767 lprbbi
->lpText
, lprbbi
->cch
, NULL
, NULL
))
2768 lprbbi
->lpText
[lprbbi
->cch
-1] = 0;
2771 *lprbbi
->lpText
= 0;
2774 if (lprbbi
->fMask
& RBBIM_IMAGE
) {
2775 if (lpBand
->fMask
& RBBIM_IMAGE
)
2776 lprbbi
->iImage
= lpBand
->iImage
;
2778 lprbbi
->iImage
= -1;
2781 if (lprbbi
->fMask
& RBBIM_CHILD
)
2782 lprbbi
->hwndChild
= lpBand
->hwndChild
;
2784 if (lprbbi
->fMask
& RBBIM_CHILDSIZE
) {
2785 lprbbi
->cxMinChild
= lpBand
->cxMinChild
;
2786 lprbbi
->cyMinChild
= lpBand
->cyMinChild
;
2787 if (lprbbi
->cbSize
>= sizeof (REBARBANDINFOA
)) {
2788 lprbbi
->cyChild
= lpBand
->cyChild
;
2789 lprbbi
->cyMaxChild
= lpBand
->cyMaxChild
;
2790 lprbbi
->cyIntegral
= lpBand
->cyIntegral
;
2794 if (lprbbi
->fMask
& RBBIM_SIZE
)
2795 lprbbi
->cx
= lpBand
->cx
;
2797 if (lprbbi
->fMask
& RBBIM_BACKGROUND
)
2798 lprbbi
->hbmBack
= lpBand
->hbmBack
;
2800 if (lprbbi
->fMask
& RBBIM_ID
)
2801 lprbbi
->wID
= lpBand
->wID
;
2803 /* check for additional data */
2804 if (lprbbi
->cbSize
>= sizeof (REBARBANDINFOA
)) {
2805 if (lprbbi
->fMask
& RBBIM_IDEALSIZE
)
2806 lprbbi
->cxIdeal
= lpBand
->cxIdeal
;
2808 if (lprbbi
->fMask
& RBBIM_LPARAM
)
2809 lprbbi
->lParam
= lpBand
->lParam
;
2811 if (lprbbi
->fMask
& RBBIM_HEADERSIZE
)
2812 lprbbi
->cxHeader
= lpBand
->cxHeader
;
2815 REBAR_DumpBandInfo (lprbbi
);
2822 REBAR_GetBandInfoW (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
2824 LPREBARBANDINFOW lprbbi
= (LPREBARBANDINFOW
)lParam
;
2829 if (lprbbi
->cbSize
< REBARBANDINFOW_V3_SIZE
)
2831 if ((UINT
)wParam
>= infoPtr
->uNumBands
)
2834 TRACE("index %u\n", (UINT
)wParam
);
2836 /* copy band information */
2837 lpBand
= &infoPtr
->bands
[(UINT
)wParam
];
2839 if (lprbbi
->fMask
& RBBIM_STYLE
)
2840 lprbbi
->fStyle
= lpBand
->fStyle
;
2842 if (lprbbi
->fMask
& RBBIM_COLORS
) {
2843 lprbbi
->clrFore
= lpBand
->clrFore
;
2844 lprbbi
->clrBack
= lpBand
->clrBack
;
2845 if (lprbbi
->clrBack
== CLR_DEFAULT
)
2846 lprbbi
->clrBack
= infoPtr
->clrBtnFace
;
2849 if ((lprbbi
->fMask
& RBBIM_TEXT
) && (lprbbi
->lpText
)) {
2850 if (lpBand
->lpText
&& (lpBand
->fMask
& RBBIM_TEXT
))
2851 lstrcpynW (lprbbi
->lpText
, lpBand
->lpText
, lprbbi
->cch
);
2853 *lprbbi
->lpText
= 0;
2856 if (lprbbi
->fMask
& RBBIM_IMAGE
) {
2857 if (lpBand
->fMask
& RBBIM_IMAGE
)
2858 lprbbi
->iImage
= lpBand
->iImage
;
2860 lprbbi
->iImage
= -1;
2863 if (lprbbi
->fMask
& RBBIM_CHILD
)
2864 lprbbi
->hwndChild
= lpBand
->hwndChild
;
2866 if (lprbbi
->fMask
& RBBIM_CHILDSIZE
) {
2867 lprbbi
->cxMinChild
= lpBand
->cxMinChild
;
2868 lprbbi
->cyMinChild
= lpBand
->cyMinChild
;
2869 if (lprbbi
->cbSize
>= sizeof (REBARBANDINFOW
)) {
2870 lprbbi
->cyChild
= lpBand
->cyChild
;
2871 lprbbi
->cyMaxChild
= lpBand
->cyMaxChild
;
2872 lprbbi
->cyIntegral
= lpBand
->cyIntegral
;
2876 if (lprbbi
->fMask
& RBBIM_SIZE
)
2877 lprbbi
->cx
= lpBand
->cx
;
2879 if (lprbbi
->fMask
& RBBIM_BACKGROUND
)
2880 lprbbi
->hbmBack
= lpBand
->hbmBack
;
2882 if (lprbbi
->fMask
& RBBIM_ID
)
2883 lprbbi
->wID
= lpBand
->wID
;
2885 /* check for additional data */
2886 if (lprbbi
->cbSize
>= sizeof (REBARBANDINFOW
)) {
2887 if (lprbbi
->fMask
& RBBIM_IDEALSIZE
)
2888 lprbbi
->cxIdeal
= lpBand
->cxIdeal
;
2890 if (lprbbi
->fMask
& RBBIM_LPARAM
)
2891 lprbbi
->lParam
= lpBand
->lParam
;
2893 if (lprbbi
->fMask
& RBBIM_HEADERSIZE
)
2894 lprbbi
->cxHeader
= lpBand
->cxHeader
;
2897 REBAR_DumpBandInfo ((LPREBARBANDINFOA
)lprbbi
);
2904 REBAR_GetBarHeight (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
2908 nHeight
= (infoPtr
->dwStyle
& CCS_VERT
) ? infoPtr
->calcSize
.cx
: infoPtr
->calcSize
.cy
;
2910 TRACE("height = %d\n", nHeight
);
2917 REBAR_GetBarInfo (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
2919 LPREBARINFO lpInfo
= (LPREBARINFO
)lParam
;
2924 if (lpInfo
->cbSize
< sizeof (REBARINFO
))
2927 TRACE("getting bar info!\n");
2929 if (infoPtr
->himl
) {
2930 lpInfo
->himl
= infoPtr
->himl
;
2931 lpInfo
->fMask
|= RBIM_IMAGELIST
;
2938 inline static LRESULT
2939 REBAR_GetBkColor (REBAR_INFO
*infoPtr
)
2941 COLORREF clr
= infoPtr
->clrBk
;
2943 if (clr
== CLR_DEFAULT
)
2944 clr
= infoPtr
->clrBtnFace
;
2946 TRACE("background color 0x%06lx!\n", clr
);
2952 /* << REBAR_GetColorScheme >> */
2953 /* << REBAR_GetDropTarget >> */
2957 REBAR_GetPalette (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
2959 FIXME("empty stub!\n");
2966 REBAR_GetRect (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
2968 INT iBand
= (INT
)wParam
;
2969 LPRECT lprc
= (LPRECT
)lParam
;
2972 if ((iBand
< 0) && ((UINT
)iBand
>= infoPtr
->uNumBands
))
2977 lpBand
= &infoPtr
->bands
[iBand
];
2978 CopyRect (lprc
, &lpBand
->rcBand
);
2980 TRACE("band %d, (%ld,%ld)-(%ld,%ld)\n", iBand
,
2981 lprc
->left
, lprc
->top
, lprc
->right
, lprc
->bottom
);
2987 inline static LRESULT
2988 REBAR_GetRowCount (REBAR_INFO
*infoPtr
)
2990 TRACE("%u\n", infoPtr
->uNumRows
);
2992 return infoPtr
->uNumRows
;
2997 REBAR_GetRowHeight (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
2999 INT iRow
= (INT
)wParam
;
3004 for (i
=0; i
<infoPtr
->uNumBands
; i
++) {
3005 lpBand
= &infoPtr
->bands
[i
];
3006 if (HIDDENBAND(lpBand
)) continue;
3007 if (lpBand
->iRow
!= iRow
) continue;
3008 if (infoPtr
->dwStyle
& CCS_VERT
)
3009 j
= lpBand
->rcBand
.right
- lpBand
->rcBand
.left
;
3011 j
= lpBand
->rcBand
.bottom
- lpBand
->rcBand
.top
;
3012 if (j
> ret
) ret
= j
;
3015 TRACE("row %d, height %d\n", iRow
, ret
);
3021 inline static LRESULT
3022 REBAR_GetTextColor (REBAR_INFO
*infoPtr
)
3024 TRACE("text color 0x%06lx!\n", infoPtr
->clrText
);
3026 return infoPtr
->clrText
;
3030 inline static LRESULT
3031 REBAR_GetToolTips (REBAR_INFO
*infoPtr
)
3033 return (LRESULT
)infoPtr
->hwndToolTip
;
3037 inline static LRESULT
3038 REBAR_GetUnicodeFormat (REBAR_INFO
*infoPtr
)
3040 TRACE("%s hwnd=%p\n",
3041 infoPtr
->bUnicode
? "TRUE" : "FALSE", infoPtr
->hwndSelf
);
3043 return infoPtr
->bUnicode
;
3047 inline static LRESULT
3048 REBAR_GetVersion (REBAR_INFO
*infoPtr
)
3050 TRACE("version %d\n", infoPtr
->iVersion
);
3051 return infoPtr
->iVersion
;
3056 REBAR_HitTest (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
3058 LPRBHITTESTINFO lprbht
= (LPRBHITTESTINFO
)lParam
;
3063 REBAR_InternalHitTest (infoPtr
, &lprbht
->pt
, &lprbht
->flags
, &lprbht
->iBand
);
3065 return lprbht
->iBand
;
3070 REBAR_IdToIndex (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
3074 if (infoPtr
== NULL
)
3077 if (infoPtr
->uNumBands
< 1)
3080 for (i
= 0; i
< infoPtr
->uNumBands
; i
++) {
3081 if (infoPtr
->bands
[i
].wID
== (UINT
)wParam
) {
3082 TRACE("id %u is band %u found!\n", (UINT
)wParam
, i
);
3087 TRACE("id %u is not found\n", (UINT
)wParam
);
3093 REBAR_InsertBandA (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
3095 LPREBARBANDINFOA lprbbi
= (LPREBARBANDINFOA
)lParam
;
3096 UINT uIndex
= (UINT
)wParam
;
3099 if (infoPtr
== NULL
)
3103 if (lprbbi
->cbSize
< REBARBANDINFOA_V3_SIZE
)
3106 /* trace the index as signed to see the -1 */
3107 TRACE("insert band at %d!\n", (INT
)uIndex
);
3108 REBAR_DumpBandInfo (lprbbi
);
3110 if (infoPtr
->uNumBands
== 0) {
3111 infoPtr
->bands
= (REBAR_BAND
*)Alloc (sizeof (REBAR_BAND
));
3115 REBAR_BAND
*oldBands
= infoPtr
->bands
;
3117 (REBAR_BAND
*)Alloc ((infoPtr
->uNumBands
+1)*sizeof(REBAR_BAND
));
3118 if (((INT
)uIndex
== -1) || (uIndex
> infoPtr
->uNumBands
))
3119 uIndex
= infoPtr
->uNumBands
;
3121 /* pre insert copy */
3123 memcpy (&infoPtr
->bands
[0], &oldBands
[0],
3124 uIndex
* sizeof(REBAR_BAND
));
3128 if (uIndex
< infoPtr
->uNumBands
- 1) {
3129 memcpy (&infoPtr
->bands
[uIndex
+1], &oldBands
[uIndex
],
3130 (infoPtr
->uNumBands
- uIndex
- 1) * sizeof(REBAR_BAND
));
3136 infoPtr
->uNumBands
++;
3138 TRACE("index %u!\n", uIndex
);
3140 /* initialize band (infoPtr->bands[uIndex])*/
3141 lpBand
= &infoPtr
->bands
[uIndex
];
3143 lpBand
->fStatus
= 0;
3144 lpBand
->clrFore
= infoPtr
->clrText
;
3145 lpBand
->clrBack
= infoPtr
->clrBk
;
3146 lpBand
->hwndChild
= 0;
3147 lpBand
->hwndPrevParent
= 0;
3149 REBAR_CommonSetupBand (infoPtr
->hwndSelf
, lprbbi
, lpBand
);
3150 lpBand
->lpText
= NULL
;
3151 if ((lprbbi
->fMask
& RBBIM_TEXT
) && (lprbbi
->lpText
)) {
3152 INT len
= MultiByteToWideChar( CP_ACP
, 0, lprbbi
->lpText
, -1, NULL
, 0 );
3154 lpBand
->lpText
= (LPWSTR
)Alloc (len
*sizeof(WCHAR
));
3155 MultiByteToWideChar( CP_ACP
, 0, lprbbi
->lpText
, -1, lpBand
->lpText
, len
);
3159 REBAR_ValidateBand (infoPtr
, lpBand
);
3160 /* On insert of second band, revalidate band 1 to possible add gripper */
3161 if (infoPtr
->uNumBands
== 2)
3162 REBAR_ValidateBand (infoPtr
, &infoPtr
->bands
[0]);
3164 REBAR_DumpBand (infoPtr
);
3166 REBAR_Layout (infoPtr
, NULL
, TRUE
, FALSE
);
3167 InvalidateRect(infoPtr
->hwndSelf
, 0, 1);
3174 REBAR_InsertBandW (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
3176 LPREBARBANDINFOW lprbbi
= (LPREBARBANDINFOW
)lParam
;
3177 UINT uIndex
= (UINT
)wParam
;
3180 if (infoPtr
== NULL
)
3184 if (lprbbi
->cbSize
< REBARBANDINFOW_V3_SIZE
)
3187 /* trace the index as signed to see the -1 */
3188 TRACE("insert band at %d!\n", (INT
)uIndex
);
3189 REBAR_DumpBandInfo ((LPREBARBANDINFOA
)lprbbi
);
3191 if (infoPtr
->uNumBands
== 0) {
3192 infoPtr
->bands
= (REBAR_BAND
*)Alloc (sizeof (REBAR_BAND
));
3196 REBAR_BAND
*oldBands
= infoPtr
->bands
;
3198 (REBAR_BAND
*)Alloc ((infoPtr
->uNumBands
+1)*sizeof(REBAR_BAND
));
3199 if (((INT
)uIndex
== -1) || (uIndex
> infoPtr
->uNumBands
))
3200 uIndex
= infoPtr
->uNumBands
;
3202 /* pre insert copy */
3204 memcpy (&infoPtr
->bands
[0], &oldBands
[0],
3205 uIndex
* sizeof(REBAR_BAND
));
3209 if (uIndex
< infoPtr
->uNumBands
- 1) {
3210 memcpy (&infoPtr
->bands
[uIndex
+1], &oldBands
[uIndex
],
3211 (infoPtr
->uNumBands
- uIndex
- 1) * sizeof(REBAR_BAND
));
3217 infoPtr
->uNumBands
++;
3219 TRACE("index %u!\n", uIndex
);
3221 /* initialize band (infoPtr->bands[uIndex])*/
3222 lpBand
= &infoPtr
->bands
[uIndex
];
3224 lpBand
->fStatus
= 0;
3225 lpBand
->clrFore
= infoPtr
->clrText
;
3226 lpBand
->clrBack
= infoPtr
->clrBk
;
3227 lpBand
->hwndChild
= 0;
3228 lpBand
->hwndPrevParent
= 0;
3230 REBAR_CommonSetupBand (infoPtr
->hwndSelf
, (LPREBARBANDINFOA
)lprbbi
, lpBand
);
3231 lpBand
->lpText
= NULL
;
3232 if ((lprbbi
->fMask
& RBBIM_TEXT
) && (lprbbi
->lpText
)) {
3233 INT len
= lstrlenW (lprbbi
->lpText
);
3235 lpBand
->lpText
= (LPWSTR
)Alloc ((len
+ 1)*sizeof(WCHAR
));
3236 strcpyW (lpBand
->lpText
, lprbbi
->lpText
);
3240 REBAR_ValidateBand (infoPtr
, lpBand
);
3241 /* On insert of second band, revalidate band 1 to possible add gripper */
3242 if (infoPtr
->uNumBands
== 2)
3243 REBAR_ValidateBand (infoPtr
, &infoPtr
->bands
[0]);
3245 REBAR_DumpBand (infoPtr
);
3247 REBAR_Layout (infoPtr
, NULL
, TRUE
, FALSE
);
3248 InvalidateRect(infoPtr
->hwndSelf
, 0, 1);
3255 REBAR_MaximizeBand (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
3258 UINT uBand
= (UINT
) wParam
;
3261 if ((infoPtr
->uNumBands
== 0) ||
3262 ((INT
)uBand
< 0) || (uBand
>= infoPtr
->uNumBands
)) {
3264 ERR("Illegal MaximizeBand, requested=%d, current band count=%d\n",
3265 (INT
)uBand
, infoPtr
->uNumBands
);
3269 lpBand
= &infoPtr
->bands
[uBand
];
3271 if (lParam
&& (lpBand
->fMask
& RBBIM_IDEALSIZE
)) {
3272 /* handle setting ideal size */
3273 lpBand
->ccx
= lpBand
->cxIdeal
;
3276 /* handle setting to max */
3277 FIXME("(uBand = %u fIdeal = %s) case not coded\n",
3278 (UINT
)wParam
, lParam
? "TRUE" : "FALSE");
3282 infoPtr
->fStatus
|= BAND_NEEDS_LAYOUT
;
3283 REBAR_Layout (infoPtr
, 0, TRUE
, TRUE
);
3284 InvalidateRect (infoPtr
->hwndSelf
, 0, TRUE
);
3292 REBAR_MinimizeBand (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
3294 REBAR_BAND
*band
, *lpBand
;
3295 UINT uBand
= (UINT
) wParam
;
3297 INT imindBand
, imaxdBand
, iprevBand
, startBand
, endBand
;
3300 /* A "minimize" band is equivalent to "dragging" the gripper
3301 * of than band to the right till the band is only the size
3306 if ((infoPtr
->uNumBands
== 0) ||
3307 ((INT
)uBand
< 0) || (uBand
>= infoPtr
->uNumBands
)) {
3309 ERR("Illegal MinimizeBand, requested=%d, current band count=%d\n",
3310 (INT
)uBand
, infoPtr
->uNumBands
);
3314 /* compute amount of movement and validate */
3315 lpBand
= &infoPtr
->bands
[uBand
];
3317 if (infoPtr
->dwStyle
& CCS_VERT
)
3318 movement
= lpBand
->rcBand
.bottom
- lpBand
->rcBand
.top
-
3321 movement
= lpBand
->rcBand
.right
- lpBand
->rcBand
.left
-
3324 ERR("something is wrong, band=(%ld,%ld)-(%ld,%ld), cxheader=%d\n",
3325 lpBand
->rcBand
.left
, lpBand
->rcBand
.top
,
3326 lpBand
->rcBand
.right
, lpBand
->rcBand
.bottom
,
3333 iprevBand
= -1; /* to suppress warning message */
3335 /* find the first band in row of the one whose is being minimized */
3336 for (i
=0; i
<infoPtr
->uNumBands
; i
++) {
3337 band
= &infoPtr
->bands
[i
];
3338 if (HIDDENBAND(band
)) continue;
3339 if (band
->iRow
== lpBand
->iRow
) {
3341 if (imindBand
== -1) imindBand
= i
;
3345 /* if the selected band is first in row then need to expand */
3346 /* next visible band */
3347 if (imindBand
== uBand
) {
3349 movement
= -movement
;
3350 /* find the first visible band to the right of the selected band */
3351 for (i
=uBand
+1; i
<=imaxdBand
; i
++) {
3352 band
= &infoPtr
->bands
[i
];
3353 if (!HIDDENBAND(band
)) {
3355 LEADJ(band
, movement
);
3356 band
->ccx
= rcBw(band
);
3360 /* what case is this */
3361 if (iprevBand
== -1) {
3362 ERR("no previous visible band\n");
3366 endBand
= iprevBand
;
3368 lpBand
->rcBand
.left
,
3371 band
->rcBand
.bottom
);
3373 /* otherwise expand previous visible band */
3376 /* find the first visible band to the left of the selected band */
3377 for (i
=uBand
-1; i
>=imindBand
; i
--) {
3378 band
= &infoPtr
->bands
[i
];
3379 if (!HIDDENBAND(band
)) {
3381 READJ(band
, movement
);
3382 band
->ccx
= rcBw(band
);
3386 /* what case is this */
3387 if (iprevBand
== -1) {
3388 ERR("no previous visible band\n");
3391 startBand
= iprevBand
;
3396 lpBand
->rcBand
.right
,
3397 lpBand
->rcBand
.bottom
);
3400 REBAR_Shrink (infoPtr
, lpBand
, movement
, uBand
);
3402 /* recompute all rectangles */
3403 if (infoPtr
->dwStyle
& CCS_VERT
) {
3404 REBAR_CalcVertBand (infoPtr
, startBand
, endBand
+1,
3408 REBAR_CalcHorzBand (infoPtr
, startBand
, endBand
+1,
3412 TRACE("bands after minimize, see band # %d, %d\n",
3413 startBand
, endBand
);
3414 REBAR_DumpBand (infoPtr
);
3416 REBAR_MoveChildWindows (infoPtr
, startBand
, endBand
+1);
3418 InvalidateRect (infoPtr
->hwndSelf
, &newrect
, TRUE
);
3419 UpdateWindow (infoPtr
->hwndSelf
);
3425 REBAR_MoveBand (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
3427 REBAR_BAND
*oldBands
= infoPtr
->bands
;
3429 UINT uFrom
= (UINT
)wParam
;
3430 UINT uTo
= (UINT
)lParam
;
3433 if ((infoPtr
->uNumBands
== 0) ||
3434 ((INT
)uFrom
< 0) || (uFrom
>= infoPtr
->uNumBands
) ||
3435 ((INT
)uTo
< 0) || (uTo
>= infoPtr
->uNumBands
)) {
3437 ERR("Illegal MoveBand, from=%d, to=%d, current band count=%d\n",
3438 (INT
)uFrom
, (INT
)uTo
, infoPtr
->uNumBands
);
3442 /* save one to be moved */
3443 memcpy (&holder
, &oldBands
[uFrom
], sizeof(REBAR_BAND
));
3445 /* close up rest of bands (psuedo delete) */
3446 if (uFrom
< infoPtr
->uNumBands
- 1) {
3447 memcpy (&oldBands
[uFrom
], &oldBands
[uFrom
+1],
3448 (infoPtr
->uNumBands
- uFrom
- 1) * sizeof(REBAR_BAND
));
3451 /* allocate new space and copy rest of bands into it */
3453 (REBAR_BAND
*)Alloc ((infoPtr
->uNumBands
)*sizeof(REBAR_BAND
));
3455 /* pre insert copy */
3457 memcpy (&infoPtr
->bands
[0], &oldBands
[0],
3458 uTo
* sizeof(REBAR_BAND
));
3461 /* set moved band */
3462 memcpy (&infoPtr
->bands
[uTo
], &holder
, sizeof(REBAR_BAND
));
3465 if (uTo
< infoPtr
->uNumBands
- 1) {
3466 memcpy (&infoPtr
->bands
[uTo
+1], &oldBands
[uTo
],
3467 (infoPtr
->uNumBands
- uTo
- 1) * sizeof(REBAR_BAND
));
3472 TRACE("moved band %d to index %d\n", uFrom
, uTo
);
3473 REBAR_DumpBand (infoPtr
);
3475 infoPtr
->fStatus
|= BAND_NEEDS_LAYOUT
;
3476 /* **************************************************** */
3478 /* We do not do a REBAR_Layout here because the native */
3479 /* control does not do that. The actual layout and */
3480 /* repaint is done by the *next* real action, ex.: */
3481 /* RB_INSERTBAND, RB_DELETEBAND, RB_SIZETORECT, etc. */
3483 /* **************************************************** */
3489 /* return TRUE if two strings are different */
3491 REBAR_strdifW( LPCWSTR a
, LPCWSTR b
)
3493 return ( (a
&& !b
) || (b
&& !a
) || (a
&& b
&& lstrcmpW(a
, b
) ) );
3497 REBAR_SetBandInfoA (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
3499 LPREBARBANDINFOA lprbbi
= (LPREBARBANDINFOA
)lParam
;
3505 if (lprbbi
->cbSize
< REBARBANDINFOA_V3_SIZE
)
3507 if ((UINT
)wParam
>= infoPtr
->uNumBands
)
3510 TRACE("index %u\n", (UINT
)wParam
);
3511 REBAR_DumpBandInfo (lprbbi
);
3513 /* set band information */
3514 lpBand
= &infoPtr
->bands
[(UINT
)wParam
];
3516 bChanged
= REBAR_CommonSetupBand (infoPtr
->hwndSelf
, lprbbi
, lpBand
);
3517 if (lprbbi
->fMask
& RBBIM_TEXT
) {
3523 len
= MultiByteToWideChar( CP_ACP
, 0, lprbbi
->lpText
, -1, NULL
, 0 );
3525 wstr
= (LPWSTR
)Alloc (len
*sizeof(WCHAR
));
3527 MultiByteToWideChar( CP_ACP
, 0, lprbbi
->lpText
, -1, wstr
, len
);
3529 if (REBAR_strdifW(lpBand
->lpText
, wstr
)) {
3530 if (lpBand
->lpText
) {
3531 Free (lpBand
->lpText
);
3532 lpBand
->lpText
= NULL
;
3535 lpBand
->lpText
= wstr
;
3544 REBAR_ValidateBand (infoPtr
, lpBand
);
3546 REBAR_DumpBand (infoPtr
);
3548 if (bChanged
&& (lprbbi
->fMask
& (RBBIM_CHILDSIZE
| RBBIM_SIZE
))) {
3549 REBAR_Layout (infoPtr
, NULL
, TRUE
, FALSE
);
3550 InvalidateRect(infoPtr
->hwndSelf
, 0, 1);
3557 REBAR_SetBandInfoW (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
3559 LPREBARBANDINFOW lprbbi
= (LPREBARBANDINFOW
)lParam
;
3565 if (lprbbi
->cbSize
< REBARBANDINFOW_V3_SIZE
)
3567 if ((UINT
)wParam
>= infoPtr
->uNumBands
)
3570 TRACE("index %u\n", (UINT
)wParam
);
3571 REBAR_DumpBandInfo ((LPREBARBANDINFOA
)lprbbi
);
3573 /* set band information */
3574 lpBand
= &infoPtr
->bands
[(UINT
)wParam
];
3576 bChanged
= REBAR_CommonSetupBand (infoPtr
->hwndSelf
, (LPREBARBANDINFOA
)lprbbi
, lpBand
);
3577 if( (lprbbi
->fMask
& RBBIM_TEXT
) &&
3578 REBAR_strdifW( lpBand
->lpText
, lprbbi
->lpText
) ) {
3579 if (lpBand
->lpText
) {
3580 Free (lpBand
->lpText
);
3581 lpBand
->lpText
= NULL
;
3583 if (lprbbi
->lpText
) {
3584 INT len
= lstrlenW (lprbbi
->lpText
);
3587 lpBand
->lpText
= (LPWSTR
)Alloc ((len
+ 1)*sizeof(WCHAR
));
3588 strcpyW (lpBand
->lpText
, lprbbi
->lpText
);
3594 REBAR_ValidateBand (infoPtr
, lpBand
);
3596 REBAR_DumpBand (infoPtr
);
3598 if ( bChanged
&& (lprbbi
->fMask
& (RBBIM_CHILDSIZE
| RBBIM_SIZE
)) ) {
3599 REBAR_Layout (infoPtr
, NULL
, TRUE
, FALSE
);
3600 InvalidateRect(infoPtr
->hwndSelf
, 0, 1);
3608 REBAR_SetBarInfo (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
3610 LPREBARINFO lpInfo
= (LPREBARINFO
)lParam
;
3617 if (lpInfo
->cbSize
< sizeof (REBARINFO
))
3620 TRACE("setting bar info!\n");
3622 if (lpInfo
->fMask
& RBIM_IMAGELIST
) {
3623 infoPtr
->himl
= lpInfo
->himl
;
3624 if (infoPtr
->himl
) {
3626 ImageList_GetIconSize (infoPtr
->himl
, &cx
, &cy
);
3627 infoPtr
->imageSize
.cx
= cx
;
3628 infoPtr
->imageSize
.cy
= cy
;
3631 infoPtr
->imageSize
.cx
= 0;
3632 infoPtr
->imageSize
.cy
= 0;
3634 TRACE("new image cx=%ld, cy=%ld\n", infoPtr
->imageSize
.cx
,
3635 infoPtr
->imageSize
.cy
);
3638 /* revalidate all bands to reset flags for images in headers of bands */
3639 for (i
=0; i
<infoPtr
->uNumBands
; i
++) {
3640 lpBand
= &infoPtr
->bands
[i
];
3641 REBAR_ValidateBand (infoPtr
, lpBand
);
3649 REBAR_SetBkColor (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
3653 clrTemp
= infoPtr
->clrBk
;
3654 infoPtr
->clrBk
= (COLORREF
)lParam
;
3656 TRACE("background color 0x%06lx!\n", infoPtr
->clrBk
);
3662 /* << REBAR_SetColorScheme >> */
3663 /* << REBAR_SetPalette >> */
3667 REBAR_SetParent (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
3669 HWND hwndTemp
= infoPtr
->hwndNotify
;
3671 infoPtr
->hwndNotify
= (HWND
)wParam
;
3673 return (LRESULT
)hwndTemp
;
3678 REBAR_SetTextColor (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
3682 clrTemp
= infoPtr
->clrText
;
3683 infoPtr
->clrText
= (COLORREF
)lParam
;
3685 TRACE("text color 0x%06lx!\n", infoPtr
->clrText
);
3691 /* << REBAR_SetTooltips >> */
3694 inline static LRESULT
3695 REBAR_SetUnicodeFormat (REBAR_INFO
*infoPtr
, WPARAM wParam
)
3697 BOOL bTemp
= infoPtr
->bUnicode
;
3699 TRACE("to %s hwnd=%p, was %s\n",
3700 ((BOOL
)wParam
) ? "TRUE" : "FALSE", infoPtr
->hwndSelf
,
3701 (bTemp
) ? "TRUE" : "FALSE");
3703 infoPtr
->bUnicode
= (BOOL
)wParam
;
3710 REBAR_SetVersion (REBAR_INFO
*infoPtr
, INT iVersion
)
3712 INT iOldVersion
= infoPtr
->iVersion
;
3714 if (iVersion
> COMCTL32_VERSION
)
3717 infoPtr
->iVersion
= iVersion
;
3719 TRACE("new version %d\n", iVersion
);
3726 REBAR_ShowBand (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
3730 if (((INT
)wParam
< 0) || ((INT
)wParam
> infoPtr
->uNumBands
))
3733 lpBand
= &infoPtr
->bands
[(INT
)wParam
];
3736 TRACE("show band %d\n", (INT
)wParam
);
3737 lpBand
->fStyle
= lpBand
->fStyle
& ~RBBS_HIDDEN
;
3738 if (IsWindow (lpBand
->hwndChild
))
3739 ShowWindow (lpBand
->hwndChild
, SW_SHOW
);
3742 TRACE("hide band %d\n", (INT
)wParam
);
3743 lpBand
->fStyle
= lpBand
->fStyle
| RBBS_HIDDEN
;
3744 if (IsWindow (lpBand
->hwndChild
))
3745 ShowWindow (lpBand
->hwndChild
, SW_HIDE
);
3748 REBAR_Layout (infoPtr
, NULL
, TRUE
, FALSE
);
3749 InvalidateRect(infoPtr
->hwndSelf
, 0, 1);
3756 REBAR_SizeToRect (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
3758 LPRECT lpRect
= (LPRECT
)lParam
;
3764 TRACE("[%ld %ld %ld %ld]\n",
3765 lpRect
->left
, lpRect
->top
, lpRect
->right
, lpRect
->bottom
);
3767 /* what is going on???? */
3768 GetWindowRect(infoPtr
->hwndSelf
, &t1
);
3769 TRACE("window rect [%ld %ld %ld %ld]\n",
3770 t1
.left
, t1
.top
, t1
.right
, t1
.bottom
);
3771 GetClientRect(infoPtr
->hwndSelf
, &t1
);
3772 TRACE("client rect [%ld %ld %ld %ld]\n",
3773 t1
.left
, t1
.top
, t1
.right
, t1
.bottom
);
3775 /* force full _Layout processing */
3776 TRACE("setting NEEDS_LAYOUT\n");
3777 infoPtr
->fStatus
|= BAND_NEEDS_LAYOUT
;
3778 REBAR_Layout (infoPtr
, lpRect
, TRUE
, FALSE
);
3779 InvalidateRect (infoPtr
->hwndSelf
, NULL
, TRUE
);
3786 REBAR_Create (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
3788 LPCREATESTRUCTA cs
= (LPCREATESTRUCTA
) lParam
;
3791 if (TRACE_ON(rebar
)) {
3792 GetWindowRect(infoPtr
->hwndSelf
, &wnrc1
);
3793 GetClientRect(infoPtr
->hwndSelf
, &clrc1
);
3794 TRACE("window=(%ld,%ld)-(%ld,%ld) client=(%ld,%ld)-(%ld,%ld) cs=(%d,%d %dx%d)\n",
3795 wnrc1
.left
, wnrc1
.top
, wnrc1
.right
, wnrc1
.bottom
,
3796 clrc1
.left
, clrc1
.top
, clrc1
.right
, clrc1
.bottom
,
3797 cs
->x
, cs
->y
, cs
->cx
, cs
->cy
);
3800 TRACE("created!\n");
3806 REBAR_Destroy (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
3812 /* free rebar bands */
3813 if ((infoPtr
->uNumBands
> 0) && infoPtr
->bands
) {
3814 /* clean up each band */
3815 for (i
= 0; i
< infoPtr
->uNumBands
; i
++) {
3816 lpBand
= &infoPtr
->bands
[i
];
3818 /* delete text strings */
3819 if (lpBand
->lpText
) {
3820 Free (lpBand
->lpText
);
3821 lpBand
->lpText
= NULL
;
3823 /* destroy child window */
3824 DestroyWindow (lpBand
->hwndChild
);
3827 /* free band array */
3828 Free (infoPtr
->bands
);
3829 infoPtr
->bands
= NULL
;
3832 DeleteObject (infoPtr
->hcurArrow
);
3833 DeleteObject (infoPtr
->hcurHorz
);
3834 DeleteObject (infoPtr
->hcurVert
);
3835 DeleteObject (infoPtr
->hcurDrag
);
3836 if(infoPtr
->hDefaultFont
) DeleteObject (infoPtr
->hDefaultFont
);
3837 SetWindowLongA (infoPtr
->hwndSelf
, 0, 0);
3839 /* free rebar info data */
3841 TRACE("destroyed!\n");
3847 REBAR_EraseBkGnd (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
3851 if (GetClipBox ( (HDC
)wParam
, &cliprect
))
3852 return REBAR_InternalEraseBkGnd (infoPtr
, wParam
, lParam
, &cliprect
);
3858 REBAR_GetFont (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
3860 return (LRESULT
)infoPtr
->hFont
;
3864 REBAR_PushChevron(REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
3866 if (wParam
>= 0 && (UINT
)wParam
< infoPtr
->uNumBands
)
3868 NMREBARCHEVRON nmrbc
;
3869 REBAR_BAND
*lpBand
= &infoPtr
->bands
[wParam
];
3871 TRACE("Pressed chevron on band %d\n", wParam
);
3873 /* redraw chevron in pushed state */
3874 lpBand
->fDraw
|= DRAW_CHEVRONPUSHED
;
3875 RedrawWindow(infoPtr
->hwndSelf
, &lpBand
->rcChevron
,0,
3876 RDW_ERASE
|RDW_INVALIDATE
|RDW_UPDATENOW
);
3878 /* notify app so it can display a popup menu or whatever */
3879 nmrbc
.uBand
= wParam
;
3880 nmrbc
.wID
= lpBand
->wID
;
3881 nmrbc
.lParam
= lpBand
->lParam
;
3882 nmrbc
.rc
= lpBand
->rcChevron
;
3883 nmrbc
.lParamNM
= lParam
;
3884 REBAR_Notify((NMHDR
*)&nmrbc
, infoPtr
, RBN_CHEVRONPUSHED
);
3886 /* redraw chevron in previous state */
3887 lpBand
->fDraw
&= ~DRAW_CHEVRONPUSHED
;
3888 InvalidateRect(infoPtr
->hwndSelf
, &lpBand
->rcChevron
, TRUE
);
3896 REBAR_LButtonDown (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
3902 ptMouseDown
.x
= (INT
)LOWORD(lParam
);
3903 ptMouseDown
.y
= (INT
)HIWORD(lParam
);
3905 REBAR_InternalHitTest(infoPtr
, &ptMouseDown
, &htFlags
, &iHitBand
);
3906 lpBand
= &infoPtr
->bands
[iHitBand
];
3908 if (htFlags
== RBHT_CHEVRON
)
3910 REBAR_PushChevron(infoPtr
, iHitBand
, 0);
3912 else if (htFlags
== RBHT_GRABBER
|| htFlags
== RBHT_CAPTION
)
3914 TRACE("Starting drag\n");
3916 SetCapture (infoPtr
->hwndSelf
);
3917 infoPtr
->iGrabbedBand
= iHitBand
;
3919 /* save off the LOWORD and HIWORD of lParam as initial x,y */
3920 infoPtr
->dragStart
= MAKEPOINTS(lParam
);
3921 infoPtr
->dragNow
= infoPtr
->dragStart
;
3922 if (infoPtr
->dwStyle
& CCS_VERT
)
3923 infoPtr
->ihitoffset
= infoPtr
->dragStart
.y
- (lpBand
->rcBand
.top
+REBAR_PRE_GRIPPER
);
3925 infoPtr
->ihitoffset
= infoPtr
->dragStart
.x
- (lpBand
->rcBand
.left
+REBAR_PRE_GRIPPER
);
3931 REBAR_LButtonUp (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
3933 if (infoPtr
->iGrabbedBand
>= 0)
3938 infoPtr
->dragStart
.x
= 0;
3939 infoPtr
->dragStart
.y
= 0;
3940 infoPtr
->dragNow
= infoPtr
->dragStart
;
3944 if (infoPtr
->fStatus
& BEGIN_DRAG_ISSUED
) {
3945 REBAR_Notify(&layout
, infoPtr
, RBN_LAYOUTCHANGED
);
3946 REBAR_Notify_NMREBAR (infoPtr
, infoPtr
->iGrabbedBand
, RBN_ENDDRAG
);
3947 infoPtr
->fStatus
&= ~BEGIN_DRAG_ISSUED
;
3950 infoPtr
->iGrabbedBand
= -1;
3952 GetClientRect(infoPtr
->hwndSelf
, &rect
);
3953 InvalidateRect(infoPtr
->hwndSelf
, NULL
, TRUE
);
3960 REBAR_MouseLeave (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
3962 if (infoPtr
->ichevronhotBand
>= 0)
3964 REBAR_BAND
*lpChevronBand
= &infoPtr
->bands
[infoPtr
->ichevronhotBand
];
3965 if (lpChevronBand
->fDraw
& DRAW_CHEVRONHOT
)
3967 lpChevronBand
->fDraw
&= ~DRAW_CHEVRONHOT
;
3968 InvalidateRect(infoPtr
->hwndSelf
, &lpChevronBand
->rcChevron
, TRUE
);
3971 infoPtr
->iOldBand
= -1;
3972 infoPtr
->ichevronhotBand
= -2;
3978 REBAR_MouseMove (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
3980 REBAR_BAND
*lpChevronBand
;
3983 ptsmove
= MAKEPOINTS(lParam
);
3985 /* if we are currently dragging a band */
3986 if (infoPtr
->iGrabbedBand
>= 0)
3988 REBAR_BAND
*band1
, *band2
;
3990 if (GetCapture() != infoPtr
->hwndSelf
)
3991 ERR("We are dragging but haven't got capture?!?\n");
3993 band1
= &infoPtr
->bands
[infoPtr
->iGrabbedBand
-1];
3994 band2
= &infoPtr
->bands
[infoPtr
->iGrabbedBand
];
3996 /* if mouse did not move much, exit */
3997 if ((abs(ptsmove
.x
- infoPtr
->dragNow
.x
) <= mindragx
) &&
3998 (abs(ptsmove
.y
- infoPtr
->dragNow
.y
) <= mindragy
)) return 0;
4000 /* Test for valid drag case - must not be first band in row */
4001 if (infoPtr
->dwStyle
& CCS_VERT
) {
4002 if ((ptsmove
.x
< band2
->rcBand
.left
) ||
4003 (ptsmove
.x
> band2
->rcBand
.right
) ||
4004 ((infoPtr
->iGrabbedBand
> 0) && (band1
->iRow
!= band2
->iRow
))) {
4005 FIXME("Cannot drag to other rows yet!!\n");
4008 REBAR_HandleLRDrag (infoPtr
, &ptsmove
);
4012 if ((ptsmove
.y
< band2
->rcBand
.top
) ||
4013 (ptsmove
.y
> band2
->rcBand
.bottom
) ||
4014 ((infoPtr
->iGrabbedBand
> 0) && (band1
->iRow
!= band2
->iRow
))) {
4015 FIXME("Cannot drag to other rows yet!!\n");
4018 REBAR_HandleLRDrag (infoPtr
, &ptsmove
);
4027 TRACKMOUSEEVENT trackinfo
;
4029 ptMove
.x
= (INT
)ptsmove
.x
;
4030 ptMove
.y
= (INT
)ptsmove
.y
;
4031 REBAR_InternalHitTest(infoPtr
, &ptMove
, &htFlags
, &iHitBand
);
4033 if (infoPtr
->iOldBand
>= 0 && infoPtr
->iOldBand
== infoPtr
->ichevronhotBand
)
4035 lpChevronBand
= &infoPtr
->bands
[infoPtr
->ichevronhotBand
];
4036 if (lpChevronBand
->fDraw
& DRAW_CHEVRONHOT
)
4038 lpChevronBand
->fDraw
&= ~DRAW_CHEVRONHOT
;
4039 InvalidateRect(infoPtr
->hwndSelf
, &lpChevronBand
->rcChevron
, TRUE
);
4041 infoPtr
->ichevronhotBand
= -2;
4044 if (htFlags
== RBHT_CHEVRON
)
4046 /* fill in the TRACKMOUSEEVENT struct */
4047 trackinfo
.cbSize
= sizeof(TRACKMOUSEEVENT
);
4048 trackinfo
.dwFlags
= TME_QUERY
;
4049 trackinfo
.hwndTrack
= infoPtr
->hwndSelf
;
4050 trackinfo
.dwHoverTime
= 0;
4052 /* call _TrackMouseEvent to see if we are currently tracking for this hwnd */
4053 _TrackMouseEvent(&trackinfo
);
4055 /* Make sure tracking is enabled so we receive a WM_MOUSELEAVE message */
4056 if(!(trackinfo
.dwFlags
& TME_LEAVE
))
4058 trackinfo
.dwFlags
= TME_LEAVE
; /* notify upon leaving */
4060 /* call TRACKMOUSEEVENT so we receive a WM_MOUSELEAVE message */
4061 /* and can properly deactivate the hot chevron */
4062 _TrackMouseEvent(&trackinfo
);
4065 lpChevronBand
= &infoPtr
->bands
[iHitBand
];
4066 if (!(lpChevronBand
->fDraw
& DRAW_CHEVRONHOT
))
4068 lpChevronBand
->fDraw
|= DRAW_CHEVRONHOT
;
4069 InvalidateRect(infoPtr
->hwndSelf
, &lpChevronBand
->rcChevron
, TRUE
);
4070 infoPtr
->ichevronhotBand
= iHitBand
;
4073 infoPtr
->iOldBand
= iHitBand
;
4080 inline static LRESULT
4081 REBAR_NCCalcSize (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
4083 if (infoPtr
->dwStyle
& WS_BORDER
) {
4084 InflateRect((LPRECT
)lParam
, -GetSystemMetrics(SM_CXEDGE
),
4085 -GetSystemMetrics(SM_CYEDGE
));
4087 TRACE("new client=(%ld,%ld)-(%ld,%ld)\n",
4088 ((LPRECT
)lParam
)->left
, ((LPRECT
)lParam
)->top
,
4089 ((LPRECT
)lParam
)->right
, ((LPRECT
)lParam
)->bottom
);
4095 REBAR_NCCreate (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4097 LPCREATESTRUCTA cs
= (LPCREATESTRUCTA
) lParam
;
4098 REBAR_INFO
*infoPtr
= REBAR_GetInfoPtr (hwnd
);
4100 NONCLIENTMETRICSA ncm
;
4104 if (infoPtr
!= NULL
) {
4105 ERR("Strange info structure pointer *not* NULL\n");
4109 if (TRACE_ON(rebar
)) {
4110 GetWindowRect(hwnd
, &wnrc1
);
4111 GetClientRect(hwnd
, &clrc1
);
4112 TRACE("window=(%ld,%ld)-(%ld,%ld) client=(%ld,%ld)-(%ld,%ld) cs=(%d,%d %dx%d)\n",
4113 wnrc1
.left
, wnrc1
.top
, wnrc1
.right
, wnrc1
.bottom
,
4114 clrc1
.left
, clrc1
.top
, clrc1
.right
, clrc1
.bottom
,
4115 cs
->x
, cs
->y
, cs
->cx
, cs
->cy
);
4118 /* allocate memory for info structure */
4119 infoPtr
= (REBAR_INFO
*)Alloc (sizeof(REBAR_INFO
));
4120 SetWindowLongA (hwnd
, 0, (DWORD
)infoPtr
);
4122 /* initialize info structure - initial values are 0 */
4123 infoPtr
->clrBk
= CLR_NONE
;
4124 infoPtr
->clrText
= CLR_NONE
;
4125 infoPtr
->clrBtnText
= GetSysColor (COLOR_BTNTEXT
);
4126 infoPtr
->clrBtnFace
= GetSysColor (COLOR_BTNFACE
);
4127 infoPtr
->iOldBand
= -1;
4128 infoPtr
->ichevronhotBand
= -2;
4129 infoPtr
->iGrabbedBand
= -1;
4130 infoPtr
->hwndSelf
= hwnd
;
4131 infoPtr
->DoRedraw
= TRUE
;
4132 infoPtr
->hcurArrow
= LoadCursorA (0, (LPSTR
)IDC_ARROW
);
4133 infoPtr
->hcurHorz
= LoadCursorA (0, (LPSTR
)IDC_SIZEWE
);
4134 infoPtr
->hcurVert
= LoadCursorA (0, (LPSTR
)IDC_SIZENS
);
4135 infoPtr
->hcurDrag
= LoadCursorA (0, (LPSTR
)IDC_SIZE
);
4136 infoPtr
->bUnicode
= IsWindowUnicode (hwnd
);
4137 infoPtr
->fStatus
= CREATE_RUNNING
;
4138 infoPtr
->hFont
= GetStockObject (SYSTEM_FONT
);
4140 /* issue WM_NOTIFYFORMAT to get unicode status of parent */
4141 i
= SendMessageA(REBAR_GetNotifyParent (infoPtr
),
4142 WM_NOTIFYFORMAT
, (WPARAM
)hwnd
, NF_QUERY
);
4143 if ((i
< NFR_ANSI
) || (i
> NFR_UNICODE
)) {
4144 ERR("wrong response to WM_NOTIFYFORMAT (%d), assuming ANSI\n",
4148 infoPtr
->NtfUnicode
= (i
== NFR_UNICODE
) ? 1 : 0;
4150 /* add necessary styles to the requested styles */
4151 infoPtr
->dwStyle
= cs
->style
| WS_VISIBLE
| CCS_TOP
;
4152 SetWindowLongA (hwnd
, GWL_STYLE
, infoPtr
->dwStyle
);
4154 /* get font handle for Caption Font */
4155 ncm
.cbSize
= sizeof(NONCLIENTMETRICSA
);
4156 SystemParametersInfoA (SPI_GETNONCLIENTMETRICS
,
4157 ncm
.cbSize
, &ncm
, 0);
4158 /* if the font is bold, set to normal */
4159 if (ncm
.lfCaptionFont
.lfWeight
> FW_NORMAL
) {
4160 ncm
.lfCaptionFont
.lfWeight
= FW_NORMAL
;
4162 tfont
= CreateFontIndirectA (&ncm
.lfCaptionFont
);
4164 infoPtr
->hFont
= infoPtr
->hDefaultFont
= tfont
;
4168 GetSysColor (numerous);
4169 GetSysColorBrush (numerous) (see WM_SYSCOLORCHANGE);
4170 *GetStockObject (SYSTEM_FONT);
4171 *SetWindowLong (hwnd, 0, info ptr);
4173 *SetWindowLong (hwnd, GWL_STYLE, style+0x10000001);
4174 WS_VISIBLE = 0x10000000;
4175 CCS_TOP = 0x00000001;
4176 *SystemParametersInfo (SPI_GETNONCLIENTMETRICS...);
4177 *CreateFontIndirect (lfCaptionFont from above);
4179 SelectObject (hdc, fontabove);
4180 GetTextMetrics (hdc, ); guessing is tmHeight
4181 SelectObject (hdc, oldfont);
4184 MapWindowPoints (0, parent, rectabove, 2);
4187 ClientToScreen (clientrect);
4188 SetWindowPos (hwnd, 0, 0, 0, 0, 0, SWP_NOZORDER);
4195 REBAR_NCHitTest (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
4202 LRESULT ret
= HTCLIENT
;
4205 * Differences from doc at MSDN (as observed with version 4.71 of
4207 * 1. doc says nmmouse.pt is in screen coord, trace shows client coord.
4208 * 2. if band is not identified .dwItemSpec is 0xffffffff.
4209 * 3. native always seems to return HTCLIENT if notify return is 0.
4212 shortpt
= MAKEPOINTS (lParam
);
4213 POINTSTOPOINT(pt
, shortpt
);
4215 ScreenToClient (infoPtr
->hwndSelf
, &clpt
);
4216 REBAR_InternalHitTest (infoPtr
, &clpt
, &scrap
,
4217 (INT
*)&nmmouse
.dwItemSpec
);
4218 nmmouse
.dwItemData
= 0;
4220 nmmouse
.dwHitInfo
= 0;
4221 if ((i
= REBAR_Notify((NMHDR
*) &nmmouse
, infoPtr
, NM_NCHITTEST
))) {
4222 TRACE("notify changed return value from %ld to %d\n",
4226 TRACE("returning %ld, client point (%ld,%ld)\n", ret
, clpt
.x
, clpt
.y
);
4232 REBAR_NCPaint (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
4237 if (infoPtr
->dwStyle
& WS_MINIMIZE
)
4238 return 0; /* Nothing to do */
4240 if (infoPtr
->dwStyle
& WS_BORDER
) {
4242 /* adjust rectangle and draw the necessary edge */
4243 if (!(hdc
= GetDCEx( infoPtr
->hwndSelf
, 0, DCX_USESTYLE
| DCX_WINDOW
)))
4245 GetWindowRect (infoPtr
->hwndSelf
, &rcWindow
);
4246 OffsetRect (&rcWindow
, -rcWindow
.left
, -rcWindow
.top
);
4247 TRACE("rect (%ld,%ld)-(%ld,%ld)\n",
4248 rcWindow
.left
, rcWindow
.top
,
4249 rcWindow
.right
, rcWindow
.bottom
);
4250 DrawEdge (hdc
, &rcWindow
, EDGE_ETCHED
, BF_RECT
);
4251 ReleaseDC( infoPtr
->hwndSelf
, hdc
);
4259 REBAR_NotifyFormat (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
4263 if (lParam
== NF_REQUERY
) {
4264 i
= SendMessageA(REBAR_GetNotifyParent (infoPtr
),
4265 WM_NOTIFYFORMAT
, (WPARAM
)infoPtr
->hwndSelf
, NF_QUERY
);
4266 if ((i
< NFR_ANSI
) || (i
> NFR_UNICODE
)) {
4267 ERR("wrong response to WM_NOTIFYFORMAT (%d), assuming ANSI\n",
4271 infoPtr
->NtfUnicode
= (i
== NFR_UNICODE
) ? 1 : 0;
4274 return (LRESULT
)((infoPtr
->bUnicode
) ? NFR_UNICODE
: NFR_ANSI
);
4279 REBAR_Paint (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
4285 GetClientRect(infoPtr
->hwndSelf
, &rc
);
4286 hdc
= wParam
==0 ? BeginPaint (infoPtr
->hwndSelf
, &ps
) : (HDC
)wParam
;
4288 TRACE("painting (%ld,%ld)-(%ld,%ld) client (%ld,%ld)-(%ld,%ld)\n",
4289 ps
.rcPaint
.left
, ps
.rcPaint
.top
,
4290 ps
.rcPaint
.right
, ps
.rcPaint
.bottom
,
4291 rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
4294 /* Erase area of paint if requested */
4295 REBAR_InternalEraseBkGnd (infoPtr
, wParam
, lParam
, &ps
.rcPaint
);
4298 REBAR_Refresh (infoPtr
, hdc
);
4300 EndPaint (infoPtr
->hwndSelf
, &ps
);
4306 REBAR_SetCursor (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
4311 TRACE("code=0x%X id=0x%X\n", LOWORD(lParam
), HIWORD(lParam
));
4314 ScreenToClient (infoPtr
->hwndSelf
, &pt
);
4316 REBAR_InternalHitTest (infoPtr
, &pt
, &flags
, NULL
);
4318 if (flags
== RBHT_GRABBER
) {
4319 if ((infoPtr
->dwStyle
& CCS_VERT
) &&
4320 !(infoPtr
->dwStyle
& RBS_VERTICALGRIPPER
))
4321 SetCursor (infoPtr
->hcurVert
);
4323 SetCursor (infoPtr
->hcurHorz
);
4325 else if (flags
!= RBHT_CLIENT
)
4326 SetCursor (infoPtr
->hcurArrow
);
4333 REBAR_SetFont (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
4339 infoPtr
->hFont
= (HFONT
)wParam
;
4341 /* revalidate all bands to change sizes of text in headers of bands */
4342 for (i
=0; i
<infoPtr
->uNumBands
; i
++) {
4343 lpBand
= &infoPtr
->bands
[i
];
4344 REBAR_ValidateBand (infoPtr
, lpBand
);
4348 if (LOWORD(lParam
)) {
4349 GetClientRect (infoPtr
->hwndSelf
, &rcClient
);
4350 REBAR_Layout (infoPtr
, &rcClient
, FALSE
, TRUE
);
4357 inline static LRESULT
4358 REBAR_SetRedraw (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
4359 /*****************************************************
4362 * Handles the WM_SETREDRAW message.
4365 * According to testing V4.71 of COMCTL32 returns the
4366 * *previous* status of the redraw flag (either 0 or -1)
4367 * instead of the MSDN documented value of 0 if handled
4369 *****************************************************/
4371 BOOL oldredraw
= infoPtr
->DoRedraw
;
4373 TRACE("set to %s, fStatus=%08x\n",
4374 (wParam
) ? "TRUE" : "FALSE", infoPtr
->fStatus
);
4375 infoPtr
->DoRedraw
= (BOOL
) wParam
;
4377 if (infoPtr
->fStatus
& BAND_NEEDS_REDRAW
) {
4378 REBAR_MoveChildWindows (infoPtr
, 0, infoPtr
->uNumBands
);
4379 REBAR_ForceResize (infoPtr
);
4380 InvalidateRect (infoPtr
->hwndSelf
, 0, TRUE
);
4382 infoPtr
->fStatus
&= ~BAND_NEEDS_REDRAW
;
4384 return (oldredraw
) ? -1 : 0;
4389 REBAR_Size (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
4393 /* auto resize deadlock check */
4394 if (infoPtr
->fStatus
& AUTO_RESIZE
) {
4395 infoPtr
->fStatus
&= ~AUTO_RESIZE
;
4396 TRACE("AUTO_RESIZE was set, reset, fStatus=%08x lparam=%08lx\n",
4397 infoPtr
->fStatus
, lParam
);
4401 if (infoPtr
->fStatus
& CREATE_RUNNING
) {
4402 /* still in CreateWindow */
4405 if ((INT
)wParam
!= SIZE_RESTORED
) {
4406 ERR("WM_SIZE in create and flags=%08x, lParam=%08lx\n",
4410 TRACE("still in CreateWindow\n");
4411 infoPtr
->fStatus
&= ~CREATE_RUNNING
;
4412 GetWindowRect ( infoPtr
->hwndSelf
, &rcWin
);
4413 TRACE("win rect (%ld,%ld)-(%ld,%ld)\n",
4414 rcWin
.left
, rcWin
.top
, rcWin
.right
, rcWin
.bottom
);
4416 if ((lParam
== 0) && (rcWin
.right
-rcWin
.left
== 0) &&
4417 (rcWin
.bottom
-rcWin
.top
== 0)) {
4418 /* native control seems to do this */
4419 GetClientRect (GetParent(infoPtr
->hwndSelf
), &rcClient
);
4420 TRACE("sizing rebar, message and client zero, parent client (%ld,%ld)\n",
4421 rcClient
.right
, rcClient
.bottom
);
4426 cx
= rcWin
.right
- rcWin
.left
;
4427 cy
= rcWin
.bottom
- rcWin
.top
;
4428 if ((cx
== LOWORD(lParam
)) && (cy
== HIWORD(lParam
))) {
4432 /* do the actual WM_SIZE request */
4433 GetClientRect (infoPtr
->hwndSelf
, &rcClient
);
4434 TRACE("sizing rebar from (%ld,%ld) to (%d,%d), client (%ld,%ld)\n",
4435 infoPtr
->calcSize
.cx
, infoPtr
->calcSize
.cy
,
4436 LOWORD(lParam
), HIWORD(lParam
),
4437 rcClient
.right
, rcClient
.bottom
);
4441 if ((INT
)wParam
!= SIZE_RESTORED
) {
4442 ERR("WM_SIZE out of create and flags=%08x, lParam=%08lx\n",
4446 /* Handle cases when outside of the CreateWindow process */
4448 GetClientRect (infoPtr
->hwndSelf
, &rcClient
);
4449 if ((lParam
== 0) && (rcClient
.right
+ rcClient
.bottom
!= 0) &&
4450 (infoPtr
->dwStyle
& RBS_AUTOSIZE
)) {
4451 /* on a WM_SIZE to zero and current client not zero and AUTOSIZE */
4452 /* native seems to use the current client rect for the size */
4453 infoPtr
->fStatus
|= BAND_NEEDS_LAYOUT
;
4454 TRACE("sizing rebar to client (%ld,%ld) size is zero but AUTOSIZE set\n",
4455 rcClient
.right
, rcClient
.bottom
);
4458 TRACE("sizing rebar from (%ld,%ld) to (%d,%d), client (%ld,%ld)\n",
4459 infoPtr
->calcSize
.cx
, infoPtr
->calcSize
.cy
,
4460 LOWORD(lParam
), HIWORD(lParam
),
4461 rcClient
.right
, rcClient
.bottom
);
4465 if (infoPtr
->dwStyle
& RBS_AUTOSIZE
) {
4466 NMRBAUTOSIZE autosize
;
4468 GetClientRect(infoPtr
->hwndSelf
, &autosize
.rcTarget
);
4469 autosize
.fChanged
= 0; /* ??? */
4470 autosize
.rcActual
= autosize
.rcTarget
; /* ??? */
4471 REBAR_Notify((NMHDR
*) &autosize
, infoPtr
, RBN_AUTOSIZE
);
4472 TRACE("RBN_AUTOSIZE client=(%ld,%ld), lp=%08lx\n",
4473 autosize
.rcTarget
.right
, autosize
.rcTarget
.bottom
, lParam
);
4476 if ((infoPtr
->calcSize
.cx
!= rcClient
.right
) ||
4477 (infoPtr
->calcSize
.cy
!= rcClient
.bottom
))
4478 infoPtr
->fStatus
|= BAND_NEEDS_LAYOUT
;
4480 REBAR_Layout (infoPtr
, &rcClient
, TRUE
, TRUE
);
4481 infoPtr
->fStatus
&= ~AUTO_RESIZE
;
4488 REBAR_StyleChanged (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
4490 STYLESTRUCT
*ss
= (STYLESTRUCT
*)lParam
;
4492 TRACE("current style=%08lx, styleOld=%08lx, style being set to=%08lx\n",
4493 infoPtr
->dwStyle
, ss
->styleOld
, ss
->styleNew
);
4494 infoPtr
->dwStyle
= ss
->styleNew
;
4501 REBAR_WindowPosChanged (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
4503 WINDOWPOS
*lpwp
= (WINDOWPOS
*)lParam
;
4507 /* Save the new origin of this window - used by _ForceResize */
4508 infoPtr
->origin
.x
= lpwp
->x
;
4509 infoPtr
->origin
.y
= lpwp
->y
;
4510 ret
= DefWindowProcA(infoPtr
->hwndSelf
, WM_WINDOWPOSCHANGED
,
4512 GetWindowRect(infoPtr
->hwndSelf
, &rc
);
4513 TRACE("hwnd %p new pos (%ld,%ld)-(%ld,%ld)\n",
4514 infoPtr
->hwndSelf
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
4519 static LRESULT WINAPI
4520 REBAR_WindowProc (HWND hwnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
)
4522 REBAR_INFO
*infoPtr
= REBAR_GetInfoPtr (hwnd
);
4524 TRACE("hwnd=%p msg=%x wparam=%x lparam=%lx\n",
4525 hwnd
, uMsg
, wParam
, lParam
);
4526 if (!infoPtr
&& (uMsg
!= WM_NCCREATE
))
4527 return DefWindowProcA (hwnd
, uMsg
, wParam
, lParam
);
4530 /* case RB_BEGINDRAG: */
4533 return REBAR_DeleteBand (infoPtr
, wParam
, lParam
);
4535 /* case RB_DRAGMOVE: */
4536 /* case RB_ENDDRAG: */
4538 case RB_GETBANDBORDERS
:
4539 return REBAR_GetBandBorders (infoPtr
, wParam
, lParam
);
4541 case RB_GETBANDCOUNT
:
4542 return REBAR_GetBandCount (infoPtr
);
4544 case RB_GETBANDINFO
: /* obsoleted after IE3, but we have to
4545 support it anyway. */
4546 case RB_GETBANDINFOA
:
4547 return REBAR_GetBandInfoA (infoPtr
, wParam
, lParam
);
4549 case RB_GETBANDINFOW
:
4550 return REBAR_GetBandInfoW (infoPtr
, wParam
, lParam
);
4552 case RB_GETBARHEIGHT
:
4553 return REBAR_GetBarHeight (infoPtr
, wParam
, lParam
);
4556 return REBAR_GetBarInfo (infoPtr
, wParam
, lParam
);
4559 return REBAR_GetBkColor (infoPtr
);
4561 /* case RB_GETCOLORSCHEME: */
4562 /* case RB_GETDROPTARGET: */
4565 return REBAR_GetPalette (infoPtr
, wParam
, lParam
);
4568 return REBAR_GetRect (infoPtr
, wParam
, lParam
);
4570 case RB_GETROWCOUNT
:
4571 return REBAR_GetRowCount (infoPtr
);
4573 case RB_GETROWHEIGHT
:
4574 return REBAR_GetRowHeight (infoPtr
, wParam
, lParam
);
4576 case RB_GETTEXTCOLOR
:
4577 return REBAR_GetTextColor (infoPtr
);
4579 case RB_GETTOOLTIPS
:
4580 return REBAR_GetToolTips (infoPtr
);
4582 case RB_GETUNICODEFORMAT
:
4583 return REBAR_GetUnicodeFormat (infoPtr
);
4585 case CCM_GETVERSION
:
4586 return REBAR_GetVersion (infoPtr
);
4589 return REBAR_HitTest (infoPtr
, wParam
, lParam
);
4592 return REBAR_IdToIndex (infoPtr
, wParam
, lParam
);
4594 case RB_INSERTBANDA
:
4595 return REBAR_InsertBandA (infoPtr
, wParam
, lParam
);
4597 case RB_INSERTBANDW
:
4598 return REBAR_InsertBandW (infoPtr
, wParam
, lParam
);
4600 case RB_MAXIMIZEBAND
:
4601 return REBAR_MaximizeBand (infoPtr
, wParam
, lParam
);
4603 case RB_MINIMIZEBAND
:
4604 return REBAR_MinimizeBand (infoPtr
, wParam
, lParam
);
4607 return REBAR_MoveBand (infoPtr
, wParam
, lParam
);
4609 case RB_PUSHCHEVRON
:
4610 return REBAR_PushChevron (infoPtr
, wParam
, lParam
);
4612 case RB_SETBANDINFOA
:
4613 return REBAR_SetBandInfoA (infoPtr
, wParam
, lParam
);
4615 case RB_SETBANDINFOW
:
4616 return REBAR_SetBandInfoW (infoPtr
, wParam
, lParam
);
4619 return REBAR_SetBarInfo (infoPtr
, wParam
, lParam
);
4622 return REBAR_SetBkColor (infoPtr
, wParam
, lParam
);
4624 /* case RB_SETCOLORSCHEME: */
4625 /* case RB_SETPALETTE: */
4626 /* return REBAR_GetPalette (infoPtr, wParam, lParam); */
4629 return REBAR_SetParent (infoPtr
, wParam
, lParam
);
4631 case RB_SETTEXTCOLOR
:
4632 return REBAR_SetTextColor (infoPtr
, wParam
, lParam
);
4634 /* case RB_SETTOOLTIPS: */
4636 case RB_SETUNICODEFORMAT
:
4637 return REBAR_SetUnicodeFormat (infoPtr
, wParam
);
4639 case CCM_SETVERSION
:
4640 return REBAR_SetVersion (infoPtr
, (INT
)wParam
);
4643 return REBAR_ShowBand (infoPtr
, wParam
, lParam
);
4646 return REBAR_SizeToRect (infoPtr
, wParam
, lParam
);
4649 /* Messages passed to parent */
4653 if (infoPtr
->NtfUnicode
)
4654 return SendMessageW (REBAR_GetNotifyParent (infoPtr
),
4655 uMsg
, wParam
, lParam
);
4657 return SendMessageA (REBAR_GetNotifyParent (infoPtr
),
4658 uMsg
, wParam
, lParam
);
4661 /* case WM_CHARTOITEM: supported according to ControlSpy */
4664 return REBAR_Create (infoPtr
, wParam
, lParam
);
4667 return REBAR_Destroy (infoPtr
, wParam
, lParam
);
4670 return REBAR_EraseBkGnd (infoPtr
, wParam
, lParam
);
4673 return REBAR_GetFont (infoPtr
, wParam
, lParam
);
4675 /* case WM_LBUTTONDBLCLK: supported according to ControlSpy */
4677 case WM_LBUTTONDOWN
:
4678 return REBAR_LButtonDown (infoPtr
, wParam
, lParam
);
4681 return REBAR_LButtonUp (infoPtr
, wParam
, lParam
);
4683 /* case WM_MEASUREITEM: supported according to ControlSpy */
4686 return REBAR_MouseMove (infoPtr
, wParam
, lParam
);
4689 return REBAR_MouseLeave (infoPtr
, wParam
, lParam
);
4692 return REBAR_NCCalcSize (infoPtr
, wParam
, lParam
);
4695 return REBAR_NCCreate (hwnd
, wParam
, lParam
);
4698 return REBAR_NCHitTest (infoPtr
, wParam
, lParam
);
4701 return REBAR_NCPaint (infoPtr
, wParam
, lParam
);
4703 case WM_NOTIFYFORMAT
:
4704 return REBAR_NotifyFormat (infoPtr
, wParam
, lParam
);
4707 return REBAR_Paint (infoPtr
, wParam
, lParam
);
4709 /* case WM_PALETTECHANGED: supported according to ControlSpy */
4710 /* case WM_PRINTCLIENT: supported according to ControlSpy */
4711 /* case WM_QUERYNEWPALETTE:supported according to ControlSpy */
4712 /* case WM_RBUTTONDOWN: supported according to ControlSpy */
4713 /* case WM_RBUTTONUP: supported according to ControlSpy */
4716 return REBAR_SetCursor (infoPtr
, wParam
, lParam
);
4719 return REBAR_SetFont (infoPtr
, wParam
, lParam
);
4722 return REBAR_SetRedraw (infoPtr
, wParam
, lParam
);
4725 return REBAR_Size (infoPtr
, wParam
, lParam
);
4727 case WM_STYLECHANGED
:
4728 return REBAR_StyleChanged (infoPtr
, wParam
, lParam
);
4730 /* case WM_SYSCOLORCHANGE: supported according to ControlSpy */
4731 /* "Applications that have brushes using the existing system colors
4732 should delete those brushes and recreate them using the new
4733 system colors." per MSDN */
4735 /* case WM_VKEYTOITEM: supported according to ControlSpy */
4736 /* case WM_WININICHANGE: */
4738 case WM_WINDOWPOSCHANGED
:
4739 return REBAR_WindowPosChanged (infoPtr
, wParam
, lParam
);
4742 if ((uMsg
>= WM_USER
) && (uMsg
< WM_APP
))
4743 ERR("unknown msg %04x wp=%08x lp=%08lx\n",
4744 uMsg
, wParam
, lParam
);
4745 return DefWindowProcA (hwnd
, uMsg
, wParam
, lParam
);
4752 REBAR_Register (void)
4756 ZeroMemory (&wndClass
, sizeof(WNDCLASSA
));
4757 wndClass
.style
= CS_GLOBALCLASS
| CS_DBLCLKS
;
4758 wndClass
.lpfnWndProc
= (WNDPROC
)REBAR_WindowProc
;
4759 wndClass
.cbClsExtra
= 0;
4760 wndClass
.cbWndExtra
= sizeof(REBAR_INFO
*);
4761 wndClass
.hCursor
= 0;
4762 wndClass
.hbrBackground
= (HBRUSH
)(COLOR_BTNFACE
+ 1);
4764 wndClass
.hbrBackground
= CreateSolidBrush(RGB(0,128,0));
4766 wndClass
.lpszClassName
= REBARCLASSNAMEA
;
4768 RegisterClassA (&wndClass
);
4770 mindragx
= GetSystemMetrics (SM_CXDRAG
);
4771 mindragy
= GetSystemMetrics (SM_CYDRAG
);
4777 REBAR_Unregister (void)
4779 UnregisterClassA (REBARCLASSNAMEA
, NULL
);