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 --- protocols/IRCG/src/irc.h | 3 +- protocols/IRCG/src/ircproto.cpp | 1 - protocols/IRCG/src/main.cpp | 4 +-- protocols/IRCG/src/options.cpp | 76 ++++++++++++----------------------------- 4 files changed, 24 insertions(+), 60 deletions(-) (limited to 'protocols/IRCG/src') diff --git a/protocols/IRCG/src/irc.h b/protocols/IRCG/src/irc.h index 9fe6584d87..6928d21dda 100644 --- a/protocols/IRCG/src/irc.h +++ b/protocols/IRCG/src/irc.h @@ -697,8 +697,7 @@ void UninitContactMenus(void); void WindowSetIcon(HWND hWnd, int iconId); void WindowFreeIcon(HWND hWnd); -void AddIcons(void); -void UninitIcons(void); +void InitIcons(void); HICON LoadIconEx(int iIndex, bool big = false); HANDLE GetIconHandle(int iconId); void ReleaseIconEx(HICON hIcon); diff --git a/protocols/IRCG/src/ircproto.cpp b/protocols/IRCG/src/ircproto.cpp index 3331c9aa93..0c384234c0 100644 --- a/protocols/IRCG/src/ircproto.cpp +++ b/protocols/IRCG/src/ircproto.cpp @@ -78,7 +78,6 @@ CIrcProto::CIrcProto( const char* szModuleName, const TCHAR* tszUserName ) : CallService( MS_DB_SETSETTINGRESIDENT, TRUE, ( LPARAM )text ); CList_SetAllOffline(true); - AddIcons(); IRC_MAP_ENTRY("PING", PING) IRC_MAP_ENTRY("JOIN", JOIN) diff --git a/protocols/IRCG/src/main.cpp b/protocols/IRCG/src/main.cpp index 0a2a5d70df..f6265a1c2b 100644 --- a/protocols/IRCG/src/main.cpp +++ b/protocols/IRCG/src/main.cpp @@ -89,10 +89,9 @@ static int ircProtoUninit( CIrcProto* ppro ) extern "C" int __declspec(dllexport) Load( ) { - mir_getLP( &pluginInfo ); - AddIcons(); + InitIcons(); InitTimers(); InitServers(); InitContactMenus(); @@ -112,7 +111,6 @@ extern "C" int __declspec(dllexport) Load( ) extern "C" int __declspec(dllexport) Unload(void) { UninitContactMenus(); - UninitIcons(); UninitTimers(); g_Instances.destroy(); diff --git a/protocols/IRCG/src/options.cpp b/protocols/IRCG/src/options.cpp index d7ed8753cc..a01e34822b 100644 --- a/protocols/IRCG/src/options.cpp +++ b/protocols/IRCG/src/options.cpp @@ -27,8 +27,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. static WNDPROC OldProc; static WNDPROC OldListViewProc; -static HANDLE* hIconLibItems; - static const CIrcProto* pZero = NULL; void CIrcProto::ReadSettings( TDbSetting* sets, int count ) @@ -191,66 +189,36 @@ static void removeSpaces( TCHAR* p ) ///////////////////////////////////////////////////////////////////////////////////////// // add icons to the skinning module -struct -{ - char* szDescr; - char* szName; - int iSize; - int defIconID; -} -static iconList[] = -{ - { LPGEN("Main"), "main", 0, IDI_MAIN }, - { LPGEN("Add"), "add", 0, IDI_ADD }, - { LPGEN("Apply"), "apply", 0, IDI_APPLY }, - { LPGEN("Rename"), "rename", 0, IDI_RENAME }, - { LPGEN("Edit"), "edit", 0, IDI_EDIT }, - { LPGEN("Cancel"), "delete", 0, IDI_DELETE }, - { LPGEN("Ignore"), "block", 0, IDI_BLOCK }, - { LPGEN("Channel list"), "list", 0, IDI_LIST }, - { LPGEN("Channel manager"), "manager", 0, IDI_MANAGER }, - { LPGEN("Quick connect"), "quick", 0, IDI_QUICK }, - { LPGEN("Server window"), "server", 0, IDI_SERVER }, - { LPGEN("Show channel"), "show", 0, IDI_SHOW }, - { LPGEN("Question"), "question", 0, IDI_IRCQUESTION}, - { LPGEN("WhoIs"), "whois", 0, IDI_WHOIS }, - { LPGEN("Incoming DCC Chat"), "dcc", 0, IDI_DCC }, - { LPGEN("Logo (48x48)"), "logo", 48, IDI_LOGO } +static IconItem iconList[] = +{ + { LPGEN("Main"), "main", IDI_MAIN, 0 }, + { LPGEN("Add"), "add", IDI_ADD, 0 }, + { LPGEN("Apply"), "apply", IDI_APPLY, 0 }, + { LPGEN("Rename"), "rename", IDI_RENAME, 0 }, + { LPGEN("Edit"), "edit", IDI_EDIT, 0 }, + { LPGEN("Cancel"), "delete", IDI_DELETE, 0 }, + { LPGEN("Ignore"), "block", IDI_BLOCK, 0 }, + { LPGEN("Channel list"), "list", IDI_LIST, 0 }, + { LPGEN("Channel manager"), "manager", IDI_MANAGER, 0 }, + { LPGEN("Quick connect"), "quick", IDI_QUICK, 0 }, + { LPGEN("Server window"), "server", IDI_SERVER, 0 }, + { LPGEN("Show channel"), "show", IDI_SHOW, 0 }, + { LPGEN("Question"), "question",IDI_IRCQUESTION, 0 }, + { LPGEN("WhoIs"), "whois", IDI_WHOIS, 0 }, + { LPGEN("Incoming DCC Chat"), "dcc", IDI_DCC, 0 }, + { LPGEN("Logo (48x48)"), "logo", IDI_LOGO, 48 } }; -void AddIcons(void) -{ - TCHAR szFile[MAX_PATH]; - GetModuleFileName(hInst, szFile, MAX_PATH); - - SKINICONDESC sid = { sizeof(sid) }; - sid.pszSection = "Protocols/IRC"; - sid.ptszDefaultFile = szFile; - sid.flags = SIDF_PATH_TCHAR; - hIconLibItems = new HANDLE[ SIZEOF(iconList) ]; - - // add them one by one - for ( int i=0; i < SIZEOF(iconList); i++ ) { - char szTemp[255]; - mir_snprintf(szTemp, sizeof(szTemp), "IRC_%s", iconList[i].szName ); - sid.pszName = szTemp; - sid.pszDescription = iconList[i].szDescr; - sid.iDefaultIndex = -iconList[i].defIconID; - sid.cx = sid.cy = iconList[i].iSize; - hIconLibItems[i] = Skin_AddIcon(&sid ); - } -} - -void UninitIcons(void) +void InitIcons(void) { - delete[] hIconLibItems; + Icon_Register(hInst, "Protocols/IRC", iconList, SIZEOF(iconList), "IRC"); } HICON LoadIconEx( int iconId, bool big ) { for ( int i=0; i < SIZEOF(iconList); i++ ) if ( iconList[i].defIconID == iconId ) - return Skin_GetIconByHandle(hIconLibItems[i], big); + return Skin_GetIconByHandle(iconList[i].hIcolib, big); return NULL; } @@ -259,7 +227,7 @@ HANDLE GetIconHandle( int iconId ) { for ( int i=0; i < SIZEOF(iconList); i++ ) if ( iconList[i].defIconID == iconId ) - return hIconLibItems[i]; + return iconList[i].hIcolib; return NULL; } -- cgit v1.2.3