Improve our best size calculation for multi-line wxTextCtrl with GTK
Instead of trying to figure it out ourselves, just ask the control what its minimum size is.
This commit is contained in:
parent
e21b27019f
commit
31a672b858
1 changed files with 3 additions and 14 deletions
|
|
@ -2153,24 +2153,13 @@ wxSize wxTextCtrl::DoGetSizeFromTextSize(int xlen, int ylen) const
|
|||
//multiline
|
||||
else
|
||||
{
|
||||
// add space for vertical scrollbar
|
||||
if ( m_scrollBar[1] && !(m_windowStyle & wxTE_NO_VSCROLL) )
|
||||
tsize.IncBy(GTKGetPreferredSize(GTK_WIDGET(m_scrollBar[1])).x + 3, 0);
|
||||
|
||||
// height
|
||||
if ( ylen <= 0 )
|
||||
{
|
||||
tsize.y = 1 + cHeight * wxMax(wxMin(GetNumberOfLines(), 10), 2);
|
||||
// add space for horizontal scrollbar
|
||||
if ( m_scrollBar[0] && (m_windowStyle & wxHSCROLL) )
|
||||
tsize.IncBy(0, GTKGetPreferredSize(GTK_WIDGET(m_scrollBar[0])).y + 3);
|
||||
}
|
||||
|
||||
if ( !HasFlag(wxBORDER_NONE) )
|
||||
{
|
||||
// hardcode borders, margins, etc
|
||||
tsize.IncBy(5, 4);
|
||||
}
|
||||
GtkRequisition req;
|
||||
gtk_widget_get_preferred_size(m_widget, &req, nullptr);
|
||||
tsize.IncTo(wxSize(req.width, req.height));
|
||||
}
|
||||
|
||||
// We should always use at least the specified height if it's valid.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue