Fix inserting first choice item to wxEnumProperty
Situation when when first choice item is inserted (in wxPGProperty::InsertChoice) to the empty collection must be handled in a special way. In order to do so: 1. The state when there are no choice items in wxEnumProperty object and hence no item is selected must be explicitly indicated (by special index value wxNOT_FOUND). 2. This initial state must be handled in a special way when there is determined new selection index after insertion. See #16401. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@76974 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -1896,15 +1896,18 @@ wxValidator* wxPGProperty::DoGetValidator() const
|
|||||||
int wxPGProperty::InsertChoice( const wxString& label, int index, int value )
|
int wxPGProperty::InsertChoice( const wxString& label, int index, int value )
|
||||||
{
|
{
|
||||||
wxPropertyGrid* pg = GetGrid();
|
wxPropertyGrid* pg = GetGrid();
|
||||||
int sel = GetChoiceSelection();
|
const int sel = GetChoiceSelection();
|
||||||
|
|
||||||
int newSel = sel;
|
|
||||||
|
|
||||||
if ( index == wxNOT_FOUND )
|
if ( index == wxNOT_FOUND )
|
||||||
index = m_choices.GetCount();
|
index = m_choices.GetCount();
|
||||||
|
|
||||||
if ( index <= sel )
|
int newSel;
|
||||||
newSel++;
|
if ( sel == wxNOT_FOUND )
|
||||||
|
newSel = 0;
|
||||||
|
else if ( index <= sel )
|
||||||
|
newSel = sel + 1;
|
||||||
|
else
|
||||||
|
newSel = sel;
|
||||||
|
|
||||||
m_choices.Insert(label, index, value);
|
m_choices.Insert(label, index, value);
|
||||||
|
|
||||||
|
@@ -1102,7 +1102,7 @@ WX_PG_IMPLEMENT_PROPERTY_CLASS(wxEnumProperty, wxPGProperty,
|
|||||||
wxEnumProperty::wxEnumProperty( const wxString& label, const wxString& name, const wxChar* const* labels,
|
wxEnumProperty::wxEnumProperty( const wxString& label, const wxString& name, const wxChar* const* labels,
|
||||||
const long* values, int value ) : wxPGProperty(label,name)
|
const long* values, int value ) : wxPGProperty(label,name)
|
||||||
{
|
{
|
||||||
SetIndex(0);
|
SetIndex(wxNOT_FOUND);
|
||||||
|
|
||||||
if ( labels )
|
if ( labels )
|
||||||
{
|
{
|
||||||
@@ -1144,7 +1144,7 @@ wxEnumProperty::wxEnumProperty( const wxString& label, const wxString& name,
|
|||||||
const wxArrayString& labels, const wxArrayInt& values, int value )
|
const wxArrayString& labels, const wxArrayInt& values, int value )
|
||||||
: wxPGProperty(label,name)
|
: wxPGProperty(label,name)
|
||||||
{
|
{
|
||||||
SetIndex(0);
|
SetIndex(wxNOT_FOUND);
|
||||||
|
|
||||||
if ( &labels && labels.size() )
|
if ( &labels && labels.size() )
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user