diff --git a/common/wx_unit_binder.cpp b/common/wx_unit_binder.cpp index 9498d3a232..25ef4cb205 100644 --- a/common/wx_unit_binder.cpp +++ b/common/wx_unit_binder.cpp @@ -35,7 +35,7 @@ #include "wx_unit_binder.h" -WX_UNIT_BINDER::WX_UNIT_BINDER( wxWindow* aParent, wxTextCtrl* aTextInput, +WX_UNIT_BINDER::WX_UNIT_BINDER( wxWindow* aParent, wxTextCtrl* aTextInput, wxStaticText* aUnitLabel, wxSpinButton* aSpinButton ) : m_textCtrl( aTextInput ), m_unitLabel( aUnitLabel ), @@ -60,7 +60,7 @@ void WX_UNIT_BINDER::SetValue( int aValue ) wxString s = StringFromValue( m_units, aValue, false ); m_textCtrl->SetValue( s ); - + m_unitLabel->SetLabel( GetAbbreviatedUnitsLabel( m_units ) ); } @@ -73,6 +73,14 @@ int WX_UNIT_BINDER::GetValue() const } +bool WX_UNIT_BINDER::Valid() const +{ + double dummy; + + return m_textCtrl->GetValue().ToDouble( &dummy ); +} + + void WX_UNIT_BINDER::Enable( bool aEnable ) { m_textCtrl->Enable( aEnable ); diff --git a/include/wx_unit_binder.h b/include/wx_unit_binder.h index be4e39d39d..ad4741d563 100644 --- a/include/wx_unit_binder.h +++ b/include/wx_unit_binder.h @@ -60,6 +60,12 @@ public: */ virtual int GetValue() const; + /** + * Function Valid + * Returns true if the text control contains a real number. + */ + bool Valid() const; + /** * Function Enable * Enables/diasables the binded widgets