📄 tooltips.c
字号:
/* lpToolInfo->lpszText = toolPtr->lpszText; */
lpToolInfo->lpszText = NULL; /* FIXME */
if (lpToolInfo->cbSize >= sizeof(TTTOOLINFOA))
lpToolInfo->lParam = toolPtr->lParam;
return TRUE;
}
else
return FALSE;
}
else
return (infoPtr->nCurrentTool != -1);
}
static LRESULT
TOOLTIPS_GetCurrentToolW (HWND hwnd, WPARAM wParam, LPARAM lParam)
{
TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
LPTTTOOLINFOW lpToolInfo = (LPTTTOOLINFOW)lParam;
TTTOOL_INFO *toolPtr;
if (lpToolInfo == NULL)
return FALSE;
if (lpToolInfo->cbSize < TTTOOLINFOW_V1_SIZE)
return FALSE;
if (lpToolInfo) {
if (infoPtr->nCurrentTool > -1) {
toolPtr = &infoPtr->tools[infoPtr->nCurrentTool];
/* copy tool data */
lpToolInfo->uFlags = toolPtr->uFlags;
lpToolInfo->rect = toolPtr->rect;
lpToolInfo->hinst = toolPtr->hinst;
/* lpToolInfo->lpszText = toolPtr->lpszText; */
lpToolInfo->lpszText = NULL; /* FIXME */
if (lpToolInfo->cbSize >= sizeof(TTTOOLINFOW))
lpToolInfo->lParam = toolPtr->lParam;
return TRUE;
}
else
return FALSE;
}
else
return (infoPtr->nCurrentTool != -1);
}
static LRESULT
TOOLTIPS_GetDelayTime (HWND hwnd, WPARAM wParam, LPARAM lParam)
{
TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
switch (wParam) {
case TTDT_RESHOW:
return infoPtr->nReshowTime;
case TTDT_AUTOPOP:
return infoPtr->nAutoPopTime;
case TTDT_INITIAL:
case TTDT_AUTOMATIC: /* Apparently TTDT_AUTOMATIC returns TTDT_INITIAL */
return infoPtr->nInitialTime;
default:
WARN("Invalid wParam %x\n", wParam);
break;
}
return -1;
}
static LRESULT
TOOLTIPS_GetMargin (HWND hwnd, WPARAM wParam, LPARAM lParam)
{
TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
LPRECT lpRect = (LPRECT)lParam;
lpRect->left = infoPtr->rcMargin.left;
lpRect->right = infoPtr->rcMargin.right;
lpRect->bottom = infoPtr->rcMargin.bottom;
lpRect->top = infoPtr->rcMargin.top;
return 0;
}
inline static LRESULT
TOOLTIPS_GetMaxTipWidth (HWND hwnd, WPARAM wParam, LPARAM lParam)
{
TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
return infoPtr->nMaxTipWidth;
}
static LRESULT
TOOLTIPS_GetTextA (HWND hwnd, WPARAM wParam, LPARAM lParam)
{
TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
LPTTTOOLINFOA lpToolInfo = (LPTTTOOLINFOA)lParam;
INT nTool;
if (lpToolInfo == NULL)
return 0;
if (lpToolInfo->cbSize < TTTOOLINFOA_V1_SIZE)
return 0;
nTool = TOOLTIPS_GetToolFromInfoA (infoPtr, lpToolInfo);
if (nTool == -1) return 0;
/* NB this API is broken, there is no way for the app to determine
what size buffer it requires nor a way to specify how long the
one it supplies is. We'll assume it's up to INFOTIPSIZE */
WideCharToMultiByte(CP_ACP, 0, infoPtr->tools[nTool].lpszText, -1,
lpToolInfo->lpszText, INFOTIPSIZE, NULL, NULL);
return 0;
}
static LRESULT
TOOLTIPS_GetTextW (HWND hwnd, WPARAM wParam, LPARAM lParam)
{
TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
LPTTTOOLINFOW lpToolInfo = (LPTTTOOLINFOW)lParam;
INT nTool;
if (lpToolInfo == NULL)
return 0;
if (lpToolInfo->cbSize < TTTOOLINFOW_V1_SIZE)
return 0;
nTool = TOOLTIPS_GetToolFromInfoW (infoPtr, lpToolInfo);
if (nTool == -1) return 0;
strcpyW (lpToolInfo->lpszText, infoPtr->tools[nTool].lpszText);
return 0;
}
inline static LRESULT
TOOLTIPS_GetTipBkColor (HWND hwnd, WPARAM wParam, LPARAM lParam)
{
TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
return infoPtr->clrBk;
}
inline static LRESULT
TOOLTIPS_GetTipTextColor (HWND hwnd, WPARAM wParam, LPARAM lParam)
{
TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
return infoPtr->clrText;
}
inline static LRESULT
TOOLTIPS_GetToolCount (HWND hwnd, WPARAM wParam, LPARAM lParam)
{
TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
return infoPtr->uNumTools;
}
static LRESULT
TOOLTIPS_GetToolInfoA (HWND hwnd, WPARAM wParam, LPARAM lParam)
{
TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
LPTTTOOLINFOA lpToolInfo = (LPTTTOOLINFOA)lParam;
TTTOOL_INFO *toolPtr;
INT nTool;
if (lpToolInfo == NULL)
return FALSE;
if (lpToolInfo->cbSize < TTTOOLINFOA_V1_SIZE)
return FALSE;
if (infoPtr->uNumTools == 0)
return FALSE;
nTool = TOOLTIPS_GetToolFromInfoA (infoPtr, lpToolInfo);
if (nTool == -1)
return FALSE;
TRACE("tool %d\n", nTool);
toolPtr = &infoPtr->tools[nTool];
/* copy tool data */
lpToolInfo->uFlags = toolPtr->uFlags;
lpToolInfo->rect = toolPtr->rect;
lpToolInfo->hinst = toolPtr->hinst;
/* lpToolInfo->lpszText = toolPtr->lpszText; */
lpToolInfo->lpszText = NULL; /* FIXME */
if (lpToolInfo->cbSize >= sizeof(TTTOOLINFOA))
lpToolInfo->lParam = toolPtr->lParam;
return TRUE;
}
static LRESULT
TOOLTIPS_GetToolInfoW (HWND hwnd, WPARAM wParam, LPARAM lParam)
{
TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
LPTTTOOLINFOW lpToolInfo = (LPTTTOOLINFOW)lParam;
TTTOOL_INFO *toolPtr;
INT nTool;
if (lpToolInfo == NULL)
return FALSE;
if (lpToolInfo->cbSize < TTTOOLINFOW_V1_SIZE)
return FALSE;
if (infoPtr->uNumTools == 0)
return FALSE;
nTool = TOOLTIPS_GetToolFromInfoW (infoPtr, lpToolInfo);
if (nTool == -1)
return FALSE;
TRACE("tool %d\n", nTool);
toolPtr = &infoPtr->tools[nTool];
/* copy tool data */
lpToolInfo->uFlags = toolPtr->uFlags;
lpToolInfo->rect = toolPtr->rect;
lpToolInfo->hinst = toolPtr->hinst;
/* lpToolInfo->lpszText = toolPtr->lpszText; */
lpToolInfo->lpszText = NULL; /* FIXME */
if (lpToolInfo->cbSize >= sizeof(TTTOOLINFOW))
lpToolInfo->lParam = toolPtr->lParam;
return TRUE;
}
static LRESULT
TOOLTIPS_HitTestA (HWND hwnd, WPARAM wParam, LPARAM lParam)
{
TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
LPTTHITTESTINFOA lptthit = (LPTTHITTESTINFOA)lParam;
TTTOOL_INFO *toolPtr;
INT nTool;
if (lptthit == 0)
return FALSE;
nTool = TOOLTIPS_GetToolFromPoint (infoPtr, lptthit->hwnd, &lptthit->pt);
if (nTool == -1)
return FALSE;
TRACE("tool %d!\n", nTool);
/* copy tool data */
if (lptthit->ti.cbSize >= sizeof(TTTOOLINFOA)) {
toolPtr = &infoPtr->tools[nTool];
lptthit->ti.uFlags = toolPtr->uFlags;
lptthit->ti.hwnd = toolPtr->hwnd;
lptthit->ti.uId = toolPtr->uId;
lptthit->ti.rect = toolPtr->rect;
lptthit->ti.hinst = toolPtr->hinst;
/* lptthit->ti.lpszText = toolPtr->lpszText; */
lptthit->ti.lpszText = NULL; /* FIXME */
lptthit->ti.lParam = toolPtr->lParam;
}
return TRUE;
}
static LRESULT
TOOLTIPS_HitTestW (HWND hwnd, WPARAM wParam, LPARAM lParam)
{
TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
LPTTHITTESTINFOW lptthit = (LPTTHITTESTINFOW)lParam;
TTTOOL_INFO *toolPtr;
INT nTool;
if (lptthit == 0)
return FALSE;
nTool = TOOLTIPS_GetToolFromPoint (infoPtr, lptthit->hwnd, &lptthit->pt);
if (nTool == -1)
return FALSE;
TRACE("tool %d!\n", nTool);
/* copy tool data */
if (lptthit->ti.cbSize >= sizeof(TTTOOLINFOW)) {
toolPtr = &infoPtr->tools[nTool];
lptthit->ti.uFlags = toolPtr->uFlags;
lptthit->ti.hwnd = toolPtr->hwnd;
lptthit->ti.uId = toolPtr->uId;
lptthit->ti.rect = toolPtr->rect;
lptthit->ti.hinst = toolPtr->hinst;
/* lptthit->ti.lpszText = toolPtr->lpszText; */
lptthit->ti.lpszText = NULL; /* FIXME */
lptthit->ti.lParam = toolPtr->lParam;
}
return TRUE;
}
static LRESULT
TOOLTIPS_NewToolRectA (HWND hwnd, WPARAM wParam, LPARAM lParam)
{
TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
LPTTTOOLINFOA lpti = (LPTTTOOLINFOA)lParam;
INT nTool;
if (lpti == NULL)
return 0;
if (lpti->cbSize < TTTOOLINFOA_V1_SIZE)
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;
return 0;
}
static LRESULT
TOOLTIPS_NewToolRectW (HWND hwnd, WPARAM wParam, LPARAM lParam)
{
TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
LPTTTOOLINFOW lpti = (LPTTTOOLINFOW)lParam;
INT nTool;
if (lpti == NULL)
return 0;
if (lpti->cbSize < TTTOOLINFOW_V1_SIZE)
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;
return 0;
}
inline static LRESULT
TOOLTIPS_Pop (HWND hwnd, WPARAM wParam, LPARAM lParam)
{
TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
TOOLTIPS_Hide (hwnd, infoPtr);
return 0;
}
static LRESULT
TOOLTIPS_RelayEvent (HWND hwnd, WPARAM wParam, LPARAM lParam)
{
TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
LPMSG lpMsg = (LPMSG)lParam;
POINT pt;
INT nOldTool;
if (lParam == 0) {
ERR("lpMsg == NULL!\n");
return 0;
}
switch (lpMsg->message) {
case WM_LBUTTONDOWN:
case WM_LBUTTONUP:
case WM_MBUTTONDOWN:
case WM_MBUTTONUP:
case WM_RBUTTONDOWN:
case WM_RBUTTONUP:
TOOLTIPS_Hide (hwnd, infoPtr);
break;
case WM_MOUSEMOVE:
pt.x = (short)LOWORD(lpMsg->lParam);
pt.y = (short)HIWORD(lpMsg->lParam);
nOldTool = infoPtr->nTool;
infoPtr->nTool = TOOLTIPS_GetToolFromPoint(infoPtr, lpMsg->hwnd,
&pt);
TRACE("tool (%p) %d %d %d\n", hwnd, nOldTool,
infoPtr->nTool, infoPtr->nCurrentTool);
TRACE("WM_MOUSEMOVE (%p %d %d)\n", hwnd, pt.x, pt.y);
if (infoPtr->nTool != nOldTool) {
if(infoPtr->nTool == -1) { /* Moved out of all tools */
TOOLTIPS_Hide(hwnd, infoPtr);
KillTimer(hwnd, ID_TIMERLEAVE);
} else if (nOldTool == -1) { /* Moved from outside */
if(infoPtr->bActive) {
SetTimer(hwnd, ID_TIMERSHOW, infoPtr->nInitialTime, 0);
TRACE("timer 1 started!\n");
}
} else { /* Moved from one to another */
TOOLTIPS_Hide (hwnd, infoPtr);
KillTimer(hwnd, ID_TIMERLEAVE);
if(infoPtr->bActive) {
SetTimer (hwnd, ID_TIMERSHOW, infoPtr->nReshowTime, 0);
TRACE("timer 1 started!\n");
}
}
} else if(infoPtr->nCurrentTool != -1) { /* restart autopop */
KillTimer(hwnd, ID_TIMERPOP);
SetTimer(hwnd, ID_TIMERPOP, infoPtr->nAutoPopTime, 0);
TRACE("timer 2 restarted\n");
} else if(infoPtr->nTool != -1 && infoPtr->bActive) {
/* previous show attempt didn't result in tooltip so try again */
SetTimer(hwnd, ID_TIMERSHOW, infoPtr->nInitialTime, 0);
TRACE("timer 1 started!\n");
}
break;
}
return 0;
}
static LRESULT
TOOLTIPS_SetDelayTime (HWND hwnd, WPARAM wParam, LPARAM lParam)
{
TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
INT nTime = (INT)LOWORD(lParam);
switch (wParam) {
case TTDT_AUTOMATIC:
if (nTime <= 0)
nTime = GetDoubleClickTime();
infoPtr->nReshowTime = nTime / 5;
infoPtr->nAutoPopTime = nTime * 10;
infoPtr->nInitialTime = nTime;
break;
case TTDT_RESHOW:
if(nTime < 0)
nTime = GetDoubleClickTime() / 5;
infoPtr->nReshowTime = nTime;
break;
case TTDT_AUTOPOP:
if(nTime < 0)
nTime = GetDoubleClickTime() * 10;
infoPtr->nAutoPopTime = nTime;
break;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -