]> git.saurik.com Git - wxWidgets.git/commitdiff
Fix wxALWAYS_SHOW_SB behaviour in wxGTK.
authorVadim Zeitlin <vadim@wxwidgets.org>
Mon, 26 Nov 2012 13:14:39 +0000 (13:14 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Mon, 26 Nov 2012 13:14:39 +0000 (13:14 +0000)
Don't show the scrollbar always if it's not enabled at all, i.e. if the
corresponding wxHSCROLL or wxVSCROLL style is not specified.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@73022 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/gtk/window.cpp

index 3090800b74d9f1c38c72ca6b257556096a1e0cba..ca7409a761f2bb48fca3721e2184c8b293c31034 100644 (file)
@@ -2270,14 +2270,20 @@ void wxWindowGTK::GTKCreateScrolledWindowWith(GtkWidget* view)
         }
     }
 
-    if (HasFlag(wxALWAYS_SHOW_SB))
-    {
-        gtk_scrolled_window_set_policy( scrolledWindow, GTK_POLICY_ALWAYS, GTK_POLICY_ALWAYS );
-    }
-    else
-    {
-        gtk_scrolled_window_set_policy( scrolledWindow, GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC );
-    }
+    // If wx[HV]SCROLL is not given, the corresponding scrollbar is not shown
+    // at all. Otherwise it may be shown only on demand (default) or always, if
+    // the wxALWAYS_SHOW_SB is specified.
+    GtkPolicyType horzPolicy = HasFlag(wxHSCROLL)
+                                ? HasFlag(wxALWAYS_SHOW_SB)
+                                    ? GTK_POLICY_ALWAYS
+                                    : GTK_POLICY_AUTOMATIC
+                                : GTK_POLICY_NEVER;
+    GtkPolicyType vertPolicy = HasFlag(wxVSCROLL)
+                                ? HasFlag(wxALWAYS_SHOW_SB)
+                                    ? GTK_POLICY_ALWAYS
+                                    : GTK_POLICY_AUTOMATIC
+                                : GTK_POLICY_NEVER;
+    gtk_scrolled_window_set_policy( scrolledWindow, horzPolicy, vertPolicy );
 
     m_scrollBar[ScrollDir_Horz] = GTK_RANGE(gtk_scrolled_window_get_hscrollbar(scrolledWindow));
     m_scrollBar[ScrollDir_Vert] = GTK_RANGE(gtk_scrolled_window_get_vscrollbar(scrolledWindow));