Converted PNS track/via size settings dialog to use Transfer{To,From}Window()

Dialogs were non functional since they were converted to take advantage
of TEXT_CTRL_EVAL.
This commit is contained in:
Maciej Suminski 2018-02-12 23:20:06 +01:00
parent 53e705f634
commit 3ee93caafe
10 changed files with 86 additions and 110 deletions

View File

@ -34,53 +34,53 @@ DIALOG_PNS_DIFF_PAIR_DIMENSIONS::DIALOG_PNS_DIFF_PAIR_DIMENSIONS( wxWindow* aPar
m_viaGap( this, m_viaGapText, m_viaGapUnit ),
m_sizes( aSizes )
{
m_traceWidth.SetValue( aSizes.DiffPairWidth() );
m_traceGap.SetValue( aSizes.DiffPairGap() );
m_viaGap.SetValue( aSizes.DiffPairViaGap() );
m_viaTraceGapEqual->SetValue( m_sizes.DiffPairViaGapSameAsTraceGap() );
updateCheckbox();
Layout();
GetSizer()->SetSizeHints( this );
Centre();
m_stdButtonsOK->SetDefault();
}
bool DIALOG_PNS_DIFF_PAIR_DIMENSIONS::TransferDataFromWindow()
{
if( !wxDialog::TransferDataToWindow() )
return false;
// Save widgets' values to settings
m_sizes.SetDiffPairGap( m_traceGap.GetValue() );
m_sizes.SetDiffPairViaGap( m_viaGap.GetValue() );
m_sizes.SetDiffPairWidth( m_traceWidth.GetValue() );
return true;
}
bool DIALOG_PNS_DIFF_PAIR_DIMENSIONS::TransferDataToWindow()
{
if( !wxDialog::TransferDataFromWindow() )
return false;
m_traceWidth.SetValue( m_sizes.DiffPairWidth() );
m_traceGap.SetValue( m_sizes.DiffPairGap() );
m_viaGap.SetValue( m_sizes.DiffPairViaGap() );
m_viaTraceGapEqual->SetValue( m_sizes.DiffPairViaGapSameAsTraceGap() );
updateCheckbox();
return true;
}
void DIALOG_PNS_DIFF_PAIR_DIMENSIONS::updateCheckbox()
{
if( m_viaTraceGapEqual->GetValue() )
{
m_sizes.SetDiffPairViaGapSameAsTraceGap( true );
m_viaGapText->Disable();
m_viaGapLabel->Disable();
m_viaGapUnit->Disable();
}
else
{
m_sizes.SetDiffPairViaGapSameAsTraceGap( false );
m_viaGapText->Enable();
m_viaGapLabel->Enable();
m_viaGapUnit->Enable();
}
}
void DIALOG_PNS_DIFF_PAIR_DIMENSIONS::OnOkClick( wxCommandEvent& aEvent )
{
// Save widgets' values to settings
m_sizes.SetDiffPairGap ( m_traceGap.GetValue() );
m_sizes.SetDiffPairViaGap ( m_viaGap.GetValue() );
m_sizes.SetDiffPairWidth ( m_traceWidth.GetValue() );
// todo: verify against design rules
EndModal( wxID_OK );
m_sizes.SetDiffPairViaGapSameAsTraceGap( m_viaTraceGapEqual->GetValue() );
m_viaGapText->Enable( !m_viaTraceGapEqual->GetValue() );
m_viaGapLabel->Enable( !m_viaTraceGapEqual->GetValue() );
m_viaGapUnit->Enable( !m_viaTraceGapEqual->GetValue() );
}
void DIALOG_PNS_DIFF_PAIR_DIMENSIONS::OnViaTraceGapEqualCheck( wxCommandEvent& event )
{
event.Skip();
updateCheckbox();
}

View File

@ -41,10 +41,12 @@ class DIALOG_PNS_DIFF_PAIR_DIMENSIONS : public DIALOG_PNS_DIFF_PAIR_DIMENSIONS_B
public:
DIALOG_PNS_DIFF_PAIR_DIMENSIONS( wxWindow* aParent, PNS::SIZES_SETTINGS& aSizes );
bool TransferDataFromWindow() override;
bool TransferDataToWindow() override;
private:
void updateCheckbox();
virtual void OnOkClick( wxCommandEvent& aEvent ) override;
virtual void OnViaTraceGapEqualCheck( wxCommandEvent& event ) override;
UNIT_BINDER m_traceWidth;

View File

@ -1,8 +1,8 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Jan 2 2018)
// C++ code generated with wxFormBuilder (version Jul 17 2016)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
// PLEASE DO "NOT" EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////
#include "widgets/text_ctrl_eval.h"
@ -92,15 +92,11 @@ DIALOG_PNS_DIFF_PAIR_DIMENSIONS_BASE::DIALOG_PNS_DIFF_PAIR_DIMENSIONS_BASE( wxWi
// Connect Events
m_viaTraceGapEqual->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_PNS_DIFF_PAIR_DIMENSIONS_BASE::OnViaTraceGapEqualCheck ), NULL, this );
m_stdButtonsCancel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PNS_DIFF_PAIR_DIMENSIONS_BASE::OnCancelClick ), NULL, this );
m_stdButtonsOK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PNS_DIFF_PAIR_DIMENSIONS_BASE::OnOkClick ), NULL, this );
}
DIALOG_PNS_DIFF_PAIR_DIMENSIONS_BASE::~DIALOG_PNS_DIFF_PAIR_DIMENSIONS_BASE()
{
// Disconnect Events
m_viaTraceGapEqual->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_PNS_DIFF_PAIR_DIMENSIONS_BASE::OnViaTraceGapEqualCheck ), NULL, this );
m_stdButtonsCancel->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PNS_DIFF_PAIR_DIMENSIONS_BASE::OnCancelClick ), NULL, this );
m_stdButtonsOK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PNS_DIFF_PAIR_DIMENSIONS_BASE::OnOkClick ), NULL, this );
}

