diff options
80 files changed, 1818 insertions, 2001 deletions
diff --git a/include/m_icolib.h b/include/m_icolib.h index f9056b2a58..1ec7ee74f7 100644 --- a/include/m_icolib.h +++ b/include/m_icolib.h @@ -24,14 +24,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #ifndef M_ICOLIB_H__
#define M_ICOLIB_H__ 1
-#define SKINICONDESC_SIZE sizeof(SKINICONDESC) // v0.0.1.0+
-#define SKINICONDESC_SIZE_V1 (offsetof(SKINICONDESC, hDefaultIcon))
-#define SKINICONDESC_SIZE_V2 (offsetof(SKINICONDESC, cx)) // v0.0.0.2+
-#define SKINICONDESC_SIZE_V3 (offsetof(SKINICONDESC, flags)) // v0.0.0.3+
+extern int hLangpack;
// WARNING: do not use Translate(TS) for p(t)szSection or p(t)szDescription as they
// are translated by the core, which may lead to double translation.
// Use LPGEN instead which are just dummy wrappers/markers for "lpgen.pl".
+
typedef struct {
size_t cbSize;
union {
@@ -71,17 +69,14 @@ typedef struct { #define SIDF_ALL_TCHAR 0
#endif
-//
// Add a icon into options UI
//
// wParam = (WPARAM)0
// lParam = (LPARAM)(SKINICONDESC*)sid;
// returns a handle to the newly added item
-//
-#define MS_SKIN2_ADDICON "Skin2/Icons/AddIcon"
__inline static HANDLE Skin_AddIcon(SKINICONDESC* si)
-{ return (HANDLE)CallService(MS_SKIN2_ADDICON, 0, (LPARAM)si);
+{ return (HANDLE)CallService("Skin2/Icons/AddIcon", hLangpack, (LPARAM)si);
}
//
diff --git a/plugins/AddContactPlus/main.cpp b/plugins/AddContactPlus/main.cpp index 402b9d5ecb..95f1fac93d 100644 --- a/plugins/AddContactPlus/main.cpp +++ b/plugins/AddContactPlus/main.cpp @@ -160,7 +160,7 @@ static int OnModulesLoaded(WPARAM, LPARAM) sid.iDefaultIndex = -IDI_ADDCONTACT;
sid.ptszDescription = LPGENT("Add Contact");
sid.pszName = ICON_ADD;
- hIconLibItem = (HANDLE)CallService(MS_SKIN2_ADDICON, (WPARAM)0, (LPARAM)&sid);
+ hIconLibItem = Skin_AddIcon(&sid);
hChangedIcons = HookEvent(ME_SKIN2_ICONSCHANGED, OnIconsChanged);
HOTKEYDESC hkd = {0};
diff --git a/plugins/Alarms/alarms.cpp b/plugins/Alarms/alarms.cpp index c0dc60bb85..3c0a198716 100644 --- a/plugins/Alarms/alarms.cpp +++ b/plugins/Alarms/alarms.cpp @@ -294,10 +294,10 @@ static int MainInit(WPARAM wparam,LPARAM lparam) { return 0;
}
-static int MainDeInit(WPARAM wParam, LPARAM lParam) {
+static int MainDeInit(WPARAM wParam, LPARAM lParam)
+{
DeinitFrames();
DeinitList();
- DeinitIcons();
return 0;
}
diff --git a/plugins/Alarms/icons.cpp b/plugins/Alarms/icons.cpp index fe6abf834d..5a07541e27 100644 --- a/plugins/Alarms/icons.cpp +++ b/plugins/Alarms/icons.cpp @@ -5,7 +5,8 @@ HANDLE hIcoLibIconsChanged; HICON hIconMenuSet, hIconList1, hIconList2, hIconMenuShowHide, hIconSystray;
-int ReloadIcons(WPARAM wParam, LPARAM lParam) {
+int ReloadIcons(WPARAM wParam, LPARAM lParam)
+{
hIconMenuSet = (HICON)CallService(MS_SKIN2_GETICON, 0, (LPARAM)"alarms_menu_set");
hIconList1 = (HICON)CallService(MS_SKIN2_GETICON, 0, (LPARAM)"alarms_list1");
hIconList2 = (HICON)CallService(MS_SKIN2_GETICON, 0, (LPARAM)"alarms_list2");
@@ -16,76 +17,55 @@ int ReloadIcons(WPARAM wParam, LPARAM lParam) { return 0;
}
-void InitIcons() {
- if (ServiceExists(MS_SKIN2_ADDICON)) {
- SKINICONDESC sid = {0};
-
- sid.cbSize = sizeof(SKINICONDESC);
- sid.pszSection = Translate("Alarms");
-
- sid.pszDescription = Translate("Menu: Set Alarm");
- sid.pszName = "alarms_menu_set";
+void InitIcons()
+{
+ SKINICONDESC sid = {0};
+
+ sid.cbSize = sizeof(SKINICONDESC);
+ sid.pszSection = "Alarms";
+
+ sid.pszDescription = "Menu: Set Alarm";
+ sid.pszName = "alarms_menu_set";
+ sid.pszDefaultFile = "alarms.dll";
+ sid.iDefaultIndex = 0;
+ sid.hDefaultIcon = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_MAINMENU), IMAGE_ICON, 16, 16, 0);
+ Skin_AddIcon(&sid);
+
+ sid.pszDescription = "Reminder: Soon";
+ sid.pszName = "alarms_list1";
+ sid.pszDefaultFile = "alarms.dll";
+ sid.iDefaultIndex = 1;
+ sid.hDefaultIcon = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_LIST1), IMAGE_ICON, 16, 16, 0);//LR_LOADTRANSPARENT | LR_LOADMAP3DCOLORS ); Skin_AddIcon(&sid);
+
+ sid.pszDescription = "Reminder: Very Soon";
+ sid.pszName = "alarms_list2";
+ sid.pszDefaultFile = "alarms.dll";
+ sid.iDefaultIndex = 2;
+ sid.hDefaultIcon = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_LIST2), IMAGE_ICON, 16, 16, 0);//LR_LOADTRANSPARENT | LR_LOADMAP3DCOLORS );
+ Skin_AddIcon(&sid);
+
+ sid.pszDescription = "Alarm: System Tray";
+ sid.pszName = "alarms_systray";
+ sid.pszDefaultFile = "alarms.dll";
+ sid.iDefaultIndex = 3;
+ sid.hDefaultIcon = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_MAINMENU), IMAGE_ICON, 16, 16, 0);//LR_LOADTRANSPARENT | LR_LOADMAP3DCOLORS );
+ Skin_AddIcon(&sid);
+
+ if (!ServiceExists(MS_CLIST_FRAMES_ADDFRAME)) {
+ sid.pszDescription = "Menu: Show/Hide Reminders";
+ sid.pszName = "alarms_menu_showhide";
sid.pszDefaultFile = "alarms.dll";
- sid.iDefaultIndex = 0;
+ sid.iDefaultIndex = 4;
sid.hDefaultIcon = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_MAINMENU), IMAGE_ICON, 16, 16, 0);
- CallService(MS_SKIN2_ADDICON, 0, (LPARAM)&sid);
-
- sid.pszDescription = Translate("Reminder: Soon");
- sid.pszName = "alarms_list1";
- sid.pszDefaultFile = "alarms.dll";
- sid.iDefaultIndex = 1;
- sid.hDefaultIcon = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_LIST1), IMAGE_ICON, 16, 16, 0);//LR_LOADTRANSPARENT | LR_LOADMAP3DCOLORS );
- CallService(MS_SKIN2_ADDICON, 0, (LPARAM)&sid);
-
- sid.pszDescription = Translate("Reminder: Very Soon");
- sid.pszName = "alarms_list2";
- sid.pszDefaultFile = "alarms.dll";
- sid.iDefaultIndex = 2;
- sid.hDefaultIcon = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_LIST2), IMAGE_ICON, 16, 16, 0);//LR_LOADTRANSPARENT | LR_LOADMAP3DCOLORS );
- CallService(MS_SKIN2_ADDICON, 0, (LPARAM)&sid);
-
- sid.pszDescription = Translate("Alarm: System Tray");
- sid.pszName = "alarms_systray";
- sid.pszDefaultFile = "alarms.dll";
- sid.iDefaultIndex = 3;
- sid.hDefaultIcon = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_MAINMENU), IMAGE_ICON, 16, 16, 0);//LR_LOADTRANSPARENT | LR_LOADMAP3DCOLORS );
- CallService(MS_SKIN2_ADDICON, 0, (LPARAM)&sid);
-
- if (!ServiceExists(MS_CLIST_FRAMES_ADDFRAME)) {
- sid.pszDescription = Translate("Menu: Show/Hide Reminders");
- sid.pszName = "alarms_menu_showhide";
- sid.pszDefaultFile = "alarms.dll";
- sid.iDefaultIndex = 4;
- sid.hDefaultIcon = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_MAINMENU), IMAGE_ICON, 16, 16, 0);
- CallService(MS_SKIN2_ADDICON, 0, (LPARAM)&sid);
+ Skin_AddIcon(&sid);
- hIconMenuShowHide = (HICON)CallService(MS_SKIN2_GETICON, 0, (LPARAM)"alarms_menu_showhide");
- }
-
- hIconMenuSet = (HICON)CallService(MS_SKIN2_GETICON, 0, (LPARAM)"alarms_menu_set");
- hIconList1 = (HICON)CallService(MS_SKIN2_GETICON, 0, (LPARAM)"alarms_list1");
- hIconList2 = (HICON)CallService(MS_SKIN2_GETICON, 0, (LPARAM)"alarms_list2");
- hIconSystray = (HICON)CallService(MS_SKIN2_GETICON, 0, (LPARAM)"alarms_systray");
-
- hIcoLibIconsChanged = HookEvent(ME_SKIN2_ICONSCHANGED, ReloadIcons);
- } else {
- hIconMenuSet = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_MAINMENU), IMAGE_ICON, 16, 16, 0);//LR_LOADTRANSPARENT | LR_LOADMAP3DCOLORS );
- hIconList1 = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_LIST1), IMAGE_ICON, 16, 16, 0);//LR_LOADTRANSPARENT | LR_LOADMAP3DCOLORS );
- hIconList2 = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_LIST2), IMAGE_ICON, 16, 16, 0);//LR_LOADTRANSPARENT | LR_LOADMAP3DCOLORS );
- hIconSystray = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_MAINMENU), IMAGE_ICON, 16, 16, 0);//LR_LOADTRANSPARENT | LR_LOADMAP3DCOLORS );
- if (!ServiceExists(MS_CLIST_FRAMES_ADDFRAME))
- hIconMenuShowHide = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_MAINMENU), IMAGE_ICON, 16, 16, 0);//LR_LOADTRANSPARENT | LR_LOADMAP3DCOLORS );
+ hIconMenuShowHide = (HICON)CallService(MS_SKIN2_GETICON, 0, (LPARAM)"alarms_menu_showhide");
}
-}
+ hIconMenuSet = (HICON)CallService(MS_SKIN2_GETICON, 0, (LPARAM)"alarms_menu_set");
+ hIconList1 = (HICON)CallService(MS_SKIN2_GETICON, 0, (LPARAM)"alarms_list1");
+ hIconList2 = (HICON)CallService(MS_SKIN2_GETICON, 0, (LPARAM)"alarms_list2");
+ hIconSystray = (HICON)CallService(MS_SKIN2_GETICON, 0, (LPARAM)"alarms_systray");
-void DeinitIcons() {
- if (!ServiceExists(MS_SKIN2_ADDICON)) {
- DestroyIcon(hIconMenuSet);
- DestroyIcon(hIconList1);
- DestroyIcon(hIconList2);
- DestroyIcon(hIconSystray);
- if (!ServiceExists(MS_CLIST_FRAMES_ADDFRAME))
- DestroyIcon(hIconMenuShowHide);
- }
+ hIcoLibIconsChanged = HookEvent(ME_SKIN2_ICONSCHANGED, ReloadIcons);
}
diff --git a/plugins/Alarms/icons.h b/plugins/Alarms/icons.h index 89226dd5d4..d47228f952 100644 --- a/plugins/Alarms/icons.h +++ b/plugins/Alarms/icons.h @@ -6,7 +6,6 @@ extern HICON hIconMenuSet, hIconList1, hIconList2, hIconMenuShowHide, hIconSystray;
void InitIcons();
-void DeinitIcons();
#endif
diff --git a/plugins/AuthState/main.cpp b/plugins/AuthState/main.cpp index 890e3689b1..91e80262c4 100644 --- a/plugins/AuthState/main.cpp +++ b/plugins/AuthState/main.cpp @@ -151,20 +151,10 @@ int onExtraImageListRebuild(WPARAM wParam, LPARAM lParam) g_IECAuthGrant.cbSize = sizeof(IconExtraColumn);
g_IECAuthGrant.ColumnType = clistIcon;
- if (ServiceExists(MS_CLIST_EXTRA_ADD_ICON))
- {
- if (ServiceExists(MS_SKIN2_ADDICON))
- {
- g_IECAuth.hImage = (HANDLE)CallService(MS_CLIST_EXTRA_ADD_ICON, (WPARAM)(HICON) CallService(MS_SKIN2_GETICON, 0, (LPARAM)"auth_icon"), (LPARAM)0);
- g_IECGrant.hImage = (HANDLE)CallService(MS_CLIST_EXTRA_ADD_ICON, (WPARAM)(HICON) CallService(MS_SKIN2_GETICON, 0, (LPARAM)"grant_icon"), (LPARAM)0);
- g_IECAuthGrant.hImage = (HANDLE)CallService(MS_CLIST_EXTRA_ADD_ICON, (WPARAM)(HICON) CallService(MS_SKIN2_GETICON, 0, (LPARAM)"authgrant_icon"), (LPARAM)0);
- }
- else
- {
- g_IECAuth.hImage = (HANDLE)CallService(MS_CLIST_EXTRA_ADD_ICON, (WPARAM)LoadImage(g_hInst, MAKEINTRESOURCE(IDI_AUTH), IMAGE_ICON, 16, 16, LR_SHARED), (LPARAM)0);
- g_IECGrant.hImage = (HANDLE)CallService(MS_CLIST_EXTRA_ADD_ICON, (WPARAM)LoadImage(g_hInst, MAKEINTRESOURCE(IDI_GRANT), IMAGE_ICON, 16, 16, LR_SHARED), (LPARAM)0);
- g_IECAuthGrant.hImage = (HANDLE)CallService(MS_CLIST_EXTRA_ADD_ICON, (WPARAM)LoadImage(g_hInst, MAKEINTRESOURCE(IDI_AUTHGRANT), IMAGE_ICON, 16, 16, LR_SHARED), (LPARAM)0);
- }
+ if (ServiceExists(MS_CLIST_EXTRA_ADD_ICON)) {
+ g_IECAuth.hImage = (HANDLE)CallService(MS_CLIST_EXTRA_ADD_ICON, (WPARAM)(HICON) CallService(MS_SKIN2_GETICON, 0, (LPARAM)"auth_icon"), (LPARAM)0);
+ g_IECGrant.hImage = (HANDLE)CallService(MS_CLIST_EXTRA_ADD_ICON, (WPARAM)(HICON) CallService(MS_SKIN2_GETICON, 0, (LPARAM)"grant_icon"), (LPARAM)0);
+ g_IECAuthGrant.hImage = (HANDLE)CallService(MS_CLIST_EXTRA_ADD_ICON, (WPARAM)(HICON) CallService(MS_SKIN2_GETICON, 0, (LPARAM)"authgrant_icon"), (LPARAM)0);
}
return 0;
@@ -236,40 +226,34 @@ int onPrebuildContactMenu(WPARAM wParam, LPARAM lParam) int onModulesLoaded(WPARAM wParam,LPARAM lParam)
{
- // hHookExtraIconsRebuild = HookEvent(ME_CLIST_EXTRA_LIST_REBUILD, onExtraImageListRebuild);
- // hHookExtraIconsApply = HookEvent(ME_CLIST_EXTRA_IMAGE_APPLY, onExtraImageApplying);
// IcoLib support
- if (ServiceExists(MS_SKIN2_ADDICON))
- {
- SKINICONDESC sid = {0};
- ZeroMemory(&sid, sizeof(sid));
- TCHAR szFile[MAX_PATH];
- sid.cbSize = sizeof(sid);
- sid.flags = SIDF_ALL_TCHAR;
-
- sid.ptszSection = _T("Auth State");
- GetModuleFileName(g_hInst, szFile, MAX_PATH);
- sid.ptszDefaultFile = szFile;
-
- sid.ptszDescription = _T("Auth");
- sid.pszName = "auth_icon";
- sid.iDefaultIndex = -IDI_AUTH;
- CallService(MS_SKIN2_ADDICON, 0, (LPARAM)&sid);
-
- sid.ptszDescription = _T("Grant");
- sid.pszName = "grant_icon";
- sid.iDefaultIndex = -IDI_GRANT;
- CallService(MS_SKIN2_ADDICON, 0, (LPARAM)&sid);
-
- sid.ptszDescription = _T("Auth & Grant");
- sid.pszName = "authgrant_icon";
- sid.iDefaultIndex = -IDI_AUTHGRANT;
- CallService(MS_SKIN2_ADDICON, 0, (LPARAM)&sid);
-
- // hIcoLibIconsChanged = HookEvent(ME_SKIN2_ICONSCHANGED, onExtraImageListRebuild);
- }
+ SKINICONDESC sid = {0};
+ ZeroMemory(&sid, sizeof(sid));
+ TCHAR szFile[MAX_PATH];
+ sid.cbSize = sizeof(sid);
+ sid.flags = SIDF_ALL_TCHAR;
+
+ sid.ptszSection = _T("Auth State");
+ GetModuleFileName(g_hInst, szFile, MAX_PATH);
+ sid.ptszDefaultFile = szFile;
+
+ sid.ptszDescription = _T("Auth");
+ sid.pszName = "auth_icon";
+ sid.iDefaultIndex = -IDI_AUTH;
+ Skin_AddIcon(&sid);
+
+ sid.ptszDescription = _T("Grant");
+ sid.pszName = "grant_icon";
+ sid.iDefaultIndex = -IDI_GRANT;
+ Skin_AddIcon(&sid);
+
+ sid.ptszDescription = _T("Auth & Grant");
+ sid.pszName = "authgrant_icon";
+ sid.iDefaultIndex = -IDI_AUTHGRANT;
+ Skin_AddIcon(&sid);
+
+ // extra icons
hExtraIcon = ExtraIcon_Register("authstate", "Auth State", "authgrant_icon");
-
if (hExtraIcon != NULL)
{
// Set initial value for all contacts
@@ -280,8 +264,7 @@ int onModulesLoaded(WPARAM wParam,LPARAM lParam) hContact = (HANDLE) CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM) hContact, 0);
}
}
- else
- {
+ else {
hIcoLibIconsChanged = HookEvent(ME_SKIN2_ICONSCHANGED, onExtraImageListRebuild);
hHookExtraIconsRebuild = HookEvent(ME_CLIST_EXTRA_LIST_REBUILD, onExtraImageListRebuild);
hHookExtraIconsApply = HookEvent(ME_CLIST_EXTRA_IMAGE_APPLY, onExtraImageApplying);
@@ -291,8 +274,7 @@ int onModulesLoaded(WPARAM wParam,LPARAM lParam) if (bContactMenuItem) hPrebuildContactMenu = HookEvent(ME_CLIST_PREBUILDCONTACTMENU, onPrebuildContactMenu);
// Updater support
- if (ServiceExists(MS_UPDATE_REGISTER))
- {
+ if (ServiceExists(MS_UPDATE_REGISTER)) {
Update update = {0};
char szVersion[16];
diff --git a/plugins/BASS_interface/Main.cpp b/plugins/BASS_interface/Main.cpp index fa214604b9..e667325770 100644 --- a/plugins/BASS_interface/Main.cpp +++ b/plugins/BASS_interface/Main.cpp @@ -333,7 +333,7 @@ void InitIcons(void) sid.pszDescription = (char*)iconList[i].szDescr;
sid.iDefaultIndex = -iconList[i].defIconID;
- hIconLibItem[i] = (HANDLE)CallService(MS_SKIN2_ADDICON, 0, (LPARAM)&sid);
+ hIconLibItem[i] = Skin_AddIcon(&sid);
}
}
diff --git a/plugins/BasicHistory/BasicHistory.cpp b/plugins/BasicHistory/BasicHistory.cpp index 975cd061ed..9d1a3f0204 100644 --- a/plugins/BasicHistory/BasicHistory.cpp +++ b/plugins/BasicHistory/BasicHistory.cpp @@ -233,47 +233,47 @@ void InitIcolib() sid.pszName = "BasicHistory_in";
sid.ptszDescription = LPGENT("Incoming message");
sid.iDefaultIndex = -IDI_INM;
- hEventIcons[0] = (HANDLE)CallService(MS_SKIN2_ADDICON, 0, (LPARAM)&sid);
+ hEventIcons[0] = Skin_AddIcon(&sid);
sid.pszName = "BasicHistory_out";
sid.ptszDescription = LPGENT("Outgoing message");
sid.iDefaultIndex = -IDI_OUTM;
- hEventIcons[1] = (HANDLE)CallService(MS_SKIN2_ADDICON, 0, (LPARAM)&sid);
+ hEventIcons[1] = Skin_AddIcon(&sid);
sid.pszName = "BasicHistory_status";
sid.ptszDescription = LPGENT("Statuschange");
sid.iDefaultIndex = -IDI_STATUS;
- hEventIcons[2] = (HANDLE)CallService(MS_SKIN2_ADDICON, 0, (LPARAM)&sid);
+ hEventIcons[2] = Skin_AddIcon(&sid);
sid.pszName = "BasicHistory_show";
sid.ptszDescription = LPGENT("Show Contacts");
sid.iDefaultIndex = -IDI_SHOW;
- hPlusIcon = (HANDLE)CallService(MS_SKIN2_ADDICON, 0, (LPARAM)&sid);
+ hPlusIcon = Skin_AddIcon(&sid);
sid.pszName = "BasicHistory_hide";
sid.ptszDescription = LPGENT("Hide Contacts");
sid.iDefaultIndex = -IDI_HIDE;
- hMinusIcon = (HANDLE)CallService(MS_SKIN2_ADDICON, 0, (LPARAM)&sid);
+ hMinusIcon = Skin_AddIcon(&sid);
sid.pszName = "BasicHistory_findnext";
sid.ptszDescription = LPGENT("Find Next");
sid.iDefaultIndex = -IDI_FINDNEXT;
- hFindNextIcon = (HANDLE)CallService(MS_SKIN2_ADDICON, 0, (LPARAM)&sid);
+ hFindNextIcon = Skin_AddIcon(&sid);
sid.pszName = "BasicHistory_findprev";
sid.ptszDescription = LPGENT("Find Previous");
sid.iDefaultIndex = -IDI_FINDPREV;
- hFindPrevIcon = (HANDLE)CallService(MS_SKIN2_ADDICON, 0, (LPARAM)&sid);
+ hFindPrevIcon = Skin_AddIcon(&sid);
sid.pszName = "BasicHistory_plusex";
sid.ptszDescription = LPGENT("Plus in export");
sid.iDefaultIndex = -IDI_PLUSEX;
- hPlusExIcon = (HANDLE)CallService(MS_SKIN2_ADDICON, 0, (LPARAM)&sid);
+ hPlusExIcon = Skin_AddIcon(&sid);
sid.pszName = "BasicHistory_minusex";
sid.ptszDescription = LPGENT("Minus in export");
sid.iDefaultIndex = -IDI_MINUSEX;
- hMinusExIcon = (HANDLE)CallService(MS_SKIN2_ADDICON, 0, (LPARAM)&sid);
+ hMinusExIcon = Skin_AddIcon(&sid);
}
void InitUpdater()
diff --git a/plugins/BossKeyPlus/BossKey.cpp b/plugins/BossKeyPlus/BossKey.cpp index 6888a5347b..08d9dceed0 100644 --- a/plugins/BossKeyPlus/BossKey.cpp +++ b/plugins/BossKeyPlus/BossKey.cpp @@ -625,7 +625,7 @@ static int IcoLibInit (void) // Icolib support sid.pszName = "hidemim";
sid.ptszDescription = _T("Hide Miranda IM");
sid.iDefaultIndex = -IDI_DLGPASSWD;
- g_hIcon = (HANDLE)CallService(MS_SKIN2_ADDICON, 0, (LPARAM)&sid);
+ g_hIcon = Skin_AddIcon(&sid);
return 0;
}
diff --git a/plugins/BuddyExpectator/BuddyExpectator.cpp b/plugins/BuddyExpectator/BuddyExpectator.cpp index 19e02d446a..e31bdf06c2 100644 --- a/plugins/BuddyExpectator/BuddyExpectator.cpp +++ b/plugins/BuddyExpectator/BuddyExpectator.cpp @@ -484,15 +484,7 @@ INT_PTR ContactStillAbsentAction(WPARAM wParam, LPARAM lParam) */
int onIconsChanged(WPARAM wParam, LPARAM lParam)
{
- if (ServiceExists(MS_SKIN2_ADDICON))
- {
- hIcon = (HICON)CallService(MS_SKIN2_GETICON, 0, (LPARAM)"main_icon");
- }
- else
- {
- hIcon = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_MAINICON), IMAGE_ICON, 16, 16, 0);
- }
-
+ hIcon = (HICON)CallService(MS_SKIN2_GETICON, 0, (LPARAM)"main_icon");
return 0;
}
@@ -563,16 +555,7 @@ int onExtraImageListRebuild(WPARAM wParam, LPARAM lParam) g_IECMissYou.ColumnType = options.MissYouIcon;
if (ServiceExists(MS_CLIST_EXTRA_ADD_ICON))
- {
- if (ServiceExists(MS_SKIN2_ADDICON))
- {
- g_IECMissYou.hImage = (HANDLE)CallService(MS_CLIST_EXTRA_ADD_ICON, (WPARAM)(HICON) CallService(MS_SKIN2_GETICON, 0, (LPARAM)"enabled_icon"), (LPARAM)0);
- }
- else
- {
- g_IECMissYou.hImage = (HANDLE)CallService(MS_CLIST_EXTRA_ADD_ICON, (WPARAM)LoadImage(hInst, MAKEINTRESOURCE(IDI_ENABLED), IMAGE_ICON, 16, 16, LR_SHARED), (LPARAM)0);
- }
- }
+ g_IECMissYou.hImage = (HANDLE)CallService(MS_CLIST_EXTRA_ADD_ICON, (WPARAM)(HICON) CallService(MS_SKIN2_GETICON, 0, (LPARAM)"enabled_icon"), (LPARAM)0);
return 0;
}
@@ -767,48 +750,43 @@ int ModulesLoaded(WPARAM wParam, LPARAM lParam) }
// IcoLib support
- if (ServiceExists(MS_SKIN2_ADDICON))
- {
- SKINICONDESC sid = {0};
- char szFile[MAX_PATH];
- GetModuleFileNameA(hInst, szFile, MAX_PATH);
- sid.pszDefaultFile = szFile;
- sid.cbSize = SKINICONDESC_SIZE_V1;
-
- sid.pszSection = Translate("BuddyExpectator");
+ SKINICONDESC sid = {0};
+ char szFile[MAX_PATH];
+ GetModuleFileNameA(hInst, szFile, MAX_PATH);
+ sid.pszDefaultFile = szFile;
+ sid.cbSize = sizeof(sid);
+ sid.pszSection = "BuddyExpectator";
- sid.pszDescription = Translate("Tray/popup icon");
- sid.pszName = "main_icon";
- sid.iDefaultIndex = -IDI_MAINICON;
- CallService(MS_SKIN2_ADDICON, 0, (LPARAM)&sid);
+ sid.pszDescription = "Tray/popup icon";
+ sid.pszName = "main_icon";
+ sid.iDefaultIndex = -IDI_MAINICON;
+ Skin_AddIcon(&sid);
- sid.pszDescription = Translate("Enabled");
- sid.pszName = "enabled_icon";
- sid.iDefaultIndex = -IDI_ENABLED;
- hEnabledIcon = (HANDLE)CallService(MS_SKIN2_ADDICON, 0, (LPARAM)&sid);
+ sid.pszDescription = "Enabled";
+ sid.pszName = "enabled_icon";
+ sid.iDefaultIndex = -IDI_ENABLED;
+ hEnabledIcon = Skin_AddIcon(&sid);
- sid.pszDescription = Translate("Disabled");
- sid.pszName = "disabled_icon";
- sid.iDefaultIndex = -IDI_DISABLED;
- hDisabledIcon = (HANDLE)CallService(MS_SKIN2_ADDICON, 0, (LPARAM)&sid);
+ sid.pszDescription = "Disabled";
+ sid.pszName = "disabled_icon";
+ sid.iDefaultIndex = -IDI_DISABLED;
+ hDisabledIcon = Skin_AddIcon(&sid);
- sid.pszDescription = Translate("Hide");
- sid.pszName = "hide_icon";
- sid.iDefaultIndex = -IDI_HIDE;
- CallService(MS_SKIN2_ADDICON, 0, (LPARAM)&sid);
+ sid.pszDescription = "Hide";
+ sid.pszName = "hide_icon";
+ sid.iDefaultIndex = -IDI_HIDE;
+ Skin_AddIcon(&sid);
- sid.pszDescription = Translate("NeverHide");
- sid.pszName = "neverhide_icon";
- sid.iDefaultIndex = -IDI_NEVERHIDE;
- CallService(MS_SKIN2_ADDICON, 0, (LPARAM)&sid);
+ sid.pszDescription = "NeverHide";
+ sid.pszName = "neverhide_icon";
+ sid.iDefaultIndex = -IDI_NEVERHIDE;
+ Skin_AddIcon(&sid);
- hIcoLibIconsChanged = HookEvent(ME_SKIN2_ICONSCHANGED, onIconsChanged);
- }
+ hIcoLibIconsChanged = HookEvent(ME_SKIN2_ICONSCHANGED, onIconsChanged);
onIconsChanged(0,0);
- if (options.enableMissYou)
- {
+ if (options.enableMissYou) {
hPrebuildContactMenu = HookEvent(ME_CLIST_PREBUILDCONTACTMENU, onPrebuildContactMenu);
CLISTMENUITEM mi = {0};
diff --git a/plugins/CSList/cslist.cpp b/plugins/CSList/cslist.cpp index 42740beb52..5050ec39f5 100644 --- a/plugins/CSList/cslist.cpp +++ b/plugins/CSList/cslist.cpp @@ -323,9 +323,6 @@ void CSList::setStatus( WORD code, StatusItem* item, char* protoName) void CSList::initIcoLib( )
{
- if ( !ServiceExists( MS_SKIN2_ADDICON ))
- return;
-
// init icons of buttons
TCHAR tszFile[MAX_PATH];
GetModuleFileName( CSList::handle, tszFile, MAX_PATH );
@@ -337,15 +334,14 @@ void CSList::initIcoLib( ) sid.cx = sid.cy = 16;
sid.ptszSection = _T(MODULENAME);
- for ( int i = 0; i < SIZEOF(forms); i++ )
- {
+ for (int i=0; i < SIZEOF(forms); i++ ) {
char szSettingName[64];
mir_snprintf( szSettingName, SIZEOF(szSettingName), "%s_%s", __INTERNAL_NAME, forms[i].pszIconIcoLib );
sid.pszName = szSettingName;
sid.ptszDescription = forms[i].ptszDescr;
sid.iDefaultIndex = -forms[i].iconNoIcoLib;
- forms[i].hIcoLibItem = ( HANDLE )CallService( MS_SKIN2_ADDICON, 0, ( LPARAM )&sid );
+ forms[i].hIcoLibItem = Skin_AddIcon(&sid);
}
}
diff --git a/plugins/ChangeKeyboardLayout/hook_events.c b/plugins/ChangeKeyboardLayout/hook_events.c index 37f317a448..5fb03491ee 100644 --- a/plugins/ChangeKeyboardLayout/hook_events.c +++ b/plugins/ChangeKeyboardLayout/hook_events.c @@ -108,16 +108,8 @@ void RegPopupActions() int OnIconsChanged(WPARAM wParam, LPARAM lParam)
{
- if(ServiceExists(MS_SKIN2_ADDICON))
- {
- hPopupIcon = (HICON)CallService(MS_SKIN2_GETICON, 0, (LPARAM)"ckl_popup_icon");
- hCopyIcon = (HICON)CallService(MS_SKIN2_GETICON, 0, (LPARAM)"ckl_copy_icon");
- }
- else
- {
- hPopupIcon = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_POPUPICON), IMAGE_ICON, 16, 16, 0);
- hCopyIcon = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_COPYICON), IMAGE_ICON, 16, 16, 0);
- }
+ hPopupIcon = (HICON)CallService(MS_SKIN2_GETICON, 0, (LPARAM)"ckl_popup_icon");
+ hCopyIcon = (HICON)CallService(MS_SKIN2_GETICON, 0, (LPARAM)"ckl_copy_icon");
RegPopupActions();
return 0;
}
@@ -132,7 +124,7 @@ int ModulesLoaded(WPARAM wParam, LPARAM lParam) LPSTR ptszTemp;
SKINICONDESC sid = {0};
- CHAR szFile[MAX_PATH];
+ TCHAR szFile[MAX_PATH];
//Çàïîëíÿåì êîíôèãóðàöèîííûå ñòðîêè èç áàçû. Åñëè èõ òàì íåò - ãåíåðèðóåì.
@@ -178,25 +170,24 @@ int ModulesLoaded(WPARAM wParam, LPARAM lParam) hChangeTextLayout = CreateServiceFunction(MS_CKL_CHANGETEXTLAYOUT, APIChangeTextLayout);
// IcoLib support
- if(ServiceExists(MS_SKIN2_ADDICON))
- {
- GetModuleFileNameA(hInst, szFile, MAX_PATH);
- sid.pszDefaultFile = szFile;
- sid.cbSize = SKINICONDESC_SIZE;
-
- sid.pszSection = Translate(ModuleName);
- sid.pszDescription = Translate("Popup");
- sid.pszName = "ckl_popup_icon";
- sid.iDefaultIndex = -IDI_POPUPICON;
- CallService(MS_SKIN2_ADDICON, 0, (LPARAM)&sid);
-
- sid.pszDescription = Translate("Copy to clipboard");
- sid.pszName = "ckl_copy_icon";
- sid.iDefaultIndex = -IDI_COPYICON;
- CallService(MS_SKIN2_ADDICON, 0, (LPARAM)&sid);
-
- hIcoLibIconsChanged = HookEvent(ME_SKIN2_ICONSCHANGED, OnIconsChanged);
- }
+ GetModuleFileName(hInst, szFile, MAX_PATH);
+ sid.ptszDefaultFile = szFile;
+ sid.cbSize = sizeof(sid);
+ sid.flags = SIDF_PATH_TCHAR;
+
+ sid.pszSection = Translate(ModuleName);
+ sid.pszDescription = Translate("Popup");
+ sid.pszName = "ckl_popup_icon";
+ sid.iDefaultIndex = -IDI_POPUPICON;
+ Skin_AddIcon(&sid);
+
+ sid.pszDescription = Translate("Copy to clipboard");
+ sid.pszName = "ckl_copy_icon";
+ sid.iDefaultIndex = -IDI_COPYICON;
+ Skin_AddIcon(&sid);
+
+ hIcoLibIconsChanged = HookEvent(ME_SKIN2_ICONSCHANGED, OnIconsChanged);
+
OnIconsChanged(0, 0);
RegPopupActions();
diff --git a/plugins/Chat/options.c b/plugins/Chat/options.c index 1e25f541e7..c80b0c1871 100644 --- a/plugins/Chat/options.c +++ b/plugins/Chat/options.c @@ -493,7 +493,7 @@ void AddIcons(void) sid.pszDescription = (char*)iconList[i].szDescr;
sid.pszName = (char*)iconList[i].szName;
sid.iDefaultIndex = -iconList[i].defIconID;
- CallService(MS_SKIN2_ADDICON, 0, (LPARAM)&sid);
+ Skin_AddIcon(&sid);
} }
// load icons from the skinning module if available
diff --git a/plugins/Clist_modern/modern_clc.cpp b/plugins/Clist_modern/modern_clc.cpp index 1e05581498..e4626ceb63 100644 --- a/plugins/Clist_modern/modern_clc.cpp +++ b/plugins/Clist_modern/modern_clc.cpp @@ -67,8 +67,8 @@ static int clcExitDragToScroll(); static int clcHookModulesLoaded(WPARAM wParam,LPARAM lParam)
{
- int i;
- if (MirandaExiting()) return 0;
+ if (MirandaExiting())
+ return 0;
ModernHookEvent(ME_MODERNOPT_INITIALIZE,ModernOptInit);
ModernHookEvent(ME_MODERNOPT_INITIALIZE,ModernSkinOptInit);
@@ -79,67 +79,46 @@ static int clcHookModulesLoaded(WPARAM wParam,LPARAM lParam) g_szMetaModuleName = (char *)CallService(MS_MC_GETPROTOCOLNAME, 0, 0);
// Get icons
- if(ServiceExists(MS_SKIN2_ADDICON))
- {
- SKINICONDESC sid={0};
- char szMyPath[MAX_PATH];
- int i;
-
- GetModuleFileNameA(g_hInst, szMyPath, MAX_PATH);
-
- sid.cbSize = sizeof(sid);
- sid.cx=16;
- sid.cy=16;
- sid.pszDefaultFile = szMyPath;
-
- sid.pszSection = LPGEN("Contact List");
- sid.pszDescription = LPGEN("Listening to");
- sid.pszName = "LISTENING_TO_ICON";
- sid.iDefaultIndex = - IDI_LISTENING_TO;
- CallService(MS_SKIN2_ADDICON, 0, (LPARAM)&sid);
-
- sid.pszSection = LPGEN("Contact List/Avatar Overlay");
+ int i;
- for (i = 0 ; i < MAX_REGS(g_pAvatarOverlayIcons) ; i++)
- {
- sid.pszDescription = g_pAvatarOverlayIcons[i].description;
- sid.pszName = g_pAvatarOverlayIcons[i].name;
- sid.iDefaultIndex = - g_pAvatarOverlayIcons[i].id;
- CallService(MS_SKIN2_ADDICON, 0, (LPARAM)&sid);
- }
- sid.pszSection = LPGEN("Contact List/Status Overlay");
+ TCHAR szMyPath[MAX_PATH];
+ GetModuleFileName(g_hInst, szMyPath, SIZEOF(szMyPath));
+
+ SKINICONDESC sid={0};
+ sid.cbSize = sizeof(sid);
+ sid.cx = 16;
+ sid.cy = 16;
+ sid.ptszDefaultFile = szMyPath;
+ sid.flags = SIDF_PATH_TCHAR;
+
+ sid.pszSection = LPGEN("Contact List");
+ sid.pszDescription = LPGEN("Listening to");
+ sid.pszName = "LISTENING_TO_ICON";
+ sid.iDefaultIndex = - IDI_LISTENING_TO;
+ Skin_AddIcon(&sid);
+
+ sid.pszSection = LPGEN("Contact List/Avatar Overlay");
+ for (i=0; i < MAX_REGS(g_pAvatarOverlayIcons) ; i++) {
+ sid.pszDescription = g_pAvatarOverlayIcons[i].description;
+ sid.pszName = g_pAvatarOverlayIcons[i].name;
+ sid.iDefaultIndex = - g_pAvatarOverlayIcons[i].id;
+ Skin_AddIcon(&sid);
+ }
- for (i = 0 ; i < MAX_REGS(g_pStatusOverlayIcons) ; i++)
- {
- sid.pszDescription = g_pStatusOverlayIcons[i].description;
- sid.pszName = g_pStatusOverlayIcons[i].name;
- sid.iDefaultIndex = - g_pStatusOverlayIcons[i].id;
- CallService(MS_SKIN2_ADDICON, 0, (LPARAM)&sid);
- }
+ sid.pszSection = LPGEN("Contact List/Status Overlay");
+ for (i=0; i < MAX_REGS(g_pStatusOverlayIcons); i++) {
+ sid.pszDescription = g_pStatusOverlayIcons[i].description;
+ sid.pszName = g_pStatusOverlayIcons[i].name;
+ sid.iDefaultIndex = - g_pStatusOverlayIcons[i].id;
+ Skin_AddIcon(&sid);
+ }
- clcHookIconsChanged(0,0);
+ clcHookIconsChanged(0,0);
- hIconChangedHook=ModernHookEvent(ME_SKIN2_ICONSCHANGED, clcHookIconsChanged);
- }
- else
- {
- if (hAvatarOverlays) ImageList_Destroy(hAvatarOverlays);
- hAvatarOverlays=ImageList_Create(16,16,ILC_MASK|ILC_COLOR32,MAX_REGS(g_pAvatarOverlayIcons)*2,1);
- for (i = 0 ; i < MAX_REGS(g_pAvatarOverlayIcons) ; i++)
- {
- HICON hIcon=LoadSmallIcon(g_hInst, MAKEINTRESOURCE(g_pAvatarOverlayIcons[i].id));
- g_pAvatarOverlayIcons[i].listID = ImageList_AddIcon(hAvatarOverlays,hIcon);
- DestroyIcon_protect(hIcon);
- hIcon=LoadSmallIcon(g_hInst, MAKEINTRESOURCE(g_pStatusOverlayIcons[i].id));
- g_pStatusOverlayIcons[i].listID = ImageList_AddIcon(hAvatarOverlays,hIcon);
- DestroyIcon_protect(hIcon);
- }
- g_hListeningToIcon = (HICON)LoadImage(g_hInst, MAKEINTRESOURCE(IDI_LISTENING_TO), IMAGE_ICON, 16, 16, 0);
- }
+ hIconChangedHook=ModernHookEvent(ME_SKIN2_ICONSCHANGED, clcHookIconsChanged);
// Register smiley category
- if (ServiceExists(MS_SMILEYADD_REGISTERCATEGORY))
- {
+ if (ServiceExists(MS_SMILEYADD_REGISTERCATEGORY)) {
SMADD_REGCAT rc;
rc.cbSize = sizeof(rc);
diff --git a/plugins/Clist_modern/modern_clui.cpp b/plugins/Clist_modern/modern_clui.cpp index 5929ecfc87..80c9937763 100644 --- a/plugins/Clist_modern/modern_clui.cpp +++ b/plugins/Clist_modern/modern_clui.cpp @@ -1071,8 +1071,7 @@ HICON CLUI_LoadIconFromExternalFile(char *filename,int i,boolean UseLibrary,bool if (hi) has_proto_icon=TRUE;
if (hi && nf) DestroyIcon(hi);
}
- if (!UseLibrary||!ServiceExists(MS_SKIN2_ADDICON))
- {
+ if (!UseLibrary) {
hIcon=CLUI_ExtractIconFromPath(szFullPath,needFree);
if (hIcon) return hIcon;
if (UseLibrary)
@@ -1082,10 +1081,8 @@ HICON CLUI_LoadIconFromExternalFile(char *filename,int i,boolean UseLibrary,bool if (hIcon) return hIcon;
}
}
- else
- {
- if (registerit&&IconName!=NULL&&SectName!=NULL)
- {
+ else {
+ if (registerit && IconName != NULL && SectName != NULL) {
sid.cbSize = sizeof(sid);
sid.cx=16;
sid.cy=16;
@@ -1096,7 +1093,7 @@ HICON CLUI_LoadIconFromExternalFile(char *filename,int i,boolean UseLibrary,bool sid.pszDefaultFile=internalidx<0?szMyPath:szPath;
sid.iDefaultIndex=(UseLibrary&2)?i:(internalidx<0)?internalidx:-internalidx;
- CallService(MS_SKIN2_ADDICON, 0, (LPARAM)&sid);
+ Skin_AddIcon(&sid);
}
return ((HICON)CallService(MS_SKIN2_GETICON, 0, (LPARAM)IconName));
}
@@ -1864,7 +1861,7 @@ HANDLE RegisterIcolibIconHandle(char * szIcoID, char *szSectionName, char * szD sid.iDefaultIndex = 0;
sid.hDefaultIcon = LoadSmallIcon( hDefaultModuleInst, MAKEINTRESOURCE(iDefaultResource));
}
- hIcolibItem = ( HANDLE )CallService(MS_SKIN2_ADDICON, 0, (LPARAM)&sid);
+ hIcolibItem = Skin_AddIcon(&sid);
if ( sid.hDefaultIcon ) DestroyIcon(sid.hDefaultIcon);
return hIcolibItem;
}
diff --git a/plugins/Clist_modern/modern_viewmodebar.cpp b/plugins/Clist_modern/modern_viewmodebar.cpp index ae385f77bb..38f7e42f97 100644 --- a/plugins/Clist_modern/modern_viewmodebar.cpp +++ b/plugins/Clist_modern/modern_viewmodebar.cpp @@ -1069,90 +1069,83 @@ void BuildViewModeMenu() LRESULT CALLBACK ViewModeFrameWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
- switch(msg)
+ switch(msg)
{
- case WM_CREATE:
- {
- HWND hwndButton;
+ case WM_CREATE:
+ {
+ HWND hwndButton;
RECT rcMargins={12,0,2,0};
- hwndSelector = CreateWindow( SKINBUTTONCLASS, _T(""), BS_PUSHBUTTON | WS_VISIBLE | WS_CHILD | WS_TABSTOP , 0, 0, 20, 20,
- hwnd, (HMENU) IDC_SELECTMODE, g_hInst, NULL);
- SendMessage(hwndSelector, BUTTONADDTOOLTIP, (WPARAM)TranslateT("Select a view mode"), 0);
+ hwndSelector = CreateWindow( SKINBUTTONCLASS, _T(""), BS_PUSHBUTTON | WS_VISIBLE | WS_CHILD | WS_TABSTOP , 0, 0, 20, 20,
+ hwnd, (HMENU) IDC_SELECTMODE, g_hInst, NULL);
+ SendMessage(hwndSelector, BUTTONADDTOOLTIP, (WPARAM)TranslateT("Select a view mode"), 0);
SendMessage(hwndSelector, BUTTONSETMARGINS,0 ,(LPARAM) &rcMargins);
SendMessage(hwndSelector, BUTTONSETID,0 ,(LPARAM) "ViewMode.Select" );
SendMessage(hwndSelector, WM_SETFONT,0 ,(LPARAM) FONTID_VIEMODES+1 );
SendMessage(hwndSelector, BUTTONSETASFLATBTN, TRUE, 0 );
SendMessage(hwndSelector, MBM_UPDATETRANSPARENTFLAG, 0, 2);
- SendMessage(hwndSelector, BUTTONSETSENDONDOWN, 0 ,(LPARAM) 1 );
-
+ SendMessage(hwndSelector, BUTTONSETSENDONDOWN, 0 ,(LPARAM) 1 );
+
//SendMessage(hwndSelector, BM_SETASMENUACTION, 1, 0);
- hwndButton = CreateWindow( SKINBUTTONCLASS, _T(""), BS_PUSHBUTTON | WS_VISIBLE | WS_CHILD | WS_TABSTOP, 0, 0, 20, 20,
- hwnd, (HMENU) IDC_CONFIGUREMODES, g_hInst, NULL);
- SendMessage(hwndButton, BUTTONADDTOOLTIP, (WPARAM)TranslateT("Setup view modes"), 0);
+ hwndButton = CreateWindow( SKINBUTTONCLASS, _T(""), BS_PUSHBUTTON | WS_VISIBLE | WS_CHILD | WS_TABSTOP, 0, 0, 20, 20,
+ hwnd, (HMENU) IDC_CONFIGUREMODES, g_hInst, NULL);
+ SendMessage(hwndButton, BUTTONADDTOOLTIP, (WPARAM)TranslateT("Setup view modes"), 0);
SendMessage(hwndButton, BUTTONSETID,0 ,(LPARAM) "ViewMode.Setup" );
SendMessage(hwndButton, BUTTONSETASFLATBTN, TRUE, 0 );
SendMessage(hwndButton, MBM_UPDATETRANSPARENTFLAG, 0, 2);
- hwndButton = CreateWindow( SKINBUTTONCLASS, _T(""), BS_PUSHBUTTON | WS_VISIBLE | WS_CHILD | WS_TABSTOP, 0, 0, 20, 20,
- hwnd, (HMENU) IDC_RESETMODES, g_hInst, NULL);
- SendMessage(hwndButton, BUTTONADDTOOLTIP, (WPARAM)TranslateT("Clear view mode and return to default display"), 0);
+ hwndButton = CreateWindow( SKINBUTTONCLASS, _T(""), BS_PUSHBUTTON | WS_VISIBLE | WS_CHILD | WS_TABSTOP, 0, 0, 20, 20,
+ hwnd, (HMENU) IDC_RESETMODES, g_hInst, NULL);
+ SendMessage(hwndButton, BUTTONADDTOOLTIP, (WPARAM)TranslateT("Clear view mode and return to default display"), 0);
SendMessage(hwndButton, BUTTONSETID,0 ,(LPARAM) "ViewMode.Clear" );
SendMessage(hwnd, WM_USER + 100, 0, 0);
SendMessage(hwndButton, BUTTONSETASFLATBTN, TRUE, 0 );
SendMessage(hwndButton, MBM_UPDATETRANSPARENTFLAG, 0, 2);
- return FALSE;
- }
- case WM_NCCALCSIZE:
- return 18;// FrameNCCalcSize(hwnd, DefWindowProc, wParam, lParam, hasTitleBar);
- case WM_SIZE:
- {
- RECT rcCLVMFrame;
- HDWP PosBatch = BeginDeferWindowPos(3);
- GetClientRect(hwnd, &rcCLVMFrame);
- PosBatch = DeferWindowPos(PosBatch, GetDlgItem(hwnd, IDC_RESETMODES), 0,
- rcCLVMFrame.right - 23, 1, 22, 18, SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOREDRAW | SWP_NOCOPYBITS);
- PosBatch = DeferWindowPos(PosBatch, GetDlgItem(hwnd, IDC_CONFIGUREMODES), 0,
- rcCLVMFrame.right - 45, 1, 22, 18, SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOREDRAW | SWP_NOCOPYBITS);
- PosBatch = DeferWindowPos(PosBatch, GetDlgItem(hwnd, IDC_SELECTMODE), 0,
- 1, 1, rcCLVMFrame.right - 46, 18, SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOREDRAW | SWP_NOCOPYBITS);
- EndDeferWindowPos(PosBatch);
- break;
- }
- case WM_USER + 100:
- if(ServiceExists(MS_SKIN2_ADDICON))
- {
- SendMessage(GetDlgItem(hwnd, IDC_RESETMODES), MBM_SETICOLIBHANDLE, 0,
- (LPARAM) RegisterIcolibIconHandle("CLN_CLVM_reset", "Contact List",Translate("Reset view mode"), _T("clisticons.dll"),9, g_hInst, IDI_RESETVIEW ));
-
- SendMessage(GetDlgItem(hwnd, IDC_CONFIGUREMODES), MBM_SETICOLIBHANDLE, 0,
- (LPARAM) RegisterIcolibIconHandle("CLN_CLVM_set", "Contact List",Translate("Setup view modes"), _T("clisticons.dll"), 10, g_hInst, IDI_SETVIEW ));
- }
- else
- {
- SendMessage(GetDlgItem(hwnd, IDC_RESETMODES), BM_SETIMAGE, IMAGE_ICON, (LPARAM)LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_DELETE), IMAGE_ICON, 16, 16, LR_SHARED));
- SendMessage(GetDlgItem(hwnd, IDC_CONFIGUREMODES), BM_SETIMAGE, IMAGE_ICON, (LPARAM)LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_RENAME), IMAGE_ICON, 16, 16, LR_SHARED));
- //SendMessage(GetDlgItem(hwnd, IDC_SELECTMODE), BM_SETIMAGE, IMAGE_ICON, (LPARAM)LoadImage(g_hInst, MAKEINTRESOURCE(IDI_CHAT), IMAGE_ICON, 16, 16, LR_SHARED));
- }
- {
- int bSkinned = ModernGetSettingByte(NULL, "CLCExt", "bskinned", 0);
- int i = 0;
-
- while(_buttons[i] != 0) {
- //SendMessage(GetDlgItem(hwnd, _buttons[i]), BM_SETSKINNED, 0, bSkinned);
- if(1&&bSkinned) {
- SendDlgItemMessage(hwnd, _buttons[i], BUTTONSETASFLATBTN, TRUE, 0);
- SendDlgItemMessage(hwnd, _buttons[i], BUTTONSETASFLATBTN + 10, 0, 0);
- }
- else {
- SendDlgItemMessage(hwnd, _buttons[i], BUTTONSETASFLATBTN, TRUE, 1);
- SendDlgItemMessage(hwnd, _buttons[i], BUTTONSETASFLATBTN + 10, 0, 1);
- }
- i++;
- }
- }
- if(g_CluiData.bFilterEffective)
- {
-
+ return FALSE;
+ }
+ case WM_NCCALCSIZE:
+ return 18;// FrameNCCalcSize(hwnd, DefWindowProc, wParam, lParam, hasTitleBar);
+ case WM_SIZE:
+ {
+ RECT rcCLVMFrame;
+ HDWP PosBatch = BeginDeferWindowPos(3);
+ GetClientRect(hwnd, &rcCLVMFrame);
+ PosBatch = DeferWindowPos(PosBatch, GetDlgItem(hwnd, IDC_RESETMODES), 0,
+ rcCLVMFrame.right - 23, 1, 22, 18, SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOREDRAW | SWP_NOCOPYBITS);
+ PosBatch = DeferWindowPos(PosBatch, GetDlgItem(hwnd, IDC_CONFIGUREMODES), 0,
+ rcCLVMFrame.right - 45, 1, 22, 18, SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOREDRAW | SWP_NOCOPYBITS);
+ PosBatch = DeferWindowPos(PosBatch, GetDlgItem(hwnd, IDC_SELECTMODE), 0,
+ 1, 1, rcCLVMFrame.right - 46, 18, SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOREDRAW | SWP_NOCOPYBITS);
+ EndDeferWindowPos(PosBatch);
+ break;
+ }
+ case WM_USER + 100:
+ SendMessage(GetDlgItem(hwnd, IDC_RESETMODES), MBM_SETICOLIBHANDLE, 0,
+ (LPARAM) RegisterIcolibIconHandle("CLN_CLVM_reset", "Contact List",Translate("Reset view mode"), _T("clisticons.dll"),9, g_hInst, IDI_RESETVIEW ));
+
+ SendMessage(GetDlgItem(hwnd, IDC_CONFIGUREMODES), MBM_SETICOLIBHANDLE, 0,
+ (LPARAM) RegisterIcolibIconHandle("CLN_CLVM_set", "Contact List",Translate("Setup view modes"), _T("clisticons.dll"), 10, g_hInst, IDI_SETVIEW ));
+
+ {
+ int bSkinned = ModernGetSettingByte(NULL, "CLCExt", "bskinned", 0);
+ int i = 0;
+
+ while(_buttons[i] != 0) {
+ //SendMessage(GetDlgItem(hwnd, _buttons[i]), BM_SETSKINNED, 0, bSkinned);
+ if(1&&bSkinned) {
+ SendDlgItemMessage(hwnd, _buttons[i], BUTTONSETASFLATBTN, TRUE, 0);
+ SendDlgItemMessage(hwnd, _buttons[i], BUTTONSETASFLATBTN + 10, 0, 0);
+ }
+ else {
+ SendDlgItemMessage(hwnd, _buttons[i], BUTTONSETASFLATBTN, TRUE, 1);
+ SendDlgItemMessage(hwnd, _buttons[i], BUTTONSETASFLATBTN + 10, 0, 1);
+ }
+ i++;
+ }
+ }
+
+ if(g_CluiData.bFilterEffective)
+ {
+
{
TCHAR * temp;
//temp=alloca((strlen(szSetting)+1)*sizeof(TCHAR));
@@ -1164,153 +1157,150 @@ LRESULT CALLBACK ViewModeFrameWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM }
}
- }
- else
- SetWindowText(GetDlgItem(hwnd, IDC_SELECTMODE), TranslateT("All contacts"));
- break;
- case WM_ERASEBKGND:
- if (g_CluiData.fDisableSkinEngine)
- return sttDrawViewModeBackground(hwnd, (HDC)wParam, NULL);
- else
- return 0;
- case WM_NCPAINT:
- case WM_PAINT:
- /*if ( g_CluiData.fDisableSkinEngine )
+ }
+ else
+ SetWindowText(GetDlgItem(hwnd, IDC_SELECTMODE), TranslateT("All contacts"));
+ break;
+ case WM_ERASEBKGND:
+ if (g_CluiData.fDisableSkinEngine)
+ return sttDrawViewModeBackground(hwnd, (HDC)wParam, NULL);
+ else
+ return 0;
+ case WM_NCPAINT:
+ case WM_PAINT:
+ /*if ( g_CluiData.fDisableSkinEngine )
+ {
+ PAINTSTRUCT ps;
+ HDC hdc=BeginPaint(hwnd,&ps);
+ if (hdc)
+ {
+ HBRUSH br=GetSysColorBrush(COLOR_3DFACE);
+ FillRect(hdc,&ps.rcPaint,br);
+ }
+ EndPaint(hwnd,&ps);
+ }
+ else
+ */
+ if (GetParent(hwnd)==pcli->hwndContactList && g_CluiData.fLayered)
+ {
+ ValidateRect(hwnd,NULL);
+ }
+ else if (GetParent(hwnd)!=pcli->hwndContactList || !g_CluiData.fLayered)
+ {
+ HDC hdc, hdc2;
+ HBITMAP hbmp,hbmpo;
+ RECT rc={0};
+ GetClientRect(hwnd,&rc);
+ rc.right++;
+ rc.bottom++;
+ hdc = GetDC(hwnd);
+ hdc2=CreateCompatibleDC(hdc);
+ hbmp=ske_CreateDIB32(rc.right,rc.bottom);
+ hbmpo=(HBITMAP)SelectObject(hdc2,hbmp);
+
+ if ( g_CluiData.fDisableSkinEngine )
{
- PAINTSTRUCT ps;
- HDC hdc=BeginPaint(hwnd,&ps);
- if (hdc)
- {
- HBRUSH br=GetSysColorBrush(COLOR_3DFACE);
- FillRect(hdc,&ps.rcPaint,br);
- }
- EndPaint(hwnd,&ps);
+ sttDrawViewModeBackground( hwnd, hdc2, &rc );
}
else
- */
- if (GetParent(hwnd)==pcli->hwndContactList && g_CluiData.fLayered)
{
- ValidateRect(hwnd,NULL);
- }
- else if (GetParent(hwnd)!=pcli->hwndContactList || !g_CluiData.fLayered)
- {
- HDC hdc, hdc2;
- HBITMAP hbmp,hbmpo;
- RECT rc={0};
- GetClientRect(hwnd,&rc);
- rc.right++;
- rc.bottom++;
- hdc = GetDC(hwnd);
- hdc2=CreateCompatibleDC(hdc);
- hbmp=ske_CreateDIB32(rc.right,rc.bottom);
- hbmpo=(HBITMAP)SelectObject(hdc2,hbmp);
-
- if ( g_CluiData.fDisableSkinEngine )
+ if (GetParent(hwnd)!=pcli->hwndContactList)
{
- sttDrawViewModeBackground( hwnd, hdc2, &rc );
+ HBRUSH br=GetSysColorBrush(COLOR_3DFACE);
+ FillRect(hdc2,&rc,br);
}
else
- {
- if (GetParent(hwnd)!=pcli->hwndContactList)
- {
- HBRUSH br=GetSysColorBrush(COLOR_3DFACE);
- FillRect(hdc2,&rc,br);
- }
- else
- ske_BltBackImage(hwnd,hdc2,&rc);
+ ske_BltBackImage(hwnd,hdc2,&rc);
- DrawViewModeBar(hwnd,hdc2);
- }
-
+ DrawViewModeBar(hwnd,hdc2);
+ }
+
+ {
+ int i;
+ for (i=0; _buttons[i]!=0; i++)
{
- int i;
- for (i=0; _buttons[i]!=0; i++)
- {
- RECT childRect;
- RECT MyRect;
- POINT Offset;
- GetWindowRect(hwnd,&MyRect);
- GetWindowRect(GetDlgItem(hwnd, _buttons[i]),&childRect);
- Offset.x=childRect.left-MyRect.left;;
- Offset.y=childRect.top-MyRect.top;
- SendMessage(GetDlgItem(hwnd, _buttons[i]),BUTTONDRAWINPARENT,(WPARAM)hdc2,(LPARAM)&Offset);
+ RECT childRect;
+ RECT MyRect;
+ POINT Offset;
+ GetWindowRect(hwnd,&MyRect);
+ GetWindowRect(GetDlgItem(hwnd, _buttons[i]),&childRect);
+ Offset.x=childRect.left-MyRect.left;;
+ Offset.y=childRect.top-MyRect.top;
+ SendMessage(GetDlgItem(hwnd, _buttons[i]),BUTTONDRAWINPARENT,(WPARAM)hdc2,(LPARAM)&Offset);
- }
}
- BitBlt(hdc,rc.left,rc.top,rc.right-rc.left,rc.bottom-rc.top,
- hdc2,rc.left,rc.top,SRCCOPY);
- SelectObject(hdc2,hbmpo);
- DeleteObject(hbmp);
- mod_DeleteDC(hdc2);
+ }
+ BitBlt(hdc,rc.left,rc.top,rc.right-rc.left,rc.bottom-rc.top,
+ hdc2,rc.left,rc.top,SRCCOPY);
+ SelectObject(hdc2,hbmpo);
+ DeleteObject(hbmp);
+ mod_DeleteDC(hdc2);
- SelectObject(hdc,GetStockObject(DEFAULT_GUI_FONT));
+ SelectObject(hdc,GetStockObject(DEFAULT_GUI_FONT));
- ReleaseDC(hwnd,hdc);
- ValidateRect(hwnd,NULL);
- }
- return 0;
- case WM_NOTIFY:
+ ReleaseDC(hwnd,hdc);
+ ValidateRect(hwnd,NULL);
+ }
+ return 0;
+
+ case WM_NOTIFY:
+ if (((LPNMHDR) lParam)->code==BUTTONNEEDREDRAW)
+ pcli->pfnInvalidateRect(hwnd, NULL, FALSE);
+ return 0;
+
+ case WM_TIMER:
+ switch(wParam) {
+ case TIMERID_VIEWMODEEXPIRE:
{
- if (((LPNMHDR) lParam)->code==BUTTONNEEDREDRAW)
- pcli->pfnInvalidateRect(hwnd, NULL, FALSE);
- return 0;
- }
-
- case WM_TIMER:
- {
- switch(wParam)
- {
- case TIMERID_VIEWMODEEXPIRE:
- {
- POINT pt;
- RECT rcCLUI;
+ POINT pt;
+ RECT rcCLUI;
- GetWindowRect(pcli->hwndContactList, &rcCLUI);
- GetCursorPos(&pt);
- if(PtInRect(&rcCLUI, pt))
- break;
+ GetWindowRect(pcli->hwndContactList, &rcCLUI);
+ GetCursorPos(&pt);
+ if(PtInRect(&rcCLUI, pt))
+ break;
- KillTimer(hwnd, wParam);
- if (!g_CluiData.old_viewmode[0])
- SendMessage(hwnd, WM_COMMAND, IDC_RESETMODES, 0);
- else
- ApplyViewMode((const char *)g_CluiData.old_viewmode);
- break;
- }
- }
- break;
- }
- case WM_COMMAND:
- {
- switch(LOWORD(wParam)) {
- case IDC_SELECTMODE:
- {
- RECT rc;
- POINT pt;
- int selection;
- MENUITEMINFO mii = {0};
- TCHAR szTemp[256];
-
- BuildViewModeMenu();
- //GetWindowRect(GetDlgItem(hwnd, IDC_SELECTMODE), &rc);
- GetWindowRect((HWND)lParam, &rc);
- pt.x = rc.left;
- pt.y = rc.bottom;
- selection = TrackPopupMenu(hViewModeMenu,TPM_RETURNCMD|TPM_TOPALIGN|TPM_LEFTALIGN|TPM_LEFTBUTTON, pt.x, pt.y, 0, GetParent(hwnd), NULL);
+ KillTimer(hwnd, wParam);
+ if (!g_CluiData.old_viewmode[0])
+ SendMessage(hwnd, WM_COMMAND, IDC_RESETMODES, 0);
+ else
+ ApplyViewMode((const char *)g_CluiData.old_viewmode);
+ break;
+ }
+ }
+ break;
+
+ case WM_COMMAND:
+ {
+ switch(LOWORD(wParam)) {
+ case IDC_SELECTMODE:
+ {
+ RECT rc;
+ POINT pt;
+ int selection;
+ MENUITEMINFO mii = {0};
+ TCHAR szTemp[256];
+
+ BuildViewModeMenu();
+ //GetWindowRect(GetDlgItem(hwnd, IDC_SELECTMODE), &rc);
+ GetWindowRect((HWND)lParam, &rc);
+ pt.x = rc.left;
+ pt.y = rc.bottom;
+ selection = TrackPopupMenu(hViewModeMenu,TPM_RETURNCMD|TPM_TOPALIGN|TPM_LEFTALIGN|TPM_LEFTBUTTON, pt.x, pt.y, 0, GetParent(hwnd), NULL);
PostMessage(hwnd, WM_NULL, 0, 0);
- if(selection)
+ if(selection)
{
-
+
if(selection == 10001)
goto clvm_config_command;
else if(selection == 10002)
goto clvm_reset_command;
- mii.cbSize = sizeof(mii);
- mii.fMask = MIIM_STRING;
- mii.dwTypeData = szTemp;
- mii.cch = 256;
- GetMenuItemInfo(hViewModeMenu, selection, FALSE, &mii);
+ mii.cbSize = sizeof(mii);
+ mii.fMask = MIIM_STRING;
+ mii.dwTypeData = szTemp;
+ mii.cch = 256;
+ GetMenuItemInfo(hViewModeMenu, selection, FALSE, &mii);
{
char * temp=mir_utf8encodeT(szTemp);
@@ -1318,28 +1308,28 @@ LRESULT CALLBACK ViewModeFrameWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM if (temp) mir_free(temp);
}
- }
- break;
- }
- case IDC_RESETMODES:
+ }
+ break;
+ }
+ case IDC_RESETMODES:
clvm_reset_command:
- ApplyViewMode( "" );
- break;
- case IDC_CONFIGUREMODES:
- {
+ ApplyViewMode( "" );
+ break;
+ case IDC_CONFIGUREMODES:
+ {
clvm_config_command:
if (!g_ViewModeOptDlg)
- CreateDialogParam(g_hInst, MAKEINTRESOURCE(IDD_OPT_VIEWMODES), 0, DlgProcViewModesSetup, 0);
- break;
- }
- }
- break;
+ CreateDialogParam(g_hInst, MAKEINTRESOURCE(IDD_OPT_VIEWMODES), 0, DlgProcViewModesSetup, 0);
+ break;
+ }
+ }
+ break;
- }
- default:
- return DefWindowProc(hwnd, msg, wParam, lParam);
- }
- return TRUE;
+ }
+ default:
+ return DefWindowProc(hwnd, msg, wParam, lParam);
+ }
+ return TRUE;
}
static HWND hCLVMFrame;
diff --git a/plugins/Clist_mw/clui.cpp b/plugins/Clist_mw/clui.cpp index 14079c2ac6..bddf0478e0 100644 --- a/plugins/Clist_mw/clui.cpp +++ b/plugins/Clist_mw/clui.cpp @@ -201,33 +201,27 @@ HICON LoadIconFromExternalFile(char *filename,int i,boolean UseLibrary,boolean r _snprintf(szFullPath, SIZEOF(szFullPath), "%s\\Icons\\%s,%d", szPath, filename, i);
}
- if (!UseLibrary||!ServiceExists(MS_SKIN2_ADDICON))
- {
+ if (!UseLibrary) {
hIcon = ExtractIconFromPath(szFullPath);
if (hIcon) return hIcon;
}
- else
- {
- if (registerit&&IconName != NULL&&SectName != NULL)
- {
+ else {
+ if (registerit && IconName != NULL && SectName != NULL) {
sid.cbSize = sizeof(sid);
sid.pszSection = SectName;
sid.pszName = IconName;
sid.pszDescription = Description;
if (strlen(szMyPath) != 0)
- {
sid.pszDefaultFile = szMyPath;
- }
sid.iDefaultIndex = internalidx;
sid.hDefaultIcon = DefIcon;
- CallService(MS_SKIN2_ADDICON, 0, (LPARAM)&sid);
- {
- char buf[256];
- sprintf(buf,"Registring Icon %s/%s hDefaultIcon: %p\r\n",SectName,IconName,DefIcon);
- OutputDebugStringA(buf);
- }
+ Skin_AddIcon(&sid);
+
+ char buf[256];
+ sprintf(buf,"Registring Icon %s/%s hDefaultIcon: %p\r\n",SectName,IconName,DefIcon);
+ OutputDebugStringA(buf);
}
return ((HICON)CallService(MS_SKIN2_GETICON, 0, (LPARAM)IconName));
}
diff --git a/plugins/Console/Console.c b/plugins/Console/Console.c index c0e02f994b..2a568d98fa 100644 --- a/plugins/Console/Console.c +++ b/plugins/Console/Console.c @@ -1311,25 +1311,25 @@ static int OnSystemModulesLoaded(WPARAM wParam,LPARAM lParam) }
if (ServiceExists(MS_TB_ADDBUTTON)) {
- SKINICONDESC sid={0};
TBButton tbb = {0};
- char szModuleFileName[MAX_PATH]={0};
-
- GetModuleFileNameA(hInst,szModuleFileName,MAX_PATH);
+ SKINICONDESC sid={0};
+ TCHAR szModuleFileName[MAX_PATH]={0};
+ GetModuleFileName(hInst, szModuleFileName, SIZEOF(szModuleFileName));
sid.cbSize = sizeof(sid);
- sid.pszSection = Translate("Console");
- sid.pszDefaultFile = szModuleFileName;
+ sid.pszSection = "Console";
+ sid.ptszDefaultFile = szModuleFileName;
+ sid.flags = SIDF_PATH_TCHAR;
- sid.pszDescription = Translate("Show");
+ sid.pszDescription = "Show";
sid.pszName = "Console_Up";
sid.iDefaultIndex = -IDI_BTN_UP;
- CallService(MS_SKIN2_ADDICON,0,(LPARAM)&sid);
+ Skin_AddIcon(&sid);
- sid.pszDescription = Translate("Hide");
+ sid.pszDescription = "Hide";
sid.pszName = "Console_Down";
sid.iDefaultIndex = -IDI_BTN_DN;
- CallService(MS_SKIN2_ADDICON,0,(LPARAM)&sid);
+ Skin_AddIcon(&sid);
tbb.cbSize = sizeof(TBButton);
tbb.pszButtonID = "console_btn";
diff --git a/plugins/CountryFlags/icons.c b/plugins/CountryFlags/icons.c index 46bf2a9391..82dea7cabc 100644 --- a/plugins/CountryFlags/icons.c +++ b/plugins/CountryFlags/icons.c @@ -265,7 +265,7 @@ void InitIcons(void) sid.hDefaultIcon=(hIcon!=NULL)?ResizeIconCentered(hIcon,sid.cx,sid.cy):NULL;
if(hIcon!=NULL) DestroyIcon(hIcon);
index=CountryNumberToIndex(countries[i].id);
- phIconHandles[index]=(HANDLE)CallService(MS_SKIN2_ADDICON,0,(LPARAM)&sid);
+ phIconHandles[index] = Skin_AddIcon(&sid);
if(sid.hDefaultIcon!=NULL) DestroyIcon(sid.hDefaultIcon);
}
ImageList_Destroy(himl);
diff --git a/plugins/Db_autobackups/main.c b/plugins/Db_autobackups/main.c index 87de4cb9a0..1d00a3b60f 100644 --- a/plugins/Db_autobackups/main.c +++ b/plugins/Db_autobackups/main.c @@ -80,7 +80,7 @@ static void IcoLibInit(void) sid.pszName = iconList[i].szName;
sid.ptszDescription = iconList[i].szDescr;
sid.iDefaultIndex = -iconList[i].defIconID;
- CallService(MS_SKIN2_ADDICON, 0, (LPARAM)&sid);
+ Skin_AddIcon(&sid);
}
}
diff --git a/plugins/Dbx_mmap_SA/dialogs.c b/plugins/Dbx_mmap_SA/dialogs.c index 228db23f64..df13214b62 100644 --- a/plugins/Dbx_mmap_SA/dialogs.c +++ b/plugins/Dbx_mmap_SA/dialogs.c @@ -106,12 +106,12 @@ static int ModulesLoad(WPARAM wParam, LPARAM lParam) sid.ptszDescription = LPGENT("Database");
sid.pszName = "database";
sid.iDefaultIndex = -IDI_ICON2;
- CallService(MS_SKIN2_ADDICON, 0, (LPARAM)&sid);
+ Skin_AddIcon(&sid);
sid.ptszDescription = LPGENT("Change Password");
sid.pszName = "password";
sid.iDefaultIndex = -IDI_ICON3;
- CallService(MS_SKIN2_ADDICON, 0, (LPARAM)&sid);
+ Skin_AddIcon(&sid);
menu.cbSize = sizeof(menu);
menu.flags = CMIM_ALL | CMIF_TCHAR;
diff --git a/plugins/FavContacts/src/main.cpp b/plugins/FavContacts/src/main.cpp index c6dfaa7bb1..d2c4db9f6f 100644 --- a/plugins/FavContacts/src/main.cpp +++ b/plugins/FavContacts/src/main.cpp @@ -67,7 +67,7 @@ INT_PTR svcShowMenuCentered(WPARAM wParam, LPARAM lParam); int ProcessSrmmEvent(WPARAM wParam, LPARAM lParam);
int ProcessSrmmIconClick(WPARAM wParam, LPARAM lParam);
-int g_icoFavourite=0, g_icoRegular=0;
+HANDLE g_icoFavourite=0, g_icoRegular=0;
float g_widthMultiplier = 0;
int g_maxItemWidth = 0;
@@ -186,9 +186,9 @@ int ProcessModulesLoaded(WPARAM wParam, LPARAM lParam) StatusIconData sid = {0};
sid.cbSize = sizeof(sid);
sid.szModule = "FavContacts";
- sid.szTooltip = Translate("Favourite Contacts");
- sid.hIcon = (HICON)CallService(MS_SKIN2_GETICONBYHANDLE, 0, g_icoFavourite);
- sid.hIconDisabled = (HICON)CallService(MS_SKIN2_GETICONBYHANDLE, 0, g_icoRegular);
+ sid.szTooltip = "Favourite Contacts";
+ sid.hIcon = (HICON)CallService(MS_SKIN2_GETICONBYHANDLE, 0, (LPARAM)g_icoFavourite);
+ sid.hIconDisabled = (HICON)CallService(MS_SKIN2_GETICONBYHANDLE, 0, (LPARAM)g_icoRegular);
CallService(MS_MSG_ADDICON, 0, (LPARAM)&sid);
HookEvent(ME_MSG_ICONPRESSED, ProcessSrmmIconClick);
@@ -355,12 +355,12 @@ extern "C" __declspec(dllexport) int Load(PLUGINLINK * link) sid.pszName = "favcontacts_favourite";
sid.ptszDescription = _T("Favourite Contact");
sid.iDefaultIndex = -IDI_FAVOURITE;
- g_icoFavourite = CallService(MS_SKIN2_ADDICON, 0, (LPARAM)&sid);
+ g_icoFavourite = Skin_AddIcon(&sid);
sid.pszName = "favcontacts_regular";
sid.ptszDescription = _T("Regular Contact");
sid.iDefaultIndex = -IDI_REGULAR;
- g_icoRegular = CallService(MS_SKIN2_ADDICON, 0, (LPARAM)&sid);
+ g_icoRegular = Skin_AddIcon(&sid);
LoadHttpApi();
@@ -753,7 +753,7 @@ static BOOL sttDrawItem_Contact(LPDRAWITEMSTRUCT lpdis, Options *options = NULL) if (options->wMaxRecent && DBGetContactSettingByte(hContact, "FavContacts", "IsFavourite", 0))
{
DrawIconEx(hdcTemp, lpdis->rcItem.right - 18, (lpdis->rcItem.top + lpdis->rcItem.bottom - 16) / 2,
- (HICON)CallService(MS_SKIN2_GETICONBYHANDLE, 0, g_icoFavourite), 16, 16, 0, NULL, DI_NORMAL);
+ (HICON)CallService(MS_SKIN2_GETICONBYHANDLE, 0, (LPARAM)g_icoFavourite), 16, 16, 0, NULL, DI_NORMAL);
lpdis->rcItem.right -= 20;
}
@@ -1015,8 +1015,7 @@ int sttShowMenu(bool centered) szColumn.cx = szColumn.cy = 0;
unsigned maxWidth = GetSystemMetrics(SM_CXSCREEN) * DBGetContactSettingByte(NULL, "FavContacts", "MenuWidth", 66) / 100;
- if (szMenu.cx > maxWidth)
- {
+ if (szMenu.cx > maxWidth) {
g_widthMultiplier = (float)maxWidth / szMenu.cx;
szMenu.cx *= g_widthMultiplier;
}
diff --git a/plugins/FingerPrintModPlus/src/fingerprint.cpp b/plugins/FingerPrintModPlus/src/fingerprint.cpp index a802975898..1f5621e89e 100644 --- a/plugins/FingerPrintModPlus/src/fingerprint.cpp +++ b/plugins/FingerPrintModPlus/src/fingerprint.cpp @@ -631,7 +631,7 @@ HICON FASTCALL LoadIconFromExternalFile(LPTSTR filename, int nLibrary, LPSTR Ico sid.ptszDefaultFile = destfile;
sid.iDefaultIndex = -internalidx;
sid.cx = sid.cy = 16;
- CallService(MS_SKIN2_ADDICON, 0, (LPARAM)&sid);
+ Skin_AddIcon(&sid);
hIcon = ((HICON)CallService(MS_SKIN2_GETICON, 0, (LPARAM)IconName));
}
diff --git a/plugins/Gender/main.cpp b/plugins/Gender/main.cpp index a95d5593c9..3df2a909e8 100644 --- a/plugins/Gender/main.cpp +++ b/plugins/Gender/main.cpp @@ -265,33 +265,30 @@ int onModulesLoaded(WPARAM wParam,LPARAM lParam) bMetaAvail = (ServiceExists(MS_MC_GETMETACONTACT) != 0);
//IcoLib support
- if(ServiceExists(MS_SKIN2_ADDICON))
- {
- SKINICONDESC sid = {0};
- sid.cbSize = SKINICONDESC_SIZE;
- sid.flags = SIDF_ALL_TCHAR;
- sid.ptszSection = LPGENT("Gender");
- TCHAR szFile[MAX_PATH];
- GetModuleFileName(g_hInst, szFile, MAX_PATH);
- sid.ptszDefaultFile = szFile;
+ SKINICONDESC sid = {0};
+ sid.cbSize = sizeof(sid);
+ sid.flags = SIDF_ALL_TCHAR;
+ sid.ptszSection = LPGENT("Gender");
+ TCHAR szFile[MAX_PATH];
+ GetModuleFileName(g_hInst, szFile, MAX_PATH);
+ sid.ptszDefaultFile = szFile;
- sid.ptszDescription = LPGENT("Male");
- sid.pszName = "male_icon";
- sid.iDefaultIndex = -IDI_MALE;
- g_hIconMale = (HANDLE)CallService(MS_SKIN2_ADDICON, 0, (LPARAM)&sid);
+ sid.ptszDescription = LPGENT("Male");
+ sid.pszName = "male_icon";
+ sid.iDefaultIndex = -IDI_MALE;
+ g_hIconMale = Skin_AddIcon(&sid);
- sid.ptszDescription = LPGENT("Female");
- sid.pszName = "female_icon";
- sid.iDefaultIndex = -IDI_FEMALE;
- g_hIconFemale = (HANDLE)CallService(MS_SKIN2_ADDICON, 0, (LPARAM)&sid);
+ sid.ptszDescription = LPGENT("Female");
+ sid.pszName = "female_icon";
+ sid.iDefaultIndex = -IDI_FEMALE;
+ g_hIconFemale = Skin_AddIcon(&sid);
- sid.ptszDescription = LPGENT("No info");
- sid.pszName = "menu_icon";
- sid.iDefaultIndex = -IDI_UNDEF;
- g_hIconMenu = (HANDLE)CallService(MS_SKIN2_ADDICON, 0, (LPARAM)&sid);
+ sid.ptszDescription = LPGENT("No info");
+ sid.pszName = "menu_icon";
+ sid.iDefaultIndex = -IDI_UNDEF;
+ g_hIconMenu = Skin_AddIcon(&sid);
- hIcoLibIconsChanged = HookEvent(ME_SKIN2_ICONSCHANGED, onExtraImageListRebuild);
- }
+ hIcoLibIconsChanged = HookEvent(ME_SKIN2_ICONSCHANGED, onExtraImageListRebuild);
g_hExtraIcon = ExtraIcon_Register("gender", "Gender", "menu_icon");
if (g_hExtraIcon != NULL)
diff --git a/plugins/HistorySweeperLight/options.c b/plugins/HistorySweeperLight/options.c index 53a2ab5bd9..f98f5dc67c 100644 --- a/plugins/HistorySweeperLight/options.c +++ b/plugins/HistorySweeperLight/options.c @@ -79,7 +79,7 @@ void InitIcons(void) sid.pszDescription = (char*)iconList[i].szDescr;
sid.iDefaultIndex = -iconList[i].defIconID;
- hIconLibItem[i] = (HANDLE)CallService(MS_SKIN2_ADDICON, 0, (LPARAM)&sid);
+ hIconLibItem[i] = Skin_AddIcon(&sid);
}
}
diff --git a/plugins/IgnoreState/main.cpp b/plugins/IgnoreState/main.cpp index 824569c959..014266df77 100644 --- a/plugins/IgnoreState/main.cpp +++ b/plugins/IgnoreState/main.cpp @@ -201,7 +201,7 @@ static VOID init_icolib (void) sid.pszName = iconList[i].szName;
sid.ptszDescription = iconList[i].szDescr;
sid.iDefaultIndex = -iconList[i].defIconID;
- iconList[i].hIconLibItem = (HANDLE) CallService(MS_SKIN2_ADDICON, 0, (LPARAM)&sid);
+ iconList[i].hIconLibItem = Skin_AddIcon(&sid);
}
// hIcoLibIconsChanged = HookEvent(ME_SKIN2_ICONSCHANGED, onExtraImageListRebuild);
}
diff --git a/plugins/MenuItemEx/main.c b/plugins/MenuItemEx/main.c index 1183559159..9088aaf6c5 100644 --- a/plugins/MenuItemEx/main.c +++ b/plugins/MenuItemEx/main.c @@ -252,14 +252,14 @@ static void IconsInit() sid.pszName = iconList[i].szName;
sid.ptszDescription = iconList[i].szDescr;
sid.iDefaultIndex = -iconList[i].defIconID;
- CallService(MS_SKIN2_ADDICON, 0, (LPARAM)&sid);
+ Skin_AddIcon(&sid);
}
for ( i = 0; i < SIZEOF(overlayIconList); i++ ) {
sid.pszName = overlayIconList[i].szName;
sid.ptszDescription = overlayIconList[i].szDescr;
sid.iDefaultIndex = -overlayIconList[i].defIconID;
- CallService(MS_SKIN2_ADDICON, 0, (LPARAM)&sid);
+ Skin_AddIcon(&sid);
}
}
diff --git a/plugins/MetaContacts/icons.c b/plugins/MetaContacts/icons.c index f10739ca0b..829636be1f 100644 --- a/plugins/MetaContacts/icons.c +++ b/plugins/MetaContacts/icons.c @@ -88,7 +88,7 @@ void InitIcons(void) { sid.pszDescription = Translate(iconList[i].szDescr);
sid.pszName = iconList[i].szName;
sid.iDefaultIndex = -iconList[i].defIconID;
- CallService(MS_SKIN2_ADDICON, 0, (LPARAM)&sid);
+ Skin_AddIcon(&sid);
}
hIcoLibIconsChanged = HookEvent(ME_SKIN2_ICONSCHANGED, ReloadIcons);
diff --git a/plugins/NewXstatusNotify/main.cpp b/plugins/NewXstatusNotify/main.cpp index 9d149e0c3b..e2eef82117 100644 --- a/plugins/NewXstatusNotify/main.cpp +++ b/plugins/NewXstatusNotify/main.cpp @@ -1318,7 +1318,7 @@ void InitIcolib() mir_snprintf(szSettingName, sizeof(szSettingName), "%s_%s", MODULE, iconList[i].szName);
sid.pszDescription = Translate(iconList[i].szDescr);
sid.iDefaultIndex = -iconList[i].iIconID;
- CallService(MS_SKIN2_ADDICON, 0, (LPARAM)&sid);
+ Skin_AddIcon(&sid);
}
}
diff --git a/plugins/Nudge/main.cpp b/plugins/Nudge/main.cpp index 5648e052a5..cf5538c2a1 100644 --- a/plugins/Nudge/main.cpp +++ b/plugins/Nudge/main.cpp @@ -390,23 +390,20 @@ void RegisterToDbeditorpp(void) void LoadIcons(void)
{
//Load icons
- if(ServiceExists(MS_SKIN2_ADDICON))
- {
- SKINICONDESC sid = {0};
- TCHAR szFilename[MAX_PATH];
- GetModuleFileName(hInst,szFilename,MAX_PATH);
-
- sid.cbSize = SKINICONDESC_SIZE;
- sid.flags = SIDF_ALL_TCHAR;
- sid.ptszSection = LPGENT("Nudge");
- sid.ptszDefaultFile = szFilename;
-
- sid.pszName = "Nudge_Default";
- sid.ptszDescription = LPGENT("Nudge as Default");
- sid.iDefaultIndex = -IDI_NUDGE;
- sid.hDefaultIcon = LoadIcon(hInst,MAKEINTRESOURCE(IDI_NUDGE));
- g_hIcon = (HANDLE)CallService(MS_SKIN2_ADDICON, 0, (LPARAM)&sid);
- }
+ SKINICONDESC sid = {0};
+ TCHAR szFilename[MAX_PATH];
+ GetModuleFileName(hInst,szFilename,MAX_PATH);
+
+ sid.cbSize = sizeof(sid);
+ sid.flags = SIDF_ALL_TCHAR;
+ sid.ptszSection = LPGENT("Nudge");
+ sid.ptszDefaultFile = szFilename;
+
+ sid.pszName = "Nudge_Default";
+ sid.ptszDescription = LPGENT("Nudge as Default");
+ sid.iDefaultIndex = -IDI_NUDGE;
+ sid.hDefaultIcon = LoadIcon(hInst,MAKEINTRESOURCE(IDI_NUDGE));
+ g_hIcon = Skin_AddIcon(&sid);
}
// Nudge support
@@ -791,7 +788,7 @@ void Nudge_AddAccount(PROTOACCOUNT *proto) mir_sntprintf(iconDesc, SIZEOF(iconDesc), TranslateT("Nudge for %s"), proto->tszAccountName);
SKINICONDESC sid = {0};
- sid.cbSize = SKINICONDESC_SIZE;
+ sid.cbSize = sizeof(sid);
sid.flags = SIDF_ALL_TCHAR;
sid.ptszSection = LPGENT("Nudge");
sid.ptszDefaultFile = szFilename;
@@ -799,7 +796,7 @@ void Nudge_AddAccount(PROTOACCOUNT *proto) sid.ptszDescription = iconDesc;
sid.iDefaultIndex = -IDI_NUDGE;
sid.hDefaultIcon = LoadIcon(hInst,MAKEINTRESOURCE(IDI_NUDGE));
- newNudge->item.hIcoLibItem = (HANDLE) CallService(MS_SKIN2_ADDICON, 0, (LPARAM)&sid);
+ newNudge->item.hIcoLibItem = Skin_AddIcon(&sid);
//Add contact menu entry
CLISTMENUITEM mi = {0};
diff --git a/plugins/PackUpdater/Src/Utils.cpp b/plugins/PackUpdater/Src/Utils.cpp index 533d1472eb..6841316644 100644 --- a/plugins/PackUpdater/Src/Utils.cpp +++ b/plugins/PackUpdater/Src/Utils.cpp @@ -59,7 +59,7 @@ VOID IcoLibInit() sid.pszName = iconList[i].szIconName;
sid.ptszDescription = iconList[i].tszDescr;
sid.iDefaultIndex = -iconList[i].IconID;
- CallService(MS_SKIN2_ADDICON, 0, (LPARAM)&sid);
+ Skin_AddIcon(&sid);
}
}
diff --git a/plugins/Popup/src/icons.cpp b/plugins/Popup/src/icons.cpp index 5bfd22f49c..e33d39ec83 100644 --- a/plugins/Popup/src/icons.cpp +++ b/plugins/Popup/src/icons.cpp @@ -140,6 +140,6 @@ void InitIcons() break;
}
}
- CallService(MS_SKIN2_ADDICON, 0, (LPARAM)&sid);
+ Skin_AddIcon(&sid);
}
}
\ No newline at end of file diff --git a/plugins/Popup/src/main.cpp b/plugins/Popup/src/main.cpp index 0a9beb7382..84b1921aa2 100644 --- a/plugins/Popup/src/main.cpp +++ b/plugins/Popup/src/main.cpp @@ -380,22 +380,6 @@ void LoadHotkey() { //Function which makes the initializations
static int ModulesLoaded(WPARAM wParam,LPARAM lParam)
{
- //check if 'Icon Library Manager' and 'FontService' exist (load icon and font later)
- if (!ServiceExists(MS_FONT_REGISTER) || !ServiceExists(MS_SKIN2_ADDICON)) {
- LPTSTR msg = TranslateTS(
- _T("This version of Popup Plus requires\r\n")
- _T("'Icon Library Manager' and 'FontService'\r\n")
- _T("modules.\r\n")
- _T("\r\n")
- _T("You always can download them at\r\n")
- _T("http://addons.miranda-im.org/\r\n")
- _T("\r\n")
- _T("Do you want to visit Miranda IM homepage now?\r\n"));
- if (MessageBox(NULL, msg, _T("Popup Plus Error"), MB_YESNO|MB_ICONSTOP) == IDYES)
- ShellExecute(NULL, _T("open"), _T("http://addons.miranda-im.org/"), NULL, NULL, SW_SHOWNORMAL);
- return 0;
- }
-
//check if History++ is installed
gbHppInstalled = ServiceExists(MS_HPP_GETVERSION) && ServiceExists(MS_HPP_EG_WINDOW) &&
(CallService(MS_HPP_GETVERSION, 0, 0) >= PLUGIN_MAKE_VERSION(1,5,0,112));
diff --git a/plugins/Popup/src/notifications.cpp b/plugins/Popup/src/notifications.cpp index 97be02af44..3a8beb8f15 100644 --- a/plugins/Popup/src/notifications.cpp +++ b/plugins/Popup/src/notifications.cpp @@ -235,7 +235,7 @@ HANDLE RegisterNotification(POPUPNOTIFICATION *notification) sid.pszName = setting;
sid.pszDescription = notification->lpzName;
sid.hDefaultIcon = notification->lchIcon;
- CallService(MS_SKIN2_ADDICON, 0, (LPARAM)&sid);
+ Skin_AddIcon(&sid);
gTreeData.insert(ptd);
return (HANDLE)ptd;
diff --git a/plugins/QuickMessages/Utils.c b/plugins/QuickMessages/Utils.c index 41b3710664..8b80502064 100644 --- a/plugins/QuickMessages/Utils.c +++ b/plugins/QuickMessages/Utils.c @@ -375,7 +375,7 @@ int AddIcon(HICON icon, char *name, char *description) sid.pszName = name;
sid.hDefaultIcon = icon;
- return CallService(MS_SKIN2_ADDICON, 0, (LPARAM) &sid);
+ return Skin_AddIcon( &sid);
}
int RegisterCustomButton(WPARAM wParam,LPARAM lParam)
diff --git a/plugins/QuickReplies/events.cpp b/plugins/QuickReplies/events.cpp index fd4991423d..2227c6d6f1 100644 --- a/plugins/QuickReplies/events.cpp +++ b/plugins/QuickReplies/events.cpp @@ -35,7 +35,7 @@ INT_PTR QuickRepliesService(WPARAM, LPARAM) int OnModulesLoaded(WPARAM wParam, LPARAM lParam)
{
UnhookEvent(hOnModulesLoaded);
- HICON hIcon = NULL;
+ HANDLE hIcon = NULL;
char buttonName[32];
if (!ServiceExists(MS_QUICKREPLIES_SERVICE))
@@ -43,34 +43,26 @@ int OnModulesLoaded(WPARAM wParam, LPARAM lParam) iNumber = 0;
hQuickRepliesService = CreateServiceFunction(MS_QUICKREPLIES_SERVICE, QuickRepliesService);
}
- else
- iNumber = DBGetContactSettingByte(NULL, MODULE_NAME, "InstancesCount", 0);
+ else iNumber = DBGetContactSettingByte(NULL, MODULE_NAME, "InstancesCount", 0);
DBWriteContactSettingByte(NULL, MODULE_NAME, "InstancesCount", iNumber + 1);
hOnOptInitialized = HookEvent(ME_OPT_INITIALISE, OnOptInitialized);
hOnButtonPressed = HookEvent(ME_MSG_BUTTONPRESSED, OnButtonPressed);
- if (ServiceExists(MS_SKIN2_ADDICON))
- {
- char buttonNameTranslated[32];
- mir_snprintf(buttonName, SIZEOF(buttonName), "Button %x", iNumber + 1);
- mir_snprintf(buttonNameTranslated, SIZEOF(buttonNameTranslated), "%s %x",Translate("Button"), iNumber + 1);
-
- SKINICONDESC sid = {0};
- sid.cbSize = sizeof(SKINICONDESC);
- sid.pszSection = "TabSRMM/Quick Replies";
- sid.cx = sid.cy = 16;
- sid.pszDescription = buttonNameTranslated;
- sid.pszName = buttonName;
- sid.hDefaultIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_QICON));
-
- hIcon = (HICON)CallService(MS_SKIN2_ADDICON, 0, (LPARAM) &sid);
- }
- else
- hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_QICON));
+ char buttonNameTranslated[32];
+ mir_snprintf(buttonName, SIZEOF(buttonName), "Button %x", iNumber + 1);
+ mir_snprintf(buttonNameTranslated, SIZEOF(buttonNameTranslated), "%s %x",Translate("Button"), iNumber + 1);
- if (ServiceExists(MS_BB_ADDBUTTON))
- {
+ SKINICONDESC sid = {0};
+ sid.cbSize = sizeof(sid);
+ sid.pszSection = "TabSRMM/Quick Replies";
+ sid.cx = sid.cy = 16;
+ sid.pszDescription = buttonNameTranslated;
+ sid.pszName = buttonName;
+ sid.hDefaultIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_QICON));
+ hIcon = Skin_AddIcon(&sid);
+
+ if (ServiceExists(MS_BB_ADDBUTTON)) {
mir_snprintf(buttonName, SIZEOF(buttonName), MODULE_NAME" %x", iNumber + 1);
BBButton bbd = {0};
@@ -78,15 +70,13 @@ int OnModulesLoaded(WPARAM wParam, LPARAM lParam) bbd.bbbFlags = BBBF_ISIMBUTTON | BBBF_ISCHATBUTTON | BBBF_ISLSIDEBUTTON;
bbd.pszModuleName = buttonName;
bbd.ptszTooltip = _T("Quick Replies\r\nLeft button - open menu\r\nRight button - options page");
- bbd.hIcon = (HANDLE)hIcon;
+ bbd.hIcon = hIcon;
bbd.dwButtonID = iNumber;
bbd.dwDefPos = 220;
CallService(MS_BB_ADDBUTTON, 0, (LPARAM)&bbd);
}
- DestroyIcon(hIcon);
-
return 0;
}
diff --git a/plugins/Rate/main.cpp b/plugins/Rate/main.cpp index d5a7fcbf71..d1f1b0f71f 100644 --- a/plugins/Rate/main.cpp +++ b/plugins/Rate/main.cpp @@ -173,20 +173,20 @@ int onExtraImageListRebuild(WPARAM wParam, LPARAM lParam) static void init_icolib (void)
{
- SKINICONDESC sid = {0};
- char szFile[MAX_PATH];
- sid.cbSize = SKINICONDESC_SIZE_V1;
- int i = 0;
+ TCHAR szFile[MAX_PATH];
+ GetModuleFileName(g_hInst, szFile, MAX_PATH);
+ SKINICONDESC sid = {0};
+ sid.cbSize = sizeof(sid);
sid.pszSection = Translate("Contact Rate");
- GetModuleFileNameA(g_hInst, szFile, MAX_PATH);
sid.pszDefaultFile = szFile;
+ sid.flags = SIDF_PATH_TCHAR;
- for ( i = 0; i < SIZEOF(iconList); i++ ) {
+ for (int i = 0; i < SIZEOF(iconList); i++ ) {
sid.pszName = iconList[i].szName;
- sid.ptszDescription = iconList[i].szDescr;
+ sid.pszDescription = iconList[i].szDescr;
sid.iDefaultIndex = -iconList[i].defIconID;
- iconList[i].hIconLibItem = (HANDLE) CallService(MS_SKIN2_ADDICON, 0, (LPARAM)&sid);
+ iconList[i].hIconLibItem = Skin_AddIcon(&sid);
}
}
diff --git a/plugins/SRMM/globals.c b/plugins/SRMM/globals.c index 11e7606158..802bc9fccc 100644 --- a/plugins/SRMM/globals.c +++ b/plugins/SRMM/globals.c @@ -64,7 +64,7 @@ static void InitIcons(void) mir_snprintf(szSettingName, sizeof(szSettingName), "SRMM_%s", iconList[i].szName);
sid.pszDescription = (char*)iconList[i].szDescr;
sid.iDefaultIndex = -iconList[i].defIconID;
- hIconLibItem[i] = (HANDLE)CallService(MS_SKIN2_ADDICON, 0, (LPARAM)&sid);
+ hIconLibItem[i] = Skin_AddIcon(&sid);
}
}
diff --git a/plugins/Scriver/globals.c b/plugins/Scriver/globals.c index c1006bd8f7..d92ca958f4 100644 --- a/plugins/Scriver/globals.c +++ b/plugins/Scriver/globals.c @@ -171,7 +171,7 @@ void RegisterIcons(void) sid.cx = sid.cy = iconList[i].size;
sid.iDefaultIndex = -iconList[i].defaultIndex;
sid.ptszDescription = (TCHAR*)iconList[i].description;
- CallService(MS_SKIN2_ADDICON, 0, (LPARAM)&sid);
+ Skin_AddIcon(&sid);
}
}
diff --git a/plugins/SecureIM/loadicons.cpp b/plugins/SecureIM/loadicons.cpp index ec6d0ae17e..3303424626 100644 --- a/plugins/SecureIM/loadicons.cpp +++ b/plugins/SecureIM/loadicons.cpp @@ -65,27 +65,21 @@ void InitIcons(void) g_hIconInst = hNewIconInst;
- SKINICONDESC sid;
- memset(&sid,0,sizeof(sid));
-
- sid.cbSize = sizeof(SKINICONDESC);
+ SKINICONDESC sid = { 0 };
+ sid.cbSize = sizeof(sid);
sid.pszSection = "SecureIM";
HICON hIcon;
for (int i=0; icons[i].key; i++) {
- if(ServiceExists(MS_SKIN2_ADDICON)) {
- sid.pszSection = icons[i].section;
- sid.pszName = icons[i].name;
- sid.pszDescription = icons[i].text;
- sid.pszDefaultFile = "secureim_icons.dll";
- sid.iDefaultIndex = icons[i].key;
- sid.hDefaultIcon = (HICON)LoadImage(g_hIconInst, MAKEINTRESOURCE(icons[i].key), IMAGE_ICON, 16, 16, LR_SHARED);
- CallService(MS_SKIN2_ADDICON, 0, (LPARAM)&sid);
- hIcon = (HICON)CallService(MS_SKIN2_GETICON, 0, (LPARAM)icons[i].name);
- }
- else {
- hIcon = (HICON)LoadImage(g_hIconInst, MAKEINTRESOURCE(icons[i].key), IMAGE_ICON, 16, 16, LR_SHARED);
- }
+ sid.pszSection = icons[i].section;
+ sid.pszName = icons[i].name;
+ sid.pszDescription = icons[i].text;
+ sid.pszDefaultFile = "secureim_icons.dll";
+ sid.iDefaultIndex = icons[i].key;
+ sid.hDefaultIcon = (HICON)LoadImage(g_hIconInst, MAKEINTRESOURCE(icons[i].key), IMAGE_ICON, 16, 16, LR_SHARED);
+ Skin_AddIcon(&sid);
+ hIcon = (HICON)CallService(MS_SKIN2_GETICON, 0, (LPARAM)icons[i].name);
+
if(icons[i].tbl == TBL_IEC)
g_hIEC[icons[i].idx]=hIcon;
else
@@ -96,9 +90,7 @@ void InitIcons(void) g_hPOP[icons[i].idx]=hIcon;
}
- if(ServiceExists(MS_SKIN2_ADDICON)) {
- AddHookFunction(ME_SKIN2_ICONSCHANGED, ReloadIcons);
- }
+ AddHookFunction(ME_SKIN2_ICONSCHANGED, ReloadIcons);
}
// EOF
diff --git a/plugins/Sessions/Src/Main.cpp b/plugins/Sessions/Src/Main.cpp index a002af0f87..2e418dbb88 100644 --- a/plugins/Sessions/Src/Main.cpp +++ b/plugins/Sessions/Src/Main.cpp @@ -951,12 +951,11 @@ static int PluginInit(WPARAM wparam,LPARAM lparam) hiSessionsSave = LoadIcon(hinstance, MAKEINTRESOURCE(IDD_SESSIONS_SAVE));
hiSessionsLoadLast = LoadIcon(hinstance, MAKEINTRESOURCE(IDD_SESSIONS_LOADLAST));
- hibChecked =(HANDLE)AddIcon(hiChecked, "SessionMarked", _T("Favorite Session"));
- hibNotChecked =(HANDLE)AddIcon(hiNotChecked, "SessionUnMarked", _T("Not favorite Session"));
-
- hibSessionsLoad =(HANDLE)AddIcon(hiSessionsLoad, "SessionsLoad", _T("Load Session"));
- hibSessionsSave =(HANDLE)AddIcon(hiSessionsSave, "SessionsSave", _T("Save Session"));
- hibSessionsLoadLast =(HANDLE)AddIcon(hiSessionsLoadLast, "SessionsLoadLast", _T("Load last Session"));
+ hibChecked = AddIcon(hiChecked, "SessionMarked", LPGENT("Favorite Session"));
+ hibNotChecked = AddIcon(hiNotChecked, "SessionUnMarked", LPGENT("Not favorite Session"));
+ hibSessionsLoad = AddIcon(hiSessionsLoad, "SessionsLoad", LPGENT("Load Session"));
+ hibSessionsSave = AddIcon(hiSessionsSave, "SessionsSave", LPGENT("Save Session"));
+ hibSessionsLoadLast = AddIcon(hiSessionsLoadLast, "SessionsLoadLast", LPGENT("Load last Session"));
CLISTMENUITEM cl;
ZeroMemory(&cl, sizeof(cl));
diff --git a/plugins/Sessions/Src/Utils.cpp b/plugins/Sessions/Src/Utils.cpp index a4859e7874..26adc41513 100644 --- a/plugins/Sessions/Src/Utils.cpp +++ b/plugins/Sessions/Src/Utils.cpp @@ -535,7 +535,7 @@ BYTE IsMarkedUserDefSession(int ses_count) return DBGetContactSettingByte(NULL, __INTERNAL_NAME, szSessionName, 0);
}
-int AddIcon(HICON icon, char *name, TCHAR *description)
+HANDLE AddIcon(HICON icon, char *name, TCHAR *description)
{
SKINICONDESC sid = {0};
sid.cbSize = sizeof(SKINICONDESC);
@@ -545,7 +545,7 @@ int AddIcon(HICON icon, char *name, TCHAR *description) sid.ptszDescription = description;
sid.pszName = name;
sid.hDefaultIcon = icon;
- return CallService(MS_SKIN2_ADDICON, 0, (LPARAM) &sid);
+ return Skin_AddIcon( &sid);
}
void SavePosition(HWND hwnd, char *wndName)
diff --git a/plugins/Sessions/Src/Utils.h b/plugins/Sessions/Src/Utils.h index ce4fe75a59..f73dad00ad 100644 --- a/plugins/Sessions/Src/Utils.h +++ b/plugins/Sessions/Src/Utils.h @@ -33,7 +33,7 @@ int CheckForDuplicate(DWORD contact_list[],DWORD lparam); BOOL ResaveSettings(char* szName,int iFirst,int iLimit,TCHAR* pszPrevSetting);
void OffsetWindow(HWND parent, HWND hwnd, int dx, int dy);
int LoadSessionToCombobox (HWND hdlg,BOOL mode,int iLimit,char* pszSetting,int iFirstNum);
-int AddIcon(HICON icon, char *name, TCHAR *description);
+HANDLE AddIcon(HICON icon, char *name, TCHAR *description);
int MarkUserDefSession(int ses_count,BYTE bCheck);
BYTE IsMarkedUserDefSession(int ses_count);
void SavePosition(HWND hWnd, char *wndName);
diff --git a/plugins/SimpleStatusMsg/utils.cpp b/plugins/SimpleStatusMsg/utils.cpp index da2584cd22..549dd957bc 100644 --- a/plugins/SimpleStatusMsg/utils.cpp +++ b/plugins/SimpleStatusMsg/utils.cpp @@ -64,7 +64,7 @@ void IconsInit(void) sid.pszName = szSettingName;
sid.ptszDescription = (TCHAR*)iconList[i].szDescr;
sid.iDefaultIndex = -iconList[i].defIconID;
- hIconLibItem[i] = (HANDLE)CallService(MS_SKIN2_ADDICON, 0, (LPARAM)&sid);
+ hIconLibItem[i] = Skin_AddIcon(&sid);
}
}
diff --git a/plugins/SmileyAdd/main.cpp b/plugins/SmileyAdd/main.cpp index 92a7285a45..e647b694c2 100644 --- a/plugins/SmileyAdd/main.cpp +++ b/plugins/SmileyAdd/main.cpp @@ -64,7 +64,7 @@ static const PLUGININFOEX pluginInfoEx = static SKINICONDESC skinDesc =
{
- SKINICONDESC_SIZE_V1, "SmileyAdd", NULL,
+ sizeof(SKINICONDESC), "SmileyAdd", NULL,
"SmileyAdd_ButtonSmiley", NULL, -IDI_SMILINGICON
};
@@ -88,7 +88,7 @@ static int ModulesLoaded(WPARAM, LPARAM) skinDesc.pszDefaultFile = path;
skinDesc.pszDescription = LPGEN("Button Smiley");
- HANDLE hSkinIcon = (HANDLE)CallService(MS_SKIN2_ADDICON, 0, (LPARAM)&skinDesc);
+ HANDLE hSkinIcon = Skin_AddIcon(&skinDesc);
INT_PTR temp = CallService(MS_MC_GETPROTOCOLNAME, 0, 0);
metaProtoName = mir_strdup(temp == CALLSERVICE_NOTFOUND ? NULL : (char*)temp);
diff --git a/plugins/SpellChecker/spellchecker.cpp b/plugins/SpellChecker/spellchecker.cpp index 09802db20e..d5ed23c822 100644 --- a/plugins/SpellChecker/spellchecker.cpp +++ b/plugins/SpellChecker/spellchecker.cpp @@ -262,7 +262,7 @@ int ModulesLoaded(WPARAM wParam, LPARAM lParam) sid.ptszDescription = iconList[i].szDescr; sid.pszName = iconList[i].szName; sid.iDefaultIndex = -iconList[i].defIconID; - CallService(MS_SKIN2_ADDICON, 0, (LPARAM)&sid); + Skin_AddIcon(&sid); } InitOptions(); @@ -318,7 +318,7 @@ int ModulesLoaded(WPARAM wParam, LPARAM lParam) } // Oki, lets add to IcoLib, then - CallService(MS_SKIN2_ADDICON, 0, (LPARAM)&sid); + Skin_AddIcon(&sid); if (hFlag != NULL) DestroyIcon(hFlag); diff --git a/plugins/Svc_crshdmp/crshdmp_icons.cpp b/plugins/Svc_crshdmp/crshdmp_icons.cpp index 7b983bf0d0..1f7106303f 100644 --- a/plugins/Svc_crshdmp/crshdmp_icons.cpp +++ b/plugins/Svc_crshdmp/crshdmp_icons.cpp @@ -55,7 +55,7 @@ void InitIcons(void) sid.pszDescription = (char*)iconList[i].szDescr;
sid.iDefaultIndex = -iconList[i].defIconID;
- hIconLibItem[i] = (HANDLE)CallService(MS_SKIN2_ADDICON, 0, (LPARAM)&sid);
+ hIconLibItem[i] = Skin_AddIcon(&sid);
}
}
diff --git a/plugins/Svc_dbepp/headers.h b/plugins/Svc_dbepp/headers.h index 97a530291c..57663f56e1 100644 --- a/plugins/Svc_dbepp/headers.h +++ b/plugins/Svc_dbepp/headers.h @@ -53,7 +53,6 @@ /////// icons support
-extern BYTE UsingIconManager;
void addIcons(TCHAR* szModuleFileName);
HICON LoadSkinnedDBEIcon(int icon);
int AddIconToList(HIMAGELIST hil, HICON hIcon);
diff --git a/plugins/Svc_dbepp/icons.cpp b/plugins/Svc_dbepp/icons.cpp index f6ac36e95e..ae77539ae0 100644 --- a/plugins/Svc_dbepp/icons.cpp +++ b/plugins/Svc_dbepp/icons.cpp @@ -16,72 +16,64 @@ void addIcons(TCHAR* szModuleFileName) mir_snprintf(name, SIZEOF(name), "DBE++_%d", ICO_KNOWN);
sid.pszName = name;
sid.iDefaultIndex = -ICO_KNOWN;
- CallService(MS_SKIN2_ADDICON,0,(LPARAM)&sid);
+ Skin_AddIcon(&sid);
// open known module
sid.ptszDescription = LPGENT("Open Known Module");
mir_snprintf(name, SIZEOF(name), "DBE++_%d", ICO_KNOWNOPEN);
sid.pszName = name;
sid.iDefaultIndex = -ICO_KNOWNOPEN;
- CallService(MS_SKIN2_ADDICON,0,(LPARAM)&sid);
+ Skin_AddIcon(&sid);
// closed unknown module
sid.ptszDescription = LPGENT("Closed Unknown Module");
mir_snprintf(name, SIZEOF(name), "DBE++_%d", ICO_UNKNOWN);
sid.pszName = name;
sid.iDefaultIndex = -ICO_UNKNOWN;
- CallService(MS_SKIN2_ADDICON,0,(LPARAM)&sid);
+ Skin_AddIcon(&sid);
// open unknown module
sid.ptszDescription = LPGENT("Open Unknown Module");
mir_snprintf(name, SIZEOF(name), "DBE++_%d", ICO_UNKNOWNOPEN);
sid.pszName = name;
sid.iDefaultIndex = -ICO_UNKNOWNOPEN;
- CallService(MS_SKIN2_ADDICON,0,(LPARAM)&sid);
+ Skin_AddIcon(&sid);
// settings contact
sid.ptszDescription = LPGENT("Settings");
mir_snprintf(name, SIZEOF(name), "DBE++_%d", ICO_SETTINGS);
sid.pszName = name;
sid.iDefaultIndex = -ICO_SETTINGS;
- CallService(MS_SKIN2_ADDICON,0,(LPARAM)&sid);
+ Skin_AddIcon(&sid);
// contact group
sid.ptszDescription = LPGENT("Contacts Group");
mir_snprintf(name, SIZEOF(name), "DBE++_%d", ICO_CONTACTS);
sid.pszName = name;
sid.iDefaultIndex = -ICO_CONTACTS;
- CallService(MS_SKIN2_ADDICON,0,(LPARAM)&sid);
+ Skin_AddIcon(&sid);
// unknwon contact
sid.ptszDescription = LPGENT("Unknown Contact");
mir_snprintf(name, SIZEOF(name), "DBE++_%d", ICO_OFFLINE);
sid.pszName = name;
sid.iDefaultIndex = -ICO_OFFLINE;
- CallService(MS_SKIN2_ADDICON,0,(LPARAM)&sid);
+ Skin_AddIcon(&sid);
// known contact
sid.ptszDescription = LPGENT("Known Contact");
mir_snprintf(name, SIZEOF(name), "DBE++_%d", ICO_ONLINE);
sid.pszName = name;
sid.iDefaultIndex = -ICO_ONLINE;
- CallService(MS_SKIN2_ADDICON,0,(LPARAM)&sid);
+ Skin_AddIcon(&sid);
}
HICON LoadSkinnedDBEIcon(int icon)
{
- HICON hIcon = 0;
- if (UsingIconManager)
- {
- char name[32];
- mir_snprintf(name, SIZEOF(name), "DBE++_%d", icon);
-
- hIcon = (HICON)CallService(MS_SKIN2_GETICON,0,(LPARAM)name);
- }
- if (!hIcon)
- return LoadIcon(hInst, MAKEINTRESOURCE(icon));
- else
- return hIcon;
+ char name[32];
+ mir_snprintf(name, SIZEOF(name), "DBE++_%d", icon);
+ HICON hIcon = (HICON)CallService(MS_SKIN2_GETICON,0,(LPARAM)name);
+ return (hIcon) ? hIcon : LoadIcon(hInst, MAKEINTRESOURCE(icon));
}
diff --git a/plugins/Svc_dbepp/main.cpp b/plugins/Svc_dbepp/main.cpp index 0c7eec1a0f..c1507b3797 100644 --- a/plugins/Svc_dbepp/main.cpp +++ b/plugins/Svc_dbepp/main.cpp @@ -18,7 +18,6 @@ BYTE nameOrder[NAMEORDERCOUNT]; HANDLE hUserMenu;
HANDLE hRestore;
WatchListArrayStruct WatchListArray;
-BYTE UsingIconManager;
HANDLE sMenuCommand, sRegisterModule, sRegisterSingleModule, sImport, sServicemodeLaunch;
HANDLE hModulesLoadedHook = NULL, hSettingsChangedHook=NULL, hOptInitHook=NULL, hPreShutdownHook=NULL, hTTBHook = NULL;
@@ -212,13 +211,8 @@ int ModulesLoaded(WPARAM wParam,LPARAM lParam) doOldKnownModulesList(); // add the old plugins which havnt been changed over yet..
// icons
- if (GetModuleFileName(hInst, szModuleFileName, MAX_PATH) && ServiceExists(MS_SKIN2_ADDICON))
- {
- UsingIconManager =1;
+ if (GetModuleFileName(hInst, szModuleFileName, MAX_PATH))
addIcons(szModuleFileName);
- }
- else
- UsingIconManager = 0;
DBFreeVariant(&dbv);
UnhookEvent(hModulesLoadedHook);
diff --git a/plugins/TabSRMM/chat/options.cpp b/plugins/TabSRMM/chat/options.cpp index 28f0362869..6a3da75c8d 100644 --- a/plugins/TabSRMM/chat/options.cpp +++ b/plugins/TabSRMM/chat/options.cpp @@ -426,71 +426,67 @@ static void LoadLogFonts(void) LoadMsgDlgFont(FONTSECTION_CHAT, i, &aFonts[i].lf, &aFonts[i].color, CHAT_FONTMODULE);
}
-static struct _tagicons { char *szDesc; char *szName; int id; UINT size;} _icons[] = {
- LPGEN("Window Icon"), "chat_window", IDI_CHANMGR, 16,
- LPGEN("Icon overlay"), "chat_overlay", IDI_OVERLAY, 16,
-
- LPGEN("Status 1 (10x10)"), "chat_status0", IDI_STATUS0, 16,
- LPGEN("Status 2 (10x10)"), "chat_status1", IDI_STATUS1, 16,
- LPGEN("Status 3 (10x10)"), "chat_status2", IDI_STATUS2, 16,
- LPGEN("Status 4 (10x10)"), "chat_status3", IDI_STATUS3, 16,
- LPGEN("Status 5 (10x10)"), "chat_status4", IDI_STATUS4, 16,
- LPGEN("Status 6 (10x10)"), "chat_status5", IDI_STATUS5, 16,
- NULL, NULL, -1, 0
+struct { char *szDesc; char *szName; int id; UINT size;} static _icons[] =
+{
+ { LPGEN("Window Icon"), "chat_window", IDI_CHANMGR, 16 },
+ { LPGEN("Icon overlay"), "chat_overlay", IDI_OVERLAY, 16 },
+
+ { LPGEN("Status 1 (10x10)"), "chat_status0", IDI_STATUS0, 16 },
+ { LPGEN("Status 2 (10x10)"), "chat_status1", IDI_STATUS1, 16 },
+ { LPGEN("Status 3 (10x10)"), "chat_status2", IDI_STATUS2, 16 },
+ { LPGEN("Status 4 (10x10)"), "chat_status3", IDI_STATUS3, 16 },
+ { LPGEN("Status 5 (10x10)"), "chat_status4", IDI_STATUS4, 16 },
+ { LPGEN("Status 6 (10x10)"), "chat_status5", IDI_STATUS5, 16 },
};
-static struct _tag1icons { char *szDesc; char *szName; int id; UINT size;} _logicons[] = {
- LPGEN("Message in (10x10)"), "chat_log_message_in", IDI_MESSAGE, 16,
- LPGEN("Message out (10x10)"), "chat_log_message_out", IDI_MESSAGEOUT, 16,
- LPGEN("Action (10x10)"), "chat_log_action", IDI_ACTION, 16,
- LPGEN("Add Status (10x10)"), "chat_log_addstatus", IDI_ADDSTATUS, 16,
- LPGEN("Remove Status (10x10)"), "chat_log_removestatus", IDI_REMSTATUS, 16,
- LPGEN("Join (10x10)"), "chat_log_join", IDI_JOIN, 16,
- LPGEN("Leave (10x10)"), "chat_log_part", IDI_PART, 16,
- LPGEN("Quit (10x10)"), "chat_log_quit", IDI_QUIT, 16,
- LPGEN("Kick (10x10)"), "chat_log_kick", IDI_KICK, 16,
- LPGEN("Notice (10x10)"), "chat_log_notice", IDI_NOTICE, 16,
- LPGEN("Nickchange (10x10)"), "chat_log_nick", IDI_NICK, 16,
- LPGEN("Topic (10x10)"), "chat_log_topic", IDI_TOPIC, 16,
- LPGEN("Highlight (10x10)"), "chat_log_highlight", IDI_HIGHLIGHT, 16,
- LPGEN("Information (10x10)"), "chat_log_info", IDI_INFO, 16,
- NULL, NULL, 0, 0
+struct { char *szDesc; char *szName; int id; UINT size;} static _logicons[] =
+{
+ { LPGEN("Message in (10x10)"), "chat_log_message_in", IDI_MESSAGE, 16 },
+ { LPGEN("Message out (10x10)"), "chat_log_message_out", IDI_MESSAGEOUT, 16 },
+ { LPGEN("Action (10x10)"), "chat_log_action", IDI_ACTION, 16 },
+ { LPGEN("Add Status (10x10)"), "chat_log_addstatus", IDI_ADDSTATUS, 16 },
+ { LPGEN("Remove Status (10x10)"), "chat_log_removestatus", IDI_REMSTATUS, 16 },
+ { LPGEN("Join (10x10)"), "chat_log_join", IDI_JOIN, 16 },
+ { LPGEN("Leave (10x10)"), "chat_log_part", IDI_PART, 16 },
+ { LPGEN("Quit (10x10)"), "chat_log_quit", IDI_QUIT, 16 },
+ { LPGEN("Kick (10x10)"), "chat_log_kick", IDI_KICK, 16 },
+ { LPGEN("Notice (10x10)"), "chat_log_notice", IDI_NOTICE, 16 },
+ { LPGEN("Nickchange (10x10)"), "chat_log_nick", IDI_NICK, 16 },
+ { LPGEN("Topic (10x10)"), "chat_log_topic", IDI_TOPIC, 16 },
+ { LPGEN("Highlight (10x10)"), "chat_log_highlight", IDI_HIGHLIGHT, 16 },
+ { LPGEN("Information (10x10)"), "chat_log_info", IDI_INFO, 16 }
};
// add icons to the skinning module
void Chat_AddIcons(void)
{
- if (ServiceExists(MS_SKIN2_ADDICON)) {
- SKINICONDESC sid = {0};
- char szFile[MAX_PATH];
- int i = 0;
-
- // 16x16 icons
- sid.cbSize = sizeof(SKINICONDESC);
- sid.pszSection = TranslateA("TabSRMM/Group chat windows");
- GetModuleFileNameA(g_hIconDLL, szFile, MAX_PATH);
- sid.pszDefaultFile = szFile;
-
- while (_icons[i].szDesc != NULL) {
- sid.cx = sid.cy = _icons[i].size;
- sid.pszDescription = _icons[i].szDesc;
- sid.pszName = _icons[i].szName;
- sid.iDefaultIndex = -_icons[i].id;
- CallService(MS_SKIN2_ADDICON, 0, (LPARAM)&sid);
- i++;
- }
- i = 0;
- sid.pszSection = TranslateA("TabSRMM/Group chat log");
- while (_logicons[i].szDesc != NULL) {
- sid.cx = sid.cy = _logicons[i].size;
- sid.pszDescription = _logicons[i].szDesc;
- sid.pszName = _logicons[i].szName;
- sid.iDefaultIndex = -_logicons[i].id;
- CallService(MS_SKIN2_ADDICON, 0, (LPARAM)&sid);
- i++;
- }
+ int i;
+ TCHAR szFile[MAX_PATH];
+ GetModuleFileName(g_hIconDLL, szFile, SIZEOF(szFile));
+
+ // 16x16 icons
+ SKINICONDESC sid = {0};
+ sid.cbSize = sizeof(SKINICONDESC);
+ sid.pszSection = "TabSRMM/Group chat windows";
+ sid.ptszDefaultFile = szFile;
+ sid.flags = SIDF_PATH_TCHAR;
+
+ for (i=0; i < SIZEOF(_icons); i++) {
+ sid.cx = sid.cy = _icons[i].size;
+ sid.pszDescription = _icons[i].szDesc;
+ sid.pszName = _icons[i].szName;
+ sid.iDefaultIndex = -_icons[i].id;
+ Skin_AddIcon(&sid);
+ }
+
+ sid.pszSection = "TabSRMM/Group chat log";
+ for (i=0; i < SIZEOF(_logicons); i++) {
+ sid.cx = sid.cy = _logicons[i].size;
+ sid.pszDescription = _logicons[i].szDesc;
+ sid.pszName = _logicons[i].szName;
+ sid.iDefaultIndex = -_logicons[i].id;
+ Skin_AddIcon(&sid);
}
- return;
}
/*
diff --git a/plugins/TabSRMM/src/msgs.cpp b/plugins/TabSRMM/src/msgs.cpp index 214d65ac54..e1081ab5c3 100644 --- a/plugins/TabSRMM/src/msgs.cpp +++ b/plugins/TabSRMM/src/msgs.cpp @@ -1076,9 +1076,9 @@ static int TSAPI SetupIconLibConfig() sid.iDefaultIndex = ICONBLOCKS[n].idesc[i].uId == -IDI_HISTORY ? 0 : ICONBLOCKS[n].idesc[i].uId; // workaround problem /w icoLib and a resource id of 1 (actually, a Windows problem)
i++;
if(n>0&&n<4)
- PluginConfig.g_buttonBarIconHandles[j++]=(HANDLE)CallService(MS_SKIN2_ADDICON, 0, (LPARAM)&sid);
+ PluginConfig.g_buttonBarIconHandles[j++] = Skin_AddIcon(&sid);
else
- CallService(MS_SKIN2_ADDICON, 0, (LPARAM)&sid);
+ Skin_AddIcon(&sid);
}
n++;
}
@@ -1088,19 +1088,19 @@ static int TSAPI SetupIconLibConfig() sid.pszName = "tabSRMM_clock_symbol";
sid.pszDescription = "Clock symbol (for the info panel clock)";
sid.iDefaultIndex = -IDI_CLOCK;
- CallService(MS_SKIN2_ADDICON, 0, (LPARAM)&sid);
+ Skin_AddIcon(&sid);
strncpy(szFilename, "plugins\\tabsrmm.dll", MAX_PATH);
sid.pszName = "tabSRMM_overlay_disabled";
sid.pszDescription = "Feature disabled (used as overlay)";
sid.iDefaultIndex = -IDI_FEATURE_DISABLED;
- CallService(MS_SKIN2_ADDICON, 0, (LPARAM)&sid);
+ Skin_AddIcon(&sid);
sid.pszName = "tabSRMM_overlay_enabled";
sid.pszDescription = "Feature enabled (used as overlay)";
sid.iDefaultIndex = -IDI_FEATURE_ENABLED;
- CallService(MS_SKIN2_ADDICON, 0, (LPARAM)&sid);
+ Skin_AddIcon(&sid);
return 1;
diff --git a/plugins/TranslitSwitcher/Src/TranslitSwitcher.cpp b/plugins/TranslitSwitcher/Src/TranslitSwitcher.cpp index b6f0e43207..e762b2a5a0 100644 --- a/plugins/TranslitSwitcher/Src/TranslitSwitcher.cpp +++ b/plugins/TranslitSwitcher/Src/TranslitSwitcher.cpp @@ -78,7 +78,7 @@ INT_PTR ServiceInvert(WPARAM wParam, LPARAM lParam) int OnModulesLoaded(WPARAM wParam, LPARAM lParam)
{
- HICON hSwitchIcon = NULL, hTranslitIcon = NULL, hInvertIcon = NULL;
+ HANDLE hSwitchIcon = NULL, hTranslitIcon = NULL, hInvertIcon = NULL;
HOTKEYDESC hkd = {0};
hkd.cbSize = sizeof(hkd);
@@ -135,8 +135,7 @@ int OnModulesLoaded(WPARAM wParam, LPARAM lParam) Hotkey_Register(&hkd);
hOnButtonPressed = HookEvent(ME_MSG_BUTTONPRESSED, OnButtonPressed);
- if (ServiceExists(MS_BB_ADDBUTTON) && ServiceExists(MS_SKIN2_ADDICON))
- {
+ if (ServiceExists(MS_BB_ADDBUTTON)) {
SKINICONDESC sid = {0};
sid.cbSize = sizeof(SKINICONDESC);
sid.flags = SIDF_TCHAR;
@@ -145,27 +144,18 @@ int OnModulesLoaded(WPARAM wParam, LPARAM lParam) sid.ptszDescription = _T("SwitchLayout and Send");
sid.pszName = "SwitchLayout and Send";
sid.hDefaultIcon = LoadIcon(hInst, MAKEINTRESOURCE(IDI_SWITCHSEND));
- hSwitchIcon = (HICON)CallService(MS_SKIN2_ADDICON, 0, (LPARAM) &sid);
+ hSwitchIcon = Skin_AddIcon(&sid);
sid.ptszDescription = _T("Translit and Send");
sid.pszName = "Translit and Send";
sid.hDefaultIcon = LoadIcon(hInst, MAKEINTRESOURCE(IDI_TRANSLITSEND));
- hTranslitIcon = (HICON)CallService(MS_SKIN2_ADDICON, 0, (LPARAM) &sid);
+ hTranslitIcon = Skin_AddIcon(&sid);
sid.ptszDescription = _T("Invert Case and Send");
sid.pszName = "Invert Case and Send";
sid.hDefaultIcon = LoadIcon(hInst, MAKEINTRESOURCE(IDI_INVERTSEND));
- hInvertIcon = (HICON)CallService(MS_SKIN2_ADDICON, 0, (LPARAM) &sid);
- }
- else if (ServiceExists(MS_BB_ADDBUTTON))
- {
- hSwitchIcon = LoadIcon(hInst, MAKEINTRESOURCE(IDI_SWITCHSEND));
- hTranslitIcon = LoadIcon(hInst, MAKEINTRESOURCE(IDI_TRANSLITSEND));
- hInvertIcon = LoadIcon(hInst, MAKEINTRESOURCE(IDI_INVERTSEND));
- }
+ hInvertIcon = Skin_AddIcon(&sid);
- if (ServiceExists(MS_BB_ADDBUTTON))
- {
BBButton bbd = {0};
bbd.cbSize = sizeof(BBButton);
bbd.bbbFlags = BBBF_ISIMBUTTON | BBBF_ISCHATBUTTON | BBBF_ISRSIDEBUTTON;
@@ -190,11 +180,6 @@ int OnModulesLoaded(WPARAM wParam, LPARAM lParam) bbd.dwDefPos = 50;
CallService(MS_BB_ADDBUTTON, 0, (LPARAM)&bbd);
}
-
- DestroyIcon(hSwitchIcon);
- DestroyIcon(hTranslitIcon);
- DestroyIcon(hInvertIcon);
-
return 0;
}
diff --git a/plugins/Updater/icons.cpp b/plugins/Updater/icons.cpp index 1123294676..03a76a1939 100644 --- a/plugins/Updater/icons.cpp +++ b/plugins/Updater/icons.cpp @@ -51,6 +51,6 @@ void InitIcons(void) sid.pszDescription = iconList[i].szDescr;
sid.pszName = iconList[i].szName;
sid.iDefaultIndex = -iconList[i].defIconID;
- hIcolibIcon[i] = (HANDLE)CallService(MS_SKIN2_ADDICON, 0, (LPARAM)&sid);
+ hIcolibIcon[i] = Skin_AddIcon(&sid);
}
}
diff --git a/plugins/UserInfoEx/classPsTreeItem.cpp b/plugins/UserInfoEx/classPsTreeItem.cpp index 7f32b4871a..4f8b641691 100644 --- a/plugins/UserInfoEx/classPsTreeItem.cpp +++ b/plugins/UserInfoEx/classPsTreeItem.cpp @@ -412,12 +412,10 @@ INT CPsTreeItem::Icon(HIMAGELIST hIml, OPTIONSDIALOGPAGE *odp, BOOLEAN bInitIcon if (!sid.hDefaultIcon) sid.hDefaultIcon = ImageList_GetIcon(hIml, 0, ILD_NORMAL);
}
// add file to icolib
- CallServiceSync(MS_SKIN2_ADDICON, NULL, (LPARAM)&sid);
+ Skin_AddIcon(&sid);
if (!bInitIconsOnly)
- {
hIcon = IcoLib_GetIcon(pszIconName);
- }
}
if (!bInitIconsOnly && hIml) {
diff --git a/plugins/Variables/variables.cpp b/plugins/Variables/variables.cpp index 5f81c35eb3..26190fb779 100644 --- a/plugins/Variables/variables.cpp +++ b/plugins/Variables/variables.cpp @@ -592,23 +592,23 @@ int LoadVarModule() { }
hShowHelpService = CreateServiceFunction(MS_VARS_SHOWHELP, showHelpService);
hShowHelpExService = CreateServiceFunction(MS_VARS_SHOWHELPEX, showHelpExService);
- if (ServiceExists(MS_SKIN2_ADDICON)) {
- SKINICONDESC sid;
- char szFile[MAX_PATH];
-
- ZeroMemory(&sid, sizeof(SKINICONDESC));
- sid.cbSize = sizeof(SKINICONDESC);
- sid.ptszSection = TranslateT("Variables");
- sid.ptszDescription = TranslateT("Help");
- sid.pszName = "vars_help";
- GetModuleFileNameA(hInst, szFile, MAX_PATH);
- sid.pszDefaultFile = szFile;
- sid.iDefaultIndex = -IDI_V;
- sid.cx = sid.cy = 16;
- sid.flags = SIDF_TCHAR;
- CallService(MS_SKIN2_ADDICON, (WPARAM)0, (LPARAM)&sid);
- hIconsChangedHook = HookEvent(ME_SKIN2_ICONSCHANGED, iconsChanged);
- }
+
+ TCHAR szFile[MAX_PATH];
+ GetModuleFileName(hInst, szFile, MAX_PATH);
+
+ SKINICONDESC sid = { 0 };
+ sid.cbSize = sizeof(SKINICONDESC);
+ sid.ptszSection = TranslateT("Variables");
+ sid.ptszDescription = TranslateT("Help");
+ sid.pszName = "vars_help";
+ sid.ptszDefaultFile = szFile;
+ sid.iDefaultIndex = -IDI_V;
+ sid.cx = sid.cy = 16;
+ sid.flags = SIDF_ALL_TCHAR;
+ Skin_AddIcon(&sid);
+
+ hIconsChangedHook = HookEvent(ME_SKIN2_ICONSCHANGED, iconsChanged);
+
hGetIconService = CreateServiceFunction(MS_VARS_GETSKINITEM, getSkinItemService);
hOptionsHook = HookEvent(ME_OPT_INITIALISE, OptionsInit);
diff --git a/plugins/WhenWasIt/icons.cpp b/plugins/WhenWasIt/icons.cpp index facb02b574..805593ade4 100644 --- a/plugins/WhenWasIt/icons.cpp +++ b/plugins/WhenWasIt/icons.cpp @@ -75,46 +75,40 @@ int LoadIcons() return 0;
}
-int AddIcon(HICON icon, char *name, char *description)
+HANDLE AddIcon(HICON icon, char *name, char *description)
{
SKINICONDESC sid = {0};
- sid.cbSize = sizeof(SKINICONDESC);
+ sid.cbSize = sizeof(sid);
sid.pszSection = "WhenWasIt";
sid.cx = sid.cy = 16;
sid.pszDescription = description;
sid.pszName = name;
sid.hDefaultIcon = icon;
-
- return CallService(MS_SKIN2_ADDICON, 0, (LPARAM) &sid);
+ return Skin_AddIcon(&sid);
}
int AddIcons()
{
- if (ServiceExists(MS_SKIN2_ADDICON)) //if icolib is installed
- {
-// AddIcon(hiDlgIcon, "Dlg", "Popup and dialog ");
- AddIcon(hiCheckMenu, "MenuCheck", "Check birthdays menu item");
- AddIcon(hiListMenu, "MenuList", "List birthdays menu item");
- AddIcon(hiAddBirthdayContact, "AddBirthday", "Add/change birthday");
- AddIcon(hiRefreshUserDetails, "RefreshUserDetails", "Refresh user details");
-
- AddIcon(hiImportBirthdays, "ImportBirthdays", "Import birthdays");
- AddIcon(hiExportBirthdays, "ExportBirthdays", "Export birthdays");
-
- int i;
- char name[1024];
- char description[1024];
- AddIcon(hiDTB[0], "DTB0", "Birthday today");
- AddIcon(hiDTB[1], "DTB1", "1 day to birthday");
- for (i = 2; i < cDTB; i++)
- {
- sprintf(name, "DTB%d", i);
- sprintf(description, "%d days to birthday", i);
- AddIcon(hiDTB[i], name, description);
- }
- sprintf(description, "More than %d days to birthday", cDTB - 1);
- AddIcon(hiDTBMore, "DTBMore", description);
- }
+ AddIcon(hiCheckMenu, "MenuCheck", "Check birthdays menu item");
+ AddIcon(hiListMenu, "MenuList", "List birthdays menu item");
+ AddIcon(hiAddBirthdayContact, "AddBirthday", "Add/change birthday");
+ AddIcon(hiRefreshUserDetails, "RefreshUserDetails", "Refresh user details");
+
+ AddIcon(hiImportBirthdays, "ImportBirthdays", "Import birthdays");
+ AddIcon(hiExportBirthdays, "ExportBirthdays", "Export birthdays");
+
+ int i;
+ char name[1024];
+ char description[1024];
+ AddIcon(hiDTB[0], "DTB0", "Birthday today");
+ AddIcon(hiDTB[1], "DTB1", "1 day to birthday");
+ for (i = 2; i < cDTB; i++) {
+ sprintf(name, "DTB%d", i);
+ sprintf(description, "%d days to birthday", i);
+ AddIcon(hiDTB[i], name, description);
+ }
+ sprintf(description, "More than %d days to birthday", cDTB - 1);
+ AddIcon(hiDTBMore, "DTBMore", description);
return 0;
}
diff --git a/protocols/AimOscar/theme.cpp b/protocols/AimOscar/theme.cpp index 326401052c..e0bf133f61 100644 --- a/protocols/AimOscar/theme.cpp +++ b/protocols/AimOscar/theme.cpp @@ -94,7 +94,7 @@ void InitIcons(void) sid.pszDescription = (char*)iconList[i].szDescr;
sid.iDefaultIndex = -iconList[i].defIconID;
- hIconLibItem[i] = (HANDLE)CallService(MS_SKIN2_ADDICON, 0, (LPARAM)&sid);
+ hIconLibItem[i] = Skin_AddIcon(&sid);
}
}
diff --git a/protocols/FacebookRM/theme.cpp b/protocols/FacebookRM/theme.cpp index c3d2fca65b..1fdbeace0b 100644 --- a/protocols/FacebookRM/theme.cpp +++ b/protocols/FacebookRM/theme.cpp @@ -80,7 +80,7 @@ void InitIcons(void) sid.pszDescription = (char*)icons[i].descr;
sid.iDefaultIndex = -icons[i].defIconID;
- hIconLibItem[i] = (HANDLE)CallService(MS_SKIN2_ADDICON,0,(LPARAM)&sid);
+ hIconLibItem[i] = Skin_AddIcon(&sid);
} else { // External icons
hIconLibItem[i] = (HANDLE)CallService(MS_SKIN2_GETICONHANDLE,0,
(LPARAM)icons[i].section);
diff --git a/protocols/Gadu-Gadu/icolib.c b/protocols/Gadu-Gadu/icolib.c index 55ceb60cf0..58d5c2fe2a 100644 --- a/protocols/Gadu-Gadu/icolib.c +++ b/protocols/Gadu-Gadu/icolib.c @@ -69,7 +69,7 @@ void gg_icolib_init() sid.pszName = szSettingName;
sid.pszDescription = (char*)iconList[i].szDescr;
sid.iDefaultIndex = -iconList[i].defIconID;
- hIconLibItem[i] = (HANDLE) CallService(MS_SKIN2_ADDICON, 0, (LPARAM)&sid);
+ hIconLibItem[i] = Skin_AddIcon(&sid);
}
}
diff --git a/protocols/IRCG/options.cpp b/protocols/IRCG/options.cpp index 2152e340c9..e3f8bd1746 100644 --- a/protocols/IRCG/options.cpp +++ b/protocols/IRCG/options.cpp @@ -238,8 +238,9 @@ void AddIcons(void) sid.ptszDescription = iconList[i].szDescr;
sid.iDefaultIndex = -iconList[i].defIconID;
sid.cx = sid.cy = iconList[i].iSize;
- hIconLibItems[i] = ( HANDLE )CallService( MS_SKIN2_ADDICON, 0, ( LPARAM )&sid );
-} }
+ hIconLibItems[i] = Skin_AddIcon(&sid );
+ }
+}
void UninitIcons(void)
{
diff --git a/protocols/IcqOscarJ/iconlib.cpp b/protocols/IcqOscarJ/iconlib.cpp index bc378bc094..3d95822a1f 100644 --- a/protocols/IcqOscarJ/iconlib.cpp +++ b/protocols/IcqOscarJ/iconlib.cpp @@ -41,11 +41,10 @@ IcqIconHandle IconLibDefine(const char *desc, const char *section, const char *module, const char *ident, const TCHAR *def_file, int def_idx)
{
SKINICONDESC sid = {0};
-
- sid.cbSize = SKINICONDESC_SIZE;
+ sid.cbSize = sizeof(sid);
sid.pwszSection = make_unicode_string(section);
sid.pwszDescription = make_unicode_string(desc);
- sid.flags = SIDF_UNICODE | SIDF_PATH_TCHAR;
+ sid.flags = SIDF_ALL_TCHAR;
char szName[MAX_PATH + 128];
null_snprintf(szName, sizeof(szName), "%s_%s", module ? module : ICQ_PROTOCOL_NAME, ident);
@@ -55,7 +54,7 @@ IcqIconHandle IconLibDefine(const char *desc, const char *section, const char *m IcqIconHandle hIcon = (IcqIconHandle)SAFE_MALLOC(sizeof(IcqIconHandle_s));
hIcon->szName = null_strdup(sid.pszName);
- hIcon->hIcoLib = (HANDLE)CallService(MS_SKIN2_ADDICON, 0, (LPARAM)&sid);
+ hIcon->hIcoLib = Skin_AddIcon(&sid);
SAFE_FREE(&sid.pwszSection);
SAFE_FREE(&sid.pwszDescription);
diff --git a/protocols/JabberG/jabber_icolib.cpp b/protocols/JabberG/jabber_icolib.cpp index c85198a59c..12c9387ced 100644 --- a/protocols/JabberG/jabber_icolib.cpp +++ b/protocols/JabberG/jabber_icolib.cpp @@ -143,7 +143,7 @@ void CIconPool::RegisterIcon(const char *name, const char *filename, int iconid, sid.ptszDescription = szDescription;
sid.flags = SIDF_TCHAR;
sid.iDefaultIndex = iconid;
- item->m_hIcolibItem = (HANDLE)CallService(MS_SKIN2_ADDICON, 0, (LPARAM)&sid);
+ item->m_hIcolibItem = Skin_AddIcon(&sid);
m_items.insert(item);
}
@@ -294,7 +294,7 @@ void CJabberProto::IconsInit( void ) mir_snprintf( szSettingName, SIZEOF(szSettingName), "%s_%s", m_szModuleName, iconList[i].szName );
sid.iDefaultIndex = -iconList[i].defIconID;
- m_phIconLibItems[i] = ( HANDLE )CallService(MS_SKIN2_ADDICON, 0, (LPARAM)&sid);
+ m_phIconLibItems[i] = Skin_AddIcon(&sid);
} }
HANDLE CJabberProto::GetIconHandle( int iconId )
@@ -421,7 +421,7 @@ static HICON LoadTransportIcon(char *filename,int i,char *IconName,TCHAR *SectNa sid.pszDefaultFile=szMyPath;
sid.iDefaultIndex=i;
sid.flags = SIDF_TCHAR;
- CallService(MS_SKIN2_ADDICON, 0, (LPARAM)&sid);
+ Skin_AddIcon(&sid);
}
return ((HICON)CallService(MS_SKIN2_GETICON, 0, (LPARAM)IconName));
}
@@ -690,7 +690,7 @@ static void sttProcessIcons( int iAmount ) sid.pszName = szSettingName;
sid.pszDescription = sharedIconList[i].szDescr;
sid.iDefaultIndex = -sharedIconList[i].defIconID;
- sharedIconList[i].hIcon = ( HANDLE )CallService(MS_SKIN2_ADDICON, 0, (LPARAM)&sid);
+ sharedIconList[i].hIcon = Skin_AddIcon(&sid);
} }
void g_IconsInit()
diff --git a/protocols/MRA/MraIcons.cpp b/protocols/MRA/MraIcons.cpp index f910f6adc5..0da6ee011e 100644 --- a/protocols/MRA/MraIcons.cpp +++ b/protocols/MRA/MraIcons.cpp @@ -8,28 +8,26 @@ void AddIcoLibItems(LPWSTR lpwszRootSectionName,LPWSTR lpwszSubSectionName,const {
char szBuff[MAX_PATH];
WCHAR wszSection[MAX_PATH],wszPath[MAX_FILEPATH];
- SKINICONDESC sid={0};
-
- sid.cbSize=SKINICONDESC_SIZE;
- sid.pwszSection=wszSection;
- sid.pwszDefaultFile=wszPath;
- sid.cx=sid.cy=16;
- sid.flags=SIDF_ALL_UNICODE;
+ 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++)
- {
+ 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);
- hResult[i]=(HANDLE)CallService(MS_SKIN2_ADDICON,0,(LPARAM)&sid);
+ hResult[i] = Skin_AddIcon(&sid);
}
}
@@ -100,20 +98,19 @@ void InitXStatusIcons() int iCurIndex;
char szBuff[MAX_PATH];
WCHAR wszSection[MAX_PATH],wszPath[MAX_FILEPATH];
- SKINICONDESC sid={0};
- sid.cbSize=SKINICONDESC_SIZE;
+ SKINICONDESC sid={0};
+ sid.cbSize = sizeof(sid);
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));
- }else{
+ else
bzero(wszPath,sizeof(wszPath));
- }
+
mir_sntprintf(wszSection,SIZEOF(wszSection),L"Status Icons/%s/Custom Status",PROTOCOL_NAMEW);
masMraSettings.hXStatusAdvancedStatusIcons[0]=NULL;
@@ -130,7 +127,7 @@ void InitXStatusIcons() }else{
sid.hDefaultIcon=NULL;
}
- masMraSettings.hXStatusAdvancedStatusIcons[i]=(HANDLE)CallService(MS_SKIN2_ADDICON,0,(LPARAM)&sid);
+ masMraSettings.hXStatusAdvancedStatusIcons[i] = Skin_AddIcon(&sid);
}
}
diff --git a/protocols/MSN/msn_opts.cpp b/protocols/MSN/msn_opts.cpp index c55755f1b9..b611b2559a 100644 --- a/protocols/MSN/msn_opts.cpp +++ b/protocols/MSN/msn_opts.cpp @@ -73,7 +73,7 @@ void MsnInitIcons(void) sid.pszName = szSettingName;
sid.pszDescription = (char*)iconList[i].szDescr;
sid.iDefaultIndex = -iconList[i].defIconID;
- hIconLibItem[i] = (HANDLE)CallService(MS_SKIN2_ADDICON, 0, (LPARAM)&sid);
+ hIconLibItem[i] = Skin_AddIcon(&sid);
}
}
diff --git a/protocols/NewsAggregator/Src/Icons.cpp b/protocols/NewsAggregator/Src/Icons.cpp index 096a38086b..16b782fd3c 100644 --- a/protocols/NewsAggregator/Src/Icons.cpp +++ b/protocols/NewsAggregator/Src/Icons.cpp @@ -58,7 +58,7 @@ VOID InitIcons() sid.ptszDescription = iconList[i].szDescr;
sid.iDefaultIndex = -iconList[i].defIconID;
- iconList[i].hIconLibItem = ( HANDLE )CallService(MS_SKIN2_ADDICON, 0, (LPARAM)&sid);
+ iconList[i].hIconLibItem = Skin_AddIcon(&sid);
}
}
diff --git a/protocols/Omegle/theme.cpp b/protocols/Omegle/theme.cpp index 73ef80a46c..d7f7fc7e9b 100644 --- a/protocols/Omegle/theme.cpp +++ b/protocols/Omegle/theme.cpp @@ -73,7 +73,7 @@ void InitIcons(void) sid.pszDescription = (char*)icons[i].descr;
sid.iDefaultIndex = -icons[i].defIconID;
- hIconLibItem[i] = (HANDLE)CallService(MS_SKIN2_ADDICON,0,(LPARAM)&sid);
+ hIconLibItem[i] = Skin_AddIcon(&sid);
} else { // External icons
hIconLibItem[i] = (HANDLE)CallService(MS_SKIN2_GETICONHANDLE,0,
(LPARAM)icons[i].section);
diff --git a/protocols/Quotes/IconLib.cpp b/protocols/Quotes/IconLib.cpp index 9702bfe3d8..6957a35d0b 100644 --- a/protocols/Quotes/IconLib.cpp +++ b/protocols/Quotes/IconLib.cpp @@ -70,7 +70,7 @@ void Quotes_IconsInit() sid.pszName = const_cast<char*>(sName.c_str());
sid.ptszDescription = iconList[i].szDescr;
sid.iDefaultIndex = -iconList[i].defIconID;
- iconList[i].hIconLibItem = reinterpret_cast<HANDLE>(CallService(MS_SKIN2_ADDICON,0,reinterpret_cast<LPARAM>(&sid)));
+ iconList[i].hIconLibItem = Skin_AddIcon(&sid);
}
}
diff --git a/protocols/Twitter/theme.cpp b/protocols/Twitter/theme.cpp index f17e7d700a..11dea3cb44 100644 --- a/protocols/Twitter/theme.cpp +++ b/protocols/Twitter/theme.cpp @@ -74,7 +74,7 @@ void InitIcons(void) sid.pszDescription = (char*)icons[i].descr;
sid.iDefaultIndex = -icons[i].defIconID;
- hIconLibItem[i] = (HANDLE)CallService(MS_SKIN2_ADDICON,0,(LPARAM)&sid);
+ hIconLibItem[i] = Skin_AddIcon(&sid);
}
else // External icons
{
diff --git a/protocols/Weather/weather_icons.cpp b/protocols/Weather/weather_icons.cpp index ada253bb07..6669a64515 100644 --- a/protocols/Weather/weather_icons.cpp +++ b/protocols/Weather/weather_icons.cpp @@ -61,7 +61,7 @@ void InitIcons(void) sid.pszDescription = iconList[i].szDescr;
sid.iDefaultIndex = -iconList[i].defIconID;
- iconList[i].hIconLibItem = ( HANDLE )CallService(MS_SKIN2_ADDICON, 0, (LPARAM)&sid);
+ iconList[i].hIconLibItem = ( HANDLE )Skin_AddIcon(&sid);
} }
HICON LoadIconEx(const char* name, BOOL big)
diff --git a/protocols/YAMN/main.cpp b/protocols/YAMN/main.cpp index e876465609..7ea9386c4c 100644 --- a/protocols/YAMN/main.cpp +++ b/protocols/YAMN/main.cpp @@ -320,7 +320,7 @@ static void LoadIcons() sid.pszName = iconList[i].szName;
sid.pszDescription = iconList[i].szDescr;
sid.iDefaultIndex = -iconList[i].defIconID;
- iconList[i].hIcon = ( HANDLE )CallService(MS_SKIN2_ADDICON, 0, (LPARAM)&sid);
+ iconList[i].hIcon = Skin_AddIcon(&sid);
} }
HANDLE WINAPI g_GetIconHandle( int idx )
diff --git a/protocols/Yahoo/icolib.cpp b/protocols/Yahoo/icolib.cpp index 7f87f2c890..868624380e 100644 --- a/protocols/Yahoo/icolib.cpp +++ b/protocols/Yahoo/icolib.cpp @@ -56,7 +56,7 @@ void CYahooProto::IconsInit( void ) sid.pszName = szSettingName;
sid.pszDescription = (char* )iconList[i].szDescr;
sid.iDefaultIndex = -iconList[i].defIconID;
- hIconLibItem[i] = (HANDLE)CallService(MS_SKIN2_ADDICON, 0, (LPARAM)&sid);
+ hIconLibItem[i] = Skin_AddIcon(&sid);
}
}
diff --git a/src/core/miranda.h b/src/core/miranda.h index edd32bfb25..40329e5013 100644 --- a/src/core/miranda.h +++ b/src/core/miranda.h @@ -225,7 +225,7 @@ int pathToAbsoluteW(const TCHAR *pSrc, TCHAR *pOut, TCHAR* base); /**** skin2icons.cpp *******************************************************************/
-HANDLE IcoLib_AddNewIcon(SKINICONDESC* sid);
+HANDLE IcoLib_AddNewIcon(int hLangpack, SKINICONDESC* sid);
HICON IcoLib_GetIcon(const char* pszIconName, bool big);
HICON IcoLib_GetIconByHandle(HANDLE hItem, bool big);
HANDLE IcoLib_IsManaged(HICON hIcon);
diff --git a/src/miranda32_10.vcxproj b/src/miranda32_10.vcxproj index f0bbb6345a..ce87c1a7d8 100644 --- a/src/miranda32_10.vcxproj +++ b/src/miranda32_10.vcxproj @@ -308,6 +308,9 @@ <ClCompile Include="modules\history\history.cpp">
<PrecompiledHeaderFile>..\..\core\commonheaders.h</PrecompiledHeaderFile>
</ClCompile>
+ <ClCompile Include="modules\icolib\skin2opts.cpp">
+ <PrecompiledHeaderFile>..\..\core\commonheaders.h</PrecompiledHeaderFile>
+ </ClCompile>
<ClCompile Include="modules\idle\idle.cpp">
<PrecompiledHeaderFile>..\..\core\commonheaders.h</PrecompiledHeaderFile>
</ClCompile>
diff --git a/src/miranda32_10.vcxproj.filters b/src/miranda32_10.vcxproj.filters index 7344a5c894..82a799129c 100644 --- a/src/miranda32_10.vcxproj.filters +++ b/src/miranda32_10.vcxproj.filters @@ -623,6 +623,9 @@ <ClCompile Include="modules\skin\hotkey_opts.cpp">
<Filter>Modules\skin</Filter>
</ClCompile>
+ <ClCompile Include="modules\icolib\skin2opts.cpp">
+ <Filter>Modules\icolib</Filter>
+ </ClCompile>
</ItemGroup>
<ItemGroup>
<None Include="res\_blank.ico">
diff --git a/src/modules/clist/genmenu.cpp b/src/modules/clist/genmenu.cpp index 7fcb9b32c7..f61921b4e1 100644 --- a/src/modules/clist/genmenu.cpp +++ b/src/modules/clist/genmenu.cpp @@ -1117,7 +1117,7 @@ static int MO_RegisterIcon(PMO_IntMenuItem pmi, void*) sid.pszDefaultFile = NULL;
sid.pszDescription = buf;
sid.hDefaultIcon = hIcon;
- pmi->hIcolibItem = (HANDLE)CallService(MS_SKIN2_ADDICON, 0, (LPARAM)&sid);
+ pmi->hIcolibItem = IcoLib_AddNewIcon(0, &sid);
Safe_DestroyIcon(hIcon);
if (hIcon = (HICON)CallService(MS_SKIN2_GETICON, 0, (LPARAM)iconame)) {
diff --git a/src/modules/icolib/IcoLib.h b/src/modules/icolib/IcoLib.h index 29bd85905b..30121729a8 100644 --- a/src/modules/icolib/IcoLib.h +++ b/src/modules/icolib/IcoLib.h @@ -20,23 +20,28 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
-typedef struct
+
+#define SECTIONPARAM_MAKE(index, level, flags) MAKELONG((index)&0xFFFF, MAKEWORD(level, flags))
+#define SECTIONPARAM_INDEX(lparam) LOWORD(lparam)
+#define SECTIONPARAM_LEVEL(lparam) LOBYTE(HIWORD(lparam))
+#define SECTIONPARAM_FLAGS(lparam) HIBYTE(HIWORD(lparam))
+#define SECTIONPARAM_HAVEPAGE 0x0001
+
+struct SectionItem
{
TCHAR* name;
int flags;
int maxOrder;
int ref_count;
-}
- SectionItem;
+};
-typedef struct
+struct IconSourceFile
{
TCHAR* file;
int ref_count;
-}
- IconSourceFile;
+};
-typedef struct
+struct IconSourceItem
{
IconSourceFile* file;
int indx;
@@ -49,10 +54,9 @@ typedef struct BYTE* icon_data;
int icon_size;
-}
- IconSourceItem;
+};
-typedef struct
+struct IconItem
{
char* name;
SectionItem* section;
@@ -61,6 +65,7 @@ typedef struct TCHAR* default_file;
int default_indx;
int cx, cy;
+ int hLangpack;
IconSourceItem* source_small;
IconSourceItem* source_big;
@@ -69,15 +74,35 @@ typedef struct TCHAR* temp_file;
HICON temp_icon;
BOOL temp_reset;
-}
- IconItem;
-typedef struct
-{
- char *paramName;
- DWORD value;
-}
- TreeItem;
+ __inline TCHAR* getDescr() const { return LangPackTranslateStringT(hLangpack, description); }
+};
// extracticon.c
+
UINT _ExtractIconEx(LPCTSTR lpszFile, int iconIndex, int cxIcon, int cyIcon, HICON *phicon, UINT flags);
+
+void __fastcall SAFE_FREE(void** p);
+void __fastcall SafeDestroyIcon(HICON* icon);
+
+int IconSourceItem_Release(IconSourceItem** pitem);
+int IconSourceItem_ReleaseIcon(IconSourceItem* item);
+HICON IconSourceItem_GetIcon(IconSourceItem* item);
+IconSourceItem* GetIconSourceItem(const TCHAR* file, int indx, int cxIcon, int cyIcon);
+
+IconItem* IcoLib_FindHIcon(HICON hIcon, bool &big);
+IconItem* IcoLib_FindIcon(const char* pszIconName);
+
+HICON IconItem_GetIcon(IconItem* item, bool big);
+
+int SkinOptionsInit(WPARAM, LPARAM);
+
+extern CRITICAL_SECTION csIconList;
+extern LIST<IconItem> iconList;
+extern LIST<SectionItem> sectionList;
+
+extern BOOL bNeedRebuild;
+extern int iconEventActive;
+extern HICON hIconBlank;
+extern HANDLE hIcons2ChangedEvent, hIconsChangedEvent;
+
diff --git a/src/modules/icolib/skin2icons.cpp b/src/modules/icolib/skin2icons.cpp index 810c15d741..2d6d9ab9cd 100644 --- a/src/modules/icolib/skin2icons.cpp +++ b/src/modules/icolib/skin2icons.cpp @@ -26,33 +26,24 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "IcoLib.h"
static BOOL bModuleInitialized = FALSE;
-static HANDLE hIcons2ChangedEvent, hIconsChangedEvent;
-static HICON hIconBlank = NULL;
+HANDLE hIcons2ChangedEvent, hIconsChangedEvent;
-HANDLE hIcoLib_AddNewIcon, hIcoLib_RemoveIcon, hIcoLib_GetIcon, hIcoLib_GetIcon2,
- hIcoLib_GetIconHandle, hIcoLib_IsManaged, hIcoLib_AddRef, hIcoLib_ReleaseIcon;
+HICON hIconBlank = NULL;
-static int iconEventActive = 0;
+static HANDLE hIcoLib_AddNewIcon, hIcoLib_RemoveIcon, hIcoLib_GetIcon, hIcoLib_GetIcon2,
+ hIcoLib_GetIconHandle, hIcoLib_IsManaged, hIcoLib_AddRef, hIcoLib_ReleaseIcon;
-static BOOL bNeedRebuild = FALSE;
+int iconEventActive = 0;
-struct IcoLibOptsData {
- HWND hwndIndex;
-};
+BOOL bNeedRebuild = FALSE;
CRITICAL_SECTION csIconList;
-#define SECTIONPARAM_MAKE(index, level, flags) MAKELONG((index)&0xFFFF, MAKEWORD(level, flags))
-#define SECTIONPARAM_INDEX(lparam) LOWORD(lparam)
-#define SECTIONPARAM_LEVEL(lparam) LOBYTE(HIWORD(lparam))
-#define SECTIONPARAM_FLAGS(lparam) HIBYTE(HIWORD(lparam))
-#define SECTIONPARAM_HAVEPAGE 0x0001
-
static int sttCompareSections(const SectionItem* p1, const SectionItem* p2)
{ return _tcscmp(p1->name, p2->name);
}
-static LIST<SectionItem> sectionList(20, sttCompareSections);
+LIST<SectionItem> sectionList(20, sttCompareSections);
static int sttCompareIconSourceFiles(const IconSourceFile* p1, const IconSourceFile* p2)
{ return _tcsicmp(p1->file, p2->file);
@@ -91,23 +82,19 @@ static int sttCompareIcons(const IconItem* p1, const IconItem* p2) { return strcmp(p1->name, p2->name);
}
-static LIST<IconItem> iconList(20, sttCompareIcons);
+LIST<IconItem> iconList(20, sttCompareIcons);
/////////////////////////////////////////////////////////////////////////////////////////
// Utility functions
-static void __fastcall MySetCursor(TCHAR* nCursor)
-{ SetCursor(LoadCursor(NULL, nCursor));
-}
-
-static void __fastcall SAFE_FREE(void** p)
+void __fastcall SAFE_FREE(void** p)
{
if (*p) {
mir_free(*p);
*p = NULL;
} }
-static void __fastcall SafeDestroyIcon(HICON* icon)
+void __fastcall SafeDestroyIcon(HICON* icon)
{
if (*icon) {
DestroyIcon(*icon);
@@ -289,7 +276,7 @@ static int GetIconData(HICON icon, BYTE** data, int* size) #define VER30 0x00030000
-static HICON IconSourceItem_GetIcon(IconSourceItem* item)
+HICON IconSourceItem_GetIcon(IconSourceItem* item)
{
if (item->icon) {
item->icon_ref_count++;
@@ -312,7 +299,7 @@ static HICON IconSourceItem_GetIcon(IconSourceItem* item) return item->icon;
}
-static int IconSourceItem_ReleaseIcon(IconSourceItem* item)
+int IconSourceItem_ReleaseIcon(IconSourceItem* item)
{
if (item && item->icon_ref_count)
{
@@ -394,7 +381,7 @@ IconSourceItem* CreateStaticIconSourceItem(int cxIcon, int cyIcon) return newItem;
}
-static int IconSourceItem_Release(IconSourceItem** pitem)
+int IconSourceItem_Release(IconSourceItem** pitem)
{
if (pitem && *pitem && (*pitem)->ref_count) {
IconSourceItem* item = *pitem;
@@ -418,32 +405,6 @@ static int IconSourceItem_Release(IconSourceItem** pitem) /////////////////////////////////////////////////////////////////////////////////////////
// Service functions
-static HICON ExtractIconFromPath(const TCHAR *path, int cxIcon, int cyIcon)
-{
- TCHAR *comma;
- TCHAR file[ MAX_PATH ], fileFull[ MAX_PATH ];
- int n;
- HICON hIcon;
-
- if ( !path)
- return (HICON)NULL;
-
- lstrcpyn(file, path, SIZEOF(file));
- comma = _tcsrchr(file, ',');
- if ( !comma)
- n = 0;
- else {
- n = _ttoi(comma+1);
- *comma = 0;
- }
- pathToAbsoluteT(file, fileFull, NULL);
- hIcon = NULL;
-
- //SHOULD BE REPLACED WITH GOOD ENOUGH FUNCTION
- _ExtractIconEx(fileFull, n, cxIcon, cyIcon, &hIcon, LR_COLOR);
- return hIcon;
-}
-
static SectionItem* IcoLib_AddSection(TCHAR *sectionName, BOOL create_new)
{
if ( !sectionName)
@@ -481,7 +442,7 @@ static void IcoLib_RemoveSection(SectionItem* section) }
}
-static IconItem* IcoLib_FindIcon(const char* pszIconName)
+IconItem* IcoLib_FindIcon(const char* pszIconName)
{
int indx;
IconItem key = { (char*)pszIconName };
@@ -491,7 +452,7 @@ static IconItem* IcoLib_FindIcon(const char* pszIconName) return NULL;
}
-static IconItem* IcoLib_FindHIcon(HICON hIcon, bool &big)
+IconItem* IcoLib_FindHIcon(HICON hIcon, bool &big)
{
IconItem* item = NULL;
int indx;
@@ -534,33 +495,24 @@ static void IcoLib_FreeIcon(IconItem* icon) /////////////////////////////////////////////////////////////////////////////////////////
// IcoLib_AddNewIcon
-HANDLE IcoLib_AddNewIcon(SKINICONDESC* sid)
+HANDLE IcoLib_AddNewIcon(int hLangpack, SKINICONDESC* sid)
{
- int utf = 0, utf_path = 0;
- IconItem* item;
-
- if ( !sid->cbSize)
+ if (sid->cbSize != sizeof(SKINICONDESC))
return NULL;
- if (sid->cbSize < SKINICONDESC_SIZE_V1)
- return NULL;
-
- if (sid->cbSize >= SKINICONDESC_SIZE) {
- utf = sid->flags & SIDF_UNICODE ? 1 : 0;
- utf_path = sid->flags & SIDF_PATH_UNICODE ? 1 : 0;
- }
+ bool utf = (sid->flags & SIDF_UNICODE) != 0;
+ bool utf_path = (sid->flags & SIDF_PATH_UNICODE) != 0;
EnterCriticalSection(&csIconList);
- item = IcoLib_FindIcon(sid->pszName);
- if ( !item) {
- item = (IconItem*)mir_alloc(sizeof(IconItem));
+ IconItem* item = IcoLib_FindIcon(sid->pszName);
+ if (!item) {
+ item = (IconItem*)mir_calloc(sizeof(IconItem));
item->name = sid->pszName;
iconList.insert(item);
}
else IcoLib_FreeIcon(item);
- ZeroMemory(item, sizeof(*item));
item->name = mir_strdup(sid->pszName);
if (utf) {
item->description = mir_u2t(sid->pwszDescription);
@@ -572,36 +524,28 @@ HANDLE IcoLib_AddNewIcon(SKINICONDESC* sid) item->section = IcoLib_AddSection(pwszSection, TRUE);
SAFE_FREE((void**)&pwszSection);
}
+
if (item->section) {
item->section->ref_count++;
item->orderID = ++item->section->maxOrder;
}
- else
- item->orderID = 0;
+ else item->orderID = 0;
if (sid->pszDefaultFile) {
- if (utf_path) {
-
- WCHAR fileFull[ MAX_PATH ];
-
- pathToAbsoluteW(sid->pwszDefaultFile, fileFull, NULL);
- item->default_file = mir_wstrdup(fileFull);
- }
- else {
- WCHAR *file = mir_a2u(sid->pszDefaultFile);
- WCHAR fileFull[ MAX_PATH ];
- pathToAbsoluteW(file, fileFull, NULL);
- SAFE_FREE((void**)&file);
- item->default_file = mir_wstrdup(fileFull);
- } }
+ WCHAR fileFull[ MAX_PATH ];
+ if (utf_path)
+ pathToAbsoluteT(sid->pwszDefaultFile, fileFull, NULL);
+ else
+ pathToAbsoluteT( StrConvT(sid->pszDefaultFile), fileFull, NULL);
+ item->default_file = mir_wstrdup(fileFull);
+ }
item->default_indx = sid->iDefaultIndex;
- if (sid->cbSize >= SKINICONDESC_SIZE_V3) {
- item->cx = sid->cx;
- item->cy = sid->cy;
- }
+ item->cx = sid->cx;
+ item->cy = sid->cy;
+ item->hLangpack = hLangpack;
- if (sid->cbSize >= SKINICONDESC_SIZE_V2 && sid->hDefaultIcon) {
+ if (sid->hDefaultIcon) {
bool big;
IconItem* def_item = IcoLib_FindHIcon(sid->hDefaultIcon, big);
if (def_item) {
@@ -618,7 +562,7 @@ HANDLE IcoLib_AddNewIcon(SKINICONDESC* sid) }
}
- if (sid->cbSize >= SKINICONDESC_SIZE && item->section)
+ if (item->section)
item->section->flags = sid->flags & SIDF_SORTED;
LeaveCriticalSection(&csIconList);
@@ -724,46 +668,6 @@ HICON IconItem_GetIcon(IconItem* item, bool big) }
/////////////////////////////////////////////////////////////////////////////////////////
-// IconItem_GetIcon_Preview
-
-HICON IconItem_GetIcon_Preview(IconItem* item)
-{
- HICON hIcon = NULL;
-
- if ( !item->temp_reset) {
- HICON hRefIcon = IconItem_GetIcon(item, false);
- hIcon = CopyIcon(hRefIcon);
- if (item->source_small && item->source_small->icon == hRefIcon)
- IconSourceItem_ReleaseIcon(item->source_small);
- }
- else {
- if (item->default_icon) {
- HICON hRefIcon = IconSourceItem_GetIcon(item->default_icon);
- if (hRefIcon) {
- hIcon = CopyIcon(hRefIcon);
- if (item->default_icon->icon == hRefIcon)
- IconSourceItem_ReleaseIcon(item->default_icon);
- } }
-
- if ( !hIcon && item->default_file) {
- IconSourceItem_Release(&item->default_icon);
- item->default_icon = GetIconSourceItem(item->default_file, item->default_indx, item->cx, item->cy);
- if (item->default_icon) {
- HICON hRefIcon = IconSourceItem_GetIcon(item->default_icon);
- if (hRefIcon) {
- hIcon = CopyIcon(hRefIcon);
- if (item->default_icon->icon == hRefIcon)
- IconSourceItem_ReleaseIcon(item->default_icon);
- } } }
-
- if ( !hIcon)
- return CopyIcon(hIconBlank);
- }
- return hIcon;
-}
-
-
-/////////////////////////////////////////////////////////////////////////////////////////
// IcoLib_GetIcon
// lParam: pszIconName
// wParam: PLOADIMAGEPARAM or NULL.
@@ -885,968 +789,6 @@ static INT_PTR IcoLib_AddRef(WPARAM wParam, LPARAM) return res;
}
-/////////////////////////////////////////////////////////////////////////////////////////
-// IcoLib_ReleaseIcon
-// lParam: pszIconName or NULL
-// wParam: HICON or NULL
-
-int IcoLib_ReleaseIcon(HICON hIcon, char* szIconName, bool big)
-{
- IconItem *item = NULL;
-
- EnterCriticalSection(&csIconList);
-
- if (szIconName)
- item = IcoLib_FindIcon(szIconName);
-
- if ( !item && hIcon) // find by HICON
- item = IcoLib_FindHIcon(hIcon, big);
-
- int res = 1;
- if (item) {
- IconSourceItem* source = big && !item->cx ? item->source_big : item->source_small;
- if (source && source->icon_ref_count) {
- if (iconEventActive)
- source->icon_ref_count--;
- else
- IconSourceItem_ReleaseIcon(source);
- res = 0;
- }
- }
-
- LeaveCriticalSection(&csIconList);
- return res;
-}
-
-/////////////////////////////////////////////////////////////////////////////////////////
-// IcoLib GUI service routines
-
-static void LoadSectionIcons(TCHAR *filename, SectionItem* sectionActive)
-{
- TCHAR path[ MAX_PATH ];
- int suffIndx;
- HICON hIcon;
- int indx;
-
- mir_sntprintf(path, SIZEOF(path), _T("%s,"), filename);
- suffIndx = lstrlen(path);
-
- EnterCriticalSection(&csIconList);
-
- for (indx = 0; indx < iconList.getCount(); indx++) {
- IconItem *item = iconList[ indx ];
-
- if (item->default_file && item->section == sectionActive) {
- _itot(item->default_indx, path + suffIndx, 10);
- hIcon = ExtractIconFromPath(path, item->cx, item->cy);
- if (hIcon) {
- SAFE_FREE((void**)&item->temp_file);
- SafeDestroyIcon(&item->temp_icon);
-
- item->temp_file = mir_tstrdup(path);
- item->temp_icon = hIcon;
- item->temp_reset = FALSE;
- } } }
-
- LeaveCriticalSection(&csIconList);
-}
-
-void LoadSubIcons(HWND htv, TCHAR *filename, HTREEITEM hItem)
-{
- TVITEM tvi;
- TreeItem *treeItem;
- SectionItem* sectionActive;
-
- tvi.mask = TVIF_HANDLE | TVIF_PARAM;
- tvi.hItem = hItem;
-
- TreeView_GetItem(htv, &tvi);
- treeItem = (TreeItem *)tvi.lParam;
- sectionActive = sectionList[ SECTIONPARAM_INDEX(treeItem->value) ];
-
- tvi.hItem = TreeView_GetChild(htv, tvi.hItem);
- while (tvi.hItem) {
- LoadSubIcons(htv, filename, tvi.hItem);
- tvi.hItem = TreeView_GetNextSibling(htv, tvi.hItem);
- }
-
- if (SECTIONPARAM_FLAGS(treeItem->value) & SECTIONPARAM_HAVEPAGE)
- LoadSectionIcons(filename, sectionActive);
-}
-
-static void UndoChanges(int iconIndx, int cmd)
-{
- IconItem *item = iconList[ iconIndx ];
-
- if ( !item->temp_file && !item->temp_icon && item->temp_reset && cmd == ID_CANCELCHANGE)
- item->temp_reset = FALSE;
- else
- {
- SAFE_FREE((void**)&item->temp_file);
- SafeDestroyIcon(&item->temp_icon);
- }
-
- if (cmd == ID_RESET)
- item->temp_reset = TRUE;
-}
-
-void UndoSubItemChanges(HWND htv, HTREEITEM hItem, int cmd)
-{
- TVITEM tvi = {0};
- TreeItem *treeItem;
- int indx;
-
- tvi.mask = TVIF_HANDLE | TVIF_PARAM;
- tvi.hItem = hItem;
- TreeView_GetItem(htv, &tvi);
- treeItem = (TreeItem *)tvi.lParam;
-
- if (SECTIONPARAM_FLAGS(treeItem->value) & SECTIONPARAM_HAVEPAGE) {
- EnterCriticalSection(&csIconList);
-
- for (indx = 0; indx < iconList.getCount(); indx++)
- if (iconList[ indx ]->section == sectionList[ SECTIONPARAM_INDEX(treeItem->value) ])
- UndoChanges(indx, cmd);
-
- LeaveCriticalSection(&csIconList);
- }
-
- tvi.hItem = TreeView_GetChild(htv, tvi.hItem);
- while (tvi.hItem) {
- UndoSubItemChanges(htv, tvi.hItem, cmd);
- tvi.hItem = TreeView_GetNextSibling(htv, tvi.hItem);
-} }
-
-static void OpenIconsPage()
-{
- CallService(MS_UTILS_OPENURL, 1, (LPARAM)"http://addons.miranda-im.org/index.php?action=display&id=35");
-}
-
-static int OpenPopupMenu(HWND hwndDlg)
-{
- HMENU hMenu, hPopup;
- POINT pt;
- int cmd;
-
- GetCursorPos(&pt);
- hMenu = LoadMenu(hMirandaInst, MAKEINTRESOURCE(IDR_ICOLIB_CONTEXT));
- hPopup = GetSubMenu(hMenu, 0);
- TranslateMenu(hPopup);
- cmd = TrackPopupMenu(hPopup, TPM_RIGHTBUTTON|TPM_RETURNCMD, pt.x, pt.y, 0, hwndDlg, NULL);
- DestroyMenu(hMenu);
- return cmd;
-}
-
-static TCHAR* OpenFileDlg(HWND hParent, const TCHAR* szFile, BOOL bAll)
-{
- OPENFILENAME ofn = {0};
- TCHAR filter[512], *pfilter, file[MAX_PATH*2];
-
- ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400;
- ofn.hwndOwner = hParent;
-
- lstrcpy(filter, TranslateT("Icon Sets"));
- if (bAll)
- lstrcat(filter, _T(" (*.dll;*.icl;*.exe;*.ico)"));
- else
- lstrcat(filter, _T(" (*.dll)"));
-
- pfilter=filter+lstrlen(filter)+1;
- if (bAll)
- lstrcpy(pfilter, _T("*.DLL;*.ICL;*.EXE;*.ICO"));
- else
- lstrcpy(pfilter, _T("*.DLL"));
-
- pfilter += lstrlen(pfilter) + 1;
- lstrcpy(pfilter, TranslateT("All Files"));
- lstrcat(pfilter, _T(" (*)"));
- pfilter += lstrlen(pfilter) + 1;
- lstrcpy(pfilter, _T("*"));
- pfilter += lstrlen(pfilter) + 1;
- *pfilter='\0';
-
- ofn.lpstrFilter = filter;
- ofn.lpstrDefExt = _T("dll");
- lstrcpyn(file, szFile, SIZEOF(file));
- ofn.lpstrFile = file;
- ofn.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | OFN_DONTADDTORECENT;
- ofn.nMaxFile = MAX_PATH*2;
-
- if ( !GetOpenFileName(&ofn))
- return NULL;
-
- return mir_tstrdup(file);
-}
-
-//
-// User interface
-//
-
-#define DM_REBUILDICONSPREVIEW (WM_USER+10)
-#define DM_CHANGEICON (WM_USER+11)
-#define DM_CHANGESPECIFICICON (WM_USER+12)
-#define DM_UPDATEICONSPREVIEW (WM_USER+13)
-#define DM_REBUILD_CTREE (WM_USER+14)
-
-INT_PTR CALLBACK DlgProcIconImport(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
-
-void DoOptionsChanged(HWND hwndDlg)
-{
- SendMessage(hwndDlg, DM_UPDATEICONSPREVIEW, 0, 0);
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
-}
-
-void DoIconsChanged(HWND hwndDlg)
-{
- SendMessage(hwndDlg, DM_UPDATEICONSPREVIEW, 0, 0);
-
- iconEventActive = 1; // Disable icon destroying - performance boost
- NotifyEventHooks(hIconsChangedEvent, 0, 0);
- NotifyEventHooks(hIcons2ChangedEvent, 0, 0);
- iconEventActive = 0;
-
- EnterCriticalSection(&csIconList); // Destroy unused icons
- for (int indx = 0; indx < iconList.getCount(); indx++) {
- IconItem *item = iconList[indx];
- if (item->source_small && !item->source_small->icon_ref_count) {
- item->source_small->icon_ref_count++;
- IconSourceItem_ReleaseIcon(item->source_small);
- }
- if (item->source_big && !item->source_big->icon_ref_count) {
- item->source_big->icon_ref_count++;
- IconSourceItem_ReleaseIcon(item->source_big);
- }
- }
- LeaveCriticalSection(&csIconList);
-}
-
-static HTREEITEM FindNamedTreeItemAt(HWND hwndTree, HTREEITEM hItem, const TCHAR *name)
-{
- TVITEM tvi = {0};
- TCHAR str[MAX_PATH];
-
- if (hItem)
- tvi.hItem = TreeView_GetChild(hwndTree, hItem);
- else
- tvi.hItem = TreeView_GetRoot(hwndTree);
-
- if ( !name)
- return tvi.hItem;
-
- tvi.mask = TVIF_TEXT;
- tvi.pszText = str;
- tvi.cchTextMax = MAX_PATH;
-
- while (tvi.hItem)
- {
- TreeView_GetItem(hwndTree, &tvi);
-
- if ( !lstrcmp(tvi.pszText, name))
- return tvi.hItem;
-
- tvi.hItem = TreeView_GetNextSibling(hwndTree, tvi.hItem);
- }
- return NULL;
-}
-
-/////////////////////////////////////////////////////////////////////////////////////////
-// icon import dialog's window procedure
-
-static int IconDlg_Resize(HWND, LPARAM, UTILRESIZECONTROL *urc)
-{
- switch (urc->wId) {
- case IDC_ICONSET:
- return RD_ANCHORX_WIDTH | RD_ANCHORY_TOP;
-
- case IDC_BROWSE:
- return RD_ANCHORX_RIGHT | RD_ANCHORY_TOP;
-
- case IDC_PREVIEW:
- return RD_ANCHORX_WIDTH | RD_ANCHORY_HEIGHT;
-
- case IDC_GETMORE:
- return RD_ANCHORX_CENTRE | RD_ANCHORY_BOTTOM;
- }
- return RD_ANCHORX_LEFT | RD_ANCHORY_TOP; // default
-}
-
-INT_PTR CALLBACK DlgProcIconImport(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
-{
- static HWND hwndParent, hwndDragOver;
- static int dragging;
- static int dragItem, dropHiLite;
- static HWND hPreview = NULL;
-
- switch (msg) {
- case WM_INITDIALOG:
- TranslateDialogDefault(hwndDlg);
- hwndParent = (HWND)lParam;
- hPreview = GetDlgItem(hwndDlg, IDC_PREVIEW);
- dragging = dragItem = 0;
- ListView_SetImageList(hPreview, ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), ILC_COLOR32|ILC_MASK, 0, 100), LVSIL_NORMAL);
- ListView_SetIconSpacing(hPreview, 56, 67);
- {
- RECT rcThis, rcParent;
- int cxScreen = GetSystemMetrics(SM_CXSCREEN);
-
- GetWindowRect(hwndDlg, &rcThis);
- GetWindowRect(hwndParent, &rcParent);
- OffsetRect(&rcThis, rcParent.right-rcThis.left, 0);
- OffsetRect(&rcThis, 0, rcParent.top-rcThis.top);
- GetWindowRect(GetParent(hwndParent), &rcParent);
- if (rcThis.right > cxScreen) {
- OffsetRect(&rcParent, cxScreen-rcThis.right, 0);
- OffsetRect(&rcThis, cxScreen-rcThis.right, 0);
- MoveWindow(GetParent(hwndParent), rcParent.left, rcParent.top, rcParent.right-rcParent.left, rcParent.bottom-rcParent.top, TRUE);
- }
- MoveWindow(hwndDlg, rcThis.left, rcThis.top, rcThis.right-rcThis.left, rcThis.bottom-rcThis.top, FALSE);
- GetClientRect(hwndDlg, &rcThis);
- SendMessage(hwndDlg, WM_SIZE, 0, MAKELPARAM(rcThis.right-rcThis.left, rcThis.bottom-rcThis.top));
- }
-
- if (shAutoComplete) shAutoComplete(GetDlgItem(hwndDlg, IDC_ICONSET), 1);
- SetDlgItemText(hwndDlg, IDC_ICONSET, _T("icons.dll"));
- return TRUE;
-
- case DM_REBUILDICONSPREVIEW:
- {
- LVITEM lvi;
- TCHAR filename[MAX_PATH], caption[64];
- HIMAGELIST hIml;
- int count, i;
- HICON hIcon;
-
- MySetCursor(IDC_WAIT);
- ListView_DeleteAllItems(hPreview);
- hIml = ListView_GetImageList(hPreview, LVSIL_NORMAL);
- ImageList_RemoveAll(hIml);
- GetDlgItemText(hwndDlg, IDC_ICONSET, filename, SIZEOF(filename));
- {
- RECT rcPreview, rcGroup;
-
- GetWindowRect(hPreview, &rcPreview);
- GetWindowRect(GetDlgItem(hwndDlg, IDC_IMPORTMULTI), &rcGroup);
- //SetWindowPos(hPreview, 0, 0, 0, rcPreview.right-rcPreview.left, rcGroup.bottom-rcPreview.top, SWP_NOZORDER|SWP_NOMOVE);
- }
-
- if (_taccess(filename, 0) != 0) {
- MySetCursor(IDC_ARROW);
- break;
- }
-
- lvi.mask = LVIF_TEXT|LVIF_IMAGE|LVIF_PARAM;
- lvi.iSubItem = 0;
- lvi.iItem = 0;
- count = (int)_ExtractIconEx(filename, -1, 16, 16, NULL, LR_DEFAULTCOLOR);
- for (i = 0; i < count; lvi.iItem++, i++) {
- mir_sntprintf(caption, SIZEOF(caption), _T("%d"), i+1);
- lvi.pszText = caption;
- //hIcon = ExtractIcon(hMirandaInst, filename, i);
- _ExtractIconEx(filename, i, 16, 16, &hIcon, LR_DEFAULTCOLOR);
- lvi.iImage = ImageList_AddIcon(hIml, hIcon);
- DestroyIcon(hIcon);
- lvi.lParam = i;
- ListView_InsertItem(hPreview, &lvi);
- }
- MySetCursor(IDC_ARROW);
- }
- break;
-
- case WM_COMMAND:
- switch(LOWORD(wParam)) {
- case IDC_BROWSE:
- {
- TCHAR str[MAX_PATH];
- TCHAR *file;
-
- GetDlgItemText(hwndDlg, IDC_ICONSET, str, SIZEOF(str));
- if ( !(file = OpenFileDlg(GetParent(hwndDlg), str, TRUE))) break;
- SetDlgItemText(hwndDlg, IDC_ICONSET, file);
- SAFE_FREE((void**)&file);
- }
- break;
-
- case IDC_GETMORE:
- OpenIconsPage();
- break;
-
- case IDC_ICONSET:
- if (HIWORD(wParam) == EN_CHANGE)
- SendMessage(hwndDlg, DM_REBUILDICONSPREVIEW, 0, 0);
- break;
- }
- break;
-
- case WM_MOUSEMOVE:
- if (dragging) {
- LVHITTESTINFO lvhti;
- int onItem=0;
- HWND hwndOver;
- RECT rc;
- POINT ptDrag;
- HWND hPPreview = GetDlgItem(hwndParent, IDC_PREVIEW);
-
- lvhti.pt.x = (short)LOWORD(lParam); lvhti.pt.y = (short)HIWORD(lParam);
- ClientToScreen(hwndDlg, &lvhti.pt);
- hwndOver = WindowFromPoint(lvhti.pt);
- GetWindowRect(hwndOver, &rc);
- ptDrag.x = lvhti.pt.x - rc.left; ptDrag.y = lvhti.pt.y - rc.top;
- if (hwndOver != hwndDragOver) {
- ImageList_DragLeave(hwndDragOver);
- hwndDragOver = hwndOver;
- ImageList_DragEnter(hwndDragOver, ptDrag.x, ptDrag.y);
- }
-
- ImageList_DragMove(ptDrag.x, ptDrag.y);
- if (hwndOver == hPPreview) {
- ScreenToClient(hPPreview, &lvhti.pt);
-
- if (ListView_HitTest(hPPreview, &lvhti) != -1) {
- if (lvhti.iItem != dropHiLite) {
- ImageList_DragLeave(hwndDragOver);
- if (dropHiLite != -1)
- ListView_SetItemState(hPPreview, dropHiLite, 0, LVIS_DROPHILITED);
- dropHiLite = lvhti.iItem;
- ListView_SetItemState(hPPreview, dropHiLite, LVIS_DROPHILITED, LVIS_DROPHILITED);
- UpdateWindow(hPPreview);
- ImageList_DragEnter(hwndDragOver, ptDrag.x, ptDrag.y);
- }
- onItem = 1;
- } }
-
- if ( !onItem && dropHiLite != -1) {
- ImageList_DragLeave(hwndDragOver);
- ListView_SetItemState(hPPreview, dropHiLite, 0, LVIS_DROPHILITED);
- UpdateWindow(hPPreview);
- ImageList_DragEnter(hwndDragOver, ptDrag.x, ptDrag.y);
- dropHiLite = -1;
- }
- MySetCursor(onItem ? IDC_ARROW : IDC_NO);
- }
- break;
-
- case WM_LBUTTONUP:
- if (dragging) {
- ReleaseCapture();
- ImageList_EndDrag();
- dragging = 0;
- if (dropHiLite != -1) {
- TCHAR path[MAX_PATH], fullPath[MAX_PATH], filename[MAX_PATH];
- LVITEM lvi;
-
- GetDlgItemText(hwndDlg, IDC_ICONSET, fullPath, SIZEOF(fullPath));
- CallService(MS_UTILS_PATHTORELATIVET, (WPARAM)fullPath, (LPARAM)filename);
- lvi.mask=LVIF_PARAM;
- lvi.iItem = dragItem; lvi.iSubItem = 0;
- ListView_GetItem(hPreview, &lvi);
- mir_sntprintf(path, MAX_PATH, _T("%s,%d"), filename, (int)lvi.lParam);
- SendMessage(hwndParent, DM_CHANGEICON, dropHiLite, (LPARAM)path);
- ListView_SetItemState(GetDlgItem(hwndParent, IDC_PREVIEW), dropHiLite, 0, LVIS_DROPHILITED);
- } }
- break;
-
- case WM_NOTIFY:
- switch (((LPNMHDR)lParam)->idFrom) {
- case IDC_PREVIEW:
- switch (((LPNMHDR)lParam)->code) {
- case LVN_BEGINDRAG:
- SetCapture(hwndDlg);
- dragging = 1;
- dragItem = ((LPNMLISTVIEW)lParam)->iItem;
- dropHiLite = -1;
- ImageList_BeginDrag(ListView_GetImageList(hPreview, LVSIL_NORMAL), dragItem, GetSystemMetrics(SM_CXICON)/2, GetSystemMetrics(SM_CYICON)/2);
- {
- POINT pt;
- RECT rc;
-
- GetCursorPos(&pt);
- GetWindowRect(hwndDlg, &rc);
- ImageList_DragEnter(hwndDlg, pt.x - rc.left, pt.y - rc.top);
- hwndDragOver = hwndDlg;
- }
- break;
- }
- break;
- }
- break;
-
- case WM_CLOSE:
- DestroyWindow(hwndDlg);
- EnableWindow(GetDlgItem(hwndParent, IDC_IMPORT), TRUE);
- break;
-
- case WM_SIZE:
- { // make the dlg resizeable
- UTILRESIZEDIALOG urd = {0};
-
- if (IsIconic(hwndDlg)) break;
- urd.cbSize = sizeof(urd);
- urd.hInstance = hMirandaInst;
- urd.hwndDlg = hwndDlg;
- urd.lParam = 0; // user-defined
- urd.lpTemplate = MAKEINTRESOURCEA(IDD_ICOLIB_IMPORT);
- urd.pfnResizer = IconDlg_Resize;
- CallService(MS_UTILS_RESIZEDIALOG, 0, (LPARAM)&urd);
- break;
- } }
-
- return FALSE;
-}
-
-/////////////////////////////////////////////////////////////////////////////////////////
-// IcoLib options window procedure
-
-static int CALLBACK DoSortIconsFunc(LPARAM lParam1, LPARAM lParam2, LPARAM)
-{ return lstrcmpi(TranslateTS(iconList[lParam1]->description), TranslateTS(iconList[lParam2]->description));
-}
-
-static int CALLBACK DoSortIconsFuncByOrder(LPARAM lParam1, LPARAM lParam2, LPARAM)
-{ return iconList[lParam1]->orderID - iconList[lParam2]->orderID;
-}
-
-static void SaveCollapseState(HWND hwndTree)
-{
- HTREEITEM hti;
- TVITEM tvi;
-
- hti = TreeView_GetRoot(hwndTree);
- while (hti != NULL) {
- HTREEITEM ht;
- TreeItem *treeItem;
-
- tvi.mask = TVIF_STATE | TVIF_HANDLE | TVIF_CHILDREN | TVIF_PARAM;
- tvi.hItem = hti;
- tvi.stateMask = (DWORD)-1;
- TreeView_GetItem(hwndTree, &tvi);
-
- if (tvi.cChildren > 0) {
- treeItem = (TreeItem *)tvi.lParam;
- if (tvi.state & TVIS_EXPANDED)
- DBWriteContactSettingByte(NULL, "SkinIconsUI", treeItem->paramName, TVIS_EXPANDED);
- else
- DBWriteContactSettingByte(NULL, "SkinIconsUI", treeItem->paramName, 0);
- }
-
- ht = TreeView_GetChild(hwndTree, hti);
- if (ht == NULL) {
- ht = TreeView_GetNextSibling(hwndTree, hti);
- while (ht == NULL) {
- hti = TreeView_GetParent(hwndTree, hti);
- if (hti == NULL) break;
- ht = TreeView_GetNextSibling(hwndTree, hti);
- } }
-
- hti = ht;
-} }
-
-INT_PTR CALLBACK DlgProcIcoLibOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
-{
- struct IcoLibOptsData *dat;
- static HTREEITEM prevItem = 0;
- static HWND hPreview = NULL;
-
- dat = (struct IcoLibOptsData*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
- switch (msg) {
- case WM_INITDIALOG:
- TranslateDialogDefault(hwndDlg);
- hPreview = GetDlgItem(hwndDlg, IDC_PREVIEW);
- dat = (struct IcoLibOptsData*)mir_alloc(sizeof(struct IcoLibOptsData));
- dat->hwndIndex = NULL;
- SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)dat);
- //
- // Reset temporary data & upload sections list
- //
- EnterCriticalSection(&csIconList);
- {
- int indx;
- for (indx = 0; indx < iconList.getCount(); indx++) {
- iconList[indx]->temp_file = NULL;
- iconList[indx]->temp_icon = NULL;
- iconList[indx]->temp_reset = FALSE;
- }
- bNeedRebuild = FALSE;
- }
- LeaveCriticalSection(&csIconList);
- //
- // Setup preview listview
- //
- ListView_SetUnicodeFormat(hPreview, TRUE);
- ListView_SetExtendedListViewStyleEx(hPreview, LVS_EX_INFOTIP, LVS_EX_INFOTIP);
- ListView_SetImageList(hPreview, ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), ILC_COLOR32|ILC_MASK, 0, 30), LVSIL_NORMAL);
- ListView_SetIconSpacing(hPreview, 56, 67);
-
- SendMessage(hwndDlg, DM_REBUILD_CTREE, 0, 0);
- return TRUE;
-
- case DM_REBUILD_CTREE:
- {
- HWND hwndTree = GetDlgItem(hwndDlg, IDC_CATEGORYLIST);
- int indx;
- TCHAR itemName[1024];
- HTREEITEM hSection;
-
- if ( !hwndTree) break;
-
- TreeView_SelectItem(hwndTree, NULL);
- TreeView_DeleteAllItems(hwndTree);
-
- for (indx = 0; indx < sectionList.getCount(); indx++) {
- TCHAR* sectionName;
- int sectionLevel = 0;
-
- hSection = NULL;
- lstrcpy(itemName, sectionList[indx]->name);
- sectionName = itemName;
-
- while (sectionName) {
- // allow multi-level tree
- TCHAR* pItemName = sectionName;
- HTREEITEM hItem;
-
- if (sectionName = _tcschr(sectionName, '/')) {
- // one level deeper
- *sectionName = 0;
- }
-
- pItemName = TranslateTS(pItemName);
-
- hItem = FindNamedTreeItemAt(hwndTree, hSection, pItemName);
- if ( !sectionName || !hItem) {
- if ( !hItem) {
- TVINSERTSTRUCT tvis = {0};
- TreeItem *treeItem = (TreeItem *)mir_alloc(sizeof(TreeItem));
- treeItem->value = SECTIONPARAM_MAKE(indx, sectionLevel, sectionName?0:SECTIONPARAM_HAVEPAGE);
- treeItem->paramName = mir_t2a(itemName);
-
- tvis.hParent = hSection;
- tvis.hInsertAfter = TVI_SORT; //TVI_LAST;
- tvis.item.mask = TVIF_TEXT|TVIF_PARAM|TVIF_STATE;
- tvis.item.pszText = pItemName;
- tvis.item.lParam = (LPARAM) treeItem;
-
- tvis.item.state = tvis.item.stateMask = DBGetContactSettingByte(NULL, "SkinIconsUI", treeItem->paramName, TVIS_EXPANDED);
- hItem = TreeView_InsertItem(hwndTree, &tvis);
- }
- else {
- TVITEM tvi = {0};
- TreeItem *treeItem;
- tvi.hItem = hItem;
- tvi.mask = TVIF_HANDLE | TVIF_PARAM;
- TreeView_GetItem(hwndTree, &tvi);
- treeItem = (TreeItem *)tvi.lParam;
- treeItem->value = SECTIONPARAM_MAKE(indx, sectionLevel, SECTIONPARAM_HAVEPAGE);
- } }
-
- if (sectionName) {
- *sectionName = '/';
- sectionName++;
- }
- sectionLevel++;
-
- hSection = hItem;
- } }
-
- ShowWindow(hwndTree, SW_SHOW);
-
- TreeView_SelectItem(hwndTree, FindNamedTreeItemAt(hwndTree, 0, NULL));
- }
- break;
-
- // Rebuild preview to new section
- case DM_REBUILDICONSPREVIEW:
- {
- LVITEM lvi = {0};
- HIMAGELIST hIml;
- HICON hIcon;
- SectionItem* sectionActive = (SectionItem*)lParam;
- int indx;
-
- EnableWindow(hPreview, sectionActive != NULL);
-
- ListView_DeleteAllItems(hPreview);
- hIml = ListView_GetImageList(hPreview, LVSIL_NORMAL);
- ImageList_RemoveAll(hIml);
-
- if (sectionActive == NULL)
- break;
-
- lvi.mask = LVIF_TEXT|LVIF_IMAGE|LVIF_PARAM;
-
- EnterCriticalSection(&csIconList);
-
- for (indx = 0; indx < iconList.getCount(); indx++) {
- IconItem *item = iconList[indx];
-
- if (item->section == sectionActive) {
- lvi.pszText = TranslateTS(item->description);
- hIcon = item->temp_icon;
- if ( !hIcon)
- hIcon = IconItem_GetIcon_Preview(item);
- lvi.iImage = ImageList_AddIcon(hIml, hIcon);
- lvi.lParam = indx;
- ListView_InsertItem(hPreview, &lvi);
- if (hIcon != item->temp_icon) SafeDestroyIcon(&hIcon);
- } }
-
- LeaveCriticalSection(&csIconList);
-
- if (sectionActive->flags & SIDF_SORTED)
- ListView_SortItems(hPreview, DoSortIconsFunc, 0);
- else
- ListView_SortItems(hPreview, DoSortIconsFuncByOrder, 0);
- }
- break;
-
- // Refresh preview to new section
- case DM_UPDATEICONSPREVIEW:
- {
- LVITEM lvi = {0};
- HICON hIcon;
- int indx, count;
- HIMAGELIST hIml = ListView_GetImageList(hPreview, LVSIL_NORMAL);
-
- lvi.mask = LVIF_IMAGE|LVIF_PARAM;
- count = ListView_GetItemCount(hPreview);
-
- for (indx = 0; indx < count; indx++) {
- lvi.iItem = indx;
- ListView_GetItem(hPreview, &lvi);
- EnterCriticalSection(&csIconList);
- hIcon = iconList[lvi.lParam]->temp_icon;
- if ( !hIcon)
- hIcon = IconItem_GetIcon_Preview(iconList[lvi.lParam]);
- LeaveCriticalSection(&csIconList);
-
- if (hIcon)
- ImageList_ReplaceIcon(hIml, lvi.iImage, hIcon);
- if (hIcon != iconList[lvi.lParam]->temp_icon) SafeDestroyIcon(&hIcon);
- }
- ListView_RedrawItems(hPreview, 0, count);
- }
- break;
-
- // Temporary change icon - only inside options dialog
- case DM_CHANGEICON:
- {
- TCHAR *path=(TCHAR*)lParam;
- LVITEM lvi = {0};
- IconItem *item;
-
- lvi.mask = LVIF_PARAM;
- lvi.iItem = wParam;
- ListView_GetItem(hPreview, &lvi);
-
- EnterCriticalSection(&csIconList);
- item = iconList[ lvi.lParam ];
-
- SAFE_FREE((void**)&item->temp_file);
- SafeDestroyIcon(&item->temp_icon);
- item->temp_file = mir_tstrdup(path);
- item->temp_icon = (HICON)ExtractIconFromPath(path, item->cx, item->cy);
- item->temp_reset = FALSE;
-
- LeaveCriticalSection(&csIconList);
- DoOptionsChanged(hwndDlg);
- }
- break;
-
- case WM_COMMAND:
- if (LOWORD(wParam) == IDC_IMPORT) {
- dat->hwndIndex = CreateDialogParam(hMirandaInst, MAKEINTRESOURCE(IDD_ICOLIB_IMPORT), GetParent(hwndDlg), DlgProcIconImport, (LPARAM)hwndDlg);
- EnableWindow((HWND)lParam, FALSE);
- }
- else if (LOWORD(wParam) == IDC_GETMORE) {
- OpenIconsPage();
- break;
- }
- else if (LOWORD(wParam) == IDC_LOADICONS) {
- TCHAR filetmp[1] = {0};
- TCHAR *file;
-
- if (file = OpenFileDlg(hwndDlg, filetmp, FALSE)) {
- HWND htv = GetDlgItem(hwndDlg, IDC_CATEGORYLIST);
- TCHAR filename[ MAX_PATH ];
-
- CallService(MS_UTILS_PATHTORELATIVET, (WPARAM)file, (LPARAM)filename);
- SAFE_FREE((void**)&file);
-
- MySetCursor(IDC_WAIT);
- LoadSubIcons(htv, filename, TreeView_GetSelection(htv));
- MySetCursor(IDC_ARROW);
-
- DoOptionsChanged(hwndDlg);
- } }
- break;
-
- case WM_CONTEXTMENU:
- if ((HWND)wParam == hPreview) {
- UINT count = ListView_GetSelectedCount(hPreview);
-
- if (count > 0) {
- int cmd = OpenPopupMenu(hwndDlg);
- switch(cmd) {
- case ID_CANCELCHANGE:
- case ID_RESET:
- {
- LVITEM lvi = {0};
- int itemIndx = -1;
-
- while ((itemIndx = ListView_GetNextItem(hPreview, itemIndx, LVNI_SELECTED)) != -1) {
- lvi.mask = LVIF_PARAM;
- lvi.iItem = itemIndx; //lvhti.iItem;
- ListView_GetItem(hPreview, &lvi);
-
- UndoChanges(lvi.lParam, cmd);
- }
-
- DoOptionsChanged(hwndDlg);
- break;
- } } }
- }
- else {
- HWND htv = GetDlgItem(hwndDlg, IDC_CATEGORYLIST);
- if ((HWND)wParam == htv) {
- int cmd = OpenPopupMenu(hwndDlg);
-
- switch(cmd) {
- case ID_CANCELCHANGE:
- case ID_RESET:
- UndoSubItemChanges(htv, TreeView_GetSelection(htv), cmd);
- DoOptionsChanged(hwndDlg);
- break;
- } } }
- break;
-
- case WM_NOTIFY:
- switch(((LPNMHDR)lParam)->idFrom) {
- case 0:
- switch(((LPNMHDR)lParam)->code) {
- case PSN_APPLY:
- {
- int indx;
-
- EnterCriticalSection(&csIconList);
-
- for (indx = 0; indx < iconList.getCount(); indx++) {
- IconItem *item = iconList[indx];
- if (item->temp_reset) {
- DBDeleteContactSetting(NULL, "SkinIcons", item->name);
- if (item->source_small != item->default_icon) {
- IconSourceItem_Release(&item->source_small);
- }
- }
- else if (item->temp_file) {
- DBWriteContactSettingTString(NULL, "SkinIcons", item->name, item->temp_file);
- IconSourceItem_Release(&item->source_small);
- SafeDestroyIcon(&item->temp_icon);
- }
- }
- LeaveCriticalSection(&csIconList);
-
- DoIconsChanged(hwndDlg);
- return TRUE;
- } }
- break;
-
- case IDC_PREVIEW:
- if (((LPNMHDR)lParam)->code == LVN_GETINFOTIP)
- {
- IconItem *item;
- NMLVGETINFOTIP *pInfoTip = (NMLVGETINFOTIP *)lParam;
- LVITEM lvi;
- lvi.mask = LVIF_PARAM;
- lvi.iItem = pInfoTip->iItem;
- ListView_GetItem(pInfoTip->hdr.hwndFrom, &lvi);
-
- if (lvi.lParam < iconList.getCount()) {
- item = iconList[lvi.lParam];
- if (item->temp_file)
- _tcsncpy(pInfoTip->pszText, item->temp_file, pInfoTip->cchTextMax);
- else if (item->default_file)
- mir_sntprintf(pInfoTip->pszText, pInfoTip->cchTextMax, _T("%s, %d"), item->default_file, item->default_indx);
- }
- }
- if (bNeedRebuild) {
- EnterCriticalSection(&csIconList);
- bNeedRebuild = FALSE;
- LeaveCriticalSection(&csIconList);
- SendMessage(hwndDlg, DM_REBUILD_CTREE, 0, 0);
- }
- break;
-
- case IDC_CATEGORYLIST:
- switch(((NMHDR*)lParam)->code) {
- case TVN_SELCHANGEDA: // !!!! This needs to be here - both !!
- case TVN_SELCHANGEDW:
- {
- NMTREEVIEW *pnmtv = (NMTREEVIEW*)lParam;
- TVITEM tvi = pnmtv->itemNew;
- TreeItem *treeItem = (TreeItem *)tvi.lParam;
- if (treeItem)
- SendMessage(hwndDlg, DM_REBUILDICONSPREVIEW, 0, (LPARAM)(
- (SECTIONPARAM_FLAGS(treeItem->value)&SECTIONPARAM_HAVEPAGE)?
- sectionList[ SECTIONPARAM_INDEX(treeItem->value) ] : NULL));
- break;
- }
- case TVN_DELETEITEMA: // no idea why both TVN_SELCHANGEDA/W should be there but let's keep this both too...
- case TVN_DELETEITEMW:
- {
- TreeItem *treeItem = (TreeItem *)(((LPNMTREEVIEW)lParam)->itemOld.lParam);
- if (treeItem) {
- mir_free(treeItem->paramName);
- mir_free(treeItem);
- }
- break;
- } }
- if (bNeedRebuild) {
- EnterCriticalSection(&csIconList);
- bNeedRebuild = FALSE;
- LeaveCriticalSection(&csIconList);
- SendMessage(hwndDlg, DM_REBUILD_CTREE, 0, 0);
- } }
- break;
- case WM_DESTROY:
- {
- int indx;
-
- SaveCollapseState(GetDlgItem(hwndDlg, IDC_CATEGORYLIST));
- DestroyWindow(dat->hwndIndex);
-
- EnterCriticalSection(&csIconList);
- for (indx = 0; indx < iconList.getCount(); indx++) {
- IconItem *item = iconList[indx];
-
- SAFE_FREE((void**)&item->temp_file);
- SafeDestroyIcon(&item->temp_icon);
- }
- LeaveCriticalSection(&csIconList);
-
- SAFE_FREE((void**)&dat);
- break;
- } }
-
- return FALSE;
-}
-
-static UINT iconsExpertOnlyControls[]={IDC_IMPORT};
-
-static int SkinOptionsInit(WPARAM wParam, LPARAM)
-{
- OPTIONSDIALOGPAGE odp = {0};
- odp.cbSize = sizeof(odp);
- odp.hInstance = hMirandaInst;
- odp.flags = ODPF_BOLDGROUPS;
- odp.position = -180000000;
- odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_ICOLIB);
- odp.pszTitle = LPGEN("Icons");
- odp.pszGroup = LPGEN("Customize");
- odp.pfnDlgProc = DlgProcIcoLibOpts;
- odp.expertOnlyControls = iconsExpertOnlyControls;
- odp.nExpertOnlyControls = SIZEOF(iconsExpertOnlyControls);
- Options_AddPage(wParam, &odp);
- return 0;
-}
-
static int SkinSystemModulesLoaded(WPARAM, LPARAM)
{
HookEvent(ME_OPT_INITIALISE, SkinOptionsInit);
@@ -1856,8 +798,8 @@ static int SkinSystemModulesLoaded(WPARAM, LPARAM) /////////////////////////////////////////////////////////////////////////////////////////
// Module initialization and finalization procedure
-static INT_PTR sttIcoLib_AddNewIcon(WPARAM, LPARAM lParam)
-{ return (INT_PTR)IcoLib_AddNewIcon((SKINICONDESC*)lParam);
+static INT_PTR sttIcoLib_AddNewIcon(WPARAM wParam, LPARAM lParam)
+{ return (INT_PTR)IcoLib_AddNewIcon((int)wParam, (SKINICONDESC*)lParam);
}
static INT_PTR sttIcoLib_GetIcon(WPARAM wParam, LPARAM lParam)
@@ -1891,7 +833,7 @@ int LoadIcoLibModule(void) hIconBlank = LoadIconEx(NULL, MAKEINTRESOURCE(IDI_BLANK), 0);
InitializeCriticalSection(&csIconList);
- hIcoLib_AddNewIcon = CreateServiceFunction(MS_SKIN2_ADDICON, sttIcoLib_AddNewIcon);
+ hIcoLib_AddNewIcon = CreateServiceFunction("Skin2/Icons/AddIcon", sttIcoLib_AddNewIcon);
hIcoLib_RemoveIcon = CreateServiceFunction(MS_SKIN2_REMOVEICON, IcoLib_RemoveIcon);
hIcoLib_GetIcon = CreateServiceFunction(MS_SKIN2_GETICON, sttIcoLib_GetIcon);
hIcoLib_GetIconHandle = CreateServiceFunction(MS_SKIN2_GETICONHANDLE, sttIcoLib_GetIconHandle);
diff --git a/src/modules/icolib/skin2opts.cpp b/src/modules/icolib/skin2opts.cpp new file mode 100644 index 0000000000..0d230d7930 --- /dev/null +++ b/src/modules/icolib/skin2opts.cpp @@ -0,0 +1,1051 @@ +/*
+
+Miranda IM: the free IM client for Microsoft* Windows*
+
+Copyright 2000-2009 Miranda ICQ/IM project,
+all portions of this codebase are copyrighted to the people
+listed in contributors.txt.
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#include "..\..\core\commonheaders.h"
+
+#include "IcoLib.h"
+
+struct TreeItem
+{
+ char *paramName;
+ DWORD value;
+};
+
+struct IcoLibOptsData
+{
+ HWND hwndIndex;
+};
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
+static HICON ExtractIconFromPath(const TCHAR *path, int cxIcon, int cyIcon)
+{
+ TCHAR *comma;
+ TCHAR file[ MAX_PATH ], fileFull[ MAX_PATH ];
+ int n;
+ HICON hIcon;
+
+ if ( !path)
+ return (HICON)NULL;
+
+ lstrcpyn(file, path, SIZEOF(file));
+ comma = _tcsrchr(file, ',');
+ if ( !comma)
+ n = 0;
+ else {
+ n = _ttoi(comma+1);
+ *comma = 0;
+ }
+ pathToAbsoluteT(file, fileFull, NULL);
+ hIcon = NULL;
+
+ //SHOULD BE REPLACED WITH GOOD ENOUGH FUNCTION
+ _ExtractIconEx(fileFull, n, cxIcon, cyIcon, &hIcon, LR_COLOR);
+ return hIcon;
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+// IcoLib_ReleaseIcon
+// lParam: pszIconName or NULL
+// wParam: HICON or NULL
+
+int IcoLib_ReleaseIcon(HICON hIcon, char* szIconName, bool big)
+{
+ IconItem *item = NULL;
+
+ EnterCriticalSection(&csIconList);
+
+ if (szIconName)
+ item = IcoLib_FindIcon(szIconName);
+
+ if ( !item && hIcon) // find by HICON
+ item = IcoLib_FindHIcon(hIcon, big);
+
+ int res = 1;
+ if (item) {
+ IconSourceItem* source = big && !item->cx ? item->source_big : item->source_small;
+ if (source && source->icon_ref_count) {
+ if (iconEventActive)
+ source->icon_ref_count--;
+ else
+ IconSourceItem_ReleaseIcon(source);
+ res = 0;
+ }
+ }
+
+ LeaveCriticalSection(&csIconList);
+ return res;
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+// IconItem_GetIcon_Preview
+
+HICON IconItem_GetIcon_Preview(IconItem* item)
+{
+ HICON hIcon = NULL;
+
+ if ( !item->temp_reset) {
+ HICON hRefIcon = IconItem_GetIcon(item, false);
+ hIcon = CopyIcon(hRefIcon);
+ if (item->source_small && item->source_small->icon == hRefIcon)
+ IconSourceItem_ReleaseIcon(item->source_small);
+ }
+ else {
+ if (item->default_icon) {
+ HICON hRefIcon = IconSourceItem_GetIcon(item->default_icon);
+ if (hRefIcon) {
+ hIcon = CopyIcon(hRefIcon);
+ if (item->default_icon->icon == hRefIcon)
+ IconSourceItem_ReleaseIcon(item->default_icon);
+ } }
+
+ if ( !hIcon && item->default_file) {
+ IconSourceItem_Release(&item->default_icon);
+ item->default_icon = GetIconSourceItem(item->default_file, item->default_indx, item->cx, item->cy);
+ if (item->default_icon) {
+ HICON hRefIcon = IconSourceItem_GetIcon(item->default_icon);
+ if (hRefIcon) {
+ hIcon = CopyIcon(hRefIcon);
+ if (item->default_icon->icon == hRefIcon)
+ IconSourceItem_ReleaseIcon(item->default_icon);
+ } } }
+
+ if ( !hIcon)
+ return CopyIcon(hIconBlank);
+ }
+ return hIcon;
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+// IcoLib GUI service routines
+
+static void __fastcall MySetCursor(TCHAR* nCursor)
+{ SetCursor(LoadCursor(NULL, nCursor));
+}
+
+static void LoadSectionIcons(TCHAR *filename, SectionItem* sectionActive)
+{
+ TCHAR path[ MAX_PATH ];
+ mir_sntprintf(path, SIZEOF(path), _T("%s,"), filename);
+ int suffIndx = lstrlen(path);
+
+ EnterCriticalSection(&csIconList);
+
+ for (int indx = 0; indx < iconList.getCount(); indx++) {
+ IconItem *item = iconList[ indx ];
+
+ if (item->default_file && item->section == sectionActive) {
+ _itot(item->default_indx, path + suffIndx, 10);
+ HICON hIcon = ExtractIconFromPath(path, item->cx, item->cy);
+ if (!hIcon)
+ continue;
+
+ SAFE_FREE((void**)&item->temp_file);
+ SafeDestroyIcon(&item->temp_icon);
+
+ item->temp_file = mir_tstrdup(path);
+ item->temp_icon = hIcon;
+ item->temp_reset = FALSE;
+ } }
+
+ LeaveCriticalSection(&csIconList);
+}
+
+void LoadSubIcons(HWND htv, TCHAR *filename, HTREEITEM hItem)
+{
+ TVITEM tvi;
+ tvi.mask = TVIF_HANDLE | TVIF_PARAM;
+ tvi.hItem = hItem;
+ TreeView_GetItem(htv, &tvi);
+
+ TreeItem *treeItem = (TreeItem *)tvi.lParam;
+ SectionItem* sectionActive = sectionList[ SECTIONPARAM_INDEX(treeItem->value) ];
+
+ tvi.hItem = TreeView_GetChild(htv, tvi.hItem);
+ while (tvi.hItem) {
+ LoadSubIcons(htv, filename, tvi.hItem);
+ tvi.hItem = TreeView_GetNextSibling(htv, tvi.hItem);
+ }
+
+ if (SECTIONPARAM_FLAGS(treeItem->value) & SECTIONPARAM_HAVEPAGE)
+ LoadSectionIcons(filename, sectionActive);
+}
+
+static void UndoChanges(int iconIndx, int cmd)
+{
+ IconItem *item = iconList[ iconIndx ];
+
+ if ( !item->temp_file && !item->temp_icon && item->temp_reset && cmd == ID_CANCELCHANGE)
+ item->temp_reset = FALSE;
+ else {
+ SAFE_FREE((void**)&item->temp_file);
+ SafeDestroyIcon(&item->temp_icon);
+ }
+
+ if (cmd == ID_RESET)
+ item->temp_reset = TRUE;
+}
+
+void UndoSubItemChanges(HWND htv, HTREEITEM hItem, int cmd)
+{
+ TVITEM tvi = {0};
+ tvi.mask = TVIF_HANDLE | TVIF_PARAM;
+ tvi.hItem = hItem;
+ TreeView_GetItem(htv, &tvi);
+
+ TreeItem *treeItem = (TreeItem *)tvi.lParam;
+ if (SECTIONPARAM_FLAGS(treeItem->value) & SECTIONPARAM_HAVEPAGE) {
+ EnterCriticalSection(&csIconList);
+
+ for (int indx = 0; indx < iconList.getCount(); indx++)
+ if (iconList[ indx ]->section == sectionList[ SECTIONPARAM_INDEX(treeItem->value) ])
+ UndoChanges(indx, cmd);
+
+ LeaveCriticalSection(&csIconList);
+ }
+
+ tvi.hItem = TreeView_GetChild(htv, tvi.hItem);
+ while (tvi.hItem) {
+ UndoSubItemChanges(htv, tvi.hItem, cmd);
+ tvi.hItem = TreeView_GetNextSibling(htv, tvi.hItem);
+} }
+
+static void OpenIconsPage()
+{
+ CallService(MS_UTILS_OPENURL, 1, (LPARAM)"http://addons.miranda-im.org/index.php?action=display&id=35");
+}
+
+static int OpenPopupMenu(HWND hwndDlg)
+{
+ HMENU hMenu, hPopup;
+ POINT pt;
+ int cmd;
+
+ GetCursorPos(&pt);
+ hMenu = LoadMenu(hMirandaInst, MAKEINTRESOURCE(IDR_ICOLIB_CONTEXT));
+ hPopup = GetSubMenu(hMenu, 0);
+ TranslateMenu(hPopup);
+ cmd = TrackPopupMenu(hPopup, TPM_RIGHTBUTTON|TPM_RETURNCMD, pt.x, pt.y, 0, hwndDlg, NULL);
+ DestroyMenu(hMenu);
+ return cmd;
+}
+
+static TCHAR* OpenFileDlg(HWND hParent, const TCHAR* szFile, BOOL bAll)
+{
+ OPENFILENAME ofn = {0};
+ TCHAR filter[512], *pfilter, file[MAX_PATH*2];
+
+ ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400;
+ ofn.hwndOwner = hParent;
+
+ lstrcpy(filter, TranslateT("Icon Sets"));
+ if (bAll)
+ lstrcat(filter, _T(" (*.dll;*.icl;*.exe;*.ico)"));
+ else
+ lstrcat(filter, _T(" (*.dll)"));
+
+ pfilter=filter+lstrlen(filter)+1;
+ if (bAll)
+ lstrcpy(pfilter, _T("*.DLL;*.ICL;*.EXE;*.ICO"));
+ else
+ lstrcpy(pfilter, _T("*.DLL"));
+
+ pfilter += lstrlen(pfilter) + 1;
+ lstrcpy(pfilter, TranslateT("All Files"));
+ lstrcat(pfilter, _T(" (*)"));
+ pfilter += lstrlen(pfilter) + 1;
+ lstrcpy(pfilter, _T("*"));
+ pfilter += lstrlen(pfilter) + 1;
+ *pfilter='\0';
+
+ ofn.lpstrFilter = filter;
+ ofn.lpstrDefExt = _T("dll");
+ lstrcpyn(file, szFile, SIZEOF(file));
+ ofn.lpstrFile = file;
+ ofn.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | OFN_DONTADDTORECENT;
+ ofn.nMaxFile = MAX_PATH*2;
+
+ if ( !GetOpenFileName(&ofn))
+ return NULL;
+
+ return mir_tstrdup(file);
+}
+
+//
+// User interface
+//
+
+#define DM_REBUILDICONSPREVIEW (WM_USER+10)
+#define DM_CHANGEICON (WM_USER+11)
+#define DM_CHANGESPECIFICICON (WM_USER+12)
+#define DM_UPDATEICONSPREVIEW (WM_USER+13)
+#define DM_REBUILD_CTREE (WM_USER+14)
+
+INT_PTR CALLBACK DlgProcIconImport(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
+
+void DoOptionsChanged(HWND hwndDlg)
+{
+ SendMessage(hwndDlg, DM_UPDATEICONSPREVIEW, 0, 0);
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+}
+
+void DoIconsChanged(HWND hwndDlg)
+{
+ SendMessage(hwndDlg, DM_UPDATEICONSPREVIEW, 0, 0);
+
+ iconEventActive = 1; // Disable icon destroying - performance boost
+ NotifyEventHooks(hIconsChangedEvent, 0, 0);
+ NotifyEventHooks(hIcons2ChangedEvent, 0, 0);
+ iconEventActive = 0;
+
+ EnterCriticalSection(&csIconList); // Destroy unused icons
+ for (int indx = 0; indx < iconList.getCount(); indx++) {
+ IconItem *item = iconList[indx];
+ if (item->source_small && !item->source_small->icon_ref_count) {
+ item->source_small->icon_ref_count++;
+ IconSourceItem_ReleaseIcon(item->source_small);
+ }
+ if (item->source_big && !item->source_big->icon_ref_count) {
+ item->source_big->icon_ref_count++;
+ IconSourceItem_ReleaseIcon(item->source_big);
+ }
+ }
+ LeaveCriticalSection(&csIconList);
+}
+
+static HTREEITEM FindNamedTreeItemAt(HWND hwndTree, HTREEITEM hItem, const TCHAR *name)
+{
+ TVITEM tvi = {0};
+ TCHAR str[MAX_PATH];
+
+ if (hItem)
+ tvi.hItem = TreeView_GetChild(hwndTree, hItem);
+ else
+ tvi.hItem = TreeView_GetRoot(hwndTree);
+
+ if ( !name)
+ return tvi.hItem;
+
+ tvi.mask = TVIF_TEXT;
+ tvi.pszText = str;
+ tvi.cchTextMax = MAX_PATH;
+
+ while (tvi.hItem)
+ {
+ TreeView_GetItem(hwndTree, &tvi);
+
+ if ( !lstrcmp(tvi.pszText, name))
+ return tvi.hItem;
+
+ tvi.hItem = TreeView_GetNextSibling(hwndTree, tvi.hItem);
+ }
+ return NULL;
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+// icon import dialog's window procedure
+
+static int IconDlg_Resize(HWND, LPARAM, UTILRESIZECONTROL *urc)
+{
+ switch (urc->wId) {
+ case IDC_ICONSET:
+ return RD_ANCHORX_WIDTH | RD_ANCHORY_TOP;
+
+ case IDC_BROWSE:
+ return RD_ANCHORX_RIGHT | RD_ANCHORY_TOP;
+
+ case IDC_PREVIEW:
+ return RD_ANCHORX_WIDTH | RD_ANCHORY_HEIGHT;
+
+ case IDC_GETMORE:
+ return RD_ANCHORX_CENTRE | RD_ANCHORY_BOTTOM;
+ }
+ return RD_ANCHORX_LEFT | RD_ANCHORY_TOP; // default
+}
+
+INT_PTR CALLBACK DlgProcIconImport(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ static HWND hwndParent, hwndDragOver;
+ static int dragging;
+ static int dragItem, dropHiLite;
+ static HWND hPreview = NULL;
+
+ switch (msg) {
+ case WM_INITDIALOG:
+ TranslateDialogDefault(hwndDlg);
+ hwndParent = (HWND)lParam;
+ hPreview = GetDlgItem(hwndDlg, IDC_PREVIEW);
+ dragging = dragItem = 0;
+ ListView_SetImageList(hPreview, ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), ILC_COLOR32|ILC_MASK, 0, 100), LVSIL_NORMAL);
+ ListView_SetIconSpacing(hPreview, 56, 67);
+ {
+ RECT rcThis, rcParent;
+ int cxScreen = GetSystemMetrics(SM_CXSCREEN);
+
+ GetWindowRect(hwndDlg, &rcThis);
+ GetWindowRect(hwndParent, &rcParent);
+ OffsetRect(&rcThis, rcParent.right-rcThis.left, 0);
+ OffsetRect(&rcThis, 0, rcParent.top-rcThis.top);
+ GetWindowRect(GetParent(hwndParent), &rcParent);
+ if (rcThis.right > cxScreen) {
+ OffsetRect(&rcParent, cxScreen-rcThis.right, 0);
+ OffsetRect(&rcThis, cxScreen-rcThis.right, 0);
+ MoveWindow(GetParent(hwndParent), rcParent.left, rcParent.top, rcParent.right-rcParent.left, rcParent.bottom-rcParent.top, TRUE);
+ }
+ MoveWindow(hwndDlg, rcThis.left, rcThis.top, rcThis.right-rcThis.left, rcThis.bottom-rcThis.top, FALSE);
+ GetClientRect(hwndDlg, &rcThis);
+ SendMessage(hwndDlg, WM_SIZE, 0, MAKELPARAM(rcThis.right-rcThis.left, rcThis.bottom-rcThis.top));
+ }
+
+ if (shAutoComplete)
+ shAutoComplete(GetDlgItem(hwndDlg, IDC_ICONSET), 1);
+
+ SetDlgItemText(hwndDlg, IDC_ICONSET, _T("icons.dll"));
+ return TRUE;
+
+ case DM_REBUILDICONSPREVIEW:
+ {
+ MySetCursor(IDC_WAIT);
+ ListView_DeleteAllItems(hPreview);
+ HIMAGELIST hIml = ListView_GetImageList(hPreview, LVSIL_NORMAL);
+ ImageList_RemoveAll(hIml);
+
+ TCHAR filename[MAX_PATH], caption[64];
+ GetDlgItemText(hwndDlg, IDC_ICONSET, filename, SIZEOF(filename));
+ {
+ RECT rcPreview, rcGroup;
+
+ GetWindowRect(hPreview, &rcPreview);
+ GetWindowRect(GetDlgItem(hwndDlg, IDC_IMPORTMULTI), &rcGroup);
+ //SetWindowPos(hPreview, 0, 0, 0, rcPreview.right-rcPreview.left, rcGroup.bottom-rcPreview.top, SWP_NOZORDER|SWP_NOMOVE);
+ }
+
+ if ( _taccess(filename, 0) != 0) {
+ MySetCursor(IDC_ARROW);
+ break;
+ }
+
+ LVITEM lvi;
+ lvi.mask = LVIF_TEXT|LVIF_IMAGE|LVIF_PARAM;
+ lvi.iSubItem = 0;
+ lvi.iItem = 0;
+ int count = (int)_ExtractIconEx(filename, -1, 16, 16, NULL, LR_DEFAULTCOLOR);
+ for (int i = 0; i < count; lvi.iItem++, i++) {
+ mir_sntprintf(caption, SIZEOF(caption), _T("%d"), i+1);
+ lvi.pszText = caption;
+
+ HICON hIcon;
+ _ExtractIconEx(filename, i, 16, 16, &hIcon, LR_DEFAULTCOLOR);
+ lvi.iImage = ImageList_AddIcon(hIml, hIcon);
+ DestroyIcon(hIcon);
+ lvi.lParam = i;
+ ListView_InsertItem(hPreview, &lvi);
+ }
+ MySetCursor(IDC_ARROW);
+ }
+ break;
+
+ case WM_COMMAND:
+ switch(LOWORD(wParam)) {
+ case IDC_BROWSE:
+ {
+ TCHAR str[MAX_PATH], *file;
+ GetDlgItemText(hwndDlg, IDC_ICONSET, str, SIZEOF(str));
+ if ( !(file = OpenFileDlg(GetParent(hwndDlg), str, TRUE)))
+ break;
+ SetDlgItemText(hwndDlg, IDC_ICONSET, file);
+ SAFE_FREE((void**)&file);
+ }
+ break;
+
+ case IDC_GETMORE:
+ OpenIconsPage();
+ break;
+
+ case IDC_ICONSET:
+ if (HIWORD(wParam) == EN_CHANGE)
+ SendMessage(hwndDlg, DM_REBUILDICONSPREVIEW, 0, 0);
+ break;
+ }
+ break;
+
+ case WM_MOUSEMOVE:
+ if (dragging) {
+ LVHITTESTINFO lvhti;
+ int onItem=0;
+ HWND hwndOver;
+ RECT rc;
+ POINT ptDrag;
+ HWND hPPreview = GetDlgItem(hwndParent, IDC_PREVIEW);
+
+ lvhti.pt.x = (short)LOWORD(lParam); lvhti.pt.y = (short)HIWORD(lParam);
+ ClientToScreen(hwndDlg, &lvhti.pt);
+ hwndOver = WindowFromPoint(lvhti.pt);
+ GetWindowRect(hwndOver, &rc);
+ ptDrag.x = lvhti.pt.x - rc.left; ptDrag.y = lvhti.pt.y - rc.top;
+ if (hwndOver != hwndDragOver) {
+ ImageList_DragLeave(hwndDragOver);
+ hwndDragOver = hwndOver;
+ ImageList_DragEnter(hwndDragOver, ptDrag.x, ptDrag.y);
+ }
+
+ ImageList_DragMove(ptDrag.x, ptDrag.y);
+ if (hwndOver == hPPreview) {
+ ScreenToClient(hPPreview, &lvhti.pt);
+
+ if (ListView_HitTest(hPPreview, &lvhti) != -1) {
+ if (lvhti.iItem != dropHiLite) {
+ ImageList_DragLeave(hwndDragOver);
+ if (dropHiLite != -1)
+ ListView_SetItemState(hPPreview, dropHiLite, 0, LVIS_DROPHILITED);
+ dropHiLite = lvhti.iItem;
+ ListView_SetItemState(hPPreview, dropHiLite, LVIS_DROPHILITED, LVIS_DROPHILITED);
+ UpdateWindow(hPPreview);
+ ImageList_DragEnter(hwndDragOver, ptDrag.x, ptDrag.y);
+ }
+ onItem = 1;
+ } }
+
+ if ( !onItem && dropHiLite != -1) {
+ ImageList_DragLeave(hwndDragOver);
+ ListView_SetItemState(hPPreview, dropHiLite, 0, LVIS_DROPHILITED);
+ UpdateWindow(hPPreview);
+ ImageList_DragEnter(hwndDragOver, ptDrag.x, ptDrag.y);
+ dropHiLite = -1;
+ }
+ MySetCursor(onItem ? IDC_ARROW : IDC_NO);
+ }
+ break;
+
+ case WM_LBUTTONUP:
+ if (dragging) {
+ ReleaseCapture();
+ ImageList_EndDrag();
+ dragging = 0;
+ if (dropHiLite != -1) {
+ TCHAR path[MAX_PATH], fullPath[MAX_PATH], filename[MAX_PATH];
+ LVITEM lvi;
+
+ GetDlgItemText(hwndDlg, IDC_ICONSET, fullPath, SIZEOF(fullPath));
+ CallService(MS_UTILS_PATHTORELATIVET, (WPARAM)fullPath, (LPARAM)filename);
+ lvi.mask=LVIF_PARAM;
+ lvi.iItem = dragItem; lvi.iSubItem = 0;
+ ListView_GetItem(hPreview, &lvi);
+ mir_sntprintf(path, MAX_PATH, _T("%s,%d"), filename, (int)lvi.lParam);
+ SendMessage(hwndParent, DM_CHANGEICON, dropHiLite, (LPARAM)path);
+ ListView_SetItemState(GetDlgItem(hwndParent, IDC_PREVIEW), dropHiLite, 0, LVIS_DROPHILITED);
+ } }
+ break;
+
+ case WM_NOTIFY:
+ switch (((LPNMHDR)lParam)->idFrom) {
+ case IDC_PREVIEW:
+ switch (((LPNMHDR)lParam)->code) {
+ case LVN_BEGINDRAG:
+ SetCapture(hwndDlg);
+ dragging = 1;
+ dragItem = ((LPNMLISTVIEW)lParam)->iItem;
+ dropHiLite = -1;
+ ImageList_BeginDrag(ListView_GetImageList(hPreview, LVSIL_NORMAL), dragItem, GetSystemMetrics(SM_CXICON)/2, GetSystemMetrics(SM_CYICON)/2);
+ {
+ POINT pt;
+ RECT rc;
+
+ GetCursorPos(&pt);
+ GetWindowRect(hwndDlg, &rc);
+ ImageList_DragEnter(hwndDlg, pt.x - rc.left, pt.y - rc.top);
+ hwndDragOver = hwndDlg;
+ }
+ break;
+ }
+ break;
+ }
+ break;
+
+ case WM_SIZE: // make the dlg resizeable
+ if ( !IsIconic(hwndDlg)) {
+ UTILRESIZEDIALOG urd = {0};
+ urd.cbSize = sizeof(urd);
+ urd.hInstance = hMirandaInst;
+ urd.hwndDlg = hwndDlg;
+ urd.lParam = 0; // user-defined
+ urd.lpTemplate = MAKEINTRESOURCEA(IDD_ICOLIB_IMPORT);
+ urd.pfnResizer = IconDlg_Resize;
+ CallService(MS_UTILS_RESIZEDIALOG, 0, (LPARAM)&urd);
+ }
+ break;
+
+ case WM_CLOSE:
+ DestroyWindow(hwndDlg);
+ EnableWindow(GetDlgItem(hwndParent, IDC_IMPORT), TRUE);
+ break;
+
+ }
+
+ return FALSE;
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+// IcoLib options window procedure
+
+static int CALLBACK DoSortIconsFunc(LPARAM lParam1, LPARAM lParam2, LPARAM)
+{ return lstrcmpi(iconList[lParam1]->getDescr(), iconList[lParam2]->getDescr());
+}
+
+static int CALLBACK DoSortIconsFuncByOrder(LPARAM lParam1, LPARAM lParam2, LPARAM)
+{ return iconList[lParam1]->orderID - iconList[lParam2]->orderID;
+}
+
+static void SaveCollapseState(HWND hwndTree)
+{
+ HTREEITEM hti = TreeView_GetRoot(hwndTree);
+ while (hti != NULL) {
+ TVITEM tvi;
+ tvi.mask = TVIF_STATE | TVIF_HANDLE | TVIF_CHILDREN | TVIF_PARAM;
+ tvi.hItem = hti;
+ tvi.stateMask = (DWORD)-1;
+ TreeView_GetItem(hwndTree, &tvi);
+
+ if (tvi.cChildren > 0) {
+ TreeItem *treeItem = (TreeItem *)tvi.lParam;
+ if (tvi.state & TVIS_EXPANDED)
+ DBWriteContactSettingByte(NULL, "SkinIconsUI", treeItem->paramName, TVIS_EXPANDED);
+ else
+ DBWriteContactSettingByte(NULL, "SkinIconsUI", treeItem->paramName, 0);
+ }
+
+ HTREEITEM ht = TreeView_GetChild(hwndTree, hti);
+ if (ht == NULL) {
+ ht = TreeView_GetNextSibling(hwndTree, hti);
+ while (ht == NULL) {
+ hti = TreeView_GetParent(hwndTree, hti);
+ if (hti == NULL) break;
+ ht = TreeView_GetNextSibling(hwndTree, hti);
+ }
+ }
+
+ hti = ht;
+ }
+}
+
+INT_PTR CALLBACK DlgProcIcoLibOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ struct IcoLibOptsData *dat;
+ static HTREEITEM prevItem = 0;
+ static HWND hPreview = NULL;
+
+ dat = (struct IcoLibOptsData*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
+ switch (msg) {
+ case WM_INITDIALOG:
+ TranslateDialogDefault(hwndDlg);
+ hPreview = GetDlgItem(hwndDlg, IDC_PREVIEW);
+ dat = (struct IcoLibOptsData*)mir_alloc(sizeof(struct IcoLibOptsData));
+ dat->hwndIndex = NULL;
+ SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)dat);
+ //
+ // Reset temporary data & upload sections list
+ //
+ EnterCriticalSection(&csIconList);
+ {
+ int indx;
+ for (indx = 0; indx < iconList.getCount(); indx++) {
+ iconList[indx]->temp_file = NULL;
+ iconList[indx]->temp_icon = NULL;
+ iconList[indx]->temp_reset = FALSE;
+ }
+ bNeedRebuild = FALSE;
+ }
+ LeaveCriticalSection(&csIconList);
+ //
+ // Setup preview listview
+ //
+ ListView_SetUnicodeFormat(hPreview, TRUE);
+ ListView_SetExtendedListViewStyleEx(hPreview, LVS_EX_INFOTIP, LVS_EX_INFOTIP);
+ ListView_SetImageList(hPreview, ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), ILC_COLOR32|ILC_MASK, 0, 30), LVSIL_NORMAL);
+ ListView_SetIconSpacing(hPreview, 56, 67);
+
+ SendMessage(hwndDlg, DM_REBUILD_CTREE, 0, 0);
+ return TRUE;
+
+ case DM_REBUILD_CTREE:
+ {
+ HWND hwndTree = GetDlgItem(hwndDlg, IDC_CATEGORYLIST);
+ int indx;
+ TCHAR itemName[1024];
+ HTREEITEM hSection;
+
+ if ( !hwndTree) break;
+
+ TreeView_SelectItem(hwndTree, NULL);
+ TreeView_DeleteAllItems(hwndTree);
+
+ for (indx = 0; indx < sectionList.getCount(); indx++) {
+ TCHAR* sectionName;
+ int sectionLevel = 0;
+
+ hSection = NULL;
+ lstrcpy(itemName, sectionList[indx]->name);
+ sectionName = itemName;
+
+ while (sectionName) {
+ // allow multi-level tree
+ TCHAR* pItemName = sectionName;
+ HTREEITEM hItem;
+
+ if (sectionName = _tcschr(sectionName, '/')) {
+ // one level deeper
+ *sectionName = 0;
+ }
+
+ pItemName = TranslateTS(pItemName);
+ hItem = FindNamedTreeItemAt(hwndTree, hSection, pItemName);
+ if ( !sectionName || !hItem) {
+ if ( !hItem) {
+ TVINSERTSTRUCT tvis = {0};
+ TreeItem *treeItem = (TreeItem *)mir_alloc(sizeof(TreeItem));
+ treeItem->value = SECTIONPARAM_MAKE(indx, sectionLevel, sectionName ? 0 : SECTIONPARAM_HAVEPAGE);
+ treeItem->paramName = mir_t2a(itemName);
+
+ tvis.hParent = hSection;
+ tvis.hInsertAfter = TVI_SORT;
+ tvis.item.mask = TVIF_TEXT|TVIF_PARAM|TVIF_STATE;
+ tvis.item.pszText = pItemName;
+ tvis.item.lParam = (LPARAM) treeItem;
+
+ tvis.item.state = tvis.item.stateMask = DBGetContactSettingByte(NULL, "SkinIconsUI", treeItem->paramName, TVIS_EXPANDED);
+ hItem = TreeView_InsertItem(hwndTree, &tvis);
+ }
+ else {
+ TVITEM tvi = {0};
+ tvi.hItem = hItem;
+ tvi.mask = TVIF_HANDLE | TVIF_PARAM;
+ TreeView_GetItem(hwndTree, &tvi);
+ TreeItem *treeItem = (TreeItem *)tvi.lParam;
+ treeItem->value = SECTIONPARAM_MAKE(indx, sectionLevel, SECTIONPARAM_HAVEPAGE);
+ } }
+
+ if (sectionName) {
+ *sectionName = '/';
+ sectionName++;
+ }
+ sectionLevel++;
+
+ hSection = hItem;
+ }
+ }
+
+ ShowWindow(hwndTree, SW_SHOW);
+
+ TreeView_SelectItem(hwndTree, FindNamedTreeItemAt(hwndTree, 0, NULL));
+ }
+ break;
+
+ // Rebuild preview to new section
+ case DM_REBUILDICONSPREVIEW:
+ {
+ SectionItem* sectionActive = (SectionItem*)lParam;
+ EnableWindow(hPreview, sectionActive != NULL);
+
+ ListView_DeleteAllItems(hPreview);
+ HIMAGELIST hIml = ListView_GetImageList(hPreview, LVSIL_NORMAL);
+ ImageList_RemoveAll(hIml);
+
+ if (sectionActive == NULL)
+ break;
+
+ LVITEM lvi = {0};
+ lvi.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_PARAM;
+
+ EnterCriticalSection(&csIconList);
+
+ for (int indx = 0; indx < iconList.getCount(); indx++) {
+ IconItem *item = iconList[indx];
+ if (item->section == sectionActive) {
+ lvi.pszText = item->getDescr();
+ HICON hIcon = item->temp_icon;
+ if (!hIcon)
+ hIcon = IconItem_GetIcon_Preview(item);
+ lvi.iImage = ImageList_AddIcon(hIml, hIcon);
+ lvi.lParam = indx;
+ ListView_InsertItem(hPreview, &lvi);
+ if (hIcon != item->temp_icon)
+ SafeDestroyIcon(&hIcon);
+ }
+ }
+
+ LeaveCriticalSection(&csIconList);
+
+ if (sectionActive->flags & SIDF_SORTED)
+ ListView_SortItems(hPreview, DoSortIconsFunc, 0);
+ else
+ ListView_SortItems(hPreview, DoSortIconsFuncByOrder, 0);
+ }
+ break;
+
+ // Refresh preview to new section
+ case DM_UPDATEICONSPREVIEW:
+ {
+ LVITEM lvi = {0};
+ HICON hIcon;
+ int indx, count;
+ HIMAGELIST hIml = ListView_GetImageList(hPreview, LVSIL_NORMAL);
+
+ lvi.mask = LVIF_IMAGE|LVIF_PARAM;
+ count = ListView_GetItemCount(hPreview);
+
+ for (indx = 0; indx < count; indx++) {
+ lvi.iItem = indx;
+ ListView_GetItem(hPreview, &lvi);
+ EnterCriticalSection(&csIconList);
+ hIcon = iconList[lvi.lParam]->temp_icon;
+ if ( !hIcon)
+ hIcon = IconItem_GetIcon_Preview(iconList[lvi.lParam]);
+ LeaveCriticalSection(&csIconList);
+
+ if (hIcon)
+ ImageList_ReplaceIcon(hIml, lvi.iImage, hIcon);
+ if (hIcon != iconList[lvi.lParam]->temp_icon) SafeDestroyIcon(&hIcon);
+ }
+ ListView_RedrawItems(hPreview, 0, count);
+ }
+ break;
+
+ // Temporary change icon - only inside options dialog
+ case DM_CHANGEICON:
+ {
+ LVITEM lvi = {0};
+ lvi.mask = LVIF_PARAM;
+ lvi.iItem = wParam;
+ ListView_GetItem(hPreview, &lvi);
+
+ EnterCriticalSection(&csIconList);
+ IconItem *item = iconList[ lvi.lParam ];
+
+ SAFE_FREE((void**)&item->temp_file);
+ SafeDestroyIcon(&item->temp_icon);
+
+ TCHAR *path = (TCHAR*)lParam;
+ item->temp_file = mir_tstrdup(path);
+ item->temp_icon = (HICON)ExtractIconFromPath(path, item->cx, item->cy);
+ item->temp_reset = FALSE;
+
+ LeaveCriticalSection(&csIconList);
+ DoOptionsChanged(hwndDlg);
+ }
+ break;
+
+ case WM_COMMAND:
+ if (LOWORD(wParam) == IDC_IMPORT) {
+ dat->hwndIndex = CreateDialogParam(hMirandaInst, MAKEINTRESOURCE(IDD_ICOLIB_IMPORT), GetParent(hwndDlg), DlgProcIconImport, (LPARAM)hwndDlg);
+ EnableWindow((HWND)lParam, FALSE);
+ }
+ else if (LOWORD(wParam) == IDC_GETMORE) {
+ OpenIconsPage();
+ break;
+ }
+ else if (LOWORD(wParam) == IDC_LOADICONS) {
+ TCHAR filetmp[1] = {0};
+ TCHAR *file;
+
+ if (file = OpenFileDlg(hwndDlg, filetmp, FALSE)) {
+ HWND htv = GetDlgItem(hwndDlg, IDC_CATEGORYLIST);
+ TCHAR filename[ MAX_PATH ];
+
+ CallService(MS_UTILS_PATHTORELATIVET, (WPARAM)file, (LPARAM)filename);
+ SAFE_FREE((void**)&file);
+
+ MySetCursor(IDC_WAIT);
+ LoadSubIcons(htv, filename, TreeView_GetSelection(htv));
+ MySetCursor(IDC_ARROW);
+
+ DoOptionsChanged(hwndDlg);
+ } }
+ break;
+
+ case WM_CONTEXTMENU:
+ if ((HWND)wParam == hPreview) {
+ UINT count = ListView_GetSelectedCount(hPreview);
+
+ if (count > 0) {
+ int cmd = OpenPopupMenu(hwndDlg);
+ switch(cmd) {
+ case ID_CANCELCHANGE:
+ case ID_RESET:
+ {
+ LVITEM lvi = {0};
+ int itemIndx = -1;
+
+ while ((itemIndx = ListView_GetNextItem(hPreview, itemIndx, LVNI_SELECTED)) != -1) {
+ lvi.mask = LVIF_PARAM;
+ lvi.iItem = itemIndx; //lvhti.iItem;
+ ListView_GetItem(hPreview, &lvi);
+
+ UndoChanges(lvi.lParam, cmd);
+ }
+
+ DoOptionsChanged(hwndDlg);
+ break;
+ } } }
+ }
+ else {
+ HWND htv = GetDlgItem(hwndDlg, IDC_CATEGORYLIST);
+ if ((HWND)wParam == htv) {
+ int cmd = OpenPopupMenu(hwndDlg);
+
+ switch(cmd) {
+ case ID_CANCELCHANGE:
+ case ID_RESET:
+ UndoSubItemChanges(htv, TreeView_GetSelection(htv), cmd);
+ DoOptionsChanged(hwndDlg);
+ break;
+ } } }
+ break;
+
+ case WM_NOTIFY:
+ switch(((LPNMHDR)lParam)->idFrom) {
+ case 0:
+ switch(((LPNMHDR)lParam)->code) {
+ case PSN_APPLY:
+ {
+ EnterCriticalSection(&csIconList);
+
+ for (int indx = 0; indx < iconList.getCount(); indx++) {
+ IconItem *item = iconList[indx];
+ if (item->temp_reset) {
+ DBDeleteContactSetting(NULL, "SkinIcons", item->name);
+ if (item->source_small != item->default_icon) {
+ IconSourceItem_Release(&item->source_small);
+ }
+ }
+ else if (item->temp_file) {
+ DBWriteContactSettingTString(NULL, "SkinIcons", item->name, item->temp_file);
+ IconSourceItem_Release(&item->source_small);
+ SafeDestroyIcon(&item->temp_icon);
+ }
+ }
+ LeaveCriticalSection(&csIconList);
+
+ DoIconsChanged(hwndDlg);
+ return TRUE;
+ }
+ }
+ break;
+
+ case IDC_PREVIEW:
+ if (((LPNMHDR)lParam)->code == LVN_GETINFOTIP) {
+ IconItem *item;
+ NMLVGETINFOTIP *pInfoTip = (NMLVGETINFOTIP *)lParam;
+ LVITEM lvi;
+ lvi.mask = LVIF_PARAM;
+ lvi.iItem = pInfoTip->iItem;
+ ListView_GetItem(pInfoTip->hdr.hwndFrom, &lvi);
+
+ if (lvi.lParam < iconList.getCount()) {
+ item = iconList[lvi.lParam];
+ if (item->temp_file)
+ _tcsncpy(pInfoTip->pszText, item->temp_file, pInfoTip->cchTextMax);
+ else if (item->default_file)
+ mir_sntprintf(pInfoTip->pszText, pInfoTip->cchTextMax, _T("%s, %d"), item->default_file, item->default_indx);
+ }
+ }
+ if (bNeedRebuild) {
+ EnterCriticalSection(&csIconList);
+ bNeedRebuild = FALSE;
+ LeaveCriticalSection(&csIconList);
+ SendMessage(hwndDlg, DM_REBUILD_CTREE, 0, 0);
+ }
+ break;
+
+ case IDC_CATEGORYLIST:
+ switch(((NMHDR*)lParam)->code) {
+ case TVN_SELCHANGEDA: // !!!! This needs to be here - both !!
+ case TVN_SELCHANGEDW:
+ {
+ NMTREEVIEW *pnmtv = (NMTREEVIEW*)lParam;
+ TVITEM tvi = pnmtv->itemNew;
+ TreeItem *treeItem = (TreeItem *)tvi.lParam;
+ if (treeItem)
+ SendMessage(hwndDlg, DM_REBUILDICONSPREVIEW, 0, (LPARAM)(
+ (SECTIONPARAM_FLAGS(treeItem->value)&SECTIONPARAM_HAVEPAGE)?
+ sectionList[ SECTIONPARAM_INDEX(treeItem->value) ] : NULL));
+ break;
+ }
+ case TVN_DELETEITEMA: // no idea why both TVN_SELCHANGEDA/W should be there but let's keep this both too...
+ case TVN_DELETEITEMW:
+ {
+ TreeItem *treeItem = (TreeItem *)(((LPNMTREEVIEW)lParam)->itemOld.lParam);
+ if (treeItem) {
+ mir_free(treeItem->paramName);
+ mir_free(treeItem);
+ }
+ break;
+ }
+ }
+ if (bNeedRebuild) {
+ EnterCriticalSection(&csIconList);
+ bNeedRebuild = FALSE;
+ LeaveCriticalSection(&csIconList);
+ SendMessage(hwndDlg, DM_REBUILD_CTREE, 0, 0);
+ } }
+ break;
+
+ case WM_DESTROY:
+ SaveCollapseState(GetDlgItem(hwndDlg, IDC_CATEGORYLIST));
+ DestroyWindow(dat->hwndIndex);
+
+ EnterCriticalSection(&csIconList);
+ {
+ for (int indx = 0; indx < iconList.getCount(); indx++) {
+ IconItem *item = iconList[indx];
+
+ SAFE_FREE((void**)&item->temp_file);
+ SafeDestroyIcon(&item->temp_icon);
+ }
+ }
+ LeaveCriticalSection(&csIconList);
+
+ SAFE_FREE((void**)&dat);
+ break;
+ }
+
+ return FALSE;
+}
+
+static UINT iconsExpertOnlyControls[]={IDC_IMPORT};
+
+int SkinOptionsInit(WPARAM wParam, LPARAM)
+{
+ OPTIONSDIALOGPAGE odp = {0};
+ odp.cbSize = sizeof(odp);
+ odp.hInstance = hMirandaInst;
+ odp.flags = ODPF_BOLDGROUPS;
+ odp.position = -180000000;
+ odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_ICOLIB);
+ odp.pszTitle = LPGEN("Icons");
+ odp.pszGroup = LPGEN("Customize");
+ odp.pfnDlgProc = DlgProcIcoLibOpts;
+ odp.expertOnlyControls = iconsExpertOnlyControls;
+ odp.nExpertOnlyControls = SIZEOF(iconsExpertOnlyControls);
+ Options_AddPage(wParam, &odp);
+ return 0;
+}
diff --git a/src/modules/skin/skinicons.cpp b/src/modules/skin/skinicons.cpp index 777cc19757..24138e0000 100644 --- a/src/modules/skin/skinicons.cpp +++ b/src/modules/skin/skinicons.cpp @@ -314,7 +314,7 @@ HICON LoadSkinProtoIcon(const char* szProto, int status, bool big) sid.pszName = iconName;
sid.ptszDescription = cli.pfnGetStatusModeDescription(statusIcons[i].id, 0);
sid.iDefaultIndex = statusIcons[i].resource_id;
- IcoLib_AddNewIcon(&sid);
+ IcoLib_AddNewIcon(0, &sid);
} } } }
// format: core_status_%s%d
@@ -364,12 +364,11 @@ static void convertOneProtocol(char* moduleName, char* iconName) {
char* pm = moduleName + strlen(moduleName);
char* pi = iconName + strlen(iconName);
- DBVARIANT dbv;
- int i;
- for (i = 0; i < SIZEOF(statusIcons); i++) {
+ for (int i = 0; i < SIZEOF(statusIcons); i++) {
_itoa(statusIcons[i].id, pm, 10);
+ DBVARIANT dbv;
if ( !DBGetContactSettingTString(NULL, "Icons", moduleName, &dbv)) {
_itoa(i, pi, 10);
@@ -471,7 +470,7 @@ int LoadSkinIcons(void) sid.pszSection = mainIcons[i].section == NULL ? "Main Icons" : (char*)mainIcons[i].section;
sid.pszDescription = (char*)mainIcons[i].description;
sid.iDefaultIndex = mainIcons[i].resource_id;
- hMainIcons[i] = IcoLib_AddNewIcon(&sid);
+ hMainIcons[i] = IcoLib_AddNewIcon(0, &sid);
}
//
// Add global icons to list
@@ -485,7 +484,7 @@ int LoadSkinIcons(void) sid.pszName = iconName;
sid.pszDescription = (char*)statusIcons[i].description;
sid.iDefaultIndex = statusIcons[i].resource_id;
- hStatusIcons[i] = IcoLib_AddNewIcon(&sid);
+ hStatusIcons[i] = IcoLib_AddNewIcon(0, &sid);
}
return 0;
}
|