summaryrefslogtreecommitdiff
path: root/protocols/Quotes/src/IconLib.cpp
diff options
context:
space:
mode:
authorKirill Volinsky <mataes2007@gmail.com>2012-10-13 09:49:24 +0000
committerKirill Volinsky <mataes2007@gmail.com>2012-10-13 09:49:24 +0000
commitf7d2c07c102d940727b0f053864c04ed32a76ff8 (patch)
tree07ee5f7aeb9a85341d39f5566a065899dd4de3e9 /protocols/Quotes/src/IconLib.cpp
parent221fd937a28a3254936c65ca06a98713e41528cc (diff)
Quotes: folders restructurization
git-svn-id: http://svn.miranda-ng.org/main/trunk@1905 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/Quotes/src/IconLib.cpp')
-rw-r--r--protocols/Quotes/src/IconLib.cpp106
1 files changed, 106 insertions, 0 deletions
diff --git a/protocols/Quotes/src/IconLib.cpp b/protocols/Quotes/src/IconLib.cpp
new file mode 100644
index 0000000000..b131aa7009
--- /dev/null
+++ b/protocols/Quotes/src/IconLib.cpp
@@ -0,0 +1,106 @@
+#include "StdAfx.h"
+#include "IconLib.h"
+#include <m_icolib.h>
+#include "resource.h"
+#include "EconomicRateInfo.h"
+// #include <newpluginapi.h>
+#include <m_langpack.h>
+#include <sstream>
+#pragma warning (disable:4996)
+#include <m_utils.h>
+#pragma warning (default:4996)
+#include "ModuleInfo.h"
+
+// extern HMODULE g_hInstance;
+
+namespace
+{
+ struct CIconList
+ {
+ TCHAR* szDescr;
+ char* szName;
+ int defIconID;
+// TCHAR* szSection;
+ HANDLE hIconLibItem;
+ };
+
+ CIconList iconList[] =
+ {
+ {_T("Protocol icon"),ICON_STR_MAIN,IDI_ICON_MAIN},
+ {_T("Quote/Rate up"),ICON_STR_QUOTE_UP,IDI_ICON_UP},
+ {_T("Quote/Rate down"),ICON_STR_QUOTE_DOWN,IDI_ICON_DOWN},
+ {_T("Quote/Rate not changed"),ICON_STR_QUOTE_NOT_CHANGED,IDI_ICON_NOTCHANGED},
+ {_T("Quote Section"),ICON_STR_SECTION,IDI_ICON_SECTION},
+ {_T("Quote"),ICON_STR_QUOTE,IDI_ICON_QUOTE},
+ {_T("Currency Converter"),ICON_STR_CURRENCY_CONVERTER,IDI_ICON_CURRENCY_CONVERTER},
+ {_T("Refresh"),ICON_STR_REFRESH,IDI_ICON_REFRESH},
+ {_T("Export"),ICON_STR_EXPORT,IDI_ICON_EXPORT},
+ {_T("Swap button"),ICON_STR_SWAP,IDI_ICON_SWAP},
+ {_T("Import"),ICON_STR_IMPORT,IDI_ICON_IMPORT},
+ };
+}
+
+void Quotes_IconsInit()
+{
+ USES_CONVERSION;
+
+ SKINICONDESC sid = {0};
+ TCHAR szFile[MAX_PATH];
+ ::GetModuleFileName(g_hInstance, szFile, MAX_PATH);
+
+ sid.cbSize = sizeof(SKINICONDESC);
+ sid.ptszDefaultFile = szFile;
+ sid.cx = sid.cy = 16;
+ sid.flags = SIDF_ALL_TCHAR;
+ sid.ptszSection = A2T(QUOTES_PROTOCOL_NAME);
+
+// TCHAR* szRootSection = TranslateTS(A2T(QUOTES_PROTOCOL_NAME));
+
+ for ( int i = 0; i < SIZEOF(iconList); i++ )
+ {
+// char szSettingName[100];
+// TCHAR szSectionName[100];
+// mir_snprintf( szSettingName, sizeof( szSettingName ),"%s_%s",QUOTES_PROTOCOL_NAME, iconList[i].szName );
+// {
+// mir_sntprintf( szSectionName, SIZEOF( szSectionName ),_T("%s/%s"), TranslateT("Protocols"), szRootSection);
+// sid.ptszSection = szSectionName;
+// }
+
+ std::string sName = Quotes_MakeIconName( iconList[i].szName);
+ sid.pszName = const_cast<char*>(sName.c_str());
+ sid.ptszDescription = iconList[i].szDescr;
+ sid.iDefaultIndex = -iconList[i].defIconID;
+ iconList[i].hIconLibItem = Skin_AddIcon(&sid);
+ }
+}
+
+std::string Quotes_MakeIconName(const char* name)
+{
+ assert(name);
+ //char szSettingName[100];
+ //mir_snprintf(szSettingName,SIZEOF(szSettingName),"%s_%s",QUOTES_PROTOCOL_NAME,name);
+ std::string sName(QUOTES_PROTOCOL_NAME);
+ sName += "_";
+ sName += name;
+ return sName;
+}
+
+HICON Quotes_LoadIconEx(const char* name,bool bBig /*= false*/)
+{
+ std::string sIconName = Quotes_MakeIconName(name);
+ return reinterpret_cast<HICON>(CallService( MS_SKIN2_GETICON,((bBig) ? 1 : 0),reinterpret_cast<LPARAM>(sIconName.c_str())));
+}
+
+HANDLE Quotes_GetIconHandle(int iconId)
+{
+ for(int i=0;i < SIZEOF(iconList);i++)
+ {
+ if(iconList[i].defIconID == iconId)
+ {
+ return iconList[i].hIconLibItem;
+ }
+ }
+
+ return NULL;
+}
+