From 3efe504dcceddd61c04a0c86f5b8f3d60ff460dd Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Sun, 14 Apr 2024 19:04:53 +0100 Subject: [PATCH] Collapse LIB_TEXT into SCH_TEXT. --- common/api/api_enums.cpp | 2 - common/eda_item.cpp | 1 - eeschema/CMakeLists.txt | 3 - eeschema/api/api_sch_utils.cpp | 4 - .../dialogs/dialog_lib_text_properties.cpp | 303 --- eeschema/dialogs/dialog_lib_text_properties.h | 60 - .../dialog_lib_text_properties_base.cpp | 267 -- .../dialog_lib_text_properties_base.fbp | 2198 ----------------- .../dialogs/dialog_lib_text_properties_base.h | 93 - eeschema/dialogs/dialog_text_properties.cpp | 124 +- eeschema/dialogs/dialog_text_properties.h | 9 +- .../dialogs/dialog_text_properties_base.cpp | 32 +- .../dialogs/dialog_text_properties_base.fbp | 247 +- .../dialogs/dialog_text_properties_base.h | 4 + .../graphics_importer_lib_symbol.cpp | 8 +- eeschema/lib_symbol.cpp | 2 + eeschema/lib_symbol.h | 2 +- eeschema/lib_text.cpp | 533 ---- eeschema/lib_text.h | 137 - eeschema/sch_io/altium/sch_io_altium.cpp | 6 +- .../cadstar/cadstar_sch_archive_loader.cpp | 46 +- eeschema/sch_io/eagle/sch_io_eagle.cpp | 44 +- eeschema/sch_io/eagle/sch_io_eagle.h | 5 +- .../sch_io/easyeda/sch_easyeda_parser.cpp | 10 +- .../easyedapro/sch_easyedapro_parser.cpp | 8 +- .../sch_io_kicad_legacy_lib_cache.cpp | 58 +- .../sch_io_kicad_legacy_lib_cache.h | 5 +- .../sch_io/kicad_sexpr/sch_io_kicad_sexpr.cpp | 5 - .../sch_io_kicad_sexpr_lib_cache.cpp | 9 +- .../sch_io_kicad_sexpr_lib_cache.h | 4 +- .../kicad_sexpr/sch_io_kicad_sexpr_parser.cpp | 10 +- .../kicad_sexpr/sch_io_kicad_sexpr_parser.h | 4 +- .../sch_io/ltspice/sch_io_ltspice_parser.cpp | 2 +- eeschema/sch_label.cpp | 10 +- eeschema/sch_painter.cpp | 227 +- eeschema/sch_painter.h | 2 +- eeschema/sch_symbol.cpp | 4 +- eeschema/sch_text.cpp | 547 +++- eeschema/sch_text.h | 39 +- eeschema/symbol_editor/symbol_edit_frame.cpp | 1 - eeschema/symbol_editor/symbol_edit_frame.h | 1 - eeschema/tools/ee_actions.cpp | 2 +- eeschema/tools/ee_grid_helper.cpp | 1 - eeschema/tools/ee_selection_tool.cpp | 7 +- .../tools/symbol_editor_drawing_tools.cpp | 20 +- eeschema/tools/symbol_editor_edit_tool.cpp | 14 +- include/core/typeinfo.h | 2 - qa/tests/eeschema/test_ee_item.cpp | 2 - 48 files changed, 1075 insertions(+), 4049 deletions(-) delete mode 100644 eeschema/dialogs/dialog_lib_text_properties.cpp delete mode 100644 eeschema/dialogs/dialog_lib_text_properties.h delete mode 100644 eeschema/dialogs/dialog_lib_text_properties_base.cpp delete mode 100644 eeschema/dialogs/dialog_lib_text_properties_base.fbp delete mode 100644 eeschema/dialogs/dialog_lib_text_properties_base.h delete mode 100644 eeschema/lib_text.cpp delete mode 100644 eeschema/lib_text.h diff --git a/common/api/api_enums.cpp b/common/api/api_enums.cpp index b9b21b5eec..0f02aa70fb 100644 --- a/common/api/api_enums.cpp +++ b/common/api/api_enums.cpp @@ -76,7 +76,6 @@ KICAD_T FromProtoEnum( types::KiCadObjectType aValue ) case types::KiCadObjectType::KOT_SCH_PIN: return SCH_PIN_T; case types::KiCadObjectType::KOT_LIB_SYMBOL: return LIB_SYMBOL_T; // case types::KiCadObjectType::KOT_LIB_SHAPE: return LIB_SHAPE_T; - // case types::KiCadObjectType::KOT_LIB_TEXT: return LIB_TEXT_T; // case types::KiCadObjectType::KOT_LIB_TEXTBOX: return LIB_TEXTBOX_T; // case types::KiCadObjectType::KOT_LIB_PIN: return LIB_PIN_T; case types::KiCadObjectType::KOT_WSG_LINE: return WSG_LINE_T; @@ -139,7 +138,6 @@ types::KiCadObjectType ToProtoEnum( KICAD_T aValue ) case SCH_PIN_T: return types::KiCadObjectType::KOT_SCH_PIN; case LIB_SYMBOL_T: return types::KiCadObjectType::KOT_LIB_SYMBOL; // case LIB_SHAPE_T: return types::KiCadObjectType::KOT_LIB_SHAPE; - // case LIB_TEXT_T: return types::KiCadObjectType::KOT_LIB_TEXT; // case LIB_TEXTBOX_T: return types::KiCadObjectType::KOT_LIB_TEXTBOX; // case LIB_PIN_T: return types::KiCadObjectType::KOT_LIB_PIN; case WSG_LINE_T: return types::KiCadObjectType::KOT_WSG_LINE; diff --git a/common/eda_item.cpp b/common/eda_item.cpp index 97051aeb54..1e1f0d9742 100644 --- a/common/eda_item.cpp +++ b/common/eda_item.cpp @@ -397,7 +397,6 @@ static struct EDA_ITEM_DESC .Map( LIB_SYMBOL_T, _HKI( "Symbol" ) ) .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" ) ) diff --git a/eeschema/CMakeLists.txt b/eeschema/CMakeLists.txt index d94e38d9fc..962153bed6 100644 --- a/eeschema/CMakeLists.txt +++ b/eeschema/CMakeLists.txt @@ -127,8 +127,6 @@ set( EESCHEMA_DLGS dialogs/dialog_lib_shape_properties_base.cpp dialogs/dialog_lib_symbol_properties.cpp dialogs/dialog_lib_symbol_properties_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_line_properties.cpp @@ -364,7 +362,6 @@ set( EESCHEMA_SRCS lib_pin.cpp lib_shape.cpp lib_symbol.cpp - lib_text.cpp lib_textbox.cpp libarch.cpp menubar.cpp diff --git a/eeschema/api/api_sch_utils.cpp b/eeschema/api/api_sch_utils.cpp index 138f8220be..6995cf6682 100644 --- a/eeschema/api/api_sch_utils.cpp +++ b/eeschema/api/api_sch_utils.cpp @@ -21,9 +21,7 @@ #include #include #include -#include #include - #include #include #include @@ -31,7 +29,6 @@ #include #include #include -#include #include #include #include @@ -95,7 +92,6 @@ std::unique_ptr CreateItemForType( KICAD_T aType, EDA_ITEM* aContainer case LIB_SYMBOL_T: return nullptr; // TODO: ctor currently requires non-null name case LIB_SHAPE_T: return std::make_unique( parentLibSymbol ); - case LIB_TEXT_T: return std::make_unique( parentLibSymbol ); case LIB_TEXTBOX_T: return std::make_unique( parentLibSymbol ); case LIB_PIN_T: return std::make_unique( parentLibSymbol ); diff --git a/eeschema/dialogs/dialog_lib_text_properties.cpp b/eeschema/dialogs/dialog_lib_text_properties.cpp deleted file mode 100644 index a4ce73c567..0000000000 --- a/eeschema/dialogs/dialog_lib_text_properties.cpp +++ /dev/null @@ -1,303 +0,0 @@ -/* - * This program source code file is part of KiCad, a free EDA CAD application. - * - * Copyright (C) 2001 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com - * Copyright (C) 2004-2023 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 - * 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 "confirm.h" - -DIALOG_LIB_TEXT_PROPERTIES::DIALOG_LIB_TEXT_PROPERTIES( SYMBOL_EDIT_FRAME* aParent, - LIB_TEXT* aText ) : - DIALOG_LIB_TEXT_PROPERTIES_BASE( aParent ), - m_parent( aParent ), - m_graphicText( aText ), - m_textSize( aParent, m_textSizeLabel, m_textSizeCtrl, m_textSizeUnits, true ) -{ - COLOR_SETTINGS* colorSettings = m_parent->GetColorSettings(); - COLOR4D schematicBackground = colorSettings->GetColor( LAYER_SCHEMATIC_BACKGROUND ); - - m_scintillaTricks = new SCINTILLA_TRICKS( m_StyledTextCtrl, wxT( "{}" ), false, - // onAcceptFn - [this]( wxKeyEvent& aEvent ) - { - wxPostEvent( this, wxCommandEvent( wxEVT_COMMAND_BUTTON_CLICKED, wxID_OK ) ); - } ); - - SetInitialFocus( m_StyledTextCtrl ); - - m_separator1->SetIsSeparator(); - - m_horizontal->SetIsRadioButton(); - m_horizontal->SetBitmap( KiBitmapBundle( BITMAPS::text_horizontal ) ); - m_vertical->SetIsRadioButton(); - m_vertical->SetBitmap( KiBitmapBundle( BITMAPS::text_vertical ) ); - - m_separator2->SetIsSeparator(); - - m_bold->SetIsCheckButton(); - m_bold->SetBitmap( KiBitmapBundle( BITMAPS::text_bold ) ); - m_italic->SetIsCheckButton(); - m_italic->SetBitmap( KiBitmapBundle( BITMAPS::text_italic ) ); - - m_separator3->SetIsSeparator(); - - m_hAlignLeft->SetIsRadioButton(); - m_hAlignLeft->SetBitmap( KiBitmapBundle( BITMAPS::text_align_left ) ); - m_hAlignCenter->SetIsRadioButton(); - m_hAlignCenter->SetBitmap( KiBitmapBundle( BITMAPS::text_align_center ) ); - m_hAlignRight->SetIsRadioButton(); - m_hAlignRight->SetBitmap( KiBitmapBundle( BITMAPS::text_align_right ) ); - - m_separator4->SetIsSeparator(); - - m_vAlignTop->SetIsRadioButton(); - m_vAlignTop->SetBitmap( KiBitmapBundle( BITMAPS::text_valign_top ) ); - m_vAlignCenter->SetIsRadioButton(); - m_vAlignCenter->SetBitmap( KiBitmapBundle( BITMAPS::text_valign_center ) ); - m_vAlignBottom->SetIsRadioButton(); - m_vAlignBottom->SetBitmap( KiBitmapBundle( BITMAPS::text_valign_bottom ) ); - - m_separator5->SetIsSeparator(); - - m_textColorSwatch->SetDefaultColor( COLOR4D::UNSPECIFIED ); - m_textColorSwatch->SetSwatchBackground( schematicBackground ); - - m_horizontal->Bind( wxEVT_BUTTON, &DIALOG_LIB_TEXT_PROPERTIES::onOrientButton, this ); - m_vertical->Bind( wxEVT_BUTTON, &DIALOG_LIB_TEXT_PROPERTIES::onOrientButton, this ); - - m_hAlignLeft->Bind( wxEVT_BUTTON, &DIALOG_LIB_TEXT_PROPERTIES::onHAlignButton, this ); - m_hAlignCenter->Bind( wxEVT_BUTTON, &DIALOG_LIB_TEXT_PROPERTIES::onHAlignButton, this ); - m_hAlignRight->Bind( wxEVT_BUTTON, &DIALOG_LIB_TEXT_PROPERTIES::onHAlignButton, this ); - - m_vAlignTop->Bind( wxEVT_BUTTON, &DIALOG_LIB_TEXT_PROPERTIES::onVAlignButton, this ); - m_vAlignCenter->Bind( wxEVT_BUTTON, &DIALOG_LIB_TEXT_PROPERTIES::onVAlignButton, this ); - m_vAlignBottom->Bind( wxEVT_BUTTON, &DIALOG_LIB_TEXT_PROPERTIES::onVAlignButton, this ); - - SetupStandardButtons(); - - if( !aParent->IsSymbolEditable() || aParent->IsSymbolAlias() ) - { - m_sdbSizerButtonsCancel->SetDefault(); - m_sdbSizerButtonsOK->SetLabel( _( "Read Only" ) ); - m_sdbSizerButtonsOK->Enable( false ); - } - - // Now all widgets have the size fixed, call FinishDialogSettings - finishDialogSettings(); -} - - -DIALOG_LIB_TEXT_PROPERTIES::~DIALOG_LIB_TEXT_PROPERTIES() -{ - delete m_scintillaTricks; -}; - - -bool DIALOG_LIB_TEXT_PROPERTIES::TransferDataToWindow() -{ - wxCHECK( m_commonToAllUnits, false ); - - if( m_graphicText ) - { - const SYMBOL* symbol = m_graphicText->GetParentSymbol(); - - wxCHECK( symbol, false ); - - m_textSize.SetValue( m_graphicText->GetTextWidth() ); - m_StyledTextCtrl->SetValue( m_graphicText->GetText() ); - m_StyledTextCtrl->EmptyUndoBuffer(); - - m_fontCtrl->SetFontSelection( m_graphicText->GetFont() ); - m_textColorSwatch->SetSwatchColor( m_graphicText->GetTextColor(), false ); - - m_italic->Check( m_graphicText->IsItalic() ); - m_bold->Check( m_graphicText->IsBold() ); - - m_privateCheckbox->SetValue( m_graphicText->IsPrivate() ); - m_commonToAllUnits->SetValue( symbol->GetUnitCount() > 1 && m_graphicText->GetUnit() == 0 ); - m_commonToAllUnits->Enable( symbol->GetUnitCount() > 1 ); - m_commonToAllBodyStyles->SetValue( m_graphicText->GetBodyStyle() == 0 ); - - if( m_graphicText->GetTextAngle().IsHorizontal() ) - m_horizontal->Check(); - else - m_vertical->Check(); - - switch ( m_graphicText->GetHorizJustify() ) - { - case GR_TEXT_H_ALIGN_LEFT: m_hAlignLeft->Check( true ); break; - case GR_TEXT_H_ALIGN_CENTER: m_hAlignCenter->Check( true ); break; - case GR_TEXT_H_ALIGN_RIGHT: m_hAlignRight->Check( true ); break; - case GR_TEXT_H_ALIGN_INDETERMINATE: break; - } - - switch ( m_graphicText->GetVertJustify() ) - { - case GR_TEXT_V_ALIGN_TOP: m_vAlignTop->Check( true ); break; - case GR_TEXT_V_ALIGN_CENTER: m_vAlignCenter->Check( true ); break; - case GR_TEXT_V_ALIGN_BOTTOM: m_vAlignBottom->Check( true ); break; - case GR_TEXT_V_ALIGN_INDETERMINATE: break; - } - } - else - { - SYMBOL_EDITOR_SETTINGS* cfg = m_parent->GetSettings(); - auto* tools = m_parent->GetToolManager()->GetTool(); - SYMBOL* symbol = m_parent->GetCurSymbol(); - - wxCHECK( cfg && symbol && tools, false ); - - m_textSize.SetValue( schIUScale.MilsToIU( cfg->m_Defaults.text_size ) ); - - m_commonToAllUnits->SetValue( symbol->GetUnitCount() > 1 && !tools->GetDrawSpecificUnit() ); - m_commonToAllUnits->Enable( symbol->GetUnitCount() > 1 ); - m_commonToAllBodyStyles->SetValue( !tools->GetDrawSpecificBodyStyle() ); - - if( tools->GetLastTextAngle().IsHorizontal() ) - m_horizontal->Check(); - else - m_vertical->Check(); - } - - return true; -} - - -void DIALOG_LIB_TEXT_PROPERTIES::onOrientButton( wxCommandEvent& aEvent ) -{ - for( BITMAP_BUTTON* btn : { m_horizontal, m_vertical } ) - { - if( btn->IsChecked() && btn != aEvent.GetEventObject() ) - btn->Check( false ); - } -} - - -void DIALOG_LIB_TEXT_PROPERTIES::onHAlignButton( wxCommandEvent& aEvent ) -{ - for( BITMAP_BUTTON* btn : { m_hAlignLeft, m_hAlignCenter, m_hAlignRight } ) - { - if( btn->IsChecked() && btn != aEvent.GetEventObject() ) - btn->Check( false ); - } -} - - -void DIALOG_LIB_TEXT_PROPERTIES::onVAlignButton( wxCommandEvent& aEvent ) -{ - for( BITMAP_BUTTON* btn : { m_vAlignTop, m_vAlignCenter, m_vAlignBottom } ) - { - if( btn->IsChecked() && btn != aEvent.GetEventObject() ) - btn->Check( false ); - } -} - - -bool DIALOG_LIB_TEXT_PROPERTIES::TransferDataFromWindow() -{ - if( m_graphicText ) - { - if( m_StyledTextCtrl->GetValue().IsEmpty() ) - { - // Other text items do not have defined extents, and so will disappear if empty - DisplayError( this, _( "Text can not be empty." ) ); - return false; - } - else - { - m_graphicText->SetText( m_StyledTextCtrl->GetValue() ); - } - - if( m_fontCtrl->HaveFontSelection() ) - { - m_graphicText->SetFont( m_fontCtrl->GetFontSelection( m_bold->IsChecked(), - m_italic->IsChecked() ) ); - } - - if( m_textSize.GetValue() != m_graphicText->GetTextWidth() ) - m_graphicText->SetTextSize( VECTOR2I( m_textSize.GetValue(), m_textSize.GetValue() ) ); - - if( m_horizontal->IsChecked() ) - m_graphicText->SetTextAngle( ANGLE_HORIZONTAL ); - else - m_graphicText->SetTextAngle( ANGLE_VERTICAL ); - - m_graphicText->SetPrivate( m_privateCheckbox->GetValue() ); - - if( !m_commonToAllUnits->GetValue() ) - m_graphicText->SetUnit( m_parent->GetUnit() ); - else - m_graphicText->SetUnit( 0 ); - - if( !m_commonToAllBodyStyles->GetValue() ) - m_graphicText->SetBodyStyle( m_parent->GetBodyStyle() ); - else - m_graphicText->SetBodyStyle( 0 ); - - // Must come after SetTextSize() - m_graphicText->SetBold( m_bold->IsChecked() ); - m_graphicText->SetItalic( m_italic->IsChecked() ); - m_graphicText->SetTextColor( m_textColorSwatch->GetSwatchColor() ); - - if( m_hAlignLeft->IsChecked() ) - m_graphicText->SetHorizJustify( GR_TEXT_H_ALIGN_LEFT ); - else if( m_hAlignCenter->IsChecked() ) - m_graphicText->SetHorizJustify( GR_TEXT_H_ALIGN_CENTER ); - else - m_graphicText->SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT ); - - if( m_vAlignTop->IsChecked() ) - m_graphicText->SetVertJustify( GR_TEXT_V_ALIGN_TOP ); - else if( m_vAlignCenter->IsChecked() ) - m_graphicText->SetVertJustify( GR_TEXT_V_ALIGN_CENTER ); - else - m_graphicText->SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM ); - - // Record settings used for next time: - auto* tools = m_parent->GetToolManager()->GetTool(); - tools->SetLastTextAngle( m_graphicText->GetTextAngle() ); - tools->SetDrawSpecificBodyStyle( !m_commonToAllBodyStyles->GetValue() ); - tools->SetDrawSpecificUnit( !m_commonToAllUnits->GetValue() ); - } - - m_parent->SetMsgPanel( m_graphicText ); - - return true; -} - - -void DIALOG_LIB_TEXT_PROPERTIES::onMultiLineTCLostFocus( wxFocusEvent& event ) -{ - if( m_scintillaTricks ) - m_scintillaTricks->CancelAutocomplete(); - - event.Skip(); -} diff --git a/eeschema/dialogs/dialog_lib_text_properties.h b/eeschema/dialogs/dialog_lib_text_properties.h deleted file mode 100644 index 9966a798f8..0000000000 --- a/eeschema/dialogs/dialog_lib_text_properties.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - * 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-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_TEXT_PROPERTIES_H -#define DIALOG_LIB_TEXT_PROPERTIES_H - -#include -#include - -class SYMBOL_EDIT_FRAME; -class SCINTILLA_TRICKS; -class LIB_TEXT; - - -class DIALOG_LIB_TEXT_PROPERTIES : public DIALOG_LIB_TEXT_PROPERTIES_BASE -{ -public: - DIALOG_LIB_TEXT_PROPERTIES( SYMBOL_EDIT_FRAME* aParent, LIB_TEXT* aText ); - ~DIALOG_LIB_TEXT_PROPERTIES() override; - -private: - void onOrientButton( wxCommandEvent &aEvent ); - void onHAlignButton( wxCommandEvent &aEvent ); - void onVAlignButton( wxCommandEvent &aEvent ); - void onMultiLineTCLostFocus( wxFocusEvent& event ) override; - - bool TransferDataToWindow() override; - bool TransferDataFromWindow() override; - - SYMBOL_EDIT_FRAME* m_parent; - LIB_TEXT* m_graphicText; - - UNIT_BINDER m_textSize; - SCINTILLA_TRICKS* m_scintillaTricks; -}; - - -#endif // DIALOG_LIB_TEXT_PROPERTIES_H diff --git a/eeschema/dialogs/dialog_lib_text_properties_base.cpp b/eeschema/dialogs/dialog_lib_text_properties_base.cpp deleted file mode 100644 index c8bc0788cf..0000000000 --- a/eeschema/dialogs/dialog_lib_text_properties_base.cpp +++ /dev/null @@ -1,267 +0,0 @@ -/////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version 4.0.0-0-g0efcecf) -// 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_text_properties_base.h" - -/////////////////////////////////////////////////////////////////////////// - -DIALOG_LIB_TEXT_PROPERTIES_BASE::DIALOG_LIB_TEXT_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 ); - - 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 ); - 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 ); - 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->SetReadOnly( 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 ) ); - 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( 2, 0 ), wxGBSpan( 1, 1 ), wxRIGHT|wxLEFT|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 ); - gbSizer1->Add( m_fontCtrl, wxGBPosition( 2, 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( 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( 3, 0 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 ); - - wxBoxSizer* bSizer71; - bSizer71 = new wxBoxSizer( wxHORIZONTAL ); - - m_textSizeCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( -1,-1 ), 0 ); - bSizer71->Add( m_textSizeCtrl, 0, wxALIGN_CENTER_VERTICAL, 5 ); - - m_textSizeUnits = new wxStaticText( this, wxID_ANY, _("mm"), wxDefaultPosition, wxDefaultSize, 0 ); - m_textSizeUnits->Wrap( -1 ); - bSizer71->Add( m_textSizeUnits, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 3 ); - - m_textColorLabel = new wxStaticText( this, wxID_ANY, _("Color:"), wxDefaultPosition, wxDefaultSize, 0 ); - m_textColorLabel->Wrap( -1 ); - bSizer71->Add( m_textColorLabel, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 15 ); - - - bSizer71->Add( 5, 0, 0, 0, 5 ); - - m_panelBorderColor1 = new wxPanel( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxBORDER_SIMPLE|wxTAB_TRAVERSAL ); - wxBoxSizer* bSizer221; - bSizer221 = new wxBoxSizer( wxVERTICAL ); - - m_textColorSwatch = new COLOR_SWATCH( m_panelBorderColor1, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 ); - bSizer221->Add( m_textColorSwatch, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_CENTER_HORIZONTAL, 5 ); - - - m_panelBorderColor1->SetSizer( bSizer221 ); - m_panelBorderColor1->Layout(); - bSizer221->Fit( m_panelBorderColor1 ); - bSizer71->Add( m_panelBorderColor1, 0, wxALIGN_CENTER_VERTICAL, 5 ); - - - gbSizer1->Add( bSizer71, wxGBPosition( 3, 1 ), wxGBSpan( 1, 1 ), wxEXPAND, 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_commonToAllUnits = new wxCheckBox( this, wxID_ANY, _("Common to all units"), wxDefaultPosition, wxDefaultSize, 0 ); - gbSizer1->Add( m_commonToAllUnits, wxGBPosition( 5, 3 ), wxGBSpan( 1, 1 ), wxLEFT, 100 ); - - m_commonToAllBodyStyles = new wxCheckBox( this, wxID_ANY, _("Common to all body styles"), wxDefaultPosition, wxDefaultSize, 0 ); - gbSizer1->Add( m_commonToAllBodyStyles, wxGBPosition( 6, 3 ), wxGBSpan( 1, 1 ), wxLEFT, 100 ); - - - bPropertiesSizer->Add( gbSizer1, 1, wxEXPAND|wxTOP|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_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_LIB_TEXT_PROPERTIES_BASE::OnCloseDialog ) ); - 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 ); -} - -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_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 ); - -} diff --git a/eeschema/dialogs/dialog_lib_text_properties_base.fbp b/eeschema/dialogs/dialog_lib_text_properties_base.fbp deleted file mode 100644 index 9e626cca42..0000000000 --- a/eeschema/dialogs/dialog_lib_text_properties_base.fbp +++ /dev/null @@ -1,2198 +0,0 @@ - - - - - - C++ - 1 - source_name - 0 - 0 - res - UTF-8 - connect - dialog_lib_text_properties_base - 1000 - none - - - 1 - DIALOG_LIB_TEXT_PROPERTIES_BASE - - . - - 1 - 1 - 1 - 1 - UI - 0 - 1 - 0 - - 0 - wxAUI_MGR_DEFAULT - - - - 1 - 0 - 1 - impl_virtual - - - - 0 - wxID_ANY - - - DIALOG_LIB_TEXT_PROPERTIES_BASE - - -1,-1 - wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER - DIALOG_SHIM; dialog_shim.h - Text Item Properties - - 0 - - - - OnCloseDialog - - - bMainSizer - wxVERTICAL - none - - 5 - wxEXPAND|wxTOP|wxRIGHT|wxLEFT - 1 - - - bPropertiesSizer - wxVERTICAL - none - - 5 - wxEXPAND|wxTOP|wxRIGHT|wxLEFT - 1 - - -1,10 - wxBOTH - - - 0 - - gbSizer1 - wxFLEX_GROWMODE_SPECIFIED - none - 3 - - 5 - 1 - 0 - wxRIGHT|wxLEFT - 0 - 1 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 0 - 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 - 0 - 1 - - 1 - 0 - - 0 - 0 - wxID_ANY - 0 - 0 - - 0 - - - 0 - - 1 - m_StyledTextCtrl - 1 - - - protected - 1 - - 0 - Resizable - 1 - - ; ; forward_declare - 0 - 4 - 0 - - 1 - 0 - 0 - - - wxBORDER_SUNKEN - onMultiLineTCLostFocus - OnSetFocusText - - - - 5 - 1 - 0 - wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL - 2 - 1 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 0 - 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 - 2 - 1 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - "Default Font" "KiCad Font" - 1 - - 1 - 0 - Dock - 0 - Left - 0 - 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 - 2 - 1 - - - formattingSizer - wxHORIZONTAL - none - - 5 - wxALIGN_CENTER_VERTICAL|wxLEFT - 0 - - 1 - 1 - 1 - 1 - - - - - 0 - - - - - 1 - 0 - 1 - - 1 - - 0 - 0 - - Dock - 0 - Left - 0 - 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 - - - - - 0 - - - - - 1 - 0 - 1 - - 1 - - 0 - 0 - - Dock - 0 - Left - 0 - 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 - - - - - 0 - - - - - 1 - 0 - 1 - - 1 - - 0 - 0 - - Dock - 0 - Left - 0 - 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 - - - - - 0 - - - - - 1 - 0 - 1 - - 1 - - 0 - 0 - - Dock - 0 - Left - 0 - 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 - - - - - 0 - - - - - 1 - 0 - 1 - - 1 - - 0 - 0 - - Dock - 0 - Left - 0 - 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 - - - - - 0 - - - - - 1 - 0 - 1 - - 1 - - 0 - 0 - - Dock - 0 - Left - 0 - 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 - - - - - 0 - - - - - 1 - 0 - 1 - - 1 - - 0 - 0 - - Dock - 0 - Left - 0 - 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 - - - - - 0 - - - - - 1 - 0 - 1 - - 1 - - 0 - 0 - - Dock - 0 - Left - 0 - 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 - - - - - 0 - - - - - 1 - 0 - 1 - - 1 - - 0 - 0 - - Dock - 0 - Left - 0 - 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 - - - - - 0 - - - - - 1 - 0 - 1 - - 1 - - 0 - 0 - - Dock - 0 - Left - 0 - 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 - - - - - 0 - - - - - 1 - 0 - 1 - - 1 - - 0 - 0 - - Dock - 0 - Left - 0 - 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 - - - - - 0 - - - - - 1 - 0 - 1 - - 1 - - 0 - 0 - - Dock - 0 - Left - 0 - 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 - - - - - 0 - - - - - 1 - 0 - 1 - - 1 - - 0 - 0 - - Dock - 0 - Left - 0 - 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 - - - - - 0 - - - - - 1 - 0 - 1 - - 1 - - 0 - 0 - - Dock - 0 - Left - 0 - 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 - - - - - 0 - - - - - 1 - 0 - 1 - - 1 - - 0 - 0 - - Dock - 0 - Left - 0 - 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 - 3 - 1 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 0 - 1 - - 1 - - 0 - 0 - wxID_ANY - Text size: - 0 - - 0 - - - 0 - - 1 - m_textSizeLabel - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - - - -1 - - - - 5 - 1 - 1 - wxEXPAND - 3 - 1 - - - bSizer71 - wxHORIZONTAL - none - - 5 - wxALIGN_CENTER_VERTICAL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 0 - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - 0 - -1,-1 - 0 - -1,-1 - 1 - m_textSizeCtrl - 1 - - - protected - 1 - - Resizable - 1 - -1,-1 - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - 3 - wxALIGN_CENTER_VERTICAL|wxLEFT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 0 - 1 - - 1 - - 0 - 0 - wxID_ANY - mm - 0 - - 0 - - - 0 - -1,-1 - 1 - m_textSizeUnits - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - - - -1 - - - - 15 - wxALIGN_CENTER_VERTICAL|wxLEFT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 0 - 1 - - 1 - - 0 - 0 - wxID_ANY - Color: - 0 - - 0 - - - 0 - - 1 - m_textColorLabel - 1 - - - protected - 1 - - Resizable - 1 - - - ; ; Not forward_declare - 0 - - - - - -1 - - - - 5 - - 0 - - 0 - protected - 5 - - - - 5 - wxALIGN_CENTER_VERTICAL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 0 - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - - 0 - - 1 - m_panelBorderColor1 - 1 - - - protected - 1 - - Resizable - 1 - - ; ; forward_declare - 0 - - - - wxBORDER_SIMPLE|wxTAB_TRAVERSAL - - - bSizer221 - wxVERTICAL - none - - 5 - wxALIGN_CENTER_VERTICAL|wxALIGN_CENTER_HORIZONTAL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - COLOR_SWATCH - 1 - - - 1 - - 0 - Dock - 0 - Left - 0 - 1 - - 1 - - 0 - 0 - wxID_ANY - - - 0 - - - 0 - - 1 - m_textColorSwatch - 1 - - - protected - 1 - - Resizable - - 1 - - COLOR_SWATCH; widgets/color_swatch.h; forward_declare - 0 - - - - - - - - - - - - - 5 - 2 - 0 - wxLEFT - 5 - 1 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 0 - 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 - 1 - 3 - wxLEFT - 5 - 1 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 0 - 1 - - 1 - - 0 - 0 - wxID_ANY - Common to all units - - 0 - - - 0 - - 1 - m_commonToAllUnits - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - 100 - 1 - 3 - wxLEFT - 6 - 1 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 0 - 1 - - 1 - - 0 - 0 - wxID_ANY - Common to all body styles - - 0 - - - 0 - - 1 - m_commonToAllBodyStyles - 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 - - - - - - 5 - wxEXPAND|wxALL - 0 - - 0 - 1 - 0 - 0 - 0 - 1 - 0 - 0 - - m_sdbSizerButtons - protected - - - - - - diff --git a/eeschema/dialogs/dialog_lib_text_properties_base.h b/eeschema/dialogs/dialog_lib_text_properties_base.h deleted file mode 100644 index 094e9fa891..0000000000 --- a/eeschema/dialogs/dialog_lib_text_properties_base.h +++ /dev/null @@ -1,93 +0,0 @@ -/////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version 4.0.0-0-g0efcecf) -// 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 - -/////////////////////////////////////////////////////////////////////////// - -/////////////////////////////////////////////////////////////////////////////// -/// Class DIALOG_LIB_TEXT_PROPERTIES_BASE -/////////////////////////////////////////////////////////////////////////////// -class DIALOG_LIB_TEXT_PROPERTIES_BASE : public DIALOG_SHIM -{ - private: - - protected: - wxStaticText* m_textLabel; - wxStyledTextCtrl* m_StyledTextCtrl; - 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_textColorLabel; - wxPanel* m_panelBorderColor1; - COLOR_SWATCH* m_textColorSwatch; - wxCheckBox* m_privateCheckbox; - wxCheckBox* m_commonToAllUnits; - wxCheckBox* m_commonToAllBodyStyles; - wxStdDialogButtonSizer* m_sdbSizerButtons; - wxButton* m_sdbSizerButtonsOK; - wxButton* m_sdbSizerButtonsCancel; - - // Virtual event handlers, override them in your derived class - virtual void OnCloseDialog( wxCloseEvent& event ) { event.Skip(); } - virtual void onMultiLineTCLostFocus( wxFocusEvent& event ) { event.Skip(); } - virtual void OnSetFocusText( wxFocusEvent& event ) { event.Skip(); } - - - public: - - DIALOG_LIB_TEXT_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_LIB_TEXT_PROPERTIES_BASE(); - -}; - diff --git a/eeschema/dialogs/dialog_text_properties.cpp b/eeschema/dialogs/dialog_text_properties.cpp index 00cf3b2f2b..a850f28740 100644 --- a/eeschema/dialogs/dialog_text_properties.cpp +++ b/eeschema/dialogs/dialog_text_properties.cpp @@ -24,6 +24,7 @@ */ #include +#include #include #include #include @@ -39,7 +40,7 @@ #include -DIALOG_TEXT_PROPERTIES::DIALOG_TEXT_PROPERTIES( SCH_EDIT_FRAME* aParent, SCH_ITEM* aTextItem ) : +DIALOG_TEXT_PROPERTIES::DIALOG_TEXT_PROPERTIES( SCH_BASE_FRAME* aParent, SCH_ITEM* aTextItem ) : DIALOG_TEXT_PROPERTIES_BASE( aParent ), m_frame( aParent ), m_currentItem( aTextItem ), @@ -49,6 +50,8 @@ DIALOG_TEXT_PROPERTIES::DIALOG_TEXT_PROPERTIES( SCH_EDIT_FRAME* aParent, SCH_ITE m_scintillaTricks( nullptr ), m_helpWindow( nullptr ) { + m_isSymbolEditor = dynamic_cast( aParent ) != nullptr; + COLOR_SETTINGS* colorSettings = m_frame->GetColorSettings(); COLOR4D schematicBackground = colorSettings->GetColor( LAYER_SCHEMATIC_BACKGROUND ); @@ -152,23 +155,38 @@ DIALOG_TEXT_PROPERTIES::DIALOG_TEXT_PROPERTIES( SCH_EDIT_FRAME* aParent, SCH_ITE m_separator5->SetIsSeparator(); - SCH_SHEET_LIST sheetList = m_frame->Schematic().GetSheets(); - sheetList.SortByPageNumbers( false ); + m_fgSymbolEditor->Show( m_isSymbolEditor ); - for( const SCH_SHEET_PATH& sheet : sheetList ) + if( SCH_EDIT_FRAME* schematicEditor = dynamic_cast( m_frame ) ) { - wxString sheetPageNum = sheet.GetPageNumber(); - wxString sheetName = sheet.size() == 1 ? _( "" ) : sheet.Last()->GetName(); + SCH_SHEET_LIST sheetList = schematicEditor->Schematic().GetSheets(); + sheetList.SortByPageNumbers( false ); - m_hyperlinkCombo->Append( wxT( "#" ) + sheetPageNum, - wxString::Format( _( "Page %s (%s)" ), sheetPageNum, sheetName ) ); - m_pageNumbers.push_back( sheetPageNum ); + for( const SCH_SHEET_PATH& sheet : sheetList ) + { + wxString sheetPageNum = sheet.GetPageNumber(); + wxString sheetName = sheet.size() == 1 ? _( "" ) + : sheet.Last()->GetName(); + + m_hyperlinkCombo->Append( wxT( "#" ) + sheetPageNum, + wxString::Format( _( "Page %s (%s)" ), + sheetPageNum, + sheetName ) ); + m_pageNumbers.push_back( sheetPageNum ); + } + + m_hyperlinkCombo->Append( wxT( "---" ) ); + m_hyperlinkCombo->Append( wxT( "file://" ), wxT( "file://..." ) ); + m_hyperlinkCombo->Append( wxT( "http://" ), wxT( "http://..." ) ); + m_hyperlinkCombo->Append( wxT( "https://" ), wxT( "https://..." ) ); + } + else + { + m_excludeFromSim->Hide(); + m_syntaxHelp->Hide(); + m_hyperlinkCb->Hide(); + m_hyperlinkCombo->Hide(); } - - m_hyperlinkCombo->Append( wxT( "---" ) ); - m_hyperlinkCombo->Append( wxT( "file://" ), wxT( "file://..." ) ); - m_hyperlinkCombo->Append( wxT( "http://" ), wxT( "http://..." ) ); - m_hyperlinkCombo->Append( wxT( "https://" ), wxT( "https://..." ) ); SetupStandardButtons(); Layout(); @@ -199,22 +217,28 @@ DIALOG_TEXT_PROPERTIES::~DIALOG_TEXT_PROPERTIES() void DIALOG_TEXT_PROPERTIES::getContextualTextVars( const wxString& aCrossRef, wxArrayString* aTokens ) { + SCHEMATIC* schematic = m_currentItem->Schematic(); + if( !aCrossRef.IsEmpty() ) { - SCH_SHEET_LIST sheets = m_frame->Schematic().GetSheets(); - SCH_REFERENCE_LIST refs; - SCH_SYMBOL* refSymbol = nullptr; + SCH_SYMBOL* refSymbol = nullptr; - sheets.GetSymbols( refs ); - - for( int jj = 0; jj < (int) refs.GetCount(); jj++ ) + if( schematic ) { - SCH_REFERENCE& ref = refs[jj]; + SCH_SHEET_LIST sheets = m_currentItem->Schematic()->GetSheets(); + SCH_REFERENCE_LIST refs; - if( ref.GetSymbol()->GetRef( &ref.GetSheetPath(), true ) == aCrossRef ) + sheets.GetSymbols( refs ); + + for( int jj = 0; jj < (int) refs.GetCount(); jj++ ) { - refSymbol = ref.GetSymbol(); - break; + SCH_REFERENCE& ref = refs[jj]; + + if( ref.GetSymbol()->GetRef( &ref.GetSheetPath(), true ) == aCrossRef ) + { + refSymbol = ref.GetSymbol(); + break; + } } } @@ -223,8 +247,6 @@ void DIALOG_TEXT_PROPERTIES::getContextualTextVars( const wxString& aCrossRef, } else { - SCHEMATIC* schematic = m_currentItem->Schematic(); - if( schematic && schematic->CurrentSheet().Last() ) { schematic->CurrentSheet().Last()->GetContextualTextVars( aTokens ); @@ -243,16 +265,20 @@ bool DIALOG_TEXT_PROPERTIES::TransferDataToWindow() if( !wxDialog::TransferDataToWindow() ) return false; - SCHEMATIC& schematic = m_frame->Schematic(); - m_hyperlinkCb->SetValue( m_currentText->HasHyperlink() ); m_hyperlinkCombo->SetValue( m_currentText->GetHyperlink() ); + wxString text = m_currentText->GetText(); + // show text variable cross-references in a human-readable format - m_textCtrl->SetValue( schematic.ConvertKIIDsToRefs( m_currentText->GetText() ) ); + if( SCHEMATIC* schematic = m_currentItem->Schematic() ) + text = schematic->ConvertKIIDsToRefs( text ); + + m_textCtrl->SetValue( text ); m_textCtrl->EmptyUndoBuffer(); - m_excludeFromSim->SetValue( m_currentItem->GetExcludedFromSim() ); + if( !m_isSymbolEditor ) + m_excludeFromSim->SetValue( m_currentItem->GetExcludedFromSim() ); m_fontCtrl->SetFontSelection( m_currentText->GetFont() ); m_textSize.SetValue( m_currentText->GetTextWidth() ); @@ -315,6 +341,17 @@ bool DIALOG_TEXT_PROPERTIES::TransferDataToWindow() m_fillColorSwatch->Enable( textBox->IsFilled() ); } + if( m_isSymbolEditor ) + { + SYMBOL* symbol = m_currentItem->GetParentSymbol(); + + m_privateCheckbox->SetValue( m_currentItem->IsPrivate() ); + m_commonToAllUnits->SetValue( symbol->IsMulti() && m_currentItem->GetUnit() == 0 ); + m_commonToAllUnits->Enable( symbol->IsMulti() ); + m_commonToAllBodyStyles->SetValue( symbol->HasAlternateBodyStyle() && m_currentItem->GetBodyStyle() == 0 ); + m_commonToAllBodyStyles->Enable( symbol->HasAlternateBodyStyle() ); + } + return true; } @@ -416,7 +453,6 @@ bool DIALOG_TEXT_PROPERTIES::TransferDataFromWindow() return false; SCH_COMMIT commit( m_frame ); - wxString text; /* save old text in undo list if not already in edit */ if( m_currentItem->GetEditFlags() == 0 ) @@ -424,8 +460,11 @@ bool DIALOG_TEXT_PROPERTIES::TransferDataFromWindow() m_frame->GetCanvas()->Refresh(); + wxString text = m_textCtrl->GetValue(); + // convert any text variable cross-references to their UUIDs - text = m_frame->Schematic().ConvertRefsToKIIDs( m_textCtrl->GetValue() ); + if( SCHEMATIC* schematic = m_currentItem->Schematic() ) + text = schematic->ConvertRefsToKIIDs( m_textCtrl->GetValue() ); #ifdef __WXMAC__ // On macOS CTRL+Enter produces '\r' instead of '\n' regardless of EOL setting @@ -454,7 +493,24 @@ bool DIALOG_TEXT_PROPERTIES::TransferDataFromWindow() m_currentItem->SetExcludedFromSim( m_excludeFromSim->GetValue() ); - if( !m_currentText->ValidateHyperlink( m_hyperlinkCombo->GetValue() ) ) + if( m_isSymbolEditor ) + { + SYMBOL_EDIT_FRAME* symbolEditor = dynamic_cast( m_frame ); + + m_currentItem->SetPrivate( m_privateCheckbox->GetValue() ); + + if( !m_commonToAllUnits->GetValue() ) + m_currentItem->SetUnit( symbolEditor->GetUnit() ); + else + m_currentItem->SetUnit( 0 ); + + if( !m_commonToAllBodyStyles->GetValue() ) + m_currentItem->SetBodyStyle( symbolEditor->GetBodyStyle() ); + else + m_currentItem->SetBodyStyle( 0 ); + } + + if( !EDA_TEXT::ValidateHyperlink( m_hyperlinkCombo->GetValue() ) ) { DisplayError( this, _( "Invalid hyperlink destination. Please enter either a valid URL " "(e.g. file:// or http(s)://) or \"#\" to create " @@ -467,7 +523,7 @@ bool DIALOG_TEXT_PROPERTIES::TransferDataFromWindow() } if( m_currentText->GetTextWidth() != m_textSize.GetValue() ) - m_currentText->SetTextSize( VECTOR2I( m_textSize.GetValue(), m_textSize.GetValue() ) ); + m_currentText->SetTextSize( VECTOR2I( m_textSize.GetIntValue(), m_textSize.GetIntValue() ) ); if( m_fontCtrl->HaveFontSelection() ) { diff --git a/eeschema/dialogs/dialog_text_properties.h b/eeschema/dialogs/dialog_text_properties.h index 4de839c5af..fe2050d1d1 100644 --- a/eeschema/dialogs/dialog_text_properties.h +++ b/eeschema/dialogs/dialog_text_properties.h @@ -1,7 +1,7 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2020-2022 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2020-2024 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,8 +38,8 @@ class HTML_MESSAGE_BOX; class DIALOG_TEXT_PROPERTIES : public DIALOG_TEXT_PROPERTIES_BASE { public: - DIALOG_TEXT_PROPERTIES( SCH_EDIT_FRAME* parent, SCH_ITEM* aTextItem ); - ~DIALOG_TEXT_PROPERTIES(); + DIALOG_TEXT_PROPERTIES( SCH_BASE_FRAME* parent, SCH_ITEM* aTextItem ); + ~DIALOG_TEXT_PROPERTIES() override; private: void getContextualTextVars( const wxString& aCrossRef, wxArrayString* aTokens ); @@ -59,7 +59,8 @@ private: bool TransferDataToWindow() override; bool TransferDataFromWindow() override; - SCH_EDIT_FRAME* m_frame; + SCH_BASE_FRAME* m_frame; + bool m_isSymbolEditor; SCH_ITEM* m_currentItem; EDA_TEXT* m_currentText; UNIT_BINDER m_textSize; diff --git a/eeschema/dialogs/dialog_text_properties_base.cpp b/eeschema/dialogs/dialog_text_properties_base.cpp index fcd4fc3670..606d23b171 100644 --- a/eeschema/dialogs/dialog_text_properties_base.cpp +++ b/eeschema/dialogs/dialog_text_properties_base.cpp @@ -32,7 +32,7 @@ DIALOG_TEXT_PROPERTIES_BASE::DIALOG_TEXT_PROPERTIES_BASE( wxWindow* parent, wxWi m_textEntrySizer = new wxGridBagSizer( 2, 3 ); m_textEntrySizer->SetFlexibleDirection( wxBOTH ); m_textEntrySizer->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); - m_textEntrySizer->SetEmptyCellSize( wxSize( 0,12 ) ); + m_textEntrySizer->SetEmptyCellSize( wxSize( 0,6 ) ); m_textLabel = new wxStaticText( this, wxID_ANY, _("Text:"), wxDefaultPosition, wxDefaultSize, 0 ); m_textLabel->Wrap( -1 ); @@ -84,7 +84,7 @@ DIALOG_TEXT_PROPERTIES_BASE::DIALOG_TEXT_PROPERTIES_BASE( wxWindow* parent, wxWi m_textEntrySizer->Add( bSizer41, wxGBPosition( 1, 5 ), wxGBSpan( 1, 1 ), wxEXPAND|wxALIGN_RIGHT|wxLEFT, 5 ); m_excludeFromSim = new wxCheckBox( this, wxID_ANY, _("Exclude from simulation"), wxDefaultPosition, wxDefaultSize, 0 ); - m_textEntrySizer->Add( m_excludeFromSim, wxGBPosition( 1, 0 ), wxGBSpan( 1, 2 ), wxTOP, 10 ); + m_textEntrySizer->Add( m_excludeFromSim, wxGBPosition( 1, 0 ), wxGBSpan( 1, 2 ), wxTOP|wxBOTTOM, 10 ); m_fontLabel = new wxStaticText( this, wxID_ANY, _("Font:"), wxDefaultPosition, wxDefaultSize, 0 ); m_fontLabel->Wrap( -1 ); @@ -309,6 +309,34 @@ DIALOG_TEXT_PROPERTIES_BASE::DIALOG_TEXT_PROPERTIES_BASE( wxWindow* parent, wxWi bMainSizer->Add( m_textEntrySizer, 1, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 10 ); + m_fgSymbolEditor = new wxFlexGridSizer( 0, 3, 0, 0 ); + m_fgSymbolEditor->AddGrowableCol( 0 ); + m_fgSymbolEditor->AddGrowableCol( 2 ); + m_fgSymbolEditor->SetFlexibleDirection( wxBOTH ); + m_fgSymbolEditor->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); + + m_privateCheckbox = new wxCheckBox( this, wxID_ANY, _("Private to Symbol Editor"), wxDefaultPosition, wxDefaultSize, 0 ); + m_privateCheckbox->SetValue(true); + m_fgSymbolEditor->Add( m_privateCheckbox, 0, wxRIGHT, 5 ); + + + m_fgSymbolEditor->Add( 60, 0, 1, wxEXPAND, 5 ); + + m_commonToAllUnits = new wxCheckBox( this, wxID_ANY, _("Common to all units"), wxDefaultPosition, wxDefaultSize, 0 ); + m_fgSymbolEditor->Add( m_commonToAllUnits, 0, wxRIGHT|wxLEFT, 5 ); + + + m_fgSymbolEditor->Add( 0, 0, 1, wxEXPAND, 5 ); + + + m_fgSymbolEditor->Add( 0, 0, 1, wxEXPAND, 5 ); + + m_commonToAllBodyStyles = new wxCheckBox( this, wxID_ANY, _("Common to all body styles"), wxDefaultPosition, wxDefaultSize, 0 ); + m_fgSymbolEditor->Add( m_commonToAllBodyStyles, 0, wxALL, 5 ); + + + bMainSizer->Add( m_fgSymbolEditor, 0, wxEXPAND|wxRIGHT|wxLEFT, 10 ); + m_sdbSizer1 = new wxStdDialogButtonSizer(); m_sdbSizer1OK = new wxButton( this, wxID_OK ); m_sdbSizer1->AddButton( m_sdbSizer1OK ); diff --git a/eeschema/dialogs/dialog_text_properties_base.fbp b/eeschema/dialogs/dialog_text_properties_base.fbp index a015f8a7d3..f9422cd8f1 100644 --- a/eeschema/dialogs/dialog_text_properties_base.fbp +++ b/eeschema/dialogs/dialog_text_properties_base.fbp @@ -128,7 +128,7 @@ wxEXPAND|wxTOP|wxRIGHT|wxLEFT 1 - 0,12 + 0,6 wxBOTH 3 @@ -358,7 +358,7 @@ 10 2 0 - wxTOP + wxTOP|wxBOTTOM 1 1 @@ -3117,6 +3117,249 @@ + + 10 + wxEXPAND|wxRIGHT|wxLEFT + 0 + + 3 + wxBOTH + 0,2 + + 0 + + m_fgSymbolEditor + wxFLEX_GROWMODE_SPECIFIED + protected + 0 + 0 + + 5 + wxRIGHT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 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 + + 0 + protected + 60 + + + + 5 + wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + Common to all units + + 0 + + + 0 + + 1 + m_commonToAllUnits + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + 5 + wxEXPAND + 1 + + 0 + protected + 0 + + + + 5 + wxEXPAND + 1 + + 0 + protected + 0 + + + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + Common to all body styles + + 0 + + + 0 + + 1 + m_commonToAllBodyStyles + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + 5 wxALL|wxEXPAND diff --git a/eeschema/dialogs/dialog_text_properties_base.h b/eeschema/dialogs/dialog_text_properties_base.h index b3d0fc482d..c1823bab68 100644 --- a/eeschema/dialogs/dialog_text_properties_base.h +++ b/eeschema/dialogs/dialog_text_properties_base.h @@ -94,6 +94,10 @@ class DIALOG_TEXT_PROPERTIES_BASE : public DIALOG_SHIM COLOR_SWATCH* m_fillColorSwatch; wxCheckBox* m_hyperlinkCb; WX_COMBOBOX* m_hyperlinkCombo; + wxFlexGridSizer* m_fgSymbolEditor; + wxCheckBox* m_privateCheckbox; + wxCheckBox* m_commonToAllUnits; + wxCheckBox* m_commonToAllBodyStyles; wxStdDialogButtonSizer* m_sdbSizer1; wxButton* m_sdbSizer1OK; wxButton* m_sdbSizer1Cancel; diff --git a/eeschema/import_gfx/graphics_importer_lib_symbol.cpp b/eeschema/import_gfx/graphics_importer_lib_symbol.cpp index 06142f3625..f45817d1b1 100644 --- a/eeschema/import_gfx/graphics_importer_lib_symbol.cpp +++ b/eeschema/import_gfx/graphics_importer_lib_symbol.cpp @@ -27,9 +27,8 @@ #include #include -#include +#include #include -#include GRAPHICS_IMPORTER_LIB_SYMBOL::GRAPHICS_IMPORTER_LIB_SYMBOL( LIB_SYMBOL* aSymbol, int aUnit ) : @@ -186,17 +185,16 @@ void GRAPHICS_IMPORTER_LIB_SYMBOL::AddText( const VECTOR2D& aOrigin, const wxStr double aOrientation, GR_TEXT_H_ALIGN_T aHJustify, GR_TEXT_V_ALIGN_T aVJustify, const COLOR4D& aColor ) { - std::unique_ptr textItem = std::make_unique( m_symbol ); + auto textItem = std::make_unique( MapCoordinate( aOrigin ), aText, LAYER_DEVICE ); + textItem->SetParent( m_symbol ); textItem->SetUnit( m_unit ); textItem->SetTextColor( aColor ); textItem->SetTextThickness( MapLineWidth( aThickness ) ); - textItem->SetTextPos( MapCoordinate( aOrigin ) ); textItem->SetTextAngle( EDA_ANGLE( aOrientation, DEGREES_T ) ); textItem->SetTextWidth( aWidth * ImportScalingFactor().x ); textItem->SetTextHeight( aHeight * ImportScalingFactor().y ); textItem->SetVertJustify( aVJustify ); textItem->SetHorizJustify( aHJustify ); - textItem->SetText( aText ); addItem( std::move( textItem ) ); } diff --git a/eeschema/lib_symbol.cpp b/eeschema/lib_symbol.cpp index dbcc305acd..80b6dc05b3 100644 --- a/eeschema/lib_symbol.cpp +++ b/eeschema/lib_symbol.cpp @@ -971,6 +971,8 @@ void LIB_SYMBOL::AddDrawItem( SCH_ITEM* aItem, bool aSort ) { wxCHECK( aItem, /* void */ ); + aItem->SetParent( this ); + m_drawings.push_back( aItem ); if( aSort ) diff --git a/eeschema/lib_symbol.h b/eeschema/lib_symbol.h index 8962ef44a1..00cab138eb 100644 --- a/eeschema/lib_symbol.h +++ b/eeschema/lib_symbol.h @@ -45,7 +45,7 @@ class TEST_LIB_SYMBOL_FIXTURE; typedef std::shared_ptr LIB_SYMBOL_SPTR; ///< shared pointer to LIB_SYMBOL typedef std::weak_ptr LIB_SYMBOL_REF; ///< weak pointer to LIB_SYMBOL -typedef MULTIVECTOR LIB_ITEMS_CONTAINER; +typedef MULTIVECTOR LIB_ITEMS_CONTAINER; typedef LIB_ITEMS_CONTAINER::ITEM_PTR_VECTOR LIB_ITEMS; diff --git a/eeschema/lib_text.cpp b/eeschema/lib_text.cpp deleted file mode 100644 index 14b9cacd6a..0000000000 --- a/eeschema/lib_text.cpp +++ /dev/null @@ -1,533 +0,0 @@ -/* - * This program source code file is part of KiCad, a free EDA CAD application. - * - * Copyright (C) 2004-2024 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 // For some default values -#include - -LIB_TEXT::LIB_TEXT( SCH_ITEM* aParent ) : - SCH_ITEM( aParent, LIB_TEXT_T ), - EDA_TEXT( schIUScale, wxEmptyString ) -{ - SetTextSize( VECTOR2I( schIUScale.MilsToIU( DEFAULT_TEXT_SIZE ), - schIUScale.MilsToIU( DEFAULT_TEXT_SIZE ) ) ); -} - - -void LIB_TEXT::ViewGetLayers( int aLayers[], int& aCount ) const -{ - aCount = 2; - aLayers[0] = IsPrivate() ? LAYER_PRIVATE_NOTES : LAYER_DEVICE; - aLayers[1] = LAYER_SELECTION_SHADOWS; -} - - -bool LIB_TEXT::HitTest( const VECTOR2I& aPosition, int aAccuracy ) const -{ - EDA_TEXT tmp_text( *this ); - tmp_text.SetTextPos( DefaultTransform.TransformCoordinate( GetTextPos() ) ); - - /* The text orientation may need to be flipped if the - * transformation matrix causes xy axes to be flipped. - * this simple algo works only for schematic matrix (rot 90 or/and mirror) - */ - bool t1 = ( DefaultTransform.x1 != 0 ) ^ ( GetTextAngle() != ANGLE_HORIZONTAL ); - - tmp_text.SetTextAngle( t1 ? ANGLE_HORIZONTAL : ANGLE_VERTICAL ); - return tmp_text.TextHitTest( aPosition, aAccuracy ); -} - - -EDA_ITEM* LIB_TEXT::Clone() const -{ - return new LIB_TEXT( *this ); -} - - -int LIB_TEXT::compare( const SCH_ITEM& aOther, int aCompareFlags ) const -{ - wxASSERT( aOther.Type() == LIB_TEXT_T ); - - int retv = SCH_ITEM::compare( aOther, aCompareFlags ); - - if( retv ) - return retv; - - const LIB_TEXT* tmp = ( LIB_TEXT* ) &aOther; - - int result = GetText().CmpNoCase( tmp->GetText() ); - - if( result != 0 ) - return result; - - if( GetTextPos().x != tmp->GetTextPos().x ) - return GetTextPos().x - tmp->GetTextPos().x; - - if( GetTextPos().y != tmp->GetTextPos().y ) - return GetTextPos().y - tmp->GetTextPos().y; - - if( GetTextWidth() != tmp->GetTextWidth() ) - return GetTextWidth() - tmp->GetTextWidth(); - - if( GetTextHeight() != tmp->GetTextHeight() ) - return GetTextHeight() - tmp->GetTextHeight(); - - return 0; -} - - -void LIB_TEXT::Move( const VECTOR2I& aOffset ) -{ - EDA_TEXT::Offset( aOffset ); -} - - -void LIB_TEXT::NormalizeJustification( bool inverse ) -{ - if( GetHorizJustify() == GR_TEXT_H_ALIGN_CENTER && GetVertJustify() == GR_TEXT_V_ALIGN_CENTER ) - return; - - VECTOR2I delta( 0, 0 ); - BOX2I bbox = GetTextBox(); - - if( GetTextAngle().IsHorizontal() ) - { - if( GetHorizJustify() == GR_TEXT_H_ALIGN_LEFT ) - delta.x = bbox.GetWidth() / 2; - else if( GetHorizJustify() == GR_TEXT_H_ALIGN_RIGHT ) - delta.x = - bbox.GetWidth() / 2; - - if( GetVertJustify() == GR_TEXT_V_ALIGN_TOP ) - delta.y = - bbox.GetHeight() / 2; - else if( GetVertJustify() == GR_TEXT_V_ALIGN_BOTTOM ) - delta.y = bbox.GetHeight() / 2; - } - else - { - if( GetHorizJustify() == GR_TEXT_H_ALIGN_LEFT ) - delta.y = bbox.GetWidth() / 2; - else if( GetHorizJustify() == GR_TEXT_H_ALIGN_RIGHT ) - delta.y = - bbox.GetWidth() / 2; - - if( GetVertJustify() == GR_TEXT_V_ALIGN_TOP ) - delta.x = + bbox.GetHeight() / 2; - else if( GetVertJustify() == GR_TEXT_V_ALIGN_BOTTOM ) - delta.x = - bbox.GetHeight() / 2; - } - - if( inverse ) - SetTextPos( GetTextPos() - delta ); - else - SetTextPos( GetTextPos() + delta ); -} - - -void LIB_TEXT::MirrorHorizontally( int aCenter ) -{ - NormalizeJustification( false ); - int x = GetTextPos().x; - - x -= aCenter; - x *= -1; - x += aCenter; - - if( GetTextAngle().IsHorizontal() ) - { - if( GetHorizJustify() == GR_TEXT_H_ALIGN_LEFT ) - SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT ); - else if( GetHorizJustify() == GR_TEXT_H_ALIGN_RIGHT ) - SetHorizJustify( GR_TEXT_H_ALIGN_LEFT ); - } - else - { - if( GetVertJustify() == GR_TEXT_V_ALIGN_TOP ) - SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM ); - else if( GetVertJustify() == GR_TEXT_V_ALIGN_BOTTOM ) - SetVertJustify( GR_TEXT_V_ALIGN_TOP ); - } - - SetTextX( x ); - NormalizeJustification( true ); -} - - -void LIB_TEXT::MirrorVertically( int aCenter ) -{ - NormalizeJustification( false ); - int y = GetTextPos().y; - - y -= aCenter; - y *= -1; - y += aCenter; - - if( GetTextAngle().IsHorizontal() ) - { - if( GetVertJustify() == GR_TEXT_V_ALIGN_TOP ) - SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM ); - else if( GetVertJustify() == GR_TEXT_V_ALIGN_BOTTOM ) - SetVertJustify( GR_TEXT_V_ALIGN_TOP ); - } - else - { - if( GetHorizJustify() == GR_TEXT_H_ALIGN_LEFT ) - SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT ); - else if( GetHorizJustify() == GR_TEXT_H_ALIGN_RIGHT ) - SetHorizJustify( GR_TEXT_H_ALIGN_LEFT ); - } - - SetTextY( y ); - NormalizeJustification( true ); -} - - -void LIB_TEXT::Rotate( const VECTOR2I& center, bool aRotateCCW ) -{ - NormalizeJustification( false ); - EDA_ANGLE rot_angle = aRotateCCW ? -ANGLE_90 : ANGLE_90; - - VECTOR2I pt = GetTextPos(); - RotatePoint( pt, center, rot_angle ); - SetTextPos( pt ); - - if( GetTextAngle().IsHorizontal() ) - { - SetTextAngle( ANGLE_VERTICAL ); - } - else - { - // 180° rotation is a mirror - - if( GetHorizJustify() == GR_TEXT_H_ALIGN_LEFT ) - SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT ); - else if( GetHorizJustify() == GR_TEXT_H_ALIGN_RIGHT ) - SetHorizJustify( GR_TEXT_H_ALIGN_LEFT ); - - if( GetVertJustify() == GR_TEXT_V_ALIGN_TOP ) - SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM ); - else if( GetVertJustify() == GR_TEXT_V_ALIGN_BOTTOM ) - SetVertJustify( GR_TEXT_V_ALIGN_TOP ); - - SetTextAngle( ANGLE_0 ); - } - - NormalizeJustification( true ); -} - - -void LIB_TEXT::Plot( PLOTTER* plotter, bool aBackground, const SCH_PLOT_OPTS& aPlotOpts, - int aUnit, int aBodyStyle, const VECTOR2I& offset, bool aDimmed ) -{ - wxASSERT( plotter != nullptr ); - - if( IsPrivate() ) - return; - - if( aBackground ) - return; - - SCH_RENDER_SETTINGS* renderSettings = getRenderSettings( plotter ); - - BOX2I bBox = GetBoundingBox(); - // convert coordinates from draw Y axis to symbol_editor Y axis - bBox.RevertYAxis(); - - /* - * 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 plotter's Text() function will also recalculate H and V justifications according - * to the text orientation - * - when a symbol is mirrored the text is not, and justifications become a nightmare - * - * So the easier way is to use no justifications (centered text) and use GetBoundingBox to - * know the text coordinate considered as centered. - */ - VECTOR2I txtpos = bBox.Centre(); - TEXT_ATTRIBUTES attrs = GetAttributes(); - attrs.m_Halign = GR_TEXT_H_ALIGN_CENTER; - attrs.m_Valign = GR_TEXT_V_ALIGN_CENTER; - - // The text orientation may need to be flipped if the transformation matrix causes xy - // axes to be flipped. - int t1 = ( renderSettings->m_Transform.x1 != 0 ) ^ ( GetTextAngle() != ANGLE_HORIZONTAL ); - VECTOR2I pos = renderSettings->TransformCoordinate( txtpos ) + offset; - COLOR4D color = GetTextColor(); - COLOR4D bg = renderSettings->GetBackgroundColor(); - - if( !plotter->GetColorMode() || color == COLOR4D::UNSPECIFIED ) - color = renderSettings->GetLayerColor( LAYER_DEVICE ); - - if( !IsVisible() ) - bg = renderSettings->GetLayerColor( LAYER_HIDDEN ); - else if( bg == COLOR4D::UNSPECIFIED || !plotter->GetColorMode() ) - bg = COLOR4D::WHITE; - - if( aDimmed ) - { - color.Desaturate( ); - color = color.Mix( bg, 0.5f ); - } - - int penWidth = std::max( GetEffectiveTextPenWidth(), renderSettings->GetMinPenWidth() ); - - KIFONT::FONT* font = GetFont(); - - if( !font ) - font = KIFONT::FONT::GetFont( renderSettings->GetDefaultFont(), IsBold(), IsItalic() ); - - attrs.m_StrokeWidth = penWidth; - attrs.m_Angle = t1 ? ANGLE_HORIZONTAL : ANGLE_VERTICAL; - - plotter->PlotText( pos, color, GetText(), attrs, font, GetFontMetrics() ); -} - - -int LIB_TEXT::GetPenWidth() const -{ - return GetEffectiveTextPenWidth(); -} - - -KIFONT::FONT* LIB_TEXT::getDrawFont() const -{ - KIFONT::FONT* font = EDA_TEXT::GetFont(); - - if( !font ) - font = KIFONT::FONT::GetFont( GetDefaultFont(), IsBold(), IsItalic() ); - - return font; -} - - -void LIB_TEXT::Print( const SCH_RENDER_SETTINGS* aSettings, int aUnit, int aBodyStyle, - const VECTOR2I& aOffset, bool aForceNoFill, bool aDimmed ) -{ - wxDC* DC = aSettings->GetPrintDC(); - COLOR4D color = GetTextColor(); - bool blackAndWhiteMode = GetGRForceBlackPenState(); - int penWidth = std::max( GetEffectiveTextPenWidth(), aSettings->GetDefaultPenWidth() ); - - if( blackAndWhiteMode || color == COLOR4D::UNSPECIFIED ) - color = aSettings->GetLayerColor( LAYER_DEVICE ); - - COLOR4D bg = aSettings->GetBackgroundColor(); - - if( bg == COLOR4D::UNSPECIFIED || GetGRForceBlackPenState() ) - bg = COLOR4D::WHITE; - - if( !IsVisible() ) - bg = aSettings->GetLayerColor( LAYER_HIDDEN ); - - if( aDimmed ) - { - color.Desaturate( ); - color = color.Mix( bg, 0.5f ); - } - - // Calculate the text orientation, according to the symbol orientation/mirror (needed when - // draw text in schematic) - EDA_ANGLE orient = GetTextAngle(); - - if( aSettings->m_Transform.y1 ) // Rotate symbol 90 degrees. - { - if( orient == ANGLE_HORIZONTAL ) - orient = ANGLE_VERTICAL; - else - orient = ANGLE_HORIZONTAL; - } - - KIFONT::FONT* font = GetFont(); - - if( !font ) - font = KIFONT::FONT::GetFont( aSettings->GetDefaultFont(), IsBold(), IsItalic() ); - - /* - * 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 - */ - BOX2I 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 = aSettings->m_Transform.TransformCoordinate( txtpos ) + aOffset; - - GRPrintText( DC, txtpos, color, GetShownText( true ), orient, GetTextSize(), - GR_TEXT_H_ALIGN_CENTER, GR_TEXT_V_ALIGN_CENTER, penWidth, IsItalic(), IsBold(), - font, GetFontMetrics() ); -} - - -void LIB_TEXT::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector& aList ) -{ - wxString msg; - - getSymbolEditorMsgPanelInfo( aFrame, aList ); - - // Don't use GetShownText() here; we want to show the user the variable references - aList.emplace_back( _( "Text" ), KIUI::EllipsizeStatusText( aFrame, GetText() ) ); - - aList.emplace_back( _( "Font" ), GetFont() ? GetFont()->GetName() : _( "Default" ) ); - - aList.emplace_back( _( "Style" ), GetTextStyleName() ); - - aList.emplace_back( _( "Text Size" ), aFrame->MessageTextFromValue( GetTextWidth() ) ); - - switch ( GetHorizJustify() ) - { - case GR_TEXT_H_ALIGN_LEFT: msg = _( "Left" ); break; - case GR_TEXT_H_ALIGN_CENTER: msg = _( "Center" ); break; - case GR_TEXT_H_ALIGN_RIGHT: msg = _( "Right" ); break; - case GR_TEXT_H_ALIGN_INDETERMINATE: msg = INDETERMINATE_STATE; break; - } - - aList.emplace_back( _( "H Justification" ), msg ); - - switch ( GetVertJustify() ) - { - case GR_TEXT_V_ALIGN_TOP: msg = _( "Top" ); break; - case GR_TEXT_V_ALIGN_CENTER: msg = _( "Center" ); break; - case GR_TEXT_V_ALIGN_BOTTOM: msg = _( "Bottom" ); break; - case GR_TEXT_V_ALIGN_INDETERMINATE: msg = INDETERMINATE_STATE; break; - } - - aList.emplace_back( _( "V Justification" ), msg ); -} - - -const BOX2I LIB_TEXT::GetBoundingBox() const -{ - /* Y coordinates for LIB_ITEMS are bottom to top, so we must invert the Y position when - * calling GetTextBox() that works using top to bottom Y axis orientation. - */ - BOX2I bbox = GetTextBox( -1, true ); - bbox.RevertYAxis(); - - // We are using now a bottom to top Y axis. - VECTOR2I orig = bbox.GetOrigin(); - VECTOR2I end = bbox.GetEnd(); - - RotatePoint( orig, GetTextPos(), -GetTextAngle() ); - RotatePoint( end, GetTextPos(), -GetTextAngle() ); - - bbox.SetOrigin( orig ); - bbox.SetEnd( end ); - - // We are using now a top to bottom Y axis: - bbox.RevertYAxis(); - - return bbox; -} - - -wxString LIB_TEXT::GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) const -{ - return wxString::Format( _( "Graphic Text '%s'" ), KIUI::EllipsizeMenuText( GetText() ) ); -} - - -BITMAPS LIB_TEXT::GetMenuImage() const -{ - return BITMAPS::text; -} - - -void LIB_TEXT::BeginEdit( const VECTOR2I& aPosition ) -{ - SetTextPos( aPosition ); -} - - -void LIB_TEXT::CalcEdit( const VECTOR2I& aPosition ) -{ - SetTextPos( aPosition ); -} - - -bool LIB_TEXT::operator==( const SCH_ITEM& aOther ) const -{ - if( Type() != aOther.Type() ) - return false; - - const LIB_TEXT& other = static_cast( aOther ); - - return SCH_ITEM::operator==( aOther ) && EDA_TEXT::operator==( other ); -} - - -double LIB_TEXT::Similarity( const SCH_ITEM& aOther ) const -{ - if( m_Uuid == aOther.m_Uuid ) - return 1.0; - - if( aOther.Type() != Type() ) - return 0.0; - - const LIB_TEXT& other = static_cast( aOther ); - - double similarity = SimilarityBase( other ); - similarity *= EDA_TEXT::Similarity( other ); - - return similarity; -} - -static struct LIB_TEXT_DESC -{ - LIB_TEXT_DESC() - { - PROPERTY_MANAGER& propMgr = PROPERTY_MANAGER::Instance(); - REGISTER_TYPE( LIB_TEXT ); - propMgr.AddTypeCast( new TYPE_CAST ); - propMgr.AddTypeCast( new TYPE_CAST ); - propMgr.InheritsAfter( TYPE_HASH( LIB_TEXT ), TYPE_HASH( SCH_ITEM ) ); - propMgr.InheritsAfter( TYPE_HASH( LIB_TEXT ), TYPE_HASH( EDA_TEXT ) ); - - propMgr.Mask( TYPE_HASH( LIB_TEXT ), TYPE_HASH( EDA_TEXT ), _HKI( "Mirrored" ) ); - propMgr.Mask( TYPE_HASH( LIB_TEXT ), TYPE_HASH( EDA_TEXT ), _HKI( "Visible" ) ); - propMgr.Mask( TYPE_HASH( LIB_TEXT ), TYPE_HASH( EDA_TEXT ), _HKI( "Width" ) ); - propMgr.Mask( TYPE_HASH( LIB_TEXT ), TYPE_HASH( EDA_TEXT ), _HKI( "Height" ) ); - - // Orientation is exposed differently in schematic; mask the base for now - propMgr.Mask( TYPE_HASH( LIB_TEXT ), TYPE_HASH( EDA_TEXT ), _HKI( "Orientation" ) ); - } -} _LIB_TEXT_DESC; diff --git a/eeschema/lib_text.h b/eeschema/lib_text.h deleted file mode 100644 index e1dd6c8875..0000000000 --- a/eeschema/lib_text.h +++ /dev/null @@ -1,137 +0,0 @@ -/* - * 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-2024 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_TEXT_H -#define LIB_TEXT_H - -#include -#include - - -/** - * Define a symbol library graphical text item. - * - * This is only a graphical text item. Field text like the reference designator, - * symbol value, etc. are not LIB_TEXT items. See the #SCH_FIELD class for the - * field item definition. - */ -class LIB_TEXT : public SCH_ITEM, public EDA_TEXT -{ -public: - LIB_TEXT( SCH_ITEM* aParent ); - - // Do not create a copy constructor. The one generated by the compiler is adequate. - - ~LIB_TEXT() { } - - wxString GetClass() const override - { - return wxT( "LIB_TEXT" ); - } - - static inline bool ClassOf( const EDA_ITEM* aItem ) - { - return aItem && aItem->Type() == LIB_TEXT_T; - } - - wxString GetFriendlyName() const override - { - return _( "Text" ); - } - - void ViewGetLayers( int aLayers[], int& aCount ) const override; - - bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override; - - bool HitTest( const BOX2I& aRect, bool aContained, int aAccuracy = 0 ) const override - { - if( m_flags & (STRUCT_DELETED | SKIP_STRUCT ) ) - return false; - - BOX2I rect = aRect; - - rect.Inflate( aAccuracy ); - - BOX2I textBox = GetTextBox(); - textBox.RevertYAxis(); - - if( aContained ) - return rect.Contains( textBox ); - - return rect.Intersects( textBox, GetTextAngle() ); - } - - int GetPenWidth() const override; - - KIFONT::FONT* getDrawFont() const override; - - const BOX2I GetBoundingBox() const override; - - void BeginEdit( const VECTOR2I& aStartPoint ) override; - void CalcEdit( const VECTOR2I& aPosition ) override; - - void Move( const VECTOR2I& aOffset ) override; - - VECTOR2I GetPosition() const override { return EDA_TEXT::GetTextPos(); } - void SetPosition( const VECTOR2I& aPos ) override { EDA_TEXT::SetTextPos( aPos ); } - - void MirrorHorizontally( int aCenter ) override; - void MirrorVertically( int aCenter ) override; - void Rotate( const VECTOR2I& aCenter, bool aRotateCCW = true ) override; - - void NormalizeJustification( bool inverse ); - - void Print( const SCH_RENDER_SETTINGS* aSettings, int aUnit, int aBodyStyle, - const VECTOR2I& aOffset, bool aForceNoFill, bool aDimmed ) override; - - void Plot( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT_OPTS& aPlotOpts, - int aUnit, int aBodyStyle, const VECTOR2I& aOffset, bool aDimmed ) override; - - wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) const override; - void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector& aList ) override; - - BITMAPS GetMenuImage() const override; - - EDA_ITEM* Clone() const override; - - double Similarity( const SCH_ITEM& aOther ) const override; - - bool operator==( const SCH_ITEM& aOther ) const override; - -private: - /** - * @copydoc SCH_ITEM::compare() - * - * The text specific sort order is as follows: - * - Text string, case insensitive compare. - * - Text horizontal (X) position. - * - Text vertical (Y) position. - * - Text width. - * - Text height. - */ - int compare( const SCH_ITEM& aOther, int aCompareFlags = 0 ) const override; -}; - - -#endif // LIB_TEXT_H diff --git a/eeschema/sch_io/altium/sch_io_altium.cpp b/eeschema/sch_io/altium/sch_io_altium.cpp index 14e2f7a565..bf3a36b00b 100644 --- a/eeschema/sch_io/altium/sch_io_altium.cpp +++ b/eeschema/sch_io/altium/sch_io_altium.cpp @@ -40,7 +40,6 @@ #include #include #include -#include #include #include @@ -1521,7 +1520,7 @@ void SCH_IO_ALTIUM::ParseLabel( const std::map& aProperties, schsym = m_symbols.at( libSymbolIt->first ); } - LIB_TEXT* textItem = new LIB_TEXT( symbol ); + SCH_TEXT* textItem = new SCH_TEXT( { 0, 0 }, elem.text, LAYER_DEVICE ); symbol->AddDrawItem( textItem, false ); /// Handle labels that are in a library symbol, not on schematic @@ -1531,10 +1530,9 @@ void SCH_IO_ALTIUM::ParseLabel( const std::map& aProperties, textItem->SetPosition( GetRelativePosition( elem.location + m_sheetOffset, schsym ) ); textItem->SetUnit( std::max( 0, elem.ownerpartid ) ); - textItem->SetText( elem.text ); SetTextPositioning( textItem, elem.justification, elem.orientation ); - size_t fontId = static_cast( elem.fontId ); + size_t fontId = elem.fontId; if( m_altiumSheet && fontId > 0 && fontId <= m_altiumSheet->fonts.size() ) { diff --git a/eeschema/sch_io/cadstar/cadstar_sch_archive_loader.cpp b/eeschema/sch_io/cadstar/cadstar_sch_archive_loader.cpp index 12414a1f6f..206c1816d0 100644 --- a/eeschema/sch_io/cadstar/cadstar_sch_archive_loader.cpp +++ b/eeschema/sch_io/cadstar/cadstar_sch_archive_loader.cpp @@ -31,7 +31,6 @@ #include #include #include -#include #include #include #include @@ -1696,9 +1695,9 @@ const LIB_SYMBOL* CADSTAR_SCH_ARCHIVE_LOADER::loadSymdef( const SYMDEF_ID& aSymd for( std::pair textPair : csSym.Texts ) { TEXT csText = textPair.second; + VECTOR2I pos = getKiCadLibraryPoint( csText.Position, csSym.Origin ); + auto libtext = std::make_unique( pos, csText.Text, LAYER_DEVICE ); - std::unique_ptr libtext = std::make_unique( kiSym.get() ); - libtext->SetText( csText.Text ); libtext->SetUnit( gateNumber ); libtext->SetPosition( getKiCadLibraryPoint( csText.Position, csSym.Origin ) ); libtext->SetMultilineAllowed( true ); // temporarily so that we calculate bbox correctly @@ -1720,7 +1719,7 @@ const LIB_SYMBOL* CADSTAR_SCH_ARCHIVE_LOADER::loadSymdef( const SYMDEF_ID& aSymd RotatePoint( linePos, libtext->GetTextPos(), -libtext->GetTextAngle() ); - LIB_TEXT* textLine = static_cast( libtext->Duplicate() ); + SCH_TEXT* textLine = static_cast( libtext->Duplicate() ); textLine->SetText( strings[ii] ); textLine->SetHorizJustify( GR_TEXT_H_ALIGN_LEFT ); textLine->SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM ); @@ -3064,12 +3063,7 @@ void CADSTAR_SCH_ARCHIVE_LOADER::applyTextSettings( EDA_TEXT* aKiCadT EDA_ITEM* textEdaItem = dynamic_cast( aKiCadTextItem ); wxCHECK( textEdaItem, /* void */ ); // ensure this is a EDA_ITEM - switch( textEdaItem->Type() ) - { - // Some KiCad schematic text items only permit a limited amount of angles - // and text justifications - case LIB_TEXT_T: - case SCH_FIELD_T: + if( textEdaItem->Type() == SCH_FIELD_T || aInvertY ) { // Spin style not used. All text justifications are permitted. However, only orientations // of 0 deg or 90 deg are supported @@ -3101,10 +3095,8 @@ void CADSTAR_SCH_ARCHIVE_LOADER::applyTextSettings( EDA_TEXT* aKiCadT aKiCadTextItem->SetTextAngle( angle ); setAlignment( aKiCadTextItem, textAlignment ); - return; } - - case SCH_TEXT_T: + else if( textEdaItem->Type() == SCH_TEXT_T ) { // Note spin style in a SCH_TEXT results in a vertical alignment GR_TEXT_V_ALIGN_BOTTOM // so need to adjust the location of the text element based on Cadstar's original text @@ -3122,6 +3114,7 @@ void CADSTAR_SCH_ARCHIVE_LOADER::applyTextSettings( EDA_TEXT* aKiCadT case SPIN_STYLE::UP: pos = { bb.GetRight() - off, bb.GetBottom() }; break; case SPIN_STYLE::LEFT: pos = { bb.GetRight() , bb.GetBottom() + off }; break; case SPIN_STYLE::RIGHT: pos = { bb.GetLeft() , bb.GetBottom() + off }; break; + default: wxFAIL_MSG( "Unexpected Spin Style" ); break; } aKiCadTextItem->SetTextPos( pos ); @@ -3147,23 +3140,22 @@ void CADSTAR_SCH_ARCHIVE_LOADER::applyTextSettings( EDA_TEXT* aKiCadT aKiCadTextItem->SetTextAngle( ANGLE_VERTICAL ); aKiCadTextItem->SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT ); break; + + default: + wxFAIL_MSG( "Unexpected Spin Style" ); + break; } aKiCadTextItem->SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM ); - break; } - - // We don't want to change position of net labels as that would break connectivity - case