diff options
author | George Hazan <george.hazan@gmail.com> | 2015-06-25 12:41:45 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2015-06-25 12:41:45 +0000 |
commit | 7f1c59f929275ac7536c17e10f7267026957ae8f (patch) | |
tree | 4a0ab3eec309394d0dbc4a8e5e8da3101e855198 /plugins/MirOTR/src | |
parent | 503f26d1660a9b06f7eb1dcdeadc7038b27b1490 (diff) |
crazy own menu creation system removed from MirOTR
git-svn-id: http://svn.miranda-ng.org/main/trunk@14379 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/MirOTR/src')
-rw-r--r-- | plugins/MirOTR/src/mirotrmenu.cpp | 56 | ||||
-rw-r--r-- | plugins/MirOTR/src/mirotrmenu.h | 33 |
2 files changed, 18 insertions, 71 deletions
diff --git a/plugins/MirOTR/src/mirotrmenu.cpp b/plugins/MirOTR/src/mirotrmenu.cpp index f00c228042..8893296cff 100644 --- a/plugins/MirOTR/src/mirotrmenu.cpp +++ b/plugins/MirOTR/src/mirotrmenu.cpp @@ -16,38 +16,21 @@ MirOTRMenuExecParam,*lpMirOTRMenuExecParam; // MirOTR MENU /////////////////////////////////////////// -static INT_PTR RemoveMirOTRMenuItem(WPARAM wParam, LPARAM) +static HGENMENU AddMirOTRMenuItem(CLISTMENUITEM *mi) { - Menu_RemoveItem((HGENMENU)wParam); - return 0; -} - -static INT_PTR AddMirOTRMenuItem(WPARAM, LPARAM lParam) -{ - MIROTRMENUITEM *mi=(MIROTRMENUITEM*)lParam; - if ( mi->cbSize != sizeof( MIROTRMENUITEM )) - return 0; - TMO_MenuItem tmi = { 0 }; tmi.flags = mi->flags; tmi.hIcon = mi->hIcon; tmi.hIcolibItem = mi->icolibItem; tmi.position = mi->position; tmi.name.t = mi->ptszName; - tmi.root = mi->root; + tmi.root = mi->hParentMenu; - //owner data + // owner data lpMirOTRMenuExecParam cmep = ( lpMirOTRMenuExecParam )mir_calloc(sizeof(MirOTRMenuExecParam)); - cmep->szServiceName = mir_strdup( mi->pszService ); + cmep->szServiceName = mir_strdup(mi->pszService); tmi.ownerdata = cmep; - return (INT_PTR)Menu_AddItem(hMirOTRMenuObject, &tmi); -} - -static INT_PTR BuildMirOTRMenu(WPARAM hContact, LPARAM) -{ - HMENU hMenu = CreatePopupMenu(); - Menu_Build(hMenu, hMirOTRMenuObject, hContact); - return (INT_PTR)hMenu; + return Menu_AddItem(hMirOTRMenuObject, &tmi); } //called with: @@ -164,10 +147,13 @@ LRESULT CALLBACK PopupMenuWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM void ShowOTRMenu(MCONTACT hContact, POINT pt) { - HMENU menu = (HMENU)CallService(MS_MIROTR_MENUBUILDMIROTR, hContact, 0); + HMENU hMenu = CreatePopupMenu(); + Menu_Build(hMenu, hMirOTRMenuObject, hContact); + SetWindowLongPtr(hDummyPaintWin, GWLP_USERDATA, (LONG_PTR)hContact); - TrackPopupMenu(menu, 0, pt.x, pt.y, 0, hDummyPaintWin, 0); - DestroyMenu(menu); + + TrackPopupMenu(hMenu, 0, pt.x, pt.y, 0, hDummyPaintWin, 0); + DestroyMenu(hMenu); } void InitMirOTRMenu(void) @@ -186,56 +172,50 @@ void InitMirOTRMenu(void) CreateServiceFunction("MIROTRMENUS/FreeOwnerDataMirOTRMenu", FreeOwnerDataMirOTRMenu); CreateServiceFunction("MIROTRMENUS/OnAddMenuItemMirOTRMenu", OnAddMenuItemMirOTRMenu); - CreateServiceFunction(MS_MIROTR_ADDMIROTRMENUITEM, AddMirOTRMenuItem); - CreateServiceFunction(MS_MIROTR_MENUBUILDMIROTR, BuildMirOTRMenu); - CreateServiceFunction(MS_MIROTR_REMOVEMIROTRMENUITEM, RemoveMirOTRMenuItem); - hMirOTRMenuObject = Menu_AddObject("MirOTRMenu", LPGEN("MirOTR menu"), "MirOTRMenuCheckService", "MirOTRMenuExecService"); Menu_ConfigureObject(hMirOTRMenuObject, MCO_OPT_FREE_SERVICE, "MIROTRMENUS/FreeOwnerDataMirOTRMenu"); Menu_ConfigureObject(hMirOTRMenuObject, MCO_OPT_ONADD_SERVICE, "MIROTRMENUS/OnAddMenuItemMirOTRMenu"); // menu items - MIROTRMENUITEM mi = { 0 }; - mi.cbSize = sizeof(mi); - + CLISTMENUITEM mi = { 0 }; mi.flags = CMIF_DISABLED | CMIF_TCHAR; mi.ptszName = LPGENT("OTR Status"); mi.position = 0; - hStatusInfoItem = (HGENMENU)AddMirOTRMenuItem(0, (LPARAM)&mi); + hStatusInfoItem = AddMirOTRMenuItem(&mi); mi.flags = CMIF_TCHAR | CMIF_NOTPRIVATE | CMIF_NOTUNVERIFIED; mi.ptszName = LANG_MENU_START; mi.position = 100001; mi.pszService = MS_OTR_MENUSTART; mi.icolibItem = IcoLib_GetIconHandle(ICON_UNVERIFIED); - AddMirOTRMenuItem(0, (LPARAM)&mi); + AddMirOTRMenuItem(&mi); mi.flags = CMIF_TCHAR | CMIF_NOTNOTPRIVATE | CMIF_NOTFINISHED; mi.ptszName = LANG_MENU_REFRESH; mi.position = 100002; mi.pszService = MS_OTR_MENUREFRESH; mi.icolibItem = IcoLib_GetIconHandle(ICON_FINISHED); - AddMirOTRMenuItem(0, (LPARAM)&mi); + AddMirOTRMenuItem(&mi); mi.flags = CMIF_TCHAR | CMIF_NOTNOTPRIVATE; mi.ptszName = LANG_MENU_STOP; mi.position = 100003; mi.pszService = MS_OTR_MENUSTOP; mi.icolibItem = IcoLib_GetIconHandle(ICON_NOT_PRIVATE); - AddMirOTRMenuItem(0, (LPARAM)&mi); + AddMirOTRMenuItem(&mi); mi.flags = CMIF_TCHAR | CMIF_NOTNOTPRIVATE | CMIF_NOTFINISHED; mi.ptszName = LANG_MENU_VERIFY; mi.position = 200001; mi.pszService = MS_OTR_MENUVERIFY; mi.icolibItem = IcoLib_GetIconHandle(ICON_PRIVATE); - AddMirOTRMenuItem(0, (LPARAM)&mi); + AddMirOTRMenuItem(&mi); mi.flags = CMIF_TCHAR | CMIF_CHECKED; mi.ptszName = LANG_MENU_TOGGLEHTML; mi.position = 300001; mi.pszService = MS_OTR_MENUTOGGLEHTML; - hHTMLConvMenuItem = (HGENMENU)AddMirOTRMenuItem(0, (LPARAM)&mi); + hHTMLConvMenuItem = AddMirOTRMenuItem(&mi); } void UninitMirOTRMenu(void) diff --git a/plugins/MirOTR/src/mirotrmenu.h b/plugins/MirOTR/src/mirotrmenu.h index e57e954745..d101caa38e 100644 --- a/plugins/MirOTR/src/mirotrmenu.h +++ b/plugins/MirOTR/src/mirotrmenu.h @@ -1,7 +1,4 @@ #pragma once
-#define MS_MIROTR_ADDMIROTRMENUITEM MODULENAME"/AddMirOTRMenuItem"
-#define MS_MIROTR_MENUBUILDMIROTR MODULENAME"/MenuBuildMirOTR"
-#define MS_MIROTR_REMOVEMIROTRMENUITEM MODULENAME"/RemoveMirOTRMenuItem"
#define CMIF_NOTNOTPRIVATE CMIF_NOTOFFLINE
#define CMIF_NOTUNVERIFIED CMIF_NOTONLINE
@@ -9,36 +6,6 @@ #define CMIF_NOTFINISHED CMIF_NOTOFFLIST
#define CMIF_DISABLED 0x8000
-//add a new item to the MirOTR Menu
-//wParam=0
-//lParam=(LPARAM)(CLISTMENUITEM*)&mi
-//returns a handle to the new item, or NULL on failure
-//the service that is called when the item is clicked is called with
-//wParam=0, lParam=hContact
-//dividers are inserted every 100000 positions
-//pszContactOwner is ignored for this service.
-//
-// WARNING: do not use Translate(TS) for p(t)szName or p(t)szPopupName as they
-// are translated by the core, which may lead to double translation.
-// Use LPGEN instead which are just dummy wrappers/markers for "lpgen.pl".
-typedef struct {
- int cbSize; //size in bytes of this structure
- union {
- char* pszName; //[TRANSLATED-BY-CORE] text of the menu item
- TCHAR* ptszName; //Unicode text of the menu item
- };
- int position; //approx position on the menu. lower numbers go nearer the top
- HGENMENU root; //submenu where the item will be added, NULL for root
- DWORD flags; //set of MOMIF_* flags
- union {
- HICON hIcon; //icon to put by the item. If this was not loaded from
- //a resource, you can delete it straight after the call
- HANDLE icolibItem; //set CMIF_ICONFROMICOLIB to pass this value
- };
- DWORD hotKey; //keyboard accelerator, same as lParam of WM_HOTKEY,0 for none
- char* pszService; //name of service to call when the item gets selected
-} MIROTRMENUITEM;
-
void InitMirOTRMenu(void);
void UninitMirOTRMenu(void);
|