mirror of
https://gitlab.com/kicad/code/kicad.git
synced 2025-04-18 18:29:17 +00:00
Collapse LIB_TEXT into SCH_TEXT.
This commit is contained in:
parent
5d7e96841b
commit
3efe504dcc
common
eeschema
CMakeLists.txtsch_label.cppsch_painter.cppsch_painter.hsch_symbol.cppsch_text.cppsch_text.h
api
dialogs
dialog_lib_text_properties.cppdialog_lib_text_properties.hdialog_lib_text_properties_base.cppdialog_lib_text_properties_base.fbpdialog_lib_text_properties_base.hdialog_text_properties.cppdialog_text_properties.hdialog_text_properties_base.cppdialog_text_properties_base.fbpdialog_text_properties_base.h
import_gfx
lib_symbol.cpplib_symbol.hlib_text.cpplib_text.hsch_io
altium
cadstar
eagle
easyeda
easyedapro
kicad_legacy
kicad_sexpr
sch_io_kicad_sexpr.cppsch_io_kicad_sexpr_lib_cache.cppsch_io_kicad_sexpr_lib_cache.hsch_io_kicad_sexpr_parser.cppsch_io_kicad_sexpr_parser.h
ltspice
symbol_editor
tools
include/core
qa/tests/eeschema
@ -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;
|
||||
|
@ -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" ) )
|
||||
|
||||
|
@ -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
|
||||
|
@ -21,9 +21,7 @@
|
||||
#include <lib_pin.h>
|
||||
#include <lib_shape.h>
|
||||
#include <lib_symbol.h>
|
||||
#include <lib_text.h>
|
||||
#include <lib_textbox.h>
|
||||
|
||||
#include <sch_bitmap.h>
|
||||
#include <sch_bus_entry.h>
|
||||
#include <sch_field.h>
|
||||
@ -31,7 +29,6 @@
|
||||
#include <sch_label.h>
|
||||
#include <sch_line.h>
|
||||
#include <sch_no_connect.h>
|
||||
#include <sch_pin.h>
|
||||
#include <sch_shape.h>
|
||||
#include <sch_sheet.h>
|
||||
#include <sch_sheet_pin.h>
|
||||
@ -95,7 +92,6 @@ std::unique_ptr<EDA_ITEM> 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<LIB_SHAPE>( parentLibSymbol );
|
||||
case LIB_TEXT_T: return std::make_unique<LIB_TEXT>( parentLibSymbol );
|
||||
case LIB_TEXTBOX_T: return std::make_unique<LIB_TEXTBOX>( parentLibSymbol );
|
||||
case LIB_PIN_T: return std::make_unique<LIB_PIN>( parentLibSymbol );
|
||||
|
||||
|
@ -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 <widgets/bitmap_button.h>
|
||||
#include <widgets/font_choice.h>
|
||||
#include <widgets/color_swatch.h>
|
||||
#include <symbol_edit_frame.h>
|
||||
#include <lib_text.h>
|
||||
#include <settings/settings_manager.h>
|
||||
#include <dialog_lib_text_properties.h>
|
||||
#include <symbol_editor/symbol_editor_settings.h>
|
||||
#include <tools/symbol_editor_drawing_tools.h>
|
||||
#include <scintilla_tricks.h>
|
||||
#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_EDITOR_DRAWING_TOOLS>();
|
||||
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<SYMBOL_EDITOR_DRAWING_TOOLS>();
|
||||
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();
|
||||
}
|
@ -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 <dialog_lib_text_properties_base.h>
|
||||
#include <widgets/unit_binder.h>
|
||||
|
||||
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
|
@ -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 );
|
||||
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -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 <wx/artprov.h>
|
||||
#include <wx/xrc/xmlres.h>
|
||||
#include <wx/intl.h>
|
||||
class BITMAP_BUTTON;
|
||||
class COLOR_SWATCH;
|
||||
class FONT_CHOICE;
|
||||
|
||||
#include "dialog_shim.h"
|
||||
#include <wx/string.h>
|
||||
#include <wx/stattext.h>
|
||||
#include <wx/gdicmn.h>
|
||||
#include <wx/font.h>
|
||||
#include <wx/colour.h>
|
||||
#include <wx/settings.h>
|
||||
#include <wx/stc/stc.h>
|
||||
#include <wx/choice.h>
|
||||
#include <wx/bmpbuttn.h>
|
||||
#include <wx/bitmap.h>
|
||||
#include <wx/image.h>
|
||||
#include <wx/icon.h>
|
||||
#include <wx/button.h>
|
||||
#include <wx/sizer.h>
|
||||
#include <wx/textctrl.h>
|
||||
#include <wx/panel.h>
|
||||
#include <wx/checkbox.h>
|
||||
#include <wx/gbsizer.h>
|
||||
#include <wx/dialog.h>
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
/// 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();
|
||||
|
||||
};
|
||||
|
@ -24,6 +24,7 @@
|
||||
*/
|
||||
|
||||
#include <sch_edit_frame.h>
|
||||
#include <symbol_edit_frame.h>
|
||||
#include <widgets/bitmap_button.h>
|
||||
#include <widgets/font_choice.h>
|
||||
#include <widgets/color_swatch.h>
|
||||
@ -39,7 +40,7 @@
|
||||
#include <gr_text.h>
|
||||
|
||||
|
||||
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<SYMBOL_EDIT_FRAME*>( 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<SCH_EDIT_FRAME*>( m_frame ) )
|
||||
{
|
||||
wxString sheetPageNum = sheet.GetPageNumber();
|
||||
wxString sheetName = sheet.size() == 1 ? _( "<root sheet>" ) : 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 ? _( "<root sheet>" )
|
||||
: 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<SYMBOL_EDIT_FRAME*>( 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 \"#<page number>\" 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() )
|
||||
{
|
||||
|
@ -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;
|
||||
|
@ -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 );
|
||||
|
@ -128,7 +128,7 @@
|
||||
<property name="flag">wxEXPAND|wxTOP|wxRIGHT|wxLEFT</property>
|
||||
<property name="proportion">1</property>
|
||||
<object class="wxGridBagSizer" expanded="true">
|
||||
<property name="empty_cell_size">0,12</property>
|
||||
<property name="empty_cell_size">0,6</property>
|
||||
<property name="flexible_direction">wxBOTH</property>
|
||||
<property name="growablecols">3</property>
|
||||
<property name="growablerows"></property>
|
||||
@ -358,7 +358,7 @@
|
||||
<property name="border">10</property>
|
||||
<property name="colspan">2</property>
|
||||
<property name="column">0</property>
|
||||
<property name="flag">wxTOP</property>
|
||||
<property name="flag">wxTOP|wxBOTTOM</property>
|
||||
<property name="row">1</property>
|
||||
<property name="rowspan">1</property>
|
||||
<object class="wxCheckBox" expanded="true">
|
||||
@ -3117,6 +3117,249 @@
|
||||
</object>
|
||||
</object>
|
||||
</object>
|
||||
<object class="sizeritem" expanded="true">
|
||||
<property name="border">10</property>
|
||||
<property name="flag">wxEXPAND|wxRIGHT|wxLEFT</property>
|
||||
<property name="proportion">0</property>
|
||||
<object class="wxFlexGridSizer" expanded="true">
|
||||
<property name="cols">3</property>
|
||||
<property name="flexible_direction">wxBOTH</property>
|
||||
<property name="growablecols">0,2</property>
|
||||
<property name="growablerows"></property>
|
||||
<property name="hgap">0</property>
|
||||
<property name="minimum_size"></property>
|
||||
<property name="name">m_fgSymbolEditor</property>
|
||||
<property name="non_flexible_grow_mode">wxFLEX_GROWMODE_SPECIFIED</property>
|
||||
<property name="permission">protected</property>
|
||||
<property name="rows">0</property>
|
||||
<property name="vgap">0</property>
|
||||
<object class="sizeritem" expanded="true">
|
||||
<property name="border">5</property>
|
||||
<property name="flag">wxRIGHT</property>
|
||||
<property name="proportion">0</property>
|
||||
<object class="wxCheckBox" expanded="true">
|
||||
<property name="BottomDockable">1</property>
|
||||
<property name="LeftDockable">1</property>
|
||||
<property name="RightDockable">1</property>
|
||||
<property name="TopDockable">1</property>
|
||||
<property name="aui_layer"></property>
|
||||
<property name="aui_name"></property>
|
||||
<property name="aui_position"></property>
|
||||
<property name="aui_row"></property>
|
||||
<property name="best_size"></property>
|
||||
<property name="bg"></property>
|
||||
<property name="caption"></property>
|
||||
<property name="caption_visible">1</property>
|
||||
<property name="center_pane">0</property>
|
||||
<property name="checked">1</property>
|
||||
<property name="close_button">1</property>
|
||||
<property name="context_help"></property>
|
||||
<property name="context_menu">1</property>
|
||||
<property name="default_pane">0</property>
|
||||
<property name="dock">Dock</property>
|
||||
<property name="dock_fixed">0</property>
|
||||
<property name="docking">Left</property>
|
||||
<property name="drag_accept_files">0</property>
|
||||
<property name="enabled">1</property>
|
||||
<property name="fg"></property>
|
||||
<property name="floatable">1</property>
|
||||
<property name="font"></property>
|
||||
<property name="gripper">0</property>
|
||||
<property name="hidden">0</property>
|
||||
<property name="id">wxID_ANY</property>
|
||||
<property name="label">Private to Symbol Editor</property>
|
||||
<property name="max_size"></property>
|
||||
<property name="maximize_button">0</property>
|
||||
<property name="maximum_size"></property>
|
||||
<property name="min_size"></property>
|
||||
<property name="minimize_button">0</property>
|
||||
<property name="minimum_size"></property>
|
||||
<property name="moveable">1</property>
|
||||
<property name="name">m_privateCheckbox</property>
|
||||
<property name="pane_border">1</property>
|
||||
<property name="pane_position"></property>
|
||||
<property name="pane_size"></property>
|
||||
<property name="permission">protected</property>
|
||||
<property name="pin_button">1</property>
|
||||
<property name="pos"></property>
|
||||
<property name="resize">Resizable</property>
|
||||
<property name="show">1</property>
|
||||
<property name="size"></property>
|
||||
<property name="style"></property>
|
||||
<property name="subclass">; ; forward_declare</property>
|
||||
<property name="toolbar_pane">0</property>
|
||||
<property name="tooltip"></property>
|
||||
<property name="validator_data_type"></property>
|
||||
<property name="validator_style">wxFILTER_NONE</property>
|
||||
<property name="validator_type">wxDefaultValidator</property>
|
||||
<property name="validator_variable"></property>
|
||||
<property name="window_extra_style"></property>
|
||||
<property name="window_name"></property>
|
||||
<property name="window_style"></property>
|
||||
</object>
|
||||
</object>
|
||||
<object class="sizeritem" expanded="true">
|
||||
<property name="border">5</property>
|
||||
<property name="flag">wxEXPAND</property>
|
||||
<property name="proportion">1</property>
|
||||
<object class="spacer" expanded="true">
|
||||
<property name="height">0</property>
|
||||
<property name="permission">protected</property>
|
||||
<property name="width">60</property>
|
||||
</object>
|
||||
</object>
|
||||
<object class="sizeritem" expanded="true">
|
||||
<property name="border">5</property>
|
||||
<property name="flag">wxRIGHT|wxLEFT</property>
|
||||
<property name="proportion">0</property>
|
||||
<object class="wxCheckBox" expanded="true">
|
||||
<property name="BottomDockable">1</property>
|
||||
<property name="LeftDockable">1</property>
|
||||
<property name="RightDockable">1</property>
|
||||
<property name="TopDockable">1</property>
|
||||
<property name="aui_layer"></property>
|
||||
<property name="aui_name"></property>
|
||||
<property name="aui_position"></property>
|
||||
<property name="aui_row"></property>
|
||||
<property name="best_size"></property>
|
||||
<property name="bg"></property>
|
||||
<property name="caption"></property>
|
||||
<property name="caption_visible">1</property>
|
||||
<property name="center_pane">0</property>
|
||||
<property name="checked">0</property>
|
||||
<property name="close_button">1</property>
|
||||
<property name="context_help"></property>
|
||||
<property name="context_menu">1</property>
|
||||
<property name="default_pane">0</property>
|
||||
<property name="dock">Dock</property>
|
||||
<property name="dock_fixed">0</property>
|
||||
<property name="docking">Left</property>
|
||||
<property name="drag_accept_files">0</property>
|
||||
<property name="enabled">1</property>
|
||||
<property name="fg"></property>
|
||||
<property name="floatable">1</property>
|
||||
<property name="font"></property>
|
||||
<property name="gripper">0</property>
|
||||
<property name="hidden">0</property>
|
||||
<property name="id">wxID_ANY</property>
|
||||
<property name="label">Common to all units</property>
|
||||
<property name="max_size"></property>
|
||||
<property name="maximize_button">0</property>
|
||||
<property name="maximum_size"></property>
|
||||
<property name="min_size"></property>
|
||||
<property name="minimize_button">0</property>
|
||||
<property name="minimum_size"></property>
|
||||
<property name="moveable">1</property>
|
||||
<property name="name">m_commonToAllUnits</property>
|
||||
<property name="pane_border">1</property>
|
||||
<property name="pane_position"></property>
|
||||
<property name="pane_size"></property>
|
||||
<property name="permission">protected</property>
|
||||
<property name="pin_button">1</property>
|
||||
<property name="pos"></property>
|
||||
<property name="resize">Resizable</property>
|
||||
<property name="show">1</property>
|
||||
<property name="size"></property>
|
||||
<property name="style"></property>
|
||||
<property name="subclass"></property>
|
||||
<property name="toolbar_pane">0</property>
|
||||
<property name="tooltip"></property>
|
||||
<property name="validator_data_type"></property>
|
||||
<property name="validator_style">wxFILTER_NONE</property>
|
||||
<property name="validator_type">wxDefaultValidator</property>
|
||||
<property name="validator_variable"></property>
|
||||
<property name="window_extra_style"></property>
|
||||
<property name="window_name"></property>
|
||||
<property name="window_style"></property>
|
||||
</object>
|
||||
</object>
|
||||
<object class="sizeritem" expanded="true">
|
||||
<property name="border">5</property>
|
||||
<property name="flag">wxEXPAND</property>
|
||||
<property name="proportion">1</property>
|
||||
<object class="spacer" expanded="true">
|
||||
<property name="height">0</property>
|
||||
<property name="permission">protected</property>
|
||||
<property name="width">0</property>
|
||||
</object>
|
||||
</object>
|
||||
<object class="sizeritem" expanded="true">
|
||||
<property name="border">5</property>
|
||||
<property name="flag">wxEXPAND</property>
|
||||
<property name="proportion">1</property>
|
||||
<object class="spacer" expanded="true">
|
||||
<property name="height">0</property>
|
||||
<property name="permission">protected</property>
|
||||
<property name="width">0</property>
|
||||
</object>
|
||||
</object>
|
||||
<object class="sizeritem" expanded="true">
|
||||
<property name="border">5</property>
|
||||
<property name="flag">wxALL</property>
|
||||
<property name="proportion">0</property>
|
||||
<object class="wxCheckBox" expanded="true">
|
||||
<property name="BottomDockable">1</property>
|
||||
<property name="LeftDockable">1</property>
|
||||
<property name="RightDockable">1</property>
|
||||
<property name="TopDockable">1</property>
|
||||
<property name="aui_layer"></property>
|
||||
<property name="aui_name"></property>
|
||||
<property name="aui_position"></property>
|
||||
<property name="aui_row"></property>
|
||||
<property name="best_size"></property>
|
||||
<property name="bg"></property>
|
||||
<property name="caption"></property>
|
||||
<property name="caption_visible">1</property>
|
||||
<property name="center_pane">0</property>
|
||||
<property name="checked">0</property>
|
||||
<property name="close_button">1</property>
|
||||
<property name="context_help"></property>
|
||||
<property name="context_menu">1</property>
|
||||
<property name="default_pane">0</property>
|
||||
<property name="dock">Dock</property>
|
||||
<property name="dock_fixed">0</property>
|
||||
<property name="docking">Left</property>
|
||||
<property name="drag_accept_files">0</property>
|
||||
<property name="enabled">1</property>
|
||||
<property name="fg"></property>
|
||||
<property name="floatable">1</property>
|
||||
<property name="font"></property>
|
||||
<property name="gripper">0</property>
|
||||
<property name="hidden">0</property>
|
||||
<property name="id">wxID_ANY</property>
|
||||
<property name="label">Common to all body styles</property>
|
||||
<property name="max_size"></property>
|
||||
<property name="maximize_button">0</property>
|
||||
<property name="maximum_size"></property>
|
||||
<property name="min_size"></property>
|
||||
<property name="minimize_button">0</property>
|
||||
<property name="minimum_size"></property>
|
||||
<property name="moveable">1</property>
|
||||
<property name="name">m_commonToAllBodyStyles</property>
|
||||
<property name="pane_border">1</property>
|
||||
<property name="pane_position"></property>
|
||||
<property name="pane_size"></property>
|
||||
<property name="permission">protected</property>
|
||||
<property name="pin_button">1</property>
|
||||
<property name="pos"></property>
|
||||
<property name="resize">Resizable</property>
|
||||
<property name="show">1</property>
|
||||
<property name="size"></property>
|
||||
<property name="style"></property>
|
||||
<property name="subclass"></property>
|
||||
<property name="toolbar_pane">0</property>
|
||||
<property name="tooltip"></property>
|
||||
<property name="validator_data_type"></property>
|
||||
<property name="validator_style">wxFILTER_NONE</property>
|
||||
<property name="validator_type">wxDefaultValidator</property>
|
||||
<property name="validator_variable"></property>
|
||||
<property name="window_extra_style"></property>
|
||||
<property name="window_name"></property>
|
||||
<property name="window_style"></property>
|
||||
</object>
|
||||
</object>
|
||||
</object>
|
||||
</object>
|
||||
<object class="sizeritem" expanded="true">
|
||||
<property name="border">5</property>
|
||||
<property name="flag">wxALL|wxEXPAND</property>
|
||||
|
@ -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;
|
||||
|
@ -27,9 +27,8 @@
|
||||
|
||||
#include <lib_symbol.h>
|
||||
#include <lib_shape.h>
|
||||
#include <lib_text.h>
|
||||
#include <sch_text.h>
|
||||
#include <memory>
|
||||
#include <tuple>
|
||||
|
||||
|
||||
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<LIB_TEXT> textItem = std::make_unique<LIB_TEXT>( m_symbol );
|
||||
auto textItem = std::make_unique<SCH_TEXT>( 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 ) );
|
||||
}
|
||||
|
@ -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 )
|
||||
|
@ -45,7 +45,7 @@ class TEST_LIB_SYMBOL_FIXTURE;
|
||||
|
||||
typedef std::shared_ptr<LIB_SYMBOL> LIB_SYMBOL_SPTR; ///< shared pointer to LIB_SYMBOL
|
||||
typedef std::weak_ptr<LIB_SYMBOL> LIB_SYMBOL_REF; ///< weak pointer to LIB_SYMBOL
|
||||
typedef MULTIVECTOR<SCH_ITEM, SCH_FIELD_T, LIB_PIN_T> LIB_ITEMS_CONTAINER;
|
||||
typedef MULTIVECTOR<SCH_ITEM, SCH_TEXT_T, LIB_PIN_T> LIB_ITEMS_CONTAINER;
|
||||
typedef LIB_ITEMS_CONTAINER::ITEM_PTR_VECTOR LIB_ITEMS;
|
||||
|
||||
|
||||
|
@ -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 <common.h>
|
||||
#include <font/font.h>
|
||||
#include <sch_draw_panel.h>
|
||||
#include <plotters/plotter.h>
|
||||
#include <trigo.h>
|
||||
#include <base_units.h>
|
||||
#include <widgets/msgpanel.h>
|
||||
#include <bitmaps.h>
|
||||
#include <eda_draw_frame.h>
|
||||
#include <general.h>
|
||||
#include <transform.h>
|
||||
#include <settings/color_settings.h>
|
||||
#include <lib_text.h>
|
||||
#include <default_values.h> // For some default values
|
||||
#include <string_utils.h>
|
||||
|
||||
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<MSG_PANEL_ITEM>& 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<const LIB_TEXT&>( 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<const LIB_TEXT&>( 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<LIB_TEXT, SCH_ITEM> );
|
||||
propMgr.AddTypeCast( new TYPE_CAST<LIB_TEXT, EDA_TEXT> );
|
||||
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;
|
@ -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 <eda_text.h>
|
||||
#include <sch_item.h>
|
||||
|
||||
|
||||
/**
|
||||
* 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<MSG_PANEL_ITEM>& 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
|
@ -40,7 +40,6 @@
|
||||
#include <lib_shape.h>
|
||||
#include <lib_id.h>
|
||||
#include <lib_pin.h>
|
||||
#include <lib_text.h>
|
||||
#include <lib_textbox.h>
|
||||
|
||||
#include <sch_bitmap.h>
|
||||
@ -1521,7 +1520,7 @@ void SCH_IO_ALTIUM::ParseLabel( const std::map<wxString, wxString>& 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<wxString, wxString>& 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<int>( elem.fontId );
|
||||
size_t fontId = elem.fontId;
|
||||
|
||||
if( m_altiumSheet && fontId > 0 && fontId <= m_altiumSheet->fonts.size() )
|
||||
{
|
||||
|
@ -31,7 +31,6 @@
|
||||
#include <core/kicad_algo.h>
|
||||
#include <eda_text.h>
|
||||
#include <lib_shape.h>
|
||||
#include <lib_text.h>
|
||||
#include <macros.h>
|
||||
#include <progress_reporter.h>
|
||||
#include <string_utils.h>
|
||||
@ -1696,9 +1695,9 @@ const LIB_SYMBOL* CADSTAR_SCH_ARCHIVE_LOADER::loadSymdef( const SYMDEF_ID& aSymd
|
||||
for( std::pair<TEXT_ID, TEXT> textPair : csSym.Texts )
|
||||
{
|
||||
TEXT csText = textPair.second;
|
||||
VECTOR2I pos = getKiCadLibraryPoint( csText.Position, csSym.Origin );
|
||||
auto libtext = std::make_unique<SCH_TEXT>( pos, csText.Text, LAYER_DEVICE );
|
||||
|
||||
std::unique_ptr<LIB_TEXT> libtext = std::make_unique<LIB_TEXT>( 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<LIB_TEXT*>( libtext->Duplicate() );
|
||||
SCH_TEXT* textLine = static_cast<SCH_TEXT*>( 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<EDA_ITEM*>( 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 SCH_LABEL_T:
|
||||
case SCH_GLOBAL_LABEL_T:
|
||||
case SCH_HIER_LABEL_T:
|
||||
case SCH_SHEET_PIN_T:
|
||||
static_cast<SCH_LABEL_BASE*>( aKiCadTextItem )->SetSpinStyle( spin );
|
||||
return;
|
||||
|
||||
default:
|
||||
else if( SCH_LABEL_BASE* label = dynamic_cast<SCH_LABEL_BASE*>( aKiCadTextItem ) )
|
||||
{
|
||||
// We don't want to change position of net labels as that would break connectivity
|
||||
label->SetSpinStyle( spin );
|
||||
}
|
||||
else
|
||||
{
|
||||
wxFAIL_MSG( "Unexpected item type" );
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@ -3246,9 +3238,9 @@ LIB_SYMBOL* CADSTAR_SCH_ARCHIVE_LOADER::getScaledLibPart( const LIB_SYMBOL* aSym
|
||||
break;
|
||||
}
|
||||
|
||||
case KICAD_T::LIB_TEXT_T:
|
||||
case KICAD_T::SCH_TEXT_T:
|
||||
{
|
||||
LIB_TEXT& txt = static_cast<LIB_TEXT&>( item );
|
||||
SCH_TEXT& txt = static_cast<SCH_TEXT&>( item );
|
||||
|
||||
txt.SetPosition( scalePt( txt.GetPosition() ) );
|
||||
txt.SetTextSize( scaleSize( txt.GetTextSize() ) );
|
||||
|
@ -43,7 +43,6 @@
|
||||
#include <lib_shape.h>
|
||||
#include <lib_id.h>
|
||||
#include <lib_pin.h>
|
||||
#include <lib_text.h>
|
||||
#include <project.h>
|
||||
#include <project_sch.h>
|
||||
#include <sch_bus_entry.h>
|
||||
@ -2224,8 +2223,7 @@ bool SCH_IO_EAGLE::loadSymbol( wxXmlNode* aSymbolNode, std::unique_ptr<LIB_SYMBO
|
||||
}
|
||||
else if( nodeName == wxT( "text" ) )
|
||||
{
|
||||
std::unique_ptr<LIB_TEXT> libtext( loadSymbolText( aSymbol, currentNode,
|
||||
aGateNumber ) );
|
||||
std::unique_ptr<SCH_TEXT> libtext( loadSymbolText( currentNode, aGateNumber ) );
|
||||
|
||||
if( libtext->GetText() == wxT( "${REFERENCE}" ) )
|
||||
{
|
||||
@ -2515,15 +2513,10 @@ LIB_PIN* SCH_IO_EAGLE::loadPin( std::unique_ptr<LIB_SYMBOL>& aSymbol, wxXmlNode*
|
||||
}
|
||||
|
||||
|
||||
LIB_TEXT* SCH_IO_EAGLE::loadSymbolText( std::unique_ptr<LIB_SYMBOL>& aSymbol,
|
||||
wxXmlNode* aLibText, int aGateNumber )
|
||||
SCH_TEXT* SCH_IO_EAGLE::loadSymbolText( wxXmlNode* aLibText, int aGateNumber )
|
||||
{
|
||||
std::unique_ptr<LIB_TEXT> libtext = std::make_unique<LIB_TEXT>( aSymbol.get() );
|
||||
ETEXT etext( aLibText );
|
||||
|
||||
libtext->SetUnit( aGateNumber );
|
||||
libtext->SetPosition( VECTOR2I( etext.x.ToSchUnits(), etext.y.ToSchUnits() ) );
|
||||
|
||||
ETEXT etext( aLibText );
|
||||
VECTOR2I pos( etext.x.ToSchUnits(), etext.y.ToSchUnits() );
|
||||
const wxString& eagleText = aLibText->GetNodeContent();
|
||||
wxString adjustedText;
|
||||
wxStringTokenizer tokenizer( eagleText, "\r\n" );
|
||||
@ -2539,7 +2532,12 @@ LIB_TEXT* SCH_IO_EAGLE::loadSymbolText( std::unique_ptr<LIB_SYMBOL>& aSymbol,
|
||||
adjustedText += tmp;
|
||||
}
|
||||
|
||||
libtext->SetText( adjustedText.IsEmpty() ? wxString( wxT( "~" ) ) : adjustedText );
|
||||
if( adjustedText.IsEmpty() )
|
||||
adjustedText = wxT( "~" );
|
||||
|
||||
auto libtext = std::make_unique<SCH_TEXT>( pos, adjustedText, LAYER_DEVICE );
|
||||
|
||||
libtext->SetUnit( aGateNumber );
|
||||
loadTextAttributes( libtext.get(), etext );
|
||||
|
||||
return libtext.release();
|
||||
@ -2599,9 +2597,8 @@ void SCH_IO_EAGLE::loadSymbolFrame( wxXmlNode* aFrameNode, std::vector<SCH_ITEM*
|
||||
|
||||
for( i = 0; i < eframe.rows; i++ )
|
||||
{
|
||||
LIB_TEXT* legendText = new LIB_TEXT( nullptr );
|
||||
legendText->SetPosition( VECTOR2I( legendPosX, KiROUND( legendPosY ) ) );
|
||||
legendText->SetText( wxString( legendChar ) );
|
||||
SCH_TEXT* legendText = new SCH_TEXT( VECTOR2I( legendPosX, KiROUND( legendPosY ) ),
|
||||
wxString( legendChar ), LAYER_DEVICE );
|
||||
legendText->SetTextSize( VECTOR2I( schIUScale.MilsToIU( 90 ),
|
||||
schIUScale.MilsToIU( 100 ) ) );
|
||||
aItems.push_back( legendText );
|
||||
@ -2640,9 +2637,8 @@ void SCH_IO_EAGLE::loadSymbolFrame( wxXmlNode* aFrameNode, std::vector<SCH_ITEM*
|
||||
|
||||
for( i = 0; i < eframe.rows; i++ )
|
||||
{
|
||||
LIB_TEXT* legendText = new LIB_TEXT( nullptr );
|
||||
legendText->SetPosition( VECTOR2I( legendPosX, KiROUND( legendPosY ) ) );
|
||||
legendText->SetText( wxString( legendChar ) );
|
||||
SCH_TEXT* legendText = new SCH_TEXT( VECTOR2I( legendPosX, KiROUND( legendPosY ) ),
|
||||
wxString( legendChar ), LAYER_DEVICE );
|
||||
legendText->SetTextSize( VECTOR2I( schIUScale.MilsToIU( 90 ),
|
||||
schIUScale.MilsToIU( 100 ) ) );
|
||||
aItems.push_back( legendText );
|
||||
@ -2681,9 +2677,8 @@ void SCH_IO_EAGLE::loadSymbolFrame( wxXmlNode* aFrameNode, std::vector<SCH_ITEM*
|
||||
|
||||
for( i = 0; i < eframe.columns; i++ )
|
||||
{
|
||||
LIB_TEXT* legendText = new LIB_TEXT( nullptr );
|
||||
legendText->SetPosition( VECTOR2I( KiROUND( legendPosX ), legendPosY ) );
|
||||
legendText->SetText( wxString( legendChar ) );
|
||||
SCH_TEXT* legendText = new SCH_TEXT( VECTOR2I( KiROUND( legendPosX ), legendPosY ),
|
||||
wxString( legendChar ), LAYER_DEVICE );
|
||||
legendText->SetTextSize( VECTOR2I( schIUScale.MilsToIU( 90 ),
|
||||
schIUScale.MilsToIU( 100 ) ) );
|
||||
aItems.push_back( legendText );
|
||||
@ -2722,9 +2717,8 @@ void SCH_IO_EAGLE::loadSymbolFrame( wxXmlNode* aFrameNode, std::vector<SCH_ITEM*
|
||||
|
||||
for( i = 0; i < eframe.columns; i++ )
|
||||
{
|
||||
LIB_TEXT* legendText = new LIB_TEXT( nullptr );
|
||||
legendText->SetPosition( VECTOR2I( KiROUND( legendPosX ), legendPosY ) );
|
||||
legendText->SetText( wxString( legendChar ) );
|
||||
SCH_TEXT* legendText = new SCH_TEXT( VECTOR2I( KiROUND( legendPosX ), legendPosY ),
|
||||
wxString( legendChar ), LAYER_DEVICE );
|
||||
legendText->SetTextSize( VECTOR2I( schIUScale.MilsToIU( 90 ),
|
||||
schIUScale.MilsToIU( 100 ) ) );
|
||||
aItems.push_back( legendText );
|
||||
@ -2781,7 +2775,7 @@ void SCH_IO_EAGLE::loadTextAttributes( EDA_TEXT* aText, const ETEXT& aAttribs )
|
||||
}
|
||||
|
||||
|
||||
void SCH_IO_EAGLE::loadFieldAttributes( SCH_FIELD* aField, const LIB_TEXT* aText ) const
|
||||
void SCH_IO_EAGLE::loadFieldAttributes( SCH_FIELD* aField, const SCH_TEXT* aText ) const
|
||||
{
|
||||
aField->SetTextPos( aText->GetPosition() );
|
||||
aField->SetTextSize( aText->GetTextSize() );
|
||||
|
@ -166,12 +166,11 @@ private:
|
||||
int aGateNumber );
|
||||
LIB_PIN* loadPin( std::unique_ptr<LIB_SYMBOL>& aSymbol, wxXmlNode*, EPIN* epin,
|
||||
int aGateNumber );
|
||||
LIB_TEXT* loadSymbolText( std::unique_ptr<LIB_SYMBOL>& aSymbol, wxXmlNode* aLibText,
|
||||
int aGateNumber );
|
||||
SCH_TEXT* loadSymbolText( wxXmlNode* aLibText, int aGateNumber );
|
||||
void loadSymbolFrame( wxXmlNode* aFrameNode, std::vector<SCH_ITEM*>& aLines );
|
||||
|
||||
void loadTextAttributes( EDA_TEXT* aText, const ETEXT& aAttribs ) const;
|
||||
void loadFieldAttributes( SCH_FIELD* aField, const LIB_TEXT* aText ) const;
|
||||
void loadFieldAttributes( SCH_FIELD* aField, const SCH_TEXT* aText ) const;
|
||||
|
||||
///< Move net labels that are detached from any wire to the nearest wire
|
||||
void adjustNetLabels();
|
||||
|
@ -30,7 +30,6 @@
|
||||
#include <sch_sheet_pin.h>
|
||||
#include <sch_line.h>
|
||||
#include <lib_shape.h>
|
||||
#include <lib_text.h>
|
||||
#include <sch_no_connect.h>
|
||||
#include <sch_label.h>
|
||||
#include <sch_junction.h>
|
||||
@ -899,20 +898,21 @@ void SCH_EASYEDA_PARSER::ParseSymbolShapes( LIB_SYMBOL* aSymbol
|
||||
if( textType == wxS( "P" ) )
|
||||
{
|
||||
textItem = &aSymbol->GetReferenceField();
|
||||
textItem->SetTextPos( RelPosSym( pos ) );
|
||||
textItem->SetText( textStr );
|
||||
}
|
||||
else if( textType == wxS( "N" ) )
|
||||
{
|
||||
textItem = &aSymbol->GetValueField();
|
||||
textItem->SetTextPos( RelPosSym( pos ) );
|
||||
textItem->SetText( textStr );
|
||||
}
|
||||
else
|
||||
{
|
||||
textItem = new LIB_TEXT( aSymbol );
|
||||
textItem = new SCH_TEXT( RelPosSym( pos ), textStr, LAYER_DEVICE );
|
||||
added = true;
|
||||
}
|
||||
|
||||
textItem->SetTextPos( RelPosSym( pos ) );
|
||||
textItem->SetText( textStr );
|
||||
|
||||
textItem->SetTextAngleDegrees( ( 360 - angle ) % 360 );
|
||||
textItem->SetVertJustify( GR_TEXT_V_ALIGN_TOP );
|
||||
|
||||
|
@ -34,7 +34,6 @@
|
||||
#include <sch_line.h>
|
||||
#include <sch_bitmap.h>
|
||||
#include <lib_shape.h>
|
||||
#include <lib_text.h>
|
||||
#include <sch_no_connect.h>
|
||||
#include <sch_label.h>
|
||||
#include <sch_junction.h>
|
||||
@ -513,14 +512,11 @@ EASYEDAPRO::SYM_INFO SCH_EASYEDAPRO_PARSER::ParseSymbol( const std::vector<nlohm
|
||||
wxString textStr = line.at( 5 );
|
||||
wxString fontStyleStr = line.at( 6 );
|
||||
|
||||
std::unique_ptr<LIB_TEXT> text = std::make_unique<LIB_TEXT>( ksymbol );
|
||||
|
||||
text->SetPosition( ScalePosSym( pos ) );
|
||||
text->SetText( UnescapeHTML( textStr ) );
|
||||
auto text = std::make_unique<SCH_TEXT>( ScalePosSym( pos ), UnescapeHTML( textStr ),
|
||||
LAYER_DEVICE );
|
||||
|
||||
text->SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
|
||||
text->SetVertJustify( GR_TEXT_V_ALIGN_TOP );
|
||||
|
||||
text->SetTextAngleDegrees( angle );
|
||||
|
||||
text->SetUnit( currentUnit );
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user