Reduce code duplication in wxGTK wxDataViewRenderer classes

The code was more complicated than necessary, with the base class
providing both virtual GtkOnCellChanged() and GtkOnTextEdited() that
were both overridden to achieve the same thing, namely customizing how
the value entered by user is converted to wxVariant, in different
derived classes.

Make GtkOnTextEdited() non-virtual and remove GtkOnCellChanged()
completely and add a new simple GtkGetValueFromString() which is called
from GtkOnTextEdited() to do the conversion.

This removes the existing code duplication and will make it simpler to
modify this code in the future, without changing the behaviour.
This commit is contained in:
Vadim Zeitlin
2018-02-05 00:01:52 +01:00
parent 0972dece27
commit a00b8dec8b
3 changed files with 27 additions and 37 deletions

View File

@@ -228,9 +228,7 @@ public:
virtual void GtkPackIntoColumn(GtkTreeViewColumn *column) wxOVERRIDE;
protected:
virtual void GtkOnCellChanged(const wxVariant& value,
const wxDataViewItem& item,
unsigned col) wxOVERRIDE;
virtual wxVariant GtkGetValueFromString(const wxString& str) const wxOVERRIDE;
private:
wxDataViewIconText m_value;
@@ -281,7 +279,7 @@ public:
virtual bool GetValue( wxVariant &value ) const wxOVERRIDE;
private:
virtual void GtkOnTextEdited(const char *itempath, const wxString& str) wxOVERRIDE;
virtual wxVariant GtkGetValueFromString(const wxString& str) const;
};