#include <matrixelement.h>
Public Member Functions | |
| MatrixElement (uint rows=1, uint columns=1, BasicElement *parent=0) | |
| MatrixElement (const MatrixElement &) | |
| virtual MatrixElement * | clone () |
| virtual bool | accept (ElementVisitor *visitor) |
| virtual void | entered (SequenceElement *child) |
| virtual BasicElement * | goToPos (FormulaCursor *, bool &handled, const LuPixelPoint &point, const LuPixelPoint &parentOrigin) |
| virtual void | calcSizes (const ContextStyle &cstyle, ContextStyle::TextStyle tstyle, ContextStyle::IndexStyle istyle, StyleAttributes &style) |
| virtual void | dispatchFontCommand (FontCommand *cmd) |
| virtual void | goInside (FormulaCursor *cursor) |
| virtual SequenceElement * | getMainChild () |
| virtual void | selectChild (FormulaCursor *, BasicElement *) |
| virtual TQString | toLatex () |
| virtual TQString | formulaString () |
| uint | getRows () const |
| uint | getColumns () const |
| SequenceElement * | elementAt (uint row, uint column) |
| Public Member Functions inherited from BasicElement | |
| BasicElement (BasicElement *parent=0) | |
| BasicElement (const BasicElement &) | |
| virtual bool | readOnly (const BasicElement *child) const |
| virtual FormulaElement * | formula () |
| virtual const FormulaElement * | formula () const |
| virtual TQChar | getCharacter () const |
| virtual TokenType | getTokenType () const |
| virtual bool | isInvisible () const |
| LuPixelPoint | widgetPos () |
| virtual void | moveHome (FormulaCursor *) |
| virtual void | moveEnd (FormulaCursor *) |
| virtual void | insert (FormulaCursor *, TQPtrList< BasicElement > &, Direction) |
| virtual void | remove (FormulaCursor *, TQPtrList< BasicElement > &, Direction) |
| virtual void | normalize (FormulaCursor *, Direction) |
| virtual bool | isSenseless () |
| virtual BasicElement * | getChild (FormulaCursor *, Direction=beforeCursor) |
| virtual void | childWillVanish (FormulaCursor *, BasicElement *) |
| virtual void | registerTab (BasicElement *) |
| virtual KCommand * | buildCommand (Container *, Request *) |
| virtual KCommand * | input (Container *, TQKeyEvent *) |
| const BasicElement * | getParent () const |
| BasicElement * | getParent () |
| void | setParent (BasicElement *p) |
| luPixel | getX () const |
| luPixel | getY () const |
| void | setX (luPixel x) |
| void | setY (luPixel y) |
| luPixel | getWidth () const |
| luPixel | getHeight () const |
| void | setWidth (luPixel width) |
| void | setHeight (luPixel height) |
| luPixel | getBaseline () const |
| void | setBaseline (luPixel line) |
| luPixel | axis (const ContextStyle &style, ContextStyle::TextStyle tstyle, double factor) const |
| TQDomElement | getElementDom (TQDomDocument &doc) |
| virtual void | writeMathML (TQDomDocument &doc, TQDomNode &parent, bool oasisFormat=false) const |
| bool | buildFromDom (TQDomElement element) |
| int | buildFromMathMLDom (TQDomElement element) |
| ElementType * | getElementType () const |
| virtual void | setElementType (ElementType *t) |
| virtual void | setStyle (StyleElement *) |
Protected Member Functions | |
| virtual TQString | getTagName () const |
| virtual void | writeDom (TQDomElement element) |
| virtual TQString | getElementName () const |
| virtual void | writeMathMLAttributes (TQDomElement &element) const |
| virtual void | writeMathMLContent (TQDomDocument &doc, TQDomElement &element, bool oasisFormat) const |
| virtual bool | readAttributesFromDom (TQDomElement element) |
| virtual bool | readContentFromDom (TQDomNode &node) |
| virtual bool | readAttributesFromMathMLDom (const TQDomElement &element) |
| virtual int | readContentFromMathMLDom (TQDomNode &node) |
| Protected Member Functions inherited from BasicElement | |
| bool | buildChild (SequenceElement *child, TQDomNode node, TQString name) |
| double | getSize (const TQString &str, SizeType *st) |
| SizeType | getSpace (const TQString &str) |
Friends | |
| class | KFCRemoveColumn |
| class | KFCRemoveRow |
| class | MatrixSequenceElement |
Additional Inherited Members | |
| Static Public Member Functions inherited from BasicElement | |
| static int | getEvilDestructionCount () |
Detailed Description
A matrix.
Definition at line 38 of file matrixelement.h.
Constructor & Destructor Documentation
◆ MatrixElement() [1/2]
| MatrixElement::MatrixElement | ( | uint | rows = 1, |
| uint | columns = 1, | ||
| BasicElement * | parent = 0 ) |
Definition at line 272 of file matrixelement.cpp.
◆ ~MatrixElement()
| MatrixElement::~MatrixElement | ( | ) |
Definition at line 297 of file matrixelement.cpp.
◆ MatrixElement() [2/2]
| MatrixElement::MatrixElement | ( | const MatrixElement & | other | ) |
Definition at line 302 of file matrixelement.cpp.
Member Function Documentation
◆ accept()
|
virtual |
Visit this element.
An implementation of the visitor pattern.
Implements BasicElement.
Definition at line 329 of file matrixelement.cpp.
◆ calcSizes()
|
virtual |
Calculates our width and height and our children's parentPosition.
Implements BasicElement.
Definition at line 435 of file matrixelement.cpp.
◆ clone()
|
inlinevirtual |
Implements BasicElement.
Definition at line 53 of file matrixelement.h.
◆ dispatchFontCommand()
|
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. */ virtual void draw( TQPainter& painter, const LuPixelRect& r, const ContextStyle& context, ContextStyle::TextStyle tstyle, ContextStyle::IndexStyle istyle, StyleAttributes& style, const LuPixelPoint& parentOrigin );
/** Dispatch this FontCommand to all our TextElement children.
Reimplemented from BasicElement.
◆ elementAt()
| SequenceElement * MatrixElement::elementAt | ( | uint | row, |
| uint | column ) |
Definition at line 1254 of file matrixelement.cpp.
◆ entered()
|
virtual |
The cursor has entered one of our child sequences.
This is a good point to tell the user where he is.
Reimplemented from BasicElement.
Definition at line 335 of file matrixelement.cpp.
◆ formulaString()
|
virtual |
Reimplemented from BasicElement.
Definition at line 1235 of file matrixelement.cpp.
◆ getColumns()
|
inline |
Definition at line 201 of file matrixelement.h.
◆ getElementName()
|
inlineprotectedvirtual |
Reimplemented from BasicElement.
Definition at line 219 of file matrixelement.h.
◆ getMainChild()
|
virtual |
We define the Main Child of a matrix to be the first row/column.
Reimplemented from BasicElement.
Definition at line 713 of file matrixelement.cpp.
◆ getRows()
|
inline |
Definition at line 200 of file matrixelement.h.
◆ getTagName()
|
inlineprotectedvirtual |
Returns the tag name of this element type.
Reimplemented from BasicElement.
Definition at line 212 of file matrixelement.h.
◆ goInside()
|
virtual |
Enters this element while moving to the left starting inside the element `from'.
Draws the whole element including its children.
Searches for a cursor position inside this element or to the left of it. */ virtual void moveLeft(FormulaCursor* cursor, BasicElement* from);
/** 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. */ virtual void moveRight(FormulaCursor* cursor, BasicElement* from);
/** Enters this element while moving up starting inside the element `from'. Searches for a cursor position inside this element or above it. */ virtual void moveUp(FormulaCursor*, BasicElement*);
/** Enters this element while moving down starting inside the element `from'. Searches for a cursor position inside this element or below it. */ virtual void moveDown(FormulaCursor*, BasicElement*);
/** Sets the cursor inside this element to its start position. For most elements that is the main child.
The `parentOrigin' is the point this element's parent starts. We can use our parentPosition to get our own origin then. */ void MatrixElement::draw( TQPainter& painter, const LuPixelRect& rect, const ContextStyle& context, ContextStyle::TextStyle tstyle, ContextStyle::IndexStyle istyle, StyleAttributes& style, const LuPixelPoint& parentOrigin ) { LuPixelPoint myPos( parentOrigin.x()+getX(), parentOrigin.y()+getY() ); if ( !LuPixelRect( myPos.x(), myPos.y(), getWidth(), getHeight() ).intersects( rect ) ) return;
uint rows = getRows(); uint columns = getColumns();
for (uint r = 0; r < rows; r++) { for (uint c = 0; c < columns; c++) { getElement(r, c)->draw(painter, rect, context, context.convertTextStyleFraction(tstyle), context.convertIndexStyleUpper(istyle), style, myPos); } }
Debug painter.setPen(TQt::red); painter.drawRect(myPos.x(), myPos.y(), getWidth(), getHeight()); }
void MatrixElement::dispatchFontCommand( FontCommand* cmd ) { uint rows = getRows(); uint columns = getColumns();
for (uint r = 0; r < rows; r++) { for (uint c = 0; c < columns; c++) { getElement(r, c)->dispatchFontCommand( cmd ); } } }
navigation
The elements are responsible to handle cursor movement themselves. To do this they need to know the direction the cursor moves and the element it comes from.
The cursor might be in normal or in selection mode.
/** 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. */ void MatrixElement::moveLeft(FormulaCursor* cursor, BasicElement* from) { if (cursor->isSelectionMode()) { getParent()->moveLeft(cursor, this); } else { if (from == getParent()) { getElement(getRows()-1, getColumns()-1)->moveLeft(cursor, this); } else { bool linear = cursor->getLinearMovement(); uint row = 0; uint column = 0; if (searchElement(from, row, column)) { if (column > 0) { getElement(row, column-1)->moveLeft(cursor, this); } else if (linear && (row > 0)) { getElement(row-1, getColumns()-1)->moveLeft(cursor, this); } else { getParent()->moveLeft(cursor, this); } } else { getParent()->moveLeft(cursor, this); } } } }
/** 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. */ void MatrixElement::moveRight(FormulaCursor* cursor, BasicElement* from) { if (cursor->isSelectionMode()) { getParent()->moveRight(cursor, this); } else { if (from == getParent()) { getElement(0, 0)->moveRight(cursor, this); } else { bool linear = cursor->getLinearMovement(); uint row = 0; uint column = 0; if (searchElement(from, row, column)) { if (column < getColumns()-1) { getElement(row, column+1)->moveRight(cursor, this); } else if (linear && (row < getRows()-1)) { getElement(row+1, 0)->moveRight(cursor, this); } else { getParent()->moveRight(cursor, this); } } else { getParent()->moveRight(cursor, this); } } } }
/** Enters this element while moving up starting inside the element `from'. Searches for a cursor position inside this element or above it. */ void MatrixElement::moveUp(FormulaCursor* cursor, BasicElement* from) { if (cursor->isSelectionMode()) { getParent()->moveUp(cursor, this); } else { if (from == getParent()) { getElement(0, 0)->moveRight(cursor, this); } else { uint row = 0; uint column = 0; if (searchElement(from, row, column)) { if (row > 0) { getElement(row-1, column)->moveRight(cursor, this); } else { getParent()->moveUp(cursor, this); } } else { getParent()->moveUp(cursor, this); } } } }
/** Enters this element while moving down starting inside the element `from'. Searches for a cursor position inside this element or below it. */ void MatrixElement::moveDown(FormulaCursor* cursor, BasicElement* from) { if (cursor->isSelectionMode()) { getParent()->moveDown(cursor, this); } else { if (from == getParent()) { getElement(0, 0)->moveRight(cursor, this); } else { uint row = 0; uint column = 0; if (searchElement(from, row, column)) { if (row < getRows()-1) { getElement(row+1, column)->moveRight(cursor, this); } else { getParent()->moveDown(cursor, this); } } else { getParent()->moveDown(cursor, this); } } } }
/** Sets the cursor inside this element to its start position. For most elements that is the main child.
Reimplemented from BasicElement.
Definition at line 706 of file matrixelement.cpp.
◆ goToPos()
|
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 341 of file matrixelement.cpp.
◆ readAttributesFromDom()
|
protectedvirtual |
Reads our attributes from the element.
Returns false if it failed.
Reimplemented from BasicElement.
Definition at line 789 of file matrixelement.cpp.
◆ readAttributesFromMathMLDom()
|
protectedvirtual |
Reads our attributes from the MathML element.
Returns false if it failed.
Reimplemented from BasicElement.
Definition at line 861 of file matrixelement.cpp.
◆ readContentFromDom()
|
protectedvirtual |
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.
Definition at line 832 of file matrixelement.cpp.
◆ readContentFromMathMLDom()
|
protectedvirtual |
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 1118 of file matrixelement.cpp.
◆ selectChild()
|
virtual |
Inserts all new children at the cursor position.
Places the cursor according to the direction. Removes all selected children and returns them. Places the cursor to where the children have been. Moves the cursor to a normal place where new elements might be inserted. Sets the cursor to select the child. The mark is placed before, the position behind it.
Reimplemented from BasicElement.
Definition at line 718 of file matrixelement.cpp.
◆ toLatex()
|
virtual |
Moves the cursor away from the given child.
The cursor is guaranteed to be inside this element. Returns wether the element has no more useful children (except its main child) and should therefore be replaced by its main child's content.
- Returns
- the latex representation of the element and of the element's children
Reimplemented from BasicElement.
Definition at line 1208 of file matrixelement.cpp.
◆ writeDom()
|
protectedvirtual |
Appends our attributes to the dom element.
Reimplemented from BasicElement.
Definition at line 764 of file matrixelement.cpp.
◆ writeMathMLAttributes()
|
protectedvirtual |
Reimplemented from BasicElement.
Definition at line 1259 of file matrixelement.cpp.
◆ writeMathMLContent()
|
protectedvirtual |
Reimplemented from BasicElement.
Definition at line 1767 of file matrixelement.cpp.
Friends And Related Symbol Documentation
◆ KFCRemoveColumn
|
friend |
Definition at line 39 of file matrixelement.h.
◆ KFCRemoveRow
|
friend |
Definition at line 40 of file matrixelement.h.
◆ MatrixSequenceElement
|
friend |
Definition at line 41 of file matrixelement.h.
The documentation for this class was generated from the following files:
