From c8283bbae2f7a24c21c862f1769e8566b0b5144f Mon Sep 17 00:00:00 2001 From: George Hazan Date: Wed, 6 Jan 2021 12:43:52 +0300 Subject: CCtrlColor applied in dialogs when possible --- plugins/TabSRMM/src/eventpopups.cpp | 80 ++++++++++++++++++++----------------- plugins/TabSRMM/src/msgoptions.cpp | 26 +++++++----- 2 files changed, 59 insertions(+), 47 deletions(-) (limited to 'plugins/TabSRMM/src') diff --git a/plugins/TabSRMM/src/eventpopups.cpp b/plugins/TabSRMM/src/eventpopups.cpp index 7b28288a9e..e97c92355a 100644 --- a/plugins/TabSRMM/src/eventpopups.cpp +++ b/plugins/TabSRMM/src/eventpopups.cpp @@ -490,10 +490,19 @@ class CPopupOptionsDlg : public CDlgBase { CCtrlTreeView eventOptions; CCtrlButton btnPreview, btnModes; + CCtrlColor mucBack, mucText, msgBack, msgText, otherBack, otherText, errBack, errText; public: CPopupOptionsDlg() : CDlgBase(g_plugin, IDD_POPUP_OPT), + errBack(this, IDC_COLBACK_ERR), + errText(this, IDC_COLTEXT_ERR), + msgBack(this, IDC_COLBACK_MESSAGE), + msgText(this, IDC_COLTEXT_MESSAGE), + mucBack(this, IDC_COLBACK_MUC), + mucText(this, IDC_COLTEXT_MUC), + otherBack(this, IDC_COLBACK_OTHERS), + otherText(this, IDC_COLTEXT_OTHERS), btnModes(this, IDC_POPUPSTATUSMODES), btnPreview(this, IDC_PREVIEW), eventOptions(this, IDC_EVENTOPTIONS) @@ -506,18 +515,18 @@ public: { TreeViewInit(eventOptions, lvGroupsNEN, lvItemsNEN, 0, 0, TRUE); - SendDlgItemMessage(m_hwnd, IDC_COLBACK_MESSAGE, CPM_SETCOLOUR, 0, nen_options.colBackMsg); - SendDlgItemMessage(m_hwnd, IDC_COLTEXT_MESSAGE, CPM_SETCOLOUR, 0, nen_options.colTextMsg); - SendDlgItemMessage(m_hwnd, IDC_COLBACK_OTHERS, CPM_SETCOLOUR, 0, nen_options.colBackOthers); - SendDlgItemMessage(m_hwnd, IDC_COLTEXT_OTHERS, CPM_SETCOLOUR, 0, nen_options.colTextOthers); - SendDlgItemMessage(m_hwnd, IDC_COLBACK_ERR, CPM_SETCOLOUR, 0, nen_options.colBackErr); - SendDlgItemMessage(m_hwnd, IDC_COLTEXT_ERR, CPM_SETCOLOUR, 0, nen_options.colTextErr); + msgBack.SetColor(nen_options.colBackMsg); + msgText.SetColor(nen_options.colTextMsg); + otherBack.SetColor(nen_options.colBackOthers); + otherText.SetColor(nen_options.colTextOthers); + errBack.SetColor(nen_options.colBackErr); + errText.SetColor(nen_options.colTextErr); CheckDlgButton(m_hwnd, IDC_CHKDEFAULTCOL_MESSAGE, nen_options.bDefaultColorMsg ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(m_hwnd, IDC_CHKDEFAULTCOL_OTHERS, nen_options.bDefaultColorOthers ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(m_hwnd, IDC_CHKDEFAULTCOL_ERR, nen_options.bDefaultColorErr ? BST_CHECKED : BST_UNCHECKED); - SendDlgItemMessage(m_hwnd, IDC_COLTEXT_MUC, CPM_SETCOLOUR, 0, g_Settings.crPUTextColour); - SendDlgItemMessage(m_hwnd, IDC_COLBACK_MUC, CPM_SETCOLOUR, 0, g_Settings.crPUBkgColour); + mucText.SetColor(g_Settings.crPUTextColour); + mucBack.SetColor(g_Settings.crPUBkgColour); CheckDlgButton(m_hwnd, IDC_CHKDEFAULTCOL_MUC, g_Settings.iPopupStyle == 2 ? BST_CHECKED : BST_UNCHECKED); SendDlgItemMessage(m_hwnd, IDC_DELAY_MESSAGE_SPIN, UDM_SETRANGE, 0, MAKELONG(3600, -1)); @@ -530,14 +539,14 @@ public: SendDlgItemMessage(m_hwnd, IDC_DELAY_ERR_SPIN, UDM_SETPOS, 0, (LPARAM)nen_options.iDelayErr); SendDlgItemMessage(m_hwnd, IDC_DELAY_MESSAGE_MUC_SPIN, UDM_SETPOS, 0, (LPARAM)g_Settings.iPopupTimeout); - Utils::enableDlgControl(m_hwnd, IDC_COLBACK_MESSAGE, !nen_options.bDefaultColorMsg); - Utils::enableDlgControl(m_hwnd, IDC_COLTEXT_MESSAGE, !nen_options.bDefaultColorMsg); - Utils::enableDlgControl(m_hwnd, IDC_COLBACK_OTHERS, !nen_options.bDefaultColorOthers); - Utils::enableDlgControl(m_hwnd, IDC_COLTEXT_OTHERS, !nen_options.bDefaultColorOthers); - Utils::enableDlgControl(m_hwnd, IDC_COLBACK_ERR, !nen_options.bDefaultColorErr); - Utils::enableDlgControl(m_hwnd, IDC_COLTEXT_ERR, !nen_options.bDefaultColorErr); - Utils::enableDlgControl(m_hwnd, IDC_COLTEXT_MUC, g_Settings.iPopupStyle == 3); - Utils::enableDlgControl(m_hwnd, IDC_COLBACK_MUC, g_Settings.iPopupStyle == 3); + msgBack.Enable(!nen_options.bDefaultColorMsg); + msgText.Enable(!nen_options.bDefaultColorMsg); + otherBack.Enable(!nen_options.bDefaultColorOthers); + otherText.Enable(!nen_options.bDefaultColorOthers); + errBack.Enable(!nen_options.bDefaultColorErr); + errText.Enable(!nen_options.bDefaultColorErr); + mucText.Enable(g_Settings.iPopupStyle == 3); + mucBack.Enable(g_Settings.iPopupStyle == 3); CheckDlgButton(m_hwnd, IDC_MUC_LOGCOLORS, g_Settings.iPopupStyle < 2 ? BST_CHECKED : BST_UNCHECKED); Utils::enableDlgControl(m_hwnd, IDC_MUC_LOGCOLORS, g_Settings.iPopupStyle != 2); @@ -558,11 +567,8 @@ public: db_set_b(0, CHAT_MODULE, "PopupStyle", (BYTE)g_Settings.iPopupStyle); db_set_w(0, CHAT_MODULE, "PopupTimeout", g_Settings.iPopupTimeout); - - g_Settings.crPUBkgColour = SendDlgItemMessage(m_hwnd, IDC_COLBACK_MUC, CPM_GETCOLOUR, 0, 0); - db_set_dw(0, CHAT_MODULE, "PopupColorBG", (DWORD)g_Settings.crPUBkgColour); - g_Settings.crPUTextColour = SendDlgItemMessage(m_hwnd, IDC_COLTEXT_MUC, CPM_GETCOLOUR, 0, 0); - db_set_dw(0, CHAT_MODULE, "PopupColorText", (DWORD)g_Settings.crPUTextColour); + db_set_dw(0, CHAT_MODULE, "PopupColorBG", g_Settings.crPUBkgColour = mucBack.GetColor()); + db_set_dw(0, CHAT_MODULE, "PopupColorText", g_Settings.crPUTextColour = mucText.GetColor()); NEN_WriteOptions(&nen_options); CheckForRemoveMask(); @@ -614,14 +620,14 @@ public: nen_options.iLimitPreview = GetDlgItemInt(m_hwnd, IDC_MESSAGEPREVIEWLIMIT, nullptr, FALSE); else nen_options.iLimitPreview = 0; - Utils::enableDlgControl(m_hwnd, IDC_COLBACK_MESSAGE, !nen_options.bDefaultColorMsg); - Utils::enableDlgControl(m_hwnd, IDC_COLTEXT_MESSAGE, !nen_options.bDefaultColorMsg); - Utils::enableDlgControl(m_hwnd, IDC_COLBACK_OTHERS, !nen_options.bDefaultColorOthers); - Utils::enableDlgControl(m_hwnd, IDC_COLTEXT_OTHERS, !nen_options.bDefaultColorOthers); - Utils::enableDlgControl(m_hwnd, IDC_COLBACK_ERR, !nen_options.bDefaultColorErr); - Utils::enableDlgControl(m_hwnd, IDC_COLTEXT_ERR, !nen_options.bDefaultColorErr); - Utils::enableDlgControl(m_hwnd, IDC_COLTEXT_MUC, g_Settings.iPopupStyle == 3); - Utils::enableDlgControl(m_hwnd, IDC_COLBACK_MUC, g_Settings.iPopupStyle == 3); + msgBack.Enable(!nen_options.bDefaultColorMsg); + msgText.Enable(!nen_options.bDefaultColorMsg); + otherBack.Enable(!nen_options.bDefaultColorOthers); + otherText.Enable(!nen_options.bDefaultColorOthers); + errBack.Enable(!nen_options.bDefaultColorErr); + errText.Enable(!nen_options.bDefaultColorErr); + mucText.Enable(g_Settings.iPopupStyle == 3); + mucBack.Enable(g_Settings.iPopupStyle == 3); Utils::enableDlgControl(m_hwnd, IDC_MESSAGEPREVIEWLIMIT, IsDlgButtonChecked(m_hwnd, IDC_LIMITPREVIEW) != 0); Utils::enableDlgControl(m_hwnd, IDC_MESSAGEPREVIEWLIMITSPIN, IsDlgButtonChecked(m_hwnd, IDC_LIMITPREVIEW) != 0); @@ -632,14 +638,14 @@ public: Utils::enableDlgControl(m_hwnd, IDC_DELAY_ERR, nen_options.iDelayErr != -1); Utils::enableDlgControl(m_hwnd, IDC_DELAY_MUC, g_Settings.iPopupTimeout != -1); - nen_options.colBackMsg = SendDlgItemMessage(m_hwnd, IDC_COLBACK_MESSAGE, CPM_GETCOLOUR, 0, 0); - nen_options.colTextMsg = SendDlgItemMessage(m_hwnd, IDC_COLTEXT_MESSAGE, CPM_GETCOLOUR, 0, 0); - nen_options.colBackOthers = SendDlgItemMessage(m_hwnd, IDC_COLBACK_OTHERS, CPM_GETCOLOUR, 0, 0); - nen_options.colTextOthers = SendDlgItemMessage(m_hwnd, IDC_COLTEXT_OTHERS, CPM_GETCOLOUR, 0, 0); - nen_options.colBackErr = SendDlgItemMessage(m_hwnd, IDC_COLBACK_ERR, CPM_GETCOLOUR, 0, 0); - nen_options.colTextErr = SendDlgItemMessage(m_hwnd, IDC_COLTEXT_ERR, CPM_GETCOLOUR, 0, 0); - g_Settings.crPUBkgColour = SendDlgItemMessage(m_hwnd, IDC_COLBACK_MUC, CPM_GETCOLOUR, 0, 0); - g_Settings.crPUTextColour = SendDlgItemMessage(m_hwnd, IDC_COLTEXT_MUC, CPM_GETCOLOUR, 0, 0); + nen_options.colBackMsg = msgBack.GetColor(); + nen_options.colTextMsg = msgText.GetColor(); + nen_options.colBackOthers = otherBack.GetColor(); + nen_options.colTextOthers = otherText.GetColor(); + nen_options.colBackErr = errBack.GetColor(); + nen_options.colTextErr = errText.GetColor(); + g_Settings.crPUBkgColour = mucBack.GetColor(); + g_Settings.crPUTextColour = mucText.GetColor(); } }; diff --git a/plugins/TabSRMM/src/msgoptions.cpp b/plugins/TabSRMM/src/msgoptions.cpp index c53759d8dc..7b09df4edc 100644 --- a/plugins/TabSRMM/src/msgoptions.cpp +++ b/plugins/TabSRMM/src/msgoptions.cpp @@ -556,6 +556,7 @@ class CTemplateEditDlg : public CMsgDialog TTemplateSet *tSet; CCtrlEdit edtText; + CCtrlColor clr1, clr2, clr3, clr4, clr5; CCtrlButton btnResetAll, btnSave, btnForget, btnRevert, btnPreview; CCtrlListBox listTemplates; CCtrlHyperlink urlHelp; @@ -564,6 +565,11 @@ public: CTemplateEditDlg(BOOL _rtl, HWND hwndParent) : CSuper(IDD_TEMPLATEEDIT, 0), rtl(_rtl), + clr1(this, IDC_COLOR1), + clr2(this, IDC_COLOR2), + clr3(this, IDC_COLOR3), + clr4(this, IDC_COLOR4), + clr5(this, IDC_COLOR5), edtText(this, IDC_EDITTEMPLATE), urlHelp(this, IDC_VARIABLESHELP, "https://wiki.miranda-ng.org/index.php?title=Plugin:TabSRMM/en/Templates"), btnSave(this, IDC_SAVETEMPLATE), @@ -621,11 +627,11 @@ public: Utils::enableDlgControl(m_hwndParent, IDC_MODIFY, FALSE); Utils::enableDlgControl(m_hwndParent, IDC_RTLMODIFY, FALSE); - SendDlgItemMessage(m_hwnd, IDC_COLOR1, CPM_SETCOLOUR, 0, M.GetDword("cc1", SRMSGDEFSET_BKGCOLOUR)); - SendDlgItemMessage(m_hwnd, IDC_COLOR2, CPM_SETCOLOUR, 0, M.GetDword("cc2", SRMSGDEFSET_BKGCOLOUR)); - SendDlgItemMessage(m_hwnd, IDC_COLOR3, CPM_SETCOLOUR, 0, M.GetDword("cc3", SRMSGDEFSET_BKGCOLOUR)); - SendDlgItemMessage(m_hwnd, IDC_COLOR4, CPM_SETCOLOUR, 0, M.GetDword("cc4", SRMSGDEFSET_BKGCOLOUR)); - SendDlgItemMessage(m_hwnd, IDC_COLOR5, CPM_SETCOLOUR, 0, M.GetDword("cc5", SRMSGDEFSET_BKGCOLOUR)); + clr1.SetColor(M.GetDword("cc1", SRMSGDEFSET_BKGCOLOUR)); + clr1.SetColor(M.GetDword("cc2", SRMSGDEFSET_BKGCOLOUR)); + clr1.SetColor(M.GetDword("cc3", SRMSGDEFSET_BKGCOLOUR)); + clr1.SetColor(M.GetDword("cc4", SRMSGDEFSET_BKGCOLOUR)); + clr1.SetColor(M.GetDword("cc5", SRMSGDEFSET_BKGCOLOUR)); edtText.SendMsg(EM_SETREADONLY, TRUE, 0); return true; } @@ -640,11 +646,11 @@ public: delete m_pContainer; delete m_cache; - db_set_dw(0, SRMSGMOD_T, "cc1", SendDlgItemMessage(m_hwnd, IDC_COLOR1, CPM_GETCOLOUR, 0, 0)); - db_set_dw(0, SRMSGMOD_T, "cc2", SendDlgItemMessage(m_hwnd, IDC_COLOR2, CPM_GETCOLOUR, 0, 0)); - db_set_dw(0, SRMSGMOD_T, "cc3", SendDlgItemMessage(m_hwnd, IDC_COLOR3, CPM_GETCOLOUR, 0, 0)); - db_set_dw(0, SRMSGMOD_T, "cc4", SendDlgItemMessage(m_hwnd, IDC_COLOR4, CPM_GETCOLOUR, 0, 0)); - db_set_dw(0, SRMSGMOD_T, "cc5", SendDlgItemMessage(m_hwnd, IDC_COLOR5, CPM_GETCOLOUR, 0, 0)); + db_set_dw(0, SRMSGMOD_T, "cc1", clr1.GetColor()); + db_set_dw(0, SRMSGMOD_T, "cc2", clr2.GetColor()); + db_set_dw(0, SRMSGMOD_T, "cc3", clr3.GetColor()); + db_set_dw(0, SRMSGMOD_T, "cc4", clr4.GetColor()); + db_set_dw(0, SRMSGMOD_T, "cc5", clr5.GetColor()); } INT_PTR DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam) override -- cgit v1.2.3