Paragraph and image layout fixes

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@76025 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Julian Smart 2014-02-27 15:15:18 +00:00
parent f631f732af
commit 9adba53251
2 changed files with 23 additions and 2 deletions

View File

@ -2211,7 +2211,7 @@ public:
*/
wxRichTextDrawingContext(wxRichTextBuffer* buffer);
void Init() { m_buffer = NULL; m_enableVirtualAttributes = true; m_enableImages = true; }
void Init() { m_buffer = NULL; m_enableVirtualAttributes = true; m_enableImages = true; m_layingOut = false; }
/**
Does this object have virtual attributes?
@ -2281,9 +2281,22 @@ public:
bool GetImagesEnabled() const { return m_enableImages; }
/**
Set laying out flag
*/
void SetLayingOut(bool b) { m_layingOut = b; }
/**
Returns @true if laying out.
*/
bool GetLayingOut() const { return m_layingOut; }
wxRichTextBuffer* m_buffer;
bool m_enableVirtualAttributes;
bool m_enableImages;
bool m_layingOut;
};
/**

View File

@ -1995,6 +1995,8 @@ void wxRichTextParagraphLayoutBox::MoveAnchoredObjectToParagraph(wxRichTextParag
/// Draw the item
bool wxRichTextParagraphLayoutBox::Draw(wxDC& dc, wxRichTextDrawingContext& context, const wxRichTextRange& range, const wxRichTextSelection& selection, const wxRect& rect, int descent, int style)
{
context.SetLayingOut(false);
if (!IsShown())
return true;
@ -2054,6 +2056,8 @@ bool wxRichTextParagraphLayoutBox::Draw(wxDC& dc, wxRichTextDrawingContext& cont
/// Lay the item out
bool wxRichTextParagraphLayoutBox::Layout(wxDC& dc, wxRichTextDrawingContext& context, const wxRect& rect, const wxRect& parentRect, int style)
{
context.SetLayingOut(true);
Move(rect.GetPosition());
if (!IsShown())
@ -5307,7 +5311,7 @@ bool wxRichTextParagraph::Layout(wxDC& dc, wxRichTextDrawingContext& context, co
// Add the last line - it's the current pos -> last para pos
// Subtract -1 because the last position is always the end-paragraph position.
if (lastCompletedEndPos <= GetRange().GetEnd()-1)
if ((lastCompletedEndPos < GetRange().GetEnd()-1) || lineCount == 0)
{
int startOffset = (lineCount == 0 ? startPositionFirstLine : startPositionSubsequentLines);
availableRect = wxRect(rect.x + startOffset, rect.y + currentPosition.y,
@ -12217,6 +12221,10 @@ bool wxRichTextImage::LoadImageCache(wxDC& dc, wxRichTextDrawingContext& context
if (!m_imageBlock.IsOk())
return false;
// Don't repeat unless absolutely necessary
if (m_imageCache.IsOk() && !resetCache && !context.GetLayingOut())
return true;
if (!context.GetImagesEnabled())
{
if (resetCache || !m_imageCache.IsOk())