32 #include <type_traits> 56 #include <wx/string.h> 57 #include <wx/gdicmn.h> 60 class wxFindReplaceData;
108 m_text( aText.m_text ),
153 std::swap(
m_e, aTradingPartner.
m_e );
163 width = aDefaultWidth;
167 else if( width <= 1 )
206 tmp.Replace( wxT(
"\n" ), wxT(
" " ) );
207 tmp.Replace( wxT(
"\r" ), wxT(
" " ) );
208 tmp.Replace( wxT(
"\t" ), wxT(
" " ) );
210 if( tmp.Length() > 36 )
211 tmp = tmp.Left( 34 ) + wxT(
"..." );
226 wxArrayString strings;
230 bool hasOverBar =
false;
236 if( strings.GetCount() )
238 if( aLine >= 0 && ( aLine < (
int)strings.GetCount() ) )
239 text = strings.Item( aLine );
241 text = strings.Item( 0 );
243 linecount = strings.GetCount();
249 for(
unsigned ii = 1; ii < text.size(); ii++ )
251 if( text[ii-1] ==
'~' && text[ii] !=
'~' )
261 double penWidth( thickness );
262 int dx =
KiROUND( font.ComputeStringBoundaryLimits( text, fontSize, penWidth ).x );
267 wxSize textsize = wxSize( dx, dy );
286 double overbarPosition = font.ComputeOverbarVerticalPosition( fontSize.
y );
287 int extra_height =
KiROUND( overbarPosition - curr_height );
289 extra_height += thickness / 2;
290 textsize.y += extra_height;
291 rect.
Move( wxPoint( 0, -extra_height ) );
298 for(
unsigned ii = 1; ii < strings.GetCount(); ii++ )
300 text = strings.Item( ii );
301 dx =
KiROUND( font.ComputeStringBoundaryLimits( text, fontSize, penWidth ).x );
302 textsize.x = std::max( textsize.x, dx );
340 rect.
SetY( rect.
GetY() - ( dy / 2) );
379 wxPoint location = aPoint;
406 std::vector<wxPoint> positions;
407 wxArrayString strings;
410 positions.reserve( strings.Count() );
414 for(
unsigned ii = 0; ii < strings.Count(); ii++ )
415 printOneLineOfText( aSettings, aOffset, aColor, aFillMode, strings[ii], positions[ii] );
442 pos.y -= ( aLineCount - 1 ) * offset.y / 2;
446 pos.y -= ( aLineCount - 1 ) * offset.y;
458 for(
int ii = 0; ii < aLineCount; ii++ )
460 aPositions.push_back( pos );
467 const wxString& aText,
const wxPoint &aPos )
473 penWidth = -penWidth;
495 wxString stylemsg[4] = {
502 return stylemsg[style];
522 #ifndef GERBVIEW // Gerbview does not use EDA_TEXT::Format 526 aFormatter->
Print( aNestLevel + 1,
"(effects" );
529 aFormatter->
Print( 0,
" (font" );
531 aFormatter->
Print( 0,
" (size %s %s)",
539 aFormatter->
Print( 0,
" bold" );
542 aFormatter->
Print( 0,
" italic" );
544 aFormatter->
Print( 0,
")");
550 aFormatter->
Print( 0,
" (justify");
559 aFormatter->
Print( 0,
" mirror" );
560 aFormatter->
Print( 0,
")" );
564 aFormatter->
Print( 0,
" hide" );
566 aFormatter->
Print( 0,
")\n" );
578 std::vector<wxPoint>* cornerBuffer =
static_cast<std::vector<wxPoint>*
>( aData );
579 cornerBuffer->push_back( wxPoint( x0, y0 ) );
580 cornerBuffer->push_back( wxPoint( xf, yf ) );
586 std::vector<wxPoint> cornerBuffer;
592 bool forceBold =
true;
599 wxArrayString strings_list;
601 std::vector<wxPoint> positions;
602 positions.reserve( strings_list.Count() );
605 for(
unsigned ii = 0; ii < strings_list.Count(); ii++ )
607 wxString txt = strings_list.Item( ii );
626 std::shared_ptr<SHAPE_COMPOUND> shape = std::make_shared<SHAPE_COMPOUND>();
630 for(
unsigned jj = 0; jj < pts.size(); jj += 2 )
631 shape->AddShape(
new SHAPE_SEGMENT( pts[jj], pts[jj+1], penWidth ) );
void SetMirrored(bool isMirrored)
const STROKE_FONT & GetStrokeFont() const
EDA_TEXT(const wxString &text=wxEmptyString)
int GetInterline() const
Return the distance between two lines of text.
static PROPERTY_MANAGER & Instance()
void SwapEffects(EDA_TEXT &aTradingPartner)
Swap the text effects of the two involved instances.
void Move(const wxPoint &aMoveVector)
Move the rectangle by the aMoveVector.
#define DEFAULT_SIZE_TEXT
This is the "default-of-the-default" hardcoded text size; individual application define their own def...
EDA_TEXT_VJUSTIFY_T GetVertJustify() const
Container for all the knowledge about how graphical objects are drawn on any output surface/device.
int GetPenSizeForBold(int aTextSize)
Function GetPensizeForBold.
void CopyText(const EDA_TEXT &aSrc)
static double GetInterline(double aGlyphHeight)
Compute the distance (interline) between 2 lines of text (for multiline texts).
Implementation of conversion functions that require both schematic and board internal units.
std::vector< wxPoint > TransformToSegmentList() const
Convert the text shape to a list of segment.
void SetEffects(const EDA_TEXT &aSrc)
Set the text effects from another instance.
bool Replace(const wxFindReplaceData &aSearchData)
Helper function used in search and replace dialog.
void SetItalic(bool isItalic)
EDA_RECT GetTextBox(int aLine=-1, bool aInvertY=false) const
Useful in multiline texts to calculate the full text or a line area (for zones filling,...
void SetVisible(bool aVisible)
static void addTextSegmToBuffer(int x0, int y0, int xf, int yf, void *aData)
static ENUM_MAP< T > & Instance()
double GetTextAngle() const
bool m_shown_text_has_text_var_refs
void SetOrigin(const wxPoint &pos)
static struct EDA_TEXT_DESC _EDA_TEXT_DESC
void SetTextSize(const wxSize &aNewSize)
virtual double GetDrawRotation() const
void RotatePoint(int *pX, int *pY, double angle)
int GetTextThickness() const
VECTOR2D GetTextLineSize(const UTF8 &aText) const
Compute the X and Y size of a given text.
bool Contains(const wxPoint &aPoint) const
int GetEffectiveTextPenWidth(int aDefaultWidth=0) const
The EffectiveTextPenWidth uses the text thickness if > 1 or aDefaultWidth.
virtual void SetLineWidth(float aLineWidth)
Set the line width.
int GetTextHeight() const
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
void SetFontBold(const bool aBold)
Set bold property of current font.
wxString GetTextStyleName() const
int LenSize(const wxString &aLine, int aThickness) const
Display value expressed in distance units (mm/inch)
int Clamp_Text_PenSize(int aPenSize, int aSize, bool aBold)
Function Clamp_Text_PenSize Don't allow text to become cluttered up in its own fatness.
EDA_TEXT_HJUSTIFY_T GetHorizJustify() const
static EDA_TEXT_HJUSTIFY_T MapHorizJustify(int aHorizJustify)
virtual void SetText(const wxString &aText)
VECTOR2< double > VECTOR2D
const wxSize & GetTextSize() const
void SetVertJustify(EDA_TEXT_VJUSTIFY_T aType)
int GetPenSizeForNormal(int aTextSize)
wxString ShortenedShownText() const
Returns a shortened version (max 15 characters) of the shown text.
#define ENUM_TO_WXANY(type)
Macro to define read-only fields (no setter method available)
wxDC * GetPrintDC() const
virtual void Format(OUTPUTFORMATTER *aFormatter, int aNestLevel, int aControlBits) const
Output the object to aFormatter in s-expression form.
#define ALLOW_BOLD_THICKNESS
bool IsDefaultFormatting() const
static bool Replace(const wxFindReplaceData &aSearchData, wxString &aText)
Perform a text replace on aText using the find and replace criteria in aSearchData on items that supp...
void SetFontItalic(bool aItalic)
Set italic property of current font.
static EDA_TEXT_VJUSTIFY_T MapVertJustify(int aVertJustify)
bool IsMultilineAllowed() const
void wxStringSplit(const wxString &aText, wxArrayString &aStrings, wxChar aSplitter)
Split aString to a string list separated at aSplitter.
void GRText(wxDC *aDC, const wxPoint &aPos, COLOR4D aColor, const wxString &aText, double aOrient, const wxSize &aSize, enum EDA_TEXT_HJUSTIFY_T aH_justify, enum EDA_TEXT_VJUSTIFY_T aV_justify, int aWidth, bool aItalic, bool aBold, void(*aCallback)(int x0, int y0, int xf, int yf, void *aData), void *aCallbackData, PLOTTER *aPlotter)
Function GRText Draw a graphic text (like footprint texts)
Some functions to handle hotkeys in KiCad.
void SetTextWidth(int aWidth)
void printOneLineOfText(const RENDER_SETTINGS *aSettings, const wxPoint &aOffset, COLOR4D aColor, OUTLINE_MODE aFillMode, const wxString &aText, const wxPoint &aPos)
Print each line of this EDA_TEXT.
void Normalize()
Ensures that the height ant width are positive.
void SetSize(const wxSize &size)
void SwapText(EDA_TEXT &aTradingPartner)
void SetGlyphSize(const VECTOR2D aSize)
Set the font glyph size.
void Print(const RENDER_SETTINGS *aSettings, const wxPoint &aOffset, COLOR4D aColor, OUTLINE_MODE aDisplay_mode=FILLED)
Print this text object to the device context aDC.
void SetFontUnderlined(bool aUnderlined)
std::shared_ptr< SHAPE_COMPOUND > GetEffectiveTextShape() const
void SetHorizJustify(EDA_TEXT_HJUSTIFY_T aType)
wxString UnescapeString(const wxString &aSource)
void AddProperty(PROPERTY_BASE *aProperty)
Register a property.
Handle the component boundary box.
virtual bool TextHitTest(const wxPoint &aPoint, int aAccuracy=0) const
Test if aPoint is within the bounds of this object.
void SetTextHeight(int aHeight)
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
bool Intersects(const EDA_RECT &aRect) const
Test for a common area between rectangles.
void GetLinePositions(std::vector< wxPoint > &aPositions, int aLineCount) const
Populate aPositions with the position of each line of a multiline text, according to the vertical jus...
int GetDefaultPenWidth() const
const wxPoint & GetTextPos() const
Provide class metadata.Helper macro to map type hashes to names.
void SetTextThickness(int aWidth)
The TextThickness is that set by the user.
BASIC_GAL basic_gal(basic_displayOptions)
virtual const wxString & GetText() const
Return the string associated with the text object.
virtual wxString GetShownText(int aDepth=0) const
Return the string actually shown after processing of the base text.
std::string FormatInternalUnits(int aValue)
Function FormatInternalUnits converts aValue from internal units to a string appropriate for writing ...
EDA_RECT & Inflate(wxCoord dx, wxCoord dy)
Inflate the rectangle horizontally by dx and vertically by dy.
A color representation with 4 components: red, green, blue, alpha.