X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/243dbf1a5088be31980df51b97831b52cb6986cd..2943b2c6af7be72c9eddf7dbf6d5abce5ad18c07:/src/mac/carbon/choice.cpp diff --git a/src/mac/carbon/choice.cpp b/src/mac/carbon/choice.cpp index bc77b99ad8..c187d9ecc7 100644 --- a/src/mac/carbon/choice.cpp +++ b/src/mac/carbon/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,12 +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() ) ) ; - Rect drawRect ; + wxMacPortStateHelper st( UMAGetWindowPort( (WindowRef) MacGetRootWindow() ) ) ; wxFontRefData * font = (wxFontRefData*) m_font.GetRefData() ; if ( font ) { @@ -273,10 +276,9 @@ wxSize wxChoice::DoGetBestSize() const // Add room for the popup arrow lbWidth += 2 * lbHeight ; // And just a bit more - int cy = 12 ; int cx = ::TextWidth( "X" , 0 , 1 ) ; lbWidth += cx ; - + } return wxSize(lbWidth, lbHeight); }