From 447e5fbb0fc7062b6749afe84252e2978ee57094 Mon Sep 17 00:00:00 2001
From: George Hazan <ghazan@miranda.im>
Date: Fri, 8 May 2020 14:22:06 +0300
Subject: NewStory to use common icons for files & URLs

---
 plugins/NewStory/src/history.cpp         |  6 +++---
 plugins/NewStory/src/history_control.cpp |  7 +++----
 plugins/NewStory/src/main.cpp            |  2 --
 plugins/NewStory/src/options.cpp         |  2 +-
 plugins/NewStory/src/resource.h          |  2 --
 plugins/NewStory/src/templates.cpp       | 13 +++++++++----
 plugins/NewStory/src/templates.h         |  6 ++++--
 7 files changed, 20 insertions(+), 18 deletions(-)

(limited to 'plugins/NewStory/src')

diff --git a/plugins/NewStory/src/history.cpp b/plugins/NewStory/src/history.cpp
index 512f8f37c1..cee9ad0dd4 100644
--- a/plugins/NewStory/src/history.cpp
+++ b/plugins/NewStory/src/history.cpp
@@ -552,7 +552,7 @@ public:
 		UpdateTitle();
 
 		ADDEVENTS tmp = { m_hContact, db_event_first(m_hContact), -1 };
-		SendMessage(m_histControl.GetHwnd(), NSM_ADDEVENTS, WPARAM(&tmp), 0);
+		m_histControl.SendMsg(NSM_ADDEVENTS, WPARAM(&tmp), 0);
 
 		Window_SetIcon_IcoLib(m_hwnd, g_plugin.getIconHandle(ICO_NEWSTORY));
 
@@ -562,11 +562,11 @@ public:
 		SendMessage(ibMessages.hwndIcoIn, BM_SETIMAGE, IMAGE_ICON, (LPARAM)g_plugin.getIcon(ICO_MSGIN));
 		SendMessage(ibMessages.hwndIcoOut, BM_SETIMAGE, IMAGE_ICON, (LPARAM)g_plugin.getIcon(ICO_MSGOUT));
 		
-		SendMessage(ibFiles.hwndIco, STM_SETICON, (LPARAM)g_plugin.getIcon(ICO_FILE), 0);
+		SendMessage(ibFiles.hwndIco, STM_SETICON, (LPARAM)Skin_LoadIcon(SKINICON_EVENT_FILE), 0);
 		SendMessage(ibFiles.hwndIcoIn, BM_SETIMAGE, IMAGE_ICON, (LPARAM)g_plugin.getIcon(ICO_MSGIN));
 		SendMessage(ibFiles.hwndIcoOut, BM_SETIMAGE, IMAGE_ICON, (LPARAM)g_plugin.getIcon(ICO_MSGOUT));
 		
-		SendMessage(ibUrls.hwndIco, STM_SETICON, (LPARAM)g_plugin.getIcon(ICO_URL), 0);
+		SendMessage(ibUrls.hwndIco, STM_SETICON, (LPARAM)Skin_LoadIcon(SKINICON_EVENT_URL), 0);
 		SendMessage(ibUrls.hwndIcoIn, BM_SETIMAGE, IMAGE_ICON, (LPARAM)g_plugin.getIcon(ICO_MSGIN));
 		SendMessage(ibUrls.hwndIcoOut, BM_SETIMAGE, IMAGE_ICON, (LPARAM)g_plugin.getIcon(ICO_MSGOUT));
 		
diff --git a/plugins/NewStory/src/history_control.cpp b/plugins/NewStory/src/history_control.cpp
index f19f4565db..36ecde6e4a 100644
--- a/plugins/NewStory/src/history_control.cpp
+++ b/plugins/NewStory/src/history_control.cpp
@@ -385,7 +385,7 @@ struct NewstoryListData : public MZeroedObject
 		SIZE sz;
 		sz.cx = width - 6;
 		HFONT hfnt = (HFONT)SelectObject(hdc, g_fontTable[fontid].hfnt);
-		MTextMeasure(hdc, &sz, (HANDLE)item->data);
+		MTextMeasure(hdc, &sz, item->data);
 		SelectObject(hdc, hfnt);
 		int height = sz.cy + 5;
 
@@ -403,7 +403,7 @@ struct NewstoryListData : public MZeroedObject
 		pos.x = 3;
 		pos.y = top + 2;
 		hfnt = (HFONT)SelectObject(hdc, g_fontTable[fontid].hfnt);
-		MTextDisplay(hdc, pos, sz, (HANDLE)item->data);
+		MTextDisplay(hdc, pos, sz, item->data);
 		SelectObject(hdc, hfnt);
 
 		DeleteObject(hbr);
@@ -752,8 +752,7 @@ LRESULT CALLBACK NewstoryListWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM
 					RECT rc2;
 					SetRect(&rc2, 0, top, width, height);
 
-					HBRUSH hbr;
-					hbr = CreateSolidBrush(g_colorTable[COLOR_BACK].cl);
+					HBRUSH hbr = CreateSolidBrush(g_colorTable[COLOR_BACK].cl);
 					FillRect(hdc, &rc2, hbr);
 					DeleteObject(hbr);
 				}
diff --git a/plugins/NewStory/src/main.cpp b/plugins/NewStory/src/main.cpp
index c2dc1000ae..e090402bdc 100644
--- a/plugins/NewStory/src/main.cpp
+++ b/plugins/NewStory/src/main.cpp
@@ -59,8 +59,6 @@ static IconItem icons[] =
 	{ LPGEN("Incoming message"),  "msgin",     ICO_MSGIN      },
 	{ LPGEN("Outgoing message"),  "msgout",    ICO_MSGOUT     },
 	{ LPGEN("User signed in"),    "signin",    ICO_SIGNIN     },
-	{ LPGEN("File"),              "file",      ICO_FILE       },
-	{ LPGEN("URL"),               "url",       ICO_URL        },
 	{ LPGEN("Unknown event"),     "unknown",   ICO_UNKNOWN    },
 
 	{ LPGEN("Find previous"),     "findprev",  ICO_FINDPREV   },
diff --git a/plugins/NewStory/src/options.cpp b/plugins/NewStory/src/options.cpp
index 30b4c314ad..f5306862bd 100644
--- a/plugins/NewStory/src/options.cpp
+++ b/plugins/NewStory/src/options.cpp
@@ -120,7 +120,7 @@ public:
 			tvis.hInsertAfter = TVI_LAST;
 			tvis.item.mask = TVIF_TEXT | TVIF_PARAM | TVIF_IMAGE | TVIF_SELECTEDIMAGE;
 			tvis.item.pszText = TranslateW(it.title);
-			tvis.item.iSelectedImage = tvis.item.iImage = ImageList_AddIcon(himgTree, g_plugin.getIcon(it.icon));
+			tvis.item.iSelectedImage = tvis.item.iImage = ImageList_AddIcon(himgTree, it.getIcon());
 			tvis.item.lParam = (LPARAM)&it;
 			m_tree.InsertItem(&tvis);
 
diff --git a/plugins/NewStory/src/resource.h b/plugins/NewStory/src/resource.h
index a8ec88878a..160a52f51d 100644
--- a/plugins/NewStory/src/resource.h
+++ b/plugins/NewStory/src/resource.h
@@ -20,8 +20,6 @@
 #define ICO_MSGIN                       116
 #define ICO_MSGOUT                      117
 #define ICO_SIGNIN                      118
-#define ICO_FILE                        119
-#define ICO_URL                         120
 #define ICO_UNKNOWN                     121
 #define ICO_FINDPREV                    122
 #define ICO_FINDNEXT                    123
diff --git a/plugins/NewStory/src/templates.cpp b/plugins/NewStory/src/templates.cpp
index e5fd6c6729..82b3244d91 100644
--- a/plugins/NewStory/src/templates.cpp
+++ b/plugins/NewStory/src/templates.cpp
@@ -169,7 +169,7 @@ void vfEvent(int, TemplateVars *vars, MCONTACT, ItemData *item)
 		hIcon = g_plugin.getIcon(ICO_SENDMSG);
 		break;
 	case EVENTTYPE_FILE:
