Add wxControl::GetSizeFromTextSize() to size the control to its text.

This function can be used to size a, say, wxTextCtrl to be exactly of the size
needed to enter the given amount of text in it.

This patch adds wxGTK implementation for wxTextCtrl, wxChoice and wxCombobox;
changes to the samples and the documentation.

Closes #14812.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@72935 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2012-11-09 21:11:37 +00:00
parent c017416682
commit 7a78a93782
15 changed files with 269 additions and 62 deletions

View File

@@ -404,4 +404,17 @@ void wxComboBox::Dismiss()
{
gtk_combo_box_popdown( GTK_COMBO_BOX(m_widget) );
}
wxSize wxComboBox::DoGetSizeFromTextSize(int xlen, int ylen) const
{
wxSize tsize( wxChoice::DoGetSizeFromTextSize(xlen, ylen) );
// Add the margins we have previously set, but only the horizontal border
// as vertical one has been taken account in the prevoius call.
// Also get other GTK+ margins.
tsize.IncBy( GTKGetEntryMargins(GetEntry()).x, 0);
return tsize;
}
#endif // wxUSE_COMBOBOX