KiCad PCB EDA Suite
NETNAME_VALIDATOR Class Reference

#include <validators.h>

Inheritance diagram for NETNAME_VALIDATOR:
SCH_NETNAME_VALIDATOR

Public Member Functions

 NETNAME_VALIDATOR (wxString *aVal=nullptr)
 
 NETNAME_VALIDATOR (bool aAllowSpaces)
 
 NETNAME_VALIDATOR (const NETNAME_VALIDATOR &aValidator)
 
virtual wxObject * Clone () const override
 
virtual bool TransferToWindow () override
 
virtual bool TransferFromWindow () override
 
virtual bool Validate (wxWindow *aParent) override
 

Protected Member Functions

wxString IsValid (const wxString &aVal) const override
 

Private Attributes

bool m_allowSpaces
 

Detailed Description

Definition at line 199 of file validators.h.

Constructor & Destructor Documentation

◆ NETNAME_VALIDATOR() [1/3]

NETNAME_VALIDATOR::NETNAME_VALIDATOR ( wxString *  aVal = nullptr)

Definition at line 319 of file validators.cpp.

319 :
320 wxTextValidator(),
321 m_allowSpaces( false )
322{
323}

Referenced by Clone().

◆ NETNAME_VALIDATOR() [2/3]

NETNAME_VALIDATOR::NETNAME_VALIDATOR ( bool  aAllowSpaces)

Definition at line 333 of file validators.cpp.

333 :
334 wxTextValidator(),
335 m_allowSpaces( aAllowSpaces )
336{
337}

◆ NETNAME_VALIDATOR() [3/3]

NETNAME_VALIDATOR::NETNAME_VALIDATOR ( const NETNAME_VALIDATOR aValidator)

Definition at line 326 of file validators.cpp.

326 :
327 wxTextValidator( aValidator ),
328 m_allowSpaces( aValidator.m_allowSpaces )
329{
330}

Member Function Documentation

◆ Clone()

virtual wxObject * NETNAME_VALIDATOR::Clone ( ) const
inlineoverridevirtual

Reimplemented in SCH_NETNAME_VALIDATOR.

Definition at line 208 of file validators.h.

208{ return new NETNAME_VALIDATOR( *this ); }
NETNAME_VALIDATOR(wxString *aVal=nullptr)
Definition: validators.cpp:319

References NETNAME_VALIDATOR().

◆ IsValid()

wxString NETNAME_VALIDATOR::IsValid ( const wxString &  aVal) const
overrideprotected

Definition at line 364 of file validators.cpp.

365{
366 if( str.Contains( '\r' ) || str.Contains( '\n' ) )
367 return _( "Signal names cannot contain CR or LF characters" );
368
369 if( !m_allowSpaces && ( str.Contains( ' ' ) || str.Contains( '\t' ) ) )
370 return _( "Signal names cannot contain spaces" );
371
372 return wxString();
373}
#define _(s)

References _, and m_allowSpaces.

Referenced by SCH_NETNAME_VALIDATOR::IsValid(), and Validate().

◆ TransferFromWindow()

virtual bool NETNAME_VALIDATOR::TransferFromWindow ( )
inlineoverridevirtual

Definition at line 212 of file validators.h.

212{ return true; }

◆ TransferToWindow()

virtual bool NETNAME_VALIDATOR::TransferToWindow ( )
inlineoverridevirtual

Definition at line 210 of file validators.h.

210{ return true; }

◆ Validate()

bool NETNAME_VALIDATOR::Validate ( wxWindow *  aParent)
overridevirtual

Definition at line 340 of file validators.cpp.

341{
342 // If window is disabled, simply return
343 if ( !m_validatorWindow->IsEnabled() )
344 return true;
345
346 wxTextEntry * const text = GetTextEntry();
347
348 if ( !text )
349 return false;
350
351 const wxString& errormsg = IsValid( text->GetValue() );
352
353 if( !errormsg.empty() )
354 {
355 m_validatorWindow->SetFocus();
356 wxMessageBox( errormsg, _( "Invalid signal name" ), wxOK | wxICON_EXCLAMATION, aParent );
357 return false;
358 }
359
360 return true;
361}
wxString IsValid(const wxString &aVal) const override
Definition: validators.cpp:364

References _, IsValid(), and text.

Member Data Documentation

◆ m_allowSpaces

bool NETNAME_VALIDATOR::m_allowSpaces
private

Definition at line 221 of file validators.h.

Referenced by IsValid().


The documentation for this class was generated from the following files: