From 0bfd173e521701e43a0e592db8a2c589e820c1e1 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Tue, 13 Aug 2019 21:25:02 +0300 Subject: last tabSRMM options dialog went to UI classes --- plugins/TabSRMM/src/chat_options.cpp | 4 +- plugins/TabSRMM/src/eventpopups.cpp | 312 +++++++++++++++++------------------ plugins/TabSRMM/src/msgoptions.cpp | 38 ++--- plugins/TabSRMM/src/stdafx.h | 6 +- 4 files changed, 174 insertions(+), 186 deletions(-) diff --git a/plugins/TabSRMM/src/chat_options.cpp b/plugins/TabSRMM/src/chat_options.cpp index 078c178a53..bf910c8ebb 100644 --- a/plugins/TabSRMM/src/chat_options.cpp +++ b/plugins/TabSRMM/src/chat_options.cpp @@ -545,7 +545,7 @@ public: { SetWindowLongPtr(treeCheck.GetHwnd(), GWL_STYLE, GetWindowLongPtr(treeCheck.GetHwnd(), GWL_STYLE) | (TVS_HASBUTTONS | TVS_CHECKBOXES | TVS_NOHSCROLL)); - TreeViewInit(treeCheck.GetHwnd(), lvGroupsChat, lvItemsChat, CHAT_MODULE); + TreeViewInit(treeCheck, lvGroupsChat, lvItemsChat, CHAT_MODULE); edtGroup.SetText(ptrW(Chat_GetGroup())); return true; @@ -555,7 +555,7 @@ public: { Chat_SetGroup(ptrW(edtGroup.GetText())); - TreeViewToDB(treeCheck.GetHwnd(), lvItemsChat, CHAT_MODULE, nullptr); + TreeViewToDB(treeCheck, lvItemsChat, CHAT_MODULE, nullptr); return true; } diff --git a/plugins/TabSRMM/src/eventpopups.cpp b/plugins/TabSRMM/src/eventpopups.cpp index d273f1994b..548bd5653a 100644 --- a/plugins/TabSRMM/src/eventpopups.cpp +++ b/plugins/TabSRMM/src/eventpopups.cpp @@ -38,8 +38,6 @@ static LIST arPopupList(10, NumericKeySortT); -BOOL bWmNotify = TRUE; - static PLUGIN_DATAT* PU_GetByContact(const MCONTACT hContact) { return arPopupList.find((PLUGIN_DATAT*)&hContact); @@ -71,7 +69,6 @@ static void CheckForRemoveMask() } } - int TSAPI NEN_ReadOptions(NEN_OPTIONS *options) { options->bPreview = (BOOL)db_get_b(0, MODULE, OPT_PREVIEW, TRUE); @@ -450,12 +447,6 @@ static int PopupShowT(NEN_OPTIONS *pluginOptions, MCONTACT hContact, MEVENT hEve return 0; } -static int TSAPI PopupPreview() -{ - PopupShowT(&nen_options, 0, 0, EVENTTYPE_MESSAGE, nullptr); - return 0; -} - static TOptionListItem lvItemsNEN[] = { { 0, LPGENW("Show a preview of the event"), IDC_CHKPREVIEW, LOI_TYPE_SETTING, (UINT_PTR)&nen_options.bPreview, 1 }, @@ -499,183 +490,180 @@ static TOptionListGroup lvGroupsNEN[] = { 0, nullptr } }; -static INT_PTR CALLBACK DlgProcPopupOpts(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) +class CPopupOptionsDlg : public CDlgBase { - switch (msg) { - case WM_INITDIALOG: - TranslateDialogDefault(hWnd); - { - TreeViewInit(GetDlgItem(hWnd, IDC_EVENTOPTIONS), lvGroupsNEN, lvItemsNEN, 0, 0, TRUE); - - SendDlgItemMessage(hWnd, IDC_COLBACK_MESSAGE, CPM_SETCOLOUR, 0, nen_options.colBackMsg); - SendDlgItemMessage(hWnd, IDC_COLTEXT_MESSAGE, CPM_SETCOLOUR, 0, nen_options.colTextMsg); - SendDlgItemMessage(hWnd, IDC_COLBACK_OTHERS, CPM_SETCOLOUR, 0, nen_options.colBackOthers); - SendDlgItemMessage(hWnd, IDC_COLTEXT_OTHERS, CPM_SETCOLOUR, 0, nen_options.colTextOthers); - SendDlgItemMessage(hWnd, IDC_COLBACK_ERR, CPM_SETCOLOUR, 0, nen_options.colBackErr); - SendDlgItemMessage(hWnd, IDC_COLTEXT_ERR, CPM_SETCOLOUR, 0, nen_options.colTextErr); - CheckDlgButton(hWnd, IDC_CHKDEFAULTCOL_MESSAGE, nen_options.bDefaultColorMsg ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hWnd, IDC_CHKDEFAULTCOL_OTHERS, nen_options.bDefaultColorOthers ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hWnd, IDC_CHKDEFAULTCOL_ERR, nen_options.bDefaultColorErr ? BST_CHECKED : BST_UNCHECKED); - - SendDlgItemMessage(hWnd, IDC_COLTEXT_MUC, CPM_SETCOLOUR, 0, g_Settings.crPUTextColour); - SendDlgItemMessage(hWnd, IDC_COLBACK_MUC, CPM_SETCOLOUR, 0, g_Settings.crPUBkgColour); - CheckDlgButton(hWnd, IDC_CHKDEFAULTCOL_MUC, g_Settings.iPopupStyle == 2 ? BST_CHECKED : BST_UNCHECKED); - - SendDlgItemMessage(hWnd, IDC_DELAY_MESSAGE_SPIN, UDM_SETRANGE, 0, MAKELONG(3600, -1)); - SendDlgItemMessage(hWnd, IDC_DELAY_OTHERS_SPIN, UDM_SETRANGE, 0, MAKELONG(3600, -1)); - SendDlgItemMessage(hWnd, IDC_DELAY_MESSAGE_MUC_SPIN, UDM_SETRANGE, 0, MAKELONG(3600, -1)); - SendDlgItemMessage(hWnd, IDC_DELAY_ERR_SPIN, UDM_SETRANGE, 0, MAKELONG(3600, -1)); - - SendDlgItemMessage(hWnd, IDC_DELAY_MESSAGE_SPIN, UDM_SETPOS, 0, (LPARAM)nen_options.iDelayMsg); - SendDlgItemMessage(hWnd, IDC_DELAY_OTHERS_SPIN, UDM_SETPOS, 0, (LPARAM)nen_options.iDelayOthers); - SendDlgItemMessage(hWnd, IDC_DELAY_ERR_SPIN, UDM_SETPOS, 0, (LPARAM)nen_options.iDelayErr); - SendDlgItemMessage(hWnd, IDC_DELAY_MESSAGE_MUC_SPIN, UDM_SETPOS, 0, (LPARAM)g_Settings.iPopupTimeout); - - Utils::enableDlgControl(hWnd, IDC_COLBACK_MESSAGE, !nen_options.bDefaultColorMsg); - Utils::enableDlgControl(hWnd, IDC_COLTEXT_MESSAGE, !nen_options.bDefaultColorMsg); - Utils::enableDlgControl(hWnd, IDC_COLBACK_OTHERS, !nen_options.bDefaultColorOthers); - Utils::enableDlgControl(hWnd, IDC_COLTEXT_OTHERS, !nen_options.bDefaultColorOthers); - Utils::enableDlgControl(hWnd, IDC_COLBACK_ERR, !nen_options.bDefaultColorErr); - Utils::enableDlgControl(hWnd, IDC_COLTEXT_ERR, !nen_options.bDefaultColorErr); - Utils::enableDlgControl(hWnd, IDC_COLTEXT_MUC, g_Settings.iPopupStyle == 3); - Utils::enableDlgControl(hWnd, IDC_COLBACK_MUC, g_Settings.iPopupStyle == 3); - - CheckDlgButton(hWnd, IDC_MUC_LOGCOLORS, g_Settings.iPopupStyle < 2 ? BST_CHECKED : BST_UNCHECKED); - Utils::enableDlgControl(hWnd, IDC_MUC_LOGCOLORS, g_Settings.iPopupStyle != 2); - - SetDlgItemInt(hWnd, IDC_MESSAGEPREVIEWLIMIT, nen_options.iLimitPreview, FALSE); - CheckDlgButton(hWnd, IDC_LIMITPREVIEW, (nen_options.iLimitPreview > 0) ? BST_CHECKED : BST_UNCHECKED); - SendDlgItemMessage(hWnd, IDC_MESSAGEPREVIEWLIMITSPIN, UDM_SETRANGE, 0, MAKELONG(2048, nen_options.iLimitPreview > 0 ? 50 : 0)); - SendDlgItemMessage(hWnd, IDC_MESSAGEPREVIEWLIMITSPIN, UDM_SETPOS, 0, (LPARAM)nen_options.iLimitPreview); - Utils::enableDlgControl(hWnd, IDC_MESSAGEPREVIEWLIMIT, IsDlgButtonChecked(hWnd, IDC_LIMITPREVIEW) != 0); - Utils::enableDlgControl(hWnd, IDC_MESSAGEPREVIEWLIMITSPIN, IsDlgButtonChecked(hWnd, IDC_LIMITPREVIEW) != 0); - - bWmNotify = FALSE; - } - return TRUE; + CCtrlTreeView eventOptions; + CCtrlButton btnPreview, btnModes; + +public: + CPopupOptionsDlg() : + CDlgBase(g_plugin, IDD_POPUP_OPT), + btnModes(this, IDC_POPUPSTATUSMODES), + btnPreview(this, IDC_PREVIEW), + eventOptions(this, IDC_EVENTOPTIONS) + { + btnModes.OnClick = Callback(this, &CPopupOptionsDlg::onClick_Modes); + btnPreview.OnClick = Callback(this, &CPopupOptionsDlg::onClick_Preview); + } - case WM_DESTROY: - bWmNotify = TRUE; - break; + bool OnInitDialog() override + { + 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); + 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); + 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)); + SendDlgItemMessage(m_hwnd, IDC_DELAY_OTHERS_SPIN, UDM_SETRANGE, 0, MAKELONG(3600, -1)); + SendDlgItemMessage(m_hwnd, IDC_DELAY_MESSAGE_MUC_SPIN, UDM_SETRANGE, 0, MAKELONG(3600, -1)); + SendDlgItemMessage(m_hwnd, IDC_DELAY_ERR_SPIN, UDM_SETRANGE, 0, MAKELONG(3600, -1)); + + SendDlgItemMessage(m_hwnd, IDC_DELAY_MESSAGE_SPIN, UDM_SETPOS, 0, (LPARAM)nen_options.iDelayMsg); + SendDlgItemMessage(m_hwnd, IDC_DELAY_OTHERS_SPIN, UDM_SETPOS, 0, (LPARAM)nen_options.iDelayOthers); + 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); + + 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); + + SetDlgItemInt(m_hwnd, IDC_MESSAGEPREVIEWLIMIT, nen_options.iLimitPreview, FALSE); + CheckDlgButton(m_hwnd, IDC_LIMITPREVIEW, (nen_options.iLimitPreview > 0) ? BST_CHECKED : BST_UNCHECKED); + SendDlgItemMessage(m_hwnd, IDC_MESSAGEPREVIEWLIMITSPIN, UDM_SETRANGE, 0, MAKELONG(2048, nen_options.iLimitPreview > 0 ? 50 : 0)); + SendDlgItemMessage(m_hwnd, IDC_MESSAGEPREVIEWLIMITSPIN, UDM_SETPOS, 0, (LPARAM)nen_options.iLimitPreview); + Utils::enableDlgControl(m_hwnd, IDC_MESSAGEPREVIEWLIMIT, IsDlgButtonChecked(m_hwnd, IDC_LIMITPREVIEW) != 0); + Utils::enableDlgControl(m_hwnd, IDC_MESSAGEPREVIEWLIMITSPIN, IsDlgButtonChecked(m_hwnd, IDC_LIMITPREVIEW) != 0); + return true; + } - case DM_STATUSMASKSET: - // configure the option page - hide most of the settings here when either IEView - db_set_dw(0, MODULE, "statusmask", (DWORD)lParam); - nen_options.dwStatusMask = (int)lParam; - break; + bool OnApply() override + { + // scan the tree view and obtain the options... + TreeViewToDB(eventOptions, lvItemsNEN, nullptr, nullptr); - case WM_COMMAND: - if (!bWmNotify) { - switch (LOWORD(wParam)) { - case IDC_PREVIEW: - PopupPreview(); - break; - - case IDC_POPUPSTATUSMODES: - CreateDialogParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_CHOOSESTATUSMODES), hWnd, DlgProcSetupStatusModes, db_get_dw(0, MODULE, "statusmask", (DWORD)-1)); - break; - - default: - if (IsDlgButtonChecked(hWnd, IDC_CHKDEFAULTCOL_MUC)) - g_Settings.iPopupStyle = 2; - else if (IsDlgButtonChecked(hWnd, IDC_MUC_LOGCOLORS)) - g_Settings.iPopupStyle = 1; - else - g_Settings.iPopupStyle = 3; - - Utils::enableDlgControl(hWnd, IDC_MUC_LOGCOLORS, g_Settings.iPopupStyle != 2); - - nen_options.bDefaultColorMsg = IsDlgButtonChecked(hWnd, IDC_CHKDEFAULTCOL_MESSAGE); - nen_options.bDefaultColorOthers = IsDlgButtonChecked(hWnd, IDC_CHKDEFAULTCOL_OTHERS); - nen_options.bDefaultColorErr = IsDlgButtonChecked(hWnd, IDC_CHKDEFAULTCOL_ERR); - - nen_options.iDelayMsg = SendDlgItemMessage(hWnd, IDC_DELAY_MESSAGE_SPIN, UDM_GETPOS, 0, 0); - nen_options.iDelayOthers = SendDlgItemMessage(hWnd, IDC_DELAY_OTHERS_SPIN, UDM_GETPOS, 0, 0); - nen_options.iDelayErr = SendDlgItemMessage(hWnd, IDC_DELAY_ERR_SPIN, UDM_GETPOS, 0, 0); - - g_Settings.iPopupTimeout = SendDlgItemMessage(hWnd, IDC_DELAY_MESSAGE_MUC_SPIN, UDM_GETPOS, 0, 0); - - if (IsDlgButtonChecked(hWnd, IDC_LIMITPREVIEW)) - nen_options.iLimitPreview = GetDlgItemInt(hWnd, IDC_MESSAGEPREVIEWLIMIT, nullptr, FALSE); - else - nen_options.iLimitPreview = 0; - Utils::enableDlgControl(hWnd, IDC_COLBACK_MESSAGE, !nen_options.bDefaultColorMsg); - Utils::enableDlgControl(hWnd, IDC_COLTEXT_MESSAGE, !nen_options.bDefaultColorMsg); - Utils::enableDlgControl(hWnd, IDC_COLBACK_OTHERS, !nen_options.bDefaultColorOthers); - Utils::enableDlgControl(hWnd, IDC_COLTEXT_OTHERS, !nen_options.bDefaultColorOthers); - Utils::enableDlgControl(hWnd, IDC_COLBACK_ERR, !nen_options.bDefaultColorErr); - Utils::enableDlgControl(hWnd, IDC_COLTEXT_ERR, !nen_options.bDefaultColorErr); - Utils::enableDlgControl(hWnd, IDC_COLTEXT_MUC, g_Settings.iPopupStyle == 3); - Utils::enableDlgControl(hWnd, IDC_COLBACK_MUC, g_Settings.iPopupStyle == 3); - - Utils::enableDlgControl(hWnd, IDC_MESSAGEPREVIEWLIMIT, IsDlgButtonChecked(hWnd, IDC_LIMITPREVIEW) != 0); - Utils::enableDlgControl(hWnd, IDC_MESSAGEPREVIEWLIMITSPIN, IsDlgButtonChecked(hWnd, IDC_LIMITPREVIEW) != 0); - - // disable delay textbox when infinite is checked - Utils::enableDlgControl(hWnd, IDC_DELAY_MESSAGE, nen_options.iDelayMsg != -1); - Utils::enableDlgControl(hWnd, IDC_DELAY_OTHERS, nen_options.iDelayOthers != -1); - Utils::enableDlgControl(hWnd, IDC_DELAY_ERR, nen_options.iDelayErr != -1); - Utils::enableDlgControl(hWnd, IDC_DELAY_MUC, g_Settings.iPopupTimeout != -1); - - if (HIWORD(wParam) == CPN_COLOURCHANGED) { - nen_options.colBackMsg = SendDlgItemMessage(hWnd, IDC_COLBACK_MESSAGE, CPM_GETCOLOUR, 0, 0); - nen_options.colTextMsg = SendDlgItemMessage(hWnd, IDC_COLTEXT_MESSAGE, CPM_GETCOLOUR, 0, 0); - nen_options.colBackOthers = SendDlgItemMessage(hWnd, IDC_COLBACK_OTHERS, CPM_GETCOLOUR, 0, 0); - nen_options.colTextOthers = SendDlgItemMessage(hWnd, IDC_COLTEXT_OTHERS, CPM_GETCOLOUR, 0, 0); - nen_options.colBackErr = SendDlgItemMessage(hWnd, IDC_COLBACK_ERR, CPM_GETCOLOUR, 0, 0); - nen_options.colTextErr = SendDlgItemMessage(hWnd, IDC_COLTEXT_ERR, CPM_GETCOLOUR, 0, 0); - g_Settings.crPUBkgColour = SendDlgItemMessage(hWnd, IDC_COLBACK_MUC, CPM_GETCOLOUR, 0, 0); - g_Settings.crPUTextColour = SendDlgItemMessage(hWnd, IDC_COLTEXT_MUC, CPM_GETCOLOUR, 0, 0); - } - SendMessage(GetParent(hWnd), PSM_CHANGED, 0, 0); - break; - } - } - break; + db_set_b(0, CHAT_MODULE, "PopupStyle", (BYTE)g_Settings.iPopupStyle); + db_set_w(0, CHAT_MODULE, "PopupTimeout", g_Settings.iPopupTimeout); - case WM_NOTIFY: - switch (((LPNMHDR)lParam)->code) { - case PSN_RESET: - NEN_ReadOptions(&nen_options); - break; + 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); - case PSN_APPLY: - // scan the tree view and obtain the options... - TreeViewToDB(GetDlgItem(hWnd, IDC_EVENTOPTIONS), lvItemsNEN, nullptr, nullptr); + NEN_WriteOptions(&nen_options); + CheckForRemoveMask(); + CreateSystrayIcon(nen_options.bTraySupport); + SetEvent(g_hEvent); // wake up the thread which cares about the floater and tray + return true; + } - db_set_b(0, CHAT_MODULE, "PopupStyle", (BYTE)g_Settings.iPopupStyle); - db_set_w(0, CHAT_MODULE, "PopupTimeout", g_Settings.iPopupTimeout); + INT_PTR DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) override + { + if (msg == WM_COMMAND && wParam == DM_STATUSMASKSET) { + db_set_dw(0, MODULE, "statusmask", (DWORD)lParam); + nen_options.dwStatusMask = (int)lParam; + } - g_Settings.crPUBkgColour = SendDlgItemMessage(hWnd, IDC_COLBACK_MUC, CPM_GETCOLOUR, 0, 0); - db_set_dw(0, CHAT_MODULE, "PopupColorBG", (DWORD)g_Settings.crPUBkgColour); - g_Settings.crPUTextColour = SendDlgItemMessage(hWnd, IDC_COLTEXT_MUC, CPM_GETCOLOUR, 0, 0); - db_set_dw(0, CHAT_MODULE, "PopupColorText", (DWORD)g_Settings.crPUTextColour); + return CDlgBase::DlgProc(msg, wParam, lParam); + } - NEN_WriteOptions(&nen_options); - CheckForRemoveMask(); - CreateSystrayIcon(nen_options.bTraySupport); - SetEvent(g_hEvent); // wake up the thread which cares about the floater and tray - } - break; + void onClick_Preview(CCtrlButton *) + { + PopupShowT(&nen_options, 0, 0, EVENTTYPE_MESSAGE, nullptr); } - return FALSE; -} + void onClick_Modes(CCtrlButton *) + { + CreateDialogParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_CHOOSESTATUSMODES), m_hwnd, DlgProcSetupStatusModes, db_get_dw(0, MODULE, "statusmask", (DWORD)-1)); + } + + void OnChange() override + { + if (IsDlgButtonChecked(m_hwnd, IDC_CHKDEFAULTCOL_MUC)) + g_Settings.iPopupStyle = 2; + else if (IsDlgButtonChecked(m_hwnd, IDC_MUC_LOGCOLORS)) + g_Settings.iPopupStyle = 1; + else + g_Settings.iPopupStyle = 3; + + Utils::enableDlgControl(m_hwnd, IDC_MUC_LOGCOLORS, g_Settings.iPopupStyle != 2); + + nen_options.bDefaultColorMsg = IsDlgButtonChecked(m_hwnd, IDC_CHKDEFAULTCOL_MESSAGE); + nen_options.bDefaultColorOthers = IsDlgButtonChecked(m_hwnd, IDC_CHKDEFAULTCOL_OTHERS); + nen_options.bDefaultColorErr = IsDlgButtonChecked(m_hwnd, IDC_CHKDEFAULTCOL_ERR); + + nen_options.iDelayMsg = SendDlgItemMessage(m_hwnd, IDC_DELAY_MESSAGE_SPIN, UDM_GETPOS, 0, 0); + nen_options.iDelayOthers = SendDlgItemMessage(m_hwnd, IDC_DELAY_OTHERS_SPIN, UDM_GETPOS, 0, 0); + nen_options.iDelayErr = SendDlgItemMessage(m_hwnd, IDC_DELAY_ERR_SPIN, UDM_GETPOS, 0, 0); + + g_Settings.iPopupTimeout = SendDlgItemMessage(m_hwnd, IDC_DELAY_MESSAGE_MUC_SPIN, UDM_GETPOS, 0, 0); + + if (IsDlgButtonChecked(m_hwnd, IDC_LIMITPREVIEW)) + 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); + + Utils::enableDlgControl(m_hwnd, IDC_MESSAGEPREVIEWLIMIT, IsDlgButtonChecked(m_hwnd, IDC_LIMITPREVIEW) != 0); + Utils::enableDlgControl(m_hwnd, IDC_MESSAGEPREVIEWLIMITSPIN, IsDlgButtonChecked(m_hwnd, IDC_LIMITPREVIEW) != 0); + + // disable delay textbox when infinite is checked + Utils::enableDlgControl(m_hwnd, IDC_DELAY_MESSAGE, nen_options.iDelayMsg != -1); + Utils::enableDlgControl(m_hwnd, IDC_DELAY_OTHERS, nen_options.iDelayOthers != -1); + 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); + } +}; void Popup_Options(WPARAM wParam) { OPTIONSDIALOGPAGE odp = {}; odp.flags = ODPF_BOLDGROUPS; odp.position = 910000000; - odp.pszTemplate = MAKEINTRESOURCEA(IDD_POPUP_OPT); + odp.pDialog = new CPopupOptionsDlg(); odp.szTitle.a = LPGEN("Event notifications"); odp.szGroup.a = LPGEN("Popups"); - odp.pfnDlgProc = DlgProcPopupOpts; g_plugin.addOptions(wParam, &odp); } +///////////////////////////////////////////////////////////////////////////////////////// // updates the menu entry... // bForced is used to only update the status, nickname etc. and does NOT update the unread count + void TSAPI UpdateTrayMenuState(CTabBaseDlg *dat, BOOL bForced) { if (PluginConfig.g_hMenuTrayUnread == nullptr || dat->m_hContact == 0) diff --git a/plugins/TabSRMM/src/msgoptions.cpp b/plugins/TabSRMM/src/msgoptions.cpp index ab20605b56..101850dd1a 100644 --- a/plugins/TabSRMM/src/msgoptions.cpp +++ b/plugins/TabSRMM/src/msgoptions.cpp @@ -55,9 +55,9 @@ void LoadLogfont(int section, int i, LOGFONTA * lf, COLORREF * colour, char *szM ///////////////////////////////////////////////////////////////////////////////////////// -void TreeViewInit(HWND hwndTree, TOptionListGroup *lvGroups, TOptionListItem *lvItems, const char *DBPath, DWORD dwFlags, bool bFromMem) +void TreeViewInit(CCtrlTreeView &ctrl, TOptionListGroup *lvGroups, TOptionListItem *lvItems, const char *DBPath, DWORD dwFlags, bool bFromMem) { - SetWindowLongPtr(hwndTree, GWL_STYLE, GetWindowLongPtr(hwndTree, GWL_STYLE) | (TVS_HASBUTTONS | TVS_CHECKBOXES | TVS_NOHSCROLL)); + SetWindowLongPtr(ctrl.GetHwnd(), GWL_STYLE, GetWindowLongPtr(ctrl.GetHwnd(), GWL_STYLE) | (TVS_HASBUTTONS | TVS_CHECKBOXES | TVS_NOHSCROLL)); // fill the list box, create groups first, then add items TVINSERTSTRUCT tvi = {}; @@ -68,9 +68,9 @@ void TreeViewInit(HWND hwndTree, TOptionListGroup *lvGroups, TOptionListItem *lv tvi.item.pszText = TranslateW(lvGroups[i].szName); tvi.item.stateMask = TVIS_EXPANDED | TVIS_BOLD; tvi.item.state = TVIS_EXPANDED | TVIS_BOLD; - lvGroups[i].handle = TreeView_InsertItem(hwndTree, &tvi); + lvGroups[i].handle = ctrl.InsertItem(&tvi); - TreeView_SetItemState(hwndTree, lvGroups[i].handle, 0, TVIS_STATEIMAGEMASK); + ctrl.SetItemState(lvGroups[i].handle, 0, TVIS_STATEIMAGEMASK); } for (auto *p = lvItems; p->szName != nullptr; p++) { @@ -79,7 +79,7 @@ void TreeViewInit(HWND hwndTree, TOptionListGroup *lvGroups, TOptionListItem *lv tvi.item.pszText = TranslateW(p->szName); tvi.item.mask = TVIF_TEXT | TVIF_PARAM; tvi.item.lParam = p - lvItems; - p->handle = TreeView_InsertItem(hwndTree, &tvi); + p->handle = ctrl.InsertItem(&tvi); BOOL bCheck = FALSE; if (bFromMem == FALSE) { @@ -102,11 +102,11 @@ void TreeViewInit(HWND hwndTree, TOptionListGroup *lvGroups, TOptionListItem *lv break; } } - TreeView_SetCheckState(hwndTree, p->handle, bCheck); + ctrl.SetCheckState(p->handle, bCheck); } } -void TreeViewSetFromDB(HWND hwndTree, TOptionListItem *lvItems, DWORD dwFlags) +void TreeViewSetFromDB(CCtrlTreeView &ctrl, TOptionListItem *lvItems, DWORD dwFlags) { for (auto *p = lvItems; p->szName != nullptr; p++) { BOOL bCheck = FALSE; @@ -114,14 +114,14 @@ void TreeViewSetFromDB(HWND hwndTree, TOptionListItem *lvItems, DWORD dwFlags) bCheck = (dwFlags & (UINT)p->lParam) != 0; else if (p->uType == LOI_TYPE_SETTING) bCheck = M.GetByte((char *)p->lParam, p->id); - TreeView_SetCheckState(hwndTree, p->handle, bCheck); + ctrl.SetCheckState(p->handle, bCheck); } } -void TreeViewToDB(HWND hwndTree, TOptionListItem *lvItems, const char *DBPath, DWORD *dwFlags) +void TreeViewToDB(CCtrlTreeView &ctrl, TOptionListItem *lvItems, const char *DBPath, DWORD *dwFlags) { for (auto *p = lvItems; p->szName != nullptr; p++) { - UINT iState = TreeView_GetCheckState(hwndTree, p->handle); + UINT iState = ctrl.GetCheckState(p->handle); switch (p->uType) { case LOI_TYPE_FLAG: @@ -537,7 +537,7 @@ public: bool OnInitDialog() override { - TreeViewInit(treeOpts.GetHwnd(), lvGroupsMsg, lvItemsMsg, SRMSGMOD_T); + TreeViewInit(treeOpts, lvGroupsMsg, lvItemsMsg, SRMSGMOD_T); chkAvaPreserve.SetState(M.GetByte("dontscaleavatars", 0)); @@ -551,7 +551,7 @@ public: db_set_b(0, SRMSGMOD_T, "dontscaleavatars", chkAvaPreserve.GetState()); // scan the tree view and obtain the options... - TreeViewToDB(treeOpts.GetHwnd(), lvItemsMsg, SRMSGMOD_T, nullptr); + TreeViewToDB(treeOpts, lvItemsMsg, SRMSGMOD_T, nullptr); PluginConfig.reloadSettings(); Srmm_Broadcast(DM_OPTIONSAPPLIED, 1, 0); return true; @@ -676,7 +676,7 @@ public: break; } - TreeViewInit(logOpts.GetHwnd(), lvGroupsLog, lvItemsLog, SRMSGMOD_T, dwFlags); + TreeViewInit(logOpts, lvGroupsLog, lvItemsLog, SRMSGMOD_T, dwFlags); spnLeft.SetPosition(M.GetDword("IndentAmount", 20)); spnRight.SetPosition(M.GetDword("RightIndent", 20)); @@ -748,7 +748,7 @@ public: } // scan the tree view and obtain the options... - TreeViewToDB(logOpts.GetHwnd(), lvItemsLog, SRMSGMOD_T, &dwFlags); + TreeViewToDB(logOpts, lvItemsLog, SRMSGMOD_T, &dwFlags); db_set_dw(0, SRMSGMOD_T, "mwflags", dwFlags); if (chkAlwaysTrim.GetState()) db_set_dw(0, SRMSGMOD_T, "maxhist", spnTrim.GetPosition()); @@ -1013,7 +1013,7 @@ public: bool OnInitDialog() override { - TreeViewInit(tabOptions.GetHwnd(), lvGroupsTab, lvItemsTab, SRMSGMOD_T); + TreeViewInit(tabOptions, lvGroupsTab, lvItemsTab, SRMSGMOD_T); chkLimit.SetState(M.GetByte("cuttitle", 0)); spnLimit.SetPosition(db_get_w(0, SRMSGMOD_T, "cut_at", 15)); @@ -1033,7 +1033,7 @@ public: db_set_b(0, SRMSGMOD_T, "cuttitle", chkLimit.GetState()); db_set_b(0, SRMSGMOD_T, "escmode", cmbEscMode.GetCurSel()); - TreeViewToDB(tabOptions.GetHwnd(), lvItemsTab, SRMSGMOD_T, nullptr); + TreeViewToDB(tabOptions, lvItemsTab, SRMSGMOD_T, nullptr); PluginConfig.reloadSettings(); Srmm_Broadcast(DM_OPTIONSAPPLIED, 0, 0); @@ -1195,7 +1195,7 @@ public: bool OnInitDialog() override { - TreeViewInit(plusOptions.GetHwnd(), lvGroupsModPlus, lvItemsModPlus, SRMSGMOD_T); + TreeViewInit(plusOptions, lvGroupsModPlus, lvItemsModPlus, SRMSGMOD_T); spnTimeout.SetPosition(PluginConfig.m_MsgTimeout / 1000); spnHistSize.SetPosition(M.GetByte("historysize", 0)); @@ -1204,7 +1204,7 @@ public: bool OnApply() override { - TreeViewToDB(plusOptions.GetHwnd(), lvItemsModPlus, SRMSGMOD_T, nullptr); + TreeViewToDB(plusOptions, lvItemsModPlus, SRMSGMOD_T, nullptr); int msgTimeout = 1000 * spnTimeout.GetPosition(); PluginConfig.m_MsgTimeout = msgTimeout >= SRMSGSET_MSGTIMEOUT_MIN ? msgTimeout : SRMSGSET_MSGTIMEOUT_MIN; @@ -1221,7 +1221,7 @@ public: if (it.uType == LOI_TYPE_SETTING) db_set_b(0, SRMSGMOD_T, (char *)it.lParam, it.id); - TreeViewSetFromDB(GetDlgItem(m_hwnd, IDC_PLUS_CHECKTREE), lvItemsModPlus, 0); + TreeViewSetFromDB(plusOptions, lvItemsModPlus, 0); } }; diff --git a/plugins/TabSRMM/src/stdafx.h b/plugins/TabSRMM/src/stdafx.h index 24125e6f09..551630bf7f 100644 --- a/plugins/TabSRMM/src/stdafx.h +++ b/plugins/TabSRMM/src/stdafx.h @@ -240,9 +240,9 @@ INT_PTR SendMessageCommand(WPARAM, LPARAM); INT_PTR SendMessageCommand_W(WPARAM, LPARAM); INT_PTR SetUserPrefs(WPARAM, LPARAM); -void TreeViewInit(HWND hwndTree, TOptionListGroup *lvGroups, TOptionListItem *lvItems, const char *DBPath, DWORD dwFlags = 0, bool bFromMem = false); -void TreeViewSetFromDB(HWND hwndTree, TOptionListItem *lvItems, DWORD dwFlags); -void TreeViewToDB(HWND hwndTree, TOptionListItem *lvItems, const char *DBPath, DWORD *dwFlags); +void TreeViewInit(CCtrlTreeView&, TOptionListGroup *lvGroups, TOptionListItem *lvItems, const char *DBPath, DWORD dwFlags = 0, bool bFromMem = false); +void TreeViewSetFromDB(CCtrlTreeView&, TOptionListItem *lvItems, DWORD dwFlags); +void TreeViewToDB(CCtrlTreeView&, TOptionListItem *lvItems, const char *DBPath, DWORD *dwFlags); INT_PTR CALLBACK DlgProcSetupStatusModes(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam); -- cgit v1.2.3