Cleanup dynamic casts in unit binder
This commit is contained in:
parent
b707c84b62
commit
306ebb0e89
|
@ -204,12 +204,9 @@ void UNIT_BINDER::SetDoubleValue( double aValue )
|
||||||
|
|
||||||
void UNIT_BINDER::SetValue( wxString aValue )
|
void UNIT_BINDER::SetValue( wxString aValue )
|
||||||
{
|
{
|
||||||
auto textEntry = dynamic_cast<wxTextEntry*>( m_value );
|
if( auto textEntry = dynamic_cast<wxTextEntry*>( m_value ) )
|
||||||
auto staticText = dynamic_cast<wxStaticText*>( m_value );
|
|
||||||
|
|
||||||
if( textEntry )
|
|
||||||
textEntry->SetValue( aValue );
|
textEntry->SetValue( aValue );
|
||||||
else if( staticText )
|
else if( auto staticText = dynamic_cast<wxStaticText*>( m_value ) )
|
||||||
staticText->SetLabel( aValue );
|
staticText->SetLabel( aValue );
|
||||||
|
|
||||||
if( m_allowEval )
|
if( m_allowEval )
|
||||||
|
@ -227,12 +224,9 @@ void UNIT_BINDER::ChangeValue( int aValue )
|
||||||
|
|
||||||
void UNIT_BINDER::ChangeValue( wxString aValue )
|
void UNIT_BINDER::ChangeValue( wxString aValue )
|
||||||
{
|
{
|
||||||
auto textEntry = dynamic_cast<wxTextEntry*>( m_value );
|
if( auto textEntry = dynamic_cast<wxTextEntry*>( m_value ) )
|
||||||
auto staticText = dynamic_cast<wxStaticText*>( m_value );
|
|
||||||
|
|
||||||
if( textEntry )
|
|
||||||
textEntry->ChangeValue( aValue );
|
textEntry->ChangeValue( aValue );
|
||||||
else if( staticText )
|
else if( auto staticText = dynamic_cast<wxStaticText*>( m_value ) )
|
||||||
staticText->SetLabel( aValue );
|
staticText->SetLabel( aValue );
|
||||||
|
|
||||||
if( m_allowEval )
|
if( m_allowEval )
|
||||||
|
@ -244,18 +238,16 @@ void UNIT_BINDER::ChangeValue( wxString aValue )
|
||||||
|
|
||||||
long long int UNIT_BINDER::GetValue()
|
long long int UNIT_BINDER::GetValue()
|
||||||
{
|
{
|
||||||
auto textEntry = dynamic_cast<wxTextEntry*>( m_value );
|
|
||||||
auto staticText = dynamic_cast<wxStaticText*>( m_value );
|
|
||||||
wxString value;
|
wxString value;
|
||||||
|
|
||||||
if( textEntry )
|
if( auto textEntry = dynamic_cast<wxTextEntry*>( m_value ) )
|
||||||
{
|
{
|
||||||
if( m_needsEval && m_eval.Process( textEntry->GetValue() ) )
|
if( m_needsEval && m_eval.Process( textEntry->GetValue() ) )
|
||||||
value = m_eval.Result();
|
value = m_eval.Result();
|
||||||
else
|
else
|
||||||
value = textEntry->GetValue();
|
value = textEntry->GetValue();
|
||||||
}
|
}
|
||||||
else if( staticText )
|
else if( auto staticText = dynamic_cast<wxStaticText*>( m_value ) )
|
||||||
value = staticText->GetLabel();
|
value = staticText->GetLabel();
|
||||||
else
|
else
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -266,18 +258,16 @@ long long int UNIT_BINDER::GetValue()
|
||||||
|
|
||||||
double UNIT_BINDER::GetDoubleValue()
|
double UNIT_BINDER::GetDoubleValue()
|
||||||
{
|
{
|
||||||
auto textEntry = dynamic_cast<wxTextEntry*>( m_value );
|
|
||||||
auto staticText = dynamic_cast<wxStaticText*>( m_value );
|
|
||||||
wxString value;
|
wxString value;
|
||||||
|
|
||||||
if( textEntry )
|
if( auto textEntry = dynamic_cast<wxTextEntry*>( m_value ) )
|
||||||
{
|
{
|
||||||
if( m_needsEval && m_eval.Process( textEntry->GetValue() ) )
|
if( m_needsEval && m_eval.Process( textEntry->GetValue() ) )
|
||||||
value = m_eval.Result();
|
value = m_eval.Result();
|
||||||
else
|
else
|
||||||
value = textEntry->GetValue();
|
value = textEntry->GetValue();
|
||||||
}
|
}
|
||||||
else if( staticText )
|
else if( auto staticText = dynamic_cast<wxStaticText*>( m_value ) )
|
||||||
value = staticText->GetLabel();
|
value = staticText->GetLabel();
|
||||||
else
|
else
|
||||||
return 0.0;
|
return 0.0;
|
||||||
|
@ -288,9 +278,7 @@ double UNIT_BINDER::GetDoubleValue()
|
||||||
|
|
||||||
bool UNIT_BINDER::IsIndeterminate() const
|
bool UNIT_BINDER::IsIndeterminate() const
|
||||||
{
|
{
|
||||||
auto textEntry = dynamic_cast<wxTextEntry*>( m_value );
|
if( auto textEntry = dynamic_cast<wxTextEntry*>( m_value ) )
|
||||||
|
|
||||||
if( textEntry )
|
|
||||||
return textEntry->GetValue() == INDETERMINATE;
|
return textEntry->GetValue() == INDETERMINATE;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
@ -301,10 +289,10 @@ wxString UNIT_BINDER::GetOriginalText() const
|
||||||
{
|
{
|
||||||
if( m_allowEval )
|
if( m_allowEval )
|
||||||
return m_eval.OriginalText();
|
return m_eval.OriginalText();
|
||||||
else if( dynamic_cast<wxTextEntry*>( m_value ) )
|
else if( auto textEntry = dynamic_cast<wxTextEntry*>( m_value ) )
|
||||||
return dynamic_cast<wxTextEntry*>( m_value )->GetValue();
|
return textEntry->GetValue();
|
||||||
else if( dynamic_cast<wxStaticText*>( m_value ) )
|
else if( auto staticText = dynamic_cast<wxStaticText*>( m_value ) )
|
||||||
return dynamic_cast<wxStaticText*>( m_value )->GetLabel();
|
return staticText->GetLabel();
|
||||||
else
|
else
|
||||||
return wxEmptyString;
|
return wxEmptyString;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue