]> git.saurik.com Git - wxWidgets.git/blob - src/richtext/readme
Add missing WXK constants for the control keys
[wxWidgets.git] / src / richtext / readme
1 Implement detail of floating layout
2
3 1. Data Structure
4
5 Mainly, we maintain two floating list data for a wxRichTextBuffer.
6 'struct FloatRectMap' is used to represent a floating object's region,
7 and 'class wxFloatCollector' is a container of all 'struct FloatRectMap'.
8 It maintains all the information of the positions of all the floating
9 objects with two list of 'struct FloatRectMap', one for objects floated
10 to left and the other for right.
11
12 wxRichTextAnchoredObject is introduced to represent a kind of objects
13 that can be floated. wxRichTextImage is made to be a child class of
14 this one. In future, we may introduce some other floating object type
15 like wxRichTextTable. And we also introduce a twin object of this one,
16 it is wxRichTextPlaceHoldingObject. When the object is set to be a
17 floating one, we will place a 'placing holding' object in its origin
18 position, this makes us to record the position of the object correctly
19 even if the containing paragraph change its content.
20
21 Also, along with wxRichTextAnchoredObject, we also introduce a
22 wxRichTextAnchoredObjectAttr class, which contains the attributes of
23 floating direction, floating offset and etc. wxRichTextImageAttr is made
24 to be a subclass of this one.
25
26 Finally, wxRichTextImageDlg is a image control dialog, in which users can
27 set the alignment, floating direction, size, offset of the image, in addition,
28 users can also move the image between paragraph with this dialog.
29
30 2. Layout Algorithm
31
32 With floating objects, when we layout a paragraph, wxFloatCollector will
33 firstly collect all the floating objects of the paragraphs before this
34 one. And then, layout the floating objects of this paragraph, then layout
35 the normal objects using the available rect info according the floating
36 objects' state.
37
38 Generally, the basic paragraph layout algorithm:
39 1. All paragraphs before this one is layout well, so use wxFloatCollector
40 to collect the floating objects state;
41 2. Collect all the 'place holding objects' of the paragraph, layout the
42 floating objects with the space available for it;
43 3. For other objects left, make line break as:
44 GetAvailableWidth with a <y, h> pair, where y is the vertical position
45 of the line and h is the minimum height of the line.
46 After we get the width, do line break and normal layout.
47
48 3. Some Note
49
50 If we use floating attributes with list style, it may cause some problems.
51 Something like image/text overlap may happen. Since, list style is applied
52 to the paragraph after its normal layout, in which phrase, floating layout
53 is done, list style will change the position of the paragraph and so may
54 cause some overlap.