Reworked UI

- Buttons are enabled/disabled within wxUpdateUI events
- Save/Cancel dialog used to close window and apply (or reject) changes
This commit is contained in:
Oliver Walters 2017-04-18 19:25:02 +10:00 committed by Wayne Stambaugh
parent 59470c3b5e
commit d792e36151
5 changed files with 90 additions and 23 deletions

View File

@ -85,7 +85,7 @@ DIALOG_BOM_EDITOR::DIALOG_BOM_EDITOR( SCH_EDIT_FRAME* parent ) :
m_bom->ReloadTable(); m_bom->ReloadTable();
UpdateTitle(); Update();
} }
DIALOG_BOM_EDITOR::~DIALOG_BOM_EDITOR() DIALOG_BOM_EDITOR::~DIALOG_BOM_EDITOR()
@ -98,7 +98,7 @@ DIALOG_BOM_EDITOR::~DIALOG_BOM_EDITOR()
* work out if we need to save any changed. * work out if we need to save any changed.
* If so, capture those changes and push them to the undo stack. * If so, capture those changes and push them to the undo stack.
*/ */
void DIALOG_BOM_EDITOR::OnBomEditorClosed( wxCloseEvent& event ) bool DIALOG_BOM_EDITOR::TransferDataFromWindow()
{ {
bool saveChanges = false; bool saveChanges = false;
@ -115,11 +115,10 @@ void DIALOG_BOM_EDITOR::OnBomEditorClosed( wxCloseEvent& event )
break; break;
// Cancel (do not exit) // Cancel (do not exit)
case wxID_CANCEL: case wxID_CANCEL:
event.Veto(); return false;
return;
// Do not save, exit // Do not save, exit
default: default:
break; return true;
} }
} }
@ -157,7 +156,7 @@ void DIALOG_BOM_EDITOR::OnBomEditorClosed( wxCloseEvent& event )
m_parent->OnModify(); m_parent->OnModify();
} }
Destroy(); return true;
} }
/** /**
@ -285,7 +284,14 @@ void DIALOG_BOM_EDITOR::OnGroupComponentsToggled( wxCommandEvent& event )
m_bom->SetColumnGrouping( group ); m_bom->SetColumnGrouping( group );
m_bom->ReloadTable(); m_bom->ReloadTable();
m_regroupComponentsButton->Enable( group ); Update();
}
void DIALOG_BOM_EDITOR::OnUpdateUI( wxUpdateUIEvent& event )
{
m_regroupComponentsButton->Enable( m_bom->GetColumnGrouping() );
m_reloadTableButton->Enable( m_bom->HaveFieldsChanged() );
UpdateTitle(); UpdateTitle();
} }
@ -417,14 +423,13 @@ void DIALOG_BOM_EDITOR::OnExportBOM( wxCommandEvent& event )
void DIALOG_BOM_EDITOR::OnTableValueChanged( wxDataViewEvent& event ) void DIALOG_BOM_EDITOR::OnTableValueChanged( wxDataViewEvent& event )
{ {
m_reloadTableButton->Enable( m_bom->HaveFieldsChanged() ); Update();
UpdateTitle();
} }
void DIALOG_BOM_EDITOR::OnRegroupComponents( wxCommandEvent& event ) void DIALOG_BOM_EDITOR::OnRegroupComponents( wxCommandEvent& event )
{ {
m_bom->ReloadTable(); m_bom->ReloadTable();
Update();
} }
void DIALOG_BOM_EDITOR::OnRevertFieldChanges( wxCommandEvent& event ) void DIALOG_BOM_EDITOR::OnRevertFieldChanges( wxCommandEvent& event )
@ -434,8 +439,7 @@ void DIALOG_BOM_EDITOR::OnRevertFieldChanges( wxCommandEvent& event )
if( IsOK( this, _( "Revert all component table changes?" ) ) ) if( IsOK( this, _( "Revert all component table changes?" ) ) )
{ {
m_bom->RevertFieldChanges(); m_bom->RevertFieldChanges();
m_reloadTableButton->Enable( m_bom->HaveFieldsChanged() ); Update();
UpdateTitle();
} }
} }
} }

View File

@ -62,6 +62,9 @@ private:
void LoadColumnNames( void ); void LoadColumnNames( void );
void ReloadColumns( void ); void ReloadColumns( void );
// Called when the OK button is pressed
virtual bool TransferDataFromWindow() override;
// Checkbox event callbacks // Checkbox event callbacks
virtual void OnColumnItemToggled( wxDataViewEvent& event ) override; virtual void OnColumnItemToggled( wxDataViewEvent& event ) override;
virtual void OnGroupComponentsToggled( wxCommandEvent& event ) override; virtual void OnGroupComponentsToggled( wxCommandEvent& event ) override;
@ -75,9 +78,10 @@ private:
// Called after a value in the table has changed // Called after a value in the table has changed
virtual void OnTableValueChanged( wxDataViewEvent& event ) override; virtual void OnTableValueChanged( wxDataViewEvent& event ) override;
virtual void OnBomEditorClosed( wxCloseEvent& event ) override;
void UpdateTitle( void ); void UpdateTitle( void );
virtual void OnUpdateUI( wxUpdateUIEvent& event ) override;
}; };
#endif /* EESCHEMA_DIALOGS_DIALOG_BOM_EDITOR_H_ */ #endif /* EESCHEMA_DIALOGS_DIALOG_BOM_EDITOR_H_ */

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Apr 1 2017) // C++ code generated with wxFormBuilder (version Mar 22 2017)
// http://www.wxformbuilder.org/ // http://www.wxformbuilder.org/
// //
// PLEASE DO "NOT" EDIT THIS FILE! // PLEASE DO "NOT" EDIT THIS FILE!
@ -10,7 +10,7 @@
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
BEGIN_EVENT_TABLE( DIALOG_BOM_EDITOR_BASE, DIALOG_SHIM ) BEGIN_EVENT_TABLE( DIALOG_BOM_EDITOR_BASE, DIALOG_SHIM )
EVT_CLOSE( DIALOG_BOM_EDITOR_BASE::_wxFB_OnBomEditorClosed ) EVT_UPDATE_UI( wxID_ANY, DIALOG_BOM_EDITOR_BASE::_wxFB_OnUpdateUI )
EVT_CHECKBOX( OPT_GROUP_COMPONENTS, DIALOG_BOM_EDITOR_BASE::_wxFB_OnGroupComponentsToggled ) EVT_CHECKBOX( OPT_GROUP_COMPONENTS, DIALOG_BOM_EDITOR_BASE::_wxFB_OnGroupComponentsToggled )
EVT_BUTTON( ID_BUTTON_REGROUP, DIALOG_BOM_EDITOR_BASE::_wxFB_OnRegroupComponents ) EVT_BUTTON( ID_BUTTON_REGROUP, DIALOG_BOM_EDITOR_BASE::_wxFB_OnRegroupComponents )
EVT_BUTTON( ID_BUTTON_REVERT_CHANGES, DIALOG_BOM_EDITOR_BASE::_wxFB_OnRevertFieldChanges ) EVT_BUTTON( ID_BUTTON_REVERT_CHANGES, DIALOG_BOM_EDITOR_BASE::_wxFB_OnRevertFieldChanges )
@ -112,6 +112,21 @@ DIALOG_BOM_EDITOR_BASE::DIALOG_BOM_EDITOR_BASE( wxWindow* parent, wxWindowID id,
bSizer6->Add( sbSizer2, 0, wxEXPAND, 5 ); bSizer6->Add( sbSizer2, 0, wxEXPAND, 5 );
wxStaticBoxSizer* sbSizer4;
sbSizer4 = new wxStaticBoxSizer( new wxStaticBox( m_leftPanel, wxID_ANY, _("Apply changes") ), wxVERTICAL );
m_sdbSizer1 = new wxStdDialogButtonSizer();
m_sdbSizer1OK = new wxButton( sbSizer4->GetStaticBox(), wxID_OK );
m_sdbSizer1->AddButton( m_sdbSizer1OK );
m_sdbSizer1Cancel = new wxButton( sbSizer4->GetStaticBox(), wxID_CANCEL );
m_sdbSizer1->AddButton( m_sdbSizer1Cancel );
m_sdbSizer1->Realize();
sbSizer4->Add( m_sdbSizer1, 1, wxEXPAND, 5 );
bSizer6->Add( sbSizer4, 1, wxEXPAND, 5 );
m_leftPanel->SetSizer( bSizer6 ); m_leftPanel->SetSizer( bSizer6 );
m_leftPanel->Layout(); m_leftPanel->Layout();

View File

@ -45,7 +45,7 @@
<property name="name">DIALOG_BOM_EDITOR_BASE</property> <property name="name">DIALOG_BOM_EDITOR_BASE</property>
<property name="pos"></property> <property name="pos"></property>
<property name="size">1047,649</property> <property name="size">1047,649</property>
<property name="style">wxDEFAULT_DIALOG_STYLE|wxMAXIMIZE_BOX|wxRESIZE_BORDER</property> <property name="style">wxCAPTION|wxMAXIMIZE_BOX|wxRESIZE_BORDER|wxSTAY_ON_TOP</property>
<property name="subclass">DIALOG_SHIM; dialog_shim.h</property> <property name="subclass">DIALOG_SHIM; dialog_shim.h</property>
<property name="title">BOM editor</property> <property name="title">BOM editor</property>
<property name="tooltip"></property> <property name="tooltip"></property>
@ -61,7 +61,7 @@
<event name="OnAuiPaneRestore"></event> <event name="OnAuiPaneRestore"></event>
<event name="OnAuiRender"></event> <event name="OnAuiRender"></event>
<event name="OnChar"></event> <event name="OnChar"></event>
<event name="OnClose">OnBomEditorClosed</event> <event name="OnClose"></event>
<event name="OnEnterWindow"></event> <event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event> <event name="OnEraseBackground"></event>
<event name="OnHibernate"></event> <event name="OnHibernate"></event>
@ -87,7 +87,7 @@
<event name="OnRightUp"></event> <event name="OnRightUp"></event>
<event name="OnSetFocus"></event> <event name="OnSetFocus"></event>
<event name="OnSize"></event> <event name="OnSize"></event>
<event name="OnUpdateUI"></event> <event name="OnUpdateUI">OnUpdateUI</event>
<object class="wxBoxSizer" expanded="1"> <object class="wxBoxSizer" expanded="1">
<property name="minimum_size"></property> <property name="minimum_size"></property>
<property name="name">bHorizontalSizer</property> <property name="name">bHorizontalSizer</property>
@ -1037,6 +1037,47 @@
</object> </object>
</object> </object>
</object> </object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND</property>
<property name="proportion">1</property>
<object class="wxStaticBoxSizer" expanded="1">
<property name="id">wxID_ANY</property>
<property name="label">Apply changes</property>
<property name="minimum_size"></property>
<property name="name">sbSizer4</property>
<property name="orient">wxVERTICAL</property>
<property name="parent">1</property>
<property name="permission">none</property>
<event name="OnUpdateUI"></event>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND</property>
<property name="proportion">1</property>
<object class="wxStdDialogButtonSizer" expanded="1">
<property name="Apply">0</property>
<property name="Cancel">1</property>
<property name="ContextHelp">0</property>
<property name="Help">0</property>
<property name="No">0</property>
<property name="OK">1</property>
<property name="Save">0</property>
<property name="Yes">0</property>
<property name="minimum_size"></property>
<property name="name">m_sdbSizer1</property>
<property name="permission">protected</property>
<event name="OnApplyButtonClick"></event>
<event name="OnCancelButtonClick"></event>
<event name="OnContextHelpButtonClick"></event>
<event name="OnHelpButtonClick"></event>
<event name="OnNoButtonClick"></event>
<event name="OnOKButtonClick"></event>
<event name="OnSaveButtonClick"></event>
<event name="OnYesButtonClick"></event>
</object>
</object>
</object>
</object>
</object> </object>
</object> </object>
</object> </object>

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Apr 1 2017) // C++ code generated with wxFormBuilder (version Mar 22 2017)
// http://www.wxformbuilder.org/ // http://www.wxformbuilder.org/
// //
// PLEASE DO "NOT" EDIT THIS FILE! // PLEASE DO "NOT" EDIT THIS FILE!
@ -46,7 +46,7 @@ class DIALOG_BOM_EDITOR_BASE : public DIALOG_SHIM
private: private:
// Private event handlers // Private event handlers
void _wxFB_OnBomEditorClosed( wxCloseEvent& event ){ OnBomEditorClosed( event ); } void _wxFB_OnUpdateUI( wxUpdateUIEvent& event ){ OnUpdateUI( event ); }
void _wxFB_OnGroupComponentsToggled( wxCommandEvent& event ){ OnGroupComponentsToggled( event ); } void _wxFB_OnGroupComponentsToggled( wxCommandEvent& event ){ OnGroupComponentsToggled( event ); }
void _wxFB_OnRegroupComponents( wxCommandEvent& event ){ OnRegroupComponents( event ); } void _wxFB_OnRegroupComponents( wxCommandEvent& event ){ OnRegroupComponents( event ); }
void _wxFB_OnRevertFieldChanges( wxCommandEvent& event ){ OnRevertFieldChanges( event ); } void _wxFB_OnRevertFieldChanges( wxCommandEvent& event ){ OnRevertFieldChanges( event ); }
@ -69,11 +69,14 @@ class DIALOG_BOM_EDITOR_BASE : public DIALOG_SHIM
wxCheckBox* m_includeProjectData; wxCheckBox* m_includeProjectData;
wxCheckBox* m_showRowNumbers; wxCheckBox* m_showRowNumbers;
wxButton* m_exportButton; wxButton* m_exportButton;
wxStdDialogButtonSizer* m_sdbSizer1;
wxButton* m_sdbSizer1OK;
wxButton* m_sdbSizer1Cancel;
wxPanel* m_panel4; wxPanel* m_panel4;
wxDataViewCtrl* m_bomView; wxDataViewCtrl* m_bomView;
// Virtual event handlers, overide them in your derived class // Virtual event handlers, overide them in your derived class
virtual void OnBomEditorClosed( wxCloseEvent& event ) { event.Skip(); } virtual void OnUpdateUI( wxUpdateUIEvent& event ) { event.Skip(); }
virtual void OnGroupComponentsToggled( wxCommandEvent& event ) { event.Skip(); } virtual void OnGroupComponentsToggled( wxCommandEvent& event ) { event.Skip(); }
virtual void OnRegroupComponents( wxCommandEvent& event ) { event.Skip(); } virtual void OnRegroupComponents( wxCommandEvent& event ) { event.Skip(); }
virtual void OnRevertFieldChanges( wxCommandEvent& event ) { event.Skip(); } virtual void OnRevertFieldChanges( wxCommandEvent& event ) { event.Skip(); }
@ -87,7 +90,7 @@ class DIALOG_BOM_EDITOR_BASE : public DIALOG_SHIM
public: public:
DIALOG_BOM_EDITOR_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("BOM editor"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 1047,649 ), long style = wxDEFAULT_DIALOG_STYLE|wxMAXIMIZE_BOX|wxRESIZE_BORDER ); DIALOG_BOM_EDITOR_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("BOM editor"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 1047,649 ), long style = wxCAPTION|wxMAXIMIZE_BOX|wxRESIZE_BORDER|wxSTAY_ON_TOP );
~DIALOG_BOM_EDITOR_BASE(); ~DIALOG_BOM_EDITOR_BASE();
void m_splitter1OnIdle( wxIdleEvent& ) void m_splitter1OnIdle( wxIdleEvent& )