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
31
33
34class SCH_TEXTBOX : public SCH_SHAPE, public EDA_TEXT
35{
36public:
37 SCH_TEXTBOX( int aLineWidth = 0, FILL_T aFillType = FILL_T::NO_FILL,
38 const wxString& aText = wxEmptyString );
39
40 SCH_TEXTBOX( const SCH_TEXTBOX& aText );
41
43
44 static inline bool ClassOf( const EDA_ITEM* aItem )
45 {
46 return aItem && SCH_TEXTBOX_T == aItem->Type();
47 }
48
49 virtual wxString GetClass() const override
50 {
51 return wxT( "SCH_TEXTBOX" );
52 }
53
54 int GetTextMargin() const;
55
56 VECTOR2I GetDrawPos() const override;
57
58 virtual wxString GetShownText( const SCH_SHEET_PATH* aPath, bool aAllowExtraText,
59 int aDepth = 0 ) const;
60
61 wxString GetShownText( bool aAllowExtraText, int aDepth = 0 ) const override
62 {
63 return GetShownText( nullptr, aAllowExtraText, aDepth );
64 }
65
66 bool IsHypertext() const override
67 {
68 return HasHyperlink();
69 }
70
71 void DoHypertextAction( EDA_DRAW_FRAME* aFrame ) const override;
72
73 void SetExcludeFromSim( bool aExclude ) override { m_excludeFromSim = aExclude; }
74 bool GetExcludeFromSim() const override { return m_excludeFromSim; }
75
76 void Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& offset ) override;
77
78 void SwapData( SCH_ITEM* aItem ) override;
79
80 bool operator<( const SCH_ITEM& aItem ) const override;
81
82 void Move( const VECTOR2I& aMoveVector ) override
83 {
84 EDA_SHAPE::move( aMoveVector );
85 EDA_TEXT::Offset( aMoveVector );
86 }
87
88 void MirrorHorizontally( int aCenter ) override;
89 void MirrorVertically( int aCenter ) override;
90 void Rotate( const VECTOR2I& aCenter ) override;
91
92 virtual void Rotate90( bool aClockwise );
93
94 bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override;
95
96 bool HitTest( const BOX2I& aRect, bool aContained, int aAccuracy = 0 ) const override;
97
98 bool Matches( const EDA_SEARCH_DATA& aSearchData, void* aAuxData ) const override
99 {
100 return SCH_ITEM::Matches( GetText(), aSearchData );
101 }
102
103 bool Replace( const EDA_SEARCH_DATA& aSearchData, void* aAuxData ) override
104 {
105 return EDA_TEXT::Replace( aSearchData );
106 }
107
108 virtual bool IsReplaceable() const override { return true; }
109
110 wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) const override;
111
112 BITMAPS GetMenuImage() const override;
113
114 void Plot( PLOTTER* aPlotter, bool aBackground ) const override;
115
116 EDA_ITEM* Clone() const override
117 {
118 return new SCH_TEXTBOX( *this );
119 }
120
121 void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
122
123protected:
124 KIFONT::FONT* getDrawFont() const override;
125
126protected:
128};
129
130
131#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:365
void move(const VECTOR2I &aMoveVector)
Definition: eda_shape.cpp:173
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
Definition: eda_text.h:72
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:87
virtual bool HasHyperlink() const
Definition: eda_text.h:340
void Offset(const VECTOR2I &aOffset)
Definition: eda_text.cpp:401
bool Replace(const EDA_SEARCH_DATA &aSearchData)
Helper function used in search and replace dialog.
Definition: eda_text.cpp:330
FONT is an abstract base class for both outline and stroke fonts.
Definition: font.h:105
Container for all the knowledge about how graphical objects are drawn on any output surface/device.
Base plotter engine class.
Definition: plotter.h:110
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:147
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
bool Matches(const EDA_SEARCH_DATA &aSearchData, void *aAuxData) const override
Compare the item against the search criteria in aSearchData.
Definition: sch_textbox.h:98
void MirrorHorizontally(int aCenter) override
Mirror item horizontally about aCenter.
Definition: sch_textbox.cpp:74
bool GetExcludeFromSim() const override
Definition: sch_textbox.h:74
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:49
void SetExcludeFromSim(bool aExclude) override
Definition: sch_textbox.h:73
void Plot(PLOTTER *aPlotter, bool aBackground) const override
Plot the schematic item to aPlotter.
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:61
bool m_excludeFromSim
Definition: sch_textbox.h:127
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:108
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
bool operator<(const SCH_ITEM &aItem) const override
int GetTextMargin() const
Definition: sch_textbox.cpp:68
VECTOR2I GetDrawPos() const override
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:103
bool IsHypertext() const override
Allow items to support hypertext actions when hovered/clicked.
Definition: sch_textbox.h:66
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition: sch_textbox.h:116
static bool ClassOf(const EDA_ITEM *aItem)
Definition: sch_textbox.h:44
void Move(const VECTOR2I &aMoveVector) override
Move the item by aMoveVector to a new position.
Definition: sch_textbox.h:82
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.
virtual void Rotate90(bool aClockwise)
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:89
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 SwapData(SCH_ITEM *aItem) override
Swap the internal data structures aItem with the schematic item.
FILL_T
Definition: eda_shape.h:54
@ SCH_TEXTBOX_T
Definition: typeinfo.h:139