diff options
author | George Hazan <george.hazan@gmail.com> | 2013-12-16 16:07:54 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2013-12-16 16:07:54 +0000 |
commit | 3abd733254c02e2ca2c9bcc7fbbd1417c4a8ff74 (patch) | |
tree | f797b88d7a3c6993d447ac35b240a20fee4186b7 /src | |
parent | caf5e0116248d00c0b6beaed6e4e7817a0158fbb (diff) |
- new menu object helpers (MO_CreateMenuObject, MO_SetMenuObjectParam);
- menu item display names are now translatable;
- old nasty pieces of junk removed in CLUIFrames/cluiframes.cpp
git-svn-id: http://svn.miranda-ng.org/main/trunk@7247 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'src')
-rw-r--r-- | src/modules/clist/clistmenus.cpp | 31 | ||||
-rw-r--r-- | src/modules/clist/genmenu.cpp | 28 | ||||
-rw-r--r-- | src/modules/clist/genmenu.h | 13 | ||||
-rw-r--r-- | src/modules/clist/genmenuopt.cpp | 6 |
4 files changed, 31 insertions, 47 deletions
diff --git a/src/modules/clist/clistmenus.cpp b/src/modules/clist/clistmenus.cpp index cbb8f97b92..ef7fcde149 100644 --- a/src/modules/clist/clistmenus.cpp +++ b/src/modules/clist/clistmenus.cpp @@ -850,13 +850,7 @@ void RebuildMenuOrder(void) mir_free(hStatusMenuHandles);
}
- TMenuParam tmp = { 0 };
- tmp.cbSize = sizeof(tmp);
- tmp.ExecService = "StatusMenuExecService";
- tmp.CheckService = "StatusMenuCheckService";
- tmp.name = "StatusMenu";
-
- hStatusMenuObject = (HANDLE)CallService(MO_CREATENEWMENUOBJECT, 0, (LPARAM)&tmp);
+ hStatusMenuObject = MO_CreateMenuObject("StatusMenu", LPGEN("Status menu"), "StatusMenuCheckService", "StatusMenuExecService");
MO_SetOptionsMenuObject(hStatusMenuObject, OPT_MENUOBJECT_SET_FREE_SERVICE, (INT_PTR)"CLISTMENUS/FreeOwnerDataStatusMenu");
hStatusMainMenuHandles = (PMO_IntMenuItem*)mir_calloc(SIZEOF(statusModeList) * sizeof(PMO_IntMenuItem*));
@@ -1324,29 +1318,16 @@ void InitCustomMenus(void) hStatusMenuHandles = NULL;
hStatusMenuHandlesCnt = 0;
- //new menu sys
+ // new menu sys
InitGenMenu();
- //main menu
- {
- TMenuParam tmp = { sizeof(tmp) };
- tmp.ExecService = "MainMenuExecService";
- tmp.name = "MainMenu";
- hMainMenuObject = (HANDLE)CallService(MO_CREATENEWMENUOBJECT, 0, (LPARAM)&tmp);
- }
-
+ // 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");
- //contact menu
- {
- TMenuParam tmp = { sizeof(tmp) };
- tmp.CheckService = "ContactMenuCheckService";
- tmp.ExecService = "ContactMenuExecService";
- tmp.name = "ContactMenu";
- hContactMenuObject = (HANDLE)CallService(MO_CREATENEWMENUOBJECT, 0, (LPARAM)&tmp);
- }
-
+ // 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");
diff --git a/src/modules/clist/genmenu.cpp b/src/modules/clist/genmenu.cpp index 6fe6446ab6..15882d6475 100644 --- a/src/modules/clist/genmenu.cpp +++ b/src/modules/clist/genmenu.cpp @@ -50,7 +50,7 @@ static void DumpMenuItem(TMO_IntMenuItem* pParent, int level = 0) static int CompareMenus(const TIntMenuObject* p1, const TIntMenuObject* p2)
{
- return lstrcmpA(p1->Name, p2->Name);
+ return lstrcmpA(p1->pszName, p2->pszName);
}
LIST<TIntMenuObject> g_menus(10, CompareMenus);
@@ -434,7 +434,7 @@ int MO_ProcessCommand(PMO_IntMenuItem aHandle, LPARAM lParam) return -1;
}
- char *srvname = pimi->parent->ExecService;
+ LPCSTR srvname = pimi->parent->ExecService;
void *ownerdata = pimi->mi.ownerdata;
CallService(srvname, (WPARAM)ownerdata, lParam);
return 1;
@@ -495,20 +495,21 @@ int MO_SetOptionsMenuObject(HANDLE handle, int setting, INT_PTR value) return res;
}
-//wparam = 0;
+//wparam = LPCSTR szDisplayName;
//lparam = PMenuParam;
//result = MenuObjectHandle
-INT_PTR MO_CreateNewMenuObject(WPARAM, LPARAM lParam)
+INT_PTR MO_CreateNewMenuObject(WPARAM wParam, LPARAM lParam)
{
- PMenuParam pmp = (PMenuParam)lParam;
- if ( !bIsGenMenuInited || pmp == NULL)
+ TMenuParam *pmp = (TMenuParam *)lParam;
+ if (!bIsGenMenuInited || pmp == NULL)
return -1;
mir_cslock lck(csMenuHook);
TIntMenuObject* p = new TIntMenuObject();
p->id = NextObjectId++;
- p->Name = mir_strdup(pmp->name);
+ p->pszName = mir_strdup(pmp->name);
+ p->ptszDisplayName = Langpack_PcharToTchar(LPCSTR(wParam));
p->CheckService = mir_strdup(pmp->CheckService);
p->ExecService = mir_strdup(pmp->ExecService);
p->m_hMenuIcons = ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), ILC_COLOR32 | ILC_MASK, 15, 100);
@@ -901,7 +902,7 @@ HMENU BuildRecursiveMenu(HMENU hMenu, PMO_IntMenuItem pRootMenu, ListParam *para DBVARIANT dbv = { 0 };
int pos;
char MenuNameItems[256];
- mir_snprintf(MenuNameItems, SIZEOF(MenuNameItems), "%s_Items", pmo->Name);
+ mir_snprintf(MenuNameItems, SIZEOF(MenuNameItems), "%s_Items", pmo->pszName);
char menuItemName[256];
GetMenuItemName(pmi, menuItemName, sizeof(menuItemName));
@@ -1045,10 +1046,10 @@ static int MO_RegisterIcon(PMO_IntMenuItem pmi, void*) HICON hIcon = ImageList_GetIcon(pmi->parent->m_hMenuIcons, pmi->iconId, 0);
TCHAR sectionName[256];
- mir_sntprintf(sectionName, SIZEOF(sectionName), LPGENT("Menu icons") _T("/%s"), (TCHAR*)_A2T(pmi->parent->Name));
+ mir_sntprintf(sectionName, SIZEOF(sectionName), LPGENT("Menu icons") _T("/%s"), TranslateTS(pmi->parent->ptszDisplayName));
char iconame[256];
- mir_snprintf(iconame, sizeof(iconame), "genmenu_%s_%s", pmi->parent->Name, uname && *uname ? uname : descr);
+ mir_snprintf(iconame, sizeof(iconame), "genmenu_%s_%s", pmi->parent->pszName, uname && *uname ? uname : descr);
// remove '&'
if (descr) {
@@ -1154,7 +1155,7 @@ int InitGenMenu() CreateServiceFunction(MO_BUILDMENU, MO_BuildMenu);
CreateServiceFunction(MO_PROCESSCOMMAND, (MIRANDASERVICE)MO_ProcessCommand);
- CreateServiceFunction(MO_CREATENEWMENUOBJECT, MO_CreateNewMenuObject);
+ CreateServiceFunction("MO/CreateNewMenuObject", MO_CreateNewMenuObject);
CreateServiceFunction(MO_REMOVEMENUITEM, MO_RemoveMenuItem);
CreateServiceFunction(MO_ADDNEWMENUITEM, (MIRANDASERVICE)MO_AddNewMenuItem);
CreateServiceFunction(MO_MENUITEMGETOWNERDATA, MO_MenuItemGetOwnerData);
@@ -1166,7 +1167,7 @@ int InitGenMenu() CreateServiceFunction(MO_REMOVEMENUOBJECT, MO_RemoveMenuObject);
CreateServiceFunction(MO_GETPROTOROOTMENU, MO_GetProtoRootMenu);
- CreateServiceFunction(MO_SETOPTIONSMENUOBJECT, SRVMO_SetOptionsMenuObject);
+ CreateServiceFunction(MO_SRV_SETOPTIONSMENUOBJECT, SRVMO_SetOptionsMenuObject);
CreateServiceFunction(MO_SETOPTIONSMENUITEM, SRVMO_SetOptionsMenuItem);
bIconsDisabled = db_get_b(NULL, "CList", "DisableMenuIcons", 0) != 0;
@@ -1206,7 +1207,8 @@ TIntMenuObject::~TIntMenuObject() FreeAndNil((void**)&onAddService);
FreeAndNil((void**)&CheckService);
FreeAndNil((void**)&ExecService);
- FreeAndNil((void**)&Name);
+ FreeAndNil((void**)&ptszDisplayName);
+ FreeAndNil((void**)&pszName);
ImageList_Destroy(m_hMenuIcons);
}
diff --git a/src/modules/clist/genmenu.h b/src/modules/clist/genmenu.h index c3d14b0bbd..e33fc6159a 100644 --- a/src/modules/clist/genmenu.h +++ b/src/modules/clist/genmenu.h @@ -63,27 +63,28 @@ struct TIntMenuObject : public MZeroedObject TIntMenuObject();
~TIntMenuObject();
- char* Name;
- int id;
+ char *pszName;
+ TCHAR *ptszDisplayName;
+ int id;
//ExecService
//LPARAM lParam;//owner data
//WPARAM wParam;//allways lparam from winproc
- char *ExecService;
+ LPCSTR ExecService;
//CheckService called when building menu
//return false to skip item.
//LPARAM lParam;//0
//WPARAM wParam;//CheckParam
- char *CheckService;//analog to check_proc
+ LPCSTR CheckService;//analog to check_proc
//LPARAM lParam;//ownerdata
//WPARAM wParam;//menuitemhandle
- char *FreeService;//callback service used to free ownerdata for menuitems
+ LPCSTR FreeService;//callback service used to free ownerdata for menuitems
//LPARAM lParam;//MENUITEMINFO filled with all needed data
//WPARAM wParam;//menuitemhandle
- char *onAddService;//called just before add MENUITEMINFO to hMenu
+ LPCSTR onAddService;//called just before add MENUITEMINFO to hMenu
TMO_LinkedList m_items;
HIMAGELIST m_hMenuIcons;
diff --git a/src/modules/clist/genmenuopt.cpp b/src/modules/clist/genmenuopt.cpp index 379c503697..38294756ae 100644 --- a/src/modules/clist/genmenuopt.cpp +++ b/src/modules/clist/genmenuopt.cpp @@ -89,7 +89,7 @@ static int SaveTree(HWND hwndDlg) TIntMenuObject *pimo = g_menus[menupos];
char MenuNameItems[256];
- mir_snprintf(MenuNameItems, sizeof(MenuNameItems), "%s_Items", pimo->Name);
+ mir_snprintf(MenuNameItems, sizeof(MenuNameItems), "%s_Items", pimo->pszName);
int runtimepos = 100;
while (tvi.hItem != NULL) {
@@ -141,7 +141,7 @@ static int BuildMenuObjectsTree(HWND hwndDlg) continue;
tvis.item.lParam = (LPARAM)g_menus[i]->id;
- tvis.item.pszText = Langpack_PcharToTchar(g_menus[i]->Name);
+ tvis.item.pszText = TranslateTS(g_menus[i]->ptszDisplayName);
tvis.item.iImage = tvis.item.iSelectedImage = TRUE;
TreeView_InsertItem(hTree, &tvis);
mir_free(tvis.item.pszText);
@@ -231,7 +231,7 @@ static int BuildTree(HWND hwndDlg, int MenuObjectId, BOOL bReread) if (pimo->m_items.first == NULL)
return FALSE;
- mir_snprintf(MenuNameItems, sizeof(MenuNameItems), "%s_Items", pimo->Name);
+ mir_snprintf(MenuNameItems, sizeof(MenuNameItems), "%s_Items", pimo->pszName);
int count = 0;
{
|