]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/choiccmn.cpp
Fix documentation of wxGridBagSizer::Add() spacer overload.
[wxWidgets.git] / src / common / choiccmn.cpp
index 5dd372a3188a1402dfb4ac116ce497bba4029319..31b0a2df064cec038032bcae7160e6ff477ae004 100644 (file)
@@ -28,6 +28,8 @@
 
 #include "wx/choice.h"
 
+#include "wx/private/textmeasure.h"
+
 #ifndef WX_PRECOMP
 #endif
 
@@ -65,7 +67,7 @@ wxFLAGS_MEMBER(wxHSCROLL)
 
 wxEND_FLAGS( wxChoiceStyle )
 
-wxIMPLEMENT_DYNAMIC_CLASS_XTI(wxChoice, wxControlWithItems, "wx/choice.h")
+wxIMPLEMENT_DYNAMIC_CLASS_XTI(wxChoice, wxControl, "wx/choice.h")
 
 wxBEGIN_PROPERTIES_TABLE(wxChoice)
 wxEVENT_PROPERTY( Select, wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEvent )
@@ -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
 // ----------------------------------------------------------------------------