- TTM_TRACKACTIVATE can have NULL lParam when deactivating.
- Factor out common code from TOOLTIPS_DelTool{A,W}. - Update all indices correctly after delete.
This commit is contained in:
parent
bd60364040
commit
83face5d3e
|
@ -18,8 +18,9 @@
|
|||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* TODO:
|
||||
* - Unicode support (started).
|
||||
* - Custom draw support.
|
||||
* - Balloon tips.
|
||||
* - Messages.
|
||||
*
|
||||
* Testing:
|
||||
* - Run tests using Waite Group Windows95 API Bible Volume 2.
|
||||
|
@ -111,7 +112,7 @@ typedef struct
|
|||
INT xTrackPos;
|
||||
INT yTrackPos;
|
||||
INT nMaxTipWidth;
|
||||
INT nTool;
|
||||
INT nTool; /* tool that mouse was on on last relayed mouse move */
|
||||
INT nCurrentTool;
|
||||
INT nTrackTool;
|
||||
INT nReshowTime;
|
||||
|
@ -545,11 +546,12 @@ TOOLTIPS_TrackHide (HWND hwnd, TOOLTIPS_INFO *infoPtr)
|
|||
TTTOOL_INFO *toolPtr;
|
||||
NMHDR hdr;
|
||||
|
||||
TRACE("hide tracking tooltip %d\n", infoPtr->nTrackTool);
|
||||
|
||||
if (infoPtr->nTrackTool == -1)
|
||||
return;
|
||||
|
||||
toolPtr = &infoPtr->tools[infoPtr->nTrackTool];
|
||||
TRACE("hide tracking tooltip %d!\n", infoPtr->nTrackTool);
|
||||
|
||||
hdr.hwndFrom = hwnd;
|
||||
hdr.idFrom = toolPtr->uId;
|
||||
|
@ -886,12 +888,86 @@ TOOLTIPS_AddToolW (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|||
}
|
||||
|
||||
|
||||
static void TOOLTIPS_DelToolCommon (HWND hwnd, TOOLTIPS_INFO *infoPtr, INT nTool)
|
||||
{
|
||||
TTTOOL_INFO *toolPtr;
|
||||
|
||||
TRACE("tool %d\n", nTool);
|
||||
|
||||
if (nTool == -1)
|
||||
return;
|
||||
|
||||
/* make sure the tooltip has disappeared before deleting it */
|
||||
TOOLTIPS_Hide(hwnd, infoPtr);
|
||||
|
||||
/* delete text string */
|
||||
toolPtr = &infoPtr->tools[nTool];
|
||||
if (toolPtr->lpszText) {
|
||||
if ( (toolPtr->lpszText != LPSTR_TEXTCALLBACKW) &&
|
||||
(HIWORD((INT)toolPtr->lpszText) != 0) )
|
||||
Free (toolPtr->lpszText);
|
||||
}
|
||||
|
||||
/* remove subclassing */
|
||||
if (toolPtr->uFlags & TTF_SUBCLASS) {
|
||||
if (toolPtr->uFlags & TTF_IDISHWND) {
|
||||
RemoveWindowSubclass((HWND)toolPtr->uId, TOOLTIPS_SubclassProc, 1);
|
||||
}
|
||||
else {
|
||||
RemoveWindowSubclass(toolPtr->hwnd, TOOLTIPS_SubclassProc, 1);
|
||||
}
|
||||
}
|
||||
|
||||
/* delete tool from tool list */
|
||||
if (infoPtr->uNumTools == 1) {
|
||||
Free (infoPtr->tools);
|
||||
infoPtr->tools = NULL;
|
||||
}
|
||||
else {
|
||||
TTTOOL_INFO *oldTools = infoPtr->tools;
|
||||
infoPtr->tools =
|
||||
Alloc (sizeof(TTTOOL_INFO) * (infoPtr->uNumTools - 1));
|
||||
|
||||
if (nTool > 0)
|
||||
memcpy (&infoPtr->tools[0], &oldTools[0],
|
||||
nTool * sizeof(TTTOOL_INFO));
|
||||
|
||||
if (nTool < infoPtr->uNumTools - 1)
|
||||
memcpy (&infoPtr->tools[nTool], &oldTools[nTool + 1],
|
||||
(infoPtr->uNumTools - nTool - 1) * sizeof(TTTOOL_INFO));
|
||||
|
||||
Free (oldTools);
|
||||
}
|
||||
|
||||
/* update any indices affected by delete */
|
||||
|
||||
/* destroying tool that mouse was on on last relayed mouse move */
|
||||
if (infoPtr->nTool == nTool)
|
||||
/* -1 means no current tool (0 means first tool) */
|
||||
infoPtr->nTool = -1;
|
||||
else if (infoPtr->nTool > nTool)
|
||||
infoPtr->nTool--;
|
||||
|
||||
if (infoPtr->nTrackTool == nTool)
|
||||
/* -1 means no current tool (0 means first tool) */
|
||||
infoPtr->nTrackTool = -1;
|
||||
else if (infoPtr->nTrackTool > nTool)
|
||||
infoPtr->nTrackTool--;
|
||||
|
||||
if (infoPtr->nCurrentTool == nTool)
|
||||
/* -1 means no current tool (0 means first tool) */
|
||||
infoPtr->nCurrentTool = -1;
|
||||
else if (infoPtr->nCurrentTool > nTool)
|
||||
infoPtr->nCurrentTool--;
|
||||
|
||||
infoPtr->uNumTools--;
|
||||
}
|
||||
|
||||
static LRESULT
|
||||
TOOLTIPS_DelToolA (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
|
||||
LPTTTOOLINFOA lpToolInfo = (LPTTTOOLINFOA)lParam;
|
||||
TTTOOL_INFO *toolPtr;
|
||||
INT nTool;
|
||||
|
||||
if (lpToolInfo == NULL)
|
||||
|
@ -902,60 +978,8 @@ TOOLTIPS_DelToolA (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|||
return 0;
|
||||
|
||||
nTool = TOOLTIPS_GetToolFromInfoA (infoPtr, lpToolInfo);
|
||||
if (nTool == -1) return 0;
|
||||
|
||||
TRACE("tool %d\n", nTool);
|
||||
|
||||
/* make sure the tooltip has disappeared before deleting it */
|
||||
TOOLTIPS_Hide(hwnd, infoPtr);
|
||||
|
||||
/* delete text string */
|
||||
toolPtr = &infoPtr->tools[nTool];
|
||||
if (toolPtr->lpszText) {
|
||||
if ( (toolPtr->lpszText != LPSTR_TEXTCALLBACKW) &&
|
||||
(HIWORD((INT)toolPtr->lpszText) != 0) )
|
||||
Free (toolPtr->lpszText);
|
||||
}
|
||||
|
||||
/* remove subclassing */
|
||||
if (toolPtr->uFlags & TTF_SUBCLASS) {
|
||||
if (toolPtr->uFlags & TTF_IDISHWND) {
|
||||
RemoveWindowSubclass((HWND)toolPtr->uId, TOOLTIPS_SubclassProc, 1);
|
||||
}
|
||||
else {
|
||||
RemoveWindowSubclass(toolPtr->hwnd, TOOLTIPS_SubclassProc, 1);
|
||||
}
|
||||
}
|
||||
|
||||
/* delete tool from tool list */
|
||||
if (infoPtr->uNumTools == 1) {
|
||||
Free (infoPtr->tools);
|
||||
infoPtr->tools = NULL;
|
||||
}
|
||||
else {
|
||||
TTTOOL_INFO *oldTools = infoPtr->tools;
|
||||
infoPtr->tools =
|
||||
Alloc (sizeof(TTTOOL_INFO) * (infoPtr->uNumTools - 1));
|
||||
|
||||
if (nTool > 0)
|
||||
memcpy (&infoPtr->tools[0], &oldTools[0],
|
||||
nTool * sizeof(TTTOOL_INFO));
|
||||
|
||||
if (nTool < infoPtr->uNumTools - 1)
|
||||
memcpy (&infoPtr->tools[nTool], &oldTools[nTool + 1],
|
||||
(infoPtr->uNumTools - nTool - 1) * sizeof(TTTOOL_INFO));
|
||||
|
||||
Free (oldTools);
|
||||
}
|
||||
|
||||
/* destroying tool that mouse was on on last relayed mouse move */
|
||||
if (infoPtr->nTool == nTool)
|
||||
{
|
||||
/* no current tool (0 means first tool) */
|
||||
infoPtr->nTool = -1;
|
||||
}
|
||||
|
||||
infoPtr->uNumTools--;
|
||||
TOOLTIPS_DelToolCommon (hwnd, infoPtr, nTool);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -966,7 +990,6 @@ TOOLTIPS_DelToolW (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|||
{
|
||||
TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
|
||||
LPTTTOOLINFOW lpToolInfo = (LPTTTOOLINFOW)lParam;
|
||||
TTTOOL_INFO *toolPtr;
|
||||
INT nTool;
|
||||
|
||||
if (lpToolInfo == NULL)
|
||||
|
@ -977,60 +1000,8 @@ TOOLTIPS_DelToolW (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|||
return 0;
|
||||
|
||||
nTool = TOOLTIPS_GetToolFromInfoW (infoPtr, lpToolInfo);
|
||||
if (nTool == -1) return 0;
|
||||
|
||||
TRACE("tool %d\n", nTool);
|
||||
|
||||
/* make sure the tooltip has disappeared before deleting it */
|
||||
TOOLTIPS_Hide(hwnd, infoPtr);
|
||||
|
||||
/* delete text string */
|
||||
toolPtr = &infoPtr->tools[nTool];
|
||||
if (toolPtr->lpszText) {
|
||||
if ( (toolPtr->lpszText != LPSTR_TEXTCALLBACKW) &&
|
||||
(HIWORD((INT)toolPtr->lpszText) != 0) )
|
||||
Free (toolPtr->lpszText);
|
||||
}
|
||||
|
||||
/* remove subclassing */
|
||||
if (toolPtr->uFlags & TTF_SUBCLASS) {
|
||||
if (toolPtr->uFlags & TTF_IDISHWND) {
|
||||
RemoveWindowSubclass((HWND)toolPtr->uId, TOOLTIPS_SubclassProc, 1);
|
||||
}
|
||||
else {
|
||||
RemoveWindowSubclass(toolPtr->hwnd, TOOLTIPS_SubclassProc, 1);
|
||||
}
|
||||
}
|
||||
|
||||
/* delete tool from tool list */
|
||||
if (infoPtr->uNumTools == 1) {
|
||||
Free (infoPtr->tools);
|
||||
infoPtr->tools = NULL;
|
||||
}
|
||||
else {
|
||||
TTTOOL_INFO *oldTools = infoPtr->tools;
|
||||
infoPtr->tools =
|
||||
Alloc (sizeof(TTTOOL_INFO) * (infoPtr->uNumTools - 1));
|
||||
|
||||
if (nTool > 0)
|
||||
memcpy (&infoPtr->tools[0], &oldTools[0],
|
||||
nTool * sizeof(TTTOOL_INFO));
|
||||
|
||||
if (nTool < infoPtr->uNumTools - 1)
|
||||
memcpy (&infoPtr->tools[nTool], &oldTools[nTool + 1],
|
||||
(infoPtr->uNumTools - nTool - 1) * sizeof(TTTOOL_INFO));
|
||||
|
||||
Free (oldTools);
|
||||
}
|
||||
|
||||
/* destroying tool that mouse was on on last relayed mouse move */
|
||||
if (infoPtr->nTool == nTool)
|
||||
{
|
||||
/* no current tool (0 means first tool) */
|
||||
infoPtr->nTool = -1;
|
||||
}
|
||||
|
||||
infoPtr->uNumTools--;
|
||||
TOOLTIPS_DelToolCommon (hwnd, infoPtr, nTool);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -1482,6 +1453,9 @@ TOOLTIPS_NewToolRectA (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|||
return FALSE;
|
||||
|
||||
nTool = TOOLTIPS_GetToolFromInfoA (infoPtr, lpti);
|
||||
|
||||
TRACE("nTool = %d, rect = %s\n", nTool, wine_dbgstr_rect(&lpti->rect));
|
||||
|
||||
if (nTool == -1) return 0;
|
||||
|
||||
infoPtr->tools[nTool].rect = lpti->rect;
|
||||
|
@ -1503,6 +1477,9 @@ TOOLTIPS_NewToolRectW (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|||
return FALSE;
|
||||
|
||||
nTool = TOOLTIPS_GetToolFromInfoW (infoPtr, lpti);
|
||||
|
||||
TRACE("nTool = %d, rect = %s\n", nTool, wine_dbgstr_rect(&lpti->rect));
|
||||
|
||||
if (nTool == -1) return 0;
|
||||
|
||||
infoPtr->tools[nTool].rect = lpti->rect;
|
||||
|
@ -1790,6 +1767,8 @@ static LRESULT
|
|||
TOOLTIPS_TrackActivate (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
|
||||
|
||||
if ((BOOL)wParam) {
|
||||
LPTTTOOLINFOA lpToolInfo = (LPTTTOOLINFOA)lParam;
|
||||
|
||||
if (lpToolInfo == NULL)
|
||||
|
@ -1797,7 +1776,6 @@ TOOLTIPS_TrackActivate (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|||
if (lpToolInfo->cbSize < TTTOOLINFOA_V1_SIZE)
|
||||
return FALSE;
|
||||
|
||||
if ((BOOL)wParam) {
|
||||
/* activate */
|
||||
infoPtr->nTrackTool = TOOLTIPS_GetToolFromInfoA (infoPtr, lpToolInfo);
|
||||
if (infoPtr->nTrackTool != -1) {
|
||||
|
|
Loading…
Reference in New Issue