View File

@ -1078,11 +1078,11 @@
<property name="name">m_stdButtons</property>
<property name="permission">protected</property>
<event name="OnApplyButtonClick"></event>
<event name="OnCancelButtonClick">OnCancelClick</event>
<event name="OnCancelButtonClick"></event>
<event name="OnContextHelpButtonClick"></event>
<event name="OnHelpButtonClick"></event>
<event name="OnNoButtonClick"></event>
<event name="OnOKButtonClick">OnOkClick</event>
<event name="OnOKButtonClick"></event>
<event name="OnSaveButtonClick"></event>
<event name="OnYesButtonClick"></event>
</object>

View File

@ -1,8 +1,8 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Jan 2 2018)
// C++ code generated with wxFormBuilder (version Jul 17 2016)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
// PLEASE DO "NOT" EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////
#ifndef __DIALOG_PNS_DIFF_PAIR_DIMENSIONS_BASE_H__
@ -11,6 +11,7 @@
#include <wx/artprov.h>
#include <wx/xrc/xmlres.h>
#include <wx/intl.h>
class DIALOG_SHIM;
class TEXT_CTRL_EVAL;
#include "dialog_shim.h"
@ -55,8 +56,6 @@ class DIALOG_PNS_DIFF_PAIR_DIMENSIONS_BASE : public DIALOG_SHIM
// Virtual event handlers, overide them in your derived class
virtual void OnViaTraceGapEqualCheck( wxCommandEvent& event ) { event.Skip(); }
virtual void OnCancelClick( wxCommandEvent& event ) { event.Skip(); }
virtual void OnOkClick( wxCommandEvent& event ) { event.Skip(); }
public:

View File

@ -37,20 +37,41 @@ DIALOG_TRACK_VIA_SIZE::DIALOG_TRACK_VIA_SIZE( wxWindow* aParent, BOARD_DESIGN_SE
m_viaDrill( aParent, m_viaDrillText, m_viaDrillLabel ),
m_settings( aSettings )
{
m_stdButtonsOK->SetDefault();
// Now all widgets have the size fixed, call FinishDialogSettings
FinishDialogSettings();
}
bool DIALOG_TRACK_VIA_SIZE::TransferDataFromWindow()
{
if( !wxDialog::TransferDataFromWindow() )
return false;
if( !check() )
return false;
// Store dialog values to the router settings
m_settings.SetCustomTrackWidth( m_trackWidth.GetValue() );
m_settings.SetCustomViaSize( m_viaDiameter.GetValue() );
m_settings.SetCustomViaDrill( m_viaDrill.GetValue() );
return true;
}
bool DIALOG_TRACK_VIA_SIZE::TransferDataToWindow()
{
if( !wxDialog::TransferDataToWindow() )
return false;
// Load router settings to dialog fields
m_trackWidth.SetValue( m_settings.GetCustomTrackWidth() );
m_viaDiameter.SetValue( m_settings.GetCustomViaSize() );
m_viaDrill.SetValue( m_settings.GetCustomViaDrill() );
m_trackWidthText->SetFocus();
m_trackWidthText->SetSelection( -1, -1 );
m_stdButtonsOK->SetDefault();
// Now all widgets have the size fixed, call FinishDialogSettings
FinishDialogSettings();
// Pressing ENTER when any of the text input fields is active applies changes
Connect( wxEVT_TEXT_ENTER, wxCommandEventHandler( DIALOG_TRACK_VIA_SIZE::onOkClick ), NULL, this );
return true;
}
@ -86,28 +107,3 @@ bool DIALOG_TRACK_VIA_SIZE::check()
return true;
}
void DIALOG_TRACK_VIA_SIZE::onClose( wxCloseEvent& aEvent )
{
EndModal( 0 );
}
void DIALOG_TRACK_VIA_SIZE::onOkClick( wxCommandEvent& aEvent )
{
if( check() )
{
// Store dialog values to the router settings
m_settings.SetCustomTrackWidth( m_trackWidth.GetValue() );
m_settings.SetCustomViaSize( m_viaDiameter.GetValue() );
m_settings.SetCustomViaDrill( m_viaDrill.GetValue() );
EndModal( 1 );
}
}
void DIALOG_TRACK_VIA_SIZE::onCancelClick( wxCommandEvent& aEvent )
{
EndModal( 0 );
}

