Don't include scrollbars in client area size

Return the size of just the viewport when using QScrollArea.

Closes https://github.com/wxWidgets/wxWidgets/pull/1418
This commit is contained in:
Graham Dawes
2019-07-15 16:34:49 +01:00
committed by Vadim Zeitlin
parent 18b87b2ab5
commit cd7594e639
2 changed files with 25 additions and 2 deletions

View File

@@ -582,6 +582,23 @@ void wxWindowQt::DoGetTextExtent(const wxString& string, int *x, int *y, int *de
*externalLeading = fontMetrics.lineSpacing();
}
QWidget *wxWindowQt::QtGetClientWidget() const
{
QWidget *qtWidget = NULL;
if ( m_qtContainer != NULL )
{
qtWidget = m_qtContainer->viewport();
}
if ( qtWidget == NULL )
{
// We don't have scrollbars or the QScrollArea has no children
qtWidget = GetHandle();
}
return qtWidget;
}
/* Returns a scrollbar for the given orientation, or NULL if the scrollbar
* has not been previously created and create is false */
QScrollBar *wxWindowQt::QtGetScrollBar( int orientation ) const
@@ -957,7 +974,8 @@ void wxWindowQt::DoSetSize(int x, int y, int width, int height, int sizeFlags )
void wxWindowQt::DoGetClientSize(int *width, int *height) const
{
QRect geometry = GetHandle()->geometry();
QWidget *qtWidget = QtGetClientWidget();
const QRect geometry = qtWidget->geometry();
if (width) *width = geometry.width();
if (height) *height = geometry.height();
}
@@ -965,7 +983,7 @@ void wxWindowQt::DoGetClientSize(int *width, int *height) const
void wxWindowQt::DoSetClientSize(int width, int height)
{
QWidget *qtWidget = GetHandle();
QWidget *qtWidget = QtGetClientWidget();
QRect geometry = qtWidget->geometry();
geometry.setWidth( width );
geometry.setHeight( height );