diff options
author | George Hazan <george.hazan@gmail.com> | 2023-12-14 16:41:43 +0300 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2023-12-14 16:41:43 +0300 |
commit | 5fee2a9dfbe21f329c0955328606c69560129672 (patch) | |
tree | 958e21213f8cb27ff9275e7f4e8cf675cb66f64c | |
parent | 054bb1949247445a29a68812579800904edf6a02 (diff) |
fixes #3781 (Newstory: Problems with scrolling, and crash)
-rw-r--r-- | plugins/NewStory/src/history_array.cpp | 3 | ||||
-rw-r--r-- | plugins/NewStory/src/history_control.cpp | 55 | ||||
-rw-r--r-- | plugins/NewStory/src/stdafx.h | 1 | ||||
-rw-r--r-- | plugins/NewStory/src/templates.cpp | 57 | ||||
-rw-r--r-- | plugins/NewStory/src/utils.cpp | 5 | ||||
-rw-r--r-- | plugins/NewStory/src/utils.h | 2 |
6 files changed, 68 insertions, 55 deletions
diff --git a/plugins/NewStory/src/history_array.cpp b/plugins/NewStory/src/history_array.cpp index 30ce49af66..3eb986cd88 100644 --- a/plugins/NewStory/src/history_array.cpp +++ b/plugins/NewStory/src/history_array.cpp @@ -406,9 +406,6 @@ void ItemData::load(bool bFullLoad) if (uint32_t size = blob.getSize()) buf.AppendFormat(TranslateT(" %u KB"), size < 1024 ? 1 : unsigned(blob.getSize() / 1024)); - if (blob.getSize() > 0 && blob.getSize() == blob.getTransferred()) - buf.AppendFormat(L" [$hicon=%p$]", g_plugin.getIcon(IDI_OK)); - wtext = buf.Detach(); markRead(); break; diff --git a/plugins/NewStory/src/history_control.cpp b/plugins/NewStory/src/history_control.cpp index 600f0a9c14..10b446d7f1 100644 --- a/plugins/NewStory/src/history_control.cpp +++ b/plugins/NewStory/src/history_control.cpp @@ -590,25 +590,66 @@ int NewstoryListData::PaintItem(HDC hdc, int index, int top, int width) item->checkCreate(m_hwnd); SIZE sz; - sz.cx = width - 6; + sz.cx = width - 2; + + POINT pos; + pos.x = 38; + pos.y = top + 2; + + // Bookmark icon + if (item->dbe.flags & DBEF_BOOKMARK) + pos.x += 18; + + sz.cx -= pos.x; + if (item->m_bOfflineDownloaded) + sz.cx -= 18; + HFONT hfnt = (HFONT)SelectObject(hdc, g_fontTable[fontid].hfnt); MTextMeasure(hdc, &sz, item->data); SelectObject(hdc, hfnt); - int height = sz.cy + 5; - RECT rc; - SetRect(&rc, 0, top, width, top + height); + int height = sz.cy + 5; HBRUSH hbr = CreateSolidBrush(clBack); + RECT rc = { 0, top, width, top + height }; FillRect(hdc, &rc, hbr); DeleteObject(hbr); SetTextColor(hdc, clText); SetBkMode(hdc, TRANSPARENT); - POINT pos; - pos.x = 3; - pos.y = top + 2; + HICON hIcon; + switch (item->dbe.eventType) { + case EVENTTYPE_MESSAGE: + hIcon = g_plugin.getIcon(IDI_SENDMSG); + break; + case EVENTTYPE_FILE: + hIcon = Skin_LoadIcon(SKINICON_EVENT_FILE); + break; + case EVENTTYPE_STATUSCHANGE: + hIcon = g_plugin.getIcon(IDI_SIGNIN); + break; + default: + hIcon = g_plugin.getIcon(IDI_UNKNOWN); + break; + } + DrawIconEx(hdc, 2, pos.y, hIcon, 16, 16, 0, 0, DI_NORMAL); + + // Direction icon + if (item->dbe.flags & DBEF_SENT) + hIcon = g_plugin.getIcon(IDI_MSGOUT); + else + hIcon = g_plugin.getIcon(IDI_MSGIN); + DrawIconEx(hdc, 20, pos.y, hIcon, 16, 16, 0, 0, DI_NORMAL); + + // Bookmark icon + if (item->dbe.flags & DBEF_BOOKMARK) + DrawIconEx(hdc, 38, pos.y, g_plugin.getIcon(IDI_BOOKMARK), 16, 16, 0, 0, DI_NORMAL); + + // Finished icon + if (item->m_bOfflineDownloaded) + DrawIconEx(hdc, width-20, pos.y, g_plugin.getIcon(IDI_OK), 16, 16, 0, 0, DI_NORMAL); + hfnt = (HFONT)SelectObject(hdc, g_fontTable[fontid].hfnt); MTextDisplay(hdc, pos, sz, item->data); SelectObject(hdc, hfnt); diff --git a/plugins/NewStory/src/stdafx.h b/plugins/NewStory/src/stdafx.h index 5243753580..718f05d90f 100644 --- a/plugins/NewStory/src/stdafx.h +++ b/plugins/NewStory/src/stdafx.h @@ -108,3 +108,4 @@ struct CMPlugin : public PLUGIN<CMPlugin> extern CMOption<bool> g_bOptGrouping, g_bOptDrawEdge, g_bOptHppCompat; extern wchar_t* months[12]; +extern int g_iPixelY; diff --git a/plugins/NewStory/src/templates.cpp b/plugins/NewStory/src/templates.cpp index 952fddeb3b..8cc5eb3aff 100644 --- a/plugins/NewStory/src/templates.cpp +++ b/plugins/NewStory/src/templates.cpp @@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #include "stdafx.h" -static int g_iPixelY; +int g_iPixelY; wchar_t *weekDays[7] = { LPGENW("Sunday"), LPGENW("Monday"), LPGENW("Tuesday"), LPGENW("Wednesday"), LPGENW("Thursday"), LPGENW("Friday"), LPGENW("Saturday") }; @@ -108,7 +108,7 @@ CMStringA ItemData::formatRtf(const wchar_t *pwszStr) cr = g_colorTable[(dbe.flags & DBEF_SENT) ? COLOR_OUTNICK : COLOR_INNICK].cl; buf.AppendFormat("\\red%u\\green%u\\blue%u;}", GetRValue(cr), GetGValue(cr), GetBValue(cr)); - buf.AppendFormat("\\uc1\\pard \\cf0\\f0\\b0\\i0\\fs%d ", 2 * abs(F.lf.lfHeight) * 74 / g_iPixelY); + buf.AppendFormat("\\uc1\\pard \\cf0\\f0\\b0\\i0\\fs%d ", GetFontHeight(F.lf)); AppendUnicodeToBuffer(buf, (pwszStr) ? pwszStr : formatString()); buf.Append("}"); @@ -235,7 +235,6 @@ void vfSystem(TemplateVars *vars, MCONTACT hContact, ItemData *) void vfEvent(TemplateVars *vars, MCONTACT, ItemData *item) { - HICON hIcon; wchar_t buf[100]; // %N: Nickname @@ -252,38 +251,6 @@ void vfEvent(TemplateVars *vars, MCONTACT, ItemData *item) vars->SetNick(nick); } - // %I: Icon - switch (item->dbe.eventType) { - case EVENTTYPE_MESSAGE: - hIcon = g_plugin.getIcon(IDI_SENDMSG); - break; - case EVENTTYPE_FILE: - hIcon = Skin_LoadIcon(SKINICON_EVENT_FILE); - break; - case EVENTTYPE_STATUSCHANGE: - hIcon = g_plugin.getIcon(IDI_SIGNIN); - break; - default: - hIcon = g_plugin.getIcon(IDI_UNKNOWN); - break; - } - mir_snwprintf(buf, L"[$hicon=%p$]", hIcon); - vars->SetVar('I', buf, true); - - if (item->dbe.flags & DBEF_BOOKMARK) { - mir_snwprintf(buf, L"[$hicon=%p$]", g_plugin.getIcon(IDI_BOOKMARK)); - vars->SetVar('B', buf, true); - } - - // %i: Direction icon - if (item->dbe.flags & DBEF_SENT) - hIcon = g_plugin.getIcon(IDI_MSGOUT); - else - hIcon = g_plugin.getIcon(IDI_MSGIN); - - mir_snwprintf(buf, L"[$hicon=%p$]", hIcon); - vars->SetVar('i', buf, true); - // %D: direction symbol if (item->dbe.flags & DBEF_SENT) vars->SetVar('D', L"<<", false); @@ -424,35 +391,35 @@ TemplateInfo templates[TPL_COUNT] = { vfGlobal, vfContact, 0, 0, 0 } }, { "tpl/msglog/msg", LPGENW("Message log"), IDI_SENDMSG, LPGENW("Messages"), - L"%I%i%B[b]%N, %t:[/b]\r\n%M", 0, 0, + L"[b]%N, %t:[/b]\r\n%M", 0, 0, { vfGlobal, vfContact, vfEvent, vfMessage, 0 } }, { "tpl/msglog/msg_head", LPGENW("Message log"), IDI_SENDMSG, LPGENW("Group head"), - L"%I%i%B[b]%N, %t:[/b] %M", 0, 0, + L"[b]%N, %t:[/b] %M", 0, 0, { vfGlobal, vfContact, vfEvent, vfMessage, 0 } }, { "tpl/msglog/msg_grp", LPGENW("Message log"), IDI_SENDMSG, LPGENW("Grouped messages"), - L"%I%i%B[b]%h:%m:%s:[/b] %M", 0, 0, + L"[b]%h:%m:%s:[/b] %M", 0, 0, { vfGlobal, vfContact, vfEvent, vfMessage, 0 } }, { "tpl/msglog/file", LPGENW("Message log"), -SKINICON_EVENT_FILE, LPGENW("Files"), - L"%I%i%B[b]%N, %t:[/b]%n%M", 0, 0, + L"[b]%N, %t:[/b]%n%M", 0, 0, { vfGlobal, vfContact, vfEvent, vfFile, 0 } }, { "tpl/msglog/status", LPGENW("Message log"), IDI_SIGNIN, LPGENW("Status changes"), - L"%I%i%B[b]%N, %t:[/b]%n%M", 0, 0, + L"[b]%N, %t:[/b]%n%M", 0, 0, { vfGlobal, vfContact, vfEvent, vfSign, 0 } }, { "tpl/msglog/presense", LPGENW("Message log"), IDI_UNKNOWN, LPGENW("Presence requests"), - L"%I%i%B[b]%N, %t:[/b]%n%M", 0, 0, + L"%B[b]%N, %t:[/b]%n%M", 0, 0, { vfGlobal, vfContact, vfEvent, vfPresence, 0 } }, { "tpl/msglog/other", LPGENW("Message log"), IDI_UNKNOWN, LPGENW("Other events"), - L"%I%i%B[b]%N, %t:[/b]%n%M", 0, 0, + L"%B[b]%N, %t:[/b]%n%M", 0, 0, { vfGlobal, vfContact, vfEvent, vfOther, 0 } }, { "tpl/msglog/authrq", LPGENW("Message log"), IDI_UNKNOWN, LPGENW("Authorization requests"), - L"%I%i[b]%N, %t:[/b]%n%M", 0, 0, + L"[b]%N, %t:[/b]%n%M", 0, 0, { vfGlobal, vfEvent, vfSystem, vfAuth, 0 } }, { "tpl/msglog/added", LPGENW("Message log"), IDI_UNKNOWN, LPGENW("'You were added' events"), - L"%I%i[b]%N, %t:[/b]%n%M", 0, 0, + L"[b]%N, %t:[/b]%n%M", 0, 0, { vfGlobal, vfEvent, vfSystem, vfAdded, 0 } }, { "tpl/msglog/deleted", LPGENW("Message log"), IDI_UNKNOWN, LPGENW("'You were deleted' events"), - L"%I%i[b]%N, %t:[/b]%n%M", 0, 0, + L"[b]%N, %t:[/b]%n%M", 0, 0, { vfGlobal, vfEvent, vfSystem, vfDeleted, 0 } }, { "tpl/copy/msg", LPGENW("Clipboard"), IDI_SENDMSG, LPGENW("Messages"), diff --git a/plugins/NewStory/src/utils.cpp b/plugins/NewStory/src/utils.cpp index 3e342e7f0c..4c5b3817a2 100644 --- a/plugins/NewStory/src/utils.cpp +++ b/plugins/NewStory/src/utils.cpp @@ -36,6 +36,11 @@ bool CheckFilter(wchar_t *buf, wchar_t *filter) return false; } +int GetFontHeight(const LOGFONTA &lf) +{ + return 2 * abs(lf.lfHeight) * 74 / g_iPixelY; +} + ///////////////////////////////////////////////////////////////////////////////////////// struct diff --git a/plugins/NewStory/src/utils.h b/plugins/NewStory/src/utils.h index 3842526540..adb479e3f9 100644 --- a/plugins/NewStory/src/utils.h +++ b/plugins/NewStory/src/utils.h @@ -7,4 +7,6 @@ bool CheckFilter(wchar_t *buf, wchar_t *filter); HMENU NSMenu_Build(NewstoryListData *data, ItemData *item); bool NSMenu_Process(int iCommand, NewstoryListData *data); +int GetFontHeight(const LOGFONTA &lf); + void RemoveBbcodes(CMStringW &pwszText); |