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 8b
25 * Copyright 1998, 1999 Eric Kohl
28 * An author is needed! Any volunteers?
29 * I will only improve this control once in a while.
30 * Eric <ekohl@abo.rhein-zeitung.de>
33 * - vertical placement
34 * - ComboBox and ComboBoxEx placement
39 * - All notifications.
41 * Changes Guy Albertelli <galberte@neo.lrun.com>
43 * - Implement initial version of row grouping, row separators,
44 * text and background colors. Support additional messages.
45 * Support RBBS_BREAK. Implement ERASEBKGND and improve painting.
47 * - implement support for dragging Gripper left or right in a row. Supports
48 * WM_LBUTTONDOWN, WM_LBUTTONUP, and WM_MOUSEMOVE. Also support
51 * - Fix or implement notifications for RBN_HEIGHTCHANGE, RBN_CHILDSIZE.
52 * - Correct styles RBBS_NOGRIPPER, RBBS_GRIPPERALWAYS, and RBBS_FIXEDSIZE.
53 * - Fix algorithm for Layout and AdjustBand.
56 * - Fix algorithm for _Layout and _AdjustBand.
57 * - Fix or implement RBN_ENDDRAG, RB_MOVEBAND, WM_SETREDRAW,
58 * WM_STYLECHANGED, RB_MINIMIZEBAND, RBBS_VARIABLEHEIGHT, RBS_VARHEIGHT,
59 * RBBS_HIDDEN, WM_NOTIFYFORMAT, NM_NCHITTEST, WM_SETREDRAW, RBS_AUTOSIZE,
60 * WM_SETFONT, RBS_BORDERS
61 * - Create structures in WM_NCCREATE
62 * - Additional performance enhancements.
65 * 1. Create array of start and end band indexes by row and use.
66 * 2. Fix problem with REBAR_Layout Phase 2b to process only if only
68 * 3. Set the Caption Font (Regular) as default font for text.
69 * 4. Delete font handle on control distruction.
70 * 5. Add UpdateWindow call in _MoveChildWindows to match repainting done
72 * 6. Improve some traces.
73 * 7. Invalidate window rectangles after SetBandInfo, InsertBand, ShowBand
74 * so that repainting is correct.
75 * 8. Implement RB_MAXIMIZEBAND for the "ideal=TRUE" case.
76 * 9. Implement item custom draw notifications partially. Only done for
77 * ITEMPREPAINT and ITEMPOSTPAINT. (Used by IE4 for "Favorites" frame
78 * to draw the word "Favorites").
80 * 10. Handle CCS_NODIVIDER and fix WS_BORDER code.
81 * 11. Fix logic error in _AdjustBands where flag was set to valid band
82 * number (0) to indicate *no* band.
83 * 12. Fix CCS_VERT errors in _ForceResize, _NCCalcSize, and _NCPaint.
84 * 13. Support some special cases of CCS_TOP (and therefore CCS_LEFT),
85 * CCS_BOTTOM (and therefore CCS_RIGHT) and CCS_NOPARENTALIGN. Not
86 * at all sure whether this is all cases.
87 * 14. Handle returned value for the RBN_CHILDSIZE notify.
88 * 15. Implement RBBS_CHILDEDGE, and set each bands "offChild" at _Layout
90 * 16. Fix REBARSPACE. It should depend on CCS_NODIVIDER.
92 * 17. Fix determination of whether Gripper is needed in _ValidateBand.
93 * 18. Fix _AdjustBand processing of RBBS_FIXEDSIZE.
95 * 19. Fix problem in _Layout when all lengths are 0.
99 * 2. Following still not handled: RBBS_FIXEDBMP,
100 * RBBS_USECHEVRON, CCS_NORESIZE,
101 * CCS_NOMOVEX, CCS_NOMOVEY
102 * 3. Following are only partially handled:
103 * RBS_AUTOSIZE, RBBS_VARIABLEHEIGHT
104 * 5. Native uses (on each draw!!) SM_CYBORDER (or SM_CXBORDER for CCS_VERT)
105 * to set the size of the separator width (the value SEP_WIDTH_SIZE
106 * in here). Should be fixed!!
107 * 6. The following messages are not implemented:
108 * RB_BEGINDRAG, RB_DRAGMOVE, RB_ENDDRAG, RB_GETCOLORSCHEME,
109 * RB_GETDROPTARGET, RB_MAXIMIZEBAND,
110 * RB_SETCOLORSCHEME, RB_SETPALETTE, RB_SETTOOLTIPS
111 * WM_CHARTOITEM, WM_LBUTTONDBLCLK, WM_MEASUREITEM,
112 * WM_PALETTECHANGED, WM_PRINTCLIENT, WM_QUERYNEWPALETTE,
113 * WM_RBUTTONDOWN, WM_RBUTTONUP,
114 * WM_SYSCOLORCHANGE, WM_VKEYTOITEM, WM_WININICHANGE
115 * 7. The following notifications are not implemented:
116 * NM_CUSTOMDRAW, NM_RELEASEDCAPTURE
117 * RB_CHEVRONPUSHED, RBN_MINMAX
125 #include "wine/unicode.h"
126 #include "commctrl.h"
127 /* #include "spy.h" */
128 #include "debugtools.h"
130 DEFAULT_DEBUG_CHANNEL(rebar
);
140 UINT cxMinChild
; /* valid if _CHILDSIZE */
141 UINT cyMinChild
; /* valid if _CHILDSIZE */
142 UINT cx
; /* valid if _SIZE */
145 UINT cyChild
; /* valid if _CHILDSIZE */
146 UINT cyMaxChild
; /* valid if _CHILDSIZE */
147 UINT cyIntegral
; /* valid if _CHILDSIZE */
152 UINT lcx
; /* minimum cx for band */
153 UINT ccx
; /* current cx for band */
154 UINT hcx
; /* maximum cx for band */
155 UINT lcy
; /* minimum cy for band */
156 UINT ccy
; /* current cy for band */
157 UINT hcy
; /* maximum cy for band */
159 SIZE offChild
; /* x,y offset if child is not FIXEDSIZE */
161 INT iRow
; /* row this band assigned to */
162 UINT fStatus
; /* status flags, reset only by _Validate */
163 UINT fDraw
; /* drawing flags, reset only by _Layout */
164 UINT uCDret
; /* last return from NM_CUSTOMDRAW */
165 RECT rcoldBand
; /* previous calculated band rectangle */
166 RECT rcBand
; /* calculated band rectangle */
167 RECT rcGripper
; /* calculated gripper rectangle */
168 RECT rcCapImage
; /* calculated caption image rectangle */
169 RECT rcCapText
; /* calculated caption text rectangle */
170 RECT rcChild
; /* calculated child rectangle */
177 #define HAS_GRIPPER 0x00000001
178 #define HAS_IMAGE 0x00000002
179 #define HAS_TEXT 0x00000004
182 #define DRAW_GRIPPER 0x00000001
183 #define DRAW_IMAGE 0x00000002
184 #define DRAW_TEXT 0x00000004
185 #define DRAW_RIGHTSEP 0x00000010
186 #define DRAW_BOTTOMSEP 0x00000020
187 #define NTF_INVALIDATE 0x01000000
191 INT istartband
; /* index of first band in row */
192 INT iendband
; /* index of last band in row */
198 COLORREF clrBk
; /* background color */
199 COLORREF clrText
; /* text color */
200 COLORREF clrBtnText
; /* system color for BTNTEXT */
201 COLORREF clrBtnFace
; /* system color for BTNFACE */
202 HIMAGELIST himl
; /* handle to imagelist */
203 UINT uNumBands
; /* # of bands in rebar (first=0, last=uNumBands-1 */
204 UINT uNumRows
; /* # of rows of bands (first=1, last=uNumRows */
205 HWND hwndSelf
; /* handle of REBAR window itself */
206 HWND hwndToolTip
; /* handle to the tool tip control */
207 HWND hwndNotify
; /* notification window (parent) */
209 HFONT hFont
; /* handle to the rebar's font */
210 SIZE imageSize
; /* image size (image list) */
211 DWORD dwStyle
; /* window style */
212 SIZE calcSize
; /* calculated rebar size */
213 SIZE oldSize
; /* previous calculated rebar size */
214 BOOL bUnicode
; /* TRUE if this window is W type */
215 BOOL NtfUnicode
; /* TRUE if parent wants notify in W format */
216 BOOL DoRedraw
; /* TRUE to acutally draw bands */
217 UINT fStatus
; /* Status flags (see below) */
218 HCURSOR hcurArrow
; /* handle to the arrow cursor */
219 HCURSOR hcurHorz
; /* handle to the EW cursor */
220 HCURSOR hcurVert
; /* handle to the NS cursor */
221 HCURSOR hcurDrag
; /* handle to the drag cursor */
222 INT iVersion
; /* version number */
223 POINTS dragStart
; /* x,y of button down */
224 POINTS dragNow
; /* x,y of this MouseMove */
225 INT ihitBand
; /* band number of band whose gripper was grabbed */
226 INT ihitoffset
; /* offset of hotspot from gripper.left */
228 REBAR_ROW
*rows
; /* pointer to row indexes */
229 REBAR_BAND
*bands
; /* pointer to the array of rebar bands */
233 #define BEGIN_DRAG_ISSUED 0x00000001
234 #define AUTO_RESIZE 0x00000002
235 #define RESIZE_ANYHOW 0x00000004
236 #define NTF_HGHTCHG 0x00000008
237 #define BAND_NEEDS_LAYOUT 0x00000010
238 #define BAND_NEEDS_REDRAW 0x00000020
239 #define CREATE_RUNNING 0x00000040
241 /* ---- REBAR layout constants. Mostly determined by ---- */
242 /* ---- experiment on WIN 98. ---- */
244 /* Width (or height) of separators between bands (either horz. or */
245 /* vert.). True only if RBS_BANDBORDERS is set */
246 #define SEP_WIDTH_SIZE 2
247 #define SEP_WIDTH ((infoPtr->dwStyle & RBS_BANDBORDERS) ? SEP_WIDTH_SIZE : 0)
249 /* Blank (background color) space between Gripper (if present) */
250 /* and next item (image, text, or window). Always present */
251 #define REBAR_ALWAYS_SPACE 4
253 /* Blank (background color) space after Image (if present). */
254 #define REBAR_POST_IMAGE 2
256 /* Blank (background color) space after Text (if present). */
257 #define REBAR_POST_TEXT 4
259 /* Height of vertical gripper in a CCS_VERT rebar. */
260 #define GRIPPER_HEIGHT 16
262 /* Blank (background color) space before Gripper (if present). */
263 #define REBAR_PRE_GRIPPER 2
265 /* Width (of normal vertical gripper) or height (of horz. gripper) */
267 #define GRIPPER_WIDTH 3
269 /* Height of divider for Rebar if not disabled (CCS_NODIVIDER) */
270 /* either top or bottom */
271 #define REBAR_DIVIDER 2
273 /* This is the increment that is used over the band height */
274 #define REBARSPACE(a) ((a->fStyle & RBBS_CHILDEDGE) ? 2*REBAR_DIVIDER : 0)
276 /* ---- End of REBAR layout constants. ---- */
279 /* The following 6 defines return the proper rcBand element */
280 /* depending on whether CCS_VERT was set. */
281 #define rcBlt(b) ((infoPtr->dwStyle & CCS_VERT) ? b->rcBand.top : b->rcBand.left)
282 #define rcBrb(b) ((infoPtr->dwStyle & CCS_VERT) ? b->rcBand.bottom : b->rcBand.right)
283 #define rcBw(b) ((infoPtr->dwStyle & CCS_VERT) ? (b->rcBand.bottom - b->rcBand.top) : \
284 (b->rcBand.right - b->rcBand.left))
285 #define ircBlt(b) ((infoPtr->dwStyle & CCS_VERT) ? b->rcBand.left : b->rcBand.top)
286 #define ircBrb(b) ((infoPtr->dwStyle & CCS_VERT) ? b->rcBand.right : b->rcBand.bottom)
287 #define ircBw(b) ((infoPtr->dwStyle & CCS_VERT) ? (b->rcBand.right - b->rcBand.left) : \
288 (b->rcBand.bottom - b->rcBand.top))
290 /* The following define determines if a given band is hidden */
291 #define HIDDENBAND(a) (((a)->fStyle & RBBS_HIDDEN) || \
292 ((infoPtr->dwStyle & CCS_VERT) && \
293 ((a)->fStyle & RBBS_NOVERT)))
295 /* The following defines adjust the right or left end of a rectangle */
296 #define READJ(b,i) {if(infoPtr->dwStyle & CCS_VERT) b->rcBand.bottom+=(i); \
297 else b->rcBand.right += (i);}
298 #define LEADJ(b,i) {if(infoPtr->dwStyle & CCS_VERT) b->rcBand.top+=(i); \
299 else b->rcBand.left += (i);}
302 #define REBAR_GetInfoPtr(wndPtr) ((REBAR_INFO *)GetWindowLongA (hwnd, 0))
305 /* "constant values" retrieved when DLL was initialized */
306 /* FIXME we do this when the classes are registered. */
307 static UINT mindragx
= 0;
308 static UINT mindragy
= 0;
310 static char *band_stylename
[] = {
311 "RBBS_BREAK", /* 0001 */
312 "RBBS_FIXEDSIZE", /* 0002 */
313 "RBBS_CHILDEDGE", /* 0004 */
314 "RBBS_HIDDEN", /* 0008 */
315 "RBBS_NOVERT", /* 0010 */
316 "RBBS_FIXEDBMP", /* 0020 */
317 "RBBS_VARIABLEHEIGHT", /* 0040 */
318 "RBBS_GRIPPERALWAYS", /* 0080 */
319 "RBBS_NOGRIPPER", /* 0100 */
322 static char *band_maskname
[] = {
323 "RBBIM_STYLE", /* 0x00000001 */
324 "RBBIM_COLORS", /* 0x00000002 */
325 "RBBIM_TEXT", /* 0x00000004 */
326 "RBBIM_IMAGE", /* 0x00000008 */
327 "RBBIM_CHILD", /* 0x00000010 */
328 "RBBIM_CHILDSIZE", /* 0x00000020 */
329 "RBBIM_SIZE", /* 0x00000040 */
330 "RBBIM_BACKGROUND", /* 0x00000080 */
331 "RBBIM_ID", /* 0x00000100 */
332 "RBBIM_IDEALSIZE", /* 0x00000200 */
333 "RBBIM_LPARAM", /* 0x00000400 */
334 "RBBIM_HEADERSIZE", /* 0x00000800 */
338 static CHAR line
[200];
342 REBAR_FmtStyle( UINT style
)
347 while (band_stylename
[i
]) {
348 if (style
& (1<<i
)) {
349 if (*line
!= 0) strcat(line
, " | ");
350 strcat(line
, band_stylename
[i
]);
359 REBAR_FmtMask( UINT mask
)
364 while (band_maskname
[i
]) {
366 if (*line
!= 0) strcat(line
, " | ");
367 strcat(line
, band_maskname
[i
]);
376 REBAR_DumpBandInfo( LPREBARBANDINFOA pB
)
378 if( !TRACE_ON(rebar
) ) return;
379 TRACE("band info: ID=%u, size=%u, child=%04x, clrF=0x%06lx, clrB=0x%06lx\n",
380 pB
->wID
, pB
->cbSize
, pB
->hwndChild
, pB
->clrFore
, pB
->clrBack
);
381 TRACE("band info: mask=0x%08x (%s)\n", pB
->fMask
, REBAR_FmtMask(pB
->fMask
));
382 if (pB
->fMask
& RBBIM_STYLE
)
383 TRACE("band info: style=0x%08x (%s)\n", pB
->fStyle
, REBAR_FmtStyle(pB
->fStyle
));
384 if (pB
->fMask
& (RBBIM_SIZE
| RBBIM_IDEALSIZE
| RBBIM_HEADERSIZE
| RBBIM_LPARAM
)) {
386 if (pB
->fMask
& RBBIM_SIZE
)
387 DPRINTF(" cx=%u", pB
->cx
);
388 if (pB
->fMask
& RBBIM_IDEALSIZE
)
389 DPRINTF(" xIdeal=%u", pB
->cxIdeal
);
390 if (pB
->fMask
& RBBIM_HEADERSIZE
)
391 DPRINTF(" xHeader=%u", pB
->cxHeader
);
392 if (pB
->fMask
& RBBIM_LPARAM
)
393 DPRINTF(" lParam=0x%08lx", pB
->lParam
);
396 if (pB
->fMask
& RBBIM_CHILDSIZE
)
397 TRACE("band info: xMin=%u, yMin=%u, yChild=%u, yMax=%u, yIntgl=%u\n",
399 pB
->cyMinChild
, pB
->cyChild
, pB
->cyMaxChild
, pB
->cyIntegral
);
403 REBAR_DumpBand (REBAR_INFO
*iP
)
408 if(! TRACE_ON(rebar
) ) return;
410 TRACE("hwnd=%04x: color=%08lx/%08lx, bands=%u, rows=%u, cSize=%ld,%ld\n",
411 iP
->hwndSelf
, iP
->clrText
, iP
->clrBk
, iP
->uNumBands
, iP
->uNumRows
,
412 iP
->calcSize
.cx
, iP
->calcSize
.cy
);
413 TRACE("hwnd=%04x: flags=%08x, dragStart=%d,%d, dragNow=%d,%d, ihitBand=%d\n",
414 iP
->hwndSelf
, iP
->fStatus
, iP
->dragStart
.x
, iP
->dragStart
.y
,
415 iP
->dragNow
.x
, iP
->dragNow
.y
,
417 TRACE("hwnd=%04x: style=%08lx, I'm Unicode=%s, notify in Unicode=%s, redraw=%s\n",
418 iP
->hwndSelf
, iP
->dwStyle
, (iP
->bUnicode
)?"TRUE":"FALSE",
419 (iP
->NtfUnicode
)?"TRUE":"FALSE", (iP
->DoRedraw
)?"TRUE":"FALSE");
420 for (i
= 0; i
< iP
->uNumBands
; i
++) {
422 TRACE("band # %u: ID=%u, child=%04x, row=%u, clrF=0x%06lx, clrB=0x%06lx\n",
423 i
, pB
->wID
, pB
->hwndChild
, pB
->iRow
, pB
->clrFore
, pB
->clrBack
);
424 TRACE("band # %u: mask=0x%08x (%s)\n", i
, pB
->fMask
, REBAR_FmtMask(pB
->fMask
));
425 if (pB
->fMask
& RBBIM_STYLE
)
426 TRACE("band # %u: style=0x%08x (%s)\n",
427 i
, pB
->fStyle
, REBAR_FmtStyle(pB
->fStyle
));
428 TRACE("band # %u: uMinH=%u xHeader=%u",
429 i
, pB
->uMinHeight
, pB
->cxHeader
);
430 if (pB
->fMask
& (RBBIM_SIZE
| RBBIM_IDEALSIZE
| RBBIM_LPARAM
)) {
431 if (pB
->fMask
& RBBIM_SIZE
)
432 DPRINTF(" cx=%u", pB
->cx
);
433 if (pB
->fMask
& RBBIM_IDEALSIZE
)
434 DPRINTF(" xIdeal=%u", pB
->cxIdeal
);
435 if (pB
->fMask
& RBBIM_LPARAM
)
436 DPRINTF(" lParam=0x%08lx", pB
->lParam
);
440 TRACE("band # %u: xMin=%u, yMin=%u, yChild=%u, yMax=%u, yIntgl=%u\n",
441 i
, pB
->cxMinChild
, pB
->cyMinChild
, pB
->cyChild
, pB
->cyMaxChild
, pB
->cyIntegral
);
442 if (pB
->fMask
& RBBIM_TEXT
)
443 TRACE("band # %u: text=%s\n",
444 i
, (pB
->lpText
) ? debugstr_w(pB
->lpText
) : "(null)");
445 TRACE("band # %u: lcx=%u, ccx=%u, hcx=%u, lcy=%u, ccy=%u, hcy=%u, offChild=%ld,%ld\n",
446 i
, pB
->lcx
, pB
->ccx
, pB
->hcx
, pB
->lcy
, pB
->ccy
, pB
->hcy
, pB
->offChild
.cx
, pB
->offChild
.cy
);
447 TRACE("band # %u: fStatus=%08x, fDraw=%08x, Band=(%d,%d)-(%d,%d), Grip=(%d,%d)-(%d,%d)\n",
448 i
, pB
->fStatus
, pB
->fDraw
,
449 pB
->rcBand
.left
, pB
->rcBand
.top
, pB
->rcBand
.right
, pB
->rcBand
.bottom
,
450 pB
->rcGripper
.left
, pB
->rcGripper
.top
, pB
->rcGripper
.right
, pB
->rcGripper
.bottom
);
451 TRACE("band # %u: Img=(%d,%d)-(%d,%d), Txt=(%d,%d)-(%d,%d), Child=(%d,%d)-(%d,%d)\n",
453 pB
->rcCapImage
.left
, pB
->rcCapImage
.top
, pB
->rcCapImage
.right
, pB
->rcCapImage
.bottom
,
454 pB
->rcCapText
.left
, pB
->rcCapText
.top
, pB
->rcCapText
.right
, pB
->rcCapText
.bottom
,
455 pB
->rcChild
.left
, pB
->rcChild
.top
, pB
->rcChild
.right
, pB
->rcChild
.bottom
);
462 REBAR_GetNotifyParent (REBAR_INFO
*infoPtr
)
466 parent
= infoPtr
->hwndNotify
;
468 parent
= GetParent (infoPtr
->hwndSelf
);
469 owner
= GetWindow (infoPtr
->hwndSelf
, GW_OWNER
);
470 if (owner
) parent
= owner
;
477 REBAR_Notify (NMHDR
*nmhdr
, REBAR_INFO
*infoPtr
, UINT code
)
481 parent
= REBAR_GetNotifyParent (infoPtr
);
482 nmhdr
->idFrom
= GetDlgCtrlID (infoPtr
->hwndSelf
);
483 nmhdr
->hwndFrom
= infoPtr
->hwndSelf
;
486 TRACE("window %04x, code=%08x, %s\n", parent
, code
,
487 (infoPtr
->NtfUnicode
) ? "via Unicode" : "via ANSI");
489 if (infoPtr
->NtfUnicode
)
490 return SendMessageW (parent
, WM_NOTIFY
, (WPARAM
) nmhdr
->idFrom
,
493 return SendMessageA (parent
, WM_NOTIFY
, (WPARAM
) nmhdr
->idFrom
,
498 REBAR_Notify_NMREBAR (REBAR_INFO
*infoPtr
, UINT uBand
, UINT code
)
500 NMREBAR notify_rebar
;
503 notify_rebar
.dwMask
= 0;
505 lpBand
= &infoPtr
->bands
[uBand
];
506 if (lpBand
->fMask
& RBBIM_ID
) {
507 notify_rebar
.dwMask
|= RBNM_ID
;
508 notify_rebar
.wID
= lpBand
->wID
;
510 if (lpBand
->fMask
& RBBIM_LPARAM
) {
511 notify_rebar
.dwMask
|= RBNM_LPARAM
;
512 notify_rebar
.lParam
= lpBand
->lParam
;
514 if (lpBand
->fMask
& RBBIM_STYLE
) {
515 notify_rebar
.dwMask
|= RBNM_STYLE
;
516 notify_rebar
.fStyle
= lpBand
->fStyle
;
519 notify_rebar
.uBand
= uBand
;
520 return REBAR_Notify ((NMHDR
*)¬ify_rebar
, infoPtr
, code
);
524 REBAR_DrawBand (HDC hdc
, REBAR_INFO
*infoPtr
, REBAR_BAND
*lpBand
)
530 if (lpBand
->fDraw
& DRAW_TEXT
) {
531 hOldFont
= SelectObject (hdc
, infoPtr
->hFont
);
532 oldBkMode
= SetBkMode (hdc
, TRANSPARENT
);
535 /* should test for CDRF_NOTIFYITEMDRAW here */
536 nmcd
.dwDrawStage
= CDDS_ITEMPREPAINT
;
538 nmcd
.rc
= lpBand
->rcBand
;
539 nmcd
.rc
.right
= lpBand
->rcCapText
.right
;
540 nmcd
.rc
.bottom
= lpBand
->rcCapText
.bottom
;
541 nmcd
.dwItemSpec
= lpBand
->wID
;
543 nmcd
.lItemlParam
= lpBand
->lParam
;
544 lpBand
->uCDret
= REBAR_Notify ((NMHDR
*)&nmcd
, infoPtr
, NM_CUSTOMDRAW
);
545 if (lpBand
->uCDret
== CDRF_SKIPDEFAULT
) {
546 if (oldBkMode
!= TRANSPARENT
)
547 SetBkMode (hdc
, oldBkMode
);
548 SelectObject (hdc
, hOldFont
);
553 if (lpBand
->fDraw
& DRAW_GRIPPER
)
554 DrawEdge (hdc
, &lpBand
->rcGripper
, BDR_RAISEDINNER
, BF_RECT
| BF_MIDDLE
);
556 /* draw caption image */
557 if (lpBand
->fDraw
& DRAW_IMAGE
) {
561 pt
.y
= (lpBand
->rcCapImage
.bottom
+ lpBand
->rcCapImage
.top
- infoPtr
->imageSize
.cy
)/2;
562 pt
.x
= (lpBand
->rcCapImage
.right
+ lpBand
->rcCapImage
.left
- infoPtr
->imageSize
.cx
)/2;
564 ImageList_Draw (infoPtr
->himl
, lpBand
->iImage
, hdc
,
569 /* draw caption text */
570 if (lpBand
->fDraw
& DRAW_TEXT
) {
571 /* need to handle CDRF_NEWFONT here */
572 INT oldBkMode
= SetBkMode (hdc
, TRANSPARENT
);
573 COLORREF oldcolor
= CLR_NONE
;
575 if (lpBand
->clrFore
!= CLR_NONE
) {
576 new = (lpBand
->clrFore
== CLR_DEFAULT
) ? infoPtr
->clrBtnText
:
578 oldcolor
= SetTextColor (hdc
, new);
580 DrawTextW (hdc
, lpBand
->lpText
, -1, &lpBand
->rcCapText
,
581 DT_CENTER
| DT_VCENTER
| DT_SINGLELINE
);
582 if (oldBkMode
!= TRANSPARENT
)
583 SetBkMode (hdc
, oldBkMode
);
584 if (lpBand
->clrFore
!= CLR_NONE
)
585 SetTextColor (hdc
, oldcolor
);
586 SelectObject (hdc
, hOldFont
);
589 if (lpBand
->uCDret
== (CDRF_NOTIFYPOSTPAINT
| CDRF_NOTIFYITEMDRAW
)) {
590 nmcd
.dwDrawStage
= CDDS_ITEMPOSTPAINT
;
592 nmcd
.rc
= lpBand
->rcBand
;
593 nmcd
.rc
.right
= lpBand
->rcCapText
.right
;
594 nmcd
.rc
.bottom
= lpBand
->rcCapText
.bottom
;
595 nmcd
.dwItemSpec
= lpBand
->wID
;
597 nmcd
.lItemlParam
= lpBand
->lParam
;
598 lpBand
->uCDret
= REBAR_Notify ((NMHDR
*)&nmcd
, infoPtr
, NM_CUSTOMDRAW
);
604 REBAR_Refresh (REBAR_INFO
*infoPtr
, HDC hdc
)
609 if (!infoPtr
->DoRedraw
) return;
611 oldrow
= infoPtr
->bands
[0].iRow
;
612 for (i
= 0; i
< infoPtr
->uNumBands
; i
++) {
613 lpBand
= &infoPtr
->bands
[i
];
615 if (HIDDENBAND(lpBand
)) continue;
617 /* now draw the band */
618 TRACE("[%04x] drawing band %i, flags=%08x\n",
619 infoPtr
->hwndSelf
, i
, lpBand
->fDraw
);
620 REBAR_DrawBand (hdc
, infoPtr
, lpBand
);
627 REBAR_FixVert (REBAR_INFO
*infoPtr
, UINT rowstart
, UINT rowend
,
630 /* Cycle through bands in row and fix height of each band. */
631 /* Also determine whether each band has changed. */
633 /* all bands at desired size. */
634 /* start and end bands are *not* hidden */
639 for (i
= (INT
)rowstart
; i
<=(INT
)rowend
; i
++) {
640 lpBand
= &infoPtr
->bands
[i
];
641 if (HIDDENBAND(lpBand
)) continue;
643 /* adjust height of bands in row to "mcy" value */
644 if (infoPtr
->dwStyle
& CCS_VERT
) {
645 if (lpBand
->rcBand
.right
!= lpBand
->rcBand
.left
+ mcy
)
646 lpBand
->rcBand
.right
= lpBand
->rcBand
.left
+ mcy
;
649 if (lpBand
->rcBand
.bottom
!= lpBand
->rcBand
.top
+ mcy
)
650 lpBand
->rcBand
.bottom
= lpBand
->rcBand
.top
+ mcy
;
654 /* mark whether we need to invalidate this band and trace */
655 if ((lpBand
->rcoldBand
.left
!=lpBand
->rcBand
.left
) ||
656 (lpBand
->rcoldBand
.top
!=lpBand
->rcBand
.top
) ||
657 (lpBand
->rcoldBand
.right
!=lpBand
->rcBand
.right
) ||
658 (lpBand
->rcoldBand
.bottom
!=lpBand
->rcBand
.bottom
)) {
659 lpBand
->fDraw
|= NTF_INVALIDATE
;
660 TRACE("band %d row=%d: changed to (%d,%d)-(%d,%d) from (%d,%d)-(%d,%d)\n",
662 lpBand
->rcBand
.left
, lpBand
->rcBand
.top
,
663 lpBand
->rcBand
.right
, lpBand
->rcBand
.bottom
,
664 lpBand
->rcoldBand
.left
, lpBand
->rcoldBand
.top
,
665 lpBand
->rcoldBand
.right
, lpBand
->rcoldBand
.bottom
);
668 TRACE("band %d row=%d: unchanged (%d,%d)-(%d,%d)\n",
670 lpBand
->rcBand
.left
, lpBand
->rcBand
.top
,
671 lpBand
->rcBand
.right
, lpBand
->rcBand
.bottom
);
677 REBAR_AdjustBands (REBAR_INFO
*infoPtr
, UINT rowstart
, UINT rowend
,
679 /* Function: This routine distributes the extra space in a row. */
680 /* See algorithm below. */
682 /* all bands @ ->cxHeader size */
683 /* start and end bands are *not* hidden */
686 UINT x
, xsep
, extra
, curwidth
, fudge
;
687 INT i
, last_adjusted
;
689 TRACE("start=%u, end=%u, max x=%d, max y=%d\n",
690 rowstart
, rowend
, maxx
, mcy
);
692 /* ******************* Phase 1 ************************ */
694 /* For each visible band with valid child */
695 /* a. inflate band till either all extra space used */
696 /* or band's ->ccx reached. */
697 /* If any band modified, add any space left to last band */
700 /* ****************************************************** */
701 lpBand
= &infoPtr
->bands
[rowend
];
702 extra
= maxx
- rcBrb(lpBand
);
705 for (i
=(INT
)rowstart
; i
<=(INT
)rowend
; i
++) {
706 lpBand
= &infoPtr
->bands
[i
];
707 if (HIDDENBAND(lpBand
)) continue;
708 xsep
= (x
== 0) ? 0 : SEP_WIDTH
;
709 curwidth
= rcBw(lpBand
);
711 /* set new left/top point */
712 if (infoPtr
->dwStyle
& CCS_VERT
)
713 lpBand
->rcBand
.top
= x
+ xsep
;
715 lpBand
->rcBand
.left
= x
+ xsep
;
717 /* compute new width */
718 if ((lpBand
->hwndChild
&& extra
) && !(lpBand
->fStyle
& RBBS_FIXEDSIZE
)) {
719 /* set to the "current" band size less the header */
722 if ((lpBand
->fMask
& RBBIM_SIZE
) && (lpBand
->cx
> 0) &&
723 (fudge
> curwidth
)) {
724 TRACE("adjusting band %d by %d, fudge=%d, curwidth=%d, extra=%d\n",
725 i
, fudge
-curwidth
, fudge
, curwidth
, extra
);
726 if ((fudge
- curwidth
) > extra
)
727 fudge
= curwidth
+ extra
;
728 extra
-= (fudge
- curwidth
);
732 TRACE("adjusting band %d by %d, fudge=%d, curwidth=%d\n",
733 i
, extra
, fudge
, curwidth
);
739 /* set new right/bottom point */
740 if (infoPtr
->dwStyle
& CCS_VERT
)
741 lpBand
->rcBand
.bottom
= lpBand
->rcBand
.top
+ curwidth
;
743 lpBand
->rcBand
.right
= lpBand
->rcBand
.left
+ curwidth
;
744 TRACE("Phase 1 band %d, (%d,%d)-(%d,%d), orig x=%d, xsep=%d\n",
745 i
, lpBand
->rcBand
.left
, lpBand
->rcBand
.top
,
746 lpBand
->rcBand
.right
, lpBand
->rcBand
.bottom
, x
, xsep
);
749 if ((x
>= maxx
) || (last_adjusted
!= -1)) {
751 ERR("Phase 1 failed, x=%d, maxx=%d, start=%u, end=%u\n",
752 x
, maxx
, rowstart
, rowend
);
754 /* done, so spread extra space */
757 TRACE("Need to spread %d on last adjusted band %d\n",
758 fudge
, last_adjusted
);
759 for (i
=(INT
)last_adjusted
; i
<=(INT
)rowend
; i
++) {
760 lpBand
= &infoPtr
->bands
[i
];
761 if (HIDDENBAND(lpBand
)) continue;
763 /* set right/bottom point */
764 if (i
!= last_adjusted
) {
765 if (infoPtr
->dwStyle
& CCS_VERT
)
766 lpBand
->rcBand
.top
+= fudge
;
768 lpBand
->rcBand
.left
+= fudge
;
771 /* set left/bottom point */
772 if (infoPtr
->dwStyle
& CCS_VERT
)
773 lpBand
->rcBand
.bottom
+= fudge
;
775 lpBand
->rcBand
.right
+= fudge
;
778 TRACE("Phase 1 succeeded, used x=%d\n", x
);
779 REBAR_FixVert (infoPtr
, rowstart
, rowend
, mcy
);
783 /* ******************* Phase 2 ************************ */
785 /* Find first visible band, put all */
786 /* extra space there. */
788 /* ****************************************************** */
791 for (i
=(INT
)rowstart
; i
<=(INT
)rowend
; i
++) {
792 lpBand
= &infoPtr
->bands
[i
];
793 if (HIDDENBAND(lpBand
)) continue;
794 xsep
= (x
== 0) ? 0 : SEP_WIDTH
;
795 curwidth
= rcBw(lpBand
);
797 /* set new left/top point */
798 if (infoPtr
->dwStyle
& CCS_VERT
)
799 lpBand
->rcBand
.top
= x
+ xsep
;
801 lpBand
->rcBand
.left
= x
+ xsep
;
803 /* compute new width */
809 /* set new right/bottom point */
810 if (infoPtr
->dwStyle
& CCS_VERT
)
811 lpBand
->rcBand
.bottom
= lpBand
->rcBand
.top
+ curwidth
;
813 lpBand
->rcBand
.right
= lpBand
->rcBand
.left
+ curwidth
;
814 TRACE("Phase 2 band %d, (%d,%d)-(%d,%d), orig x=%d, xsep=%d\n",
815 i
, lpBand
->rcBand
.left
, lpBand
->rcBand
.top
,
816 lpBand
->rcBand
.right
, lpBand
->rcBand
.bottom
, x
, xsep
);
821 ERR("Phase 2 failed, x=%d, maxx=%d, start=%u, end=%u\n",
822 x
, maxx
, rowstart
, rowend
);
824 /* done, so spread extra space */
825 TRACE("Phase 2 succeeded, used x=%d\n", x
);
826 REBAR_FixVert (infoPtr
, rowstart
, rowend
, mcy
);
830 /* ******************* Phase 3 ************************ */
831 /* at this point everything is back to ->cxHeader values */
832 /* and should not have gotten here. */
833 /* ****************************************************** */
835 lpBand
= &infoPtr
->bands
[rowstart
];
836 ERR("Serious problem adjusting row %d, start band %d, end band %d\n",
837 lpBand
->iRow
, rowstart
, rowend
);
838 REBAR_DumpBand (infoPtr
);
844 REBAR_CalcHorzBand (REBAR_INFO
*infoPtr
, UINT rstart
, UINT rend
, BOOL notify
)
845 /* Function: this routine initializes all the rectangles in */
846 /* each band in a row to fit in the adjusted rcBand rect. */
847 /* *** Supports only Horizontal bars. *** */
854 /* MS seems to use GetDlgCtrlID() for above GetWindowLong call */
855 parenthwnd
= GetParent (infoPtr
->hwndSelf
);
857 for(i
=rstart
; i
<rend
; i
++){
858 lpBand
= &infoPtr
->bands
[i
];
859 if (HIDDENBAND(lpBand
)) {
860 SetRect (&lpBand
->rcChild
,
861 lpBand
->rcBand
.right
, lpBand
->rcBand
.top
,
862 lpBand
->rcBand
.right
, lpBand
->rcBand
.bottom
);
866 oldChild
= lpBand
->rcChild
;
868 /* set initial gripper rectangle */
869 SetRect (&lpBand
->rcGripper
, lpBand
->rcBand
.left
, lpBand
->rcBand
.top
,
870 lpBand
->rcBand
.left
, lpBand
->rcBand
.bottom
);
872 /* calculate gripper rectangle */
873 if ( lpBand
->fStatus
& HAS_GRIPPER
) {
874 lpBand
->fDraw
|= DRAW_GRIPPER
;
875 lpBand
->rcGripper
.left
+= REBAR_PRE_GRIPPER
;
876 lpBand
->rcGripper
.right
= lpBand
->rcGripper
.left
+ GRIPPER_WIDTH
;
877 lpBand
->rcGripper
.top
+= 2;
878 lpBand
->rcGripper
.bottom
-= 2;
880 SetRect (&lpBand
->rcCapImage
,
881 lpBand
->rcGripper
.right
+REBAR_ALWAYS_SPACE
, lpBand
->rcBand
.top
,
882 lpBand
->rcGripper
.right
+REBAR_ALWAYS_SPACE
, lpBand
->rcBand
.bottom
);
884 else { /* no gripper will be drawn */
886 if (lpBand
->fStatus
& (HAS_IMAGE
| HAS_TEXT
))
887 /* if no gripper but either image or text, then leave space */
888 xoff
= REBAR_ALWAYS_SPACE
;
889 SetRect (&lpBand
->rcCapImage
,
890 lpBand
->rcBand
.left
+xoff
, lpBand
->rcBand
.top
,
891 lpBand
->rcBand
.left
+xoff
, lpBand
->rcBand
.bottom
);
894 /* image is visible */
895 if (lpBand
->fStatus
& HAS_IMAGE
) {
896 lpBand
->fDraw
|= DRAW_IMAGE
;
897 lpBand
->rcCapImage
.right
+= infoPtr
->imageSize
.cx
;
898 lpBand
->rcCapImage
.bottom
= lpBand
->rcCapImage
.top
+ infoPtr
->imageSize
.cy
;
900 /* set initial caption text rectangle */
901 SetRect (&lpBand
->rcCapText
,
902 lpBand
->rcCapImage
.right
+REBAR_POST_IMAGE
, lpBand
->rcBand
.top
+1,
903 lpBand
->rcBand
.left
+lpBand
->cxHeader
, lpBand
->rcBand
.bottom
-1);
904 /* update band height
905 if (lpBand->uMinHeight < infoPtr->imageSize.cy + 2) {
906 lpBand->uMinHeight = infoPtr->imageSize.cy + 2;
907 lpBand->rcBand.bottom = lpBand->rcBand.top + lpBand->uMinHeight;
911 /* set initial caption text rectangle */
912 SetRect (&lpBand
->rcCapText
, lpBand
->rcCapImage
.right
, lpBand
->rcBand
.top
+1,
913 lpBand
->rcBand
.left
+lpBand
->cxHeader
, lpBand
->rcBand
.bottom
-1);
916 /* text is visible */
917 if (lpBand
->fStatus
& HAS_TEXT
) {
918 lpBand
->fDraw
|= DRAW_TEXT
;
919 lpBand
->rcCapText
.right
= max(lpBand
->rcCapText
.left
,
920 lpBand
->rcCapText
.right
-REBAR_POST_TEXT
);
923 /* set initial child window rectangle if there is a child */
924 if (lpBand
->fMask
& RBBIM_CHILD
) {
925 xoff
= lpBand
->offChild
.cx
;
926 yoff
= lpBand
->offChild
.cy
;
927 SetRect (&lpBand
->rcChild
,
928 lpBand
->rcBand
.left
+lpBand
->cxHeader
, lpBand
->rcBand
.top
+yoff
,
929 lpBand
->rcBand
.right
-xoff
, lpBand
->rcBand
.bottom
-yoff
);
932 SetRect (&lpBand
->rcChild
,
933 lpBand
->rcBand
.left
+lpBand
->cxHeader
, lpBand
->rcBand
.top
,
934 lpBand
->rcBand
.right
, lpBand
->rcBand
.bottom
);
937 /* flag if notify required and invalidate rectangle */
939 ((oldChild
.right
-oldChild
.left
!= lpBand
->rcChild
.right
-lpBand
->rcChild
.left
) ||
940 (oldChild
.bottom
-oldChild
.top
!= lpBand
->rcChild
.bottom
-lpBand
->rcChild
.top
))) {
941 TRACE("Child rectangle changed for band %u\n", i
);
942 TRACE(" from (%d,%d)-(%d,%d) to (%d,%d)-(%d,%d)\n",
943 oldChild
.left
, oldChild
.top
,
944 oldChild
.right
, oldChild
.bottom
,
945 lpBand
->rcChild
.left
, lpBand
->rcChild
.top
,
946 lpBand
->rcChild
.right
, lpBand
->rcChild
.bottom
);
948 if (lpBand
->fDraw
& NTF_INVALIDATE
) {
949 TRACE("invalidating (%d,%d)-(%d,%d)\n",
952 lpBand
->rcBand
.right
+ ((lpBand
->fDraw
& DRAW_RIGHTSEP
) ? SEP_WIDTH_SIZE
: 0),
953 lpBand
->rcBand
.bottom
+ ((lpBand
->fDraw
& DRAW_BOTTOMSEP
) ? SEP_WIDTH_SIZE
: 0));
954 lpBand
->fDraw
&= ~NTF_INVALIDATE
;
955 work
= lpBand
->rcBand
;
956 if (lpBand
->fDraw
& DRAW_RIGHTSEP
) work
.right
+= SEP_WIDTH_SIZE
;
957 if (lpBand
->fDraw
& DRAW_BOTTOMSEP
) work
.bottom
+= SEP_WIDTH_SIZE
;
958 InvalidateRect(infoPtr
->hwndSelf
, &work
, TRUE
);
967 REBAR_CalcVertBand (REBAR_INFO
*infoPtr
, UINT rstart
, UINT rend
, BOOL notify
)
968 /* Function: this routine initializes all the rectangles in */
969 /* each band in a row to fit in the adjusted rcBand rect. */
970 /* *** Supports only Vertical bars. *** */
977 /* MS seems to use GetDlgCtrlID() for above GetWindowLong call */
978 parenthwnd
= GetParent (infoPtr
->hwndSelf
);
980 for(i
=rstart
; i
<rend
; i
++){
981 lpBand
= &infoPtr
->bands
[i
];
982 if (HIDDENBAND(lpBand
)) continue;
983 oldChild
= lpBand
->rcChild
;
985 /* set initial gripper rectangle */
986 SetRect (&lpBand
->rcGripper
, lpBand
->rcBand
.left
, lpBand
->rcBand
.top
,
987 lpBand
->rcBand
.right
, lpBand
->rcBand
.top
);
989 /* calculate gripper rectangle */
990 if (lpBand
->fStatus
& HAS_GRIPPER
) {
991 lpBand
->fDraw
|= DRAW_GRIPPER
;
993 if (infoPtr
->dwStyle
& RBS_VERTICALGRIPPER
) {
994 /* vertical gripper */
995 lpBand
->rcGripper
.left
+= 3;
996 lpBand
->rcGripper
.right
= lpBand
->rcGripper
.left
+ GRIPPER_WIDTH
;
997 lpBand
->rcGripper
.top
+= REBAR_PRE_GRIPPER
;
998 lpBand
->rcGripper
.bottom
= lpBand
->rcGripper
.top
+ GRIPPER_HEIGHT
;
1000 /* initialize Caption image rectangle */
1001 SetRect (&lpBand
->rcCapImage
, lpBand
->rcBand
.left
,
1002 lpBand
->rcGripper
.bottom
+ REBAR_ALWAYS_SPACE
,
1003 lpBand
->rcBand
.right
,
1004 lpBand
->rcGripper
.bottom
+ REBAR_ALWAYS_SPACE
);
1007 /* horizontal gripper */
1008 lpBand
->rcGripper
.left
+= 2;
1009 lpBand
->rcGripper
.right
-= 2;
1010 lpBand
->rcGripper
.top
+= REBAR_PRE_GRIPPER
;
1011 lpBand
->rcGripper
.bottom
= lpBand
->rcGripper
.top
+ GRIPPER_WIDTH
;
1013 /* initialize Caption image rectangle */
1014 SetRect (&lpBand
->rcCapImage
, lpBand
->rcBand
.left
,
1015 lpBand
->rcGripper
.bottom
+ REBAR_ALWAYS_SPACE
,
1016 lpBand
->rcBand
.right
,
1017 lpBand
->rcGripper
.bottom
+ REBAR_ALWAYS_SPACE
);
1020 else { /* no gripper will be drawn */
1022 if (lpBand
->fStatus
& (HAS_IMAGE
| HAS_TEXT
))
1023 /* if no gripper but either image or text, then leave space */
1024 xoff
= REBAR_ALWAYS_SPACE
;
1025 /* initialize Caption image rectangle */
1026 SetRect (&lpBand
->rcCapImage
,
1027 lpBand
->rcBand
.left
, lpBand
->rcBand
.top
+xoff
,
1028 lpBand
->rcBand
.right
, lpBand
->rcBand
.top
+xoff
);
1031 /* image is visible */
1032 if (lpBand
->fStatus
& HAS_IMAGE
) {
1033 lpBand
->fDraw
|= DRAW_IMAGE
;
1035 lpBand
->rcCapImage
.right
= lpBand
->rcCapImage
.left
+ infoPtr
->imageSize
.cx
;
1036 lpBand
->rcCapImage
.bottom
+= infoPtr
->imageSize
.cy
;
1038 /* set initial caption text rectangle */
1039 SetRect (&lpBand
->rcCapText
,
1040 lpBand
->rcBand
.left
, lpBand
->rcCapImage
.bottom
+REBAR_POST_IMAGE
,
1041 lpBand
->rcBand
.right
, lpBand
->rcBand
.top
+lpBand
->cxHeader
);
1042 /* update band height *
1043 if (lpBand->uMinHeight < infoPtr->imageSize.cx + 2) {
1044 lpBand->uMinHeight = infoPtr->imageSize.cx + 2;
1045 lpBand->rcBand.right = lpBand->rcBand.left + lpBand->uMinHeight;
1049 /* set initial caption text rectangle */
1050 SetRect (&lpBand
->rcCapText
,
1051 lpBand
->rcBand
.left
, lpBand
->rcCapImage
.bottom
,
1052 lpBand
->rcBand
.right
, lpBand
->rcBand
.top
+lpBand
->cxHeader
);
1055 /* text is visible */
1056 if (lpBand
->fStatus
& HAS_TEXT
) {
1057 lpBand
->fDraw
|= DRAW_TEXT
;
1058 lpBand
->rcCapText
.bottom
= max(lpBand
->rcCapText
.top
,
1059 lpBand
->rcCapText
.bottom
);
1062 /* set initial child window rectangle if there is a child */
1063 if (lpBand
->fMask
& RBBIM_CHILD
) {
1064 yoff
= lpBand
->offChild
.cx
;
1065 xoff
= lpBand
->offChild
.cy
;
1066 SetRect (&lpBand
->rcChild
,
1067 lpBand
->rcBand
.left
+xoff
, lpBand
->rcBand
.top
+lpBand
->cxHeader
,
1068 lpBand
->rcBand
.right
-xoff
, lpBand
->rcBand
.bottom
-yoff
);
1071 SetRect (&lpBand
->rcChild
,
1072 lpBand
->rcBand
.left
, lpBand
->rcBand
.top
+lpBand
->cxHeader
,
1073 lpBand
->rcBand
.right
, lpBand
->rcBand
.bottom
);
1076 /* flag if notify required and invalidate rectangle */
1078 ((oldChild
.right
-oldChild
.left
!= lpBand
->rcChild
.right
-lpBand
->rcChild
.left
) ||
1079 (oldChild
.bottom
-oldChild
.top
!= lpBand
->rcChild
.bottom
-lpBand
->rcChild
.top
))) {
1080 TRACE("Child rectangle changed for band %u\n", i
);
1081 TRACE(" from (%d,%d)-(%d,%d) to (%d,%d)-(%d,%d)\n",
1082 oldChild
.left
, oldChild
.top
,
1083 oldChild
.right
, oldChild
.bottom
,
1084 lpBand
->rcChild
.left
, lpBand
->rcChild
.top
,
1085 lpBand
->rcChild
.right
, lpBand
->rcChild
.bottom
);
1087 if (lpBand
->fDraw
& NTF_INVALIDATE
) {
1088 TRACE("invalidating (%d,%d)-(%d,%d)\n",
1089 lpBand
->rcBand
.left
,
1091 lpBand
->rcBand
.right
+ ((lpBand
->fDraw
& DRAW_BOTTOMSEP
) ? SEP_WIDTH_SIZE
: 0),
1092 lpBand
->rcBand
.bottom
+ ((lpBand
->fDraw
& DRAW_RIGHTSEP
) ? SEP_WIDTH_SIZE
: 0));
1093 lpBand
->fDraw
&= ~NTF_INVALIDATE
;
1094 work
= lpBand
->rcBand
;
1095 if (lpBand
->fDraw
& DRAW_RIGHTSEP
) work
.bottom
+= SEP_WIDTH_SIZE
;
1096 if (lpBand
->fDraw
& DRAW_BOTTOMSEP
) work
.right
+= SEP_WIDTH_SIZE
;
1097 InvalidateRect(infoPtr
->hwndSelf
, &work
, TRUE
);
1105 REBAR_ForceResize (REBAR_INFO
*infoPtr
)
1106 /* Function: This changes the size of the REBAR window to that */
1107 /* calculated by REBAR_Layout. */
1110 INT x
, y
, width
, height
;
1111 INT xedge
= GetSystemMetrics(SM_CXEDGE
);
1112 INT yedge
= GetSystemMetrics(SM_CYEDGE
);
1114 /* TEST TEST TEST */
1115 GetWindowRect (infoPtr
->hwndSelf
, &rc
);
1116 /* END TEST END TEST END TEST */
1119 GetClientRect (infoPtr
->hwndSelf
, &rc
);
1121 TRACE( " old [%ld x %ld], new [%ld x %ld], client [%d x %d]\n",
1122 infoPtr
->oldSize
.cx
, infoPtr
->oldSize
.cy
,
1123 infoPtr
->calcSize
.cx
, infoPtr
->calcSize
.cy
,
1124 rc
.right
, rc
.bottom
);
1126 /* If we need to shrink client, then skip size test */
1127 if ((infoPtr
->calcSize
.cy
>= rc
.bottom
) &&
1128 (infoPtr
->calcSize
.cx
>= rc
.right
)) {
1130 /* if size did not change then skip process */
1131 if ((infoPtr
->oldSize
.cx
== infoPtr
->calcSize
.cx
) &&
1132 (infoPtr
->oldSize
.cy
== infoPtr
->calcSize
.cy
) &&
1133 !(infoPtr
->fStatus
& RESIZE_ANYHOW
))
1135 TRACE("skipping reset\n");
1140 infoPtr
->fStatus
&= ~RESIZE_ANYHOW
;
1141 /* Set flag to ignore next WM_SIZE message */
1142 infoPtr
->fStatus
|= AUTO_RESIZE
;
1149 if (infoPtr
->dwStyle
& WS_BORDER
) {
1154 if (!(infoPtr
->dwStyle
& CCS_NOPARENTALIGN
)) {
1155 INT mode
= infoPtr
->dwStyle
& (CCS_VERT
| CCS_TOP
| CCS_BOTTOM
);
1158 GetClientRect(GetParent(infoPtr
->hwndSelf
), &rcPcl
);
1161 /* _TOP sets width to parents width */
1162 width
+= (rcPcl
.right
- rcPcl
.left
);
1163 height
+= infoPtr
->calcSize
.cy
;
1164 x
+= ((infoPtr
->dwStyle
& WS_BORDER
) ? -xedge
: 0);
1165 y
+= ((infoPtr
->dwStyle
& WS_BORDER
) ? -yedge
: 0);
1166 y
+= ((infoPtr
->dwStyle
& CCS_NODIVIDER
) ? 0 : REBAR_DIVIDER
);
1169 /* FIXME: wrong wrong wrong */
1170 /* _BOTTOM sets width to parents width */
1171 width
+= (rcPcl
.right
- rcPcl
.left
);
1172 height
+= infoPtr
->calcSize
.cy
;
1174 y
= rcPcl
.bottom
- height
+ 1;
1177 /* _LEFT sets height to parents height */
1178 width
+= infoPtr
->calcSize
.cx
;
1179 height
+= (rcPcl
.bottom
- rcPcl
.top
);
1180 x
+= ((infoPtr
->dwStyle
& WS_BORDER
) ? -xedge
: 0);
1181 x
+= ((infoPtr
->dwStyle
& CCS_NODIVIDER
) ? 0 : REBAR_DIVIDER
);
1182 y
+= ((infoPtr
->dwStyle
& WS_BORDER
) ? -yedge
: 0);
1185 /* FIXME: wrong wrong wrong */
1186 /* _RIGHT sets height to parents height */
1187 width
+= infoPtr
->calcSize
.cx
;
1188 height
+= (rcPcl
.bottom
- rcPcl
.top
);
1189 x
= rcPcl
.right
- width
+ 1;
1193 width
+= infoPtr
->calcSize
.cx
;
1194 height
+= infoPtr
->calcSize
.cy
;
1198 width
+= infoPtr
->calcSize
.cx
;
1199 height
+= infoPtr
->calcSize
.cy
;
1202 TRACE("hwnd %04x, style=%08lx, setting at (%d,%d) for (%d,%d)\n",
1203 infoPtr
->hwndSelf
, infoPtr
->dwStyle
,
1204 x
, y
, width
, height
);
1205 SetWindowPos (infoPtr
->hwndSelf
, 0, x
, y
, width
, height
,
1211 REBAR_MoveChildWindows (REBAR_INFO
*infoPtr
, UINT start
, UINT endplus
)
1214 CHAR szClassName
[40];
1216 NMREBARCHILDSIZE rbcz
;
1220 if (!(deferpos
= BeginDeferWindowPos(infoPtr
->uNumBands
)))
1221 ERR("BeginDeferWindowPos returned NULL\n");
1223 for (i
= start
; i
< endplus
; i
++) {
1224 lpBand
= &infoPtr
->bands
[i
];
1226 if (HIDDENBAND(lpBand
)) continue;
1227 if (lpBand
->hwndChild
) {
1228 TRACE("hwndChild = %x\n", lpBand
->hwndChild
);
1230 /* Always geterate the RBN_CHILDSIZE even it child
1233 rbcz
.wID
= lpBand
->wID
;
1234 rbcz
.rcChild
= lpBand
->rcChild
;
1235 rbcz
.rcBand
= lpBand
->rcBand
;
1236 rbcz
.rcBand
.left
+= lpBand
->cxHeader
;
1237 REBAR_Notify ((NMHDR
*)&rbcz
, infoPtr
, RBN_CHILDSIZE
);
1238 if (!EqualRect (&lpBand
->rcChild
, &rbcz
.rcChild
)) {
1239 TRACE("Child rect changed by NOTIFY for band %u\n", i
);
1240 TRACE(" from (%d,%d)-(%d,%d) to (%d,%d)-(%d,%d)\n",
1241 lpBand
->rcChild
.left
, lpBand
->rcChild
.top
,
1242 lpBand
->rcChild
.right
, lpBand
->rcChild
.bottom
,
1243 rbcz
.rcChild
.left
, rbcz
.rcChild
.top
,
1244 rbcz
.rcChild
.right
, rbcz
.rcChild
.bottom
);
1245 lpBand
->rcChild
= rbcz
.rcChild
; /* *** ??? */
1248 /* native (IE4 in "Favorites" frame **1) does:
1249 * SetRect (&rc, -1, -1, -1, -1)
1250 * EqualRect (&rc,band->rc???)
1252 * CopyRect (band->rc????, &rc)
1253 * set flag outside of loop
1256 GetClassNameA (lpBand
->hwndChild
, szClassName
, 40);
1257 if (!lstrcmpA (szClassName
, "ComboBox") ||
1258 !lstrcmpA (szClassName
, WC_COMBOBOXEXA
)) {
1259 INT nEditHeight
, yPos
;
1262 /* special placement code for combo or comboex box */
1265 /* get size of edit line */
1266 GetWindowRect (lpBand
->hwndChild
, &rc
);
1267 nEditHeight
= rc
.bottom
- rc
.top
;
1268 yPos
= (lpBand
->rcChild
.bottom
+ lpBand
->rcChild
.top
- nEditHeight
)/2;
1270 /* center combo box inside child area */
1271 TRACE("moving child (Combo(Ex)) %04x to (%d,%d) for (%d,%d)\n",
1273 lpBand
->rcChild
.left
, yPos
,
1274 lpBand
->rcChild
.right
- lpBand
->rcChild
.left
,
1276 deferpos
= DeferWindowPos (deferpos
, lpBand
->hwndChild
, HWND_TOP
,
1277 lpBand
->rcChild
.left
,
1278 /*lpBand->rcChild.top*/ yPos
,
1279 lpBand
->rcChild
.right
- lpBand
->rcChild
.left
,
1283 ERR("DeferWindowPos returned NULL\n");
1286 TRACE("moving child (Other) %04x to (%d,%d) for (%d,%d)\n",
1288 lpBand
->rcChild
.left
, lpBand
->rcChild
.top
,
1289 lpBand
->rcChild
.right
- lpBand
->rcChild
.left
,
1290 lpBand
->rcChild
.bottom
- lpBand
->rcChild
.top
);
1291 deferpos
= DeferWindowPos (deferpos
, lpBand
->hwndChild
, HWND_TOP
,
1292 lpBand
->rcChild
.left
,
1293 lpBand
->rcChild
.top
,
1294 lpBand
->rcChild
.right
- lpBand
->rcChild
.left
,
1295 lpBand
->rcChild
.bottom
- lpBand
->rcChild
.top
,
1298 ERR("DeferWindowPos returned NULL\n");
1302 if (!EndDeferWindowPos(deferpos
))
1303 ERR("EndDeferWindowPos returned NULL\n");
1305 UpdateWindow (infoPtr
->hwndSelf
);
1307 if (infoPtr
->fStatus
& NTF_HGHTCHG
) {
1308 infoPtr
->fStatus
&= ~NTF_HGHTCHG
;
1309 REBAR_Notify (&heightchange
, infoPtr
, RBN_HEIGHTCHANGE
);
1312 /* native (from **1 above) does:
1313 * UpdateWindow(rebar)
1315 * RBN_HEIGHTCHANGE if necessary
1316 * if ret from any EqualRect was 0
1317 * Goto "BeginDeferWindowPos"
1324 REBAR_Layout (REBAR_INFO
*infoPtr
, LPRECT lpRect
, BOOL notify
, BOOL resetclient
)
1325 /* Function: This routine is resposible for laying out all */
1326 /* the bands in a rebar. It assigns each band to a row and*/
1327 /* determines when to start a new row. */
1329 REBAR_BAND
*lpBand
, *prevBand
;
1330 RECT rcClient
, rcAdj
;
1331 INT initx
, inity
, x
, y
, cx
, cxsep
, mmcy
, mcy
, clientcx
, clientcy
;
1332 INT adjcx
, adjcy
, row
, rightx
, bottomy
, origheight
;
1333 UINT i
, j
, rowstart
, origrows
, cntonrow
;
1336 if (!(infoPtr
->fStatus
& BAND_NEEDS_LAYOUT
)) {
1337 TRACE("no layout done. No band changed.\n");
1338 REBAR_DumpBand (infoPtr
);
1341 infoPtr
->fStatus
&= ~BAND_NEEDS_LAYOUT
;
1342 if (!infoPtr
->DoRedraw
) infoPtr
->fStatus
|= BAND_NEEDS_REDRAW
;
1344 GetClientRect (infoPtr
->hwndSelf
, &rcClient
);
1345 TRACE("Client is (%d,%d)-(%d,%d)\n",
1346 rcClient
.left
, rcClient
.top
, rcClient
.right
, rcClient
.bottom
);
1350 TRACE("adjustment rect is (%d,%d)-(%d,%d)\n",
1351 rcAdj
.left
, rcAdj
.top
, rcAdj
.right
, rcAdj
.bottom
);
1354 CopyRect (&rcAdj
, &rcClient
);
1357 clientcx
= rcClient
.right
- rcClient
.left
;
1358 clientcy
= rcClient
.bottom
- rcClient
.top
;
1359 adjcx
= rcAdj
.right
- rcAdj
.left
;
1360 adjcy
= rcAdj
.bottom
- rcAdj
.top
;
1362 TRACE("window client rect will be set to adj rect\n");
1367 if (!infoPtr
->DoRedraw
&& (clientcx
== 0) && (clientcy
== 0)) {
1368 ERR("no redraw and client is zero, skip layout\n");
1369 infoPtr
->fStatus
|= BAND_NEEDS_LAYOUT
;
1373 /* save height of original control */
1374 if (infoPtr
->dwStyle
& CCS_VERT
)
1375 origheight
= infoPtr
->calcSize
.cx
;
1377 origheight
= infoPtr
->calcSize
.cy
;
1378 origrows
= infoPtr
->uNumRows
;
1383 /* ******* Start Phase 1 - all bands on row at minimum size ******* */
1385 TRACE("band loop constants, clientcx=%d, clientcy=%d, adjcx=%d, adjcy=%d\n",
1386 clientcx
, clientcy
, adjcx
, adjcy
);
1396 for (i
= 0; i
< infoPtr
->uNumBands
; i
++) {
1397 lpBand
= &infoPtr
->bands
[i
];
1401 if (HIDDENBAND(lpBand
)) continue;
1403 lpBand
->rcoldBand
= lpBand
->rcBand
;
1405 /* Set the offset of the child window */
1406 if ((lpBand
->fMask
& RBBIM_CHILD
) &&
1407 !(lpBand
->fStyle
& RBBS_FIXEDSIZE
)) {
1408 lpBand
->offChild
.cx
= 4; /* ??? */
1410 lpBand
->offChild
.cy
= ((lpBand
->fStyle
& RBBS_CHILDEDGE
) ? 2 : 0);
1412 /* separator from previous band */
1413 cxsep
= (cntonrow
== 0) ? 0 : SEP_WIDTH
;
1415 /* Header: includes gripper, text, image */
1416 cx
= lpBand
->cxHeader
;
1417 if (lpBand
->fStyle
& RBBS_FIXEDSIZE
) cx
= lpBand
->lcx
;
1419 if (infoPtr
->dwStyle
& CCS_VERT
)
1420 dobreak
= (y
+ cx
+ cxsep
> adjcy
);
1422 dobreak
= (x
+ cx
+ cxsep
> adjcx
);
1424 /* This is the check for whether we need to start a new row */
1425 if ( ( (lpBand
->fStyle
& RBBS_BREAK
) && (i
!= 0) ) ||
1426 ( ((infoPtr
->dwStyle
& CCS_VERT
) ? (y
!= 0) : (x
!= 0)) && dobreak
)) {
1428 for (j
= rowstart
; j
< i
; j
++) {
1430 lpB
= &infoPtr
->bands
[j
];
1431 if (infoPtr
->dwStyle
& CCS_VERT
) {
1432 lpB
->rcBand
.right
= lpB
->rcBand
.left
+ mcy
;
1435 lpB
->rcBand
.bottom
= lpB
->rcBand
.top
+ mcy
;
1439 TRACE("P1 Spliting to new row %d on band %u\n", row
+1, i
);
1440 if (infoPtr
->dwStyle
& CCS_VERT
) {
1442 x
+= (mcy
+ SEP_WIDTH
);
1446 y
+= (mcy
+ SEP_WIDTH
);
1458 if (mcy
< lpBand
->lcy
+ REBARSPACE(lpBand
))
1459 mcy
= lpBand
->lcy
+ REBARSPACE(lpBand
);
1461 /* if boundary rect specified then limit mcy */
1463 if (infoPtr
->dwStyle
& CCS_VERT
) {
1464 if (x
+mcy
> adjcx
) {
1466 TRACE("P1 row %u limiting mcy=%d, adjcx=%d, x=%d\n",
1471 if (y
+mcy
> adjcy
) {
1473 TRACE("P1 row %u limiting mcy=%d, adjcy=%d, y=%d\n",
1479 TRACE("P1 band %u, row %d, x=%d, y=%d, cxsep=%d, cx=%d\n",
1482 if (infoPtr
->dwStyle
& CCS_VERT
) {
1483 /* bound the bottom side if we have a bounding rectangle */
1485 bottomy
= (lpRect
) ? min(clientcy
, y
+cxsep
+cx
) : y
+cxsep
+cx
;
1486 lpBand
->rcBand
.left
= x
;
1487 lpBand
->rcBand
.right
= x
+ min(mcy
,
1488 lpBand
->lcy
+REBARSPACE(lpBand
));
1489 lpBand
->rcBand
.top
= min(bottomy
, y
+ cxsep
);
1490 lpBand
->rcBand
.bottom
= bottomy
;
1491 lpBand
->uMinHeight
= lpBand
->lcy
;
1495 /* bound the right side if we have a bounding rectangle */
1496 rightx
= (lpRect
) ? min(clientcx
, x
+cxsep
+cx
) : x
+cxsep
+cx
;
1498 lpBand
->rcBand
.left
= min(rightx
, x
+ cxsep
);
1499 lpBand
->rcBand
.right
= rightx
;
1500 lpBand
->rcBand
.top
= y
;
1501 lpBand
->rcBand
.bottom
= y
+ min(mcy
,
1502 lpBand
->lcy
+REBARSPACE(lpBand
));
1503 lpBand
->uMinHeight
= lpBand
->lcy
;
1506 TRACE("P1 band %u, row %d, (%d,%d)-(%d,%d)\n",
1508 lpBand
->rcBand
.left
, lpBand
->rcBand
.top
,
1509 lpBand
->rcBand
.right
, lpBand
->rcBand
.bottom
);
1513 } /* for (i = 0; i < infoPtr->uNumBands... */
1515 if (infoPtr
->dwStyle
& CCS_VERT
)
1520 for (j
= rowstart
; j
< infoPtr
->uNumBands
; j
++) {
1521 lpBand
= &infoPtr
->bands
[j
];
1522 if (infoPtr
->dwStyle
& CCS_VERT
) {
1523 lpBand
->rcBand
.right
= lpBand
->rcBand
.left
+ mcy
;
1526 lpBand
->rcBand
.bottom
= lpBand
->rcBand
.top
+ mcy
;
1530 if (infoPtr
->uNumBands
)
1531 infoPtr
->uNumRows
= row
;
1533 /* ******* End Phase 1 - all bands on row at minimum size ******* */
1536 /* ******* Start Phase 1a - Adjust heights for RBS_VARHEIGHT off ******* */
1539 if (!(infoPtr
->dwStyle
& RBS_VARHEIGHT
)) {
1542 /* get the max height of all bands */
1543 for (i
=0; i
<infoPtr
->uNumBands
; i
++) {
1544 lpBand
= &infoPtr
->bands
[i
];
1545 if (HIDDENBAND(lpBand
)) continue;
1546 if (infoPtr
->dwStyle
& CCS_VERT
)
1547 mmcy
= max(mmcy
, lpBand
->rcBand
.right
- lpBand
->rcBand
.left
);
1549 mmcy
= max(mmcy
, lpBand
->rcBand
.bottom
- lpBand
->rcBand
.top
);
1552 /* now adjust all rectangles by using the height found above */
1555 for (i
=0; i
<infoPtr
->uNumBands
; i
++) {
1556 lpBand
= &infoPtr
->bands
[i
];
1557 if (HIDDENBAND(lpBand
)) continue;
1558 if (lpBand
->iRow
!= row
)
1559 xy
+= (mmcy
+ SEP_WIDTH
);
1560 if (infoPtr
->dwStyle
& CCS_VERT
) {
1561 lpBand
->rcBand
.left
= xy
;
1562 lpBand
->rcBand
.right
= xy
+ mmcy
;
1565 lpBand
->rcBand
.top
= xy
;
1566 lpBand
->rcBand
.bottom
= xy
+ mmcy
;
1570 /* set the x/y values to the correct maximum */
1571 if (infoPtr
->dwStyle
& CCS_VERT
)
1577 /* ******* End Phase 1a - Adjust heights for RBS_VARHEIGHT off ******* */
1580 /* ******* Start Phase 2 - split rows till adjustment height full ******* */
1582 /* assumes that the following variables contain: */
1583 /* y/x current height/width of all rows */
1585 INT i
, j
, prev_rh
, new_rh
, adj_rh
, prev_idx
, current_idx
;
1586 REBAR_BAND
*prev
, *current
, *walk
;
1588 /* FIXME: problem # 2 */
1589 if (((infoPtr
->dwStyle
& CCS_VERT
) ?
1591 (x
< adjcx
) : (y
< adjcy
)
1593 (adjcx
- x
> 4) : (adjcy
- y
> 4)
1596 (infoPtr
->uNumBands
> 1)) {
1597 for (i
=(INT
)infoPtr
->uNumBands
-2; i
>=0; i
--) {
1598 TRACE("P2 adjcx=%d, adjcy=%d, x=%d, y=%d\n",
1599 adjcx
, adjcy
, x
, y
);
1601 /* find the current band (starts at i+1) */
1602 current
= &infoPtr
->bands
[i
+1];
1604 while (HIDDENBAND(current
)) {
1606 if (i
< 0) break; /* out of bands */
1607 current
= &infoPtr
->bands
[i
+1];
1610 if (i
< 0) break; /* out of bands */
1612 /* now find the prev band (starts at i) */
1613 prev
= &infoPtr
->bands
[i
];
1615 while (HIDDENBAND(prev
)) {
1617 if (i
< 0) break; /* out of bands */
1618 prev
= &infoPtr
->bands
[i
];
1621 if (i
< 0) break; /* out of bands */
1623 prev_rh
= ircBw(prev
);
1624 if (prev
->iRow
== current
->iRow
) {
1625 new_rh
= (infoPtr
->dwStyle
& RBS_VARHEIGHT
) ?
1626 current
->lcy
+ REBARSPACE(current
) :
1628 adj_rh
= new_rh
+ SEP_WIDTH
;
1629 infoPtr
->uNumRows
++;
1630 current
->fDraw
|= NTF_INVALIDATE
;
1632 if (infoPtr
->dwStyle
& CCS_VERT
) {
1633 current
->rcBand
.top
= inity
;
1634 current
->rcBand
.bottom
= clientcy
;
1635 current
->rcBand
.left
+= (prev_rh
+ SEP_WIDTH
);
1636 current
->rcBand
.right
= current
->rcBand
.left
+ new_rh
;
1640 current
->rcBand
.left
= initx
;
1641 current
->rcBand
.right
= clientcx
;
1642 current
->rcBand
.top
+= (prev_rh
+ SEP_WIDTH
);
1643 current
->rcBand
.bottom
= current
->rcBand
.top
+ new_rh
;
1646 TRACE("P2 moving band %d to own row at (%d,%d)-(%d,%d)\n",
1648 current
->rcBand
.left
, current
->rcBand
.top
,
1649 current
->rcBand
.right
, current
->rcBand
.bottom
);
1650 TRACE("P2 prev band %d at (%d,%d)-(%d,%d)\n",
1652 prev
->rcBand
.left
, prev
->rcBand
.top
,
1653 prev
->rcBand
.right
, prev
->rcBand
.bottom
);
1654 TRACE("P2 values: prev_rh=%d, new_rh=%d, adj_rh=%d\n",
1655 prev_rh
, new_rh
, adj_rh
);
1656 /* for bands below current adjust row # and top/bottom */
1657 for (j
= current_idx
+1; j
<infoPtr
->uNumBands
; j
++) {
1658 walk
= &infoPtr
->bands
[j
];
1659 if (HIDDENBAND(walk
)) continue;
1660 walk
->fDraw
|= NTF_INVALIDATE
;
1662 if (infoPtr
->dwStyle
& CCS_VERT
) {
1663 walk
->rcBand
.left
+= adj_rh
;
1664 walk
->rcBand
.right
+= adj_rh
;
1667 walk
->rcBand
.top
+= adj_rh
;
1668 walk
->rcBand
.bottom
+= adj_rh
;
1671 if ((infoPtr
->dwStyle
& CCS_VERT
) ? (x
>= adjcx
) : (y
>= adjcy
))
1672 break; /* all done */
1678 /* ******* End Phase 2 - split rows till adjustment height full ******* */
1681 /* ******* Start Phase 2a - create array of start and end ******* */
1682 /* indexes by row */
1684 if (infoPtr
->uNumRows
!= origrows
) {
1685 if (infoPtr
->rows
) COMCTL32_Free (infoPtr
->rows
);
1686 infoPtr
->rows
= COMCTL32_Alloc (sizeof (REBAR_ROW
) * infoPtr
->uNumRows
);
1690 for (i
= 0; i
< infoPtr
->uNumBands
; i
++) {
1691 lpBand
= &infoPtr
->bands
[i
];
1692 if (HIDDENBAND(lpBand
)) continue;
1694 if (lpBand
->iRow
> row
) {
1696 infoPtr
->rows
[row
-1].istartband
= i
;
1699 ERR("P2a bug!!!!!!\n");
1701 infoPtr
->rows
[row
-1].iendband
= i
;
1704 for (i
= 0; i
< infoPtr
->uNumRows
; i
++) {
1707 p
= &infoPtr
->rows
[i
];
1708 TRACE("P2a row %d, starts %d, ends %d\n",
1709 i
+1, p
->istartband
, p
->iendband
);
1712 /* ******* End Phase 2a - create array of start and end ******* */
1713 /* indexes by row */
1716 /* ******* Start Phase 2b - adjust all bands for height full ******* */
1717 /* assumes that the following variables contain: */
1718 /* y/x current height/width of all rows */
1719 /* clientcy/clientcx height/width of client area */
1721 if (((infoPtr
->dwStyle
& CCS_VERT
) ? clientcx
> x
: clientcy
> y
) &&
1722 infoPtr
->uNumBands
) {
1723 INT diff
, i
, iband
, j
;
1725 diff
= (infoPtr
->dwStyle
& CCS_VERT
) ? clientcx
- x
: clientcy
- y
;
1726 for (i
= infoPtr
->uNumRows
; i
>= 1; i
--) {
1727 /* if row has more than 1 band, ignore row */
1728 if (infoPtr
->rows
[i
-1].istartband
!= infoPtr
->rows
[i
-1].iendband
)
1730 /* point to only band in row */
1731 iband
= infoPtr
->rows
[i
-1].istartband
;
1732 lpBand
= &infoPtr
->bands
[iband
];
1733 if(HIDDENBAND(lpBand
)) continue;
1734 if (!(lpBand
->fMask
& RBBS_VARIABLEHEIGHT
)) continue;
1735 if (((INT
)lpBand
->cyMaxChild
< 1) ||
1736 ((INT
)lpBand
->cyIntegral
< 1)) {
1737 if (lpBand
->cyMaxChild
+ lpBand
->cyIntegral
== 0) continue;
1738 ERR("P2b band %u RBBS_VARIABLEHEIGHT set but cyMax=%d, cyInt=%d\n",
1739 iband
, lpBand
->cyMaxChild
, lpBand
->cyIntegral
);
1742 /* j is now the maximum height/width in the client area */
1743 j
= ((diff
/ lpBand
->cyIntegral
) * lpBand
->cyIntegral
) +
1745 if (j
> lpBand
->cyMaxChild
+ REBARSPACE(lpBand
))
1746 j
= lpBand
->cyMaxChild
+ REBARSPACE(lpBand
);
1747 diff
-= (j
- ircBw(lpBand
));
1748 if (infoPtr
->dwStyle
& CCS_VERT
)
1749 lpBand
->rcBand
.right
= lpBand
->rcBand
.left
+ j
;
1751 lpBand
->rcBand
.bottom
= lpBand
->rcBand
.top
+ j
;
1752 TRACE("P2b band %d, row %d changed to (%d,%d)-(%d,%d)\n",
1753 iband
, lpBand
->iRow
,
1754 lpBand
->rcBand
.left
, lpBand
->rcBand
.top
,
1755 lpBand
->rcBand
.right
, lpBand
->rcBand
.bottom
);
1756 if (diff
<= 0) break;
1759 ERR("P2b allocated more than available, diff=%d\n", diff
);
1762 if (infoPtr
->dwStyle
& CCS_VERT
)
1763 x
= clientcx
- diff
;
1765 y
= clientcy
- diff
;
1768 /* ******* End Phase 2b - adjust all bands for height full ******* */
1771 /* ******* Start Phase 3 - adjust all bands for width full ******* */
1773 if (infoPtr
->uNumBands
) {
1776 /* If RBS_BANDBORDERS set then indicate to draw bottom separator */
1777 /* on all bands in all rows but last row. */
1778 /* Also indicate to draw the right separator for each band in */
1779 /* each row but the rightmost band. */
1780 if (infoPtr
->dwStyle
& RBS_BANDBORDERS
) {
1782 for(i
= 0; i
< infoPtr
->uNumRows
; i
++) {
1783 p
= &infoPtr
->rows
[i
];
1784 for (j
= p
->istartband
; j
<= p
->iendband
; j
++) {
1785 lpBand
= &infoPtr
->bands
[j
];
1786 if (HIDDENBAND(lpBand
)) continue;
1787 if (j
!= p
->iendband
)
1788 lpBand
->fDraw
|= DRAW_RIGHTSEP
;
1789 if (i
!= infoPtr
->uNumRows
-1)
1790 lpBand
->fDraw
|= DRAW_BOTTOMSEP
;
1795 /* Distribute the extra space on the horizontal and adjust */
1796 /* all bands in row to same height. */
1797 for (i
=1; i
<=infoPtr
->uNumRows
; i
++) {
1798 p
= &infoPtr
->rows
[i
-1];
1801 TRACE("P3 processing row %d, starting band %d, ending band %d\n",
1802 i
, p
->istartband
, p
->iendband
);
1804 /* Find the largest height of the bands in the row */
1805 for (j
= p
->istartband
; j
<= p
->iendband
; j
++) {
1806 lpBand
= &infoPtr
->bands
[j
];
1807 if (HIDDENBAND(lpBand
)) continue;
1808 if (mcy
< ircBw(lpBand
))
1809 mcy
= ircBw(lpBand
);
1812 REBAR_AdjustBands (infoPtr
, p
->istartband
, p
->iendband
,
1813 (infoPtr
->dwStyle
& CCS_VERT
) ?
1814 clientcy
: clientcx
, mcy
);
1817 /* Calculate the other rectangles in each band */
1818 if (infoPtr
->dwStyle
& CCS_VERT
) {
1819 REBAR_CalcVertBand (infoPtr
, 0, infoPtr
->uNumBands
,
1823 REBAR_CalcHorzBand (infoPtr
, 0, infoPtr
->uNumBands
,
1828 /* ******* End Phase 3 - adjust all bands for width full ******* */
1830 /* now compute size of Rebar itself */
1831 infoPtr
->oldSize
= infoPtr
->calcSize
;
1832 if (infoPtr
->uNumBands
== 0) {
1833 /* we have no bands, so make size the size of client */
1837 if (infoPtr
->dwStyle
& CCS_VERT
) {
1838 infoPtr
->calcSize
.cx
= x
;
1839 infoPtr
->calcSize
.cy
= clientcy
;
1840 TRACE("vert, notify=%d, x=%d, origheight=%d\n",
1841 notify
, x
, origheight
);
1842 if (notify
&& (x
!= origheight
)) infoPtr
->fStatus
|= NTF_HGHTCHG
;
1845 infoPtr
->calcSize
.cx
= clientcx
;
1846 infoPtr
->calcSize
.cy
= y
;
1847 TRACE("horz, notify=%d, y=%d, origheight=%d\n",
1848 notify
, y
, origheight
);
1849 if (notify
&& (y
!= origheight
)) infoPtr
->fStatus
|= NTF_HGHTCHG
;
1852 REBAR_DumpBand (infoPtr
);
1854 REBAR_MoveChildWindows (infoPtr
, 0, infoPtr
->uNumBands
);
1856 REBAR_ForceResize (infoPtr
);
1861 REBAR_ValidateBand (REBAR_INFO
*infoPtr
, REBAR_BAND
*lpBand
)
1862 /* Function: This routine evaluates the band specs supplied */
1863 /* by the user and updates the following 5 fields in */
1864 /* the internal band structure: cxHeader, lcx, lcy, hcx, hcy*/
1871 lpBand
->fStatus
= 0;
1879 /* Data comming in from users into the cx... and cy... fields */
1880 /* may be bad, just garbage, because the user never clears */
1881 /* the fields. RB_{SET|INSERT}BAND{A|W} just passes the data */
1882 /* along if the fields exist in the input area. Here we must */
1883 /* determine if the data is valid. I have no idea how MS does */
1884 /* the validation, but it does because the RB_GETBANDINFO */
1885 /* returns a 0 when I know the sample program passed in an */
1886 /* address. Here I will use the algorithim that if the value */
1887 /* is greater than 65535 then it is bad and replace it with */
1888 /* a zero. Feel free to improve the algorithim. - GA 12/2000 */
1889 if (lpBand
->cxMinChild
> 65535) lpBand
->cxMinChild
= 0;
1890 if (lpBand
->cyMinChild
> 65535) lpBand
->cyMinChild
= 0;
1891 if (lpBand
->cx
> 65535) lpBand
->cx
= 0;
1892 if (lpBand
->cyChild
> 65535) lpBand
->cyChild
= 0;
1893 if (lpBand
->cyMaxChild
> 65535) lpBand
->cyMaxChild
= 0;
1894 if (lpBand
->cyIntegral
> 65535) lpBand
->cyIntegral
= 0;
1895 if (lpBand
->cxIdeal
> 65535) lpBand
->cxIdeal
= 0;
1896 if (lpBand
->cxHeader
> 65535) lpBand
->cxHeader
= 0;
1898 /* FIXME: probably should only set NEEDS_LAYOUT flag when */
1899 /* values change. Till then always set it. */
1900 TRACE("setting NEEDS_LAYOUT\n");
1901 infoPtr
->fStatus
|= BAND_NEEDS_LAYOUT
;
1903 /* Header is where the image, text and gripper exist */
1904 /* in the band and preceed the child window. */
1906 /* count number of non-FIXEDSIZE and non-Hidden bands */
1908 for (i
=0; i
<infoPtr
->uNumBands
; i
++){
1909 tBand
= &infoPtr
->bands
[i
];
1910 if (!HIDDENBAND(tBand
) && !(tBand
->fStyle
& RBBS_FIXEDSIZE
))
1914 /* calculate gripper rectangle */
1915 if ( (!(lpBand
->fStyle
& RBBS_NOGRIPPER
)) &&
1916 ( (lpBand
->fStyle
& RBBS_GRIPPERALWAYS
) ||
1917 ( !(lpBand
->fStyle
& RBBS_FIXEDSIZE
) && (nonfixed
> 1)))
1919 lpBand
->fStatus
|= HAS_GRIPPER
;
1920 if (infoPtr
->dwStyle
& CCS_VERT
)
1921 if (infoPtr
->dwStyle
& RBS_VERTICALGRIPPER
)
1922 header
+= (GRIPPER_HEIGHT
+ REBAR_PRE_GRIPPER
);
1924 header
+= (GRIPPER_WIDTH
+ REBAR_PRE_GRIPPER
);
1926 header
+= (REBAR_PRE_GRIPPER
+ GRIPPER_WIDTH
);
1927 /* Always have 4 pixels before anything else */
1928 header
+= REBAR_ALWAYS_SPACE
;
1931 /* image is visible */
1932 if ((lpBand
->fMask
& RBBIM_IMAGE
) && (infoPtr
->himl
)) {
1933 lpBand
->fStatus
|= HAS_IMAGE
;
1934 if (infoPtr
->dwStyle
& CCS_VERT
) {
1935 header
+= (infoPtr
->imageSize
.cy
+ REBAR_POST_IMAGE
);
1936 lpBand
->lcy
= infoPtr
->imageSize
.cx
+ 2;
1939 header
+= (infoPtr
->imageSize
.cx
+ REBAR_POST_IMAGE
);
1940 lpBand
->lcy
= infoPtr
->imageSize
.cy
+ 2;
1944 /* text is visible */
1945 if ((lpBand
->fMask
& RBBIM_TEXT
) && (lpBand
->lpText
)) {
1946 HDC hdc
= GetDC (0);
1947 HFONT hOldFont
= SelectObject (hdc
, infoPtr
->hFont
);
1950 lpBand
->fStatus
|= HAS_TEXT
;
1951 GetTextExtentPoint32W (hdc
, lpBand
->lpText
,
1952 lstrlenW (lpBand
->lpText
), &size
);
1953 header
+= ((infoPtr
->dwStyle
& CCS_VERT
) ? (size
.cy
+ REBAR_POST_TEXT
) : (size
.cx
+ REBAR_POST_TEXT
));
1954 textheight
= (infoPtr
->dwStyle
& CCS_VERT
) ? 0 : size
.cy
;
1956 SelectObject (hdc
, hOldFont
);
1960 /* if no gripper but either image or text, then leave space */
1961 if ((lpBand
->fStatus
& (HAS_IMAGE
| HAS_TEXT
)) &&
1962 !(lpBand
->fStatus
& HAS_GRIPPER
)) {
1963 header
+= REBAR_ALWAYS_SPACE
;
1966 /* check if user overrode the header value */
1967 if (!(lpBand
->fMask
& RBBIM_HEADERSIZE
))
1968 lpBand
->cxHeader
= header
;
1971 /* Now compute minimum size of child window */
1972 lpBand
->offChild
.cx
= 0;
1973 lpBand
->offChild
.cy
= 0;
1974 lpBand
->lcy
= textheight
;
1975 lpBand
->ccy
= lpBand
->lcy
;
1976 if (lpBand
->fMask
& RBBIM_CHILDSIZE
) {
1977 lpBand
->lcx
= lpBand
->cxMinChild
;
1979 /* Set the .cy values for CHILDSIZE case */
1980 lpBand
->lcy
= max(lpBand
->lcy
, lpBand
->cyMinChild
);
1981 lpBand
->ccy
= lpBand
->lcy
;
1982 lpBand
->hcy
= lpBand
->lcy
;
1983 if (lpBand
->cyMaxChild
!= 0xffffffff) {
1984 lpBand
->hcy
= lpBand
->cyMaxChild
;
1986 if (lpBand
->cyChild
!= 0xffffffff)
1987 lpBand
->ccy
= max (lpBand
->cyChild
, lpBand
->lcy
);
1989 TRACE("_CHILDSIZE\n");
1991 if (lpBand
->fMask
& RBBIM_SIZE
) {
1992 lpBand
->hcx
= max (lpBand
->cx
-lpBand
->cxHeader
, lpBand
->lcx
);
1996 lpBand
->hcx
= lpBand
->lcx
;
1997 lpBand
->ccx
= lpBand
->hcx
;
1999 /* make ->.cx include header size for _Layout */
2000 lpBand
->lcx
+= lpBand
->cxHeader
;
2001 lpBand
->ccx
+= lpBand
->cxHeader
;
2002 lpBand
->hcx
+= lpBand
->cxHeader
;
2007 REBAR_CommonSetupBand (HWND hwnd
, LPREBARBANDINFOA lprbbi
, REBAR_BAND
*lpBand
)
2008 /* Function: This routine copies the supplied values from */
2009 /* user input (lprbbi) to the internal band structure. */
2011 lpBand
->fMask
|= lprbbi
->fMask
;
2013 if (lprbbi
->fMask
& RBBIM_STYLE
)
2014 lpBand
->fStyle
= lprbbi
->fStyle
;
2016 if (lprbbi
->fMask
& RBBIM_COLORS
) {
2017 lpBand
->clrFore
= lprbbi
->clrFore
;
2018 lpBand
->clrBack
= lprbbi
->clrBack
;
2021 if (lprbbi
->fMask
& RBBIM_IMAGE
)
2022 lpBand
->iImage
= lprbbi
->iImage
;
2024 if (lprbbi
->fMask
& RBBIM_CHILD
) {
2025 if (lprbbi
->hwndChild
) {
2026 lpBand
->hwndChild
= lprbbi
->hwndChild
;
2027 lpBand
->hwndPrevParent
=
2028 SetParent (lpBand
->hwndChild
, hwnd
);
2029 /* below in trace fro WinRAR */
2030 ShowWindow(lpBand
->hwndChild
, SW_SHOWNOACTIVATE
| SW_SHOWNORMAL
);
2031 /* above in trace fro WinRAR */
2034 TRACE("child: 0x%x prev parent: 0x%x\n",
2035 lpBand
->hwndChild
, lpBand
->hwndPrevParent
);
2036 lpBand
->hwndChild
= 0;
2037 lpBand
->hwndPrevParent
= 0;
2041 if (lprbbi
->fMask
& RBBIM_CHILDSIZE
) {
2042 lpBand
->cxMinChild
= lprbbi
->cxMinChild
;
2043 lpBand
->cyMinChild
= lprbbi
->cyMinChild
;
2044 if (lprbbi
->cbSize
>= sizeof (REBARBANDINFOA
)) {
2045 lpBand
->cyChild
= lprbbi
->cyChild
;
2046 lpBand
->cyMaxChild
= lprbbi
->cyMaxChild
;
2047 lpBand
->cyIntegral
= lprbbi
->cyIntegral
;
2049 else { /* special case - these should be zeroed out since */
2050 /* RBBIM_CHILDSIZE added these in WIN32_IE >= 0x0400 */
2051 lpBand
->cyChild
= 0;
2052 lpBand
->cyMaxChild
= 0;
2053 lpBand
->cyIntegral
= 0;
2057 if (lprbbi
->fMask
& RBBIM_SIZE
)
2058 lpBand
->cx
= lprbbi
->cx
;
2060 if (lprbbi
->fMask
& RBBIM_BACKGROUND
)
2061 lpBand
->hbmBack
= lprbbi
->hbmBack
;
2063 if (lprbbi
->fMask
& RBBIM_ID
)
2064 lpBand
->wID
= lprbbi
->wID
;
2066 /* check for additional data */
2067 if (lprbbi
->cbSize
>= sizeof (REBARBANDINFOA
)) {
2068 if (lprbbi
->fMask
& RBBIM_IDEALSIZE
)
2069 lpBand
->cxIdeal
= lprbbi
->cxIdeal
;
2071 if (lprbbi
->fMask
& RBBIM_LPARAM
)
2072 lpBand
->lParam
= lprbbi
->lParam
;
2074 if (lprbbi
->fMask
& RBBIM_HEADERSIZE
)
2075 lpBand
->cxHeader
= lprbbi
->cxHeader
;
2080 REBAR_InternalEraseBkGnd (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
, RECT
*clip
)
2081 /* Function: This erases the background rectangle by drawing */
2082 /* each band with its background color (or the default) and */
2083 /* draws each bands right separator if necessary. The row */
2084 /* separators are drawn on the first band of the next row. */
2088 HDC hdc
= (HDC
)wParam
;
2090 COLORREF old
= CLR_NONE
, new;
2093 for(i
=0; i
<infoPtr
->uNumBands
; i
++) {
2094 lpBand
= &infoPtr
->bands
[i
];
2095 if (HIDDENBAND(lpBand
)) continue;
2097 /* draw band separator between rows */
2098 if (lpBand
->iRow
!= oldrow
) {
2099 oldrow
= lpBand
->iRow
;
2100 if (lpBand
->fDraw
& DRAW_BOTTOMSEP
) {
2102 rcRowSep
= lpBand
->rcBand
;
2103 if (infoPtr
->dwStyle
& CCS_VERT
) {
2104 rcRowSep
.right
+= SEP_WIDTH_SIZE
;
2105 rcRowSep
.bottom
= infoPtr
->calcSize
.cy
;
2106 DrawEdge (hdc
, &rcRowSep
, EDGE_ETCHED
, BF_RIGHT
);
2109 rcRowSep
.bottom
+= SEP_WIDTH_SIZE
;
2110 rcRowSep
.right
= infoPtr
->calcSize
.cx
;
2111 DrawEdge (hdc
, &rcRowSep
, EDGE_ETCHED
, BF_BOTTOM
);
2113 TRACE ("drawing band separator bottom (%d,%d)-(%d,%d)\n",
2114 rcRowSep
.left
, rcRowSep
.top
,
2115 rcRowSep
.right
, rcRowSep
.bottom
);
2119 /* draw band separator between bands in a row */
2120 if (lpBand
->fDraw
& DRAW_RIGHTSEP
) {
2122 rcSep
= lpBand
->rcBand
;
2123 if (infoPtr
->dwStyle
& CCS_VERT
) {
2124 rcSep
.bottom
+= SEP_WIDTH_SIZE
;
2125 DrawEdge (hdc
, &rcSep
, EDGE_ETCHED
, BF_BOTTOM
);
2128 rcSep
.right
+= SEP_WIDTH_SIZE
;
2129 DrawEdge (hdc
, &rcSep
, EDGE_ETCHED
, BF_RIGHT
);
2131 TRACE("drawing band separator right (%d,%d)-(%d,%d)\n",
2132 rcSep
.left
, rcSep
.top
, rcSep
.right
, rcSep
.bottom
);
2135 /* draw the actual background */
2136 if (lpBand
->clrBack
!= CLR_NONE
) {
2137 new = (lpBand
->clrBack
== CLR_DEFAULT
) ? infoPtr
->clrBtnFace
:
2140 /* testing only - make background green to see it */
2143 old
= SetBkColor (hdc
, new);
2146 rect
= lpBand
->rcBand
;
2147 TRACE("%s background color=0x%06lx, band (%d,%d)-(%d,%d), clip (%d,%d)-(%d,%d)\n",
2148 (lpBand
->clrBack
== CLR_NONE
) ? "none" :
2149 ((lpBand
->clrBack
== CLR_DEFAULT
) ? "dft" : ""),
2151 lpBand
->rcBand
.left
,lpBand
->rcBand
.top
,
2152 lpBand
->rcBand
.right
,lpBand
->rcBand
.bottom
,
2153 clip
->left
, clip
->top
,
2154 clip
->right
, clip
->bottom
);
2155 ExtTextOutA (hdc
, 0, 0, ETO_OPAQUE
, &rect
, NULL
, 0, 0);
2156 if (lpBand
->clrBack
!= CLR_NONE
)
2157 SetBkColor (hdc
, old
);
2163 REBAR_InternalHitTest (REBAR_INFO
*infoPtr
, LPPOINT lpPt
, UINT
*pFlags
, INT
*pBand
)
2169 GetClientRect (infoPtr
->hwndSelf
, &rect
);
2171 *pFlags
= RBHT_NOWHERE
;
2172 if (PtInRect (&rect
, *lpPt
))
2174 if (infoPtr
->uNumBands
== 0) {
2175 *pFlags
= RBHT_NOWHERE
;
2182 /* somewhere inside */
2183 infoPtr
->ihitBand
= -1;
2184 for (iCount
= 0; iCount
< infoPtr
->uNumBands
; iCount
++) {
2185 lpBand
= &infoPtr
->bands
[iCount
];
2186 if (HIDDENBAND(lpBand
)) continue;
2187 if (PtInRect (&lpBand
->rcBand
, *lpPt
)) {
2190 if (PtInRect (&lpBand
->rcGripper
, *lpPt
)) {
2191 *pFlags
= RBHT_GRABBER
;
2192 infoPtr
->ihitBand
= iCount
;
2193 TRACE("ON GRABBER %d\n", iCount
);
2196 else if (PtInRect (&lpBand
->rcCapImage
, *lpPt
)) {
2197 *pFlags
= RBHT_CAPTION
;
2198 TRACE("ON CAPTION %d\n", iCount
);
2201 else if (PtInRect (&lpBand
->rcCapText
, *lpPt
)) {
2202 *pFlags
= RBHT_CAPTION
;
2203 TRACE("ON CAPTION %d\n", iCount
);
2206 else if (PtInRect (&lpBand
->rcChild
, *lpPt
)) {
2207 *pFlags
= RBHT_CLIENT
;
2208 TRACE("ON CLIENT %d\n", iCount
);
2212 *pFlags
= RBHT_NOWHERE
;
2213 TRACE("NOWHERE %d\n", iCount
);
2219 *pFlags
= RBHT_NOWHERE
;
2228 *pFlags
= RBHT_NOWHERE
;
2235 TRACE("flags=0x%X\n", *pFlags
);
2241 REBAR_Shrink (REBAR_INFO
*infoPtr
, REBAR_BAND
*band
, INT movement
, INT i
)
2242 /* Function: This attempts to shrink the given band by the */
2243 /* the amount in "movement". A shrink to the left is indi- */
2244 /* cated by "movement" being negative. "i" is merely the */
2245 /* band index for trace messages. */
2247 INT Leadjust
, Readjust
, avail
, ret
;
2249 /* Note: a left drag is indicated by "movement" being negative. */
2250 /* Similarly, a right drag is indicated by "movement" */
2251 /* being positive. "movement" should never be 0, but if */
2252 /* it is then the band does not move. */
2254 avail
= rcBw(band
) - band
->lcx
;
2256 /* now compute the Left End adjustment factor and Right End */
2257 /* adjustment factor. They may be different if shrinking. */
2259 /* if this band is not shrinkable, then just move it */
2260 Leadjust
= Readjust
= movement
;
2266 if (avail
<= abs(movement
)) {
2267 Readjust
= movement
;
2268 Leadjust
= movement
+ avail
;
2272 Readjust
= movement
;
2279 if (avail
<= abs(movement
)) {
2280 Leadjust
= movement
;
2281 Readjust
= movement
- avail
;
2285 Leadjust
= movement
;
2292 /* Reasonability Check */
2293 if (rcBlt(band
) + Leadjust
< 0) {
2294 ERR("adjustment will fail, band %d: left=%d, right=%d, move=%d, rtn=%d\n",
2295 i
, Leadjust
, Readjust
, movement
, ret
);
2298 LEADJ(band
, Leadjust
);
2299 READJ(band
, Readjust
);
2301 TRACE("band %d: left=%d, right=%d, move=%d, rtn=%d, rcBand=(%d,%d)-(%d,%d)\n",
2302 i
, Leadjust
, Readjust
, movement
, ret
,
2303 band
->rcBand
.left
, band
->rcBand
.top
,
2304 band
->rcBand
.right
, band
->rcBand
.bottom
);
2310 REBAR_HandleLRDrag (REBAR_INFO
*infoPtr
, POINTS
*ptsmove
)
2311 /* Function: This will implement the functionality of a */
2312 /* Gripper drag within a row. It will not implement "out- */
2313 /* of-row" drags. (They are detected and handled in */
2314 /* REBAR_MouseMove.) */
2315 /* **** FIXME Switching order of bands in a row not **** */
2316 /* **** yet implemented. **** */
2318 REBAR_BAND
*hitBand
, *band
, *mindBand
, *maxdBand
;
2320 INT imindBand
= -1, imaxdBand
, ihitBand
, i
, movement
;
2321 INT RHeaderSum
= 0, LHeaderSum
= 0;
2324 /* on first significant mouse movement, issue notify */
2326 if (!(infoPtr
->fStatus
& BEGIN_DRAG_ISSUED
)) {
2327 if (REBAR_Notify_NMREBAR (infoPtr
, -1, RBN_BEGINDRAG
)) {
2328 /* Notify returned TRUE - abort drag */
2329 infoPtr
->dragStart
.x
= 0;
2330 infoPtr
->dragStart
.y
= 0;
2331 infoPtr
->dragNow
= infoPtr
->dragStart
;
2332 infoPtr
->ihitBand
= -1;
2336 infoPtr
->fStatus
|= BEGIN_DRAG_ISSUED
;
2339 ihitBand
= infoPtr
->ihitBand
;
2340 hitBand
= &infoPtr
->bands
[ihitBand
];
2341 imaxdBand
= ihitBand
; /* to suppress warning message */
2343 /* find all the bands in the row of the one whose Gripper was seized */
2344 for (i
=0; i
<infoPtr
->uNumBands
; i
++) {
2345 band
= &infoPtr
->bands
[i
];
2346 if (HIDDENBAND(band
)) continue;
2347 if (band
->iRow
== hitBand
->iRow
) {
2349 if (imindBand
== -1) imindBand
= i
;
2350 /* minimum size of each band is size of header plus */
2351 /* size of minimum child plus offset of child from header plus */
2352 /* a one to separate each band. */
2354 LHeaderSum
+= (band
->lcx
+ SEP_WIDTH
);
2356 RHeaderSum
+= (band
->lcx
+ SEP_WIDTH
);
2360 if (RHeaderSum
) RHeaderSum
-= SEP_WIDTH
; /* no separator afterlast band */
2362 mindBand
= &infoPtr
->bands
[imindBand
];
2363 maxdBand
= &infoPtr
->bands
[imaxdBand
];
2365 if (imindBand
== imaxdBand
) return; /* nothing to drag agains */
2366 if (imindBand
== ihitBand
) return; /* first band in row, cant drag */
2368 /* limit movement to inside adjustable bands - Left */
2369 if ( (ptsmove
->x
< mindBand
->rcBand
.left
) ||
2370 (ptsmove
->x
> maxdBand
->rcBand
.right
) ||
2371 (ptsmove
->y
< mindBand
->rcBand
.top
) ||
2372 (ptsmove
->y
> maxdBand
->rcBand
.bottom
))
2373 return; /* should swap bands */
2375 if (infoPtr
->dwStyle
& CCS_VERT
)
2376 movement
= ptsmove
->y
- ((hitBand
->rcBand
.top
+REBAR_PRE_GRIPPER
) -
2377 infoPtr
->ihitoffset
);
2379 movement
= ptsmove
->x
- ((hitBand
->rcBand
.left
+REBAR_PRE_GRIPPER
) -
2380 infoPtr
->ihitoffset
);
2381 infoPtr
->dragNow
= *ptsmove
;
2383 TRACE("before: movement=%d (%d,%d), imindBand=%d, ihitBand=%d, imaxdBand=%d, LSum=%d, RSum=%d\n",
2384 movement
, ptsmove
->x
, ptsmove
->y
, imindBand
, ihitBand
,
2385 imaxdBand
, LHeaderSum
, RHeaderSum
);
2386 REBAR_DumpBand (infoPtr
);
2390 /* *** Drag left/up *** */
2391 compress
= rcBlt(hitBand
) - rcBlt(mindBand
) -
2393 if (compress
< abs(movement
)) {
2394 TRACE("limiting left drag, was %d changed to %d\n",
2395 movement
, -compress
);
2396 movement
= -compress
;
2399 for (i
=ihitBand
; i
>=imindBand
; i
--) {
2400 band
= &infoPtr
->bands
[i
];
2401 if (HIDDENBAND(band
)) continue;
2402 if (i
== ihitBand
) {
2403 LEADJ(band
, movement
)
2406 movement
= REBAR_Shrink (infoPtr
, band
, movement
, i
);
2407 band
->ccx
= rcBw(band
);
2413 /* *** Drag right/down *** */
2414 compress
= rcBrb(maxdBand
) - rcBlt(hitBand
) -
2416 if (compress
< abs(movement
)) {
2417 TRACE("limiting right drag, was %d changed to %d\n",
2418 movement
, compress
);
2419 movement
= compress
;
2421 for (i
=ihitBand
-1; i
<=imaxdBand
; i
++) {
2422 band
= &infoPtr
->bands
[i
];
2423 if (HIDDENBAND(band
)) continue;
2426 READJ(band
, movement
)
2429 movement
= REBAR_Shrink (infoPtr
, band
, movement
, i
);
2430 band
->ccx
= rcBw(band
);
2434 /* recompute all rectangles */
2435 if (infoPtr
->dwStyle
& CCS_VERT
) {
2436 REBAR_CalcVertBand (infoPtr
, imindBand
, imaxdBand
+1,
2440 REBAR_CalcHorzBand (infoPtr
, imindBand
, imaxdBand
+1,
2444 TRACE("bands after adjustment, see band # %d, %d\n",
2445 imindBand
, imaxdBand
);
2446 REBAR_DumpBand (infoPtr
);
2449 mindBand
->rcBand
.left
,
2450 mindBand
->rcBand
.top
,
2451 maxdBand
->rcBand
.right
,
2452 maxdBand
->rcBand
.bottom
);
2454 REBAR_MoveChildWindows (infoPtr
, imindBand
, imaxdBand
+1);
2456 InvalidateRect (infoPtr
->hwndSelf
, &newrect
, TRUE
);
2457 UpdateWindow (infoPtr
->hwndSelf
);
2463 /* << REBAR_BeginDrag >> */
2467 REBAR_DeleteBand (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
2469 UINT uBand
= (UINT
)wParam
;
2473 if (uBand
>= infoPtr
->uNumBands
)
2476 TRACE("deleting band %u!\n", uBand
);
2477 lpBand
= &infoPtr
->bands
[uBand
];
2478 REBAR_Notify_NMREBAR (infoPtr
, uBand
, RBN_DELETINGBAND
);
2480 if (infoPtr
->uNumBands
== 1) {
2481 TRACE(" simple delete!\n");
2482 if ((lpBand
->fMask
& RBBIM_CHILD
) && lpBand
->hwndChild
)
2483 childhwnd
= lpBand
->hwndChild
;
2484 COMCTL32_Free (infoPtr
->bands
);
2485 infoPtr
->bands
= NULL
;
2486 infoPtr
->uNumBands
= 0;
2489 REBAR_BAND
*oldBands
= infoPtr
->bands
;
2490 TRACE("complex delete! [uBand=%u]\n", uBand
);
2492 if ((lpBand
->fMask
& RBBIM_CHILD
) && lpBand
->hwndChild
)
2493 childhwnd
= lpBand
->hwndChild
;
2495 infoPtr
->uNumBands
--;
2496 infoPtr
->bands
= COMCTL32_Alloc (sizeof (REBAR_BAND
) * infoPtr
->uNumBands
);
2498 memcpy (&infoPtr
->bands
[0], &oldBands
[0],
2499 uBand
* sizeof(REBAR_BAND
));
2502 if (uBand
< infoPtr
->uNumBands
) {
2503 memcpy (&infoPtr
->bands
[uBand
], &oldBands
[uBand
+1],
2504 (infoPtr
->uNumBands
- uBand
) * sizeof(REBAR_BAND
));
2507 COMCTL32_Free (oldBands
);
2511 ShowWindow (childhwnd
, SW_HIDE
);
2513 REBAR_Notify_NMREBAR (infoPtr
, -1, RBN_DELETEDBAND
);
2515 /* if only 1 band left the re-validate to possible eliminate gripper */
2516 if (infoPtr
->uNumBands
== 1)
2517 REBAR_ValidateBand (infoPtr
, &infoPtr
->bands
[0]);
2519 TRACE("setting NEEDS_LAYOUT\n");
2520 infoPtr
->fStatus
|= BAND_NEEDS_LAYOUT
;
2521 infoPtr
->fStatus
|= RESIZE_ANYHOW
;
2522 REBAR_Layout (infoPtr
, NULL
, TRUE
, FALSE
);
2528 /* << REBAR_DragMove >> */
2529 /* << REBAR_EndDrag >> */
2533 REBAR_GetBandBorders (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
2535 LPRECT lpRect
= (LPRECT
)lParam
;
2540 if ((UINT
)wParam
>= infoPtr
->uNumBands
)
2543 lpBand
= &infoPtr
->bands
[(UINT
)wParam
];
2545 /* FIXME - the following values were determined by experimentation */
2546 /* with the REBAR Control Spy. I have guesses as to what the 4 and */
2547 /* 1 are, but I am not sure. There doesn't seem to be any actual */
2548 /* difference in size of the control area with and without the */
2550 if (infoPtr
->dwStyle
& RBS_BANDBORDERS
) {
2551 if (infoPtr
->dwStyle
& CCS_VERT
) {
2553 lpRect
->top
= lpBand
->cxHeader
+ 4;
2558 lpRect
->left
= lpBand
->cxHeader
+ 4;
2565 lpRect
->left
= lpBand
->cxHeader
;
2571 inline static LRESULT
2572 REBAR_GetBandCount (REBAR_INFO
*infoPtr
)
2574 TRACE("band count %u!\n", infoPtr
->uNumBands
);
2576 return infoPtr
->uNumBands
;
2581 REBAR_GetBandInfoA (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
2583 LPREBARBANDINFOA lprbbi
= (LPREBARBANDINFOA
)lParam
;
2588 if (lprbbi
->cbSize
< REBARBANDINFO_V3_SIZEA
)
2590 if ((UINT
)wParam
>= infoPtr
->uNumBands
)
2593 TRACE("index %u\n", (UINT
)wParam
);
2595 /* copy band information */
2596 lpBand
= &infoPtr
->bands
[(UINT
)wParam
];
2598 if (lprbbi
->fMask
& RBBIM_STYLE
)
2599 lprbbi
->fStyle
= lpBand
->fStyle
;
2601 if (lprbbi
->fMask
& RBBIM_COLORS
) {
2602 lprbbi
->clrFore
= lpBand
->clrFore
;
2603 lprbbi
->clrBack
= lpBand
->clrBack
;
2604 if (lprbbi
->clrBack
== CLR_DEFAULT
)
2605 lprbbi
->clrBack
= infoPtr
->clrBtnFace
;
2608 if ((lprbbi
->fMask
& RBBIM_TEXT
) && (lprbbi
->lpText
)) {
2609 if (lpBand
->lpText
&& (lpBand
->fMask
& RBBIM_TEXT
))
2611 if (!WideCharToMultiByte( CP_ACP
, 0, lpBand
->lpText
, -1,
2612 lprbbi
->lpText
, lprbbi
->cch
, NULL
, NULL
))
2613 lprbbi
->lpText
[lprbbi
->cch
-1] = 0;
2616 *lprbbi
->lpText
= 0;
2619 if (lprbbi
->fMask
& RBBIM_IMAGE
) {
2620 if (lpBand
->fMask
& RBBIM_IMAGE
)
2621 lprbbi
->iImage
= lpBand
->iImage
;
2623 lprbbi
->iImage
= -1;
2626 if (lprbbi
->fMask
& RBBIM_CHILD
)
2627 lprbbi
->hwndChild
= lpBand
->hwndChild
;
2629 if (lprbbi
->fMask
& RBBIM_CHILDSIZE
) {
2630 lprbbi
->cxMinChild
= lpBand
->cxMinChild
;
2631 lprbbi
->cyMinChild
= lpBand
->cyMinChild
;
2632 if (lprbbi
->cbSize
>= sizeof (REBARBANDINFOA
)) {
2633 lprbbi
->cyChild
= lpBand
->cyChild
;
2634 lprbbi
->cyMaxChild
= lpBand
->cyMaxChild
;
2635 lprbbi
->cyIntegral
= lpBand
->cyIntegral
;
2639 if (lprbbi
->fMask
& RBBIM_SIZE
)
2640 lprbbi
->cx
= lpBand
->cx
;
2642 if (lprbbi
->fMask
& RBBIM_BACKGROUND
)
2643 lprbbi
->hbmBack
= lpBand
->hbmBack
;
2645 if (lprbbi
->fMask
& RBBIM_ID
)
2646 lprbbi
->wID
= lpBand
->wID
;
2648 /* check for additional data */
2649 if (lprbbi
->cbSize
>= sizeof (REBARBANDINFOA
)) {
2650 if (lprbbi
->fMask
& RBBIM_IDEALSIZE
)
2651 lprbbi
->cxIdeal
= lpBand
->cxIdeal
;
2653 if (lprbbi
->fMask
& RBBIM_LPARAM
)
2654 lprbbi
->lParam
= lpBand
->lParam
;
2656 if (lprbbi
->fMask
& RBBIM_HEADERSIZE
)
2657 lprbbi
->cxHeader
= lpBand
->cxHeader
;
2660 REBAR_DumpBandInfo (lprbbi
);
2667 REBAR_GetBandInfoW (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
2669 LPREBARBANDINFOW lprbbi
= (LPREBARBANDINFOW
)lParam
;
2674 if (lprbbi
->cbSize
< REBARBANDINFO_V3_SIZEW
)
2676 if ((UINT
)wParam
>= infoPtr
->uNumBands
)
2679 TRACE("index %u\n", (UINT
)wParam
);
2681 /* copy band information */
2682 lpBand
= &infoPtr
->bands
[(UINT
)wParam
];
2684 if (lprbbi
->fMask
& RBBIM_STYLE
)
2685 lprbbi
->fStyle
= lpBand
->fStyle
;
2687 if (lprbbi
->fMask
& RBBIM_COLORS
) {
2688 lprbbi
->clrFore
= lpBand
->clrFore
;
2689 lprbbi
->clrBack
= lpBand
->clrBack
;
2690 if (lprbbi
->clrBack
== CLR_DEFAULT
)
2691 lprbbi
->clrBack
= infoPtr
->clrBtnFace
;
2694 if ((lprbbi
->fMask
& RBBIM_TEXT
) && (lprbbi
->lpText
)) {
2695 if (lpBand
->lpText
&& (lpBand
->fMask
& RBBIM_TEXT
))
2696 lstrcpynW (lprbbi
->lpText
, lpBand
->lpText
, lprbbi
->cch
);
2698 *lprbbi
->lpText
= 0;
2701 if (lprbbi
->fMask
& RBBIM_IMAGE
) {
2702 if (lpBand
->fMask
& RBBIM_IMAGE
)
2703 lprbbi
->iImage
= lpBand
->iImage
;
2705 lprbbi
->iImage
= -1;
2708 if (lprbbi
->fMask
& RBBIM_CHILD
)
2709 lprbbi
->hwndChild
= lpBand
->hwndChild
;
2711 if (lprbbi
->fMask
& RBBIM_CHILDSIZE
) {
2712 lprbbi
->cxMinChild
= lpBand
->cxMinChild
;
2713 lprbbi
->cyMinChild
= lpBand
->cyMinChild
;
2714 if (lprbbi
->cbSize
>= sizeof (REBARBANDINFOW
)) {
2715 lprbbi
->cyChild
= lpBand
->cyChild
;
2716 lprbbi
->cyMaxChild
= lpBand
->cyMaxChild
;
2717 lprbbi
->cyIntegral
= lpBand
->cyIntegral
;
2721 if (lprbbi
->fMask
& RBBIM_SIZE
)
2722 lprbbi
->cx
= lpBand
->cx
;
2724 if (lprbbi
->fMask
& RBBIM_BACKGROUND
)
2725 lprbbi
->hbmBack
= lpBand
->hbmBack
;
2727 if (lprbbi
->fMask
& RBBIM_ID
)
2728 lprbbi
->wID
= lpBand
->wID
;
2730 /* check for additional data */
2731 if (lprbbi
->cbSize
>= sizeof (REBARBANDINFOW
)) {
2732 if (lprbbi
->fMask
& RBBIM_IDEALSIZE
)
2733 lprbbi
->cxIdeal
= lpBand
->cxIdeal
;
2735 if (lprbbi
->fMask
& RBBIM_LPARAM
)
2736 lprbbi
->lParam
= lpBand
->lParam
;
2738 if (lprbbi
->fMask
& RBBIM_HEADERSIZE
)
2739 lprbbi
->cxHeader
= lpBand
->cxHeader
;
2742 REBAR_DumpBandInfo ((LPREBARBANDINFOA
)lprbbi
);
2749 REBAR_GetBarHeight (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
2753 nHeight
= (infoPtr
->dwStyle
& CCS_VERT
) ? infoPtr
->calcSize
.cx
: infoPtr
->calcSize
.cy
;
2755 TRACE("height = %d\n", nHeight
);
2762 REBAR_GetBarInfo (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
2764 LPREBARINFO lpInfo
= (LPREBARINFO
)lParam
;
2769 if (lpInfo
->cbSize
< sizeof (REBARINFO
))
2772 TRACE("getting bar info!\n");
2774 if (infoPtr
->himl
) {
2775 lpInfo
->himl
= infoPtr
->himl
;
2776 lpInfo
->fMask
|= RBIM_IMAGELIST
;
2783 inline static LRESULT
2784 REBAR_GetBkColor (REBAR_INFO
*infoPtr
)
2786 COLORREF clr
= infoPtr
->clrBk
;
2788 if (clr
== CLR_DEFAULT
)
2789 clr
= infoPtr
->clrBtnFace
;
2791 TRACE("background color 0x%06lx!\n", clr
);
2797 /* << REBAR_GetColorScheme >> */
2798 /* << REBAR_GetDropTarget >> */
2802 REBAR_GetPalette (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
2804 FIXME("empty stub!\n");
2811 REBAR_GetRect (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
2813 INT iBand
= (INT
)wParam
;
2814 LPRECT lprc
= (LPRECT
)lParam
;
2817 if ((iBand
< 0) && ((UINT
)iBand
>= infoPtr
->uNumBands
))
2822 lpBand
= &infoPtr
->bands
[iBand
];
2823 CopyRect (lprc
, &lpBand
->rcBand
);
2825 TRACE("band %d, (%d,%d)-(%d,%d)\n", iBand
,
2826 lprc
->left
, lprc
->top
, lprc
->right
, lprc
->bottom
);
2832 inline static LRESULT
2833 REBAR_GetRowCount (REBAR_INFO
*infoPtr
)
2835 TRACE("%u\n", infoPtr
->uNumRows
);
2837 return infoPtr
->uNumRows
;
2842 REBAR_GetRowHeight (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
2844 INT iRow
= (INT
)wParam
;
2849 for (i
=0; i
<infoPtr
->uNumBands
; i
++) {
2850 lpBand
= &infoPtr
->bands
[i
];
2851 if (HIDDENBAND(lpBand
)) continue;
2852 if (lpBand
->iRow
!= iRow
) continue;
2853 if (infoPtr
->dwStyle
& CCS_VERT
)
2854 j
= lpBand
->rcBand
.right
- lpBand
->rcBand
.left
;
2856 j
= lpBand
->rcBand
.bottom
- lpBand
->rcBand
.top
;
2857 if (j
> ret
) ret
= j
;
2860 TRACE("row %d, height %d\n", iRow
, ret
);
2866 inline static LRESULT
2867 REBAR_GetTextColor (REBAR_INFO
*infoPtr
)
2869 TRACE("text color 0x%06lx!\n", infoPtr
->clrText
);
2871 return infoPtr
->clrText
;
2875 inline static LRESULT
2876 REBAR_GetToolTips (REBAR_INFO
*infoPtr
)
2878 return infoPtr
->hwndToolTip
;
2882 inline static LRESULT
2883 REBAR_GetUnicodeFormat (REBAR_INFO
*infoPtr
)
2885 TRACE("%s hwnd=0x%x\n",
2886 infoPtr
->bUnicode
? "TRUE" : "FALSE", infoPtr
->hwndSelf
);
2888 return infoPtr
->bUnicode
;
2892 inline static LRESULT
2893 REBAR_GetVersion (REBAR_INFO
*infoPtr
)
2895 TRACE("version %d\n", infoPtr
->iVersion
);
2896 return infoPtr
->iVersion
;
2901 REBAR_HitTest (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
2903 LPRBHITTESTINFO lprbht
= (LPRBHITTESTINFO
)lParam
;
2908 REBAR_InternalHitTest (infoPtr
, &lprbht
->pt
, &lprbht
->flags
, &lprbht
->iBand
);
2910 return lprbht
->iBand
;
2915 REBAR_IdToIndex (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
2919 if (infoPtr
== NULL
)
2922 if (infoPtr
->uNumBands
< 1)
2925 for (i
= 0; i
< infoPtr
->uNumBands
; i
++) {
2926 if (infoPtr
->bands
[i
].wID
== (UINT
)wParam
) {
2927 TRACE("id %u is band %u found!\n", (UINT
)wParam
, i
);
2932 TRACE("id %u is not found\n", (UINT
)wParam
);
2938 REBAR_InsertBandA (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
2940 LPREBARBANDINFOA lprbbi
= (LPREBARBANDINFOA
)lParam
;
2941 UINT uIndex
= (UINT
)wParam
;
2944 if (infoPtr
== NULL
)
2948 if (lprbbi
->cbSize
< REBARBANDINFO_V3_SIZEA
)
2951 /* trace the index as signed to see the -1 */
2952 TRACE("insert band at %d!\n", (INT
)uIndex
);
2953 REBAR_DumpBandInfo (lprbbi
);
2955 if (infoPtr
->uNumBands
== 0) {
2956 infoPtr
->bands
= (REBAR_BAND
*)COMCTL32_Alloc (sizeof (REBAR_BAND
));
2960 REBAR_BAND
*oldBands
= infoPtr
->bands
;
2962 (REBAR_BAND
*)COMCTL32_Alloc ((infoPtr
->uNumBands
+1)*sizeof(REBAR_BAND
));
2963 if (((INT
)uIndex
== -1) || (uIndex
> infoPtr
->uNumBands
))
2964 uIndex
= infoPtr
->uNumBands
;
2966 /* pre insert copy */
2968 memcpy (&infoPtr
->bands
[0], &oldBands
[0],
2969 uIndex
* sizeof(REBAR_BAND
));
2973 if (uIndex
< infoPtr
->uNumBands
- 1) {
2974 memcpy (&infoPtr
->bands
[uIndex
+1], &oldBands
[uIndex
],
2975 (infoPtr
->uNumBands
- uIndex
- 1) * sizeof(REBAR_BAND
));
2978 COMCTL32_Free (oldBands
);
2981 infoPtr
->uNumBands
++;
2983 TRACE("index %u!\n", uIndex
);
2985 /* initialize band (infoPtr->bands[uIndex])*/
2986 lpBand
= &infoPtr
->bands
[uIndex
];
2988 lpBand
->fStatus
= 0;
2989 lpBand
->clrFore
= infoPtr
->clrText
;
2990 lpBand
->clrBack
= infoPtr
->clrBk
;
2991 lpBand
->hwndChild
= 0;
2992 lpBand
->hwndPrevParent
= 0;
2994 REBAR_CommonSetupBand (infoPtr
->hwndSelf
, lprbbi
, lpBand
);
2995 lpBand
->lpText
= NULL
;
2996 if ((lprbbi
->fMask
& RBBIM_TEXT
) && (lprbbi
->lpText
)) {
2997 INT len
= MultiByteToWideChar( CP_ACP
, 0, lprbbi
->lpText
, -1, NULL
, 0 );
2999 lpBand
->lpText
= (LPWSTR
)COMCTL32_Alloc (len
*sizeof(WCHAR
));
3000 MultiByteToWideChar( CP_ACP
, 0, lprbbi
->lpText
, -1, lpBand
->lpText
, len
);
3004 REBAR_ValidateBand (infoPtr
, lpBand
);
3005 /* On insert of second band, revalidate band 1 to possible add gripper */
3006 if (infoPtr
->uNumBands
== 2)
3007 REBAR_ValidateBand (infoPtr
, &infoPtr
->bands
[0]);
3009 REBAR_DumpBand (infoPtr
);
3011 REBAR_Layout (infoPtr
, NULL
, TRUE
, FALSE
);
3012 InvalidateRect(infoPtr
->hwndSelf
, 0, 1);
3019 REBAR_InsertBandW (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
3021 LPREBARBANDINFOW lprbbi
= (LPREBARBANDINFOW
)lParam
;
3022 UINT uIndex
= (UINT
)wParam
;
3025 if (infoPtr
== NULL
)
3029 if (lprbbi
->cbSize
< REBARBANDINFO_V3_SIZEW
)
3032 /* trace the index as signed to see the -1 */
3033 TRACE("insert band at %d!\n", (INT
)uIndex
);
3034 REBAR_DumpBandInfo ((LPREBARBANDINFOA
)lprbbi
);
3036 if (infoPtr
->uNumBands
== 0) {
3037 infoPtr
->bands
= (REBAR_BAND
*)COMCTL32_Alloc (sizeof (REBAR_BAND
));
3041 REBAR_BAND
*oldBands
= infoPtr
->bands
;
3043 (REBAR_BAND
*)COMCTL32_Alloc ((infoPtr
->uNumBands
+1)*sizeof(REBAR_BAND
));
3044 if (((INT
)uIndex
== -1) || (uIndex
> infoPtr
->uNumBands
))
3045 uIndex
= infoPtr
->uNumBands
;
3047 /* pre insert copy */
3049 memcpy (&infoPtr
->bands
[0], &oldBands
[0],
3050 uIndex
* sizeof(REBAR_BAND
));
3054 if (uIndex
< infoPtr
->uNumBands
- 1) {
3055 memcpy (&infoPtr
->bands
[uIndex
+1], &oldBands
[uIndex
],
3056 (infoPtr
->uNumBands
- uIndex
- 1) * sizeof(REBAR_BAND
));
3059 COMCTL32_Free (oldBands
);
3062 infoPtr
->uNumBands
++;
3064 TRACE("index %u!\n", uIndex
);
3066 /* initialize band (infoPtr->bands[uIndex])*/
3067 lpBand
= &infoPtr
->bands
[uIndex
];
3069 lpBand
->fStatus
= 0;
3070 lpBand
->clrFore
= infoPtr
->clrText
;
3071 lpBand
->clrBack
= infoPtr
->clrBk
;
3072 lpBand
->hwndChild
= 0;
3073 lpBand
->hwndPrevParent
= 0;
3075 REBAR_CommonSetupBand (infoPtr
->hwndSelf
, (LPREBARBANDINFOA
)lprbbi
, lpBand
);
3076 lpBand
->lpText
= NULL
;
3077 if ((lprbbi
->fMask
& RBBIM_TEXT
) && (lprbbi
->lpText
)) {
3078 INT len
= lstrlenW (lprbbi
->lpText
);
3080 lpBand
->lpText
= (LPWSTR
)COMCTL32_Alloc ((len
+ 1)*sizeof(WCHAR
));
3081 strcpyW (lpBand
->lpText
, lprbbi
->lpText
);
3085 REBAR_ValidateBand (infoPtr
, lpBand
);
3086 /* On insert of second band, revalidate band 1 to possible add gripper */
3087 if (infoPtr
->uNumBands
== 2)
3088 REBAR_ValidateBand (infoPtr
, &infoPtr
->bands
[0]);
3090 REBAR_DumpBand (infoPtr
);
3092 REBAR_Layout (infoPtr
, NULL
, TRUE
, FALSE
);
3093 InvalidateRect(infoPtr
->hwndSelf
, 0, 1);
3100 REBAR_MaximizeBand (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
3103 UINT uBand
= (UINT
) wParam
;
3106 if ((infoPtr
->uNumBands
== 0) ||
3107 ((INT
)uBand
< 0) || (uBand
>= infoPtr
->uNumBands
)) {
3109 ERR("Illegal MaximizeBand, requested=%d, current band count=%d\n",
3110 (INT
)uBand
, infoPtr
->uNumBands
);
3114 lpBand
= &infoPtr
->bands
[uBand
];
3116 if (lParam
&& (lpBand
->fMask
& RBBIM_IDEALSIZE
)) {
3117 /* handle setting ideal size */
3118 lpBand
->ccx
= lpBand
->cxIdeal
;
3121 /* handle setting to max */
3122 FIXME("(uBand = %u fIdeal = %s) case not coded\n",
3123 (UINT
)wParam
, lParam
? "TRUE" : "FALSE");
3127 infoPtr
->fStatus
|= BAND_NEEDS_LAYOUT
;
3128 REBAR_Layout (infoPtr
, 0, TRUE
, TRUE
);
3129 InvalidateRect (infoPtr
->hwndSelf
, 0, TRUE
);
3137 REBAR_MinimizeBand (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
3139 REBAR_BAND
*band
, *lpBand
;
3140 UINT uBand
= (UINT
) wParam
;
3142 INT imindBand
, imaxdBand
, iprevBand
, startBand
, endBand
;
3145 /* A "minimize" band is equivalent to "dragging" the gripper
3146 * of than band to the right till the band is only the size
3151 if ((infoPtr
->uNumBands
== 0) ||
3152 ((INT
)uBand
< 0) || (uBand
>= infoPtr
->uNumBands
)) {
3154 ERR("Illegal MinimizeBand, requested=%d, current band count=%d\n",
3155 (INT
)uBand
, infoPtr
->uNumBands
);
3159 /* compute amount of movement and validate */
3160 lpBand
= &infoPtr
->bands
[uBand
];
3162 if (infoPtr
->dwStyle
& CCS_VERT
)
3163 movement
= lpBand
->rcBand
.bottom
- lpBand
->rcBand
.top
-
3166 movement
= lpBand
->rcBand
.right
- lpBand
->rcBand
.left
-
3169 ERR("something is wrong, band=(%d,%d)-(%d,%d), cxheader=%d\n",
3170 lpBand
->rcBand
.left
, lpBand
->rcBand
.top
,
3171 lpBand
->rcBand
.right
, lpBand
->rcBand
.bottom
,
3178 iprevBand
= -1; /* to suppress warning message */
3180 /* find the first band in row of the one whose is being minimized */
3181 for (i
=0; i
<infoPtr
->uNumBands
; i
++) {
3182 band
= &infoPtr
->bands
[i
];
3183 if (HIDDENBAND(band
)) continue;
3184 if (band
->iRow
== lpBand
->iRow
) {
3186 if (imindBand
== -1) imindBand
= i
;
3190 /* if the selected band is first in row then need to expand */
3191 /* next visible band */
3192 if (imindBand
== uBand
) {
3194 movement
= -movement
;
3195 /* find the first visible band to the right of the selected band */
3196 for (i
=uBand
+1; i
<=imaxdBand
; i
++) {
3197 band
= &infoPtr
->bands
[i
];
3198 if (!HIDDENBAND(band
)) {
3200 LEADJ(band
, movement
);
3201 band
->ccx
= rcBw(band
);
3205 /* what case is this */
3206 if (iprevBand
== -1) {
3207 ERR("no previous visible band\n");
3211 endBand
= iprevBand
;
3213 lpBand
->rcBand
.left
,
3216 band
->rcBand
.bottom
);
3218 /* otherwise expand previous visible band */
3221 /* find the first visible band to the left of the selected band */
3222 for (i
=uBand
-1; i
>=imindBand
; i
--) {
3223 band
= &infoPtr
->bands
[i
];
3224 if (!HIDDENBAND(band
)) {
3226 READJ(band
, movement
);
3227 band
->ccx
= rcBw(band
);
3231 /* what case is this */
3232 if (iprevBand
== -1) {
3233 ERR("no previous visible band\n");
3236 startBand
= iprevBand
;
3241 lpBand
->rcBand
.right
,
3242 lpBand
->rcBand
.bottom
);
3245 REBAR_Shrink (infoPtr
, lpBand
, movement
, uBand
);
3247 /* recompute all rectangles */
3248 if (infoPtr
->dwStyle
& CCS_VERT
) {
3249 REBAR_CalcVertBand (infoPtr
, startBand
, endBand
+1,
3253 REBAR_CalcHorzBand (infoPtr
, startBand
, endBand
+1,
3257 TRACE("bands after minimize, see band # %d, %d\n",
3258 startBand
, endBand
);
3259 REBAR_DumpBand (infoPtr
);
3261 REBAR_MoveChildWindows (infoPtr
, startBand
, endBand
+1);
3263 InvalidateRect (infoPtr
->hwndSelf
, &newrect
, TRUE
);
3264 UpdateWindow (infoPtr
->hwndSelf
);
3270 REBAR_MoveBand (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
3272 REBAR_BAND
*oldBands
= infoPtr
->bands
;
3274 UINT uFrom
= (UINT
)wParam
;
3275 UINT uTo
= (UINT
)lParam
;
3278 if ((infoPtr
->uNumBands
== 0) ||
3279 ((INT
)uFrom
< 0) || (uFrom
>= infoPtr
->uNumBands
) ||
3280 ((INT
)uTo
< 0) || (uTo
>= infoPtr
->uNumBands
)) {
3282 ERR("Illegal MoveBand, from=%d, to=%d, current band count=%d\n",
3283 (INT
)uFrom
, (INT
)uTo
, infoPtr
->uNumBands
);
3287 /* save one to be moved */
3288 memcpy (&holder
, &oldBands
[uFrom
], sizeof(REBAR_BAND
));
3290 /* close up rest of bands (psuedo delete) */
3291 if (uFrom
< infoPtr
->uNumBands
- 1) {
3292 memcpy (&oldBands
[uFrom
], &oldBands
[uFrom
+1],
3293 (infoPtr
->uNumBands
- uFrom
- 1) * sizeof(REBAR_BAND
));
3296 /* allocate new space and copy rest of bands into it */
3298 (REBAR_BAND
*)COMCTL32_Alloc ((infoPtr
->uNumBands
)*sizeof(REBAR_BAND
));
3300 /* pre insert copy */
3302 memcpy (&infoPtr
->bands
[0], &oldBands
[0],
3303 uTo
* sizeof(REBAR_BAND
));
3306 /* set moved band */
3307 memcpy (&infoPtr
->bands
[uTo
], &holder
, sizeof(REBAR_BAND
));
3310 if (uTo
< infoPtr
->uNumBands
- 1) {
3311 memcpy (&infoPtr
->bands
[uTo
+1], &oldBands
[uTo
],
3312 (infoPtr
->uNumBands
- uTo
- 1) * sizeof(REBAR_BAND
));
3315 COMCTL32_Free (oldBands
);
3317 TRACE("moved band %d to index %d\n", uFrom
, uTo
);
3318 REBAR_DumpBand (infoPtr
);
3320 infoPtr
->fStatus
|= BAND_NEEDS_LAYOUT
;
3321 /* **************************************************** */
3323 /* We do not do a REBAR_Layout here because the native */
3324 /* control does not do that. The actual layout and */
3325 /* repaint is done by the *next* real action, ex.: */
3326 /* RB_INSERTBAND, RB_DELETEBAND, RB_SIZETORECT, etc. */
3328 /* **************************************************** */
3335 REBAR_SetBandInfoA (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
3337 LPREBARBANDINFOA lprbbi
= (LPREBARBANDINFOA
)lParam
;
3342 if (lprbbi
->cbSize
< REBARBANDINFO_V3_SIZEA
)
3344 if ((UINT
)wParam
>= infoPtr
->uNumBands
)
3347 TRACE("index %u\n", (UINT
)wParam
);
3348 REBAR_DumpBandInfo (lprbbi
);
3350 /* set band information */
3351 lpBand
= &infoPtr
->bands
[(UINT
)wParam
];
3353 REBAR_CommonSetupBand (infoPtr
->hwndSelf
, lprbbi
, lpBand
);
3354 if (lprbbi
->fMask
& RBBIM_TEXT
) {
3355 if (lpBand
->lpText
) {
3356 COMCTL32_Free (lpBand
->lpText
);
3357 lpBand
->lpText
= NULL
;
3359 if (lprbbi
->lpText
) {
3360 INT len
= MultiByteToWideChar( CP_ACP
, 0, lprbbi
->lpText
, -1, NULL
, 0 );
3361 lpBand
->lpText
= (LPWSTR
)COMCTL32_Alloc (len
*sizeof(WCHAR
));
3362 MultiByteToWideChar( CP_ACP
, 0, lprbbi
->lpText
, -1, lpBand
->lpText
, len
);
3366 REBAR_ValidateBand (infoPtr
, lpBand
);
3368 REBAR_DumpBand (infoPtr
);
3370 if (lprbbi
->fMask
& (RBBIM_CHILDSIZE
| RBBIM_SIZE
)) {
3371 REBAR_Layout (infoPtr
, NULL
, TRUE
, FALSE
);
3372 InvalidateRect(infoPtr
->hwndSelf
, 0, 1);
3380 REBAR_SetBandInfoW (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
3382 LPREBARBANDINFOW lprbbi
= (LPREBARBANDINFOW
)lParam
;
3387 if (lprbbi
->cbSize
< REBARBANDINFO_V3_SIZEW
)
3389 if ((UINT
)wParam
>= infoPtr
->uNumBands
)
3392 TRACE("index %u\n", (UINT
)wParam
);
3393 REBAR_DumpBandInfo ((LPREBARBANDINFOA
)lprbbi
);
3395 /* set band information */
3396 lpBand
= &infoPtr
->bands
[(UINT
)wParam
];
3398 REBAR_CommonSetupBand (infoPtr
->hwndSelf
, (LPREBARBANDINFOA
)lprbbi
, lpBand
);
3399 if (lprbbi
->fMask
& RBBIM_TEXT
) {
3400 if (lpBand
->lpText
) {
3401 COMCTL32_Free (lpBand
->lpText
);
3402 lpBand
->lpText
= NULL
;
3404 if (lprbbi
->lpText
) {
3405 INT len
= lstrlenW (lprbbi
->lpText
);
3406 lpBand
->lpText
= (LPWSTR
)COMCTL32_Alloc ((len
+ 1)*sizeof(WCHAR
));
3407 strcpyW (lpBand
->lpText
, lprbbi
->lpText
);
3411 REBAR_ValidateBand (infoPtr
, lpBand
);
3413 REBAR_DumpBand (infoPtr
);
3415 if (lprbbi
->fMask
& (RBBIM_CHILDSIZE
| RBBIM_SIZE
)) {
3416 REBAR_Layout (infoPtr
, NULL
, TRUE
, FALSE
);
3417 InvalidateRect(infoPtr
->hwndSelf
, 0, 1);
3425 REBAR_SetBarInfo (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
3427 LPREBARINFO lpInfo
= (LPREBARINFO
)lParam
;
3434 if (lpInfo
->cbSize
< sizeof (REBARINFO
))
3437 TRACE("setting bar info!\n");
3439 if (lpInfo
->fMask
& RBIM_IMAGELIST
) {
3440 infoPtr
->himl
= lpInfo
->himl
;
3441 if (infoPtr
->himl
) {
3443 ImageList_GetIconSize (infoPtr
->himl
, &cx
, &cy
);
3444 infoPtr
->imageSize
.cx
= cx
;
3445 infoPtr
->imageSize
.cy
= cy
;
3448 infoPtr
->imageSize
.cx
= 0;
3449 infoPtr
->imageSize
.cy
= 0;
3451 TRACE("new image cx=%ld, cy=%ld\n", infoPtr
->imageSize
.cx
,
3452 infoPtr
->imageSize
.cy
);
3455 /* revalidate all bands to reset flags for images in headers of bands */
3456 for (i
=0; i
<infoPtr
->uNumBands
; i
++) {
3457 lpBand
= &infoPtr
->bands
[i
];
3458 REBAR_ValidateBand (infoPtr
, lpBand
);
3466 REBAR_SetBkColor (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
3470 clrTemp
= infoPtr
->clrBk
;
3471 infoPtr
->clrBk
= (COLORREF
)lParam
;
3473 TRACE("background color 0x%06lx!\n", infoPtr
->clrBk
);
3479 /* << REBAR_SetColorScheme >> */
3480 /* << REBAR_SetPalette >> */
3484 REBAR_SetParent (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
3486 HWND hwndTemp
= infoPtr
->hwndNotify
;
3488 infoPtr
->hwndNotify
= (HWND
)wParam
;
3490 return (LRESULT
)hwndTemp
;
3495 REBAR_SetTextColor (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
3499 clrTemp
= infoPtr
->clrText
;
3500 infoPtr
->clrText
= (COLORREF
)lParam
;
3502 TRACE("text color 0x%06lx!\n", infoPtr
->clrText
);
3508 /* << REBAR_SetTooltips >> */
3511 inline static LRESULT
3512 REBAR_SetUnicodeFormat (REBAR_INFO
*infoPtr
, WPARAM wParam
)
3514 BOOL bTemp
= infoPtr
->bUnicode
;
3516 TRACE("to %s hwnd=0x%04x, was %s\n",
3517 ((BOOL
)wParam
) ? "TRUE" : "FALSE", infoPtr
->hwndSelf
,
3518 (bTemp
) ? "TRUE" : "FALSE");
3520 infoPtr
->bUnicode
= (BOOL
)wParam
;
3527 REBAR_SetVersion (REBAR_INFO
*infoPtr
, INT iVersion
)
3529 INT iOldVersion
= infoPtr
->iVersion
;
3531 if (iVersion
> COMCTL32_VERSION
)
3534 infoPtr
->iVersion
= iVersion
;
3536 TRACE("new version %d\n", iVersion
);
3543 REBAR_ShowBand (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
3547 if (((INT
)wParam
< 0) || ((INT
)wParam
> infoPtr
->uNumBands
))
3550 lpBand
= &infoPtr
->bands
[(INT
)wParam
];
3553 TRACE("show band %d\n", (INT
)wParam
);
3554 lpBand
->fStyle
= lpBand
->fStyle
& ~RBBS_HIDDEN
;
3555 if (IsWindow (lpBand
->hwndChild
))
3556 ShowWindow (lpBand
->hwndChild
, SW_SHOW
);
3559 TRACE("hide band %d\n", (INT
)wParam
);
3560 lpBand
->fStyle
= lpBand
->fStyle
| RBBS_HIDDEN
;
3561 if (IsWindow (lpBand
->hwndChild
))
3562 ShowWindow (lpBand
->hwndChild
, SW_HIDE
);
3565 REBAR_Layout (infoPtr
, NULL
, TRUE
, FALSE
);
3566 InvalidateRect(infoPtr
->hwndSelf
, 0, 1);
3573 REBAR_SizeToRect (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
3575 LPRECT lpRect
= (LPRECT
)lParam
;
3581 TRACE("[%d %d %d %d]\n",
3582 lpRect
->left
, lpRect
->top
, lpRect
->right
, lpRect
->bottom
);
3584 /* what is going on???? */
3585 GetWindowRect(infoPtr
->hwndSelf
, &t1
);
3586 TRACE("window rect [%d %d %d %d]\n",
3587 t1
.left
, t1
.top
, t1
.right
, t1
.bottom
);
3588 GetClientRect(infoPtr
->hwndSelf
, &t1
);
3589 TRACE("client rect [%d %d %d %d]\n",
3590 t1
.left
, t1
.top
, t1
.right
, t1
.bottom
);
3592 /* force full _Layout processing */
3593 TRACE("setting NEEDS_LAYOUT\n");
3594 infoPtr
->fStatus
|= BAND_NEEDS_LAYOUT
;
3595 REBAR_Layout (infoPtr
, lpRect
, TRUE
, FALSE
);
3596 InvalidateRect (infoPtr
->hwndSelf
, NULL
, TRUE
);
3603 REBAR_Create (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
3605 LPCREATESTRUCTA cs
= (LPCREATESTRUCTA
) lParam
;
3608 if (TRACE_ON(rebar
)) {
3609 GetWindowRect(infoPtr
->hwndSelf
, &wnrc1
);
3610 GetClientRect(infoPtr
->hwndSelf
, &clrc1
);
3611 TRACE("window=(%d,%d)-(%d,%d) client=(%d,%d)-(%d,%d) cs=(%d,%d %dx%d)\n",
3612 wnrc1
.left
, wnrc1
.top
, wnrc1
.right
, wnrc1
.bottom
,
3613 clrc1
.left
, clrc1
.top
, clrc1
.right
, clrc1
.bottom
,
3614 cs
->x
, cs
->y
, cs
->cx
, cs
->cy
);
3617 TRACE("created!\n");
3623 REBAR_Destroy (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
3629 /* free rebar bands */
3630 if ((infoPtr
->uNumBands
> 0) && infoPtr
->bands
) {
3631 /* clean up each band */
3632 for (i
= 0; i
< infoPtr
->uNumBands
; i
++) {
3633 lpBand
= &infoPtr
->bands
[i
];
3635 /* delete text strings */
3636 if (lpBand
->lpText
) {
3637 COMCTL32_Free (lpBand
->lpText
);
3638 lpBand
->lpText
= NULL
;
3640 /* destroy child window */
3641 DestroyWindow (lpBand
->hwndChild
);
3644 /* free band array */
3645 COMCTL32_Free (infoPtr
->bands
);
3646 infoPtr
->bands
= NULL
;
3649 DeleteObject (infoPtr
->hcurArrow
);
3650 DeleteObject (infoPtr
->hcurHorz
);
3651 DeleteObject (infoPtr
->hcurVert
);
3652 DeleteObject (infoPtr
->hcurDrag
);
3653 if(infoPtr
->hDefaultFont
) DeleteObject (infoPtr
->hDefaultFont
);
3654 SetWindowLongA (infoPtr
->hwndSelf
, 0, 0);
3656 /* free rebar info data */
3657 COMCTL32_Free (infoPtr
);
3658 TRACE("destroyed!\n");
3664 REBAR_EraseBkGnd (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
3668 if (GetClipBox ( (HDC
)wParam
, &cliprect
))
3669 return REBAR_InternalEraseBkGnd (infoPtr
, wParam
, lParam
, &cliprect
);
3675 REBAR_GetFont (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
3677 return (LRESULT
)infoPtr
->hFont
;
3682 REBAR_LButtonDown (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
3686 /* If InternalHitTest did not find a hit on the Gripper, */
3687 /* then ignore the button click. */
3688 if (infoPtr
->ihitBand
== -1) return 0;
3690 SetCapture (infoPtr
->hwndSelf
);
3692 /* save off the LOWORD and HIWORD of lParam as initial x,y */
3693 lpBand
= &infoPtr
->bands
[infoPtr
->ihitBand
];
3694 infoPtr
->dragStart
= MAKEPOINTS(lParam
);
3695 infoPtr
->dragNow
= infoPtr
->dragStart
;
3696 if (infoPtr
->dwStyle
& CCS_VERT
)
3697 infoPtr
->ihitoffset
= infoPtr
->dragStart
.y
- (lpBand
->rcBand
.top
+REBAR_PRE_GRIPPER
);
3699 infoPtr
->ihitoffset
= infoPtr
->dragStart
.x
- (lpBand
->rcBand
.left
+REBAR_PRE_GRIPPER
);
3706 REBAR_LButtonUp (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
3712 /* If InternalHitTest did not find a hit on the Gripper, */
3713 /* then ignore the button click. */
3714 if (infoPtr
->ihitBand
== -1) return 0;
3716 ihitBand
= infoPtr
->ihitBand
;
3717 infoPtr
->dragStart
.x
= 0;
3718 infoPtr
->dragStart
.y
= 0;
3719 infoPtr
->dragNow
= infoPtr
->dragStart
;
3720 infoPtr
->ihitBand
= -1;
3724 if (infoPtr
->fStatus
& BEGIN_DRAG_ISSUED
) {
3725 REBAR_Notify((NMHDR
*) &layout
, infoPtr
, RBN_LAYOUTCHANGED
);
3726 REBAR_Notify_NMREBAR (infoPtr
, ihitBand
, RBN_ENDDRAG
);
3727 infoPtr
->fStatus
&= ~BEGIN_DRAG_ISSUED
;
3730 GetClientRect(infoPtr
->hwndSelf
, &rect
);
3731 InvalidateRect(infoPtr
->hwndSelf
, NULL
, TRUE
);
3738 REBAR_MouseMove (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
3740 REBAR_BAND
*band1
, *band2
;
3743 /* Validate entry as hit on Gripper has occured */
3744 if (GetCapture() != infoPtr
->hwndSelf
) return 0;
3745 if (infoPtr
->ihitBand
== -1) return 0;
3747 ptsmove
= MAKEPOINTS(lParam
);
3749 /* if mouse did not move much, exit */
3750 if ((abs(ptsmove
.x
- infoPtr
->dragNow
.x
) <= mindragx
) &&
3751 (abs(ptsmove
.y
- infoPtr
->dragNow
.y
) <= mindragy
)) return 0;
3753 band1
= &infoPtr
->bands
[infoPtr
->ihitBand
-1];
3754 band2
= &infoPtr
->bands
[infoPtr
->ihitBand
];
3756 /* Test for valid drag case - must not be first band in row */
3757 if (infoPtr
->dwStyle
& CCS_VERT
) {
3758 if ((ptsmove
.x
< band2
->rcBand
.left
) ||
3759 (ptsmove
.x
> band2
->rcBand
.right
) ||
3760 ((infoPtr
->ihitBand
> 0) && (band1
->iRow
!= band2
->iRow
))) {
3761 FIXME("Cannot drag to other rows yet!!\n");
3764 REBAR_HandleLRDrag (infoPtr
, &ptsmove
);
3768 if ((ptsmove
.y
< band2
->rcBand
.top
) ||
3769 (ptsmove
.y
> band2
->rcBand
.bottom
) ||
3770 ((infoPtr
->ihitBand
> 0) && (band1
->iRow
!= band2
->iRow
))) {
3771 FIXME("Cannot drag to other rows yet!!\n");
3774 REBAR_HandleLRDrag (infoPtr
, &ptsmove
);
3781 inline static LRESULT
3782 REBAR_NCCalcSize (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
3784 if (infoPtr
->dwStyle
& WS_BORDER
) {
3785 InflateRect((LPRECT
)lParam
, -GetSystemMetrics(SM_CXEDGE
),
3786 -GetSystemMetrics(SM_CYEDGE
));
3788 TRACE("new client=(%d,%d)-(%d,%d)\n",
3789 ((LPRECT
)lParam
)->left
, ((LPRECT
)lParam
)->top
,
3790 ((LPRECT
)lParam
)->right
, ((LPRECT
)lParam
)->bottom
);
3796 REBAR_NCCreate (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3798 LPCREATESTRUCTA cs
= (LPCREATESTRUCTA
) lParam
;
3799 REBAR_INFO
*infoPtr
= REBAR_GetInfoPtr (hwnd
);
3801 NONCLIENTMETRICSA ncm
;
3805 if (infoPtr
!= NULL
) {
3806 ERR("Strange info structure pointer *not* NULL\n");
3810 if (TRACE_ON(rebar
)) {
3811 GetWindowRect(hwnd
, &wnrc1
);
3812 GetClientRect(hwnd
, &clrc1
);
3813 TRACE("window=(%d,%d)-(%d,%d) client=(%d,%d)-(%d,%d) cs=(%d,%d %dx%d)\n",
3814 wnrc1
.left
, wnrc1
.top
, wnrc1
.right
, wnrc1
.bottom
,
3815 clrc1
.left
, clrc1
.top
, clrc1
.right
, clrc1
.bottom
,
3816 cs
->x
, cs
->y
, cs
->cx
, cs
->cy
);
3819 /* allocate memory for info structure */
3820 infoPtr
= (REBAR_INFO
*)COMCTL32_Alloc (sizeof(REBAR_INFO
));
3821 SetWindowLongA (hwnd
, 0, (DWORD
)infoPtr
);
3823 /* initialize info structure - initial values are 0 */
3824 infoPtr
->clrBk
= CLR_NONE
;
3825 infoPtr
->clrText
= CLR_NONE
;
3826 infoPtr
->clrBtnText
= GetSysColor (COLOR_BTNTEXT
);
3827 infoPtr
->clrBtnFace
= GetSysColor (COLOR_BTNFACE
);
3828 infoPtr
->ihitBand
= -1;
3829 infoPtr
->hwndSelf
= hwnd
;
3830 infoPtr
->DoRedraw
= TRUE
;
3831 infoPtr
->hcurArrow
= LoadCursorA (0, IDC_ARROWA
);
3832 infoPtr
->hcurHorz
= LoadCursorA (0, IDC_SIZEWEA
);
3833 infoPtr
->hcurVert
= LoadCursorA (0, IDC_SIZENSA
);
3834 infoPtr
->hcurDrag
= LoadCursorA (0, IDC_SIZEA
);
3835 infoPtr
->bUnicode
= IsWindowUnicode (hwnd
);
3836 infoPtr
->fStatus
= CREATE_RUNNING
;
3837 infoPtr
->hFont
= GetStockObject (SYSTEM_FONT
);
3839 /* issue WM_NOTIFYFORMAT to get unicode status of parent */
3840 i
= SendMessageA(REBAR_GetNotifyParent (infoPtr
),
3841 WM_NOTIFYFORMAT
, hwnd
, NF_QUERY
);
3842 if ((i
< NFR_ANSI
) || (i
> NFR_UNICODE
)) {
3843 ERR("wrong response to WM_NOTIFYFORMAT (%d), assuming ANSI\n",
3847 infoPtr
->NtfUnicode
= (i
== NFR_UNICODE
) ? 1 : 0;
3849 /* add necessary styles to the requested styles */
3850 infoPtr
->dwStyle
= cs
->style
| WS_VISIBLE
| CCS_TOP
;
3851 SetWindowLongA (hwnd
, GWL_STYLE
, infoPtr
->dwStyle
);
3853 /* get font handle for Caption Font */
3854 ncm
.cbSize
= sizeof(NONCLIENTMETRICSA
);
3855 SystemParametersInfoA (SPI_GETNONCLIENTMETRICS
,
3856 ncm
.cbSize
, &ncm
, 0);
3857 /* if the font is bold, set to normal */
3858 if (ncm
.lfCaptionFont
.lfWeight
> FW_NORMAL
) {
3859 ncm
.lfCaptionFont
.lfWeight
= FW_NORMAL
;
3861 tfont
= CreateFontIndirectA (&ncm
.lfCaptionFont
);
3863 infoPtr
->hFont
= infoPtr
->hDefaultFont
= tfont
;
3867 GetSysColor (numerous);
3868 GetSysColorBrush (numerous) (see WM_SYSCOLORCHANGE);
3869 *GetStockObject (SYSTEM_FONT);
3870 *SetWindowLong (hwnd, 0, info ptr);
3872 *SetWindowLong (hwnd, GWL_STYLE, style+0x10000001);
3873 WS_VISIBLE = 0x10000000;
3874 CCS_TOP = 0x00000001;
3875 *SystemParametersInfo (SPI_GETNONCLIENTMETRICS...);
3876 *CreateFontIndirect (lfCaptionFont from above);
3878 SelectObject (hdc, fontabove);
3879 GetTextMetrics (hdc, ); guessing is tmHeight
3880 SelectObject (hdc, oldfont);
3883 MapWindowPoints (0, parent, rectabove, 2);
3886 ClientToScreen (clientrect);
3887 SetWindowPos (hwnd, 0, 0, 0, 0, 0, SWP_NOZORDER);
3894 REBAR_NCHitTest (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
3901 LRESULT ret
= HTCLIENT
;
3904 * Differences from doc at MSDN (as observed with version 4.71 of
3906 * 1. doc says nmmouse.pt is in screen coord, trace shows client coord.
3907 * 2. if band is not identified .dwItemSpec is 0xffffffff.
3908 * 3. native always seems to return HTCLIENT if notify return is 0.
3911 shortpt
= MAKEPOINTS (lParam
);
3912 POINTSTOPOINT(pt
, shortpt
);
3914 ScreenToClient (infoPtr
->hwndSelf
, &clpt
);
3915 REBAR_InternalHitTest (infoPtr
, &clpt
, &scrap
,
3916 (INT
*)&nmmouse
.dwItemSpec
);
3917 nmmouse
.dwItemData
= 0;
3919 nmmouse
.dwHitInfo
= 0;
3920 if ((i
= REBAR_Notify((NMHDR
*) &nmmouse
, infoPtr
, NM_NCHITTEST
))) {
3921 TRACE("notify changed return value from %ld to %d\n",
3925 TRACE("returning %ld, client point (%ld,%ld)\n", ret
, clpt
.x
, clpt
.y
);
3931 REBAR_NCPaint (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
3936 if (infoPtr
->dwStyle
& WS_MINIMIZE
)
3937 return 0; /* Nothing to do */
3939 if (infoPtr
->dwStyle
& WS_BORDER
) {
3941 /* adjust rectangle and draw the necessary edge */
3942 if (!(hdc
= GetDCEx( infoPtr
->hwndSelf
, 0, DCX_USESTYLE
| DCX_WINDOW
)))
3944 GetWindowRect (infoPtr
->hwndSelf
, &rcWindow
);
3945 OffsetRect (&rcWindow
, -rcWindow
.left
, -rcWindow
.top
);
3946 TRACE("rect (%d,%d)-(%d,%d)\n",
3947 rcWindow
.left
, rcWindow
.top
,
3948 rcWindow
.right
, rcWindow
.bottom
);
3949 DrawEdge (hdc
, &rcWindow
, EDGE_ETCHED
, BF_RECT
);
3950 ReleaseDC( infoPtr
->hwndSelf
, hdc
);
3958 REBAR_NotifyFormat (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
3962 if (lParam
== NF_REQUERY
) {
3963 i
= SendMessageA(REBAR_GetNotifyParent (infoPtr
),
3964 WM_NOTIFYFORMAT
, infoPtr
->hwndSelf
, NF_QUERY
);
3965 if ((i
< NFR_ANSI
) || (i
> NFR_UNICODE
)) {
3966 ERR("wrong response to WM_NOTIFYFORMAT (%d), assuming ANSI\n",
3970 infoPtr
->NtfUnicode
= (i
== NFR_UNICODE
) ? 1 : 0;
3973 return (LRESULT
)((infoPtr
->bUnicode
) ? NFR_UNICODE
: NFR_ANSI
);
3978 REBAR_Paint (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
3984 GetClientRect(infoPtr
->hwndSelf
, &rc
);
3985 hdc
= wParam
==0 ? BeginPaint (infoPtr
->hwndSelf
, &ps
) : (HDC
)wParam
;
3987 TRACE("painting (%d,%d)-(%d,%d) client (%d,%d)-(%d,%d)\n",
3988 ps
.rcPaint
.left
, ps
.rcPaint
.top
,
3989 ps
.rcPaint
.right
, ps
.rcPaint
.bottom
,
3990 rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
3993 /* Erase area of paint if requested */
3994 REBAR_InternalEraseBkGnd (infoPtr
, wParam
, lParam
, &ps
.rcPaint
);
3997 REBAR_Refresh (infoPtr
, hdc
);
3999 EndPaint (infoPtr
->hwndSelf
, &ps
);
4005 REBAR_SetCursor (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
4010 TRACE("code=0x%X id=0x%X\n", LOWORD(lParam
), HIWORD(lParam
));
4013 ScreenToClient (infoPtr
->hwndSelf
, &pt
);
4015 REBAR_InternalHitTest (infoPtr
, &pt
, &flags
, NULL
);
4017 if (flags
== RBHT_GRABBER
) {
4018 if ((infoPtr
->dwStyle
& CCS_VERT
) &&
4019 !(infoPtr
->dwStyle
& RBS_VERTICALGRIPPER
))
4020 SetCursor (infoPtr
->hcurVert
);
4022 SetCursor (infoPtr
->hcurHorz
);
4024 else if (flags
!= RBHT_CLIENT
)
4025 SetCursor (infoPtr
->hcurArrow
);
4032 REBAR_SetFont (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
4038 infoPtr
->hFont
= (HFONT
)wParam
;
4040 /* revalidate all bands to change sizes of text in headers of bands */
4041 for (i
=0; i
<infoPtr
->uNumBands
; i
++) {
4042 lpBand
= &infoPtr
->bands
[i
];
4043 REBAR_ValidateBand (infoPtr
, lpBand
);
4047 if (LOWORD(lParam
)) {
4048 GetClientRect (infoPtr
->hwndSelf
, &rcClient
);
4049 REBAR_Layout (infoPtr
, &rcClient
, FALSE
, TRUE
);
4056 inline static LRESULT
4057 REBAR_SetRedraw (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
4058 /*****************************************************
4061 * Handles the WM_SETREDRAW message.
4064 * According to testing V4.71 of COMCTL32 returns the
4065 * *previous* status of the redraw flag (either 0 or -1)
4066 * instead of the MSDN documented value of 0 if handled
4068 *****************************************************/
4070 BOOL oldredraw
= infoPtr
->DoRedraw
;
4072 TRACE("set to %s, fStatus=%08x\n",
4073 (wParam
) ? "TRUE" : "FALSE", infoPtr
->fStatus
);
4074 infoPtr
->DoRedraw
= (BOOL
) wParam
;
4076 if (infoPtr
->fStatus
& BAND_NEEDS_REDRAW
) {
4077 REBAR_MoveChildWindows (infoPtr
, 0, infoPtr
->uNumBands
);
4078 REBAR_ForceResize (infoPtr
);
4079 InvalidateRect (infoPtr
->hwndSelf
, 0, TRUE
);
4081 infoPtr
->fStatus
&= ~BAND_NEEDS_REDRAW
;
4083 return (oldredraw
) ? -1 : 0;
4088 REBAR_Size (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
4092 /* auto resize deadlock check */
4093 if (infoPtr
->fStatus
& AUTO_RESIZE
) {
4094 infoPtr
->fStatus
&= ~AUTO_RESIZE
;
4095 TRACE("AUTO_RESIZE was set, reset, fStatus=%08x lparam=%08lx\n",
4096 infoPtr
->fStatus
, lParam
);
4100 if (infoPtr
->fStatus
& CREATE_RUNNING
) {
4101 /* still in CreateWindow */
4104 if ((INT
)wParam
!= SIZE_RESTORED
) {
4105 ERR("WM_SIZE in create and flags=%08x, lParam=%08lx\n",
4109 TRACE("still in CreateWindow\n");
4110 infoPtr
->fStatus
&= ~CREATE_RUNNING
;
4111 GetWindowRect ( infoPtr
->hwndSelf
, &rcWin
);
4112 TRACE("win rect (%d,%d)-(%d,%d)\n",
4113 rcWin
.left
, rcWin
.top
, rcWin
.right
, rcWin
.bottom
);
4115 if ((lParam
== 0) && (rcWin
.right
-rcWin
.left
== 0) &&
4116 (rcWin
.bottom
-rcWin
.top
== 0)) {
4117 /* native control seems to do this */
4118 GetClientRect (GetParent(infoPtr
->hwndSelf
), &rcClient
);
4119 TRACE("sizing rebar, message and client zero, parent client (%d,%d)\n",
4120 rcClient
.right
, rcClient
.bottom
);
4125 cx
= rcWin
.right
- rcWin
.left
;
4126 cy
= rcWin
.bottom
- rcWin
.top
;
4127 if ((cx
== LOWORD(lParam
)) && (cy
== HIWORD(lParam
))) {
4131 /* do the actual WM_SIZE request */
4132 GetClientRect (infoPtr
->hwndSelf
, &rcClient
);
4133 TRACE("sizing rebar from (%ld,%ld) to (%d,%d), client (%d,%d)\n",
4134 infoPtr
->calcSize
.cx
, infoPtr
->calcSize
.cy
,
4135 LOWORD(lParam
), HIWORD(lParam
),
4136 rcClient
.right
, rcClient
.bottom
);
4140 if ((INT
)wParam
!= SIZE_RESTORED
) {
4141 ERR("WM_SIZE out of create and flags=%08x, lParam=%08lx\n",
4145 /* Handle cases when outside of the CreateWindow process */
4147 GetClientRect (infoPtr
->hwndSelf
, &rcClient
);
4148 if ((lParam
== 0) && (rcClient
.right
+ rcClient
.bottom
!= 0) &&
4149 (infoPtr
->dwStyle
& RBS_AUTOSIZE
)) {
4150 /* on a WM_SIZE to zero and current client not zero and AUTOSIZE */
4151 /* native seems to use the current client rect for the size */
4152 infoPtr
->fStatus
|= BAND_NEEDS_LAYOUT
;
4153 TRACE("sizing rebar to client (%d,%d) size is zero but AUTOSIZE set\n",
4154 rcClient
.right
, rcClient
.bottom
);
4157 TRACE("sizing rebar from (%ld,%ld) to (%d,%d), client (%d,%d)\n",
4158 infoPtr
->calcSize
.cx
, infoPtr
->calcSize
.cy
,
4159 LOWORD(lParam
), HIWORD(lParam
),
4160 rcClient
.right
, rcClient
.bottom
);
4164 if (infoPtr
->dwStyle
& RBS_AUTOSIZE
) {
4165 NMRBAUTOSIZE autosize
;
4167 GetClientRect(infoPtr
->hwndSelf
, &autosize
.rcTarget
);
4168 autosize
.fChanged
= 0; /* ??? */
4169 autosize
.rcActual
= autosize
.rcTarget
; /* ??? */
4170 REBAR_Notify((NMHDR
*) &autosize
, infoPtr
, RBN_AUTOSIZE
);
4171 TRACE("RBN_AUTOSIZE client=(%d,%d), lp=%08lx\n",
4172 autosize
.rcTarget
.right
, autosize
.rcTarget
.bottom
, lParam
);
4175 if ((infoPtr
->calcSize
.cx
!= rcClient
.right
) ||
4176 (infoPtr
->calcSize
.cy
!= rcClient
.bottom
))
4177 infoPtr
->fStatus
|= BAND_NEEDS_LAYOUT
;
4179 REBAR_Layout (infoPtr
, &rcClient
, TRUE
, TRUE
);
4180 infoPtr
->fStatus
&= ~AUTO_RESIZE
;
4187 REBAR_StyleChanged (REBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
4189 STYLESTRUCT
*ss
= (STYLESTRUCT
*)lParam
;
4191 TRACE("current style=%08lx, styleOld=%08lx, style being set to=%08lx\n",
4192 infoPtr
->dwStyle
, ss
->styleOld
, ss
->styleNew
);
4193 infoPtr
->dwStyle
= ss
->styleNew
;
4199 static LRESULT WINAPI
4200 REBAR_WindowProc (HWND hwnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
)
4202 REBAR_INFO
*infoPtr
= REBAR_GetInfoPtr (hwnd
);
4204 TRACE("hwnd=%x msg=%x wparam=%x lparam=%lx\n",
4205 hwnd
, uMsg
, /* SPY_GetMsgName(uMsg), */ wParam
, lParam
);
4206 if (!infoPtr
&& (uMsg
!= WM_NCCREATE
))
4207 return DefWindowProcA (hwnd
, uMsg
, wParam
, lParam
);
4210 /* case RB_BEGINDRAG: */
4213 return REBAR_DeleteBand (infoPtr
, wParam
, lParam
);
4215 /* case RB_DRAGMOVE: */
4216 /* case RB_ENDDRAG: */
4218 case RB_GETBANDBORDERS
:
4219 return REBAR_GetBandBorders (infoPtr
, wParam
, lParam
);
4221 case RB_GETBANDCOUNT
:
4222 return REBAR_GetBandCount (infoPtr
);
4224 case RB_GETBANDINFO
: /* obsoleted after IE3, but we have to
4225 support it anyway. */
4226 case RB_GETBANDINFOA
:
4227 return REBAR_GetBandInfoA (infoPtr
, wParam
, lParam
);
4229 case RB_GETBANDINFOW
:
4230 return REBAR_GetBandInfoW (infoPtr
, wParam
, lParam
);
4232 case RB_GETBARHEIGHT
:
4233 return REBAR_GetBarHeight (infoPtr
, wParam
, lParam
);
4236 return REBAR_GetBarInfo (infoPtr
, wParam
, lParam
);
4239 return REBAR_GetBkColor (infoPtr
);
4241 /* case RB_GETCOLORSCHEME: */
4242 /* case RB_GETDROPTARGET: */
4245 return REBAR_GetPalette (infoPtr
, wParam
, lParam
);
4248 return REBAR_GetRect (infoPtr
, wParam
, lParam
);
4250 case RB_GETROWCOUNT
:
4251 return REBAR_GetRowCount (infoPtr
);
4253 case RB_GETROWHEIGHT
:
4254 return REBAR_GetRowHeight (infoPtr
, wParam
, lParam
);
4256 case RB_GETTEXTCOLOR
:
4257 return REBAR_GetTextColor (infoPtr
);
4259 case RB_GETTOOLTIPS
:
4260 return REBAR_GetToolTips (infoPtr
);
4262 case RB_GETUNICODEFORMAT
:
4263 return REBAR_GetUnicodeFormat (infoPtr
);
4265 case CCM_GETVERSION
:
4266 return REBAR_GetVersion (infoPtr
);
4269 return REBAR_HitTest (infoPtr
, wParam
, lParam
);
4272 return REBAR_IdToIndex (infoPtr
, wParam
, lParam
);
4274 case RB_INSERTBANDA
:
4275 return REBAR_InsertBandA (infoPtr
, wParam
, lParam
);
4277 case RB_INSERTBANDW
:
4278 return REBAR_InsertBandW (infoPtr
, wParam
, lParam
);
4280 case RB_MAXIMIZEBAND
:
4281 return REBAR_MaximizeBand (infoPtr
, wParam
, lParam
);
4283 case RB_MINIMIZEBAND
:
4284 return REBAR_MinimizeBand (infoPtr
, wParam
, lParam
);
4287 return REBAR_MoveBand (infoPtr
, wParam
, lParam
);
4289 case RB_SETBANDINFOA
:
4290 return REBAR_SetBandInfoA (infoPtr
, wParam
, lParam
);
4292 case RB_SETBANDINFOW
:
4293 return REBAR_SetBandInfoW (infoPtr
, wParam
, lParam
);
4296 return REBAR_SetBarInfo (infoPtr
, wParam
, lParam
);
4299 return REBAR_SetBkColor (infoPtr
, wParam
, lParam
);
4301 /* case RB_SETCOLORSCHEME: */
4302 /* case RB_SETPALETTE: */
4303 /* return REBAR_GetPalette (infoPtr, wParam, lParam); */
4306 return REBAR_SetParent (infoPtr
, wParam
, lParam
);
4308 case RB_SETTEXTCOLOR
:
4309 return REBAR_SetTextColor (infoPtr
, wParam
, lParam
);
4311 /* case RB_SETTOOLTIPS: */
4313 case RB_SETUNICODEFORMAT
:
4314 return REBAR_SetUnicodeFormat (infoPtr
, wParam
);
4316 case CCM_SETVERSION
:
4317 return REBAR_SetVersion (infoPtr
, (INT
)wParam
);
4320 return REBAR_ShowBand (infoPtr
, wParam
, lParam
);
4323 return REBAR_SizeToRect (infoPtr
, wParam
, lParam
);
4326 /* Messages passed to parent */
4330 if (infoPtr
->NtfUnicode
)
4331 return SendMessageW (REBAR_GetNotifyParent (infoPtr
),
4332 uMsg
, wParam
, lParam
);
4334 return SendMessageA (REBAR_GetNotifyParent (infoPtr
),
4335 uMsg
, wParam
, lParam
);
4338 /* case WM_CHARTOITEM: supported according to ControlSpy */
4341 return REBAR_Create (infoPtr
, wParam
, lParam
);
4344 return REBAR_Destroy (infoPtr
, wParam
, lParam
);
4347 return REBAR_EraseBkGnd (infoPtr
, wParam
, lParam
);
4350 return REBAR_GetFont (infoPtr
, wParam
, lParam
);
4352 /* case WM_LBUTTONDBLCLK: supported according to ControlSpy */
4354 case WM_LBUTTONDOWN
:
4355 return REBAR_LButtonDown (infoPtr
, wParam
, lParam
);
4358 return REBAR_LButtonUp (infoPtr
, wParam
, lParam
);
4360 /* case WM_MEASUREITEM: supported according to ControlSpy */
4363 return REBAR_MouseMove (infoPtr
, wParam
, lParam
);
4366 return REBAR_NCCalcSize (infoPtr
, wParam
, lParam
);
4369 return REBAR_NCCreate (hwnd
, wParam
, lParam
);
4372 return REBAR_NCHitTest (infoPtr
, wParam
, lParam
);
4375 return REBAR_NCPaint (infoPtr
, wParam
, lParam
);
4377 case WM_NOTIFYFORMAT
:
4378 return REBAR_NotifyFormat (infoPtr
, wParam
, lParam
);
4381 return REBAR_Paint (infoPtr
, wParam
, lParam
);
4383 /* case WM_PALETTECHANGED: supported according to ControlSpy */
4384 /* case WM_PRINTCLIENT: supported according to ControlSpy */
4385 /* case WM_QUERYNEWPALETTE:supported according to ControlSpy */
4386 /* case WM_RBUTTONDOWN: supported according to ControlSpy */
4387 /* case WM_RBUTTONUP: supported according to ControlSpy */
4390 return REBAR_SetCursor (infoPtr
, wParam
, lParam
);
4393 return REBAR_SetFont (infoPtr
, wParam
, lParam
);
4396 return REBAR_SetRedraw (infoPtr
, wParam
, lParam
);
4399 return REBAR_Size (infoPtr
, wParam
, lParam
);
4401 case WM_STYLECHANGED
:
4402 return REBAR_StyleChanged (infoPtr
, wParam
, lParam
);
4404 /* case WM_SYSCOLORCHANGE: supported according to ControlSpy */
4405 /* "Applications that have brushes using the existing system colors
4406 should delete those brushes and recreate them using the new
4407 system colors." per MSDN */
4409 /* case WM_VKEYTOITEM: supported according to ControlSpy */
4410 /* case WM_WININICHANGE: */
4413 if (uMsg
>= WM_USER
)
4414 ERR("unknown msg %04x wp=%08x lp=%08lx\n",
4415 uMsg
, wParam
, lParam
);
4416 return DefWindowProcA (hwnd
, uMsg
, wParam
, lParam
);
4423 REBAR_Register (void)
4427 ZeroMemory (&wndClass
, sizeof(WNDCLASSA
));
4428 wndClass
.style
= CS_GLOBALCLASS
| CS_DBLCLKS
;
4429 wndClass
.lpfnWndProc
= (WNDPROC
)REBAR_WindowProc
;
4430 wndClass
.cbClsExtra
= 0;
4431 wndClass
.cbWndExtra
= sizeof(REBAR_INFO
*);
4432 wndClass
.hCursor
= 0;
4433 wndClass
.hbrBackground
= (HBRUSH
)(COLOR_BTNFACE
+ 1);
4435 wndClass
.hbrBackground
= CreateSolidBrush(RGB(0,128,0));
4437 wndClass
.lpszClassName
= REBARCLASSNAMEA
;
4439 RegisterClassA (&wndClass
);
4441 mindragx
= GetSystemMetrics (SM_CXDRAG
);
4442 mindragy
= GetSystemMetrics (SM_CYDRAG
);
4448 REBAR_Unregister (void)
4450 UnregisterClassA (REBARCLASSNAMEA
, (HINSTANCE
)NULL
);