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
}
// Allow adjustment of scroll increment. The default is (15, 15).
}
// Allow adjustment of scroll increment. The default is (15, 15).
- void SetScrollLineX(int x) { m_scrollLineX = x; }
- void SetScrollLineY(int y) { m_scrollLineY = y; }
- int GetScrollLineX() const { return m_scrollLineX; }
- int GetScrollLineY() const { return m_scrollLineY; }
+ void SetScrollLineX(int x) { m_xScrollPixelsPerLine = x; }
+ void SetScrollLineY(int y) { m_yScrollPixelsPerLine = y; }
+ int GetScrollLineX() const { return m_xScrollPixelsPerLine; }
+ int GetScrollLineY() const { return m_yScrollPixelsPerLine; }
// ------- drag and drop
#if wxUSE_DRAG_AND_DROP
// ------- drag and drop
#if wxUSE_DRAG_AND_DROP
bool m_editable; // applies to whole grid
bool m_cellEditCtrlEnabled; // is in-place edit currently shown?
bool m_editable; // applies to whole grid
bool m_cellEditCtrlEnabled; // is in-place edit currently shown?
- int m_scrollLineX; // X scroll increment
- int m_scrollLineY; // Y scroll increment
-
void Init(); // common part of all ctors
void Create();
void CreateColumnWindow();
void Init(); // common part of all ctors
void Create();
void CreateColumnWindow();
Create();
SetInitialSize(size);
Create();
SetInitialSize(size);
- SetScrollRate(m_scrollLineX, m_scrollLineY);
CalcDimensions();
return true;
CalcDimensions();
return true;
m_extraWidth =
m_extraHeight = 0;
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;
}
// ----------------------------------------------------------------------------
}
// ----------------------------------------------------------------------------
//
// Sometimes GRID_SCROLL_LINE / 2 is not enough,
// so just add a full scroll unit...
//
// Sometimes GRID_SCROLL_LINE / 2 is not enough,
// so just add a full scroll unit...
+ ypos += m_yScrollPixelsPerLine;
}
// special handling for wide cells - show always left part of the cell!
}
// special handling for wide cells - show always left part of the cell!
xpos = x0 + (right - cw);
// see comment for ypos above
xpos = x0 + (right - cw);
// see comment for ypos above
+ xpos += m_xScrollPixelsPerLine;
}
if ( xpos != -1 || ypos != -1 )
{
if ( xpos != -1 )
}
if ( xpos != -1 || ypos != -1 )
{
if ( xpos != -1 )
+ xpos /= m_xScrollPixelsPerLine;
+ ypos /= m_yScrollPixelsPerLine;
Scroll( xpos, ypos );
AdjustScrollbars();
}
Scroll( xpos, ypos );
AdjustScrollbars();
}
// 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
// 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);
}
SetClientSize(size.x + m_rowLabelWidth, size.y + m_colLabelHeight);
}