diff --git a/eeschema/dialogs/dialog_edit_components_libid.cpp b/eeschema/dialogs/dialog_edit_components_libid.cpp index 47942fafe9..454eac8d33 100644 --- a/eeschema/dialogs/dialog_edit_components_libid.cpp +++ b/eeschema/dialogs/dialog_edit_components_libid.cpp @@ -89,7 +89,7 @@ public: private: SCH_EDIT_FRAME* m_parent; - bool m_isModified; // set to true is the schemaic is modified + bool m_isModified; // set to true if the schematic is modified std::vector m_components; @@ -102,19 +102,24 @@ private: * @param aReferences is the value of cell( aRowId, COL_REFS) * @param aStrLibId is the value of cell( aRowId, COL_CURR_LIBID) */ - void AddRowToGrid( int aRowId, bool aMarkRow, const wxString& aReferences, const wxString& aStrLibId ); + void AddRowToGrid( int aRowId, bool aMarkRow, + const wxString& aReferences, const wxString& aStrLibId ); - // returns true if all new lib id are valid + /// returns true if all new lib id are valid bool validateLibIds(); - // Reverts all changes already made + /// Reverts all changes already made void revertChanges(); // Events handlers + // called on a right click or a left double click: void onCellBrowseLib( wxGridEvent& event ) override; + + // Apply changes, but do not close the dialog void onApplyButton( wxCommandEvent& event ) override; + // Cancel all changes, and close the dialog void onCancel( wxCommandEvent& event ) override { if( m_isModified ) @@ -122,8 +127,15 @@ private: event.Skip(); } + // Undo all changes, and clear the list of new lib_ids void onUndoChangesButton( wxCommandEvent& event ) override; + void updateUIChangesButton( wxUpdateUIEvent& event ) override + { + m_buttonUndo->Enable( m_isModified ); + } + + // Automatically called when click on OK button bool TransferDataFromWindow() override; }; @@ -159,6 +171,8 @@ static bool sort_by_libid( const CMP_CANDIDATE& cmp1, const CMP_CANDIDATE& cmp2 void DIALOG_EDIT_COMPONENTS_LIBID::initDlg() { + m_isModified = false; + // Build the component list: #if 0 // This option build a component list that works fine to edit LIB_ID fields, but does not display @@ -258,10 +272,16 @@ void DIALOG_EDIT_COMPONENTS_LIBID::initDlg() AddRowToGrid( row, mark_cell, refs, last_str_libid ); m_grid->AutoSizeColumn( COL_CURR_LIBID ); + // ensure the column title is correctly displayed + // (the min size is already fixed by AutoSizeColumn() ) + m_grid->AutoSizeColLabelSize( COL_CURR_LIBID ); - // Gives a similar width to COL_NEW_LIBID because it can conatains similar strings + // Gives a similar width to COL_NEW_LIBID because it can contains similar strings if( m_grid->GetColSize( COL_CURR_LIBID ) > m_grid->GetColSize( COL_NEW_LIBID ) ) m_grid->SetColSize( COL_NEW_LIBID, m_grid->GetColSize( COL_CURR_LIBID ) ); + // ensure the column title is correctly displayed + m_grid->SetColMinimalWidth( COL_NEW_LIBID, m_grid->GetColSize( COL_NEW_LIBID ) ); + m_grid->AutoSizeColLabelSize( COL_NEW_LIBID ); } diff --git a/eeschema/dialogs/dialog_edit_components_libid_base.cpp b/eeschema/dialogs/dialog_edit_components_libid_base.cpp index 7da12d03a9..147bb3ef37 100644 --- a/eeschema/dialogs/dialog_edit_components_libid_base.cpp +++ b/eeschema/dialogs/dialog_edit_components_libid_base.cpp @@ -31,8 +31,8 @@ DIALOG_EDIT_COMPONENTS_LIBID_BASE::DIALOG_EDIT_COMPONENTS_LIBID_BASE( wxWindow* // Columns m_grid->SetColSize( 0, 500 ); - m_grid->SetColSize( 1, 150 ); - m_grid->SetColSize( 2, 150 ); + m_grid->SetColSize( 1, 100 ); + m_grid->SetColSize( 2, 100 ); m_grid->EnableDragColMove( false ); m_grid->EnableDragColSize( true ); m_grid->SetColLabelSize( 30 ); @@ -63,9 +63,6 @@ DIALOG_EDIT_COMPONENTS_LIBID_BASE::DIALOG_EDIT_COMPONENTS_LIBID_BASE( wxWindow* m_staticline = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ); bSizerMain->Add( m_staticline, 0, wxEXPAND | wxALL, 5 ); - wxBoxSizer* bSizerButtons; - bSizerButtons = new wxBoxSizer( wxHORIZONTAL ); - wxBoxSizer* bSizerMsgWarning; bSizerMsgWarning = new wxBoxSizer( wxVERTICAL ); @@ -76,7 +73,10 @@ DIALOG_EDIT_COMPONENTS_LIBID_BASE::DIALOG_EDIT_COMPONENTS_LIBID_BASE( wxWindow* bSizerMsgWarning->Add( m_staticTextWarning, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5 ); - bSizerButtons->Add( bSizerMsgWarning, 1, wxALIGN_CENTER_VERTICAL, 5 ); + bSizerMain->Add( bSizerMsgWarning, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_CENTER_HORIZONTAL, 5 ); + + wxBoxSizer* bSizerButtons; + bSizerButtons = new wxBoxSizer( wxHORIZONTAL ); m_sdbSizer = new wxStdDialogButtonSizer(); m_sdbSizerOK = new wxButton( this, wxID_OK ); @@ -93,7 +93,7 @@ DIALOG_EDIT_COMPONENTS_LIBID_BASE::DIALOG_EDIT_COMPONENTS_LIBID_BASE( wxWindow* bSizerButtons->Add( m_buttonUndo, 0, wxTOP|wxBOTTOM|wxRIGHT|wxALIGN_CENTER_VERTICAL, 5 ); - bSizerMain->Add( bSizerButtons, 0, wxALIGN_RIGHT|wxEXPAND, 5 ); + bSizerMain->Add( bSizerButtons, 0, wxALIGN_RIGHT, 5 ); this->SetSizer( bSizerMain ); @@ -107,6 +107,7 @@ DIALOG_EDIT_COMPONENTS_LIBID_BASE::DIALOG_EDIT_COMPONENTS_LIBID_BASE( wxWindow* m_sdbSizerApply->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_COMPONENTS_LIBID_BASE::onApplyButton ), NULL, this ); m_sdbSizerCancel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_COMPONENTS_LIBID_BASE::onCancel ), NULL, this ); m_buttonUndo->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_COMPONENTS_LIBID_BASE::onUndoChangesButton ), NULL, this ); + m_buttonUndo->Connect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( DIALOG_EDIT_COMPONENTS_LIBID_BASE::updateUIChangesButton ), NULL, this ); } DIALOG_EDIT_COMPONENTS_LIBID_BASE::~DIALOG_EDIT_COMPONENTS_LIBID_BASE() @@ -117,5 +118,6 @@ DIALOG_EDIT_COMPONENTS_LIBID_BASE::~DIALOG_EDIT_COMPONENTS_LIBID_BASE() m_sdbSizerApply->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_COMPONENTS_LIBID_BASE::onApplyButton ), NULL, this ); m_sdbSizerCancel->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_COMPONENTS_LIBID_BASE::onCancel ), NULL, this ); m_buttonUndo->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDIT_COMPONENTS_LIBID_BASE::onUndoChangesButton ), NULL, this ); + m_buttonUndo->Disconnect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( DIALOG_EDIT_COMPONENTS_LIBID_BASE::updateUIChangesButton ), NULL, this ); } diff --git a/eeschema/dialogs/dialog_edit_components_libid_base.fbp b/eeschema/dialogs/dialog_edit_components_libid_base.fbp index d8c237ff84..43f27ffbb2 100644 --- a/eeschema/dialogs/dialog_edit_components_libid_base.fbp +++ b/eeschema/dialogs/dialog_edit_components_libid_base.fbp @@ -44,7 +44,7 @@ DIALOG_EDIT_COMPONENTS_LIBID_BASE - 839,311 + 766,311 wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER DIALOG_SHIM; dialog_shim.h Edit Components Links to Symbols in Libraries @@ -207,7 +207,7 @@ "Components" "Current Symbol" "New Symbol" wxALIGN_CENTRE 3 - 500,150,150 + 500,100,100 1 0 @@ -405,107 +405,107 @@ 5 - wxALIGN_RIGHT|wxEXPAND + wxALIGN_CENTER_VERTICAL|wxALIGN_CENTER_HORIZONTAL + 0 + + + bSizerMsgWarning + wxVERTICAL + none + + 5 + wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + ,90,92,-1,70,0 + 0 + 0 + wxID_ANY + Warning: Changes made from this dialog cannot be undone, after closing it. + + 0 + + + 0 + + 1 + m_staticTextWarning + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALIGN_RIGHT 0 bSizerButtons wxHORIZONTAL none - - 5 - wxALIGN_CENTER_VERTICAL - 1 - - - bSizerMsgWarning - wxVERTICAL - none - - 5 - wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - ,90,92,-1,70,0 - 0 - 0 - wxID_ANY - Warning: Changes made from this dialog cannot be undone, after closing it. - - 0 - - - 0 - - 1 - m_staticTextWarning - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - - - -1 - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL @@ -617,7 +617,7 @@ - + updateUIChangesButton diff --git a/eeschema/dialogs/dialog_edit_components_libid_base.h b/eeschema/dialogs/dialog_edit_components_libid_base.h index 03ac54c6a3..91549be06c 100644 --- a/eeschema/dialogs/dialog_edit_components_libid_base.h +++ b/eeschema/dialogs/dialog_edit_components_libid_base.h @@ -53,11 +53,12 @@ class DIALOG_EDIT_COMPONENTS_LIBID_BASE : public DIALOG_SHIM virtual void onApplyButton( wxCommandEvent& event ) { event.Skip(); } virtual void onCancel( wxCommandEvent& event ) { event.Skip(); } virtual void onUndoChangesButton( wxCommandEvent& event ) { event.Skip(); } + virtual void updateUIChangesButton( wxUpdateUIEvent& event ) { event.Skip(); } public: - DIALOG_EDIT_COMPONENTS_LIBID_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Edit Components Links to Symbols in Libraries"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 839,311 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); + DIALOG_EDIT_COMPONENTS_LIBID_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Edit Components Links to Symbols in Libraries"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 766,311 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); ~DIALOG_EDIT_COMPONENTS_LIBID_BASE(); };