I'll share with you my hack on customizing wxTextValidator to suit your needs...
1) grab (valtext.h and valtext.cpp) from wx source tree and make these changes:
*** valtext.h changes ***
include <wx/regex.h>
static const long wxFILTER_SPACE = 0x400; // allow you enter spaces and not filter them out.
// works reliably in conjunction with wxFILTER_REGEX only, unfortunately
static const long wxFILTER_REGEX = 0x800;
// we need to save flags in this struct
// because wxRegEx is not copyable
// so we can recompile the wxRegEx obj from
// pattern & flags when we need to copy it
// in wxTextValidator2::Copy()
struct wxRegexPattern
{
wxRegexPattern()
{
flags = wxRE_DEFAULT;
}
wxRegexPattern(const wxString& pattern_,
const wxString& purpose_ = wxEmptyString)
: pattern( pattern_ ), purpose( purpose_ )
{
flags = wxRE_DEFAULT;
}
long flags;
wxString pattern;
wxString purpose;
};
wxTextValidator2 ctor will look like this:
wxTextValidator2(long style = wxFILTER_NONE, wxString *val = NULL,
const wxRegexPattern& exprs = wxRegexPattern());
and add this overload:
bool HasFlag(long style) const
{ return (m_validatorStyle & style) != 0; }
finaly add this to the protected data members:
protected:
struct // anonymous
{
wxRegEx m_regex;
wxRegexPattern m_exprs;
};
I'll post the rest if you are interested...
Regards
I tweaked my wxTextValidator2::IsValid() a little bit to allow wxFILTER_SPACE to work with
wxFILTER_ALPHA, wxFILTER_ALPHANUMERIC and wxFILTER_DIGITS
As i said wxFILTER_SPACE is intended to allow spaces between words or digits in a the control