Fix layout of content within a floating object by using Move and not SetPosition; prevent creeping of floating objects on layout.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@75354 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Julian Smart
2013-12-05 19:56:24 +00:00
parent a9c26905e8
commit 69b8b92a42

View File

@@ -283,13 +283,24 @@ int wxRichTextFloatCollector::GetFitPosition(const wxRichTextFloatRectMapArray&
int last = start; int last = start;
while (i < (int) array.GetCount()) while (i < (int) array.GetCount())
{ {
// Our object will fit before this object
if (array[i]->startY - last >= height) if (array[i]->startY - last >= height)
return last + 1; {
// If we are fitting after another object, add a pixel since last
// is the bottom of another object.
if (last != start)
last ++;
return last;
}
last = array[i]->endY; last = array[i]->endY;
i++; i++;
} }
return last + 1; // If we are fitting after another object, add a pixel since last
// is the bottom of another object.
if (last != start)
last ++;
return last;
} }
int wxRichTextFloatCollector::GetFitPosition(int direction, int start, int height) const int wxRichTextFloatCollector::GetFitPosition(int direction, int start, int height) const
@@ -1990,7 +2001,7 @@ 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)
{ {
SetPosition(rect.GetPosition()); Move(rect.GetPosition());
if (!IsShown()) if (!IsShown())
return true; return true;
@@ -4917,7 +4928,7 @@ bool wxRichTextParagraph::Layout(wxDC& dc, wxRichTextDrawingContext& context, co
wxSize oldSize = child->GetCachedSize(); wxSize oldSize = child->GetCachedSize();
child->Invalidate(wxRICHTEXT_ALL); child->Invalidate(wxRICHTEXT_ALL);
child->SetPosition(wxPoint(0, 0)); //child->SetPosition(wxPoint(0, 0));
// Lays out the object first with a given amount of space, and then if no width was specified in attr, // Lays out the object first with a given amount of space, and then if no width was specified in attr,
// lays out the object again using the minimum size // lays out the object again using the minimum size
@@ -6423,10 +6434,10 @@ void wxRichTextParagraph::LayoutFloat(wxDC& dc, wxRichTextDrawingContext& contex
int newOffsetY = pos - rect.y; int newOffsetY = pos - rect.y;
if (newOffsetY != offsetY) if (newOffsetY != offsetY)
{ {
if (anchored->GetAttributes().GetTextBoxAttr().GetTop().GetUnits() == wxTEXT_ATTR_UNITS_PIXELS) if (!anchored->GetAttributes().GetTextBoxAttr().GetTop().IsValid() || anchored->GetAttributes().GetTextBoxAttr().GetTop().GetUnits() == wxTEXT_ATTR_UNITS_PIXELS)
{ {
// We unscaled in GetPixels, so apply scale again. // We unscaled in GetPixels, so apply scale again.
anchored->GetAttributes().GetTextBoxAttr().GetTop().SetValue(int((double(newOffsetY) * converter.GetScale()) + 0.5)); anchored->GetAttributes().GetTextBoxAttr().GetTop().SetValue(int((double(newOffsetY) * converter.GetScale()) + 0.5), wxTEXT_ATTR_UNITS_PIXELS);
} }
else else
{ {