KiCad PCB EDA Suite
eda_text.cpp
Go to the documentation of this file.
1 /*
2  * This program source code file is part of KiCad, a free EDA CAD application.
3  *
4  * Copyright (C) 2016 Jean-Pierre Charras, jp.charras at wanadoo.fr
5  * Copyright (C) 2004-2017 KiCad Developers, see change_log.txt for contributors.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, you may find one here:
19  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20  * or you may search the http://www.gnu.org website for the version 2 license,
21  * or you may write to the Free Software Foundation, Inc.,
22  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23  */
24 
30 #include <algorithm> // for max
31 #include <stddef.h> // for NULL
32 #include <type_traits> // for swap
33 #include <vector> // for vector
34 
35 #include <base_struct.h> // for EDA_ITEM
36 #include <base_units.h>
37 #include <basic_gal.h> // for BASIC_GAL, basic_gal
38 #include <common.h> // for wxStringSplit
39 #include <convert_to_biu.h> // for Mils2iu
40 #include <core/typeinfo.h> // for KICAD_T, SCH_LABEL_T, SCH_TEXT_T, SCH_G...
41 #include <eda_rect.h> // for EDA_RECT
42 #include <eda_text.h> // for EDA_TEXT, TEXT_EFFECTS, GR_TEXT_VJUSTIF...
43 #include <gal/color4d.h> // for COLOR4D, COLOR4D::BLACK
44 #include <gal/stroke_font.h> // for STROKE_FONT
45 #include <gr_text.h> // for GRText
46 #include <kicad_string.h> // for UnescapeString
47 #include <math/util.h> // for KiROUND
48 #include <math/vector2d.h> // for VECTOR2D
49 #include <trigo.h> // for RotatePoint
50 
51 #include <wx/debug.h> // for wxASSERT
52 #include <wx/wx.h> // for wxPoint, wxString, wxArrayString, wxSize
53 
54 class OUTPUTFORMATTER;
55 class wxFindReplaceData;
56 
57 
59 {
60  wxASSERT( aHorizJustify >= GR_TEXT_HJUSTIFY_LEFT && aHorizJustify <= GR_TEXT_HJUSTIFY_RIGHT );
61 
62  if( aHorizJustify > GR_TEXT_HJUSTIFY_RIGHT )
64 
65  if( aHorizJustify < GR_TEXT_HJUSTIFY_LEFT )
66  return GR_TEXT_HJUSTIFY_LEFT;
67 
68  return (EDA_TEXT_HJUSTIFY_T) aHorizJustify;
69 }
70 
71 
73 {
74  wxASSERT( aVertJustify >= GR_TEXT_VJUSTIFY_TOP && aVertJustify <= GR_TEXT_VJUSTIFY_BOTTOM );
75 
76  if( aVertJustify > GR_TEXT_VJUSTIFY_BOTTOM )
78 
79  if( aVertJustify < GR_TEXT_VJUSTIFY_TOP )
80  return GR_TEXT_VJUSTIFY_TOP;
81 
82  return (EDA_TEXT_VJUSTIFY_T) aVertJustify;
83 }
84 
85 
86 EDA_TEXT::EDA_TEXT( const wxString& text ) :
87  m_text( text ),
88  m_e( 1<<TE_VISIBLE )
89 {
90  int sz = Mils2iu( DEFAULT_SIZE_TEXT );
91  SetTextSize( wxSize( sz, sz ) );
92 
93  if( !text.IsEmpty() )
94  m_shown_text = UnescapeString( text );
95 }
96 
97 
98 EDA_TEXT::EDA_TEXT( const EDA_TEXT& aText ) :
99  m_text( aText.m_text ),
100  m_e( aText.m_e )
101 {
103 }
104 
105 
107 {
108 }
109 
110 
111 void EDA_TEXT::SetText( const wxString& aText )
112 {
113  m_text = aText;
114  m_shown_text = UnescapeString( aText );
115 }
116 
117 
118 void EDA_TEXT::CopyText( const EDA_TEXT& aSrc )
119 {
120  m_text = aSrc.m_text;
121  m_shown_text = aSrc.m_shown_text;
122 }
123 
124 
125 void EDA_TEXT::SetEffects( const EDA_TEXT& aSrc )
126 {
127  m_e = aSrc.m_e;
128 }
129 
130 
131 void EDA_TEXT::SwapText( EDA_TEXT& aTradingPartner )
132 {
133  std::swap( m_text, aTradingPartner.m_text );
134  std::swap( m_shown_text, aTradingPartner.m_shown_text );
135 }
136 
137 
138 void EDA_TEXT::SwapEffects( EDA_TEXT& aTradingPartner )
139 {
140  std::swap( m_e, aTradingPartner.m_e );
141 }
142 
143 
144 bool EDA_TEXT::Replace( wxFindReplaceData& aSearchData )
145 {
146  return EDA_ITEM::Replace( aSearchData, m_text );
147 }
148 
149 
150 int EDA_TEXT::LenSize( const wxString& aLine, int aThickness, int aMarkupFlags ) const
151 {
154  basic_gal.SetLineWidth( (float) aThickness );
156 
157  VECTOR2D tsize = basic_gal.GetTextLineSize( aLine, aMarkupFlags );
158 
159  return KiROUND( tsize.x );
160 }
161 
162 
164 {
165  wxString tmp = GetShownText();
166 
167  tmp.Replace( wxT( "\n" ), wxT( " " ) );
168  tmp.Replace( wxT( "\r" ), wxT( " " ) );
169  tmp.Replace( wxT( "\t" ), wxT( " " ) );
170 
171  if( tmp.Length() > 15 )
172  tmp = tmp.Left( 12 ) + wxT( "..." );
173 
174  return tmp;
175 }
176 
177 
179 {
181 }
182 
183 
184 EDA_RECT EDA_TEXT::GetTextBox( int aLine, int aThickness, bool aInvertY, int aMarkupFlags ) const
185 {
186  EDA_RECT rect;
187  wxArrayString strings;
188  wxString text = GetShownText();
189  int thickness = ( aThickness < 0 ) ? GetThickness() : aThickness;
190  int linecount = 1;
191  bool hasOverBar = false; // true if the first line of text as an overbar
192 
193  if( IsMultilineAllowed() )
194  {
195  wxStringSplit( text, strings, '\n' );
196 
197  if( strings.GetCount() ) // GetCount() == 0 for void strings
198  {
199  if( aLine >= 0 && (aLine < (int)strings.GetCount()) )
200  text = strings.Item( aLine );
201  else
202  text = strings.Item( 0 );
203 
204  linecount = strings.GetCount();
205  }
206  }
207 
208  // Search for overbar symbol. Only text is scanned,
209  // because only this line can change the bounding box
210  for( unsigned ii = 1; ii < text.size(); ii++ )
211  {
212  if( text[ii-1] == '~' && text[ii] != '~' )
213  {
214  hasOverBar = true;
215  break;
216  }
217  }
218 
219  // calculate the H and V size
220  const auto& font = basic_gal.GetStrokeFont();
221  VECTOR2D size( GetTextSize() );
222  double penWidth( thickness );
223  int dx = KiROUND( font.ComputeStringBoundaryLimits( text, size, penWidth, aMarkupFlags ).x );
224  int dy = GetInterline();
225 
226  // Creates bounding box (rectangle) for an horizontal
227  // and left and top justified text. the bounding box will be moved later
228  // according to the actual text options
229  wxSize textsize = wxSize( dx, dy );
230  wxPoint pos = GetTextPos();
231 
232  if( aInvertY )
233  pos.y = -pos.y;
234 
235  rect.SetOrigin( pos );
236 
237  // The bbox vertical size returned by GetInterline( aThickness )
238  // includes letters like j and y and ] + interval between lines.
239  // The interval below the last line is not usefull, and we can use its half value
240  // as vertical margin above the text
241  // the full interval is roughly GetTextHeight() * 0.4 - aThickness/2
242  rect.Move( wxPoint( 0, thickness/4 - KiROUND( GetTextHeight() * 0.22 ) ) );
243 
244  if( hasOverBar )
245  { // A overbar adds an extra size to the text
246  // Height from the base line text of chars like [ or {
247  double curr_height = GetTextHeight() * 1.15;
248  int extra_height = KiROUND( font.ComputeOverbarVerticalPosition( size.y, penWidth ) - curr_height );
249  extra_height += thickness / 2;
250  textsize.y += extra_height;
251  rect.Move( wxPoint( 0, -extra_height ) );
252  }
253 
254  // for multiline texts and aLine < 0, merge all rectangles
255  // ( if aLine < 0, we want the full text bounding box )
256  if( IsMultilineAllowed() && aLine < 0 )
257  {
258  for( unsigned ii = 1; ii < strings.GetCount(); ii++ )
259  {
260  text = strings.Item( ii );
261  dx = KiROUND( font.ComputeStringBoundaryLimits( text, size, penWidth, aMarkupFlags ).x );
262  textsize.x = std::max( textsize.x, dx );
263  textsize.y += dy;
264  }
265  }
266 
267  rect.SetSize( textsize );
268 
269  /* Now, calculate the rect origin, according to text justification
270  * At this point the rectangle origin is the text origin (m_Pos).
271  * This is true only for left and top text justified texts (using top to bottom Y axis
272  * orientation). and must be recalculated for others justifications
273  * also, note the V justification is relative to the first line
274  */
275  switch( GetHorizJustify() )
276  {
278  if( IsMirrored() )
279  rect.SetX( rect.GetX() - rect.GetWidth() );
280  break;
281 
283  rect.SetX( rect.GetX() - (rect.GetWidth() / 2) );
284  break;
285 
287  if( !IsMirrored() )
288  rect.SetX( rect.GetX() - rect.GetWidth() );
289  break;
290  }
291 
292  dy = GetTextHeight() + thickness;
293 
294  switch( GetVertJustify() )
295  {
297  break;
298 
300  rect.SetY( rect.GetY() - ( dy / 2) );
301  break;
302 
304  rect.SetY( rect.GetY() - dy );
305  break;
306  }
307 
308  if( linecount > 1 )
309  {
310  int yoffset;
311  linecount -= 1;
312 
313  switch( GetVertJustify() )
314  {
316  break;
317 
319  yoffset = linecount * GetInterline() / 2;
320  rect.SetY( rect.GetY() - yoffset );
321  break;
322 
324  yoffset = linecount * GetInterline();
325  rect.SetY( rect.GetY() - yoffset );
326  break;
327  }
328  }
329 
330  rect.Normalize(); // Make h and v sizes always >= 0
331 
332  return rect;
333 }
334 
335 
336 bool EDA_TEXT::TextHitTest( const wxPoint& aPoint, int aAccuracy ) const
337 {
338  EDA_RECT rect = GetTextBox( -1 ); // Get the full text area.
339  wxPoint location = aPoint;
340 
341  rect.Inflate( aAccuracy );
342  RotatePoint( &location, GetTextPos(), -GetTextAngle() );
343 
344  return rect.Contains( location );
345 }
346 
347 
348 bool EDA_TEXT::TextHitTest( const EDA_RECT& aRect, bool aContains, int aAccuracy ) const
349 {
350  EDA_RECT rect = aRect;
351 
352  rect.Inflate( aAccuracy );
353 
354  if( aContains )
355  return rect.Contains( GetTextBox( -1 ) );
356 
357  return rect.Intersects( GetTextBox( -1 ), GetTextAngle() );
358 }
359 
360 
361 void EDA_TEXT::Print( wxDC* aDC, const wxPoint& aOffset, COLOR4D aColor, EDA_DRAW_MODE_T aFillMode )
362 {
363  if( IsMultilineAllowed() )
364  {
365  std::vector<wxPoint> positions;
366  wxArrayString strings;
367  wxStringSplit( GetShownText(), strings, '\n' );
368 
369  positions.reserve( strings.Count() );
370 
371  GetPositionsOfLinesOfMultilineText( positions, strings.Count() );
372 
373  for( unsigned ii = 0; ii < strings.Count(); ii++ )
374  {
375  wxString& txt = strings.Item( ii );
376  printOneLineOfText( aDC, aOffset, aColor, aFillMode, txt, positions[ii] );
377  }
378  }
379  else
380  printOneLineOfText( aDC, aOffset, aColor, aFillMode, GetShownText(), GetTextPos() );
381 }
382 
383 
385  std::vector<wxPoint>& aPositions, int aLineCount ) const
386 {
387  wxPoint pos = GetTextPos(); // Position of first line of the
388  // multiline text according to
389  // the center of the multiline text block
390 
391  wxPoint offset; // Offset to next line.
392 
393  offset.y = GetInterline();
394 
395  if( aLineCount > 1 )
396  {
397  switch( GetVertJustify() )
398  {
400  break;
401 
403  pos.y -= ( aLineCount - 1 ) * offset.y / 2;
404  break;
405 
407  pos.y -= ( aLineCount - 1 ) * offset.y;
408  break;
409  }
410  }
411 
412  // Rotate the position of the first line
413  // around the center of the multiline text block
414  RotatePoint( &pos, GetTextPos(), GetTextAngle() );
415 
416  // Rotate the offset lines to increase happened in the right direction
417  RotatePoint( &offset, GetTextAngle() );
418 
419  for( int ii = 0; ii < aLineCount; ii++ )
420  {
421  aPositions.push_back( pos );
422  pos += offset;
423  }
424 }
425 
426 void EDA_TEXT::printOneLineOfText( wxDC* aDC, const wxPoint& aOffset, COLOR4D aColor,
427  EDA_DRAW_MODE_T aFillMode, const wxString& aText,
428  const wxPoint &aPos )
429 {
430  int width = GetThickness();
431 
432  if( aFillMode == SKETCH )
433  width = -width;
434 
435  wxSize size = GetTextSize();
436 
437  if( IsMirrored() )
438  size.x = -size.x;
439 
440  GRText( aDC, aOffset + aPos, aColor, aText, GetTextAngle(), size, GetHorizJustify(),
441  GetVertJustify(), width, IsItalic(), IsBold() );
442 }
443 
444 
446 {
447  int style = 0;
448 
449  if( IsItalic() )
450  style = 1;
451 
452  if( IsBold() )
453  style += 2;
454 
455  wxString stylemsg[4] = {
456  _("Normal"),
457  _("Italic"),
458  _("Bold"),
459  _("Bold+Italic")
460  };
461 
462  return stylemsg[style];
463 }
464 
465 
467 {
468  return ( IsVisible()
469  && !IsMirrored()
472  && GetThickness() == 0
473  && !IsItalic()
474  && !IsBold()
475  && !IsMultilineAllowed()
476  );
477 }
478 
479 
480 void EDA_TEXT::Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControlBits ) const
481 {
482 #ifndef GERBVIEW // Gerbview does not use EDA_TEXT::Format
483  // and does not define FormatInternalUnits, used here
484  // however this function should exist
485 
486  aFormatter->Print( aNestLevel + 1, "(effects" );
487 
488  // Text size
489  aFormatter->Print( 0, " (font" );
490 
491  aFormatter->Print( 0, " (size %s %s)",
492  FormatInternalUnits( GetTextHeight() ).c_str(),
493  FormatInternalUnits( GetTextWidth() ).c_str() );
494 
495  if( GetThickness() )
496  aFormatter->Print( 0, " (thickness %s)", FormatInternalUnits( GetThickness() ).c_str() );
497 
498  if( IsBold() )
499  aFormatter->Print( 0, " bold" );
500 
501  if( IsItalic() )
502  aFormatter->Print( 0, " italic" );
503 
504  aFormatter->Print( 0, ")"); // (font
505 
506  if( IsMirrored() ||
509  {
510  aFormatter->Print( 0, " (justify");
511 
513  aFormatter->Print( 0, (GetHorizJustify() == GR_TEXT_HJUSTIFY_LEFT) ? " left" : " right" );
514 
516  aFormatter->Print( 0, (GetVertJustify() == GR_TEXT_VJUSTIFY_TOP) ? " top" : " bottom" );
517 
518  if( IsMirrored() )
519  aFormatter->Print( 0, " mirror" );
520  aFormatter->Print( 0, ")" ); // (justify
521  }
522 
523  if( !(aControlBits & CTL_OMIT_HIDE) && !IsVisible() )
524  aFormatter->Print( 0, " hide" );
525 
526  aFormatter->Print( 0, ")\n" ); // (justify
527 
528 #endif
529 }
530 
531 // Convert the text shape to a list of segment
532 // each segment is stored as 2 wxPoints: its starting point and its ending point
533 // we are using GRText to create the segments and therefore a call-back function is needed
534 
535 // This is a call back function, used by GRText to put each segment in buffer
536 static void addTextSegmToBuffer( int x0, int y0, int xf, int yf, void* aData )
537 {
538  std::vector<wxPoint>* cornerBuffer = static_cast<std::vector<wxPoint>*>( aData );
539  cornerBuffer->push_back( wxPoint( x0, y0 ) );
540  cornerBuffer->push_back( wxPoint( xf, yf ) );
541 }
542 
543 
544 void EDA_TEXT::TransformTextShapeToSegmentList( std::vector<wxPoint>& aCornerBuffer ) const
545 {
546  wxSize size = GetTextSize();
547 
548  if( IsMirrored() )
549  size.x = -size.x;
550 
551  COLOR4D color = COLOR4D::BLACK; // not actually used, but needed by GRText
552 
553  if( IsMultilineAllowed() )
554  {
555  wxArrayString strings_list;
556  wxStringSplit( GetShownText(), strings_list, wxChar('\n') );
557  std::vector<wxPoint> positions;
558  positions.reserve( strings_list.Count() );
559  GetPositionsOfLinesOfMultilineText( positions,strings_list.Count() );
560 
561  for( unsigned ii = 0; ii < strings_list.Count(); ii++ )
562  {
563  wxString txt = strings_list.Item( ii );
564  GRText( NULL, positions[ii], color, txt, GetTextAngle(), size, GetHorizJustify(),
566  &aCornerBuffer );
567  }
568  }
569  else
570  {
573  &aCornerBuffer );
574  }
575 }
const STROKE_FONT & GetStrokeFont() const
EDA_TEXT(const wxString &text=wxEmptyString)
Definition: eda_text.cpp:86
void wxStringSplit(const wxString &aText, wxArrayString &aStrings, wxChar aSplitter)
Split aString to a string list separated at aSplitter.
Definition: common.cpp:186
void SetFontItalic(const bool aItalic)
Set italic property of current font.
bool IsBold() const
Definition: eda_text.h:167
int GetInterline() const
Return the distance between two lines of text.
Definition: eda_text.cpp:178
void SwapEffects(EDA_TEXT &aTradingPartner)
Swap the text effects of the two involved instances.
Definition: eda_text.cpp:138
void Move(const wxPoint &aMoveVector)
Function Move moves 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...
Definition: eda_text.h:70
EDA_TEXT_HJUSTIFY_T
Definition: eda_text.h:44
EDA_TEXT_VJUSTIFY_T GetVertJustify() const
Definition: eda_text.h:184
bool IsMirrored() const
Definition: eda_text.h:173
void CopyText(const EDA_TEXT &aSrc)
Definition: eda_text.cpp:118
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.
static bool Replace(wxFindReplaceData &aSearchData, wxString &aText)
Helper function used in search and replace dialog Function Replace performs a text replace on aText u...
int GetX() const
Definition: eda_rect.h:111
wxString m_shown_text
Definition: eda_text.h:367
bool IsVisible() const
Definition: eda_text.h:170
void SetEffects(const EDA_TEXT &aSrc)
Set the text effects from another instance.
Definition: eda_text.cpp:125
TEXT_EFFECTS m_e
Definition: eda_text.h:385
int color
Definition: DXF_plotter.cpp:61
int GetWidth() const
Definition: eda_rect.h:119
static void addTextSegmToBuffer(int x0, int y0, int xf, int yf, void *aData)
Definition: eda_text.cpp:536
double GetTextAngle() const
Definition: eda_text.h:158
void SetOrigin(const wxPoint &pos)
Definition: eda_rect.h:131
OUTPUTFORMATTER is an important interface (abstract class) used to output 8 bit text in a convenient ...
Definition: richio.h:327
int GetThickness() const
Return the pen width.
Definition: eda_text.h:148
void SetTextSize(const wxSize &aNewSize)
Definition: eda_text.h:222
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:208
bool Contains(const wxPoint &aPoint) const
Function Contains.
void printOneLineOfText(wxDC *aDC, const wxPoint &aOffset, COLOR4D aColor, EDA_DRAW_MODE_T aFillMode, const wxString &aText, const wxPoint &aPos)
Print each line of this EDA_TEXT.
Definition: eda_text.cpp:426
virtual void SetLineWidth(float aLineWidth)
Set the line width.
int GetTextHeight() const
Definition: eda_text.h:229
bool IsItalic() const
Definition: eda_text.h:164
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
Definition: eda_text.h:109
void SetFontBold(const bool aBold)
Set bold property of current font.
EDA_TEXT_HJUSTIFY_T GetHorizJustify() const
Definition: eda_text.h:183
static EDA_TEXT_HJUSTIFY_T MapHorizJustify(int aHorizJustify)
Definition: eda_text.cpp:58
virtual void SetText(const wxString &aText)
Definition: eda_text.cpp:111
#define NULL
VECTOR2< double > VECTOR2D
Definition: vector2d.h:593
EDA_DRAW_MODE_T
Definition: eda_text.h:59
EDA_RECT GetTextBox(int aLine=-1, int aThickness=-1, bool aInvertY=false, int aMarkupFlags=0) const
Useful in multiline texts to calculate the full text or a line area (for zones filling,...
Definition: eda_text.cpp:184
const wxSize & GetTextSize() const
Definition: eda_text.h:223
void TransformTextShapeToSegmentList(std::vector< wxPoint > &aCornerBuffer) const
Convert the text shape to a list of segment.
Definition: eda_text.cpp:544
wxString ShortenedShownText() const
Returns a shortened version (max 15 characters) of the shown text.
Definition: eda_text.cpp:163
void SetX(int val)
Definition: eda_rect.h:168
virtual ~EDA_TEXT()
Definition: eda_text.cpp:106
virtual void Format(OUTPUTFORMATTER *aFormatter, int aNestLevel, int aControlBits) const
Output the object to aFormatter in s-expression form.
Definition: eda_text.cpp:480
bool IsDefaultFormatting() const
Definition: eda_text.cpp:466
wxString m_text
Definition: eda_text.h:366
static EDA_TEXT_VJUSTIFY_T MapVertJustify(int aVertJustify)
Definition: eda_text.cpp:72
bool IsMultilineAllowed() const
Definition: eda_text.h:181
void SetY(int val)
Definition: eda_rect.h:174
void Print(wxDC *aDC, const wxPoint &aOffset, COLOR4D aColor, EDA_DRAW_MODE_T aDisplay_mode=FILLED)
Print this text object to the device context aDC.
Definition: eda_text.cpp:361
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 module texts)
Definition: gr_text.cpp:143
EDA_TEXT_VJUSTIFY_T
Definition: eda_text.h:51
void Normalize()
Function Normalize ensures that the height ant width are positive.
void SetSize(const wxSize &size)
Definition: eda_rect.h:144
void SwapText(EDA_TEXT &aTradingPartner)
Definition: eda_text.cpp:131
int GetTextWidth() const
Definition: eda_text.h:226
wxString GetTextStyleName()
Definition: eda_text.cpp:445
bool Replace(wxFindReplaceData &aSearchData)
Helper function used in search and replace dialog.
Definition: eda_text.cpp:144
#define _(s)
Definition: 3d_actions.cpp:31
int LenSize(const wxString &aLine, int aThickness, int aMarkupFlags) const
Definition: eda_text.cpp:150
wxString UnescapeString(const wxString &aSource)
Definition: string.cpp:131
EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
virtual bool TextHitTest(const wxPoint &aPoint, int aAccuracy=0) const
Test if aPoint is within the bounds of this object.
Definition: eda_text.cpp:336
int GetY() const
Definition: eda_rect.h:112
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: util.h:61
The common library.
bool Intersects(const EDA_RECT &aRect) const
Function Intersects tests for a common area between rectangles.
const wxPoint & GetTextPos() const
Definition: eda_text.h:232
void GetPositionsOfLinesOfMultilineText(std::vector< wxPoint > &aPositions, int aLineCount) const
Populate aPositions with the position of each line of a multiline text, according to the vertical jus...
Definition: eda_text.cpp:384
void SetGlyphSize(const VECTOR2D aGlyphSize)
Set the font glyph size.
virtual wxString GetShownText() const
Return the string actually shown after processing of the base text.
Definition: eda_text.h:129
BASIC_GAL basic_gal(basic_displayOptions)
Definition: colors.h:45
int PRINTF_FUNC Print(int nestLevel, const char *fmt,...)
Function Print formats and writes text to the output stream.
Definition: richio.cpp:404
#define CTL_OMIT_HIDE
Definition: eda_text.h:39
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:123
std::string FormatInternalUnits(int aValue)
Function FormatInternalUnits converts aValue from internal units to a string appropriate for writing ...
Definition: base_units.cpp:480
EDA_RECT & Inflate(wxCoord dx, wxCoord dy)
Function Inflate inflates the rectangle horizontally by dx and vertically by dy.
VECTOR2D GetTextLineSize(const UTF8 &aText, int aMarkupFlags=0) const
Compute the X and Y size of a given text.
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39