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.

130 lines
4.3 KiB

  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2022 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. #ifndef LIB_TEXTBOX_H
  24. #define LIB_TEXTBOX_H
  25. #include <eda_text.h>
  26. #include <lib_shape.h>
  27. class HTML_MESSAGE_BOX;
  28. class LIB_TEXTBOX : public LIB_SHAPE, public EDA_TEXT
  29. {
  30. public:
  31. LIB_TEXTBOX( LIB_SYMBOL* aParent, int aLineWidth = 0, FILL_T aFillType = FILL_T::NO_FILL,
  32. const wxString& aText = wxEmptyString );
  33. LIB_TEXTBOX( const LIB_TEXTBOX& aText );
  34. ~LIB_TEXTBOX() { }
  35. static inline bool ClassOf( const EDA_ITEM* aItem )
  36. {
  37. return aItem && aItem->Type() == LIB_TEXTBOX_T;
  38. }
  39. virtual wxString GetClass() const override
  40. {
  41. return wxT( "LIB_TEXTBOX" );
  42. }
  43. int GetLegacyTextMargin() const;
  44. void SetMarginLeft( int aLeft ) { m_marginLeft = aLeft; }
  45. void SetMarginTop( int aTop ) { m_marginTop = aTop; }
  46. void SetMarginRight( int aRight ) { m_marginRight = aRight; }
  47. void SetMarginBottom( int aBottom ) { m_marginBottom = aBottom; }
  48. int GetMarginLeft() const { return m_marginLeft; }
  49. int GetMarginTop() const { return m_marginTop; }
  50. int GetMarginRight() const { return m_marginRight; }
  51. int GetMarginBottom() const { return m_marginBottom; }
  52. int GetLibTextSize() const { return GetTextWidth(); }
  53. void SetLibTextSize( int aSize ) { SetTextSize( VECTOR2I( aSize, aSize ) ); }
  54. VECTOR2I GetDrawPos() const override;
  55. wxString GetShownText( bool aAllowExtraText, int aDepth = 0 ) const override;
  56. void MirrorHorizontally( const VECTOR2I& center );
  57. void MirrorVertically( const VECTOR2I& center );
  58. void Rotate( const VECTOR2I& aCenter, bool aRotateCCW ) override;
  59. bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override;
  60. bool HitTest( const BOX2I& aRect, bool aContained, int aAccuracy = 0 ) const override;
  61. bool Matches( const EDA_SEARCH_DATA& aSearchData, void* aAuxData ) const override
  62. {
  63. return LIB_ITEM::Matches( GetText(), aSearchData );
  64. }
  65. bool Replace( const EDA_SEARCH_DATA& aSearchData, void* aAuxData ) override
  66. {
  67. return EDA_TEXT::Replace( aSearchData );
  68. }
  69. virtual bool IsReplaceable() const override { return true; }
  70. wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) const override;
  71. BITMAPS GetMenuImage() const override;
  72. void Plot( PLOTTER* aPlotter, bool aBackground, const VECTOR2I& offset,
  73. const TRANSFORM& aTransform, bool aDimmed ) const override;
  74. EDA_ITEM* Clone() const override
  75. {
  76. return new LIB_TEXTBOX( *this );
  77. }
  78. void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
  79. void ViewGetLayers( int aLayers[], int& aCount ) const override;
  80. double Similarity( const LIB_ITEM& aOther ) const override;
  81. bool operator==( const LIB_ITEM& aOther ) const override;
  82. protected:
  83. KIFONT::FONT* getDrawFont() const override;
  84. private:
  85. int compare( const LIB_ITEM& aOther, int aCompareFlags = 0 ) const override;
  86. void print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset, void* aData,
  87. const TRANSFORM& aTransform, bool aDimmed ) override;
  88. private:
  89. int m_marginLeft;
  90. int m_marginTop;
  91. int m_marginRight;
  92. int m_marginBottom;
  93. };
  94. #endif /* LIB_TEXTBOX_H */