You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

682 lines
21 KiB

  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. /**
  25. * @file eda_text.cpp
  26. * @brief Implementation of base KiCad text object.
  27. */
  28. #include <algorithm> // for max
  29. #include <stddef.h> // for NULL
  30. #include <type_traits> // for swap
  31. #include <vector> // for vector
  32. #include <eda_item.h> // for EDA_ITEM
  33. #include <base_units.h>
  34. #include <basic_gal.h> // for BASIC_GAL, basic_gal
  35. #include <convert_to_biu.h> // for Mils2iu
  36. #include <eda_rect.h> // for EDA_RECT
  37. #include <eda_text.h> // for EDA_TEXT, TEXT_EFFECTS, GR_TEXT_VJUSTIF...
  38. #include <gal/color4d.h> // for COLOR4D, COLOR4D::BLACK
  39. #include <gal/stroke_font.h> // for STROKE_FONT
  40. #include <gr_text.h> // for GRText
  41. #include <kicad_string.h> // for UnescapeString
  42. #include <math/util.h> // for KiROUND
  43. #include <math/vector2d.h> // for VECTOR2D
  44. #include <richio.h>
  45. #include <render_settings.h>
  46. #include <trigo.h> // for RotatePoint
  47. #include <i18n_utility.h>
  48. #include <geometry/shape_segment.h>
  49. #include <geometry/shape_compound.h>
  50. #include <geometry/shape_poly_set.h>
  51. #include <wx/debug.h> // for wxASSERT
  52. #include <wx/wx.h> // for wxPoint, wxString, wxArrayString, wxSize
  53. class OUTPUTFORMATTER;
  54. class wxFindReplaceData;
  55. EDA_TEXT_HJUSTIFY_T EDA_TEXT::MapHorizJustify( int aHorizJustify )
  56. {
  57. wxASSERT( aHorizJustify >= GR_TEXT_HJUSTIFY_LEFT && aHorizJustify <= GR_TEXT_HJUSTIFY_RIGHT );
  58. if( aHorizJustify > GR_TEXT_HJUSTIFY_RIGHT )
  59. return GR_TEXT_HJUSTIFY_RIGHT;
  60. if( aHorizJustify < GR_TEXT_HJUSTIFY_LEFT )
  61. return GR_TEXT_HJUSTIFY_LEFT;
  62. return (EDA_TEXT_HJUSTIFY_T) aHorizJustify;
  63. }
  64. EDA_TEXT_VJUSTIFY_T EDA_TEXT::MapVertJustify( int aVertJustify )
  65. {
  66. wxASSERT( aVertJustify >= GR_TEXT_VJUSTIFY_TOP && aVertJustify <= GR_TEXT_VJUSTIFY_BOTTOM );
  67. if( aVertJustify > GR_TEXT_VJUSTIFY_BOTTOM )
  68. return GR_TEXT_VJUSTIFY_BOTTOM;
  69. if( aVertJustify < GR_TEXT_VJUSTIFY_TOP )
  70. return GR_TEXT_VJUSTIFY_TOP;
  71. return (EDA_TEXT_VJUSTIFY_T) aVertJustify;
  72. }
  73. EDA_TEXT::EDA_TEXT( const wxString& text ) :
  74. m_text( text ),
  75. m_e( 1<<TE_VISIBLE )
  76. {
  77. int sz = Mils2iu( DEFAULT_SIZE_TEXT );
  78. SetTextSize( wxSize( sz, sz ) );
  79. m_shown_text_has_text_var_refs = false;
  80. if( !text.IsEmpty() )
  81. {
  82. m_shown_text = UnescapeString( text );
  83. m_shown_text_has_text_var_refs = m_shown_text.Contains( wxT( "${" ) );
  84. }
  85. }
  86. EDA_TEXT::EDA_TEXT( const EDA_TEXT& aText ) :
  87. m_text( aText.m_text ),
  88. m_e( aText.m_e )
  89. {
  90. m_shown_text = UnescapeString( m_text );
  91. m_shown_text_has_text_var_refs = m_shown_text.Contains( wxT( "${" ) );
  92. }
  93. EDA_TEXT::~EDA_TEXT()
  94. {
  95. }
  96. void EDA_TEXT::SetText( const wxString& aText )
  97. {
  98. m_text = aText;
  99. m_shown_text = UnescapeString( aText );
  100. m_shown_text_has_text_var_refs = m_shown_text.Contains( wxT( "${" ) );
  101. }
  102. void EDA_TEXT::CopyText( const EDA_TEXT& aSrc )
  103. {
  104. m_text = aSrc.m_text;
  105. m_shown_text = aSrc.m_shown_text;
  106. m_shown_text_has_text_var_refs = aSrc.m_shown_text_has_text_var_refs;
  107. }
  108. void EDA_TEXT::SetEffects( const EDA_TEXT& aSrc )
  109. {
  110. m_e = aSrc.m_e;
  111. }
  112. void EDA_TEXT::SwapText( EDA_TEXT& aTradingPartner )
  113. {
  114. std::swap( m_text, aTradingPartner.m_text );
  115. std::swap( m_shown_text, aTradingPartner.m_shown_text );
  116. std::swap( m_shown_text_has_text_var_refs, aTradingPartner.m_shown_text_has_text_var_refs );
  117. }
  118. void EDA_TEXT::SwapEffects( EDA_TEXT& aTradingPartner )
  119. {
  120. std::swap( m_e, aTradingPartner.m_e );
  121. }
  122. int EDA_TEXT::GetEffectiveTextPenWidth( int aDefaultWidth ) const
  123. {
  124. int width = GetTextThickness();
  125. if( width <= 1 )
  126. {
  127. width = aDefaultWidth;
  128. if( IsBold() )
  129. width = GetPenSizeForBold( GetTextWidth() );
  130. else if( width <= 1 )
  131. width = GetPenSizeForNormal( GetTextWidth() );
  132. }
  133. // Clip pen size for small texts:
  134. width = Clamp_Text_PenSize( width, GetTextSize(), ALLOW_BOLD_THICKNESS );
  135. return width;
  136. }
  137. bool EDA_TEXT::Replace( wxFindReplaceData& aSearchData )
  138. {
  139. bool retval = EDA_ITEM::Replace( aSearchData, m_text );
  140. m_shown_text = UnescapeString( m_text );
  141. m_shown_text_has_text_var_refs = m_shown_text.Contains( wxT( "${" ) );
  142. return retval;
  143. }
  144. int EDA_TEXT::LenSize( const wxString& aLine, int aThickness ) const
  145. {
  146. basic_gal.SetFontItalic( IsItalic() );
  147. basic_gal.SetFontBold( IsBold() );
  148. basic_gal.SetFontUnderlined( false );
  149. basic_gal.SetLineWidth( (float) aThickness );
  150. basic_gal.SetGlyphSize( VECTOR2D( GetTextSize() ) );
  151. VECTOR2D tsize = basic_gal.GetTextLineSize( aLine );
  152. return KiROUND( tsize.x );
  153. }
  154. wxString EDA_TEXT::ShortenedShownText() const
  155. {
  156. wxString tmp = GetShownText();
  157. tmp.Replace( wxT( "\n" ), wxT( " " ) );
  158. tmp.Replace( wxT( "\r" ), wxT( " " ) );
  159. tmp.Replace( wxT( "\t" ), wxT( " " ) );
  160. if( tmp.Length() > 36 )
  161. tmp = tmp.Left( 34 ) + wxT( "..." );
  162. return tmp;
  163. }
  164. int EDA_TEXT::GetInterline() const
  165. {
  166. return KiROUND( KIGFX::STROKE_FONT::GetInterline( GetTextHeight() ) );
  167. }
  168. EDA_RECT EDA_TEXT::GetTextBox( int aLine, bool aInvertY ) const
  169. {
  170. EDA_RECT rect;
  171. wxArrayString strings;
  172. wxString text = GetShownText();
  173. int thickness = GetEffectiveTextPenWidth();
  174. int linecount = 1;
  175. bool hasOverBar = false; // true if the first line of text as an overbar
  176. if( IsMultilineAllowed() )
  177. {
  178. wxStringSplit( text, strings, '\n' );
  179. if( strings.GetCount() ) // GetCount() == 0 for void strings
  180. {
  181. if( aLine >= 0 && ( aLine < (int)strings.GetCount() ) )
  182. text = strings.Item( aLine );
  183. else
  184. text = strings.Item( 0 );
  185. linecount = strings.GetCount();
  186. }
  187. }
  188. // Search for overbar symbol. Only text is scanned,
  189. // because only this line can change the bounding box
  190. for( unsigned ii = 1; ii < text.size(); ii++ )
  191. {
  192. if( text[ii-1] == '~' && text[ii] != '~' )
  193. {
  194. hasOverBar = true;
  195. break;
  196. }
  197. }
  198. // calculate the H and V size
  199. const auto& font = basic_gal.GetStrokeFont();
  200. VECTOR2D fontSize( GetTextSize() );
  201. double penWidth( thickness );
  202. int dx = KiROUND( font.ComputeStringBoundaryLimits( text, fontSize, penWidth ).x );
  203. int dy = GetInterline();
  204. // Creates bounding box (rectangle) for horizontal, left and top justified text. The
  205. // bounding box will be moved later according to the actual text options
  206. wxSize textsize = wxSize( dx, dy );
  207. wxPoint pos = GetTextPos();
  208. if( aInvertY )
  209. pos.y = -pos.y;
  210. rect.SetOrigin( pos );
  211. // The bbox vertical size returned by GetInterline( aThickness )
  212. // includes letters like j and y and ] + interval between lines.
  213. // The interval below the last line is not usefull, and we can use its half value
  214. // as vertical margin above the text
  215. // the full interval is roughly GetTextHeight() * 0.4 - aThickness/2
  216. rect.Move( wxPoint( 0, thickness/4 - KiROUND( GetTextHeight() * 0.22 ) ) );
  217. if( hasOverBar )
  218. { // A overbar adds an extra size to the text
  219. // Height from the base line text of chars like [ or {
  220. double curr_height = GetTextHeight() * 1.15;
  221. double overbarPosition = font.ComputeOverbarVerticalPosition( fontSize.y );
  222. int extra_height = KiROUND( overbarPosition - curr_height );
  223. extra_height += thickness / 2;
  224. textsize.y += extra_height;
  225. rect.Move( wxPoint( 0, -extra_height ) );
  226. }
  227. // for multiline texts and aLine < 0, merge all rectangles
  228. // ( if aLine < 0, we want the full text bounding box )
  229. if( IsMultilineAllowed() && aLine < 0 )
  230. {
  231. for( unsigned ii = 1; ii < strings.GetCount(); ii++ )
  232. {
  233. text = strings.Item( ii );
  234. dx = KiROUND( font.ComputeStringBoundaryLimits( text, fontSize, penWidth ).x );
  235. textsize.x = std::max( textsize.x, dx );
  236. textsize.y += dy;
  237. }
  238. }
  239. rect.SetSize( textsize );
  240. /* Now, calculate the rect origin, according to text justification
  241. * At this point the rectangle origin is the text origin (m_Pos).
  242. * This is true only for left and top text justified texts (using top to bottom Y axis
  243. * orientation). and must be recalculated for others justifications
  244. * also, note the V justification is relative to the first line
  245. */
  246. switch( GetHorizJustify() )
  247. {
  248. case GR_TEXT_HJUSTIFY_LEFT:
  249. if( IsMirrored() )
  250. rect.SetX( rect.GetX() - rect.GetWidth() );
  251. break;
  252. case GR_TEXT_HJUSTIFY_CENTER:
  253. rect.SetX( rect.GetX() - (rect.GetWidth() / 2) );
  254. break;
  255. case GR_TEXT_HJUSTIFY_RIGHT:
  256. if( !IsMirrored() )
  257. rect.SetX( rect.GetX() - rect.GetWidth() );
  258. break;
  259. }
  260. dy = GetTextHeight() + thickness;
  261. switch( GetVertJustify() )
  262. {
  263. case GR_TEXT_VJUSTIFY_TOP:
  264. break;
  265. case GR_TEXT_VJUSTIFY_CENTER:
  266. rect.SetY( rect.GetY() - ( dy / 2) );
  267. break;
  268. case GR_TEXT_VJUSTIFY_BOTTOM:
  269. rect.SetY( rect.GetY() - dy );
  270. break;
  271. }
  272. if( linecount > 1 )
  273. {
  274. int yoffset;
  275. linecount -= 1;
  276. switch( GetVertJustify() )
  277. {
  278. case GR_TEXT_VJUSTIFY_TOP:
  279. break;
  280. case GR_TEXT_VJUSTIFY_CENTER:
  281. yoffset = linecount * GetInterline() / 2;
  282. rect.SetY( rect.GetY() - yoffset );
  283. break;
  284. case GR_TEXT_VJUSTIFY_BOTTOM:
  285. yoffset = linecount * GetInterline();
  286. rect.SetY( rect.GetY() - yoffset );
  287. break;
  288. }
  289. }
  290. rect.Normalize(); // Make h and v sizes always >= 0
  291. return rect;
  292. }
  293. bool EDA_TEXT::TextHitTest( const wxPoint& aPoint, int aAccuracy ) const
  294. {
  295. EDA_RECT rect = GetTextBox();
  296. wxPoint location = aPoint;
  297. rect.Inflate( aAccuracy );
  298. RotatePoint( &location, GetTextPos(), -GetTextAngle() );
  299. return rect.Contains( location );
  300. }
  301. bool EDA_TEXT::TextHitTest( const EDA_RECT& aRect, bool aContains, int aAccuracy ) const
  302. {
  303. EDA_RECT rect = aRect;
  304. rect.Inflate( aAccuracy );
  305. if( aContains )
  306. return rect.Contains( GetTextBox() );
  307. return rect.Intersects( GetTextBox(), GetTextAngle() );
  308. }
  309. void EDA_TEXT::Print( RENDER_SETTINGS* aSettings, const wxPoint& aOffset, COLOR4D aColor,
  310. OUTLINE_MODE aFillMode )
  311. {
  312. if( IsMultilineAllowed() )
  313. {
  314. std::vector<wxPoint> positions;
  315. wxArrayString strings;
  316. wxStringSplit( GetShownText(), strings, '\n' );
  317. positions.reserve( strings.Count() );
  318. GetLinePositions( positions, strings.Count() );
  319. for( unsigned ii = 0; ii < strings.Count(); ii++ )
  320. printOneLineOfText( aSettings, aOffset, aColor, aFillMode, strings[ii], positions[ii] );
  321. }
  322. else
  323. {
  324. printOneLineOfText( aSettings, aOffset, aColor, aFillMode, GetShownText(), GetTextPos() );
  325. }
  326. }
  327. void EDA_TEXT::GetLinePositions( std::vector<wxPoint>& aPositions, int aLineCount ) const
  328. {
  329. wxPoint pos = GetTextPos(); // Position of first line of the
  330. // multiline text according to
  331. // the center of the multiline text block
  332. wxPoint offset; // Offset to next line.
  333. offset.y = GetInterline();
  334. if( aLineCount > 1 )
  335. {
  336. switch( GetVertJustify() )
  337. {
  338. case GR_TEXT_VJUSTIFY_TOP:
  339. break;
  340. case GR_TEXT_VJUSTIFY_CENTER:
  341. pos.y -= ( aLineCount - 1 ) * offset.y / 2;
  342. break;
  343. case GR_TEXT_VJUSTIFY_BOTTOM:
  344. pos.y -= ( aLineCount - 1 ) * offset.y;
  345. break;
  346. }
  347. }
  348. // Rotate the position of the first line
  349. // around the center of the multiline text block
  350. RotatePoint( &pos, GetTextPos(), GetTextAngle() );
  351. // Rotate the offset lines to increase happened in the right direction
  352. RotatePoint( &offset, GetTextAngle() );
  353. for( int ii = 0; ii < aLineCount; ii++ )
  354. {
  355. aPositions.push_back( pos );
  356. pos += offset;
  357. }
  358. }
  359. void EDA_TEXT::printOneLineOfText( RENDER_SETTINGS* aSettings, const wxPoint& aOffset,
  360. COLOR4D aColor, OUTLINE_MODE aFillMode,
  361. const wxString& aText, const wxPoint &aPos )
  362. {
  363. wxDC* DC = aSettings->GetPrintDC();
  364. int penWidth = std::max( GetEffectiveTextPenWidth(), aSettings->GetDefaultPenWidth() );
  365. if( aFillMode == SKETCH )
  366. penWidth = -penWidth;
  367. wxSize size = GetTextSize();
  368. if( IsMirrored() )
  369. size.x = -size.x;
  370. GRText( DC, aOffset + aPos, aColor, aText, GetTextAngle(), size, GetHorizJustify(),
  371. GetVertJustify(), penWidth, IsItalic(), IsBold() );
  372. }
  373. wxString EDA_TEXT::GetTextStyleName() const
  374. {
  375. int style = 0;
  376. if( IsItalic() )
  377. style = 1;
  378. if( IsBold() )
  379. style += 2;
  380. wxString stylemsg[4] = {
  381. _("Normal"),
  382. _("Italic"),
  383. _("Bold"),
  384. _("Bold+Italic")
  385. };
  386. return stylemsg[style];
  387. }
  388. bool EDA_TEXT::IsDefaultFormatting() const
  389. {
  390. return ( IsVisible()
  391. && !IsMirrored()
  392. && GetHorizJustify() == GR_TEXT_HJUSTIFY_CENTER
  393. && GetVertJustify() == GR_TEXT_VJUSTIFY_CENTER
  394. && GetTextThickness() == 0
  395. && !IsItalic()
  396. && !IsBold()
  397. && !IsMultilineAllowed()
  398. );
  399. }
  400. void EDA_TEXT::Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControlBits ) const
  401. {
  402. #ifndef GERBVIEW // Gerbview does not use EDA_TEXT::Format
  403. // and does not define FormatInternalUnits, used here
  404. // however this function should exist
  405. aFormatter->Print( aNestLevel + 1, "(effects" );
  406. // Text size
  407. aFormatter->Print( 0, " (font" );
  408. aFormatter->Print( 0, " (size %s %s)",
  409. FormatInternalUnits( GetTextHeight() ).c_str(),
  410. FormatInternalUnits( GetTextWidth() ).c_str() );
  411. if( GetTextThickness() )
  412. aFormatter->Print( 0, " (thickness %s)", FormatInternalUnits( GetTextThickness() ).c_str() );
  413. if( IsBold() )
  414. aFormatter->Print( 0, " bold" );
  415. if( IsItalic() )
  416. aFormatter->Print( 0, " italic" );
  417. aFormatter->Print( 0, ")"); // (font
  418. if( IsMirrored() ||
  419. GetHorizJustify() != GR_TEXT_HJUSTIFY_CENTER ||
  420. GetVertJustify() != GR_TEXT_VJUSTIFY_CENTER )
  421. {
  422. aFormatter->Print( 0, " (justify");
  423. if( GetHorizJustify() != GR_TEXT_HJUSTIFY_CENTER )
  424. aFormatter->Print( 0, (GetHorizJustify() == GR_TEXT_HJUSTIFY_LEFT) ? " left" : " right" );
  425. if( GetVertJustify() != GR_TEXT_VJUSTIFY_CENTER )
  426. aFormatter->Print( 0, (GetVertJustify() == GR_TEXT_VJUSTIFY_TOP) ? " top" : " bottom" );
  427. if( IsMirrored() )
  428. aFormatter->Print( 0, " mirror" );
  429. aFormatter->Print( 0, ")" ); // (justify
  430. }
  431. if( !(aControlBits & CTL_OMIT_HIDE) && !IsVisible() )
  432. aFormatter->Print( 0, " hide" );
  433. aFormatter->Print( 0, ")\n" ); // (justify
  434. #endif
  435. }
  436. // Convert the text shape to a list of segment
  437. // each segment is stored as 2 wxPoints: its starting point and its ending point
  438. // we are using GRText to create the segments and therefore a call-back function is needed
  439. // This is a call back function, used by GRText to put each segment in buffer
  440. static void addTextSegmToBuffer( int x0, int y0, int xf, int yf, void* aData )
  441. {
  442. std::vector<wxPoint>* cornerBuffer = static_cast<std::vector<wxPoint>*>( aData );
  443. cornerBuffer->push_back( wxPoint( x0, y0 ) );
  444. cornerBuffer->push_back( wxPoint( xf, yf ) );
  445. }
  446. std::vector<wxPoint> EDA_TEXT::TransformToSegmentList() const
  447. {
  448. std::vector<wxPoint> cornerBuffer;
  449. wxSize size = GetTextSize();
  450. if( IsMirrored() )
  451. size.x = -size.x;
  452. bool forceBold = true;
  453. int penWidth = 0; // use max-width for bold text
  454. COLOR4D color = COLOR4D::BLACK; // not actually used, but needed by GRText
  455. if( IsMultilineAllowed() )
  456. {
  457. wxArrayString strings_list;
  458. wxStringSplit( GetShownText(), strings_list, wxChar('\n') );
  459. std::vector<wxPoint> positions;
  460. positions.reserve( strings_list.Count() );
  461. GetLinePositions( positions, strings_list.Count() );
  462. for( unsigned ii = 0; ii < strings_list.Count(); ii++ )
  463. {
  464. wxString txt = strings_list.Item( ii );
  465. GRText( NULL, positions[ii], color, txt, GetDrawRotation(), size, GetHorizJustify(),
  466. GetVertJustify(), penWidth, IsItalic(), forceBold, addTextSegmToBuffer,
  467. &cornerBuffer );
  468. }
  469. }
  470. else
  471. {
  472. GRText( NULL, GetTextPos(), color, GetText(), GetDrawRotation(), size, GetHorizJustify(),
  473. GetVertJustify(), penWidth, IsItalic(), forceBold, addTextSegmToBuffer,
  474. &cornerBuffer );
  475. }
  476. return cornerBuffer;
  477. }
  478. std::shared_ptr<SHAPE_COMPOUND> EDA_TEXT::GetEffectiveTextShape( ) const
  479. {
  480. std::shared_ptr<SHAPE_COMPOUND> shape = std::make_shared<SHAPE_COMPOUND>();
  481. int penWidth = GetEffectiveTextPenWidth();
  482. std::vector<wxPoint> pts = TransformToSegmentList();
  483. for( unsigned jj = 0; jj < pts.size(); jj += 2 )
  484. shape->AddShape( new SHAPE_SEGMENT( pts[jj], pts[jj+1], penWidth ) );
  485. return shape;
  486. }
  487. double EDA_TEXT::GetDrawRotation() const
  488. {
  489. return GetTextAngle();
  490. }
  491. static struct EDA_TEXT_DESC
  492. {
  493. EDA_TEXT_DESC()
  494. {
  495. ENUM_MAP<EDA_TEXT_HJUSTIFY_T>::Instance()
  496. .Map( GR_TEXT_HJUSTIFY_LEFT, _HKI( "Left" ) )
  497. .Map( GR_TEXT_HJUSTIFY_CENTER, _HKI( "Center" ) )
  498. .Map( GR_TEXT_HJUSTIFY_RIGHT, _HKI( "Right" ) );
  499. ENUM_MAP<EDA_TEXT_VJUSTIFY_T>::Instance()
  500. .Map( GR_TEXT_VJUSTIFY_TOP, _HKI( "Top" ) )
  501. .Map( GR_TEXT_VJUSTIFY_CENTER, _HKI( "Center" ) )
  502. .Map( GR_TEXT_VJUSTIFY_BOTTOM, _HKI( "Bottom" ) );
  503. PROPERTY_MANAGER& propMgr = PROPERTY_MANAGER::Instance();
  504. REGISTER_TYPE( EDA_TEXT );
  505. propMgr.AddProperty( new PROPERTY<EDA_TEXT, wxString>( _HKI( "Text" ),
  506. &EDA_TEXT::SetText, &EDA_TEXT::GetText ) );
  507. propMgr.AddProperty( new PROPERTY<EDA_TEXT, int>( _HKI( "Thickness" ),
  508. &EDA_TEXT::SetTextThickness, &EDA_TEXT::GetTextThickness, PROPERTY_DISPLAY::DISTANCE ) );
  509. propMgr.AddProperty( new PROPERTY<EDA_TEXT, bool>( _HKI( "Italic" ),
  510. &EDA_TEXT::SetItalic, &EDA_TEXT::IsItalic ) );
  511. propMgr.AddProperty( new PROPERTY<EDA_TEXT, bool>( _HKI( "Bold" ),
  512. &EDA_TEXT::SetBold, &EDA_TEXT::IsBold ) );
  513. propMgr.AddProperty( new PROPERTY<EDA_TEXT, bool>( _HKI( "Mirrored" ),
  514. &EDA_TEXT::SetMirrored, &EDA_TEXT::IsMirrored ) );
  515. propMgr.AddProperty( new PROPERTY<EDA_TEXT, bool>( _HKI( "Visible" ),
  516. &EDA_TEXT::SetVisible, &EDA_TEXT::IsVisible ) );
  517. propMgr.AddProperty( new PROPERTY<EDA_TEXT, int>( _HKI( "Width" ),
  518. &EDA_TEXT::SetTextWidth, &EDA_TEXT::GetTextWidth, PROPERTY_DISPLAY::DISTANCE ) );
  519. propMgr.AddProperty( new PROPERTY<EDA_TEXT, int>( _HKI( "Height" ),
  520. &EDA_TEXT::SetTextHeight, &EDA_TEXT::GetTextHeight, PROPERTY_DISPLAY::DISTANCE ) );
  521. propMgr.AddProperty( new PROPERTY_ENUM<EDA_TEXT, EDA_TEXT_HJUSTIFY_T>( _HKI( "Horizontal Justification" ),
  522. &EDA_TEXT::SetHorizJustify, &EDA_TEXT::GetHorizJustify ) );
  523. propMgr.AddProperty( new PROPERTY_ENUM<EDA_TEXT, EDA_TEXT_VJUSTIFY_T>( _HKI( "Vertical Justification" ),
  524. &EDA_TEXT::SetVertJustify, &EDA_TEXT::GetVertJustify ) );
  525. }
  526. } _EDA_TEXT_DESC;
  527. ENUM_TO_WXANY( EDA_TEXT_HJUSTIFY_T )
  528. ENUM_TO_WXANY( EDA_TEXT_VJUSTIFY_T )