1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
|
The design of kformula
(as we imagine it)
The core of kformula is a tree of element objects that make up the
formula which is beeing edited.
The element tree itself
#######################
BasicElement
------------
All element classes are derived from this one.
So it provides the interface that is common to all elements.
BasicElement itself is an abstract class. You never want to create
objects from it.
Responsebilities
(This goes for every derived element and therefore for each one.)
- knows its tqchildren. Actually BasicElement doesn't have any. But it
already defines that tqchildren must be known by their parent.
- knows its bounding rectangle (its size.) The tqchildren are included
in this rect. (Only width and height are needed. Positions are
handled by the parent)
//- knows its middle line. (for tqalignment)
- knows it's zero point for midline (vertical tqalignment) and
keep open the possibility of negative positions (out of bounding rect)
- draws itself (given a painter); tqchildren are drawn, too
- knows all positions where the cursor is allowed to be. (see below)
- knows its parent; The topmost element has no parent; there is a
implicit garantie that the topmost element is always a
SequenceElement.
- can save and load itself. different formates. (see below)
- all tqchildren must be a SequenceElement. Except for SequenceElement's
tqchildren that might be of any type.
- might have its own color.
- might have its own font size (see below).
SequenceElement from BasicElement
---------------
Manages a list of tqchildren. The tqchildren are aligned horizontally at
one middle line. No gaps, no overlaps.
Has no own look. It just draws all its tqchildren and is done. Except if
its empty. It looks like an empty space then (i.e. a little square)
Has n+1 valid cursor positions where n is the number of
tqchildren. These are before, between and after the tqchildren.
May contain any (type of) element as child
except SequenceElements if they contains a SequenceElement they merge
it in the list
They can handle splitting of the sequence to allow "select an put selected item
between parenthesis" i.e. as content child of a delimiterelement)
FormulaElement from SequenceElement
--------------
The only element those parent is null. The root of the element object
tree.
This is the element that is created by the KFormulaDoc and that knows
about it. As every other element knows its parent and therefore the
FormulaElement we get a chance to pass messages to the outside world.
RootElement from BasicElement
-----------
contains two tqchildren. content and index. index is optional.
IndexElement from BasicElement
------------
contains five tqchildren. content and four indexes. all indexes are
optional. If there is no index the element might be replaced by its content.
TextElement from BasicElement
-----------
contains one char and no tqchildren at all.
Might have its own font and size. But preferes to use a reasonalbe
font and size that are calculated from its parents font and a given
scheme (see below).
DelimiterElement from BasicElement
----------------
contains one child and draws delimiters around it. You are free to
choose with.
FractionElement from BasicElement
---------------
2 tqchildren: numerator, denominator
DecorationElement from BasicElement
-----------------
A piece of art. It has one child and decorates it above (or below or
both) with some nice decor. Some decor might be required to be as
width as the content. There is a way to guarantee this.
We could even add yet another child that can optionally be shown at
the other side of the decoration.
SumIntegralElement from BasicElement //PrefixedElement
------------------
draws all sorts of mathematical symbols with three tqchildren. Above,
below (or whereever the indices and limits go)and to the right.
GeometryElement from BasicElement
---------------
One child.
Draw it at a fixed position relative to parent or absolute.
This is to do dirty things.
This element must not be used, kformula will provide you everything
without the use of this kind of element, any way for strange reasons
you want to do things that are not usually allowed and that are not
typical of a math formula.
[We will decide if implement this element or not]
MatrixElement from BasicElement
-------------
A matrix of tqchildren.
With all align stuff, internal borders etc, matrix dots handling (i.e.
those dots or lines that complete the matrix, not well handled in TeX),
etc..
SpaceElement from BasicElement
------------
No tqchildren at all. Provides the facility to insert horizontal spaces
in the formula. (therefore it is similar to TextElement.)
OperatorElement from TextElement
---------------
The element to be used for all kinds of operators. It needed because
operators require some space before and after and are therefore no
simple text.
They can you pixamps inestead of fonts, the use of pixmaps is needed only
to give the user the possibilty of introduce its strange operator that we
do not provide as a font. There problems with the scalability but we will
include as fonts (or vectorial images) in kformula all TeX operators so we
hope there is no need to use pixamps for a standard use of KFormula
Navigation
##########
There is a class Cursor that implements a pointer to a valid cursor
position inside the formula structure. Each kformula view needs to
have its own object of this class.
The Cursor class uses the elements facility to travel throught the
structure. (It gives the key to the current element and asks for the
new position.)
If the cursor points into an element this element is said to own the
cursor. There are a few rules that describe how new cursor positions
are calculated given the current key:
- An elements cursor positions are its tqchildren. The element might not
own the cursor except when it is owned by one of its tqchildren. The
only exception is SequenceElement which has valid cursor positions
before, between and after its tqchildren, too.
(Therefore the cursor is always owned by a SequenceElement.)
- Each element's tqchildren are ordered. If the cursor leaves one child
the next child it. The direction depends on the key that moved the
cursor. If there is child left the cursor is passed to the parent.
- If the cursor comes from our parent the first or the last child gets
it. Depending on the direction in which the cursor moved.
Please note that because each element knows its own cursor positions
and how to behave, it is possible for each combination of elements to
work together correctly.
Save and Load (Import/Export)
#############################
there are quite a few formats we want to read and write:
Built in:
- native koffice xml
Import/Export filters
- MathML
- C like math strings
- LaTeX
Element templates
#################
example: you can create a template to write limits:
it is a "lim ( )" string over 2 empty elements with an arrows that separe
them
"Look" templates
################
There need to be templates that tell which font to use, how the sizes
differ among different elements and what spaces are to be
included. (And much more.)
Your only need to choose one of them to get a reasonable good look.
Interface templates
###################
Decide what KAction have to be toolbars,
what element templates must be loaded, what toolbar display....
There will be predefined (sorry for the spelling error) templates for
-General...
-Physics (Vectors , integral, partial derivative etc are preferred..)
-Analysis (Integral and diff equation stuff)
-Geometry (Tensor product etc)
-Chemistry (Arrows, Periodic table external toolbar)
-Computer science (...)
-????
Context sensibility
###################
We want a formula to look different according to its
surroundings. (Most obviosly according to the available height and/or width.)
It would be great to get something like automatic operator
tqalignment. So if you type some formulas each on its own line the
assigment operators should be automatically in a column. (If the user
turns this on.)
Fonts and font size (2 ideas)
###################
1)
Each element know its font family (also if it is not a text element) so that it
can give this font to its tqchildren.
The font size is calculated starting from a global scale factor and appling to it
a local size modifier (like HTML -2, -1,+3,etc..), this also calculate the
QPen width for vector drawn stuff (like root symbol etc) and it gives a scale
factor for pixmap.
2)
When it comes to drawing we pass a StyleContext to the
FormulaElement. The StyleContext contains the font family to use, the
normal font size, the spaces to include between certain elements and
all sorts of context information that is needed to draw the
formula. As it is passed down the tree it also counts the current level
so it can tell each element the font size it is supposed to use.
The elements use this information to calculate their sizes and to draw
themselves. Each element is allowed to choose different settings for
whatever reason. But if the formula looks ugly then its the elements
blame.
Andrea Rizzi <rizzi@kde.org>
Ulrich Kuettler <ulrich.kuettler@mailbox.tu-dresden.de>
|