2022-01-25 22:33:37 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2022 KiCad Developers, see AUTHORS.txt for contributors.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef SCH_TEXTBOX_H
|
|
|
|
#define SCH_TEXTBOX_H
|
|
|
|
|
|
|
|
|
|
|
|
#include <eda_text.h>
|
|
|
|
#include <sch_shape.h>
|
2023-11-12 14:14:41 +00:00
|
|
|
#include <schematic.h>
|
2022-01-25 22:33:37 +00:00
|
|
|
|
|
|
|
|
|
|
|
class HTML_MESSAGE_BOX;
|
|
|
|
|
|
|
|
class SCH_TEXTBOX : public SCH_SHAPE, public EDA_TEXT
|
|
|
|
{
|
|
|
|
public:
|
2024-04-15 20:18:54 +00:00
|
|
|
SCH_TEXTBOX( SCH_LAYER_ID aLayer = LAYER_NOTES, int aLineWidth = 0,
|
|
|
|
FILL_T aFillType = FILL_T::NO_FILL, const wxString& aText = wxEmptyString,
|
|
|
|
KICAD_T aType = SCH_TEXTBOX_T );
|
2022-01-25 22:33:37 +00:00
|
|
|
|
|
|
|
SCH_TEXTBOX( const SCH_TEXTBOX& aText );
|
|
|
|
|
|
|
|
~SCH_TEXTBOX() { }
|
|
|
|
|
2024-04-15 20:18:54 +00:00
|
|
|
static bool ClassOf( const EDA_ITEM* aItem )
|
2022-01-25 22:33:37 +00:00
|
|
|
{
|
|
|
|
return aItem && SCH_TEXTBOX_T == aItem->Type();
|
|
|
|
}
|
|
|
|
|
2024-04-15 20:18:54 +00:00
|
|
|
wxString GetClass() const override
|
2022-01-25 22:33:37 +00:00
|
|
|
{
|
|
|
|
return wxT( "SCH_TEXTBOX" );
|
|
|
|
}
|
|
|
|
|
2024-01-20 17:05:21 +00:00
|
|
|
int GetLegacyTextMargin() const;
|
|
|
|
|
|
|
|
void SetMarginLeft( int aLeft ) { m_marginLeft = aLeft; }
|
|
|
|
void SetMarginTop( int aTop ) { m_marginTop = aTop; }
|
|
|
|
void SetMarginRight( int aRight ) { m_marginRight = aRight; }
|
|
|
|
void SetMarginBottom( int aBottom ) { m_marginBottom = aBottom; }
|
|
|
|
|
|
|
|
int GetMarginLeft() const { return m_marginLeft; }
|
|
|
|
int GetMarginTop() const { return m_marginTop; }
|
|
|
|
int GetMarginRight() const { return m_marginRight; }
|
|
|
|
int GetMarginBottom() const { return m_marginBottom; }
|
2022-01-25 22:33:37 +00:00
|
|
|
|
2023-10-30 17:29:38 +00:00
|
|
|
int GetSchTextSize() const { return GetTextWidth(); }
|
|
|
|
void SetSchTextSize( int aSize ) { SetTextSize( VECTOR2I( aSize, aSize ) ); }
|
|
|
|
|
2022-01-31 19:11:21 +00:00
|
|
|
VECTOR2I GetDrawPos() const override;
|
2022-01-25 22:33:37 +00:00
|
|
|
|
2023-05-05 13:21:56 +00:00
|
|
|
virtual wxString GetShownText( const SCH_SHEET_PATH* aPath, bool aAllowExtraText,
|
|
|
|
int aDepth = 0 ) const;
|
|
|
|
|
|
|
|
wxString GetShownText( bool aAllowExtraText, int aDepth = 0 ) const override
|
|
|
|
{
|
2024-04-15 20:18:54 +00:00
|
|
|
SCH_SHEET_PATH* sheetPath = nullptr;
|
2023-11-12 14:14:41 +00:00
|
|
|
|
2024-04-15 20:18:54 +00:00
|
|
|
if( SCHEMATIC* schematic = Schematic() )
|
|
|
|
sheetPath = &schematic->CurrentSheet();
|
|
|
|
|
|
|
|
return GetShownText( sheetPath, aAllowExtraText, aDepth );
|
2023-05-05 13:21:56 +00:00
|
|
|
}
|
2022-01-25 22:33:37 +00:00
|
|
|
|
2022-08-27 18:14:57 +00:00
|
|
|
bool IsHypertext() const override
|
|
|
|
{
|
|
|
|
return HasHyperlink();
|
|
|
|
}
|
|
|
|
|
|
|
|
void DoHypertextAction( EDA_DRAW_FRAME* aFrame ) const override;
|
|
|
|
|
2023-08-08 16:32:08 +00:00
|
|
|
void SetExcludedFromSim( bool aExclude ) override { m_excludedFromSim = aExclude; }
|
|
|
|
bool GetExcludedFromSim() const override { return m_excludedFromSim; }
|
2023-04-09 11:14:21 +00:00
|
|
|
|
2022-01-25 22:33:37 +00:00
|
|
|
void SwapData( SCH_ITEM* aItem ) override;
|
|
|
|
|
|
|
|
bool operator<( const SCH_ITEM& aItem ) const override;
|
|
|
|
|
|
|
|
void Move( const VECTOR2I& aMoveVector ) override
|
|
|
|
{
|
|
|
|
EDA_SHAPE::move( aMoveVector );
|
|
|
|
EDA_TEXT::Offset( aMoveVector );
|
|
|
|
}
|
|
|
|
|
|
|
|
void MirrorHorizontally( int aCenter ) override;
|
|
|
|
void MirrorVertically( int aCenter ) override;
|
2024-04-04 22:51:22 +00:00
|
|
|
void Rotate( const VECTOR2I& aCenter, bool aRotateCCW ) override;
|
2022-01-25 22:33:37 +00:00
|
|
|
|
|
|
|
virtual void Rotate90( bool aClockwise );
|
|
|
|
|
|
|
|
bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override;
|
|
|
|
|
2022-08-31 09:33:46 +00:00
|
|
|
bool HitTest( const BOX2I& aRect, bool aContained, int aAccuracy = 0 ) const override;
|
2022-01-25 22:33:37 +00:00
|
|
|
|
2022-08-05 02:40:38 +00:00
|
|
|
bool Matches( const EDA_SEARCH_DATA& aSearchData, void* aAuxData ) const override
|
2022-01-25 22:33:37 +00:00
|
|
|
{
|
|
|
|
return SCH_ITEM::Matches( GetText(), aSearchData );
|
|
|
|
}
|
|
|
|
|
2022-08-05 02:40:38 +00:00
|
|
|
bool Replace( const EDA_SEARCH_DATA& aSearchData, void* aAuxData ) override
|
2022-01-25 22:33:37 +00:00
|
|
|
{
|
|
|
|
return EDA_TEXT::Replace( aSearchData );
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual bool IsReplaceable() const override { return true; }
|
|
|
|
|
2024-06-27 09:11:55 +00:00
|
|
|
wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const override;
|
2022-01-25 22:33:37 +00:00
|
|
|
|
|
|
|
BITMAPS GetMenuImage() const override;
|
|
|
|
|
2024-04-05 21:35:32 +00:00
|
|
|
void Print( const SCH_RENDER_SETTINGS* aSettings, int aUnit, int aBodyStyle,
|
|
|
|
const VECTOR2I& offset, bool aForceNoFill, bool aDimmed ) override;
|
|
|
|
|
|
|
|
void Plot( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT_OPTS& aPlotOpts,
|
|
|
|
int aUnit, int aBodyStyle, const VECTOR2I& aOffset, bool aDimmed ) override;
|
2022-01-25 22:33:37 +00:00
|
|
|
|
|
|
|
EDA_ITEM* Clone() const override
|
|
|
|
{
|
|
|
|
return new SCH_TEXTBOX( *this );
|
|
|
|
}
|
|
|
|
|
|
|
|
void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
|
2022-10-22 20:32:10 +00:00
|
|
|
|
2023-09-14 21:39:42 +00:00
|
|
|
double Similarity( const SCH_ITEM& aOther ) const override;
|
|
|
|
|
|
|
|
bool operator==( const SCH_ITEM& aOther ) const override;
|
|
|
|
|
2022-10-22 20:32:10 +00:00
|
|
|
protected:
|
|
|
|
KIFONT::FONT* getDrawFont() const override;
|
2023-04-09 11:14:21 +00:00
|
|
|
|
2023-08-06 19:20:53 +00:00
|
|
|
const KIFONT::METRICS& getFontMetrics() const override { return GetFontMetrics(); }
|
|
|
|
|
2024-04-15 20:18:54 +00:00
|
|
|
int compare( const SCH_ITEM& aOther, int aCompareFlags = 0 ) const override;
|
|
|
|
|
2023-04-09 11:14:21 +00:00
|
|
|
protected:
|
2023-08-08 16:32:08 +00:00
|
|
|
bool m_excludedFromSim;
|
2024-01-20 17:05:21 +00:00
|
|
|
int m_marginLeft;
|
|
|
|
int m_marginTop;
|
|
|
|
int m_marginRight;
|
|
|
|
int m_marginBottom;
|
2022-01-25 22:33:37 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif /* SCH_TEXTBOX_H */
|