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.
26 #include "sysmetrics.h"
29 DEFAULT_DEBUG_CHANNEL(rebar)
33 #define DRAW_GRIPPER 1
38 #define GRIPPER_WIDTH 13
41 #define REBAR_GetInfoPtr(wndPtr) ((REBAR_INFO *)GetWindowLongA (hwnd, 0))
45 REBAR_DrawBand (HDC hdc, REBAR_INFO *infoPtr, REBAR_BAND *lpBand)
48 DrawEdge (hdc, &lpBand->rcBand, BDR_RAISEDINNER, BF_MIDDLE);
53 if (lpBand->fDraw & DRAW_GRIPPER)
54 DrawEdge (hdc, &lpBand->rcGripper, BDR_RAISEDINNER, BF_RECT | BF_MIDDLE);
56 /* draw caption image */
57 if (lpBand->fDraw & DRAW_IMAGE) {
58 /* FIXME: center image */
61 pt.y = (lpBand->rcCapImage.bottom + lpBand->rcCapImage.top - infoPtr->imageSize.cy)/2;
62 pt.x = (lpBand->rcCapImage.right + lpBand->rcCapImage.left - infoPtr->imageSize.cx)/2;
64 ImageList_Draw (infoPtr->himl, lpBand->iImage, hdc,
65 /* lpBand->rcCapImage.left, lpBand->rcCapImage.top, */
70 /* draw caption text */
71 if (lpBand->fDraw & DRAW_TEXT) {
72 HFONT hOldFont = SelectObject (hdc, infoPtr->hFont);
73 INT oldBkMode = SetBkMode (hdc, TRANSPARENT);
74 DrawTextW (hdc, lpBand->lpText, -1, &lpBand->rcCapText,
75 DT_CENTER | DT_VCENTER | DT_SINGLELINE);
76 if (oldBkMode != TRANSPARENT)
77 SetBkMode (hdc, oldBkMode);
78 SelectObject (hdc, hOldFont);
84 REBAR_Refresh (HWND hwnd, HDC hdc)
86 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
90 for (i = 0; i < infoPtr->uNumBands; i++) {
91 lpBand = &infoPtr->bands[i];
93 if ((lpBand->fStyle & RBBS_HIDDEN) ||
94 ((GetWindowLongA (hwnd, GWL_STYLE) & CCS_VERT) &&
95 (lpBand->fStyle & RBBS_NOVERT)))
98 REBAR_DrawBand (hdc, infoPtr, lpBand);
105 REBAR_CalcHorzBand (REBAR_INFO *infoPtr, REBAR_BAND *lpBand)
109 /* set initial caption image rectangle */
110 SetRect (&lpBand->rcCapImage, 0, 0, 0, 0);
112 /* image is visible */
113 if ((lpBand->iImage > -1) && (infoPtr->himl)) {
114 lpBand->fDraw |= DRAW_IMAGE;
116 lpBand->rcCapImage.right = lpBand->rcCapImage.left + infoPtr->imageSize.cx;
117 lpBand->rcCapImage.bottom = lpBand->rcCapImage.top + infoPtr->imageSize.cy;
119 /* update band height */
120 if (lpBand->uMinHeight < infoPtr->imageSize.cy + 2) {
121 lpBand->uMinHeight = infoPtr->imageSize.cy + 2;
122 lpBand->rcBand.bottom = lpBand->rcBand.top + lpBand->uMinHeight;
126 /* set initial caption text rectangle */
127 lpBand->rcCapText.left = lpBand->rcCapImage.right;
128 lpBand->rcCapText.top = lpBand->rcBand.top + 1;
129 lpBand->rcCapText.right = lpBand->rcCapText.left;
130 lpBand->rcCapText.bottom = lpBand->rcBand.bottom - 1;
132 /* text is visible */
133 if (lpBand->lpText) {
135 HFONT hOldFont = SelectObject (hdc, infoPtr->hFont);
138 lpBand->fDraw |= DRAW_TEXT;
139 GetTextExtentPoint32W (hdc, lpBand->lpText,
140 lstrlenW (lpBand->lpText), &size);
141 lpBand->rcCapText.right += size.cx;
143 SelectObject (hdc, hOldFont);
147 /* set initial child window rectangle */
148 if (lpBand->fStyle & RBBS_FIXEDSIZE) {
149 lpBand->rcChild.left = lpBand->rcCapText.right;
150 lpBand->rcChild.top = lpBand->rcBand.top;
151 lpBand->rcChild.right = lpBand->rcBand.right;
152 lpBand->rcChild.bottom = lpBand->rcBand.bottom;
155 lpBand->rcChild.left = lpBand->rcCapText.right + 4;
156 lpBand->rcChild.top = lpBand->rcBand.top + 2;
157 lpBand->rcChild.right = lpBand->rcBand.right - 4;
158 lpBand->rcChild.bottom = lpBand->rcBand.bottom - 2;
161 /* calculate gripper rectangle */
162 if ((!(lpBand->fStyle & RBBS_NOGRIPPER)) &&
163 (!(lpBand->fStyle & RBBS_FIXEDSIZE)) &&
164 ((lpBand->fStyle & RBBS_GRIPPERALWAYS) ||
165 (infoPtr->uNumBands > 1))) {
166 lpBand->fDraw |= DRAW_GRIPPER;
167 lpBand->rcGripper.left = lpBand->rcBand.left + 3;
168 lpBand->rcGripper.right = lpBand->rcGripper.left + 3;
169 lpBand->rcGripper.top = lpBand->rcBand.top + 3;
170 lpBand->rcGripper.bottom = lpBand->rcBand.bottom - 3;
172 /* move caption rectangles */
173 OffsetRect (&lpBand->rcCapImage, GRIPPER_WIDTH, 0);
174 OffsetRect (&lpBand->rcCapText, GRIPPER_WIDTH, 0);
176 /* adjust child rectangle */
177 lpBand->rcChild.left += GRIPPER_WIDTH;
185 REBAR_CalcVertBand (HWND hwnd, REBAR_INFO *infoPtr, REBAR_BAND *lpBand)
189 /* set initial caption image rectangle */
190 SetRect (&lpBand->rcCapImage, 0, 0, 0, 0);
192 /* image is visible */
193 if ((lpBand->iImage > -1) && (infoPtr->himl)) {
194 lpBand->fDraw |= DRAW_IMAGE;
196 lpBand->rcCapImage.right = lpBand->rcCapImage.left + infoPtr->imageSize.cx;
197 lpBand->rcCapImage.bottom = lpBand->rcCapImage.top + infoPtr->imageSize.cy;
199 /* update band width */
200 if (lpBand->uMinHeight < infoPtr->imageSize.cx + 2) {
201 lpBand->uMinHeight = infoPtr->imageSize.cx + 2;
202 lpBand->rcBand.right = lpBand->rcBand.left + lpBand->uMinHeight;
206 /* set initial caption text rectangle */
207 lpBand->rcCapText.left = lpBand->rcBand.left + 1;
208 lpBand->rcCapText.top = lpBand->rcCapImage.bottom;
209 lpBand->rcCapText.right = lpBand->rcBand.right - 1;
210 lpBand->rcCapText.bottom = lpBand->rcCapText.top;
212 /* text is visible */
213 if (lpBand->lpText) {
215 HFONT hOldFont = SelectObject (hdc, infoPtr->hFont);
218 lpBand->fDraw |= DRAW_TEXT;
219 GetTextExtentPoint32W (hdc, lpBand->lpText,
220 lstrlenW (lpBand->lpText), &size);
221 /* lpBand->rcCapText.right += size.cx; */
222 lpBand->rcCapText.bottom += size.cy;
224 SelectObject (hdc, hOldFont);
228 /* set initial child window rectangle */
229 if (lpBand->fStyle & RBBS_FIXEDSIZE) {
230 lpBand->rcChild.left = lpBand->rcBand.left;
231 lpBand->rcChild.top = lpBand->rcCapText.bottom;
232 lpBand->rcChild.right = lpBand->rcBand.right;
233 lpBand->rcChild.bottom = lpBand->rcBand.bottom;
236 lpBand->rcChild.left = lpBand->rcBand.left + 2;
237 lpBand->rcChild.top = lpBand->rcCapText.bottom + 4;
238 lpBand->rcChild.right = lpBand->rcBand.right - 2;
239 lpBand->rcChild.bottom = lpBand->rcBand.bottom - 4;
242 /* calculate gripper rectangle */
243 if ((!(lpBand->fStyle & RBBS_NOGRIPPER)) &&
244 (!(lpBand->fStyle & RBBS_FIXEDSIZE)) &&
245 ((lpBand->fStyle & RBBS_GRIPPERALWAYS) ||
246 (infoPtr->uNumBands > 1))) {
247 lpBand->fDraw |= DRAW_GRIPPER;
249 if (GetWindowLongA (hwnd, GWL_STYLE) & RBS_VERTICALGRIPPER) {
250 /* adjust band width */
251 lpBand->rcBand.right += GRIPPER_WIDTH;
252 lpBand->uMinHeight += GRIPPER_WIDTH;
254 lpBand->rcGripper.left = lpBand->rcBand.left + 3;
255 lpBand->rcGripper.right = lpBand->rcGripper.left + 3;
256 lpBand->rcGripper.top = lpBand->rcBand.top + 3;
257 lpBand->rcGripper.bottom = lpBand->rcBand.bottom - 3;
259 /* move caption rectangles */
260 OffsetRect (&lpBand->rcCapImage, GRIPPER_WIDTH, 0);
261 OffsetRect (&lpBand->rcCapText, GRIPPER_WIDTH, 0);
263 /* adjust child rectangle */
264 lpBand->rcChild.left += GRIPPER_WIDTH;
267 lpBand->rcGripper.left = lpBand->rcBand.left + 3;
268 lpBand->rcGripper.right = lpBand->rcBand.right - 3;
269 lpBand->rcGripper.top = lpBand->rcBand.top + 3;
270 lpBand->rcGripper.bottom = lpBand->rcGripper.top + 3;
272 /* move caption rectangles */
273 OffsetRect (&lpBand->rcCapImage, 0, GRIPPER_WIDTH);
274 OffsetRect (&lpBand->rcCapText, 0, GRIPPER_WIDTH);
276 /* adjust child rectangle */
277 lpBand->rcChild.top += GRIPPER_WIDTH;
284 REBAR_Layout (HWND hwnd, LPRECT lpRect)
286 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
287 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
296 GetClientRect (hwnd, &rcClient);
301 if (dwStyle & CCS_VERT) {
302 cx = 20; /* FIXME: fixed height */
303 cy = rcClient.bottom - rcClient.top;
306 cx = rcClient.right - rcClient.left;
307 cy = 20; /* FIXME: fixed height */
310 for (i = 0; i < infoPtr->uNumBands; i++) {
311 lpBand = &infoPtr->bands[i];
313 if ((lpBand->fStyle & RBBS_HIDDEN) ||
314 ((dwStyle & CCS_VERT) && (lpBand->fStyle & RBBS_NOVERT)))
318 if (dwStyle & CCS_VERT) {
319 if (lpBand->fStyle & RBBS_VARIABLEHEIGHT)
320 cx = lpBand->cyMaxChild;
321 else if (lpBand->fStyle & RBBIM_CHILDSIZE)
322 cx = lpBand->cyMinChild;
326 lpBand->rcBand.left = x;
327 lpBand->rcBand.right = x + cx;
328 lpBand->rcBand.top = y;
329 lpBand->rcBand.bottom = y + cy;
330 lpBand->uMinHeight = cx;
333 if (lpBand->fStyle & RBBS_VARIABLEHEIGHT)
334 cy = lpBand->cyMaxChild;
335 else if (lpBand->fStyle & RBBIM_CHILDSIZE)
336 cy = lpBand->cyMinChild;
340 lpBand->rcBand.left = x;
341 lpBand->rcBand.right = x + cx;
342 lpBand->rcBand.top = y;
343 lpBand->rcBand.bottom = y + cy;
344 lpBand->uMinHeight = cy;
347 if (dwStyle & CCS_VERT) {
348 REBAR_CalcVertBand (hwnd, infoPtr, lpBand);
349 x += lpBand->uMinHeight;
352 REBAR_CalcHorzBand (infoPtr, lpBand);
353 y += lpBand->uMinHeight;
357 if (dwStyle & CCS_VERT) {
358 infoPtr->calcSize.cx = x;
359 infoPtr->calcSize.cy = rcClient.bottom - rcClient.top;
362 infoPtr->calcSize.cx = rcClient.right - rcClient.left;
363 infoPtr->calcSize.cy = y;
369 REBAR_ForceResize (HWND hwnd)
371 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
374 TRACE (rebar, " to [%d x %d]!\n",
375 infoPtr->calcSize.cx, infoPtr->calcSize.cy);
377 infoPtr->bAutoResize = TRUE;
381 rc.right = infoPtr->calcSize.cx;
382 rc.bottom = infoPtr->calcSize.cy;
384 if (GetWindowLongA (hwnd, GWL_STYLE) & WS_BORDER) {
385 InflateRect (&rc, sysMetrics[SM_CXEDGE], sysMetrics[SM_CYEDGE]);
388 SetWindowPos (hwnd, 0, 0, 0,
389 rc.right - rc.left, rc.bottom - rc.top,
390 SWP_NOMOVE | SWP_NOZORDER | SWP_SHOWWINDOW);
395 REBAR_MoveChildWindows (HWND hwnd)
397 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
399 CHAR szClassName[40];
402 for (i = 0; i < infoPtr->uNumBands; i++) {
403 lpBand = &infoPtr->bands[i];
405 if (lpBand->fStyle & RBBS_HIDDEN)
407 if (lpBand->hwndChild) {
408 TRACE (rebar, "hwndChild = %x\n", lpBand->hwndChild);
410 GetClassNameA (lpBand->hwndChild, szClassName, 40);
411 if (!lstrcmpA (szClassName, "ComboBox")) {
412 INT nEditHeight, yPos;
415 /* special placement code for combo box */
418 /* get size of edit line */
419 GetWindowRect (lpBand->hwndChild, &rc);
420 nEditHeight = rc.bottom - rc.top;
421 yPos = (lpBand->rcChild.bottom + lpBand->rcChild.top - nEditHeight)/2;
423 /* center combo box inside child area */
424 SetWindowPos (lpBand->hwndChild, HWND_TOP,
425 lpBand->rcChild.left, /*lpBand->rcChild.top*/ yPos,
426 lpBand->rcChild.right - lpBand->rcChild.left,
431 else if (!lstrcmpA (szClassName, WC_COMBOBOXEXA)) {
432 /* special placement code for extended combo box */
438 SetWindowPos (lpBand->hwndChild, HWND_TOP,
439 lpBand->rcChild.left, lpBand->rcChild.top,
440 lpBand->rcChild.right - lpBand->rcChild.left,
441 lpBand->rcChild.bottom - lpBand->rcChild.top,
450 REBAR_InternalHitTest (HWND hwnd, LPPOINT lpPt, UINT *pFlags, INT *pBand)
452 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
457 GetClientRect (hwnd, &rect);
459 *pFlags = RBHT_NOWHERE;
460 if (PtInRect (&rect, *lpPt))
462 if (infoPtr->uNumBands == 0) {
463 *pFlags = RBHT_NOWHERE;
466 TRACE (rebar, "NOWHERE\n");
470 /* somewhere inside */
471 for (iCount = 0; iCount < infoPtr->uNumBands; iCount++) {
472 lpBand = &infoPtr->bands[iCount];
473 if (PtInRect (&lpBand->rcBand, *lpPt)) {
476 if (PtInRect (&lpBand->rcGripper, *lpPt)) {
477 *pFlags = RBHT_GRABBER;
478 TRACE (rebar, "ON GRABBER %d\n", iCount);
481 else if (PtInRect (&lpBand->rcCapImage, *lpPt)) {
482 *pFlags = RBHT_CAPTION;
483 TRACE (rebar, "ON CAPTION %d\n", iCount);
486 else if (PtInRect (&lpBand->rcCapText, *lpPt)) {
487 *pFlags = RBHT_CAPTION;
488 TRACE (rebar, "ON CAPTION %d\n", iCount);
491 else if (PtInRect (&lpBand->rcChild, *lpPt)) {
492 *pFlags = RBHT_CLIENT;
493 TRACE (rebar, "ON CLIENT %d\n", iCount);
497 *pFlags = RBHT_NOWHERE;
498 TRACE (rebar, "NOWHERE %d\n", iCount);
504 *pFlags = RBHT_NOWHERE;
508 TRACE (rebar, "NOWHERE\n");
513 *pFlags = RBHT_NOWHERE;
516 TRACE (rebar, "NOWHERE\n");
520 TRACE (rebar, "flags=0x%X\n", *pFlags);
526 /* << REBAR_BeginDrag >> */
530 REBAR_DeleteBand (HWND hwnd, WPARAM wParam, LPARAM lParam)
532 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
533 UINT uBand = (UINT)wParam;
535 if (uBand >= infoPtr->uNumBands)
538 TRACE (rebar, "deleting band %u!\n", uBand);
540 if (infoPtr->uNumBands == 1) {
541 TRACE (rebar, " simple delete!\n");
542 COMCTL32_Free (infoPtr->bands);
543 infoPtr->bands = NULL;
544 infoPtr->uNumBands = 0;
547 REBAR_BAND *oldBands = infoPtr->bands;
548 TRACE(rebar, "complex delete! [uBand=%u]\n", uBand);
550 infoPtr->uNumBands--;
551 infoPtr->bands = COMCTL32_Alloc (sizeof (REBAR_BAND) * infoPtr->uNumBands);
553 memcpy (&infoPtr->bands[0], &oldBands[0],
554 uBand * sizeof(REBAR_BAND));
557 if (uBand < infoPtr->uNumBands) {
558 memcpy (&infoPtr->bands[uBand], &oldBands[uBand+1],
559 (infoPtr->uNumBands - uBand) * sizeof(REBAR_BAND));
562 COMCTL32_Free (oldBands);
565 REBAR_Layout (hwnd, NULL);
566 REBAR_ForceResize (hwnd);
567 REBAR_MoveChildWindows (hwnd);
573 /* << REBAR_DragMove >> */
574 /* << REBAR_EndDrag >> */
578 REBAR_GetBandBorders (HWND hwnd, WPARAM wParam, LPARAM lParam)
580 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
581 /* LPRECT32 lpRect = (LPRECT32)lParam; */
586 if ((UINT)wParam >= infoPtr->uNumBands)
589 lpBand = &infoPtr->bands[(UINT)wParam];
590 if (GetWindowLongA (hwnd, GWL_STYLE) & RBS_BANDBORDERS) {
601 __inline__ static LRESULT
602 REBAR_GetBandCount (HWND hwnd)
604 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
606 TRACE (rebar, "band count %u!\n", infoPtr->uNumBands);
608 return infoPtr->uNumBands;
613 REBAR_GetBandInfoA (HWND hwnd, WPARAM wParam, LPARAM lParam)
615 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
616 LPREBARBANDINFOA lprbbi = (LPREBARBANDINFOA)lParam;
621 if (lprbbi->cbSize < REBARBANDINFO_V3_SIZEA)
623 if ((UINT)wParam >= infoPtr->uNumBands)
626 TRACE (rebar, "index %u\n", (UINT)wParam);
628 /* copy band information */
629 lpBand = &infoPtr->bands[(UINT)wParam];
631 if (lprbbi->fMask & RBBIM_STYLE)
632 lprbbi->fStyle = lpBand->fStyle;
634 if (lprbbi->fMask & RBBIM_COLORS) {
635 lprbbi->clrFore = lpBand->clrFore;
636 lprbbi->clrBack = lpBand->clrBack;
639 if ((lprbbi->fMask & RBBIM_TEXT) &&
640 (lprbbi->lpText) && (lpBand->lpText)) {
641 lstrcpynWtoA (lprbbi->lpText, lpBand->lpText, lprbbi->cch);
644 if (lprbbi->fMask & RBBIM_IMAGE)
645 lprbbi->iImage = lpBand->iImage;
647 if (lprbbi->fMask & RBBIM_CHILD)
648 lprbbi->hwndChild = lpBand->hwndChild;
650 if (lprbbi->fMask & RBBIM_CHILDSIZE) {
651 lprbbi->cxMinChild = lpBand->cxMinChild;
652 lprbbi->cyMinChild = lpBand->cyMinChild;
653 lprbbi->cyMaxChild = lpBand->cyMaxChild;
654 lprbbi->cyChild = lpBand->cyChild;
655 lprbbi->cyIntegral = lpBand->cyIntegral;
658 if (lprbbi->fMask & RBBIM_SIZE)
659 lprbbi->cx = lpBand->cx;
661 if (lprbbi->fMask & RBBIM_BACKGROUND)
662 lprbbi->hbmBack = lpBand->hbmBack;
664 if (lprbbi->fMask & RBBIM_ID)
665 lprbbi->wID = lpBand->wID;
667 /* check for additional data */
668 if (lprbbi->cbSize >= sizeof (REBARBANDINFOA)) {
669 if (lprbbi->fMask & RBBIM_IDEALSIZE)
670 lprbbi->cxIdeal = lpBand->cxIdeal;
672 if (lprbbi->fMask & RBBIM_LPARAM)
673 lprbbi->lParam = lpBand->lParam;
675 if (lprbbi->fMask & RBBIM_HEADERSIZE)
676 lprbbi->cxHeader = lpBand->cxHeader;
684 REBAR_GetBandInfoW (HWND hwnd, WPARAM wParam, LPARAM lParam)
686 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
687 LPREBARBANDINFOW lprbbi = (LPREBARBANDINFOW)lParam;
692 if (lprbbi->cbSize < REBARBANDINFO_V3_SIZEW)
694 if ((UINT)wParam >= infoPtr->uNumBands)
697 TRACE (rebar, "index %u\n", (UINT)wParam);
699 /* copy band information */
700 lpBand = &infoPtr->bands[(UINT)wParam];
702 if (lprbbi->fMask & RBBIM_STYLE)
703 lprbbi->fStyle = lpBand->fStyle;
705 if (lprbbi->fMask & RBBIM_COLORS) {
706 lprbbi->clrFore = lpBand->clrFore;
707 lprbbi->clrBack = lpBand->clrBack;
710 if ((lprbbi->fMask & RBBIM_TEXT) &&
711 (lprbbi->lpText) && (lpBand->lpText)) {
712 lstrcpynW (lprbbi->lpText, lpBand->lpText, lprbbi->cch);
715 if (lprbbi->fMask & RBBIM_IMAGE)
716 lprbbi->iImage = lpBand->iImage;
718 if (lprbbi->fMask & RBBIM_CHILD)
719 lprbbi->hwndChild = lpBand->hwndChild;
721 if (lprbbi->fMask & RBBIM_CHILDSIZE) {
722 lprbbi->cxMinChild = lpBand->cxMinChild;
723 lprbbi->cyMinChild = lpBand->cyMinChild;
724 lprbbi->cyMaxChild = lpBand->cyMaxChild;
725 lprbbi->cyChild = lpBand->cyChild;
726 lprbbi->cyIntegral = lpBand->cyIntegral;
729 if (lprbbi->fMask & RBBIM_SIZE)
730 lprbbi->cx = lpBand->cx;
732 if (lprbbi->fMask & RBBIM_BACKGROUND)
733 lprbbi->hbmBack = lpBand->hbmBack;
735 if (lprbbi->fMask & RBBIM_ID)
736 lprbbi->wID = lpBand->wID;
738 /* check for additional data */
739 if (lprbbi->cbSize >= sizeof (REBARBANDINFOA)) {
740 if (lprbbi->fMask & RBBIM_IDEALSIZE)
741 lprbbi->cxIdeal = lpBand->cxIdeal;
743 if (lprbbi->fMask & RBBIM_LPARAM)
744 lprbbi->lParam = lpBand->lParam;
746 if (lprbbi->fMask & RBBIM_HEADERSIZE)
747 lprbbi->cxHeader = lpBand->cxHeader;
755 REBAR_GetBarHeight (HWND hwnd, WPARAM wParam, LPARAM lParam)
757 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
760 REBAR_Layout (hwnd, NULL);
761 nHeight = infoPtr->calcSize.cy;
763 if (GetWindowLongA (hwnd, GWL_STYLE) & WS_BORDER)
764 nHeight += (2 * sysMetrics[SM_CYEDGE]);
766 FIXME (rebar, "height = %d\n", nHeight);
773 REBAR_GetBarInfo (HWND hwnd, WPARAM wParam, LPARAM lParam)
775 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
776 LPREBARINFO lpInfo = (LPREBARINFO)lParam;
781 if (lpInfo->cbSize < sizeof (REBARINFO))
784 TRACE (rebar, "getting bar info!\n");
787 lpInfo->himl = infoPtr->himl;
788 lpInfo->fMask |= RBIM_IMAGELIST;
795 __inline__ static LRESULT
796 REBAR_GetBkColor (HWND hwnd)
798 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
800 TRACE (rebar, "background color 0x%06lx!\n", infoPtr->clrBk);
802 return infoPtr->clrBk;
806 /* << REBAR_GetColorScheme >> */
807 /* << REBAR_GetDropTarget >> */
811 REBAR_GetPalette (HWND hwnd, WPARAM wParam, LPARAM lParam)
813 FIXME (rebar, "empty stub!\n");
820 REBAR_GetRect (HWND hwnd, WPARAM wParam, LPARAM lParam)
822 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
823 INT iBand = (INT)wParam;
824 LPRECT lprc = (LPRECT)lParam;
827 if ((iBand < 0) && ((UINT)iBand >= infoPtr->uNumBands))
832 TRACE (rebar, "band %d\n", iBand);
834 lpBand = &infoPtr->bands[iBand];
835 CopyRect (lprc, &lpBand->rcBand);
837 lprc->left = lpBand->rcBand.left;
838 lprc->top = lpBand->rcBand.top;
839 lprc->right = lpBand->rcBand.right;
840 lprc->bottom = lpBand->rcBand.bottom;
847 __inline__ static LRESULT
848 REBAR_GetRowCount (HWND hwnd)
850 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
852 FIXME (rebar, "%u : semi stub!\n", infoPtr->uNumBands);
854 return infoPtr->uNumBands;
859 REBAR_GetRowHeight (HWND hwnd, WPARAM wParam, LPARAM lParam)
861 /* REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd); */
863 FIXME (rebar, "-- height = 20: semi stub!\n");
869 __inline__ static LRESULT
870 REBAR_GetTextColor (HWND hwnd)
872 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
874 TRACE (rebar, "text color 0x%06lx!\n", infoPtr->clrText);
876 return infoPtr->clrText;
880 __inline__ static LRESULT
881 REBAR_GetToolTips (HWND hwnd)
883 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
884 return infoPtr->hwndToolTip;
888 __inline__ static LRESULT
889 REBAR_GetUnicodeFormat (HWND hwnd)
891 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
892 return infoPtr->bUnicode;
897 REBAR_HitTest (HWND hwnd, WPARAM wParam, LPARAM lParam)
899 /* REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd); */
900 LPRBHITTESTINFO lprbht = (LPRBHITTESTINFO)lParam;
905 REBAR_InternalHitTest (hwnd, &lprbht->pt, &lprbht->flags, &lprbht->iBand);
907 return lprbht->iBand;
912 REBAR_IdToIndex (HWND hwnd, WPARAM wParam, LPARAM lParam)
914 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
920 if (infoPtr->uNumBands < 1)
923 TRACE (rebar, "id %u\n", (UINT)wParam);
925 for (i = 0; i < infoPtr->uNumBands; i++) {
926 if (infoPtr->bands[i].wID == (UINT)wParam) {
927 TRACE (rebar, "band %u found!\n", i);
932 TRACE (rebar, "no band found!\n");
938 REBAR_InsertBandA (HWND hwnd, WPARAM wParam, LPARAM lParam)
940 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
941 LPREBARBANDINFOA lprbbi = (LPREBARBANDINFOA)lParam;
942 UINT uIndex = (UINT)wParam;
949 if (lprbbi->cbSize < REBARBANDINFO_V3_SIZEA)
952 TRACE (rebar, "insert band at %u!\n", uIndex);
954 if (infoPtr->uNumBands == 0) {
955 infoPtr->bands = (REBAR_BAND *)COMCTL32_Alloc (sizeof (REBAR_BAND));
959 REBAR_BAND *oldBands = infoPtr->bands;
961 (REBAR_BAND *)COMCTL32_Alloc ((infoPtr->uNumBands+1)*sizeof(REBAR_BAND));
962 if (((INT)uIndex == -1) || (uIndex > infoPtr->uNumBands))
963 uIndex = infoPtr->uNumBands;
965 /* pre insert copy */
967 memcpy (&infoPtr->bands[0], &oldBands[0],
968 uIndex * sizeof(REBAR_BAND));
972 if (uIndex < infoPtr->uNumBands - 1) {
973 memcpy (&infoPtr->bands[uIndex+1], &oldBands[uIndex],
974 (infoPtr->uNumBands - uIndex - 1) * sizeof(REBAR_BAND));
977 COMCTL32_Free (oldBands);
980 infoPtr->uNumBands++;
982 TRACE (rebar, "index %u!\n", uIndex);
984 /* initialize band (infoPtr->bands[uIndex])*/
985 lpBand = &infoPtr->bands[uIndex];
987 if (lprbbi->fMask & RBBIM_STYLE)
988 lpBand->fStyle = lprbbi->fStyle;
990 if (lprbbi->fMask & RBBIM_COLORS) {
991 lpBand->clrFore = lprbbi->clrFore;
992 lpBand->clrBack = lprbbi->clrBack;
995 lpBand->clrFore = CLR_NONE;
996 lpBand->clrBack = CLR_NONE;
999 if ((lprbbi->fMask & RBBIM_TEXT) && (lprbbi->lpText)) {
1000 INT len = lstrlenA (lprbbi->lpText);
1002 lpBand->lpText = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
1003 lstrcpyAtoW (lpBand->lpText, lprbbi->lpText);
1007 if (lprbbi->fMask & RBBIM_IMAGE)
1008 lpBand->iImage = lprbbi->iImage;
1010 lpBand->iImage = -1;
1012 if (lprbbi->fMask & RBBIM_CHILD) {
1013 TRACE (rebar, "hwndChild = %x\n", lprbbi->hwndChild);
1014 lpBand->hwndChild = lprbbi->hwndChild;
1015 lpBand->hwndPrevParent =
1016 SetParent (lpBand->hwndChild, hwnd);
1019 if (lprbbi->fMask & RBBIM_CHILDSIZE) {
1020 lpBand->cxMinChild = lprbbi->cxMinChild;
1021 lpBand->cyMinChild = lprbbi->cyMinChild;
1022 lpBand->cyMaxChild = lprbbi->cyMaxChild;
1023 lpBand->cyChild = lprbbi->cyChild;
1024 lpBand->cyIntegral = lprbbi->cyIntegral;
1027 lpBand->cxMinChild = -1;
1028 lpBand->cyMinChild = -1;
1029 lpBand->cyMaxChild = -1;
1030 lpBand->cyChild = -1;
1031 lpBand->cyIntegral = -1;
1034 if (lprbbi->fMask & RBBIM_SIZE)
1035 lpBand->cx = lprbbi->cx;
1039 if (lprbbi->fMask & RBBIM_BACKGROUND)
1040 lpBand->hbmBack = lprbbi->hbmBack;
1042 if (lprbbi->fMask & RBBIM_ID)
1043 lpBand->wID = lprbbi->wID;
1045 /* check for additional data */
1046 if (lprbbi->cbSize >= sizeof (REBARBANDINFOA)) {
1047 if (lprbbi->fMask & RBBIM_IDEALSIZE)
1048 lpBand->cxIdeal = lprbbi->cxIdeal;
1050 if (lprbbi->fMask & RBBIM_LPARAM)
1051 lpBand->lParam = lprbbi->lParam;
1053 if (lprbbi->fMask & RBBIM_HEADERSIZE)
1054 lpBand->cxHeader = lprbbi->cxHeader;
1058 REBAR_Layout (hwnd, NULL);
1059 REBAR_ForceResize (hwnd);
1060 REBAR_MoveChildWindows (hwnd);
1067 REBAR_InsertBandW (HWND hwnd, WPARAM wParam, LPARAM lParam)
1069 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
1070 LPREBARBANDINFOW lprbbi = (LPREBARBANDINFOW)lParam;
1071 UINT uIndex = (UINT)wParam;
1074 if (infoPtr == NULL)
1078 if (lprbbi->cbSize < REBARBANDINFO_V3_SIZEW)
1081 TRACE (rebar, "insert band at %u!\n", uIndex);
1083 if (infoPtr->uNumBands == 0) {
1084 infoPtr->bands = (REBAR_BAND *)COMCTL32_Alloc (sizeof (REBAR_BAND));
1088 REBAR_BAND *oldBands = infoPtr->bands;
1090 (REBAR_BAND *)COMCTL32_Alloc ((infoPtr->uNumBands+1)*sizeof(REBAR_BAND));
1091 if (((INT)uIndex == -1) || (uIndex > infoPtr->uNumBands))
1092 uIndex = infoPtr->uNumBands;
1094 /* pre insert copy */
1096 memcpy (&infoPtr->bands[0], &oldBands[0],
1097 uIndex * sizeof(REBAR_BAND));
1101 if (uIndex < infoPtr->uNumBands - 1) {
1102 memcpy (&infoPtr->bands[uIndex+1], &oldBands[uIndex],
1103 (infoPtr->uNumBands - uIndex - 1) * sizeof(REBAR_BAND));
1106 COMCTL32_Free (oldBands);
1109 infoPtr->uNumBands++;
1111 TRACE (rebar, "index %u!\n", uIndex);
1113 /* initialize band (infoPtr->bands[uIndex])*/
1114 lpBand = &infoPtr->bands[uIndex];
1116 if (lprbbi->fMask & RBBIM_STYLE)
1117 lpBand->fStyle = lprbbi->fStyle;
1119 if (lprbbi->fMask & RBBIM_COLORS) {
1120 lpBand->clrFore = lprbbi->clrFore;
1121 lpBand->clrBack = lprbbi->clrBack;
1124 lpBand->clrFore = CLR_NONE;
1125 lpBand->clrBack = CLR_NONE;
1128 if ((lprbbi->fMask & RBBIM_TEXT) && (lprbbi->lpText)) {
1129 INT len = lstrlenW (lprbbi->lpText);
1131 lpBand->lpText = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
1132 lstrcpyW (lpBand->lpText, lprbbi->lpText);
1136 if (lprbbi->fMask & RBBIM_IMAGE)
1137 lpBand->iImage = lprbbi->iImage;
1139 lpBand->iImage = -1;
1141 if (lprbbi->fMask & RBBIM_CHILD) {
1142 TRACE (rebar, "hwndChild = %x\n", lprbbi->hwndChild);
1143 lpBand->hwndChild = lprbbi->hwndChild;
1144 lpBand->hwndPrevParent =
1145 SetParent (lpBand->hwndChild, hwnd);
1148 if (lprbbi->fMask & RBBIM_CHILDSIZE) {
1149 lpBand->cxMinChild = lprbbi->cxMinChild;
1150 lpBand->cyMinChild = lprbbi->cyMinChild;
1151 lpBand->cyMaxChild = lprbbi->cyMaxChild;
1152 lpBand->cyChild = lprbbi->cyChild;
1153 lpBand->cyIntegral = lprbbi->cyIntegral;
1156 lpBand->cxMinChild = -1;
1157 lpBand->cyMinChild = -1;
1158 lpBand->cyMaxChild = -1;
1159 lpBand->cyChild = -1;
1160 lpBand->cyIntegral = -1;
1163 if (lprbbi->fMask & RBBIM_SIZE)
1164 lpBand->cx = lprbbi->cx;
1168 if (lprbbi->fMask & RBBIM_BACKGROUND)
1169 lpBand->hbmBack = lprbbi->hbmBack;
1171 if (lprbbi->fMask & RBBIM_ID)
1172 lpBand->wID = lprbbi->wID;
1174 /* check for additional data */
1175 if (lprbbi->cbSize >= sizeof (REBARBANDINFOW)) {
1176 if (lprbbi->fMask & RBBIM_IDEALSIZE)
1177 lpBand->cxIdeal = lprbbi->cxIdeal;
1179 if (lprbbi->fMask & RBBIM_LPARAM)
1180 lpBand->lParam = lprbbi->lParam;
1182 if (lprbbi->fMask & RBBIM_HEADERSIZE)
1183 lpBand->cxHeader = lprbbi->cxHeader;
1187 REBAR_Layout (hwnd, NULL);
1188 REBAR_ForceResize (hwnd);
1189 REBAR_MoveChildWindows (hwnd);
1196 REBAR_MaximizeBand (HWND hwnd, WPARAM wParam, LPARAM lParam)
1198 /* REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd); */
1200 FIXME (rebar, "(uBand = %u fIdeal = %s)\n",
1201 (UINT)wParam, lParam ? "TRUE" : "FALSE");
1209 REBAR_MinimizeBand (HWND hwnd, WPARAM wParam, LPARAM lParam)
1211 /* REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd); */
1213 FIXME (rebar, "(uBand = %u)\n", (UINT)wParam);
1221 REBAR_MoveBand (HWND hwnd, WPARAM wParam, LPARAM lParam)
1223 /* REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd); */
1225 FIXME (rebar, "(iFrom = %u iTof = %u)\n",
1226 (UINT)wParam, (UINT)lParam);
1234 REBAR_SetBandInfoA (HWND hwnd, WPARAM wParam, LPARAM lParam)
1236 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
1237 LPREBARBANDINFOA lprbbi = (LPREBARBANDINFOA)lParam;
1242 if (lprbbi->cbSize < REBARBANDINFO_V3_SIZEA)
1244 if ((UINT)wParam >= infoPtr->uNumBands)
1247 TRACE (rebar, "index %u\n", (UINT)wParam);
1249 /* set band information */
1250 lpBand = &infoPtr->bands[(UINT)wParam];
1252 if (lprbbi->fMask & RBBIM_STYLE)
1253 lpBand->fStyle = lprbbi->fStyle;
1255 if (lprbbi->fMask & RBBIM_COLORS) {
1256 lpBand->clrFore = lprbbi->clrFore;
1257 lpBand->clrBack = lprbbi->clrBack;
1260 if (lprbbi->fMask & RBBIM_TEXT) {
1261 if (lpBand->lpText) {
1262 COMCTL32_Free (lpBand->lpText);
1263 lpBand->lpText = NULL;
1265 if (lprbbi->lpText) {
1266 INT len = lstrlenA (lprbbi->lpText);
1267 lpBand->lpText = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
1268 lstrcpyAtoW (lpBand->lpText, lprbbi->lpText);
1272 if (lprbbi->fMask & RBBIM_IMAGE)
1273 lpBand->iImage = lprbbi->iImage;
1275 if (lprbbi->fMask & RBBIM_CHILD) {
1276 if (lprbbi->hwndChild) {
1277 lpBand->hwndChild = lprbbi->hwndChild;
1278 lpBand->hwndPrevParent =
1279 SetParent (lpBand->hwndChild, hwnd);
1282 TRACE (rebar, "child: 0x%x prev parent: 0x%x\n",
1283 lpBand->hwndChild, lpBand->hwndPrevParent);
1284 lpBand->hwndChild = 0;
1285 lpBand->hwndPrevParent = 0;
1289 if (lprbbi->fMask & RBBIM_CHILDSIZE) {
1290 lpBand->cxMinChild = lprbbi->cxMinChild;
1291 lpBand->cyMinChild = lprbbi->cyMinChild;
1292 lpBand->cyMaxChild = lprbbi->cyMaxChild;
1293 lpBand->cyChild = lprbbi->cyChild;
1294 lpBand->cyIntegral = lprbbi->cyIntegral;
1297 if (lprbbi->fMask & RBBIM_SIZE)
1298 lpBand->cx = lprbbi->cx;
1300 if (lprbbi->fMask & RBBIM_BACKGROUND)
1301 lpBand->hbmBack = lprbbi->hbmBack;
1303 if (lprbbi->fMask & RBBIM_ID)
1304 lpBand->wID = lprbbi->wID;
1306 /* check for additional data */
1307 if (lprbbi->cbSize >= sizeof (REBARBANDINFOA)) {
1308 if (lprbbi->fMask & RBBIM_IDEALSIZE)
1309 lpBand->cxIdeal = lprbbi->cxIdeal;
1311 if (lprbbi->fMask & RBBIM_LPARAM)
1312 lpBand->lParam = lprbbi->lParam;
1314 if (lprbbi->fMask & RBBIM_HEADERSIZE)
1315 lpBand->cxHeader = lprbbi->cxHeader;
1318 REBAR_Layout (hwnd, NULL);
1319 REBAR_ForceResize (hwnd);
1320 REBAR_MoveChildWindows (hwnd);
1327 REBAR_SetBandInfoW (HWND hwnd, WPARAM wParam, LPARAM lParam)
1329 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
1330 LPREBARBANDINFOW lprbbi = (LPREBARBANDINFOW)lParam;
1335 if (lprbbi->cbSize < REBARBANDINFO_V3_SIZEW)
1337 if ((UINT)wParam >= infoPtr->uNumBands)
1340 TRACE (rebar, "index %u\n", (UINT)wParam);
1342 /* set band information */
1343 lpBand = &infoPtr->bands[(UINT)wParam];
1345 if (lprbbi->fMask & RBBIM_STYLE)
1346 lpBand->fStyle = lprbbi->fStyle;
1348 if (lprbbi->fMask & RBBIM_COLORS) {
1349 lpBand->clrFore = lprbbi->clrFore;
1350 lpBand->clrBack = lprbbi->clrBack;
1353 if (lprbbi->fMask & RBBIM_TEXT) {
1354 if (lpBand->lpText) {
1355 COMCTL32_Free (lpBand->lpText);
1356 lpBand->lpText = NULL;
1358 if (lprbbi->lpText) {
1359 INT len = lstrlenW (lprbbi->lpText);
1360 lpBand->lpText = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
1361 lstrcpyW (lpBand->lpText, lprbbi->lpText);
1365 if (lprbbi->fMask & RBBIM_IMAGE)
1366 lpBand->iImage = lprbbi->iImage;
1368 if (lprbbi->fMask & RBBIM_CHILD) {
1369 if (lprbbi->hwndChild) {
1370 lpBand->hwndChild = lprbbi->hwndChild;
1371 lpBand->hwndPrevParent =
1372 SetParent (lpBand->hwndChild, hwnd);
1375 TRACE (rebar, "child: 0x%x prev parent: 0x%x\n",
1376 lpBand->hwndChild, lpBand->hwndPrevParent);
1377 lpBand->hwndChild = 0;
1378 lpBand->hwndPrevParent = 0;
1382 if (lprbbi->fMask & RBBIM_CHILDSIZE) {
1383 lpBand->cxMinChild = lprbbi->cxMinChild;
1384 lpBand->cyMinChild = lprbbi->cyMinChild;
1385 lpBand->cyMaxChild = lprbbi->cyMaxChild;
1386 lpBand->cyChild = lprbbi->cyChild;
1387 lpBand->cyIntegral = lprbbi->cyIntegral;
1390 if (lprbbi->fMask & RBBIM_SIZE)
1391 lpBand->cx = lprbbi->cx;
1393 if (lprbbi->fMask & RBBIM_BACKGROUND)
1394 lpBand->hbmBack = lprbbi->hbmBack;
1396 if (lprbbi->fMask & RBBIM_ID)
1397 lpBand->wID = lprbbi->wID;
1399 /* check for additional data */
1400 if (lprbbi->cbSize >= sizeof (REBARBANDINFOW)) {
1401 if (lprbbi->fMask & RBBIM_IDEALSIZE)
1402 lpBand->cxIdeal = lprbbi->cxIdeal;
1404 if (lprbbi->fMask & RBBIM_LPARAM)
1405 lpBand->lParam = lprbbi->lParam;
1407 if (lprbbi->fMask & RBBIM_HEADERSIZE)
1408 lpBand->cxHeader = lprbbi->cxHeader;
1411 REBAR_Layout (hwnd, NULL);
1412 REBAR_ForceResize (hwnd);
1413 REBAR_MoveChildWindows (hwnd);
1420 REBAR_SetBarInfo (HWND hwnd, WPARAM wParam, LPARAM lParam)
1422 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
1423 LPREBARINFO lpInfo = (LPREBARINFO)lParam;
1428 if (lpInfo->cbSize < sizeof (REBARINFO))
1431 TRACE (rebar, "setting bar info!\n");
1433 if (lpInfo->fMask & RBIM_IMAGELIST) {
1434 infoPtr->himl = lpInfo->himl;
1435 if (infoPtr->himl) {
1436 ImageList_GetIconSize (infoPtr->himl, &infoPtr->imageSize.cx,
1437 &infoPtr->imageSize.cy);
1440 infoPtr->imageSize.cx = 0;
1441 infoPtr->imageSize.cy = 0;
1450 REBAR_SetBkColor (HWND hwnd, WPARAM wParam, LPARAM lParam)
1452 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
1455 clrTemp = infoPtr->clrBk;
1456 infoPtr->clrBk = (COLORREF)lParam;
1458 TRACE (rebar, "background color 0x%06lx!\n", infoPtr->clrBk);
1464 /* << REBAR_SetColorScheme >> */
1465 /* << REBAR_SetPalette >> */
1469 REBAR_SetParent (HWND hwnd, WPARAM wParam, LPARAM lParam)
1471 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
1472 HWND hwndTemp = infoPtr->hwndNotify;
1474 infoPtr->hwndNotify = (HWND)wParam;
1476 return (LRESULT)hwndTemp;
1481 REBAR_SetTextColor (HWND hwnd, WPARAM wParam, LPARAM lParam)
1483 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
1486 clrTemp = infoPtr->clrText;
1487 infoPtr->clrText = (COLORREF)lParam;
1489 TRACE (rebar, "text color 0x%06lx!\n", infoPtr->clrText);
1495 /* << REBAR_SetTooltips >> */
1498 __inline__ static LRESULT
1499 REBAR_SetUnicodeFormat (HWND hwnd, WPARAM wParam)
1501 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
1502 BOOL bTemp = infoPtr->bUnicode;
1503 infoPtr->bUnicode = (BOOL)wParam;
1509 REBAR_ShowBand (HWND hwnd, WPARAM wParam, LPARAM lParam)
1511 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
1514 if (((INT)wParam < 0) || ((INT)wParam > infoPtr->uNumBands))
1517 lpBand = &infoPtr->bands[(INT)wParam];
1520 TRACE (rebar, "show band %d\n", (INT)wParam);
1521 lpBand->fStyle = lpBand->fStyle & ~RBBS_HIDDEN;
1522 if (IsWindow (lpBand->hwndChild))
1523 ShowWindow (lpBand->hwndChild, SW_SHOW);
1526 TRACE (rebar, "hide band %d\n", (INT)wParam);
1527 lpBand->fStyle = lpBand->fStyle | RBBS_HIDDEN;
1528 if (IsWindow (lpBand->hwndChild))
1529 ShowWindow (lpBand->hwndChild, SW_SHOW);
1532 REBAR_Layout (hwnd, NULL);
1533 REBAR_ForceResize (hwnd);
1534 REBAR_MoveChildWindows (hwnd);
1541 REBAR_SizeToRect (HWND hwnd, WPARAM wParam, LPARAM lParam)
1543 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
1544 LPRECT lpRect = (LPRECT)lParam;
1549 FIXME (rebar, "layout change not implemented!\n");
1550 FIXME (rebar, "[%d %d %d %d]\n",
1551 lpRect->left, lpRect->top, lpRect->right, lpRect->bottom);
1554 SetWindowPos (hwnd, 0, lpRect->left, lpRect->top,
1555 lpRect->right - lpRect->left, lpRect->bottom - lpRect->top,
1559 infoPtr->calcSize.cx = lpRect->right - lpRect->left;
1560 infoPtr->calcSize.cy = lpRect->bottom - lpRect->top;
1562 REBAR_ForceResize (hwnd);
1569 REBAR_Create (HWND hwnd, WPARAM wParam, LPARAM lParam)
1571 REBAR_INFO *infoPtr;
1573 /* allocate memory for info structure */
1574 infoPtr = (REBAR_INFO *)COMCTL32_Alloc (sizeof(REBAR_INFO));
1575 SetWindowLongA (hwnd, 0, (DWORD)infoPtr);
1577 /* initialize info structure */
1578 infoPtr->clrBk = CLR_NONE;
1579 infoPtr->clrText = RGB(0, 0, 0);
1581 infoPtr->bAutoResize = FALSE;
1582 infoPtr->hcurArrow = LoadCursorA (0, IDC_ARROWA);
1583 infoPtr->hcurHorz = LoadCursorA (0, IDC_SIZEWEA);
1584 infoPtr->hcurVert = LoadCursorA (0, IDC_SIZENSA);
1585 infoPtr->hcurDrag = LoadCursorA (0, IDC_SIZEA);
1587 infoPtr->bUnicode = IsWindowUnicode (hwnd);
1589 if (GetWindowLongA (hwnd, GWL_STYLE) & RBS_AUTOSIZE)
1590 FIXME (rebar, "style RBS_AUTOSIZE set!\n");
1593 SendMessageA (hwnd, WM_NOTIFYFORMAT, (WPARAM)hwnd, NF_QUERY);
1596 TRACE (rebar, "created!\n");
1602 REBAR_Destroy (HWND hwnd, WPARAM wParam, LPARAM lParam)
1604 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
1609 /* free rebar bands */
1610 if ((infoPtr->uNumBands > 0) && infoPtr->bands) {
1611 /* clean up each band */
1612 for (i = 0; i < infoPtr->uNumBands; i++) {
1613 lpBand = &infoPtr->bands[i];
1615 /* delete text strings */
1616 if (lpBand->lpText) {
1617 COMCTL32_Free (lpBand->lpText);
1618 lpBand->lpText = NULL;
1620 /* destroy child window */
1621 DestroyWindow (lpBand->hwndChild);
1624 /* free band array */
1625 COMCTL32_Free (infoPtr->bands);
1626 infoPtr->bands = NULL;
1632 DeleteObject (infoPtr->hcurArrow);
1633 DeleteObject (infoPtr->hcurHorz);
1634 DeleteObject (infoPtr->hcurVert);
1635 DeleteObject (infoPtr->hcurDrag);
1640 /* free rebar info data */
1641 COMCTL32_Free (infoPtr);
1643 TRACE (rebar, "destroyed!\n");
1649 REBAR_GetFont (HWND hwnd, WPARAM wParam, LPARAM lParam)
1651 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
1653 return (LRESULT)infoPtr->hFont;
1659 REBAR_MouseMove (HWND hwnd, WPARAM wParam, LPARAM lParam)
1661 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
1668 __inline__ static LRESULT
1669 REBAR_NCCalcSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
1671 if (GetWindowLongA (hwnd, GWL_STYLE) & WS_BORDER) {
1672 ((LPRECT)lParam)->left += sysMetrics[SM_CXEDGE];
1673 ((LPRECT)lParam)->top += sysMetrics[SM_CYEDGE];
1674 ((LPRECT)lParam)->right -= sysMetrics[SM_CXEDGE];
1675 ((LPRECT)lParam)->bottom -= sysMetrics[SM_CYEDGE];
1683 REBAR_NCPaint (HWND hwnd, WPARAM wParam, LPARAM lParam)
1685 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
1689 if (dwStyle & WS_MINIMIZE)
1690 return 0; /* Nothing to do */
1692 DefWindowProcA (hwnd, WM_NCPAINT, wParam, lParam);
1694 if (!(hdc = GetDCEx( hwnd, 0, DCX_USESTYLE | DCX_WINDOW )))
1697 if (dwStyle & WS_BORDER) {
1698 GetWindowRect (hwnd, &rcWindow);
1699 OffsetRect (&rcWindow, -rcWindow.left, -rcWindow.top);
1700 DrawEdge (hdc, &rcWindow, EDGE_ETCHED, BF_RECT);
1703 ReleaseDC( hwnd, hdc );
1710 REBAR_Paint (HWND hwnd, WPARAM wParam)
1715 hdc = wParam==0 ? BeginPaint (hwnd, &ps) : (HDC)wParam;
1716 REBAR_Refresh (hwnd, hdc);
1718 EndPaint (hwnd, &ps);
1724 REBAR_SetCursor (HWND hwnd, WPARAM wParam, LPARAM lParam)
1726 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
1727 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
1731 TRACE (rebar, "code=0x%X id=0x%X\n", LOWORD(lParam), HIWORD(lParam));
1734 ScreenToClient (hwnd, &pt);
1736 REBAR_InternalHitTest (hwnd, &pt, &flags, NULL);
1738 if (flags == RBHT_GRABBER) {
1739 if ((dwStyle & CCS_VERT) &&
1740 !(dwStyle & RBS_VERTICALGRIPPER))
1741 SetCursor (infoPtr->hcurVert);
1743 SetCursor (infoPtr->hcurHorz);
1745 else if (flags != RBHT_CLIENT)
1746 SetCursor (infoPtr->hcurArrow);
1753 REBAR_SetFont (HWND hwnd, WPARAM wParam, LPARAM lParam)
1755 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
1757 /* TEXTMETRIC32A tm; */
1758 HFONT hFont /*, hOldFont */;
1761 infoPtr->hFont = (HFONT)wParam;
1763 hFont = infoPtr->hFont ? infoPtr->hFont : GetStockObject (SYSTEM_FONT);
1766 hOldFont = SelectObject32 (hdc, hFont);
1767 GetTextMetrics32A (hdc, &tm);
1768 infoPtr->nHeight = tm.tmHeight + VERT_BORDER;
1769 SelectObject32 (hdc, hOldFont);
1770 ReleaseDC32 (0, hdc);
1774 REBAR_Layout (hwnd);
1775 hdc = GetDC32 (hwnd);
1776 REBAR_Refresh (hwnd, hdc);
1777 ReleaseDC32 (hwnd, hdc);
1785 REBAR_Size (HWND hwnd, WPARAM wParam, LPARAM lParam)
1787 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
1788 /* DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE); */
1790 /* INT32 x, y, cx, cy; */
1792 /* auto resize deadlock check */
1793 if (infoPtr->bAutoResize) {
1794 infoPtr->bAutoResize = FALSE;
1798 TRACE (rebar, "sizing rebar!\n");
1800 /* get parent rectangle */
1801 GetClientRect (GetParent (hwnd), &rcParent);
1803 REBAR_Layout (hwnd, &rcParent);
1805 if (dwStyle & CCS_VERT) {
1806 if (dwStyle & CCS_LEFT == CCS_LEFT) {
1809 cx = infoPtr->calcSize.cx;
1810 cy = infoPtr->calcSize.cy;
1813 x = rcParent.right - infoPtr->calcSize.cx;
1815 cx = infoPtr->calcSize.cx;
1816 cy = infoPtr->calcSize.cy;
1820 if (dwStyle & CCS_TOP) {
1823 cx = infoPtr->calcSize.cx;
1824 cy = infoPtr->calcSize.cy;
1828 y = rcParent.bottom - infoPtr->calcSize.cy;
1829 cx = infoPtr->calcSize.cx;
1830 cy = infoPtr->calcSize.cy;
1834 SetWindowPos32 (hwnd, 0, x, y, cx, cy,
1835 SWP_NOZORDER | SWP_SHOWWINDOW);
1837 REBAR_Layout (hwnd, NULL);
1838 REBAR_ForceResize (hwnd);
1839 REBAR_MoveChildWindows (hwnd);
1846 REBAR_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
1850 /* case RB_BEGINDRAG: */
1853 return REBAR_DeleteBand (hwnd, wParam, lParam);
1855 /* case RB_DRAGMOVE: */
1856 /* case RB_ENDDRAG: */
1858 case RB_GETBANDBORDERS:
1859 return REBAR_GetBandBorders (hwnd, wParam, lParam);
1861 case RB_GETBANDCOUNT:
1862 return REBAR_GetBandCount (hwnd);
1864 /* case RB_GETBANDINFO32: */ /* outdated, just for compatibility */
1866 case RB_GETBANDINFOA:
1867 return REBAR_GetBandInfoA (hwnd, wParam, lParam);
1869 case RB_GETBANDINFOW:
1870 return REBAR_GetBandInfoW (hwnd, wParam, lParam);
1872 case RB_GETBARHEIGHT:
1873 return REBAR_GetBarHeight (hwnd, wParam, lParam);
1876 return REBAR_GetBarInfo (hwnd, wParam, lParam);
1879 return REBAR_GetBkColor (hwnd);
1881 /* case RB_GETCOLORSCHEME: */
1882 /* case RB_GETDROPTARGET: */
1885 return REBAR_GetPalette (hwnd, wParam, lParam);
1888 return REBAR_GetRect (hwnd, wParam, lParam);
1890 case RB_GETROWCOUNT:
1891 return REBAR_GetRowCount (hwnd);
1893 case RB_GETROWHEIGHT:
1894 return REBAR_GetRowHeight (hwnd, wParam, lParam);
1896 case RB_GETTEXTCOLOR:
1897 return REBAR_GetTextColor (hwnd);
1899 case RB_GETTOOLTIPS:
1900 return REBAR_GetToolTips (hwnd);
1902 case RB_GETUNICODEFORMAT:
1903 return REBAR_GetUnicodeFormat (hwnd);
1906 return REBAR_HitTest (hwnd, wParam, lParam);
1909 return REBAR_IdToIndex (hwnd, wParam, lParam);
1911 case RB_INSERTBANDA:
1912 return REBAR_InsertBandA (hwnd, wParam, lParam);
1914 case RB_INSERTBANDW:
1915 return REBAR_InsertBandW (hwnd, wParam, lParam);
1917 case RB_MAXIMIZEBAND:
1918 return REBAR_MaximizeBand (hwnd, wParam, lParam);
1920 case RB_MINIMIZEBAND:
1921 return REBAR_MinimizeBand (hwnd, wParam, lParam);
1924 return REBAR_MoveBand (hwnd, wParam, lParam);
1926 case RB_SETBANDINFOA:
1927 return REBAR_SetBandInfoA (hwnd, wParam, lParam);
1929 case RB_SETBANDINFOW:
1930 return REBAR_SetBandInfoW (hwnd, wParam, lParam);
1933 return REBAR_SetBarInfo (hwnd, wParam, lParam);
1936 return REBAR_SetBkColor (hwnd, wParam, lParam);
1938 /* case RB_SETCOLORSCHEME: */
1939 /* case RB_SETPALETTE: */
1940 /* return REBAR_GetPalette (hwnd, wParam, lParam); */
1943 return REBAR_SetParent (hwnd, wParam, lParam);
1945 case RB_SETTEXTCOLOR:
1946 return REBAR_SetTextColor (hwnd, wParam, lParam);
1948 /* case RB_SETTOOLTIPS: */
1950 case RB_SETUNICODEFORMAT:
1951 return REBAR_SetUnicodeFormat (hwnd, wParam);
1954 return REBAR_ShowBand (hwnd, wParam, lParam);
1957 return REBAR_SizeToRect (hwnd, wParam, lParam);
1961 return SendMessageA (GetParent (hwnd), uMsg, wParam, lParam);
1964 return REBAR_Create (hwnd, wParam, lParam);
1967 return REBAR_Destroy (hwnd, wParam, lParam);
1970 return REBAR_GetFont (hwnd, wParam, lParam);
1972 /* case WM_MOUSEMOVE: */
1973 /* return REBAR_MouseMove (hwnd, wParam, lParam); */
1976 return REBAR_NCCalcSize (hwnd, wParam, lParam);
1979 return REBAR_NCPaint (hwnd, wParam, lParam);
1982 return SendMessageA (GetParent (hwnd), uMsg, wParam, lParam);
1985 return REBAR_Paint (hwnd, wParam);
1988 return REBAR_SetCursor (hwnd, wParam, lParam);
1991 return REBAR_SetFont (hwnd, wParam, lParam);
1994 return REBAR_Size (hwnd, wParam, lParam);
1996 /* case WM_TIMER: */
1998 /* case WM_WININICHANGE: */
2001 if (uMsg >= WM_USER)
2002 ERR (rebar, "unknown msg %04x wp=%08x lp=%08lx\n",
2003 uMsg, wParam, lParam);
2004 return DefWindowProcA (hwnd, uMsg, wParam, lParam);
2011 REBAR_Register (VOID)
2015 if (GlobalFindAtomA (REBARCLASSNAMEA)) return;
2017 ZeroMemory (&wndClass, sizeof(WNDCLASSA));
2018 wndClass.style = CS_GLOBALCLASS | CS_DBLCLKS;
2019 wndClass.lpfnWndProc = (WNDPROC)REBAR_WindowProc;
2020 wndClass.cbClsExtra = 0;
2021 wndClass.cbWndExtra = sizeof(REBAR_INFO *);
2022 wndClass.hCursor = 0;
2023 wndClass.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1);
2024 wndClass.lpszClassName = REBARCLASSNAMEA;
2026 RegisterClassA (&wndClass);
2031 REBAR_Unregister (VOID)
2033 if (GlobalFindAtomA (REBARCLASSNAMEA))
2034 UnregisterClassA (REBARCLASSNAMEA, (HINSTANCE)NULL);