diff options
author | George Hazan <george.hazan@gmail.com> | 2012-11-19 12:51:53 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2012-11-19 12:51:53 +0000 |
commit | 32dedc767dec565c576b78b786e7a95d76ac806e (patch) | |
tree | 0f2eb209b3716569a8e3c3ef146a91f402ebbb4d /src/modules/extraicons/usedIcons.cpp | |
parent | adf7367cfdb57b32aadeb74af45dce9a6a3c02a5 (diff) |
- added another helper, ExtraIcon_Clear, to remove an icon from slot;
- added ability to pass IcoLib handles instead of icons' names
git-svn-id: http://svn.miranda-ng.org/main/trunk@2371 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'src/modules/extraicons/usedIcons.cpp')
-rw-r--r-- | src/modules/extraicons/usedIcons.cpp | 69 |
1 files changed, 52 insertions, 17 deletions
diff --git a/src/modules/extraicons/usedIcons.cpp b/src/modules/extraicons/usedIcons.cpp index 1c42104490..e810dd1878 100644 --- a/src/modules/extraicons/usedIcons.cpp +++ b/src/modules/extraicons/usedIcons.cpp @@ -25,41 +25,69 @@ struct Icon {
string name;
int refCount;
- HANDLE hImage;
+ HANDLE hIcoLib, hImage;
Icon(const char *icolibName) :
- name(icolibName), refCount(0), hImage(INVALID_HANDLE_VALUE)
+ name(icolibName), hIcoLib(0), refCount(0), hImage(INVALID_HANDLE_VALUE)
+ {
+ }
+
+ Icon(HANDLE _hIcolib) :
+ name(""), hIcoLib(_hIcolib), refCount(0), hImage(INVALID_HANDLE_VALUE)
{
}
};
static vector<Icon> usedIcons;
-static Icon * FindIcon(const char *icolibName)
+static Icon* FindIcon(const char *icolibName)
{
Icon *icon = NULL;
- for (unsigned int i = 0; i < usedIcons.size(); i++)
- {
+ for (unsigned int i = 0; i < usedIcons.size(); i++) {
Icon *tmp = &usedIcons[i];
- if (tmp->name != icolibName)
- continue;
-
- icon = tmp;
- break;
+ if (tmp->name == icolibName) {
+ icon = tmp;
+ break;
+ }
}
- if (icon == NULL)
- {
- usedIcons.push_back(Icon(icolibName));
+ if (icon == NULL) {
+ usedIcons.push_back( Icon(icolibName));
icon = &usedIcons[usedIcons.size() - 1];
}
- if (icon->hImage == INVALID_HANDLE_VALUE)
- {
+ if (icon->hImage == INVALID_HANDLE_VALUE) {
HICON hIcon = Skin_GetIcon(icon->name.c_str());
- if (hIcon != NULL)
- {
+ if (hIcon != NULL) {
+ icon->hImage = ExtraIcon_Add(hIcon);
+ Skin_ReleaseIcon(hIcon);
+ }
+ }
+
+ return icon;
+}
+
+static Icon* FindIcon(HANDLE hIcolib)
+{
+ Icon *icon = NULL;
+
+ for (unsigned int i = 0; i < usedIcons.size(); i++) {
+ Icon *tmp = &usedIcons[i];
+ if (tmp->hImage == hIcolib) {
+ icon = tmp;
+ break;
+ }
+ }
+
+ if (icon == NULL) {
+ usedIcons.push_back( Icon(hIcolib));
+ icon = &usedIcons[usedIcons.size() - 1];
+ }
+
+ if (icon->hImage == INVALID_HANDLE_VALUE) {
+ HICON hIcon = Skin_GetIconByHandle(icon->hIcoLib);
+ if (hIcon != NULL) {
icon->hImage = ExtraIcon_Add(hIcon);
Skin_ReleaseIcon(hIcon);
}
@@ -80,6 +108,13 @@ HANDLE AddIcon(const char *icolibName) return icon->hImage;
}
+HANDLE AddIcon(HANDLE hIcolib)
+{
+ Icon *icon = FindIcon(hIcolib);
+ icon->refCount++;
+ return icon->hImage;
+}
+
void RemoveIcon(const char *icolibName)
{
for (unsigned int i = 0; i < usedIcons.size(); i++)
|