X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/34585919945f677b905e314cdbd850fc4cbd3583..169d1d643c0ee0c90fa8e393b5298606bbb68cfd:/src/mac/carbon/choice.cpp diff --git a/src/mac/carbon/choice.cpp b/src/mac/carbon/choice.cpp index 309bcf0ded..852459a9ff 100644 --- a/src/mac/carbon/choice.cpp +++ b/src/mac/carbon/choice.cpp @@ -21,9 +21,7 @@ #include "wx/menu.h" #include "wx/mac/uma.h" -#if !USE_SHARED_LIBRARY IMPLEMENT_DYNAMIC_CLASS(wxChoice, wxControl) -#endif extern MenuHandle NewUniqueMenu() ; @@ -80,10 +78,12 @@ bool wxChoice::Create(wxWindow *parent, wxWindowID id, m_peer->SetValueAndRange( n > 0 ? 1 : 0 , 0 , 0 ) ; MacPostControlCreate(pos,size) ; +#if !wxUSE_STL if ( style & wxCB_SORT ) { m_strings = wxArrayString(1) ; // autosort } +#endif for ( int i = 0; i < n; i++ ) { @@ -98,7 +98,25 @@ bool wxChoice::Create(wxWindow *parent, wxWindowID id, // ---------------------------------------------------------------------------- int wxChoice::DoAppend(const wxString& item) { +#if wxUSE_STL + 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 m_datas.Insert( NULL , index ) ; UMAInsertMenuItem(MAC_WXHMENU( m_macPopUpMenuHandle ) , item, m_font.GetEncoding() , index ); DoSetItemClientData( index , NULL ) ;