KiCad PCB EDA Suite
lib_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) 2004-2012 KiCad Developers, see change_log.txt for contributors.
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, you may find one here:
18  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19  * or you may search the http://www.gnu.org website for the version 2 license,
20  * or you may write to the Free Software Foundation, Inc.,
21  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22  */
23 
28 #include <fctsys.h>
29 #include <gr_basic.h>
30 #include <macros.h>
31 #include <class_drawpanel.h>
32 #include <plot_common.h>
33 #include <drawtxt.h>
34 #include <trigo.h>
35 #include <wxstruct.h>
36 #include <richio.h>
37 #include <base_units.h>
38 #include <msgpanel.h>
39 #include <bitmaps.h>
40 
41 #include <lib_draw_item.h>
42 #include <general.h>
43 #include <transform.h>
44 #include <lib_text.h>
45 
46 
48  LIB_ITEM( LIB_TEXT_T, aParent ),
49  EDA_TEXT()
50 {
51  SetTextSize( wxSize( 50, 50 ) );
52  m_typeName = _( "Text" );
53  m_rotate = false;
54  m_updateText = false;
55 }
56 
57 
58 bool LIB_TEXT::Save( OUTPUTFORMATTER& aFormatter )
59 {
60  wxString text = m_Text;
61 
62  if( text.Contains( wxT( "~" ) ) || text.Contains( wxT( "\"" ) ) )
63  {
64  // convert double quote to similar-looking two apostrophes
65  text.Replace( wxT( "\"" ), wxT( "''" ) );
66  text = wxT( "\"" ) + text + wxT( "\"" );
67  }
68  else
69  {
70  // Spaces are not allowed in text because it is not double quoted:
71  // changed to '~'
72  text.Replace( wxT( " " ), wxT( "~" ) );
73  }
74 
75  aFormatter.Print( 0, "T %g %d %d %d %d %d %d %s", GetTextAngle(),
76  GetTextPos().x, GetTextPos().y,
77  GetTextWidth(), !IsVisible(), m_Unit, m_Convert, TO_UTF8( text ) );
78 
79  aFormatter.Print( 0, " %s %d", IsItalic() ? "Italic" : "Normal", IsBold() );
80 
81  char hjustify = 'C';
82 
84  hjustify = 'L';
86  hjustify = 'R';
87 
88  char vjustify = 'C';
89 
91  vjustify = 'B';
92  else if( GetVertJustify() == GR_TEXT_VJUSTIFY_TOP )
93  vjustify = 'T';
94 
95  aFormatter.Print( 0, " %c %c\n", hjustify, vjustify );
96 
97  return true;
98 }
99 
100 
101 bool LIB_TEXT::Load( LINE_READER& aLineReader, wxString& errorMsg )
102 {
103  int cnt, thickness = 0;
104  char hjustify = 'C', vjustify = 'C';
105  char buf[256];
106  char tmp[256];
107  char* line = (char*) aLineReader;
108  double angle;
109  int not_visible;
110  int x, y, size;
111 
112  buf[0] = 0;
113  tmp[0] = 0; // For italic option, Not in old versions
114 
115  cnt = sscanf( line + 2, "%lf %d %d %d %d %d %d \"%[^\"]\" %255s %d %c %c",
116  &angle, &x, &y, &size, &not_visible,
117  &m_Unit, &m_Convert, buf, tmp, &thickness, &hjustify,
118  &vjustify );
119 
120  SetVisible( !not_visible );
121 
122  if( cnt >= 8 ) // if quoted loading failed, load as not quoted
123  {
124  m_Text = FROM_UTF8( buf );
125 
126  // convert two apostrophes back to double quote
127  m_Text.Replace( wxT( "''" ), wxT( "\"" ) );
128  }
129  else
130  {
131  cnt = sscanf( line + 2, "%lf %d %d %d %d %d %d %255s %255s %d %c %c",
132  &angle, &x, &y, &size, &not_visible,
133  &m_Unit, &m_Convert, buf, tmp, &thickness, &hjustify,
134  &vjustify );
135 
136  if( cnt < 8 )
137  {
138  errorMsg.Printf( _( "Text only had %d parameters of the required 8" ), cnt );
139  return false;
140  }
141 
142  SetVisible( !not_visible );
143 
144  /* Convert '~' to spaces (only if text is not quoted). */
145  m_Text = FROM_UTF8( buf );
146  m_Text.Replace( wxT( "~" ), wxT( " " ) );
147  }
148 
149  SetTextAngle( angle );
150 
151  SetTextSize( wxSize( size, size ) );
152  SetTextPos( wxPoint( x, y ) );
153 
154  if( strncasecmp( tmp, "Italic", 6 ) == 0 )
155  SetItalic( true );
156 
157  if( thickness > 0 )
158  {
159  SetBold( true );
160  }
161 
162  switch( hjustify )
163  {
164  case 'L':
166  break;
167 
168  case 'C':
170  break;
171 
172  case 'R':
174  break;
175  }
176 
177  switch( vjustify )
178  {
179  case 'T':
181  break;
182 
183  case 'C':
185  break;
186 
187  case 'B':
189  break;
190  }
191 
192  return true;
193 }
194 
195 
196 bool LIB_TEXT::HitTest( const wxPoint& aPosition ) const
197 {
198  return HitTest( aPosition, 0, DefaultTransform );
199 }
200 
201 
202 bool LIB_TEXT::HitTest( const wxPoint &aPosition, int aThreshold, const TRANSFORM& aTransform ) const
203 {
204  if( aThreshold < 0 )
205  aThreshold = 0;
206 
207  EDA_TEXT tmp_text( *this );
208  tmp_text.SetTextPos( aTransform.TransformCoordinate( GetTextPos() ) );
209 
210  /* The text orientation may need to be flipped if the
211  * transformation matrix causes xy axes to be flipped.
212  * this simple algo works only for schematic matrix (rot 90 or/and mirror)
213  */
214  bool t1 = ( aTransform.x1 != 0 ) ^ ( GetTextAngle() != 0 );
215 
216  tmp_text.SetTextAngle( t1 ? TEXT_ANGLE_HORIZ : TEXT_ANGLE_VERT );
217  return tmp_text.TextHitTest( aPosition );
218 }
219 
220 
222 {
223  LIB_TEXT* newitem = new LIB_TEXT(NULL);
224 
225  newitem->m_Unit = m_Unit;
226  newitem->m_Convert = m_Convert;
227  newitem->m_Flags = m_Flags;
228  newitem->m_Text = m_Text;
229 
230  newitem->SetEffects( *this );
231 
232  return newitem;
233 }
234 
235 
236 int LIB_TEXT::compare( const LIB_ITEM& other ) const
237 {
238  wxASSERT( other.Type() == LIB_TEXT_T );
239 
240  const LIB_TEXT* tmp = ( LIB_TEXT* ) &other;
241 
242  int result = m_Text.CmpNoCase( tmp->m_Text );
243 
244  if( result != 0 )
245  return result;
246 
247  if( GetTextPos().x != tmp->GetTextPos().x )
248  return GetTextPos().x - tmp->GetTextPos().x;
249 
250  if( GetTextPos().y != tmp->GetTextPos().y )
251  return GetTextPos().y - tmp->GetTextPos().y;
252 
253  if( GetTextWidth() != tmp->GetTextWidth() )
254  return GetTextWidth() - tmp->GetTextWidth();
255 
256  if( GetTextHeight() != tmp->GetTextHeight() )
257  return GetTextHeight() - tmp->GetTextHeight();
258 
259  return 0;
260 }
261 
262 
263 void LIB_TEXT::SetOffset( const wxPoint& aOffset )
264 {
265  EDA_TEXT::Offset( aOffset );
266 }
267 
268 
269 bool LIB_TEXT::Inside( EDA_RECT& rect ) const
270 {
271  /*
272  * FIXME: This should calculate the text size and justification and
273  * use rectangle intersect.
274  */
275  return rect.Contains( GetTextPos().x, -GetTextPos().y );
276 }
277 
278 
279 void LIB_TEXT::Move( const wxPoint& newPosition )
280 {
281  SetTextPos( newPosition );
282 }
283 
284 
285 void LIB_TEXT::MirrorHorizontal( const wxPoint& center )
286 {
287  int x = GetTextPos().x;
288 
289  x -= center.x;
290  x *= -1;
291  x += center.x;
292 
293  SetTextX( x );
294 }
295 
296 
297 void LIB_TEXT::MirrorVertical( const wxPoint& center )
298 {
299  int y = GetTextPos().y;
300 
301  y -= center.y;
302  y *= -1;
303  y += center.y;
304 
305  SetTextY( y );
306 }
307 
308 
309 void LIB_TEXT::Rotate( const wxPoint& center, bool aRotateCCW )
310 {
311  int rot_angle = aRotateCCW ? -900 : 900;
312 
313  wxPoint pt = GetTextPos();
314  RotatePoint( &pt, center, rot_angle );
315  SetTextPos( pt );
316 
317  SetTextAngle( GetTextAngle() != 0.0 ? 0 : 900 );
318 }
319 
320 
321 void LIB_TEXT::Plot( PLOTTER* plotter, const wxPoint& offset, bool fill,
322  const TRANSFORM& aTransform )
323 {
324  wxASSERT( plotter != NULL );
325 
326  EDA_RECT bBox = GetBoundingBox();
327  // convert coordinates from draw Y axis to libedit Y axis
328  bBox.RevertYAxis();
329  wxPoint txtpos = bBox.Centre();
330 
331  /* The text orientation may need to be flipped if the
332  * transformation matrix causes xy axes to be flipped. */
333  int t1 = ( aTransform.x1 != 0 ) ^ ( GetTextAngle() != 0 );
334  wxPoint pos = aTransform.TransformCoordinate( txtpos ) + offset;
335 
336  // Get color
337  COLOR4D color;
338 
339  if( plotter->GetColorMode() ) // Used normal color or selected color
341  else
342  color = COLOR4D::BLACK;
343 
344  plotter->Text( pos, color, GetShownText(),
347  GetPenSize(), IsItalic(), IsBold() );
348 }
349 
350 
352 {
353  int pensize = GetThickness();
354 
355  if( pensize == 0 ) // Use default values for pen size
356  {
357  if( IsBold() )
358  pensize = GetPenSizeForBold( GetTextWidth() );
359  else
360  pensize = GetDefaultLineThickness();
361  }
362 
363  // Clip pen size for small texts:
364  pensize = Clamp_Text_PenSize( pensize, GetTextSize(), IsBold() );
365  return pensize;
366 }
367 
368 
369 void LIB_TEXT::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
370  COLOR4D aColor, GR_DRAWMODE aDrawMode, void* aData,
371  const TRANSFORM& aTransform )
372 {
374 
375  if( aColor == COLOR4D::UNSPECIFIED ) // Used normal color or selected color
376  {
377  if( IsSelected() )
378  color = GetItemSelectedColor();
379  }
380  else
381  {
382  color = aColor;
383  }
384 
385  GRSetDrawMode( aDC, aDrawMode );
386 
387  /* Calculate the text orientation, according to the component
388  * orientation/mirror (needed when draw text in schematic)
389  */
390  int orient = GetTextAngle();
391 
392  if( aTransform.y1 ) // Rotate component 90 degrees.
393  {
394  if( orient == TEXT_ANGLE_HORIZ )
395  orient = TEXT_ANGLE_VERT;
396  else
397  orient = TEXT_ANGLE_HORIZ;
398  }
399 
400  /* Calculate the text justification, according to the component
401  * orientation/mirror this is a bit complicated due to cumulative
402  * calculations:
403  * - numerous cases (mirrored or not, rotation)
404  * - the DrawGraphicText function recalculate also H and H justifications
405  * according to the text orientation.
406  * - When a component is mirrored, the text is not mirrored and
407  * justifications are complicated to calculate
408  * so the more easily way is to use no justifications ( Centered text )
409  * and use GetBoundaryBox to know the text coordinate considered as centered
410  */
411  EDA_RECT bBox = GetBoundingBox();
412 
413  // convert coordinates from draw Y axis to libedit Y axis:
414  bBox.RevertYAxis();
415  wxPoint txtpos = bBox.Centre();
416 
417  // Calculate pos according to mirror/rotation.
418  txtpos = aTransform.TransformCoordinate( txtpos ) + aOffset;
419 
420  EDA_RECT* clipbox = aPanel? aPanel->GetClipBox() : NULL;
421  DrawGraphicText( clipbox, aDC, txtpos, color, GetShownText(), orient, GetTextSize(),
423  IsItalic(), IsBold() );
424 
425 
426  /* Enable this to draw the bounding box around the text field to validate
427  * the bounding box calculations.
428  */
429 #if 0
430  // bBox already uses libedit Y axis.
431  bBox = aTransform.TransformCoordinate( bBox );
432  bBox.Move( aOffset );
433  GRRect( clipbox, aDC, bBox, 0, LIGHTMAGENTA );
434 #endif
435 }
436 
437 
439 {
440  wxString msg;
441 
442  LIB_ITEM::GetMsgPanelInfo( aList );
443 
444  msg = StringFromValue( g_UserUnit, GetThickness(), true );
445 
446  aList.push_back( MSG_PANEL_ITEM( _( "Line Width" ), msg, BLUE ) );
447 }
448 
449 
451 {
452  /* Y coordinates for LIB_ITEMS are bottom to top, so we must invert the Y position when
453  * calling GetTextBox() that works using top to bottom Y axis orientation.
454  */
455  EDA_RECT rect = GetTextBox( -1, -1, true );
456  rect.RevertYAxis();
457 
458  // We are using now a bottom to top Y axis.
459  wxPoint orig = rect.GetOrigin();
460  wxPoint end = rect.GetEnd();
461 
462  RotatePoint( &orig, GetTextPos(), -GetTextAngle() );
463  RotatePoint( &end, GetTextPos(), -GetTextAngle() );
464 
465  rect.SetOrigin( orig );
466  rect.SetEnd( end );
467 
468  // We are using now a top to bottom Y axis:
469  rect.RevertYAxis();
470 
471  return rect;
472 }
473 
474 
476 {
477  if( InEditMode() )
478  {
479  m_rotate = true;
480  }
481  else
482  {
484  }
485 }
486 
487 
488 void LIB_TEXT::SetText( const wxString& aText )
489 {
490  if( aText == m_Text )
491  return;
492 
493  if( InEditMode() )
494  {
495  m_savedText = aText;
496  m_updateText = true;
497  }
498  else
499  {
500  m_Text = aText;
501  }
502 }
503 
504 
506 {
507  wxString msg;
508  msg.Printf( _( "Graphic Text %s" ), GetChars( ShortenedShownText() ) );
509  return msg;
510 }
511 
512 
514 {
515  return text_xpm;
516 }
517 
518 
519 void LIB_TEXT::BeginEdit( STATUS_FLAGS aEditMode, const wxPoint aPosition )
520 {
521  wxCHECK_RET( ( aEditMode & ( IS_NEW | IS_MOVED ) ) != 0,
522  wxT( "Invalid edit mode for LIB_TEXT object." ) );
523 
524  if( aEditMode == IS_MOVED )
525  {
527  m_initialCursorPos = aPosition;
529  }
530  else
531  {
532  SetTextPos( aPosition );
533  }
534 
535  m_Flags = aEditMode;
536 }
537 
538 
539 bool LIB_TEXT::ContinueEdit( const wxPoint aPosition )
540 {
541  wxCHECK_MSG( ( m_Flags & ( IS_NEW | IS_MOVED ) ) != 0, false,
542  wxT( "Bad call to ContinueEdit(). Text is not being edited." ) );
543 
544  return false;
545 }
546 
547 
548 void LIB_TEXT::EndEdit( const wxPoint& aPosition, bool aAbort )
549 {
550  wxCHECK_RET( ( m_Flags & ( IS_NEW | IS_MOVED ) ) != 0,
551  wxT( "Bad call to EndEdit(). Text is not being edited." ) );
552 
553  m_Flags = 0;
554  m_rotate = false;
555  m_updateText = false;
556  SetEraseLastDrawItem( false );
557 }
558 
559 
560 void LIB_TEXT::calcEdit( const wxPoint& aPosition )
561 {
562  if( m_rotate )
563  {
565  m_rotate = false;
566  }
567 
568  if( m_updateText )
569  {
570  std::swap( m_Text, m_savedText );
571  m_updateText = false;
572  }
573 
574  if( m_Flags == IS_NEW )
575  {
577  SetTextPos( aPosition );
578  }
579  else if( m_Flags == IS_MOVED )
580  {
581  Move( m_initialPos + aPosition - m_initialCursorPos );
582  }
583 }
void SetTextAngle(double aAngle)
Definition: eda_text.h:156
Definition: colors.h:57
KICAD_T Type() const
Function Type()
Definition: base_struct.h:198
#define TEXT_ANGLE_HORIZ
Frequent text rotations, used with {Set,Get}TextAngle(), in 0.1 degrees for now, hoping to migrate to...
Definition: common.h:91
void Offset(const wxPoint &aOffset)
Definition: eda_text.h:229
void BeginEdit(STATUS_FLAGS aEditMode, const wxPoint aStartPoint=wxPoint(0, 0)) override
Begin an editing a component library draw item in aEditMode at aPosition.
Definition: lib_text.cpp:519
Class LINE_READER is an abstract class from which implementation specific LINE_READERs may be derived...
Definition: richio.h:81
void DrawGraphicText(EDA_RECT *aClipBox, 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), PLOTTER *aPlotter)
Function DrawGraphicText Draw a graphic text (like module texts)
Definition: drawtxt.cpp:122
void Plot(PLOTTER *aPlotter, const wxPoint &aOffset, bool aFill, const TRANSFORM &aTransform) override
Plot the draw item using the plot object.
Definition: lib_text.cpp:321
void Move(const wxPoint &aMoveVector)
Function Move moves the rectangle by the aMoveVector.
wxString m_Text
Definition: eda_text.h:346
wxString ShortenedShownText() const
Returns a shortened version (max 15 characters) of the shown text.
Definition: eda_text.cpp:92
PNG memory record (file in memory).
Definition: bitmap_types.h:38
static wxString FROM_UTF8(const char *cstring)
function FROM_UTF8 converts a UTF8 encoded C string to a wxString for all wxWidgets build modes...
Definition: macros.h:53
void GRSetDrawMode(wxDC *DC, GR_DRAWMODE draw_mode)
Definition: gr_basic.cpp:290
const wxPoint & GetTextPos() const
Definition: eda_text.h:224
wxString m_typeName
Name of object displayed in the message panel.
bool IsItalic() const
Definition: eda_text.h:170
void SetEraseLastDrawItem(bool aErase=true)
void Move(const wxPoint &aPosition) override
Function Move moves a draw object to aPosition.
Definition: lib_text.cpp:279
Implementation of conversion functions that require both schematic and board internal units...
Class LIB_TEXT defines a component library graphical text item.
Definition: lib_text.h:45
bool HitTest(const wxPoint &aPosition) const override
Function HitTest tests if aPosition is contained within or on the bounding area of an item...
Definition: lib_text.cpp:196
void EndEdit(const wxPoint &aPosition, bool aAbort=false) override
End an object editing action.
Definition: lib_text.cpp:548
bool Contains(const wxPoint &aPoint) const
Function Contains.
virtual COLOR4D GetDefaultColor()
bool ContinueEdit(const wxPoint aNextPoint) override
Continue an edit in progress at aPosition.
Definition: lib_text.cpp:539
void SetEffects(const EDA_TEXT &aSrc)
Function SetEffects sets the text effects from another instance.
Definition: eda_text.cpp:68
void MirrorHorizontal(const wxPoint &aCenter) override
Function MirrorHorizontal mirrors the draw object along the horizontal (X) axis about aCenter point...
Definition: lib_text.cpp:285
wxString StringFromValue(EDA_UNITS_T aUnit, int aValue, bool aAddUnitSymbol)
Function StringFromValue returns the string from aValue according to units (inch, mm ...
Definition: base_units.cpp:203
void SetItalic(bool isItalic)
Definition: eda_text.h:169
int GetTextWidth() const
Definition: eda_text.h:218
int GetDefaultLineThickness()
Default line thickness used to draw/plot items having a default thickness line value (i...
void SetTextPos(const wxPoint &aPoint)
Definition: eda_text.h:223
void SetVisible(bool aVisible)
Definition: eda_text.h:175
bool IsSelected() const
Definition: base_struct.h:221
bool InEditMode() const
Return the draw item editing mode status.
void SetOrigin(const wxPoint &pos)
int m_Unit
Unit identification for multiple parts per package.
Class OUTPUTFORMATTER is an important interface (abstract class) used to output 8 bit text in a conve...
Definition: richio.h:327
int x1
Definition: transform.h:48
void SetTextSize(const wxSize &aNewSize)
Definition: eda_text.h:214
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:317
void Rotate() override
Rotate the draw item.
Definition: lib_text.cpp:475
void RevertYAxis()
Function RevertYAxis Mirror the rectangle from the X axis (negate Y pos and size) ...
bool Inside(EDA_RECT &aRect) const override
Function Inside tests if any part of the draw object is inside rectangle bounds of aRect...
Definition: lib_text.cpp:269
EDA_TEXT_HJUSTIFY_T GetHorizJustify() const
Definition: eda_text.h:190
#define TEXT_ANGLE_VERT
Definition: common.h:92
bool IsBold() const
Definition: eda_text.h:173
double GetTextAngle() const
Definition: eda_text.h:164
Class LIB_ITEM is the base class for drawable items used by schematic library components.
Definition: lib_draw_item.h:77
int GetThickness() const
Function GetThickness returns pen width.
Definition: eda_text.h:154
This file contains miscellaneous commonly used macros and functions.
virtual void Text(const wxPoint &aPos, const 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, bool aMultilineAllowed=false, void *aData=NULL)
Draws text with the plotter.
Definition: drawtxt.cpp:229
void SetTextX(int aX)
Definition: eda_text.h:226
virtual wxString GetShownText() const
Returns the string actually shown after processing of the base text.
Definition: eda_text.h:135
#define IS_NEW
New item, just created.
Definition: base_struct.h:113
Class EDA_TEXT is a mix-in class (via multiple inheritance) that handles texts such as labels...
Definition: eda_text.h:114
wxPoint TransformCoordinate(const wxPoint &aPoint) const
Calculate a new coordinate according to the mirror/rotation transform.
Definition: transform.cpp:41
#define TO_UTF8(wxstring)
Macro TO_UTF8 converts a wxString to a UTF8 encoded C string for all wxWidgets build modes...
Definition: macros.h:47
const wxPoint & GetOrigin() const
int y1
Definition: transform.h:49
bool Load(LINE_READER &aLineReader, wxString &aErrorMsg) override
Definition: lib_text.cpp:101
void GetMsgPanelInfo(std::vector< MSG_PANEL_ITEM > &aList) override
Function GetMsgPanelInfo displays basic info (type, part and convert) about the current item in messa...
Definition: lib_text.cpp:438
void GRRect(EDA_RECT *aClipBox, wxDC *aDC, int x1, int y1, int x2, int y2, COLOR4D aColor)
Definition: gr_basic.cpp:1077
Class for tranforming drawing coordinates for a wxDC device context.
Definition: transform.h:45
EDA_RECT GetTextBox(int aLine=-1, int aThickness=-1, bool aInvertY=false) const
Function GetTextBox useful in multiline texts to calculate the full text or a line area (for zones fi...
Definition: eda_text.cpp:115
virtual bool TextHitTest(const wxPoint &aPoint, int aAccuracy=0) const
Function TextHitTest Test if aPoint is within the bounds of this object.
Definition: eda_text.cpp:267
GR_DRAWMODE
Drawmode. Compositing mode plus a flag or two.
Definition: gr_basic.h:41
Base window classes and related definitions.
void SetEnd(int x, int y)
int Clamp_Text_PenSize(int aPenSize, int aSize, bool aBold)
Function Clamp_Text_PenSize As a rule, pen width should not be >1/4em, otherwise the character will b...
Definition: drawtxt.cpp:67
void SetVertJustify(EDA_TEXT_VJUSTIFY_T aType)
Definition: eda_text.h:194
void SetOffset(const wxPoint &aOffset) override
Function Offset sets the drawing object by aOffset from the current position.
Definition: lib_text.cpp:263
bool Save(OUTPUTFORMATTER &aFormatter) override
Function Save writes draw item object to aFormatter in component library "*.lib" format.
Definition: lib_text.cpp:58
Class LIB_PART defines a library part object.
unsigned STATUS_FLAGS
Definition: base_struct.h:144
EDA_RECT * GetClipBox()
Common plot library Plot settings, and plotting engines (Postscript, Gerber, HPGL and DXF) ...
bool m_rotate
Flag to indicate a rotation occurred while editing.
Definition: lib_text.h:48
void MirrorVertical(const wxPoint &aCenter) override
Function MirrorVertical mirrors the draw object along the MirrorVertical (Y) axis about aCenter point...
Definition: lib_text.cpp:297
wxPoint Centre() const
bool GetColorMode() const
Definition: plot_common.h:121
const wxPoint GetEnd() const
EDA_UNITS_T g_UserUnit
Global variables definitions.
Definition: common.cpp:56
int GetPenSize() const override
Function GetPenSize.
Definition: lib_text.cpp:351
wxString m_savedText
Temporary storage for the string when edition.
Definition: lib_text.h:47
EDA_TEXT_VJUSTIFY_T GetVertJustify() const
Definition: eda_text.h:191
void calcEdit(const wxPoint &aPosition) override
Calculates the attributes of an item at aPosition when it is being edited.
Definition: lib_text.cpp:560
Base plotter engine class.
Definition: plot_common.h:86
int GetPenSizeForBold(int aTextSize)
Function GetPensizeForBold.
Definition: drawtxt.cpp:49
virtual void GetMsgPanelInfo(std::vector< MSG_PANEL_ITEM > &aList) override
Function GetMsgPanelInfo displays basic info (type, part and convert) about the current item in messa...
static const wxChar * GetChars(const wxString &s)
Function GetChars returns a wxChar* to the actual wxChar* data within a wxString, and is helpful for ...
Definition: macros.h:92
BITMAP_DEF GetMenuImage() const override
Function GetMenuImage returns a pointer to an image to be used in menus.
Definition: lib_text.cpp:513
TRANSFORM DefaultTransform
Definition: eeschema.cpp:57
void drawGraphic(EDA_DRAW_PANEL *aPanel, wxDC *aDC, const wxPoint &aOffset, COLOR4D aColor, GR_DRAWMODE aDrawMode, void *aData, const TRANSFORM &aTransform) override
Function drawGraphic.
Definition: lib_text.cpp:369
const EDA_RECT GetBoundingBox() const override
Definition: lib_text.cpp:450
void SetHorizJustify(EDA_TEXT_HJUSTIFY_T aType)
Definition: eda_text.h:193
bool IsVisible() const
Definition: eda_text.h:176
wxPoint m_initialPos
Temporary position when moving an existing item.
static DIRECTION_45::AngleType angle(const VECTOR2I &a, const VECTOR2I &b)
void SetText(const wxString &aText) override
Sets the text item string to aText.
Definition: lib_text.cpp:488
STATUS_FLAGS m_Flags
Flag bits for editing and other uses.
Definition: base_struct.h:175
Class EDA_RECT handles the component boundary box.
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:151
std::vector< MSG_PANEL_ITEM > MSG_PANEL_ITEMS
Definition: msgpanel.h:102
int m_Convert
Shape identification for alternate body styles.
int GetTextHeight() const
Definition: eda_text.h:221
This file is part of the common libary.
COLOR4D GetItemSelectedColor()
static const char * text_xpm[]
Definition: colors.h:45
const wxSize & GetTextSize() const
Definition: eda_text.h:215
EDA_ITEM * Clone() const override
Function Clone creates a duplicate of this item with linked list members set to NULL.
Definition: lib_text.cpp:221
Class EDA_MSG_ITEM is used EDA_MSG_PANEL as the item type for displaying messages.
Definition: msgpanel.h:53
int PRINTF_FUNC Print(int nestLevel, const char *fmt,...)
Function Print formats and writes text to the output stream.
Definition: richio.cpp:408
Message panel definition file.
void SetBold(bool aBold)
Definition: eda_text.h:172
bool m_updateText
Flag to indicate text change occurred while editing.
Definition: lib_text.h:49
LIB_TEXT(LIB_PART *aParent)
Definition: lib_text.cpp:47
int compare(const LIB_ITEM &aOther) const override
Function compare provides the draw object specific comparison called by the == and < operators...
Definition: lib_text.cpp:236
void SetTextY(int aY)
Definition: eda_text.h:227
wxPoint m_initialCursorPos
Initial cursor position at the beginning of a move.
wxString GetSelectMenuText() const override
Function GetSelectMenuText returns the text to display to be used in the selection clarification cont...
Definition: lib_text.cpp:505
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39
#define IS_MOVED
Item being moved.
Definition: base_struct.h:112