wxTextCtrl:
1. now only scroll the visible text, not the entire text rect 2. don't draw the columns before the leftmost (visible) one git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/wxUNIVERSAL@8443 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -291,10 +291,11 @@ private:
|
|||||||
// the rectangle (in client coordinates) to draw text inside
|
// the rectangle (in client coordinates) to draw text inside
|
||||||
wxRect m_rectText;
|
wxRect m_rectText;
|
||||||
|
|
||||||
// for the controls without horz scrollbar: the offset by which the window
|
// for the controls without horz scrollbar only: the position of the first
|
||||||
// is scrolled to the right and the first visible position
|
// and last visible pixels and the first visible column
|
||||||
|
wxCoord m_ofsHorz,
|
||||||
|
m_posLastVisible;
|
||||||
long m_colStart;
|
long m_colStart;
|
||||||
wxCoord m_ofsHorz;
|
|
||||||
|
|
||||||
DECLARE_EVENT_TABLE()
|
DECLARE_EVENT_TABLE()
|
||||||
DECLARE_DYNAMIC_CLASS(wxTextCtrl)
|
DECLARE_DYNAMIC_CLASS(wxTextCtrl)
|
||||||
|
@@ -72,6 +72,7 @@ void wxTextCtrl::Init()
|
|||||||
|
|
||||||
m_colStart = 0;
|
m_colStart = 0;
|
||||||
m_ofsHorz = 0;
|
m_ofsHorz = 0;
|
||||||
|
m_posLastVisible = 0;
|
||||||
|
|
||||||
m_curPos =
|
m_curPos =
|
||||||
m_curRow =
|
m_curRow =
|
||||||
@@ -687,6 +688,10 @@ void wxTextCtrl::UpdateTextRect()
|
|||||||
m_rectText = GetRenderer()->
|
m_rectText = GetRenderer()->
|
||||||
GetTextClientArea(this,
|
GetTextClientArea(this,
|
||||||
wxRect(wxPoint(0, 0), GetClientSize()));
|
wxRect(wxPoint(0, 0), GetClientSize()));
|
||||||
|
|
||||||
|
// it will be updated the next time we're redrawn, don't redo the (rather
|
||||||
|
// complex and time consuming) calculation of it here
|
||||||
|
m_posLastVisible = m_rectText.width;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxTextCtrl::OnSize(wxSizeEvent& event)
|
void wxTextCtrl::OnSize(wxSizeEvent& event)
|
||||||
@@ -934,7 +939,11 @@ void wxTextCtrl::ScrollText(long col)
|
|||||||
m_ofsHorz = ofsHorz;
|
m_ofsHorz = ofsHorz;
|
||||||
m_colStart = col;
|
m_colStart = col;
|
||||||
|
|
||||||
ScrollWindow(dx, 0, &m_rectText);
|
// NB3: scroll only the text shown, not the entire text area (there may
|
||||||
|
// be blank area at the end)
|
||||||
|
wxRect rectText = m_rectText;
|
||||||
|
rectText.width = m_posLastVisible;
|
||||||
|
ScrollWindow(dx, 0, &rectText);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1112,6 +1121,10 @@ void wxTextCtrl::DoDrawTextInRect(wxDC& dc, const wxRect& rectUpdate)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// don't show the columns which are scrolled out to the left
|
||||||
|
if ( colStart > m_colStart )
|
||||||
|
colStart = m_colStart;
|
||||||
|
|
||||||
(void)HitTest(pt2, &colEnd, NULL);
|
(void)HitTest(pt2, &colEnd, NULL);
|
||||||
|
|
||||||
// extract the part of line we need to redraw
|
// extract the part of line we need to redraw
|
||||||
@@ -1142,6 +1155,9 @@ void wxTextCtrl::DoDrawTextInRect(wxDC& dc, const wxRect& rectUpdate)
|
|||||||
rectText.width -= GetTextWidth(text.Last());
|
rectText.width -= GetTextWidth(text.Last());
|
||||||
text.RemoveLast();
|
text.RemoveLast();
|
||||||
|
|
||||||
|
// remember the position of the last pixel shown
|
||||||
|
m_posLastVisible = rectText.GetRight() - m_rectText.GetLeft();
|
||||||
|
|
||||||
if ( !text )
|
if ( !text )
|
||||||
{
|
{
|
||||||
// string became empty, nothing to draw finally
|
// string became empty, nothing to draw finally
|
||||||
|
Reference in New Issue
Block a user