31 #include <wx/msgdlg.h> 40 wxTextValidator( wxFILTER_EXCLUDE_CHAR_LIST, aValue )
46 wxString excludes(
"\r\n\t" );
62 long style = GetStyle();
71 style |= wxFILTER_EMPTY;
75 SetCharExcludes( excludes );
80 wxTextValidator( aValidator )
90 if( !m_validatorWindow->IsEnabled() || !m_validatorWindow->IsShown() )
93 wxTextEntry *
const text = GetTextEntry();
98 wxString val( text->GetValue() );
101 wxString fieldCharError;
106 fieldCharError =
_(
"The reference designator cannot contain %s character(s)." );
110 fieldCharError =
_(
"The value field cannot contain %s character(s)." );
114 fieldCharError =
_(
"The footprint field cannot contain %s character(s)." );
118 fieldCharError =
_(
"The datasheet field cannot contain %s character(s)." );
122 fieldCharError =
_(
"The sheet name cannot contain %s character(s)." );
126 fieldCharError =
_(
"The sheet filename cannot contain %s character(s)." );
130 fieldCharError =
_(
"The field cannot contain %s character(s)." );
138 if( HasFlag( wxFILTER_EMPTY ) && val.empty() )
142 msg.Printf(
_(
"The name of the field cannot be empty." ) );
144 msg.Printf(
_(
"The value of the field cannot be empty." ) );
146 else if( HasFlag( wxFILTER_EXCLUDE_CHAR_LIST ) && ContainsExcludedCharacters( val ) )
148 wxArrayString whiteSpace;
154 if( val.Find(
'\r' ) != wxNOT_FOUND )
155 whiteSpace.Add(
_(
"carriage return" ) );
156 if( val.Find(
'\n' ) != wxNOT_FOUND )
157 whiteSpace.Add(
_(
"line feed" ) );
158 if( val.Find(
'\t' ) != wxNOT_FOUND )
159 whiteSpace.Add(
_(
"tab" ) );
160 if( spaceIllegal && (val.Find(
' ' ) != wxNOT_FOUND) )
161 whiteSpace.Add(
_(
"space" ) );
165 if( whiteSpace.size() == 1 )
166 badChars = whiteSpace[0];
167 else if( whiteSpace.size() == 2 )
168 badChars.Printf(
_(
"%s or %s" ), whiteSpace[0], whiteSpace[1] );
169 else if( whiteSpace.size() == 3 )
170 badChars.Printf(
_(
"%s, %s, or %s" ), whiteSpace[0], whiteSpace[1], whiteSpace[2] );
171 else if( whiteSpace.size() == 4 )
172 badChars.Printf(
_(
"%s, %s, %s, or %s" ),
173 whiteSpace[0], whiteSpace[1], whiteSpace[2], whiteSpace[3] );
175 wxCHECK_MSG(
false,
true,
"Invalid illegal character in field validator." );
177 msg.Printf( fieldCharError, badChars );
181 msg.Printf(
_(
"The reference designator cannot contain text variable references" ) );
186 m_validatorWindow->SetFocus();
188 wxMessageBox( msg,
_(
"Field Validation Error" ), wxOK | wxICON_EXCLAMATION, aParent );
202 if( ( str.Contains(
'[' ) || str.Contains(
']' ) ) &&
204 return _(
"Signal name contains '[' or ']' but is not a valid vector bus name" );
Field Reference of part, i.e. "IC21".
static bool ParseBusGroup(wxString aGroup, wxString *name, std::vector< wxString > *aMemberList)
Parses a bus group label into the name and a list of components.
wxString IsValid(const wxString &aVal) const override
Field Value of part, i.e. "3.3K".
Definitions of control validators for schematic dialogs.
SCH_FIELD_VALIDATOR(bool aIsLibEditor, int aFieldId, wxString *aValue=NULL)
static bool ParseBusVector(const wxString &aBus, wxString *aName, std::vector< wxString > *aMemberList)
Parses a bus vector (e.g.
A text control validator used for validating the text allowed in library and schematic component fiel...
wxString IsValid(const wxString &aVal) const override
virtual bool Validate(wxWindow *aParent) override
Override the default Validate() function provided by wxTextValidator to provide better error messages...
Field Name Module PCB, i.e. "16DIP300".