]> git.saurik.com Git - wxWidgets.git/commitdiff
Fix wxChoice on Mac whith STL when using wxCB_SORT.
authorMattia Barbon <mbarbon@cpan.org>
Sun, 24 Apr 2005 15:28:18 +0000 (15:28 +0000)
committerMattia Barbon <mbarbon@cpan.org>
Sun, 24 Apr 2005 15:28:18 +0000 (15:28 +0000)
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

src/mac/carbon/choice.cpp

index b173ac7d558ccae6ce267bef6cd66c5e457b0ddb..6d42fc9d8d7182e1f0d3f6bb6988d8b770e50f05 100644 (file)
@@ -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