summaryrefslogtreecommitdiff
path: root/plugins/IgnoreState/src/options.cpp
diff options
context:
space:
mode:
authorKirill Volinsky <Mataes2007@gmail.com>2018-12-26 13:53:09 +0300
committerKirill Volinsky <Mataes2007@gmail.com>2018-12-26 13:53:09 +0300
commit6ee11a1b2f808a034857be75ed8aefa24879b3d6 (patch)
tree4b5a0cc596bc04619fdf2543d245b7dd977ebb8d /plugins/IgnoreState/src/options.cpp
parent7c95036f1097a757172cfbc80387acb79875e174 (diff)
IgnoreState: moved to m_gui
Diffstat (limited to 'plugins/IgnoreState/src/options.cpp')
-rw-r--r--plugins/IgnoreState/src/options.cpp124
1 files changed, 52 insertions, 72 deletions
diff --git a/plugins/IgnoreState/src/options.cpp b/plugins/IgnoreState/src/options.cpp
index 3dc51d64a8..d662672517 100644
--- a/plugins/IgnoreState/src/options.cpp
+++ b/plugins/IgnoreState/src/options.cpp
@@ -20,85 +20,66 @@
#include "stdafx.h"
-#define MS_SKINENG_DRAWICONEXFIX "SkinEngine/DrawIconEx_Fix"
-
-static bool bInitializing;
-
-INT_PTR CALLBACK DlgProcOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+COptDialog::COptDialog() :
+ CDlgBase(g_plugin, IDD_IGNORE_OPT),
+ m_tvFilter(this, IDC_FILTER),
+ m_chkIgnoreAll(this, IDC_IGNORE_IGNOREALL)
{
- HWND hTree = GetDlgItem(hwndDlg, IDC_FILTER);
-
- switch (msg) {
- case WM_INITDIALOG:
- TranslateDialogDefault(hwndDlg);
- bInitializing = true;
- fill_filter();
-
- SetWindowLongPtr(hTree, GWL_STYLE, GetWindowLongPtr(hTree, GWL_STYLE) | TVS_NOHSCROLL);
- {
- HIMAGELIST himlButtonIcons = ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), ILC_COLOR32 | ILC_MASK, 2, 2);
- TreeView_SetImageList(hTree, himlButtonIcons, TVSIL_NORMAL);
- TreeView_DeleteAllItems(hTree);
+ m_chkIgnoreAll.OnChange = Callback(this, &COptDialog::OnIgnoreAllChange);
+}
- for (int i = 2; i < nII; i++) { // we don`t need it IGNORE_ALL and IGNORE_MESSAGE
- TVINSERTSTRUCT tvis = {};
- int index = ImageList_AddIcon(himlButtonIcons, Skin_LoadIcon(ii[i].icon));
- tvis.hParent = nullptr;
- tvis.hInsertAfter = TVI_LAST;
- tvis.item.mask = TVIF_PARAM | TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_STATE;
- tvis.item.lParam = ii[i].type;
- tvis.item.pszText = TranslateW(ii[i].name);
- tvis.item.iImage = tvis.item.iSelectedImage = index;
- HTREEITEM hti = TreeView_InsertItem(hTree, &tvis);
- TreeView_SetCheckState(hTree, hti, checkState(ii[i].type));
- }
+bool COptDialog::OnInitDialog()
+{
+ fill_filter();
+ SetWindowLongPtr(m_tvFilter.GetHwnd(), GWL_STYLE, GetWindowLongPtr(m_tvFilter.GetHwnd(), GWL_STYLE) | TVS_NOHSCROLL);
+ {
+ HIMAGELIST himlButtonIcons = ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), ILC_COLOR32 | ILC_MASK, 2, 2);
+ m_tvFilter.SetImageList(himlButtonIcons, TVSIL_NORMAL);
+ m_tvFilter.DeleteAllItems();
+
+ for (int i = 2; i < nII; i++) { // we don`t need it IGNORE_ALL and IGNORE_MESSAGE
+ TVINSERTSTRUCT tvis = {};
+ int index = ImageList_AddIcon(himlButtonIcons, Skin_LoadIcon(ii[i].icon));
+ tvis.hParent = nullptr;
+ tvis.hInsertAfter = TVI_LAST;
+ tvis.item.mask = TVIF_PARAM | TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_STATE;
+ tvis.item.lParam = ii[i].type;
+ tvis.item.pszText = TranslateW(ii[i].name);
+ tvis.item.iImage = tvis.item.iSelectedImage = index;
+ HTREEITEM hti = m_tvFilter.InsertItem(&tvis);
+ m_tvFilter.SetCheckState(hti, checkState(ii[i].type));
}
+ }
- CheckDlgButton(hwndDlg, IDC_IGNORE_IGNOREALL, bUseMirandaSettings ? BST_CHECKED : BST_UNCHECKED);
- EnableWindow(GetDlgItem(hwndDlg, IDC_FILTER), !bUseMirandaSettings);
+ m_chkIgnoreAll.SetState(bUseMirandaSettings);
+ m_tvFilter.Enable(!bUseMirandaSettings);
- bInitializing = false;
- return TRUE;
+ return true;
+}
- case WM_COMMAND:
- switch (LOWORD(wParam)) {
- case IDC_IGNORE_IGNOREALL:
- EnableWindow(GetDlgItem(hwndDlg, IDC_FILTER), BST_UNCHECKED == IsDlgButtonChecked(hwndDlg, IDC_IGNORE_IGNOREALL));
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- break;
- }
- break;
+void COptDialog::OnIgnoreAllChange(CCtrlBase*)
+{
+ m_tvFilter.Enable(!m_chkIgnoreAll.GetState());
+}
- case WM_NOTIFY:
- switch (((LPNMHDR)lParam)->idFrom) {
- case 0:
- switch (((LPNMHDR)lParam)->code) {
- case PSN_APPLY:
- {
- DWORD flags = 0;
- TVITEM tvi;
- tvi.mask = TVIF_HANDLE | TBIF_LPARAM;
- tvi.hItem = TreeView_GetRoot(hTree); //check ignore all
- while (tvi.hItem) {
- TreeView_GetItem(hTree, &tvi);
- if (TreeView_GetCheckState(hTree, tvi.hItem)) flags |= 1 << (tvi.lParam - 1);
- tvi.hItem = TreeView_GetNextSibling(hTree, tvi.hItem);
- }
- g_plugin.setDword("Filter", flags);
+bool COptDialog::OnApply()
+{
+ DWORD flags = 0;
+ TVITEMEX tvi;
+ tvi.mask = TVIF_HANDLE | TBIF_LPARAM;
+ tvi.hItem = m_tvFilter.GetRoot(); //check ignore all
+ while (tvi.hItem) {
+ m_tvFilter.GetItem(&tvi);
+ if (m_tvFilter.GetCheckState(tvi.hItem)) flags |= 1 << (tvi.lParam - 1);
+ tvi.hItem = m_tvFilter.GetNextSibling(tvi.hItem);
+ }
+ g_plugin.setDword("Filter", flags);
- bUseMirandaSettings = IsDlgButtonChecked(hwndDlg, IDC_IGNORE_IGNOREALL) ? 1 : 0;
- g_plugin.setByte("UseMirandaSettings", bUseMirandaSettings);
+ bUseMirandaSettings = m_chkIgnoreAll.GetState();
+ g_plugin.setByte("UseMirandaSettings", bUseMirandaSettings);
- fill_filter();
- }
- }
- case IDC_FILTER:
- if (((LPNMHDR)lParam)->code == NM_CLICK)
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- break;
- }
- }
- return FALSE;
+ fill_filter();
+ return true;
}
int onOptInitialise(WPARAM wParam, LPARAM)
@@ -106,9 +87,8 @@ int onOptInitialise(WPARAM wParam, LPARAM)
OPTIONSDIALOGPAGE odp = {};
odp.flags = ODPF_BOLDGROUPS;
odp.szGroup.a = LPGEN("Icons");
- odp.pszTemplate = MAKEINTRESOURCEA(IDD_IGNORE_OPT);
odp.szTitle.a = LPGEN("Ignore State");
- odp.pfnDlgProc = DlgProcOptions;
+ odp.pDialog = new COptDialog;
g_plugin.addOptions(wParam, &odp);
return 0;
}