Refactor and simplify wxChoice::DoGetBestSize().
Use wxTextMeasure instead of duplicating its code and also reuse the code between different ports. Closes #14706. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@72848 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -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
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user