]> git.saurik.com Git - wxWidgets.git/blobdiff - src/mac/choice.cpp
made wxFFile a bit more safe: don't crash when Tell() and Length() are called on...
[wxWidgets.git] / src / mac / choice.cpp
index c130d3798aa099eb4a68f8d16755fe6194fcd73b..a18113dbf37d7c3651c8e431ac2aab0abc1af36d 100644 (file)
@@ -38,6 +38,20 @@ wxChoice::~wxChoice()
     // DisposeMenu( m_macPopUpMenuHandle ) ;
 }
 
+bool wxChoice::Create(wxWindow *parent, wxWindowID id,
+           const wxPoint& pos,
+           const wxSize& size,
+           const wxArrayString& choices,
+           long style,
+           const wxValidator& validator,
+           const wxString& name)
+{
+    wxCArrayString chs(choices);
+
+    return Create(parent, id, pos, size, chs.GetCount(), chs.GetStrings(),
+                  style, validator, name);
+}
+
 bool wxChoice::Create(wxWindow *parent, wxWindowID id,
            const wxPoint& pos,
            const wxSize& size,
@@ -245,12 +259,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
         {
@@ -272,8 +285,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);
         }