From befee9b7138622434d29acf09427d69a1e7c68ee Mon Sep 17 00:00:00 2001 From: Jaakko Salli Date: Fri, 10 Jul 2009 14:47:58 +0000 Subject: [PATCH] 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 --- src/generic/bmpcboxg.cpp | 10 ++++++++++ src/msw/bmpcbox.cpp | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/src/generic/bmpcboxg.cpp b/src/generic/bmpcboxg.cpp index ce14a4708f..010132792f 100644 --- a/src/generic/bmpcboxg.cpp +++ b/src/generic/bmpcboxg.cpp @@ -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; } diff --git a/src/msw/bmpcbox.cpp b/src/msw/bmpcbox.cpp index d160fd93cd..6ae9044a2d 100644 --- a/src/msw/bmpcbox.cpp +++ b/src/msw/bmpcbox.cpp @@ -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(m_bitmaps[pos]); + m_bitmaps.RemoveAt(pos); + m_bitmaps.Insert(bmp, index); + } return index; } -- 2.47.2