X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/5be55d562f584025d966980f5fc4272db60c6eae..28b4db7f890258e83fa0a57ea85c72585e48b756:/src/mac/choice.cpp diff --git a/src/mac/choice.cpp b/src/mac/choice.cpp index 9f7d40175e..c187d9ecc7 100644 --- a/src/mac/choice.cpp +++ b/src/mac/choice.cpp @@ -48,11 +48,11 @@ bool wxChoice::Create(wxWindow *parent, wxWindowID id, { 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_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 ) ; @@ -105,7 +105,7 @@ void wxChoice::Delete(int n) delete GetClientObject(n); } ::DeleteMenuItem( MAC_WXHMENU(m_macPopUpMenuHandle) , n + 1) ; - m_strings.Remove( n ) ; + m_strings.RemoveAt( n ) ; m_datas.RemoveAt( n ) ; SetControl32BitMaximum( (ControlHandle) m_macControl , GetCount()) ; } @@ -161,7 +161,7 @@ int wxChoice::FindString(const wxString& s) const for( int i = 0 ; i < GetCount() ; i++ ) { if ( GetString( i ).IsSameAs(s, FALSE) ) - return i ; + return i ; } return wxNOT_FOUND ; } @@ -177,8 +177,12 @@ void wxChoice::SetString(int n, const wxString& s) wxString wxChoice::GetString(int n) const { + wxCHECK_MSG( n >= 0 && (size_t)n < m_strings.GetCount(), _T(""), + _T("wxChoice::GetString(): invalid index") ); + return m_strings[n] ; } + // ---------------------------------------------------------------------------- // client data // ---------------------------------------------------------------------------- @@ -186,7 +190,7 @@ void wxChoice::DoSetItemClientData( int n, void* clientData ) { wxCHECK_RET( n >= 0 && (size_t)n < m_datas.GetCount(), wxT("invalid index in wxChoice::SetClientData") ); - + m_datas[n] = (char*) clientData ; } @@ -207,7 +211,7 @@ wxClientData* wxChoice::DoGetItemClientObject( int n ) const return (wxClientData *)DoGetItemClientData(n); } -void wxChoice::MacHandleControlClick( WXWidget control , wxInt16 controlpart ) +void wxChoice::MacHandleControlClick( WXWidget control , wxInt16 controlpart , bool WXUNUSED(mouseStillDown)) { wxCommandEvent event(wxEVT_COMMAND_CHOICE_SELECTED, m_windowId ); int n = GetSelection(); @@ -232,11 +236,11 @@ wxSize wxChoice::DoGetBestSize() const int wLine; #if TARGET_CARBON long metric ; - GetThemeMetric(kThemeMetricPopupButtonHeight , &metric ); - lbHeight = metric ; + GetThemeMetric(kThemeMetricPopupButtonHeight , &metric ); + lbHeight = metric ; #endif { - wxMacPortStateHelper st( UMAGetWindowPort( (WindowRef) MacGetRootWindow() ) ) ; + wxMacPortStateHelper st( UMAGetWindowPort( (WindowRef) MacGetRootWindow() ) ) ; wxFontRefData * font = (wxFontRefData*) m_font.GetRefData() ; if ( font ) { @@ -274,7 +278,7 @@ wxSize wxChoice::DoGetBestSize() const // And just a bit more int cx = ::TextWidth( "X" , 0 , 1 ) ; lbWidth += cx ; - + } return wxSize(lbWidth, lbHeight); }