From 6617cb7b9b8795c2d11c03a78ebe642a2e1fa71f Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sun, 13 May 2018 21:34:18 +0300 Subject: more correct version of getting icon's index --- src/core/stdmsg/src/chat_window.cpp | 9 +++++++++ src/core/stdmsg/src/msgdialog.cpp | 5 +++++ src/core/stdmsg/src/msgs.h | 3 +++ src/core/stdmsg/src/stdafx.h | 2 +- src/core/stdmsg/src/tabs.cpp | 12 ++---------- 5 files changed, 20 insertions(+), 11 deletions(-) (limited to 'src/core/stdmsg') diff --git a/src/core/stdmsg/src/chat_window.cpp b/src/core/stdmsg/src/chat_window.cpp index a015311e85..61600f5619 100644 --- a/src/core/stdmsg/src/chat_window.cpp +++ b/src/core/stdmsg/src/chat_window.cpp @@ -197,6 +197,15 @@ void CChatRoomDlg::onSplitterY(CSplitter *pSplitter) ///////////////////////////////////////////////////////////////////////////////////////// +int CChatRoomDlg::GetImageId() const +{ + if (m_si->wState & GC_EVENT_HIGHLIGHT) + return 0; + + MODULEINFO *mi = pci->MM_FindModule(m_si->pszModule); + return (m_si->wStatus == ID_STATUS_ONLINE) ? mi->OnlineIconIndex : mi->OfflineIconIndex; +} + void CChatRoomDlg::LoadSettings() { m_clrInputBG = db_get_dw(0, CHAT_MODULE, "ColorMessageBG", GetSysColor(COLOR_WINDOW)); diff --git a/src/core/stdmsg/src/msgdialog.cpp b/src/core/stdmsg/src/msgdialog.cpp index f8271b829d..da37118eeb 100644 --- a/src/core/stdmsg/src/msgdialog.cpp +++ b/src/core/stdmsg/src/msgdialog.cpp @@ -453,6 +453,11 @@ void CSrmmWindow::OnSplitterMoved(CSplitter *pSplitter) ///////////////////////////////////////////////////////////////////////////////////////// +int CSrmmWindow::GetImageId() const +{ + return pcli->pfnIconFromStatusMode(m_szProto, m_wStatus, m_hContact); +} + void CSrmmWindow::NotifyTyping(int mode) { if (!m_hContact) diff --git a/src/core/stdmsg/src/msgs.h b/src/core/stdmsg/src/msgs.h index 3d5e443517..5f04157bab 100644 --- a/src/core/stdmsg/src/msgs.h +++ b/src/core/stdmsg/src/msgs.h @@ -53,6 +53,7 @@ protected: CMsgDialog(int idDialog, SESSION_INFO *si = nullptr); + virtual int GetImageId() const PURE; virtual void OnActivate() PURE; INT_PTR DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) override; @@ -125,6 +126,7 @@ public: INT_PTR DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) override; int Resizer(UTILRESIZECONTROL *urc) override; + int GetImageId() const override; void LoadSettings() override {} void ScrollToBottom() override; void SetStatusText(const wchar_t*, HICON) override; @@ -179,6 +181,7 @@ public: INT_PTR DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) override; int Resizer(UTILRESIZECONTROL *urc) override; + int GetImageId() const override; void LoadSettings() override; void RedrawLog() override; void StreamInEvents(LOGINFO *lin, bool bRedraw) override; diff --git a/src/core/stdmsg/src/stdafx.h b/src/core/stdmsg/src/stdafx.h index c9f458a840..713dbaf132 100644 --- a/src/core/stdmsg/src/stdafx.h +++ b/src/core/stdmsg/src/stdafx.h @@ -155,7 +155,7 @@ public: CTabbedWindow* AddPage(MCONTACT hContact, wchar_t *pwszText = nullptr, int iActivate = -1); void AddPage(SESSION_INFO*, int insertAt = -1); - void FixTabIcons(CSrmmBaseDialog*); + void FixTabIcons(CMsgDialog*); void SetMessageHighlight(CChatRoomDlg*); void SetTabHighlight(CChatRoomDlg*); void TabClicked(); diff --git a/src/core/stdmsg/src/tabs.cpp b/src/core/stdmsg/src/tabs.cpp index a464ee96ad..65dffff4b5 100644 --- a/src/core/stdmsg/src/tabs.cpp +++ b/src/core/stdmsg/src/tabs.cpp @@ -279,20 +279,12 @@ void CTabbedWindow::AddPage(SESSION_INFO *si, int insertAt) m_tab.ActivatePage(indexfound); } -void CTabbedWindow::FixTabIcons(CSrmmBaseDialog *pDlg) +void CTabbedWindow::FixTabIcons(CMsgDialog *pDlg) { if (pDlg == nullptr) return; - int image = 0; - if (SESSION_INFO *si = ((CChatRoomDlg*)pDlg)->m_si) { - if (!(si->wState & GC_EVENT_HIGHLIGHT)) { - MODULEINFO *mi = pci->MM_FindModule(si->pszModule); - image = (si->wStatus == ID_STATUS_ONLINE) ? mi->OnlineIconIndex : mi->OfflineIconIndex; - } - } - else image = pcli->pfnIconFromStatusMode(GetContactProto(pDlg->m_hContact), Contact_GetStatus(pDlg->m_hContact), pDlg->m_hContact); - + int image = pDlg->GetImageId(); if (pDlg == m_pEmbed) { SendMessage(m_hwnd, WM_SETICON, 0, (LPARAM)ImageList_GetIcon(Clist_GetImageList(), image, 0)); return; -- cgit v1.2.3