summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/Scriver/src/chat.h2
-rw-r--r--plugins/Scriver/src/chat_tools.cpp88
-rw-r--r--plugins/Scriver/src/chat_window.cpp13
-rw-r--r--plugins/TabSRMM/src/chat.h2
-rw-r--r--plugins/TabSRMM/src/chat_main.cpp17
-rw-r--r--plugins/TabSRMM/src/chat_tools.cpp98
-rw-r--r--plugins/TabSRMM/src/chat_window.cpp21
7 files changed, 34 insertions, 207 deletions
diff --git a/plugins/Scriver/src/chat.h b/plugins/Scriver/src/chat.h
index fb21c082b8..54de98256a 100644
--- a/plugins/Scriver/src/chat.h
+++ b/plugins/Scriver/src/chat.h
@@ -84,8 +84,6 @@ char SM_GetStatusIndicator(SESSION_INFO *si, USERINFO *ui);
// tools.c
BOOL DoSoundsFlashPopupTrayStuff(SESSION_INFO *si, GCEVENT *gce, BOOL bHighlight, int bManyFix);
wchar_t* my_strstri(const wchar_t* s1, const wchar_t* s2) ;
-UINT CreateGCMenu(HWND hwndDlg, HMENU *hMenu, int iIndex, POINT pt, SESSION_INFO *si, wchar_t* pszUID, wchar_t* pszWordText);
-void DestroyGCMenu(HMENU *hMenu, int iIndex);
/////////////////////////////////////////////////////////////////////////////////////////
diff --git a/plugins/Scriver/src/chat_tools.cpp b/plugins/Scriver/src/chat_tools.cpp
index 050d4656c5..18511598f0 100644
--- a/plugins/Scriver/src/chat_tools.cpp
+++ b/plugins/Scriver/src/chat_tools.cpp
@@ -30,91 +30,3 @@ wchar_t* my_strstri(const wchar_t* s1, const wchar_t* s2)
return nullptr;
}
-
-UINT CreateGCMenu(HWND hwnd, HMENU *hMenu, int iIndex, POINT pt, SESSION_INFO *si, wchar_t* pszUID, wchar_t* pszWordText)
-{
- GCMENUITEMS gcmi = { 0 };
- HMENU hSubMenu = 0;
-
- *hMenu = GetSubMenu(g_hMenu, iIndex);
- gcmi.pszID = si->ptszID;
- gcmi.pszModule = si->pszModule;
- gcmi.pszUID = pszUID;
-
- if (iIndex == 1) {
- int iLen = GetRichTextLength(hwnd, CP_ACP, FALSE);
-
- EnableMenuItem(*hMenu, IDM_CLEAR, MF_ENABLED);
- EnableMenuItem(*hMenu, ID_COPYALL, MF_ENABLED);
- if (!iLen) {
- EnableMenuItem(*hMenu, ID_COPYALL, MF_BYCOMMAND | MF_GRAYED);
- EnableMenuItem(*hMenu, IDM_CLEAR, MF_BYCOMMAND | MF_GRAYED);
- }
-
- if (pszWordText && pszWordText[0]) {
- wchar_t szMenuText[4096];
- mir_snwprintf(szMenuText, TranslateT("Look up '%s':"), pszWordText);
- ModifyMenu(*hMenu, 4, MF_STRING | MF_BYPOSITION, 4, szMenuText);
- SetSearchEngineIcons(*hMenu, g_dat.hSearchEngineIconList);
- }
- else ModifyMenu(*hMenu, 4, MF_STRING | MF_GRAYED | MF_BYPOSITION, 4, TranslateT("No word to look up"));
- gcmi.Type = MENU_ON_LOG;
- }
- else if (iIndex == 0) {
- wchar_t szTemp[50];
- if (pszWordText)
- mir_snwprintf(szTemp, TranslateT("&Message %s"), pszWordText);
- else
- mir_wstrncpy(szTemp, TranslateT("&Message"), _countof(szTemp) - 1);
-
- if (mir_wstrlen(szTemp) > 40)
- mir_wstrncpy(szTemp + 40, L"...", 4);
- ModifyMenu(*hMenu, ID_MESS, MF_STRING | MF_BYCOMMAND, ID_MESS, szTemp);
- gcmi.Type = MENU_ON_NICKLIST;
- }
-
- NotifyEventHooks(pci->hBuildMenuEvent, 0, (WPARAM)&gcmi);
-
- if (gcmi.nItems > 0)
- AppendMenu(*hMenu, MF_SEPARATOR, 0, 0);
-
- for (int i = 0; i < gcmi.nItems; i++) {
- wchar_t *ptszText = TranslateW(gcmi.Item[i].pszDesc);
- DWORD dwState = gcmi.Item[i].bDisabled ? MF_GRAYED : 0;
-
- if (gcmi.Item[i].uType == MENU_NEWPOPUP) {
- hSubMenu = CreateMenu();
- AppendMenu(*hMenu, dwState | MF_POPUP, (UINT_PTR)hSubMenu, ptszText);
- }
- else if (gcmi.Item[i].uType == MENU_POPUPHMENU)
- AppendMenu(hSubMenu == 0 ? *hMenu : hSubMenu, dwState | MF_POPUP, gcmi.Item[i].dwID, ptszText);
- else if (gcmi.Item[i].uType == MENU_POPUPITEM)
- AppendMenu(hSubMenu == 0 ? *hMenu : hSubMenu, dwState | MF_STRING, gcmi.Item[i].dwID, ptszText);
- else if (gcmi.Item[i].uType == MENU_POPUPCHECK)
- AppendMenu(hSubMenu == 0 ? *hMenu : hSubMenu, dwState | MF_CHECKED | MF_STRING, gcmi.Item[i].dwID, ptszText);
- else if (gcmi.Item[i].uType == MENU_POPUPSEPARATOR)
- AppendMenu(hSubMenu == 0 ? *hMenu : hSubMenu, MF_SEPARATOR, 0, ptszText);
- else if (gcmi.Item[i].uType == MENU_SEPARATOR)
- AppendMenu(*hMenu, MF_SEPARATOR, 0, ptszText);
- else if (gcmi.Item[i].uType == MENU_HMENU)
- AppendMenu(*hMenu, dwState | MF_POPUP, gcmi.Item[i].dwID, ptszText);
- else if (gcmi.Item[i].uType == MENU_ITEM)
- AppendMenu(*hMenu, dwState | MF_STRING, gcmi.Item[i].dwID, ptszText);
- else if (gcmi.Item[i].uType == MENU_CHECK)
- AppendMenu(*hMenu, dwState | MF_CHECKED | MF_STRING, gcmi.Item[i].dwID, ptszText);
- }
- return TrackPopupMenu(*hMenu, TPM_RETURNCMD, pt.x, pt.y, 0, hwnd, nullptr);
-}
-
-void DestroyGCMenu(HMENU *hMenu, int iIndex)
-{
- MENUITEMINFO mii = { 0 };
- mii.cbSize = sizeof(mii);
- mii.fMask = MIIM_SUBMENU;
- while(GetMenuItemInfo(*hMenu, iIndex, TRUE, &mii))
- {
- if (mii.hSubMenu != nullptr)
- DestroyMenu(mii.hSubMenu);
- RemoveMenu(*hMenu, iIndex, MF_BYPOSITION);
- }
-}
diff --git a/plugins/Scriver/src/chat_window.cpp b/plugins/Scriver/src/chat_window.cpp
index 699ff3518f..13a273c3ca 100644
--- a/plugins/Scriver/src/chat_window.cpp
+++ b/plugins/Scriver/src/chat_window.cpp
@@ -861,8 +861,8 @@ LRESULT CChatRoomDlg::WndProc_Log(UINT msg, WPARAM wParam, LPARAM lParam)
SESSION_INFO *si = m_si;
CHARRANGE all = { 0, -1 };
- HMENU hMenu = nullptr;
- UINT uID = CreateGCMenu(m_log.GetHwnd(), &hMenu, 1, pt, si, nullptr, pszWord);
+ HMENU hMenu = GetSubMenu(g_hMenu, 1);
+ UINT uID = Chat_CreateGCMenu(m_log.GetHwnd(), hMenu, pt, si, nullptr, pszWord);
inMenu = FALSE;
switch (uID) {
case 0:
@@ -904,7 +904,7 @@ LRESULT CChatRoomDlg::WndProc_Log(UINT msg, WPARAM wParam, LPARAM lParam)
DoEventHook(GC_USER_LOGMENU, nullptr, nullptr, uID);
break;
}
- DestroyGCMenu(&hMenu, 5);
+ Chat_DestroyGCMenu(hMenu, 5);
}
break;
@@ -950,14 +950,13 @@ LRESULT CChatRoomDlg::WndProc_Nicklist(UINT msg, WPARAM wParam, LPARAM lParam)
USERINFO *ui = pci->SM_GetUserFromIndex(m_si->ptszID, m_si->pszModule, (int)item);
if (ui) {
- HMENU hMenu = 0;
+ HMENU hMenu = GetSubMenu(g_hMenu, 0);
USERINFO uinew;
-
memcpy(&uinew, ui, sizeof(USERINFO));
if (hti.pt.x == -1 && hti.pt.y == -1)
hti.pt.y += height - 4;
ClientToScreen(m_nickList.GetHwnd(), &hti.pt);
- UINT uID = CreateGCMenu(m_nickList.GetHwnd(), &hMenu, 0, hti.pt, m_si, uinew.pszUID, uinew.pszNick);
+ UINT uID = Chat_CreateGCMenu(m_nickList.GetHwnd(), hMenu, hti.pt, m_si, uinew.pszUID, uinew.pszNick);
switch (uID) {
case 0:
@@ -971,7 +970,7 @@ LRESULT CChatRoomDlg::WndProc_Nicklist(UINT msg, WPARAM wParam, LPARAM lParam)
DoEventHook(GC_USER_NICKLISTMENU, ui, nullptr, uID);
break;
}
- DestroyGCMenu(&hMenu, 1);
+ Chat_DestroyGCMenu(hMenu, 1);
return TRUE;
}
}
diff --git a/plugins/TabSRMM/src/chat.h b/plugins/TabSRMM/src/chat.h
index e9947ed8b3..e9f7b1ce0c 100644
--- a/plugins/TabSRMM/src/chat.h
+++ b/plugins/TabSRMM/src/chat.h
@@ -131,8 +131,6 @@ wchar_t* my_strstri(const wchar_t* s1, const wchar_t* s2);
int GetRichTextLength(HWND hwnd);
bool IsHighlighted(SESSION_INFO *si, GCEVENT *pszText);
char GetIndicator(SESSION_INFO *si, LPCTSTR ptszNick, int *iNickIndex);
-UINT CreateGCMenu(HWND hwndDlg, HMENU *hMenu, int iIndex, POINT pt, SESSION_INFO *si, wchar_t* pszUID, wchar_t* pszWordText);
-void DestroyGCMenu(HMENU *hMenu, int iIndex);
void Chat_SetFilters(SESSION_INFO *si);
void DoFlashAndSoundWorker(FLASH_PARAMS* p);
BOOL DoPopup(SESSION_INFO *si, GCEVENT* gce);
diff --git a/plugins/TabSRMM/src/chat_main.cpp b/plugins/TabSRMM/src/chat_main.cpp
index 626c5aea5c..bbc0162b93 100644
--- a/plugins/TabSRMM/src/chat_main.cpp
+++ b/plugins/TabSRMM/src/chat_main.cpp
@@ -206,6 +206,22 @@ static void CheckUpdate()
db_set_b(0, "Compatibility", "TabChatFonts", 3);
}
+/////////////////////////////////////////////////////////////////////////////////////////
+
+static gc_item tabItems[] =
+{
+ { TranslateT("Highlight user..."), 20020, MENU_ITEM }
+};
+
+static int OnCreateGCMenu(WPARAM, LPARAM lParam)
+{
+ GCMENUITEMS *gcitems = (GCMENUITEMS*)lParam;
+ if (gcitems->Type == MENU_ON_NICKLIST)
+ Chat_AddMenuItems(gcitems->hMenu, _countof(tabItems), tabItems);
+
+ return 0;
+}
+
// load the module
int Chat_Load()
{
@@ -239,6 +255,7 @@ int Chat_Load()
g_hMenu = LoadMenu(g_hInst, MAKEINTRESOURCE(IDR_MENU));
+ HookEvent(ME_GC_BUILDMENU, OnCreateGCMenu);
g_Settings.Highlight = new CMUCHighlight();
return 0;
}
diff --git a/plugins/TabSRMM/src/chat_tools.cpp b/plugins/TabSRMM/src/chat_tools.cpp
index 99f121c538..a3fe2d7e42 100644
--- a/plugins/TabSRMM/src/chat_tools.cpp
+++ b/plugins/TabSRMM/src/chat_tools.cpp
@@ -503,104 +503,6 @@ BOOL LogToFile(SESSION_INFO *si, GCEVENT *gce)
return oldLogToFile(si, gce); // call kernel method
}
-UINT CreateGCMenu(HWND hwndDlg, HMENU *hMenu, int iIndex, POINT pt, SESSION_INFO *si, wchar_t* pszUID, wchar_t* pszWordText)
-{
- HMENU hSubMenu = 0;
-
- *hMenu = GetSubMenu(g_hMenu, iIndex);
- TranslateMenu(*hMenu);
-
- GCMENUITEMS gcmi = { 0 };
- gcmi.pszID = si->ptszID;
- gcmi.pszModule = si->pszModule;
- gcmi.pszUID = pszUID;
-
- if (iIndex == 1) {
- int i = GetRichTextLength(GetDlgItem(hwndDlg, IDC_SRMM_LOG));
-
- EnableMenuItem(*hMenu, ID_CLEARLOG, MF_ENABLED);
- EnableMenuItem(*hMenu, ID_COPYALL, MF_ENABLED);
- ModifyMenu(*hMenu, 4, MF_GRAYED | MF_BYPOSITION, 4, nullptr);
- if (!i) {
- EnableMenuItem(*hMenu, ID_COPYALL, MF_BYCOMMAND | MF_GRAYED);
- EnableMenuItem(*hMenu, ID_CLEARLOG, MF_BYCOMMAND | MF_GRAYED);
- if (pszWordText && pszWordText[0])
- ModifyMenu(*hMenu, 4, MF_ENABLED | MF_BYPOSITION, 4, nullptr);
- }
-
- if (pszWordText && pszWordText[0]) {
- wchar_t szMenuText[4096];
- mir_snwprintf(szMenuText, TranslateT("Look up '%s':"), pszWordText);
- ModifyMenu(*hMenu, 4, MF_STRING | MF_BYPOSITION, 4, szMenuText);
- }
- else ModifyMenu(*hMenu, 4, MF_STRING | MF_GRAYED | MF_BYPOSITION, 4, TranslateT("No word to look up"));
- gcmi.Type = MENU_ON_LOG;
- }
- else if (iIndex == 0) {
- wchar_t szTemp[50];
- if (pszWordText)
- mir_snwprintf(szTemp, TranslateT("&Message %s"), pszWordText);
- else
- wcsncpy_s(szTemp, TranslateT("&Message"), _TRUNCATE);
-
- if (mir_wstrlen(szTemp) > 40)
- wcsncpy_s(szTemp + 40, 4, L"...", _TRUNCATE);
- ModifyMenu(*hMenu, ID_MESS, MF_STRING | MF_BYCOMMAND, ID_MESS, szTemp);
- gcmi.Type = MENU_ON_NICKLIST;
- }
-
- NotifyEventHooks(pci->hBuildMenuEvent, 0, (WPARAM)&gcmi);
-
- if (gcmi.nItems > 0)
- AppendMenu(*hMenu, MF_SEPARATOR, 0, 0);
-
- for (int i = 0; i < gcmi.nItems; i++) {
- wchar_t *ptszText = TranslateW(gcmi.Item[i].pszDesc);
- DWORD dwState = gcmi.Item[i].bDisabled ? MF_GRAYED : 0;
-
- if (gcmi.Item[i].uType == MENU_NEWPOPUP) {
- hSubMenu = CreateMenu();
- AppendMenu(*hMenu, dwState | MF_POPUP, (UINT_PTR)hSubMenu, ptszText);
- }
- else if (gcmi.Item[i].uType == MENU_POPUPHMENU)
- AppendMenu(hSubMenu == 0 ? *hMenu : hSubMenu, dwState | MF_POPUP, gcmi.Item[i].dwID, ptszText);
- else if (gcmi.Item[i].uType == MENU_POPUPITEM)
- AppendMenu(hSubMenu == 0 ? *hMenu : hSubMenu, dwState | MF_STRING, gcmi.Item[i].dwID, ptszText);
- else if (gcmi.Item[i].uType == MENU_POPUPCHECK)
- AppendMenu(hSubMenu == 0 ? *hMenu : hSubMenu, dwState | MF_CHECKED | MF_STRING, gcmi.Item[i].dwID, ptszText);
- else if (gcmi.Item[i].uType == MENU_POPUPSEPARATOR)
- AppendMenu(hSubMenu == 0 ? *hMenu : hSubMenu, MF_SEPARATOR, 0, ptszText);
- else if (gcmi.Item[i].uType == MENU_SEPARATOR)
- AppendMenu(*hMenu, MF_SEPARATOR, 0, ptszText);
- else if (gcmi.Item[i].uType == MENU_HMENU)
- AppendMenu(*hMenu, dwState | MF_POPUP, gcmi.Item[i].dwID, ptszText);
- else if (gcmi.Item[i].uType == MENU_ITEM)
- AppendMenu(*hMenu, dwState | MF_STRING, gcmi.Item[i].dwID, ptszText);
- else if (gcmi.Item[i].uType == MENU_CHECK)
- AppendMenu(*hMenu, dwState | MF_CHECKED | MF_STRING, gcmi.Item[i].dwID, ptszText);
- }
-
- if (iIndex == 0) {
- AppendMenu(*hMenu, MF_SEPARATOR, 0, 0);
- int pos = GetMenuItemCount(*hMenu);
- InsertMenu(*hMenu, pos, MF_BYPOSITION, (UINT_PTR)20020, TranslateT("Highlight user..."));
- }
-
- return TrackPopupMenu(*hMenu, TPM_RETURNCMD, pt.x, pt.y, 0, hwndDlg, nullptr);
-}
-
-void DestroyGCMenu(HMENU *hMenu, int iIndex)
-{
- MENUITEMINFO mii = { 0 };
- mii.cbSize = sizeof(mii);
- mii.fMask = MIIM_SUBMENU;
- while (GetMenuItemInfo(*hMenu, iIndex, TRUE, &mii)) {
- if (mii.hSubMenu != nullptr)
- DestroyMenu(mii.hSubMenu);
- RemoveMenu(*hMenu, iIndex, MF_BYPOSITION);
- }
-}
-
/*
* set all filters and notification config for a session
* uses per channel mask + filterbits, default config as backup
diff --git a/plugins/TabSRMM/src/chat_window.cpp b/plugins/TabSRMM/src/chat_window.cpp
index e147e83d2f..d5aa212c48 100644
--- a/plugins/TabSRMM/src/chat_window.cpp
+++ b/plugins/TabSRMM/src/chat_window.cpp
@@ -1606,14 +1606,14 @@ LRESULT CChatRoomDlg::WndProc_Nicklist(UINT msg, WPARAM wParam, LPARAM lParam)
USERINFO *ui = pci->SM_GetUserFromIndex(si->ptszID, si->pszModule, item);
if (ui) {
- HMENU hMenu = 0;
+ HMENU hMenu = GetSubMenu(g_hMenu, 0);
USERINFO uinew;
memcpy(&uinew, ui, sizeof(USERINFO));
if (hti.pt.x == -1 && hti.pt.y == -1)
hti.pt.y += height - 4;
ClientToScreen(m_nickList.GetHwnd(), &hti.pt);
- UINT uID = CreateGCMenu(m_nickList.GetHwnd(), &hMenu, 0, hti.pt, si, uinew.pszUID, uinew.pszNick);
+ UINT uID = Chat_CreateGCMenu(m_nickList.GetHwnd(), hMenu, hti.pt, si, uinew.pszUID, uinew.pszNick);
switch (uID) {
case 0:
break;
@@ -1639,7 +1639,7 @@ LRESULT CChatRoomDlg::WndProc_Nicklist(UINT msg, WPARAM wParam, LPARAM lParam)
DoEventHook(GC_USER_NICKLISTMENU, ui, nullptr, uID);
break;
}
- DestroyGCMenu(&hMenu, 1);
+ Chat_DestroyGCMenu(hMenu, 1);
return TRUE;
}
}
@@ -2174,8 +2174,8 @@ INT_PTR CChatRoomDlg::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam)
}
}
- HMENU hMenu = 0;
- UINT uID = CreateGCMenu(m_hwnd, &hMenu, 1, pt, m_si, nullptr, pszWord);
+ HMENU hMenu = GetSubMenu(g_hMenu, 1);
+ UINT uID = Chat_CreateGCMenu(m_hwnd, hMenu, pt, m_si, nullptr, pszWord);
switch (uID) {
case 0:
PostMessage(m_hwnd, WM_MOUSEACTIVATE, 0, 0);
@@ -2213,7 +2213,7 @@ INT_PTR CChatRoomDlg::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam)
break;
}
- DestroyGCMenu(&hMenu, 5);
+ Chat_DestroyGCMenu(hMenu, 5);
}
}
break;
@@ -2248,8 +2248,8 @@ INT_PTR CChatRoomDlg::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam)
// clicked a nick name
if (g_Settings.bClickableNicks) {
if (msg == WM_RBUTTONDOWN) {
- HMENU hMenu = 0;
- USERINFO uiNew;
+ HMENU hMenu = GetSubMenu(g_hMenu, 0);
+
for (USERINFO *ui = m_si->pUsers; ui; ui = ui->next) {
if (mir_wstrcmp(ui->pszNick, tr.lpstrText))
continue;
@@ -2257,8 +2257,9 @@ INT_PTR CChatRoomDlg::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam)
pt.x = (short)LOWORD(((ENLINK*)lParam)->lParam);
pt.y = (short)HIWORD(((ENLINK*)lParam)->lParam);
ClientToScreen(((NMHDR*)lParam)->hwndFrom, &pt);
+ USERINFO uiNew;
memcpy(&uiNew, ui, sizeof(USERINFO));
- UINT uID = CreateGCMenu(m_hwnd, &hMenu, 0, pt, m_si, uiNew.pszUID, uiNew.pszNick);
+ UINT uID = Chat_CreateGCMenu(m_hwnd, hMenu, pt, m_si, uiNew.pszUID, uiNew.pszNick);
switch (uID) {
case 0:
break;
@@ -2271,7 +2272,7 @@ INT_PTR CChatRoomDlg::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam)
DoEventHook(GC_USER_NICKLISTMENU, ui, nullptr, (LPARAM)uID);
break;
}
- DestroyGCMenu(&hMenu, 1);
+ Chat_DestroyGCMenu(hMenu, 1);
return TRUE;
}
return TRUE;