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( int aLineWidth = 0, FILL_T aFillType = FILL_T::NO_FILL,
39 const wxString& aText = wxEmptyString, KICAD_T aType = SCH_TEXTBOX_T );
40
41 SCH_TEXTBOX( const SCH_TEXTBOX& aText );
42
44
45 static inline bool ClassOf( const EDA_ITEM* aItem )
46 {
47 return aItem && SCH_TEXTBOX_T == aItem->Type();
48 }
49
50 virtual wxString GetClass() const override
51 {
52 return wxT( "SCH_TEXTBOX" );
53 }
54
55 int GetLegacyTextMargin() const;
56
57 void SetMarginLeft( int aLeft ) { m_marginLeft = aLeft; }
58 void SetMarginTop( int aTop ) { m_marginTop = aTop; }
59 void SetMarginRight( int aRight ) { m_marginRight = aRight; }
60 void SetMarginBottom( int aBottom ) { m_marginBottom = aBottom; }
61
62 int GetMarginLeft() const { return m_marginLeft; }
63 int GetMarginTop() const { return m_marginTop; }
64 int GetMarginRight() const { return m_marginRight; }
65 int GetMarginBottom() const { return m_marginBottom; }
66
67 int GetSchTextSize() const { return GetTextWidth(); }
68 void SetSchTextSize( int aSize ) { SetTextSize( VECTOR2I( aSize, aSize ) ); }
69
70 VECTOR2I GetDrawPos() const override;
71
72 virtual wxString GetShownText( const SCH_SHEET_PATH* aPath, bool aAllowExtraText,
73 int aDepth = 0 ) const;
74
75 wxString GetShownText( bool aAllowExtraText, int aDepth = 0 ) const override
76 {
77 SCHEMATIC* schematic = Schematic();
78
79 if( schematic )
80 return GetShownText( &schematic->CurrentSheet(), aAllowExtraText, aDepth );
81 else
82 return GetText();
83 }
84
85 bool IsHypertext() const override
86 {
87 return HasHyperlink();
88 }
89
90 void DoHypertextAction( EDA_DRAW_FRAME* aFrame ) const override;
91
92 void SetExcludedFromSim( bool aExclude ) override { m_excludedFromSim = aExclude; }
93 bool GetExcludedFromSim() const override { return m_excludedFromSim; }
94
95 void Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& offset ) override;
96
97 void SwapData( SCH_ITEM* aItem ) override;
98
99 bool operator<( const SCH_ITEM& aItem ) const override;
100
101 void Move( const VECTOR2I& aMoveVector ) override
102 {
103 EDA_SHAPE::move( aMoveVector );
104 EDA_TEXT::Offset( aMoveVector );
105 }
106
107 void MirrorHorizontally( int aCenter ) override;
108 void MirrorVertically( int aCenter ) override;
109 void Rotate( const VECTOR2I& aCenter ) override;
110
111 virtual void Rotate90( bool aClockwise );
112
113 bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override;
114
115 bool HitTest( const BOX2I& aRect, bool aContained, int aAccuracy = 0 ) const override;
116
117 bool Matches( const EDA_SEARCH_DATA& aSearchData, void* aAuxData ) const override
118 {
119 return SCH_ITEM::Matches( GetText(), aSearchData );
120 }
121
122 bool Replace( const EDA_SEARCH_DATA& aSearchData, void* aAuxData ) override
123 {
124 return EDA_TEXT::Replace( aSearchData );
125 }
126
127 virtual bool IsReplaceable() const override { return true; }
128
129 wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) const override;
130
131 BITMAPS GetMenuImage() const override;
132
133 void Plot( PLOTTER* aPlotter, bool aBackground,
134 const SCH_PLOT_SETTINGS& aPlotSettings ) const override;
135
136 EDA_ITEM* Clone() const override
137 {
138 return new SCH_TEXTBOX( *this );
139 }
140
141 void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
142
143 double Similarity( const SCH_ITEM& aOther ) const override;
144
145 bool operator==( const SCH_ITEM& aOther ) const override;
146
147protected:
148 KIFONT::FONT* getDrawFont() const override;
149
150 const KIFONT::METRICS& getFontMetrics() const override { return GetFontMetrics(); }
151
152protected:
158};
159
160
161#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:85
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:97
virtual bool Matches(const EDA_SEARCH_DATA &aSearchData, void *aAuxData) const
Compare the item against the search criteria in aSearchData.
Definition: eda_item.h:372
void move(const VECTOR2I &aMoveVector)
Definition: eda_shape.cpp:241
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
Definition: eda_text.h:80
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:95
int GetTextWidth() const
Definition: eda_text.h:222
virtual bool HasHyperlink() const
Definition: eda_text.h:358
void Offset(const VECTOR2I &aOffset)
Definition: eda_text.cpp:437
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
Container for all the knowledge about how graphical objects are drawn on any output surface/device.
Base plotter engine class.
Definition: plotter.h:104
Holds all the data relating to one schematic.
Definition: schematic.h:75
SCH_SHEET_PATH & CurrentSheet() const override
Definition: schematic.h:136
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:165
SCHEMATIC * Schematic() const
Searches the item hierarchy to find a SCHEMATIC.
Definition: sch_item.cpp:113
const KIFONT::METRICS & GetFontMetrics() const
Definition: sch_item.cpp:331
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:60
bool Matches(const EDA_SEARCH_DATA &aSearchData, void *aAuxData) const override
Compare the item against the search criteria in aSearchData.
Definition: sch_textbox.h:117
int m_marginRight
Definition: sch_textbox.h:156
int m_marginBottom
Definition: sch_textbox.h:157
int GetMarginBottom() const
Definition: sch_textbox.h:65
void MirrorHorizontally(int aCenter) override
Mirror item horizontally about aCenter.
Definition: sch_textbox.cpp:84
bool m_excludedFromSim
Definition: sch_textbox.h:153
bool operator==(const SCH_ITEM &aOther) const override
bool HitTest(const VECTOR2I &aPosition, int aAccuracy=0) const override
Test if aPosition is inside or on the boundary of this item.
virtual wxString GetClass() const override
Return the class name.
Definition: sch_textbox.h:50
int GetLegacyTextMargin() const
Definition: sch_textbox.cpp:78
int GetMarginLeft() const
Definition: sch_textbox.h:62
int GetSchTextSize() const
Definition: sch_textbox.h:67
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:75
void Rotate(const VECTOR2I &aCenter) override
Rotate the item around aCenter 90 degrees in the clockwise direction.
virtual bool IsReplaceable() const override
Override this method in any derived object that supports test find and replace.
Definition: sch_textbox.h:127
bool GetExcludedFromSim() const override
Definition: sch_textbox.h:93
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
bool operator<(const SCH_ITEM &aItem) const override
const KIFONT::METRICS & getFontMetrics() const override
Definition: sch_textbox.h:150
void Plot(PLOTTER *aPlotter, bool aBackground, const SCH_PLOT_SETTINGS &aPlotSettings) const override
Plot the schematic item to aPlotter.
VECTOR2I GetDrawPos() const override
int GetMarginRight() const
Definition: sch_textbox.h:64
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:122
bool IsHypertext() const override
Allow items to support hypertext actions when hovered/clicked.
Definition: sch_textbox.h:85
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition: sch_textbox.h:136
static bool ClassOf(const EDA_ITEM *aItem)
Definition: sch_textbox.h:45
int GetMarginTop() const
Definition: sch_textbox.h:63
void Move(const VECTOR2I &aMoveVector) override
Move the item by aMoveVector to a new position.
Definition: sch_textbox.h:101
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:57
int m_marginLeft
Definition: sch_textbox.h:154
virtual void Rotate90(bool aClockwise)
void SetMarginRight(int aRight)
Definition: sch_textbox.h:59
void SetSchTextSize(int aSize)
Definition: sch_textbox.h:68
double Similarity(const SCH_ITEM &aOther) const override
Return a measure of how likely the other object is to represent the same object.
void Print(const RENDER_SETTINGS *aSettings, const VECTOR2I &offset) override
Print a schematic item.
void MirrorVertically(int aCenter) override
Mirror item vertically about aCenter.
Definition: sch_textbox.cpp:97
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider) const override
Return a user-visible description string of this item.
KIFONT::FONT * getDrawFont() const override
void DoHypertextAction(EDA_DRAW_FRAME *aFrame) const override
void SetMarginTop(int aTop)
Definition: sch_textbox.h:58
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:92
FILL_T
Definition: eda_shape.h:54
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition: typeinfo.h:78
@ SCH_TEXTBOX_T
Definition: typeinfo.h:151
VECTOR2< int > VECTOR2I
Definition: vector2d.h:588