summaryrefslogtreecommitdiff
path: root/protocols/MRA/src/MraIcons.cpp
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2013-10-25 00:27:33 +0000
committerGeorge Hazan <george.hazan@gmail.com>2013-10-25 00:27:33 +0000
commit402c282619b316fc77d71546ea40f026e0506bbb (patch)
tree5c9e5c2120fdd5f62f9826f77d967b5f5ac6de0f /protocols/MRA/src/MraIcons.cpp
parent05b2e149be5b49508d99f39bf9d53c6f9a170dc4 (diff)
MRA:
- all menu related code moved to Mra_menus.cpp; - mra-specific menu items moved to the Services... submenu; git-svn-id: http://svn.miranda-ng.org/main/trunk@6616 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/MRA/src/MraIcons.cpp')
-rw-r--r--protocols/MRA/src/MraIcons.cpp191
1 files changed, 63 insertions, 128 deletions
diff --git a/protocols/MRA/src/MraIcons.cpp b/protocols/MRA/src/MraIcons.cpp
index 9917c681e5..3df65987a3 100644
--- a/protocols/MRA/src/MraIcons.cpp
+++ b/protocols/MRA/src/MraIcons.cpp
@@ -3,75 +3,49 @@
HANDLE hXStatusAdvancedStatusIcons[MRA_XSTATUS_COUNT+4];
-GUI_DISPLAY_ITEM gdiMenuItems[] =
+IconItem gdiMenuItems[MAIN_MENU_ITEMS_COUNT] =
{
- { MRA_GOTO_INBOX, MRA_GOTO_INBOX_STR, IDI_INBOX, &CMraProto::MraGotoInbox },
- { MRA_SHOW_INBOX_STATUS, MRA_SHOW_INBOX_STATUS_STR, IDI_MAIL_NOTIFY, &CMraProto::MraShowInboxStatus },
- { MRA_EDIT_PROFILE, MRA_EDIT_PROFILE_STR, IDI_PROFILE, &CMraProto::MraEditProfile },
- { MRA_MY_ALBUM, MRA_MY_ALBUM_STR, IDI_MRA_PHOTO, &CMraProto::MraViewAlbum },
- { MRA_MY_BLOG, MRA_MY_BLOG_STR, IDI_MRA_BLOGS, &CMraProto::MraReadBlog },
- { MRA_MY_BLOGSTATUS, MRA_MY_BLOGSTATUS_STR, IDI_BLOGSTATUS, &CMraProto::MraReplyBlogStatus },
- { MRA_MY_VIDEO, MRA_MY_VIDEO_STR, IDI_MRA_VIDEO, &CMraProto::MraViewVideo },
- { MRA_MY_ANSWERS, MRA_MY_ANSWERS_STR, IDI_MRA_ANSWERS, &CMraProto::MraAnswers },
- { MRA_MY_WORLD, MRA_MY_WORLD_STR, IDI_MRA_WORLD, &CMraProto::MraWorld },
- { MRA_ZHUKI, MRA_ZHUKI_STR, IDI_MRA_ZHUKI, &CMraProto::MraZhuki },
- { MRA_WEB_SEARCH, MRA_WEB_SEARCH_STR, IDI_MRA_WEB_SEARCH, &CMraProto::MraWebSearch },
- { MRA_UPD_ALL_USERS_INFO, MRA_UPD_ALL_USERS_INFO_STR, IDI_PROFILE, &CMraProto::MraUpdateAllUsersInfo },
- { MRA_CHK_USERS_AVATARS, MRA_CHK_USERS_AVATARS_STR, IDI_PROFILE, &CMraProto::MraCheckUpdatesUsersAvt },
- { MRA_REQ_AUTH_FOR_ALL, MRA_REQ_AUTH_FOR_ALL_STR, IDI_AUTHRUGUEST, &CMraProto::MraRequestAuthForAll }
+ { MRA_GOTO_INBOX_STR, MRA_GOTO_INBOX, IDI_INBOX },
+ { MRA_SHOW_INBOX_STATUS_STR, MRA_SHOW_INBOX_STATUS, IDI_MAIL_NOTIFY },
+ { MRA_EDIT_PROFILE_STR, MRA_EDIT_PROFILE, IDI_PROFILE },
+ { MRA_MY_ALBUM_STR, MRA_VIEW_ALBUM, IDI_MRA_PHOTO },
+ { MRA_MY_BLOG_STR, MRA_READ_BLOG, IDI_MRA_BLOGS },
+ { MRA_MY_BLOGSTATUS_STR, MRA_REPLY_BLOG_STATUS, IDI_BLOGSTATUS },
+ { MRA_MY_VIDEO_STR, MRA_VIEW_VIDEO, IDI_MRA_VIDEO },
+ { MRA_MY_ANSWERS_STR, MRA_ANSWERS, IDI_MRA_ANSWERS },
+ { MRA_MY_WORLD_STR, MRA_WORLD, IDI_MRA_WORLD },
+ { MRA_ZHUKI_STR, MRA_ZHUKI, IDI_MRA_ZHUKI },
+ { MRA_WEB_SEARCH_STR, MRA_WEB_SEARCH, IDI_MRA_WEB_SEARCH },
+ { MRA_UPD_ALL_USERS_INFO_STR, MRA_UPD_ALL_USERS_INFO, IDI_PROFILE },
+ { MRA_CHK_USERS_AVATARS_STR, MRA_CHK_USERS_AVATARS, IDI_PROFILE },
+ { MRA_REQ_AUTH_FOR_ALL_STR, MRA_REQ_AUTH_FOR_ALL, IDI_AUTHRUGUEST }
};
-GUI_DISPLAY_ITEM gdiContactMenuItems[] =
+IconItem gdiContactMenuItems[CONTACT_MENU_ITEMS_COUNT] =
{
- { MRA_REQ_AUTH, MRA_REQ_AUTH_STR, IDI_AUTHRUGUEST, &CMraProto::MraRequestAuthorization },
- { MRA_GRANT_AUTH, MRA_GRANT_AUTH_STR, IDI_AUTHGRANT, &CMraProto::MraGrantAuthorization },
- { MRA_SEND_POSTCARD, MRA_SEND_POSTCARD_STR, IDI_MRA_POSTCARD, &CMraProto::MraSendPostcard },
- { MRA_VIEW_ALBUM, MRA_VIEW_ALBUM_STR, IDI_MRA_PHOTO, &CMraProto::MraViewAlbum },
- { MRA_READ_BLOG, MRA_READ_BLOG_STR , IDI_MRA_BLOGS, &CMraProto::MraReadBlog },
- { MRA_REPLY_BLOG_STATUS, MRA_REPLY_BLOG_STATUS_STR, IDI_BLOGSTATUS, &CMraProto::MraReplyBlogStatus },
- { MRA_VIEW_VIDEO, MRA_VIEW_VIDEO_STR, IDI_MRA_VIDEO, &CMraProto::MraViewVideo },
- { MRA_ANSWERS, MRA_ANSWERS_STR, IDI_MRA_ANSWERS, &CMraProto::MraAnswers },
- { MRA_WORLD, MRA_WORLD_STR, IDI_MRA_WORLD, &CMraProto::MraWorld },
- { PS_SEND_NUDGE, MRA_SENDNUDGE_STR, IDI_MRA_ALARM, NULL }
+ { MRA_REQ_AUTH_STR, MRA_REQ_AUTH, IDI_AUTHRUGUEST },
+ { MRA_GRANT_AUTH_STR, MRA_GRANT_AUTH, IDI_AUTHGRANT },
+ { MRA_SEND_POSTCARD_STR, MRA_SEND_POSTCARD, IDI_MRA_POSTCARD },
+ { MRA_VIEW_ALBUM_STR, MRA_VIEW_ALBUM, IDI_MRA_PHOTO },
+ { MRA_READ_BLOG_STR, MRA_READ_BLOG, IDI_MRA_BLOGS },
+ { MRA_REPLY_BLOG_STATUS_STR, MRA_REPLY_BLOG_STATUS, IDI_BLOGSTATUS },
+ { MRA_VIEW_VIDEO_STR, MRA_VIEW_VIDEO, IDI_MRA_VIDEO },
+ { MRA_ANSWERS_STR, MRA_ANSWERS, IDI_MRA_ANSWERS },
+ { MRA_WORLD_STR, MRA_WORLD, IDI_MRA_WORLD },
+ { MRA_SENDNUDGE_STR, PS_SEND_NUDGE, IDI_MRA_ALARM }
};
-GUI_DISPLAY_ITEM gdiExtraStatusIconsItems[] =
+IconItem gdiExtraStatusIconsItems[ADV_ICON_MAX] =
{
- { ADV_ICON_DELETED_ID, ADV_ICON_DELETED_STR, IDI_DELETED, NULL },
- { ADV_ICON_NOT_ON_SERVER_ID, ADV_ICON_NOT_ON_SERVER_STR, IDI_AUTHGRANT, NULL },
- { ADV_ICON_NOT_AUTHORIZED_ID, ADV_ICON_NOT_AUTHORIZED_STR, IDI_AUTHRUGUEST, NULL },
- { ADV_ICON_PHONE_ID, ADV_ICON_PHONE_STR, IDI_MRA_PHONE, NULL },
- { ADV_ICON_BLOGSTATUS_ID, ADV_ICON_BLOGSTATUS_STR, IDI_BLOGSTATUS, NULL },
+ { ADV_ICON_DELETED_STR, ADV_ICON_DELETED_ID, IDI_DELETED },
+ { ADV_ICON_NOT_ON_SERVER_STR, ADV_ICON_NOT_ON_SERVER_ID, IDI_AUTHGRANT },
+ { ADV_ICON_NOT_AUTHORIZED_STR, ADV_ICON_NOT_AUTHORIZED_ID, IDI_AUTHRUGUEST },
+ { ADV_ICON_PHONE_STR, ADV_ICON_PHONE_ID, IDI_MRA_PHONE },
+ { ADV_ICON_BLOGSTATUS_STR, ADV_ICON_BLOGSTATUS_ID, IDI_BLOGSTATUS }
};
//////////////////////////////////////////////////////////////////////////////////////
-static void AddIcoLibItems(LPWSTR lptszSubSectionName, GUI_DISPLAY_ITEM *pgdiItems, size_t dwCount)
-{
- TCHAR tszSection[MAX_PATH], tszPath[MAX_FILEPATH];
- GetModuleFileName(masMraSettings.hInstance, tszPath, SIZEOF(tszPath));
- mir_sntprintf(tszSection, SIZEOF(tszSection), _T("Protocols/MRA/%s"), lptszSubSectionName);
-
- SKINICONDESC sid = { sizeof(sid) };
- sid.ptszSection = tszSection;
- sid.ptszDefaultFile = tszPath;
- sid.cx = sid.cy = 16;
- sid.flags = SIDF_ALL_UNICODE;
-
- if (lptszSubSectionName == NULL)
- lptszSubSectionName = _T("");
-
- for (size_t i = 0;i<dwCount;i++) {
- char szBuff[MAX_PATH];
- mir_snprintf(szBuff, SIZEOF(szBuff), "MRA_%s", pgdiItems[i].lpszName);
-
- sid.pszName = szBuff;
- sid.pwszDescription = pgdiItems[i].lpwszDescr;
- sid.iDefaultIndex = -pgdiItems[i].defIcon;
- pgdiItems[i].hIconHandle = Skin_AddIcon(&sid);
- }
-}
-
HICON IconLibGetIcon(HANDLE hIcon)
{
return IconLibGetIconEx(hIcon, LR_SHARED);
@@ -92,24 +66,45 @@ HICON IconLibGetIconEx(HANDLE hIcon, DWORD dwFlags)
void IconsLoad()
{
- AddIcoLibItems(LPGENT("Main Menu"), gdiMenuItems, SIZEOF(gdiMenuItems));
- AddIcoLibItems(LPGENT("Contact Menu"), gdiContactMenuItems, SIZEOF(gdiContactMenuItems));
+ g_hMainIcon = (HICON)LoadImage(g_hInstance, MAKEINTRESOURCE(IDI_MRA), IMAGE_ICON, 0, 0, LR_SHARED);
- // Advanced Status Icons initialization
- AddIcoLibItems(LPGENT("Extra status"), gdiExtraStatusIconsItems, SIZEOF(gdiExtraStatusIconsItems));
+ Icon_Register(g_hInstance, LPGEN("Protocols") "/" LPGEN("MRA") "/" LPGEN("Main Menu"), gdiMenuItems, MAIN_MENU_ITEMS_COUNT, "MRA_");
+ Icon_Register(g_hInstance, LPGEN("Protocols") "/" LPGEN("MRA") "/" LPGEN("Contact Menu"), gdiContactMenuItems, CONTACT_MENU_ITEMS_COUNT, "MRA_");
+ Icon_Register(g_hInstance, LPGEN("Protocols") "/" LPGEN("MRA") "/" LPGEN("Extra status"), gdiExtraStatusIconsItems, ADV_ICON_MAX, "MRA_");
}
void InitXStatusIcons()
{
- TCHAR tszPath[MAX_FILEPATH];
- if (masMraSettings.hDLLXStatusIcons)
- GetModuleFileName(masMraSettings.hDLLXStatusIcons, tszPath, SIZEOF(tszPath));
- else
- bzero(tszPath, sizeof(tszPath));
+ // load libs
+ TCHAR szBuff[MAX_FILEPATH];
+ if (GetModuleFileName(NULL, szBuff, SIZEOF(szBuff))) {
+ LPWSTR lpwszFileName;
+ g_dwMirWorkDirPathLen = GetFullPathName(szBuff, MAX_FILEPATH, g_szMirWorkDirPath, &lpwszFileName);
+ if (g_dwMirWorkDirPathLen) {
+ g_dwMirWorkDirPathLen -= lstrlenW(lpwszFileName);
+ g_szMirWorkDirPath[g_dwMirWorkDirPathLen] = 0;
+
+ // load xstatus icons lib
+ DWORD dwBuffLen;
+ DWORD dwErrorCode = FindFile(g_szMirWorkDirPath, (DWORD)g_dwMirWorkDirPathLen, _T("xstatus_MRA.dll"), -1, szBuff, SIZEOF(szBuff), &dwBuffLen);
+ if (dwErrorCode == NO_ERROR) {
+ g_hDLLXStatusIcons = LoadLibraryEx(szBuff, NULL, 0);
+ if (g_hDLLXStatusIcons) {
+ dwBuffLen = LoadString(g_hDLLXStatusIcons, IDS_IDENTIFY, szBuff, MAX_FILEPATH);
+ if (dwBuffLen == 0 || _tcsnicmp(_T("# Custom Status Icons #"), szBuff, 23)) {
+ FreeLibrary(g_hDLLXStatusIcons);
+ g_hDLLXStatusIcons = NULL;
+ }
+ }
+ }
+ }
+ }
+
+ GetModuleFileName((g_hDLLXStatusIcons != NULL) ? g_hDLLXStatusIcons : g_hInstance, szBuff, SIZEOF(szBuff));
SKINICONDESC sid = { sizeof(sid) };
sid.ptszSection = LPGENT("Protocols")_T("/")LPGENT("MRA")_T("/")LPGENT("Custom Status");
- sid.ptszDefaultFile = tszPath;
+ sid.ptszDefaultFile = szBuff;
sid.cx = sid.cy = 16;
sid.flags = SIDF_ALL_TCHAR;
@@ -138,63 +133,3 @@ void DestroyXStatusIcons()
bzero(hXStatusAdvancedStatusIcons, sizeof(hXStatusAdvancedStatusIcons));
}
-
-/////////////////////////////////////////////////////////////////////////////////////////
-
-void CMraProto::InitMainMenu()
-{
- HICON hMainIcon = (HICON)LoadImage(masMraSettings.hInstance, MAKEINTRESOURCE(IDI_MRA), IMAGE_ICON, 0, 0, LR_SHARED);
- CListCreateMenu(200001, 500085000, hMainIcon, NULL, TRUE, gdiMenuItems, SIZEOF(gdiMenuItems), hMainMenuItems);
-}
-
-void CMraProto::InitContactMenu()
-{
- CListCreateMenu(2000060000, -500050000, NULL, NULL, FALSE, gdiContactMenuItems, SIZEOF(gdiContactMenuItems), hContactMenuItems);
-}
-
-void CMraProto::CListCreateMenu(LONG lPosition, LONG lPopupPosition, HICON hMainIcon, LPSTR pszContactOwner, BOOL bIsMain, const GUI_DISPLAY_ITEM *pgdiItems, size_t dwCount, HGENMENU *hResult)
-{
- if (!pgdiItems || !dwCount || !hResult)
- return;
-
- char szServiceFunction[MAX_PATH], *pszServiceFunctionName;
- strncpy(szServiceFunction, m_szModuleName, sizeof(szServiceFunction));
- pszServiceFunctionName = szServiceFunction + strlen(m_szModuleName);
-
- CLISTMENUITEM mi = { sizeof(mi) };
- mi.position = -1999901008;
-
- HGENMENU (*fnAddFunc)(CLISTMENUITEM*);
- if (bIsMain) {
- fnAddFunc = Menu_AddProtoMenuItem;
-
- HGENMENU hRootMenu = MO_GetProtoRootMenu(m_szModuleName);
- if (hRootMenu == NULL) {
- mi.ptszName = m_tszUserName;
- mi.hParentMenu = HGENMENU_ROOT;
- mi.flags = CMIF_ROOTPOPUP | CMIF_TCHAR | CMIF_KEEPUNTRANSLATED;
- mi.hIcon = hMainIcon;
- hRootMenu = Menu_AddProtoMenuItem(&mi);
- }
- mi.hParentMenu = hRootMenu;
- mi.flags = CMIF_UNICODE | CMIF_CHILDPOPUP;
- }
- else {
- fnAddFunc = Menu_AddContactMenuItem;
- mi.ptszPopupName = m_tszUserName;
- mi.flags = CMIF_UNICODE;
- }
-
- mi.popupPosition = lPopupPosition;
- mi.pszService = szServiceFunction;
-
- for (size_t i = 0; i < dwCount; i++) {
- memmove(pszServiceFunctionName, pgdiItems[i].lpszName, lstrlenA(pgdiItems[i].lpszName)+1);
- if (pgdiItems[i].lpFunc)
- CreateProtoService(pgdiItems[i].lpszName, pgdiItems[i].lpFunc);
- mi.position = int(lPosition + i);
- mi.icolibItem = pgdiItems[i].hIconHandle;
- mi.ptszName = pgdiItems[i].lpwszDescr;
- hResult[i] = fnAddFunc(&mi);
- }
-}