2022-01-25 22:33:37 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2022 KiCad Developers, see AUTHORS.txt for contributors.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
2022-08-27 17:23:43 +00:00
|
|
|
#include <base_units.h>
|
2022-01-25 22:33:37 +00:00
|
|
|
#include <pgm_base.h>
|
|
|
|
#include <sch_edit_frame.h>
|
|
|
|
#include <plotters/plotter.h>
|
|
|
|
#include <widgets/msgpanel.h>
|
|
|
|
#include <bitmaps.h>
|
|
|
|
#include <string_utils.h>
|
|
|
|
#include <schematic.h>
|
|
|
|
#include <settings/color_settings.h>
|
|
|
|
#include <sch_painter.h>
|
|
|
|
#include <wx/log.h>
|
|
|
|
#include <dialogs/html_message_box.h>
|
|
|
|
#include <project/project_file.h>
|
|
|
|
#include <project/net_settings.h>
|
|
|
|
#include <core/kicad_algo.h>
|
|
|
|
#include <trigo.h>
|
|
|
|
#include <sch_textbox.h>
|
2022-08-27 18:14:57 +00:00
|
|
|
#include <tools/sch_navigate_tool.h>
|
2022-01-25 22:33:37 +00:00
|
|
|
|
|
|
|
using KIGFX::SCH_RENDER_SETTINGS;
|
|
|
|
|
|
|
|
|
|
|
|
SCH_TEXTBOX::SCH_TEXTBOX( int aLineWidth, FILL_T aFillType, const wxString& text ) :
|
|
|
|
SCH_SHAPE( SHAPE_T::RECT, aLineWidth, aFillType, SCH_TEXTBOX_T ),
|
2022-08-28 13:44:31 +00:00
|
|
|
EDA_TEXT( Mils2iu( DEFAULT_SIZE_TEXT ), text )
|
2022-01-25 22:33:37 +00:00
|
|
|
{
|
|
|
|
m_layer = LAYER_NOTES;
|
|
|
|
|
|
|
|
SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
|
|
|
|
SetVertJustify( GR_TEXT_V_ALIGN_TOP );
|
|
|
|
SetMultilineAllowed( true );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
SCH_TEXTBOX::SCH_TEXTBOX( const SCH_TEXTBOX& aText ) :
|
|
|
|
SCH_SHAPE( aText ),
|
|
|
|
EDA_TEXT( aText )
|
|
|
|
{ }
|
|
|
|
|
|
|
|
|
|
|
|
int SCH_TEXTBOX::GetTextMargin() const
|
|
|
|
{
|
|
|
|
return KiROUND( GetTextSize().y * 0.8 );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void SCH_TEXTBOX::MirrorHorizontally( int aCenter )
|
|
|
|
{
|
|
|
|
// Text is NOT really mirrored; it just has its justification flipped
|
|
|
|
if( GetTextAngle() == ANGLE_HORIZONTAL )
|
|
|
|
{
|
2022-01-31 19:11:21 +00:00
|
|
|
switch( GetHorizJustify() )
|
|
|
|
{
|
|
|
|
case GR_TEXT_H_ALIGN_LEFT: SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT ); break;
|
|
|
|
case GR_TEXT_H_ALIGN_CENTER: break;
|
|
|
|
case GR_TEXT_H_ALIGN_RIGHT: SetHorizJustify( GR_TEXT_H_ALIGN_LEFT ); break;
|
|
|
|
}
|
2022-01-25 22:33:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void SCH_TEXTBOX::MirrorVertically( int aCenter )
|
|
|
|
{
|
|
|
|
// Text is NOT really mirrored; it just has its justification flipped
|
|
|
|
if( GetTextAngle() == ANGLE_VERTICAL )
|
|
|
|
{
|
2022-01-31 19:11:21 +00:00
|
|
|
switch( GetHorizJustify() )
|
|
|
|
{
|
|
|
|
case GR_TEXT_H_ALIGN_LEFT: SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT ); break;
|
|
|
|
case GR_TEXT_H_ALIGN_CENTER: break;
|
|
|
|
case GR_TEXT_H_ALIGN_RIGHT: SetHorizJustify( GR_TEXT_H_ALIGN_LEFT ); break;
|
|
|
|
}
|
2022-01-25 22:33:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void SCH_TEXTBOX::Rotate( const VECTOR2I& aCenter )
|
|
|
|
{
|
|
|
|
SCH_SHAPE::Rotate( aCenter );
|
|
|
|
SetTextAngle( GetTextAngle() == ANGLE_VERTICAL ? ANGLE_HORIZONTAL : ANGLE_VERTICAL );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void SCH_TEXTBOX::Rotate90( bool aClockwise )
|
|
|
|
{
|
|
|
|
SetTextAngle( GetTextAngle() == ANGLE_VERTICAL ? ANGLE_HORIZONTAL : ANGLE_VERTICAL );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-01-31 19:11:21 +00:00
|
|
|
VECTOR2I SCH_TEXTBOX::GetDrawPos() const
|
2022-01-25 22:33:37 +00:00
|
|
|
{
|
|
|
|
int margin = GetTextMargin();
|
|
|
|
BOX2I bbox( m_start, m_end - m_start );
|
|
|
|
|
|
|
|
bbox.Normalize();
|
|
|
|
|
2022-09-02 18:15:40 +00:00
|
|
|
VECTOR2I pos( bbox.GetLeft() + margin, bbox.GetBottom() - margin );
|
|
|
|
|
2022-01-30 10:52:52 +00:00
|
|
|
if( GetTextAngle() == ANGLE_VERTICAL )
|
2022-01-25 22:33:37 +00:00
|
|
|
{
|
2022-01-31 19:11:21 +00:00
|
|
|
switch( GetHorizJustify() )
|
|
|
|
{
|
|
|
|
case GR_TEXT_H_ALIGN_LEFT:
|
2022-09-02 18:15:40 +00:00
|
|
|
pos.y = bbox.GetBottom() - margin;
|
|
|
|
break;
|
2022-01-31 19:11:21 +00:00
|
|
|
case GR_TEXT_H_ALIGN_CENTER:
|
2022-09-02 18:15:40 +00:00
|
|
|
pos.y = ( bbox.GetTop() + bbox.GetBottom() ) / 2;
|
|
|
|
break;
|
2022-01-31 19:11:21 +00:00
|
|
|
case GR_TEXT_H_ALIGN_RIGHT:
|
2022-09-02 18:15:40 +00:00
|
|
|
pos.y = bbox.GetTop() + margin;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch( GetVertJustify() )
|
|
|
|
{
|
|
|
|
case GR_TEXT_V_ALIGN_TOP:
|
|
|
|
pos.x = bbox.GetLeft() + margin;
|
|
|
|
break;
|
|
|
|
case GR_TEXT_V_ALIGN_CENTER:
|
|
|
|
pos.x = ( bbox.GetLeft() + bbox.GetRight() ) / 2;
|
|
|
|
break;
|
|
|
|
case GR_TEXT_V_ALIGN_BOTTOM:
|
|
|
|
pos.x = bbox.GetRight() - margin;
|
|
|
|
break;
|
2022-01-31 19:11:21 +00:00
|
|
|
}
|
2022-01-25 22:33:37 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-01-31 19:11:21 +00:00
|
|
|
switch( GetHorizJustify() )
|
|
|
|
{
|
|
|
|
case GR_TEXT_H_ALIGN_LEFT:
|
2022-09-02 18:15:40 +00:00
|
|
|
pos.x = bbox.GetLeft() + margin;
|
|
|
|
break;
|
2022-01-31 19:11:21 +00:00
|
|
|
case GR_TEXT_H_ALIGN_CENTER:
|
2022-09-02 18:15:40 +00:00
|
|
|
pos.x = ( bbox.GetLeft() + bbox.GetRight() ) / 2;
|
|
|
|
break;
|
2022-01-31 19:11:21 +00:00
|
|
|
case GR_TEXT_H_ALIGN_RIGHT:
|
2022-09-02 18:15:40 +00:00
|
|
|
pos.x = bbox.GetRight() - margin;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch( GetVertJustify() )
|
|
|
|
{
|
|
|
|
case GR_TEXT_V_ALIGN_TOP:
|
|
|
|
pos.y = bbox.GetTop() + margin;
|
|
|
|
break;
|
|
|
|
case GR_TEXT_V_ALIGN_CENTER:
|
|
|
|
pos.y = ( bbox.GetTop() + bbox.GetBottom() ) / 2;
|
|
|
|
break;
|
|
|
|
case GR_TEXT_V_ALIGN_BOTTOM:
|
|
|
|
pos.y = bbox.GetBottom() - margin;
|
|
|
|
break;
|
2022-01-31 19:11:21 +00:00
|
|
|
}
|
2022-01-25 22:33:37 +00:00
|
|
|
}
|
2022-02-01 00:26:37 +00:00
|
|
|
|
2022-09-02 18:15:40 +00:00
|
|
|
return pos;
|
2022-01-25 22:33:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void SCH_TEXTBOX::SwapData( SCH_ITEM* aItem )
|
|
|
|
{
|
|
|
|
SCH_TEXTBOX* item = static_cast<SCH_TEXTBOX*>( aItem );
|
|
|
|
|
|
|
|
std::swap( m_layer, item->m_layer );
|
|
|
|
|
|
|
|
SwapText( *item );
|
|
|
|
SwapAttributes( *item );
|
|
|
|
|
|
|
|
SCH_SHAPE::SwapData( aItem );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool SCH_TEXTBOX::operator<( const SCH_ITEM& aItem ) const
|
|
|
|
{
|
|
|
|
if( Type() != aItem.Type() )
|
|
|
|
return Type() < aItem.Type();
|
|
|
|
|
|
|
|
auto other = static_cast<const SCH_TEXTBOX*>( &aItem );
|
|
|
|
|
|
|
|
if( GetLayer() != other->GetLayer() )
|
|
|
|
return GetLayer() < other->GetLayer();
|
|
|
|
|
|
|
|
if( GetPosition().x != other->GetPosition().x )
|
|
|
|
return GetPosition().x < other->GetPosition().x;
|
|
|
|
|
|
|
|
if( GetPosition().y != other->GetPosition().y )
|
|
|
|
return GetPosition().y < other->GetPosition().y;
|
|
|
|
|
|
|
|
return GetText() < other->GetText();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
KIFONT::FONT* SCH_TEXTBOX::GetDrawFont() const
|
|
|
|
{
|
|
|
|
KIFONT::FONT* font = EDA_TEXT::GetFont();
|
|
|
|
|
|
|
|
if( !font )
|
|
|
|
font = KIFONT::FONT::GetFont( GetDefaultFont(), IsBold(), IsItalic() );
|
|
|
|
|
|
|
|
return font;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void SCH_TEXTBOX::Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset )
|
|
|
|
{
|
2022-04-29 12:51:49 +00:00
|
|
|
wxDC* DC = aSettings->GetPrintDC();
|
|
|
|
int penWidth = GetPenWidth();
|
|
|
|
bool blackAndWhiteMode = GetGRForceBlackPenState();
|
|
|
|
VECTOR2I pt1 = GetStart();
|
|
|
|
VECTOR2I pt2 = GetEnd();
|
|
|
|
COLOR4D color = GetStroke().GetColor();
|
|
|
|
PLOT_DASH_TYPE lineStyle = GetStroke().GetPlotStyle();
|
2022-01-28 22:51:34 +00:00
|
|
|
|
2022-04-01 20:23:38 +00:00
|
|
|
if( GetFillMode() == FILL_T::FILLED_WITH_COLOR && !blackAndWhiteMode )
|
2022-01-28 22:51:34 +00:00
|
|
|
GRFilledRect( DC, pt1, pt2, 0, GetFillColor(), GetFillColor() );
|
|
|
|
|
2022-01-31 19:11:21 +00:00
|
|
|
if( penWidth > 0 )
|
2022-01-28 22:51:34 +00:00
|
|
|
{
|
2022-01-31 19:11:21 +00:00
|
|
|
penWidth = std::max( penWidth, aSettings->GetMinPenWidth() );
|
|
|
|
|
2022-04-29 12:51:49 +00:00
|
|
|
if( blackAndWhiteMode || color == COLOR4D::UNSPECIFIED )
|
2022-01-31 19:11:21 +00:00
|
|
|
color = aSettings->GetLayerColor( m_layer );
|
2022-01-28 22:51:34 +00:00
|
|
|
|
2022-04-29 12:51:49 +00:00
|
|
|
if( lineStyle == PLOT_DASH_TYPE::DEFAULT )
|
2022-06-28 01:12:13 +00:00
|
|
|
lineStyle = PLOT_DASH_TYPE::SOLID;
|
2022-04-29 12:51:49 +00:00
|
|
|
|
|
|
|
if( lineStyle == PLOT_DASH_TYPE::SOLID )
|
2022-01-28 22:51:34 +00:00
|
|
|
{
|
2022-01-31 19:11:21 +00:00
|
|
|
GRRect( DC, pt1, pt2, penWidth, color );
|
2022-01-28 22:51:34 +00:00
|
|
|
}
|
2022-01-31 19:11:21 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
std::vector<SHAPE*> shapes = MakeEffectiveShapes( true );
|
2022-01-28 22:51:34 +00:00
|
|
|
|
2022-01-31 19:11:21 +00:00
|
|
|
for( SHAPE* shape : shapes )
|
|
|
|
{
|
2022-04-29 12:51:49 +00:00
|
|
|
STROKE_PARAMS::Stroke( shape, lineStyle, penWidth, aSettings,
|
2022-01-31 19:11:21 +00:00
|
|
|
[&]( const VECTOR2I& a, const VECTOR2I& b )
|
|
|
|
{
|
|
|
|
GRLine( DC, a.x, a.y, b.x, b.y, penWidth, color );
|
|
|
|
} );
|
|
|
|
}
|
|
|
|
|
|
|
|
for( SHAPE* shape : shapes )
|
|
|
|
delete shape;
|
|
|
|
}
|
2022-01-28 22:51:34 +00:00
|
|
|
}
|
|
|
|
|
2022-04-29 12:51:49 +00:00
|
|
|
color = GetTextColor();
|
2022-04-27 21:45:22 +00:00
|
|
|
|
2022-04-29 12:51:49 +00:00
|
|
|
if( blackAndWhiteMode || color == COLOR4D::UNSPECIFIED )
|
|
|
|
color = aSettings->GetLayerColor( m_layer );
|
2022-04-27 21:45:22 +00:00
|
|
|
|
2022-01-25 22:33:37 +00:00
|
|
|
EDA_TEXT::Print( aSettings, aOffset, color );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
wxString SCH_TEXTBOX::GetShownText( int aDepth ) const
|
|
|
|
{
|
|
|
|
std::function<bool( wxString* )> textResolver =
|
|
|
|
[&]( wxString* token ) -> bool
|
|
|
|
{
|
|
|
|
if( token->Contains( ':' ) )
|
|
|
|
{
|
|
|
|
if( Schematic()->ResolveCrossReference( token, aDepth ) )
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SCHEMATIC* schematic = Schematic();
|
|
|
|
SCH_SHEET* sheet = schematic ? schematic->CurrentSheet().Last() : nullptr;
|
|
|
|
|
|
|
|
if( sheet && sheet->ResolveTextVar( token, aDepth + 1 ) )
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
};
|
|
|
|
|
|
|
|
std::function<bool( wxString* )> schematicTextResolver =
|
|
|
|
[&]( wxString* token ) -> bool
|
|
|
|
{
|
|
|
|
return Schematic()->ResolveTextVar( token, aDepth + 1 );
|
|
|
|
};
|
|
|
|
|
|
|
|
wxString text = EDA_TEXT::GetShownText();
|
|
|
|
|
|
|
|
if( HasTextVars() )
|
|
|
|
{
|
|
|
|
PROJECT* project = nullptr;
|
|
|
|
|
|
|
|
if( Schematic() )
|
|
|
|
project = &Schematic()->Prj();
|
|
|
|
|
|
|
|
if( aDepth < 10 )
|
|
|
|
text = ExpandTextVars( text, &textResolver, &schematicTextResolver, project );
|
|
|
|
}
|
|
|
|
|
|
|
|
KIFONT::FONT* font = GetDrawFont();
|
|
|
|
VECTOR2D size = GetEnd() - GetStart();
|
|
|
|
int colWidth = GetTextAngle() == ANGLE_HORIZONTAL ? size.x : size.y;
|
|
|
|
|
|
|
|
colWidth = abs( colWidth ) - GetTextMargin() * 2;
|
|
|
|
font->LinebreakText( text, colWidth, GetTextSize(), GetTextThickness(), IsBold(), IsItalic() );
|
|
|
|
|
|
|
|
return text;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool SCH_TEXTBOX::HitTest( const VECTOR2I& aPosition, int aAccuracy ) const
|
|
|
|
{
|
2022-08-31 12:56:58 +00:00
|
|
|
BOX2I rect = GetBoundingBox();
|
2022-01-25 22:33:37 +00:00
|
|
|
|
|
|
|
rect.Inflate( aAccuracy );
|
|
|
|
|
|
|
|
return rect.Contains( aPosition );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-08-31 09:33:46 +00:00
|
|
|
bool SCH_TEXTBOX::HitTest( const BOX2I& aRect, bool aContained, int aAccuracy ) const
|
2022-01-25 22:33:37 +00:00
|
|
|
{
|
2022-08-31 09:33:46 +00:00
|
|
|
BOX2I rect = aRect;
|
2022-01-25 22:33:37 +00:00
|
|
|
|
|
|
|
rect.Inflate( aAccuracy );
|
|
|
|
|
|
|
|
if( aContained )
|
|
|
|
return rect.Contains( GetBoundingBox() );
|
|
|
|
|
|
|
|
return rect.Intersects( GetBoundingBox() );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-08-27 18:14:57 +00:00
|
|
|
void SCH_TEXTBOX::DoHypertextAction( EDA_DRAW_FRAME* aFrame ) const
|
|
|
|
{
|
|
|
|
wxCHECK_MSG( IsHypertext(), /* void */,
|
|
|
|
"Calling a hypertext menu on a SCH_TEXTBOX with no hyperlink?" );
|
|
|
|
|
|
|
|
SCH_NAVIGATE_TOOL* navTool = aFrame->GetToolManager()->GetTool<SCH_NAVIGATE_TOOL>();
|
|
|
|
navTool->HypertextCommand( m_hyperlink );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-01-25 22:33:37 +00:00
|
|
|
wxString SCH_TEXTBOX::GetSelectMenuText( EDA_UNITS aUnits ) const
|
|
|
|
{
|
|
|
|
return wxString::Format( _( "Graphic Text Box" ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
BITMAPS SCH_TEXTBOX::GetMenuImage() const
|
|
|
|
{
|
|
|
|
return BITMAPS::add_textbox;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-02-10 19:49:25 +00:00
|
|
|
void SCH_TEXTBOX::Plot( PLOTTER* aPlotter, bool aBackground ) const
|
2022-01-25 22:33:37 +00:00
|
|
|
{
|
2022-02-10 19:49:25 +00:00
|
|
|
if( aBackground )
|
|
|
|
{
|
|
|
|
SCH_SHAPE::Plot( aPlotter, aBackground );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-01-25 22:33:37 +00:00
|
|
|
RENDER_SETTINGS* settings = aPlotter->RenderSettings();
|
|
|
|
KIFONT::FONT* font = GetDrawFont();
|
2022-01-31 19:11:21 +00:00
|
|
|
int penWidth = GetPenWidth();
|
2022-04-29 12:51:49 +00:00
|
|
|
COLOR4D color = GetStroke().GetColor();
|
|
|
|
PLOT_DASH_TYPE lineStyle = GetStroke().GetPlotStyle();
|
2022-01-25 22:33:37 +00:00
|
|
|
|
2022-01-31 19:11:21 +00:00
|
|
|
if( penWidth > 0 )
|
|
|
|
{
|
|
|
|
penWidth = std::max( penWidth, settings->GetMinPenWidth() );
|
|
|
|
|
2022-04-29 12:51:49 +00:00
|
|
|
if( !aPlotter->GetColorMode() || color == COLOR4D::UNSPECIFIED )
|
|
|
|
color = settings->GetLayerColor( m_layer );
|
2022-03-30 19:37:56 +00:00
|
|
|
|
2022-04-29 12:51:49 +00:00
|
|
|
if( lineStyle == PLOT_DASH_TYPE::DEFAULT )
|
2022-06-28 01:12:13 +00:00
|
|
|
lineStyle = PLOT_DASH_TYPE::SOLID;
|
2022-04-29 12:51:49 +00:00
|
|
|
|
|
|
|
aPlotter->SetColor( color );
|
2022-06-28 18:06:17 +00:00
|
|
|
aPlotter->SetDash( penWidth, lineStyle );
|
2022-01-31 19:11:21 +00:00
|
|
|
aPlotter->Rect( m_start, m_end, FILL_T::NO_FILL, penWidth );
|
2022-06-28 18:06:17 +00:00
|
|
|
aPlotter->SetDash( penWidth, PLOT_DASH_TYPE::SOLID );
|
2022-01-31 19:11:21 +00:00
|
|
|
}
|
2022-01-25 22:33:37 +00:00
|
|
|
|
2022-04-29 12:51:49 +00:00
|
|
|
color = GetTextColor();
|
|
|
|
|
|
|
|
if( !aPlotter->GetColorMode() || color == COLOR4D::UNSPECIFIED )
|
|
|
|
color = settings->GetLayerColor( m_layer );
|
2022-04-27 21:45:22 +00:00
|
|
|
|
2022-01-31 19:11:21 +00:00
|
|
|
penWidth = GetEffectiveTextPenWidth( settings->GetDefaultPenWidth() );
|
2022-01-25 22:33:37 +00:00
|
|
|
penWidth = std::max( penWidth, settings->GetMinPenWidth() );
|
|
|
|
aPlotter->SetCurrentLineWidth( penWidth );
|
|
|
|
|
|
|
|
std::vector<VECTOR2I> positions;
|
|
|
|
wxArrayString strings_list;
|
|
|
|
wxStringSplit( GetShownText(), strings_list, '\n' );
|
|
|
|
positions.reserve( strings_list.Count() );
|
|
|
|
|
|
|
|
GetLinePositions( positions, (int) strings_list.Count() );
|
|
|
|
|
|
|
|
for( unsigned ii = 0; ii < strings_list.Count(); ii++ )
|
|
|
|
{
|
|
|
|
aPlotter->Text( positions[ii], color, strings_list.Item( ii ), GetTextAngle(),
|
|
|
|
GetTextSize(), GetHorizJustify(), GetVertJustify(), penWidth, IsItalic(),
|
|
|
|
IsBold(), false, font );
|
|
|
|
}
|
2022-05-14 13:52:53 +00:00
|
|
|
|
|
|
|
if( HasHyperlink() )
|
2022-07-03 15:19:55 +00:00
|
|
|
aPlotter->HyperlinkBox( GetBoundingBox(), GetHyperlink() );
|
2022-01-25 22:33:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void SCH_TEXTBOX::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList )
|
|
|
|
{
|
2022-03-20 15:57:18 +00:00
|
|
|
EDA_UNITS units = aFrame->GetUserUnits();
|
|
|
|
|
2022-01-25 22:33:37 +00:00
|
|
|
// Don't use GetShownText() here; we want to show the user the variable references
|
2022-08-22 16:39:19 +00:00
|
|
|
aList.emplace_back( _( "Text Box" ), KIUI::EllipsizeStatusText( aFrame, GetText() ) );
|
2022-01-25 22:33:37 +00:00
|
|
|
|
2022-04-26 17:52:53 +00:00
|
|
|
aList.emplace_back( _( "Font" ), GetDrawFont()->GetName() );
|
|
|
|
|
2022-01-25 22:33:37 +00:00
|
|
|
wxString textStyle[] = { _( "Normal" ), _( "Italic" ), _( "Bold" ), _( "Bold Italic" ) };
|
|
|
|
int style = IsBold() && IsItalic() ? 3 : IsBold() ? 2 : IsItalic() ? 1 : 0;
|
|
|
|
aList.emplace_back( _( "Style" ), textStyle[style] );
|
|
|
|
|
2022-03-20 15:57:18 +00:00
|
|
|
aList.emplace_back( _( "Text Size" ), MessageTextFromValue( units, GetTextWidth() ) );
|
|
|
|
|
|
|
|
wxString msg = MessageTextFromValue( units, std::abs( GetEnd().x - GetStart().x ) );
|
|
|
|
aList.emplace_back( _( "Box Width" ), msg );
|
|
|
|
|
|
|
|
msg = MessageTextFromValue( units, std::abs( GetEnd().y - GetStart().y ) );
|
|
|
|
aList.emplace_back( _( "Box Height" ), msg );
|
|
|
|
|
|
|
|
m_stroke.GetMsgPanelInfo( units, aList );
|
2022-01-25 22:33:37 +00:00
|
|
|
}
|