Fixed wxCB_SORT for wxMSW and generic wxBitmapComboBox
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@61371 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -151,6 +151,8 @@ int wxBitmapComboBox::DoInsertItems(const wxArrayStringsAdapter & items,
|
||||
const unsigned int numItems = items.GetCount();
|
||||
const unsigned int countNew = GetCount() + numItems;
|
||||
|
||||
wxASSERT( numItems == 1 || !HasFlag(wxCB_SORT) ); // Sanity check
|
||||
|
||||
m_bitmaps.Alloc(countNew);
|
||||
|
||||
for ( unsigned int i = 0; i < numItems; i++ )
|
||||
@@ -166,6 +168,14 @@ int wxBitmapComboBox::DoInsertItems(const wxArrayStringsAdapter & items,
|
||||
for ( int i = numItems-1; i >= 0; i-- )
|
||||
BCBDoDeleteOneItem(pos + i);
|
||||
}
|
||||
else if ( ((unsigned int)index) != pos )
|
||||
{
|
||||
// Move pre-inserted empty bitmap into correct position
|
||||
// (usually happens when combo box has wxCB_SORT style)
|
||||
wxBitmap* bmp = static_cast<wxBitmap*>(m_bitmaps[pos]);
|
||||
m_bitmaps.RemoveAt(pos);
|
||||
m_bitmaps.Insert(bmp, index);
|
||||
}
|
||||
|
||||
return index;
|
||||
}
|
||||
|
@@ -253,6 +253,8 @@ int wxBitmapComboBox::DoInsertItems(const wxArrayStringsAdapter & items,
|
||||
const unsigned int numItems = items.GetCount();
|
||||
const unsigned int countNew = GetCount() + numItems;
|
||||
|
||||
wxASSERT( numItems == 1 || !HasFlag(wxCB_SORT) ); // Sanity check
|
||||
|
||||
m_bitmaps.Alloc(countNew);
|
||||
|
||||
for ( unsigned int i = 0; i < numItems; i++ )
|
||||
@@ -268,6 +270,14 @@ int wxBitmapComboBox::DoInsertItems(const wxArrayStringsAdapter & items,
|
||||
for ( int i = numItems-1; i >= 0; i-- )
|
||||
BCBDoDeleteOneItem(pos + i);
|
||||
}
|
||||
else if ( ((unsigned int)index) != pos )
|
||||
{
|
||||
// Move pre-inserted empty bitmap into correct position
|
||||
// (usually happens when combo box has wxCB_SORT style)
|
||||
wxBitmap* bmp = static_cast<wxBitmap*>(m_bitmaps[pos]);
|
||||
m_bitmaps.RemoveAt(pos);
|
||||
m_bitmaps.Insert(bmp, index);
|
||||
}
|
||||
|
||||
return index;
|
||||
}
|
||||
|
Reference in New Issue
Block a user