Improved layout, in particular passed a container size in order to allow relative size calculation
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@70303 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -2010,9 +2010,11 @@ public:
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
Lay the item out at the specified position with the given size constraint.
|
Lay the item out at the specified position with the given size constraint.
|
||||||
Layout must set the cached size.
|
Layout must set the cached size. @rect is the available space for the object,
|
||||||
|
and @a parentRect is the container that is used to determine a relative size
|
||||||
|
or position (for example if a text box must be 50% of the parent text box).
|
||||||
*/
|
*/
|
||||||
virtual bool Layout(wxDC& dc, const wxRect& rect, int style) = 0;
|
virtual bool Layout(wxDC& dc, const wxRect& rect, const wxRect& parentRect, int style) = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Hit-testing: returns a flag indicating hit test details, plus
|
Hit-testing: returns a flag indicating hit test details, plus
|
||||||
@@ -2350,10 +2352,15 @@ public:
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
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. @a availableParentSpace is the maximum space
|
||||||
|
for the object, whereas @a availableContainerSpace is the container with which relative positions and
|
||||||
|
sizes should be computed. For example, a text box whose space has already been constrained
|
||||||
|
in a previous layout pass to @a availableParentSpace, but should have a width of 50% of @a availableContainerSpace.
|
||||||
|
(If these two rects were the same, a 2nd pass could see the object getting too small.)
|
||||||
*/
|
*/
|
||||||
virtual bool LayoutToBestSize(wxDC& dc, wxRichTextBuffer* buffer,
|
virtual bool LayoutToBestSize(wxDC& dc, wxRichTextBuffer* buffer,
|
||||||
const wxRichTextAttr& parentAttr, const wxRichTextAttr& attr, const wxRect& availableParentSpace, int style);
|
const wxRichTextAttr& parentAttr, const wxRichTextAttr& attr,
|
||||||
|
const wxRect& availableParentSpace, const wxRect& availableContainerSpace, int style);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Sets the object's attributes.
|
Sets the object's attributes.
|
||||||
@@ -2504,8 +2511,11 @@ public:
|
|||||||
/**
|
/**
|
||||||
Returns the rectangle which the child has available to it given restrictions specified in the
|
Returns the rectangle which the child has available to it given restrictions specified in the
|
||||||
child attribute, e.g. 50% width of the parent, 400 pixels, x position 20% of the parent, etc.
|
child attribute, e.g. 50% width of the parent, 400 pixels, x position 20% of the parent, etc.
|
||||||
|
availableContainerSpace might be a parent that the cell has to compute its width relative to.
|
||||||
|
E.g. a cell that's 50% of its parent.
|
||||||
*/
|
*/
|
||||||
static wxRect AdjustAvailableSpace(wxDC& dc, wxRichTextBuffer* buffer, const wxRichTextAttr& parentAttr, const wxRichTextAttr& childAttr, const wxRect& availableParentSpace);
|
static wxRect AdjustAvailableSpace(wxDC& dc, wxRichTextBuffer* buffer, const wxRichTextAttr& parentAttr, const wxRichTextAttr& childAttr,
|
||||||
|
const wxRect& availableParentSpace, const wxRect& availableContainerSpace);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
wxSize m_size;
|
wxSize m_size;
|
||||||
@@ -2673,7 +2683,7 @@ public:
|
|||||||
|
|
||||||
virtual bool Draw(wxDC& dc, const wxRichTextRange& range, const wxRichTextSelection& selection, const wxRect& rect, int descent, int style);
|
virtual bool Draw(wxDC& dc, const wxRichTextRange& range, const wxRichTextSelection& selection, const wxRect& rect, int descent, int style);
|
||||||
|
|
||||||
virtual bool Layout(wxDC& dc, const wxRect& rect, int style);
|
virtual bool Layout(wxDC& dc, const wxRect& rect, const wxRect& parentRect, int style);
|
||||||
|
|
||||||
virtual bool GetRangeSize(const wxRichTextRange& range, wxSize& size, int& descent, wxDC& dc, int flags, wxPoint position = wxPoint(0,0), wxArrayInt* partialExtents = NULL) const;
|
virtual bool GetRangeSize(const wxRichTextRange& range, wxSize& size, int& descent, wxDC& dc, int flags, wxPoint position = wxPoint(0,0), wxArrayInt* partialExtents = NULL) const;
|
||||||
|
|
||||||
@@ -3428,7 +3438,7 @@ public:
|
|||||||
|
|
||||||
virtual bool Draw(wxDC& dc, const wxRichTextRange& range, const wxRichTextSelection& selection, const wxRect& rect, int descent, int style);
|
virtual bool Draw(wxDC& dc, const wxRichTextRange& range, const wxRichTextSelection& selection, const wxRect& rect, int descent, int style);
|
||||||
|
|
||||||
virtual bool Layout(wxDC& dc, const wxRect& rect, int style);
|
virtual bool Layout(wxDC& dc, const wxRect& rect, const wxRect& parentRect, int style);
|
||||||
|
|
||||||
virtual bool GetRangeSize(const wxRichTextRange& range, wxSize& size, int& descent, wxDC& dc, int flags, wxPoint position = wxPoint(0,0), wxArrayInt* partialExtents = NULL) const;
|
virtual bool GetRangeSize(const wxRichTextRange& range, wxSize& size, int& descent, wxDC& dc, int flags, wxPoint position = wxPoint(0,0), wxArrayInt* partialExtents = NULL) const;
|
||||||
|
|
||||||
@@ -3599,7 +3609,7 @@ public:
|
|||||||
|
|
||||||
virtual bool Draw(wxDC& dc, const wxRichTextRange& range, const wxRichTextSelection& selection, const wxRect& rect, int descent, int style);
|
virtual bool Draw(wxDC& dc, const wxRichTextRange& range, const wxRichTextSelection& selection, const wxRect& rect, int descent, int style);
|
||||||
|
|
||||||
virtual bool Layout(wxDC& dc, const wxRect& rect, int style);
|
virtual bool Layout(wxDC& dc, const wxRect& rect, const wxRect& parentRect, int style);
|
||||||
|
|
||||||
virtual bool GetRangeSize(const wxRichTextRange& range, wxSize& size, int& descent, wxDC& dc, int flags, wxPoint position = wxPoint(0,0), wxArrayInt* partialExtents = NULL) const;
|
virtual bool GetRangeSize(const wxRichTextRange& range, wxSize& size, int& descent, wxDC& dc, int flags, wxPoint position = wxPoint(0,0), wxArrayInt* partialExtents = NULL) const;
|
||||||
|
|
||||||
@@ -3875,7 +3885,7 @@ public:
|
|||||||
|
|
||||||
virtual bool Draw(wxDC& dc, const wxRichTextRange& range, const wxRichTextSelection& selection, const wxRect& rect, int descent, int style);
|
virtual bool Draw(wxDC& dc, const wxRichTextRange& range, const wxRichTextSelection& selection, const wxRect& rect, int descent, int style);
|
||||||
|
|
||||||
virtual bool Layout(wxDC& dc, const wxRect& rect, int style);
|
virtual bool Layout(wxDC& dc, const wxRect& rect, const wxRect& parentRect, int style);
|
||||||
|
|
||||||
virtual bool GetRangeSize(const wxRichTextRange& range, wxSize& size, int& descent, wxDC& dc, int flags, wxPoint position = wxPoint(0,0), wxArrayInt* partialExtents = NULL) const;
|
virtual bool GetRangeSize(const wxRichTextRange& range, wxSize& size, int& descent, wxDC& dc, int flags, wxPoint position = wxPoint(0,0), wxArrayInt* partialExtents = NULL) const;
|
||||||
|
|
||||||
@@ -4723,7 +4733,7 @@ public:
|
|||||||
|
|
||||||
virtual wxString GetXMLNodeName() const { return wxT("table"); }
|
virtual wxString GetXMLNodeName() const { return wxT("table"); }
|
||||||
|
|
||||||
virtual bool Layout(wxDC& dc, const wxRect& rect, int style);
|
virtual bool Layout(wxDC& dc, const wxRect& rect, const wxRect& parentRect, int style);
|
||||||
|
|
||||||
virtual bool GetRangeSize(const wxRichTextRange& range, wxSize& size, int& descent, wxDC& dc, int flags, wxPoint position = wxPoint(0,0), wxArrayInt* partialExtents = NULL) const;
|
virtual bool GetRangeSize(const wxRichTextRange& range, wxSize& size, int& descent, wxDC& dc, int flags, wxPoint position = wxPoint(0,0), wxArrayInt* partialExtents = NULL) const;
|
||||||
|
|
||||||
|
@@ -1894,9 +1894,11 @@ public:
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
Lay the item out at the specified position with the given size constraint.
|
Lay the item out at the specified position with the given size constraint.
|
||||||
Layout must set the cached size.
|
Layout must set the cached size. @rect is the available space for the object,
|
||||||
|
and @a parentRect is the container that is used to determine a relative size
|
||||||
|
or position (for example if a text box must be 50% of the parent text box).
|
||||||
*/
|
*/
|
||||||
virtual bool Layout(wxDC& dc, const wxRect& rect, int style) = 0;
|
virtual bool Layout(wxDC& dc, const wxRect& rect, const wxRect& parentRect, int style) = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Hit-testing: returns a flag indicating hit test details, plus
|
Hit-testing: returns a flag indicating hit test details, plus
|
||||||
@@ -2230,10 +2232,15 @@ public:
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
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. @a availableParentSpace is the maximum space
|
||||||
|
for the object, whereas @a availableContainerSpace is the container with which relative positions and
|
||||||
|
sizes should be computed. For example, a text box whose space has already been constrained
|
||||||
|
in a previous layout pass to @a availableParentSpace, but should have a width of 50% of @a availableContainerSpace.
|
||||||
|
(If these two rects were the same, a 2nd pass could see the object getting too small.)
|
||||||
*/
|
*/
|
||||||
virtual bool LayoutToBestSize(wxDC& dc, wxRichTextBuffer* buffer,
|
virtual bool LayoutToBestSize(wxDC& dc, wxRichTextBuffer* buffer,
|
||||||
const wxRichTextAttr& parentAttr, const wxRichTextAttr& attr, const wxRect& availableParentSpace, int style);
|
const wxRichTextAttr& parentAttr, const wxRichTextAttr& attr,
|
||||||
|
const wxRect& availableParentSpace, const wxRect& availableContainerSpace, int style);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Sets the object's attributes.
|
Sets the object's attributes.
|
||||||
@@ -2384,8 +2391,11 @@ public:
|
|||||||
/**
|
/**
|
||||||
Returns the rectangle which the child has available to it given restrictions specified in the
|
Returns the rectangle which the child has available to it given restrictions specified in the
|
||||||
child attribute, e.g. 50% width of the parent, 400 pixels, x position 20% of the parent, etc.
|
child attribute, e.g. 50% width of the parent, 400 pixels, x position 20% of the parent, etc.
|
||||||
|
availableContainerSpace might be a parent that the cell has to compute its width relative to.
|
||||||
|
E.g. a cell that's 50% of its parent.
|
||||||
*/
|
*/
|
||||||
static wxRect AdjustAvailableSpace(wxDC& dc, wxRichTextBuffer* buffer, const wxRichTextAttr& parentAttr, const wxRichTextAttr& childAttr, const wxRect& availableParentSpace);
|
static wxRect AdjustAvailableSpace(wxDC& dc, wxRichTextBuffer* buffer, const wxRichTextAttr& parentAttr, const wxRichTextAttr& childAttr,
|
||||||
|
const wxRect& availableParentSpace, const wxRect& availableContainerSpace);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
wxSize m_size;
|
wxSize m_size;
|
||||||
@@ -2553,7 +2563,7 @@ public:
|
|||||||
|
|
||||||
virtual bool Draw(wxDC& dc, const wxRichTextRange& range, const wxRichTextSelection& selection, const wxRect& rect, int descent, int style);
|
virtual bool Draw(wxDC& dc, const wxRichTextRange& range, const wxRichTextSelection& selection, const wxRect& rect, int descent, int style);
|
||||||
|
|
||||||
virtual bool Layout(wxDC& dc, const wxRect& rect, int style);
|
virtual bool Layout(wxDC& dc, const wxRect& rect, const wxRect& parentRect, int style);
|
||||||
|
|
||||||
virtual bool GetRangeSize(const wxRichTextRange& range, wxSize& size, int& descent, wxDC& dc, int flags, wxPoint position = wxPoint(0,0), wxArrayInt* partialExtents = NULL) const;
|
virtual bool GetRangeSize(const wxRichTextRange& range, wxSize& size, int& descent, wxDC& dc, int flags, wxPoint position = wxPoint(0,0), wxArrayInt* partialExtents = NULL) const;
|
||||||
|
|
||||||
@@ -3309,7 +3319,7 @@ public:
|
|||||||
|
|
||||||
virtual bool Draw(wxDC& dc, const wxRichTextRange& range, const wxRichTextSelection& selection, const wxRect& rect, int descent, int style);
|
virtual bool Draw(wxDC& dc, const wxRichTextRange& range, const wxRichTextSelection& selection, const wxRect& rect, int descent, int style);
|
||||||
|
|
||||||
virtual bool Layout(wxDC& dc, const wxRect& rect, int style);
|
virtual bool Layout(wxDC& dc, const wxRect& rect, const wxRect& parentRect, int style);
|
||||||
|
|
||||||
virtual bool GetRangeSize(const wxRichTextRange& range, wxSize& size, int& descent, wxDC& dc, int flags, wxPoint position = wxPoint(0,0), wxArrayInt* partialExtents = NULL) const;
|
virtual bool GetRangeSize(const wxRichTextRange& range, wxSize& size, int& descent, wxDC& dc, int flags, wxPoint position = wxPoint(0,0), wxArrayInt* partialExtents = NULL) const;
|
||||||
|
|
||||||
@@ -3480,7 +3490,7 @@ public:
|
|||||||
|
|
||||||
virtual bool Draw(wxDC& dc, const wxRichTextRange& range, const wxRichTextSelection& selection, const wxRect& rect, int descent, int style);
|
virtual bool Draw(wxDC& dc, const wxRichTextRange& range, const wxRichTextSelection& selection, const wxRect& rect, int descent, int style);
|
||||||
|
|
||||||
virtual bool Layout(wxDC& dc, const wxRect& rect, int style);
|
virtual bool Layout(wxDC& dc, const wxRect& rect, const wxRect& parentRect, int style);
|
||||||
|
|
||||||
virtual bool GetRangeSize(const wxRichTextRange& range, wxSize& size, int& descent, wxDC& dc, int flags, wxPoint position = wxPoint(0,0), wxArrayInt* partialExtents = NULL) const;
|
virtual bool GetRangeSize(const wxRichTextRange& range, wxSize& size, int& descent, wxDC& dc, int flags, wxPoint position = wxPoint(0,0), wxArrayInt* partialExtents = NULL) const;
|
||||||
|
|
||||||
@@ -3756,7 +3766,7 @@ public:
|
|||||||
|
|
||||||
virtual bool Draw(wxDC& dc, const wxRichTextRange& range, const wxRichTextSelection& selection, const wxRect& rect, int descent, int style);
|
virtual bool Draw(wxDC& dc, const wxRichTextRange& range, const wxRichTextSelection& selection, const wxRect& rect, int descent, int style);
|
||||||
|
|
||||||
virtual bool Layout(wxDC& dc, const wxRect& rect, int style);
|
virtual bool Layout(wxDC& dc, const wxRect& rect, const wxRect& parentRect, int style);
|
||||||
|
|
||||||
virtual bool GetRangeSize(const wxRichTextRange& range, wxSize& size, int& descent, wxDC& dc, int flags, wxPoint position = wxPoint(0,0), wxArrayInt* partialExtents = NULL) const;
|
virtual bool GetRangeSize(const wxRichTextRange& range, wxSize& size, int& descent, wxDC& dc, int flags, wxPoint position = wxPoint(0,0), wxArrayInt* partialExtents = NULL) const;
|
||||||
|
|
||||||
@@ -4604,7 +4614,7 @@ public:
|
|||||||
|
|
||||||
virtual wxString GetXMLNodeName() const { return wxT("table"); }
|
virtual wxString GetXMLNodeName() const { return wxT("table"); }
|
||||||
|
|
||||||
virtual bool Layout(wxDC& dc, const wxRect& rect, int style);
|
virtual bool Layout(wxDC& dc, const wxRect& rect, const wxRect& parentRect, int style);
|
||||||
|
|
||||||
virtual bool GetRangeSize(const wxRichTextRange& range, wxSize& size, int& descent, wxDC& dc, int flags, wxPoint position = wxPoint(0,0), wxArrayInt* partialExtents = NULL) const;
|
virtual bool GetRangeSize(const wxRichTextRange& range, wxSize& size, int& descent, wxDC& dc, int flags, wxPoint position = wxPoint(0,0), wxArrayInt* partialExtents = NULL) const;
|
||||||
|
|
||||||
|
@@ -953,14 +953,16 @@ bool wxRichTextObject::GetTotalMargin(wxDC& dc, wxRichTextBuffer* buffer, const
|
|||||||
|
|
||||||
// Returns the rectangle which the child has available to it given restrictions specified in the
|
// Returns the rectangle which the child has available to it given restrictions specified in the
|
||||||
// child attribute, e.g. 50% width of the parent, 400 pixels, x position 20% of the parent, etc.
|
// child attribute, e.g. 50% width of the parent, 400 pixels, x position 20% of the parent, etc.
|
||||||
wxRect wxRichTextObject::AdjustAvailableSpace(wxDC& dc, wxRichTextBuffer* buffer, const wxRichTextAttr& WXUNUSED(parentAttr), const wxRichTextAttr& childAttr, const wxRect& availableParentSpace)
|
// availableContainerSpace might be a parent that the cell has to compute its width relative to.
|
||||||
|
// E.g. a cell that's 50% of its parent.
|
||||||
|
wxRect wxRichTextObject::AdjustAvailableSpace(wxDC& dc, wxRichTextBuffer* buffer, const wxRichTextAttr& WXUNUSED(parentAttr), const wxRichTextAttr& childAttr, const wxRect& availableParentSpace, const wxRect& availableContainerSpace)
|
||||||
{
|
{
|
||||||
wxRect rect = availableParentSpace;
|
wxRect rect = availableParentSpace;
|
||||||
double scale = 1.0;
|
double scale = 1.0;
|
||||||
if (buffer)
|
if (buffer)
|
||||||
scale = buffer->GetScale();
|
scale = buffer->GetScale();
|
||||||
|
|
||||||
wxTextAttrDimensionConverter converter(dc, scale, availableParentSpace.GetSize());
|
wxTextAttrDimensionConverter converter(dc, scale, availableContainerSpace.GetSize());
|
||||||
|
|
||||||
if (childAttr.GetTextBoxAttr().GetWidth().IsValid())
|
if (childAttr.GetTextBoxAttr().GetWidth().IsValid())
|
||||||
rect.width = converter.GetPixels(childAttr.GetTextBoxAttr().GetWidth());
|
rect.width = converter.GetPixels(childAttr.GetTextBoxAttr().GetWidth());
|
||||||
@@ -978,7 +980,7 @@ wxRect wxRichTextObject::AdjustAvailableSpace(wxDC& dc, wxRichTextBuffer* buffer
|
|||||||
{
|
{
|
||||||
int x = converter.GetPixels(childAttr.GetTextBoxAttr().GetPosition().GetRight());
|
int x = converter.GetPixels(childAttr.GetTextBoxAttr().GetPosition().GetRight());
|
||||||
if (childAttr.GetTextBoxAttr().GetPosition().GetRight().GetPosition() == wxTEXT_BOX_ATTR_POSITION_RELATIVE)
|
if (childAttr.GetTextBoxAttr().GetPosition().GetRight().GetPosition() == wxTEXT_BOX_ATTR_POSITION_RELATIVE)
|
||||||
rect.x = availableParentSpace.x + availableParentSpace.width - rect.width;
|
rect.x = availableContainerSpace.x + availableContainerSpace.width - rect.width;
|
||||||
else
|
else
|
||||||
rect.x += x;
|
rect.x += x;
|
||||||
}
|
}
|
||||||
@@ -991,11 +993,14 @@ wxRect wxRichTextObject::AdjustAvailableSpace(wxDC& dc, wxRichTextBuffer* buffer
|
|||||||
{
|
{
|
||||||
int y = converter.GetPixels(childAttr.GetTextBoxAttr().GetPosition().GetBottom());
|
int y = converter.GetPixels(childAttr.GetTextBoxAttr().GetPosition().GetBottom());
|
||||||
if (childAttr.GetTextBoxAttr().GetPosition().GetBottom().GetPosition() == wxTEXT_BOX_ATTR_POSITION_RELATIVE)
|
if (childAttr.GetTextBoxAttr().GetPosition().GetBottom().GetPosition() == wxTEXT_BOX_ATTR_POSITION_RELATIVE)
|
||||||
rect.y = availableParentSpace.y + availableParentSpace.height - rect.height;
|
rect.y = availableContainerSpace.y + availableContainerSpace.height - rect.height;
|
||||||
else
|
else
|
||||||
rect.y += y;
|
rect.y += y;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (rect.GetWidth() > availableParentSpace.GetWidth())
|
||||||
|
rect.SetWidth(availableParentSpace.GetWidth());
|
||||||
|
|
||||||
return rect;
|
return rect;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1054,18 +1059,19 @@ int wxRichTextObject::HitTest(wxDC& WXUNUSED(dc), const wxPoint& pt, long& textP
|
|||||||
// 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 maximum ('best') size
|
// lays out the object again using the maximum ('best') size
|
||||||
bool wxRichTextObject::LayoutToBestSize(wxDC& dc, wxRichTextBuffer* buffer,
|
bool wxRichTextObject::LayoutToBestSize(wxDC& dc, wxRichTextBuffer* buffer,
|
||||||
const wxRichTextAttr& parentAttr, const wxRichTextAttr& attr, const wxRect& availableParentSpace,
|
const wxRichTextAttr& parentAttr, const wxRichTextAttr& attr,
|
||||||
|
const wxRect& availableParentSpace, const wxRect& availableContainerSpace,
|
||||||
int style)
|
int style)
|
||||||
{
|
{
|
||||||
wxRect availableChildRect = AdjustAvailableSpace(dc, buffer, parentAttr, attr, availableParentSpace);
|
wxRect availableChildRect = AdjustAvailableSpace(dc, buffer, parentAttr, attr, availableParentSpace, availableContainerSpace);
|
||||||
wxRect originalAvailableRect = availableChildRect;
|
wxRect originalAvailableRect = availableChildRect;
|
||||||
Layout(dc, availableChildRect, style);
|
Layout(dc, availableChildRect, availableContainerSpace, style);
|
||||||
|
|
||||||
wxSize maxSize = GetMaxSize();
|
wxSize maxSize = GetMaxSize();
|
||||||
|
|
||||||
// Don't ignore if maxSize.x is zero, since we need to redo the paragraph's lines
|
// Don't ignore if maxSize.x is zero, since we need to redo the paragraph's lines
|
||||||
// on this basis
|
// on this basis
|
||||||
if (!attr.GetTextBoxAttr().GetWidth().IsValid() && maxSize.x < availableChildRect.width /* && maxSize.x > 0 */)
|
if (!attr.GetTextBoxAttr().GetWidth().IsValid() && maxSize.x < availableChildRect.width)
|
||||||
{
|
{
|
||||||
// Redo the layout with a fixed, minimum size this time.
|
// Redo the layout with a fixed, minimum size this time.
|
||||||
Invalidate(wxRICHTEXT_ALL);
|
Invalidate(wxRICHTEXT_ALL);
|
||||||
@@ -1073,7 +1079,7 @@ bool wxRichTextObject::LayoutToBestSize(wxDC& dc, wxRichTextBuffer* buffer,
|
|||||||
newAttr.GetTextBoxAttr().GetWidth().SetValue(maxSize.x, wxTEXT_ATTR_UNITS_PIXELS);
|
newAttr.GetTextBoxAttr().GetWidth().SetValue(maxSize.x, wxTEXT_ATTR_UNITS_PIXELS);
|
||||||
newAttr.GetTextBoxAttr().GetWidth().SetPosition(wxTEXT_BOX_ATTR_POSITION_ABSOLUTE);
|
newAttr.GetTextBoxAttr().GetWidth().SetPosition(wxTEXT_BOX_ATTR_POSITION_ABSOLUTE);
|
||||||
|
|
||||||
availableChildRect = AdjustAvailableSpace(dc, buffer, parentAttr, newAttr, availableParentSpace);
|
availableChildRect = AdjustAvailableSpace(dc, buffer, parentAttr, newAttr, availableParentSpace, availableContainerSpace);
|
||||||
|
|
||||||
// If a paragraph, align the whole paragraph.
|
// If a paragraph, align the whole paragraph.
|
||||||
// Problem with this: if we're limited by a floating object, a line may be centered
|
// Problem with this: if we're limited by a floating object, a line may be centered
|
||||||
@@ -1091,7 +1097,7 @@ bool wxRichTextObject::LayoutToBestSize(wxDC& dc, wxRichTextBuffer* buffer,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Layout(dc, availableChildRect, style);
|
Layout(dc, availableChildRect, availableContainerSpace, style);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -1816,7 +1822,7 @@ bool wxRichTextParagraphLayoutBox::Draw(wxDC& dc, const wxRichTextRange& range,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Lay the item out
|
/// Lay the item out
|
||||||
bool wxRichTextParagraphLayoutBox::Layout(wxDC& dc, const wxRect& rect, int style)
|
bool wxRichTextParagraphLayoutBox::Layout(wxDC& dc, const wxRect& rect, const wxRect& parentRect, int style)
|
||||||
{
|
{
|
||||||
SetPosition(rect.GetPosition());
|
SetPosition(rect.GetPosition());
|
||||||
|
|
||||||
@@ -1947,7 +1953,7 @@ bool wxRichTextParagraphLayoutBox::Layout(wxDC& dc, const wxRect& rect, int styl
|
|||||||
// 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
|
||||||
child->LayoutToBestSize(dc, GetBuffer(),
|
child->LayoutToBestSize(dc, GetBuffer(),
|
||||||
GetAttributes(), child->GetAttributes(), availableSpace, style&~wxRICHTEXT_LAYOUT_SPECIFIED_RECT);
|
GetAttributes(), child->GetAttributes(), availableSpace, rect, style&~wxRICHTEXT_LAYOUT_SPECIFIED_RECT);
|
||||||
|
|
||||||
// Layout must set the cached size
|
// Layout must set the cached size
|
||||||
availableSpace.y += child->GetCachedSize().y;
|
availableSpace.y += child->GetCachedSize().y;
|
||||||
@@ -1981,7 +1987,7 @@ bool wxRichTextParagraphLayoutBox::Layout(wxDC& dc, const wxRect& rect, int styl
|
|||||||
// 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
|
||||||
child->LayoutToBestSize(dc, GetBuffer(),
|
child->LayoutToBestSize(dc, GetBuffer(),
|
||||||
GetAttributes(), child->GetAttributes(), availableSpace, style&~wxRICHTEXT_LAYOUT_SPECIFIED_RECT);
|
GetAttributes(), child->GetAttributes(), availableSpace, rect, style&~wxRICHTEXT_LAYOUT_SPECIFIED_RECT);
|
||||||
|
|
||||||
//child->Layout(dc, availableChildRect, style);
|
//child->Layout(dc, availableChildRect, style);
|
||||||
}
|
}
|
||||||
@@ -2007,12 +2013,22 @@ bool wxRichTextParagraphLayoutBox::Layout(wxDC& dc, const wxRect& rect, int styl
|
|||||||
if (node && node->GetData()->IsShown())
|
if (node && node->GetData()->IsShown())
|
||||||
{
|
{
|
||||||
wxRichTextObject* child = node->GetData();
|
wxRichTextObject* child = node->GetData();
|
||||||
// maxHeight = (child->GetPosition().y - GetPosition().y) + child->GetCachedSize().y;
|
|
||||||
maxHeight = child->GetPosition().y - (GetPosition().y + topMargin) + child->GetCachedSize().y;
|
maxHeight = child->GetPosition().y - (GetPosition().y + topMargin) + child->GetCachedSize().y;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
maxHeight = 0; // topMargin + bottomMargin;
|
maxHeight = 0; // topMargin + bottomMargin;
|
||||||
|
|
||||||
|
if (GetAttributes().GetTextBoxAttr().GetSize().GetWidth().IsValid())
|
||||||
|
{
|
||||||
|
wxRect r = AdjustAvailableSpace(dc, GetBuffer(), wxRichTextAttr() /* not used */, GetAttributes(), parentRect, parentRect);
|
||||||
|
int w = r.GetWidth();
|
||||||
|
|
||||||
|
// Convert external to content rect
|
||||||
|
w = w - leftMargin - rightMargin;
|
||||||
|
maxWidth = wxMax(maxWidth, w);
|
||||||
|
maxMaxWidth = wxMax(maxMaxWidth, w);
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: (also in para layout) should set the
|
// TODO: (also in para layout) should set the
|
||||||
// object's size to an absolute one if specified,
|
// object's size to an absolute one if specified,
|
||||||
// but if not specified, calculate it from content.
|
// but if not specified, calculate it from content.
|
||||||
@@ -3884,7 +3900,9 @@ bool wxRichTextParagraphLayoutBox::DoNumberList(const wxRichTextRange& range, co
|
|||||||
levels[i] = -1; // start from the number we found, if any
|
levels[i] = -1; // start from the number we found, if any
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if wxDEBUG_LEVEL
|
||||||
wxASSERT(!specifyLevel || (specifyLevel && (specifiedLevel >= 0)));
|
wxASSERT(!specifyLevel || (specifyLevel && (specifiedLevel >= 0)));
|
||||||
|
#endif
|
||||||
|
|
||||||
// If we are associated with a control, make undoable; otherwise, apply immediately
|
// If we are associated with a control, make undoable; otherwise, apply immediately
|
||||||
// to the data.
|
// to the data.
|
||||||
@@ -4329,7 +4347,7 @@ static int wxRichTextGetRangeWidth(const wxRichTextParagraph& para, const wxRich
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Lay the item out
|
/// Lay the item out
|
||||||
bool wxRichTextParagraph::Layout(wxDC& dc, const wxRect& rect, int style)
|
bool wxRichTextParagraph::Layout(wxDC& dc, const wxRect& rect, const wxRect& parentRect, int style)
|
||||||
{
|
{
|
||||||
// Deal with floating objects firstly before the normal layout
|
// Deal with floating objects firstly before the normal layout
|
||||||
wxRichTextBuffer* buffer = GetBuffer();
|
wxRichTextBuffer* buffer = GetBuffer();
|
||||||
@@ -4469,7 +4487,7 @@ bool wxRichTextParagraph::Layout(wxDC& dc, const wxRect& rect, int style)
|
|||||||
// The position will be determined by its location in its line,
|
// The position will be determined by its location in its line,
|
||||||
// and not by the child's actual position.
|
// and not by the child's actual position.
|
||||||
child->LayoutToBestSize(dc, buffer,
|
child->LayoutToBestSize(dc, buffer,
|
||||||
GetAttributes(), child->GetAttributes(), availableRect, style);
|
GetAttributes(), child->GetAttributes(), availableRect, parentRect, style);
|
||||||
|
|
||||||
if (oldSize != child->GetCachedSize())
|
if (oldSize != child->GetCachedSize())
|
||||||
{
|
{
|
||||||
@@ -4553,7 +4571,7 @@ bool wxRichTextParagraph::Layout(wxDC& dc, const wxRect& rect, int style)
|
|||||||
// lays out the object again using the minimum size
|
// lays out the object again using the minimum size
|
||||||
child->Invalidate(wxRICHTEXT_ALL);
|
child->Invalidate(wxRICHTEXT_ALL);
|
||||||
child->LayoutToBestSize(dc, buffer,
|
child->LayoutToBestSize(dc, buffer,
|
||||||
GetAttributes(), child->GetAttributes(), availableRect, style);
|
GetAttributes(), child->GetAttributes(), availableRect, parentRect, style);
|
||||||
childSize = child->GetCachedSize();
|
childSize = child->GetCachedSize();
|
||||||
childDescent = child->GetDescent();
|
childDescent = child->GetDescent();
|
||||||
//child->SetPosition(availableRect.GetPosition());
|
//child->SetPosition(availableRect.GetPosition());
|
||||||
@@ -6223,7 +6241,7 @@ bool wxRichTextPlainText::DrawTabbedString(wxDC& dc, const wxRichTextAttr& attr,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Lay the item out
|
/// Lay the item out
|
||||||
bool wxRichTextPlainText::Layout(wxDC& dc, const wxRect& WXUNUSED(rect), int WXUNUSED(style))
|
bool wxRichTextPlainText::Layout(wxDC& dc, const wxRect& WXUNUSED(rect), const wxRect& WXUNUSED(parentRect), int WXUNUSED(style))
|
||||||
{
|
{
|
||||||
// Only lay out if we haven't already cached the size
|
// Only lay out if we haven't already cached the size
|
||||||
if (m_size.x == -1)
|
if (m_size.x == -1)
|
||||||
@@ -8120,7 +8138,7 @@ WX_DEFINE_OBJARRAY(wxRichTextRectArray);
|
|||||||
// layout to a particular size, or it could be the total space available in the
|
// layout to a particular size, or it could be the total space available in the
|
||||||
// parent. rect is the overall size, so we must subtract margins and padding.
|
// parent. rect is the overall size, so we must subtract margins and padding.
|
||||||
// to get the actual available space.
|
// to get the actual available space.
|
||||||
bool wxRichTextTable::Layout(wxDC& dc, const wxRect& rect, int style)
|
bool wxRichTextTable::Layout(wxDC& dc, const wxRect& rect, const wxRect& WXUNUSED(parentRect), int style)
|
||||||
{
|
{
|
||||||
SetPosition(rect.GetPosition());
|
SetPosition(rect.GetPosition());
|
||||||
|
|
||||||
@@ -8181,16 +8199,21 @@ bool wxRichTextTable::Layout(wxDC& dc, const wxRect& rect, int style)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// The final calculated widths
|
// The final calculated widths
|
||||||
wxArrayInt colWidths(m_colCount);
|
wxArrayInt colWidths;
|
||||||
|
colWidths.Add(0, m_colCount);
|
||||||
|
|
||||||
wxArrayInt absoluteColWidths(m_colCount);
|
wxArrayInt absoluteColWidths;
|
||||||
|
absoluteColWidths.Add(0, m_colCount);
|
||||||
// wxArrayInt absoluteColWidthsSpanning(m_colCount);
|
// wxArrayInt absoluteColWidthsSpanning(m_colCount);
|
||||||
wxArrayInt percentageColWidths(m_colCount);
|
wxArrayInt percentageColWidths;
|
||||||
|
percentageColWidths.Add(0, m_colCount);
|
||||||
// wxArrayInt percentageColWidthsSpanning(m_colCount);
|
// wxArrayInt percentageColWidthsSpanning(m_colCount);
|
||||||
// These are only relevant when the first column contains spanning information.
|
// These are only relevant when the first column contains spanning information.
|
||||||
// wxArrayInt columnSpans(m_colCount); // Each contains 1 for non-spanning cell, > 1 for spanning cell.
|
// wxArrayInt columnSpans(m_colCount); // Each contains 1 for non-spanning cell, > 1 for spanning cell.
|
||||||
wxArrayInt maxColWidths(m_colCount);
|
wxArrayInt maxColWidths;
|
||||||
wxArrayInt minColWidths(m_colCount);
|
maxColWidths.Add(0, m_colCount);
|
||||||
|
wxArrayInt minColWidths;
|
||||||
|
minColWidths.Add(0, m_colCount);
|
||||||
|
|
||||||
wxSize tableSize(tableWidth, 0);
|
wxSize tableSize(tableWidth, 0);
|
||||||
|
|
||||||
@@ -8332,7 +8355,7 @@ bool wxRichTextTable::Layout(wxDC& dc, const wxRect& rect, int style)
|
|||||||
|
|
||||||
// Lay out cell to find min/max widths
|
// Lay out cell to find min/max widths
|
||||||
cell->Invalidate(wxRICHTEXT_ALL);
|
cell->Invalidate(wxRICHTEXT_ALL);
|
||||||
cell->Layout(dc, availableSpace, style);
|
cell->Layout(dc, availableSpace, availableSpace, style);
|
||||||
|
|
||||||
if (colSpan == 1)
|
if (colSpan == 1)
|
||||||
{
|
{
|
||||||
@@ -8623,7 +8646,8 @@ bool wxRichTextTable::Layout(wxDC& dc, const wxRect& rect, int style)
|
|||||||
int maxCellHeight = 0;
|
int maxCellHeight = 0;
|
||||||
int maxSpecifiedCellHeight = 0;
|
int maxSpecifiedCellHeight = 0;
|
||||||
|
|
||||||
wxArrayInt actualWidths(m_colCount);
|
wxArrayInt actualWidths;
|
||||||
|
actualWidths.Add(0, m_colCount);
|
||||||
|
|
||||||
wxTextAttrDimensionConverter converter(dc, scale);
|
wxTextAttrDimensionConverter converter(dc, scale);
|
||||||
for (i = 0; i < m_colCount; i++)
|
for (i = 0; i < m_colCount; i++)
|
||||||
@@ -8670,7 +8694,7 @@ bool wxRichTextTable::Layout(wxDC& dc, const wxRect& rect, int style)
|
|||||||
|
|
||||||
// Lay out cell
|
// Lay out cell
|
||||||
cell->Invalidate(wxRICHTEXT_ALL);
|
cell->Invalidate(wxRICHTEXT_ALL);
|
||||||
cell->Layout(dc, availableCellSpace, style);
|
cell->Layout(dc, availableCellSpace, availableSpace, style);
|
||||||
|
|
||||||
// TODO: use GetCachedSize().x to compute 'natural' size
|
// TODO: use GetCachedSize().x to compute 'natural' size
|
||||||
|
|
||||||
@@ -8691,7 +8715,7 @@ bool wxRichTextTable::Layout(wxDC& dc, const wxRect& rect, int style)
|
|||||||
wxRect availableCellSpace = wxRect(cell->GetPosition(), wxSize(actualWidths[i], maxCellHeight));
|
wxRect availableCellSpace = wxRect(cell->GetPosition(), wxSize(actualWidths[i], maxCellHeight));
|
||||||
// Lay out cell with new height
|
// Lay out cell with new height
|
||||||
cell->Invalidate(wxRICHTEXT_ALL);
|
cell->Invalidate(wxRICHTEXT_ALL);
|
||||||
cell->Layout(dc, availableCellSpace, style);
|
cell->Layout(dc, availableCellSpace, availableSpace, style);
|
||||||
|
|
||||||
// Make sure the cell size really is the appropriate size,
|
// Make sure the cell size really is the appropriate size,
|
||||||
// not the calculated box size
|
// not the calculated box size
|
||||||
@@ -9949,7 +9973,7 @@ bool wxRichTextImage::Draw(wxDC& dc, const wxRichTextRange& range, const wxRichT
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Lay the item out
|
/// Lay the item out
|
||||||
bool wxRichTextImage::Layout(wxDC& dc, const wxRect& rect, int WXUNUSED(style))
|
bool wxRichTextImage::Layout(wxDC& dc, const wxRect& rect, const wxRect& WXUNUSED(parentRect), int WXUNUSED(style))
|
||||||
{
|
{
|
||||||
if (!LoadImageCache(dc))
|
if (!LoadImageCache(dc))
|
||||||
return false;
|
return false;
|
||||||
|
@@ -446,7 +446,7 @@ void wxRichTextCtrl::OnPaint(wxPaintEvent& WXUNUSED(event))
|
|||||||
wxRect availableSpace(GetClientSize());
|
wxRect availableSpace(GetClientSize());
|
||||||
if (GetBuffer().IsDirty())
|
if (GetBuffer().IsDirty())
|
||||||
{
|
{
|
||||||
GetBuffer().Layout(dc, availableSpace, wxRICHTEXT_FIXED_WIDTH|wxRICHTEXT_VARIABLE_HEIGHT);
|
GetBuffer().Layout(dc, availableSpace, availableSpace, wxRICHTEXT_FIXED_WIDTH|wxRICHTEXT_VARIABLE_HEIGHT);
|
||||||
GetBuffer().Invalidate(wxRICHTEXT_NONE);
|
GetBuffer().Invalidate(wxRICHTEXT_NONE);
|
||||||
SetupScrollbars();
|
SetupScrollbars();
|
||||||
}
|
}
|
||||||
@@ -3745,7 +3745,7 @@ bool wxRichTextCtrl::LayoutContent(bool onlyVisibleRect)
|
|||||||
|
|
||||||
GetBuffer().Defragment();
|
GetBuffer().Defragment();
|
||||||
GetBuffer().UpdateRanges(); // If items were deleted, ranges need recalculation
|
GetBuffer().UpdateRanges(); // If items were deleted, ranges need recalculation
|
||||||
GetBuffer().Layout(dc, availableSpace, flags);
|
GetBuffer().Layout(dc, availableSpace, availableSpace, flags);
|
||||||
GetBuffer().Invalidate(wxRICHTEXT_NONE);
|
GetBuffer().Invalidate(wxRICHTEXT_NONE);
|
||||||
|
|
||||||
if (!IsFrozen())
|
if (!IsFrozen())
|
||||||
|
@@ -67,7 +67,7 @@ void wxRichTextPrintout::OnPreparePrinting()
|
|||||||
{
|
{
|
||||||
GetRichTextBuffer()->Invalidate(wxRICHTEXT_ALL);
|
GetRichTextBuffer()->Invalidate(wxRICHTEXT_ALL);
|
||||||
|
|
||||||
GetRichTextBuffer()->Layout(*GetDC(), rect, wxRICHTEXT_FIXED_WIDTH|wxRICHTEXT_VARIABLE_HEIGHT);
|
GetRichTextBuffer()->Layout(*GetDC(), rect, rect, wxRICHTEXT_FIXED_WIDTH|wxRICHTEXT_VARIABLE_HEIGHT);
|
||||||
|
|
||||||
// Now calculate the page breaks
|
// Now calculate the page breaks
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user