m_includeList = val.m_includeList;
m_excludeList = val.m_excludeList;
- return TRUE;
-}
-
-wxTextValidator::~wxTextValidator()
-{
+ return true;
}
static bool wxIsAlpha(const wxString& val)
for ( i = 0; i < (int)val.Length(); i++)
{
if (!wxIsalpha(val[i]))
- return FALSE;
+ return false;
}
- return TRUE;
+ return true;
}
static bool wxIsAlphaNumeric(const wxString& val)
for ( i = 0; i < (int)val.Length(); i++)
{
if (!wxIsalnum(val[i]))
- return FALSE;
+ return false;
}
- return TRUE;
+ return true;
}
// Called when the value in the window must be validated.
bool wxTextValidator::Validate(wxWindow *parent)
{
if( !CheckValidator() )
- return FALSE;
+ return false;
wxTextCtrl *control = (wxTextCtrl *) m_validatorWindow;
// If window is disabled, simply return
if ( !control->IsEnabled() )
- return TRUE;
+ return true;
wxString val(control->GetValue());
- bool ok = TRUE;
+ bool ok = true;
// NB: this format string should contian exactly one '%s'
wxString errormsg;
}
else if ( (m_validatorStyle & wxFILTER_ASCII) && !val.IsAscii() )
{
- ok = FALSE;
+ ok = false;
errormsg = _("'%s' should only contain ASCII characters.");
}
else if ( (m_validatorStyle & wxFILTER_ALPHA) && !wxIsAlpha(val) )
{
- ok = FALSE;
+ ok = false;
errormsg = _("'%s' should only contain alphabetic characters.");
}
else if ( (m_validatorStyle & wxFILTER_ALPHANUMERIC) && !wxIsAlphaNumeric(val))
{
- ok = FALSE;
+ ok = false;
errormsg = _("'%s' should only contain alphabetic or numeric characters.");
}
else if ( (m_validatorStyle & wxFILTER_NUMERIC) && !wxIsNumeric(val))
{
- ok = FALSE;
+ ok = false;
errormsg = _("'%s' should be numeric.");
}
{
//it's only ok to have the members of the list
errormsg = _("'%s' is invalid");
- ok = FALSE;
+ ok = false;
}
else if ( (m_validatorStyle & wxFILTER_EXCLUDE_CHAR_LIST) && !IsNotInCharExcludeList(val))
{
// it's only ok to have non-members of the list
errormsg = _("'%s' is invalid");
- ok = FALSE;
+ ok = false;
}
if ( !ok )
bool wxTextValidator::TransferToWindow(void)
{
if( !CheckValidator() )
- return FALSE;
+ return false;
if ( m_stringValue )
{
control->SetValue(* m_stringValue);
}
- return TRUE;
+ return true;
}
// Called to transfer data to the window
bool wxTextValidator::TransferFromWindow(void)
{
if( !CheckValidator() )
- return FALSE;
+ return false;
if ( m_stringValue )
{
*m_stringValue = control->GetValue();
}
- return TRUE;
+ return true;
}
void wxTextValidator::SetIncludeList(const wxStringList& list)
// Allow for "," (French) as well as "." -- in future we should
// use wxSystemSettings or other to do better localisation
if ((!wxIsdigit(val[i])) && (val[i] != '.') && (val[i] != ',') && (val[i] != wxT('e')) && (val[i] != wxT('E')) && (val[i] != wxT('+')) && (val[i] != wxT('-')))
- return FALSE;
+ return false;
}
- return TRUE;
+ return true;
}
bool wxTextValidator::IsInCharIncludeList(const wxString& val)
for ( i = 0; i < val.Length(); i++)
{
if (!m_includeList.Member((wxString) val[i]))
- return FALSE;
+ return false;
}
- return TRUE;
+ return true;
}
bool wxTextValidator::IsNotInCharExcludeList(const wxString& val)
for ( i = 0; i < val.Length(); i++)
{
if (m_excludeList.Member((wxString) val[i]))
- return FALSE;
+ return false;
}
- return TRUE;
+ return true;
}
#endif