summaryrefslogtreecommitdiff
path: root/plugins/Scriver
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2016-11-02 18:30:41 +0300
committerGeorge Hazan <ghazan@miranda.im>2016-11-02 18:30:50 +0300
commit2c5081fe7d0e6b155847c5ead1b32b4b42bfe4ae (patch)
tree27cadc2a6f39c3de5ff94fd8a0edf714936434c2 /plugins/Scriver
parent2e8ebf3ad76d00ad32d4a492b32d360db87cb28e (diff)
- common mouse hovering processing code moved to MIR_APP_DLL
- now all chats support mToolTip
Diffstat (limited to 'plugins/Scriver')
-rw-r--r--plugins/Scriver/src/chat/window.cpp88
1 files changed, 2 insertions, 86 deletions
diff --git a/plugins/Scriver/src/chat/window.cpp b/plugins/Scriver/src/chat/window.cpp
index 461cb94a2c..c895b9e179 100644
--- a/plugins/Scriver/src/chat/window.cpp
+++ b/plugins/Scriver/src/chat/window.cpp
@@ -744,70 +744,6 @@ static LRESULT CALLBACK LogSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPAR
return mir_callNextSubclass(hwnd, LogSubclassProc, msg, wParam, lParam);
}
-static void ProcessNickListHovering(HWND hwnd, int hoveredItem, SESSION_INFO * parentdat)
-{
- static int currentHovered = -1;
- static HWND hwndToolTip = NULL;
- static HWND oldParent = NULL;
-
- if (hoveredItem == currentHovered)
- return;
-
- currentHovered = hoveredItem;
-
- if (oldParent != hwnd && hwndToolTip) {
- SendMessage(hwndToolTip, TTM_DELTOOL, 0, 0);
- DestroyWindow(hwndToolTip);
- hwndToolTip = NULL;
- }
- if (hoveredItem == -1) {
- SendMessage(hwndToolTip, TTM_ACTIVATE, 0, 0);
- return;
- }
-
- BOOL bNewTip = FALSE;
- if (!hwndToolTip) {
- hwndToolTip = CreateWindowEx(WS_EX_TOPMOST, TOOLTIPS_CLASS, NULL,
- WS_POPUP | TTS_NOPREFIX | TTS_ALWAYSTIP,
- CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
- hwnd, NULL, g_hInst, NULL);
- bNewTip = TRUE;
- }
-
- RECT clientRect;
- GetClientRect(hwnd, &clientRect);
- TOOLINFO ti = { sizeof(TOOLINFO) };
- ti.uFlags = TTF_SUBCLASS;
- ti.hinst = g_hInst;
- ti.hwnd = hwnd;
- ti.uId = 1;
- ti.rect = clientRect;
-
- wchar_t tszBuf[1024]; tszBuf[0] = 0;
- USERINFO *ui = pci->SM_GetUserFromIndex(parentdat->ptszID, parentdat->pszModule, currentHovered);
- if (ui) {
- if (ProtoServiceExists(parentdat->pszModule, MS_GC_PROTO_GETTOOLTIPTEXT)) {
- wchar_t *p = (wchar_t*)CallProtoService(parentdat->pszModule, MS_GC_PROTO_GETTOOLTIPTEXT, (WPARAM)parentdat->ptszID, (LPARAM)ui->pszUID);
- if (p != NULL) {
- wcsncpy_s(tszBuf, p, _TRUNCATE);
- mir_free(p);
- }
- }
-
- if (tszBuf[0] == 0)
- mir_snwprintf(tszBuf, L"%s: %s\r\n%s: %s\r\n%s: %s",
- TranslateT("Nickname"), ui->pszNick,
- TranslateT("Unique ID"), ui->pszUID,
- TranslateT("Status"), pci->TM_WordToString(parentdat->pStatuses, ui->Status));
-
- ti.lpszText = tszBuf;
- }
-
- SendMessage(hwndToolTip, bNewTip ? TTM_ADDTOOL : TTM_UPDATETIPTEXT, 0, (LPARAM)&ti);
- SendMessage(hwndToolTip, TTM_ACTIVATE, ti.lpszText != NULL, 0);
- SendMessage(hwndToolTip, TTM_SETMAXTIPWIDTH, 0, 400);
-}
-
static LRESULT CALLBACK NicklistSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
SESSION_INFO *si = (SESSION_INFO*)GetWindowLongPtr(GetParent(hwnd), GWLP_USERDATA);
@@ -991,28 +927,8 @@ static LRESULT CALLBACK NicklistSubclassProc(HWND hwnd, UINT msg, WPARAM wParam,
break;
case WM_MOUSEMOVE:
- POINT pt = { LOWORD(lParam), HIWORD(lParam) };
- RECT clientRect;
- GetClientRect(hwnd, &clientRect);
-
- // Mouse capturing/releasing
- BOOL bInClient = PtInRect(&clientRect, pt);
- if (bInClient && GetCapture() != hwnd)
- SetCapture(hwnd);
- else if (!bInClient)
- ReleaseCapture();
-
- if (bInClient) {
- // hit test item under mouse
- DWORD nItemUnderMouse = (DWORD)SendMessage(hwnd, LB_ITEMFROMPOINT, 0, lParam);
- if (HIWORD(nItemUnderMouse) == 1)
- nItemUnderMouse = (DWORD)(-1);
- else
- nItemUnderMouse &= 0xFFFF;
-
- ProcessNickListHovering(hwnd, (int)nItemUnderMouse, si);
- }
- else ProcessNickListHovering(hwnd, -1, NULL);
+ Chat_HoverMouse(si, hwnd, lParam, ServiceExists("mToolTip/HideTip"));
+ break;
}
return mir_callNextSubclass(hwnd, NicklistSubclassProc, msg, wParam, lParam);