Custom validator that verifies that a string defines a valid LIB_ID.
More...
#include <validators.h>
Custom validator that verifies that a string defines a valid LIB_ID.
The default validation allows empty LIB_ID strings to allow the LIB_ID to be cleared. Use SetStyle( wxFILTER_EMPTY ) to force a valid LIB_ID string.
Definition at line 177 of file validators.h.
◆ LIB_ID_VALIDATOR()
LIB_ID_VALIDATOR::LIB_ID_VALIDATOR |
( |
wxString * |
aValue = nullptr | ) |
|
|
inline |
- Parameters
-
aLibIdType | is the type of LIB_ID object to validate. |
aValue | is a pointer to a wxString containing the value to validate. |
Definition at line 184 of file validators.h.
184 :
185 wxTextValidator( wxFILTER_EXCLUDE_CHAR_LIST, aValue )
186 {
187 SetCharExcludes( wxT( "\r\n\t" ) );
188 }
Referenced by Clone().
◆ Clone()
virtual wxObject * LIB_ID_VALIDATOR::Clone |
( |
| ) |
const |
|
inlineoverridevirtual |
◆ Validate()
bool LIB_ID_VALIDATOR::Validate |
( |
wxWindow * |
aParent | ) |
|
|
override |
Definition at line 271 of file validators.cpp.
272{
274
275
276 if( !m_validatorWindow->IsEnabled() )
277 return true;
278
279 wxTextEntry*
const text = GetTextEntry();
280
282 return false;
283
284 wxString msg;
285 wxString val(
text->GetValue() );
286 wxString tmp = val.Clone();
287
288
289 if( !(GetStyle() & wxFILTER_EMPTY) && val.IsEmpty() )
290 return true;
291
292 if( tmp.Trim() != val )
293 {
294 msg =
_(
"Entry contains trailing white space." );
295 }
296 else if( tmp.Trim( false ) != val )
297 {
298 msg =
_(
"Entry contains leading white space." );
299 }
300 else if(
dummy.Parse( val ) != -1 || !
dummy.IsValid() )
301 {
302 msg.Printf(
_(
"'%s' is not a valid library identifier format." ), val );
303 }
304
305 if( !msg.empty() )
306 {
307 m_validatorWindow->SetFocus();
308
309 wxMessageBox( msg,
_(
"Library Identifier Validation Error" ),
310 wxOK | wxICON_EXCLAMATION, aParent );
311
312 return false;
313 }
314
315 return true;
316}
A logical library item identifier and consists of various portions much like a URI.
std::vector< FAB_LAYER_COLOR > dummy
References _, dummy, and text.
The documentation for this class was generated from the following files: