Resets scroll position on load
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@35960 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -561,7 +561,7 @@ public:
|
|||||||
virtual bool SetFont(const wxFont& font);
|
virtual bool SetFont(const wxFont& font);
|
||||||
|
|
||||||
/// Set up scrollbars, e.g. after a resize
|
/// Set up scrollbars, e.g. after a resize
|
||||||
virtual void SetupScrollbars();
|
virtual void SetupScrollbars(bool atTop = false);
|
||||||
|
|
||||||
/// Keyboard navigation
|
/// Keyboard navigation
|
||||||
virtual bool Navigate(int keyCode, int flags);
|
virtual bool Navigate(int keyCode, int flags);
|
||||||
|
@@ -1949,6 +1949,8 @@ bool wxRichTextParagraph::Draw(wxDC& dc, const wxRichTextRange& WXUNUSED(range),
|
|||||||
/// Lay the item out
|
/// Lay the item out
|
||||||
bool wxRichTextParagraph::Layout(wxDC& dc, const wxRect& rect, int style)
|
bool wxRichTextParagraph::Layout(wxDC& dc, const wxRect& rect, int style)
|
||||||
{
|
{
|
||||||
|
// ClearLines();
|
||||||
|
|
||||||
// Increase the size of the paragraph due to spacing
|
// Increase the size of the paragraph due to spacing
|
||||||
int spaceBeforePara = ConvertTenthsMMToPixels(dc, GetAttributes().GetParagraphSpacingBefore());
|
int spaceBeforePara = ConvertTenthsMMToPixels(dc, GetAttributes().GetParagraphSpacingBefore());
|
||||||
int spaceAfterPara = ConvertTenthsMMToPixels(dc, GetAttributes().GetParagraphSpacingAfter());
|
int spaceAfterPara = ConvertTenthsMMToPixels(dc, GetAttributes().GetParagraphSpacingAfter());
|
||||||
@@ -4859,13 +4861,16 @@ bool wxRichTextPlainTextHandler::DoLoadFile(wxRichTextBuffer *buffer, wxInputStr
|
|||||||
{
|
{
|
||||||
int ch = stream.GetC();
|
int ch = stream.GetC();
|
||||||
|
|
||||||
if (ch == 10 && lastCh != 13)
|
if (!stream.Eof())
|
||||||
str += wxT('\n');
|
{
|
||||||
|
if (ch == 10 && lastCh != 13)
|
||||||
if (ch > 0 && ch != 10)
|
str += wxT('\n');
|
||||||
str += wxChar(ch);
|
|
||||||
|
if (ch > 0 && ch != 10)
|
||||||
lastCh = ch;
|
str += wxChar(ch);
|
||||||
|
|
||||||
|
lastCh = ch;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
buffer->Clear();
|
buffer->Clear();
|
||||||
|
@@ -1331,7 +1331,7 @@ void wxRichTextCtrl::OnSize(wxSizeEvent& event)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Set up scrollbars, e.g. after a resize
|
/// Set up scrollbars, e.g. after a resize
|
||||||
void wxRichTextCtrl::SetupScrollbars()
|
void wxRichTextCtrl::SetupScrollbars(bool atTop)
|
||||||
{
|
{
|
||||||
if (m_freezeCount)
|
if (m_freezeCount)
|
||||||
return;
|
return;
|
||||||
@@ -1351,8 +1351,9 @@ void wxRichTextCtrl::SetupScrollbars()
|
|||||||
|
|
||||||
int unitsY = maxHeight/pixelsPerUnit;
|
int unitsY = maxHeight/pixelsPerUnit;
|
||||||
|
|
||||||
int startX, startY;
|
int startX = 0, startY = 0;
|
||||||
GetViewStart(& startX, & startY);
|
if (!atTop)
|
||||||
|
GetViewStart(& startX, & startY);
|
||||||
|
|
||||||
int maxPositionX = 0; // wxMax(sz.x - clientSize.x, 0);
|
int maxPositionX = 0; // wxMax(sz.x - clientSize.x, 0);
|
||||||
int maxPositionY = (wxMax(maxHeight - clientSize.y, 0))/pixelsPerUnit;
|
int maxPositionY = (wxMax(maxHeight - clientSize.y, 0))/pixelsPerUnit;
|
||||||
@@ -1413,6 +1414,7 @@ bool wxRichTextCtrl::LoadFile(const wxString& filename, int type)
|
|||||||
SetInsertionPoint(0);
|
SetInsertionPoint(0);
|
||||||
Layout();
|
Layout();
|
||||||
PositionCaret();
|
PositionCaret();
|
||||||
|
SetupScrollbars(true);
|
||||||
Refresh();
|
Refresh();
|
||||||
SendUpdateEvent();
|
SendUpdateEvent();
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user