Remove scroll units duplication in wxGrid to fix setting them.
For some unknown reason wxGrid decided to store its scroll units in its own m_scrollLine[XY] variables instead of just using the base wxScrollWindow class m_[xy]ScrollPixelsPerLine ones. And, of course, the two could get out of sync because wxGrid didn't update the base class version correctly. Just don't duplicate these values at all and use the base class fields. This makes the code simpler and also fixes changing the size of the scroll units. Closes #12221. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@64918 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -1911,7 +1911,6 @@ bool wxGrid::Create(wxWindow *parent, wxWindowID id,
|
||||
|
||||
Create();
|
||||
SetInitialSize(size);
|
||||
SetScrollRate(m_scrollLineX, m_scrollLineY);
|
||||
CalcDimensions();
|
||||
|
||||
return true;
|
||||
@@ -2249,8 +2248,11 @@ void wxGrid::Init()
|
||||
m_extraWidth =
|
||||
m_extraHeight = 0;
|
||||
|
||||
m_scrollLineX = GRID_SCROLL_LINE_X;
|
||||
m_scrollLineY = GRID_SCROLL_LINE_Y;
|
||||
// we can't call SetScrollRate() as the window isn't created yet but OTOH
|
||||
// we don't need to call it neither as the scroll position is (0, 0) right
|
||||
// now anyhow, so just set the parameters directly
|
||||
m_xScrollPixelsPerLine = GRID_SCROLL_LINE_X;
|
||||
m_yScrollPixelsPerLine = GRID_SCROLL_LINE_Y;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
@@ -6405,7 +6407,7 @@ void wxGrid::MakeCellVisible( int row, int col )
|
||||
//
|
||||
// Sometimes GRID_SCROLL_LINE / 2 is not enough,
|
||||
// so just add a full scroll unit...
|
||||
ypos += m_scrollLineY;
|
||||
ypos += m_yScrollPixelsPerLine;
|
||||
}
|
||||
|
||||
// special handling for wide cells - show always left part of the cell!
|
||||
@@ -6424,15 +6426,15 @@ void wxGrid::MakeCellVisible( int row, int col )
|
||||
xpos = x0 + (right - cw);
|
||||
|
||||
// see comment for ypos above
|
||||
xpos += m_scrollLineX;
|
||||
xpos += m_xScrollPixelsPerLine;
|
||||
}
|
||||
|
||||
if ( xpos != -1 || ypos != -1 )
|
||||
{
|
||||
if ( xpos != -1 )
|
||||
xpos /= m_scrollLineX;
|
||||
xpos /= m_xScrollPixelsPerLine;
|
||||
if ( ypos != -1 )
|
||||
ypos /= m_scrollLineY;
|
||||
ypos /= m_yScrollPixelsPerLine;
|
||||
Scroll( xpos, ypos );
|
||||
AdjustScrollbars();
|
||||
}
|
||||
@@ -8115,10 +8117,8 @@ void wxGrid::AutoSize()
|
||||
// we know that we're not going to have scrollbars so disable them now to
|
||||
// avoid trouble in SetClientSize() which can otherwise set the correct
|
||||
// client size but also leave space for (not needed any more) scrollbars
|
||||
SetScrollbars(0, 0, 0, 0, 0, 0, true);
|
||||
|
||||
// restore the scroll rate parameters overwritten by SetScrollbars()
|
||||
SetScrollRate(m_scrollLineX, m_scrollLineY);
|
||||
SetScrollbars(m_xScrollPixelsPerLine, m_yScrollPixelsPerLine,
|
||||
0, 0, 0, 0, true);
|
||||
|
||||
SetClientSize(size.x + m_rowLabelWidth, size.y + m_colLabelHeight);
|
||||
}
|
||||
|
Reference in New Issue
Block a user