- wxCHECK_MSG(!(GetWindowStyle() & wxCB_SORT), -1, wxT("can't insert into sorted list"));
- wxCHECK_MSG((pos>=0) && (pos<=GetCount()), -1, wxT("invalid index"));
-
- if (pos == GetCount())
- return DoAppend(item);
-
- UMAAppendMenuItem(MAC_WXHMENU( m_macPopUpMenuHandle ) , item, m_font.GetEncoding() );
- m_strings.Insert( item, pos ) ;
- m_datas.Insert( NULL, pos ) ;
- DoSetItemClientData( pos , NULL ) ;
- SetControl32BitMaximum( (ControlRef) m_macControl , pos) ;
- return pos ;
+ const unsigned int numItems = items.GetCount();
+ for( unsigned int i = 0; i < numItems; ++i, ++pos )
+ {
+ unsigned int idx;
+
+#if wxUSE_STL
+ if ( IsSorted() )
+ {
+ wxArrayString::iterator
+ insertPoint = std::lower_bound( m_strings.begin(), m_strings.end(), items[i] );
+ idx = insertPoint - m_strings.begin();
+ m_strings.insert( insertPoint, items[i] );
+ }
+ else
+#endif // wxUSE_STL
+ {
+ idx = pos;
+ m_strings.Insert( items[i], idx );
+ }
+
+ UMAInsertMenuItem(MAC_WXHMENU( m_macPopUpMenuHandle ),
+ items[i],
+ m_font.GetEncoding(),
+ idx);
+ m_datas.Insert( NULL, idx );
+ AssignNewItemClientData(idx, clientData, i, type);
+ }
+
+ m_peer->SetMaximum( GetCount() );
+
+ return pos - 1;