-		hIcon = g_plugin.getIcon(ICO_FILE);
+		hIcon = Skin_LoadIcon(SKINICON_EVENT_FILE);
 		break;
 	case EVENTTYPE_STATUSCHANGE:
 		hIcon = g_plugin.getIcon(ICO_SIGNIN);
@@ -301,6 +301,11 @@ void vfOther(int, TemplateVars *vars, MCONTACT, ItemData *)
 
 /////////////////////////////////////////////////////////////////////////////////////////
 
+HICON TemplateInfo::getIcon() const
+{
+	return (iIcon < 0) ? Skin_LoadIcon(-iIcon) : g_plugin.getIcon(iIcon);
+}
+
 TemplateInfo templates[TPL_COUNT] =
 {
 	{ "tpl/interface/title", LPGENW("Interface"), ICO_NEWSTORY, LPGENW("Window title"),
@@ -313,7 +318,7 @@ TemplateInfo templates[TPL_COUNT] =
 	{ "tpl/msglog/msg_grp", LPGENW("Message log"), ICO_SENDMSG, LPGENW("Grouped messages"),
 		L"%I%i[b]%t:[/b] %M", 0, 0,
 		{ vfGlobal, vfContact, vfEvent, vfMessage, 0 } },
-	{ "tpl/msglog/file", LPGENW("Message log"), ICO_FILE, LPGENW("Files"),
+	{ "tpl/msglog/file", LPGENW("Message log"), -SKINICON_EVENT_FILE, LPGENW("Files"),
 		L"%I%i[b]%N, %t:[/b]%n%M", 0, 0,
 		{ vfGlobal, vfContact, vfEvent, vfFile, 0 } },
 	{ "tpl/msglog/status", LPGENW("Message log"), ICO_SIGNIN, LPGENW("Status changes"),
@@ -339,10 +344,10 @@ TemplateInfo templates[TPL_COUNT] =
 	{ "tpl/copy/msg", LPGENW("Clipboard"), ICO_SENDMSG, LPGENW("Messages"),
 		L"%N, %t:\x0d\x0a%M%n", 0, 0,
 		{ vfGlobal, vfContact, vfEvent, vfMessage, 0 } },
-	{ "tpl/copy/file", LPGENW("Clipboard"), ICO_FILE, LPGENW("Files"),
+	{ "tpl/copy/file", LPGENW("Clipboard"), -SKINICON_EVENT_FILE, LPGENW("Files"),
 		L"%N, %t:\x0d\x0a%M%n", 0, 0,
 		{ vfGlobal, vfContact, vfEvent, vfFile, 0 } },
-	{ "tpl/copy/url", LPGENW("Clipboard"), ICO_URL, LPGENW("URLs"),
+	{ "tpl/copy/url", LPGENW("Clipboard"), -SKINICON_EVENT_URL, LPGENW("URLs"),
 		L"%N, %t:\x0d\x0a%M%n", 0, 0,
 		{ vfGlobal, vfContact, vfEvent, vfUrl, 0 } },
 	{ "tpl/copy/status", LPGENW("Clipboard"), ICO_SIGNIN, LPGENW("Status changes"),
diff --git a/plugins/NewStory/src/templates.h b/plugins/NewStory/src/templates.h
index b1542bd607..4349ea79d5 100644
--- a/plugins/NewStory/src/templates.h
+++ b/plugins/NewStory/src/templates.h
@@ -30,14 +30,16 @@ struct TemplateInfo
 {
 	enum { VF_COUNT = 6 };
 
-	char* setting;
+	char*    setting;
 	wchar_t* group;
-	int  icon;
+	int      iIcon;
 	wchar_t* title;
 	wchar_t* defvalue;
 	wchar_t* value;
 	wchar_t* tmpValue;
 	VarFunc vf[VF_COUNT];
+
+	HICON getIcon() const;
 };
 
 enum
-- 
cgit v1.2.3