21
21
#ifndef MATRIXELEMENT_H
22
22
#define MATRIXELEMENT_H
26
26
#include "basicelement.h"
28
28
KFORMULA_NAMESPACE_BEGIN
31
class MatrixSequenceElement;
33
37
class MatrixElement : public BasicElement {
38
friend class KFCRemoveColumn;
39
friend class KFCRemoveRow;
40
friend class MatrixSequenceElement;
42
MatrixElement& operator=( const MatrixElement& ) { return *this; }
35
44
MatrixElement(uint rows = 1, uint columns = 1, BasicElement* parent = 0);
47
MatrixElement( const MatrixElement& );
49
virtual MatrixElement* clone() {
50
return new MatrixElement( *this );
53
virtual bool accept( ElementVisitor* visitor );
56
* The cursor has entered one of our child sequences.
57
* This is a good point to tell the user where he is.
59
virtual void entered( SequenceElement* child );
39
62
* Sets the cursor and returns the element the point is in.
40
63
* The handled flag shows whether the cursor has been set.
41
64
* This is needed because only the innermost matching element
42
65
* is allowed to set the cursor.
44
virtual BasicElement* goToPos(FormulaCursor*, bool& handled,
45
const KoPoint& point, const KoPoint& parentOrigin);
67
virtual BasicElement* goToPos( FormulaCursor*, bool& handled,
68
const LuPixelPoint& point, const LuPixelPoint& parentOrigin );
62
85
* The `parentOrigin' is the point this element's parent starts.
63
86
* We can use our parentPosition to get our own origin then.
65
virtual void draw(QPainter& painter, const QRect& r,
66
const ContextStyle& context,
67
ContextStyle::TextStyle tstyle,
68
ContextStyle::IndexStyle istyle,
69
const KoPoint& parentOrigin);
88
virtual void draw( QPainter& painter, const LuPixelRect& r,
89
const ContextStyle& context,
90
ContextStyle::TextStyle tstyle,
91
ContextStyle::IndexStyle istyle,
92
const LuPixelPoint& parentOrigin );
95
* Dispatch this FontCommand to all our TextElement children.
97
virtual void dispatchFontCommand( FontCommand* cmd );
206
239
* The elements we contain.
208
QList<QList<SequenceElement> > content;
241
QPtrList< QPtrList< MatrixSequenceElement > > content;
246
class MultilineSequenceElement;
250
* Any number of lines.
252
class MultilineElement : public BasicElement {
253
friend class KFCNewLine;
255
typedef BasicElement inherited;
259
* The container this FormulaElement belongs to must not be 0,
260
* except you really know what you are doing.
262
MultilineElement( BasicElement* parent = 0 );
265
MultilineElement( const MultilineElement& );
267
virtual MultilineElement* clone() {
268
return new MultilineElement( *this );
271
virtual bool accept( ElementVisitor* visitor );
274
* The cursor has entered one of our child sequences.
275
* This is a good point to tell the user where he is.
277
virtual void entered( SequenceElement* child );
280
* Returns the element the point is in.
282
BasicElement* goToPos( FormulaCursor* cursor, bool& handled,
283
const LuPixelPoint& point, const LuPixelPoint& parentOrigin );
286
* Sets the cursor inside this element to its start position.
287
* For most elements that is the main child.
289
virtual void goInside(FormulaCursor* cursor);
292
* Enters this element while moving to the left starting inside
293
* the element `from'. Searches for a cursor position inside
294
* this element or to the left of it.
296
virtual void moveLeft( FormulaCursor* cursor, BasicElement* from );
299
* Enters this element while moving to the right starting inside
300
* the element `from'. Searches for a cursor position inside
301
* this element or to the right of it.
303
virtual void moveRight( FormulaCursor* cursor, BasicElement* from );
306
* Enters this element while moving up starting inside
307
* the element `from'. Searches for a cursor position inside
308
* this element or above it.
310
virtual void moveUp( FormulaCursor* cursor, BasicElement* from );
313
* Enters this element while moving down starting inside
314
* the element `from'. Searches for a cursor position inside
315
* this element or below it.
317
virtual void moveDown( FormulaCursor* cursor, BasicElement* from );
320
* Calculates our width and height and
321
* our children's parentPosition.
323
virtual void calcSizes(const ContextStyle& context, ContextStyle::TextStyle tstyle, ContextStyle::IndexStyle istyle);
326
* Draws the whole element including its children.
327
* The `parentOrigin' is the point this element's parent starts.
328
* We can use our parentPosition to get our own origin then.
330
virtual void draw( QPainter& painter, const LuPixelRect& r,
331
const ContextStyle& context,
332
ContextStyle::TextStyle tstyle,
333
ContextStyle::IndexStyle istyle,
334
const LuPixelPoint& parentOrigin );
337
* Dispatch this FontCommand to all our TextElement children.
339
virtual void dispatchFontCommand( FontCommand* cmd );
341
virtual void insert(FormulaCursor*, QPtrList<BasicElement>&, Direction);
342
virtual void remove(FormulaCursor*, QPtrList<BasicElement>&, Direction);
344
virtual void normalize(FormulaCursor*, Direction);
346
virtual SequenceElement* getMainChild();
349
* Sets the cursor to select the child. The mark is placed before,
350
* the position behind it.
352
virtual void selectChild(FormulaCursor* cursor, BasicElement* child);
355
* @returns the latex representation of the element and
356
* of the element's children
358
virtual QString toLatex();
360
virtual QString formulaString();
362
virtual void writeMathML( QDomDocument doc, QDomNode parent );
369
* Returns the tag name of this element type.
371
virtual QString getTagName() const { return "MULTILINE"; }
374
* Appends our attributes to the dom element.
376
virtual void writeDom(QDomElement element);
379
* Reads our attributes from the element.
380
* Returns false if it failed.
382
virtual bool readAttributesFromDom(QDomElement element);
385
* Reads our content from the node. Sets the node to the next node
386
* that needs to be read.
387
* Returns false if it failed.
389
virtual bool readContentFromDom(QDomNode& node);
395
* The list of sequences. Each one is a line.
397
QPtrList< MultilineSequenceElement > content;
211
401
KFORMULA_NAMESPACE_END