4 * Copyright 1998 Eric Kohl
11 * - Fix TB_GETBITMAPFLAGS.
12 * - Fix TB_GETROWS and TB_SETROWS.
13 * - Tooltip support (almost complete).
15 * - Internal COMMCTL32 bitmaps.
16 * - Fix TOOLBAR_Customize. (Customize dialog.)
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 * - Microsofts controlspy examples.
37 #define SEPARATOR_WIDTH 8
38 #define SEPARATOR_HEIGHT 5
40 #define BOTTOM_BORDER 2
44 #define TOOLBAR_GetInfoPtr(wndPtr) ((TOOLBAR_INFO *)wndPtr->wExtra[0])
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
);
58 SelectObject32 ( hdc
, GetSysColorPen32 (COLOR_3DHILIGHT
));
59 MoveToEx32 (hdc
, x
, yBottom
, NULL
);
60 LineTo32 (hdc
, x
, yTop
);
65 TOOLBAR_DrawString (TOOLBAR_INFO
*infoPtr
, TBUTTON_INFO
*btnPtr
,
66 HDC32 hdc
, INT32 nState
)
68 RECT32 rcText
= btnPtr
->rect
;
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
)) {
84 SetTextColor32 (hdc
, GetSysColor32 (COLOR_3DHILIGHT
));
85 OffsetRect32 (&rcText
, 1, 1);
86 DrawText32A (hdc
, infoPtr
->strings
[btnPtr
->iString
], -1, &rcText
,
88 SetTextColor32 (hdc
, GetSysColor32 (COLOR_3DSHADOW
));
89 OffsetRect32 (&rcText
, -1, -1);
90 DrawText32A (hdc
, infoPtr
->strings
[btnPtr
->iString
], -1, &rcText
,
92 SetTextColor32 (hdc
, clrOld
);
94 else if (nState
& TBSTATE_INDETERMINATE
) {
96 SetTextColor32 (hdc
, GetSysColor32 (COLOR_3DSHADOW
));
97 DrawText32A (hdc
, infoPtr
->strings
[btnPtr
->iString
], -1, &rcText
,
99 SetTextColor32 (hdc
, clrOld
);
102 DrawText32A (hdc
, infoPtr
->strings
[btnPtr
->iString
], -1, &rcText
,
105 SelectObject32 (hdc
, hOldFont
);
106 if (nOldBkMode
!= TRANSPARENT
)
107 SetBkMode32 (hdc
, nOldBkMode
);
113 TOOLBAR_DrawButton (WND
*wndPtr
, TBUTTON_INFO
*btnPtr
, HDC32 hdc
)
115 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr(wndPtr
);
116 BOOL32 bFlat
= (wndPtr
->dwStyle
& TBSTYLE_FLAT
);
119 if (btnPtr
->fsState
& TBSTATE_HIDDEN
) return;
122 if (btnPtr
->fsStyle
& TBSTYLE_SEP
) {
123 if ((bFlat
) && (btnPtr
->idCommand
== 0))
124 TOOLBAR_DrawFlatSeparator (&btnPtr
->rect
, hdc
);
129 if (!(btnPtr
->fsState
& TBSTATE_ENABLED
)) {
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
);
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
);
150 /* checked TBSTYLE_CHECK*/
151 if ((btnPtr
->fsStyle
& TBSTYLE_CHECK
) &&
152 (btnPtr
->fsState
& TBSTATE_CHECKED
)) {
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
);
168 if (btnPtr
->fsState
& TBSTATE_INDETERMINATE
) {
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
);
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
);
193 TOOLBAR_Refresh (WND
*wndPtr
, HDC32 hdc
)
195 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr(wndPtr
);
196 TBUTTON_INFO
*btnPtr
;
200 btnPtr
= infoPtr
->buttons
;
201 for (i
= 0; i
< infoPtr
->nNumButtons
; i
++, btnPtr
++)
202 TOOLBAR_DrawButton (wndPtr
, btnPtr
, hdc
);
207 TOOLBAR_CalcStrings (WND
*wndPtr
, LPSIZE32 lpSize
)
209 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr(wndPtr
);
210 TBUTTON_INFO
*btnPtr
;
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
)
230 if (sz
.cy
> lpSize
->cy
)
235 SelectObject32 (hdc
, hOldFont
);
236 ReleaseDC32 (0, hdc
);
238 TRACE (toolbar
, "string size %d x %d!\n", lpSize
->cx
, lpSize
->cy
);
243 TOOLBAR_CalcToolbar (WND
*wndPtr
)
245 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr(wndPtr
);
246 TBUTTON_INFO
*btnPtr
;
251 RECT32 rect
= {0, 0, 0, 0};
253 TOOLBAR_CalcStrings (wndPtr
, &sizeString
);
255 if (sizeString
.cy
> 0)
256 infoPtr
->nButtonHeight
= sizeString
.cy
+ infoPtr
->nBitmapHeight
+ 6;
257 else if (infoPtr
->nButtonHeight
< infoPtr
->nBitmapHeight
+ 6)
258 infoPtr
->nButtonHeight
= infoPtr
->nBitmapHeight
+ 6;
260 if (sizeString
.cx
> infoPtr
->nBitmapWidth
)
261 infoPtr
->nButtonWidth
= sizeString
.cx
+ 6;
262 else if (infoPtr
->nButtonWidth
< infoPtr
->nBitmapWidth
+ 6)
263 infoPtr
->nButtonWidth
= infoPtr
->nBitmapWidth
+ 6;
265 x
= infoPtr
->nIndent
;
267 cx
= infoPtr
->nButtonWidth
;
268 cy
= infoPtr
->nButtonHeight
;
272 rect
.bottom
= y
+ cy
;
275 btnPtr
= infoPtr
->buttons
;
276 for (i
= 0; i
< infoPtr
->nNumButtons
; i
++, btnPtr
++) {
279 if (btnPtr
->fsState
& TBSTATE_HIDDEN
)
282 if (btnPtr
->fsStyle
& TBSTYLE_SEP
) {
283 /* UNDOCUMENTED: If a separator has a non zero bitmap index, */
284 /* it is the actual width of the separator. This is used for */
285 /* custom controls in toolbars. */
286 if ((wndPtr
->dwStyle
& TBSTYLE_WRAPABLE
) &&
287 (btnPtr
->fsState
& TBSTATE_WRAP
)) {
290 cx
= infoPtr
->nWidth
;
291 cy
= ((btnPtr
->iBitmap
> 0) ?
292 btnPtr
->iBitmap
: SEPARATOR_WIDTH
) * 2 / 3;
297 cx
= (btnPtr
->iBitmap
> 0) ?
298 btnPtr
->iBitmap
: SEPARATOR_WIDTH
;
301 /* this must be a button */
302 cx
= infoPtr
->nButtonWidth
;
306 btnPtr
->rect
.left
= x
;
307 btnPtr
->rect
.top
= y
;
308 btnPtr
->rect
.right
= x
+ cx
;
309 btnPtr
->rect
.bottom
= y
+ cy
;
313 if (rect
.right
< x
+ cx
)
315 if (rect
.bottom
< y
+ cy
)
316 rect
.bottom
= y
+ cy
;
318 if (infoPtr
->hwndToolTip
) {
321 ZeroMemory (&ti
, sizeof(TTTOOLINFO32A
));
322 ti
.cbSize
= sizeof(TTTOOLINFO32A
);
323 ti
.hwnd
= wndPtr
->hwndSelf
;
324 ti
.uId
= btnPtr
->idCommand
;
325 ti
.rect
= btnPtr
->rect
;
326 SendMessage32A (infoPtr
->hwndToolTip
, TTM_NEWTOOLRECT32A
,
333 if (i
< infoPtr
->nNumButtons
)
340 infoPtr
->nHeight
= y
+ cy
+ BOTTOM_BORDER
;
341 infoPtr
->maxSize
.cx
= rect
.right
- rect
.left
;
342 infoPtr
->maxSize
.cy
= rect
.bottom
- rect
.top
;
343 TRACE (toolbar
, "toolbar height %d\n", infoPtr
->nHeight
);
348 TOOLBAR_InternalHitTest (WND
*wndPtr
, LPPOINT32 lpPt
)
350 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr(wndPtr
);
351 TBUTTON_INFO
*btnPtr
;
354 btnPtr
= infoPtr
->buttons
;
355 for (i
= 0; i
< infoPtr
->nNumButtons
; i
++, btnPtr
++) {
356 if (btnPtr
->fsState
& TBSTATE_HIDDEN
)
359 if (btnPtr
->fsStyle
& TBSTYLE_SEP
) {
360 if (PtInRect32 (&btnPtr
->rect
, *lpPt
)) {
361 TRACE (toolbar
, " ON SEPARATOR %d!\n", i
);
366 if (PtInRect32 (&btnPtr
->rect
, *lpPt
)) {
367 TRACE (toolbar
, " ON BUTTON %d!\n", i
);
373 TRACE (toolbar
, " NOWHERE!\n");
379 TOOLBAR_GetButtonIndex (TOOLBAR_INFO
*infoPtr
, INT32 idCommand
)
381 TBUTTON_INFO
*btnPtr
;
384 btnPtr
= infoPtr
->buttons
;
385 for (i
= 0; i
< infoPtr
->nNumButtons
; i
++, btnPtr
++) {
386 if (btnPtr
->idCommand
== idCommand
) {
387 TRACE (toolbar
, "command=%d index=%d\n", idCommand
, i
);
391 TRACE (toolbar
, "no index found for command=%d\n", idCommand
);
397 TOOLBAR_GetCheckedGroupButtonIndex (TOOLBAR_INFO
*infoPtr
, INT32 nIndex
)
399 TBUTTON_INFO
*btnPtr
;
402 if ((nIndex
< 0) || (nIndex
> infoPtr
->nNumButtons
))
405 /* check index button */
406 btnPtr
= &infoPtr
->buttons
[nIndex
];
407 if ((btnPtr
->fsStyle
& TBSTYLE_CHECKGROUP
) == TBSTYLE_CHECKGROUP
) {
408 if (btnPtr
->fsState
& TBSTATE_CHECKED
)
412 /* check previous buttons */
413 nRunIndex
= nIndex
- 1;
414 while (nRunIndex
>= 0) {
415 btnPtr
= &infoPtr
->buttons
[nRunIndex
];
416 if ((btnPtr
->fsStyle
& TBSTYLE_CHECKGROUP
) == TBSTYLE_CHECKGROUP
) {
417 if (btnPtr
->fsState
& TBSTATE_CHECKED
)
425 /* check next buttons */
426 nRunIndex
= nIndex
+ 1;
427 while (nRunIndex
< infoPtr
->nNumButtons
) {
428 btnPtr
= &infoPtr
->buttons
[nRunIndex
];
429 if ((btnPtr
->fsStyle
& TBSTYLE_CHECKGROUP
) == TBSTYLE_CHECKGROUP
) {
430 if (btnPtr
->fsState
& TBSTATE_CHECKED
)
443 TOOLBAR_RelayEvent (HWND32 hwndTip
, HWND32 hwndMsg
, UINT32 uMsg
,
444 WPARAM32 wParam
, LPARAM lParam
)
452 msg
.time
= GetMessageTime ();
453 msg
.pt
.x
= LOWORD(GetMessagePos ());
454 msg
.pt
.y
= HIWORD(GetMessagePos ());
456 SendMessage32A (hwndTip
, TTM_RELAYEVENT
, 0, (LPARAM
)&msg
);
461 TOOLBAR_AddBitmap (WND
*wndPtr
, WPARAM32 wParam
, LPARAM lParam
)
463 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr(wndPtr
);
464 LPTBADDBITMAP lpAddBmp
= (LPTBADDBITMAP
)lParam
;
467 if ((!lpAddBmp
) || ((INT32
)wParam
<= 0))
470 TRACE (toolbar
, "adding %d bitmaps!\n", wParam
);
472 if (!(infoPtr
->himlDef
)) {
473 /* create new default image list */
474 TRACE (toolbar
, "creating default image list!\n");
476 ImageList_Create (infoPtr
->nBitmapWidth
, infoPtr
->nBitmapHeight
,
477 ILC_COLOR
| ILC_MASK
, (INT32
)wParam
, 2);
481 if (!(infoPtr
->himlDis
)) {
482 /* create new disabled image list */
483 TRACE (toolbar
, "creating disabled image list!\n");
485 ImageList_Create (infoPtr
->nBitmapWidth
,
486 infoPtr
->nBitmapHeight
, ILC_COLOR
| ILC_MASK
,
491 /* Add bitmaps to the default image list */
492 if (lpAddBmp
->hInst
== (HINSTANCE32
)0) {
494 ImageList_AddMasked (infoPtr
->himlDef
, (HBITMAP32
)lpAddBmp
->nID
,
495 GetSysColor32 (COLOR_3DFACE
));
497 else if (lpAddBmp
->hInst
== HINST_COMMCTRL
) {
498 /* add internal bitmaps */
499 FIXME (toolbar
, "internal bitmaps not supported!\n");
501 /* Hack to "add" some reserved images within the image list
502 to get the right image indices */
503 nIndex
= ImageList_GetImageCount (infoPtr
->himlDef
);
504 ImageList_SetImageCount (infoPtr
->himlDef
, nIndex
+ (INT32
)wParam
);
508 LoadBitmap32A (lpAddBmp
->hInst
, (LPSTR
)lpAddBmp
->nID
);
510 nIndex
= ImageList_Add (infoPtr
->himlDef
, hBmp
, (HBITMAP32
)0);
512 DeleteObject32 (hBmp
);
516 infoPtr
->nNumBitmaps
+= (INT32
)wParam
;
523 TOOLBAR_AddButtons32A (WND
*wndPtr
, WPARAM32 wParam
, LPARAM lParam
)
525 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr(wndPtr
);
526 LPTBBUTTON lpTbb
= (LPTBBUTTON
)lParam
;
527 INT32 nOldButtons
, nNewButtons
, nAddButtons
, nCount
;
530 TRACE (toolbar
, "adding %d buttons!\n", wParam
);
532 nAddButtons
= (UINT32
)wParam
;
533 nOldButtons
= infoPtr
->nNumButtons
;
534 nNewButtons
= nOldButtons
+ nAddButtons
;
536 if (infoPtr
->nNumButtons
== 0) {
538 HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY
,
539 sizeof (TBUTTON_INFO
) * nNewButtons
);
542 TBUTTON_INFO
*oldButtons
= infoPtr
->buttons
;
544 HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY
,
545 sizeof (TBUTTON_INFO
) * nNewButtons
);
546 memcpy (&infoPtr
->buttons
[0], &oldButtons
[0],
547 nOldButtons
* sizeof(TBUTTON_INFO
));
548 HeapFree (GetProcessHeap (), 0, oldButtons
);
551 infoPtr
->nNumButtons
= nNewButtons
;
553 /* insert new button data (bad implementation)*/
554 for (nCount
= 0; nCount
< nAddButtons
; nCount
++) {
555 infoPtr
->buttons
[nOldButtons
+nCount
].iBitmap
= lpTbb
[nCount
].iBitmap
;
556 infoPtr
->buttons
[nOldButtons
+nCount
].idCommand
= lpTbb
[nCount
].idCommand
;
557 infoPtr
->buttons
[nOldButtons
+nCount
].fsState
= lpTbb
[nCount
].fsState
;
558 infoPtr
->buttons
[nOldButtons
+nCount
].fsStyle
= lpTbb
[nCount
].fsStyle
;
559 infoPtr
->buttons
[nOldButtons
+nCount
].dwData
= lpTbb
[nCount
].dwData
;
560 infoPtr
->buttons
[nOldButtons
+nCount
].iString
= lpTbb
[nCount
].iString
;
562 if ((infoPtr
->hwndToolTip
) && !(lpTbb
[nCount
].fsStyle
& TBSTYLE_SEP
)) {
565 ZeroMemory (&ti
, sizeof(TTTOOLINFO32A
));
566 ti
.cbSize
= sizeof (TTTOOLINFO32A
);
567 ti
.hwnd
= wndPtr
->hwndSelf
;
568 ti
.uId
= lpTbb
[nCount
].idCommand
;
570 ti
.lpszText
= LPSTR_TEXTCALLBACK32A
;
572 SendMessage32A (infoPtr
->hwndToolTip
, TTM_ADDTOOL32A
,
577 TOOLBAR_CalcToolbar (wndPtr
);
579 hdc
= GetDC32 (wndPtr
->hwndSelf
);
580 TOOLBAR_Refresh (wndPtr
, hdc
);
581 ReleaseDC32 (wndPtr
->hwndSelf
, hdc
);
587 // << TOOLBAR_AddButtons32W >>
591 TOOLBAR_AddString32A (WND
*wndPtr
, WPARAM32 wParam
, LPARAM lParam
)
593 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr(wndPtr
);
599 TRACE (toolbar
, "adding string from resource!\n");
601 len
= LoadString32A ((HINSTANCE32
)wParam
, (UINT32
)lParam
,
604 TRACE (toolbar
, "len=%d \"%s\"\n", len
, szString
);
605 nIndex
= infoPtr
->nNumStrings
;
606 if (infoPtr
->nNumStrings
== 0) {
608 HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY
, sizeof(char *));
611 char **oldStrings
= infoPtr
->strings
;
613 HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY
,
614 sizeof(char *) * (infoPtr
->nNumStrings
+ 1));
615 memcpy (&infoPtr
->strings
[0], &oldStrings
[0],
616 sizeof(char *) * infoPtr
->nNumStrings
);
617 HeapFree (GetProcessHeap (), 0, oldStrings
);
620 infoPtr
->strings
[infoPtr
->nNumStrings
] =
621 HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY
, sizeof(char)*(len
+1));
622 lstrcpy32A (infoPtr
->strings
[infoPtr
->nNumStrings
], szString
);
623 infoPtr
->nNumStrings
++;
626 char *p
= (char*)lParam
;
629 if (p
== NULL
) return -1;
630 TRACE (toolbar
, "adding string(s) from array!\n");
631 nIndex
= infoPtr
->nNumStrings
;
633 len
= lstrlen32A (p
);
634 TRACE (toolbar
, "len=%d \"%s\"\n", len
, p
);
636 if (infoPtr
->nNumStrings
== 0) {
638 HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY
, sizeof(char *));
641 char **oldStrings
= infoPtr
->strings
;
643 HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY
,
644 sizeof(char *) * (infoPtr
->nNumStrings
+ 1));
645 memcpy (&infoPtr
->strings
[0], &oldStrings
[0],
646 sizeof(char *) * infoPtr
->nNumStrings
);
647 HeapFree (GetProcessHeap (), 0, oldStrings
);
650 infoPtr
->strings
[infoPtr
->nNumStrings
] =
651 HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY
, sizeof(char)*(len
+1));
652 lstrcpy32A (infoPtr
->strings
[infoPtr
->nNumStrings
], p
);
653 infoPtr
->nNumStrings
++;
663 // << TOOLBAR_AddString32W >>
667 TOOLBAR_AutoSize (WND
*wndPtr
, WPARAM32 wParam
, LPARAM lParam
)
669 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr(wndPtr
);
673 UINT32 uPosFlags
= 0;
675 TRACE (toolbar
, "resizing!\n");
677 parent
= GetParent32 (wndPtr
->hwndSelf
);
678 GetClientRect32(parent
, &parent_rect
);
680 if (wndPtr
->dwStyle
& CCS_NORESIZE
) {
681 uPosFlags
|= SWP_NOSIZE
;
686 infoPtr
->nWidth
= parent_rect
.right
- parent_rect
.left
;
687 TOOLBAR_CalcToolbar (wndPtr
);
688 cy
= infoPtr
->nHeight
;
689 cx
= infoPtr
->nWidth
;
692 if (wndPtr
->dwStyle
& CCS_NOPARENTALIGN
)
693 uPosFlags
|= SWP_NOMOVE
;
695 if (!(wndPtr
->dwStyle
& CCS_NODIVIDER
))
698 infoPtr
->bAutoSize
= TRUE
;
699 SetWindowPos32 (wndPtr
->hwndSelf
, HWND_TOP
, parent_rect
.left
, parent_rect
.top
,
707 TOOLBAR_ButtonCount (WND
*wndPtr
, WPARAM32 wParam
, LPARAM lParam
)
709 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr(wndPtr
);
711 return infoPtr
->nNumButtons
;
716 TOOLBAR_ButtonStructSize (WND
*wndPtr
, WPARAM32 wParam
, LPARAM lParam
)
718 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr(wndPtr
);
720 if (infoPtr
== NULL
) {
721 ERR (toolbar
, "(0x%08lx, 0x%08x, 0x%08lx)\n", (DWORD
)wndPtr
, wParam
, lParam
);
722 ERR (toolbar
, "infoPtr == NULL!\n");
726 infoPtr
->dwStructSize
= (DWORD
)wParam
;
733 TOOLBAR_ChangeBitmap (WND
*wndPtr
, WPARAM32 wParam
, LPARAM lParam
)
735 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr(wndPtr
);
736 TBUTTON_INFO
*btnPtr
;
740 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT32
)wParam
);
744 btnPtr
= &infoPtr
->buttons
[nIndex
];
745 btnPtr
->iBitmap
= LOWORD(lParam
);
747 hdc
= GetDC32 (wndPtr
->hwndSelf
);
748 TOOLBAR_DrawButton (wndPtr
, btnPtr
, hdc
);
749 ReleaseDC32 (wndPtr
->hwndSelf
, hdc
);
756 TOOLBAR_CheckButton (WND
*wndPtr
, WPARAM32 wParam
, LPARAM lParam
)
758 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr(wndPtr
);
759 TBUTTON_INFO
*btnPtr
;
762 INT32 nOldIndex
= -1;
764 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT32
)wParam
);
768 btnPtr
= &infoPtr
->buttons
[nIndex
];
770 if (!(btnPtr
->fsStyle
& TBSTYLE_CHECK
))
773 if (LOWORD(lParam
) == FALSE
)
774 btnPtr
->fsState
&= ~TBSTATE_CHECKED
;
776 if (btnPtr
->fsStyle
& TBSTYLE_GROUP
) {
778 TOOLBAR_GetCheckedGroupButtonIndex (infoPtr
, nIndex
);
779 if (nOldIndex
== nIndex
)
782 infoPtr
->buttons
[nOldIndex
].fsState
&= ~TBSTATE_CHECKED
;
784 btnPtr
->fsState
|= TBSTATE_CHECKED
;
787 hdc
= GetDC32 (wndPtr
->hwndSelf
);
789 TOOLBAR_DrawButton (wndPtr
, &infoPtr
->buttons
[nOldIndex
], hdc
);
790 TOOLBAR_DrawButton (wndPtr
, btnPtr
, hdc
);
791 ReleaseDC32 (wndPtr
->hwndSelf
, hdc
);
793 /* FIXME: Send a WM_NOTIFY?? */
800 TOOLBAR_CommandToIndex (WND
*wndPtr
, WPARAM32 wParam
, LPARAM lParam
)
802 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr(wndPtr
);
804 return TOOLBAR_GetButtonIndex (infoPtr
, (INT32
)wParam
);
809 TOOLBAR_Customize (WND
*wndPtr
)
811 FIXME (toolbar
, "customization not implemented!\n");
818 TOOLBAR_DeleteButton (WND
*wndPtr
, WPARAM32 wParam
, LPARAM lParam
)
820 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr(wndPtr
);
821 INT32 nIndex
= (INT32
)wParam
;
823 if ((nIndex
< 0) || (nIndex
>= infoPtr
->nNumButtons
))
826 if ((infoPtr
->hwndToolTip
) &&
827 !(infoPtr
->buttons
[nIndex
].fsStyle
& TBSTYLE_SEP
)) {
830 ZeroMemory (&ti
, sizeof(TTTOOLINFO32A
));
831 ti
.cbSize
= sizeof (TTTOOLINFO32A
);
832 ti
.hwnd
= wndPtr
->hwndSelf
;
833 ti
.uId
= infoPtr
->buttons
[nIndex
].idCommand
;
835 SendMessage32A (infoPtr
->hwndToolTip
, TTM_DELTOOL32A
, 0, (LPARAM
)&ti
);
838 if (infoPtr
->nNumButtons
== 1) {
839 TRACE (toolbar
, " simple delete!\n");
840 HeapFree (GetProcessHeap (), 0, infoPtr
->buttons
);
841 infoPtr
->buttons
= NULL
;
842 infoPtr
->nNumButtons
= 0;
845 TBUTTON_INFO
*oldButtons
= infoPtr
->buttons
;
846 TRACE(toolbar
, "complex delete! [nIndex=%d]\n", nIndex
);
848 infoPtr
->nNumButtons
--;
849 infoPtr
->buttons
= HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY
,
850 sizeof (TBUTTON_INFO
) * infoPtr
->nNumButtons
);
852 memcpy (&infoPtr
->buttons
[0], &oldButtons
[0],
853 nIndex
* sizeof(TBUTTON_INFO
));
856 if (nIndex
< infoPtr
->nNumButtons
) {
857 memcpy (&infoPtr
->buttons
[nIndex
], &oldButtons
[nIndex
+1],
858 (infoPtr
->nNumButtons
- nIndex
) * sizeof(TBUTTON_INFO
));
861 HeapFree (GetProcessHeap (), 0, oldButtons
);
864 TOOLBAR_CalcToolbar (wndPtr
);
866 InvalidateRect32 (wndPtr
->hwndSelf
, NULL
, TRUE
);
867 UpdateWindow32 (wndPtr
->hwndSelf
);
874 TOOLBAR_EnableButton (WND
*wndPtr
, WPARAM32 wParam
, LPARAM lParam
)
876 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr(wndPtr
);
877 TBUTTON_INFO
*btnPtr
;
881 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT32
)wParam
);
885 btnPtr
= &infoPtr
->buttons
[nIndex
];
886 if (LOWORD(lParam
) == FALSE
)
887 btnPtr
->fsState
&= ~(TBSTATE_ENABLED
| TBSTATE_PRESSED
);
889 btnPtr
->fsState
|= TBSTATE_ENABLED
;
891 hdc
= GetDC32 (wndPtr
->hwndSelf
);
892 TOOLBAR_DrawButton (wndPtr
, btnPtr
, hdc
);
893 ReleaseDC32 (wndPtr
->hwndSelf
, hdc
);
899 // << TOOLBAR_GetAnchorHighlight >>
903 TOOLBAR_GetBitmap (WND
*wndPtr
, WPARAM32 wParam
, LPARAM lParam
)
905 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr(wndPtr
);
908 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT32
)wParam
);
912 return infoPtr
->buttons
[nIndex
].iBitmap
;
917 TOOLBAR_GetBitmapFlags (WND
*wndPtr
, WPARAM32 wParam
, LPARAM lParam
)
919 FIXME (toolbar
, "stub!\n");
925 TOOLBAR_GetButton (WND
*wndPtr
, WPARAM32 wParam
, LPARAM lParam
)
927 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr(wndPtr
);
928 LPTBBUTTON lpTbb
= (LPTBBUTTON
)lParam
;
929 INT32 nIndex
= (INT32
)wParam
;
930 TBUTTON_INFO
*btnPtr
;
932 if (infoPtr
== NULL
) return FALSE
;
933 if (lpTbb
== NULL
) return FALSE
;
935 if ((nIndex
< 0) || (nIndex
>= infoPtr
->nNumButtons
))
938 btnPtr
= &infoPtr
->buttons
[nIndex
];
939 lpTbb
->iBitmap
= btnPtr
->iBitmap
;
940 lpTbb
->idCommand
= btnPtr
->idCommand
;
941 lpTbb
->fsState
= btnPtr
->fsState
;
942 lpTbb
->fsStyle
= btnPtr
->fsStyle
;
943 lpTbb
->dwData
= btnPtr
->dwData
;
944 lpTbb
->iString
= btnPtr
->iString
;
951 TOOLBAR_GetButtonInfo32A (WND
*wndPtr
, WPARAM32 wParam
, LPARAM lParam
)
953 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr(wndPtr
);
954 LPTBBUTTONINFO32A lpTbInfo
= (LPTBBUTTONINFO32A
)lParam
;
955 TBUTTON_INFO
*btnPtr
;
958 if (infoPtr
== NULL
) return -1;
959 if (lpTbInfo
== NULL
) return -1;
960 if (lpTbInfo
->cbSize
< sizeof(LPTBBUTTONINFO32A
)) return -1;
962 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT32
)wParam
);
967 btnPtr
= &infoPtr
->buttons
[nIndex
];
969 if (lpTbInfo
->dwMask
& TBIF_COMMAND
)
970 lpTbInfo
->idCommand
= btnPtr
->idCommand
;
972 if (lpTbInfo
->dwMask
& TBIF_IMAGE
)
973 lpTbInfo
->iImage
= btnPtr
->iBitmap
;
975 if (lpTbInfo
->dwMask
& TBIF_LPARAM
)
976 lpTbInfo
->lParam
= btnPtr
->dwData
;
978 if (lpTbInfo
->dwMask
& TBIF_SIZE
)
979 lpTbInfo
->cx
= (WORD
)(btnPtr
->rect
.right
- btnPtr
->rect
.left
);
981 if (lpTbInfo
->dwMask
& TBIF_STATE
)
982 lpTbInfo
->fsState
= btnPtr
->fsState
;
984 if (lpTbInfo
->dwMask
& TBIF_STYLE
)
985 lpTbInfo
->fsStyle
= btnPtr
->fsStyle
;
987 if (lpTbInfo
->dwMask
& TBIF_TEXT
) {
988 if ((btnPtr
->iString
>= 0) || (btnPtr
->iString
< infoPtr
->nNumStrings
))
989 lstrcpyn32A (lpTbInfo
->pszText
,
990 (LPSTR
)infoPtr
->strings
[btnPtr
->iString
],
998 // << TOOLBAR_GetButtonInfo32W >>
1002 TOOLBAR_GetButtonSize (WND
*wndPtr
)
1004 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr(wndPtr
);
1006 return MAKELONG((WORD
)infoPtr
->nButtonWidth
,
1007 (WORD
)infoPtr
->nButtonHeight
);
1012 TOOLBAR_GetButtonText32A (WND
*wndPtr
, WPARAM32 wParam
, LPARAM lParam
)
1014 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr(wndPtr
);
1015 INT32 nIndex
, nStringIndex
;
1017 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT32
)wParam
);
1021 nStringIndex
= infoPtr
->buttons
[nIndex
].iString
;
1023 TRACE (toolbar
, "index=%d stringIndex=%d\n", nIndex
, nStringIndex
);
1025 if ((nStringIndex
< 0) || (nStringIndex
>= infoPtr
->nNumStrings
))
1028 if (lParam
== 0) return -1;
1030 lstrcpy32A ((LPSTR
)lParam
, (LPSTR
)infoPtr
->strings
[nStringIndex
]);
1032 return lstrlen32A ((LPSTR
)infoPtr
->strings
[nStringIndex
]);
1036 // << TOOLBAR_GetButtonText32W >>
1037 // << TOOLBAR_GetColorScheme >>
1041 TOOLBAR_GetDisabledImageList (WND
*wndPtr
, WPARAM32 wParam
, LPARAM lParam
)
1043 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr(wndPtr
);
1045 if (wndPtr
->dwStyle
& TBSTYLE_FLAT
)
1046 return (LRESULT
)infoPtr
->himlDis
;
1052 __inline__
static LRESULT
1053 TOOLBAR_GetExtendedStyle (WND
*wndPtr
)
1055 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr(wndPtr
);
1057 return infoPtr
->dwExStyle
;
1062 TOOLBAR_GetHotImageList (WND
*wndPtr
, WPARAM32 wParam
, LPARAM lParam
)
1064 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr(wndPtr
);
1066 if (wndPtr
->dwStyle
& TBSTYLE_FLAT
)
1067 return (LRESULT
)infoPtr
->himlHot
;
1073 // << TOOLBAR_GetHotItem >>
1077 TOOLBAR_GetImageList (WND
*wndPtr
, WPARAM32 wParam
, LPARAM lParam
)
1079 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr(wndPtr
);
1081 if (wndPtr
->dwStyle
& TBSTYLE_FLAT
)
1082 return (LRESULT
)infoPtr
->himlDef
;
1088 // << TOOLBAR_GetInsertMark >>
1089 // << TOOLBAR_GetInsertMarkColor >>
1093 TOOLBAR_GetItemRect (WND
*wndPtr
, WPARAM32 wParam
, LPARAM lParam
)
1095 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr(wndPtr
);
1096 TBUTTON_INFO
*btnPtr
;
1100 if (infoPtr
== NULL
) return FALSE
;
1101 nIndex
= (INT32
)wParam
;
1102 btnPtr
= &infoPtr
->buttons
[nIndex
];
1103 if ((nIndex
< 0) || (nIndex
>= infoPtr
->nNumButtons
))
1105 lpRect
= (LPRECT32
)lParam
;
1106 if (lpRect
== NULL
) return FALSE
;
1107 if (btnPtr
->fsState
& TBSTATE_HIDDEN
) return FALSE
;
1109 lpRect
->left
= btnPtr
->rect
.left
;
1110 lpRect
->right
= btnPtr
->rect
.right
;
1111 lpRect
->bottom
= btnPtr
->rect
.bottom
;
1112 lpRect
->top
= btnPtr
->rect
.top
;
1119 TOOLBAR_GetMaxSize (WND
*wndPtr
, WPARAM32 wParam
, LPARAM lParam
)
1121 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr(wndPtr
);
1122 LPSIZE32 lpSize
= (LPSIZE32
)lParam
;
1127 lpSize
->cx
= infoPtr
->maxSize
.cx
;
1128 lpSize
->cx
= infoPtr
->maxSize
.cy
;
1130 TRACE (toolbar
, "maximum size %d x %d\n",
1131 infoPtr
->maxSize
.cx
, infoPtr
->maxSize
.cy
);
1137 // << TOOLBAR_GetObject >>
1138 // << TOOLBAR_GetPadding >>
1142 TOOLBAR_GetRect (WND
*wndPtr
, WPARAM32 wParam
, LPARAM lParam
)
1144 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr(wndPtr
);
1145 TBUTTON_INFO
*btnPtr
;
1149 if (infoPtr
== NULL
) return FALSE
;
1150 nIndex
= (INT32
)wParam
;
1151 btnPtr
= &infoPtr
->buttons
[nIndex
];
1152 if ((nIndex
< 0) || (nIndex
>= infoPtr
->nNumButtons
))
1154 lpRect
= (LPRECT32
)lParam
;
1155 if (lpRect
== NULL
) return FALSE
;
1157 lpRect
->left
= btnPtr
->rect
.left
;
1158 lpRect
->right
= btnPtr
->rect
.right
;
1159 lpRect
->bottom
= btnPtr
->rect
.bottom
;
1160 lpRect
->top
= btnPtr
->rect
.top
;
1167 TOOLBAR_GetRows (WND
*wndPtr
, WPARAM32 wParam
, LPARAM lParam
)
1169 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr(wndPtr
);
1171 if (wndPtr
->dwStyle
& TBSTYLE_WRAPABLE
)
1172 return infoPtr
->nMaxRows
;
1179 TOOLBAR_GetState (WND
*wndPtr
, WPARAM32 wParam
, LPARAM lParam
)
1181 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr(wndPtr
);
1184 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT32
)wParam
);
1185 if (nIndex
== -1) return -1;
1187 return infoPtr
->buttons
[nIndex
].fsState
;
1192 TOOLBAR_GetStyle (WND
*wndPtr
, WPARAM32 wParam
, LPARAM lParam
)
1194 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr(wndPtr
);
1197 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT32
)wParam
);
1198 if (nIndex
== -1) return -1;
1200 return infoPtr
->buttons
[nIndex
].fsStyle
;
1205 TOOLBAR_GetTextRows (WND
*wndPtr
, WPARAM32 wParam
, LPARAM lParam
)
1207 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr(wndPtr
);
1209 if (infoPtr
== NULL
)
1212 return infoPtr
->nMaxTextRows
;
1217 TOOLBAR_GetToolTips (WND
*wndPtr
, WPARAM32 wParam
, LPARAM lParam
)
1219 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr(wndPtr
);
1221 if (infoPtr
== NULL
) return 0;
1222 return infoPtr
->hwndToolTip
;
1227 TOOLBAR_GetUnicodeFormat (WND
*wndPtr
, WPARAM32 wParam
, LPARAM lParam
)
1229 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr(wndPtr
);
1231 TRACE (toolbar
, "%s hwnd=0x%04x stub!\n",
1232 infoPtr
->bUnicode
? "TRUE" : "FALSE", wndPtr
->hwndSelf
);
1234 return infoPtr
->bUnicode
;
1239 TOOLBAR_HideButton (WND
*wndPtr
, WPARAM32 wParam
, LPARAM lParam
)
1241 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr(wndPtr
);
1242 TBUTTON_INFO
*btnPtr
;
1245 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT32
)wParam
);
1249 btnPtr
= &infoPtr
->buttons
[nIndex
];
1250 if (LOWORD(lParam
) == FALSE
)
1251 btnPtr
->fsState
&= ~TBSTATE_HIDDEN
;
1253 btnPtr
->fsState
|= TBSTATE_HIDDEN
;
1255 TOOLBAR_CalcToolbar (wndPtr
);
1257 InvalidateRect32 (wndPtr
->hwndSelf
, NULL
, TRUE
);
1258 UpdateWindow32 (wndPtr
->hwndSelf
);
1264 __inline__
static LRESULT
1265 TOOLBAR_HitTest (WND
*wndPtr
, WPARAM32 wParam
, LPARAM lParam
)
1267 return TOOLBAR_InternalHitTest (wndPtr
, (LPPOINT32
)lParam
);
1272 TOOLBAR_Indeterminate (WND
*wndPtr
, WPARAM32 wParam
, LPARAM lParam
)
1274 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr(wndPtr
);
1275 TBUTTON_INFO
*btnPtr
;
1279 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT32
)wParam
);
1283 btnPtr
= &infoPtr
->buttons
[nIndex
];
1284 if (LOWORD(lParam
) == FALSE
)
1285 btnPtr
->fsState
&= ~TBSTATE_INDETERMINATE
;
1287 btnPtr
->fsState
|= TBSTATE_INDETERMINATE
;
1289 hdc
= GetDC32 (wndPtr
->hwndSelf
);
1290 TOOLBAR_DrawButton (wndPtr
, btnPtr
, hdc
);
1291 ReleaseDC32 (wndPtr
->hwndSelf
, hdc
);
1298 TOOLBAR_InsertButton32A (WND
*wndPtr
, WPARAM32 wParam
, LPARAM lParam
)
1300 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr(wndPtr
);
1301 LPTBBUTTON lpTbb
= (LPTBBUTTON
)lParam
;
1302 INT32 nIndex
= (INT32
)wParam
;
1303 TBUTTON_INFO
*oldButtons
;
1306 if (lpTbb
== NULL
) return FALSE
;
1307 if (nIndex
< 0) return FALSE
;
1309 TRACE (toolbar
, "inserting button index=%d\n", nIndex
);
1310 if (nIndex
> infoPtr
->nNumButtons
) {
1311 nIndex
= infoPtr
->nNumButtons
;
1312 TRACE (toolbar
, "adjust index=%d\n", nIndex
);
1315 oldButtons
= infoPtr
->buttons
;
1316 infoPtr
->nNumButtons
++;
1317 infoPtr
->buttons
= HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY
,
1318 sizeof (TBUTTON_INFO
) * infoPtr
->nNumButtons
);
1319 /* pre insert copy */
1321 memcpy (&infoPtr
->buttons
[0], &oldButtons
[0],
1322 nIndex
* sizeof(TBUTTON_INFO
));
1325 /* insert new button */
1326 infoPtr
->buttons
[nIndex
].iBitmap
= lpTbb
->iBitmap
;
1327 infoPtr
->buttons
[nIndex
].idCommand
= lpTbb
->idCommand
;
1328 infoPtr
->buttons
[nIndex
].fsState
= lpTbb
->fsState
;
1329 infoPtr
->buttons
[nIndex
].fsStyle
= lpTbb
->fsStyle
;
1330 infoPtr
->buttons
[nIndex
].dwData
= lpTbb
->dwData
;
1331 infoPtr
->buttons
[nIndex
].iString
= lpTbb
->iString
;
1333 if ((infoPtr
->hwndToolTip
) && !(lpTbb
->fsStyle
& TBSTYLE_SEP
)) {
1336 ZeroMemory (&ti
, sizeof(TTTOOLINFO32A
));
1337 ti
.cbSize
= sizeof (TTTOOLINFO32A
);
1338 ti
.hwnd
= wndPtr
->hwndSelf
;
1339 ti
.uId
= lpTbb
->idCommand
;
1341 ti
.lpszText
= LPSTR_TEXTCALLBACK32A
;
1343 SendMessage32A (infoPtr
->hwndToolTip
, TTM_ADDTOOL32A
,
1347 /* post insert copy */
1348 if (nIndex
< infoPtr
->nNumButtons
- 1) {
1349 memcpy (&infoPtr
->buttons
[nIndex
+1], &oldButtons
[nIndex
],
1350 (infoPtr
->nNumButtons
- nIndex
- 1) * sizeof(TBUTTON_INFO
));
1353 HeapFree (GetProcessHeap (), 0, oldButtons
);
1355 TOOLBAR_CalcToolbar (wndPtr
);
1357 hdc
= GetDC32 (wndPtr
->hwndSelf
);
1358 TOOLBAR_Refresh (wndPtr
, hdc
);
1359 ReleaseDC32 (wndPtr
->hwndSelf
, hdc
);
1365 // << TOOLBAR_InsertButton32W >>
1366 // << TOOLBAR_InsertMarkHitTest >>
1370 TOOLBAR_IsButtonChecked (WND
*wndPtr
, WPARAM32 wParam
, LPARAM lParam
)
1372 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr(wndPtr
);
1375 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT32
)wParam
);
1379 return (infoPtr
->buttons
[nIndex
].fsState
& TBSTATE_CHECKED
);
1384 TOOLBAR_IsButtonEnabled (WND
*wndPtr
, WPARAM32 wParam
, LPARAM lParam
)
1386 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr(wndPtr
);
1389 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT32
)wParam
);
1393 return (infoPtr
->buttons
[nIndex
].fsState
& TBSTATE_ENABLED
);
1398 TOOLBAR_IsButtonHidden (WND
*wndPtr
, WPARAM32 wParam
, LPARAM lParam
)
1400 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr(wndPtr
);
1403 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT32
)wParam
);
1407 return (infoPtr
->buttons
[nIndex
].fsState
& TBSTATE_HIDDEN
);
1412 TOOLBAR_IsButtonHighlighted (WND
*wndPtr
, WPARAM32 wParam
, LPARAM lParam
)
1414 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr(wndPtr
);
1417 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT32
)wParam
);
1421 return (infoPtr
->buttons
[nIndex
].fsState
& TBSTATE_MARKED
);
1426 TOOLBAR_IsButtonIndeterminate (WND
*wndPtr
, WPARAM32 wParam
, LPARAM lParam
)
1428 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr(wndPtr
);
1431 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT32
)wParam
);
1435 return (infoPtr
->buttons
[nIndex
].fsState
& TBSTATE_INDETERMINATE
);
1440 TOOLBAR_IsButtonPressed (WND
*wndPtr
, WPARAM32 wParam
, LPARAM lParam
)
1442 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr(wndPtr
);
1445 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT32
)wParam
);
1449 return (infoPtr
->buttons
[nIndex
].fsState
& TBSTATE_PRESSED
);
1453 // << TOOLBAR_LoadImages >>
1454 // << TOOLBAR_MapAccelerator >>
1455 // << TOOLBAR_MarkButton >>
1456 // << TOOLBAR_MoveButton >>
1460 TOOLBAR_PressButton (WND
*wndPtr
, WPARAM32 wParam
, LPARAM lParam
)
1462 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr(wndPtr
);
1463 TBUTTON_INFO
*btnPtr
;
1467 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT32
)wParam
);
1471 btnPtr
= &infoPtr
->buttons
[nIndex
];
1472 if (LOWORD(lParam
) == FALSE
)
1473 btnPtr
->fsState
&= ~TBSTATE_PRESSED
;
1475 btnPtr
->fsState
|= TBSTATE_PRESSED
;
1477 hdc
= GetDC32 (wndPtr
->hwndSelf
);
1478 TOOLBAR_DrawButton (wndPtr
, btnPtr
, hdc
);
1479 ReleaseDC32 (wndPtr
->hwndSelf
, hdc
);
1485 // << TOOLBAR_ReplaceBitmap >>
1489 TOOLBAR_SaveRestore32A (WND
*wndPtr
, WPARAM32 wParam
, LPARAM lParam
)
1491 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr(wndPtr
);
1492 LPTBSAVEPARAMS32A lpSave
= (LPTBSAVEPARAMS32A
)lParam
;
1494 if (lpSave
== NULL
) return 0;
1496 if ((BOOL32
)wParam
) {
1497 /* save toolbar information */
1498 FIXME (toolbar
, "save to \"%s\" \"%s\"\n",
1499 lpSave
->pszSubKey
, lpSave
->pszValueName
);
1504 /* restore toolbar information */
1506 FIXME (toolbar
, "restore from \"%s\" \"%s\"\n",
1507 lpSave
->pszSubKey
, lpSave
->pszValueName
);
1516 // << TOOLBAR_SaveRestore32W >>
1517 // << TOOLBAR_SetAnchorHighlight >>
1521 TOOLBAR_SetBitmapSize (WND
*wndPtr
, WPARAM32 wParam
, LPARAM lParam
)
1523 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr(wndPtr
);
1525 if ((LOWORD(lParam
) <= 0) || (HIWORD(lParam
)<=0))
1528 infoPtr
->nBitmapWidth
= (INT32
)LOWORD(lParam
);
1529 infoPtr
->nBitmapHeight
= (INT32
)HIWORD(lParam
);
1535 // << TOOLBAR_SetButtonInfo >>
1539 TOOLBAR_SetButtonSize (WND
*wndPtr
, WPARAM32 wParam
, LPARAM lParam
)
1541 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr(wndPtr
);
1543 if ((LOWORD(lParam
) <= 0) || (HIWORD(lParam
)<=0))
1546 infoPtr
->nButtonWidth
= (INT32
)LOWORD(lParam
);
1547 infoPtr
->nButtonHeight
= (INT32
)HIWORD(lParam
);
1554 TOOLBAR_SetButtonWidth (WND
*wndPtr
, WPARAM32 wParam
, LPARAM lParam
)
1556 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr(wndPtr
);
1558 if (infoPtr
== NULL
)
1561 infoPtr
->cxMin
= (INT32
)LOWORD(lParam
);
1562 infoPtr
->cxMax
= (INT32
)HIWORD(lParam
);
1569 TOOLBAR_SetCmdId (WND
*wndPtr
, WPARAM32 wParam
, LPARAM lParam
)
1571 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr(wndPtr
);
1572 INT32 nIndex
= (INT32
)wParam
;
1574 if ((nIndex
< 0) || (nIndex
>= infoPtr
->nNumButtons
))
1577 infoPtr
->buttons
[nIndex
].idCommand
= (INT32
)lParam
;
1579 if (infoPtr
->hwndToolTip
) {
1581 FIXME (toolbar
, "change tool tip!\n");
1589 // << TOOLBAR_SetColorScheme >>
1593 TOOLBAR_SetDisabledImageList (WND
*wndPtr
, WPARAM32 wParam
, LPARAM lParam
)
1595 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr(wndPtr
);
1596 HIMAGELIST himlTemp
;
1598 if (!(wndPtr
->dwStyle
& TBSTYLE_FLAT
))
1601 himlTemp
= infoPtr
->himlDis
;
1602 infoPtr
->himlDis
= (HIMAGELIST
)lParam
;
1604 /* FIXME: redraw ? */
1606 return (LRESULT
)himlTemp
;
1610 // << TOOLBAR_SetDrawTextFlags >>
1614 TOOLBAR_SetExtendedStyle (WND
*wndPtr
, WPARAM32 wParam
, LPARAM lParam
)
1616 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr(wndPtr
);
1619 dwTemp
= infoPtr
->dwExStyle
;
1620 infoPtr
->dwExStyle
= (DWORD
)lParam
;
1622 return (LRESULT
)dwTemp
;
1627 TOOLBAR_SetHotImageList (WND
*wndPtr
, WPARAM32 wParam
, LPARAM lParam
)
1629 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr(wndPtr
);
1630 HIMAGELIST himlTemp
;
1632 if (!(wndPtr
->dwStyle
& TBSTYLE_FLAT
))
1635 himlTemp
= infoPtr
->himlHot
;
1636 infoPtr
->himlHot
= (HIMAGELIST
)lParam
;
1638 /* FIXME: redraw ? */
1640 return (LRESULT
)himlTemp
;
1644 // << TOOLBAR_SetHotItem >>
1648 TOOLBAR_SetImageList (WND
*wndPtr
, WPARAM32 wParam
, LPARAM lParam
)
1650 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr(wndPtr
);
1651 HIMAGELIST himlTemp
;
1653 if (!(wndPtr
->dwStyle
& TBSTYLE_FLAT
))
1656 himlTemp
= infoPtr
->himlDef
;
1657 infoPtr
->himlDef
= (HIMAGELIST
)lParam
;
1659 /* FIXME: redraw ? */
1661 return (LRESULT
)himlTemp
;
1666 TOOLBAR_SetIndent (WND
*wndPtr
, WPARAM32 wParam
, LPARAM lParam
)
1668 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr(wndPtr
);
1671 infoPtr
->nIndent
= (INT32
)wParam
;
1672 TOOLBAR_CalcToolbar (wndPtr
);
1673 hdc
= GetDC32 (wndPtr
->hwndSelf
);
1674 TOOLBAR_Refresh (wndPtr
, hdc
);
1675 ReleaseDC32 (wndPtr
->hwndSelf
, hdc
);
1681 // << TOOLBAR_SetInsertMark >>
1685 TOOLBAR_SetInsertMarkColor (WND
*wndPtr
, WPARAM32 wParam
, LPARAM lParam
)
1687 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr(wndPtr
);
1689 infoPtr
->clrInsertMark
= (COLORREF
)lParam
;
1691 /* FIXME : redraw ??*/
1698 TOOLBAR_SetMaxTextRows (WND
*wndPtr
, WPARAM32 wParam
, LPARAM lParam
)
1700 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr(wndPtr
);
1702 if (infoPtr
== NULL
)
1705 infoPtr
->nMaxTextRows
= (INT32
)wParam
;
1711 // << TOOLBAR_SetPadding >>
1715 TOOLBAR_SetParent (WND
*wndPtr
, WPARAM32 wParam
, LPARAM lParam
)
1717 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr(wndPtr
);
1718 HWND32 hwndOldNotify
;
1720 if (infoPtr
== NULL
) return 0;
1721 hwndOldNotify
= infoPtr
->hwndNotify
;
1722 infoPtr
->hwndNotify
= (HWND32
)wParam
;
1724 return hwndOldNotify
;
1729 TOOLBAR_SetRows (WND
*wndPtr
, WPARAM32 wParam
, LPARAM lParam
)
1731 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr(wndPtr
);
1733 FIXME (toolbar
, "support multiple rows!\n");
1740 TOOLBAR_SetState (WND
*wndPtr
, WPARAM32 wParam
, LPARAM lParam
)
1742 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr(wndPtr
);
1743 TBUTTON_INFO
*btnPtr
;
1747 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT32
)wParam
);
1751 btnPtr
= &infoPtr
->buttons
[nIndex
];
1752 btnPtr
->fsState
= LOWORD(lParam
);
1754 hdc
= GetDC32 (wndPtr
->hwndSelf
);
1755 TOOLBAR_DrawButton (wndPtr
, btnPtr
, hdc
);
1756 ReleaseDC32 (wndPtr
->hwndSelf
, hdc
);
1763 TOOLBAR_SetStyle (WND
*wndPtr
, WPARAM32 wParam
, LPARAM lParam
)
1765 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr(wndPtr
);
1766 TBUTTON_INFO
*btnPtr
;
1770 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT32
)wParam
);
1774 btnPtr
= &infoPtr
->buttons
[nIndex
];
1775 btnPtr
->fsStyle
= LOWORD(lParam
);
1777 hdc
= GetDC32 (wndPtr
->hwndSelf
);
1778 TOOLBAR_DrawButton (wndPtr
, btnPtr
, hdc
);
1779 ReleaseDC32 (wndPtr
->hwndSelf
, hdc
);
1781 if (infoPtr
->hwndToolTip
) {
1783 FIXME (toolbar
, "change tool tip!\n");
1792 TOOLBAR_SetToolTips (WND
*wndPtr
, WPARAM32 wParam
, LPARAM lParam
)
1794 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr(wndPtr
);
1796 if (infoPtr
== NULL
) return 0;
1797 infoPtr
->hwndToolTip
= (HWND32
)wParam
;
1803 TOOLBAR_SetUnicodeFormat (WND
*wndPtr
, WPARAM32 wParam
, LPARAM lParam
)
1805 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr(wndPtr
);
1808 TRACE (toolbar
, "%s hwnd=0x%04x stub!\n",
1809 ((BOOL32
)wParam
) ? "TRUE" : "FALSE", wndPtr
->hwndSelf
);
1811 bTemp
= infoPtr
->bUnicode
;
1812 infoPtr
->bUnicode
= (BOOL32
)wParam
;
1819 TOOLBAR_Create (WND
*wndPtr
, WPARAM32 wParam
, LPARAM lParam
)
1821 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr(wndPtr
);
1824 /* initialize info structure */
1825 infoPtr
->nButtonHeight
= 22;
1826 infoPtr
->nButtonWidth
= 23;
1827 infoPtr
->nBitmapHeight
= 15;
1828 infoPtr
->nBitmapWidth
= 16;
1830 infoPtr
->nHeight
= infoPtr
->nButtonHeight
+ TOP_BORDER
+ BOTTOM_BORDER
;
1831 infoPtr
->nMaxRows
= 1;
1832 infoPtr
->nMaxTextRows
= 1;
1833 infoPtr
->cxMin
= -1;
1834 infoPtr
->cxMax
= -1;
1836 infoPtr
->bCaptured
= FALSE
;
1837 infoPtr
->bUnicode
= FALSE
;
1838 infoPtr
->nButtonDown
= -1;
1839 infoPtr
->nOldHit
= -1;
1841 infoPtr
->hwndNotify
= GetParent32 (wndPtr
->hwndSelf
);
1842 infoPtr
->bTransparent
= (wndPtr
->dwStyle
& TBSTYLE_FLAT
);
1843 infoPtr
->nHotItem
= -1;
1845 SystemParametersInfo32A (SPI_GETICONTITLELOGFONT
, 0, &logFont
, 0);
1846 infoPtr
->hFont
= CreateFontIndirect32A (&logFont
);
1848 if (wndPtr
->dwStyle
& TBSTYLE_TOOLTIPS
) {
1849 /* Create tooltip control */
1850 infoPtr
->hwndToolTip
=
1851 CreateWindowEx32A (0, TOOLTIPS_CLASS32A
, NULL
, TTS_ALWAYSTIP
,
1852 CW_USEDEFAULT32
, CW_USEDEFAULT32
,
1853 CW_USEDEFAULT32
, CW_USEDEFAULT32
,
1854 wndPtr
->hwndSelf
, 0, 0, 0);
1856 /* Send NM_TOOLTIPSCREATED notification */
1857 if (infoPtr
->hwndToolTip
) {
1858 NMTOOLTIPSCREATED nmttc
;
1860 nmttc
.hdr
.hwndFrom
= wndPtr
->hwndSelf
;
1861 nmttc
.hdr
.idFrom
= wndPtr
->wIDmenu
;
1862 nmttc
.hdr
.code
= NM_TOOLTIPSCREATED
;
1863 nmttc
.hwndToolTips
= infoPtr
->hwndToolTip
;
1865 SendMessage32A (infoPtr
->hwndNotify
, WM_NOTIFY
,
1866 (WPARAM32
)wndPtr
->wIDmenu
, (LPARAM
)&nmttc
);
1875 TOOLBAR_Destroy (WND
*wndPtr
, WPARAM32 wParam
, LPARAM lParam
)
1877 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr(wndPtr
);
1879 /* delete tooltip control */
1880 if (infoPtr
->hwndToolTip
)
1881 DestroyWindow32 (infoPtr
->hwndToolTip
);
1883 /* delete button data */
1884 if (infoPtr
->buttons
)
1885 HeapFree (GetProcessHeap (), 0, infoPtr
->buttons
);
1887 /* delete strings */
1888 if (infoPtr
->strings
) {
1890 for (i
= 0; i
< infoPtr
->nNumStrings
; i
++)
1891 if (infoPtr
->strings
[i
])
1892 HeapFree (GetProcessHeap (), 0, infoPtr
->strings
[i
]);
1894 HeapFree (GetProcessHeap (), 0, infoPtr
->strings
);
1897 /* destroy default image list */
1898 if (infoPtr
->himlDef
)
1899 ImageList_Destroy (infoPtr
->himlDef
);
1901 /* destroy disabled image list */
1902 if (infoPtr
->himlDis
)
1903 ImageList_Destroy (infoPtr
->himlDis
);
1905 /* destroy hot image list */
1906 if (infoPtr
->himlHot
)
1907 ImageList_Destroy (infoPtr
->himlHot
);
1909 /* delete default font */
1911 DeleteObject32 (infoPtr
->hFont
);
1913 /* free toolbar info data */
1914 HeapFree (GetProcessHeap (), 0, infoPtr
);
1921 TOOLBAR_EraseBackground (WND
*wndPtr
, WPARAM32 wParam
, LPARAM lParam
)
1923 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr(wndPtr
);
1925 if (infoPtr
->bTransparent
)
1926 return SendMessage32A (GetParent32 (wndPtr
->hwndSelf
), WM_ERASEBKGND
,
1929 return DefWindowProc32A (wndPtr
->hwndSelf
, WM_ERASEBKGND
, wParam
, lParam
);
1934 TOOLBAR_LButtonDblClk (WND
*wndPtr
, WPARAM32 wParam
, LPARAM lParam
)
1936 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr(wndPtr
);
1937 TBUTTON_INFO
*btnPtr
;
1942 pt
.x
= (INT32
)LOWORD(lParam
);
1943 pt
.y
= (INT32
)HIWORD(lParam
);
1944 nHit
= TOOLBAR_InternalHitTest (wndPtr
, &pt
);
1947 btnPtr
= &infoPtr
->buttons
[nHit
];
1948 if (!(btnPtr
->fsState
& TBSTATE_ENABLED
))
1950 SetCapture32 (wndPtr
->hwndSelf
);
1951 infoPtr
->bCaptured
= TRUE
;
1952 infoPtr
->nButtonDown
= nHit
;
1954 btnPtr
->fsState
|= TBSTATE_PRESSED
;
1956 hdc
= GetDC32 (wndPtr
->hwndSelf
);
1957 TOOLBAR_DrawButton (wndPtr
, btnPtr
, hdc
);
1958 ReleaseDC32 (wndPtr
->hwndSelf
, hdc
);
1960 else if (wndPtr
->dwStyle
& CCS_ADJUSTABLE
)
1961 TOOLBAR_Customize (wndPtr
);
1968 TOOLBAR_LButtonDown (WND
*wndPtr
, WPARAM32 wParam
, LPARAM lParam
)
1970 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr(wndPtr
);
1971 TBUTTON_INFO
*btnPtr
;
1976 if (infoPtr
->hwndToolTip
)
1977 TOOLBAR_RelayEvent (infoPtr
->hwndToolTip
, wndPtr
->hwndSelf
,
1978 WM_LBUTTONDOWN
, wParam
, lParam
);
1980 pt
.x
= (INT32
)LOWORD(lParam
);
1981 pt
.y
= (INT32
)HIWORD(lParam
);
1982 nHit
= TOOLBAR_InternalHitTest (wndPtr
, &pt
);
1985 btnPtr
= &infoPtr
->buttons
[nHit
];
1986 if (!(btnPtr
->fsState
& TBSTATE_ENABLED
))
1989 SetCapture32 (wndPtr
->hwndSelf
);
1990 infoPtr
->bCaptured
= TRUE
;
1991 infoPtr
->nButtonDown
= nHit
;
1992 infoPtr
->nOldHit
= nHit
;
1994 btnPtr
->fsState
|= TBSTATE_PRESSED
;
1996 hdc
= GetDC32 (wndPtr
->hwndSelf
);
1997 TOOLBAR_DrawButton (wndPtr
, btnPtr
, hdc
);
1998 ReleaseDC32 (wndPtr
->hwndSelf
, hdc
);
2007 TOOLBAR_LButtonUp (WND
*wndPtr
, WPARAM32 wParam
, LPARAM lParam
)
2009 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr(wndPtr
);
2010 TBUTTON_INFO
*btnPtr
;
2013 INT32 nOldIndex
= -1;
2015 BOOL32 bSendMessage
= TRUE
;
2017 if (infoPtr
->hwndToolTip
)
2018 TOOLBAR_RelayEvent (infoPtr
->hwndToolTip
, wndPtr
->hwndSelf
,
2019 WM_LBUTTONUP
, wParam
, lParam
);
2021 pt
.x
= (INT32
)LOWORD(lParam
);
2022 pt
.y
= (INT32
)HIWORD(lParam
);
2023 nHit
= TOOLBAR_InternalHitTest (wndPtr
, &pt
);
2025 if ((infoPtr
->bCaptured
) && (infoPtr
->nButtonDown
>= 0)) {
2026 infoPtr
->bCaptured
= FALSE
;
2028 btnPtr
= &infoPtr
->buttons
[infoPtr
->nButtonDown
];
2029 btnPtr
->fsState
&= ~TBSTATE_PRESSED
;
2031 if (nHit
== infoPtr
->nButtonDown
) {
2032 if (btnPtr
->fsStyle
& TBSTYLE_CHECK
) {
2033 if (btnPtr
->fsStyle
& TBSTYLE_GROUP
) {
2034 nOldIndex
= TOOLBAR_GetCheckedGroupButtonIndex (infoPtr
,
2035 infoPtr
->nButtonDown
);
2036 if (nOldIndex
== infoPtr
->nButtonDown
)
2037 bSendMessage
= FALSE
;
2038 if ((nOldIndex
!= infoPtr
->nButtonDown
) &&
2040 infoPtr
->buttons
[nOldIndex
].fsState
&= ~TBSTATE_CHECKED
;
2041 btnPtr
->fsState
|= TBSTATE_CHECKED
;
2044 if (btnPtr
->fsState
& TBSTATE_CHECKED
)
2045 btnPtr
->fsState
&= ~TBSTATE_CHECKED
;
2047 btnPtr
->fsState
|= TBSTATE_CHECKED
;
2052 bSendMessage
= FALSE
;
2054 hdc
= GetDC32 (wndPtr
->hwndSelf
);
2055 if (nOldIndex
!= -1)
2056 TOOLBAR_DrawButton (wndPtr
, &infoPtr
->buttons
[nOldIndex
], hdc
);
2057 TOOLBAR_DrawButton (wndPtr
, btnPtr
, hdc
);
2058 ReleaseDC32 (wndPtr
->hwndSelf
, hdc
);
2061 SendMessage32A (infoPtr
->hwndNotify
, WM_COMMAND
,
2062 MAKEWPARAM(btnPtr
->idCommand
, 0),
2063 (LPARAM
)wndPtr
->hwndSelf
);
2065 infoPtr
->nButtonDown
= -1;
2066 infoPtr
->nOldHit
= -1;
2074 TOOLBAR_MouseMove (WND
*wndPtr
, WPARAM32 wParam
, LPARAM lParam
)
2076 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr(wndPtr
);
2077 TBUTTON_INFO
*btnPtr
;
2082 if (infoPtr
->hwndToolTip
)
2083 TOOLBAR_RelayEvent (infoPtr
->hwndToolTip
, wndPtr
->hwndSelf
,
2084 WM_MOUSEMOVE
, wParam
, lParam
);
2086 pt
.x
= (INT32
)LOWORD(lParam
);
2087 pt
.y
= (INT32
)HIWORD(lParam
);
2088 nHit
= TOOLBAR_InternalHitTest (wndPtr
, &pt
);
2090 if (infoPtr
->bCaptured
) {
2091 if (infoPtr
->nOldHit
!= nHit
) {
2092 btnPtr
= &infoPtr
->buttons
[infoPtr
->nButtonDown
];
2093 if (infoPtr
->nOldHit
== infoPtr
->nButtonDown
) {
2094 btnPtr
->fsState
&= ~TBSTATE_PRESSED
;
2095 hdc
= GetDC32 (wndPtr
->hwndSelf
);
2096 TOOLBAR_DrawButton (wndPtr
, btnPtr
, hdc
);
2097 ReleaseDC32 (wndPtr
->hwndSelf
, hdc
);
2099 else if (nHit
== infoPtr
->nButtonDown
) {
2100 btnPtr
->fsState
|= TBSTATE_PRESSED
;
2101 hdc
= GetDC32 (wndPtr
->hwndSelf
);
2102 TOOLBAR_DrawButton (wndPtr
, btnPtr
, hdc
);
2103 ReleaseDC32 (wndPtr
->hwndSelf
, hdc
);
2106 infoPtr
->nOldHit
= nHit
;
2113 // << TOOLBAR_NCActivate >>
2117 TOOLBAR_NCCalcSize (WND
*wndPtr
, WPARAM32 wParam
, LPARAM lParam
)
2119 if (!(wndPtr
->dwStyle
& CCS_NODIVIDER
)) {
2120 LPRECT32 winRect
= (LPRECT32
)lParam
;
2124 return DefWindowProc32A (wndPtr
->hwndSelf
, WM_NCCALCSIZE
, wParam
, lParam
);
2129 TOOLBAR_NCCreate (WND
*wndPtr
, WPARAM32 wParam
, LPARAM lParam
)
2131 TOOLBAR_INFO
*infoPtr
;
2133 /* allocate memory for info structure */
2134 infoPtr
= (TOOLBAR_INFO
*)HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY
,
2135 sizeof(TOOLBAR_INFO
));
2136 wndPtr
->wExtra
[0] = (DWORD
)infoPtr
;
2138 if (infoPtr
== NULL
) {
2139 ERR (toolbar
, "could not allocate info memory!\n");
2143 if ((TOOLBAR_INFO
*)wndPtr
->wExtra
[0] != infoPtr
) {
2144 ERR (toolbar
, "pointer assignment error!\n");
2149 infoPtr
->dwStructSize
= sizeof(TBBUTTON
);
2151 /* fix instance handle, if the toolbar was created by CreateToolbarEx() */
2152 if (!wndPtr
->hInstance
)
2153 wndPtr
->hInstance
= wndPtr
->parent
->hInstance
;
2155 return DefWindowProc32A (wndPtr
->hwndSelf
, WM_NCCREATE
, wParam
, lParam
);
2160 TOOLBAR_NCPaint (WND
*wndPtr
, WPARAM32 wParam
, LPARAM lParam
)
2164 HWND32 hwnd
= wndPtr
->hwndSelf
;
2166 if ( wndPtr
->dwStyle
& WS_MINIMIZE
||
2167 !WIN_IsWindowDrawable( wndPtr
, 0 )) return 0; /* Nothing to do */
2169 DefWindowProc32A (hwnd
, WM_NCPAINT
, wParam
, lParam
);
2171 if (!(hdc
= GetDCEx32( hwnd
, 0, DCX_USESTYLE
| DCX_WINDOW
))) return 0;
2173 if (ExcludeVisRect( hdc
, wndPtr
->rectClient
.left
-wndPtr
->rectWindow
.left
,
2174 wndPtr
->rectClient
.top
-wndPtr
->rectWindow
.top
,
2175 wndPtr
->rectClient
.right
-wndPtr
->rectWindow
.left
,
2176 wndPtr
->rectClient
.bottom
-wndPtr
->rectWindow
.top
)
2178 ReleaseDC32( hwnd
, hdc
);
2182 if (!(wndPtr
->flags
& WIN_MANAGED
)) {
2183 if (!(wndPtr
->dwStyle
& CCS_NODIVIDER
)) {
2184 rect
.left
= wndPtr
->rectClient
.left
;
2185 rect
.top
= wndPtr
->rectClient
.top
- 2;
2186 rect
.right
= wndPtr
->rectClient
.right
;
2188 SelectObject32 ( hdc
, GetSysColorPen32 (COLOR_3DSHADOW
));
2189 MoveToEx32 (hdc
, rect
.left
, rect
.top
, NULL
);
2190 LineTo32 (hdc
, rect
.right
, rect
.top
);
2192 SelectObject32 ( hdc
, GetSysColorPen32 (COLOR_3DHILIGHT
));
2193 MoveToEx32 (hdc
, rect
.left
, rect
.top
, NULL
);
2194 LineTo32 (hdc
, rect
.right
, rect
.top
);
2199 ReleaseDC32( hwnd
, hdc
);
2205 __inline__
static LRESULT
2206 TOOLBAR_Notify (WND
*wndPtr
, WPARAM32 wParam
, LPARAM lParam
)
2208 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr(wndPtr
);
2209 LPNMHDR lpnmh
= (LPNMHDR
)lParam
;
2211 TRACE (toolbar
, "passing WM_NOTIFY!\n");
2213 if ((infoPtr
->hwndToolTip
) && (lpnmh
->hwndFrom
== infoPtr
->hwndToolTip
)) {
2214 SendMessage32A (infoPtr
->hwndNotify
, WM_NOTIFY
, wParam
, lParam
);
2217 if (lpnmh
->code
== TTN_GETDISPINFO32A
) {
2218 LPNMTTDISPINFO32A lpdi
= (LPNMTTDISPINFO32A
)lParam
;
2220 FIXME (toolbar
, "retrieving ASCII string\n");
2223 else if (lpnmh
->code
== TTN_GETDISPINFO32W
) {
2224 LPNMTTDISPINFO32W lpdi
= (LPNMTTDISPINFO32W
)lParam
;
2226 FIXME (toolbar
, "retrieving UNICODE string\n");
2237 TOOLBAR_Paint (WND
*wndPtr
, WPARAM32 wParam
)
2242 hdc
= wParam
==0 ? BeginPaint32 (wndPtr
->hwndSelf
, &ps
) : (HDC32
)wParam
;
2243 TOOLBAR_Refresh (wndPtr
, hdc
);
2245 EndPaint32 (wndPtr
->hwndSelf
, &ps
);
2251 TOOLBAR_Size (WND
*wndPtr
, WPARAM32 wParam
, LPARAM lParam
)
2253 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr(wndPtr
);
2258 UINT32 uPosFlags
= 0;
2260 /* Resize deadlock check */
2261 if (infoPtr
->bAutoSize
) {
2262 infoPtr
->bAutoSize
= FALSE
;
2266 flags
= (INT32
) wParam
;
2268 /* FIXME for flags =
2269 * SIZE_MAXIMIZED, SIZE_MAXSHOW, SIZE_MINIMIZED
2272 TRACE (toolbar
, "sizing toolbar!\n");
2274 if (flags
== SIZE_RESTORED
) {
2275 /* width and height don't apply */
2276 parent
= GetParent32 (wndPtr
->hwndSelf
);
2277 GetClientRect32(parent
, &parent_rect
);
2279 if (wndPtr
->dwStyle
& CCS_NORESIZE
) {
2280 uPosFlags
|= SWP_NOSIZE
;
2283 // infoPtr->nWidth = parent_rect.right - parent_rect.left;
2284 cy
= infoPtr
->nHeight
;
2285 cx
= infoPtr
->nWidth
;
2286 TOOLBAR_CalcToolbar (wndPtr
);
2287 infoPtr
->nWidth
= cx
;
2288 infoPtr
->nHeight
= cy
;
2291 infoPtr
->nWidth
= parent_rect
.right
- parent_rect
.left
;
2292 TOOLBAR_CalcToolbar (wndPtr
);
2293 cy
= infoPtr
->nHeight
;
2294 cx
= infoPtr
->nWidth
;
2297 if (wndPtr
->dwStyle
& CCS_NOPARENTALIGN
) {
2298 uPosFlags
|= SWP_NOMOVE
;
2299 cy
= infoPtr
->nHeight
;
2300 cx
= infoPtr
->nWidth
;
2303 if (!(wndPtr
->dwStyle
& CCS_NODIVIDER
))
2306 SetWindowPos32 (wndPtr
->hwndSelf
, 0, parent_rect
.left
, parent_rect
.top
,
2307 cx
, cy
, uPosFlags
| SWP_NOZORDER
);
2319 ToolbarWindowProc (HWND32 hwnd
, UINT32 uMsg
, WPARAM32 wParam
, LPARAM lParam
)
2321 WND
*wndPtr
= WIN_FindWndPtr(hwnd
);
2326 return TOOLBAR_AddBitmap (wndPtr
, wParam
, lParam
);
2328 case TB_ADDBUTTONS32A
:
2329 return TOOLBAR_AddButtons32A (wndPtr
, wParam
, lParam
);
2331 // case TB_ADDBUTTONS32W:
2333 case TB_ADDSTRING32A
:
2334 return TOOLBAR_AddString32A (wndPtr
, wParam
, lParam
);
2336 // case TB_ADDSTRING32W:
2339 return TOOLBAR_AutoSize (wndPtr
, wParam
, lParam
);
2341 case TB_BUTTONCOUNT
:
2342 return TOOLBAR_ButtonCount (wndPtr
, wParam
, lParam
);
2344 case TB_BUTTONSTRUCTSIZE
:
2345 return TOOLBAR_ButtonStructSize (wndPtr
, wParam
, lParam
);
2347 case TB_CHANGEBITMAP
:
2348 return TOOLBAR_ChangeBitmap (wndPtr
, wParam
, lParam
);
2350 case TB_CHECKBUTTON
:
2351 return TOOLBAR_CheckButton (wndPtr
, wParam
, lParam
);
2353 case TB_COMMANDTOINDEX
:
2354 return TOOLBAR_CommandToIndex (wndPtr
, wParam
, lParam
);
2357 return TOOLBAR_Customize (wndPtr
);
2359 case TB_DELETEBUTTON
:
2360 return TOOLBAR_DeleteButton (wndPtr
, wParam
, lParam
);
2362 case TB_ENABLEBUTTON
:
2363 return TOOLBAR_EnableButton (wndPtr
, wParam
, lParam
);
2365 // case TB_GETANCHORHIGHLIGHT: /* 4.71 */
2368 return TOOLBAR_GetBitmap (wndPtr
, wParam
, lParam
);
2370 case TB_GETBITMAPFLAGS
:
2371 return TOOLBAR_GetBitmapFlags (wndPtr
, wParam
, lParam
);
2374 return TOOLBAR_GetButton (wndPtr
, wParam
, lParam
);
2376 case TB_GETBUTTONINFO32A
:
2377 return TOOLBAR_GetButtonInfo32A (wndPtr
, wParam
, lParam
);
2379 // case TB_GETBUTTONINFO32W: /* 4.71 */
2381 case TB_GETBUTTONSIZE
:
2382 return TOOLBAR_GetButtonSize (wndPtr
);
2384 case TB_GETBUTTONTEXT32A
:
2385 return TOOLBAR_GetButtonText32A (wndPtr
, wParam
, lParam
);
2387 // case TB_GETBUTTONTEXT32W:
2388 // case TB_GETCOLORSCHEME: /* 4.71 */
2390 case TB_GETDISABLEDIMAGELIST
:
2391 return TOOLBAR_GetDisabledImageList (wndPtr
, wParam
, lParam
);
2393 case TB_GETEXTENDEDSTYLE
:
2394 return TOOLBAR_GetExtendedStyle (wndPtr
);
2396 case TB_GETHOTIMAGELIST
:
2397 return TOOLBAR_GetHotImageList (wndPtr
, wParam
, lParam
);
2399 // case TB_GETHOTITEM: /* 4.71 */
2401 case TB_GETIMAGELIST
:
2402 return TOOLBAR_GetImageList (wndPtr
, wParam
, lParam
);
2404 // case TB_GETINSERTMARK: /* 4.71 */
2405 // case TB_GETINSERTMARKCOLOR: /* 4.71 */
2407 case TB_GETITEMRECT
:
2408 return TOOLBAR_GetItemRect (wndPtr
, wParam
, lParam
);
2411 return TOOLBAR_GetMaxSize (wndPtr
, wParam
, lParam
);
2413 // case TB_GETOBJECT: /* 4.71 */
2414 // case TB_GETPADDING: /* 4.71 */
2417 return TOOLBAR_GetRect (wndPtr
, wParam
, lParam
);
2420 return TOOLBAR_GetRows (wndPtr
, wParam
, lParam
);
2423 return TOOLBAR_GetState (wndPtr
, wParam
, lParam
);
2426 return TOOLBAR_GetStyle (wndPtr
, wParam
, lParam
);
2428 case TB_GETTEXTROWS
:
2429 return TOOLBAR_GetTextRows (wndPtr
, wParam
, lParam
);
2431 case TB_GETTOOLTIPS
:
2432 return TOOLBAR_GetToolTips (wndPtr
, wParam
, lParam
);
2434 case TB_GETUNICODEFORMAT
:
2435 return TOOLBAR_GetUnicodeFormat (wndPtr
, wParam
, lParam
);
2438 return TOOLBAR_HideButton (wndPtr
, wParam
, lParam
);
2441 return TOOLBAR_HitTest (wndPtr
, wParam
, lParam
);
2443 case TB_INDETERMINATE
:
2444 return TOOLBAR_Indeterminate (wndPtr
, wParam
, lParam
);
2446 case TB_INSERTBUTTON32A
:
2447 return TOOLBAR_InsertButton32A (wndPtr
, wParam
, lParam
);
2449 // case TB_INSERTBUTTON32W:
2450 // case TB_INSERTMARKHITTEST: /* 4.71 */
2452 case TB_ISBUTTONCHECKED
:
2453 return TOOLBAR_IsButtonChecked (wndPtr
, wParam
, lParam
);
2455 case TB_ISBUTTONENABLED
:
2456 return TOOLBAR_IsButtonEnabled (wndPtr
, wParam
, lParam
);
2458 case TB_ISBUTTONHIDDEN
:
2459 return TOOLBAR_IsButtonHidden (wndPtr
, wParam
, lParam
);
2461 case TB_ISBUTTONHIGHLIGHTED
:
2462 return TOOLBAR_IsButtonHighlighted (wndPtr
, wParam
, lParam
);
2464 case TB_ISBUTTONINDETERMINATE
:
2465 return TOOLBAR_IsButtonIndeterminate (wndPtr
, wParam
, lParam
);
2467 case TB_ISBUTTONPRESSED
:
2468 return TOOLBAR_IsButtonPressed (wndPtr
, wParam
, lParam
);
2470 // case TB_LOADIMAGES: /* 4.70 */
2471 // case TB_MAPACCELERATOR32A: /* 4.71 */
2472 // case TB_MAPACCELERATOR32W: /* 4.71 */
2473 // case TB_MARKBUTTON: /* 4.71 */
2474 // case TB_MOVEBUTTON: /* 4.71 */
2476 case TB_PRESSBUTTON
:
2477 return TOOLBAR_PressButton (wndPtr
, wParam
, lParam
);
2479 // case TB_REPLACEBITMAP:
2481 case TB_SAVERESTORE32A
:
2482 return TOOLBAR_SaveRestore32A (wndPtr
, wParam
, lParam
);
2484 // case TB_SAVERESTORE32W:
2485 // case TB_SETANCHORHIGHLIGHT: /* 4.71 */
2487 case TB_SETBITMAPSIZE
:
2488 return TOOLBAR_SetBitmapSize (wndPtr
, wParam
, lParam
);
2490 // case TB_SETBUTTONINFO32A: /* 4.71 */
2491 // case TB_SETBUTTONINFO32W: /* 4.71 */
2493 case TB_SETBUTTONSIZE
:
2494 return TOOLBAR_SetButtonSize (wndPtr
, wParam
, lParam
);
2496 case TB_SETBUTTONWIDTH
:
2497 return TOOLBAR_SetButtonWidth (wndPtr
, wParam
, lParam
);
2500 return TOOLBAR_SetCmdId (wndPtr
, wParam
, lParam
);
2502 // case TB_SETCOLORSCHEME: /* 4.71 */
2504 case TB_SETDISABLEDIMAGELIST
:
2505 return TOOLBAR_SetDisabledImageList (wndPtr
, wParam
, lParam
);
2507 // case TB_SETDRAWTEXTFLAGS: /* 4.71 */
2509 case TB_SETEXTENDEDSTYLE
:
2510 return TOOLBAR_SetExtendedStyle (wndPtr
, wParam
, lParam
);
2512 case TB_SETHOTIMAGELIST
:
2513 return TOOLBAR_SetHotImageList (wndPtr
, wParam
, lParam
);
2515 // case TB_SETHOTITEM: /* 4.71 */
2517 case TB_SETIMAGELIST
:
2518 return TOOLBAR_SetImageList (wndPtr
, wParam
, lParam
);
2521 return TOOLBAR_SetIndent (wndPtr
, wParam
, lParam
);
2523 // case TB_SETINSERTMARK: /* 4.71 */
2525 case TB_SETINSERTMARKCOLOR
:
2526 return TOOLBAR_SetInsertMarkColor (wndPtr
, wParam
, lParam
);
2528 case TB_SETMAXTEXTROWS
:
2529 return TOOLBAR_SetMaxTextRows (wndPtr
, wParam
, lParam
);
2531 // case TB_SETPADDING: /* 4.71 */
2534 return TOOLBAR_SetParent (wndPtr
, wParam
, lParam
);
2537 return TOOLBAR_SetRows (wndPtr
, wParam
, lParam
);
2540 return TOOLBAR_SetState (wndPtr
, wParam
, lParam
);
2543 return TOOLBAR_SetStyle (wndPtr
, wParam
, lParam
);
2545 case TB_SETTOOLTIPS
:
2546 return TOOLBAR_SetToolTips (wndPtr
, wParam
, lParam
);
2548 case TB_SETUNICODEFORMAT
:
2549 return TOOLBAR_SetUnicodeFormat (wndPtr
, wParam
, lParam
);
2555 return TOOLBAR_Create (wndPtr
, wParam
, lParam
);
2560 return TOOLBAR_Destroy (wndPtr
, wParam
, lParam
);
2563 return TOOLBAR_EraseBackground (wndPtr
, wParam
, lParam
);
2567 // case WM_KILLFOCUS:
2569 case WM_LBUTTONDBLCLK
:
2570 return TOOLBAR_LButtonDblClk (wndPtr
, wParam
, lParam
);
2572 case WM_LBUTTONDOWN
:
2573 return TOOLBAR_LButtonDown (wndPtr
, wParam
, lParam
);
2576 return TOOLBAR_LButtonUp (wndPtr
, wParam
, lParam
);
2579 return TOOLBAR_MouseMove (wndPtr
, wParam
, lParam
);
2581 // case WM_NCACTIVATE:
2582 // return TOOLBAR_NCActivate (wndPtr, wParam, lParam);
2585 return TOOLBAR_NCCalcSize (wndPtr
, wParam
, lParam
);
2588 return TOOLBAR_NCCreate (wndPtr
, wParam
, lParam
);
2591 return TOOLBAR_NCPaint (wndPtr
, wParam
, lParam
);
2594 return TOOLBAR_Notify (wndPtr
, wParam
, lParam
);
2596 // case WM_NOTIFYFORMAT:
2599 return TOOLBAR_Paint (wndPtr
, wParam
);
2602 return TOOLBAR_Size (wndPtr
, wParam
, lParam
);
2604 // case WM_SYSCOLORCHANGE:
2606 // case WM_WININICHANGE:
2611 case WM_MEASUREITEM
:
2613 return SendMessage32A (GetParent32 (hwnd
), uMsg
, wParam
, lParam
);
2616 if (uMsg
>= WM_USER
)
2617 ERR (toolbar
, "unknown msg %04x wp=%08x lp=%08lx\n",
2618 uMsg
, wParam
, lParam
);
2619 return DefWindowProc32A (hwnd
, uMsg
, wParam
, lParam
);
2625 void TOOLBAR_Register (void)
2627 WNDCLASS32A wndClass
;
2629 if (GlobalFindAtom32A (TOOLBARCLASSNAME32A
)) return;
2631 ZeroMemory (&wndClass
, sizeof(WNDCLASS32A
));
2632 wndClass
.style
= CS_GLOBALCLASS
| CS_DBLCLKS
;
2633 wndClass
.lpfnWndProc
= (WNDPROC32
)ToolbarWindowProc
;
2634 wndClass
.cbClsExtra
= 0;
2635 wndClass
.cbWndExtra
= sizeof(TOOLBAR_INFO
*);
2636 wndClass
.hCursor
= LoadCursor32A (0, IDC_ARROW32A
);
2637 wndClass
.hbrBackground
= (HBRUSH32
)(COLOR_3DFACE
+ 1);
2638 wndClass
.lpszClassName
= TOOLBARCLASSNAME32A
;
2640 RegisterClass32A (&wndClass
);