Dedupe wxCB_READONLY check

This commit is contained in:
Graham Dawes
2019-02-04 09:25:55 +00:00
parent 1472b2f8ef
commit a60c2470b5
2 changed files with 9 additions and 3 deletions

View File

@@ -87,6 +87,7 @@ protected:
private:
void SetActualValue(const wxString& value);
bool IsReadOnly() const;
// From wxTextEntry:
virtual wxWindow *GetEditableWindow() wxOVERRIDE { return this; }

View File

@@ -171,7 +171,7 @@ bool wxComboBox::Create(wxWindow *parent, wxWindowID id,
void wxComboBox::SetActualValue(const wxString &value)
{
if ( HasFlag(wxCB_READONLY) )
if ( IsReadOnly() )
{
SetStringSelection( value );
}
@@ -182,11 +182,16 @@ void wxComboBox::SetActualValue(const wxString &value)
}
}
bool wxComboBox::IsReadOnly() const
{
return HasFlag( wxCB_READONLY );
}
void wxComboBox::SetValue(const wxString& value)
{
SetActualValue( value );
if ( !HasFlag(wxCB_READONLY) )
if ( !IsReadOnly() )
SetInsertionPoint( 0 );
}
@@ -251,7 +256,7 @@ void wxComboBox::Dismiss()
void wxComboBox::Clear()
{
if ( !HasFlag(wxCB_READONLY) )
if ( !IsReadOnly() )
wxTextEntry::Clear();
wxItemContainer::Clear();