From fcdd53359135f790b85728c4254b97095a56dad8 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Wed, 24 Dec 2008 23:46:13 +0000 Subject: [PATCH] handle correctly never/always shown scrollbars in GetClientSize() git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@57536 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/gtk/window.cpp | 40 +++++++++++++++++++++++++++++++++------- 1 file changed, 33 insertions(+), 7 deletions(-) diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp index fd3a7b09f2..3de7239792 100644 --- a/src/gtk/window.cpp +++ b/src/gtk/window.cpp @@ -2584,17 +2584,43 @@ void wxWindowGTK::DoGetClientSize( int *width, int *height ) const int w = m_width; int h = m_height; - if (m_wxwindow) + if ( m_wxwindow ) { // if window is scrollable, account for scrollbars - for (int i = 0; i < 2 && m_scrollBar[i]; i++) + if ( GTK_IS_SCROLLED_WINDOW(m_widget) ) { - GtkRequisition req; - GtkAdjustment* adj = gtk_range_get_adjustment(m_scrollBar[i]); - // if scrollbar enabled - if (adj->upper > adj->page_size) + GtkPolicyType policy[ScrollDir_Max]; + gtk_scrolled_window_get_policy(GTK_SCROLLED_WINDOW(m_widget), + &policy[ScrollDir_Horz], + &policy[ScrollDir_Vert]); + + for ( int i = 0; i < ScrollDir_Max; i++ ) { - gtk_widget_size_request(GTK_WIDGET(m_scrollBar[i]), &req); + // don't account for the scrollbars we don't have + GtkRange * const range = m_scrollBar[i]; + if ( !range ) + continue; + + // nor for the ones we have but don't current show + switch ( policy[i] ) + { + case GTK_POLICY_NEVER: + // never shown so doesn't take any place + continue; + + case GTK_POLICY_ALWAYS: + // no checks necessary + break; + + case GTK_POLICY_AUTOMATIC: + // may be shown or not, check + GtkAdjustment *adj = gtk_range_get_adjustment(range); + if ( adj->upper <= adj->page_size ) + continue; + } + + GtkRequisition req; + gtk_widget_size_request(GTK_WIDGET(range), &req); if (i == ScrollDir_Horz) h -= req.height; else