diff options
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/NewStory/src/history.cpp | 2 | ||||
-rw-r--r-- | plugins/NewStory/src/history_array.cpp | 16 | ||||
-rw-r--r-- | plugins/NewStory/src/history_array.h | 2 | ||||
-rw-r--r-- | plugins/NewStory/src/history_control.cpp | 56 | ||||
-rw-r--r-- | plugins/NewStory/src/history_control.h | 13 | ||||
-rw-r--r-- | plugins/NewStory/src/history_log.cpp | 11 | ||||
-rw-r--r-- | plugins/NewStory/src/msglog.cpp | 220 |
7 files changed, 67 insertions, 253 deletions
diff --git a/plugins/NewStory/src/history.cpp b/plugins/NewStory/src/history.cpp index 9496d3e5c0..b55c9318ce 100644 --- a/plugins/NewStory/src/history.cpp +++ b/plugins/NewStory/src/history.cpp @@ -560,7 +560,7 @@ public: } if (m_hContact != INVALID_CONTACT_ID) - PostMessage(m_histControl.GetHwnd(), WM_USER, m_hContact, 0); + PostMessage(m_histControl.GetHwnd(), NSM_ADDHISTORY, m_hContact, 0); Window_SetIcon_IcoLib(m_hwnd, g_plugin.getIconHandle(ICO_NEWSTORY)); diff --git a/plugins/NewStory/src/history_array.cpp b/plugins/NewStory/src/history_array.cpp index 96f79184c3..0a2304ea56 100644 --- a/plugins/NewStory/src/history_array.cpp +++ b/plugins/NewStory/src/history_array.cpp @@ -134,13 +134,17 @@ bool HistoryArray::addHistory(MCONTACT hContact, EventLoadMode) return true; } -bool HistoryArray::addEvent(MCONTACT hContact, MEVENT hEvent, EventLoadMode mode) +bool HistoryArray::addEvent(MCONTACT hContact, MEVENT hEvent, int count, EventLoadMode mode) { - allocateBlock(1); - tail->items[0].hContact = hContact; - tail->items[0].hEvent = hEvent; - if (mode != ELM_NOTHING) - tail->items[0].load(mode); + allocateBlock(count); + + for (int i = 0; i < count; i++) { + tail->items[i].hContact = hContact; + tail->items[i].hEvent = hEvent; + if (mode != ELM_NOTHING) + tail->items[i].load(mode); + hEvent = db_event_next(hContact, hEvent); + } return true; } diff --git a/plugins/NewStory/src/history_array.h b/plugins/NewStory/src/history_array.h index 53dea911a4..3141c3146f 100644 --- a/plugins/NewStory/src/history_array.h +++ b/plugins/NewStory/src/history_array.h @@ -166,7 +166,7 @@ public: void clear(); bool addHistory(MCONTACT hContact, EventLoadMode mode = ELM_NOTHING); - bool addEvent(MCONTACT hContact, MEVENT hEvent, EventLoadMode mode = ELM_NOTHING); + bool addEvent(MCONTACT hContact, MEVENT hEvent, int count, EventLoadMode mode = ELM_NOTHING); // bool preloadEvents(int count = 10); diff --git a/plugins/NewStory/src/history_control.cpp b/plugins/NewStory/src/history_control.cpp index da8dcecd5b..bfebfb4600 100644 --- a/plugins/NewStory/src/history_control.cpp +++ b/plugins/NewStory/src/history_control.cpp @@ -39,33 +39,30 @@ static LRESULT CALLBACK HistoryEditWndProc(HWND hwnd, UINT msg, WPARAM wParam, L { switch (msg) { case WM_KEYDOWN: - { - switch (wParam) { - case VK_ESCAPE: - { - EndEditItem(GetParent(hwnd), (NewstoryListData *)GetWindowLongPtr(GetParent(hwnd), 0)); - return 0; - } + switch (wParam) { + case VK_ESCAPE: + { + EndEditItem(GetParent(hwnd), (NewstoryListData *)GetWindowLongPtr(GetParent(hwnd), 0)); + return 0; } - break; } + break; + case WM_GETDLGCODE: - { - if (lParam) { - MSG *msg2 = (MSG *)lParam; - if (msg2->message == WM_KEYDOWN && msg2->wParam == VK_TAB) - return 0; - if (msg2->message == WM_CHAR && msg2->wParam == '\t') - return 0; - } - return DLGC_WANTMESSAGE; + if (lParam) { + MSG *msg2 = (MSG *)lParam; + if (msg2->message == WM_KEYDOWN && msg2->wParam == VK_TAB) + return 0; + if (msg2->message == WM_CHAR && msg2->wParam == '\t') + return 0; } - // case WM_KILLFOCUS: - // { - // EndEditItem(GetParent(hwnd), (NewstoryListData *)GetWindowLong(GetParent(hwnd), 0)); - // return 0; - // } + return DLGC_WANTMESSAGE; + + case WM_KILLFOCUS: + EndEditItem(GetParent(hwnd), (NewstoryListData *)GetWindowLong(GetParent(hwnd), 0)); + return 0; } + return CallWindowProc(OldEditWndProc, hwnd, msg, wParam, lParam); } @@ -453,7 +450,8 @@ LRESULT CALLBACK NewstoryListWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM RecalcScrollBar(hwnd, data); break; - case WM_USER: + // History list control messages + case NSM_ADDHISTORY: data->items.addHistory((MCONTACT)wParam); RecalcScrollBar(hwnd, data); data->scrollTopItem = data->items.getCount(); @@ -461,7 +459,17 @@ LRESULT CALLBACK NewstoryListWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM InvalidateRect(hwnd, 0, FALSE); break; - // History list control messages + case NSM_ADDEVENTS: + { + auto *p = (ADDEVENTS *)wParam; + data->items.addEvent(p->hContact, p->hFirstEVent, p->eventCount); + } + RecalcScrollBar(hwnd, data); + data->scrollTopItem = data->items.getCount(); + FixScrollPosition(hwnd, data); + InvalidateRect(hwnd, 0, FALSE); + break; + case NSM_GETCOUNT: return data->items.getCount(); diff --git a/plugins/NewStory/src/history_control.h b/plugins/NewStory/src/history_control.h index f17da39fdb..934da14054 100644 --- a/plugins/NewStory/src/history_control.h +++ b/plugins/NewStory/src/history_control.h @@ -3,6 +3,13 @@ #define NEWSTORYLIST_CLASS "NewstoryList" +struct ADDEVENTS +{ + MCONTACT hContact; + MEVENT hFirstEVent; + int eventCount; +}; + enum { NSM_FIRST = WM_USER + 100, @@ -36,6 +43,12 @@ enum // result = id NSM_GETITEMFROMPIXEL, + // add history for a contact + NSM_ADDHISTORY, + + // add one or more events + NSM_ADDEVENTS, + // wParam = id NSM_SETCARET, diff --git a/plugins/NewStory/src/history_log.cpp b/plugins/NewStory/src/history_log.cpp index 779ef66ade..0fb7b1134b 100644 --- a/plugins/NewStory/src/history_log.cpp +++ b/plugins/NewStory/src/history_log.cpp @@ -12,7 +12,7 @@ public: void Attach() override { - m_hwnd = ::CreateWindowW(_T(NEWSTORYLIST_CLASS), L"", WS_TABSTOP, 0, 0, 300, 150, m_pDlg.GetHwnd(), (HMENU)IDC_SRMM_LOG, m_pDlg.GetInst(), 0); + m_hwnd = ::CreateWindow(_T(NEWSTORYLIST_CLASS), L"NewStory", WS_VISIBLE | WS_CHILD | WS_TABSTOP, 0, 0, 300, 150, m_pDlg.GetHwnd(), 0, m_pDlg.GetInst(), 0); } void Detach() override @@ -48,6 +48,11 @@ public: void LogEvents(MEVENT hDbEventFirst, int count, bool bAppend) override { + if (count != -1) { + ADDEVENTS tmp = { m_pDlg.m_hContact, hDbEventFirst, count }; + SendMessage(m_hwnd, NSM_ADDEVENTS, (LPARAM)&tmp, 0); + } + else SendMessage(m_hwnd, NSM_ADDHISTORY, m_pDlg.m_hContact, 0); } void LogEvents(DBEVENTINFO *dbei_s, bool bAppend) @@ -60,6 +65,10 @@ public: void Resize() override { + RECT rc; + GetClientRect(GetDlgItem(m_pDlg.GetHwnd(), IDC_SRMM_LOG), &rc); + + ::SetWindowPos(m_hwnd, 0, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, SWP_NOACTIVATE | SWP_NOZORDER); } void ScrollToBottom() override diff --git a/plugins/NewStory/src/msglog.cpp b/plugins/NewStory/src/msglog.cpp deleted file mode 100644 index f818dd4b2b..0000000000 --- a/plugins/NewStory/src/msglog.cpp +++ /dev/null @@ -1,220 +0,0 @@ -#include "stdafx.h" - -///////////////////////////////////////////////////////////////////////////////////////// -// CNewStoryLogWindow class - -class CNewStoryLogWindow : public CSrmmLogWindow -{ - HWND m_hwnd = nullptr; - -public: - CNewStoryLogWindow(CMsgDialog& pDlg) : - CSrmmLogWindow(pDlg) - { - } - - void Attach() override - { - /*IEVIEWWINDOW ieWindow = {}; - ieWindow.iType = IEW_CREATE; - ieWindow.dwMode = IEWM_TABSRMM; - ieWindow.parent = m_pDlg.GetHwnd(); - ieWindow.cx = 200; - ieWindow.cy = 200; - CallService(MS_IEVIEW_WINDOW, 0, (LPARAM)&ieWindow); - m_hwnd = ieWindow.hwnd;*/ - } - - void Detach() override - { - /*IEVIEWWINDOW ieWindow = {}; - ieWindow.iType = IEW_DESTROY; - ieWindow.hwnd = m_hwnd; - CallService(MS_IEVIEW_WINDOW, 0, (LPARAM)&ieWindow);*/ - } - - ////////////////////////////////////////////////////////////////////////////////////// - - bool AtBottom() override - { - return false; - } - - void Clear() override - { - /*IEVIEWEVENT event = {}; - event.iType = IEE_CLEAR_LOG; - event.hwnd = m_hwnd; - CallService(MS_IEVIEW_EVENT, 0, (LPARAM) & event);*/ - } - - HWND GetHwnd() override - { - return m_hwnd; - } - - wchar_t* GetSelection() override - { - return (wchar_t*)1; - /*IEVIEWEVENT event = {}; - event.hwnd = m_hwnd; - event.iType = IEE_GET_SELECTION; - event.hContact = m_pDlg.m_hContact; - return (wchar_t*)CallService(MS_IEVIEW_EVENT, 0, (LPARAM) & event);*/ - } - - int GetType() override - { - return 1; - } - - void LogEvents(MEVENT hDbEventFirst, int count, bool bAppend) override - { - /*if (!bAppend) - Clear(); - - IEVIEWEVENT event = {}; - event.iType = IEE_LOG_DB_EVENTS; - event.hwnd = m_hwnd; - event.hDbEventFirst = hDbEventFirst; - event.hContact = m_pDlg.m_hContact; - event.count = count; - CallService(MS_IEVIEW_EVENT, 0, (LPARAM) & event);*/ - } - - void CNewStoryLogWindow::LogEvents(DBEVENTINFO* dbei_s, bool bAppend) - { - if (dbei_s == nullptr) - return; - - /*if (!bAppend) - Clear(); - - IEVIEWEVENT event = {}; - event.hwnd = m_hwnd; - event.iType = IEE_LOG_MEM_EVENTS; - event.count = 1; - - IEVIEWEVENTDATA evData = {}; - if (dbei_s->flags & DBEF_SENT) { - evData.dwFlags = IEEDF_SENT; - evData.bIsMe = true; - } - else { - evData.dwFlags = IEEDF_UNICODE_NICK; - evData.szNick.w = Clist_GetContactDisplayName(m_pDlg.m_hContact); - } - switch (dbei_s->eventType) { - case EVENTTYPE_STATUSCHANGE: evData.iType = IEED_EVENT_STATUSCHANGE; break; - case EVENTTYPE_FILE: evData.iType = IEED_EVENT_FILE; break; - case EVENTTYPE_ERRMSG: evData.iType = IEED_EVENT_ERRMSG; break; - default: evData.iType = IEED_EVENT_MESSAGE; break; - } - evData.szText.a = (char*)dbei_s->pBlob; - evData.time = dbei_s->timestamp; - event.eventData = &evData; - event.codepage = CP_UTF8; - CallService(MS_IEVIEW_EVENT, 0, (LPARAM) & event);*/ - } - - void LogEvents(LOGINFO* pLog, bool) override - { - /*IEVIEWEVENTDATA ied = {}; - ied.dwFlags = IEEDF_UNICODE_NICK; - - IEVIEWEVENT event = {}; - event.hwnd = m_hwnd; - event.hContact = m_pDlg.m_hContact; - event.codepage = CP_UTF8; - event.iType = IEE_LOG_MEM_EVENTS; - event.eventData = &ied; - event.count = 1; - - while (pLog) { - T2Utf szText(pLog->ptszText); - ied.szNick.w = pLog->ptszNick; - ied.szText.a = szText; - ied.time = pLog->time; - ied.bIsMe = pLog->bIsMe; - - switch (pLog->iType) { - case GC_EVENT_MESSAGE: - ied.iType = IEED_GC_EVENT_MESSAGE; - ied.dwData = IEEDD_GC_SHOW_NICK; - break; - case GC_EVENT_ACTION: - ied.iType = IEED_GC_EVENT_ACTION; - break; - case GC_EVENT_JOIN: - ied.iType = IEED_GC_EVENT_JOIN; - break; - case GC_EVENT_PART: - ied.iType = IEED_GC_EVENT_PART; - break; - case GC_EVENT_QUIT: - ied.iType = IEED_GC_EVENT_QUIT; - break; - case GC_EVENT_NICK: - ied.iType = IEED_GC_EVENT_NICK; - break; - case GC_EVENT_KICK: - ied.iType = IEED_GC_EVENT_KICK; - break; - case GC_EVENT_NOTICE: - ied.iType = IEED_GC_EVENT_NOTICE; - break; - case GC_EVENT_TOPIC: - ied.iType = IEED_GC_EVENT_TOPIC; - break; - case GC_EVENT_INFORMATION: - ied.iType = IEED_GC_EVENT_INFORMATION; - break; - case GC_EVENT_ADDSTATUS: - ied.iType = IEED_GC_EVENT_ADDSTATUS; - break; - case GC_EVENT_REMOVESTATUS: - ied.iType = IEED_GC_EVENT_REMOVESTATUS; - break; - } - - ied.dwData |= IEEDD_GC_SHOW_TIME | IEEDD_GC_SHOW_ICON; - ied.dwFlags = IEEDF_UNICODE_TEXT | IEEDF_UNICODE_NICK | IEEDF_UNICODE_TEXT2; - CallService(MS_IEVIEW_EVENT, 0, (LPARAM) & event); - - pLog = pLog->prev; - }*/ - } - - void Resize() override - { - /*RECT rcRichEdit; - GetWindowRect(GetDlgItem(m_pDlg.GetHwnd(), IDC_SRMM_LOG), &rcRichEdit); - - POINT pt = { rcRichEdit.left, rcRichEdit.top }; - ScreenToClient(GetParent(m_hwnd), &pt); - - IEVIEWWINDOW ieWindow = { sizeof(ieWindow) }; - ieWindow.iType = IEW_SETPOS; - ieWindow.parent = m_hwnd; - ieWindow.hwnd = m_hwnd; - ieWindow.x = pt.x; - ieWindow.y = pt.y; - ieWindow.cx = rcRichEdit.right - rcRichEdit.left; - ieWindow.cy = rcRichEdit.bottom - rcRichEdit.top; - if (ieWindow.cx != 0 && ieWindow.cy != 0) - CallService(MS_IEVIEW_WINDOW, 0, (LPARAM)&ieWindow);*/ - } - - void ScrollToBottom() override - { - /*IEVIEWWINDOW iew = { sizeof(iew) }; - iew.iType = IEW_SCROLLBOTTOM; - iew.hwnd = m_hwnd; - CallService(MS_IEVIEW_WINDOW, 0, (LPARAM)&iew);*/ - } -}; - -CSrmmLogWindow *logBuilder(CMsgDialog &pDlg) -{ - return new CNewStoryLogWindow(pDlg); -} |