summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2015-06-22 12:13:16 +0000
committerGeorge Hazan <george.hazan@gmail.com>2015-06-22 12:13:16 +0000
commit4625aafb053a002f0223bfbe76abfbec629feacf (patch)
tree512f5e5fc5fd6b4d7a79d9b535158d065017f94f /src
parent28a3f4e95a93f30155c68aa87198595ca9e100b5 (diff)
minor correction in the internal genmenu structure
git-svn-id: http://svn.miranda-ng.org/main/trunk@14324 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'src')
-rw-r--r--src/mir_app/src/clistmenus.cpp41
-rw-r--r--src/mir_app/src/genmenu.cpp58
-rw-r--r--src/mir_app/src/genmenu.h6
3 files changed, 47 insertions, 58 deletions
diff --git a/src/mir_app/src/clistmenus.cpp b/src/mir_app/src/clistmenus.cpp
index 4cf60f4414..069f55920c 100644
--- a/src/mir_app/src/clistmenus.cpp
+++ b/src/mir_app/src/clistmenus.cpp
@@ -202,7 +202,7 @@ 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.ptszName;
+ mmep->szMenuName = tmi.name.t;
tmi.ownerdata = mmep;
PMO_IntMenuItem pimi = MO_AddNewMenuItem(hMainMenuObject, &tmi);
@@ -441,7 +441,7 @@ INT_PTR StatusMenuCheckService(WPARAM wParam, LPARAM)
if (timiParent) {
CLISTMENUITEM mi2 = { sizeof(mi2) };
mi2.flags = CMIM_NAME | CMIF_TCHAR;
- mi2.ptszName = TranslateTH(timi->mi.hLangpack, timi->mi.hIcon ? timi->mi.ptszName : LPGENT("Custom status"));
+ mi2.ptszName = TranslateTH(timi->mi.hLangpack, timi->mi.hIcon ? timi->mi.name.t : LPGENT("Custom status"));
timiParent = MO_GetIntMenuItem(timi->mi.root);
@@ -484,14 +484,14 @@ INT_PTR StatusMenuCheckService(WPARAM wParam, LPARAM)
else
timi->mi.flags &= ~CMIF_CHECKED;
}
- else if ((!smep || smep->proto) && timi->mi.pszName) {
+ else if ((!smep || smep->proto) && timi->mi.name.a) {
int curProtoStatus = 0;
BOOL IconNeedDestroy = FALSE;
char* prot;
if (smep)
prot = smep->proto;
else {
- char *prn = mir_u2a(timi->mi.ptszName);
+ char *prn = mir_u2a(timi->mi.name.t);
prot = NEWSTR_ALLOCA(prn);
if (prn) mir_free(prn);
}
@@ -564,8 +564,8 @@ INT_PTR StatusMenuExecService(WPARAM wParam, LPARAM)
ptszName = acc->tszAccountName;
pimi->mi.flags &= ~CMIF_CHECKED;
}
- replaceStrT(pimi->mi.ptszName, ptszName);
- replaceStrT(root->mi.ptszName, ptszName);
+ replaceStrT(pimi->mi.name.t, ptszName);
+ replaceStrT(root->mi.name.t, ptszName);
if (cli.hwndStatus)
InvalidateRect(cli.hwndStatus, NULL, TRUE);
@@ -851,16 +851,15 @@ void RebuildMenuOrder(void)
//adding root
TMO_MenuItem tmi = { 0 };
- tmi.cbSize = sizeof(tmi);
tmi.flags = CMIF_TCHAR | CMIF_ROOTHANDLE | CMIF_KEEPUNTRANSLATED;
tmi.position = pos++;
tmi.hIcon = ic = (HICON)CallProtoServiceInt(NULL, pa->szModuleName, PS_LOADICON, PLI_PROTOCOL | PLIF_SMALL, 0);
if (Proto_IsAccountLocked(pa) && cli.bDisplayLocked) {
mir_sntprintf(tbuf, _countof(tbuf), TranslateT("%s (locked)"), pa->tszAccountName);
- tmi.ptszName = tbuf;
+ tmi.name.t = tbuf;
}
- else tmi.ptszName = pa->tszAccountName;
+ else tmi.name.t = pa->tszAccountName;
//owner data
StatusMenuExecParam *smep = (StatusMenuExecParam*)mir_calloc(sizeof(StatusMenuExecParam));
@@ -870,7 +869,6 @@ void RebuildMenuOrder(void)
PMO_IntMenuItem rootmenu = MO_AddNewMenuItem(hStatusMenuObject, &tmi);
memset(&tmi, 0, sizeof(tmi));
- tmi.cbSize = sizeof(tmi);
tmi.flags = CMIF_TCHAR | CMIF_ROOTHANDLE | CMIF_KEEPUNTRANSLATED;
tmi.root = rootmenu;
tmi.position = pos++;
@@ -886,9 +884,9 @@ void RebuildMenuOrder(void)
if ((tmi.flags & CMIF_CHECKED) && cli.bDisplayLocked) {
mir_sntprintf(tbuf, _countof(tbuf), TranslateT("%s (locked)"), pa->tszAccountName);
- tmi.ptszName = tbuf;
+ tmi.name.t = tbuf;
}
- else tmi.ptszName = pa->tszAccountName;
+ else tmi.name.t = pa->tszAccountName;
PMO_IntMenuItem menuHandle = MO_AddNewMenuItem(hStatusMenuObject, &tmi);
((StatusMenuExecParam*)tmi.ownerdata)->protoindex = (int)menuHandle;
@@ -914,13 +912,12 @@ void RebuildMenuOrder(void)
// adding
memset(&tmi, 0, sizeof(tmi));
- tmi.cbSize = sizeof(tmi);
tmi.flags = CMIF_ROOTHANDLE | CMIF_TCHAR;
if (statusModeList[j] == ID_STATUS_OFFLINE)
tmi.flags |= CMIF_CHECKED;
tmi.root = rootmenu;
tmi.position = pos++;
- tmi.ptszName = cli.pfnGetStatusModeDescription(statusModeList[j], GSMDF_UNTRANSLATED);
+ tmi.name.t = cli.pfnGetStatusModeDescription(statusModeList[j], GSMDF_UNTRANSLATED);
tmi.hIcon = Skin_LoadProtoIcon(pa->szModuleName, statusModeList[j]);
// owner data
@@ -936,7 +933,7 @@ void RebuildMenuOrder(void)
hStatusMenuHandles[i].menuhandle[j] = MO_AddNewMenuItem(hStatusMenuObject, &tmi);
char buf[256];
- mir_snprintf(buf, "ProtocolIcon_%s_%s", pa->szModuleName, tmi.pszName);
+ mir_snprintf(buf, "ProtocolIcon_%s_%s", pa->szModuleName, tmi.name.a);
MO_SetOptionsMenuItem(hStatusMenuHandles[i].menuhandle[j], OPT_MENUITEMSETUNIQNAME, (INT_PTR)buf);
IcoLib_ReleaseIcon(tmi.hIcon);
@@ -976,13 +973,13 @@ void RebuildMenuOrder(void)
HotkeyToName(hotkeyName, _countof(hotkeyName), HIBYTE(hotKey), LOBYTE(hotKey));
mir_sntprintf(buf, _T("%s\t%s"),
cli.pfnGetStatusModeDescription(statusModeList[j], 0), hotkeyName);
- tmi.ptszName = buf;
+ tmi.name.t = buf;
tmi.hotKey = MAKELONG(HIBYTE(hotKey), LOBYTE(hotKey));
hStatusMainMenuHandles[j] = MO_AddNewMenuItem(hStatusMenuObject, &tmi);
}
char buf[256];
- mir_snprintf(buf, "Root2ProtocolIcon_%s_%s", pa->szModuleName, tmi.pszName);
+ mir_snprintf(buf, "Root2ProtocolIcon_%s_%s", pa->szModuleName, tmi.name.a);
MO_SetOptionsMenuItem(hStatusMainMenuHandles[j], OPT_MENUITEMSETUNIQNAME, (INT_PTR)buf);
IcoLib_ReleaseIcon(tmi.hIcon);
@@ -1005,7 +1002,7 @@ static int sttRebuildHotkeys(WPARAM, LPARAM)
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);
- tmi.ptszName = buf;
+ tmi.name.t = buf;
tmi.hotKey = MAKELONG(HIBYTE(hotKey), LOBYTE(hotKey));
MO_ModifyMenuItem(hStatusMainMenuHandles[j], &tmi);
}
@@ -1106,12 +1103,11 @@ int fnConvertMenu(CLISTMENUITEM *mi, TMO_MenuItem *pmi)
return FALSE;
memset(pmi, 0, sizeof(TMO_MenuItem));
- pmi->cbSize = sizeof(TMO_MenuItem);
pmi->root = mi->hParentMenu;
pmi->flags = mi->flags;
pmi->hIcon = mi->hIcon;
pmi->hotKey = mi->hotKey;
- pmi->pszName = mi->pszName;
+ pmi->name.a = mi->pszName;
pmi->position = mi->position;
pmi->hLangpack = mi->hLangpack;
return TRUE;
@@ -1164,12 +1160,11 @@ static INT_PTR AddStatusMenuItem(WPARAM wParam, LPARAM lParam)
}
if (pRoot == NULL) {
TMO_MenuItem tmi = { 0 };
- tmi.cbSize = sizeof(tmi);
tmi.flags = (mi->flags & CMIF_UNICODE) | CMIF_ROOTHANDLE;
tmi.position = 1001;
tmi.root = mp->pMenu;
tmi.hIcon = NULL;
- tmi.pszName = mi->pszPopupName;
+ tmi.name.a = mi->pszPopupName;
pRoot = MO_AddNewMenuItem(hStatusMenuObject, &tmi);
}
@@ -1205,7 +1200,7 @@ static INT_PTR AddStatusMenuItem(WPARAM wParam, LPARAM lParam)
smep->hMenuItem = menuHandle;
char buf[MAX_PATH + 64];
- char *p = (pRoot) ? mir_t2a(pRoot->mi.ptszName) : NULL;
+ char *p = (pRoot) ? mir_t2a(pRoot->mi.name.t) : NULL;
mir_snprintf(buf, "%s/%s", (p) ? p : "", mi->pszService ? mi->pszService : "");
mir_free(p);
diff --git a/src/mir_app/src/genmenu.cpp b/src/mir_app/src/genmenu.cpp
index 4920542b06..ac481b7407 100644
--- a/src/mir_app/src/genmenu.cpp
+++ b/src/mir_app/src/genmenu.cpp
@@ -39,7 +39,7 @@ static void DumpMenuItem(TMO_IntMenuItem* pParent, int level = 0)
temp[ level ] = 0;
for (PMO_IntMenuItem pimi = pParent; pimi != NULL; pimi = pimi->next) {
- Netlib_Logf(NULL, "%sMenu item %08p [%08p]: %S", temp, pimi, pimi->mi.root, pimi->mi.ptszName);
+ Netlib_Logf(NULL, "%sMenu item %08p [%08p]: %S", temp, pimi, pimi->mi.root, pimi->mi.name.t);
PMO_IntMenuItem submenu = pimi->submenu.first;
if (submenu)
@@ -79,9 +79,9 @@ int GetMenuObjbyId(const int id)
LPTSTR GetMenuItemText(PMO_IntMenuItem pimi)
{
if (pimi->mi.flags & CMIF_KEEPUNTRANSLATED)
- return pimi->mi.ptszName;
+ return pimi->mi.name.t;
- return TranslateTH(pimi->mi.hLangpack, pimi->mi.ptszName);
+ return TranslateTH(pimi->mi.hLangpack, pimi->mi.name.t);
}
///////////////////////////////////////////////////////////////////////////////
@@ -266,7 +266,7 @@ INT_PTR MO_GetProtoRootMenu(WPARAM wParam, LPARAM)
// lparam = PMO_MenuItem
INT_PTR MO_GetMenuItem(WPARAM wParam, LPARAM lParam)
{
- PMO_MenuItem mi = (PMO_MenuItem)lParam;
+ TMO_MenuItem *mi = (TMO_MenuItem*)lParam;
if (!bIsGenMenuInited || mi == NULL)
return -1;
@@ -301,11 +301,11 @@ INT_PTR MO_GetDefaultMenuItem(WPARAM wParam, LPARAM)
// wparam MenuItemHandle
// lparam PMO_MenuItem
-int MO_ModifyMenuItem(PMO_IntMenuItem menuHandle, PMO_MenuItem pmi)
+int MO_ModifyMenuItem(PMO_IntMenuItem menuHandle, TMO_MenuItem *pmi)
{
int oldflags;
- if (!bIsGenMenuInited || pmi == NULL || pmi->cbSize != sizeof(TMO_MenuItem))
+ if (!bIsGenMenuInited || pmi == NULL)
return -1;
mir_cslock lck(csMenuHook);
@@ -315,12 +315,12 @@ int MO_ModifyMenuItem(PMO_IntMenuItem menuHandle, PMO_MenuItem pmi)
return -1;
if (pmi->flags & CMIM_NAME) {
- FreeAndNil((void**)&pimi->mi.pszName);
+ FreeAndNil((void**)&pimi->mi.name.t);
if (pmi->flags & CMIF_UNICODE)
- pimi->mi.ptszName = mir_tstrdup(pmi->ptszName);
+ pimi->mi.name.t = mir_tstrdup(pmi->name.t);
else
- pimi->mi.ptszName = mir_a2t(pmi->pszName);
+ pimi->mi.name.t = mir_a2t(pmi->name.a);
}
if (pmi->flags & CMIM_FLAGS) {
@@ -631,9 +631,9 @@ static int GetNextObjectMenuItemId()
// lparam = PMO_MenuItem
// return MenuItemHandle
-PMO_IntMenuItem MO_AddNewMenuItem(HANDLE menuobjecthandle, PMO_MenuItem pmi)
+PMO_IntMenuItem MO_AddNewMenuItem(HANDLE menuobjecthandle, TMO_MenuItem *pmi)
{
- if (!bIsGenMenuInited || pmi == NULL || pmi->cbSize != sizeof(TMO_MenuItem))
+ if (!bIsGenMenuInited || pmi == NULL)
return NULL;
// old mode
@@ -658,9 +658,9 @@ PMO_IntMenuItem MO_AddNewMenuItem(HANDLE menuobjecthandle, PMO_MenuItem pmi)
p->hLangpack = pmi->hLangpack;
if (pmi->flags & CMIF_UNICODE)
- p->mi.ptszName = mir_tstrdup(pmi->ptszName);
+ p->mi.name.t = mir_tstrdup(pmi->name.t);
else
- p->mi.ptszName = mir_a2u(pmi->pszName);
+ p->mi.name.t = mir_a2u(pmi->name.a);
if (pmi->hIcon != NULL && !bIconsDisabled) {
HANDLE hIcolibItem = IcoLib_IsManaged(pmi->hIcon);
@@ -696,14 +696,14 @@ PMO_IntMenuItem MO_AddNewMenuItem(HANDLE menuobjecthandle, PMO_MenuItem pmi)
int FindRoot(PMO_IntMenuItem pimi, void* param)
{
- if (pimi->mi.pszName != NULL)
- if (pimi->submenu.first && !mir_tstrcmp(pimi->mi.ptszName, (TCHAR*)param))
+ if (pimi->mi.name.t != NULL)
+ if (pimi->submenu.first && !mir_tstrcmp(pimi->mi.name.t, (TCHAR*)param))
return TRUE;
return FALSE;
}
-PMO_IntMenuItem MO_AddOldNewMenuItem(HANDLE menuobjecthandle, PMO_MenuItem pmi)
+PMO_IntMenuItem MO_AddOldNewMenuItem(HANDLE menuobjecthandle, TMO_MenuItem *pmi)
{
if (!bIsGenMenuInited || pmi == NULL)
return NULL;
@@ -712,9 +712,6 @@ PMO_IntMenuItem MO_AddOldNewMenuItem(HANDLE menuobjecthandle, PMO_MenuItem pmi)
if (objidx == -1)
return NULL;
- if (pmi->cbSize != sizeof(TMO_MenuItem))
- return NULL;
-
if (pmi->flags & CMIF_ROOTHANDLE)
return NULL;
@@ -740,7 +737,7 @@ PMO_IntMenuItem MO_AddOldNewMenuItem(HANDLE menuobjecthandle, PMO_MenuItem pmi)
tmi.ownerdata = 0;
tmi.root = NULL;
// copy pszPopupName
- tmi.ptszName = (TCHAR*)pmi->root;
+ tmi.name.t = (TCHAR*)pmi->root;
if ((oldroot = MO_AddNewMenuItem(menuobjecthandle, &tmi)) != NULL)
MO_SetOptionsMenuItem(oldroot, OPT_MENUITEMSETUNIQNAME, (INT_PTR)pmi->root);
}
@@ -753,7 +750,7 @@ PMO_IntMenuItem MO_AddOldNewMenuItem(HANDLE menuobjecthandle, PMO_MenuItem pmi)
return MO_AddNewMenuItem(menuobjecthandle, pmi);
}
-static int WhereToPlace(HMENU hMenu, PMO_MenuItem mi)
+static int WhereToPlace(HMENU hMenu, TMO_MenuItem *mi)
{
MENUITEMINFO mii = { sizeof(mii) };
mii.fMask = MIIM_SUBMENU | MIIM_DATA;
@@ -874,9 +871,9 @@ void GetMenuItemName(PMO_IntMenuItem pMenuItem, char* pszDest, size_t cbDestSize
if (pMenuItem->UniqName)
mir_snprintf(pszDest, cbDestSize, "{%s}", pMenuItem->UniqName);
else if (pMenuItem->mi.flags & CMIF_UNICODE)
- mir_snprintf(pszDest, cbDestSize, "{%s}", (char*)_T2A(pMenuItem->mi.ptszName));
+ mir_snprintf(pszDest, cbDestSize, "{%s}", (char*)_T2A(pMenuItem->mi.name.t));
else
- mir_snprintf(pszDest, cbDestSize, "{%s}", pMenuItem->mi.pszName);
+ mir_snprintf(pszDest, cbDestSize, "{%s}", pMenuItem->mi.name.t);
}
HMENU BuildRecursiveMenu(HMENU hMenu, PMO_IntMenuItem pRootMenu, ListParam *param)
@@ -894,10 +891,7 @@ HMENU BuildRecursiveMenu(HMENU hMenu, PMO_IntMenuItem pRootMenu, ListParam *para
DeleteMenu(hMenu, 0, MF_BYPOSITION);
for (PMO_IntMenuItem pmi = pRootMenu; pmi != NULL; pmi = pmi->next) {
- PMO_MenuItem mi = &pmi->mi;
- if (mi->cbSize != sizeof(TMO_MenuItem))
- continue;
-
+ TMO_MenuItem *mi = &pmi->mi;
if (mi->flags & CMIF_HIDDEN)
continue;
@@ -933,7 +927,7 @@ HMENU BuildRecursiveMenu(HMENU hMenu, PMO_IntMenuItem pRootMenu, ListParam *para
continue; // find out what value to return if not getting added
}
- // mi.pszName
+ // mi.name.t
mir_snprintf(DBString, _countof(DBString), "%s_name", menuItemName);
if (!db_get_ts(NULL, MenuNameItems, DBString, &dbv)) {
if (mir_tstrlen(dbv.ptszVal) > 0)
@@ -976,7 +970,7 @@ HMENU BuildRecursiveMenu(HMENU hMenu, PMO_IntMenuItem pRootMenu, ListParam *para
if (pmi->mi.flags & CMIF_DEFAULT)
mii.fState |= MFS_DEFAULT;
- mii.dwTypeData = (pmi->CustomName) ? pmi->CustomName : mi->ptszName;
+ mii.dwTypeData = (pmi->CustomName) ? pmi->CustomName : mi->name.t;
// it's a submenu
if (pmi->submenu.first) {
@@ -986,7 +980,7 @@ HMENU BuildRecursiveMenu(HMENU hMenu, PMO_IntMenuItem pRootMenu, ListParam *para
#ifdef PUTPOSITIONSONMENU
if (GetKeyState(VK_CONTROL) & 0x8000) {
TCHAR str[256];
- mir_sntprintf(str, _countof(str), _T("%s (%d, id %x)"), mi->pszName, mi->position, mii.dwItemData);
+ mir_sntprintf(str, _countof(str), _T("%s (%d, id %x)"), mi->name.a, mi->position, mii.dwItemData);
mii.dwTypeData = str;
}
#endif
@@ -1001,7 +995,7 @@ HMENU BuildRecursiveMenu(HMENU hMenu, PMO_IntMenuItem pRootMenu, ListParam *para
#ifdef PUTPOSITIONSONMENU
if (GetKeyState(VK_CONTROL) & 0x8000) {
TCHAR str[256];
- mir_sntprintf(str, _countof(str), _T("%s (%d, id %x)"), mi->pszName, mi->position, mii.dwItemData);
+ mir_sntprintf(str, _countof(str), _T("%s (%d, id %x)"), mi->name.a, mi->position, mii.dwItemData);
mii.dwTypeData = str;
}
#endif
@@ -1228,7 +1222,7 @@ void TIntMenuObject::freeItem(TMO_IntMenuItem *p)
CallService(FreeService, (WPARAM)p, (LPARAM)p->mi.ownerdata);
p->signature = 0;
- FreeAndNil((void**)&p->mi.pszName);
+ FreeAndNil((void**)&p->mi.name.t);
FreeAndNil((void**)&p->UniqName);
FreeAndNil((void**)&p->CustomName);
if (p->hBmp) DeleteObject(p->hBmp);
diff --git a/src/mir_app/src/genmenu.h b/src/mir_app/src/genmenu.h
index 198d5417bc..1c129f2197 100644
--- a/src/mir_app/src/genmenu.h
+++ b/src/mir_app/src/genmenu.h
@@ -104,12 +104,12 @@ void GetMenuItemName(PMO_IntMenuItem pMenuItem, char* pszDest, size_t cbDestSize
PMO_IntMenuItem MO_GetIntMenuItem(HGENMENU);
-PMO_IntMenuItem MO_AddNewMenuItem(HANDLE menuobjecthandle, PMO_MenuItem pmi);
-PMO_IntMenuItem MO_AddOldNewMenuItem(HANDLE menuobjecthandle, PMO_MenuItem pmi);
+PMO_IntMenuItem MO_AddNewMenuItem(HANDLE menuobjecthandle, TMO_MenuItem *pmi);
+PMO_IntMenuItem MO_AddOldNewMenuItem(HANDLE menuobjecthandle, TMO_MenuItem *pmi);
int MO_DrawMenuItem(LPDRAWITEMSTRUCT dis);
int MO_MeasureMenuItem(LPMEASUREITEMSTRUCT mis);
-int MO_ModifyMenuItem(PMO_IntMenuItem menuHandle, PMO_MenuItem pmiparam);
+int MO_ModifyMenuItem(PMO_IntMenuItem menuHandle, TMO_MenuItem *pmiparam);
int MO_ProcessCommand(PMO_IntMenuItem pimi, LPARAM lParam);
INT_PTR MO_ProcessHotKeys(HANDLE menuHandle, INT_PTR vKey);
int MO_SetOptionsMenuItem(PMO_IntMenuItem menuobjecthandle, int setting, INT_PTR value);