diff options
author | George Hazan <george.hazan@gmail.com> | 2015-06-23 12:43:36 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2015-06-23 12:43:36 +0000 |
commit | 7d3d5e16b4e5378a751576095771c2a75b7276fb (patch) | |
tree | bda97aa4f8e050d6eeb56f24ad386fef7d5050e0 /src/mir_app | |
parent | f1fb66125cf0747022043cfdc9c83dfb8edb438e (diff) |
- Menu_ConfigureItem replaced MO_SETOPTIONSMENUITEM;
- Menu_ConfigureObject replaced MO_SETOPTIONSMENUOBJECT;
- TIntMenuObject::hotkey replaced TMenuObject::hotkey
git-svn-id: http://svn.miranda-ng.org/main/trunk@14349 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'src/mir_app')
-rw-r--r-- | src/mir_app/src/clistmenus.cpp | 34 | ||||
-rw-r--r-- | src/mir_app/src/genmenu.cpp | 66 | ||||
-rw-r--r-- | src/mir_app/src/genmenu.h | 3 | ||||
-rw-r--r-- | src/mir_app/src/mir_app.def | 3 | ||||
-rw-r--r-- | src/mir_app/src/mir_app64.def | 3 |
5 files changed, 47 insertions, 62 deletions
diff --git a/src/mir_app/src/clistmenus.cpp b/src/mir_app/src/clistmenus.cpp index 2e8c4cfda3..47e2fa473e 100644 --- a/src/mir_app/src/clistmenus.cpp +++ b/src/mir_app/src/clistmenus.cpp @@ -218,7 +218,7 @@ static INT_PTR AddMainMenuItem(WPARAM, LPARAM lParam) }
else name = mi->pszName;
- MO_SetOptionsMenuItem(pimi, OPT_MENUITEMSETUNIQNAME, (INT_PTR)name);
+ Menu_ConfigureItem(pimi, MCI_OPT_UNIQUENAME, name);
if (needFree) mir_free(name);
return (INT_PTR)pimi;
@@ -291,7 +291,7 @@ 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]) MO_SetOptionsMenuItem(menuHandle, OPT_MENUITEMSETUNIQNAME, (INT_PTR)buf);
+ if (buf[0]) Menu_ConfigureItem(menuHandle, MCI_OPT_UNIQUENAME, buf);
return (INT_PTR)menuHandle;
}
@@ -809,7 +809,7 @@ void RebuildMenuOrder(void) }
hStatusMenuObject = MO_CreateMenuObject("StatusMenu", LPGEN("Status menu"), "StatusMenuCheckService", "StatusMenuExecService");
- MO_SetOptionsMenuObject(hStatusMenuObject, OPT_MENUOBJECT_SET_FREE_SERVICE, (INT_PTR)"CLISTMENUS/FreeOwnerDataStatusMenu");
+ Menu_ConfigureObject(hStatusMenuObject, MCO_OPT_FREE_SERVICE, (INT_PTR)"CLISTMENUS/FreeOwnerDataStatusMenu");
hStatusMainMenuHandles = (TMO_IntMenuItem**)mir_calloc(_countof(statusModeList) * sizeof(TMO_IntMenuItem*));
hStatusMainMenuHandlesCnt = _countof(statusModeList);
@@ -885,7 +885,7 @@ void RebuildMenuOrder(void) char buf[256];
mir_snprintf(buf, "RootProtocolIcon_%s", pa->szModuleName);
- MO_SetOptionsMenuItem(menuHandle, OPT_MENUITEMSETUNIQNAME, (INT_PTR)buf);
+ Menu_ConfigureItem(menuHandle, MCI_OPT_UNIQUENAME, buf);
DestroyIcon(ic);
pos += 500000;
@@ -918,7 +918,7 @@ void RebuildMenuOrder(void) char buf[256];
mir_snprintf(buf, "ProtocolIcon_%s_%s", pa->szModuleName, tmi.name.a);
- MO_SetOptionsMenuItem(hStatusMenuHandles[i].menuhandle[j], OPT_MENUITEMSETUNIQNAME, (INT_PTR)buf);
+ Menu_ConfigureItem(hStatusMenuHandles[i].menuhandle[j], MCI_OPT_UNIQUENAME, buf);
IcoLib_ReleaseIcon(tmi.hIcon);
}
@@ -945,9 +945,8 @@ void RebuildMenuOrder(void) tmi.hIcon = Skin_LoadIcon(skinIconStatusList[j]);
tmi.position = pos++;
- tmi.hotKey = MAKELPARAM(MOD_CONTROL, '0' + j);
- //owner data
+ // owner data
StatusMenuExecParam *smep = (StatusMenuExecParam*)mir_calloc(sizeof(StatusMenuExecParam));
smep->status = statusModeList[j];
tmi.ownerdata = smep;
@@ -955,16 +954,16 @@ void RebuildMenuOrder(void) TCHAR buf[256], hotkeyName[100];
WORD hotKey = GetHotkeyValue(statusHotkeys[j]);
HotkeyToName(hotkeyName, _countof(hotkeyName), HIBYTE(hotKey), LOBYTE(hotKey));
- mir_sntprintf(buf, _T("%s\t%s"),
- cli.pfnGetStatusModeDescription(statusModeList[j], 0), hotkeyName);
+ mir_sntprintf(buf, _T("%s\t%s"), cli.pfnGetStatusModeDescription(statusModeList[j], 0), hotkeyName);
tmi.name.t = buf;
- tmi.hotKey = MAKELONG(HIBYTE(hotKey), LOBYTE(hotKey));
hStatusMainMenuHandles[j] = MO_AddNewMenuItem(hStatusMenuObject, &tmi);
+
+ hStatusMainMenuHandles[j]->hotKey = hotKey;
}
char buf[256];
mir_snprintf(buf, "Root2ProtocolIcon_%s_%s", pa->szModuleName, tmi.name.a);
- MO_SetOptionsMenuItem(hStatusMainMenuHandles[j], OPT_MENUITEMSETUNIQNAME, (INT_PTR)buf);
+ Menu_ConfigureItem(hStatusMainMenuHandles[j], MCI_OPT_UNIQUENAME, buf);
IcoLib_ReleaseIcon(tmi.hIcon);
break;
@@ -985,7 +984,7 @@ static int sttRebuildHotkeys(WPARAM, LPARAM) mir_sntprintf(buf, _T("%s\t%s"), cli.pfnGetStatusModeDescription(statusModeList[j], 0), hotkeyName);
Menu_ModifyItem(hStatusMainMenuHandles[j], buf);
- hStatusMainMenuHandles[j]->mi.hotKey = MAKELONG(HIBYTE(hotKey), LOBYTE(hotKey));
+ hStatusMainMenuHandles[j]->hotKey = MAKELONG(HIBYTE(hotKey), LOBYTE(hotKey));
}
return 0;
@@ -1072,7 +1071,6 @@ int fnConvertMenu(CLISTMENUITEM *mi, TMO_MenuItem *pmi) pmi->root = mi->hParentMenu;
pmi->flags = mi->flags;
pmi->hIcon = mi->hIcon;
- pmi->hotKey = mi->hotKey;
pmi->name.a = mi->pszName;
pmi->position = mi->position;
pmi->hLangpack = mi->hLangpack;
@@ -1170,7 +1168,7 @@ static INT_PTR AddStatusMenuItem(WPARAM wParam, LPARAM lParam) mir_snprintf(buf, "%s/%s", (p) ? p : "", mi->pszService ? mi->pszService : "");
mir_free(p);
- MO_SetOptionsMenuItem(menuHandle, OPT_MENUITEMSETUNIQNAME, (INT_PTR)buf);
+ Menu_ConfigureItem(menuHandle, MCI_OPT_UNIQUENAME, buf);
return (INT_PTR)menuHandle;
}
@@ -1249,13 +1247,13 @@ void InitCustomMenus(void) // main menu
hMainMenuObject = MO_CreateMenuObject("MainMenu", LPGEN("Main menu"), 0, "MainMenuExecService");
- MO_SetOptionsMenuObject(hMainMenuObject, OPT_USERDEFINEDITEMS, TRUE);
- MO_SetOptionsMenuObject(hMainMenuObject, OPT_MENUOBJECT_SET_FREE_SERVICE, (INT_PTR)"CLISTMENUS/FreeOwnerDataMainMenu");
+ Menu_ConfigureObject(hMainMenuObject, MCO_OPT_USERDEFINEDITEMS, TRUE);
+ Menu_ConfigureObject(hMainMenuObject, MCO_OPT_FREE_SERVICE, (INT_PTR)"CLISTMENUS/FreeOwnerDataMainMenu");
// contact menu
hContactMenuObject = MO_CreateMenuObject("ContactMenu", LPGEN("Contact menu"), "ContactMenuCheckService", "ContactMenuExecService");
- MO_SetOptionsMenuObject(hContactMenuObject, OPT_USERDEFINEDITEMS, TRUE);
- MO_SetOptionsMenuObject(hContactMenuObject, OPT_MENUOBJECT_SET_FREE_SERVICE, (INT_PTR)"CLISTMENUS/FreeOwnerDataContactMenu");
+ Menu_ConfigureObject(hContactMenuObject, MCO_OPT_USERDEFINEDITEMS, TRUE);
+ Menu_ConfigureObject(hContactMenuObject, MCO_OPT_FREE_SERVICE, (INT_PTR)"CLISTMENUS/FreeOwnerDataContactMenu");
// initialize hotkeys
CreateServiceFunction(MS_CLIST_HKSTATUS, HotkeySetStatus);
diff --git a/src/mir_app/src/genmenu.cpp b/src/mir_app/src/genmenu.cpp index 8efe8d2481..b060decb5c 100644 --- a/src/mir_app/src/genmenu.cpp +++ b/src/mir_app/src/genmenu.cpp @@ -225,11 +225,11 @@ INT_PTR MO_ProcessHotKeys(HANDLE menuHandle, INT_PTR vKey) return FALSE;
for (TMO_IntMenuItem *pimi = g_menus[objidx]->m_items.first; pimi != NULL; pimi = pimi->next) {
- if (pimi->mi.hotKey == 0) continue;
- if (HIWORD(pimi->mi.hotKey) != vKey) continue;
- if (!(LOWORD(pimi->mi.hotKey) & MOD_ALT) != !(GetKeyState(VK_MENU) & 0x8000)) continue;
- if (!(LOWORD(pimi->mi.hotKey) & MOD_CONTROL) != !(GetKeyState(VK_CONTROL) & 0x8000)) continue;
- if (!(LOWORD(pimi->mi.hotKey) & MOD_SHIFT) != !(GetKeyState(VK_SHIFT) & 0x8000)) continue;
+ if (pimi->hotKey == 0) continue;
+ if (HIWORD(pimi->hotKey) != vKey) continue;
+ if (!(LOWORD(pimi->hotKey) & MOD_ALT) != !(GetKeyState(VK_MENU) & 0x8000)) continue;
+ if (!(LOWORD(pimi->hotKey) & MOD_CONTROL) != !(GetKeyState(VK_CONTROL) & 0x8000)) continue;
+ if (!(LOWORD(pimi->hotKey) & MOD_SHIFT) != !(GetKeyState(VK_SHIFT) & 0x8000)) continue;
MO_ProcessCommand(pimi, 0);
return TRUE;
@@ -238,14 +238,13 @@ INT_PTR MO_ProcessHotKeys(HANDLE menuHandle, INT_PTR vKey) return FALSE;
}
-INT_PTR MO_GetProtoRootMenu(WPARAM wParam, LPARAM)
+MIR_APP_DLL(HGENMENU) Menu_GetProtocolRoot(const char *szProto)
{
- char *szProto = (char*)wParam;
if (szProto == NULL)
return 0;
if (db_get_b(NULL, "CList", "MoveProtoMenus", TRUE))
- return (INT_PTR)cli.pfnGetProtocolMenu(szProto);
+ return cli.pfnGetProtocolMenu(szProto);
int objidx = GetMenuObjbyId((int)hMainMenuObject);
if (objidx == -1)
@@ -256,7 +255,7 @@ INT_PTR MO_GetProtoRootMenu(WPARAM wParam, LPARAM) TIntMenuObject* pmo = g_menus[objidx];
for (TMO_IntMenuItem *p = pmo->m_items.first; p != NULL; p = p->next)
if (!mir_strcmp(p->UniqName, szProto))
- return (INT_PTR)p;
+ return p;
return NULL;
}
@@ -440,25 +439,30 @@ int MO_ProcessCommand(TMO_IntMenuItem *aHandle, LPARAM lParam) return 1;
}
-int MO_SetOptionsMenuItem(TMO_IntMenuItem *aHandle, int setting, INT_PTR value)
+MIR_APP_DLL(int) Menu_ConfigureItem(HGENMENU hItem, int iOption, INT_PTR value)
{
if (!bIsGenMenuInited)
return -1;
mir_cslock lck(csMenuHook);
- TMO_IntMenuItem *pimi = MO_GetIntMenuItem(aHandle);
+ TMO_IntMenuItem *pimi = MO_GetIntMenuItem(hItem);
if (pimi == NULL)
return -1;
- if (setting == OPT_MENUITEMSETUNIQNAME) {
- mir_free(pimi->UniqName);
- pimi->UniqName = mir_strdup((char*)value);
+ switch (iOption) {
+ case MCI_OPT_UNIQUENAME:
+ replaceStr(pimi->UniqName, (char*)value);
+ return 0;
+
+ case MCI_OPT_HOTKEY:
+ pimi->hotKey = (DWORD)value;
+ return 0;
}
return 1;
}
-int MO_SetOptionsMenuObject(HANDLE handle, int setting, INT_PTR value)
+MIR_APP_DLL(int) Menu_ConfigureObject(HANDLE handle, int setting, INT_PTR value)
{
if (!bIsGenMenuInited)
return -1;
@@ -471,22 +475,22 @@ int MO_SetOptionsMenuObject(HANDLE handle, int setting, INT_PTR value) TIntMenuObject* pmo = g_menus[pimoidx];
switch (setting) {
- case OPT_MENUOBJECT_SET_ONADD_SERVICE:
+ case MCO_OPT_ONADD_SERVICE:
FreeAndNil((void**)&pmo->onAddService);
pmo->onAddService = mir_strdup((char*)value);
break;
- case OPT_MENUOBJECT_SET_FREE_SERVICE:
+ case MCO_OPT_FREE_SERVICE:
FreeAndNil((void**)&pmo->FreeService);
pmo->FreeService = mir_strdup((char*)value);
break;
- case OPT_MENUOBJECT_SET_CHECK_SERVICE:
+ case MCO_OPT_CHECK_SERVICE:
FreeAndNil((void**)&pmo->CheckService);
pmo->CheckService = mir_strdup((char*)value);
break;
- case OPT_USERDEFINEDITEMS:
+ case MCO_OPT_USERDEFINEDITEMS:
pmo->m_bUseUserDefinedItems = (BOOL)value;
break;
}
@@ -728,7 +732,7 @@ TMO_IntMenuItem *MO_AddOldNewMenuItem(HANDLE menuobjecthandle, TMO_MenuItem *pmi // copy pszPopupName
tmi.name.t = (TCHAR*)pmi->root;
if ((oldroot = MO_AddNewMenuItem(menuobjecthandle, &tmi)) != NULL)
- MO_SetOptionsMenuItem(oldroot, OPT_MENUITEMSETUNIQNAME, (INT_PTR)pmi->root);
+ Menu_ConfigureItem(oldroot, MCI_OPT_UNIQUENAME, (const char*)pmi->root);
}
pmi->root = oldroot;
@@ -1128,24 +1132,6 @@ static int OnModulesLoaded(WPARAM, LPARAM) return 0;
}
-static INT_PTR SRVMO_SetOptionsMenuObject(WPARAM, LPARAM lParam)
-{
- lpOptParam lpop = (lpOptParam)lParam;
- if (lpop == NULL)
- return 0;
-
- return MO_SetOptionsMenuObject(lpop->Handle, lpop->Setting, lpop->Value);
-}
-
-static INT_PTR SRVMO_SetOptionsMenuItem(WPARAM, LPARAM lParam)
-{
- lpOptParam lpop = (lpOptParam)lParam;
- if (lpop == NULL)
- return 0;
-
- return MO_SetOptionsMenuItem((TMO_IntMenuItem*)lpop->Handle, lpop->Setting, lpop->Value);
-}
-
int InitGenMenu()
{
CreateServiceFunction(MO_BUILDMENU, MO_BuildMenu);
@@ -1160,10 +1146,6 @@ int InitGenMenu() CreateServiceFunction(MO_PROCESSCOMMANDBYMENUIDENT, MO_ProcessCommandByMenuIdent);
CreateServiceFunction(MO_PROCESSHOTKEYS, (MIRANDASERVICE)MO_ProcessHotKeys);
CreateServiceFunction(MO_REMOVEMENUOBJECT, MO_RemoveMenuObject);
- CreateServiceFunction(MO_GETPROTOROOTMENU, MO_GetProtoRootMenu);
-
- CreateServiceFunction(MO_SRV_SETOPTIONSMENUOBJECT, SRVMO_SetOptionsMenuObject);
- CreateServiceFunction(MO_SETOPTIONSMENUITEM, SRVMO_SetOptionsMenuItem);
bIconsDisabled = db_get_b(NULL, "CList", "DisableMenuIcons", 0) != 0;
diff --git a/src/mir_app/src/genmenu.h b/src/mir_app/src/genmenu.h index 12dabdacc7..0c5f3cd0d2 100644 --- a/src/mir_app/src/genmenu.h +++ b/src/mir_app/src/genmenu.h @@ -53,6 +53,7 @@ struct TMO_IntMenuItem HANDLE hIcolibItem; // handle of iconlib item
HBITMAP hBmp;
int originalPosition;
+ DWORD hotKey;
int hLangpack;
TMO_IntMenuItem *next; // next item in list
@@ -113,8 +114,6 @@ int MO_DrawMenuItem(LPDRAWITEMSTRUCT dis); int MO_MeasureMenuItem(LPMEASUREITEMSTRUCT mis);
int MO_ProcessCommand(TMO_IntMenuItem *pimi, LPARAM lParam);
INT_PTR MO_ProcessHotKeys(HANDLE menuHandle, INT_PTR vKey);
-int MO_SetOptionsMenuItem(TMO_IntMenuItem *menuobjecthandle, int setting, INT_PTR value);
-int MO_SetOptionsMenuObject(HANDLE menuobjecthandle, int setting, INT_PTR value);
INT_PTR MO_ProcessCommandByMenuIdent(WPARAM wParam, LPARAM lParam);
int MO_ProcessCommandBySubMenuIdent(int menuID, int command, LPARAM lParam);
diff --git a/src/mir_app/src/mir_app.def b/src/mir_app/src/mir_app.def index 8764180eff..e8e029f9e7 100644 --- a/src/mir_app/src/mir_app.def +++ b/src/mir_app/src/mir_app.def @@ -202,3 +202,6 @@ Utils_ReplaceVars @199 Utils_ReplaceVarsW @200
Menu_ShowItem @201
Menu_ModifyItem @202
+Menu_ConfigureItem @203
+Menu_GetProtocolRoot @204
+Menu_ConfigureObject @205
diff --git a/src/mir_app/src/mir_app64.def b/src/mir_app/src/mir_app64.def index 87aee3de21..e1114580b8 100644 --- a/src/mir_app/src/mir_app64.def +++ b/src/mir_app/src/mir_app64.def @@ -202,3 +202,6 @@ Utils_ReplaceVars @199 Utils_ReplaceVarsW @200
Menu_ShowItem @201
Menu_ModifyItem @202
+Menu_ConfigureItem @203
+Menu_GetProtocolRoot @204
+Menu_ConfigureObject @205
|