Fix a hack implemented in wxEnumProperty::ValueFromString_ and wxEnumProperty::ValueFromInt_ functions.

wxEnumProperty code is refactored in order to fix a hack which purpose was (apparently) to bypass constness of these functions by caching determined indices in wxEnumProperty::ms_nextIndex static member variable for further processing. (Unclear concept of using this static member was referred in http://trac.wxwidgets.org/ticket/12779#comment:9)
Now, determined index is returned to the caller and processed there if necessary and hence caching of this index is not necessary.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@78390 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Artur Wieczorek
2015-01-19 17:22:29 +00:00
parent eec7ef7232
commit 752938cecd
3 changed files with 51 additions and 42 deletions

View File

@@ -454,20 +454,34 @@ protected:
int GetIndex() const;
void SetIndex( int index );
#if WXWIN_COMPATIBILITY_3_0
wxDEPRECATED_MSG("use ValueFromString_(wxVariant&, int*, const wxString&, int) function instead")
bool ValueFromString_( wxVariant& value,
const wxString& text,
int argFlags ) const;
bool ValueFromInt_( wxVariant& value, int intVal, int argFlags ) const;
static void ResetNextIndex() { ms_nextIndex = -2; }
int argFlags ) const
{
return ValueFromString_(value, NULL, text, argFlags);
}
wxDEPRECATED_MSG("use ValueFromInt_(wxVariant&, int*, int, int) function instead")
bool ValueFromInt_( wxVariant& value, int intVal, int argFlags ) const
{
return ValueFromInt_(value, NULL, intVal, argFlags);
}
wxDEPRECATED_MSG("don't use ResetNextIndex() function")
static void ResetNextIndex() { }
#endif
// Converts text to value and returns corresponding index in the collection
bool ValueFromString_(wxVariant& value,
int* pIndex,
const wxString& text,
int argFlags) const;
// Converts number to value and returns corresponding index in the collection
bool ValueFromInt_(wxVariant& value, int* pIndex, int intVal, int argFlags) const;
private:
// This is private so that classes are guaranteed to use GetIndex
// for up-to-date index value.
int m_index;
// Relies on ValidateValue being called always before OnSetValue
static int ms_nextIndex;
};
// -----------------------------------------------------------------------