summaryrefslogtreecommitdiff
path: root/plugins
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
parent2e8ebf3ad76d00ad32d4a492b32d360db87cb28e (diff)
- common mouse hovering processing code moved to MIR_APP_DLL
- now all chats support mToolTip
Diffstat (limited to 'plugins')
-rw-r--r--plugins/Scriver/src/chat/window.cpp88
-rw-r--r--plugins/TabSRMM/src/chat/chat.h2
-rw-r--r--plugins/TabSRMM/src/chat/window.cpp174
3 files changed, 14 insertions, 250 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);
diff --git a/plugins/TabSRMM/src/chat/chat.h b/plugins/TabSRMM/src/chat/chat.h
index 59f4078655..d85b8986a6 100644
--- a/plugins/TabSRMM/src/chat/chat.h
+++ b/plugins/TabSRMM/src/chat/chat.h
@@ -62,7 +62,7 @@ struct SESSION_INFO : public GCSessionInfoBase
int iLogTrayFlags, iLogPopupFlags, iDiskLogFlags;
int iSearchItem;
- wchar_t szSearch[255];
+ wchar_t szSearch[255];
};
struct LOGSTREAMDATA : public GCLogStreamDataBase
diff --git a/plugins/TabSRMM/src/chat/window.cpp b/plugins/TabSRMM/src/chat/window.cpp
index d44c0bb5b6..679b64152a 100644
--- a/plugins/TabSRMM/src/chat/window.cpp
+++ b/plugins/TabSRMM/src/chat/window.cpp
@@ -1264,76 +1264,6 @@ static LRESULT CALLBACK LogSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPAR
}
/////////////////////////////////////////////////////////////////////////////////////////
-// process mouse - hovering for the nickname list.fires events so the protocol can
-// show the userinfo - tooltip.
-
-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) {
- bNewTip = true;
- 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);
- }
-
- RECT clientRect;
- GetClientRect(hwnd, &clientRect);
-
- TOOLINFO ti = { sizeof(ti) };
- 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 *ui1 = pci->SM_GetUserFromIndex(parentdat->ptszID, parentdat->pszModule, currentHovered);
- if (ui1) {
- if (ProtoServiceExists(parentdat->pszModule, MS_GC_PROTO_GETTOOLTIPTEXT)) {
- wchar_t *p = (wchar_t*)CallProtoService(parentdat->pszModule, MS_GC_PROTO_GETTOOLTIPTEXT, (WPARAM)parentdat->ptszID, (LPARAM)ui1->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"), ui1->pszNick,
- TranslateT("Unique ID"), ui1->pszUID,
- TranslateT("Status"), pci->TM_WordToString(parentdat->pStatuses, ui1->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);
-}
-
-/////////////////////////////////////////////////////////////////////////////////////////
// subclassing for the nickname list control.It is an ownerdrawn listbox
static LRESULT CALLBACK NicklistSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
@@ -1341,9 +1271,6 @@ static LRESULT CALLBACK NicklistSubclassProc(HWND hwnd, UINT msg, WPARAM wParam,
HWND hwndParent = GetParent(hwnd);
TWindowData *dat = (TWindowData*)GetWindowLongPtr(hwndParent, GWLP_USERDATA);
- static BOOL isToolTip = NULL;
- static int currentHovered = -1;
-
switch (msg) {
case WM_NCCALCSIZE:
if (CSkin::m_DisableScrollbars) {
@@ -1521,8 +1448,8 @@ static LRESULT CALLBACK NicklistSubclassProc(HWND hwnd, UINT msg, WPARAM wParam,
case WM_CONTEXTMENU:
{
- SESSION_INFO *parentdat = dat->si;
- if (parentdat == NULL)
+ SESSION_INFO *si = dat->si;
+ if (si == NULL)
break;
int height = 0;
@@ -1544,7 +1471,7 @@ static LRESULT CALLBACK NicklistSubclassProc(HWND hwnd, UINT msg, WPARAM wParam,
else
item &= 0xFFFF;
- USERINFO *ui = pci->SM_GetUserFromIndex(parentdat->ptszID, parentdat->pszModule, item);
+ USERINFO *ui = pci->SM_GetUserFromIndex(si->ptszID, si->pszModule, item);
if (ui) {
HMENU hMenu = 0;
USERINFO uinew;
@@ -1553,26 +1480,26 @@ static LRESULT CALLBACK NicklistSubclassProc(HWND hwnd, UINT msg, WPARAM wParam,
hti.pt.y += height - 4;
ClientToScreen(hwnd, &hti.pt);
- UINT uID = CreateGCMenu(hwnd, &hMenu, 0, hti.pt, parentdat, uinew.pszUID, uinew.pszNick);
+ UINT uID = CreateGCMenu(hwnd, &hMenu, 0, hti.pt, si, uinew.pszUID, uinew.pszNick);
switch (uID) {
case 0:
break;
case 20020: // add to highlight...
{
- THighLightEdit the = { THighLightEdit::CMD_ADD, parentdat, ui };
- HWND hwndDlg = CreateDialogParam(g_hInst, MAKEINTRESOURCE(IDD_ADDHIGHLIGHT), parentdat->dat->pContainer->hwnd, CMUCHighlight::dlgProcAdd, (LPARAM)&the);
+ THighLightEdit the = { THighLightEdit::CMD_ADD, si, ui };
+ HWND hwndDlg = CreateDialogParam(g_hInst, MAKEINTRESOURCE(IDD_ADDHIGHLIGHT), si->dat->pContainer->hwnd, CMUCHighlight::dlgProcAdd, (LPARAM)&the);
TranslateDialogDefault(hwndDlg);
RECT rc, rcWnd;
- GetClientRect(parentdat->pContainer->hwnd, &rcWnd);
+ GetClientRect(si->pContainer->hwnd, &rcWnd);
GetWindowRect(hwndDlg, &rc);
SetWindowPos(hwndDlg, HWND_TOP, (rcWnd.right - (rc.right - rc.left)) / 2, (rcWnd.bottom - (rc.bottom - rc.top)) / 2, 0, 0, SWP_NOSIZE | SWP_SHOWWINDOW);
}
break;
case ID_MESS:
- pci->DoEventHookAsync(GetParent(hwnd), parentdat->ptszID, parentdat->pszModule, GC_USER_PRIVMESS, ui->pszUID, NULL, 0);
+ pci->DoEventHookAsync(GetParent(hwnd), si->ptszID, si->pszModule, GC_USER_PRIVMESS, ui->pszUID, NULL, 0);
break;
default:
@@ -1584,9 +1511,9 @@ static LRESULT CALLBACK NicklistSubclassProc(HWND hwnd, UINT msg, WPARAM wParam,
if (pItems) {
if (SendMessage(hwnd, LB_GETSELITEMS, iSelectedItems, (LPARAM)pItems) != LB_ERR) {
for (int i = 0; i < iSelectedItems; i++) {
- USERINFO *ui1 = pci->SM_GetUserFromIndex(parentdat->ptszID, parentdat->pszModule, pItems[i]);
+ USERINFO *ui1 = pci->SM_GetUserFromIndex(si->ptszID, si->pszModule, pItems[i]);
if (ui1)
- pci->DoEventHookAsync(hwndParent, parentdat->ptszID, parentdat->pszModule, GC_USER_NICKLISTMENU, ui1->pszUID, NULL, (LPARAM)uID);
+ pci->DoEventHookAsync(hwndParent, si->ptszID, si->pszModule, GC_USER_NICKLISTMENU, ui1->pszUID, NULL, (LPARAM)uID);
}
}
mir_free(pItems);
@@ -1602,86 +1529,7 @@ static LRESULT CALLBACK NicklistSubclassProc(HWND hwnd, UINT msg, WPARAM wParam,
break;
case WM_MOUSEMOVE:
- RECT clientRect;
- {
- POINT pt = { LOWORD(lParam), HIWORD(lParam) };
- GetClientRect(hwnd, &clientRect);
- if (PtInRect(&clientRect, pt)) {
- // hit test item under mouse
- DWORD nItemUnderMouse = (DWORD)SendMessage(hwnd, LB_ITEMFROMPOINT, 0, lParam);
- if (HIWORD(nItemUnderMouse) == 1)
- nItemUnderMouse = (DWORD)(-1);
- else
- nItemUnderMouse &= 0xFFFF;
-
- if (M.GetByte("adv_TipperTooltip", 1) && ServiceExists("mToolTip/HideTip")) {
- if ((int)nItemUnderMouse == currentHovered) break;
- currentHovered = (int)nItemUnderMouse;
-
- KillTimer(hwnd, 1);
-
- if (isToolTip) {
- CallService("mToolTip/HideTip", 0, 0);
- isToolTip = FALSE;
- }
-
- if (nItemUnderMouse != -1)
- SetTimer(hwnd, 1, 450, 0);
- }
- else ProcessNickListHovering(hwnd, (int)nItemUnderMouse, dat->si);
- }
- else {
- if (M.GetByte("adv_TipperTooltip", 1) && ServiceExists("mToolTip/HideTip")) {
- KillTimer(hwnd, 1);
- if (isToolTip) {
- CallService("mToolTip/HideTip", 0, 0);
- isToolTip = FALSE;
- }
- }
- else ProcessNickListHovering(hwnd, -1, NULL);
- }
- }
- break;
-
- case WM_TIMER:
- POINT pt;
- GetCursorPos(&pt);
- ScreenToClient(hwnd, &pt);
- {
- SESSION_INFO *parentdat = dat->si;
-
- DWORD nItemUnderMouse = (DWORD)SendDlgItemMessage(dat->hwnd, IDC_LIST, LB_ITEMFROMPOINT, 0, MAKELPARAM(pt.x, pt.y));
- if (HIWORD(nItemUnderMouse) == 1)
- nItemUnderMouse = (DWORD)(-1);
- else
- nItemUnderMouse &= 0xFFFF;
- if (((int)nItemUnderMouse != currentHovered) || (nItemUnderMouse == -1)) {
- KillTimer(hwnd, 1);
- break;
- }
-
- USERINFO *ui1 = pci->SM_GetUserFromIndex(parentdat->ptszID, parentdat->pszModule, currentHovered);
- if (ui1) {
- wchar_t tszBuf[1024]; tszBuf[0] = 0;
- if (ProtoServiceExists(parentdat->pszModule, MS_GC_PROTO_GETTOOLTIPTEXT)) {
- wchar_t *p = (wchar_t*)CallProtoService(parentdat->pszModule, MS_GC_PROTO_GETTOOLTIPTEXT, (WPARAM)parentdat->ptszID, (LPARAM)ui1->pszUID);
- if (p) {
- wcsncpy_s(tszBuf, p, _TRUNCATE);
- mir_free(p);
- }
- }
- if (tszBuf[0] == 0)
- mir_snwprintf(tszBuf, L"<b>%s:</b>\t%s\n<b>%s:</b>\t%s\n<b>%s:</b>\t%s",
- TranslateT("Nick"), ui1->pszNick,
- TranslateT("Unique ID"), ui1->pszUID,
- TranslateT("Status"), pci->TM_WordToString(parentdat->pStatuses, ui1->Status));
-
- CLCINFOTIP ti = { sizeof(ti) };
- if (CallService("mToolTip/ShowTipW", (WPARAM)tszBuf, (LPARAM)&ti))
- isToolTip = TRUE;
- }
- KillTimer(hwnd, 1);
- }
+ Chat_HoverMouse(dat->si, hwnd, lParam, M.GetByte("adv_TipperTooltip", 1) && ServiceExists("mToolTip/HideTip"));
break;
}
return mir_callNextSubclass(hwnd, NicklistSubclassProc, msg, wParam, lParam);