X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/5b781a6729859abc77e6ca5b1f81cbaad974a78f..947ea04d016852aa293291069d5c91ce4c6dde60:/src/mac/carbon/choice.cpp diff --git a/src/mac/carbon/choice.cpp b/src/mac/carbon/choice.cpp index 2b1cf2daae..bac3579f34 100644 --- a/src/mac/carbon/choice.cpp +++ b/src/mac/carbon/choice.cpp @@ -15,6 +15,7 @@ // For compilers that support precompilation, includes "wx.h". #include "wx/choice.h" +#include "wx/menu.h" #include "wx/mac/uma.h" #if !USE_SHARED_LIBRARY @@ -29,11 +30,19 @@ wxChoice::~wxChoice() DisposeMenu( m_macPopUpMenuHandle ) ; } +int wxChoice::GetCount() const { + return m_strings.Count() ; +} + +void wxChoice::SetString( int n , const wxString& s ) { + m_strings[n] = s ; +} + bool wxChoice::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size, - int n, const wxString choices[], - long style, + int n, const wxString choices[], + long style, const wxValidator& validator, const wxString& name) { @@ -55,6 +64,7 @@ bool wxChoice::Create(wxWindow *parent, wxWindowID id, wxMenuItem::MacBuildMenuString( label , NULL , NULL , choices[i] ,false); AppendMenu( m_macPopUpMenuHandle , label ) ; m_strings.Add( choices[i] ) ; + m_dataArray.Add( NULL ); } SetControlMinimum( m_macControl , 0 ) ; SetControlMaximum( m_macControl , Number()) ; @@ -66,19 +76,50 @@ bool wxChoice::Create(wxWindow *parent, wxWindowID id, return TRUE; } -void wxChoice::Append(const wxString& item) +int wxChoice::DoAppend(const wxString& item) { Str255 label; wxMenuItem::MacBuildMenuString( label , NULL , NULL , item ,false); AppendMenu( m_macPopUpMenuHandle , label ) ; m_strings.Add( item ) ; - SetControlMaximum( m_macControl , Number()) ; + m_dataArray.Add( NULL ); + return m_strings.Count() ; +} + +void *wxChoice::DoGetItemClientData(int N) const +{ + return (void *)m_dataArray[N]; +} + +void wxChoice::DoSetItemClientData( int N, void* Client_data ) +{ + wxASSERT_MSG( m_dataArray.GetCount() >= N , "invalid client_data array" ) ; + + if ( m_dataArray.GetCount() > N ) + { + m_dataArray[N] = (char*) Client_data ; + } + else + { + m_dataArray.Add( (char*) Client_data ) ; + } +} + +void wxChoice::DoSetItemClientObject( int n, wxClientData* clientData ) +{ + DoSetItemClientData(n, clientData); +} + +wxClientData* wxChoice::DoGetItemClientObject( int N ) const +{ + return (wxClientData *) DoGetItemClientData( N ) ; } void wxChoice::Delete(int n) { ::DeleteMenuItem( m_macPopUpMenuHandle , n + 1) ; m_strings.Remove( n ) ; + m_dataArray.Remove( n ) ; SetControlMaximum( m_macControl , Number()) ; } @@ -89,6 +130,7 @@ void wxChoice::Clear() ::DeleteMenuItem( m_macPopUpMenuHandle , 1 ) ; } m_strings.Clear() ; + m_dataArray.Empty() ; SetControlMaximum( m_macControl , Number()) ; } @@ -127,35 +169,8 @@ wxString wxChoice::GetString(int n) const return m_strings[n] ; } -void wxChoice::SetSize(int x, int y, int width, int height, int sizeFlags) +void wxChoice::DoSetSize(int x, int y, int width, int height, int sizeFlags) { wxControl::SetSize( x,y,width,height,sizeFlags ) ; } -wxString wxChoice::GetStringSelection () const -{ - int sel = GetSelection (); - if (sel > -1) - return wxString(this->GetString (sel)); - else - return wxString(""); -} - -bool wxChoice::SetStringSelection (const wxString& s) -{ - int sel = FindString (s); - if (sel > -1) - { - SetSelection (sel); - return TRUE; - } - else - return FALSE; -} - -void wxChoice::Command(wxCommandEvent & event) -{ - SetSelection (event.GetInt()); - ProcessCommand (event); -} -