2011-12-08 15:45:01 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2013-11-18 17:52:18 +00:00
|
|
|
* Copyright (C) 2013 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
|
|
|
* Copyright (C) 2013 Wayne Stambaugh <stambaughw@verizon.net>
|
2020-05-27 22:28:36 +00:00
|
|
|
* Copyright (C) 1992-2020 KiCad Developers, see AUTHORS.txt for contributors.
|
2011-12-08 15:45:01 +00:00
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
|
2018-01-30 10:49:51 +00:00
|
|
|
#include <sch_edit_frame.h>
|
2012-04-13 18:51:24 +00:00
|
|
|
#include <base_units.h>
|
2019-05-21 02:52:39 +00:00
|
|
|
#include <sch_validators.h>
|
2019-06-19 10:31:21 +00:00
|
|
|
#include <tool/tool_manager.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <general.h>
|
2019-05-31 12:15:25 +00:00
|
|
|
#include <gr_text.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <confirm.h>
|
2020-04-06 13:06:57 +00:00
|
|
|
#include <sch_component.h>
|
|
|
|
#include <sch_reference_list.h>
|
2020-05-13 02:00:37 +00:00
|
|
|
#include <schematic.h>
|
2018-02-03 09:09:53 +00:00
|
|
|
#include <widgets/unit_binder.h>
|
2020-09-05 16:00:29 +00:00
|
|
|
#include <html_messagebox.h>
|
2020-05-23 15:50:08 +00:00
|
|
|
#include <dialog_edit_label.h>
|
2018-10-19 11:28:34 +00:00
|
|
|
#include <kicad_string.h>
|
2019-06-19 10:31:21 +00:00
|
|
|
#include <tool/actions.h>
|
2020-05-27 22:28:36 +00:00
|
|
|
#include <scintilla_tricks.h>
|
2020-08-31 14:11:54 +00:00
|
|
|
#include <sch_iref.h>
|
2012-03-19 20:57:19 +00:00
|
|
|
|
|
|
|
class SCH_EDIT_FRAME;
|
|
|
|
class SCH_TEXT;
|
|
|
|
|
|
|
|
|
2012-09-28 17:47:41 +00:00
|
|
|
DIALOG_LABEL_EDITOR::DIALOG_LABEL_EDITOR( SCH_EDIT_FRAME* aParent, SCH_TEXT* aTextItem ) :
|
2018-02-03 09:09:53 +00:00
|
|
|
DIALOG_LABEL_EDITOR_BASE( aParent ),
|
2019-03-11 21:32:05 +00:00
|
|
|
m_textSize( aParent, m_textSizeLabel, m_textSizeCtrl, m_textSizeUnits, false ),
|
2020-05-27 22:28:36 +00:00
|
|
|
m_netNameValidator( true ),
|
2020-09-05 16:00:29 +00:00
|
|
|
m_scintillaTricks( nullptr ),
|
|
|
|
m_helpWindow( nullptr )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2010-03-16 18:22:59 +00:00
|
|
|
m_Parent = aParent;
|
|
|
|
m_CurrentText = aTextItem;
|
2009-12-27 14:01:21 +00:00
|
|
|
|
2018-02-03 09:09:53 +00:00
|
|
|
switch( m_CurrentText->Type() )
|
|
|
|
{
|
2018-07-22 15:01:24 +00:00
|
|
|
case SCH_GLOBAL_LABEL_T: SetTitle( _( "Global Label Properties" ) ); break;
|
2019-05-21 02:52:39 +00:00
|
|
|
case SCH_HIER_LABEL_T: SetTitle( _( "Hierarchical Label Properties" ) ); break;
|
2018-07-22 15:01:24 +00:00
|
|
|
case SCH_LABEL_T: SetTitle( _( "Label Properties" ) ); break;
|
|
|
|
case SCH_SHEET_PIN_T: SetTitle( _( "Hierarchical Sheet Pin Properties" ) ); break;
|
|
|
|
default: SetTitle( _( "Text Properties" ) ); break;
|
2018-02-03 09:09:53 +00:00
|
|
|
}
|
|
|
|
|
2019-07-16 19:45:18 +00:00
|
|
|
m_valueMultiLine->SetEOLMode( wxSTC_EOL_LF );
|
2020-04-19 19:09:26 +00:00
|
|
|
|
2020-05-27 23:18:28 +00:00
|
|
|
m_scintillaTricks = new SCINTILLA_TRICKS( m_valueMultiLine, wxT( "()" ) );
|
2019-07-16 19:45:18 +00:00
|
|
|
|
2018-02-03 09:09:53 +00:00
|
|
|
if( m_CurrentText->IsMultilineAllowed() )
|
|
|
|
{
|
2018-06-27 13:21:26 +00:00
|
|
|
m_activeTextCtrl = m_valueMultiLine;
|
2019-07-09 11:19:27 +00:00
|
|
|
m_activeTextEntry = nullptr;
|
2018-06-27 13:21:26 +00:00
|
|
|
|
2020-01-23 17:12:50 +00:00
|
|
|
m_labelSingleLine->Show( false );
|
|
|
|
m_valueSingleLine->Show( false );
|
|
|
|
m_labelCombo->Show( false );
|
|
|
|
m_valueCombo->Show( false );
|
2018-06-27 13:21:26 +00:00
|
|
|
|
2018-07-22 15:01:24 +00:00
|
|
|
m_textEntrySizer->AddGrowableRow( 0 );
|
2018-06-27 13:21:26 +00:00
|
|
|
}
|
|
|
|
else if( m_CurrentText->Type() == SCH_GLOBAL_LABEL_T || m_CurrentText->Type() == SCH_LABEL_T )
|
|
|
|
{
|
|
|
|
m_activeTextCtrl = m_valueCombo;
|
|
|
|
m_activeTextEntry = m_valueCombo;
|
|
|
|
|
2018-07-22 15:01:24 +00:00
|
|
|
m_labelSingleLine->Show( false ); m_valueSingleLine->Show( false );
|
|
|
|
m_labelMultiLine->Show( false ); m_valueMultiLine->Show( false );
|
2019-05-21 02:52:39 +00:00
|
|
|
|
|
|
|
m_valueCombo->SetValidator( m_netNameValidator );
|
2018-02-03 09:09:53 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-06-27 13:21:26 +00:00
|
|
|
m_activeTextCtrl = m_valueSingleLine;
|
|
|
|
m_activeTextEntry = m_valueSingleLine;
|
|
|
|
|
2020-04-19 19:09:26 +00:00
|
|
|
m_labelCombo->Show( false );
|
|
|
|
m_valueCombo->Show( false );
|
|
|
|
m_labelMultiLine->Show( false );
|
|
|
|
m_valueMultiLine->Show( false );
|
2019-05-21 02:52:39 +00:00
|
|
|
|
|
|
|
if( m_CurrentText->Type() != SCH_TEXT_T )
|
|
|
|
m_valueSingleLine->SetValidator( m_netNameValidator );
|
2019-06-20 06:20:33 +00:00
|
|
|
|
|
|
|
m_valueCombo->SetValidator( m_netNameValidator );
|
2018-02-03 09:09:53 +00:00
|
|
|
}
|
|
|
|
|
2018-03-06 05:33:04 +00:00
|
|
|
SetInitialFocus( m_activeTextCtrl );
|
|
|
|
|
2018-02-03 09:09:53 +00:00
|
|
|
m_TextShape->Show( m_CurrentText->Type() == SCH_GLOBAL_LABEL_T ||
|
2019-04-15 23:56:41 +00:00
|
|
|
m_CurrentText->Type() == SCH_HIER_LABEL_T );
|
2018-02-03 09:09:53 +00:00
|
|
|
|
2020-05-05 19:25:38 +00:00
|
|
|
if( m_CurrentText->Type() == SCH_GLOBAL_LABEL_T )
|
|
|
|
{
|
|
|
|
wxFont infoFont = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT );
|
|
|
|
infoFont.SetSymbolicSize( wxFONTSIZE_X_SMALL );
|
2020-05-07 13:49:51 +00:00
|
|
|
m_note1->SetFont( infoFont );
|
|
|
|
m_note2->SetFont( infoFont );
|
2020-05-05 19:25:38 +00:00
|
|
|
}
|
|
|
|
else
|
2020-05-08 21:16:27 +00:00
|
|
|
{
|
|
|
|
m_note1->Show( false );
|
|
|
|
m_note2->Show( false );
|
|
|
|
}
|
2020-05-05 19:25:38 +00:00
|
|
|
|
2018-02-03 09:09:53 +00:00
|
|
|
m_sdbSizer1OK->SetDefault();
|
|
|
|
Layout();
|
2017-03-07 13:32:34 +00:00
|
|
|
|
2020-05-27 22:28:36 +00:00
|
|
|
m_valueMultiLine->Bind( wxEVT_STC_CHARADDED, &DIALOG_LABEL_EDITOR::onScintillaCharAdded, this );
|
2017-12-28 19:33:15 +00:00
|
|
|
|
2018-07-22 15:01:24 +00:00
|
|
|
// DIALOG_SHIM needs a unique hash_key because classname is not sufficient because the
|
|
|
|
// various versions have different controls so we want to store sizes for each version.
|
|
|
|
m_hash_key = TO_UTF8( GetTitle() );
|
|
|
|
|
|
|
|
|
2016-07-16 10:54:55 +00:00
|
|
|
// Now all widgets have the size fixed, call FinishDialogSettings
|
|
|
|
FinishDialogSettings();
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2009-02-09 20:27:16 +00:00
|
|
|
|
2017-12-28 19:33:15 +00:00
|
|
|
DIALOG_LABEL_EDITOR::~DIALOG_LABEL_EDITOR()
|
|
|
|
{
|
2020-05-27 22:28:36 +00:00
|
|
|
delete m_scintillaTricks;
|
2020-09-05 16:00:29 +00:00
|
|
|
|
|
|
|
if( m_helpWindow )
|
|
|
|
m_helpWindow->Destroy();
|
2017-12-28 19:33:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-02-03 09:09:53 +00:00
|
|
|
bool DIALOG_LABEL_EDITOR::TransferDataToWindow()
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2018-02-03 09:09:53 +00:00
|
|
|
if( !wxDialog::TransferDataToWindow() )
|
|
|
|
return false;
|
2013-08-13 23:04:41 +00:00
|
|
|
|
2020-04-06 13:06:57 +00:00
|
|
|
if( m_CurrentText->Type() == SCH_TEXT_T )
|
|
|
|
{
|
2020-07-29 17:02:39 +00:00
|
|
|
SCHEMATIC& schematic = m_Parent->Schematic();
|
|
|
|
|
2020-04-06 13:06:57 +00:00
|
|
|
// show text variable cross-references in a human-readable format
|
2020-07-29 17:02:39 +00:00
|
|
|
m_valueMultiLine->SetValue( schematic.ConvertKIIDsToRefs( m_CurrentText->GetText() ) );
|
2020-04-06 13:06:57 +00:00
|
|
|
}
|
2019-07-09 11:19:27 +00:00
|
|
|
else
|
2020-04-06 13:06:57 +00:00
|
|
|
{
|
|
|
|
// show control characters in a human-readable format
|
|
|
|
m_activeTextEntry->SetValue( UnescapeString( m_CurrentText->GetText() ) );
|
|
|
|
}
|
2018-06-27 13:21:26 +00:00
|
|
|
|
|
|
|
if( m_valueCombo->IsShown() )
|
|
|
|
{
|
|
|
|
// Load the combobox with the existing labels of the same type
|
2018-07-21 13:51:08 +00:00
|
|
|
std::set<wxString> existingLabels;
|
2020-05-13 02:00:37 +00:00
|
|
|
SCH_SCREENS allScreens( m_Parent->Schematic().Root() );
|
2018-06-27 13:21:26 +00:00
|
|
|
|
|
|
|
for( SCH_SCREEN* screen = allScreens.GetFirst(); screen; screen = allScreens.GetNext() )
|
2019-06-25 23:39:58 +00:00
|
|
|
{
|
2020-07-06 10:51:04 +00:00
|
|
|
for( SCH_ITEM* item : screen->Items().OfType( m_CurrentText->Type() ) )
|
2019-06-25 23:39:58 +00:00
|
|
|
{
|
|
|
|
auto textItem = static_cast<const SCH_TEXT*>( item );
|
|
|
|
existingLabels.insert( UnescapeString( textItem->GetText() ) );
|
|
|
|
}
|
|
|
|
}
|
2018-06-27 13:21:26 +00:00
|
|
|
|
2018-07-21 13:51:08 +00:00
|
|
|
wxArrayString existingLabelArray;
|
|
|
|
|
2019-12-05 15:20:59 +00:00
|
|
|
for( const wxString& label : existingLabels )
|
2018-07-21 13:51:08 +00:00
|
|
|
existingLabelArray.push_back( label );
|
|
|
|
|
|
|
|
// existingLabelArray.Sort();
|
|
|
|
m_valueCombo->Append( existingLabelArray );
|
2018-06-27 13:21:26 +00:00
|
|
|
}
|
2009-02-09 20:27:16 +00:00
|
|
|
|
2017-02-02 15:50:49 +00:00
|
|
|
// Set text options:
|
2020-01-08 19:07:55 +00:00
|
|
|
m_TextOrient->SetSelection( static_cast<int>( m_CurrentText->GetLabelSpinStyle() ) );
|
2018-02-04 19:11:12 +00:00
|
|
|
|
2020-01-08 19:07:55 +00:00
|
|
|
m_TextShape->SetSelection( static_cast<int>( m_CurrentText->GetShape() ) );
|
2008-03-20 01:50:21 +00:00
|
|
|
|
2008-12-19 20:40:08 +00:00
|
|
|
int style = 0;
|
2011-12-08 15:45:01 +00:00
|
|
|
|
2013-03-18 19:36:07 +00:00
|
|
|
if( m_CurrentText->IsItalic() )
|
2008-12-19 20:40:08 +00:00
|
|
|
style = 1;
|
2011-12-08 15:45:01 +00:00
|
|
|
|
2013-03-18 19:36:07 +00:00
|
|
|
if( m_CurrentText->IsBold() )
|
2008-12-19 20:40:08 +00:00
|
|
|
style += 2;
|
2009-02-09 20:27:16 +00:00
|
|
|
|
|
|
|
m_TextStyle->SetSelection( style );
|
2008-03-20 01:50:21 +00:00
|
|
|
|
2018-02-03 09:09:53 +00:00
|
|
|
m_textSize.SetValue( m_CurrentText->GetTextWidth() );
|
2008-12-20 17:28:25 +00:00
|
|
|
|
2018-02-03 09:09:53 +00:00
|
|
|
return true;
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2010-03-16 18:22:59 +00:00
|
|
|
|
2009-04-28 19:34:42 +00:00
|
|
|
/*!
|
2018-02-03 09:09:53 +00:00
|
|
|
* wxEVT_COMMAND_ENTER event handler for single-line control
|
2009-04-28 19:34:42 +00:00
|
|
|
*/
|
2012-09-28 17:47:41 +00:00
|
|
|
void DIALOG_LABEL_EDITOR::OnEnterKey( wxCommandEvent& aEvent )
|
2009-04-28 19:34:42 +00:00
|
|
|
{
|
2018-02-03 09:09:53 +00:00
|
|
|
wxPostEvent( this, wxCommandEvent( wxEVT_COMMAND_BUTTON_CLICKED, wxID_OK ) );
|
2009-04-28 19:34:42 +00:00
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2010-03-16 18:22:59 +00:00
|
|
|
|
2020-05-27 22:28:36 +00:00
|
|
|
void DIALOG_LABEL_EDITOR::onScintillaCharAdded( wxStyledTextEvent &aEvent )
|
2017-12-28 19:33:15 +00:00
|
|
|
{
|
2020-05-27 22:28:36 +00:00
|
|
|
wxStyledTextCtrl* te = m_valueMultiLine;
|
|
|
|
wxArrayString autocompleteTokens;
|
2020-05-29 17:52:51 +00:00
|
|
|
int text_pos = te->GetCurrentPos();
|
|
|
|
int start = te->WordStartPosition( text_pos, true );
|
2020-05-27 22:28:36 +00:00
|
|
|
wxString partial;
|
|
|
|
|
|
|
|
auto textVarRef =
|
|
|
|
[&]( int pos )
|
|
|
|
{
|
|
|
|
return pos >= 2 && te->GetCharAt( pos-2 ) == '$' && te->GetCharAt( pos-1 ) == '{';
|
|
|
|
};
|
|
|
|
|
|
|
|
// Check for cross-reference
|
|
|
|
if( start > 1 && te->GetCharAt( start-1 ) == ':' )
|
2017-12-28 19:33:15 +00:00
|
|
|
{
|
2020-05-27 22:28:36 +00:00
|
|
|
int refStart = te->WordStartPosition( start-1, true );
|
|
|
|
|
|
|
|
if( textVarRef( refStart ) )
|
2019-07-09 11:19:27 +00:00
|
|
|
{
|
2020-05-29 17:52:51 +00:00
|
|
|
partial = te->GetRange( start+1, text_pos );
|
2019-08-13 15:52:34 +00:00
|
|
|
|
2020-05-27 22:28:36 +00:00
|
|
|
wxString ref = te->GetRange( refStart, start-1 );
|
|
|
|
SCH_SHEET_LIST sheets = m_Parent->Schematic().GetSheets();
|
|
|
|
SCH_REFERENCE_LIST refs;
|
|
|
|
SCH_COMPONENT* refComponent = nullptr;
|
2019-08-13 15:52:34 +00:00
|
|
|
|
2020-05-27 22:28:36 +00:00
|
|
|
sheets.GetComponents( refs );
|
|
|
|
|
|
|
|
for( size_t jj = 0; jj < refs.GetCount(); jj++ )
|
|
|
|
{
|
|
|
|
if( refs[ jj ].GetComp()->GetRef( &refs[ jj ].GetSheetPath(), true ) == ref )
|
|
|
|
{
|
|
|
|
refComponent = refs[ jj ].GetComp();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( refComponent )
|
|
|
|
refComponent->GetContextualTextVars( &autocompleteTokens );
|
2019-07-09 11:19:27 +00:00
|
|
|
}
|
2017-12-28 19:33:15 +00:00
|
|
|
}
|
2020-05-27 22:28:36 +00:00
|
|
|
else if( textVarRef( start ) )
|
2019-07-09 11:19:27 +00:00
|
|
|
{
|
2020-05-29 17:52:51 +00:00
|
|
|
partial = te->GetTextRange( start, text_pos );
|
2020-05-27 22:28:36 +00:00
|
|
|
|
|
|
|
m_CurrentText->GetContextualTextVars( &autocompleteTokens );
|
|
|
|
|
2020-07-28 12:11:11 +00:00
|
|
|
SCHEMATIC* schematic = m_CurrentText->Schematic();
|
|
|
|
|
|
|
|
if( schematic && schematic->CurrentSheet().Last() )
|
|
|
|
schematic->CurrentSheet().Last()->GetContextualTextVars( &autocompleteTokens );
|
|
|
|
|
2020-05-27 22:28:36 +00:00
|
|
|
for( std::pair<wxString, wxString> entry : Prj().GetTextVars() )
|
|
|
|
autocompleteTokens.push_back( entry.first );
|
2017-12-28 19:33:15 +00:00
|
|
|
}
|
2020-05-27 22:28:36 +00:00
|
|
|
|
|
|
|
m_scintillaTricks->DoAutocomplete( partial, autocompleteTokens );
|
|
|
|
m_valueMultiLine->SetFocus();
|
2017-12-28 19:33:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-02-03 09:09:53 +00:00
|
|
|
bool DIALOG_LABEL_EDITOR::TransferDataFromWindow()
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2018-02-03 09:09:53 +00:00
|
|
|
if( !wxDialog::TransferDataFromWindow() )
|
|
|
|
return false;
|
2010-03-16 18:22:59 +00:00
|
|
|
|
2020-06-14 15:08:47 +00:00
|
|
|
// Don't allow text to disappear; it can be difficult to correct if you can't select it
|
|
|
|
if( !m_textSize.Validate( 0.01, 1000.0, EDA_UNITS::MILLIMETRES ) )
|
2018-11-29 18:59:38 +00:00
|
|
|
return false;
|
|
|
|
|
2009-12-27 14:01:21 +00:00
|
|
|
wxString text;
|
|
|
|
|
|
|
|
/* save old text in undo list if not already in edit */
|
2019-04-28 16:36:31 +00:00
|
|
|
if( m_CurrentText->GetEditFlags() == 0 )
|
2020-08-26 18:04:32 +00:00
|
|
|
m_Parent->SaveCopyInUndoList( m_Parent->GetScreen(), m_CurrentText, UNDO_REDO::CHANGED, false );
|
2009-12-27 14:01:21 +00:00
|
|
|
|
2019-02-17 17:18:14 +00:00
|
|
|
m_Parent->GetCanvas()->Refresh();
|
2009-12-27 14:01:21 +00:00
|
|
|
|
2019-06-08 15:32:49 +00:00
|
|
|
if( m_CurrentText->Type() == SCH_TEXT_T )
|
2020-04-06 13:06:57 +00:00
|
|
|
{
|
|
|
|
// convert any text variable cross-references to their UUIDs
|
2020-07-29 17:02:39 +00:00
|
|
|
text = m_Parent->Schematic().ConvertRefsToKIIDs( m_valueMultiLine->GetValue() );
|
2020-04-06 13:06:57 +00:00
|
|
|
}
|
2019-06-08 15:32:49 +00:00
|
|
|
else
|
2020-04-06 13:06:57 +00:00
|
|
|
{
|
|
|
|
// labels need escaping
|
2019-06-08 15:32:49 +00:00
|
|
|
text = EscapeString( m_activeTextEntry->GetValue(), CTX_NETNAME );
|
2020-04-06 13:06:57 +00:00
|
|
|
}
|
2011-12-08 15:45:01 +00:00
|
|
|
|
2009-12-27 14:01:21 +00:00
|
|
|
if( !text.IsEmpty() )
|
2013-03-18 19:36:07 +00:00
|
|
|
m_CurrentText->SetText( text );
|
2011-12-21 13:42:02 +00:00
|
|
|
else if( !m_CurrentText->IsNew() )
|
2012-10-13 18:33:58 +00:00
|
|
|
{
|
2009-12-27 14:01:21 +00:00
|
|
|
DisplayError( this, _( "Empty Text!" ) );
|
2018-02-03 09:09:53 +00:00
|
|
|
return false;
|
2012-10-13 18:33:58 +00:00
|
|
|
}
|
2009-12-27 14:01:21 +00:00
|
|
|
|
2020-03-29 01:12:29 +00:00
|
|
|
m_CurrentText->SetLabelSpinStyle( (LABEL_SPIN_STYLE::SPIN) m_TextOrient->GetSelection() );
|
2018-02-04 19:11:12 +00:00
|
|
|
|
2018-02-03 09:09:53 +00:00
|
|
|
m_CurrentText->SetTextSize( wxSize( m_textSize.GetValue(), m_textSize.GetValue() ) );
|
2011-12-08 15:45:01 +00:00
|
|
|
|
2009-12-27 14:01:21 +00:00
|
|
|
if( m_TextShape )
|
2020-03-29 01:12:29 +00:00
|
|
|
m_CurrentText->SetShape( (PINSHEETLABEL_SHAPE) m_TextShape->GetSelection() );
|
2009-12-27 14:01:21 +00:00
|
|
|
|
|
|
|
int style = m_TextStyle->GetSelection();
|
2011-12-08 15:45:01 +00:00
|
|
|
|
2013-03-18 19:36:07 +00:00
|
|
|
m_CurrentText->SetItalic( ( style & 1 ) );
|
2009-12-27 14:01:21 +00:00
|
|
|
|
|
|
|
if( ( style & 2 ) )
|
|
|
|
{
|
2013-03-18 19:36:07 +00:00
|
|
|
m_CurrentText->SetBold( true );
|
2020-04-14 12:25:00 +00:00
|
|
|
m_CurrentText->SetTextThickness( GetPenSizeForBold( m_CurrentText->GetTextWidth() ) );
|
2009-12-27 14:01:21 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-03-18 19:36:07 +00:00
|
|
|
m_CurrentText->SetBold( false );
|
2020-04-14 12:25:00 +00:00
|
|
|
m_CurrentText->SetTextThickness( 0 ); // Use default pen width
|
2009-12-27 14:01:21 +00:00
|
|
|
}
|
|
|
|
|
2020-08-10 11:40:58 +00:00
|
|
|
m_Parent->UpdateItem( m_CurrentText );
|
2018-10-18 09:50:43 +00:00
|
|
|
m_Parent->GetCanvas()->Refresh();
|
2010-03-16 18:22:59 +00:00
|
|
|
m_Parent->OnModify();
|
2009-12-27 14:01:21 +00:00
|
|
|
|
2020-08-31 14:11:54 +00:00
|
|
|
if( m_CurrentText->Type() == SCH_GLOBAL_LABEL_T )
|
|
|
|
{
|
|
|
|
SCH_GLOBALLABEL* label = static_cast<SCH_GLOBALLABEL*>( m_CurrentText );
|
|
|
|
SCH_IREF* iref = label->GetIref();
|
|
|
|
|
|
|
|
if( iref )
|
|
|
|
{
|
|
|
|
if( iref->GetBoundingBox().Intersects( label->GetBoundingBox() ) )
|
|
|
|
iref->PlaceAtDefaultPosition();
|
|
|
|
iref->CopyParentStyle();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-02-03 09:09:53 +00:00
|
|
|
return true;
|
2009-12-27 14:01:21 +00:00
|
|
|
}
|
2020-05-08 21:16:27 +00:00
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_LABEL_EDITOR::OnFormattingHelp( wxHyperlinkEvent& aEvent )
|
|
|
|
{
|
2020-09-05 16:00:29 +00:00
|
|
|
m_helpWindow = SCH_TEXT::ShowSyntaxHelp( this );
|
2020-05-08 21:16:27 +00:00
|
|
|
}
|