Minor changes in dialogs: use wxWidgets default event handlers for wxID_CANCEL and wxID_OK buttons

This commit is contained in:
jean-pierre charras 2016-07-19 19:44:28 +02:00
parent d8eab321f7
commit e10242a0a9
9 changed files with 55 additions and 79 deletions

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Jun 5 2014)
// C++ code generated with wxFormBuilder (version May 6 2016)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
@ -23,7 +23,6 @@ DIALOG_DIMENSION_EDITOR_BASE::DIALOG_DIMENSION_EDITOR_BASE( wxWindow* parent, wx
bSizerMain->Add( m_staticTextDim, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
m_Name = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
m_Name->SetMaxLength( 0 );
m_Name->SetMinSize( wxSize( 400,-1 ) );
bSizerMain->Add( m_Name, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
@ -39,7 +38,6 @@ DIALOG_DIMENSION_EDITOR_BASE::DIALOG_DIMENSION_EDITOR_BASE( wxWindow* parent, wx
bSizerLeft->Add( m_staticTextSizeX, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
m_TxtSizeXCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
m_TxtSizeXCtrl->SetMaxLength( 0 );
bSizerLeft->Add( m_TxtSizeXCtrl, 0, wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 );
m_staticTextSizeY = new wxStaticText( this, wxID_ANY, _("Text Height"), wxDefaultPosition, wxDefaultSize, 0 );
@ -47,7 +45,6 @@ DIALOG_DIMENSION_EDITOR_BASE::DIALOG_DIMENSION_EDITOR_BASE( wxWindow* parent, wx
bSizerLeft->Add( m_staticTextSizeY, 0, wxRIGHT|wxLEFT, 5 );
m_TxtSizeYCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
m_TxtSizeYCtrl->SetMaxLength( 0 );
bSizerLeft->Add( m_TxtSizeYCtrl, 0, wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 );
m_staticTextWidth = new wxStaticText( this, wxID_ANY, _("Text Thickness"), wxDefaultPosition, wxDefaultSize, 0 );
@ -55,7 +52,6 @@ DIALOG_DIMENSION_EDITOR_BASE::DIALOG_DIMENSION_EDITOR_BASE( wxWindow* parent, wx
bSizerLeft->Add( m_staticTextWidth, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
m_TxtWidthCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
m_TxtWidthCtrl->SetMaxLength( 0 );
bSizerLeft->Add( m_TxtWidthCtrl, 0, wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 );
m_staticTextPosX = new wxStaticText( this, wxID_ANY, _("Text Position X"), wxDefaultPosition, wxDefaultSize, 0 );
@ -63,7 +59,6 @@ DIALOG_DIMENSION_EDITOR_BASE::DIALOG_DIMENSION_EDITOR_BASE( wxWindow* parent, wx
bSizerLeft->Add( m_staticTextPosX, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
m_textCtrlPosX = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
m_textCtrlPosX->SetMaxLength( 0 );
bSizerLeft->Add( m_textCtrlPosX, 0, wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 );
m_staticTextPosY = new wxStaticText( this, wxID_ANY, _("Text Position Y"), wxDefaultPosition, wxDefaultSize, 0 );
@ -71,7 +66,6 @@ DIALOG_DIMENSION_EDITOR_BASE::DIALOG_DIMENSION_EDITOR_BASE( wxWindow* parent, wx
bSizerLeft->Add( m_staticTextPosY, 0, wxRIGHT|wxLEFT, 5 );
m_textCtrlPosY = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
m_textCtrlPosY->SetMaxLength( 0 );
bSizerLeft->Add( m_textCtrlPosY, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
@ -119,14 +113,12 @@ DIALOG_DIMENSION_EDITOR_BASE::DIALOG_DIMENSION_EDITOR_BASE( wxWindow* parent, wx
this->Centre( wxBOTH );
// Connect Events
m_sdbSizerBtsCancel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_DIMENSION_EDITOR_BASE::OnCancelClick ), NULL, this );
m_sdbSizerBtsOK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_DIMENSION_EDITOR_BASE::OnOKClick ), NULL, this );
}
DIALOG_DIMENSION_EDITOR_BASE::~DIALOG_DIMENSION_EDITOR_BASE()
{
// Disconnect Events
m_sdbSizerBtsCancel->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_DIMENSION_EDITOR_BASE::OnCancelClick ), NULL, this );
m_sdbSizerBtsOK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_DIMENSION_EDITOR_BASE::OnOKClick ), NULL, this );
}

View File

@ -1532,7 +1532,7 @@
<property name="name">m_sdbSizerBts</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>

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Jun 5 2014)
// C++ code generated with wxFormBuilder (version May 6 2016)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
@ -61,7 +61,6 @@ class DIALOG_DIMENSION_EDITOR_BASE : public DIALOG_SHIM
wxButton* m_sdbSizerBtsCancel;
// Virtual event handlers, overide them in your derived class
virtual void OnCancelClick( wxCommandEvent& event ) { event.Skip(); }
virtual void OnOKClick( wxCommandEvent& event ) { event.Skip(); }

View File

@ -69,8 +69,7 @@ private:
*/
void initDialog();
void OnOkClick( wxCommandEvent& event );
void OnCancelClick( wxCommandEvent& event );
virtual void OnOkClick( wxCommandEvent& event ) override;
/**
* Function AcceptOptionsForKeepOut
@ -95,7 +94,10 @@ ZONE_EDIT_T InvokeKeepoutAreaEditor( PCB_BASE_FRAME* aCaller, ZONE_SETTINGS* aSe
{
DIALOG_KEEPOUT_AREA_PROPERTIES dlg( aCaller, aSettings );
ZONE_EDIT_T result = ZONE_EDIT_T( dlg.ShowModal() );
ZONE_EDIT_T result = ZONE_ABORT;
if( dlg.ShowModal() == wxID_OK )
result = ZONE_OK;
return result;
}
@ -111,13 +113,10 @@ DIALOG_KEEPOUT_AREA_PROPERTIES::DIALOG_KEEPOUT_AREA_PROPERTIES( PCB_BASE_FRAME*
m_ptr = aSettings;
m_zonesettings = *aSettings;
SetReturnCode( ZONE_ABORT ); // Will be changed on button OK click
initDialog();
m_sdbSizerButtonsOK->SetDefault();
GetSizer()->SetSizeHints( this );
Center();
FinishDialogSettings();
}
@ -185,18 +184,12 @@ void DIALOG_KEEPOUT_AREA_PROPERTIES::initDialog()
}
void DIALOG_KEEPOUT_AREA_PROPERTIES::OnCancelClick( wxCommandEvent& event )
{
EndModal( ZONE_ABORT );
}
void DIALOG_KEEPOUT_AREA_PROPERTIES::OnOkClick( wxCommandEvent& event )
{
if( AcceptOptionsForKeepOut() )
{
*m_ptr = m_zonesettings;
EndModal( ZONE_OK );
event.Skip(); // ends returning wxID_OK (default behavior)
}
}

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Jun 5 2014)
// C++ code generated with wxFormBuilder (version May 6 2016)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
@ -10,7 +10,6 @@
///////////////////////////////////////////////////////////////////////////
BEGIN_EVENT_TABLE( DIALOG_KEEPOUT_AREA_PROPERTIES_BASE, DIALOG_SHIM )
EVT_BUTTON( wxID_CANCEL, DIALOG_KEEPOUT_AREA_PROPERTIES_BASE::_wxFB_OnCancelClick )
EVT_BUTTON( wxID_OK, DIALOG_KEEPOUT_AREA_PROPERTIES_BASE::_wxFB_OnOkClick )
END_EVENT_TABLE()
@ -59,13 +58,13 @@ DIALOG_KEEPOUT_AREA_PROPERTIES_BASE::DIALOG_KEEPOUT_AREA_PROPERTIES_BASE( wxWind
wxStaticBoxSizer* sbSizerCutoutOpts;
sbSizerCutoutOpts = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Keepout Options:") ), wxVERTICAL );
m_cbTracksCtrl = new wxCheckBox( this, wxID_ANY, _("No tracks"), wxDefaultPosition, wxDefaultSize, 0 );
m_cbTracksCtrl = new wxCheckBox( sbSizerCutoutOpts->GetStaticBox(), wxID_ANY, _("No tracks"), wxDefaultPosition, wxDefaultSize, 0 );
sbSizerCutoutOpts->Add( m_cbTracksCtrl, 0, wxTOP|wxRIGHT|wxLEFT|wxEXPAND, 5 );
m_cbViasCtrl = new wxCheckBox( this, wxID_ANY, _("No vias"), wxDefaultPosition, wxDefaultSize, 0 );
m_cbViasCtrl = new wxCheckBox( sbSizerCutoutOpts->GetStaticBox(), wxID_ANY, _("No vias"), wxDefaultPosition, wxDefaultSize, 0 );
sbSizerCutoutOpts->Add( m_cbViasCtrl, 0, wxTOP|wxRIGHT|wxLEFT|wxEXPAND, 5 );
m_cbCopperPourCtrl = new wxCheckBox( this, wxID_ANY, _("No copper pour"), wxDefaultPosition, wxDefaultSize, 0 );
m_cbCopperPourCtrl = new wxCheckBox( sbSizerCutoutOpts->GetStaticBox(), wxID_ANY, _("No copper pour"), wxDefaultPosition, wxDefaultSize, 0 );
sbSizerCutoutOpts->Add( m_cbCopperPourCtrl, 0, wxALL|wxEXPAND, 5 );

View File

@ -583,6 +583,7 @@
<property name="minimum_size"></property>
<property name="name">sbSizerCutoutOpts</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">
@ -953,7 +954,7 @@
<property name="name">m_sdbSizerButtons</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>

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Jun 5 2014)
// C++ code generated with wxFormBuilder (version May 6 2016)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
@ -42,7 +42,6 @@ class DIALOG_KEEPOUT_AREA_PROPERTIES_BASE : public DIALOG_SHIM
private:
// Private event handlers
void _wxFB_OnCancelClick( wxCommandEvent& event ){ OnCancelClick( event ); }
void _wxFB_OnOkClick( wxCommandEvent& event ){ OnOkClick( event ); }
@ -61,7 +60,6 @@ class DIALOG_KEEPOUT_AREA_PROPERTIES_BASE : public DIALOG_SHIM
wxButton* m_sdbSizerButtonsCancel;
// Virtual event handlers, overide them in your derived class
virtual void OnCancelClick( wxCommandEvent& event ) { event.Skip(); }
virtual void OnOkClick( wxCommandEvent& event ) { event.Skip(); }

View File

@ -6,9 +6,9 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2016 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 1992-2015 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 1992-2016 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -80,9 +80,9 @@ class DIALOG_DIMENSION_EDITOR : public DIALOG_DIMENSION_EDITOR_BASE
{
private:
PCB_EDIT_FRAME* m_Parent;
PCB_EDIT_FRAME* m_parent;
wxDC* m_DC;
DIMENSION* CurrentDimension;
DIMENSION* m_currentDimension;
public:
@ -94,8 +94,7 @@ public:
private:
void OnCancelClick( wxCommandEvent& event );
void OnOKClick( wxCommandEvent& event );
virtual void OnOKClick( wxCommandEvent& event ) override;
};
@ -105,10 +104,10 @@ DIALOG_DIMENSION_EDITOR::DIALOG_DIMENSION_EDITOR( PCB_EDIT_FRAME* aParent,
{
SetFocus();
m_Parent = aParent;
m_parent = aParent;
m_DC = aDC;
CurrentDimension = aDimension;
m_currentDimension = aDimension;
if( aDimension->Text().IsMirrored() )
m_rbMirror->SetSelection( 1 );
@ -134,14 +133,14 @@ DIALOG_DIMENSION_EDITOR::DIALOG_DIMENSION_EDITOR( PCB_EDIT_FRAME* aParent,
AddUnitSymbol( *m_staticTextPosY );
// Configure the layers list selector
if( !m_Parent->GetBoard()->IsLayerEnabled( aDimension->GetLayer() ) )
if( !m_parent->GetBoard()->IsLayerEnabled( aDimension->GetLayer() ) )
// Should not happens, because one cannot select a board item on a
// not activated layer, but ...
m_SelLayerBox->ShowNonActivatedLayers( true );
m_SelLayerBox->SetLayersHotkeys( false );
m_SelLayerBox->SetLayerSet( LSET::AllCuMask().set( Edge_Cuts ) );
m_SelLayerBox->SetBoardFrame( m_Parent );
m_SelLayerBox->SetBoardFrame( m_parent );
m_SelLayerBox->Resync();
if( m_SelLayerBox->SetLayerSelection( aDimension->GetLayer() ) < 0 )
@ -152,15 +151,11 @@ DIALOG_DIMENSION_EDITOR::DIALOG_DIMENSION_EDITOR( PCB_EDIT_FRAME* aParent,
}
m_sdbSizerBtsOK->SetDefault();
GetSizer()->Fit( this );
GetSizer()->SetSizeHints( this );
Centre();
}
FixOSXCancelButtonIssue();
void DIALOG_DIMENSION_EDITOR::OnCancelClick( wxCommandEvent& event )
{
EndModal( -1 );
// Now all widgets have the size fixed, call FinishDialogSettings
FinishDialogSettings();
}
@ -168,7 +163,7 @@ void DIALOG_DIMENSION_EDITOR::OnOKClick( wxCommandEvent& event )
{
LAYER_ID newlayer = ToLAYER_ID( m_SelLayerBox->GetLayerSelection() );
if( !m_Parent->GetBoard()->IsLayerEnabled( newlayer ) )
if( !m_parent->GetBoard()->IsLayerEnabled( newlayer ) )
{
wxMessageBox( _( "The layer currently selected is not enabled for this board\n"
"You cannot use it" ) );
@ -178,24 +173,24 @@ void DIALOG_DIMENSION_EDITOR::OnOKClick( wxCommandEvent& event )
#ifndef USE_WX_OVERLAY
if( m_DC ) // Delete old text.
{
CurrentDimension->Draw( m_Parent->GetCanvas(), m_DC, GR_XOR );
m_currentDimension->Draw( m_parent->GetCanvas(), m_DC, GR_XOR );
}
#endif
m_Parent->SaveCopyInUndoList(CurrentDimension, UR_CHANGED);
m_parent->SaveCopyInUndoList(m_currentDimension, UR_CHANGED);
if( m_Name->GetValue() != wxEmptyString )
{
CurrentDimension->SetText( m_Name->GetValue() );
m_currentDimension->SetText( m_Name->GetValue() );
}
wxString msg;
// Get new size value:
msg = m_TxtSizeXCtrl->GetValue();
CurrentDimension->Text().SetWidth( ValueFromString( g_UserUnit, msg ) );
m_currentDimension->Text().SetWidth( ValueFromString( g_UserUnit, msg ) );
msg = m_TxtSizeYCtrl->GetValue();
CurrentDimension->Text().SetHeight( ValueFromString( g_UserUnit, msg ) );
m_currentDimension->Text().SetHeight( ValueFromString( g_UserUnit, msg ) );
// Get new position value:
// It will be copied later in dimension, because
@ -204,12 +199,12 @@ void DIALOG_DIMENSION_EDITOR::OnOKClick( wxCommandEvent& event )
pos.x = ValueFromString( g_UserUnit, msg );
msg = m_textCtrlPosY->GetValue();
pos.y = ValueFromString( g_UserUnit, msg );
CurrentDimension->Text().SetTextPosition( pos );
m_currentDimension->Text().SetTextPosition( pos );
// Get new line thickness value:
msg = m_TxtWidthCtrl->GetValue();
int width = ValueFromString( g_UserUnit, msg );
int maxthickness = Clamp_Text_PenSize( width, CurrentDimension->Text().GetSize() );
int maxthickness = Clamp_Text_PenSize( width, m_currentDimension->Text().GetSize() );
if( width > maxthickness )
{
@ -219,39 +214,39 @@ void DIALOG_DIMENSION_EDITOR::OnOKClick( wxCommandEvent& event )
width = maxthickness;
}
CurrentDimension->SetWidth( width );
CurrentDimension->Text().SetThickness( width );
CurrentDimension->Text().SetMirrored( ( m_rbMirror->GetSelection() == 1 ) ? true : false );
CurrentDimension->SetLayer( newlayer );
m_currentDimension->SetWidth( width );
m_currentDimension->Text().SetThickness( width );
m_currentDimension->Text().SetMirrored( ( m_rbMirror->GetSelection() == 1 ) ? true : false );
m_currentDimension->SetLayer( newlayer );
#ifndef USE_WX_OVERLAY
if( m_DC ) // Display new text
{
CurrentDimension->Draw( m_Parent->GetCanvas(), m_DC, GR_OR );
m_currentDimension->Draw( m_parent->GetCanvas(), m_DC, GR_OR );
}
#else
m_Parent->Refresh();
m_parent->Refresh();
#endif
m_Parent->OnModify();
EndModal( 1 );
m_parent->OnModify();
event.Skip(); // ends returning wxID_OK (default behavior)
}
static void AbortBuildDimension( EDA_DRAW_PANEL* Panel, wxDC* aDC )
{
DIMENSION* Dimension = (DIMENSION*) Panel->GetScreen()->GetCurItem();
DIMENSION* dimension = (DIMENSION*) Panel->GetScreen()->GetCurItem();
if( Dimension )
if( dimension )
{
if( Dimension->IsNew() )
if( dimension->IsNew() )
{
Dimension->Draw( Panel, aDC, GR_XOR );
Dimension->DeleteStructure();
dimension->Draw( Panel, aDC, GR_XOR );
dimension->DeleteStructure();
}
else
{
Dimension->Draw( Panel, aDC, GR_OR );
dimension->Draw( Panel, aDC, GR_OR );
}
}
@ -359,9 +354,8 @@ void PCB_EDIT_FRAME::ShowDimensionPropertyDialog( DIMENSION* aDimension, wxDC* a
if( aDimension == NULL )
return;
DIALOG_DIMENSION_EDITOR* frame = new DIALOG_DIMENSION_EDITOR( this, aDimension, aDC );
frame->ShowModal();
frame->Destroy();
DIALOG_DIMENSION_EDITOR dlg( this, aDimension, aDC );
dlg.ShowModal();
}

View File

@ -76,7 +76,7 @@ columnset = compfields | partfields # union
columns = ['Item', 'Qty', 'Reference(s)', 'Value', 'LibPart', 'Footprint', 'Datasheet'] + sorted(list(columnset))
# Create a new csv writer object to use as the output formatter
out = csv.writer( f, lineterminator='\n', delimiter=',', quotechar='\"', quoting=csv.QUOTE_MINIMAL )
out = csv.writer( f, lineterminator='\n', delimiter=',', quotechar='\"', quoting=csv.QUOTE_ALL )
# override csv.writer's writerow() to support encoding conversion (initial encoding is utf8):
def writerow( acsvwriter, columns ):