Release 980712
[wine/multimedia.git] / controls / toolbar.c
blobb562df11fffe9536fa182aed289ea360dcd31fc3
1 /*
2 * Toolbar control
4 * Copyright 1998 Eric Kohl
6 * TODO:
7 * - Bitmap drawing.
8 * - Button wrapping.
9 * - Messages.
10 * - Notifications.
11 * - Fix TB_GETBITMAPFLAGS.
12 * - Fix TB_GETROWS and TB_SETROWS.
13 * - Tooltip support (partially).
14 * - Unicode suppport.
15 * - Internal COMMCTL32 bitmaps.
16 * - Fix TOOLBAR_Customize. (Customize dialog.)
18 * Testing:
19 * - Run tests using Waite Group Windows95 API Bible Volume 2.
20 * The second cdrom contains executables addstr.exe, btncount.exe,
21 * btnstate.exe, butstrsz.exe, chkbtn.exe, chngbmp.exe, customiz.exe,
22 * enablebtn.exe, getbmp.exe, getbtn.exe, getflags.exe, hidebtn.exe,
23 * indetbtn.exe, insbtn.exe, pressbtn.exe, setbtnsz.exe, setcmdid.exe,
24 * setparnt.exe, setrows.exe, toolwnd.exe.
25 * - additional features.
28 #include "windows.h"
29 #include "commctrl.h"
30 #include "cache.h"
31 #include "toolbar.h"
32 #include "heap.h"
33 #include "win.h"
34 #include "debug.h"
37 #define SEPARATOR_WIDTH 8
38 #define SEPARATOR_HEIGHT 5
39 #define TOP_BORDER 2
40 #define BOTTOM_BORDER 2
44 #define TOOLBAR_GetInfoPtr(wndPtr) ((TOOLBAR_INFO *)wndPtr->wExtra[0])
47 static void
48 TOOLBAR_DrawFlatSeparator (LPRECT32 lpRect, HDC32 hdc)
50 INT32 x = (lpRect->left + lpRect->right) / 2 - 1;
51 INT32 yBottom = lpRect->bottom - 3;
52 INT32 yTop = lpRect->top + 1;
54 SelectObject32 ( hdc, GetSysColorPen32 (COLOR_3DSHADOW));
55 MoveToEx32 (hdc, x, yBottom, NULL);
56 LineTo32 (hdc, x, yTop);
57 x++;
58 SelectObject32 ( hdc, GetSysColorPen32 (COLOR_3DHILIGHT));
59 MoveToEx32 (hdc, x, yBottom, NULL);
60 LineTo32 (hdc, x, yTop);
64 static void
65 TOOLBAR_DrawString (TOOLBAR_INFO *infoPtr, TBUTTON_INFO *btnPtr,
66 HDC32 hdc, INT32 nState)
68 RECT32 rcText = btnPtr->rect;
69 HFONT32 hOldFont;
70 INT32 nOldBkMode;
72 /* draw text */
73 if ((btnPtr->iString > -1) && (btnPtr->iString < infoPtr->nNumStrings)) {
75 InflateRect32 (&rcText, -3, -3);
76 rcText.top += infoPtr->nBitmapHeight;
77 if (nState & (TBSTATE_PRESSED | TBSTATE_CHECKED))
78 OffsetRect32 (&rcText, 1, 1);
80 hOldFont = SelectObject32 (hdc, infoPtr->hFont);
81 nOldBkMode = SetBkMode32 (hdc, TRANSPARENT);
82 if (!(nState & TBSTATE_ENABLED)) {
83 COLORREF clrOld =
84 SetTextColor32 (hdc, GetSysColor32 (COLOR_3DHILIGHT));
85 OffsetRect32 (&rcText, 1, 1);
86 DrawText32A (hdc, infoPtr->strings[btnPtr->iString], -1, &rcText,
87 DT_CENTER);
88 SetTextColor32 (hdc, GetSysColor32 (COLOR_3DSHADOW));
89 OffsetRect32 (&rcText, -1, -1);
90 DrawText32A (hdc, infoPtr->strings[btnPtr->iString], -1, &rcText,
91 DT_CENTER);
92 SetTextColor32 (hdc, clrOld);
94 else if (nState & TBSTATE_INDETERMINATE) {
95 COLORREF clrOld =
96 SetTextColor32 (hdc, GetSysColor32 (COLOR_3DSHADOW));
97 DrawText32A (hdc, infoPtr->strings[btnPtr->iString], -1, &rcText,
98 DT_CENTER);
99 SetTextColor32 (hdc, clrOld);
101 else
102 DrawText32A (hdc, infoPtr->strings[btnPtr->iString], -1, &rcText,
103 DT_CENTER);
105 SelectObject32 (hdc, hOldFont);
106 if (nOldBkMode != TRANSPARENT)
107 SetBkMode32 (hdc, nOldBkMode);
112 static void
113 TOOLBAR_DrawButton (WND *wndPtr, TBUTTON_INFO *btnPtr, HDC32 hdc)
115 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
116 BOOL32 bFlat = (wndPtr->dwStyle & TBSTYLE_FLAT);
117 RECT32 rc;
119 if (btnPtr->fsState & TBSTATE_HIDDEN) return;
121 rc = btnPtr->rect;
122 if (btnPtr->fsStyle & TBSTYLE_SEP) {
123 if ((bFlat) && (btnPtr->idCommand == 0))
124 TOOLBAR_DrawFlatSeparator (&btnPtr->rect, hdc);
125 return;
128 /* disabled */
129 if (!(btnPtr->fsState & TBSTATE_ENABLED)) {
130 HICON32 hIcon;
131 DrawEdge32 (hdc, &rc, EDGE_RAISED,
132 BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST);
134 // ImageList_Draw (infoPtr->himlDis, btnPtr->iBitmap, hdc,
135 // rc.left+1, rc.top+1, ILD_NORMAL);
136 TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState);
137 return;
140 /* pressed TBSTYLE_BUTTON */
141 if (btnPtr->fsState & TBSTATE_PRESSED) {
142 DrawEdge32 (hdc, &rc, EDGE_SUNKEN,
143 BF_RECT | BF_MIDDLE | BF_ADJUST);
144 ImageList_Draw (infoPtr->himlDef, btnPtr->iBitmap, hdc,
145 rc.left+2, rc.top+2, ILD_NORMAL);
146 TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState);
147 return;
150 /* checked TBSTYLE_CHECK*/
151 if ((btnPtr->fsStyle & TBSTYLE_CHECK) &&
152 (btnPtr->fsState & TBSTATE_CHECKED)) {
153 HBRUSH32 hbr;
154 DrawEdge32 (hdc, &rc, EDGE_SUNKEN,
155 BF_RECT | BF_MIDDLE | BF_ADJUST);
157 hbr = SelectObject32 (hdc, CACHE_GetPattern55AABrush ());
158 PatBlt32 (hdc, rc.left, rc.top, rc.right - rc.left,
159 rc.bottom - rc.top, 0x00FA0089);
160 SelectObject32 (hdc, hbr);
161 ImageList_Draw (infoPtr->himlDef, btnPtr->iBitmap, hdc,
162 rc.left+2, rc.top+2, ILD_NORMAL);
163 TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState);
164 return;
167 /* indeterminate */
168 if (btnPtr->fsState & TBSTATE_INDETERMINATE) {
169 HBRUSH32 hbr;
170 DrawEdge32 (hdc, &rc, EDGE_RAISED,
171 BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST);
173 hbr = SelectObject32 (hdc, CACHE_GetPattern55AABrush ());
174 PatBlt32 (hdc, rc.left, rc.top, rc.right - rc.left,
175 rc.bottom - rc.top, 0x00FA0089);
176 SelectObject32 (hdc, hbr);
177 // ImageList_Draw (infoPtr->himlDis, btnPtr->iBitmap, hdc,
178 // rc.left+1, rc.top+1, ILD_NORMAL);
179 TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState);
180 return;
183 /* normal state */
184 DrawEdge32 (hdc, &rc, EDGE_RAISED,
185 BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST);
186 ImageList_Draw (infoPtr->himlDef, btnPtr->iBitmap, hdc,
187 rc.left+1, rc.top+1, ILD_NORMAL);
188 TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState);
192 static void
193 TOOLBAR_Refresh (WND *wndPtr, HDC32 hdc)
195 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
196 TBUTTON_INFO *btnPtr;
197 INT32 i;
199 /* draw buttons */
200 btnPtr = infoPtr->buttons;
201 for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++)
202 TOOLBAR_DrawButton (wndPtr, btnPtr, hdc);
206 static void
207 TOOLBAR_CalcStrings (WND *wndPtr, LPSIZE32 lpSize)
209 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
210 TBUTTON_INFO *btnPtr;
211 INT32 i;
212 HDC32 hdc;
213 HFONT32 hOldFont;
214 SIZE32 sz;
216 lpSize->cx = 0;
217 lpSize->cy = 0;
218 hdc = GetDC32 (0);
219 hOldFont = SelectObject32 (hdc, infoPtr->hFont);
221 btnPtr = infoPtr->buttons;
222 for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++) {
223 if (!(btnPtr->fsState & TBSTATE_HIDDEN) &&
224 (btnPtr->iString > -1) &&
225 (btnPtr->iString < infoPtr->nNumStrings)) {
226 LPSTR lpText = infoPtr->strings[btnPtr->iString];
227 GetTextExtentPoint32A (hdc, lpText, lstrlen32A(lpText), &sz);
228 if (sz.cx > lpSize->cx)
229 lpSize->cx = sz.cx;
230 if (sz.cy > lpSize->cy)
231 lpSize->cy = sz.cy;
235 SelectObject32 (hdc, hOldFont);
236 ReleaseDC32 (0, hdc);
238 TRACE (toolbar, "string size %d x %d!\n", lpSize->cx, lpSize->cy);
242 static void
243 TOOLBAR_CalcToolbar (WND *wndPtr)
245 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
246 TBUTTON_INFO *btnPtr;
247 INT32 i, j, nRows;
248 INT32 x, y, cx, cy;
249 BOOL32 bVertical;
250 SIZE32 sizeString;
253 /* test */
254 TOOLBAR_CalcStrings (wndPtr, &sizeString);
256 if (sizeString.cy > 0)
257 infoPtr->nButtonHeight = sizeString.cy + infoPtr->nBitmapHeight + 6;
259 if (sizeString.cx > infoPtr->nBitmapWidth)
260 infoPtr->nButtonWidth = sizeString.cx + 6;
262 x = infoPtr->nIndent;
263 y = TOP_BORDER;
264 cx = infoPtr->nButtonWidth;
265 cy = infoPtr->nButtonHeight;
266 nRows = 1;
268 btnPtr = infoPtr->buttons;
269 for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++) {
270 bVertical = FALSE;
272 if (btnPtr->fsState & TBSTATE_HIDDEN)
273 continue;
275 if (btnPtr->fsStyle & TBSTYLE_SEP) {
276 /* UNDOCUMENTED: If a separator has a non zero bitmap index, */
277 /* it is the actual width of the separator. This is used for */
278 /* custom controls in toolbars. */
279 if ((wndPtr->dwStyle & TBSTYLE_WRAPABLE) &&
280 (btnPtr->fsState & TBSTATE_WRAP)) {
281 x = 0;
282 y += cy;
283 cx = infoPtr->nWidth;
284 cy = ((btnPtr->iBitmap == 0) ?
285 SEPARATOR_WIDTH : btnPtr->iBitmap) * 2 / 3;
286 nRows++;
287 bVertical = TRUE;
289 else
290 cx = (btnPtr->iBitmap == 0) ?
291 SEPARATOR_WIDTH : btnPtr->iBitmap;
293 else {
294 /* this must be a button */
295 cx = infoPtr->nButtonWidth;
299 btnPtr->rect.left = x;
300 btnPtr->rect.top = y;
301 btnPtr->rect.right = x + cx;
302 btnPtr->rect.bottom = y + cy;
304 if (bVertical) {
305 x = 0;
306 y += cy;
307 if (i < infoPtr->nNumButtons)
308 nRows++;
310 else
311 x += cx;
314 infoPtr->nHeight = y + cy + BOTTOM_BORDER;
315 TRACE (toolbar, "toolbar height %d\n", infoPtr->nHeight);
319 static INT32
320 TOOLBAR_InternalHitTest (WND *wndPtr, LPPOINT32 lpPt)
322 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
323 TBUTTON_INFO *btnPtr;
324 INT32 i;
326 btnPtr = infoPtr->buttons;
327 for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++) {
328 if (btnPtr->fsStyle & TBSTYLE_SEP) {
329 if (PtInRect32 (&btnPtr->rect, *lpPt)) {
330 TRACE (toolbar, " ON SEPARATOR %d!\n", i);
331 return -i;
334 else {
335 if (PtInRect32 (&btnPtr->rect, *lpPt)) {
336 TRACE (toolbar, " ON BUTTON %d!\n", i);
337 return i;
342 TRACE (toolbar, " NOWHERE!\n");
343 return -1;
347 static INT32
348 TOOLBAR_GetButtonIndex (TOOLBAR_INFO *infoPtr, INT32 idCommand)
350 TBUTTON_INFO *btnPtr;
351 INT32 i;
353 btnPtr = infoPtr->buttons;
354 for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++) {
355 if (btnPtr->idCommand == idCommand) {
356 TRACE (toolbar, "command=%d index=%d\n", idCommand, i);
357 return i;
360 TRACE (toolbar, "no index found for command=%d\n", idCommand);
361 return -1;
365 static INT32
366 TOOLBAR_GetCheckedGroupButtonIndex (TOOLBAR_INFO *infoPtr, INT32 nIndex)
368 TBUTTON_INFO *btnPtr;
369 INT32 nRunIndex;
371 if ((nIndex < 0) || (nIndex > infoPtr->nNumButtons))
372 return -1;
374 /* check index button */
375 btnPtr = &infoPtr->buttons[nIndex];
376 if ((btnPtr->fsStyle & TBSTYLE_CHECKGROUP) == TBSTYLE_CHECKGROUP) {
377 if (btnPtr->fsState & TBSTATE_CHECKED)
378 return nIndex;
381 /* check previous buttons */
382 nRunIndex = nIndex - 1;
383 while (nRunIndex >= 0) {
384 btnPtr = &infoPtr->buttons[nRunIndex];
385 if ((btnPtr->fsStyle & TBSTYLE_CHECKGROUP) == TBSTYLE_CHECKGROUP) {
386 if (btnPtr->fsState & TBSTATE_CHECKED)
387 return nRunIndex;
389 else
390 break;
391 nRunIndex--;
394 /* check next buttons */
395 nRunIndex = nIndex + 1;
396 while (nRunIndex < infoPtr->nNumButtons) {
397 btnPtr = &infoPtr->buttons[nRunIndex];
398 if ((btnPtr->fsStyle & TBSTYLE_CHECKGROUP) == TBSTYLE_CHECKGROUP) {
399 if (btnPtr->fsState & TBSTATE_CHECKED)
400 return nRunIndex;
402 else
403 break;
404 nRunIndex++;
407 return -1;
411 static LRESULT
412 TOOLBAR_AddBitmap (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
414 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
415 LPTBADDBITMAP lpAddBmp = (LPTBADDBITMAP)lParam;
416 INT32 nIndex = 0;
418 if ((!lpAddBmp) || ((INT32)wParam <= 0))
419 return -1;
421 TRACE (toolbar, "adding %d bitmaps!\n", wParam);
423 if (!(infoPtr->himlDef)) {
424 /* create new default image list */
425 TRACE (toolbar, "creating default image list!\n");
426 infoPtr->himlDef =
427 ImageList_Create (infoPtr->nBitmapWidth, infoPtr->nBitmapHeight,
428 ILC_COLOR | ILC_MASK, (INT32)wParam, 2);
431 #if 0
432 if (!(infoPtr->himlDis)) {
433 /* create new disabled image list */
434 TRACE (toolbar, "creating disabled image list!\n");
435 infoPtr->himlDis =
436 ImageList_Create (infoPtr->nBitmapWidth,
437 infoPtr->nBitmapHeight, ILC_COLOR | ILC_MASK,
438 (INT32)wParam, 2);
440 #endif
442 /* Add bitmaps to the default image list */
443 if (lpAddBmp->hInst == (HINSTANCE32)0) {
444 nIndex =
445 ImageList_AddMasked (infoPtr->himlDef, (HBITMAP32)lpAddBmp->nID,
446 GetSysColor32 (COLOR_3DFACE));
448 else if (lpAddBmp->hInst == HINST_COMMCTRL) {
449 /* add internal bitmaps */
450 FIXME (toolbar, "internal bitmaps not supported!\n");
452 /* Hack to "add" some reserved images within the image list
453 to get the right image indices */
454 nIndex = ImageList_GetImageCount (infoPtr->himlDef);
455 ImageList_SetImageCount (infoPtr->himlDef, nIndex + (INT32)wParam);
457 else {
458 HBITMAP32 hBmp =
459 LoadBitmap32A (lpAddBmp->hInst, (LPSTR)lpAddBmp->nID);
461 nIndex = ImageList_Add (infoPtr->himlDef, hBmp, (HBITMAP32)0);
463 DeleteObject32 (hBmp);
467 infoPtr->nNumBitmaps += (INT32)wParam;
469 return nIndex;
473 static LRESULT
474 TOOLBAR_AddButtons32A (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
476 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
477 LPTBBUTTON lpTbb = (LPTBBUTTON)lParam;
478 INT32 nOldButtons, nNewButtons, nAddButtons, nCount;
479 HDC32 hdc;
481 TRACE (toolbar, "adding %d buttons!\n", wParam);
483 nAddButtons = (UINT32)wParam;
484 nOldButtons = infoPtr->nNumButtons;
485 nNewButtons = nOldButtons + nAddButtons;
487 if (infoPtr->nNumButtons == 0) {
488 infoPtr->buttons =
489 HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY,
490 sizeof (TBUTTON_INFO) * nNewButtons);
492 else {
493 TBUTTON_INFO *oldButtons = infoPtr->buttons;
494 infoPtr->buttons =
495 HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY,
496 sizeof (TBUTTON_INFO) * nNewButtons);
497 memcpy (&infoPtr->buttons[0], &oldButtons[0],
498 nOldButtons * sizeof(TBUTTON_INFO));
499 HeapFree (GetProcessHeap (), 0, oldButtons);
502 infoPtr->nNumButtons = nNewButtons;
504 /* insert new button data (bad implementation)*/
505 for (nCount = 0; nCount < nAddButtons; nCount++) {
506 infoPtr->buttons[nOldButtons+nCount].iBitmap = lpTbb[nCount].iBitmap;
507 infoPtr->buttons[nOldButtons+nCount].idCommand = lpTbb[nCount].idCommand;
508 infoPtr->buttons[nOldButtons+nCount].fsState = lpTbb[nCount].fsState;
509 infoPtr->buttons[nOldButtons+nCount].fsStyle = lpTbb[nCount].fsStyle;
510 infoPtr->buttons[nOldButtons+nCount].dwData = lpTbb[nCount].dwData;
511 infoPtr->buttons[nOldButtons+nCount].iString = lpTbb[nCount].iString;
514 TOOLBAR_CalcToolbar (wndPtr);
516 hdc = GetDC32 (wndPtr->hwndSelf);
517 TOOLBAR_Refresh (wndPtr, hdc);
518 ReleaseDC32 (wndPtr->hwndSelf, hdc);
520 return TRUE;
524 // << TOOLBAR_AddButtons32W >>
527 static LRESULT
528 TOOLBAR_AddString32A (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
530 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
531 INT32 nIndex;
533 if (wParam) {
534 char szString[256];
535 INT32 len;
536 TRACE (toolbar, "adding string from resource!\n");
538 len = LoadString32A ((HINSTANCE32)wParam, (UINT32)lParam,
539 szString, 256);
541 TRACE (toolbar, "len=%d \"%s\"\n", len, szString);
542 nIndex = infoPtr->nNumStrings;
543 if (infoPtr->nNumStrings == 0) {
544 infoPtr->strings =
545 HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, sizeof(char *));
547 else {
548 char **oldStrings = infoPtr->strings;
549 infoPtr->strings =
550 HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY,
551 sizeof(char *) * (infoPtr->nNumStrings + 1));
552 memcpy (&infoPtr->strings[0], &oldStrings[0],
553 sizeof(char *) * infoPtr->nNumStrings);
554 HeapFree (GetProcessHeap (), 0, oldStrings);
557 infoPtr->strings[infoPtr->nNumStrings] =
558 HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, sizeof(char)*(len+1));
559 lstrcpy32A (infoPtr->strings[infoPtr->nNumStrings], szString);
560 infoPtr->nNumStrings++;
562 else {
563 char *p = (char*)lParam;
564 INT32 len;
566 if (p == NULL) return -1;
567 TRACE (toolbar, "adding string(s) from array!\n");
568 nIndex = infoPtr->nNumStrings;
569 while (*p) {
570 len = lstrlen32A (p);
571 TRACE (toolbar, "len=%d \"%s\"\n", len, p);
573 if (infoPtr->nNumStrings == 0) {
574 infoPtr->strings =
575 HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, sizeof(char *));
577 else {
578 char **oldStrings = infoPtr->strings;
579 infoPtr->strings =
580 HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY,
581 sizeof(char *) * (infoPtr->nNumStrings + 1));
582 memcpy (&infoPtr->strings[0], &oldStrings[0],
583 sizeof(char *) * infoPtr->nNumStrings);
584 HeapFree (GetProcessHeap (), 0, oldStrings);
587 infoPtr->strings[infoPtr->nNumStrings] =
588 HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, sizeof(char)*(len+1));
589 lstrcpy32A (infoPtr->strings[infoPtr->nNumStrings], p);
590 infoPtr->nNumStrings++;
592 p += (len+1);
596 return nIndex;
600 // << TOOLBAR_AddString32W >>
603 static LRESULT
604 TOOLBAR_AutoSize (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
606 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
607 RECT32 parent_rect;
608 HWND32 parent;
609 INT32 x, y, cx, cy;
610 UINT32 uPosFlags = 0;
612 FIXME (toolbar, "auto size!\n");
614 parent = GetParent32 (wndPtr->hwndSelf);
615 GetClientRect32(parent, &parent_rect);
617 if (wndPtr->dwStyle & CCS_NORESIZE)
618 uPosFlags |= SWP_NOSIZE;
619 else {
620 infoPtr->nWidth = parent_rect.right - parent_rect.left;
621 TOOLBAR_CalcToolbar (wndPtr);
622 cy = infoPtr->nHeight;
623 cx = infoPtr->nWidth;
626 if (wndPtr->dwStyle & CCS_NOPARENTALIGN) {
627 uPosFlags |= SWP_NOMOVE;
628 // if (wndPtr->dwStyle & (CCS_TOP | CCS_BOTTOM))
629 // cy = (INT32)HIWORD(lParam);
631 #if 0
632 if (wndPtr->dwStyle & CCS_NORESIZE) {
633 uPosFlags |= SWP_NOSIZE;
634 // cx = (INT32)LOWORD(lParam);
635 // cy = (INT32)HIWORD(lParam);
637 else {
638 /* FIXME: handle CCS_NOMOVEX and CCS_NOMOVEY */
642 infoPtr->nWidth = cx;
643 infoPtr->nHeight = cy;
644 #endif
645 if (!(wndPtr->dwStyle & CCS_NODIVIDER))
646 cy += 2;
648 infoPtr->bAutoSize = TRUE;
649 SetWindowPos32 (wndPtr->hwndSelf, 0, parent_rect.left, parent_rect.top,
650 cx, cy, uPosFlags | SWP_NOZORDER);
652 return 0;
656 static LRESULT
657 TOOLBAR_ButtonCount (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
659 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
661 return infoPtr->nNumButtons;
665 static LRESULT
666 TOOLBAR_ButtonStructSize (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
668 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
670 if (infoPtr == NULL) {
671 ERR (toolbar, "(0x%08lx, 0x%08x, 0x%08lx)\n", (DWORD)wndPtr, wParam, lParam);
672 ERR (toolbar, "infoPtr == NULL!\n");
673 return 0;
676 infoPtr->dwStructSize = (DWORD)wParam;
678 return 0;
682 static LRESULT
683 TOOLBAR_ChangeBitmap (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
685 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
686 TBUTTON_INFO *btnPtr;
687 HDC32 hdc;
688 INT32 nIndex;
690 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT32)wParam);
691 if (nIndex == -1)
692 return FALSE;
694 btnPtr = &infoPtr->buttons[nIndex];
695 btnPtr->iBitmap = LOWORD(lParam);
697 hdc = GetDC32 (wndPtr->hwndSelf);
698 TOOLBAR_DrawButton (wndPtr, btnPtr, hdc);
699 ReleaseDC32 (wndPtr->hwndSelf, hdc);
701 return TRUE;
705 static LRESULT
706 TOOLBAR_CheckButton (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
708 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
709 TBUTTON_INFO *btnPtr;
710 HDC32 hdc;
711 INT32 nIndex;
712 INT32 nOldIndex = -1;
714 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT32)wParam);
715 if (nIndex == -1)
716 return FALSE;
718 btnPtr = &infoPtr->buttons[nIndex];
720 if (!(btnPtr->fsStyle & TBSTYLE_CHECK))
721 return FALSE;
723 if (LOWORD(lParam) == FALSE)
724 btnPtr->fsState &= ~TBSTATE_CHECKED;
725 else {
726 if (btnPtr->fsStyle & TBSTYLE_GROUP) {
727 nOldIndex =
728 TOOLBAR_GetCheckedGroupButtonIndex (infoPtr, nIndex);
729 if (nOldIndex == nIndex)
730 return 0;
731 if (nOldIndex != -1)
732 infoPtr->buttons[nOldIndex].fsState &= ~TBSTATE_CHECKED;
734 btnPtr->fsState |= TBSTATE_CHECKED;
737 hdc = GetDC32 (wndPtr->hwndSelf);
738 if (nOldIndex != -1)
739 TOOLBAR_DrawButton (wndPtr, &infoPtr->buttons[nOldIndex], hdc);
740 TOOLBAR_DrawButton (wndPtr, btnPtr, hdc);
741 ReleaseDC32 (wndPtr->hwndSelf, hdc);
743 /* FIXME: Send a WM_NOTIFY?? */
745 return TRUE;
749 static LRESULT
750 TOOLBAR_CommandToIndex (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
752 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
754 return TOOLBAR_GetButtonIndex (infoPtr, (INT32)wParam);
758 static LRESULT
759 TOOLBAR_Customize (WND *wndPtr)
761 FIXME (toolbar, "customization not implemented!\n");
763 return 0;
767 static LRESULT
768 TOOLBAR_DeleteButton (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
770 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
771 INT32 nIndex = (INT32)wParam;
773 if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons))
774 return FALSE;
776 if (infoPtr->nNumButtons == 1) {
777 TRACE (toolbar, " simple delete!\n");
778 HeapFree (GetProcessHeap (), 0, infoPtr->buttons);
779 infoPtr->buttons = NULL;
780 infoPtr->nNumButtons = 0;
782 else {
783 TBUTTON_INFO *oldButtons = infoPtr->buttons;
784 TRACE(toolbar, "complex delete! [nIndex=%d]\n", nIndex);
786 infoPtr->nNumButtons--;
787 infoPtr->buttons = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY,
788 sizeof (TBUTTON_INFO) * infoPtr->nNumButtons);
789 if (nIndex > 0) {
790 memcpy (&infoPtr->buttons[0], &oldButtons[0],
791 nIndex * sizeof(TBUTTON_INFO));
794 if (nIndex < infoPtr->nNumButtons) {
795 memcpy (&infoPtr->buttons[nIndex], &oldButtons[nIndex+1],
796 (infoPtr->nNumButtons - nIndex) * sizeof(TBUTTON_INFO));
799 HeapFree (GetProcessHeap (), 0, oldButtons);
802 TOOLBAR_CalcToolbar (wndPtr);
804 InvalidateRect32 (wndPtr->hwndSelf, NULL, TRUE);
805 UpdateWindow32 (wndPtr->hwndSelf);
807 return TRUE;
811 static LRESULT
812 TOOLBAR_EnableButton (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
814 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
815 TBUTTON_INFO *btnPtr;
816 HDC32 hdc;
817 INT32 nIndex;
819 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT32)wParam);
820 if (nIndex == -1)
821 return FALSE;
823 btnPtr = &infoPtr->buttons[nIndex];
824 if (LOWORD(lParam) == FALSE)
825 btnPtr->fsState &= ~(TBSTATE_ENABLED | TBSTATE_PRESSED);
826 else
827 btnPtr->fsState |= TBSTATE_ENABLED;
829 hdc = GetDC32 (wndPtr->hwndSelf);
830 TOOLBAR_DrawButton (wndPtr, btnPtr, hdc);
831 ReleaseDC32 (wndPtr->hwndSelf, hdc);
833 return TRUE;
837 // << TOOLBAR_GetAnchorHighlight >>
840 static LRESULT
841 TOOLBAR_GetBitmap (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
843 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
844 INT32 nIndex;
846 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT32)wParam);
847 if (nIndex == -1)
848 return 0;
850 return infoPtr->buttons[nIndex].iBitmap;
854 static LRESULT
855 TOOLBAR_GetBitmapFlags (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
857 FIXME (toolbar, "stub!\n");
858 return 0;
862 static LRESULT
863 TOOLBAR_GetButton (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
865 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
866 LPTBBUTTON lpTbb = (LPTBBUTTON)lParam;
867 INT32 nIndex = (INT32)wParam;
868 TBUTTON_INFO *btnPtr;
870 if (infoPtr == NULL) return FALSE;
871 if (lpTbb == NULL) return FALSE;
873 if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons))
874 return FALSE;
876 btnPtr = &infoPtr->buttons[nIndex];
877 lpTbb->iBitmap = btnPtr->iBitmap;
878 lpTbb->idCommand = btnPtr->idCommand;
879 lpTbb->fsState = btnPtr->fsState;
880 lpTbb->fsStyle = btnPtr->fsStyle;
881 lpTbb->dwData = btnPtr->dwData;
882 lpTbb->iString = btnPtr->iString;
884 return TRUE;
888 // << TOOLBAR_GetButtonInfo >>
891 static LRESULT
892 TOOLBAR_GetButtonSize (WND *wndPtr)
894 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
896 return MAKELONG((WORD)infoPtr->nButtonWidth,
897 (WORD)infoPtr->nButtonHeight);
901 static LRESULT
902 TOOLBAR_GetButtonText32A (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
904 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
905 INT32 nIndex, nStringIndex;
907 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT32)wParam);
908 if (nIndex == -1)
909 return -1;
911 nStringIndex = infoPtr->buttons[nIndex].iString;
913 TRACE (toolbar, "index=%d stringIndex=%d\n", nIndex, nStringIndex);
915 if ((nStringIndex < 0) || (nStringIndex >= infoPtr->nNumStrings))
916 return -1;
918 if (lParam == 0) return -1;
920 lstrcpy32A ((LPSTR)lParam, (LPSTR)infoPtr->strings[nStringIndex]);
922 return lstrlen32A ((LPSTR)infoPtr->strings[nStringIndex]);
926 // << TOOLBAR_GetButtonText32W >>
927 // << TOOLBAR_GetColorScheme >>
928 // << TOOLBAR_GetDisabledImageList >>
929 // << TOOLBAR_GetExtendedStyle >>
930 // << TOOLBAR_GetHotImageList >>
931 // << TOOLBAR_GetHotItem >>
934 static LRESULT
935 TOOLBAR_GetImageList (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
937 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
938 return (LRESULT)infoPtr->himlDef;
942 // << TOOLBAR_GetInsertMark >>
943 // << TOOLBAR_GetInsertMarkColor >>
946 static LRESULT
947 TOOLBAR_GetItemRect (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
949 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
950 TBUTTON_INFO *btnPtr;
951 LPRECT32 lpRect;
952 INT32 nIndex;
954 if (infoPtr == NULL) return FALSE;
955 nIndex = (INT32)wParam;
956 btnPtr = &infoPtr->buttons[nIndex];
957 if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons))
958 return FALSE;
959 lpRect = (LPRECT32)lParam;
960 if (lpRect == NULL) return FALSE;
961 if (btnPtr->fsState & TBSTATE_HIDDEN) return FALSE;
963 lpRect->left = btnPtr->rect.left;
964 lpRect->right = btnPtr->rect.right;
965 lpRect->bottom = btnPtr->rect.bottom;
966 lpRect->top = btnPtr->rect.top;
968 return TRUE;
972 // << TOOLBAR_GetMaxSize >>
973 // << TOOLBAR_GetObject >>
974 // << TOOLBAR_GetPadding >>
975 // << TOOLBAR_GetRect >>
978 static LRESULT
979 TOOLBAR_GetRows (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
981 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
983 if (wndPtr->dwStyle & TBSTYLE_WRAPABLE)
984 return infoPtr->nMaxRows;
985 else
986 return 1;
990 static LRESULT
991 TOOLBAR_GetState (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
993 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
994 INT32 nIndex;
996 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT32)wParam);
997 if (nIndex == -1) return -1;
999 return infoPtr->buttons[nIndex].fsState;
1003 static LRESULT
1004 TOOLBAR_GetStyle (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
1006 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
1007 INT32 nIndex;
1009 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT32)wParam);
1010 if (nIndex == -1) return -1;
1012 return infoPtr->buttons[nIndex].fsStyle;
1016 // << TOOLBAR_GetTextRows >>
1019 static LRESULT
1020 TOOLBAR_GetToolTips (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
1022 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
1024 if (infoPtr == NULL) return 0;
1025 return infoPtr->hwndToolTip;
1029 // << TOOLBAR_GetUnicodeFormat >>
1032 static LRESULT
1033 TOOLBAR_HideButton (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
1035 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
1036 TBUTTON_INFO *btnPtr;
1037 INT32 nIndex;
1039 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT32)wParam);
1040 if (nIndex == -1)
1041 return FALSE;
1043 btnPtr = &infoPtr->buttons[nIndex];
1044 if (LOWORD(lParam) == FALSE)
1045 btnPtr->fsState &= ~TBSTATE_HIDDEN;
1046 else
1047 btnPtr->fsState |= TBSTATE_HIDDEN;
1049 TOOLBAR_CalcToolbar (wndPtr);
1051 InvalidateRect32 (wndPtr->hwndSelf, NULL, TRUE);
1052 UpdateWindow32 (wndPtr->hwndSelf);
1054 return TRUE;
1058 static LRESULT
1059 TOOLBAR_HitTest (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
1061 return TOOLBAR_InternalHitTest (wndPtr, (LPPOINT32)lParam);
1065 static LRESULT
1066 TOOLBAR_Indeterminate (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
1068 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
1069 TBUTTON_INFO *btnPtr;
1070 HDC32 hdc;
1071 INT32 nIndex;
1073 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT32)wParam);
1074 if (nIndex == -1)
1075 return FALSE;
1077 btnPtr = &infoPtr->buttons[nIndex];
1078 if (LOWORD(lParam) == FALSE)
1079 btnPtr->fsState &= ~TBSTATE_INDETERMINATE;
1080 else
1081 btnPtr->fsState |= TBSTATE_INDETERMINATE;
1083 hdc = GetDC32 (wndPtr->hwndSelf);
1084 TOOLBAR_DrawButton (wndPtr, btnPtr, hdc);
1085 ReleaseDC32 (wndPtr->hwndSelf, hdc);
1087 return TRUE;
1091 static LRESULT
1092 TOOLBAR_InsertButton32A (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
1094 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
1095 LPTBBUTTON lpTbb = (LPTBBUTTON)lParam;
1096 INT32 nIndex = (INT32)wParam;
1097 TBUTTON_INFO *oldButtons;
1098 HDC32 hdc;
1100 if (lpTbb == NULL) return FALSE;
1101 if (nIndex < 0) return FALSE;
1103 TRACE (toolbar, "inserting button index=%d\n", nIndex);
1104 if (nIndex > infoPtr->nNumButtons) {
1105 nIndex = infoPtr->nNumButtons;
1106 TRACE (toolbar, "adjust index=%d\n", nIndex);
1109 oldButtons = infoPtr->buttons;
1110 infoPtr->nNumButtons++;
1111 infoPtr->buttons = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY,
1112 sizeof (TBUTTON_INFO) * infoPtr->nNumButtons);
1113 /* pre insert copy */
1114 if (nIndex > 0) {
1115 memcpy (&infoPtr->buttons[0], &oldButtons[0],
1116 nIndex * sizeof(TBUTTON_INFO));
1119 /* insert new button */
1120 infoPtr->buttons[nIndex].iBitmap = lpTbb->iBitmap;
1121 infoPtr->buttons[nIndex].idCommand = lpTbb->idCommand;
1122 infoPtr->buttons[nIndex].fsState = lpTbb->fsState;
1123 infoPtr->buttons[nIndex].fsStyle = lpTbb->fsStyle;
1124 infoPtr->buttons[nIndex].dwData = lpTbb->dwData;
1125 infoPtr->buttons[nIndex].iString = lpTbb->iString;
1127 /* post insert copy */
1128 if (nIndex < infoPtr->nNumButtons - 1) {
1129 memcpy (&infoPtr->buttons[nIndex+1], &oldButtons[nIndex],
1130 (infoPtr->nNumButtons - nIndex - 1) * sizeof(TBUTTON_INFO));
1133 HeapFree (GetProcessHeap (), 0, oldButtons);
1135 TOOLBAR_CalcToolbar (wndPtr);
1137 hdc = GetDC32 (wndPtr->hwndSelf);
1138 TOOLBAR_Refresh (wndPtr, hdc);
1139 ReleaseDC32 (wndPtr->hwndSelf, hdc);
1141 return TRUE;
1145 // << TOOLBAR_InsertButton32W >>
1146 // << TOOLBAR_InsertMarkHitTest >>
1149 static LRESULT
1150 TOOLBAR_IsButtonChecked (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
1152 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
1153 INT32 nIndex;
1155 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT32)wParam);
1156 if (nIndex == -1)
1157 return FALSE;
1159 return (infoPtr->buttons[nIndex].fsState & TBSTATE_CHECKED);
1163 static LRESULT
1164 TOOLBAR_IsButtonEnabled (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
1166 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
1167 INT32 nIndex;
1169 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT32)wParam);
1170 if (nIndex == -1)
1171 return FALSE;
1173 return (infoPtr->buttons[nIndex].fsState & TBSTATE_ENABLED);
1177 static LRESULT
1178 TOOLBAR_IsButtonHidden (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
1180 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
1181 INT32 nIndex;
1183 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT32)wParam);
1184 if (nIndex == -1)
1185 return FALSE;
1187 return (infoPtr->buttons[nIndex].fsState & TBSTATE_HIDDEN);
1191 static LRESULT
1192 TOOLBAR_IsButtonHighlighted (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
1194 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
1195 INT32 nIndex;
1197 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT32)wParam);
1198 if (nIndex == -1)
1199 return FALSE;
1201 return (infoPtr->buttons[nIndex].fsState & TBSTATE_MARKED);
1205 static LRESULT
1206 TOOLBAR_IsButtonIndeterminate (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
1208 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
1209 INT32 nIndex;
1211 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT32)wParam);
1212 if (nIndex == -1)
1213 return FALSE;
1215 return (infoPtr->buttons[nIndex].fsState & TBSTATE_INDETERMINATE);
1219 static LRESULT
1220 TOOLBAR_IsButtonPressed (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
1222 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
1223 INT32 nIndex;
1225 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT32)wParam);
1226 if (nIndex == -1)
1227 return FALSE;
1229 return (infoPtr->buttons[nIndex].fsState & TBSTATE_PRESSED);
1233 // << TOOLBAR_LoadImages >>
1234 // << TOOLBAR_MapAccelerator >>
1235 // << TOOLBAR_MarkButton >>
1236 // << TOOLBAR_MoveButton >>
1239 static LRESULT
1240 TOOLBAR_PressButton (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
1242 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
1243 TBUTTON_INFO *btnPtr;
1244 HDC32 hdc;
1245 INT32 nIndex;
1247 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT32)wParam);
1248 if (nIndex == -1)
1249 return FALSE;
1251 btnPtr = &infoPtr->buttons[nIndex];
1252 if (LOWORD(lParam) == FALSE)
1253 btnPtr->fsState &= ~TBSTATE_PRESSED;
1254 else
1255 btnPtr->fsState |= TBSTATE_PRESSED;
1257 hdc = GetDC32 (wndPtr->hwndSelf);
1258 TOOLBAR_DrawButton (wndPtr, btnPtr, hdc);
1259 ReleaseDC32 (wndPtr->hwndSelf, hdc);
1261 return TRUE;
1265 // << TOOLBAR_ReplaceBitmap >>
1268 static LRESULT
1269 TOOLBAR_SaveRestore32A (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
1271 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
1272 LPTBSAVEPARAMS32A lpSave = (LPTBSAVEPARAMS32A)lParam;
1274 if (lpSave == NULL) return 0;
1276 if ((BOOL32)wParam) {
1277 /* save toolbar information */
1278 FIXME (toolbar, "save to \"%s\" \"%s\"\n",
1279 lpSave->pszSubKey, lpSave->pszValueName);
1283 else {
1284 /* restore toolbar information */
1286 FIXME (toolbar, "restore from \"%s\" \"%s\"\n",
1287 lpSave->pszSubKey, lpSave->pszValueName);
1292 return 0;
1296 // << TOOLBAR_SaveRestore32W >>
1297 // << TOOLBAR_SetAnchorHighlight >>
1300 static LRESULT
1301 TOOLBAR_SetBitmapSize (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
1303 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
1305 if ((LOWORD(lParam) <= 0) || (HIWORD(lParam)<=0))
1306 return FALSE;
1308 infoPtr->nBitmapWidth = (INT32)LOWORD(lParam);
1309 infoPtr->nBitmapHeight = (INT32)HIWORD(lParam);
1311 return TRUE;
1315 // << TOOLBAR_SetButtonInfo >>
1318 static LRESULT
1319 TOOLBAR_SetButtonSize (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
1321 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
1323 if ((LOWORD(lParam) <= 0) || (HIWORD(lParam)<=0))
1324 return FALSE;
1326 infoPtr->nButtonWidth = (INT32)LOWORD(lParam);
1327 infoPtr->nButtonHeight = (INT32)HIWORD(lParam);
1329 return TRUE;
1333 // << TOOLBAR_SetButtonWidth >>
1336 static LRESULT
1337 TOOLBAR_SetCmdId (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
1339 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
1340 INT32 nIndex = (INT32)wParam;
1342 if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons))
1343 return FALSE;
1345 infoPtr->buttons[nIndex].idCommand = (INT32)lParam;
1347 return TRUE;
1351 // << TOOLBAR_SetColorScheme >>
1352 // << TOOLBAR_SetDisabledImageList >>
1353 // << TOOLBAR_SetDrawTextFlags >>
1354 // << TOOLBAR_SetExtendedStyle >>
1355 // << TOOLBAR_SetHotImageList >>
1356 // << TOOLBAR_SetHotItem >>
1359 static LRESULT
1360 TOOLBAR_SetImageList (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
1362 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
1363 HIMAGELIST himlTemp;
1365 himlTemp = infoPtr->himlDef;
1366 infoPtr->himlDef = (HIMAGELIST)lParam;
1368 /* FIXME: redraw ? */
1370 return (LRESULT)himlTemp;
1374 static LRESULT
1375 TOOLBAR_SetIndent (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
1377 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
1378 HDC32 hdc;
1380 infoPtr->nIndent = (INT32)wParam;
1381 TOOLBAR_CalcToolbar (wndPtr);
1382 hdc = GetDC32 (wndPtr->hwndSelf);
1383 TOOLBAR_Refresh (wndPtr, hdc);
1384 ReleaseDC32 (wndPtr->hwndSelf, hdc);
1386 return TRUE;
1390 // << TOOLBAR_SetInsertMark >>
1393 static LRESULT
1394 TOOLBAR_SetInsertMarkColor (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
1396 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
1398 infoPtr->clrInsertMark = (COLORREF)lParam;
1400 /* FIXME : redraw ??*/
1402 return 0;
1406 // << TOOLBAR_SetMaxTextRows >>
1407 // << TOOLBAR_SetPadding >>
1410 static LRESULT
1411 TOOLBAR_SetParent (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
1413 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
1414 HWND32 hwndOldNotify;
1416 if (infoPtr == NULL) return 0;
1417 hwndOldNotify = infoPtr->hwndNotify;
1418 infoPtr->hwndNotify = (HWND32)wParam;
1420 return hwndOldNotify;
1424 static LRESULT
1425 TOOLBAR_SetRows (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
1427 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
1429 FIXME (toolbar, "support multiple rows!\n");
1431 return 0;
1435 static LRESULT
1436 TOOLBAR_SetState (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
1438 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
1439 TBUTTON_INFO *btnPtr;
1440 HDC32 hdc;
1441 INT32 nIndex;
1443 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT32)wParam);
1444 if (nIndex == -1)
1445 return FALSE;
1447 btnPtr = &infoPtr->buttons[nIndex];
1448 btnPtr->fsState = LOWORD(lParam);
1450 hdc = GetDC32 (wndPtr->hwndSelf);
1451 TOOLBAR_DrawButton (wndPtr, btnPtr, hdc);
1452 ReleaseDC32 (wndPtr->hwndSelf, hdc);
1454 return TRUE;
1458 static LRESULT
1459 TOOLBAR_SetStyle (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
1461 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
1462 TBUTTON_INFO *btnPtr;
1463 HDC32 hdc;
1464 INT32 nIndex;
1466 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT32)wParam);
1467 if (nIndex == -1)
1468 return FALSE;
1470 btnPtr = &infoPtr->buttons[nIndex];
1471 btnPtr->fsStyle = LOWORD(lParam);
1473 hdc = GetDC32 (wndPtr->hwndSelf);
1474 TOOLBAR_DrawButton (wndPtr, btnPtr, hdc);
1475 ReleaseDC32 (wndPtr->hwndSelf, hdc);
1477 return TRUE;
1481 static LRESULT
1482 TOOLBAR_SetToolTips (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
1484 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
1486 if (infoPtr == NULL) return 0;
1487 infoPtr->hwndToolTip = (HWND32)wParam;
1488 return 0;
1492 static LRESULT
1493 TOOLBAR_SetUnicodeFormat (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
1495 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
1497 FIXME (toolbar, "hwnd=0x%04x stub!\n", wndPtr->hwndSelf);
1499 return 0;
1503 static LRESULT
1504 TOOLBAR_Create (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
1506 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
1507 LOGFONT32A logFont;
1509 /* initialize info structure */
1510 infoPtr->nButtonHeight = 22;
1511 infoPtr->nButtonWidth = 23;
1512 infoPtr->nBitmapHeight = 15;
1513 infoPtr->nBitmapWidth = 16;
1515 infoPtr->nHeight = infoPtr->nButtonHeight + TOP_BORDER + BOTTOM_BORDER;
1516 infoPtr->nMaxRows = 1;
1518 infoPtr->bCaptured = 0;
1519 infoPtr->nButtonDown = -1;
1520 infoPtr->nOldHit = -1;
1522 infoPtr->hwndNotify = GetParent32 (wndPtr->hwndSelf);
1523 infoPtr->bTransparent = (wndPtr->dwStyle & TBSTYLE_FLAT);
1524 infoPtr->nHotItem = -1;
1526 SystemParametersInfo32A (SPI_GETICONTITLELOGFONT, 0, &logFont, 0);
1527 infoPtr->hFont = CreateFontIndirect32A (&logFont);
1529 return 0;
1533 static LRESULT
1534 TOOLBAR_Destroy (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
1536 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
1538 /* delete tool tip */
1539 if (infoPtr->hwndToolTip)
1540 DestroyWindow32 (infoPtr->hwndToolTip);
1542 /* delete button data */
1543 if (infoPtr->buttons)
1544 HeapFree (GetProcessHeap (), 0, infoPtr->buttons);
1546 /* delete strings */
1547 if (infoPtr->strings) {
1548 INT32 i;
1549 for (i = 0; i < infoPtr->nNumStrings; i++)
1550 if (infoPtr->strings[i])
1551 HeapFree (GetProcessHeap (), 0, infoPtr->strings[i]);
1553 HeapFree (GetProcessHeap (), 0, infoPtr->strings);
1556 /* destroy default image list */
1557 if (infoPtr->himlDef)
1558 ImageList_Destroy (infoPtr->himlDef);
1560 /* destroy disabled image list */
1561 if (infoPtr->himlDis)
1562 ImageList_Destroy (infoPtr->himlDis);
1564 /* destroy hot image list */
1565 if (infoPtr->himlHot)
1566 ImageList_Destroy (infoPtr->himlHot);
1568 /* delete default font */
1569 if (infoPtr->hFont)
1570 DeleteObject32 (infoPtr->hFont);
1572 /* free toolbar info data */
1573 HeapFree (GetProcessHeap (), 0, infoPtr);
1575 return 0;
1579 static LRESULT
1580 TOOLBAR_EraseBackground (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
1582 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
1584 if (infoPtr->bTransparent)
1585 return SendMessage32A (GetParent32 (wndPtr->hwndSelf), WM_ERASEBKGND,
1586 wParam, lParam);
1588 return DefWindowProc32A (wndPtr->hwndSelf, WM_ERASEBKGND, wParam, lParam);
1592 static LRESULT
1593 TOOLBAR_LButtonDblClk (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
1595 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
1596 TBUTTON_INFO *btnPtr;
1597 POINT32 pt;
1598 INT32 nHit;
1599 HDC32 hdc;
1601 pt.x = (INT32)LOWORD(lParam);
1602 pt.y = (INT32)HIWORD(lParam);
1603 nHit = TOOLBAR_InternalHitTest (wndPtr, &pt);
1605 if (nHit >= 0) {
1606 btnPtr = &infoPtr->buttons[nHit];
1607 if (!(btnPtr->fsState & TBSTATE_ENABLED))
1608 return 0;
1609 SetCapture32 (wndPtr->hwndSelf);
1610 infoPtr->bCaptured = TRUE;
1611 infoPtr->nButtonDown = nHit;
1613 btnPtr->fsState |= TBSTATE_PRESSED;
1615 hdc = GetDC32 (wndPtr->hwndSelf);
1616 TOOLBAR_DrawButton (wndPtr, btnPtr, hdc);
1617 ReleaseDC32 (wndPtr->hwndSelf, hdc);
1619 else if (wndPtr->dwStyle & CCS_ADJUSTABLE)
1620 TOOLBAR_Customize (wndPtr);
1622 return 0;
1626 static LRESULT
1627 TOOLBAR_LButtonDown (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
1629 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
1630 TBUTTON_INFO *btnPtr;
1631 POINT32 pt;
1632 INT32 nHit;
1633 HDC32 hdc;
1635 pt.x = (INT32)LOWORD(lParam);
1636 pt.y = (INT32)HIWORD(lParam);
1637 nHit = TOOLBAR_InternalHitTest (wndPtr, &pt);
1639 if (nHit >= 0) {
1640 btnPtr = &infoPtr->buttons[nHit];
1641 if (!(btnPtr->fsState & TBSTATE_ENABLED))
1642 return 0;
1644 SetCapture32 (wndPtr->hwndSelf);
1645 infoPtr->bCaptured = TRUE;
1646 infoPtr->nButtonDown = nHit;
1647 infoPtr->nOldHit = nHit;
1649 btnPtr->fsState |= TBSTATE_PRESSED;
1651 hdc = GetDC32 (wndPtr->hwndSelf);
1652 TOOLBAR_DrawButton (wndPtr, btnPtr, hdc);
1653 ReleaseDC32 (wndPtr->hwndSelf, hdc);
1657 return 0;
1661 static LRESULT
1662 TOOLBAR_LButtonUp (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
1664 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
1665 TBUTTON_INFO *btnPtr;
1666 POINT32 pt;
1667 INT32 nHit;
1668 INT32 nOldIndex = -1;
1669 HDC32 hdc;
1670 BOOL32 bSendMessage = TRUE;
1672 pt.x = (INT32)LOWORD(lParam);
1673 pt.y = (INT32)HIWORD(lParam);
1674 nHit = TOOLBAR_InternalHitTest (wndPtr, &pt);
1676 if ((infoPtr->bCaptured) && (infoPtr->nButtonDown >= 0)) {
1677 infoPtr->bCaptured = FALSE;
1678 ReleaseCapture ();
1679 btnPtr = &infoPtr->buttons[infoPtr->nButtonDown];
1680 btnPtr->fsState &= ~TBSTATE_PRESSED;
1682 if (nHit == infoPtr->nButtonDown) {
1683 if (btnPtr->fsStyle & TBSTYLE_CHECK) {
1684 if (btnPtr->fsStyle & TBSTYLE_GROUP) {
1685 nOldIndex = TOOLBAR_GetCheckedGroupButtonIndex (infoPtr,
1686 infoPtr->nButtonDown);
1687 if (nOldIndex == infoPtr->nButtonDown)
1688 bSendMessage = FALSE;
1689 if ((nOldIndex != infoPtr->nButtonDown) &&
1690 (nOldIndex != -1))
1691 infoPtr->buttons[nOldIndex].fsState &= ~TBSTATE_CHECKED;
1692 btnPtr->fsState |= TBSTATE_CHECKED;
1694 else {
1695 if (btnPtr->fsState & TBSTATE_CHECKED)
1696 btnPtr->fsState &= ~TBSTATE_CHECKED;
1697 else
1698 btnPtr->fsState |= TBSTATE_CHECKED;
1702 else
1703 bSendMessage = FALSE;
1705 hdc = GetDC32 (wndPtr->hwndSelf);
1706 if (nOldIndex != -1)
1707 TOOLBAR_DrawButton (wndPtr, &infoPtr->buttons[nOldIndex], hdc);
1708 TOOLBAR_DrawButton (wndPtr, btnPtr, hdc);
1709 ReleaseDC32 (wndPtr->hwndSelf, hdc);
1711 if (bSendMessage)
1712 SendMessage32A (infoPtr->hwndNotify, WM_COMMAND,
1713 MAKEWPARAM(btnPtr->idCommand, 0),
1714 (LPARAM)wndPtr->hwndSelf);
1716 infoPtr->nButtonDown = -1;
1717 infoPtr->nOldHit = -1;
1720 return 0;
1724 static LRESULT
1725 TOOLBAR_MouseMove (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
1727 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
1728 TBUTTON_INFO *btnPtr;
1729 POINT32 pt;
1730 INT32 nHit;
1731 HDC32 hdc;
1733 pt.x = (INT32)LOWORD(lParam);
1734 pt.y = (INT32)HIWORD(lParam);
1735 nHit = TOOLBAR_InternalHitTest (wndPtr, &pt);
1737 if (infoPtr->bCaptured) {
1738 if (infoPtr->nOldHit != nHit) {
1739 btnPtr = &infoPtr->buttons[infoPtr->nButtonDown];
1740 if (infoPtr->nOldHit == infoPtr->nButtonDown) {
1741 btnPtr->fsState &= ~TBSTATE_PRESSED;
1742 hdc = GetDC32 (wndPtr->hwndSelf);
1743 TOOLBAR_DrawButton (wndPtr, btnPtr, hdc);
1744 ReleaseDC32 (wndPtr->hwndSelf, hdc);
1746 else if (nHit == infoPtr->nButtonDown) {
1747 btnPtr->fsState |= TBSTATE_PRESSED;
1748 hdc = GetDC32 (wndPtr->hwndSelf);
1749 TOOLBAR_DrawButton (wndPtr, btnPtr, hdc);
1750 ReleaseDC32 (wndPtr->hwndSelf, hdc);
1753 infoPtr->nOldHit = nHit;
1756 return 0;
1763 static LRESULT
1764 TOOLBAR_NCCalcSize (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
1766 if (!(wndPtr->dwStyle & CCS_NODIVIDER)) {
1767 LPRECT32 winRect = (LPRECT32)lParam;
1768 winRect->top += 2;
1769 winRect->bottom += 2;
1772 return DefWindowProc32A (wndPtr->hwndSelf, WM_NCCALCSIZE, wParam, lParam);
1776 static LRESULT
1777 TOOLBAR_NCCreate (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
1779 TOOLBAR_INFO *infoPtr;
1781 /* allocate memory for info structure */
1782 infoPtr = (TOOLBAR_INFO *)HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY,
1783 sizeof(TOOLBAR_INFO));
1784 wndPtr->wExtra[0] = (DWORD)infoPtr;
1786 if (infoPtr == NULL) {
1787 ERR (toolbar, "could not allocate info memory!\n");
1788 return 0;
1791 if ((TOOLBAR_INFO*)wndPtr->wExtra[0] != infoPtr) {
1792 ERR (toolbar, "pointer assignment error!\n");
1793 return 0;
1796 /* this is just for security (reliable??)*/
1797 infoPtr->dwStructSize = sizeof(TBBUTTON);
1799 return DefWindowProc32A (wndPtr->hwndSelf, WM_NCCREATE, wParam, lParam);
1803 static LRESULT
1804 TOOLBAR_NCPaint (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
1806 HDC32 hdc;
1807 RECT32 rect;
1808 HWND32 hwnd = wndPtr->hwndSelf;
1810 if ( wndPtr->dwStyle & WS_MINIMIZE ||
1811 !WIN_IsWindowDrawable( wndPtr, 0 )) return 0; /* Nothing to do */
1813 DefWindowProc32A (hwnd, WM_NCPAINT, wParam, lParam);
1815 if (!(hdc = GetDCEx32( hwnd, 0, DCX_USESTYLE | DCX_WINDOW ))) return 0;
1817 if (ExcludeVisRect( hdc, wndPtr->rectClient.left-wndPtr->rectWindow.left,
1818 wndPtr->rectClient.top-wndPtr->rectWindow.top,
1819 wndPtr->rectClient.right-wndPtr->rectWindow.left,
1820 wndPtr->rectClient.bottom-wndPtr->rectWindow.top )
1821 == NULLREGION)
1823 ReleaseDC32( hwnd, hdc );
1824 return 0;
1827 if (!(wndPtr->flags & WIN_MANAGED)) {
1828 if (!(wndPtr->dwStyle & CCS_NODIVIDER)) {
1829 rect.left = wndPtr->rectClient.left;
1830 rect.top = wndPtr->rectClient.top - 2;
1831 rect.right = wndPtr->rectClient.right;
1833 SelectObject32 ( hdc, GetSysColorPen32 (COLOR_3DSHADOW));
1834 MoveToEx32 (hdc, rect.left, rect.top, NULL);
1835 LineTo32 (hdc, rect.right, rect.top);
1836 rect.top++;
1837 SelectObject32 ( hdc, GetSysColorPen32 (COLOR_3DHILIGHT));
1838 MoveToEx32 (hdc, rect.left, rect.top, NULL);
1839 LineTo32 (hdc, rect.right, rect.top);
1844 ReleaseDC32( hwnd, hdc );
1846 return 0;
1850 static LRESULT
1851 TOOLBAR_Paint (WND *wndPtr, WPARAM32 wParam)
1853 HDC32 hdc;
1854 PAINTSTRUCT32 ps;
1856 hdc = wParam==0 ? BeginPaint32 (wndPtr->hwndSelf, &ps) : (HDC32)wParam;
1857 TOOLBAR_Refresh (wndPtr, hdc);
1858 if (!wParam)
1859 EndPaint32 (wndPtr->hwndSelf, &ps);
1860 return 0;
1864 static LRESULT
1865 TOOLBAR_Size (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
1867 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
1868 RECT32 parent_rect;
1869 HWND32 parent;
1870 INT32 x, y, cx, cy;
1871 INT32 flags;
1872 UINT32 uPosFlags = 0;
1874 if (infoPtr->bAutoSize) {
1875 infoPtr->bAutoSize = FALSE;
1876 return 0;
1879 flags = (INT32) wParam;
1881 /* FIXME for flags =
1882 * SIZE_MAXIMIZED, SIZE_MAXSHOW, SIZE_MINIMIZED
1885 TRACE (toolbar, "sizing toolbar!\n");
1887 if (flags == SIZE_RESTORED) {
1888 /* width and height don't apply */
1889 parent = GetParent32 (wndPtr->hwndSelf);
1890 GetClientRect32(parent, &parent_rect);
1892 if (wndPtr->dwStyle & CCS_NORESIZE)
1893 uPosFlags |= SWP_NOSIZE;
1894 else {
1895 infoPtr->nWidth = parent_rect.right - parent_rect.left;
1896 TOOLBAR_CalcToolbar (wndPtr);
1897 cy = infoPtr->nHeight;
1898 cx = infoPtr->nWidth;
1901 if (wndPtr->dwStyle & CCS_NOPARENTALIGN) {
1902 uPosFlags |= SWP_NOMOVE;
1903 // if (wndPtr->dwStyle & (CCS_TOP | CCS_BOTTOM))
1904 // cy = (INT32)HIWORD(lParam);
1906 #if 0
1907 if (wndPtr->dwStyle & CCS_NORESIZE) {
1908 uPosFlags |= SWP_NOSIZE;
1909 // cx = (INT32)LOWORD(lParam);
1910 // cy = (INT32)HIWORD(lParam);
1912 else {
1913 /* FIXME: handle CCS_NOMOVEX and CCS_NOMOVEY */
1917 infoPtr->nWidth = cx;
1918 infoPtr->nHeight = cy;
1919 #endif
1920 if (!(wndPtr->dwStyle & CCS_NODIVIDER))
1921 cy += 2;
1923 SetWindowPos32 (wndPtr->hwndSelf, 0, parent_rect.left, parent_rect.top,
1924 cx, cy, uPosFlags | SWP_NOZORDER);
1926 return 0;
1935 LRESULT WINAPI
1936 ToolbarWindowProc (HWND32 hwnd, UINT32 uMsg, WPARAM32 wParam, LPARAM lParam)
1938 WND *wndPtr = WIN_FindWndPtr(hwnd);
1940 switch (uMsg)
1942 case TB_ADDBITMAP:
1943 return TOOLBAR_AddBitmap (wndPtr, wParam, lParam);
1945 case TB_ADDBUTTONS32A:
1946 return TOOLBAR_AddButtons32A (wndPtr, wParam, lParam);
1948 // case TB_ADDBUTTONS32W:
1950 case TB_ADDSTRING32A:
1951 return TOOLBAR_AddString32A (wndPtr, wParam, lParam);
1953 // case TB_ADDSTRING32W:
1955 case TB_AUTOSIZE:
1956 return TOOLBAR_AutoSize (wndPtr, wParam, lParam);
1958 case TB_BUTTONCOUNT:
1959 return TOOLBAR_ButtonCount (wndPtr, wParam, lParam);
1961 case TB_BUTTONSTRUCTSIZE:
1962 return TOOLBAR_ButtonStructSize (wndPtr, wParam, lParam);
1964 case TB_CHANGEBITMAP:
1965 return TOOLBAR_ChangeBitmap (wndPtr, wParam, lParam);
1967 case TB_CHECKBUTTON:
1968 return TOOLBAR_CheckButton (wndPtr, wParam, lParam);
1970 case TB_COMMANDTOINDEX:
1971 return TOOLBAR_CommandToIndex (wndPtr, wParam, lParam);
1973 case TB_CUSTOMIZE:
1974 return TOOLBAR_Customize (wndPtr);
1976 case TB_DELETEBUTTON:
1977 return TOOLBAR_DeleteButton (wndPtr, wParam, lParam);
1979 case TB_ENABLEBUTTON:
1980 return TOOLBAR_EnableButton (wndPtr, wParam, lParam);
1982 // case TB_GETANCHORHIGHLIGHT: /* 4.71 */
1984 case TB_GETBITMAP:
1985 return TOOLBAR_GetBitmap (wndPtr, wParam, lParam);
1987 case TB_GETBITMAPFLAGS:
1988 return TOOLBAR_GetBitmapFlags (wndPtr, wParam, lParam);
1990 case TB_GETBUTTON:
1991 return TOOLBAR_GetButton (wndPtr, wParam, lParam);
1993 // case TB_GETBUTTONINFO: /* 4.71 */
1995 case TB_GETBUTTONSIZE:
1996 return TOOLBAR_GetButtonSize (wndPtr);
1998 case TB_GETBUTTONTEXT32A:
1999 return TOOLBAR_GetButtonText32A (wndPtr, wParam, lParam);
2001 // case TB_GETBUTTONTEXT32W:
2002 // case TB_GETCOLORSCHEME: /* 4.71 */
2003 // case TB_GETDISABLEDIMAGELIST: /* 4.70 */
2004 // case TB_GETEXTENDEDSTYLE: /* 4.71 */
2005 // case TB_GETHOTIMAGELIST: /* 4.70 */
2006 // case TB_GETHOTITEM: /* 4.71 */
2008 case TB_GETIMAGELIST:
2009 return TOOLBAR_GetImageList (wndPtr, wParam, lParam);
2011 // case TB_GETINSERTMARK: /* 4.71 */
2012 // case TB_GETINSERTMARKCOLOR: /* 4.71 */
2014 case TB_GETITEMRECT:
2015 return TOOLBAR_GetItemRect (wndPtr, wParam, lParam);
2017 // case TB_GETMAXSIZE: /* 4.71 */
2018 // case TB_GETOBJECT: /* 4.71 */
2019 // case TB_GETPADDING: /* 4.71 */
2020 // case TB_GETRECT: /* 4.70 */
2022 case TB_GETROWS:
2023 return TOOLBAR_GetRows (wndPtr, wParam, lParam);
2025 case TB_GETSTATE:
2026 return TOOLBAR_GetState (wndPtr, wParam, lParam);
2028 case TB_GETSTYLE:
2029 return TOOLBAR_GetStyle (wndPtr, wParam, lParam);
2031 // case TB_GETTEXTROWS: /* 4.70 */
2033 case TB_GETTOOLTIPS:
2034 return TOOLBAR_GetToolTips (wndPtr, wParam, lParam);
2036 // case TB_GETUNICODEFORMAT:
2038 case TB_HIDEBUTTON:
2039 return TOOLBAR_HideButton (wndPtr, wParam, lParam);
2041 case TB_HITTEST:
2042 return TOOLBAR_HitTest (wndPtr, wParam, lParam);
2044 case TB_INDETERMINATE:
2045 return TOOLBAR_Indeterminate (wndPtr, wParam, lParam);
2047 case TB_INSERTBUTTON32A:
2048 return TOOLBAR_InsertButton32A (wndPtr, wParam, lParam);
2050 // case TB_INSERTBUTTON32W:
2051 // case TB_INSERTMARKHITTEST: /* 4.71 */
2053 case TB_ISBUTTONCHECKED:
2054 return TOOLBAR_IsButtonChecked (wndPtr, wParam, lParam);
2056 case TB_ISBUTTONENABLED:
2057 return TOOLBAR_IsButtonEnabled (wndPtr, wParam, lParam);
2059 case TB_ISBUTTONHIDDEN:
2060 return TOOLBAR_IsButtonHidden (wndPtr, wParam, lParam);
2062 case TB_ISBUTTONHIGHLIGHTED:
2063 return TOOLBAR_IsButtonHighlighted (wndPtr, wParam, lParam);
2065 case TB_ISBUTTONINDETERMINATE:
2066 return TOOLBAR_IsButtonIndeterminate (wndPtr, wParam, lParam);
2068 case TB_ISBUTTONPRESSED:
2069 return TOOLBAR_IsButtonPressed (wndPtr, wParam, lParam);
2071 // case TB_LOADIMAGES: /* 4.70 */
2072 // case TB_MAPACCELERATOR32A: /* 4.71 */
2073 // case TB_MAPACCELERATOR32W: /* 4.71 */
2074 // case TB_MARKBUTTON: /* 4.71 */
2075 // case TB_MOVEBUTTON: /* 4.71 */
2077 case TB_PRESSBUTTON:
2078 return TOOLBAR_PressButton (wndPtr, wParam, lParam);
2080 // case TB_REPLACEBITMAP:
2082 case TB_SAVERESTORE32A:
2083 return TOOLBAR_SaveRestore32A (wndPtr, wParam, lParam);
2085 // case TB_SAVERESTORE32W:
2086 // case TB_SETANCHORHIGHLIGHT: /* 4.71 */
2088 case TB_SETBITMAPSIZE:
2089 return TOOLBAR_SetBitmapSize (wndPtr, wParam, lParam);
2091 // case TB_SETBUTTONINFO: /* 4.71 */
2093 case TB_SETBUTTONSIZE:
2094 return TOOLBAR_SetButtonSize (wndPtr, wParam, lParam);
2096 // case TB_SETBUTTONWIDTH: /* 4.70 */
2098 case TB_SETCMDID:
2099 return TOOLBAR_SetCmdId (wndPtr, wParam, lParam);
2101 // case TB_SETCOLORSCHEME: /* 4.71 */
2102 // case TB_SETDISABLEDIMAGELIST: /* 4.70 */
2103 // case TB_SETDRAWTEXTFLAGS: /* 4.71 */
2104 // case TB_SETEXTENDEDSTYLE: /* 4.71 */
2105 // case TB_SETHOTIMAGELIST: /* 4.70 */
2106 // case TB_SETHOTITEM: /* 4.71 */
2108 case TB_SETIMAGELIST:
2109 return TOOLBAR_SetImageList (wndPtr, wParam, lParam);
2111 case TB_SETINDENT:
2112 return TOOLBAR_SetIndent (wndPtr, wParam, lParam);
2114 // case TB_SETINSERTMARK: /* 4.71 */
2116 case TB_SETINSERTMARKCOLOR:
2117 return TOOLBAR_SetInsertMarkColor (wndPtr, wParam, lParam);
2119 // case TB_SETMAXTEXTROWS: /* 4.70 */
2120 // case TB_SETPADDING: /* 4.71 */
2122 case TB_SETPARENT:
2123 return TOOLBAR_SetParent (wndPtr, wParam, lParam);
2125 case TB_SETROWS:
2126 return TOOLBAR_SetRows (wndPtr, wParam, lParam);
2128 case TB_SETSTATE:
2129 return TOOLBAR_SetState (wndPtr, wParam, lParam);
2131 case TB_SETSTYLE:
2132 return TOOLBAR_SetStyle (wndPtr, wParam, lParam);
2134 case TB_SETTOOLTIPS:
2135 return TOOLBAR_SetToolTips (wndPtr, wParam, lParam);
2137 case TB_SETUNICODEFORMAT:
2138 return TOOLBAR_SetUnicodeFormat (wndPtr, wParam, lParam);
2140 case WM_CREATE:
2141 return TOOLBAR_Create (wndPtr, wParam, lParam);
2143 case WM_DESTROY:
2144 return TOOLBAR_Destroy (wndPtr, wParam, lParam);
2146 case WM_ERASEBKGND:
2147 return TOOLBAR_EraseBackground (wndPtr, wParam, lParam);
2149 case WM_LBUTTONDBLCLK:
2150 return TOOLBAR_LButtonDblClk (wndPtr, wParam, lParam);
2152 case WM_LBUTTONDOWN:
2153 return TOOLBAR_LButtonDown (wndPtr, wParam, lParam);
2155 case WM_LBUTTONUP:
2156 return TOOLBAR_LButtonUp (wndPtr, wParam, lParam);
2158 case WM_MOUSEMOVE:
2159 return TOOLBAR_MouseMove (wndPtr, wParam, lParam);
2161 // case WM_NCACTIVATE:
2162 // return TOOLBAR_NCActivate (wndPtr, wParam, lParam);
2164 case WM_NCCALCSIZE:
2165 return TOOLBAR_NCCalcSize (wndPtr, wParam, lParam);
2167 case WM_NCCREATE:
2168 return TOOLBAR_NCCreate (wndPtr, wParam, lParam);
2170 case WM_NCPAINT:
2171 return TOOLBAR_NCPaint (wndPtr, wParam, lParam);
2173 // case WM_NOTIFY:
2174 // SendMessage32A (GetParent32 (hwnd), uMsg, wParam, lParam);
2176 case WM_PAINT:
2177 return TOOLBAR_Paint (wndPtr, wParam);
2179 case WM_SIZE:
2180 return TOOLBAR_Size (wndPtr, wParam, lParam);
2182 // case WM_SYSCOLORCHANGE:
2184 // case WM_WININICHANGE:
2186 case WM_CHARTOITEM:
2187 case WM_COMMAND:
2188 case WM_DRAWITEM:
2189 case WM_MEASUREITEM:
2190 case WM_VKEYTOITEM:
2191 return SendMessage32A (GetParent32 (hwnd), uMsg, wParam, lParam);
2193 default:
2194 if (uMsg >= WM_USER)
2195 ERR (toolbar, "unknown msg %04x wp=%08x lp=%08lx\n",
2196 uMsg, wParam, lParam);
2197 return DefWindowProc32A (hwnd, uMsg, wParam, lParam);
2199 return 0;
2203 void
2204 TOOLBAR_Register (void)
2206 WNDCLASS32A wndClass;
2208 if (GlobalFindAtom32A (TOOLBARCLASSNAME32A)) return;
2210 ZeroMemory (&wndClass, sizeof(WNDCLASS32A));
2211 wndClass.style = CS_GLOBALCLASS | CS_DBLCLKS;
2212 wndClass.lpfnWndProc = (WNDPROC32)ToolbarWindowProc;
2213 wndClass.cbClsExtra = 0;
2214 wndClass.cbWndExtra = sizeof(TOOLBAR_INFO *);
2215 wndClass.hCursor = LoadCursor32A (0, IDC_ARROW32A);
2216 wndClass.hbrBackground = (HBRUSH32)(COLOR_3DFACE + 1);
2217 wndClass.lpszClassName = TOOLBARCLASSNAME32A;
2219 RegisterClass32A (&wndClass);