Add font to status bar for text objects.

This commit is contained in:
Jeff Young 2022-04-26 18:52:53 +01:00
parent e6f11c5c39
commit 47e002a33d
17 changed files with 41 additions and 27 deletions

View File

@ -253,7 +253,7 @@ void DS_DATA_MODEL_IO::format( DS_DATA_ITEM_TEXT* aItem, int aNestLevel ) const
{
m_out->Print( 0, " (font" );
if( aItem->m_Font && !aItem->m_Font->Name().IsEmpty() )
if( aItem->m_Font && !aItem->m_Font->GetName().IsEmpty() )
m_out->Print( 0, " (face \"%s\")", aItem->m_Font->NameAsToken() );
if( write_thickness )

View File

@ -781,7 +781,7 @@ wxString EDA_TEXT::GetTextStyleName() const
wxString EDA_TEXT::GetFontName() const
{
if( GetFont() )
return GetFont()->Name();
return GetFont()->GetName();
else
return wxEmptyString;
}
@ -812,7 +812,7 @@ void EDA_TEXT::Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControl
aFormatter->Print( 0, " (font" );
if( GetFont() && !GetFont()->Name().IsEmpty() )
if( GetFont() && !GetFont()->GetName().IsEmpty() )
aFormatter->Print( 0, " (face \"%s\")", GetFont()->NameAsToken() );
// Text size

View File

@ -53,12 +53,6 @@ FONT::FONT()
}
const wxString& FONT::Name() const
{
return m_fontName;
}
FONT* FONT::getDefaultFont()
{
if( !s_defaultFont )

View File

@ -72,11 +72,11 @@ void FONT_CHOICE::SetFontSelection( KIFONT::FONT* aFont )
}
else
{
SetStringSelection( aFont->Name() );
SetStringSelection( aFont->GetName() );
if( GetSelection() == wxNOT_FOUND )
{
Append( aFont->Name() + m_notFound );
Append( aFont->GetName() + m_notFound );
SetSelection( GetCount() );
}
}

View File

