30 #include <wx/textentry.h> 31 #include <wx/numformatter.h> 41 if( aString.IsEmpty() )
46 if( sscanf( (
const char*) aString.c_str(),
"%lf%7s", &
m_base, buf ) == 0 )
59 for(
char* bufPtr = buf; *bufPtr; ++bufPtr )
60 *bufPtr = tolower( *bufPtr );
62 if( !strcmp( buf,
"meg" ) )
90 while( std::fabs(
m_base ) >= 1000.0 )
115 res *= std::pow( 10, (
int)
m_prefix );
131 wxString res = wxString::FromCDouble(
m_base );
165 else if( prefixDiff < 0 )
196 else if( prefixDiff < 0 )
236 if ( aString.Find(
',' ) >= 0 || aString.Find(
'.' ) >= 0 )
238 while( aString.EndsWith(
'0' ) )
239 aString.RemoveLast();
241 if( aString.EndsWith(
'.' ) || aString.EndsWith(
',' ) )
242 aString.RemoveLast();
249 wxTextEntry*
const text = GetTextEntry();
254 if( text->IsEmpty() )
263 wxString svalue = text->GetValue();
268 svalue.Replace(
",",
"." );
278 wxString::Format(
_(
"\"%s\" is not a valid Spice value" ), text->GetValue() ) );
283 if( svalue != text->GetValue() )
284 text->SetValue( svalue );
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
SPICE_VALUE operator-(const SPICE_VALUE &aOther) const
wxString ToSpiceString() const
Returns string value in Spice format (e.g.
bool Validate(wxWindow *aParent) override
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
This file is part of the common library.
bool m_emptyAllowed
Is it valid to get an empty value?
void Normalize()
Normalizes the value.
wxString ToString() const
Returns string value as when converting double to string (e.g.
static void stripZeros(wxString &aString)
Removes redundant zeros from the end of a string.
Helper class to handle Spice way of expressing values (e.g. 10.5 Meg)
SPICE_VALUE operator *(const SPICE_VALUE &aOther) const
SPICE_VALUE operator+(const SPICE_VALUE &aOther) const
SPICE_VALUE operator/(const SPICE_VALUE &aOther) const
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
bool m_spiceStr
Was the value defined using the Spice notation?
static LIB_PART * dummy()
Used to draw a dummy shape when a LIB_PART is not found in library.
Hold a translatable error message and may be used when throwing exceptions containing a translated er...