From: Mattia Barbon Date: Sun, 24 Apr 2005 15:28:18 +0000 (+0000) Subject: Fix wxChoice on Mac whith STL when using wxCB_SORT. X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/9c707f80c026273d65c0cc435144061b7678f0e3?ds=inline Fix wxChoice on Mac whith STL when using wxCB_SORT. Should have done this yesterday instead of hacking a compilation fix. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@33867 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/mac/carbon/choice.cpp b/src/mac/carbon/choice.cpp index b173ac7d55..6d42fc9d8d 100644 --- a/src/mac/carbon/choice.cpp +++ b/src/mac/carbon/choice.cpp @@ -80,7 +80,6 @@ bool wxChoice::Create(wxWindow *parent, wxWindowID id, m_peer->SetValueAndRange( n > 0 ? 1 : 0 , 0 , 0 ) ; MacPostControlCreate(pos,size) ; - // FIXME: STL version of wxArrayString doesn't have the same args #if !wxUSE_STL if ( style & wxCB_SORT ) { @@ -101,10 +100,22 @@ bool wxChoice::Create(wxWindow *parent, wxWindowID id, // ---------------------------------------------------------------------------- int wxChoice::DoAppend(const wxString& item) { - // FIXME: STL version of wxArrayString doesn't have the same args #if wxUSE_STL - size_t index = m_strings.size(); - m_strings.Add( item ); + wxArrayString::iterator insertPoint; + size_t index; + + if (GetWindowStyle() & wxCB_SORT) + { + insertPoint = std::lower_bound( m_strings.begin(), m_strings.end(), item ); + index = insertPoint - m_strings.begin(); + } + else + { + insertPoint = m_strings.end(); + index = m_strings.size(); + } + + m_strings.insert( insertPoint, item ); #else size_t index = m_strings.Add( item ) ; #endif