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
This commit is contained in:
Mattia Barbon 2005-04-24 15:28:18 +00:00
parent 70949ed554
commit 9c707f80c0

View File

@ -80,7 +80,6 @@ bool wxChoice::Create(wxWindow *parent, wxWindowID id,
m_peer->SetValueAndRange( n > 0 ? 1 : 0 , 0 , 0 ) ; m_peer->SetValueAndRange( n > 0 ? 1 : 0 , 0 , 0 ) ;
MacPostControlCreate(pos,size) ; MacPostControlCreate(pos,size) ;
// FIXME: STL version of wxArrayString doesn't have the same args
#if !wxUSE_STL #if !wxUSE_STL
if ( style & wxCB_SORT ) if ( style & wxCB_SORT )
{ {
@ -101,10 +100,22 @@ bool wxChoice::Create(wxWindow *parent, wxWindowID id,
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
int wxChoice::DoAppend(const wxString& item) int wxChoice::DoAppend(const wxString& item)
{ {
// FIXME: STL version of wxArrayString doesn't have the same args
#if wxUSE_STL #if wxUSE_STL
size_t index = m_strings.size(); wxArrayString::iterator insertPoint;
m_strings.Add( item ); 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 #else
size_t index = m_strings.Add( item ) ; size_t index = m_strings.Add( item ) ;
#endif #endif