Make wxWindow::HasScrollbar() respect wxScrolled::ShowScrollbars().
Override CanScroll() in wxScrolled to return the real state of the scrollbar instead of just relying on the wx[HV]SCROLL styles. Closes #15440. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@74714 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
3d777efedc
commit
029a401d74
@ -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);
|
||||
|
@ -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,
|
||||
|
@ -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:
|
||||
|
@ -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 \
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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))
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user