From e964f60be38a8a92cba9fc93c2247a052e40d21b Mon Sep 17 00:00:00 2001 From: slotwin Date: Sun, 8 Jun 2014 15:25:36 +0000 Subject: Clist_nicer: add icons to menu items use IcoLib where possible remove unused resources and code proper capitalization git-svn-id: http://svn.miranda-ng.org/main/trunk@9423 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/Clist_nicer/src/CLUIFrames/cluiframes.cpp | 2 +- plugins/Clist_nicer/src/CLUIFrames/groupmenu.cpp | 48 +++++++++++------------ plugins/Clist_nicer/src/Include/resource.h | 5 +-- plugins/Clist_nicer/src/clc.cpp | 2 +- plugins/Clist_nicer/src/clistmenus.cpp | 48 ++++++++++------------- 5 files changed, 47 insertions(+), 58 deletions(-) (limited to 'plugins/Clist_nicer/src') diff --git a/plugins/Clist_nicer/src/CLUIFrames/cluiframes.cpp b/plugins/Clist_nicer/src/CLUIFrames/cluiframes.cpp index 71224107c0..0a3bf1a58b 100644 --- a/plugins/Clist_nicer/src/CLUIFrames/cluiframes.cpp +++ b/plugins/Clist_nicer/src/CLUIFrames/cluiframes.cpp @@ -596,7 +596,7 @@ HMENU CLUIFramesCreateMenuForFrame(int frameid, int root, int popuppos, HGENMENU return NULL; CLISTMENUITEM mi = { sizeof(mi) }; - mi.icolibItem = LoadSkinnedIconHandle(SKINICON_OTHER_MIRANDA); //LoadIcon(g_hInst,MAKEINTRESOURCE(IDI_MIRANDA)); + mi.icolibItem = LoadSkinnedIconHandle(SKINICON_OTHER_MIRANDA); mi.pszPopupName = (char *)root; mi.popupPosition = frameid; mi.position = popuppos++; diff --git a/plugins/Clist_nicer/src/CLUIFrames/groupmenu.cpp b/plugins/Clist_nicer/src/CLUIFrames/groupmenu.cpp index 4fd3471746..94ac7d1bab 100644 --- a/plugins/Clist_nicer/src/CLUIFrames/groupmenu.cpp +++ b/plugins/Clist_nicer/src/CLUIFrames/groupmenu.cpp @@ -43,11 +43,6 @@ HGENMENU hDisableGroupsMenuItem; HGENMENU hNewGroupMenuItem; HGENMENU hNewSubGroupMenuItem; -int NewGroupIconidx; - -extern HIMAGELIST hCListImages; -extern HICON LoadIconFromExternalFile(char *filename, int i, boolean UseLibrary, boolean registerit, char *IconName, char *SectName, char *Description, int internalidx); - void InitSubGroupMenus(void); //Groupmenu exec param(ownerdata) @@ -235,14 +230,14 @@ static int OnBuildGroupMenu(WPARAM wParam, LPARAM lParam) return 0; } -int static OnIconLibIconChanged(WPARAM wParam, LPARAM lParam) +IconItemT iconItem[] = { + { LPGENT("New group"), "new_group", IDI_ADDGROUP }, + { LPGENT("Contact list"), "clist", IDI_CLIST } +}; + +void InitIconLibMenuIcons(void) { - CLISTMENUITEM clmi = { sizeof(clmi) }; - clmi.flags = CMIM_ICON; - clmi.hIcon = ImageList_GetIcon(hCListImages, NewGroupIconidx, 0); - Menu_ModifyItem(hNewSubGroupMenuItem, &clmi); - Menu_ModifyItem(hNewGroupMenuItem, &clmi); - return 0; + Icon_RegisterT(g_hInst, LPGENT("Contact list"), iconItem, SIZEOF(iconItem)); } void InitGroupMenus(void) @@ -268,12 +263,13 @@ void InitGroupMenus(void) MO_SetMenuObjectParam(hGroupMenuObject, OPT_MENUOBJECT_SET_FREE_SERVICE, "CLISTMENUSGroup/FreeOwnerDataGroupMenu"); MO_SetMenuObjectParam(hGroupMenuObject, OPT_MENUOBJECT_SET_ONADD_SERVICE, "CLISTMENUSGroup/GroupMenuonAddService"); { - //add exit command to menu + //add exit command to menu GroupMenuParam gmp; CLISTMENUITEM mi = { sizeof(mi) }; mi.position = 1900000; mi.pszService = "CloseAction"; + mi.icolibItem = LoadSkinnedIconHandle(SKINICON_OTHER_EXIT); mi.pszName = LPGEN("E&xit"); AddGroupMenuItem(0, (LPARAM)&mi); @@ -281,21 +277,23 @@ void InitGroupMenus(void) mi.cbSize = sizeof(mi); mi.position = 500; mi.pszService = MS_CLIST_SHOWHIDE; - mi.pszName = LPGEN("&Hide/Show"); + mi.icolibItem = LoadSkinnedIconHandle(SKINICON_OTHER_SHOWHIDE); + mi.pszName = LPGEN("&Hide/show"); hHideShowMainMenuItem = (HGENMENU)AddGroupMenuItem(0, (LPARAM)&mi); memset(&mi, 0, sizeof(mi)); mi.cbSize = sizeof(mi); mi.position = 200000; - mi.icolibItem = LoadSkinnedIconHandle(SKINICON_OTHER_FINDUSER); //LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_FINDUSER)); + mi.icolibItem = LoadSkinnedIconHandle(SKINICON_OTHER_FINDUSER); mi.pszService = "FindAdd/FindAddCommand"; - mi.pszName = LPGEN("&Find/Add contacts..."); + mi.pszName = LPGEN("&Find/add contacts..."); AddGroupMenuItem(0, (LPARAM)&mi); memset(&mi, 0, sizeof(mi)); mi.cbSize = sizeof(mi); mi.position = 300000; mi.pszService = ""; + mi.icolibItem = LoadSkinnedIconHandle(SKINICON_OTHER_MAINMENU); mi.pszName = LPGEN("&Main menu"); hGroupMainMenuItemProxy = (HGENMENU)AddGroupMenuItem(0, (LPARAM)&mi); @@ -303,6 +301,7 @@ void InitGroupMenus(void) mi.cbSize = sizeof(mi); mi.position = 300100; mi.pszService = ""; + mi.icolibItem = LoadSkinnedIconHandle(SKINICON_OTHER_STATUS); mi.pszName = LPGEN("&Status"); hGroupStatusMenuItemProxy = (HGENMENU)AddGroupMenuItem(0, (LPARAM)&mi); @@ -310,31 +309,30 @@ void InitGroupMenus(void) mi.cbSize = sizeof(mi); mi.position = 390100; mi.pszService = ""; + mi.icolibItem = iconItem[1].hIcolib; mi.pszName = LPGEN("Appearance"); hAppearanceMenuItemProxy = (HGENMENU)AddGroupMenuItem(0, (LPARAM)&mi); memset(&mi, 0, sizeof(mi)); mi.cbSize = sizeof(mi); mi.position = 400000; - mi.icolibItem = LoadSkinnedIconHandle(SKINICON_OTHER_OPTIONS); //LoadIcon(GetModuleHandle(NULL),MAKEINTRESOURCE(IDI_OPTIONS)); + mi.icolibItem = LoadSkinnedIconHandle(SKINICON_OTHER_OPTIONS); mi.pszService = "Options/OptionsCommand"; mi.pszName = LPGEN("&Options..."); - AddGroupMenuItem(0, (LPARAM)&mi); memset(&mi, 0, sizeof(mi)); mi.cbSize = sizeof(mi); mi.position = 500000; - mi.icolibItem = LoadSkinnedIconHandle(SKINICON_OTHER_MIRANDA); //LoadIcon(GetModuleHandle(NULL),MAKEINTRESOURCE(IDI_MIRANDA)); + mi.icolibItem = LoadSkinnedIconHandle(SKINICON_OTHER_MIRANDA); mi.pszService = "CLN/About"; mi.pszName = LPGEN("&About the contact list..."); - AddGroupMenuItem(0, (LPARAM)&mi); memset(&mi, 0, sizeof(mi)); mi.cbSize = sizeof(mi); mi.position = 100000; - mi.hIcon = ImageList_GetIcon(hCListImages, NewGroupIconidx, 0); + mi.icolibItem = iconItem[0].hIcolib; mi.pszService = "CLISTMENUSSubGroup/GroupMenuExecProxy"; mi.pszName = LPGEN("&New group"); gmp.lParam = 0; @@ -509,7 +507,7 @@ INT_PTR SubGroupMenuExecService(WPARAM wParam, LPARAM lParam) { return 1; } -INT_PTR FreeOwnerDataSubGroupMenu (WPARAM wParam, LPARAM lParam) +INT_PTR FreeOwnerDataSubGroupMenu(WPARAM wParam, LPARAM lParam) { lpSubGroupMenuExecParam mmep = (lpSubGroupMenuExecParam)lParam; if (mmep != NULL) { @@ -555,7 +553,7 @@ void InitSubGroupMenus(void) CLISTMENUITEM mi = { sizeof(mi) }; mi.position = 1000; - mi.hIcon = ImageList_GetIcon(hCListImages, NewGroupIconidx, 0); + mi.icolibItem = iconItem[0].hIcolib; mi.pszService = "CLISTMENUSSubGroup/GroupMenuExecProxy"; mi.pszName = LPGEN("&New subgroup"); gmp.lParam = 0; @@ -575,7 +573,7 @@ void InitSubGroupMenus(void) memset(&mi, 0, sizeof(mi)); mi.cbSize = sizeof(mi); mi.position = 900001; - mi.icolibItem = LoadSkinnedIconHandle(SKINICON_OTHER_RENAME); //LoadIcon(GetModuleHandle(NULL),MAKEINTRESOURCE(IDI_RENAME)); + mi.icolibItem = LoadSkinnedIconHandle(SKINICON_OTHER_RENAME); mi.pszService = "CLISTMENUSSubGroup/GroupMenuExecProxy"; mi.pszName = LPGEN("&Rename group"); gmp.lParam = 0; @@ -585,7 +583,7 @@ void InitSubGroupMenus(void) memset(&mi, 0, sizeof(mi)); mi.cbSize = sizeof(mi); mi.position = 900002; - mi.icolibItem = LoadSkinnedIconHandle(SKINICON_OTHER_DELETE); //LoadIcon(GetModuleHandle(NULL),MAKEINTRESOURCE(IDI_DELETE)); + mi.icolibItem = LoadSkinnedIconHandle(SKINICON_OTHER_DELETE); mi.pszService = "CLISTMENUSSubGroup/GroupMenuExecProxy"; mi.pszName = LPGEN("&Delete group"); gmp.lParam = 0; diff --git a/plugins/Clist_nicer/src/Include/resource.h b/plugins/Clist_nicer/src/Include/resource.h index 33ebca1ec5..abb763ae2e 100644 --- a/plugins/Clist_nicer/src/Include/resource.h +++ b/plugins/Clist_nicer/src/Include/resource.h @@ -10,10 +10,9 @@ #define IDD_OPTIONSDIALOG 101 #define IDD_CLNABOUT 102 #define IDD_OPT_CLIST 126 -#define IDI_NOTICK 143 -#define IDI_TICK 146 +#define IDI_ADDGROUP 143 +#define IDI_CLIST 146 #define IDI_OPTIONS 163 -#define IDI_RENAME 173 #define IDI_DELETE 175 #define IDI_CLVM_OPTIONS 176 #define IDI_CLVM_SELECT 177 diff --git a/plugins/Clist_nicer/src/clc.cpp b/plugins/Clist_nicer/src/clc.cpp index 5af0e66a5d..a083760a2f 100644 --- a/plugins/Clist_nicer/src/clc.cpp +++ b/plugins/Clist_nicer/src/clc.cpp @@ -211,7 +211,7 @@ int LoadCLCModule(void) g_cxsmIcon = GetSystemMetrics(SM_CXSMICON); g_cysmIcon = GetSystemMetrics(SM_CYSMICON); - hCListImages = (HIMAGELIST) CallService(MS_CLIST_GETICONSIMAGELIST, 0, 0); + hCListImages = (HIMAGELIST)CallService(MS_CLIST_GETICONSIMAGELIST, 0, 0); HookEvent(ME_DB_CONTACT_SETTINGCHANGED, ClcSettingChanged); HookEvent(ME_DB_EVENT_ADDED, ClcEventAdded); diff --git a/plugins/Clist_nicer/src/clistmenus.cpp b/plugins/Clist_nicer/src/clistmenus.cpp index 74498cab6a..ef24d740b7 100644 --- a/plugins/Clist_nicer/src/clistmenus.cpp +++ b/plugins/Clist_nicer/src/clistmenus.cpp @@ -31,6 +31,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. static HMENU hMainMenu, hMainStatusMenu; +void InitIconLibMenuIcons(); +extern IconItemT iconItem[]; + void DestroyTrayMenu(HMENU hMenu) { int i, cnt; @@ -70,7 +73,7 @@ static INT_PTR CALLBACK IgnoreDialogProc(HWND hWnd, UINT msg, WPARAM wParam, LPA { MCONTACT hContact = (MCONTACT)GetWindowLongPtr(hWnd, GWLP_USERDATA); - switch(msg) { + switch (msg) { case WM_INITDIALOG: { DWORD dwMask; @@ -87,14 +90,14 @@ static INT_PTR CALLBACK IgnoreDialogProc(HWND hWnd, UINT msg, WPARAM wParam, LPA hwndAdd = GetDlgItem(hWnd, IDC_IGN_ADDPERMANENTLY); // CreateWindowEx(0, _T("CLCButtonClass"), _T("FOO"), WS_VISIBLE | BS_PUSHBUTTON | WS_CHILD | WS_TABSTOP, 200, 276, 106, 24, hWnd, (HMENU)IDC_IGN_ADDPERMANENTLY, g_hInst, NULL); CustomizeButton(hwndAdd, false, true, false); - SendMessage(hwndAdd, BM_SETIMAGE, IMAGE_ICON, (LPARAM)LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(210), IMAGE_ICON, 16, 16, LR_SHARED)); + SendMessage(hwndAdd, BM_SETIMAGE, IMAGE_ICON, (LPARAM)LoadSkinnedIcon(SKINICON_OTHER_ADDCONTACT)); SetWindowText(hwndAdd, TranslateT("Add permanently")); EnableWindow(hwndAdd, cfg::getByte(hContact, "CList", "NotOnList", 0)); hwndAdd = GetDlgItem(hWnd, IDC_DSP_LOADDEFAULT); // CreateWindowEx(0, _T("CLCButtonClass"), _T("FOO"), WS_VISIBLE | BS_PUSHBUTTON | WS_CHILD | WS_TABSTOP, 200, 276, 106, 24, hWnd, (HMENU)IDC_IGN_ADDPERMANENTLY, g_hInst, NULL); CustomizeButton(hwndAdd, false, true, false); - SendMessage(hwndAdd, BM_SETIMAGE, IMAGE_ICON, (LPARAM)LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_DELETE), IMAGE_ICON, 16, 16, LR_SHARED)); + SendMessage(hwndAdd, BM_SETIMAGE, IMAGE_ICON, (LPARAM)LoadSkinnedIcon(SKINICON_OTHER_DELETE)); SetWindowText(hwndAdd, TranslateT("Revert to default")); EnableWindow(hwndAdd, TRUE); @@ -375,34 +378,23 @@ static INT_PTR SetContactIgnore(WPARAM wParam, LPARAM lParam) return 0; } -/* - * service function: Set a contacts floating status. - * (clist_nicer+ specific service) - * - * Servicename = CList/SetContactFloating - * - * a floating contact appears as a small independent top level window anywhere on - * the desktop. -*/ - int InitCustomMenus(void) { - CreateServiceFunction("CloseAction",CloseAction); + InitIconLibMenuIcons(); + + CreateServiceFunction("CloseAction", CloseAction); CreateServiceFunction("CList/SetContactIgnore", SetContactIgnore); - { - //FYR: Visibility and ignore item moved back to clist_nicer from core - HANDLE hIgnoreItem = 0; // FYR: moved from global it is never used globally - if ( !hIgnoreItem ) { - CLISTMENUITEM mi = { sizeof(mi) }; - mi.position = 200000; - mi.pszPopupName = ( char* )-1; - mi.pszService = "CList/SetContactIgnore"; - mi.pszName = LPGEN("&Contact list settings..."); - hIgnoreItem = Menu_AddContactMenuItem(&mi); - } - } - hMainStatusMenu = (HMENU)CallService(MS_CLIST_MENUGETSTATUS,0,0); - hMainMenu = (HMENU)CallService(MS_CLIST_MENUGETMAIN,0,0); + + CLISTMENUITEM mi = { sizeof(mi) }; + mi.position = 200000; + mi.pszPopupName = (char *)-1; + mi.pszService = "CList/SetContactIgnore"; + mi.icolibItem = iconItem[1].hIcolib; + mi.pszName = LPGEN("&Contact list settings..."); + Menu_AddContactMenuItem(&mi); + + hMainStatusMenu = (HMENU)CallService(MS_CLIST_MENUGETSTATUS, 0, 0); + hMainMenu = (HMENU)CallService(MS_CLIST_MENUGETMAIN, 0, 0); return 0; } -- cgit v1.2.3