Separate initialization from data loading.

This commit is contained in:
Jeff Young 2025-08-11 18:29:20 +01:00
parent ac7ae87495
commit 92e139f64b
2 changed files with 16 additions and 9 deletions

View File

@ -44,6 +44,7 @@ DIALOG_LIB_NEW_SYMBOL::DIALOG_LIB_NEW_SYMBOL( EDA_DRAW_FRAME* aParent,
m_pinTextPosition( aParent, m_staticPinTextPositionLabel, m_textPinTextPosition, m_pinTextPosition( aParent, m_staticPinTextPositionLabel, m_textPinTextPosition,
m_staticPinTextPositionUnits, true ), m_staticPinTextPositionUnits, true ),
m_validator( std::move( aValidator ) ), m_validator( std::move( aValidator ) ),
m_inheritFromSymbolName( aInheritFromSymbolName ),
m_nameIsDefaulted( true ) m_nameIsDefaulted( true )
{ {
if( aSymbolNames.GetCount() ) if( aSymbolNames.GetCount() )
@ -54,20 +55,11 @@ DIALOG_LIB_NEW_SYMBOL::DIALOG_LIB_NEW_SYMBOL( EDA_DRAW_FRAME* aParent,
unescapedNames.Add( UnescapeString( name ) ); unescapedNames.Add( UnescapeString( name ) );
m_comboInheritanceSelect->SetStringList( unescapedNames ); m_comboInheritanceSelect->SetStringList( unescapedNames );
if( !aInheritFromSymbolName.IsEmpty() )
m_comboInheritanceSelect->SetSelectedString( UnescapeString( aInheritFromSymbolName ) );
} }
m_textName->SetValidator( FIELD_VALIDATOR( FIELD_T::VALUE ) ); m_textName->SetValidator( FIELD_VALIDATOR( FIELD_T::VALUE ) );
m_textReference->SetValidator( FIELD_VALIDATOR( FIELD_T::REFERENCE ) ); m_textReference->SetValidator( FIELD_VALIDATOR( FIELD_T::REFERENCE ) );
if( !aInheritFromSymbolName.IsEmpty() )
{
m_textName->ChangeValue( UnescapeString( getDerivativeName( aInheritFromSymbolName ) ) );
m_nameIsDefaulted = true;
}
m_pinTextPosition.SetValue( schIUScale.MilsToIU( DEFAULT_PIN_NAME_OFFSET ) ); m_pinTextPosition.SetValue( schIUScale.MilsToIU( DEFAULT_PIN_NAME_OFFSET ) );
m_comboInheritanceSelect->Connect( FILTERED_ITEM_SELECTED, m_comboInheritanceSelect->Connect( FILTERED_ITEM_SELECTED,
@ -112,6 +104,19 @@ DIALOG_LIB_NEW_SYMBOL::~DIALOG_LIB_NEW_SYMBOL()
nullptr, this ); nullptr, this );
} }
bool DIALOG_LIB_NEW_SYMBOL::TransferDataToWindow()
{
if( !m_inheritFromSymbolName.IsEmpty() )
{
m_comboInheritanceSelect->SetSelectedString( UnescapeString( m_inheritFromSymbolName ) );
m_textName->ChangeValue( UnescapeString( getDerivativeName( m_inheritFromSymbolName ) ) );
}
return true;
}
bool DIALOG_LIB_NEW_SYMBOL::TransferDataFromWindow() bool DIALOG_LIB_NEW_SYMBOL::TransferDataFromWindow()
{ {
return m_validator( GetName() ); return m_validator( GetName() );

View File

@ -106,6 +106,7 @@ public:
bool GetPinNameInside() { return m_checkShowPinNameInside->GetValue(); } bool GetPinNameInside() { return m_checkShowPinNameInside->GetValue(); }
protected: protected:
bool TransferDataToWindow() override;
bool TransferDataFromWindow() override; bool TransferDataFromWindow() override;
virtual void onPowerCheckBox( wxCommandEvent& aEvent ) override; virtual void onPowerCheckBox( wxCommandEvent& aEvent ) override;
@ -119,5 +120,6 @@ private:
private: private:
UNIT_BINDER m_pinTextPosition; UNIT_BINDER m_pinTextPosition;
std::function<bool( wxString newName )> m_validator; std::function<bool( wxString newName )> m_validator;
wxString m_inheritFromSymbolName;
bool m_nameIsDefaulted; bool m_nameIsDefaulted;
}; };