2014-10-21 15:48:00 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2020-01-23 20:45:51 +00:00
|
|
|
* Copyright (C) 2009 Wayne Stambaugh <stambaughw@gmail.com>
|
2021-06-14 18:00:08 +00:00
|
|
|
* Copyright (C) 2016-2021 KiCad Developers, see AUTHORS.txt for contributors.
|
2014-10-21 15:48:00 +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
|
|
|
|
*/
|
|
|
|
|
2020-10-06 21:25:37 +00:00
|
|
|
#include <default_values.h>
|
2021-06-14 18:00:08 +00:00
|
|
|
#include <dialog_lib_new_symbol.h>
|
2020-10-06 21:25:37 +00:00
|
|
|
#include <eda_draw_frame.h>
|
2016-08-19 16:42:39 +00:00
|
|
|
#include <sch_validators.h>
|
|
|
|
#include <template_fieldnames.h>
|
2013-05-26 04:36:44 +00:00
|
|
|
|
2021-06-14 18:00:08 +00:00
|
|
|
DIALOG_LIB_NEW_SYMBOL::DIALOG_LIB_NEW_SYMBOL( EDA_DRAW_FRAME* aParent,
|
|
|
|
const wxArrayString* aRootSymbolNames ) :
|
|
|
|
DIALOG_LIB_NEW_SYMBOL_BASE( dynamic_cast<wxWindow*>( aParent ) ),
|
2020-01-23 20:45:51 +00:00
|
|
|
m_pinTextPosition( aParent, m_staticPinTextPositionLabel, m_textPinTextPosition,
|
|
|
|
m_staticPinTextPositionUnits, true )
|
2013-05-26 04:36:44 +00:00
|
|
|
{
|
2019-11-06 19:15:42 +00:00
|
|
|
if( aRootSymbolNames && aRootSymbolNames->GetCount() )
|
2021-07-28 17:36:13 +00:00
|
|
|
{
|
|
|
|
wxArrayString escapedNames;
|
|
|
|
|
|
|
|
for( const wxString& name : *aRootSymbolNames )
|
|
|
|
escapedNames.Add( UnescapeString( name ) );
|
|
|
|
|
|
|
|
m_comboInheritanceSelect->Append( escapedNames );
|
|
|
|
}
|
2019-11-06 19:15:42 +00:00
|
|
|
|
2020-11-12 21:31:41 +00:00
|
|
|
m_textName->SetValidator( SCH_FIELD_VALIDATOR( true, VALUE_FIELD ) );
|
|
|
|
m_textReference->SetValidator( SCH_FIELD_VALIDATOR( true, REFERENCE_FIELD ) );
|
2016-08-19 16:42:39 +00:00
|
|
|
|
2020-10-06 21:25:37 +00:00
|
|
|
m_pinTextPosition.SetValue( Mils2iu( DEFAULT_PIN_NAME_OFFSET ) );
|
2020-01-23 20:45:51 +00:00
|
|
|
|
2013-12-08 04:46:25 +00:00
|
|
|
// initial focus should be on first editable field.
|
|
|
|
m_textName->SetFocus();
|
|
|
|
|
2021-11-16 19:39:58 +00:00
|
|
|
SetupStandardButtons();
|
2016-07-18 07:04:13 +00:00
|
|
|
|
|
|
|
// Now all widgets have the size fixed, call FinishDialogSettings
|
2020-11-16 11:16:44 +00:00
|
|
|
finishDialogSettings();
|
2013-05-26 04:36:44 +00:00
|
|
|
}
|
2019-11-06 19:15:42 +00:00
|
|
|
|
|
|
|
|
2021-06-14 18:00:08 +00:00
|
|
|
void DIALOG_LIB_NEW_SYMBOL::OnParentSymbolSelect( wxCommandEvent& aEvent )
|
2019-11-06 19:15:42 +00:00
|
|
|
{
|
|
|
|
syncControls( !m_comboInheritanceSelect->GetValue().IsEmpty() );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-06-14 18:00:08 +00:00
|
|
|
void DIALOG_LIB_NEW_SYMBOL::syncControls( bool aIsDerivedPart )
|
2019-11-06 19:15:42 +00:00
|
|
|
{
|
|
|
|
m_staticTextDes->Enable( !aIsDerivedPart );
|
|
|
|
m_textReference->Enable( !aIsDerivedPart );
|
|
|
|
m_staticTextUnits->Enable( !aIsDerivedPart );
|
|
|
|
m_spinPartCount->Enable( !aIsDerivedPart );
|
2022-02-06 13:23:08 +00:00
|
|
|
m_checkUnitsInterchangeable->Enable( !aIsDerivedPart );
|
2019-11-06 19:15:42 +00:00
|
|
|
m_checkHasConversion->Enable( !aIsDerivedPart );
|
|
|
|
m_checkIsPowerSymbol->Enable( !aIsDerivedPart );
|
2020-09-09 13:03:37 +00:00
|
|
|
m_excludeFromBomCheckBox->Enable( !aIsDerivedPart );
|
|
|
|
m_excludeFromBoardCheckBox->Enable( !aIsDerivedPart );
|
2020-01-23 20:45:51 +00:00
|
|
|
m_staticPinTextPositionLabel->Enable( !aIsDerivedPart );
|
|
|
|
m_textPinTextPosition->Enable( !aIsDerivedPart );
|
|
|
|
m_staticPinTextPositionUnits->Enable( !aIsDerivedPart );
|
2019-11-06 19:15:42 +00:00
|
|
|
m_checkShowPinNumber->Enable( !aIsDerivedPart );
|
|
|
|
m_checkShowPinName->Enable( !aIsDerivedPart );
|
|
|
|
m_checkShowPinNameInside->Enable( !aIsDerivedPart );
|
|
|
|
}
|
2020-09-09 13:03:37 +00:00
|
|
|
|
|
|
|
|
2021-06-14 18:00:08 +00:00
|
|
|
void DIALOG_LIB_NEW_SYMBOL::onPowerCheckBox( wxCommandEvent& aEvent )
|
2020-09-09 13:03:37 +00:00
|
|
|
{
|
|
|
|
if( m_checkIsPowerSymbol->IsChecked() )
|
|
|
|
{
|
|
|
|
m_excludeFromBomCheckBox->SetValue( true );
|
|
|
|
m_excludeFromBoardCheckBox->SetValue( true );
|
|
|
|
m_excludeFromBomCheckBox->Enable( false );
|
|
|
|
m_excludeFromBoardCheckBox->Enable( false );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_excludeFromBomCheckBox->Enable( true );
|
|
|
|
m_excludeFromBoardCheckBox->Enable( true );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|