unit_binder: allow updates without triggers

Adds a helper function to allow unit binder calls that change a value
but shouldn't trigger wxevents
This commit is contained in:
Seth Hillbrand 2018-09-09 11:04:10 -07:00
parent 49735c219b
commit 9e33d38cd5
2 changed files with 30 additions and 0 deletions

View File

@ -224,6 +224,26 @@ void UNIT_BINDER::SetValue( wxString aValue )
} }
void UNIT_BINDER::ChangeValue( int aValue )
{
ChangeValue( StringFromValue( m_units, aValue, false, m_useMils ) );
}
void UNIT_BINDER::ChangeValue( wxString aValue )
{
if( dynamic_cast<wxTextEntry*>( m_value ) )
dynamic_cast<wxTextEntry*>( m_value )->ChangeValue( aValue );
else if( dynamic_cast<wxStaticText*>( m_value ) )
dynamic_cast<wxStaticText*>( m_value )->SetLabel( aValue );
if( m_allowEval )
m_eval.Clear();
m_unitLabel->SetLabel( GetAbbreviatedUnitsLabel( m_units, m_useMils ) );
}
int UNIT_BINDER::GetValue() const int UNIT_BINDER::GetValue() const
{ {
wxString s; wxString s;

View File

@ -75,6 +75,16 @@ public:
void SetValue( wxString aValue ); void SetValue( wxString aValue );
/**
* Function ChangeValue
* Changes the value (in Internal Units) for the text field, taking care of units conversion
* but does not trigger the update routine
* @param aValue is the new value.
*/
virtual void ChangeValue( int aValue );
void ChangeValue( wxString aValue );
/** /**
* Function GetValue * Function GetValue
* Returns the current value in Internal Units. * Returns the current value in Internal Units.