X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/4b26b60fac70f89cf33935f78469e27536d8b614..b77b87881bae2e6306366d79e7fe160334b3d4a2:/src/mac/carbon/choice.cpp diff --git a/src/mac/carbon/choice.cpp b/src/mac/carbon/choice.cpp index 86d75eb0da..55a9268e10 100644 --- a/src/mac/carbon/choice.cpp +++ b/src/mac/carbon/choice.cpp @@ -46,6 +46,9 @@ bool wxChoice::Create(wxWindow *parent, wxWindowID id, const wxValidator& validator, const wxString& name) { + if ( !wxChoiceBase::Create(parent, id, pos, size, style, validator, name) ) + return false; + Rect bounds ; Str255 title ; @@ -60,6 +63,7 @@ bool wxChoice::Create(wxWindow *parent, wxWindowID id, if ( n > 0 ) SetControl32BitValue( (ControlHandle) m_macControl , 1 ) ; MacPostControlCreate() ; + // TODO wxCB_SORT for ( int i = 0; i < n; i++ ) { Append(choices[i]); @@ -105,7 +109,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()) ; } @@ -177,8 +181,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 // ---------------------------------------------------------------------------- @@ -237,12 +245,11 @@ wxSize wxChoice::DoGetBestSize() const #endif { wxMacPortStateHelper st( UMAGetWindowPort( (WindowRef) MacGetRootWindow() ) ) ; - wxFontRefData * font = (wxFontRefData*) m_font.GetRefData() ; - if ( font ) + if ( m_font.Ok() ) { - ::TextFont( font->m_macFontNum ) ; - ::TextSize( short(font->m_macFontSize) ) ; - ::TextFace( font->m_macFontStyle ) ; + ::TextFont( m_font.GetMacFontNum() ) ; + ::TextSize( m_font.GetMacFontSize() ) ; + ::TextFace( m_font.GetMacFontStyle() ) ; } else { @@ -264,8 +271,7 @@ wxSize wxChoice::DoGetBestSize() const &baseline ); wLine = bounds.h ; #else - wxCharBuffer text = wxMacStringToCString( str ) ; - wLine = ::TextWidth( text , 0 , strlen(text) ) ; + wLine = ::TextWidth( str.c_str() , 0 , str.Length() ) ; #endif lbWidth = wxMax(lbWidth, wLine); }