- Note that position and size should be calculated separately, because
- for example inserting a paragraph may result in the following paragraphs
- moving down, but not changing in size.
-
- Need to determine how objects specify their position. Absolute coordinates,
- or relative to last object? May be hard to determine that. So should probably
- be in absolute coordinates, in which case we'll need a Move virtual function
- that allows quick movement of all elements without layout.
-
- Let's work through a simple example of layout. Say we're laying out
- a document with the buffer as the top box, with a wxRichTextParagraphLayoutBox
- inside that that consists of wxRichTextParagraph objects.
-
- We're in a mode whereby changes of window size change the width of the
- page (useful for text editors, as opposed to word processors). The
- window width is 600.
-
- We pass (600, -1) to the top-level Layout (i.e. restrict size in horizontal
- direction only). The wxRichTextBuffer box doesn't currently have
- well-defined layout behaviour so we simply assume it has one child
- that fills its parent (later we can define sizer-like box layout behaviour).
- So it passes the same dimensions to the child, which is a wxRichTextParagraphLayoutBox.
- This then looks at each child in turn (wxRichTextParagraph) and determines
- the size the paragraph will take up, setting the cached size, and
- splitting the paragraph into lines.
-
- When the layout for one paragraph returns, the next paragraph is
- fed the position of the previous, so it can position itself.
-
- Each time Layout is called, the cached list of lines for each paragraph
- is recreated, since it can change for example if the parent object width
- changes.
-
- Reporting size
- ==============
-
- Each object can report its size for a given range. It's important that
- it can report a partial size, so that wrapping can be implemented,
- hit test calculations performed, etc. So GetRangeSize must be implemented
- for each object.
-