Mikołaj Zalewski : comctl32: toolbar: Move add/remove/ setrect tooltip code to separate functions.
Alexandre Julliard
julliard at wine.codeweavers.com
Mon Oct 9 14:05:13 CDT 2006
Module: wine
Branch: master
Commit: 7b899eabe93722499d7a887f8402b1131d9c1f19
URL: http://source.winehq.org/git/wine.git/?a=commit;h=7b899eabe93722499d7a887f8402b1131d9c1f19
Author: Mikołaj Zalewski <mikolaj at zalewski.pl>
Date: Sun Oct 8 23:40:37 2006 +0200
comctl32: toolbar: Move add/remove/setrect tooltip code to separate functions.
---
dlls/comctl32/toolbar.c | 146 +++++++++++++++++++----------------------------
1 files changed, 58 insertions(+), 88 deletions(-)
diff --git a/dlls/comctl32/toolbar.c b/dlls/comctl32/toolbar.c
index 945b40b..c25b01f 100644
--- a/dlls/comctl32/toolbar.c
+++ b/dlls/comctl32/toolbar.c
@@ -251,6 +251,7 @@ static LRESULT TOOLBAR_LButtonDown(HWND
static void TOOLBAR_SetHotItemEx (TOOLBAR_INFO *infoPtr, INT nHit, DWORD dwReason);
static LRESULT TOOLBAR_AutoSize(HWND hwnd);
static void TOOLBAR_CheckImageListIconSize(TOOLBAR_INFO *infoPtr);
+static void TOOLBAR_TooltipSetRect(TOOLBAR_INFO *infoPtr, TBUTTON_INFO *button);
static LRESULT
TOOLBAR_NotifyFormat(TOOLBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam);
@@ -1726,19 +1727,7 @@ TOOLBAR_CalcToolbar (HWND hwnd)
if (infoPtr->rcBound.bottom < y + cy)
infoPtr->rcBound.bottom = y + cy;
- /* Set the toolTip only for non-hidden, non-separator button */
- if (infoPtr->hwndToolTip && !(btnPtr->fsStyle & BTNS_SEP ))
- {
- TTTOOLINFOW ti;
-
- ZeroMemory (&ti, sizeof(ti));
- ti.cbSize = sizeof(ti);
- ti.hwnd = hwnd;
- ti.uId = btnPtr->idCommand;
- ti.rect = btnPtr->rect;
- SendMessageW (infoPtr->hwndToolTip, TTM_NEWTOOLRECTW,
- 0, (LPARAM)&ti);
- }
+ TOOLBAR_TooltipSetRect(infoPtr, btnPtr);
/* btnPtr->nRow is zero based. The space between the rows is */
/* also considered as a row. */
@@ -1902,6 +1891,56 @@ TOOLBAR_RelayEvent (HWND hwndTip, HWND h
SendMessageW (hwndTip, TTM_RELAYEVENT, 0, (LPARAM)&msg);
}
+static void
+TOOLBAR_TooltipAddTool(TOOLBAR_INFO *infoPtr, TBUTTON_INFO *button)
+{
+ if (infoPtr->hwndToolTip && !(button->fsStyle & BTNS_SEP)) {
+ TTTOOLINFOW ti;
+
+ ZeroMemory(&ti, sizeof(TTTOOLINFOW));
+ ti.cbSize = sizeof (TTTOOLINFOW);
+ ti.hwnd = infoPtr->hwndSelf;
+ ti.uId = button->idCommand;
+ ti.hinst = 0;
+ ti.lpszText = LPSTR_TEXTCALLBACKW;
+ /* ti.lParam = random value from the stack? */
+
+ SendMessageW(infoPtr->hwndToolTip, TTM_ADDTOOLW,
+ 0, (LPARAM)&ti);
+ }
+}
+
+static void
+TOOLBAR_TooltipDelTool(TOOLBAR_INFO *infoPtr, TBUTTON_INFO *button)
+{
+ if ((infoPtr->hwndToolTip) && !(button->fsStyle & BTNS_SEP)) {
+ TTTOOLINFOW ti;
+
+ ZeroMemory(&ti, sizeof(ti));
+ ti.cbSize = sizeof(ti);
+ ti.hwnd = infoPtr->hwndSelf;
+ ti.uId = button->idCommand;
+
+ SendMessageW(infoPtr->hwndToolTip, TTM_DELTOOLW, 0, (LPARAM)&ti);
+ }
+}
+
+static void TOOLBAR_TooltipSetRect(TOOLBAR_INFO *infoPtr, TBUTTON_INFO *button)
+{
+ /* Set the toolTip only for non-hidden, non-separator button */
+ if (infoPtr->hwndToolTip && !(button->fsStyle & BTNS_SEP))
+ {
+ TTTOOLINFOW ti;
+
+ ZeroMemory(&ti, sizeof(ti));
+ ti.cbSize = sizeof(ti);
+ ti.hwnd = infoPtr->hwndSelf;
+ ti.uId = button->idCommand;
+ ti.rect = button->rect;
+ SendMessageW(infoPtr->hwndToolTip, TTM_NEWTOOLRECTW, 0, (LPARAM)&ti);
+ }
+}
+
/* keeps available button list box sorted by button id */
static void TOOLBAR_Cust_InsertAvailButton(HWND hwnd, PCUSTOMBUTTON btnInfoNew)
{
@@ -2835,19 +2874,7 @@ TOOLBAR_AddButtonsA (HWND hwnd, WPARAM w
btnPtr->iString = lpTbb[nCount].iString;
btnPtr->bHot = FALSE;
- if ((infoPtr->hwndToolTip) && !(btnPtr->fsStyle & BTNS_SEP)) {
- TTTOOLINFOW ti;
-
- ZeroMemory (&ti, sizeof(ti));
- ti.cbSize = sizeof(ti);
- ti.hwnd = hwnd;
- ti.uId = btnPtr->idCommand;
- ti.hinst = 0;
- ti.lpszText = LPSTR_TEXTCALLBACKW;
-
- SendMessageW (infoPtr->hwndToolTip, TTM_ADDTOOLW,
- 0, (LPARAM)&ti);
- }
+ TOOLBAR_TooltipAddTool(infoPtr, btnPtr);
}
TOOLBAR_CalcToolbar (hwnd);
@@ -2903,20 +2930,7 @@ TOOLBAR_AddButtonsW (HWND hwnd, WPARAM w
btnPtr->iString = lpTbb[nCount].iString;
btnPtr->bHot = FALSE;
- if ((infoPtr->hwndToolTip) && !(btnPtr->fsStyle & BTNS_SEP)) {
- TTTOOLINFOW ti;
-
- ZeroMemory (&ti, sizeof(TTTOOLINFOW));
- ti.cbSize = sizeof (TTTOOLINFOW);
- ti.hwnd = hwnd;
- ti.uId = btnPtr->idCommand;
- ti.hinst = 0;
- ti.lpszText = LPSTR_TEXTCALLBACKW;
- ti.lParam = lParam;
-
- SendMessageW (infoPtr->hwndToolTip, TTM_ADDTOOLW,
- 0, (LPARAM)&ti);
- }
+ TOOLBAR_TooltipAddTool(infoPtr, btnPtr);
}
TOOLBAR_CalcToolbar (hwnd);
@@ -3251,17 +3265,7 @@ TOOLBAR_DeleteButton (HWND hwnd, WPARAM
nmtb.tbButton.iString = btnPtr->iString;
TOOLBAR_SendNotify(&nmtb.hdr, infoPtr, TBN_DELETINGBUTTON);
- if ((infoPtr->hwndToolTip) &&
- !(btnPtr->fsStyle & BTNS_SEP)) {
- TTTOOLINFOW ti;
-
- ZeroMemory (&ti, sizeof(ti));
- ti.cbSize = sizeof(ti);
- ti.hwnd = hwnd;
- ti.uId = infoPtr->buttons[nIndex].idCommand;
-
- SendMessageW (infoPtr->hwndToolTip, TTM_DELTOOLW, 0, (LPARAM)&ti);
- }
+ TOOLBAR_TooltipDelTool(infoPtr, &infoPtr->buttons[nIndex]);
if (infoPtr->nNumButtons == 1) {
TRACE(" simple delete!\n");
@@ -3909,19 +3913,7 @@ TOOLBAR_InsertButtonA (HWND hwnd, WPARAM
else
infoPtr->buttons[nIndex].iString = lpTbb->iString;
- if ((infoPtr->hwndToolTip) && !(lpTbb->fsStyle & BTNS_SEP)) {
- TTTOOLINFOW ti;
-
- ZeroMemory (&ti, sizeof(ti));
- ti.cbSize = sizeof (ti);
- ti.hwnd = hwnd;
- ti.uId = lpTbb->idCommand;
- ti.hinst = 0;
- ti.lpszText = LPSTR_TEXTCALLBACKW;
-
- SendMessageW (infoPtr->hwndToolTip, TTM_ADDTOOLW,
- 0, (LPARAM)&ti);
- }
+ TOOLBAR_TooltipAddTool(infoPtr, &infoPtr->buttons[nIndex]);
/* post insert copy */
if (nIndex < infoPtr->nNumButtons - 1) {
@@ -4010,19 +4002,7 @@ TOOLBAR_InsertButtonW (HWND hwnd, WPARAM
else
infoPtr->buttons[nIndex].iString = lpTbb->iString;
- if ((infoPtr->hwndToolTip) && !(lpTbb->fsStyle & BTNS_SEP)) {
- TTTOOLINFOW ti;
-
- ZeroMemory (&ti, sizeof(TTTOOLINFOW));
- ti.cbSize = sizeof (TTTOOLINFOW);
- ti.hwnd = hwnd;
- ti.uId = lpTbb->idCommand;
- ti.hinst = 0;
- ti.lpszText = LPSTR_TEXTCALLBACKW;
-
- SendMessageW (infoPtr->hwndToolTip, TTM_ADDTOOLW,
- 0, (LPARAM)&ti);
- }
+ TOOLBAR_TooltipAddTool(infoPtr, &infoPtr->buttons[nIndex]);
/* post insert copy */
if (nIndex < infoPtr->nNumButtons - 1) {
@@ -4441,20 +4421,10 @@ static void
TOOLBAR_DeleteAllButtons(TOOLBAR_INFO *infoPtr)
{
INT i;
- TTTOOLINFOW ti;
-
- ZeroMemory(&ti, sizeof(ti));
- ti.cbSize = sizeof(ti);
- ti.hwnd = infoPtr->hwndSelf;
for (i = 0; i < infoPtr->nNumButtons; i++)
{
- if ((infoPtr->hwndToolTip) &&
- !(infoPtr->buttons[i].fsStyle & BTNS_SEP))
- {
- ti.uId = infoPtr->buttons[i].idCommand;
- SendMessageW(infoPtr->hwndToolTip, TTM_DELTOOLW, 0, (LPARAM)&ti);
- }
+ TOOLBAR_TooltipDelTool(infoPtr, &infoPtr->buttons[i]);
}
Free(infoPtr->buttons);
More information about the wine-cvs
mailing list