diff --git a/include/wx/generic/scrolwin.h b/include/wx/generic/scrolwin.h index ca51c09146..863cdf923e 100644 --- a/include/wx/generic/scrolwin.h +++ b/include/wx/generic/scrolwin.h @@ -21,6 +21,7 @@ public: // implement base class pure virtuals virtual void AdjustScrollbars(); + virtual bool IsScrollbarShown(int orient) const; protected: virtual void DoScroll(int x, int y); diff --git a/include/wx/gtk/scrolwin.h b/include/wx/gtk/scrolwin.h index c2fcbfd411..c36040ce88 100644 --- a/include/wx/gtk/scrolwin.h +++ b/include/wx/gtk/scrolwin.h @@ -29,6 +29,8 @@ public: bool noRefresh = false); virtual void AdjustScrollbars(); + virtual bool IsScrollbarShown(int orient) const; + protected: virtual void DoScroll(int x, int y); virtual void DoShowScrollbars(wxScrollbarVisibility horz, diff --git a/include/wx/gtk1/scrolwin.h b/include/wx/gtk1/scrolwin.h index d64333e41e..28fe92640f 100644 --- a/include/wx/gtk1/scrolwin.h +++ b/include/wx/gtk1/scrolwin.h @@ -25,6 +25,7 @@ public: int noUnitsX, int noUnitsY, int xPos = 0, int yPos = 0, bool noRefresh = false); + virtual bool IsScrollbarShown(int orient) const; virtual void AdjustScrollbars(); protected: diff --git a/include/wx/scrolwin.h b/include/wx/scrolwin.h index 637d63b320..9c3f1eebbf 100644 --- a/include/wx/scrolwin.h +++ b/include/wx/scrolwin.h @@ -100,6 +100,9 @@ public: DoShowScrollbars(horz, vert); } + // Test whether the specified scrollbar is shown. + virtual bool IsScrollbarShown(int orient) const = 0; + // Enable/disable Windows scrolling in either direction. If true, wxWidgets // scrolls the canvas and only a bit of the canvas is invalidated; no // Clear() is necessary. If false, the whole canvas is invalidated and a @@ -315,6 +318,8 @@ protected: public: \ virtual void PrepareDC(wxDC& dc) { DoPrepareDC(dc); } \ virtual bool Layout() { return ScrollLayout(); } \ + virtual bool CanScroll(int orient) const \ + { return IsScrollbarShown(orient); } \ virtual void DoSetVirtualSize(int x, int y) \ { ScrollDoSetVirtualSize(x, y); } \ virtual wxSize GetBestVirtualSize() const \ diff --git a/src/generic/scrlwing.cpp b/src/generic/scrlwing.cpp index ed7d288d7e..ee49a9c6a1 100644 --- a/src/generic/scrlwing.cpp +++ b/src/generic/scrlwing.cpp @@ -1201,6 +1201,14 @@ wxScrollHelper::wxScrollHelper(wxWindow *winToScroll) m_yVisibility = wxSHOW_SB_DEFAULT; } +bool wxScrollHelper::IsScrollbarShown(int orient) const +{ + wxScrollbarVisibility visibility = orient == wxHORIZONTAL ? m_xVisibility + : m_yVisibility; + + return visibility != wxSHOW_SB_NEVER; +} + void wxScrollHelper::DoShowScrollbars(wxScrollbarVisibility horz, wxScrollbarVisibility vert) { diff --git a/src/gtk/scrolwin.cpp b/src/gtk/scrolwin.cpp index 37cf570e13..9b39077a3d 100644 --- a/src/gtk/scrolwin.cpp +++ b/src/gtk/scrolwin.cpp @@ -181,6 +181,23 @@ GtkPolicyType GtkPolicyFromWX(wxScrollbarVisibility visibility) } // anonymous namespace +bool wxScrollHelper::IsScrollbarShown(int orient) const +{ + GtkScrolledWindow * const scrolled = GTK_SCROLLED_WINDOW(m_win->m_widget); + if ( !scrolled ) + { + // By default, all windows are scrollable. + return true; + } + + GtkPolicyType hpolicy, vpolicy; + gtk_scrolled_window_get_policy(scrolled, &hpolicy, &vpolicy); + + GtkPolicyType policy = orient == wxHORIZONTAL ? hpolicy : vpolicy; + + return policy != GTK_POLICY_NEVER; +} + void wxScrollHelper::DoShowScrollbars(wxScrollbarVisibility horz, wxScrollbarVisibility vert) { diff --git a/src/gtk1/scrolwin.cpp b/src/gtk1/scrolwin.cpp index 2c2179cf78..4d4586697a 100644 --- a/src/gtk1/scrolwin.cpp +++ b/src/gtk1/scrolwin.cpp @@ -178,6 +178,11 @@ void wxScrollHelper::DoScroll( int x_pos, int y_pos ) &m_yScrollPosition); } +bool wxScrollHelper::IsScrollbarShown(int WXUNUSED(orient)) const +{ + return true; +} + void wxScrollHelper::DoShowScrollbars(wxScrollbarVisibility WXUNUSED(horz), wxScrollbarVisibility WXUNUSED(vert)) {