summaryrefslogtreecommitdiff
path: root/plugins/WhenWasIt/src/icons.cpp
blob: 98760e03c60cb842e49237d6ea190871880ef883 (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
/*
WhenWasIt (birthday reminder) plugin for Miranda IM

Copyright © 2006 Cristian Libotean

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
*/

#include "commonheaders.h"

HANDLE hCheckMenu, hListMenu, hAddBirthdayContact, hRefreshUserDetails;
HANDLE hImportBirthdays, hExportBirthdays;

const int cDTB = 10;
HANDLE hDTB[cDTB] = { NULL };
HANDLE hDTBMore = NULL;

HANDLE hWWIExtraIcons = (HANDLE)-1;

static HANDLE AddIcon(char *name, char *description, TCHAR *tszPath, int iDefaultIdx)
{
	SKINICONDESC sid = { 0 };
	sid.flags = SIDF_PATH_TCHAR;
	sid.section.a = LPGEN("WhenWasIt");
	sid.description.a = description;
	sid.pszName = name;
	sid.defaultFile.t = tszPath;
	sid.iDefaultIndex = -iDefaultIdx;
	return IcoLib_AddIcon(&sid);
}

int AddIcons()
{
	TCHAR tszPath[MAX_PATH];
	GetModuleFileName(hInstance, tszPath, _countof(tszPath));

	hCheckMenu = AddIcon("MenuCheck", LPGEN("Check birthdays menu item"), tszPath, IDI_CHECK);
	hListMenu = AddIcon("MenuList", LPGEN("List birthdays menu item"), tszPath, IDI_LIST);
	hAddBirthdayContact = AddIcon("AddBirthday", LPGEN("Add/change birthday"), tszPath, IDI_ADD);
	hRefreshUserDetails = AddIcon("RefreshUserDetails", LPGEN("Refresh user details"), tszPath, IDI_REFRESH_USERDETAILS);

	hImportBirthdays = AddIcon("ImportBirthdays", LPGEN("Import birthdays"), tszPath, IDI_IMPORT_BIRTHDAYS);
	hExportBirthdays = AddIcon("ExportBirthdays", LPGEN("Export birthdays"), tszPath, IDI_EXPORT_BIRTHDAYS);

	char name[1024];
	char description[1024];
	hDTB[0] = AddIcon("DTB0", LPGEN("Birthday today"), tszPath, IDI_DTB0);
	hDTB[1] = AddIcon("DTB1", LPGEN("1 day to birthday"), tszPath, IDI_DTB1);
	for (int i = 2; i < cDTB; i++) {
		mir_snprintf(name, "DTB%d", i);
		mir_snprintf(description, _countof(description), Translate("%d days to birthday"), i);
		hDTB[i] = AddIcon(name, description, tszPath, IDI_DTB0 + i);
	}
	mir_snprintf(description, _countof(description), Translate("More than %d days to birthday"), cDTB - 1);
	hDTBMore = AddIcon("DTBMore", description, tszPath, IDI_DTBMORE);

	hWWIExtraIcons = ExtraIcon_RegisterIcolib("WhenWasIt", LPGEN("WhenWasIt birthday reminder"), "MenuCheck");
	return 0;
}

HANDLE GetDTBIconHandle(int dtb)
{
	return ((dtb >= cDTB || dtb < 0) ? hDTBMore : hDTB[dtb]);
}