4 * Copyright 1998, 1999 Eric Kohl
7 * An author is needed! Any volunteers?
8 * I will only improve this control once in a while.
9 * Eric <ekohl@abo.rhein-zeitung.de>
12 * - vertical placement
13 * - ComboBox and ComboBoxEx placement
18 * - All notifications.
25 #include "wine/unicode.h"
27 #include "debugtools.h"
29 DEFAULT_DEBUG_CHANNEL(rebar);
51 UINT fDraw; /* drawing flags */
52 RECT rcBand; /* calculated band rectangle */
53 RECT rcGripper; /* calculated gripper rectangle */
54 RECT rcCapImage; /* calculated caption image rectangle */
55 RECT rcCapText; /* calculated caption text rectangle */
56 RECT rcChild; /* calculated child rectangle */
64 COLORREF clrBk; /* background color */
65 COLORREF clrText; /* text color */
66 HIMAGELIST himl; /* handle to imagelist */
67 UINT uNumBands; /* number of bands in the rebar */
68 HWND hwndToolTip; /* handle to the tool tip control */
69 HWND hwndNotify; /* notification window (parent) */
70 HFONT hFont; /* handle to the rebar's font */
71 SIZE imageSize; /* image size (image list) */
73 SIZE calcSize; /* calculated rebar size */
74 BOOL bAutoResize; /* auto resize deadlock flag */
75 BOOL bUnicode; /* Unicode flag */
76 HCURSOR hcurArrow; /* handle to the arrow cursor */
77 HCURSOR hcurHorz; /* handle to the EW cursor */
78 HCURSOR hcurVert; /* handle to the NS cursor */
79 HCURSOR hcurDrag; /* handle to the drag cursor */
80 INT iVersion; /* version number */
82 REBAR_BAND *bands; /* pointer to the array of rebar bands */
87 #define DRAW_GRIPPER 1
92 #define GRIPPER_WIDTH 13
95 #define REBAR_GetInfoPtr(wndPtr) ((REBAR_INFO *)GetWindowLongA (hwnd, 0))
99 REBAR_DrawBand (HDC hdc, REBAR_INFO *infoPtr, REBAR_BAND *lpBand)
102 DrawEdge (hdc, &lpBand->rcBand, BDR_RAISEDINNER, BF_MIDDLE);
104 /* draw background */
107 if (lpBand->fDraw & DRAW_GRIPPER)
108 DrawEdge (hdc, &lpBand->rcGripper, BDR_RAISEDINNER, BF_RECT | BF_MIDDLE);
110 /* draw caption image */
111 if (lpBand->fDraw & DRAW_IMAGE) {
112 /* FIXME: center image */
115 pt.y = (lpBand->rcCapImage.bottom + lpBand->rcCapImage.top - infoPtr->imageSize.cy)/2;
116 pt.x = (lpBand->rcCapImage.right + lpBand->rcCapImage.left - infoPtr->imageSize.cx)/2;
118 ImageList_Draw (infoPtr->himl, lpBand->iImage, hdc,
119 /* lpBand->rcCapImage.left, lpBand->rcCapImage.top, */
124 /* draw caption text */
125 if (lpBand->fDraw & DRAW_TEXT) {
126 HFONT hOldFont = SelectObject (hdc, infoPtr->hFont);
127 INT oldBkMode = SetBkMode (hdc, TRANSPARENT);
128 DrawTextW (hdc, lpBand->lpText, -1, &lpBand->rcCapText,
129 DT_CENTER | DT_VCENTER | DT_SINGLELINE);
130 if (oldBkMode != TRANSPARENT)
131 SetBkMode (hdc, oldBkMode);
132 SelectObject (hdc, hOldFont);
138 REBAR_Refresh (HWND hwnd, HDC hdc)
140 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
144 for (i = 0; i < infoPtr->uNumBands; i++) {
145 lpBand = &infoPtr->bands[i];
147 if ((lpBand->fStyle & RBBS_HIDDEN) ||
148 ((GetWindowLongA (hwnd, GWL_STYLE) & CCS_VERT) &&
149 (lpBand->fStyle & RBBS_NOVERT)))
152 REBAR_DrawBand (hdc, infoPtr, lpBand);
159 REBAR_CalcHorzBand (REBAR_INFO *infoPtr, REBAR_BAND *lpBand)
163 /* set initial caption image rectangle */
164 SetRect (&lpBand->rcCapImage, 0, 0, 0, 0);
166 /* image is visible */
167 if ((lpBand->iImage > -1) && (infoPtr->himl)) {
168 lpBand->fDraw |= DRAW_IMAGE;
170 lpBand->rcCapImage.right = lpBand->rcCapImage.left + infoPtr->imageSize.cx;
171 lpBand->rcCapImage.bottom = lpBand->rcCapImage.top + infoPtr->imageSize.cy;
173 /* update band height */
174 if (lpBand->uMinHeight < infoPtr->imageSize.cy + 2) {
175 lpBand->uMinHeight = infoPtr->imageSize.cy + 2;
176 lpBand->rcBand.bottom = lpBand->rcBand.top + lpBand->uMinHeight;
180 /* set initial caption text rectangle */
181 lpBand->rcCapText.left = lpBand->rcCapImage.right;
182 lpBand->rcCapText.top = lpBand->rcBand.top + 1;
183 lpBand->rcCapText.right = lpBand->rcCapText.left;
184 lpBand->rcCapText.bottom = lpBand->rcBand.bottom - 1;
186 /* text is visible */
187 if (lpBand->lpText) {
189 HFONT hOldFont = SelectObject (hdc, infoPtr->hFont);
192 lpBand->fDraw |= DRAW_TEXT;
193 GetTextExtentPoint32W (hdc, lpBand->lpText,
194 lstrlenW (lpBand->lpText), &size);
195 lpBand->rcCapText.right += size.cx;
197 SelectObject (hdc, hOldFont);
201 /* set initial child window rectangle */
202 if (lpBand->fStyle & RBBS_FIXEDSIZE) {
203 lpBand->rcChild.left = lpBand->rcCapText.right;
204 lpBand->rcChild.top = lpBand->rcBand.top;
205 lpBand->rcChild.right = lpBand->rcBand.right;
206 lpBand->rcChild.bottom = lpBand->rcBand.bottom;
209 lpBand->rcChild.left = lpBand->rcCapText.right + 4;
210 lpBand->rcChild.top = lpBand->rcBand.top + 2;
211 lpBand->rcChild.right = lpBand->rcBand.right - 4;
212 lpBand->rcChild.bottom = lpBand->rcBand.bottom - 2;
215 /* calculate gripper rectangle */
216 if ((!(lpBand->fStyle & RBBS_NOGRIPPER)) &&
217 (!(lpBand->fStyle & RBBS_FIXEDSIZE)) &&
218 ((lpBand->fStyle & RBBS_GRIPPERALWAYS) ||
219 (infoPtr->uNumBands > 1))) {
220 lpBand->fDraw |= DRAW_GRIPPER;
221 lpBand->rcGripper.left = lpBand->rcBand.left + 3;
222 lpBand->rcGripper.right = lpBand->rcGripper.left + 3;
223 lpBand->rcGripper.top = lpBand->rcBand.top + 3;
224 lpBand->rcGripper.bottom = lpBand->rcBand.bottom - 3;
226 /* move caption rectangles */
227 OffsetRect (&lpBand->rcCapImage, GRIPPER_WIDTH, 0);
228 OffsetRect (&lpBand->rcCapText, GRIPPER_WIDTH, 0);
230 /* adjust child rectangle */
231 lpBand->rcChild.left += GRIPPER_WIDTH;
239 REBAR_CalcVertBand (HWND hwnd, REBAR_INFO *infoPtr, REBAR_BAND *lpBand)
243 /* set initial caption image rectangle */
244 SetRect (&lpBand->rcCapImage, 0, 0, 0, 0);
246 /* image is visible */
247 if ((lpBand->iImage > -1) && (infoPtr->himl)) {
248 lpBand->fDraw |= DRAW_IMAGE;
250 lpBand->rcCapImage.right = lpBand->rcCapImage.left + infoPtr->imageSize.cx;
251 lpBand->rcCapImage.bottom = lpBand->rcCapImage.top + infoPtr->imageSize.cy;
253 /* update band width */
254 if (lpBand->uMinHeight < infoPtr->imageSize.cx + 2) {
255 lpBand->uMinHeight = infoPtr->imageSize.cx + 2;
256 lpBand->rcBand.right = lpBand->rcBand.left + lpBand->uMinHeight;
260 /* set initial caption text rectangle */
261 lpBand->rcCapText.left = lpBand->rcBand.left + 1;
262 lpBand->rcCapText.top = lpBand->rcCapImage.bottom;
263 lpBand->rcCapText.right = lpBand->rcBand.right - 1;
264 lpBand->rcCapText.bottom = lpBand->rcCapText.top;
266 /* text is visible */
267 if (lpBand->lpText) {
269 HFONT hOldFont = SelectObject (hdc, infoPtr->hFont);
272 lpBand->fDraw |= DRAW_TEXT;
273 GetTextExtentPoint32W (hdc, lpBand->lpText,
274 lstrlenW (lpBand->lpText), &size);
275 /* lpBand->rcCapText.right += size.cx; */
276 lpBand->rcCapText.bottom += size.cy;
278 SelectObject (hdc, hOldFont);
282 /* set initial child window rectangle */
283 if (lpBand->fStyle & RBBS_FIXEDSIZE) {
284 lpBand->rcChild.left = lpBand->rcBand.left;
285 lpBand->rcChild.top = lpBand->rcCapText.bottom;
286 lpBand->rcChild.right = lpBand->rcBand.right;
287 lpBand->rcChild.bottom = lpBand->rcBand.bottom;
290 lpBand->rcChild.left = lpBand->rcBand.left + 2;
291 lpBand->rcChild.top = lpBand->rcCapText.bottom + 4;
292 lpBand->rcChild.right = lpBand->rcBand.right - 2;
293 lpBand->rcChild.bottom = lpBand->rcBand.bottom - 4;
296 /* calculate gripper rectangle */
297 if ((!(lpBand->fStyle & RBBS_NOGRIPPER)) &&
298 (!(lpBand->fStyle & RBBS_FIXEDSIZE)) &&
299 ((lpBand->fStyle & RBBS_GRIPPERALWAYS) ||
300 (infoPtr->uNumBands > 1))) {
301 lpBand->fDraw |= DRAW_GRIPPER;
303 if (GetWindowLongA (hwnd, GWL_STYLE) & RBS_VERTICALGRIPPER) {
304 /* adjust band width */
305 lpBand->rcBand.right += GRIPPER_WIDTH;
306 lpBand->uMinHeight += GRIPPER_WIDTH;
308 lpBand->rcGripper.left = lpBand->rcBand.left + 3;
309 lpBand->rcGripper.right = lpBand->rcGripper.left + 3;
310 lpBand->rcGripper.top = lpBand->rcBand.top + 3;
311 lpBand->rcGripper.bottom = lpBand->rcBand.bottom - 3;
313 /* move caption rectangles */
314 OffsetRect (&lpBand->rcCapImage, GRIPPER_WIDTH, 0);
315 OffsetRect (&lpBand->rcCapText, GRIPPER_WIDTH, 0);
317 /* adjust child rectangle */
318 lpBand->rcChild.left += GRIPPER_WIDTH;
321 lpBand->rcGripper.left = lpBand->rcBand.left + 3;
322 lpBand->rcGripper.right = lpBand->rcBand.right - 3;
323 lpBand->rcGripper.top = lpBand->rcBand.top + 3;
324 lpBand->rcGripper.bottom = lpBand->rcGripper.top + 3;
326 /* move caption rectangles */
327 OffsetRect (&lpBand->rcCapImage, 0, GRIPPER_WIDTH);
328 OffsetRect (&lpBand->rcCapText, 0, GRIPPER_WIDTH);
330 /* adjust child rectangle */
331 lpBand->rcChild.top += GRIPPER_WIDTH;
338 REBAR_Layout (HWND hwnd, LPRECT lpRect)
340 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
341 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
350 GetClientRect (hwnd, &rcClient);
355 if (dwStyle & CCS_VERT) {
356 cx = 20; /* FIXME: fixed height */
357 cy = rcClient.bottom - rcClient.top;
360 cx = rcClient.right - rcClient.left;
361 cy = 20; /* FIXME: fixed height */
364 for (i = 0; i < infoPtr->uNumBands; i++) {
365 lpBand = &infoPtr->bands[i];
367 if ((lpBand->fStyle & RBBS_HIDDEN) ||
368 ((dwStyle & CCS_VERT) && (lpBand->fStyle & RBBS_NOVERT)))
372 if (dwStyle & CCS_VERT) {
373 if (lpBand->fStyle & RBBS_VARIABLEHEIGHT)
374 cx = lpBand->cyMaxChild;
375 else if (lpBand->fStyle & RBBIM_CHILDSIZE)
376 cx = lpBand->cyMinChild;
380 lpBand->rcBand.left = x;
381 lpBand->rcBand.right = x + cx;
382 lpBand->rcBand.top = y;
383 lpBand->rcBand.bottom = y + cy;
384 lpBand->uMinHeight = cx;
387 if (lpBand->fStyle & RBBS_VARIABLEHEIGHT)
388 cy = lpBand->cyMaxChild;
389 else if (lpBand->fStyle & RBBIM_CHILDSIZE)
390 cy = lpBand->cyMinChild;
394 lpBand->rcBand.left = x;
395 lpBand->rcBand.right = x + cx;
396 lpBand->rcBand.top = y;
397 lpBand->rcBand.bottom = y + cy;
398 lpBand->uMinHeight = cy;
401 if (dwStyle & CCS_VERT) {
402 REBAR_CalcVertBand (hwnd, infoPtr, lpBand);
403 x += lpBand->uMinHeight;
406 REBAR_CalcHorzBand (infoPtr, lpBand);
407 y += lpBand->uMinHeight;
411 if (dwStyle & CCS_VERT) {
412 infoPtr->calcSize.cx = x;
413 infoPtr->calcSize.cy = rcClient.bottom - rcClient.top;
416 infoPtr->calcSize.cx = rcClient.right - rcClient.left;
417 infoPtr->calcSize.cy = y;
423 REBAR_ForceResize (HWND hwnd)
425 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
428 TRACE(" to [%d x %d]!\n",
429 infoPtr->calcSize.cx, infoPtr->calcSize.cy);
431 infoPtr->bAutoResize = TRUE;
435 rc.right = infoPtr->calcSize.cx;
436 rc.bottom = infoPtr->calcSize.cy;
438 if (GetWindowLongA (hwnd, GWL_STYLE) & WS_BORDER) {
439 InflateRect (&rc, GetSystemMetrics(SM_CXEDGE), GetSystemMetrics(SM_CYEDGE));
442 SetWindowPos (hwnd, 0, 0, 0,
443 rc.right - rc.left, rc.bottom - rc.top,
444 SWP_NOMOVE | SWP_NOZORDER | SWP_SHOWWINDOW);
449 REBAR_MoveChildWindows (HWND hwnd)
451 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
453 CHAR szClassName[40];
456 for (i = 0; i < infoPtr->uNumBands; i++) {
457 lpBand = &infoPtr->bands[i];
459 if (lpBand->fStyle & RBBS_HIDDEN)
461 if (lpBand->hwndChild) {
462 TRACE("hwndChild = %x\n", lpBand->hwndChild);
464 GetClassNameA (lpBand->hwndChild, szClassName, 40);
465 if (!lstrcmpA (szClassName, "ComboBox")) {
466 INT nEditHeight, yPos;
469 /* special placement code for combo box */
472 /* get size of edit line */
473 GetWindowRect (lpBand->hwndChild, &rc);
474 nEditHeight = rc.bottom - rc.top;
475 yPos = (lpBand->rcChild.bottom + lpBand->rcChild.top - nEditHeight)/2;
477 /* center combo box inside child area */
478 SetWindowPos (lpBand->hwndChild, HWND_TOP,
479 lpBand->rcChild.left, /*lpBand->rcChild.top*/ yPos,
480 lpBand->rcChild.right - lpBand->rcChild.left,
485 else if (!lstrcmpA (szClassName, WC_COMBOBOXEXA)) {
486 INT nEditHeight, yPos;
490 /* special placement code for extended combo box */
492 /* get size of edit line */
493 hwndEdit = SendMessageA (lpBand->hwndChild, CBEM_GETEDITCONTROL, 0, 0);
494 GetWindowRect (hwndEdit, &rc);
495 nEditHeight = rc.bottom - rc.top;
496 yPos = (lpBand->rcChild.bottom + lpBand->rcChild.top - nEditHeight)/2;
498 /* center combo box inside child area */
499 SetWindowPos (lpBand->hwndChild, HWND_TOP,
500 lpBand->rcChild.left, /*lpBand->rcChild.top*/ yPos,
501 lpBand->rcChild.right - lpBand->rcChild.left,
508 SetWindowPos (lpBand->hwndChild, HWND_TOP,
509 lpBand->rcChild.left, lpBand->rcChild.top,
510 lpBand->rcChild.right - lpBand->rcChild.left,
511 lpBand->rcChild.bottom - lpBand->rcChild.top,
520 REBAR_InternalHitTest (HWND hwnd, LPPOINT lpPt, UINT *pFlags, INT *pBand)
522 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
527 GetClientRect (hwnd, &rect);
529 *pFlags = RBHT_NOWHERE;
530 if (PtInRect (&rect, *lpPt))
532 if (infoPtr->uNumBands == 0) {
533 *pFlags = RBHT_NOWHERE;
540 /* somewhere inside */
541 for (iCount = 0; iCount < infoPtr->uNumBands; iCount++) {
542 lpBand = &infoPtr->bands[iCount];
543 if (PtInRect (&lpBand->rcBand, *lpPt)) {
546 if (PtInRect (&lpBand->rcGripper, *lpPt)) {
547 *pFlags = RBHT_GRABBER;
548 TRACE("ON GRABBER %d\n", iCount);
551 else if (PtInRect (&lpBand->rcCapImage, *lpPt)) {
552 *pFlags = RBHT_CAPTION;
553 TRACE("ON CAPTION %d\n", iCount);
556 else if (PtInRect (&lpBand->rcCapText, *lpPt)) {
557 *pFlags = RBHT_CAPTION;
558 TRACE("ON CAPTION %d\n", iCount);
561 else if (PtInRect (&lpBand->rcChild, *lpPt)) {
562 *pFlags = RBHT_CLIENT;
563 TRACE("ON CLIENT %d\n", iCount);
567 *pFlags = RBHT_NOWHERE;
568 TRACE("NOWHERE %d\n", iCount);
574 *pFlags = RBHT_NOWHERE;
583 *pFlags = RBHT_NOWHERE;
590 TRACE("flags=0x%X\n", *pFlags);
596 /* << REBAR_BeginDrag >> */
600 REBAR_DeleteBand (HWND hwnd, WPARAM wParam, LPARAM lParam)
602 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
603 UINT uBand = (UINT)wParam;
605 if (uBand >= infoPtr->uNumBands)
608 TRACE("deleting band %u!\n", uBand);
610 if (infoPtr->uNumBands == 1) {
611 TRACE(" simple delete!\n");
612 COMCTL32_Free (infoPtr->bands);
613 infoPtr->bands = NULL;
614 infoPtr->uNumBands = 0;
617 REBAR_BAND *oldBands = infoPtr->bands;
618 TRACE("complex delete! [uBand=%u]\n", uBand);
620 infoPtr->uNumBands--;
621 infoPtr->bands = COMCTL32_Alloc (sizeof (REBAR_BAND) * infoPtr->uNumBands);
623 memcpy (&infoPtr->bands[0], &oldBands[0],
624 uBand * sizeof(REBAR_BAND));
627 if (uBand < infoPtr->uNumBands) {
628 memcpy (&infoPtr->bands[uBand], &oldBands[uBand+1],
629 (infoPtr->uNumBands - uBand) * sizeof(REBAR_BAND));
632 COMCTL32_Free (oldBands);
635 REBAR_Layout (hwnd, NULL);
636 REBAR_ForceResize (hwnd);
637 REBAR_MoveChildWindows (hwnd);
643 /* << REBAR_DragMove >> */
644 /* << REBAR_EndDrag >> */
648 REBAR_GetBandBorders (HWND hwnd, WPARAM wParam, LPARAM lParam)
650 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
651 /* LPRECT32 lpRect = (LPRECT32)lParam; */
656 if ((UINT)wParam >= infoPtr->uNumBands)
659 lpBand = &infoPtr->bands[(UINT)wParam];
660 if (GetWindowLongA (hwnd, GWL_STYLE) & RBS_BANDBORDERS) {
671 inline static LRESULT
672 REBAR_GetBandCount (HWND hwnd)
674 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
676 TRACE("band count %u!\n", infoPtr->uNumBands);
678 return infoPtr->uNumBands;
683 REBAR_GetBandInfoA (HWND hwnd, WPARAM wParam, LPARAM lParam)
685 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
686 LPREBARBANDINFOA lprbbi = (LPREBARBANDINFOA)lParam;
691 if (lprbbi->cbSize < REBARBANDINFO_V3_SIZEA)
693 if ((UINT)wParam >= infoPtr->uNumBands)
696 TRACE("index %u\n", (UINT)wParam);
698 /* copy band information */
699 lpBand = &infoPtr->bands[(UINT)wParam];
701 if (lprbbi->fMask & RBBIM_STYLE)
702 lprbbi->fStyle = lpBand->fStyle;
704 if (lprbbi->fMask & RBBIM_COLORS) {
705 lprbbi->clrFore = lpBand->clrFore;
706 lprbbi->clrBack = lpBand->clrBack;
709 if ((lprbbi->fMask & RBBIM_TEXT) &&
710 (lprbbi->lpText) && (lpBand->lpText)) {
711 lstrcpynWtoA (lprbbi->lpText, lpBand->lpText, lprbbi->cch);
714 if (lprbbi->fMask & RBBIM_IMAGE)
715 lprbbi->iImage = lpBand->iImage;
717 if (lprbbi->fMask & RBBIM_CHILD)
718 lprbbi->hwndChild = lpBand->hwndChild;
720 if (lprbbi->fMask & RBBIM_CHILDSIZE) {
721 lprbbi->cxMinChild = lpBand->cxMinChild;
722 lprbbi->cyMinChild = lpBand->cyMinChild;
723 lprbbi->cyMaxChild = lpBand->cyMaxChild;
724 lprbbi->cyChild = lpBand->cyChild;
725 lprbbi->cyIntegral = lpBand->cyIntegral;
728 if (lprbbi->fMask & RBBIM_SIZE)
729 lprbbi->cx = lpBand->cx;
731 if (lprbbi->fMask & RBBIM_BACKGROUND)
732 lprbbi->hbmBack = lpBand->hbmBack;
734 if (lprbbi->fMask & RBBIM_ID)
735 lprbbi->wID = lpBand->wID;
737 /* check for additional data */
738 if (lprbbi->cbSize >= sizeof (REBARBANDINFOA)) {
739 if (lprbbi->fMask & RBBIM_IDEALSIZE)
740 lprbbi->cxIdeal = lpBand->cxIdeal;
742 if (lprbbi->fMask & RBBIM_LPARAM)
743 lprbbi->lParam = lpBand->lParam;
745 if (lprbbi->fMask & RBBIM_HEADERSIZE)
746 lprbbi->cxHeader = lpBand->cxHeader;
754 REBAR_GetBandInfoW (HWND hwnd, WPARAM wParam, LPARAM lParam)
756 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
757 LPREBARBANDINFOW lprbbi = (LPREBARBANDINFOW)lParam;
762 if (lprbbi->cbSize < REBARBANDINFO_V3_SIZEW)
764 if ((UINT)wParam >= infoPtr->uNumBands)
767 TRACE("index %u\n", (UINT)wParam);
769 /* copy band information */
770 lpBand = &infoPtr->bands[(UINT)wParam];
772 if (lprbbi->fMask & RBBIM_STYLE)
773 lprbbi->fStyle = lpBand->fStyle;
775 if (lprbbi->fMask & RBBIM_COLORS) {
776 lprbbi->clrFore = lpBand->clrFore;
777 lprbbi->clrBack = lpBand->clrBack;
780 if ((lprbbi->fMask & RBBIM_TEXT) &&
781 (lprbbi->lpText) && (lpBand->lpText)) {
782 lstrcpynW (lprbbi->lpText, lpBand->lpText, lprbbi->cch);
785 if (lprbbi->fMask & RBBIM_IMAGE)
786 lprbbi->iImage = lpBand->iImage;
788 if (lprbbi->fMask & RBBIM_CHILD)
789 lprbbi->hwndChild = lpBand->hwndChild;
791 if (lprbbi->fMask & RBBIM_CHILDSIZE) {
792 lprbbi->cxMinChild = lpBand->cxMinChild;
793 lprbbi->cyMinChild = lpBand->cyMinChild;
794 lprbbi->cyMaxChild = lpBand->cyMaxChild;
795 lprbbi->cyChild = lpBand->cyChild;
796 lprbbi->cyIntegral = lpBand->cyIntegral;
799 if (lprbbi->fMask & RBBIM_SIZE)
800 lprbbi->cx = lpBand->cx;
802 if (lprbbi->fMask & RBBIM_BACKGROUND)
803 lprbbi->hbmBack = lpBand->hbmBack;
805 if (lprbbi->fMask & RBBIM_ID)
806 lprbbi->wID = lpBand->wID;
808 /* check for additional data */
809 if (lprbbi->cbSize >= sizeof (REBARBANDINFOA)) {
810 if (lprbbi->fMask & RBBIM_IDEALSIZE)
811 lprbbi->cxIdeal = lpBand->cxIdeal;
813 if (lprbbi->fMask & RBBIM_LPARAM)
814 lprbbi->lParam = lpBand->lParam;
816 if (lprbbi->fMask & RBBIM_HEADERSIZE)
817 lprbbi->cxHeader = lpBand->cxHeader;
825 REBAR_GetBarHeight (HWND hwnd, WPARAM wParam, LPARAM lParam)
827 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
830 REBAR_Layout (hwnd, NULL);
831 nHeight = infoPtr->calcSize.cy;
833 if (GetWindowLongA (hwnd, GWL_STYLE) & WS_BORDER)
834 nHeight += (2 * GetSystemMetrics(SM_CYEDGE));
837 FIXME("height = %d\n", nHeight);
844 REBAR_GetBarInfo (HWND hwnd, WPARAM wParam, LPARAM lParam)
846 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
847 LPREBARINFO lpInfo = (LPREBARINFO)lParam;
852 if (lpInfo->cbSize < sizeof (REBARINFO))
855 TRACE("getting bar info!\n");
858 lpInfo->himl = infoPtr->himl;
859 lpInfo->fMask |= RBIM_IMAGELIST;
866 inline static LRESULT
867 REBAR_GetBkColor (HWND hwnd)
869 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
871 TRACE("background color 0x%06lx!\n", infoPtr->clrBk);
873 return infoPtr->clrBk;
877 /* << REBAR_GetColorScheme >> */
878 /* << REBAR_GetDropTarget >> */
882 REBAR_GetPalette (HWND hwnd, WPARAM wParam, LPARAM lParam)
884 FIXME("empty stub!\n");
891 REBAR_GetRect (HWND hwnd, WPARAM wParam, LPARAM lParam)
893 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
894 INT iBand = (INT)wParam;
895 LPRECT lprc = (LPRECT)lParam;
898 if ((iBand < 0) && ((UINT)iBand >= infoPtr->uNumBands))
903 TRACE("band %d\n", iBand);
905 lpBand = &infoPtr->bands[iBand];
906 CopyRect (lprc, &lpBand->rcBand);
908 lprc->left = lpBand->rcBand.left;
909 lprc->top = lpBand->rcBand.top;
910 lprc->right = lpBand->rcBand.right;
911 lprc->bottom = lpBand->rcBand.bottom;
918 inline static LRESULT
919 REBAR_GetRowCount (HWND hwnd)
921 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
923 FIXME("%u : semi stub!\n", infoPtr->uNumBands);
925 return infoPtr->uNumBands;
930 REBAR_GetRowHeight (HWND hwnd, WPARAM wParam, LPARAM lParam)
932 /* REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd); */
934 FIXME("-- height = 20: semi stub!\n");
940 inline static LRESULT
941 REBAR_GetTextColor (HWND hwnd)
943 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
945 TRACE("text color 0x%06lx!\n", infoPtr->clrText);
947 return infoPtr->clrText;
951 inline static LRESULT
952 REBAR_GetToolTips (HWND hwnd)
954 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
955 return infoPtr->hwndToolTip;
959 inline static LRESULT
960 REBAR_GetUnicodeFormat (HWND hwnd)
962 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
963 return infoPtr->bUnicode;
967 inline static LRESULT
968 REBAR_GetVersion (HWND hwnd)
970 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
971 return infoPtr->iVersion;
976 REBAR_HitTest (HWND hwnd, WPARAM wParam, LPARAM lParam)
978 /* REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd); */
979 LPRBHITTESTINFO lprbht = (LPRBHITTESTINFO)lParam;
984 REBAR_InternalHitTest (hwnd, &lprbht->pt, &lprbht->flags, &lprbht->iBand);
986 return lprbht->iBand;
991 REBAR_IdToIndex (HWND hwnd, WPARAM wParam, LPARAM lParam)
993 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
999 if (infoPtr->uNumBands < 1)
1002 TRACE("id %u\n", (UINT)wParam);
1004 for (i = 0; i < infoPtr->uNumBands; i++) {
1005 if (infoPtr->bands[i].wID == (UINT)wParam) {
1006 TRACE("band %u found!\n", i);
1011 TRACE("no band found!\n");
1017 REBAR_InsertBandA (HWND hwnd, WPARAM wParam, LPARAM lParam)
1019 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
1020 LPREBARBANDINFOA lprbbi = (LPREBARBANDINFOA)lParam;
1021 UINT uIndex = (UINT)wParam;
1024 if (infoPtr == NULL)
1028 if (lprbbi->cbSize < REBARBANDINFO_V3_SIZEA)
1031 TRACE("insert band at %u!\n", uIndex);
1033 if (infoPtr->uNumBands == 0) {
1034 infoPtr->bands = (REBAR_BAND *)COMCTL32_Alloc (sizeof (REBAR_BAND));
1038 REBAR_BAND *oldBands = infoPtr->bands;
1040 (REBAR_BAND *)COMCTL32_Alloc ((infoPtr->uNumBands+1)*sizeof(REBAR_BAND));
1041 if (((INT)uIndex == -1) || (uIndex > infoPtr->uNumBands))
1042 uIndex = infoPtr->uNumBands;
1044 /* pre insert copy */
1046 memcpy (&infoPtr->bands[0], &oldBands[0],
1047 uIndex * sizeof(REBAR_BAND));
1051 if (uIndex < infoPtr->uNumBands - 1) {
1052 memcpy (&infoPtr->bands[uIndex+1], &oldBands[uIndex],
1053 (infoPtr->uNumBands - uIndex - 1) * sizeof(REBAR_BAND));
1056 COMCTL32_Free (oldBands);
1059 infoPtr->uNumBands++;
1061 TRACE("index %u!\n", uIndex);
1063 /* initialize band (infoPtr->bands[uIndex])*/
1064 lpBand = &infoPtr->bands[uIndex];
1066 if (lprbbi->fMask & RBBIM_STYLE)
1067 lpBand->fStyle = lprbbi->fStyle;
1069 if (lprbbi->fMask & RBBIM_COLORS) {
1070 lpBand->clrFore = lprbbi->clrFore;
1071 lpBand->clrBack = lprbbi->clrBack;
1074 lpBand->clrFore = CLR_NONE;
1075 lpBand->clrBack = CLR_NONE;
1078 if ((lprbbi->fMask & RBBIM_TEXT) && (lprbbi->lpText)) {
1079 INT len = lstrlenA (lprbbi->lpText);
1081 lpBand->lpText = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
1082 lstrcpyAtoW (lpBand->lpText, lprbbi->lpText);
1086 if (lprbbi->fMask & RBBIM_IMAGE)
1087 lpBand->iImage = lprbbi->iImage;
1089 lpBand->iImage = -1;
1091 if (lprbbi->fMask & RBBIM_CHILD) {
1092 TRACE("hwndChild = %x\n", lprbbi->hwndChild);
1093 lpBand->hwndChild = lprbbi->hwndChild;
1094 lpBand->hwndPrevParent =
1095 SetParent (lpBand->hwndChild, hwnd);
1098 if (lprbbi->fMask & RBBIM_CHILDSIZE) {
1099 lpBand->cxMinChild = lprbbi->cxMinChild;
1100 lpBand->cyMinChild = lprbbi->cyMinChild;
1101 lpBand->cyMaxChild = lprbbi->cyMaxChild;
1102 lpBand->cyChild = lprbbi->cyChild;
1103 lpBand->cyIntegral = lprbbi->cyIntegral;
1106 lpBand->cxMinChild = -1;
1107 lpBand->cyMinChild = -1;
1108 lpBand->cyMaxChild = -1;
1109 lpBand->cyChild = -1;
1110 lpBand->cyIntegral = -1;
1113 if (lprbbi->fMask & RBBIM_SIZE)
1114 lpBand->cx = lprbbi->cx;
1118 if (lprbbi->fMask & RBBIM_BACKGROUND)
1119 lpBand->hbmBack = lprbbi->hbmBack;
1121 if (lprbbi->fMask & RBBIM_ID)
1122 lpBand->wID = lprbbi->wID;
1124 /* check for additional data */
1125 if (lprbbi->cbSize >= sizeof (REBARBANDINFOA)) {
1126 if (lprbbi->fMask & RBBIM_IDEALSIZE)
1127 lpBand->cxIdeal = lprbbi->cxIdeal;
1129 if (lprbbi->fMask & RBBIM_LPARAM)
1130 lpBand->lParam = lprbbi->lParam;
1132 if (lprbbi->fMask & RBBIM_HEADERSIZE)
1133 lpBand->cxHeader = lprbbi->cxHeader;
1137 REBAR_Layout (hwnd, NULL);
1138 REBAR_ForceResize (hwnd);
1139 REBAR_MoveChildWindows (hwnd);
1146 REBAR_InsertBandW (HWND hwnd, WPARAM wParam, LPARAM lParam)
1148 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
1149 LPREBARBANDINFOW lprbbi = (LPREBARBANDINFOW)lParam;
1150 UINT uIndex = (UINT)wParam;
1153 if (infoPtr == NULL)
1157 if (lprbbi->cbSize < REBARBANDINFO_V3_SIZEW)
1160 TRACE("insert band at %u!\n", uIndex);
1162 if (infoPtr->uNumBands == 0) {
1163 infoPtr->bands = (REBAR_BAND *)COMCTL32_Alloc (sizeof (REBAR_BAND));
1167 REBAR_BAND *oldBands = infoPtr->bands;
1169 (REBAR_BAND *)COMCTL32_Alloc ((infoPtr->uNumBands+1)*sizeof(REBAR_BAND));
1170 if (((INT)uIndex == -1) || (uIndex > infoPtr->uNumBands))
1171 uIndex = infoPtr->uNumBands;
1173 /* pre insert copy */
1175 memcpy (&infoPtr->bands[0], &oldBands[0],
1176 uIndex * sizeof(REBAR_BAND));
1180 if (uIndex < infoPtr->uNumBands - 1) {
1181 memcpy (&infoPtr->bands[uIndex+1], &oldBands[uIndex],
1182 (infoPtr->uNumBands - uIndex - 1) * sizeof(REBAR_BAND));
1185 COMCTL32_Free (oldBands);
1188 infoPtr->uNumBands++;
1190 TRACE("index %u!\n", uIndex);
1192 /* initialize band (infoPtr->bands[uIndex])*/
1193 lpBand = &infoPtr->bands[uIndex];
1195 if (lprbbi->fMask & RBBIM_STYLE)
1196 lpBand->fStyle = lprbbi->fStyle;
1198 if (lprbbi->fMask & RBBIM_COLORS) {
1199 lpBand->clrFore = lprbbi->clrFore;
1200 lpBand->clrBack = lprbbi->clrBack;
1203 lpBand->clrFore = CLR_NONE;
1204 lpBand->clrBack = CLR_NONE;
1207 if ((lprbbi->fMask & RBBIM_TEXT) && (lprbbi->lpText)) {
1208 INT len = lstrlenW (lprbbi->lpText);
1210 lpBand->lpText = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
1211 strcpyW (lpBand->lpText, lprbbi->lpText);
1215 if (lprbbi->fMask & RBBIM_IMAGE)
1216 lpBand->iImage = lprbbi->iImage;
1218 lpBand->iImage = -1;
1220 if (lprbbi->fMask & RBBIM_CHILD) {
1221 TRACE("hwndChild = %x\n", lprbbi->hwndChild);
1222 lpBand->hwndChild = lprbbi->hwndChild;
1223 lpBand->hwndPrevParent =
1224 SetParent (lpBand->hwndChild, hwnd);
1227 if (lprbbi->fMask & RBBIM_CHILDSIZE) {
1228 lpBand->cxMinChild = lprbbi->cxMinChild;
1229 lpBand->cyMinChild = lprbbi->cyMinChild;
1230 lpBand->cyMaxChild = lprbbi->cyMaxChild;
1231 lpBand->cyChild = lprbbi->cyChild;
1232 lpBand->cyIntegral = lprbbi->cyIntegral;
1235 lpBand->cxMinChild = -1;
1236 lpBand->cyMinChild = -1;
1237 lpBand->cyMaxChild = -1;
1238 lpBand->cyChild = -1;
1239 lpBand->cyIntegral = -1;
1242 if (lprbbi->fMask & RBBIM_SIZE)
1243 lpBand->cx = lprbbi->cx;
1247 if (lprbbi->fMask & RBBIM_BACKGROUND)
1248 lpBand->hbmBack = lprbbi->hbmBack;
1250 if (lprbbi->fMask & RBBIM_ID)
1251 lpBand->wID = lprbbi->wID;
1253 /* check for additional data */
1254 if (lprbbi->cbSize >= sizeof (REBARBANDINFOW)) {
1255 if (lprbbi->fMask & RBBIM_IDEALSIZE)
1256 lpBand->cxIdeal = lprbbi->cxIdeal;
1258 if (lprbbi->fMask & RBBIM_LPARAM)
1259 lpBand->lParam = lprbbi->lParam;
1261 if (lprbbi->fMask & RBBIM_HEADERSIZE)
1262 lpBand->cxHeader = lprbbi->cxHeader;
1266 REBAR_Layout (hwnd, NULL);
1267 REBAR_ForceResize (hwnd);
1268 REBAR_MoveChildWindows (hwnd);
1275 REBAR_MaximizeBand (HWND hwnd, WPARAM wParam, LPARAM lParam)
1277 /* REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd); */
1279 FIXME("(uBand = %u fIdeal = %s)\n",
1280 (UINT)wParam, lParam ? "TRUE" : "FALSE");
1288 REBAR_MinimizeBand (HWND hwnd, WPARAM wParam, LPARAM lParam)
1290 /* REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd); */
1292 FIXME("(uBand = %u)\n", (UINT)wParam);
1300 REBAR_MoveBand (HWND hwnd, WPARAM wParam, LPARAM lParam)
1302 /* REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd); */
1304 FIXME("(iFrom = %u iTof = %u)\n",
1305 (UINT)wParam, (UINT)lParam);
1313 REBAR_SetBandInfoA (HWND hwnd, WPARAM wParam, LPARAM lParam)
1315 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
1316 LPREBARBANDINFOA lprbbi = (LPREBARBANDINFOA)lParam;
1321 if (lprbbi->cbSize < REBARBANDINFO_V3_SIZEA)
1323 if ((UINT)wParam >= infoPtr->uNumBands)
1326 TRACE("index %u\n", (UINT)wParam);
1328 /* set band information */
1329 lpBand = &infoPtr->bands[(UINT)wParam];
1331 if (lprbbi->fMask & RBBIM_STYLE)
1332 lpBand->fStyle = lprbbi->fStyle;
1334 if (lprbbi->fMask & RBBIM_COLORS) {
1335 lpBand->clrFore = lprbbi->clrFore;
1336 lpBand->clrBack = lprbbi->clrBack;
1339 if (lprbbi->fMask & RBBIM_TEXT) {
1340 if (lpBand->lpText) {
1341 COMCTL32_Free (lpBand->lpText);
1342 lpBand->lpText = NULL;
1344 if (lprbbi->lpText) {
1345 INT len = lstrlenA (lprbbi->lpText);
1346 lpBand->lpText = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
1347 lstrcpyAtoW (lpBand->lpText, lprbbi->lpText);
1351 if (lprbbi->fMask & RBBIM_IMAGE)
1352 lpBand->iImage = lprbbi->iImage;
1354 if (lprbbi->fMask & RBBIM_CHILD) {
1355 if (lprbbi->hwndChild) {
1356 lpBand->hwndChild = lprbbi->hwndChild;
1357 lpBand->hwndPrevParent =
1358 SetParent (lpBand->hwndChild, hwnd);
1361 TRACE("child: 0x%x prev parent: 0x%x\n",
1362 lpBand->hwndChild, lpBand->hwndPrevParent);
1363 lpBand->hwndChild = 0;
1364 lpBand->hwndPrevParent = 0;
1368 if (lprbbi->fMask & RBBIM_CHILDSIZE) {
1369 lpBand->cxMinChild = lprbbi->cxMinChild;
1370 lpBand->cyMinChild = lprbbi->cyMinChild;
1371 lpBand->cyMaxChild = lprbbi->cyMaxChild;
1372 lpBand->cyChild = lprbbi->cyChild;
1373 lpBand->cyIntegral = lprbbi->cyIntegral;
1376 if (lprbbi->fMask & RBBIM_SIZE)
1377 lpBand->cx = lprbbi->cx;
1379 if (lprbbi->fMask & RBBIM_BACKGROUND)
1380 lpBand->hbmBack = lprbbi->hbmBack;
1382 if (lprbbi->fMask & RBBIM_ID)
1383 lpBand->wID = lprbbi->wID;
1385 /* check for additional data */
1386 if (lprbbi->cbSize >= sizeof (REBARBANDINFOA)) {
1387 if (lprbbi->fMask & RBBIM_IDEALSIZE)
1388 lpBand->cxIdeal = lprbbi->cxIdeal;
1390 if (lprbbi->fMask & RBBIM_LPARAM)
1391 lpBand->lParam = lprbbi->lParam;
1393 if (lprbbi->fMask & RBBIM_HEADERSIZE)
1394 lpBand->cxHeader = lprbbi->cxHeader;
1397 REBAR_Layout (hwnd, NULL);
1398 REBAR_ForceResize (hwnd);
1399 REBAR_MoveChildWindows (hwnd);
1406 REBAR_SetBandInfoW (HWND hwnd, WPARAM wParam, LPARAM lParam)
1408 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
1409 LPREBARBANDINFOW lprbbi = (LPREBARBANDINFOW)lParam;
1414 if (lprbbi->cbSize < REBARBANDINFO_V3_SIZEW)
1416 if ((UINT)wParam >= infoPtr->uNumBands)
1419 TRACE("index %u\n", (UINT)wParam);
1421 /* set band information */
1422 lpBand = &infoPtr->bands[(UINT)wParam];
1424 if (lprbbi->fMask & RBBIM_STYLE)
1425 lpBand->fStyle = lprbbi->fStyle;
1427 if (lprbbi->fMask & RBBIM_COLORS) {
1428 lpBand->clrFore = lprbbi->clrFore;
1429 lpBand->clrBack = lprbbi->clrBack;
1432 if (lprbbi->fMask & RBBIM_TEXT) {
1433 if (lpBand->lpText) {
1434 COMCTL32_Free (lpBand->lpText);
1435 lpBand->lpText = NULL;
1437 if (lprbbi->lpText) {
1438 INT len = lstrlenW (lprbbi->lpText);
1439 lpBand->lpText = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
1440 strcpyW (lpBand->lpText, lprbbi->lpText);
1444 if (lprbbi->fMask & RBBIM_IMAGE)
1445 lpBand->iImage = lprbbi->iImage;
1447 if (lprbbi->fMask & RBBIM_CHILD) {
1448 if (lprbbi->hwndChild) {
1449 lpBand->hwndChild = lprbbi->hwndChild;
1450 lpBand->hwndPrevParent =
1451 SetParent (lpBand->hwndChild, hwnd);
1454 TRACE("child: 0x%x prev parent: 0x%x\n",
1455 lpBand->hwndChild, lpBand->hwndPrevParent);
1456 lpBand->hwndChild = 0;
1457 lpBand->hwndPrevParent = 0;
1461 if (lprbbi->fMask & RBBIM_CHILDSIZE) {
1462 lpBand->cxMinChild = lprbbi->cxMinChild;
1463 lpBand->cyMinChild = lprbbi->cyMinChild;
1464 lpBand->cyMaxChild = lprbbi->cyMaxChild;
1465 lpBand->cyChild = lprbbi->cyChild;
1466 lpBand->cyIntegral = lprbbi->cyIntegral;
1469 if (lprbbi->fMask & RBBIM_SIZE)
1470 lpBand->cx = lprbbi->cx;
1472 if (lprbbi->fMask & RBBIM_BACKGROUND)
1473 lpBand->hbmBack = lprbbi->hbmBack;
1475 if (lprbbi->fMask & RBBIM_ID)
1476 lpBand->wID = lprbbi->wID;
1478 /* check for additional data */
1479 if (lprbbi->cbSize >= sizeof (REBARBANDINFOW)) {
1480 if (lprbbi->fMask & RBBIM_IDEALSIZE)
1481 lpBand->cxIdeal = lprbbi->cxIdeal;
1483 if (lprbbi->fMask & RBBIM_LPARAM)
1484 lpBand->lParam = lprbbi->lParam;
1486 if (lprbbi->fMask & RBBIM_HEADERSIZE)
1487 lpBand->cxHeader = lprbbi->cxHeader;
1490 REBAR_Layout (hwnd, NULL);
1491 REBAR_ForceResize (hwnd);
1492 REBAR_MoveChildWindows (hwnd);
1499 REBAR_SetBarInfo (HWND hwnd, WPARAM wParam, LPARAM lParam)
1501 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
1502 LPREBARINFO lpInfo = (LPREBARINFO)lParam;
1507 if (lpInfo->cbSize < sizeof (REBARINFO))
1510 TRACE("setting bar info!\n");
1512 if (lpInfo->fMask & RBIM_IMAGELIST) {
1513 infoPtr->himl = lpInfo->himl;
1514 if (infoPtr->himl) {
1515 ImageList_GetIconSize (infoPtr->himl, &infoPtr->imageSize.cx,
1516 &infoPtr->imageSize.cy);
1519 infoPtr->imageSize.cx = 0;
1520 infoPtr->imageSize.cy = 0;
1529 REBAR_SetBkColor (HWND hwnd, WPARAM wParam, LPARAM lParam)
1531 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
1534 clrTemp = infoPtr->clrBk;
1535 infoPtr->clrBk = (COLORREF)lParam;
1537 TRACE("background color 0x%06lx!\n", infoPtr->clrBk);
1543 /* << REBAR_SetColorScheme >> */
1544 /* << REBAR_SetPalette >> */
1548 REBAR_SetParent (HWND hwnd, WPARAM wParam, LPARAM lParam)
1550 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
1551 HWND hwndTemp = infoPtr->hwndNotify;
1553 infoPtr->hwndNotify = (HWND)wParam;
1555 return (LRESULT)hwndTemp;
1560 REBAR_SetTextColor (HWND hwnd, WPARAM wParam, LPARAM lParam)
1562 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
1565 clrTemp = infoPtr->clrText;
1566 infoPtr->clrText = (COLORREF)lParam;
1568 TRACE("text color 0x%06lx!\n", infoPtr->clrText);
1574 /* << REBAR_SetTooltips >> */
1577 inline static LRESULT
1578 REBAR_SetUnicodeFormat (HWND hwnd, WPARAM wParam)
1580 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
1581 BOOL bTemp = infoPtr->bUnicode;
1582 infoPtr->bUnicode = (BOOL)wParam;
1588 REBAR_SetVersion (HWND hwnd, INT iVersion)
1590 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
1591 INT iOldVersion = infoPtr->iVersion;
1593 if (iVersion > COMCTL32_VERSION)
1596 infoPtr->iVersion = iVersion;
1603 REBAR_ShowBand (HWND hwnd, WPARAM wParam, LPARAM lParam)
1605 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
1608 if (((INT)wParam < 0) || ((INT)wParam > infoPtr->uNumBands))
1611 lpBand = &infoPtr->bands[(INT)wParam];
1614 TRACE("show band %d\n", (INT)wParam);
1615 lpBand->fStyle = lpBand->fStyle & ~RBBS_HIDDEN;
1616 if (IsWindow (lpBand->hwndChild))
1617 ShowWindow (lpBand->hwndChild, SW_SHOW);
1620 TRACE("hide band %d\n", (INT)wParam);
1621 lpBand->fStyle = lpBand->fStyle | RBBS_HIDDEN;
1622 if (IsWindow (lpBand->hwndChild))
1623 ShowWindow (lpBand->hwndChild, SW_SHOW);
1626 REBAR_Layout (hwnd, NULL);
1627 REBAR_ForceResize (hwnd);
1628 REBAR_MoveChildWindows (hwnd);
1635 REBAR_SizeToRect (HWND hwnd, WPARAM wParam, LPARAM lParam)
1637 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
1638 LPRECT lpRect = (LPRECT)lParam;
1643 FIXME("layout change not implemented!\n");
1644 FIXME("[%d %d %d %d]\n",
1645 lpRect->left, lpRect->top, lpRect->right, lpRect->bottom);
1648 SetWindowPos (hwnd, 0, lpRect->left, lpRect->top,
1649 lpRect->right - lpRect->left, lpRect->bottom - lpRect->top,
1653 infoPtr->calcSize.cx = lpRect->right - lpRect->left;
1654 infoPtr->calcSize.cy = lpRect->bottom - lpRect->top;
1656 REBAR_ForceResize (hwnd);
1663 REBAR_Create (HWND hwnd, WPARAM wParam, LPARAM lParam)
1665 REBAR_INFO *infoPtr;
1667 /* allocate memory for info structure */
1668 infoPtr = (REBAR_INFO *)COMCTL32_Alloc (sizeof(REBAR_INFO));
1669 SetWindowLongA (hwnd, 0, (DWORD)infoPtr);
1671 /* initialize info structure */
1672 infoPtr->iVersion = 0;
1673 infoPtr->clrBk = CLR_NONE;
1674 infoPtr->clrText = RGB(0, 0, 0);
1676 infoPtr->bAutoResize = FALSE;
1677 infoPtr->hcurArrow = LoadCursorA (0, IDC_ARROWA);
1678 infoPtr->hcurHorz = LoadCursorA (0, IDC_SIZEWEA);
1679 infoPtr->hcurVert = LoadCursorA (0, IDC_SIZENSA);
1680 infoPtr->hcurDrag = LoadCursorA (0, IDC_SIZEA);
1682 infoPtr->bUnicode = IsWindowUnicode (hwnd);
1684 if (GetWindowLongA (hwnd, GWL_STYLE) & RBS_AUTOSIZE)
1685 FIXME("style RBS_AUTOSIZE set!\n");
1688 SendMessageA (hwnd, WM_NOTIFYFORMAT, (WPARAM)hwnd, NF_QUERY);
1691 TRACE("created!\n");
1697 REBAR_Destroy (HWND hwnd, WPARAM wParam, LPARAM lParam)
1699 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
1704 /* free rebar bands */
1705 if ((infoPtr->uNumBands > 0) && infoPtr->bands) {
1706 /* clean up each band */
1707 for (i = 0; i < infoPtr->uNumBands; i++) {
1708 lpBand = &infoPtr->bands[i];
1710 /* delete text strings */
1711 if (lpBand->lpText) {
1712 COMCTL32_Free (lpBand->lpText);
1713 lpBand->lpText = NULL;
1715 /* destroy child window */
1716 DestroyWindow (lpBand->hwndChild);
1719 /* free band array */
1720 COMCTL32_Free (infoPtr->bands);
1721 infoPtr->bands = NULL;
1727 DeleteObject (infoPtr->hcurArrow);
1728 DeleteObject (infoPtr->hcurHorz);
1729 DeleteObject (infoPtr->hcurVert);
1730 DeleteObject (infoPtr->hcurDrag);
1735 /* free rebar info data */
1736 COMCTL32_Free (infoPtr);
1737 SetWindowLongA (hwnd, 0, 0);
1738 TRACE("destroyed!\n");
1744 REBAR_GetFont (HWND hwnd, WPARAM wParam, LPARAM lParam)
1746 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
1748 return (LRESULT)infoPtr->hFont;
1754 REBAR_MouseMove (HWND hwnd, WPARAM wParam, LPARAM lParam)
1756 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
1763 inline static LRESULT
1764 REBAR_NCCalcSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
1766 if (GetWindowLongA (hwnd, GWL_STYLE) & WS_BORDER) {
1767 ((LPRECT)lParam)->left += GetSystemMetrics(SM_CXEDGE);
1768 ((LPRECT)lParam)->top += GetSystemMetrics(SM_CYEDGE);
1769 ((LPRECT)lParam)->right -= GetSystemMetrics(SM_CXEDGE);
1770 ((LPRECT)lParam)->bottom -= GetSystemMetrics(SM_CYEDGE);
1778 REBAR_NCPaint (HWND hwnd, WPARAM wParam, LPARAM lParam)
1780 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
1784 if (dwStyle & WS_MINIMIZE)
1785 return 0; /* Nothing to do */
1787 DefWindowProcA (hwnd, WM_NCPAINT, wParam, lParam);
1789 if (!(hdc = GetDCEx( hwnd, 0, DCX_USESTYLE | DCX_WINDOW )))
1792 if (dwStyle & WS_BORDER) {
1793 GetWindowRect (hwnd, &rcWindow);
1794 OffsetRect (&rcWindow, -rcWindow.left, -rcWindow.top);
1795 DrawEdge (hdc, &rcWindow, EDGE_ETCHED, BF_RECT);
1798 ReleaseDC( hwnd, hdc );
1805 REBAR_Paint (HWND hwnd, WPARAM wParam)
1810 hdc = wParam==0 ? BeginPaint (hwnd, &ps) : (HDC)wParam;
1811 REBAR_Refresh (hwnd, hdc);
1813 EndPaint (hwnd, &ps);
1819 REBAR_SetCursor (HWND hwnd, WPARAM wParam, LPARAM lParam)
1821 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
1822 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
1826 TRACE("code=0x%X id=0x%X\n", LOWORD(lParam), HIWORD(lParam));
1829 ScreenToClient (hwnd, &pt);
1831 REBAR_InternalHitTest (hwnd, &pt, &flags, NULL);
1833 if (flags == RBHT_GRABBER) {
1834 if ((dwStyle & CCS_VERT) &&
1835 !(dwStyle & RBS_VERTICALGRIPPER))
1836 SetCursor (infoPtr->hcurVert);
1838 SetCursor (infoPtr->hcurHorz);
1840 else if (flags != RBHT_CLIENT)
1841 SetCursor (infoPtr->hcurArrow);
1848 REBAR_SetFont (HWND hwnd, WPARAM wParam, LPARAM lParam)
1850 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
1852 /* TEXTMETRIC32A tm; */
1853 HFONT hFont /*, hOldFont */;
1856 infoPtr->hFont = (HFONT)wParam;
1858 hFont = infoPtr->hFont ? infoPtr->hFont : GetStockObject (SYSTEM_FONT);
1861 hOldFont = SelectObject32 (hdc, hFont);
1862 GetTextMetrics32A (hdc, &tm);
1863 infoPtr->nHeight = tm.tmHeight + VERT_BORDER;
1864 SelectObject32 (hdc, hOldFont);
1865 ReleaseDC32 (0, hdc);
1869 REBAR_Layout (hwnd);
1870 hdc = GetDC32 (hwnd);
1871 REBAR_Refresh (hwnd, hdc);
1872 ReleaseDC32 (hwnd, hdc);
1880 REBAR_Size (HWND hwnd, WPARAM wParam, LPARAM lParam)
1882 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
1883 /* DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE); */
1885 /* INT32 x, y, cx, cy; */
1887 /* auto resize deadlock check */
1888 if (infoPtr->bAutoResize) {
1889 infoPtr->bAutoResize = FALSE;
1893 TRACE("sizing rebar!\n");
1895 /* get parent rectangle */
1896 GetClientRect (GetParent (hwnd), &rcParent);
1898 REBAR_Layout (hwnd, &rcParent);
1900 if (dwStyle & CCS_VERT) {
1901 if (dwStyle & CCS_LEFT == CCS_LEFT) {
1904 cx = infoPtr->calcSize.cx;
1905 cy = infoPtr->calcSize.cy;
1908 x = rcParent.right - infoPtr->calcSize.cx;
1910 cx = infoPtr->calcSize.cx;
1911 cy = infoPtr->calcSize.cy;
1915 if (dwStyle & CCS_TOP) {
1918 cx = infoPtr->calcSize.cx;
1919 cy = infoPtr->calcSize.cy;
1923 y = rcParent.bottom - infoPtr->calcSize.cy;
1924 cx = infoPtr->calcSize.cx;
1925 cy = infoPtr->calcSize.cy;
1929 SetWindowPos32 (hwnd, 0, x, y, cx, cy,
1930 SWP_NOZORDER | SWP_SHOWWINDOW);
1932 REBAR_Layout (hwnd, NULL);
1933 REBAR_ForceResize (hwnd);
1934 REBAR_MoveChildWindows (hwnd);
1940 static LRESULT WINAPI
1941 REBAR_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
1943 TRACE("hwnd=%x msg=%x wparam=%x lparam=%lx\n", hwnd, uMsg, wParam, lParam);
1944 if (!REBAR_GetInfoPtr (hwnd) && (uMsg != WM_CREATE))
1945 return DefWindowProcA (hwnd, uMsg, wParam, lParam);
1948 /* case RB_BEGINDRAG: */
1951 return REBAR_DeleteBand (hwnd, wParam, lParam);
1953 /* case RB_DRAGMOVE: */
1954 /* case RB_ENDDRAG: */
1956 case RB_GETBANDBORDERS:
1957 return REBAR_GetBandBorders (hwnd, wParam, lParam);
1959 case RB_GETBANDCOUNT:
1960 return REBAR_GetBandCount (hwnd);
1962 /* case RB_GETBANDINFO32: */ /* outdated, just for compatibility */
1964 case RB_GETBANDINFOA:
1965 return REBAR_GetBandInfoA (hwnd, wParam, lParam);
1967 case RB_GETBANDINFOW:
1968 return REBAR_GetBandInfoW (hwnd, wParam, lParam);
1970 case RB_GETBARHEIGHT:
1971 return REBAR_GetBarHeight (hwnd, wParam, lParam);
1974 return REBAR_GetBarInfo (hwnd, wParam, lParam);
1977 return REBAR_GetBkColor (hwnd);
1979 /* case RB_GETCOLORSCHEME: */
1980 /* case RB_GETDROPTARGET: */
1983 return REBAR_GetPalette (hwnd, wParam, lParam);
1986 return REBAR_GetRect (hwnd, wParam, lParam);
1988 case RB_GETROWCOUNT:
1989 return REBAR_GetRowCount (hwnd);
1991 case RB_GETROWHEIGHT:
1992 return REBAR_GetRowHeight (hwnd, wParam, lParam);
1994 case RB_GETTEXTCOLOR:
1995 return REBAR_GetTextColor (hwnd);
1997 case RB_GETTOOLTIPS:
1998 return REBAR_GetToolTips (hwnd);
2000 case RB_GETUNICODEFORMAT:
2001 return REBAR_GetUnicodeFormat (hwnd);
2003 case CCM_GETVERSION:
2004 return REBAR_GetVersion (hwnd);
2007 return REBAR_HitTest (hwnd, wParam, lParam);
2010 return REBAR_IdToIndex (hwnd, wParam, lParam);
2012 case RB_INSERTBANDA:
2013 return REBAR_InsertBandA (hwnd, wParam, lParam);
2015 case RB_INSERTBANDW:
2016 return REBAR_InsertBandW (hwnd, wParam, lParam);
2018 case RB_MAXIMIZEBAND:
2019 return REBAR_MaximizeBand (hwnd, wParam, lParam);
2021 case RB_MINIMIZEBAND:
2022 return REBAR_MinimizeBand (hwnd, wParam, lParam);
2025 return REBAR_MoveBand (hwnd, wParam, lParam);
2027 case RB_SETBANDINFOA:
2028 return REBAR_SetBandInfoA (hwnd, wParam, lParam);
2030 case RB_SETBANDINFOW:
2031 return REBAR_SetBandInfoW (hwnd, wParam, lParam);
2034 return REBAR_SetBarInfo (hwnd, wParam, lParam);
2037 return REBAR_SetBkColor (hwnd, wParam, lParam);
2039 /* case RB_SETCOLORSCHEME: */
2040 /* case RB_SETPALETTE: */
2041 /* return REBAR_GetPalette (hwnd, wParam, lParam); */
2044 return REBAR_SetParent (hwnd, wParam, lParam);
2046 case RB_SETTEXTCOLOR:
2047 return REBAR_SetTextColor (hwnd, wParam, lParam);
2049 /* case RB_SETTOOLTIPS: */
2051 case RB_SETUNICODEFORMAT:
2052 return REBAR_SetUnicodeFormat (hwnd, wParam);
2054 case CCM_SETVERSION:
2055 return REBAR_SetVersion (hwnd, (INT)wParam);
2058 return REBAR_ShowBand (hwnd, wParam, lParam);
2061 return REBAR_SizeToRect (hwnd, wParam, lParam);
2065 return SendMessageA (GetParent (hwnd), uMsg, wParam, lParam);
2068 return REBAR_Create (hwnd, wParam, lParam);
2071 return REBAR_Destroy (hwnd, wParam, lParam);
2074 return REBAR_GetFont (hwnd, wParam, lParam);
2076 /* case WM_MOUSEMOVE: */
2077 /* return REBAR_MouseMove (hwnd, wParam, lParam); */
2080 return REBAR_NCCalcSize (hwnd, wParam, lParam);
2083 return REBAR_NCPaint (hwnd, wParam, lParam);
2086 return SendMessageA (GetParent (hwnd), uMsg, wParam, lParam);
2089 return REBAR_Paint (hwnd, wParam);
2092 return REBAR_SetCursor (hwnd, wParam, lParam);
2095 return REBAR_SetFont (hwnd, wParam, lParam);
2098 return REBAR_Size (hwnd, wParam, lParam);
2100 /* case WM_TIMER: */
2102 /* case WM_WININICHANGE: */
2105 if (uMsg >= WM_USER)
2106 ERR("unknown msg %04x wp=%08x lp=%08lx\n",
2107 uMsg, wParam, lParam);
2108 return DefWindowProcA (hwnd, uMsg, wParam, lParam);
2115 REBAR_Register (void)
2119 ZeroMemory (&wndClass, sizeof(WNDCLASSA));
2120 wndClass.style = CS_GLOBALCLASS | CS_DBLCLKS;
2121 wndClass.lpfnWndProc = (WNDPROC)REBAR_WindowProc;
2122 wndClass.cbClsExtra = 0;
2123 wndClass.cbWndExtra = sizeof(REBAR_INFO *);
2124 wndClass.hCursor = 0;
2125 wndClass.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1);
2126 wndClass.lpszClassName = REBARCLASSNAMEA;
2128 RegisterClassA (&wndClass);
2133 REBAR_Unregister (void)
2135 UnregisterClassA (REBARCLASSNAMEA, (HINSTANCE)NULL);