X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/f696015cf1e474315b63823d697a5fa0462055b7..f239a20092359e3c914adb79bd39f3f5d2b2e06f:/src/generic/bmpcboxg.cpp diff --git a/src/generic/bmpcboxg.cpp b/src/generic/bmpcboxg.cpp index ce14a4708f..029d8a5463 100644 --- a/src/generic/bmpcboxg.cpp +++ b/src/generic/bmpcboxg.cpp @@ -128,7 +128,7 @@ bool wxBitmapComboBox::Create(wxWindow *parent, wxBitmapComboBox::~wxBitmapComboBox() { - Clear(); + DoClear(); } // ---------------------------------------------------------------------------- @@ -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(m_bitmaps[pos]); + m_bitmaps.RemoveAt(pos); + m_bitmaps.Insert(bmp, index); + } return index; } @@ -327,7 +337,7 @@ void wxBitmapComboBox::OnDrawItem(wxDC& dc, { text = GetString(item); } - + wxBitmapComboBoxBase::DrawItem(dc, rect, item, text, flags); }