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:
parent
f631f732af
commit
9adba53251
@ -2211,7 +2211,7 @@ public:
|
|||||||
*/
|
*/
|
||||||
wxRichTextDrawingContext(wxRichTextBuffer* buffer);
|
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?
|
Does this object have virtual attributes?
|
||||||
@ -2281,9 +2281,22 @@ public:
|
|||||||
|
|
||||||
bool GetImagesEnabled() const { return m_enableImages; }
|
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;
|
wxRichTextBuffer* m_buffer;
|
||||||
bool m_enableVirtualAttributes;
|
bool m_enableVirtualAttributes;
|
||||||
bool m_enableImages;
|
bool m_enableImages;
|
||||||
|
bool m_layingOut;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1995,6 +1995,8 @@ void wxRichTextParagraphLayoutBox::MoveAnchoredObjectToParagraph(wxRichTextParag
|
|||||||
/// Draw the item
|
/// Draw the item
|
||||||
bool wxRichTextParagraphLayoutBox::Draw(wxDC& dc, wxRichTextDrawingContext& context, const wxRichTextRange& range, const wxRichTextSelection& selection, const wxRect& rect, int descent, int style)
|
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())
|
if (!IsShown())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
@ -2054,6 +2056,8 @@ bool wxRichTextParagraphLayoutBox::Draw(wxDC& dc, wxRichTextDrawingContext& cont
|
|||||||
/// Lay the item out
|
/// Lay the item out
|
||||||
bool wxRichTextParagraphLayoutBox::Layout(wxDC& dc, wxRichTextDrawingContext& context, const wxRect& rect, const wxRect& parentRect, int style)
|
bool wxRichTextParagraphLayoutBox::Layout(wxDC& dc, wxRichTextDrawingContext& context, const wxRect& rect, const wxRect& parentRect, int style)
|
||||||
{
|
{
|
||||||
|
context.SetLayingOut(true);
|
||||||
|
|
||||||
Move(rect.GetPosition());
|
Move(rect.GetPosition());
|
||||||
|
|
||||||
if (!IsShown())
|
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
|
// Add the last line - it's the current pos -> last para pos
|
||||||
// Subtract -1 because the last position is always the end-paragraph position.
|
// 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);
|
int startOffset = (lineCount == 0 ? startPositionFirstLine : startPositionSubsequentLines);
|
||||||
availableRect = wxRect(rect.x + startOffset, rect.y + currentPosition.y,
|
availableRect = wxRect(rect.x + startOffset, rect.y + currentPosition.y,
|
||||||
@ -12217,6 +12221,10 @@ bool wxRichTextImage::LoadImageCache(wxDC& dc, wxRichTextDrawingContext& context
|
|||||||
if (!m_imageBlock.IsOk())
|
if (!m_imageBlock.IsOk())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
// Don't repeat unless absolutely necessary
|
||||||
|
if (m_imageCache.IsOk() && !resetCache && !context.GetLayingOut())
|
||||||
|
return true;
|
||||||
|
|
||||||
if (!context.GetImagesEnabled())
|
if (!context.GetImagesEnabled())
|
||||||
{
|
{
|
||||||
if (resetCache || !m_imageCache.IsOk())
|
if (resetCache || !m_imageCache.IsOk())
|
||||||
|
Loading…
Reference in New Issue
Block a user