KiCad PCB EDA Suite
Loading...
Searching...
No Matches
sch_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 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 SCH_TEXTBOX_H
25#define SCH_TEXTBOX_H
26
27
28#include <eda_text.h>
29#include <sch_shape.h>
30#include <schematic.h>
31
32
34
35class SCH_TEXTBOX : public SCH_SHAPE, public EDA_TEXT
36{
37public:
38 SCH_TEXTBOX( SCH_LAYER_ID aLayer = LAYER_NOTES, int aLineWidth = 0,
39 FILL_T aFillType = FILL_T::NO_FILL, const wxString& aText = wxEmptyString,
40 KICAD_T aType = SCH_TEXTBOX_T );
41
42 SCH_TEXTBOX( const SCH_TEXTBOX& aText );
43
45
46 static bool ClassOf( const EDA_ITEM* aItem )
47 {
48 return aItem && SCH_TEXTBOX_T == aItem->Type();
49 }
50
51 wxString GetClass() const override
52 {
53 return wxT( "SCH_TEXTBOX" );
54 }
55
56 int GetLegacyTextMargin() const;
57
58 void SetMarginLeft( int aLeft ) { m_marginLeft = aLeft; }
59 void SetMarginTop( int aTop ) { m_marginTop = aTop; }
60 void SetMarginRight( int aRight ) { m_marginRight = aRight; }
61 void SetMarginBottom( int aBottom ) { m_marginBottom = aBottom; }
62
63 int GetMarginLeft() const { return m_marginLeft; }
64 int GetMarginTop() const { return m_marginTop; }
65 int GetMarginRight() const { return m_marginRight; }
66 int GetMarginBottom() const { return m_marginBottom; }
67
68 int GetSchTextSize() const { return GetTextWidth(); }
69 void SetSchTextSize( int aSize ) { SetTextSize( VECTOR2I( aSize, aSize ) ); }
70
71 VECTOR2I GetDrawPos() const override;
72
73 virtual wxString GetShownText( const SCH_SHEET_PATH* aPath, bool aAllowExtraText,
74 int aDepth = 0 ) const;
75
76 wxString GetShownText( bool aAllowExtraText, int aDepth = 0 ) const override
77 {
78 SCH_SHEET_PATH* sheetPath = nullptr;
79
80 if( SCHEMATIC* schematic = Schematic() )
81 sheetPath = &schematic->CurrentSheet();
82
83 return GetShownText( sheetPath, aAllowExtraText, aDepth );
84 }
85
86 bool IsHypertext() const override
87 {
88 return HasHyperlink();
89 }
90
91 void DoHypertextAction( EDA_DRAW_FRAME* aFrame ) const override;
92
93 void SetExcludedFromSim( bool aExclude ) override { m_excludedFromSim = aExclude; }
94 bool GetExcludedFromSim() const override { return m_excludedFromSim; }
95
96 void SwapData( SCH_ITEM* aItem ) override;
97
98 bool operator<( const SCH_ITEM& aItem ) const override;
99
100 void Move( const VECTOR2I& aMoveVector ) override
101 {
102 EDA_SHAPE::move( aMoveVector );
103 EDA_TEXT::Offset( aMoveVector );
104 }
105
106 void MirrorHorizontally( int aCenter ) override;
107 void MirrorVertically( int aCenter ) override;
108 void Rotate( const VECTOR2I& aCenter, bool aRotateCCW ) override;
109
110 virtual void Rotate90( bool aClockwise );
111
112 bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override;
113
114 bool HitTest( const BOX2I& aRect, bool aContained, int aAccuracy = 0 ) const override;
115
116 bool Matches( const EDA_SEARCH_DATA& aSearchData, void* aAuxData ) const override
117 {
118 return SCH_ITEM::Matches( GetText(), aSearchData );
119 }
120
121 bool Replace( const EDA_SEARCH_DATA& aSearchData, void* aAuxData ) override
122 {
123 return EDA_TEXT::Replace( aSearchData );
124 }
125
126 virtual bool IsReplaceable() const override { return true; }
127
128 wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const override;
129
130 BITMAPS GetMenuImage() const override;
131
132 void Print( const SCH_RENDER_SETTINGS* aSettings, int aUnit, int aBodyStyle,
133 const VECTOR2I& offset, bool aForceNoFill, bool aDimmed ) override;
134
135 void Plot( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT_OPTS& aPlotOpts,
136 int aUnit, int aBodyStyle, const VECTOR2I& aOffset, bool aDimmed ) override;
137
138 EDA_ITEM* Clone() const override
139 {
140 return new SCH_TEXTBOX( *this );
141 }
142
143 void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
144
145 double Similarity( const SCH_ITEM& aOther ) const override;
146
147 bool operator==( const SCH_ITEM& aOther ) const override;
148
149protected:
150 KIFONT::FONT* getDrawFont() const override;
151
152 const KIFONT::METRICS& getFontMetrics() const override { return GetFontMetrics(); }
153
154 int compare( const SCH_ITEM& aOther, int aCompareFlags = 0 ) const override;
155
156protected:
162};
163
164
165#endif /* SCH_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:89
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:101
virtual bool Matches(const EDA_SEARCH_DATA &aSearchData, void *aAuxData) const
Compare the item against the search criteria in aSearchData.
Definition: eda_item.h:377
void move(const VECTOR2I &aMoveVector)
Definition: eda_shape.cpp:279
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
Definition: eda_text.h:79
void SetTextSize(VECTOR2I aNewSize, bool aEnforceMinTextSize=true)
Definition: eda_text.cpp:419
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:94
int GetTextWidth() const
Definition: eda_text.h:244
virtual bool HasHyperlink() const
Definition: eda_text.h:380
void Offset(const VECTOR2I &aOffset)
Definition: eda_text.cpp:482
bool Replace(const EDA_SEARCH_DATA &aSearchData)
Helper function used in search and replace dialog.
Definition: eda_text.cpp:390
FONT is an abstract base class for both outline and stroke fonts.
Definition: font.h:131
Base plotter engine class.
Definition: plotter.h:105
Holds all the data relating to one schematic.
Definition: schematic.h:77
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:166
SCHEMATIC * Schematic() const
Searches the item hierarchy to find a SCHEMATIC.
Definition: sch_item.cpp:150
const KIFONT::METRICS & GetFontMetrics() const
Definition: sch_item.cpp:466
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
void SetMarginBottom(int aBottom)
Definition: sch_textbox.h:61
bool Matches(const EDA_SEARCH_DATA &aSearchData, void *aAuxData) const override
Compare the item against the search criteria in aSearchData.
Definition: sch_textbox.h:116
int m_marginRight
Definition: sch_textbox.h:160
int m_marginBottom
Definition: sch_textbox.h:161
int GetMarginBottom() const
Definition: sch_textbox.h:66
void MirrorHorizontally(int aCenter) override
Mirror item horizontally about aCenter.
Definition: sch_textbox.cpp:85
bool m_excludedFromSim
Definition: sch_textbox.h:157
bool operator==(const SCH_ITEM &aOther) const override
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider, bool aFull) const override
Return a user-visible description string of this item.
bool HitTest(const VECTOR2I &aPosition, int aAccuracy=0) const override
Test if aPosition is inside or on the boundary of this item.
int GetLegacyTextMargin() const
Definition: sch_textbox.cpp:76
int GetMarginLeft() const
Definition: sch_textbox.h:63
int GetSchTextSize() const
Definition: sch_textbox.h:68
virtual wxString GetShownText(const SCH_SHEET_PATH *aPath, bool aAllowExtraText, int aDepth=0) const
wxString GetShownText(bool aAllowExtraText, int aDepth=0) const override
Return the string actually shown after processing of the base text.
Definition: sch_textbox.h:76
virtual bool IsReplaceable() const override
Override this method in any derived object that supports test find and replace.
Definition: sch_textbox.h:126
bool GetExcludedFromSim() const override
Definition: sch_textbox.h:94
int compare(const SCH_ITEM &aOther, int aCompareFlags=0) const override
Provide the draw object specific comparison called by the == and < operators.
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
bool operator<(const SCH_ITEM &aItem) const override
wxString GetClass() const override
Return the class name.
Definition: sch_textbox.h:51
const KIFONT::METRICS & getFontMetrics() const override
Definition: sch_textbox.h:152
void Print(const SCH_RENDER_SETTINGS *aSettings, int aUnit, int aBodyStyle, const VECTOR2I &offset, bool aForceNoFill, bool aDimmed) override
Print an item.
VECTOR2I GetDrawPos() const override
int GetMarginRight() const
Definition: sch_textbox.h:65
void Rotate(const VECTOR2I &aCenter, bool aRotateCCW) override
Rotate the item around aCenter 90 degrees in the clockwise direction.
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.
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: sch_textbox.h:121
bool IsHypertext() const override
Allow items to support hypertext actions when hovered/clicked.
Definition: sch_textbox.h:86
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition: sch_textbox.h:138
static bool ClassOf(const EDA_ITEM *aItem)
Definition: sch_textbox.h:46
int GetMarginTop() const
Definition: sch_textbox.h:64
void Move(const VECTOR2I &aMoveVector) override
Move the item by aMoveVector to a new position.
Definition: sch_textbox.h:100
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: sch_textbox.h:58
int m_marginLeft
Definition: sch_textbox.h:158
virtual void Rotate90(bool aClockwise)
void SetMarginRight(int aRight)
Definition: sch_textbox.h:60
void SetSchTextSize(int aSize)
Definition: sch_textbox.h:69
double Similarity(const SCH_ITEM &aOther) const override
Return a measure of how likely the other object is to represent the same object.
void MirrorVertically(int aCenter) override
Mirror item vertically about aCenter.
Definition: sch_textbox.cpp:98
KIFONT::FONT * getDrawFont() const override
void DoHypertextAction(EDA_DRAW_FRAME *aFrame) const override
void SetMarginTop(int aTop)
Definition: sch_textbox.h:59
void SwapData(SCH_ITEM *aItem) override
Swap the internal data structures aItem with the schematic item.
void SetExcludedFromSim(bool aExclude) override
Definition: sch_textbox.h:93
FILL_T
Definition: eda_shape.h:55
SCH_LAYER_ID
Eeschema drawing layers.
Definition: layer_ids.h:353
@ LAYER_NOTES
Definition: layer_ids.h:371
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition: typeinfo.h:78
@ SCH_TEXTBOX_T
Definition: typeinfo.h:152
VECTOR2< int32_t > VECTOR2I
Definition: vector2d.h:691