summaryrefslogtreecommitdiff
path: root/plugins/MetaContacts/icons.cpp
diff options
context:
space:
mode:
authorKirill Volinsky <mataes2007@gmail.com>2012-06-23 14:21:20 +0000
committerKirill Volinsky <mataes2007@gmail.com>2012-06-23 14:21:20 +0000
commitc507a151a8011784ba37228d33610fa0406736eb (patch)
tree073fb5e27d739c6ebd0a820977eaf1da254c67e5 /plugins/MetaContacts/icons.cpp
parent4a9e49eaf838d1b87a2c6696945f00f35c988397 (diff)
MetaContacts:
renamed to .cpp git-svn-id: http://svn.miranda-ng.org/main/trunk@557 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/MetaContacts/icons.cpp')
-rw-r--r--plugins/MetaContacts/icons.cpp101
1 files changed, 101 insertions, 0 deletions
diff --git a/plugins/MetaContacts/icons.cpp b/plugins/MetaContacts/icons.cpp
new file mode 100644
index 0000000000..829636be1f
--- /dev/null
+++ b/plugins/MetaContacts/icons.cpp
@@ -0,0 +1,101 @@
+#include "metacontacts.h"
+
+HANDLE hIcoLibIconsChanged = NULL;
+
+
+typedef struct {
+ char* szDescr;
+ char* szName;
+ int defIconID;
+} IconStruct;
+
+static IconStruct iconList[] = {
+ { "Toggle Off", "mc_off", IDI_MCMENUOFF },
+ { "Toggle On", "mc_on", IDI_MCMENU },
+ { "Convert to MetaContact", "mc_convert", IDI_MCCONVERT },
+ { "Add to Existing", "mc_add", IDI_MCADD },
+ { "Edit", "mc_edit", IDI_MCEDIT },
+ { "Set to Default", "mc_default", IDI_MCSETDEFAULT },
+ { "Remove", "mc_remove", IDI_MCREMOVE },
+};
+
+
+HICON LoadIconEx(IconIndex i) {
+ HICON hIcon;
+
+ if (hIcoLibIconsChanged)
+ hIcon = (HICON)CallService(MS_SKIN2_GETICON, 0, (LPARAM)iconList[(int)i].szName);
+ else
+ hIcon = (HICON)LoadImage(hInstance, MAKEINTRESOURCE(iconList[(int)i].defIconID), IMAGE_ICON, 0, 0, 0);
+
+ return hIcon;
+}
+
+
+void ReleaseIconEx(HICON hIcon) {
+ if (hIcoLibIconsChanged)
+ CallService(MS_SKIN2_RELEASEICON, (WPARAM)hIcon, 0);
+ else
+ DestroyIcon(hIcon);
+}
+
+int ReloadIcons(WPARAM wParam, LPARAM lParam) {
+ // fix menu icons
+ CLISTMENUITEM menu = {0};
+
+ menu.cbSize = sizeof(menu);
+ menu.flags = CMIM_ICON;
+
+ menu.hIcon = LoadIconEx(Meta_IsEnabled() ? I_MENUOFF : I_MENU);
+ CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hMenuOnOff, (LPARAM)&menu);
+ ReleaseIconEx(menu.hIcon);
+
+ menu.hIcon = LoadIconEx(I_CONVERT);
+ CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hMenuConvert, (LPARAM)&menu);
+ ReleaseIconEx(menu.hIcon);
+
+ menu.hIcon = LoadIconEx(I_ADD);
+ CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hMenuAdd, (LPARAM)&menu);
+ ReleaseIconEx(menu.hIcon);
+
+ menu.hIcon = LoadIconEx(I_EDIT);
+ CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hMenuEdit, (LPARAM)&menu);
+ ReleaseIconEx(menu.hIcon);
+
+ menu.hIcon = LoadIconEx(I_SETDEFAULT);
+ CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hMenuDefault, (LPARAM)&menu);
+ ReleaseIconEx(menu.hIcon);
+
+ menu.hIcon = LoadIconEx(I_REMOVE);
+ CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hMenuDelete, (LPARAM)&menu);
+ ReleaseIconEx(menu.hIcon);
+
+ return 0;
+}
+
+void InitIcons(void) {
+ SKINICONDESC sid = {0};
+ char path[MAX_PATH];
+ int i;
+
+ sid.cbSize = sizeof(SKINICONDESC);
+ sid.pszSection = META_PROTO;
+ sid.pszDefaultFile = path;
+ GetModuleFileName(hInstance, path, sizeof(path));
+
+ for (i = 0; i < sizeof(iconList) / sizeof(IconStruct); ++i)
+ {
+ sid.pszDescription = Translate(iconList[i].szDescr);
+ sid.pszName = iconList[i].szName;
+ sid.iDefaultIndex = -iconList[i].defIconID;
+ Skin_AddIcon(&sid);
+ }
+
+ hIcoLibIconsChanged = HookEvent(ME_SKIN2_ICONSCHANGED, ReloadIcons);
+
+ ReloadIcons(0, 0);
+}
+
+void DeinitIcons(void) {
+ if (hIcoLibIconsChanged) UnhookEvent(hIcoLibIconsChanged);
+}