KiCad PCB EDA Suite
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) 2004 Jean-Pierre Charras,
5  * Copyright (C) 2004-2017 KiCad Developers, see change_log.txt for contributors.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, you may find one here:
19  *
20  * or you may search the website for the version 2 license,
21  * or you may write to the Free Software Foundation, Inc.,
22  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23  */
29 #ifndef _LIB_TEXT_H_
30 #define _LIB_TEXT_H_
32 #include <eda_text.h>
33 #include <lib_draw_item.h>
44 class LIB_TEXT : public LIB_ITEM, public EDA_TEXT
45 {
46  wxString m_savedText;
47  bool m_rotate;
48  bool m_updateText;
50  void drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
51  COLOR4D aColor, GR_DRAWMODE aDrawMode, void* aData,
52  const TRANSFORM& aTransform ) override;
54  void CalcEdit( const wxPoint& aPosition ) override;
56 public:
57  LIB_TEXT( LIB_PART * aParent );
59  // Do not create a copy constructor. The one generated by the compiler is adequate.
61  ~LIB_TEXT() { }
63  wxString GetClass() const override
64  {
65  return wxT( "LIB_TEXT" );
66  }
68  wxString GetTypeName() override
69  {
70  return _( "Text" );
71  }
73  void ViewGetLayers( int aLayers[], int& aCount ) const override;
85  void SetText( const wxString& aText ) override;
87  bool HitTest( const wxPoint& aPosition ) const override;
89  bool HitTest( const wxPoint &aPosition, int aThreshold, const TRANSFORM& aTransform ) const override;
91  bool HitTest( const EDA_RECT& aRect ) const
92  {
93  return TextHitTest( aRect );
94  }
97  int GetPenSize( ) const override;
99  void GetMsgPanelInfo( EDA_UNITS_T aUnits, std::vector< MSG_PANEL_ITEM >& aList ) override;
101  const EDA_RECT GetBoundingBox() const override;
103  void Rotate() override;
105  void BeginEdit( STATUS_FLAGS aEditMode, const wxPoint aStartPoint = wxPoint( 0, 0 ) ) override;
107  bool ContinueEdit( const wxPoint aNextPoint ) override;
109  void EndEdit( const wxPoint& aPosition, bool aAbort = false ) override;
111  void SetOffset( const wxPoint& aOffset ) override;
113  bool Inside( EDA_RECT& aRect ) const override;
115  void Move( const wxPoint& aPosition ) override;
117  wxPoint GetPosition() const override { return EDA_TEXT::GetTextPos(); }
119  void MirrorHorizontal( const wxPoint& aCenter ) override;
121  void MirrorVertical( const wxPoint& aCenter ) override;
123  void Rotate( const wxPoint& aCenter, bool aRotateCCW = true ) override;
125  void Plot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill,
126  const TRANSFORM& aTransform ) override;
128  int GetWidth() const override { return GetThickness(); }
130  void SetWidth( int aWidth ) override { SetThickness( aWidth ); }
132  wxString GetSelectMenuText( EDA_UNITS_T aUnits ) const override;
134  BITMAP_DEF GetMenuImage() const override;
136  EDA_ITEM* Clone() const override;
138 private:
150  int compare( const LIB_ITEM& aOther ) const override;
151 };
154 #endif // _LIB_TEXT_H_
void BeginEdit(STATUS_FLAGS aEditMode, const wxPoint aStartPoint=wxPoint(0, 0)) override
Begin an editing a component library draw item in aEditMode at aPosition.
Definition: lib_text.cpp:379
void Plot(PLOTTER *aPlotter, const wxPoint &aOffset, bool aFill, const TRANSFORM &aTransform) override
Plot the draw item using the plot object.
Definition: lib_text.cpp:183
void Move(const wxPoint &aPosition) override
Move a draw object to aPosition.
Definition: lib_text.cpp:141
Define a symbol library graphical text item.
Definition: lib_text.h:44
bool HitTest(const wxPoint &aPosition) const override
Function HitTest tests if aPosition is contained within or on the bounding area of an item.
Definition: lib_text.cpp:62
void EndEdit(const wxPoint &aPosition, bool aAbort=false) override
End an object editing action.
Definition: lib_text.cpp:407
wxString GetSelectMenuText(EDA_UNITS_T aUnits) const override
Function GetSelectMenuText returns the text to display to be used in the selection clarification cont...
Definition: lib_text.cpp:367
bool ContinueEdit(const wxPoint aNextPoint) override
Continue an edit in progress at aPosition.
Definition: lib_text.cpp:398
void GetMsgPanelInfo(EDA_UNITS_T aUnits, std::vector< MSG_PANEL_ITEM > &aList) override
Display basic info (type, part and convert) about the current item in message panel.
Definition: lib_text.cpp:300
void CalcEdit(const wxPoint &aPosition) override
Calculates the attributes of an item at aPosition when it is being edited.
Definition: lib_text.cpp:418
void MirrorHorizontal(const wxPoint &aCenter) override
Mirror the draw object along the horizontal (X) axis about aCenter point.
Definition: lib_text.cpp:147
wxPoint GetPosition() const override
Return the current draw object position.
Definition: lib_text.h:117
int GetThickness() const
Function GetThickness returns pen width.
Definition: eda_text.h:167
bool HitTest(const EDA_RECT &aRect) const
Definition: lib_text.h:91
Definition of base KiCad text object.
void Rotate() override
Rotate the draw item.
Definition: lib_text.cpp:337
bool Inside(EDA_RECT &aRect) const override
Test if any part of the draw object is inside rectangle bounds of aRect.
Definition: lib_text.cpp:135
Definition: lib_text.h:61
The base class for drawable items used by schematic library components.
Definition: lib_draw_item.h:67
void ViewGetLayers(int aLayers[], int &aCount) const override
Function ViewGetLayers() Returns the all the layers within the VIEW the object is painted on.
Definition: lib_text.cpp:55
Class EDA_TEXT is a mix-in class (via multiple inheritance) that handles texts such as labels,...
Definition: eda_text.h:127
Class for tranforming drawing coordinates for a wxDC device context.
Definition: transform.h:45
Drawmode. Compositing mode plus a flag or two.
Definition: gr_basic.h:37
void SetOffset(const wxPoint &aOffset) override
Set the drawing object by aOffset from the current position.
Definition: lib_text.cpp:129
Define a library symbol object.
int GetWidth() const override
Return the width of the draw item.
Definition: lib_text.h:128
Definition: base_struct.h:147
bool m_rotate
Flag to indicate a rotation occurred while editing.
Definition: lib_text.h:47
void MirrorVertical(const wxPoint &aCenter) override
Mirror the draw object along the MirrorVertical (Y) axis about aCenter point.
Definition: lib_text.cpp:159
int GetPenSize() const override
Definition: lib_text.cpp:213
wxString m_savedText
Temporary storage for the string when editing.
Definition: lib_text.h:46
Base plotter engine class.
Definition: plotter.h:97
BITMAP_DEF GetMenuImage() const override
Function GetMenuImage returns a pointer to an image to be used in menus.
Definition: lib_text.cpp:373
void drawGraphic(EDA_DRAW_PANEL *aPanel, wxDC *aDC, const wxPoint &aOffset, COLOR4D aColor, GR_DRAWMODE aDrawMode, void *aData, const TRANSFORM &aTransform) override
Draw the item on aPanel.
Definition: lib_text.cpp:231
const EDA_RECT GetBoundingBox() const override
Definition: lib_text.cpp:312
void SetText(const wxString &aText) override
Sets the text item string to aText.
Definition: lib_text.cpp:350
wxString GetClass() const override
Function GetClass returns the class name.
Definition: lib_text.h:63
Class EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
virtual bool TextHitTest(const wxPoint &aPoint, int aAccuracy=0) const
Function TextHitTest Test if aPoint is within the bounds of this object.
Definition: eda_text.cpp:255
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:154
const wxPoint & GetTextPos() const
Definition: eda_text.h:237
EDA_ITEM * Clone() const override
Function Clone creates a duplicate of this item with linked list members set to NULL.
Definition: lib_text.cpp:87
wxString GetTypeName() override
Provide a user-consumable name of the object type.
Definition: lib_text.h:68
void SetWidth(int aWidth) override
Set the width of the draw item to aWidth.
Definition: lib_text.h:130
bool m_updateText
Flag to indicate text change occurred while editing.
Definition: lib_text.h:48
Definition: lib_text.cpp:45
Definition: common.h:160
int compare(const LIB_ITEM &aOther) const override
Provide the draw object specific comparison called by the == and < operators.
Definition: lib_text.cpp:102
void SetThickness(int aNewThickness)
Function SetThickness sets pen width.
Definition: eda_text.h:161
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39