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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
|
#include "_globals.h"
#include "iconlib.h"
#include "main.h"
#include "resource.h"
bool IconLib::m_bIcoLibAvailable = false;
HANDLE IconLib::m_hHookSkin2IconsChanged = NULL;
IconLib::IconInfo IconLib::m_IconInfo[] = {
{ IDI_HISTORYSTATS , muA("main_menu") , NULL , I18N(muT("Create statistics (main menu)")) },
{ IDI_HISTORYSTATS , muA("menu_show") , NULL , I18N(muT("Show statistics (main menu)")) },
{ IDI_HISTORYSTATS , muA("menu_config") , NULL , I18N(muT("Configure... (main menu)")) },
{ IDI_HISTORYSTATS , muA("contact_menu") , NULL , I18N(muT("Contact menu")) },
{ IDI_EXCLUDE_NO , muA("exclude_no") , NULL , I18N(muT("Unexcluded contacts")) },
{ IDI_EXCLUDE_YES , muA("exclude_yes") , NULL , I18N(muT("Excluded contacts")) },
{ IDI_TREE_CHECK1 , muA("tree_check1") , I18N(muT("Options tree")), I18N(muT("Checkbox")) },
{ IDI_TREE_CHECK2 , muA("tree_check2") , I18N(muT("Options tree")), I18N(muT("Checkbox (checked)")) },
{ IDI_TREE_CHECK3 , muA("tree_check3") , I18N(muT("Options tree")), I18N(muT("Checkbox (disabled)")) },
{ IDI_TREE_CHECK4 , muA("tree_check4") , I18N(muT("Options tree")), I18N(muT("Checkbox (checked & disabled)")) },
{ IDI_TREE_RADIO1 , muA("tree_radio1") , I18N(muT("Options tree")), I18N(muT("Radio button")) },
{ IDI_TREE_RADIO2 , muA("tree_radio2") , I18N(muT("Options tree")), I18N(muT("Radio button (checked)")) },
{ IDI_TREE_RADIO3 , muA("tree_radio3") , I18N(muT("Options tree")), I18N(muT("Radio button (disabled)")) },
{ IDI_TREE_RADIO4 , muA("tree_radio4") , I18N(muT("Options tree")), I18N(muT("Radio button (checked & disabled)")) },
{ IDI_TREE_EDIT1 , muA("tree_edit1") , I18N(muT("Options tree")), I18N(muT("Edit control")) },
{ IDI_TREE_EDIT2 , muA("tree_edit2") , I18N(muT("Options tree")), I18N(muT("Edit control (disabled)")) },
{ IDI_TREE_COMBO1 , muA("tree_combo1") , I18N(muT("Options tree")), I18N(muT("Combo box")) },
{ IDI_TREE_COMBO2 , muA("tree_combo2") , I18N(muT("Options tree")), I18N(muT("Combo box (disabled)")) },
{ IDI_TREE_FOLDER1 , muA("tree_folder1") , I18N(muT("Options tree")), I18N(muT("Folder")) },
{ IDI_TREE_FOLDER2 , muA("tree_folder2") , I18N(muT("Options tree")), I18N(muT("Folder (disabled)")) },
{ IDI_TREE_BUTTON1 , muA("tree_button1") , I18N(muT("Options tree")), I18N(muT("Button")) },
{ IDI_TREE_BUTTON2 , muA("tree_button2") , I18N(muT("Options tree")), I18N(muT("Button (disabled)")) },
{ IDI_TREE_DATETIME1, muA("tree_datetime1"), I18N(muT("Options tree")), I18N(muT("Date/time picker")) },
{ IDI_TREE_DATETIME2, muA("tree_datetime2"), I18N(muT("Options tree")), I18N(muT("Date/time picker (disabled)")) },
};
ext::string IconLib::m_Section;
ext::a::string IconLib::m_IconName;
IconLib::CallbackSet IconLib::m_Callbacks;
int IconLib::handleCallbacks(WPARAM wParam, LPARAM lParam)
{
citer_each_(CallbackSet, i, m_Callbacks)
{
(*i->first)(i->second);
}
return 0;
}
void IconLib::init()
{
array_each_(i, m_IconInfo)
{
m_IconInfo[i].hIcon = NULL;
}
if (m_bIcoLibAvailable = mu::icolib::_available())
{
bool bIcoLibTested = false;
mu_ansi szModule[MAX_PATH];
GetModuleFileNameA(g_hInst, szModule, MAX_PATH);
m_Section = muT("HistoryStats");
m_IconName = muA("historystats_");
array_each_(i, m_IconInfo)
{
ext::string strSection = m_Section;
if (m_IconInfo[i].szSection)
{
strSection += muT("/");
strSection += i18n(m_IconInfo[i].szSection);
}
mu::icolib::addIcon(
strSection.c_str(),
i18n(m_IconInfo[i].szDescription),
(m_IconName + m_IconInfo[i].szIconName).c_str(),
szModule,
-m_IconInfo[i].wID);
if (!bIcoLibTested)
{
bIcoLibTested = true;
if (!getIcon(static_cast<IconIndex>(i)))
{
m_bIcoLibAvailable = false;
break;
}
}
}
m_hHookSkin2IconsChanged = mu::_link::hookEvent(ME_SKIN2_ICONSCHANGED, handleCallbacks);
}
if (!m_bIcoLibAvailable)
{
array_each_(i, m_IconInfo)
{
m_IconInfo[i].hIcon = reinterpret_cast<HICON>(LoadImage(
g_hInst,
MAKEINTRESOURCE(m_IconInfo[i].wID),
IMAGE_ICON,
OS::smIconCX(),
OS::smIconCY(),
0));
}
}
}
void IconLib::registerCallback(CallbackProc callback, LPARAM lParam)
{
m_Callbacks.insert(std::make_pair(callback, lParam));
}
void IconLib::unregisterCallback(CallbackProc callback, LPARAM lParam)
{
m_Callbacks.erase(std::make_pair(callback, lParam));
}
void IconLib::uninit()
{
if (m_hHookSkin2IconsChanged)
{
mu::_link::unhookEvent(m_hHookSkin2IconsChanged);
m_hHookSkin2IconsChanged = NULL;
}
array_each_(i, m_IconInfo)
{
if (m_IconInfo[i].hIcon)
{
DestroyIcon(m_IconInfo[i].hIcon);
m_IconInfo[i].hIcon = NULL;
}
}
}
HICON IconLib::getIcon(IconIndex index)
{
if (m_bIcoLibAvailable)
{
return mu::icolib::getIcon((m_IconName + m_IconInfo[index].szIconName).c_str());
}
else
{
return m_IconInfo[index].hIcon;
}
}
|