X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/3b3dc8019a520ce5e166c8ae9098ba020f8b3f94..ba98e032a7d195fc94d3856bcd8f4cf4b4b01b4c:/src/mac/carbon/choice.cpp diff --git a/src/mac/carbon/choice.cpp b/src/mac/carbon/choice.cpp index d4268c6e97..b0ba01d97d 100644 --- a/src/mac/carbon/choice.cpp +++ b/src/mac/carbon/choice.cpp @@ -17,6 +17,7 @@ #ifndef WX_PRECOMP #include "wx/menu.h" + #include "wx/dcclient.h" #endif #include "wx/mac/uma.h" @@ -100,7 +101,7 @@ bool wxChoice::Create(wxWindow *parent, SetSelection( 0 ); // Needed because it is a wxControlWithItems - SetBestSize( size ); + SetInitialSize( size ); return true; } @@ -217,6 +218,12 @@ unsigned int wxChoice::GetCount() const int wxChoice::FindString( const wxString& s, bool bCase ) const { +#if !wxUSE_STL + // Avoid assert for non-default args passed to sorted array Index + if ( HasFlag(wxCB_SORT) ) + bCase = true; +#endif + return m_strings.Index( s , bCase ) ; } @@ -294,13 +301,16 @@ wxSize wxChoice::DoGetBestSize() const int wLine; #if TARGET_CARBON - long metric ; + SInt32 metric ; GetThemeMetric( kThemeMetricPopupButtonHeight , &metric ); lbHeight = metric ; #endif { +#if wxMAC_USE_CORE_GRAPHICS + wxClientDC dc(const_cast(this)); +#else wxMacPortStateHelper st( UMAGetWindowPort( (WindowRef) MacGetTopLevelWindowRef() ) ) ; if ( m_font.Ok() ) { @@ -314,12 +324,16 @@ wxSize wxChoice::DoGetBestSize() const ::TextSize( 9 ) ; ::TextFace( 0 ) ; } - +#endif // Find the widest line for(unsigned int i = 0; i < GetCount(); i++) { wxString str(GetString(i)); - +#if wxMAC_USE_CORE_GRAPHICS + wxCoord width, height ; + dc.GetTextExtent( str , &width, &height); + wLine = width ; +#else #if wxUSE_UNICODE Point bounds = { 0, 0 } ; SInt16 baseline ; @@ -335,15 +349,21 @@ wxSize wxChoice::DoGetBestSize() const #else wLine = ::TextWidth( str.c_str() , 0 , str.length() ) ; #endif - +#endif lbWidth = wxMax( lbWidth, wLine ) ; } // Add room for the popup arrow lbWidth += 2 * lbHeight ; - +#if wxMAC_USE_CORE_GRAPHICS + wxCoord width, height ; + dc.GetTextExtent( wxT("X"), &width, &height); + int cx = width ; + lbHeight += 4; +#else // And just a bit more int cx = ::TextWidth( "X" , 0 , 1 ) ; +#endif lbWidth += cx ; }