summaryrefslogtreecommitdiff
path: root/plugins/MetaContacts/src/icons.cpp
blob: 694c28d7bd01a459bf90d499392b0319986669c9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#include "metacontacts.h"

typedef struct {
	TCHAR* szDescr;
	char* szName;
	int   defIconID;
} IconStruct;

static IconStruct iconList[] = {
	{ LPGENT("Toggle Off"),					"mc_off",		IDI_MCMENUOFF     },
	{ LPGENT("Toggle On"),					"mc_on",		IDI_MCMENU        },
	{ LPGENT("Convert to MetaContact"),		"mc_convert",	IDI_MCCONVERT     },
	{ LPGENT("Add to Existing"),			"mc_add",		IDI_MCADD         },
	{ LPGENT("Edit"),						"mc_edit",		IDI_MCEDIT        },
	{ LPGENT("Set to Default"),				"mc_default",	IDI_MCSETDEFAULT  },
	{ LPGENT("Remove"),						"mc_remove",	IDI_MCREMOVE      },
};


HICON LoadIconEx(IconIndex i)
{
	return Skin_GetIcon(iconList[i].szName);
}

void ReleaseIconEx(HICON hIcon)
{
	Skin_ReleaseIcon(hIcon);
}

int ReloadIcons(WPARAM wParam, LPARAM lParam)
{
	// fix menu icons
	CLISTMENUITEM mi = { sizeof(mi) };
	mi.flags = CMIM_ICON;

	mi.hIcon = LoadIconEx(Meta_IsEnabled() ? I_MENUOFF : I_MENU);
	CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hMenuOnOff, (LPARAM)&mi);
	ReleaseIconEx(mi.hIcon);

	mi.hIcon = LoadIconEx(I_CONVERT);
	CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hMenuConvert, (LPARAM)&mi);
	ReleaseIconEx(mi.hIcon);
	
	mi.hIcon = LoadIconEx(I_ADD);
	CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hMenuAdd, (LPARAM)&mi);
	ReleaseIconEx(mi.hIcon);
	
	mi.hIcon = LoadIconEx(I_EDIT);
	CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hMenuEdit, (LPARAM)&mi);
	ReleaseIconEx(mi.hIcon);

	mi.hIcon = LoadIconEx(I_SETDEFAULT);
	CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hMenuDefault, (LPARAM)&mi);
	ReleaseIconEx(mi.hIcon);

	mi.hIcon = LoadIconEx(I_REMOVE);
	CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hMenuDelete, (LPARAM)&mi);
	ReleaseIconEx(mi.hIcon);

	return 0;
}

void InitIcons(void) 
{
	TCHAR path[MAX_PATH];
	GetModuleFileName(hInstance, path, SIZEOF(path));

	SKINICONDESC sid = { sizeof(sid) };
	sid.flags = SIDF_ALL_TCHAR;
	sid.ptszSection = _T(META_PROTO);
	sid.ptszDefaultFile = path;

	for (int i=0; i < SIZEOF(iconList); ++i) {
		sid.ptszDescription = iconList[i].szDescr;
		sid.pszName = iconList[i].szName;
		sid.iDefaultIndex = -iconList[i].defIconID;
		Skin_AddIcon(&sid);
	}

	HookEvent(ME_SKIN2_ICONSCHANGED, ReloadIcons);

	ReloadIcons(0, 0); 
}