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:
Jaakko Salli
2009-07-10 14:47:58 +00:00
parent 65bd7f79c8
commit befee9b713
2 changed files with 20 additions and 0 deletions

View File

@@ -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;
}

View File

@@ -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;
}