diff options
author | George Hazan <george.hazan@gmail.com> | 2012-09-11 19:28:53 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2012-09-11 19:28:53 +0000 |
commit | 274cffbbffa950ddf286092b52f03f76ec61a301 (patch) | |
tree | 5aeb062d27c79d1fbc15eaf033da943630bcbf84 /protocols/MRA/MraIcons.cpp | |
parent | 482be69d327aef60a9a654b8cc6a5e6646d095de (diff) |
slightly refactored MRA
git-svn-id: http://svn.miranda-ng.org/main/trunk@1564 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/MRA/MraIcons.cpp')
-rw-r--r-- | protocols/MRA/MraIcons.cpp | 156 |
1 files changed, 62 insertions, 94 deletions
diff --git a/protocols/MRA/MraIcons.cpp b/protocols/MRA/MraIcons.cpp index 0da6ee011e..d45e03bd73 100644 --- a/protocols/MRA/MraIcons.cpp +++ b/protocols/MRA/MraIcons.cpp @@ -1,148 +1,116 @@ #include "Mra.h"
#include "MraIcons.h"
-
-
-
-void AddIcoLibItems(LPWSTR lpwszRootSectionName,LPWSTR lpwszSubSectionName,const GUI_DISPLAY_ITEM *pgdiItems,SIZE_T dwCount,HANDLE *hResult)
+void CMraProto::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];
+ WCHAR wszSection[MAX_PATH], wszPath[MAX_FILEPATH];
- SKINICONDESC sid={0};
+ SKINICONDESC sid = {0};
sid.cbSize = sizeof(sid);
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);
+ if (lpwszSubSectionName == NULL) lpwszSubSectionName = L"";
+ GetModuleFileName(masMraSettings.hInstance, wszPath, SIZEOF(wszPath));
+ mir_sntprintf(wszSection, SIZEOF(wszSection), L"%s%s%s", lpwszRootSectionName, m_tszUserName, lpwszSubSectionName);
+
+ for (size_t i = 0;i<dwCount;i++) {
+ mir_snprintf(szBuff, SIZEOF(szBuff), "%s_%s", m_szModuleName, 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] = Skin_AddIcon(&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));
+ return IconLibGetIconEx(hIcon, LR_SHARED);
}
-
-HICON IconLibGetIconEx(HANDLE hIcon,DWORD dwFlags)
+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);
- }
+ HICON hiIcon = NULL;
+ if (hIcon) {
+ hiIcon = Skin_GetIconByHandle(hIcon);
+ if ((dwFlags & LR_SHARED) == 0)
+ hiIcon = CopyIcon(hiIcon);
}
-return(hiIcon);
+ return hiIcon;
}
//////////////////////////////////////////////////////////////////////////////////////
-void IconsLoad()
+
+void CMraProto::IconsLoad()
{
- AddIcoLibItems(L"Protocols/",L"/MainMenu",gdiMenuItems,SIZEOF(gdiMenuItems),masMraSettings.hMainMenuIcons);
- AddIcoLibItems(L"Protocols/",L"/ContactMenu",gdiContactMenuItems,SIZEOF(gdiContactMenuItems),masMraSettings.hContactMenuIcons);
+ AddIcoLibItems(L"Protocols/", L"/MainMenu", gdiMenuItems, gdiMenuItemsCount, hMainMenuIcons);
+ AddIcoLibItems(L"Protocols/", L"/ContactMenu", gdiContactMenuItems, gdiContactMenuItemsCount, hContactMenuIcons);
+
// Advanced Status Icons initialization
- AddIcoLibItems(L"Protocols/",L"/Extra status",gdiExtraStatusIconsItems,SIZEOF(gdiExtraStatusIconsItems),masMraSettings.hAdvancedStatusIcons);
+ AddIcoLibItems(L"Protocols/", L"/Extra status", gdiExtraStatusIconsItems, gdiExtraStatusIconsItemsCount, hAdvancedStatusIcons);
}
-void IconsUnLoad()
+void CMraProto::IconsUnLoad()
{
- RemoveIcoLibItems(gdiMenuItems,SIZEOF(gdiMenuItems));
- bzero(masMraSettings.hMainMenuIcons,sizeof(masMraSettings.hMainMenuIcons));
-
- RemoveIcoLibItems(gdiContactMenuItems,SIZEOF(gdiContactMenuItems));
- bzero(masMraSettings.hContactMenuIcons,sizeof(masMraSettings.hContactMenuIcons));
-
// Advanced Status Icons initialization
- RemoveIcoLibItems(gdiExtraStatusIconsItems,SIZEOF(gdiExtraStatusIconsItems));
- bzero(masMraSettings.hAdvancedStatusIcons,sizeof(masMraSettings.hAdvancedStatusIcons));
- bzero(masMraSettings.hAdvancedStatusItems,sizeof(masMraSettings.hAdvancedStatusItems));
+ bzero(hAdvancedStatusIcons, sizeof(hAdvancedStatusIcons));
+ bzero(hAdvancedStatusItems, sizeof(hAdvancedStatusItems));
}
-
-
-
-void InitXStatusIcons()
+void CMraProto::InitXStatusIcons()
{
int iCurIndex;
char szBuff[MAX_PATH];
- WCHAR wszSection[MAX_PATH],wszPath[MAX_FILEPATH];
+ WCHAR wszSection[MAX_PATH], wszPath[MAX_FILEPATH];
- SKINICONDESC sid={0};
+ SKINICONDESC sid = {0};
sid.cbSize = sizeof(sid);
- sid.pwszSection=wszSection;
- sid.pwszDefaultFile=wszPath;
- sid.cx=sid.cy=16;
- sid.flags=SIDF_ALL_UNICODE;
+ 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));
+ GetModuleFileName(masMraSettings.hDLLXStatusIcons, wszPath, SIZEOF(wszPath));
else
- bzero(wszPath,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;
+ bzero(wszPath, sizeof(wszPath));
+
+ mir_sntprintf(wszSection, SIZEOF(wszSection), L"Status Icons/%s/Custom Status", m_tszUserName);
+
+ hXStatusAdvancedStatusIcons[0] = NULL;
+ for (size_t i = 1; i < MRA_XSTATUS_COUNT+1; i++) {
+ mir_snprintf(szBuff, SIZEOF(szBuff), "%s_xstatus%ld", m_szModuleName, 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] = Skin_AddIcon(&sid);
+ sid.hDefaultIcon = (HICON)LoadImage(masMraSettings.hDLLXStatusIcons, MAKEINTRESOURCE(iCurIndex), IMAGE_ICON, 0, 0, LR_SHARED);
+ else
+ sid.hDefaultIcon = NULL;
+
+ hXStatusAdvancedStatusIcons[i] = Skin_AddIcon(&sid);
}
}
-void DestroyXStatusIcons()
+void CMraProto::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);
+ for (size_t i = 1; i < MRA_XSTATUS_COUNT+1; i++) {
+ mir_snprintf(szBuff, SIZEOF(szBuff), "xstatus%ld", i);
+ Skin_RemoveIcon(szBuff);
}
- bzero(masMraSettings.hXStatusAdvancedStatusIcons,sizeof(masMraSettings.hXStatusAdvancedStatusIcons));
- bzero(masMraSettings.hXStatusAdvancedStatusItems,sizeof(masMraSettings.hXStatusAdvancedStatusItems));
+
+ bzero(hXStatusAdvancedStatusIcons, sizeof(hXStatusAdvancedStatusIcons));
+ bzero(hXStatusAdvancedStatusItems, sizeof(hXStatusAdvancedStatusItems));
}
|