summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2017-03-11 20:46:09 +0300
committerGeorge Hazan <ghazan@miranda.im>2017-03-11 20:46:17 +0300
commit1a23578ffa4dd87cc024f362bd8b2fadfa087e23 (patch)
treeb98bd46ac4c6004d2f6c02615eafd7046e061018
parenta81484f320776e7c945e2f74172f979745dd870b (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
-rw-r--r--include/m_chat_int.h36
-rw-r--r--libs/win32/mir_app.libbin107430 -> 111428 bytes
-rw-r--r--libs/win64/mir_app.libbin102866 -> 106888 bytes
-rw-r--r--plugins/Scriver/src/chat/log.cpp4
-rw-r--r--plugins/Scriver/src/chat/main.cpp21
-rw-r--r--plugins/Scriver/src/chat/options.cpp4
-rw-r--r--plugins/Scriver/src/chat/window.cpp425
-rw-r--r--plugins/Scriver/src/msgdialog.cpp101
-rw-r--r--plugins/Scriver/src/msgoptions.cpp2
-rw-r--r--plugins/Scriver/src/msgs.h13
-rw-r--r--plugins/Scriver/src/tabs.cpp2
-rw-r--r--plugins/TabSRMM/src/chat_log.cpp26
-rw-r--r--plugins/TabSRMM/src/chat_main.cpp13
-rw-r--r--plugins/TabSRMM/src/chat_options.cpp6
-rw-r--r--plugins/TabSRMM/src/chat_tools.cpp2
-rw-r--r--plugins/TabSRMM/src/chat_window.cpp384
-rw-r--r--plugins/TabSRMM/src/container.cpp2
-rw-r--r--plugins/TabSRMM/src/msgdlgutils.cpp2
-rw-r--r--plugins/TabSRMM/src/msgs.h12
-rw-r--r--src/core/stdmsg/src/chat_manager.cpp6
-rw-r--r--src/core/stdmsg/src/chat_options.cpp4
-rw-r--r--src/core/stdmsg/src/chat_util.cpp4
-rw-r--r--src/core/stdmsg/src/chat_window.cpp379
-rw-r--r--src/core/stdmsg/src/msgs.h1
-rw-r--r--src/core/stdmsg/src/stdafx.h40
-rw-r--r--src/core/stdmsg/src/tabs.cpp150
-rw-r--r--src/mir_app/src/chat_manager.cpp11
-rw-r--r--src/mir_app/src/chat_svc.cpp35
-rw-r--r--src/mir_app/src/colorchooser.cpp4
-rw-r--r--src/mir_app/src/mir_app.def13
-rw-r--r--src/mir_app/src/mir_app64.def13
-rw-r--r--src/mir_app/src/srmm_base.cpp18
-rw-r--r--src/mir_app/src/srmm_util.cpp22
33 files changed, 889 insertions, 866 deletions
diff --git a/include/m_chat_int.h b/include/m_chat_int.h
index 5dd5596c13..3fdf5b984b 100644
--- a/include/m_chat_int.h
+++ b/include/m_chat_int.h
@@ -39,20 +39,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define GC_FAKE_EVENT MEVENT(0xBABABEDA)
-#define GC_UPDATESTATUSBAR (WM_USER+106)
-#define GC_SETWNDPROPS (WM_USER+108)
-#define GC_REDRAWLOG (WM_USER+109)
-#define GC_SHOWFILTERMENU (WM_USER+113)
-#define GC_REDRAWWINDOW (WM_USER+118)
-#define GC_SHOWCOLORCHOOSER (WM_USER+119)
-#define GC_ADDLOG (WM_USER+120)
-#define GC_UPDATENICKLIST (WM_USER+125)
-#define GC_SCROLLTOBOTTOM (WM_USER+129)
-#define GC_FIXTABICONS (WM_USER+132)
-#define GC_SETTABHIGHLIGHT (WM_USER+138)
-#define GC_SETMESSAGEHIGHLIGHT (WM_USER+139)
-#define GC_REDRAWLOG2 (WM_USER+140)
-
#define TIMERID_FLASHWND 1
#define GCW_TABROOM 10
@@ -341,7 +327,6 @@ struct CHAT_MANAGER
wchar_t* (*RemoveFormatting)(const wchar_t *pszText);
void (*ReloadSettings)(void);
- void (*ColorChooser)(SESSION_INFO *si, BOOL bFG, HWND hwndDlg, HWND hwndTarget, HWND hwndChooser);
int (*DoRtfToTags)(CMStringW &pszText, int iNumColors, COLORREF *pColors);
int logPixelSY, logPixelSX;
@@ -394,6 +379,12 @@ EXTERN_C MIR_APP_DLL(DWORD) CALLBACK Srmm_LogStreamCallback(DWORD_PTR dwCookie,
// receives char** as the first parameter
EXTERN_C MIR_APP_DLL(DWORD) CALLBACK Srmm_MessageStreamCallback(DWORD_PTR dwCookie, LPBYTE pbBuff, LONG cb, LONG *pcb);
+// handles rclick on some buttons
+EXTERN_C MIR_APP_DLL(LRESULT) CALLBACK Srmm_ButtonSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
+
+// updates options for all windows
+EXTERN_C MIR_APP_DLL(void) Chat_UpdateOptions();
+
/////////////////////////////////////////////////////////////////////////////////////////
class MIR_APP_EXPORT CSrmmBaseDialog : public CDlgBase
@@ -416,10 +407,21 @@ public:
bool m_bFilterEnabled, m_bNicklistEnabled;
bool m_bFGSet, m_bBGSet;
COLORREF m_iFG, m_iBG;
+ CCtrlButton *m_pFilter, *m_pColor, *m_pBkColor;
void ClearLog();
-
- virtual void CloseTab(bool bForced = false) PURE;
+ void RedrawLog2();
+ void ShowColorChooser(int iCtrlId);
+
+ virtual void AddLog();
+ virtual void CloseTab(bool = false) {}
+ virtual void RedrawLog() {}
+ virtual void ScrollToBottom() {}
+ virtual void ShowFilterMenu() {}
+ virtual void StreamInEvents(LOGINFO*, bool) {}
+ virtual void UpdateNickList() {}
+ virtual void UpdateOptions() {}
+ virtual void UpdateStatusBar() {}
virtual void UpdateTitle() PURE;
__forceinline bool isChat() const { return m_si != nullptr; }
diff --git a/libs/win32/mir_app.lib b/libs/win32/mir_app.lib
index a4b7c7c451..5ea3545b8b 100644
--- a/libs/win32/mir_app.lib
+++ b/libs/win32/mir_app.lib
Binary files differ
diff --git a/libs/win64/mir_app.lib b/libs/win64/mir_app.lib
index ab94ce99cb..afdf0ab9ac 100644
--- a/libs/win64/mir_app.lib
+++ b/libs/win64/mir_app.lib
Binary files differ
diff --git a/plugins/Scriver/src/chat/log.cpp b/plugins/Scriver/src/chat/log.cpp
index 87cb9fc8f1..02ba38a147 100644
--- a/plugins/Scriver/src/chat/log.cpp
+++ b/plugins/Scriver/src/chat/log.cpp
@@ -25,7 +25,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define EM_GETSCROLLPOS (WM_USER+221)
#endif
-void CChatRoomDlg::Log_StreamInEvent(LOGINFO* lin, BOOL bRedraw)
+void CChatRoomDlg::StreamInEvents(LOGINFO* lin, bool bRedraw)
{
if (m_hwnd == nullptr || lin == nullptr || m_si == nullptr)
return;
@@ -102,7 +102,7 @@ void CChatRoomDlg::Log_StreamInEvent(LOGINFO* lin, BOOL bRedraw)
// 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/Scriver/src/chat/main.cpp b/plugins/Scriver/src/chat/main.cpp
index 4a419ebde8..086b64c529 100644
--- a/plugins/Scriver/src/chat/main.cpp
+++ b/plugins/Scriver/src/chat/main.cpp
@@ -57,13 +57,13 @@ static void OnReplaceSession(SESSION_INFO *si)
static void OnNewUser(SESSION_INFO *si, USERINFO*)
{
if (si->pDlg)
- SendMessage(si->pDlg->GetHwnd(), GC_UPDATENICKLIST, 0, 0);
+ si->pDlg->UpdateNickList();
}
static void OnSetStatus(SESSION_INFO *si, int)
{
if (si->pDlg)
- PostMessage(si->pDlg->GetHwnd(), GC_FIXTABICONS, 0, 0);
+ si->pDlg->FixTabIcons();
}
static void OnFlashHighlight(SESSION_INFO *si, int bInactive)
@@ -73,7 +73,14 @@ static void OnFlashHighlight(SESSION_INFO *si, int bInactive)
if (g_Settings.bFlashWindowHighlight)
SendMessage(GetParent(si->pDlg->GetHwnd()), CM_STARTFLASHING, 0, 0);
- SendMessage(si->pDlg->GetHwnd(), GC_SETMESSAGEHIGHLIGHT, 0, 0);
+
+ si->wState |= GC_EVENT_HIGHLIGHT;
+ si->pDlg->FixTabIcons();
+ si->pDlg->UpdateTitle();
+
+ HWND hwndParent = GetParent(si->pDlg->GetHwnd());
+ if (g_Settings.bFlashWindowHighlight && GetActiveWindow() != si->pDlg->GetHwnd() && GetForegroundWindow() != hwndParent)
+ SendMessage(hwndParent, CM_STARTFLASHING, 0, 0);
}
static void OnFlashWindow(SESSION_INFO *si, int bInactive)
@@ -83,7 +90,13 @@ static void OnFlashWindow(SESSION_INFO *si, int bInactive)
if (g_Settings.bFlashWindow)
SendMessage(GetParent(si->pDlg->GetHwnd()), CM_STARTFLASHING, 0, 0);
- SendMessage(si->pDlg->GetHwnd(), GC_SETTABHIGHLIGHT, 0, 0);
+
+ si->pDlg->FixTabIcons();
+ si->pDlg->UpdateTitle();
+
+ HWND hwndParent = GetParent(si->pDlg->GetHwnd());
+ if (g_Settings.bFlashWindow && GetActiveWindow() != hwndParent && GetForegroundWindow() != hwndParent)
+ SendMessage(hwndParent, CM_STARTFLASHING, 0, 0);
}
static void OnCreateModule(MODULEINFO *mi)
diff --git a/plugins/Scriver/src/chat/options.cpp b/plugins/Scriver/src/chat/options.cpp
index 2f81c012e2..8ee73f0592 100644
--- a/plugins/Scriver/src/chat/options.cpp
+++ b/plugins/Scriver/src/chat/options.cpp
@@ -327,7 +327,7 @@ INT_PTR CALLBACK DlgProcOptions1(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM
SaveBranch(GetDlgItem(hwndDlg, IDC_CHAT_CHECKBOXES), branch4, _countof(branch4));
pci->ReloadSettings();
- pci->SM_BroadcastMessage(nullptr, GC_SETWNDPROPS, 0, 0, TRUE);
+ Chat_UpdateOptions();
}
return TRUE;
}
@@ -606,7 +606,7 @@ INT_PTR CALLBACK DlgProcOptions2(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM
pci->MM_FontsChanged();
pci->ReloadSettings();
- pci->SM_BroadcastMessage(nullptr, GC_SETWNDPROPS, 0, 0, TRUE);
+ Chat_UpdateOptions();
return TRUE;
}
break;
diff --git a/plugins/Scriver/src/chat/window.cpp b/plugins/Scriver/src/chat/window.cpp
index 97054b8993..3f77820882 100644
--- a/plugins/Scriver/src/chat/window.cpp
+++ b/plugins/Scriver/src/chat/window.cpp
@@ -428,7 +428,7 @@ INT_PTR CALLBACK CChatRoomDlg::FilterWndProc(HWND hwndDlg, UINT uMsg, WPARAM wPa
pDlg->m_iLogFilterFlags = iFlags;
if (pDlg->m_bFilterEnabled)
- SendMessage(pDlg->GetHwnd(), GC_REDRAWLOG, 0, 0);
+ pDlg->RedrawLog();
PostMessage(hwndDlg, WM_CLOSE, 0, 0);
}
break;
@@ -441,24 +441,6 @@ INT_PTR CALLBACK CChatRoomDlg::FilterWndProc(HWND hwndDlg, UINT uMsg, WPARAM wPa
return FALSE;
}
-static LRESULT CALLBACK ButtonSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
-{
- switch (msg) {
- case WM_RBUTTONUP:
- if (db_get_b(0, CHAT_MODULE, "RightClickFilter", 0) != 0) {
- if (GetDlgItem(GetParent(hwnd), IDC_FILTER) == hwnd)
- SendMessage(GetParent(hwnd), GC_SHOWFILTERMENU, 0, 0);
- if (GetDlgItem(GetParent(hwnd), IDC_COLOR) == hwnd)
- SendMessage(GetParent(hwnd), GC_SHOWCOLORCHOOSER, 0, IDC_COLOR);
- if (GetDlgItem(GetParent(hwnd), IDC_BKGCOLOR) == hwnd)
- SendMessage(GetParent(hwnd), GC_SHOWCOLORCHOOSER, 0, IDC_BKGCOLOR);
- }
- break;
- }
-
- return mir_callNextSubclass(hwnd, ButtonSubclassProc, msg, wParam, lParam);
-}
-
LRESULT CALLBACK CChatRoomDlg::LogSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
static BOOL inMenu = FALSE;
@@ -795,7 +777,24 @@ 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();
+}
+
+void CChatRoomDlg::FixTabIcons()
+{
+ HICON hIcon;
+ if (!(m_si->wState & GC_EVENT_HIGHLIGHT)) {
+ if (m_si->wState & STATE_TALK)
+ hIcon = (m_si->wStatus == ID_STATUS_ONLINE) ? pci->MM_FindModule(m_si->pszModule)->hOnlineTalkIcon : pci->MM_FindModule(m_si->pszModule)->hOfflineTalkIcon;
+ else
+ hIcon = (m_si->wStatus == ID_STATUS_ONLINE) ? pci->MM_FindModule(m_si->pszModule)->hOnlineIcon : pci->MM_FindModule(m_si->pszModule)->hOfflineIcon;
+ }
+ else hIcon = g_dat.hMsgIcon;
+
+ TabControlData tcd = {};
+ tcd.iFlags = TCDF_ICON;
+ tcd.hIcon = hIcon;
+ SendMessage(m_hwndParent, CM_UPDATETABCONTROL, (WPARAM)&tcd, (LPARAM)m_hwnd);
}
/////////////////////////////////////////////////////////////////////////////////////////
@@ -884,6 +883,9 @@ CChatRoomDlg::CChatRoomDlg(SESSION_INFO *si)
{
m_pLog = &m_log;
m_pEntry = &m_message;
+ m_pColor = &m_btnColor;
+ m_pBkColor = &m_btnBkColor;
+ m_pFilter = &m_btnFilter;
m_btnOk.OnClick = Callback(this, &CChatRoomDlg::onClick_Ok);
m_btnFilter.OnClick = Callback(this, &CChatRoomDlg::onClick_Filter);
@@ -919,12 +921,13 @@ void CChatRoomDlg::OnInitDialog()
RichUtil_SubClass(m_log.GetHwnd());
RichUtil_SubClass(m_nickList.GetHwnd());
- mir_subclassWindow(m_nickList.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_message.GetHwnd(), MessageSubclassProc);
+ mir_subclassWindow(m_nickList.GetHwnd(), NicklistSubclassProc);
+
+ mir_subclassWindow(m_btnFilter.GetHwnd(), Srmm_ButtonSubclassProc);
+ mir_subclassWindow(m_btnColor.GetHwnd(), Srmm_ButtonSubclassProc);
+ mir_subclassWindow(m_btnBkColor.GetHwnd(), Srmm_ButtonSubclassProc);
Srmm_CreateToolbarIcons(m_hwnd, BBBF_ISCHATBUTTON);
@@ -969,12 +972,12 @@ void CChatRoomDlg::OnInitDialog()
m_log.SendMsg(EM_HIDESELECTION, TRUE, 0);
- SendMessage(m_hwnd, GC_SETWNDPROPS, 0, 0);
- SendMessage(m_hwnd, GC_UPDATESTATUSBAR, 0, 0);
+ UpdateOptions();
+ UpdateStatusBar();
UpdateTitle();
SendMessage(m_hwndParent, CM_ADDCHILD, (WPARAM)this, 0);
- PostMessage(m_hwnd, GC_UPDATENICKLIST, 0, 0);
+ UpdateNickList();
NotifyLocalWinEvent(m_hContact, m_hwnd, MSG_WINDOW_EVT_OPEN);
}
@@ -1105,7 +1108,7 @@ void CChatRoomDlg::onClick_ShowList(CCtrlButton *pButton)
m_bNicklistEnabled = !m_bNicklistEnabled;
pButton->SendMsg(BM_SETIMAGE, IMAGE_ICON, (LPARAM)GetCachedIcon(m_bNicklistEnabled ? "chat_nicklist" : "chat_nicklist2"));
- SendMessage(m_hwnd, GC_SCROLLTOBOTTOM, 0, 0);
+ ScrollToBottom();
SendMessage(m_hwnd, WM_SIZE, 0, 0);
}
@@ -1117,9 +1120,9 @@ void CChatRoomDlg::onClick_Filter(CCtrlButton *pButton)
m_bFilterEnabled = !m_bFilterEnabled;
pButton->SendMsg(BM_SETIMAGE, IMAGE_ICON, (LPARAM)GetCachedIcon(m_bFilterEnabled ? "chat_filter" : "chat_filter2"));
if (m_bFilterEnabled && db_get_b(0, CHAT_MODULE, "RightClickFilter", 0) == 0)
- SendMessage(m_hwnd, GC_SHOWFILTERMENU, 0, 0);
+ ShowFilterMenu();
else
- SendMessage(m_hwnd, GC_REDRAWLOG, 0, 0);
+ RedrawLog();
}
void CChatRoomDlg::onClick_BIU(CCtrlButton *pButton)
@@ -1157,7 +1160,7 @@ void CChatRoomDlg::onClick_Color(CCtrlButton *pButton)
if (IsDlgButtonChecked(m_hwnd, IDC_COLOR)) {
if (db_get_b(0, 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 = pInfo->crColors[m_iFG];
@@ -1191,7 +1194,7 @@ void CChatRoomDlg::onClick_BkColor(CCtrlButton *pButton)
if (IsDlgButtonChecked(m_hwnd, IDC_BKGCOLOR)) {
if (db_get_b(0, 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 = pInfo->crColors[m_iBG];
@@ -1217,6 +1220,160 @@ void CChatRoomDlg::onChange_Message(CCtrlEdit *pEdit)
m_btnOk.Enable(GetRichTextLength(pEdit->GetHwnd(), 1200, FALSE) != 0);
}
+/////////////////////////////////////////////////////////////////////////////////////////
+
+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()
+{
+ if ((GetWindowLongPtr(m_log.GetHwnd(), GWL_STYLE) & WS_VSCROLL) == 0)
+ return;
+
+ SCROLLINFO sci = { 0 };
+ sci.cbSize = sizeof(sci);
+ sci.fMask = SIF_PAGE | SIF_RANGE;
+ GetScrollInfo(m_log.GetHwnd(), SB_VERT, &sci);
+
+ sci.fMask = SIF_POS;
+ sci.nPos = sci.nMax - sci.nPage + 1;
+ SetScrollInfo(m_log.GetHwnd(), SB_VERT, &sci, TRUE);
+
+ CHARRANGE sel;
+ sel.cpMin = sel.cpMax = GetRichTextLength(m_log.GetHwnd(), CP_ACP, FALSE);
+ m_log.SendMsg(EM_EXSETSEL, 0, (LPARAM)&sel);
+ PostMessage(m_log.GetHwnd(), WM_VSCROLL, MAKEWPARAM(SB_BOTTOM, 0), 0);
+}
+
+void CChatRoomDlg::ShowFilterMenu()
+{
+ HWND hwnd = CreateDialogParam(g_hInst, MAKEINTRESOURCE(IDD_FILTER), m_hwnd, FilterWndProc, (LPARAM)this);
+ TranslateDialogDefault(hwnd);
+
+ RECT rc;
+ GetWindowRect(m_btnFilter.GetHwnd(), &rc);
+ SetWindowPos(hwnd, HWND_TOP, rc.left - 85, (IsWindowVisible(m_btnFilter.GetHwnd()) || IsWindowVisible(m_btnBold.GetHwnd())) ? rc.top - 206 : rc.top - 186, 0, 0, SWP_NOSIZE | SWP_SHOWWINDOW);
+}
+
+void CChatRoomDlg::UpdateNickList()
+{
+ m_nickList.SendMsg(WM_SETREDRAW, FALSE, 0);
+ m_nickList.SendMsg(LB_RESETCONTENT, 0, 0);
+ for (int index = 0; index < m_si->nUsersInNicklist; index++) {
+ USERINFO *ui = pci->SM_GetUserFromIndex(m_si->ptszID, m_si->pszModule, index);
+ if (ui) {
+ char szIndicator = SM_GetStatusIndicator(m_si, ui);
+ if (szIndicator > '\0') {
+ static wchar_t ptszBuf[128];
+ mir_snwprintf(ptszBuf, L"%c%s", szIndicator, ui->pszNick);
+ m_nickList.SendMsg(LB_ADDSTRING, 0, (LPARAM)ptszBuf);
+ }
+ else m_nickList.SendMsg(LB_ADDSTRING, 0, (LPARAM)ui->pszNick);
+ }
+ }
+ m_nickList.SendMsg(WM_SETREDRAW, TRUE, 0);
+ InvalidateRect(m_nickList.GetHwnd(), nullptr, FALSE);
+ UpdateWindow(m_nickList.GetHwnd());
+ UpdateTitle();
+}
+
+void CChatRoomDlg::UpdateOptions()
+{
+ m_btnShowList.SendMsg(BM_SETIMAGE, IMAGE_ICON, (LPARAM)GetCachedIcon(m_bNicklistEnabled ? "chat_nicklist" : "chat_nicklist2"));
+ m_btnFilter.SendMsg(BM_SETIMAGE, IMAGE_ICON, (LPARAM)GetCachedIcon(m_bFilterEnabled ? "chat_filter" : "chat_filter2"));
+ {
+ MODULEINFO *pInfo = pci->MM_FindModule(m_si->pszModule);
+ 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_btnChanMgr.Enable(pInfo->bChanMgr);
+ }
+ }
+
+ UpdateStatusBar();
+ UpdateTitle();
+ FixTabIcons();
+
+ m_log.SendMsg(EM_SETBKGNDCOLOR, 0, g_Settings.crLogBackground);
+
+ // messagebox
+ COLORREF crFore;
+ LoadMsgDlgFont(MSGFONTID_MESSAGEAREA, nullptr, &crFore);
+
+ CHARFORMAT2 cf;
+ cf.cbSize = sizeof(CHARFORMAT2);
+ cf.dwMask = CFM_COLOR | CFM_BOLD | CFM_UNDERLINE | CFM_BACKCOLOR;
+ cf.dwEffects = 0;
+ cf.crTextColor = crFore;
+ cf.crBackColor = db_get_dw(0, SRMMMOD, SRMSGSET_INPUTBKGCOLOUR, SRMSGDEFSET_INPUTBKGCOLOUR);
+ m_message.SendMsg(EM_SETBKGNDCOLOR, 0, db_get_dw(0, SRMMMOD, SRMSGSET_INPUTBKGCOLOUR, SRMSGDEFSET_INPUTBKGCOLOUR));
+ m_message.SendMsg(WM_SETFONT, (WPARAM)g_Settings.MessageBoxFont, MAKELPARAM(TRUE, 0));
+ m_message.SendMsg(EM_SETCHARFORMAT, SCF_ALL, (LPARAM)&cf);
+ {
+ // nicklist
+ int ih = GetTextPixelSize(L"AQG_glo'", g_Settings.UserListFont, FALSE);
+ int ih2 = GetTextPixelSize(L"AQG_glo'", g_Settings.UserListHeadingsFont, FALSE);
+ int height = db_get_b(0, CHAT_MODULE, "NicklistRowDist", 12);
+ int font = ih > ih2 ? ih : ih2;
+ // make sure we have space for icon!
+ if (db_get_b(0, CHAT_MODULE, "ShowContactStatus", 0))
+ font = font > 16 ? font : 16;
+
+ m_nickList.SendMsg(LB_SETITEMHEIGHT, 0, height > font ? height : font);
+ InvalidateRect(m_nickList.GetHwnd(), nullptr, TRUE);
+ }
+ m_message.SendMsg(EM_REQUESTRESIZE, 0, 0);
+ SendMessage(m_hwnd, WM_SIZE, 0, 0);
+ RedrawLog2();
+}
+
+void CChatRoomDlg::UpdateStatusBar()
+{
+ MODULEINFO *mi = pci->MM_FindModule(m_si->pszModule);
+ wchar_t szTemp[512];
+ mir_snwprintf(szTemp, L"%s : %s", mi->ptszModDispName, m_si->ptszStatusbarText ? m_si->ptszStatusbarText : L"");
+
+ StatusBarData sbd;
+ sbd.iItem = 0;
+ sbd.iFlags = SBDF_TEXT | SBDF_ICON;
+ sbd.hIcon = m_si->wStatus == ID_STATUS_ONLINE ? mi->hOnlineIcon : mi->hOfflineIcon;
+ sbd.pszText = szTemp;
+ SendMessage(m_hwndParent, CM_UPDATESTATUSBAR, (WPARAM)&sbd, (LPARAM)m_hwnd);
+
+ sbd.iItem = 1;
+ sbd.hIcon = nullptr;
+ sbd.pszText = L"";
+ SendMessage(m_hwndParent, CM_UPDATESTATUSBAR, (WPARAM)&sbd, (LPARAM)m_hwnd);
+
+ StatusIconData sid = { sizeof(sid) };
+ sid.szModule = SRMMMOD;
+ Srmm_ModifyIcon(m_hContact, &sid);
+}
+
void CChatRoomDlg::UpdateTitle()
{
TitleBarData tbd = {};
@@ -1262,86 +1419,8 @@ INT_PTR CChatRoomDlg::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam)
POINT pt;
HICON hIcon;
TabControlData tcd;
- wchar_t szTemp[512];
switch (uMsg) {
- case GC_SETWNDPROPS:
- m_btnShowList.SendMsg(BM_SETIMAGE, IMAGE_ICON, (LPARAM)GetCachedIcon(m_bNicklistEnabled ? "chat_nicklist" : "chat_nicklist2"));
- m_btnFilter.SendMsg(BM_SETIMAGE, IMAGE_ICON, (LPARAM)GetCachedIcon(m_bFilterEnabled ? "chat_filter" : "chat_filter2"));
- {
- MODULEINFO *pInfo = pci->MM_FindModule(m_si->pszModule);
- 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_btnChanMgr.Enable(pInfo->bChanMgr);
- }
- }
-
- SendMessage(m_hwnd, GC_UPDATESTATUSBAR, 0, 0);
- UpdateTitle();
- SendMessage(m_hwnd, GC_FIXTABICONS, 0, 0);
-
- m_log.SendMsg(EM_SETBKGNDCOLOR, 0, g_Settings.crLogBackground);
-
- // messagebox
- COLORREF crFore;
- LoadMsgDlgFont(MSGFONTID_MESSAGEAREA, nullptr, &crFore);
-
- CHARFORMAT2 cf;
- cf.cbSize = sizeof(CHARFORMAT2);
- cf.dwMask = CFM_COLOR | CFM_BOLD | CFM_UNDERLINE | CFM_BACKCOLOR;
- cf.dwEffects = 0;
- cf.crTextColor = crFore;
- cf.crBackColor = db_get_dw(0, SRMMMOD, SRMSGSET_INPUTBKGCOLOUR, SRMSGDEFSET_INPUTBKGCOLOUR);
- m_message.SendMsg(EM_SETBKGNDCOLOR, 0, db_get_dw(0, SRMMMOD, SRMSGSET_INPUTBKGCOLOUR, SRMSGDEFSET_INPUTBKGCOLOUR));
- m_message.SendMsg(WM_SETFONT, (WPARAM)g_Settings.MessageBoxFont, MAKELPARAM(TRUE, 0));
- m_message.SendMsg(EM_SETCHARFORMAT, SCF_ALL, (LPARAM)&cf);
- {
- // nicklist
- int ih = GetTextPixelSize(L"AQG_glo'", g_Settings.UserListFont, FALSE);
- int ih2 = GetTextPixelSize(L"AQG_glo'", g_Settings.UserListHeadingsFont, FALSE);
- int height = db_get_b(0, CHAT_MODULE, "NicklistRowDist", 12);
- int font = ih > ih2 ? ih : ih2;
- // make sure we have space for icon!
- if (db_get_b(0, CHAT_MODULE, "ShowContactStatus", 0))
- font = font > 16 ? font : 16;
-
- m_nickList.SendMsg(LB_SETITEMHEIGHT, 0, height > font ? height : font);
- InvalidateRect(m_nickList.GetHwnd(), nullptr, TRUE);
- }
- m_message.SendMsg(EM_REQUESTRESIZE, 0, 0);
- SendMessage(m_hwnd, WM_SIZE, 0, 0);
- SendMessage(m_hwnd, GC_REDRAWLOG2, 0, 0);
- break;
-
- case GC_UPDATESTATUSBAR:
- {
- MODULEINFO *mi = pci->MM_FindModule(m_si->pszModule);
- hIcon = m_si->wStatus == ID_STATUS_ONLINE ? mi->hOnlineIcon : mi->hOfflineIcon;
- mir_snwprintf(szTemp, L"%s : %s", mi->ptszModDispName, m_si->ptszStatusbarText ? m_si->ptszStatusbarText : L"");
-
- StatusBarData sbd;
- sbd.iItem = 0;
- sbd.iFlags = SBDF_TEXT | SBDF_ICON;
- sbd.hIcon = hIcon;
- sbd.pszText = szTemp;
- SendMessage(m_hwndParent, CM_UPDATESTATUSBAR, (WPARAM)&sbd, (LPARAM)m_hwnd);
-
- sbd.iItem = 1;
- sbd.hIcon = nullptr;
- sbd.pszText = L"";
- SendMessage(m_hwndParent, CM_UPDATESTATUSBAR, (WPARAM)&sbd, (LPARAM)m_hwnd);
-
- StatusIconData sid = { sizeof(sid) };
- sid.szModule = SRMMMOD;
- Srmm_ModifyIcon(m_hContact, &sid);
- }
- break;
-
case DM_SWITCHINFOBAR:
case DM_SWITCHTOOLBAR:
SendMessage(m_hwnd, WM_SIZE, 0, 0);
@@ -1349,7 +1428,7 @@ INT_PTR CChatRoomDlg::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam)
case WM_SIZE:
if (wParam == SIZE_MAXIMIZED)
- PostMessage(m_hwnd, GC_SCROLLTOBOTTOM, 0, 0);
+ ScrollToBottom();
if (IsIconic(m_hwnd)) break;
@@ -1359,80 +1438,12 @@ INT_PTR CChatRoomDlg::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam)
}
break;
- 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++;
- }
- Log_StreamInEvent(pLog, TRUE);
- mir_forkthread(phase2, m_si);
- }
- else Log_StreamInEvent(m_si->pLogEnd, TRUE);
- }
- else ClearLog();
- break;
-
- case GC_REDRAWLOG2:
- m_si->LastTime = 0;
- if (m_si->pLog)
- Log_StreamInEvent(m_si->pLogEnd, TRUE);
- break;
-
- case GC_ADDLOG:
- if (m_si->pLogEnd)
- Log_StreamInEvent(m_si->pLog, FALSE);
- else
- ClearLog();
- break;
-
case DM_UPDATETABCONTROL:
tcd.iFlags = TCDF_TEXT;
tcd.pszText = m_si->ptszName;
SendMessage(m_hwndParent, CM_UPDATETABCONTROL, (WPARAM)&tcd, (LPARAM)m_hwnd);
// fall through
- case GC_FIXTABICONS:
- if (!(m_si->wState & GC_EVENT_HIGHLIGHT)) {
- if (m_si->wState & STATE_TALK)
- hIcon = (m_si->wStatus == ID_STATUS_ONLINE) ? pci->MM_FindModule(m_si->pszModule)->hOnlineTalkIcon : pci->MM_FindModule(m_si->pszModule)->hOfflineTalkIcon;
- else
- hIcon = (m_si->wStatus == ID_STATUS_ONLINE) ? pci->MM_FindModule(m_si->pszModule)->hOnlineIcon : pci->MM_FindModule(m_si->pszModule)->hOfflineIcon;
- }
- else hIcon = g_dat.hMsgIcon;
-
- tcd.iFlags = TCDF_ICON;
- tcd.hIcon = hIcon;
- SendMessage(m_hwndParent, CM_UPDATETABCONTROL, (WPARAM)&tcd, (LPARAM)m_hwnd);
- break;
-
- case GC_SETMESSAGEHIGHLIGHT:
- m_si->wState |= GC_EVENT_HIGHLIGHT;
- SendMessage(m_hwnd, GC_FIXTABICONS, 0, 0);
- UpdateTitle();
- if (g_Settings.bFlashWindowHighlight && GetActiveWindow() != m_hwnd && GetForegroundWindow() != m_hwndParent)
- SendMessage(m_hwndParent, CM_STARTFLASHING, 0, 0);
- break;
-
- case GC_SETTABHIGHLIGHT:
- SendMessage(m_hwnd, GC_FIXTABICONS, 0, 0);
- UpdateTitle();
- if (g_Settings.bFlashWindow && GetActiveWindow() != m_hwndParent && GetForegroundWindow() != m_hwndParent)
- SendMessage(m_hwndParent, CM_STARTFLASHING, 0, 0);
- break;
-
case DM_ACTIVATE:
if (m_si->wState & STATE_TALK) {
m_si->wState &= ~STATE_TALK;
@@ -1446,7 +1457,7 @@ INT_PTR CChatRoomDlg::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam)
pcli->pfnRemoveEvent(m_hContact, GC_FAKE_EVENT);
}
- SendMessage(m_hwnd, GC_FIXTABICONS, 0, 0);
+ FixTabIcons();
if (!m_si->pDlg) {
ShowRoom(m_si);
SendMessage(m_hwnd, WM_MOUSEACTIVATE, 0, 0);
@@ -1524,58 +1535,6 @@ INT_PTR CChatRoomDlg::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam)
}
break;
- case GC_UPDATENICKLIST:
- m_nickList.SendMsg(WM_SETREDRAW, FALSE, 0);
- m_nickList.SendMsg(LB_RESETCONTENT, 0, 0);
- for (int index = 0; index < m_si->nUsersInNicklist; index++) {
- USERINFO *ui = pci->SM_GetUserFromIndex(m_si->ptszID, m_si->pszModule, index);
- if (ui) {
- char szIndicator = SM_GetStatusIndicator(m_si, ui);
- if (szIndicator > '\0') {
- static wchar_t ptszBuf[128];
- mir_snwprintf(ptszBuf, L"%c%s", szIndicator, ui->pszNick);
- m_nickList.SendMsg(LB_ADDSTRING, 0, (LPARAM)ptszBuf);
- }
- else m_nickList.SendMsg(LB_ADDSTRING, 0, (LPARAM)ui->pszNick);
- }
- }
- m_nickList.SendMsg(WM_SETREDRAW, TRUE, 0);
- InvalidateRect(m_nickList.GetHwnd(), nullptr, FALSE);
- UpdateWindow(m_nickList.GetHwnd());
- UpdateTitle();
- break;
-
- case GC_SHOWFILTERMENU:
- {
- HWND hwnd = CreateDialogParam(g_hInst, MAKEINTRESOURCE(IDD_FILTER), m_hwnd, FilterWndProc, (LPARAM)this);
- TranslateDialogDefault(hwnd);
- GetWindowRect(m_btnFilter.GetHwnd(), &rc);
- SetWindowPos(hwnd, HWND_TOP, rc.left - 85, (IsWindowVisible(m_btnFilter.GetHwnd()) || IsWindowVisible(m_btnBold.GetHwnd())) ? rc.top - 206 : rc.top - 186, 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:
- if ((GetWindowLongPtr(m_log.GetHwnd(), GWL_STYLE) & WS_VSCROLL) != 0) {
- SCROLLINFO sci = { 0 };
- sci.cbSize = sizeof(sci);
- sci.fMask = SIF_PAGE | SIF_RANGE;
- GetScrollInfo(m_log.GetHwnd(), SB_VERT, &sci);
-
- sci.fMask = SIF_POS;
- sci.nPos = sci.nMax - sci.nPage + 1;
- SetScrollInfo(m_log.GetHwnd(), SB_VERT, &sci, TRUE);
-
- CHARRANGE sel;
- sel.cpMin = sel.cpMax = GetRichTextLength(m_log.GetHwnd(), CP_ACP, FALSE);
- m_log.SendMsg(EM_EXSETSEL, 0, (LPARAM)&sel);
- PostMessage(m_log.GetHwnd(), WM_VSCROLL, MAKEWPARAM(SB_BOTTOM, 0), 0);
- }
- break;
-
case WM_ACTIVATE:
if (LOWORD(wParam) != WA_ACTIVE)
break;
@@ -1645,7 +1604,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();
else
SendMessage(m_hwndParent, WM_SYSCOMMAND, SC_MINIMIZE, 0);
break;
diff --git a/plugins/Scriver/src/msgdialog.cpp b/plugins/Scriver/src/msgdialog.cpp
index 2326d472d9..c00341ed28 100644
--- a/plugins/Scriver/src/msgdialog.cpp
+++ b/plugins/Scriver/src/msgdialog.cpp
@@ -1061,6 +1061,50 @@ void CSrmmWindow::onChanged_Splitter(CSplitter *pSplitter)
m_pParent->iSplitterY = rc.bottom - pSplitter->GetPos();
}
+void CSrmmWindow::UpdateStatusBar()
+{
+ if (m_pParent->hwndActive == m_hwnd) {
+ wchar_t szText[256];
+ StatusBarData sbd = { 0 };
+ sbd.iFlags = SBDF_TEXT | SBDF_ICON;
+ if (m_iMessagesInProgress && (g_dat.flags & SMF_SHOWPROGRESS)) {
+ sbd.hIcon = GetCachedIcon("scriver_DELIVERING");
+ sbd.pszText = szText;
+ mir_snwprintf(szText, TranslateT("Sending in progress: %d message(s) left..."), m_iMessagesInProgress);
+ }
+ else if (m_nTypeSecs) {
+ sbd.hIcon = GetCachedIcon("scriver_TYPING");
+ sbd.pszText = szText;
+ mir_snwprintf(szText, TranslateT("%s is typing a message..."), pcli->pfnGetContactDisplayName(m_hContact, 0));
+ m_nTypeSecs--;
+ }
+ else if (m_lastMessage) {
+ wchar_t date[64], time[64];
+ TimeZone_PrintTimeStamp(nullptr, m_lastMessage, L"d", date, _countof(date), 0);
+ TimeZone_PrintTimeStamp(nullptr, m_lastMessage, L"t", time, _countof(time), 0);
+ mir_snwprintf(szText, TranslateT("Last message received on %s at %s."), date, time);
+ sbd.pszText = szText;
+ }
+ else sbd.pszText = L"";
+
+ SendMessage(m_hwndParent, CM_UPDATESTATUSBAR, (WPARAM)&sbd, (LPARAM)m_hwnd);
+ UpdateReadChars();
+
+ StatusIconData sid = { sizeof(sid) };
+ sid.szModule = SRMMMOD;
+ sid.flags = MBF_DISABLED;
+ Srmm_ModifyIcon(m_hContact, &sid);
+ sid.dwId = 1;
+ if (IsTypingNotificationSupported() && g_dat.flags2 & SMF2_SHOWTYPINGSWITCH)
+ sid.flags = (db_get_b(m_hContact, SRMMMOD, SRMSGSET_TYPING,
+ db_get_b(0, SRMMMOD, SRMSGSET_TYPINGNEW, SRMSGDEFSET_TYPINGNEW))) ? 0 : MBF_DISABLED;
+ else
+ sid.flags = MBF_HIDDEN;
+
+ Srmm_ModifyIcon(m_hContact, &sid);
+ }
+}
+
/////////////////////////////////////////////////////////////////////////////////////////
static const wchar_t *titleTokenNames[] = { L"%name%", L"%status%", L"%statusmsg%", L"%account%" };
@@ -1168,7 +1212,7 @@ INT_PTR CSrmmWindow::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam)
break;
case DM_CHANGEICONS:
- SendMessage(m_hwnd, GC_UPDATESTATUSBAR, 0, 0);
+ UpdateStatusBar();
SetStatusIcon();
case DM_UPDATEICON:
@@ -1275,7 +1319,7 @@ INT_PTR CSrmmWindow::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam)
SendMessage(m_hwnd, DM_REMAKELOG, 0, 0);
UpdateTitle();
SendMessage(m_hwnd, DM_UPDATETABCONTROL, 0, 0);
- SendMessage(m_hwnd, GC_UPDATESTATUSBAR, 0, 0);
+ UpdateStatusBar();
m_message.SendMsg(EM_REQUESTRESIZE, 0, 0);
SetupInfobar(m_pInfobarData);
break;
@@ -1473,7 +1517,7 @@ INT_PTR CSrmmWindow::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam)
if (!IsWindowVisible(m_hwndParent) && m_hDbUnreadEventFirst == 0)
m_hDbUnreadEventFirst = hDbEvent;
m_lastMessage = dbei.timestamp;
- SendMessage(m_hwnd, GC_UPDATESTATUSBAR, 0, 0);
+ UpdateStatusBar();
if (GetForegroundWindow() == m_hwndParent && m_pParent->hwndActive == m_hwnd)
SkinPlaySound("RecvMsgActive");
else SkinPlaySound("RecvMsgInactive");
@@ -1498,49 +1542,6 @@ INT_PTR CSrmmWindow::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam)
}
break;
- case GC_UPDATESTATUSBAR:
- if (m_pParent->hwndActive == m_hwnd) {
- wchar_t szText[256];
- StatusBarData sbd = { 0 };
- sbd.iFlags = SBDF_TEXT | SBDF_ICON;
- if (m_iMessagesInProgress && (g_dat.flags & SMF_SHOWPROGRESS)) {
- sbd.hIcon = GetCachedIcon("scriver_DELIVERING");
- sbd.pszText = szText;
- mir_snwprintf(szText, TranslateT("Sending in progress: %d message(s) left..."), m_iMessagesInProgress);
- }
- else if (m_nTypeSecs) {
- sbd.hIcon = GetCachedIcon("scriver_TYPING");
- sbd.pszText = szText;
- mir_snwprintf(szText, TranslateT("%s is typing a message..."), pcli->pfnGetContactDisplayName(m_hContact, 0));
- m_nTypeSecs--;
- }
- else if (m_lastMessage) {
- wchar_t date[64], time[64];
- TimeZone_PrintTimeStamp(nullptr, m_lastMessage, L"d", date, _countof(date), 0);
- TimeZone_PrintTimeStamp(nullptr, m_lastMessage, L"t", time, _countof(time), 0);
- mir_snwprintf(szText, TranslateT("Last message received on %s at %s."), date, time);
- sbd.pszText = szText;
- }
- else sbd.pszText = L"";
-
- SendMessage(m_hwndParent, CM_UPDATESTATUSBAR, (WPARAM)&sbd, (LPARAM)m_hwnd);
- UpdateReadChars();
-
- StatusIconData sid = { sizeof(sid) };
- sid.szModule = SRMMMOD;
- sid.flags = MBF_DISABLED;
- Srmm_ModifyIcon(m_hContact, &sid);
- sid.dwId = 1;
- if (IsTypingNotificationSupported() && g_dat.flags2 & SMF2_SHOWTYPINGSWITCH)
- sid.flags = (db_get_b(m_hContact, SRMMMOD, SRMSGSET_TYPING,
- db_get_b(0, SRMMMOD, SRMSGSET_TYPINGNEW, SRMSGDEFSET_TYPINGNEW))) ? 0 : MBF_DISABLED;
- else
- sid.flags = MBF_HIDDEN;
-
- Srmm_ModifyIcon(m_hContact, &sid);
- }
- break;
-
case DM_CLEARLOG:
if (m_hwndIeview != nullptr) {
IEVIEWEVENT evt = { sizeof(evt) };
@@ -1569,14 +1570,14 @@ INT_PTR CSrmmWindow::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam)
m_nTypeSecs--;
else {
m_bShowTyping = false;
- SendMessage(m_hwnd, GC_UPDATESTATUSBAR, 0, 0);
+ UpdateStatusBar();
SendMessage(m_hwnd, DM_UPDATEICON, 0, 0);
}
}
else {
if (m_nTypeSecs) {
m_bShowTyping = true;
- SendMessage(m_hwnd, GC_UPDATESTATUSBAR, 0, 0);
+ UpdateStatusBar();
SendMessage(m_hwnd, DM_UPDATEICON, 0, 0);
}
}
@@ -1612,14 +1613,14 @@ INT_PTR CSrmmWindow::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam)
case DM_SHOWMESSAGESENDING:
SetTimer(m_hwnd, TIMERID_MSGSEND, 1000, nullptr);
if (g_dat.flags & SMF_SHOWPROGRESS)
- SendMessage(GetHwnd(), GC_UPDATESTATUSBAR, 0, 0);
+ UpdateStatusBar();
break;
case DM_STOPMESSAGESENDING:
if (m_iMessagesInProgress > 0) {
m_iMessagesInProgress--;
if (g_dat.flags & SMF_SHOWPROGRESS)
- SendMessage(GetHwnd(), GC_UPDATESTATUSBAR, 0, 0);
+ UpdateStatusBar();
}
if (m_iMessagesInProgress == 0)
KillTimer(m_hwnd, TIMERID_MSGSEND);
diff --git a/plugins/Scriver/src/msgoptions.cpp b/plugins/Scriver/src/msgoptions.cpp
index 0888246fb5..1a638ffea0 100644
--- a/plugins/Scriver/src/msgoptions.cpp
+++ b/plugins/Scriver/src/msgoptions.cpp
@@ -239,7 +239,7 @@ static void ApplyChanges(int i)
ReloadGlobals();
WindowList_Broadcast(g_dat.hParentWindowList, DM_OPTIONSAPPLIED, 0, 0);
WindowList_Broadcast(pci->hWindowList, DM_OPTIONSAPPLIED, 0, 0);
- pci->SM_BroadcastMessage(nullptr, GC_SETWNDPROPS, 0, 0, TRUE);
+ Chat_UpdateOptions();
}
}
diff --git a/plugins/Scriver/src/msgs.h b/plugins/Scriver/src/msgs.h
index 55a97e5a83..df69df5f9a 100644
--- a/plugins/Scriver/src/msgs.h
+++ b/plugins/Scriver/src/msgs.h
@@ -150,7 +150,8 @@ public:
virtual void OnInitDialog() override;
virtual void OnDestroy() override;
-
+
+ virtual void UpdateStatusBar() override;
virtual void UpdateTitle() override;
virtual INT_PTR DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) override;
@@ -176,7 +177,6 @@ class CChatRoomDlg : public CScriverWindow
CSplitter m_splitterX, m_splitterY;
void MessageDialogResize(int w, int h);
- void Log_StreamInEvent(LOGINFO* lin, BOOL bRedraw);
static LRESULT CALLBACK MessageSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
static LRESULT CALLBACK LogSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
@@ -194,6 +194,13 @@ public:
virtual INT_PTR DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam) 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;
void onChange_Message(CCtrlEdit*);
@@ -212,6 +219,8 @@ public:
void OnSplitterX(CSplitter*);
void OnSplitterY(CSplitter*);
+
+ void FixTabIcons();
};
#define HM_DBEVENTADDED (WM_USER+10)
diff --git a/plugins/Scriver/src/tabs.cpp b/plugins/Scriver/src/tabs.cpp
index dc77083ee8..17e62a0db6 100644
--- a/plugins/Scriver/src/tabs.cpp
+++ b/plugins/Scriver/src/tabs.cpp
@@ -193,7 +193,7 @@ static void ActivateChild(ParentWindowData *dat, HWND child)
HWND prev = dat->hwndActive;
dat->hwndActive = child;
SetupStatusBar(dat);
- SendMessage(dat->hwndActive, GC_UPDATESTATUSBAR, 0, 0);
+ pDlg->UpdateStatusBar();
pDlg->UpdateTitle();
SendMessage(dat->hwndActive, WM_SIZE, 0, 0);
ShowWindow(dat->hwndActive, SW_SHOWNOACTIVATE);
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);
};
diff --git a/src/core/stdmsg/src/chat_manager.cpp b/src/core/stdmsg/src/chat_manager.cpp
index c0e881954d..bd9d3cacb8 100644
--- a/src/core/stdmsg/src/chat_manager.cpp
+++ b/src/core/stdmsg/src/chat_manager.cpp
@@ -88,7 +88,7 @@ static void OnReplaceSession(SESSION_INFO *si)
static void OnNewUser(SESSION_INFO *si, USERINFO*)
{
if (si->pDlg)
- SendMessage(si->pDlg->GetHwnd(), GC_UPDATENICKLIST, 0, 0);
+ si->pDlg->UpdateNickList();
}
static void OnFlashHighlight(SESSION_INFO *si, int bInactive)
@@ -99,7 +99,7 @@ static void OnFlashHighlight(SESSION_INFO *si, int bInactive)
if (!g_Settings.bTabsEnable && si->pDlg && g_Settings.bFlashWindowHighlight)
SetTimer(si->pDlg->GetHwnd(), TIMERID_FLASHWND, 900, NULL);
if (g_Settings.bTabsEnable && si->pDlg)
- SendMessage(si->pDlg->GetHwnd(), GC_SETMESSAGEHIGHLIGHT, 0, (LPARAM)si->pDlg);
+ pDialog->SetMessageHighlight(si->pDlg);
}
static void OnFlashWindow(SESSION_INFO *si, int bInactive)
@@ -110,7 +110,7 @@ static void OnFlashWindow(SESSION_INFO *si, int bInactive)
if (!g_Settings.bTabsEnable && si->pDlg && g_Settings.bFlashWindow)
SetTimer(si->pDlg->GetHwnd(), TIMERID_FLASHWND, 900, NULL);
if (g_Settings.bTabsEnable && si->pDlg)
- SendMessage(si->pDlg->GetHwnd(), GC_SETTABHIGHLIGHT, 0, (LPARAM)si->pDlg);
+ pDialog->SetTabHighlight(si->pDlg);
}
static BOOL DoTrayIcon(SESSION_INFO *si, GCEVENT *gce)
diff --git a/src/core/stdmsg/src/chat_options.cpp b/src/core/stdmsg/src/chat_options.cpp
index 13b6d7f0af..b5a75b4241 100644
--- a/src/core/stdmsg/src/chat_options.cpp
+++ b/src/core/stdmsg/src/chat_options.cpp
@@ -433,7 +433,7 @@ static INT_PTR CALLBACK DlgProcOptions1(HWND hwndDlg, UINT uMsg, WPARAM, LPARAM
pci->SM_BroadcastMessage(NULL, WM_CLOSE, 0, 1, FALSE);
g_Settings.bTabsEnable = db_get_b(NULL, CHAT_MODULE, "Tabs", 1) != 0;
}
- else pci->SM_BroadcastMessage(NULL, GC_SETWNDPROPS, 0, 0, TRUE);
+ else Chat_UpdateOptions();
return TRUE;
}
@@ -641,7 +641,7 @@ static INT_PTR CALLBACK DlgProcOptions2(HWND hwndDlg, UINT uMsg, WPARAM wParam,
db_unset(NULL, CHAT_MODULE, "NicklistRowDist");
pci->ReloadSettings();
- pci->SM_BroadcastMessage(NULL, GC_SETWNDPROPS, 0, 0, TRUE);
+ Chat_UpdateOptions();
return TRUE;
}
break;
diff --git a/src/core/stdmsg/src/chat_util.cpp b/src/core/stdmsg/src/chat_util.cpp
index f4d514d635..d163e2e83a 100644
--- a/src/core/stdmsg/src/chat_util.cpp
+++ b/src/core/stdmsg/src/chat_util.cpp
@@ -21,7 +21,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "stdafx.h"
-void CChatRoomDlg::Log_StreamInEvent(LOGINFO *lin, BOOL bRedraw)
+void CChatRoomDlg::StreamInEvents(LOGINFO *lin, bool bRedraw)
{
if (m_hwnd == nullptr || lin == nullptr || m_si == nullptr)
return;
@@ -102,7 +102,7 @@ void CChatRoomDlg::Log_StreamInEvent(LOGINFO *lin, BOOL bRedraw)
// 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
SendMessage(m_log.GetHwnd(), EM_SETSCROLLPOS, 0, (LPARAM)&point);
diff --git a/src/core/stdmsg/src/chat_window.cpp b/src/core/stdmsg/src/chat_window.cpp
index d96426e630..dda13a4b78 100644
--- a/src/core/stdmsg/src/chat_window.cpp
+++ b/src/core/stdmsg/src/chat_window.cpp
@@ -617,7 +617,7 @@ INT_PTR CALLBACK CChatRoomDlg::FilterWndProc(HWND hwndDlg, UINT uMsg, WPARAM wPa
pDlg->m_iLogFilterFlags = iFlags;
if (pDlg->m_bFilterEnabled)
- SendMessage(GetParent(hwndDlg), GC_REDRAWLOG, 0, 0);
+ pDlg->RedrawLog();
PostMessage(hwndDlg, WM_CLOSE, 0, 0);
}
break;
@@ -630,24 +630,6 @@ INT_PTR CALLBACK CChatRoomDlg::FilterWndProc(HWND hwndDlg, UINT uMsg, WPARAM wPa
return(FALSE);
}
-static LRESULT CALLBACK ButtonSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
-{
- switch (msg) {
- case WM_RBUTTONUP:
- if (db_get_b(0, CHAT_MODULE, "RightClickFilter", 0) != 0) {
- if (GetDlgItem(GetParent(hwnd), IDC_FILTER) == hwnd)
- SendMessage(GetParent(hwnd), GC_SHOWFILTERMENU, 0, 0);
- if (GetDlgItem(GetParent(hwnd), IDC_COLOR) == hwnd)
- SendMessage(GetParent(hwnd), GC_SHOWCOLORCHOOSER, 0, IDC_COLOR);
- if (GetDlgItem(GetParent(hwnd), IDC_BKGCOLOR) == hwnd)
- SendMessage(GetParent(hwnd), GC_SHOWCOLORCHOOSER, 0, IDC_BKGCOLOR);
- }
- break;
- }
-
- return mir_callNextSubclass(hwnd, ButtonSubclassProc, msg, wParam, lParam);
-}
-
static LRESULT CALLBACK LogSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
CHARRANGE sel;
@@ -824,7 +806,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();
}
/////////////////////////////////////////////////////////////////////////////////////////
@@ -854,6 +836,9 @@ CChatRoomDlg::CChatRoomDlg(SESSION_INFO *si) :
{
m_pLog = &m_log;
m_pEntry = &m_message;
+ m_pColor = &m_btnColor;
+ m_pBkColor = &m_btnBkColor;
+ m_pFilter = &m_btnFilter;
m_autoClose = 0;
m_forceResizable = true;
@@ -896,9 +881,10 @@ void CChatRoomDlg::OnInitDialog()
NotifyLocalWinEvent(m_hContact, m_hwnd, MSG_WINDOW_EVT_OPENING);
- 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);
SetWindowLongPtr(m_log.GetHwnd(), GWLP_USERDATA, LPARAM(this));
@@ -907,7 +893,7 @@ void CChatRoomDlg::OnInitDialog()
SetWindowLongPtr(m_nickList.GetHwnd(), GWLP_USERDATA, LPARAM(m_si));
mir_subclassWindow(m_nickList.GetHwnd(), NicklistSubclassProc);
- SendDlgItemMessage(m_hwnd, IDC_MESSAGE, EM_SUBCLASSED, 0, LPARAM(m_si));
+ m_message.SendMsg(EM_SUBCLASSED, 0, LPARAM(m_si));
SendDlgItemMessage(m_hwnd, IDC_LOG, EM_AUTOURLDETECT, 1, 0);
int mask = (int)SendDlgItemMessage(m_hwnd, IDC_LOG, EM_GETEVENTMASK, 0, 0);
@@ -924,8 +910,8 @@ void CChatRoomDlg::OnInitDialog()
SendDlgItemMessage(m_hwnd, IDC_LOG, EM_HIDESELECTION, TRUE, 0);
- SendMessage(m_hwnd, GC_SETWNDPROPS, 0, 0);
- SendMessage(m_hwnd, GC_UPDATESTATUSBAR, 0, 0);
+ UpdateOptions();
+ UpdateStatusBar();
UpdateTitle();
SetWindowPosition();
@@ -971,7 +957,7 @@ void CChatRoomDlg::OnClick_Bold(CCtrlButton *pButton)
case IDC_ITALICS: cf.dwEffects |= CFE_ITALIC; break;
case IDC_UNDERLINE: cf.dwEffects |= CFE_UNDERLINE; break;
}
- SendDlgItemMessage(m_hwnd, IDC_MESSAGE, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf);
+ m_message.SendMsg(EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf);
}
void CChatRoomDlg::OnClick_Color(CCtrlButton *pButton)
@@ -985,17 +971,17 @@ void CChatRoomDlg::OnClick_Color(CCtrlButton *pButton)
if (IsDlgButtonChecked(m_hwnd, IDC_COLOR)) {
if (db_get_b(0, 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];
- SendDlgItemMessage(m_hwnd, IDC_MESSAGE, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf);
+ m_message.SendMsg(EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf);
}
}
else {
cf.dwMask = CFM_COLOR;
cf.crTextColor = g_Settings.MessageAreaColor;
- SendDlgItemMessage(m_hwnd, IDC_MESSAGE, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf);
+ m_message.SendMsg(EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf);
}
}
@@ -1010,17 +996,17 @@ void CChatRoomDlg::OnClick_BkColor(CCtrlButton *pButton)
if (IsDlgButtonChecked(m_hwnd, IDC_BKGCOLOR)) {
if (db_get_b(0, 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];
- SendDlgItemMessage(m_hwnd, IDC_MESSAGE, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf);
+ m_message.SendMsg(EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf);
}
}
else {
cf.dwMask = CFM_BACKCOLOR;
cf.crBackColor = (COLORREF)db_get_dw(0, CHAT_MODULE, "ColorMessageBG", GetSysColor(COLOR_WINDOW));
- SendDlgItemMessage(m_hwnd, IDC_MESSAGE, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf);
+ m_message.SendMsg(EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf);
}
}
@@ -1032,9 +1018,9 @@ void CChatRoomDlg::OnClick_Filter(CCtrlButton *pButton)
m_bFilterEnabled = !m_bFilterEnabled;
SendDlgItemMessage(m_hwnd, IDC_FILTER, BM_SETIMAGE, IMAGE_ICON, (LPARAM)LoadIconEx(m_bFilterEnabled ? "filter" : "filter2", FALSE));
if (m_bFilterEnabled && db_get_b(0, CHAT_MODULE, "RightClickFilter", 0) == 0)
- SendMessage(m_hwnd, GC_SHOWFILTERMENU, 0, 0);
+ ShowFilterMenu();
else
- SendMessage(m_hwnd, GC_REDRAWLOG, 0, 0);
+ RedrawLog();
}
void CChatRoomDlg::OnClick_History(CCtrlButton *pButton)
@@ -1055,7 +1041,7 @@ void CChatRoomDlg::OnClick_NickList(CCtrlButton *pButton)
m_bNicklistEnabled = !m_bNicklistEnabled;
pButton->SendMsg(BM_SETIMAGE, IMAGE_ICON, (LPARAM)LoadIconEx(m_bNicklistEnabled ? "nicklist" : "nicklist2", FALSE));
- SendMessage(m_hwnd, GC_SCROLLTOBOTTOM, 0, 0);
+ ScrollToBottom();
SendMessage(m_hwnd, WM_SIZE, 0, 0);
}
@@ -1087,7 +1073,7 @@ void CChatRoomDlg::OnClick_Ok(CCtrlButton *pButton)
if (mi->bAckMsg) {
EnableWindow(m_message.GetHwnd(), FALSE);
- SendDlgItemMessage(m_hwnd, IDC_MESSAGE, EM_SETREADONLY, TRUE, 0);
+ m_message.SendMsg(EM_SETREADONLY, TRUE, 0);
}
else SetDlgItemText(m_hwnd, IDC_MESSAGE, L"");
@@ -1111,9 +1097,9 @@ void CChatRoomDlg::OnListDblclick(CCtrlListBox*)
return;
if (GetKeyState(VK_SHIFT) & 0x8000) {
- int start = LOWORD(SendDlgItemMessage(m_hwnd, IDC_MESSAGE, EM_GETSEL, 0, 0));
+ int start = LOWORD(m_message.SendMsg(EM_GETSEL, 0, 0));
CMStringW buf(FORMAT, (start == 0) ? L"%s: " : L"%s ", ui->pszUID);
- SendDlgItemMessage(m_hwnd, IDC_MESSAGE, EM_REPLACESEL, FALSE, (LPARAM)buf.c_str());
+ m_message.SendMsg(EM_REPLACESEL, FALSE, (LPARAM)buf.c_str());
PostMessage(m_hwnd, WM_MOUSEACTIVATE, 0, 0);
}
else DoEventHook(GC_USER_PRIVMESS, ui, nullptr, 0);
@@ -1213,6 +1199,8 @@ void CChatRoomDlg::SaveWindowPosition(bool bUpdateSession)
}
}
+/////////////////////////////////////////////////////////////////////////////////////////
+
void CChatRoomDlg::CloseTab(bool)
{
if (g_Settings.bTabsEnable)
@@ -1220,6 +1208,152 @@ void CChatRoomDlg::CloseTab(bool)
Close();
}
+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_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()
+{
+ if ((GetWindowLongPtr(m_log.GetHwnd(), GWL_STYLE) & WS_VSCROLL) == 0)
+ return;
+
+ CHARRANGE sel;
+ SCROLLINFO scroll = {};
+ scroll.cbSize = sizeof(scroll);
+ scroll.fMask = SIF_PAGE | SIF_RANGE;
+ GetScrollInfo(m_log.GetHwnd(), SB_VERT, &scroll);
+
+ scroll.fMask = SIF_POS;
+ scroll.nPos = scroll.nMax - scroll.nPage + 1;
+ SetScrollInfo(m_log.GetHwnd(), SB_VERT, &scroll, TRUE);
+
+ sel.cpMin = sel.cpMax = GetRichTextLength(m_log.GetHwnd());
+ SendDlgItemMessage(m_hwnd, IDC_LOG, EM_EXSETSEL, 0, (LPARAM)&sel);
+ PostMessage(m_log.GetHwnd(), WM_VSCROLL, MAKEWPARAM(SB_BOTTOM, 0), 0);
+}
+
+void CChatRoomDlg::ShowFilterMenu()
+{
+ HWND hwnd = CreateDialogParam(g_hInst, MAKEINTRESOURCE(IDD_FILTER), m_hwnd, FilterWndProc, (LPARAM)this);
+ TranslateDialogDefault(hwnd);
+
+ RECT rc;
+ GetWindowRect(m_btnFilter.GetHwnd(), &rc);
+ SetWindowPos(hwnd, HWND_TOP, rc.left - 85, (IsWindowVisible(m_btnFilter.GetHwnd()) || IsWindowVisible(m_btnBold.GetHwnd())) ? rc.top - 206 : rc.top - 186, 0, 0, SWP_NOSIZE | SWP_SHOWWINDOW);
+}
+
+void CChatRoomDlg::UpdateNickList()
+{
+ int i = SendDlgItemMessage(m_hwnd, IDC_LIST, LB_GETTOPINDEX, 0, 0);
+ SendDlgItemMessage(m_hwnd, IDC_LIST, LB_SETCOUNT, m_si->nUsersInNicklist, 0);
+ SendDlgItemMessage(m_hwnd, IDC_LIST, LB_SETTOPINDEX, i, 0);
+
+ UpdateTitle();
+}
+
+void CChatRoomDlg::UpdateOptions()
+{
+ m_btnNickList.SendMsg(BM_SETIMAGE, IMAGE_ICON, (LPARAM)LoadIconEx(m_bNicklistEnabled ? "nicklist" : "nicklist2", FALSE));
+ m_btnFilter.SendMsg(BM_SETIMAGE, IMAGE_ICON, (LPARAM)LoadIconEx(m_bFilterEnabled ? "filter" : "filter2", FALSE));
+
+ MODULEINFO *mi = pci->MM_FindModule(m_si->pszModule);
+ EnableWindow(m_btnBold.GetHwnd(), mi->bBold);
+ EnableWindow(m_btnItalic.GetHwnd(), mi->bItalics);
+ EnableWindow(m_btnUnderline.GetHwnd(), mi->bUnderline);
+ EnableWindow(m_btnColor.GetHwnd(), mi->bColor);
+ EnableWindow(m_btnBkColor.GetHwnd(), mi->bBkgColor);
+ if (m_si->iType == GCW_CHATROOM)
+ EnableWindow(m_btnChannelMgr.GetHwnd(), mi->bChanMgr);
+
+ HICON hIcon = m_si->wStatus == ID_STATUS_ONLINE ? mi->hOnlineIcon : mi->hOfflineIcon;
+ if (!hIcon) {
+ pci->MM_IconsChanged();
+ hIcon = (m_si->wStatus == ID_STATUS_ONLINE) ? mi->hOnlineIcon : mi->hOfflineIcon;
+ }
+
+ if (g_Settings.bTabsEnable)
+ pDialog->FixTabIcons(nullptr);
+
+ SendMessage(m_hwndStatus, SB_SETICON, 0, (LPARAM)hIcon);
+
+ Window_SetIcon_IcoLib(getCaptionWindow(), GetIconHandle("window"));
+
+ SendDlgItemMessage(m_hwnd, IDC_LOG, EM_SETBKGNDCOLOR, 0, g_Settings.crLogBackground);
+
+ CHARFORMAT2 cf;
+ cf.cbSize = sizeof(CHARFORMAT2);
+ cf.dwMask = CFM_COLOR | CFM_BOLD | CFM_UNDERLINE | CFM_BACKCOLOR;
+ cf.dwEffects = 0;
+ cf.crTextColor = g_Settings.MessageAreaColor;
+ cf.crBackColor = db_get_dw(0, CHAT_MODULE, "ColorMessageBG", GetSysColor(COLOR_WINDOW));
+
+ m_message.SendMsg(EM_SETBKGNDCOLOR, 0, db_get_dw(0, CHAT_MODULE, "ColorMessageBG", GetSysColor(COLOR_WINDOW)));
+ m_message.SendMsg(WM_SETFONT, (WPARAM)g_Settings.MessageAreaFont, MAKELPARAM(TRUE, 0));
+ m_message.SendMsg(EM_SETCHARFORMAT, SCF_ALL, (LPARAM)&cf);
+
+ // nicklist
+ int ih = GetTextPixelSize(L"AQGglo", g_Settings.UserListFont, FALSE);
+ int ih2 = GetTextPixelSize(L"AQGglo", g_Settings.UserListHeadingsFont, FALSE);
+ int height = db_get_b(0, CHAT_MODULE, "NicklistRowDist", 12);
+ int font = ih > ih2 ? ih : ih2;
+
+ // make sure we have space for icon!
+ if (g_Settings.bShowContactStatus)
+ font = font > 16 ? font : 16;
+
+ SendDlgItemMessage(m_hwnd, IDC_LIST, LB_SETITEMHEIGHT, 0, height > font ? height : font);
+ InvalidateRect(m_nickList.GetHwnd(), nullptr, TRUE);
+
+ SendMessage(m_hwnd, WM_SIZE, 0, 0);
+ RedrawLog2();
+}
+
+void CChatRoomDlg::UpdateStatusBar()
+{
+ MODULEINFO *mi = pci->MM_FindModule(m_si->pszModule);
+ wchar_t *ptszDispName = mi->ptszModDispName;
+ int x = 12;
+ x += GetTextPixelSize(ptszDispName, (HFONT)SendMessage(m_hwndStatus, WM_GETFONT, 0, 0), TRUE);
+ x += GetSystemMetrics(SM_CXSMICON);
+ int iStatusbarParts[2] = { x, -1 };
+ SendMessage(m_hwndStatus, SB_SETPARTS, 2, (LPARAM)&iStatusbarParts);
+
+ // stupid hack to make icons show. I dunno why this is needed currently
+ HICON hIcon = m_si->wStatus == ID_STATUS_ONLINE ? mi->hOnlineIcon : mi->hOfflineIcon;
+ if (!hIcon) {
+ pci->MM_IconsChanged();
+ hIcon = m_si->wStatus == ID_STATUS_ONLINE ? mi->hOnlineIcon : mi->hOfflineIcon;
+ }
+
+ SendMessage(m_hwndStatus, SB_SETICON, 0, (LPARAM)hIcon);
+
+ if (g_Settings.bTabsEnable)
+ pDialog->FixTabIcons(nullptr);
+
+ SendMessage(m_hwndStatus, SB_SETTEXT, 0, (LPARAM)ptszDispName);
+ SendMessage(m_hwndStatus, SB_SETTEXT, 1, (LPARAM)(m_si->ptszStatusbarText ? m_si->ptszStatusbarText : L""));
+ SendMessage(m_hwndStatus, SB_SETTIPTEXT, 1, (LPARAM)(m_si->ptszStatusbarText ? m_si->ptszStatusbarText : L""));
+}
+
void CChatRoomDlg::UpdateTitle()
{
wchar_t szTemp[100];
@@ -1242,66 +1376,14 @@ void CChatRoomDlg::UpdateTitle()
SetWindowText(getCaptionWindow(), szTemp);
}
+/////////////////////////////////////////////////////////////////////////////////////////
+
INT_PTR CChatRoomDlg::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam)
{
SESSION_INFO *s;
- RECT rc;
CHARRANGE sel;
switch (uMsg) {
- case GC_SETWNDPROPS:
- SendDlgItemMessage(m_hwnd, IDC_SHOWNICKLIST, BM_SETIMAGE, IMAGE_ICON, (LPARAM)LoadIconEx(m_bNicklistEnabled ? "nicklist" : "nicklist2", FALSE));
- SendDlgItemMessage(m_hwnd, IDC_FILTER, BM_SETIMAGE, IMAGE_ICON, (LPARAM)LoadIconEx(m_bFilterEnabled ? "filter" : "filter2", FALSE));
- {
- MODULEINFO *mi = pci->MM_FindModule(m_si->pszModule);
- EnableWindow(m_btnBold.GetHwnd(), mi->bBold);
- EnableWindow(m_btnItalic.GetHwnd(), mi->bItalics);
- EnableWindow(m_btnUnderline.GetHwnd(), mi->bUnderline);
- EnableWindow(m_btnColor.GetHwnd(), mi->bColor);
- EnableWindow(m_btnBkColor.GetHwnd(), mi->bBkgColor);
- if (m_si->iType == GCW_CHATROOM)
- EnableWindow(m_btnChannelMgr.GetHwnd(), mi->bChanMgr);
-
- HICON hIcon = m_si->wStatus == ID_STATUS_ONLINE ? mi->hOnlineIcon : mi->hOfflineIcon;
- if (!hIcon) {
- pci->MM_IconsChanged();
- hIcon = (m_si->wStatus == ID_STATUS_ONLINE) ? mi->hOnlineIcon : mi->hOfflineIcon;
- }
-
- SendMessage(m_hwndParent, GC_FIXTABICONS, 0, 0);
- SendMessage(m_hwndStatus, SB_SETICON, 0, (LPARAM)hIcon);
- }
- Window_SetIcon_IcoLib(getCaptionWindow(), GetIconHandle("window"));
-
- SendDlgItemMessage(m_hwnd, IDC_LOG, EM_SETBKGNDCOLOR, 0, g_Settings.crLogBackground);
-
- CHARFORMAT2 cf;
- cf.cbSize = sizeof(CHARFORMAT2);
- cf.dwMask = CFM_COLOR | CFM_BOLD | CFM_UNDERLINE | CFM_BACKCOLOR;
- cf.dwEffects = 0;
- cf.crTextColor = g_Settings.MessageAreaColor;
- cf.crBackColor = db_get_dw(0, CHAT_MODULE, "ColorMessageBG", GetSysColor(COLOR_WINDOW));
- SendDlgItemMessage(m_hwnd, IDC_MESSAGE, EM_SETBKGNDCOLOR, 0, db_get_dw(0, CHAT_MODULE, "ColorMessageBG", GetSysColor(COLOR_WINDOW)));
- SendDlgItemMessage(m_hwnd, IDC_MESSAGE, WM_SETFONT, (WPARAM)g_Settings.MessageAreaFont, MAKELPARAM(TRUE, 0));
- SendDlgItemMessage(m_hwnd, IDC_MESSAGE, EM_SETCHARFORMAT, SCF_ALL, (LPARAM)&cf);
- {
- // nicklist
- int ih = GetTextPixelSize(L"AQGglo", g_Settings.UserListFont, FALSE);
- int ih2 = GetTextPixelSize(L"AQGglo", g_Settings.UserListHeadingsFont, FALSE);
- int height = db_get_b(0, CHAT_MODULE, "NicklistRowDist", 12);
- int font = ih > ih2 ? ih : ih2;
-
- // make sure we have space for icon!
- if (g_Settings.bShowContactStatus)
- font = font > 16 ? font : 16;
-
- SendDlgItemMessage(m_hwnd, IDC_LIST, LB_SETITEMHEIGHT, 0, height > font ? height : font);
- InvalidateRect(m_nickList.GetHwnd(), nullptr, TRUE);
- }
- SendMessage(m_hwnd, WM_SIZE, 0, 0);
- SendMessage(m_hwnd, GC_REDRAWLOG2, 0, 0);
- break;
-
case WM_CBD_LOADICONS:
Srmm_UpdateToolbarIcons(m_hwnd);
break;
@@ -1310,36 +1392,9 @@ INT_PTR CChatRoomDlg::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam)
SetButtonsPos(m_hwnd, true);
break;
- case GC_UPDATESTATUSBAR:
- {
- MODULEINFO *mi = pci->MM_FindModule(m_si->pszModule);
- wchar_t *ptszDispName = mi->ptszModDispName;
- int x = 12;
- x += GetTextPixelSize(ptszDispName, (HFONT)SendMessage(m_hwndStatus, WM_GETFONT, 0, 0), TRUE);
- x += GetSystemMetrics(SM_CXSMICON);
- int iStatusbarParts[2] = { x, -1 };
- SendMessage(m_hwndStatus, SB_SETPARTS, 2, (LPARAM)&iStatusbarParts);
-
- // stupid hack to make icons show. I dunno why this is needed currently
- HICON hIcon = m_si->wStatus == ID_STATUS_ONLINE ? mi->hOnlineIcon : mi->hOfflineIcon;
- if (!hIcon) {
- pci->MM_IconsChanged();
- hIcon = m_si->wStatus == ID_STATUS_ONLINE ? mi->hOnlineIcon : mi->hOfflineIcon;
- }
-
- SendMessage(m_hwndStatus, SB_SETICON, 0, (LPARAM)hIcon);
- SendMessage(m_hwndParent, GC_FIXTABICONS, 0, 0);
-
- SendMessage(m_hwndStatus, SB_SETTEXT, 0, (LPARAM)ptszDispName);
-
- SendMessage(m_hwndStatus, SB_SETTEXT, 1, (LPARAM)(m_si->ptszStatusbarText ? m_si->ptszStatusbarText : L""));
- SendMessage(m_hwndStatus, SB_SETTIPTEXT, 1, (LPARAM)(m_si->ptszStatusbarText ? m_si->ptszStatusbarText : L""));
- }
- return TRUE;
-
case WM_SIZE:
if (wParam == SIZE_MAXIMIZED)
- PostMessage(m_hwnd, GC_SCROLLTOBOTTOM, 0, 0);
+ ScrollToBottom();
if (!IsIconic(m_hwnd)) {
SendMessage(m_hwndStatus, WM_SIZE, 0, 0);
@@ -1388,45 +1443,6 @@ INT_PTR CChatRoomDlg::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam)
}
return TRUE;
- 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_bFilterEnabled || (m_iLogFilterFlags&pLog->iType) != 0)
- index++;
- }
- Log_StreamInEvent(pLog, TRUE);
- mir_forkthread(phase2, m_si);
- }
- else Log_StreamInEvent(m_si->pLogEnd, TRUE);
- }
- else ClearLog();
- break;
-
- case GC_REDRAWLOG2:
- m_si->LastTime = 0;
- if (m_si->pLog)
- Log_StreamInEvent(m_si->pLogEnd, TRUE);
- break;
-
- case GC_ADDLOG:
- if (m_si->pLogEnd)
- Log_StreamInEvent(m_si->pLog, FALSE);
- else
- ClearLog();
- break;
-
case WM_CTLCOLORLISTBOX:
SetBkColor((HDC)wParam, g_Settings.crUserListBGColor);
return (INT_PTR)pci->hListBkgBrush;
@@ -1498,45 +1514,6 @@ INT_PTR CChatRoomDlg::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam)
}
break;
- case GC_UPDATENICKLIST:
- {
- int i = SendDlgItemMessage(m_hwnd, IDC_LIST, LB_GETTOPINDEX, 0, 0);
- SendDlgItemMessage(m_hwnd, IDC_LIST, LB_SETCOUNT, m_si->nUsersInNicklist, 0);
- SendDlgItemMessage(m_hwnd, IDC_LIST, LB_SETTOPINDEX, i, 0);
- }
- UpdateTitle();
- break;
-
- case GC_SHOWFILTERMENU:
- {
- HWND hwnd = CreateDialogParam(g_hInst, MAKEINTRESOURCE(IDD_FILTER), m_hwnd, FilterWndProc, (LPARAM)this);
- TranslateDialogDefault(hwnd);
- GetWindowRect(m_btnFilter.GetHwnd(), &rc);
- SetWindowPos(hwnd, HWND_TOP, rc.left - 85, (IsWindowVisible(m_btnFilter.GetHwnd()) || IsWindowVisible(m_btnBold.GetHwnd())) ? rc.top - 206 : rc.top - 186, 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:
- if ((GetWindowLongPtr(m_log.GetHwnd(), GWL_STYLE) & WS_VSCROLL) != 0) {
- SCROLLINFO scroll = {};
- scroll.cbSize = sizeof(scroll);
- scroll.fMask = SIF_PAGE | SIF_RANGE;
- GetScrollInfo(m_log.GetHwnd(), SB_VERT, &scroll);
-
- scroll.fMask = SIF_POS;
- scroll.nPos = scroll.nMax - scroll.nPage + 1;
- SetScrollInfo(m_log.GetHwnd(), SB_VERT, &scroll, TRUE);
-
- sel.cpMin = sel.cpMax = GetRichTextLength(m_log.GetHwnd());
- SendDlgItemMessage(m_hwnd, IDC_LOG, EM_EXSETSEL, 0, (LPARAM)&sel);
- PostMessage(m_log.GetHwnd(), WM_VSCROLL, MAKEWPARAM(SB_BOTTOM, 0), 0);
- }
- break;
-
case WM_TIMER:
if (wParam == TIMERID_FLASHWND)
FlashWindow(m_hwnd, TRUE);
@@ -1547,7 +1524,7 @@ INT_PTR CChatRoomDlg::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam)
if (g_Settings.bTabsEnable) {
m_si->wState &= ~GC_EVENT_HIGHLIGHT;
m_si->wState &= ~STATE_TALK;
- SendMessage(m_hwndParent, GC_FIXTABICONS, 0, (LPARAM)this);
+ pDialog->FixTabIcons(nullptr);
}
break;
}
@@ -1715,7 +1692,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;
}
diff --git a/src/core/stdmsg/src/msgs.h b/src/core/stdmsg/src/msgs.h
index 60c2ef2d8f..c3509bdb46 100644
--- a/src/core/stdmsg/src/msgs.h
+++ b/src/core/stdmsg/src/msgs.h
@@ -99,7 +99,6 @@ public:
virtual INT_PTR DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) override;
- virtual void CloseTab(bool) override {}
virtual void UpdateTitle() override {}
void OnSplitterMoved(CSplitter*);
diff --git a/src/core/stdmsg/src/stdafx.h b/src/core/stdmsg/src/stdafx.h
index 5c77fca204..d9959618aa 100644
--- a/src/core/stdmsg/src/stdafx.h
+++ b/src/core/stdmsg/src/stdafx.h
@@ -161,6 +161,38 @@ char* Message_GetFromStream(HWND hwndDlg, SESSION_INFO *si);
void NotifyLocalWinEvent(MCONTACT hContact, HWND hwnd, unsigned int type);
// tabs.cpp
+
+struct CTabbedWindow : public CDlgBase
+{
+ CCtrlPages m_tab;
+
+ CTabbedWindow() :
+ CDlgBase(g_hInst, IDD_CONTAINER),
+ m_tab(this, IDC_TAB)
+ {}
+
+ void AddPage(SESSION_INFO*, int insertAt = -1);
+ void FixTabIcons(CChatRoomDlg*);
+ void SetMessageHighlight(CChatRoomDlg*);
+ void SetTabHighlight(CChatRoomDlg*);
+ void TabClicked();
+
+ virtual void OnInitDialog() override;
+ virtual void OnDestroy() override;
+
+ virtual int Resizer(UTILRESIZECONTROL *urc)
+ {
+ if (urc->wId == IDC_TAB)
+ return RD_ANCHORX_WIDTH | RD_ANCHORY_HEIGHT;
+
+ return RD_ANCHORX_LEFT | RD_ANCHORY_TOP;
+ }
+
+ virtual INT_PTR DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) override;
+};
+
+extern CTabbedWindow *pDialog;
+
void InitTabs(void);
void UninitTabs(void);
@@ -195,7 +227,6 @@ class CChatRoomDlg : public CSrmmBaseDialog
{ return (g_Settings.bTabsEnable) ? GetParent(m_hwndParent) : m_hwnd;
}
- void Log_StreamInEvent(LOGINFO *lin, BOOL bRedraw);
void SaveWindowPosition(bool bUpdateSession);
void SetWindowPosition();
@@ -211,6 +242,13 @@ public:
virtual int Resizer(UTILRESIZECONTROL *urc) override;
virtual void CloseTab(bool bForced = false) override;
+ virtual void RedrawLog() override;
+ virtual void StreamInEvents(LOGINFO* lin, bool bRedraw) override;
+ virtual void ScrollToBottom() override;
+ virtual void ShowFilterMenu() override;
+ virtual void UpdateNickList() override;
+ virtual void UpdateOptions() override;
+ virtual void UpdateStatusBar() override;
virtual void UpdateTitle() override;
void OnClick_Bold(CCtrlButton*);
diff --git a/src/core/stdmsg/src/tabs.cpp b/src/core/stdmsg/src/tabs.cpp
index 40357f92eb..e5e1a3d4f1 100644
--- a/src/core/stdmsg/src/tabs.cpp
+++ b/src/core/stdmsg/src/tabs.cpp
@@ -42,32 +42,6 @@ void TB_SaveSession(SESSION_INFO *si)
/////////////////////////////////////////////////////////////////////////////////////////
-struct CTabbedWindow : public CDlgBase
-{
- CCtrlPages m_tab;
-
- CTabbedWindow() :
- CDlgBase(g_hInst, IDD_CONTAINER),
- m_tab(this, IDC_TAB)
- {}
-
- void AddPage(SESSION_INFO*, int insertAt = -1);
- void TabClicked();
-
- virtual void OnInitDialog() override;
- virtual void OnDestroy() override;
-
- virtual int Resizer(UTILRESIZECONTROL *urc)
- {
- if (urc->wId == IDC_TAB)
- return RD_ANCHORX_WIDTH | RD_ANCHORY_HEIGHT;
-
- return RD_ANCHORX_LEFT | RD_ANCHORY_TOP;
- }
-
- virtual INT_PTR DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) override;
-};
-
static LRESULT CALLBACK TabSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
CTabbedWindow *pOwner = (CTabbedWindow*)GetWindowLongPtr(hwnd, GWLP_USERDATA);
@@ -217,7 +191,7 @@ void CTabbedWindow::AddPage(SESSION_INFO *si, int insertAt)
CChatRoomDlg *pTab = new CChatRoomDlg(si);
m_tab.AddPage(szTemp, NULL, pTab);
- SendMessage(m_hwnd, GC_FIXTABICONS, 0, (LPARAM)pTab);
+ FixTabIcons(pTab);
m_tab.ActivatePage(m_tab.GetCount() - 1);
}
@@ -225,13 +199,67 @@ void CTabbedWindow::AddPage(SESSION_INFO *si, int insertAt)
m_tab.ActivatePage(indexfound);
}
+void CTabbedWindow::FixTabIcons(CChatRoomDlg *pDlg)
+{
+ if (pDlg != nullptr) {
+ int idx = m_tab.GetDlgIndex(pDlg);
+ if (idx == -1)
+ return;
+
+ SESSION_INFO *si = pDlg->m_si;
+ int image = 0;
+ if (!(si->wState & GC_EVENT_HIGHLIGHT)) {
+ MODULEINFO *mi = pci->MM_FindModule(si->pszModule);
+ image = (si->wStatus == ID_STATUS_ONLINE) ? mi->OnlineIconIndex : mi->OfflineIconIndex;
+ if (si->wState & STATE_TALK)
+ image++;
+ }
+
+ TCITEM tci = {};
+ tci.mask = TCIF_IMAGE;
+ TabCtrl_GetItem(m_tab.GetHwnd(), idx, &tci);
+ if (tci.iImage != image) {
+ tci.iImage = image;
+ TabCtrl_SetItem(m_tab.GetHwnd(), idx, &tci);
+ }
+ }
+ else RedrawWindow(m_tab.GetHwnd(), NULL, NULL, RDW_INVALIDATE);
+}
+
+void CTabbedWindow::SetMessageHighlight(CChatRoomDlg *pDlg)
+{
+ if (pDlg != nullptr) {
+ if (m_tab.GetDlgIndex(pDlg) == -1)
+ return;
+
+ pDlg->m_si->wState |= GC_EVENT_HIGHLIGHT;
+ FixTabIcons(pDlg);
+ if (g_Settings.bFlashWindowHighlight && GetActiveWindow() != m_hwnd && GetForegroundWindow() != m_hwnd)
+ SetTimer(m_hwnd, TIMERID_FLASHWND, 900, NULL);
+ }
+ else RedrawWindow(m_tab.GetHwnd(), NULL, NULL, RDW_INVALIDATE);
+}
+
+void CTabbedWindow::SetTabHighlight(CChatRoomDlg *pDlg)
+{
+ if (pDlg != nullptr) {
+ if (m_tab.GetDlgIndex(pDlg) == -1)
+ return;
+
+ FixTabIcons(pDlg);
+ if (g_Settings.bFlashWindow && GetActiveWindow() != m_hwnd && GetForegroundWindow() != m_hwnd)
+ SetTimer(m_hwnd, TIMERID_FLASHWND, 900, NULL);
+ }
+ else RedrawWindow(m_tab.GetHwnd(), NULL, NULL, RDW_INVALIDATE);
+}
+
void CTabbedWindow::TabClicked()
{
- CDlgBase *pDlg = m_tab.GetActivePage();
+ CChatRoomDlg *pDlg = (CChatRoomDlg*)m_tab.GetActivePage();
if (pDlg == NULL)
return;
- SESSION_INFO *s = ((CChatRoomDlg*)pDlg)->m_si;
+ SESSION_INFO *s = pDlg->m_si;
if (s) {
if (s->wState & STATE_TALK) {
s->wState &= ~STATE_TALK;
@@ -245,7 +273,7 @@ void CTabbedWindow::TabClicked()
pcli->pfnRemoveEvent(s->hContact, GC_FAKE_EVENT);
}
- SendMessage(m_hwnd, GC_FIXTABICONS, 0, (LPARAM)pDlg);
+ FixTabIcons(pDlg);
if (!s->pDlg) {
pci->ShowRoom(s);
SendMessage(m_hwnd, WM_MOUSEACTIVATE, 0, 0);
@@ -260,32 +288,6 @@ INT_PTR CTabbedWindow::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam)
AddPage((SESSION_INFO*)lParam);
break;
- case GC_FIXTABICONS:
- if (CChatRoomDlg *pDlg = (CChatRoomDlg*)lParam) {
- int idx = m_tab.GetDlgIndex(pDlg);
- if (idx == -1)
- break;
-
- SESSION_INFO *si = pDlg->m_si;
- int image = 0;
- if (!(si->wState & GC_EVENT_HIGHLIGHT)) {
- MODULEINFO *mi = pci->MM_FindModule(si->pszModule);
- image = (si->wStatus == ID_STATUS_ONLINE) ? mi->OnlineIconIndex : mi->OfflineIconIndex;
- if (si->wState & STATE_TALK)
- image++;
- }
-
- TCITEM tci = {};
- tci.mask = TCIF_IMAGE;
- TabCtrl_GetItem(m_tab.GetHwnd(), idx, &tci);
- if (tci.iImage != image) {
- tci.iImage = image;
- TabCtrl_SetItem(m_tab.GetHwnd(), idx, &tci);
- }
- }
- else RedrawWindow(m_tab.GetHwnd(), NULL, NULL, RDW_INVALIDATE);
- break;
-
case GC_SWITCHNEXTTAB:
{
int total = m_tab.GetCount();
@@ -344,35 +346,9 @@ INT_PTR CTabbedWindow::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam)
}
break;
- case GC_SETMESSAGEHIGHLIGHT:
- if (CChatRoomDlg *pDlg = (CChatRoomDlg*)lParam) {
- if (m_tab.GetDlgIndex(pDlg) == -1)
- break;
-
- pDlg->m_si->wState |= GC_EVENT_HIGHLIGHT;
- SendMessage(m_hwnd, GC_FIXTABICONS, 0, (LPARAM)pDlg);
- if (g_Settings.bFlashWindowHighlight && GetActiveWindow() != m_hwnd && GetForegroundWindow() != m_hwnd)
- SetTimer(m_hwnd, TIMERID_FLASHWND, 900, NULL);
- }
- else RedrawWindow(m_tab.GetHwnd(), NULL, NULL, RDW_INVALIDATE);
- break;
-
- case GC_SETTABHIGHLIGHT:
- if (CChatRoomDlg *pDlg = (CChatRoomDlg*)lParam) {
- if (m_tab.GetDlgIndex(pDlg) == -1)
- break;
-
- SendMessage(m_hwnd, GC_FIXTABICONS, 0, (LPARAM)pDlg);
- if (g_Settings.bFlashWindow && GetActiveWindow() != m_hwnd && GetForegroundWindow() != m_hwnd)
- SetTimer(m_hwnd, TIMERID_FLASHWND, 900, NULL);
- break;
- }
- else RedrawWindow(m_tab.GetHwnd(), NULL, NULL, RDW_INVALIDATE);
- break;
-
case GC_TABCHANGE:
SetWindowLongPtr(m_hwnd, GWLP_USERDATA, (LONG_PTR)lParam);
- PostMessage(m_hwnd, GC_SCROLLTOBOTTOM, 0, 0);
+ // ScrollToBottom();
break;
case GC_DROPPEDTAB:
@@ -486,7 +462,7 @@ INT_PTR CTabbedWindow::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam)
/////////////////////////////////////////////////////////////////////////////////////////
-static CTabbedWindow *pDialog = NULL;
+CTabbedWindow *pDialog = nullptr;
void CTabbedWindow::OnDestroy()
{
@@ -546,11 +522,11 @@ void ShowRoom(SESSION_INFO *si)
PostMessage(si->pDlg->GetHwnd(), WM_SIZE, 0, 0);
if (si->iType != GCW_SERVER)
- SendMessage(si->pDlg->GetHwnd(), GC_UPDATENICKLIST, 0, 0);
+ si->pDlg->UpdateNickList();
else
si->pDlg->UpdateTitle();
- SendMessage(si->pDlg->GetHwnd(), GC_REDRAWLOG, 0, 0);
- SendMessage(si->pDlg->GetHwnd(), GC_UPDATESTATUSBAR, 0, 0);
+ si->pDlg->RedrawLog();
+ si->pDlg->UpdateStatusBar();
}
SetWindowLongPtr(si->pDlg->GetHwnd(), GWL_EXSTYLE, GetWindowLongPtr(si->pDlg->GetHwnd(), GWL_EXSTYLE) | WS_EX_APPWINDOW);
diff --git a/src/mir_app/src/chat_manager.cpp b/src/mir_app/src/chat_manager.cpp
index d8cfe40999..72863f26d7 100644
--- a/src/mir_app/src/chat_manager.cpp
+++ b/src/mir_app/src/chat_manager.cpp
@@ -242,7 +242,7 @@ BOOL SM_RemoveUser(const wchar_t *pszID, const char *pszModule, const wchar_t *p
chatApi.UM_RemoveUser(&si->pUsers, pszUID);
if (si->pDlg)
- SendMessage(si->pDlg->GetHwnd(), GC_UPDATENICKLIST, 0, 0);
+ si->pDlg->UpdateNickList();
if (pszID)
return TRUE;
@@ -268,7 +268,7 @@ BOOL SM_GiveStatus(const wchar_t *pszID, const char *pszModule, const wchar_t *p
if (ui) {
SM_MoveUser(si->ptszID, si->pszModule, ui->pszUID);
if (si->pDlg)
- SendMessage(si->pDlg->GetHwnd(), GC_UPDATENICKLIST, 0, 0);
+ si->pDlg->UpdateNickList();
}
return TRUE;
}
@@ -283,7 +283,7 @@ BOOL SM_SetContactStatus(const wchar_t *pszID, const char *pszModule, const wcha
if (ui) {
SM_MoveUser(si->ptszID, si->pszModule, ui->pszUID);
if (si->pDlg)
- SendMessage(si->pDlg->GetHwnd(), GC_UPDATENICKLIST, 0, 0);
+ si->pDlg->UpdateNickList();
}
return TRUE;
}
@@ -298,7 +298,7 @@ BOOL SM_TakeStatus(const wchar_t *pszID, const char *pszModule, const wchar_t *p
if (ui) {
SM_MoveUser(si->ptszID, si->pszModule, ui->pszUID);
if (si->pDlg)
- SendMessage(si->pDlg->GetHwnd(), GC_UPDATENICKLIST, 0, 0);
+ si->pDlg->UpdateNickList();
}
return TRUE;
}
@@ -349,7 +349,7 @@ BOOL SM_ChangeNick(const wchar_t *pszID, const char *pszModule, GCEVENT *gce)
replaceStrW(ui->pszNick, gce->ptszText);
SM_MoveUser(si->ptszID, si->pszModule, ui->pszUID);
if (si->pDlg)
- SendMessage(si->pDlg->GetHwnd(), GC_UPDATENICKLIST, 0, 0);
+ si->pDlg->UpdateNickList();
if (chatApi.OnChangeNick)
chatApi.OnChangeNick(si);
}
@@ -1110,7 +1110,6 @@ MIR_APP_DLL(CHAT_MANAGER*) Chat_GetInterface(CHAT_MANAGER_INITDATA *pInit, int _
chatApi.IsHighlighted = IsHighlighted;
chatApi.RemoveFormatting = RemoveFormatting;
chatApi.ReloadSettings = LoadGlobalSettings;
- chatApi.ColorChooser = ColorChooser;
chatApi.pLogIconBmpBits = pLogIconBmpBits;
diff --git a/src/mir_app/src/chat_svc.cpp b/src/mir_app/src/chat_svc.cpp
index d7ac64cd01..d6d5126f33 100644
--- a/src/mir_app/src/chat_svc.cpp
+++ b/src/mir_app/src/chat_svc.cpp
@@ -85,7 +85,7 @@ static int FontsChanged(WPARAM, LPARAM)
chatApi.MM_FontsChanged();
chatApi.MM_FixColors();
- chatApi.SM_BroadcastMessage(nullptr, GC_SETWNDPROPS, 0, 0, TRUE);
+ Chat_UpdateOptions();
return 0;
}
@@ -95,7 +95,7 @@ static int IconsChanged(WPARAM, LPARAM)
LoadMsgLogBitmaps();
chatApi.MM_IconsChanged();
- chatApi.SM_BroadcastMessage(nullptr, GC_SETWNDPROPS, 0, 0, FALSE);
+ Chat_UpdateOptions();
return 0;
}
@@ -113,7 +113,11 @@ static int PreShutdown(WPARAM, LPARAM)
static int SmileyOptionsChanged(WPARAM, LPARAM)
{
- chatApi.SM_BroadcastMessage(nullptr, GC_REDRAWLOG, 0, 1, FALSE);
+ for (int i = 0; i < g_arSessions.getCount(); i++) {
+ SESSION_INFO *si = g_arSessions[i];
+ if (si->pDlg)
+ si->pDlg->RedrawLog();
+ }
return 0;
}
@@ -296,15 +300,15 @@ static INT_PTR __stdcall stubRoomControl(void *param)
SM_SetOffline(si);
SM_SetStatus(si, ID_STATUS_OFFLINE);
if (si->pDlg) {
- ::SendMessage(si->pDlg->GetHwnd(), GC_UPDATESTATUSBAR, 0, 0);
- ::SendMessage(si->pDlg->GetHwnd(), GC_UPDATENICKLIST, 0, 0);
+ si->pDlg->UpdateStatusBar();
+ si->pDlg->UpdateNickList();
}
break;
case SESSION_ONLINE:
SM_SetStatus(si, ID_STATUS_ONLINE);
if (si->pDlg)
- ::SendMessage(si->pDlg->GetHwnd(), GC_UPDATESTATUSBAR, 0, 0);
+ si->pDlg->UpdateStatusBar();
break;
case WINDOW_CLEARLOG:
@@ -409,9 +413,9 @@ static BOOL AddEventToAllMatchingUID(GCEVENT *gce)
if (p->pDlg && p->bInitDone) {
if (SM_AddEvent(p->ptszID, p->pszModule, gce, FALSE))
- SendMessage(p->pDlg->GetHwnd(), GC_ADDLOG, 0, 0);
+ p->pDlg->AddLog();
else
- SendMessage(p->pDlg->GetHwnd(), GC_REDRAWLOG2, 0, 0);
+ p->pDlg->RedrawLog2();
}
if (!(gce->dwFlags & GCEF_NOTNOTIFY)) {
@@ -555,9 +559,9 @@ EXTERN_C MIR_APP_DLL(int) Chat_Event(GCEVENT *gce)
int isOk = SM_AddEvent(pWnd, pMod, gce, bIsHighlighted);
if (si->pDlg) {
if (isOk)
- SendMessage(si->pDlg->GetHwnd(), GC_ADDLOG, 0, 0);
+ si->pDlg->AddLog();
else
- SendMessage(si->pDlg->GetHwnd(), GC_REDRAWLOG2, 0, 0);
+ si->pDlg->RedrawLog2();
}
if (!(gce->dwFlags & GCEF_NOTNOTIFY)) {
@@ -689,7 +693,7 @@ MIR_APP_DLL(int) Chat_SetStatusbarText(const char *szModule, const wchar_t *wszI
db_set_s(si->hContact, si->pszModule, "StatusBar", "");
if (si->pDlg)
- SendMessage(si->pDlg->GetHwnd(), GC_UPDATESTATUSBAR, 0, 0);
+ si->pDlg->UpdateStatusBar();
}
return 0;
}
@@ -724,6 +728,15 @@ MIR_APP_DLL(int) Chat_SetUserInfo(const char *szModule, const wchar_t *wszId, vo
return GC_EVENT_ERROR;
}
+EXTERN_C MIR_APP_DLL(void) Chat_UpdateOptions()
+{
+ for (int i = 0; i < g_arSessions.getCount(); i++) {
+ SESSION_INFO *si = g_arSessions[i];
+ if (si->pDlg)
+ si->pDlg->UpdateOptions();
+ }
+}
+
/////////////////////////////////////////////////////////////////////////////////////////
// module initialization
diff --git a/src/mir_app/src/colorchooser.cpp b/src/mir_app/src/colorchooser.cpp
index aa6fd06cb1..731239b8c1 100644
--- a/src/mir_app/src/colorchooser.cpp
+++ b/src/mir_app/src/colorchooser.cpp
@@ -265,8 +265,8 @@ public:
}
};
-void ColorChooser(SESSION_INFO *si, BOOL bFG, HWND hwndDlg, HWND hwndTarget, HWND hwndChooser)
+void CSrmmBaseDialog::ShowColorChooser(int iCtrlId)
{
- CColorChooserDlg *pDialog = new CColorChooserDlg(si, bFG, hwndDlg, hwndTarget, hwndChooser);
+ CColorChooserDlg *pDialog = new CColorChooserDlg(m_si, iCtrlId == m_pColor->GetCtrlId(), m_hwnd, m_pEntry->GetHwnd(), GetDlgItem(m_hwnd, iCtrlId));
pDialog->Show();
}
diff --git a/src/mir_app/src/mir_app.def b/src/mir_app/src/mir_app.def
index 1628ca17a9..4c35385bb0 100644
--- a/src/mir_app/src/mir_app.def
+++ b/src/mir_app/src/mir_app.def
@@ -412,3 +412,16 @@ Srmm_LogStreamCallback @412
Srmm_MessageStreamCallback @413
?DoEventHook@CSrmmBaseDialog@@IAEXHPBUUSERINFO@@PB_WH@Z @414 NONAME
?ClearLog@CSrmmBaseDialog@@QAEXXZ @415 NONAME
+?CloseTab@CSrmmBaseDialog@@UAEX_N@Z @416 NONAME
+?UpdateStatusBar@CSrmmBaseDialog@@UAEXXZ @417 NONAME
+Chat_UpdateOptions @418 NONAME
+?RedrawLog@CSrmmBaseDialog@@UAEXXZ @419 NONAME
+?UpdateOptions@CSrmmBaseDialog@@UAEXXZ @420 NONAME
+?ShowColorChooser@CSrmmBaseDialog@@QAEXH@Z @421 NONAME
+?ShowFilterMenu@CSrmmBaseDialog@@UAEXXZ @422 NONAME
+_Srmm_ButtonSubclassProc@16 @423 NONAME
+?StreamInEvents@CSrmmBaseDialog@@UAEXPAULOGINFO@@_N@Z @424 NONAME
+?AddLog@CSrmmBaseDialog@@UAEXXZ @425 NONAME
+?RedrawLog2@CSrmmBaseDialog@@QAEXXZ @426 NONAME
+?ScrollToBottom@CSrmmBaseDialog@@UAEXXZ @427 NONAME
+?UpdateNickList@CSrmmBaseDialog@@UAEXXZ @428 NONAME
diff --git a/src/mir_app/src/mir_app64.def b/src/mir_app/src/mir_app64.def
index ad9ab48e67..b9521316af 100644
--- a/src/mir_app/src/mir_app64.def
+++ b/src/mir_app/src/mir_app64.def
@@ -412,3 +412,16 @@ Srmm_LogStreamCallback @412
Srmm_MessageStreamCallback @413
?DoEventHook@CSrmmBaseDialog@@IEAAXHPEBUUSERINFO@@PEB_W_J@Z @414 NONAME
?ClearLog@CSrmmBaseDialog@@QEAAXXZ @415 NONAME
+?CloseTab@CSrmmBaseDialog@@UEAAX_N@Z @416 NONAME
+?UpdateStatusBar@CSrmmBaseDialog@@UEAAXXZ @417 NONAME
+Chat_UpdateOptions @418 NONAME
+?RedrawLog@CSrmmBaseDialog@@UEAAXXZ @419 NONAME
+?UpdateOptions@CSrmmBaseDialog@@UEAAXXZ @420 NONAME
+?ShowColorChooser@CSrmmBaseDialog@@QEAAXH@Z @421 NONAME
+?ShowFilterMenu@CSrmmBaseDialog@@UEAAXXZ @422 NONAME
+Srmm_ButtonSubclassProc @423 NONAME
+?StreamInEvents@CSrmmBaseDialog@@UEAAXPEAULOGINFO@@_N@Z @424 NONAME
+?AddLog@CSrmmBaseDialog@@UEAAXXZ @425 NONAME
+?RedrawLog2@CSrmmBaseDialog@@QEAAXXZ @426 NONAME
+?ScrollToBottom@CSrmmBaseDialog@@UEAAXXZ @427 NONAME
+?UpdateNickList@CSrmmBaseDialog@@UEAAXXZ @428 NONAME
diff --git a/src/mir_app/src/srmm_base.cpp b/src/mir_app/src/srmm_base.cpp
index 1f017289b4..8df17b3fd7 100644
--- a/src/mir_app/src/srmm_base.cpp
+++ b/src/mir_app/src/srmm_base.cpp
@@ -32,6 +32,9 @@ CSrmmBaseDialog::CSrmmBaseDialog(HINSTANCE hInst, int idDialog, SESSION_INFO *si
m_si(si),
m_pLog(nullptr),
m_pEntry(nullptr),
+ m_pFilter(nullptr),
+ m_pColor(nullptr),
+ m_pBkColor(nullptr),
m_hContact(0)
{
m_bFilterEnabled = db_get_b(0, CHAT_MODULE, "FilterEnabled", 0) != 0;
@@ -138,6 +141,14 @@ INT_PTR CSrmmBaseDialog::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam)
return CDlgBase::DlgProc(msg, wParam, lParam);
}
+void CSrmmBaseDialog::AddLog()
+{
+ if (m_si->pLogEnd)
+ StreamInEvents(m_si->pLog, false);
+ else
+ ClearLog();
+}
+
void CSrmmBaseDialog::ClearLog()
{
if (m_pLog != nullptr)
@@ -162,3 +173,10 @@ void CSrmmBaseDialog::DoEventHook(int iType, const USERINFO *pUser, const wchar_
gch.pDest = &gcd;
NotifyEventHooks(chatApi.hSendEvent, 0, (WPARAM)&gch);
}
+
+void CSrmmBaseDialog::RedrawLog2()
+{
+ m_si->LastTime = 0;
+ if (m_si->pLog)
+ StreamInEvents(m_si->pLogEnd, TRUE);
+}
diff --git a/src/mir_app/src/srmm_util.cpp b/src/mir_app/src/srmm_util.cpp
index 78ed59e436..e9aeffc33c 100644
--- a/src/mir_app/src/srmm_util.cpp
+++ b/src/mir_app/src/srmm_util.cpp
@@ -72,3 +72,25 @@ MIR_APP_DLL(DWORD) CALLBACK Srmm_MessageStreamCallback(DWORD_PTR dwCookie, LPBYT
}
return 0;
}
+
+EXTERN_C MIR_APP_DLL(LRESULT) CALLBACK Srmm_ButtonSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ switch (msg) {
+ case WM_RBUTTONUP:
+ if (db_get_b(0, CHAT_MODULE, "RightClickFilter", 0) != 0) {
+ CSrmmBaseDialog *pDlg = (CSrmmBaseDialog*)GetWindowLongPtr(GetParent(hwnd), GWLP_USERDATA);
+ if (pDlg == nullptr)
+ break;
+
+ if (hwnd == pDlg->m_pFilter->GetHwnd())
+ pDlg->ShowFilterMenu();
+ else if (hwnd == pDlg->m_pColor->GetHwnd())
+ pDlg->ShowColorChooser(pDlg->m_pColor->GetCtrlId());
+ else if (hwnd == pDlg->m_pBkColor->GetHwnd())
+ pDlg->ShowColorChooser(pDlg->m_pBkColor->GetCtrlId());
+ }
+ break;
+ }
+
+ return mir_callNextSubclass(hwnd, Srmm_ButtonSubclassProc, msg, wParam, lParam);
+}