X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/aacd14428971b5e199f88597f76a895c68dd298f..04c3457ae3f7d0e5063dcc94b357e76021c368cf:/src/mac/carbon/choice.cpp diff --git a/src/mac/carbon/choice.cpp b/src/mac/carbon/choice.cpp index b173ac7d55..1e36605c7e 100644 --- a/src/mac/carbon/choice.cpp +++ b/src/mac/carbon/choice.cpp @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: choice.cpp +// Name: src/mac/carbon/choice.cpp // Purpose: wxChoice // Author: Stefan Csomor // Modified by: @@ -9,10 +9,6 @@ // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// -#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) -#pragma implementation "choice.h" -#endif - #include "wx/wxprec.h" #if wxUSE_CHOICE @@ -21,9 +17,7 @@ #include "wx/menu.h" #include "wx/mac/uma.h" -#if !USE_SHARED_LIBRARY IMPLEMENT_DYNAMIC_CLASS(wxChoice, wxControl) -#endif extern MenuHandle NewUniqueMenu() ; @@ -80,14 +74,13 @@ 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 ) { m_strings = wxArrayString(1) ; // autosort } #endif - + for ( int i = 0; i < n; i++ ) { Append(choices[i]); @@ -101,10 +94,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 @@ -190,9 +195,9 @@ int wxChoice::GetCount() const return m_strings.GetCount() ; } -int wxChoice::FindString(const wxString& s) const +int wxChoice::FindString(const wxString& s, bool bCase ) const { - return m_strings.Index( s , true , false) ; + return m_strings.Index( s , bCase ) ; } void wxChoice::SetString(int n, const wxString& s) @@ -204,7 +209,7 @@ void wxChoice::SetString(int n, const wxString& s) wxString wxChoice::GetString(int n) const { - wxCHECK_MSG( n >= 0 && (size_t)n < m_strings.GetCount(), _T(""), + wxCHECK_MSG( n >= 0 && (size_t)n < m_strings.GetCount(), wxEmptyString, _T("wxChoice::GetString(): invalid index") ); return m_strings[n] ;