Remove on-kill-focus-validation.

Fixes: lp:1805361
* https://bugs.launchpad.net/kicad/+bug/1805361
This commit is contained in:
Jeff Young 2018-11-29 18:59:38 +00:00
parent 6d8ca311f8
commit ff6a3482ec
25 changed files with 130 additions and 170 deletions

View File

@ -120,10 +120,8 @@ void EDA_DRAW_FRAME::Process_PageSettings( wxCommandEvent& event )
DIALOG_PAGES_SETTINGS::DIALOG_PAGES_SETTINGS( EDA_DRAW_FRAME* parent, wxSize aMaxUserSizeMils ) :
DIALOG_PAGES_SETTINGS_BASE( parent ),
m_initialized( false ),
m_customSizeX( parent, m_userSizeXLabel, m_userSizeXCtrl, m_userSizeXUnits, false,
MIN_PAGE_SIZE * IU_PER_MILS, aMaxUserSizeMils.x * IU_PER_MILS ),
m_customSizeY( parent, m_userSizeYLabel, m_userSizeYCtrl, m_userSizeYUnits, false,
MIN_PAGE_SIZE * IU_PER_MILS, aMaxUserSizeMils.y * IU_PER_MILS )
m_customSizeX( parent, m_userSizeXLabel, m_userSizeXCtrl, m_userSizeXUnits, false ),
m_customSizeY( parent, m_userSizeYLabel, m_userSizeYCtrl, m_userSizeYUnits, false )
{
m_parent = parent;
m_screen = m_parent->GetScreen();
@ -234,6 +232,12 @@ void DIALOG_PAGES_SETTINGS::initDialog()
void DIALOG_PAGES_SETTINGS::OnOkClick( wxCommandEvent& event )
{
if( !m_customSizeX.Validate( Mils2iu( MIN_PAGE_SIZE ), Mils2iu( m_maxPageSizeMils.x ) ) )
return;
if( !m_customSizeY.Validate( Mils2iu( MIN_PAGE_SIZE ), Mils2iu( m_maxPageSizeMils.y ) ) )
return;
if( SavePageSettings() )
{
m_screen->SetModify();
@ -423,7 +427,7 @@ void DIALOG_PAGES_SETTINGS::OnDateApplyClick( wxCommandEvent& event )
bool DIALOG_PAGES_SETTINGS::SavePageSettings()
{
bool retSuccess = false;
bool success = false;
wxString fileName = GetWksFileName();
@ -453,13 +457,10 @@ bool DIALOG_PAGES_SETTINGS::SavePageSettings()
{
GetCustomSizeMilsFromDialog();
retSuccess = m_pageInfo.SetType( PAGE_INFO::Custom );
success = m_pageInfo.SetType( PAGE_INFO::Custom );
if( retSuccess )
if( success )
{
if( !m_customSizeX.Validate( true ) || !m_customSizeY.Validate( true ) )
return false;
PAGE_INFO::SetCustomWidthMils( m_layout_size.x );
PAGE_INFO::SetCustomHeightMils( m_layout_size.y );
@ -471,42 +472,42 @@ bool DIALOG_PAGES_SETTINGS::SavePageSettings()
{
// search for longest common string first, e.g. A4 before A
if( paperType.Contains( PAGE_INFO::USLetter ) )
retSuccess = m_pageInfo.SetType( PAGE_INFO::USLetter );
success = m_pageInfo.SetType( PAGE_INFO::USLetter );
else if( paperType.Contains( PAGE_INFO::USLegal ) )
retSuccess = m_pageInfo.SetType( PAGE_INFO::USLegal );
success = m_pageInfo.SetType( PAGE_INFO::USLegal );
else if( paperType.Contains( PAGE_INFO::USLedger ) )
retSuccess = m_pageInfo.SetType( PAGE_INFO::USLedger );
success = m_pageInfo.SetType( PAGE_INFO::USLedger );
else if( paperType.Contains( PAGE_INFO::GERBER ) )
retSuccess = m_pageInfo.SetType( PAGE_INFO::GERBER );
success = m_pageInfo.SetType( PAGE_INFO::GERBER );
else if( paperType.Contains( PAGE_INFO::A4 ) )
retSuccess = m_pageInfo.SetType( PAGE_INFO::A4 );
success = m_pageInfo.SetType( PAGE_INFO::A4 );
else if( paperType.Contains( PAGE_INFO::A3 ) )
retSuccess = m_pageInfo.SetType( PAGE_INFO::A3 );
success = m_pageInfo.SetType( PAGE_INFO::A3 );
else if( paperType.Contains( PAGE_INFO::A2 ) )
retSuccess = m_pageInfo.SetType( PAGE_INFO::A2 );
success = m_pageInfo.SetType( PAGE_INFO::A2 );
else if( paperType.Contains( PAGE_INFO::A1 ) )
retSuccess = m_pageInfo.SetType( PAGE_INFO::A1 );
success = m_pageInfo.SetType( PAGE_INFO::A1 );
else if( paperType.Contains( PAGE_INFO::A0 ) )
retSuccess = m_pageInfo.SetType( PAGE_INFO::A0 );
success = m_pageInfo.SetType( PAGE_INFO::A0 );
else if( paperType.Contains( PAGE_INFO::A ) )
retSuccess = m_pageInfo.SetType( PAGE_INFO::A );
success = m_pageInfo.SetType( PAGE_INFO::A );
else if( paperType.Contains( PAGE_INFO::B ) )
retSuccess = m_pageInfo.SetType( PAGE_INFO::B );
success = m_pageInfo.SetType( PAGE_INFO::B );
else if( paperType.Contains( PAGE_INFO::C ) )
retSuccess = m_pageInfo.SetType( PAGE_INFO::C );
success = m_pageInfo.SetType( PAGE_INFO::C );
else if( paperType.Contains( PAGE_INFO::D ) )
retSuccess = m_pageInfo.SetType( PAGE_INFO::D );
success = m_pageInfo.SetType( PAGE_INFO::D );
else if( paperType.Contains( PAGE_INFO::E ) )
retSuccess = m_pageInfo.SetType( PAGE_INFO::E );
success = m_pageInfo.SetType( PAGE_INFO::E );
if( retSuccess )
if( success )
{
int choice = m_orientationComboBox->GetSelection();
m_pageInfo.SetPortrait( choice != 0 );
}
}
if( !retSuccess )
if( !success )
{
wxASSERT_MSG( false, _( "the translation for paper size must preserve original spellings" ) );
m_pageInfo.SetType( PAGE_INFO::A4 );

View File

@ -35,7 +35,7 @@ wxDEFINE_EVENT( DELAY_FOCUS, wxCommandEvent );
UNIT_BINDER::UNIT_BINDER( EDA_DRAW_FRAME* aParent,
wxStaticText* aLabel, wxWindow* aValue, wxStaticText* aUnitLabel,
bool aUseMils, int aMin, int aMax, bool allowEval ) :
bool aUseMils, bool allowEval ) :
m_label( aLabel ),
m_value( aValue ),
m_unitLabel( aUnitLabel ),
@ -44,8 +44,6 @@ UNIT_BINDER::UNIT_BINDER( EDA_DRAW_FRAME* aParent,
// Fix the units (to the current units) for the life of the binder
m_units = aParent->GetUserUnits();
m_useMils = aUseMils;
m_min = aMin;
m_max = aMax;
m_allowEval = allowEval && dynamic_cast<wxTextEntry*>( m_value );
m_needsEval = false;
@ -92,24 +90,14 @@ void UNIT_BINDER::onSetFocus( wxFocusEvent& aEvent )
void UNIT_BINDER::onKillFocus( wxFocusEvent& aEvent )
{
if( aEvent.GetWindow() && aEvent.GetWindow()->GetId() == wxID_CANCEL )
auto textEntry = dynamic_cast<wxTextEntry*>( m_value );
if( m_allowEval && textEntry )
{
// Don't eval or validate when focus lost due to Cancel. While most platforms
// suppress KillFocus events after a Cancel, MSW (at least) does not.
}
else
{
auto textEntry = dynamic_cast<wxTextEntry*>( m_value );
if( m_eval.Process( textEntry->GetValue() ) )
textEntry->ChangeValue( m_eval.Result() );
if( m_allowEval && textEntry )
{
if( m_eval.Process( textEntry->GetValue() ) )
textEntry->ChangeValue( m_eval.Result() );
m_needsEval = false;
}
Validate( true );
m_needsEval = false;
}
aEvent.Skip();
@ -127,31 +115,26 @@ wxString valueDescriptionFromLabel( wxStaticText* aLabel )
void UNIT_BINDER::delayedFocusHandler( wxCommandEvent& )
{
// Kill focus event handler must be temporarily disconnected, as displaying a message box
// will trigger the event handler and validation again, effectively creating an infinite loop
m_value->Disconnect( wxEVT_KILL_FOCUS, wxFocusEventHandler( UNIT_BINDER::onKillFocus ), NULL, this );
if( !m_errorMessage.IsEmpty() )
DisplayError( m_value->GetParent(), m_errorMessage );
m_errorMessage = wxEmptyString;
m_value->SetFocus();
m_value->Connect( wxEVT_KILL_FOCUS, wxFocusEventHandler( UNIT_BINDER::onKillFocus ), NULL, this );
}
bool UNIT_BINDER::Validate( bool setFocusOnError )
bool UNIT_BINDER::Validate( int aMin, int aMax, bool setFocusOnError )
{
auto textEntry = dynamic_cast<wxTextEntry*>( m_value );
if( !textEntry || textEntry->GetValue() == INDETERMINATE )
return true;
if( m_min > INT_MIN && GetValue() < m_min )
if( GetValue() < aMin )
{
m_errorMessage = wxString::Format( _( "%s must be larger than %s or equal." ),
m_errorMessage = wxString::Format( _( "%s must be at least %s." ),
valueDescriptionFromLabel( m_label ),
StringFromValue( m_units, m_min, true ) );
StringFromValue( m_units, aMin, true ) );
if( setFocusOnError )
{
@ -163,11 +146,11 @@ bool UNIT_BINDER::Validate( bool setFocusOnError )
return false;
}
if( m_max < INT_MAX && GetValue() > m_max )
if( GetValue() > aMax )
{
m_errorMessage = wxString::Format( _( "%s must be smaller than %s." ),
m_errorMessage = wxString::Format( _( "%s must be less than %s." ),
valueDescriptionFromLabel( m_label ),
StringFromValue( m_units, m_max, true ) );
StringFromValue( m_units, aMax, true ) );
if( setFocusOnError )
{

View File

@ -101,14 +101,14 @@ void SCH_EDIT_FRAME::EditSchematicText( SCH_TEXT* aTextItem )
}
// Conservative limits 0.01 to 250mm
const int minSize = (int)( 0.01 * IU_PER_MM );
const int maxSize = (int)( 250 * IU_PER_MM );
// Don't allow text to disappear; it can be difficult to correct if you can't select it
const int MIN_TEXTSIZE = (int)( 0.01 * IU_PER_MM );
const int MAX_TEXTSIZE = INT_MAX;
DIALOG_LABEL_EDITOR::DIALOG_LABEL_EDITOR( SCH_EDIT_FRAME* aParent, SCH_TEXT* aTextItem ) :
DIALOG_LABEL_EDITOR_BASE( aParent ),
m_textSize( aParent, m_textSizeLabel, m_textSizeCtrl, m_textSizeUnits, false, minSize, maxSize )
m_textSize( aParent, m_textSizeLabel, m_textSizeCtrl, m_textSizeUnits, false )
{
m_Parent = aParent;
m_CurrentText = aTextItem;
@ -291,6 +291,9 @@ bool DIALOG_LABEL_EDITOR::TransferDataFromWindow()
if( !wxDialog::TransferDataFromWindow() )
return false;
if( !m_textSize.Validate( MIN_TEXTSIZE, MAX_TEXTSIZE ) )
return false;
wxString text;
/* save old text in undo list if not already in edit */

View File

@ -35,7 +35,7 @@ DIALOG_EDIT_LINE_STYLE::DIALOG_EDIT_LINE_STYLE( SCH_EDIT_FRAME* aParent, SCH_LIN
DIALOG_EDIT_LINE_STYLE_BASE( aParent ),
m_frame( aParent ),
m_line( aLine ),
m_width( aParent, m_staticTextWidth, m_lineWidth, m_staticWidthUnits, true, 0 )
m_width( aParent, m_staticTextWidth, m_lineWidth, m_staticWidthUnits, true )
{
m_sdbSizerApply->SetLabel( _( "Default" ) );

View File

@ -79,7 +79,7 @@ DIALOG_EDIT_ONE_FIELD::DIALOG_EDIT_ONE_FIELD( SCH_BASE_FRAME* aParent, const wxS
DIALOG_LIB_EDIT_TEXT_BASE( aParent ),
m_posX( aParent, m_xPosLabel, m_xPosCtrl, m_xPosUnits, true ),
m_posY( aParent, m_yPosLabel, m_yPosCtrl, m_yPosUnits, true ),
m_textSize( aParent, m_textSizeLabel, m_textSizeCtrl, m_textSizeUnits, true, 0 )
m_textSize( aParent, m_textSizeLabel, m_textSizeCtrl, m_textSizeUnits, true )
{
SetTitle( aTitle );

View File

@ -34,7 +34,7 @@ DIALOG_LIB_EDIT_DRAW_ITEM::DIALOG_LIB_EDIT_DRAW_ITEM( LIB_EDIT_FRAME* aParent, L
DIALOG_LIB_EDIT_DRAW_ITEM_BASE( aParent ),
m_frame( aParent ),
m_item( aItem ),
m_lineWidth( aParent, m_widthLabel, m_widthCtrl, m_widthUnits, true, 0 )
m_lineWidth( aParent, m_widthLabel, m_widthCtrl, m_widthUnits, true )
{
SetTitle( aItem->GetTypeName() + wxT( " " ) + GetTitle() );

View File

@ -41,9 +41,9 @@ DIALOG_LIB_EDIT_PIN::DIALOG_LIB_EDIT_PIN( LIB_EDIT_FRAME* parent, LIB_PIN* aPin
m_pin( aPin ),
m_posX( parent, m_posXLabel, m_posXCtrl, m_posXUnits, true ),
m_posY( parent, m_posYLabel, m_posYCtrl, m_posYUnits, true ),
m_pinLength( parent, m_pinLengthLabel, m_pinLengthCtrl, m_pinLengthUnits, true, 0 ),
m_nameSize( parent, m_nameSizeLabel, m_nameSizeCtrl, m_nameSizeUnits, true, 0 ),
m_numberSize( parent, m_numberSizeLabel, m_numberSizeCtrl, m_numberSizeUnits, true, 0 )
m_pinLength( parent, m_pinLengthLabel, m_pinLengthCtrl, m_pinLengthUnits, true ),
m_nameSize( parent, m_nameSizeLabel, m_nameSizeCtrl, m_nameSizeUnits, true ),
m_numberSize( parent, m_numberSizeLabel, m_numberSizeCtrl, m_numberSizeUnits, true )
{
// Creates a dummy pin to show on a panel, inside this dialog:
m_dummyPin = new LIB_PIN( *m_pin );

View File

@ -35,7 +35,7 @@ DIALOG_LIB_EDIT_TEXT::DIALOG_LIB_EDIT_TEXT( LIB_EDIT_FRAME* aParent, LIB_TEXT* a
DIALOG_LIB_EDIT_TEXT_BASE( aParent ),
m_posX( aParent, m_xPosLabel, m_xPosCtrl, m_xPosUnits, true ),
m_posY( aParent, m_yPosLabel, m_yPosCtrl, m_yPosUnits, true ),
m_textSize( aParent, m_textSizeLabel, m_textSizeCtrl, m_textSizeUnits, true, 0 )
m_textSize( aParent, m_textSizeLabel, m_textSizeCtrl, m_textSizeUnits, true )
{
m_parent = aParent;
m_graphicText = aText;

View File

@ -49,15 +49,11 @@ public:
* wxComboBox, wxStaticText, etc.).
* @param aUnitLabel is the units label displayed after the text input widget
* @param aUseMils specifies the use of mils for imperial units (instead of inches)
* @param aMin a minimum value (in internal units) for validation
* @param aMax a maximum value (in internal units) for validation
* @param aAllowEval indicates \a aTextInput's content should be eval'ed before storing
*/
UNIT_BINDER( EDA_DRAW_FRAME* aParent,
wxStaticText* aLabel, wxWindow* aValue, wxStaticText* aUnitLabel,
bool aUseMils = false,
int aMin = INT_MIN, int aMax = INT_MAX,
bool aAllowEval = true );
bool aUseMils = false, bool aAllowEval = true );
/**
* Function SetUnits
@ -66,24 +62,6 @@ public:
*/
virtual void SetUnits( EDA_UNITS_T aUnits, bool aUseMils = false );
/**
* Set the minimal accepted value (in Internal Units).
*/
void SetMin( int aMin )
{
wxASSERT( aMin < m_max );
m_min = aMin;
}
/**
* Set the maximal accepted value (in Internal Units).
*/
void SetMax( int aMax )
{
wxASSERT( aMax > m_min );
m_max = aMax;
}
/**
* Function SetValue
* Sets new value (in Internal Units) for the text field, taking care of units conversion.
@ -118,12 +96,13 @@ public:
/**
* Function Validate
* Validates the control, informing the user of any errors found.
* Validates the control against the given range, informing the user of any errors found.
*
* When called from an OK handler, \a setFocusOnError should be set to true. A negative
* return value indicates an error.
* @param aMin a minimum value (in internal units) for validation
* @param aMax a maximum value (in internal units) for validation
* @return false on error.
*/
virtual bool Validate( bool setFocusOnError = false );
virtual bool Validate( int aMin, int aMax, bool setFocusOnError = true );
void SetLabel( const wxString& aLabel );
@ -155,8 +134,6 @@ protected:
bool m_useMils;
///> Validation support.
int m_min;
int m_max;
wxString m_errorMessage;
///> Evaluator

View File

@ -60,6 +60,10 @@ enum VIATYPE_T
#define MIN_VIA_DRAW_SIZE 4 /// Minimum size in pixel for full drawing
// Used for tracks and vias for algorithmic safety, not to enforce constraints
#define GEOMETRY_MIN_SIZE ( int )( 0.001 * IU_PER_MM )
/**
* Function GetTrack
* is a helper function to locate a trace segment having an end point at \a aPosition

View File

@ -99,11 +99,11 @@ int InvokeCopperZonesEditor( PCB_BASE_FRAME* aCaller, ZONE_SETTINGS* aSettings )
DIALOG_COPPER_ZONE::DIALOG_COPPER_ZONE( PCB_BASE_FRAME* aParent, ZONE_SETTINGS* aSettings ) :
DIALOG_COPPER_ZONE_BASE( aParent ),
m_cornerSmoothingType( ZONE_SETTINGS::SMOOTHING_UNDEFINED ),
m_cornerRadius( aParent, m_cornerRadiusLabel, m_cornerRadiusCtrl, m_cornerRadiusUnits, true, 0 ),
m_clearance( aParent, m_clearanceLabel, m_clearanceCtrl, m_clearanceUnits, true, 0, ZONE_CLEARANCE_MAX_VALUE_MIL*IU_PER_MILS ),
m_minWidth( aParent, m_minWidthLabel, m_minWidthCtrl, m_minWidthUnits, true, ZONE_THICKNESS_MIN_VALUE_MIL*IU_PER_MILS ),
m_antipadClearance( aParent, m_antipadLabel, m_antipadCtrl, m_antipadUnits, true, 0 ),
m_spokeWidth( aParent, m_spokeWidthLabel, m_spokeWidthCtrl, m_spokeWidthUnits, true, 0 )
m_cornerRadius( aParent, m_cornerRadiusLabel, m_cornerRadiusCtrl, m_cornerRadiusUnits, true ),
m_clearance( aParent, m_clearanceLabel, m_clearanceCtrl, m_clearanceUnits, true ),
m_minWidth( aParent, m_minWidthLabel, m_minWidthCtrl, m_minWidthUnits, true ),
m_antipadClearance( aParent, m_antipadLabel, m_antipadCtrl, m_antipadUnits, true ),
m_spokeWidth( aParent, m_spokeWidthLabel, m_spokeWidthCtrl, m_spokeWidthUnits, true )
{
m_Parent = aParent;
m_Config = Kiface().KifaceSettings();
@ -225,6 +225,15 @@ void DIALOG_COPPER_ZONE::OnClose( wxCloseEvent& event )
bool DIALOG_COPPER_ZONE::AcceptOptions( bool aUseExportableSetupOnly )
{
if( !m_clearance.Validate( 0, Mils2iu( ZONE_CLEARANCE_MAX_VALUE_MIL ) ) )
return false;
if( !m_minWidth.Validate( Mils2iu( ZONE_THICKNESS_MIN_VALUE_MIL ), INT_MAX ) )
return false;
if( !m_cornerRadius.Validate( 0, INT_MAX ) )
return false;
if( !m_spokeWidth.Validate( 0, INT_MAX ) )
return false;
if( m_settings.m_FillMode == ZFM_SEGMENTS )
{
KIDIALOG dlg( this, _( "The legacy segment fill mode is not recommended."
@ -260,12 +269,8 @@ bool DIALOG_COPPER_ZONE::AcceptOptions( bool aUseExportableSetupOnly )
m_netNameShowFilter = m_ShowNetNameFilter->GetValue();
if( !m_clearance.Validate( true ) )
return false;
m_settings.m_ZoneClearance = m_clearance.GetValue();
if( !m_minWidth.Validate( true ) )
return false;
m_settings.m_ZoneMinThickness = m_minWidth.GetValue();
m_settings.SetCornerSmoothingType( m_cornerSmoothingChoice->GetSelection() );

View File

@ -576,7 +576,7 @@ bool DIALOG_FOOTPRINT_BOARD_EDITOR::Validate()
}
}
if( !m_netClearance.Validate( true ) )
if( !m_netClearance.Validate( 0, INT_MAX ) )
return false;
return true;

View File

@ -59,7 +59,7 @@ int DIALOG_FOOTPRINT_FP_EDITOR::m_page = 0; // remember the last open page d
DIALOG_FOOTPRINT_FP_EDITOR::DIALOG_FOOTPRINT_FP_EDITOR( FOOTPRINT_EDIT_FRAME* aParent,
MODULE* aModule ) :
DIALOG_FOOTPRINT_FP_EDITOR_BASE( aParent ),
m_netClearance( aParent, m_NetClearanceLabel, m_NetClearanceCtrl, m_NetClearanceUnits, false, 0 ),
m_netClearance( aParent, m_NetClearanceLabel, m_NetClearanceCtrl, m_NetClearanceUnits, false ),
m_solderMask( aParent, m_SolderMaskMarginLabel, m_SolderMaskMarginCtrl, m_SolderMaskMarginUnits ),
m_solderPaste( aParent, m_SolderPasteMarginLabel, m_SolderPasteMarginCtrl, m_SolderPasteMarginUnits ),
m_inSelect( false )
@ -528,7 +528,7 @@ bool DIALOG_FOOTPRINT_FP_EDITOR::Validate()
}
}
if( !m_netClearance.Validate( true ) )
if( !m_netClearance.Validate( 0, INT_MAX ) )
return false;
return true;

View File

@ -81,18 +81,12 @@ private:
#define PLOTSVG_LAYERBASE wxT( "PlotSVGLayer_%d" )
#define PLOTSVG_DIR_KEY wxT( "PlotSVGDirectory" )
// reasonable values for default pen width
#define WIDTH_MAX_VALUE (2 * IU_PER_MM)
#define WIDTH_MIN_VALUE (0.05 * IU_PER_MM)
/*
* DIALOG_EXPORT_SVG functions
*/
DIALOG_EXPORT_SVG::DIALOG_EXPORT_SVG( PCB_BASE_FRAME* aParent, BOARD* aBoard ) :
DIALOG_EXPORT_SVG_BASE( aParent ),
m_lineWidth( aParent, m_penWidthLabel, m_penWidthCtrl, m_penWidthUnits, true,
WIDTH_MIN_VALUE, WIDTH_MAX_VALUE)
m_lineWidth( aParent, m_penWidthLabel, m_penWidthCtrl, m_penWidthUnits, true )
{
m_board = aBoard;
m_config = Kiface().KifaceSettings();

View File

@ -103,10 +103,10 @@ protected:
DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS( PCB_EDIT_FRAME* parent ) :
DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS_BASE( parent ),
m_lineWidth( parent, m_lineWidthLabel, m_LineWidthCtrl, m_lineWidthUnits, true, 0 ),
m_textWidth( parent, m_SizeXlabel, m_SizeXCtrl, m_SizeXunit, true, TEXTS_MIN_SIZE ),
m_textHeight( parent, m_SizeYlabel, m_SizeYCtrl, m_SizeYunit, true, TEXTS_MIN_SIZE ),
m_thickness( parent, m_ThicknessLabel, m_ThicknessCtrl, m_ThicknessUnit, true, 0 )
m_lineWidth( parent, m_lineWidthLabel, m_LineWidthCtrl, m_lineWidthUnits, true ),
m_textWidth( parent, m_SizeXlabel, m_SizeXCtrl, m_SizeXunit, true ),
m_textHeight( parent, m_SizeYlabel, m_SizeYCtrl, m_SizeYunit, true ),
m_thickness( parent, m_ThicknessLabel, m_ThicknessCtrl, m_ThicknessUnit, true )
{
m_parent = parent;
m_brdSettings = &m_parent->GetDesignSettings();
@ -315,9 +315,11 @@ void DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::visitItem( BOARD_COMMIT& aCommit, BOA
bool DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::TransferDataFromWindow()
{
if( !m_textWidth.Validate( true ) || !m_textHeight.Validate( true ) ||
!m_thickness.Validate( true ) || !m_lineWidth.Validate( true ) )
if( !m_textWidth.Validate( TEXTS_MIN_SIZE, TEXTS_MAX_SIZE )
|| !m_textHeight.Validate( TEXTS_MIN_SIZE, TEXTS_MAX_SIZE ) )
{
return false;
}
BOARD_COMMIT commit( m_parent );

View File

@ -66,7 +66,7 @@ int InvokeNonCopperZonesEditor( PCB_BASE_FRAME* aParent, ZONE_SETTINGS* aSetting
DIALOG_NON_COPPER_ZONES_EDITOR::DIALOG_NON_COPPER_ZONES_EDITOR( PCB_BASE_FRAME* aParent,
ZONE_SETTINGS* aSettings ) :
DIALOG_NONCOPPER_ZONES_PROPERTIES_BASE( aParent ),
m_minWidth( aParent, m_MinWidthLabel, m_MinWidthCtrl, m_MinWidthUnits, true, 10*IU_PER_MILS )
m_minWidth( aParent, m_MinWidthLabel, m_MinWidthCtrl, m_MinWidthUnits, true )
{
m_parent = aParent;

View File

@ -113,14 +113,14 @@ DIALOG_PAD_PROPERTIES::DIALOG_PAD_PROPERTIES( PCB_BASE_FRAME* aParent, D_PAD* aP
m_padToDie( aParent, m_padToDieLabel, m_padToDieCtrl, m_padToDieUnits, true ),
m_trapDelta( aParent, m_trapDeltaLabel, m_trapDeltaCtrl, m_trapDeltaUnits, true ),
m_cornerRadius( aParent, m_cornerRadiusLabel, m_tcCornerRadius, m_cornerRadiusUnits, true ),
m_holeX( aParent, m_holeXLabel, m_holeXCtrl, m_holeXUnits, true, 0 ),
m_holeY( aParent, m_holeYLabel, m_holeYCtrl, m_holeYUnits, true, 0 ),
m_holeX( aParent, m_holeXLabel, m_holeXCtrl, m_holeXUnits, true ),
m_holeY( aParent, m_holeYLabel, m_holeYCtrl, m_holeYUnits, true ),
m_OrientValidator( 1, &m_OrientValue ),
m_clearance( aParent, m_clearanceLabel, m_clearanceCtrl, m_clearanceUnits, true ),
m_maskClearance( aParent, m_maskClearanceLabel, m_maskClearanceCtrl, m_maskClearanceUnits, true ),
m_pasteClearance( aParent, m_pasteClearanceLabel, m_pasteClearanceCtrl, m_pasteClearanceUnits, true ),
m_spokeWidth( aParent, m_spokeWidthLabel, m_spokeWidthCtrl, m_spokeWidthUnits, true, 0 ),
m_thermalGap( aParent, m_thermalGapLabel, m_thermalGapCtrl, m_thermalGapUnits, true, 0 )
m_spokeWidth( aParent, m_spokeWidthLabel, m_spokeWidthCtrl, m_spokeWidthUnits, true ),
m_thermalGap( aParent, m_thermalGapLabel, m_thermalGapCtrl, m_thermalGapUnits, true )
{
m_currentPad = aPad; // aPad can be NULL, if the dialog is called
// from the footprint editor to set default pad setup
@ -1543,6 +1543,8 @@ bool DIALOG_PAD_PROPERTIES::transferDataToPad( D_PAD* aPad )
return true;
if( !m_localSettingsPanel->Validate() )
return true;
if( !m_spokeWidth.Validate( 0, INT_MAX ) )
return false;
m_OrientValidator.TransferFromWindow();

View File

@ -39,8 +39,8 @@
DIALOG_PLOT::DIALOG_PLOT( PCB_EDIT_FRAME* aParent ) :
DIALOG_PLOT_BASE( aParent ), m_parent( aParent ),
m_defaultLineWidth( aParent, m_lineWidthLabel, m_lineWidthCtrl, m_lineWidthUnits, true, 0 ),
m_defaultPenSize( aParent, m_hpglPenLabel, m_hpglPenCtrl, m_hpglPenUnits, true, 0 ),
m_defaultLineWidth( aParent, m_lineWidthLabel, m_lineWidthCtrl, m_lineWidthUnits, true ),
m_defaultPenSize( aParent, m_hpglPenLabel, m_hpglPenCtrl, m_hpglPenUnits, true ),
m_trackWidthCorrection( aParent, m_widthAdjustLabel, m_widthAdjustCtrl, m_widthAdjustUnits, true )
{
SetName( DLG_WINDOW_NAME );

View File

@ -32,8 +32,8 @@
DIALOG_PNS_DIFF_PAIR_DIMENSIONS::DIALOG_PNS_DIFF_PAIR_DIMENSIONS( EDA_DRAW_FRAME* aParent,
PNS::SIZES_SETTINGS& aSizes ) :
DIALOG_PNS_DIFF_PAIR_DIMENSIONS_BASE( aParent ),
m_traceWidth( aParent, m_traceWidthLabel, m_traceWidthText, m_traceWidthUnit, true, 0 ),
m_traceGap( aParent, m_traceGapLabel, m_traceGapText, m_traceGapUnit, true, 0 ),
m_traceWidth( aParent, m_traceWidthLabel, m_traceWidthText, m_traceWidthUnit, true ),
m_traceGap( aParent, m_traceGapLabel, m_traceGapText, m_traceGapUnit, true ),
m_viaGap( aParent, m_viaGapLabel, m_viaGapText, m_viaGapUnit, true ),
m_sizes( aSizes )
{

View File

@ -73,10 +73,8 @@ DIALOG_SET_GRID::DIALOG_SET_GRID( PCB_BASE_FRAME* aParent, const wxArrayString&
m_fast_grid_opts( aGridChoices ),
m_gridOriginX( aParent, m_staticTextGridPosX, m_GridOriginXCtrl, m_TextPosXUnits ),
m_gridOriginY( aParent, m_staticTextGridPosY, m_GridOriginYCtrl, m_TextPosYUnits ),
m_userGridX( aParent, m_staticTextSizeX, m_OptGridSizeX, m_TextSizeXUnits,
true, MIN_GRID_SIZE, MAX_GRID_SIZE ),
m_userGridY( aParent, m_staticTextSizeY, m_OptGridSizeY, m_TextSizeYUnits,
true, MIN_GRID_SIZE, MAX_GRID_SIZE )
m_userGridX( aParent, m_staticTextSizeX, m_OptGridSizeX, m_TextSizeXUnits ),
m_userGridY( aParent, m_staticTextSizeY, m_OptGridSizeY, m_TextSizeYUnits )
{
m_comboBoxGrid1->Append( m_fast_grid_opts );
m_comboBoxGrid2->Append( m_fast_grid_opts );
@ -94,16 +92,10 @@ DIALOG_SET_GRID::DIALOG_SET_GRID( PCB_BASE_FRAME* aParent, const wxArrayString&
bool DIALOG_SET_GRID::TransferDataFromWindow()
{
// Validate new settings
if( !m_gridOriginX.Validate( true ) )
if( !m_userGridX.Validate( MIN_GRID_SIZE, MAX_GRID_SIZE ) )
return false;
if( !m_gridOriginY.Validate( true ) )
return false;
if( !m_userGridX.Validate( true ) )
return false;
if( !m_userGridY.Validate( true ) )
if( !m_userGridY.Validate( MIN_GRID_SIZE, MAX_GRID_SIZE ) )
return false;
// Apply the new settings

View File

@ -54,9 +54,9 @@ DIALOG_TEXT_PROPERTIES::DIALOG_TEXT_PROPERTIES( PCB_BASE_EDIT_FRAME* aParent, BO
DIALOG_TEXT_PROPERTIES_BASE( aParent ),
m_Parent( aParent ), m_DC( aDC ), m_item( aItem ),
m_edaText( nullptr ), m_modText( nullptr ), m_pcbText( nullptr ),
m_textWidth( aParent, m_SizeXLabel, m_SizeXCtrl, m_SizeXUnits, true, TEXTS_MIN_SIZE ),
m_textHeight( aParent, m_SizeYLabel, m_SizeYCtrl, m_SizeYUnits, true, TEXTS_MIN_SIZE ),
m_thickness( aParent, m_ThicknessLabel, m_ThicknessCtrl, m_ThicknessUnits, true, 0 ),
m_textWidth( aParent, m_SizeXLabel, m_SizeXCtrl, m_SizeXUnits, true ),
m_textHeight( aParent, m_SizeYLabel, m_SizeYCtrl, m_SizeYUnits, true ),
m_thickness( aParent, m_ThicknessLabel, m_ThicknessCtrl, m_ThicknessUnits, true ),
m_posX( aParent, m_PositionXLabel, m_PositionXCtrl, m_PositionXUnits ),
m_posY( aParent, m_PositionYLabel, m_PositionYCtrl, m_PositionYUnits ),
m_OrientValidator( 1, &m_OrientValue )
@ -315,10 +315,8 @@ bool DIALOG_TEXT_PROPERTIES::TransferDataFromWindow()
return false;
}
if( !m_textWidth.Validate( true ) || !m_textHeight.Validate( true ) )
return false;
if( !m_thickness.Validate( true ) )
if( !m_textWidth.Validate( TEXTS_MIN_SIZE, TEXTS_MAX_SIZE )
|| !m_textHeight.Validate( TEXTS_MIN_SIZE, TEXTS_MAX_SIZE ) )
return false;
BOARD_COMMIT commit( m_Parent );

View File

@ -34,8 +34,6 @@
#include <widgets/net_selector.h>
#include <board_commit.h>
#define MIN_SIZE ( int )( 0.001 * IU_PER_MM )
DIALOG_TRACK_VIA_PROPERTIES::DIALOG_TRACK_VIA_PROPERTIES( PCB_BASE_FRAME* aParent,
const SELECTION& aItems,
COMMIT& aCommit ) :
@ -47,11 +45,11 @@ DIALOG_TRACK_VIA_PROPERTIES::DIALOG_TRACK_VIA_PROPERTIES( PCB_BASE_FRAME* aParen
m_trackStartY( aParent, m_TrackStartYLabel, m_TrackStartYCtrl, m_TrackStartYUnit ),
m_trackEndX( aParent, m_TrackEndXLabel, m_TrackEndXCtrl, m_TrackEndXUnit ),
m_trackEndY( aParent, m_TrackEndYLabel, m_TrackEndYCtrl, m_TrackEndYUnit ),
m_trackWidth( aParent, m_TrackWidthLabel, m_TrackWidthCtrl, m_TrackWidthUnit, true, MIN_SIZE ),
m_trackWidth( aParent, m_TrackWidthLabel, m_TrackWidthCtrl, m_TrackWidthUnit, true ),
m_viaX( aParent, m_ViaXLabel, m_ViaXCtrl, m_ViaXUnit ),
m_viaY( aParent, m_ViaYLabel, m_ViaYCtrl, m_ViaYUnit ),
m_viaDiameter( aParent, m_ViaDiameterLabel, m_ViaDiameterCtrl, m_ViaDiameterUnit, true, MIN_SIZE ),
m_viaDrill( aParent, m_ViaDrillLabel, m_ViaDrillCtrl, m_ViaDrillUnit, true, MIN_SIZE ),
m_viaDiameter( aParent, m_ViaDiameterLabel, m_ViaDiameterCtrl, m_ViaDiameterUnit, true ),
m_viaDrill( aParent, m_ViaDrillLabel, m_ViaDrillCtrl, m_ViaDrillUnit, true ),
m_tracks( false ),
m_vias( false )
{
@ -367,7 +365,8 @@ bool DIALOG_TRACK_VIA_PROPERTIES::TransferDataFromWindow()
if( m_vias )
{
if( !m_viaDiameter.Validate( true ) || !m_viaDrill.Validate( true ) )
if( !m_viaDiameter.Validate( GEOMETRY_MIN_SIZE, INT_MAX )
|| !m_viaDrill.Validate( GEOMETRY_MIN_SIZE, INT_MAX ) )
return false;
if( m_ViaDiameterCtrl->IsEnabled() && !m_viaDiameter.IsIndeterminate()
@ -390,7 +389,7 @@ bool DIALOG_TRACK_VIA_PROPERTIES::TransferDataFromWindow()
if( m_tracks )
{
if( !m_trackWidth.Validate( true ) )
if( !m_trackWidth.Validate( GEOMETRY_MIN_SIZE, INT_MAX ) )
return false;
}

View File

@ -32,12 +32,12 @@
PANEL_SETUP_FEATURE_CONSTRAINTS::PANEL_SETUP_FEATURE_CONSTRAINTS( PAGED_DIALOG* aParent,
PCB_EDIT_FRAME* aFrame ) :
PANEL_SETUP_FEATURE_CONSTRAINTS_BASE( aParent->GetTreebook() ),
m_trackMinWidth( aFrame, m_TrackMinWidthTitle, m_TrackMinWidthCtrl, m_TrackMinWidthUnits, true, 0 ),
m_viaMinSize( aFrame, m_ViaMinTitle, m_SetViasMinSizeCtrl, m_ViaMinUnits, true, 0 ),
m_viaMinDrill( aFrame, m_ViaMinDrillTitle, m_SetViasMinDrillCtrl, m_ViaMinDrillUnits, true, 0 ),
m_uviaMinSize( aFrame, m_uviaMinSizeLabel, m_uviaMinSizeCtrl, m_uviaMinSizeUnits, true, 0 ),
m_uviaMinDrill( aFrame, m_uviaMinDrillLabel, m_uviaMinDrillCtrl, m_uviaMinDrillUnits, true, 0 ),
m_holeToHoleMin( aFrame, m_HoleToHoleTitle, m_SetHoleToHoleCtrl, m_HoleToHoleUnits, true, 0 )
m_trackMinWidth( aFrame, m_TrackMinWidthTitle, m_TrackMinWidthCtrl, m_TrackMinWidthUnits, true ),
m_viaMinSize( aFrame, m_ViaMinTitle, m_SetViasMinSizeCtrl, m_ViaMinUnits, true ),
m_viaMinDrill( aFrame, m_ViaMinDrillTitle, m_SetViasMinDrillCtrl, m_ViaMinDrillUnits, true ),
m_uviaMinSize( aFrame, m_uviaMinSizeLabel, m_uviaMinSizeCtrl, m_uviaMinSizeUnits, true ),
m_uviaMinDrill( aFrame, m_uviaMinDrillLabel, m_uviaMinDrillCtrl, m_uviaMinDrillUnits, true ),
m_holeToHoleMin( aFrame, m_HoleToHoleTitle, m_SetHoleToHoleCtrl, m_HoleToHoleUnits, true )
{
m_Frame = aFrame;
m_BrdSettings = &m_Frame->GetBoard()->GetDesignSettings();

View File

@ -137,8 +137,7 @@ static const LSET presets[] =
PANEL_SETUP_LAYERS::PANEL_SETUP_LAYERS( PAGED_DIALOG* aParent, PCB_EDIT_FRAME* aFrame ) :
PANEL_SETUP_LAYERS_BASE( aParent->GetTreebook() ),
m_Parent( aParent ), m_frame( aFrame ),
m_pcbThickness( aFrame, m_thicknessLabel, m_thicknessCtrl, m_thicknessUnits, true,
Millimeter2iu( 0.1 ), Millimeter2iu( 10.0 ) )
m_pcbThickness( aFrame, m_thicknessLabel, m_thicknessCtrl, m_thicknessUnits, true )
{
m_pcb = aFrame->GetBoard();
@ -487,9 +486,6 @@ void PANEL_SETUP_LAYERS::OnCopperLayersChoice( wxCommandEvent& event )
bool PANEL_SETUP_LAYERS::TransferDataFromWindow()
{
if( !m_pcbThickness.Validate( true ) )
return false;
if( !testLayerNames() )
return false;

View File

@ -94,8 +94,8 @@ DIALOG_TARGET_PROPERTIES::DIALOG_TARGET_PROPERTIES( PCB_EDIT_FRAME* aParent, PCB
m_Parent( aParent ),
m_DC( aDC ),
m_Target( aTarget ),
m_Size( aParent, m_sizeLabel, m_sizeCtrl, m_sizeUnits, true, 0 ),
m_Thickness( aParent, m_thicknessLabel, m_thicknessCtrl, m_thicknessUnits, true, 0 )
m_Size( aParent, m_sizeLabel, m_sizeCtrl, m_sizeUnits, true ),
m_Thickness( aParent, m_thicknessLabel, m_thicknessCtrl, m_thicknessUnits, true )
{
m_sdbSizerButtsOK->SetDefault();
@ -119,6 +119,10 @@ bool DIALOG_TARGET_PROPERTIES::TransferDataToWindow()
bool DIALOG_TARGET_PROPERTIES::TransferDataFromWindow()
{
// Zero-size targets are hard to see/select.
if( !m_Size.Validate( Mils2iu( 1 ), INT_MAX ) )
return false;
BOARD_COMMIT commit( m_Parent );
commit.Modify( m_Target );