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.

107 lines
3.4 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 GetTextMargin() const;
  44. VECTOR2I GetDrawPos() const override;
  45. wxString GetShownText( int aDepth = 0, bool aAllowExtraText = true ) const override;
  46. void MirrorHorizontally( const VECTOR2I& center );
  47. void MirrorVertically( const VECTOR2I& center );
  48. void Rotate( const VECTOR2I& aCenter, bool aRotateCCW ) override;
  49. bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override;
  50. bool HitTest( const BOX2I& aRect, bool aContained, int aAccuracy = 0 ) const override;
  51. bool Matches( const EDA_SEARCH_DATA& aSearchData, void* aAuxData ) const override
  52. {
  53. return LIB_ITEM::Matches( GetText(), aSearchData );
  54. }
  55. bool Replace( const EDA_SEARCH_DATA& aSearchData, void* aAuxData ) override
  56. {
  57. return EDA_TEXT::Replace( aSearchData );
  58. }
  59. virtual bool IsReplaceable() const override { return true; }
  60. wxString GetSelectMenuText( UNITS_PROVIDER* aUnitsProvider ) const override;
  61. BITMAPS GetMenuImage() const override;
  62. void Plot( PLOTTER* aPlotter, bool aBackground, const VECTOR2I& offset,
  63. const TRANSFORM& aTransform, bool aDimmed ) const override;
  64. EDA_ITEM* Clone() const override
  65. {
  66. return new LIB_TEXTBOX( *this );
  67. }
  68. void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
  69. void ViewGetLayers( int aLayers[], int& aCount ) const override;
  70. protected:
  71. KIFONT::FONT* getDrawFont() const override;
  72. private:
  73. int compare( const LIB_ITEM& aOther, int aCompareFlags = 0 ) const override;
  74. void print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset, void* aData,
  75. const TRANSFORM& aTransform, bool aDimmed ) override;
  76. };
  77. #endif /* LIB_TEXTBOX_H */