Skip to content

Latest commit

 

History

History
 
 

richtext

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Implement detail of floating layout

1. Data Structure

Mainly, we maintain two floating list data for a wxRichTextBuffer.
'struct FloatRectMap' is used to represent a floating object's region,
and 'class wxFloatCollector' is a container of all 'struct FloatRectMap'.
It maintains all the information of the positions of all the floating
objects with two list of 'struct FloatRectMap', one for objects floated
to left and the other for right.

wxRichTextAnchoredObject is introduced to represent a kind of objects
that can be floated. wxRichTextImage is made to be a child class of
this one. In future, we may introduce some other floating object type
like wxRichTextTable. And we also introduce a twin object of this one,
it is wxRichTextPlaceHoldingObject. When the object is set to be a
floating one, we will place a 'placing holding' object in its origin
position, this makes us to record the position of the object correctly
even if the containing paragraph change its content.

Also, along with wxRichTextAnchoredObject, we also introduce a 
wxRichTextAnchoredObjectAttr class, which contains the attributes of
floating direction, floating offset and etc. wxRichTextImageAttr is made
to be a subclass of this one.

Finally, wxRichTextImageDlg is a image control dialog, in which users can
set the alignment, floating direction, size, offset of the image, in addition,
users can also move the image between paragraph with this dialog.

2. Layout Algorithm

With floating objects, when we layout a paragraph, wxFloatCollector will
firstly collect all the floating objects of the paragraphs before this
one. And then, layout the floating objects of this paragraph, then layout
the normal objects using the available rect info according the floating
objects' state.

Generally, the basic paragraph layout algorithm:
1. All paragraphs before this one is layout well, so use wxFloatCollector
   to collect the floating objects state;
2. Collect all the 'place holding objects' of the paragraph, layout the
   floating objects with the space available for it;
3. For other objects left, make line break as:
   GetAvailableWidth with a <y, h> pair, where y is the vertical position
   of the line and h is the minimum height of the line.
   After we get the width, do line break and normal layout.

3. Some Note

If we use floating attributes with list style, it may cause some problems.
Something like image/text overlap may happen. Since, list style is applied
to the paragraph after its normal layout, in which phrase, floating layout
is done, list style will change the position of the paragraph and so may
cause some overlap.