4 * Copyright 1998 Eric Kohl
7 * This is just a dummy control. An author is needed! Any volunteers?
8 * I will only improve this control once in a while.
9 * Eric <ekohl@abo.rhein-zeitung.de>
13 * - All notifications.
23 #define REBAR_GetInfoPtr(wndPtr) ((REBAR_INFO *)wndPtr->wExtra[0])
29 REBAR_Refresh (WND *wndPtr, HDC32 hdc)
34 GetClientRect32 (wndPtr->hwndSelf, &rect);
36 hbrBk = CreateSolidBrush32 (RGB (192, 192, 192));
37 FillRect32 (hdc, &rect, hbrBk);
38 DeleteObject32 (hbrBk);
44 // << REBAR_BeginDrag >>
48 REBAR_DeleteBand (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
50 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (wndPtr);
51 UINT32 uBand = (UINT32)wParam;
53 if (uBand >= infoPtr->uNumBands)
56 FIXME (rebar, "deleting band %u!\n", uBand);
62 // << REBAR_DragMove >>
63 // << REBAR_EndDrag >>
64 // << REBAR_GetBandBorders >>
67 __inline__ static LRESULT
68 REBAR_GetBandCount (WND *wndPtr)
70 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (wndPtr);
72 TRACE (rebar, "band count %u!\n", infoPtr->uNumBands);
74 return infoPtr->uNumBands;
79 REBAR_GetBandInfo32A (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
81 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (wndPtr);
82 LPREBARBANDINFO32A lprbbi = (LPREBARBANDINFO32A)lParam;
87 if (lprbbi->cbSize < REBARBANDINFO_V3_SIZE32A)
89 if ((UINT32)wParam >= infoPtr->uNumBands)
92 TRACE (rebar, "index %u\n", (UINT32)wParam);
94 /* copy band information */
95 lpBand = &infoPtr->bands[(UINT32)wParam];
97 if (lprbbi->fMask & RBBIM_STYLE)
98 lprbbi->fStyle = lpBand->fStyle;
100 if (lprbbi->fMask & RBBIM_COLORS) {
101 lprbbi->clrFore = lpBand->clrFore;
102 lprbbi->clrBack = lpBand->clrBack;
105 if ((lprbbi->fMask & RBBIM_TEXT) &&
106 (lprbbi->lpText) && (lpBand->lpText)) {
107 lstrcpyn32A (lprbbi->lpText, lpBand->lpText, lprbbi->cch);
110 if (lprbbi->fMask & RBBIM_IMAGE)
111 lprbbi->iImage = lpBand->iImage;
113 if (lprbbi->fMask & RBBIM_CHILD)
114 lprbbi->hwndChild = lpBand->hwndChild;
116 if (lprbbi->fMask & RBBIM_CHILDSIZE) {
117 lprbbi->cxMinChild = lpBand->cxMinChild;
118 lprbbi->cyMinChild = lpBand->cyMinChild;
119 lprbbi->cyMaxChild = lpBand->cyMaxChild;
120 lprbbi->cyChild = lpBand->cyChild;
121 lprbbi->cyIntegral = lpBand->cyIntegral;
124 if (lprbbi->fMask & RBBIM_SIZE)
125 lprbbi->cx = lpBand->cx;
127 if (lprbbi->fMask & RBBIM_BACKGROUND)
128 lprbbi->hbmBack = lpBand->hbmBack;
130 if (lprbbi->fMask & RBBIM_ID)
131 lprbbi->wID = lpBand->wID;
133 /* check for additional data */
134 if (lprbbi->cbSize >= sizeof (REBARBANDINFO32A)) {
135 if (lprbbi->fMask & RBBIM_IDEALSIZE)
136 lprbbi->cxIdeal = lpBand->cxIdeal;
138 if (lprbbi->fMask & RBBIM_LPARAM)
139 lprbbi->lParam = lpBand->lParam;
141 if (lprbbi->fMask & RBBIM_HEADERSIZE)
142 lprbbi->cxHeader = lpBand->cxHeader;
149 // << REBAR_GetBandInfo32W >>
153 REBAR_GetBarHeight (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
155 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (wndPtr);
157 FIXME (rebar, "returns fixed height of 40 pixels!\n");
164 REBAR_GetBarInfo (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
166 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (wndPtr);
167 LPREBARINFO lpInfo = (LPREBARINFO)lParam;
172 if (lpInfo->cbSize < sizeof (REBARINFO))
175 TRACE (rebar, "getting bar info!\n");
178 lpInfo->himl = infoPtr->himl;
179 lpInfo->fMask |= RBIM_IMAGELIST;
186 __inline__ static LRESULT
187 REBAR_GetBkColor (WND *wndPtr)
189 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (wndPtr);
191 TRACE (rebar, "background color 0x%06lx!\n", infoPtr->clrBk);
193 return infoPtr->clrBk;
197 // << REBAR_GetColorScheme >>
199 // << REBAR_GetRowHeight >>
202 __inline__ static LRESULT
203 REBAR_GetTextColor (WND *wndPtr)
205 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (wndPtr);
207 TRACE (rebar, "text color 0x%06lx!\n", infoPtr->clrText);
209 return infoPtr->clrText;
213 // << REBAR_GetToolTips >>
214 // << REBAR_GetUnicodeFormat >>
215 // << REBAR_HitTest >>
219 REBAR_IdToIndex (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
221 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (wndPtr);
227 if (infoPtr->uNumBands < 1)
230 TRACE (rebar, "id %u\n", (UINT32)wParam);
232 for (i = 0; i < infoPtr->uNumBands; i++) {
233 if (infoPtr->bands[i].wID == (UINT32)wParam) {
234 TRACE (rebar, "band %u found!\n", i);
239 TRACE (rebar, "no band found!\n");
245 REBAR_InsertBand32A (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
247 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (wndPtr);
248 LPREBARBANDINFO32A lprbbi = (LPREBARBANDINFO32A)lParam;
249 UINT32 uIndex = (UINT32)wParam;
256 if (lprbbi->cbSize < REBARBANDINFO_V3_SIZE32A)
259 TRACE (rebar, "insert band at %u!\n", uIndex);
261 if (infoPtr->uNumBands == 0) {
262 infoPtr->bands = (REBAR_BAND *)COMCTL32_Alloc (sizeof (REBAR_BAND));
266 REBAR_BAND *oldBands = infoPtr->bands;
268 (REBAR_BAND *)COMCTL32_Alloc ((infoPtr->uNumBands+1)*sizeof(REBAR_BAND));
269 if (((INT32)uIndex == -1) || (uIndex > infoPtr->uNumBands))
270 uIndex = infoPtr->uNumBands;
272 /* pre insert copy */
274 memcpy (&infoPtr->bands[0], &oldBands[0],
275 uIndex * sizeof(REBAR_BAND));
279 if (uIndex < infoPtr->uNumBands - 1) {
280 memcpy (&infoPtr->bands[uIndex+1], &oldBands[uIndex],
281 (infoPtr->uNumBands - uIndex - 1) * sizeof(REBAR_BAND));
284 COMCTL32_Free (&oldBands);
287 infoPtr->uNumBands++;
289 TRACE (rebar, "index %u!\n", uIndex);
291 /* initialize band (infoPtr->bands[uIndex])*/
292 lpBand = &infoPtr->bands[uIndex];
294 if (lprbbi->fMask & RBBIM_STYLE)
295 lpBand->fStyle = lprbbi->fStyle;
297 if (lprbbi->fMask & RBBIM_COLORS) {
298 lpBand->clrFore = lprbbi->clrFore;
299 lpBand->clrBack = lprbbi->clrBack;
302 if ((lprbbi->fMask & RBBIM_TEXT) && (lprbbi->lpText)) {
303 INT32 len = lstrlen32A (lprbbi->lpText);
305 lpBand->lpText = (LPSTR)COMCTL32_Alloc (len + 1);
306 lstrcpy32A (lpBand->lpText, lprbbi->lpText);
310 if (lprbbi->fMask & RBBIM_IMAGE)
311 lpBand->iImage = lprbbi->iImage;
313 if (lprbbi->fMask & RBBIM_CHILD) {
314 lpBand->hwndChild = lprbbi->hwndChild;
315 lpBand->hwndPrevParent =
316 SetParent32 (lpBand->hwndChild, wndPtr->hwndSelf);
319 if (lprbbi->fMask & RBBIM_CHILDSIZE) {
320 lpBand->cxMinChild = lprbbi->cxMinChild;
321 lpBand->cyMinChild = lprbbi->cyMinChild;
322 lpBand->cyMaxChild = lprbbi->cyMaxChild;
323 lpBand->cyChild = lprbbi->cyChild;
324 lpBand->cyIntegral = lprbbi->cyIntegral;
327 if (lprbbi->fMask & RBBIM_SIZE)
328 lpBand->cx = lprbbi->cx;
330 if (lprbbi->fMask & RBBIM_BACKGROUND)
331 lpBand->hbmBack = lprbbi->hbmBack;
333 if (lprbbi->fMask & RBBIM_ID)
334 lpBand->wID = lprbbi->wID;
336 /* check for additional data */
337 if (lprbbi->cbSize >= sizeof (REBARBANDINFO32A)) {
338 if (lprbbi->fMask & RBBIM_IDEALSIZE)
339 lpBand->cxIdeal = lprbbi->cxIdeal;
341 if (lprbbi->fMask & RBBIM_LPARAM)
342 lpBand->lParam = lprbbi->lParam;
344 if (lprbbi->fMask & RBBIM_HEADERSIZE)
345 lpBand->cxHeader = lprbbi->cxHeader;
352 // << REBAR_InsertBand32W >>
353 // << REBAR_MaximizeBand >>
354 // << REBAR_MinimizeBand >>
355 // << REBAR_MoveBand >>
359 REBAR_SetBandInfo32A (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
361 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (wndPtr);
362 LPREBARBANDINFO32A lprbbi = (LPREBARBANDINFO32A)lParam;
367 if (lprbbi->cbSize < REBARBANDINFO_V3_SIZE32A)
369 if ((UINT32)wParam >= infoPtr->uNumBands)
372 TRACE (rebar, "index %u\n", (UINT32)wParam);
374 /* set band information */
375 lpBand = &infoPtr->bands[(UINT32)wParam];
377 if (lprbbi->fMask & RBBIM_STYLE)
378 lpBand->fStyle = lprbbi->fStyle;
380 if (lprbbi->fMask & RBBIM_COLORS) {
381 lpBand->clrFore = lprbbi->clrFore;
382 lpBand->clrBack = lprbbi->clrBack;
385 if ((lprbbi->fMask & RBBIM_TEXT) && (lprbbi->lpText)) {
387 INT32 len = lstrlen32A (lprbbi->lpText);
389 lpBand->lpText = (LPSTR)COMCTL32_Alloc (len + 1);
390 lstrcpy32A (lpBand->lpText, lprbbi->lpText);
395 if (lprbbi->fMask & RBBIM_IMAGE)
396 lpBand->iImage = lprbbi->iImage;
398 if (lprbbi->fMask & RBBIM_CHILD) {
399 lpBand->hwndChild = lprbbi->hwndChild;
400 lpBand->hwndPrevParent =
401 SetParent32 (lpBand->hwndChild, wndPtr->hwndSelf);
404 if (lprbbi->fMask & RBBIM_CHILDSIZE) {
405 lpBand->cxMinChild = lprbbi->cxMinChild;
406 lpBand->cyMinChild = lprbbi->cyMinChild;
407 lpBand->cyMaxChild = lprbbi->cyMaxChild;
408 lpBand->cyChild = lprbbi->cyChild;
409 lpBand->cyIntegral = lprbbi->cyIntegral;
412 if (lprbbi->fMask & RBBIM_SIZE)
413 lpBand->cx = lprbbi->cx;
415 if (lprbbi->fMask & RBBIM_BACKGROUND)
416 lpBand->hbmBack = lprbbi->hbmBack;
418 if (lprbbi->fMask & RBBIM_ID)
419 lpBand->wID = lprbbi->wID;
421 /* check for additional data */
422 if (lprbbi->cbSize >= sizeof (REBARBANDINFO32A)) {
423 if (lprbbi->fMask & RBBIM_IDEALSIZE)
424 lpBand->cxIdeal = lprbbi->cxIdeal;
426 if (lprbbi->fMask & RBBIM_LPARAM)
427 lpBand->lParam = lprbbi->lParam;
429 if (lprbbi->fMask & RBBIM_HEADERSIZE)
430 lpBand->cxHeader = lprbbi->cxHeader;
437 // << REBAR_SetBandInfo32W >>
441 REBAR_SetBarInfo (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
443 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (wndPtr);
444 LPREBARINFO lpInfo = (LPREBARINFO)lParam;
449 if (lpInfo->cbSize < sizeof (REBARINFO))
452 TRACE (rebar, "setting bar info!\n");
454 if (lpInfo->fMask & RBIM_IMAGELIST)
455 infoPtr->himl = lpInfo->himl;
462 REBAR_SetBkColor (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
464 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (wndPtr);
467 clrTemp = infoPtr->clrBk;
468 infoPtr->clrBk = (COLORREF)lParam;
470 TRACE (rebar, "background color 0x%06lx!\n", infoPtr->clrBk);
476 // << REBAR_SetColorScheme >>
477 // << REBAR_SetPalette >>
478 // << REBAR_SetParent >>
482 REBAR_SetTextColor (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
484 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (wndPtr);
487 clrTemp = infoPtr->clrText;
488 infoPtr->clrText = (COLORREF)lParam;
490 TRACE (rebar, "text color 0x%06lx!\n", infoPtr->clrText);
496 // << REBAR_SetTooltips >>
497 // << REBAR_SetUnicodeFormat >>
501 REBAR_ShowBand (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
503 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (wndPtr);
505 if (((INT32)wParam < 0) || ((INT32)wParam > infoPtr->uNumBands))
509 FIXME (rebar, "show band %d\n", (INT32)wParam);
511 FIXME (rebar, "hide band %d\n", (INT32)wParam);
518 REBAR_SizeToRect (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
520 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (wndPtr);
521 LPRECT32 lpRect = (LPRECT32)lParam;
526 FIXME (rebar, "layout change not implemented!\n");
534 REBAR_Create (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
538 /* allocate memory for info structure */
539 infoPtr = (REBAR_INFO *)COMCTL32_Alloc (sizeof(REBAR_INFO));
540 wndPtr->wExtra[0] = (DWORD)infoPtr;
542 if (infoPtr == NULL) {
543 ERR (rebar, "could not allocate info memory!\n");
547 if ((REBAR_INFO*)wndPtr->wExtra[0] != infoPtr) {
548 ERR (rebar, "pointer assignment error!\n");
552 /* initialize info structure */
553 infoPtr->clrText = CLR_NONE;
554 infoPtr->clrText = RGB(0, 0, 0);
556 TRACE (rebar, "created!\n");
562 REBAR_Destroy (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
564 REBAR_INFO *infoPtr = REBAR_GetInfoPtr(wndPtr);
569 /* free rebar bands */
570 if ((infoPtr->uNumBands > 0) && infoPtr->bands) {
571 /* clean up each band */
572 for (i = 0; i < infoPtr->uNumBands; i++) {
573 lpBand = &infoPtr->bands[i];
575 /* delete text strings */
576 if (lpBand->lpText) {
577 COMCTL32_Free (lpBand->lpText);
578 lpBand->lpText = NULL;
582 /* free band array */
583 COMCTL32_Free (infoPtr->bands);
584 infoPtr->bands = NULL;
587 /* free rebar info data */
588 COMCTL32_Free (infoPtr);
590 TRACE (rebar, "destroyed!\n");
597 REBAR_Paint (WND *wndPtr, WPARAM32 wParam)
602 hdc = wParam==0 ? BeginPaint32 (wndPtr->hwndSelf, &ps) : (HDC32)wParam;
603 REBAR_Refresh (wndPtr, hdc);
605 EndPaint32 (wndPtr->hwndSelf, &ps);
612 REBAR_WindowProc (HWND32 hwnd, UINT32 uMsg, WPARAM32 wParam, LPARAM lParam)
614 WND *wndPtr = WIN_FindWndPtr(hwnd);
618 // case RB_BEGINDRAG:
621 return REBAR_DeleteBand (wndPtr, wParam, lParam);
625 // case RB_GETBANDBORDERS:
627 case RB_GETBANDCOUNT:
628 return REBAR_GetBandCount (wndPtr);
630 // case RB_GETBANDINFO32: /* outdated, just for compatibility */
632 case RB_GETBANDINFO32A:
633 return REBAR_GetBandInfo32A (wndPtr, wParam, lParam);
635 // case RB_GETBANDINFO32W:
637 case RB_GETBARHEIGHT:
638 return REBAR_GetBarHeight (wndPtr, wParam, lParam);
641 return REBAR_GetBarInfo (wndPtr, wParam, lParam);
644 return REBAR_GetBkColor (wndPtr);
646 // case RB_GETCOLORSCHEME:
647 // case RB_GETDROPTARGET:
648 // case RB_GETPALETTE:
650 // case RB_GETROWCOUNT:
651 // case RB_GETROWHEIGHT:
653 case RB_GETTEXTCOLOR:
654 return REBAR_GetTextColor (wndPtr);
656 // case RB_GETTOOLTIPS:
657 // case RB_GETUNICODEFORMAT:
661 return REBAR_IdToIndex (wndPtr, wParam, lParam);
663 case RB_INSERTBAND32A:
664 return REBAR_InsertBand32A (wndPtr, wParam, lParam);
666 // case RB_INSERTBAND32W:
667 // case RB_MAXIMIZEBAND:
668 // case RB_MINIMIZEBAND:
671 case RB_SETBANDINFO32A:
672 return REBAR_SetBandInfo32A (wndPtr, wParam, lParam);
674 // case RB_SETBANDINFO32W:
677 return REBAR_SetBarInfo (wndPtr, wParam, lParam);
680 return REBAR_SetBkColor (wndPtr, wParam, lParam);
682 // case RB_SETCOLORSCHEME:
683 // case RB_SETPALETTE:
684 // case RB_SETPARENT:
686 case RB_SETTEXTCOLOR:
687 return REBAR_SetTextColor (wndPtr, wParam, lParam);
689 // case RB_SETTOOLTIPS:
690 // case RB_SETUNICODEFORMAT:
693 return REBAR_ShowBand (wndPtr, wParam, lParam);
696 return REBAR_SizeToRect (wndPtr, wParam, lParam);
700 return REBAR_Create (wndPtr, wParam, lParam);
703 return REBAR_Destroy (wndPtr, wParam, lParam);
707 // case WM_MOUSEMOVE:
708 // return REBAR_MouseMove (wndPtr, wParam, lParam);
711 return REBAR_Paint (wndPtr, wParam);
717 // case WM_WININICHANGE:
721 ERR (rebar, "unknown msg %04x wp=%08x lp=%08lx\n",
722 uMsg, wParam, lParam);
723 return DefWindowProc32A (hwnd, uMsg, wParam, lParam);
730 REBAR_Register (void)
732 WNDCLASS32A wndClass;
734 if (GlobalFindAtom32A (REBARCLASSNAME32A)) return;
736 ZeroMemory (&wndClass, sizeof(WNDCLASS32A));
737 wndClass.style = CS_GLOBALCLASS | CS_DBLCLKS;
738 wndClass.lpfnWndProc = (WNDPROC32)REBAR_WindowProc;
739 wndClass.cbClsExtra = 0;
740 wndClass.cbWndExtra = sizeof(REBAR_INFO *);
741 wndClass.hCursor = 0;
742 wndClass.hbrBackground = (HBRUSH32) COLOR_BTNFACE + 1;
743 wndClass.lpszClassName = REBARCLASSNAME32A;
745 RegisterClass32A (&wndClass);