Commit e1412214 authored by charras's avatar charras

Eeschema, LibEdit: fixed undo not working after editing component properties

parent 6a383a83
......@@ -13,7 +13,8 @@
#include "general.h"
#include "protos.h"
#include "libeditfrm.h"
#include "class_libentry.h"
#include "class_library.h"
//#include "class_libentry.h"
#include "dialog_edit_component_in_lib.h"
......@@ -73,7 +74,7 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::Init( )
m_ButtonDeleteAllAlias->Enable( false );
/* Place list of alias names in listbox */
m_PartAliasList->Append( component->m_AliasList );
m_PartAliasListCtrl->Append( component->m_AliasList );
if( component->m_AliasList.GetCount() == 0 )
{
......@@ -97,3 +98,64 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::OnCancelClick( wxCommandEvent& event )
EndModal( wxID_CANCEL );
}
void DIALOG_EDIT_COMPONENT_IN_LIBRARY::InitPanelDoc()
{
CMP_LIB_ENTRY* entry;
LIB_COMPONENT* component = m_Parent->GetComponent();
CMP_LIBRARY* library = m_Parent->GetLibrary();
if( component == NULL )
return;
if( m_Parent->GetAliasName().IsEmpty() )
{
entry = component;
}
else
{
entry =
( CMP_LIB_ENTRY* ) library->FindAlias( m_Parent->GetAliasName() );
if( entry == NULL )
return;
}
m_DocCtrl->SetValue( entry->GetDescription() );
m_KeywordsCtrl->SetValue( entry->GetKeyWords() );
m_DocfileCtrl->SetValue( entry->GetDocFileName() );
}
/*
* create the basic panel for component properties editing
*/
void DIALOG_EDIT_COMPONENT_IN_LIBRARY::InitBasicPanel()
{
LIB_COMPONENT* component = m_Parent->GetComponent();
if( m_Parent->GetShowDeMorgan() )
m_AsConvertButt->SetValue( true );
/* Default values for a new component. */
if( component == NULL )
{
m_ShowPinNumButt->SetValue( true );
m_ShowPinNameButt->SetValue( true );
m_PinsNameInsideButt->SetValue( true );
m_SelNumberOfUnits->SetValue( 1 );
m_SetSkew->SetValue( 40 );
m_OptionPower->SetValue( false );
m_OptionPartsLocked->SetValue( false );
return;
}
m_ShowPinNumButt->SetValue( component->m_DrawPinNum );
m_ShowPinNameButt->SetValue( component->m_DrawPinName );
m_PinsNameInsideButt->SetValue( component->m_TextInside != 0 );
m_SelNumberOfUnits->SetValue( component->GetPartCount() );
m_SetSkew->SetValue( component->m_TextInside );
m_OptionPower->SetValue( component->isPower() );
m_OptionPartsLocked->SetValue( component->m_UnitSelectionLocked );
}
......@@ -118,8 +118,8 @@ DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE::DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE( wx
m_PanelDocBoxSizer->Add( m_staticTextDescription, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
m_Doc = new wxTextCtrl( m_PanelDoc, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
m_PanelDocBoxSizer->Add( m_Doc, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
m_DocCtrl = new wxTextCtrl( m_PanelDoc, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
m_PanelDocBoxSizer->Add( m_DocCtrl, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
m_staticTextKeywords = new wxStaticText( m_PanelDoc, wxID_ANY, _("Keywords:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextKeywords->Wrap( -1 );
......@@ -127,8 +127,8 @@ DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE::DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE( wx
m_PanelDocBoxSizer->Add( m_staticTextKeywords, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
m_Keywords = new wxTextCtrl( m_PanelDoc, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
m_PanelDocBoxSizer->Add( m_Keywords, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
m_KeywordsCtrl = new wxTextCtrl( m_PanelDoc, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
m_PanelDocBoxSizer->Add( m_KeywordsCtrl, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
m_staticTextDocFileName = new wxStaticText( m_PanelDoc, wxID_ANY, _("DocFileName:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextDocFileName->Wrap( -1 );
......@@ -136,8 +136,8 @@ DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE::DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE( wx
m_PanelDocBoxSizer->Add( m_staticTextDocFileName, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
m_Docfile = new wxTextCtrl( m_PanelDoc, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 400,-1 ), 0 );
m_PanelDocBoxSizer->Add( m_Docfile, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
m_DocfileCtrl = new wxTextCtrl( m_PanelDoc, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 400,-1 ), 0 );
m_PanelDocBoxSizer->Add( m_DocfileCtrl, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
wxBoxSizer* bSizerPaneldocbutts;
bSizerPaneldocbutts = new wxBoxSizer( wxHORIZONTAL );
......@@ -167,8 +167,8 @@ DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE::DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE( wx
bLeftBoxSizerPanelAlias->Add( m_staticTextAlias, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
m_PartAliasList = new wxListBox( m_PanelAlias, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0, NULL, 0 );
bLeftBoxSizerPanelAlias->Add( m_PartAliasList, 1, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
m_PartAliasListCtrl = new wxListBox( m_PanelAlias, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0, NULL, 0 );
bLeftBoxSizerPanelAlias->Add( m_PartAliasListCtrl, 1, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
bSizerMainPanelAlias->Add( bLeftBoxSizerPanelAlias, 1, wxEXPAND, 5 );
......
......@@ -965,7 +965,7 @@
<property name="maximum_size"></property>
<property name="maxlength">0</property>
<property name="minimum_size"></property>
<property name="name">m_Doc</property>
<property name="name">m_DocCtrl</property>
<property name="permission">protected</property>
<property name="pos"></property>
<property name="size"></property>
......@@ -1071,7 +1071,7 @@
<property name="maximum_size"></property>
<property name="maxlength">0</property>
<property name="minimum_size"></property>
<property name="name">m_Keywords</property>
<property name="name">m_KeywordsCtrl</property>
<property name="permission">protected</property>
<property name="pos"></property>
<property name="size"></property>
......@@ -1177,7 +1177,7 @@
<property name="maximum_size"></property>
<property name="maxlength">0</property>
<property name="minimum_size"></property>
<property name="name">m_Docfile</property>
<property name="name">m_DocfileCtrl</property>
<property name="permission">protected</property>
<property name="pos"></property>
<property name="size">400,-1</property>
......@@ -1461,7 +1461,7 @@
<property name="id">wxID_ANY</property>
<property name="maximum_size"></property>
<property name="minimum_size"></property>
<property name="name">m_PartAliasList</property>
<property name="name">m_PartAliasListCtrl</property>
<property name="permission">protected</property>
<property name="pos"></property>
<property name="size"></property>
......
......@@ -67,16 +67,16 @@ class DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE : public wxDialog
wxCheckBox* m_OptionPartsLocked;
wxPanel* m_PanelDoc;
wxStaticText* m_staticTextDescription;
wxTextCtrl* m_Doc;
wxTextCtrl* m_DocCtrl;
wxStaticText* m_staticTextKeywords;
wxTextCtrl* m_Keywords;
wxTextCtrl* m_KeywordsCtrl;
wxStaticText* m_staticTextDocFileName;
wxTextCtrl* m_Docfile;
wxTextCtrl* m_DocfileCtrl;
wxButton* m_ButtonCopyDoc;
wxButton* m_buttonBrowseDocFiles;
wxPanel* m_PanelAlias;
wxStaticText* m_staticTextAlias;
wxListBox* m_PartAliasList;
wxListBox* m_PartAliasListCtrl;
wxButton* m_ButtonAddeAlias;
wxButton* m_ButtonDeleteOneAlias;
wxButton* m_ButtonDeleteAllAlias;
......
......@@ -48,72 +48,10 @@ void WinEDA_LibeditFrame::EditComponentProperties()
DisplayLibInfos();
DisplayCmpDoc();
GetScreen()->SetModify();
SaveCopyInUndoList( m_component );
}
void DIALOG_EDIT_COMPONENT_IN_LIBRARY::InitPanelDoc()
{
CMP_LIB_ENTRY* entry;
LIB_COMPONENT* component = m_Parent->GetComponent();
CMP_LIBRARY* library = m_Parent->GetLibrary();
if( component == NULL )
return;
if( m_Parent->GetAliasName().IsEmpty() )
{
entry = component;
}
else
{
entry =
( CMP_LIB_ENTRY* ) library->FindAlias( m_Parent->GetAliasName() );
if( entry == NULL )
return;
}
m_Doc->SetValue( entry->GetDescription() );
m_Keywords->SetValue( entry->GetKeyWords() );
m_Docfile->SetValue( entry->GetDocFileName() );
}
/*
* create the basic panel for component properties editing
*/
void DIALOG_EDIT_COMPONENT_IN_LIBRARY::InitBasicPanel()
{
LIB_COMPONENT* component = m_Parent->GetComponent();
if( m_Parent->GetShowDeMorgan() )
m_AsConvertButt->SetValue( true );
/* Default values for a new component. */
if( component == NULL )
{
m_ShowPinNumButt->SetValue( true );
m_ShowPinNameButt->SetValue( true );
m_PinsNameInsideButt->SetValue( true );
m_SelNumberOfUnits->SetValue( 1 );
m_SetSkew->SetValue( 40 );
m_OptionPower->SetValue( false );
m_OptionPartsLocked->SetValue( false );
return;
}
m_ShowPinNumButt->SetValue( component->m_DrawPinNum );
m_ShowPinNameButt->SetValue( component->m_DrawPinName );
m_PinsNameInsideButt->SetValue( component->m_TextInside != 0 );
m_SelNumberOfUnits->SetValue( component->GetPartCount() );
m_SetSkew->SetValue( component->m_TextInside );
m_OptionPower->SetValue( component->isPower() );
m_OptionPartsLocked->SetValue( component->m_UnitSelectionLocked );
}
void DIALOG_EDIT_COMPONENT_IN_LIBRARY::OnOkClick( wxCommandEvent& event )
{
......@@ -128,6 +66,8 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::OnOkClick( wxCommandEvent& event )
return;
}
m_Parent->SaveCopyInUndoList( component );
CMP_LIBRARY* library = m_Parent->GetLibrary();
if( m_Parent->GetAliasName().IsEmpty() )
......@@ -152,14 +92,14 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::OnOkClick( wxCommandEvent& event )
}
else
{
entry->SetDescription( m_Doc->GetValue() );
entry->SetKeyWords( m_Keywords->GetValue() );
entry->SetDocFileName( m_Docfile->GetValue() );
entry->SetDescription( m_DocCtrl->GetValue() );
entry->SetKeyWords( m_KeywordsCtrl->GetValue() );
entry->SetDocFileName( m_DocfileCtrl->GetValue() );
}
if( m_PartAliasList->GetStrings() != component->m_AliasList )
if( m_PartAliasListCtrl->GetStrings() != component->m_AliasList )
{
wxArrayString aliases = m_PartAliasList->GetStrings();
wxArrayString aliases = m_PartAliasListCtrl->GetStrings();
/* Add names not existing in the current component alias list. */
for( i = 0; i < aliases.GetCount(); i++ )
......@@ -248,9 +188,9 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::CopyDocToAlias( wxCommandEvent& WXUNUSED
if( component == NULL || m_Parent->GetAliasName().IsEmpty() )
return;
m_Doc->SetValue( component->GetDescription() );
m_Docfile->SetValue( component->GetDocFileName() );
m_Keywords->SetValue( component->GetKeyWords() );
m_DocCtrl->SetValue( component->GetDescription() );
m_DocfileCtrl->SetValue( component->GetDocFileName() );
m_KeywordsCtrl->SetValue( component->GetKeyWords() );
}
......@@ -259,7 +199,7 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::DeleteAllAliasOfPart(
wxCommandEvent& WXUNUSED (event) )
/**********************************************************/
{
if( m_PartAliasList->FindString( m_Parent->GetAliasName() )
if( m_PartAliasListCtrl->FindString( m_Parent->GetAliasName() )
!= wxNOT_FOUND )
{
wxString msg;
......@@ -274,7 +214,7 @@ edited!" ),
if( IsOK( this, _( "Remove all aliases from list?" ) ) )
{
m_PartAliasList->Clear();
m_PartAliasListCtrl->Clear();
m_ButtonDeleteAllAlias->Enable( false );
m_ButtonDeleteOneAlias->Enable( false );
}
......@@ -304,7 +244,7 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::AddAliasOfPart( wxCommandEvent& WXUNUSED
Line.Replace( wxT( " " ), wxT( "_" ) );
aliasname = Line;
if( m_PartAliasList->FindString( aliasname ) != wxNOT_FOUND
if( m_PartAliasListCtrl->FindString( aliasname ) != wxNOT_FOUND
|| library->FindEntry( aliasname ) != NULL )
{
wxString msg;
......@@ -316,7 +256,7 @@ library <%s>." ),
return;
}
m_PartAliasList->Append( aliasname );
m_PartAliasListCtrl->Append( aliasname );
if( m_Parent->GetAliasName().IsEmpty() )
m_ButtonDeleteAllAlias->Enable( true );
m_ButtonDeleteOneAlias->Enable( true );
......@@ -326,7 +266,7 @@ library <%s>." ),
void DIALOG_EDIT_COMPONENT_IN_LIBRARY::DeleteAliasOfPart(
wxCommandEvent& WXUNUSED (event) )
{
wxString aliasname = m_PartAliasList->GetStringSelection();
wxString aliasname = m_PartAliasListCtrl->GetStringSelection();
if( aliasname.IsEmpty() )
return;
......@@ -340,9 +280,9 @@ edited!" ),
return;
}
m_PartAliasList->Delete( m_PartAliasList->GetSelection() );
m_PartAliasListCtrl->Delete( m_PartAliasListCtrl->GetSelection() );
if( m_PartAliasList->IsEmpty() )
if( m_PartAliasListCtrl->IsEmpty() )
{
m_ButtonDeleteAllAlias->Enable( false );
m_ButtonDeleteOneAlias->Enable( false );
......@@ -441,7 +381,7 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::BrowseAndSelectDocFile( wxCommandEvent& e
#ifdef __WINDOWS__
filename.Replace(wxT("\\"), wxT("/") );
#endif
m_Docfile->SetValue( filename );
m_DocfileCtrl->SetValue( filename );
}
......
......@@ -39,14 +39,13 @@ void WinEDA_LibeditFrame::SaveCopyInUndoList( EDA_BaseStruct* ItemToCopy,
}
/******************************************************/
/*************************************************************************/
void WinEDA_LibeditFrame::GetComponentFromRedoList(wxCommandEvent& event)
/******************************************************/
/*************************************************************************/
/* Redo the last edition:
* - Place the current edited library component in undo list
* - Get old version of the current edited library component
* @return FALSE if nothing done, else true
*/
{
if ( GetScreen()->GetRedoCommandCount() <= 0 )
......@@ -64,19 +63,24 @@ void WinEDA_LibeditFrame::GetComponentFromRedoList(wxCommandEvent& event)
if( m_component )
m_component->SetNext( NULL );
m_drawItem = NULL;
UpdateAliasSelectList();
UpdatePartSelectList();
if( m_component )
SetShowDeMorgan( m_component->HasConversion() );
DisplayLibInfos();
DisplayCmpDoc();
GetScreen()->SetModify();
DrawPanel->Refresh();
}
/******************************************************/
/************************************************************************/
void WinEDA_LibeditFrame::GetComponentFromUndoList(wxCommandEvent& event)
/******************************************************/
/************************************************************************/
/* Undo the last edition:
/** Undo the last edition:
* - Place the current edited library component in Redo list
* - Get old version of the current edited library component
* @return FALSE if nothing done, else true
*/
{
if ( GetScreen()->GetUndoCommandCount() <= 0 )
......@@ -95,6 +99,12 @@ void WinEDA_LibeditFrame::GetComponentFromUndoList(wxCommandEvent& event)
if( m_component )
m_component->SetNext( NULL );
m_drawItem = NULL;
UpdateAliasSelectList();
UpdatePartSelectList();
if( m_component )
SetShowDeMorgan( m_component->HasConversion() );
DisplayLibInfos();
DisplayCmpDoc();
GetScreen()->SetModify();
DrawPanel->Refresh();
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment