diff options
author | George Hazan <george.hazan@gmail.com> | 2015-06-27 21:50:25 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2015-06-27 21:50:25 +0000 |
commit | 24415c15d859a94a34a2b575af74336a9aff5f45 (patch) | |
tree | ecca2fa440ba5064a60bc90aa3f6843b1feb46f2 /src | |
parent | 944634aed3d3f7849a207b5007c6f8c4d6c2c975 (diff) |
- clist menus went to functions
- m_clist.h cleaning & reordering
git-svn-id: http://svn.miranda-ng.org/main/trunk@14422 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'src')
-rw-r--r-- | src/core/stdfile/src/filerecvdlg.cpp | 2 | ||||
-rw-r--r-- | src/core/stdfile/src/filesenddlg.cpp | 2 | ||||
-rw-r--r-- | src/core/stdfile/src/filexferdlg.cpp | 2 | ||||
-rw-r--r-- | src/core/stdmsg/src/msgdialog.cpp | 5 | ||||
-rw-r--r-- | src/core/stdurl/urldialogs.cpp | 4 | ||||
-rw-r--r-- | src/mir_app/src/clc.cpp | 2 | ||||
-rw-r--r-- | src/mir_app/src/clistmenus.cpp | 110 | ||||
-rw-r--r-- | src/mir_app/src/clisttray.cpp | 6 | ||||
-rw-r--r-- | src/mir_app/src/clui.cpp | 12 | ||||
-rw-r--r-- | src/mir_app/src/meta_services.cpp | 2 | ||||
-rw-r--r-- | src/mir_app/src/mir_app.def | 4 | ||||
-rw-r--r-- | src/mir_app/src/mir_app64.def | 4 |
12 files changed, 81 insertions, 74 deletions
diff --git a/src/core/stdfile/src/filerecvdlg.cpp b/src/core/stdfile/src/filerecvdlg.cpp index 09c19b331b..21842deb6e 100644 --- a/src/core/stdfile/src/filerecvdlg.cpp +++ b/src/core/stdfile/src/filerecvdlg.cpp @@ -386,8 +386,8 @@ INT_PTR CALLBACK DlgProcRecvFile(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l case IDC_USERMENU:
{
RECT rc;
- HMENU hMenu = (HMENU)CallService(MS_CLIST_MENUBUILDCONTACT, (WPARAM)dat->hContact, 0);
GetWindowRect((HWND)lParam, &rc);
+ HMENU hMenu = Menu_BuildContactMenu(dat->hContact);
TrackPopupMenu(hMenu, 0, rc.left, rc.bottom, 0, hwndDlg, NULL);
DestroyMenu(hMenu);
}
diff --git a/src/core/stdfile/src/filesenddlg.cpp b/src/core/stdfile/src/filesenddlg.cpp index 56aaf3bb88..330dcaf295 100644 --- a/src/core/stdfile/src/filesenddlg.cpp +++ b/src/core/stdfile/src/filesenddlg.cpp @@ -338,9 +338,9 @@ INT_PTR CALLBACK DlgProcSendFile(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l case IDC_USERMENU:
{
- HMENU hMenu = (HMENU)CallService(MS_CLIST_MENUBUILDCONTACT, (WPARAM)dat->hContact, 0);
RECT rc;
GetWindowRect((HWND)lParam, &rc);
+ HMENU hMenu = Menu_BuildContactMenu(dat->hContact);
TrackPopupMenu(hMenu, 0, rc.left, rc.bottom, 0, hwndDlg, NULL);
DestroyMenu(hMenu);
}
diff --git a/src/core/stdfile/src/filexferdlg.cpp b/src/core/stdfile/src/filexferdlg.cpp index 1db269962e..5b14d30c9d 100644 --- a/src/core/stdfile/src/filexferdlg.cpp +++ b/src/core/stdfile/src/filexferdlg.cpp @@ -357,7 +357,7 @@ INT_PTR CALLBACK DlgProcFileTransfer(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR case IDC_CONTACT: { RECT rc; - HMENU hMenu = (HMENU)CallService(MS_CLIST_MENUBUILDCONTACT, (WPARAM)dat->hContact, 0); + HMENU hMenu = Menu_BuildContactMenu(dat->hContact); GetWindowRect((HWND)lParam, &rc); TrackPopupMenu(hMenu, 0, rc.left, rc.bottom, 0, hwndDlg, NULL); DestroyMenu(hMenu); diff --git a/src/core/stdmsg/src/msgdialog.cpp b/src/core/stdmsg/src/msgdialog.cpp index acb7c0049d..21d47e4340 100644 --- a/src/core/stdmsg/src/msgdialog.cpp +++ b/src/core/stdmsg/src/msgdialog.cpp @@ -818,8 +818,7 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP if (pt.x >= rc.left)
break;
- HMENU hMenu = (HMENU)CallService(MS_CLIST_MENUBUILDCONTACT, (WPARAM)dat->hContact, 0);
-
+ HMENU hMenu = Menu_BuildContactMenu(dat->hContact);
TrackPopupMenu(hMenu, 0, pt2.x, pt2.y, 0, hwndDlg, NULL);
DestroyMenu(hMenu);
}
@@ -1420,7 +1419,7 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP SendMessage(hwndDlg, DM_USERNAMETOCLIP, 0, 0);
else {
RECT rc;
- HMENU hMenu = (HMENU)CallService(MS_CLIST_MENUBUILDCONTACT, (WPARAM)dat->hContact, 0);
+ HMENU hMenu = Menu_BuildContactMenu(dat->hContact);
GetWindowRect(GetDlgItem(hwndDlg, LOWORD(wParam)), &rc);
TrackPopupMenu(hMenu, 0, rc.left, rc.bottom, 0, hwndDlg, NULL);
DestroyMenu(hMenu);
diff --git a/src/core/stdurl/urldialogs.cpp b/src/core/stdurl/urldialogs.cpp index 0d781abc76..0e0cb5841a 100644 --- a/src/core/stdurl/urldialogs.cpp +++ b/src/core/stdurl/urldialogs.cpp @@ -192,7 +192,7 @@ INT_PTR CALLBACK DlgProcUrlRecv(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP case IDC_USERMENU:
{
RECT rc;
- HMENU hMenu = (HMENU)CallService(MS_CLIST_MENUBUILDCONTACT, (WPARAM)dat->hContact, 0);
+ HMENU hMenu = Menu_BuildContactMenu(dat->hContact);
GetWindowRect(GetDlgItem(hwndDlg, IDC_USERMENU), &rc);
TrackPopupMenu(hMenu, 0, rc.left, rc.bottom, 0, hwndDlg, NULL);
DestroyMenu(hMenu);
@@ -584,7 +584,7 @@ INT_PTR CALLBACK DlgProcUrlSend(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP case IDC_USERMENU:
{
RECT rc;
- HMENU hMenu = (HMENU)CallService(MS_CLIST_MENUBUILDCONTACT, (WPARAM)dat->hContact, 0);
+ HMENU hMenu = Menu_BuildContactMenu(dat->hContact);
GetWindowRect(GetDlgItem(hwndDlg, IDC_USERMENU), &rc);
TrackPopupMenu(hMenu, 0, rc.left, rc.bottom, 0, hwndDlg, NULL);
DestroyMenu(hMenu);
diff --git a/src/mir_app/src/clc.cpp b/src/mir_app/src/clc.cpp index 6c3a6c3125..8377782a84 100644 --- a/src/mir_app/src/clc.cpp +++ b/src/mir_app/src/clc.cpp @@ -1262,7 +1262,7 @@ LRESULT CALLBACK fnContactListControlWndProc(HWND hwnd, UINT msg, WPARAM wParam, return 0;
}
if (contact->type == CLCIT_CONTACT)
- hMenu = (HMENU)CallService(MS_CLIST_MENUBUILDCONTACT, (WPARAM)contact->hContact, 0);
+ hMenu = Menu_BuildContactMenu(contact->hContact);
}
else {
//call parent for new group/hide offline menu
diff --git a/src/mir_app/src/clistmenus.cpp b/src/mir_app/src/clistmenus.cpp index c76360b886..79518f6aa9 100644 --- a/src/mir_app/src/clistmenus.cpp +++ b/src/mir_app/src/clistmenus.cpp @@ -143,6 +143,17 @@ int fnGetAverageMode(int *pNetProtoCount) return averageMode;
}
+static int RecursiveDeleteMenu(HMENU hMenu)
+{
+ int cnt = GetMenuItemCount(hMenu);
+ for (int i = 0; i < cnt; i++) {
+ HMENU submenu = GetSubMenu(hMenu, 0);
+ if (submenu) DestroyMenu(submenu);
+ DeleteMenu(hMenu, 0, MF_BYPOSITION);
+ }
+ return 0;
+}
+
/////////////////////////////////////////////////////////////////////////////////////////
// MAIN MENU
@@ -153,13 +164,19 @@ struct MainMenuExecParam TMO_IntMenuItem *pimi;
};
-static INT_PTR BuildMainMenu(WPARAM, LPARAM)
+MIR_APP_DLL(HMENU) Menu_BuildMainMenu(void)
{
NotifyEventHooks(hPreBuildMainMenuEvent, 0, 0);
Menu_Build(hMainMenu, hMainMenuObject);
DrawMenuBar(cli.hwndContactList);
- return (INT_PTR)hMainMenu;
+ return hMainMenu;
+}
+
+MIR_APP_DLL(HMENU) Menu_GetMainMenu(void)
+{
+ RecursiveDeleteMenu(hMainMenu);
+ return Menu_BuildMainMenu();
}
MIR_APP_DLL(HGENMENU) Menu_AddMainMenuItem(CLISTMENUITEM *mi, int _hLang)
@@ -230,6 +247,8 @@ struct ContactMenuExecParam TMO_IntMenuItem *pimi;
};
+/////////////////////////////////////////////////////////////////////////////////////////
+
MIR_APP_DLL(HGENMENU) Menu_AddContactMenuItem(CLISTMENUITEM *mi, const char *pszProto, int _hLang)
{
TMO_MenuItem tmi;
@@ -266,7 +285,9 @@ MIR_APP_DLL(HGENMENU) Menu_AddContactMenuItem(CLISTMENUITEM *mi, const char *psz return pimi;
}
-static INT_PTR BuildContactMenu(WPARAM hContact, LPARAM)
+/////////////////////////////////////////////////////////////////////////////////////////
+
+EXTERN_C MIR_APP_DLL(HMENU) Menu_BuildContactMenu(MCONTACT hContact)
{
NotifyEventHooks(hPreBuildContactMenuEvent, hContact, 0);
@@ -279,26 +300,11 @@ static INT_PTR BuildContactMenu(WPARAM hContact, LPARAM) HMENU hMenu = CreatePopupMenu();
Menu_Build(hMenu, hContactMenuObject, (WPARAM)&bcp);
- return (INT_PTR)hMenu;
-}
-
-// called with:
-// wparam - ownerdata
-// lparam - lparam from winproc
-INT_PTR ContactMenuExecService(WPARAM wParam, LPARAM lParam)
-{
- if (wParam != 0) {
- ContactMenuExecParam *cmep = (ContactMenuExecParam*)wParam;
- if (cmep->pszContactOwner && cmep->szServiceName && cmep->szServiceName[0] == '/')
- ProtoCallService(cmep->pszContactOwner, cmep->szServiceName, lParam, cmep->pimi->execParam);
- else
- CallService(cmep->szServiceName, lParam, cmep->pimi->execParam);
- }
- return 0;
+ return hMenu;
}
// true - ok, false ignore
-INT_PTR ContactMenuCheckService(WPARAM wParam, LPARAM)
+static INT_PTR ContactMenuCheckService(WPARAM wParam, LPARAM)
{
TCheckProcParam *pcpp = (TCheckProcParam*)wParam;
if (pcpp == NULL)
@@ -326,7 +332,24 @@ INT_PTR ContactMenuCheckService(WPARAM wParam, LPARAM) return TRUE;
}
-INT_PTR FreeOwnerDataContactMenu(WPARAM, LPARAM lParam)
+// called with:
+// wparam - ContactMenuExecParam*
+// lparam - lparam from winproc
+static INT_PTR ContactMenuExecService(WPARAM wParam, LPARAM lParam)
+{
+ if (wParam != 0) {
+ ContactMenuExecParam *cmep = (ContactMenuExecParam*)wParam;
+ if (cmep->pszContactOwner && cmep->szServiceName && cmep->szServiceName[0] == '/')
+ ProtoCallService(cmep->pszContactOwner, cmep->szServiceName, lParam, cmep->pimi->execParam);
+ else
+ CallService(cmep->szServiceName, lParam, cmep->pimi->execParam);
+ }
+ return 0;
+}
+
+// called with:
+// lparam - ContactMenuExecParam*
+static INT_PTR FreeOwnerDataContactMenu(WPARAM, LPARAM lParam)
{
ContactMenuExecParam *cmep = (ContactMenuExecParam*)lParam;
if (cmep != NULL) {
@@ -387,6 +410,16 @@ MIR_APP_DLL(HGENMENU) Menu_AddStatusMenuItem(CLISTMENUITEM *mi, const char *pszP /////////////////////////////////////////////////////////////////////////////////////////
+MIR_APP_DLL(HMENU) Menu_GetStatusMenu()
+{
+ RecursiveDeleteMenu(hStatusMenu);
+
+ Menu_Build(hStatusMenu, hStatusMenuObject);
+ return hStatusMenu;
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
BOOL FindMenuHandleByGlobalID(HMENU hMenu, TMO_IntMenuItem *id, MenuItemData* itdat)
{
if (!itdat)
@@ -708,33 +741,6 @@ static int MenuIconsChanged(WPARAM, LPARAM) return 0;
}
-int RecursiveDeleteMenu(HMENU hMenu)
-{
- int cnt = GetMenuItemCount(hMenu);
- for (int i = 0; i < cnt; i++) {
- HMENU submenu = GetSubMenu(hMenu, 0);
- if (submenu) DestroyMenu(submenu);
- DeleteMenu(hMenu, 0, MF_BYPOSITION);
- }
- return 0;
-}
-
-static INT_PTR MenuGetMain(WPARAM, LPARAM)
-{
- RecursiveDeleteMenu(hMainMenu);
-
- BuildMainMenu(0, 0);
- return (INT_PTR)hMainMenu;
-}
-
-static INT_PTR BuildStatusMenu(WPARAM, LPARAM)
-{
- RecursiveDeleteMenu(hStatusMenu);
-
- Menu_Build(hStatusMenu, hStatusMenuObject);
- return (INT_PTR)hStatusMenu;
-}
-
static INT_PTR SetStatusMode(WPARAM wParam, LPARAM)
{
prochotkey = true;
@@ -964,7 +970,7 @@ void RebuildMenuOrder(void) }
}
- BuildStatusMenu(0, 0);
+ Menu_GetStatusMenu();
}
/////////////////////////////////////////////////////////////////////////////////////////
@@ -1138,12 +1144,6 @@ void InitCustomMenus(void) CreateServiceFunction(MS_CLIST_SETSTATUSMODE, SetStatusMode);
- CreateServiceFunction(MS_CLIST_MENUGETMAIN, MenuGetMain);
- CreateServiceFunction(MS_CLIST_MENUBUILDMAIN, BuildMainMenu);
-
- CreateServiceFunction(MS_CLIST_MENUBUILDCONTACT, BuildContactMenu);
-
- CreateServiceFunction(MS_CLIST_MENUGETSTATUS, BuildStatusMenu);
CreateServiceFunction(MS_CLIST_MENUPROCESSCOMMAND, MenuProcessCommand);
CreateServiceFunction(MS_CLIST_MENUPROCESSHOTKEY, MenuProcessHotkey);
diff --git a/src/mir_app/src/clisttray.cpp b/src/mir_app/src/clisttray.cpp index 2e45b26994..10ba26b081 100644 --- a/src/mir_app/src/clisttray.cpp +++ b/src/mir_app/src/clisttray.cpp @@ -685,7 +685,7 @@ INT_PTR fnTrayIconProcessMessage(WPARAM wParam, LPARAM lParam) else if (msg->lParam == (db_get_b(NULL, "CList", "Tray1Click", SETTING_TRAY1CLICK_DEFAULT) ? WM_LBUTTONUP : WM_LBUTTONDBLCLK)) {
if ((GetAsyncKeyState(VK_CONTROL) & 0x8000)) {
POINT pt;
- HMENU hMenu = (HMENU)CallService(MS_CLIST_MENUGETSTATUS, 0, 0);
+ HMENU hMenu = (HMENU)Menu_GetStatusMenu();
for (int i = 0; i < cli.trayIconCount; i++) {
if ((unsigned)cli.trayIcon[i].id == msg->wParam) {
@@ -727,10 +727,10 @@ INT_PTR fnTrayIconProcessMessage(WPARAM wParam, LPARAM lParam) mii.cbSize = sizeof(mii);
mii.fMask = MIIM_SUBMENU | MIIM_TYPE;
mii.fType = MFT_STRING;
- mii.hSubMenu = (HMENU)CallService(MS_CLIST_MENUGETMAIN, 0, 0);
+ mii.hSubMenu = Menu_GetMainMenu();
mii.dwTypeData = TranslateT("&Main menu");
InsertMenuItem(hMenu, 1, TRUE, &mii);
- mii.hSubMenu = (HMENU)CallService(MS_CLIST_MENUGETSTATUS, 0, 0);
+ mii.hSubMenu = (HMENU)Menu_GetStatusMenu();
mii.dwTypeData = TranslateT("&Status");
InsertMenuItem(hMenu, 2, TRUE, &mii);
SetMenuDefaultItem(hMenu, ID_TRAY_HIDE, FALSE);
diff --git a/src/mir_app/src/clui.cpp b/src/mir_app/src/clui.cpp index dc3413ee4c..d73eee5893 100644 --- a/src/mir_app/src/clui.cpp +++ b/src/mir_app/src/clui.cpp @@ -62,9 +62,9 @@ static int CluiModulesLoaded(WPARAM, LPARAM) MENUITEMINFO mii = { 0 };
mii.cbSize = sizeof(mii);
mii.fMask = MIIM_SUBMENU;
- mii.hSubMenu = (HMENU) CallService(MS_CLIST_MENUGETMAIN, 0, 0);
+ mii.hSubMenu = Menu_GetMainMenu();
SetMenuItemInfo(cli.hMenuMain, 0, TRUE, &mii);
- mii.hSubMenu = (HMENU) CallService(MS_CLIST_MENUGETSTATUS, 0, 0);
+ mii.hSubMenu = Menu_GetStatusMenu();
SetMenuItemInfo(cli.hMenuMain, 1, TRUE, &mii);
}
return 0;
@@ -876,7 +876,7 @@ LRESULT CALLBACK fnContactListWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM RECT rc;
POINT pt;
- hMenu = (HMENU) CallService(MS_CLIST_MENUGETSTATUS, 0, 0);
+ hMenu = Menu_GetStatusMenu();
nParts = SendMessage(cli.hwndStatus, SB_GETPARTS, 0, 0);
if (nm->dwItemSpec == 0xFFFFFFFE) {
nPanel = nParts - 1;
@@ -915,7 +915,7 @@ LRESULT CALLBACK fnContactListWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM MENUITEMINFO mii = { 0 };
mii.cbSize = sizeof(mii);
mii.fMask = MIIM_SUBMENU;
- mii.hSubMenu = (HMENU)CallService((pos == 0) ? MS_CLIST_MENUGETMAIN : MS_CLIST_MENUGETSTATUS, 0, 0);
+ mii.hSubMenu = (pos == 0) ? Menu_GetMainMenu() : Menu_GetStatusMenu();
SetMenuItemInfo(cli.hMenuMain, pos, TRUE, &mii);
}
}
@@ -955,9 +955,9 @@ LRESULT CALLBACK fnContactListWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM if (PtInRect(&rc, pt)) {
HMENU hMenu;
if (db_get_b(NULL, "CLUI", "SBarRightClk", 0))
- hMenu = (HMENU) CallService(MS_CLIST_MENUGETMAIN, 0, 0);
+ hMenu = Menu_GetMainMenu();
else
- hMenu = (HMENU) CallService(MS_CLIST_MENUGETSTATUS, 0, 0);
+ hMenu = (HMENU) Menu_GetStatusMenu();
TrackPopupMenu(hMenu, TPM_TOPALIGN | TPM_LEFTALIGN | TPM_RIGHTBUTTON, pt.x, pt.y, 0, hwnd, NULL);
return 0;
}
diff --git a/src/mir_app/src/meta_services.cpp b/src/mir_app/src/meta_services.cpp index 6bb8e3a315..38d926147b 100644 --- a/src/mir_app/src/meta_services.cpp +++ b/src/mir_app/src/meta_services.cpp @@ -659,7 +659,7 @@ int Meta_ModulesLoaded(WPARAM, LPARAM) static VOID CALLBACK sttMenuThread(PVOID param)
{
- HMENU hMenu = (HMENU)CallService(MS_CLIST_MENUBUILDCONTACT, (WPARAM)param, 0);
+ HMENU hMenu = Menu_BuildContactMenu(MCONTACT(param));
TPMPARAMS tpmp = { 0 };
tpmp.cbSize = sizeof(tpmp);
diff --git a/src/mir_app/src/mir_app.def b/src/mir_app/src/mir_app.def index 4daf0930f4..f8cb51b46f 100644 --- a/src/mir_app/src/mir_app.def +++ b/src/mir_app/src/mir_app.def @@ -225,3 +225,7 @@ Menu_AddContactMenuItem @222 Menu_AddMainMenuItem @223
Menu_AddProtoMenuItem @224
Menu_AddStatusMenuItem @225
+Menu_BuildContactMenu @226
+Menu_BuildMainMenu @227
+Menu_GetMainMenu @228
+Menu_GetStatusMenu @229
diff --git a/src/mir_app/src/mir_app64.def b/src/mir_app/src/mir_app64.def index e115db38c2..0e85f44f5c 100644 --- a/src/mir_app/src/mir_app64.def +++ b/src/mir_app/src/mir_app64.def @@ -225,3 +225,7 @@ Menu_AddContactMenuItem @222 Menu_AddMainMenuItem @223
Menu_AddProtoMenuItem @224
Menu_AddStatusMenuItem @225
+Menu_BuildContactMenu @226
+Menu_BuildMainMenu @227
+Menu_GetMainMenu @228
+Menu_GetStatusMenu @229
|