From 3b358f31e21e97978db552a2535c056d866b51cf Mon Sep 17 00:00:00 2001 From: George Hazan Date: Thu, 30 Mar 2023 13:29:59 +0300 Subject: massive code cleaning after regression caused by #3210 --- plugins/Scriver/src/msgdialog.cpp | 24 -- plugins/Scriver/src/msglog.cpp | 488 ++++++++++++++++++++----------------- plugins/Scriver/src/msgoptions.cpp | 16 +- plugins/Scriver/src/msgs.cpp | 3 - plugins/Scriver/src/msgs.h | 22 -- plugins/Scriver/src/resource.h | 3 +- plugins/Scriver/src/srmm.cpp | 101 ++++---- plugins/Scriver/src/stdafx.h | 3 +- 8 files changed, 329 insertions(+), 331 deletions(-) (limited to 'plugins/Scriver/src') diff --git a/plugins/Scriver/src/msgdialog.cpp b/plugins/Scriver/src/msgdialog.cpp index 8b9778537f..a3b069b3c4 100644 --- a/plugins/Scriver/src/msgdialog.cpp +++ b/plugins/Scriver/src/msgdialog.cpp @@ -23,8 +23,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "stdafx.h" -LIST g_arDialogs(10, PtrKeySortT); - ///////////////////////////////////////////////////////////////////////////////////////// static CMStringW GetQuotedTextW(wchar_t *text) @@ -140,8 +138,6 @@ CMsgDialog::CMsgDialog(SESSION_INFO *si) : void CMsgDialog::Init() { - g_arDialogs.insert(this); - m_autoClose = CLOSE_ON_CANCEL; m_szProto = Proto_GetBaseAccountName(m_hContact); @@ -284,8 +280,6 @@ void CMsgDialog::OnDestroy() { NotifyEvent(MSG_WINDOW_EVT_CLOSING); - g_arDialogs.remove(this); - if (m_nTypeMode == PROTOTYPE_SELFTYPING_ON) NotifyTyping(PROTOTYPE_SELFTYPING_OFF); @@ -756,24 +750,6 @@ INT_PTR CALLBACK CMsgDialog::FilterWndProc(HWND hwndDlg, UINT uMsg, WPARAM wPara ///////////////////////////////////////////////////////////////////////////////////////// -INT_PTR CLogWindow::WndProc(UINT msg, WPARAM wParam, LPARAM lParam) -{ - int result = m_pDlg.InputAreaShortcuts(m_rtf.GetHwnd(), msg, wParam, lParam); - if (result != -1) - return result; - - switch (msg) { - case WM_MEASUREITEM: - Menu_MeasureItem(lParam); - return TRUE; - - case WM_DRAWITEM: - return Menu_DrawItem(lParam); - } - - return CSuper::WndProc(msg, wParam, lParam); -} - LRESULT CMsgDialog::WndProc_Message(UINT msg, WPARAM wParam, LPARAM lParam) { int result = InputAreaShortcuts(m_message.GetHwnd(), msg, wParam, lParam); diff --git a/plugins/Scriver/src/msglog.cpp b/plugins/Scriver/src/msglog.cpp index 139fd3eef0..6b4b2266b7 100644 --- a/plugins/Scriver/src/msglog.cpp +++ b/plugins/Scriver/src/msglog.cpp @@ -696,262 +696,304 @@ void FreeMsgLogIcons(void) } ///////////////////////////////////////////////////////////////////////////////////////// +// CLogWindow - built-in log window -void CLogWindow::Attach() +class CLogWindow : public CRtfLogWindow { - CSuper::Attach(); - - uint32_t dwExStyle = GetWindowLongPtr(m_rtf.GetHwnd(), GWL_EXSTYLE); - SetWindowLongPtr(m_rtf.GetHwnd(), GWL_EXSTYLE, (m_pDlg.m_bUseRtl) ? dwExStyle | WS_EX_LEFTSCROLLBAR : dwExStyle & ~WS_EX_LEFTSCROLLBAR); - - // Workaround to make Richedit display RTL messages correctly - PARAFORMAT2 pf2; - memset(&pf2, 0, sizeof(pf2)); - pf2.cbSize = sizeof(pf2); - pf2.dwMask = PFM_RTLPARA | PFM_OFFSETINDENT | PFM_RIGHTINDENT; - pf2.wEffects = PFE_RTLPARA; - pf2.dxStartIndent = 30; - pf2.dxRightIndent = 30; - m_rtf.SendMsg(EM_SETPARAFORMAT, 0, (LPARAM)&pf2); - - pf2.dwMask = PFM_RTLPARA; - pf2.wEffects = 0; - m_rtf.SendMsg(EM_SETPARAFORMAT, 0, (LPARAM)&pf2); - - m_rtf.SendMsg(EM_SETEVENTMASK, 0, ENM_MOUSEEVENTS | ENM_LINK | ENM_KEYEVENTS); - m_rtf.SendMsg(EM_SETEDITSTYLE, SES_EXTENDBACKCOLOR, SES_EXTENDBACKCOLOR); - m_rtf.SendMsg(EM_SETLANGOPTIONS, 0, (LPARAM)m_rtf.SendMsg(EM_GETLANGOPTIONS, 0, 0) & ~(IMF_AUTOKEYBOARD | IMF_AUTOFONTSIZEADJUST)); - m_rtf.SendMsg(EM_SETMARGINS, EC_LEFTMARGIN | EC_RIGHTMARGIN, MAKELONG(0, 0)); - m_rtf.SendMsg(EM_LIMITTEXT, 0x7FFFFFFF, 0); - m_rtf.SendMsg(EM_HIDESELECTION, TRUE, 0); - m_rtf.SendMsg(EM_AUTOURLDETECT, TRUE, 0); -} - -void CLogWindow::LogEvents(MEVENT hDbEventFirst, int count, bool bAppend) -{ - CHARRANGE oldSel, sel; - m_rtf.SetDraw(false); - m_rtf.SendMsg(EM_EXGETSEL, 0, (LPARAM)&oldSel); - - LogStreamData streamData = {}; - streamData.hContact = m_pDlg.m_hContact; - streamData.hDbEvent = hDbEventFirst; - streamData.hDbEventLast = m_pDlg.m_hDbEventLast; - streamData.dlgDat = &m_pDlg; - streamData.eventsToInsert = count; - streamData.isFirst = bAppend ? m_rtf.GetRichTextLength() == 0 : 1; - streamData.gdat = &g_dat; - - EDITSTREAM stream = {}; - stream.pfnCallback = LogStreamInEvents; - stream.dwCookie = (DWORD_PTR)&streamData; - sel.cpMin = 0; - - POINT scrollPos; - bool bottomScroll = (GetFocus() != m_rtf.GetHwnd()); - if (bottomScroll && (GetWindowLongPtr(m_rtf.GetHwnd(), GWL_STYLE) & WS_VSCROLL)) { - SCROLLINFO si = {}; - si.cbSize = sizeof(si); - si.fMask = SIF_PAGE | SIF_RANGE | SIF_POS; - GetScrollInfo(m_rtf.GetHwnd(), SB_VERT, &si); - bottomScroll = (si.nPos + (int)si.nPage) >= si.nMax; - } - if (!bottomScroll) - m_rtf.SendMsg(EM_GETSCROLLPOS, 0, (LPARAM)&scrollPos); - - FINDTEXTEXA fi; - if (bAppend) { - GETTEXTLENGTHEX gtxl = { 0 }; - gtxl.flags = GTL_DEFAULT | GTL_PRECISE | GTL_NUMCHARS; - gtxl.codepage = 1200; - fi.chrg.cpMin = m_rtf.SendMsg(EM_GETTEXTLENGTHEX, (WPARAM)>xl, 0); - sel.cpMin = sel.cpMax = m_rtf.GetRichTextLength(); - m_rtf.SendMsg(EM_EXSETSEL, 0, (LPARAM)&sel); - } - else { + typedef CRtfLogWindow CSuper; + +public: + CLogWindow(CMsgDialog &pDlg) : + CSuper(pDlg) + {} + + void Attach() override + { + CSuper::Attach(); + + uint32_t dwExStyle = GetWindowLongPtr(m_rtf.GetHwnd(), GWL_EXSTYLE); + SetWindowLongPtr(m_rtf.GetHwnd(), GWL_EXSTYLE, (m_pDlg.m_bUseRtl) ? dwExStyle | WS_EX_LEFTSCROLLBAR : dwExStyle & ~WS_EX_LEFTSCROLLBAR); + + // Workaround to make Richedit display RTL messages correctly + PARAFORMAT2 pf2; + memset(&pf2, 0, sizeof(pf2)); + pf2.cbSize = sizeof(pf2); + pf2.dwMask = PFM_RTLPARA | PFM_OFFSETINDENT | PFM_RIGHTINDENT; + pf2.wEffects = PFE_RTLPARA; + pf2.dxStartIndent = 30; + pf2.dxRightIndent = 30; + m_rtf.SendMsg(EM_SETPARAFORMAT, 0, (LPARAM)&pf2); + + pf2.dwMask = PFM_RTLPARA; + pf2.wEffects = 0; + m_rtf.SendMsg(EM_SETPARAFORMAT, 0, (LPARAM)&pf2); + + m_rtf.SendMsg(EM_SETEVENTMASK, 0, ENM_MOUSEEVENTS | ENM_LINK | ENM_KEYEVENTS); + m_rtf.SendMsg(EM_SETEDITSTYLE, SES_EXTENDBACKCOLOR, SES_EXTENDBACKCOLOR); + m_rtf.SendMsg(EM_SETLANGOPTIONS, 0, (LPARAM)m_rtf.SendMsg(EM_GETLANGOPTIONS, 0, 0) & ~(IMF_AUTOKEYBOARD | IMF_AUTOFONTSIZEADJUST)); + m_rtf.SendMsg(EM_SETMARGINS, EC_LEFTMARGIN | EC_RIGHTMARGIN, MAKELONG(0, 0)); + m_rtf.SendMsg(EM_LIMITTEXT, 0x7FFFFFFF, 0); + m_rtf.SendMsg(EM_HIDESELECTION, TRUE, 0); + m_rtf.SendMsg(EM_AUTOURLDETECT, TRUE, 0); + } + + void LogEvents(MEVENT hDbEventFirst, int count, bool bAppend) override + { + CHARRANGE oldSel, sel; m_rtf.SetDraw(false); - m_rtf.SetTextA(""); + m_rtf.SendMsg(EM_EXGETSEL, 0, (LPARAM)&oldSel); + + LogStreamData streamData = {}; + streamData.hContact = m_pDlg.m_hContact; + streamData.hDbEvent = hDbEventFirst; + streamData.hDbEventLast = m_pDlg.m_hDbEventLast; + streamData.dlgDat = &m_pDlg; + streamData.eventsToInsert = count; + streamData.isFirst = bAppend ? m_rtf.GetRichTextLength() == 0 : 1; + streamData.gdat = &g_dat; + + EDITSTREAM stream = {}; + stream.pfnCallback = LogStreamInEvents; + stream.dwCookie = (DWORD_PTR)&streamData; sel.cpMin = 0; - sel.cpMax = m_rtf.GetRichTextLength(); - m_rtf.SendMsg(EM_EXSETSEL, 0, (LPARAM)&sel); - fi.chrg.cpMin = 0; - m_pDlg.m_isMixed = 0; - } - m_rtf.SendMsg(EM_STREAMIN, bAppend ? SFF_SELECTION | SF_RTF : SFF_SELECTION | SF_RTF, (LPARAM)&stream); - if (bottomScroll) { - sel.cpMin = sel.cpMax = -1; - m_rtf.SendMsg(EM_EXSETSEL, 0, (LPARAM)&sel); - } - else { - m_rtf.SendMsg(EM_EXSETSEL, 0, (LPARAM)&oldSel); - m_rtf.SendMsg(EM_SETSCROLLPOS, 0, (LPARAM)&scrollPos); - } + POINT scrollPos; + bool bottomScroll = (GetFocus() != m_rtf.GetHwnd()); + if (bottomScroll && (GetWindowLongPtr(m_rtf.GetHwnd(), GWL_STYLE) & WS_VSCROLL)) { + SCROLLINFO si = {}; + si.cbSize = sizeof(si); + si.fMask = SIF_PAGE | SIF_RANGE | SIF_POS; + GetScrollInfo(m_rtf.GetHwnd(), SB_VERT, &si); + bottomScroll = (si.nPos + (int)si.nPage) >= si.nMax; + } + if (!bottomScroll) + m_rtf.SendMsg(EM_GETSCROLLPOS, 0, (LPARAM)&scrollPos); + + FINDTEXTEXA fi; + if (bAppend) { + GETTEXTLENGTHEX gtxl = { 0 }; + gtxl.flags = GTL_DEFAULT | GTL_PRECISE | GTL_NUMCHARS; + gtxl.codepage = 1200; + fi.chrg.cpMin = m_rtf.SendMsg(EM_GETTEXTLENGTHEX, (WPARAM)>xl, 0); + sel.cpMin = sel.cpMax = m_rtf.GetRichTextLength(); + m_rtf.SendMsg(EM_EXSETSEL, 0, (LPARAM)&sel); + } + else { + m_rtf.SetDraw(false); + m_rtf.SetTextA(""); + sel.cpMin = 0; + sel.cpMax = m_rtf.GetRichTextLength(); + m_rtf.SendMsg(EM_EXSETSEL, 0, (LPARAM)&sel); + fi.chrg.cpMin = 0; + m_pDlg.m_isMixed = 0; + } + + m_rtf.SendMsg(EM_STREAMIN, bAppend ? SFF_SELECTION | SF_RTF : SFF_SELECTION | SF_RTF, (LPARAM)&stream); + if (bottomScroll) { + sel.cpMin = sel.cpMax = -1; + m_rtf.SendMsg(EM_EXSETSEL, 0, (LPARAM)&sel); + } + else { + m_rtf.SendMsg(EM_EXSETSEL, 0, (LPARAM)&oldSel); + m_rtf.SendMsg(EM_SETSCROLLPOS, 0, (LPARAM)&scrollPos); + } + + if (g_dat.smileyAddInstalled) { + SMADD_RICHEDIT3 smre; + smre.cbSize = sizeof(SMADD_RICHEDIT3); + smre.hwndRichEditControl = m_rtf.GetHwnd(); - if (g_dat.smileyAddInstalled) { - SMADD_RICHEDIT3 smre; - smre.cbSize = sizeof(SMADD_RICHEDIT3); - smre.hwndRichEditControl = m_rtf.GetHwnd(); + MCONTACT hContact = db_mc_getSrmmSub(m_pDlg.m_hContact); + smre.Protocolname = (hContact != 0) ? Proto_GetBaseAccountName(hContact) : m_pDlg.m_szProto; - MCONTACT hContact = db_mc_getSrmmSub(m_pDlg.m_hContact); - smre.Protocolname = (hContact != 0) ? Proto_GetBaseAccountName(hContact) : m_pDlg.m_szProto; + if (fi.chrg.cpMin > 0) { + sel.cpMin = fi.chrg.cpMin; + sel.cpMax = -1; + smre.rangeToReplace = &sel; + } + else smre.rangeToReplace = nullptr; - if (fi.chrg.cpMin > 0) { - sel.cpMin = fi.chrg.cpMin; - sel.cpMax = -1; - smre.rangeToReplace = &sel; + smre.disableRedraw = TRUE; + smre.hContact = m_pDlg.m_hContact; + smre.flags = 0; + CallService(MS_SMILEYADD_REPLACESMILEYS, 0, (LPARAM)&smre); } - else smre.rangeToReplace = nullptr; - smre.disableRedraw = TRUE; - smre.hContact = m_pDlg.m_hContact; - smre.flags = 0; - CallService(MS_SMILEYADD_REPLACESMILEYS, 0, (LPARAM)&smre); - } + m_rtf.SetDraw(true); + if (bottomScroll) { + ScrollToBottom(); + RedrawWindow(m_rtf.GetHwnd(), nullptr, nullptr, RDW_INVALIDATE | RDW_UPDATENOW); + } - m_rtf.SetDraw(true); - if (bottomScroll) { - ScrollToBottom(); - RedrawWindow(m_rtf.GetHwnd(), nullptr, nullptr, RDW_INVALIDATE | RDW_UPDATENOW); + m_pDlg.m_hDbEventLast = streamData.hDbEventLast; } - m_pDlg.m_hDbEventLast = streamData.hDbEventLast; -} + void LogEvents(struct LOGINFO *lin, bool bRedraw) override + { + auto *si = m_pDlg.m_si; + if (m_rtf.GetHwnd() == nullptr || lin == nullptr || si == nullptr) + return; -void CLogWindow::LogEvents(LOGINFO *lin, bool bRedraw) -{ - auto *si = m_pDlg.m_si; - if (m_rtf.GetHwnd() == nullptr || lin == nullptr || si == nullptr) - return; + if (!bRedraw && (si->iType == GCW_CHATROOM || si->iType == GCW_PRIVMESS) && m_pDlg.m_bFilterEnabled && !(m_pDlg.m_iLogFilterFlags & lin->iType)) + return; - if (!bRedraw && (si->iType == GCW_CHATROOM || si->iType == GCW_PRIVMESS) && m_pDlg.m_bFilterEnabled && !(m_pDlg.m_iLogFilterFlags & lin->iType)) - return; + LOGSTREAMDATA streamData; + memset(&streamData, 0, sizeof(streamData)); + streamData.hwnd = m_rtf.GetHwnd(); + streamData.si = si; + streamData.lin = lin; + streamData.bStripFormat = FALSE; + streamData.isFirst = bRedraw ? 1 : m_rtf.GetRichTextLength() == 0; - LOGSTREAMDATA streamData; - memset(&streamData, 0, sizeof(streamData)); - streamData.hwnd = m_rtf.GetHwnd(); - streamData.si = si; - streamData.lin = lin; - streamData.bStripFormat = FALSE; - streamData.isFirst = bRedraw ? 1 : m_rtf.GetRichTextLength() == 0; + EDITSTREAM stream = {}; + stream.pfnCallback = Srmm_LogStreamCallback; + stream.dwCookie = (DWORD_PTR)&streamData; - EDITSTREAM stream = {}; - stream.pfnCallback = Srmm_LogStreamCallback; - stream.dwCookie = (DWORD_PTR)&streamData; + SCROLLINFO scroll; + scroll.cbSize = sizeof(SCROLLINFO); + scroll.fMask = SIF_RANGE | SIF_POS | SIF_PAGE; + GetScrollInfo(m_rtf.GetHwnd(), SB_VERT, &scroll); - SCROLLINFO scroll; - scroll.cbSize = sizeof(SCROLLINFO); - scroll.fMask = SIF_RANGE | SIF_POS | SIF_PAGE; - GetScrollInfo(m_rtf.GetHwnd(), SB_VERT, &scroll); + POINT point = {}; + m_rtf.SendMsg(EM_GETSCROLLPOS, 0, (LPARAM)&point); - POINT point = {}; - m_rtf.SendMsg(EM_GETSCROLLPOS, 0, (LPARAM)&point); + // do not scroll to bottom if there is a selection + CHARRANGE oldsel, sel, newsel; + m_rtf.SendMsg(EM_EXGETSEL, 0, (LPARAM)&oldsel); + if (oldsel.cpMax != oldsel.cpMin) + m_rtf.SetDraw(false); - // do not scroll to bottom if there is a selection - CHARRANGE oldsel, sel, newsel; - m_rtf.SendMsg(EM_EXGETSEL, 0, (LPARAM)&oldsel); - if (oldsel.cpMax != oldsel.cpMin) - m_rtf.SetDraw(false); + // set the insertion point at the bottom + sel.cpMin = sel.cpMax = m_rtf.GetRichTextLength(); + m_rtf.SendMsg(EM_EXSETSEL, 0, (LPARAM)&sel); + m_rtf.SendMsg(EM_EXGETSEL, 0, (LPARAM)&sel); - // set the insertion point at the bottom - sel.cpMin = sel.cpMax = m_rtf.GetRichTextLength(); - m_rtf.SendMsg(EM_EXSETSEL, 0, (LPARAM)&sel); - m_rtf.SendMsg(EM_EXGETSEL, 0, (LPARAM)&sel); + // fix for the indent... must be a M$ bug + if (sel.cpMax == 0) + bRedraw = TRUE; - // fix for the indent... must be a M$ bug - if (sel.cpMax == 0) - bRedraw = TRUE; + // should the event(s) be appended to the current log + WPARAM wp = bRedraw ? SF_RTF : SFF_SELECTION | SF_RTF; - // should the event(s) be appended to the current log - WPARAM wp = bRedraw ? SF_RTF : SFF_SELECTION | SF_RTF; + // get the number of pixels per logical inch + bool bFlag = false; + if (bRedraw) { + m_rtf.SetDraw(false); + bFlag = true; + } - // get the number of pixels per logical inch - bool bFlag = false; - if (bRedraw) { - m_rtf.SetDraw(false); - bFlag = true; - } - - // stream in the event(s) - streamData.lin = lin; - streamData.bRedraw = bRedraw; - m_rtf.SendMsg(EM_STREAMIN, wp, (LPARAM)&stream); - - // do smileys - if (g_dat.smileyAddInstalled && (bRedraw || (lin->ptszText && lin->iType != GC_EVENT_JOIN && lin->iType != GC_EVENT_NICK && lin->iType != GC_EVENT_ADDSTATUS && lin->iType != GC_EVENT_REMOVESTATUS))) { - newsel.cpMax = -1; - newsel.cpMin = sel.cpMin; - if (newsel.cpMin < 0) - newsel.cpMin = 0; - - SMADD_RICHEDIT3 sm = { sizeof(sm) }; - sm.hwndRichEditControl = m_rtf.GetHwnd(); - sm.Protocolname = si->pszModule; - sm.rangeToReplace = bRedraw ? nullptr : &newsel; - sm.flags = 0; - sm.disableRedraw = TRUE; - sm.hContact = m_pDlg.m_hContact; - CallService(MS_SMILEYADD_REPLACESMILEYS, 0, (LPARAM)&sm); - } - - // scroll log to bottom if the log was previously scrolled to bottom, else restore old position - if (bRedraw || (UINT)scroll.nPos >= (UINT)scroll.nMax - scroll.nPage - 5 || scroll.nMax - scroll.nMin - scroll.nPage < 50) - ScrollToBottom(); - else - m_rtf.SendMsg(EM_SETSCROLLPOS, 0, (LPARAM)&point); + // stream in the event(s) + streamData.lin = lin; + streamData.bRedraw = bRedraw; + m_rtf.SendMsg(EM_STREAMIN, wp, (LPARAM)&stream); + + // do smileys + if (g_dat.smileyAddInstalled && (bRedraw || (lin->ptszText && lin->iType != GC_EVENT_JOIN && lin->iType != GC_EVENT_NICK && lin->iType != GC_EVENT_ADDSTATUS && lin->iType != GC_EVENT_REMOVESTATUS))) { + newsel.cpMax = -1; + newsel.cpMin = sel.cpMin; + if (newsel.cpMin < 0) + newsel.cpMin = 0; + + SMADD_RICHEDIT3 sm = { sizeof(sm) }; + sm.hwndRichEditControl = m_rtf.GetHwnd(); + sm.Protocolname = si->pszModule; + sm.rangeToReplace = bRedraw ? nullptr : &newsel; + sm.flags = 0; + sm.disableRedraw = TRUE; + sm.hContact = m_pDlg.m_hContact; + CallService(MS_SMILEYADD_REPLACESMILEYS, 0, (LPARAM)&sm); + } - // do we need to restore the selection - if (oldsel.cpMax != oldsel.cpMin) { - m_rtf.SendMsg(EM_EXSETSEL, 0, (LPARAM)&oldsel); - m_rtf.SetDraw(true); - InvalidateRect(m_rtf.GetHwnd(), nullptr, TRUE); - } + // scroll log to bottom if the log was previously scrolled to bottom, else restore old position + if (bRedraw || (UINT)scroll.nPos >= (UINT)scroll.nMax - scroll.nPage - 5 || scroll.nMax - scroll.nMin - scroll.nPage < 50) + ScrollToBottom(); + else + m_rtf.SendMsg(EM_SETSCROLLPOS, 0, (LPARAM)&point); - // need to invalidate the window - if (bFlag) { - sel.cpMin = sel.cpMax = m_rtf.GetRichTextLength(); - m_rtf.SendMsg(EM_EXSETSEL, 0, (LPARAM)&sel); - m_rtf.SetDraw(true); - InvalidateRect(m_rtf.GetHwnd(), nullptr, TRUE); + // do we need to restore the selection + if (oldsel.cpMax != oldsel.cpMin) { + m_rtf.SendMsg(EM_EXSETSEL, 0, (LPARAM)&oldsel); + m_rtf.SetDraw(true); + InvalidateRect(m_rtf.GetHwnd(), nullptr, TRUE); + } + + // need to invalidate the window + if (bFlag) { + sel.cpMin = sel.cpMax = m_rtf.GetRichTextLength(); + m_rtf.SendMsg(EM_EXSETSEL, 0, (LPARAM)&sel); + m_rtf.SetDraw(true); + InvalidateRect(m_rtf.GetHwnd(), nullptr, TRUE); + } } -} -void CLogWindow::ScrollToBottom() -{ - if (GetWindowLongPtr(m_rtf.GetHwnd(), GWL_STYLE) & WS_VSCROLL) { - SCROLLINFO si = { sizeof(si) }; - si.fMask = SIF_PAGE | SIF_RANGE | SIF_POS; - if (GetScrollInfo(m_rtf.GetHwnd(), SB_VERT, &si)) { - if (m_rtf.GetHwnd() != GetFocus()) { - si.fMask = SIF_POS; - si.nPos = si.nMax - si.nPage + 1; - SetScrollInfo(m_rtf.GetHwnd(), SB_VERT, &si, TRUE); - - PostMessage(m_rtf.GetHwnd(), WM_VSCROLL, MAKEWPARAM(SB_BOTTOM, 0), 0); + void ScrollToBottom() override + { + if (GetWindowLongPtr(m_rtf.GetHwnd(), GWL_STYLE) & WS_VSCROLL) { + SCROLLINFO si = { sizeof(si) }; + si.fMask = SIF_PAGE | SIF_RANGE | SIF_POS; + if (GetScrollInfo(m_rtf.GetHwnd(), SB_VERT, &si)) { + if (m_rtf.GetHwnd() != GetFocus()) { + si.fMask = SIF_POS; + si.nPos = si.nMax - si.nPage + 1; + SetScrollInfo(m_rtf.GetHwnd(), SB_VERT, &si, TRUE); + + PostMessage(m_rtf.GetHwnd(), WM_VSCROLL, MAKEWPARAM(SB_BOTTOM, 0), 0); + } } } } -} -void CLogWindow::UpdateOptions() -{ - if (m_pDlg.isChat()) - m_rtf.SendMsg(EM_SETBKGNDCOLOR, 0, g_Settings.crLogBackground); - else - m_rtf.SendMsg(EM_SETBKGNDCOLOR, 0, g_plugin.getDword(SRMSGSET_BKGCOLOUR, SRMSGDEFSET_BKGCOLOUR)); - - PARAFORMAT2 pf2; - memset(&pf2, 0, sizeof(pf2)); - pf2.cbSize = sizeof(pf2); - pf2.dwMask = PFM_OFFSET; - pf2.dxOffset = (g_dat.flags.bIndentText) ? g_dat.indentSize * 1440 / g_dat.logPixelSX : 0; - m_rtf.SendMsg(EM_SETPARAFORMAT, 0, (LPARAM)&pf2); - m_rtf.SendMsg(EM_SETLANGOPTIONS, 0, (LPARAM)m_rtf.SendMsg(EM_GETLANGOPTIONS, 0, 0) & ~(IMF_AUTOKEYBOARD | IMF_AUTOFONTSIZEADJUST)); - - Clear(); -} + void UpdateOptions() override + { + if (m_pDlg.isChat()) + m_rtf.SendMsg(EM_SETBKGNDCOLOR, 0, g_Settings.crLogBackground); + else + m_rtf.SendMsg(EM_SETBKGNDCOLOR, 0, g_plugin.getDword(SRMSGSET_BKGCOLOUR, SRMSGDEFSET_BKGCOLOUR)); + + PARAFORMAT2 pf2; + memset(&pf2, 0, sizeof(pf2)); + pf2.cbSize = sizeof(pf2); + pf2.dwMask = PFM_OFFSET; + pf2.dxOffset = (g_dat.flags.bIndentText) ? g_dat.indentSize * 1440 / g_dat.logPixelSX : 0; + m_rtf.SendMsg(EM_SETPARAFORMAT, 0, (LPARAM)&pf2); + m_rtf.SendMsg(EM_SETLANGOPTIONS, 0, (LPARAM)m_rtf.SendMsg(EM_GETLANGOPTIONS, 0, 0) & ~(IMF_AUTOKEYBOARD | IMF_AUTOFONTSIZEADJUST)); + + Clear(); + } + + INT_PTR WndProc(UINT msg, WPARAM wParam, LPARAM lParam) override + { + int result = m_pDlg.InputAreaShortcuts(m_rtf.GetHwnd(), msg, wParam, lParam); + if (result != -1) + return result; + + switch (msg) { + case WM_MEASUREITEM: + Menu_MeasureItem(lParam); + return TRUE; + + case WM_DRAWITEM: + return Menu_DrawItem(lParam); + + case WM_LBUTTONUP: + if (g_plugin.bAutoCopy) { + CHARRANGE sel; + SendMessage(m_rtf.GetHwnd(), EM_EXGETSEL, 0, (LPARAM)&sel); + if (sel.cpMin != sel.cpMax) { + SendMessage(m_rtf.GetHwnd(), WM_COPY, 0, 0); + sel.cpMin = sel.cpMax; + SendMessage(m_rtf.GetHwnd(), EM_EXSETSEL, 0, (LPARAM)&sel); + } + SetFocus(m_pDlg.m_message.GetHwnd()); + } + break; + } + + return CSuper::WndProc(msg, wParam, lParam); + } +}; -CSrmmLogWindow *logBuilder(CMsgDialog &pDlg) +CSrmmLogWindow* logBuilder(CMsgDialog &pDlg) { return new CLogWindow(pDlg); } diff --git a/plugins/Scriver/src/msgoptions.cpp b/plugins/Scriver/src/msgoptions.cpp index 8ddb352a08..226307dcd2 100644 --- a/plugins/Scriver/src/msgoptions.cpp +++ b/plugins/Scriver/src/msgoptions.cpp @@ -498,7 +498,7 @@ class CLogOptionsDlg : public CBaseOptionDlg { CCtrlSpin spinCount, spinTime, spinIndent; CCtrlCheck chkLoadUnread, chkLoadCount, chkLoadTime; - CCtrlCheck chkShowIcons, chkShowTime, chkShowSecs, chkShowDate, chkLongDate, chkRelativeDate; + CCtrlCheck chkShowIcons, chkShowTime, chkShowSecs, chkShowDate, chkLongDate, chkRelativeDate, chkAutoCopy; CCtrlCheck chkGroupMsg, chkIndentText, chkHideNames, chkMarkFollowups, chkMsgOnNewline, chkDrawLines; CCtrlRichEdit m_rtf; CCtrlHyperlink m_fonts; @@ -536,21 +536,22 @@ public: CBaseOptionDlg(IDD_OPT_MSGLOG), m_rtf(this, IDC_SRMM_LOG), m_fonts(this, IDC_FONTSCOLORS), + chkLoadTime(this, IDC_LOADTIME), + chkLoadCount(this, IDC_LOADCOUNT), + chkLoadUnread(this, IDC_LOADUNREAD), chkShowTime(this, IDC_SHOWTIMES), chkShowSecs(this, IDC_SHOWSECONDS), chkShowDate(this, IDC_SHOWDATES), chkLongDate(this, IDC_USELONGDATE), - chkRelativeDate(this, IDC_USERELATIVEDATE), + chkAutoCopy(this, IDC_AUTOCOPY), chkGroupMsg(this, IDC_GROUPMESSAGES), - chkMarkFollowups(this, IDC_MARKFOLLOWUPS), + chkHideNames(this, IDC_HIDENAMES), chkDrawLines(this, IDC_DRAWLINES), chkShowIcons(this, IDC_SHOWLOGICONS), chkIndentText(this, IDC_INDENTTEXT), - chkHideNames(this, IDC_HIDENAMES), + chkRelativeDate(this, IDC_USERELATIVEDATE), + chkMarkFollowups(this, IDC_MARKFOLLOWUPS), chkMsgOnNewline(this, IDC_MESSAGEONNEWLINE), - chkLoadTime(this, IDC_LOADTIME), - chkLoadCount(this, IDC_LOADCOUNT), - chkLoadUnread(this, IDC_LOADUNREAD), spinTime(this, IDC_LOADTIMESPIN, 12 * 60), spinCount(this, IDC_LOADCOUNTSPIN, 100), spinIndent(this, IDC_INDENTSPIN, 999) @@ -560,6 +561,7 @@ public: CreateLink(chkShowTime, g_plugin.bShowTime); CreateLink(chkShowSecs, g_plugin.bShowSeconds); CreateLink(chkShowDate, g_plugin.bShowDate); + CreateLink(chkAutoCopy, g_plugin.bAutoCopy); CreateLink(chkLongDate, g_plugin.bLongDate); CreateLink(chkGroupMsg, g_plugin.bGroupMessages); CreateLink(chkShowIcons, g_plugin.bShowIcons); diff --git a/plugins/Scriver/src/msgs.cpp b/plugins/Scriver/src/msgs.cpp index 8302c903ce..498dfe43e3 100644 --- a/plugins/Scriver/src/msgs.cpp +++ b/plugins/Scriver/src/msgs.cpp @@ -486,9 +486,6 @@ static int OnModulesLoaded(WPARAM, LPARAM) int OnSystemPreshutdown(WPARAM, LPARAM) { - for (auto &it : g_arDialogs.rev_iter()) - it->CloseTab(); - WindowList_Broadcast(g_dat.hParentWindowList, WM_CLOSE, 0, 0); return 0; } diff --git a/plugins/Scriver/src/msgs.h b/plugins/Scriver/src/msgs.h index 679a0eaa6b..3daa951eea 100644 --- a/plugins/Scriver/src/msgs.h +++ b/plugins/Scriver/src/msgs.h @@ -23,28 +23,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #ifndef SRMM_MSGS_H #define SRMM_MSGS_H -///////////////////////////////////////////////////////////////////////////////////////// -// CLogWindow - built-in log window - -class CLogWindow : public CRtfLogWindow -{ - typedef CRtfLogWindow CSuper; - -public: - CLogWindow(CMsgDialog &pDlg) : - CSuper(pDlg) - { - } - - void Attach() override; - void LogEvents(MEVENT hDbEventFirst, int count, bool bAppend) override; - void LogEvents(struct LOGINFO *, bool) override; - void ScrollToBottom() override; - void UpdateOptions() override; - - INT_PTR WndProc(UINT msg, WPARAM wParam, LPARAM lParam) override; -}; - ///////////////////////////////////////////////////////////////////////////////////////// #define MSGERROR_CANCEL 0 diff --git a/plugins/Scriver/src/resource.h b/plugins/Scriver/src/resource.h index 51c25fa42e..888a2f4974 100644 --- a/plugins/Scriver/src/resource.h +++ b/plugins/Scriver/src/resource.h @@ -1,6 +1,6 @@ //{{NO_DEPENDENCIES}} // Microsoft Visual C++ generated include file. -// Used by C:\Users\georg\DiskW\miranda-ng\plugins\Scriver\res\resource.rc +// Used by W:\miranda-ng\plugins\Scriver\res\resource.rc // #define VS_VERSION_INFO 1 #define IDD_MSGWIN 100 @@ -138,6 +138,7 @@ #define IDC_TRANSPARENCYTEXT1 1627 #define IDC_TRANSPARENCYTEXT2 1628 #define IDC_DRAWLINES 1629 +#define IDC_AUTOCOPY 1630 #define IDC_SAVEDRAFTS 1631 #define IDC_POPLIST 1632 #define IDC_LIMITNAMESLEN 1633 diff --git a/plugins/Scriver/src/srmm.cpp b/plugins/Scriver/src/srmm.cpp index a57dfc860b..242673aefa 100644 --- a/plugins/Scriver/src/srmm.cpp +++ b/plugins/Scriver/src/srmm.cpp @@ -47,55 +47,56 @@ PLUGININFOEX pluginInfoEx = { CMPlugin::CMPlugin() : PLUGIN(SRMM_MODULE, pluginInfoEx), - bCascade(SRMM_MODULE, "Cascade", 1), - bAutoMin(SRMM_MODULE, "AutoMin", 0), - bTopmost(SRMM_MODULE, "Topmost", 0), - bDelTemp(SRMM_MODULE, "DeleteTempCont", 0), - bTypingNew(SRMM_MODULE, "DefaultTyping", 1), - bAutoClose(SRMM_MODULE, "AutoClose", 0), - bAutoPopup(SRMM_MODULE, "AutoPopupMsg", 0), - bSaveDrafts(SRMM_MODULE, "SaveDrafts", 0), - bTypingUnknown(SRMM_MODULE, "UnknownTyping", 0), - bHideContainer(SRMM_MODULE, "HideContainers", 0), - bStayMinimized(SRMM_MODULE, "StayMinimized", 0), - bSavePerContact(SRMM_MODULE, "SavePerContact", 0), - - bShowAvatar(SRMM_MODULE, "AvatarEnable", 1), - bShowProgress(SRMM_MODULE, "ShowProgress", 0), - bShowIcons(SRMM_MODULE, "ShowLogIcon", 1), - bShowTime(SRMM_MODULE, "ShowTime", 1), - bShowSeconds(SRMM_MODULE, "ShowSeconds", 1), - bShowDate(SRMM_MODULE, "ShowDate", 0), - bLongDate(SRMM_MODULE, "UseLongDate", 0), - bRelativeDate(SRMM_MODULE, "UseRelativeDate", 0), - bDrawLines(SRMM_MODULE, "DrawLines", 0), - bHideNames(SRMM_MODULE, "HideNames", 1), - bIndentText(SRMM_MODULE, "IndentText", 0), - bGroupMessages(SRMM_MODULE, "GroupMessages", 0), - bMarkFollowups(SRMM_MODULE, "MarkFollowUps", 0), - bMsgOnNewline(SRMM_MODULE, "MessageOnNewLine", 0), - bUseTransparency(SRMM_MODULE, "UseTransparency", 0), - - bShowToolBar(SRMM_MODULE, "ShowButtonLine", 1), - bShowInfoBar(SRMM_MODULE, "ShowInfoBar", 1), - bShowTitleBar(SRMM_MODULE, "ShowTitleBar", 1), - bShowStatusBar(SRMM_MODULE, "ShowStatusBar", 1), - - bUseTabs(SRMM_MODULE, "UseTabs", 1), - bLimitTabs(SRMM_MODULE, "LimitTabs", 0), - bLimitChatTabs(SRMM_MODULE, "LimitChatsTabs", 0), - bLimitNames(SRMM_MODULE, "LimitNamesOnTabs", 1), - bHideOneTab(SRMM_MODULE, "HideOneTab", 1), - bTabsAtBottom(SRMM_MODULE, "TabsPosition", 0), - bSeparateChats(SRMM_MODULE, "SeparateChatsContainers", 0), - bTabCloseButton(SRMM_MODULE, "TabCloseButton", 0), - bSwitchToActive(SRMM_MODULE, "SwitchToActiveTab", 0), - - bShowTyping(SRMM_MODULE, "ShowTyping", 1), - bShowTypingWin(SRMM_MODULE, "ShowTypingWin", 1), - bShowTypingTray(SRMM_MODULE, "ShowTypingTray", 0), - bShowTypingClist(SRMM_MODULE, "ShowTypingClist", 1), - bShowTypingSwitch(SRMM_MODULE, "ShowTypingSwitch", 1), + bCascade(SRMM_MODULE, "Cascade", true), + bAutoMin(SRMM_MODULE, "AutoMin", false), + bAutoCopy(SRMM_MODULE, "AutoCopy", true), + bTopmost(SRMM_MODULE, "Topmost", false), + bDelTemp(SRMM_MODULE, "DeleteTempCont", false), + bTypingNew(SRMM_MODULE, "DefaultTyping", true), + bAutoClose(SRMM_MODULE, "AutoClose", false), + bAutoPopup(SRMM_MODULE, "AutoPopupMsg", false), + bSaveDrafts(SRMM_MODULE, "SaveDrafts", false), + bTypingUnknown(SRMM_MODULE, "UnknownTyping", false), + bHideContainer(SRMM_MODULE, "HideContainers", false), + bStayMinimized(SRMM_MODULE, "StayMinimized", false), + bSavePerContact(SRMM_MODULE, "SavePerContact", false), + + bShowAvatar(SRMM_MODULE, "AvatarEnable", true), + bShowProgress(SRMM_MODULE, "ShowProgress", false), + bShowIcons(SRMM_MODULE, "ShowLogIcon", true), + bShowTime(SRMM_MODULE, "ShowTime", true), + bShowSeconds(SRMM_MODULE, "ShowSeconds", true), + bShowDate(SRMM_MODULE, "ShowDate", false), + bLongDate(SRMM_MODULE, "UseLongDate", false), + bRelativeDate(SRMM_MODULE, "UseRelativeDate", false), + bDrawLines(SRMM_MODULE, "DrawLines", false), + bHideNames(SRMM_MODULE, "HideNames", true), + bIndentText(SRMM_MODULE, "IndentText", false), + bGroupMessages(SRMM_MODULE, "GroupMessages", false), + bMarkFollowups(SRMM_MODULE, "MarkFollowUps", false), + bMsgOnNewline(SRMM_MODULE, "MessageOnNewLine", false), + bUseTransparency(SRMM_MODULE, "UseTransparency", false), + + bShowToolBar(SRMM_MODULE, "ShowButtonLine", true), + bShowInfoBar(SRMM_MODULE, "ShowInfoBar", true), + bShowTitleBar(SRMM_MODULE, "ShowTitleBar", true), + bShowStatusBar(SRMM_MODULE, "ShowStatusBar", true), + + bUseTabs(SRMM_MODULE, "UseTabs", true), + bLimitTabs(SRMM_MODULE, "LimitTabs", false), + bLimitChatTabs(SRMM_MODULE, "LimitChatsTabs", false), + bLimitNames(SRMM_MODULE, "LimitNamesOnTabs", true), + bHideOneTab(SRMM_MODULE, "HideOneTab", true), + bTabsAtBottom(SRMM_MODULE, "TabsPosition", false), + bSeparateChats(SRMM_MODULE, "SeparateChatsContainers", false), + bTabCloseButton(SRMM_MODULE, "TabCloseButton", false), + bSwitchToActive(SRMM_MODULE, "SwitchToActiveTab", false), + + bShowTyping(SRMM_MODULE, "ShowTyping", true), + bShowTypingWin(SRMM_MODULE, "ShowTypingWin", true), + bShowTypingTray(SRMM_MODULE, "ShowTypingTray", false), + bShowTypingClist(SRMM_MODULE, "ShowTypingClist", true), + bShowTypingSwitch(SRMM_MODULE, "ShowTypingSwitch", true), iLimitNames(SRMM_MODULE, "LimitNamesLength", 20), iLimitTabs(SRMM_MODULE, "LimitTabsNum", 10), @@ -146,7 +147,9 @@ int CMPlugin::Load() int CMPlugin::Unload() { UnregisterSrmmLog(hLogger); + if (pTaskbarInterface) pTaskbarInterface->Release(); + return OnUnloadModule(); } diff --git a/plugins/Scriver/src/stdafx.h b/plugins/Scriver/src/stdafx.h index 7f1fc6a98e..731e44ad23 100644 --- a/plugins/Scriver/src/stdafx.h +++ b/plugins/Scriver/src/stdafx.h @@ -72,7 +72,7 @@ struct CMPlugin : public PLUGIN { HANDLE hLogger; - CMOption bSavePerContact, bCascade, bStayMinimized, bAutoMin, bSaveDrafts, bDelTemp, bHideContainer, bAutoPopup; + CMOption bSavePerContact, bCascade, bStayMinimized, bAutoMin, bSaveDrafts, bDelTemp, bHideContainer, bAutoPopup, bAutoCopy; CMOption bUseTransparency, bTopmost, bAutoClose, bTypingNew, bTypingUnknown; CMOption bShowTitleBar, bShowStatusBar, bShowToolBar, bShowInfoBar; CMOption bShowAvatar, bShowProgress, bShowIcons, bShowTime, bShowSeconds, bShowDate, bLongDate, bRelativeDate; @@ -141,6 +141,5 @@ CSrmmLogWindow *logBuilder(CMsgDialog &pDlg); #include "chat.h" extern GlobalMessageData g_dat; -extern LIST g_arDialogs; #endif -- cgit v1.2.3