Switch UNIT_BINDER and DIALOG_SHIM to local units.

The general idea is to support user-units inheritance.  The
UNIT_BINDER allows wrapped controls to inherit units from their
parent dialog, while KEYWAY_HOLDER and DIALOG_SHIM allow child
KEYWAY_HOLDERs or DIALOG_SHIMs to inherit units from their
parent.

The GetUserUnits() method signature has to move to KEYWAY_HOLDER
rather than KEYWAY_PLAYER (where it makes more sense) as it’s the
only common ancestor of KEYWAY_PLAYER and DIALOG_SHIM.

As long as we'll be using the UNIT_BINDER more widely, it also
makes sense to move evaluation and validation into it.

This commit also provides eeschema’s DIALOG_LABEL_EDITOR and
pcbnew’s DIALOG_TRACK_VIA_PROPERTIES and DIALOG_SET_GRID as
models of how to use the new user-units inheritance, eval, and
validation.

Fixes: lp:593795
* https://bugs.launchpad.net/kicad/+bug/593795

(cherry picked from commit c8bc53e)
This commit is contained in:
Jeff Young 2018-02-03 09:09:53 +00:00
parent 4f8c546140
commit 74acb76e7f
36 changed files with 2254 additions and 2289 deletions

View File

@ -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<KIWAY_HOLDER*>( 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<KIWAY_HOLDER*>( 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<KIWAY_PLAYER*>( aParent );

View File

@ -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 )
{

View File

@ -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];

View File

@ -23,26 +23,36 @@
*/
#include <wx/stattext.h>
#include <wx/sizer.h>
#include <wx/textentry.h>
#include <limits>
#include <base_units.h>
#include <wx/valnum.h>
#include <draw_frame.h>
#include <confirm.h>
#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<wxWindow*>( 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<wxWindow*>( 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<wxWindow*>( m_textEntry );
textInput->SetFocus();
textInput->Unbind( wxEVT_IDLE, &UNIT_BINDER::delayedFocusHandler, this );
}
bool UNIT_BINDER::Validate( bool setFocusOnError )
{
wxWindow* textInput = dynamic_cast<wxWindow*>( 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<wxWindow*>( 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<wxWindow*>( m_textEntry )->Enable( aEnable );
m_unitLabel->Enable( aEnable );
}

View File

@ -40,6 +40,7 @@
#include <confirm.h>
#include <sch_text.h>
#include <typeinfo>
#include <widgets/unit_binder.h>
#include <dialog_edit_label_base.h>
@ -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<double> 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;
}

View File

@ -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 );
}

View File

@ -14,7 +14,6 @@
<property name="file">dialog_edit_label_base</property>
<property name="first_id">1000</property>
<property name="help_provider">none</property>
<property name="indent_with_spaces"></property>
<property name="internationalize">1</property>
<property name="name">dialog_edit_label_base</property>
<property name="namespace"></property>
@ -112,7 +111,7 @@
<property name="vgap">3</property>
<object class="sizeritem" expanded="1">
<property name="border">3</property>
<property name="flag">wxALIGN_CENTER_VERTICAL|wxRIGHT</property>
<property name="flag">wxALIGN_TOP|wxRIGHT|wxTOP</property>
<property name="proportion">0</property>
<object class="wxStaticText" expanded="1">
<property name="BottomDockable">1</property>
@ -204,7 +203,7 @@
<property name="permission">none</property>
<object class="sizeritem" expanded="1">
<property name="border">3</property>
<property name="flag">wxEXPAND|wxLEFT</property>
<property name="flag">wxBOTTOM|wxEXPAND|wxLEFT</property>
<property name="proportion">0</property>
<object class="wxTextCtrl" expanded="1">
<property name="BottomDockable">1</property>
@ -240,7 +239,7 @@
<property name="maxlength"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="minimum_size">360,-1</property>
<property name="moveable">1</property>
<property name="name">m_textLabelSingleLine</property>
<property name="pane_border">1</property>
@ -295,7 +294,7 @@
</object>
<object class="sizeritem" expanded="1">
<property name="border">3</property>
<property name="flag">wxEXPAND|wxLEFT</property>
<property name="flag">wxBOTTOM|wxEXPAND|wxLEFT</property>
<property name="proportion">1</property>
<object class="wxTextCtrl" expanded="1">
<property name="BottomDockable">1</property>
@ -331,7 +330,7 @@
<property name="maxlength"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size">-1,60</property>
<property name="minimum_size">480,72</property>
<property name="moveable">1</property>
<property name="name">m_textLabelMultiLine</property>
<property name="pane_border">1</property>
@ -388,7 +387,7 @@
</object>
<object class="sizeritem" expanded="1">
<property name="border">3</property>
<property name="flag">wxALIGN_CENTER_VERTICAL|wxRIGHT</property>
<property name="flag">wxALIGN_CENTER_VERTICAL|wxTOP|wxRIGHT</property>
<property name="proportion">0</property>
<object class="wxStaticText" expanded="1">
<property name="BottomDockable">1</property>
@ -480,7 +479,7 @@
<property name="permission">none</property>
<object class="sizeritem" expanded="1">
<property name="border">3</property>
<property name="flag">wxALIGN_CENTER_VERTICAL|wxEXPAND|wxLEFT|wxRIGHT</property>
<property name="flag">wxALIGN_CENTER_VERTICAL|wxEXPAND|wxLEFT|wxTOP</property>
<property name="proportion">0</property>
<object class="wxTextCtrl" expanded="1">
<property name="BottomDockable">1</property>
@ -518,7 +517,7 @@
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_TextSize</property>
<property name="name">m_TextSizeCtrl</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
@ -570,8 +569,8 @@
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">3</property>
<property name="flag">wxALIGN_CENTER_VERTICAL|wxLEFT</property>
<property name="border">2</property>
<property name="flag">wxALIGN_CENTER_VERTICAL|wxTOP</property>
<property name="proportion">0</property>
<object class="wxStaticText" expanded="1">
<property name="BottomDockable">1</property>
@ -667,7 +666,7 @@
<property name="permission">none</property>
<object class="sizeritem" expanded="1">
<property name="border">3</property>
<property name="flag">wxRIGHT|wxTOP</property>
<property name="flag">wxRIGHT|wxTOP|wxEXPAND</property>
<property name="proportion">1</property>
<object class="wxRadioBox" expanded="1">
<property name="BottomDockable">1</property>
@ -698,7 +697,7 @@
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">O&amp;rientation:</property>
<property name="label">Orientation</property>
<property name="majorDimension">1</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
@ -757,7 +756,7 @@
</object>
<object class="sizeritem" expanded="1">
<property name="border">3</property>
<property name="flag">wxLEFT|wxRIGHT|wxTOP</property>
<property name="flag">wxLEFT|wxRIGHT|wxTOP|wxEXPAND</property>
<property name="proportion">1</property>
<object class="wxRadioBox" expanded="1">
<property name="BottomDockable">1</property>
@ -788,7 +787,7 @@
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">St&amp;yle:</property>
<property name="label">Style</property>
<property name="majorDimension">1</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
@ -847,7 +846,7 @@
</object>
<object class="sizeritem" expanded="1">
<property name="border">3</property>
<property name="flag">wxALL|wxLEFT|wxTOP</property>
<property name="flag">wxALL|wxLEFT|wxTOP|wxEXPAND</property>
<property name="proportion">1</property>
<object class="wxRadioBox" expanded="1">
<property name="BottomDockable">1</property>
@ -863,7 +862,7 @@
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="choices">&quot;Input&quot; &quot;Output&quot; &quot;Bidirectional&quot; &quot;Tri-State&quot; &quot;Passive&quot;</property>
<property name="choices">&quot;Input&quot; &quot;Output&quot; &quot;Bidirectional&quot; &quot;Tri-state&quot; &quot;Passive&quot;</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
@ -878,7 +877,7 @@
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">S&amp;hape:</property>
<property name="label">Shape</property>
<property name="majorDimension">1</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
@ -895,7 +894,7 @@
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="selection">0</property>
<property name="selection">3</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style">wxRA_SPECIFY_COLS</property>
@ -954,11 +953,11 @@
<property name="name">m_sdbSizer1</property>
<property name="permission">protected</property>
<event name="OnApplyButtonClick"></event>
<event name="OnCancelButtonClick">OnCancelClick</event>
<event name="OnCancelButtonClick"></event>
<event name="OnContextHelpButtonClick"></event>
<event name="OnHelpButtonClick"></event>
<event name="OnNoButtonClick"></event>
<event name="OnOKButtonClick">OnOkClick</event>
<event name="OnOKButtonClick"></event>
<event name="OnSaveButtonClick"></event>
<event name="OnYesButtonClick"></event>
</object>

View File

@ -1,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:

View File

@ -37,6 +37,14 @@
#include <common.h>
#include <convert_to_biu.h>
/**
* 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 ); }

View File

@ -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

View File

@ -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; }
/**

View File

@ -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
*

View File

@ -74,6 +74,8 @@ Supported units are millimeters (mm), Mil (mil) and inch (")
#include <string>
#include <map>
#include <base_units.h>
// 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

View File

@ -26,24 +26,37 @@
#define __UNIT_BINDER_H_
#include <common.h>
#include <wx/spinbutt.h>
#include <base_units.h>
#include <libeval/numeric_evaluator.h>
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_ */

View File

@ -39,7 +39,6 @@
#include <board_design_settings.h>
#include <class_draw_panel_gal.h>
#include <view/view.h>
#include <bitmaps.h>
#include <collectors.h>
#include <tool/tool_manager.h>
#include <tools/pcb_actions.h>
@ -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 );
}

View File

@ -38,6 +38,7 @@
#include <dialog_drc_base.h>
#include <dialog_drclistbox.h>
#include <widgets/unit_binder.h>
// 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_

View File

@ -26,12 +26,14 @@
#include "dialog_pns_diff_pair_dimensions.h"
#include <widgets/text_ctrl_eval.h>
#include <router/pns_sizes_settings.h>
#include <draw_frame.h>
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() );

View File

@ -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;

View File

@ -27,15 +27,16 @@
#include <router/pns_meander_placer.h>
#include <widgets/text_ctrl_eval.h>
#include <bitmaps.h>
#include <draw_frame.h>
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 )
{

View File

@ -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;

View File

@ -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 );

View File

@ -1076,7 +1076,7 @@
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_staticText9</property>
<property name="name">m_minAmplLabel</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
@ -1333,7 +1333,7 @@
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_staticText91</property>
<property name="name">m_maxAmplLabel</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
@ -1590,7 +1590,7 @@
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_staticText11</property>
<property name="name">m_spacingLabel</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
@ -2251,7 +2251,7 @@
</object>
<object class="sizeritem" expanded="0">
<property name="border">5</property>
<property name="flag">wxEXPAND|wxALL</property>
<property name="flag">wxEXPAND</property>
<property name="proportion">0</property>
<object class="wxStdDialogButtonSizer" expanded="0">
<property name="Apply">0</property>

View File

@ -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;

View File

@ -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 <dialog_set_grid_base.h>
#include <base_units.h>
#include <convert_to_biu.h>
#include <common.h>
#include <widgets/unit_binder.h>
#include <pcb_base_frame.h>
#include <class_drawpanel.h>
@ -40,20 +40,15 @@
#include <tools/pcb_actions.h>
#include <tool/tool_manager.h>
#include <limits.h>
// 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 );
}

View File

@ -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 );

File diff suppressed because it is too large Load Diff

View File

@ -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 <wx/settings.h>
#include <wx/textctrl.h>
#include <wx/sizer.h>
#include <wx/button.h>
#include <wx/statbox.h>
#include <wx/combobox.h>
#include <wx/button.h>
#include <wx/dialog.h>
///////////////////////////////////////////////////////////////////////////
@ -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();
};

View File

@ -28,40 +28,32 @@
#include <class_track.h>
#include <pcb_edit_frame.h>
#include <confirm.h>
#include <widgets/text_ctrl_eval.h>
#include <widgets/widget_net_selector.h>
#include <board_commit.h>
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<int> trackStartX( []()->OPT<int> { return NULLOPT; }() );
OPT<int> trackStartY( []()->OPT<int> { return NULLOPT; }() );
OPT<int> trackEndX( []()->OPT<int> { return NULLOPT; }() );
OPT<int> trackEndY( []()->OPT<int> { return NULLOPT; }() );
OPT<int> trackWidth( []()->OPT<int> { return NULLOPT; }() );
OPT<PCB_LAYER_ID> trackLayer( []()->OPT<PCB_LAYER_ID> { return NULLOPT; }() );
OPT<int> viaX( []()->OPT<int> { return NULLOPT; }() );
OPT<int> viaY( []()->OPT<int> { return NULLOPT; }() );
OPT<int> viaDiameter( []()->OPT<int> { return NULLOPT; }() );
OPT<int> viaDrill( []()->OPT<int> { 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<TRACK*>( 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<VIA*>( 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<PCB_LAYER_ID>( 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<VIA_DIMENSION*> ( 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;
}

View File

@ -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<T> or "<...>" if it is not available.
template<typename T>
void setCommonVal( const OPT<T>& 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;

View File

@ -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 );
}

File diff suppressed because it is too large Load Diff

View File

@ -12,7 +12,6 @@
#include <wx/xrc/xmlres.h>
#include <wx/intl.h>
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:

View File

@ -27,14 +27,18 @@
#include <confirm.h>
#include <widgets/text_ctrl_eval.h>
#include <core/optional.h>
#include <draw_frame.h>
#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;
}

View File

@ -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__

View File

@ -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() )

View File

@ -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