X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/850ff4855026066770d80c376ee6fc864169509c..1d5c2a8eb521f99044a04ee5aa7be4a5619cb918:/src/gtk1/choice.cpp diff --git a/src/gtk1/choice.cpp b/src/gtk1/choice.cpp index d794e2a915..ca9d9c1785 100644 --- a/src/gtk1/choice.cpp +++ b/src/gtk1/choice.cpp @@ -12,10 +12,12 @@ #pragma implementation "choice.h" #endif -#include "wx/choice.h" +#include "wx/defs.h" #if wxUSE_CHOICE +#include "wx/choice.h" + #include #include @@ -405,7 +407,31 @@ size_t wxChoice::GtkAppendHelper(GtkWidget *menu, const wxString& item) wxSize wxChoice::DoGetBestSize() const { wxSize ret( wxControl::DoGetBestSize() ); - if (ret.x < 80) ret.x = 80; + + // we know better our horizontal extent: it depends on the longest string + // we have + ret.x = 0; + if ( m_widget ) + { + GdkFont *font = m_font.GetInternalFont(); + + wxCoord width; + size_t count = GetCount(); + for ( size_t n = 0; n < count; n++ ) + { + width = (wxCoord)gdk_string_width(font, GetString(n).mbc_str()); + if ( width > ret.x ) + ret.x = width; + } + + // for the choice "=" button + ret.x += 20; + } + + // but not less than the minimal width + if ( ret.x < 80 ) + ret.x = 80; + ret.y = 16 + gdk_char_height( m_widget->style->font, 'H' ); return ret; }