summaryrefslogtreecommitdiff
path: root/protocols/MRA/MraIcons.cpp
diff options
context:
space:
mode:
authorVadim Dashevskiy <watcherhd@gmail.com>2012-05-15 10:38:20 +0000
committerVadim Dashevskiy <watcherhd@gmail.com>2012-05-15 10:38:20 +0000
commit48540940b6c28bb4378abfeb500ec45a625b37b6 (patch)
tree2ef294c0763e802f91d868bdef4229b6868527de /protocols/MRA/MraIcons.cpp
parent5c350913f011e119127baeb32a6aedeb4f0d33bc (diff)
initial commit
git-svn-id: http://svn.miranda-ng.org/main/trunk@2 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/MRA/MraIcons.cpp')
-rw-r--r--protocols/MRA/MraIcons.cpp151
1 files changed, 151 insertions, 0 deletions
diff --git a/protocols/MRA/MraIcons.cpp b/protocols/MRA/MraIcons.cpp
new file mode 100644
index 0000000000..18b8f8c5f5
--- /dev/null
+++ b/protocols/MRA/MraIcons.cpp
@@ -0,0 +1,151 @@
+#include "Mra.h"
+#include "MraIcons.h"
+
+
+
+
+void AddIcoLibItems(LPWSTR lpwszRootSectionName,LPWSTR lpwszSubSectionName,const GUI_DISPLAY_ITEM *pgdiItems,SIZE_T dwCount,HANDLE *hResult)
+{
+ char szBuff[MAX_PATH];
+ WCHAR wszSection[MAX_PATH],wszPath[MAX_FILEPATH];
+ SKINICONDESC sid={0};
+
+
+ sid.cbSize=SKINICONDESC_SIZE;
+ sid.pwszSection=wszSection;
+ sid.pwszDefaultFile=wszPath;
+ sid.cx=sid.cy=16;
+ sid.flags=SIDF_ALL_UNICODE;
+
+ if (lpwszSubSectionName==NULL) lpwszSubSectionName=L"";
+ GetModuleFileName(masMraSettings.hInstance,wszPath,SIZEOF(wszPath));
+ mir_sntprintf(wszSection,SIZEOF(wszSection),L"%s%s%s",lpwszRootSectionName,PROTOCOL_NAMEW,lpwszSubSectionName);
+
+ for (SIZE_T i=0;i<dwCount;i++)
+ {
+ mir_snprintf(szBuff,SIZEOF(szBuff),"%s_%s",PROTOCOL_NAMEA,pgdiItems[i].lpszName);
+ sid.pszName=szBuff;
+ sid.pwszDescription=pgdiItems[i].lpwszDescr;
+ sid.iDefaultIndex=-pgdiItems[i].defIcon;
+ sid.hDefaultIcon=(HICON)LoadImage(masMraSettings.hInstance,MAKEINTRESOURCE(pgdiItems[i].defIcon),IMAGE_ICON,0,0,LR_SHARED);
+ if (sid.hDefaultIcon==NULL) sid.hDefaultIcon=(HICON)LoadImage(NULL,MAKEINTRESOURCE(pgdiItems[i].defIcon),IMAGE_ICON,0,0,LR_SHARED);
+ hResult[i]=(HANDLE)CallService(MS_SKIN2_ADDICON,0,(LPARAM)&sid);
+ }
+}
+
+void RemoveIcoLibItems(const GUI_DISPLAY_ITEM *pgdiItems,SIZE_T dwCount)
+{
+ char szBuff[MAX_PATH];
+
+ for (SIZE_T i=0;i<dwCount;i++)
+ {
+ mir_snprintf(szBuff,SIZEOF(szBuff),"%s_%s",PROTOCOL_NAMEA,pgdiItems[i].lpszName);
+ //***deb until 08 release
+ //CallService(MS_SKIN2_REMOVEICON,0,(LPARAM)szBuff);
+ }
+}
+
+
+HICON IconLibGetIcon(HANDLE hIcon)
+{
+return(IconLibGetIconEx(hIcon,LR_SHARED));
+}
+
+
+HICON IconLibGetIconEx(HANDLE hIcon,DWORD dwFlags)
+{
+ HICON hiIcon=NULL;
+
+ if (hIcon)
+ {
+ hiIcon=(HICON)CallService(MS_SKIN2_GETICONBYHANDLE,0,(LPARAM)hIcon);
+ if ((dwFlags&LR_SHARED)==0)
+ {
+ hiIcon=CopyIcon(hiIcon);
+ }
+ }
+return(hiIcon);
+}
+
+
+//////////////////////////////////////////////////////////////////////////////////////
+void IconsLoad()
+{
+ AddIcoLibItems(L"Protocols/",L"/MainMenu",gdiMenuItems,SIZEOF(gdiMenuItems),masMraSettings.hMainMenuIcons);
+ AddIcoLibItems(L"Protocols/",L"/ContactMenu",gdiContactMenuItems,SIZEOF(gdiContactMenuItems),masMraSettings.hContactMenuIcons);
+ // Advanced Status Icons initialization
+ AddIcoLibItems(L"Protocols/",L"/Extra status",gdiExtraStatusIconsItems,SIZEOF(gdiExtraStatusIconsItems),masMraSettings.hAdvancedStatusIcons);
+}
+
+
+void IconsUnLoad()
+{
+ RemoveIcoLibItems(gdiMenuItems,SIZEOF(gdiMenuItems));
+ memset(masMraSettings.hMainMenuIcons, 0, sizeof(masMraSettings.hMainMenuIcons));
+
+ RemoveIcoLibItems(gdiContactMenuItems,SIZEOF(gdiContactMenuItems));
+ memset(masMraSettings.hContactMenuIcons, 0, sizeof(masMraSettings.hContactMenuIcons));
+
+ // Advanced Status Icons initialization
+ RemoveIcoLibItems(gdiExtraStatusIconsItems,SIZEOF(gdiExtraStatusIconsItems));
+ memset(masMraSettings.hAdvancedStatusIcons, 0, sizeof(masMraSettings.hAdvancedStatusIcons));
+ memset(masMraSettings.hAdvancedStatusItems,0, sizeof(masMraSettings.hAdvancedStatusItems));
+}
+
+
+
+
+void InitXStatusIcons()
+{
+ int iCurIndex;
+ char szBuff[MAX_PATH];
+ WCHAR wszSection[MAX_PATH],wszPath[MAX_FILEPATH];
+ SKINICONDESC sid={0};
+
+ sid.cbSize=SKINICONDESC_SIZE;
+ sid.pwszSection=wszSection;
+ sid.pwszDefaultFile=wszPath;
+ sid.cx=sid.cy=16;
+ sid.flags=SIDF_ALL_UNICODE;
+
+ if (masMraSettings.hDLLXStatusIcons)
+ {
+ GetModuleFileName(masMraSettings.hDLLXStatusIcons,wszPath,SIZEOF(wszPath));
+ }else{
+ memset(wszPath, 0, sizeof(wszPath));
+ }
+ mir_sntprintf(wszSection,SIZEOF(wszSection),L"Status Icons/%s/Custom Status",PROTOCOL_NAMEW);
+
+ masMraSettings.hXStatusAdvancedStatusIcons[0]=NULL;
+ for (SIZE_T i=1;i<(MRA_XSTATUS_COUNT+1);i++)
+ {
+ mir_snprintf(szBuff,SIZEOF(szBuff),"%s_xstatus%ld",PROTOCOL_NAMEA,i);
+ iCurIndex=(IDI_XSTATUS1-1+i);
+ sid.pszName=szBuff;
+ sid.pwszDescription=lpcszXStatusNameDef[i];
+ sid.iDefaultIndex=-iCurIndex;
+ if (masMraSettings.hDLLXStatusIcons)
+ {
+ sid.hDefaultIcon=(HICON)LoadImage(masMraSettings.hDLLXStatusIcons,MAKEINTRESOURCE(iCurIndex),IMAGE_ICON,0,0,LR_SHARED);
+ }else{
+ sid.hDefaultIcon=NULL;
+ }
+ masMraSettings.hXStatusAdvancedStatusIcons[i]=(HANDLE)CallService(MS_SKIN2_ADDICON,0,(LPARAM)&sid);
+ }
+}
+
+void DestroyXStatusIcons()
+{
+ char szBuff[MAX_PATH];
+
+ for (SIZE_T i=1;i<(MRA_XSTATUS_COUNT+1);i++)
+ {
+ mir_snprintf(szBuff,SIZEOF(szBuff),"xstatus%ld",i);
+ //***deb until 08 release
+ //CallService(MS_SKIN2_REMOVEICON,0,(LPARAM)szBuff);
+ }
+ memset(masMraSettings.hXStatusAdvancedStatusIcons, 0, sizeof(masMraSettings.hXStatusAdvancedStatusIcons));
+ memset(masMraSettings.hXStatusAdvancedStatusItems, 0, sizeof(masMraSettings.hXStatusAdvancedStatusItems));
+}
+
+