From ab4abbb7a60f941acab8f0566c6b619f68f1b489 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sat, 27 Jun 2015 11:09:19 +0000 Subject: - CLISTMENUITEM::pszContactOwner removed, because it's supported only by contact's menu; - Menu_AddContactMenuItem now receives parameter szProto; - Menu_Add* helpers are converted into real functions; git-svn-id: http://svn.miranda-ng.org/main/trunk@14409 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/Clist_nicer/src/CLUIFrames/cluiframes.cpp | 101 +++++++++++----------- plugins/Clist_nicer/src/CLUIFrames/cluiframes.h | 1 + plugins/Clist_nicer/src/CLUIFrames/groupmenu.cpp | 42 ++++----- 3 files changed, 74 insertions(+), 70 deletions(-) (limited to 'plugins/Clist_nicer/src/CLUIFrames') diff --git a/plugins/Clist_nicer/src/CLUIFrames/cluiframes.cpp b/plugins/Clist_nicer/src/CLUIFrames/cluiframes.cpp index 1921b5137c..e3e2986474 100644 --- a/plugins/Clist_nicer/src/CLUIFrames/cluiframes.cpp +++ b/plugins/Clist_nicer/src/CLUIFrames/cluiframes.cpp @@ -564,7 +564,17 @@ int CLUIFramesGetalClientFrame(void) return -1; } -HMENU CLUIFramesCreateMenuForFrame(int frameid, HGENMENU root, int popuppos, HGENMENU(*pfnAdd)(CLISTMENUITEM*)) +///////////////////////////////////////////////////////////////////////////////////////// + +static HGENMENU addFrameMenuItem(CLISTMENUITEM *pmi, int frameid, bool bMain) +{ + HGENMENU res = (bMain) ? Menu_AddMainMenuItem(pmi) : Menu_AddContextFrameMenuItem(pmi); + if (pmi->pszService != NULL) + Menu_ConfigureItem(res, MCI_OPT_EXECPARAM, frameid); + return res; +} + +HMENU CLUIFramesCreateMenuForFrame(int frameid, HGENMENU root, int popuppos, bool bMain) { if (FramesSysNotStarted) return NULL; @@ -576,114 +586,107 @@ HMENU CLUIFramesCreateMenuForFrame(int frameid, HGENMENU root, int popuppos, HGE mi.icolibItem = Skin_GetIconHandle(SKINICON_OTHER_MIRANDA); mi.hParentMenu = root; mi.position = popuppos++; - mi.pszName = LPGEN("&FrameTitle"); + mi.name.a = LPGEN("&FrameTitle"); mi.flags = CMIF_GRAYED; - fmh.MITitle = pfnAdd(&mi); + fmh.MITitle = addFrameMenuItem(&mi, frameid, bMain); popuppos += 100000; - mi.hIcon = NULL; + mi.icolibItem = NULL; mi.position = popuppos++; - mi.pszName = LPGEN("&Visible"); + mi.name.a = LPGEN("&Visible"); mi.flags = CMIF_CHECKED; mi.pszService = MS_CLIST_FRAMES_SHFRAME; - Menu_ConfigureItem(fmh.MIVisible = pfnAdd(&mi), MCI_OPT_EXECPARAM, frameid); + fmh.MIVisible = addFrameMenuItem(&mi, frameid, bMain); mi.position = popuppos++; - mi.pszName = LPGEN("&Show title bar"); + mi.name.a = LPGEN("&Show title bar"); mi.flags = CMIF_CHECKED; mi.pszService = MS_CLIST_FRAMES_SHFRAMETITLEBAR; - Menu_ConfigureItem(fmh.MITBVisible = pfnAdd(&mi), MCI_OPT_EXECPARAM, frameid); + fmh.MITBVisible = addFrameMenuItem(&mi, frameid, bMain); popuppos += 100000; mi.position = popuppos++; - mi.pszName = LPGEN("&Locked"); + mi.name.a = LPGEN("&Locked"); mi.flags = CMIF_CHECKED; mi.pszService = MS_CLIST_FRAMES_ULFRAME; - Menu_ConfigureItem(fmh.MILock = pfnAdd(&mi), MCI_OPT_EXECPARAM, frameid); + fmh.MILock = addFrameMenuItem(&mi, frameid, bMain); mi.position = popuppos++; - mi.pszName = LPGEN("&Collapsed"); + mi.name.a = LPGEN("&Collapsed"); mi.flags = CMIF_CHECKED; mi.pszService = MS_CLIST_FRAMES_UCOLLFRAME; - Menu_ConfigureItem(fmh.MIColl = pfnAdd(&mi), MCI_OPT_EXECPARAM, frameid); + fmh.MIColl = addFrameMenuItem(&mi, frameid, bMain); // floating mi.position = popuppos++; - mi.pszName = LPGEN("&Floating mode"); + mi.name.a = LPGEN("&Floating mode"); mi.flags = 0; mi.pszService = "Set_Floating"; - fmh.MIFloating = pfnAdd(&mi); + fmh.MIFloating = addFrameMenuItem(&mi, frameid, bMain); popuppos += 100000; mi.position = popuppos++; - mi.pszName = LPGEN("&Border"); + mi.name.a = LPGEN("&Border"); mi.flags = CMIF_CHECKED; mi.pszService = MS_CLIST_FRAMES_SETUNBORDER; - Menu_ConfigureItem(fmh.MIBorder = pfnAdd(&mi), MCI_OPT_EXECPARAM, frameid); + fmh.MIBorder = addFrameMenuItem(&mi, frameid, bMain); popuppos += 100000; mi.position = popuppos++; - mi.pszName = LPGEN("&Skinned frame"); + mi.name.a = LPGEN("&Skinned frame"); mi.flags = CMIF_CHECKED; mi.pszService = MS_CLIST_FRAMES_SETSKINNED; - Menu_ConfigureItem(fmh.MISkinned = pfnAdd(&mi), MCI_OPT_EXECPARAM, frameid); + fmh.MISkinned = addFrameMenuItem(&mi, frameid, bMain); popuppos += 100000; // alignment root mi.hParentMenu = root; mi.position = popuppos++; - mi.pszName = LPGEN("&Align"); + mi.name.a = LPGEN("&Align"); mi.flags = 0; - mi.pszService = ""; - fmh.MIAlignRoot = pfnAdd(&mi); + mi.pszService = NULL; + fmh.MIAlignRoot = addFrameMenuItem(&mi, frameid, bMain); // align top mi.hParentMenu = fmh.MIAlignRoot; mi.position = popuppos++; - mi.pszName = LPGEN("&Top"); + mi.name.a = LPGEN("&Top"); mi.pszService = CLUIFRAMESSETALIGNALTOP; - mi.pszContactOwner = (char*)alTop; - Menu_ConfigureItem(fmh.MIAlignTop = pfnAdd(&mi), MCI_OPT_EXECPARAM, frameid); + fmh.MIAlignTop = addFrameMenuItem(&mi, frameid, bMain); // align client mi.position = popuppos++; - mi.pszName = LPGEN("&Client"); + mi.name.a = LPGEN("&Client"); mi.pszService = CLUIFRAMESSETALIGNALCLIENT; - mi.pszContactOwner = (char*)alClient; - Menu_ConfigureItem(fmh.MIAlignClient = pfnAdd(&mi), MCI_OPT_EXECPARAM, frameid); + fmh.MIAlignClient = addFrameMenuItem(&mi, frameid, bMain); // align bottom mi.position = popuppos++; - mi.pszName = LPGEN("&Bottom"); + mi.name.a = LPGEN("&Bottom"); mi.pszService = CLUIFRAMESSETALIGNALBOTTOM; - mi.pszContactOwner = (char*)alBottom; - Menu_ConfigureItem(fmh.MIAlignBottom = pfnAdd(&mi), MCI_OPT_EXECPARAM, frameid); + fmh.MIAlignBottom = addFrameMenuItem(&mi, frameid, bMain); // position root mi.hParentMenu = root; mi.position = popuppos++; - mi.pszName = LPGEN("&Position"); - mi.pszService = ""; - mi.pszContactOwner = (char*)0; - HGENMENU menuid = pfnAdd(&mi); + mi.name.a = LPGEN("&Position"); + mi.pszService = NULL; + mi.hParentMenu = addFrameMenuItem(&mi, frameid, bMain); - mi.hParentMenu = menuid; mi.position = popuppos++; - mi.pszName = LPGEN("&Up"); + mi.name.a = LPGEN("&Up"); mi.pszService = CLUIFRAMESMOVEUP; - mi.pszContactOwner = (char*)1; - Menu_ConfigureItem(pfnAdd(&mi), MCI_OPT_EXECPARAM, frameid); + addFrameMenuItem(&mi, frameid, bMain); mi.position = popuppos++; - mi.pszName = LPGEN("&Down"); + mi.name.a = LPGEN("&Down"); mi.pszService = CLUIFRAMESMOVEDOWN; - mi.pszContactOwner = (char*)-1; - Menu_ConfigureItem(pfnAdd(&mi), MCI_OPT_EXECPARAM, frameid); + addFrameMenuItem(&mi, frameid, bMain); return 0; } @@ -1338,21 +1341,21 @@ static int CLUIFramesLoadMainMenu() CLISTMENUITEM mi = { 0 }; mi.icolibItem = Skin_GetIconHandle(SKINICON_OTHER_FRAME); mi.position = 3000090000; - mi.pszName = LPGEN("Frames"); + mi.name.a = LPGEN("Frames"); mi.pszService = 0; cont.MainMenuItem = Menu_AddMainMenuItem(&mi); // create frames menu int separator = (int)3000200000; for (int i = 0; i < nFramescount; i++) { - mi.hIcon = Frames[i].TitleBar.hicon; + mi.icolibItem = Frames[i].TitleBar.hicon; mi.flags = CMIF_TCHAR; mi.position = separator; mi.hParentMenu = cont.MainMenuItem; - mi.ptszName = Frames[i].TitleBar.tbname ? Frames[i].TitleBar.tbname : Frames[i].name; + mi.name.t = Frames[i].TitleBar.tbname ? Frames[i].TitleBar.tbname : Frames[i].name; mi.pszService = 0; Frames[i].MenuHandles.MainMenuItem = Menu_AddMainMenuItem(&mi); - CLUIFramesCreateMenuForFrame(Frames[i].id, Frames[i].MenuHandles.MainMenuItem, separator, Menu_AddMainMenuItem); + CLUIFramesCreateMenuForFrame(Frames[i].id, Frames[i].MenuHandles.MainMenuItem, separator, true); CLUIFramesModifyMainMenuItems(Frames[i].id, 0); CallService(MS_CLIST_FRAMEMENUNOTIFY, (WPARAM)Frames[i].id, (LPARAM)Frames[i].MenuHandles.MainMenuItem); separator++; @@ -1365,20 +1368,20 @@ static int CLUIFramesLoadMainMenu() mi.flags = 0; mi.position = separator++; mi.hParentMenu = cont.MainMenuItem; - mi.pszName = LPGEN("Show all frames"); + mi.name.a = LPGEN("Show all frames"); mi.pszService = MS_CLIST_FRAMES_SHOWALLFRAMES; Menu_AddMainMenuItem(&mi); // create "show all titlebars" menu mi.icolibItem = Skin_GetIconHandle(SKINICON_OTHER_HELP); mi.position = separator++; - mi.pszName = LPGEN("Show all title bars"); + mi.name.a = LPGEN("Show all title bars"); mi.pszService = MS_CLIST_FRAMES_SHOWALLFRAMESTB; Menu_AddMainMenuItem(&mi); // create "hide all titlebars" menu mi.position = separator++; - mi.pszName = LPGEN("Hide all title bars"); + mi.name.a = LPGEN("Hide all title bars"); mi.pszService = MS_CLIST_FRAMES_HIDEALLFRAMESTB; Menu_AddMainMenuItem(&mi); return 0; @@ -2938,7 +2941,7 @@ static int CLUIFrameOnModulesLoad(WPARAM, LPARAM) hThreadMFUpdate = mir_forkthread(MF_UpdateThread, NULL); SetThreadPriority(hThreadMFUpdate, THREAD_PRIORITY_IDLE); CLUIFramesLoadMainMenu(); - CLUIFramesCreateMenuForFrame(-1, NULL, 000010000, Menu_AddContextFrameMenuItem); + CLUIFramesCreateMenuForFrame(-1, NULL, 000010000, false); return 0; } diff --git a/plugins/Clist_nicer/src/CLUIFrames/cluiframes.h b/plugins/Clist_nicer/src/CLUIFrames/cluiframes.h index 86aba956b1..4fef8cec0f 100644 --- a/plugins/Clist_nicer/src/CLUIFrames/cluiframes.h +++ b/plugins/Clist_nicer/src/CLUIFrames/cluiframes.h @@ -69,6 +69,7 @@ struct FrameTitleBar LPTSTR tbname; LPTSTR tooltip; + HMENU hmenu; HICON hicon; diff --git a/plugins/Clist_nicer/src/CLUIFrames/groupmenu.cpp b/plugins/Clist_nicer/src/CLUIFrames/groupmenu.cpp index 077d832549..61911d6617 100644 --- a/plugins/Clist_nicer/src/CLUIFrames/groupmenu.cpp +++ b/plugins/Clist_nicer/src/CLUIFrames/groupmenu.cpp @@ -86,7 +86,7 @@ static INT_PTR AddGroupMenuItem(WPARAM wParam, LPARAM lParam) HGENMENU hNewItem = Menu_AddItem(hGroupMenuObject, &tmi); char buf[1024]; - mir_snprintf(buf, "%s/%s", mi->pszService, mi->pszName); + mir_snprintf(buf, "%s/%s", mi->pszService, mi->name.a); Menu_ConfigureItem(hNewItem, MCI_OPT_UNIQUENAME, buf); return (INT_PTR)hNewItem; } @@ -236,78 +236,78 @@ void InitGroupMenus(void) mi.position = 1900000; mi.pszService = "CloseAction"; mi.icolibItem = Skin_GetIconHandle(SKINICON_OTHER_EXIT); - mi.pszName = LPGEN("E&xit"); + mi.name.a = LPGEN("E&xit"); AddGroupMenuItem(0, (LPARAM)&mi); mi.position = 500; mi.pszService = MS_CLIST_SHOWHIDE; mi.icolibItem = Skin_GetIconHandle(SKINICON_OTHER_SHOWHIDE); - mi.pszName = LPGEN("&Hide/show"); + mi.name.a = LPGEN("&Hide/show"); hHideShowMainMenuItem = (HGENMENU)AddGroupMenuItem(0, (LPARAM)&mi); mi.position = 200000; mi.icolibItem = Skin_GetIconHandle(SKINICON_OTHER_FINDUSER); mi.pszService = "FindAdd/FindAddCommand"; - mi.pszName = LPGEN("&Find/add contacts..."); + mi.name.a = LPGEN("&Find/add contacts..."); AddGroupMenuItem(0, (LPARAM)&mi); mi.position = 300000; mi.pszService = ""; mi.icolibItem = Skin_GetIconHandle(SKINICON_OTHER_MAINMENU); - mi.pszName = LPGEN("&Main menu"); + mi.name.a = LPGEN("&Main menu"); hGroupMainMenuItemProxy = (HGENMENU)AddGroupMenuItem(0, (LPARAM)&mi); mi.position = 300100; mi.pszService = ""; mi.icolibItem = Skin_GetIconHandle(SKINICON_OTHER_STATUS); - mi.pszName = LPGEN("&Status"); + mi.name.a = LPGEN("&Status"); hGroupStatusMenuItemProxy = (HGENMENU)AddGroupMenuItem(0, (LPARAM)&mi); mi.position = 390100; mi.icolibItem = iconItem[1].hIcolib; - mi.pszName = LPGEN("Appearance"); + mi.name.a = LPGEN("Appearance"); hAppearanceMenuItemProxy = (HGENMENU)AddGroupMenuItem(0, (LPARAM)&mi); mi.position = 400000; mi.icolibItem = Skin_GetIconHandle(SKINICON_OTHER_OPTIONS); mi.pszService = "Options/OptionsCommand"; - mi.pszName = LPGEN("&Options..."); + mi.name.a = LPGEN("&Options..."); AddGroupMenuItem(0, (LPARAM)&mi); mi.position = 500000; mi.icolibItem = Skin_GetIconHandle(SKINICON_OTHER_MIRANDA); mi.pszService = "CLN/About"; - mi.pszName = LPGEN("&About the contact list..."); + mi.name.a = LPGEN("&About the contact list..."); AddGroupMenuItem(0, (LPARAM)&mi); mi.flags = 0; mi.position = 100000; mi.icolibItem = iconItem[0].hIcolib; mi.pszService = "CLISTMENUSSubGroup/GroupMenuExecProxy"; - mi.pszName = LPGEN("&New group"); + mi.name.a = LPGEN("&New group"); hNewGroupMenuItem = (HGENMENU)AddGroupMenuItem((WPARAM)&gmp, (LPARAM)&mi); mi.position = 100001; - mi.hIcon = NULL; + mi.icolibItem = NULL; mi.icolibItem = NULL; mi.pszService = MS_CLIST_SETHIDEOFFLINE; - mi.pszName = LPGEN("&Hide offline users"); + mi.name.a = LPGEN("&Hide offline users"); gmp.lParam = 0; gmp.wParam = -1; hHideOfflineUsersMenuItem = (HGENMENU)AddGroupMenuItem((WPARAM)&gmp, (LPARAM)&mi); mi.position = 100002; mi.pszService = "CLISTMENUSGroup/HideOfflineRootHelper"; - mi.pszName = LPGEN("Hide &offline users out here"); + mi.name.a = LPGEN("Hide &offline users out here"); hHideOfflineUsersOutHereMenuItem = (HGENMENU)AddGroupMenuItem(0, (LPARAM)&mi); mi.position = 100003; mi.pszService = "CLISTMENUSGroup/HideGroupsHelper"; - mi.pszName = LPGEN("Hide &empty groups"); + mi.name.a = LPGEN("Hide &empty groups"); hHideEmptyGroupsMenuItem = (HGENMENU)AddGroupMenuItem(0, (LPARAM)&mi); mi.position = 100004; mi.pszService = "CLISTMENUSGroup/UseGroupsHelper"; - mi.pszName = LPGEN("Disable &groups"); + mi.name.a = LPGEN("Disable &groups"); hDisableGroupsMenuItem = (HGENMENU)AddGroupMenuItem(0, (LPARAM)&mi); } @@ -369,7 +369,7 @@ static INT_PTR AddSubGroupMenuItem(WPARAM wParam, LPARAM lParam) HGENMENU hNewItem = Menu_AddItem(hSubGroupMenuObject, &tmi); char buf[1024]; - mir_snprintf(buf, "%s/%s", mi->pszService, mi->pszName); + mir_snprintf(buf, "%s/%s", mi->pszService, mi->name.a); Menu_ConfigureItem(hNewItem, MCI_OPT_UNIQUENAME, buf); return (INT_PTR)hNewItem; } @@ -464,16 +464,16 @@ void InitSubGroupMenus(void) mi.position = 1000; mi.icolibItem = iconItem[0].hIcolib; mi.pszService = "CLISTMENUSSubGroup/GroupMenuExecProxy"; - mi.pszName = LPGEN("&New subgroup"); + mi.name.a = LPGEN("&New subgroup"); gmp.lParam = 0; gmp.wParam = POPUP_NEWSUBGROUP; hNewSubGroupMenuItem = (HGENMENU)AddSubGroupMenuItem((WPARAM)&gmp, (LPARAM)&mi); mi.position = 1001; - mi.hIcon = NULL; + mi.icolibItem = NULL; mi.icolibItem = NULL; mi.pszService = "CLISTMENUSSubGroup/GroupMenuExecProxy"; - mi.pszName = LPGEN("&Hide offline users in here"); + mi.name.a = LPGEN("&Hide offline users in here"); gmp.lParam = 0; gmp.wParam = POPUP_GROUPHIDEOFFLINE; hHideOfflineUsersHereMenuItem = (HGENMENU)AddSubGroupMenuItem((WPARAM)&gmp, (LPARAM)&mi); @@ -482,7 +482,7 @@ void InitSubGroupMenus(void) mi.position = 900001; mi.icolibItem = Skin_GetIconHandle(SKINICON_OTHER_RENAME); mi.pszService = "CLISTMENUSSubGroup/GroupMenuExecProxy"; - mi.pszName = LPGEN("&Rename group"); + mi.name.a = LPGEN("&Rename group"); gmp.lParam = 0; gmp.wParam = POPUP_RENAMEGROUP; AddSubGroupMenuItem((WPARAM)&gmp, (LPARAM)&mi); @@ -490,7 +490,7 @@ void InitSubGroupMenus(void) mi.position = 900002; mi.icolibItem = Skin_GetIconHandle(SKINICON_OTHER_DELETE); mi.pszService = "CLISTMENUSSubGroup/GroupMenuExecProxy"; - mi.pszName = LPGEN("&Delete group"); + mi.name.a = LPGEN("&Delete group"); gmp.lParam = 0; gmp.wParam = POPUP_DELETEGROUP; AddSubGroupMenuItem((WPARAM)&gmp, (LPARAM)&mi); -- cgit v1.2.3