Reapplied patch to change the two scrolled window implementations
to no longer clip the last bits as a rounding error. I had to change GetVirtualSize() as per my mail to devs. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@31976 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -1112,18 +1112,6 @@ method:\par
|
|||||||
}}
|
}}
|
||||||
|
|
||||||
|
|
||||||
\membersection{wxWindow::GetPureVirtualSize}\label{wxwindowgetpurevirtualsize}
|
|
||||||
|
|
||||||
\constfunc{wxSize}{GetPureVirtualSize}{\void}
|
|
||||||
|
|
||||||
This gets the virtual size of the window in pixels as it has been set
|
|
||||||
by \helpref{SetVirtualSize}{wxwindowsetvirtualsize}.
|
|
||||||
|
|
||||||
\helpref{GetSize}{wxwindowgetsize},\rtfsp
|
|
||||||
\helpref{GetClientSize}{wxwindowgetclientsize},\rtfsp
|
|
||||||
\helpref{GetVirtualSize}{wxwindowgetvirtualsize}
|
|
||||||
|
|
||||||
|
|
||||||
\membersection{wxWindow::GetRect}\label{wxwindowgetrect}
|
\membersection{wxWindow::GetRect}\label{wxwindowgetrect}
|
||||||
|
|
||||||
\constfunc{virtual wxRect}{GetRect}{\void}
|
\constfunc{virtual wxRect}{GetRect}{\void}
|
||||||
@@ -1293,11 +1281,10 @@ Returns a pointer to the current validator for the window, or NULL if there is n
|
|||||||
|
|
||||||
\constfunc{wxSize}{GetVirtualSize}{\void}
|
\constfunc{wxSize}{GetVirtualSize}{\void}
|
||||||
|
|
||||||
This gets the virtual size of the window in pixels as it has been set
|
This gets the virtual size of the window in pixels. By default it
|
||||||
by \helpref{SetVirtualSize}{wxwindowsetvirtualsize} or the size of the
|
returns the client size of the window, but after a call to
|
||||||
client area, if it is larger. Use
|
\helpref{SetVirtualSize}{wxwindowsetvirtualsize} it will return
|
||||||
\helpref{GetPureVirtualSize}{wxwindowgetpurevirtualsize} if you want
|
that size.
|
||||||
to get the actual virtual height independent of the client size.
|
|
||||||
|
|
||||||
\wxheading{Parameters}
|
\wxheading{Parameters}
|
||||||
|
|
||||||
|
@@ -424,17 +424,11 @@ public:
|
|||||||
|
|
||||||
// Override these methods for windows that have a virtual size
|
// Override these methods for windows that have a virtual size
|
||||||
// independent of their client size. eg. the virtual area of a
|
// independent of their client size. eg. the virtual area of a
|
||||||
// wxScrolledWindow. Default is to return m_virtualSize unless
|
// wxScrolledWindow.
|
||||||
// the client size is bigger.
|
|
||||||
|
|
||||||
virtual void DoSetVirtualSize( int x, int y );
|
virtual void DoSetVirtualSize( int x, int y );
|
||||||
virtual wxSize DoGetVirtualSize() const;
|
virtual wxSize DoGetVirtualSize() const;
|
||||||
|
|
||||||
|
|
||||||
// Really return just m_virtualSize, nothing else
|
|
||||||
|
|
||||||
wxSize GetPureVirtualSize() const { return m_virtualSize; }
|
|
||||||
|
|
||||||
// Return the largest of ClientSize and BestSize (as determined
|
// Return the largest of ClientSize and BestSize (as determined
|
||||||
// by a sizer, interior children, or other means)
|
// by a sizer, interior children, or other means)
|
||||||
|
|
||||||
|
@@ -789,10 +789,10 @@ void wxWindowBase::DoSetVirtualSize( int x, int y )
|
|||||||
|
|
||||||
wxSize wxWindowBase::DoGetVirtualSize() const
|
wxSize wxWindowBase::DoGetVirtualSize() const
|
||||||
{
|
{
|
||||||
wxSize s( GetClientSize() );
|
if (m_virtualSize == wxDefaultSize)
|
||||||
|
return GetClientSize();
|
||||||
|
|
||||||
return wxSize( wxMax( m_virtualSize.GetWidth(), s.GetWidth() ),
|
return m_virtualSize;
|
||||||
wxMax( m_virtualSize.GetHeight(), s.GetHeight() ) );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
@@ -567,18 +567,20 @@ int wxScrollHelper::CalcScrollInc(wxScrollWinEvent& event)
|
|||||||
{
|
{
|
||||||
if (m_xScrollPixelsPerLine > 0)
|
if (m_xScrollPixelsPerLine > 0)
|
||||||
{
|
{
|
||||||
int w, h;
|
if ( m_xScrollPosition + nScrollInc < 0 )
|
||||||
GetTargetSize(&w, &h);
|
{
|
||||||
|
// As -ve as we can go
|
||||||
int nMaxWidth = m_xScrollLines*m_xScrollPixelsPerLine;
|
nScrollInc = -m_xScrollPosition;
|
||||||
int noPositions = (int) ( ((nMaxWidth - w)/(double)m_xScrollPixelsPerLine) + 0.5 );
|
}
|
||||||
if (noPositions < 0)
|
else // check for the other bound
|
||||||
noPositions = 0;
|
{
|
||||||
|
const int posMax = m_xScrollLines - m_xScrollLinesPerPage;
|
||||||
if ( (m_xScrollPosition + nScrollInc) < 0 )
|
if ( m_xScrollPosition + nScrollInc > posMax )
|
||||||
nScrollInc = -m_xScrollPosition; // As -ve as we can go
|
{
|
||||||
else if ( (m_xScrollPosition + nScrollInc) > noPositions )
|
// As +ve as we can go
|
||||||
nScrollInc = noPositions - m_xScrollPosition; // As +ve as we can go
|
nScrollInc = posMax - m_xScrollPosition;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
m_targetWindow->Refresh(true, GetScrollRect());
|
m_targetWindow->Refresh(true, GetScrollRect());
|
||||||
@@ -644,39 +646,60 @@ void wxScrollHelper::AdjustScrollbars()
|
|||||||
{
|
{
|
||||||
GetTargetSize(&w, 0);
|
GetTargetSize(&w, 0);
|
||||||
|
|
||||||
if (m_xScrollPixelsPerLine == 0)
|
|
||||||
{
|
|
||||||
m_xScrollLines = 0;
|
|
||||||
m_xScrollPosition = 0;
|
|
||||||
m_win->SetScrollbar (wxHORIZONTAL, 0, 0, 0, false);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
int vVirt = m_targetWindow->GetVirtualSize().GetWidth();
|
|
||||||
m_xScrollLines = vVirt / m_xScrollPixelsPerLine;
|
|
||||||
|
|
||||||
// Calculate page size i.e. number of scroll units you get on the
|
|
||||||
// current client window
|
|
||||||
int noPagePositions = (int) ( (w/(double)m_xScrollPixelsPerLine) + 0.5 );
|
|
||||||
if (noPagePositions < 1) noPagePositions = 1;
|
|
||||||
if ( noPagePositions > m_xScrollLines )
|
|
||||||
noPagePositions = m_xScrollLines;
|
|
||||||
|
|
||||||
// Correct position if greater than extent of canvas minus
|
|
||||||
// the visible portion of it or if below zero
|
|
||||||
m_xScrollPosition = wxMin( m_xScrollLines - noPagePositions, m_xScrollPosition);
|
|
||||||
m_xScrollPosition = wxMax( 0, m_xScrollPosition );
|
|
||||||
|
|
||||||
m_win->SetScrollbar(wxHORIZONTAL, m_xScrollPosition, noPagePositions, m_xScrollLines);
|
|
||||||
// The amount by which we scroll when paging
|
|
||||||
SetScrollPageSize(wxHORIZONTAL, noPagePositions);
|
|
||||||
}
|
|
||||||
|
|
||||||
GetTargetSize(0, &h);
|
|
||||||
|
|
||||||
// scroll lines per page: if 0, no scrolling is needed
|
// scroll lines per page: if 0, no scrolling is needed
|
||||||
int linesPerPage;
|
int linesPerPage;
|
||||||
|
|
||||||
|
if ( m_xScrollPixelsPerLine == 0 )
|
||||||
|
{
|
||||||
|
// scrolling is disabled
|
||||||
|
m_xScrollLines = 0;
|
||||||
|
m_xScrollPosition = 0;
|
||||||
|
linesPerPage = 0;
|
||||||
|
}
|
||||||
|
else // might need scrolling
|
||||||
|
{
|
||||||
|
// Round up integer division to catch any "leftover" client space.
|
||||||
|
const int wVirt = m_targetWindow->GetVirtualSize().GetWidth();
|
||||||
|
m_xScrollLines = (wVirt + m_xScrollPixelsPerLine - 1) / m_xScrollPixelsPerLine;
|
||||||
|
|
||||||
|
// Calculate page size i.e. number of scroll units you get on the
|
||||||
|
// current client window.
|
||||||
|
linesPerPage = w / m_xScrollPixelsPerLine;
|
||||||
|
|
||||||
|
// Special case. When client and virtual size are very close but
|
||||||
|
// the client is big enough, kill scrollbar.
|
||||||
|
if ((linesPerPage < m_xScrollLines) && (w >= wVirt)) ++linesPerPage;
|
||||||
|
|
||||||
|
if (linesPerPage >= m_xScrollLines)
|
||||||
|
{
|
||||||
|
// we're big enough to not need scrolling
|
||||||
|
linesPerPage =
|
||||||
|
m_xScrollLines =
|
||||||
|
m_xScrollPosition = 0;
|
||||||
|
}
|
||||||
|
else // we do need a scrollbar
|
||||||
|
{
|
||||||
|
if ( linesPerPage < 1 )
|
||||||
|
linesPerPage = 1;
|
||||||
|
|
||||||
|
// Correct position if greater than extent of canvas minus
|
||||||
|
// the visible portion of it or if below zero
|
||||||
|
const int posMax = m_xScrollLines - linesPerPage;
|
||||||
|
if ( m_xScrollPosition > posMax )
|
||||||
|
m_xScrollPosition = posMax;
|
||||||
|
else if ( m_xScrollPosition < 0 )
|
||||||
|
m_xScrollPosition = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
m_win->SetScrollbar(wxHORIZONTAL, m_xScrollPosition,
|
||||||
|
linesPerPage, m_xScrollLines);
|
||||||
|
|
||||||
|
// The amount by which we scroll when paging
|
||||||
|
SetScrollPageSize(wxHORIZONTAL, linesPerPage);
|
||||||
|
|
||||||
|
GetTargetSize(0, &h);
|
||||||
|
|
||||||
if ( m_yScrollPixelsPerLine == 0 )
|
if ( m_yScrollPixelsPerLine == 0 )
|
||||||
{
|
{
|
||||||
// scrolling is disabled
|
// scrolling is disabled
|
||||||
@@ -686,13 +709,19 @@ void wxScrollHelper::AdjustScrollbars()
|
|||||||
}
|
}
|
||||||
else // might need scrolling
|
else // might need scrolling
|
||||||
{
|
{
|
||||||
int hVirt = m_targetWindow->GetVirtualSize().GetHeight();
|
// Round up integer division to catch any "leftover" client space.
|
||||||
m_yScrollLines = hVirt / m_yScrollPixelsPerLine;
|
const int hVirt = m_targetWindow->GetVirtualSize().GetHeight();
|
||||||
|
m_yScrollLines = ( hVirt + m_yScrollPixelsPerLine - 1 ) / m_yScrollPixelsPerLine;
|
||||||
|
|
||||||
// Calculate page size i.e. number of scroll units you get on the
|
// Calculate page size i.e. number of scroll units you get on the
|
||||||
// current client window
|
// current client window.
|
||||||
linesPerPage = h / m_yScrollPixelsPerLine;
|
linesPerPage = h / m_yScrollPixelsPerLine;
|
||||||
if ( linesPerPage >= m_yScrollLines )
|
|
||||||
|
// Special case. When client and virtual size are very close but
|
||||||
|
// the client is big enough, kill scrollbar.
|
||||||
|
if ((linesPerPage < m_yScrollLines) && (h >= hVirt)) ++linesPerPage;
|
||||||
|
|
||||||
|
if (linesPerPage >= m_yScrollLines)
|
||||||
{
|
{
|
||||||
// we're big enough to not need scrolling
|
// we're big enough to not need scrolling
|
||||||
linesPerPage =
|
linesPerPage =
|
||||||
|
@@ -351,7 +351,7 @@ void wxScrolledWindow::SetScrollbars( int pixelsPerUnitX, int pixelsPerUnitY,
|
|||||||
|
|
||||||
// Setting hints here should arguably be deprecated, but without it
|
// Setting hints here should arguably be deprecated, but without it
|
||||||
// a sizer might override this manual scrollbar setting in old code.
|
// a sizer might override this manual scrollbar setting in old code.
|
||||||
m_targetWindow->SetVirtualSizeHints( noUnitsX * pixelsPerUnitX, noUnitsY * pixelsPerUnitY );
|
// m_targetWindow->SetVirtualSizeHints( noUnitsX * pixelsPerUnitX, noUnitsY * pixelsPerUnitY );
|
||||||
|
|
||||||
m_targetWindow->SetVirtualSize( noUnitsX * pixelsPerUnitX, noUnitsY * pixelsPerUnitY );
|
m_targetWindow->SetVirtualSize( noUnitsX * pixelsPerUnitX, noUnitsY * pixelsPerUnitY );
|
||||||
|
|
||||||
@@ -371,7 +371,7 @@ void wxScrolledWindow::AdjustScrollbars()
|
|||||||
|
|
||||||
m_targetWindow->GetClientSize( &w, &h );
|
m_targetWindow->GetClientSize( &w, &h );
|
||||||
m_targetWindow->GetVirtualSize( &vw, &vh );
|
m_targetWindow->GetVirtualSize( &vw, &vh );
|
||||||
|
|
||||||
if (m_xScrollPixelsPerLine == 0)
|
if (m_xScrollPixelsPerLine == 0)
|
||||||
{
|
{
|
||||||
m_hAdjust->upper = 1.0;
|
m_hAdjust->upper = 1.0;
|
||||||
@@ -380,10 +380,16 @@ void wxScrolledWindow::AdjustScrollbars()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_hAdjust->upper = vw / m_xScrollPixelsPerLine;
|
m_hAdjust->upper = (vw+m_xScrollPixelsPerLine-1) / m_xScrollPixelsPerLine;
|
||||||
|
m_hAdjust->page_size = w / m_xScrollPixelsPerLine;
|
||||||
m_hAdjust->page_increment = w / m_xScrollPixelsPerLine;
|
m_hAdjust->page_increment = w / m_xScrollPixelsPerLine;
|
||||||
m_hAdjust->page_size = m_hAdjust->page_increment;
|
|
||||||
|
|
||||||
|
// Special case. When client and virtual size are very close but
|
||||||
|
// the client is big enough, kill scrollbar.
|
||||||
|
|
||||||
|
if ((m_hAdjust->page_size < m_hAdjust->upper) && (w >= vw))
|
||||||
|
m_hAdjust->page_size += 1.0;
|
||||||
|
|
||||||
// If the scrollbar hits the right side, move the window
|
// If the scrollbar hits the right side, move the window
|
||||||
// right to keep it from over extending.
|
// right to keep it from over extending.
|
||||||
|
|
||||||
@@ -408,9 +414,12 @@ void wxScrolledWindow::AdjustScrollbars()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_vAdjust->upper = vh / m_yScrollPixelsPerLine;
|
m_vAdjust->upper = (vh+m_yScrollPixelsPerLine-1) / m_yScrollPixelsPerLine;
|
||||||
|
m_vAdjust->page_size = h / m_yScrollPixelsPerLine;
|
||||||
m_vAdjust->page_increment = h / m_yScrollPixelsPerLine;
|
m_vAdjust->page_increment = h / m_yScrollPixelsPerLine;
|
||||||
m_vAdjust->page_size = m_vAdjust->page_increment;
|
|
||||||
|
if ((m_vAdjust->page_size < m_vAdjust->upper) && (h >= vh))
|
||||||
|
m_vAdjust->page_size += 1.0;
|
||||||
|
|
||||||
if ((m_vAdjust->value != 0.0) && (m_vAdjust->value + m_vAdjust->page_size > m_vAdjust->upper))
|
if ((m_vAdjust->value != 0.0) && (m_vAdjust->value + m_vAdjust->page_size > m_vAdjust->upper))
|
||||||
{
|
{
|
||||||
|
@@ -351,7 +351,7 @@ void wxScrolledWindow::SetScrollbars( int pixelsPerUnitX, int pixelsPerUnitY,
|
|||||||
|
|
||||||
// Setting hints here should arguably be deprecated, but without it
|
// Setting hints here should arguably be deprecated, but without it
|
||||||
// a sizer might override this manual scrollbar setting in old code.
|
// a sizer might override this manual scrollbar setting in old code.
|
||||||
m_targetWindow->SetVirtualSizeHints( noUnitsX * pixelsPerUnitX, noUnitsY * pixelsPerUnitY );
|
// m_targetWindow->SetVirtualSizeHints( noUnitsX * pixelsPerUnitX, noUnitsY * pixelsPerUnitY );
|
||||||
|
|
||||||
m_targetWindow->SetVirtualSize( noUnitsX * pixelsPerUnitX, noUnitsY * pixelsPerUnitY );
|
m_targetWindow->SetVirtualSize( noUnitsX * pixelsPerUnitX, noUnitsY * pixelsPerUnitY );
|
||||||
|
|
||||||
@@ -371,7 +371,7 @@ void wxScrolledWindow::AdjustScrollbars()
|
|||||||
|
|
||||||
m_targetWindow->GetClientSize( &w, &h );
|
m_targetWindow->GetClientSize( &w, &h );
|
||||||
m_targetWindow->GetVirtualSize( &vw, &vh );
|
m_targetWindow->GetVirtualSize( &vw, &vh );
|
||||||
|
|
||||||
if (m_xScrollPixelsPerLine == 0)
|
if (m_xScrollPixelsPerLine == 0)
|
||||||
{
|
{
|
||||||
m_hAdjust->upper = 1.0;
|
m_hAdjust->upper = 1.0;
|
||||||
@@ -380,10 +380,16 @@ void wxScrolledWindow::AdjustScrollbars()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_hAdjust->upper = vw / m_xScrollPixelsPerLine;
|
m_hAdjust->upper = (vw+m_xScrollPixelsPerLine-1) / m_xScrollPixelsPerLine;
|
||||||
|
m_hAdjust->page_size = w / m_xScrollPixelsPerLine;
|
||||||
m_hAdjust->page_increment = w / m_xScrollPixelsPerLine;
|
m_hAdjust->page_increment = w / m_xScrollPixelsPerLine;
|
||||||
m_hAdjust->page_size = m_hAdjust->page_increment;
|
|
||||||
|
|
||||||
|
// Special case. When client and virtual size are very close but
|
||||||
|
// the client is big enough, kill scrollbar.
|
||||||
|
|
||||||
|
if ((m_hAdjust->page_size < m_hAdjust->upper) && (w >= vw))
|
||||||
|
m_hAdjust->page_size += 1.0;
|
||||||
|
|
||||||
// If the scrollbar hits the right side, move the window
|
// If the scrollbar hits the right side, move the window
|
||||||
// right to keep it from over extending.
|
// right to keep it from over extending.
|
||||||
|
|
||||||
@@ -408,9 +414,12 @@ void wxScrolledWindow::AdjustScrollbars()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_vAdjust->upper = vh / m_yScrollPixelsPerLine;
|
m_vAdjust->upper = (vh+m_yScrollPixelsPerLine-1) / m_yScrollPixelsPerLine;
|
||||||
|
m_vAdjust->page_size = h / m_yScrollPixelsPerLine;
|
||||||
m_vAdjust->page_increment = h / m_yScrollPixelsPerLine;
|
m_vAdjust->page_increment = h / m_yScrollPixelsPerLine;
|
||||||
m_vAdjust->page_size = m_vAdjust->page_increment;
|
|
||||||
|
if ((m_vAdjust->page_size < m_vAdjust->upper) && (h >= vh))
|
||||||
|
m_vAdjust->page_size += 1.0;
|
||||||
|
|
||||||
if ((m_vAdjust->value != 0.0) && (m_vAdjust->value + m_vAdjust->page_size > m_vAdjust->upper))
|
if ((m_vAdjust->value != 0.0) && (m_vAdjust->value + m_vAdjust->page_size > m_vAdjust->upper))
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user