Pcbnew: minor fixes in DIALOG_GLOBAL_MODULES_FIELDS_EDITION.
Better code: use TransferDataFromWindow and remove wxID_OK and wxID_CANCEL custom called events.
This commit is contained in:
parent
e5137f4eb4
commit
54670d6785
|
@ -71,12 +71,7 @@ public:
|
||||||
private:
|
private:
|
||||||
void initDialog();
|
void initDialog();
|
||||||
|
|
||||||
// event handlers
|
bool TransferDataFromWindow() override;
|
||||||
void OnOKClick( wxCommandEvent& event ) override;
|
|
||||||
void OnCancelClick( wxCommandEvent& event ) override
|
|
||||||
{
|
|
||||||
EndModal( wxID_CANCEL );
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
bool DIALOG_GLOBAL_MODULES_FIELDS_EDITION::m_refSelection = false;
|
bool DIALOG_GLOBAL_MODULES_FIELDS_EDITION::m_refSelection = false;
|
||||||
|
@ -110,7 +105,7 @@ void DIALOG_GLOBAL_MODULES_FIELDS_EDITION::initDialog()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void DIALOG_GLOBAL_MODULES_FIELDS_EDITION::OnOKClick( wxCommandEvent& event )
|
bool DIALOG_GLOBAL_MODULES_FIELDS_EDITION::TransferDataFromWindow()
|
||||||
{
|
{
|
||||||
m_refSelection = m_ReferenceOpt->GetValue();
|
m_refSelection = m_ReferenceOpt->GetValue();
|
||||||
m_valueSelection = m_ValueOpt->GetValue();
|
m_valueSelection = m_ValueOpt->GetValue();
|
||||||
|
@ -122,14 +117,14 @@ void DIALOG_GLOBAL_MODULES_FIELDS_EDITION::OnOKClick( wxCommandEvent& event )
|
||||||
m_brdSettings->m_ModuleTextWidth = ValueFromTextCtrl( *m_ThicknessValue );
|
m_brdSettings->m_ModuleTextWidth = ValueFromTextCtrl( *m_ThicknessValue );
|
||||||
|
|
||||||
// clip m_ModuleTextWidth to the 1/4 of min size, to keep it always readable
|
// clip m_ModuleTextWidth to the 1/4 of min size, to keep it always readable
|
||||||
int minsize = std::min( m_brdSettings->m_ModuleTextSize.x,
|
int max_thickness = std::min( m_brdSettings->m_ModuleTextSize.x,
|
||||||
m_brdSettings->m_ModuleTextSize.y ) / 4;
|
m_brdSettings->m_ModuleTextSize.y ) / 4;
|
||||||
if( m_brdSettings->m_ModuleTextWidth > minsize )
|
if( m_brdSettings->m_ModuleTextWidth > max_thickness )
|
||||||
m_brdSettings->m_ModuleTextWidth = minsize;
|
m_brdSettings->m_ModuleTextWidth = max_thickness;
|
||||||
|
|
||||||
m_parent->ResetModuleTextSizes( m_filterString, m_refSelection,
|
m_parent->ResetModuleTextSizes( m_filterString, m_refSelection,
|
||||||
m_valueSelection, m_othersSelection );
|
m_valueSelection, m_othersSelection );
|
||||||
EndModal( wxID_OK );
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -146,11 +141,12 @@ void PCB_BASE_FRAME::ResetModuleTextSizes( const wxString & aFilter, bool aRef,
|
||||||
|
|
||||||
int modTextWidth = GetDesignSettings().m_ModuleTextWidth;
|
int modTextWidth = GetDesignSettings().m_ModuleTextWidth;
|
||||||
const wxSize& modTextSize = GetDesignSettings().m_ModuleTextSize;
|
const wxSize& modTextSize = GetDesignSettings().m_ModuleTextSize;
|
||||||
|
bool modified = false;
|
||||||
|
|
||||||
// Prepare undo list
|
// Change fields of footprints with fpid matching the filter
|
||||||
for( MODULE* module = GetBoard()->m_Modules; module; module = module->Next() )
|
for( MODULE* module = GetBoard()->m_Modules; module; module = module->Next() )
|
||||||
{
|
{
|
||||||
if( ! aFilter.IsEmpty() )
|
if( !aFilter.IsEmpty() )
|
||||||
{
|
{
|
||||||
if( ! WildCompareString( aFilter, FROM_UTF8( module->GetFPID().Format().c_str() ),
|
if( ! WildCompareString( aFilter, FROM_UTF8( module->GetFPID().Format().c_str() ),
|
||||||
false ) )
|
false ) )
|
||||||
|
@ -168,6 +164,7 @@ void PCB_BASE_FRAME::ResetModuleTextSizes( const wxString & aFilter, bool aRef,
|
||||||
commit.Modify( item );
|
commit.Modify( item );
|
||||||
item->SetThickness( modTextWidth );
|
item->SetThickness( modTextWidth );
|
||||||
item->SetTextSize( modTextSize );
|
item->SetTextSize( modTextSize );
|
||||||
|
modified = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -181,6 +178,7 @@ void PCB_BASE_FRAME::ResetModuleTextSizes( const wxString & aFilter, bool aRef,
|
||||||
commit.Modify( item );
|
commit.Modify( item );
|
||||||
item->SetThickness( modTextWidth );
|
item->SetThickness( modTextWidth );
|
||||||
item->SetTextSize( modTextSize );
|
item->SetTextSize( modTextSize );
|
||||||
|
modified = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -199,11 +197,16 @@ void PCB_BASE_FRAME::ResetModuleTextSizes( const wxString & aFilter, bool aRef,
|
||||||
commit.Modify( item );
|
commit.Modify( item );
|
||||||
item->SetThickness( modTextWidth );
|
item->SetThickness( modTextWidth );
|
||||||
item->SetTextSize( modTextSize );
|
item->SetTextSize( modTextSize );
|
||||||
|
modified = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
commit.Push( wxT( "Reset module text size" ) );
|
if( modified )
|
||||||
|
{
|
||||||
|
commit.Push( "Reset module text size" );
|
||||||
|
GetCanvas()->Refresh();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
// C++ code generated with wxFormBuilder (version Jan 1 2016)
|
// C++ code generated with wxFormBuilder (version May 6 2016)
|
||||||
// http://www.wxformbuilder.org/
|
// http://www.wxformbuilder.org/
|
||||||
//
|
//
|
||||||
// PLEASE DO "NOT" EDIT THIS FILE!
|
// PLEASE DO "NOT" EDIT THIS FILE!
|
||||||
|
@ -37,7 +37,7 @@ DIALOG_GLOBAL_MODULES_FIELDS_EDITION_BASE::DIALOG_GLOBAL_MODULES_FIELDS_EDITION_
|
||||||
|
|
||||||
bLeftSizer->Add( sbSizer1, 1, wxBOTTOM|wxEXPAND|wxRIGHT, 5 );
|
bLeftSizer->Add( sbSizer1, 1, wxBOTTOM|wxEXPAND|wxRIGHT, 5 );
|
||||||
|
|
||||||
m_staticTextFilter = new wxStaticText( this, wxID_ANY, _("Footprint Filter:"), wxDefaultPosition, wxDefaultSize, 0 );
|
m_staticTextFilter = new wxStaticText( this, wxID_ANY, _("Footprint Name (FPID) Filter:"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||||
m_staticTextFilter->Wrap( -1 );
|
m_staticTextFilter->Wrap( -1 );
|
||||||
m_staticTextFilter->SetToolTip( _("A string to filter footprints to edit.\nIf not void, footprint names should match this filter.\nA filter can be something like SM* (case insensitive)") );
|
m_staticTextFilter->SetToolTip( _("A string to filter footprints to edit.\nIf not void, footprint names should match this filter.\nA filter can be something like SM* (case insensitive)") );
|
||||||
|
|
||||||
|
@ -124,14 +124,12 @@ DIALOG_GLOBAL_MODULES_FIELDS_EDITION_BASE::DIALOG_GLOBAL_MODULES_FIELDS_EDITION_
|
||||||
bMainSizer->Fit( this );
|
bMainSizer->Fit( this );
|
||||||
|
|
||||||
// Connect Events
|
// Connect Events
|
||||||
m_sdbSizerButtonsCancel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_GLOBAL_MODULES_FIELDS_EDITION_BASE::OnCancelClick ), NULL, this );
|
|
||||||
m_sdbSizerButtonsOK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_GLOBAL_MODULES_FIELDS_EDITION_BASE::OnOKClick ), NULL, this );
|
m_sdbSizerButtonsOK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_GLOBAL_MODULES_FIELDS_EDITION_BASE::OnOKClick ), NULL, this );
|
||||||
}
|
}
|
||||||
|
|
||||||
DIALOG_GLOBAL_MODULES_FIELDS_EDITION_BASE::~DIALOG_GLOBAL_MODULES_FIELDS_EDITION_BASE()
|
DIALOG_GLOBAL_MODULES_FIELDS_EDITION_BASE::~DIALOG_GLOBAL_MODULES_FIELDS_EDITION_BASE()
|
||||||
{
|
{
|
||||||
// Disconnect Events
|
// Disconnect Events
|
||||||
m_sdbSizerButtonsCancel->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_GLOBAL_MODULES_FIELDS_EDITION_BASE::OnCancelClick ), NULL, this );
|
|
||||||
m_sdbSizerButtonsOK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_GLOBAL_MODULES_FIELDS_EDITION_BASE::OnOKClick ), NULL, this );
|
m_sdbSizerButtonsOK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_GLOBAL_MODULES_FIELDS_EDITION_BASE::OnOKClick ), NULL, this );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -121,6 +121,7 @@
|
||||||
<property name="minimum_size"></property>
|
<property name="minimum_size"></property>
|
||||||
<property name="name">sbSizer1</property>
|
<property name="name">sbSizer1</property>
|
||||||
<property name="orient">wxVERTICAL</property>
|
<property name="orient">wxVERTICAL</property>
|
||||||
|
<property name="parent">1</property>
|
||||||
<property name="permission">none</property>
|
<property name="permission">none</property>
|
||||||
<event name="OnUpdateUI"></event>
|
<event name="OnUpdateUI"></event>
|
||||||
<object class="sizeritem" expanded="1">
|
<object class="sizeritem" expanded="1">
|
||||||
|
@ -421,7 +422,7 @@
|
||||||
<property name="gripper">0</property>
|
<property name="gripper">0</property>
|
||||||
<property name="hidden">0</property>
|
<property name="hidden">0</property>
|
||||||
<property name="id">wxID_ANY</property>
|
<property name="id">wxID_ANY</property>
|
||||||
<property name="label">Footprint Filter:</property>
|
<property name="label">Footprint Name (FPID) Filter:</property>
|
||||||
<property name="max_size"></property>
|
<property name="max_size"></property>
|
||||||
<property name="maximize_button">0</property>
|
<property name="maximize_button">0</property>
|
||||||
<property name="maximum_size"></property>
|
<property name="maximum_size"></property>
|
||||||
|
@ -584,6 +585,7 @@
|
||||||
<property name="minimum_size"></property>
|
<property name="minimum_size"></property>
|
||||||
<property name="name">sbSizerSettings</property>
|
<property name="name">sbSizerSettings</property>
|
||||||
<property name="orient">wxVERTICAL</property>
|
<property name="orient">wxVERTICAL</property>
|
||||||
|
<property name="parent">1</property>
|
||||||
<property name="permission">none</property>
|
<property name="permission">none</property>
|
||||||
<event name="OnUpdateUI"></event>
|
<event name="OnUpdateUI"></event>
|
||||||
<object class="sizeritem" expanded="1">
|
<object class="sizeritem" expanded="1">
|
||||||
|
@ -1479,11 +1481,11 @@
|
||||||
<property name="name">m_sdbSizerButtons</property>
|
<property name="name">m_sdbSizerButtons</property>
|
||||||
<property name="permission">protected</property>
|
<property name="permission">protected</property>
|
||||||
<event name="OnApplyButtonClick"></event>
|
<event name="OnApplyButtonClick"></event>
|
||||||
<event name="OnCancelButtonClick">OnCancelClick</event>
|
<event name="OnCancelButtonClick"></event>
|
||||||
<event name="OnContextHelpButtonClick"></event>
|
<event name="OnContextHelpButtonClick"></event>
|
||||||
<event name="OnHelpButtonClick"></event>
|
<event name="OnHelpButtonClick"></event>
|
||||||
<event name="OnNoButtonClick"></event>
|
<event name="OnNoButtonClick"></event>
|
||||||
<event name="OnOKButtonClick">OnOKClick</event>
|
<event name="OnOKButtonClick"></event>
|
||||||
<event name="OnSaveButtonClick"></event>
|
<event name="OnSaveButtonClick"></event>
|
||||||
<event name="OnYesButtonClick"></event>
|
<event name="OnYesButtonClick"></event>
|
||||||
</object>
|
</object>
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
// C++ code generated with wxFormBuilder (version Jan 1 2016)
|
// C++ code generated with wxFormBuilder (version May 6 2016)
|
||||||
// http://www.wxformbuilder.org/
|
// http://www.wxformbuilder.org/
|
||||||
//
|
//
|
||||||
// PLEASE DO "NOT" EDIT THIS FILE!
|
// PLEASE DO "NOT" EDIT THIS FILE!
|
||||||
|
@ -59,7 +59,6 @@ class DIALOG_GLOBAL_MODULES_FIELDS_EDITION_BASE : public DIALOG_SHIM
|
||||||
wxButton* m_sdbSizerButtonsCancel;
|
wxButton* m_sdbSizerButtonsCancel;
|
||||||
|
|
||||||
// Virtual event handlers, overide them in your derived class
|
// Virtual event handlers, overide them in your derived class
|
||||||
virtual void OnCancelClick( wxCommandEvent& event ) { event.Skip(); }
|
|
||||||
virtual void OnOKClick( wxCommandEvent& event ) { event.Skip(); }
|
virtual void OnOKClick( wxCommandEvent& event ) { event.Skip(); }
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue