lib
SequenceElement Class Reference
#include <sequenceelement.h>
Inheritance diagram for SequenceElement:

Detailed Description
The element that contains a number of children.The children are aligned in one line.
Definition at line 40 of file sequenceelement.h.
Public Types | |
typedef ChildIterator | iterator |
Public Member Functions | |
SequenceElement (BasicElement *parent=0) | |
~SequenceElement () | |
SequenceElement (const SequenceElement &) | |
virtual SequenceElement * | clone () |
virtual bool | accept (ElementVisitor *visitor) |
virtual bool | readOnly (const FormulaCursor *) const |
virtual bool | isTextOnly () const |
virtual BasicElement * | goToPos (FormulaCursor *, bool &handled, const LuPixelPoint &point, const LuPixelPoint &parentOrigin) |
void | setSizeReduction (const ContextStyle &context) |
bool | isEmpty () |
virtual void | calcSizes (const ContextStyle &style, ContextStyle::TextStyle tstyle, ContextStyle::IndexStyle istyle, StyleAttributes &style) |
virtual void | draw (QPainter &painter, const LuPixelRect &r, const ContextStyle &context, ContextStyle::TextStyle tstyle, ContextStyle::IndexStyle istyle, StyleAttributes &style, const LuPixelPoint &parentOrigin) |
virtual void | dispatchFontCommand (FontCommand *cmd) |
virtual void | drawEmptyRect (QPainter &painter, const ContextStyle &context, double factor, const LuPixelPoint &upperLeft) |
virtual void | calcCursorSize (const ContextStyle &context, FormulaCursor *cursor, bool smallCursor) |
virtual void | drawCursor (QPainter &painter, const ContextStyle &context, StyleAttributes &style, FormulaCursor *cursor, bool smallCursor, bool activeCursor) |
virtual void | moveLeft (FormulaCursor *cursor, BasicElement *from) |
virtual void | moveRight (FormulaCursor *cursor, BasicElement *from) |
virtual void | moveWordLeft (FormulaCursor *cursor) |
virtual void | moveWordRight (FormulaCursor *cursor) |
virtual void | moveUp (FormulaCursor *cursor, BasicElement *from) |
virtual void | moveDown (FormulaCursor *cursor, BasicElement *from) |
virtual void | moveHome (FormulaCursor *cursor) |
virtual void | moveEnd (FormulaCursor *cursor) |
virtual void | goInside (FormulaCursor *cursor) |
virtual void | goInsideLast (FormulaCursor *cursor) |
virtual void | insert (FormulaCursor *, QPtrList< BasicElement > &, Direction) |
virtual void | remove (FormulaCursor *, QPtrList< BasicElement > &, Direction) |
virtual void | normalize (FormulaCursor *, Direction) |
virtual BasicElement * | getChild (FormulaCursor *, Direction=beforeCursor) |
virtual void | selectChild (FormulaCursor *cursor, BasicElement *child) |
virtual void | childWillVanish (FormulaCursor *cursor, BasicElement *child) |
uint | countChildren () const |
bool | isChildNumber (uint pos, BasicElement *child) |
void | selectAllChildren (FormulaCursor *cursor) |
bool | onlyTextSelected (FormulaCursor *cursor) |
virtual KCommand * | buildCommand (Container *, Request *) |
virtual KCommand * | input (Container *container, QChar ch) |
virtual KCommand * | input (Container *container, QKeyEvent *event) |
virtual void | parse () |
void | getChildrenDom (QDomDocument &doc, QDomElement elem, uint from, uint to) |
void | getChildrenMathMLDom (QDomDocument &doc, QDomNode &elem, uint from, uint to) |
bool | buildChildrenFromDom (QPtrList< BasicElement > &list, QDomNode n) |
virtual QString | toLatex () |
virtual QString | formulaString () |
BasicElement * | getChild (uint i) |
const BasicElement * | getChild (uint i) const |
int | childPos (BasicElement *child) |
int | childPos (const BasicElement *child) const |
iterator | begin () |
iterator | end () |
virtual void | setStyle (StyleElement *style) |
virtual int | buildChildrenFromMathMLDom (QPtrList< BasicElement > &list, QDomNode n) |
virtual int | readContentFromMathMLDom (QDomNode &node) |
int | buildMathMLChild (QDomNode node) |
Static Public Member Functions | |
static void | setCreationStrategy (ElementCreationStrategy *strategy) |
Protected Member Functions | |
virtual QString | getTagName () const |
virtual void | writeDom (QDomElement element) |
virtual QString | getElementName () const |
virtual void | writeMathMLContent (QDomDocument &doc, QDomElement &element, bool oasisFormat) const |
virtual bool | readAttributesFromDom (QDomElement element) |
virtual bool | readContentFromDom (QDomNode &node) |
virtual void | setChildrenPositions () |
virtual BasicElement * | createElement (QString type, const QDomElement &element) |
luPixel | getChildPosition (const ContextStyle &context, uint child) |
virtual bool | isFirstOfToken (BasicElement *child) |
bool | insert (uint index, BasicElement *child) |
virtual luPt | getSpaceBefore (const ContextStyle &, ContextStyle::TextStyle, double) |
virtual luPt | getSpaceAfter (const ContextStyle &, ContextStyle::TextStyle, double) |
Static Protected Member Functions | |
static ElementCreationStrategy * | getCreationStrategy () |
Static Protected Attributes | |
static ElementCreationStrategy * | creationStrategy |
Classes | |
class | ChildIterator |
Member Function Documentation
bool SequenceElement::accept | ( | ElementVisitor * | visitor | ) | [virtual] |
Visit this element.
An implementation of the visitor pattern.
Implements BasicElement.
Reimplemented in NameSequence.
Definition at line 101 of file sequenceelement.cc.
bool SequenceElement::readOnly | ( | const FormulaCursor * | ) | const [virtual] |
- Returns:
- whether its prohibited to change the sequence with this cursor.
Reimplemented in FormulaElement.
Definition at line 107 of file sequenceelement.cc.
virtual bool SequenceElement::isTextOnly | ( | ) | const [inline, virtual] |
- Returns:
- true if the sequence contains only text.
Reimplemented in TokenElement.
Definition at line 63 of file sequenceelement.h.
BasicElement * SequenceElement::goToPos | ( | FormulaCursor * | , | |
bool & | handled, | |||
const LuPixelPoint & | point, | |||
const LuPixelPoint & | parentOrigin | |||
) | [virtual] |
Sets the cursor and returns the element the point is in.
The handled flag shows whether the cursor has been set. This is needed because only the innermost matching element is allowed to set the cursor.
Reimplemented from BasicElement.
Definition at line 116 of file sequenceelement.cc.
void SequenceElement::setSizeReduction | ( | const ContextStyle & | context | ) |
Tells the sequence to have a smaller size than its parant.
bool SequenceElement::isEmpty | ( | ) |
- Returns:
- true if there is no visible element in the sequence.
Please note that there might be phantom elements.
Definition at line 162 of file sequenceelement.cc.
void SequenceElement::calcSizes | ( | const ContextStyle & | style, | |
ContextStyle::TextStyle | tstyle, | |||
ContextStyle::IndexStyle | istyle, | |||
StyleAttributes & | style | |||
) | [virtual] |
Calculates our width and height and our children's parentPosition.
Implements BasicElement.
Reimplemented in FormulaElement, PaddedElement, and TokenStyleElement.
Definition at line 179 of file sequenceelement.cc.
void SequenceElement::draw | ( | QPainter & | painter, | |
const LuPixelRect & | r, | |||
const ContextStyle & | context, | |||
ContextStyle::TextStyle | tstyle, | |||
ContextStyle::IndexStyle | istyle, | |||
StyleAttributes & | style, | |||
const LuPixelPoint & | parentOrigin | |||
) | [virtual] |
Draws the whole element including its children.
The `parentOrigin' is the point this element's parent starts. We can use our parentPosition to get our own origin then.
Implements BasicElement.
Reimplemented in ErrorElement, FormulaElement, PhantomElement, and TokenStyleElement.
Definition at line 253 of file sequenceelement.cc.
void SequenceElement::dispatchFontCommand | ( | FontCommand * | cmd | ) | [virtual] |
Dispatch this FontCommand to all our TextElement children.
Reimplemented from BasicElement.
Definition at line 309 of file sequenceelement.cc.
void SequenceElement::drawCursor | ( | QPainter & | painter, | |
const ContextStyle & | context, | |||
StyleAttributes & | style, | |||
FormulaCursor * | cursor, | |||
bool | smallCursor, | |||
bool | activeCursor | |||
) | [virtual] |
If the cursor is inside a sequence it needs to be drawn.
Reimplemented in NameSequence.
Definition at line 380 of file sequenceelement.cc.
void SequenceElement::moveLeft | ( | FormulaCursor * | cursor, | |
BasicElement * | from | |||
) | [virtual] |
Enters this element while moving to the left starting inside the element `from'.
Searches for a cursor position inside this element or to the left of it.
Reimplemented from BasicElement.
Definition at line 450 of file sequenceelement.cc.
void SequenceElement::moveRight | ( | FormulaCursor * | cursor, | |
BasicElement * | from | |||
) | [virtual] |
Enters this element while moving to the right starting inside the element `from'.
Searches for a cursor position inside this element or to the right of it.
Reimplemented from BasicElement.
Definition at line 506 of file sequenceelement.cc.
void SequenceElement::moveWordLeft | ( | FormulaCursor * | cursor | ) | [virtual] |
Moves to the beginning of this word or if we are there already to the beginning of the previous.
Reimplemented in NameSequence.
Definition at line 559 of file sequenceelement.cc.
void SequenceElement::moveWordRight | ( | FormulaCursor * | cursor | ) | [virtual] |
Moves to the end of this word or if we are there already to the end of the next.
Reimplemented in NameSequence.
Definition at line 574 of file sequenceelement.cc.
void SequenceElement::moveUp | ( | FormulaCursor * | cursor, | |
BasicElement * | from | |||
) | [virtual] |
Enters this element while moving up starting inside the element `from'.
Searches for a cursor position inside this element or above it.
Reimplemented from BasicElement.
Definition at line 594 of file sequenceelement.cc.
void SequenceElement::moveDown | ( | FormulaCursor * | cursor, | |
BasicElement * | from | |||
) | [virtual] |
Enters this element while moving down starting inside the element `from'.
Searches for a cursor position inside this element or below it.
Reimplemented from BasicElement.
Definition at line 628 of file sequenceelement.cc.
void SequenceElement::moveHome | ( | FormulaCursor * | cursor | ) | [virtual] |
Moves the cursor to the first position in this sequence.
(That is before the first child.)
Reimplemented from BasicElement.
Definition at line 656 of file sequenceelement.cc.
void SequenceElement::moveEnd | ( | FormulaCursor * | cursor | ) | [virtual] |
Moves the cursor to the last position in this sequence.
(That is behind the last child.)
Reimplemented from BasicElement.
Definition at line 674 of file sequenceelement.cc.
void SequenceElement::goInside | ( | FormulaCursor * | cursor | ) | [virtual] |
Sets the cursor inside this element to its start position.
For most elements that is the main child.
Reimplemented from BasicElement.
Definition at line 698 of file sequenceelement.cc.
void SequenceElement::goInsideLast | ( | FormulaCursor * | cursor | ) | [virtual] |
Sets the cursor inside this element to its last position.
For most elements that is the main child.
Definition at line 708 of file sequenceelement.cc.
void SequenceElement::insert | ( | FormulaCursor * | , | |
QPtrList< BasicElement > & | , | |||
Direction | ||||
) | [virtual] |
Inserts all new children at the cursor position.
Places the cursor according to the direction. The inserted elements will be selected.
The list will be emptied but stays the property of the caller.
Reimplemented from BasicElement.
Definition at line 762 of file sequenceelement.cc.
void SequenceElement::remove | ( | FormulaCursor * | , | |
QPtrList< BasicElement > & | , | |||
Direction | ||||
) | [virtual] |
Removes all selected children and returns them.
Places the cursor to where the children have been.
Reimplemented from BasicElement.
Definition at line 791 of file sequenceelement.cc.
void SequenceElement::normalize | ( | FormulaCursor * | , | |
Direction | ||||
) | [virtual] |
Moves the cursor to a normal place where new elements might be inserted.
Reimplemented from BasicElement.
Definition at line 864 of file sequenceelement.cc.
BasicElement * SequenceElement::getChild | ( | FormulaCursor * | , | |
Direction | = beforeCursor | |||
) | [virtual] |
Returns the child at the cursor.
Does not care about the selection.
Reimplemented from BasicElement.
Definition at line 874 of file sequenceelement.cc.
void SequenceElement::selectChild | ( | FormulaCursor * | cursor, | |
BasicElement * | child | |||
) | [virtual] |
Sets the cursor to select the child.
The mark is placed before, the position behind it.
Reimplemented from BasicElement.
Definition at line 894 of file sequenceelement.cc.
void SequenceElement::childWillVanish | ( | FormulaCursor * | cursor, | |
BasicElement * | child | |||
) | [virtual] |
Moves the cursor away from the given child.
The cursor is guaranteed to be inside this element.
Reimplemented from BasicElement.
Definition at line 902 of file sequenceelement.cc.
uint SequenceElement::countChildren | ( | ) | const [inline] |
bool SequenceElement::isChildNumber | ( | uint | pos, | |
BasicElement * | child | |||
) | [inline] |
void SequenceElement::selectAllChildren | ( | FormulaCursor * | cursor | ) |
Selects all children.
The cursor is put behind, the mark before them.
Definition at line 922 of file sequenceelement.cc.
This is called by the container to get a command depending on the current cursor position (this is how the element gets chosen) and the request.
- Returns:
- the command that performs the requested action with the containers active cursor.
Reimplemented from BasicElement.
Reimplemented in FormulaElement, IdentifierElement, NumberElement, OperatorElement, and NameSequence.
Definition at line 943 of file sequenceelement.cc.
Parses the input.
It's the container which does create new elements because it owns the undo stack. But only the sequence knows what chars are allowed.
Reimplemented in NameSequence.
Definition at line 1315 of file sequenceelement.cc.
Parses the input.
It's the container which does create new elements because it owns the undo stack. But only the sequence knows what chars are allowed.
Reimplemented from BasicElement.
Reimplemented in FormulaElement.
Definition at line 1238 of file sequenceelement.cc.
void SequenceElement::parse | ( | ) | [virtual] |
Parses the sequence and generates a new syntax tree.
Has to be called after each modification.
Definition at line 1505 of file sequenceelement.cc.
void SequenceElement::getChildrenDom | ( | QDomDocument & | doc, | |
QDomElement | elem, | |||
uint | from, | |||
uint | to | |||
) |
void SequenceElement::getChildrenMathMLDom | ( | QDomDocument & | doc, | |
QDomNode & | elem, | |||
uint | from, | |||
uint | to | |||
) |
Stores the given childrens MathML dom in the element.
Definition at line 1417 of file sequenceelement.cc.
bool SequenceElement::buildChildrenFromDom | ( | QPtrList< BasicElement > & | list, | |
QDomNode | n | |||
) |
Builds elements from the given node and its siblings and puts them into the list.
Returns false if an error occures.
Definition at line 1431 of file sequenceelement.cc.
QString SequenceElement::toLatex | ( | ) | [virtual] |
- Returns:
- the latex representation of the element and of the element's children
Reimplemented from BasicElement.
Reimplemented in FormulaElement.
Definition at line 1547 of file sequenceelement.cc.
BasicElement* SequenceElement::getChild | ( | uint | i | ) | [inline] |
int SequenceElement::readContentFromMathMLDom | ( | QDomNode & | node | ) | [virtual] |
Reads our content from the MathML node.
Sets the node to the next node that needs to be read. It is sometimes needed to read more than one node (e. g. for fence operators). Returns the number of nodes processed or -1 if it failed.
Reimplemented from BasicElement.
Definition at line 1891 of file sequenceelement.cc.
virtual QString SequenceElement::getTagName | ( | ) | const [inline, protected, virtual] |
Returns the tag name of this element type.
Reimplemented from BasicElement.
Reimplemented in FormulaElement, and NameSequence.
Definition at line 385 of file sequenceelement.h.
void SequenceElement::writeDom | ( | QDomElement | element | ) | [protected, virtual] |
Appends our attributes to the dom element.
Reimplemented from BasicElement.
Reimplemented in FormulaElement.
Definition at line 1469 of file sequenceelement.cc.
bool SequenceElement::readAttributesFromDom | ( | QDomElement | element | ) | [protected, virtual] |
Reads our attributes from the element.
Returns false if it failed.
Reimplemented from BasicElement.
Reimplemented in FormulaElement.
Definition at line 1482 of file sequenceelement.cc.
bool SequenceElement::readContentFromDom | ( | QDomNode & | node | ) | [protected, virtual] |
Reads our content from the node.
Sets the node to the next node that needs to be read. Returns false if it failed.
Reimplemented from BasicElement.
Reimplemented in FormulaElement.
Definition at line 1495 of file sequenceelement.cc.
void SequenceElement::setChildrenPositions | ( | ) | [protected, virtual] |
Sets the childrens' positions after their size has been calculated.
- See also:
- calcSizes
Definition at line 238 of file sequenceelement.cc.
BasicElement * SequenceElement::createElement | ( | QString | type, | |
const QDomElement & | element | |||
) | [protected, virtual] |
Creates a new element with the given type.
- Parameters:
-
type the desired type of the element
Definition at line 1461 of file sequenceelement.cc.
luPixel SequenceElement::getChildPosition | ( | const ContextStyle & | context, | |
uint | child | |||
) | [protected] |
- Returns:
- the position where the child starts.
- Parameters:
-
context the context the child is in child the child's number
Definition at line 421 of file sequenceelement.cc.
bool SequenceElement::isFirstOfToken | ( | BasicElement * | child | ) | [protected, virtual] |
- Returns:
- whether the child is the first element of its token.
Reimplemented in NameSequence.
Definition at line 1541 of file sequenceelement.cc.
bool SequenceElement::insert | ( | uint | index, | |
BasicElement * | child | |||
) | [protected] |
Insert a new child in the sequence.
- Returns:
- true if succesful, i.e. if index is in range, otherwise returns false. The valid range is 0 to count(). The child is appended if index == count().
- Parameters:
-
index position in the sequence to insert the child child the child to insert in the sequence
Definition at line 727 of file sequenceelement.cc.
virtual luPt SequenceElement::getSpaceBefore | ( | const ContextStyle & | , | |
ContextStyle::TextStyle | , | |||
double | ||||
) | [inline, protected, virtual] |
Space around sequence.
Reimplemented in IdentifierElement, and TokenElement.
Definition at line 453 of file sequenceelement.h.
The documentation for this class was generated from the following files: