Add legacy empty-string token handling to EDA_TEXT.

This commit is contained in:
Jeff Young 2021-06-13 12:11:01 +01:00
parent 5d9c1dd75a
commit 74cefecaac
2 changed files with 21 additions and 13 deletions

View File

@ -94,13 +94,7 @@ EDA_TEXT::EDA_TEXT( const wxString& text ) :
{
int sz = Mils2iu( DEFAULT_SIZE_TEXT );
SetTextSize( wxSize( sz, sz ) );
m_shown_text_has_text_var_refs = false;
if( !text.IsEmpty() )
{
m_shown_text = UnescapeString( text );
m_shown_text_has_text_var_refs = m_shown_text.Contains( wxT( "${" ) );
}
cacheShownText();
}
@ -108,8 +102,7 @@ EDA_TEXT::EDA_TEXT( const EDA_TEXT& aText ) :
m_text( aText.m_text ),
m_e( aText.m_e )
{
m_shown_text = UnescapeString( m_text );
m_shown_text_has_text_var_refs = m_shown_text.Contains( wxT( "${" ) );
cacheShownText();
}
@ -121,8 +114,7 @@ EDA_TEXT::~EDA_TEXT()
void EDA_TEXT::SetText( const wxString& aText )
{
m_text = aText;
m_shown_text = UnescapeString( aText );
m_shown_text_has_text_var_refs = m_shown_text.Contains( wxT( "${" ) );
cacheShownText();
}
@ -178,13 +170,27 @@ int EDA_TEXT::GetEffectiveTextPenWidth( int aDefaultWidth ) const
bool EDA_TEXT::Replace( const wxFindReplaceData& aSearchData )
{
bool retval = EDA_ITEM::Replace( aSearchData, m_text );
m_shown_text = UnescapeString( m_text );
m_shown_text_has_text_var_refs = m_shown_text.Contains( wxT( "${" ) );
cacheShownText();
return retval;
}
void EDA_TEXT::cacheShownText()
{
if( m_text.IsEmpty() || m_text == wxT( "~" ) ) // ~ is legacy empty-string token
{
m_shown_text = wxEmptyString;
m_shown_text_has_text_var_refs = false;
}
else
{
m_shown_text = UnescapeString( m_text );
m_shown_text_has_text_var_refs = m_shown_text.Contains( wxT( "${" ) );
}
}
int EDA_TEXT::LenSize( const wxString& aLine, int aThickness ) const
{
basic_gal.SetFontItalic( IsItalic() );

View File

@ -374,6 +374,8 @@ public:
virtual double GetDrawRotation() const;
private:
void cacheShownText();
/**
* Print each line of this EDA_TEXT..
*