Made wxWindow::HasScrollbar() do what it says.

Added wxWindow::CanScroll() with the old HasScrollbar() meaning but changed
HasScrollbar() to check for the scrollbar existence instead of just checking
if it might exist.

Closes #10897.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@61634 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2009-08-10 11:18:09 +00:00
parent 4cd4a9ff70
commit c5cc7fbd27
4 changed files with 40 additions and 5 deletions

View File

@@ -391,6 +391,8 @@ All (GUI):
- Added EVT_DATAVIEW_CACHE_HINT() event (Trigve).
- Added wxLB_NO_SB style (implemented for MSW only; Dario Senic).
- Added long version field to wxAboutDialogInfo (Jeff Tupper).
- Added wxWindow::CanScroll() behaving like the old HasScrollbar() and made
HasScrollbar() really check for the scrollbar existence.
GTK:

View File

@@ -1160,13 +1160,16 @@ public:
// scrollbars
// ----------
// does the window have the scrollbar for this orientation?
bool HasScrollbar(int orient) const
// can the window have the scrollbar in this orientation?
bool CanScroll(int orient) const
{
return (m_windowStyle &
(orient == wxHORIZONTAL ? wxHSCROLL : wxVSCROLL)) != 0;
}
// does the window have the scrollbar in this orientation?
bool HasScrollbar(int orient) const;
// configure the window scrollbars
virtual void SetScrollbar( int orient,
int pos,

View File

@@ -513,7 +513,23 @@ public:
virtual int GetScrollThumb(int orientation) const;
/**
Returns @true if this window has a scroll bar for this orientation.
Returns @true if this window can have a scroll bar in this orientation.
@param orient
Orientation to check, either wxHORIZONTAL or wxVERTICAL.
@since 2.9.1
*/
bool CanScroll(int orient) const;
/**
Returns @true if this window currently has a scroll bar for this
orientation.
This method may return @false even when CanScroll() for the same
orientation returns @true, but if CanScroll() returns @false, i.e.
scrolling in this direction is not enabled at all, HasScrollbar()
always returns @false as well.
@param orient
Orientation to check, either wxHORIZONTAL or wxVERTICAL.

View File

@@ -896,6 +896,20 @@ void wxWindowBase::SendSizeEventToParent(int flags)
parent->SendSizeEvent(flags);
}
bool wxWindowBase::HasScrollbar(int orient) const
{
// if scrolling in the given direction is disabled, we can't have the
// corresponding scrollbar no matter what
if ( !CanScroll(orient) )
return false;
const wxSize sizeVirt = GetVirtualSize();
const wxSize sizeClient = GetClientSize();
return orient == wxHORIZONTAL ? sizeVirt.x > sizeClient.x
: sizeVirt.y > sizeClient.y;
}
// ----------------------------------------------------------------------------
// show/hide/enable/disable the window
// ----------------------------------------------------------------------------