- // Layout must set the cached size
- availableSpace.y += child->GetCachedSize().y;
- maxWidth = wxMax(maxWidth, child->GetCachedSize().x);
+ // Layout must set the cached size
+ availableSpace.y += child->GetCachedSize().y;
+ maxWidth = wxMax(maxWidth, child->GetCachedSize().x);
+
+ // If we're just formatting the visible part of the buffer,
+ // and we're now past the bottom of the window, start quick
+ // layout.
+ if (formatRect && child->GetPosition().y > rect.GetBottom())
+ forceQuickLayout = true;
+ }
+ else
+ {
+ // We're outside the immediately affected range, so now let's just
+ // move everything up or down. This assumes that all the children have previously
+ // been laid out and have wrapped line lists associated with them.
+ // TODO: check all paragraphs before the affected range.
+
+ int inc = availableSpace.y - child->GetPosition().y;
+
+ while (node)
+ {
+ wxRichTextParagraph* child = wxDynamicCast(node->GetData(), wxRichTextParagraph);
+ if (child)
+ {
+ if (child->GetLines().GetCount() == 0)
+ child->Layout(dc, availableSpace, style);
+ else
+ child->SetPosition(wxPoint(child->GetPosition().x, child->GetPosition().y + inc));
+
+ availableSpace.y += child->GetCachedSize().y;
+ maxWidth = wxMax(maxWidth, child->GetCachedSize().x);
+ }
+
+ node = node->GetNext();
+ }
+ break;
+ }