]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/choiccmn.cpp
Move menu messages handling from wxFrame to wxTLW in wxMSW.
[wxWidgets.git] / src / common / choiccmn.cpp
index dc925335a268a8e1c4fafc11e8bbe466b19c0679..31b0a2df064cec038032bcae7160e6ff477ae004 100644 (file)
@@ -28,6 +28,8 @@
 
 #include "wx/choice.h"
 
+#include "wx/private/textmeasure.h"
+
 #ifndef WX_PRECOMP
 #endif
 
@@ -103,6 +105,21 @@ wxChoiceBase::~wxChoiceBase()
     // this destructor is required for Darwin
 }
 
+wxSize wxChoiceBase::DoGetBestSize() const
+{
+    // a reasonable width for an empty choice list
+    wxSize best(80, -1);
+
+    const unsigned int nItems = GetCount();
+    if ( nItems > 0 )
+    {
+        wxTextMeasure txm(this);
+        best.x = txm.GetLargestStringExtent(GetStrings()).x;
+    }
+
+    return best;
+}
+
 // ----------------------------------------------------------------------------
 // misc
 // ----------------------------------------------------------------------------