Commit 02746e8e authored by Eric Kohl's avatar Eric Kohl Committed by Alexandre Julliard

Started support for menubar-like toolbars.

parent 1cbf27a3
...@@ -13,6 +13,8 @@ ...@@ -13,6 +13,8 @@
* - Unicode suppport (under construction). * - Unicode suppport (under construction).
* - Fix TOOLBAR_SetButtonInfo32A/W. * - Fix TOOLBAR_SetButtonInfo32A/W.
* - Customize dialog (under construction). * - Customize dialog (under construction).
* - TBSTYLE_AUTOSIZE for toolbar and buttons.
* - I_IMAGECALLBACK support.
* *
* Testing: * Testing:
* - Run tests using Waite Group Windows95 API Bible Volume 2. * - Run tests using Waite Group Windows95 API Bible Volume 2.
...@@ -75,14 +77,27 @@ TOOLBAR_DrawString (TOOLBAR_INFO *infoPtr, TBUTTON_INFO *btnPtr, ...@@ -75,14 +77,27 @@ TOOLBAR_DrawString (TOOLBAR_INFO *infoPtr, TBUTTON_INFO *btnPtr,
HFONT hOldFont; HFONT hOldFont;
INT nOldBkMode; INT nOldBkMode;
COLORREF clrOld; COLORREF clrOld;
LPWSTR lpText = NULL;
TRACE ("iString: %lx\n", btnPtr->iString);
/* get a pointer to the text */
if (HIWORD(btnPtr->iString) != 0)
lpText = (LPWSTR)btnPtr->iString;
else if ((btnPtr->iString >= 0) && (btnPtr->iString < infoPtr->nNumStrings))
lpText = infoPtr->strings[btnPtr->iString];
TRACE ("lpText: \"%s\"\n", debugstr_w(lpText));
/* draw text */ /* draw text */
if ((btnPtr->iString > -1) && (btnPtr->iString < infoPtr->nNumStrings)) { if (lpText) {
InflateRect (&rcText, -3, -3); InflateRect (&rcText, -3, -3);
if (himl && btnPtr->iBitmap>=0) { if (himl && btnPtr->iBitmap>=0) {
if (dwStyle & TBSTYLE_LIST) { if ((dwStyle & TBSTYLE_LIST) &&
((btnPtr->fsStyle & TBSTYLE_AUTOSIZE) == 0) &&
(btnPtr->iBitmap != I_IMAGENONE)) {
rcText.left += infoPtr->nBitmapWidth; rcText.left += infoPtr->nBitmapWidth;
} }
else { else {
...@@ -98,22 +113,18 @@ TOOLBAR_DrawString (TOOLBAR_INFO *infoPtr, TBUTTON_INFO *btnPtr, ...@@ -98,22 +113,18 @@ TOOLBAR_DrawString (TOOLBAR_INFO *infoPtr, TBUTTON_INFO *btnPtr,
if (!(nState & TBSTATE_ENABLED)) { if (!(nState & TBSTATE_ENABLED)) {
clrOld = SetTextColor (hdc, GetSysColor (COLOR_3DHILIGHT)); clrOld = SetTextColor (hdc, GetSysColor (COLOR_3DHILIGHT));
OffsetRect (&rcText, 1, 1); OffsetRect (&rcText, 1, 1);
DrawTextW (hdc, infoPtr->strings[btnPtr->iString], -1, DrawTextW (hdc, lpText, -1, &rcText, infoPtr->dwDTFlags);
&rcText, infoPtr->dwDTFlags);
SetTextColor (hdc, GetSysColor (COLOR_3DSHADOW)); SetTextColor (hdc, GetSysColor (COLOR_3DSHADOW));
OffsetRect (&rcText, -1, -1); OffsetRect (&rcText, -1, -1);
DrawTextW (hdc, infoPtr->strings[btnPtr->iString], -1, DrawTextW (hdc, lpText, -1, &rcText, infoPtr->dwDTFlags);
&rcText, infoPtr->dwDTFlags);
} }
else if (nState & TBSTATE_INDETERMINATE) { else if (nState & TBSTATE_INDETERMINATE) {
clrOld = SetTextColor (hdc, GetSysColor (COLOR_3DSHADOW)); clrOld = SetTextColor (hdc, GetSysColor (COLOR_3DSHADOW));
DrawTextW (hdc, infoPtr->strings[btnPtr->iString], -1, DrawTextW (hdc, lpText, -1, &rcText, infoPtr->dwDTFlags);
&rcText, infoPtr->dwDTFlags);
} }
else { else {
clrOld = SetTextColor (hdc, GetSysColor (COLOR_BTNTEXT)); clrOld = SetTextColor (hdc, GetSysColor (COLOR_BTNTEXT));
DrawTextW (hdc, infoPtr->strings[btnPtr->iString], -1, DrawTextW (hdc, lpText, -1, &rcText, infoPtr->dwDTFlags);
&rcText, infoPtr->dwDTFlags);
} }
SetTextColor (hdc, clrOld); SetTextColor (hdc, clrOld);
...@@ -200,6 +211,8 @@ TOOLBAR_DrawButton (HWND hwnd, TBUTTON_INFO *btnPtr, HDC hdc) ...@@ -200,6 +211,8 @@ TOOLBAR_DrawButton (HWND hwnd, TBUTTON_INFO *btnPtr, HDC hdc)
rc = btnPtr->rect; rc = btnPtr->rect;
TRACE("iBitmap: %d\n", btnPtr->iBitmap);
/* separator */ /* separator */
if (btnPtr->fsStyle & TBSTYLE_SEP) { if (btnPtr->fsStyle & TBSTYLE_SEP) {
if ((dwStyle & TBSTYLE_FLAT) && (btnPtr->iBitmap == 0)) if ((dwStyle & TBSTYLE_FLAT) && (btnPtr->iBitmap == 0))
...@@ -325,6 +338,7 @@ TOOLBAR_CalcStrings (HWND hwnd, LPSIZE lpSize) ...@@ -325,6 +338,7 @@ TOOLBAR_CalcStrings (HWND hwnd, LPSIZE lpSize)
HDC hdc; HDC hdc;
HFONT hOldFont; HFONT hOldFont;
SIZE sz; SIZE sz;
LPWSTR lpText = NULL;
lpSize->cx = 0; lpSize->cx = 0;
...@@ -337,7 +351,12 @@ TOOLBAR_CalcStrings (HWND hwnd, LPSIZE lpSize) ...@@ -337,7 +351,12 @@ TOOLBAR_CalcStrings (HWND hwnd, LPSIZE lpSize)
if (!(btnPtr->fsState & TBSTATE_HIDDEN) && if (!(btnPtr->fsState & TBSTATE_HIDDEN) &&
(btnPtr->iString > -1) && (btnPtr->iString > -1) &&
(btnPtr->iString < infoPtr->nNumStrings)) { (btnPtr->iString < infoPtr->nNumStrings)) {
LPWSTR lpText = infoPtr->strings[btnPtr->iString]; /* get a pointer to the text */
if (HIWORD(btnPtr->iString) != 0)
lpText = (LPWSTR)btnPtr->iString;
else if ((btnPtr->iString >= 0) && (btnPtr->iString < infoPtr->nNumStrings))
lpText = infoPtr->strings[btnPtr->iString];
GetTextExtentPoint32W (hdc, lpText, lstrlenW (lpText), &sz); GetTextExtentPoint32W (hdc, lpText, lstrlenW (lpText), &sz);
if (sz.cx > lpSize->cx) if (sz.cx > lpSize->cx)
lpSize->cx = sz.cx; lpSize->cx = sz.cx;
...@@ -538,11 +557,12 @@ TOOLBAR_CalcToolbar (HWND hwnd) ...@@ -538,11 +557,12 @@ TOOLBAR_CalcToolbar (HWND hwnd)
if (infoPtr->buttons[i].iBitmap >=0) if (infoPtr->buttons[i].iBitmap >=0)
usesBitmaps = TRUE; usesBitmaps = TRUE;
if (sizeString.cy > 0) if (sizeString.cy > 0) {
if (usesBitmaps) if (usesBitmaps)
infoPtr->nButtonHeight = sizeString.cy + infoPtr->nBitmapHeight + 6; infoPtr->nButtonHeight = sizeString.cy + infoPtr->nBitmapHeight + 6;
else else
infoPtr->nButtonHeight = sizeString.cy + 6; infoPtr->nButtonHeight = sizeString.cy + 6;
}
else if (infoPtr->nButtonHeight < infoPtr->nBitmapHeight + 6) else if (infoPtr->nButtonHeight < infoPtr->nBitmapHeight + 6)
infoPtr->nButtonHeight = infoPtr->nBitmapHeight + 6; infoPtr->nButtonHeight = infoPtr->nBitmapHeight + 6;
...@@ -1266,6 +1286,7 @@ TOOLBAR_AddStringA (HWND hwnd, WPARAM wParam, LPARAM lParam) ...@@ -1266,6 +1286,7 @@ TOOLBAR_AddStringA (HWND hwnd, WPARAM wParam, LPARAM lParam)
if (p == NULL) if (p == NULL)
return -1; return -1;
TRACE("adding string(s) from array!\n"); TRACE("adding string(s) from array!\n");
nIndex = infoPtr->nNumStrings; nIndex = infoPtr->nNumStrings;
while (*p) { while (*p) {
len = lstrlenA (p); len = lstrlenA (p);
...@@ -1312,24 +1333,58 @@ TOOLBAR_AddStringW (HWND hwnd, WPARAM wParam, LPARAM lParam) ...@@ -1312,24 +1333,58 @@ TOOLBAR_AddStringW (HWND hwnd, WPARAM wParam, LPARAM lParam)
szString, 256); szString, 256);
TRACE("len=%d \"%s\"\n", len, debugstr_w(szString)); TRACE("len=%d \"%s\"\n", len, debugstr_w(szString));
nIndex = infoPtr->nNumStrings; TRACE("First char: 0x%x\n", *szString);
if (infoPtr->nNumStrings == 0) { if (szString[0] == L'|')
infoPtr->strings = {
COMCTL32_Alloc (sizeof(LPWSTR)); PWSTR p = szString + 1;
}
else { nIndex = infoPtr->nNumStrings;
LPWSTR *oldStrings = infoPtr->strings; while (*p != L'|') {
infoPtr->strings =
COMCTL32_Alloc (sizeof(LPWSTR) * (infoPtr->nNumStrings + 1)); if (infoPtr->nNumStrings == 0) {
memcpy (&infoPtr->strings[0], &oldStrings[0], infoPtr->strings =
sizeof(LPWSTR) * infoPtr->nNumStrings); COMCTL32_Alloc (sizeof(LPWSTR));
COMCTL32_Free (oldStrings); }
else {
LPWSTR *oldStrings = infoPtr->strings;
infoPtr->strings =
COMCTL32_Alloc (sizeof(LPWSTR) * (infoPtr->nNumStrings + 1));
memcpy (&infoPtr->strings[0], &oldStrings[0],
sizeof(LPWSTR) * infoPtr->nNumStrings);
COMCTL32_Free (oldStrings);
}
len = COMCTL32_StrChrW (p, L'|') - p;
TRACE("len=%d \"%s\"\n", len, debugstr_w(p));
infoPtr->strings[infoPtr->nNumStrings] =
COMCTL32_Alloc (sizeof(WCHAR)*(len+1));
lstrcpyW (infoPtr->strings[infoPtr->nNumStrings], p);
infoPtr->nNumStrings++;
p += (len+1);
}
} }
else
{
nIndex = infoPtr->nNumStrings;
if (infoPtr->nNumStrings == 0) {
infoPtr->strings =
COMCTL32_Alloc (sizeof(LPWSTR));
}
else {
LPWSTR *oldStrings = infoPtr->strings;
infoPtr->strings =
COMCTL32_Alloc (sizeof(LPWSTR) * (infoPtr->nNumStrings + 1));
memcpy (&infoPtr->strings[0], &oldStrings[0],
sizeof(LPWSTR) * infoPtr->nNumStrings);
COMCTL32_Free (oldStrings);
}
infoPtr->strings[infoPtr->nNumStrings] = infoPtr->strings[infoPtr->nNumStrings] =
COMCTL32_Alloc (sizeof(WCHAR)*(len+1)); COMCTL32_Alloc (sizeof(WCHAR)*(len+1));
lstrcpyW (infoPtr->strings[infoPtr->nNumStrings], szString); lstrcpyW (infoPtr->strings[infoPtr->nNumStrings], szString);
infoPtr->nNumStrings++; infoPtr->nNumStrings++;
}
} }
else { else {
LPWSTR p = (LPWSTR)lParam; LPWSTR p = (LPWSTR)lParam;
...@@ -1341,8 +1396,8 @@ TOOLBAR_AddStringW (HWND hwnd, WPARAM wParam, LPARAM lParam) ...@@ -1341,8 +1396,8 @@ TOOLBAR_AddStringW (HWND hwnd, WPARAM wParam, LPARAM lParam)
nIndex = infoPtr->nNumStrings; nIndex = infoPtr->nNumStrings;
while (*p) { while (*p) {
len = lstrlenW (p); len = lstrlenW (p);
TRACE("len=%d \"%s\"\n", len, debugstr_w(p));
TRACE("len=%d \"%s\"\n", len, debugstr_w(p));
if (infoPtr->nNumStrings == 0) { if (infoPtr->nNumStrings == 0) {
infoPtr->strings = infoPtr->strings =
COMCTL32_Alloc (sizeof(LPWSTR)); COMCTL32_Alloc (sizeof(LPWSTR));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment