- Rect bounds ;
- Str255 title ;
-
- MacPreControlCreate( parent , id , wxEmptyString , pos , size ,style, validator , name , &bounds , title ) ;
- m_macControl = ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , title , false , 0 , -12345 , 0 ,
- kControlPopupButtonProc + kControlPopupFixedWidthVariant , (long) this ) ;
-
- m_macPopUpMenuHandle = NewUniqueMenu() ;
- SetControlData( (ControlHandle) m_macControl , kControlNoPart , kControlPopupButtonMenuHandleTag , sizeof( MenuHandle ) , (char*) &m_macPopUpMenuHandle) ;
- SetControl32BitMinimum( (ControlHandle) m_macControl , 0 ) ;
- SetControl32BitMaximum( (ControlHandle) m_macControl , 0) ;
- if ( n > 0 )
- SetControl32BitValue( (ControlHandle) m_macControl , 1 ) ;
- MacPostControlCreate() ;
- // TODO wxCB_SORT
- for ( int i = 0; i < n; i++ )
- {
- Append(choices[i]);
- }
- return TRUE;
+ Append( choices );
+
+ if ( !choices.empty() )
+ SetSelection( 0 );
+
+ SetInitialSize( size );
+
+ return true;
+}
+
+bool wxChoice::Create(wxWindow *parent,
+ wxWindowID id,
+ const wxPoint& pos,
+ const wxSize& size,
+ int n,
+ const wxString choices[],
+ long style,
+ const wxValidator& validator,
+ const wxString& name )
+{
+ 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;