Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modify the "Substitution Filters" dialog. #2068

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions Src/SubstitutionFiltersDlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ BEGIN_MESSAGE_MAP(SubstitutionFiltersDlg, CTrPropertyPage)
ON_BN_CLICKED(IDC_LFILTER_ADDBTN, OnBnClickedAddBtn)
ON_BN_CLICKED(IDC_LFILTER_CLEARBTN, OnBnClickedClearBtn)
ON_BN_CLICKED(IDC_LFILTER_REMOVEBTN, OnBnClickedRemovebtn)
ON_NOTIFY(LVN_ITEMCHANGED, IDC_SUBSTITUTION_FILTERS, OnLvnItemChangedSubstitutionFilterList)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()

Expand All @@ -68,6 +69,8 @@ BOOL SubstitutionFiltersDlg::OnInitDialog()

InitList();

SetButtonState();

return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
Expand Down Expand Up @@ -145,6 +148,8 @@ void SubstitutionFiltersDlg::OnBnClickedAddBtn()
void SubstitutionFiltersDlg::OnBnClickedClearBtn()
{
m_listFilters.DeleteAllItems();

SetButtonState();
}

/**
Expand Down Expand Up @@ -211,4 +216,40 @@ void SubstitutionFiltersDlg::OnBnClickedRemovebtn()
bool bPartialOk = false;
m_listFilters.EnsureVisible(newSel, bPartialOk);
}

SetButtonState();
}

/**
* @brief Called when item state is changed.
*
* Set the state of the "Remove" and "Clear" buttons.
* @param [in] pNMHDR Listview item data.
* @param [out] pResult Result of the action is returned in here.
*/
void SubstitutionFiltersDlg::OnLvnItemChangedSubstitutionFilterList(NMHDR* pNMHDR, LRESULT* pResult)
{
LPNMLISTVIEW pNMLV = reinterpret_cast<LPNMLISTVIEW>(pNMHDR);
if ((pNMLV->uOldState & LVIS_SELECTED) != (pNMLV->uNewState & LVIS_SELECTED))
{
SetButtonState();
}
*pResult = 0;
}

/**
* @brief Set the state of the "Remove" and "Clear" buttons.
*
* Disable the "Remove" button when no item is selected.
* Disable the "Clear" button when no item is registered in the list.
*/
void SubstitutionFiltersDlg::SetButtonState()
{
int sel = -1;
sel = m_listFilters.GetNextItem(sel, LVNI_SELECTED);
bool enabled = (sel != -1);
EnableDlgItem(IDC_LFILTER_REMOVEBTN, enabled);

enabled = (m_listFilters.GetItemCount() > 0);
EnableDlgItem(IDC_LFILTER_CLEARBTN, enabled);
}
3 changes: 3 additions & 0 deletions Src/SubstitutionFiltersDlg.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class SubstitutionFiltersDlg : public CTrPropertyPage
afx_msg void OnBnClickedAddBtn();
afx_msg void OnBnClickedClearBtn();
afx_msg void OnBnClickedRemovebtn();
afx_msg void OnLvnItemChangedSubstitutionFilterList(NMHDR* pNMHDR, LRESULT* pResult);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()

Expand All @@ -54,4 +55,6 @@ class SubstitutionFiltersDlg : public CTrPropertyPage
CSubeditList m_listFilters; /**< List control having filter strings */

SubstitutionFiltersList *m_pSubstitutionFiltersList;

void SetButtonState();
};
Loading