// If this is a floating object, size may not be recalculated
// after floats have been collected in an early stage of Layout.
// So avoid resetting the cache for floating objects during layout.
- if (!IsFloating())
+ if (!IsFloating() || !wxRichTextBuffer::GetFloatingLayoutMode())
SetCachedSize(wxDefaultSize);
SetMaxSize(wxDefaultSize);
SetMinSize(wxDefaultSize);
// If a paragraph, align the whole paragraph.
// Problem with this: if we're limited by a floating object, a line may be centered
// w.r.t. the smaller resulting box rather than the actual available width.
- if (attr.HasAlignment() && !GetContainer()->GetFloatCollector()->HasFloats()) // FIXME: aligning whole paragraph not compatible with floating objects
+ // FIXME: aligning whole paragraph not compatible with floating objects
+ if (attr.HasAlignment() && (!wxRichTextBuffer::GetFloatingLayoutMode() || (GetContainer()->GetFloatCollector() && !GetContainer()->GetFloatCollector()->HasFloats())))
{
// centering, right-justification
if (attr.GetAlignment() == wxTEXT_ALIGNMENT_CENTRE)
if (!child->GetRange().IsOutside(range))
{
// Floating objects have a zero size within the paragraph.
- if (child->IsFloating())
+ if (child->IsFloating() && wxRichTextBuffer::GetFloatingLayoutMode())
{
if (partialExtents)
{
}
else if (child->IsTopLevel())
{
- if (child->IsFloating() && GetBuffer()->GetFloatCollector() && GetBuffer()->GetFloatCollector()->HasFloat(child))
+ if (wxRichTextBuffer::GetFloatingLayoutMode() && child->IsFloating() && GetBuffer()->GetFloatCollector() && GetBuffer()->GetFloatCollector()->HasFloat(child))
{
// Don't invalidate subhierarchy if we've already been laid out
}
return wxRICHTEXT_HITTEST_NONE;
int ret = wxRICHTEXT_HITTEST_NONE;
- if (m_floatCollector && (flags & wxRICHTEXT_HITTEST_NO_FLOATING_OBJECTS) == 0)
+ if (wxRichTextBuffer::GetFloatingLayoutMode() && m_floatCollector && (flags & wxRICHTEXT_HITTEST_NO_FLOATING_OBJECTS) == 0)
ret = m_floatCollector->HitTest(dc, context, pt, textPosition, obj, flags);
if (ret == wxRICHTEXT_HITTEST_NONE)
/// Draw the floating objects
void wxRichTextParagraphLayoutBox::DrawFloats(wxDC& dc, wxRichTextDrawingContext& context, const wxRichTextRange& range, const wxRichTextSelection& selection, const wxRect& rect, int descent, int style)
{
- if (m_floatCollector)
+ if (wxRichTextBuffer::GetFloatingLayoutMode() && m_floatCollector)
m_floatCollector->Draw(dc, context, range, selection, rect, descent, style);
}
theseFlags &= ~wxRICHTEXT_DRAW_GUIDELINES;
DrawBoxAttributes(dc, GetBuffer(), attr, thisRect, theseFlags);
- DrawFloats(dc, context, range, selection, rect, descent, style);
+ if (wxRichTextBuffer::GetFloatingLayoutMode())
+ DrawFloats(dc, context, range, selection, rect, descent, style);
+
wxRichTextObjectList::compatibility_iterator node = m_children.GetFirst();
while (node)
{
// Gather information about only those floating objects that will not be formatted,
// after which floats will be gathered per-paragraph during layout.
- UpdateFloatingObjects(availableSpace, node ? node->GetData() : (wxRichTextObject*) NULL);
+ if (wxRichTextBuffer::GetFloatingLayoutMode())
+ UpdateFloatingObjects(availableSpace, node ? node->GetData() : (wxRichTextObject*) NULL);
// A way to force speedy rest-of-buffer layout (the 'else' below)
bool forceQuickLayout = false;
maxHeight = 0; // topMargin + bottomMargin;
// Check the bottom edge of any floating object
- if (GetFloatCollector() && GetFloatCollector()->HasFloats())
+ if (wxRichTextBuffer::GetFloatingLayoutMode() && GetFloatCollector() && GetFloatCollector()->HasFloats())
{
int bottom = GetFloatCollector()->GetLastRectBottom();
if (bottom > maxHeight)
{
wxRichTextObject* child = node2->GetData();
- if (!child->IsFloating() && child->GetRange().GetLength() > 0 && !child->GetRange().IsOutside(lineRange) && !lineRange.IsOutside(range))
+ if ((!child->IsFloating() || !wxRichTextBuffer::GetFloatingLayoutMode()) && child->GetRange().GetLength() > 0 && !child->GetRange().IsOutside(lineRange) && !lineRange.IsOutside(range))
{
// Draw this part of the line at the correct position
wxRichTextRange objectRange(child->GetRange());
// Deal with floating objects firstly before the normal layout
wxRichTextBuffer* buffer = GetBuffer();
wxASSERT(buffer);
+
wxRichTextFloatCollector* collector = GetContainer()->GetFloatCollector();
- wxASSERT(collector);
- LayoutFloat(dc, context, rect, parentRect, style, collector);
+
+ if (wxRichTextBuffer::GetFloatingLayoutMode())
+ {
+ wxASSERT(collector != NULL);
+ if (collector)
+ LayoutFloat(dc, context, rect, parentRect, style, collector);
+ }
wxRichTextAttr attr = GetCombinedAttributes();
context.ApplyVirtualAttributes(attr, this);
// If floating, ignore. We already laid out floats.
// Also ignore if empty object, except if we haven't got any
// size yet.
- if (child->IsFloating() || !child->IsShown() ||
- (child->GetRange().GetLength() == 0 && maxHeight > spaceBeforePara)
+ if ((child->IsFloating() && wxRichTextBuffer::GetFloatingLayoutMode())
+ || !child->IsShown() || (child->GetRange().GetLength() == 0 && maxHeight > spaceBeforePara)
)
{
node = node->GetNext();
lineAscent = wxMax(childSize.y-childDescent, maxAscent);
}
lineHeight = wxMax(lineHeight, (lineDescent + lineAscent));
- wxRect floatAvailableRect = collector->GetAvailableRect(rect.y + currentPosition.y, rect.y + currentPosition.y + lineHeight);
-
- // Adjust availableRect to the space that is available when taking floating objects into account.
- if (floatAvailableRect.x + startOffset > availableRect.x)
+ if (wxRichTextBuffer::GetFloatingLayoutMode() && collector)
{
- int newX = floatAvailableRect.x + startOffset;
- int newW = availableRect.width - (newX - availableRect.x);
- availableRect.x = newX;
- availableRect.width = newW;
- }
+ wxRect floatAvailableRect = collector->GetAvailableRect(rect.y + currentPosition.y, rect.y + currentPosition.y + lineHeight);
+
+ // Adjust availableRect to the space that is available when taking floating objects into account.
+
+ if (floatAvailableRect.x + startOffset > availableRect.x)
+ {
+ int newX = floatAvailableRect.x + startOffset;
+ int newW = availableRect.width - (newX - availableRect.x);
+ availableRect.x = newX;
+ availableRect.width = newW;
+ }
- if (floatAvailableRect.width < availableRect.width)
- availableRect.width = floatAvailableRect.width;
+ if (floatAvailableRect.width < availableRect.width)
+ availableRect.width = floatAvailableRect.width;
+ }
currentPosition.x = availableRect.x - rect.x;
// If floating, ignore. We already laid out floats.
// Also ignore if empty object, except if we haven't got any
// size yet.
- if (!child->IsFloating() && child->GetRange().GetLength() != 0 && !wxDynamicCast(child, wxRichTextPlainText))
+ if ((!child->IsFloating() || !wxRichTextBuffer::GetFloatingLayoutMode()) && child->GetRange().GetLength() != 0 && !wxDynamicCast(child, wxRichTextPlainText))
{
if (child->GetCachedSize().x > minWidth)
minWidth = child->GetMinSize().x;
if (!child->GetRange().IsOutside(range))
{
// Floating objects have a zero size within the paragraph.
- if (child->IsFloating())
+ if (child->IsFloating() && wxRichTextBuffer::GetFloatingLayoutMode())
{
if (partialExtents)
{
{
wxRichTextObject* child = node2->GetData();
- if (!child->IsFloating() && !child->GetRange().IsOutside(lineRange))
+ if ((!child->IsFloating() || !wxRichTextBuffer::GetFloatingLayoutMode()) && !child->GetRange().IsOutside(lineRange))
{
wxRichTextRange rangeToUse = lineRange;
rangeToUse.LimitTo(child->GetRange());
wxRichTextRenderer* wxRichTextBuffer::sm_renderer = NULL;
int wxRichTextBuffer::sm_bulletRightMargin = 20;
float wxRichTextBuffer::sm_bulletProportion = (float) 0.3;
+bool wxRichTextBuffer::sm_floatingLayoutMode = true;
/// Initialisation
void wxRichTextBuffer::Init()
ApplyParagraphs(GetNewParagraphs());
// Invalidate the whole buffer if there were floating objects
- if (container->GetFloatingObjectCount() > 0)
+ if (wxRichTextBuffer::GetFloatingLayoutMode() && container->GetFloatingObjectCount() > 0)
m_buffer->InvalidateHierarchy(wxRICHTEXT_ALL);
else
{
// InvalidateHierarchy goes up the hierarchy as well as down, otherwise with a nested object,
// Layout() would stop prematurely at the top level.
// Invalidate the whole buffer if there were floating objects
- if (container->GetFloatingObjectCount() > 0)
+ if (wxRichTextBuffer::GetFloatingLayoutMode() && container->GetFloatingObjectCount() > 0)
m_buffer->InvalidateHierarchy(wxRICHTEXT_ALL);
else
container->InvalidateHierarchy(GetRange());
// InvalidateHierarchy goes up the hierarchy as well as down, otherwise with a nested object,
// Layout() would stop prematurely at the top level.
// Invalidate the whole buffer if there were floating objects
- if (container->GetFloatingObjectCount() > 0)
+ if (wxRichTextBuffer::GetFloatingLayoutMode() && container->GetFloatingObjectCount() > 0)
m_buffer->InvalidateHierarchy(wxRICHTEXT_ALL);
else
container->InvalidateHierarchy(GetRange());
// Refresh everything if there were floating objects or the container changed size
// (we can't yet optimize in these cases, since more complex interaction with other content occurs)
- if (container->GetFloatingObjectCount() > 0 || (container->GetParent() && containerRect != container->GetRect()))
+ if ((wxRichTextBuffer::GetFloatingLayoutMode() && container->GetFloatingObjectCount() > 0) || (container->GetParent() && containerRect != container->GetRect()))
{
m_ctrl->Refresh(false);
}