From c4582dd65b444e5dae29ada7cc3f6c9a9c20edf3 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sun, 2 Dec 2012 18:19:49 +0000 Subject: new easy standard way of registering icons: Icon_Register git-svn-id: http://svn.miranda-ng.org/main/trunk@2601 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/Quotes/src/IconLib.cpp | 66 ++++++++++-------------------------------- 1 file changed, 16 insertions(+), 50 deletions(-) (limited to 'plugins/Quotes/src/IconLib.cpp') diff --git a/plugins/Quotes/src/IconLib.cpp b/plugins/Quotes/src/IconLib.cpp index e7caa1fd36..ce7ad5cddc 100644 --- a/plugins/Quotes/src/IconLib.cpp +++ b/plugins/Quotes/src/IconLib.cpp @@ -3,7 +3,6 @@ #include #include "resource.h" #include "EconomicRateInfo.h" -// #include #include #include #pragma warning (disable:4996) @@ -11,52 +10,24 @@ #pragma warning (default:4996) #include "ModuleInfo.h" -// extern HMODULE g_hInstance; - -namespace +static IconItem iconList[] = { - struct CIconList - { - char* szDescr; - char* szName; - int defIconID; - HANDLE hIconLibItem; - }; - - CIconList iconList[] = - { - { LPGEN("Protocol icon"), ICON_STR_MAIN, IDI_ICON_MAIN }, - { LPGEN("Quote/Rate up"), ICON_STR_QUOTE_UP, IDI_ICON_UP }, - { LPGEN("Quote/Rate down"), ICON_STR_QUOTE_DOWN, IDI_ICON_DOWN }, - { LPGEN("Quote/Rate not changed"), ICON_STR_QUOTE_NOT_CHANGED, IDI_ICON_NOTCHANGED }, - { LPGEN("Quote Section"), ICON_STR_SECTION, IDI_ICON_SECTION }, - { LPGEN("Quote"), ICON_STR_QUOTE, IDI_ICON_QUOTE }, - { LPGEN("Currency Converter"), ICON_STR_CURRENCY_CONVERTER, IDI_ICON_CURRENCY_CONVERTER }, - { LPGEN("Refresh"), ICON_STR_REFRESH, IDI_ICON_REFRESH }, - { LPGEN("Export"), ICON_STR_EXPORT, IDI_ICON_EXPORT }, - { LPGEN("Swap button"), ICON_STR_SWAP, IDI_ICON_SWAP }, - { LPGEN("Import"), ICON_STR_IMPORT, IDI_ICON_IMPORT } - }; -} + { LPGEN("Protocol icon"), ICON_STR_MAIN, IDI_ICON_MAIN }, + { LPGEN("Quote/Rate up"), ICON_STR_QUOTE_UP, IDI_ICON_UP }, + { LPGEN("Quote/Rate down"), ICON_STR_QUOTE_DOWN, IDI_ICON_DOWN }, + { LPGEN("Quote/Rate not changed"), ICON_STR_QUOTE_NOT_CHANGED, IDI_ICON_NOTCHANGED }, + { LPGEN("Quote Section"), ICON_STR_SECTION, IDI_ICON_SECTION }, + { LPGEN("Quote"), ICON_STR_QUOTE, IDI_ICON_QUOTE }, + { LPGEN("Currency Converter"), ICON_STR_CURRENCY_CONVERTER, IDI_ICON_CURRENCY_CONVERTER }, + { LPGEN("Refresh"), ICON_STR_REFRESH, IDI_ICON_REFRESH }, + { LPGEN("Export"), ICON_STR_EXPORT, IDI_ICON_EXPORT }, + { LPGEN("Swap button"), ICON_STR_SWAP, IDI_ICON_SWAP }, + { LPGEN("Import"), ICON_STR_IMPORT, IDI_ICON_IMPORT } +}; void Quotes_IconsInit() { - TCHAR szFile[MAX_PATH]; - ::GetModuleFileName(g_hInstance, szFile, MAX_PATH); - - SKINICONDESC sid = { sizeof(sid) }; - sid.ptszDefaultFile = szFile; - sid.cx = sid.cy = 16; - sid.flags = SIDF_PATH_TCHAR; - sid.pszSection = QUOTES_PROTOCOL_NAME; - - for (int i = 0; i < SIZEOF(iconList); i++) { - std::string sName = Quotes_MakeIconName( iconList[i].szName); - sid.pszName = const_cast(sName.c_str()); - sid.pszDescription = iconList[i].szDescr; - sid.iDefaultIndex = -iconList[i].defIconID; - iconList[i].hIconLibItem = Skin_AddIcon(&sid); - } + ::Icon_Register(g_hInstance, QUOTES_PROTOCOL_NAME, iconList, SIZEOF(iconList), QUOTES_PROTOCOL_NAME); } std::string Quotes_MakeIconName(const char* name) @@ -78,14 +49,9 @@ HICON Quotes_LoadIconEx(const char* name,bool bBig /*= false*/) HANDLE Quotes_GetIconHandle(int iconId) { - for(int i=0;i < SIZEOF(iconList);i++) - { + for (int i=0; i < SIZEOF(iconList); i++) if(iconList[i].defIconID == iconId) - { - return iconList[i].hIconLibItem; - } - } + return iconList[i].hIcolib; return NULL; } - -- cgit v1.2.3