77 #include "wine/unicode.h" 203 #define SEPARATOR_WIDTH 8 205 #define BOTTOM_BORDER 2 206 #define DDARROW_WIDTH 11 207 #define ARROW_HEIGHT 3 208 #define INSERTMARK_WIDTH 2 216 #define DEFSPACE_CX 7 217 #define DEFSPACE_CY 6 230 #define NONLIST_NOTEXT_OFFSET 2 232 #define TOOLBAR_NOWHERE (-1) 235 #define TBSTYLE_EX_ALL (TBSTYLE_EX_DRAWDDARROWS | \ 236 TBSTYLE_EX_VERTICAL | \ 237 TBSTYLE_EX_MIXEDBUTTONS | \ 238 TBSTYLE_EX_DOUBLEBUFFER | \ 239 TBSTYLE_EX_HIDECLIPPEDBUTTONS) 242 #define COMMON_STYLES (CCS_TOP|CCS_NOMOVEY|CCS_BOTTOM|CCS_NORESIZE| \ 243 CCS_NOPARENTALIGN|CCS_ADJUSTABLE|CCS_NODIVIDER|CCS_VERT) 245 #define GETIBITMAP(infoPtr, i) (infoPtr->iVersion >= 5 ? LOWORD(i) : i) 246 #define GETHIMLID(infoPtr, i) (infoPtr->iVersion >= 5 ? HIWORD(i) : 0) 247 #define GETDEFIMAGELIST(infoPtr, id) TOOLBAR_GetImageList(infoPtr->himlDef, infoPtr->cimlDef, id) 248 #define GETHOTIMAGELIST(infoPtr, id) TOOLBAR_GetImageList(infoPtr->himlHot, infoPtr->cimlHot, id) 249 #define GETDISIMAGELIST(infoPtr, id) TOOLBAR_GetImageList(infoPtr->himlDis, infoPtr->cimlDis, id) 273 return infoPtr->szBarPadding.cy;
306 TRACE(
"TBBUTTON: id %d, bitmap=%d, state=%02x, style=%02x, data=%p, stringid=%p (%s)\n", tbb->
idCommand,
315 TRACE(
"button %d id %d, bitmap=%d, state=%02x, style=%02x, data=%08lx, stringid=0x%08lx\n",
319 TRACE(
"button %d id %d, hot=%s, row=%d, rect=(%s)\n",
332 TRACE(
"toolbar %p at line %d, exStyle=%08x, buttons=%d, bitmaps=%d, strings=%d, style=%08x\n",
336 TRACE(
"toolbar %p at line %d, himlInt=%p, himlDef=%p, himlHot=%p, himlDis=%p, redrawable=%s\n",
394 FIXME(
"[%p] TBSTYLE_REGISTERDROP not implemented\n", infoPtr->
hwndSelf);
409 (infoPtr->
bUnicode) ?
"via Unicode" :
"via ANSI");
431 memset(&nmgd, 0,
sizeof(nmgd));
441 TRACE(
"TBN_GETDISPINFO returned bitmap id %d, mask=%08x, nNumBitmaps=%d\n",
490 WARN(
"bitmap for ID %d, index %d is not valid, number of bitmaps in imagelist: %d\n",
498 ERR(
"TBN_GETDISPINFO returned invalid index %d\n",
516 FIXME(
"Shouldn't reach here\n");
520 TRACE(
"no image list\n");
647 DWORD dwDTFlags2 = 0;
654 dwDTFlags2 = DTT_GRAYED;
728 HDC hdcMask, hdcImage;
737 RGB(0xff, 0xff, 0xff),
RGB(0,0,0), draw_flags);
807 if (bm.bmBitsPixel == 32)
809 draw_desaturated =
TRUE;
844 TRACE(
"drawing index=%d, himl=%p, left=%d, top=%d, offset=%d\n",
852 else if (draw_desaturated)
857 imldp.
cbSize =
sizeof(imldp);
888 BOOL pressed_look = !non_interactive_state &&
918 BOOL pressed = bDropDownPressed ||
957 BOOL drawSepDropDownArrow = hasDropDownArrow &&
959 RECT rc, rcArrow, rcBitmap, rcText;
965 DWORD dwItemCustDraw;
997 FIXME(
"Draw some kind of separator: fsStyle=%x\n",
1006 if (hasDropDownArrow)
1015 if (drawSepDropDownArrow)
1018 rcArrow.left =
right;
1039 rcBitmap.left += ((rc.right - rc.left) - infoPtr->
nBitmapWidth) / 2;
1043 rcBitmap.top += infoPtr->themeMargins.cyTopHeight;
1046 TRACE(
"iBitmap=%d, start=(%d,%d) w=%d, h=%d\n",
1047 btnPtr->
iBitmap, rcBitmap.left, rcBitmap.top,
1107 dwItemCustDraw = ntfret & 0xffff;
1108 dwItemCDFlag = ntfret & 0xffff0000;
1133 if (hasDropDownArrow)
1172 if (drawSepDropDownArrow)
1203 TOOLBAR_DrawImage(infoPtr, btnPtr, rcBitmap.left, rcBitmap.top, &tbcd, dwItemCDFlag);
1205 if (hasDropDownArrow && !drawSepDropDownArrow)
1252 RECT rcTemp, rcClient;
1255 DWORD dwBaseCustDraw;
1281 dwBaseCustDraw = ntfret & 0xffff;
1310 rcInsertMark.
top = rcButton.
top;
1357 if(lpText !=
NULL) {
1375 TRACE(
"string size %d x %d!\n", lpSize->
cx, lpSize->
cy);
1407 lpSize->
cy =
tm.tmHeight;
1415 if (sz.
cx > lpSize->
cx)
1417 if (sz.
cy > lpSize->
cy)
1425 TRACE(
"max string size %d x %d\n", lpSize->
cx, lpSize->
cy);
1465 bButtonWrap =
FALSE;
1467 TRACE(
"start ButtonWidth=%d, BitmapWidth=%d, width=%d, nIndent=%d\n",
1478 if (btnPtr[
i].
cx > 0)
1481 else if ((btnPtr[
i].fsStyle &
BTNS_SEP) &&
1498 TRACE(
"wrap point 1 btn %d style %02x\n",
i, btnPtr[
i].fsStyle);
1502 bButtonWrap =
FALSE;
1517 while( ( ((btnPtr[
i].fsStyle &
BTNS_SEP) &&
1520 i < infoPtr->nNumButtons )
1526 if( bFound && i < infoPtr->nNumButtons )
1529 TRACE(
"wrap point 2 btn %d style %02x, x=%d, cx=%d\n",
1530 i, btnPtr[
i].fsStyle,
x,
cx);
1533 bButtonWrap =
FALSE;
1548 TRACE(
"wrap point 3 btn %d style %02x, x=%d, cx=%d\n",
1549 i, btnPtr[
i].fsStyle,
x,
cx);
1552 bButtonWrap =
FALSE;
1569 TRACE(
"wrap point 4 btn %d style %02x, x=%d, cx=%d\n",
1570 i, btnPtr[
i].fsStyle,
x,
cx);
1581 TRACE(
"wrap point 5 btn %d style %02x, x=%d, cx=%d\n",
1582 i, btnPtr[
i].fsStyle,
x,
cx);
1586 bButtonWrap =
FALSE;
1592 TRACE(
"wrap point 6 btn %d style %02x, x=%d, cx=%d\n",
1593 i, btnPtr[
i].fsStyle,
x,
cx);
1709 BOOL bHasBitmap,
BOOL bValidImageList)
1719 if (bValidImageList)
1737 if (sizeString.
cx > 0)
1750 if (sizeString.
cy > 0)
1751 sizeButton.
cy += 1 + sizeString.
cy;
1765 sizeButton.
cx += infoPtr->themeMargins.cxLeftWidth + infoPtr->themeMargins.cxRightWidth;
1766 sizeButton.
cy += infoPtr->themeMargins.cyTopHeight + infoPtr->themeMargins.cyBottomHeight;
1786 SIZE sizeString, sizeButton;
1794 validImageList =
TRUE;
1825 nRows = nSepRows = 0;
1854 cx = (btnPtr->
cx > 0) ? btnPtr->
cx :
1913 TRACE(
"button %d style=%x, bWrap=%d, nRows=%d, nSepRows=%d, btnrow=%d, (%d,%d)-(%d,%d)\n",
1921 y +=
cy + infoPtr->szSpacing.cy;
1928 y +=
cy + ( (btnPtr->
cx > 0 ) ?
1932 y +=
cy + infoPtr->szSpacing.cy;
1950 x +=
cx + infoPtr->szSpacing.cx;
1979 TRACE(
" ON SEPARATOR %d\n",
i);
1985 TRACE(
" ON BUTTON %d\n",
i);
1993 TRACE(
" NOWHERE\n");
2002 INT nOldButtons, nNewButtons, iButton;
2009 nNewButtons = nOldButtons + nAddButtons;
2017 for (iButton = 0; iButton < nAddButtons; iButton++) {
2059 if (CommandIsIndex) {
2060 TRACE(
"command is really index command=%d\n", idCommand);
2067 TRACE(
"command=%d index=%d\n", idCommand,
i);
2071 TRACE(
"no index found for command=%d\n", idCommand);
2082 if ((nIndex < 0) || (nIndex > infoPtr->
nNumButtons))
2086 btnPtr = &infoPtr->
buttons[nIndex];
2093 nRunIndex = nIndex - 1;
2094 while (nRunIndex >= 0) {
2095 btnPtr = &infoPtr->
buttons[nRunIndex];
2106 nRunIndex = nIndex + 1;
2107 while (nRunIndex < infoPtr->nNumButtons) {
2108 btnPtr = &infoPtr->
buttons[nRunIndex];
2246 TRACE(
"index from %d, index to %d\n", nIndexFrom, nIndexTo);
2248 if (nIndexFrom == nIndexTo)
2253 nmtb.
iItem = nIndexFrom;
2274 if (nIndexTo >= (
count - 2))
2290 TRACE(
"Add: nIndexAvail %d, nIndexTo %d\n", nIndexAvail, nIndexTo);
2294 nmtb.
iItem = nIndexAvail;
2305 if (nIndexAvail != 0)
2309 if (nIndexAvail ==
count-1)
2375 if (nCurrentItem >= (nCount - 1))
return FALSE;
2383 if ((nCurrentItem >= 0) && (nCurrentItem < (nCount - 1)))
2391 if (nCurrentItem < 0)
2410 if ((nIndexTo >= 0) && (nIndexTo < (nCount - 1)))
2452 if ((nCurrentItem >= 0) && (nCurrentItem < nCount))
2460 if (nCurrentItem < 0)
2479 if ((nIndexTo >= 0) && (nIndexTo < nCount))
2522 infoPtr = custInfo->tbInfo;
2525 nmtb.
iItem = custInfo->tbInfo->nNumButtons;
2535 TRACE(
"TBNRF_HIDEHELP requested\n");
2540 for (
i = 0;
i < custInfo->tbInfo->nNumButtons;
i++)
2582 TRACE(
"WM_INITDIALOG style: %x iItem(%d) idCommand(%d) iString(%ld) %s\n",
2594 btnInfo->bVirtual =
FALSE;
2595 btnInfo->bRemovable =
TRUE;
2629 btnInfo->bVirtual =
TRUE;
2630 btnInfo->bRemovable =
FALSE;
2691 else if (
index == 0)
2797 if (btnInfo ==
NULL)
2799 FIXME(
"btnInfo invalid\n");
2819 rcButton = lpdis->
rcItem;
2822 rcButton.
right = rcButton.
left + custInfo->tbInfo->nBitmapWidth + 6;
2917 nAdded = nCountAfter - nCountBefore;
2918 if (
bitmap->nButtons == 0)
2921 }
else if (nAdded > (
INT)
bitmap->nButtons) {
2922 TRACE(
"Added more images than wParam: Previous image number %i added %i while wParam %i. Images in list %i\n",
2923 nCountBefore, nAdded,
bitmap->nButtons, nCountAfter);
2939 if (himlDef ==
NULL || himlDef != infoPtr->
himlInt)
2946 TRACE(
"Update icon size: %dx%d -> %dx%d\n",
2978 switch (lpAddBmp->
nID)
3009 WARN(
"unknown bitmap id, %ld\n", lpAddBmp->
nID);
3013 TRACE (
"adding %d internal bitmaps\n",
info.nButtons);
3016 if (lpAddBmp->
nID & 1)
3034 TRACE(
"adding %d bitmaps\n",
info.nButtons);
3049 TRACE (
"creating default image list\n");
3061 WARN(
"No default image list available\n");
3082 TRACE(
"adding %d buttons (unicode=%d)\n", nAddButtons, fUnicode);
3091 #define MAX_RESOURCE_STRING_LENGTH 512 3105 TRACE(
"adding string from resource\n");
3113 TRACE(
"string not found in resources\n");
3121 if (
len == 0 ||
len == 1)
3124 TRACE(
"delimiter: 0x%x\n", *szString);
3130 if (next_delim + 1 >= szString +
len)
3150 TRACE(
"adding string(s) from array\n");
3186 TRACE(
"adding string(s) from array\n");
3221 RECT window_rect, parent_rect;
3233 x = parent_rect.
left;
3234 y = parent_rect.
top;
3243 y = window_rect.top;
3304 btnPtr = &infoPtr->
buttons[nIndex];
3330 btnPtr = &infoPtr->
buttons[nIndex];
3340 if (nOldIndex == nIndex)
3342 if (nOldIndex != -1)
3350 if (nOldIndex != -1)
3375 custInfo.
tbInfo = infoPtr;
3397 if ((nIndex < 0) || (nIndex >= infoPtr->
nNumButtons))
3400 memset(&nmtb, 0,
sizeof(nmtb));
3414 TRACE(
" simple delete\n");
3422 TRACE(
"complex delete [nIndex=%d]\n", nIndex);
3431 if (nIndex < infoPtr->nNumButtons) {
3462 btnPtr = &infoPtr->
buttons[nIndex];
3516 if ((nIndex < 0) || (nIndex >= infoPtr->
nNumButtons))
3519 btnPtr = &infoPtr->
buttons[nIndex];
3540 if (lpTbInfo ==
NULL)
3549 WARN(
"Invalid button size\n");
3557 btnPtr = &infoPtr->
buttons[nIndex];
3583 }
else if (!bUnicode || lpTbInfo->
pszText)
3616 if (lpStr)
strcpyW (lpStr, lpText);
3678 TRACE(
"hwnd = %p, lptbim = %p\n", infoPtr->
hwndSelf, lptbim);
3680 *lptbim = infoPtr->
tbim;
3700 btnPtr = &infoPtr->
buttons[nIndex];
3701 if ((nIndex < 0) || (nIndex >= infoPtr->
nNumButtons))
3727 TRACE(
"maximum size %d x %d\n",
3749 pMetrics->
cxBarPad = infoPtr->szBarPadding.cx;
3750 pMetrics->
cyBarPad = infoPtr->szBarPadding.cy;
3780 btnPtr = &infoPtr->
buttons[nIndex];
3781 if ((nIndex < 0) || (nIndex >= infoPtr->
nNumButtons))
3799 return infoPtr->
nRows;
3842 TRACE(
"%s hwnd=%p\n",
3869 btnPtr = &infoPtr->
buttons[nIndex];
3877 if (oldState != btnPtr->
fsState) {
3904 btnPtr = &infoPtr->
buttons[nIndex];
3912 if(oldState != btnPtr->
fsState)
3934 }
else if (nIndex < 0)
3937 TRACE(
"inserting button index=%d\n", nIndex);
3940 TRACE(
"adjust index=%d\n", nIndex);
4043 WCHAR wszAccel[] = {
'&',wAccel,0};
4046 TRACE(
"hwnd = %p, wAccel = %x(%s), pIDButton = %p\n",
4063 if ((lpszStr[0] ==
'&') && (lpszStr[1] ==
'&'))
4068 if (!
strncmpiW(lpszStr, wszAccel, iLen))
4088 TRACE(
"hwnd = %p, Id = %d, fMark = 0%d\n", infoPtr->
hwndSelf,
Id, fMark);
4094 btnPtr = &infoPtr->
buttons[nIndex];
4102 if(oldState != btnPtr->
fsState)
4116 else if (*
pIndex == nIndex)
4123 else if (*
pIndex == nIndex)
4136 TRACE(
"hwnd=%p, Id=%d, nMoveIndex=%d\n", infoPtr->
hwndSelf,
Id, nMoveIndex);
4139 if ((nIndex == -1) || (nMoveIndex < 0))
4148 if (nIndex < nMoveIndex)
4150 nCount = nMoveIndex - nIndex;
4159 else if (nIndex > nMoveIndex)
4161 nCount = nIndex - nMoveIndex;
4190 btnPtr = &infoPtr->
buttons[nIndex];
4198 if(oldState != btnPtr->
fsState)
4210 int i = 0, nOldButtons = 0,
pos = 0;
4211 int nOldBitmaps, nNewBitmaps = 0;
4214 TRACE(
"hInstOld %p nIDOld %lx hInstNew %p nIDNew %lx nButtons %x\n",
4220 FIXME(
"changing standard bitmaps not implemented\n");
4224 FIXME(
"resources not in the current module not implemented\n");
4229 TRACE(
"tbimapinfo %d hInstOld %p nIDOld %x\n",
i, tbi->
hInst, tbi->
nID);
4237 TRACE(
"tbimapinfo changed %d hInstOld %p nIDOld %x\n",
i, tbi->
hInst, tbi->
nID);