X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/519cb848a8f4c91c73421bb75314754284e593a4..10992a81d39da31b79063387b7b71c0ff68737ce:/src/mac/choice.cpp diff --git a/src/mac/choice.cpp b/src/mac/choice.cpp index da3c4efc92..1c36eef12d 100644 --- a/src/mac/choice.cpp +++ b/src/mac/choice.cpp @@ -29,25 +29,28 @@ bool wxChoice::Create(wxWindow *parent, wxWindowID id, const wxValidator& validator, const wxString& name) { - m_noStrings = n; Rect bounds ; Str255 title ; MacPreControlCreate( parent , id , "" , pos , size ,style, validator , name , &bounds , title ) ; - - m_macControl = UMANewControl( parent->GetMacRootWindow() , &bounds , title , true , 0 , -12345 , 0, - kControlPopupButtonProc , (long) this ) ; + + m_macControl = UMANewControl( parent->GetMacRootWindow() , &bounds , title , true , 0 , -12345 , 0 , + kControlPopupButtonProc + kControlPopupFixedWidthVariant , (long) this ) ; m_macPopUpMenuHandle = NewMenu( 1 , "\pPopUp Menu" ) ; SetControlData( m_macControl , kControlNoPart , kControlPopupButtonMenuHandleTag , sizeof( MenuHandle ) , (char*) &m_macPopUpMenuHandle) ; for ( int i = 0 ; i < n ; i++ ) { - appendmenu( m_macPopUpMenuHandle , choices[i] ) ; + Str255 label; + wxMenuItem::MacBuildMenuString( label , NULL , NULL , choices[i] ,false); + AppendMenu( m_macPopUpMenuHandle , label ) ; + m_strings.Add( choices[i] ) ; } SetControlMinimum( m_macControl , 0 ) ; - SetControlMaximum( m_macControl , m_noStrings) ; - SetControlValue( m_macControl , 1 ) ; + SetControlMaximum( m_macControl , Number()) ; + if ( n > 0 ) + SetControlValue( m_macControl , 1 ) ; MacPostControlCreate() ; @@ -56,27 +59,28 @@ bool wxChoice::Create(wxWindow *parent, wxWindowID id, void wxChoice::Append(const wxString& item) { - appendmenu( m_macPopUpMenuHandle , item ) ; - m_noStrings ++; - SetControlMaximum( m_macControl , m_noStrings) ; + Str255 label; + wxMenuItem::MacBuildMenuString( label , NULL , NULL , item ,false); + AppendMenu( m_macPopUpMenuHandle , label ) ; + m_strings.Add( item ) ; + SetControlMaximum( m_macControl , Number()) ; } void wxChoice::Delete(int n) { - wxASSERT( n < m_noStrings ) ; ::DeleteMenuItem( m_macPopUpMenuHandle , n + 1) ; - m_noStrings --; - SetControlMaximum( m_macControl , m_noStrings) ; + m_strings.Remove( n ) ; + SetControlMaximum( m_macControl , Number()) ; } void wxChoice::Clear() { - for ( int i = 0 ; i < m_noStrings ; i++ ) + for ( int i = 0 ; i < Number() ; i++ ) { ::DeleteMenuItem( m_macPopUpMenuHandle , 1 ) ; } - m_noStrings = 0; - SetControlMaximum( m_macControl , m_noStrings) ; + m_strings.Clear() ; + SetControlMaximum( m_macControl , Number()) ; } int wxChoice::GetSelection() const @@ -89,9 +93,8 @@ void wxChoice::MacHandleControlClick( ControlHandle control , SInt16 controlpart wxCommandEvent event(wxEVT_COMMAND_CHOICE_SELECTED, m_windowId ); event.SetInt(GetSelection()); event.SetEventObject(this); - event.SetString(copystring(GetStringSelection())); + event.SetString(GetStringSelection()); ProcessCommand(event); - delete[] event.GetString(); } @@ -102,7 +105,7 @@ void wxChoice::SetSelection(int n) int wxChoice::FindString(const wxString& s) const { - for( int i = 0 ; i < m_noStrings ; i++ ) + for( int i = 0 ; i < Number() ; i++ ) { if ( GetString( i ) == s ) return i ; @@ -112,10 +115,7 @@ int wxChoice::FindString(const wxString& s) const wxString wxChoice::GetString(int n) const { - Str255 text ; - ::GetMenuItemText( m_macPopUpMenuHandle , n+1 , text ) ; - p2cstr( text ) ; - return wxString( text ); + return m_strings[n] ; } void wxChoice::SetSize(int x, int y, int width, int height, int sizeFlags)