View File

@ -38,6 +38,9 @@ public:
/** Constructor */
DIALOG_TRACK_VIA_SIZE( wxWindow* aParent, BOARD_DESIGN_SETTINGS& aSettings );
bool TransferDataFromWindow() override;
bool TransferDataToWindow() override;
protected:
UNIT_BINDER m_trackWidth;
UNIT_BINDER m_viaDiameter;
@ -48,11 +51,6 @@ protected:
///> Checks if values given in the dialog are sensible.
bool check();
// Handlers for DIALOG_TRACK_VIA_SIZE_BASE events.
void onClose( wxCloseEvent& aEvent ) override;
void onOkClick( wxCommandEvent& aEvent ) override;
void onCancelClick( wxCommandEvent& aEvent ) override;
};
#endif // __dialog_track_via_size__

View File

@ -1,8 +1,8 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Nov 22 2017)
// C++ code generated with wxFormBuilder (version Jul 17 2016)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
// PLEASE DO "NOT" EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////
#include "widgets/text_ctrl_eval.h"
@ -78,18 +78,8 @@ DIALOG_TRACK_VIA_SIZE_BASE::DIALOG_TRACK_VIA_SIZE_BASE( wxWindow* parent, wxWind
bSizes->Fit( this );
this->Centre( wxBOTH );
// Connect Events
this->Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_TRACK_VIA_SIZE_BASE::onClose ) );
m_stdButtonsCancel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_TRACK_VIA_SIZE_BASE::onCancelClick ), NULL, this );
m_stdButtonsOK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_TRACK_VIA_SIZE_BASE::onOkClick ), NULL, this );
}
DIALOG_TRACK_VIA_SIZE_BASE::~DIALOG_TRACK_VIA_SIZE_BASE()
{
// Disconnect Events
this->Disconnect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_TRACK_VIA_SIZE_BASE::onClose ) );
m_stdButtonsCancel->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_TRACK_VIA_SIZE_BASE::onCancelClick ), NULL, this );
m_stdButtonsOK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_TRACK_VIA_SIZE_BASE::onOkClick ), NULL, this );
}

View File

@ -61,7 +61,7 @@
<event name="OnAuiPaneRestore"></event>
<event name="OnAuiRender"></event>
<event name="OnChar"></event>
<event name="OnClose">onClose</event>
<event name="OnClose"></event>
<event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event>
<event name="OnHibernate"></event>
@ -980,11 +980,11 @@
<property name="name">m_stdButtons</property>
<property name="permission">protected</property>
<event name="OnApplyButtonClick"></event>
<event name="OnCancelButtonClick">onCancelClick</event>
<event name="OnCancelButtonClick"></event>
<event name="OnContextHelpButtonClick"></event>
<event name="OnHelpButtonClick"></event>
<event name="OnNoButtonClick"></event>
<event name="OnOKButtonClick">onOkClick</event>
<event name="OnOKButtonClick"></event>
<event name="OnSaveButtonClick"></event>
<event name="OnYesButtonClick"></event>
</object>

View File

@ -1,8 +1,8 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Nov 22 2017)
// C++ code generated with wxFormBuilder (version Jul 17 2016)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
// PLEASE DO "NOT" EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////
#ifndef __DIALOG_TRACK_VIA_SIZE_BASE_H__
@ -11,6 +11,7 @@
#include <wx/artprov.h>
#include <wx/xrc/xmlres.h>
#include <wx/intl.h>
class DIALOG_SHIM;
class TEXT_CTRL_EVAL;
#include "dialog_shim.h"
@ -50,12 +51,6 @@ class DIALOG_TRACK_VIA_SIZE_BASE : public DIALOG_SHIM
wxStdDialogButtonSizer* m_stdButtons;
wxButton* m_stdButtonsOK;
wxButton* m_stdButtonsCancel;
// Virtual event handlers, overide them in your derived class
virtual void onClose( wxCloseEvent& event ) { event.Skip(); }
virtual void onCancelClick( wxCommandEvent& event ) { event.Skip(); }
virtual void onOkClick( wxCommandEvent& event ) { event.Skip(); }
public: