Browse Source

unit_binder: allow updates without triggers

Adds a helper function to allow unit binder calls that change a value
but shouldn't trigger wxevents
pull/13/head
Seth Hillbrand 7 years ago
parent
commit
9e33d38cd5
  1. 20
      common/widgets/unit_binder.cpp
  2. 10
      include/widgets/unit_binder.h

20
common/widgets/unit_binder.cpp

@ -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
{
wxString s;

10
include/widgets/unit_binder.h

@ -75,6 +75,16 @@ public:
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
* Returns the current value in Internal Units.

Loading…
Cancel
Save