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:
Julian Smart
2012-01-09 14:19:50 +00:00
parent d9384bfb6d
commit bb7bbd12d3
5 changed files with 101 additions and 57 deletions

View File

@@ -2010,9 +2010,11 @@ public:
/**
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
@@ -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 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,
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.
@@ -2504,8 +2511,11 @@ public:
/**
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.
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:
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 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;
@@ -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 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;
@@ -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 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;
@@ -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 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;
@@ -4723,7 +4733,7 @@ public:
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;