add SetCharIncludes and SetCharExcludes utilities to wxTextValidator; use iterators when scanning wxStrings; fix typo in ContainsExcludedCharacters (reversed return values); modify the sample to show wxTextValidator with wxFILTER_EXCLUDE_CHAR_LIST

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@58573 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Francesco Montorsi
2009-01-31 22:41:51 +00:00
parent c27dce1818
commit fcd209b6a2
5 changed files with 72 additions and 21 deletions

View File

@@ -251,8 +251,8 @@ bool wxTextValidator::IsValid(const wxString& val, wxString* pErr) const
bool wxTextValidator::ContainsOnlyIncludedCharacters(const wxString& val) const
{
for (size_t i = 0; i < val.length(); i++)
if (m_includes.Index((wxString) val[i]) == wxNOT_FOUND)
for ( wxString::const_iterator i = val.begin(); i != val.end(); ++i )
if (m_includes.Index((wxString) *i) == wxNOT_FOUND)
// one character of 'val' is NOT present in m_includes...
return false;
@@ -262,13 +262,33 @@ bool wxTextValidator::ContainsOnlyIncludedCharacters(const wxString& val) const
bool wxTextValidator::ContainsExcludedCharacters(const wxString& val) const
{
for (size_t i = 0; i < val.length(); i++)
if (m_excludes.Index((wxString) val[i]) != wxNOT_FOUND)
for ( wxString::const_iterator i = val.begin(); i != val.end(); ++i )
if (m_excludes.Index((wxString) *i) != wxNOT_FOUND)
// one character of 'val' is present in m_excludes...
return false;
return true;
// all characters of 'val' are NOT present in m_excludes
return true;
return false;
}
void wxTextValidator::SetCharIncludes(const wxString& chars)
{
wxArrayString arr;
for ( wxString::const_iterator i = chars.begin(); i != chars.end(); ++i )
arr.Add(*i);
SetIncludes(arr);
}
void wxTextValidator::SetCharExcludes(const wxString& chars)
{
wxArrayString arr;
for ( wxString::const_iterator i = chars.begin(); i != chars.end(); ++i )
arr.Add(*i);
SetExcludes(arr);
}
void wxTextValidator::OnChar(wxKeyEvent& event)