@ -472,6 +472,8 @@ void LIB_FIELD::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_I
aList.emplace_back( _( "Visible" ), IsVisible() ? _( "Yes" ) : _( "No" ) );
aList.emplace_back( _( "Font" ), GetDrawFont()->GetName() );
aList.emplace_back( _( "Style" ), GetTextStyleName() );
aList.emplace_back( _( "Text Size" ), MessageTextFromValue( aFrame->GetUserUnits(),

View File

@ -363,6 +363,8 @@ void LIB_TEXT::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_IT
// Don't use GetShownText() here; we want to show the user the variable references
aList.emplace_back( _( "Text" ), UnescapeString( GetText() ) );
aList.emplace_back( _( "Font" ), GetDrawFont()->GetName() );
aList.emplace_back( _( "Style" ), GetTextStyleName() );
aList.emplace_back( _( "Text Size" ), MessageTextFromValue( aFrame->GetUserUnits(),

View File

@ -373,6 +373,8 @@ void LIB_TEXTBOX::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL
// Don't use GetShownText() here; we want to show the user the variable references
aList.emplace_back( _( "Text Box" ), UnescapeString( ShortenedText() ) );
aList.emplace_back( _( "Font" ), GetDrawFont()->GetName() );
wxString textStyle[] = { _( "Normal" ), _( "Italic" ), _( "Bold" ), _( "Bold Italic" ) };
int style = IsBold() && IsItalic() ? 3 : IsBold() ? 2 : IsItalic() ? 1 : 0;
aList.emplace_back( _( "Style" ), textStyle[style] );

View File

@ -691,6 +691,8 @@ void SCH_FIELD::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_I
aList.emplace_back( _( "Visible" ), IsVisible() ? _( "Yes" ) : _( "No" ) );
aList.emplace_back( _( "Font" ), GetDrawFont()->GetName() );
aList.emplace_back( _( "Style" ), GetTextStyleName() );
aList.emplace_back( _( "Text Size" ), MessageTextFromValue( aFrame->GetUserUnits(),

View File

@ -786,6 +786,8 @@ void SCH_LABEL_BASE::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PA
if( Type() == SCH_GLOBAL_LABEL_T || Type() == SCH_HIER_LABEL_T || Type() == SCH_SHEET_PIN_T )
aList.emplace_back( _( "Type" ), getElectricalTypeLabel( GetShape() ) );
aList.emplace_back( _( "Font" ), GetDrawFont()->GetName() );
wxString textStyle[] = { _( "Normal" ), _( "Italic" ), _( "Bold" ), _( "Bold Italic" ) };
int style = IsBold() && IsItalic() ? 3 : IsBold() ? 2 : IsItalic() ? 1 : 0;
aList.emplace_back( _( "Style" ), textStyle[style] );

View File

@ -472,6 +472,8 @@ void SCH_TEXT::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_IT
// Don't use GetShownText() here; we want to show the user the variable references
aList.emplace_back( _( "Graphic Text" ), UnescapeString( ShortenedText() ) );
aList.emplace_back( _( "Font" ), GetDrawFont()->GetName() );
wxString textStyle[] = { _( "Normal" ), _( "Italic" ), _( "Bold" ), _( "Bold Italic" ) };
int style = IsBold() && IsItalic() ? 3 : IsBold() ? 2 : IsItalic() ? 1 : 0;
aList.emplace_back( _( "Style" ), textStyle[style] );

View File

@ -376,6 +376,8 @@ void SCH_TEXTBOX::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL
// Don't use GetShownText() here; we want to show the user the variable references
aList.emplace_back( _( "Text Box" ), UnescapeString( ShortenedText() ) );
aList.emplace_back( _( "Font" ), GetDrawFont()->GetName() );
wxString textStyle[] = { _( "Normal" ), _( "Italic" ), _( "Bold" ), _( "Bold Italic" ) };
int style = IsBold() && IsItalic() ? 3 : IsBold() ? 2 : IsItalic() ? 1 : 0;
aList.emplace_back( _( "Style" ), textStyle[style] );

View File

@ -113,12 +113,12 @@ public:
virtual bool IsBold() const { return false; }
virtual bool IsItalic() const { return false; }
static FONT* GetFont( const wxString& aFontName = "", bool aBold = false,
static FONT* GetFont( const wxString& aFontName = wxEmptyString, bool aBold = false,
bool aItalic = false );
static bool IsStroke( const wxString& aFontName );
const wxString& Name() const;
inline const char* NameAsToken() const { return Name().utf8_str().data(); }
const wxString& GetName() const { return m_fontName; };
inline const char* NameAsToken() const { return GetName().utf8_str().data(); }
/**
* Draw a string.
@ -266,7 +266,7 @@ private:
inline std::ostream& operator<<(std::ostream& os, const KIFONT::FONT& aFont)
{
os << "[Font \"" << aFont.Name() << "\"" << ( aFont.IsStroke() ? " stroke" : "" )
os << "[Font \"" << aFont.GetName() << "\"" << ( aFont.IsStroke() ? " stroke" : "" )
<< ( aFont.IsOutline() ? " outline" : "" ) << ( aFont.IsBold() ? " bold" : "" )
<< ( aFont.IsItalic() ? " italic" : "" ) << "]";
return os;

View File

@ -259,6 +259,7 @@ EDA_ANGLE FP_TEXT::GetDrawRotation() const
void FP_TEXT::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList )
{
EDA_UNITS units = aFrame->GetUserUnits();
wxString msg;
static const wxString text_type_msg[3] =
@ -293,14 +294,10 @@ void FP_TEXT::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITE
msg.Printf( wxT( "%g" ), GetTextAngle().AsDegrees() );
aList.emplace_back( _( "Angle" ), msg );
msg = MessageTextFromValue( aFrame->GetUserUnits(), GetTextThickness() );
aList.emplace_back( _( "Thickness" ), msg );
msg = MessageTextFromValue( aFrame->GetUserUnits(), GetTextWidth() );
aList.emplace_back( _( "Width" ), msg );
msg = MessageTextFromValue( aFrame->GetUserUnits(), GetTextHeight() );
aList.emplace_back( _( "Height" ), msg );
aList.emplace_back( _( "Font" ), GetDrawFont()->GetName() );
aList.emplace_back( _( "Thickness" ), MessageTextFromValue( units, GetTextThickness() ) );
aList.emplace_back( _( "Width" ), MessageTextFromValue( units, GetTextWidth() ) );
aList.emplace_back( _( "Height" ), MessageTextFromValue(units, GetTextHeight() ) );
}

View File

@ -239,6 +239,7 @@ void FP_TEXTBOX::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_
aList.emplace_back( _( "Mirror" ), IsMirrored() ? _( "Yes" ) : _( "No" ) );
aList.emplace_back( _( "Angle" ), wxString::Format( "%g", GetTextAngle().AsDegrees() ) );
aList.emplace_back( _( "Font" ), GetDrawFont()->GetName() );
aList.emplace_back( _( "Thickness" ), MessageTextFromValue( units, GetTextThickness() ) );
aList.emplace_back( _( "Text Width" ), MessageTextFromValue( units, GetTextWidth() ) );
aList.emplace_back( _( "Text Height" ), MessageTextFromValue( units, GetTextHeight() ) );

View File

@ -335,6 +335,12 @@ void PCB_DIMENSION_BASE::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame,
GetUnits( units );
aList.emplace_back( _( "Units" ), GetAbbreviatedUnitsLabel( units ).Trim( false ) );
aList.emplace_back( _( "Font" ), m_text.GetDrawFont()->GetName() );
aList.emplace_back( _( "Text Thickness" ),
MessageTextFromValue( units, m_text.GetTextThickness() ) );
aList.emplace_back( _( "Text Width" ), MessageTextFromValue( units, m_text.GetTextWidth() ) );
aList.emplace_back( _( "Text Height" ), MessageTextFromValue( units, m_text.GetTextHeight() ) );
ORIGIN_TRANSFORMS originTransforms = aFrame->GetOriginTransforms();
units = aFrame->GetUserUnits();

View File

@ -141,6 +141,7 @@ void PCB_TEXT::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_IT
aList.emplace_back( _( "Angle" ), wxString::Format( wxT( "%g" ), GetTextAngle().AsDegrees() ) );
aList.emplace_back( _( "Font" ), GetDrawFont()->GetName() );
aList.emplace_back( _( "Thickness" ), MessageTextFromValue( units, GetTextThickness() ) );
aList.emplace_back( _( "Width" ), MessageTextFromValue( units, GetTextWidth() ) );
aList.emplace_back( _( "Height" ), MessageTextFromValue( units, GetTextHeight() ) );

View File

@ -233,6 +233,7 @@ void PCB_TEXTBOX::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL
aList.emplace_back( _( "Mirror" ), IsMirrored() ? _( "Yes" ) : _( "No" ) );
aList.emplace_back( _( "Angle" ), wxString::Format( "%g", GetTextAngle().AsDegrees() ) );
aList.emplace_back( _( "Font" ), GetDrawFont()->GetName() );
aList.emplace_back( _( "Text Thickness" ), MessageTextFromValue( units, GetTextThickness() ) );
aList.emplace_back( _( "Text Width" ), MessageTextFromValue( units, GetTextWidth() ) );
aList.emplace_back( _( "Text Height" ), MessageTextFromValue( units, GetTextHeight() ) );