summaryrefslogtreecommitdiff
path: root/plugins/Clist_modern/src/CLUIFrames/framesmenu.cpp
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2013-12-17 21:31:47 +0000
committerGeorge Hazan <george.hazan@gmail.com>2013-12-17 21:31:47 +0000
commitc5cd9533eabe06dd7cc3eda31290f8b11d09c79d (patch)
tree28fa58ff54498844e31ff9c057e06c56c20d3468 /plugins/Clist_modern/src/CLUIFrames/framesmenu.cpp
parent6c0a4e3a07f07ae80e554249814e4e5eef446427 (diff)
standardizing CLUIFrames file names
git-svn-id: http://svn.miranda-ng.org/main/trunk@7265 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Clist_modern/src/CLUIFrames/framesmenu.cpp')
-rw-r--r--plugins/Clist_modern/src/CLUIFrames/framesmenu.cpp124
1 files changed, 124 insertions, 0 deletions
diff --git a/plugins/Clist_modern/src/CLUIFrames/framesmenu.cpp b/plugins/Clist_modern/src/CLUIFrames/framesmenu.cpp
new file mode 100644
index 0000000000..8473c9403b
--- /dev/null
+++ b/plugins/Clist_modern/src/CLUIFrames/framesmenu.cpp
@@ -0,0 +1,124 @@
+#include "../hdr/modern_commonheaders.h"
+#include "../hdr/modern_commonprototypes.h"
+
+//========================== Frames
+HANDLE hFrameMenuObject;
+
+//contactmenu exec param(ownerdata)
+//also used in checkservice
+typedef struct{
+ char *szServiceName;
+ int Frameid;
+ INT_PTR param1;
+}
+ FrameMenuExecParam,*lpFrameMenuExecParam;
+
+static INT_PTR AddContextFrameMenuItem(WPARAM wParam, LPARAM lParam)
+{
+ CLISTMENUITEM *mi = (CLISTMENUITEM*)lParam;
+
+ TMO_MenuItem tmi;
+ if ( !pcli->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;
+
+ memset(fmep, 0, sizeof(FrameMenuExecParam));
+ fmep->szServiceName = mir_strdup(mi->pszService);
+ fmep->Frameid = mi->popupPosition;
+ fmep->param1 = (INT_PTR)mi->pszContactOwner;
+ tmi.ownerdata = fmep;
+ return CallService(MO_ADDNEWMENUITEM, (WPARAM)hFrameMenuObject, (LPARAM)&tmi);
+}
+
+static INT_PTR RemoveContextFrameMenuItem(WPARAM wParam, LPARAM lParam)
+{
+ lpFrameMenuExecParam fmep = (lpFrameMenuExecParam)CallService(MO_MENUITEMGETOWNERDATA, wParam, lParam);
+ if (fmep != NULL) {
+ if (fmep->szServiceName != NULL)
+ mir_free(fmep->szServiceName);
+ mir_free(fmep);
+ }
+
+ if (lParam != 1)
+ CallService(MO_REMOVEMENUITEM, wParam, 0);
+
+ return 0;
+}
+
+//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 lParam)
+{
+ PCheckProcParam pcpp = (PCheckProcParam)wParam;
+ if (pcpp == NULL)
+ return FALSE;
+
+ TMO_MenuItem mi;
+ if ( CallService(MO_GETMENUITEM, (WPARAM)pcpp->MenuItemHandle, (LPARAM)&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(g_CluiData.hEventPreBuildFrameMenu, wParam, lParam);
+ return 0;
+}
+
+static INT_PTR BuildContextFrameMenu(WPARAM wParam,LPARAM lParam)
+{
+ ListParam param = { 0 };
+ param.MenuObjectHandle = hFrameMenuObject;
+ param.wParam = wParam;
+ param.lParam = lParam;
+
+ HMENU hMenu = CreatePopupMenu();
+ ContextFrameMenuNotify(wParam, -1);
+ CallService(MO_BUILDMENU, (WPARAM)hMenu, (LPARAM)&param);
+ return (INT_PTR)hMenu;
+}
+
+//========================== Frames end
+
+int InitFramesMenus(void)
+{
+ CreateServiceFunction("FrameMenuExecService",FrameMenuExecService);
+ CreateServiceFunction("FrameMenuCheckService",FrameMenuCheckService);
+
+ CreateServiceFunction(MS_CLIST_REMOVECONTEXTFRAMEMENUITEM,RemoveContextFrameMenuItem);
+ CreateServiceFunction("CList/AddContextFrameMenuItem",AddContextFrameMenuItem);
+ CreateServiceFunction(MS_CLIST_MENUBUILDFRAMECONTEXT,BuildContextFrameMenu);
+ CreateServiceFunction(MS_CLIST_FRAMEMENUNOTIFY,ContextFrameMenuNotify);
+
+ // frame menu object
+ hFrameMenuObject = MO_CreateMenuObject("FrameMenu", LPGEN("Frame menu"), "FrameMenuCheckService", "FrameMenuExecService");
+ return 0;
+}
+
+int UnitFramesMenu()
+{
+ return 0;
+}