diff --git a/common/dialog_shim.cpp b/common/dialog_shim.cpp index f3b58f0164..11dc62dbb6 100644 --- a/common/dialog_shim.cpp +++ b/common/dialog_shim.cpp @@ -63,13 +63,27 @@ DIALOG_SHIM::DIALOG_SHIM( wxWindow* aParent, wxWindowID id, const wxString& titl m_qmodal_showing( false ), m_qmodal_parent_disabler( 0 ) { - // pray that aParent is either a KIWAY_PLAYER or DIALOG_SHIM derivation. KIWAY_HOLDER* h = dynamic_cast( aParent ); - - // wxASSERT_MSG( h, wxT( "DIALOG_SHIM's parent is NULL or not derived from KIWAY_PLAYER nor DIALOG_SHIM" ) ); + while( !h && aParent->GetParent() ) + { + aParent = aParent->GetParent(); + h = dynamic_cast( aParent ); + } if( h ) + { + // Inherit units from parent + m_units = h->GetUserUnits(); + + // Set up the message bus SetKiway( this, &h->Kiway() ); + } + else + { + wxFAIL_MSG( wxString::Format( "No KIWAY_HOLDER in parent chain. Top window is a %s.", + aParent->GetClassInfo()->GetClassName() ) ); + m_units = MILLIMETRES; + } Bind( wxEVT_CLOSE_WINDOW, &DIALOG_SHIM::OnCloseWindow, this ); Bind( wxEVT_BUTTON, &DIALOG_SHIM::OnButton, this ); @@ -77,7 +91,7 @@ DIALOG_SHIM::DIALOG_SHIM( wxWindow* aParent, wxWindowID id, const wxString& titl #ifdef __WINDOWS__ // On Windows, the app top windows can be brought to the foreground // (at least temporary) in certain circumstances, - // for instance when calling an external tool in Eeschema boom generation. + // for instance when calling an external tool in Eeschema BOM generation. // So set the parent KIWAY_PLAYER kicad frame (if exists) to top window // to avoid this annoying behavior KIWAY_PLAYER* parent_kiwayplayer = dynamic_cast( aParent ); diff --git a/common/kiway_holder.cpp b/common/kiway_holder.cpp index 000f39145b..15e984b21b 100644 --- a/common/kiway_holder.cpp +++ b/common/kiway_holder.cpp @@ -37,6 +37,12 @@ PROJECT& KIWAY_HOLDER::Prj() const } +EDA_UNITS_T KIWAY_HOLDER::GetUserUnits() const +{ + return MILLIMETRES; +} + + // this is not speed critical, hide it out of line. void KIWAY_HOLDER::SetKiway( wxWindow* aDest, KIWAY* aKiway ) { diff --git a/common/libeval/numeric_evaluator.cpp b/common/libeval/numeric_evaluator.cpp index f05a0c10f0..7da81f9ef8 100644 --- a/common/libeval/numeric_evaluator.cpp +++ b/common/libeval/numeric_evaluator.cpp @@ -55,7 +55,9 @@ namespace numEval } /* namespace numEval */ -NumericEvaluator :: NumericEvaluator() : pClParser(0) +// JEY TODO: remove this version; +NumericEvaluator :: NumericEvaluator() : + pClParser( 0 ) { struct lconv* lc = localeconv(); cClDecSep = *lc->decimal_point; @@ -65,7 +67,47 @@ NumericEvaluator :: NumericEvaluator() : pClParser(0) bClError = false; bClParseFinished = false; - init(); + if( pClParser == nullptr ) + pClParser = numEval::ParseAlloc(malloc); + + switch( g_UserUnit ) + { + case INCHES: + eClUnitDefault = Unit::Inch; + break; + case MILLIMETRES: + eClUnitDefault = Unit::Metric; + break; + default: + eClUnitDefault = Unit::Metric; + break; + } +} + +NumericEvaluator::NumericEvaluator( EDA_UNITS_T aUnits, bool aUseMils ) : + pClParser( 0 ) +{ + struct lconv* lc = localeconv(); + cClDecSep = *lc->decimal_point; + + bClTextInputStorage = true; + pClParser = numEval::ParseAlloc(malloc); + + switch( aUnits ) + { + case INCHES: + if( aUseMils ) + eClUnitDefault = Unit::Mil; + else + eClUnitDefault = Unit::Inch; + break; + case MILLIMETRES: + eClUnitDefault = Unit::Metric; + break; + default: + eClUnitDefault = Unit::Metric; + break; + } } NumericEvaluator :: ~NumericEvaluator() @@ -78,26 +120,6 @@ NumericEvaluator :: ~NumericEvaluator() clear(); } -void -NumericEvaluator :: init() -{ - if (pClParser == nullptr) - pClParser = numEval::ParseAlloc(malloc); - - //numEval::ParseTrace(stdout, "lib"); - -#if TESTMODE - eClUnitDefault = Unit::Metric; -#else - switch (g_UserUnit) - { - case INCHES : eClUnitDefault = Unit::Inch; break; - case MILLIMETRES : eClUnitDefault = Unit::Metric; break; - default: eClUnitDefault = Unit::Metric; break; - } -#endif -} - void NumericEvaluator :: clear(const void* pObj) { @@ -106,7 +128,8 @@ NumericEvaluator :: clear(const void* pObj) clToken.input = nullptr; bClError = true; - if (bClTextInputStorage && pObj) clObjMap.erase(pObj); + if (bClTextInputStorage) + clObjMap.clear(); } void @@ -151,7 +174,9 @@ NumericEvaluator :: process(const char* s) newString(s); - if (pClParser == nullptr) init(); + if (pClParser == nullptr) + pClParser = numEval::ParseAlloc(malloc); + bClError = false; bClParseFinished = false; @@ -191,8 +216,7 @@ NumericEvaluator :: newString(const char* s) bClParseFinished = false; } -NumericEvaluator::Token -NumericEvaluator :: getToken() +NumericEvaluator::Token NumericEvaluator::getToken() { Token retval; size_t idx; @@ -227,32 +251,35 @@ NumericEvaluator :: getToken() for (int i = strlen(clToken.token); i; i--) if (isDecSep(clToken.token[i-1])) clToken.token[i-1] = cClDecSep; }; - /* Lamda: Get unit for current token. Returns Unit::Invalid if token is not a unit. - * '"', "in", "th", "mi", "mil" or "mm" - */ + // Lamda: Get unit for current token. + // Valid units are ", in, mm, mil and thou. Returns Unit::Invalid otherwise. auto checkUnit = [this]() -> Unit { - const int sizeLeft = clToken.inputLen - clToken.pos; - Unit convertFrom = Unit::Invalid; - char unit[2] = { 0, 0 }; - for (int i = 0; i < sizeLeft && i < int(sizeof(unit)/sizeof(unit[0])); i++) unit[i] = tolower(clToken.input[clToken.pos+i]); - auto tokcmp = [sizeLeft, unit](const char* s, int len) -> int { - if (len > sizeLeft) return 0; - if (!strncmp(unit, s, len)) return len; - return 0; - }; - int size = 0; - if ((size = tokcmp("\"", 1))) convertFrom = Unit::Inch; - else if ((size = tokcmp("in", 2))) convertFrom = Unit::Inch; - else if ((size = tokcmp("mi", 2))) convertFrom = Unit::Mil; - else if ((size = tokcmp("th", 2))) convertFrom = Unit::Mil; - else if ((size = tokcmp("mm", 2))) convertFrom = Unit::Metric; - clToken.pos += size; - - if (size) { - while (clToken.pos < clToken.inputLen && isalnum(clToken.input[clToken.pos])) clToken.pos++; + char ch = clToken.input[clToken.pos]; + if (ch == '"') { + clToken.pos++; + return Unit::Inch; + } + // Do not use strcasecmp() as it is not available on all platforms + const char* cptr = &clToken.input[clToken.pos]; + const auto sizeLeft = clToken.inputLen - clToken.pos; + if (sizeLeft >= 2 && ch == 'm' && tolower(cptr[1]) == 'm' && !isalnum(cptr[2])) { + clToken.pos += 2; + return Unit::Metric; + } + if (sizeLeft >= 2 && ch == 'i' && tolower(cptr[1]) == 'n' && !isalnum(cptr[2])) { + clToken.pos += 2; + return Unit::Inch; + } + if (sizeLeft >= 3 && ch == 'm' && tolower(cptr[1]) == 'i' && tolower(cptr[2]) == 'l' && !isalnum(cptr[3])) { + clToken.pos += 3; + return Unit::Mil; + } + if (sizeLeft >= 4 && ch == 't' && tolower(cptr[1]) == 'h' && tolower(cptr[2]) == 'o' && tolower(cptr[2]) == 'u' && !isalnum(cptr[3])) { + clToken.pos += 4; + return Unit::Mil; } - return convertFrom; + return Unit::Invalid; }; // Start processing of first/next token: Remove whitespace @@ -301,6 +328,16 @@ NumericEvaluator :: getToken() case Unit::Invalid : break; } } + else if (eClUnitDefault == Unit::Mil) + { + switch (convertFrom) + { + case Unit::Inch : retval.value.dValue = 1.0*1000.0; break; + case Unit::Mil : retval.value.dValue = 1.0; break; + case Unit::Metric : retval.value.dValue = 1000.0/25.4; break; + case Unit::Invalid : break; + } + } } else if (isalpha(ch)) { // VAR const char* cptr = &clToken.input[clToken.pos]; diff --git a/common/widgets/unit_binder.cpp b/common/widgets/unit_binder.cpp index 4c36257e35..3d134e85eb 100644 --- a/common/widgets/unit_binder.cpp +++ b/common/widgets/unit_binder.cpp @@ -23,26 +23,36 @@ */ #include -#include #include #include #include -#include +#include +#include #include "widgets/unit_binder.h" -UNIT_BINDER::UNIT_BINDER( wxWindow* aParent, wxTextEntry* aTextInput, - wxStaticText* aUnitLabel, wxSpinButton* aSpinButton ) : - m_textEntry( aTextInput ), +UNIT_BINDER::UNIT_BINDER( EDA_DRAW_FRAME* aParent, + wxStaticText* aLabel, wxTextEntry* aTextEntry, wxStaticText* aUnitLabel, + bool aUseMils, int aMin, int aMax, bool allowEval ) : + m_label( aLabel ), + m_textEntry( aTextEntry ), m_unitLabel( aUnitLabel ), - m_units( g_UserUnit ), - m_step( 1 ), - m_min( 0 ), - m_max( 1 ) + m_eval( aParent->GetUserUnits(), aUseMils ) { - // Use the currently selected units + // 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; + m_textEntry->SetValue( wxT( "0" ) ); - m_unitLabel->SetLabel( GetAbbreviatedUnitsLabel( m_units ) ); + m_unitLabel->SetLabel( GetAbbreviatedUnitsLabel( m_units, aUseMils ) ); + + wxWindow* textInput = dynamic_cast( m_textEntry ); + textInput->Connect( wxEVT_SET_FOCUS, wxFocusEventHandler( UNIT_BINDER::onSetFocus ), NULL, this ); + textInput->Connect( wxEVT_KILL_FOCUS, wxFocusEventHandler( UNIT_BINDER::onKillFocus ), NULL, this ); + textInput->Connect( wxEVT_TEXT_ENTER, wxCommandEventHandler( UNIT_BINDER::onTextEnter ), NULL, this ); } @@ -51,13 +61,130 @@ UNIT_BINDER::~UNIT_BINDER() } +void UNIT_BINDER::onSetFocus( wxFocusEvent& aEvent ) +{ + if( m_allowEval ) + { + auto oldStr = m_eval.textInput( this ); + + if( oldStr ) + m_textEntry->SetValue( wxString::FromUTF8( oldStr ) ); + } + + aEvent.Skip(); +} + + +void UNIT_BINDER::onKillFocus( wxFocusEvent& aEvent ) +{ + // The ship is going down; no need to do anything... + if( !aEvent.GetWindow() || aEvent.GetWindow()->GetId() == wxID_CANCEL ) + return; + + if( m_allowEval ) + evaluate(); + + Validate( true ); + + aEvent.Skip(); +} + + +void UNIT_BINDER::onTextEnter( wxCommandEvent& aEvent ) +{ + if( m_allowEval ) + evaluate(); + + // Send an OK event to the parent dialog + wxCommandEvent event( wxEVT_COMMAND_BUTTON_CLICKED, wxID_OK ); + wxPostEvent( dynamic_cast( m_textEntry )->GetParent(), event ); +} + + +void UNIT_BINDER::evaluate() +{ + if( m_textEntry->GetValue().IsEmpty() ) + m_textEntry->SetValue( "0" ); + + if( m_eval.process( m_textEntry->GetValue().mb_str(), this ) ) + m_textEntry->SetValue( wxString::FromUTF8( m_eval.result() ) ); +} + + +wxString valueDescriptionFromLabel( wxStaticText* aLabel ) +{ + wxString desc = aLabel->GetLabel(); + + desc.EndsWith( wxT( ":" ), &desc ); + return desc; +} + + +void UNIT_BINDER::delayedFocusHandler( wxIdleEvent& ) +{ + wxWindow* textInput = dynamic_cast( m_textEntry ); + textInput->SetFocus(); + + textInput->Unbind( wxEVT_IDLE, &UNIT_BINDER::delayedFocusHandler, this ); +} + + +bool UNIT_BINDER::Validate( bool setFocusOnError ) +{ + wxWindow* textInput = dynamic_cast( m_textEntry ); + + if( m_min > INT_MIN && GetValue() < m_min ) + { + wxString msg = wxString::Format( _( "%s must be larger than %s." ), + valueDescriptionFromLabel( m_label ), + StringFromValue( EDA_UNITS_T::MILLIMETRES, m_min, true ) ); + DisplayError( textInput->GetParent(), msg ); + + if( setFocusOnError ) + { + m_textEntry->SelectAll(); + // Don't focus directly; we might be inside a KillFocus event handler + textInput->Bind( wxEVT_IDLE, &UNIT_BINDER::delayedFocusHandler, this ); + } + + return false; + } + + if( m_max < INT_MAX && GetValue() > m_max ) + { + wxString msg = wxString::Format( _( "%s must be smaller than %s." ), + valueDescriptionFromLabel( m_label ), + StringFromValue( EDA_UNITS_T::MILLIMETRES, m_max, true ) ); + DisplayError( textInput->GetParent(), msg ); + + if( setFocusOnError ) + { + m_textEntry->SelectAll(); + // Don't focus directly; we might be inside a KillFocus event handler + textInput->Bind( wxEVT_IDLE, &UNIT_BINDER::delayedFocusHandler, this ); + } + + return false; + } + + return true; +} + + void UNIT_BINDER::SetValue( int aValue ) { - wxString s = StringFromValue( m_units, aValue, false ); + SetValue( StringFromValue( m_units, aValue, false, m_useMils ) ); +} - m_textEntry->SetValue( s ); - m_unitLabel->SetLabel( GetAbbreviatedUnitsLabel( m_units ) ); +void UNIT_BINDER::SetValue( wxString aValue ) +{ + m_textEntry->SetValue( aValue ); + + if( m_allowEval ) + m_eval.clear(); + + m_unitLabel->SetLabel( GetAbbreviatedUnitsLabel( m_units, m_useMils ) ); } @@ -65,28 +192,20 @@ int UNIT_BINDER::GetValue() const { wxString s = m_textEntry->GetValue(); - return ValueFromString( m_units, s ); + return ValueFromString( m_units, s, m_useMils ); } -bool UNIT_BINDER::Valid() const +bool UNIT_BINDER::IsIndeterminate() const { - double dummy; - - return m_textEntry->GetValue().ToDouble( &dummy ); + return m_textEntry->GetValue() == INDETERMINATE; } void UNIT_BINDER::Enable( bool aEnable ) { - wxWindow* wxWin = dynamic_cast( m_textEntry ); - wxASSERT( wxWin ); - - // Most text input entry widgets inherit from wxTextEntry and wxWindow, so it should be fine. - // Still, it is better to be safe than sorry. - if( wxWin ) - wxWin->Enable( aEnable ); - + m_label->Enable( aEnable ); + dynamic_cast( m_textEntry )->Enable( aEnable ); m_unitLabel->Enable( aEnable ); } diff --git a/eeschema/dialogs/dialog_edit_label.cpp b/eeschema/dialogs/dialog_edit_label.cpp index 6fa8be3787..5ef8be77bd 100644 --- a/eeschema/dialogs/dialog_edit_label.cpp +++ b/eeschema/dialogs/dialog_edit_label.cpp @@ -40,6 +40,7 @@ #include #include #include +#include #include @@ -78,16 +79,16 @@ public: } private: - void InitDialog( ) override; virtual void OnEnterKey( wxCommandEvent& aEvent ) override; - virtual void OnOkClick( wxCommandEvent& aEvent ) override; - virtual void OnCancelClick( wxCommandEvent& aEvent ) override; void OnCharHook( wxKeyEvent& aEvent ); - void TextPropertiesAccept( wxCommandEvent& aEvent ); + + bool TransferDataToWindow() override; + bool TransferDataFromWindow() override; SCH_EDIT_FRAME* m_Parent; SCH_TEXT* m_CurrentText; - wxTextCtrl* m_textLabel; + wxTextCtrl* m_activeTextCtrl; + UNIT_BINDER m_textSize; }; @@ -106,24 +107,61 @@ 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 ); + + DIALOG_LABEL_EDITOR::DIALOG_LABEL_EDITOR( SCH_EDIT_FRAME* aParent, SCH_TEXT* aTextItem ) : - DIALOG_LABEL_EDITOR_BASE( aParent ) + DIALOG_LABEL_EDITOR_BASE( aParent ), + m_textSize( aParent, m_SizeTitle, m_TextSizeCtrl, m_staticSizeUnits, false, minSize, maxSize ) { m_Parent = aParent; m_CurrentText = aTextItem; - InitDialog(); - // Conservative limits 0.0 to 10.0 inches - const int minSize = 0; // a value like 0.01 is better, but if > 0, creates - // annoying issues when trying to enter a value starting by 0 or .0 - const int maxSize = 10 * 1000 * IU_PER_MILS; + switch( m_CurrentText->Type() ) + { + case SCH_GLOBAL_LABEL_T: + SetTitle( _( "Global Label Properties" ) ); + break; - wxFloatingPointValidator textSizeValidator( NULL, wxNUM_VAL_NO_TRAILING_ZEROES ); - textSizeValidator.SetPrecision( 4 ); - textSizeValidator.SetRange( To_User_Unit( g_UserUnit, minSize ), - To_User_Unit( g_UserUnit, maxSize ) ); + case SCH_HIERARCHICAL_LABEL_T: + SetTitle( _( "Hierarchical Label Properties" ) ); + break; - m_TextSize->SetValidator( textSizeValidator ); + case SCH_LABEL_T: + SetTitle( _( "Label Properties" ) ); + break; + + case SCH_SHEET_PIN_T: + SetTitle( _( "Hierarchical Sheet Pin Properties." ) ); + break; + + default: + SetTitle( _( "Text Properties" ) ); + break; + } + + if( m_CurrentText->IsMultilineAllowed() ) + { + m_activeTextCtrl = m_textLabelMultiLine; + m_textLabelSingleLine->Show( false ); + m_textControlSizer->AddGrowableRow( 0 ); + } + else + { + m_activeTextCtrl = m_textLabelSingleLine; + m_textLabelMultiLine->Show( false ); + } + + if( m_CurrentText->Type() != SCH_TEXT_T ) + ( (wxTextValidator*) m_activeTextCtrl->GetValidator() )->SetCharExcludes( wxT( " /" ) ); + + m_TextShape->Show( m_CurrentText->Type() == SCH_GLOBAL_LABEL_T || + m_CurrentText->Type() == SCH_HIERARCHICAL_LABEL_T ); + + m_sdbSizer1OK->SetDefault(); + Layout(); // wxTextCtrls fail to generate wxEVT_CHAR events when the wxTE_MULTILINE flag is set, // so we have to listen to wxEVT_CHAR_HOOK events instead. @@ -165,93 +203,13 @@ static int mapOrientation( KICAD_T labelType, int aOrientation ) } -void DIALOG_LABEL_EDITOR::InitDialog() +bool DIALOG_LABEL_EDITOR::TransferDataToWindow() { - wxString msg; - bool multiLine = false; + if( !wxDialog::TransferDataToWindow() ) + return false; - if( m_CurrentText->IsMultilineAllowed() ) - { - m_textLabel = m_textLabelMultiLine; - m_textLabelSingleLine->Show( false ); - m_textControlSizer->AddGrowableRow( 0 ); - multiLine = true; - } - else - { - m_textLabel = m_textLabelSingleLine; - m_textLabelMultiLine->Show( false ); - wxTextValidator* validator = (wxTextValidator*) m_textLabel->GetValidator(); - - // Add invalid label characters to this list. - // for any label type but SCH_TEXT_T (that has the multiline allowed) - validator->SetCharExcludes( wxT( " /" ) ); - } - - m_textLabel->SetValue( m_CurrentText->GetText() ); - m_textLabel->SetFocus(); - - switch( m_CurrentText->Type() ) - { - case SCH_GLOBAL_LABEL_T: - SetTitle( _( "Global Label Properties" ) ); - break; - - case SCH_HIERARCHICAL_LABEL_T: - SetTitle( _( "Hierarchical Label Properties" ) ); - break; - - case SCH_LABEL_T: - SetTitle( _( "Label Properties" ) ); - break; - - case SCH_SHEET_PIN_T: - SetTitle( _( "Hierarchical Sheet Pin Properties." ) ); - break; - - default: - SetTitle( _( "Text Properties" ) ); - break; - } - - const int MINTEXTWIDTH = 40; // M's are big characters, a few establish a lot of width - - int max_len = 0; - - if ( !multiLine ) - { - max_len = m_CurrentText->GetText().Length(); - } - else - { - // calculate the length of the biggest line - // we cannot use the length of the entire text that has no meaning - int curr_len = MINTEXTWIDTH; - int imax = m_CurrentText->GetText().Length(); - - for( int count = 0; count < imax; count++ ) - { - if( m_CurrentText->GetText()[count] == '\n' || - m_CurrentText->GetText()[count] == '\r' ) // new line - { - curr_len = 0; - } - else - { - curr_len++; - - if ( max_len < curr_len ) - max_len = curr_len; - } - } - } - - if( max_len < MINTEXTWIDTH ) - max_len = MINTEXTWIDTH; - - wxString textWidth; - textWidth.Append( 'M', MINTEXTWIDTH ); - EnsureTextCtrlWidth( m_textLabel, &textWidth ); + m_activeTextCtrl->SetValue( m_CurrentText->GetText() ); + m_activeTextCtrl->SetFocus(); // Set text options: int orientation = mapOrientation( m_CurrentText->Type(), m_CurrentText->GetLabelSpinStyle() ); @@ -269,35 +227,24 @@ void DIALOG_LABEL_EDITOR::InitDialog() m_TextStyle->SetSelection( style ); - wxString units = ReturnUnitSymbol( g_UserUnit, wxT( "(%s)" ) ); - msg.Printf( _( "H%s x W%s" ), GetChars( units ), GetChars( units ) ); - m_staticSizeUnits->SetLabel( msg ); + m_textSize.SetValue( m_CurrentText->GetTextWidth() ); - msg = StringFromValue( g_UserUnit, m_CurrentText->GetTextWidth() ); - m_TextSize->SetValue( msg ); - - if( m_CurrentText->Type() != SCH_GLOBAL_LABEL_T - && m_CurrentText->Type() != SCH_HIERARCHICAL_LABEL_T ) - { - m_TextShape->Show( false ); - } - - m_sdbSizer1OK->SetDefault(); + return true; } /*! - * wxEVT_COMMAND_ENTER event handler for m_textLabel + * wxEVT_COMMAND_ENTER event handler for single-line control */ void DIALOG_LABEL_EDITOR::OnEnterKey( wxCommandEvent& aEvent ) { - TextPropertiesAccept( aEvent ); + wxPostEvent( this, wxCommandEvent( wxEVT_COMMAND_BUTTON_CLICKED, wxID_OK ) ); } /*! - * wxEVT_CHAR_HOOK event handler for m_textLabel + * wxEVT_CHAR_HOOK event handler for multi-line control */ void DIALOG_LABEL_EDITOR::OnCharHook( wxKeyEvent& aEvent ) @@ -313,8 +260,7 @@ void DIALOG_LABEL_EDITOR::OnCharHook( wxKeyEvent& aEvent ) } else if( aEvent.GetKeyCode() == WXK_RETURN && aEvent.ShiftDown() ) { - wxCommandEvent cmdEvent( wxEVT_COMMAND_ENTER ); - TextPropertiesAccept( cmdEvent ); + wxPostEvent( this, wxCommandEvent( wxEVT_COMMAND_BUTTON_CLICKED, wxID_OK ) ); } else { @@ -323,31 +269,12 @@ void DIALOG_LABEL_EDITOR::OnCharHook( wxKeyEvent& aEvent ) } -/*! - * wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_OK - */ - -void DIALOG_LABEL_EDITOR::OnOkClick( wxCommandEvent& aEvent ) +bool DIALOG_LABEL_EDITOR::TransferDataFromWindow() { - TextPropertiesAccept( aEvent ); -} + if( !wxDialog::TransferDataFromWindow() ) + return false; - -/*! - * wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CANCEL - */ - -void DIALOG_LABEL_EDITOR::OnCancelClick( wxCommandEvent& aEvent ) -{ - m_Parent->GetCanvas()->MoveCursorToCrossHair(); - EndModal( wxID_CANCEL ); -} - - -void DIALOG_LABEL_EDITOR::TextPropertiesAccept( wxCommandEvent& aEvent ) -{ wxString text; - int value; /* save old text in undo list if not already in edit */ /* or the label to be edited is part of a block */ @@ -357,22 +284,20 @@ void DIALOG_LABEL_EDITOR::TextPropertiesAccept( wxCommandEvent& aEvent ) m_Parent->GetCanvas()->RefreshDrawingRect( m_CurrentText->GetBoundingBox() ); - text = m_textLabel->GetValue(); + text = m_activeTextCtrl->GetValue(); if( !text.IsEmpty() ) m_CurrentText->SetText( text ); else if( !m_CurrentText->IsNew() ) { DisplayError( this, _( "Empty Text!" ) ); - return; + return false; } int orientation = m_TextOrient->GetSelection(); m_CurrentText->SetLabelSpinStyle( mapOrientation( m_CurrentText->Type(), orientation ) ); - text = m_TextSize->GetValue(); - value = ValueFromString( g_UserUnit, text ); - m_CurrentText->SetTextSize( wxSize( value, value ) ); + m_CurrentText->SetTextSize( wxSize( m_textSize.GetValue(), m_textSize.GetValue() ) ); if( m_TextShape ) /// @todo move cast to widget @@ -401,5 +326,6 @@ void DIALOG_LABEL_EDITOR::TextPropertiesAccept( wxCommandEvent& aEvent ) m_Parent->GetCanvas()->RefreshDrawingRect( m_CurrentText->GetBoundingBox() ); m_Parent->GetCanvas()->MoveCursorToCrossHair(); - EndModal( wxID_OK ); + + return true; } diff --git a/eeschema/dialogs/dialog_edit_label_base.cpp b/eeschema/dialogs/dialog_edit_label_base.cpp index 4fe07baa1a..bd0f6ff6d1 100644 --- a/eeschema/dialogs/dialog_edit_label_base.cpp +++ b/eeschema/dialogs/dialog_edit_label_base.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Jun 5 2018) +// C++ code generated with wxFormBuilder (version Dec 30 2017) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! @@ -18,6 +18,7 @@ DIALOG_LABEL_EDITOR_BASE::DIALOG_LABEL_EDITOR_BASE( wxWindow* parent, wxWindowID m_textControlSizer = new wxFlexGridSizer( 2, 2, 3, 3 ); m_textControlSizer->AddGrowableCol( 1 ); + m_textControlSizer->AddGrowableRow( 0 ); m_textControlSizer->SetFlexibleDirection( wxBOTH ); m_textControlSizer->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); @@ -25,37 +26,39 @@ DIALOG_LABEL_EDITOR_BASE::DIALOG_LABEL_EDITOR_BASE( wxWindow* parent, wxWindowID m_staticText1->Wrap( -1 ); m_staticText1->SetToolTip( _("Enter the text to be used within the schematic") ); - m_textControlSizer->Add( m_staticText1, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 3 ); + m_textControlSizer->Add( m_staticText1, 0, wxALIGN_TOP|wxRIGHT|wxTOP, 3 ); wxBoxSizer* bSizeText; bSizeText = new wxBoxSizer( wxVERTICAL ); m_textLabelSingleLine = new wxTextCtrl( this, wxID_VALUESINGLE, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER|wxTE_RICH ); + m_textLabelSingleLine->SetMinSize( wxSize( 360,-1 ) ); + m_textLabelSingleLine->SetValidator( wxTextValidator( wxFILTER_EXCLUDE_CHAR_LIST, &m_labelText ) ); - bSizeText->Add( m_textLabelSingleLine, 0, wxEXPAND|wxLEFT, 3 ); + bSizeText->Add( m_textLabelSingleLine, 0, wxBOTTOM|wxEXPAND|wxLEFT, 3 ); m_textLabelMultiLine = new wxTextCtrl( this, wxID_VALUEMULTI, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE ); - m_textLabelMultiLine->SetMinSize( wxSize( -1,60 ) ); + m_textLabelMultiLine->SetMinSize( wxSize( 480,72 ) ); - bSizeText->Add( m_textLabelMultiLine, 1, wxEXPAND|wxLEFT, 3 ); + bSizeText->Add( m_textLabelMultiLine, 1, wxBOTTOM|wxEXPAND|wxLEFT, 3 ); m_textControlSizer->Add( bSizeText, 1, wxEXPAND, 3 ); m_SizeTitle = new wxStaticText( this, wxID_ANY, _("&Size:"), wxDefaultPosition, wxDefaultSize, 0 ); m_SizeTitle->Wrap( -1 ); - m_textControlSizer->Add( m_SizeTitle, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 3 ); + m_textControlSizer->Add( m_SizeTitle, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxRIGHT, 3 ); wxBoxSizer* bSizeCtrlSizer; bSizeCtrlSizer = new wxBoxSizer( wxHORIZONTAL ); - m_TextSize = new wxTextCtrl( this, wxID_SIZE, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); - bSizeCtrlSizer->Add( m_TextSize, 0, wxALIGN_CENTER_VERTICAL|wxEXPAND|wxLEFT|wxRIGHT, 3 ); + m_TextSizeCtrl = new wxTextCtrl( this, wxID_SIZE, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + bSizeCtrlSizer->Add( m_TextSizeCtrl, 0, wxALIGN_CENTER_VERTICAL|wxEXPAND|wxLEFT|wxTOP, 3 ); m_staticSizeUnits = new wxStaticText( this, wxID_ANY, _("units"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticSizeUnits->Wrap( -1 ); - bSizeCtrlSizer->Add( m_staticSizeUnits, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 3 ); + bSizeCtrlSizer->Add( m_staticSizeUnits, 0, wxALIGN_CENTER_VERTICAL|wxTOP, 2 ); m_textControlSizer->Add( bSizeCtrlSizer, 1, wxEXPAND, 3 ); @@ -68,21 +71,21 @@ DIALOG_LABEL_EDITOR_BASE::DIALOG_LABEL_EDITOR_BASE( wxWindow* parent, wxWindowID wxString m_TextOrientChoices[] = { _("Right"), _("Up"), _("Left"), _("Down") }; int m_TextOrientNChoices = sizeof( m_TextOrientChoices ) / sizeof( wxString ); - m_TextOrient = new wxRadioBox( this, wxID_ANY, _("O&rientation:"), wxDefaultPosition, wxDefaultSize, m_TextOrientNChoices, m_TextOrientChoices, 1, wxRA_SPECIFY_COLS ); + m_TextOrient = new wxRadioBox( this, wxID_ANY, _("Orientation"), wxDefaultPosition, wxDefaultSize, m_TextOrientNChoices, m_TextOrientChoices, 1, wxRA_SPECIFY_COLS ); m_TextOrient->SetSelection( 0 ); - m_OptionsSizer->Add( m_TextOrient, 1, wxRIGHT|wxTOP, 3 ); + m_OptionsSizer->Add( m_TextOrient, 1, wxRIGHT|wxTOP|wxEXPAND, 3 ); wxString m_TextStyleChoices[] = { _("Normal"), _("Italic"), _("Bold"), _("Bold and italic") }; int m_TextStyleNChoices = sizeof( m_TextStyleChoices ) / sizeof( wxString ); - m_TextStyle = new wxRadioBox( this, wxID_ANY, _("St&yle:"), wxDefaultPosition, wxDefaultSize, m_TextStyleNChoices, m_TextStyleChoices, 1, wxRA_SPECIFY_COLS ); + m_TextStyle = new wxRadioBox( this, wxID_ANY, _("Style"), wxDefaultPosition, wxDefaultSize, m_TextStyleNChoices, m_TextStyleChoices, 1, wxRA_SPECIFY_COLS ); m_TextStyle->SetSelection( 3 ); - m_OptionsSizer->Add( m_TextStyle, 1, wxLEFT|wxRIGHT|wxTOP, 3 ); + m_OptionsSizer->Add( m_TextStyle, 1, wxLEFT|wxRIGHT|wxTOP|wxEXPAND, 3 ); - wxString m_TextShapeChoices[] = { _("Input"), _("Output"), _("Bidirectional"), _("Tri-State"), _("Passive") }; + wxString m_TextShapeChoices[] = { _("Input"), _("Output"), _("Bidirectional"), _("Tri-state"), _("Passive") }; int m_TextShapeNChoices = sizeof( m_TextShapeChoices ) / sizeof( wxString ); - m_TextShape = new wxRadioBox( this, wxID_ANY, _("S&hape:"), wxDefaultPosition, wxDefaultSize, m_TextShapeNChoices, m_TextShapeChoices, 1, wxRA_SPECIFY_COLS ); - m_TextShape->SetSelection( 0 ); - m_OptionsSizer->Add( m_TextShape, 1, wxALL|wxLEFT|wxTOP, 3 ); + m_TextShape = new wxRadioBox( this, wxID_ANY, _("Shape"), wxDefaultPosition, wxDefaultSize, m_TextShapeNChoices, m_TextShapeChoices, 1, wxRA_SPECIFY_COLS ); + m_TextShape->SetSelection( 3 ); + m_OptionsSizer->Add( m_TextShape, 1, wxALL|wxLEFT|wxTOP|wxEXPAND, 3 ); bMainSizer->Add( m_OptionsSizer, 0, wxEXPAND|wxLEFT|wxRIGHT|wxTOP, 12 ); @@ -103,15 +106,11 @@ DIALOG_LABEL_EDITOR_BASE::DIALOG_LABEL_EDITOR_BASE( wxWindow* parent, wxWindowID // Connect Events m_textLabelSingleLine->Connect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( DIALOG_LABEL_EDITOR_BASE::OnEnterKey ), NULL, this ); - m_sdbSizer1Cancel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_LABEL_EDITOR_BASE::OnCancelClick ), NULL, this ); - m_sdbSizer1OK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_LABEL_EDITOR_BASE::OnOkClick ), NULL, this ); } DIALOG_LABEL_EDITOR_BASE::~DIALOG_LABEL_EDITOR_BASE() { // Disconnect Events m_textLabelSingleLine->Disconnect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( DIALOG_LABEL_EDITOR_BASE::OnEnterKey ), NULL, this ); - m_sdbSizer1Cancel->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_LABEL_EDITOR_BASE::OnCancelClick ), NULL, this ); - m_sdbSizer1OK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_LABEL_EDITOR_BASE::OnOkClick ), NULL, this ); } diff --git a/eeschema/dialogs/dialog_edit_label_base.fbp b/eeschema/dialogs/dialog_edit_label_base.fbp index 3bed6f583e..d65230e7da 100644 --- a/eeschema/dialogs/dialog_edit_label_base.fbp +++ b/eeschema/dialogs/dialog_edit_label_base.fbp @@ -14,7 +14,6 @@ dialog_edit_label_base 1000 none - 1 dialog_edit_label_base @@ -112,7 +111,7 @@ 3 3 - wxALIGN_CENTER_VERTICAL|wxRIGHT + wxALIGN_TOP|wxRIGHT|wxTOP 0 1 @@ -204,7 +203,7 @@ none 3 - wxEXPAND|wxLEFT + wxBOTTOM|wxEXPAND|wxLEFT 0 1 @@ -240,7 +239,7 @@ 0 - + 360,-1 1 m_textLabelSingleLine 1 @@ -295,7 +294,7 @@ 3 - wxEXPAND|wxLEFT + wxBOTTOM|wxEXPAND|wxLEFT 1 1 @@ -331,7 +330,7 @@ 0 - -1,60 + 480,72 1 m_textLabelMultiLine 1 @@ -388,7 +387,7 @@ 3 - wxALIGN_CENTER_VERTICAL|wxRIGHT + wxALIGN_CENTER_VERTICAL|wxTOP|wxRIGHT 0 1 @@ -480,7 +479,7 @@ none 3 - wxALIGN_CENTER_VERTICAL|wxEXPAND|wxLEFT|wxRIGHT + wxALIGN_CENTER_VERTICAL|wxEXPAND|wxLEFT|wxTOP 0 1 @@ -518,7 +517,7 @@ 0 1 - m_TextSize + m_TextSizeCtrl 1 @@ -570,8 +569,8 @@ - 3 - wxALIGN_CENTER_VERTICAL|wxLEFT + 2 + wxALIGN_CENTER_VERTICAL|wxTOP 0 1 @@ -667,7 +666,7 @@ none 3 - wxRIGHT|wxTOP + wxRIGHT|wxTOP|wxEXPAND 1 1 @@ -698,7 +697,7 @@ 0 0 wxID_ANY - O&rientation: + Orientation 1 0 @@ -757,7 +756,7 @@ 3 - wxLEFT|wxRIGHT|wxTOP + wxLEFT|wxRIGHT|wxTOP|wxEXPAND 1 1 @@ -788,7 +787,7 @@ 0 0 wxID_ANY - St&yle: + Style 1 0 @@ -847,7 +846,7 @@ 3 - wxALL|wxLEFT|wxTOP + wxALL|wxLEFT|wxTOP|wxEXPAND 1 1 @@ -863,7 +862,7 @@ 1 0 - "Input" "Output" "Bidirectional" "Tri-State" "Passive" + "Input" "Output" "Bidirectional" "Tri-state" "Passive" 1 1 @@ -878,7 +877,7 @@ 0 0 wxID_ANY - S&hape: + Shape 1 0 @@ -895,7 +894,7 @@ 1 Resizable - 0 + 3 1 wxRA_SPECIFY_COLS @@ -954,11 +953,11 @@ m_sdbSizer1 protected - OnCancelClick + - OnOkClick + diff --git a/eeschema/dialogs/dialog_edit_label_base.h b/eeschema/dialogs/dialog_edit_label_base.h index 7308c8ab32..db66cf4823 100644 --- a/eeschema/dialogs/dialog_edit_label_base.h +++ b/eeschema/dialogs/dialog_edit_label_base.h @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Jun 5 2018) +// C++ code generated with wxFormBuilder (version Dec 30 2017) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! @@ -47,7 +47,7 @@ class DIALOG_LABEL_EDITOR_BASE : public DIALOG_SHIM wxTextCtrl* m_textLabelSingleLine; wxTextCtrl* m_textLabelMultiLine; wxStaticText* m_SizeTitle; - wxTextCtrl* m_TextSize; + wxTextCtrl* m_TextSizeCtrl; wxStaticText* m_staticSizeUnits; wxRadioBox* m_TextOrient; wxRadioBox* m_TextStyle; @@ -58,8 +58,6 @@ class DIALOG_LABEL_EDITOR_BASE : public DIALOG_SHIM // Virtual event handlers, overide them in your derived class virtual void OnEnterKey( wxCommandEvent& event ) { event.Skip(); } - virtual void OnCancelClick( wxCommandEvent& event ) { event.Skip(); } - virtual void OnOkClick( wxCommandEvent& event ) { event.Skip(); } public: diff --git a/include/base_units.h b/include/base_units.h index 07dd59f881..3ff720a4ae 100644 --- a/include/base_units.h +++ b/include/base_units.h @@ -37,6 +37,14 @@ #include #include + +/** + * Used for holding indeterminate values, such as with multiple selections + * holding different values or controls which do not wish to set a value. + */ +#define INDETERMINATE wxString( "<...>" ) + + /// Convert mm to mils. inline int Mm2mils( double x ) { return KiROUND( x * 1000./25.4 ); } diff --git a/include/dialog_shim.h b/include/dialog_shim.h index 94ff878e77..a281b54960 100644 --- a/include/dialog_shim.h +++ b/include/dialog_shim.h @@ -108,6 +108,8 @@ public: void OnPaint( wxPaintEvent &event ); + EDA_UNITS_T GetUserUnits() const override { return m_units; } + protected: /** @@ -146,9 +148,9 @@ protected: */ int VertPixelsFromDU( int y ); - bool m_fixupsRun; - - std::string m_hash_key; // alternate for class_map when classname re-used. + EDA_UNITS_T m_units; // userUnits for display and parsing + bool m_fixupsRun; // indicates various wxWidgets fixups have run + std::string m_hash_key; // alternate for class_map when classname re-used // variables for quasi-modal behavior support, only used by a few derivatives. EVENT_LOOP* m_qmodal_loop; // points to nested event_loop, NULL means not qmodal and dismissed diff --git a/include/draw_frame.h b/include/draw_frame.h index 7a45d30ebc..3480028808 100644 --- a/include/draw_frame.h +++ b/include/draw_frame.h @@ -256,9 +256,9 @@ public: /** * Function GetUserUnits - * returns the user unit currently in use + * returns the user units currently in use */ - EDA_UNITS_T GetUserUnits() const { return m_UserUnits; } + EDA_UNITS_T GetUserUnits() const override { return m_UserUnits; } void SetUserUnits( EDA_UNITS_T aUnits ) { m_UserUnits = aUnits; } /** diff --git a/include/kiway_player.h b/include/kiway_player.h index 098892bf34..694205c409 100644 --- a/include/kiway_player.h +++ b/include/kiway_player.h @@ -69,6 +69,15 @@ public: */ PROJECT& Prj() const; + /** + * Function GetUserUnits + * Allows participation in KEYWAY_PLAYER/DIALOG_SHIM userUnits inheritance. + * + * This would fit better in KEYWAY_PLAYER, but DIALOG_SHIMs can only use mix-ins + * because their primary superclass must be wxDialog. + */ + VTBL_ENTRY EDA_UNITS_T GetUserUnits() const; + /** * Function SetKiway * diff --git a/include/libeval/numeric_evaluator.h b/include/libeval/numeric_evaluator.h index 621977afd6..e2ffbdf5b6 100644 --- a/include/libeval/numeric_evaluator.h +++ b/include/libeval/numeric_evaluator.h @@ -74,6 +74,8 @@ Supported units are millimeters (mm), Mil (mil) and inch (") #include #include +#include + // This namespace is used for the lemon parser namespace numEval { @@ -96,15 +98,13 @@ class NumericEvaluator { public: NumericEvaluator(); + NumericEvaluator( EDA_UNITS_T aUnits, bool aUseMils ); ~NumericEvaluator(); - /* Initialization and destruction. init() is invoked be the constructor and should not be needed - * by the user. - * clear() should be invoked by the user if a new input string is to be processed. It will reset - * the parser and clear the original expression value for a requested object (if pObj != null). + /* clear() should be invoked by the client if a new input string is to be processed. It + * will reset the parser. User defined variables are retained. */ - void init(); - void clear(const void* pObj = nullptr); + void clear(const void* pObj = nullptr); /* Set the decimal separator for the input string. Defaults to '.' */ void setDecimalSeparator(char sep); @@ -125,6 +125,9 @@ public: /* Result of string processing. Undefined if !isValid() */ inline const char* result() const { return clToken.token; } + /* Numeric result of string processing, in default units. */ + inline const double value() const { return resultValue; } + /* Evaluate input string. * Result can be retrieved by result(). * Returns true if input string could be evaluated, otherwise false. @@ -184,6 +187,9 @@ private: bool bClError; bool bClParseFinished; + /* The result (in eClUnitDefault units) */ + int resultValue; + bool bClTextInputStorage; // Enable input string storage used by process(const char*, const void*) Unit eClUnitDefault; // Default unit for values diff --git a/include/widgets/unit_binder.h b/include/widgets/unit_binder.h index 25da17ec37..f0c97e962b 100644 --- a/include/widgets/unit_binder.h +++ b/include/widgets/unit_binder.h @@ -26,24 +26,37 @@ #define __UNIT_BINDER_H_ #include -#include +#include +#include + class wxTextEntry; class wxSpinButton; class wxStaticText; -class UNIT_BINDER + +class UNIT_BINDER : public wxEvtHandler { public: /** * Constructor. - * @param aParent is the parent window. - * @param aTextInput is the text input widget used to edit the given value (wxTextCtrl, wxComboBox, ...). - * @param aUnitLabel is the units label displayed next to the text field. - * @param aSpinButton is an optional spin button (for adjusting the input value) + * @param aParent is the parent EDA_DRAW_FRAME. + * @param aLabel is the static text used to label the text input widget (note: the label + * text, trimmed of its colon, will also be used in error messages) + * @param aTextEntry is the text input widget used to edit the given value (wxTextCtrl, + * wxComboBox, ...). + * @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( wxWindow* aParent, wxTextEntry* aTextInput, wxStaticText* aUnitLabel, wxSpinButton* aSpinButton = NULL ); + UNIT_BINDER( EDA_DRAW_FRAME* aParent, + wxStaticText* aLabel, wxTextEntry* aTextEntry, wxStaticText* aUnitLabel, + bool aUseMils = false, + int aMin = INT_MIN, int aMax = INT_MAX, + bool aAllowEval = true ); virtual ~UNIT_BINDER(); @@ -54,6 +67,8 @@ public: */ virtual void SetValue( int aValue ); + void SetValue( wxString aValue ); + /** * Function GetValue * Returns the current value in Internal Units. @@ -61,37 +76,53 @@ public: virtual int GetValue() const; /** - * Function Valid - * Returns true if the text control contains a real number. + * Function IsIndeterminate + * Returns true if the control holds the indeterminate value (for instance, if it + * represents a multiple selection of differing values). */ - bool Valid() const; + bool IsIndeterminate() const; + + /** + * Function Validate + * Validates the control, 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. + */ + virtual bool Validate( bool setFocusOnError = false ); /** * Function Enable - * Enables/diasables the binded widgets + * Enables/diasables the label, text input widget, and units label. */ void Enable( bool aEnable ); protected: void onTextChanged( wxEvent& aEvent ); + void onSetFocus( wxFocusEvent& aEvent ); + void onKillFocus( wxFocusEvent& aEvent ); + void onTextEnter( wxCommandEvent& aEvent ); + void delayedFocusHandler( wxIdleEvent& aEvent ); - ///> Text input control. - wxTextEntry* m_textEntry; + void evaluate(); - ///> Label showing currently used units. + ///> The bound widgets + wxStaticText* m_label; + wxTextEntry* m_textEntry; wxStaticText* m_unitLabel; ///> Currently used units. EDA_UNITS_T m_units; + bool m_useMils; - ///> Step size (added/subtracted difference if spin buttons are used). - int m_step; - int m_min; - int m_max; + ///> Validation support. + int m_min; + int m_max; - ///> Default value (or non-specified) - static const wxString DEFAULT_VALUE; + ///> Evaluator + NumericEvaluator m_eval; + bool m_allowEval; }; #endif /* __UNIT_BINDER_H_ */ diff --git a/pcbnew/dialogs/dialog_drc.cpp b/pcbnew/dialogs/dialog_drc.cpp index 88d1b0ea9b..83142d47e4 100644 --- a/pcbnew/dialogs/dialog_drc.cpp +++ b/pcbnew/dialogs/dialog_drc.cpp @@ -39,7 +39,6 @@ #include #include #include -#include #include #include #include @@ -88,7 +87,10 @@ protected: DIALOG_DRC_CONTROL::DIALOG_DRC_CONTROL( DRC* aTester, PCB_EDIT_FRAME* aEditorFrame, wxWindow* aParent ) : - DIALOG_DRC_CONTROL_BASE( aParent ) + DIALOG_DRC_CONTROL_BASE( aParent ), + m_trackMinWidth( aEditorFrame, m_TrackMinWidthTitle, m_SetTrackMinWidthCtrl, m_TrackMinWidthUnit, true ), + m_viaMinSize( aEditorFrame, m_ViaMinTitle, m_SetViaMinSizeCtrl, m_ViaMinUnit, true ), + m_uviaMinSize( aEditorFrame, m_MicroViaMinTitle, m_SetMicroViakMinSizeCtrl, m_MicroViaMinUnit, true ) { m_config = Kiface().KifaceSettings(); m_tester = aTester; @@ -168,13 +170,9 @@ void DIALOG_DRC_CONTROL::OnActivateDlg( wxActivateEvent& event ) void DIALOG_DRC_CONTROL::DisplayDRCValues() { - m_TrackMinWidthUnit->SetLabel( GetAbbreviatedUnitsLabel( g_UserUnit ) ); - m_ViaMinUnit->SetLabel( GetAbbreviatedUnitsLabel( g_UserUnit ) ); - m_MicroViaMinUnit->SetLabel(GetAbbreviatedUnitsLabel( g_UserUnit ) ); - - PutValueInLocalUnits( *m_SetTrackMinWidthCtrl, m_BrdSettings.m_TrackMinWidth ); - PutValueInLocalUnits( *m_SetViaMinSizeCtrl, m_BrdSettings.m_ViasMinSize ); - PutValueInLocalUnits( *m_SetMicroViakMinSizeCtrl, m_BrdSettings.m_MicroViasMinSize ); + m_trackMinWidth.SetValue( m_BrdSettings.m_TrackMinWidth ); + m_viaMinSize.SetValue( m_BrdSettings.m_ViasMinSize ); + m_uviaMinSize.SetValue( m_BrdSettings.m_MicroViasMinSize ); } @@ -205,9 +203,9 @@ void DIALOG_DRC_CONTROL::InitValues() */ void DIALOG_DRC_CONTROL::SetDrcParmeters( ) { - m_BrdSettings.m_TrackMinWidth = ValueFromTextCtrl( *m_SetTrackMinWidthCtrl ); - m_BrdSettings.m_ViasMinSize = ValueFromTextCtrl( *m_SetViaMinSizeCtrl ); - m_BrdSettings.m_MicroViasMinSize = ValueFromTextCtrl( *m_SetMicroViakMinSizeCtrl ); + m_BrdSettings.m_TrackMinWidth = m_trackMinWidth.GetValue(); + m_BrdSettings.m_ViasMinSize = m_viaMinSize.GetValue(); + m_BrdSettings.m_MicroViasMinSize = m_uviaMinSize.GetValue(); m_brdEditor->GetBoard()->SetDesignSettings( m_BrdSettings ); } diff --git a/pcbnew/dialogs/dialog_drc.h b/pcbnew/dialogs/dialog_drc.h index abb2b13d4c..5a7b93c4b6 100644 --- a/pcbnew/dialogs/dialog_drc.h +++ b/pcbnew/dialogs/dialog_drc.h @@ -38,6 +38,7 @@ #include #include +#include // forward declarations class DRCLISTBOX; @@ -148,8 +149,13 @@ private: DRC* m_tester; PCB_EDIT_FRAME* m_brdEditor; wxConfigBase* m_config; + wxString m_markersTitleTemplate; wxString m_unconnectedTitleTemplate; + + UNIT_BINDER m_trackMinWidth; + UNIT_BINDER m_viaMinSize; + UNIT_BINDER m_uviaMinSize; }; #endif // _DIALOG_DRC_H_ diff --git a/pcbnew/dialogs/dialog_pns_diff_pair_dimensions.cpp b/pcbnew/dialogs/dialog_pns_diff_pair_dimensions.cpp index 21744682c1..6f89a2b674 100644 --- a/pcbnew/dialogs/dialog_pns_diff_pair_dimensions.cpp +++ b/pcbnew/dialogs/dialog_pns_diff_pair_dimensions.cpp @@ -26,12 +26,14 @@ #include "dialog_pns_diff_pair_dimensions.h" #include #include +#include -DIALOG_PNS_DIFF_PAIR_DIMENSIONS::DIALOG_PNS_DIFF_PAIR_DIMENSIONS( wxWindow* aParent, PNS::SIZES_SETTINGS& aSizes ) : +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( this, m_traceWidthText, m_traceWidthUnit ), - m_traceGap( this, m_traceGapText, m_traceGapUnit ), - m_viaGap( this, m_viaGapText, m_viaGapUnit ), + m_traceWidth( aParent, m_traceWidthLabel, m_traceWidthText, m_traceWidthUnit ), + m_traceGap( aParent, m_traceGapLabel, m_traceGapText, m_traceGapUnit ), + m_viaGap( aParent, m_viaGapLabel, m_viaGapText, m_viaGapUnit ), m_sizes( aSizes ) { Layout(); @@ -44,7 +46,7 @@ DIALOG_PNS_DIFF_PAIR_DIMENSIONS::DIALOG_PNS_DIFF_PAIR_DIMENSIONS( wxWindow* aPar bool DIALOG_PNS_DIFF_PAIR_DIMENSIONS::TransferDataFromWindow() { - if( !wxDialog::TransferDataToWindow() ) + if( !wxDialog::TransferDataFromWindow() ) return false; // Save widgets' values to settings @@ -58,7 +60,7 @@ bool DIALOG_PNS_DIFF_PAIR_DIMENSIONS::TransferDataFromWindow() bool DIALOG_PNS_DIFF_PAIR_DIMENSIONS::TransferDataToWindow() { - if( !wxDialog::TransferDataFromWindow() ) + if( !wxDialog::TransferDataToWindow() ) return false; m_traceWidth.SetValue( m_sizes.DiffPairWidth() ); diff --git a/pcbnew/dialogs/dialog_pns_diff_pair_dimensions.h b/pcbnew/dialogs/dialog_pns_diff_pair_dimensions.h index b0d0ee1f02..4e512295bf 100644 --- a/pcbnew/dialogs/dialog_pns_diff_pair_dimensions.h +++ b/pcbnew/dialogs/dialog_pns_diff_pair_dimensions.h @@ -39,7 +39,7 @@ class SIZES_SETTINGS; class DIALOG_PNS_DIFF_PAIR_DIMENSIONS : public DIALOG_PNS_DIFF_PAIR_DIMENSIONS_BASE { public: - DIALOG_PNS_DIFF_PAIR_DIMENSIONS( wxWindow* aParent, PNS::SIZES_SETTINGS& aSizes ); + DIALOG_PNS_DIFF_PAIR_DIMENSIONS( EDA_DRAW_FRAME* aParent, PNS::SIZES_SETTINGS& aSizes ); bool TransferDataFromWindow() override; bool TransferDataToWindow() override; diff --git a/pcbnew/dialogs/dialog_pns_length_tuning_settings.cpp b/pcbnew/dialogs/dialog_pns_length_tuning_settings.cpp index 9eaaf9cfbe..19319254a5 100644 --- a/pcbnew/dialogs/dialog_pns_length_tuning_settings.cpp +++ b/pcbnew/dialogs/dialog_pns_length_tuning_settings.cpp @@ -27,15 +27,16 @@ #include #include #include +#include -DIALOG_PNS_LENGTH_TUNING_SETTINGS::DIALOG_PNS_LENGTH_TUNING_SETTINGS( wxWindow* aParent, +DIALOG_PNS_LENGTH_TUNING_SETTINGS::DIALOG_PNS_LENGTH_TUNING_SETTINGS( EDA_DRAW_FRAME* aParent, PNS::MEANDER_SETTINGS& aSettings, PNS::ROUTER_MODE aMode ) : DIALOG_PNS_LENGTH_TUNING_SETTINGS_BASE( aParent ), - m_minAmpl( this, m_minAmplText, m_minAmplUnit ), - m_maxAmpl( this, m_maxAmplText, m_maxAmplUnit ), - m_spacing( this, m_spacingText, m_spacingUnit ), - m_targetLength( this, m_targetLengthText, m_targetLengthUnit ), + m_minAmpl( aParent, m_minAmplLabel, m_minAmplText, m_minAmplUnit ), + m_maxAmpl( aParent, m_maxAmplLabel, m_maxAmplText, m_maxAmplUnit ), + m_spacing( aParent, m_spacingLabel, m_spacingText, m_spacingUnit ), + m_targetLength( aParent, m_targetLengthLabel, m_targetLengthText, m_targetLengthUnit ), m_settings( aSettings ), m_mode( aMode ) { diff --git a/pcbnew/dialogs/dialog_pns_length_tuning_settings.h b/pcbnew/dialogs/dialog_pns_length_tuning_settings.h index e5440c27e3..148681238e 100644 --- a/pcbnew/dialogs/dialog_pns_length_tuning_settings.h +++ b/pcbnew/dialogs/dialog_pns_length_tuning_settings.h @@ -41,7 +41,7 @@ class MEANDER_SETTINGS; class DIALOG_PNS_LENGTH_TUNING_SETTINGS : public DIALOG_PNS_LENGTH_TUNING_SETTINGS_BASE { public: - DIALOG_PNS_LENGTH_TUNING_SETTINGS( wxWindow* aParent, PNS::MEANDER_SETTINGS& aSettings, PNS::ROUTER_MODE aMode ); + DIALOG_PNS_LENGTH_TUNING_SETTINGS( EDA_DRAW_FRAME* aParent, PNS::MEANDER_SETTINGS& aSettings, PNS::ROUTER_MODE aMode ); virtual void OnOkClick( wxCommandEvent& aEvent ) override; diff --git a/pcbnew/dialogs/dialog_pns_length_tuning_settings_base.cpp b/pcbnew/dialogs/dialog_pns_length_tuning_settings_base.cpp index 57590e8039..68433ec43a 100644 --- a/pcbnew/dialogs/dialog_pns_length_tuning_settings_base.cpp +++ b/pcbnew/dialogs/dialog_pns_length_tuning_settings_base.cpp @@ -95,9 +95,9 @@ DIALOG_PNS_LENGTH_TUNING_SETTINGS_BASE::DIALOG_PNS_LENGTH_TUNING_SETTINGS_BASE( fgSizer3->SetFlexibleDirection( wxBOTH ); fgSizer3->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); - m_staticText9 = new wxStaticText( sbSizer2->GetStaticBox(), wxID_ANY, _("Min amplitude (Amin):"), wxDefaultPosition, wxDefaultSize, 0 ); - m_staticText9->Wrap( -1 ); - fgSizer3->Add( m_staticText9, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxRIGHT|wxLEFT, 5 ); + m_minAmplLabel = new wxStaticText( sbSizer2->GetStaticBox(), wxID_ANY, _("Min amplitude (Amin):"), wxDefaultPosition, wxDefaultSize, 0 ); + m_minAmplLabel->Wrap( -1 ); + fgSizer3->Add( m_minAmplLabel, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxRIGHT|wxLEFT, 5 ); m_minAmplText = new TEXT_CTRL_EVAL( sbSizer2->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); fgSizer3->Add( m_minAmplText, 0, wxEXPAND|wxLEFT|wxRIGHT|wxTOP, 5 ); @@ -106,9 +106,9 @@ DIALOG_PNS_LENGTH_TUNING_SETTINGS_BASE::DIALOG_PNS_LENGTH_TUNING_SETTINGS_BASE( m_minAmplUnit->Wrap( -1 ); fgSizer3->Add( m_minAmplUnit, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxRIGHT, 5 ); - m_staticText91 = new wxStaticText( sbSizer2->GetStaticBox(), wxID_ANY, _("Max amplitude (Amax):"), wxDefaultPosition, wxDefaultSize, 0 ); - m_staticText91->Wrap( -1 ); - fgSizer3->Add( m_staticText91, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxRIGHT|wxLEFT, 5 ); + m_maxAmplLabel = new wxStaticText( sbSizer2->GetStaticBox(), wxID_ANY, _("Max amplitude (Amax):"), wxDefaultPosition, wxDefaultSize, 0 ); + m_maxAmplLabel->Wrap( -1 ); + fgSizer3->Add( m_maxAmplLabel, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxRIGHT|wxLEFT, 5 ); m_maxAmplText = new TEXT_CTRL_EVAL( sbSizer2->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); fgSizer3->Add( m_maxAmplText, 0, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 ); @@ -117,9 +117,9 @@ DIALOG_PNS_LENGTH_TUNING_SETTINGS_BASE::DIALOG_PNS_LENGTH_TUNING_SETTINGS_BASE( m_maxAmplUnit->Wrap( -1 ); fgSizer3->Add( m_maxAmplUnit, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxRIGHT, 5 ); - m_staticText11 = new wxStaticText( sbSizer2->GetStaticBox(), wxID_ANY, _("Spacing (s):"), wxDefaultPosition, wxDefaultSize, 0 ); - m_staticText11->Wrap( -1 ); - fgSizer3->Add( m_staticText11, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxRIGHT|wxLEFT, 5 ); + m_spacingLabel = new wxStaticText( sbSizer2->GetStaticBox(), wxID_ANY, _("Spacing (s):"), wxDefaultPosition, wxDefaultSize, 0 ); + m_spacingLabel->Wrap( -1 ); + fgSizer3->Add( m_spacingLabel, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxRIGHT|wxLEFT, 5 ); m_spacingText = new TEXT_CTRL_EVAL( sbSizer2->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); fgSizer3->Add( m_spacingText, 0, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 ); @@ -165,7 +165,7 @@ DIALOG_PNS_LENGTH_TUNING_SETTINGS_BASE::DIALOG_PNS_LENGTH_TUNING_SETTINGS_BASE( m_stdButtons->AddButton( m_stdButtonsCancel ); m_stdButtons->Realize(); - bMainSizer->Add( m_stdButtons, 0, wxEXPAND|wxALL, 5 ); + bMainSizer->Add( m_stdButtons, 0, wxEXPAND, 5 ); this->SetSizer( bMainSizer ); diff --git a/pcbnew/dialogs/dialog_pns_length_tuning_settings_base.fbp b/pcbnew/dialogs/dialog_pns_length_tuning_settings_base.fbp index 9abc1adf4f..506b8b5cfd 100644 --- a/pcbnew/dialogs/dialog_pns_length_tuning_settings_base.fbp +++ b/pcbnew/dialogs/dialog_pns_length_tuning_settings_base.fbp @@ -1076,7 +1076,7 @@ 0 1 - m_staticText9 + m_minAmplLabel 1 @@ -1333,7 +1333,7 @@ 0 1 - m_staticText91 + m_maxAmplLabel 1 @@ -1590,7 +1590,7 @@ 0 1 - m_staticText11 + m_spacingLabel 1 @@ -2251,7 +2251,7 @@ 5 - wxEXPAND|wxALL + wxEXPAND 0 0 diff --git a/pcbnew/dialogs/dialog_pns_length_tuning_settings_base.h b/pcbnew/dialogs/dialog_pns_length_tuning_settings_base.h index ea826d5c2b..7b79b1aa51 100644 --- a/pcbnew/dialogs/dialog_pns_length_tuning_settings_base.h +++ b/pcbnew/dialogs/dialog_pns_length_tuning_settings_base.h @@ -52,13 +52,13 @@ class DIALOG_PNS_LENGTH_TUNING_SETTINGS_BASE : public DIALOG_SHIM TEXT_CTRL_EVAL* m_targetLengthText; wxStaticText* m_targetLengthUnit; wxStaticBitmap* m_legend; - wxStaticText* m_staticText9; + wxStaticText* m_minAmplLabel; TEXT_CTRL_EVAL* m_minAmplText; wxStaticText* m_minAmplUnit; - wxStaticText* m_staticText91; + wxStaticText* m_maxAmplLabel; TEXT_CTRL_EVAL* m_maxAmplText; wxStaticText* m_maxAmplUnit; - wxStaticText* m_staticText11; + wxStaticText* m_spacingLabel; TEXT_CTRL_EVAL* m_spacingText; wxStaticText* m_spacingUnit; wxStaticText* m_staticText14; diff --git a/pcbnew/dialogs/dialog_set_grid.cpp b/pcbnew/dialogs/dialog_set_grid.cpp index ea4c5c95d4..642dd36815 100644 --- a/pcbnew/dialogs/dialog_set_grid.cpp +++ b/pcbnew/dialogs/dialog_set_grid.cpp @@ -1,7 +1,7 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 1992-2016 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 1992-2018 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 @@ -29,8 +29,8 @@ #include #include -#include #include +#include #include #include @@ -40,20 +40,15 @@ #include #include -#include - // Max values for grid size -static const double MAX_GRID_SIZE = 1000.0 * IU_PER_MM; -static const double MIN_GRID_SIZE = 0.001 * IU_PER_MM; +static const int MAX_GRID_SIZE = KiROUND( 1000.0 * IU_PER_MM ); +static const int MIN_GRID_SIZE = KiROUND( 0.001 * IU_PER_MM ); -// Min/Max value for grid offset -static const double MAX_GRID_OFFSET = INT_MAX / 2.0; class DIALOG_SET_GRID : public DIALOG_SET_GRID_BASE { PCB_BASE_FRAME* m_parent; wxArrayString m_fast_grid_opts; - EDA_UNITS_T m_units; public: /// This has no dependencies on calling wxFrame derivative, such as PCB_BASE_FRAME. @@ -64,72 +59,64 @@ public: private: void OnResetGridOrgClick( wxCommandEvent& event ) override; - void OnInitDlg( wxInitDialogEvent& event ) override - { - // Call the default wxDialog handler of a wxInitDialogEvent - TransferDataToWindow(); - // Now all widgets have the size fixed, call FinishDialogSettings - FinishDialogSettings(); - } - - bool getGridSize( wxPoint& aGrisSize ); - bool getGridOrigin( wxPoint& aGridOrigin ); + UNIT_BINDER m_gridOriginX; + UNIT_BINDER m_gridOriginY; + UNIT_BINDER m_userGridX; + UNIT_BINDER m_userGridY; }; DIALOG_SET_GRID::DIALOG_SET_GRID( PCB_BASE_FRAME* aParent, const wxArrayString& aGridChoices ): DIALOG_SET_GRID_BASE( aParent ), m_parent( aParent ), - m_fast_grid_opts( aGridChoices ) + 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_comboBoxGrid1->Append( m_fast_grid_opts ); + m_comboBoxGrid2->Append( m_fast_grid_opts ); + m_sdbSizerOK->SetDefault(); // set OK button as default response to 'Enter' key - m_units = m_parent->GetUserUnits(); + Layout(); - m_TextPosXUnits->SetLabel( GetAbbreviatedUnitsLabel( m_units ) ); - m_TextPosYUnits->SetLabel( GetAbbreviatedUnitsLabel( m_units ) ); - - m_TextSizeXUnits->SetLabel( GetAbbreviatedUnitsLabel( m_units, true ) ); - m_TextSizeYUnits->SetLabel( GetAbbreviatedUnitsLabel( m_units, true ) ); + // Now all widgets have the size fixed, call FinishDialogSettings + FinishDialogSettings(); } bool DIALOG_SET_GRID::TransferDataFromWindow() { // Validate new settings - wxPoint gridOrigin; - - if( !getGridOrigin( gridOrigin ) ) - { - wxMessageBox( wxString::Format( _( "Invalid grid origin (must be between %.3f mm and %.3f mm)" ), - -MAX_GRID_OFFSET/IU_PER_MM, - MAX_GRID_OFFSET/IU_PER_MM ) ); + if( !m_gridOriginX.Validate( true ) ) return false; - } - wxPoint gridSize; - - if( !getGridSize( gridSize ) ) - { - wxMessageBox( wxString::Format( _( "Invalid grid size (must be between %.3f mm and %.3f mm)" ), - MIN_GRID_SIZE/IU_PER_MM, - MAX_GRID_SIZE/IU_PER_MM ) ); + if( !m_gridOriginY.Validate( true ) ) + return false; + + if( !m_userGridX.Validate( true ) ) + return false; + + if( !m_userGridY.Validate( true ) ) return false; - } // Apply the new settings // Because grid origin is saved in board, show as modified m_parent->OnModify(); - m_parent->SetGridOrigin( gridOrigin ); - m_parent->m_UserGridSize = gridSize; + m_parent->SetGridOrigin( wxPoint( m_gridOriginX.GetValue(), m_gridOriginY.GetValue() ) ); + m_parent->m_UserGridSize = wxPoint( m_userGridX.GetValue(), m_userGridY.GetValue() ); m_parent->m_FastGrid1 = m_comboBoxGrid1->GetSelection(); m_parent->m_FastGrid2 = m_comboBoxGrid2->GetSelection(); // User grid BASE_SCREEN* screen = m_parent->GetScreen(); - screen->AddGrid( gridSize, EDA_UNITS_T::UNSCALED_UNITS, ID_POPUP_GRID_USER ); + screen->AddGrid( m_parent->m_UserGridSize, EDA_UNITS_T::UNSCALED_UNITS, ID_POPUP_GRID_USER ); // If the user grid is the current option, recall SetGrid() // to force new values put in list as current grid value @@ -145,7 +132,7 @@ bool DIALOG_SET_GRID::TransferDataFromWindow() screen->GetGridCmdId() - ID_POPUP_GRID_LEVEL_1000 ); TOOL_EVENT gridOriginUpdate = ACTIONS::gridSetOrigin.MakeEvent(); - gridOriginUpdate.SetParameter( new VECTOR2D( gridOrigin ) ); + gridOriginUpdate.SetParameter( new VECTOR2D( m_parent->GetGridOrigin() ) ); mgr->ProcessEvent( gridOriginUpdate ); } @@ -155,14 +142,11 @@ bool DIALOG_SET_GRID::TransferDataFromWindow() bool DIALOG_SET_GRID::TransferDataToWindow() { - m_OptGridSizeX->SetValue( StringFromValue( m_units, m_parent->m_UserGridSize.x, false, true ) ); - m_OptGridSizeY->SetValue( StringFromValue( m_units, m_parent->m_UserGridSize.y, false, true ) ); + m_userGridX.SetValue( m_parent->m_UserGridSize.x ); + m_userGridY.SetValue( m_parent->m_UserGridSize.y ); - m_GridOriginXCtrl->SetValue( StringFromValue( m_units, m_parent->GetGridOrigin().x ) ); - m_GridOriginYCtrl->SetValue( StringFromValue( m_units, m_parent->GetGridOrigin().y ) ); - - m_comboBoxGrid1->Append( m_fast_grid_opts ); - m_comboBoxGrid2->Append( m_fast_grid_opts ); + m_gridOriginX.SetValue( m_parent->GetGridOrigin().x ); + m_gridOriginY.SetValue( m_parent->GetGridOrigin().y ); m_comboBoxGrid1->SetSelection( m_parent->m_FastGrid1 ); m_comboBoxGrid2->SetSelection( m_parent->m_FastGrid2 ); @@ -171,49 +155,10 @@ bool DIALOG_SET_GRID::TransferDataToWindow() } -bool DIALOG_SET_GRID::getGridSize( wxPoint& aGridSize ) -{ - double x = DoubleValueFromString( m_units, m_OptGridSizeX->GetValue(), true ); - - if( x < MIN_GRID_SIZE || x > MAX_GRID_SIZE ) - return false; - - double y = DoubleValueFromString( m_units, m_OptGridSizeY->GetValue(), true ); - - if( y < MIN_GRID_SIZE || y > MAX_GRID_SIZE ) - return false; - - aGridSize.x = KiROUND( x ); - aGridSize.y = KiROUND( y ); - - return true; -} - - -bool DIALOG_SET_GRID::getGridOrigin( wxPoint& aGridOrigin ) -{ - double x = DoubleValueFromString( m_units, m_GridOriginXCtrl->GetValue() ); - - // Some error checking here is a good thing. - if( x < -MAX_GRID_OFFSET || x > MAX_GRID_OFFSET ) - return false; - - double y = DoubleValueFromString( m_units, m_GridOriginYCtrl->GetValue() ); - - if( y < -MAX_GRID_OFFSET || y > MAX_GRID_OFFSET ) - return false; - - aGridOrigin.x = KiROUND( x ); - aGridOrigin.y = KiROUND( y ); - - return true; -} - - void DIALOG_SET_GRID::OnResetGridOrgClick( wxCommandEvent& event ) { - m_GridOriginXCtrl->SetValue( wxT( "0" ) ); - m_GridOriginYCtrl->SetValue( wxT( "0" ) ); + m_gridOriginX.SetValue( 0 ); + m_gridOriginY.SetValue( 0 ); } diff --git a/pcbnew/dialogs/dialog_set_grid_base.cpp b/pcbnew/dialogs/dialog_set_grid_base.cpp index a8f347846c..4fb36e2d26 100644 --- a/pcbnew/dialogs/dialog_set_grid_base.cpp +++ b/pcbnew/dialogs/dialog_set_grid_base.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Apr 19 2018) +// C++ code generated with wxFormBuilder (version Dec 30 2017) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! @@ -20,7 +20,7 @@ DIALOG_SET_GRID_BASE::DIALOG_SET_GRID_BASE( wxWindow* parent, wxWindowID id, con bUpperSizer = new wxBoxSizer( wxHORIZONTAL ); wxStaticBoxSizer* sbLeftSizer; - sbLeftSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Grid Origin:") ), wxVERTICAL ); + sbLeftSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Grid Origin") ), wxVERTICAL ); wxFlexGridSizer* fgSizerGridOrigin; fgSizerGridOrigin = new wxFlexGridSizer( 2, 3, 0, 0 ); @@ -30,40 +30,34 @@ DIALOG_SET_GRID_BASE::DIALOG_SET_GRID_BASE( wxWindow* parent, wxWindowID id, con m_staticTextGridPosX = new wxStaticText( sbLeftSizer->GetStaticBox(), wxID_ANY, _("X:"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticTextGridPosX->Wrap( -1 ); - fgSizerGridOrigin->Add( m_staticTextGridPosX, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxLEFT|wxTOP, 5 ); + fgSizerGridOrigin->Add( m_staticTextGridPosX, 0, wxALIGN_CENTER_VERTICAL, 5 ); m_GridOriginXCtrl = new wxTextCtrl( sbLeftSizer->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); - fgSizerGridOrigin->Add( m_GridOriginXCtrl, 0, wxEXPAND|wxLEFT|wxRIGHT|wxTOP, 5 ); + fgSizerGridOrigin->Add( m_GridOriginXCtrl, 0, wxEXPAND|wxLEFT, 5 ); m_TextPosXUnits = new wxStaticText( sbLeftSizer->GetStaticBox(), wxID_ANY, _("mm"), wxDefaultPosition, wxDefaultSize, 0 ); m_TextPosXUnits->Wrap( -1 ); - fgSizerGridOrigin->Add( m_TextPosXUnits, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_LEFT|wxTOP, 5 ); + fgSizerGridOrigin->Add( m_TextPosXUnits, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_LEFT, 5 ); m_staticTextGridPosY = new wxStaticText( sbLeftSizer->GetStaticBox(), wxID_ANY, _("Y:"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticTextGridPosY->Wrap( -1 ); - fgSizerGridOrigin->Add( m_staticTextGridPosY, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxBOTTOM|wxLEFT|wxTOP, 5 ); + fgSizerGridOrigin->Add( m_staticTextGridPosY, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM, 5 ); m_GridOriginYCtrl = new wxTextCtrl( sbLeftSizer->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); - fgSizerGridOrigin->Add( m_GridOriginYCtrl, 0, wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT|wxTOP, 5 ); + fgSizerGridOrigin->Add( m_GridOriginYCtrl, 0, wxEXPAND|wxTOP|wxBOTTOM|wxLEFT, 5 ); m_TextPosYUnits = new wxStaticText( sbLeftSizer->GetStaticBox(), wxID_ANY, _("mm"), wxDefaultPosition, wxDefaultSize, 0 ); m_TextPosYUnits->Wrap( -1 ); fgSizerGridOrigin->Add( m_TextPosYUnits, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_LEFT, 5 ); - sbLeftSizer->Add( fgSizerGridOrigin, 1, wxALL|wxEXPAND, 5 ); - - m_buttonReset = new wxButton( sbLeftSizer->GetStaticBox(), wxID_ANY, _("Reset Grid Origin"), wxDefaultPosition, wxDefaultSize, 0 ); - sbLeftSizer->Add( m_buttonReset, 0, wxALL|wxEXPAND, 5 ); + sbLeftSizer->Add( fgSizerGridOrigin, 0, wxEXPAND|wxRIGHT|wxLEFT, 5 ); - bUpperSizer->Add( sbLeftSizer, 0, wxEXPAND|wxALL, 5 ); - - wxBoxSizer* bRightSizer; - bRightSizer = new wxBoxSizer( wxVERTICAL ); + bUpperSizer->Add( sbLeftSizer, 0, wxEXPAND|wxTOP|wxBOTTOM|wxRIGHT, 5 ); wxStaticBoxSizer* sbUserGridSizer; - sbUserGridSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("User Defined Grid:") ), wxVERTICAL ); + sbUserGridSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("User Defined Grid") ), wxVERTICAL ); wxFlexGridSizer* fgSizer31; fgSizer31 = new wxFlexGridSizer( 2, 3, 0, 0 ); @@ -73,10 +67,10 @@ DIALOG_SET_GRID_BASE::DIALOG_SET_GRID_BASE( wxWindow* parent, wxWindowID id, con m_staticTextSizeX = new wxStaticText( sbUserGridSizer->GetStaticBox(), wxID_ANY, _("Size X:"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticTextSizeX->Wrap( -1 ); - fgSizer31->Add( m_staticTextSizeX, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxLEFT|wxRIGHT, 5 ); + fgSizer31->Add( m_staticTextSizeX, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT, 5 ); m_OptGridSizeX = new wxTextCtrl( sbUserGridSizer->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); - fgSizer31->Add( m_OptGridSizeX, 0, wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT, 5 ); + fgSizer31->Add( m_OptGridSizeX, 0, wxEXPAND|wxBOTTOM|wxLEFT, 5 ); m_TextSizeXUnits = new wxStaticText( sbUserGridSizer->GetStaticBox(), wxID_ANY, _("mm"), wxDefaultPosition, wxDefaultSize, 0 ); m_TextSizeXUnits->Wrap( -1 ); @@ -84,23 +78,26 @@ DIALOG_SET_GRID_BASE::DIALOG_SET_GRID_BASE( wxWindow* parent, wxWindowID id, con m_staticTextSizeY = new wxStaticText( sbUserGridSizer->GetStaticBox(), wxID_ANY, _("Size Y:"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticTextSizeY->Wrap( -1 ); - fgSizer31->Add( m_staticTextSizeY, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT, 5 ); + fgSizer31->Add( m_staticTextSizeY, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 ); m_OptGridSizeY = new wxTextCtrl( sbUserGridSizer->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); - fgSizer31->Add( m_OptGridSizeY, 0, wxEXPAND|wxLEFT|wxRIGHT, 5 ); + fgSizer31->Add( m_OptGridSizeY, 0, wxEXPAND|wxLEFT, 5 ); m_TextSizeYUnits = new wxStaticText( sbUserGridSizer->GetStaticBox(), wxID_ANY, _("mm"), wxDefaultPosition, wxDefaultSize, 0 ); m_TextSizeYUnits->Wrap( -1 ); fgSizer31->Add( m_TextSizeYUnits, 0, wxALIGN_CENTER_VERTICAL, 5 ); - sbUserGridSizer->Add( fgSizer31, 0, wxALL|wxEXPAND, 5 ); + sbUserGridSizer->Add( fgSizer31, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); - bRightSizer->Add( sbUserGridSizer, 0, wxALL|wxEXPAND, 5 ); + bUpperSizer->Add( sbUserGridSizer, 0, wxEXPAND|wxTOP|wxBOTTOM|wxLEFT, 5 ); + + + bSizerMain->Add( bUpperSizer, 0, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 ); wxStaticBoxSizer* sbFastSwitchSizer; - sbFastSwitchSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Fast Switching:") ), wxVERTICAL ); + sbFastSwitchSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Fast Switching") ), wxVERTICAL ); wxFlexGridSizer* fgSizer3; fgSizer3 = new wxFlexGridSizer( 2, 2, 0, 0 ); @@ -110,29 +107,36 @@ DIALOG_SET_GRID_BASE::DIALOG_SET_GRID_BASE( wxWindow* parent, wxWindowID id, con m_staticTextGrid1 = new wxStaticText( sbFastSwitchSizer->GetStaticBox(), wxID_ANY, _("Grid 1:"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticTextGrid1->Wrap( -1 ); - fgSizer3->Add( m_staticTextGrid1, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 5 ); + fgSizer3->Add( m_staticTextGrid1, 0, wxALIGN_CENTER_VERTICAL, 5 ); m_comboBoxGrid1 = new wxComboBox( sbFastSwitchSizer->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, NULL, wxCB_READONLY ); - fgSizer3->Add( m_comboBoxGrid1, 1, wxEXPAND|wxLEFT|wxRIGHT, 5 ); + m_comboBoxGrid1->SetMinSize( wxSize( 240,-1 ) ); + + fgSizer3->Add( m_comboBoxGrid1, 0, wxLEFT, 5 ); m_staticTextGrid2 = new wxStaticText( sbFastSwitchSizer->GetStaticBox(), wxID_ANY, _("Grid 2:"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticTextGrid2->Wrap( -1 ); - fgSizer3->Add( m_staticTextGrid2, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxLEFT, 5 ); + fgSizer3->Add( m_staticTextGrid2, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT, 5 ); m_comboBoxGrid2 = new wxComboBox( sbFastSwitchSizer->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, NULL, wxCB_READONLY ); - fgSizer3->Add( m_comboBoxGrid2, 1, wxALL|wxEXPAND, 5 ); + m_comboBoxGrid2->SetMinSize( wxSize( 240,-1 ) ); + + fgSizer3->Add( m_comboBoxGrid2, 0, wxTOP|wxBOTTOM|wxLEFT, 5 ); - sbFastSwitchSizer->Add( fgSizer3, 0, wxEXPAND, 5 ); + sbFastSwitchSizer->Add( fgSizer3, 0, wxEXPAND|wxLEFT, 5 ); - bRightSizer->Add( sbFastSwitchSizer, 0, wxALL|wxEXPAND, 5 ); + bSizerMain->Add( sbFastSwitchSizer, 0, wxEXPAND|wxALL, 5 ); + + wxBoxSizer* bButtonSizer; + bButtonSizer = new wxBoxSizer( wxHORIZONTAL ); + + m_buttonReset = new wxButton( this, wxID_ANY, _("Reset Grid Origin"), wxDefaultPosition, wxDefaultSize, 0 ); + bButtonSizer->Add( m_buttonReset, 0, wxALL|wxEXPAND, 5 ); - bUpperSizer->Add( bRightSizer, 1, wxEXPAND, 5 ); - - - bSizerMain->Add( bUpperSizer, 1, wxEXPAND, 5 ); + bButtonSizer->Add( 0, 0, 1, wxEXPAND, 5 ); m_sdbSizer = new wxStdDialogButtonSizer(); m_sdbSizerOK = new wxButton( this, wxID_OK ); @@ -141,7 +145,10 @@ DIALOG_SET_GRID_BASE::DIALOG_SET_GRID_BASE( wxWindow* parent, wxWindowID id, con m_sdbSizer->AddButton( m_sdbSizerCancel ); m_sdbSizer->Realize(); - bSizerMain->Add( m_sdbSizer, 0, wxEXPAND, 5 ); + bButtonSizer->Add( m_sdbSizer, 0, wxEXPAND, 5 ); + + + bSizerMain->Add( bButtonSizer, 0, wxEXPAND|wxLEFT, 5 ); this->SetSizer( bSizerMain ); diff --git a/pcbnew/dialogs/dialog_set_grid_base.fbp b/pcbnew/dialogs/dialog_set_grid_base.fbp index f6d7523b6f..8cbeecbf27 100644 --- a/pcbnew/dialogs/dialog_set_grid_base.fbp +++ b/pcbnew/dialogs/dialog_set_grid_base.fbp @@ -14,7 +14,6 @@ dialog_set_grid_base 1000 none - 1 dialog_set_grid @@ -46,7 +45,7 @@ DIALOG_SET_GRID_BASE -1,-1 - wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER + wxDEFAULT_DIALOG_STYLE DIALOG_SHIM; dialog_shim.h Grid Settings @@ -96,20 +95,20 @@ none 5 - wxEXPAND - 1 + wxEXPAND|wxTOP|wxRIGHT|wxLEFT + 0 bUpperSizer wxHORIZONTAL none - + 5 - wxEXPAND|wxALL + wxEXPAND|wxTOP|wxBOTTOM|wxRIGHT 0 wxID_ANY - Grid Origin: + Grid Origin sbLeftSizer wxVERTICAL @@ -118,8 +117,8 @@ 5 - wxALL|wxEXPAND - 1 + wxEXPAND|wxRIGHT|wxLEFT + 0 3 wxBOTH @@ -134,7 +133,7 @@ 0 5 - wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxLEFT|wxTOP + wxALIGN_CENTER_VERTICAL 0 1 @@ -217,7 +216,7 @@ 5 - wxEXPAND|wxLEFT|wxRIGHT|wxTOP + wxEXPAND|wxLEFT 0 1 @@ -308,7 +307,7 @@ 5 - wxALIGN_CENTER_VERTICAL|wxALIGN_LEFT|wxTOP + wxALIGN_CENTER_VERTICAL|wxALIGN_LEFT 0 1 @@ -391,7 +390,7 @@ 5 - wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxBOTTOM|wxLEFT|wxTOP + wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM 0 1 @@ -474,7 +473,7 @@ 5 - wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT|wxTOP + wxEXPAND|wxTOP|wxBOTTOM|wxLEFT 0 1 @@ -648,11 +647,591 @@ + + + + 5 + wxEXPAND|wxTOP|wxBOTTOM|wxLEFT + 0 + + wxID_ANY + User Defined Grid + + sbUserGridSizer + wxVERTICAL + 1 + none + 5 - wxALL|wxEXPAND + wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT 0 - + + 3 + wxBOTH + 1 + + 0 + + fgSizer31 + wxFLEX_GROWMODE_SPECIFIED + none + 2 + 0 + + 5 + wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Size X: + + 0 + + + 0 + + 1 + m_staticTextSizeX + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND|wxBOTTOM|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + 0 + + 0 + + 1 + m_OptGridSizeX + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALIGN_CENTER_VERTICAL|wxBOTTOM + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + mm + + 0 + + + 0 + + 1 + m_TextSizeXUnits + 1 + + + protected + 1 + + Resizable + 1 + + + ; forward_declare + 0 + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALIGN_CENTER_VERTICAL|wxRIGHT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Size Y: + + 0 + + + 0 + + 1 + m_staticTextSizeY + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + 0 + + 0 + + 1 + m_OptGridSizeY + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALIGN_CENTER_VERTICAL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + mm + + 0 + + + 0 + + 1 + m_TextSizeYUnits + 1 + + + protected + 1 + + Resizable + 1 + + + ; forward_declare + 0 + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND|wxALL + 0 + + wxID_ANY + Fast Switching + + sbFastSwitchSizer + wxVERTICAL + 1 + none + + + 5 + wxEXPAND|wxLEFT + 0 + + 2 + wxBOTH + 1 + + 0 + + fgSizer3 + wxFLEX_GROWMODE_SPECIFIED + none + 2 + 0 + + 5 + wxALIGN_CENTER_VERTICAL + 0 + 1 1 1 @@ -669,7 +1248,6 @@ 1 1 - 0 0 Dock 0 @@ -681,7 +1259,7 @@ 0 0 wxID_ANY - Reset Grid Origin + Grid 1: 0 @@ -689,7 +1267,7 @@ 0 1 - m_buttonReset + m_staticTextGrid1 1 @@ -703,14 +1281,10 @@ 0 - - wxFILTER_NONE - wxDefaultValidator - - OnResetGridOrgClick + -1 @@ -736,947 +1310,273 @@ - - - - 5 - wxEXPAND - 1 - - - bRightSizer - wxVERTICAL - none - + 5 - wxALL|wxEXPAND + wxLEFT 0 - + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 wxID_ANY - User Defined Grid: - - sbUserGridSizer - wxVERTICAL - 1 - none + + 0 + + + 0 + 240,-1 + 1 + m_comboBoxGrid1 + 1 + + + protected + 1 + + Resizable + -1 + 1 + + wxCB_READONLY + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - 5 - wxALL|wxEXPAND - 0 - - 3 - wxBOTH - 1 - - 0 - - fgSizer31 - wxFLEX_GROWMODE_SPECIFIED - none - 2 - 0 - - 5 - wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxLEFT|wxRIGHT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Size X: - - 0 - - - 0 - - 1 - m_staticTextSizeX - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - - - -1 - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - 0 - - 0 - - 1 - m_OptGridSizeX - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxALIGN_CENTER_VERTICAL|wxBOTTOM - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - mm - - 0 - - - 0 - - 1 - m_TextSizeXUnits - 1 - - - protected - 1 - - Resizable - 1 - - - ; forward_declare - 0 - - - - - -1 - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Size Y: - - 0 - - - 0 - - 1 - m_staticTextSizeY - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - - - -1 - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxEXPAND|wxLEFT|wxRIGHT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - 0 - - 0 - - 1 - m_OptGridSizeY - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxALIGN_CENTER_VERTICAL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - mm - - 0 - - - 0 - - 1 - m_TextSizeYUnits - 1 - - - protected - 1 - - Resizable - 1 - - - ; forward_declare - 0 - - - - - -1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - + 5 - wxALL|wxEXPAND + wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT 0 - + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 wxID_ANY - Fast Switching: + Grid 2: + + 0 + + + 0 - sbFastSwitchSizer - wxVERTICAL - 1 - none + 1 + m_staticTextGrid2 + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxTOP|wxBOTTOM|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + 240,-1 + 1 + m_comboBoxGrid2 + 1 + + + protected + 1 + + Resizable + -1 + 1 + + wxCB_READONLY + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - 5 - wxEXPAND - 0 - - 2 - wxBOTH - 1 - - 0 - - fgSizer3 - wxFLEX_GROWMODE_SPECIFIED - none - 2 - 0 - - 5 - wxALIGN_CENTER_VERTICAL|wxLEFT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Grid 1: - - 0 - - - 0 - - 1 - m_staticTextGrid1 - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - - - -1 - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxEXPAND|wxLEFT|wxRIGHT - 1 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - - 0 - - 1 - m_comboBoxGrid1 - 1 - - - protected - 1 - - Resizable - -1 - 1 - - wxCB_READONLY - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxLEFT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Grid 2: - - 0 - - - 0 - - 1 - m_staticTextGrid2 - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - - - -1 - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxALL|wxEXPAND - 1 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - - 0 - - 1 - m_comboBoxGrid2 - 1 - - - protected - 1 - - Resizable - -1 - 1 - - wxCB_READONLY - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1685,28 +1585,137 @@ 5 - wxEXPAND + wxEXPAND|wxLEFT 0 - - 0 - 1 - 0 - 0 - 0 - 1 - 0 - 0 + - m_sdbSizer - protected - - OnCancelClick - - - - OnOkClick - - + bButtonSizer + wxHORIZONTAL + none + + 5 + wxALL|wxEXPAND + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Reset Grid Origin + + 0 + + + 0 + + 1 + m_buttonReset + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + OnResetGridOrgClick + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND + 1 + + 0 + protected + 0 + + + + 5 + wxEXPAND + 0 + + 0 + 1 + 0 + 0 + 0 + 1 + 0 + 0 + + m_sdbSizer + protected + + OnCancelClick + + + + OnOkClick + + + + diff --git a/pcbnew/dialogs/dialog_set_grid_base.h b/pcbnew/dialogs/dialog_set_grid_base.h index 1f52b8c6b3..3e15863a8f 100644 --- a/pcbnew/dialogs/dialog_set_grid_base.h +++ b/pcbnew/dialogs/dialog_set_grid_base.h @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Apr 19 2018) +// C++ code generated with wxFormBuilder (version Dec 30 2017) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! @@ -20,9 +20,9 @@ #include #include #include -#include #include #include +#include #include /////////////////////////////////////////////////////////////////////////// @@ -42,7 +42,6 @@ class DIALOG_SET_GRID_BASE : public DIALOG_SHIM wxStaticText* m_staticTextGridPosY; wxTextCtrl* m_GridOriginYCtrl; wxStaticText* m_TextPosYUnits; - wxButton* m_buttonReset; wxStaticText* m_staticTextSizeX; wxTextCtrl* m_OptGridSizeX; wxStaticText* m_TextSizeXUnits; @@ -53,6 +52,7 @@ class DIALOG_SET_GRID_BASE : public DIALOG_SHIM wxComboBox* m_comboBoxGrid1; wxStaticText* m_staticTextGrid2; wxComboBox* m_comboBoxGrid2; + wxButton* m_buttonReset; wxStdDialogButtonSizer* m_sdbSizer; wxButton* m_sdbSizerOK; wxButton* m_sdbSizerCancel; @@ -66,7 +66,7 @@ class DIALOG_SET_GRID_BASE : public DIALOG_SHIM public: - DIALOG_SET_GRID_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Grid Settings"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); + DIALOG_SET_GRID_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Grid Settings"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE ); ~DIALOG_SET_GRID_BASE(); }; diff --git a/pcbnew/dialogs/dialog_track_via_properties.cpp b/pcbnew/dialogs/dialog_track_via_properties.cpp index 6bb032c339..68813abe15 100644 --- a/pcbnew/dialogs/dialog_track_via_properties.cpp +++ b/pcbnew/dialogs/dialog_track_via_properties.cpp @@ -28,40 +28,32 @@ #include #include #include -#include #include #include -DIALOG_TRACK_VIA_PROPERTIES::DIALOG_TRACK_VIA_PROPERTIES( PCB_BASE_FRAME* aParent, const SELECTION& aItems ) : - DIALOG_TRACK_VIA_PROPERTIES_BASE( aParent ), m_items( aItems ), - m_trackStartX( aParent, m_TrackStartXCtrl, m_TrackStartXUnit ), - m_trackStartY( aParent, m_TrackStartYCtrl, m_TrackStartYUnit ), - m_trackEndX( aParent, m_TrackEndXCtrl, m_TrackEndXUnit ), - m_trackEndY( aParent, m_TrackEndYCtrl, m_TrackEndYUnit ), - m_trackWidth( aParent, m_TrackWidthCtrl, m_TrackWidthUnit ), - m_viaX( aParent, m_ViaXCtrl, m_ViaXUnit ), m_viaY( aParent, m_ViaYCtrl, m_ViaYUnit ), - m_viaDiameter( aParent, m_ViaDiameterCtrl, m_ViaDiameterUnit ), - m_viaDrill( aParent, m_ViaDrillCtrl, m_ViaDrillUnit ), - m_tracks( false ), m_vias( false ) +#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 ) : + DIALOG_TRACK_VIA_PROPERTIES_BASE( aParent ), + m_items( aItems ), m_commit( aCommit ), + m_trackStartX( aParent, m_TrackStartXLabel, m_TrackStartXCtrl, m_TrackStartXUnit ), + 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, false, MIN_SIZE ), + 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, false, MIN_SIZE ), + m_viaDrill( aParent, m_ViaDrillLabel, m_ViaDrillCtrl, m_ViaDrillUnit, false, MIN_SIZE ), + m_tracks( false ), + m_vias( false ) { wxASSERT( !m_items.Empty() ); - // This is a way to trick gcc into considering these variables as initialized - OPT trackStartX( []()->OPT { return NULLOPT; }() ); - OPT trackStartY( []()->OPT { return NULLOPT; }() ); - OPT trackEndX( []()->OPT { return NULLOPT; }() ); - OPT trackEndY( []()->OPT { return NULLOPT; }() ); - OPT trackWidth( []()->OPT { return NULLOPT; }() ); - OPT trackLayer( []()->OPT { return NULLOPT; }() ); - OPT viaX( []()->OPT { return NULLOPT; }() ); - OPT viaY( []()->OPT { return NULLOPT; }() ); - OPT viaDiameter( []()->OPT { return NULLOPT; }() ); - OPT viaDrill( []()->OPT { return NULLOPT; }() ); - - VIATYPE_T viaType = VIA_NOT_DEFINED; - PCB_LAYER_ID viaStartLayer = UNDEFINED_LAYER; - PCB_LAYER_ID viaEndLayer = UNDEFINED_LAYER; + VIATYPE_T viaType = VIA_NOT_DEFINED; m_haveUniqueNet = true; int prevNet = -1; @@ -87,13 +79,9 @@ DIALOG_TRACK_VIA_PROPERTIES::DIALOG_TRACK_VIA_PROPERTIES( PCB_BASE_FRAME* aParen } if ( m_haveUniqueNet ) - { m_NetComboBox->SetSelectedNet( prevNet ); - } else - { m_NetComboBox->SetMultiple( true ); - } // Look for values that are common for every item that is selected @@ -107,33 +95,33 @@ DIALOG_TRACK_VIA_PROPERTIES::DIALOG_TRACK_VIA_PROPERTIES( PCB_BASE_FRAME* aParen if( !m_tracks ) // first track in the list { - trackStartX = t->GetStart().x; - trackStartY = t->GetStart().y; - trackEndX = t->GetEnd().x; - trackEndY = t->GetEnd().y; - trackWidth = t->GetWidth(); - trackLayer = t->GetLayer(); + m_trackStartX.SetValue( t->GetStart().x ); + m_trackStartY.SetValue( t->GetStart().y ); + m_trackEndX.SetValue( t->GetEnd().x ); + m_trackEndY.SetValue( t->GetEnd().y ); + m_trackWidth.SetValue( t->GetWidth() ); + m_TrackLayerCtrl->SetLayerSelection( t->GetLayer() ); m_tracks = true; } else // check if values are the same for every selected track { - if( trackStartX && ( *trackStartX != t->GetStart().x ) ) - trackStartX = NULLOPT; + if( m_trackStartX.GetValue() != t->GetStart().x ) + m_trackStartX.SetValue( INDETERMINATE ); - if( trackStartY && ( *trackStartY != t->GetStart().y ) ) - trackStartY = NULLOPT; + if( m_trackStartY.GetValue() != t->GetStart().y ) + m_trackStartY.SetValue( INDETERMINATE ); - if( trackEndX && ( *trackEndX != t->GetEnd().x ) ) - trackEndX = NULLOPT; + if( m_trackEndX.GetValue() != t->GetEnd().x ) + m_trackEndX.SetValue( INDETERMINATE ); - if( trackEndY && ( *trackEndY != t->GetEnd().y ) ) - trackEndY = NULLOPT; + if( m_trackEndY.GetValue() != t->GetEnd().y ) + m_trackEndY.SetValue( INDETERMINATE ); - if( trackWidth && ( *trackWidth != t->GetWidth() ) ) - trackWidth = NULLOPT; + if( m_trackWidth.GetValue() != t->GetWidth() ) + m_trackWidth.SetValue( INDETERMINATE ); - if( trackLayer && ( *trackLayer != t->GetLayer() ) ) - trackLayer = NULLOPT; + if( m_TrackLayerCtrl->GetLayerSelection() != t->GetLayer() ) + m_TrackLayerCtrl->SetLayerSelection( UNDEFINED_LAYER ); } if( t->IsLocked() ) @@ -150,37 +138,37 @@ DIALOG_TRACK_VIA_PROPERTIES::DIALOG_TRACK_VIA_PROPERTIES( PCB_BASE_FRAME* aParen if( !m_vias ) // first via in the list { - viaX = v->GetPosition().x; - viaY = v->GetPosition().y; - viaDiameter = v->GetWidth(); - viaDrill = v->GetDrillValue(); + m_viaX.SetValue( v->GetPosition().x ); + m_viaY.SetValue( v->GetPosition().y ); + m_viaDiameter.SetValue( v->GetWidth() ); + m_viaDrill.SetValue( v->GetDrillValue() ); m_vias = true; viaType = v->GetViaType(); - viaStartLayer = v->TopLayer(); - viaEndLayer = v->BottomLayer(); + m_ViaStartLayer->SetLayerSelection( v->TopLayer() ); + m_ViaEndLayer->SetLayerSelection( v->BottomLayer() ); } else // check if values are the same for every selected via { - if( viaX && ( *viaX != v->GetPosition().x ) ) - viaX = NULLOPT; + if( m_viaX.GetValue() != v->GetPosition().x ) + m_viaX.SetValue( INDETERMINATE ); - if( viaY && ( *viaY != v->GetPosition().y ) ) - viaY = NULLOPT; + if( m_viaY.GetValue() != v->GetPosition().y ) + m_viaY.SetValue( INDETERMINATE ); - if( viaDiameter && ( *viaDiameter != v->GetWidth() ) ) - viaDiameter = NULLOPT; + if( m_viaDiameter.GetValue() != v->GetWidth() ) + m_viaDiameter.SetValue( INDETERMINATE ); - if( viaDrill && ( *viaDrill != v->GetDrillValue() ) ) - viaDrill = NULLOPT; + if( m_viaDrill.GetValue() != v->GetDrillValue() ) + m_viaDrill.SetValue( INDETERMINATE ); if( viaType != v->GetViaType() ) viaType = VIA_NOT_DEFINED; - if( viaStartLayer != v->TopLayer() ) - viaStartLayer = UNDEFINED_LAYER; + if( m_ViaStartLayer->GetLayerSelection() != v->TopLayer() ) + m_ViaStartLayer->SetLayerSelection( UNDEFINED_LAYER ); - if( viaEndLayer != v->BottomLayer() ) - viaEndLayer = UNDEFINED_LAYER; + if( m_ViaEndLayer->GetLayerSelection() != v->BottomLayer() ) + m_ViaEndLayer->SetLayerSelection( UNDEFINED_LAYER ); } if( v->IsLocked() ) @@ -203,24 +191,20 @@ DIALOG_TRACK_VIA_PROPERTIES::DIALOG_TRACK_VIA_PROPERTIES( PCB_BASE_FRAME* aParen if( m_vias ) { - setCommonVal( viaX, m_ViaXCtrl, m_viaX ); - setCommonVal( viaY, m_ViaYCtrl, m_viaY ); - setCommonVal( viaDiameter, m_ViaDiameterCtrl, m_viaDiameter ); - setCommonVal( viaDrill, m_ViaDrillCtrl, m_viaDrill ); - - m_DesignRuleViasUnit->SetLabel( GetAbbreviatedUnitsLabel( g_UserUnit ) ); + m_DesignRuleViasUnit->SetLabel( GetAbbreviatedUnitsLabel( m_units ) ); int viaSelection = wxNOT_FOUND; for( unsigned ii = 0; ii < aParent->GetDesignSettings().m_ViasDimensionsList.size(); ii++ ) { VIA_DIMENSION* viaDimension = &aParent->GetDesignSettings().m_ViasDimensionsList[ii]; - wxString msg = StringFromValue( g_UserUnit, viaDimension->m_Diameter, false ) - + " / " + StringFromValue( g_UserUnit, viaDimension->m_Drill, false ); + wxString msg = StringFromValue( m_units, viaDimension->m_Diameter, false ) + + " / " + StringFromValue( m_units, viaDimension->m_Drill, false ); m_DesignRuleViasCtrl->Append( msg, viaDimension ); - if( viaSelection == wxNOT_FOUND && viaDiameter == viaDimension->m_Diameter - && viaDrill == viaDimension->m_Drill ) + if( viaSelection == wxNOT_FOUND + && m_viaDiameter.GetValue() == viaDimension->m_Diameter + && m_viaDrill.GetValue() == viaDimension->m_Drill ) { viaSelection = ii; } @@ -246,7 +230,6 @@ DIALOG_TRACK_VIA_PROPERTIES::DIALOG_TRACK_VIA_PROPERTIES( PCB_BASE_FRAME* aParen else if( viaType == VIA_NOT_DEFINED ) m_ViaTypeChoice->SetSelection( 3 ); - m_ViaStartLayer->SetLayersHotkeys( false ); m_ViaStartLayer->SetNotAllowedLayerSet( LSET::AllNonCuMask() ); m_ViaStartLayer->SetBoardFrame( aParent ); @@ -256,19 +239,8 @@ DIALOG_TRACK_VIA_PROPERTIES::DIALOG_TRACK_VIA_PROPERTIES( PCB_BASE_FRAME* aParen m_ViaEndLayer->SetBoardFrame( aParent ); m_ViaEndLayer->Resync(); - - m_ViaStartLayer->SetLayerSelection( viaStartLayer ); - m_ViaEndLayer->SetLayerSelection( viaEndLayer ); - - m_ViaStartLayer->Enable( false ); - m_ViaEndLayer->Enable( false ); - - if( viaType != VIA_THROUGH ) // check if selected type isnt through. - { - m_ViaStartLayer->Enable(); - m_ViaEndLayer->Enable(); - } - + m_ViaStartLayer->Enable( viaType != VIA_THROUGH ); + m_ViaEndLayer->Enable( viaType != VIA_THROUGH ); } else { @@ -277,16 +249,10 @@ DIALOG_TRACK_VIA_PROPERTIES::DIALOG_TRACK_VIA_PROPERTIES( PCB_BASE_FRAME* aParen if( m_tracks ) { - setCommonVal( trackStartX, m_TrackStartXCtrl, m_trackStartX ); - setCommonVal( trackStartY, m_TrackStartYCtrl, m_trackStartY ); - setCommonVal( trackEndX, m_TrackEndXCtrl, m_trackEndX ); - setCommonVal( trackEndY, m_TrackEndYCtrl, m_trackEndY ); - setCommonVal( trackWidth, m_TrackWidthCtrl, m_trackWidth ); - for( unsigned ii = 0; ii < aParent->GetDesignSettings().m_TrackWidthList.size(); ii++ ) { int width = aParent->GetDesignSettings().m_TrackWidthList[ii]; - wxString msg = StringFromValue( g_UserUnit, width, false ); + wxString msg = StringFromValue( m_units, width, false ); m_TrackWidthCtrl->Append( msg ); } @@ -295,9 +261,6 @@ DIALOG_TRACK_VIA_PROPERTIES::DIALOG_TRACK_VIA_PROPERTIES( PCB_BASE_FRAME* aParen m_TrackLayerCtrl->SetBoardFrame( aParent ); m_TrackLayerCtrl->Resync(); - if( trackLayer ) - m_TrackLayerCtrl->SetLayerSelection( *trackLayer ); - m_TrackWidthCtrl->SetFocus(); } else @@ -306,38 +269,60 @@ DIALOG_TRACK_VIA_PROPERTIES::DIALOG_TRACK_VIA_PROPERTIES( PCB_BASE_FRAME* aParen } if( hasLocked && hasUnlocked ) - { m_lockedCbox->Set3StateValue( wxCHK_UNDETERMINED ); - } else if( hasLocked ) - { m_lockedCbox->Set3StateValue( wxCHK_CHECKED ); - } else - { m_lockedCbox->Set3StateValue( wxCHK_UNCHECKED ); - } - m_StdButtonsOK->SetDefault(); - // Pressing ENTER when any of the text input fields is active applies changes - Connect( wxEVT_TEXT_ENTER, wxCommandEventHandler( DIALOG_TRACK_VIA_PROPERTIES::onOkClick ), - NULL, this ); + // Now all widgets have the size fixed, call FinishDialogSettings + FinishDialogSettings(); } -bool DIALOG_TRACK_VIA_PROPERTIES::Apply( COMMIT& aCommit ) +bool DIALOG_TRACK_VIA_PROPERTIES::TransferDataFromWindow() { - if( !check() ) - return false; + // Run validations: + + if( m_vias ) + { + if( !m_viaDiameter.Validate( true ) ) + return false; + + if( !m_viaDrill.Validate( true ) ) + return false; + + if( !m_trackNetclass->IsChecked() && m_viaDiameter.GetValue() <= m_viaDrill.GetValue() ) + { + DisplayError( GetParent(), _( "Via drill size must be smaller than via diameter" ) ); + m_ViaDrillCtrl->SelectAll(); + m_ViaDrillCtrl->SetFocus(); + return false; + } + + if( m_ViaStartLayer->GetLayerSelection() == m_ViaEndLayer->GetLayerSelection() ) + { + DisplayError( GetParent(), _( "Via start layer and end layer cannot be the same" ) ); + return false; + } + } + + if( m_tracks ) + { + if( !m_trackWidth.Validate( true ) ) + return false; + } + + // If we survived that, then save the changes: bool changeLock = m_lockedCbox->Get3StateValue() != wxCHK_UNDETERMINED; bool setLock = m_lockedCbox->Get3StateValue() == wxCHK_CHECKED; for( auto item : m_items ) { - aCommit.Modify( item ); + m_commit.Modify( item ); switch( item->Type() ) { @@ -346,40 +331,22 @@ bool DIALOG_TRACK_VIA_PROPERTIES::Apply( COMMIT& aCommit ) wxASSERT( m_tracks ); TRACK* t = static_cast( item ); - if( m_trackStartX.Valid() || m_trackStartY.Valid() ) - { - wxPoint start = t->GetStart(); + if( !m_trackStartX.IsIndeterminate() ) + t->SetStart( wxPoint( m_trackStartX.GetValue(), t->GetStart().y ) ); - if( m_trackStartX.Valid() ) - start.x = m_trackStartX.GetValue(); + if( !m_trackStartY.IsIndeterminate() ) + t->SetStart( wxPoint( t->GetStart().x, m_trackStartY.GetValue() ) ); - if( m_trackStartY.Valid() ) - start.y = m_trackStartY.GetValue(); + if( !m_trackEndX.IsIndeterminate() ) + t->SetEnd( wxPoint( m_trackEndX.GetValue(), t->GetEnd().y ) ); - t->SetStart( start ); - } - - if( m_trackEndX.Valid() || m_trackEndY.Valid() ) - { - wxPoint end = t->GetEnd(); - - if( m_trackEndX.Valid() ) - end.x = m_trackEndX.GetValue(); - - if( m_trackEndY.Valid() ) - end.y = m_trackEndY.GetValue(); - - t->SetEnd( end ); - } + if( !m_trackEndY.IsIndeterminate() ) + t->SetEnd( wxPoint( t->GetEnd().x, m_trackEndY.GetValue() ) ); if( m_trackNetclass->IsChecked() ) - { t->SetWidth( t->GetNetClass()->GetTrackWidth() ); - } - else if( m_trackWidth.Valid() ) - { + else if( !m_trackWidth.IsIndeterminate() ) t->SetWidth( m_trackWidth.GetValue() ); - } LAYER_NUM layer = m_TrackLayerCtrl->GetLayerSelection(); @@ -395,28 +362,15 @@ bool DIALOG_TRACK_VIA_PROPERTIES::Apply( COMMIT& aCommit ) t->SetNetCode( m_NetComboBox->GetSelectedNet() ); } - break; } case PCB_VIA_T: { wxASSERT( m_vias ); - VIA* v = static_cast( item ); - if( m_viaX.Valid() || m_viaY.Valid() ) - { - wxPoint pos = v->GetPosition(); - - if( m_viaX.Valid() ) - pos.x = m_viaX.GetValue(); - - if( m_viaY.Valid() ) - pos.y = m_viaY.GetValue(); - - v->SetPosition( pos ); - } + v->SetPosition( wxPoint( m_viaX.GetValue(), m_viaY.GetValue() ) ); if( m_ViaTypeChoice->GetSelection() != 3) { @@ -435,7 +389,6 @@ bool DIALOG_TRACK_VIA_PROPERTIES::Apply( COMMIT& aCommit ) default: break; } - } auto startLayer = static_cast( m_ViaStartLayer->GetLayerSelection() ); @@ -472,12 +425,11 @@ bool DIALOG_TRACK_VIA_PROPERTIES::Apply( COMMIT& aCommit ) } else { - if( m_viaDiameter.Valid() ) + if( !m_viaDiameter.IsIndeterminate() ) v->SetWidth( m_viaDiameter.GetValue() ); - if( m_viaDrill.Valid() ) + if( !m_viaDrill.IsIndeterminate() ) v->SetDrill( m_viaDrill.GetValue() ); - } if ( m_NetComboBox->IsUniqueNetSelected() ) @@ -498,23 +450,17 @@ bool DIALOG_TRACK_VIA_PROPERTIES::Apply( COMMIT& aCommit ) } } + m_commit.Push( _( "Edit track/via properties" ) ); + return true; } -void DIALOG_TRACK_VIA_PROPERTIES::onClose( wxCloseEvent& aEvent ) -{ - EndModal( 0 ); -} - - void DIALOG_TRACK_VIA_PROPERTIES::onTrackNetclassCheck( wxCommandEvent& aEvent ) { bool enableNC = aEvent.IsChecked(); - m_TrackWidthLabel->Enable( !enableNC ); - m_TrackWidthCtrl->Enable( !enableNC ); - m_TrackWidthUnit->Enable( !enableNC ); + m_trackWidth.Enable( !enableNC ); } @@ -526,26 +472,8 @@ void DIALOG_TRACK_VIA_PROPERTIES::onViaNetclassCheck( wxCommandEvent& aEvent ) m_DesignRuleViasCtrl->Enable( !enableNC ); m_DesignRuleViasUnit->Enable( !enableNC ); - m_ViaDiameterLabel->Enable( !enableNC ); - m_ViaDiameterCtrl->Enable( !enableNC ); - m_ViaDiameterUnit->Enable( !enableNC ); - - m_ViaDrillLabel->Enable( !enableNC ); - m_ViaDrillCtrl->Enable( !enableNC ); - m_ViaDrillUnit->Enable( !enableNC ); -} - - -void DIALOG_TRACK_VIA_PROPERTIES::onCancelClick( wxCommandEvent& aEvent ) -{ - EndModal( 0 ); -} - - -void DIALOG_TRACK_VIA_PROPERTIES::onOkClick( wxCommandEvent& aEvent ) -{ - if( check() ) - EndModal( 1 ); + m_viaDiameter.Enable( !enableNC ); + m_viaDrill.Enable( !enableNC ); } @@ -553,11 +481,8 @@ void DIALOG_TRACK_VIA_PROPERTIES::onViaSelect( wxCommandEvent& aEvent ) { VIA_DIMENSION* viaDimension = static_cast ( aEvent.GetClientData() ); - wxString msg = StringFromValue( g_UserUnit, viaDimension->m_Diameter, false ); - m_ViaDiameterCtrl->ChangeValue( msg ); - - msg = StringFromValue( g_UserUnit, viaDimension->m_Drill, false ); - m_ViaDrillCtrl->ChangeValue( msg ); + m_viaDiameter.SetValue( viaDimension->m_Diameter ); + m_viaDrill.SetValue( viaDimension->m_Drill ); } @@ -581,55 +506,4 @@ void DIALOG_TRACK_VIA_PROPERTIES::onViaEdit( wxCommandEvent& aEvent ) m_ViaEndLayer->Enable( false ); } } - -} - - -bool DIALOG_TRACK_VIA_PROPERTIES::check() const -{ - bool trackNetclass = m_trackNetclass->IsChecked(); - bool viaNetclass = m_trackNetclass->IsChecked(); - - if( m_tracks && !trackNetclass && m_trackWidth.Valid() && m_trackWidth.GetValue() <= 0 ) - { - DisplayError( GetParent(), _( "Invalid track width" ) ); - m_TrackWidthCtrl->SetFocus(); - return false; - } - - if( m_vias && !viaNetclass ) - { - if( m_viaDiameter.Valid() && m_viaDiameter.GetValue() <= 0 ) - { - DisplayError( GetParent(), _( "Invalid via diameter" ) ); - m_ViaDiameterCtrl->SetFocus(); - return false; - } - - if( m_viaDrill.Valid() && m_viaDrill.GetValue() <= 0 ) - { - DisplayError( GetParent(), _( "Invalid via drill size" ) ); - m_ViaDrillCtrl->SetFocus(); - return false; - } - - if( m_viaDiameter.Valid() && m_viaDrill.Valid() && m_viaDiameter.GetValue() <= m_viaDrill.GetValue() ) - { - DisplayError( GetParent(), _( "Via drill size has to be smaller than via diameter" ) ); - m_ViaDrillCtrl->SetFocus(); - return false; - } - - } - - if( m_vias) - { - if( m_ViaStartLayer->GetLayerSelection() == m_ViaEndLayer->GetLayerSelection() ) - { - DisplayError( GetParent(), _( "Via start layer and end layer cannot be the same" ) ); - return false; - } - } - - return true; } diff --git a/pcbnew/dialogs/dialog_track_via_properties.h b/pcbnew/dialogs/dialog_track_via_properties.h index 3dc4d77a16..de070bc61c 100644 --- a/pcbnew/dialogs/dialog_track_via_properties.h +++ b/pcbnew/dialogs/dialog_track_via_properties.h @@ -35,57 +35,29 @@ class PCB_BASE_FRAME; class DIALOG_TRACK_VIA_PROPERTIES : public DIALOG_TRACK_VIA_PROPERTIES_BASE { public: - DIALOG_TRACK_VIA_PROPERTIES( PCB_BASE_FRAME* aParent, const SELECTION& aItems ); + DIALOG_TRACK_VIA_PROPERTIES( PCB_BASE_FRAME* aParent, const SELECTION& aItems, + COMMIT& aCommit ); - ///> Applies values from the dialog to the selected items. - bool Apply( COMMIT& aCommit ); + bool TransferDataFromWindow() override; private: - void onClose( wxCloseEvent& aEvent ) override; void onTrackNetclassCheck( wxCommandEvent& aEvent ) override; void onViaNetclassCheck( wxCommandEvent& aEvent ) override; - void onCancelClick( wxCommandEvent& aEvent ) override; - void onOkClick( wxCommandEvent& aEvent ) override; void onViaSelect( wxCommandEvent& aEvent ); void onViaEdit( wxCommandEvent& aEvent ); - void OnInitDlg( wxInitDialogEvent& event ) override - { - // Call the default wxDialog handler of a wxInitDialogEvent - TransferDataToWindow(); + const SELECTION& m_items; // List of items to be modified. + COMMIT& m_commit; // An undo record to add any changes to. - // Now all widgets have the size fixed, call FinishDialogSettings - FinishDialogSettings(); - } + UNIT_BINDER m_trackStartX, m_trackStartY; + UNIT_BINDER m_trackEndX, m_trackEndY; + UNIT_BINDER m_trackWidth; - ///> Checks if the dialog values are correct. - bool check() const; + UNIT_BINDER m_viaX, m_viaY; + UNIT_BINDER m_viaDiameter, m_viaDrill; - ///> Sets wxTextEntry to the value stored in OPT or "<...>" if it is not available. - template - void setCommonVal( const OPT& aVal, wxTextEntry* aTxtEntry, UNIT_BINDER& aBinder ) - { - if( aVal ) - aBinder.SetValue( *aVal ); - else - aTxtEntry->SetValue( "<...>" ); - } - - ///> Selected items to be modified. - const SELECTION& m_items; - - UNIT_BINDER m_trackStartX, m_trackStartY; - UNIT_BINDER m_trackEndX, m_trackEndY; - UNIT_BINDER m_trackWidth; - - UNIT_BINDER m_viaX, m_viaY; - UNIT_BINDER m_viaDiameter, m_viaDrill; - - ///> Flag that determines if the dialog displays track properties. - bool m_tracks; - - ///> Flag that determines if the dialog displays via properties. - bool m_vias; + bool m_tracks; // True if dialog displays any track properties. + bool m_vias; // True if dialog displays any via properties. ///> Fixme bool m_haveUniqueNet; diff --git a/pcbnew/dialogs/dialog_track_via_properties_base.cpp b/pcbnew/dialogs/dialog_track_via_properties_base.cpp index 0f6c954014..7e4fb324a6 100644 --- a/pcbnew/dialogs/dialog_track_via_properties_base.cpp +++ b/pcbnew/dialogs/dialog_track_via_properties_base.cpp @@ -6,7 +6,6 @@ /////////////////////////////////////////////////////////////////////////// #include "pcb_layer_box_selector.h" -#include "widgets/text_ctrl_eval.h" #include "widgets/widget_net_selector.h" #include "dialog_track_via_properties_base.h" @@ -19,191 +18,213 @@ DIALOG_TRACK_VIA_PROPERTIES_BASE::DIALOG_TRACK_VIA_PROPERTIES_BASE( wxWindow* pa m_MainSizer = new wxBoxSizer( wxVERTICAL ); - m_sbCommonSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Common:") ), wxHORIZONTAL ); + m_sbCommonSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Common") ), wxHORIZONTAL ); m_staticText24 = new wxStaticText( m_sbCommonSizer->GetStaticBox(), wxID_ANY, _("Net:"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticText24->Wrap( -1 ); - m_sbCommonSizer->Add( m_staticText24, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); + m_sbCommonSizer->Add( m_staticText24, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); m_NetComboBox = new WIDGET_NET_SELECTOR( m_sbCommonSizer->GetStaticBox(), wxID_ANY, _("Combo!"), wxDefaultPosition, wxDefaultSize, 0, NULL, wxCB_DROPDOWN|wxCB_READONLY ); - m_sbCommonSizer->Add( m_NetComboBox, 1, wxALL|wxEXPAND, 5 ); + m_sbCommonSizer->Add( m_NetComboBox, 6, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); + + + m_sbCommonSizer->Add( 0, 0, 1, wxEXPAND, 5 ); m_lockedCbox = new wxCheckBox( m_sbCommonSizer->GetStaticBox(), wxID_ANY, _("Locked"), wxDefaultPosition, wxDefaultSize, wxCHK_3STATE ); - m_sbCommonSizer->Add( m_lockedCbox, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxALL, 5 ); + m_sbCommonSizer->Add( m_lockedCbox, 2, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); m_MainSizer->Add( m_sbCommonSizer, 0, wxEXPAND|wxALL, 5 ); - m_sbTrackSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Tracks:") ), wxHORIZONTAL ); + m_sbTrackSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Tracks") ), wxHORIZONTAL ); wxFlexGridSizer* fgTrackLeftGridSizer; - fgTrackLeftGridSizer = new wxFlexGridSizer( 4, 3, 5, 5 ); + fgTrackLeftGridSizer = new wxFlexGridSizer( 6, 3, 5, 5 ); + fgTrackLeftGridSizer->AddGrowableCol( 1 ); fgTrackLeftGridSizer->SetFlexibleDirection( wxBOTH ); fgTrackLeftGridSizer->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); m_TrackStartXLabel = new wxStaticText( m_sbTrackSizer->GetStaticBox(), wxID_ANY, _("Start point X:"), wxDefaultPosition, wxDefaultSize, 0 ); m_TrackStartXLabel->Wrap( -1 ); - fgTrackLeftGridSizer->Add( m_TrackStartXLabel, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxALL, 5 ); + fgTrackLeftGridSizer->Add( m_TrackStartXLabel, 0, wxALIGN_CENTER_VERTICAL|wxTOP, 3 ); - m_TrackStartXCtrl = new TEXT_CTRL_EVAL( m_sbTrackSizer->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); - fgTrackLeftGridSizer->Add( m_TrackStartXCtrl, 0, wxALIGN_CENTER_HORIZONTAL|wxEXPAND, 5 ); + m_TrackStartXCtrl = new wxTextCtrl( m_sbTrackSizer->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + fgTrackLeftGridSizer->Add( m_TrackStartXCtrl, 0, wxALIGN_CENTER_HORIZONTAL|wxEXPAND|wxTOP, 3 ); m_TrackStartXUnit = new wxStaticText( m_sbTrackSizer->GetStaticBox(), wxID_ANY, _("Unit"), wxDefaultPosition, wxDefaultSize, 0 ); m_TrackStartXUnit->Wrap( -1 ); - fgTrackLeftGridSizer->Add( m_TrackStartXUnit, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); + fgTrackLeftGridSizer->Add( m_TrackStartXUnit, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxTOP, 3 ); m_TrackStartYLabel = new wxStaticText( m_sbTrackSizer->GetStaticBox(), wxID_ANY, _("Start point Y:"), wxDefaultPosition, wxDefaultSize, 0 ); m_TrackStartYLabel->Wrap( -1 ); - fgTrackLeftGridSizer->Add( m_TrackStartYLabel, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxALL, 5 ); + fgTrackLeftGridSizer->Add( m_TrackStartYLabel, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM, 5 ); - m_TrackStartYCtrl = new TEXT_CTRL_EVAL( m_sbTrackSizer->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); - fgTrackLeftGridSizer->Add( m_TrackStartYCtrl, 0, wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 ); + m_TrackStartYCtrl = new wxTextCtrl( m_sbTrackSizer->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + fgTrackLeftGridSizer->Add( m_TrackStartYCtrl, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxEXPAND, 5 ); m_TrackStartYUnit = new wxStaticText( m_sbTrackSizer->GetStaticBox(), wxID_ANY, _("Unit"), wxDefaultPosition, wxDefaultSize, 0 ); m_TrackStartYUnit->Wrap( -1 ); - fgTrackLeftGridSizer->Add( m_TrackStartYUnit, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); + fgTrackLeftGridSizer->Add( m_TrackStartYUnit, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT, 5 ); m_TrackEndXLabel = new wxStaticText( m_sbTrackSizer->GetStaticBox(), wxID_ANY, _("End point X:"), wxDefaultPosition, wxDefaultSize, 0 ); m_TrackEndXLabel->Wrap( -1 ); - fgTrackLeftGridSizer->Add( m_TrackEndXLabel, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxALL, 5 ); + fgTrackLeftGridSizer->Add( m_TrackEndXLabel, 0, wxALIGN_CENTER_VERTICAL|wxTOP, 5 ); - m_TrackEndXCtrl = new TEXT_CTRL_EVAL( m_sbTrackSizer->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); - fgTrackLeftGridSizer->Add( m_TrackEndXCtrl, 0, wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 ); + m_TrackEndXCtrl = new wxTextCtrl( m_sbTrackSizer->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + fgTrackLeftGridSizer->Add( m_TrackEndXCtrl, 0, wxALIGN_CENTER_VERTICAL|wxEXPAND|wxTOP, 5 ); m_TrackEndXUnit = new wxStaticText( m_sbTrackSizer->GetStaticBox(), wxID_ANY, _("Unit"), wxDefaultPosition, wxDefaultSize, 0 ); m_TrackEndXUnit->Wrap( -1 ); - fgTrackLeftGridSizer->Add( m_TrackEndXUnit, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); + fgTrackLeftGridSizer->Add( m_TrackEndXUnit, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxTOP, 5 ); m_TrackEndYLabel = new wxStaticText( m_sbTrackSizer->GetStaticBox(), wxID_ANY, _("End point Y:"), wxDefaultPosition, wxDefaultSize, 0 ); m_TrackEndYLabel->Wrap( -1 ); - fgTrackLeftGridSizer->Add( m_TrackEndYLabel, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxALL, 5 ); + fgTrackLeftGridSizer->Add( m_TrackEndYLabel, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM, 5 ); - m_TrackEndYCtrl = new TEXT_CTRL_EVAL( m_sbTrackSizer->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); - fgTrackLeftGridSizer->Add( m_TrackEndYCtrl, 0, wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 ); + m_TrackEndYCtrl = new wxTextCtrl( m_sbTrackSizer->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + fgTrackLeftGridSizer->Add( m_TrackEndYCtrl, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxEXPAND, 5 ); m_TrackEndYUnit = new wxStaticText( m_sbTrackSizer->GetStaticBox(), wxID_ANY, _("Unit"), wxDefaultPosition, wxDefaultSize, 0 ); m_TrackEndYUnit->Wrap( -1 ); - fgTrackLeftGridSizer->Add( m_TrackEndYUnit, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); - - - m_sbTrackSizer->Add( fgTrackLeftGridSizer, 1, wxEXPAND, 5 ); - - wxFlexGridSizer* fgTrackRightSizer; - fgTrackRightSizer = new wxFlexGridSizer( 4, 3, 5, 5 ); - fgTrackRightSizer->SetFlexibleDirection( wxBOTH ); - fgTrackRightSizer->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); + fgTrackLeftGridSizer->Add( m_TrackEndYUnit, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT, 5 ); m_TrackWidthLabel = new wxStaticText( m_sbTrackSizer->GetStaticBox(), wxID_ANY, _("Width:"), wxDefaultPosition, wxDefaultSize, 0 ); m_TrackWidthLabel->Wrap( -1 ); - fgTrackRightSizer->Add( m_TrackWidthLabel, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxTOP|wxBOTTOM|wxRIGHT, 5 ); + fgTrackLeftGridSizer->Add( m_TrackWidthLabel, 0, wxALIGN_CENTER_VERTICAL|wxTOP, 5 ); m_TrackWidthCtrl = new wxComboBox( m_sbTrackSizer->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, NULL, wxTE_PROCESS_ENTER ); - fgTrackRightSizer->Add( m_TrackWidthCtrl, 0, wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 ); + fgTrackLeftGridSizer->Add( m_TrackWidthCtrl, 0, wxALIGN_CENTER_VERTICAL|wxEXPAND|wxTOP, 5 ); m_TrackWidthUnit = new wxStaticText( m_sbTrackSizer->GetStaticBox(), wxID_ANY, _("Unit"), wxDefaultPosition, wxDefaultSize, 0 ); m_TrackWidthUnit->Wrap( -1 ); - fgTrackRightSizer->Add( m_TrackWidthUnit, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); + fgTrackLeftGridSizer->Add( m_TrackWidthUnit, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxTOP, 5 ); - fgTrackRightSizer->Add( 0, 0, 1, wxEXPAND, 5 ); + fgTrackLeftGridSizer->Add( 0, 0, 1, wxEXPAND, 5 ); m_trackNetclass = new wxCheckBox( m_sbTrackSizer->GetStaticBox(), wxID_ANY, _("Use net class width"), wxDefaultPosition, wxDefaultSize, 0 ); - fgTrackRightSizer->Add( m_trackNetclass, 0, wxBOTTOM|wxTOP, 5 ); + fgTrackLeftGridSizer->Add( m_trackNetclass, 0, wxBOTTOM, 5 ); - fgTrackRightSizer->Add( 0, 0, 1, wxEXPAND, 5 ); + fgTrackLeftGridSizer->Add( 0, 0, 1, wxEXPAND, 5 ); + + + m_sbTrackSizer->Add( fgTrackLeftGridSizer, 5, wxEXPAND|wxRIGHT|wxLEFT, 5 ); + + + m_sbTrackSizer->Add( 0, 0, 0, wxEXPAND|wxRIGHT|wxLEFT, 10 ); + + wxFlexGridSizer* fgTrackRightSizer; + fgTrackRightSizer = new wxFlexGridSizer( 1, 3, 5, 5 ); + fgTrackRightSizer->AddGrowableCol( 1 ); + fgTrackRightSizer->SetFlexibleDirection( wxBOTH ); + fgTrackRightSizer->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); m_TrackLayerLabel = new wxStaticText( m_sbTrackSizer->GetStaticBox(), wxID_ANY, _("Layer:"), wxDefaultPosition, wxDefaultSize, 0 ); m_TrackLayerLabel->Wrap( -1 ); - fgTrackRightSizer->Add( m_TrackLayerLabel, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxALL, 5 ); + fgTrackRightSizer->Add( m_TrackLayerLabel, 0, wxALIGN_CENTER_VERTICAL, 5 ); m_TrackLayerCtrl = new PCB_LAYER_BOX_SELECTOR( m_sbTrackSizer->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, NULL, 0 ); - fgTrackRightSizer->Add( m_TrackLayerCtrl, 0, wxALIGN_CENTER_VERTICAL, 5 ); + fgTrackRightSizer->Add( m_TrackLayerCtrl, 0, wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 ); fgTrackRightSizer->Add( 0, 0, 1, wxEXPAND, 5 ); - m_sbTrackSizer->Add( fgTrackRightSizer, 1, wxEXPAND, 5 ); + m_sbTrackSizer->Add( fgTrackRightSizer, 4, wxEXPAND|wxLEFT, 10 ); m_MainSizer->Add( m_sbTrackSizer, 0, wxALL|wxEXPAND, 5 ); - m_sbViaSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Vias:") ), wxHORIZONTAL ); + m_sbViaSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Vias") ), wxHORIZONTAL ); wxFlexGridSizer* fgViaLeftSizer; - fgViaLeftSizer = new wxFlexGridSizer( 4, 3, 5, 5 ); + fgViaLeftSizer = new wxFlexGridSizer( 6, 3, 5, 5 ); + fgViaLeftSizer->AddGrowableCol( 1 ); fgViaLeftSizer->SetFlexibleDirection( wxBOTH ); fgViaLeftSizer->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); m_ViaXLabel = new wxStaticText( m_sbViaSizer->GetStaticBox(), wxID_ANY, _("Position X:"), wxDefaultPosition, wxDefaultSize, 0 ); m_ViaXLabel->Wrap( -1 ); - fgViaLeftSizer->Add( m_ViaXLabel, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxALL, 5 ); + fgViaLeftSizer->Add( m_ViaXLabel, 0, wxALIGN_CENTER_VERTICAL|wxTOP, 3 ); - m_ViaXCtrl = new TEXT_CTRL_EVAL( m_sbViaSizer->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); - fgViaLeftSizer->Add( m_ViaXCtrl, 0, wxEXPAND, 5 ); + m_ViaXCtrl = new wxTextCtrl( m_sbViaSizer->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + fgViaLeftSizer->Add( m_ViaXCtrl, 0, wxEXPAND|wxTOP, 3 ); m_ViaXUnit = new wxStaticText( m_sbViaSizer->GetStaticBox(), wxID_ANY, _("Unit"), wxDefaultPosition, wxDefaultSize, 0 ); m_ViaXUnit->Wrap( -1 ); - fgViaLeftSizer->Add( m_ViaXUnit, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); + fgViaLeftSizer->Add( m_ViaXUnit, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxTOP, 3 ); m_ViaYLabel = new wxStaticText( m_sbViaSizer->GetStaticBox(), wxID_ANY, _("Position Y:"), wxDefaultPosition, wxDefaultSize, 0 ); m_ViaYLabel->Wrap( -1 ); - fgViaLeftSizer->Add( m_ViaYLabel, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxALL, 5 ); + fgViaLeftSizer->Add( m_ViaYLabel, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM, 5 ); - m_ViaYCtrl = new TEXT_CTRL_EVAL( m_sbViaSizer->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); - fgViaLeftSizer->Add( m_ViaYCtrl, 0, wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 ); + m_ViaYCtrl = new wxTextCtrl( m_sbViaSizer->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + fgViaLeftSizer->Add( m_ViaYCtrl, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxEXPAND, 5 ); m_ViaYUnit = new wxStaticText( m_sbViaSizer->GetStaticBox(), wxID_ANY, _("Unit"), wxDefaultPosition, wxDefaultSize, 0 ); m_ViaYUnit->Wrap( -1 ); - fgViaLeftSizer->Add( m_ViaYUnit, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); + fgViaLeftSizer->Add( m_ViaYUnit, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT, 5 ); - m_ViaDiameterLabel = new wxStaticText( m_sbViaSizer->GetStaticBox(), wxID_ANY, _("Diameter:"), wxDefaultPosition, wxDefaultSize, 0 ); - m_ViaDiameterLabel->Wrap( -1 ); - fgViaLeftSizer->Add( m_ViaDiameterLabel, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxALL, 5 ); - - m_ViaDiameterCtrl = new TEXT_CTRL_EVAL( m_sbViaSizer->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); - fgViaLeftSizer->Add( m_ViaDiameterCtrl, 0, wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 ); - - m_ViaDiameterUnit = new wxStaticText( m_sbViaSizer->GetStaticBox(), wxID_ANY, _("Unit"), wxDefaultPosition, wxDefaultSize, 0 ); - m_ViaDiameterUnit->Wrap( -1 ); - fgViaLeftSizer->Add( m_ViaDiameterUnit, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); - - m_ViaDrillLabel = new wxStaticText( m_sbViaSizer->GetStaticBox(), wxID_ANY, _("Drill:"), wxDefaultPosition, wxDefaultSize, 0 ); - m_ViaDrillLabel->Wrap( -1 ); - fgViaLeftSizer->Add( m_ViaDrillLabel, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxALL, 5 ); - - m_ViaDrillCtrl = new TEXT_CTRL_EVAL( m_sbViaSizer->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); - fgViaLeftSizer->Add( m_ViaDrillCtrl, 0, wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 ); - - m_ViaDrillUnit = new wxStaticText( m_sbViaSizer->GetStaticBox(), wxID_ANY, _("Unit"), wxDefaultPosition, wxDefaultSize, 0 ); - m_ViaDrillUnit->Wrap( -1 ); - fgViaLeftSizer->Add( m_ViaDrillUnit, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); - - - m_sbViaSizer->Add( fgViaLeftSizer, 1, wxEXPAND|wxALL, 5 ); - - wxFlexGridSizer* fgViaRightSizer; - fgViaRightSizer = new wxFlexGridSizer( 5, 3, 5, 5 ); - fgViaRightSizer->SetFlexibleDirection( wxBOTH ); - fgViaRightSizer->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); - - m_DesignRuleVias = new wxStaticText( m_sbViaSizer->GetStaticBox(), wxID_ANY, _("Design rule vias:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_DesignRuleVias = new wxStaticText( m_sbViaSizer->GetStaticBox(), wxID_ANY, _("Design rules:"), wxDefaultPosition, wxDefaultSize, 0 ); m_DesignRuleVias->Wrap( -1 ); - fgViaRightSizer->Add( m_DesignRuleVias, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxALL, 5 ); + fgViaLeftSizer->Add( m_DesignRuleVias, 0, wxALIGN_CENTER_VERTICAL|wxTOP, 5 ); wxArrayString m_DesignRuleViasCtrlChoices; m_DesignRuleViasCtrl = new wxChoice( m_sbViaSizer->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, m_DesignRuleViasCtrlChoices, 0 ); m_DesignRuleViasCtrl->SetSelection( 0 ); - fgViaRightSizer->Add( m_DesignRuleViasCtrl, 0, wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 ); + fgViaLeftSizer->Add( m_DesignRuleViasCtrl, 0, wxALIGN_CENTER_VERTICAL|wxEXPAND|wxTOP, 5 ); m_DesignRuleViasUnit = new wxStaticText( m_sbViaSizer->GetStaticBox(), wxID_ANY, _("Unit"), wxDefaultPosition, wxDefaultSize, 0 ); m_DesignRuleViasUnit->Wrap( -1 ); - fgViaRightSizer->Add( m_DesignRuleViasUnit, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); + fgViaLeftSizer->Add( m_DesignRuleViasUnit, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxTOP, 5 ); + + m_ViaDiameterLabel = new wxStaticText( m_sbViaSizer->GetStaticBox(), wxID_ANY, _("Diameter:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_ViaDiameterLabel->Wrap( -1 ); + fgViaLeftSizer->Add( m_ViaDiameterLabel, 0, wxALIGN_CENTER_VERTICAL, 5 ); + + m_ViaDiameterCtrl = new wxTextCtrl( m_sbViaSizer->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + fgViaLeftSizer->Add( m_ViaDiameterCtrl, 0, wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 ); + + m_ViaDiameterUnit = new wxStaticText( m_sbViaSizer->GetStaticBox(), wxID_ANY, _("Unit"), wxDefaultPosition, wxDefaultSize, 0 ); + m_ViaDiameterUnit->Wrap( -1 ); + fgViaLeftSizer->Add( m_ViaDiameterUnit, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 ); + + m_ViaDrillLabel = new wxStaticText( m_sbViaSizer->GetStaticBox(), wxID_ANY, _("Drill:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_ViaDrillLabel->Wrap( -1 ); + fgViaLeftSizer->Add( m_ViaDrillLabel, 0, wxALIGN_CENTER_VERTICAL, 5 ); + + m_ViaDrillCtrl = new wxTextCtrl( m_sbViaSizer->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + fgViaLeftSizer->Add( m_ViaDrillCtrl, 0, wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 ); + + m_ViaDrillUnit = new wxStaticText( m_sbViaSizer->GetStaticBox(), wxID_ANY, _("Unit"), wxDefaultPosition, wxDefaultSize, 0 ); + m_ViaDrillUnit->Wrap( -1 ); + fgViaLeftSizer->Add( m_ViaDrillUnit, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 ); + + + fgViaLeftSizer->Add( 0, 0, 1, wxEXPAND, 5 ); + + m_viaNetclass = new wxCheckBox( m_sbViaSizer->GetStaticBox(), wxID_ANY, _("Use net class size"), wxDefaultPosition, wxDefaultSize, 0 ); + fgViaLeftSizer->Add( m_viaNetclass, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM, 5 ); + + + fgViaLeftSizer->Add( 0, 0, 1, wxEXPAND, 5 ); + + + m_sbViaSizer->Add( fgViaLeftSizer, 5, wxEXPAND|wxRIGHT|wxLEFT, 5 ); + + + m_sbViaSizer->Add( 0, 0, 0, wxEXPAND|wxRIGHT|wxLEFT, 10 ); + + wxFlexGridSizer* fgViaRightSizer; + fgViaRightSizer = new wxFlexGridSizer( 3, 3, 5, 5 ); + fgViaRightSizer->AddGrowableCol( 1 ); + fgViaRightSizer->SetFlexibleDirection( wxBOTH ); + fgViaRightSizer->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); m_ViaTypeLabel = new wxStaticText( m_sbViaSizer->GetStaticBox(), wxID_ANY, _("Via type:"), wxDefaultPosition, wxDefaultSize, 0 ); m_ViaTypeLabel->Wrap( -1 ); - fgViaRightSizer->Add( m_ViaTypeLabel, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5 ); + fgViaRightSizer->Add( m_ViaTypeLabel, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxTOP, 5 ); wxString m_ViaTypeChoiceChoices[] = { _("Through"), _("Micro"), _("Blind/buried"), wxEmptyString }; int m_ViaTypeChoiceNChoices = sizeof( m_ViaTypeChoiceChoices ) / sizeof( wxString ); @@ -211,14 +232,14 @@ DIALOG_TRACK_VIA_PROPERTIES_BASE::DIALOG_TRACK_VIA_PROPERTIES_BASE( wxWindow* pa m_ViaTypeChoice->SetSelection( 0 ); m_ViaTypeChoice->Enable( false ); - fgViaRightSizer->Add( m_ViaTypeChoice, 0, wxEXPAND, 5 ); + fgViaRightSizer->Add( m_ViaTypeChoice, 0, wxEXPAND|wxLEFT, 5 ); fgViaRightSizer->Add( 0, 0, 1, wxEXPAND, 5 ); m_ViaStartLayerLabel = new wxStaticText( m_sbViaSizer->GetStaticBox(), wxID_ANY, _("Start layer:"), wxDefaultPosition, wxDefaultSize, 0 ); m_ViaStartLayerLabel->Wrap( -1 ); - fgViaRightSizer->Add( m_ViaStartLayerLabel, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5 ); + fgViaRightSizer->Add( m_ViaStartLayerLabel, 0, wxALIGN_CENTER_VERTICAL, 5 ); m_ViaStartLayer = new PCB_LAYER_BOX_SELECTOR( m_sbViaSizer->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, NULL, 0 ); fgViaRightSizer->Add( m_ViaStartLayer, 0, wxEXPAND, 5 ); @@ -228,7 +249,7 @@ DIALOG_TRACK_VIA_PROPERTIES_BASE::DIALOG_TRACK_VIA_PROPERTIES_BASE( wxWindow* pa m_ViaEndLayerLabel1 = new wxStaticText( m_sbViaSizer->GetStaticBox(), wxID_ANY, _("End layer:"), wxDefaultPosition, wxDefaultSize, 0 ); m_ViaEndLayerLabel1->Wrap( -1 ); - fgViaRightSizer->Add( m_ViaEndLayerLabel1, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxALL, 5 ); + fgViaRightSizer->Add( m_ViaEndLayerLabel1, 0, wxALIGN_CENTER_VERTICAL, 5 ); m_ViaEndLayer = new PCB_LAYER_BOX_SELECTOR( m_sbViaSizer->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, NULL, 0 ); fgViaRightSizer->Add( m_ViaEndLayer, 0, wxEXPAND, 5 ); @@ -237,16 +258,7 @@ DIALOG_TRACK_VIA_PROPERTIES_BASE::DIALOG_TRACK_VIA_PROPERTIES_BASE( wxWindow* pa fgViaRightSizer->Add( 0, 0, 1, wxEXPAND, 5 ); - fgViaRightSizer->Add( 0, 0, 1, wxEXPAND, 5 ); - - m_viaNetclass = new wxCheckBox( m_sbViaSizer->GetStaticBox(), wxID_ANY, _("Use net class size"), wxDefaultPosition, wxDefaultSize, 0 ); - fgViaRightSizer->Add( m_viaNetclass, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxTOP, 5 ); - - - fgViaRightSizer->Add( 0, 0, 1, wxEXPAND, 5 ); - - - m_sbViaSizer->Add( fgViaRightSizer, 1, wxEXPAND|wxALL, 5 ); + m_sbViaSizer->Add( fgViaRightSizer, 4, wxEXPAND|wxLEFT, 10 ); m_MainSizer->Add( m_sbViaSizer, 0, wxALL|wxEXPAND, 5 ); @@ -261,7 +273,7 @@ DIALOG_TRACK_VIA_PROPERTIES_BASE::DIALOG_TRACK_VIA_PROPERTIES_BASE( wxWindow* pa m_StdButtons->AddButton( m_StdButtonsCancel ); m_StdButtons->Realize(); - m_MainSizer->Add( m_StdButtons, 0, wxALL|wxEXPAND, 5 ); + m_MainSizer->Add( m_StdButtons, 0, wxEXPAND, 5 ); this->SetSizer( m_MainSizer ); @@ -271,24 +283,16 @@ DIALOG_TRACK_VIA_PROPERTIES_BASE::DIALOG_TRACK_VIA_PROPERTIES_BASE( wxWindow* pa this->Centre( wxBOTH ); // Connect Events - this->Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_TRACK_VIA_PROPERTIES_BASE::onClose ) ); - this->Connect( wxEVT_INIT_DIALOG, wxInitDialogEventHandler( DIALOG_TRACK_VIA_PROPERTIES_BASE::OnInitDlg ) ); m_TrackWidthCtrl->Connect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( DIALOG_TRACK_VIA_PROPERTIES_BASE::onOkClick ), NULL, this ); m_trackNetclass->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_TRACK_VIA_PROPERTIES_BASE::onTrackNetclassCheck ), NULL, this ); m_viaNetclass->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_TRACK_VIA_PROPERTIES_BASE::onViaNetclassCheck ), NULL, this ); - m_StdButtonsCancel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_TRACK_VIA_PROPERTIES_BASE::onCancelClick ), NULL, this ); - m_StdButtonsOK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_TRACK_VIA_PROPERTIES_BASE::onOkClick ), NULL, this ); } DIALOG_TRACK_VIA_PROPERTIES_BASE::~DIALOG_TRACK_VIA_PROPERTIES_BASE() { // Disconnect Events - this->Disconnect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_TRACK_VIA_PROPERTIES_BASE::onClose ) ); - this->Disconnect( wxEVT_INIT_DIALOG, wxInitDialogEventHandler( DIALOG_TRACK_VIA_PROPERTIES_BASE::OnInitDlg ) ); m_TrackWidthCtrl->Disconnect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( DIALOG_TRACK_VIA_PROPERTIES_BASE::onOkClick ), NULL, this ); m_trackNetclass->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_TRACK_VIA_PROPERTIES_BASE::onTrackNetclassCheck ), NULL, this ); m_viaNetclass->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_TRACK_VIA_PROPERTIES_BASE::onViaNetclassCheck ), NULL, this ); - m_StdButtonsCancel->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_TRACK_VIA_PROPERTIES_BASE::onCancelClick ), NULL, this ); - m_StdButtonsOK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_TRACK_VIA_PROPERTIES_BASE::onOkClick ), NULL, this ); } diff --git a/pcbnew/dialogs/dialog_track_via_properties_base.fbp b/pcbnew/dialogs/dialog_track_via_properties_base.fbp index e83eb302c8..ac96f3aa35 100644 --- a/pcbnew/dialogs/dialog_track_via_properties_base.fbp +++ b/pcbnew/dialogs/dialog_track_via_properties_base.fbp @@ -61,13 +61,13 @@ - onClose + - OnInitDlg + @@ -99,7 +99,7 @@ 0 wxID_ANY - Common: + Common m_sbCommonSizer wxHORIZONTAL @@ -108,7 +108,7 @@ 5 - wxALIGN_CENTER_VERTICAL|wxALL + wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT|wxLEFT 0 1 @@ -191,8 +191,8 @@ 5 - wxALL|wxEXPAND - 1 + wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT + 6 1 1 @@ -282,10 +282,20 @@ + + 5 + wxEXPAND + 1 + + 0 + protected + 0 + + 5 - wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxALL - 0 + wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxBOTTOM|wxRIGHT|wxLEFT + 2 1 1 @@ -378,7 +388,7 @@ 0 wxID_ANY - Tracks: + Tracks m_sbTrackSizer wxHORIZONTAL @@ -387,23 +397,23 @@ 5 - wxEXPAND - 1 - + wxEXPAND|wxRIGHT|wxLEFT + 5 + 3 wxBOTH - + 1 5 fgTrackLeftGridSizer wxFLEX_GROWMODE_SPECIFIED none - 4 + 6 5 - 5 - wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxALL + 3 + wxALIGN_CENTER_VERTICAL|wxTOP 0 1 @@ -485,8 +495,8 @@ - 5 - wxALIGN_CENTER_HORIZONTAL|wxEXPAND + 3 + wxALIGN_CENTER_HORIZONTAL|wxEXPAND|wxTOP 0 1 @@ -535,7 +545,7 @@ 1 - TEXT_CTRL_EVAL; widgets/text_ctrl_eval.h + ; ; forward_declare 0 @@ -576,8 +586,8 @@ - 5 - wxALIGN_CENTER_VERTICAL|wxALL + 3 + wxALIGN_CENTER_VERTICAL|wxRIGHT|wxTOP 0 1 @@ -660,7 +670,7 @@ 5 - wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxALL + wxALIGN_CENTER_VERTICAL|wxBOTTOM 0 1 @@ -743,7 +753,7 @@ 5 - wxALIGN_CENTER_VERTICAL|wxEXPAND + wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxEXPAND 0 1 @@ -792,7 +802,7 @@ 1 - TEXT_CTRL_EVAL; widgets/text_ctrl_eval.h + ; ; forward_declare 0 @@ -834,7 +844,7 @@ 5 - wxALIGN_CENTER_VERTICAL|wxALL + wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT 0 1 @@ -917,7 +927,7 @@ 5 - wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxALL + wxALIGN_CENTER_VERTICAL|wxTOP 0 1 @@ -1000,7 +1010,7 @@ 5 - wxALIGN_CENTER_VERTICAL|wxEXPAND + wxALIGN_CENTER_VERTICAL|wxEXPAND|wxTOP 0 1 @@ -1049,7 +1059,7 @@ 1 - TEXT_CTRL_EVAL; widgets/text_ctrl_eval.h + ; ; forward_declare 0 @@ -1091,7 +1101,7 @@ 5 - wxALIGN_CENTER_VERTICAL|wxALL + wxALIGN_CENTER_VERTICAL|wxRIGHT|wxTOP 0 1 @@ -1174,7 +1184,7 @@ 5 - wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxALL + wxALIGN_CENTER_VERTICAL|wxBOTTOM 0 1 @@ -1257,7 +1267,7 @@ 5 - wxALIGN_CENTER_VERTICAL|wxEXPAND + wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxEXPAND 0 1 @@ -1306,7 +1316,7 @@ 1 - TEXT_CTRL_EVAL; widgets/text_ctrl_eval.h + ; ; forward_declare 0 @@ -1348,7 +1358,7 @@ 5 - wxALIGN_CENTER_VERTICAL|wxALL + wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT 0 1 @@ -1429,27 +1439,9 @@ - - - - 5 - wxEXPAND - 1 - - 3 - wxBOTH - - - 5 - - fgTrackRightSizer - wxFLEX_GROWMODE_SPECIFIED - none - 4 - 5 5 - wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxTOP|wxBOTTOM|wxRIGHT + wxALIGN_CENTER_VERTICAL|wxTOP 0 1 @@ -1532,7 +1524,7 @@ 5 - wxALIGN_CENTER_VERTICAL|wxEXPAND + wxALIGN_CENTER_VERTICAL|wxEXPAND|wxTOP 0 1 @@ -1625,7 +1617,7 @@ 5 - wxALIGN_CENTER_VERTICAL|wxALL + wxALIGN_CENTER_VERTICAL|wxRIGHT|wxTOP 0 1 @@ -1718,7 +1710,7 @@ 5 - wxBOTTOM|wxTOP + wxBOTTOM 0 1 @@ -1814,9 +1806,37 @@ 0 + + + + 10 + wxEXPAND|wxRIGHT|wxLEFT + 0 + + 0 + protected + 0 + + + + 10 + wxEXPAND|wxLEFT + 4 + + 3 + wxBOTH + 1 + + 5 + + fgTrackRightSizer + wxFLEX_GROWMODE_SPECIFIED + none + 1 + 5 5 - wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxALL + wxALIGN_CENTER_VERTICAL 0 1 @@ -1899,7 +1919,7 @@ 5 - wxALIGN_CENTER_VERTICAL + wxALIGN_CENTER_VERTICAL|wxEXPAND 0 1 @@ -2008,7 +2028,7 @@ 0 wxID_ANY - Vias: + Vias m_sbViaSizer wxHORIZONTAL @@ -2017,23 +2037,23 @@ 5 - wxEXPAND|wxALL - 1 - + wxEXPAND|wxRIGHT|wxLEFT + 5 + 3 wxBOTH - + 1 5 fgViaLeftSizer wxFLEX_GROWMODE_SPECIFIED none - 4 + 6 5 - 5 - wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxALL + 3 + wxALIGN_CENTER_VERTICAL|wxTOP 0 1 @@ -2115,8 +2135,8 @@ - 5 - wxEXPAND + 3 + wxEXPAND|wxTOP 0 1 @@ -2165,7 +2185,7 @@ 1 - TEXT_CTRL_EVAL; widgets/text_ctrl_eval.h + ; ; forward_declare 0 @@ -2206,8 +2226,8 @@ - 5 - wxALIGN_CENTER_VERTICAL|wxALL + 3 + wxALIGN_CENTER_VERTICAL|wxRIGHT|wxTOP 0 1 @@ -2290,7 +2310,7 @@ 5 - wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxALL + wxALIGN_CENTER_VERTICAL|wxBOTTOM 0 1 @@ -2373,7 +2393,7 @@ 5 - wxALIGN_CENTER_VERTICAL|wxEXPAND + wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxEXPAND 0 1 @@ -2422,7 +2442,7 @@ 1 - TEXT_CTRL_EVAL; widgets/text_ctrl_eval.h + ; ; forward_declare 0 @@ -2464,7 +2484,7 @@ 5 - wxALIGN_CENTER_VERTICAL|wxALL + wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT 0 1 @@ -2547,7 +2567,261 @@ 5 - wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxALL + wxALIGN_CENTER_VERTICAL|wxTOP + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 0 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Design rules: + + 0 + + + 0 + + 1 + m_DesignRuleVias + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALIGN_CENTER_VERTICAL|wxEXPAND|wxTOP + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + + 1 + m_DesignRuleViasCtrl + 1 + + + protected + 1 + + Resizable + 0 + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALIGN_CENTER_VERTICAL|wxRIGHT|wxTOP + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Unit + + 0 + + + 0 + + 1 + m_DesignRuleViasUnit + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALIGN_CENTER_VERTICAL 0 1 @@ -2679,7 +2953,7 @@ 1 - TEXT_CTRL_EVAL; widgets/text_ctrl_eval.h + ; ; forward_declare 0 @@ -2721,7 +2995,7 @@ 5 - wxALIGN_CENTER_VERTICAL|wxALL + wxALIGN_CENTER_VERTICAL|wxRIGHT 0 1 @@ -2804,7 +3078,7 @@ 5 - wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxALL + wxALIGN_CENTER_VERTICAL 0 1 @@ -2936,7 +3210,7 @@ 1 - TEXT_CTRL_EVAL; widgets/text_ctrl_eval.h + ; ; forward_declare 0 @@ -2978,7 +3252,7 @@ 5 - wxALIGN_CENTER_VERTICAL|wxALL + wxALIGN_CENTER_VERTICAL|wxRIGHT 0 1 @@ -3059,112 +3333,21 @@ - - - - 5 - wxEXPAND|wxALL - 1 - - 3 - wxBOTH - - - 5 - - fgViaRightSizer - wxFLEX_GROWMODE_SPECIFIED - none - 5 - 5 5 - wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxALL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 0 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Design rule vias: - - 0 - - - 0 - - 1 - m_DesignRuleVias - 1 - - + wxEXPAND + 1 + + 0 protected - 1 - - Resizable - 1 - - - - 0 - - - - - -1 - - - - - - - - - - - - - - - - - - - - - - - + 0 5 - wxALIGN_CENTER_VERTICAL|wxEXPAND + wxALIGN_CENTER_VERTICAL|wxBOTTOM 0 - + 1 1 1 @@ -3178,7 +3361,7 @@ 1 0 - + 0 1 1 @@ -3193,6 +3376,7 @@ 0 0 wxID_ANY + Use net class size 0 @@ -3200,7 +3384,7 @@ 0 1 - m_DesignRuleViasCtrl + m_viaNetclass 1 @@ -3208,7 +3392,6 @@ 1 Resizable - 0 1 @@ -3223,7 +3406,7 @@ - + onViaNetclassCheck @@ -3250,90 +3433,45 @@ 5 - wxALIGN_CENTER_VERTICAL|wxALL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Unit - - 0 - - - 0 - - 1 - m_DesignRuleViasUnit - 1 - - + wxEXPAND + 1 + + 0 protected - 1 - - Resizable - 1 - - - - 0 - - - - - -1 - - - - - - - - - - - - - - - - - - - - - - - + 0 + + + + 10 + wxEXPAND|wxRIGHT|wxLEFT + 0 + + 0 + protected + 0 + + + + 10 + wxEXPAND|wxLEFT + 4 + + 3 + wxBOTH + 1 + + 5 + + fgViaRightSizer + wxFLEX_GROWMODE_SPECIFIED + none + 3 + 5 5 - wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL + wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxTOP 0 1 @@ -3416,7 +3554,7 @@ 5 - wxEXPAND + wxEXPAND|wxLEFT 0 1 @@ -3514,7 +3652,7 @@ 5 - wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL + wxALIGN_CENTER_VERTICAL 0 1 @@ -3698,7 +3836,7 @@ 5 - wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxALL + wxALIGN_CENTER_VERTICAL 0 1 @@ -3880,114 +4018,6 @@ 0 - - 5 - wxEXPAND - 1 - - 0 - protected - 0 - - - - 5 - wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxTOP - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Use net class size - - 0 - - - 0 - - 1 - m_viaNetclass - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - onViaNetclassCheck - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxEXPAND - 1 - - 0 - protected - 0 - - @@ -4004,7 +4034,7 @@ 5 - wxALL|wxEXPAND + wxEXPAND 0 0 @@ -4019,11 +4049,11 @@ m_StdButtons protected - onCancelClick + - onOkClick + diff --git a/pcbnew/dialogs/dialog_track_via_properties_base.h b/pcbnew/dialogs/dialog_track_via_properties_base.h index 9a241fa9a6..ae7336b287 100644 --- a/pcbnew/dialogs/dialog_track_via_properties_base.h +++ b/pcbnew/dialogs/dialog_track_via_properties_base.h @@ -12,7 +12,6 @@ #include #include class PCB_LAYER_BOX_SELECTOR; -class TEXT_CTRL_EVAL; class WIDGET_NET_SELECTOR; #include "dialog_shim.h" @@ -50,16 +49,16 @@ class DIALOG_TRACK_VIA_PROPERTIES_BASE : public DIALOG_SHIM wxCheckBox* m_lockedCbox; wxStaticBoxSizer* m_sbTrackSizer; wxStaticText* m_TrackStartXLabel; - TEXT_CTRL_EVAL* m_TrackStartXCtrl; + wxTextCtrl* m_TrackStartXCtrl; wxStaticText* m_TrackStartXUnit; wxStaticText* m_TrackStartYLabel; - TEXT_CTRL_EVAL* m_TrackStartYCtrl; + wxTextCtrl* m_TrackStartYCtrl; wxStaticText* m_TrackStartYUnit; wxStaticText* m_TrackEndXLabel; - TEXT_CTRL_EVAL* m_TrackEndXCtrl; + wxTextCtrl* m_TrackEndXCtrl; wxStaticText* m_TrackEndXUnit; wxStaticText* m_TrackEndYLabel; - TEXT_CTRL_EVAL* m_TrackEndYCtrl; + wxTextCtrl* m_TrackEndYCtrl; wxStaticText* m_TrackEndYUnit; wxStaticText* m_TrackWidthLabel; wxComboBox* m_TrackWidthCtrl; @@ -69,38 +68,35 @@ class DIALOG_TRACK_VIA_PROPERTIES_BASE : public DIALOG_SHIM PCB_LAYER_BOX_SELECTOR* m_TrackLayerCtrl; wxStaticBoxSizer* m_sbViaSizer; wxStaticText* m_ViaXLabel; - TEXT_CTRL_EVAL* m_ViaXCtrl; + wxTextCtrl* m_ViaXCtrl; wxStaticText* m_ViaXUnit; wxStaticText* m_ViaYLabel; - TEXT_CTRL_EVAL* m_ViaYCtrl; + wxTextCtrl* m_ViaYCtrl; wxStaticText* m_ViaYUnit; - wxStaticText* m_ViaDiameterLabel; - TEXT_CTRL_EVAL* m_ViaDiameterCtrl; - wxStaticText* m_ViaDiameterUnit; - wxStaticText* m_ViaDrillLabel; - TEXT_CTRL_EVAL* m_ViaDrillCtrl; - wxStaticText* m_ViaDrillUnit; wxStaticText* m_DesignRuleVias; wxChoice* m_DesignRuleViasCtrl; wxStaticText* m_DesignRuleViasUnit; + wxStaticText* m_ViaDiameterLabel; + wxTextCtrl* m_ViaDiameterCtrl; + wxStaticText* m_ViaDiameterUnit; + wxStaticText* m_ViaDrillLabel; + wxTextCtrl* m_ViaDrillCtrl; + wxStaticText* m_ViaDrillUnit; + wxCheckBox* m_viaNetclass; wxStaticText* m_ViaTypeLabel; wxChoice* m_ViaTypeChoice; wxStaticText* m_ViaStartLayerLabel; PCB_LAYER_BOX_SELECTOR* m_ViaStartLayer; wxStaticText* m_ViaEndLayerLabel1; PCB_LAYER_BOX_SELECTOR* m_ViaEndLayer; - wxCheckBox* m_viaNetclass; 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 OnInitDlg( wxInitDialogEvent& event ) { event.Skip(); } virtual void onOkClick( wxCommandEvent& event ) { event.Skip(); } virtual void onTrackNetclassCheck( wxCommandEvent& event ) { event.Skip(); } virtual void onViaNetclassCheck( wxCommandEvent& event ) { event.Skip(); } - virtual void onCancelClick( wxCommandEvent& event ) { event.Skip(); } public: diff --git a/pcbnew/dialogs/dialog_track_via_size.cpp b/pcbnew/dialogs/dialog_track_via_size.cpp index abb42470a5..94fa22e86f 100644 --- a/pcbnew/dialogs/dialog_track_via_size.cpp +++ b/pcbnew/dialogs/dialog_track_via_size.cpp @@ -27,14 +27,18 @@ #include #include #include +#include #include "board_design_settings.h" -DIALOG_TRACK_VIA_SIZE::DIALOG_TRACK_VIA_SIZE( wxWindow* aParent, BOARD_DESIGN_SETTINGS& aSettings ) : +const int minSize = (int)( 0.01 * IU_PER_MM ); + +DIALOG_TRACK_VIA_SIZE::DIALOG_TRACK_VIA_SIZE( EDA_DRAW_FRAME* aParent, + BOARD_DESIGN_SETTINGS& aSettings ) : DIALOG_TRACK_VIA_SIZE_BASE( aParent ), - m_trackWidth( aParent, m_trackWidthText, m_trackWidthLabel ), - m_viaDiameter( aParent, m_viaDiameterText, m_viaDiameterLabel ), - m_viaDrill( aParent, m_viaDrillText, m_viaDrillLabel ), + m_trackWidth( aParent, m_trackWidthLabel, m_trackWidthText, m_trackWidthLabel, false, minSize ), + m_viaDiameter( aParent, m_viaDiameterLabel, m_viaDiameterText, m_viaDiameterLabel, false, minSize ), + m_viaDrill( aParent, m_viaDrillLabel, m_viaDrillText, m_viaDrillLabel, false, minSize ), m_settings( aSettings ) { m_stdButtonsOK->SetDefault(); @@ -49,8 +53,12 @@ bool DIALOG_TRACK_VIA_SIZE::TransferDataFromWindow() if( !wxDialog::TransferDataFromWindow() ) return false; - if( !check() ) + if( m_viaDrill.GetValue() >= m_viaDiameter.GetValue() ) + { + DisplayError( GetParent(), _( "Via drill size has to be smaller than via diameter" ) ); + m_viaDrillText->SetFocus(); return false; + } // Store dialog values to the router settings m_settings.SetCustomTrackWidth( m_trackWidth.GetValue() ); @@ -74,36 +82,3 @@ bool DIALOG_TRACK_VIA_SIZE::TransferDataToWindow() return true; } - -bool DIALOG_TRACK_VIA_SIZE::check() -{ - if( m_trackWidth.GetValue() <= 0 ) - { - DisplayError( GetParent(), _( "Invalid track width" ) ); - m_trackWidthText->SetFocus(); - return false; - } - - if( m_viaDiameter.GetValue() <= 0 ) - { - DisplayError( GetParent(), _( "Invalid via diameter" ) ); - m_viaDiameterText->SetFocus(); - return false; - } - - if( m_viaDrill.GetValue() <= 0 ) - { - DisplayError( GetParent(), _( "Invalid via drill size" ) ); - m_viaDrillText->SetFocus(); - return false; - } - - if( m_viaDrill.GetValue() >= m_viaDiameter.GetValue() ) - { - DisplayError( GetParent(), _( "Via drill size has to be smaller than via diameter" ) ); - m_viaDrillText->SetFocus(); - return false; - } - - return true; -} diff --git a/pcbnew/dialogs/dialog_track_via_size.h b/pcbnew/dialogs/dialog_track_via_size.h index 5ccdb69837..a0b82c9428 100644 --- a/pcbnew/dialogs/dialog_track_via_size.h +++ b/pcbnew/dialogs/dialog_track_via_size.h @@ -36,7 +36,7 @@ class DIALOG_TRACK_VIA_SIZE : public DIALOG_TRACK_VIA_SIZE_BASE { public: /** Constructor */ - DIALOG_TRACK_VIA_SIZE( wxWindow* aParent, BOARD_DESIGN_SETTINGS& aSettings ); + DIALOG_TRACK_VIA_SIZE( EDA_DRAW_FRAME* aParent, BOARD_DESIGN_SETTINGS& aSettings ); bool TransferDataFromWindow() override; bool TransferDataToWindow() override; @@ -48,9 +48,6 @@ protected: // Routings settings that are modified by the dialog. BOARD_DESIGN_SETTINGS& m_settings; - - ///> Checks if values given in the dialog are sensible. - bool check(); }; #endif // __dialog_track_via_size__ diff --git a/pcbnew/microwave/microwave_inductor.cpp b/pcbnew/microwave/microwave_inductor.cpp index 90f399fec8..752793d07a 100644 --- a/pcbnew/microwave/microwave_inductor.cpp +++ b/pcbnew/microwave/microwave_inductor.cpp @@ -306,14 +306,14 @@ MODULE* MWAVE::CreateMicrowaveInductor( INDUCTOR_PATTERN& inductorPattern, inductorPattern.m_length = min_len; // Enter the desired length. - msg = StringFromValue( g_UserUnit, inductorPattern.m_length ); - WX_TEXT_ENTRY_DIALOG dlg( nullptr, _( "Length of Trace:" ), wxEmptyString, msg ); + msg = StringFromValue( aPcbFrame->GetUserUnits(), inductorPattern.m_length, true ); + WX_TEXT_ENTRY_DIALOG dlg( aPcbFrame, _( "Length of Trace:" ), wxEmptyString, msg ); if( dlg.ShowModal() != wxID_OK ) return nullptr; // canceled by user msg = dlg.GetValue(); - inductorPattern.m_length = ValueFromString( g_UserUnit, msg ); + inductorPattern.m_length = ValueFromString( aPcbFrame->GetUserUnits(), msg ); // Control values (ii = minimum length) if( inductorPattern.m_length < min_len ) @@ -336,7 +336,7 @@ MODULE* MWAVE::CreateMicrowaveInductor( INDUCTOR_PATTERN& inductorPattern, // Generate footprint. the value is also used as footprint name. msg = "L"; - WX_TEXT_ENTRY_DIALOG cmpdlg( nullptr, _( "Component Value:" ), wxEmptyString, msg ); + WX_TEXT_ENTRY_DIALOG cmpdlg( aPcbFrame, _( "Component Value:" ), wxEmptyString, msg ); cmpdlg.SetTextValidator( FILE_NAME_CHAR_VALIDATOR( &msg ) ); if( ( cmpdlg.ShowModal() != wxID_OK ) || msg.IsEmpty() ) diff --git a/pcbnew/tools/edit_tool.cpp b/pcbnew/tools/edit_tool.cpp index ad86f0725d..79d3c2c47f 100644 --- a/pcbnew/tools/edit_tool.cpp +++ b/pcbnew/tools/edit_tool.cpp @@ -654,13 +654,8 @@ int EDIT_TOOL::Properties( const TOOL_EVENT& aEvent ) { if ( !changeTrackWidthOnClick( selection ) ) { - DIALOG_TRACK_VIA_PROPERTIES dlg( editFrame, selection ); - - if( dlg.ShowModal() ) - { - dlg.Apply( *m_commit ); - m_commit->Push( _( "Edit track/via properties" ) ); - } + DIALOG_TRACK_VIA_PROPERTIES dlg( editFrame, selection, *m_commit ); + dlg.ShowModal(); } } else if( selection.Size() == 1 ) // Properties are displayed when there is only one item selected