summaryrefslogtreecommitdiff
path: root/plugins/NewStory/src/history_control.cpp
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2023-07-29 13:19:57 +0300
committerGeorge Hazan <george.hazan@gmail.com>2023-07-29 13:19:57 +0300
commita63fdd451d23aa5d4b33c1bcf3540bea411f3358 (patch)
tree58611d7ffb4d32adfd9aa308026f479b27309f72 /plugins/NewStory/src/history_control.cpp
parent65b8ac5da658208d9b8540eaa39299283ea99d04 (diff)
NewStory: event is redrawn when ME_DB_EVENT_EDITED is fired + code cleaning
Diffstat (limited to 'plugins/NewStory/src/history_control.cpp')
-rw-r--r--plugins/NewStory/src/history_control.cpp46
1 files changed, 36 insertions, 10 deletions
diff --git a/plugins/NewStory/src/history_control.cpp b/plugins/NewStory/src/history_control.cpp
index 1a38dce3e5..4e723dfa1c 100644
--- a/plugins/NewStory/src/history_control.cpp
+++ b/plugins/NewStory/src/history_control.cpp
@@ -328,6 +328,12 @@ void NewstoryListData::RecalcScrollBar()
SetScrollInfo(hwnd, SB_VERT, &si, TRUE);
}
+void NewstoryListData::ScheduleDraw()
+{
+ redrawTimer.Stop();
+ redrawTimer.Start(100);
+}
+
void NewstoryListData::ScrollListBy(int scrollItems, int scrollPixels)
{
if (scrollItems) {
@@ -428,16 +434,12 @@ LRESULT CALLBACK NewstoryListWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM
case NSM_ADDEVENTS:
if (auto *p = (ADDEVENTS *)wParam)
data->items.addEvent(p->hContact, p->hFirstEVent, p->eventCount);
-
- data->redrawTimer.Stop();
- data->redrawTimer.Start(100);
+ data->ScheduleDraw();
break;
case NSM_ADDCHATEVENT:
data->items.addChatEvent((SESSION_INFO *)wParam, (LOGINFO *)lParam);
-
- data->redrawTimer.Stop();
- data->redrawTimer.Start(100);
+ data->ScheduleDraw();
break;
case NSM_CLEAR:
@@ -512,7 +514,7 @@ LRESULT CALLBACK NewstoryListWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM
int end = min(data->items.getCount() - 1, max(0, lParam));
if (start > end)
std::swap(start, end);
-
+
for (int i = start; i <= end; ++i) {
auto *p = data->items.get(i, false);
p->m_bSelected = false;
@@ -580,6 +582,11 @@ LRESULT CALLBACK NewstoryListWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM
case NSM_SET_SRMM:
data->pMsgDlg = (CSrmmBaseDialog *)lParam;
+ lParam = data->pMsgDlg->m_hContact;
+ __fallthrough;
+
+ case NSM_SET_CONTACT:
+ WindowList_Add(g_hNewstoryLogs, hwnd, lParam);
break;
case NSM_COPY:
@@ -595,8 +602,26 @@ LRESULT CALLBACK NewstoryListWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM
Utils_ClipboardCopy(res);
}
- __fallthrough;
- // End of history list control messages
+ InvalidateRect(hwnd, 0, FALSE);
+ break;
+
+ case UM_EDITEVENT:
+ idx = data->items.find(lParam);
+ if (idx != -1) {
+ auto *p = data->items[idx];
+ p->load(true);
+ p->setText();
+ data->ScheduleDraw();
+ }
+ break;
+
+ case UM_REMOVEEVENT:
+ idx = data->items.find(lParam);
+ if (idx != -1) {
+ data->items.remove(idx);
+ data->ScheduleDraw();
+ }
+ break;
case WM_SIZE:
InvalidateRect(hwnd, 0, FALSE);
@@ -900,10 +925,11 @@ LRESULT CALLBACK NewstoryListWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM
if (s_scrollTopItem != data->scrollTopItem || s_scrollTopPixel != data->scrollTopPixel)
InvalidateRect(hwnd, 0, FALSE);
- break;
}
+ break;
case WM_DESTROY:
+ WindowList_Add(g_hNewstoryLogs, hwnd);
delete data;
SetWindowLongPtr(hwnd, 0, 0);
break;