- UMAAppendMenuItem(MAC_WXHMENU( m_macPopUpMenuHandle ) , item);
- m_strings.Add( item ) ;
- m_datas.Add( NULL ) ;
- int index = m_strings.GetCount() - 1 ;
+#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 );