202#define SEPARATOR_WIDTH 8
204#define BOTTOM_BORDER 2
205#define DDARROW_WIDTH 11
206#define ARROW_HEIGHT 3
207#define INSERTMARK_WIDTH 2
229#define NONLIST_NOTEXT_OFFSET 2
231#define TOOLBAR_NOWHERE (-1)
234#define TBSTYLE_EX_ALL (TBSTYLE_EX_DRAWDDARROWS | \
235 TBSTYLE_EX_VERTICAL | \
236 TBSTYLE_EX_MIXEDBUTTONS | \
237 TBSTYLE_EX_DOUBLEBUFFER | \
238 TBSTYLE_EX_HIDECLIPPEDBUTTONS)
241#define COMMON_STYLES (CCS_TOP|CCS_NOMOVEY|CCS_BOTTOM|CCS_NORESIZE| \
242 CCS_NOPARENTALIGN|CCS_ADJUSTABLE|CCS_NODIVIDER|CCS_VERT)
244#define GETIBITMAP(infoPtr, i) (infoPtr->iVersion >= 5 ? LOWORD(i) : i)
245#define GETHIMLID(infoPtr, i) (infoPtr->iVersion >= 5 ? HIWORD(i) : 0)
246#define GETDEFIMAGELIST(infoPtr, id) TOOLBAR_GetImageList(infoPtr->himlDef, infoPtr->cimlDef, id)
247#define GETHOTIMAGELIST(infoPtr, id) TOOLBAR_GetImageList(infoPtr->himlHot, infoPtr->cimlHot, id)
248#define GETDISIMAGELIST(infoPtr, id) TOOLBAR_GetImageList(infoPtr->himlDis, infoPtr->cimlDis, id)
272 return infoPtr->szBarPadding.cy;
315 TRACE(
"TBBUTTON: id %d, bitmap=%d, state=%02x, style=%02x, data=%p, stringid=%p (%s)\n", tbb->
idCommand,
324 TRACE(
"button %d id %d, bitmap=%d, state=%02x, style=%02x, data=%08lx, stringid=0x%08lx\n",
328 TRACE(
"button %d id %d, hot=%s, row=%d, rect=(%s)\n",
341 TRACE(
"toolbar %p at line %d, exStyle=%08x, buttons=%d, bitmaps=%d, strings=%d, style=%08x\n",
345 TRACE(
"toolbar %p at line %d, himlInt=%p, himlDef=%p, himlHot=%p, himlDis=%p, redrawable=%s\n",
403 FIXME(
"[%p] TBSTYLE_REGISTERDROP not implemented\n", infoPtr->
hwndSelf);
418 (infoPtr->
bUnicode) ?
"via Unicode" :
"via ANSI");
440 memset(&nmgd, 0,
sizeof(nmgd));
450 TRACE(
"TBN_GETDISPINFO returned bitmap id %d, mask=%08x, nNumBitmaps=%d\n",
499 WARN(
"bitmap for ID %d, index %d is not valid, number of bitmaps in imagelist: %d\n",
507 ERR(
"TBN_GETDISPINFO returned invalid index %d\n",
525 FIXME(
"Shouldn't reach here\n");
529 TRACE(
"no image list\n");
648 DWORD dwDTFlags = TOOLBAR_GetButtonDTFlags(infoPtr, btnPtr);
660 DWORD dwDTFlags2 = 0;
667 dwDTFlags2 = DTT_GRAYED;
676 DrawThemeText(theme,
hdc, partId, stateId, lpText, -1, dwDTFlags, dwDTFlags2, rcText);
749 HDC hdcMask, hdcImage;
758 RGB(0xff, 0xff, 0xff),
RGB(0,0,0), draw_flags);
828 if (bm.bmBitsPixel == 32)
830 draw_desaturated =
TRUE;
865 TRACE(
"drawing index=%d, himl=%p, left=%d, top=%d, offset=%d\n",
873 else if (draw_desaturated)
878 imldp.
cbSize =
sizeof(imldp);
909 BOOL pressed_look = !non_interactive_state &&
939 BOOL pressed = bDropDownPressed ||
978 BOOL drawSepDropDownArrow = hasDropDownArrow &&
980 RECT rc, rcArrow, rcBitmap, rcText;
986 DWORD dwItemCustDraw;
1018 FIXME(
"Draw some kind of separator: fsStyle=%x\n",
1027 if (hasDropDownArrow)
1036 if (drawSepDropDownArrow)
1039 rcArrow.left =
right;
1060 rcBitmap.left += ((rc.right - rc.left) - infoPtr->
nBitmapWidth) / 2;
1064 rcBitmap.top += infoPtr->themeMargins.cyTopHeight;
1067 TRACE(
"iBitmap=%d, start=(%d,%d) w=%d, h=%d\n",
1068 btnPtr->
iBitmap, rcBitmap.left, rcBitmap.top,
1128 dwItemCustDraw = ntfret & 0xffff;
1129 dwItemCDFlag = ntfret & 0xffff0000;
1154 if (hasDropDownArrow)
1193 if (drawSepDropDownArrow)
1228 TOOLBAR_DrawImage(infoPtr, btnPtr, rcBitmap.left, rcBitmap.top, &tbcd, dwItemCDFlag);
1230 if (hasDropDownArrow && !drawSepDropDownArrow)
1277 RECT rcTemp, rcClient;
1280 DWORD dwBaseCustDraw;
1306 dwBaseCustDraw = ntfret & 0xffff;
1335 rcInsertMark.
top = rcButton.
top;
1382 if(lpText !=
NULL) {
1400 TRACE(
"string size %d x %d!\n", lpSize->
cx, lpSize->
cy);
1432 lpSize->
cy =
tm.tmHeight;
1440 if (sz.
cx > lpSize->
cx)
1442 if (sz.
cy > lpSize->
cy)
1450 TRACE(
"max string size %d x %d\n", lpSize->
cx, lpSize->
cy);
1490 bButtonWrap =
FALSE;
1492 TRACE(
"start ButtonWidth=%d, BitmapWidth=%d, width=%d, nIndent=%d\n",
1498 btnPtr[
i].
fsState &= ~TBSTATE_WRAP;
1503 if (btnPtr[
i].
cx > 0)
1506 else if ((btnPtr[
i].fsStyle &
BTNS_SEP) &&
1523 TRACE(
"wrap point 1 btn %d style %02x\n",
i, btnPtr[
i].fsStyle);
1527 bButtonWrap =
FALSE;
1542 while( ( ((btnPtr[
i].fsStyle &
BTNS_SEP) &&
1545 i < infoPtr->nNumButtons )
1551 if( bFound && i < infoPtr->nNumButtons )
1554 TRACE(
"wrap point 2 btn %d style %02x, x=%d, cx=%d\n",
1555 i, btnPtr[
i].fsStyle,
x,
cx);
1558 bButtonWrap =
FALSE;
1573 TRACE(
"wrap point 3 btn %d style %02x, x=%d, cx=%d\n",
1574 i, btnPtr[
i].fsStyle,
x,
cx);
1577 bButtonWrap =
FALSE;
1594 TRACE(
"wrap point 4 btn %d style %02x, x=%d, cx=%d\n",
1595 i, btnPtr[
i].fsStyle,
x,
cx);
1606 TRACE(
"wrap point 5 btn %d style %02x, x=%d, cx=%d\n",
1607 i, btnPtr[
i].fsStyle,
x,
cx);
1611 bButtonWrap =
FALSE;
1617 TRACE(
"wrap point 6 btn %d style %02x, x=%d, cx=%d\n",
1618 i, btnPtr[
i].fsStyle,
x,
cx);
1734 BOOL bHasBitmap,
BOOL bValidImageList)
1744 if (bValidImageList)
1762 if (sizeString.
cx > 0)
1775 if (sizeString.
cy > 0)
1776 sizeButton.
cy += 1 + sizeString.
cy;
1790 sizeButton.
cx += infoPtr->themeMargins.cxLeftWidth + infoPtr->themeMargins.cxRightWidth;
1791 sizeButton.
cy += infoPtr->themeMargins.cyTopHeight + infoPtr->themeMargins.cyBottomHeight;
1811 SIZE sizeString, sizeButton;
1819 validImageList =
TRUE;
1850 nRows = nSepRows = 0;
1879 cx = (btnPtr->
cx > 0) ? btnPtr->
cx :
1938 TRACE(
"button %d style=%x, bWrap=%d, nRows=%d, nSepRows=%d, btnrow=%d, (%d,%d)-(%d,%d)\n",
1946 y +=
cy + infoPtr->szSpacing.cy;
1953 y +=
cy + ( (btnPtr->
cx > 0 ) ?
1957 y +=
cy + infoPtr->szSpacing.cy;
1975 x +=
cx + infoPtr->szSpacing.cx;
2004 TRACE(
" ON SEPARATOR %d\n",
i);
2010 TRACE(
" ON BUTTON %d\n",
i);
2018 TRACE(
" NOWHERE\n");
2027 INT nOldButtons, nNewButtons, iButton;
2034 nNewButtons = nOldButtons + nAddButtons;
2042 for (iButton = 0; iButton < nAddButtons; iButton++) {
2084 if (CommandIsIndex) {
2085 TRACE(
"command is really index command=%d\n", idCommand);
2092 TRACE(
"command=%d index=%d\n", idCommand,
i);
2096 TRACE(
"no index found for command=%d\n", idCommand);
2107 if ((nIndex < 0) || (nIndex > infoPtr->
nNumButtons))
2111 btnPtr = &infoPtr->
buttons[nIndex];
2118 nRunIndex = nIndex - 1;
2119 while (nRunIndex >= 0) {
2120 btnPtr = &infoPtr->
buttons[nRunIndex];
2131 nRunIndex = nIndex + 1;
2132 while (nRunIndex < infoPtr->nNumButtons) {
2133 btnPtr = &infoPtr->
buttons[nRunIndex];
2271 TRACE(
"index from %d, index to %d\n", nIndexFrom, nIndexTo);
2273 if (nIndexFrom == nIndexTo)
2278 nmtb.
iItem = nIndexFrom;
2299 if (nIndexTo >= (
count - 2))
2315 TRACE(
"Add: nIndexAvail %d, nIndexTo %d\n", nIndexAvail, nIndexTo);
2319 nmtb.
iItem = nIndexAvail;
2330 if (nIndexAvail != 0)
2334 if (nIndexAvail ==
count-1)
2400 if (nCurrentItem >= (nCount - 1))
return FALSE;
2408 if ((nCurrentItem >= 0) && (nCurrentItem < (nCount - 1)))
2416 if (nCurrentItem < 0)
2435 if ((nIndexTo >= 0) && (nIndexTo < (nCount - 1)))
2477 if ((nCurrentItem >= 0) && (nCurrentItem < nCount))
2485 if (nCurrentItem < 0)
2504 if ((nIndexTo >= 0) && (nIndexTo < nCount))
2547 infoPtr = custInfo->tbInfo;
2550 nmtb.
iItem = custInfo->tbInfo->nNumButtons;
2560 TRACE(
"TBNRF_HIDEHELP requested\n");
2565 for (
i = 0;
i < custInfo->tbInfo->nNumButtons;
i++)
2607 TRACE(
"WM_INITDIALOG style: %x iItem(%d) idCommand(%d) iString(%ld) %s\n",
2619 btnInfo->bVirtual =
FALSE;
2620 btnInfo->bRemovable =
TRUE;
2654 btnInfo->bVirtual =
TRUE;
2655 btnInfo->bRemovable =
FALSE;
2716 else if (
index == 0)
2822 if (btnInfo ==
NULL)
2824 FIXME(
"btnInfo invalid\n");
2844 rcButton = lpdis->
rcItem;
2847 rcButton.
right = rcButton.
left + custInfo->tbInfo->nBitmapWidth + 6;
2942 nAdded = nCountAfter - nCountBefore;
2943 if (
bitmap->nButtons == 0)
2946 }
else if (nAdded > (
INT)
bitmap->nButtons) {
2947 TRACE(
"Added more images than wParam: Previous image number %i added %i while wParam %i. Images in list %i\n",
2948 nCountBefore, nAdded,
bitmap->nButtons, nCountAfter);
2964 if (himlDef ==
NULL || himlDef != infoPtr->
himlInt)
2971 TRACE(
"Update icon size: %dx%d -> %dx%d\n",
3003 switch (lpAddBmp->
nID)
3034 WARN(
"unknown bitmap id, %ld\n", lpAddBmp->
nID);
3038 TRACE (
"adding %d internal bitmaps\n",
info.nButtons);
3041 if (lpAddBmp->
nID & 1)
3059 TRACE(
"adding %d bitmaps\n",
info.nButtons);
3074 TRACE (
"creating default image list\n");
3086 WARN(
"No default image list available\n");
3107 TRACE(
"adding %d buttons (unicode=%d)\n", nAddButtons, fUnicode);
3116#define MAX_RESOURCE_STRING_LENGTH 512
3130 TRACE(
"adding string from resource\n");
3138 TRACE(
"string not found in resources\n");
3146 if (
len == 0 ||
len == 1)
3149 TRACE(
"delimiter: 0x%x\n", *szString);
3155 if (next_delim + 1 >= szString +
len)
3175 TRACE(
"adding string(s) from array\n");
3211 TRACE(
"adding string(s) from array\n");
3246 RECT window_rect, parent_rect;
3258 x = parent_rect.
left;
3259 y = parent_rect.
top;
3268 y = window_rect.top;
3329 btnPtr = &infoPtr->
buttons[nIndex];
3355 btnPtr = &infoPtr->
buttons[nIndex];
3365 if (nOldIndex == nIndex)
3367 if (nOldIndex != -1)
3375 if (nOldIndex != -1)
3400 custInfo.
tbInfo = infoPtr;
3422 if ((nIndex < 0) || (nIndex >= infoPtr->
nNumButtons))
3425 memset(&nmtb, 0,
sizeof(nmtb));
3439 TRACE(
" simple delete\n");
3447 TRACE(
"complex delete [nIndex=%d]\n", nIndex);
3456 if (nIndex < infoPtr->nNumButtons) {
3487 btnPtr = &infoPtr->
buttons[nIndex];
3541 if ((nIndex < 0) || (nIndex >= infoPtr->
nNumButtons))
3544 btnPtr = &infoPtr->
buttons[nIndex];
3565 if (lpTbInfo ==
NULL)
3574 WARN(
"Invalid button size\n");
3582 btnPtr = &infoPtr->
buttons[nIndex];
3608 }
else if (!bUnicode || lpTbInfo->
pszText)
3641 if (lpStr)
lstrcpyW (lpStr, lpText);
3703 TRACE(
"hwnd = %p, lptbim = %p\n", infoPtr->
hwndSelf, lptbim);
3705 *lptbim = infoPtr->
tbim;
3725 btnPtr = &infoPtr->
buttons[nIndex];
3726 if ((nIndex < 0) || (nIndex >= infoPtr->
nNumButtons))
3752 TRACE(
"maximum size %d x %d\n",
3774 pMetrics->
cxBarPad = infoPtr->szBarPadding.cx;
3775 pMetrics->
cyBarPad = infoPtr->szBarPadding.cy;
3805 btnPtr = &infoPtr->
buttons[nIndex];
3806 if ((nIndex < 0) || (nIndex >= infoPtr->
nNumButtons))
3824 return infoPtr->
nRows;
3867 TRACE(
"%s hwnd=%p\n",
3894 btnPtr = &infoPtr->
buttons[nIndex];
3900 btnPtr->
fsState &= ~TBSTATE_HIDDEN;
3902 if (oldState != btnPtr->
fsState) {