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-2017 KiCad Developers, see AUTHORS.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 <class_plotter.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  return rect.Intersects( GetBoundingBox() );
272 }
273 
274 
275 void LIB_TEXT::Move( const wxPoint& newPosition )
276 {
277  SetTextPos( newPosition );
278 }
279 
280 
281 void LIB_TEXT::MirrorHorizontal( const wxPoint& center )
282 {
283  int x = GetTextPos().x;
284 
285  x -= center.x;
286  x *= -1;
287  x += center.x;
288 
289  SetTextX( x );
290 }
291 
292 
293 void LIB_TEXT::MirrorVertical( const wxPoint& center )
294 {
295  int y = GetTextPos().y;
296 
297  y -= center.y;
298  y *= -1;
299  y += center.y;
300 
301  SetTextY( y );
302 }
303 
304 
305 void LIB_TEXT::Rotate( const wxPoint& center, bool aRotateCCW )
306 {
307  int rot_angle = aRotateCCW ? -900 : 900;
308 
309  wxPoint pt = GetTextPos();
310  RotatePoint( &pt, center, rot_angle );
311  SetTextPos( pt );
312 
313  SetTextAngle( GetTextAngle() != 0.0 ? 0 : 900 );
314 }
315 
316 
317 void LIB_TEXT::Plot( PLOTTER* plotter, const wxPoint& offset, bool fill,
318  const TRANSFORM& aTransform )
319 {
320  wxASSERT( plotter != NULL );
321 
322  EDA_RECT bBox = GetBoundingBox();
323  // convert coordinates from draw Y axis to libedit Y axis
324  bBox.RevertYAxis();
325  wxPoint txtpos = bBox.Centre();
326 
327  /* The text orientation may need to be flipped if the
328  * transformation matrix causes xy axes to be flipped. */
329  int t1 = ( aTransform.x1 != 0 ) ^ ( GetTextAngle() != 0 );
330  wxPoint pos = aTransform.TransformCoordinate( txtpos ) + offset;
331 
332  // Get color
333  COLOR4D color;
334 
335  if( plotter->GetColorMode() ) // Used normal color or selected color
337  else
338  color = COLOR4D::BLACK;
339 
340  plotter->Text( pos, color, GetShownText(),
343  GetPenSize(), IsItalic(), IsBold() );
344 }
345 
346 
348 {
349  int pensize = GetThickness();
350 
351  if( pensize == 0 ) // Use default values for pen size
352  {
353  if( IsBold() )
354  pensize = GetPenSizeForBold( GetTextWidth() );
355  else
356  pensize = GetDefaultLineThickness();
357  }
358 
359  // Clip pen size for small texts:
360  pensize = Clamp_Text_PenSize( pensize, GetTextSize(), IsBold() );
361  return pensize;
362 }
363 
364 
365 void LIB_TEXT::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
366  COLOR4D aColor, GR_DRAWMODE aDrawMode, void* aData,
367  const TRANSFORM& aTransform )
368 {
370 
371  if( aColor == COLOR4D::UNSPECIFIED ) // Used normal color or selected color
372  {
373  if( IsSelected() )
374  color = GetItemSelectedColor();
375  }
376  else
377  {
378  color = aColor;
379  }
380 
381  GRSetDrawMode( aDC, aDrawMode );
382 
383  /* Calculate the text orientation, according to the component
384  * orientation/mirror (needed when draw text in schematic)
385  */
386  int orient = GetTextAngle();
387 
388  if( aTransform.y1 ) // Rotate component 90 degrees.
389  {
390  if( orient == TEXT_ANGLE_HORIZ )
391  orient = TEXT_ANGLE_VERT;
392  else
393  orient = TEXT_ANGLE_HORIZ;
394  }
395 
396  /* Calculate the text justification, according to the component
397  * orientation/mirror this is a bit complicated due to cumulative
398  * calculations:
399  * - numerous cases (mirrored or not, rotation)
400  * - the DrawGraphicText function recalculate also H and H justifications
401  * according to the text orientation.
402  * - When a component is mirrored, the text is not mirrored and
403  * justifications are complicated to calculate
404  * so the more easily way is to use no justifications ( Centered text )
405  * and use GetBoundaryBox to know the text coordinate considered as centered
406  */
407  EDA_RECT bBox = GetBoundingBox();
408 
409  // convert coordinates from draw Y axis to libedit Y axis:
410  bBox.RevertYAxis();
411  wxPoint txtpos = bBox.Centre();
412 
413  // Calculate pos according to mirror/rotation.
414  txtpos = aTransform.TransformCoordinate( txtpos ) + aOffset;
415 
416  EDA_RECT* clipbox = aPanel? aPanel->GetClipBox() : NULL;
417  DrawGraphicText( clipbox, aDC, txtpos, color, GetShownText(), orient, GetTextSize(),
419  IsItalic(), IsBold() );
420 
421 
422  /* Enable this to draw the bounding box around the text field to validate
423  * the bounding box calculations.
424  */
425 #if 0
426  // bBox already uses libedit Y axis.
427  bBox = aTransform.TransformCoordinate( bBox );
428  bBox.Move( aOffset );
429  GRRect( clipbox, aDC, bBox, 0, LIGHTMAGENTA );
430 #endif
431 }
432 
433 
435 {
436  wxString msg;
437 
438  LIB_ITEM::GetMsgPanelInfo( aList );
439 
440  msg = StringFromValue( g_UserUnit, GetThickness(), true );
441 
442  aList.push_back( MSG_PANEL_ITEM( _( "Line Width" ), msg, BLUE ) );
443 }
444 
445 
447 {
448  /* Y coordinates for LIB_ITEMS are bottom to top, so we must invert the Y position when
449  * calling GetTextBox() that works using top to bottom Y axis orientation.
450  */
451  EDA_RECT rect = GetTextBox( -1, -1, true );
452  rect.RevertYAxis();
453 
454  // We are using now a bottom to top Y axis.
455  wxPoint orig = rect.GetOrigin();
456  wxPoint end = rect.GetEnd();
457 
458  RotatePoint( &orig, GetTextPos(), -GetTextAngle() );
459  RotatePoint( &end, GetTextPos(), -GetTextAngle() );
460 
461  rect.SetOrigin( orig );
462  rect.SetEnd( end );
463 
464  // We are using now a top to bottom Y axis:
465  rect.RevertYAxis();
466 
467  return rect;
468 }
469 
470 
472 {
473  if( InEditMode() )
474  {
475  m_rotate = true;
476  }
477  else
478  {
480  }
481 }
482 
483 
484 void LIB_TEXT::SetText( const wxString& aText )
485 {
486  if( aText == m_Text )
487  return;
488 
489  if( InEditMode() )
490  {
491  m_savedText = aText;
492  m_updateText = true;
493  }
494  else
495  {
496  m_Text = aText;
497  }
498 }
499 
500 
502 {
503  wxString msg;
504  msg.Printf( _( "Graphic Text %s" ), GetChars( ShortenedShownText() ) );
505  return msg;
506 }
507 
508 
510 {
511  return text_xpm;
512 }
513 
514 
515 void LIB_TEXT::BeginEdit( STATUS_FLAGS aEditMode, const wxPoint aPosition )
516 {
517  wxCHECK_RET( ( aEditMode & ( IS_NEW | IS_MOVED ) ) != 0,
518  wxT( "Invalid edit mode for LIB_TEXT object." ) );
519 
520  if( aEditMode == IS_MOVED )
521  {
523  m_initialCursorPos = aPosition;
525  }
526  else
527  {
528  SetTextPos( aPosition );
529  }
530 
531  m_Flags = aEditMode;
532 }
533 
534 
535 bool LIB_TEXT::ContinueEdit( const wxPoint aPosition )
536 {
537  wxCHECK_MSG( ( m_Flags & ( IS_NEW | IS_MOVED ) ) != 0, false,
538  wxT( "Bad call to ContinueEdit(). Text is not being edited." ) );
539 
540  return false;
541 }
542 
543 
544 void LIB_TEXT::EndEdit( const wxPoint& aPosition, bool aAbort )
545 {
546  wxCHECK_RET( ( m_Flags & ( IS_NEW | IS_MOVED ) ) != 0,
547  wxT( "Bad call to EndEdit(). Text is not being edited." ) );
548 
549  m_Flags = 0;
550  m_rotate = false;
551  m_updateText = false;
552  SetEraseLastDrawItem( false );
553 }
554 
555 
556 void LIB_TEXT::calcEdit( const wxPoint& aPosition )
557 {
558  if( m_rotate )
559  {
561  m_rotate = false;
562  }
563 
564  if( m_updateText )
565  {
566  std::swap( m_Text, m_savedText );
567  m_updateText = false;
568  }
569 
570  if( m_Flags == IS_NEW )
571  {
573  SetTextPos( aPosition );
574  }
575  else if( m_Flags == IS_MOVED )
576  {
577  Move( m_initialPos + aPosition - m_initialCursorPos );
578  }
579 }
void SetTextAngle(double aAngle)
Definition: eda_text.h:156
Definition: colors.h:57
KICAD_T Type() const
Function Type()
Definition: base_struct.h:212
#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:90
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:515
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:317
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:79
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:296
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:275
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:544
virtual COLOR4D GetDefaultColor()
bool ContinueEdit(const wxPoint aNextPoint) override
Continue an edit in progress at aPosition.
Definition: lib_text.cpp:535
void SetEffects(const EDA_TEXT &aSrc)
Function SetEffects sets the text effects from another instance.
Definition: eda_text.cpp:55
void MirrorHorizontal(const wxPoint &aCenter) override
Function MirrorHorizontal mirrors the draw object along the horizontal (X) axis about aCenter point...
Definition: lib_text.cpp:281
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:235
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:471
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:91
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:67
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:127
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:434
void GRRect(EDA_RECT *aClipBox, wxDC *aDC, int x1, int y1, int x2, int y2, COLOR4D aColor)
Definition: gr_basic.cpp:1076
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:102
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:254
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:158
EDA_RECT * GetClipBox()
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:293
wxPoint Centre() const
bool GetColorMode() const
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:347
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:556
Base plotter engine class.
Definition: class_plotter.h:97
bool Intersects(const EDA_RECT &aRect) const
Function Intersects tests for a common area between rectangles.
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:509
TRANSFORM DefaultTransform
Definition: eeschema.cpp:58
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:365
const EDA_RECT GetBoundingBox() const override
Definition: lib_text.cpp:446
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:484
STATUS_FLAGS m_Flags
Flag bits for editing and other uses.
Definition: base_struct.h:189
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:165
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:404
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:501
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:126