summaryrefslogtreecommitdiff
path: root/plugins/UserInfoEx
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2012-11-19 14:06:55 +0000
committerGeorge Hazan <george.hazan@gmail.com>2012-11-19 14:06:55 +0000
commit0a4edf42be37bf12786e668837488ce074f476f2 (patch)
treee2d4e17f25dc357e1d6bb0bdc15476f3ca148567 /plugins/UserInfoEx
parent32dedc767dec565c576b78b786e7a95d76ac806e (diff)
more cleaning of icons' names
git-svn-id: http://svn.miranda-ng.org/main/trunk@2372 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/UserInfoEx')
-rw-r--r--plugins/UserInfoEx/src/Flags/svc_flags.cpp18
-rw-r--r--plugins/UserInfoEx/src/Flags/svc_flagsicons.cpp58
-rw-r--r--plugins/UserInfoEx/src/Flags/svc_flagsicons.h3
3 files changed, 35 insertions, 44 deletions
diff --git a/plugins/UserInfoEx/src/Flags/svc_flags.cpp b/plugins/UserInfoEx/src/Flags/svc_flags.cpp
index e3b59f47f8..95d0259ce4 100644
--- a/plugins/UserInfoEx/src/Flags/svc_flags.cpp
+++ b/plugins/UserInfoEx/src/Flags/svc_flags.cpp
@@ -235,12 +235,7 @@ static void CALLBACK SetExtraImage(LPARAM lParam)
{
/* get contact's country */
int countryNumber = ServiceDetectContactOriginCountry((WPARAM)lParam,0);
- if (countryNumber != 0xFFFF || gFlagsOpts.bUseUnknownFlag) {
- char szId[20];
- mir_snprintf(szId, SIZEOF(szId), (countryNumber == 0xFFFF) ? "%s_0x%X" : "%s_%i","flags", countryNumber); /* buffer safe */
- ExtraIcon_SetIcon(hExtraIconSvc, (HANDLE)lParam, szId);
- }
- else ExtraIcon_Clear(hExtraIconSvc, (HANDLE)lParam);
+ ExtraIcon_SetIcon(hExtraIconSvc, (HANDLE)lParam, (countryNumber != 0xFFFF || gFlagsOpts.bUseUnknownFlag) ? LoadFlagHandle(countryNumber) : NULL);
}
static void CALLBACK RemoveExtraImages(LPARAM lParam)
@@ -314,8 +309,7 @@ VOID SvcFlagsEnableExtraIcons(BYTE bColumn, BOOLEAN bUpdateDB)
// Flags is on
if (gFlagsOpts.bShowExtraImgFlag) {
- if(hExtraIconSvc == INVALID_HANDLE_VALUE) {
- char szId[20];
+ if (hExtraIconSvc == INVALID_HANDLE_VALUE) {
//get local langID for descIcon (try to use user local Flag as icon)
DWORD langid = 0;
int r = GetLocaleInfo(
@@ -324,13 +318,9 @@ VOID SvcFlagsEnableExtraIcons(BYTE bColumn, BOOLEAN bUpdateDB)
(LPTSTR)&langid, sizeof(langid)/sizeof(TCHAR));
if (!CallService(MS_UTILS_GETCOUNTRYBYNUMBER,langid,0)) langid = 1;
- EXTRAICON_INFO ico = { sizeof(ico) };
- ico.type = EXTRAICON_TYPE_ICOLIB;
- ico.name = "Flags";
- ico.description = "Flags (uinfoex)";
+ char szId[20];
mir_snprintf(szId, SIZEOF(szId), (langid==0xFFFF)?"%s_0x%X":"%s_%i","flags",langid); /* buffer safe */
- ico.descIcon = szId;
- hExtraIconSvc = (HANDLE)CallService(MS_EXTRAICON_REGISTER, (WPARAM)&ico, 0);
+ hExtraIconSvc = ExtraIcon_Register("Flags", "Flags (uinfoex)", szId);
if (hExtraIconSvc)
HookEvent(ME_DB_CONTACT_SETTINGCHANGED, OnExtraIconSvcChanged);
}
diff --git a/plugins/UserInfoEx/src/Flags/svc_flagsicons.cpp b/plugins/UserInfoEx/src/Flags/svc_flagsicons.cpp
index d7119cd75e..fe4ce708bb 100644
--- a/plugins/UserInfoEx/src/Flags/svc_flagsicons.cpp
+++ b/plugins/UserInfoEx/src/Flags/svc_flagsicons.cpp
@@ -138,22 +138,30 @@ static int CountryNumberToBitmapIndex(int countryNumber)
HICON LoadFlag(int countryNumber)
{
- char szId[20],*szCountry;
/* create identifier */
- szCountry=(char*)CallService(MS_UTILS_GETCOUNTRYBYNUMBER,countryNumber,0);
- if(szCountry == NULL)
- szCountry=(char*)CallService(MS_UTILS_GETCOUNTRYBYNUMBER,countryNumber=0xFFFF,0);
+ char *szCountry = (char*)CallService(MS_UTILS_GETCOUNTRYBYNUMBER,countryNumber,0);
+ if (szCountry == NULL)
+ szCountry = (char*)CallService(MS_UTILS_GETCOUNTRYBYNUMBER,countryNumber=0xFFFF,0);
- wsprintfA(szId,(countryNumber==0xFFFF)?"%s_0x%X":"%s_%i","flags",countryNumber); /* buffer safe */
+ char szId[20];
+ wsprintfA(szId,(countryNumber==0xFFFF) ? "%s_0x%X" : "%s_%i","flags",countryNumber); /* buffer safe */
return Skin_GetIcon(szId);
}
+HANDLE LoadFlagHandle(int countryNumber)
+{
+ if (phIconHandles == NULL)
+ return NULL;
+
+ return phIconHandles[ CountryNumberToIndex(countryNumber) ];
+}
+
int CountryNumberToIndex(int countryNumber)
{
- int i,nf=0;
- for(i=0;i<nCountriesCount;++i) {
- if(countries[i].id==countryNumber) return i;
- if(countries[i].id==0xFFFF) nf=i;
+ int nf=0;
+ for(int i=0; i < nCountriesCount; i++) {
+ if(countries[i].id == countryNumber) return i;
+ if(countries[i].id == 0xFFFF) nf=i;
}
return nf; /* Unknown */
}
@@ -382,7 +390,6 @@ VOID InitIcons()
FIP->FI_Unload(dib_ico);
return;
}
- //FIP->FI_SaveU(fif,dib_ico,_T("d:\\CD-Archiv\\Miranda\\trunk\\miranda\\bin9\\Debug Unicode\\Plugins\\dib_ico.bmp"),0);
}
else {
FIP->FI_Unload(dib);
@@ -404,29 +411,22 @@ VOID InitIcons()
DeleteObject(hScrBM); hScrBM = NULL;
DeleteObject(hbmMask); hbmMask = NULL;
- if(himl!=NULL) {
- phIconHandles=(HANDLE*)mir_alloc(nCountriesCount*sizeof(HANDLE));
- if(phIconHandles!=NULL) {
+ if (himl != NULL) {
+ phIconHandles = (HANDLE*)mir_alloc(nCountriesCount*sizeof(HANDLE));
+ if (phIconHandles != NULL) {
char szId[20];
- int i,index;
- SKINICONDESC skid;
-
- /* register icons */
- ZeroMemory(&skid,sizeof(skid));
- skid.cbSize = sizeof(skid);
- skid.ptszSection = LPGENT("Country Flags");
- skid.pszName = szId; // name to refer to icon when playing and in db
- //skid.pszDefaultFile = NULL; // default icon file to use
- //skid.iDefaultIndex = NULL; // index of icon in default file
- skid.cx = GetSystemMetrics(SM_CXSMICON);
- skid.cy = GetSystemMetrics(SM_CYSMICON);
- skid.flags = SIDF_SORTED|SIDF_TCHAR;
-
- for(i=0;i<nCountriesCount;++i) {
+ SKINICONDESC skid = { sizeof(skid) };
+ skid.ptszSection = LPGENT("Country Flags");
+ skid.pszName = szId; // name to refer to icon when playing and in db
+ skid.cx = GetSystemMetrics(SM_CXSMICON);
+ skid.cy = GetSystemMetrics(SM_CYSMICON);
+ skid.flags = SIDF_SORTED | SIDF_TCHAR;
+
+ for (int i=0; i < nCountriesCount; i++) {
skid.ptszDescription = mir_a2t(LPGEN(countries[i].szName));
/* create identifier */
wsprintfA(szId,(countries[i].id==0xFFFF)?"%s0x%X":"%s%i","flags_",countries[i].id); /* buffer safe */
- index = CountryNumberToBitmapIndex(countries[i].id);
+ int index = CountryNumberToBitmapIndex(countries[i].id);
/* create icon */
skid.hDefaultIcon=ImageList_ExtractIcon(NULL, himl, index);
index = CountryNumberToIndex(countries[i].id);
diff --git a/plugins/UserInfoEx/src/Flags/svc_flagsicons.h b/plugins/UserInfoEx/src/Flags/svc_flagsicons.h
index 7f29330a11..2aabd00c66 100644
--- a/plugins/UserInfoEx/src/Flags/svc_flagsicons.h
+++ b/plugins/UserInfoEx/src/Flags/svc_flagsicons.h
@@ -33,8 +33,9 @@ Last change by : $Author: ing.u.horn $
#ifndef _UINFOEX_FLAGSICONS_H_INCLUDED_
#define _UINFOEX_FLAGSICONS_H_INCLUDED_
-int CountryNumberToIndex(int countryNumber);
+int CountryNumberToIndex(int countryNumber);
HICON LoadFlag(int countryNumber);
+HANDLE LoadFlagHandle(int countryNumber);
VOID InitIcons();
//VOID SvcFlagsOnModulesLoaded();