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,
122 * RBBS_USECHEVRON, CCS_NORESIZE,
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
139 * RB_CHEVRONPUSHED, RBN_MINMAX
147 #include "wine/unicode.h"
148 #include "commctrl.h"
149 #include "wine/debug.h"
151 WINE_DEFAULT_DEBUG_CHANNEL(rebar
);
161 UINT cxMinChild
; /* valid if _CHILDSIZE */
162 UINT cyMinChild
; /* valid if _CHILDSIZE */
163 UINT cx
; /* valid if _SIZE */
166 UINT cyChild
; /* valid if _CHILDSIZE */
167 UINT cyMaxChild
; /* valid if _CHILDSIZE */
168 UINT cyIntegral
; /* valid if _CHILDSIZE */
173 UINT lcx
; /* minimum cx for band */
174 UINT ccx
; /* current cx for band */
175 UINT hcx
; /* maximum cx for band */
176 UINT lcy
; /* minimum cy for band */
177 UINT ccy
; /* current cy for band */
178 UINT hcy
; /* maximum cy for band */
180 SIZE offChild
; /* x,y offset if child is not FIXEDSIZE */
182 INT iRow
; /* row this band assigned to */
183 UINT fStatus
; /* status flags, reset only by _Validate */
184 UINT fDraw
; /* drawing flags, reset only by _Layout */
185 UINT uCDret
; /* last return from NM_CUSTOMDRAW */
186 RECT rcoldBand
; /* previous calculated band rectangle */
187 RECT rcBand
; /* calculated band rectangle */
188 RECT rcGripper
; /* calculated gripper rectangle */
189 RECT rcCapImage
; /* calculated caption image rectangle */
190 RECT rcCapText
; /* calculated caption text rectangle */
191 RECT rcChild
; /* calculated child rectangle */
198 #define HAS_GRIPPER 0x00000001
199 #define HAS_IMAGE 0x00000002
200 #define HAS_TEXT 0x00000004
203 #define DRAW_GRIPPER 0x00000001
204 #define DRAW_IMAGE 0x00000002
205 #define DRAW_TEXT 0x00000004
206 #define DRAW_RIGHTSEP 0x00000010
207 #define DRAW_BOTTOMSEP 0x00000020
208 #define NTF_INVALIDATE 0x01000000
212 INT istartband
; /* index of first band in row */
213 INT iendband
; /* index of last band in row */
219 COLORREF clrBk
; /* background color */
220 COLORREF clrText
; /* text color */
221 COLORREF clrBtnText
; /* system color for BTNTEXT */
222 COLORREF clrBtnFace
; /* system color for BTNFACE */
223 HIMAGELIST himl
; /* handle to imagelist */
224 UINT uNumBands
; /* # of bands in rebar (first=0, last=uNumBands-1 */
225 UINT uNumRows
; /* # of rows of bands (first=1, last=uNumRows */
226 HWND hwndSelf
; /* handle of REBAR window itself */
227 HWND hwndToolTip
; /* handle to the tool tip control */
228 HWND hwndNotify
; /* notification window (parent) */
230 HFONT hFont
; /* handle to the rebar's font */
231 SIZE imageSize
; /* image size (image list) */
232 DWORD dwStyle
; /* window style */
233 SIZE calcSize
; /* calculated rebar size */
234 SIZE oldSize
; /* previous calculated rebar size */
235 BOOL bUnicode
; /* TRUE if this window is W type */
236 BOOL NtfUnicode
; /* TRUE if parent wants notify in W format */
237 BOOL DoRedraw
; /* TRUE to acutally draw bands */
238 UINT fStatus
; /* Status flags (see below) */
239 HCURSOR hcurArrow
; /* handle to the arrow cursor */
240 HCURSOR hcurHorz
; /* handle to the EW cursor */
241 HCURSOR hcurVert
; /* handle to the NS cursor */
242 HCURSOR hcurDrag
; /* handle to the drag cursor */
243 INT iVersion
; /* version number */
244 POINTS dragStart
; /* x,y of button down */
245 POINTS dragNow
; /* x,y of this MouseMove */
246 INT ihitBand
; /* band number of band whose gripper was grabbed */
247 INT ihitoffset
; /* offset of hotspot from gripper.left */
248 POINT origin
; /* left/upper corner of client */
250 REBAR_ROW
*rows
; /* pointer to row indexes */
251 REBAR_BAND
*bands
; /* pointer to the array of rebar bands */
255 #define BEGIN_DRAG_ISSUED 0x00000001
256 #define AUTO_RESIZE 0x00000002
257 #define RESIZE_ANYHOW 0x00000004
258 #define NTF_HGHTCHG 0x00000008
259 #define BAND_NEEDS_LAYOUT 0x00000010
260 #define BAND_NEEDS_REDRAW 0x00000020
261 #define CREATE_RUNNING 0x00000040
263 /* ---- REBAR layout constants. Mostly determined by ---- */
264 /* ---- experiment on WIN 98. ---- */
266 /* Width (or height) of separators between bands (either horz. or */
267 /* vert.). True only if RBS_BANDBORDERS is set */
268 #define SEP_WIDTH_SIZE 2
269 #define SEP_WIDTH ((infoPtr->dwStyle & RBS_BANDBORDERS) ? SEP_WIDTH_SIZE : 0)
271 /* Blank (background color) space between Gripper (if present) */
272 /* and next item (image, text, or window). Always present */
273 #define REBAR_ALWAYS_SPACE 4
275 /* Blank (background color) space after Image (if present). */
276 #define REBAR_POST_IMAGE 2
278 /* Blank (background color) space after Text (if present). */
279 #define REBAR_POST_TEXT 4
281 /* Height of vertical gripper in a CCS_VERT rebar. */
282 #define GRIPPER_HEIGHT 16
284 /* Blank (background color) space before Gripper (if present). */
285 #define REBAR_PRE_GRIPPER 2
287 /* Width (of normal vertical gripper) or height (of horz. gripper) */
289 #define GRIPPER_WIDTH 3
291 /* Height of divider for Rebar if not disabled (CCS_NODIVIDER) */
292 /* either top or bottom */
293 #define REBAR_DIVIDER 2
295 /* This is the increment that is used over the band height */
296 #define REBARSPACE(a) ((a->fStyle & RBBS_CHILDEDGE) ? 2*REBAR_DIVIDER : 0)
298 /* ---- End of REBAR layout constants. ---- */
301 /* The following 6 defines return the proper rcBand element */
302 /* depending on whether CCS_VERT was set. */
303 #define rcBlt(b) ((infoPtr->dwStyle & CCS_VERT) ? b->rcBand.top : b->rcBand.left)
304 #define rcBrb(b) ((infoPtr->dwStyle & CCS_VERT) ? b->rcBand.bottom : b->rcBand.right)
305 #define rcBw(b) ((infoPtr->dwStyle & CCS_VERT) ? (b->rcBand.bottom - b->rcBand.top) : \
306 (b->rcBand.right - b->rcBand.left))
307 #define ircBlt(b) ((infoPtr->dwStyle & CCS_VERT) ? b->rcBand.left : b->rcBand.top)
308 #define ircBrb(b) ((infoPtr->dwStyle & CCS_VERT) ? b->rcBand.right : b->rcBand.bottom)
309 #define ircBw(b) ((infoPtr->dwStyle & CCS_VERT) ? (b->rcBand.right - b->rcBand.left) : \
310 (b->rcBand.bottom - b->rcBand.top))
312 /* The following define determines if a given band is hidden */
313 #define HIDDENBAND(a) (((a)->fStyle & RBBS_HIDDEN) || \
314 ((infoPtr->dwStyle & CCS_VERT) && \
315 ((a)->fStyle & RBBS_NOVERT)))
317 /* The following defines adjust the right or left end of a rectangle */
318 #define READJ(b,i) do { if(infoPtr->dwStyle & CCS_VERT) b->rcBand.bottom+=(i); \
319 else b->rcBand.right += (i); } while(0)
320 #define LEADJ(b,i) do { if(infoPtr->dwStyle & CCS_VERT) b->rcBand.top+=(i); \
321 else b->rcBand.left += (i); } while(0)
324 #define REBAR_GetInfoPtr(wndPtr) ((REBAR_INFO *)GetWindowLongA (hwnd, 0))
327 /* "constant values" retrieved when DLL was initialized */
328 /* FIXME we do this when the classes are registered. */
329 static UINT mindragx
= 0;
330 static UINT mindragy
= 0;
332 static char *band_stylename
[] = {
333 "RBBS_BREAK", /* 0001 */
334 "RBBS_FIXEDSIZE", /* 0002 */
335 "RBBS_CHILDEDGE", /* 0004 */
336 "RBBS_HIDDEN", /* 0008 */
337 "RBBS_NOVERT", /* 0010 */
338 "RBBS_FIXEDBMP", /* 0020 */
339 "RBBS_VARIABLEHEIGHT", /* 0040 */
340 "RBBS_GRIPPERALWAYS", /* 0080 */
341 "RBBS_NOGRIPPER", /* 0100 */
344 static char *band_maskname
[] = {
345 "RBBIM_STYLE", /* 0x00000001 */
346 "RBBIM_COLORS", /* 0x00000002 */
347 "RBBIM_TEXT", /* 0x00000004 */
348 "RBBIM_IMAGE", /* 0x00000008 */
349 "RBBIM_CHILD", /* 0x00000010 */
350 "RBBIM_CHILDSIZE", /* 0x00000020 */
351 "RBBIM_SIZE", /* 0x00000040 */
352 "RBBIM_BACKGROUND", /* 0x00000080 */
353 "RBBIM_ID", /* 0x00000100 */
354 "RBBIM_IDEALSIZE", /* 0x00000200 */
355 "RBBIM_LPARAM", /* 0x00000400 */
356 "RBBIM_HEADERSIZE", /* 0x00000800 */
360 static CHAR line
[200];
364 REBAR_FmtStyle( UINT style
)
369 while (band_stylename
[i
]) {
370 if (style
& (1<<i
)) {
371 if (*line
!= 0) strcat(line
, " | ");
372 strcat(line
, band_stylename
[i
]);
381 REBAR_FmtMask( UINT mask
)
386 while (band_maskname
[i
]) {
388 if (*line
!= 0) strcat(line
, " | ");
389 strcat(line
, band_maskname
[i
]);
398 REBAR_DumpBandInfo( LPREBARBANDINFOA pB
)
400 if( !TRACE_ON(rebar
) ) return;
401 TRACE("band info: ID=%u, size=%u, child=%p, clrF=0x%06lx, clrB=0x%06lx\n",
402 pB
->wID
, pB
->cbSize
, pB
->hwndChild
, pB
->clrFore
, pB
->clrBack
);
403 TRACE("band info: mask=0x%08x (%s)\n", pB
->fMask
, REBAR_FmtMask(pB
->fMask
));
404 if (pB
->fMask
& RBBIM_STYLE
)
405 TRACE("band info: style=0x%08x (%s)\n", pB
->fStyle
, REBAR_FmtStyle(pB
->fStyle
));
406 if (pB
->fMask
& (RBBIM_SIZE
| RBBIM_IDEALSIZE
| RBBIM_HEADERSIZE
| RBBIM_LPARAM
)) {
408 if (pB
->fMask
& RBBIM_SIZE
)
409 DPRINTF(" cx=%u", pB
->cx
);
410 if (pB
->fMask
& RBBIM_IDEALSIZE
)
411 DPRINTF(" xIdeal=%u", pB
->cxIdeal
);
412 if (pB
->fMask
& RBBIM_HEADERSIZE
)
413 DPRINTF(" xHeader=%u", pB
->cxHeader
);
414 if (pB
->fMask
& RBBIM_LPARAM
)
415 DPRINTF(" lParam=0x%08lx", pB
->lParam
);
418 if (pB
->fMask
& RBBIM_CHILDSIZE
)
419 TRACE("band info: xMin=%u, yMin=%u, yChild=%u, yMax=%u, yIntgl=%u\n",
421 pB
->cyMinChild
, pB
->cyChild
, pB
->cyMaxChild
, pB
->cyIntegral
);
425 REBAR_DumpBand (REBAR_INFO
*iP
)
430 if(! TRACE_ON(rebar
) ) return;
432 TRACE("hwnd=%p: color=%08lx/%08lx, bands=%u, rows=%u, cSize=%ld,%ld\n",
433 iP
->hwndSelf
, iP
->clrText
, iP
->clrBk
, iP
->uNumBands
, iP
->uNumRows
,
434 iP
->calcSize
.cx
, iP
->calcSize
.cy
);
435 TRACE("hwnd=%p: flags=%08x, dragStart=%d,%d, dragNow=%d,%d, ihitBand=%d\n",
436 iP
->hwndSelf
, iP
->fStatus
, iP
->dragStart
.x
, iP
->dragStart
.y
,
437 iP
->dragNow
.x
, iP
->dragNow
.y
,
439 TRACE("hwnd=%p: style=%08lx, I'm Unicode=%s, notify in Unicode=%s, redraw=%s\n",
440 iP
->hwndSelf
, iP
->dwStyle
, (iP
->bUnicode
)?"TRUE":"FALSE",
441 (iP
->NtfUnicode
)?"TRUE":"FALSE", (iP
->DoRedraw
)?"TRUE":"FALSE");
442 for (i
= 0; i
< iP
->uNumBands
; i
++) {
444 TRACE("band # %u: ID=%u, child=%p, row=%u, clrF=0x%06lx, clrB=0x%06lx\n",
445 i
, pB
->wID
, pB
->hwndChild
, pB
->iRow
, pB
->clrFore
, pB
->clrBack
);
446 TRACE("band # %u: mask=0x%08x (%s)\n", i
, pB
->fMask
, REBAR_FmtMask(pB
->fMask
));
447 if (pB
->fMask
& RBBIM_STYLE
)
448 TRACE("band # %u: style=0x%08x (%s)\n",
449 i
, pB
->fStyle
, REBAR_FmtStyle(pB
->fStyle
));
450 TRACE("band # %u: uMinH=%u xHeader=%u",
451 i
, pB
->uMinHeight
, pB
->cxHeader
);
452 if (pB
->fMask
& (RBBIM_SIZE
| RBBIM_IDEALSIZE
| RBBIM_LPARAM
)) {
453 if (pB
->fMask
& RBBIM_SIZE
)
454 DPRINTF(" cx=%u", pB
->cx
);
455 if (pB
->fMask
& RBBIM_IDEALSIZE
)
456 DPRINTF(" xIdeal=%u", pB
->cxIdeal
);
457 if (pB
->fMask
& RBBIM_LPARAM
)
458 DPRINTF(" lParam=0x%08lx", pB
->lParam
);
462 TRACE("band # %u: xMin=%u, yMin=%u, yChild=%u, yMax=%u, yIntgl=%u\n",
463 i
, pB
->cxMinChild
, pB
->cyMinChild
, pB
->cyChild
, pB
->cyMaxChild
, pB
->cyIntegral
);
464 if (pB
->fMask
& RBBIM_TEXT
)
465 TRACE("band # %u: text=%s\n",
466 i
, (pB
->lpText
) ? debugstr_w(pB
->lpText
) : "(null)");
467 TRACE("band # %u: lcx=%u, ccx=%u, hcx=%u, lcy=%u, ccy=%u, hcy=%u, offChild=%ld,%ld\n",
468 i
, pB
->lcx
, pB
->ccx
, pB
->hcx
, pB
->lcy
, pB
->ccy
, pB
->hcy
, pB
->offChild
.cx
, pB
->offChild
.cy
);
469 TRACE("band # %u: fStatus=%08x, fDraw=%08x, Band=(%d,%d)-(%d,%d), Grip=(%d,%d)-(%d,%d)\n",
470 i
, pB
->fStatus
, pB
->fDraw
,
471 pB
->rcBand
.left
, pB
->rcBand
.top
, pB
->rcBand
.right
, pB
->rcBand
.bottom
,
472 pB
->rcGripper
.left
, pB
->rcGripper
.top
, pB
->rcGripper
.right
, pB
->rcGripper
.bottom
);
473 TRACE("band # %u: Img=(%d,%d)-(%d,%d), Txt=(%d,%d)-(%d,%d), Child=(%d,%d)-(%d,%d)\n",
475 pB
->rcCapImage
.left
, pB
->rcCapImage
.top
, pB
->rcCapImage
.right
, pB
->rcCapImage
.bottom
,
476 pB
->rcCapText
.left
, pB
->rcCapText
.top
, pB
->rcCapText
.right
, pB
->rcCapText
.bottom
,
477 pB
->rcChild
.left
, pB
->rcChild
.top
, pB
->rcChild
.right
, pB
->rcChild
.bottom
);
484 REBAR_GetNotifyParent (REBAR_INFO
*infoPtr
)
488 parent
= infoPtr
->hwndNotify
;
490 parent
= GetParent (infoPtr
->hwndSelf
);
491 owner
= GetWindow (infoPtr
->hwndSelf
, GW_OWNER
);
492 if (owner
) parent
= owner
;
499 REBAR_Notify (NMHDR
*nmhdr
, REBAR_INFO
*infoPtr
, UINT code
)
503 parent
= REBAR_GetNotifyParent (infoPtr
);
504 nmhdr
->idFrom
= GetDlgCtrlID (infoPtr
->hwndSelf
);
505 nmhdr
->hwndFrom
= infoPtr
->hwndSelf
;
508 TRACE("window %p, code=%08x, %s\n", parent
, code
,
509 (infoPtr
->NtfUnicode
) ? "via Unicode" : "via ANSI");
511 if (infoPtr
->NtfUnicode
)
512 return SendMessageW (parent
, WM_NOTIFY
, (WPARAM
) nmhdr
->idFrom
,
515 return SendMessageA (parent
, WM_NOTIFY
, (WPARAM
) nmhdr
->idFrom
,
520 REBAR_Notify_NMREBAR (REBAR_INFO
*infoPtr
, UINT uBand
, UINT code
)
522 NMREBAR notify_rebar
;
525 notify_rebar
.dwMask
= 0;
527 lpBand
= &infoPtr
->bands
[uBand
];
528 if (lpBand
->fMask
& RBBIM_ID
) {
529 notify_rebar
.dwMask
|= RBNM_ID
;
530 notify_rebar
.wID
= lpBand
->wID
;
532 if (lpBand
->fMask
& RBBIM_LPARAM
) {
533 notify_rebar
.dwMask
|= RBNM_LPARAM
;
534 notify_rebar
.lParam
= lpBand
->lParam
;
536 if (lpBand
->fMask
& RBBIM_STYLE
) {
537 notify_rebar
.dwMask
|= RBNM_STYLE
;
538 notify_rebar
.fStyle
= lpBand
->fStyle
;
541 notify_rebar
.uBand
= uBand
;
542 return REBAR_Notify ((NMHDR
*)¬ify_rebar
, infoPtr
, code
);
546 REBAR_DrawBand (HDC hdc
, REBAR_INFO
*infoPtr
, REBAR_BAND
*lpBand
)
552 if (lpBand
->fDraw
& DRAW_TEXT
) {
553 hOldFont
= SelectObject (hdc
, infoPtr
->hFont
);
554 oldBkMode
= SetBkMode (hdc
, TRANSPARENT
);
557 /* should test for CDRF_NOTIFYITEMDRAW here */
558 nmcd
.dwDrawStage
= CDDS_ITEMPREPAINT
;
560 nmcd
.rc
= lpBand
->rcBand
;
561 nmcd
.rc
.right
= lpBand
->rcCapText
.right
;
562 nmcd
.rc
.bottom
= lpBand
->rcCapText
.bottom
;
563 nmcd
.dwItemSpec
= lpBand
->wID
;
565 nmcd
.lItemlParam
= lpBand
->lParam
;
566 lpBand
->uCDret
= REBAR_Notify ((NMHDR
*)&nmcd
, infoPtr
, NM_CUSTOMDRAW
);
567 if (lpBand
->uCDret
== CDRF_SKIPDEFAULT
) {
568 if (oldBkMode
!= TRANSPARENT
)
569 SetBkMode (hdc
, oldBkMode
);
570 SelectObject (hdc
, hOldFont
);
575 if (lpBand
->fDraw
& DRAW_GRIPPER
)
576 DrawEdge (hdc
, &lpBand
->rcGripper
, BDR_RAISEDINNER
, BF_RECT
| BF_MIDDLE
);
578 /* draw caption image */
579 if (lpBand
->fDraw
& DRAW_IMAGE
) {
583 pt
.y
= (lpBand
->rcCapImage
.bottom
+ lpBand
->rcCapImage
.top
- infoPtr
->imageSize
.cy
)/2;
584 pt
.x
= (lpBand
->rcCapImage
.right
+ lpBand
->rcCapImage
.left
- infoPtr
->imageSize
.cx
)/2;
586 ImageList_Draw (infoPtr
->himl
, lpBand
->iImage
, hdc
,
591 /* draw caption text */
592 if (lpBand
->fDraw
& DRAW_TEXT
) {
593 /* need to handle CDRF_NEWFONT here */
594 INT oldBkMode
= SetBkMode (hdc
, TRANSPARENT
);
595 COLORREF oldcolor
= CLR_NONE
;
597 if (lpBand
->clrFore
!= CLR_NONE
) {
598 new = (lpBand
->clrFore
== CLR_DEFAULT
) ? infoPtr
->clrBtnText
:
600 oldcolor
= SetTextColor (hdc
, new);
602 DrawTextW (hdc
, lpBand
->lpText
, -1, &lpBand
->rcCapText
,
603 DT_CENTER
| DT_VCENTER
| DT_SINGLELINE
);
604 if (oldBkMode
!= TRANSPARENT
)
605 SetBkMode (hdc
, oldBkMode
);
606 if (lpBand
->clrFore
!= CLR_NONE
)
607 SetTextColor (hdc
, oldcolor
);
608 SelectObject (hdc
, hOldFont
);
611 if (lpBand
->uCDret
== (CDRF_NOTIFYPOSTPAINT
| CDRF_NOTIFYITEMDRAW
)) {
612 nmcd
.dwDrawStage
= CDDS_ITEMPOSTPAINT
;
614 nmcd
.rc
= lpBand
->rcBand
;
615 nmcd
.rc
.right
= lpBand
->rcCapText
.right
;
616 nmcd
.rc
.bottom
= lpBand
->rcCapText
.bottom
;
617 nmcd
.dwItemSpec
= lpBand
->wID
;
619 nmcd
.lItemlParam
= lpBand
->lParam
;
620 lpBand
->uCDret
= REBAR_Notify ((NMHDR
*)&nmcd
, infoPtr
, NM_CUSTOMDRAW
);
626 REBAR_Refresh (REBAR_INFO
*infoPtr
, HDC hdc
)
631 if (!infoPtr
->DoRedraw
) return;
633 oldrow
= infoPtr
->bands
[0].iRow
;
634 for (i
= 0; i
< infoPtr
->uNumBands
; i
++) {
635 lpBand
= &infoPtr
->bands
[i
];
637 if (HIDDENBAND(lpBand
)) continue;
639 /* now draw the band */
640 TRACE("[%p] drawing band %i, flags=%08x\n",
641 infoPtr
->hwndSelf
, i
, lpBand
->fDraw
);
642 REBAR_DrawBand (hdc
, infoPtr
, lpBand
);
649 REBAR_FixVert (REBAR_INFO
*infoPtr
, UINT rowstart
, UINT rowend
,
652 /* Cycle through bands in row and fix height of each band. */
653 /* Also determine whether each band has changed. */
655 /* all bands at desired size. */
656 /* start and end bands are *not* hidden */
661 for (i
= (INT
)rowstart
; i
<=(INT
)rowend
; i
++) {
662 lpBand
= &infoPtr
->bands
[i
];
663 if (HIDDENBAND(lpBand
)) continue;
665 /* adjust height of bands in row to "mcy" value */
666 if (infoPtr
->dwStyle
& CCS_VERT
) {
667 if (lpBand
->rcBand
.right
!= lpBand
->rcBand
.left
+ mcy
)
668 lpBand
->rcBand
.right
= lpBand
->rcBand
.left
+ mcy
;
671 if (lpBand
->rcBand
.bottom
!= lpBand
->rcBand
.top
+ mcy
)
672 lpBand
->rcBand
.bottom
= lpBand
->rcBand
.top
+ mcy
;
676 /* mark whether we need to invalidate this band and trace */
677 if ((lpBand
->rcoldBand
.left
!=lpBand
->rcBand
.left
) ||
678 (lpBand
->rcoldBand
.top
!=lpBand
->rcBand
.top
) ||
679 (lpBand
->rcoldBand
.right
!=lpBand
->rcBand
.right
) ||
680 (lpBand
->rcoldBand
.bottom
!=lpBand
->rcBand
.bottom
)) {
681 lpBand
->fDraw
|= NTF_INVALIDATE
;
682 TRACE("band %d row=%d: changed to (%d,%d)-(%d,%d) from (%d,%d)-(%d,%d)\n",
684 lpBand
->rcBand
.left
, lpBand
->rcBand
.top
,
685 lpBand
->rcBand
.right
, lpBand
->rcBand
.bottom
,
686 lpBand
->rcoldBand
.left
, lpBand
->rcoldBand
.top
,
687 lpBand
->rcoldBand
.right
, lpBand
->rcoldBand
.bottom
);
690 TRACE("band %d row=%d: unchanged (%d,%d)-(%d,%d)\n",
692 lpBand
->rcBand
.left
, lpBand
->rcBand
.top
,
693 lpBand
->rcBand
.right
, lpBand
->rcBand
.bottom
);
699 REBAR_AdjustBands (REBAR_INFO
*infoPtr
, UINT rowstart
, UINT rowend
,
701 /* Function: This routine distributes the extra space in a row. */
702 /* See algorithm below. */
704 /* all bands @ ->cxHeader size */
705 /* start and end bands are *not* hidden */
708 UINT x
, xsep
, extra
, curwidth
, fudge
;
709 INT i
, last_adjusted
;
711 TRACE("start=%u, end=%u, max x=%d, max y=%d\n",
712 rowstart
, rowend
, maxx
, mcy
);
714 /* ******************* Phase 1 ************************ */
716 /* For each visible band with valid child */
717 /* a. inflate band till either all extra space used */
718 /* or band's ->ccx reached. */
719 /* If any band modified, add any space left to last band */
722 /* ****************************************************** */
723 lpBand
= &infoPtr
->bands
[rowend
];
724 extra
= maxx
- rcBrb(lpBand
);
727 for (i
=(INT
)rowstart
; i
<=(INT
)rowend
; i
++) {
728 lpBand
= &infoPtr
->bands
[i
];
729 if (HIDDENBAND(lpBand
)) continue;
730 xsep
= (x
== 0) ? 0 : SEP_WIDTH
;
731 curwidth
= rcBw(lpBand
);
733 /* set new left/top point */
734 if (infoPtr
->dwStyle
& CCS_VERT
)
735 lpBand
->rcBand
.top
= x
+ xsep
;
737 lpBand
->rcBand
.left
= x
+ xsep
;
739 /* compute new width */
740 if ((lpBand
->hwndChild
&& extra
) && !(lpBand
->fStyle
& RBBS_FIXEDSIZE
)) {
741 /* set to the "current" band size less the header */
744 if ((lpBand
->fMask
& RBBIM_SIZE
) && (lpBand
->cx
> 0) &&
745 (fudge
> curwidth
)) {
746 TRACE("adjusting band %d by %d, fudge=%d, curwidth=%d, extra=%d\n",
747 i
, fudge
-curwidth
, fudge
, curwidth
, extra
);
748 if ((fudge
- curwidth
) > extra
)
749 fudge
= curwidth
+ extra
;
750 extra
-= (fudge
- curwidth
);
754 TRACE("adjusting band %d by %d, fudge=%d, curwidth=%d\n",
755 i
, extra
, fudge
, curwidth
);
761 /* set new right/bottom point */
762 if (infoPtr
->dwStyle
& CCS_VERT
)
763 lpBand
->rcBand
.bottom
= lpBand
->rcBand
.top
+ curwidth
;
765 lpBand
->rcBand
.right
= lpBand
->rcBand
.left
+ curwidth
;
766 TRACE("Phase 1 band %d, (%d,%d)-(%d,%d), orig x=%d, xsep=%d\n",
767 i
, lpBand
->rcBand
.left
, lpBand
->rcBand
.top
,
768 lpBand
->rcBand
.right
, lpBand
->rcBand
.bottom
, x
, xsep
);
771 if ((x
>= maxx
) || (last_adjusted
!= -1)) {
773 ERR("Phase 1 failed, x=%d, maxx=%d, start=%u, end=%u\n",
774 x
, maxx
, rowstart
, rowend
);
776 /* done, so spread extra space */
779 TRACE("Need to spread %d on last adjusted band %d\n",
780 fudge
, last_adjusted
);
781 for (i
=(INT
)last_adjusted
; i
<=(INT
)rowend
; i
++) {
782 lpBand
= &infoPtr
->bands
[i
];
783 if (HIDDENBAND(lpBand
)) continue;
785 /* set right/bottom point */
786 if (i
!= last_adjusted
) {
787 if (infoPtr
->dwStyle
& CCS_VERT
)
788 lpBand
->rcBand
.top
+= fudge
;
790 lpBand
->rcBand
.left
+= fudge
;
793 /* set left/bottom point */
794 if (infoPtr
->dwStyle
& CCS_VERT
)
795 lpBand
->rcBand
.bottom
+= fudge
;
797 lpBand
->rcBand
.right
+= fudge
;
800 TRACE("Phase 1 succeeded, used x=%d\n", x
);
801 REBAR_FixVert (infoPtr
, rowstart
, rowend
, mcy
);
805 /* ******************* Phase 2 ************************ */
807 /* Find first visible band, put all */
808 /* extra space there. */
810 /* ****************************************************** */
813 for (i
=(INT
)rowstart
; i
<=(INT
)rowend
; i
++) {
814 lpBand
= &infoPtr
->bands
[i
];
815 if (HIDDENBAND(lpBand
)) continue;
816 xsep
= (x
== 0) ? 0 : SEP_WIDTH
;
817 curwidth
= rcBw(lpBand
);
819 /* set new left/top point */
820 if (infoPtr
->dwStyle
& CCS_VERT
)
821 lpBand
->rcBand
.top
= x
+ xsep
;
823 lpBand
->rcBand
.left
= x
+ xsep
;
825 /* compute new width */
831 /* set new right/bottom point */
832 if (infoPtr
->dwStyle
& CCS_VERT
)
833 lpBand
->rcBand
.bottom
= lpBand
->rcBand
.top
+ curwidth
;
835 lpBand
->rcBand
.right
= lpBand
->rcBand
.left
+ curwidth
;
836 TRACE("Phase 2 band %d, (%d,%d)-(%d,%d), orig x=%d, xsep=%d\n",
837 i
, lpBand
->rcBand
.left
, lpBand
->rcBand
.top
,
838 lpBand
->rcBand
.right
, lpBand
->rcBand
.bottom
, x
, xsep
);
843 ERR("Phase 2 failed, x=%d, maxx=%d, start=%u, end=%u\n",
844 x
, maxx
, rowstart
, rowend
);
846 /* done, so spread extra space */
847 TRACE("Phase 2 succeeded, used x=%d\n", x
);
848 REBAR_FixVert (infoPtr
, rowstart
, rowend
, mcy
);
852 /* ******************* Phase 3 ************************ */
853 /* at this point everything is back to ->cxHeader values */
854 /* and should not have gotten here. */
855 /* ****************************************************** */
857 lpBand
= &infoPtr
->bands
[rowstart
];
858 ERR("Serious problem adjusting row %d, start band %d, end band %d\n",
859 lpBand
->iRow
, rowstart
, rowend
);
860 REBAR_DumpBand (infoPtr
);
866 REBAR_CalcHorzBand (REBAR_INFO
*infoPtr
, UINT rstart
, UINT rend
, BOOL notify
)
867 /* Function: this routine initializes all the rectangles in */
868 /* each band in a row to fit in the adjusted rcBand rect. */
869 /* *** Supports only Horizontal bars. *** */
876 /* MS seems to use GetDlgCtrlID() for above GetWindowLong call */
877 parenthwnd
= GetParent (infoPtr
->hwndSelf
);
879 for(i
=rstart
; i
<rend
; i
++){
880 lpBand
= &infoPtr
->bands
[i
];
881 if (HIDDENBAND(lpBand
)) {
882 SetRect (&lpBand
->rcChild
,
883 lpBand
->rcBand
.right
, lpBand
->rcBand
.top
,
884 lpBand
->rcBand
.right
, lpBand
->rcBand
.bottom
);
888 oldChild
= lpBand
->rcChild
;
890 /* set initial gripper rectangle */
891 SetRect (&lpBand
->rcGripper
, lpBand
->rcBand
.left
, lpBand
->rcBand
.top
,
892 lpBand
->rcBand
.left
, lpBand
->rcBand
.bottom
);
894 /* calculate gripper rectangle */
895 if ( lpBand
->fStatus
& HAS_GRIPPER
) {
896 lpBand
->fDraw
|= DRAW_GRIPPER
;
897 lpBand
->rcGripper
.left
+= REBAR_PRE_GRIPPER
;
898 lpBand
->rcGripper
.right
= lpBand
->rcGripper
.left
+ GRIPPER_WIDTH
;
899 lpBand
->rcGripper
.top
+= 2;
900 lpBand
->rcGripper
.bottom
-= 2;
902 SetRect (&lpBand
->rcCapImage
,
903 lpBand
->rcGripper
.right
+REBAR_ALWAYS_SPACE
, lpBand
->rcBand
.top
,
904 lpBand
->rcGripper
.right
+REBAR_ALWAYS_SPACE
, lpBand
->rcBand
.bottom
);
906 else { /* no gripper will be drawn */
908 if (lpBand
->fStatus
& (HAS_IMAGE
| HAS_TEXT
))
909 /* if no gripper but either image or text, then leave space */
910 xoff
= REBAR_ALWAYS_SPACE
;
911 SetRect (&lpBand
->rcCapImage
,
912 lpBand
->rcBand
.left
+xoff
, lpBand
->rcBand
.top
,
913 lpBand
->rcBand
.left
+xoff
, lpBand
->rcBand
.bottom
);
916 /* image is visible */
917 if (lpBand
->fStatus
& HAS_IMAGE
) {
918 lpBand
->fDraw
|= DRAW_IMAGE
;
919 lpBand
->rcCapImage
.right
+= infoPtr
->imageSize
.cx
;
920 lpBand
->rcCapImage
.bottom
= lpBand
->rcCapImage
.top
+ infoPtr
->imageSize
.cy
;
922 /* set initial caption text rectangle */
923 SetRect (&lpBand
->rcCapText
,
924 lpBand
->rcCapImage
.right
+REBAR_POST_IMAGE
, lpBand
->rcBand
.top
+1,
925 lpBand
->rcBand
.left
+lpBand
->cxHeader
, lpBand
->rcBand
.bottom
-1);
926 /* update band height
927 if (lpBand->uMinHeight < infoPtr->imageSize.cy + 2) {
928 lpBand->uMinHeight = infoPtr->imageSize.cy + 2;
929 lpBand->rcBand.bottom = lpBand->rcBand.top + lpBand->uMinHeight;
933 /* set initial caption text rectangle */
934 SetRect (&lpBand
->rcCapText
, lpBand
->rcCapImage
.right
, lpBand
->rcBand
.top
+1,
935 lpBand
->rcBand
.left
+lpBand
->cxHeader
, lpBand
->rcBand
.bottom
-1);
938 /* text is visible */
939 if (lpBand
->fStatus
& HAS_TEXT
) {
940 lpBand
->fDraw
|= DRAW_TEXT
;
941 lpBand
->rcCapText
.right
= max(lpBand
->rcCapText
.left
,
942 lpBand
->rcCapText
.right
-REBAR_POST_TEXT
);
945 /* set initial child window rectangle if there is a child */
946 if (lpBand
->fMask
& RBBIM_CHILD
) {
947 xoff
= lpBand
->offChild
.cx
;
948 yoff
= lpBand
->offChild
.cy
;
949 SetRect (&lpBand
->rcChild
,
950 lpBand
->rcBand
.left
+lpBand
->cxHeader
, lpBand
->rcBand
.top
+yoff
,
951 lpBand
->rcBand
.right
-xoff
, lpBand
->rcBand
.bottom
-yoff
);
954 SetRect (&lpBand
->rcChild
,
955 lpBand
->rcBand
.left
+lpBand
->cxHeader
, lpBand
->rcBand
.top
,
956 lpBand
->rcBand
.right
, lpBand
->rcBand
.bottom
);
959 /* flag if notify required and invalidate rectangle */
961 ((oldChild
.right
-oldChild
.left
!= lpBand
->rcChild
.right
-lpBand
->rcChild
.left
) ||
962 (oldChild
.bottom
-oldChild
.top
!= lpBand
->rcChild
.bottom
-lpBand
->rcChild
.top
))) {
963 TRACE("Child rectangle changed for band %u\n", i
);
964 TRACE(" from (%d,%d)-(%d,%d) to (%d,%d)-(%d,%d)\n",
965 oldChild
.left
, oldChild
.top
,
966 oldChild
.right
, oldChild
.bottom
,
967 lpBand
->rcChild
.left
, lpBand
->rcChild
.top
,
968 lpBand
->rcChild
.right
, lpBand
->rcChild
.bottom
);
970 if (lpBand
->fDraw
& NTF_INVALIDATE
) {
971 TRACE("invalidating (%d,%d)-(%d,%d)\n",
974 lpBand
->rcBand
.right
+ ((lpBand
->fDraw
& DRAW_RIGHTSEP
) ? SEP_WIDTH_SIZE
: 0),
975 lpBand
->rcBand
.bottom
+ ((lpBand
->fDraw
& DRAW_BOTTOMSEP
) ? SEP_WIDTH_SIZE
: 0));
976 lpBand
->fDraw
&= ~NTF_INVALIDATE
;
977 work
= lpBand
->rcBand
;
978 if (lpBand
->fDraw
& DRAW_RIGHTSEP
) work
.right
+= SEP_WIDTH_SIZE
;
979 if (lpBand
->fDraw
& DRAW_BOTTOMSEP
) work
.bottom
+= SEP_WIDTH_SIZE
;
980 InvalidateRect(infoPtr
->hwndSelf
, &work
, TRUE
);
989 REBAR_CalcVertBand (REBAR_INFO
*infoPtr
, UINT rstart
, UINT rend
, BOOL notify
)
990 /* Function: this routine initializes all the rectangles in */
991 /* each band in a row to fit in the adjusted rcBand rect. */
992 /* *** Supports only Vertical bars. *** */
999 /* MS seems to use GetDlgCtrlID() for above GetWindowLong call */
1000 parenthwnd
= GetParent (infoPtr
->hwndSelf
);
1002 for(i
=rstart
; i
<rend
; i
++){
1003 lpBand
= &infoPtr
->bands
[i
];
1004 if (HIDDENBAND(lpBand
)) continue;
1005 oldChild
= lpBand
->rcChild
;
1007 /* set initial gripper rectangle */
1008 SetRect (&lpBand
->rcGripper
, lpBand
->rcBand
.left
, lpBand
->rcBand
.top
,
1009 lpBand
->rcBand
.right
, lpBand
->rcBand
.top
);
1011 /* calculate gripper rectangle */
1012 if (lpBand
->fStatus
& HAS_GRIPPER
) {
1013 lpBand
->fDraw
|= DRAW_GRIPPER
;
1015 if (infoPtr
->dwStyle
& RBS_VERTICALGRIPPER
) {
1016 /* vertical gripper */
1017 lpBand
->rcGripper
.left
+= 3;
1018 lpBand
->rcGripper
.right
= lpBand
->rcGripper
.left
+ GRIPPER_WIDTH
;
1019 lpBand
->rcGripper
.top
+= REBAR_PRE_GRIPPER
;
1020 lpBand
->rcGripper
.bottom
= lpBand
->rcGripper
.top
+ GRIPPER_HEIGHT
;
1022 /* initialize Caption image rectangle */
1023 SetRect (&lpBand
->rcCapImage
, lpBand
->rcBand
.left
,
1024 lpBand
->rcGripper
.bottom
+ REBAR_ALWAYS_SPACE
,
1025 lpBand
->rcBand
.right
,
1026 lpBand
->rcGripper
.bottom
+ REBAR_ALWAYS_SPACE
);
1029 /* horizontal gripper */
1030 lpBand
->rcGripper
.left
+= 2;
1031 lpBand
->rcGripper
.right
-= 2;
1032 lpBand
->rcGripper
.top
+= REBAR_PRE_GRIPPER
;
1033 lpBand
->rcGripper
.bottom
= lpBand
->rcGripper
.top
+ GRIPPER_WIDTH
;
1035 /* initialize Caption image rectangle */
1036 SetRect (&lpBand
->rcCapImage
, lpBand
->rcBand
.left
,
1037 lpBand
->rcGripper
.bottom
+ REBAR_ALWAYS_SPACE
,
1038 lpBand
->rcBand
.right
,
1039 lpBand
->rcGripper
.bottom
+ REBAR_ALWAYS_SPACE
);
1042 else { /* no gripper will be drawn */
1044 if (lpBand
->fStatus
& (HAS_IMAGE
| HAS_TEXT
))
1045 /* if no gripper but either image or text, then leave space */
1046 xoff
= REBAR_ALWAYS_SPACE
;
1047 /* initialize Caption image rectangle */
1048 SetRect (&lpBand
->rcCapImage
,
1049 lpBand
->rcBand
.left
, lpBand
->rcBand
.top
+xoff
,
1050 lpBand
->rcBand
.right
, lpBand
->rcBand
.top
+xoff
);
1053 /* image is visible */
1054 if (lpBand
->fStatus
& HAS_IMAGE
) {
1055 lpBand
->fDraw
|= DRAW_IMAGE
;
1057 lpBand
->rcCapImage
.right
= lpBand
->rcCapImage
.left
+ infoPtr
->imageSize
.cx
;
1058 lpBand
->rcCapImage
.bottom
+= infoPtr
->imageSize
.cy
;
1060 /* set initial caption text rectangle */
1061 SetRect (&lpBand
->rcCapText
,
1062 lpBand
->rcBand
.left
, lpBand
->rcCapImage
.bottom
+REBAR_POST_IMAGE
,
1063 lpBand
->rcBand
.right
, lpBand
->rcBand
.top
+lpBand
->cxHeader
);
1064 /* update band height *
1065 if (lpBand->uMinHeight < infoPtr->imageSize.cx + 2) {
1066 lpBand->uMinHeight = infoPtr->imageSize.cx + 2;
1067 lpBand->rcBand.right = lpBand->rcBand.left + lpBand->uMinHeight;
1071 /* set initial caption text rectangle */
1072 SetRect (&lpBand
->rcCapText
,
1073 lpBand
->rcBand
.left
, lpBand
->rcCapImage
.bottom
,
1074 lpBand
->rcBand
.right
, lpBand
->rcBand
.top
+lpBand
->cxHeader
);
1077 /* text is visible */
1078 if (lpBand
->fStatus
& HAS_TEXT
) {
1079 lpBand
->fDraw
|= DRAW_TEXT
;
1080 lpBand
->rcCapText
.bottom
= max(lpBand
->rcCapText
.top
,
1081 lpBand
->rcCapText
.bottom
);
1084 /* set initial child window rectangle if there is a child */
1085 if (lpBand
->fMask
& RBBIM_CHILD
) {
1086 yoff
= lpBand
->offChild
.cx
;
1087 xoff
= lpBand
->offChild
.cy
;
1088 SetRect (&lpBand
->rcChild
,
1089 lpBand
->rcBand
.left
+xoff
, lpBand
->rcBand
.top
+lpBand
->cxHeader
,
1090 lpBand
->rcBand
.right
-xoff
, lpBand
->rcBand
.bottom
-yoff
);
1093 SetRect (&lpBand
->rcChild
,
1094 lpBand
->rcBand
.left
, lpBand
->rcBand
.top
+lpBand
->cxHeader
,
1095 lpBand
->rcBand
.right
, lpBand
->rcBand
.bottom
);
1098 /* flag if notify required and invalidate rectangle */
1100 ((oldChild
.right
-oldChild
.left
!= lpBand
->rcChild
.right
-lpBand
->rcChild
.left
) ||
1101 (oldChild
.bottom
-oldChild
.top
!= lpBand
->rcChild
.bottom
-lpBand
->rcChild
.top
))) {
1102 TRACE("Child rectangle changed for band %u\n", i
);
1103 TRACE(" from (%d,%d)-(%d,%d) to (%d,%d)-(%d,%d)\n",
1104 oldChild
.left
, oldChild
.top
,
1105 oldChild
.right
, oldChild
.bottom
,
1106 lpBand
->rcChild
.left
, lpBand
->rcChild
.top
,
1107 lpBand
->rcChild
.right
, lpBand
->rcChild
.bottom
);
1109 if (lpBand
->fDraw
& NTF_INVALIDATE
) {
1110 TRACE("invalidating (%d,%d)-(%d,%d)\n",
1111 lpBand
->rcBand
.left
,
1113 lpBand
->rcBand
.right
+ ((lpBand
->fDraw
& DRAW_BOTTOMSEP
) ? SEP_WIDTH_SIZE
: 0),
1114 lpBand
->rcBand
.bottom
+ ((lpBand
->fDraw
& DRAW_RIGHTSEP
) ? SEP_WIDTH_SIZE
: 0));
1115 lpBand
->fDraw
&= ~NTF_INVALIDATE
;
1116 work
= lpBand
->rcBand
;
1117 if (lpBand
->fDraw
& DRAW_RIGHTSEP
) work
.bottom
+= SEP_WIDTH_SIZE
;
1118 if (lpBand
->fDraw
& DRAW_BOTTOMSEP
) work
.right
+= SEP_WIDTH_SIZE
;
1119 InvalidateRect(infoPtr
->hwndSelf
, &work
, TRUE
);
1127 REBAR_ForceResize (REBAR_INFO
*infoPtr
)
1128 /* Function: This changes the size of the REBAR window to that */
1129 /* calculated by REBAR_Layout. */
1132 INT x
, y
, width
, height
;
1133 INT xedge
= GetSystemMetrics(SM_CXEDGE
);
1134 INT yedge
= GetSystemMetrics(SM_CYEDGE
);
1136 /* TEST TEST TEST */
1137 GetWindowRect (infoPtr
->hwndSelf
, &rc
);
1138 /* END TEST END TEST END TEST */
1141 GetClientRect (infoPtr
->hwndSelf
, &rc
);
1143 TRACE( " old [%ld x %ld], new [%ld x %ld], client [%d x %d]\n",
1144 infoPtr
->oldSize
.cx
, infoPtr
->oldSize
.cy
,
1145 infoPtr
->calcSize
.cx
, infoPtr
->calcSize
.cy
,
1146 rc
.right
, rc
.bottom
);
1148 /* If we need to shrink client, then skip size test */
1149 if ((infoPtr
->calcSize
.cy
>= rc
.bottom
) &&
1150 (infoPtr
->calcSize
.cx
>= rc
.right
)) {
1152 /* if size did not change then skip process */
1153 if ((infoPtr
->oldSize
.cx
== infoPtr
->calcSize
.cx
) &&
1154 (infoPtr
->oldSize
.cy
== infoPtr
->calcSize
.cy
) &&
1155 !(infoPtr
->fStatus
& RESIZE_ANYHOW
))
1157 TRACE("skipping reset\n");
1162 infoPtr
->fStatus
&= ~RESIZE_ANYHOW
;
1163 /* Set flag to ignore next WM_SIZE message */
1164 infoPtr
->fStatus
|= AUTO_RESIZE
;
1171 if (infoPtr
->dwStyle
& WS_BORDER
) {
1176 if (!(infoPtr
->dwStyle
& CCS_NOPARENTALIGN
)) {
1177 INT mode
= infoPtr
->dwStyle
& (CCS_VERT
| CCS_TOP
| CCS_BOTTOM
);
1180 GetClientRect(GetParent(infoPtr
->hwndSelf
), &rcPcl
);
1183 /* _TOP sets width to parents width */
1184 width
+= (rcPcl
.right
- rcPcl
.left
);
1185 height
+= infoPtr
->calcSize
.cy
;
1186 x
+= ((infoPtr
->dwStyle
& WS_BORDER
) ? -xedge
: 0);
1187 y
+= ((infoPtr
->dwStyle
& WS_BORDER
) ? -yedge
: 0);
1188 y
+= ((infoPtr
->dwStyle
& CCS_NODIVIDER
) ? 0 : REBAR_DIVIDER
);
1191 /* FIXME: wrong wrong wrong */
1192 /* _BOTTOM sets width to parents width */
1193 width
+= (rcPcl
.right
- rcPcl
.left
);
1194 height
+= infoPtr
->calcSize
.cy
;
1196 y
= rcPcl
.bottom
- height
+ 1;
1199 /* _LEFT sets height to parents height */
1200 width
+= infoPtr
->calcSize
.cx
;
1201 height
+= (rcPcl
.bottom
- rcPcl
.top
);
1202 x
+= ((infoPtr
->dwStyle
& WS_BORDER
) ? -xedge
: 0);
1203 x
+= ((infoPtr
->dwStyle
& CCS_NODIVIDER
) ? 0 : REBAR_DIVIDER
);
1204 y
+= ((infoPtr
->dwStyle
& WS_BORDER
) ? -yedge
: 0);
1207 /* FIXME: wrong wrong wrong */
1208 /* _RIGHT sets height to parents height */
1209 width
+= infoPtr
->calcSize
.cx
;
1210 height
+= (rcPcl
.bottom
- rcPcl
.top
);
1211 x
= rcPcl
.right
- width
+ 1;
1215 width
+= infoPtr
->calcSize
.cx
;
1216 height
+= infoPtr
->calcSize
.cy
;
1220 width
+= infoPtr
->calcSize
.cx
;
1221 height
+= infoPtr
->calcSize
.cy
;
1222 x
= infoPtr
->origin
.x
;
1223 y
= infoPtr
->origin
.y
;
1226 TRACE("hwnd %p, style=%08lx, setting at (%d,%d) for (%d,%d)\n",
1227 infoPtr
->hwndSelf
, infoPtr
->dwStyle
,
1228 x
, y
, width
, height
);
1229 SetWindowPos (infoPtr
->hwndSelf
, 0, x
, y
, width
, height
,
1235 REBAR_MoveChildWindows (REBAR_INFO
*infoPtr
, UINT start
, UINT endplus
)
1238 CHAR szClassName
[40];
1240 NMREBARCHILDSIZE rbcz
;
1244 if (!(deferpos
= BeginDeferWindowPos(infoPtr
->uNumBands
)))
1245 ERR("BeginDeferWindowPos returned NULL\n");
1247 for (i
= start
; i
< endplus
; i
++) {
1248 lpBand
= &infoPtr
->bands
[i
];
1250 if (HIDDENBAND(lpBand
)) continue;
1251 if (lpBand
->hwndChild
) {
1252 TRACE("hwndChild = %p\n", lpBand
->hwndChild
);
1254 /* Always geterate the RBN_CHILDSIZE even it child
1257 rbcz
.wID
= lpBand
->wID
;
1258 rbcz
.rcChild
= lpBand
->rcChild
;
1259 rbcz
.rcBand
= lpBand
->rcBand
;
1260 if (infoPtr
->dwStyle
& CCS_VERT
)
1261 rbcz
.rcBand
.top
+= lpBand
->cxHeader
;
1263 rbcz
.rcBand
.left
+= lpBand
->cxHeader
;
1264 REBAR_Notify ((NMHDR
*)&rbcz
, infoPtr
, RBN_CHILDSIZE
);
1265 if (!EqualRect (&lpBand
->rcChild
, &rbcz
.rcChild
)) {
1266 TRACE("Child rect changed by NOTIFY for band %u\n", i
);
1267 TRACE(" from (%d,%d)-(%d,%d) to (%d,%d)-(%d,%d)\n",
1268 lpBand
->rcChild
.left
, lpBand
->rcChild
.top
,
1269 lpBand
->rcChild
.right
, lpBand
->rcChild
.bottom
,
1270 rbcz
.rcChild
.left
, rbcz
.rcChild
.top
,
1271 rbcz
.rcChild
.right
, rbcz
.rcChild
.bottom
);
1272 lpBand
->rcChild
= rbcz
.rcChild
; /* *** ??? */
1275 /* native (IE4 in "Favorites" frame **1) does:
1276 * SetRect (&rc, -1, -1, -1, -1)
1277 * EqualRect (&rc,band->rc???)
1279 * CopyRect (band->rc????, &rc)
1280 * set flag outside of loop
1283 GetClassNameA (lpBand
->hwndChild
, szClassName
, 40);
1284 if (!lstrcmpA (szClassName
, "ComboBox") ||
1285 !lstrcmpA (szClassName
, WC_COMBOBOXEXA
)) {
1286 INT nEditHeight
, yPos
;
1289 /* special placement code for combo or comboex box */
1292 /* get size of edit line */
1293 GetWindowRect (lpBand
->hwndChild
, &rc
);
1294 nEditHeight
= rc
.bottom
- rc
.top
;
1295 yPos
= (lpBand
->rcChild
.bottom
+ lpBand
->rcChild
.top
- nEditHeight
)/2;
1297 /* center combo box inside child area */
1298 TRACE("moving child (Combo(Ex)) %p to (%d,%d) for (%d,%d)\n",
1300 lpBand
->rcChild
.left
, yPos
,
1301 lpBand
->rcChild
.right
- lpBand
->rcChild
.left
,
1303 deferpos
= DeferWindowPos (deferpos
, lpBand
->hwndChild
, HWND_TOP
,
1304 lpBand
->rcChild
.left
,
1305 /*lpBand->rcChild.top*/ yPos
,
1306 lpBand
->rcChild
.right
- lpBand
->rcChild
.left
,
1310 ERR("DeferWindowPos returned NULL\n");
1313 TRACE("moving child (Other) %p to (%d,%d) for (%d,%d)\n",
1315 lpBand
->rcChild
.left
, lpBand
->rcChild
.top
,
1316 lpBand
->rcChild
.right
- lpBand
->rcChild
.left
,
1317 lpBand
->rcChild
.bottom
- lpBand
->rcChild
.top
);
1318 deferpos
= DeferWindowPos (deferpos
, lpBand
->hwndChild
, HWND_TOP
,
1319 lpBand
->rcChild
.left
,
1320 lpBand
->rcChild
.top
,
1321 lpBand
->rcChild
.right
- lpBand
->rcChild
.left
,
1322 lpBand
->rcChild
.bottom
- lpBand
->rcChild
.top
,
1325 ERR("DeferWindowPos returned NULL\n");
1329 if (!EndDeferWindowPos(deferpos
))
1330 ERR("EndDeferWindowPos returned NULL\n");
1332 if (infoPtr
->DoRedraw
)
1333 UpdateWindow (infoPtr
->hwndSelf
);
1335 if (infoPtr
->fStatus
& NTF_HGHTCHG
) {
1336 infoPtr
->fStatus
&= ~NTF_HGHTCHG
;
1337 REBAR_Notify (&heightchange
, infoPtr
, RBN_HEIGHTCHANGE
);
1340 /* native (from **1 above) does:
1341 * UpdateWindow(rebar)
1343 * RBN_HEIGHTCHANGE if necessary
1344 * if ret from any EqualRect was 0
1345 * Goto "BeginDeferWindowPos"
1352 REBAR_Layout (REBAR_INFO
*infoPtr
, LPRECT lpRect
, BOOL notify
, BOOL resetclient
)
1353 /* Function: This routine is resposible for laying out all */
1354 /* the bands in a rebar. It assigns each band to a row and*/
1355 /* determines when to start a new row. */
1357 REBAR_BAND
*lpBand
, *prevBand
;
1358 RECT rcClient
, rcAdj
;
1359 INT initx
, inity
, x
, y
, cx
, cxsep
, mmcy
, mcy
, clientcx
, clientcy
;
1360 INT adjcx
, adjcy
, row
, rightx
, bottomy
, origheight
;
1361 UINT i
, j
, rowstart
, origrows
, cntonrow
;
1364 if (!(infoPtr
->fStatus
& BAND_NEEDS_LAYOUT
)) {
1365 TRACE("no layout done. No band changed.\n");
1366 REBAR_DumpBand (infoPtr
);
1369 infoPtr
->fStatus
&= ~BAND_NEEDS_LAYOUT
;
1370 if (!infoPtr
->DoRedraw
) infoPtr
->fStatus
|= BAND_NEEDS_REDRAW
;
1372 GetClientRect (infoPtr
->hwndSelf
, &rcClient
);
1373 TRACE("Client is (%d,%d)-(%d,%d)\n",
1374 rcClient
.left
, rcClient
.top
, rcClient
.right
, rcClient
.bottom
);
1378 TRACE("adjustment rect is (%d,%d)-(%d,%d)\n",
1379 rcAdj
.left
, rcAdj
.top
, rcAdj
.right
, rcAdj
.bottom
);
1382 CopyRect (&rcAdj
, &rcClient
);
1385 clientcx
= rcClient
.right
- rcClient
.left
;
1386 clientcy
= rcClient
.bottom
- rcClient
.top
;
1387 adjcx
= rcAdj
.right
- rcAdj
.left
;
1388 adjcy
= rcAdj
.bottom
- rcAdj
.top
;
1390 TRACE("window client rect will be set to adj rect\n");
1395 if (!infoPtr
->DoRedraw
&& (clientcx
== 0) && (clientcy
== 0)) {
1396 ERR("no redraw and client is zero, skip layout\n");
1397 infoPtr
->fStatus
|= BAND_NEEDS_LAYOUT
;
1401 /* save height of original control */
1402 if (infoPtr
->dwStyle
& CCS_VERT
)
1403 origheight
= infoPtr
->calcSize
.cx
;
1405 origheight
= infoPtr
->calcSize
.cy
;
1406 origrows
= infoPtr
->uNumRows
;
1411 /* ******* Start Phase 1 - all bands on row at minimum size ******* */
1413 TRACE("band loop constants, clientcx=%d, clientcy=%d, adjcx=%d, adjcy=%d\n",
1414 clientcx
, clientcy
, adjcx
, adjcy
);
1424 for (i
= 0; i
< infoPtr
->uNumBands
; i
++) {
1425 lpBand
= &infoPtr
->bands
[i
];
1429 if (HIDDENBAND(lpBand
)) continue;
1431 lpBand
->rcoldBand
= lpBand
->rcBand
;
1433 /* Set the offset of the child window */
1434 if ((lpBand
->fMask
& RBBIM_CHILD
) &&
1435 !(lpBand
->fStyle
& RBBS_FIXEDSIZE
)) {
1436 lpBand
->offChild
.cx
= ((lpBand
->fStyle
& RBBS_CHILDEDGE
) ? 4 : 0);
1438 lpBand
->offChild
.cy
= ((lpBand
->fStyle
& RBBS_CHILDEDGE
) ? 2 : 0);
1440 /* separator from previous band */
1441 cxsep
= (cntonrow
== 0) ? 0 : SEP_WIDTH
;
1443 /* Header: includes gripper, text, image */
1444 cx
= lpBand
->cxHeader
;
1445 if (lpBand
->fStyle
& RBBS_FIXEDSIZE
) cx
= lpBand
->lcx
;
1447 if (infoPtr
->dwStyle
& CCS_VERT
)
1448 dobreak
= (y
+ cx
+ cxsep
> adjcy
);
1450 dobreak
= (x
+ cx
+ cxsep
> adjcx
);
1452 /* This is the check for whether we need to start a new row */
1453 if ( ( (lpBand
->fStyle
& RBBS_BREAK
) && (i
!= 0) ) ||
1454 ( ((infoPtr
->dwStyle
& CCS_VERT
) ? (y
!= 0) : (x
!= 0)) && dobreak
)) {
1456 for (j
= rowstart
; j
< i
; j
++) {
1458 lpB
= &infoPtr
->bands
[j
];
1459 if (infoPtr
->dwStyle
& CCS_VERT
) {
1460 lpB
->rcBand
.right
= lpB
->rcBand
.left
+ mcy
;
1463 lpB
->rcBand
.bottom
= lpB
->rcBand
.top
+ mcy
;
1467 TRACE("P1 Spliting to new row %d on band %u\n", row
+1, i
);
1468 if (infoPtr
->dwStyle
& CCS_VERT
) {
1470 x
+= (mcy
+ SEP_WIDTH
);
1474 y
+= (mcy
+ SEP_WIDTH
);
1486 if (mcy
< lpBand
->lcy
+ REBARSPACE(lpBand
))
1487 mcy
= lpBand
->lcy
+ REBARSPACE(lpBand
);
1489 /* if boundary rect specified then limit mcy */
1491 if (infoPtr
->dwStyle
& CCS_VERT
) {
1492 if (x
+mcy
> adjcx
) {
1494 TRACE("P1 row %u limiting mcy=%d, adjcx=%d, x=%d\n",
1499 if (y
+mcy
> adjcy
) {
1501 TRACE("P1 row %u limiting mcy=%d, adjcy=%d, y=%d\n",
1507 TRACE("P1 band %u, row %d, x=%d, y=%d, cxsep=%d, cx=%d\n",
1510 if (infoPtr
->dwStyle
& CCS_VERT
) {
1511 /* bound the bottom side if we have a bounding rectangle */
1513 bottomy
= (lpRect
) ? min(clientcy
, y
+cxsep
+cx
) : y
+cxsep
+cx
;
1514 lpBand
->rcBand
.left
= x
;
1515 lpBand
->rcBand
.right
= x
+ min(mcy
,
1516 lpBand
->lcy
+REBARSPACE(lpBand
));
1517 lpBand
->rcBand
.top
= min(bottomy
, y
+ cxsep
);
1518 lpBand
->rcBand
.bottom
= bottomy
;
1519 lpBand
->uMinHeight
= lpBand
->lcy
;
1523 /* bound the right side if we have a bounding rectangle */
1524 rightx
= (lpRect
) ? min(clientcx
, x
+cxsep
+cx
) : x
+cxsep
+cx
;
1526 lpBand
->rcBand
.left
= min(rightx
, x
+ cxsep
);
1527 lpBand
->rcBand
.right
= rightx
;
1528 lpBand
->rcBand
.top
= y
;
1529 lpBand
->rcBand
.bottom
= y
+ min(mcy
,
1530 lpBand
->lcy
+REBARSPACE(lpBand
));
1531 lpBand
->uMinHeight
= lpBand
->lcy
;
1534 TRACE("P1 band %u, row %d, (%d,%d)-(%d,%d)\n",
1536 lpBand
->rcBand
.left
, lpBand
->rcBand
.top
,
1537 lpBand
->rcBand
.right
, lpBand
->rcBand
.bottom
);
1541 } /* for (i = 0; i < infoPtr->uNumBands... */
1543 if (infoPtr
->dwStyle
& CCS_VERT
)
1548 for (j
= rowstart
; j
< infoPtr
->uNumBands
; j
++) {
1549 lpBand
= &infoPtr
->bands
[j
];
1550 if (infoPtr
->dwStyle
& CCS_VERT
) {
1551 lpBand
->rcBand
.right
= lpBand
->rcBand
.left
+ mcy
;
1554 lpBand
->rcBand
.bottom
= lpBand
->rcBand
.top
+ mcy
;
1558 if (infoPtr
->uNumBands
)
1559 infoPtr
->uNumRows
= row
;
1561 /* ******* End Phase 1 - all bands on row at minimum size ******* */
1564 /* ******* Start Phase 1a - Adjust heights for RBS_VARHEIGHT off ******* */
1567 if (!(infoPtr
->dwStyle
& RBS_VARHEIGHT
)) {
1570 /* get the max height of all bands */
1571 for (i
=0; i
<infoPtr
->uNumBands
; i
++) {
1572 lpBand
= &infoPtr
->bands
[i
];
1573 if (HIDDENBAND(lpBand
)) continue;
1574 if (infoPtr
->dwStyle
& CCS_VERT
)
1575 mmcy
= max(mmcy
, lpBand
->rcBand
.right
- lpBand
->rcBand
.left
);
1577 mmcy
= max(mmcy
, lpBand
->rcBand
.bottom
- lpBand
->rcBand
.top
);
1580 /* now adjust all rectangles by using the height found above */
1583 for (i
=0; i
<infoPtr
->uNumBands
; i
++) {
1584 lpBand
= &infoPtr
->bands
[i
];
1585 if (HIDDENBAND(lpBand
)) continue;
1586 if (lpBand
->iRow
!= row
)
1587 xy
+= (mmcy
+ SEP_WIDTH
);
1588 if (infoPtr
->dwStyle
& CCS_VERT
) {
1589 lpBand
->rcBand
.left
= xy
;
1590 lpBand
->rcBand
.right
= xy
+ mmcy
;
1593 lpBand
->rcBand
.top
= xy
;
1594 lpBand
->rcBand
.bottom
= xy
+ mmcy
;
1598 /* set the x/y values to the correct maximum */
1599 if (infoPtr
->dwStyle
& CCS_VERT
)
1605 /* ******* End Phase 1a - Adjust heights for RBS_VARHEIGHT off ******* */
1608 /* ******* Start Phase 2 - split rows till adjustment height full ******* */
1610 /* assumes that the following variables contain: */
1611 /* y/x current height/width of all rows */
1613 INT i
, prev_rh
, new_rh
, adj_rh
, prev_idx
, current_idx
;
1614 REBAR_BAND
*prev
, *current
, *walk
;
1617 /* FIXME: problem # 2 */
1618 if (((infoPtr
->dwStyle
& CCS_VERT
) ?
1620 (x
< adjcx
) : (y
< adjcy
)
1622 (adjcx
- x
> 4) : (adjcy
- y
> 4)
1625 (infoPtr
->uNumBands
> 1)) {
1626 for (i
=(INT
)infoPtr
->uNumBands
-2; i
>=0; i
--) {
1627 TRACE("P2 adjcx=%d, adjcy=%d, x=%d, y=%d\n",
1628 adjcx
, adjcy
, x
, y
);
1630 /* find the current band (starts at i+1) */
1631 current
= &infoPtr
->bands
[i
+1];
1633 while (HIDDENBAND(current
)) {
1635 if (i
< 0) break; /* out of bands */
1636 current
= &infoPtr
->bands
[i
+1];
1639 if (i
< 0) break; /* out of bands */
1641 /* now find the prev band (starts at i) */
1642 prev
= &infoPtr
->bands
[i
];
1644 while (HIDDENBAND(prev
)) {
1646 if (i
< 0) break; /* out of bands */
1647 prev
= &infoPtr
->bands
[i
];
1650 if (i
< 0) break; /* out of bands */
1652 prev_rh
= ircBw(prev
);
1653 if (prev
->iRow
== current
->iRow
) {
1654 new_rh
= (infoPtr
->dwStyle
& RBS_VARHEIGHT
) ?
1655 current
->lcy
+ REBARSPACE(current
) :
1657 adj_rh
= new_rh
+ SEP_WIDTH
;
1658 infoPtr
->uNumRows
++;
1659 current
->fDraw
|= NTF_INVALIDATE
;
1661 if (infoPtr
->dwStyle
& CCS_VERT
) {
1662 current
->rcBand
.top
= inity
;
1663 current
->rcBand
.bottom
= clientcy
;
1664 current
->rcBand
.left
+= (prev_rh
+ SEP_WIDTH
);
1665 current
->rcBand
.right
= current
->rcBand
.left
+ new_rh
;
1669 current
->rcBand
.left
= initx
;
1670 current
->rcBand
.right
= clientcx
;
1671 current
->rcBand
.top
+= (prev_rh
+ SEP_WIDTH
);
1672 current
->rcBand
.bottom
= current
->rcBand
.top
+ new_rh
;
1675 TRACE("P2 moving band %d to own row at (%d,%d)-(%d,%d)\n",
1677 current
->rcBand
.left
, current
->rcBand
.top
,
1678 current
->rcBand
.right
, current
->rcBand
.bottom
);
1679 TRACE("P2 prev band %d at (%d,%d)-(%d,%d)\n",
1681 prev
->rcBand
.left
, prev
->rcBand
.top
,
1682 prev
->rcBand
.right
, prev
->rcBand
.bottom
);
1683 TRACE("P2 values: prev_rh=%d, new_rh=%d, adj_rh=%d\n",
1684 prev_rh
, new_rh
, adj_rh
);
1685 /* for bands below current adjust row # and top/bottom */
1686 for (j
= current_idx
+1; j
<infoPtr
->uNumBands
; j
++) {
1687 walk
= &infoPtr
->bands
[j
];
1688 if (HIDDENBAND(walk
)) continue;
1689 walk
->fDraw
|= NTF_INVALIDATE
;
1691 if (infoPtr
->dwStyle
& CCS_VERT
) {
1692 walk
->rcBand
.left
+= adj_rh
;
1693 walk
->rcBand
.right
+= adj_rh
;
1696 walk
->rcBand
.top
+= adj_rh
;
1697 walk
->rcBand
.bottom
+= adj_rh
;
1700 if ((infoPtr
->dwStyle
& CCS_VERT
) ? (x
>= adjcx
) : (y
>= adjcy
))
1701 break; /* all done */
1707 /* ******* End Phase 2 - split rows till adjustment height full ******* */
1710 /* ******* Start Phase 2a - create array of start and end ******* */
1711 /* indexes by row */
1713 if (infoPtr
->uNumRows
!= origrows
) {
1714 if (infoPtr
->rows
) COMCTL32_Free (infoPtr
->rows
);
1715 infoPtr
->rows
= COMCTL32_Alloc (sizeof (REBAR_ROW
) * infoPtr
->uNumRows
);
1719 for (i
= 0; i
< infoPtr
->uNumBands
; i
++) {
1720 lpBand
= &infoPtr
->bands
[i
];
1721 if (HIDDENBAND(lpBand
)) continue;
1723 if (lpBand
->iRow
> row
) {
1725 infoPtr
->rows
[row
-1].istartband
= i
;
1728 ERR("P2a bug!!!!!!\n");
1730 infoPtr
->rows
[row
-1].iendband
= i
;
1733 for (i
= 0; i
< infoPtr
->uNumRows
; i
++) {
1736 p
= &infoPtr
->rows
[i
];
1737 TRACE("P2a row %d, starts %d, ends %d\n",
1738 i
+1, p
->istartband
, p
->iendband
);
1741 /* ******* End Phase 2a - create array of start and end ******* */
1742 /* indexes by row */
1745 /* ******* Start Phase 2b - adjust all bands for height full ******* */
1746 /* assumes that the following variables contain: */
1747 /* y/x current height/width of all rows */
1748 /* clientcy/clientcx height/width of client area */
1750 if (((infoPtr
->dwStyle
& CCS_VERT
) ? clientcx
> x
: clientcy
> y
) &&
1751 infoPtr
->uNumBands
) {
1755 diff
= (infoPtr
->dwStyle
& CCS_VERT
) ? clientcx
- x
: clientcy
- y
;
1756 for (i
= infoPtr
->uNumRows
; i
>= 1; i
--) {
1757 /* if row has more than 1 band, ignore row */
1758 if (infoPtr
->rows
[i
-1].istartband
!= infoPtr
->rows
[i
-1].iendband
)
1760 /* point to only band in row */
1761 iband
= infoPtr
->rows
[i
-1].istartband
;
1762 lpBand
= &infoPtr
->bands
[iband
];
1763 if(HIDDENBAND(lpBand
)) continue;
1764 if (lpBand
->fMask
& RBBS_VARIABLEHEIGHT
) continue;
1765 if (((INT
)lpBand
->cyMaxChild
< 1) ||
1766 ((INT
)lpBand
->cyIntegral
< 1)) {
1767 if (lpBand
->cyMaxChild
+ lpBand
->cyIntegral
== 0) continue;
1768 ERR("P2b band %u RBBS_VARIABLEHEIGHT set but cyMax=%d, cyInt=%d\n",
1769 iband
, lpBand
->cyMaxChild
, lpBand
->cyIntegral
);
1772 /* j is now the maximum height/width in the client area */
1773 j
= ((diff
/ lpBand
->cyIntegral
) * lpBand
->cyIntegral
) +
1775 if (j
> lpBand
->cyMaxChild
+ REBARSPACE(lpBand
))
1776 j
= lpBand
->cyMaxChild
+ REBARSPACE(lpBand
);
1777 diff
-= (j
- ircBw(lpBand
));
1778 if (infoPtr
->dwStyle
& CCS_VERT
)
1779 lpBand
->rcBand
.right
= lpBand
->rcBand
.left
+ j
;
1781 lpBand
->rcBand
.bottom
= lpBand
->rcBand
.top
+ j
;
1782 TRACE("P2b band %d, row %d changed to (%d,%d)-(%d,%d)\n",
1783 iband
, lpBand
->iRow
,
1784 lpBand
->rcBand
.left
, lpBand
->rcBand
.top
,
1785 lpBand
->rcBand
.right
, lpBand
->rcBand
.bottom
);
1786 if (diff
<= 0) break;
1789 ERR("P2b allocated more than available, diff=%d\n", diff
);
1792 if (infoPtr
->dwStyle
& CCS_VERT
)
1793 x
= clientcx
- diff
;
1795 y
= clientcy
- diff
;
1798 /* ******* End Phase 2b - adjust all bands for height full ******* */
1801 /* ******* Start Phase 3 - adjust all bands for width full ******* */
1803 if (infoPtr
->uNumBands
) {
1806 /* If RBS_BANDBORDERS set then indicate to draw bottom separator */
1807 /* on all bands in all rows but last row. */
1808 /* Also indicate to draw the right separator for each band in */
1809 /* each row but the rightmost band. */
1810 if (infoPtr
->dwStyle
& RBS_BANDBORDERS
) {
1812 for(i
= 0; i
< infoPtr
->uNumRows
; i
++) {
1813 p
= &infoPtr
->rows
[i
];
1814 for (j
= p
->istartband
; j
<= p
->iendband
; j
++) {
1815 lpBand
= &infoPtr
->bands
[j
];
1816 if (HIDDENBAND(lpBand
)) continue;
1817 if (j
!= p
->iendband
)
1818 lpBand
->fDraw
|= DRAW_RIGHTSEP
;
1819 if (i
!= infoPtr
->uNumRows
-1)
1820 lpBand
->fDraw
|= DRAW_BOTTOMSEP
;
1825 /* Distribute the extra space on the horizontal and adjust */
1826 /* all bands in row to same height. */
1827 for (i
=1; i
<=infoPtr
->uNumRows
; i
++) {
1828 p
= &infoPtr
->rows
[i
-1];
1831 TRACE("P3 processing row %d, starting band %d, ending band %d\n",
1832 i
, p
->istartband
, p
->iendband
);
1834 /* Find the largest height of the bands in the row */
1835 for (j
= p
->istartband
; j
<= p
->iendband
; j
++) {
1836 lpBand
= &infoPtr
->bands
[j
];
1837 if (HIDDENBAND(lpBand
)) continue;
1838 if (mcy
< ircBw(lpBand
))
1839 mcy
= ircBw(lpBand
);
1842 REBAR_AdjustBands (infoPtr
, p
->istartband
, p
->iendband
,
1843 (infoPtr
->dwStyle
& CCS_VERT
) ?
1844 clientcy
: clientcx
, mcy
);
1847 /* Calculate the other rectangles in each band */
1848 if (infoPtr
->dwStyle
& CCS_VERT
) {
1849 REBAR_CalcVertBand (infoPtr
, 0, infoPtr
->uNumBands
,
1853 REBAR_CalcHorzBand (infoPtr
, 0, infoPtr
->uNumBands
,
1858 /* ******* End Phase 3 - adjust all bands for width full ******* */
1860 /* now compute size of Rebar itself */
1861 infoPtr
->oldSize
= infoPtr
->calcSize
;
1862 if (infoPtr
->uNumBands
== 0) {
1863 /* we have no bands, so make size the size of client */
1867 if (infoPtr
->dwStyle
& CCS_VERT
) {
1868 infoPtr
->calcSize
.cx
= x
;
1869 infoPtr
->calcSize
.cy
= clientcy
;
1870 TRACE("vert, notify=%d, x=%d, origheight=%d\n",
1871 notify
, x
, origheight
);
1872 if (notify
&& (x
!= origheight
)) infoPtr
->fStatus
|= NTF_HGHTCHG
;
1875 infoPtr
->calcSize
.cx
= clientcx
;
1876 infoPtr
->calcSize
.cy
= y
;
1877 TRACE("horz, notify=%d, y=%d, origheight=%d\n",
1878 notify
, y
, origheight
);
1879 if (notify
&& (y
!= origheight
)) infoPtr
->fStatus
|= NTF_HGHTCHG
;
1882 REBAR_DumpBand (infoPtr
);
1884 REBAR_MoveChildWindows (infoPtr
, 0, infoPtr
->uNumBands
);
1886 REBAR_ForceResize (infoPtr
);
1891 REBAR_ValidateBand (REBAR_INFO
*infoPtr
, REBAR_BAND
*lpBand
)
1892 /* Function: This routine evaluates the band specs supplied */
1893 /* by the user and updates the following 5 fields in */
1894 /* the internal band structure: cxHeader, lcx, lcy, hcx, hcy*/
1901 lpBand
->fStatus
= 0;
1909 /* Data comming in from users into the cx... and cy... fields */
1910 /* may be bad, just garbage, because the user never clears */
1911 /* the fields. RB_{SET|INSERT}BAND{A|W} just passes the data */
1912 /* along if the fields exist in the input area. Here we must */
1913 /* determine if the data is valid. I have no idea how MS does */
1914 /* the validation, but it does because the RB_GETBANDINFO */
1915 /* returns a 0 when I know the sample program passed in an */
1916 /* address. Here I will use the algorithim that if the value */
1917 /* is greater than 65535 then it is bad and replace it with */
1918 /* a zero. Feel free to improve the algorithim. - GA 12/2000 */
1919 if (lpBand
->cxMinChild
> 65535) lpBand
->cxMinChild
= 0;
1920 if (lpBand
->cyMinChild
> 65535) lpBand
->cyMinChild
= 0;
1921 if (lpBand
->cx
> 65535) lpBand
->cx
= 0;
1922 if (lpBand
->cyChild
> 65535) lpBand
->cyChild
= 0;
1923 if (lpBand
->cyMaxChild
> 65535) lpBand
->cyMaxChild
= 0;
1924 if (lpBand
->cyIntegral
> 65535) lpBand
->cyIntegral
= 0;
1925 if (lpBand
->cxIdeal
> 65535) lpBand
->cxIdeal
= 0;
1926 if (lpBand
->cxHeader
> 65535) lpBand
->cxHeader
= 0;
1928 /* FIXME: probably should only set NEEDS_LAYOUT flag when */
1929 /* values change. Till then always set it. */
1930 TRACE("setting NEEDS_LAYOUT\n");
1931 infoPtr
->fStatus
|= BAND_NEEDS_LAYOUT
;
1933 /* Header is where the image, text and gripper exist */
1934 /* in the band and preceed the child window. */
1936 /* count number of non-FIXEDSIZE and non-Hidden bands */
1938 for (i
=0; i
<infoPtr
->uNumBands
; i
++){
1939 tBand
= &infoPtr
->bands
[i
];
1940 if (!HIDDENBAND(tBand
) && !(tBand
->fStyle
& RBBS_FIXEDSIZE
))
1944 /* calculate gripper rectangle */
1945 if ( (!(lpBand
->fStyle
& RBBS_NOGRIPPER
)) &&
1946 ( (lpBand
->fStyle
& RBBS_GRIPPERALWAYS
) ||
1947 ( !(lpBand
->fStyle
& RBBS_FIXEDSIZE
) && (nonfixed
> 1)))
1949 lpBand
->fStatus
|= HAS_GRIPPER
;
1950 if (infoPtr
->dwStyle
& CCS_VERT
)
1951 if (infoPtr
->dwStyle
& RBS_VERTICALGRIPPER
)
1952 header
+= (GRIPPER_HEIGHT
+ REBAR_PRE_GRIPPER
);
1954 header
+= (GRIPPER_WIDTH
+ REBAR_PRE_GRIPPER
);
1956 header
+= (REBAR_PRE_GRIPPER
+ GRIPPER_WIDTH
);
1957 /* Always have 4 pixels before anything else */
1958 header
+= REBAR_ALWAYS_SPACE
;
1961 /* image is visible */
1962 if ((lpBand
->fMask
& RBBIM_IMAGE
) && (infoPtr
->himl
)) {
1963 lpBand
->fStatus
|= HAS_IMAGE
;
1964 if (infoPtr
->dwStyle
& CCS_VERT
) {
1965 header
+= (infoPtr
->imageSize
.cy
+ REBAR_POST_IMAGE
);
1966 lpBand
->lcy
= infoPtr
->imageSize
.cx
+ 2;
1969 header
+= (infoPtr
->imageSize
.cx
+ REBAR_POST_IMAGE
);
1970 lpBand
->lcy
= infoPtr
->imageSize
.cy
+ 2;
1974 /* text is visible */
1975 if ((lpBand
->fMask
& RBBIM_TEXT
) && (lpBand
->lpText
)) {
1976 HDC hdc
= GetDC (0);
1977 HFONT hOldFont
= SelectObject (hdc
, infoPtr
->hFont
);
1980 lpBand
->fStatus
|= HAS_TEXT
;
1981 GetTextExtentPoint32W (hdc
, lpBand
->lpText
,
1982 lstrlenW (lpBand
->lpText
), &size
);
1983 header
+= ((infoPtr
->dwStyle
& CCS_VERT
) ? (size
.cy
+ REBAR_POST_TEXT
) : (size
.cx
+ REBAR_POST_TEXT
));
1984 textheight
= (infoPtr
->dwStyle
& CCS_VERT
) ? 0 : size
.cy
;
1986 SelectObject (hdc
, hOldFont
);
1990 /* if no gripper but either image or text, then leave space */
1991 if ((lpBand
->fStatus
& (HAS_IMAGE
| HAS_TEXT
)) &&
1992 !(lpBand
->fStatus
& HAS_GRIPPER
)) {
1993 header
+= REBAR_ALWAYS_SPACE
;
1996 /* check if user overrode the header value */
1997 if (!(lpBand
->fMask
& RBBIM_HEADERSIZE
))
1998 lpBand
->cxHeader
= header
;
2001 /* Now compute minimum size of child window */
2002 lpBand
->offChild
.cx
= 0;
2003 lpBand
->offChild
.cy
= 0;
2004 lpBand
->lcy
= textheight
;
2005 lpBand
->ccy
= lpBand
->lcy
;
2006 if (lpBand
->fMask
& RBBIM_CHILDSIZE
) {
2007 lpBand
->lcx
= lpBand
->cxMinChild
;
2009 /* Set the .cy values for CHILDSIZE case */
2010 lpBand
->lcy
= max(lpBand
->lcy
, lpBand
->cyMinChild
);
2011 lpBand
->ccy
= lpBand
->lcy
;
2012 lpBand
->hcy
= lpBand
->lcy
;
2013 if (lpBand
->cyMaxChild
!= 0xffffffff) {
2014 lpBand
->hcy
= lpBand
->cyMaxChild
;
2016 if (lpBand
->cyChild
!= 0xffffffff)
2017 lpBand
->ccy
= max (lpBand
->cyChild
, lpBand
->lcy
);
2019 TRACE("_CHILDSIZE\n");
2021 if (lpBand
->fMask
& RBBIM_SIZE
) {
2022 lpBand
->hcx
= max (lpBand
->cx
-lpBand
->cxHeader
, lpBand
->lcx
);
2026 lpBand
->hcx
= lpBand
->lcx
;
2027 lpBand
->ccx
= lpBand
->hcx
;
2029 /* make ->.cx include header size for _Layout */
2030 lpBand
->lcx
+= lpBand
->cxHeader
;
2031 lpBand
->ccx
+= lpBand
->cxHeader
;
2032 lpBand
->hcx
+= lpBand
->cxHeader
;
2037 REBAR_CommonSetupBand (HWND hwnd
, LPREBARBANDINFOA lprbbi
, REBAR_BAND
*lpBand
)
2038 /* Function: This routine copies the supplied values from */
2039 /* user input (lprbbi) to the internal band structure. */
2041 lpBand
->fMask
|= lprbbi
->fMask
;
2043 if (lprbbi
->fMask
& RBBIM_STYLE
)
2044 lpBand
->fStyle
= lprbbi
->fStyle
;
2046 if (lprbbi
->fMask
& RBBIM_COLORS
) {
2047 lpBand
->clrFore
= lprbbi
->clrFore
;
2048 lpBand
->clrBack
= lprbbi
->clrBack
;
2051 if (lprbbi
->fMask
& RBBIM_IMAGE
)
2052 lpBand
->iImage
= lprbbi
->iImage
;
2054 if (lprbbi
->fMask
& RBBIM_CHILD
) {
2055 if (lprbbi
->hwndChild
) {
2056 lpBand
->hwndChild
= lprbbi
->hwndChild
;
2057 lpBand
->hwndPrevParent
=
2058 SetParent (lpBand
->hwndChild
, hwnd
);
2059 /* below in trace fro WinRAR */
2060 ShowWindow(lpBand
->hwndChild
, SW_SHOWNOACTIVATE
| SW_SHOWNORMAL
);
2061 /* above in trace fro WinRAR */
2064 TRACE("child: %p prev parent: %p\n",
2065 lpBand
->hwndChild
, lpBand
->hwndPrevParent
);
2066 lpBand
->hwndChild
= 0;
2067 lpBand
->hwndPrevParent
= 0;
2071 if (lprbbi
->fMask
& RBBIM_CHILDSIZE
) {
2072 lpBand
->cxMinChild
= lprbbi
->cxMinChild
;
2073 lpBand
->cyMinChild
= lprbbi
->cyMinChild
;
2074 if (lprbbi
->cbSize
>= sizeof (REBARBANDINFOA
)) {
2075 lpBand
->cyChild
= lprbbi
->cyChild
;
2076 lpBand
->cyMaxChild
= lprbbi
->cyMaxChild
;
2077 lpBand
->cyIntegral
= lprbbi
->cyIntegral
;
2079 else { /* special case - these should be zeroed out since */
2080 /* RBBIM_CHILDSIZE added these in WIN32_IE >= 0x0400 */
2081 lpBand
->cyChild
= 0;
2082 lpBand
->cyMaxChild
= 0;
2083 lpBand
->cyIntegral
= 0;
2087 if (lprbbi
->fMask
& RBBIM_SIZE
)
2088 lpBand
->cx
= lprbbi
->cx
;
2090 if (lprbbi
->fMask
& RBBIM_BACKGROUND
)
2091 lpBand
->hbmBack
= lprbbi
->hbmBack
;
2093 if (lprbbi
->fMask
& RBBIM_ID
)
2094 lpBand
->wID
= lprbbi
->wID
;
2096 /* check for additional data */
2097 if (lprbbi
->cbSize
>= sizeof (REBARBANDINFOA
)) {
2098 if (lprbbi
->fMask
& RBBIM_IDEALSIZE
)
2099 lpBand
->cxIdeal
= lprbbi
->cxIdeal
;
2101 if (lprbbi
->fMask
& RBBIM_LPARAM
)
2102 lpBand
->lParam
= lprbbi
->lParam
;
2104 if (lprbbi
->fMask
& RBBIM_HEADERSIZE
)
2105 lpBand
->cxHeader
= lprbbi
->cxHeader
;
2110 REBAR_InternalEraseBkGnd (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
, RECT
*clip
)
2111 /* Function: This erases the background rectangle by drawing */
2112 /* each band with its background color (or the default) and */
2113 /* draws each bands right separator if necessary. The row */
2114 /* separators are drawn on the first band of the next row. */
2119 HDC hdc
= (HDC
)wParam
;
2121 COLORREF old
= CLR_NONE
, new;
2124 for(i
=0; i
<infoPtr
->uNumBands
; i
++) {
2125 lpBand
= &infoPtr
->bands
[i
];
2126 if (HIDDENBAND(lpBand
)) continue;
2128 /* draw band separator between rows */
2129 if (lpBand
->iRow
!= oldrow
) {
2130 oldrow
= lpBand
->iRow
;
2131 if (lpBand
->fDraw
& DRAW_BOTTOMSEP
) {
2133 rcRowSep
= lpBand
->rcBand
;
2134 if (infoPtr
->dwStyle
& CCS_VERT
) {
2135 rcRowSep
.right
+= SEP_WIDTH_SIZE
;
2136 rcRowSep
.bottom
= infoPtr
->calcSize
.cy
;
2137 DrawEdge (hdc
, &rcRowSep
, EDGE_ETCHED
, BF_RIGHT
);
2140 rcRowSep
.bottom
+= SEP_WIDTH_SIZE
;
2141 rcRowSep
.right
= infoPtr
->calcSize
.cx
;
2142 DrawEdge (hdc
, &rcRowSep
, EDGE_ETCHED
, BF_BOTTOM
);
2144 TRACE ("drawing band separator bottom (%d,%d)-(%d,%d)\n",
2145 rcRowSep
.left
, rcRowSep
.top
,
2146 rcRowSep
.right
, rcRowSep
.bottom
);
2150 /* draw band separator between bands in a row */
2151 if (lpBand
->fDraw
& DRAW_RIGHTSEP
) {
2153 rcSep
= lpBand
->rcBand
;
2154 if (infoPtr
->dwStyle
& CCS_VERT
) {
2155 rcSep
.bottom
+= SEP_WIDTH_SIZE
;
2156 DrawEdge (hdc
, &rcSep
, EDGE_ETCHED
, BF_BOTTOM
);
2159 rcSep
.right
+= SEP_WIDTH_SIZE
;
2160 DrawEdge (hdc
, &rcSep
, EDGE_ETCHED
, BF_RIGHT
);
2162 TRACE("drawing band separator right (%d,%d)-(%d,%d)\n",
2163 rcSep
.left
, rcSep
.top
, rcSep
.right
, rcSep
.bottom
);
2166 /* draw the actual background */
2167 if (lpBand
->clrBack
!= CLR_NONE
) {
2168 new = (lpBand
->clrBack
== CLR_DEFAULT
) ? infoPtr
->clrBtnFace
:
2171 /* testing only - make background green to see it */
2176 /* In the absence of documentation for Rebar vs. CLR_NONE,
2177 * we will use the default BtnFace color. Note documentation
2178 * exists for Listview and Imagelist.
2180 new = infoPtr
->clrBtnFace
;
2182 /* testing only - make background green to see it */
2186 old
= SetBkColor (hdc
, new);
2188 rect
= lpBand
->rcBand
;
2189 TRACE("%s background color=0x%06lx, band (%d,%d)-(%d,%d), clip (%d,%d)-(%d,%d)\n",
2190 (lpBand
->clrBack
== CLR_NONE
) ? "none" :
2191 ((lpBand
->clrBack
== CLR_DEFAULT
) ? "dft" : ""),
2193 lpBand
->rcBand
.left
,lpBand
->rcBand
.top
,
2194 lpBand
->rcBand
.right
,lpBand
->rcBand
.bottom
,
2195 clip
->left
, clip
->top
,
2196 clip
->right
, clip
->bottom
);
2197 ExtTextOutA (hdc
, 0, 0, ETO_OPAQUE
, &rect
, NULL
, 0, 0);
2198 if (lpBand
->clrBack
!= CLR_NONE
)
2199 SetBkColor (hdc
, old
);
2205 REBAR_InternalHitTest (REBAR_INFO
*infoPtr
, LPPOINT lpPt
, UINT
*pFlags
, INT
*pBand
)
2211 GetClientRect (infoPtr
->hwndSelf
, &rect
);
2213 *pFlags
= RBHT_NOWHERE
;
2214 if (PtInRect (&rect
, *lpPt
))
2216 if (infoPtr
->uNumBands
== 0) {
2217 *pFlags
= RBHT_NOWHERE
;
2224 /* somewhere inside */
2225 infoPtr
->ihitBand
= -1;
2226 for (iCount
= 0; iCount
< infoPtr
->uNumBands
; iCount
++) {
2227 lpBand
= &infoPtr
->bands
[iCount
];
2228 if (HIDDENBAND(lpBand
)) continue;
2229 if (PtInRect (&lpBand
->rcBand
, *lpPt
)) {
2232 if (PtInRect (&lpBand
->rcGripper
, *lpPt
)) {
2233 *pFlags
= RBHT_GRABBER
;
2234 infoPtr
->ihitBand
= iCount
;
2235 TRACE("ON GRABBER %d\n", iCount
);
2238 else if (PtInRect (&lpBand
->rcCapImage
, *lpPt
)) {
2239 *pFlags
= RBHT_CAPTION
;
2240 TRACE("ON CAPTION %d\n", iCount
);
2243 else if (PtInRect (&lpBand
->rcCapText
, *lpPt
)) {
2244 *pFlags
= RBHT_CAPTION
;
2245 TRACE("ON CAPTION %d\n", iCount
);
2248 else if (PtInRect (&lpBand
->rcChild
, *lpPt
)) {
2249 *pFlags
= RBHT_CLIENT
;
2250 TRACE("ON CLIENT %d\n", iCount
);
2254 *pFlags
= RBHT_NOWHERE
;
2255 TRACE("NOWHERE %d\n", iCount
);
2261 *pFlags
= RBHT_NOWHERE
;
2270 *pFlags
= RBHT_NOWHERE
;
2277 TRACE("flags=0x%X\n", *pFlags
);
2283 REBAR_Shrink (REBAR_INFO
*infoPtr
, REBAR_BAND
*band
, INT movement
, INT i
)
2284 /* Function: This attempts to shrink the given band by the */
2285 /* the amount in "movement". A shrink to the left is indi- */
2286 /* cated by "movement" being negative. "i" is merely the */
2287 /* band index for trace messages. */
2289 INT Leadjust
, Readjust
, avail
, ret
;
2291 /* Note: a left drag is indicated by "movement" being negative. */
2292 /* Similarly, a right drag is indicated by "movement" */
2293 /* being positive. "movement" should never be 0, but if */
2294 /* it is then the band does not move. */
2296 avail
= rcBw(band
) - band
->lcx
;
2298 /* now compute the Left End adjustment factor and Right End */
2299 /* adjustment factor. They may be different if shrinking. */
2301 /* if this band is not shrinkable, then just move it */
2302 Leadjust
= Readjust
= movement
;
2308 if (avail
<= abs(movement
)) {
2309 Readjust
= movement
;
2310 Leadjust
= movement
+ avail
;
2314 Readjust
= movement
;
2321 if (avail
<= abs(movement
)) {
2322 Leadjust
= movement
;
2323 Readjust
= movement
- avail
;
2327 Leadjust
= movement
;
2334 /* Reasonability Check */
2335 if (rcBlt(band
) + Leadjust
< 0) {
2336 ERR("adjustment will fail, band %d: left=%d, right=%d, move=%d, rtn=%d\n",
2337 i
, Leadjust
, Readjust
, movement
, ret
);
2340 LEADJ(band
, Leadjust
);
2341 READJ(band
, Readjust
);
2343 TRACE("band %d: left=%d, right=%d, move=%d, rtn=%d, rcBand=(%d,%d)-(%d,%d)\n",
2344 i
, Leadjust
, Readjust
, movement
, ret
,
2345 band
->rcBand
.left
, band
->rcBand
.top
,
2346 band
->rcBand
.right
, band
->rcBand
.bottom
);
2352 REBAR_HandleLRDrag (REBAR_INFO
*infoPtr
, POINTS
*ptsmove
)
2353 /* Function: This will implement the functionality of a */
2354 /* Gripper drag within a row. It will not implement "out- */
2355 /* of-row" drags. (They are detected and handled in */
2356 /* REBAR_MouseMove.) */
2357 /* **** FIXME Switching order of bands in a row not **** */
2358 /* **** yet implemented. **** */
2360 REBAR_BAND
*hitBand
, *band
, *mindBand
, *maxdBand
;
2362 INT imindBand
= -1, imaxdBand
, ihitBand
, i
, movement
;
2363 INT RHeaderSum
= 0, LHeaderSum
= 0;
2366 /* on first significant mouse movement, issue notify */
2368 if (!(infoPtr
->fStatus
& BEGIN_DRAG_ISSUED
)) {
2369 if (REBAR_Notify_NMREBAR (infoPtr
, -1, RBN_BEGINDRAG
)) {
2370 /* Notify returned TRUE - abort drag */
2371 infoPtr
->dragStart
.x
= 0;
2372 infoPtr
->dragStart
.y
= 0;
2373 infoPtr
->dragNow
= infoPtr
->dragStart
;
2374 infoPtr
->ihitBand
= -1;
2378 infoPtr
->fStatus
|= BEGIN_DRAG_ISSUED
;
2381 ihitBand
= infoPtr
->ihitBand
;
2382 hitBand
= &infoPtr
->bands
[ihitBand
];
2383 imaxdBand
= ihitBand
; /* to suppress warning message */
2385 /* find all the bands in the row of the one whose Gripper was seized */
2386 for (i
=0; i
<infoPtr
->uNumBands
; i
++) {
2387 band
= &infoPtr
->bands
[i
];
2388 if (HIDDENBAND(band
)) continue;
2389 if (band
->iRow
== hitBand
->iRow
) {
2391 if (imindBand
== -1) imindBand
= i
;
2392 /* minimum size of each band is size of header plus */
2393 /* size of minimum child plus offset of child from header plus */
2394 /* a one to separate each band. */
2396 LHeaderSum
+= (band
->lcx
+ SEP_WIDTH
);
2398 RHeaderSum
+= (band
->lcx
+ SEP_WIDTH
);
2402 if (RHeaderSum
) RHeaderSum
-= SEP_WIDTH
; /* no separator afterlast band */
2404 mindBand
= &infoPtr
->bands
[imindBand
];
2405 maxdBand
= &infoPtr
->bands
[imaxdBand
];
2407 if (imindBand
== imaxdBand
) return; /* nothing to drag agains */
2408 if (imindBand
== ihitBand
) return; /* first band in row, cant drag */
2410 /* limit movement to inside adjustable bands - Left */
2411 if ( (ptsmove
->x
< mindBand
->rcBand
.left
) ||
2412 (ptsmove
->x
> maxdBand
->rcBand
.right
) ||
2413 (ptsmove
->y
< mindBand
->rcBand
.top
) ||
2414 (ptsmove
->y
> maxdBand
->rcBand
.bottom
))
2415 return; /* should swap bands */
2417 if (infoPtr
->dwStyle
& CCS_VERT
)
2418 movement
= ptsmove
->y
- ((hitBand
->rcBand
.top
+REBAR_PRE_GRIPPER
) -
2419 infoPtr
->ihitoffset
);
2421 movement
= ptsmove
->x
- ((hitBand
->rcBand
.left
+REBAR_PRE_GRIPPER
) -
2422 infoPtr
->ihitoffset
);
2423 infoPtr
->dragNow
= *ptsmove
;
2425 TRACE("before: movement=%d (%d,%d), imindBand=%d, ihitBand=%d, imaxdBand=%d, LSum=%d, RSum=%d\n",
2426 movement
, ptsmove
->x
, ptsmove
->y
, imindBand
, ihitBand
,
2427 imaxdBand
, LHeaderSum
, RHeaderSum
);
2428 REBAR_DumpBand (infoPtr
);
2432 /* *** Drag left/up *** */
2433 compress
= rcBlt(hitBand
) - rcBlt(mindBand
) -
2435 if (compress
< abs(movement
)) {
2436 TRACE("limiting left drag, was %d changed to %d\n",
2437 movement
, -compress
);
2438 movement
= -compress
;
2441 for (i
=ihitBand
; i
>=imindBand
; i
--) {
2442 band
= &infoPtr
->bands
[i
];
2443 if (HIDDENBAND(band
)) continue;
2444 if (i
== ihitBand
) {
2445 LEADJ(band
, movement
);
2448 movement
= REBAR_Shrink (infoPtr
, band
, movement
, i
);
2449 band
->ccx
= rcBw(band
);
2455 /* *** Drag right/down *** */
2456 compress
= rcBrb(maxdBand
) - rcBlt(hitBand
) -
2458 if (compress
< abs(movement
)) {
2459 TRACE("limiting right drag, was %d changed to %d\n",
2460 movement
, compress
);
2461 movement
= compress
;
2463 for (i
=ihitBand
-1; i
<=imaxdBand
; i
++) {
2464 band
= &infoPtr
->bands
[i
];
2465 if (HIDDENBAND(band
)) continue;
2468 READJ(band
, movement
);
2471 movement
= REBAR_Shrink (infoPtr
, band
, movement
, i
);
2472 band
->ccx
= rcBw(band
);
2476 /* recompute all rectangles */
2477 if (infoPtr
->dwStyle
& CCS_VERT
) {
2478 REBAR_CalcVertBand (infoPtr
, imindBand
, imaxdBand
+1,
2482 REBAR_CalcHorzBand (infoPtr
, imindBand
, imaxdBand
+1,
2486 TRACE("bands after adjustment, see band # %d, %d\n",
2487 imindBand
, imaxdBand
);
2488 REBAR_DumpBand (infoPtr
);
2491 mindBand
->rcBand
.left
,
2492 mindBand
->rcBand
.top
,
2493 maxdBand
->rcBand
.right
,
2494 maxdBand
->rcBand
.bottom
);
2496 REBAR_MoveChildWindows (infoPtr
, imindBand
, imaxdBand
+1);
2498 InvalidateRect (infoPtr
->hwndSelf
, &newrect
, TRUE
);
2499 UpdateWindow (infoPtr
->hwndSelf
);
2505 /* << REBAR_BeginDrag >> */
2509 REBAR_DeleteBand (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
2511 UINT uBand
= (UINT
)wParam
;
2515 if (uBand
>= infoPtr
->uNumBands
)
2518 TRACE("deleting band %u!\n", uBand
);
2519 lpBand
= &infoPtr
->bands
[uBand
];
2520 REBAR_Notify_NMREBAR (infoPtr
, uBand
, RBN_DELETINGBAND
);
2522 if (infoPtr
->uNumBands
== 1) {
2523 TRACE(" simple delete!\n");
2524 if ((lpBand
->fMask
& RBBIM_CHILD
) && lpBand
->hwndChild
)
2525 childhwnd
= lpBand
->hwndChild
;
2526 COMCTL32_Free (infoPtr
->bands
);
2527 infoPtr
->bands
= NULL
;
2528 infoPtr
->uNumBands
= 0;
2531 REBAR_BAND
*oldBands
= infoPtr
->bands
;
2532 TRACE("complex delete! [uBand=%u]\n", uBand
);
2534 if ((lpBand
->fMask
& RBBIM_CHILD
) && lpBand
->hwndChild
)
2535 childhwnd
= lpBand
->hwndChild
;
2537 infoPtr
->uNumBands
--;
2538 infoPtr
->bands
= COMCTL32_Alloc (sizeof (REBAR_BAND
) * infoPtr
->uNumBands
);
2540 memcpy (&infoPtr
->bands
[0], &oldBands
[0],
2541 uBand
* sizeof(REBAR_BAND
));
2544 if (uBand
< infoPtr
->uNumBands
) {
2545 memcpy (&infoPtr
->bands
[uBand
], &oldBands
[uBand
+1],
2546 (infoPtr
->uNumBands
- uBand
) * sizeof(REBAR_BAND
));
2549 COMCTL32_Free (oldBands
);
2553 ShowWindow (childhwnd
, SW_HIDE
);
2555 REBAR_Notify_NMREBAR (infoPtr
, -1, RBN_DELETEDBAND
);
2557 /* if only 1 band left the re-validate to possible eliminate gripper */
2558 if (infoPtr
->uNumBands
== 1)
2559 REBAR_ValidateBand (infoPtr
, &infoPtr
->bands
[0]);
2561 TRACE("setting NEEDS_LAYOUT\n");
2562 infoPtr
->fStatus
|= BAND_NEEDS_LAYOUT
;
2563 infoPtr
->fStatus
|= RESIZE_ANYHOW
;
2564 REBAR_Layout (infoPtr
, NULL
, TRUE
, FALSE
);
2570 /* << REBAR_DragMove >> */
2571 /* << REBAR_EndDrag >> */
2575 REBAR_GetBandBorders (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
2577 LPRECT lpRect
= (LPRECT
)lParam
;
2582 if ((UINT
)wParam
>= infoPtr
->uNumBands
)
2585 lpBand
= &infoPtr
->bands
[(UINT
)wParam
];
2587 /* FIXME - the following values were determined by experimentation */
2588 /* with the REBAR Control Spy. I have guesses as to what the 4 and */
2589 /* 1 are, but I am not sure. There doesn't seem to be any actual */
2590 /* difference in size of the control area with and without the */
2592 if (infoPtr
->dwStyle
& RBS_BANDBORDERS
) {
2593 if (infoPtr
->dwStyle
& CCS_VERT
) {
2595 lpRect
->top
= lpBand
->cxHeader
+ 4;
2600 lpRect
->left
= lpBand
->cxHeader
+ 4;
2607 lpRect
->left
= lpBand
->cxHeader
;
2613 inline static LRESULT
2614 REBAR_GetBandCount (REBAR_INFO
*infoPtr
)
2616 TRACE("band count %u!\n", infoPtr
->uNumBands
);
2618 return infoPtr
->uNumBands
;
2623 REBAR_GetBandInfoA (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
2625 LPREBARBANDINFOA lprbbi
= (LPREBARBANDINFOA
)lParam
;
2630 if (lprbbi
->cbSize
< REBARBANDINFO_V3_SIZEA
)
2632 if ((UINT
)wParam
>= infoPtr
->uNumBands
)
2635 TRACE("index %u\n", (UINT
)wParam
);
2637 /* copy band information */
2638 lpBand
= &infoPtr
->bands
[(UINT
)wParam
];
2640 if (lprbbi
->fMask
& RBBIM_STYLE
)
2641 lprbbi
->fStyle
= lpBand
->fStyle
;
2643 if (lprbbi
->fMask
& RBBIM_COLORS
) {
2644 lprbbi
->clrFore
= lpBand
->clrFore
;
2645 lprbbi
->clrBack
= lpBand
->clrBack
;
2646 if (lprbbi
->clrBack
== CLR_DEFAULT
)
2647 lprbbi
->clrBack
= infoPtr
->clrBtnFace
;
2650 if ((lprbbi
->fMask
& RBBIM_TEXT
) && (lprbbi
->lpText
)) {
2651 if (lpBand
->lpText
&& (lpBand
->fMask
& RBBIM_TEXT
))
2653 if (!WideCharToMultiByte( CP_ACP
, 0, lpBand
->lpText
, -1,
2654 lprbbi
->lpText
, lprbbi
->cch
, NULL
, NULL
))
2655 lprbbi
->lpText
[lprbbi
->cch
-1] = 0;
2658 *lprbbi
->lpText
= 0;
2661 if (lprbbi
->fMask
& RBBIM_IMAGE
) {
2662 if (lpBand
->fMask
& RBBIM_IMAGE
)
2663 lprbbi
->iImage
= lpBand
->iImage
;
2665 lprbbi
->iImage
= -1;
2668 if (lprbbi
->fMask
& RBBIM_CHILD
)
2669 lprbbi
->hwndChild
= lpBand
->hwndChild
;
2671 if (lprbbi
->fMask
& RBBIM_CHILDSIZE
) {
2672 lprbbi
->cxMinChild
= lpBand
->cxMinChild
;
2673 lprbbi
->cyMinChild
= lpBand
->cyMinChild
;
2674 if (lprbbi
->cbSize
>= sizeof (REBARBANDINFOA
)) {
2675 lprbbi
->cyChild
= lpBand
->cyChild
;
2676 lprbbi
->cyMaxChild
= lpBand
->cyMaxChild
;
2677 lprbbi
->cyIntegral
= lpBand
->cyIntegral
;
2681 if (lprbbi
->fMask
& RBBIM_SIZE
)
2682 lprbbi
->cx
= lpBand
->cx
;
2684 if (lprbbi
->fMask
& RBBIM_BACKGROUND
)
2685 lprbbi
->hbmBack
= lpBand
->hbmBack
;
2687 if (lprbbi
->fMask
& RBBIM_ID
)
2688 lprbbi
->wID
= lpBand
->wID
;
2690 /* check for additional data */
2691 if (lprbbi
->cbSize
>= sizeof (REBARBANDINFOA
)) {
2692 if (lprbbi
->fMask
& RBBIM_IDEALSIZE
)
2693 lprbbi
->cxIdeal
= lpBand
->cxIdeal
;
2695 if (lprbbi
->fMask
& RBBIM_LPARAM
)
2696 lprbbi
->lParam
= lpBand
->lParam
;
2698 if (lprbbi
->fMask
& RBBIM_HEADERSIZE
)
2699 lprbbi
->cxHeader
= lpBand
->cxHeader
;
2702 REBAR_DumpBandInfo (lprbbi
);
2709 REBAR_GetBandInfoW (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
2711 LPREBARBANDINFOW lprbbi
= (LPREBARBANDINFOW
)lParam
;
2716 if (lprbbi
->cbSize
< REBARBANDINFO_V3_SIZEW
)
2718 if ((UINT
)wParam
>= infoPtr
->uNumBands
)
2721 TRACE("index %u\n", (UINT
)wParam
);
2723 /* copy band information */
2724 lpBand
= &infoPtr
->bands
[(UINT
)wParam
];
2726 if (lprbbi
->fMask
& RBBIM_STYLE
)
2727 lprbbi
->fStyle
= lpBand
->fStyle
;
2729 if (lprbbi
->fMask
& RBBIM_COLORS
) {
2730 lprbbi
->clrFore
= lpBand
->clrFore
;
2731 lprbbi
->clrBack
= lpBand
->clrBack
;
2732 if (lprbbi
->clrBack
== CLR_DEFAULT
)
2733 lprbbi
->clrBack
= infoPtr
->clrBtnFace
;
2736 if ((lprbbi
->fMask
& RBBIM_TEXT
) && (lprbbi
->lpText
)) {
2737 if (lpBand
->lpText
&& (lpBand
->fMask
& RBBIM_TEXT
))
2738 lstrcpynW (lprbbi
->lpText
, lpBand
->lpText
, lprbbi
->cch
);
2740 *lprbbi
->lpText
= 0;
2743 if (lprbbi
->fMask
& RBBIM_IMAGE
) {
2744 if (lpBand
->fMask
& RBBIM_IMAGE
)
2745 lprbbi
->iImage
= lpBand
->iImage
;
2747 lprbbi
->iImage
= -1;
2750 if (lprbbi
->fMask
& RBBIM_CHILD
)
2751 lprbbi
->hwndChild
= lpBand
->hwndChild
;
2753 if (lprbbi
->fMask
& RBBIM_CHILDSIZE
) {
2754 lprbbi
->cxMinChild
= lpBand
->cxMinChild
;
2755 lprbbi
->cyMinChild
= lpBand
->cyMinChild
;
2756 if (lprbbi
->cbSize
>= sizeof (REBARBANDINFOW
)) {
2757 lprbbi
->cyChild
= lpBand
->cyChild
;
2758 lprbbi
->cyMaxChild
= lpBand
->cyMaxChild
;
2759 lprbbi
->cyIntegral
= lpBand
->cyIntegral
;
2763 if (lprbbi
->fMask
& RBBIM_SIZE
)
2764 lprbbi
->cx
= lpBand
->cx
;
2766 if (lprbbi
->fMask
& RBBIM_BACKGROUND
)
2767 lprbbi
->hbmBack
= lpBand
->hbmBack
;
2769 if (lprbbi
->fMask
& RBBIM_ID
)
2770 lprbbi
->wID
= lpBand
->wID
;
2772 /* check for additional data */
2773 if (lprbbi
->cbSize
>= sizeof (REBARBANDINFOW
)) {
2774 if (lprbbi
->fMask
& RBBIM_IDEALSIZE
)
2775 lprbbi
->cxIdeal
= lpBand
->cxIdeal
;
2777 if (lprbbi
->fMask
& RBBIM_LPARAM
)
2778 lprbbi
->lParam
= lpBand
->lParam
;
2780 if (lprbbi
->fMask
& RBBIM_HEADERSIZE
)
2781 lprbbi
->cxHeader
= lpBand
->cxHeader
;
2784 REBAR_DumpBandInfo ((LPREBARBANDINFOA
)lprbbi
);
2791 REBAR_GetBarHeight (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
2795 nHeight
= (infoPtr
->dwStyle
& CCS_VERT
) ? infoPtr
->calcSize
.cx
: infoPtr
->calcSize
.cy
;
2797 TRACE("height = %d\n", nHeight
);
2804 REBAR_GetBarInfo (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
2806 LPREBARINFO lpInfo
= (LPREBARINFO
)lParam
;
2811 if (lpInfo
->cbSize
< sizeof (REBARINFO
))
2814 TRACE("getting bar info!\n");
2816 if (infoPtr
->himl
) {
2817 lpInfo
->himl
= infoPtr
->himl
;
2818 lpInfo
->fMask
|= RBIM_IMAGELIST
;
2825 inline static LRESULT
2826 REBAR_GetBkColor (REBAR_INFO
*infoPtr
)
2828 COLORREF clr
= infoPtr
->clrBk
;
2830 if (clr
== CLR_DEFAULT
)
2831 clr
= infoPtr
->clrBtnFace
;
2833 TRACE("background color 0x%06lx!\n", clr
);
2839 /* << REBAR_GetColorScheme >> */
2840 /* << REBAR_GetDropTarget >> */
2844 REBAR_GetPalette (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
2846 FIXME("empty stub!\n");
2853 REBAR_GetRect (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
2855 INT iBand
= (INT
)wParam
;
2856 LPRECT lprc
= (LPRECT
)lParam
;
2859 if ((iBand
< 0) && ((UINT
)iBand
>= infoPtr
->uNumBands
))
2864 lpBand
= &infoPtr
->bands
[iBand
];
2865 CopyRect (lprc
, &lpBand
->rcBand
);
2867 TRACE("band %d, (%d,%d)-(%d,%d)\n", iBand
,
2868 lprc
->left
, lprc
->top
, lprc
->right
, lprc
->bottom
);
2874 inline static LRESULT
2875 REBAR_GetRowCount (REBAR_INFO
*infoPtr
)
2877 TRACE("%u\n", infoPtr
->uNumRows
);
2879 return infoPtr
->uNumRows
;
2884 REBAR_GetRowHeight (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
2886 INT iRow
= (INT
)wParam
;
2891 for (i
=0; i
<infoPtr
->uNumBands
; i
++) {
2892 lpBand
= &infoPtr
->bands
[i
];
2893 if (HIDDENBAND(lpBand
)) continue;
2894 if (lpBand
->iRow
!= iRow
) continue;
2895 if (infoPtr
->dwStyle
& CCS_VERT
)
2896 j
= lpBand
->rcBand
.right
- lpBand
->rcBand
.left
;
2898 j
= lpBand
->rcBand
.bottom
- lpBand
->rcBand
.top
;
2899 if (j
> ret
) ret
= j
;
2902 TRACE("row %d, height %d\n", iRow
, ret
);
2908 inline static LRESULT
2909 REBAR_GetTextColor (REBAR_INFO
*infoPtr
)
2911 TRACE("text color 0x%06lx!\n", infoPtr
->clrText
);
2913 return infoPtr
->clrText
;
2917 inline static LRESULT
2918 REBAR_GetToolTips (REBAR_INFO
*infoPtr
)
2920 return (LRESULT
)infoPtr
->hwndToolTip
;
2924 inline static LRESULT
2925 REBAR_GetUnicodeFormat (REBAR_INFO
*infoPtr
)
2927 TRACE("%s hwnd=%p\n",
2928 infoPtr
->bUnicode
? "TRUE" : "FALSE", infoPtr
->hwndSelf
);
2930 return infoPtr
->bUnicode
;
2934 inline static LRESULT
2935 REBAR_GetVersion (REBAR_INFO
*infoPtr
)
2937 TRACE("version %d\n", infoPtr
->iVersion
);
2938 return infoPtr
->iVersion
;
2943 REBAR_HitTest (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
2945 LPRBHITTESTINFO lprbht
= (LPRBHITTESTINFO
)lParam
;
2950 REBAR_InternalHitTest (infoPtr
, &lprbht
->pt
, &lprbht
->flags
, &lprbht
->iBand
);
2952 return lprbht
->iBand
;
2957 REBAR_IdToIndex (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
2961 if (infoPtr
== NULL
)
2964 if (infoPtr
->uNumBands
< 1)
2967 for (i
= 0; i
< infoPtr
->uNumBands
; i
++) {
2968 if (infoPtr
->bands
[i
].wID
== (UINT
)wParam
) {
2969 TRACE("id %u is band %u found!\n", (UINT
)wParam
, i
);
2974 TRACE("id %u is not found\n", (UINT
)wParam
);
2980 REBAR_InsertBandA (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
2982 LPREBARBANDINFOA lprbbi
= (LPREBARBANDINFOA
)lParam
;
2983 UINT uIndex
= (UINT
)wParam
;
2986 if (infoPtr
== NULL
)
2990 if (lprbbi
->cbSize
< REBARBANDINFO_V3_SIZEA
)
2993 /* trace the index as signed to see the -1 */
2994 TRACE("insert band at %d!\n", (INT
)uIndex
);
2995 REBAR_DumpBandInfo (lprbbi
);
2997 if (infoPtr
->uNumBands
== 0) {
2998 infoPtr
->bands
= (REBAR_BAND
*)COMCTL32_Alloc (sizeof (REBAR_BAND
));
3002 REBAR_BAND
*oldBands
= infoPtr
->bands
;
3004 (REBAR_BAND
*)COMCTL32_Alloc ((infoPtr
->uNumBands
+1)*sizeof(REBAR_BAND
));
3005 if (((INT
)uIndex
== -1) || (uIndex
> infoPtr
->uNumBands
))
3006 uIndex
= infoPtr
->uNumBands
;
3008 /* pre insert copy */
3010 memcpy (&infoPtr
->bands
[0], &oldBands
[0],
3011 uIndex
* sizeof(REBAR_BAND
));
3015 if (uIndex
< infoPtr
->uNumBands
- 1) {
3016 memcpy (&infoPtr
->bands
[uIndex
+1], &oldBands
[uIndex
],
3017 (infoPtr
->uNumBands
- uIndex
- 1) * sizeof(REBAR_BAND
));
3020 COMCTL32_Free (oldBands
);
3023 infoPtr
->uNumBands
++;
3025 TRACE("index %u!\n", uIndex
);
3027 /* initialize band (infoPtr->bands[uIndex])*/
3028 lpBand
= &infoPtr
->bands
[uIndex
];
3030 lpBand
->fStatus
= 0;
3031 lpBand
->clrFore
= infoPtr
->clrText
;
3032 lpBand
->clrBack
= infoPtr
->clrBk
;
3033 lpBand
->hwndChild
= 0;
3034 lpBand
->hwndPrevParent
= 0;
3036 REBAR_CommonSetupBand (infoPtr
->hwndSelf
, lprbbi
, lpBand
);
3037 lpBand
->lpText
= NULL
;
3038 if ((lprbbi
->fMask
& RBBIM_TEXT
) && (lprbbi
->lpText
)) {
3039 INT len
= MultiByteToWideChar( CP_ACP
, 0, lprbbi
->lpText
, -1, NULL
, 0 );
3041 lpBand
->lpText
= (LPWSTR
)COMCTL32_Alloc (len
*sizeof(WCHAR
));
3042 MultiByteToWideChar( CP_ACP
, 0, lprbbi
->lpText
, -1, lpBand
->lpText
, len
);
3046 REBAR_ValidateBand (infoPtr
, lpBand
);
3047 /* On insert of second band, revalidate band 1 to possible add gripper */
3048 if (infoPtr
->uNumBands
== 2)
3049 REBAR_ValidateBand (infoPtr
, &infoPtr
->bands
[0]);
3051 REBAR_DumpBand (infoPtr
);
3053 REBAR_Layout (infoPtr
, NULL
, TRUE
, FALSE
);
3054 InvalidateRect(infoPtr
->hwndSelf
, 0, 1);
3061 REBAR_InsertBandW (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
3063 LPREBARBANDINFOW lprbbi
= (LPREBARBANDINFOW
)lParam
;
3064 UINT uIndex
= (UINT
)wParam
;
3067 if (infoPtr
== NULL
)
3071 if (lprbbi
->cbSize
< REBARBANDINFO_V3_SIZEW
)
3074 /* trace the index as signed to see the -1 */
3075 TRACE("insert band at %d!\n", (INT
)uIndex
);
3076 REBAR_DumpBandInfo ((LPREBARBANDINFOA
)lprbbi
);
3078 if (infoPtr
->uNumBands
== 0) {
3079 infoPtr
->bands
= (REBAR_BAND
*)COMCTL32_Alloc (sizeof (REBAR_BAND
));
3083 REBAR_BAND
*oldBands
= infoPtr
->bands
;
3085 (REBAR_BAND
*)COMCTL32_Alloc ((infoPtr
->uNumBands
+1)*sizeof(REBAR_BAND
));
3086 if (((INT
)uIndex
== -1) || (uIndex
> infoPtr
->uNumBands
))
3087 uIndex
= infoPtr
->uNumBands
;
3089 /* pre insert copy */
3091 memcpy (&infoPtr
->bands
[0], &oldBands
[0],
3092 uIndex
* sizeof(REBAR_BAND
));
3096 if (uIndex
< infoPtr
->uNumBands
- 1) {
3097 memcpy (&infoPtr
->bands
[uIndex
+1], &oldBands
[uIndex
],
3098 (infoPtr
->uNumBands
- uIndex
- 1) * sizeof(REBAR_BAND
));
3101 COMCTL32_Free (oldBands
);
3104 infoPtr
->uNumBands
++;
3106 TRACE("index %u!\n", uIndex
);
3108 /* initialize band (infoPtr->bands[uIndex])*/
3109 lpBand
= &infoPtr
->bands
[uIndex
];
3111 lpBand
->fStatus
= 0;
3112 lpBand
->clrFore
= infoPtr
->clrText
;
3113 lpBand
->clrBack
= infoPtr
->clrBk
;
3114 lpBand
->hwndChild
= 0;
3115 lpBand
->hwndPrevParent
= 0;
3117 REBAR_CommonSetupBand (infoPtr
->hwndSelf
, (LPREBARBANDINFOA
)lprbbi
, lpBand
);
3118 lpBand
->lpText
= NULL
;
3119 if ((lprbbi
->fMask
& RBBIM_TEXT
) && (lprbbi
->lpText
)) {
3120 INT len
= lstrlenW (lprbbi
->lpText
);
3122 lpBand
->lpText
= (LPWSTR
)COMCTL32_Alloc ((len
+ 1)*sizeof(WCHAR
));
3123 strcpyW (lpBand
->lpText
, lprbbi
->lpText
);
3127 REBAR_ValidateBand (infoPtr
, lpBand
);
3128 /* On insert of second band, revalidate band 1 to possible add gripper */
3129 if (infoPtr
->uNumBands
== 2)
3130 REBAR_ValidateBand (infoPtr
, &infoPtr
->bands
[0]);
3132 REBAR_DumpBand (infoPtr
);
3134 REBAR_Layout (infoPtr
, NULL
, TRUE
, FALSE
);
3135 InvalidateRect(infoPtr
->hwndSelf
, 0, 1);
3142 REBAR_MaximizeBand (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
3145 UINT uBand
= (UINT
) wParam
;
3148 if ((infoPtr
->uNumBands
== 0) ||
3149 ((INT
)uBand
< 0) || (uBand
>= infoPtr
->uNumBands
)) {
3151 ERR("Illegal MaximizeBand, requested=%d, current band count=%d\n",
3152 (INT
)uBand
, infoPtr
->uNumBands
);
3156 lpBand
= &infoPtr
->bands
[uBand
];
3158 if (lParam
&& (lpBand
->fMask
& RBBIM_IDEALSIZE
)) {
3159 /* handle setting ideal size */
3160 lpBand
->ccx
= lpBand
->cxIdeal
;
3163 /* handle setting to max */
3164 FIXME("(uBand = %u fIdeal = %s) case not coded\n",
3165 (UINT
)wParam
, lParam
? "TRUE" : "FALSE");
3169 infoPtr
->fStatus
|= BAND_NEEDS_LAYOUT
;
3170 REBAR_Layout (infoPtr
, 0, TRUE
, TRUE
);
3171 InvalidateRect (infoPtr
->hwndSelf
, 0, TRUE
);
3179 REBAR_MinimizeBand (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
3181 REBAR_BAND
*band
, *lpBand
;
3182 UINT uBand
= (UINT
) wParam
;
3184 INT imindBand
, imaxdBand
, iprevBand
, startBand
, endBand
;
3187 /* A "minimize" band is equivalent to "dragging" the gripper
3188 * of than band to the right till the band is only the size
3193 if ((infoPtr
->uNumBands
== 0) ||
3194 ((INT
)uBand
< 0) || (uBand
>= infoPtr
->uNumBands
)) {
3196 ERR("Illegal MinimizeBand, requested=%d, current band count=%d\n",
3197 (INT
)uBand
, infoPtr
->uNumBands
);
3201 /* compute amount of movement and validate */
3202 lpBand
= &infoPtr
->bands
[uBand
];
3204 if (infoPtr
->dwStyle
& CCS_VERT
)
3205 movement
= lpBand
->rcBand
.bottom
- lpBand
->rcBand
.top
-
3208 movement
= lpBand
->rcBand
.right
- lpBand
->rcBand
.left
-
3211 ERR("something is wrong, band=(%d,%d)-(%d,%d), cxheader=%d\n",
3212 lpBand
->rcBand
.left
, lpBand
->rcBand
.top
,
3213 lpBand
->rcBand
.right
, lpBand
->rcBand
.bottom
,
3220 iprevBand
= -1; /* to suppress warning message */
3222 /* find the first band in row of the one whose is being minimized */
3223 for (i
=0; i
<infoPtr
->uNumBands
; i
++) {
3224 band
= &infoPtr
->bands
[i
];
3225 if (HIDDENBAND(band
)) continue;
3226 if (band
->iRow
== lpBand
->iRow
) {
3228 if (imindBand
== -1) imindBand
= i
;
3232 /* if the selected band is first in row then need to expand */
3233 /* next visible band */
3234 if (imindBand
== uBand
) {
3236 movement
= -movement
;
3237 /* find the first visible band to the right of the selected band */
3238 for (i
=uBand
+1; i
<=imaxdBand
; i
++) {
3239 band
= &infoPtr
->bands
[i
];
3240 if (!HIDDENBAND(band
)) {
3242 LEADJ(band
, movement
);
3243 band
->ccx
= rcBw(band
);
3247 /* what case is this */
3248 if (iprevBand
== -1) {
3249 ERR("no previous visible band\n");
3253 endBand
= iprevBand
;
3255 lpBand
->rcBand
.left
,
3258 band
->rcBand
.bottom
);
3260 /* otherwise expand previous visible band */
3263 /* find the first visible band to the left of the selected band */
3264 for (i
=uBand
-1; i
>=imindBand
; i
--) {
3265 band
= &infoPtr
->bands
[i
];
3266 if (!HIDDENBAND(band
)) {
3268 READJ(band
, movement
);
3269 band
->ccx
= rcBw(band
);
3273 /* what case is this */
3274 if (iprevBand
== -1) {
3275 ERR("no previous visible band\n");
3278 startBand
= iprevBand
;
3283 lpBand
->rcBand
.right
,
3284 lpBand
->rcBand
.bottom
);
3287 REBAR_Shrink (infoPtr
, lpBand
, movement
, uBand
);
3289 /* recompute all rectangles */
3290 if (infoPtr
->dwStyle
& CCS_VERT
) {
3291 REBAR_CalcVertBand (infoPtr
, startBand
, endBand
+1,
3295 REBAR_CalcHorzBand (infoPtr
, startBand
, endBand
+1,
3299 TRACE("bands after minimize, see band # %d, %d\n",
3300 startBand
, endBand
);
3301 REBAR_DumpBand (infoPtr
);
3303 REBAR_MoveChildWindows (infoPtr
, startBand
, endBand
+1);
3305 InvalidateRect (infoPtr
->hwndSelf
, &newrect
, TRUE
);
3306 UpdateWindow (infoPtr
->hwndSelf
);
3312 REBAR_MoveBand (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
3314 REBAR_BAND
*oldBands
= infoPtr
->bands
;
3316 UINT uFrom
= (UINT
)wParam
;
3317 UINT uTo
= (UINT
)lParam
;
3320 if ((infoPtr
->uNumBands
== 0) ||
3321 ((INT
)uFrom
< 0) || (uFrom
>= infoPtr
->uNumBands
) ||
3322 ((INT
)uTo
< 0) || (uTo
>= infoPtr
->uNumBands
)) {
3324 ERR("Illegal MoveBand, from=%d, to=%d, current band count=%d\n",
3325 (INT
)uFrom
, (INT
)uTo
, infoPtr
->uNumBands
);
3329 /* save one to be moved */
3330 memcpy (&holder
, &oldBands
[uFrom
], sizeof(REBAR_BAND
));
3332 /* close up rest of bands (psuedo delete) */
3333 if (uFrom
< infoPtr
->uNumBands
- 1) {
3334 memcpy (&oldBands
[uFrom
], &oldBands
[uFrom
+1],
3335 (infoPtr
->uNumBands
- uFrom
- 1) * sizeof(REBAR_BAND
));
3338 /* allocate new space and copy rest of bands into it */
3340 (REBAR_BAND
*)COMCTL32_Alloc ((infoPtr
->uNumBands
)*sizeof(REBAR_BAND
));
3342 /* pre insert copy */
3344 memcpy (&infoPtr
->bands
[0], &oldBands
[0],
3345 uTo
* sizeof(REBAR_BAND
));
3348 /* set moved band */
3349 memcpy (&infoPtr
->bands
[uTo
], &holder
, sizeof(REBAR_BAND
));
3352 if (uTo
< infoPtr
->uNumBands
- 1) {
3353 memcpy (&infoPtr
->bands
[uTo
+1], &oldBands
[uTo
],
3354 (infoPtr
->uNumBands
- uTo
- 1) * sizeof(REBAR_BAND
));
3357 COMCTL32_Free (oldBands
);
3359 TRACE("moved band %d to index %d\n", uFrom
, uTo
);
3360 REBAR_DumpBand (infoPtr
);
3362 infoPtr
->fStatus
|= BAND_NEEDS_LAYOUT
;
3363 /* **************************************************** */
3365 /* We do not do a REBAR_Layout here because the native */
3366 /* control does not do that. The actual layout and */
3367 /* repaint is done by the *next* real action, ex.: */
3368 /* RB_INSERTBAND, RB_DELETEBAND, RB_SIZETORECT, etc. */
3370 /* **************************************************** */
3377 REBAR_SetBandInfoA (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
3379 LPREBARBANDINFOA lprbbi
= (LPREBARBANDINFOA
)lParam
;
3384 if (lprbbi
->cbSize
< REBARBANDINFO_V3_SIZEA
)
3386 if ((UINT
)wParam
>= infoPtr
->uNumBands
)
3389 TRACE("index %u\n", (UINT
)wParam
);
3390 REBAR_DumpBandInfo (lprbbi
);
3392 /* set band information */
3393 lpBand
= &infoPtr
->bands
[(UINT
)wParam
];
3395 REBAR_CommonSetupBand (infoPtr
->hwndSelf
, lprbbi
, lpBand
);
3396 if (lprbbi
->fMask
& RBBIM_TEXT
) {
3397 if (lpBand
->lpText
) {
3398 COMCTL32_Free (lpBand
->lpText
);
3399 lpBand
->lpText
= NULL
;
3401 if (lprbbi
->lpText
) {
3402 INT len
= MultiByteToWideChar( CP_ACP
, 0, lprbbi
->lpText
, -1, NULL
, 0 );
3403 lpBand
->lpText
= (LPWSTR
)COMCTL32_Alloc (len
*sizeof(WCHAR
));
3404 MultiByteToWideChar( CP_ACP
, 0, lprbbi
->lpText
, -1, lpBand
->lpText
, len
);
3408 REBAR_ValidateBand (infoPtr
, lpBand
);
3410 REBAR_DumpBand (infoPtr
);
3412 if (lprbbi
->fMask
& (RBBIM_CHILDSIZE
| RBBIM_SIZE
)) {
3413 REBAR_Layout (infoPtr
, NULL
, TRUE
, FALSE
);
3414 InvalidateRect(infoPtr
->hwndSelf
, 0, 1);
3422 REBAR_SetBandInfoW (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
3424 LPREBARBANDINFOW lprbbi
= (LPREBARBANDINFOW
)lParam
;
3429 if (lprbbi
->cbSize
< REBARBANDINFO_V3_SIZEW
)
3431 if ((UINT
)wParam
>= infoPtr
->uNumBands
)
3434 TRACE("index %u\n", (UINT
)wParam
);
3435 REBAR_DumpBandInfo ((LPREBARBANDINFOA
)lprbbi
);
3437 /* set band information */
3438 lpBand
= &infoPtr
->bands
[(UINT
)wParam
];
3440 REBAR_CommonSetupBand (infoPtr
->hwndSelf
, (LPREBARBANDINFOA
)lprbbi
, lpBand
);
3441 if (lprbbi
->fMask
& RBBIM_TEXT
) {
3442 if (lpBand
->lpText
) {
3443 COMCTL32_Free (lpBand
->lpText
);
3444 lpBand
->lpText
= NULL
;
3446 if (lprbbi
->lpText
) {
3447 INT len
= lstrlenW (lprbbi
->lpText
);
3448 lpBand
->lpText
= (LPWSTR
)COMCTL32_Alloc ((len
+ 1)*sizeof(WCHAR
));
3449 strcpyW (lpBand
->lpText
, lprbbi
->lpText
);
3453 REBAR_ValidateBand (infoPtr
, lpBand
);
3455 REBAR_DumpBand (infoPtr
);
3457 if (lprbbi
->fMask
& (RBBIM_CHILDSIZE
| RBBIM_SIZE
)) {
3458 REBAR_Layout (infoPtr
, NULL
, TRUE
, FALSE
);
3459 InvalidateRect(infoPtr
->hwndSelf
, 0, 1);
3467 REBAR_SetBarInfo (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
3469 LPREBARINFO lpInfo
= (LPREBARINFO
)lParam
;
3476 if (lpInfo
->cbSize
< sizeof (REBARINFO
))
3479 TRACE("setting bar info!\n");
3481 if (lpInfo
->fMask
& RBIM_IMAGELIST
) {
3482 infoPtr
->himl
= lpInfo
->himl
;
3483 if (infoPtr
->himl
) {
3485 ImageList_GetIconSize (infoPtr
->himl
, &cx
, &cy
);
3486 infoPtr
->imageSize
.cx
= cx
;
3487 infoPtr
->imageSize
.cy
= cy
;
3490 infoPtr
->imageSize
.cx
= 0;
3491 infoPtr
->imageSize
.cy
= 0;
3493 TRACE("new image cx=%ld, cy=%ld\n", infoPtr
->imageSize
.cx
,
3494 infoPtr
->imageSize
.cy
);
3497 /* revalidate all bands to reset flags for images in headers of bands */
3498 for (i
=0; i
<infoPtr
->uNumBands
; i
++) {
3499 lpBand
= &infoPtr
->bands
[i
];
3500 REBAR_ValidateBand (infoPtr
, lpBand
);
3508 REBAR_SetBkColor (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
3512 clrTemp
= infoPtr
->clrBk
;
3513 infoPtr
->clrBk
= (COLORREF
)lParam
;
3515 TRACE("background color 0x%06lx!\n", infoPtr
->clrBk
);
3521 /* << REBAR_SetColorScheme >> */
3522 /* << REBAR_SetPalette >> */
3526 REBAR_SetParent (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
3528 HWND hwndTemp
= infoPtr
->hwndNotify
;
3530 infoPtr
->hwndNotify
= (HWND
)wParam
;
3532 return (LRESULT
)hwndTemp
;
3537 REBAR_SetTextColor (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
3541 clrTemp
= infoPtr
->clrText
;
3542 infoPtr
->clrText
= (COLORREF
)lParam
;
3544 TRACE("text color 0x%06lx!\n", infoPtr
->clrText
);
3550 /* << REBAR_SetTooltips >> */
3553 inline static LRESULT
3554 REBAR_SetUnicodeFormat (REBAR_INFO
*infoPtr
, WPARAM wParam
)
3556 BOOL bTemp
= infoPtr
->bUnicode
;
3558 TRACE("to %s hwnd=%p, was %s\n",
3559 ((BOOL
)wParam
) ? "TRUE" : "FALSE", infoPtr
->hwndSelf
,
3560 (bTemp
) ? "TRUE" : "FALSE");
3562 infoPtr
->bUnicode
= (BOOL
)wParam
;
3569 REBAR_SetVersion (REBAR_INFO
*infoPtr
, INT iVersion
)
3571 INT iOldVersion
= infoPtr
->iVersion
;
3573 if (iVersion
> COMCTL32_VERSION
)
3576 infoPtr
->iVersion
= iVersion
;
3578 TRACE("new version %d\n", iVersion
);
3585 REBAR_ShowBand (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
3589 if (((INT
)wParam
< 0) || ((INT
)wParam
> infoPtr
->uNumBands
))
3592 lpBand
= &infoPtr
->bands
[(INT
)wParam
];
3595 TRACE("show band %d\n", (INT
)wParam
);
3596 lpBand
->fStyle
= lpBand
->fStyle
& ~RBBS_HIDDEN
;
3597 if (IsWindow (lpBand
->hwndChild
))
3598 ShowWindow (lpBand
->hwndChild
, SW_SHOW
);
3601 TRACE("hide band %d\n", (INT
)wParam
);
3602 lpBand
->fStyle
= lpBand
->fStyle
| RBBS_HIDDEN
;
3603 if (IsWindow (lpBand
->hwndChild
))
3604 ShowWindow (lpBand
->hwndChild
, SW_HIDE
);
3607 REBAR_Layout (infoPtr
, NULL
, TRUE
, FALSE
);
3608 InvalidateRect(infoPtr
->hwndSelf
, 0, 1);
3615 REBAR_SizeToRect (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
3617 LPRECT lpRect
= (LPRECT
)lParam
;
3623 TRACE("[%d %d %d %d]\n",
3624 lpRect
->left
, lpRect
->top
, lpRect
->right
, lpRect
->bottom
);
3626 /* what is going on???? */
3627 GetWindowRect(infoPtr
->hwndSelf
, &t1
);
3628 TRACE("window rect [%d %d %d %d]\n",
3629 t1
.left
, t1
.top
, t1
.right
, t1
.bottom
);
3630 GetClientRect(infoPtr
->hwndSelf
, &t1
);
3631 TRACE("client rect [%d %d %d %d]\n",
3632 t1
.left
, t1
.top
, t1
.right
, t1
.bottom
);
3634 /* force full _Layout processing */
3635 TRACE("setting NEEDS_LAYOUT\n");
3636 infoPtr
->fStatus
|= BAND_NEEDS_LAYOUT
;
3637 REBAR_Layout (infoPtr
, lpRect
, TRUE
, FALSE
);
3638 InvalidateRect (infoPtr
->hwndSelf
, NULL
, TRUE
);
3645 REBAR_Create (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
3647 LPCREATESTRUCTA cs
= (LPCREATESTRUCTA
) lParam
;
3650 if (TRACE_ON(rebar
)) {
3651 GetWindowRect(infoPtr
->hwndSelf
, &wnrc1
);
3652 GetClientRect(infoPtr
->hwndSelf
, &clrc1
);
3653 TRACE("window=(%d,%d)-(%d,%d) client=(%d,%d)-(%d,%d) cs=(%d,%d %dx%d)\n",
3654 wnrc1
.left
, wnrc1
.top
, wnrc1
.right
, wnrc1
.bottom
,
3655 clrc1
.left
, clrc1
.top
, clrc1
.right
, clrc1
.bottom
,
3656 cs
->x
, cs
->y
, cs
->cx
, cs
->cy
);
3659 TRACE("created!\n");
3665 REBAR_Destroy (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
3671 /* free rebar bands */
3672 if ((infoPtr
->uNumBands
> 0) && infoPtr
->bands
) {
3673 /* clean up each band */
3674 for (i
= 0; i
< infoPtr
->uNumBands
; i
++) {
3675 lpBand
= &infoPtr
->bands
[i
];
3677 /* delete text strings */
3678 if (lpBand
->lpText
) {
3679 COMCTL32_Free (lpBand
->lpText
);
3680 lpBand
->lpText
= NULL
;
3682 /* destroy child window */
3683 DestroyWindow (lpBand
->hwndChild
);
3686 /* free band array */
3687 COMCTL32_Free (infoPtr
->bands
);
3688 infoPtr
->bands
= NULL
;
3691 DeleteObject (infoPtr
->hcurArrow
);
3692 DeleteObject (infoPtr
->hcurHorz
);
3693 DeleteObject (infoPtr
->hcurVert
);
3694 DeleteObject (infoPtr
->hcurDrag
);
3695 if(infoPtr
->hDefaultFont
) DeleteObject (infoPtr
->hDefaultFont
);
3696 SetWindowLongA (infoPtr
->hwndSelf
, 0, 0);
3698 /* free rebar info data */
3699 COMCTL32_Free (infoPtr
);
3700 TRACE("destroyed!\n");
3706 REBAR_EraseBkGnd (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
3710 if (GetClipBox ( (HDC
)wParam
, &cliprect
))
3711 return REBAR_InternalEraseBkGnd (infoPtr
, wParam
, lParam
, &cliprect
);
3717 REBAR_GetFont (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
3719 return (LRESULT
)infoPtr
->hFont
;
3724 REBAR_LButtonDown (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
3728 /* If InternalHitTest did not find a hit on the Gripper, */
3729 /* then ignore the button click. */
3730 if (infoPtr
->ihitBand
== -1) return 0;
3732 SetCapture (infoPtr
->hwndSelf
);
3734 /* save off the LOWORD and HIWORD of lParam as initial x,y */
3735 lpBand
= &infoPtr
->bands
[infoPtr
->ihitBand
];
3736 infoPtr
->dragStart
= MAKEPOINTS(lParam
);
3737 infoPtr
->dragNow
= infoPtr
->dragStart
;
3738 if (infoPtr
->dwStyle
& CCS_VERT
)
3739 infoPtr
->ihitoffset
= infoPtr
->dragStart
.y
- (lpBand
->rcBand
.top
+REBAR_PRE_GRIPPER
);
3741 infoPtr
->ihitoffset
= infoPtr
->dragStart
.x
- (lpBand
->rcBand
.left
+REBAR_PRE_GRIPPER
);
3748 REBAR_LButtonUp (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
3754 /* If InternalHitTest did not find a hit on the Gripper, */
3755 /* then ignore the button click. */
3756 if (infoPtr
->ihitBand
== -1) return 0;
3758 ihitBand
= infoPtr
->ihitBand
;
3759 infoPtr
->dragStart
.x
= 0;
3760 infoPtr
->dragStart
.y
= 0;
3761 infoPtr
->dragNow
= infoPtr
->dragStart
;
3762 infoPtr
->ihitBand
= -1;
3766 if (infoPtr
->fStatus
& BEGIN_DRAG_ISSUED
) {
3767 REBAR_Notify((NMHDR
*) &layout
, infoPtr
, RBN_LAYOUTCHANGED
);
3768 REBAR_Notify_NMREBAR (infoPtr
, ihitBand
, RBN_ENDDRAG
);
3769 infoPtr
->fStatus
&= ~BEGIN_DRAG_ISSUED
;
3772 GetClientRect(infoPtr
->hwndSelf
, &rect
);
3773 InvalidateRect(infoPtr
->hwndSelf
, NULL
, TRUE
);
3780 REBAR_MouseMove (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
3782 REBAR_BAND
*band1
, *band2
;
3785 /* Validate entry as hit on Gripper has occurred */
3786 if (GetCapture() != infoPtr
->hwndSelf
) return 0;
3787 if (infoPtr
->ihitBand
== -1) return 0;
3789 ptsmove
= MAKEPOINTS(lParam
);
3791 /* if mouse did not move much, exit */
3792 if ((abs(ptsmove
.x
- infoPtr
->dragNow
.x
) <= mindragx
) &&
3793 (abs(ptsmove
.y
- infoPtr
->dragNow
.y
) <= mindragy
)) return 0;
3795 band1
= &infoPtr
->bands
[infoPtr
->ihitBand
-1];
3796 band2
= &infoPtr
->bands
[infoPtr
->ihitBand
];
3798 /* Test for valid drag case - must not be first band in row */
3799 if (infoPtr
->dwStyle
& CCS_VERT
) {
3800 if ((ptsmove
.x
< band2
->rcBand
.left
) ||
3801 (ptsmove
.x
> band2
->rcBand
.right
) ||
3802 ((infoPtr
->ihitBand
> 0) && (band1
->iRow
!= band2
->iRow
))) {
3803 FIXME("Cannot drag to other rows yet!!\n");
3806 REBAR_HandleLRDrag (infoPtr
, &ptsmove
);
3810 if ((ptsmove
.y
< band2
->rcBand
.top
) ||
3811 (ptsmove
.y
> band2
->rcBand
.bottom
) ||
3812 ((infoPtr
->ihitBand
> 0) && (band1
->iRow
!= band2
->iRow
))) {
3813 FIXME("Cannot drag to other rows yet!!\n");
3816 REBAR_HandleLRDrag (infoPtr
, &ptsmove
);
3823 inline static LRESULT
3824 REBAR_NCCalcSize (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
3826 if (infoPtr
->dwStyle
& WS_BORDER
) {
3827 InflateRect((LPRECT
)lParam
, -GetSystemMetrics(SM_CXEDGE
),
3828 -GetSystemMetrics(SM_CYEDGE
));
3830 TRACE("new client=(%d,%d)-(%d,%d)\n",
3831 ((LPRECT
)lParam
)->left
, ((LPRECT
)lParam
)->top
,
3832 ((LPRECT
)lParam
)->right
, ((LPRECT
)lParam
)->bottom
);
3838 REBAR_NCCreate (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3840 LPCREATESTRUCTA cs
= (LPCREATESTRUCTA
) lParam
;
3841 REBAR_INFO
*infoPtr
= REBAR_GetInfoPtr (hwnd
);
3843 NONCLIENTMETRICSA ncm
;
3847 if (infoPtr
!= NULL
) {
3848 ERR("Strange info structure pointer *not* NULL\n");
3852 if (TRACE_ON(rebar
)) {
3853 GetWindowRect(hwnd
, &wnrc1
);
3854 GetClientRect(hwnd
, &clrc1
);
3855 TRACE("window=(%d,%d)-(%d,%d) client=(%d,%d)-(%d,%d) cs=(%d,%d %dx%d)\n",
3856 wnrc1
.left
, wnrc1
.top
, wnrc1
.right
, wnrc1
.bottom
,
3857 clrc1
.left
, clrc1
.top
, clrc1
.right
, clrc1
.bottom
,
3858 cs
->x
, cs
->y
, cs
->cx
, cs
->cy
);
3861 /* allocate memory for info structure */
3862 infoPtr
= (REBAR_INFO
*)COMCTL32_Alloc (sizeof(REBAR_INFO
));
3863 SetWindowLongA (hwnd
, 0, (DWORD
)infoPtr
);
3865 /* initialize info structure - initial values are 0 */
3866 infoPtr
->clrBk
= CLR_NONE
;
3867 infoPtr
->clrText
= CLR_NONE
;
3868 infoPtr
->clrBtnText
= GetSysColor (COLOR_BTNTEXT
);
3869 infoPtr
->clrBtnFace
= GetSysColor (COLOR_BTNFACE
);
3870 infoPtr
->ihitBand
= -1;
3871 infoPtr
->hwndSelf
= hwnd
;
3872 infoPtr
->DoRedraw
= TRUE
;
3873 infoPtr
->hcurArrow
= LoadCursorA (0, IDC_ARROWA
);
3874 infoPtr
->hcurHorz
= LoadCursorA (0, IDC_SIZEWEA
);
3875 infoPtr
->hcurVert
= LoadCursorA (0, IDC_SIZENSA
);
3876 infoPtr
->hcurDrag
= LoadCursorA (0, IDC_SIZEA
);
3877 infoPtr
->bUnicode
= IsWindowUnicode (hwnd
);
3878 infoPtr
->fStatus
= CREATE_RUNNING
;
3879 infoPtr
->hFont
= GetStockObject (SYSTEM_FONT
);
3881 /* issue WM_NOTIFYFORMAT to get unicode status of parent */
3882 i
= SendMessageA(REBAR_GetNotifyParent (infoPtr
),
3883 WM_NOTIFYFORMAT
, (WPARAM
)hwnd
, NF_QUERY
);
3884 if ((i
< NFR_ANSI
) || (i
> NFR_UNICODE
)) {
3885 ERR("wrong response to WM_NOTIFYFORMAT (%d), assuming ANSI\n",
3889 infoPtr
->NtfUnicode
= (i
== NFR_UNICODE
) ? 1 : 0;
3891 /* add necessary styles to the requested styles */
3892 infoPtr
->dwStyle
= cs
->style
| WS_VISIBLE
| CCS_TOP
;
3893 SetWindowLongA (hwnd
, GWL_STYLE
, infoPtr
->dwStyle
);
3895 /* get font handle for Caption Font */
3896 ncm
.cbSize
= sizeof(NONCLIENTMETRICSA
);
3897 SystemParametersInfoA (SPI_GETNONCLIENTMETRICS
,
3898 ncm
.cbSize
, &ncm
, 0);
3899 /* if the font is bold, set to normal */
3900 if (ncm
.lfCaptionFont
.lfWeight
> FW_NORMAL
) {
3901 ncm
.lfCaptionFont
.lfWeight
= FW_NORMAL
;
3903 tfont
= CreateFontIndirectA (&ncm
.lfCaptionFont
);
3905 infoPtr
->hFont
= infoPtr
->hDefaultFont
= tfont
;
3909 GetSysColor (numerous);
3910 GetSysColorBrush (numerous) (see WM_SYSCOLORCHANGE);
3911 *GetStockObject (SYSTEM_FONT);
3912 *SetWindowLong (hwnd, 0, info ptr);
3914 *SetWindowLong (hwnd, GWL_STYLE, style+0x10000001);
3915 WS_VISIBLE = 0x10000000;
3916 CCS_TOP = 0x00000001;
3917 *SystemParametersInfo (SPI_GETNONCLIENTMETRICS...);
3918 *CreateFontIndirect (lfCaptionFont from above);
3920 SelectObject (hdc, fontabove);
3921 GetTextMetrics (hdc, ); guessing is tmHeight
3922 SelectObject (hdc, oldfont);
3925 MapWindowPoints (0, parent, rectabove, 2);
3928 ClientToScreen (clientrect);
3929 SetWindowPos (hwnd, 0, 0, 0, 0, 0, SWP_NOZORDER);
3936 REBAR_NCHitTest (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
3943 LRESULT ret
= HTCLIENT
;
3946 * Differences from doc at MSDN (as observed with version 4.71 of
3948 * 1. doc says nmmouse.pt is in screen coord, trace shows client coord.
3949 * 2. if band is not identified .dwItemSpec is 0xffffffff.
3950 * 3. native always seems to return HTCLIENT if notify return is 0.
3953 shortpt
= MAKEPOINTS (lParam
);
3954 POINTSTOPOINT(pt
, shortpt
);
3956 ScreenToClient (infoPtr
->hwndSelf
, &clpt
);
3957 REBAR_InternalHitTest (infoPtr
, &clpt
, &scrap
,
3958 (INT
*)&nmmouse
.dwItemSpec
);
3959 nmmouse
.dwItemData
= 0;
3961 nmmouse
.dwHitInfo
= 0;
3962 if ((i
= REBAR_Notify((NMHDR
*) &nmmouse
, infoPtr
, NM_NCHITTEST
))) {
3963 TRACE("notify changed return value from %ld to %d\n",
3967 TRACE("returning %ld, client point (%ld,%ld)\n", ret
, clpt
.x
, clpt
.y
);
3973 REBAR_NCPaint (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
3978 if (infoPtr
->dwStyle
& WS_MINIMIZE
)
3979 return 0; /* Nothing to do */
3981 if (infoPtr
->dwStyle
& WS_BORDER
) {
3983 /* adjust rectangle and draw the necessary edge */
3984 if (!(hdc
= GetDCEx( infoPtr
->hwndSelf
, 0, DCX_USESTYLE
| DCX_WINDOW
)))
3986 GetWindowRect (infoPtr
->hwndSelf
, &rcWindow
);
3987 OffsetRect (&rcWindow
, -rcWindow
.left
, -rcWindow
.top
);
3988 TRACE("rect (%d,%d)-(%d,%d)\n",
3989 rcWindow
.left
, rcWindow
.top
,
3990 rcWindow
.right
, rcWindow
.bottom
);
3991 DrawEdge (hdc
, &rcWindow
, EDGE_ETCHED
, BF_RECT
);
3992 ReleaseDC( infoPtr
->hwndSelf
, hdc
);
4000 REBAR_NotifyFormat (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
4004 if (lParam
== NF_REQUERY
) {
4005 i
= SendMessageA(REBAR_GetNotifyParent (infoPtr
),
4006 WM_NOTIFYFORMAT
, (WPARAM
)infoPtr
->hwndSelf
, NF_QUERY
);
4007 if ((i
< NFR_ANSI
) || (i
> NFR_UNICODE
)) {
4008 ERR("wrong response to WM_NOTIFYFORMAT (%d), assuming ANSI\n",
4012 infoPtr
->NtfUnicode
= (i
== NFR_UNICODE
) ? 1 : 0;
4015 return (LRESULT
)((infoPtr
->bUnicode
) ? NFR_UNICODE
: NFR_ANSI
);
4020 REBAR_Paint (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
4026 GetClientRect(infoPtr
->hwndSelf
, &rc
);
4027 hdc
= wParam
==0 ? BeginPaint (infoPtr
->hwndSelf
, &ps
) : (HDC
)wParam
;
4029 TRACE("painting (%d,%d)-(%d,%d) client (%d,%d)-(%d,%d)\n",
4030 ps
.rcPaint
.left
, ps
.rcPaint
.top
,
4031 ps
.rcPaint
.right
, ps
.rcPaint
.bottom
,
4032 rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
4035 /* Erase area of paint if requested */
4036 REBAR_InternalEraseBkGnd (infoPtr
, wParam
, lParam
, &ps
.rcPaint
);
4039 REBAR_Refresh (infoPtr
, hdc
);
4041 EndPaint (infoPtr
->hwndSelf
, &ps
);
4047 REBAR_SetCursor (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
4052 TRACE("code=0x%X id=0x%X\n", LOWORD(lParam
), HIWORD(lParam
));
4055 ScreenToClient (infoPtr
->hwndSelf
, &pt
);
4057 REBAR_InternalHitTest (infoPtr
, &pt
, &flags
, NULL
);
4059 if (flags
== RBHT_GRABBER
) {
4060 if ((infoPtr
->dwStyle
& CCS_VERT
) &&
4061 !(infoPtr
->dwStyle
& RBS_VERTICALGRIPPER
))
4062 SetCursor (infoPtr
->hcurVert
);
4064 SetCursor (infoPtr
->hcurHorz
);
4066 else if (flags
!= RBHT_CLIENT
)
4067 SetCursor (infoPtr
->hcurArrow
);
4074 REBAR_SetFont (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
4080 infoPtr
->hFont
= (HFONT
)wParam
;
4082 /* revalidate all bands to change sizes of text in headers of bands */
4083 for (i
=0; i
<infoPtr
->uNumBands
; i
++) {
4084 lpBand
= &infoPtr
->bands
[i
];
4085 REBAR_ValidateBand (infoPtr
, lpBand
);
4089 if (LOWORD(lParam
)) {
4090 GetClientRect (infoPtr
->hwndSelf
, &rcClient
);
4091 REBAR_Layout (infoPtr
, &rcClient
, FALSE
, TRUE
);
4098 inline static LRESULT
4099 REBAR_SetRedraw (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
4100 /*****************************************************
4103 * Handles the WM_SETREDRAW message.
4106 * According to testing V4.71 of COMCTL32 returns the
4107 * *previous* status of the redraw flag (either 0 or -1)
4108 * instead of the MSDN documented value of 0 if handled
4110 *****************************************************/
4112 BOOL oldredraw
= infoPtr
->DoRedraw
;
4114 TRACE("set to %s, fStatus=%08x\n",
4115 (wParam
) ? "TRUE" : "FALSE", infoPtr
->fStatus
);
4116 infoPtr
->DoRedraw
= (BOOL
) wParam
;
4118 if (infoPtr
->fStatus
& BAND_NEEDS_REDRAW
) {
4119 REBAR_MoveChildWindows (infoPtr
, 0, infoPtr
->uNumBands
);
4120 REBAR_ForceResize (infoPtr
);
4121 InvalidateRect (infoPtr
->hwndSelf
, 0, TRUE
);
4123 infoPtr
->fStatus
&= ~BAND_NEEDS_REDRAW
;
4125 return (oldredraw
) ? -1 : 0;
4130 REBAR_Size (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
4134 /* auto resize deadlock check */
4135 if (infoPtr
->fStatus
& AUTO_RESIZE
) {
4136 infoPtr
->fStatus
&= ~AUTO_RESIZE
;
4137 TRACE("AUTO_RESIZE was set, reset, fStatus=%08x lparam=%08lx\n",
4138 infoPtr
->fStatus
, lParam
);
4142 if (infoPtr
->fStatus
& CREATE_RUNNING
) {
4143 /* still in CreateWindow */
4146 if ((INT
)wParam
!= SIZE_RESTORED
) {
4147 ERR("WM_SIZE in create and flags=%08x, lParam=%08lx\n",
4151 TRACE("still in CreateWindow\n");
4152 infoPtr
->fStatus
&= ~CREATE_RUNNING
;
4153 GetWindowRect ( infoPtr
->hwndSelf
, &rcWin
);
4154 TRACE("win rect (%d,%d)-(%d,%d)\n",
4155 rcWin
.left
, rcWin
.top
, rcWin
.right
, rcWin
.bottom
);
4157 if ((lParam
== 0) && (rcWin
.right
-rcWin
.left
== 0) &&
4158 (rcWin
.bottom
-rcWin
.top
== 0)) {
4159 /* native control seems to do this */
4160 GetClientRect (GetParent(infoPtr
->hwndSelf
), &rcClient
);
4161 TRACE("sizing rebar, message and client zero, parent client (%d,%d)\n",
4162 rcClient
.right
, rcClient
.bottom
);
4167 cx
= rcWin
.right
- rcWin
.left
;
4168 cy
= rcWin
.bottom
- rcWin
.top
;
4169 if ((cx
== LOWORD(lParam
)) && (cy
== HIWORD(lParam
))) {
4173 /* do the actual WM_SIZE request */
4174 GetClientRect (infoPtr
->hwndSelf
, &rcClient
);
4175 TRACE("sizing rebar from (%ld,%ld) to (%d,%d), client (%d,%d)\n",
4176 infoPtr
->calcSize
.cx
, infoPtr
->calcSize
.cy
,
4177 LOWORD(lParam
), HIWORD(lParam
),
4178 rcClient
.right
, rcClient
.bottom
);
4182 if ((INT
)wParam
!= SIZE_RESTORED
) {
4183 ERR("WM_SIZE out of create and flags=%08x, lParam=%08lx\n",
4187 /* Handle cases when outside of the CreateWindow process */
4189 GetClientRect (infoPtr
->hwndSelf
, &rcClient
);
4190 if ((lParam
== 0) && (rcClient
.right
+ rcClient
.bottom
!= 0) &&
4191 (infoPtr
->dwStyle
& RBS_AUTOSIZE
)) {
4192 /* on a WM_SIZE to zero and current client not zero and AUTOSIZE */
4193 /* native seems to use the current client rect for the size */
4194 infoPtr
->fStatus
|= BAND_NEEDS_LAYOUT
;
4195 TRACE("sizing rebar to client (%d,%d) size is zero but AUTOSIZE set\n",
4196 rcClient
.right
, rcClient
.bottom
);
4199 TRACE("sizing rebar from (%ld,%ld) to (%d,%d), client (%d,%d)\n",
4200 infoPtr
->calcSize
.cx
, infoPtr
->calcSize
.cy
,
4201 LOWORD(lParam
), HIWORD(lParam
),
4202 rcClient
.right
, rcClient
.bottom
);
4206 if (infoPtr
->dwStyle
& RBS_AUTOSIZE
) {
4207 NMRBAUTOSIZE autosize
;
4209 GetClientRect(infoPtr
->hwndSelf
, &autosize
.rcTarget
);
4210 autosize
.fChanged
= 0; /* ??? */
4211 autosize
.rcActual
= autosize
.rcTarget
; /* ??? */
4212 REBAR_Notify((NMHDR
*) &autosize
, infoPtr
, RBN_AUTOSIZE
);
4213 TRACE("RBN_AUTOSIZE client=(%d,%d), lp=%08lx\n",
4214 autosize
.rcTarget
.right
, autosize
.rcTarget
.bottom
, lParam
);
4217 if ((infoPtr
->calcSize
.cx
!= rcClient
.right
) ||
4218 (infoPtr
->calcSize
.cy
!= rcClient
.bottom
))
4219 infoPtr
->fStatus
|= BAND_NEEDS_LAYOUT
;
4221 REBAR_Layout (infoPtr
, &rcClient
, TRUE
, TRUE
);
4222 infoPtr
->fStatus
&= ~AUTO_RESIZE
;
4229 REBAR_StyleChanged (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
4231 STYLESTRUCT
*ss
= (STYLESTRUCT
*)lParam
;
4233 TRACE("current style=%08lx, styleOld=%08lx, style being set to=%08lx\n",
4234 infoPtr
->dwStyle
, ss
->styleOld
, ss
->styleNew
);
4235 infoPtr
->dwStyle
= ss
->styleNew
;
4242 REBAR_WindowPosChanged (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
4244 WINDOWPOS
*lpwp
= (WINDOWPOS
*)lParam
;
4248 /* Save the new origin of this window - used by _ForceResize */
4249 infoPtr
->origin
.x
= lpwp
->x
;
4250 infoPtr
->origin
.y
= lpwp
->y
;
4251 ret
= DefWindowProcA(infoPtr
->hwndSelf
, WM_WINDOWPOSCHANGED
,
4253 GetWindowRect(infoPtr
->hwndSelf
, &rc
);
4254 TRACE("hwnd %p new pos (%d,%d)-(%d,%d)\n",
4255 infoPtr
->hwndSelf
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
4260 static LRESULT WINAPI
4261 REBAR_WindowProc (HWND hwnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
)
4263 REBAR_INFO
*infoPtr
= REBAR_GetInfoPtr (hwnd
);
4265 TRACE("hwnd=%p msg=%x wparam=%x lparam=%lx\n",
4266 hwnd
, uMsg
, wParam
, lParam
);
4267 if (!infoPtr
&& (uMsg
!= WM_NCCREATE
))
4268 return DefWindowProcA (hwnd
, uMsg
, wParam
, lParam
);
4271 /* case RB_BEGINDRAG: */
4274 return REBAR_DeleteBand (infoPtr
, wParam
, lParam
);
4276 /* case RB_DRAGMOVE: */
4277 /* case RB_ENDDRAG: */
4279 case RB_GETBANDBORDERS
:
4280 return REBAR_GetBandBorders (infoPtr
, wParam
, lParam
);
4282 case RB_GETBANDCOUNT
:
4283 return REBAR_GetBandCount (infoPtr
);
4285 case RB_GETBANDINFO
: /* obsoleted after IE3, but we have to
4286 support it anyway. */
4287 case RB_GETBANDINFOA
:
4288 return REBAR_GetBandInfoA (infoPtr
, wParam
, lParam
);
4290 case RB_GETBANDINFOW
:
4291 return REBAR_GetBandInfoW (infoPtr
, wParam
, lParam
);
4293 case RB_GETBARHEIGHT
:
4294 return REBAR_GetBarHeight (infoPtr
, wParam
, lParam
);
4297 return REBAR_GetBarInfo (infoPtr
, wParam
, lParam
);
4300 return REBAR_GetBkColor (infoPtr
);
4302 /* case RB_GETCOLORSCHEME: */
4303 /* case RB_GETDROPTARGET: */
4306 return REBAR_GetPalette (infoPtr
, wParam
, lParam
);
4309 return REBAR_GetRect (infoPtr
, wParam
, lParam
);
4311 case RB_GETROWCOUNT
:
4312 return REBAR_GetRowCount (infoPtr
);
4314 case RB_GETROWHEIGHT
:
4315 return REBAR_GetRowHeight (infoPtr
, wParam
, lParam
);
4317 case RB_GETTEXTCOLOR
:
4318 return REBAR_GetTextColor (infoPtr
);
4320 case RB_GETTOOLTIPS
:
4321 return REBAR_GetToolTips (infoPtr
);
4323 case RB_GETUNICODEFORMAT
:
4324 return REBAR_GetUnicodeFormat (infoPtr
);
4326 case CCM_GETVERSION
:
4327 return REBAR_GetVersion (infoPtr
);
4330 return REBAR_HitTest (infoPtr
, wParam
, lParam
);
4333 return REBAR_IdToIndex (infoPtr
, wParam
, lParam
);
4335 case RB_INSERTBANDA
:
4336 return REBAR_InsertBandA (infoPtr
, wParam
, lParam
);
4338 case RB_INSERTBANDW
:
4339 return REBAR_InsertBandW (infoPtr
, wParam
, lParam
);
4341 case RB_MAXIMIZEBAND
:
4342 return REBAR_MaximizeBand (infoPtr
, wParam
, lParam
);
4344 case RB_MINIMIZEBAND
:
4345 return REBAR_MinimizeBand (infoPtr
, wParam
, lParam
);
4348 return REBAR_MoveBand (infoPtr
, wParam
, lParam
);
4350 case RB_SETBANDINFOA
:
4351 return REBAR_SetBandInfoA (infoPtr
, wParam
, lParam
);
4353 case RB_SETBANDINFOW
:
4354 return REBAR_SetBandInfoW (infoPtr
, wParam
, lParam
);
4357 return REBAR_SetBarInfo (infoPtr
, wParam
, lParam
);
4360 return REBAR_SetBkColor (infoPtr
, wParam
, lParam
);
4362 /* case RB_SETCOLORSCHEME: */
4363 /* case RB_SETPALETTE: */
4364 /* return REBAR_GetPalette (infoPtr, wParam, lParam); */
4367 return REBAR_SetParent (infoPtr
, wParam
, lParam
);
4369 case RB_SETTEXTCOLOR
:
4370 return REBAR_SetTextColor (infoPtr
, wParam
, lParam
);
4372 /* case RB_SETTOOLTIPS: */
4374 case RB_SETUNICODEFORMAT
:
4375 return REBAR_SetUnicodeFormat (infoPtr
, wParam
);
4377 case CCM_SETVERSION
:
4378 return REBAR_SetVersion (infoPtr
, (INT
)wParam
);
4381 return REBAR_ShowBand (infoPtr
, wParam
, lParam
);
4384 return REBAR_SizeToRect (infoPtr
, wParam
, lParam
);
4387 /* Messages passed to parent */
4391 if (infoPtr
->NtfUnicode
)
4392 return SendMessageW (REBAR_GetNotifyParent (infoPtr
),
4393 uMsg
, wParam
, lParam
);
4395 return SendMessageA (REBAR_GetNotifyParent (infoPtr
),
4396 uMsg
, wParam
, lParam
);
4399 /* case WM_CHARTOITEM: supported according to ControlSpy */
4402 return REBAR_Create (infoPtr
, wParam
, lParam
);
4405 return REBAR_Destroy (infoPtr
, wParam
, lParam
);
4408 return REBAR_EraseBkGnd (infoPtr
, wParam
, lParam
);
4411 return REBAR_GetFont (infoPtr
, wParam
, lParam
);
4413 /* case WM_LBUTTONDBLCLK: supported according to ControlSpy */
4415 case WM_LBUTTONDOWN
:
4416 return REBAR_LButtonDown (infoPtr
, wParam
, lParam
);
4419 return REBAR_LButtonUp (infoPtr
, wParam
, lParam
);
4421 /* case WM_MEASUREITEM: supported according to ControlSpy */
4424 return REBAR_MouseMove (infoPtr
, wParam
, lParam
);
4427 return REBAR_NCCalcSize (infoPtr
, wParam
, lParam
);
4430 return REBAR_NCCreate (hwnd
, wParam
, lParam
);
4433 return REBAR_NCHitTest (infoPtr
, wParam
, lParam
);
4436 return REBAR_NCPaint (infoPtr
, wParam
, lParam
);
4438 case WM_NOTIFYFORMAT
:
4439 return REBAR_NotifyFormat (infoPtr
, wParam
, lParam
);
4442 return REBAR_Paint (infoPtr
, wParam
, lParam
);
4444 /* case WM_PALETTECHANGED: supported according to ControlSpy */
4445 /* case WM_PRINTCLIENT: supported according to ControlSpy */
4446 /* case WM_QUERYNEWPALETTE:supported according to ControlSpy */
4447 /* case WM_RBUTTONDOWN: supported according to ControlSpy */
4448 /* case WM_RBUTTONUP: supported according to ControlSpy */
4451 return REBAR_SetCursor (infoPtr
, wParam
, lParam
);
4454 return REBAR_SetFont (infoPtr
, wParam
, lParam
);
4457 return REBAR_SetRedraw (infoPtr
, wParam
, lParam
);
4460 return REBAR_Size (infoPtr
, wParam
, lParam
);
4462 case WM_STYLECHANGED
:
4463 return REBAR_StyleChanged (infoPtr
, wParam
, lParam
);
4465 /* case WM_SYSCOLORCHANGE: supported according to ControlSpy */
4466 /* "Applications that have brushes using the existing system colors
4467 should delete those brushes and recreate them using the new
4468 system colors." per MSDN */
4470 /* case WM_VKEYTOITEM: supported according to ControlSpy */
4471 /* case WM_WININICHANGE: */
4473 case WM_WINDOWPOSCHANGED
:
4474 return REBAR_WindowPosChanged (infoPtr
, wParam
, lParam
);
4477 if ((uMsg
>= WM_USER
) && (uMsg
< WM_APP
))
4478 ERR("unknown msg %04x wp=%08x lp=%08lx\n",
4479 uMsg
, wParam
, lParam
);
4480 return DefWindowProcA (hwnd
, uMsg
, wParam
, lParam
);
4487 REBAR_Register (void)
4491 ZeroMemory (&wndClass
, sizeof(WNDCLASSA
));
4492 wndClass
.style
= CS_GLOBALCLASS
| CS_DBLCLKS
;
4493 wndClass
.lpfnWndProc
= (WNDPROC
)REBAR_WindowProc
;
4494 wndClass
.cbClsExtra
= 0;
4495 wndClass
.cbWndExtra
= sizeof(REBAR_INFO
*);
4496 wndClass
.hCursor
= 0;
4497 wndClass
.hbrBackground
= (HBRUSH
)(COLOR_BTNFACE
+ 1);
4499 wndClass
.hbrBackground
= CreateSolidBrush(RGB(0,128,0));
4501 wndClass
.lpszClassName
= REBARCLASSNAMEA
;
4503 RegisterClassA (&wndClass
);
4505 mindragx
= GetSystemMetrics (SM_CXDRAG
);
4506 mindragy
= GetSystemMetrics (SM_CYDRAG
);
4512 REBAR_Unregister (void)
4514 UnregisterClassA (REBARCLASSNAMEA
, NULL
);