From 5506efaee55358ea21418854826276b408e0a4bf Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Thu, 19 Apr 2018 23:13:19 +0100 Subject: [PATCH] Add a SaveAndContinue button to the Fields Editor. --- .../dialogs/dialog_fields_editor_global.cpp | 10 ++ .../dialogs/dialog_fields_editor_global.h | 16 +- .../dialog_fields_editor_global_base.cpp | 20 ++- .../dialog_fields_editor_global_base.fbp | 147 +++++++++++++++--- .../dialog_fields_editor_global_base.h | 2 + 5 files changed, 164 insertions(+), 31 deletions(-) diff --git a/eeschema/dialogs/dialog_fields_editor_global.cpp b/eeschema/dialogs/dialog_fields_editor_global.cpp index de6cf622d8..8072770e1f 100644 --- a/eeschema/dialogs/dialog_fields_editor_global.cpp +++ b/eeschema/dialogs/dialog_fields_editor_global.cpp @@ -597,3 +597,13 @@ void DIALOG_FIELDS_EDITOR_GLOBAL::OnSizeFieldList( wxSizeEvent& event ) event.Skip(); } + + +void DIALOG_FIELDS_EDITOR_GLOBAL::OnSaveAndContinue( wxCommandEvent& aEvent ) +{ + if( TransferDataFromWindow() ) + { + wxCommandEvent dummyEvent; + m_parent->OnSaveProject( dummyEvent ); + } +} diff --git a/eeschema/dialogs/dialog_fields_editor_global.h b/eeschema/dialogs/dialog_fields_editor_global.h index 7cd25ef6eb..52b79a6ebe 100644 --- a/eeschema/dialogs/dialog_fields_editor_global.h +++ b/eeschema/dialogs/dialog_fields_editor_global.h @@ -51,17 +51,15 @@ private: void AddField( const wxString& aFieldName, bool defaultShow, bool defaultSortBy ); void LoadFieldNames(); - bool Match( SCH_REFERENCE& aRef, SCH_REFERENCE& bRef, bool groupComponents ); - void RebuildRows(); - void OnColSort( wxGridEvent& aEvent ); - virtual void OnColumnItemToggled( wxDataViewEvent& event ) override; - virtual void OnGroupComponentsToggled( wxCommandEvent& event ) override; - virtual void OnRegroupComponents( wxCommandEvent& event ) override; - virtual void OnTableValueChanged( wxGridEvent& event ) override; - virtual void OnTableItemContextMenu( wxGridEvent& event ) override; - virtual void OnSizeFieldList( wxSizeEvent& event ) override; + void OnColumnItemToggled( wxDataViewEvent& event ) override; + void OnGroupComponentsToggled( wxCommandEvent& event ) override; + void OnRegroupComponents( wxCommandEvent& event ) override; + void OnTableValueChanged( wxGridEvent& event ) override; + void OnTableItemContextMenu( wxGridEvent& event ) override; + void OnSizeFieldList( wxSizeEvent& event ) override; + void OnSaveAndContinue( wxCommandEvent& aEvent ) override; }; #endif /* DIALOG_FIELDS_EDITOR_GLOBAL_H */ diff --git a/eeschema/dialogs/dialog_fields_editor_global_base.cpp b/eeschema/dialogs/dialog_fields_editor_global_base.cpp index 1e33ae0f93..966b5d3403 100644 --- a/eeschema/dialogs/dialog_fields_editor_global_base.cpp +++ b/eeschema/dialogs/dialog_fields_editor_global_base.cpp @@ -37,12 +37,12 @@ DIALOG_FIELDS_EDITOR_GLOBAL_BASE::DIALOG_FIELDS_EDITOR_GLOBAL_BASE( wxWindow* pa bGroupSizer->Add( 0, 0, 1, wxEXPAND, 5 ); m_bRefresh = new wxBitmapButton( m_leftPanel, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW ); - m_bRefresh->SetMinSize( wxSize( 30,28 ) ); + m_bRefresh->SetMinSize( wxSize( 30,30 ) ); bGroupSizer->Add( m_bRefresh, 0, wxALIGN_CENTER_VERTICAL, 5 ); - bLeftSizer->Add( bGroupSizer, 0, wxALL|wxBOTTOM|wxEXPAND|wxTOP, 3 ); + bLeftSizer->Add( bGroupSizer, 0, wxALL|wxBOTTOM|wxEXPAND|wxTOP, 2 ); m_fieldsCtrl = new wxDataViewListCtrl( m_leftPanel, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 ); m_fieldsCtrl->SetMinSize( wxSize( 220,220 ) ); @@ -92,6 +92,15 @@ DIALOG_FIELDS_EDITOR_GLOBAL_BASE::DIALOG_FIELDS_EDITOR_GLOBAL_BASE( wxWindow* pa m_splitter1->SplitVertically( m_leftPanel, m_panel4, 230 ); bMainSizer->Add( m_splitter1, 1, wxALL|wxEXPAND, 5 ); + wxBoxSizer* bButtonsSizer; + bButtonsSizer = new wxBoxSizer( wxHORIZONTAL ); + + + bButtonsSizer->Add( 0, 0, 1, wxEXPAND, 5 ); + + m_button1 = new wxButton( this, wxID_ANY, _("Apply, Save Schematic && Continue"), wxDefaultPosition, wxDefaultSize, 0 ); + bButtonsSizer->Add( m_button1, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 ); + m_sdbSizer1 = new wxStdDialogButtonSizer(); m_sdbSizer1OK = new wxButton( this, wxID_OK ); m_sdbSizer1->AddButton( m_sdbSizer1OK ); @@ -99,7 +108,10 @@ DIALOG_FIELDS_EDITOR_GLOBAL_BASE::DIALOG_FIELDS_EDITOR_GLOBAL_BASE( wxWindow* pa m_sdbSizer1->AddButton( m_sdbSizer1Cancel ); m_sdbSizer1->Realize(); - bMainSizer->Add( m_sdbSizer1, 0, wxEXPAND, 5 ); + bButtonsSizer->Add( m_sdbSizer1, 0, wxEXPAND|wxLEFT, 5 ); + + + bMainSizer->Add( bButtonsSizer, 0, wxEXPAND, 5 ); this->SetSizer( bMainSizer ); @@ -115,6 +127,7 @@ DIALOG_FIELDS_EDITOR_GLOBAL_BASE::DIALOG_FIELDS_EDITOR_GLOBAL_BASE( wxWindow* pa m_fieldsCtrl->Connect( wxEVT_SIZE, wxSizeEventHandler( DIALOG_FIELDS_EDITOR_GLOBAL_BASE::OnSizeFieldList ), NULL, this ); m_grid->Connect( wxEVT_GRID_CELL_CHANGED, wxGridEventHandler( DIALOG_FIELDS_EDITOR_GLOBAL_BASE::OnTableValueChanged ), NULL, this ); m_grid->Connect( wxEVT_GRID_CELL_RIGHT_CLICK, wxGridEventHandler( DIALOG_FIELDS_EDITOR_GLOBAL_BASE::OnTableItemContextMenu ), NULL, this ); + m_button1->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FIELDS_EDITOR_GLOBAL_BASE::OnSaveAndContinue ), NULL, this ); m_sdbSizer1Cancel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FIELDS_EDITOR_GLOBAL_BASE::OnCancel ), NULL, this ); m_sdbSizer1OK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FIELDS_EDITOR_GLOBAL_BASE::OnOK ), NULL, this ); } @@ -128,6 +141,7 @@ DIALOG_FIELDS_EDITOR_GLOBAL_BASE::~DIALOG_FIELDS_EDITOR_GLOBAL_BASE() m_fieldsCtrl->Disconnect( wxEVT_SIZE, wxSizeEventHandler( DIALOG_FIELDS_EDITOR_GLOBAL_BASE::OnSizeFieldList ), NULL, this ); m_grid->Disconnect( wxEVT_GRID_CELL_CHANGED, wxGridEventHandler( DIALOG_FIELDS_EDITOR_GLOBAL_BASE::OnTableValueChanged ), NULL, this ); m_grid->Disconnect( wxEVT_GRID_CELL_RIGHT_CLICK, wxGridEventHandler( DIALOG_FIELDS_EDITOR_GLOBAL_BASE::OnTableItemContextMenu ), NULL, this ); + m_button1->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FIELDS_EDITOR_GLOBAL_BASE::OnSaveAndContinue ), NULL, this ); m_sdbSizer1Cancel->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FIELDS_EDITOR_GLOBAL_BASE::OnCancel ), NULL, this ); m_sdbSizer1OK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FIELDS_EDITOR_GLOBAL_BASE::OnOK ), NULL, this ); diff --git a/eeschema/dialogs/dialog_fields_editor_global_base.fbp b/eeschema/dialogs/dialog_fields_editor_global_base.fbp index b57d11b185..c4da6932e3 100644 --- a/eeschema/dialogs/dialog_fields_editor_global_base.fbp +++ b/eeschema/dialogs/dialog_fields_editor_global_base.fbp @@ -766,26 +766,135 @@ 5 wxEXPAND 0 - - 0 - 1 - 0 - 0 - 0 - 1 - 0 - 0 + - m_sdbSizer1 - protected - - OnCancel - - - - OnOK - - + bButtonsSizer + wxHORIZONTAL + none + + 5 + wxEXPAND + 1 + + 0 + protected + 0 + + + + 5 + wxALIGN_CENTER_VERTICAL|wxRIGHT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Apply, Save Schematic && Continue + + 0 + + + 0 + + 1 + m_button1 + 1 + + + protected + 1 + + Resizable + 1 + + + ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + OnSaveAndContinue + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND|wxLEFT + 0 + + 0 + 1 + 0 + 0 + 0 + 1 + 0 + 0 + + m_sdbSizer1 + protected + + OnCancel + + + + OnOK + + + + diff --git a/eeschema/dialogs/dialog_fields_editor_global_base.h b/eeschema/dialogs/dialog_fields_editor_global_base.h index 66b00480e0..626aa94f81 100644 --- a/eeschema/dialogs/dialog_fields_editor_global_base.h +++ b/eeschema/dialogs/dialog_fields_editor_global_base.h @@ -49,6 +49,7 @@ class DIALOG_FIELDS_EDITOR_GLOBAL_BASE : public DIALOG_SHIM wxDataViewListCtrl* m_fieldsCtrl; wxPanel* m_panel4; wxGrid* m_grid; + wxButton* m_button1; wxStdDialogButtonSizer* m_sdbSizer1; wxButton* m_sdbSizer1OK; wxButton* m_sdbSizer1Cancel; @@ -60,6 +61,7 @@ class DIALOG_FIELDS_EDITOR_GLOBAL_BASE : public DIALOG_SHIM virtual void OnSizeFieldList( wxSizeEvent& event ) { event.Skip(); } virtual void OnTableValueChanged( wxGridEvent& event ) { event.Skip(); } virtual void OnTableItemContextMenu( wxGridEvent& event ) { event.Skip(); } + virtual void OnSaveAndContinue( wxCommandEvent& event ) { event.Skip(); } virtual void OnCancel( wxCommandEvent& event ) { event.Skip(); } virtual void OnOK( wxCommandEvent& event ) { event.Skip(); }