From b6669f0ee3361891e9807e5c734bf9121e9cfb06 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Tue, 26 Sep 2023 12:20:03 +0300 Subject: SRMM options update unification --- plugins/Scriver/src/msgdialog.cpp | 39 +---------------------------- plugins/Scriver/src/msgoptions.cpp | 6 ++--- plugins/Scriver/src/msgs.h | 1 + plugins/Scriver/src/msgutils.cpp | 39 +++++++++++++++++++++++++++++ plugins/SmileyAdd/src/dlgboxsubclass.cpp | 10 +------- plugins/SmileyAdd/src/services.cpp | 4 +-- plugins/TabSRMM/src/chat_options.cpp | 2 +- plugins/TabSRMM/src/generic_msghandlers.cpp | 17 ++++++------- plugins/TabSRMM/src/msgdialog.cpp | 10 +++----- plugins/TabSRMM/src/msgoptions.cpp | 8 +++--- plugins/TabSRMM/src/msgs.cpp | 2 +- plugins/TabSRMM/src/msgs.h | 2 +- plugins/TabSRMM/src/userprefs.cpp | 2 +- 13 files changed, 66 insertions(+), 76 deletions(-) (limited to 'plugins') diff --git a/plugins/Scriver/src/msgdialog.cpp b/plugins/Scriver/src/msgdialog.cpp index d062cf512a..4e1b373608 100644 --- a/plugins/Scriver/src/msgdialog.cpp +++ b/plugins/Scriver/src/msgdialog.cpp @@ -217,7 +217,7 @@ bool CMsgDialog::OnInitDialog() } } - SendMessage(m_hwnd, DM_OPTIONSAPPLIED, 0, 0); + OnOptionsApplied(); PopupWindow(m_bIncoming); if (notifyUnread) { @@ -891,43 +891,6 @@ INT_PTR CMsgDialog::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) } break; - case DM_OPTIONSAPPLIED: - if (!isChat()) { - GetAvatar(); - SetDialogToType(); - - m_pLog->UpdateOptions(); - - COLORREF colour = g_plugin.getDword(SRMSGSET_INPUTBKGCOLOUR, SRMSGDEFSET_INPUTBKGCOLOUR); - m_message.SendMsg(EM_SETBKGNDCOLOR, 0, colour); - InvalidateRect(m_message.GetHwnd(), nullptr, FALSE); - - LOGFONT lf; - LoadMsgDlgFont(MSGFONTID_MESSAGEAREA, &lf, &colour); - - CHARFORMAT2 cf2; - memset(&cf2, 0, sizeof(cf2)); - cf2.cbSize = sizeof(cf2); - cf2.dwMask = CFM_COLOR | CFM_FACE | CFM_CHARSET | CFM_SIZE | CFM_WEIGHT | CFM_BOLD | CFM_ITALIC; - cf2.crTextColor = colour; - cf2.bCharSet = lf.lfCharSet; - wcsncpy(cf2.szFaceName, lf.lfFaceName, LF_FACESIZE); - cf2.dwEffects = ((lf.lfWeight >= FW_BOLD) ? CFE_BOLD : 0) | (lf.lfItalic ? CFE_ITALIC : 0); - cf2.wWeight = (uint16_t)lf.lfWeight; - cf2.bPitchAndFamily = lf.lfPitchAndFamily; - cf2.yHeight = abs(lf.lfHeight) * 1440 / g_dat.logPixelSY; - m_message.SendMsg(EM_SETCHARFORMAT, SCF_ALL, (LPARAM)&cf2); - m_message.SendMsg(EM_SETLANGOPTIONS, 0, (LPARAM)m_message.SendMsg(EM_GETLANGOPTIONS, 0, 0) & ~IMF_AUTOKEYBOARD); - - SendMessage(m_hwnd, DM_REMAKELOG, 0, 0); - UpdateTitle(); - UpdateTabControl(); - UpdateStatusBar(); - m_message.SendMsg(EM_REQUESTRESIZE, 0, 0); - SetupInfobar(); - } - break; - case DM_ACTIVATE: if (isChat()) { if (m_si->wState & STATE_TALK) { diff --git a/plugins/Scriver/src/msgoptions.cpp b/plugins/Scriver/src/msgoptions.cpp index b51cddc4fa..2a1975e5e6 100644 --- a/plugins/Scriver/src/msgoptions.cpp +++ b/plugins/Scriver/src/msgoptions.cpp @@ -75,7 +75,7 @@ int FontServiceFontsChanged(WPARAM, LPARAM) { LoadMsgLogIcons(); LoadInfobarFonts(); - Srmm_Broadcast(DM_OPTIONSAPPLIED, 0, 0); + Srmm_ApplyOptions(); return 0; } @@ -177,7 +177,7 @@ class CBaseOptionDlg : public CDlgBase { ReloadGlobals(); WindowList_Broadcast(g_dat.hParentWindowList, DM_OPTIONSAPPLIED, 0, 0); - Srmm_Broadcast(DM_OPTIONSAPPLIED, 0, 0); + Srmm_ApplyOptions(); Chat_UpdateOptions(); } @@ -739,7 +739,7 @@ public: } ReloadGlobals(); - Srmm_Broadcast(DM_OPTIONSAPPLIED, 0, 0); + Srmm_ApplyOptions(); return true; } diff --git a/plugins/Scriver/src/msgs.h b/plugins/Scriver/src/msgs.h index c6422300d7..f24d81b4d6 100644 --- a/plugins/Scriver/src/msgs.h +++ b/plugins/Scriver/src/msgs.h @@ -133,6 +133,7 @@ public: void EventAdded(MEVENT, const DB::EventInfo &dbei) override; bool GetFirstEvent() override; void LoadSettings() override; + void OnOptionsApplied() override; void RemakeLog() override; void SetStatusText(const wchar_t *, HICON) override; void ShowFilterMenu() override; diff --git a/plugins/Scriver/src/msgutils.cpp b/plugins/Scriver/src/msgutils.cpp index bb9da0e619..4f4fb2349b 100644 --- a/plugins/Scriver/src/msgutils.cpp +++ b/plugins/Scriver/src/msgutils.cpp @@ -294,6 +294,45 @@ void CMsgDialog::NotifyTyping(int mode) CallService(MS_PROTO_SELFISTYPING, m_hContact, m_nTypeMode); } +void CMsgDialog::OnOptionsApplied() +{ + if (isChat()) + return; + + GetAvatar(); + SetDialogToType(); + + m_pLog->UpdateOptions(); + + COLORREF colour = g_plugin.getDword(SRMSGSET_INPUTBKGCOLOUR, SRMSGDEFSET_INPUTBKGCOLOUR); + m_message.SendMsg(EM_SETBKGNDCOLOR, 0, colour); + InvalidateRect(m_message.GetHwnd(), nullptr, FALSE); + + LOGFONT lf; + LoadMsgDlgFont(MSGFONTID_MESSAGEAREA, &lf, &colour); + + CHARFORMAT2 cf2; + memset(&cf2, 0, sizeof(cf2)); + cf2.cbSize = sizeof(cf2); + cf2.dwMask = CFM_COLOR | CFM_FACE | CFM_CHARSET | CFM_SIZE | CFM_WEIGHT | CFM_BOLD | CFM_ITALIC; + cf2.crTextColor = colour; + cf2.bCharSet = lf.lfCharSet; + wcsncpy(cf2.szFaceName, lf.lfFaceName, LF_FACESIZE); + cf2.dwEffects = ((lf.lfWeight >= FW_BOLD) ? CFE_BOLD : 0) | (lf.lfItalic ? CFE_ITALIC : 0); + cf2.wWeight = (uint16_t)lf.lfWeight; + cf2.bPitchAndFamily = lf.lfPitchAndFamily; + cf2.yHeight = abs(lf.lfHeight) * 1440 / g_dat.logPixelSY; + m_message.SendMsg(EM_SETCHARFORMAT, SCF_ALL, (LPARAM)&cf2); + m_message.SendMsg(EM_SETLANGOPTIONS, 0, (LPARAM)m_message.SendMsg(EM_GETLANGOPTIONS, 0, 0) & ~IMF_AUTOKEYBOARD); + + SendMessage(m_hwnd, DM_REMAKELOG, 0, 0); + UpdateTitle(); + UpdateTabControl(); + UpdateStatusBar(); + m_message.SendMsg(EM_REQUESTRESIZE, 0, 0); + SetupInfobar(); +} + void CMsgDialog::Reattach(HWND hwndContainer) { MCONTACT hContact = m_hContact; diff --git a/plugins/SmileyAdd/src/dlgboxsubclass.cpp b/plugins/SmileyAdd/src/dlgboxsubclass.cpp index 9a5792651d..0dd3cafd0d 100644 --- a/plugins/SmileyAdd/src/dlgboxsubclass.cpp +++ b/plugins/SmileyAdd/src/dlgboxsubclass.cpp @@ -56,15 +56,7 @@ static OBJLIST g_MsgWndList(10, HandleKeySortT); int UpdateSrmmDlg(WPARAM wParam, LPARAM) { - mir_cslock lck(csWndList); - - for (auto &it : g_MsgWndList) { - if (wParam == 0 || it->pDlg->m_hContact == wParam) { - SendMessage(it->pDlg->GetHwnd(), WM_SETREDRAW, FALSE, 0); - it->pDlg->UpdateOptions(); - SendMessage(it->pDlg->GetHwnd(), WM_SETREDRAW, TRUE, 0); - } - } + Srmm_ApplyOptions(); return 0; } diff --git a/plugins/SmileyAdd/src/services.cpp b/plugins/SmileyAdd/src/services.cpp index fbbc9398a7..b2dbc14ea4 100644 --- a/plugins/SmileyAdd/src/services.cpp +++ b/plugins/SmileyAdd/src/services.cpp @@ -265,12 +265,12 @@ INT_PTR LoadContactSmileys(WPARAM, LPARAM lParam) switch (cont->type) { case 0: g_SmileyPackCStore.AddSmileyPack(cont->pszModule, cont->path); - NotifyEventHooks(g_hevOptionsChanged, (WPARAM)cont->pszModule, 0); + NotifyEventHooks(g_hevOptionsChanged, 0, (WPARAM)cont->pszModule); break; case 1: g_SmileyPackCStore.AddSmiley(cont->pszModule, cont->path); - NotifyEventHooks(g_hevOptionsChanged, (WPARAM)cont->pszModule, 0); + NotifyEventHooks(g_hevOptionsChanged, 0, (WPARAM)cont->pszModule); break; case 2: diff --git a/plugins/TabSRMM/src/chat_options.cpp b/plugins/TabSRMM/src/chat_options.cpp index 0294bb5c45..250346da03 100644 --- a/plugins/TabSRMM/src/chat_options.cpp +++ b/plugins/TabSRMM/src/chat_options.cpp @@ -402,7 +402,7 @@ int FontServiceFontsChanged(WPARAM, LPARAM) FreeTabConfig(); ReloadTabConfig(); Skin->setupAeroSkins(); - Srmm_Broadcast(DM_OPTIONSAPPLIED, 1, 0); + Srmm_ApplyOptions(); return 0; } diff --git a/plugins/TabSRMM/src/generic_msghandlers.cpp b/plugins/TabSRMM/src/generic_msghandlers.cpp index 7d1e8ceb35..7fbd56f602 100644 --- a/plugins/TabSRMM/src/generic_msghandlers.cpp +++ b/plugins/TabSRMM/src/generic_msghandlers.cpp @@ -842,7 +842,7 @@ void CMsgDialog::DM_NotifyTyping(int mode) } } -void CMsgDialog::DM_OptionsApplied(bool bRemakeLog) +void CMsgDialog::OnOptionsApplied() { m_szMicroLf[0] = 0; if (!m_pContainer->m_theme.isPrivate) { @@ -868,14 +868,13 @@ void CMsgDialog::DM_OptionsApplied(bool bRemakeLog) if (m_hwnd == m_pContainer->m_hwndActive) SendMessage(m_pContainer->m_hwnd, WM_SIZE, 0, 0); InvalidateRect(m_message.GetHwnd(), nullptr, FALSE); - if (bRemakeLog) { - if (IsIconic(m_pContainer->m_hwnd)) - m_bDeferredRemakeLog = true; - else if (isChat()) - RedrawLog(); - else - RemakeLog(); - } + + if (IsIconic(m_pContainer->m_hwnd)) + m_bDeferredRemakeLog = true; + else if (isChat()) + RedrawLog(); + else + RemakeLog(); ShowWindow(m_hwndPanelPicParent, SW_SHOW); EnableWindow(m_hwndPanelPicParent, TRUE); diff --git a/plugins/TabSRMM/src/msgdialog.cpp b/plugins/TabSRMM/src/msgdialog.cpp index 8f6d86edb5..09aee40cb7 100644 --- a/plugins/TabSRMM/src/msgdialog.cpp +++ b/plugins/TabSRMM/src/msgdialog.cpp @@ -580,7 +580,7 @@ bool CMsgDialog::OnInitDialog() else { GetFirstEvent(); - DM_OptionsApplied(); + OnOptionsApplied(); DB::ECPTR pCursor(DB::EventsRev(m_hContact)); while (MEVENT hdbEvent = pCursor.FetchNext()) { @@ -1434,7 +1434,7 @@ int CMsgDialog::OnFilter(MSGFILTER *pFilter) db_unset(m_hContact, SRMSGMOD_T, "mwmask"); db_unset(m_hContact, SRMSGMOD_T, "mwflags"); } - DM_OptionsApplied(); + OnOptionsApplied(); RemakeLog(); } return _dlgReturn(m_hwnd, 1); @@ -2188,7 +2188,7 @@ INT_PTR CMsgDialog::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam) if (isChat()) RedrawLog(); else - DM_OptionsApplied(); + OnOptionsApplied(); break; case WM_NOTIFY: @@ -2331,10 +2331,6 @@ INT_PTR CMsgDialog::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam) UpdateWindowIcon(); return 0; - case DM_OPTIONSAPPLIED: - DM_OptionsApplied(lParam == 0); - return 0; - case DM_UPDATESTATUSMSG: m_pPanel.Invalidate(); return 0; diff --git a/plugins/TabSRMM/src/msgoptions.cpp b/plugins/TabSRMM/src/msgoptions.cpp index ab56521362..2d22090b74 100644 --- a/plugins/TabSRMM/src/msgoptions.cpp +++ b/plugins/TabSRMM/src/msgoptions.cpp @@ -289,7 +289,7 @@ public: CacheMsgLogIcons(); PluginConfig.reloadSettings(); CSkin::setAeroEffect(-1); - Srmm_Broadcast(DM_OPTIONSAPPLIED, 1, 0); + Srmm_ApplyOptions(); Srmm_Broadcast(DM_FORCEDREMAKELOG, 0, 0); SendMessage(GetParent(m_hwnd), WM_COMMAND, IDCANCEL, 0); } @@ -423,7 +423,7 @@ public: db_set_b(0, SRMSGMOD_T, "dontscaleavatars", chkAvaPreserve.GetState()); PluginConfig.reloadSettings(); - Srmm_Broadcast(DM_OPTIONSAPPLIED, 1, 0); + Srmm_ApplyOptions(); return true; } @@ -852,7 +852,7 @@ public: else db_set_dw(0, SRMSGMOD_T, "maxhist", 0); PluginConfig.reloadSettings(); - Srmm_Broadcast(DM_OPTIONSAPPLIED, 1, 0); + Srmm_ApplyOptions(); return true; } @@ -1093,7 +1093,7 @@ public: db_set_b(0, SRMSGMOD_T, "escmode", cmbEscMode.GetCurSel()); PluginConfig.reloadSettings(); - Srmm_Broadcast(DM_OPTIONSAPPLIED, 0, 0); + Srmm_ApplyOptions(); return true; } diff --git a/plugins/TabSRMM/src/msgs.cpp b/plugins/TabSRMM/src/msgs.cpp index 7343237d28..db04ba7685 100644 --- a/plugins/TabSRMM/src/msgs.cpp +++ b/plugins/TabSRMM/src/msgs.cpp @@ -623,7 +623,7 @@ int IconsChanged(WPARAM, LPARAM) { CreateImageList(false); CacheMsgLogIcons(); - Srmm_Broadcast(DM_OPTIONSAPPLIED, 0, 0); + Srmm_ApplyOptions(); Srmm_Broadcast(DM_UPDATEWINICON, 0, 0); return 0; } diff --git a/plugins/TabSRMM/src/msgs.h b/plugins/TabSRMM/src/msgs.h index 4aef4ccf63..5817cfcb88 100644 --- a/plugins/TabSRMM/src/msgs.h +++ b/plugins/TabSRMM/src/msgs.h @@ -597,6 +597,7 @@ public: bool GetFirstEvent() override; bool IsActive() const override; void LoadSettings() override; + void OnOptionsApplied() override; void RemakeLog() override; void SetStatusText(const wchar_t *, HICON) override; void ShowFilterMenu() override; @@ -630,7 +631,6 @@ public: void LogEvent(DB::EventInfo &dbei); - void DM_OptionsApplied(bool bRemakeLog = true); void DM_RecalcPictureSize(void); void DM_ScrollToBottom(WPARAM wParam, LPARAM lParam); diff --git a/plugins/TabSRMM/src/userprefs.cpp b/plugins/TabSRMM/src/userprefs.cpp index 944474d85a..70ff19332e 100644 --- a/plugins/TabSRMM/src/userprefs.cpp +++ b/plugins/TabSRMM/src/userprefs.cpp @@ -342,7 +342,7 @@ public: fShouldHide = false; else ShowWindow(dat->m_pContainer->m_hwnd, SW_HIDE); - dat->DM_OptionsApplied(); + dat->OnOptionsApplied(); dat->RemakeLog(); if (fShouldHide) ShowWindow(dat->m_pContainer->m_hwnd, SW_SHOWNORMAL); -- cgit v1.2.3