X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/37788684ba0dfe52d3b4f67e5c2dae521893bfff..95316a3f245a4baf3046e97222660bed986153ed:/src/common/choiccmn.cpp diff --git a/src/common/choiccmn.cpp b/src/common/choiccmn.cpp index dc925335a2..31b0a2df06 100644 --- a/src/common/choiccmn.cpp +++ b/src/common/choiccmn.cpp @@ -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 // ----------------------------------------------------------------------------