summaryrefslogtreecommitdiff
path: root/plugins/WhenWasIt/src/icons.cpp
blob: 9cb6c49b3e9be35af73e3df81832ab12406490b4 (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 "stdafx.h"

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

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

HANDLE hWWIExtraIcons = (HANDLE)-1;

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

int AddIcons()
{
	wchar_t 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, Translate("%d days to birthday"), i);
		hDTB[i] = AddIcon(name, description, tszPath, IDI_DTB0 + i);
	}
	mir_snprintf(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]);
}