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"
26 #include "wine/winestring.h"
28 #include "debugtools.h"
30 DEFAULT_DEBUG_CHANNEL(rebar);
52 UINT fDraw; /* drawing flags */
53 RECT rcBand; /* calculated band rectangle */
54 RECT rcGripper; /* calculated gripper rectangle */
55 RECT rcCapImage; /* calculated caption image rectangle */
56 RECT rcCapText; /* calculated caption text rectangle */
57 RECT rcChild; /* calculated child rectangle */
65 COLORREF clrBk; /* background color */
66 COLORREF clrText; /* text color */
67 HIMAGELIST himl; /* handle to imagelist */
68 UINT uNumBands; /* number of bands in the rebar */
69 HWND hwndToolTip; /* handle to the tool tip control */
70 HWND hwndNotify; /* notification window (parent) */
71 HFONT hFont; /* handle to the rebar's font */
72 SIZE imageSize; /* image size (image list) */
74 SIZE calcSize; /* calculated rebar size */
75 BOOL bAutoResize; /* auto resize deadlock flag */
76 BOOL bUnicode; /* Unicode flag */
77 HCURSOR hcurArrow; /* handle to the arrow cursor */
78 HCURSOR hcurHorz; /* handle to the EW cursor */
79 HCURSOR hcurVert; /* handle to the NS cursor */
80 HCURSOR hcurDrag; /* handle to the drag cursor */
81 INT iVersion; /* version number */
83 REBAR_BAND *bands; /* pointer to the array of rebar bands */
88 #define DRAW_GRIPPER 1
93 #define GRIPPER_WIDTH 13
96 #define REBAR_GetInfoPtr(wndPtr) ((REBAR_INFO *)GetWindowLongA (hwnd, 0))
100 REBAR_DrawBand (HDC hdc, REBAR_INFO *infoPtr, REBAR_BAND *lpBand)
103 DrawEdge (hdc, &lpBand->rcBand, BDR_RAISEDINNER, BF_MIDDLE);
105 /* draw background */
108 if (lpBand->fDraw & DRAW_GRIPPER)
109 DrawEdge (hdc, &lpBand->rcGripper, BDR_RAISEDINNER, BF_RECT | BF_MIDDLE);
111 /* draw caption image */
112 if (lpBand->fDraw & DRAW_IMAGE) {
113 /* FIXME: center image */
116 pt.y = (lpBand->rcCapImage.bottom + lpBand->rcCapImage.top - infoPtr->imageSize.cy)/2;
117 pt.x = (lpBand->rcCapImage.right + lpBand->rcCapImage.left - infoPtr->imageSize.cx)/2;
119 ImageList_Draw (infoPtr->himl, lpBand->iImage, hdc,
120 /* lpBand->rcCapImage.left, lpBand->rcCapImage.top, */
125 /* draw caption text */
126 if (lpBand->fDraw & DRAW_TEXT) {
127 HFONT hOldFont = SelectObject (hdc, infoPtr->hFont);
128 INT oldBkMode = SetBkMode (hdc, TRANSPARENT);
129 DrawTextW (hdc, lpBand->lpText, -1, &lpBand->rcCapText,
130 DT_CENTER | DT_VCENTER | DT_SINGLELINE);
131 if (oldBkMode != TRANSPARENT)
132 SetBkMode (hdc, oldBkMode);
133 SelectObject (hdc, hOldFont);
139 REBAR_Refresh (HWND hwnd, HDC hdc)
141 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
145 for (i = 0; i < infoPtr->uNumBands; i++) {
146 lpBand = &infoPtr->bands[i];
148 if ((lpBand->fStyle & RBBS_HIDDEN) ||
149 ((GetWindowLongA (hwnd, GWL_STYLE) & CCS_VERT) &&
150 (lpBand->fStyle & RBBS_NOVERT)))
153 REBAR_DrawBand (hdc, infoPtr, lpBand);
160 REBAR_CalcHorzBand (REBAR_INFO *infoPtr, REBAR_BAND *lpBand)
164 /* set initial caption image rectangle */
165 SetRect (&lpBand->rcCapImage, 0, 0, 0, 0);
167 /* image is visible */
168 if ((lpBand->iImage > -1) && (infoPtr->himl)) {
169 lpBand->fDraw |= DRAW_IMAGE;
171 lpBand->rcCapImage.right = lpBand->rcCapImage.left + infoPtr->imageSize.cx;
172 lpBand->rcCapImage.bottom = lpBand->rcCapImage.top + infoPtr->imageSize.cy;
174 /* update band height */
175 if (lpBand->uMinHeight < infoPtr->imageSize.cy + 2) {
176 lpBand->uMinHeight = infoPtr->imageSize.cy + 2;
177 lpBand->rcBand.bottom = lpBand->rcBand.top + lpBand->uMinHeight;
181 /* set initial caption text rectangle */
182 lpBand->rcCapText.left = lpBand->rcCapImage.right;
183 lpBand->rcCapText.top = lpBand->rcBand.top + 1;
184 lpBand->rcCapText.right = lpBand->rcCapText.left;
185 lpBand->rcCapText.bottom = lpBand->rcBand.bottom - 1;
187 /* text is visible */
188 if (lpBand->lpText) {
190 HFONT hOldFont = SelectObject (hdc, infoPtr->hFont);
193 lpBand->fDraw |= DRAW_TEXT;
194 GetTextExtentPoint32W (hdc, lpBand->lpText,
195 lstrlenW (lpBand->lpText), &size);
196 lpBand->rcCapText.right += size.cx;
198 SelectObject (hdc, hOldFont);
202 /* set initial child window rectangle */
203 if (lpBand->fStyle & RBBS_FIXEDSIZE) {
204 lpBand->rcChild.left = lpBand->rcCapText.right;
205 lpBand->rcChild.top = lpBand->rcBand.top;
206 lpBand->rcChild.right = lpBand->rcBand.right;
207 lpBand->rcChild.bottom = lpBand->rcBand.bottom;
210 lpBand->rcChild.left = lpBand->rcCapText.right + 4;
211 lpBand->rcChild.top = lpBand->rcBand.top + 2;
212 lpBand->rcChild.right = lpBand->rcBand.right - 4;
213 lpBand->rcChild.bottom = lpBand->rcBand.bottom - 2;
216 /* calculate gripper rectangle */
217 if ((!(lpBand->fStyle & RBBS_NOGRIPPER)) &&
218 (!(lpBand->fStyle & RBBS_FIXEDSIZE)) &&
219 ((lpBand->fStyle & RBBS_GRIPPERALWAYS) ||
220 (infoPtr->uNumBands > 1))) {
221 lpBand->fDraw |= DRAW_GRIPPER;
222 lpBand->rcGripper.left = lpBand->rcBand.left + 3;
223 lpBand->rcGripper.right = lpBand->rcGripper.left + 3;
224 lpBand->rcGripper.top = lpBand->rcBand.top + 3;
225 lpBand->rcGripper.bottom = lpBand->rcBand.bottom - 3;
227 /* move caption rectangles */
228 OffsetRect (&lpBand->rcCapImage, GRIPPER_WIDTH, 0);
229 OffsetRect (&lpBand->rcCapText, GRIPPER_WIDTH, 0);
231 /* adjust child rectangle */
232 lpBand->rcChild.left += GRIPPER_WIDTH;
240 REBAR_CalcVertBand (HWND hwnd, REBAR_INFO *infoPtr, REBAR_BAND *lpBand)
244 /* set initial caption image rectangle */
245 SetRect (&lpBand->rcCapImage, 0, 0, 0, 0);
247 /* image is visible */
248 if ((lpBand->iImage > -1) && (infoPtr->himl)) {
249 lpBand->fDraw |= DRAW_IMAGE;
251 lpBand->rcCapImage.right = lpBand->rcCapImage.left + infoPtr->imageSize.cx;
252 lpBand->rcCapImage.bottom = lpBand->rcCapImage.top + infoPtr->imageSize.cy;
254 /* update band width */
255 if (lpBand->uMinHeight < infoPtr->imageSize.cx + 2) {
256 lpBand->uMinHeight = infoPtr->imageSize.cx + 2;
257 lpBand->rcBand.right = lpBand->rcBand.left + lpBand->uMinHeight;
261 /* set initial caption text rectangle */
262 lpBand->rcCapText.left = lpBand->rcBand.left + 1;
263 lpBand->rcCapText.top = lpBand->rcCapImage.bottom;
264 lpBand->rcCapText.right = lpBand->rcBand.right - 1;
265 lpBand->rcCapText.bottom = lpBand->rcCapText.top;
267 /* text is visible */
268 if (lpBand->lpText) {
270 HFONT hOldFont = SelectObject (hdc, infoPtr->hFont);
273 lpBand->fDraw |= DRAW_TEXT;
274 GetTextExtentPoint32W (hdc, lpBand->lpText,
275 lstrlenW (lpBand->lpText), &size);
276 /* lpBand->rcCapText.right += size.cx; */
277 lpBand->rcCapText.bottom += size.cy;
279 SelectObject (hdc, hOldFont);
283 /* set initial child window rectangle */
284 if (lpBand->fStyle & RBBS_FIXEDSIZE) {
285 lpBand->rcChild.left = lpBand->rcBand.left;
286 lpBand->rcChild.top = lpBand->rcCapText.bottom;
287 lpBand->rcChild.right = lpBand->rcBand.right;
288 lpBand->rcChild.bottom = lpBand->rcBand.bottom;
291 lpBand->rcChild.left = lpBand->rcBand.left + 2;
292 lpBand->rcChild.top = lpBand->rcCapText.bottom + 4;
293 lpBand->rcChild.right = lpBand->rcBand.right - 2;
294 lpBand->rcChild.bottom = lpBand->rcBand.bottom - 4;
297 /* calculate gripper rectangle */
298 if ((!(lpBand->fStyle & RBBS_NOGRIPPER)) &&
299 (!(lpBand->fStyle & RBBS_FIXEDSIZE)) &&
300 ((lpBand->fStyle & RBBS_GRIPPERALWAYS) ||
301 (infoPtr->uNumBands > 1))) {
302 lpBand->fDraw |= DRAW_GRIPPER;
304 if (GetWindowLongA (hwnd, GWL_STYLE) & RBS_VERTICALGRIPPER) {
305 /* adjust band width */
306 lpBand->rcBand.right += GRIPPER_WIDTH;
307 lpBand->uMinHeight += GRIPPER_WIDTH;
309 lpBand->rcGripper.left = lpBand->rcBand.left + 3;
310 lpBand->rcGripper.right = lpBand->rcGripper.left + 3;
311 lpBand->rcGripper.top = lpBand->rcBand.top + 3;
312 lpBand->rcGripper.bottom = lpBand->rcBand.bottom - 3;
314 /* move caption rectangles */
315 OffsetRect (&lpBand->rcCapImage, GRIPPER_WIDTH, 0);
316 OffsetRect (&lpBand->rcCapText, GRIPPER_WIDTH, 0);
318 /* adjust child rectangle */
319 lpBand->rcChild.left += GRIPPER_WIDTH;
322 lpBand->rcGripper.left = lpBand->rcBand.left + 3;
323 lpBand->rcGripper.right = lpBand->rcBand.right - 3;
324 lpBand->rcGripper.top = lpBand->rcBand.top + 3;
325 lpBand->rcGripper.bottom = lpBand->rcGripper.top + 3;
327 /* move caption rectangles */
328 OffsetRect (&lpBand->rcCapImage, 0, GRIPPER_WIDTH);
329 OffsetRect (&lpBand->rcCapText, 0, GRIPPER_WIDTH);
331 /* adjust child rectangle */
332 lpBand->rcChild.top += GRIPPER_WIDTH;
339 REBAR_Layout (HWND hwnd, LPRECT lpRect)
341 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
342 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
351 GetClientRect (hwnd, &rcClient);
356 if (dwStyle & CCS_VERT) {
357 cx = 20; /* FIXME: fixed height */
358 cy = rcClient.bottom - rcClient.top;
361 cx = rcClient.right - rcClient.left;
362 cy = 20; /* FIXME: fixed height */
365 for (i = 0; i < infoPtr->uNumBands; i++) {
366 lpBand = &infoPtr->bands[i];
368 if ((lpBand->fStyle & RBBS_HIDDEN) ||
369 ((dwStyle & CCS_VERT) && (lpBand->fStyle & RBBS_NOVERT)))
373 if (dwStyle & CCS_VERT) {
374 if (lpBand->fStyle & RBBS_VARIABLEHEIGHT)
375 cx = lpBand->cyMaxChild;
376 else if (lpBand->fStyle & RBBIM_CHILDSIZE)
377 cx = lpBand->cyMinChild;
381 lpBand->rcBand.left = x;
382 lpBand->rcBand.right = x + cx;
383 lpBand->rcBand.top = y;
384 lpBand->rcBand.bottom = y + cy;
385 lpBand->uMinHeight = cx;
388 if (lpBand->fStyle & RBBS_VARIABLEHEIGHT)
389 cy = lpBand->cyMaxChild;
390 else if (lpBand->fStyle & RBBIM_CHILDSIZE)
391 cy = lpBand->cyMinChild;
395 lpBand->rcBand.left = x;
396 lpBand->rcBand.right = x + cx;
397 lpBand->rcBand.top = y;
398 lpBand->rcBand.bottom = y + cy;
399 lpBand->uMinHeight = cy;
402 if (dwStyle & CCS_VERT) {
403 REBAR_CalcVertBand (hwnd, infoPtr, lpBand);
404 x += lpBand->uMinHeight;
407 REBAR_CalcHorzBand (infoPtr, lpBand);
408 y += lpBand->uMinHeight;
412 if (dwStyle & CCS_VERT) {
413 infoPtr->calcSize.cx = x;
414 infoPtr->calcSize.cy = rcClient.bottom - rcClient.top;
417 infoPtr->calcSize.cx = rcClient.right - rcClient.left;
418 infoPtr->calcSize.cy = y;
424 REBAR_ForceResize (HWND hwnd)
426 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
429 TRACE( " to [%ld x %ld]!\n",
430 infoPtr->calcSize.cx, infoPtr->calcSize.cy);
432 infoPtr->bAutoResize = TRUE;
436 rc.right = infoPtr->calcSize.cx;
437 rc.bottom = infoPtr->calcSize.cy;
439 if (GetWindowLongA (hwnd, GWL_STYLE) & WS_BORDER) {
440 InflateRect (&rc, GetSystemMetrics(SM_CXEDGE), GetSystemMetrics(SM_CYEDGE));
443 SetWindowPos (hwnd, 0, 0, 0,
444 rc.right - rc.left, rc.bottom - rc.top,
445 SWP_NOMOVE | SWP_NOZORDER | SWP_SHOWWINDOW);
450 REBAR_MoveChildWindows (HWND hwnd)
452 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
454 CHAR szClassName[40];
457 for (i = 0; i < infoPtr->uNumBands; i++) {
458 lpBand = &infoPtr->bands[i];
460 if (lpBand->fStyle & RBBS_HIDDEN)
462 if (lpBand->hwndChild) {
463 TRACE("hwndChild = %x\n", lpBand->hwndChild);
465 GetClassNameA (lpBand->hwndChild, szClassName, 40);
466 if (!lstrcmpA (szClassName, "ComboBox")) {
467 INT nEditHeight, yPos;
470 /* special placement code for combo box */
473 /* get size of edit line */
474 GetWindowRect (lpBand->hwndChild, &rc);
475 nEditHeight = rc.bottom - rc.top;
476 yPos = (lpBand->rcChild.bottom + lpBand->rcChild.top - nEditHeight)/2;
478 /* center combo box inside child area */
479 SetWindowPos (lpBand->hwndChild, HWND_TOP,
480 lpBand->rcChild.left, /*lpBand->rcChild.top*/ yPos,
481 lpBand->rcChild.right - lpBand->rcChild.left,
486 else if (!lstrcmpA (szClassName, WC_COMBOBOXEXA)) {
487 INT nEditHeight, yPos;
491 /* special placement code for extended combo box */
493 /* get size of edit line */
494 hwndEdit = SendMessageA (lpBand->hwndChild, CBEM_GETEDITCONTROL, 0, 0);
495 GetWindowRect (hwndEdit, &rc);
496 nEditHeight = rc.bottom - rc.top;
497 yPos = (lpBand->rcChild.bottom + lpBand->rcChild.top - nEditHeight)/2;
499 /* center combo box inside child area */
500 SetWindowPos (lpBand->hwndChild, HWND_TOP,
501 lpBand->rcChild.left, /*lpBand->rcChild.top*/ yPos,
502 lpBand->rcChild.right - lpBand->rcChild.left,
509 SetWindowPos (lpBand->hwndChild, HWND_TOP,
510 lpBand->rcChild.left, lpBand->rcChild.top,
511 lpBand->rcChild.right - lpBand->rcChild.left,
512 lpBand->rcChild.bottom - lpBand->rcChild.top,
521 REBAR_InternalHitTest (HWND hwnd, LPPOINT lpPt, UINT *pFlags, INT *pBand)
523 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
528 GetClientRect (hwnd, &rect);
530 *pFlags = RBHT_NOWHERE;
531 if (PtInRect (&rect, *lpPt))
533 if (infoPtr->uNumBands == 0) {
534 *pFlags = RBHT_NOWHERE;
541 /* somewhere inside */
542 for (iCount = 0; iCount < infoPtr->uNumBands; iCount++) {
543 lpBand = &infoPtr->bands[iCount];
544 if (PtInRect (&lpBand->rcBand, *lpPt)) {
547 if (PtInRect (&lpBand->rcGripper, *lpPt)) {
548 *pFlags = RBHT_GRABBER;
549 TRACE("ON GRABBER %d\n", iCount);
552 else if (PtInRect (&lpBand->rcCapImage, *lpPt)) {
553 *pFlags = RBHT_CAPTION;
554 TRACE("ON CAPTION %d\n", iCount);
557 else if (PtInRect (&lpBand->rcCapText, *lpPt)) {
558 *pFlags = RBHT_CAPTION;
559 TRACE("ON CAPTION %d\n", iCount);
562 else if (PtInRect (&lpBand->rcChild, *lpPt)) {
563 *pFlags = RBHT_CLIENT;
564 TRACE("ON CLIENT %d\n", iCount);
568 *pFlags = RBHT_NOWHERE;
569 TRACE("NOWHERE %d\n", iCount);
575 *pFlags = RBHT_NOWHERE;
584 *pFlags = RBHT_NOWHERE;
591 TRACE("flags=0x%X\n", *pFlags);
597 /* << REBAR_BeginDrag >> */
601 REBAR_DeleteBand (HWND hwnd, WPARAM wParam, LPARAM lParam)
603 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
604 UINT uBand = (UINT)wParam;
606 if (uBand >= infoPtr->uNumBands)
609 TRACE("deleting band %u!\n", uBand);
611 if (infoPtr->uNumBands == 1) {
612 TRACE(" simple delete!\n");
613 COMCTL32_Free (infoPtr->bands);
614 infoPtr->bands = NULL;
615 infoPtr->uNumBands = 0;
618 REBAR_BAND *oldBands = infoPtr->bands;
619 TRACE("complex delete! [uBand=%u]\n", uBand);
621 infoPtr->uNumBands--;
622 infoPtr->bands = COMCTL32_Alloc (sizeof (REBAR_BAND) * infoPtr->uNumBands);
624 memcpy (&infoPtr->bands[0], &oldBands[0],
625 uBand * sizeof(REBAR_BAND));
628 if (uBand < infoPtr->uNumBands) {
629 memcpy (&infoPtr->bands[uBand], &oldBands[uBand+1],
630 (infoPtr->uNumBands - uBand) * sizeof(REBAR_BAND));
633 COMCTL32_Free (oldBands);
636 REBAR_Layout (hwnd, NULL);
637 REBAR_ForceResize (hwnd);
638 REBAR_MoveChildWindows (hwnd);
644 /* << REBAR_DragMove >> */
645 /* << REBAR_EndDrag >> */
649 REBAR_GetBandBorders (HWND hwnd, WPARAM wParam, LPARAM lParam)
651 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
652 /* LPRECT32 lpRect = (LPRECT32)lParam; */
657 if ((UINT)wParam >= infoPtr->uNumBands)
660 lpBand = &infoPtr->bands[(UINT)wParam];
661 if (GetWindowLongA (hwnd, GWL_STYLE) & RBS_BANDBORDERS) {
672 inline static LRESULT
673 REBAR_GetBandCount (HWND hwnd)
675 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
677 TRACE("band count %u!\n", infoPtr->uNumBands);
679 return infoPtr->uNumBands;
684 REBAR_GetBandInfoA (HWND hwnd, WPARAM wParam, LPARAM lParam)
686 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
687 LPREBARBANDINFOA lprbbi = (LPREBARBANDINFOA)lParam;
692 if (lprbbi->cbSize < REBARBANDINFO_V3_SIZEA)
694 if ((UINT)wParam >= infoPtr->uNumBands)
697 TRACE("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 lstrcpynWtoA (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_GetBandInfoW (HWND hwnd, WPARAM wParam, LPARAM lParam)
757 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
758 LPREBARBANDINFOW lprbbi = (LPREBARBANDINFOW)lParam;
763 if (lprbbi->cbSize < REBARBANDINFO_V3_SIZEW)
765 if ((UINT)wParam >= infoPtr->uNumBands)
768 TRACE("index %u\n", (UINT)wParam);
770 /* copy band information */
771 lpBand = &infoPtr->bands[(UINT)wParam];
773 if (lprbbi->fMask & RBBIM_STYLE)
774 lprbbi->fStyle = lpBand->fStyle;
776 if (lprbbi->fMask & RBBIM_COLORS) {
777 lprbbi->clrFore = lpBand->clrFore;
778 lprbbi->clrBack = lpBand->clrBack;
781 if ((lprbbi->fMask & RBBIM_TEXT) &&
782 (lprbbi->lpText) && (lpBand->lpText)) {
783 lstrcpynW (lprbbi->lpText, lpBand->lpText, lprbbi->cch);
786 if (lprbbi->fMask & RBBIM_IMAGE)
787 lprbbi->iImage = lpBand->iImage;
789 if (lprbbi->fMask & RBBIM_CHILD)
790 lprbbi->hwndChild = lpBand->hwndChild;
792 if (lprbbi->fMask & RBBIM_CHILDSIZE) {
793 lprbbi->cxMinChild = lpBand->cxMinChild;
794 lprbbi->cyMinChild = lpBand->cyMinChild;
795 lprbbi->cyMaxChild = lpBand->cyMaxChild;
796 lprbbi->cyChild = lpBand->cyChild;
797 lprbbi->cyIntegral = lpBand->cyIntegral;
800 if (lprbbi->fMask & RBBIM_SIZE)
801 lprbbi->cx = lpBand->cx;
803 if (lprbbi->fMask & RBBIM_BACKGROUND)
804 lprbbi->hbmBack = lpBand->hbmBack;
806 if (lprbbi->fMask & RBBIM_ID)
807 lprbbi->wID = lpBand->wID;
809 /* check for additional data */
810 if (lprbbi->cbSize >= sizeof (REBARBANDINFOA)) {
811 if (lprbbi->fMask & RBBIM_IDEALSIZE)
812 lprbbi->cxIdeal = lpBand->cxIdeal;
814 if (lprbbi->fMask & RBBIM_LPARAM)
815 lprbbi->lParam = lpBand->lParam;
817 if (lprbbi->fMask & RBBIM_HEADERSIZE)
818 lprbbi->cxHeader = lpBand->cxHeader;
826 REBAR_GetBarHeight (HWND hwnd, WPARAM wParam, LPARAM lParam)
828 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
831 REBAR_Layout (hwnd, NULL);
832 nHeight = infoPtr->calcSize.cy;
834 if (GetWindowLongA (hwnd, GWL_STYLE) & WS_BORDER)
835 nHeight += (2 * GetSystemMetrics(SM_CYEDGE));
838 FIXME("height = %d\n", nHeight);
845 REBAR_GetBarInfo (HWND hwnd, WPARAM wParam, LPARAM lParam)
847 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
848 LPREBARINFO lpInfo = (LPREBARINFO)lParam;
853 if (lpInfo->cbSize < sizeof (REBARINFO))
856 TRACE("getting bar info!\n");
859 lpInfo->himl = infoPtr->himl;
860 lpInfo->fMask |= RBIM_IMAGELIST;
867 inline static LRESULT
868 REBAR_GetBkColor (HWND hwnd)
870 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
872 TRACE("background color 0x%06lx!\n", infoPtr->clrBk);
874 return infoPtr->clrBk;
878 /* << REBAR_GetColorScheme >> */
879 /* << REBAR_GetDropTarget >> */
883 REBAR_GetPalette (HWND hwnd, WPARAM wParam, LPARAM lParam)
885 FIXME("empty stub!\n");
892 REBAR_GetRect (HWND hwnd, WPARAM wParam, LPARAM lParam)
894 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
895 INT iBand = (INT)wParam;
896 LPRECT lprc = (LPRECT)lParam;
899 if ((iBand < 0) && ((UINT)iBand >= infoPtr->uNumBands))
904 TRACE("band %d\n", iBand);
906 lpBand = &infoPtr->bands[iBand];
907 CopyRect (lprc, &lpBand->rcBand);
909 lprc->left = lpBand->rcBand.left;
910 lprc->top = lpBand->rcBand.top;
911 lprc->right = lpBand->rcBand.right;
912 lprc->bottom = lpBand->rcBand.bottom;
919 inline static LRESULT
920 REBAR_GetRowCount (HWND hwnd)
922 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
924 FIXME("%u : semi stub!\n", infoPtr->uNumBands);
926 return infoPtr->uNumBands;
931 REBAR_GetRowHeight (HWND hwnd, WPARAM wParam, LPARAM lParam)
933 /* REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd); */
935 FIXME("-- height = 20: semi stub!\n");
941 inline static LRESULT
942 REBAR_GetTextColor (HWND hwnd)
944 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
946 TRACE("text color 0x%06lx!\n", infoPtr->clrText);
948 return infoPtr->clrText;
952 inline static LRESULT
953 REBAR_GetToolTips (HWND hwnd)
955 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
956 return infoPtr->hwndToolTip;
960 inline static LRESULT
961 REBAR_GetUnicodeFormat (HWND hwnd)
963 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
964 return infoPtr->bUnicode;
968 inline static LRESULT
969 REBAR_GetVersion (HWND hwnd)
971 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
972 return infoPtr->iVersion;
977 REBAR_HitTest (HWND hwnd, WPARAM wParam, LPARAM lParam)
979 /* REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd); */
980 LPRBHITTESTINFO lprbht = (LPRBHITTESTINFO)lParam;
985 REBAR_InternalHitTest (hwnd, &lprbht->pt, &lprbht->flags, &lprbht->iBand);
987 return lprbht->iBand;
992 REBAR_IdToIndex (HWND hwnd, WPARAM wParam, LPARAM lParam)
994 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
1000 if (infoPtr->uNumBands < 1)
1003 TRACE("id %u\n", (UINT)wParam);
1005 for (i = 0; i < infoPtr->uNumBands; i++) {
1006 if (infoPtr->bands[i].wID == (UINT)wParam) {
1007 TRACE("band %u found!\n", i);
1012 TRACE("no band found!\n");
1018 REBAR_InsertBandA (HWND hwnd, WPARAM wParam, LPARAM lParam)
1020 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
1021 LPREBARBANDINFOA lprbbi = (LPREBARBANDINFOA)lParam;
1022 UINT uIndex = (UINT)wParam;
1025 if (infoPtr == NULL)
1029 if (lprbbi->cbSize < REBARBANDINFO_V3_SIZEA)
1032 TRACE("insert band at %u!\n", uIndex);
1034 if (infoPtr->uNumBands == 0) {
1035 infoPtr->bands = (REBAR_BAND *)COMCTL32_Alloc (sizeof (REBAR_BAND));
1039 REBAR_BAND *oldBands = infoPtr->bands;
1041 (REBAR_BAND *)COMCTL32_Alloc ((infoPtr->uNumBands+1)*sizeof(REBAR_BAND));
1042 if (((INT)uIndex == -1) || (uIndex > infoPtr->uNumBands))
1043 uIndex = infoPtr->uNumBands;
1045 /* pre insert copy */
1047 memcpy (&infoPtr->bands[0], &oldBands[0],
1048 uIndex * sizeof(REBAR_BAND));
1052 if (uIndex < infoPtr->uNumBands - 1) {
1053 memcpy (&infoPtr->bands[uIndex+1], &oldBands[uIndex],
1054 (infoPtr->uNumBands - uIndex - 1) * sizeof(REBAR_BAND));
1057 COMCTL32_Free (oldBands);
1060 infoPtr->uNumBands++;
1062 TRACE("index %u!\n", uIndex);
1064 /* initialize band (infoPtr->bands[uIndex])*/
1065 lpBand = &infoPtr->bands[uIndex];
1067 if (lprbbi->fMask & RBBIM_STYLE)
1068 lpBand->fStyle = lprbbi->fStyle;
1070 if (lprbbi->fMask & RBBIM_COLORS) {
1071 lpBand->clrFore = lprbbi->clrFore;
1072 lpBand->clrBack = lprbbi->clrBack;
1075 lpBand->clrFore = CLR_NONE;
1076 lpBand->clrBack = CLR_NONE;
1079 if ((lprbbi->fMask & RBBIM_TEXT) && (lprbbi->lpText)) {
1080 INT len = lstrlenA (lprbbi->lpText);
1082 lpBand->lpText = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
1083 lstrcpyAtoW (lpBand->lpText, lprbbi->lpText);
1087 if (lprbbi->fMask & RBBIM_IMAGE)
1088 lpBand->iImage = lprbbi->iImage;
1090 lpBand->iImage = -1;
1092 if (lprbbi->fMask & RBBIM_CHILD) {
1093 TRACE("hwndChild = %x\n", lprbbi->hwndChild);
1094 lpBand->hwndChild = lprbbi->hwndChild;
1095 lpBand->hwndPrevParent =
1096 SetParent (lpBand->hwndChild, hwnd);
1099 if (lprbbi->fMask & RBBIM_CHILDSIZE) {
1100 lpBand->cxMinChild = lprbbi->cxMinChild;
1101 lpBand->cyMinChild = lprbbi->cyMinChild;
1102 lpBand->cyMaxChild = lprbbi->cyMaxChild;
1103 lpBand->cyChild = lprbbi->cyChild;
1104 lpBand->cyIntegral = lprbbi->cyIntegral;
1107 lpBand->cxMinChild = -1;
1108 lpBand->cyMinChild = -1;
1109 lpBand->cyMaxChild = -1;
1110 lpBand->cyChild = -1;
1111 lpBand->cyIntegral = -1;
1114 if (lprbbi->fMask & RBBIM_SIZE)
1115 lpBand->cx = lprbbi->cx;
1119 if (lprbbi->fMask & RBBIM_BACKGROUND)
1120 lpBand->hbmBack = lprbbi->hbmBack;
1122 if (lprbbi->fMask & RBBIM_ID)
1123 lpBand->wID = lprbbi->wID;
1125 /* check for additional data */
1126 if (lprbbi->cbSize >= sizeof (REBARBANDINFOA)) {
1127 if (lprbbi->fMask & RBBIM_IDEALSIZE)
1128 lpBand->cxIdeal = lprbbi->cxIdeal;
1130 if (lprbbi->fMask & RBBIM_LPARAM)
1131 lpBand->lParam = lprbbi->lParam;
1133 if (lprbbi->fMask & RBBIM_HEADERSIZE)
1134 lpBand->cxHeader = lprbbi->cxHeader;
1138 REBAR_Layout (hwnd, NULL);
1139 REBAR_ForceResize (hwnd);
1140 REBAR_MoveChildWindows (hwnd);
1147 REBAR_InsertBandW (HWND hwnd, WPARAM wParam, LPARAM lParam)
1149 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
1150 LPREBARBANDINFOW lprbbi = (LPREBARBANDINFOW)lParam;
1151 UINT uIndex = (UINT)wParam;
1154 if (infoPtr == NULL)
1158 if (lprbbi->cbSize < REBARBANDINFO_V3_SIZEW)
1161 TRACE("insert band at %u!\n", uIndex);
1163 if (infoPtr->uNumBands == 0) {
1164 infoPtr->bands = (REBAR_BAND *)COMCTL32_Alloc (sizeof (REBAR_BAND));
1168 REBAR_BAND *oldBands = infoPtr->bands;
1170 (REBAR_BAND *)COMCTL32_Alloc ((infoPtr->uNumBands+1)*sizeof(REBAR_BAND));
1171 if (((INT)uIndex == -1) || (uIndex > infoPtr->uNumBands))
1172 uIndex = infoPtr->uNumBands;
1174 /* pre insert copy */
1176 memcpy (&infoPtr->bands[0], &oldBands[0],
1177 uIndex * sizeof(REBAR_BAND));
1181 if (uIndex < infoPtr->uNumBands - 1) {
1182 memcpy (&infoPtr->bands[uIndex+1], &oldBands[uIndex],
1183 (infoPtr->uNumBands - uIndex - 1) * sizeof(REBAR_BAND));
1186 COMCTL32_Free (oldBands);
1189 infoPtr->uNumBands++;
1191 TRACE("index %u!\n", uIndex);
1193 /* initialize band (infoPtr->bands[uIndex])*/
1194 lpBand = &infoPtr->bands[uIndex];
1196 if (lprbbi->fMask & RBBIM_STYLE)
1197 lpBand->fStyle = lprbbi->fStyle;
1199 if (lprbbi->fMask & RBBIM_COLORS) {
1200 lpBand->clrFore = lprbbi->clrFore;
1201 lpBand->clrBack = lprbbi->clrBack;
1204 lpBand->clrFore = CLR_NONE;
1205 lpBand->clrBack = CLR_NONE;
1208 if ((lprbbi->fMask & RBBIM_TEXT) && (lprbbi->lpText)) {
1209 INT len = lstrlenW (lprbbi->lpText);
1211 lpBand->lpText = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
1212 strcpyW (lpBand->lpText, lprbbi->lpText);
1216 if (lprbbi->fMask & RBBIM_IMAGE)
1217 lpBand->iImage = lprbbi->iImage;
1219 lpBand->iImage = -1;
1221 if (lprbbi->fMask & RBBIM_CHILD) {
1222 TRACE("hwndChild = %x\n", lprbbi->hwndChild);
1223 lpBand->hwndChild = lprbbi->hwndChild;
1224 lpBand->hwndPrevParent =
1225 SetParent (lpBand->hwndChild, hwnd);
1228 if (lprbbi->fMask & RBBIM_CHILDSIZE) {
1229 lpBand->cxMinChild = lprbbi->cxMinChild;
1230 lpBand->cyMinChild = lprbbi->cyMinChild;
1231 lpBand->cyMaxChild = lprbbi->cyMaxChild;
1232 lpBand->cyChild = lprbbi->cyChild;
1233 lpBand->cyIntegral = lprbbi->cyIntegral;
1236 lpBand->cxMinChild = -1;
1237 lpBand->cyMinChild = -1;
1238 lpBand->cyMaxChild = -1;
1239 lpBand->cyChild = -1;
1240 lpBand->cyIntegral = -1;
1243 if (lprbbi->fMask & RBBIM_SIZE)
1244 lpBand->cx = lprbbi->cx;
1248 if (lprbbi->fMask & RBBIM_BACKGROUND)
1249 lpBand->hbmBack = lprbbi->hbmBack;
1251 if (lprbbi->fMask & RBBIM_ID)
1252 lpBand->wID = lprbbi->wID;
1254 /* check for additional data */
1255 if (lprbbi->cbSize >= sizeof (REBARBANDINFOW)) {
1256 if (lprbbi->fMask & RBBIM_IDEALSIZE)
1257 lpBand->cxIdeal = lprbbi->cxIdeal;
1259 if (lprbbi->fMask & RBBIM_LPARAM)
1260 lpBand->lParam = lprbbi->lParam;
1262 if (lprbbi->fMask & RBBIM_HEADERSIZE)
1263 lpBand->cxHeader = lprbbi->cxHeader;
1267 REBAR_Layout (hwnd, NULL);
1268 REBAR_ForceResize (hwnd);
1269 REBAR_MoveChildWindows (hwnd);
1276 REBAR_MaximizeBand (HWND hwnd, WPARAM wParam, LPARAM lParam)
1278 /* REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd); */
1280 FIXME("(uBand = %u fIdeal = %s)\n",
1281 (UINT)wParam, lParam ? "TRUE" : "FALSE");
1289 REBAR_MinimizeBand (HWND hwnd, WPARAM wParam, LPARAM lParam)
1291 /* REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd); */
1293 FIXME("(uBand = %u)\n", (UINT)wParam);
1301 REBAR_MoveBand (HWND hwnd, WPARAM wParam, LPARAM lParam)
1303 /* REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd); */
1305 FIXME("(iFrom = %u iTof = %u)\n",
1306 (UINT)wParam, (UINT)lParam);
1314 REBAR_SetBandInfoA (HWND hwnd, WPARAM wParam, LPARAM lParam)
1316 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
1317 LPREBARBANDINFOA lprbbi = (LPREBARBANDINFOA)lParam;
1322 if (lprbbi->cbSize < REBARBANDINFO_V3_SIZEA)
1324 if ((UINT)wParam >= infoPtr->uNumBands)
1327 TRACE("index %u\n", (UINT)wParam);
1329 /* set band information */
1330 lpBand = &infoPtr->bands[(UINT)wParam];
1332 if (lprbbi->fMask & RBBIM_STYLE)
1333 lpBand->fStyle = lprbbi->fStyle;
1335 if (lprbbi->fMask & RBBIM_COLORS) {
1336 lpBand->clrFore = lprbbi->clrFore;
1337 lpBand->clrBack = lprbbi->clrBack;
1340 if (lprbbi->fMask & RBBIM_TEXT) {
1341 if (lpBand->lpText) {
1342 COMCTL32_Free (lpBand->lpText);
1343 lpBand->lpText = NULL;
1345 if (lprbbi->lpText) {
1346 INT len = lstrlenA (lprbbi->lpText);
1347 lpBand->lpText = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
1348 lstrcpyAtoW (lpBand->lpText, lprbbi->lpText);
1352 if (lprbbi->fMask & RBBIM_IMAGE)
1353 lpBand->iImage = lprbbi->iImage;
1355 if (lprbbi->fMask & RBBIM_CHILD) {
1356 if (lprbbi->hwndChild) {
1357 lpBand->hwndChild = lprbbi->hwndChild;
1358 lpBand->hwndPrevParent =
1359 SetParent (lpBand->hwndChild, hwnd);
1362 TRACE("child: 0x%x prev parent: 0x%x\n",
1363 lpBand->hwndChild, lpBand->hwndPrevParent);
1364 lpBand->hwndChild = 0;
1365 lpBand->hwndPrevParent = 0;
1369 if (lprbbi->fMask & RBBIM_CHILDSIZE) {
1370 lpBand->cxMinChild = lprbbi->cxMinChild;
1371 lpBand->cyMinChild = lprbbi->cyMinChild;
1372 lpBand->cyMaxChild = lprbbi->cyMaxChild;
1373 lpBand->cyChild = lprbbi->cyChild;
1374 lpBand->cyIntegral = lprbbi->cyIntegral;
1377 if (lprbbi->fMask & RBBIM_SIZE)
1378 lpBand->cx = lprbbi->cx;
1380 if (lprbbi->fMask & RBBIM_BACKGROUND)
1381 lpBand->hbmBack = lprbbi->hbmBack;
1383 if (lprbbi->fMask & RBBIM_ID)
1384 lpBand->wID = lprbbi->wID;
1386 /* check for additional data */
1387 if (lprbbi->cbSize >= sizeof (REBARBANDINFOA)) {
1388 if (lprbbi->fMask & RBBIM_IDEALSIZE)
1389 lpBand->cxIdeal = lprbbi->cxIdeal;
1391 if (lprbbi->fMask & RBBIM_LPARAM)
1392 lpBand->lParam = lprbbi->lParam;
1394 if (lprbbi->fMask & RBBIM_HEADERSIZE)
1395 lpBand->cxHeader = lprbbi->cxHeader;
1398 REBAR_Layout (hwnd, NULL);
1399 REBAR_ForceResize (hwnd);
1400 REBAR_MoveChildWindows (hwnd);
1407 REBAR_SetBandInfoW (HWND hwnd, WPARAM wParam, LPARAM lParam)
1409 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
1410 LPREBARBANDINFOW lprbbi = (LPREBARBANDINFOW)lParam;
1415 if (lprbbi->cbSize < REBARBANDINFO_V3_SIZEW)
1417 if ((UINT)wParam >= infoPtr->uNumBands)
1420 TRACE("index %u\n", (UINT)wParam);
1422 /* set band information */
1423 lpBand = &infoPtr->bands[(UINT)wParam];
1425 if (lprbbi->fMask & RBBIM_STYLE)
1426 lpBand->fStyle = lprbbi->fStyle;
1428 if (lprbbi->fMask & RBBIM_COLORS) {
1429 lpBand->clrFore = lprbbi->clrFore;
1430 lpBand->clrBack = lprbbi->clrBack;
1433 if (lprbbi->fMask & RBBIM_TEXT) {
1434 if (lpBand->lpText) {
1435 COMCTL32_Free (lpBand->lpText);
1436 lpBand->lpText = NULL;
1438 if (lprbbi->lpText) {
1439 INT len = lstrlenW (lprbbi->lpText);
1440 lpBand->lpText = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
1441 strcpyW (lpBand->lpText, lprbbi->lpText);
1445 if (lprbbi->fMask & RBBIM_IMAGE)
1446 lpBand->iImage = lprbbi->iImage;
1448 if (lprbbi->fMask & RBBIM_CHILD) {
1449 if (lprbbi->hwndChild) {
1450 lpBand->hwndChild = lprbbi->hwndChild;
1451 lpBand->hwndPrevParent =
1452 SetParent (lpBand->hwndChild, hwnd);
1455 TRACE("child: 0x%x prev parent: 0x%x\n",
1456 lpBand->hwndChild, lpBand->hwndPrevParent);
1457 lpBand->hwndChild = 0;
1458 lpBand->hwndPrevParent = 0;
1462 if (lprbbi->fMask & RBBIM_CHILDSIZE) {
1463 lpBand->cxMinChild = lprbbi->cxMinChild;
1464 lpBand->cyMinChild = lprbbi->cyMinChild;
1465 lpBand->cyMaxChild = lprbbi->cyMaxChild;
1466 lpBand->cyChild = lprbbi->cyChild;
1467 lpBand->cyIntegral = lprbbi->cyIntegral;
1470 if (lprbbi->fMask & RBBIM_SIZE)
1471 lpBand->cx = lprbbi->cx;
1473 if (lprbbi->fMask & RBBIM_BACKGROUND)
1474 lpBand->hbmBack = lprbbi->hbmBack;
1476 if (lprbbi->fMask & RBBIM_ID)
1477 lpBand->wID = lprbbi->wID;
1479 /* check for additional data */
1480 if (lprbbi->cbSize >= sizeof (REBARBANDINFOW)) {
1481 if (lprbbi->fMask & RBBIM_IDEALSIZE)
1482 lpBand->cxIdeal = lprbbi->cxIdeal;
1484 if (lprbbi->fMask & RBBIM_LPARAM)
1485 lpBand->lParam = lprbbi->lParam;
1487 if (lprbbi->fMask & RBBIM_HEADERSIZE)
1488 lpBand->cxHeader = lprbbi->cxHeader;
1491 REBAR_Layout (hwnd, NULL);
1492 REBAR_ForceResize (hwnd);
1493 REBAR_MoveChildWindows (hwnd);
1500 REBAR_SetBarInfo (HWND hwnd, WPARAM wParam, LPARAM lParam)
1502 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
1503 LPREBARINFO lpInfo = (LPREBARINFO)lParam;
1508 if (lpInfo->cbSize < sizeof (REBARINFO))
1511 TRACE("setting bar info!\n");
1513 if (lpInfo->fMask & RBIM_IMAGELIST) {
1514 infoPtr->himl = lpInfo->himl;
1515 if (infoPtr->himl) {
1517 ImageList_GetIconSize (infoPtr->himl, &cx, &cy);
1518 infoPtr->imageSize.cx = cx;
1519 infoPtr->imageSize.cy = cy;
1522 infoPtr->imageSize.cx = 0;
1523 infoPtr->imageSize.cy = 0;
1532 REBAR_SetBkColor (HWND hwnd, WPARAM wParam, LPARAM lParam)
1534 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
1537 clrTemp = infoPtr->clrBk;
1538 infoPtr->clrBk = (COLORREF)lParam;
1540 TRACE("background color 0x%06lx!\n", infoPtr->clrBk);
1546 /* << REBAR_SetColorScheme >> */
1547 /* << REBAR_SetPalette >> */
1551 REBAR_SetParent (HWND hwnd, WPARAM wParam, LPARAM lParam)
1553 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
1554 HWND hwndTemp = infoPtr->hwndNotify;
1556 infoPtr->hwndNotify = (HWND)wParam;
1558 return (LRESULT)hwndTemp;
1563 REBAR_SetTextColor (HWND hwnd, WPARAM wParam, LPARAM lParam)
1565 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
1568 clrTemp = infoPtr->clrText;
1569 infoPtr->clrText = (COLORREF)lParam;
1571 TRACE("text color 0x%06lx!\n", infoPtr->clrText);
1577 /* << REBAR_SetTooltips >> */
1580 inline static LRESULT
1581 REBAR_SetUnicodeFormat (HWND hwnd, WPARAM wParam)
1583 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
1584 BOOL bTemp = infoPtr->bUnicode;
1585 infoPtr->bUnicode = (BOOL)wParam;
1591 REBAR_SetVersion (HWND hwnd, INT iVersion)
1593 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
1594 INT iOldVersion = infoPtr->iVersion;
1596 if (iVersion > COMCTL32_VERSION)
1599 infoPtr->iVersion = iVersion;
1606 REBAR_ShowBand (HWND hwnd, WPARAM wParam, LPARAM lParam)
1608 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
1611 if (((INT)wParam < 0) || ((INT)wParam > infoPtr->uNumBands))
1614 lpBand = &infoPtr->bands[(INT)wParam];
1617 TRACE("show band %d\n", (INT)wParam);
1618 lpBand->fStyle = lpBand->fStyle & ~RBBS_HIDDEN;
1619 if (IsWindow (lpBand->hwndChild))
1620 ShowWindow (lpBand->hwndChild, SW_SHOW);
1623 TRACE("hide band %d\n", (INT)wParam);
1624 lpBand->fStyle = lpBand->fStyle | RBBS_HIDDEN;
1625 if (IsWindow (lpBand->hwndChild))
1626 ShowWindow (lpBand->hwndChild, SW_SHOW);
1629 REBAR_Layout (hwnd, NULL);
1630 REBAR_ForceResize (hwnd);
1631 REBAR_MoveChildWindows (hwnd);
1638 REBAR_SizeToRect (HWND hwnd, WPARAM wParam, LPARAM lParam)
1640 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
1641 LPRECT lpRect = (LPRECT)lParam;
1646 FIXME("layout change not implemented!\n");
1647 FIXME("[%d %d %d %d]\n",
1648 lpRect->left, lpRect->top, lpRect->right, lpRect->bottom);
1651 SetWindowPos (hwnd, 0, lpRect->left, lpRect->top,
1652 lpRect->right - lpRect->left, lpRect->bottom - lpRect->top,
1656 infoPtr->calcSize.cx = lpRect->right - lpRect->left;
1657 infoPtr->calcSize.cy = lpRect->bottom - lpRect->top;
1659 REBAR_ForceResize (hwnd);
1666 REBAR_Create (HWND hwnd, WPARAM wParam, LPARAM lParam)
1668 REBAR_INFO *infoPtr;
1670 /* allocate memory for info structure */
1671 infoPtr = (REBAR_INFO *)COMCTL32_Alloc (sizeof(REBAR_INFO));
1672 SetWindowLongA (hwnd, 0, (DWORD)infoPtr);
1674 /* initialize info structure */
1675 infoPtr->iVersion = 0;
1676 infoPtr->clrBk = CLR_NONE;
1677 infoPtr->clrText = RGB(0, 0, 0);
1679 infoPtr->bAutoResize = FALSE;
1680 infoPtr->hcurArrow = LoadCursorA (0, IDC_ARROWA);
1681 infoPtr->hcurHorz = LoadCursorA (0, IDC_SIZEWEA);
1682 infoPtr->hcurVert = LoadCursorA (0, IDC_SIZENSA);
1683 infoPtr->hcurDrag = LoadCursorA (0, IDC_SIZEA);
1685 infoPtr->bUnicode = IsWindowUnicode (hwnd);
1687 if (GetWindowLongA (hwnd, GWL_STYLE) & RBS_AUTOSIZE)
1688 FIXME("style RBS_AUTOSIZE set!\n");
1691 SendMessageA (hwnd, WM_NOTIFYFORMAT, (WPARAM)hwnd, NF_QUERY);
1694 TRACE("created!\n");
1700 REBAR_Destroy (HWND hwnd, WPARAM wParam, LPARAM lParam)
1702 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
1707 /* free rebar bands */
1708 if ((infoPtr->uNumBands > 0) && infoPtr->bands) {
1709 /* clean up each band */
1710 for (i = 0; i < infoPtr->uNumBands; i++) {
1711 lpBand = &infoPtr->bands[i];
1713 /* delete text strings */
1714 if (lpBand->lpText) {
1715 COMCTL32_Free (lpBand->lpText);
1716 lpBand->lpText = NULL;
1718 /* destroy child window */
1719 DestroyWindow (lpBand->hwndChild);
1722 /* free band array */
1723 COMCTL32_Free (infoPtr->bands);
1724 infoPtr->bands = NULL;
1730 DeleteObject (infoPtr->hcurArrow);
1731 DeleteObject (infoPtr->hcurHorz);
1732 DeleteObject (infoPtr->hcurVert);
1733 DeleteObject (infoPtr->hcurDrag);
1738 /* free rebar info data */
1739 COMCTL32_Free (infoPtr);
1740 SetWindowLongA (hwnd, 0, 0);
1741 TRACE("destroyed!\n");
1747 REBAR_GetFont (HWND hwnd, WPARAM wParam, LPARAM lParam)
1749 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
1751 return (LRESULT)infoPtr->hFont;
1757 REBAR_MouseMove (HWND hwnd, WPARAM wParam, LPARAM lParam)
1759 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
1766 inline static LRESULT
1767 REBAR_NCCalcSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
1769 if (GetWindowLongA (hwnd, GWL_STYLE) & WS_BORDER) {
1770 ((LPRECT)lParam)->left += GetSystemMetrics(SM_CXEDGE);
1771 ((LPRECT)lParam)->top += GetSystemMetrics(SM_CYEDGE);
1772 ((LPRECT)lParam)->right -= GetSystemMetrics(SM_CXEDGE);
1773 ((LPRECT)lParam)->bottom -= GetSystemMetrics(SM_CYEDGE);
1781 REBAR_NCPaint (HWND hwnd, WPARAM wParam, LPARAM lParam)
1783 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
1787 if (dwStyle & WS_MINIMIZE)
1788 return 0; /* Nothing to do */
1790 DefWindowProcA (hwnd, WM_NCPAINT, wParam, lParam);
1792 if (!(hdc = GetDCEx( hwnd, 0, DCX_USESTYLE | DCX_WINDOW )))
1795 if (dwStyle & WS_BORDER) {
1796 GetWindowRect (hwnd, &rcWindow);
1797 OffsetRect (&rcWindow, -rcWindow.left, -rcWindow.top);
1798 DrawEdge (hdc, &rcWindow, EDGE_ETCHED, BF_RECT);
1801 ReleaseDC( hwnd, hdc );
1808 REBAR_Paint (HWND hwnd, WPARAM wParam)
1813 hdc = wParam==0 ? BeginPaint (hwnd, &ps) : (HDC)wParam;
1814 REBAR_Refresh (hwnd, hdc);
1816 EndPaint (hwnd, &ps);
1822 REBAR_SetCursor (HWND hwnd, WPARAM wParam, LPARAM lParam)
1824 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
1825 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
1829 TRACE("code=0x%X id=0x%X\n", LOWORD(lParam), HIWORD(lParam));
1832 ScreenToClient (hwnd, &pt);
1834 REBAR_InternalHitTest (hwnd, &pt, &flags, NULL);
1836 if (flags == RBHT_GRABBER) {
1837 if ((dwStyle & CCS_VERT) &&
1838 !(dwStyle & RBS_VERTICALGRIPPER))
1839 SetCursor (infoPtr->hcurVert);
1841 SetCursor (infoPtr->hcurHorz);
1843 else if (flags != RBHT_CLIENT)
1844 SetCursor (infoPtr->hcurArrow);
1851 REBAR_SetFont (HWND hwnd, WPARAM wParam, LPARAM lParam)
1853 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
1855 /* TEXTMETRIC32A tm; */
1856 HFONT hFont /*, hOldFont */;
1859 infoPtr->hFont = (HFONT)wParam;
1861 hFont = infoPtr->hFont ? infoPtr->hFont : GetStockObject (SYSTEM_FONT);
1864 hOldFont = SelectObject32 (hdc, hFont);
1865 GetTextMetrics32A (hdc, &tm);
1866 infoPtr->nHeight = tm.tmHeight + VERT_BORDER;
1867 SelectObject32 (hdc, hOldFont);
1868 ReleaseDC32 (0, hdc);
1872 REBAR_Layout (hwnd);
1873 hdc = GetDC32 (hwnd);
1874 REBAR_Refresh (hwnd, hdc);
1875 ReleaseDC32 (hwnd, hdc);
1883 REBAR_Size (HWND hwnd, WPARAM wParam, LPARAM lParam)
1885 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
1886 /* DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE); */
1888 /* INT32 x, y, cx, cy; */
1890 /* auto resize deadlock check */
1891 if (infoPtr->bAutoResize) {
1892 infoPtr->bAutoResize = FALSE;
1896 TRACE("sizing rebar!\n");
1898 /* get parent rectangle */
1899 GetClientRect (GetParent (hwnd), &rcParent);
1901 REBAR_Layout (hwnd, &rcParent);
1903 if (dwStyle & CCS_VERT) {
1904 if (dwStyle & CCS_LEFT == CCS_LEFT) {
1907 cx = infoPtr->calcSize.cx;
1908 cy = infoPtr->calcSize.cy;
1911 x = rcParent.right - infoPtr->calcSize.cx;
1913 cx = infoPtr->calcSize.cx;
1914 cy = infoPtr->calcSize.cy;
1918 if (dwStyle & CCS_TOP) {
1921 cx = infoPtr->calcSize.cx;
1922 cy = infoPtr->calcSize.cy;
1926 y = rcParent.bottom - infoPtr->calcSize.cy;
1927 cx = infoPtr->calcSize.cx;
1928 cy = infoPtr->calcSize.cy;
1932 SetWindowPos32 (hwnd, 0, x, y, cx, cy,
1933 SWP_NOZORDER | SWP_SHOWWINDOW);
1935 REBAR_Layout (hwnd, NULL);
1936 REBAR_ForceResize (hwnd);
1937 REBAR_MoveChildWindows (hwnd);
1943 static LRESULT WINAPI
1944 REBAR_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
1946 TRACE("hwnd=%x msg=%x wparam=%x lparam=%lx\n", hwnd, uMsg, wParam, lParam);
1947 if (!REBAR_GetInfoPtr (hwnd) && (uMsg != WM_CREATE))
1948 return DefWindowProcA (hwnd, uMsg, wParam, lParam);
1951 /* case RB_BEGINDRAG: */
1954 return REBAR_DeleteBand (hwnd, wParam, lParam);
1956 /* case RB_DRAGMOVE: */
1957 /* case RB_ENDDRAG: */
1959 case RB_GETBANDBORDERS:
1960 return REBAR_GetBandBorders (hwnd, wParam, lParam);
1962 case RB_GETBANDCOUNT:
1963 return REBAR_GetBandCount (hwnd);
1965 /* case RB_GETBANDINFO32: */ /* outdated, just for compatibility */
1967 case RB_GETBANDINFOA:
1968 return REBAR_GetBandInfoA (hwnd, wParam, lParam);
1970 case RB_GETBANDINFOW:
1971 return REBAR_GetBandInfoW (hwnd, wParam, lParam);
1973 case RB_GETBARHEIGHT:
1974 return REBAR_GetBarHeight (hwnd, wParam, lParam);
1977 return REBAR_GetBarInfo (hwnd, wParam, lParam);
1980 return REBAR_GetBkColor (hwnd);
1982 /* case RB_GETCOLORSCHEME: */
1983 /* case RB_GETDROPTARGET: */
1986 return REBAR_GetPalette (hwnd, wParam, lParam);
1989 return REBAR_GetRect (hwnd, wParam, lParam);
1991 case RB_GETROWCOUNT:
1992 return REBAR_GetRowCount (hwnd);
1994 case RB_GETROWHEIGHT:
1995 return REBAR_GetRowHeight (hwnd, wParam, lParam);
1997 case RB_GETTEXTCOLOR:
1998 return REBAR_GetTextColor (hwnd);
2000 case RB_GETTOOLTIPS:
2001 return REBAR_GetToolTips (hwnd);
2003 case RB_GETUNICODEFORMAT:
2004 return REBAR_GetUnicodeFormat (hwnd);
2006 case CCM_GETVERSION:
2007 return REBAR_GetVersion (hwnd);
2010 return REBAR_HitTest (hwnd, wParam, lParam);
2013 return REBAR_IdToIndex (hwnd, wParam, lParam);
2015 case RB_INSERTBANDA:
2016 return REBAR_InsertBandA (hwnd, wParam, lParam);
2018 case RB_INSERTBANDW:
2019 return REBAR_InsertBandW (hwnd, wParam, lParam);
2021 case RB_MAXIMIZEBAND:
2022 return REBAR_MaximizeBand (hwnd, wParam, lParam);
2024 case RB_MINIMIZEBAND:
2025 return REBAR_MinimizeBand (hwnd, wParam, lParam);
2028 return REBAR_MoveBand (hwnd, wParam, lParam);
2030 case RB_SETBANDINFOA:
2031 return REBAR_SetBandInfoA (hwnd, wParam, lParam);
2033 case RB_SETBANDINFOW:
2034 return REBAR_SetBandInfoW (hwnd, wParam, lParam);
2037 return REBAR_SetBarInfo (hwnd, wParam, lParam);
2040 return REBAR_SetBkColor (hwnd, wParam, lParam);
2042 /* case RB_SETCOLORSCHEME: */
2043 /* case RB_SETPALETTE: */
2044 /* return REBAR_GetPalette (hwnd, wParam, lParam); */
2047 return REBAR_SetParent (hwnd, wParam, lParam);
2049 case RB_SETTEXTCOLOR:
2050 return REBAR_SetTextColor (hwnd, wParam, lParam);
2052 /* case RB_SETTOOLTIPS: */
2054 case RB_SETUNICODEFORMAT:
2055 return REBAR_SetUnicodeFormat (hwnd, wParam);
2057 case CCM_SETVERSION:
2058 return REBAR_SetVersion (hwnd, (INT)wParam);
2061 return REBAR_ShowBand (hwnd, wParam, lParam);
2064 return REBAR_SizeToRect (hwnd, wParam, lParam);
2068 return SendMessageA (GetParent (hwnd), uMsg, wParam, lParam);
2071 return REBAR_Create (hwnd, wParam, lParam);
2074 return REBAR_Destroy (hwnd, wParam, lParam);
2077 return REBAR_GetFont (hwnd, wParam, lParam);
2079 /* case WM_MOUSEMOVE: */
2080 /* return REBAR_MouseMove (hwnd, wParam, lParam); */
2083 return REBAR_NCCalcSize (hwnd, wParam, lParam);
2086 return REBAR_NCPaint (hwnd, wParam, lParam);
2089 return SendMessageA (GetParent (hwnd), uMsg, wParam, lParam);
2092 return REBAR_Paint (hwnd, wParam);
2095 return REBAR_SetCursor (hwnd, wParam, lParam);
2098 return REBAR_SetFont (hwnd, wParam, lParam);
2101 return REBAR_Size (hwnd, wParam, lParam);
2103 /* case WM_TIMER: */
2105 /* case WM_WININICHANGE: */
2108 if (uMsg >= WM_USER)
2109 ERR("unknown msg %04x wp=%08x lp=%08lx\n",
2110 uMsg, wParam, lParam);
2111 return DefWindowProcA (hwnd, uMsg, wParam, lParam);
2118 REBAR_Register (void)
2122 ZeroMemory (&wndClass, sizeof(WNDCLASSA));
2123 wndClass.style = CS_GLOBALCLASS | CS_DBLCLKS;
2124 wndClass.lpfnWndProc = (WNDPROC)REBAR_WindowProc;
2125 wndClass.cbClsExtra = 0;
2126 wndClass.cbWndExtra = sizeof(REBAR_INFO *);
2127 wndClass.hCursor = 0;
2128 wndClass.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1);
2129 wndClass.lpszClassName = REBARCLASSNAMEA;
2131 RegisterClassA (&wndClass);
2136 REBAR_Unregister (void)
2138 UnregisterClassA (REBARCLASSNAMEA, (HINSTANCE)NULL);