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.
27 #include "debugtools.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(" 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, GetSystemMetrics(SM_CXEDGE), GetSystemMetrics(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("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 INT nEditHeight, yPos;
436 /* special placement code for extended combo box */
438 /* get size of edit line */
439 hwndEdit = SendMessageA (lpBand->hwndChild, CBEM_GETEDITCONTROL, 0, 0);
440 GetWindowRect (hwndEdit, &rc);
441 nEditHeight = rc.bottom - rc.top;
442 yPos = (lpBand->rcChild.bottom + lpBand->rcChild.top - nEditHeight)/2;
444 /* center combo box inside child area */
445 SetWindowPos (lpBand->hwndChild, HWND_TOP,
446 lpBand->rcChild.left, /*lpBand->rcChild.top*/ yPos,
447 lpBand->rcChild.right - lpBand->rcChild.left,
454 SetWindowPos (lpBand->hwndChild, HWND_TOP,
455 lpBand->rcChild.left, lpBand->rcChild.top,
456 lpBand->rcChild.right - lpBand->rcChild.left,
457 lpBand->rcChild.bottom - lpBand->rcChild.top,
466 REBAR_InternalHitTest (HWND hwnd, LPPOINT lpPt, UINT *pFlags, INT *pBand)
468 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
473 GetClientRect (hwnd, &rect);
475 *pFlags = RBHT_NOWHERE;
476 if (PtInRect (&rect, *lpPt))
478 if (infoPtr->uNumBands == 0) {
479 *pFlags = RBHT_NOWHERE;
486 /* somewhere inside */
487 for (iCount = 0; iCount < infoPtr->uNumBands; iCount++) {
488 lpBand = &infoPtr->bands[iCount];
489 if (PtInRect (&lpBand->rcBand, *lpPt)) {
492 if (PtInRect (&lpBand->rcGripper, *lpPt)) {
493 *pFlags = RBHT_GRABBER;
494 TRACE("ON GRABBER %d\n", iCount);
497 else if (PtInRect (&lpBand->rcCapImage, *lpPt)) {
498 *pFlags = RBHT_CAPTION;
499 TRACE("ON CAPTION %d\n", iCount);
502 else if (PtInRect (&lpBand->rcCapText, *lpPt)) {
503 *pFlags = RBHT_CAPTION;
504 TRACE("ON CAPTION %d\n", iCount);
507 else if (PtInRect (&lpBand->rcChild, *lpPt)) {
508 *pFlags = RBHT_CLIENT;
509 TRACE("ON CLIENT %d\n", iCount);
513 *pFlags = RBHT_NOWHERE;
514 TRACE("NOWHERE %d\n", iCount);
520 *pFlags = RBHT_NOWHERE;
529 *pFlags = RBHT_NOWHERE;
536 TRACE("flags=0x%X\n", *pFlags);
542 /* << REBAR_BeginDrag >> */
546 REBAR_DeleteBand (HWND hwnd, WPARAM wParam, LPARAM lParam)
548 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
549 UINT uBand = (UINT)wParam;
551 if (uBand >= infoPtr->uNumBands)
554 TRACE("deleting band %u!\n", uBand);
556 if (infoPtr->uNumBands == 1) {
557 TRACE(" simple delete!\n");
558 COMCTL32_Free (infoPtr->bands);
559 infoPtr->bands = NULL;
560 infoPtr->uNumBands = 0;
563 REBAR_BAND *oldBands = infoPtr->bands;
564 TRACE("complex delete! [uBand=%u]\n", uBand);
566 infoPtr->uNumBands--;
567 infoPtr->bands = COMCTL32_Alloc (sizeof (REBAR_BAND) * infoPtr->uNumBands);
569 memcpy (&infoPtr->bands[0], &oldBands[0],
570 uBand * sizeof(REBAR_BAND));
573 if (uBand < infoPtr->uNumBands) {
574 memcpy (&infoPtr->bands[uBand], &oldBands[uBand+1],
575 (infoPtr->uNumBands - uBand) * sizeof(REBAR_BAND));
578 COMCTL32_Free (oldBands);
581 REBAR_Layout (hwnd, NULL);
582 REBAR_ForceResize (hwnd);
583 REBAR_MoveChildWindows (hwnd);
589 /* << REBAR_DragMove >> */
590 /* << REBAR_EndDrag >> */
594 REBAR_GetBandBorders (HWND hwnd, WPARAM wParam, LPARAM lParam)
596 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
597 /* LPRECT32 lpRect = (LPRECT32)lParam; */
602 if ((UINT)wParam >= infoPtr->uNumBands)
605 lpBand = &infoPtr->bands[(UINT)wParam];
606 if (GetWindowLongA (hwnd, GWL_STYLE) & RBS_BANDBORDERS) {
617 inline static LRESULT
618 REBAR_GetBandCount (HWND hwnd)
620 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
622 TRACE("band count %u!\n", infoPtr->uNumBands);
624 return infoPtr->uNumBands;
629 REBAR_GetBandInfoA (HWND hwnd, WPARAM wParam, LPARAM lParam)
631 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
632 LPREBARBANDINFOA lprbbi = (LPREBARBANDINFOA)lParam;
637 if (lprbbi->cbSize < REBARBANDINFO_V3_SIZEA)
639 if ((UINT)wParam >= infoPtr->uNumBands)
642 TRACE("index %u\n", (UINT)wParam);
644 /* copy band information */
645 lpBand = &infoPtr->bands[(UINT)wParam];
647 if (lprbbi->fMask & RBBIM_STYLE)
648 lprbbi->fStyle = lpBand->fStyle;
650 if (lprbbi->fMask & RBBIM_COLORS) {
651 lprbbi->clrFore = lpBand->clrFore;
652 lprbbi->clrBack = lpBand->clrBack;
655 if ((lprbbi->fMask & RBBIM_TEXT) &&
656 (lprbbi->lpText) && (lpBand->lpText)) {
657 lstrcpynWtoA (lprbbi->lpText, lpBand->lpText, lprbbi->cch);
660 if (lprbbi->fMask & RBBIM_IMAGE)
661 lprbbi->iImage = lpBand->iImage;
663 if (lprbbi->fMask & RBBIM_CHILD)
664 lprbbi->hwndChild = lpBand->hwndChild;
666 if (lprbbi->fMask & RBBIM_CHILDSIZE) {
667 lprbbi->cxMinChild = lpBand->cxMinChild;
668 lprbbi->cyMinChild = lpBand->cyMinChild;
669 lprbbi->cyMaxChild = lpBand->cyMaxChild;
670 lprbbi->cyChild = lpBand->cyChild;
671 lprbbi->cyIntegral = lpBand->cyIntegral;
674 if (lprbbi->fMask & RBBIM_SIZE)
675 lprbbi->cx = lpBand->cx;
677 if (lprbbi->fMask & RBBIM_BACKGROUND)
678 lprbbi->hbmBack = lpBand->hbmBack;
680 if (lprbbi->fMask & RBBIM_ID)
681 lprbbi->wID = lpBand->wID;
683 /* check for additional data */
684 if (lprbbi->cbSize >= sizeof (REBARBANDINFOA)) {
685 if (lprbbi->fMask & RBBIM_IDEALSIZE)
686 lprbbi->cxIdeal = lpBand->cxIdeal;
688 if (lprbbi->fMask & RBBIM_LPARAM)
689 lprbbi->lParam = lpBand->lParam;
691 if (lprbbi->fMask & RBBIM_HEADERSIZE)
692 lprbbi->cxHeader = lpBand->cxHeader;
700 REBAR_GetBandInfoW (HWND hwnd, WPARAM wParam, LPARAM lParam)
702 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
703 LPREBARBANDINFOW lprbbi = (LPREBARBANDINFOW)lParam;
708 if (lprbbi->cbSize < REBARBANDINFO_V3_SIZEW)
710 if ((UINT)wParam >= infoPtr->uNumBands)
713 TRACE("index %u\n", (UINT)wParam);
715 /* copy band information */
716 lpBand = &infoPtr->bands[(UINT)wParam];
718 if (lprbbi->fMask & RBBIM_STYLE)
719 lprbbi->fStyle = lpBand->fStyle;
721 if (lprbbi->fMask & RBBIM_COLORS) {
722 lprbbi->clrFore = lpBand->clrFore;
723 lprbbi->clrBack = lpBand->clrBack;
726 if ((lprbbi->fMask & RBBIM_TEXT) &&
727 (lprbbi->lpText) && (lpBand->lpText)) {
728 lstrcpynW (lprbbi->lpText, lpBand->lpText, lprbbi->cch);
731 if (lprbbi->fMask & RBBIM_IMAGE)
732 lprbbi->iImage = lpBand->iImage;
734 if (lprbbi->fMask & RBBIM_CHILD)
735 lprbbi->hwndChild = lpBand->hwndChild;
737 if (lprbbi->fMask & RBBIM_CHILDSIZE) {
738 lprbbi->cxMinChild = lpBand->cxMinChild;
739 lprbbi->cyMinChild = lpBand->cyMinChild;
740 lprbbi->cyMaxChild = lpBand->cyMaxChild;
741 lprbbi->cyChild = lpBand->cyChild;
742 lprbbi->cyIntegral = lpBand->cyIntegral;
745 if (lprbbi->fMask & RBBIM_SIZE)
746 lprbbi->cx = lpBand->cx;
748 if (lprbbi->fMask & RBBIM_BACKGROUND)
749 lprbbi->hbmBack = lpBand->hbmBack;
751 if (lprbbi->fMask & RBBIM_ID)
752 lprbbi->wID = lpBand->wID;
754 /* check for additional data */
755 if (lprbbi->cbSize >= sizeof (REBARBANDINFOA)) {
756 if (lprbbi->fMask & RBBIM_IDEALSIZE)
757 lprbbi->cxIdeal = lpBand->cxIdeal;
759 if (lprbbi->fMask & RBBIM_LPARAM)
760 lprbbi->lParam = lpBand->lParam;
762 if (lprbbi->fMask & RBBIM_HEADERSIZE)
763 lprbbi->cxHeader = lpBand->cxHeader;
771 REBAR_GetBarHeight (HWND hwnd, WPARAM wParam, LPARAM lParam)
773 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
776 REBAR_Layout (hwnd, NULL);
777 nHeight = infoPtr->calcSize.cy;
779 if (GetWindowLongA (hwnd, GWL_STYLE) & WS_BORDER)
780 nHeight += (2 * GetSystemMetrics(SM_CYEDGE));
783 FIXME("height = %d\n", nHeight);
790 REBAR_GetBarInfo (HWND hwnd, WPARAM wParam, LPARAM lParam)
792 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
793 LPREBARINFO lpInfo = (LPREBARINFO)lParam;
798 if (lpInfo->cbSize < sizeof (REBARINFO))
801 TRACE("getting bar info!\n");
804 lpInfo->himl = infoPtr->himl;
805 lpInfo->fMask |= RBIM_IMAGELIST;
812 inline static LRESULT
813 REBAR_GetBkColor (HWND hwnd)
815 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
817 TRACE("background color 0x%06lx!\n", infoPtr->clrBk);
819 return infoPtr->clrBk;
823 /* << REBAR_GetColorScheme >> */
824 /* << REBAR_GetDropTarget >> */
828 REBAR_GetPalette (HWND hwnd, WPARAM wParam, LPARAM lParam)
830 FIXME("empty stub!\n");
837 REBAR_GetRect (HWND hwnd, WPARAM wParam, LPARAM lParam)
839 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
840 INT iBand = (INT)wParam;
841 LPRECT lprc = (LPRECT)lParam;
844 if ((iBand < 0) && ((UINT)iBand >= infoPtr->uNumBands))
849 TRACE("band %d\n", iBand);
851 lpBand = &infoPtr->bands[iBand];
852 CopyRect (lprc, &lpBand->rcBand);
854 lprc->left = lpBand->rcBand.left;
855 lprc->top = lpBand->rcBand.top;
856 lprc->right = lpBand->rcBand.right;
857 lprc->bottom = lpBand->rcBand.bottom;
864 inline static LRESULT
865 REBAR_GetRowCount (HWND hwnd)
867 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
869 FIXME("%u : semi stub!\n", infoPtr->uNumBands);
871 return infoPtr->uNumBands;
876 REBAR_GetRowHeight (HWND hwnd, WPARAM wParam, LPARAM lParam)
878 /* REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd); */
880 FIXME("-- height = 20: semi stub!\n");
886 inline static LRESULT
887 REBAR_GetTextColor (HWND hwnd)
889 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
891 TRACE("text color 0x%06lx!\n", infoPtr->clrText);
893 return infoPtr->clrText;
897 inline static LRESULT
898 REBAR_GetToolTips (HWND hwnd)
900 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
901 return infoPtr->hwndToolTip;
905 inline static LRESULT
906 REBAR_GetUnicodeFormat (HWND hwnd)
908 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
909 return infoPtr->bUnicode;
913 inline static LRESULT
914 REBAR_GetVersion (HWND hwnd)
916 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
917 return infoPtr->iVersion;
922 REBAR_HitTest (HWND hwnd, WPARAM wParam, LPARAM lParam)
924 /* REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd); */
925 LPRBHITTESTINFO lprbht = (LPRBHITTESTINFO)lParam;
930 REBAR_InternalHitTest (hwnd, &lprbht->pt, &lprbht->flags, &lprbht->iBand);
932 return lprbht->iBand;
937 REBAR_IdToIndex (HWND hwnd, WPARAM wParam, LPARAM lParam)
939 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
945 if (infoPtr->uNumBands < 1)
948 TRACE("id %u\n", (UINT)wParam);
950 for (i = 0; i < infoPtr->uNumBands; i++) {
951 if (infoPtr->bands[i].wID == (UINT)wParam) {
952 TRACE("band %u found!\n", i);
957 TRACE("no band found!\n");
963 REBAR_InsertBandA (HWND hwnd, WPARAM wParam, LPARAM lParam)
965 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
966 LPREBARBANDINFOA lprbbi = (LPREBARBANDINFOA)lParam;
967 UINT uIndex = (UINT)wParam;
974 if (lprbbi->cbSize < REBARBANDINFO_V3_SIZEA)
977 TRACE("insert band at %u!\n", uIndex);
979 if (infoPtr->uNumBands == 0) {
980 infoPtr->bands = (REBAR_BAND *)COMCTL32_Alloc (sizeof (REBAR_BAND));
984 REBAR_BAND *oldBands = infoPtr->bands;
986 (REBAR_BAND *)COMCTL32_Alloc ((infoPtr->uNumBands+1)*sizeof(REBAR_BAND));
987 if (((INT)uIndex == -1) || (uIndex > infoPtr->uNumBands))
988 uIndex = infoPtr->uNumBands;
990 /* pre insert copy */
992 memcpy (&infoPtr->bands[0], &oldBands[0],
993 uIndex * sizeof(REBAR_BAND));
997 if (uIndex < infoPtr->uNumBands - 1) {
998 memcpy (&infoPtr->bands[uIndex+1], &oldBands[uIndex],
999 (infoPtr->uNumBands - uIndex - 1) * sizeof(REBAR_BAND));
1002 COMCTL32_Free (oldBands);
1005 infoPtr->uNumBands++;
1007 TRACE("index %u!\n", uIndex);
1009 /* initialize band (infoPtr->bands[uIndex])*/
1010 lpBand = &infoPtr->bands[uIndex];
1012 if (lprbbi->fMask & RBBIM_STYLE)
1013 lpBand->fStyle = lprbbi->fStyle;
1015 if (lprbbi->fMask & RBBIM_COLORS) {
1016 lpBand->clrFore = lprbbi->clrFore;
1017 lpBand->clrBack = lprbbi->clrBack;
1020 lpBand->clrFore = CLR_NONE;
1021 lpBand->clrBack = CLR_NONE;
1024 if ((lprbbi->fMask & RBBIM_TEXT) && (lprbbi->lpText)) {
1025 INT len = lstrlenA (lprbbi->lpText);
1027 lpBand->lpText = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
1028 lstrcpyAtoW (lpBand->lpText, lprbbi->lpText);
1032 if (lprbbi->fMask & RBBIM_IMAGE)
1033 lpBand->iImage = lprbbi->iImage;
1035 lpBand->iImage = -1;
1037 if (lprbbi->fMask & RBBIM_CHILD) {
1038 TRACE("hwndChild = %x\n", lprbbi->hwndChild);
1039 lpBand->hwndChild = lprbbi->hwndChild;
1040 lpBand->hwndPrevParent =
1041 SetParent (lpBand->hwndChild, hwnd);
1044 if (lprbbi->fMask & RBBIM_CHILDSIZE) {
1045 lpBand->cxMinChild = lprbbi->cxMinChild;
1046 lpBand->cyMinChild = lprbbi->cyMinChild;
1047 lpBand->cyMaxChild = lprbbi->cyMaxChild;
1048 lpBand->cyChild = lprbbi->cyChild;
1049 lpBand->cyIntegral = lprbbi->cyIntegral;
1052 lpBand->cxMinChild = -1;
1053 lpBand->cyMinChild = -1;
1054 lpBand->cyMaxChild = -1;
1055 lpBand->cyChild = -1;
1056 lpBand->cyIntegral = -1;
1059 if (lprbbi->fMask & RBBIM_SIZE)
1060 lpBand->cx = lprbbi->cx;
1064 if (lprbbi->fMask & RBBIM_BACKGROUND)
1065 lpBand->hbmBack = lprbbi->hbmBack;
1067 if (lprbbi->fMask & RBBIM_ID)
1068 lpBand->wID = lprbbi->wID;
1070 /* check for additional data */
1071 if (lprbbi->cbSize >= sizeof (REBARBANDINFOA)) {
1072 if (lprbbi->fMask & RBBIM_IDEALSIZE)
1073 lpBand->cxIdeal = lprbbi->cxIdeal;
1075 if (lprbbi->fMask & RBBIM_LPARAM)
1076 lpBand->lParam = lprbbi->lParam;
1078 if (lprbbi->fMask & RBBIM_HEADERSIZE)
1079 lpBand->cxHeader = lprbbi->cxHeader;
1083 REBAR_Layout (hwnd, NULL);
1084 REBAR_ForceResize (hwnd);
1085 REBAR_MoveChildWindows (hwnd);
1092 REBAR_InsertBandW (HWND hwnd, WPARAM wParam, LPARAM lParam)
1094 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
1095 LPREBARBANDINFOW lprbbi = (LPREBARBANDINFOW)lParam;
1096 UINT uIndex = (UINT)wParam;
1099 if (infoPtr == NULL)
1103 if (lprbbi->cbSize < REBARBANDINFO_V3_SIZEW)
1106 TRACE("insert band at %u!\n", uIndex);
1108 if (infoPtr->uNumBands == 0) {
1109 infoPtr->bands = (REBAR_BAND *)COMCTL32_Alloc (sizeof (REBAR_BAND));
1113 REBAR_BAND *oldBands = infoPtr->bands;
1115 (REBAR_BAND *)COMCTL32_Alloc ((infoPtr->uNumBands+1)*sizeof(REBAR_BAND));
1116 if (((INT)uIndex == -1) || (uIndex > infoPtr->uNumBands))
1117 uIndex = infoPtr->uNumBands;
1119 /* pre insert copy */
1121 memcpy (&infoPtr->bands[0], &oldBands[0],
1122 uIndex * sizeof(REBAR_BAND));
1126 if (uIndex < infoPtr->uNumBands - 1) {
1127 memcpy (&infoPtr->bands[uIndex+1], &oldBands[uIndex],
1128 (infoPtr->uNumBands - uIndex - 1) * sizeof(REBAR_BAND));
1131 COMCTL32_Free (oldBands);
1134 infoPtr->uNumBands++;
1136 TRACE("index %u!\n", uIndex);
1138 /* initialize band (infoPtr->bands[uIndex])*/
1139 lpBand = &infoPtr->bands[uIndex];
1141 if (lprbbi->fMask & RBBIM_STYLE)
1142 lpBand->fStyle = lprbbi->fStyle;
1144 if (lprbbi->fMask & RBBIM_COLORS) {
1145 lpBand->clrFore = lprbbi->clrFore;
1146 lpBand->clrBack = lprbbi->clrBack;
1149 lpBand->clrFore = CLR_NONE;
1150 lpBand->clrBack = CLR_NONE;
1153 if ((lprbbi->fMask & RBBIM_TEXT) && (lprbbi->lpText)) {
1154 INT len = lstrlenW (lprbbi->lpText);
1156 lpBand->lpText = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
1157 lstrcpyW (lpBand->lpText, lprbbi->lpText);
1161 if (lprbbi->fMask & RBBIM_IMAGE)
1162 lpBand->iImage = lprbbi->iImage;
1164 lpBand->iImage = -1;
1166 if (lprbbi->fMask & RBBIM_CHILD) {
1167 TRACE("hwndChild = %x\n", lprbbi->hwndChild);
1168 lpBand->hwndChild = lprbbi->hwndChild;
1169 lpBand->hwndPrevParent =
1170 SetParent (lpBand->hwndChild, hwnd);
1173 if (lprbbi->fMask & RBBIM_CHILDSIZE) {
1174 lpBand->cxMinChild = lprbbi->cxMinChild;
1175 lpBand->cyMinChild = lprbbi->cyMinChild;
1176 lpBand->cyMaxChild = lprbbi->cyMaxChild;
1177 lpBand->cyChild = lprbbi->cyChild;
1178 lpBand->cyIntegral = lprbbi->cyIntegral;
1181 lpBand->cxMinChild = -1;
1182 lpBand->cyMinChild = -1;
1183 lpBand->cyMaxChild = -1;
1184 lpBand->cyChild = -1;
1185 lpBand->cyIntegral = -1;
1188 if (lprbbi->fMask & RBBIM_SIZE)
1189 lpBand->cx = lprbbi->cx;
1193 if (lprbbi->fMask & RBBIM_BACKGROUND)
1194 lpBand->hbmBack = lprbbi->hbmBack;
1196 if (lprbbi->fMask & RBBIM_ID)
1197 lpBand->wID = lprbbi->wID;
1199 /* check for additional data */
1200 if (lprbbi->cbSize >= sizeof (REBARBANDINFOW)) {
1201 if (lprbbi->fMask & RBBIM_IDEALSIZE)
1202 lpBand->cxIdeal = lprbbi->cxIdeal;
1204 if (lprbbi->fMask & RBBIM_LPARAM)
1205 lpBand->lParam = lprbbi->lParam;
1207 if (lprbbi->fMask & RBBIM_HEADERSIZE)
1208 lpBand->cxHeader = lprbbi->cxHeader;
1212 REBAR_Layout (hwnd, NULL);
1213 REBAR_ForceResize (hwnd);
1214 REBAR_MoveChildWindows (hwnd);
1221 REBAR_MaximizeBand (HWND hwnd, WPARAM wParam, LPARAM lParam)
1223 /* REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd); */
1225 FIXME("(uBand = %u fIdeal = %s)\n",
1226 (UINT)wParam, lParam ? "TRUE" : "FALSE");
1234 REBAR_MinimizeBand (HWND hwnd, WPARAM wParam, LPARAM lParam)
1236 /* REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd); */
1238 FIXME("(uBand = %u)\n", (UINT)wParam);
1246 REBAR_MoveBand (HWND hwnd, WPARAM wParam, LPARAM lParam)
1248 /* REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd); */
1250 FIXME("(iFrom = %u iTof = %u)\n",
1251 (UINT)wParam, (UINT)lParam);
1259 REBAR_SetBandInfoA (HWND hwnd, WPARAM wParam, LPARAM lParam)
1261 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
1262 LPREBARBANDINFOA lprbbi = (LPREBARBANDINFOA)lParam;
1267 if (lprbbi->cbSize < REBARBANDINFO_V3_SIZEA)
1269 if ((UINT)wParam >= infoPtr->uNumBands)
1272 TRACE("index %u\n", (UINT)wParam);
1274 /* set band information */
1275 lpBand = &infoPtr->bands[(UINT)wParam];
1277 if (lprbbi->fMask & RBBIM_STYLE)
1278 lpBand->fStyle = lprbbi->fStyle;
1280 if (lprbbi->fMask & RBBIM_COLORS) {
1281 lpBand->clrFore = lprbbi->clrFore;
1282 lpBand->clrBack = lprbbi->clrBack;
1285 if (lprbbi->fMask & RBBIM_TEXT) {
1286 if (lpBand->lpText) {
1287 COMCTL32_Free (lpBand->lpText);
1288 lpBand->lpText = NULL;
1290 if (lprbbi->lpText) {
1291 INT len = lstrlenA (lprbbi->lpText);
1292 lpBand->lpText = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
1293 lstrcpyAtoW (lpBand->lpText, lprbbi->lpText);
1297 if (lprbbi->fMask & RBBIM_IMAGE)
1298 lpBand->iImage = lprbbi->iImage;
1300 if (lprbbi->fMask & RBBIM_CHILD) {
1301 if (lprbbi->hwndChild) {
1302 lpBand->hwndChild = lprbbi->hwndChild;
1303 lpBand->hwndPrevParent =
1304 SetParent (lpBand->hwndChild, hwnd);
1307 TRACE("child: 0x%x prev parent: 0x%x\n",
1308 lpBand->hwndChild, lpBand->hwndPrevParent);
1309 lpBand->hwndChild = 0;
1310 lpBand->hwndPrevParent = 0;
1314 if (lprbbi->fMask & RBBIM_CHILDSIZE) {
1315 lpBand->cxMinChild = lprbbi->cxMinChild;
1316 lpBand->cyMinChild = lprbbi->cyMinChild;
1317 lpBand->cyMaxChild = lprbbi->cyMaxChild;
1318 lpBand->cyChild = lprbbi->cyChild;
1319 lpBand->cyIntegral = lprbbi->cyIntegral;
1322 if (lprbbi->fMask & RBBIM_SIZE)
1323 lpBand->cx = lprbbi->cx;
1325 if (lprbbi->fMask & RBBIM_BACKGROUND)
1326 lpBand->hbmBack = lprbbi->hbmBack;
1328 if (lprbbi->fMask & RBBIM_ID)
1329 lpBand->wID = lprbbi->wID;
1331 /* check for additional data */
1332 if (lprbbi->cbSize >= sizeof (REBARBANDINFOA)) {
1333 if (lprbbi->fMask & RBBIM_IDEALSIZE)
1334 lpBand->cxIdeal = lprbbi->cxIdeal;
1336 if (lprbbi->fMask & RBBIM_LPARAM)
1337 lpBand->lParam = lprbbi->lParam;
1339 if (lprbbi->fMask & RBBIM_HEADERSIZE)
1340 lpBand->cxHeader = lprbbi->cxHeader;
1343 REBAR_Layout (hwnd, NULL);
1344 REBAR_ForceResize (hwnd);
1345 REBAR_MoveChildWindows (hwnd);
1352 REBAR_SetBandInfoW (HWND hwnd, WPARAM wParam, LPARAM lParam)
1354 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
1355 LPREBARBANDINFOW lprbbi = (LPREBARBANDINFOW)lParam;
1360 if (lprbbi->cbSize < REBARBANDINFO_V3_SIZEW)
1362 if ((UINT)wParam >= infoPtr->uNumBands)
1365 TRACE("index %u\n", (UINT)wParam);
1367 /* set band information */
1368 lpBand = &infoPtr->bands[(UINT)wParam];
1370 if (lprbbi->fMask & RBBIM_STYLE)
1371 lpBand->fStyle = lprbbi->fStyle;
1373 if (lprbbi->fMask & RBBIM_COLORS) {
1374 lpBand->clrFore = lprbbi->clrFore;
1375 lpBand->clrBack = lprbbi->clrBack;
1378 if (lprbbi->fMask & RBBIM_TEXT) {
1379 if (lpBand->lpText) {
1380 COMCTL32_Free (lpBand->lpText);
1381 lpBand->lpText = NULL;
1383 if (lprbbi->lpText) {
1384 INT len = lstrlenW (lprbbi->lpText);
1385 lpBand->lpText = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
1386 lstrcpyW (lpBand->lpText, lprbbi->lpText);
1390 if (lprbbi->fMask & RBBIM_IMAGE)
1391 lpBand->iImage = lprbbi->iImage;
1393 if (lprbbi->fMask & RBBIM_CHILD) {
1394 if (lprbbi->hwndChild) {
1395 lpBand->hwndChild = lprbbi->hwndChild;
1396 lpBand->hwndPrevParent =
1397 SetParent (lpBand->hwndChild, hwnd);
1400 TRACE("child: 0x%x prev parent: 0x%x\n",
1401 lpBand->hwndChild, lpBand->hwndPrevParent);
1402 lpBand->hwndChild = 0;
1403 lpBand->hwndPrevParent = 0;
1407 if (lprbbi->fMask & RBBIM_CHILDSIZE) {
1408 lpBand->cxMinChild = lprbbi->cxMinChild;
1409 lpBand->cyMinChild = lprbbi->cyMinChild;
1410 lpBand->cyMaxChild = lprbbi->cyMaxChild;
1411 lpBand->cyChild = lprbbi->cyChild;
1412 lpBand->cyIntegral = lprbbi->cyIntegral;
1415 if (lprbbi->fMask & RBBIM_SIZE)
1416 lpBand->cx = lprbbi->cx;
1418 if (lprbbi->fMask & RBBIM_BACKGROUND)
1419 lpBand->hbmBack = lprbbi->hbmBack;
1421 if (lprbbi->fMask & RBBIM_ID)
1422 lpBand->wID = lprbbi->wID;
1424 /* check for additional data */
1425 if (lprbbi->cbSize >= sizeof (REBARBANDINFOW)) {
1426 if (lprbbi->fMask & RBBIM_IDEALSIZE)
1427 lpBand->cxIdeal = lprbbi->cxIdeal;
1429 if (lprbbi->fMask & RBBIM_LPARAM)
1430 lpBand->lParam = lprbbi->lParam;
1432 if (lprbbi->fMask & RBBIM_HEADERSIZE)
1433 lpBand->cxHeader = lprbbi->cxHeader;
1436 REBAR_Layout (hwnd, NULL);
1437 REBAR_ForceResize (hwnd);
1438 REBAR_MoveChildWindows (hwnd);
1445 REBAR_SetBarInfo (HWND hwnd, WPARAM wParam, LPARAM lParam)
1447 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
1448 LPREBARINFO lpInfo = (LPREBARINFO)lParam;
1453 if (lpInfo->cbSize < sizeof (REBARINFO))
1456 TRACE("setting bar info!\n");
1458 if (lpInfo->fMask & RBIM_IMAGELIST) {
1459 infoPtr->himl = lpInfo->himl;
1460 if (infoPtr->himl) {
1461 ImageList_GetIconSize (infoPtr->himl, &infoPtr->imageSize.cx,
1462 &infoPtr->imageSize.cy);
1465 infoPtr->imageSize.cx = 0;
1466 infoPtr->imageSize.cy = 0;
1475 REBAR_SetBkColor (HWND hwnd, WPARAM wParam, LPARAM lParam)
1477 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
1480 clrTemp = infoPtr->clrBk;
1481 infoPtr->clrBk = (COLORREF)lParam;
1483 TRACE("background color 0x%06lx!\n", infoPtr->clrBk);
1489 /* << REBAR_SetColorScheme >> */
1490 /* << REBAR_SetPalette >> */
1494 REBAR_SetParent (HWND hwnd, WPARAM wParam, LPARAM lParam)
1496 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
1497 HWND hwndTemp = infoPtr->hwndNotify;
1499 infoPtr->hwndNotify = (HWND)wParam;
1501 return (LRESULT)hwndTemp;
1506 REBAR_SetTextColor (HWND hwnd, WPARAM wParam, LPARAM lParam)
1508 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
1511 clrTemp = infoPtr->clrText;
1512 infoPtr->clrText = (COLORREF)lParam;
1514 TRACE("text color 0x%06lx!\n", infoPtr->clrText);
1520 /* << REBAR_SetTooltips >> */
1523 inline static LRESULT
1524 REBAR_SetUnicodeFormat (HWND hwnd, WPARAM wParam)
1526 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
1527 BOOL bTemp = infoPtr->bUnicode;
1528 infoPtr->bUnicode = (BOOL)wParam;
1534 REBAR_SetVersion (HWND hwnd, INT iVersion)
1536 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
1537 INT iOldVersion = infoPtr->iVersion;
1539 if (iVersion > COMCTL32_VERSION)
1542 infoPtr->iVersion = iVersion;
1549 REBAR_ShowBand (HWND hwnd, WPARAM wParam, LPARAM lParam)
1551 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
1554 if (((INT)wParam < 0) || ((INT)wParam > infoPtr->uNumBands))
1557 lpBand = &infoPtr->bands[(INT)wParam];
1560 TRACE("show band %d\n", (INT)wParam);
1561 lpBand->fStyle = lpBand->fStyle & ~RBBS_HIDDEN;
1562 if (IsWindow (lpBand->hwndChild))
1563 ShowWindow (lpBand->hwndChild, SW_SHOW);
1566 TRACE("hide band %d\n", (INT)wParam);
1567 lpBand->fStyle = lpBand->fStyle | RBBS_HIDDEN;
1568 if (IsWindow (lpBand->hwndChild))
1569 ShowWindow (lpBand->hwndChild, SW_SHOW);
1572 REBAR_Layout (hwnd, NULL);
1573 REBAR_ForceResize (hwnd);
1574 REBAR_MoveChildWindows (hwnd);
1581 REBAR_SizeToRect (HWND hwnd, WPARAM wParam, LPARAM lParam)
1583 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
1584 LPRECT lpRect = (LPRECT)lParam;
1589 FIXME("layout change not implemented!\n");
1590 FIXME("[%d %d %d %d]\n",
1591 lpRect->left, lpRect->top, lpRect->right, lpRect->bottom);
1594 SetWindowPos (hwnd, 0, lpRect->left, lpRect->top,
1595 lpRect->right - lpRect->left, lpRect->bottom - lpRect->top,
1599 infoPtr->calcSize.cx = lpRect->right - lpRect->left;
1600 infoPtr->calcSize.cy = lpRect->bottom - lpRect->top;
1602 REBAR_ForceResize (hwnd);
1609 REBAR_Create (HWND hwnd, WPARAM wParam, LPARAM lParam)
1611 REBAR_INFO *infoPtr;
1613 /* allocate memory for info structure */
1614 infoPtr = (REBAR_INFO *)COMCTL32_Alloc (sizeof(REBAR_INFO));
1615 SetWindowLongA (hwnd, 0, (DWORD)infoPtr);
1617 /* initialize info structure */
1618 infoPtr->iVersion = 0;
1619 infoPtr->clrBk = CLR_NONE;
1620 infoPtr->clrText = RGB(0, 0, 0);
1622 infoPtr->bAutoResize = FALSE;
1623 infoPtr->hcurArrow = LoadCursorA (0, IDC_ARROWA);
1624 infoPtr->hcurHorz = LoadCursorA (0, IDC_SIZEWEA);
1625 infoPtr->hcurVert = LoadCursorA (0, IDC_SIZENSA);
1626 infoPtr->hcurDrag = LoadCursorA (0, IDC_SIZEA);
1628 infoPtr->bUnicode = IsWindowUnicode (hwnd);
1630 if (GetWindowLongA (hwnd, GWL_STYLE) & RBS_AUTOSIZE)
1631 FIXME("style RBS_AUTOSIZE set!\n");
1634 SendMessageA (hwnd, WM_NOTIFYFORMAT, (WPARAM)hwnd, NF_QUERY);
1637 TRACE("created!\n");
1643 REBAR_Destroy (HWND hwnd, WPARAM wParam, LPARAM lParam)
1645 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
1650 /* free rebar bands */
1651 if ((infoPtr->uNumBands > 0) && infoPtr->bands) {
1652 /* clean up each band */
1653 for (i = 0; i < infoPtr->uNumBands; i++) {
1654 lpBand = &infoPtr->bands[i];
1656 /* delete text strings */
1657 if (lpBand->lpText) {
1658 COMCTL32_Free (lpBand->lpText);
1659 lpBand->lpText = NULL;
1661 /* destroy child window */
1662 DestroyWindow (lpBand->hwndChild);
1665 /* free band array */
1666 COMCTL32_Free (infoPtr->bands);
1667 infoPtr->bands = NULL;
1673 DeleteObject (infoPtr->hcurArrow);
1674 DeleteObject (infoPtr->hcurHorz);
1675 DeleteObject (infoPtr->hcurVert);
1676 DeleteObject (infoPtr->hcurDrag);
1681 /* free rebar info data */
1682 COMCTL32_Free (infoPtr);
1684 TRACE("destroyed!\n");
1690 REBAR_GetFont (HWND hwnd, WPARAM wParam, LPARAM lParam)
1692 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
1694 return (LRESULT)infoPtr->hFont;
1700 REBAR_MouseMove (HWND hwnd, WPARAM wParam, LPARAM lParam)
1702 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
1709 inline static LRESULT
1710 REBAR_NCCalcSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
1712 if (GetWindowLongA (hwnd, GWL_STYLE) & WS_BORDER) {
1713 ((LPRECT)lParam)->left += GetSystemMetrics(SM_CXEDGE);
1714 ((LPRECT)lParam)->top += GetSystemMetrics(SM_CYEDGE);
1715 ((LPRECT)lParam)->right -= GetSystemMetrics(SM_CXEDGE);
1716 ((LPRECT)lParam)->bottom -= GetSystemMetrics(SM_CYEDGE);
1724 REBAR_NCPaint (HWND hwnd, WPARAM wParam, LPARAM lParam)
1726 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
1730 if (dwStyle & WS_MINIMIZE)
1731 return 0; /* Nothing to do */
1733 DefWindowProcA (hwnd, WM_NCPAINT, wParam, lParam);
1735 if (!(hdc = GetDCEx( hwnd, 0, DCX_USESTYLE | DCX_WINDOW )))
1738 if (dwStyle & WS_BORDER) {
1739 GetWindowRect (hwnd, &rcWindow);
1740 OffsetRect (&rcWindow, -rcWindow.left, -rcWindow.top);
1741 DrawEdge (hdc, &rcWindow, EDGE_ETCHED, BF_RECT);
1744 ReleaseDC( hwnd, hdc );
1751 REBAR_Paint (HWND hwnd, WPARAM wParam)
1756 hdc = wParam==0 ? BeginPaint (hwnd, &ps) : (HDC)wParam;
1757 REBAR_Refresh (hwnd, hdc);
1759 EndPaint (hwnd, &ps);
1765 REBAR_SetCursor (HWND hwnd, WPARAM wParam, LPARAM lParam)
1767 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
1768 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
1772 TRACE("code=0x%X id=0x%X\n", LOWORD(lParam), HIWORD(lParam));
1775 ScreenToClient (hwnd, &pt);
1777 REBAR_InternalHitTest (hwnd, &pt, &flags, NULL);
1779 if (flags == RBHT_GRABBER) {
1780 if ((dwStyle & CCS_VERT) &&
1781 !(dwStyle & RBS_VERTICALGRIPPER))
1782 SetCursor (infoPtr->hcurVert);
1784 SetCursor (infoPtr->hcurHorz);
1786 else if (flags != RBHT_CLIENT)
1787 SetCursor (infoPtr->hcurArrow);
1794 REBAR_SetFont (HWND hwnd, WPARAM wParam, LPARAM lParam)
1796 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
1798 /* TEXTMETRIC32A tm; */
1799 HFONT hFont /*, hOldFont */;
1802 infoPtr->hFont = (HFONT)wParam;
1804 hFont = infoPtr->hFont ? infoPtr->hFont : GetStockObject (SYSTEM_FONT);
1807 hOldFont = SelectObject32 (hdc, hFont);
1808 GetTextMetrics32A (hdc, &tm);
1809 infoPtr->nHeight = tm.tmHeight + VERT_BORDER;
1810 SelectObject32 (hdc, hOldFont);
1811 ReleaseDC32 (0, hdc);
1815 REBAR_Layout (hwnd);
1816 hdc = GetDC32 (hwnd);
1817 REBAR_Refresh (hwnd, hdc);
1818 ReleaseDC32 (hwnd, hdc);
1826 REBAR_Size (HWND hwnd, WPARAM wParam, LPARAM lParam)
1828 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
1829 /* DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE); */
1831 /* INT32 x, y, cx, cy; */
1833 /* auto resize deadlock check */
1834 if (infoPtr->bAutoResize) {
1835 infoPtr->bAutoResize = FALSE;
1839 TRACE("sizing rebar!\n");
1841 /* get parent rectangle */
1842 GetClientRect (GetParent (hwnd), &rcParent);
1844 REBAR_Layout (hwnd, &rcParent);
1846 if (dwStyle & CCS_VERT) {
1847 if (dwStyle & CCS_LEFT == CCS_LEFT) {
1850 cx = infoPtr->calcSize.cx;
1851 cy = infoPtr->calcSize.cy;
1854 x = rcParent.right - infoPtr->calcSize.cx;
1856 cx = infoPtr->calcSize.cx;
1857 cy = infoPtr->calcSize.cy;
1861 if (dwStyle & CCS_TOP) {
1864 cx = infoPtr->calcSize.cx;
1865 cy = infoPtr->calcSize.cy;
1869 y = rcParent.bottom - infoPtr->calcSize.cy;
1870 cx = infoPtr->calcSize.cx;
1871 cy = infoPtr->calcSize.cy;
1875 SetWindowPos32 (hwnd, 0, x, y, cx, cy,
1876 SWP_NOZORDER | SWP_SHOWWINDOW);
1878 REBAR_Layout (hwnd, NULL);
1879 REBAR_ForceResize (hwnd);
1880 REBAR_MoveChildWindows (hwnd);
1886 static LRESULT WINAPI
1887 REBAR_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
1891 /* case RB_BEGINDRAG: */
1894 return REBAR_DeleteBand (hwnd, wParam, lParam);
1896 /* case RB_DRAGMOVE: */
1897 /* case RB_ENDDRAG: */
1899 case RB_GETBANDBORDERS:
1900 return REBAR_GetBandBorders (hwnd, wParam, lParam);
1902 case RB_GETBANDCOUNT:
1903 return REBAR_GetBandCount (hwnd);
1905 /* case RB_GETBANDINFO32: */ /* outdated, just for compatibility */
1907 case RB_GETBANDINFOA:
1908 return REBAR_GetBandInfoA (hwnd, wParam, lParam);
1910 case RB_GETBANDINFOW:
1911 return REBAR_GetBandInfoW (hwnd, wParam, lParam);
1913 case RB_GETBARHEIGHT:
1914 return REBAR_GetBarHeight (hwnd, wParam, lParam);
1917 return REBAR_GetBarInfo (hwnd, wParam, lParam);
1920 return REBAR_GetBkColor (hwnd);
1922 /* case RB_GETCOLORSCHEME: */
1923 /* case RB_GETDROPTARGET: */
1926 return REBAR_GetPalette (hwnd, wParam, lParam);
1929 return REBAR_GetRect (hwnd, wParam, lParam);
1931 case RB_GETROWCOUNT:
1932 return REBAR_GetRowCount (hwnd);
1934 case RB_GETROWHEIGHT:
1935 return REBAR_GetRowHeight (hwnd, wParam, lParam);
1937 case RB_GETTEXTCOLOR:
1938 return REBAR_GetTextColor (hwnd);
1940 case RB_GETTOOLTIPS:
1941 return REBAR_GetToolTips (hwnd);
1943 case RB_GETUNICODEFORMAT:
1944 return REBAR_GetUnicodeFormat (hwnd);
1946 case CCM_GETVERSION:
1947 return REBAR_GetVersion (hwnd);
1950 return REBAR_HitTest (hwnd, wParam, lParam);
1953 return REBAR_IdToIndex (hwnd, wParam, lParam);
1955 case RB_INSERTBANDA:
1956 return REBAR_InsertBandA (hwnd, wParam, lParam);
1958 case RB_INSERTBANDW:
1959 return REBAR_InsertBandW (hwnd, wParam, lParam);
1961 case RB_MAXIMIZEBAND:
1962 return REBAR_MaximizeBand (hwnd, wParam, lParam);
1964 case RB_MINIMIZEBAND:
1965 return REBAR_MinimizeBand (hwnd, wParam, lParam);
1968 return REBAR_MoveBand (hwnd, wParam, lParam);
1970 case RB_SETBANDINFOA:
1971 return REBAR_SetBandInfoA (hwnd, wParam, lParam);
1973 case RB_SETBANDINFOW:
1974 return REBAR_SetBandInfoW (hwnd, wParam, lParam);
1977 return REBAR_SetBarInfo (hwnd, wParam, lParam);
1980 return REBAR_SetBkColor (hwnd, wParam, lParam);
1982 /* case RB_SETCOLORSCHEME: */
1983 /* case RB_SETPALETTE: */
1984 /* return REBAR_GetPalette (hwnd, wParam, lParam); */
1987 return REBAR_SetParent (hwnd, wParam, lParam);
1989 case RB_SETTEXTCOLOR:
1990 return REBAR_SetTextColor (hwnd, wParam, lParam);
1992 /* case RB_SETTOOLTIPS: */
1994 case RB_SETUNICODEFORMAT:
1995 return REBAR_SetUnicodeFormat (hwnd, wParam);
1997 case CCM_SETVERSION:
1998 return REBAR_SetVersion (hwnd, (INT)wParam);
2001 return REBAR_ShowBand (hwnd, wParam, lParam);
2004 return REBAR_SizeToRect (hwnd, wParam, lParam);
2008 return SendMessageA (GetParent (hwnd), uMsg, wParam, lParam);
2011 return REBAR_Create (hwnd, wParam, lParam);
2014 return REBAR_Destroy (hwnd, wParam, lParam);
2017 return REBAR_GetFont (hwnd, wParam, lParam);
2019 /* case WM_MOUSEMOVE: */
2020 /* return REBAR_MouseMove (hwnd, wParam, lParam); */
2023 return REBAR_NCCalcSize (hwnd, wParam, lParam);
2026 return REBAR_NCPaint (hwnd, wParam, lParam);
2029 return SendMessageA (GetParent (hwnd), uMsg, wParam, lParam);
2032 return REBAR_Paint (hwnd, wParam);
2035 return REBAR_SetCursor (hwnd, wParam, lParam);
2038 return REBAR_SetFont (hwnd, wParam, lParam);
2041 return REBAR_Size (hwnd, wParam, lParam);
2043 /* case WM_TIMER: */
2045 /* case WM_WININICHANGE: */
2048 if (uMsg >= WM_USER)
2049 ERR("unknown msg %04x wp=%08x lp=%08lx\n",
2050 uMsg, wParam, lParam);
2051 return DefWindowProcA (hwnd, uMsg, wParam, lParam);
2058 REBAR_Register (void)
2062 ZeroMemory (&wndClass, sizeof(WNDCLASSA));
2063 wndClass.style = CS_GLOBALCLASS | CS_DBLCLKS;
2064 wndClass.lpfnWndProc = (WNDPROC)REBAR_WindowProc;
2065 wndClass.cbClsExtra = 0;
2066 wndClass.cbWndExtra = sizeof(REBAR_INFO *);
2067 wndClass.hCursor = 0;
2068 wndClass.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1);
2069 wndClass.lpszClassName = REBARCLASSNAMEA;
2071 RegisterClassA (&wndClass);
2076 REBAR_Unregister (void)
2078 UnregisterClassA (REBARCLASSNAMEA, (HINSTANCE)NULL);