comctl32: Unify the implementation of TOOLTIPS_Show and TOOLTIPS_TrackShow to give tracked tooltips balloon support.
This commit is contained in:
parent
c02b46d987
commit
5ff8e6d7e1
|
@ -515,7 +515,7 @@ TOOLTIPS_CalcTipSize (HWND hwnd, const TOOLTIPS_INFO *infoPtr, LPSIZE lpSize)
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
TOOLTIPS_Show (HWND hwnd, TOOLTIPS_INFO *infoPtr)
|
TOOLTIPS_Show (HWND hwnd, TOOLTIPS_INFO *infoPtr, BOOL track_activate)
|
||||||
{
|
{
|
||||||
TTTOOL_INFO *toolPtr;
|
TTTOOL_INFO *toolPtr;
|
||||||
HMONITOR monitor;
|
HMONITOR monitor;
|
||||||
|
@ -525,25 +525,40 @@ TOOLTIPS_Show (HWND hwnd, TOOLTIPS_INFO *infoPtr)
|
||||||
NMHDR hdr;
|
NMHDR hdr;
|
||||||
int ptfx = 0;
|
int ptfx = 0;
|
||||||
DWORD style = GetWindowLongW(hwnd, GWL_STYLE);
|
DWORD style = GetWindowLongW(hwnd, GWL_STYLE);
|
||||||
|
INT nTool;
|
||||||
|
|
||||||
if (infoPtr->nTool == -1) {
|
if (track_activate)
|
||||||
|
{
|
||||||
|
if (infoPtr->nTrackTool == -1)
|
||||||
|
{
|
||||||
|
TRACE("invalid tracking tool (-1)!\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
nTool = infoPtr->nTrackTool;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (infoPtr->nTool == -1)
|
||||||
|
{
|
||||||
TRACE("invalid tool (-1)!\n");
|
TRACE("invalid tool (-1)!\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
nTool = infoPtr->nTool;
|
||||||
infoPtr->nCurrentTool = infoPtr->nTool;
|
|
||||||
|
|
||||||
TRACE("Show tooltip pre %d! (%p)\n", infoPtr->nTool, hwnd);
|
|
||||||
|
|
||||||
TOOLTIPS_GetTipText (hwnd, infoPtr, infoPtr->nCurrentTool);
|
|
||||||
|
|
||||||
if (infoPtr->szTipText[0] == '\0') {
|
|
||||||
infoPtr->nCurrentTool = -1;
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TRACE("Show tooltip %d!\n", infoPtr->nCurrentTool);
|
TRACE("Show tooltip pre %d! (%p)\n", nTool, hwnd);
|
||||||
toolPtr = &infoPtr->tools[infoPtr->nCurrentTool];
|
|
||||||
|
TOOLTIPS_GetTipText (hwnd, infoPtr, nTool);
|
||||||
|
|
||||||
|
if (infoPtr->szTipText[0] == '\0')
|
||||||
|
return;
|
||||||
|
|
||||||
|
toolPtr = &infoPtr->tools[nTool];
|
||||||
|
|
||||||
|
if (!track_activate)
|
||||||
|
infoPtr->nCurrentTool = infoPtr->nTool;
|
||||||
|
|
||||||
|
TRACE("Show tooltip %d!\n", nTool);
|
||||||
|
|
||||||
hdr.hwndFrom = hwnd;
|
hdr.hwndFrom = hwnd;
|
||||||
hdr.idFrom = toolPtr->uId;
|
hdr.idFrom = toolPtr->uId;
|
||||||
|
@ -556,41 +571,26 @@ TOOLTIPS_Show (HWND hwnd, TOOLTIPS_INFO *infoPtr)
|
||||||
TOOLTIPS_CalcTipSize (hwnd, infoPtr, &size);
|
TOOLTIPS_CalcTipSize (hwnd, infoPtr, &size);
|
||||||
TRACE("size %d x %d\n", size.cx, size.cy);
|
TRACE("size %d x %d\n", size.cx, size.cy);
|
||||||
|
|
||||||
if (toolPtr->uFlags & TTF_CENTERTIP) {
|
if (track_activate)
|
||||||
RECT rc;
|
{
|
||||||
|
if (toolPtr->uFlags & TTF_ABSOLUTE)
|
||||||
|
{
|
||||||
|
rect.left = infoPtr->xTrackPos;
|
||||||
|
rect.top = infoPtr->yTrackPos;
|
||||||
|
ptfx = rect.left;
|
||||||
|
|
||||||
if (toolPtr->uFlags & TTF_IDISHWND)
|
if (toolPtr->uFlags & TTF_CENTERTIP)
|
||||||
GetWindowRect ((HWND)toolPtr->uId, &rc);
|
{
|
||||||
else {
|
rect.left -= (size.cx / 2);
|
||||||
rc = toolPtr->rect;
|
if (!(style & TTS_BALLOON))
|
||||||
MapWindowPoints (toolPtr->hwnd, NULL, (LPPOINT)&rc, 2);
|
rect.top -= (size.cy / 2);
|
||||||
}
|
}
|
||||||
rect.left = (rc.left + rc.right - size.cx) / 2;
|
infoPtr->bToolBelow = TRUE;
|
||||||
if (style & TTS_BALLOON)
|
|
||||||
{
|
|
||||||
ptfx = rc.left + ((rc.right - rc.left) / 2);
|
|
||||||
|
|
||||||
/* CENTERTIP ballon tooltips default to below the field
|
|
||||||
if they fit on the screen */
|
|
||||||
if(rc.bottom + size.cy > GetSystemMetrics(SM_CYSCREEN))
|
|
||||||
{
|
|
||||||
rect.top = rc.top - size.cy;
|
|
||||||
infoPtr->bToolBelow = FALSE;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
infoPtr->bToolBelow = TRUE;
|
RECT rcTool;
|
||||||
rect.top = rc.bottom;
|
|
||||||
}
|
|
||||||
rect.left = max(0, rect.left - BALLOON_STEMINDENT);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
rect.top = rc.bottom + 2;
|
|
||||||
infoPtr->bToolBelow = TRUE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
GetCursorPos ((LPPOINT)&rect);
|
GetCursorPos ((LPPOINT)&rect);
|
||||||
if (style & TTS_BALLOON)
|
if (style & TTS_BALLOON)
|
||||||
{
|
{
|
||||||
|
@ -612,6 +612,88 @@ TOOLTIPS_Show (HWND hwnd, TOOLTIPS_INFO *infoPtr)
|
||||||
rect.top += 20;
|
rect.top += 20;
|
||||||
infoPtr->bToolBelow = TRUE;
|
infoPtr->bToolBelow = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (toolPtr->uFlags & TTF_CENTERTIP)
|
||||||
|
{
|
||||||
|
rect.left -= (size.cx / 2);
|
||||||
|
rect.top -= (size.cy / 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (toolPtr->uFlags & TTF_IDISHWND)
|
||||||
|
GetWindowRect ((HWND)toolPtr->uId, &rcTool);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
rcTool = toolPtr->rect;
|
||||||
|
MapWindowPoints (toolPtr->hwnd, NULL, (LPPOINT)&rcTool, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* smart placement */
|
||||||
|
if ((rect.left + size.cx > rcTool.left) && (rect.left < rcTool.right) &&
|
||||||
|
(rect.top + size.cy > rcTool.top) && (rect.top < rcTool.bottom))
|
||||||
|
rect.left = rcTool.right;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (toolPtr->uFlags & TTF_CENTERTIP)
|
||||||
|
{
|
||||||
|
RECT rc;
|
||||||
|
|
||||||
|
if (toolPtr->uFlags & TTF_IDISHWND)
|
||||||
|
GetWindowRect ((HWND)toolPtr->uId, &rc);
|
||||||
|
else {
|
||||||
|
rc = toolPtr->rect;
|
||||||
|
MapWindowPoints (toolPtr->hwnd, NULL, (LPPOINT)&rc, 2);
|
||||||
|
}
|
||||||
|
rect.left = (rc.left + rc.right - size.cx) / 2;
|
||||||
|
if (style & TTS_BALLOON)
|
||||||
|
{
|
||||||
|
ptfx = rc.left + ((rc.right - rc.left) / 2);
|
||||||
|
|
||||||
|
/* CENTERTIP ballon tooltips default to below the field
|
||||||
|
* if they fit on the screen */
|
||||||
|
if (rc.bottom + size.cy > GetSystemMetrics(SM_CYSCREEN))
|
||||||
|
{
|
||||||
|
rect.top = rc.top - size.cy;
|
||||||
|
infoPtr->bToolBelow = FALSE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
infoPtr->bToolBelow = TRUE;
|
||||||
|
rect.top = rc.bottom;
|
||||||
|
}
|
||||||
|
rect.left = max(0, rect.left - BALLOON_STEMINDENT);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
rect.top = rc.bottom + 2;
|
||||||
|
infoPtr->bToolBelow = TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
GetCursorPos ((LPPOINT)&rect);
|
||||||
|
if (style & TTS_BALLOON)
|
||||||
|
{
|
||||||
|
ptfx = rect.left;
|
||||||
|
if(rect.top - size.cy >= 0)
|
||||||
|
{
|
||||||
|
rect.top -= size.cy;
|
||||||
|
infoPtr->bToolBelow = FALSE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
infoPtr->bToolBelow = TRUE;
|
||||||
|
rect.top += 20;
|
||||||
|
}
|
||||||
|
rect.left = max(0, rect.left - BALLOON_STEMINDENT);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
rect.top += 20;
|
||||||
|
infoPtr->bToolBelow = TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TRACE("pos %d - %d\n", rect.left, rect.top);
|
TRACE("pos %d - %d\n", rect.left, rect.top);
|
||||||
|
@ -708,11 +790,14 @@ TOOLTIPS_Show (HWND hwnd, TOOLTIPS_INFO *infoPtr)
|
||||||
InvalidateRect(hwnd, NULL, TRUE);
|
InvalidateRect(hwnd, NULL, TRUE);
|
||||||
UpdateWindow(hwnd);
|
UpdateWindow(hwnd);
|
||||||
|
|
||||||
|
if (!track_activate)
|
||||||
|
{
|
||||||
SetTimer (hwnd, ID_TIMERPOP, infoPtr->nAutoPopTime, 0);
|
SetTimer (hwnd, ID_TIMERPOP, infoPtr->nAutoPopTime, 0);
|
||||||
TRACE("timer 2 started!\n");
|
TRACE("timer 2 started!\n");
|
||||||
SetTimer (hwnd, ID_TIMERLEAVE, infoPtr->nReshowTime, 0);
|
SetTimer (hwnd, ID_TIMERLEAVE, infoPtr->nReshowTime, 0);
|
||||||
TRACE("timer 3 started!\n");
|
TRACE("timer 3 started!\n");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -745,98 +830,7 @@ TOOLTIPS_Hide (HWND hwnd, TOOLTIPS_INFO *infoPtr)
|
||||||
static void
|
static void
|
||||||
TOOLTIPS_TrackShow (HWND hwnd, TOOLTIPS_INFO *infoPtr)
|
TOOLTIPS_TrackShow (HWND hwnd, TOOLTIPS_INFO *infoPtr)
|
||||||
{
|
{
|
||||||
TTTOOL_INFO *toolPtr;
|
TOOLTIPS_Show(hwnd, infoPtr, TRUE);
|
||||||
RECT rect;
|
|
||||||
SIZE size;
|
|
||||||
NMHDR hdr;
|
|
||||||
|
|
||||||
if (infoPtr->nTrackTool == -1) {
|
|
||||||
TRACE("invalid tracking tool (-1)!\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
TRACE("show tracking tooltip pre %d!\n", infoPtr->nTrackTool);
|
|
||||||
|
|
||||||
TOOLTIPS_GetTipText (hwnd, infoPtr, infoPtr->nTrackTool);
|
|
||||||
|
|
||||||
if (infoPtr->szTipText[0] == '\0') {
|
|
||||||
infoPtr->nTrackTool = -1;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
TRACE("show tracking tooltip %d!\n", infoPtr->nTrackTool);
|
|
||||||
toolPtr = &infoPtr->tools[infoPtr->nTrackTool];
|
|
||||||
|
|
||||||
hdr.hwndFrom = hwnd;
|
|
||||||
hdr.idFrom = toolPtr->uId;
|
|
||||||
hdr.code = TTN_SHOW;
|
|
||||||
SendMessageW (toolPtr->hwnd, WM_NOTIFY,
|
|
||||||
(WPARAM)toolPtr->uId, (LPARAM)&hdr);
|
|
||||||
|
|
||||||
TRACE("%s\n", debugstr_w(infoPtr->szTipText));
|
|
||||||
|
|
||||||
TOOLTIPS_CalcTipSize (hwnd, infoPtr, &size);
|
|
||||||
TRACE("size %d x %d\n", size.cx, size.cy);
|
|
||||||
|
|
||||||
if (toolPtr->uFlags & TTF_ABSOLUTE) {
|
|
||||||
rect.left = infoPtr->xTrackPos;
|
|
||||||
rect.top = infoPtr->yTrackPos;
|
|
||||||
|
|
||||||
if (toolPtr->uFlags & TTF_CENTERTIP) {
|
|
||||||
rect.left -= (size.cx / 2);
|
|
||||||
rect.top -= (size.cy / 2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
RECT rcTool;
|
|
||||||
|
|
||||||
if (toolPtr->uFlags & TTF_IDISHWND)
|
|
||||||
GetWindowRect ((HWND)toolPtr->uId, &rcTool);
|
|
||||||
else {
|
|
||||||
rcTool = toolPtr->rect;
|
|
||||||
MapWindowPoints (toolPtr->hwnd, NULL, (LPPOINT)&rcTool, 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
GetCursorPos ((LPPOINT)&rect);
|
|
||||||
rect.top += 20;
|
|
||||||
|
|
||||||
if (toolPtr->uFlags & TTF_CENTERTIP) {
|
|
||||||
rect.left -= (size.cx / 2);
|
|
||||||
rect.top -= (size.cy / 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* smart placement */
|
|
||||||
if ((rect.left + size.cx > rcTool.left) && (rect.left < rcTool.right) &&
|
|
||||||
(rect.top + size.cy > rcTool.top) && (rect.top < rcTool.bottom))
|
|
||||||
rect.left = rcTool.right;
|
|
||||||
}
|
|
||||||
|
|
||||||
TRACE("pos %d - %d\n", rect.left, rect.top);
|
|
||||||
|
|
||||||
rect.right = rect.left + size.cx;
|
|
||||||
rect.bottom = rect.top + size.cy;
|
|
||||||
|
|
||||||
AdjustWindowRectEx (&rect, GetWindowLongW (hwnd, GWL_STYLE),
|
|
||||||
FALSE, GetWindowLongW (hwnd, GWL_EXSTYLE));
|
|
||||||
|
|
||||||
if (GetWindowLongW(hwnd, GWL_STYLE) & TTS_BALLOON)
|
|
||||||
{
|
|
||||||
HRGN hRgn;
|
|
||||||
|
|
||||||
/* FIXME: need to add pointy bit using CreatePolyRgn & CombinRgn */
|
|
||||||
hRgn = CreateRoundRectRgn(0, 0, rect.right - rect.left, rect.bottom - rect.top, BALLOON_ROUNDEDNESS, BALLOON_ROUNDEDNESS);
|
|
||||||
|
|
||||||
SetWindowRgn(hwnd, hRgn, FALSE);
|
|
||||||
/* we don't free the region handle as the system deletes it when
|
|
||||||
* it is no longer needed */
|
|
||||||
}
|
|
||||||
|
|
||||||
SetWindowPos (hwnd, HWND_TOP, rect.left, rect.top,
|
|
||||||
rect.right - rect.left, rect.bottom - rect.top,
|
|
||||||
SWP_SHOWWINDOW | SWP_NOACTIVATE );
|
|
||||||
|
|
||||||
InvalidateRect(hwnd, NULL, TRUE);
|
|
||||||
UpdateWindow(hwnd);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -2133,7 +2127,7 @@ TOOLTIPS_SetToolInfoW (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
||||||
if (infoPtr->szTipText[0] == 0)
|
if (infoPtr->szTipText[0] == 0)
|
||||||
TOOLTIPS_Hide(hwnd, infoPtr);
|
TOOLTIPS_Hide(hwnd, infoPtr);
|
||||||
else
|
else
|
||||||
TOOLTIPS_Show (hwnd, infoPtr);
|
TOOLTIPS_Show (hwnd, infoPtr, FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -2255,7 +2249,7 @@ TOOLTIPS_UpdateTipTextA (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
||||||
if(infoPtr->nCurrentTool == -1) return 0;
|
if(infoPtr->nCurrentTool == -1) return 0;
|
||||||
/* force repaint */
|
/* force repaint */
|
||||||
if (infoPtr->bActive)
|
if (infoPtr->bActive)
|
||||||
TOOLTIPS_Show (hwnd, infoPtr);
|
TOOLTIPS_Show (hwnd, infoPtr, FALSE);
|
||||||
else if (infoPtr->bTrackActive)
|
else if (infoPtr->bTrackActive)
|
||||||
TOOLTIPS_TrackShow (hwnd, infoPtr);
|
TOOLTIPS_TrackShow (hwnd, infoPtr);
|
||||||
|
|
||||||
|
@ -2311,9 +2305,9 @@ TOOLTIPS_UpdateTipTextW (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
||||||
if(infoPtr->nCurrentTool == -1) return 0;
|
if(infoPtr->nCurrentTool == -1) return 0;
|
||||||
/* force repaint */
|
/* force repaint */
|
||||||
if (infoPtr->bActive)
|
if (infoPtr->bActive)
|
||||||
TOOLTIPS_Show (hwnd, infoPtr);
|
TOOLTIPS_Show (hwnd, infoPtr, FALSE);
|
||||||
else if (infoPtr->bTrackActive)
|
else if (infoPtr->bTrackActive)
|
||||||
TOOLTIPS_TrackShow (hwnd, infoPtr);
|
TOOLTIPS_Show (hwnd, infoPtr, TRUE);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -2570,7 +2564,7 @@ TOOLTIPS_Timer (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
||||||
KillTimer (hwnd, ID_TIMERSHOW);
|
KillTimer (hwnd, ID_TIMERSHOW);
|
||||||
nOldTool = infoPtr->nTool;
|
nOldTool = infoPtr->nTool;
|
||||||
if ((infoPtr->nTool = TOOLTIPS_CheckTool (hwnd, TRUE)) == nOldTool)
|
if ((infoPtr->nTool = TOOLTIPS_CheckTool (hwnd, TRUE)) == nOldTool)
|
||||||
TOOLTIPS_Show (hwnd, infoPtr);
|
TOOLTIPS_Show (hwnd, infoPtr, FALSE);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ID_TIMERPOP:
|
case ID_TIMERPOP:
|
||||||
|
|
Loading…
Reference in New Issue