diff options
author | George Hazan <ghazan@miranda.im> | 2017-03-11 20:46:09 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2017-03-11 20:46:17 +0300 |
commit | 1a23578ffa4dd87cc024f362bd8b2fadfa087e23 (patch) | |
tree | b98bd46ac4c6004d2f6c02615eafd7046e061018 /plugins/TabSRMM | |
parent | a81484f320776e7c945e2f74172f979745dd870b (diff) |
group chats:
- massive extinction of all remaining GC_* messages;
- color chooser completely moved to mir_app;
- color buttons' subclass function also moved to mir_app;
- all code management transferred to a bunch of virtual functions, members of CChatRoomDlg;
- numerous small fixes, like fix for a broken highlight in StdMsg
Diffstat (limited to 'plugins/TabSRMM')
-rw-r--r-- | plugins/TabSRMM/src/chat_log.cpp | 26 | ||||
-rw-r--r-- | plugins/TabSRMM/src/chat_main.cpp | 13 | ||||
-rw-r--r-- | plugins/TabSRMM/src/chat_options.cpp | 6 | ||||
-rw-r--r-- | plugins/TabSRMM/src/chat_tools.cpp | 2 | ||||
-rw-r--r-- | plugins/TabSRMM/src/chat_window.cpp | 384 | ||||
-rw-r--r-- | plugins/TabSRMM/src/container.cpp | 2 | ||||
-rw-r--r-- | plugins/TabSRMM/src/msgdlgutils.cpp | 2 | ||||
-rw-r--r-- | plugins/TabSRMM/src/msgs.h | 12 |
8 files changed, 209 insertions, 238 deletions
diff --git a/plugins/TabSRMM/src/chat_log.cpp b/plugins/TabSRMM/src/chat_log.cpp index bdcdadf887..a33c74b442 100644 --- a/plugins/TabSRMM/src/chat_log.cpp +++ b/plugins/TabSRMM/src/chat_log.cpp @@ -829,23 +829,20 @@ char* Log_CreateRTF(LOGSTREAMDATA *streamData) return str.Detach();
}
-void CChatRoomDlg::StreamInEvents(LOGINFO *lin, SESSION_INFO *si, bool bRedraw)
+void CChatRoomDlg::StreamInEvents(LOGINFO *lin, bool bRedraw)
{
- CHARRANGE oldsel, sel, newsel;
- POINT point = { 0 };
-
- if (m_hwnd == 0 || lin == 0 || si == 0)
+ if (m_hwnd == 0 || lin == 0 || m_si == 0)
return;
LOGSTREAMDATA streamData;
memset(&streamData, 0, sizeof(streamData));
streamData.hwnd = m_log.GetHwnd();
- streamData.si = si;
+ streamData.si = m_si;
streamData.lin = lin;
streamData.bStripFormat = FALSE;
streamData.dat = this;
- if (!bRedraw && (si->iType == GCW_CHATROOM || si->iType == GCW_PRIVMESS) && m_bFilterEnabled && (m_iLogFilterFlags & lin->iType) == 0)
+ if (!bRedraw && (m_si->iType == GCW_CHATROOM || m_si->iType == GCW_PRIVMESS) && m_bFilterEnabled && (m_iLogFilterFlags & lin->iType) == 0)
return;
bool bFlag = false, fDoReplace;
@@ -858,9 +855,12 @@ void CChatRoomDlg::StreamInEvents(LOGINFO *lin, SESSION_INFO *si, bool bRedraw) scroll.cbSize = sizeof(SCROLLINFO);
scroll.fMask = SIF_RANGE | SIF_POS | SIF_PAGE;
GetScrollInfo(GetDlgItem(m_hwnd, IDC_LOG), SB_VERT, &scroll);
+
+ POINT point = { 0 };
m_log.SendMsg(EM_GETSCROLLPOS, 0, (LPARAM)&point);
// do not scroll to bottom if there is a selection
+ CHARRANGE oldsel, sel, newsel;
m_log.SendMsg(EM_EXGETSEL, 0, (LPARAM)&oldsel);
if (oldsel.cpMax != oldsel.cpMin)
m_log.SendMsg(WM_SETREDRAW, FALSE, 0);
@@ -941,18 +941,18 @@ void CChatRoomDlg::StreamInEvents(LOGINFO *lin, SESSION_INFO *si, bool bRedraw) SMADD_RICHEDIT3 sm = { sizeof(sm) };
sm.hwndRichEditControl = m_log.GetHwnd();
- sm.Protocolname = si->pszModule;
+ sm.Protocolname = m_si->pszModule;
sm.rangeToReplace = bRedraw ? nullptr : &newsel;
sm.disableRedraw = TRUE;
- sm.hContact = si->hContact;
+ sm.hContact = m_si->hContact;
CallService(MS_SMILEYADD_REPLACESMILEYS, 0, (LPARAM)&sm);
}
// trim the message log to the number of most recent events
// this uses hidden marks in the rich text to find the events which should be deleted
- if (si->bTrimmed) {
+ if (m_si->bTrimmed) {
wchar_t szPattern[50];
- mir_snwprintf(szPattern, L"~-+%d+-~", si->pLogEnd);
+ mir_snwprintf(szPattern, L"~-+%d+-~", m_si->pLogEnd);
FINDTEXTEX fi;
fi.lpstrText = szPattern;
@@ -965,12 +965,12 @@ void CChatRoomDlg::StreamInEvents(LOGINFO *lin, SESSION_INFO *si, bool bRedraw) m_log.SendMsg(EM_SETSEL, 0, fi.chrgText.cpMax + 1);
m_log.SendMsg(EM_REPLACESEL, TRUE, (LPARAM)L"");
}
- si->bTrimmed = false;
+ m_si->bTrimmed = false;
}
// 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))
- SendMessage(GetParent(m_log.GetHwnd()), GC_SCROLLTOBOTTOM, 0, 0);
+ ScrollToBottom();
else
m_log.SendMsg(EM_SETSCROLLPOS, 0, (LPARAM)&point);
diff --git a/plugins/TabSRMM/src/chat_main.cpp b/plugins/TabSRMM/src/chat_main.cpp index 945ca7e475..5df84402de 100644 --- a/plugins/TabSRMM/src/chat_main.cpp +++ b/plugins/TabSRMM/src/chat_main.cpp @@ -37,12 +37,13 @@ pfnDoTrayIcon oldDoTrayIcon; CHAT_MANAGER *pci;
TMUCSettings g_Settings;
-static void OnCreateSession(SESSION_INFO*, MODULEINFO *mi)
+static void OnCreateSession(SESSION_INFO *si, MODULEINFO *mi)
{
- if (mi) {
+ if (si->pDlg)
+ si->pDlg->UpdateStatusBar();
+
+ if (mi)
mi->idleTimeStamp = time(0);
- pci->SM_BroadcastMessage(mi->pszModule, GC_UPDATESTATUSBAR, 0, 1, TRUE);
- }
}
static void OnReplaceSession(SESSION_INFO *si)
@@ -62,7 +63,7 @@ static void OnSetTopic(SESSION_INFO *si) static void OnNewUser(SESSION_INFO *si, USERINFO*)
{
if (si->pDlg) {
- SendMessage(si->pDlg->GetHwnd(), GC_UPDATENICKLIST, 0, 0);
+ si->pDlg->UpdateNickList();
if (si->pDlg)
si->pDlg->GetMyNick();
}
@@ -73,7 +74,7 @@ static void OnChangeNick(SESSION_INFO *si) if (si->pDlg) {
if (si->pDlg)
si->pDlg->GetMyNick();
- SendMessage(si->pDlg->GetHwnd(), GC_UPDATESTATUSBAR, 0, 0);
+ si->pDlg->UpdateStatusBar();
}
}
diff --git a/plugins/TabSRMM/src/chat_options.cpp b/plugins/TabSRMM/src/chat_options.cpp index 5566b3d538..f3c227e3e4 100644 --- a/plugins/TabSRMM/src/chat_options.cpp +++ b/plugins/TabSRMM/src/chat_options.cpp @@ -453,7 +453,7 @@ INT_PTR CALLBACK DlgProcOptions1(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM pci->ReloadSettings();
pci->MM_IconsChanged();
pci->MM_FontsChanged();
- pci->SM_BroadcastMessage(nullptr, GC_SETWNDPROPS, 0, 0, TRUE);
+ Chat_UpdateOptions();
SM_ReconfigureFilters();
return TRUE;
}
@@ -887,7 +887,7 @@ INT_PTR CALLBACK DlgProcOptions2(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM pci->ReloadSettings();
pci->MM_FontsChanged();
pci->MM_FixColors();
- pci->SM_BroadcastMessage(nullptr, GC_SETWNDPROPS, 0, 0, TRUE);
+ Chat_UpdateOptions();
PluginConfig.reloadSettings();
CacheMsgLogIcons();
@@ -995,7 +995,7 @@ INT_PTR CALLBACK DlgProcOptions3(HWND hwndDlg, UINT uMsg, WPARAM, LPARAM lParam) pci->ReloadSettings();
pci->MM_FontsChanged();
- pci->SM_BroadcastMessage(nullptr, GC_SETWNDPROPS, 0, 0, TRUE);
+ Chat_UpdateOptions();
SM_ReconfigureFilters();
return TRUE;
}
diff --git a/plugins/TabSRMM/src/chat_tools.cpp b/plugins/TabSRMM/src/chat_tools.cpp index d316bbd744..d8f914a224 100644 --- a/plugins/TabSRMM/src/chat_tools.cpp +++ b/plugins/TabSRMM/src/chat_tools.cpp @@ -333,8 +333,6 @@ BOOL DoSoundsFlashPopupTrayStuff(SESSION_INFO *si, GCEVENT *gce, BOOL bHighlight if (dat || !nen_options.iMUCDisable)
DoPopup(si, gce);
- if (params->bInactive && si && si->pDlg)
- SendMessage(si->pDlg->GetHwnd(), GC_SETMESSAGEHIGHLIGHT, 0, (LPARAM)si);
if (g_Settings.bFlashWindowHighlight && params->bInactive)
params->bMustFlash = TRUE;
params->bMustAutoswitch = TRUE;
diff --git a/plugins/TabSRMM/src/chat_window.cpp b/plugins/TabSRMM/src/chat_window.cpp index 02f2ad473f..f0bbd0020d 100644 --- a/plugins/TabSRMM/src/chat_window.cpp +++ b/plugins/TabSRMM/src/chat_window.cpp @@ -1066,7 +1066,7 @@ INT_PTR CALLBACK CChatRoomDlg::FilterWndProc(HWND hwndDlg, UINT uMsg, WPARAM wPa Chat_SetFilters(pDlg->m_si); pDlg->m_iLogFilterFlags = iFlags; if (pDlg->m_bFilterEnabled) - SendMessage(pDlg->GetHwnd(), GC_REDRAWLOG, 0, 0); + pDlg->RedrawLog(); } } DestroyWindow(hwndDlg); @@ -1080,33 +1080,6 @@ INT_PTR CALLBACK CChatRoomDlg::FilterWndProc(HWND hwndDlg, UINT uMsg, WPARAM wPa } ///////////////////////////////////////////////////////////////////////////////////////// -// subclass for some tool bar buttons which must perform special actions -// on right click. - -static LRESULT CALLBACK ButtonSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) -{ - switch (msg) { - case WM_RBUTTONUP: - if (M.GetByte(CHAT_MODULE, "RightClickFilter", 0) != 0) { - HWND hwndParent = GetParent(hwnd); - switch (GetDlgCtrlID(hwnd)) { - case IDC_FILTER: - SendMessage(hwndParent, GC_SHOWFILTERMENU, 0, 0); - break; - case IDC_COLOR: - SendMessage(hwndParent, GC_SHOWCOLORCHOOSER, 0, IDC_COLOR); - break; - case IDC_BKGCOLOR: - SendMessage(hwndParent, GC_SHOWCOLORCHOOSER, 0, IDC_BKGCOLOR); - } - } - break; - } - - return mir_callNextSubclass(hwnd, ButtonSubclassProc, msg, wParam, lParam); -} - -///////////////////////////////////////////////////////////////////////////////////////// // subclassing for the message history display(rich edit control in which the chat history appears) static LRESULT CALLBACK LogSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) @@ -1513,7 +1486,7 @@ static void __cdecl phase2(void * lParam) SESSION_INFO *si = (SESSION_INFO*)lParam; Sleep(30); if (si && si->pDlg) - PostMessage(si->pDlg->GetHwnd(), GC_REDRAWLOG2, 0, 0); + si->pDlg->RedrawLog2(); } ///////////////////////////////////////////////////////////////////////////////////////// @@ -1534,6 +1507,10 @@ CChatRoomDlg::CChatRoomDlg(SESSION_INFO *si) m_btnUnderline(this, IDC_UNDERLINE), m_btnNickList(this, IDC_SHOWNICKLIST) { + m_pColor = &m_btnColor; + m_pBkColor = &m_btnBkColor; + m_pFilter = &m_btnFilter; + m_szProto = GetContactProto(m_hContact); m_bFilterEnabled = db_get_b(m_hContact, CHAT_MODULE, "FilterEnabled", m_bFilterEnabled) != 0; Chat_SetFilters(m_si); @@ -1643,15 +1620,16 @@ void CChatRoomDlg::OnInitDialog() mir_subclassWindow(GetDlgItem(m_hwnd, IDC_SPLITTERY), SplitterSubclassProc); mir_subclassWindow(m_list.GetHwnd(), NicklistSubclassProc); mir_subclassWindow(m_log.GetHwnd(), LogSubclassProc); - mir_subclassWindow(m_btnFilter.GetHwnd(), ButtonSubclassProc); - mir_subclassWindow(m_btnColor.GetHwnd(), ButtonSubclassProc); - mir_subclassWindow(m_btnBkColor.GetHwnd(), ButtonSubclassProc); + + mir_subclassWindow(m_btnFilter.GetHwnd(), Srmm_ButtonSubclassProc); + mir_subclassWindow(m_btnColor.GetHwnd(), Srmm_ButtonSubclassProc); + mir_subclassWindow(m_btnBkColor.GetHwnd(), Srmm_ButtonSubclassProc); mir_subclassWindow(m_message.GetHwnd(), MessageSubclassProc); m_message.SendMsg(EM_SUBCLASSED, 0, 0); - SendMessage(m_hwnd, GC_SETWNDPROPS, 0, 0); - SendMessage(m_hwnd, GC_UPDATESTATUSBAR, 0, 0); + UpdateOptions(); + UpdateStatusBar(); UpdateTitle(); m_hTabIcon = m_hTabStatusIcon; @@ -1659,7 +1637,7 @@ void CChatRoomDlg::OnInitDialog() SendMessage(m_pContainer->hwnd, DM_QUERYCLIENTAREA, 0, (LPARAM)&rc); SetWindowPos(m_hwnd, HWND_TOP, rc.left, rc.top, (rc.right - rc.left), (rc.bottom - rc.top), 0); ShowWindow(m_hwnd, SW_SHOW); - PostMessage(m_hwnd, GC_UPDATENICKLIST, 0, 0); + UpdateNickList(); m_pContainer->hwndActive = m_hwnd; TABSRMM_FireEvent(m_hContact, m_hwnd, MSG_WINDOW_EVT_OPEN, 0); } @@ -1756,7 +1734,7 @@ void CChatRoomDlg::onClick_OK(CCtrlButton*) DoEventHook(GC_USER_MESSAGE, nullptr, ptszText, 0); mi->idleTimeStamp = time(0); mi->lastIdleCheck = 0; - pci->SM_BroadcastMessage(m_si->pszModule, GC_UPDATESTATUSBAR, 0, 1, TRUE); + UpdateStatusBar(); if (m_pContainer) if (fSound && !nen_options.iNoSounds && !(m_pContainer->dwFlags & CNT_NOSOUND)) SkinPlaySound("ChatSent"); @@ -1779,10 +1757,10 @@ void CChatRoomDlg::onClick_Filter(CCtrlButton *pButton) (LPARAM)(m_bFilterEnabled ? PluginConfig.g_iconOverlayEnabled : PluginConfig.g_iconOverlayDisabled), 0); if (m_bFilterEnabled && M.GetByte(CHAT_MODULE, "RightClickFilter", 0) == 0) { - SendMessage(m_hwnd, GC_SHOWFILTERMENU, 0, 0); + ShowFilterMenu(); return; } - SendMessage(m_hwnd, GC_REDRAWLOG, 0, 0); + RedrawLog(); UpdateTitle(); db_set_b(m_si->hContact, CHAT_MODULE, "FilterEnabled", m_bFilterEnabled); } @@ -1815,7 +1793,7 @@ void CChatRoomDlg::onClick_ShowNickList(CCtrlButton *pButton) SendMessage(m_hwnd, WM_SIZE, 0, 0); if (CSkin::m_skinEnabled) InvalidateRect(m_hwnd, nullptr, TRUE); - PostMessage(m_hwnd, GC_SCROLLTOBOTTOM, 0, 0); + ScrollToBottom(); } void CChatRoomDlg::onClick_ChanMgr(CCtrlButton *pButton) @@ -1855,7 +1833,7 @@ void CChatRoomDlg::onClick_Color(CCtrlButton *pButton) if (IsDlgButtonChecked(m_hwnd, IDC_COLOR)) { if (M.GetByte(CHAT_MODULE, "RightClickFilter", 0) == 0) - SendMessage(m_hwnd, GC_SHOWCOLORCHOOSER, 0, IDC_COLOR); + ShowColorChooser(IDC_COLOR); else if (m_bFGSet) { cf.dwMask = CFM_COLOR; cf.crTextColor = pci->MM_FindModule(m_si->pszModule)->crColors[m_iFG]; @@ -1882,7 +1860,7 @@ void CChatRoomDlg::onClick_BkColor(CCtrlButton *pButton) if (IsDlgButtonChecked(m_hwnd, IDC_BKGCOLOR)) { if (M.GetByte(CHAT_MODULE, "RightClickFilter", 0) == 0) - SendMessage(m_hwnd, GC_SHOWCOLORCHOOSER, 0, IDC_BKGCOLOR); + ShowColorChooser(IDC_BKGCOLOR); else if (m_bBGSet) { cf.dwMask = CFM_BACKCOLOR; cf.crBackColor = pci->MM_FindModule(m_si->pszModule)->crColors[m_iBG]; @@ -1950,6 +1928,25 @@ void CChatRoomDlg::onDblClick_List(CCtrlListBox*) ///////////////////////////////////////////////////////////////////////////////////////// +void CChatRoomDlg::AddLog() +{ + if (PluginConfig.m_bUseDividers) { + if (PluginConfig.m_bDividersUsePopupConfig) { + if (!MessageWindowOpened(0, (LPARAM)m_hwnd)) + DM_AddDivider(); + } + else { + bool bInactive = (GetForegroundWindow() != m_pContainer->hwnd || GetActiveWindow() != m_pContainer->hwnd); + if (bInactive) + DM_AddDivider(); + else if (m_pContainer->hwndActive != m_hwnd) + DM_AddDivider(); + } + } + + CSrmmBaseDialog::AddLog(); +} + void CChatRoomDlg::CloseTab(bool bForced) { int iTabs = TabCtrl_GetItemCount(m_hwndParent); @@ -1994,6 +1991,137 @@ void CChatRoomDlg::CloseTab(bool bForced) } } +void CChatRoomDlg::RedrawLog() +{ + m_si->LastTime = 0; + if (m_si->pLog) { + LOGINFO * pLog = m_si->pLog; + if (m_si->iEventCount > 60) { + int index = 0; + while (index < 59) { + if (pLog->next == nullptr) + break; + pLog = pLog->next; + if ((m_si->iType != GCW_CHATROOM && m_si->iType != GCW_PRIVMESS) || !m_bFilterEnabled || (m_iLogFilterFlags & pLog->iType) != 0) + index++; + } + StreamInEvents(pLog, TRUE); + mir_forkthread(phase2, m_si); + } + else StreamInEvents(m_si->pLogEnd, TRUE); + } + else ClearLog(); +} + +void CChatRoomDlg::ScrollToBottom() +{ + DM_ScrollToBottom(0, 0); +} + +void CChatRoomDlg::ShowFilterMenu() +{ + m_hwndFilter = CreateDialogParam(g_hInst, MAKEINTRESOURCE(IDD_FILTER), m_pContainer->hwnd, FilterWndProc, (LPARAM)this); + TranslateDialogDefault(m_hwndFilter); + + RECT rcFilter, rcLog; + GetClientRect(m_hwndFilter, &rcFilter); + GetWindowRect(m_log.GetHwnd(), &rcLog); + + POINT pt; + pt.x = rcLog.right; pt.y = rcLog.bottom; + ScreenToClient(m_pContainer->hwnd, &pt); + + SetWindowPos(m_hwndFilter, HWND_TOP, pt.x - rcFilter.right, pt.y - rcFilter.bottom, 0, 0, SWP_NOSIZE | SWP_SHOWWINDOW); +} + +void CChatRoomDlg::UpdateNickList() +{ + int i = m_list.SendMsg(LB_GETTOPINDEX, 0, 0); + m_list.SendMsg(LB_SETCOUNT, m_si->nUsersInNicklist, 0); + m_list.SendMsg(LB_SETTOPINDEX, i, 0); + UpdateTitle(); + m_hTabIcon = m_hTabStatusIcon; +} + +void CChatRoomDlg::UpdateOptions() +{ + MODULEINFO *pInfo = m_si ? pci->MM_FindModule(m_si->pszModule) : nullptr; + if (pInfo) { + m_btnBold.Enable(pInfo->bBold); + m_btnItalic.Enable(pInfo->bItalics); + m_btnUnderline.Enable(pInfo->bUnderline); + m_btnColor.Enable(pInfo->bColor); + m_btnBkColor.Enable(pInfo->bBkgColor); + if (m_si->iType == GCW_CHATROOM) + m_btnChannelMgr.Enable(pInfo->bChanMgr); + } + m_log.SendMsg(EM_SETBKGNDCOLOR, 0, M.GetDword(FONTMODULE, SRMSGSET_BKGCOLOUR, SRMSGDEFSET_BKGCOLOUR)); + + DM_InitRichEdit(); + m_btnOk.SendMsg(BUTTONSETASNORMAL, TRUE, 0); + + m_list.SetItemHeight(0, g_Settings.iNickListFontHeight); + InvalidateRect(m_list.GetHwnd(), nullptr, TRUE); + + m_btnFilter.SendMsg(BUTTONSETOVERLAYICON, (LPARAM)(m_bFilterEnabled ? PluginConfig.g_iconOverlayEnabled : PluginConfig.g_iconOverlayDisabled), 0); + SendMessage(m_hwnd, WM_SIZE, 0, 0); + RedrawLog2(); +} + +void CChatRoomDlg::UpdateStatusBar() +{ + if (m_pContainer->hwndActive != m_hwnd || m_pContainer->hwndStatus == 0 || CMimAPI::m_shutDown || m_wszStatusBar[0]) + return; + + if (m_si->pszModule != nullptr) { + wchar_t szFinalStatusBarText[512]; + + //Mad: strange rare crash here... + MODULEINFO *mi = pci->MM_FindModule(m_si->pszModule); + if (!mi) + return; + + if (!mi->ptszModDispName) + return; + + int x = 12; + x += GetTextPixelSize(mi->ptszModDispName, (HFONT)SendMessage(m_pContainer->hwndStatus, WM_GETFONT, 0, 0), TRUE); + x += GetSystemMetrics(SM_CXSMICON); + + if (m_pPanel.isActive()) { + time_t now = time(0); + DWORD diff = (now - mi->idleTimeStamp) / 60; + + if ((diff >= 1 && diff != mi->lastIdleCheck)) { + mi->lastIdleCheck = diff; + if (diff == 0) + mi->tszIdleMsg[0] = 0; + else if (diff > 59) { + DWORD hours = diff / 60; + DWORD minutes = diff % 60; + mir_snwprintf(mi->tszIdleMsg, TranslateT(", %d %s, %d %s idle"), hours, hours > 1 ? + TranslateT("hours") : TranslateT("hour"), + minutes, minutes > 1 ? TranslateT("minutes") : TranslateT("minute")); + } + else mir_snwprintf(mi->tszIdleMsg, TranslateT(", %d %s idle"), diff, diff > 1 ? TranslateT("minutes") : TranslateT("minute")); + } + mir_snwprintf(szFinalStatusBarText, TranslateT("%s on %s%s"), m_wszMyNickname, mi->ptszModDispName, mi->tszIdleMsg); + } + else { + if (m_si->ptszStatusbarText) + mir_snwprintf(szFinalStatusBarText, L"%s %s", mi->ptszModDispName, m_si->ptszStatusbarText); + else + wcsncpy_s(szFinalStatusBarText, mi->ptszModDispName, _TRUNCATE); + } + SendMessage(m_pContainer->hwndStatus, SB_SETTEXT, 0, (LPARAM)szFinalStatusBarText); + tabUpdateStatusBar(); + m_pPanel.Invalidate(); + if (m_pWnd) + m_pWnd->Invalidate(); + return; + } +} + void CChatRoomDlg::UpdateTitle() { m_wStatus = m_si->wStatus; @@ -2046,7 +2174,7 @@ void CChatRoomDlg::UpdateTitle() SetWindowText(m_hwnd, szTemp); if (m_pContainer->hwndActive == m_hwnd) { m_pContainer->UpdateTitle(0, this); - SendMessage(m_hwnd, GC_UPDATESTATUSBAR, 0, 0); + UpdateStatusBar(); } } @@ -2059,7 +2187,6 @@ INT_PTR CChatRoomDlg::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam) POINT pt, tmp, cur; RECT rc; - MODULEINFO *pInfo; switch (uMsg) { case WM_SETFOCUS: @@ -2071,96 +2198,19 @@ INT_PTR CChatRoomDlg::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam) return 1; case WM_TIMECHANGE: - PostMessage(m_hwnd, GC_REDRAWLOG, 0, 0); + RedrawLog(); break; case WM_CBD_LOADICONS: Srmm_UpdateToolbarIcons(m_hwnd); return 0; - case GC_SETWNDPROPS: - pInfo = m_si ? pci->MM_FindModule(m_si->pszModule) : nullptr; - if (pInfo) { - m_btnBold.Enable(pInfo->bBold); - m_btnItalic.Enable(pInfo->bItalics); - m_btnUnderline.Enable(pInfo->bUnderline); - m_btnColor.Enable(pInfo->bColor); - m_btnBkColor.Enable(pInfo->bBkgColor); - if (m_si->iType == GCW_CHATROOM) - m_btnChannelMgr.Enable(pInfo->bChanMgr); - } - m_log.SendMsg(EM_SETBKGNDCOLOR, 0, M.GetDword(FONTMODULE, SRMSGSET_BKGCOLOUR, SRMSGDEFSET_BKGCOLOUR)); - - DM_InitRichEdit(); - m_btnOk.SendMsg(BUTTONSETASNORMAL, TRUE, 0); - - m_list.SetItemHeight(0, g_Settings.iNickListFontHeight); - InvalidateRect(m_list.GetHwnd(), nullptr, TRUE); - - m_btnFilter.SendMsg(BUTTONSETOVERLAYICON, (LPARAM)(m_bFilterEnabled ? PluginConfig.g_iconOverlayEnabled : PluginConfig.g_iconOverlayDisabled), 0); - SendMessage(m_hwnd, WM_SIZE, 0, 0); - SendMessage(m_hwnd, GC_REDRAWLOG2, 0, 0); - break; - - case GC_UPDATESTATUSBAR: - if (m_pContainer->hwndActive != m_hwnd || m_pContainer->hwndStatus == 0 || CMimAPI::m_shutDown || m_wszStatusBar[0]) - break; - - if (m_si->pszModule != nullptr) { - wchar_t szFinalStatusBarText[512]; - - //Mad: strange rare crash here... - MODULEINFO *mi = pci->MM_FindModule(m_si->pszModule); - if (!mi) - break; - - if (!mi->ptszModDispName) - break; - - int x = 12; - x += GetTextPixelSize(mi->ptszModDispName, (HFONT)SendMessage(m_pContainer->hwndStatus, WM_GETFONT, 0, 0), TRUE); - x += GetSystemMetrics(SM_CXSMICON); - - if (m_pPanel.isActive()) { - time_t now = time(0); - DWORD diff = (now - mi->idleTimeStamp) / 60; - - if ((diff >= 1 && diff != mi->lastIdleCheck) || lParam) { - mi->lastIdleCheck = diff; - if (diff == 0) - mi->tszIdleMsg[0] = 0; - else if (diff > 59) { - DWORD hours = diff / 60; - DWORD minutes = diff % 60; - mir_snwprintf(mi->tszIdleMsg, TranslateT(", %d %s, %d %s idle"), hours, hours > 1 ? - TranslateT("hours") : TranslateT("hour"), - minutes, minutes > 1 ? TranslateT("minutes") : TranslateT("minute")); - } - else mir_snwprintf(mi->tszIdleMsg, TranslateT(", %d %s idle"), diff, diff > 1 ? TranslateT("minutes") : TranslateT("minute")); - } - mir_snwprintf(szFinalStatusBarText, TranslateT("%s on %s%s"), m_wszMyNickname, mi->ptszModDispName, mi->tszIdleMsg); - } - else { - if (m_si->ptszStatusbarText) - mir_snwprintf(szFinalStatusBarText, L"%s %s", mi->ptszModDispName, m_si->ptszStatusbarText); - else - wcsncpy_s(szFinalStatusBarText, mi->ptszModDispName, _TRUNCATE); - } - SendMessage(m_pContainer->hwndStatus, SB_SETTEXT, 0, (LPARAM)szFinalStatusBarText); - UpdateStatusBar(); - m_pPanel.Invalidate(); - if (m_pWnd) - m_pWnd->Invalidate(); - return TRUE; - } - break; - case WM_SIZE: if (m_ipFieldHeight == 0) m_ipFieldHeight = CInfoPanel::m_ipConfig.height1; if (wParam == SIZE_MAXIMIZED) - PostMessage(m_hwnd, GC_SCROLLTOBOTTOM, 0, 0); + ScrollToBottom(); if (!IsIconic(m_hwnd)) { int panelHeight = m_pPanel.getHeight() + 1; @@ -2190,58 +2240,6 @@ INT_PTR CChatRoomDlg::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam) } return 0; - case GC_REDRAWWINDOW: - InvalidateRect(m_hwnd, nullptr, TRUE); - break; - - case GC_REDRAWLOG: - m_si->LastTime = 0; - if (m_si->pLog) { - LOGINFO * pLog = m_si->pLog; - if (m_si->iEventCount > 60) { - int index = 0; - while (index < 59) { - if (pLog->next == nullptr) - break; - pLog = pLog->next; - if ((m_si->iType != GCW_CHATROOM && m_si->iType != GCW_PRIVMESS) || !m_bFilterEnabled || (m_iLogFilterFlags & pLog->iType) != 0) - index++; - } - StreamInEvents(pLog, m_si, TRUE); - mir_forkthread(phase2, m_si); - } - else StreamInEvents(m_si->pLogEnd, m_si, TRUE); - } - else ClearLog(); - break; - - case GC_REDRAWLOG2: - m_si->LastTime = 0; - if (m_si->pLog) - StreamInEvents(m_si->pLogEnd, m_si, TRUE); - break; - - case GC_ADDLOG: - if (PluginConfig.m_bUseDividers) { - if (PluginConfig.m_bDividersUsePopupConfig) { - if (!MessageWindowOpened(0, (LPARAM)m_hwnd)) - DM_AddDivider(); - } - else { - bool bInactive = (GetForegroundWindow() != m_pContainer->hwnd || GetActiveWindow() != m_pContainer->hwnd); - if (bInactive) - DM_AddDivider(); - else if (m_pContainer->hwndActive != m_hwnd) - DM_AddDivider(); - } - } - - if (m_si->pLogEnd) - StreamInEvents(m_si->pLog, m_si, FALSE); - else - ClearLog(); - break; - case DM_TYPING: // Typing support for GCW_PRIVMESS sessions if (m_si->iType == GCW_PRIVMESS) { @@ -2383,16 +2381,6 @@ INT_PTR CChatRoomDlg::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam) } break; - case GC_UPDATENICKLIST: - { - int i = m_list.SendMsg(LB_GETTOPINDEX, 0, 0); - m_list.SendMsg(LB_SETCOUNT, m_si->nUsersInNicklist, 0); - m_list.SendMsg(LB_SETTOPINDEX, i, 0); - UpdateTitle(); - m_hTabIcon = m_hTabStatusIcon; - } - break; - case DM_SPLITTERMOVED: RECT rcLog; GetWindowRect(m_log.GetHwnd(), &rcLog); @@ -2439,28 +2427,6 @@ INT_PTR CChatRoomDlg::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam) } break; - case GC_SHOWFILTERMENU: - m_hwndFilter = CreateDialogParam(g_hInst, MAKEINTRESOURCE(IDD_FILTER), m_pContainer->hwnd, FilterWndProc, (LPARAM)this); - TranslateDialogDefault(m_hwndFilter); - - RECT rcFilter; - GetClientRect(m_hwndFilter, &rcFilter); - GetWindowRect(m_log.GetHwnd(), &rcLog); - - pt.x = rcLog.right; pt.y = rcLog.bottom; - ScreenToClient(m_pContainer->hwnd, &pt); - - SetWindowPos(m_hwndFilter, HWND_TOP, pt.x - rcFilter.right, pt.y - rcFilter.bottom, 0, 0, SWP_NOSIZE | SWP_SHOWWINDOW); - break; - - case GC_SHOWCOLORCHOOSER: - pci->ColorChooser(m_si, lParam == IDC_COLOR, m_hwnd, m_message.GetHwnd(), GetDlgItem(m_hwnd, lParam)); - break; - - case GC_SCROLLTOBOTTOM: - DM_ScrollToBottom(wParam, lParam); - return 0; - case WM_TIMER: if (wParam == TIMERID_FLASHWND) if (m_bCanFlashTab) @@ -2939,7 +2905,7 @@ INT_PTR CChatRoomDlg::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam) case WM_LBUTTONDBLCLK: if (LOWORD(lParam) < 30) - PostMessage(m_hwnd, GC_SCROLLTOBOTTOM, 0, 0); + ScrollToBottom(); break; case WM_CLOSE: @@ -2984,7 +2950,7 @@ INT_PTR CChatRoomDlg::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam) else { SendMessage(m_hwnd, WM_SIZE, 0, 0); if (lParam == 0) - PostMessage(m_hwnd, GC_SCROLLTOBOTTOM, 1, 1); + ScrollToBottom(); } return 0; @@ -3013,7 +2979,7 @@ INT_PTR CChatRoomDlg::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam) break; case DM_SMILEYOPTIONSCHANGED: - SendMessage(m_hwnd, GC_REDRAWLOG, 0, 1); + RedrawLog(); break; case EM_THEMECHANGED: diff --git a/plugins/TabSRMM/src/container.cpp b/plugins/TabSRMM/src/container.cpp index 4f33d16414..63f7d3e731 100644 --- a/plugins/TabSRMM/src/container.cpp +++ b/plugins/TabSRMM/src/container.cpp @@ -1238,7 +1238,7 @@ panel_found: dat->m_pPanel.Invalidate(TRUE);
}
else if (dat)
- SendMessage(dat->GetHwnd(), GC_UPDATESTATUSBAR, 0, 0);
+ dat->UpdateStatusBar();
}
break;
diff --git a/plugins/TabSRMM/src/msgdlgutils.cpp b/plugins/TabSRMM/src/msgdlgutils.cpp index 30c5fff688..368a29f5e7 100644 --- a/plugins/TabSRMM/src/msgdlgutils.cpp +++ b/plugins/TabSRMM/src/msgdlgutils.cpp @@ -441,7 +441,7 @@ void CTabBaseDlg::UpdateReadChars() const /////////////////////////////////////////////////////////////////////////////////////////
// update all status bar fields and force a redraw of the status bar.
-void CTabBaseDlg::UpdateStatusBar() const
+void CTabBaseDlg::tabUpdateStatusBar() const
{
if (m_pContainer->hwndStatus && m_pContainer->hwndActive == m_hwnd) {
if (!isChat()) {
diff --git a/plugins/TabSRMM/src/msgs.h b/plugins/TabSRMM/src/msgs.h index 7dc383a505..a88344eb34 100644 --- a/plugins/TabSRMM/src/msgs.h +++ b/plugins/TabSRMM/src/msgs.h @@ -361,6 +361,7 @@ public: virtual CThumbBase* tabCreateThumb(CProxyWindow*) const = 0;
virtual void tabClearLog() = 0;
+ void tabUpdateStatusBar() const;
static LONG_PTR CALLBACK StatusBarSubclassProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
@@ -422,7 +423,6 @@ public: void ShowPicture(bool showNewPic);
void StreamInEvents(MEVENT hDbEventFirst, int count, int fAppend, DBEVENTINFO *dbei_s);
void UpdateReadChars() const;
- void UpdateStatusBar() const;
int MsgWindowDrawHandler(WPARAM wParam, LPARAM lParam);
int MsgWindowUpdateMenu(HMENU submenu, int menuID);
@@ -456,7 +456,6 @@ public: virtual int Resizer(UTILRESIZECONTROL *urc) override;
- virtual void CloseTab(bool) override {};
virtual void UpdateTitle() override;
virtual INT_PTR DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) override;
@@ -499,7 +498,15 @@ public: virtual int Resizer(UTILRESIZECONTROL *urc) override;
+ virtual void AddLog() override;
virtual void CloseTab(bool bForced = false) override;
+ virtual void RedrawLog() override;
+ virtual void ScrollToBottom() override;
+ virtual void ShowFilterMenu() override;
+ virtual void StreamInEvents(LOGINFO* lin, bool bRedraw) override;
+ virtual void UpdateNickList() override;
+ virtual void UpdateOptions() override;
+ virtual void UpdateStatusBar() override;
virtual void UpdateTitle() override;
virtual INT_PTR DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) override;
@@ -518,7 +525,6 @@ public: void onDblClick_List(CCtrlListBox*);
- void StreamInEvents(LOGINFO* lin, SESSION_INFO *si, bool bRedraw);
void UpdateWindowState(UINT msg);
};
|