+ m_macIsUserPane = false;
+
+ if ( !wxChoiceBase::Create( parent, id, pos, size, style, validator, name ) )
+ return false;
+
+ Rect bounds = wxMacGetBoundsForControl( this , pos , size );
+
+ m_peer = new wxMacControl( this ) ;
+ OSStatus err = CreatePopupButtonControl(
+ MAC_WXHWND(parent->MacGetTopLevelWindowRef()) , &bounds , CFSTR("") ,
+ -12345 , false /* no variable width */ , 0 , 0 , 0 , m_peer->GetControlRefAddr() );
+ verify_noerr( err );
+
+ m_macPopUpMenuHandle = NewUniqueMenu() ;
+ m_peer->SetData<MenuHandle>( kControlNoPart , kControlPopupButtonMenuHandleTag , (MenuHandle) m_macPopUpMenuHandle ) ;
+ m_peer->SetValueAndRange( n > 0 ? 1 : 0 , 0 , 0 );
+ MacPostControlCreate( pos, size );
+
+#if !wxUSE_STL
+ if ( style & wxCB_SORT )
+ // autosort
+ m_strings = wxArrayString( 1 );
+#endif
+
+ Append(n, choices);
+
+ // Set the first item as being selected
+ if (n > 0)
+ SetSelection( 0 );
+
+ // Needed because it is a wxControlWithItems
+ SetInitialSize( size );
+
+ return true;
+}
+
+// ----------------------------------------------------------------------------
+// adding/deleting items to/from the list
+// ----------------------------------------------------------------------------
+
+int wxChoice::DoInsertItems(const wxArrayStringsAdapter & items,
+ unsigned int pos,
+ void **clientData, wxClientDataType type)
+{
+ 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],
+ GetFont().GetEncoding(),
+ idx);
+ m_datas.Insert( NULL, idx );
+ AssignNewItemClientData(idx, clientData, i, type);
+ }
+
+ m_peer->SetMaximum( GetCount() );
+
+ return pos - 1;