diff options
author | George Hazan <george.hazan@gmail.com> | 2015-06-26 18:21:10 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2015-06-26 18:21:10 +0000 |
commit | 68924bfc1a213e619563c2cffb6d44b5b5346f6d (patch) | |
tree | 139f501b225080e4f895dbd40083df5956c3e339 /src | |
parent | b7a7d90f054d48dfda64e8a11d4f5cbb3fe2a521 (diff) |
next slice of cutting out unused menu features - popupPosition
git-svn-id: http://svn.miranda-ng.org/main/trunk@14400 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'src')
-rw-r--r-- | src/core/stdhelp/src/help.cpp | 2 | ||||
-rw-r--r-- | src/mir_app/src/clistmenus.cpp | 72 | ||||
-rw-r--r-- | src/mir_app/src/clistmod.cpp | 2 | ||||
-rw-r--r-- | src/mir_app/src/framesmenu.cpp | 112 | ||||
-rw-r--r-- | src/mir_app/src/genmenu.cpp | 7 | ||||
-rw-r--r-- | src/mir_app/src/genmenu.h | 1 | ||||
-rw-r--r-- | src/mir_app/src/movetogroup.cpp | 6 |
7 files changed, 157 insertions, 45 deletions
diff --git a/src/core/stdhelp/src/help.cpp b/src/core/stdhelp/src/help.cpp index a8c70ad3aa..d71ff4c9b1 100644 --- a/src/core/stdhelp/src/help.cpp +++ b/src/core/stdhelp/src/help.cpp @@ -76,7 +76,7 @@ int LoadHelpModule(void) CLISTMENUITEM mi = { 0 };
mi.icolibItem = Skin_GetIconHandle(SKINICON_OTHER_MIRANDA);
mi.pszPopupName = LPGEN("&Help");
- mi.popupPosition = 2000090000;
+ // mi.popupPosition = 2000090000; !!!!!!!!!!!!!!!!!!!!
mi.position = 2000090000;
mi.pszName = LPGEN("&About...");
mi.pszService = "Help/AboutCommand";
diff --git a/src/mir_app/src/clistmenus.cpp b/src/mir_app/src/clistmenus.cpp index d6ada2b63d..5103f02de3 100644 --- a/src/mir_app/src/clistmenus.cpp +++ b/src/mir_app/src/clistmenus.cpp @@ -92,23 +92,6 @@ tStatusMenuHandles, *lpStatusMenuHandles; lpStatusMenuHandles hStatusMenuHandles;
int hStatusMenuHandlesCnt;
-//mainmenu exec param(ownerdata)
-struct MainMenuExecParam
-{
- char *szServiceName;
- TCHAR *szMenuName;
- int Param1;
-};
-
-//contactmenu exec param(ownerdata)
-//also used in checkservice
-struct ContactMenuExecParam
-{
- char *szServiceName;
- char *pszContactOwner;//for check proc
- int param;
-};
-
struct BuildContactParam
{
char *szProto;
@@ -176,6 +159,13 @@ int fnGetAverageMode(int *pNetProtoCount) /////////////////////////////////////////////////////////////////////////////////////////
// MAIN MENU
+struct MainMenuExecParam
+{
+ char *szServiceName;
+ TCHAR *szMenuName;
+ TMO_IntMenuItem *pimi;
+};
+
static INT_PTR BuildMainMenu(WPARAM, LPARAM)
{
NotifyEventHooks(hPreBuildMainMenuEvent, 0, 0);
@@ -198,11 +188,11 @@ static INT_PTR AddMainMenuItem(WPARAM, LPARAM lParam) //we need just one parametr.
mmep->szServiceName = mir_strdup(mi->pszService);
- mmep->Param1 = mi->popupPosition;
mmep->szMenuName = tmi.name.t;
tmi.ownerdata = mmep;
TMO_IntMenuItem *pimi = Menu_AddItem(hMainMenuObject, &tmi);
+ mmep->pimi = pimi;
char* name;
bool needFree = false;
@@ -226,18 +216,14 @@ int MainMenuCheckService(WPARAM, LPARAM) return 0;
}
-//called with:
-//wparam - ownerdata
-//lparam - lparam from winproc
+// called with:
+// wparam - ownerdata
+// lparam - lparam from winproc
INT_PTR MainMenuExecService(WPARAM wParam, LPARAM lParam)
{
MainMenuExecParam *mmep = (MainMenuExecParam*)wParam;
if (mmep != NULL) {
- // bug in help.c, it used wparam as parent window handle without reason.
- if (!mir_strcmp(mmep->szServiceName, "Help/AboutCommand"))
- mmep->Param1 = 0;
-
- CallService(mmep->szServiceName, mmep->Param1, lParam);
+ CallService(mmep->szServiceName, mmep->pimi->execParam, lParam);
}
return 1;
}
@@ -255,6 +241,13 @@ INT_PTR FreeOwnerDataMainMenu(WPARAM, LPARAM lParam) /////////////////////////////////////////////////////////////////////////////////////////
// CONTACT MENU
+struct ContactMenuExecParam
+{
+ char *szServiceName;
+ char *pszContactOwner;//for check proc
+ TMO_IntMenuItem *pimi;
+};
+
static INT_PTR AddContactMenuItem(WPARAM, LPARAM lParam)
{
TMO_MenuItem tmi;
@@ -273,11 +266,12 @@ static INT_PTR AddContactMenuItem(WPARAM, LPARAM lParam) cmep->szServiceName = mir_strdup(mi->pszService);
if (mi->pszContactOwner != NULL)
cmep->pszContactOwner = mir_strdup(mi->pszContactOwner);
- cmep->param = mi->popupPosition;
tmi.ownerdata = cmep;
//may be need to change how UniqueName is formed?
- TMO_IntMenuItem *menuHandle = Menu_AddItem(hContactMenuObject, &tmi);
+ TMO_IntMenuItem *pimi = Menu_AddItem(hContactMenuObject, &tmi);
+ cmep->pimi = pimi;
+
char buf[256];
if (mi->pszService)
mir_snprintf(buf, "%s/%s", (mi->pszContactOwner) ? mi->pszContactOwner : "", (mi->pszService) ? mi->pszService : "");
@@ -288,8 +282,8 @@ static INT_PTR AddContactMenuItem(WPARAM, LPARAM lParam) mir_snprintf(buf, "%s/NoService/%s", (mi->pszContactOwner) ? mi->pszContactOwner : "", mi->ptszName);
}
else buf[0] = '\0';
- if (buf[0]) Menu_ConfigureItem(menuHandle, MCI_OPT_UNIQUENAME, buf);
- return (INT_PTR)menuHandle;
+ if (buf[0]) Menu_ConfigureItem(pimi, MCI_OPT_UNIQUENAME, buf);
+ return (INT_PTR)pimi;
}
static INT_PTR BuildContactMenu(WPARAM hContact, LPARAM)
@@ -316,7 +310,7 @@ INT_PTR ContactMenuExecService(WPARAM wParam, LPARAM lParam) if (wParam != 0) {
ContactMenuExecParam *cmep = (ContactMenuExecParam*)wParam;
//call with wParam = (MCONTACT)hContact, lparam = popupposition
- CallService(cmep->szServiceName, lParam, cmep->param);
+ CallService(cmep->szServiceName, lParam, cmep->pimi->execParam);
}
return 0;
}
@@ -841,9 +835,9 @@ void RebuildMenuOrder(void) }
else tmi.name.t = pa->tszAccountName;
- TMO_IntMenuItem *menuHandle = Menu_AddItem(hStatusMenuObject, &tmi);
- ((StatusMenuExecParam*)tmi.ownerdata)->protoindex = (int)menuHandle;
- Menu_ModifyItem(menuHandle, tmi.name.t, tmi.hIcon, tmi.flags);
+ TMO_IntMenuItem *pimi = Menu_AddItem(hStatusMenuObject, &tmi);
+ ((StatusMenuExecParam*)tmi.ownerdata)->protoindex = (int)pimi;
+ Menu_ModifyItem(pimi, tmi.name.t, tmi.hIcon, tmi.flags);
cli.menuProtos = (MenuProto*)mir_realloc(cli.menuProtos, sizeof(MenuProto)*(cli.menuProtoCount + 1));
memset(&(cli.menuProtos[cli.menuProtoCount]), 0, sizeof(MenuProto));
@@ -854,7 +848,7 @@ void RebuildMenuOrder(void) char buf[256];
mir_snprintf(buf, "RootProtocolIcon_%s", pa->szModuleName);
- Menu_ConfigureItem(menuHandle, MCI_OPT_UNIQUENAME, buf);
+ Menu_ConfigureItem(pimi, MCI_OPT_UNIQUENAME, buf);
DestroyIcon(ic);
pos += 500000;
@@ -1128,17 +1122,17 @@ static INT_PTR AddStatusMenuItem(WPARAM wParam, LPARAM lParam) tmi.ownerdata = smep;
}
- TMO_IntMenuItem *menuHandle = Menu_AddItem(hStatusMenuObject, &tmi);
+ TMO_IntMenuItem *pimi = Menu_AddItem(hStatusMenuObject, &tmi);
if (smep)
- smep->hMenuItem = menuHandle;
+ smep->hMenuItem = pimi;
char buf[MAX_PATH + 64];
char *p = (pRoot) ? mir_t2a(pRoot->mi.name.t) : NULL;
mir_snprintf(buf, "%s/%s", (p) ? p : "", mi->pszService ? mi->pszService : "");
mir_free(p);
- Menu_ConfigureItem(menuHandle, MCI_OPT_UNIQUENAME, buf);
- return (INT_PTR)menuHandle;
+ Menu_ConfigureItem(pimi, MCI_OPT_UNIQUENAME, buf);
+ return (INT_PTR)pimi;
}
/////////////////////////////////////////////////////////////////////////////////////////
diff --git a/src/mir_app/src/clistmod.cpp b/src/mir_app/src/clistmod.cpp index e1b20354f8..9d54905a72 100644 --- a/src/mir_app/src/clistmod.cpp +++ b/src/mir_app/src/clistmod.cpp @@ -26,6 +26,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "clc.h"
INT_PTR ContactChangeGroup(WPARAM wParam, LPARAM lParam);
+int InitFramesMenus(void);
int InitCListEvents(void);
void UninitCListEvents(void);
int ContactSettingChanged(WPARAM wParam, LPARAM lParam);
@@ -504,6 +505,7 @@ int LoadContactListModule2(void) InitCListEvents();
InitGroupServices();
+ InitFramesMenus();
cli.pfnInitTray();
hCListImages = ImageList_Create(16, 16, ILC_MASK | ILC_COLOR32, 13, 0);
diff --git a/src/mir_app/src/framesmenu.cpp b/src/mir_app/src/framesmenu.cpp new file mode 100644 index 0000000000..ce17f358ff --- /dev/null +++ b/src/mir_app/src/framesmenu.cpp @@ -0,0 +1,112 @@ +#include "stdafx.h"
+
+#include <m_cluiframes.h>
+
+//========================== Frames
+HANDLE hFrameMenuObject;
+static HANDLE hPreBuildFrameMenuEvent;
+
+//contactmenu exec param(ownerdata)
+//also used in checkservice
+typedef struct{
+ char *szServiceName;
+ int Frameid;
+ INT_PTR param1;
+}FrameMenuExecParam, *lpFrameMenuExecParam;
+
+INT_PTR FreeOwnerDataFrameMenu(WPARAM, LPARAM lParam)
+{
+ lpFrameMenuExecParam cmep = (lpFrameMenuExecParam)lParam;
+ if (cmep != NULL){
+ mir_free(cmep->szServiceName);
+ mir_free(cmep);
+ }
+ return 0;
+}
+
+static INT_PTR AddContextFrameMenuItem(WPARAM, LPARAM lParam)
+{
+ CLISTMENUITEM *mi = (CLISTMENUITEM*)lParam;
+
+ TMO_MenuItem tmi;
+ if (!cli.pfnConvertMenu(mi, &tmi))
+ return NULL;
+
+ tmi.root = (mi->flags & CMIF_ROOTHANDLE) ? mi->hParentMenu : NULL;
+
+ lpFrameMenuExecParam fmep = (lpFrameMenuExecParam)mir_alloc(sizeof(FrameMenuExecParam));
+ if (fmep == NULL)
+ return 0;
+
+ fmep->szServiceName = mir_strdup(mi->pszService);
+ fmep->Frameid = 0; // mi->popupPosition; !!!!!!!!!!!!!!!!!!!!!!!!!!
+ fmep->param1 = (INT_PTR)mi->pszContactOwner;
+ tmi.ownerdata = fmep;
+ return (INT_PTR)Menu_AddItem(hFrameMenuObject, &tmi);
+}
+
+//called with:
+//wparam - ownerdata
+//lparam - lparam from winproc
+INT_PTR FrameMenuExecService(WPARAM wParam, LPARAM lParam)
+{
+ lpFrameMenuExecParam fmep = (lpFrameMenuExecParam)wParam;
+ if (fmep == NULL)
+ return -1;
+
+ CallService(fmep->szServiceName, lParam, fmep->param1);
+ return 0;
+}
+
+//true - ok,false ignore
+INT_PTR FrameMenuCheckService(WPARAM wParam, LPARAM)
+{
+ TCheckProcParam *pcpp = (TCheckProcParam*)wParam;
+ if (pcpp == NULL)
+ return FALSE;
+
+ TMO_MenuItem mi;
+ if (Menu_GetItemInfo(pcpp->MenuItemHandle, mi) == 0) {
+ lpFrameMenuExecParam fmep = (lpFrameMenuExecParam)mi.ownerdata;
+ if (fmep != NULL) {
+ //pcpp->wParam - frameid
+ if (((WPARAM)fmep->Frameid == pcpp->wParam) || fmep->Frameid == -1)
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+static INT_PTR ContextFrameMenuNotify(WPARAM wParam, LPARAM lParam)
+{
+ NotifyEventHooks(hPreBuildFrameMenuEvent, wParam, lParam);
+ return 0;
+}
+
+static INT_PTR BuildContextFrameMenu(WPARAM wParam, LPARAM lParam)
+{
+ ContextFrameMenuNotify(wParam, -1);
+
+ HMENU hMenu = CreatePopupMenu();
+ Menu_Build(hMenu, hFrameMenuObject, wParam, lParam);
+ return (INT_PTR)hMenu;
+}
+
+//========================== Frames end
+
+int InitFramesMenus(void)
+{
+ CreateServiceFunction("FrameMenuExecService", FrameMenuExecService);
+ CreateServiceFunction("FrameMenuCheckService", FrameMenuCheckService);
+ CreateServiceFunction("FrameMenuFreeService", FreeOwnerDataFrameMenu);
+
+ CreateServiceFunction("CList/AddContextFrameMenuItem", AddContextFrameMenuItem);
+ CreateServiceFunction(MS_CLIST_MENUBUILDFRAMECONTEXT, BuildContextFrameMenu);
+ CreateServiceFunction(MS_CLIST_FRAMEMENUNOTIFY, ContextFrameMenuNotify);
+ hPreBuildFrameMenuEvent = CreateHookableEvent(ME_CLIST_PREBUILDFRAMEMENU);
+
+ // frame menu object
+ hFrameMenuObject = Menu_AddObject("FrameMenu", LPGEN("Frame menu"), "FrameMenuCheckService", "FrameMenuExecService");
+ Menu_ConfigureObject(hFrameMenuObject, MCO_OPT_FREE_SERVICE, "FrameMenuFreeService");
+ return 0;
+}
diff --git a/src/mir_app/src/genmenu.cpp b/src/mir_app/src/genmenu.cpp index 05babf2759..7eac996704 100644 --- a/src/mir_app/src/genmenu.cpp +++ b/src/mir_app/src/genmenu.cpp @@ -445,8 +445,7 @@ MIR_APP_DLL(BOOL) Menu_ProcessCommand(HGENMENU hMenuItem, LPARAM lParam) }
LPCSTR srvname = pimi->parent->ExecService;
- void *ownerdata = pimi->mi.ownerdata;
- CallService(srvname, (WPARAM)ownerdata, lParam);
+ CallService(srvname, (WPARAM)pimi->mi.ownerdata, lParam);
return true;
}
@@ -470,6 +469,10 @@ MIR_APP_DLL(int) Menu_ConfigureItem(HGENMENU hItem, int iOption, INT_PTR value) case MCI_OPT_HOTKEY:
pimi->hotKey = (DWORD)value;
return 0;
+
+ case MCI_OPT_EXECPARAM:
+ pimi->execParam = value;
+ return 0;
}
return 1;
diff --git a/src/mir_app/src/genmenu.h b/src/mir_app/src/genmenu.h index 17c6102763..93909aab18 100644 --- a/src/mir_app/src/genmenu.h +++ b/src/mir_app/src/genmenu.h @@ -54,6 +54,7 @@ struct TMO_IntMenuItem HBITMAP hBmp;
int originalPosition;
DWORD hotKey;
+ WPARAM execParam;
int hLangpack;
TMO_IntMenuItem *next; // next item in list
diff --git a/src/mir_app/src/movetogroup.cpp b/src/mir_app/src/movetogroup.cpp index ba995132c8..311c72a629 100644 --- a/src/mir_app/src/movetogroup.cpp +++ b/src/mir_app/src/movetogroup.cpp @@ -69,17 +69,17 @@ static void AddGroupItem(HGENMENU hRoot, TCHAR* name, int pos, WPARAM param, boo {
CLISTMENUITEM mi = { 0 };
mi.hParentMenu = hRoot;
- mi.popupPosition = param; // param to pszService - only with CMIF_ROOTHANDLE !!!!!!
mi.position = pos;
mi.ptszName = PrepareGroupName(name);
mi.flags = CMIF_ROOTHANDLE | CMIF_TCHAR | CMIF_KEEPUNTRANSLATED;
if (checked)
mi.flags |= CMIF_CHECKED;
mi.pszService = MTG_MOVE;
- HANDLE result = Menu_AddContactMenuItem(&mi);
- mir_free(mi.ptszName);
+ HGENMENU result = Menu_AddContactMenuItem(&mi);
+ Menu_ConfigureItem(result, MCI_OPT_EXECPARAM, param);
lphGroupsItems.insert((HANDLE*)result);
+ mir_free(mi.ptszName);
}
static int OnContactMenuBuild(WPARAM wParam, LPARAM)
|