KiCad PCB EDA Suite
Loading...
Searching...
No Matches
lib_textbox.h
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) 2022-2024 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
24#ifndef LIB_TEXTBOX_H
25#define LIB_TEXTBOX_H
26
27
28#include <eda_text.h>
29#include <lib_shape.h>
30
31
33
34class LIB_TEXTBOX : public LIB_SHAPE, public EDA_TEXT
35{
36public:
37 LIB_TEXTBOX( SCH_ITEM* aParent, int aLineWidth = 0, FILL_T aFillType = FILL_T::NO_FILL,
38 const wxString& aText = wxEmptyString );
39
40 LIB_TEXTBOX( const LIB_TEXTBOX& aText );
41
43
44 static inline bool ClassOf( const EDA_ITEM* aItem )
45 {
46 return aItem && aItem->Type() == LIB_TEXTBOX_T;
47 }
48
49 virtual wxString GetClass() const override
50 {
51 return wxT( "LIB_TEXTBOX" );
52 }
53
54 int GetLegacyTextMargin() const;
55
56 void SetMarginLeft( int aLeft ) { m_marginLeft = aLeft; }
57 void SetMarginTop( int aTop ) { m_marginTop = aTop; }
58 void SetMarginRight( int aRight ) { m_marginRight = aRight; }
59 void SetMarginBottom( int aBottom ) { m_marginBottom = aBottom; }
60
61 int GetMarginLeft() const { return m_marginLeft; }
62 int GetMarginTop() const { return m_marginTop; }
63 int GetMarginRight() const { return m_marginRight; }
64 int GetMarginBottom() const { return m_marginBottom; }
65
66 int GetLibTextSize() const { return GetTextWidth(); }
67 void SetLibTextSize( int aSize ) { SetTextSize( VECTOR2I( aSize, aSize ) ); }
68
69 VECTOR2I GetDrawPos() const override;
70
71 wxString GetShownText( bool aAllowExtraText, int aDepth = 0 ) const override;
72
73 void MirrorHorizontally( int aCenter ) override;
74 void MirrorVertically( int aCenter ) override;
75 void Rotate( const VECTOR2I& aCenter, bool aRotateCCW ) override;
76
77 bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override;
78
79 bool HitTest( const BOX2I& aRect, bool aContained, int aAccuracy = 0 ) const override;
80
81 bool Matches( const EDA_SEARCH_DATA& aSearchData, void* aAuxData ) const override
82 {
83 return SCH_ITEM::Matches( GetText(), aSearchData );
84 }
85
86 bool Replace( const EDA_SEARCH_DATA& aSearchData, void* aAuxData ) override
87 {
88 return EDA_TEXT::Replace( aSearchData );
89 }
90
91 virtual bool IsReplaceable() const override { return true; }
92
93 wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) const override;
94
95 BITMAPS GetMenuImage() const override;
96
97 void Print( const SCH_RENDER_SETTINGS* aSettings, int aUnit, int aBodyStyle,
98 const VECTOR2I& aOffset, bool aForceNoFill, bool aDimmed ) override;
99
100 void Plot( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT_OPTS& aPlotOpts,
101 int aUnit, int aBodyStyle, const VECTOR2I& aOffset, bool aDimmed ) override;
102
103 EDA_ITEM* Clone() const override
104 {
105 return new LIB_TEXTBOX( *this );
106 }
107
108 void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
109
110 void ViewGetLayers( int aLayers[], int& aCount ) const override;
111
112 double Similarity( const SCH_ITEM& aOther ) const override;
113
114 bool operator==( const SCH_ITEM& aOther ) const override;
115
116protected:
117 KIFONT::FONT* getDrawFont() const override;
118
119private:
120 int compare( const SCH_ITEM& aOther, int aCompareFlags = 0 ) const override;
121
122private:
127};
128
129
130#endif /* LIB_TEXTBOX_H */
BITMAPS
A list of all bitmap identifiers.
Definition: bitmaps_list.h:33
The base class for create windows for drawing purpose.
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:88
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:100
virtual bool Matches(const EDA_SEARCH_DATA &aSearchData, void *aAuxData) const
Compare the item against the search criteria in aSearchData.
Definition: eda_item.h:375
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
Definition: eda_text.h:83
void SetTextSize(VECTOR2I aNewSize, bool aEnforceMinTextSize=true)
Definition: eda_text.cpp:374
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:98
int GetTextWidth() const
Definition: eda_text.h:225
bool Replace(const EDA_SEARCH_DATA &aSearchData)
Helper function used in search and replace dialog.
Definition: eda_text.cpp:345
FONT is an abstract base class for both outline and stroke fonts.
Definition: font.h:131
int m_marginLeft
Definition: lib_textbox.h:123
VECTOR2I GetDrawPos() const override
void GetMsgPanelInfo(EDA_DRAW_FRAME *aFrame, std::vector< MSG_PANEL_ITEM > &aList) override
Populate aList of MSG_PANEL_ITEM objects with it's internal state for display purposes.
void SetMarginLeft(int aLeft)
Definition: lib_textbox.h:56
bool HitTest(const VECTOR2I &aPosition, int aAccuracy=0) const override
Test if aPosition is inside or on the boundary of this item.
bool Replace(const EDA_SEARCH_DATA &aSearchData, void *aAuxData) override
Perform a text replace using the find and replace criteria in aSearchData on items that support text ...
Definition: lib_textbox.h:86
int compare(const SCH_ITEM &aOther, int aCompareFlags=0) const override
Provide the draw object specific comparison called by the == and < operators.
bool operator==(const SCH_ITEM &aOther) const override
int m_marginBottom
Definition: lib_textbox.h:126
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider) const override
Return a user-visible description string of this item.
void MirrorHorizontally(int aCenter) override
Mirror item horizontally about aCenter.
Definition: lib_textbox.cpp:78
void Print(const SCH_RENDER_SETTINGS *aSettings, int aUnit, int aBodyStyle, const VECTOR2I &aOffset, bool aForceNoFill, bool aDimmed) override
Print an item.
virtual bool IsReplaceable() const override
Override this method in any derived object that supports test find and replace.
Definition: lib_textbox.h:91
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
void MirrorVertically(int aCenter) override
Mirror item vertically about aCenter.
Definition: lib_textbox.cpp:91
int GetMarginTop() const
Definition: lib_textbox.h:62
void Plot(PLOTTER *aPlotter, bool aBackground, const SCH_PLOT_OPTS &aPlotOpts, int aUnit, int aBodyStyle, const VECTOR2I &aOffset, bool aDimmed) override
Plot the item to aPlotter.
int GetMarginBottom() const
Definition: lib_textbox.h:64
int GetLibTextSize() const
Definition: lib_textbox.h:66
virtual wxString GetClass() const override
Return the class name.
Definition: lib_textbox.h:49
void SetMarginRight(int aRight)
Definition: lib_textbox.h:58
KIFONT::FONT * getDrawFont() const override
void SetLibTextSize(int aSize)
Definition: lib_textbox.h:67
bool Matches(const EDA_SEARCH_DATA &aSearchData, void *aAuxData) const override
Compare the item against the search criteria in aSearchData.
Definition: lib_textbox.h:81
int GetMarginRight() const
Definition: lib_textbox.h:63
int GetMarginLeft() const
Definition: lib_textbox.h:61
void SetMarginTop(int aTop)
Definition: lib_textbox.h:57
void SetMarginBottom(int aBottom)
Definition: lib_textbox.h:59
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition: lib_textbox.h:103
int GetLegacyTextMargin() const
Definition: lib_textbox.cpp:72
void ViewGetLayers(int aLayers[], int &aCount) const override
Return the all the layers within the VIEW the object is painted on.
int m_marginRight
Definition: lib_textbox.h:125
void Rotate(const VECTOR2I &aCenter, bool aRotateCCW) override
Rotate the item around aCenter 90 degrees in the clockwise direction.
static bool ClassOf(const EDA_ITEM *aItem)
Definition: lib_textbox.h:44
double Similarity(const SCH_ITEM &aOther) const override
Return a measure of how likely the other object is to represent the same object.
wxString GetShownText(bool aAllowExtraText, int aDepth=0) const override
Return the string actually shown after processing of the base text.
Base plotter engine class.
Definition: plotter.h:104
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:172
FILL_T
Definition: eda_shape.h:55
@ LIB_TEXTBOX_T
Definition: typeinfo.h:205
VECTOR2< int > VECTOR2I
Definition: vector2d.h:588