diff --git a/bitmaps_png/CMakeLists.txt b/bitmaps_png/CMakeLists.txt index cc710131a8..7539da5256 100644 --- a/bitmaps_png/CMakeLists.txt +++ b/bitmaps_png/CMakeLists.txt @@ -1,7 +1,7 @@ # This program source code file is part of KICAD, a free EDA CAD application. # # Copyright (C) 2011 SoftPLC Corporation, Dick Hollenbeck -# Copyright (C) 2011-2018 Kicad Developers, see AUTHORS.txt for contributors. +# Copyright (C) 2011-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 @@ -174,6 +174,7 @@ set( BMAPS_MID add_radial_dimension add_rectangle add_symbol_to_schematic + add_textbox add_tracks add_via add_zone_cutout diff --git a/bitmaps_png/png/add_textbox_24.png b/bitmaps_png/png/add_textbox_24.png new file mode 100644 index 0000000000..e6d937e6c8 Binary files /dev/null and b/bitmaps_png/png/add_textbox_24.png differ diff --git a/bitmaps_png/png/text_box_24.png b/bitmaps_png/png/text_box_24.png new file mode 100644 index 0000000000..325c2c4494 Binary files /dev/null and b/bitmaps_png/png/text_box_24.png differ diff --git a/bitmaps_png/sources/light/add_textbox.svg b/bitmaps_png/sources/light/add_textbox.svg new file mode 100644 index 0000000000..35a67b764d --- /dev/null +++ b/bitmaps_png/sources/light/add_textbox.svg @@ -0,0 +1,102 @@ + + + + + + + + + + image/svg+xml + + add_rectangle + + + + + + + + + + + + + + + add_rectangle + + + + + diff --git a/common/eda_item.cpp b/common/eda_item.cpp index 8c1c7ee47d..373cdb63a1 100644 --- a/common/eda_item.cpp +++ b/common/eda_item.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2015 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com - * Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 1992-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 @@ -346,6 +346,7 @@ static struct EDA_ITEM_DESC .Map( SCH_LINE_T, _HKI( "Line" ) ) .Map( SCH_BITMAP_T, _HKI( "Bitmap" ) ) .Map( SCH_TEXT_T, _HKI( "Text" ) ) + .Map( SCH_TEXTBOX_T, _HKI( "Text Box" ) ) .Map( SCH_LABEL_T, _HKI( "Net Label" ) ) .Map( SCH_DIRECTIVE_LABEL_T, _HKI( "Directive Label" ) ) .Map( SCH_GLOBAL_LABEL_T, _HKI( "Global Label" ) ) @@ -367,6 +368,7 @@ static struct EDA_ITEM_DESC .Map( LIB_ALIAS_T, _HKI( "Alias" ) ) .Map( LIB_SHAPE_T, _HKI( "Graphic" ) ) .Map( LIB_TEXT_T, _HKI( "Text" ) ) + .Map( LIB_TEXTBOX_T, _HKI( "Text Box" ) ) .Map( LIB_PIN_T, _HKI( "Pin" ) ) .Map( LIB_FIELD_T, _HKI( "Symbol Field" ) ) diff --git a/common/font/font.cpp b/common/font/font.cpp index 9bca6ace54..9600125fbe 100644 --- a/common/font/font.cpp +++ b/common/font/font.cpp @@ -96,7 +96,7 @@ bool FONT::IsStroke( const wxString& aFontName ) } -void FONT::getLinePositions( const UTF8& aText, const VECTOR2I& aPosition, +void FONT::getLinePositions( const wxString& aText, const VECTOR2I& aPosition, wxArrayString& aTextLines, std::vector& aPositions, std::vector& aExtents, const TEXT_ATTRIBUTES& aAttrs ) const { @@ -161,7 +161,7 @@ void FONT::getLinePositions( const UTF8& aText, const VECTOR2I& aPosition, * object, such as a run of superscript characters) * @param aAttrs are the styling attributes of the text, including its rotation */ -void FONT::Draw( KIGFX::GAL* aGal, const UTF8& aText, const VECTOR2I& aPosition, +void FONT::Draw( KIGFX::GAL* aGal, const wxString& aText, const VECTOR2I& aPosition, const VECTOR2I& aCursor, const TEXT_ATTRIBUTES& aAttrs ) const { if( !aGal || aText.empty() ) @@ -232,7 +232,7 @@ VECTOR2I drawMarkup( BOX2I* aBoundingBox, std::vector>* a VECTOR2I FONT::drawMarkup( BOX2I* aBoundingBox, std::vector>* aGlyphs, - const UTF8& aText, const VECTOR2I& aPosition, const VECTOR2I& aSize, + const wxString& aText, const VECTOR2I& aPosition, const VECTOR2I& aSize, const EDA_ANGLE& aAngle, bool aMirror, const VECTOR2I& aOrigin, TEXT_STYLE_FLAGS aTextStyle ) const { @@ -244,7 +244,7 @@ VECTOR2I FONT::drawMarkup( BOX2I* aBoundingBox, std::vector>* aWords, + const std::unique_ptr& aNode, const KIFONT::FONT* aFont, + const VECTOR2I& aSize, TEXT_STYLE_FLAGS aTextStyle ) +{ + TEXT_STYLE_FLAGS textStyle = aTextStyle; + + if( !aNode->is_root() ) + { + wxChar escapeChar = 0; + + if( aNode->isSubscript() ) + { + escapeChar = '_'; + textStyle = TEXT_STYLE::SUBSCRIPT; + } + else if( aNode->isSuperscript() ) + { + escapeChar = '^'; + textStyle = TEXT_STYLE::SUPERSCRIPT; + } + + if( aNode->isOverbar() ) + { + escapeChar = '~'; + textStyle |= TEXT_STYLE::OVERBAR; + } + + if( escapeChar ) + { + wxString word = wxString::Format( "%c{", escapeChar ); + int width = 0; + + if( aNode->has_content() ) + { + VECTOR2I next = aFont->GetTextAsGlyphs( nullptr, nullptr, aNode->string(), aSize, + {0,0}, ANGLE_0, false, {0,0}, textStyle ); + word += aNode->string(); + width += next.x; + } + + std::vector> childWords; + + for( const std::unique_ptr& child : aNode->children ) + wordbreakMarkup( &childWords, child, aFont, aSize, textStyle ); + + for( const std::pair& childWord : childWords ) + { + word += childWord.first; + width += childWord.second; + } + + word += "}"; + aWords->emplace_back( std::make_pair( word, width ) ); + return; + } + else + { + wxString space( wxT( " " ) ); + wxString textRun( aNode->string() ); + wxArrayString words; + + wxStringSplit( textRun, words, ' ' ); + + if( textRun.EndsWith( " " ) ) + words.Add( " " ); + + for( size_t ii = 0; ii < words.size(); ++ii ) + { + int w = aFont->GetTextAsGlyphs( nullptr, nullptr, words[ii], aSize, { 0, 0 }, + ANGLE_0, false, { 0, 0 }, textStyle ).x; + + aWords->emplace_back( std::make_pair( words[ii], w ) ); + } + } + } + + for( const std::unique_ptr& child : aNode->children ) + wordbreakMarkup( aWords, child, aFont, aSize, textStyle ); +} + + +void FONT::wordbreakMarkup( std::vector>* aWords, const wxString& aText, + const VECTOR2I& aSize, TEXT_STYLE_FLAGS aTextStyle ) const +{ + MARKUP::MARKUP_PARSER markupParser( aText ); + std::unique_ptr root = markupParser.Parse(); + + ::wordbreakMarkup( aWords, root, this, aSize, aTextStyle ); +} + + +/* + * This is a highly simplified line-breaker. KiCad is an EDA tool, not a word processor. + * + * 1) It breaks only on spaces. If you type a word wider than the column width then you get + * overflow. + * 2) It treats runs of formatted text (superscript, subscript, overbar) as single words. + * 3) It does not perform justification. + * + * The results of the linebreaking are the addition of \n in the text. It is presumed that this + * function is called on m_shownText (or equivalent) rather than the original source text. + */ +void FONT::LinebreakText( wxString& aText, int aColumnWidth, const VECTOR2I& aSize, int aThickness, + bool aBold, bool aItalic ) const +{ + TEXT_STYLE_FLAGS textStyle = 0; + + if( aBold ) + textStyle |= TEXT_STYLE::BOLD; + + if( aItalic ) + textStyle |= TEXT_STYLE::ITALIC; + + int spaceWidth = GetTextAsGlyphs( nullptr, nullptr, " ", aSize, VECTOR2I(), ANGLE_0, false, + VECTOR2I(), textStyle ).x; + + wxArrayString textLines; + wxStringSplit( aText, textLines, '\n' ); + + aText = wxEmptyString; + + for( size_t ii = 0; ii < textLines.Count(); ++ii ) + { + int lineWidth = 0; + std::vector> words; + + wordbreakMarkup( &words, textLines[ii], aSize, textStyle ); + + for( size_t jj = 0; jj < words.size(); /* advance in loop */ ) + { + if( lineWidth + spaceWidth + words[jj].second < aColumnWidth - aThickness ) + { + if( lineWidth > 0 ) + { + aText += " "; + lineWidth += spaceWidth; + } + + aText += words[jj].first; + lineWidth += words[jj].second; + + jj++; + } + else + { + aText += '\n'; + lineWidth = 0; + } + } + } +} + + diff --git a/common/font/outline_font.cpp b/common/font/outline_font.cpp index ad3a385df8..cd4ebe609d 100644 --- a/common/font/outline_font.cpp +++ b/common/font/outline_font.cpp @@ -206,7 +206,7 @@ void OUTLINE_FONT::GetLinesAsGlyphs( std::vector>* aGlyph void OUTLINE_FONT::GetLinesAsGlyphs( std::vector>* aGlyphs, - const UTF8& aText, const VECTOR2I& aPosition, + const wxString& aText, const VECTOR2I& aPosition, const TEXT_ATTRIBUTES& aAttrs ) const { wxArrayString strings; @@ -221,14 +221,14 @@ void OUTLINE_FONT::GetLinesAsGlyphs( std::vector>* aGlyph for( size_t i = 0; i < strings.GetCount(); i++ ) { - (void) drawMarkup( nullptr, aGlyphs, UTF8( strings.Item( i ) ), positions[i], - aAttrs.m_Size, aAttrs.m_Angle, aAttrs.m_Mirrored, aPosition, textStyle ); + (void) drawMarkup( nullptr, aGlyphs, strings.Item( i ), positions[i], aAttrs.m_Size, + aAttrs.m_Angle, aAttrs.m_Mirrored, aPosition, textStyle ); } } VECTOR2I OUTLINE_FONT::GetTextAsGlyphs( BOX2I* aBBox, std::vector>* aGlyphs, - const UTF8& aText, const VECTOR2I& aSize, + const wxString& aText, const VECTOR2I& aSize, const VECTOR2I& aPosition, const EDA_ANGLE& aAngle, bool aMirror, const VECTOR2I& aOrigin, TEXT_STYLE_FLAGS aTextStyle ) const @@ -396,7 +396,7 @@ VECTOR2I OUTLINE_FONT::GetTextAsGlyphs( BOX2I* aBBox, std::vector>* aGlyphs, - const UTF8& aText, const VECTOR2I& aSize, + const wxString& aText, const VECTOR2I& aSize, const VECTOR2I& aPosition, const EDA_ANGLE& aAngle, bool aMirror, const VECTOR2I& aOrigin, TEXT_STYLE_FLAGS aTextStyle ) const @@ -236,25 +236,19 @@ VECTOR2I STROKE_FONT::GetTextAsGlyphs( BOX2I* aBBox, std::vector= (int) m_glyphBoundingBoxes->size() || dd < 0 ) + if( c >= (int) m_glyphBoundingBoxes->size() || c < 0 ) { - switch( *i ) - { - case '\t': - // TAB->SPACE - dd = 0; - break; - default: - // everything else is turned into a '?' - dd = '?' - ' '; - } + if( c == '\t' ) + c = ' '; + else + c = '?'; } + // Index into bounding boxes table + int dd = (signed) c - ' '; + if( dd == 0 ) { // 'space' character - draw nothing, advance cursor position @@ -275,7 +269,7 @@ VECTOR2I STROKE_FONT::GetTextAsGlyphs( BOX2I* aBBox, std::vector 0.0 ) glyphExtents.x -= glyphExtents.y * tilt; cursor.x += glyphExtents.x; diff --git a/common/plotters/PDF_plotter.cpp b/common/plotters/PDF_plotter.cpp index d01ffeafe5..fb19c53368 100644 --- a/common/plotters/PDF_plotter.cpp +++ b/common/plotters/PDF_plotter.cpp @@ -261,6 +261,62 @@ void PDF_PLOTTER::Circle( const VECTOR2I& pos, int diametre, FILL_T aFill, int w } +void PDF_PLOTTER::Arc( const VECTOR2I& aCenter, const VECTOR2I& aStart, const VECTOR2I& aEnd, + FILL_T aFill, int aWidth, int aMaxError ) +{ + wxASSERT( workFile ); + + /* + * Arcs are not so easily approximated by beziers (in the general case), so we approximate + * them in the old way + */ + EDA_ANGLE startAngle( aStart - aCenter ); + EDA_ANGLE endAngle( aEnd - aCenter ); + int radius = ( aStart - aCenter ).EuclideanNorm(); + int numSegs = GetArcToSegmentCount( radius, aMaxError, FULL_CIRCLE ); + EDA_ANGLE delta = ANGLE_360 / std::max( 8, numSegs ); + VECTOR2I start( aStart ); + VECTOR2I end( aEnd ); + VECTOR2I pt; + + if( startAngle > endAngle ) + { + if( endAngle < ANGLE_0 ) + endAngle.Normalize(); + else + startAngle = startAngle.Normalize() - ANGLE_360; + } + + SetCurrentLineWidth( aWidth ); + VECTOR2D pos_dev = userToDeviceCoordinates( start ); + fprintf( workFile, "%g %g m ", pos_dev.x, pos_dev.y ); + + for( EDA_ANGLE ii = delta; startAngle + ii < endAngle; ii += delta ) + { + pt = start; + RotatePoint( pt, aCenter, -ii ); + + pos_dev = userToDeviceCoordinates( pt ); + fprintf( workFile, "%g %g l ", pos_dev.x, pos_dev.y ); + } + + pos_dev = userToDeviceCoordinates( end ); + fprintf( workFile, "%g %g l ", pos_dev.x, pos_dev.y ); + + // The arc is drawn... if not filled we stroke it, otherwise we finish + // closing the pie at the center + if( aFill == FILL_T::NO_FILL ) + { + fputs( "S\n", workFile ); + } + else + { + pos_dev = userToDeviceCoordinates( aCenter ); + fprintf( workFile, "%g %g l b\n", pos_dev.x, pos_dev.y ); + } +} + + void PDF_PLOTTER::Arc( const VECTOR2I& aCenter, const EDA_ANGLE& aStartAngle, const EDA_ANGLE& aEndAngle, int aRadius, FILL_T aFill, int aWidth ) { @@ -282,6 +338,9 @@ void PDF_PLOTTER::Arc( const VECTOR2I& aCenter, const EDA_ANGLE& aStartAngle, VECTOR2I end; const EDA_ANGLE delta( 5, DEGREES_T ); // increment to draw circles + startAngle = ANGLE_180 - startAngle; + endAngle = ANGLE_180 - endAngle; + if( startAngle > endAngle ) std::swap( startAngle, endAngle ); diff --git a/common/plotters/PS_plotter.cpp b/common/plotters/PS_plotter.cpp index 16efb609e9..b4d95bcdd5 100644 --- a/common/plotters/PS_plotter.cpp +++ b/common/plotters/PS_plotter.cpp @@ -587,48 +587,40 @@ void PS_PLOTTER::Circle( const VECTOR2I& pos, int diametre, FILL_T fill, int wid } -void PS_PLOTTER::Arc( const VECTOR2I& aCenter, const EDA_ANGLE& aStartAngle, - const EDA_ANGLE& aEndAngle, int aRadius, FILL_T aFill, int aWidth ) +VECTOR2D mapCoords( const VECTOR2D& aSource ) { - wxASSERT( m_outputFile ); - - if( aRadius <= 0 ) - return; - - EDA_ANGLE startAngle( aStartAngle ); - EDA_ANGLE endAngle( aEndAngle ); - - if( startAngle > endAngle ) - std::swap( startAngle, endAngle ); - - SetCurrentLineWidth( aWidth ); - - // Calculate start point. - VECTOR2D centre_dev = userToDeviceCoordinates( aCenter ); - double radius_dev = userToDeviceSize( aRadius ); - - if( m_plotMirror ) - { - if( m_mirrorIsHorizontal ) - { - startAngle = ANGLE_180 - startAngle; - endAngle = ANGLE_180 - endAngle; - std::swap( startAngle, endAngle ); - } - else - { - startAngle = -startAngle; - endAngle = -endAngle; - } - } - - fprintf( m_outputFile, "%g %g %g %g %g arc%d\n", centre_dev.x, centre_dev.y, - radius_dev, startAngle.AsDegrees(), endAngle.AsDegrees(), getFillId( aFill ) ); + return VECTOR2D( aSource.x, aSource.y ); } -void PS_PLOTTER::PlotPoly( const std::vector& aCornerList, FILL_T aFill, - int aWidth, void * aData ) +void PS_PLOTTER::Arc( const VECTOR2I& aCenter, const VECTOR2I& aStart, const VECTOR2I& aEnd, + FILL_T aFill, int aWidth, int aMaxError ) +{ + wxASSERT( m_outputFile ); + + VECTOR2D center_device = userToDeviceCoordinates( aCenter ); + VECTOR2D start_device = userToDeviceCoordinates( aStart ); + VECTOR2D end_device = userToDeviceCoordinates( aEnd ); + double radius_device = ( start_device - center_device ).EuclideanNorm(); + EDA_ANGLE startAngle( mapCoords( start_device - center_device ) ); + EDA_ANGLE endAngle( mapCoords( end_device - center_device ) ); + + // userToDeviceCoordinates gets our start/ends out of order + std::swap( startAngle, endAngle ); + + SetCurrentLineWidth( aWidth ); + + fprintf( m_outputFile, "%g %g %g %g %g arc%d\n", + center_device.x, + center_device.y, + radius_device, + startAngle.AsDegrees(), + endAngle.AsDegrees(), + getFillId( aFill ) ); +} + +void PS_PLOTTER::PlotPoly( const std::vector& aCornerList, FILL_T aFill, int aWidth, + void* aData ) { if( aCornerList.size() <= 1 ) return; diff --git a/common/plotters/plotter.cpp b/common/plotters/plotter.cpp index dfbf415439..3ff5ad8a36 100644 --- a/common/plotters/plotter.cpp +++ b/common/plotters/plotter.cpp @@ -45,7 +45,6 @@ #include #include // for KiROUND - PLOTTER::PLOTTER( ) { m_plotScale = 1; @@ -154,6 +153,49 @@ double PLOTTER::GetDashGapLenIU() const } +void PLOTTER::Arc( const VECTOR2I& aCenter, const VECTOR2I& aStart, const VECTOR2I& aEnd, + FILL_T aFill, int aWidth, int aMaxError ) +{ + EDA_ANGLE startAngle( aStart - aCenter ); + EDA_ANGLE endAngle( aEnd - aCenter ); + int radius = ( aStart - aCenter ).EuclideanNorm(); + int numSegs = GetArcToSegmentCount( radius, aMaxError, FULL_CIRCLE ); + EDA_ANGLE delta = ANGLE_360 / std::max( 8, numSegs ); + VECTOR2I start( aStart ); + VECTOR2I end( aEnd ); + VECTOR2I pt; + + if( startAngle > endAngle ) + { + if( endAngle < ANGLE_0 ) + endAngle.Normalize(); + else + startAngle = startAngle.Normalize() - ANGLE_360; + } + + SetCurrentLineWidth( aWidth ); + MoveTo( start ); + + for( EDA_ANGLE ii = delta; startAngle + ii < endAngle; ii += delta ) + { + pt = start; + RotatePoint( pt, aCenter, -ii ); + + LineTo( pt ); + } + + if( aFill == FILL_T::NO_FILL ) + { + FinishTo( end ); + } + else + { + LineTo( end ); + FinishTo( aCenter ); + } +} + + void PLOTTER::Arc( const VECTOR2I& aCenter, const EDA_ANGLE& aStartAngle, const EDA_ANGLE& aEndAngle, int aRadius, FILL_T aFill, int aWidth ) { diff --git a/common/string_utils.cpp b/common/string_utils.cpp index 694f367a57..c06c4e743b 100644 --- a/common/string_utils.cpp +++ b/common/string_utils.cpp @@ -1025,15 +1025,14 @@ void wxStringSplit( const wxString& aText, wxArrayString& aStrings, wxChar aSpli aStrings.Add( tmp ); tmp.Clear(); } - else + { tmp << aText[ii]; + } } if( !tmp.IsEmpty() ) - { aStrings.Add( tmp ); - } } diff --git a/eeschema/CMakeLists.txt b/eeschema/CMakeLists.txt index 3f666f337a..9cb66aed5c 100644 --- a/eeschema/CMakeLists.txt +++ b/eeschema/CMakeLists.txt @@ -58,6 +58,7 @@ set( EESCHEMA_DLGS dialogs/dialog_edit_symbols_libid.cpp dialogs/dialog_edit_symbols_libid_base.cpp dialogs/dialog_field_properties.cpp + dialogs/dialog_field_properties_base.cpp dialogs/dialog_eeschema_page_settings.cpp dialogs/dialog_erc.cpp dialogs/dialog_erc_base.cpp @@ -72,6 +73,8 @@ set( EESCHEMA_DLGS dialogs/dialog_lib_edit_pin_table_base.cpp dialogs/dialog_lib_text_properties.cpp dialogs/dialog_lib_text_properties_base.cpp + dialogs/dialog_lib_textbox_properties.cpp + dialogs/dialog_lib_textbox_properties_base.cpp dialogs/dialog_lib_new_symbol.cpp dialogs/dialog_lib_new_symbol_base.cpp dialogs/dialog_lib_shape_properties.cpp @@ -187,6 +190,7 @@ set( EESCHEMA_SRCS lib_pin.cpp lib_symbol.cpp lib_text.cpp + lib_textbox.cpp libarch.cpp menubar.cpp pin_numbers.cpp @@ -216,6 +220,7 @@ set( EESCHEMA_SRCS sch_sheet_pin.cpp sch_symbol.cpp sch_text.cpp + sch_textbox.cpp sch_validators.cpp schematic.cpp schematic_settings.cpp diff --git a/eeschema/dialogs/dialog_field_properties.cpp b/eeschema/dialogs/dialog_field_properties.cpp index d846b54b06..e3759d1702 100644 --- a/eeschema/dialogs/dialog_field_properties.cpp +++ b/eeschema/dialogs/dialog_field_properties.cpp @@ -46,7 +46,7 @@ DIALOG_FIELD_PROPERTIES::DIALOG_FIELD_PROPERTIES( SCH_BASE_FRAME* aParent, const wxString& aTitle, const EDA_TEXT* aTextItem ) : - DIALOG_LIB_TEXT_PROPERTIES_BASE( aParent ), + DIALOG_FIELD_PROPERTIES_BASE( aParent ), m_posX( aParent, m_xPosLabel, m_xPosCtrl, m_xPosUnits, true ), m_posY( aParent, m_yPosLabel, m_yPosCtrl, m_yPosUnits, true ), m_textSize( aParent, m_textSizeLabel, m_textSizeCtrl, m_textSizeUnits, true ), diff --git a/eeschema/dialogs/dialog_field_properties.h b/eeschema/dialogs/dialog_field_properties.h index 3eaa666d40..83a96596f2 100644 --- a/eeschema/dialogs/dialog_field_properties.h +++ b/eeschema/dialogs/dialog_field_properties.h @@ -1,13 +1,9 @@ - -#ifndef DIALOG_EDIT_ONE_FIELD_H_ -#define DIALOG_EDIT_ONE_FIELD_H_ - /* * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2012 Jean-Pierre Charras, jean-pierre.charras@gipsa-lab.inpg.com * Copyright (C) 2016 Wayne Stambaugh, stambaughw@gmail.com - * Copyright (C) 2004-2021 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2004-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 @@ -27,7 +23,10 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -#include +#ifndef DIALOG_FIELD_PROPERTIES_H +#define DIALOG_FIELD_PROPERTIES_H + +#include #include #include #include @@ -44,7 +43,7 @@ class SCINTILLA_TRICKS; * This class is setup in expectation of its children possibly using Kiway player so * #DIALOG_SHIM::ShowQuasiModal is required when calling any subclasses. */ -class DIALOG_FIELD_PROPERTIES : public DIALOG_LIB_TEXT_PROPERTIES_BASE +class DIALOG_FIELD_PROPERTIES : public DIALOG_FIELD_PROPERTIES_BASE { public: DIALOG_FIELD_PROPERTIES( SCH_BASE_FRAME* aParent, const wxString& aTitle, @@ -147,4 +146,4 @@ private: bool m_isSheetFilename; }; -#endif // DIALOG_EDIT_ONE_FIELD_H_ +#endif // DIALOG_FIELD_PROPERTIES_H diff --git a/eeschema/dialogs/dialog_field_properties_base.cpp b/eeschema/dialogs/dialog_field_properties_base.cpp new file mode 100644 index 0000000000..df0437c741 --- /dev/null +++ b/eeschema/dialogs/dialog_field_properties_base.cpp @@ -0,0 +1,296 @@ +/////////////////////////////////////////////////////////////////////////// +// C++ code generated with wxFormBuilder (version Oct 26 2018) +// http://www.wxformbuilder.org/ +// +// PLEASE DO *NOT* EDIT THIS FILE! +/////////////////////////////////////////////////////////////////////////// + +#include "widgets/bitmap_button.h" +#include "widgets/font_choice.h" + +#include "dialog_field_properties_base.h" + +/////////////////////////////////////////////////////////////////////////// + +DIALOG_FIELD_PROPERTIES_BASE::DIALOG_FIELD_PROPERTIES_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : DIALOG_SHIM( parent, id, title, pos, size, style ) +{ + this->SetSizeHints( wxDefaultSize, wxDefaultSize ); + + wxBoxSizer* bMainSizer; + bMainSizer = new wxBoxSizer( wxVERTICAL ); + + wxBoxSizer* bPropertiesSizer; + bPropertiesSizer = new wxBoxSizer( wxVERTICAL ); + + wxBoxSizer* bUpperBoxSizer; + bUpperBoxSizer = new wxBoxSizer( wxVERTICAL ); + + wxBoxSizer* bTextValueBoxSizer; + bTextValueBoxSizer = new wxBoxSizer( wxHORIZONTAL ); + + m_textLabel = new wxStaticText( this, wxID_ANY, _("Text:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_textLabel->Wrap( -1 ); + bTextValueBoxSizer->Add( m_textLabel, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 ); + + m_TextCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + bTextValueBoxSizer->Add( m_TextCtrl, 1, wxALIGN_CENTER_VERTICAL|wxLEFT, 5 ); + + m_StyledTextCtrl = new wxStyledTextCtrl( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxBORDER_SUNKEN, wxEmptyString ); + m_StyledTextCtrl->SetUseTabs( true ); + m_StyledTextCtrl->SetTabWidth( 4 ); + m_StyledTextCtrl->SetIndent( 4 ); + m_StyledTextCtrl->SetTabIndents( false ); + m_StyledTextCtrl->SetBackSpaceUnIndents( false ); + m_StyledTextCtrl->SetViewEOL( false ); + m_StyledTextCtrl->SetViewWhiteSpace( false ); + m_StyledTextCtrl->SetMarginWidth( 2, 0 ); + m_StyledTextCtrl->SetIndentationGuides( false ); + m_StyledTextCtrl->SetMarginWidth( 1, 0 ); + m_StyledTextCtrl->SetMarginWidth( 0, 0 ); + m_StyledTextCtrl->MarkerDefine( wxSTC_MARKNUM_FOLDER, wxSTC_MARK_BOXPLUS ); + m_StyledTextCtrl->MarkerSetBackground( wxSTC_MARKNUM_FOLDER, wxColour( wxT("BLACK") ) ); + m_StyledTextCtrl->MarkerSetForeground( wxSTC_MARKNUM_FOLDER, wxColour( wxT("WHITE") ) ); + m_StyledTextCtrl->MarkerDefine( wxSTC_MARKNUM_FOLDEROPEN, wxSTC_MARK_BOXMINUS ); + m_StyledTextCtrl->MarkerSetBackground( wxSTC_MARKNUM_FOLDEROPEN, wxColour( wxT("BLACK") ) ); + m_StyledTextCtrl->MarkerSetForeground( wxSTC_MARKNUM_FOLDEROPEN, wxColour( wxT("WHITE") ) ); + m_StyledTextCtrl->MarkerDefine( wxSTC_MARKNUM_FOLDERSUB, wxSTC_MARK_EMPTY ); + m_StyledTextCtrl->MarkerDefine( wxSTC_MARKNUM_FOLDEREND, wxSTC_MARK_BOXPLUS ); + m_StyledTextCtrl->MarkerSetBackground( wxSTC_MARKNUM_FOLDEREND, wxColour( wxT("BLACK") ) ); + m_StyledTextCtrl->MarkerSetForeground( wxSTC_MARKNUM_FOLDEREND, wxColour( wxT("WHITE") ) ); + m_StyledTextCtrl->MarkerDefine( wxSTC_MARKNUM_FOLDEROPENMID, wxSTC_MARK_BOXMINUS ); + m_StyledTextCtrl->MarkerSetBackground( wxSTC_MARKNUM_FOLDEROPENMID, wxColour( wxT("BLACK") ) ); + m_StyledTextCtrl->MarkerSetForeground( wxSTC_MARKNUM_FOLDEROPENMID, wxColour( wxT("WHITE") ) ); + m_StyledTextCtrl->MarkerDefine( wxSTC_MARKNUM_FOLDERMIDTAIL, wxSTC_MARK_EMPTY ); + m_StyledTextCtrl->MarkerDefine( wxSTC_MARKNUM_FOLDERTAIL, wxSTC_MARK_EMPTY ); + m_StyledTextCtrl->SetSelBackground( true, wxSystemSettings::GetColour( wxSYS_COLOUR_HIGHLIGHT ) ); + m_StyledTextCtrl->SetSelForeground( true, wxSystemSettings::GetColour( wxSYS_COLOUR_HIGHLIGHTTEXT ) ); + bTextValueBoxSizer->Add( m_StyledTextCtrl, 1, wxRIGHT|wxLEFT, 5 ); + + m_TextValueSelectButton = new wxBitmapButton( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW|0 ); + bTextValueBoxSizer->Add( m_TextValueSelectButton, 0, wxALIGN_CENTER_VERTICAL, 5 ); + + + bUpperBoxSizer->Add( bTextValueBoxSizer, 1, wxEXPAND|wxTOP|wxBOTTOM|wxRIGHT, 5 ); + + m_note = new wxStaticText( this, wxID_ANY, _("(%s)"), wxDefaultPosition, wxDefaultSize, 0 ); + m_note->Wrap( -1 ); + bUpperBoxSizer->Add( m_note, 0, wxBOTTOM|wxRIGHT|wxLEFT, 10 ); + + + bPropertiesSizer->Add( bUpperBoxSizer, 0, wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 ); + + wxBoxSizer* bSizer9; + bSizer9 = new wxBoxSizer( wxVERTICAL ); + + m_visible = new wxCheckBox( this, wxID_ANY, _("Visible"), wxDefaultPosition, wxDefaultSize, 0 ); + bSizer9->Add( m_visible, 0, wxALIGN_LEFT|wxBOTTOM, 2 ); + + + bPropertiesSizer->Add( bSizer9, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 10 ); + + wxGridBagSizer* gbSizer1; + gbSizer1 = new wxGridBagSizer( 3, 0 ); + gbSizer1->SetFlexibleDirection( wxBOTH ); + gbSizer1->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); + gbSizer1->SetEmptyCellSize( wxSize( -1,10 ) ); + + m_fontLabel = new wxStaticText( this, wxID_ANY, _("Font:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_fontLabel->Wrap( -1 ); + gbSizer1->Add( m_fontLabel, wxGBPosition( 0, 0 ), wxGBSpan( 1, 1 ), wxALL, 5 ); + + wxString m_fontCtrlChoices[] = { _("Default Font"), _("KiCad Font") }; + int m_fontCtrlNChoices = sizeof( m_fontCtrlChoices ) / sizeof( wxString ); + m_fontCtrl = new FONT_CHOICE( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_fontCtrlNChoices, m_fontCtrlChoices, 0 ); + m_fontCtrl->SetSelection( 0 ); + gbSizer1->Add( m_fontCtrl, wxGBPosition( 0, 1 ), wxGBSpan( 1, 2 ), wxEXPAND, 5 ); + + wxBoxSizer* formattingSizer; + formattingSizer = new wxBoxSizer( wxHORIZONTAL ); + + m_separator1 = new BITMAP_BUTTON( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 21,21 ), wxBU_AUTODRAW|wxBORDER_NONE ); + m_separator1->Enable( false ); + + formattingSizer->Add( m_separator1, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 5 ); + + m_horizontal = new BITMAP_BUTTON( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 21,21 ), wxBU_AUTODRAW|wxBORDER_NONE ); + m_horizontal->SetToolTip( _("Horizontal text") ); + + formattingSizer->Add( m_horizontal, 0, wxALIGN_CENTER_VERTICAL, 5 ); + + m_vertical = new BITMAP_BUTTON( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 21,21 ), wxBU_AUTODRAW|wxBORDER_NONE ); + m_vertical->SetToolTip( _("Vertical text") ); + + formattingSizer->Add( m_vertical, 0, wxALIGN_CENTER_VERTICAL, 5 ); + + m_separator2 = new BITMAP_BUTTON( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 21,21 ), wxBU_AUTODRAW|wxBORDER_NONE ); + m_separator2->Enable( false ); + + formattingSizer->Add( m_separator2, 0, wxALIGN_CENTER_VERTICAL, 5 ); + + m_bold = new BITMAP_BUTTON( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 21,21 ), wxBU_AUTODRAW|wxBORDER_NONE ); + m_bold->SetToolTip( _("Bold") ); + + formattingSizer->Add( m_bold, 0, wxALIGN_CENTER_VERTICAL, 5 ); + + m_italic = new BITMAP_BUTTON( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 21,21 ), wxBU_AUTODRAW|wxBORDER_NONE ); + m_italic->SetToolTip( _("Italic") ); + + formattingSizer->Add( m_italic, 0, wxALIGN_CENTER_VERTICAL, 5 ); + + m_separator3 = new BITMAP_BUTTON( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 21,21 ), wxBU_AUTODRAW|wxBORDER_NONE ); + m_separator3->Enable( false ); + + formattingSizer->Add( m_separator3, 0, wxALIGN_CENTER_VERTICAL, 5 ); + + m_hAlignLeft = new BITMAP_BUTTON( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 21,21 ), wxBU_AUTODRAW|wxBORDER_NONE ); + m_hAlignLeft->SetToolTip( _("Align left") ); + + formattingSizer->Add( m_hAlignLeft, 0, wxALIGN_CENTER_VERTICAL, 5 ); + + m_hAlignCenter = new BITMAP_BUTTON( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 21,21 ), wxBU_AUTODRAW|wxBORDER_NONE ); + m_hAlignCenter->SetToolTip( _("Align horizontal center") ); + + formattingSizer->Add( m_hAlignCenter, 0, wxALIGN_CENTER_VERTICAL, 5 ); + + m_hAlignRight = new BITMAP_BUTTON( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 21,21 ), wxBU_AUTODRAW|wxBORDER_NONE ); + m_hAlignRight->SetToolTip( _("Align right") ); + + formattingSizer->Add( m_hAlignRight, 0, wxALIGN_CENTER_VERTICAL, 5 ); + + m_separator4 = new BITMAP_BUTTON( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 21,21 ), wxBU_AUTODRAW|wxBORDER_NONE ); + m_separator4->Enable( false ); + + formattingSizer->Add( m_separator4, 0, wxALIGN_CENTER_VERTICAL, 5 ); + + m_vAlignTop = new BITMAP_BUTTON( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 21,21 ), wxBU_AUTODRAW|wxBORDER_NONE ); + m_vAlignTop->SetToolTip( _("Align top") ); + + formattingSizer->Add( m_vAlignTop, 0, wxALIGN_CENTER_VERTICAL, 5 ); + + m_vAlignCenter = new BITMAP_BUTTON( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 21,21 ), wxBU_AUTODRAW|wxBORDER_NONE ); + m_vAlignCenter->SetToolTip( _("Align vertical center") ); + + formattingSizer->Add( m_vAlignCenter, 0, wxALIGN_CENTER_VERTICAL, 5 ); + + m_vAlignBottom = new BITMAP_BUTTON( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 21,21 ), wxBU_AUTODRAW|wxBORDER_NONE ); + m_vAlignBottom->SetToolTip( _("Align bottom") ); + + formattingSizer->Add( m_vAlignBottom, 0, wxALIGN_CENTER_VERTICAL, 5 ); + + m_separator5 = new BITMAP_BUTTON( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 21,21 ), wxBU_AUTODRAW|wxBORDER_NONE ); + m_separator5->Enable( false ); + + formattingSizer->Add( m_separator5, 0, wxALIGN_CENTER_VERTICAL, 5 ); + + + gbSizer1->Add( formattingSizer, wxGBPosition( 0, 3 ), wxGBSpan( 1, 2 ), wxEXPAND, 5 ); + + m_textSizeLabel = new wxStaticText( this, wxID_ANY, _("Text size:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_textSizeLabel->Wrap( -1 ); + gbSizer1->Add( m_textSizeLabel, wxGBPosition( 1, 0 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 ); + + m_textSizeCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + gbSizer1->Add( m_textSizeCtrl, wxGBPosition( 1, 1 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL, 5 ); + + m_textSizeUnits = new wxStaticText( this, wxID_ANY, _("mm"), wxDefaultPosition, wxDefaultSize, 0 ); + m_textSizeUnits->Wrap( -1 ); + gbSizer1->Add( m_textSizeUnits, wxGBPosition( 1, 2 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL|wxLEFT, 5 ); + + m_xPosLabel = new wxStaticText( this, wxID_ANY, _("Position X:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_xPosLabel->Wrap( -1 ); + gbSizer1->Add( m_xPosLabel, wxGBPosition( 3, 0 ), wxGBSpan( 1, 1 ), wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL, 5 ); + + m_xPosCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + gbSizer1->Add( m_xPosCtrl, wxGBPosition( 3, 1 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL, 5 ); + + m_xPosUnits = new wxStaticText( this, wxID_ANY, _("mm"), wxDefaultPosition, wxDefaultSize, 0 ); + m_xPosUnits->Wrap( -1 ); + gbSizer1->Add( m_xPosUnits, wxGBPosition( 3, 2 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL|wxLEFT, 5 ); + + m_yPosLabel = new wxStaticText( this, wxID_ANY, _("Position Y:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_yPosLabel->Wrap( -1 ); + gbSizer1->Add( m_yPosLabel, wxGBPosition( 4, 0 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 ); + + m_yPosCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + gbSizer1->Add( m_yPosCtrl, wxGBPosition( 4, 1 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL, 5 ); + + m_yPosUnits = new wxStaticText( this, wxID_ANY, _("mm"), wxDefaultPosition, wxDefaultSize, 0 ); + m_yPosUnits->Wrap( -1 ); + gbSizer1->Add( m_yPosUnits, wxGBPosition( 4, 2 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL|wxLEFT, 5 ); + + m_CommonUnit = new wxCheckBox( this, wxID_ANY, _("Common to all units"), wxDefaultPosition, wxDefaultSize, 0 ); + gbSizer1->Add( m_CommonUnit, wxGBPosition( 3, 4 ), wxGBSpan( 1, 1 ), wxRIGHT, 5 ); + + m_CommonConvert = new wxCheckBox( this, wxID_ANY, _("Common to all body styles"), wxDefaultPosition, wxDefaultSize, 0 ); + gbSizer1->Add( m_CommonConvert, wxGBPosition( 4, 4 ), wxGBSpan( 1, 1 ), wxRIGHT, 5 ); + + + bPropertiesSizer->Add( gbSizer1, 1, wxEXPAND|wxRIGHT|wxLEFT, 5 ); + + wxFlexGridSizer* fgSizer3; + fgSizer3 = new wxFlexGridSizer( 5, 4, 3, 3 ); + fgSizer3->SetFlexibleDirection( wxBOTH ); + fgSizer3->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); + + + fgSizer3->Add( 0, 0, 1, wxEXPAND, 5 ); + + + fgSizer3->Add( 0, 0, 1, wxEXPAND, 5 ); + + + fgSizer3->Add( 0, 0, 1, wxEXPAND, 5 ); + + + fgSizer3->Add( 0, 0, 1, wxEXPAND, 5 ); + + + fgSizer3->Add( 0, 0, 1, wxEXPAND, 5 ); + + + bPropertiesSizer->Add( fgSizer3, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); + + wxBoxSizer* bBottomtBoxSizer; + bBottomtBoxSizer = new wxBoxSizer( wxVERTICAL ); + + + bPropertiesSizer->Add( bBottomtBoxSizer, 0, wxEXPAND|wxTOP|wxLEFT, 5 ); + + + bMainSizer->Add( bPropertiesSizer, 1, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 ); + + m_staticline2 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ); + bMainSizer->Add( m_staticline2, 0, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 10 ); + + m_sdbSizerButtons = new wxStdDialogButtonSizer(); + m_sdbSizerButtonsOK = new wxButton( this, wxID_OK ); + m_sdbSizerButtons->AddButton( m_sdbSizerButtonsOK ); + m_sdbSizerButtonsCancel = new wxButton( this, wxID_CANCEL ); + m_sdbSizerButtons->AddButton( m_sdbSizerButtonsCancel ); + m_sdbSizerButtons->Realize(); + + bMainSizer->Add( m_sdbSizerButtons, 0, wxEXPAND|wxALL, 5 ); + + + this->SetSizer( bMainSizer ); + this->Layout(); + bMainSizer->Fit( this ); + + // Connect Events + this->Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_FIELD_PROPERTIES_BASE::OnCloseDialog ) ); + m_TextCtrl->Connect( wxEVT_SET_FOCUS, wxFocusEventHandler( DIALOG_FIELD_PROPERTIES_BASE::OnSetFocusText ), NULL, this ); + m_StyledTextCtrl->Connect( wxEVT_KILL_FOCUS, wxFocusEventHandler( DIALOG_FIELD_PROPERTIES_BASE::onMultiLineTCLostFocus ), NULL, this ); + m_StyledTextCtrl->Connect( wxEVT_SET_FOCUS, wxFocusEventHandler( DIALOG_FIELD_PROPERTIES_BASE::OnSetFocusText ), NULL, this ); + m_TextValueSelectButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FIELD_PROPERTIES_BASE::OnTextValueSelectButtonClick ), NULL, this ); +} + +DIALOG_FIELD_PROPERTIES_BASE::~DIALOG_FIELD_PROPERTIES_BASE() +{ + // Disconnect Events + this->Disconnect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_FIELD_PROPERTIES_BASE::OnCloseDialog ) ); + m_TextCtrl->Disconnect( wxEVT_SET_FOCUS, wxFocusEventHandler( DIALOG_FIELD_PROPERTIES_BASE::OnSetFocusText ), NULL, this ); + m_StyledTextCtrl->Disconnect( wxEVT_KILL_FOCUS, wxFocusEventHandler( DIALOG_FIELD_PROPERTIES_BASE::onMultiLineTCLostFocus ), NULL, this ); + m_StyledTextCtrl->Disconnect( wxEVT_SET_FOCUS, wxFocusEventHandler( DIALOG_FIELD_PROPERTIES_BASE::OnSetFocusText ), NULL, this ); + m_TextValueSelectButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FIELD_PROPERTIES_BASE::OnTextValueSelectButtonClick ), NULL, this ); + +} diff --git a/eeschema/dialogs/dialog_field_properties_base.fbp b/eeschema/dialogs/dialog_field_properties_base.fbp new file mode 100644 index 0000000000..d2f1eec390 --- /dev/null +++ b/eeschema/dialogs/dialog_field_properties_base.fbp @@ -0,0 +1,2617 @@ + + + + + + C++ + 1 + source_name + 0 + 0 + res + UTF-8 + connect + dialog_field_properties_base + 1000 + none + + 1 + DIALOG_FIELD_PROPERTIES_BASE + + . + + 1 + 1 + 1 + 1 + UI + 1 + 0 + + 0 + wxAUI_MGR_DEFAULT + + + + 1 + 1 + impl_virtual + + + + 0 + wxID_ANY + + + DIALOG_FIELD_PROPERTIES_BASE + + -1,-1 + wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER + DIALOG_SHIM; dialog_shim.h + Text Item Properties + + + + + OnCloseDialog + + + bMainSizer + wxVERTICAL + none + + 5 + wxEXPAND|wxTOP|wxRIGHT|wxLEFT + 1 + + + bPropertiesSizer + wxVERTICAL + none + + 5 + wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND + 0 + + + bUpperBoxSizer + wxVERTICAL + none + + 5 + wxEXPAND|wxTOP|wxBOTTOM|wxRIGHT + 1 + + + bTextValueBoxSizer + wxHORIZONTAL + none + + 5 + wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Text: + 0 + + 0 + + + 0 + + 1 + m_textLabel + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + 5 + wxALIGN_CENTER_VERTICAL|wxLEFT + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + + 0 + + 1 + m_TextCtrl + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + OnSetFocusText + + + + 5 + wxRIGHT|wxLEFT + 1 + + 1 + 1 + 1 + 1 + + + + + 0 + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + 0 + + 0 + 0 + wxID_ANY + 0 + 0 + + 0 + + + 0 + + 1 + m_StyledTextCtrl + 1 + + + protected + 1 + + Resizable + 1 + + ; ; forward_declare + 0 + 4 + 0 + + 1 + 0 + 0 + + + wxBORDER_SUNKEN + onMultiLineTCLostFocus + OnSetFocusText + + + + 5 + wxALIGN_CENTER_VERTICAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + + 1 + 0 + 1 + + 1 + + 0 + 0 + + Dock + 0 + Left + 1 + + 1 + + + 0 + 0 + wxID_ANY + Select... + + 0 + + 0 + + + 0 + + 1 + m_TextValueSelectButton + 1 + + + protected + 1 + + + + Resizable + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + OnTextValueSelectButtonClick + + + + + + 10 + wxBOTTOM|wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + (%s) + 0 + + 0 + + + 0 + + 1 + m_note + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + + + -1 + + + + + + 10 + wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT + 0 + + + bSizer9 + wxVERTICAL + none + + 2 + wxALIGN_LEFT|wxBOTTOM + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Visible + + 0 + + + 0 + + 1 + m_visible + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + 5 + wxEXPAND|wxRIGHT|wxLEFT + 1 + + -1,10 + wxBOTH + + + 0 + + gbSizer1 + wxFLEX_GROWMODE_SPECIFIED + none + 3 + + 5 + 1 + 0 + wxALL + 0 + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Font: + 0 + + 0 + + + 0 + + 1 + m_fontLabel + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + + + -1 + + + + 5 + 2 + 1 + wxEXPAND + 0 + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + "Default Font" "KiCad Font" + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + + 1 + m_fontCtrl + 1 + + + protected + 1 + + Resizable + 0 + 1 + + + FONT_CHOICE; widgets/font_choice.h; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + 5 + 2 + 3 + wxEXPAND + 0 + 1 + + + formattingSizer + wxHORIZONTAL + none + + 5 + wxALIGN_CENTER_VERTICAL|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + + 1 + 0 + 1 + + 1 + + 0 + 0 + + Dock + 0 + Left + 0 + + 1 + + + 0 + 0 + wxID_ANY + + + 0 + + 0 + -1,-1 + + 0 + + 1 + m_separator1 + 1 + + + protected + 1 + + + + Resizable + 1 + 21,21 + wxBORDER_NONE + BITMAP_BUTTON; widgets/bitmap_button.h; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + 5 + wxALIGN_CENTER_VERTICAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + + 1 + 0 + 1 + + 1 + + 0 + 0 + + Dock + 0 + Left + 1 + + 1 + + + 0 + 0 + wxID_ANY + Horizontal text + + 0 + + 0 + -1,-1 + + 0 + + 1 + m_horizontal + 1 + + + protected + 1 + + + + Resizable + 1 + 21,21 + wxBORDER_NONE + BITMAP_BUTTON; widgets/bitmap_button.h; forward_declare + 0 + Horizontal text + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + 5 + wxALIGN_CENTER_VERTICAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + + 1 + 0 + 1 + + 1 + + 0 + 0 + + Dock + 0 + Left + 1 + + 1 + + + 0 + 0 + wxID_ANY + Vertical text + + 0 + + 0 + -1,-1 + + 0 + + 1 + m_vertical + 1 + + + protected + 1 + + + + Resizable + 1 + 21,21 + wxBORDER_NONE + BITMAP_BUTTON; widgets/bitmap_button.h; forward_declare + 0 + Vertical text + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + 5 + wxALIGN_CENTER_VERTICAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + + 1 + 0 + 1 + + 1 + + 0 + 0 + + Dock + 0 + Left + 0 + + 1 + + + 0 + 0 + wxID_ANY + + + 0 + + 0 + -1,-1 + + 0 + + 1 + m_separator2 + 1 + + + protected + 1 + + + + Resizable + 1 + 21,21 + wxBORDER_NONE + BITMAP_BUTTON; widgets/bitmap_button.h; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + 5 + wxALIGN_CENTER_VERTICAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + + 1 + 0 + 1 + + 1 + + 0 + 0 + + Dock + 0 + Left + 1 + + 1 + + + 0 + 0 + wxID_ANY + Bold + + 0 + + 0 + -1,-1 + + 0 + + 1 + m_bold + 1 + + + protected + 1 + + + + Resizable + 1 + 21,21 + wxBORDER_NONE + BITMAP_BUTTON; widgets/bitmap_button.h; forward_declare + 0 + Bold + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + 5 + wxALIGN_CENTER_VERTICAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + + 1 + 0 + 1 + + 1 + + 0 + 0 + + Dock + 0 + Left + 1 + + 1 + + + 0 + 0 + wxID_ANY + Italic + + 0 + + 0 + -1,-1 + + 0 + + 1 + m_italic + 1 + + + protected + 1 + + + + Resizable + 1 + 21,21 + wxBORDER_NONE + BITMAP_BUTTON; widgets/bitmap_button.h; forward_declare + 0 + Italic + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + 5 + wxALIGN_CENTER_VERTICAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + + 1 + 0 + 1 + + 1 + + 0 + 0 + + Dock + 0 + Left + 0 + + 1 + + + 0 + 0 + wxID_ANY + + + 0 + + 0 + -1,-1 + + 0 + + 1 + m_separator3 + 1 + + + protected + 1 + + + + Resizable + 1 + 21,21 + wxBORDER_NONE + BITMAP_BUTTON; widgets/bitmap_button.h; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + 5 + wxALIGN_CENTER_VERTICAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + + 1 + 0 + 1 + + 1 + + 0 + 0 + + Dock + 0 + Left + 1 + + 1 + + + 0 + 0 + wxID_ANY + Align left + + 0 + + 0 + -1,-1 + + 0 + + 1 + m_hAlignLeft + 1 + + + protected + 1 + + + + Resizable + 1 + 21,21 + wxBORDER_NONE + BITMAP_BUTTON; widgets/bitmap_button.h; forward_declare + 0 + Align left + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + 5 + wxALIGN_CENTER_VERTICAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + + 1 + 0 + 1 + + 1 + + 0 + 0 + + Dock + 0 + Left + 1 + + 1 + + + 0 + 0 + wxID_ANY + Align center + + 0 + + 0 + -1,-1 + + 0 + + 1 + m_hAlignCenter + 1 + + + protected + 1 + + + + Resizable + 1 + 21,21 + wxBORDER_NONE + BITMAP_BUTTON; widgets/bitmap_button.h; forward_declare + 0 + Align horizontal center + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + 5 + wxALIGN_CENTER_VERTICAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + + 1 + 0 + 1 + + 1 + + 0 + 0 + + Dock + 0 + Left + 1 + + 1 + + + 0 + 0 + wxID_ANY + Align right + + 0 + + 0 + -1,-1 + + 0 + + 1 + m_hAlignRight + 1 + + + protected + 1 + + + + Resizable + 1 + 21,21 + wxBORDER_NONE + BITMAP_BUTTON; widgets/bitmap_button.h; forward_declare + 0 + Align right + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + 5 + wxALIGN_CENTER_VERTICAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + + 1 + 0 + 1 + + 1 + + 0 + 0 + + Dock + 0 + Left + 0 + + 1 + + + 0 + 0 + wxID_ANY + + + 0 + + 0 + -1,-1 + + 0 + + 1 + m_separator4 + 1 + + + protected + 1 + + + + Resizable + 1 + 21,21 + wxBORDER_NONE + BITMAP_BUTTON; widgets/bitmap_button.h; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + 5 + wxALIGN_CENTER_VERTICAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + + 1 + 0 + 1 + + 1 + + 0 + 0 + + Dock + 0 + Left + 1 + + 1 + + + 0 + 0 + wxID_ANY + Align top + + 0 + + 0 + -1,-1 + + 0 + + 1 + m_vAlignTop + 1 + + + protected + 1 + + + + Resizable + 1 + 21,21 + wxBORDER_NONE + BITMAP_BUTTON; widgets/bitmap_button.h; forward_declare + 0 + Align top + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + 5 + wxALIGN_CENTER_VERTICAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + + 1 + 0 + 1 + + 1 + + 0 + 0 + + Dock + 0 + Left + 1 + + 1 + + + 0 + 0 + wxID_ANY + Align vertical center + + 0 + + 0 + -1,-1 + + 0 + + 1 + m_vAlignCenter + 1 + + + protected + 1 + + + + Resizable + 1 + 21,21 + wxBORDER_NONE + BITMAP_BUTTON; widgets/bitmap_button.h; forward_declare + 0 + Align vertical center + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + 5 + wxALIGN_CENTER_VERTICAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + + 1 + 0 + 1 + + 1 + + 0 + 0 + + Dock + 0 + Left + 1 + + 1 + + + 0 + 0 + wxID_ANY + Align bottom + + 0 + + 0 + -1,-1 + + 0 + + 1 + m_vAlignBottom + 1 + + + protected + 1 + + + + Resizable + 1 + 21,21 + wxBORDER_NONE + BITMAP_BUTTON; widgets/bitmap_button.h; forward_declare + 0 + Align bottom + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + 5 + wxALIGN_CENTER_VERTICAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + + 1 + 0 + 1 + + 1 + + 0 + 0 + + Dock + 0 + Left + 0 + + 1 + + + 0 + 0 + wxID_ANY + + + 0 + + 0 + -1,-1 + + 0 + + 1 + m_separator5 + 1 + + + protected + 1 + + + + Resizable + 1 + 21,21 + wxBORDER_NONE + BITMAP_BUTTON; widgets/bitmap_button.h; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + 5 + 1 + 0 + wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT + 1 + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Text size: + 0 + + 0 + + + 0 + + 1 + m_textSizeLabel + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + 5 + 1 + 1 + wxALIGN_CENTER_VERTICAL + 1 + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + 0 + + 0 + + 1 + m_textSizeCtrl + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + 5 + 1 + 2 + wxALIGN_CENTER_VERTICAL|wxLEFT + 1 + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + mm + 0 + + 0 + + + 0 + + 1 + m_textSizeUnits + 1 + + + protected + 1 + + Resizable + 1 + + + ; forward_declare + 0 + + + + + -1 + + + + 5 + 1 + 0 + wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL + 3 + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Position X: + 0 + + 0 + + + 0 + + 1 + m_xPosLabel + 1 + + + protected + 1 + + Resizable + 1 + + + ; forward_declare + 0 + + + + + -1 + + + + 5 + 1 + 1 + wxALIGN_CENTER_VERTICAL + 3 + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + + 0 + + 1 + m_xPosCtrl + 1 + + + protected + 1 + + Resizable + 1 + + + ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + 5 + 1 + 2 + wxALIGN_CENTER_VERTICAL|wxLEFT + 3 + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + mm + 0 + + 0 + + + 0 + + 1 + m_xPosUnits + 1 + + + protected + 1 + + Resizable + 1 + + + ; forward_declare + 0 + + + + + -1 + + + + 5 + 1 + 0 + wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT + 4 + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Position Y: + 0 + + 0 + + + 0 + + 1 + m_yPosLabel + 1 + + + protected + 1 + + Resizable + 1 + + + ; forward_declare + 0 + + + + + -1 + + + + 5 + 1 + 1 + wxALIGN_CENTER_VERTICAL + 4 + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + + 0 + + 1 + m_yPosCtrl + 1 + + + protected + 1 + + Resizable + 1 + + + ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + 5 + 1 + 2 + wxALIGN_CENTER_VERTICAL|wxLEFT + 4 + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + mm + 0 + + 0 + + + 0 + + 1 + m_yPosUnits + 1 + + + protected + 1 + + Resizable + 1 + + + ; forward_declare + 0 + + + + + -1 + + + + 5 + 1 + 4 + wxRIGHT + 3 + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Common to all units + + 0 + + + 0 + + 1 + m_CommonUnit + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + 5 + 1 + 4 + wxRIGHT + 4 + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Common to all body styles + + 0 + + + 0 + + 1 + m_CommonConvert + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + 5 + wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT + 0 + + 4 + wxBOTH + + + 3 + -1,-1 + fgSizer3 + wxFLEX_GROWMODE_SPECIFIED + none + 5 + 3 + + 5 + wxEXPAND + 1 + + 0 + protected + 0 + + + + 5 + wxEXPAND + 1 + + 0 + protected + 0 + + + + 5 + wxEXPAND + 1 + + 0 + protected + 0 + + + + 5 + wxEXPAND + 1 + + 0 + protected + 0 + + + + 5 + wxEXPAND + 1 + + 0 + protected + 0 + + + + + + 5 + wxEXPAND|wxTOP|wxLEFT + 0 + + + bBottomtBoxSizer + wxVERTICAL + none + + + + + + 10 + wxEXPAND|wxTOP|wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + + 1 + m_staticline2 + 1 + + + protected + 1 + + Resizable + 1 + + wxLI_HORIZONTAL + ; forward_declare + 0 + + + + + + + + 5 + wxEXPAND|wxALL + 0 + + 0 + 1 + 0 + 0 + 0 + 1 + 0 + 0 + + m_sdbSizerButtons + protected + + + + + + diff --git a/eeschema/dialogs/dialog_field_properties_base.h b/eeschema/dialogs/dialog_field_properties_base.h new file mode 100644 index 0000000000..15428eea3c --- /dev/null +++ b/eeschema/dialogs/dialog_field_properties_base.h @@ -0,0 +1,99 @@ +/////////////////////////////////////////////////////////////////////////// +// C++ code generated with wxFormBuilder (version Oct 26 2018) +// http://www.wxformbuilder.org/ +// +// PLEASE DO *NOT* EDIT THIS FILE! +/////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include +#include +#include +class BITMAP_BUTTON; +class FONT_CHOICE; + +#include "dialog_shim.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/////////////////////////////////////////////////////////////////////////// + +/////////////////////////////////////////////////////////////////////////////// +/// Class DIALOG_FIELD_PROPERTIES_BASE +/////////////////////////////////////////////////////////////////////////////// +class DIALOG_FIELD_PROPERTIES_BASE : public DIALOG_SHIM +{ + private: + + protected: + wxStaticText* m_textLabel; + wxTextCtrl* m_TextCtrl; + wxStyledTextCtrl* m_StyledTextCtrl; + wxBitmapButton* m_TextValueSelectButton; + wxStaticText* m_note; + wxCheckBox* m_visible; + wxStaticText* m_fontLabel; + FONT_CHOICE* m_fontCtrl; + BITMAP_BUTTON* m_separator1; + BITMAP_BUTTON* m_horizontal; + BITMAP_BUTTON* m_vertical; + BITMAP_BUTTON* m_separator2; + BITMAP_BUTTON* m_bold; + BITMAP_BUTTON* m_italic; + BITMAP_BUTTON* m_separator3; + BITMAP_BUTTON* m_hAlignLeft; + BITMAP_BUTTON* m_hAlignCenter; + BITMAP_BUTTON* m_hAlignRight; + BITMAP_BUTTON* m_separator4; + BITMAP_BUTTON* m_vAlignTop; + BITMAP_BUTTON* m_vAlignCenter; + BITMAP_BUTTON* m_vAlignBottom; + BITMAP_BUTTON* m_separator5; + wxStaticText* m_textSizeLabel; + wxTextCtrl* m_textSizeCtrl; + wxStaticText* m_textSizeUnits; + wxStaticText* m_xPosLabel; + wxTextCtrl* m_xPosCtrl; + wxStaticText* m_xPosUnits; + wxStaticText* m_yPosLabel; + wxTextCtrl* m_yPosCtrl; + wxStaticText* m_yPosUnits; + wxCheckBox* m_CommonUnit; + wxCheckBox* m_CommonConvert; + wxStaticLine* m_staticline2; + wxStdDialogButtonSizer* m_sdbSizerButtons; + wxButton* m_sdbSizerButtonsOK; + wxButton* m_sdbSizerButtonsCancel; + + // Virtual event handlers, overide them in your derived class + virtual void OnCloseDialog( wxCloseEvent& event ) { event.Skip(); } + virtual void OnSetFocusText( wxFocusEvent& event ) { event.Skip(); } + virtual void onMultiLineTCLostFocus( wxFocusEvent& event ) { event.Skip(); } + virtual void OnTextValueSelectButtonClick( wxCommandEvent& event ) { event.Skip(); } + + + public: + + DIALOG_FIELD_PROPERTIES_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Text Item Properties"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); + ~DIALOG_FIELD_PROPERTIES_BASE(); + +}; + diff --git a/eeschema/dialogs/dialog_label_properties.cpp b/eeschema/dialogs/dialog_label_properties.cpp index c29f8e519f..d7eec9a629 100644 --- a/eeschema/dialogs/dialog_label_properties.cpp +++ b/eeschema/dialogs/dialog_label_properties.cpp @@ -43,10 +43,6 @@ #include -class SCH_EDIT_FRAME; -class SCH_TEXT; - - DIALOG_LABEL_PROPERTIES::DIALOG_LABEL_PROPERTIES( SCH_EDIT_FRAME* aParent, SCH_LABEL_BASE* aLabel ) : DIALOG_LABEL_PROPERTIES_BASE( aParent ), m_activeTextEntry( nullptr ), @@ -238,8 +234,8 @@ bool DIALOG_LABEL_PROPERTIES::TransferDataToWindow() { for( SCH_ITEM* item : screen->Items().OfType( m_currentLabel->Type() ) ) { - const SCH_TEXT* textItem = static_cast( item ); - existingLabels.insert( UnescapeString( textItem->GetText() ) ); + const SCH_LABEL_BASE* label = static_cast( item ); + existingLabels.insert( UnescapeString( label->GetText() ) ); } } @@ -508,7 +504,7 @@ void DIALOG_LABEL_PROPERTIES::onSpinButton( wxCommandEvent& aEvent ) void DIALOG_LABEL_PROPERTIES::OnFormattingHelp( wxHyperlinkEvent& aEvent ) { - m_helpWindow = SCH_TEXT::ShowSyntaxHelp( this ); + m_helpWindow = SCH_LABEL_BASE::ShowSyntaxHelp( this ); } diff --git a/eeschema/dialogs/dialog_label_properties.h b/eeschema/dialogs/dialog_label_properties.h index b45b2477a7..435d259ae7 100644 --- a/eeschema/dialogs/dialog_label_properties.h +++ b/eeschema/dialogs/dialog_label_properties.h @@ -1,7 +1,7 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2020-2021 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2020-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 @@ -26,13 +26,11 @@ #include #include -#include #include #include class SCH_EDIT_FRAME; -class SCH_TEXT; class HTML_MESSAGE_BOX; diff --git a/eeschema/dialogs/dialog_lib_shape_properties.cpp b/eeschema/dialogs/dialog_lib_shape_properties.cpp index efc2ae9858..a41ff54eab 100644 --- a/eeschema/dialogs/dialog_lib_shape_properties.cpp +++ b/eeschema/dialogs/dialog_lib_shape_properties.cpp @@ -1,7 +1,7 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2006-2021 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2006-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 @@ -73,6 +73,7 @@ bool DIALOG_LIB_SHAPE_PROPERTIES::TransferDataToWindow() if( shape ) m_lineWidth.SetValue( shape->GetWidth() ); + m_privateCheckbox->SetValue( m_item->IsPrivate() ); m_checkApplyToAllUnits->SetValue( m_item->GetUnit() == 0 ); m_checkApplyToAllUnits->Enable( symbol && symbol->GetUnitCount() > 1 ); m_checkApplyToAllConversions->SetValue( m_item->GetConvert() == 0 ); @@ -183,6 +184,8 @@ bool DIALOG_LIB_SHAPE_PROPERTIES::TransferDataFromWindow() shape->SetStroke( stroke ); } + m_item->SetPrivate( m_privateCheckbox->GetValue() ); + if( GetApplyToAllConversions() ) m_item->SetConvert( 0 ); else diff --git a/eeschema/dialogs/dialog_lib_shape_properties_base.cpp b/eeschema/dialogs/dialog_lib_shape_properties_base.cpp index 910d71416b..ef7ce2f556 100644 --- a/eeschema/dialogs/dialog_lib_shape_properties_base.cpp +++ b/eeschema/dialogs/dialog_lib_shape_properties_base.cpp @@ -78,6 +78,12 @@ DIALOG_LIB_SHAPE_PROPERTIES_BASE::DIALOG_LIB_SHAPE_PROPERTIES_BASE( wxWindow* pa dlgBorderSizer->Add( bSizerFill, 0, wxEXPAND|wxTOP|wxBOTTOM, 5 ); + m_privateCheckbox = new wxCheckBox( this, wxID_ANY, _("Private to Symbol Editor"), wxDefaultPosition, wxDefaultSize, 0 ); + dlgBorderSizer->Add( m_privateCheckbox, 0, wxALL, 3 ); + + + dlgBorderSizer->Add( 0, 8, 1, wxEXPAND, 5 ); + m_checkApplyToAllUnits = new wxCheckBox( this, wxID_ANY, _("Common to all &units in symbol"), wxDefaultPosition, wxDefaultSize, 0 ); dlgBorderSizer->Add( m_checkApplyToAllUnits, 0, wxALL, 3 ); diff --git a/eeschema/dialogs/dialog_lib_shape_properties_base.fbp b/eeschema/dialogs/dialog_lib_shape_properties_base.fbp index de65eeb1f5..b3a2c5e91c 100644 --- a/eeschema/dialogs/dialog_lib_shape_properties_base.fbp +++ b/eeschema/dialogs/dialog_lib_shape_properties_base.fbp @@ -693,6 +693,80 @@ + + 3 + wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Private to Symbol Editor + + 0 + + + 0 + + 1 + m_privateCheckbox + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + 5 + wxEXPAND + 1 + + 8 + protected + 0 + + 3 wxALL diff --git a/eeschema/dialogs/dialog_lib_shape_properties_base.h b/eeschema/dialogs/dialog_lib_shape_properties_base.h index 04feed965b..33d70b26b3 100644 --- a/eeschema/dialogs/dialog_lib_shape_properties_base.h +++ b/eeschema/dialogs/dialog_lib_shape_properties_base.h @@ -61,6 +61,7 @@ class DIALOG_LIB_SHAPE_PROPERTIES_BASE : public DIALOG_SHIM wxRadioButton* m_rbFillBackground; wxRadioButton* m_rbFillCustom; COLOR_SWATCH* m_colorSwatch; + wxCheckBox* m_privateCheckbox; wxCheckBox* m_checkApplyToAllUnits; wxCheckBox* m_checkApplyToAllConversions; wxStaticLine* m_staticline; diff --git a/eeschema/dialogs/dialog_lib_text_properties.cpp b/eeschema/dialogs/dialog_lib_text_properties.cpp index f25d76748c..5b63e06896 100644 --- a/eeschema/dialogs/dialog_lib_text_properties.cpp +++ b/eeschema/dialogs/dialog_lib_text_properties.cpp @@ -36,8 +36,6 @@ DIALOG_LIB_TEXT_PROPERTIES::DIALOG_LIB_TEXT_PROPERTIES( SYMBOL_EDIT_FRAME* aParent, LIB_TEXT* aText ) : DIALOG_LIB_TEXT_PROPERTIES_BASE( aParent ), - m_posX( aParent, m_xPosLabel, m_xPosCtrl, m_xPosUnits, true ), - m_posY( aParent, m_yPosLabel, m_yPosCtrl, m_yPosUnits, true ), m_textSize( aParent, m_textSizeLabel, m_textSizeCtrl, m_textSizeUnits, true ) { m_parent = aParent; @@ -49,15 +47,7 @@ DIALOG_LIB_TEXT_PROPERTIES::DIALOG_LIB_TEXT_PROPERTIES( SYMBOL_EDIT_FRAME* aPare wxPostEvent( this, wxCommandEvent( wxEVT_COMMAND_BUTTON_CLICKED, wxID_OK ) ); } ); - // Disable options for fieldedit, not existing in graphic text - m_visible->Show( false ); - m_TextValueSelectButton->Hide(); - - m_note->SetFont( KIUI::GetInfoFont( this ).Italic() ); - m_note->Show( false ); - - SetInitialFocus( m_TextCtrl ); - m_StyledTextCtrl->Show( false ); + SetInitialFocus( m_StyledTextCtrl ); m_separator1->SetIsSeparator(); @@ -128,15 +118,15 @@ bool DIALOG_LIB_TEXT_PROPERTIES::TransferDataToWindow() { if( m_graphicText ) { - m_posX.SetValue( m_graphicText->GetPosition().x ); - m_posY.SetValue( m_graphicText->GetPosition().y ); m_textSize.SetValue( m_graphicText->GetTextWidth() ); - m_TextCtrl->SetValue( m_graphicText->GetText() ); + m_StyledTextCtrl->SetValue( m_graphicText->GetText() ); m_fontCtrl->SetFontSelection( m_graphicText->GetFont() ); m_italic->Check( m_graphicText->IsItalic() ); m_bold->Check( m_graphicText->IsBold() ); + + m_privateCheckbox->SetValue( m_graphicText->IsPrivate() ); m_CommonUnit->SetValue( m_graphicText->GetUnit() == 0 ); m_CommonConvert->SetValue( m_graphicText->GetConvert() == 0 ); @@ -213,10 +203,10 @@ bool DIALOG_LIB_TEXT_PROPERTIES::TransferDataFromWindow() { if( m_graphicText ) { - if( m_TextCtrl->GetValue().IsEmpty() ) + if( m_StyledTextCtrl->GetValue().IsEmpty() ) m_graphicText->SetText( wxT( "[null]" ) ); else - m_graphicText->SetText( m_TextCtrl->GetValue() ); + m_graphicText->SetText( m_StyledTextCtrl->GetValue() ); if( m_fontCtrl->HaveFontSelection() ) { @@ -224,8 +214,6 @@ bool DIALOG_LIB_TEXT_PROPERTIES::TransferDataFromWindow() m_italic->IsChecked() ) ); } - m_graphicText->SetPosition( wxPoint( m_posX.GetValue(), m_posY.GetValue() ) ); - if( m_textSize.GetValue() != m_graphicText->GetTextWidth() ) m_graphicText->SetTextSize( wxSize( m_textSize.GetValue(), m_textSize.GetValue() ) ); @@ -234,6 +222,8 @@ bool DIALOG_LIB_TEXT_PROPERTIES::TransferDataFromWindow() else m_graphicText->SetTextAngle( ANGLE_VERTICAL ); + m_graphicText->SetPrivate( m_privateCheckbox->GetValue() ); + if( !m_CommonUnit->GetValue() ) m_graphicText->SetUnit( m_parent->GetUnit() ); else diff --git a/eeschema/dialogs/dialog_lib_text_properties.h b/eeschema/dialogs/dialog_lib_text_properties.h index f268446352..9966a798f8 100644 --- a/eeschema/dialogs/dialog_lib_text_properties.h +++ b/eeschema/dialogs/dialog_lib_text_properties.h @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2001 Jean-Pierre Charras, jp.charras at wanadoo.fr - * Copyright (C) 2004-2021 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2004-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 @@ -52,8 +52,6 @@ private: SYMBOL_EDIT_FRAME* m_parent; LIB_TEXT* m_graphicText; - UNIT_BINDER m_posX; - UNIT_BINDER m_posY; UNIT_BINDER m_textSize; SCINTILLA_TRICKS* m_scintillaTricks; }; diff --git a/eeschema/dialogs/dialog_lib_text_properties_base.cpp b/eeschema/dialogs/dialog_lib_text_properties_base.cpp index e72036487c..1f234d0ce2 100644 --- a/eeschema/dialogs/dialog_lib_text_properties_base.cpp +++ b/eeschema/dialogs/dialog_lib_text_properties_base.cpp @@ -22,18 +22,15 @@ DIALOG_LIB_TEXT_PROPERTIES_BASE::DIALOG_LIB_TEXT_PROPERTIES_BASE( wxWindow* pare wxBoxSizer* bPropertiesSizer; bPropertiesSizer = new wxBoxSizer( wxVERTICAL ); - wxBoxSizer* bUpperBoxSizer; - bUpperBoxSizer = new wxBoxSizer( wxVERTICAL ); - - wxBoxSizer* bTextValueBoxSizer; - bTextValueBoxSizer = new wxBoxSizer( wxHORIZONTAL ); + wxGridBagSizer* gbSizer1; + gbSizer1 = new wxGridBagSizer( 3, 0 ); + gbSizer1->SetFlexibleDirection( wxBOTH ); + gbSizer1->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); + gbSizer1->SetEmptyCellSize( wxSize( -1,10 ) ); m_textLabel = new wxStaticText( this, wxID_ANY, _("Text:"), wxDefaultPosition, wxDefaultSize, 0 ); m_textLabel->Wrap( -1 ); - bTextValueBoxSizer->Add( m_textLabel, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 ); - - m_TextCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); - bTextValueBoxSizer->Add( m_TextCtrl, 1, wxALIGN_CENTER_VERTICAL|wxLEFT, 5 ); + gbSizer1->Add( m_textLabel, wxGBPosition( 0, 0 ), wxGBSpan( 1, 1 ), wxRIGHT|wxLEFT, 5 ); m_StyledTextCtrl = new wxStyledTextCtrl( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxBORDER_SUNKEN, wxEmptyString ); m_StyledTextCtrl->SetUseTabs( true ); @@ -64,45 +61,17 @@ DIALOG_LIB_TEXT_PROPERTIES_BASE::DIALOG_LIB_TEXT_PROPERTIES_BASE( wxWindow* pare m_StyledTextCtrl->MarkerDefine( wxSTC_MARKNUM_FOLDERTAIL, wxSTC_MARK_EMPTY ); m_StyledTextCtrl->SetSelBackground( true, wxSystemSettings::GetColour( wxSYS_COLOUR_HIGHLIGHT ) ); m_StyledTextCtrl->SetSelForeground( true, wxSystemSettings::GetColour( wxSYS_COLOUR_HIGHLIGHTTEXT ) ); - bTextValueBoxSizer->Add( m_StyledTextCtrl, 1, wxRIGHT|wxLEFT, 5 ); - - m_TextValueSelectButton = new wxBitmapButton( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW|0 ); - bTextValueBoxSizer->Add( m_TextValueSelectButton, 0, wxALIGN_CENTER_VERTICAL, 5 ); - - - bUpperBoxSizer->Add( bTextValueBoxSizer, 1, wxEXPAND|wxTOP|wxBOTTOM|wxRIGHT, 5 ); - - m_note = new wxStaticText( this, wxID_ANY, _("(%s)"), wxDefaultPosition, wxDefaultSize, 0 ); - m_note->Wrap( -1 ); - bUpperBoxSizer->Add( m_note, 0, wxBOTTOM|wxRIGHT|wxLEFT, 10 ); - - - bPropertiesSizer->Add( bUpperBoxSizer, 0, wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 ); - - wxBoxSizer* bSizer9; - bSizer9 = new wxBoxSizer( wxVERTICAL ); - - m_visible = new wxCheckBox( this, wxID_ANY, _("Visible"), wxDefaultPosition, wxDefaultSize, 0 ); - bSizer9->Add( m_visible, 0, wxALIGN_LEFT|wxBOTTOM, 2 ); - - - bPropertiesSizer->Add( bSizer9, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 10 ); - - wxGridBagSizer* gbSizer1; - gbSizer1 = new wxGridBagSizer( 3, 0 ); - gbSizer1->SetFlexibleDirection( wxBOTH ); - gbSizer1->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); - gbSizer1->SetEmptyCellSize( wxSize( -1,10 ) ); + gbSizer1->Add( m_StyledTextCtrl, wxGBPosition( 0, 1 ), wxGBSpan( 1, 4 ), wxEXPAND, 5 ); m_fontLabel = new wxStaticText( this, wxID_ANY, _("Font:"), wxDefaultPosition, wxDefaultSize, 0 ); m_fontLabel->Wrap( -1 ); - gbSizer1->Add( m_fontLabel, wxGBPosition( 0, 0 ), wxGBSpan( 1, 1 ), wxALL, 5 ); + gbSizer1->Add( m_fontLabel, wxGBPosition( 2, 0 ), wxGBSpan( 1, 1 ), wxALL, 5 ); wxString m_fontCtrlChoices[] = { _("Default Font"), _("KiCad Font") }; int m_fontCtrlNChoices = sizeof( m_fontCtrlChoices ) / sizeof( wxString ); m_fontCtrl = new FONT_CHOICE( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_fontCtrlNChoices, m_fontCtrlChoices, 0 ); m_fontCtrl->SetSelection( 0 ); - gbSizer1->Add( m_fontCtrl, wxGBPosition( 0, 1 ), wxGBSpan( 1, 2 ), wxEXPAND, 5 ); + gbSizer1->Add( m_fontCtrl, wxGBPosition( 2, 1 ), wxGBSpan( 1, 2 ), wxEXPAND, 5 ); wxBoxSizer* formattingSizer; formattingSizer = new wxBoxSizer( wxHORIZONTAL ); @@ -183,49 +152,30 @@ DIALOG_LIB_TEXT_PROPERTIES_BASE::DIALOG_LIB_TEXT_PROPERTIES_BASE( wxWindow* pare formattingSizer->Add( m_separator5, 0, wxALIGN_CENTER_VERTICAL, 5 ); - gbSizer1->Add( formattingSizer, wxGBPosition( 0, 3 ), wxGBSpan( 1, 2 ), wxEXPAND, 5 ); + gbSizer1->Add( formattingSizer, wxGBPosition( 2, 3 ), wxGBSpan( 1, 2 ), wxEXPAND, 5 ); m_textSizeLabel = new wxStaticText( this, wxID_ANY, _("Text size:"), wxDefaultPosition, wxDefaultSize, 0 ); m_textSizeLabel->Wrap( -1 ); - gbSizer1->Add( m_textSizeLabel, wxGBPosition( 1, 0 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 ); + gbSizer1->Add( m_textSizeLabel, wxGBPosition( 3, 0 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 ); m_textSizeCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); - gbSizer1->Add( m_textSizeCtrl, wxGBPosition( 1, 1 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL, 5 ); + gbSizer1->Add( m_textSizeCtrl, wxGBPosition( 3, 1 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL, 5 ); m_textSizeUnits = new wxStaticText( this, wxID_ANY, _("mm"), wxDefaultPosition, wxDefaultSize, 0 ); m_textSizeUnits->Wrap( -1 ); - gbSizer1->Add( m_textSizeUnits, wxGBPosition( 1, 2 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL|wxLEFT, 5 ); + gbSizer1->Add( m_textSizeUnits, wxGBPosition( 3, 2 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL|wxLEFT, 5 ); - m_xPosLabel = new wxStaticText( this, wxID_ANY, _("Position X:"), wxDefaultPosition, wxDefaultSize, 0 ); - m_xPosLabel->Wrap( -1 ); - gbSizer1->Add( m_xPosLabel, wxGBPosition( 3, 0 ), wxGBSpan( 1, 1 ), wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL, 5 ); - - m_xPosCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); - gbSizer1->Add( m_xPosCtrl, wxGBPosition( 3, 1 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL, 5 ); - - m_xPosUnits = new wxStaticText( this, wxID_ANY, _("mm"), wxDefaultPosition, wxDefaultSize, 0 ); - m_xPosUnits->Wrap( -1 ); - gbSizer1->Add( m_xPosUnits, wxGBPosition( 3, 2 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL|wxLEFT, 5 ); - - m_yPosLabel = new wxStaticText( this, wxID_ANY, _("Position Y:"), wxDefaultPosition, wxDefaultSize, 0 ); - m_yPosLabel->Wrap( -1 ); - gbSizer1->Add( m_yPosLabel, wxGBPosition( 4, 0 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 ); - - m_yPosCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); - gbSizer1->Add( m_yPosCtrl, wxGBPosition( 4, 1 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL, 5 ); - - m_yPosUnits = new wxStaticText( this, wxID_ANY, _("mm"), wxDefaultPosition, wxDefaultSize, 0 ); - m_yPosUnits->Wrap( -1 ); - gbSizer1->Add( m_yPosUnits, wxGBPosition( 4, 2 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL|wxLEFT, 5 ); + m_privateCheckbox = new wxCheckBox( this, wxID_ANY, _("Private to Symbol Editor"), wxDefaultPosition, wxDefaultSize, 0 ); + gbSizer1->Add( m_privateCheckbox, wxGBPosition( 5, 0 ), wxGBSpan( 1, 2 ), wxLEFT, 5 ); m_CommonUnit = new wxCheckBox( this, wxID_ANY, _("Common to all units"), wxDefaultPosition, wxDefaultSize, 0 ); - gbSizer1->Add( m_CommonUnit, wxGBPosition( 3, 4 ), wxGBSpan( 1, 1 ), wxRIGHT, 5 ); + gbSizer1->Add( m_CommonUnit, wxGBPosition( 5, 3 ), wxGBSpan( 1, 1 ), wxLEFT, 100 ); m_CommonConvert = new wxCheckBox( this, wxID_ANY, _("Common to all body styles"), wxDefaultPosition, wxDefaultSize, 0 ); - gbSizer1->Add( m_CommonConvert, wxGBPosition( 4, 4 ), wxGBSpan( 1, 1 ), wxRIGHT, 5 ); + gbSizer1->Add( m_CommonConvert, wxGBPosition( 6, 3 ), wxGBSpan( 1, 1 ), wxLEFT, 100 ); - bPropertiesSizer->Add( gbSizer1, 1, wxEXPAND|wxRIGHT|wxLEFT, 5 ); + bPropertiesSizer->Add( gbSizer1, 1, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 ); wxFlexGridSizer* fgSizer3; fgSizer3 = new wxFlexGridSizer( 5, 4, 3, 3 ); @@ -278,19 +228,15 @@ DIALOG_LIB_TEXT_PROPERTIES_BASE::DIALOG_LIB_TEXT_PROPERTIES_BASE( wxWindow* pare // Connect Events this->Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_LIB_TEXT_PROPERTIES_BASE::OnCloseDialog ) ); - m_TextCtrl->Connect( wxEVT_SET_FOCUS, wxFocusEventHandler( DIALOG_LIB_TEXT_PROPERTIES_BASE::OnSetFocusText ), NULL, this ); m_StyledTextCtrl->Connect( wxEVT_KILL_FOCUS, wxFocusEventHandler( DIALOG_LIB_TEXT_PROPERTIES_BASE::onMultiLineTCLostFocus ), NULL, this ); m_StyledTextCtrl->Connect( wxEVT_SET_FOCUS, wxFocusEventHandler( DIALOG_LIB_TEXT_PROPERTIES_BASE::OnSetFocusText ), NULL, this ); - m_TextValueSelectButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_LIB_TEXT_PROPERTIES_BASE::OnTextValueSelectButtonClick ), NULL, this ); } DIALOG_LIB_TEXT_PROPERTIES_BASE::~DIALOG_LIB_TEXT_PROPERTIES_BASE() { // Disconnect Events this->Disconnect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_LIB_TEXT_PROPERTIES_BASE::OnCloseDialog ) ); - m_TextCtrl->Disconnect( wxEVT_SET_FOCUS, wxFocusEventHandler( DIALOG_LIB_TEXT_PROPERTIES_BASE::OnSetFocusText ), NULL, this ); m_StyledTextCtrl->Disconnect( wxEVT_KILL_FOCUS, wxFocusEventHandler( DIALOG_LIB_TEXT_PROPERTIES_BASE::onMultiLineTCLostFocus ), NULL, this ); m_StyledTextCtrl->Disconnect( wxEVT_SET_FOCUS, wxFocusEventHandler( DIALOG_LIB_TEXT_PROPERTIES_BASE::OnSetFocusText ), NULL, this ); - m_TextValueSelectButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_LIB_TEXT_PROPERTIES_BASE::OnTextValueSelectButtonClick ), NULL, this ); } diff --git a/eeschema/dialogs/dialog_lib_text_properties_base.fbp b/eeschema/dialogs/dialog_lib_text_properties_base.fbp index 5355265b07..31238aa229 100644 --- a/eeschema/dialogs/dialog_lib_text_properties_base.fbp +++ b/eeschema/dialogs/dialog_lib_text_properties_base.fbp @@ -70,432 +70,7 @@ none 5 - wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND - 0 - - - bUpperBoxSizer - wxVERTICAL - none - - 5 - wxEXPAND|wxTOP|wxBOTTOM|wxRIGHT - 1 - - - bTextValueBoxSizer - wxHORIZONTAL - none - - 5 - wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Text: - 0 - - 0 - - - 0 - - 1 - m_textLabel - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - - - -1 - - - - 5 - wxALIGN_CENTER_VERTICAL|wxLEFT - 1 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - - - 0 - - 1 - m_TextCtrl - 1 - - - protected - 1 - - Resizable - 1 - - - ; ; forward_declare - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - OnSetFocusText - - - - 5 - wxRIGHT|wxLEFT - 1 - - 1 - 1 - 1 - 1 - - - - - 0 - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - 0 - - 0 - 0 - wxID_ANY - 0 - 0 - - 0 - - - 0 - - 1 - m_StyledTextCtrl - 1 - - - protected - 1 - - Resizable - 1 - - ; ; forward_declare - 0 - 4 - 0 - - 1 - 0 - 0 - - - wxBORDER_SUNKEN - onMultiLineTCLostFocus - OnSetFocusText - - - - 5 - wxALIGN_CENTER_VERTICAL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - - 1 - 0 - 1 - - 1 - - 0 - 0 - - Dock - 0 - Left - 1 - - 1 - - - 0 - 0 - wxID_ANY - Select... - - 0 - - 0 - - - 0 - - 1 - m_TextValueSelectButton - 1 - - - protected - 1 - - - - Resizable - 1 - - - ; ; forward_declare - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - OnTextValueSelectButtonClick - - - - - - 10 - wxBOTTOM|wxRIGHT|wxLEFT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - (%s) - 0 - - 0 - - - 0 - - 1 - m_note - 1 - - - protected - 1 - - Resizable - 1 - - - ; ; forward_declare - 0 - - - - - -1 - - - - - - 10 - wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT - 0 - - - bSizer9 - wxVERTICAL - none - - 2 - wxALIGN_LEFT|wxBOTTOM - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Visible - - 0 - - - 0 - - 1 - m_visible - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - 5 - wxEXPAND|wxRIGHT|wxLEFT + wxEXPAND|wxTOP|wxRIGHT|wxLEFT 1 -1,10 @@ -512,9 +87,144 @@ 5 1 0 - wxALL + wxRIGHT|wxLEFT 0 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Text: + 0 + + 0 + + + 0 + + 1 + m_textLabel + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + 5 + 4 + 1 + wxEXPAND + 0 + 1 + + 1 + 1 + 1 + 1 + + + + + 0 + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + 0 + + 0 + 0 + wxID_ANY + 0 + 0 + + 0 + + + 0 + + 1 + m_StyledTextCtrl + 1 + + + protected + 1 + + Resizable + 1 + + ; ; forward_declare + 0 + 4 + 0 + + 1 + 0 + 0 + + + wxBORDER_SUNKEN + onMultiLineTCLostFocus + OnSetFocusText + + + + 5 + 1 + 0 + wxALL + 2 + 1 1 1 @@ -577,7 +287,7 @@ 2 1 wxEXPAND - 0 + 2 1 1 @@ -644,7 +354,7 @@ 2 3 wxEXPAND - 0 + 2 1 @@ -1738,7 +1448,7 @@ 1 0 wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT - 1 + 3 1 1 @@ -1802,7 +1512,7 @@ 1 1 wxALIGN_CENTER_VERTICAL - 1 + 3 1 1 @@ -1869,7 +1579,7 @@ 1 2 wxALIGN_CENTER_VERTICAL|wxLEFT - 1 + 3 1 1 @@ -1930,12 +1640,12 @@ 5 - 1 + 2 0 - wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL - 3 + wxLEFT + 5 1 - + 1 1 1 @@ -1949,6 +1659,7 @@ 1 0 + 0 1 1 @@ -1963,8 +1674,7 @@ 0 0 wxID_ANY - Position X: - 0 + Private to Symbol Editor 0 @@ -1972,7 +1682,7 @@ 0 1 - m_xPosLabel + m_privateCheckbox 1 @@ -1983,347 +1693,24 @@ 1 - ; forward_declare - 0 - - - - - -1 - - - - 5 - 1 - 1 - wxALIGN_CENTER_VERTICAL - 3 - 1 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - - - 0 - - 1 - m_xPosCtrl - 1 - - - protected - 1 - - Resizable - 1 - - - ; forward_declare + ; ; forward_declare 0 wxFILTER_NONE wxDefaultValidator - - 5 + 100 1 - 2 - wxALIGN_CENTER_VERTICAL|wxLEFT - 3 - 1 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - mm - 0 - - 0 - - - 0 - - 1 - m_xPosUnits - 1 - - - protected - 1 - - Resizable - 1 - - - ; forward_declare - 0 - - - - - -1 - - - - 5 - 1 - 0 - wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT - 4 - 1 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Position Y: - 0 - - 0 - - - 0 - - 1 - m_yPosLabel - 1 - - - protected - 1 - - Resizable - 1 - - - ; forward_declare - 0 - - - - - -1 - - - - 5 - 1 - 1 - wxALIGN_CENTER_VERTICAL - 4 - 1 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - - - 0 - - 1 - m_yPosCtrl - 1 - - - protected - 1 - - Resizable - 1 - - - ; forward_declare - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - 5 - 1 - 2 - wxALIGN_CENTER_VERTICAL|wxLEFT - 4 - 1 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - mm - 0 - - 0 - - - 0 - - 1 - m_yPosUnits - 1 - - - protected - 1 - - Resizable - 1 - - - ; forward_declare - 0 - - - - - -1 - - - - 5 - 1 - 4 - wxRIGHT - 3 + 3 + wxLEFT + 5 1 1 @@ -2386,11 +1773,11 @@ - 5 + 100 1 - 4 - wxRIGHT - 4 + 3 + wxLEFT + 6 1 1 diff --git a/eeschema/dialogs/dialog_lib_text_properties_base.h b/eeschema/dialogs/dialog_lib_text_properties_base.h index 1f8e612981..e10bc9499c 100644 --- a/eeschema/dialogs/dialog_lib_text_properties_base.h +++ b/eeschema/dialogs/dialog_lib_text_properties_base.h @@ -20,16 +20,16 @@ class FONT_CHOICE; #include #include #include -#include #include +#include #include #include #include #include #include #include +#include #include -#include #include #include #include @@ -45,11 +45,7 @@ class DIALOG_LIB_TEXT_PROPERTIES_BASE : public DIALOG_SHIM protected: wxStaticText* m_textLabel; - wxTextCtrl* m_TextCtrl; wxStyledTextCtrl* m_StyledTextCtrl; - wxBitmapButton* m_TextValueSelectButton; - wxStaticText* m_note; - wxCheckBox* m_visible; wxStaticText* m_fontLabel; FONT_CHOICE* m_fontCtrl; BITMAP_BUTTON* m_separator1; @@ -70,12 +66,7 @@ class DIALOG_LIB_TEXT_PROPERTIES_BASE : public DIALOG_SHIM wxStaticText* m_textSizeLabel; wxTextCtrl* m_textSizeCtrl; wxStaticText* m_textSizeUnits; - wxStaticText* m_xPosLabel; - wxTextCtrl* m_xPosCtrl; - wxStaticText* m_xPosUnits; - wxStaticText* m_yPosLabel; - wxTextCtrl* m_yPosCtrl; - wxStaticText* m_yPosUnits; + wxCheckBox* m_privateCheckbox; wxCheckBox* m_CommonUnit; wxCheckBox* m_CommonConvert; wxStaticLine* m_staticline2; @@ -85,9 +76,8 @@ class DIALOG_LIB_TEXT_PROPERTIES_BASE : public DIALOG_SHIM // Virtual event handlers, overide them in your derived class virtual void OnCloseDialog( wxCloseEvent& event ) { event.Skip(); } - virtual void OnSetFocusText( wxFocusEvent& event ) { event.Skip(); } virtual void onMultiLineTCLostFocus( wxFocusEvent& event ) { event.Skip(); } - virtual void OnTextValueSelectButtonClick( wxCommandEvent& event ) { event.Skip(); } + virtual void OnSetFocusText( wxFocusEvent& event ) { event.Skip(); } public: diff --git a/eeschema/dialogs/dialog_lib_textbox_properties.cpp b/eeschema/dialogs/dialog_lib_textbox_properties.cpp new file mode 100644 index 0000000000..2d0b8b0e8d --- /dev/null +++ b/eeschema/dialogs/dialog_lib_textbox_properties.cpp @@ -0,0 +1,310 @@ +/* + * 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 + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "symbol_editor_drawing_tools.h" + +DIALOG_LIB_TEXTBOX_PROPERTIES::DIALOG_LIB_TEXTBOX_PROPERTIES( SYMBOL_EDIT_FRAME* aParent, + LIB_TEXTBOX* aTextBox ) : + DIALOG_LIB_TEXTBOX_PROPERTIES_BASE( aParent ), + m_frame( aParent ), + m_currentText( aTextBox ), + m_textSize( aParent, m_textSizeLabel, m_textSizeCtrl, m_textSizeUnits ), + m_borderWidth( aParent, m_borderWidthLabel, m_borderWidthCtrl, m_borderWidthUnits ), + m_scintillaTricks( nullptr ), + m_helpWindow( nullptr ) +{ + m_borderColorSwatch->SetDefaultColor( COLOR4D::UNSPECIFIED ); + + for( const std::pair& typeEntry : lineTypeNames ) + m_borderStyleCombo->Append( typeEntry.second.name, KiBitmap( typeEntry.second.bitmap ) ); + + m_borderStyleCombo->Append( DEFAULT_STYLE ); + m_fillColorSwatch->SetDefaultColor( COLOR4D::UNSPECIFIED ); + + m_textCtrl->SetEOLMode( wxSTC_EOL_LF ); + + m_scintillaTricks = new SCINTILLA_TRICKS( m_textCtrl, wxT( "{}" ), false, + [this]() + { + wxPostEvent( this, wxCommandEvent( wxEVT_COMMAND_BUTTON_CLICKED, wxID_OK ) ); + } ); + + m_textEntrySizer->AddGrowableRow( 0 ); + + SetInitialFocus( m_textCtrl ); + + m_separator1->SetIsSeparator(); + + m_bold->SetIsCheckButton(); + m_bold->SetBitmap( KiBitmap( BITMAPS::text_bold ) ); + m_italic->SetIsCheckButton(); + m_italic->SetBitmap( KiBitmap( BITMAPS::text_italic ) ); + + m_separator2->SetIsSeparator(); + + m_spin0->SetIsCheckButton(); + m_spin0->SetBitmap( KiBitmap( BITMAPS::text_align_left ) ); + m_spin1->SetIsCheckButton(); + m_spin1->SetBitmap( KiBitmap( BITMAPS::text_align_right ) ); + m_spin2->SetIsCheckButton(); + m_spin2->SetBitmap( KiBitmap( BITMAPS::text_align_bottom ) ); + m_spin3->SetIsCheckButton(); + m_spin3->SetBitmap( KiBitmap( BITMAPS::text_align_top ) ); + + m_separator3->SetIsSeparator(); + + SetupStandardButtons(); + Layout(); + + m_spin0->Bind( wxEVT_BUTTON, &DIALOG_LIB_TEXTBOX_PROPERTIES::onSpinButton, this ); + m_spin1->Bind( wxEVT_BUTTON, &DIALOG_LIB_TEXTBOX_PROPERTIES::onSpinButton, this ); + m_spin2->Bind( wxEVT_BUTTON, &DIALOG_LIB_TEXTBOX_PROPERTIES::onSpinButton, this ); + m_spin3->Bind( wxEVT_BUTTON, &DIALOG_LIB_TEXTBOX_PROPERTIES::onSpinButton, this ); + + m_fillColorSwatch->Bind( COLOR_SWATCH_CHANGED, &DIALOG_LIB_TEXTBOX_PROPERTIES::onFillSwatch, this ); + + // Now all widgets have the size fixed, call FinishDialogSettings + finishDialogSettings(); +} + + +DIALOG_LIB_TEXTBOX_PROPERTIES::~DIALOG_LIB_TEXTBOX_PROPERTIES() +{ + delete m_scintillaTricks; + + if( m_helpWindow ) + m_helpWindow->Destroy(); +} + + +bool DIALOG_LIB_TEXTBOX_PROPERTIES::TransferDataToWindow() +{ + if( !wxDialog::TransferDataToWindow() ) + return false; + + m_textCtrl->SetValue( m_currentText->GetText() ); + + m_fontCtrl->SetFontSelection( m_currentText->GetFont() ); + m_textSize.SetValue( m_currentText->GetTextWidth() ); + + m_bold->Check( m_currentText->IsBold() ); + m_italic->Check( m_currentText->IsItalic() ); + + m_borderWidth.SetValue( m_currentText->GetWidth() ); + m_borderColorSwatch->SetSwatchColor( m_currentText->GetStroke().GetColor(), false ); + + int style = static_cast( m_currentText->GetStroke().GetPlotStyle() ); + + if( style == -1 ) + m_borderStyleCombo->SetStringSelection( DEFAULT_STYLE ); + else if( style < (int) lineTypeNames.size() ) + m_borderStyleCombo->SetSelection( style ); + else + wxFAIL_MSG( "Line type not found in the type lookup map" ); + + m_filledCtrl->SetValue( m_currentText->IsFilled() ); + m_fillColorSwatch->SetSwatchColor( m_currentText->GetFillColor(), false ); + + if( m_currentText->GetTextAngle() == ANGLE_VERTICAL ) + { + if( m_currentText->GetHorizJustify() == GR_TEXT_H_ALIGN_RIGHT ) + m_spin3->Check(); + else + m_spin2->Check(); + } + else + { + if( m_currentText->GetHorizJustify() == GR_TEXT_H_ALIGN_RIGHT ) + m_spin1->Check(); + else + m_spin0->Check(); + } + + m_privateCheckbox->SetValue( m_currentText->IsPrivate() ); + m_CommonUnit->SetValue( m_currentText->GetUnit() == 0 ); + m_CommonConvert->SetValue( m_currentText->GetConvert() == 0 ); + + return true; +} + + +void DIALOG_LIB_TEXTBOX_PROPERTIES::onSpinButton( wxCommandEvent& aEvent ) +{ + for( BITMAP_BUTTON* btn : { m_spin0, m_spin1, m_spin2, m_spin3 } ) + { + if( btn->IsChecked() && btn != aEvent.GetEventObject() ) + btn->Check( false ); + } +} + + +bool DIALOG_LIB_TEXTBOX_PROPERTIES::TransferDataFromWindow() +{ + if( !wxDialog::TransferDataFromWindow() ) + return false; + + // Don't allow text to disappear; it can be difficult to correct if you can't select it + if( !m_textSize.Validate( 0.01, 1000.0, EDA_UNITS::MILLIMETRES ) ) + return false; + + wxString text = m_textCtrl->GetValue(); + + if( !text.IsEmpty() ) + { +#ifdef __WXMAC__ + // On macOS CTRL+Enter produces '\r' instead of '\n' regardless of EOL setting + text.Replace( "\r", "\n" ); +#endif + + m_currentText->SetText( text ); + } + else if( !m_currentText->IsNew() ) + { + DisplayError( this, _( "Text can not be empty." ) ); + return false; + } + + if( m_currentText->GetTextWidth() != m_textSize.GetValue() ) + m_currentText->SetTextSize( wxSize( m_textSize.GetValue(), m_textSize.GetValue() ) ); + + if( m_fontCtrl->HaveFontSelection() ) + { + m_currentText->SetFont( m_fontCtrl->GetFontSelection( m_bold->IsChecked(), + m_italic->IsChecked() ) ); + } + + if( m_bold->IsChecked() != m_currentText->IsBold() ) + { + if( m_bold->IsChecked() ) + { + m_currentText->SetBold( true ); + m_currentText->SetTextThickness( GetPenSizeForBold( m_currentText->GetTextWidth() ) ); + } + else + { + m_currentText->SetBold( false ); + m_currentText->SetTextThickness( 0 ); // Use default pen width + } + } + + m_currentText->SetItalic( m_italic->IsChecked() ); + + if( m_spin0->IsChecked() ) + { + m_currentText->SetTextAngle( ANGLE_HORIZONTAL ); + m_currentText->SetHorizJustify( GR_TEXT_H_ALIGN_LEFT ); + } + else if( m_spin1->IsChecked() ) + { + m_currentText->SetTextAngle( ANGLE_HORIZONTAL ); + m_currentText->SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT ); + } + else if( m_spin2->IsChecked() ) + { + m_currentText->SetTextAngle( ANGLE_VERTICAL ); + m_currentText->SetHorizJustify( GR_TEXT_H_ALIGN_LEFT ); + } + else if( m_spin3->IsChecked() ) + { + m_currentText->SetTextAngle( ANGLE_VERTICAL ); + m_currentText->SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT ); + } + + m_currentText->UpdateTextPosition(); + + STROKE_PARAMS stroke = m_currentText->GetStroke(); + + if( !m_borderWidth.IsIndeterminate() ) + stroke.SetWidth( m_borderWidth.GetValue() ); + + auto it = lineTypeNames.begin(); + std::advance( it, m_borderStyleCombo->GetSelection() ); + + if( it == lineTypeNames.end() ) + stroke.SetPlotStyle( PLOT_DASH_TYPE::DEFAULT ); + else + stroke.SetPlotStyle( it->first ); + + stroke.SetColor( m_borderColorSwatch->GetSwatchColor() ); + + m_currentText->SetStroke( stroke ); + + m_currentText->SetFillMode( m_filledCtrl->GetValue() ? FILL_T::FILLED_WITH_COLOR + : FILL_T::NO_FILL ); + m_currentText->SetFillColor( m_fillColorSwatch->GetSwatchColor() ); + + m_currentText->SetPrivate( m_privateCheckbox->GetValue() ); + + if( !m_CommonUnit->GetValue() ) + m_currentText->SetUnit( m_frame->GetUnit() ); + else + m_currentText->SetUnit( 0 ); + + if( !m_CommonConvert->GetValue() ) + m_currentText->SetConvert( m_frame->GetConvert() ); + else + m_currentText->SetConvert( 0 ); + + // Record settings used for next time: + auto* tools = m_frame->GetToolManager()->GetTool(); + tools->SetLastTextAngle( m_currentText->GetTextAngle() ); + tools->SetDrawSpecificConvert( !m_CommonConvert->GetValue() ); + tools->SetDrawSpecificUnit( !m_CommonUnit->GetValue() ); + + m_frame->SetMsgPanel( m_currentText ); + + return true; +} + + +void DIALOG_LIB_TEXTBOX_PROPERTIES::OnFormattingHelp( wxHyperlinkEvent& aEvent ) +{ + m_helpWindow = SCH_TEXT::ShowSyntaxHelp( this ); +} + + +void DIALOG_LIB_TEXTBOX_PROPERTIES::onMultiLineTCLostFocus( wxFocusEvent& event ) +{ + if( m_scintillaTricks ) + m_scintillaTricks->CancelAutocomplete(); + + event.Skip(); +} + + +void DIALOG_LIB_TEXTBOX_PROPERTIES::onFillSwatch( wxCommandEvent& aEvent ) +{ + m_filledCtrl->SetValue( true ); +} \ No newline at end of file diff --git a/eeschema/dialogs/dialog_lib_textbox_properties.h b/eeschema/dialogs/dialog_lib_textbox_properties.h new file mode 100644 index 0000000000..a015602dcf --- /dev/null +++ b/eeschema/dialogs/dialog_lib_textbox_properties.h @@ -0,0 +1,65 @@ +/* + * 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 DIALOG_LIB_TEXTBOX_PROPERTIES_H +#define DIALOG_LIB_TEXTBOX_PROPERTIES_H + +#include +#include +#include "dialog_lib_textbox_properties_base.h" + + +class SYMBOL_EDIT_FRAME; +class LIB_TEXTBOX; +class SCINTILLA_TRICKS; +class HTML_MESSAGE_BOX; + + +class DIALOG_LIB_TEXTBOX_PROPERTIES : public DIALOG_LIB_TEXTBOX_PROPERTIES_BASE +{ +public: + DIALOG_LIB_TEXTBOX_PROPERTIES( SYMBOL_EDIT_FRAME* parent, LIB_TEXTBOX* aTextBox ); + ~DIALOG_LIB_TEXTBOX_PROPERTIES(); + +private: + void onSpinButton( wxCommandEvent &aEvent ); + void onFillSwatch( wxCommandEvent& aEvent ); + + void OnFormattingHelp( wxHyperlinkEvent& aEvent ) override; + void onMultiLineTCLostFocus( wxFocusEvent& event ) override; + + bool TransferDataToWindow() override; + bool TransferDataFromWindow() override; + + SYMBOL_EDIT_FRAME* m_frame; + LIB_TEXTBOX* m_currentText; + UNIT_BINDER m_textSize; + UNIT_BINDER m_borderWidth; + SCINTILLA_TRICKS* m_scintillaTricks; + + HTML_MESSAGE_BOX* m_helpWindow; +}; + + + +#endif // DIALOG_LIB_TEXTBOX_PROPERTIES_H diff --git a/eeschema/dialogs/dialog_lib_textbox_properties_base.cpp b/eeschema/dialogs/dialog_lib_textbox_properties_base.cpp new file mode 100644 index 0000000000..b1dbf84f91 --- /dev/null +++ b/eeschema/dialogs/dialog_lib_textbox_properties_base.cpp @@ -0,0 +1,259 @@ +/////////////////////////////////////////////////////////////////////////// +// C++ code generated with wxFormBuilder (version Oct 26 2018) +// http://www.wxformbuilder.org/ +// +// PLEASE DO *NOT* EDIT THIS FILE! +/////////////////////////////////////////////////////////////////////////// + +#include "widgets/bitmap_button.h" +#include "widgets/color_swatch.h" +#include "widgets/font_choice.h" + +#include "dialog_lib_textbox_properties_base.h" + +/////////////////////////////////////////////////////////////////////////// + +DIALOG_LIB_TEXTBOX_PROPERTIES_BASE::DIALOG_LIB_TEXTBOX_PROPERTIES_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : DIALOG_SHIM( parent, id, title, pos, size, style ) +{ + this->SetSizeHints( wxDefaultSize, wxDefaultSize ); + + wxBoxSizer* bMainSizer; + bMainSizer = new wxBoxSizer( wxVERTICAL ); + + m_textEntrySizer = new wxGridBagSizer( 3, 0 ); + m_textEntrySizer->SetFlexibleDirection( wxBOTH ); + m_textEntrySizer->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); + + m_textLabel = new wxStaticText( this, wxID_ANY, _("Text:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_textLabel->Wrap( -1 ); + m_textEntrySizer->Add( m_textLabel, wxGBPosition( 0, 0 ), wxGBSpan( 1, 1 ), wxRIGHT, 5 ); + + m_textCtrl = new wxStyledTextCtrl( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxBORDER_SUNKEN, wxEmptyString ); + m_textCtrl->SetUseTabs( true ); + m_textCtrl->SetTabWidth( 4 ); + m_textCtrl->SetIndent( 4 ); + m_textCtrl->SetTabIndents( false ); + m_textCtrl->SetBackSpaceUnIndents( false ); + m_textCtrl->SetViewEOL( false ); + m_textCtrl->SetViewWhiteSpace( false ); + m_textCtrl->SetMarginWidth( 2, 0 ); + m_textCtrl->SetIndentationGuides( false ); + m_textCtrl->SetMarginWidth( 1, 0 ); + m_textCtrl->SetMarginWidth( 0, 0 ); + m_textCtrl->MarkerDefine( wxSTC_MARKNUM_FOLDER, wxSTC_MARK_BOXPLUS ); + m_textCtrl->MarkerSetBackground( wxSTC_MARKNUM_FOLDER, wxColour( wxT("BLACK") ) ); + m_textCtrl->MarkerSetForeground( wxSTC_MARKNUM_FOLDER, wxColour( wxT("WHITE") ) ); + m_textCtrl->MarkerDefine( wxSTC_MARKNUM_FOLDEROPEN, wxSTC_MARK_BOXMINUS ); + m_textCtrl->MarkerSetBackground( wxSTC_MARKNUM_FOLDEROPEN, wxColour( wxT("BLACK") ) ); + m_textCtrl->MarkerSetForeground( wxSTC_MARKNUM_FOLDEROPEN, wxColour( wxT("WHITE") ) ); + m_textCtrl->MarkerDefine( wxSTC_MARKNUM_FOLDERSUB, wxSTC_MARK_EMPTY ); + m_textCtrl->MarkerDefine( wxSTC_MARKNUM_FOLDEREND, wxSTC_MARK_BOXPLUS ); + m_textCtrl->MarkerSetBackground( wxSTC_MARKNUM_FOLDEREND, wxColour( wxT("BLACK") ) ); + m_textCtrl->MarkerSetForeground( wxSTC_MARKNUM_FOLDEREND, wxColour( wxT("WHITE") ) ); + m_textCtrl->MarkerDefine( wxSTC_MARKNUM_FOLDEROPENMID, wxSTC_MARK_BOXMINUS ); + m_textCtrl->MarkerSetBackground( wxSTC_MARKNUM_FOLDEROPENMID, wxColour( wxT("BLACK") ) ); + m_textCtrl->MarkerSetForeground( wxSTC_MARKNUM_FOLDEROPENMID, wxColour( wxT("WHITE") ) ); + m_textCtrl->MarkerDefine( wxSTC_MARKNUM_FOLDERMIDTAIL, wxSTC_MARK_EMPTY ); + m_textCtrl->MarkerDefine( wxSTC_MARKNUM_FOLDERTAIL, wxSTC_MARK_EMPTY ); + m_textCtrl->SetSelBackground( true, wxSystemSettings::GetColour( wxSYS_COLOUR_HIGHLIGHT ) ); + m_textCtrl->SetSelForeground( true, wxSystemSettings::GetColour( wxSYS_COLOUR_HIGHLIGHTTEXT ) ); + m_textCtrl->SetMinSize( wxSize( 500,140 ) ); + + m_textEntrySizer->Add( m_textCtrl, wxGBPosition( 0, 1 ), wxGBSpan( 1, 4 ), wxEXPAND, 5 ); + + m_fontLabel = new wxStaticText( this, wxID_ANY, _("Font:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_fontLabel->Wrap( -1 ); + m_textEntrySizer->Add( m_fontLabel, wxGBPosition( 1, 0 ), wxGBSpan( 1, 1 ), wxRIGHT|wxALIGN_CENTER_VERTICAL, 5 ); + + wxString m_fontCtrlChoices[] = { _("Default Font"), _("KiCad Font") }; + int m_fontCtrlNChoices = sizeof( m_fontCtrlChoices ) / sizeof( wxString ); + m_fontCtrl = new FONT_CHOICE( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_fontCtrlNChoices, m_fontCtrlChoices, 0 ); + m_fontCtrl->SetSelection( 0 ); + m_textEntrySizer->Add( m_fontCtrl, wxGBPosition( 1, 1 ), wxGBSpan( 1, 2 ), wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 ); + + wxBoxSizer* bSizeCtrlSizer; + bSizeCtrlSizer = new wxBoxSizer( wxHORIZONTAL ); + + m_separator1 = new BITMAP_BUTTON( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 21,21 ), wxBU_AUTODRAW|wxBORDER_NONE ); + m_separator1->Enable( false ); + + bSizeCtrlSizer->Add( m_separator1, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxLEFT, 5 ); + + m_bold = new BITMAP_BUTTON( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 21,21 ), wxBU_AUTODRAW|wxBORDER_NONE ); + m_bold->SetToolTip( _("Bold") ); + + bSizeCtrlSizer->Add( m_bold, 0, wxTOP|wxBOTTOM|wxALIGN_CENTER_VERTICAL, 5 ); + + m_italic = new BITMAP_BUTTON( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 21,21 ), wxBU_AUTODRAW|wxBORDER_NONE ); + m_italic->SetToolTip( _("Italic") ); + + bSizeCtrlSizer->Add( m_italic, 0, wxTOP|wxBOTTOM|wxALIGN_CENTER_VERTICAL, 5 ); + + m_separator2 = new BITMAP_BUTTON( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 21,21 ), wxBU_AUTODRAW|wxBORDER_NONE ); + m_separator2->Enable( false ); + + bSizeCtrlSizer->Add( m_separator2, 0, wxTOP|wxBOTTOM|wxALIGN_CENTER_VERTICAL, 5 ); + + m_spin0 = new BITMAP_BUTTON( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 21,21 ), wxBU_AUTODRAW|wxBORDER_NONE ); + m_spin0->SetToolTip( _("Align right") ); + + bSizeCtrlSizer->Add( m_spin0, 0, wxTOP|wxBOTTOM|wxALIGN_CENTER_VERTICAL, 5 ); + + m_spin1 = new BITMAP_BUTTON( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 21,21 ), wxBU_AUTODRAW|wxBORDER_NONE ); + m_spin1->SetToolTip( _("Align bottom") ); + + bSizeCtrlSizer->Add( m_spin1, 0, wxTOP|wxBOTTOM|wxALIGN_CENTER_VERTICAL, 5 ); + + m_spin2 = new BITMAP_BUTTON( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 21,21 ), wxBU_AUTODRAW|wxBORDER_NONE ); + m_spin2->SetToolTip( _("Align left") ); + + bSizeCtrlSizer->Add( m_spin2, 0, wxTOP|wxBOTTOM|wxALIGN_CENTER_VERTICAL, 5 ); + + m_spin3 = new BITMAP_BUTTON( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 21,21 ), wxBU_AUTODRAW|wxBORDER_NONE ); + m_spin3->SetToolTip( _("Align top") ); + + bSizeCtrlSizer->Add( m_spin3, 0, wxTOP|wxBOTTOM|wxALIGN_CENTER_VERTICAL, 5 ); + + m_separator3 = new BITMAP_BUTTON( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 21,21 ), wxBU_AUTODRAW|wxBORDER_NONE ); + m_separator3->Enable( false ); + + bSizeCtrlSizer->Add( m_separator3, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM, 5 ); + + + m_textEntrySizer->Add( bSizeCtrlSizer, wxGBPosition( 1, 3 ), wxGBSpan( 1, 1 ), wxEXPAND, 5 ); + + wxBoxSizer* bSizer41; + bSizer41 = new wxBoxSizer( wxVERTICAL ); + + m_syntaxHelp = new wxHyperlinkCtrl( this, wxID_ANY, _("Syntax help"), wxEmptyString, wxDefaultPosition, wxDefaultSize, wxHL_DEFAULT_STYLE ); + m_syntaxHelp->SetToolTip( _("Show syntax help window") ); + + bSizer41->Add( m_syntaxHelp, 0, wxRIGHT|wxLEFT, 5 ); + + + m_textEntrySizer->Add( bSizer41, wxGBPosition( 1, 4 ), wxGBSpan( 1, 1 ), wxEXPAND|wxALIGN_RIGHT|wxLEFT, 80 ); + + m_textSizeLabel = new wxStaticText( this, wxID_ANY, _("Text size:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_textSizeLabel->Wrap( -1 ); + m_textEntrySizer->Add( m_textSizeLabel, wxGBPosition( 2, 0 ), wxGBSpan( 1, 1 ), wxRIGHT|wxALIGN_CENTER_VERTICAL, 5 ); + + m_textSizeCtrl = new wxTextCtrl( this, wxID_SIZE, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + m_textEntrySizer->Add( m_textSizeCtrl, wxGBPosition( 2, 1 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 ); + + m_textSizeUnits = new wxStaticText( this, wxID_ANY, _("mm"), wxDefaultPosition, wxDefaultSize, 0 ); + m_textSizeUnits->Wrap( -1 ); + m_textEntrySizer->Add( m_textSizeUnits, wxGBPosition( 2, 2 ), wxGBSpan( 1, 1 ), wxLEFT|wxALIGN_CENTER_VERTICAL, 5 ); + + + m_textEntrySizer->Add( 0, 15, wxGBPosition( 3, 0 ), wxGBSpan( 1, 1 ), wxEXPAND, 5 ); + + m_borderWidthLabel = new wxStaticText( this, wxID_ANY, _("Border width:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_borderWidthLabel->Wrap( -1 ); + m_textEntrySizer->Add( m_borderWidthLabel, wxGBPosition( 4, 0 ), wxGBSpan( 1, 1 ), wxRIGHT|wxALIGN_CENTER_VERTICAL, 5 ); + + m_borderWidthCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( -1,-1 ), 0 ); + m_textEntrySizer->Add( m_borderWidthCtrl, wxGBPosition( 4, 1 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL, 5 ); + + m_borderWidthUnits = new wxStaticText( this, wxID_ANY, _("mm"), wxDefaultPosition, wxDefaultSize, 0 ); + m_borderWidthUnits->Wrap( -1 ); + m_textEntrySizer->Add( m_borderWidthUnits, wxGBPosition( 4, 2 ), wxGBSpan( 1, 1 ), wxLEFT|wxALIGN_CENTER_VERTICAL, 5 ); + + m_borderColorLabel = new wxStaticText( this, wxID_ANY, _("Border color:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_borderColorLabel->Wrap( -1 ); + m_textEntrySizer->Add( m_borderColorLabel, wxGBPosition( 5, 0 ), wxGBSpan( 1, 1 ), wxRIGHT|wxALIGN_CENTER_VERTICAL, 5 ); + + m_panelBorderColor = new wxPanel( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxBORDER_SIMPLE|wxTAB_TRAVERSAL ); + wxBoxSizer* bSizer2; + bSizer2 = new wxBoxSizer( wxVERTICAL ); + + m_borderColorSwatch = new COLOR_SWATCH( m_panelBorderColor, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 ); + bSizer2->Add( m_borderColorSwatch, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_CENTER_HORIZONTAL, 5 ); + + + m_panelBorderColor->SetSizer( bSizer2 ); + m_panelBorderColor->Layout(); + bSizer2->Fit( m_panelBorderColor ); + m_textEntrySizer->Add( m_panelBorderColor, wxGBPosition( 5, 1 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL, 5 ); + + m_borderStyleLabel = new wxStaticText( this, wxID_ANY, _("Border style:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_borderStyleLabel->Wrap( -1 ); + m_textEntrySizer->Add( m_borderStyleLabel, wxGBPosition( 6, 0 ), wxGBSpan( 1, 1 ), wxRIGHT|wxALIGN_CENTER_VERTICAL, 5 ); + + m_borderStyleCombo = new wxBitmapComboBox( this, wxID_ANY, _("Combo!"), wxDefaultPosition, wxDefaultSize, 0, NULL, wxCB_READONLY ); + m_borderStyleCombo->SetMinSize( wxSize( 240,-1 ) ); + + m_textEntrySizer->Add( m_borderStyleCombo, wxGBPosition( 6, 1 ), wxGBSpan( 1, 2 ), wxALIGN_CENTER_VERTICAL, 5 ); + + + m_textEntrySizer->Add( 0, 15, wxGBPosition( 7, 0 ), wxGBSpan( 1, 1 ), wxEXPAND, 5 ); + + m_filledCtrl = new wxCheckBox( this, wxID_ANY, _("Background fill"), wxDefaultPosition, wxDefaultSize, 0 ); + m_textEntrySizer->Add( m_filledCtrl, wxGBPosition( 4, 3 ), wxGBSpan( 1, 2 ), wxLEFT, 100 ); + + m_fillColorLabel = new wxStaticText( this, wxID_ANY, _("Fill color:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_fillColorLabel->Wrap( -1 ); + m_textEntrySizer->Add( m_fillColorLabel, wxGBPosition( 5, 3 ), wxGBSpan( 1, 1 ), wxLEFT|wxALIGN_CENTER_VERTICAL, 100 ); + + m_panelFillColor = new wxPanel( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxBORDER_SIMPLE|wxTAB_TRAVERSAL ); + wxBoxSizer* bSizer21; + bSizer21 = new wxBoxSizer( wxVERTICAL ); + + m_fillColorSwatch = new COLOR_SWATCH( m_panelFillColor, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 ); + bSizer21->Add( m_fillColorSwatch, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_CENTER_HORIZONTAL, 5 ); + + + m_panelFillColor->SetSizer( bSizer21 ); + m_panelFillColor->Layout(); + bSizer21->Fit( m_panelFillColor ); + m_textEntrySizer->Add( m_panelFillColor, wxGBPosition( 5, 4 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL, 5 ); + + m_privateCheckbox = new wxCheckBox( this, wxID_ANY, _("Private to symbol editor"), wxDefaultPosition, wxDefaultSize, 0 ); + m_textEntrySizer->Add( m_privateCheckbox, wxGBPosition( 8, 0 ), wxGBSpan( 1, 2 ), 0, 5 ); + + m_CommonUnit = new wxCheckBox( this, wxID_ANY, _("Common to all units"), wxDefaultPosition, wxDefaultSize, 0 ); + m_textEntrySizer->Add( m_CommonUnit, wxGBPosition( 8, 3 ), wxGBSpan( 1, 2 ), wxLEFT, 100 ); + + m_CommonConvert = new wxCheckBox( this, wxID_ANY, _("Common to all body styles"), wxDefaultPosition, wxDefaultSize, 0 ); + m_textEntrySizer->Add( m_CommonConvert, wxGBPosition( 9, 3 ), wxGBSpan( 1, 2 ), wxLEFT, 100 ); + + + m_textEntrySizer->AddGrowableCol( 1 ); + m_textEntrySizer->AddGrowableCol( 4 ); + + bMainSizer->Add( m_textEntrySizer, 1, wxEXPAND|wxALL, 10 ); + + m_staticline = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ); + bMainSizer->Add( m_staticline, 0, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 ); + + wxBoxSizer* bSizer4; + bSizer4 = new wxBoxSizer( wxHORIZONTAL ); + + m_sdbSizer1 = new wxStdDialogButtonSizer(); + m_sdbSizer1OK = new wxButton( this, wxID_OK ); + m_sdbSizer1->AddButton( m_sdbSizer1OK ); + m_sdbSizer1Cancel = new wxButton( this, wxID_CANCEL ); + m_sdbSizer1->AddButton( m_sdbSizer1Cancel ); + m_sdbSizer1->Realize(); + + bSizer4->Add( m_sdbSizer1, 1, wxALL|wxEXPAND, 5 ); + + + bMainSizer->Add( bSizer4, 0, wxEXPAND|wxALL, 5 ); + + + this->SetSizer( bMainSizer ); + this->Layout(); + bMainSizer->Fit( this ); + + // Connect Events + m_textCtrl->Connect( wxEVT_KILL_FOCUS, wxFocusEventHandler( DIALOG_LIB_TEXTBOX_PROPERTIES_BASE::onMultiLineTCLostFocus ), NULL, this ); + m_syntaxHelp->Connect( wxEVT_COMMAND_HYPERLINK, wxHyperlinkEventHandler( DIALOG_LIB_TEXTBOX_PROPERTIES_BASE::OnFormattingHelp ), NULL, this ); +} + +DIALOG_LIB_TEXTBOX_PROPERTIES_BASE::~DIALOG_LIB_TEXTBOX_PROPERTIES_BASE() +{ + // Disconnect Events + m_textCtrl->Disconnect( wxEVT_KILL_FOCUS, wxFocusEventHandler( DIALOG_LIB_TEXTBOX_PROPERTIES_BASE::onMultiLineTCLostFocus ), NULL, this ); + m_syntaxHelp->Disconnect( wxEVT_COMMAND_HYPERLINK, wxHyperlinkEventHandler( DIALOG_LIB_TEXTBOX_PROPERTIES_BASE::OnFormattingHelp ), NULL, this ); + +} diff --git a/eeschema/dialogs/dialog_lib_textbox_properties_base.fbp b/eeschema/dialogs/dialog_lib_textbox_properties_base.fbp new file mode 100644 index 0000000000..102846ba22 --- /dev/null +++ b/eeschema/dialogs/dialog_lib_textbox_properties_base.fbp @@ -0,0 +1,2373 @@ + + + + + + C++ + 1 + source_name + 0 + 0 + res + UTF-8 + connect + dialog_lib_textbox_properties_base + 1000 + none + + 1 + dialog_lib_textbox_properties_base + + . + + 1 + 1 + 1 + 1 + UI + 1 + 0 + + 0 + wxAUI_MGR_DEFAULT + + + + 1 + 1 + impl_virtual + + + + 0 + wxID_ANY + + + DIALOG_LIB_TEXTBOX_PROPERTIES_BASE + + -1,-1 + wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER + DIALOG_SHIM; dialog_shim.h + Text Box Properties + + + + + + + bMainSizer + wxVERTICAL + none + + 10 + wxEXPAND|wxALL + 1 + + -1,-1 + wxBOTH + 1,4 + + 0 + + m_textEntrySizer + wxFLEX_GROWMODE_SPECIFIED + protected + 3 + + 5 + 1 + 0 + wxRIGHT + 0 + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Text: + 0 + + 0 + + + 0 + + 1 + m_textLabel + 1 + + + protected + 1 + + Resizable + 1 + + + ; forward_declare + 0 + + + + + -1 + + + + 5 + 4 + 1 + wxEXPAND + 0 + 1 + + 1 + 1 + 1 + 1 + + + + + 0 + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + 0 + + 0 + 0 + wxID_ANY + 0 + 0 + + 0 + + + 0 + 500,140 + 1 + m_textCtrl + 1 + + + protected + 1 + + Resizable + 1 + + ; forward_declare + 0 + 4 + 0 + + 1 + 0 + 0 + + + wxBORDER_SUNKEN + onMultiLineTCLostFocus + + + + 5 + 1 + 0 + wxRIGHT|wxALIGN_CENTER_VERTICAL + 1 + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Font: + 0 + + 0 + + + 0 + + 1 + m_fontLabel + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + + + -1 + + + + 5 + 2 + 1 + wxALIGN_CENTER_VERTICAL|wxEXPAND + 1 + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + "Default Font" "KiCad Font" + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + + 1 + m_fontCtrl + 1 + + + protected + 1 + + Resizable + 0 + 1 + + + FONT_CHOICE; widgets/font_choice.h; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + 5 + 1 + 3 + wxEXPAND + 1 + 1 + + + bSizeCtrlSizer + wxHORIZONTAL + none + + 5 + wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + + 1 + 0 + 1 + + 1 + + 0 + 0 + + Dock + 0 + Left + 0 + + 1 + + + 0 + 0 + wxID_ANY + + + 0 + + 0 + + + 0 + + 1 + m_separator1 + 1 + + + protected + 1 + + + + Resizable + 1 + 21,21 + wxBORDER_NONE + BITMAP_BUTTON; widgets/bitmap_button.h; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + 5 + wxTOP|wxBOTTOM|wxALIGN_CENTER_VERTICAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + + 1 + 0 + 1 + + 1 + + 0 + 0 + + Dock + 0 + Left + 1 + + 1 + + + 0 + 0 + wxID_ANY + Bold + + 0 + + 0 + + + 0 + + 1 + m_bold + 1 + + + protected + 1 + + + + Resizable + 1 + 21,21 + wxBORDER_NONE + BITMAP_BUTTON; widgets/bitmap_button.h; forward_declare + 0 + Bold + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + 5 + wxTOP|wxBOTTOM|wxALIGN_CENTER_VERTICAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + + 1 + 0 + 1 + + 1 + + 0 + 0 + + Dock + 0 + Left + 1 + + 1 + + + 0 + 0 + wxID_ANY + Italic + + 0 + + 0 + + + 0 + + 1 + m_italic + 1 + + + protected + 1 + + + + Resizable + 1 + 21,21 + wxBORDER_NONE + BITMAP_BUTTON; widgets/bitmap_button.h; forward_declare + 0 + Italic + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + 5 + wxTOP|wxBOTTOM|wxALIGN_CENTER_VERTICAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + + 1 + 0 + 1 + + 1 + + 0 + 0 + + Dock + 0 + Left + 0 + + 1 + + + 0 + 0 + wxID_ANY + + + 0 + + 0 + + + 0 + + 1 + m_separator2 + 1 + + + protected + 1 + + + + Resizable + 1 + 21,21 + wxBORDER_NONE + BITMAP_BUTTON; widgets/bitmap_button.h; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + 5 + wxTOP|wxBOTTOM|wxALIGN_CENTER_VERTICAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + + 1 + 0 + 1 + + 1 + + 0 + 0 + + Dock + 0 + Left + 1 + + 1 + + + 0 + 0 + wxID_ANY + Align right + + 0 + + 0 + + + 0 + + 1 + m_spin0 + 1 + + + protected + 1 + + + + Resizable + 1 + 21,21 + wxBORDER_NONE + BITMAP_BUTTON; widgets/bitmap_button.h; forward_declare + 0 + Align right + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + 5 + wxTOP|wxBOTTOM|wxALIGN_CENTER_VERTICAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + + 1 + 0 + 1 + + 1 + + 0 + 0 + + Dock + 0 + Left + 1 + + 1 + + + 0 + 0 + wxID_ANY + Align bottom + + 0 + + 0 + + + 0 + + 1 + m_spin1 + 1 + + + protected + 1 + + + + Resizable + 1 + 21,21 + wxBORDER_NONE + BITMAP_BUTTON; widgets/bitmap_button.h; forward_declare + 0 + Align bottom + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + 5 + wxTOP|wxBOTTOM|wxALIGN_CENTER_VERTICAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + + 1 + 0 + 1 + + 1 + + 0 + 0 + + Dock + 0 + Left + 1 + + 1 + + + 0 + 0 + wxID_ANY + Align left + + 0 + + 0 + + + 0 + + 1 + m_spin2 + 1 + + + protected + 1 + + + + Resizable + 1 + 21,21 + wxBORDER_NONE + BITMAP_BUTTON; widgets/bitmap_button.h; forward_declare + 0 + Align left + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + 5 + wxTOP|wxBOTTOM|wxALIGN_CENTER_VERTICAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + + 1 + 0 + 1 + + 1 + + 0 + 0 + + Dock + 0 + Left + 1 + + 1 + + + 0 + 0 + wxID_ANY + Align top + + 0 + + 0 + + + 0 + + 1 + m_spin3 + 1 + + + protected + 1 + + + + Resizable + 1 + 21,21 + wxBORDER_NONE + BITMAP_BUTTON; widgets/bitmap_button.h; forward_declare + 0 + Align top + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + 5 + wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM + 0 + + 1 + 1 + 1 + 1 + + + + + + + + + 1 + 0 + 1 + + 1 + + 0 + 0 + + Dock + 0 + Left + 0 + + 1 + + + 0 + 0 + wxID_ANY + + + 0 + + 0 + + + 0 + + 1 + m_separator3 + 1 + + + protected + 1 + + + + Resizable + 1 + 21,21 + wxBORDER_NONE + BITMAP_BUTTON; widgets/bitmap_button.h; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + 80 + 1 + 4 + wxEXPAND|wxALIGN_RIGHT|wxLEFT + 1 + 1 + + + bSizer41 + wxVERTICAL + none + + 5 + wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + + wxID_ANY + Syntax help + + 0 + + + 0 + + 1 + m_syntaxHelp + + 1 + + + protected + 1 + + Resizable + 1 + + wxHL_DEFAULT_STYLE + ; ; forward_declare + 0 + Show syntax help window + + + + + + OnFormattingHelp + + + + + + 5 + 1 + 0 + wxRIGHT|wxALIGN_CENTER_VERTICAL + 2 + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Text size: + 0 + + 0 + + + 0 + + 1 + m_textSizeLabel + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + 5 + 1 + 1 + wxALIGN_CENTER_VERTICAL|wxEXPAND + 2 + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_SIZE + + 0 + + + + 0 + + 1 + m_textSizeCtrl + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + 5 + 1 + 2 + wxLEFT|wxALIGN_CENTER_VERTICAL + 2 + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + mm + 0 + + 0 + + + 0 + + 1 + m_textSizeUnits + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + 5 + 1 + 0 + wxEXPAND + 3 + 1 + + 15 + protected + 0 + + + + 5 + 1 + 0 + wxRIGHT|wxALIGN_CENTER_VERTICAL + 4 + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Border width: + 0 + + 0 + + + 0 + + 1 + m_borderWidthLabel + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + + + -1 + + + + 5 + 1 + 1 + wxALIGN_CENTER_VERTICAL + 4 + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + 0 + -1,-1 + 0 + -1,-1 + 1 + m_borderWidthCtrl + 1 + + + protected + 1 + + Resizable + 1 + -1,-1 + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + 5 + 1 + 2 + wxLEFT|wxALIGN_CENTER_VERTICAL + 4 + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + mm + 0 + + 0 + + + 0 + -1,-1 + 1 + m_borderWidthUnits + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + 5 + 1 + 0 + wxRIGHT|wxALIGN_CENTER_VERTICAL + 5 + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Border color: + 0 + + 0 + + + 0 + + 1 + m_borderColorLabel + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; Not forward_declare + 0 + + + + + -1 + + + + 5 + 1 + 1 + wxALIGN_CENTER_VERTICAL + 5 + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + + 1 + m_panelBorderColor + 1 + + + protected + 1 + + Resizable + 1 + + ; ; forward_declare + 0 + + + + wxBORDER_SIMPLE|wxTAB_TRAVERSAL + + + bSizer2 + wxVERTICAL + none + + 5 + wxALIGN_CENTER_VERTICAL|wxALIGN_CENTER_HORIZONTAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + COLOR_SWATCH + 1 + + + 1 + + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + + 0 + + + 0 + + 1 + m_borderColorSwatch + 1 + + + protected + 1 + + Resizable + + 1 + + COLOR_SWATCH; widgets/color_swatch.h; forward_declare + 0 + + + + + + + + + + + 5 + 1 + 0 + wxRIGHT|wxALIGN_CENTER_VERTICAL + 6 + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Border style: + 0 + + 0 + + + 0 + + 1 + m_borderStyleLabel + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + + + -1 + + + + 5 + 2 + 1 + wxALIGN_CENTER_VERTICAL + 6 + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + 240,-1 + 1 + m_borderStyleCombo + 1 + + + protected + 1 + + Resizable + -1 + 1 + + wxCB_READONLY + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + Combo! + + + + + + + 5 + 1 + 0 + wxEXPAND + 7 + 1 + + 15 + protected + 0 + + + + 100 + 2 + 3 + wxLEFT + 4 + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Background fill + + 0 + + + 0 + + 1 + m_filledCtrl + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + 100 + 1 + 3 + wxLEFT|wxALIGN_CENTER_VERTICAL + 5 + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Fill color: + 0 + + 0 + + + 0 + + 1 + m_fillColorLabel + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + + + -1 + + + + 5 + 1 + 4 + wxALIGN_CENTER_VERTICAL + 5 + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + + 1 + m_panelFillColor + 1 + + + protected + 1 + + Resizable + 1 + + ; ; forward_declare + 0 + + + + wxBORDER_SIMPLE|wxTAB_TRAVERSAL + + + bSizer21 + wxVERTICAL + none + + 5 + wxALIGN_CENTER_VERTICAL|wxALIGN_CENTER_HORIZONTAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + COLOR_SWATCH + 1 + + + 1 + + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + + 0 + + + 0 + + 1 + m_fillColorSwatch + 1 + + + protected + 1 + + Resizable + + 1 + + COLOR_SWATCH; widgets/color_swatch.h; forward_declare + 0 + + + + + + + + + + + 5 + 2 + 0 + + 8 + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Private to symbol editor + + 0 + + + 0 + + 1 + m_privateCheckbox + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + 100 + 2 + 3 + wxLEFT + 8 + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Common to all units + + 0 + + + 0 + + 1 + m_CommonUnit + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + 100 + 2 + 3 + wxLEFT + 9 + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Common to all body styles + + 0 + + + 0 + + 1 + m_CommonConvert + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + 5 + wxEXPAND|wxTOP|wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + + 1 + m_staticline + 1 + + + protected + 1 + + Resizable + 1 + + wxLI_HORIZONTAL + ; ; forward_declare + 0 + + + + + + + + 5 + wxEXPAND|wxALL + 0 + + + bSizer4 + wxHORIZONTAL + none + + 5 + wxALL|wxEXPAND + 1 + + 0 + 1 + 0 + 0 + 0 + 1 + 0 + 0 + + m_sdbSizer1 + protected + + + + + + + + diff --git a/eeschema/dialogs/dialog_lib_textbox_properties_base.h b/eeschema/dialogs/dialog_lib_textbox_properties_base.h new file mode 100644 index 0000000000..e6cb88e958 --- /dev/null +++ b/eeschema/dialogs/dialog_lib_textbox_properties_base.h @@ -0,0 +1,105 @@ +/////////////////////////////////////////////////////////////////////////// +// C++ code generated with wxFormBuilder (version Oct 26 2018) +// http://www.wxformbuilder.org/ +// +// PLEASE DO *NOT* EDIT THIS FILE! +/////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include +#include +#include +class BITMAP_BUTTON; +class COLOR_SWATCH; +class FONT_CHOICE; + +#include "dialog_shim.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/////////////////////////////////////////////////////////////////////////// + +/////////////////////////////////////////////////////////////////////////////// +/// Class DIALOG_LIB_TEXTBOX_PROPERTIES_BASE +/////////////////////////////////////////////////////////////////////////////// +class DIALOG_LIB_TEXTBOX_PROPERTIES_BASE : public DIALOG_SHIM +{ + private: + + protected: + enum + { + wxID_SIZE = 1000 + }; + + wxGridBagSizer* m_textEntrySizer; + wxStaticText* m_textLabel; + wxStyledTextCtrl* m_textCtrl; + wxStaticText* m_fontLabel; + FONT_CHOICE* m_fontCtrl; + BITMAP_BUTTON* m_separator1; + BITMAP_BUTTON* m_bold; + BITMAP_BUTTON* m_italic; + BITMAP_BUTTON* m_separator2; + BITMAP_BUTTON* m_spin0; + BITMAP_BUTTON* m_spin1; + BITMAP_BUTTON* m_spin2; + BITMAP_BUTTON* m_spin3; + BITMAP_BUTTON* m_separator3; + wxHyperlinkCtrl* m_syntaxHelp; + wxStaticText* m_textSizeLabel; + wxTextCtrl* m_textSizeCtrl; + wxStaticText* m_textSizeUnits; + wxStaticText* m_borderWidthLabel; + wxTextCtrl* m_borderWidthCtrl; + wxStaticText* m_borderWidthUnits; + wxStaticText* m_borderColorLabel; + wxPanel* m_panelBorderColor; + COLOR_SWATCH* m_borderColorSwatch; + wxStaticText* m_borderStyleLabel; + wxBitmapComboBox* m_borderStyleCombo; + wxCheckBox* m_filledCtrl; + wxStaticText* m_fillColorLabel; + wxPanel* m_panelFillColor; + COLOR_SWATCH* m_fillColorSwatch; + wxCheckBox* m_privateCheckbox; + wxCheckBox* m_CommonUnit; + wxCheckBox* m_CommonConvert; + wxStaticLine* m_staticline; + wxStdDialogButtonSizer* m_sdbSizer1; + wxButton* m_sdbSizer1OK; + wxButton* m_sdbSizer1Cancel; + + // Virtual event handlers, overide them in your derived class + virtual void onMultiLineTCLostFocus( wxFocusEvent& event ) { event.Skip(); } + virtual void OnFormattingHelp( wxHyperlinkEvent& event ) { event.Skip(); } + + + public: + + DIALOG_LIB_TEXTBOX_PROPERTIES_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Text Box Properties"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); + ~DIALOG_LIB_TEXTBOX_PROPERTIES_BASE(); + +}; + diff --git a/eeschema/dialogs/dialog_migrate_buses.cpp b/eeschema/dialogs/dialog_migrate_buses.cpp index 5511c88a07..c2b4eead16 100644 --- a/eeschema/dialogs/dialog_migrate_buses.cpp +++ b/eeschema/dialogs/dialog_migrate_buses.cpp @@ -2,6 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2018 CERN + * Copyright (C) 2019-2022 KiCad Developers, see change_log.txt for contributors. * @author Jon Evans * * This program is free software; you can redistribute it and/or @@ -24,6 +25,7 @@ #include #include #include +#include /** * Migrates buses using legacy multi-label joining behavior. @@ -75,18 +77,18 @@ void DIALOG_MIGRATE_BUSES::loadGraphData() m_items.clear(); auto subgraphs = m_frame->Schematic().ConnectionGraph()->GetBusesNeedingMigration(); - for( auto subgraph : subgraphs ) + for( const CONNECTION_SUBGRAPH* subgraph : subgraphs ) { BUS_MIGRATION_STATUS status; status.subgraph = subgraph; status.approved = false; - auto labels = subgraph->GetBusLabels(); + std::vector labels = subgraph->GetBusLabels(); wxASSERT( labels.size() > 1 ); - for( auto label : labels ) - status.labels.push_back( static_cast( label )->GetText() ); + for( SCH_ITEM* label : labels ) + status.labels.push_back( static_cast( label )->GetText() ); status.possible_labels = getProposedLabels( status.labels ); m_items.push_back( status ); @@ -169,21 +171,18 @@ void DIALOG_MIGRATE_BUSES::onItemSelected( wxListEvent& aEvent ) m_selected_index = sel; - auto subgraph = m_items[sel].subgraph; + const CONNECTION_SUBGRAPH* subgraph = m_items[sel].subgraph; + const SCH_SHEET_PATH& sheet = subgraph->m_sheet; + SCH_ITEM* driver = subgraph->m_driver; - auto sheet = subgraph->m_sheet; - auto driver = subgraph->m_driver; - - const SCH_SHEET_PATH& current = m_frame->GetCurrentSheet(); - - if( sheet != current ) + if( sheet != m_frame->GetCurrentSheet() ) { sheet.UpdateAllScreenReferences(); m_frame->Schematic().SetCurrentSheet( sheet ); m_frame->TestDanglingEnds(); } - auto pos = driver->GetPosition(); + VECTOR2I pos = driver->GetPosition(); m_frame->GetCanvas()->GetViewControls()->SetCrossHairCursorPosition( pos, false ); m_frame->RedrawScreen( pos, false ); @@ -201,23 +200,21 @@ void DIALOG_MIGRATE_BUSES::onAcceptClicked( wxCommandEvent& aEvent ) { wxASSERT( m_selected_index < m_items.size() ); - auto sel = m_selected_index; + unsigned sel = m_selected_index; m_items[sel].approved_label = m_cb_new_name->GetStringSelection(); m_items[sel].approved = true; - auto labels = m_items[sel].subgraph->GetBusLabels(); + std::vector labels = m_items[sel].subgraph->GetBusLabels(); - for( auto label : labels ) - static_cast( label )->SetText( m_items[sel].approved_label ); + for( SCH_ITEM* label : labels ) + static_cast( label )->SetText( m_items[sel].approved_label ); m_migration_list->SetItem( sel, 2, m_items[sel].approved_label ); m_migration_list->SetItem( sel, 3, _( "Updated" ) ); if( sel < m_items.size() - 1 ) - { m_migration_list->Select( sel + 1 ); - } m_frame->GetCanvas()->Refresh(); } diff --git a/eeschema/dialogs/dialog_sheet_pin_properties.cpp b/eeschema/dialogs/dialog_sheet_pin_properties.cpp index 1e4674334f..501b42c533 100644 --- a/eeschema/dialogs/dialog_sheet_pin_properties.cpp +++ b/eeschema/dialogs/dialog_sheet_pin_properties.cpp @@ -141,7 +141,7 @@ void DIALOG_SHEET_PIN_PROPERTIES::onOKButton( wxCommandEvent& event ) void DIALOG_SHEET_PIN_PROPERTIES::OnSyntaxHelp( wxHyperlinkEvent& aEvent ) { - m_helpWindow = SCH_TEXT::ShowSyntaxHelp( this ); + m_helpWindow = SCH_LABEL_BASE::ShowSyntaxHelp( this ); } diff --git a/eeschema/dialogs/dialog_text_properties.cpp b/eeschema/dialogs/dialog_text_properties.cpp index 81944aa4c6..e357d708c6 100644 --- a/eeschema/dialogs/dialog_text_properties.cpp +++ b/eeschema/dialogs/dialog_text_properties.cpp @@ -29,26 +29,48 @@ #include #include #include -#include +#include #include #include #include #include #include #include - -class SCH_EDIT_FRAME; -class SCH_TEXT; +#include -DIALOG_TEXT_PROPERTIES::DIALOG_TEXT_PROPERTIES( SCH_EDIT_FRAME* aParent, SCH_TEXT* aTextItem ) : +DIALOG_TEXT_PROPERTIES::DIALOG_TEXT_PROPERTIES( SCH_EDIT_FRAME* aParent, SCH_ITEM* aTextItem ) : DIALOG_TEXT_PROPERTIES_BASE( aParent ), - m_textSize( aParent, m_textSizeLabel, m_textSizeCtrl, m_textSizeUnits, false ), + m_frame( aParent ), + m_currentItem( aTextItem ), + m_currentText( dynamic_cast( aTextItem ) ), + m_textSize( aParent, m_textSizeLabel, m_textSizeCtrl, m_textSizeUnits ), + m_borderWidth( aParent, m_borderWidthLabel, m_borderWidthCtrl, m_borderWidthUnits ), m_scintillaTricks( nullptr ), m_helpWindow( nullptr ) { - m_frame = aParent; - m_currentText = aTextItem; + if( aTextItem->Type() == SCH_TEXTBOX_T ) + { + SetTitle( _( "Text Box Properties" ) ); + + m_borderColorSwatch->SetDefaultColor( COLOR4D::UNSPECIFIED ); + + for( const std::pair& typeEntry : lineTypeNames ) + m_borderStyleCombo->Append( typeEntry.second.name, KiBitmap( typeEntry.second.bitmap ) ); + + m_borderStyleCombo->Append( DEFAULT_STYLE ); + m_fillColorSwatch->SetDefaultColor( COLOR4D::UNSPECIFIED ); + } + else + { + m_borderWidth.Show( false ); + m_borderColorLabel->Show( false ); + m_panelBorderColor->Show( false ); + m_borderStyleLabel->Show( false ); + m_borderStyleCombo->Show( false ); + m_fillColorLabel->Show( false ); + m_panelFillColor->Show( false ); + } m_textCtrl->SetEOLMode( wxSTC_EOL_LF ); @@ -91,6 +113,8 @@ DIALOG_TEXT_PROPERTIES::DIALOG_TEXT_PROPERTIES( SCH_EDIT_FRAME* aParent, SCH_TEX m_spin2->Bind( wxEVT_BUTTON, &DIALOG_TEXT_PROPERTIES::onSpinButton, this ); m_spin3->Bind( wxEVT_BUTTON, &DIALOG_TEXT_PROPERTIES::onSpinButton, this ); + m_fillColorSwatch->Bind( COLOR_SWATCH_CHANGED, &DIALOG_TEXT_PROPERTIES::onFillSwatch, this ); + // Now all widgets have the size fixed, call FinishDialogSettings finishDialogSettings(); } @@ -121,12 +145,51 @@ bool DIALOG_TEXT_PROPERTIES::TransferDataToWindow() m_bold->Check( m_currentText->IsBold() ); m_italic->Check( m_currentText->IsItalic() ); - switch( m_currentText->GetTextSpinStyle() ) + if( m_currentItem->Type() == SCH_TEXTBOX_T ) { - case TEXT_SPIN_STYLE::RIGHT: m_spin0->Check( true ); break; - case TEXT_SPIN_STYLE::LEFT: m_spin1->Check( true ); break; - case TEXT_SPIN_STYLE::UP: m_spin2->Check( true ); break; - case TEXT_SPIN_STYLE::BOTTOM: m_spin3->Check( true ); break; + SCH_TEXTBOX* textBox = static_cast( m_currentItem ); + + m_borderWidth.SetValue( textBox->GetWidth() ); + m_borderColorSwatch->SetSwatchColor( textBox->GetStroke().GetColor(), false ); + + int style = static_cast( textBox->GetStroke().GetPlotStyle() ); + + if( style == -1 ) + m_borderStyleCombo->SetStringSelection( DEFAULT_STYLE ); + else if( style < (int) lineTypeNames.size() ) + m_borderStyleCombo->SetSelection( style ); + else + wxFAIL_MSG( "Line type not found in the type lookup map" ); + + m_filledCtrl->SetValue( textBox->IsFilled() ); + m_fillColorSwatch->SetSwatchColor( textBox->GetFillColor(), false ); + + if( textBox->GetTextAngle() == ANGLE_VERTICAL ) + { + if( textBox->GetHorizJustify() == GR_TEXT_H_ALIGN_RIGHT ) + m_spin3->Check(); + else + m_spin2->Check(); + } + else + { + if( textBox->GetHorizJustify() == GR_TEXT_H_ALIGN_RIGHT ) + m_spin1->Check(); + else + m_spin0->Check(); + } + } + else + { + TEXT_SPIN_STYLE spin = static_cast( m_currentItem )->GetTextSpinStyle(); + + switch( spin ) + { + case TEXT_SPIN_STYLE::RIGHT: m_spin0->Check( true ); break; + case TEXT_SPIN_STYLE::LEFT: m_spin1->Check( true ); break; + case TEXT_SPIN_STYLE::UP: m_spin2->Check( true ); break; + case TEXT_SPIN_STYLE::BOTTOM: m_spin3->Check( true ); break; + } } return true; @@ -180,7 +243,7 @@ void DIALOG_TEXT_PROPERTIES::onScintillaCharAdded( wxStyledTextEvent &aEvent ) { partial = te->GetTextRange( start, text_pos ); - SCHEMATIC* schematic = m_currentText->Schematic(); + SCHEMATIC* schematic = m_currentItem->Schematic(); if( schematic && schematic->CurrentSheet().Last() ) schematic->CurrentSheet().Last()->GetContextualTextVars( &autocompleteTokens ); @@ -216,9 +279,9 @@ bool DIALOG_TEXT_PROPERTIES::TransferDataFromWindow() wxString text; /* save old text in undo list if not already in edit */ - if( m_currentText->GetEditFlags() == 0 ) + if( m_currentItem->GetEditFlags() == 0 ) { - m_frame->SaveCopyInUndoList( m_frame->GetScreen(), m_currentText, UNDO_REDO::CHANGED, + m_frame->SaveCopyInUndoList( m_frame->GetScreen(), m_currentItem, UNDO_REDO::CHANGED, false ); } @@ -236,7 +299,7 @@ bool DIALOG_TEXT_PROPERTIES::TransferDataFromWindow() m_currentText->SetText( text ); } - else if( !m_currentText->IsNew() ) + else if( !m_currentItem->IsNew() ) { DisplayError( this, _( "Text can not be empty." ) ); return false; @@ -267,21 +330,70 @@ bool DIALOG_TEXT_PROPERTIES::TransferDataFromWindow() m_currentText->SetItalic( m_italic->IsChecked() ); - TEXT_SPIN_STYLE selectedSpinStyle= TEXT_SPIN_STYLE::LEFT; + if( m_currentItem->Type() == SCH_TEXT_T ) + { + TEXT_SPIN_STYLE selectedSpinStyle= TEXT_SPIN_STYLE::LEFT; - if( m_spin0->IsChecked() ) - selectedSpinStyle = TEXT_SPIN_STYLE::RIGHT; - else if( m_spin1->IsChecked() ) - selectedSpinStyle = TEXT_SPIN_STYLE::LEFT; - else if( m_spin2->IsChecked() ) - selectedSpinStyle = TEXT_SPIN_STYLE::UP; - else if( m_spin3->IsChecked() ) - selectedSpinStyle = TEXT_SPIN_STYLE::BOTTOM; + if( m_spin0->IsChecked() ) + selectedSpinStyle = TEXT_SPIN_STYLE::RIGHT; + else if( m_spin1->IsChecked() ) + selectedSpinStyle = TEXT_SPIN_STYLE::LEFT; + else if( m_spin2->IsChecked() ) + selectedSpinStyle = TEXT_SPIN_STYLE::UP; + else if( m_spin3->IsChecked() ) + selectedSpinStyle = TEXT_SPIN_STYLE::BOTTOM; - if( m_currentText->GetTextSpinStyle() != selectedSpinStyle ) - m_currentText->SetTextSpinStyle( selectedSpinStyle ); + static_cast( m_currentItem )->SetTextSpinStyle( selectedSpinStyle ); + } + else + { + SCH_TEXTBOX* textBox = static_cast( m_currentItem ); - m_frame->UpdateItem( m_currentText, false, true ); + if( m_spin0->IsChecked() ) + { + textBox->SetTextAngle( ANGLE_HORIZONTAL ); + textBox->SetHorizJustify( GR_TEXT_H_ALIGN_LEFT ); + } + else if( m_spin1->IsChecked() ) + { + textBox->SetTextAngle( ANGLE_HORIZONTAL ); + textBox->SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT ); + } + else if( m_spin2->IsChecked() ) + { + textBox->SetTextAngle( ANGLE_VERTICAL ); + textBox->SetHorizJustify( GR_TEXT_H_ALIGN_LEFT ); + } + else if( m_spin3->IsChecked() ) + { + textBox->SetTextAngle( ANGLE_VERTICAL ); + textBox->SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT ); + } + + textBox->UpdateTextPosition(); + + STROKE_PARAMS stroke = textBox->GetStroke(); + + if( !m_borderWidth.IsIndeterminate() ) + stroke.SetWidth( m_borderWidth.GetValue() ); + + auto it = lineTypeNames.begin(); + std::advance( it, m_borderStyleCombo->GetSelection() ); + + if( it == lineTypeNames.end() ) + stroke.SetPlotStyle( PLOT_DASH_TYPE::DEFAULT ); + else + stroke.SetPlotStyle( it->first ); + + stroke.SetColor( m_borderColorSwatch->GetSwatchColor() ); + + textBox->SetStroke( stroke ); + + textBox->SetFillMode( m_filledCtrl->GetValue() ? FILL_T::FILLED_WITH_COLOR : FILL_T::NO_FILL ); + textBox->SetFillColor( m_fillColorSwatch->GetSwatchColor() ); + } + + m_frame->UpdateItem( m_currentItem, false, true ); m_frame->GetCanvas()->Refresh(); m_frame->OnModify(); @@ -302,3 +414,9 @@ void DIALOG_TEXT_PROPERTIES::onMultiLineTCLostFocus( wxFocusEvent& event ) event.Skip(); } + + +void DIALOG_TEXT_PROPERTIES::onFillSwatch( wxCommandEvent& aEvent ) +{ + m_filledCtrl->SetValue( true ); +} \ No newline at end of file diff --git a/eeschema/dialogs/dialog_text_properties.h b/eeschema/dialogs/dialog_text_properties.h index 8cddf9d253..fbe4218add 100644 --- a/eeschema/dialogs/dialog_text_properties.h +++ b/eeschema/dialogs/dialog_text_properties.h @@ -38,12 +38,13 @@ class HTML_MESSAGE_BOX; class DIALOG_TEXT_PROPERTIES : public DIALOG_TEXT_PROPERTIES_BASE { public: - DIALOG_TEXT_PROPERTIES( SCH_EDIT_FRAME* parent, SCH_TEXT* aTextItem ); + DIALOG_TEXT_PROPERTIES( SCH_EDIT_FRAME* parent, SCH_ITEM* aTextItem ); ~DIALOG_TEXT_PROPERTIES(); private: void onScintillaCharAdded( wxStyledTextEvent &aEvent ); void onSpinButton( wxCommandEvent &aEvent ); + void onFillSwatch( wxCommandEvent& aEvent ); void OnFormattingHelp( wxHyperlinkEvent& aEvent ) override; void onMultiLineTCLostFocus( wxFocusEvent& event ) override; @@ -52,8 +53,10 @@ private: bool TransferDataFromWindow() override; SCH_EDIT_FRAME* m_frame; - SCH_TEXT* m_currentText; + SCH_ITEM* m_currentItem; + EDA_TEXT* m_currentText; UNIT_BINDER m_textSize; + UNIT_BINDER m_borderWidth; SCINTILLA_TRICKS* m_scintillaTricks; HTML_MESSAGE_BOX* m_helpWindow; diff --git a/eeschema/dialogs/dialog_text_properties_base.cpp b/eeschema/dialogs/dialog_text_properties_base.cpp index f5fb605fcb..c3a7d5c044 100644 --- a/eeschema/dialogs/dialog_text_properties_base.cpp +++ b/eeschema/dialogs/dialog_text_properties_base.cpp @@ -6,6 +6,7 @@ /////////////////////////////////////////////////////////////////////////// #include "widgets/bitmap_button.h" +#include "widgets/color_swatch.h" #include "widgets/font_choice.h" #include "dialog_text_properties_base.h" @@ -137,13 +138,71 @@ DIALOG_TEXT_PROPERTIES_BASE::DIALOG_TEXT_PROPERTIES_BASE( wxWindow* parent, wxWi m_textEntrySizer->Add( m_textSizeLabel, wxGBPosition( 2, 0 ), wxGBSpan( 1, 1 ), wxRIGHT|wxALIGN_CENTER_VERTICAL, 5 ); m_textSizeCtrl = new wxTextCtrl( this, wxID_SIZE, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); - m_textEntrySizer->Add( m_textSizeCtrl, wxGBPosition( 2, 1 ), wxGBSpan( 1, 1 ), wxEXPAND|wxALIGN_CENTER_VERTICAL, 5 ); + m_textEntrySizer->Add( m_textSizeCtrl, wxGBPosition( 2, 1 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 ); m_textSizeUnits = new wxStaticText( this, wxID_ANY, _("mm"), wxDefaultPosition, wxDefaultSize, 0 ); m_textSizeUnits->Wrap( -1 ); m_textEntrySizer->Add( m_textSizeUnits, wxGBPosition( 2, 2 ), wxGBSpan( 1, 1 ), wxLEFT|wxALIGN_CENTER_VERTICAL, 5 ); + m_borderWidthLabel = new wxStaticText( this, wxID_ANY, _("Border width:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_borderWidthLabel->Wrap( -1 ); + m_textEntrySizer->Add( m_borderWidthLabel, wxGBPosition( 4, 0 ), wxGBSpan( 1, 1 ), wxRIGHT|wxALIGN_CENTER_VERTICAL, 5 ); + m_borderWidthCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( -1,-1 ), 0 ); + m_textEntrySizer->Add( m_borderWidthCtrl, wxGBPosition( 4, 1 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL, 5 ); + + m_borderWidthUnits = new wxStaticText( this, wxID_ANY, _("mm"), wxDefaultPosition, wxDefaultSize, 0 ); + m_borderWidthUnits->Wrap( -1 ); + m_textEntrySizer->Add( m_borderWidthUnits, wxGBPosition( 4, 2 ), wxGBSpan( 1, 1 ), wxLEFT|wxALIGN_CENTER_VERTICAL, 5 ); + + m_borderColorLabel = new wxStaticText( this, wxID_ANY, _("Border color:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_borderColorLabel->Wrap( -1 ); + m_textEntrySizer->Add( m_borderColorLabel, wxGBPosition( 5, 0 ), wxGBSpan( 1, 1 ), wxRIGHT|wxALIGN_CENTER_VERTICAL, 5 ); + + m_panelBorderColor = new wxPanel( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxBORDER_SIMPLE|wxTAB_TRAVERSAL ); + wxBoxSizer* bSizer2; + bSizer2 = new wxBoxSizer( wxVERTICAL ); + + m_borderColorSwatch = new COLOR_SWATCH( m_panelBorderColor, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 ); + bSizer2->Add( m_borderColorSwatch, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_CENTER_HORIZONTAL, 5 ); + + + m_panelBorderColor->SetSizer( bSizer2 ); + m_panelBorderColor->Layout(); + bSizer2->Fit( m_panelBorderColor ); + m_textEntrySizer->Add( m_panelBorderColor, wxGBPosition( 5, 1 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL, 5 ); + + m_borderStyleLabel = new wxStaticText( this, wxID_ANY, _("Border style:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_borderStyleLabel->Wrap( -1 ); + m_textEntrySizer->Add( m_borderStyleLabel, wxGBPosition( 6, 0 ), wxGBSpan( 1, 1 ), wxRIGHT|wxALIGN_CENTER_VERTICAL, 5 ); + + m_borderStyleCombo = new wxBitmapComboBox( this, wxID_ANY, _("Combo!"), wxDefaultPosition, wxDefaultSize, 0, NULL, wxCB_READONLY ); + m_borderStyleCombo->SetMinSize( wxSize( 240,-1 ) ); + + m_textEntrySizer->Add( m_borderStyleCombo, wxGBPosition( 6, 1 ), wxGBSpan( 1, 2 ), wxALIGN_CENTER_VERTICAL, 5 ); + + m_filledCtrl = new wxCheckBox( this, wxID_ANY, _("Background fill"), wxDefaultPosition, wxDefaultSize, 0 ); + m_textEntrySizer->Add( m_filledCtrl, wxGBPosition( 4, 3 ), wxGBSpan( 1, 2 ), wxLEFT, 100 ); + + m_fillColorLabel = new wxStaticText( this, wxID_ANY, _("Fill color:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_fillColorLabel->Wrap( -1 ); + m_textEntrySizer->Add( m_fillColorLabel, wxGBPosition( 5, 3 ), wxGBSpan( 1, 1 ), wxLEFT|wxALIGN_CENTER_VERTICAL, 100 ); + + m_panelFillColor = new wxPanel( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxBORDER_SIMPLE|wxTAB_TRAVERSAL ); + wxBoxSizer* bSizer21; + bSizer21 = new wxBoxSizer( wxVERTICAL ); + + m_fillColorSwatch = new COLOR_SWATCH( m_panelFillColor, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 ); + bSizer21->Add( m_fillColorSwatch, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_CENTER_HORIZONTAL, 5 ); + + + m_panelFillColor->SetSizer( bSizer21 ); + m_panelFillColor->Layout(); + bSizer21->Fit( m_panelFillColor ); + m_textEntrySizer->Add( m_panelFillColor, wxGBPosition( 5, 4 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL, 5 ); + + + m_textEntrySizer->AddGrowableCol( 1 ); m_textEntrySizer->AddGrowableCol( 4 ); bMainSizer->Add( m_textEntrySizer, 1, wxEXPAND|wxALL, 10 ); diff --git a/eeschema/dialogs/dialog_text_properties_base.fbp b/eeschema/dialogs/dialog_text_properties_base.fbp index a86e885d9f..f6f58bbca9 100644 --- a/eeschema/dialogs/dialog_text_properties_base.fbp +++ b/eeschema/dialogs/dialog_text_properties_base.fbp @@ -63,9 +63,9 @@ wxEXPAND|wxALL 1 - + -1,-1 wxBOTH - 4 + 1,4 0 @@ -345,16 +345,16 @@ wxEXPAND 1 1 - + bSizeCtrlSizer wxHORIZONTAL none - + 5 wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxLEFT 0 - + 1 1 1 @@ -422,11 +422,11 @@ - + 5 wxTOP|wxBOTTOM|wxALIGN_CENTER_VERTICAL 0 - + 1 1 1 @@ -494,11 +494,11 @@ - + 5 wxTOP|wxBOTTOM|wxALIGN_CENTER_VERTICAL 0 - + 1 1 1 @@ -566,11 +566,11 @@ - + 5 wxTOP|wxBOTTOM|wxALIGN_CENTER_VERTICAL 0 - + 1 1 1 @@ -638,11 +638,11 @@ - + 5 wxTOP|wxBOTTOM|wxALIGN_CENTER_VERTICAL 0 - + 1 1 1 @@ -710,11 +710,11 @@ - + 5 wxTOP|wxBOTTOM|wxALIGN_CENTER_VERTICAL 0 - + 1 1 1 @@ -782,11 +782,11 @@ - + 5 wxTOP|wxBOTTOM|wxALIGN_CENTER_VERTICAL 0 - + 1 1 1 @@ -854,11 +854,11 @@ - + 5 wxTOP|wxBOTTOM|wxALIGN_CENTER_VERTICAL 0 - + 1 1 1 @@ -926,11 +926,11 @@ - + 5 wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM 0 - + 1 1 1 @@ -1007,16 +1007,16 @@ wxEXPAND|wxALIGN_RIGHT|wxLEFT 1 1 - + bSizer41 wxVERTICAL none - + 5 wxRIGHT|wxLEFT 0 - + 1 1 1 @@ -1146,7 +1146,7 @@ 5 1 1 - wxEXPAND|wxALIGN_CENTER_VERTICAL + wxALIGN_CENTER_VERTICAL|wxEXPAND 2 1 @@ -1273,6 +1273,784 @@ -1 + + 5 + 1 + 0 + wxRIGHT|wxALIGN_CENTER_VERTICAL + 4 + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Border width: + 0 + + 0 + + + 0 + + 1 + m_borderWidthLabel + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + + + -1 + + + + 5 + 1 + 1 + wxALIGN_CENTER_VERTICAL + 4 + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + 0 + -1,-1 + 0 + -1,-1 + 1 + m_borderWidthCtrl + 1 + + + protected + 1 + + Resizable + 1 + -1,-1 + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + 5 + 1 + 2 + wxLEFT|wxALIGN_CENTER_VERTICAL + 4 + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + mm + 0 + + 0 + + + 0 + -1,-1 + 1 + m_borderWidthUnits + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + 5 + 1 + 0 + wxRIGHT|wxALIGN_CENTER_VERTICAL + 5 + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Border color: + 0 + + 0 + + + 0 + + 1 + m_borderColorLabel + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; Not forward_declare + 0 + + + + + -1 + + + + 5 + 1 + 1 + wxALIGN_CENTER_VERTICAL + 5 + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + + 1 + m_panelBorderColor + 1 + + + protected + 1 + + Resizable + 1 + + ; ; forward_declare + 0 + + + + wxBORDER_SIMPLE|wxTAB_TRAVERSAL + + + bSizer2 + wxVERTICAL + none + + 5 + wxALIGN_CENTER_VERTICAL|wxALIGN_CENTER_HORIZONTAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + COLOR_SWATCH + 1 + + + 1 + + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + + 0 + + + 0 + + 1 + m_borderColorSwatch + 1 + + + protected + 1 + + Resizable + + 1 + + COLOR_SWATCH; widgets/color_swatch.h; forward_declare + 0 + + + + + + + + + + + 5 + 1 + 0 + wxRIGHT|wxALIGN_CENTER_VERTICAL + 6 + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Border style: + 0 + + 0 + + + 0 + + 1 + m_borderStyleLabel + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + + + -1 + + + + 5 + 2 + 1 + wxALIGN_CENTER_VERTICAL + 6 + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + 240,-1 + 1 + m_borderStyleCombo + 1 + + + protected + 1 + + Resizable + -1 + 1 + + wxCB_READONLY + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + Combo! + + + + + + + 100 + 2 + 3 + wxLEFT + 4 + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Background fill + + 0 + + + 0 + + 1 + m_filledCtrl + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + 100 + 1 + 3 + wxLEFT|wxALIGN_CENTER_VERTICAL + 5 + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Fill color: + 0 + + 0 + + + 0 + + 1 + m_fillColorLabel + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + + + -1 + + + + 5 + 1 + 4 + wxALIGN_CENTER_VERTICAL + 5 + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + + 1 + m_panelFillColor + 1 + + + protected + 1 + + Resizable + 1 + + ; ; forward_declare + 0 + + + + wxBORDER_SIMPLE|wxTAB_TRAVERSAL + + + bSizer21 + wxVERTICAL + none + + 5 + wxALIGN_CENTER_VERTICAL|wxALIGN_CENTER_HORIZONTAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + COLOR_SWATCH + 1 + + + 1 + + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + + 0 + + + 0 + + 1 + m_fillColorSwatch + 1 + + + protected + 1 + + Resizable + + 1 + + COLOR_SWATCH; widgets/color_swatch.h; forward_declare + 0 + + + + + + + + + diff --git a/eeschema/dialogs/dialog_text_properties_base.h b/eeschema/dialogs/dialog_text_properties_base.h index e905eab300..ae76ca5f9f 100644 --- a/eeschema/dialogs/dialog_text_properties_base.h +++ b/eeschema/dialogs/dialog_text_properties_base.h @@ -11,6 +11,7 @@ #include #include class BITMAP_BUTTON; +class COLOR_SWATCH; class FONT_CHOICE; #include "dialog_shim.h" @@ -30,6 +31,9 @@ class FONT_CHOICE; #include #include #include +#include +#include +#include #include #include #include @@ -67,6 +71,18 @@ class DIALOG_TEXT_PROPERTIES_BASE : public DIALOG_SHIM wxStaticText* m_textSizeLabel; wxTextCtrl* m_textSizeCtrl; wxStaticText* m_textSizeUnits; + wxStaticText* m_borderWidthLabel; + wxTextCtrl* m_borderWidthCtrl; + wxStaticText* m_borderWidthUnits; + wxStaticText* m_borderColorLabel; + wxPanel* m_panelBorderColor; + COLOR_SWATCH* m_borderColorSwatch; + wxStaticText* m_borderStyleLabel; + wxBitmapComboBox* m_borderStyleCombo; + wxCheckBox* m_filledCtrl; + wxStaticText* m_fillColorLabel; + wxPanel* m_panelFillColor; + COLOR_SWATCH* m_fillColorSwatch; wxStaticLine* m_staticline; wxStdDialogButtonSizer* m_sdbSizer1; wxButton* m_sdbSizer1OK; diff --git a/eeschema/ee_collectors.cpp b/eeschema/ee_collectors.cpp index 18d5576dcb..5ca5d24f10 100644 --- a/eeschema/ee_collectors.cpp +++ b/eeschema/ee_collectors.cpp @@ -45,6 +45,7 @@ const KICAD_T EE_COLLECTOR::AllItems[] = { const KICAD_T EE_COLLECTOR::EditableItems[] = { SCH_SHAPE_T, SCH_TEXT_T, + SCH_TEXTBOX_T, SCH_LABEL_T, SCH_GLOBAL_LABEL_T, SCH_HIER_LABEL_T, @@ -84,6 +85,7 @@ const KICAD_T EE_COLLECTOR::MovableItems[] = SCH_BITMAP_T, SCH_SHAPE_T, SCH_TEXT_T, + SCH_TEXTBOX_T, SCH_LABEL_T, SCH_GLOBAL_LABEL_T, SCH_HIER_LABEL_T, diff --git a/eeschema/erc.cpp b/eeschema/erc.cpp index 1b79aa40f3..1ffbfefa37 100644 --- a/eeschema/erc.cpp +++ b/eeschema/erc.cpp @@ -33,6 +33,7 @@ #include #include #include +#include #include #include #include @@ -256,6 +257,18 @@ void ERC_TESTER::TestTextVars( DS_PROXY_VIEW_ITEM* aDrawingSheet ) screen->Append( marker ); } } + else if( SCH_TEXTBOX* textBox = dynamic_cast( item ) ) + { + if( textBox->GetShownText().Matches( wxT( "*${*}*" ) ) ) + { + std::shared_ptr ercItem = + ERC_ITEM::Create( ERCE_UNRESOLVED_VARIABLE ); + ercItem->SetItems( textBox ); + + SCH_MARKER* marker = new SCH_MARKER( ercItem, textBox->GetPosition() ); + screen->Append( marker ); + } + } } for( DS_DRAW_ITEM_BASE* item = wsItems.GetFirst(); item; item = wsItems.GetNext() ) @@ -629,7 +642,7 @@ int ERC_TESTER::TestSimilarLabels() int errors = 0; - std::unordered_map labelMap; + std::unordered_map labelMap; for( const std::pair> net : nets ) { @@ -645,20 +658,20 @@ int ERC_TESTER::TestSimilarLabels() case SCH_HIER_LABEL_T: case SCH_GLOBAL_LABEL_T: { - SCH_TEXT* text = static_cast( item ); + SCH_LABEL_BASE* label = static_cast( item ); - wxString normalized = text->GetShownText().Lower(); + wxString normalized = label->GetShownText().Lower(); if( !labelMap.count( normalized ) ) { - labelMap[normalized] = text; + labelMap[normalized] = label; } - else if( labelMap.at( normalized )->GetShownText() != text->GetShownText() ) + else if( labelMap.at( normalized )->GetShownText() != label->GetShownText() ) { std::shared_ptr ercItem = ERC_ITEM::Create( ERCE_SIMILAR_LABELS ); - ercItem->SetItems( text, labelMap.at( normalized ) ); + ercItem->SetItems( label, labelMap.at( normalized ) ); - SCH_MARKER* marker = new SCH_MARKER( ercItem, text->GetPosition() ); + SCH_MARKER* marker = new SCH_MARKER( ercItem, label->GetPosition() ); subgraph->m_sheet.LastScreen()->Append( marker ); errors += 1; } diff --git a/eeschema/invoke_sch_dialog.h b/eeschema/invoke_sch_dialog.h index c792c875ed..9bdfec80b8 100644 --- a/eeschema/invoke_sch_dialog.h +++ b/eeschema/invoke_sch_dialog.h @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2013 SoftPLC Corporation, Dick Hollenbeck - * Copyright (C) 2013-2021 KiCad Developers, see change_log.txt for contributors. + * Copyright (C) 2013-2022 KiCad Developers, see change_log.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 @@ -44,16 +44,8 @@ #include #include -class wxFrame; -class wxDialog; -class SYMBOL_LIBS; -class SCH_SYMBOL; -class SCH_TEXT; class SCH_SHEET_PATH; class RESCUER; - -// Often this is not used in the prototypes, since wxFrame is good enough and would -// represent maximum information hiding. class SCH_EDIT_FRAME; /** diff --git a/eeschema/lib_item.cpp b/eeschema/lib_item.cpp index b20f9ce6e5..72cfacae98 100644 --- a/eeschema/lib_item.cpp +++ b/eeschema/lib_item.cpp @@ -38,7 +38,8 @@ const int fill_tab[3] = { 'N', 'F', 'f' }; LIB_ITEM::LIB_ITEM( KICAD_T aType, LIB_SYMBOL* aSymbol, int aUnit, int aConvert ) : EDA_ITEM( aSymbol, aType ), m_unit( aUnit ), - m_convert( aConvert ) + m_convert( aConvert ), + m_private( false ) { } diff --git a/eeschema/lib_item.h b/eeschema/lib_item.h index 0924f759e0..05c95b6e83 100644 --- a/eeschema/lib_item.h +++ b/eeschema/lib_item.h @@ -262,6 +262,9 @@ public: void SetConvert( int aConvert ) { m_convert = aConvert; } int GetConvert() const { return m_convert; } + void SetPrivate( bool aPrivate ) { m_private = aPrivate; } + bool IsPrivate() const { return m_private; } + #if defined(DEBUG) void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); } #endif @@ -316,6 +319,11 @@ protected: * body styles. This is typially used for representing DeMorgan variants in KiCad. */ int m_convert; + + /** + * Private items are shown only in the Symbol Editor. + */ + bool m_private; }; diff --git a/eeschema/lib_shape.cpp b/eeschema/lib_shape.cpp index 94f10432ea..2578bbb667 100644 --- a/eeschema/lib_shape.cpp +++ b/eeschema/lib_shape.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2017 Jean-Pierre Charras, jp.charras at wanadoo.fr - * Copyright (C) 2004-20212KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2004-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 @@ -33,8 +33,9 @@ #include -LIB_SHAPE::LIB_SHAPE( LIB_SYMBOL* aParent, SHAPE_T aShape, int aLineWidth, FILL_T aFillType ) : - LIB_ITEM( LIB_SHAPE_T, aParent ), +LIB_SHAPE::LIB_SHAPE( LIB_SYMBOL* aParent, SHAPE_T aShape, int aLineWidth, FILL_T aFillType, + KICAD_T aType ) : + LIB_ITEM( aType, aParent ), EDA_SHAPE( aShape, aLineWidth, aFillType, true ) { m_editState = 0; @@ -113,11 +114,11 @@ void LIB_SHAPE::Plot( PLOTTER* aPlotter, const VECTOR2I& aOffset, bool aFill, { VECTOR2I start = aTransform.TransformCoordinate( m_start ) + aOffset; VECTOR2I end = aTransform.TransformCoordinate( m_end ) + aOffset; - VECTOR2I center; - EDA_ANGLE startAngle; - EDA_ANGLE endAngle; - int pen_size = GetEffectivePenWidth( aPlotter->RenderSettings() ); + VECTOR2I center = aTransform.TransformCoordinate( getCenter() ) + aOffset; + int penWidth = GetEffectivePenWidth( aPlotter->RenderSettings() ); FILL_T fill = aFill ? m_fill : FILL_T::NO_FILL; + COLOR4D color = aPlotter->RenderSettings()->GetLayerColor( IsPrivate() ? LAYER_NOTES + : LAYER_DEVICE ); static std::vector cornerList; @@ -136,26 +137,29 @@ void LIB_SHAPE::Plot( PLOTTER* aPlotter, const VECTOR2I& aOffset, bool aFill, for( const VECTOR2I& pt : m_bezierPoints ) cornerList.push_back( aTransform.TransformCoordinate( pt ) + aOffset ); } - else if( GetShape() == SHAPE_T::ARC ) - { - center = aTransform.TransformCoordinate( getCenter() ) + aOffset; - CalcArcAngles( startAngle, endAngle ); - aTransform.MapAngles( &startAngle, &endAngle ); - } - - if( fill == FILL_T::FILLED_WITH_BG_BODYCOLOR ) + if( fill != FILL_T::NO_FILL ) { - aPlotter->SetColor( aPlotter->RenderSettings()->GetLayerColor( LAYER_DEVICE_BACKGROUND ) ); + COLOR4D fillColor = color; + + if( aPlotter->GetColorMode() ) + { + if( fill == FILL_T::FILLED_WITH_BG_BODYCOLOR ) + fillColor = aPlotter->RenderSettings()->GetLayerColor( LAYER_DEVICE_BACKGROUND ); + else if( fill == FILL_T::FILLED_WITH_COLOR ) + fillColor = GetFillColor(); + } + + aPlotter->SetColor( fillColor ); switch( GetShape() ) { case SHAPE_T::ARC: - aPlotter->Arc( center, -endAngle, -startAngle, GetRadius(), fill, 0 ); + aPlotter->Arc( center, start, end, fill, 0, ARC_HIGH_DEF ); break; case SHAPE_T::CIRCLE: - aPlotter->Circle( start, GetRadius() * 2, fill, 0 ); + aPlotter->Circle( center, GetRadius() * 2, fill, 0 ); break; case SHAPE_T::RECT: @@ -171,31 +175,31 @@ void LIB_SHAPE::Plot( PLOTTER* aPlotter, const VECTOR2I& aOffset, bool aFill, UNIMPLEMENTED_FOR( SHAPE_T_asString() ); } - if( pen_size <= 0 ) + if( penWidth <= 0 ) return; else fill = FILL_T::NO_FILL; } - aPlotter->SetColor( aPlotter->RenderSettings()->GetLayerColor( LAYER_DEVICE ) ); + aPlotter->SetColor( color ); switch( GetShape() ) { case SHAPE_T::ARC: - aPlotter->Arc( center, -endAngle, -startAngle, GetRadius(), fill, pen_size ); + aPlotter->Arc( center, start, end, fill, penWidth, ARC_HIGH_DEF ); break; case SHAPE_T::CIRCLE: - aPlotter->Circle( start, GetRadius() * 2, fill, pen_size ); + aPlotter->Circle( center, GetRadius() * 2, fill, penWidth ); break; case SHAPE_T::RECT: - aPlotter->Rect( start, end, fill, pen_size ); + aPlotter->Rect( start, end, fill, penWidth ); break; case SHAPE_T::POLY: case SHAPE_T::BEZIER: - aPlotter->PlotPoly( cornerList, fill, pen_size ); + aPlotter->PlotPoly( cornerList, fill, penWidth ); break; default: @@ -223,8 +227,7 @@ void LIB_SHAPE::print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset VECTOR2I pt1 = aTransform.TransformCoordinate( m_start ) + aOffset; VECTOR2I pt2 = aTransform.TransformCoordinate( m_end ) + aOffset; VECTOR2I c; - COLOR4D color = aSettings->GetLayerColor( LAYER_DEVICE ); - COLOR4D fillColor = color; + COLOR4D color = aSettings->GetLayerColor( IsPrivate() ? LAYER_NOTES : LAYER_DEVICE ); unsigned ptCount = 0; VECTOR2I* buffer = nullptr; @@ -291,8 +294,12 @@ void LIB_SHAPE::print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset } else { + COLOR4D fillColor = color; + if( GetFillMode() == FILL_T::FILLED_WITH_BG_BODYCOLOR ) fillColor = aSettings->GetLayerColor( LAYER_DEVICE_BACKGROUND ); + else if( GetFillMode() == FILL_T::FILLED_WITH_COLOR ) + fillColor = GetFillColor(); switch( GetShape() ) { @@ -421,3 +428,12 @@ void LIB_SHAPE::AddPoint( const VECTOR2I& aPosition ) } + + +void LIB_SHAPE::ViewGetLayers( int aLayers[], int& aCount ) const +{ + aCount = 3; + aLayers[0] = IsPrivate() ? LAYER_NOTES : LAYER_DEVICE; + aLayers[1] = IsPrivate() ? LAYER_NOTES_BACKGROUND : LAYER_DEVICE_BACKGROUND; + aLayers[2] = LAYER_SELECTION_SHADOWS; +} diff --git a/eeschema/lib_shape.h b/eeschema/lib_shape.h index ca3d8d10ad..9ef8b7b79e 100644 --- a/eeschema/lib_shape.h +++ b/eeschema/lib_shape.h @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com - * Copyright (C) 2004-2021 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2004-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 @@ -33,7 +33,7 @@ class LIB_SHAPE : public LIB_ITEM, public EDA_SHAPE { public: LIB_SHAPE( LIB_SYMBOL* aParent, SHAPE_T aShape, int aLineWidth = 0, - FILL_T aFillType = FILL_T::NO_FILL ); + FILL_T aFillType = FILL_T::NO_FILL, KICAD_T aType = LIB_SHAPE_T ); // Do not create a copy constructor. The one generated by the compiler is adequate. @@ -78,8 +78,8 @@ public: bool ContinueEdit( const VECTOR2I& aPosition ) override { return continueEdit( aPosition ); } void CalcEdit( const VECTOR2I& aPosition ) override { calcEdit( aPosition ); } - void EndEdit() override { endEdit( false ); } - void SetEditState( int aState ) { setEditState( aState ); } + void EndEdit() override { endEdit( false ); } + void SetEditState( int aState ) { setEditState( aState ); } void AddPoint( const VECTOR2I& aPosition ); @@ -87,7 +87,7 @@ public: void MoveTo( const VECTOR2I& aPosition ) override; - VECTOR2I GetPosition() const override { return getPosition(); } + VECTOR2I GetPosition() const override { return getPosition(); } void SetPosition( const VECTOR2I& aPosition ) override { setPosition( aPosition ); } VECTOR2I GetCenter() const { return getCenter(); } @@ -105,6 +105,8 @@ public: EDA_ITEM* Clone() const override; + void ViewGetLayers( int aLayers[], int& aCount ) const override; + private: /** * @copydoc LIB_ITEM::compare() diff --git a/eeschema/lib_textbox.cpp b/eeschema/lib_textbox.cpp new file mode 100644 index 0000000000..7263dc0f8c --- /dev/null +++ b/eeschema/lib_textbox.cpp @@ -0,0 +1,415 @@ +/* + * 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 + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +using KIGFX::SCH_RENDER_SETTINGS; + + +LIB_TEXTBOX::LIB_TEXTBOX( LIB_SYMBOL* aParent, int aLineWidth, FILL_T aFillType, + const wxString& text ) : + LIB_SHAPE( aParent, SHAPE_T::RECT, aLineWidth, aFillType, LIB_TEXTBOX_T ), + EDA_TEXT( text ) +{ + SetTextSize( wxSize( Mils2iu( DEFAULT_TEXT_SIZE ), Mils2iu( DEFAULT_TEXT_SIZE ) ) ); + SetHorizJustify( GR_TEXT_H_ALIGN_LEFT ); + SetVertJustify( GR_TEXT_V_ALIGN_TOP ); + SetMultilineAllowed( true ); +} + + +LIB_TEXTBOX::LIB_TEXTBOX( const LIB_TEXTBOX& aText ) : + LIB_SHAPE( aText ), + EDA_TEXT( aText ) +{ } + + +int LIB_TEXTBOX::GetTextMargin() const +{ + return KiROUND( GetTextSize().y * 0.8 ); +} + + +void LIB_TEXTBOX::Offset( const VECTOR2I& aOffset ) +{ + LIB_SHAPE::Offset( aOffset ); + UpdateTextPosition(); +} + + +void LIB_TEXTBOX::MoveTo( const VECTOR2I& newPosition ) +{ + LIB_SHAPE::MoveTo( newPosition ); + UpdateTextPosition(); +} + + +void LIB_TEXTBOX::MirrorHorizontally( const VECTOR2I& center ) +{ + // Text is NOT really mirrored; it just has its justification flipped + if( GetTextAngle() == ANGLE_HORIZONTAL ) + { + SetHorizJustify( GetHorizJustify() == GR_TEXT_H_ALIGN_RIGHT ? GR_TEXT_H_ALIGN_LEFT + : GR_TEXT_H_ALIGN_RIGHT ); + } + + UpdateTextPosition(); +} + + +void LIB_TEXTBOX::MirrorVertically( const VECTOR2I& center ) +{ + // Text is NOT really mirrored; it just has its justification flipped + if( GetTextAngle() == ANGLE_VERTICAL ) + { + SetHorizJustify( GetHorizJustify() == GR_TEXT_H_ALIGN_RIGHT ? GR_TEXT_H_ALIGN_LEFT + : GR_TEXT_H_ALIGN_RIGHT ); + } + + UpdateTextPosition(); +} + + +void LIB_TEXTBOX::Rotate( const VECTOR2I& aCenter, bool aRotateCCW ) +{ + LIB_SHAPE::Rotate( aCenter, aRotateCCW ); + + SetTextAngle( GetTextAngle() == ANGLE_VERTICAL ? ANGLE_HORIZONTAL : ANGLE_VERTICAL ); + UpdateTextPosition(); +} + + +void LIB_TEXTBOX::UpdateTextPosition() +{ + int margin = GetTextMargin(); + BOX2I bbox( VECTOR2I( std::min( m_start.x, m_end.x ), std::min( -m_start.y, -m_end.y ) ), + VECTOR2I( abs( m_end.x - m_start.x ), abs( m_end.y - m_start.y ) ) ); + + if( GetTextAngle() == ANGLE_HORIZONTAL ) + { + if( GetHorizJustify() == GR_TEXT_H_ALIGN_RIGHT ) + SetTextPos( VECTOR2I( bbox.GetRight() - margin, bbox.GetTop() + margin ) ); + else + SetTextPos( VECTOR2I( bbox.GetLeft() + margin, bbox.GetTop() + margin ) ); + } + else + { + if( GetHorizJustify() == GR_TEXT_H_ALIGN_RIGHT ) + SetTextPos( VECTOR2I( bbox.GetLeft() + margin, bbox.GetTop() + margin ) ); + else + SetTextPos( VECTOR2I( bbox.GetLeft() + margin, bbox.GetBottom() - margin ) ); + } +} + + +int LIB_TEXTBOX::compare( const LIB_ITEM& aOther, LIB_ITEM::COMPARE_FLAGS aCompareFlags ) const +{ + wxASSERT( aOther.Type() == LIB_TEXTBOX_T ); + + int retv = LIB_ITEM::compare( aOther, aCompareFlags ); + + if( retv ) + return retv; + + const LIB_TEXTBOX* tmp = static_cast( &aOther ); + + int result = GetText().CmpNoCase( tmp->GetText() ); + + if( result != 0 ) + return result; + + if( GetTextWidth() != tmp->GetTextWidth() ) + return GetTextWidth() - tmp->GetTextWidth(); + + if( GetTextHeight() != tmp->GetTextHeight() ) + return GetTextHeight() - tmp->GetTextHeight(); + + if( IsBold() != tmp->IsBold() ) + return IsBold() - tmp->IsBold(); + + if( IsItalic() != tmp->IsItalic() ) + return IsItalic() - tmp->IsItalic(); + + if( GetHorizJustify() != tmp->GetHorizJustify() ) + return GetHorizJustify() - tmp->GetHorizJustify(); + + if( GetTextAngle().AsTenthsOfADegree() != tmp->GetTextAngle().AsTenthsOfADegree() ) + return GetTextAngle().AsTenthsOfADegree() - tmp->GetTextAngle().AsTenthsOfADegree(); + + return EDA_SHAPE::Compare( &static_cast( aOther ) ); +} + + +int LIB_TEXTBOX::GetPenWidth() const +{ + return GetEffectiveTextPenWidth(); +} + + +KIFONT::FONT* LIB_TEXTBOX::GetDrawFont() const +{ + KIFONT::FONT* font = EDA_TEXT::GetFont(); + + if( !font ) + font = KIFONT::FONT::GetFont( GetDefaultFont(), IsBold(), IsItalic() ); + + return font; +} + + +void LIB_TEXTBOX::print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset, void* aData, + const TRANSFORM& aTransform ) +{ + bool forceNoFill = static_cast( aData ); + int penWidth = GetEffectivePenWidth( aSettings ); + + if( forceNoFill && IsFilled() && penWidth == 0 ) + return; + + wxDC* DC = aSettings->GetPrintDC(); + VECTOR2I pt1 = aTransform.TransformCoordinate( m_start ) + aOffset; + VECTOR2I pt2 = aTransform.TransformCoordinate( m_end ) + aOffset; + COLOR4D color = aSettings->GetLayerColor( IsPrivate() ? LAYER_NOTES : LAYER_DEVICE ); + + if( !forceNoFill && GetFillMode() == FILL_T::FILLED_WITH_COLOR ) + { + GRFilledRect( nullptr, DC, pt1.x, pt1.y, pt2.x, pt2.y, penWidth, color, GetFillColor() ); + } + + if( GetStroke().GetColor() != COLOR4D::UNSPECIFIED ) + color = GetStroke().GetColor(); + + penWidth = std::max( penWidth, aSettings->GetDefaultPenWidth() ); + + if( GetStroke().GetPlotStyle() <= PLOT_DASH_TYPE::FIRST_TYPE ) + { + GRRect( nullptr, DC, pt1.x, pt1.y, pt2.x, pt2.y, penWidth, color ); + } + else + { + std::vector shapes = MakeEffectiveShapes( true ); + + for( SHAPE* shape : shapes ) + { + STROKE_PARAMS::Stroke( shape, GetStroke().GetPlotStyle(), penWidth, aSettings, + [&]( const VECTOR2I& a, const VECTOR2I& b ) + { + GRLine( nullptr, DC, a.x, a.y, b.x, b.y, penWidth, color ); + } ); + } + + for( SHAPE* shape : shapes ) + delete shape; + } + + // Calculate the text orientation, according to the symbol orientation/mirror (needed when + // draw text in schematic) + EDA_ANGLE orient = GetTextAngle(); + + if( aTransform.y1 ) // Rotate symbol 90 degrees. + { + if( orient == ANGLE_HORIZONTAL ) + orient = ANGLE_VERTICAL; + else + orient = ANGLE_HORIZONTAL; + } + + /* + * Calculate the text justification, according to the symbol orientation/mirror. + * This is a bit complicated due to cumulative calculations: + * - numerous cases (mirrored or not, rotation) + * - the GRText function will also recalculate H and V justifications according to the text + * orientation. + * - When a symbol is mirrored, the text is not mirrored and justifications are complicated + * to calculate so the more easily way is to use no justifications (centered text) and + * use GetBoundingBox to know the text coordinate considered as centered + */ + EDA_RECT bBox = GetBoundingBox(); + + // convert coordinates from draw Y axis to symbol_editor Y axis: + bBox.RevertYAxis(); + VECTOR2I txtpos = bBox.Centre(); + + // Calculate pos according to mirror/rotation. + txtpos = aTransform.TransformCoordinate( txtpos ) + aOffset; + + GRPrintText( DC, txtpos, color, GetShownText(), orient, GetTextSize(), GR_TEXT_H_ALIGN_CENTER, + GR_TEXT_V_ALIGN_CENTER, penWidth, IsItalic(), IsBold(), GetDrawFont() ); +} + + +wxString LIB_TEXTBOX::GetShownText( int aDepth ) const +{ + wxString text = EDA_TEXT::GetShownText(); + + KIFONT::FONT* font = GetDrawFont(); + VECTOR2D size = GetEnd() - GetStart(); + int colWidth = GetTextAngle() == ANGLE_HORIZONTAL ? size.x : size.y; + + colWidth = abs( colWidth ) - GetTextMargin() * 2; + font->LinebreakText( text, colWidth, GetTextSize(), GetTextThickness(), IsBold(), IsItalic() ); + + return text; +} + + +bool LIB_TEXTBOX::HitTest( const VECTOR2I& aPosition, int aAccuracy ) const +{ + if( aAccuracy < Mils2iu( MINIMUM_SELECTION_DISTANCE ) ) + aAccuracy = Mils2iu( MINIMUM_SELECTION_DISTANCE ); + + EDA_RECT rect = GetBoundingBox(); + + rect.Inflate( aAccuracy ); + + return rect.Contains( aPosition ); +} + + +bool LIB_TEXTBOX::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) const +{ + EDA_RECT rect = aRect; + + rect.Inflate( aAccuracy ); + + if( aContained ) + return rect.Contains( GetBoundingBox() ); + + return rect.Intersects( GetBoundingBox() ); +} + + +wxString LIB_TEXTBOX::GetSelectMenuText( EDA_UNITS aUnits ) const +{ + return wxString::Format( _( "Graphic Text Box" ) ); +} + + +BITMAPS LIB_TEXTBOX::GetMenuImage() const +{ + return BITMAPS::add_textbox; +} + + +void LIB_TEXTBOX::Plot( PLOTTER* aPlotter, const VECTOR2I& aOffset, bool aFill, + const TRANSFORM& aTransform ) const +{ + wxASSERT( aPlotter != nullptr ); + + VECTOR2I start = aTransform.TransformCoordinate( m_start ) + aOffset; + VECTOR2I end = aTransform.TransformCoordinate( m_end ) + aOffset; + int penWidth = GetEffectivePenWidth( aPlotter->RenderSettings() ); + FILL_T fill = aFill ? m_fill : FILL_T::NO_FILL; + COLOR4D color = aPlotter->RenderSettings()->GetLayerColor( IsPrivate() ? LAYER_NOTES + : LAYER_DEVICE ); + if( fill != FILL_T::NO_FILL ) + { + COLOR4D fillColor = color; + + if( aPlotter->GetColorMode() ) + { + if( fill == FILL_T::FILLED_WITH_BG_BODYCOLOR ) + fillColor = aPlotter->RenderSettings()->GetLayerColor( LAYER_DEVICE_BACKGROUND ); + else if( fill == FILL_T::FILLED_WITH_COLOR ) + fillColor = GetFillColor(); + } + + aPlotter->SetColor( fillColor ); + aPlotter->Rect( start, end, fill, 0 ); + + fill = FILL_T::NO_FILL; + } + + aPlotter->SetColor( color ); + aPlotter->Rect( start, end, fill, penWidth ); + + KIFONT::FONT* font = GetDrawFont(); + LIB_TEXTBOX text( *this ); + + penWidth = std::max( GetEffectiveTextPenWidth(), aPlotter->RenderSettings()->GetMinPenWidth() ); + + if( aTransform.y1 != 0 && aTransform.x2 != 0 ) + { + text.SetTextAngle( text.GetTextAngle() == ANGLE_HORIZONTAL ? ANGLE_VERTICAL + : ANGLE_HORIZONTAL ); + } + + // NB: UpdateTextPosition() wants Symbol Editor (upside-down) coordinates + text.SetStart( VECTOR2I( start.x, -start.y ) ); + text.SetEnd( VECTOR2I( end.x, -end.y ) ); + text.UpdateTextPosition(); + + std::vector positions; + wxArrayString strings_list; + wxStringSplit( GetShownText(), strings_list, '\n' ); + positions.reserve( strings_list.Count() ); + + text.GetLinePositions( positions, (int) strings_list.Count() ); + + for( unsigned ii = 0; ii < strings_list.Count(); ii++ ) + { + aPlotter->Text( positions[ii], color, strings_list.Item( ii ), text.GetTextAngle(), + text.GetTextSize(), text.GetHorizJustify(), text.GetVertJustify(), + penWidth, text.IsItalic(), text.IsBold(), false, font ); + } +} + + +void LIB_TEXTBOX::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector& aList ) +{ + wxString msg; + + // Don't use GetShownText() here; we want to show the user the variable references + aList.emplace_back( _( "Text Box" ), UnescapeString( GetText() ) ); + + wxString textStyle[] = { _( "Normal" ), _( "Italic" ), _( "Bold" ), _( "Bold Italic" ) }; + int style = IsBold() && IsItalic() ? 3 : IsBold() ? 2 : IsItalic() ? 1 : 0; + aList.emplace_back( _( "Style" ), textStyle[style] ); + + aList.emplace_back( _( "Text Size" ), MessageTextFromValue( aFrame->GetUserUnits(), + GetTextWidth() ) ); +} + + +void LIB_TEXTBOX::ViewGetLayers( int aLayers[], int& aCount ) const +{ + aCount = 3; + aLayers[0] = IsPrivate() ? LAYER_NOTES : LAYER_DEVICE; + aLayers[1] = IsPrivate() ? LAYER_NOTES_BACKGROUND : LAYER_DEVICE_BACKGROUND; + aLayers[2] = LAYER_SELECTION_SHADOWS; +} diff --git a/eeschema/lib_textbox.h b/eeschema/lib_textbox.h new file mode 100644 index 0000000000..ae7df0c93c --- /dev/null +++ b/eeschema/lib_textbox.h @@ -0,0 +1,112 @@ +/* + * 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 LIB_TEXTBOX_H +#define LIB_TEXTBOX_H + + +#include +#include + + +class HTML_MESSAGE_BOX; + +class LIB_TEXTBOX : public LIB_SHAPE, public EDA_TEXT +{ +public: + LIB_TEXTBOX( LIB_SYMBOL* aParent, int aLineWidth = 0, FILL_T aFillType = FILL_T::NO_FILL, + const wxString& aText = wxEmptyString ); + + LIB_TEXTBOX( const LIB_TEXTBOX& aText ); + + ~LIB_TEXTBOX() { } + + static inline bool ClassOf( const EDA_ITEM* aItem ) + { + return aItem && aItem->Type() == LIB_TEXTBOX_T; + } + + virtual wxString GetClass() const override + { + return wxT( "LIB_TEXTBOX" ); + } + + int GetTextMargin() const; + + void UpdateTextPosition(); + + wxString GetShownText( int aDepth = 0 ) const override; + + int GetPenWidth() const override; + + KIFONT::FONT* GetDrawFont() const override; + + void Offset( const VECTOR2I& aOffset ) override; + void MoveTo( const VECTOR2I& newPosition ) override; + + void MirrorHorizontally( const VECTOR2I& center ); + void MirrorVertically( const VECTOR2I& center ); + void Rotate( const VECTOR2I& aCenter, bool aRotateCCW ) override; + + bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override; + + bool HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy = 0 ) const override; + + bool Matches( const wxFindReplaceData& aSearchData, void* aAuxData ) const override + { + return LIB_ITEM::Matches( GetText(), aSearchData ); + } + + bool Replace( const wxFindReplaceData& aSearchData, void* aAuxData ) override + { + return EDA_TEXT::Replace( aSearchData ); + } + + virtual bool IsReplaceable() const override { return true; } + + wxString GetSelectMenuText( EDA_UNITS aUnits ) const override; + + BITMAPS GetMenuImage() const override; + + void Plot( PLOTTER* aPlotter, const VECTOR2I& offset, bool fill, + const TRANSFORM& aTransform ) const override; + + EDA_ITEM* Clone() const override + { + return new LIB_TEXTBOX( *this ); + } + + void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector& aList ) override; + + void ViewGetLayers( int aLayers[], int& aCount ) const override; + +private: + int compare( const LIB_ITEM& aOther, + LIB_ITEM::COMPARE_FLAGS aCompareFlags = LIB_ITEM::COMPARE_FLAGS::NORMAL ) const override; + + void print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset, void* aData, + const TRANSFORM& aTransform ) override; +}; + + +#endif /* LIB_TEXTBOX_H */ diff --git a/eeschema/menubar.cpp b/eeschema/menubar.cpp index 9cbc30febb..5910cdb2b0 100644 --- a/eeschema/menubar.cpp +++ b/eeschema/menubar.cpp @@ -220,11 +220,12 @@ void SCH_EDIT_FRAME::ReCreateMenuBar() placeMenu->Add( EE_ACTIONS::importSheetPin ); placeMenu->AppendSeparator(); + placeMenu->Add( EE_ACTIONS::placeSchematicText ); + placeMenu->Add( EE_ACTIONS::drawTextBox ); placeMenu->Add( EE_ACTIONS::drawRectangle ); placeMenu->Add( EE_ACTIONS::drawCircle ); placeMenu->Add( EE_ACTIONS::drawArc ); placeMenu->Add( EE_ACTIONS::drawLines ); - placeMenu->Add( EE_ACTIONS::placeSchematicText ); placeMenu->Add( EE_ACTIONS::placeImage ); diff --git a/eeschema/netlist_exporters/netlist_exporter_pspice.cpp b/eeschema/netlist_exporters/netlist_exporter_pspice.cpp index c5583afca6..df077fa1af 100644 --- a/eeschema/netlist_exporters/netlist_exporter_pspice.cpp +++ b/eeschema/netlist_exporters/netlist_exporter_pspice.cpp @@ -3,7 +3,7 @@ * * Copyright (C) 1992-2013 jp.charras at wanadoo.fr * Copyright (C) 2013 SoftPLC Corporation, Dick Hollenbeck - * Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.TXT for contributors. + * Copyright (C) 1992-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 @@ -38,6 +38,7 @@ #include #include #include +#include #include #include @@ -469,14 +470,21 @@ void NETLIST_EXPORTER_PSPICE::UpdateDirectives( unsigned aCtl ) wxRE_ADVANCED ); m_directives.clear(); - bool controlBlock = false; - bool circuitBlock = false; + + bool controlBlock = false; + bool circuitBlock = false; + wxString text; for( unsigned i = 0; i < sheetList.size(); i++ ) { - for( SCH_ITEM* item : sheetList[i].LastScreen()->Items().OfType( SCH_TEXT_T ) ) + for( SCH_ITEM* item : sheetList[i].LastScreen()->Items() ) { - wxString text = static_cast( item )->GetShownText(); + if( item->Type() == SCH_TEXT_T ) + text = static_cast( item )->GetShownText(); + else if( item->Type() == SCH_TEXTBOX_T ) + text = static_cast( item )->GetShownText(); + else + continue; if( text.IsEmpty() ) continue; diff --git a/eeschema/sch_edit_frame.cpp b/eeschema/sch_edit_frame.cpp index c721177baa..92ec27e36d 100644 --- a/eeschema/sch_edit_frame.cpp +++ b/eeschema/sch_edit_frame.cpp @@ -519,8 +519,12 @@ void SCH_EDIT_FRAME::setupUIConditions() CURRENT_TOOL( EE_ACTIONS::placeHierLabel ); CURRENT_TOOL( EE_ACTIONS::drawSheet ); CURRENT_TOOL( EE_ACTIONS::importSheetPin ); + CURRENT_TOOL( EE_ACTIONS::drawRectangle ); + CURRENT_TOOL( EE_ACTIONS::drawCircle ); + CURRENT_TOOL( EE_ACTIONS::drawArc ); CURRENT_TOOL( EE_ACTIONS::drawLines ); CURRENT_TOOL( EE_ACTIONS::placeSchematicText ); + CURRENT_TOOL( EE_ACTIONS::drawTextBox ); CURRENT_TOOL( EE_ACTIONS::placeImage ); #undef CURRENT_TOOL @@ -1177,7 +1181,7 @@ bool SCH_EDIT_FRAME::isAutoSaveRequired() const } -static void inheritNetclass( const SCH_SHEET_PATH& aSheetPath, SCH_TEXT* aItem ) +static void inheritNetclass( const SCH_SHEET_PATH& aSheetPath, SCH_LABEL_BASE* aItem ) { if( CONNECTION_SUBGRAPH::GetDriverPriority( aItem ) == CONNECTION_SUBGRAPH::PRIORITY::NONE ) return; @@ -1285,8 +1289,8 @@ void SCH_EDIT_FRAME::AddItemToScreenAndUndoList( SCH_SCREEN* aScreen, SCH_ITEM* { RecalculateConnections( LOCAL_CLEANUP ); - if( SCH_TEXT* textItem = dynamic_cast( aItem ) ) - inheritNetclass( GetCurrentSheet(), textItem ); + if( SCH_LABEL_BASE* label = dynamic_cast( aItem ) ) + inheritNetclass( GetCurrentSheet(), label ); } } diff --git a/eeschema/sch_file_versions.h b/eeschema/sch_file_versions.h index 9f67532247..3dc3578334 100644 --- a/eeschema/sch_file_versions.h +++ b/eeschema/sch_file_versions.h @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2020-2021 CERN - * + * Copyright (C) 2020-2022 KiCad Developers, see AUTHORS.txt for contributors. * @author Wayne Stambaugh * * This program is free software; you can redistribute it and/or @@ -42,7 +42,8 @@ //#define SEXPR_SYMBOL_LIB_FILE_VERSION 20210619 // Change pin overbar syntax from `~...~` to `~{...}`. //#define SEXPR_SYMBOL_LIB_FILE_VERSION 20211014 // Arc formatting. //#define SEXPR_SYMBOL_LIB_FILE_VERSION 20220101 // Class flags. -#define SEXPR_SYMBOL_LIB_FILE_VERSION 20220102 // Fonts. +//#define SEXPR_SYMBOL_LIB_FILE_VERSION 20220102 // Fonts. +#define SEXPR_SYMBOL_LIB_FILE_VERSION 20220126 // Text boxes. /** @@ -73,4 +74,5 @@ //#define SEXPR_SCHEMATIC_FILE_VERSION 20220102 // Dash-dot-dot //#define SEXPR_SCHEMATIC_FILE_VERSION 20220103 // Label fields //#define SEXPR_SCHEMATIC_FILE_VERSION 20220104 // Fonts -#define SEXPR_SCHEMATIC_FILE_VERSION 20220124 // netclass_flag -> directive_label +//#define SEXPR_SCHEMATIC_FILE_VERSION 20220124 // netclass_flag -> directive_label +#define SEXPR_SCHEMATIC_FILE_VERSION 20220126 // Text boxes diff --git a/eeschema/sch_painter.cpp b/eeschema/sch_painter.cpp index 17aa7a4994..8f210f99f9 100644 --- a/eeschema/sch_painter.cpp +++ b/eeschema/sch_painter.cpp @@ -38,6 +38,7 @@ #include #include #include +#include #include #include #include @@ -51,6 +52,7 @@ #include #include #include +#include #include #include #include @@ -219,11 +221,13 @@ bool SCH_PAINTER::Draw( const VIEW_ITEM *aItem, int aLayer ) HANDLE_ITEM( LIB_PIN_T, LIB_PIN ); HANDLE_ITEM( LIB_FIELD_T, LIB_FIELD ); HANDLE_ITEM( LIB_TEXT_T, LIB_TEXT ); + HANDLE_ITEM( LIB_TEXTBOX_T, LIB_TEXTBOX ); HANDLE_ITEM( SCH_SYMBOL_T, SCH_SYMBOL ); HANDLE_ITEM( SCH_JUNCTION_T, SCH_JUNCTION ); HANDLE_ITEM( SCH_LINE_T, SCH_LINE ); HANDLE_ITEM( SCH_SHAPE_T, SCH_SHAPE ); HANDLE_ITEM( SCH_TEXT_T, SCH_TEXT ); + HANDLE_ITEM( SCH_TEXTBOX_T, SCH_TEXTBOX ); HANDLE_ITEM( SCH_LABEL_T, SCH_LABEL ); HANDLE_ITEM( SCH_DIRECTIVE_LABEL_T, SCH_DIRECTIVE_LABEL ); HANDLE_ITEM( SCH_FIELD_T, SCH_FIELD ); @@ -334,6 +338,20 @@ COLOR4D SCH_PAINTER::getRenderColor( const EDA_ITEM* aItem, int aLayer, bool aDr if( color == COLOR4D::UNSPECIFIED ) color = m_schSettings.GetLayerColor( aLayer ); } + else if( aItem->Type() == SCH_TEXTBOX_T ) + { + const SCH_TEXTBOX* textBox = static_cast( aItem ); + + if( m_schSettings.m_OverrideItemColors ) + color = m_schSettings.GetLayerColor( aLayer ); + else if( aLayer == LAYER_NOTES ) + color = textBox->GetStroke().GetColor(); + else if( aLayer == LAYER_NOTES_BACKGROUND ) + color = textBox->GetFillColor(); + + if( color == COLOR4D::UNSPECIFIED ) + color = m_schSettings.GetLayerColor( aLayer ); + } if( aItem->IsBrightened() ) // Selection disambiguation, net highlighting, etc. { @@ -360,22 +378,35 @@ COLOR4D SCH_PAINTER::getRenderColor( const EDA_ITEM* aItem, int aLayer, bool aDr } -float SCH_PAINTER::getLineWidth( const LIB_ITEM* aItem, bool aDrawingShadows ) const +float SCH_PAINTER::getLineWidth( const EDA_ITEM* aItem, bool aDrawingShadows ) const { - float width = (float) aItem->GetEffectivePenWidth( &m_schSettings ); + wxCHECK( aItem, static_cast( Mils2iu( DEFAULT_LINE_WIDTH_MILS ) ) ); - if( ( aItem->IsBrightened() || aItem->IsSelected() ) && aDrawingShadows ) - width += getShadowWidth( aItem->IsBrightened() ); + int pen; - return width; -} + if( aItem->Type() == LIB_TEXTBOX_T ) + { + pen = static_cast( aItem )->GetStroke().GetWidth(); + } + else if( aItem->Type() == SCH_TEXTBOX_T ) + { + pen = static_cast( aItem )->GetStroke().GetWidth(); + } + else if( dynamic_cast( aItem ) ) + { + pen = static_cast( aItem )->GetEffectivePenWidth( &m_schSettings ); + } + else if( dynamic_cast( aItem ) ) + { + pen = static_cast( aItem )->GetPenWidth(); + } + else + { + pen = 0; + UNIMPLEMENTED_FOR( aItem->GetClass() ); + } - -float SCH_PAINTER::getLineWidth( const SCH_ITEM* aItem, bool aDrawingShadows ) const -{ - wxCHECK( aItem, static_cast( Mils2iu( DEFAULT_WIRE_WIDTH_MILS ) ) ); - - float width = (float) aItem->GetPenWidth(); + float width = pen; if( ( aItem->IsBrightened() || aItem->IsSelected() ) && aDrawingShadows ) width += getShadowWidth( aItem->IsBrightened() ); @@ -384,44 +415,41 @@ float SCH_PAINTER::getLineWidth( const SCH_ITEM* aItem, bool aDrawingShadows ) c } -float SCH_PAINTER::getTextThickness( const SCH_TEXT* aItem, bool aDrawingShadows ) const +float SCH_PAINTER::getTextThickness( const EDA_ITEM* aItem, bool aDrawingShadows ) const { - float width = (float) aItem->GetEffectiveTextPenWidth( m_schSettings.GetDefaultPenWidth() ); + int pen = m_schSettings.GetDefaultPenWidth(); - if( ( aItem->IsBrightened() || aItem->IsSelected() ) && aDrawingShadows ) - width += getShadowWidth( aItem->IsBrightened() ); + switch( aItem->Type() ) + { + case SCH_FIELD_T: + pen = static_cast( aItem )->GetEffectiveTextPenWidth( pen ); + break; - return width; -} + case SCH_TEXT_T: + pen = static_cast( aItem )->GetEffectiveTextPenWidth( pen ); + break; + case SCH_TEXTBOX_T: + pen = static_cast( aItem )->GetEffectiveTextPenWidth( pen ); + break; -float SCH_PAINTER::getTextThickness( const SCH_FIELD* aItem, bool aDrawingShadows ) const -{ - float width = (float) aItem->GetEffectiveTextPenWidth( m_schSettings.GetDefaultPenWidth() ); + case LIB_FIELD_T: + pen = std::max( pen, static_cast( aItem )->GetEffectiveTextPenWidth() ); + break; - if( ( aItem->IsBrightened() || aItem->IsSelected() ) && aDrawingShadows ) - width += getShadowWidth( aItem->IsBrightened() ); + case LIB_TEXT_T: + pen = std::max( pen, static_cast( aItem )->GetEffectiveTextPenWidth() ); + break; - return width; -} + case LIB_TEXTBOX_T: + pen = std::max( pen, static_cast( aItem )->GetEffectiveTextPenWidth() ); + break; + default: + UNIMPLEMENTED_FOR( aItem->GetClass() ); + } -float SCH_PAINTER::getTextThickness( const LIB_FIELD* aItem, bool aDrawingShadows ) const -{ - float width = (float) std::max( aItem->GetEffectiveTextPenWidth(), - m_schSettings.GetDefaultPenWidth() ); - - if( ( aItem->IsBrightened() || aItem->IsSelected() ) && aDrawingShadows ) - width += getShadowWidth( aItem->IsBrightened() ); - - return width; -} - - -float SCH_PAINTER::getTextThickness( const LIB_TEXT* aItem, bool aDrawingShadows ) const -{ - float width = (float) std::max( aItem->GetEffectiveTextPenWidth(), - m_schSettings.GetDefaultPenWidth() ); + float width = (float) pen; if( ( aItem->IsBrightened() || aItem->IsSelected() ) && aDrawingShadows ) width += getShadowWidth( aItem->IsBrightened() ); @@ -571,6 +599,7 @@ bool SCH_PAINTER::setDeviceColors( const LIB_ITEM* aItem, int aLayer ) return false; + case LAYER_NOTES_BACKGROUND: case LAYER_DEVICE_BACKGROUND: if( shape ) { @@ -593,6 +622,7 @@ bool SCH_PAINTER::setDeviceColors( const LIB_ITEM* aItem, int aLayer ) return false; + case LAYER_NOTES: case LAYER_DEVICE: m_gal->SetIsFill( shape && shape->GetFillMode() == FILL_T::FILLED_SHAPE ); m_gal->SetFillColor( getRenderColor( aItem, LAYER_DEVICE, false ) ); @@ -621,68 +651,136 @@ void SCH_PAINTER::draw( const LIB_SHAPE *aShape, int aLayer ) if( !isUnitAndConversionShown( aShape ) ) return; - if( setDeviceColors( aShape, aLayer ) ) - { - if( aLayer == LAYER_SELECTION_SHADOWS && eeconfig()->m_Selection.fill_shapes ) - { - // Consider a NAND gate. We have no idea which side of the arc is "inside" so - // we can't reliably fill. + if( aShape->IsPrivate() && !m_schSettings.m_IsSymbolEditor ) + return; + if( !setDeviceColors( aShape, aLayer ) ) + return; + + bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS; + PLOT_DASH_TYPE lineStyle = aShape->GetStroke().GetPlotStyle(); + COLOR4D color = getRenderColor( aShape, aLayer, drawingShadows ); + + auto drawShape = + [&]( const LIB_SHAPE* shape ) + { + switch( shape->GetShape() ) + { + case SHAPE_T::ARC: + { + EDA_ANGLE startAngle; + EDA_ANGLE endAngle; + shape->CalcArcAngles( startAngle, endAngle ); + + TRANSFORM().MapAngles( &startAngle, &endAngle ); + + m_gal->DrawArc( mapCoords( shape->GetCenter() ), shape->GetRadius(), + startAngle, endAngle ); + } + break; + + case SHAPE_T::CIRCLE: + m_gal->DrawCircle( mapCoords( shape->GetPosition() ), shape->GetRadius() ); + break; + + case SHAPE_T::RECT: + m_gal->DrawRectangle( mapCoords( shape->GetPosition() ), + mapCoords( shape->GetEnd() ) ); + break; + + case SHAPE_T::POLY: + { + const SHAPE_LINE_CHAIN poly = shape->GetPolyShape().Outline( 0 ); + std::deque mappedPts; + + for( const VECTOR2I& pt : poly.CPoints() ) + mappedPts.push_back( mapCoords( pt ) ); + + m_gal->DrawPolygon( mappedPts ); + } + break; + + case SHAPE_T::BEZIER: + { + std::deque mappedPts; + + for( const VECTOR2I& p : shape->GetBezierPoints() ) + mappedPts.push_back( mapCoords( p ) ); + + m_gal->DrawPolygon( mappedPts ); + } + break; + + default: + UNIMPLEMENTED_FOR( shape->SHAPE_T_asString() ); + } + }; + + if( aLayer == LAYER_SELECTION_SHADOWS ) + { + if( eeconfig()->m_Selection.fill_shapes ) + { + // Consider a NAND gate. We have no idea which side of the arc is "inside" + // so we can't reliably fill. if( aShape->GetShape() == SHAPE_T::ARC ) m_gal->SetIsFill( aShape->IsFilled() ); else m_gal->SetIsFill( true ); } - - switch( aShape->GetShape() ) + else { - case SHAPE_T::ARC: - { - EDA_ANGLE startAngle; - EDA_ANGLE endAngle; - aShape->CalcArcAngles( startAngle, endAngle ); - - TRANSFORM().MapAngles( &startAngle, &endAngle ); - - m_gal->DrawArc( mapCoords( aShape->GetCenter() ), aShape->GetRadius(), startAngle, - endAngle ); + m_gal->SetIsStroke( true ); + m_gal->SetIsFill( false ); + m_gal->SetLineWidth( getLineWidth( aShape, true ) ); + m_gal->SetStrokeColor( color ); } - break; - case SHAPE_T::CIRCLE: - m_gal->DrawCircle( mapCoords( aShape->GetPosition() ), aShape->GetRadius() ); - break; - - case SHAPE_T::RECT: - m_gal->DrawRectangle( mapCoords( aShape->GetPosition() ), - mapCoords( aShape->GetEnd() ) ); - break; - - case SHAPE_T::POLY: + drawShape( aShape ); + } + else if( aLayer == LAYER_DEVICE_BACKGROUND || aLayer == LAYER_NOTES_BACKGROUND ) + { + if( aShape->IsFilled() ) { - const SHAPE_LINE_CHAIN poly = aShape->GetPolyShape().Outline( 0 ); - std::deque mappedPts; + m_gal->SetIsFill( true ); + m_gal->SetIsStroke( false ); + m_gal->SetFillColor( aShape->GetFillColor() ); - for( const VECTOR2I& pt : poly.CPoints() ) - mappedPts.push_back( mapCoords( pt ) ); - - m_gal->DrawPolygon( mappedPts ); + drawShape( aShape ); } - break; + } + else if( aLayer == LAYER_DEVICE + || ( m_schSettings.m_IsSymbolEditor && aLayer == LAYER_NOTES ) ) + { + int lineWidth = getLineWidth( aShape, drawingShadows ); - case SHAPE_T::BEZIER: + m_gal->SetIsFill( false ); + m_gal->SetIsStroke( true ); + m_gal->SetLineWidth( lineWidth ); + m_gal->SetStrokeColor( color ); + + if( lineStyle <= PLOT_DASH_TYPE::FIRST_TYPE || drawingShadows ) { - std::deque mappedPts; - - for( const VECTOR2I& p : aShape->GetBezierPoints() ) - mappedPts.push_back( mapCoords( p ) ); - - m_gal->DrawPolygon( mappedPts ); + drawShape( aShape ); } - break; + else + { + std::vector shapes = aShape->MakeEffectiveShapes( true ); - default: - UNIMPLEMENTED_FOR( aShape->SHAPE_T_asString() ); + for( SHAPE* shape : shapes ) + { + STROKE_PARAMS::Stroke( shape, lineStyle, lineWidth, &m_schSettings, + [&]( const VECTOR2I& a, const VECTOR2I& b ) + { + // DrawLine has problem with 0 length lines so enforce minimum + if( a == b ) + m_gal->DrawLine( mapCoords( a+1 ), mapCoords( b ) ); + else + m_gal->DrawLine( mapCoords( a ), mapCoords( b ) ); + } ); + } + + for( SHAPE* shape : shapes ) + delete shape; } } } @@ -729,9 +827,10 @@ void SCH_PAINTER::draw( const LIB_FIELD *aField, int aLayer ) m_gal->SetFillColor( color ); EDA_RECT bbox = aField->GetBoundingBox(); - VECTOR2I textpos = bbox.Centre(); + VECTOR2I textpos = bbox.Centre(); - if( drawingShadows && eeconfig()->m_Selection.text_as_box ) + if( drawingShadows && ( eeconfig()->m_Selection.text_as_box + || aField->GetDrawFont()->IsOutline() ) ) { m_gal->SetIsStroke( true ); m_gal->SetIsFill( true ); @@ -758,11 +857,14 @@ void SCH_PAINTER::draw( const LIB_FIELD *aField, int aLayer ) } -void SCH_PAINTER::draw( const LIB_TEXT *aText, int aLayer ) +void SCH_PAINTER::draw( const LIB_TEXT* aText, int aLayer ) { if( !isUnitAndConversionShown( aText ) ) return; + if( aText->IsPrivate() && !m_schSettings.m_IsSymbolEditor ) + return; + bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS; if( drawingShadows && !( aText->IsBrightened() || aText->IsSelected() ) ) @@ -784,18 +886,21 @@ void SCH_PAINTER::draw( const LIB_TEXT *aText, int aLayer ) m_gal->SetFillColor( color ); m_gal->SetStrokeColor( color ); - if( drawingShadows && eeconfig()->m_Selection.text_as_box ) + if( drawingShadows && ( eeconfig()->m_Selection.text_as_box + || aText->GetDrawFont()->IsOutline() ) ) { m_gal->SetIsStroke( true ); m_gal->SetIsFill( true ); m_gal->SetLineWidth( getTextThickness( aText, drawingShadows ) ); m_gal->DrawRectangle( bBox.GetPosition(), bBox.GetEnd() ); + return; } - else + + wxString shownText( aText->GetShownText() ); + + if( !shownText.IsEmpty() ) { - TEXT_ATTRIBUTES attrs( aText->GetAttributes() ); - attrs.m_Halign = GR_TEXT_H_ALIGN_CENTER; - attrs.m_Valign = GR_TEXT_V_ALIGN_CENTER; + TEXT_ATTRIBUTES attrs = aText->GetAttributes(); attrs.m_StrokeWidth = getTextThickness( aText, drawingShadows ); strokeText( aText->GetText(), pos, attrs ); @@ -803,6 +908,109 @@ void SCH_PAINTER::draw( const LIB_TEXT *aText, int aLayer ) } +void SCH_PAINTER::draw( const LIB_TEXTBOX* aTextBox, int aLayer ) +{ + if( !isUnitAndConversionShown( aTextBox ) ) + return; + + if( aTextBox->IsPrivate() && !m_schSettings.m_IsSymbolEditor ) + return; + + bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS; + + if( drawingShadows && !( aTextBox->IsBrightened() || aTextBox->IsSelected() ) ) + return; + + COLOR4D color = getRenderColor( aTextBox, aLayer, drawingShadows ); + float borderWidth = getLineWidth( aTextBox, drawingShadows ); + PLOT_DASH_TYPE borderStyle = aTextBox->GetStroke().GetPlotStyle(); + wxString shownText = aTextBox->GetShownText(); + + auto drawText = + [&]() + { + if( !shownText.IsEmpty() ) + { + TEXT_ATTRIBUTES attrs = aTextBox->GetAttributes(); + attrs.m_StrokeWidth = getTextThickness( aTextBox, drawingShadows ); + + strokeText( shownText, aTextBox->GetTextPos(), attrs ); + } + }; + + m_gal->SetStrokeColor( color ); + m_gal->SetFillColor( color ); + m_gal->SetLineWidth( borderWidth ); + + if( aLayer == LAYER_SELECTION_SHADOWS ) + { + if( eeconfig()->m_Selection.fill_shapes + || eeconfig()->m_Selection.text_as_box + || aTextBox->GetDrawFont()->IsOutline() ) + { + m_gal->SetIsFill( true ); + m_gal->SetIsStroke( false ); + + m_gal->DrawRectangle( mapCoords( aTextBox->GetPosition() ), + mapCoords( aTextBox->GetEnd() ) ); + } + else + { + m_gal->SetIsStroke( true ); + m_gal->SetIsFill( false ); + + m_gal->DrawRectangle( mapCoords( aTextBox->GetPosition() ), + mapCoords( aTextBox->GetEnd() ) ); + drawText(); + } + } + else if( aLayer == LAYER_DEVICE_BACKGROUND || aLayer == LAYER_NOTES_BACKGROUND ) + { + if( aTextBox->IsFilled() ) + { + m_gal->SetIsFill( true ); + m_gal->SetIsStroke( false ); + + m_gal->DrawRectangle( mapCoords( aTextBox->GetPosition() ), + mapCoords( aTextBox->GetEnd() ) ); + } + } + else if( aLayer == LAYER_DEVICE || aLayer == LAYER_NOTES ) + { + m_gal->SetIsFill( false ); + m_gal->SetIsStroke( true ); + + if( borderStyle <= PLOT_DASH_TYPE::FIRST_TYPE || drawingShadows ) + { + m_gal->DrawRectangle( mapCoords( aTextBox->GetPosition() ), + mapCoords( aTextBox->GetEnd() ) ); + } + else + { + std::vector shapes = aTextBox->MakeEffectiveShapes( true ); + + for( SHAPE* shape : shapes ) + { + STROKE_PARAMS::Stroke( shape, borderStyle, borderWidth, &m_schSettings, + [&]( const VECTOR2I& a, const VECTOR2I& b ) + { + // DrawLine has problem with 0 length lines so enforce minimum + if( a == b ) + m_gal->DrawLine( mapCoords( a+1 ), mapCoords( b ) ); + else + m_gal->DrawLine( mapCoords( a ), mapCoords( b ) ); + } ); + } + + for( SHAPE* shape : shapes ) + delete shape; + } + + drawText(); + } +} + + int SCH_PAINTER::internalPinDecoSize( const LIB_PIN &aPin ) { if( m_schSettings.m_PinSymbolSize > 0 ) @@ -1123,6 +1331,7 @@ void SCH_PAINTER::draw( LIB_PIN *aPin, int aLayer ) if( text[i].IsEmpty() ) return; + // Which of these gets used depends on the font technology, so set both m_gal->SetStrokeColor( colour[i] ); m_gal->SetFillColor( colour[i] ); @@ -1133,10 +1342,15 @@ void SCH_PAINTER::draw( LIB_PIN *aPin, int aLayer ) attrs.m_Angle = aAngle; attrs.m_StrokeWidth = thickness[i]; - if( drawingShadows && eeconfig()->m_Selection.text_as_box ) + if( drawingShadows && ( eeconfig()->m_Selection.text_as_box + || aPin->GetDrawFont()->IsOutline() ) ) + { boxText( text[i], aPos, attrs ); + } else + { strokeText( text[i], aPos, attrs ); + } }; switch( orient ) @@ -1344,7 +1558,6 @@ void SCH_PAINTER::draw( const SCH_SHAPE* aShape, int aLayer ) PLOT_DASH_TYPE lineStyle = aShape->GetEffectiveLineStyle(); COLOR4D color = getRenderColor( aShape, aLayer, drawingShadows ); - if( drawingShadows && !( aShape->IsBrightened() || aShape->IsSelected() ) ) return; @@ -1361,8 +1574,8 @@ void SCH_PAINTER::draw( const SCH_SHAPE* aShape, int aLayer ) m_gal->DrawArc( aShape->GetCenter(), aShape->GetRadius(), startAngle, endAngle ); - } break; + } case SHAPE_T::CIRCLE: m_gal->DrawCircle( shape->GetPosition(), shape->GetRadius() ); @@ -1380,8 +1593,8 @@ void SCH_PAINTER::draw( const SCH_SHAPE* aShape, int aLayer ) pts.push_back( pt ); m_gal->DrawPolygon( pts ); - } break; + } case SHAPE_T::BEZIER: { @@ -1391,8 +1604,8 @@ void SCH_PAINTER::draw( const SCH_SHAPE* aShape, int aLayer ) pts.push_back( p ); m_gal->DrawPolygon( pts ); - } break; + } default: UNIMPLEMENTED_FOR( shape->SHAPE_T_asString() ); @@ -1403,7 +1616,13 @@ void SCH_PAINTER::draw( const SCH_SHAPE* aShape, int aLayer ) { if( eeconfig()->m_Selection.fill_shapes ) { - m_gal->SetIsFill( true ); + // Consider a NAND gate. We have no idea which side of the arc is "inside" + // so we can't reliably fill. + if( aShape->GetShape() == SHAPE_T::ARC ) + m_gal->SetIsFill( aShape->IsFilled() ); + else + m_gal->SetIsFill( true ); + m_gal->SetIsStroke( false ); m_gal->SetFillColor( color ); } @@ -1445,15 +1664,14 @@ void SCH_PAINTER::draw( const SCH_SHAPE* aShape, int aLayer ) for( SHAPE* shape : shapes ) { STROKE_PARAMS::Stroke( shape, lineStyle, lineWidth, &m_schSettings, - [&]( const VECTOR2I& a, const VECTOR2I& b ) - { - // DrawLine has problem with 0 length lines - // so draw a line with a minimal length - if( a == b ) - m_gal->DrawLine( a+1, b ); - else - m_gal->DrawLine( a, b ); - } ); + [&]( const VECTOR2I& a, const VECTOR2I& b ) + { + // DrawLine has problem with 0 length lines so enforce minimum + if( a == b ) + m_gal->DrawLine( a+1, b ); + else + m_gal->DrawLine( a, b ); + } ); } for( SHAPE* shape : shapes ) @@ -1519,7 +1737,8 @@ void SCH_PAINTER::draw( const SCH_TEXT *aText, int aLayer ) VECTOR2I text_offset = aText->GetSchematicTextOffset( &m_schSettings ); wxString shownText( aText->GetShownText() ); - if( drawingShadows && eeconfig()->m_Selection.text_as_box ) + if( drawingShadows && ( eeconfig()->m_Selection.text_as_box + || aText->GetDrawFont()->IsOutline() ) ) { EDA_RECT bBox = aText->GetBoundingBox(); bBox.RevertYAxis(); @@ -1553,6 +1772,110 @@ void SCH_PAINTER::draw( const SCH_TEXT *aText, int aLayer ) } +void SCH_PAINTER::draw( const SCH_TEXTBOX* aTextBox, int aLayer ) +{ + bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS; + COLOR4D color = getRenderColor( aTextBox, aLayer, drawingShadows ); + float borderWidth = getLineWidth( aTextBox, drawingShadows ); + PLOT_DASH_TYPE borderStyle = aTextBox->GetEffectiveLineStyle(); + wxString shownText = aTextBox->GetShownText(); + + auto drawText = + [&]() + { + if( !shownText.IsEmpty() ) + { + TEXT_ATTRIBUTES attrs = aTextBox->GetAttributes(); + attrs.m_StrokeWidth = getTextThickness( aTextBox, drawingShadows ); + + std::vector>* cache = nullptr; + + cache = aTextBox->GetRenderCache( shownText ); + + if( cache ) + { + for( const std::unique_ptr& glyph : *cache ) + m_gal->DrawGlyph( *glyph.get() ); + } + else + { + strokeText( shownText, aTextBox->GetTextPos(), attrs ); + } + } + }; + + if( drawingShadows && !( aTextBox->IsBrightened() || aTextBox->IsSelected() ) ) + return; + + m_gal->SetFillColor( color ); + m_gal->SetStrokeColor( color ); + m_gal->SetLineWidth( borderWidth ); + + if( aLayer == LAYER_SELECTION_SHADOWS ) + { + if( eeconfig()->m_Selection.fill_shapes + || eeconfig()->m_Selection.text_as_box + || aTextBox->GetDrawFont()->IsOutline() ) + { + m_gal->SetIsFill( true ); + m_gal->SetIsStroke( false ); + + m_gal->DrawRectangle( aTextBox->GetPosition(), aTextBox->GetEnd() ); + } + else + { + m_gal->SetIsStroke( true ); + m_gal->SetIsFill( false ); + + m_gal->DrawRectangle( aTextBox->GetPosition(), aTextBox->GetEnd() ); + drawText(); + } + } + else if( aLayer == LAYER_NOTES_BACKGROUND ) + { + if( aTextBox->IsFilled() ) + { + m_gal->SetIsFill( true ); + m_gal->SetIsStroke( false ); + + m_gal->DrawRectangle( aTextBox->GetPosition(), aTextBox->GetEnd() ); + } + } + else if( aLayer == LAYER_NOTES ) + { + m_gal->SetIsFill( false ); + m_gal->SetIsStroke( true ); + + if( borderStyle <= PLOT_DASH_TYPE::FIRST_TYPE || drawingShadows ) + { + m_gal->DrawRectangle( aTextBox->GetPosition(), aTextBox->GetEnd() ); + } + else + { + std::vector shapes = aTextBox->MakeEffectiveShapes( true ); + + for( SHAPE* shape : shapes ) + { + STROKE_PARAMS::Stroke( shape, borderStyle, borderWidth, &m_schSettings, + [&]( const VECTOR2I& a, const VECTOR2I& b ) + { + // DrawLine has problem with 0 length lines so enforce minimum + if( a == b ) + m_gal->DrawLine( a+1, b ); + else + m_gal->DrawLine( a, b ); + } ); + } + + for( SHAPE* shape : shapes ) + delete shape; + } + + drawText(); + } +} + + static void orientSymbol( LIB_SYMBOL* symbol, int orientation ) { struct ORIENT @@ -1736,7 +2059,8 @@ void SCH_PAINTER::draw( const SCH_FIELD *aField, int aLayer ) m_gal->SetStrokeColor( color ); m_gal->SetFillColor( color ); - if( drawingShadows && eeconfig()->m_Selection.text_as_box ) + if( drawingShadows && ( eeconfig()->m_Selection.text_as_box + || aField->GetDrawFont()->IsOutline() ) ) { bbox.RevertYAxis(); m_gal->SetIsStroke( true ); diff --git a/eeschema/sch_painter.h b/eeschema/sch_painter.h index 582dcb6574..f4630e2b6b 100644 --- a/eeschema/sch_painter.h +++ b/eeschema/sch_painter.h @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2019-2020 CERN - * Copyright (C) 2020-2021 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2020-2022 KiCad Developers, see AUTHORS.txt for contributors. * * @author Tomasz Wlostowski * @@ -38,11 +38,13 @@ class LIB_ITEM; class LIB_SYMBOL; class LIB_FIELD; class LIB_TEXT; +class LIB_TEXTBOX; class SCH_SYMBOL; class SCH_FIELD; class SCH_JUNCTION; class SCH_LABEL; class SCH_TEXT; +class SCH_TEXTBOX; class SCH_HIERLABEL; class SCH_DIRECTIVE_LABEL; class SCH_GLOBALLABEL; @@ -155,10 +157,12 @@ private: int aConvert = 0 ); void draw( const LIB_FIELD* aField, int aLayer ); void draw( const LIB_TEXT* aText, int aLayer ); + void draw( const LIB_TEXTBOX* aTextBox, int aLayer ); void draw( SCH_SYMBOL* aSymbol, int aLayer ); void draw( const SCH_JUNCTION* aJct, int aLayer ); void draw( const SCH_FIELD* aField, int aLayer ); - void draw( const SCH_SHAPE* shape, int aLayer ); + void draw( const SCH_SHAPE* aShape, int aLayer ); + void draw( const SCH_TEXTBOX* aTextBox, int aLayer ); void draw( const SCH_TEXT* aText, int aLayer ); void draw( const SCH_LABEL* aText, int aLayer ); void draw( const SCH_DIRECTIVE_LABEL* aLabel, int aLayer ); @@ -183,12 +187,8 @@ private: float getShadowWidth( bool aForHighlight ) const; COLOR4D getRenderColor( const EDA_ITEM* aItem, int aLayer, bool aDrawingShadows ) const; - float getLineWidth( const LIB_ITEM* aItem, bool aDrawingShadows ) const; - float getLineWidth( const SCH_ITEM* aItem, bool aDrawingShadows ) const; - float getTextThickness( const SCH_TEXT* aItem, bool aDrawingShadows ) const; - float getTextThickness( const SCH_FIELD* aItem, bool aDrawingShadows ) const; - float getTextThickness( const LIB_FIELD* aItem, bool aDrawingShadows ) const; - float getTextThickness( const LIB_TEXT* aItem, bool aDrawingShadows ) const; + float getLineWidth( const EDA_ITEM* aItem, bool aDrawingShadows ) const; + float getTextThickness( const EDA_ITEM* aItem, bool aDrawingShadows ) const; bool setDeviceColors( const LIB_ITEM* aItem, int aLayer ); diff --git a/eeschema/sch_plugins/altium/sch_altium_plugin.cpp b/eeschema/sch_plugins/altium/sch_altium_plugin.cpp index ceaf0e5039..0e08281285 100644 --- a/eeschema/sch_plugins/altium/sch_altium_plugin.cpp +++ b/eeschema/sch_plugins/altium/sch_altium_plugin.cpp @@ -931,9 +931,9 @@ void SCH_ALTIUM_PLUGIN::ParseTextFrame( const std::map& aPro break; } - // TODO: set size and word-wrap once KiCad supports wrapped text. + // JEY TODO: set size and word-wrap once KiCad supports wrapped text. - // TODO: set border and background color once KiCad supports them. + // JEY TODO: set border and background color once KiCad supports them. size_t fontId = static_cast( elem.fontId ); @@ -1138,7 +1138,7 @@ void SCH_ALTIUM_PLUGIN::ParsePolyline( const std::map& aProp if( elem.ownerpartid == ALTIUM_COMPONENT_NONE ) { - SCH_SHAPE* poly = new SCH_SHAPE( SHAPE_T::POLY, SCH_LAYER_ID::LAYER_NOTES ); + SCH_SHAPE* poly = new SCH_SHAPE( SHAPE_T::POLY ); for( VECTOR2I& point : elem.points ) poly->AddPoint( point + m_sheetOffset ); @@ -1184,7 +1184,7 @@ void SCH_ALTIUM_PLUGIN::ParsePolygon( const std::map& aPrope if( elem.ownerpartid == ALTIUM_COMPONENT_NONE ) { - SCH_SHAPE* poly = new SCH_SHAPE( SHAPE_T::POLY, SCH_LAYER_ID::LAYER_NOTES ); + SCH_SHAPE* poly = new SCH_SHAPE( SHAPE_T::POLY ); for( VECTOR2I& point : elem.points ) poly->AddPoint( point + m_sheetOffset ); @@ -1236,7 +1236,7 @@ void SCH_ALTIUM_PLUGIN::ParseRoundRectangle( const std::map& if( elem.ownerpartid == ALTIUM_COMPONENT_NONE ) { // TODO: misses rounded edges - SCH_SHAPE* rect = new SCH_SHAPE( SHAPE_T::RECT, SCH_LAYER_ID::LAYER_NOTES ); + SCH_SHAPE* rect = new SCH_SHAPE( SHAPE_T::RECT ); rect->SetPosition( sheetTopRight ); rect->SetEnd( sheetBottomLeft ); @@ -1283,7 +1283,7 @@ void SCH_ALTIUM_PLUGIN::ParseArc( const std::map& aPropertie { if( elem.startAngle == 0 && ( elem.endAngle == 0 || elem.endAngle == 360 ) ) { - SCH_SHAPE* circle = new SCH_SHAPE( SHAPE_T::CIRCLE, SCH_LAYER_ID::LAYER_NOTES ); + SCH_SHAPE* circle = new SCH_SHAPE( SHAPE_T::CIRCLE ); circle->SetPosition( elem.center + m_sheetOffset ); circle->SetEnd( circle->GetPosition() + VECTOR2I( elem.radius, 0 ) ); @@ -1293,7 +1293,7 @@ void SCH_ALTIUM_PLUGIN::ParseArc( const std::map& aPropertie } else { - SCH_SHAPE* arc = new SCH_SHAPE( SHAPE_T::ARC, SCH_LAYER_ID::LAYER_NOTES ); + SCH_SHAPE* arc = new SCH_SHAPE( SHAPE_T::ARC ); EDA_ANGLE includedAngle( elem.endAngle - elem.startAngle, DEGREES_T ); EDA_ANGLE startAngle( elem.endAngle, DEGREES_T ); VECTOR2I startOffset( KiROUND( elem.radius * startAngle.Cos() ), @@ -1414,7 +1414,7 @@ void SCH_ALTIUM_PLUGIN::ParseRectangle( const std::map& aPro if( elem.ownerpartid == ALTIUM_COMPONENT_NONE ) { - SCH_SHAPE* rect = new SCH_SHAPE( SHAPE_T::RECT, SCH_LAYER_ID::LAYER_NOTES ); + SCH_SHAPE* rect = new SCH_SHAPE( SHAPE_T::RECT ); rect->SetPosition( sheetTopRight ); rect->SetEnd( sheetBottomLeft ); diff --git a/eeschema/sch_plugins/kicad/sch_sexpr_parser.cpp b/eeschema/sch_plugins/kicad/sch_sexpr_parser.cpp index 40820f653f..e3935ef15a 100644 --- a/eeschema/sch_plugins/kicad/sch_sexpr_parser.cpp +++ b/eeschema/sch_plugins/kicad/sch_sexpr_parser.cpp @@ -36,6 +36,7 @@ #include #include #include +#include #include // KiROUND, Clamp #include #include @@ -45,6 +46,7 @@ #include // SYM_ORIENT_XXX #include #include +#include #include #include #include @@ -326,6 +328,7 @@ LIB_SYMBOL* SCH_SEXPR_PARSER::ParseSymbol( LIB_SYMBOL_MAP& aSymbolLibMap, int aF case T_polyline: case T_rectangle: case T_text: + case T_text_box: item = ParseDrawItem(); wxCHECK_MSG( item, nullptr, "Invalid draw item pointer." ); @@ -351,6 +354,7 @@ LIB_SYMBOL* SCH_SEXPR_PARSER::ParseSymbol( LIB_SYMBOL_MAP& aSymbolLibMap, int aF case T_polyline: case T_rectangle: case T_text: + case T_text_box: item = ParseDrawItem(); wxCHECK_MSG( item, nullptr, "Invalid draw item pointer." ); @@ -377,31 +381,35 @@ LIB_ITEM* SCH_SEXPR_PARSER::ParseDrawItem() switch( CurTok() ) { case T_arc: - return static_cast( parseArc() ); + return parseArc(); break; case T_bezier: - return static_cast( parseBezier() ); + return parseBezier(); break; case T_circle: - return static_cast( parseCircle() ); + return parseCircle(); break; case T_pin: - return static_cast( parsePin() ); + return parsePin(); break; case T_polyline: - return static_cast( parsePolyLine() ); + return parsePolyLine(); break; case T_rectangle: - return static_cast( parseRectangle() ); + return parseRectangle(); break; case T_text: - return static_cast( parseText() ); + return parseText(); + break; + + case T_text_box: + return parseTextBox(); break; default: @@ -900,7 +908,15 @@ LIB_SHAPE* SCH_SEXPR_PARSER::parseArc() arc->SetUnit( m_unit ); arc->SetConvert( m_convert ); - for( token = NextTok(); token != T_RIGHT; token = NextTok() ) + token = NextTok(); + + if( token == T_private ) + { + arc->SetPrivate( true ); + token = NextTok(); + } + + for( ; token != T_RIGHT; token = NextTok() ) { if( token != T_LEFT ) Expecting( T_LEFT ); @@ -1047,7 +1063,15 @@ LIB_SHAPE* SCH_SEXPR_PARSER::parseBezier() bezier->SetUnit( m_unit ); bezier->SetConvert( m_convert ); - for( token = NextTok(); token != T_RIGHT; token = NextTok() ) + token = NextTok(); + + if( token == T_private ) + { + bezier->SetPrivate( true ); + token = NextTok(); + } + + for( ; token != T_RIGHT; token = NextTok() ) { if( token != T_LEFT ) Expecting( T_LEFT ); @@ -1122,7 +1146,15 @@ LIB_SHAPE* SCH_SEXPR_PARSER::parseCircle() circle->SetUnit( m_unit ); circle->SetConvert( m_convert ); - for( token = NextTok(); token != T_RIGHT; token = NextTok() ) + token = NextTok(); + + if( token == T_private ) + { + circle->SetPrivate( true ); + token = NextTok(); + } + + for( ; token != T_RIGHT; token = NextTok() ) { if( token != T_LEFT ) Expecting( T_LEFT ); @@ -1387,7 +1419,15 @@ LIB_SHAPE* SCH_SEXPR_PARSER::parsePolyLine() poly->SetUnit( m_unit ); poly->SetConvert( m_convert ); - for( token = NextTok(); token != T_RIGHT; token = NextTok() ) + token = NextTok(); + + if( token == T_private ) + { + poly->SetPrivate( true ); + token = NextTok(); + } + + for( ; token != T_RIGHT; token = NextTok() ) { if( token != T_LEFT ) Expecting( T_LEFT ); @@ -1447,7 +1487,15 @@ LIB_SHAPE* SCH_SEXPR_PARSER::parseRectangle() rectangle->SetUnit( m_unit ); rectangle->SetConvert( m_convert ); - for( token = NextTok(); token != T_RIGHT; token = NextTok() ) + token = NextTok(); + + if( token == T_private ) + { + rectangle->SetPrivate( true ); + token = NextTok(); + } + + for( ; token != T_RIGHT; token = NextTok() ) { if( token != T_LEFT ) Expecting( T_LEFT ); @@ -1499,6 +1547,12 @@ LIB_TEXT* SCH_SEXPR_PARSER::parseText() text->SetConvert( m_convert ); token = NextTok(); + if( token == T_private ) + { + text->SetPrivate( true ); + token = NextTok(); + } + if( !IsSymbol( token ) ) { THROW_PARSE_ERROR( _( "Invalid text string" ), CurSource(), CurLine(), CurLineNumber(), @@ -1536,6 +1590,77 @@ LIB_TEXT* SCH_SEXPR_PARSER::parseText() } +LIB_TEXTBOX* SCH_SEXPR_PARSER::parseTextBox() +{ + wxCHECK_MSG( CurTok() == T_text_box, nullptr, + wxT( "Cannot parse " ) + GetTokenString( CurTok() ) + wxT( " as a text box." ) ); + + T token; + STROKE_PARAMS stroke( Mils2iu( DEFAULT_LINE_WIDTH_MILS ), PLOT_DASH_TYPE::DEFAULT ); + FILL_PARAMS fill; + std::unique_ptr textBox = std::make_unique( nullptr ); + + token = NextTok(); + + if( token == T_private ) + { + textBox->SetPrivate( true ); + token = NextTok(); + } + + if( !IsSymbol( token ) ) + { + THROW_PARSE_ERROR( _( "Invalid text string" ), CurSource(), CurLine(), CurLineNumber(), + CurOffset() ); + } + + textBox->SetText( FromUTF8() ); + + for( token = NextTok(); token != T_RIGHT; token = NextTok() ) + { + if( token != T_LEFT ) + Expecting( T_LEFT ); + + token = NextTok(); + + switch( token ) + { + case T_start: + textBox->SetPosition( parseXY() ); + NeedRIGHT(); + break; + + case T_end: + textBox->SetEnd( parseXY() ); + NeedRIGHT(); + break; + + case T_stroke: + parseStroke( stroke ); + textBox->SetStroke( stroke ); + break; + + case T_fill: + parseFill( fill ); + textBox->SetFillMode( fill.m_FillType ); + textBox->SetFillColor( fill.m_Color ); + break; + + case T_effects: + parseEDA_TEXT( static_cast( textBox.get() ), false ); + break; + + default: + Expecting( "start, end, stroke, fill or effects" ); + } + } + + textBox->UpdateTextPosition(); + + return textBox.release(); +} + + void SCH_SEXPR_PARSER::parsePAGE_INFO( PAGE_INFO& aPageInfo ) { wxCHECK_RET( ( CurTok() == T_page && m_requiredVersion <= 20200506 ) || CurTok() == T_paper, @@ -2132,45 +2257,45 @@ void SCH_SEXPR_PARSER::ParseSchematic( SCH_SHEET* aSheet, bool aIsCopyableOnly, // Complex hierarchies can have multiple copies of a sheet. This only // provides a simple tree to find the root sheet. sheet->SetParent( aSheet ); - screen->Append( static_cast( sheet ) ); + screen->Append( sheet ); break; } case T_junction: - screen->Append( static_cast( parseJunction() ) ); + screen->Append( parseJunction() ); break; case T_no_connect: - screen->Append( static_cast( parseNoConnect() ) ); + screen->Append( parseNoConnect() ); break; case T_bus_entry: - screen->Append( static_cast( parseBusEntry() ) ); + screen->Append( parseBusEntry() ); break; case T_polyline: case T_bus: case T_wire: - screen->Append( static_cast( parseLine() ) ); + screen->Append( parseLine() ); break; case T_arc: - screen->Append( static_cast( parseSchArc() ) ); + screen->Append( parseSchArc() ); break; case T_circle: - screen->Append( static_cast( parseSchCircle() ) ); + screen->Append( parseSchCircle() ); break; case T_rectangle: - screen->Append( static_cast( parseSchRectangle() ) ); + screen->Append( parseSchRectangle() ); break; case T_bezier: - screen->Append( static_cast( parseSchBezier() ) ); + screen->Append( parseSchBezier() ); break; - case T_netclass_flag: // legacy + case T_netclass_flag: // present only during early development of 7.0 KI_FALLTHROUGH; case T_text: @@ -2178,7 +2303,11 @@ void SCH_SEXPR_PARSER::ParseSchematic( SCH_SHEET* aSheet, bool aIsCopyableOnly, case T_global_label: case T_hierarchical_label: case T_directive_label: - screen->Append( static_cast( parseSchText() ) ); + screen->Append( parseSchText() ); + break; + + case T_text_box: + screen->Append( parseSchTextBox() ); break; case T_sheet_instances: @@ -3273,6 +3402,71 @@ SCH_TEXT* SCH_SEXPR_PARSER::parseSchText() } +SCH_TEXTBOX* SCH_SEXPR_PARSER::parseSchTextBox() +{ + wxCHECK_MSG( CurTok() == T_text_box, nullptr, + wxT( "Cannot parse " ) + GetTokenString( CurTok() ) + wxT( " as a text box." ) ); + + T token; + STROKE_PARAMS stroke( Mils2iu( DEFAULT_LINE_WIDTH_MILS ), PLOT_DASH_TYPE::DEFAULT ); + FILL_PARAMS fill; + std::unique_ptr textBox = std::make_unique(); + + NeedSYMBOL(); + + textBox->SetText( FromUTF8() ); + + for( token = NextTok(); token != T_RIGHT; token = NextTok() ) + { + if( token != T_LEFT ) + Expecting( T_LEFT ); + + token = NextTok(); + + switch( token ) + { + case T_start: + textBox->SetPosition( parseXY() ); + NeedRIGHT(); + break; + + case T_end: + textBox->SetEnd( parseXY() ); + NeedRIGHT(); + break; + + case T_stroke: + parseStroke( stroke ); + textBox->SetStroke( stroke ); + break; + + case T_fill: + parseFill( fill ); + textBox->SetFillMode( fill.m_FillType ); + textBox->SetFillColor( fill.m_Color ); + break; + + case T_effects: + parseEDA_TEXT( static_cast( textBox.get() ), false ); + break; + + case T_uuid: + NeedSYMBOL(); + const_cast( textBox->m_Uuid ) = KIID( FromUTF8() ); + NeedRIGHT(); + break; + + default: + Expecting( "start, end, stroke, fill or uuid" ); + } + } + + textBox->UpdateTextPosition(); + + return textBox.release(); +} + + void SCH_SEXPR_PARSER::parseBusAlias( SCH_SCREEN* aScreen ) { wxCHECK_RET( CurTok() == T_bus_alias, diff --git a/eeschema/sch_plugins/kicad/sch_sexpr_parser.h b/eeschema/sch_plugins/kicad/sch_sexpr_parser.h index 35e0a1e17c..232bcf3665 100644 --- a/eeschema/sch_plugins/kicad/sch_sexpr_parser.h +++ b/eeschema/sch_plugins/kicad/sch_sexpr_parser.h @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2020 CERN - * Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2021-2022 KiCad Developers, see AUTHORS.txt for contributors. * * @author Wayne Stambaugh * @@ -57,6 +57,7 @@ class SCH_SCREEN; class SCH_SHEET; class SCH_SHEET_PIN; class SCH_TEXT; +class SCH_TEXTBOX; class TITLE_BLOCK; @@ -177,6 +178,7 @@ class SCH_SEXPR_PARSER : public SCHEMATIC_LEXER LIB_SHAPE* parsePolyLine(); LIB_SHAPE* parseRectangle(); LIB_TEXT* parseText(); + LIB_TEXTBOX* parseTextBox(); void parsePAGE_INFO( PAGE_INFO& aPageInfo ); void parseTITLE_BLOCK( TITLE_BLOCK& aTitleBlock ); @@ -197,6 +199,7 @@ class SCH_SEXPR_PARSER : public SCHEMATIC_LEXER SCH_SHAPE* parseSchRectangle(); SCH_SHAPE* parseSchBezier(); SCH_TEXT* parseSchText(); + SCH_TEXTBOX* parseSchTextBox(); void parseBusAlias( SCH_SCREEN* aScreen ); public: diff --git a/eeschema/sch_plugins/kicad/sch_sexpr_plugin.cpp b/eeschema/sch_plugins/kicad/sch_sexpr_plugin.cpp index 779315d30e..c27011d1de 100644 --- a/eeschema/sch_plugins/kicad/sch_sexpr_plugin.cpp +++ b/eeschema/sch_plugins/kicad/sch_sexpr_plugin.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2020 CERN - * Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2021-2022 KiCad Developers, see AUTHORS.txt for contributors. * * @author Wayne Stambaugh * @@ -40,6 +40,7 @@ #include #include #include +#include #include #include #include @@ -50,6 +51,7 @@ #include #include #include +#include #include // for MAX_UNIT_COUNT_PER_PACKAGE definition #include #include @@ -251,10 +253,11 @@ static const char* getTextTypeToken( KICAD_T aType ) static void formatArc( OUTPUTFORMATTER* aFormatter, int aNestLevel, EDA_SHAPE* aArc, - const STROKE_PARAMS& aStroke, FILL_T aFillMode, const COLOR4D& aFillColor, - KIID aUuid = niluuid ) + bool aIsPrivate, const STROKE_PARAMS& aStroke, FILL_T aFillMode, + const COLOR4D& aFillColor, KIID aUuid = niluuid ) { - aFormatter->Print( aNestLevel, "(arc (start %s) (mid %s) (end %s)\n", + aFormatter->Print( aNestLevel, "(arc%s (start %s) (mid %s) (end %s)\n", + aIsPrivate ? " private" : "", FormatInternalUnits( aArc->GetStart() ).c_str(), FormatInternalUnits( aArc->GetArcMid() ).c_str(), FormatInternalUnits( aArc->GetEnd() ).c_str() ); @@ -272,10 +275,11 @@ static void formatArc( OUTPUTFORMATTER* aFormatter, int aNestLevel, EDA_SHAPE* a static void formatCircle( OUTPUTFORMATTER* aFormatter, int aNestLevel, EDA_SHAPE* aCircle, - const STROKE_PARAMS& aStroke, FILL_T aFillMode, const COLOR4D& aFillColor, - KIID aUuid = niluuid ) + bool aIsPrivate, const STROKE_PARAMS& aStroke, FILL_T aFillMode, + const COLOR4D& aFillColor, KIID aUuid = niluuid ) { - aFormatter->Print( aNestLevel, "(circle (center %s %s) (radius %s)\n", + aFormatter->Print( aNestLevel, "(circle%s (center %s %s) (radius %s)\n", + aIsPrivate ? " private" : "", FormatInternalUnits( aCircle->GetStart().x ).c_str(), FormatInternalUnits( aCircle->GetStart().y ).c_str(), FormatInternalUnits( aCircle->GetRadius() ).c_str() ); @@ -293,10 +297,11 @@ static void formatCircle( OUTPUTFORMATTER* aFormatter, int aNestLevel, EDA_SHAPE static void formatRect( OUTPUTFORMATTER* aFormatter, int aNestLevel, EDA_SHAPE* aRect, - const STROKE_PARAMS& aStroke, FILL_T aFillMode, const COLOR4D& aFillColor, - KIID aUuid = niluuid ) + bool aIsPrivate, const STROKE_PARAMS& aStroke, FILL_T aFillMode, + const COLOR4D& aFillColor, KIID aUuid = niluuid ) { - aFormatter->Print( aNestLevel, "(rectangle (start %s %s) (end %s %s)\n", + aFormatter->Print( aNestLevel, "(rectangle%s (start %s %s) (end %s %s)\n", + aIsPrivate ? " private" : "", FormatInternalUnits( aRect->GetStart().x ).c_str(), FormatInternalUnits( aRect->GetStart().y ).c_str(), FormatInternalUnits( aRect->GetEnd().x ).c_str(), @@ -314,10 +319,11 @@ static void formatRect( OUTPUTFORMATTER* aFormatter, int aNestLevel, EDA_SHAPE* static void formatBezier( OUTPUTFORMATTER* aFormatter, int aNestLevel, EDA_SHAPE* aBezier, - const STROKE_PARAMS& aStroke, FILL_T aFillMode, const COLOR4D& aFillColor, - KIID aUuid = niluuid ) + bool aIsPrivate, const STROKE_PARAMS& aStroke, FILL_T aFillMode, + const COLOR4D& aFillColor, KIID aUuid = niluuid ) { - aFormatter->Print( aNestLevel, "(bezier (pts " ); + aFormatter->Print( aNestLevel, "(bezier%s (pts ", + aIsPrivate ? " private" : "" ); for( const VECTOR2I& pt : { aBezier->GetStart(), aBezier->GetBezierC1(), aBezier->GetBezierC2(), aBezier->GetEnd() } ) @@ -342,12 +348,13 @@ static void formatBezier( OUTPUTFORMATTER* aFormatter, int aNestLevel, EDA_SHAPE static void formatPoly( OUTPUTFORMATTER* aFormatter, int aNestLevel, EDA_SHAPE* aPolyLine, - const STROKE_PARAMS& aStroke, FILL_T aFillMode, const COLOR4D& aFillColor, - KIID aUuid = niluuid ) + bool aIsPrivate, const STROKE_PARAMS& aStroke, FILL_T aFillMode, + const COLOR4D& aFillColor, KIID aUuid = niluuid ) { int newLine = 0; int lineCount = 1; - aFormatter->Print( aNestLevel, "(polyline\n" ); + aFormatter->Print( aNestLevel, "(polyline%s\n", + aIsPrivate ? " private" : "" ); aFormatter->Print( aNestLevel + 1, "(pts" ); for( const VECTOR2I& pt : aPolyLine->GetPolyShape().Outline( 0 ).CPoints() ) @@ -418,6 +425,8 @@ class SCH_SEXPR_PLUGIN_CACHE static void saveField( LIB_FIELD* aField, OUTPUTFORMATTER& aFormatter, int aNestLevel ); static void savePin( LIB_PIN* aPin, OUTPUTFORMATTER& aFormatter, int aNestLevel = 0 ); static void saveText( LIB_TEXT* aText, OUTPUTFORMATTER& aFormatter, int aNestLevel = 0 ); + static void saveTextBox( LIB_TEXTBOX* aTextBox, OUTPUTFORMATTER& aFormatter, + int aNestLevel = 0 ); static void saveDcmInfoAsFields( LIB_SYMBOL* aSymbol, OUTPUTFORMATTER& aFormatter, int& aNextFreeFieldId, int aNestLevel ); @@ -830,6 +839,10 @@ void SCH_SEXPR_PLUGIN::Format( SCH_SHEET* aSheet ) saveText( static_cast( item ), 1 ); break; + case SCH_TEXTBOX_T: + saveTextBox( static_cast( item ), 1 ); + break; + default: wxASSERT( "Unexpected schematic object type in SCH_SEXPR_PLUGIN::Format()" ); } @@ -1339,27 +1352,27 @@ void SCH_SEXPR_PLUGIN::saveShape( SCH_SHAPE* aShape, int aNestLevel ) switch( aShape->GetShape() ) { case SHAPE_T::ARC: - formatArc( m_out, aNestLevel, aShape, aShape->GetStroke(), aShape->GetFillMode(), + formatArc( m_out, aNestLevel, aShape, false, aShape->GetStroke(), aShape->GetFillMode(), aShape->GetFillColor(), aShape->m_Uuid ); break; case SHAPE_T::CIRCLE: - formatCircle( m_out, aNestLevel, aShape, aShape->GetStroke(), aShape->GetFillMode(), + formatCircle( m_out, aNestLevel, aShape, false, aShape->GetStroke(), aShape->GetFillMode(), aShape->GetFillColor(), aShape->m_Uuid ); break; case SHAPE_T::RECT: - formatRect( m_out, aNestLevel, aShape, aShape->GetStroke(), aShape->GetFillMode(), + formatRect( m_out, aNestLevel, aShape, false, aShape->GetStroke(), aShape->GetFillMode(), aShape->GetFillColor(), aShape->m_Uuid ); break; case SHAPE_T::BEZIER: - formatBezier( m_out, aNestLevel, aShape, aShape->GetStroke(), aShape->GetFillMode(), + formatBezier( m_out, aNestLevel, aShape, false, aShape->GetStroke(), aShape->GetFillMode(), aShape->GetFillColor(), aShape->m_Uuid ); break; case SHAPE_T::POLY: - formatPoly( m_out, aNestLevel, aShape, aShape->GetStroke(), aShape->GetFillMode(), + formatPoly( m_out, aNestLevel, aShape, false, aShape->GetStroke(), aShape->GetFillMode(), aShape->GetFillColor(), aShape->m_Uuid ); break; @@ -1438,7 +1451,6 @@ void SCH_SEXPR_PLUGIN::saveText( SCH_TEXT* aText, int aNestLevel ) case TEXT_SPIN_STYLE::RIGHT: break; case TEXT_SPIN_STYLE::BOTTOM: angle += ANGLE_180; break; } - } if( aText->GetText().Length() < 50 ) @@ -1461,7 +1473,7 @@ void SCH_SEXPR_PLUGIN::saveText( SCH_TEXT* aText, int aNestLevel ) m_out->Print( 0, " (fields_autoplaced)" ); m_out->Print( 0, "\n" ); - aText->Format( m_out, aNestLevel, 0 ); + aText->EDA_TEXT::Format( m_out, aNestLevel, 0 ); m_out->Print( aNestLevel + 1, "(uuid %s)\n", TO_UTF8( aText->m_Uuid.AsString() ) ); @@ -1475,6 +1487,33 @@ void SCH_SEXPR_PLUGIN::saveText( SCH_TEXT* aText, int aNestLevel ) } +void SCH_SEXPR_PLUGIN::saveTextBox( SCH_TEXTBOX* aTextBox, int aNestLevel ) +{ + wxCHECK_RET( aTextBox != nullptr && m_out != nullptr, "" ); + + m_out->Print( aNestLevel, "(text_box %s\n", + m_out->Quotew( aTextBox->GetText() ).c_str() ); + + m_out->Print( aNestLevel + 1, "(start %s %s) (end %s %s)\n", + FormatInternalUnits( aTextBox->GetStart().x ).c_str(), + FormatInternalUnits( aTextBox->GetStart().y ).c_str(), + FormatInternalUnits( aTextBox->GetEnd().x ).c_str(), + FormatInternalUnits( aTextBox->GetEnd().y ).c_str() ); + + aTextBox->GetStroke().Format( m_out, aNestLevel + 1 ); + m_out->Print( 0, "\n" ); + formatFill( m_out, aNestLevel + 1, aTextBox->GetFillMode(), aTextBox->GetFillColor() ); + m_out->Print( 0, "\n" ); + + aTextBox->EDA_TEXT::Format( m_out, aNestLevel, 0 ); + + if( aTextBox->m_Uuid != niluuid ) + m_out->Print( aNestLevel + 1, "(uuid %s)\n", TO_UTF8( aTextBox->m_Uuid.AsString() ) ); + + m_out->Print( aNestLevel, ")\n" ); +} + + void SCH_SEXPR_PLUGIN::saveBusAlias( std::shared_ptr aAlias, int aNestLevel ) { wxCHECK_RET( aAlias != nullptr, "BUS_ALIAS* is NULL" ); @@ -1970,6 +2009,7 @@ void SCH_SEXPR_PLUGIN_CACHE::saveSymbolDrawItem( LIB_ITEM* aItem, OUTPUTFORMATTE LIB_SHAPE* shape = static_cast( aItem ); STROKE_PARAMS stroke; FILL_T fillMode = shape->GetFillMode(); + bool isPrivate = shape->IsPrivate(); stroke.SetWidth( shape->GetWidth() ); @@ -1978,23 +2018,23 @@ void SCH_SEXPR_PLUGIN_CACHE::saveSymbolDrawItem( LIB_ITEM* aItem, OUTPUTFORMATTE switch( shape->GetShape() ) { case SHAPE_T::ARC: - formatArc( &aFormatter, aNestLevel, shape, stroke, fillMode, fillColor ); + formatArc( &aFormatter, aNestLevel, shape, isPrivate, stroke, fillMode, fillColor ); break; case SHAPE_T::CIRCLE: - formatCircle( &aFormatter, aNestLevel, shape, stroke, fillMode, fillColor ); + formatCircle( &aFormatter, aNestLevel, shape, isPrivate, stroke, fillMode, fillColor ); break; case SHAPE_T::RECT: - formatRect( &aFormatter, aNestLevel, shape, stroke, fillMode, fillColor ); + formatRect( &aFormatter, aNestLevel, shape, isPrivate, stroke, fillMode, fillColor ); break; case SHAPE_T::BEZIER: - formatBezier(&aFormatter, aNestLevel, shape, stroke, fillMode, fillColor ); + formatBezier(&aFormatter, aNestLevel, shape, isPrivate, stroke, fillMode, fillColor ); break; case SHAPE_T::POLY: - formatPoly( &aFormatter, aNestLevel, shape, stroke, fillMode, fillColor ); + formatPoly( &aFormatter, aNestLevel, shape, isPrivate, stroke, fillMode, fillColor ); break; default: @@ -2005,11 +2045,15 @@ void SCH_SEXPR_PLUGIN_CACHE::saveSymbolDrawItem( LIB_ITEM* aItem, OUTPUTFORMATTE } case LIB_PIN_T: - savePin( (LIB_PIN* ) aItem, aFormatter, aNestLevel ); + savePin( static_cast( aItem ), aFormatter, aNestLevel ); break; case LIB_TEXT_T: - saveText( ( LIB_TEXT* ) aItem, aFormatter, aNestLevel ); + saveText( static_cast( aItem ), aFormatter, aNestLevel ); + break; + + case LIB_TEXTBOX_T: + saveTextBox( static_cast( aItem ), aFormatter, aNestLevel ); break; default: @@ -2089,12 +2133,40 @@ void SCH_SEXPR_PLUGIN_CACHE::saveText( LIB_TEXT* aText, OUTPUTFORMATTER& aFormat { wxCHECK_RET( aText && aText->Type() == LIB_TEXT_T, "Invalid LIB_TEXT object." ); - aFormatter.Print( aNestLevel, "(text %s (at %s %s %g)\n", + aFormatter.Print( aNestLevel, "(text%s %s (at %s %s %g)\n", + aText->IsPrivate() ? " private" : "", aFormatter.Quotew( aText->GetText() ).c_str(), FormatInternalUnits( aText->GetPosition().x ).c_str(), FormatInternalUnits( aText->GetPosition().y ).c_str(), (double) aText->GetTextAngle().AsTenthsOfADegree() ); - aText->Format( &aFormatter, aNestLevel, 0 ); + + aText->EDA_TEXT::Format( &aFormatter, aNestLevel, 0 ); + aFormatter.Print( aNestLevel, ")\n" ); +} + + +void SCH_SEXPR_PLUGIN_CACHE::saveTextBox( LIB_TEXTBOX* aTextBox, OUTPUTFORMATTER& aFormatter, + int aNestLevel ) +{ + wxCHECK_RET( aTextBox && aTextBox->Type() == LIB_TEXTBOX_T, "Invalid LIB_TEXTBOX object." ); + + aFormatter.Print( aNestLevel, "(text_box%s %s\n", + aTextBox->IsPrivate() ? " private" : "", + aFormatter.Quotew( aTextBox->GetText() ).c_str() ); + + aFormatter.Print( aNestLevel + 1, "(start %s %s) (end %s %s)\n", + FormatInternalUnits( aTextBox->GetStart().x ).c_str(), + FormatInternalUnits( aTextBox->GetStart().y ).c_str(), + FormatInternalUnits( aTextBox->GetEnd().x ).c_str(), + FormatInternalUnits( aTextBox->GetEnd().y ).c_str() ); + + aTextBox->GetStroke().Format( &aFormatter, aNestLevel + 1 ); + aFormatter.Print( 0, "\n" ); + + formatFill( &aFormatter, aNestLevel + 1, aTextBox->GetFillMode(), aTextBox->GetFillColor() ); + aFormatter.Print( 0, "\n" ); + + aTextBox->EDA_TEXT::Format( &aFormatter, aNestLevel, 0 ); aFormatter.Print( aNestLevel, ")\n" ); } diff --git a/eeschema/sch_plugins/kicad/sch_sexpr_plugin.h b/eeschema/sch_plugins/kicad/sch_sexpr_plugin.h index 8f61336012..f768249b4e 100644 --- a/eeschema/sch_plugins/kicad/sch_sexpr_plugin.h +++ b/eeschema/sch_plugins/kicad/sch_sexpr_plugin.h @@ -42,6 +42,7 @@ class SCH_LINE; class SCH_SHAPE; class SCH_BUS_ENTRY_BASE; class SCH_TEXT; +class SCH_TEXTBOX; class SCH_SYMBOL; class SCH_FIELD; struct SYMBOL_INSTANCE_REFERENCE; @@ -151,6 +152,7 @@ private: void saveLine( SCH_LINE* aLine, int aNestLevel ); void saveShape( SCH_SHAPE* aShape, int aNestLevel ); void saveText( SCH_TEXT* aText, int aNestLevel ); + void saveTextBox( SCH_TEXTBOX* aText, int aNestLevel ); void saveBusAlias( std::shared_ptr aAlias, int aNestLevel ); void saveInstances( const std::vector& aSheets, const std::vector& aSymbols, int aNestLevel ); diff --git a/eeschema/sch_screen.cpp b/eeschema/sch_screen.cpp index f59b81fdec..15cf4f420a 100644 --- a/eeschema/sch_screen.cpp +++ b/eeschema/sch_screen.cpp @@ -547,34 +547,34 @@ bool SCH_SCREEN::IsTerminalPoint( const VECTOR2I& aPosition, int aLayer ) const wxCHECK_MSG( aLayer == LAYER_NOTES || aLayer == LAYER_BUS || aLayer == LAYER_WIRE, false, wxT( "Invalid layer type passed to SCH_SCREEN::IsTerminalPoint()." ) ); + SCH_SHEET_PIN* sheetPin; + SCH_LABEL_BASE* label; + switch( aLayer ) { case LAYER_BUS: - { if( GetBus( aPosition ) ) return true; - SCH_SHEET_PIN* sheetPin = GetSheetPin( aPosition ); + sheetPin = GetSheetPin( aPosition ); if( sheetPin && sheetPin->IsConnected( aPosition ) ) return true; - SCH_TEXT* label = GetLabel( aPosition ); + label = GetLabel( aPosition ); if( label && label->IsConnected( aPosition ) ) return true; - } + break; case LAYER_NOTES: - { if( GetLine( aPosition ) ) return true; - } + break; case LAYER_WIRE: - { if( GetItem( aPosition, 1, SCH_BUS_WIRE_ENTRY_T) ) return true; @@ -587,16 +587,16 @@ bool SCH_SCREEN::IsTerminalPoint( const VECTOR2I& aPosition, int aLayer ) const if( GetWire( aPosition ) ) return true; - SCH_TEXT* label = GetLabel( aPosition, 1 ); + label = GetLabel( aPosition, 1 ); if( label && label->IsConnected( aPosition ) ) return true; - SCH_SHEET_PIN* sheetPin = GetSheetPin( aPosition ); + sheetPin = GetSheetPin( aPosition ); if( sheetPin && sheetPin->IsConnected( aPosition ) ) return true; - } + break; default: @@ -1110,7 +1110,7 @@ SCH_LINE* SCH_SCREEN::GetLine( const VECTOR2I& aPosition, int aAccuracy, int aLa } -SCH_TEXT* SCH_SCREEN::GetLabel( const VECTOR2I& aPosition, int aAccuracy ) const +SCH_LABEL_BASE* SCH_SCREEN::GetLabel( const VECTOR2I& aPosition, int aAccuracy ) const { for( SCH_ITEM* item : Items().Overlapping( aPosition, aAccuracy ) ) { @@ -1121,7 +1121,7 @@ SCH_TEXT* SCH_SCREEN::GetLabel( const VECTOR2I& aPosition, int aAccuracy ) const case SCH_HIER_LABEL_T: case SCH_DIRECTIVE_LABEL_T: if( item->HitTest( aPosition, aAccuracy ) ) - return static_cast( item ); + return static_cast( item ); break; diff --git a/eeschema/sch_screen.h b/eeschema/sch_screen.h index f56ef0b353..350b093913 100644 --- a/eeschema/sch_screen.h +++ b/eeschema/sch_screen.h @@ -57,11 +57,10 @@ class LIB_SYMBOL; class LIB_PIN; class SCH_SYMBOL; class SCH_LINE; -class SCH_TEXT; +class SCH_LABEL_BASE; class PLOTTER; class REPORTER; class SCH_EDIT_FRAME; -class SCH_SHEET; class SCH_SHEET_LIST; class SCH_SEXPR_PARSER; class SCH_SEXPR_PLUGIN; @@ -437,10 +436,9 @@ public: * * @param[in] aPosition The VECTOR2I to test for label items. * @param aAccuracy Amount to inflate the item hit test bounding box. - * @return The SCH_TEXT* of the label item found at \a aPosition or NULL if item not - * found. + * @return The SCH_LABEL_BASE* of the label item found or nullptr. */ - SCH_TEXT* GetLabel( const VECTOR2I& aPosition, int aAccuracy = 0 ) const; + SCH_LABEL_BASE* GetLabel( const VECTOR2I& aPosition, int aAccuracy = 0 ) const; /** * Fetch a list of unique #LIB_SYMBOL object pointers required to properly render each diff --git a/eeschema/sch_shape.cpp b/eeschema/sch_shape.cpp index 6a90ed7d6e..ff81d161dd 100644 --- a/eeschema/sch_shape.cpp +++ b/eeschema/sch_shape.cpp @@ -34,8 +34,8 @@ #include -SCH_SHAPE::SCH_SHAPE( SHAPE_T aShape, int aLineWidth, FILL_T aFillType ) : - SCH_ITEM( nullptr, SCH_SHAPE_T ), +SCH_SHAPE::SCH_SHAPE( SHAPE_T aShape, int aLineWidth, FILL_T aFillType, KICAD_T aType ) : + SCH_ITEM( nullptr, aType ), EDA_SHAPE( aShape, aLineWidth, aFillType, false ) { SetLayer( LAYER_NOTES ); @@ -83,17 +83,13 @@ void SCH_SHAPE::MirrorVertically( int aCenter ) void SCH_SHAPE::Rotate( const VECTOR2I& aCenter ) { - rotate( aCenter, ANGLE_90 ); + rotate( aCenter, -ANGLE_90 ); } void SCH_SHAPE::Plot( PLOTTER* aPlotter ) const { int pen_size = std::max( GetPenWidth(), aPlotter->RenderSettings()->GetMinPenWidth() ); - VECTOR2I center; - int radius = 0; - EDA_ANGLE startAngle; - EDA_ANGLE endAngle; static std::vector cornerList; @@ -104,12 +100,6 @@ void SCH_SHAPE::Plot( PLOTTER* aPlotter ) const for( const VECTOR2I& pt : m_poly.Outline( 0 ).CPoints() ) cornerList.push_back( pt ); } - else if( GetShape() == SHAPE_T::ARC ) - { - center = getCenter(); - radius = GetRadius(); - CalcArcAngles( startAngle, endAngle ); - } if( GetStroke().GetColor() == COLOR4D::UNSPECIFIED ) aPlotter->SetColor( aPlotter->RenderSettings()->GetLayerColor( LAYER_NOTES ) ); @@ -122,11 +112,11 @@ void SCH_SHAPE::Plot( PLOTTER* aPlotter ) const switch( GetShape() ) { case SHAPE_T::ARC: - aPlotter->Arc( center, -endAngle, -startAngle, radius, FILL_T::NO_FILL, pen_size ); + aPlotter->Arc( getCenter(), GetStart(), GetEnd(), FILL_T::NO_FILL, pen_size, ARC_HIGH_DEF ); break; case SHAPE_T::CIRCLE: - aPlotter->Circle( GetStart(), GetRadius() * 2, FILL_T::NO_FILL, pen_size ); + aPlotter->Circle( getCenter(), GetRadius() * 2, FILL_T::NO_FILL, pen_size ); break; case SHAPE_T::RECT: @@ -169,11 +159,11 @@ void SCH_SHAPE::Plot( PLOTTER* aPlotter ) const switch( GetShape() ) { case SHAPE_T::ARC: - aPlotter->Arc( center, -endAngle, -startAngle, radius, m_fill, 0 ); + aPlotter->Arc( getCenter(), GetStart(), GetEnd(), m_fill, 0, ARC_HIGH_DEF ); break; case SHAPE_T::CIRCLE: - aPlotter->Circle( GetStart(), GetRadius() * 2, m_fill, 0 ); + aPlotter->Circle( getCenter(), GetRadius() * 2, m_fill, 0 ); break; case SHAPE_T::RECT: diff --git a/eeschema/sch_shape.h b/eeschema/sch_shape.h index 72b2bf4528..07458ef1e2 100644 --- a/eeschema/sch_shape.h +++ b/eeschema/sch_shape.h @@ -32,7 +32,8 @@ class SCH_SHAPE : public SCH_ITEM, public EDA_SHAPE { public: - SCH_SHAPE( SHAPE_T aShape, int aLineWidth = 0, FILL_T aFillType = FILL_T::NO_FILL ); + SCH_SHAPE( SHAPE_T aShape, int aLineWidth = 0, FILL_T aFillType = FILL_T::NO_FILL, + KICAD_T aType = SCH_SHAPE_T ); // Do not create a copy constructor. The one generated by the compiler is adequate. diff --git a/eeschema/sch_sheet_path.cpp b/eeschema/sch_sheet_path.cpp index 6ef34621a1..5eb16f6bff 100644 --- a/eeschema/sch_sheet_path.cpp +++ b/eeschema/sch_sheet_path.cpp @@ -291,7 +291,7 @@ wxString SCH_SHEET_PATH::PathHumanReadable( bool aUseShortRootName ) const } -void SCH_SHEET_PATH::UpdateAllScreenReferences() +void SCH_SHEET_PATH::UpdateAllScreenReferences() const { for( SCH_ITEM* item : LastScreen()->Items().OfType( SCH_SYMBOL_T ) ) { diff --git a/eeschema/sch_sheet_path.h b/eeschema/sch_sheet_path.h index cc31805a7e..62a50d490f 100644 --- a/eeschema/sch_sheet_path.h +++ b/eeschema/sch_sheet_path.h @@ -283,7 +283,7 @@ public: * Mandatory in complex hierarchies because sheets may use the same screen (basic schematic) * more than once but with different references and units according to the displayed sheet. */ - void UpdateAllScreenReferences(); + void UpdateAllScreenReferences() const; /** * Append a #SCH_REFERENCE object to \a aReferences based on \a aSymbol diff --git a/eeschema/sch_sheet_pin.cpp b/eeschema/sch_sheet_pin.cpp index c2f23fc5a9..e2a02ca88a 100644 --- a/eeschema/sch_sheet_pin.cpp +++ b/eeschema/sch_sheet_pin.cpp @@ -75,17 +75,14 @@ void SCH_SHEET_PIN::Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOf void SCH_SHEET_PIN::SwapData( SCH_ITEM* aItem ) { wxCHECK_RET( aItem->Type() == SCH_SHEET_PIN_T, - wxString::Format( wxT( "SCH_SHEET_PIN object cannot swap data with %s object." ), + wxString::Format( "SCH_SHEET_PIN object cannot swap data with %s object.", aItem->GetClass() ) ); - SCH_SHEET_PIN* pin = ( SCH_SHEET_PIN* ) aItem; - SCH_TEXT::SwapData( (SCH_TEXT*) pin ); - int tmp = pin->GetNumber(); - pin->SetNumber( GetNumber() ); - SetNumber( tmp ); - SHEET_SIDE stmp = pin->GetSide(); - pin->SetSide( GetSide() ); - SetSide( stmp ); + SCH_SHEET_PIN* pin = static_cast( aItem ); + + SCH_HIERLABEL::SwapData( pin ); + std::swap( m_number, pin->m_number ); + std::swap( m_edge, pin->m_edge ); } diff --git a/eeschema/sch_text.cpp b/eeschema/sch_text.cpp index 4e3048b803..de051938a3 100644 --- a/eeschema/sch_text.cpp +++ b/eeschema/sch_text.cpp @@ -265,8 +265,6 @@ int SCH_TEXT::GetTextOffset( const RENDER_SETTINGS* aSettings ) const ratio = DEFAULT_TEXT_OFFSET_RATIO; // For previews (such as in Preferences), etc. return KiROUND( ratio * GetTextSize().y ); - - return 0; } diff --git a/eeschema/sch_textbox.cpp b/eeschema/sch_textbox.cpp new file mode 100644 index 0000000000..07b24118d6 --- /dev/null +++ b/eeschema/sch_textbox.cpp @@ -0,0 +1,358 @@ +/* + * 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 + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +using KIGFX::SCH_RENDER_SETTINGS; + + +SCH_TEXTBOX::SCH_TEXTBOX( int aLineWidth, FILL_T aFillType, const wxString& text ) : + SCH_SHAPE( SHAPE_T::RECT, aLineWidth, aFillType, SCH_TEXTBOX_T ), + EDA_TEXT( text ) +{ + m_layer = LAYER_NOTES; + + SetHorizJustify( GR_TEXT_H_ALIGN_LEFT ); + SetVertJustify( GR_TEXT_V_ALIGN_TOP ); + SetMultilineAllowed( true ); +} + + +SCH_TEXTBOX::SCH_TEXTBOX( const SCH_TEXTBOX& aText ) : + SCH_SHAPE( aText ), + EDA_TEXT( aText ) +{ } + + +int SCH_TEXTBOX::GetTextMargin() const +{ + return KiROUND( GetTextSize().y * 0.8 ); +} + + +void SCH_TEXTBOX::MirrorHorizontally( int aCenter ) +{ + // Text is NOT really mirrored; it just has its justification flipped + if( GetTextAngle() == ANGLE_HORIZONTAL ) + { + SetHorizJustify( GetHorizJustify() == GR_TEXT_H_ALIGN_RIGHT ? GR_TEXT_H_ALIGN_LEFT + : GR_TEXT_H_ALIGN_RIGHT ); + } + + UpdateTextPosition(); +} + + +void SCH_TEXTBOX::MirrorVertically( int aCenter ) +{ + // Text is NOT really mirrored; it just has its justification flipped + if( GetTextAngle() == ANGLE_VERTICAL ) + { + SetHorizJustify( GetHorizJustify() == GR_TEXT_H_ALIGN_RIGHT ? GR_TEXT_H_ALIGN_LEFT + : GR_TEXT_H_ALIGN_RIGHT ); + } + + UpdateTextPosition(); +} + + +void SCH_TEXTBOX::Rotate( const VECTOR2I& aCenter ) +{ + SCH_SHAPE::Rotate( aCenter ); + + SetTextAngle( GetTextAngle() == ANGLE_VERTICAL ? ANGLE_HORIZONTAL : ANGLE_VERTICAL ); + UpdateTextPosition(); +} + + +void SCH_TEXTBOX::Rotate90( bool aClockwise ) +{ + SetTextAngle( GetTextAngle() == ANGLE_VERTICAL ? ANGLE_HORIZONTAL : ANGLE_VERTICAL ); + UpdateTextPosition(); +} + + +void SCH_TEXTBOX::UpdateTextPosition() +{ + int margin = GetTextMargin(); + BOX2I bbox( m_start, m_end - m_start ); + + bbox.Normalize(); + + if( GetTextAngle() == ANGLE_HORIZONTAL ) + { + if( GetHorizJustify() == GR_TEXT_H_ALIGN_RIGHT ) + SetTextPos( VECTOR2I( bbox.GetRight() - margin, bbox.GetTop() + margin ) ); + else + SetTextPos( VECTOR2I( bbox.GetLeft() + margin, bbox.GetTop() + margin ) ); + } + else + { + if( GetHorizJustify() == GR_TEXT_H_ALIGN_RIGHT ) + SetTextPos( VECTOR2I( bbox.GetLeft() + margin, bbox.GetTop() + margin ) ); + else + SetTextPos( VECTOR2I( bbox.GetLeft() + margin, bbox.GetBottom() - margin ) ); + } +} + + +void SCH_TEXTBOX::SwapData( SCH_ITEM* aItem ) +{ + SCH_TEXTBOX* item = static_cast( aItem ); + + std::swap( m_layer, item->m_layer ); + + SwapText( *item ); + SwapAttributes( *item ); + + SCH_SHAPE::SwapData( aItem ); +} + + +bool SCH_TEXTBOX::operator<( const SCH_ITEM& aItem ) const +{ + if( Type() != aItem.Type() ) + return Type() < aItem.Type(); + + auto other = static_cast( &aItem ); + + if( GetLayer() != other->GetLayer() ) + return GetLayer() < other->GetLayer(); + + if( GetPosition().x != other->GetPosition().x ) + return GetPosition().x < other->GetPosition().x; + + if( GetPosition().y != other->GetPosition().y ) + return GetPosition().y < other->GetPosition().y; + + return GetText() < other->GetText(); +} + + +int SCH_TEXTBOX::GetPenWidth() const +{ + return GetEffectiveTextPenWidth(); +} + + +KIFONT::FONT* SCH_TEXTBOX::GetDrawFont() const +{ + KIFONT::FONT* font = EDA_TEXT::GetFont(); + + if( !font ) + font = KIFONT::FONT::GetFont( GetDefaultFont(), IsBold(), IsItalic() ); + + return font; +} + + +void SCH_TEXTBOX::Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset ) +{ + COLOR4D color = aSettings->GetLayerColor( m_layer ); + EDA_TEXT::Print( aSettings, aOffset, color ); +} + + +wxString SCH_TEXTBOX::GetShownText( int aDepth ) const +{ + std::function textResolver = + [&]( wxString* token ) -> bool + { + if( token->Contains( ':' ) ) + { + if( Schematic()->ResolveCrossReference( token, aDepth ) ) + return true; + } + else + { + SCHEMATIC* schematic = Schematic(); + SCH_SHEET* sheet = schematic ? schematic->CurrentSheet().Last() : nullptr; + + if( sheet && sheet->ResolveTextVar( token, aDepth + 1 ) ) + return true; + } + + return false; + }; + + std::function schematicTextResolver = + [&]( wxString* token ) -> bool + { + return Schematic()->ResolveTextVar( token, aDepth + 1 ); + }; + + wxString text = EDA_TEXT::GetShownText(); + + if( HasTextVars() ) + { + PROJECT* project = nullptr; + + if( Schematic() ) + project = &Schematic()->Prj(); + + if( aDepth < 10 ) + text = ExpandTextVars( text, &textResolver, &schematicTextResolver, project ); + } + + KIFONT::FONT* font = GetDrawFont(); + VECTOR2D size = GetEnd() - GetStart(); + int colWidth = GetTextAngle() == ANGLE_HORIZONTAL ? size.x : size.y; + + colWidth = abs( colWidth ) - GetTextMargin() * 2; + font->LinebreakText( text, colWidth, GetTextSize(), GetTextThickness(), IsBold(), IsItalic() ); + + return text; +} + + +bool SCH_TEXTBOX::HitTest( const VECTOR2I& aPosition, int aAccuracy ) const +{ + EDA_RECT rect = GetBoundingBox(); + + rect.Inflate( aAccuracy ); + + return rect.Contains( aPosition ); +} + + +bool SCH_TEXTBOX::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) const +{ + EDA_RECT rect = aRect; + + rect.Inflate( aAccuracy ); + + if( aContained ) + return rect.Contains( GetBoundingBox() ); + + return rect.Intersects( GetBoundingBox() ); +} + + +wxString SCH_TEXTBOX::GetSelectMenuText( EDA_UNITS aUnits ) const +{ + return wxString::Format( _( "Graphic Text Box" ) ); +} + + +BITMAPS SCH_TEXTBOX::GetMenuImage() const +{ + return BITMAPS::add_textbox; +} + + +void SCH_TEXTBOX::Plot( PLOTTER* aPlotter ) const +{ + RENDER_SETTINGS* settings = aPlotter->RenderSettings(); + KIFONT::FONT* font = GetDrawFont(); + int penWidth = GetEffectiveTextPenWidth( settings->GetDefaultPenWidth() ); + FILL_T fill = m_fill; + COLOR4D color = settings->GetLayerColor( LAYER_NOTES ); + + if( fill != FILL_T::NO_FILL ) + { + COLOR4D fillColor = color; + + if( aPlotter->GetColorMode() ) + { + if( fill == FILL_T::FILLED_WITH_BG_BODYCOLOR ) + fillColor = aPlotter->RenderSettings()->GetLayerColor( LAYER_DEVICE_BACKGROUND ); + else if( fill == FILL_T::FILLED_WITH_COLOR ) + fillColor = GetFillColor(); + } + + aPlotter->SetColor( fillColor ); + aPlotter->Rect( m_start, m_end, fill, 0 ); + + fill = FILL_T::NO_FILL; + } + + aPlotter->SetColor( color ); + aPlotter->Rect( m_start, m_end, fill, penWidth ); + + penWidth = std::max( penWidth, settings->GetMinPenWidth() ); + aPlotter->SetCurrentLineWidth( penWidth ); + + std::vector positions; + wxArrayString strings_list; + wxStringSplit( GetShownText(), strings_list, '\n' ); + positions.reserve( strings_list.Count() ); + + GetLinePositions( positions, (int) strings_list.Count() ); + + for( unsigned ii = 0; ii < strings_list.Count(); ii++ ) + { + aPlotter->Text( positions[ii], color, strings_list.Item( ii ), GetTextAngle(), + GetTextSize(), GetHorizJustify(), GetVertJustify(), penWidth, IsItalic(), + IsBold(), false, font ); + } +} + + +void SCH_TEXTBOX::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector& aList ) +{ + wxString msg; + + // Don't use GetShownText() here; we want to show the user the variable references + aList.emplace_back( _( "Text Box" ), UnescapeString( GetText() ) ); + + wxString textStyle[] = { _( "Normal" ), _( "Italic" ), _( "Bold" ), _( "Bold Italic" ) }; + int style = IsBold() && IsItalic() ? 3 : IsBold() ? 2 : IsItalic() ? 1 : 0; + aList.emplace_back( _( "Style" ), textStyle[style] ); + + aList.emplace_back( _( "Text Size" ), MessageTextFromValue( aFrame->GetUserUnits(), + GetTextWidth() ) ); +} + + +#if defined(DEBUG) + +void SCH_TEXTBOX::Show( int nestLevel, std::ostream& os ) const +{ + // XML output: + wxString s = GetClass(); + + NestedSpace( nestLevel, os ) << '<' << s.Lower().mb_str() + << " layer=\"" << m_layer << '"' + << '>' + << TO_UTF8( GetText() ) + << "\n"; +} + +#endif + + diff --git a/eeschema/sch_textbox.h b/eeschema/sch_textbox.h new file mode 100644 index 0000000000..782b504600 --- /dev/null +++ b/eeschema/sch_textbox.h @@ -0,0 +1,117 @@ +/* + * 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 +#include + + +class HTML_MESSAGE_BOX; + +class SCH_TEXTBOX : public SCH_SHAPE, public EDA_TEXT +{ +public: + SCH_TEXTBOX( int aLineWidth = 0, FILL_T aFillType = FILL_T::NO_FILL, + const wxString& aText = wxEmptyString ); + + SCH_TEXTBOX( const SCH_TEXTBOX& aText ); + + ~SCH_TEXTBOX() { } + + static inline bool ClassOf( const EDA_ITEM* aItem ) + { + return aItem && SCH_TEXTBOX_T == aItem->Type(); + } + + virtual wxString GetClass() const override + { + return wxT( "SCH_TEXTBOX" ); + } + + int GetTextMargin() const; + + void UpdateTextPosition(); + + wxString GetShownText( int aDepth = 0 ) const override; + + void Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& offset ) override; + + void SwapData( SCH_ITEM* aItem ) override; + + bool operator<( const SCH_ITEM& aItem ) const override; + + int GetPenWidth() const override; + + KIFONT::FONT* GetDrawFont() 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; + void Rotate( const VECTOR2I& aCenter ) override; + + virtual void Rotate90( bool aClockwise ); + + bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override; + + bool HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy = 0 ) const override; + + bool Matches( const wxFindReplaceData& aSearchData, void* aAuxData ) const override + { + return SCH_ITEM::Matches( GetText(), aSearchData ); + } + + bool Replace( const wxFindReplaceData& aSearchData, void* aAuxData ) override + { + return EDA_TEXT::Replace( aSearchData ); + } + + virtual bool IsReplaceable() const override { return true; } + + wxString GetSelectMenuText( EDA_UNITS aUnits ) const override; + + BITMAPS GetMenuImage() const override; + + void Plot( PLOTTER* aPlotter ) const override; + + EDA_ITEM* Clone() const override + { + return new SCH_TEXTBOX( *this ); + } + + void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector& aList ) override; + +#if defined(DEBUG) + void Show( int nestLevel, std::ostream& os ) const override; +#endif +}; + + +#endif /* SCH_TEXTBOX_H */ diff --git a/eeschema/schematic.keywords b/eeschema/schematic.keywords index 62820b80df..4859613145 100644 --- a/eeschema/schematic.keywords +++ b/eeschema/schematic.keywords @@ -97,6 +97,7 @@ portrait power power_in power_out +private property property_del pts @@ -117,6 +118,7 @@ stroke symbol symbol_instances text +text_box thickness title title_block diff --git a/eeschema/symbol_editor/menubar_symbol_editor.cpp b/eeschema/symbol_editor/menubar_symbol_editor.cpp index 4228b39a32..ac4263b7f0 100644 --- a/eeschema/symbol_editor/menubar_symbol_editor.cpp +++ b/eeschema/symbol_editor/menubar_symbol_editor.cpp @@ -3,7 +3,7 @@ * * Copyright (C) 2007 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com * Copyright (C) 2009 Wayne Stambaugh - * Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 1992-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 @@ -139,6 +139,7 @@ void SYMBOL_EDIT_FRAME::ReCreateMenuBar() placeMenu->Add( EE_ACTIONS::placeSymbolPin ); placeMenu->Add( EE_ACTIONS::placeSymbolText ); + placeMenu->Add( EE_ACTIONS::drawSymbolTextBox ); placeMenu->Add( EE_ACTIONS::drawRectangle ); placeMenu->Add( EE_ACTIONS::drawCircle ); placeMenu->Add( EE_ACTIONS::drawArc ); diff --git a/eeschema/symbol_editor/symbol_edit_frame.cpp b/eeschema/symbol_editor/symbol_edit_frame.cpp index cadea00891..8634187e85 100644 --- a/eeschema/symbol_editor/symbol_edit_frame.cpp +++ b/eeschema/symbol_editor/symbol_edit_frame.cpp @@ -3,7 +3,7 @@ * * Copyright (C) 2013 Jean-Pierre Charras, jp.charras at wanadoo.fr * Copyright (C) 2008 Wayne Stambaugh - * Copyright (C) 2004-2021 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2004-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 @@ -486,6 +486,7 @@ void SYMBOL_EDIT_FRAME::setupUIConditions() mgr->SetConditions( ACTIONS::deleteTool, EDIT_TOOL( ACTIONS::deleteTool ) ); mgr->SetConditions( EE_ACTIONS::placeSymbolPin, EDIT_TOOL( EE_ACTIONS::placeSymbolPin ) ); mgr->SetConditions( EE_ACTIONS::placeSymbolText, EDIT_TOOL( EE_ACTIONS::placeSymbolText ) ); + mgr->SetConditions( EE_ACTIONS::drawSymbolTextBox, EDIT_TOOL( EE_ACTIONS::drawSymbolTextBox ) ); mgr->SetConditions( EE_ACTIONS::drawRectangle, EDIT_TOOL( EE_ACTIONS::drawRectangle ) ); mgr->SetConditions( EE_ACTIONS::drawCircle, EDIT_TOOL( EE_ACTIONS::drawCircle ) ); mgr->SetConditions( EE_ACTIONS::drawArc, EDIT_TOOL( EE_ACTIONS::drawArc ) ); diff --git a/eeschema/symbol_editor/toolbars_symbol_editor.cpp b/eeschema/symbol_editor/toolbars_symbol_editor.cpp index de14a17041..b3ced1d875 100644 --- a/eeschema/symbol_editor/toolbars_symbol_editor.cpp +++ b/eeschema/symbol_editor/toolbars_symbol_editor.cpp @@ -3,7 +3,7 @@ * * Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com * Copyright (C) 2008 Wayne Stambaugh - * Copyright (C) 2004-2020 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2004-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 @@ -27,7 +27,6 @@ #include #include #include -#include #include #include #include @@ -60,6 +59,7 @@ void SYMBOL_EDIT_FRAME::ReCreateVToolbar() m_drawToolBar->AddScaledSeparator( this ); m_drawToolBar->Add( EE_ACTIONS::placeSymbolPin, ACTION_TOOLBAR::TOGGLE ); m_drawToolBar->Add( EE_ACTIONS::placeSymbolText, ACTION_TOOLBAR::TOGGLE ); + m_drawToolBar->Add( EE_ACTIONS::drawSymbolTextBox, ACTION_TOOLBAR::TOGGLE ); m_drawToolBar->Add( EE_ACTIONS::drawRectangle, ACTION_TOOLBAR::TOGGLE ); m_drawToolBar->Add( EE_ACTIONS::drawCircle, ACTION_TOOLBAR::TOGGLE ); m_drawToolBar->Add( EE_ACTIONS::drawArc, ACTION_TOOLBAR::TOGGLE ); diff --git a/eeschema/toolbars_sch_editor.cpp b/eeschema/toolbars_sch_editor.cpp index 49416e5160..6d28191538 100644 --- a/eeschema/toolbars_sch_editor.cpp +++ b/eeschema/toolbars_sch_editor.cpp @@ -160,8 +160,12 @@ void SCH_EDIT_FRAME::ReCreateVToolbar() m_drawToolBar->Add( EE_ACTIONS::importSheetPin, ACTION_TOOLBAR::TOGGLE ); m_drawToolBar->AddScaledSeparator( this ); - m_drawToolBar->Add( EE_ACTIONS::drawLines, ACTION_TOOLBAR::TOGGLE ); m_drawToolBar->Add( EE_ACTIONS::placeSchematicText, ACTION_TOOLBAR::TOGGLE ); + m_drawToolBar->Add( EE_ACTIONS::drawTextBox, ACTION_TOOLBAR::TOGGLE ); + m_drawToolBar->Add( EE_ACTIONS::drawRectangle, ACTION_TOOLBAR::TOGGLE ); + m_drawToolBar->Add( EE_ACTIONS::drawCircle, ACTION_TOOLBAR::TOGGLE ); + m_drawToolBar->Add( EE_ACTIONS::drawArc, ACTION_TOOLBAR::TOGGLE ); + m_drawToolBar->Add( EE_ACTIONS::drawLines, ACTION_TOOLBAR::TOGGLE ); m_drawToolBar->Add( EE_ACTIONS::placeImage, ACTION_TOOLBAR::TOGGLE ); m_drawToolBar->Add( ACTIONS::deleteTool, ACTION_TOOLBAR::TOGGLE ); diff --git a/eeschema/tools/backannotate.cpp b/eeschema/tools/backannotate.cpp index 319a4d4e37..57ec1d374e 100644 --- a/eeschema/tools/backannotate.cpp +++ b/eeschema/tools/backannotate.cpp @@ -544,7 +544,7 @@ void BACK_ANNOTATE::processNetNameChange( const wxString& aRef, SCH_PIN* aPin, m_frame->SaveCopyInUndoList( screen, driver, UNDO_REDO::CHANGED, m_appendUndo ); m_appendUndo = true; - static_cast( driver )->SetText( aNewName ); + static_cast( driver )->SetText( aNewName ); } m_reporter.ReportHead( msg, RPT_SEVERITY_ACTION ); diff --git a/eeschema/tools/ee_actions.cpp b/eeschema/tools/ee_actions.cpp index 0565017ce6..83c53805e1 100644 --- a/eeschema/tools/ee_actions.cpp +++ b/eeschema/tools/ee_actions.cpp @@ -225,6 +225,11 @@ TOOL_ACTION EE_ACTIONS::placeSymbolText( "eeschema.SymbolDrawing.placeSymbolText _( "Add Text" ), _( "Add a text item" ), BITMAPS::text, AF_ACTIVATE, (void*) LIB_TEXT_T ); +TOOL_ACTION EE_ACTIONS::drawSymbolTextBox( "eeschema.SymbolDrawing.drawSymbolTextBox", + AS_GLOBAL, 0, "", + _( "Add Text Box" ), _( "Add a text box item" ), + BITMAPS::add_textbox, AF_ACTIVATE, (void*) LIB_TEXTBOX_T ); + TOOL_ACTION EE_ACTIONS::drawSymbolLines( "eeschema.SymbolDrawing.drawSymbolLines", AS_GLOBAL, 0, "", _( "Add Lines" ), _( "Add connected graphic lines" ), @@ -335,6 +340,11 @@ TOOL_ACTION EE_ACTIONS::placeSchematicText( "eeschema.InteractiveDrawing.placeSc _( "Add Text" ), _( "Add text" ), BITMAPS::text, AF_ACTIVATE ); +TOOL_ACTION EE_ACTIONS::drawTextBox( "eeschema.InteractiveDrawing.drawTextBox", + AS_GLOBAL, 0, "", + _( "Add Text Box" ), _( "Add a text box" ), + BITMAPS::add_textbox, AF_ACTIVATE, (void*) SHAPE_T::RECT ); + TOOL_ACTION EE_ACTIONS::drawRectangle( "eeschema.InteractiveDrawing.drawRectangle", AS_GLOBAL, 0, "", _( "Add Rectangle" ), _( "Add a rectangle" ), diff --git a/eeschema/tools/ee_actions.h b/eeschema/tools/ee_actions.h index 763c0fdfc8..e03826bc1b 100644 --- a/eeschema/tools/ee_actions.h +++ b/eeschema/tools/ee_actions.h @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2019 CERN - * Copyright (C) 2019-2021 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2019-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 @@ -89,6 +89,7 @@ public: static TOOL_ACTION drawSheet; static TOOL_ACTION importSheetPin; static TOOL_ACTION placeSchematicText; + static TOOL_ACTION drawTextBox; static TOOL_ACTION drawRectangle; static TOOL_ACTION drawCircle; static TOOL_ACTION drawArc; @@ -103,6 +104,7 @@ public: // Symbol Tools static TOOL_ACTION placeSymbolPin; static TOOL_ACTION placeSymbolText; + static TOOL_ACTION drawSymbolTextBox; static TOOL_ACTION drawSymbolLines; static TOOL_ACTION placeSymbolAnchor; static TOOL_ACTION finishDrawing; diff --git a/eeschema/tools/ee_grid_helper.cpp b/eeschema/tools/ee_grid_helper.cpp index 9fc02fe5eb..33a30156f1 100644 --- a/eeschema/tools/ee_grid_helper.cpp +++ b/eeschema/tools/ee_grid_helper.cpp @@ -69,7 +69,7 @@ VECTOR2I EE_GRID_HELPER::BestDragOrigin( const VECTOR2I& aMousePos, int aLayer, // we can only consider anchors from text objects if they are the only thing // selected. bool includeText = ( aItems.Size() == 1 - || aItems.OnlyContains( { SCH_TEXT_T, SCH_FIELD_T } ) ); + || aItems.OnlyContains( { SCH_TEXT_T, SCH_TEXTBOX_T, SCH_FIELD_T } ) ); for( EDA_ITEM* item : aItems ) computeAnchors( static_cast( item ), aMousePos, true, includeText ); @@ -274,6 +274,7 @@ void EE_GRID_HELPER::computeAnchors( SCH_ITEM *aItem, const VECTOR2I &aRefPos, b switch( aItem->Type() ) { case SCH_TEXT_T: + case SCH_TEXTBOX_T: case SCH_FIELD_T: { if( aIncludeText ) diff --git a/eeschema/tools/ee_point_editor.cpp b/eeschema/tools/ee_point_editor.cpp index 01dc3a937b..6dda3fbf3e 100644 --- a/eeschema/tools/ee_point_editor.cpp +++ b/eeschema/tools/ee_point_editor.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2019 CERN - * Copyright (C) 2019-2021 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2019-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 @@ -32,15 +32,16 @@ using namespace std::placeholders; #include #include #include -#include #include #include #include #include +#include #include #include #include #include +#include // Few constants to avoid using bare numbers for point indices @@ -110,8 +111,8 @@ public: points->AddPoint( VECTOR2I( botRight.x, topLeft.y ) ); points->AddPoint( VECTOR2I( topLeft.x, botRight.y ) ); points->AddPoint( botRight ); - } break; + } case SHAPE_T::POLY: for( const VECTOR2I& pt : shape->GetPolyShape().Outline( 0 ).CPoints() ) @@ -126,8 +127,30 @@ public: default: UNIMPLEMENTED_FOR( shape->SHAPE_T_asString() ); } - } + break; + } + + case LIB_TEXTBOX_T: + { + LIB_TEXTBOX* textBox = static_cast( aItem ); + + // point editor works only with rectangles having width and height > 0 + // Some symbols can have rectangles with width or height < 0 + // So normalize the size: + BOX2I dummy; + dummy.SetOrigin( mapCoords( textBox->GetPosition() ) ); + dummy.SetEnd( mapCoords( textBox->GetEnd() ) ); + dummy.Normalize(); + VECTOR2I topLeft = dummy.GetPosition(); + VECTOR2I botRight = dummy.GetEnd(); + + points->AddPoint( topLeft ); + points->AddPoint( VECTOR2I( botRight.x, topLeft.y ) ); + points->AddPoint( VECTOR2I( topLeft.x, botRight.y ) ); + points->AddPoint( botRight ); + break; + } case SCH_SHAPE_T: { @@ -162,8 +185,8 @@ public: points->AddPoint( VECTOR2I( botRight.x, topLeft.y ) ); points->AddPoint( VECTOR2I( topLeft.x, botRight.y ) ); points->AddPoint( botRight ); - } break; + } case SHAPE_T::POLY: for( const VECTOR2I& pt : shape->GetPolyShape().Outline( 0 ).CPoints() ) @@ -178,8 +201,30 @@ public: default: UNIMPLEMENTED_FOR( shape->SHAPE_T_asString() ); } - } + break; + } + + case SCH_TEXTBOX_T: + { + SCH_TEXTBOX* textBox = static_cast( aItem ); + + // point editor works only with rectangles having width and height > 0 + // Some symbols can have rectangles with width or height < 0 + // So normalize the size: + BOX2I dummy; + dummy.SetOrigin( textBox->GetPosition() ); + dummy.SetEnd( textBox->GetEnd() ); + dummy.Normalize(); + VECTOR2I topLeft = dummy.GetPosition(); + VECTOR2I botRight = dummy.GetEnd(); + + points->AddPoint( topLeft ); + points->AddPoint( VECTOR2I( botRight.x, topLeft.y ) ); + points->AddPoint( VECTOR2I( topLeft.x, botRight.y ) ); + points->AddPoint( botRight ); + break; + } case SCH_SHEET_T: { @@ -191,8 +236,8 @@ public: points->AddPoint( VECTOR2I( botRight.x, topLeft.y ) ); points->AddPoint( VECTOR2I( topLeft.x, botRight.y ) ); points->AddPoint( botRight ); - } break; + } case SCH_BITMAP_T: { @@ -204,8 +249,8 @@ public: points->AddPoint( VECTOR2I( botRight.x, topLeft.y ) ); points->AddPoint( VECTOR2I( topLeft.x, botRight.y ) ); points->AddPoint( botRight ); - } break; + } case SCH_LINE_T: { @@ -243,8 +288,8 @@ public: points->AddPoint( line->GetStartPoint(), connectedStart ); points->AddPoint( line->GetEndPoint(), connectedEnd ); - } break; + } default: points.reset(); @@ -327,7 +372,9 @@ int EE_POINT_EDITOR::Main( const TOOL_EVENT& aEvent ) { static KICAD_T supportedTypes[] = { LIB_SHAPE_T, + LIB_TEXTBOX_T, SCH_SHAPE_T, + SCH_TEXTBOX_T, SCH_SHEET_T, SCH_ITEM_LOCATE_GRAPHIC_LINE_T, SCH_BITMAP_T, @@ -589,8 +636,8 @@ void EE_POINT_EDITOR::updateParentItem() const shape->SetPosition( mapCoords( topLeft ) ); shape->SetEnd( mapCoords( botRight ) ); - } break; + } case SHAPE_T::BEZIER: // TODO @@ -599,8 +646,27 @@ void EE_POINT_EDITOR::updateParentItem() const default: UNIMPLEMENTED_FOR( shape->SHAPE_T_asString() ); } - } + break; + } + + case LIB_TEXTBOX_T: + { + LIB_TEXTBOX* textbox = static_cast( item ); + EE_GRID_HELPER gridHelper( m_toolMgr ); + VECTOR2I topLeft = m_editPoints->Point( RECT_TOPLEFT ).GetPosition(); + VECTOR2I topRight = m_editPoints->Point( RECT_TOPRIGHT ).GetPosition(); + VECTOR2I botLeft = m_editPoints->Point( RECT_BOTLEFT ).GetPosition(); + VECTOR2I botRight = m_editPoints->Point( RECT_BOTRIGHT ).GetPosition(); + + pinEditedCorner( getEditedPointIndex(), Mils2iu( 1 ), Mils2iu( 1 ), + topLeft, topRight, botLeft, botRight, &gridHelper ); + + textbox->SetPosition( mapCoords( topLeft ) ); + textbox->SetEnd( mapCoords( botRight ) ); + textbox->UpdateTextPosition(); + break; + } case SCH_SHAPE_T: { @@ -656,8 +722,8 @@ void EE_POINT_EDITOR::updateParentItem() const shape->SetPosition( topLeft ); shape->SetEnd( botRight ); - } break; + } case SHAPE_T::BEZIER: // TODO @@ -666,8 +732,27 @@ void EE_POINT_EDITOR::updateParentItem() const default: UNIMPLEMENTED_FOR( shape->SHAPE_T_asString() ); } - } + break; + } + + case SCH_TEXTBOX_T: + { + SCH_TEXTBOX* textBox = static_cast( item ); + EE_GRID_HELPER gridHelper( m_toolMgr ); + VECTOR2I topLeft = m_editPoints->Point( RECT_TOPLEFT ).GetPosition(); + VECTOR2I topRight = m_editPoints->Point( RECT_TOPRIGHT ).GetPosition(); + VECTOR2I botLeft = m_editPoints->Point( RECT_BOTLEFT ).GetPosition(); + VECTOR2I botRight = m_editPoints->Point( RECT_BOTRIGHT ).GetPosition(); + + pinEditedCorner( getEditedPointIndex(), Mils2iu( 1 ), Mils2iu( 1 ), + topLeft, topRight, botLeft, botRight, &gridHelper ); + + textBox->SetPosition( topLeft ); + textBox->SetEnd( botRight ); + textBox->UpdateTextPosition(); + break; + } case SCH_BITMAP_T: { @@ -690,8 +775,8 @@ void EE_POINT_EDITOR::updateParentItem() const double heightRatio = newHeight / oldHeight; bitmap->SetImageScale( bitmap->GetImageScale() * std::min( widthRatio, heightRatio ) ); - } break; + } case SCH_SHEET_T: { @@ -737,8 +822,9 @@ void EE_POINT_EDITOR::updateParentItem() const pin->SetPosition( pos ); } - } + break; + } case SCH_LINE_T: { @@ -770,8 +856,9 @@ void EE_POINT_EDITOR::updateParentItem() const updateItem( connected.first, true ); } - } + break; + } default: break; @@ -847,8 +934,8 @@ void EE_POINT_EDITOR::updatePoints() m_editPoints->Point( RECT_TOPRIGHT ).SetPosition( VECTOR2I( botRight.x, topLeft.y ) ); m_editPoints->Point( RECT_BOTLEFT ).SetPosition( VECTOR2I( topLeft.x, botRight.y ) ); m_editPoints->Point( RECT_BOTRIGHT ).SetPosition( botRight ); - } break; + } case SHAPE_T::BEZIER: // TODO @@ -857,8 +944,30 @@ void EE_POINT_EDITOR::updatePoints() default: UNIMPLEMENTED_FOR( shape->SHAPE_T_asString() ); } - } + break; + } + + case LIB_TEXTBOX_T: + { + LIB_TEXTBOX* textbox = static_cast( item ); + + // point editor works only with rectangles having width and height > 0 + // Some symbols can have rectangles with width or height < 0 + // So normalize the size: + BOX2I dummy; + dummy.SetOrigin( mapCoords( textbox->GetPosition() ) ); + dummy.SetEnd( mapCoords( textbox->GetEnd() ) ); + dummy.Normalize(); + VECTOR2I topLeft = dummy.GetPosition(); + VECTOR2I botRight = dummy.GetEnd(); + + m_editPoints->Point( RECT_TOPLEFT ).SetPosition( topLeft ); + m_editPoints->Point( RECT_TOPRIGHT ).SetPosition( VECTOR2I( botRight.x, topLeft.y ) ); + m_editPoints->Point( RECT_BOTLEFT ).SetPosition( VECTOR2I( topLeft.x, botRight.y ) ); + m_editPoints->Point( RECT_BOTRIGHT ).SetPosition( botRight ); + break; + } case SCH_SHAPE_T: { @@ -913,8 +1022,8 @@ void EE_POINT_EDITOR::updatePoints() m_editPoints->Point( RECT_TOPRIGHT ).SetPosition( VECTOR2I( botRight.x, topLeft.y ) ); m_editPoints->Point( RECT_BOTLEFT ).SetPosition( VECTOR2I( topLeft.x, botRight.y ) ); m_editPoints->Point( RECT_BOTRIGHT ).SetPosition( botRight ); - } break; + } case SHAPE_T::BEZIER: // TODO @@ -923,8 +1032,30 @@ void EE_POINT_EDITOR::updatePoints() default: UNIMPLEMENTED_FOR( shape->SHAPE_T_asString() ); } - } + break; + } + + case SCH_TEXTBOX_T: + { + SCH_TEXTBOX* textBox = static_cast( item ); + + // point editor works only with rectangles having width and height > 0 + // Some symbols can have rectangles with width or height < 0 + // So normalize the size: + BOX2I dummy; + dummy.SetOrigin( textBox->GetPosition() ); + dummy.SetEnd( textBox->GetEnd() ); + dummy.Normalize(); + VECTOR2I topLeft = dummy.GetPosition(); + VECTOR2I botRight = dummy.GetEnd(); + + m_editPoints->Point( RECT_TOPLEFT ).SetPosition( topLeft ); + m_editPoints->Point( RECT_TOPRIGHT ).SetPosition( VECTOR2I( botRight.x, topLeft.y ) ); + m_editPoints->Point( RECT_BOTLEFT ).SetPosition( VECTOR2I( topLeft.x, botRight.y ) ); + m_editPoints->Point( RECT_BOTRIGHT ).SetPosition( botRight ); + break; + } case SCH_BITMAP_T: { @@ -936,8 +1067,8 @@ void EE_POINT_EDITOR::updatePoints() m_editPoints->Point( RECT_TOPRIGHT ).SetPosition( botRight.x, topLeft.y ); m_editPoints->Point( RECT_BOTLEFT ).SetPosition( topLeft.x, botRight.y ); m_editPoints->Point( RECT_BOTRIGHT ).SetPosition( botRight ); - } break; + } case SCH_SHEET_T: { @@ -949,8 +1080,8 @@ void EE_POINT_EDITOR::updatePoints() m_editPoints->Point( RECT_TOPRIGHT ).SetPosition( botRight.x, topLeft.y ); m_editPoints->Point( RECT_BOTLEFT ).SetPosition( topLeft.x, botRight.y ); m_editPoints->Point( RECT_BOTRIGHT ).SetPosition( botRight ); - } break; + } case SCH_LINE_T: { @@ -958,8 +1089,8 @@ void EE_POINT_EDITOR::updatePoints() m_editPoints->Point( LINE_START ).SetPosition( line->GetStartPoint() ); m_editPoints->Point( LINE_END ).SetPosition( line->GetEndPoint() ); - } break; + } default: break; diff --git a/eeschema/tools/sch_drawing_tools.cpp b/eeschema/tools/sch_drawing_tools.cpp index 33d71420ad..b9aa47559f 100644 --- a/eeschema/tools/sch_drawing_tools.cpp +++ b/eeschema/tools/sch_drawing_tools.cpp @@ -39,6 +39,7 @@ #include #include #include +#include #include #include #include @@ -1057,7 +1058,7 @@ int SCH_DRAWING_TOOLS::TwoClickPlace( const TOOL_EVENT& aEvent ) else if( isNetLabel ) m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::LABEL_NET ); else if( isClassLabel ) - m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::LABEL_NET ); // JEY TODO: LABEL_CLASS cursor + m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::LABEL_NET ); // JEY TODO: netclass directive cursor else if( isHierLabel ) m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::LABEL_HIER ); else @@ -1299,6 +1300,7 @@ int SCH_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent ) else m_inDrawShape = true; + bool isTextBox = aEvent.IsAction( &EE_ACTIONS::drawTextBox ); SHAPE_T type = aEvent.Parameter(); // We might be running as the same shape in another co-routine. Make sure that one @@ -1390,7 +1392,11 @@ int SCH_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent ) int lineWidth = Mils2iu( cfg->m_Drawing.default_line_thickness ); - item = new SCH_SHAPE( type, lineWidth, m_lastFillStyle ); + if( isTextBox ) + item = new SCH_TEXTBOX( lineWidth, m_lastFillStyle ); + else + item = new SCH_SHAPE( type, lineWidth, m_lastFillStyle ); + item->SetFlags( IS_NEW ); item->BeginEdit( (wxPoint) cursorPos ); @@ -1407,6 +1413,17 @@ int SCH_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent ) item->ClearEditFlags(); item->SetFlags( IS_NEW ); + if( isTextBox ) + { + DIALOG_TEXT_PROPERTIES dlg( m_frame, item ); + + if( dlg.ShowQuasiModal() != wxID_OK ) + { + cleanup(); + continue; + } + } + m_frame->AddItemToScreenAndUndoList( m_frame->GetScreen(), item, false ); m_selectionTool->AddItemToSel( item ); item = nullptr; @@ -1664,5 +1681,6 @@ void SCH_DRAWING_TOOLS::setTransitions() Go( &SCH_DRAWING_TOOLS::DrawShape, EE_ACTIONS::drawRectangle.MakeEvent() ); Go( &SCH_DRAWING_TOOLS::DrawShape, EE_ACTIONS::drawCircle.MakeEvent() ); Go( &SCH_DRAWING_TOOLS::DrawShape, EE_ACTIONS::drawArc.MakeEvent() ); + Go( &SCH_DRAWING_TOOLS::DrawShape, EE_ACTIONS::drawTextBox.MakeEvent() ); Go( &SCH_DRAWING_TOOLS::PlaceImage, EE_ACTIONS::placeImage.MakeEvent() ); } diff --git a/eeschema/tools/sch_edit_tool.cpp b/eeschema/tools/sch_edit_tool.cpp index 2c9584a2a7..6f562d95cb 100644 --- a/eeschema/tools/sch_edit_tool.cpp +++ b/eeschema/tools/sch_edit_tool.cpp @@ -41,6 +41,7 @@ #include #include #include +#include #include #include #include @@ -250,6 +251,7 @@ bool SCH_EDIT_TOOL::Init() case SCH_SHEET_T: case SCH_SHEET_PIN_T: case SCH_TEXT_T: + case SCH_TEXTBOX_T: case SCH_LABEL_T: case SCH_GLOBAL_LABEL_T: case SCH_HIER_LABEL_T: @@ -430,6 +432,7 @@ bool SCH_EDIT_TOOL::Init() const KICAD_T rotatableItems[] = { SCH_SHAPE_T, SCH_TEXT_T, + SCH_TEXTBOX_T, SCH_LABEL_T, SCH_GLOBAL_LABEL_T, SCH_HIER_LABEL_T, @@ -482,8 +485,10 @@ int SCH_EDIT_TOOL::Rotate( const TOOL_EVENT& aEvent ) { if( moving && selection.HasReferencePoint() ) rotPoint = selection.GetReferencePoint(); - else + else if( head->IsConnectable() ) rotPoint = head->GetPosition(); + else + rotPoint = m_frame->GetNearestHalfGridPosition( head->GetBoundingBox().GetCenter() ); if( !moving ) saveCopyInUndoList( head, UNDO_REDO::CHANGED ); @@ -550,12 +555,12 @@ int SCH_EDIT_TOOL::Rotate( const TOOL_EVENT& aEvent ) } case SCH_SHAPE_T: + case SCH_TEXTBOX_T: for( int i = 0; clockwise ? i < 1 : i < 3; ++i ) head->Rotate( rotPoint ); break; - case SCH_BITMAP_T: for( int i = 0; clockwise ? i < 3 : i < 1; ++i ) head->Rotate( rotPoint ); @@ -731,6 +736,18 @@ int SCH_EDIT_TOOL::Mirror( const TOOL_EVENT& aEvent ) break; } + case SCH_TEXTBOX_T: + { + SCH_TEXTBOX* textBox = static_cast( item ); + + if( vertical ) + textBox->MirrorVertically( mirrorPoint.y ); + else + textBox->MirrorHorizontally( mirrorPoint.x ); + + break; + } + case SCH_SHEET_PIN_T: { // mirror within parent sheet @@ -947,6 +964,7 @@ static KICAD_T deletableItems[] = SCH_BUS_WIRE_ENTRY_T, SCH_SHAPE_T, SCH_TEXT_T, + SCH_TEXTBOX_T, SCH_LABEL_T, SCH_GLOBAL_LABEL_T, SCH_HIER_LABEL_T, @@ -1456,8 +1474,9 @@ int SCH_EDIT_TOOL::Properties( const TOOL_EVENT& aEvent ) break; case SCH_TEXT_T: + case SCH_TEXTBOX_T: { - DIALOG_TEXT_PROPERTIES dlg( m_frame, static_cast( item ) ); + DIALOG_TEXT_PROPERTIES dlg( m_frame, static_cast( item ) ); // Must be quasi modal for syntax help if( dlg.ShowQuasiModal() == wxID_OK ) diff --git a/eeschema/tools/sch_line_wire_bus_tool.cpp b/eeschema/tools/sch_line_wire_bus_tool.cpp index e493e10a84..6031cbf8fa 100644 --- a/eeschema/tools/sch_line_wire_bus_tool.cpp +++ b/eeschema/tools/sch_line_wire_bus_tool.cpp @@ -59,7 +59,6 @@ #include #include #include -#include #include #include #include diff --git a/eeschema/tools/sch_move_tool.cpp b/eeschema/tools/sch_move_tool.cpp index 560f9c0a1d..bb648c4202 100644 --- a/eeschema/tools/sch_move_tool.cpp +++ b/eeschema/tools/sch_move_tool.cpp @@ -585,7 +585,7 @@ void SCH_MOVE_TOOL::getConnectedDragItems( SCH_ITEM* aOriginalItem, const VECTOR { if( item->Type() == SCH_LABEL_T || item->Type() == SCH_DIRECTIVE_LABEL_T ) { - SCH_TEXT* label = static_cast( item ); + SCH_LABEL_BASE* label = static_cast( item ); if( label->IsSelected() ) continue; // These will be moved on their own because they're selected @@ -655,9 +655,10 @@ void SCH_MOVE_TOOL::getConnectedDragItems( SCH_ITEM* aOriginalItem, const VECTOR // Select labels that are connected to a wire (or bus) being moved. if( aOriginalItem->Type() == SCH_LINE_T && test->CanConnect( aOriginalItem ) ) { - SCH_TEXT* label = static_cast( test ); - SCH_LINE* line = static_cast( aOriginalItem ); - bool oneEndFixed = !line->HasFlag( STARTPOINT ) || !line->HasFlag( ENDPOINT ); + SCH_LABEL_BASE* label = static_cast( test ); + SCH_LINE* line = static_cast( aOriginalItem ); + + bool oneEndFixed = !line->HasFlag( STARTPOINT ) || !line->HasFlag( ENDPOINT ); if( line->HitTest( label->GetTextPos(), 1 ) ) { @@ -776,7 +777,7 @@ void SCH_MOVE_TOOL::moveItem( EDA_ITEM* aItem, const VECTOR2I& aDelta ) case SCH_LABEL_T: case SCH_DIRECTIVE_LABEL_T: { - SCH_TEXT* label = static_cast( aItem ); + SCH_LABEL_BASE* label = static_cast( aItem ); if( m_specialCaseLabels.count( label ) ) { diff --git a/eeschema/tools/sch_move_tool.h b/eeschema/tools/sch_move_tool.h index 2850f8acac..908873bfda 100644 --- a/eeschema/tools/sch_move_tool.h +++ b/eeschema/tools/sch_move_tool.h @@ -92,7 +92,7 @@ private: // A map of labels to scaling factors. Used to scale the movement vector for labels that // are attached to wires which have only one end moving. - std::map m_specialCaseLabels; + std::map m_specialCaseLabels; }; diff --git a/eeschema/tools/symbol_editor_drawing_tools.cpp b/eeschema/tools/symbol_editor_drawing_tools.cpp index 9d0fdcbe6c..9f71c209bd 100644 --- a/eeschema/tools/symbol_editor_drawing_tools.cpp +++ b/eeschema/tools/symbol_editor_drawing_tools.cpp @@ -29,10 +29,12 @@ #include #include #include +#include #include #include #include #include +#include "dialog_lib_textbox_properties.h" static void* g_lastPinWeakPtr; @@ -162,7 +164,7 @@ int SYMBOL_EDITOR_DRAWING_TOOLS::TwoClickPlace( const TOOL_EVENT& aEvent ) { case LIB_PIN_T: { - item = pinTool->CreatePin( wxPoint( cursorPos.x, -cursorPos.y ), symbol ); + item = pinTool->CreatePin( VECTOR2I( cursorPos.x, -cursorPos.y ), symbol ); g_lastPinWeakPtr = item; break; } @@ -170,7 +172,7 @@ int SYMBOL_EDITOR_DRAWING_TOOLS::TwoClickPlace( const TOOL_EVENT& aEvent ) { LIB_TEXT* text = new LIB_TEXT( symbol ); - text->SetPosition( wxPoint( cursorPos.x, -cursorPos.y ) ); + text->SetPosition( VECTOR2I( cursorPos.x, -cursorPos.y ) ); text->SetTextSize( wxSize( Mils2iu( settings->m_Defaults.text_size ), Mils2iu( settings->m_Defaults.text_size ) ) ); text->SetTextAngle( m_lastTextAngle ); @@ -239,7 +241,7 @@ int SYMBOL_EDITOR_DRAWING_TOOLS::TwoClickPlace( const TOOL_EVENT& aEvent ) } else if( item && ( evt->IsAction( &ACTIONS::refreshPreview ) || evt->IsMotion() ) ) { - static_cast( item )->SetPosition( wxPoint( cursorPos.x, -cursorPos.y ) ); + static_cast( item )->SetPosition( VECTOR2I( cursorPos.x, -cursorPos.y ) ); m_view->ClearPreview(); m_view->AddToPreview( item->Clone() ); } @@ -267,6 +269,7 @@ int SYMBOL_EDITOR_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent ) SHAPE_T type = aEvent.Parameter(); LIB_SYMBOL* symbol = m_frame->GetCurSymbol(); LIB_ITEM* item = nullptr; + bool isTextBox = aEvent.IsAction( &EE_ACTIONS::drawSymbolTextBox ); // We might be running as the same shape in another co-routine. Make sure that one // gets whacked. @@ -353,9 +356,13 @@ int SYMBOL_EDITOR_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent ) int lineWidth = Mils2iu( settings->m_Defaults.line_width ); - item = new LIB_SHAPE( symbol, type, lineWidth, m_lastFillStyle ); + if( isTextBox ) + item = new LIB_TEXTBOX( symbol, lineWidth, m_lastFillStyle ); + else + item = new LIB_SHAPE( symbol, type, lineWidth, m_lastFillStyle ); + item->SetFlags( IS_NEW ); - item->BeginEdit( wxPoint( cursorPos.x, -cursorPos.y ) ); + item->BeginEdit( VECTOR2I( cursorPos.x, -cursorPos.y ) ); if( m_drawSpecificUnit ) item->SetUnit( m_frame->GetUnit() ); @@ -375,10 +382,22 @@ int SYMBOL_EDITOR_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent ) } if( evt->IsDblClick( BUT_LEFT ) || evt->IsAction( &EE_ACTIONS::finishDrawing ) - || !item->ContinueEdit( wxPoint( cursorPos.x, -cursorPos.y ) ) ) + || !item->ContinueEdit( VECTOR2I( cursorPos.x, -cursorPos.y ) ) ) { item->EndEdit(); item->ClearEditFlags(); + + if( isTextBox ) + { + DIALOG_LIB_TEXTBOX_PROPERTIES dlg( m_frame, static_cast( item ) ); + + if( dlg.ShowQuasiModal() != wxID_OK ) + { + cleanup(); + continue; + } + } + m_view->ClearPreview(); m_frame->SaveCopyInUndoList( symbol ); @@ -392,7 +411,7 @@ int SYMBOL_EDITOR_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent ) } else if( item && ( evt->IsAction( &ACTIONS::refreshPreview ) || evt->IsMotion() ) ) { - item->CalcEdit( wxPoint( cursorPos.x, -cursorPos.y ) ); + item->CalcEdit( VECTOR2I( cursorPos.x, -cursorPos.y ) ); m_view->ClearPreview(); m_view->AddToPreview( item->Clone() ); } @@ -465,7 +484,7 @@ int SYMBOL_EDITOR_DRAWING_TOOLS::PlaceAnchor( const TOOL_EVENT& aEvent ) continue; VECTOR2I cursorPos = getViewControls()->GetCursorPosition( !evt->DisableGridSnapping() ); - wxPoint offset( -cursorPos.x, cursorPos.y ); + VECTOR2I offset( -cursorPos.x, cursorPos.y ); symbol->SetOffset( offset ); @@ -531,6 +550,7 @@ void SYMBOL_EDITOR_DRAWING_TOOLS::setTransitions() Go( &SYMBOL_EDITOR_DRAWING_TOOLS::DrawShape, EE_ACTIONS::drawCircle.MakeEvent() ); Go( &SYMBOL_EDITOR_DRAWING_TOOLS::DrawShape, EE_ACTIONS::drawArc.MakeEvent() ); Go( &SYMBOL_EDITOR_DRAWING_TOOLS::DrawShape, EE_ACTIONS::drawSymbolLines.MakeEvent() ); + Go( &SYMBOL_EDITOR_DRAWING_TOOLS::DrawShape, EE_ACTIONS::drawSymbolTextBox.MakeEvent() ); Go( &SYMBOL_EDITOR_DRAWING_TOOLS::PlaceAnchor, EE_ACTIONS::placeSymbolAnchor.MakeEvent() ); Go( &SYMBOL_EDITOR_DRAWING_TOOLS::RepeatDrawItem, EE_ACTIONS::repeatDrawItem.MakeEvent() ); } diff --git a/eeschema/tools/symbol_editor_edit_tool.cpp b/eeschema/tools/symbol_editor_edit_tool.cpp index 30c01c5a08..a3a51e4353 100644 --- a/eeschema/tools/symbol_editor_edit_tool.cpp +++ b/eeschema/tools/symbol_editor_edit_tool.cpp @@ -40,6 +40,8 @@ #include #include #include "symbol_editor_edit_tool.h" +#include "dialog_lib_textbox_properties.h" +#include "lib_textbox.h" #include // for KiROUND SYMBOL_EDITOR_EDIT_TOOL::SYMBOL_EDITOR_EDIT_TOOL() : @@ -440,6 +442,10 @@ int SYMBOL_EDITOR_EDIT_TOOL::Properties( const TOOL_EVENT& aEvent ) editTextProperties( item ); break; + case LIB_TEXTBOX_T: + editTextBoxProperties( item ); + break; + case LIB_FIELD_T: editFieldProperties( (LIB_FIELD*) item ); break; @@ -485,7 +491,23 @@ void SYMBOL_EDITOR_EDIT_TOOL::editTextProperties( LIB_ITEM* aItem ) if ( aItem->Type() != LIB_TEXT_T ) return; - DIALOG_LIB_TEXT_PROPERTIES dlg( m_frame, (LIB_TEXT*) aItem ); + DIALOG_LIB_TEXT_PROPERTIES dlg( m_frame, static_cast( aItem ) ); + + if( dlg.ShowModal() != wxID_OK ) + return; + + updateItem( aItem, true ); + m_frame->GetCanvas()->Refresh(); + m_frame->OnModify( ); +} + + +void SYMBOL_EDITOR_EDIT_TOOL::editTextBoxProperties( LIB_ITEM* aItem ) +{ + if ( aItem->Type() != LIB_TEXTBOX_T ) + return; + + DIALOG_LIB_TEXTBOX_PROPERTIES dlg( m_frame, static_cast( aItem ) ); if( dlg.ShowModal() != wxID_OK ) return; diff --git a/eeschema/tools/symbol_editor_edit_tool.h b/eeschema/tools/symbol_editor_edit_tool.h index b88aed0af8..b617969e91 100644 --- a/eeschema/tools/symbol_editor_edit_tool.h +++ b/eeschema/tools/symbol_editor_edit_tool.h @@ -66,6 +66,7 @@ public: private: void editShapeProperties( LIB_ITEM* aItem ); void editTextProperties( LIB_ITEM* aItem ); + void editTextBoxProperties( LIB_ITEM* aItem ); void editFieldProperties( LIB_FIELD* aField ); void editSymbolProperties(); diff --git a/include/bitmaps/bitmap_info.h b/include/bitmaps/bitmap_info.h index a24b736026..fbf96108fe 100644 --- a/include/bitmaps/bitmap_info.h +++ b/include/bitmaps/bitmap_info.h @@ -192,6 +192,7 @@ const std::vector g_BitmapInfo = { { BITMAPS::add_radial_dimension, wxT( "add_radial_dimension_24.png" ), 24, wxT( "light" ) }, { BITMAPS::add_rectangle, wxT( "add_rectangle_24.png" ), 24, wxT( "light" ) }, { BITMAPS::add_symbol_to_schematic, wxT( "add_symbol_to_schematic_24.png" ), 24, wxT( "light" ) }, + { BITMAPS::add_textbox, wxT( "add_textbox_24.png" ), 24, wxT( "light" ) }, { BITMAPS::add_tracks, wxT( "add_tracks_24.png" ), 24, wxT( "light" ) }, { BITMAPS::add_via, wxT( "add_via_24.png" ), 24, wxT( "light" ) }, { BITMAPS::add_zone_cutout, wxT( "add_zone_cutout_24.png" ), 24, wxT( "light" ) }, diff --git a/include/bitmaps/bitmaps_list.h b/include/bitmaps/bitmaps_list.h index df2b89b164..c28f56790f 100644 --- a/include/bitmaps/bitmaps_list.h +++ b/include/bitmaps/bitmaps_list.h @@ -72,6 +72,7 @@ enum class BITMAPS : unsigned int add_radial_dimension, add_rectangle, add_symbol_to_schematic, + add_textbox, add_tracks, add_via, add_zone, diff --git a/include/core/typeinfo.h b/include/core/typeinfo.h index cad1f5ef64..f34e92d9dc 100644 --- a/include/core/typeinfo.h +++ b/include/core/typeinfo.h @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2014 CERN - * Copyright (C) 2004-2021 KiCad Developers, see change_log.txt for contributors. + * Copyright (C) 2004-2022 KiCad Developers, see change_log.txt for contributors. * @author Tomasz Wlostowski * * This program is free software; you can redistribute it and/or @@ -134,6 +134,7 @@ enum KICAD_T SCH_LINE_T, SCH_SHAPE_T, SCH_BITMAP_T, + SCH_TEXTBOX_T, SCH_TEXT_T, SCH_LABEL_T, SCH_GLOBAL_LABEL_T, @@ -186,6 +187,7 @@ enum KICAD_T LIB_ALIAS_T, LIB_SHAPE_T, LIB_TEXT_T, + LIB_TEXTBOX_T, LIB_PIN_T, /* diff --git a/include/font/font.h b/include/font/font.h index dc731e175a..bde0f55dcd 100644 --- a/include/font/font.h +++ b/include/font/font.h @@ -31,8 +31,6 @@ #include #include #include - -#include #include #include @@ -123,10 +121,10 @@ public: * object, such as a run of superscript characters) * @param aAttrs are the styling attributes of the text, including its rotation */ - void Draw( KIGFX::GAL* aGal, const UTF8& aText, const VECTOR2I& aPosition, + void Draw( KIGFX::GAL* aGal, const wxString& aText, const VECTOR2I& aPosition, const VECTOR2I& aCursor, const TEXT_ATTRIBUTES& aAttrs ) const; - void Draw( KIGFX::GAL* aGal, const UTF8& aText, const VECTOR2I& aPosition, + void Draw( KIGFX::GAL* aGal, const wxString& aText, const VECTOR2I& aPosition, const TEXT_ATTRIBUTES& aAttributes ) const { Draw( aGal, aText, aPosition, VECTOR2I( 0, 0 ), aAttributes ); @@ -137,9 +135,15 @@ public: * * @return a VECTOR2I giving the width and height of text. */ - VECTOR2I StringBoundaryLimits( const UTF8& aText, const VECTOR2I& aSize, int aThickness, + VECTOR2I StringBoundaryLimits( const wxString& aText, const VECTOR2I& aSize, int aThickness, bool aBold, bool aItalic ) const; + /** + * Insert \n characters into text to ensure that no lines are wider than \a aColumnWidth. + */ + void LinebreakText( wxString& aText, int aColumnWidth, const VECTOR2I& aGlyphSize, + int aThickness, bool aBold, bool aItalic ) const; + /** * Compute the vertical position of an overbar. This is the distance between the text * baseline and the overbar. @@ -167,7 +171,7 @@ public: * @return text cursor position after this text */ virtual VECTOR2I GetTextAsGlyphs( BOX2I* aBBox, std::vector>* aGlyphs, - const UTF8& aText, const VECTOR2I& aSize, + const wxString& aText, const VECTOR2I& aSize, const VECTOR2I& aPosition, const EDA_ANGLE& aAngle, bool aMirror, const VECTOR2I& aOrigin, TEXT_STYLE_FLAGS aTextStyle ) const = 0; @@ -179,7 +183,7 @@ protected: * @param aText is the text to be checked. * @return unsigned - The number of lines in aText. */ - inline unsigned linesCount( const UTF8& aText ) const + inline unsigned linesCount( const wxString& aText ) const { if( aText.empty() ) return 0; // std::count does not work well with empty strings @@ -202,7 +206,7 @@ protected: * @param aOrigin is the point around which the text should be rotated, mirrored, etc. * @return new cursor position in non-rotated, non-mirrored coordinates */ - void drawSingleLineText( KIGFX::GAL* aGal, BOX2I* aBoundingBox, const UTF8& aText, + void drawSingleLineText( KIGFX::GAL* aGal, BOX2I* aBoundingBox, const wxString& aText, const VECTOR2I& aPosition, const VECTOR2I& aSize, const EDA_ANGLE& aAngle, bool aMirror, const VECTOR2I& aOrigin, bool aItalic ) const; @@ -217,18 +221,21 @@ protected: * @param aSize is the cap-height and em-width of the text. * @return new cursor position */ - VECTOR2I boundingBoxSingleLine( BOX2I* aBBox, const UTF8& aText, const VECTOR2I& aPosition, + VECTOR2I boundingBoxSingleLine( BOX2I* aBBox, const wxString& aText, const VECTOR2I& aPosition, const VECTOR2I& aSize, bool aItalic ) const; - void getLinePositions( const UTF8& aText, const VECTOR2I& aPosition, + void getLinePositions( const wxString& aText, const VECTOR2I& aPosition, wxArrayString& aTextLines, std::vector& aPositions, std::vector& aExtents, const TEXT_ATTRIBUTES& aAttrs ) const; VECTOR2I drawMarkup( BOX2I* aBoundingBox, std::vector>* aGlyphs, - const UTF8& aText, const VECTOR2I& aPosition, const VECTOR2I& aSize, + const wxString& aText, const VECTOR2I& aPosition, const VECTOR2I& aSize, const EDA_ANGLE& aAngle, bool aMirror, const VECTOR2I& aOrigin, TEXT_STYLE_FLAGS aTextStyle ) const; + void wordbreakMarkup( std::vector>* aWords, const wxString& aText, + const VECTOR2I& aSize, TEXT_STYLE_FLAGS aTextStyle ) const; + ///< Factor that determines the pitch between 2 lines. static constexpr double INTERLINE_PITCH_RATIO = 1.62; // The golden mean diff --git a/include/font/outline_font.h b/include/font/outline_font.h index e6dcad1432..cf0bb7bbfb 100644 --- a/include/font/outline_font.h +++ b/include/font/outline_font.h @@ -83,7 +83,7 @@ public: * @param aAttributes contains text attributes (angle, line spacing, ...) * @return bounding box width/height */ - VECTOR2D Draw( KIGFX::GAL* aGal, const UTF8& aText, const VECTOR2D& aPosition, + VECTOR2D Draw( KIGFX::GAL* aGal, const wxString& aText, const VECTOR2D& aPosition, const VECTOR2D& aOrigin, const TEXT_ATTRIBUTES& aAttributes ) const override; #endif @@ -100,9 +100,9 @@ public: double GetInterline( double aGlyphHeight = 0.0, double aLineSpacing = 1.0 ) const override; VECTOR2I GetTextAsGlyphs( BOX2I* aBoundingBox, std::vector>* aGlyphs, - const UTF8& aText, const VECTOR2I& aSize, const VECTOR2I& aPosition, - const EDA_ANGLE& aAngle, bool aMirror, const VECTOR2I& aOrigin, - TEXT_STYLE_FLAGS aTextStyle ) const override; + const wxString& aText, const VECTOR2I& aSize, + const VECTOR2I& aPosition, const EDA_ANGLE& aAngle, bool aMirror, + const VECTOR2I& aOrigin, TEXT_STYLE_FLAGS aTextStyle ) const override; /** * Like GetTextAsGlyphs, but handles multiple lines. @@ -115,13 +115,13 @@ public: void GetLinesAsGlyphs( std::vector>* aGlyphs, const EDA_TEXT* aText ) const; - void GetLinesAsGlyphs( std::vector>* aGlyphs, const UTF8& aText, + void GetLinesAsGlyphs( std::vector>* aGlyphs, const wxString& aText, const VECTOR2I& aPosition, const TEXT_ATTRIBUTES& aAttrs ) const; const FT_Face& GetFace() const { return m_face; } #if 0 - void RenderToOpenGLCanvas( KIGFX::OPENGL_FREETYPE& aTarget, const UTF8& aString, + void RenderToOpenGLCanvas( KIGFX::OPENGL_FREETYPE& aTarget, const wxString& aString, const VECTOR2D& aSize, const wxPoint& aPosition, const EDA_ANGLE& aAngle, bool aMirror ) const; #endif diff --git a/include/font/stroke_font.h b/include/font/stroke_font.h index 2c551307e0..7a23952d36 100644 --- a/include/font/stroke_font.h +++ b/include/font/stroke_font.h @@ -77,9 +77,9 @@ public: double GetInterline( double aGlyphHeight, double aLineSpacing = 1.0 ) const override; VECTOR2I GetTextAsGlyphs( BOX2I* aBoundingBox, std::vector>* aGlyphs, - const UTF8& aText, const VECTOR2I& aSize, const VECTOR2I& aPosition, - const EDA_ANGLE& aAngle, bool aMirror, const VECTOR2I& aOrigin, - TEXT_STYLE_FLAGS aTextStyle ) const override; + const wxString& aText, const VECTOR2I& aSize, + const VECTOR2I& aPosition, const EDA_ANGLE& aAngle, bool aMirror, + const VECTOR2I& aOrigin, TEXT_STYLE_FLAGS aTextStyle ) const override; private: /** diff --git a/include/plotters/plotter.h b/include/plotters/plotter.h index 03a4d43d11..2a79ea09ce 100644 --- a/include/plotters/plotter.h +++ b/include/plotters/plotter.h @@ -217,6 +217,12 @@ public: virtual void Circle( const VECTOR2I& pos, int diametre, FILL_T fill, int width = USE_DEFAULT_LINE_WIDTH ) = 0; + /** + * Generic fallback: arc rendered as a polyline. + */ + virtual void Arc( const VECTOR2I& aCenter, const VECTOR2I& aStart, const VECTOR2I& aEnd, + FILL_T aFill, int aWidth, int aMaxError ); + /** * Generic fallback: arc rendered as a polyline. */ diff --git a/include/plotters/plotters_pslike.h b/include/plotters/plotters_pslike.h index ee4682914e..026be4d583 100644 --- a/include/plotters/plotters_pslike.h +++ b/include/plotters/plotters_pslike.h @@ -204,9 +204,8 @@ public: int width = USE_DEFAULT_LINE_WIDTH ) override; virtual void Circle( const VECTOR2I& pos, int diametre, FILL_T fill, int width = USE_DEFAULT_LINE_WIDTH ) override; - virtual void Arc( const VECTOR2I& aCenter, const EDA_ANGLE& aStartAngle, - const EDA_ANGLE& aEndAngle, int aRadius, FILL_T aFill, - int aWidth = USE_DEFAULT_LINE_WIDTH ) override; + virtual void Arc( const VECTOR2I& aCenter, const VECTOR2I& aStart, const VECTOR2I& aEnd, + FILL_T aFill, int aWidth, int aMaxError ) override; virtual void PlotPoly( const std::vector& aCornerList, FILL_T aFill, int aWidth = USE_DEFAULT_LINE_WIDTH, void* aData = nullptr ) override; @@ -322,10 +321,13 @@ public: int width = USE_DEFAULT_LINE_WIDTH ) override; /** - * The PDF engine can't directly plot arcs, it uses the base emulation. - * So no filled arcs (not a great loss... ) + * The PDF engine can't directly plot arcs so we use polygonization. */ - virtual void Arc( const VECTOR2I& aCenter, const EDA_ANGLE& aStartAngle, const EDA_ANGLE& aEndAngle, int aRadius, + virtual void Arc( const VECTOR2I& aCenter, const VECTOR2I& aStart, const VECTOR2I& aEnd, + FILL_T aFill, int aWidth, int aMaxError ) override; + + virtual void Arc( const VECTOR2I& aCenter, const EDA_ANGLE& aStartAngle, + const EDA_ANGLE& aEndAngle, int aRadius, FILL_T aFill, int aWidth = USE_DEFAULT_LINE_WIDTH ) override; /** diff --git a/qa/eeschema/test_ee_item.cpp b/qa/eeschema/test_ee_item.cpp index 73c25f496f..eadd91d65c 100644 --- a/qa/eeschema/test_ee_item.cpp +++ b/qa/eeschema/test_ee_item.cpp @@ -37,6 +37,7 @@ #include #include #include +#include #include #include #include @@ -44,6 +45,7 @@ #include #include +#include #include #include @@ -86,6 +88,7 @@ public: case SCH_SHAPE_T: return new SCH_SHAPE( SHAPE_T::ARC ); case SCH_BITMAP_T: return new SCH_BITMAP(); case SCH_TEXT_T: return new SCH_TEXT( wxPoint( 0, 0 ), "test text" ); + case SCH_TEXTBOX_T: return new SCH_TEXTBOX( 0, FILL_T::NO_FILL, "test textbox" ); case SCH_LABEL_T: return new SCH_LABEL( wxPoint( 0, 0 ), "test label" ); case SCH_DIRECTIVE_LABEL_T: return new SCH_DIRECTIVE_LABEL( wxPoint( 0, 0 ) ); case SCH_GLOBAL_LABEL_T: return new SCH_GLOBALLABEL(); @@ -103,6 +106,7 @@ public: case SCH_SHEET_T: return new SCH_SHEET(); case LIB_SHAPE_T: return new LIB_SHAPE( &m_symbol, SHAPE_T::ARC ); case LIB_TEXT_T: return new LIB_TEXT( &m_symbol ); + case LIB_TEXTBOX_T: return new LIB_TEXTBOX( &m_symbol, 0, FILL_T::NO_FILL, "test" ); case LIB_PIN_T: return new LIB_PIN( &m_symbol ); case LIB_FIELD_T: return new LIB_FIELD( &m_symbol );