lib Library API Documentation

BasicElement Class Reference

Basis of every formula element. More...

#include <basicelement.h>

Inheritance diagram for BasicElement:

EmptyElement FractionElement IndexElement MatrixElement MultilineElement RootElement SequenceElement SingleContentElement SpaceElement SymbolElement TextElement List of all members.

Public Member Functions

 BasicElement (BasicElement *parent=0)
 BasicElement (const BasicElement &)
virtual BasicElementclone ()=0
virtual bool accept (ElementVisitor *)=0
virtual bool readOnly (const BasicElement *child) const
virtual FormulaElementformula ()
virtual const FormulaElementformula () const
virtual QChar getCharacter () const
virtual TokenType getTokenType () const
virtual bool isInvisible () const
virtual BasicElementgoToPos (FormulaCursor *, bool &handled, const LuPixelPoint &point, const LuPixelPoint &parentOrigin)
LuPixelPoint widgetPos ()
virtual void calcSizes (const ContextStyle &context, ContextStyle::TextStyle tstyle, ContextStyle::IndexStyle istyle)=0
virtual void draw (QPainter &painter, const LuPixelRect &r, const ContextStyle &context, ContextStyle::TextStyle tstyle, ContextStyle::IndexStyle istyle, const LuPixelPoint &parentOrigin)=0
virtual void dispatchFontCommand (FontCommand *)
virtual void moveLeft (FormulaCursor *cursor, BasicElement *from)
virtual void moveRight (FormulaCursor *cursor, BasicElement *from)
virtual void moveUp (FormulaCursor *, BasicElement *)
virtual void moveDown (FormulaCursor *, BasicElement *)
virtual void moveHome (FormulaCursor *)
virtual void moveEnd (FormulaCursor *)
virtual void goInside (FormulaCursor *cursor)
virtual void entered (SequenceElement *)
virtual SequenceElementgetMainChild ()
virtual void insert (FormulaCursor *, QPtrList< BasicElement > &, Direction)
virtual void remove (FormulaCursor *, QPtrList< BasicElement > &, Direction)
virtual void normalize (FormulaCursor *, Direction)
virtual bool isSenseless ()
virtual BasicElementgetChild (FormulaCursor *, Direction=beforeCursor)
virtual void selectChild (FormulaCursor *, BasicElement *)
virtual void childWillVanish (FormulaCursor *, BasicElement *)
virtual void registerTab (BasicElement *)
virtual KCommand * buildCommand (Container *, Request *)
virtual KCommand * input (Container *, QKeyEvent *)
const BasicElementgetParent () const
BasicElementgetParent ()
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) const
QDomElement getElementDom (QDomDocument &doc)
virtual void writeMathML (QDomDocument doc, QDomNode parent)
bool buildFromDom (QDomElement element)
ElementTypegetElementType () const
virtual void setElementType (ElementType *t)

Static Public Member Functions

int getEvilDestructionCount ()

Protected Member Functions

virtual QString getTagName () const
virtual void writeDom (QDomElement element)
virtual bool readAttributesFromDom (QDomElement element)
virtual bool readContentFromDom (QDomNode &node)
bool buildChild (SequenceElement *child, QDomNode node, QString name)
virtual QString toLatex ()
virtual QString formulaString ()

Detailed Description

Basis of every formula element.

An element is used basically by other elements and by the FormulaCursor .

Each element knows its size (a rect that includes all children) and how to draw itself. See calcSizes and draw .

An element might contain valid cursor position. If the cursor enters the element it must find the next valid position depending on the direction in that the cursor moves and the element it comes from. There might also be some flags inside the cursor that tell how it wants to move. See moveLeft , moveRight , moveUp , moveDown .

To build a tree an element must own children. If there are children there must be a main child. This is the child that might be used to replace the element. See getMainChild and setMainChild .

If there can be children you might want to insert and remove them. After a removal the element might be senseless. (See isSenseless ) If it is it must be removed.

Definition at line 74 of file basicelement.h.


Member Function Documentation

virtual bool BasicElement::accept ElementVisitor  )  [pure virtual]
 

Visit this element.

An implementation of the visitor pattern.

Implemented in BracketElement, OverlineElement, UnderlineElement, FractionElement, IndexElement, MatrixElement, MultilineElement, RootElement, SequenceElement, NameSequence, SpaceElement, SymbolElement, TextElement, and EmptyElement.

bool BasicElement::readOnly const BasicElement child  )  const [virtual]
 

Returns:
whether the child should be read-only. The idea is that a read-only parent has read-only children.

Reimplemented in FormulaElement.

Definition at line 64 of file basicelement.cc.

References readOnly().

Referenced by SequenceElement::readOnly(), and readOnly().

FormulaElement * BasicElement::formula  )  [virtual]
 

Provide fast access to the rootElement for each child.

Reimplemented in FormulaElement.

Definition at line 70 of file basicelement.cc.

Referenced by SequenceElement::buildCommand(), FormulaCursor::copy(), RootElement::entered(), MultilineElement::entered(), MatrixElement::entered(), IndexElement::entered(), FractionElement::entered(), UnderlineElement::entered(), OverlineElement::entered(), BracketElement::entered(), entered(), formula(), SequenceElement::input(), SymbolElement::insert(), SequenceElement::insert(), RootElement::insert(), MultilineElement::insert(), IndexElement::insert(), FractionElement::insert(), FormulaCursor::isEnd(), FormulaCursor::isHome(), SequenceElement::moveDown(), SequenceElement::moveLeft(), SequenceElement::moveRight(), SequenceElement::moveUp(), SequenceElement::parse(), SymbolElement::remove(), SequenceElement::remove(), RootElement::remove(), MultilineElement::remove(), IndexElement::remove(), and FractionElement::remove().

virtual const FormulaElement* BasicElement::formula  )  const [inline, virtual]
 

Provide fast access to the rootElement for each child.

Reimplemented in FormulaElement.

Definition at line 116 of file basicelement.h.

References formula().

virtual QChar BasicElement::getCharacter  )  const [inline, virtual]
 

Returns:
the character that represents this element. Used for parsing a sequence. This is guaranteed to be QChar::null for all non-text elements.

Reimplemented in SingleContentElement, IndexElement, NameSequence, SpaceElement, TextElement, and EmptyElement.

Definition at line 123 of file basicelement.h.

Referenced by SingleContentElement::getCharacter(), SequenceElement::parse(), SequenceParser::text(), ElementType::text(), and NameSequence::writeMathML().

virtual TokenType BasicElement::getTokenType  )  const [inline, virtual]
 

Returns:
the type of this element. Used for parsing a sequence.

Reimplemented in BracketElement, FractionElement, NameSequence, and TextElement.

Definition at line 129 of file basicelement.h.

Referenced by SequenceParser::nextToken().

virtual bool BasicElement::isInvisible  )  const [inline, virtual]
 

Returns:
true if we don't want to see the element.

Reimplemented in TextElement.

Definition at line 134 of file basicelement.h.

Referenced by SequenceElement::calcSizes(), SequenceElement::draw(), SequenceElement::isEmpty(), and SequenceElement::remove().

BasicElement * BasicElement::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 in SingleContentElement, BracketElement, FractionElement, IndexElement, MatrixElement, MultilineElement, RootElement, SequenceElement, and SymbolElement.

Definition at line 82 of file basicelement.cc.

References goToPos().

Referenced by SequenceElement::goToPos(), MatrixElement::goToPos(), and goToPos().

LuPixelPoint BasicElement::widgetPos  ) 
 

Returns our position inside the widget.

Definition at line 98 of file basicelement.cc.

References getX(), getY(), and parent.

Referenced by NameSequence::drawCursor().

virtual void BasicElement::calcSizes const ContextStyle context,
ContextStyle::TextStyle  tstyle,
ContextStyle::IndexStyle  istyle
[pure virtual]
 

Calculates our width and height and our children's parentPosition.

Implemented in BracketElement, OverlineElement, UnderlineElement, FormulaElement, FractionElement, IndexElement, MatrixElement, MultilineElement, RootElement, SequenceElement, SpaceElement, SymbolElement, TextElement, and EmptyElement.

Referenced by SequenceElement::calcSizes().

virtual void BasicElement::draw QPainter painter,
const LuPixelRect r,
const ContextStyle context,
ContextStyle::TextStyle  tstyle,
ContextStyle::IndexStyle  istyle,
const LuPixelPoint parentOrigin
[pure 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.

Implemented in BracketElement, OverlineElement, UnderlineElement, FormulaElement, FractionElement, IndexElement, MatrixElement, MultilineElement, RootElement, SequenceElement, SpaceElement, SymbolElement, TextElement, and EmptyElement.

Referenced by SequenceElement::draw().

virtual void BasicElement::dispatchFontCommand FontCommand  )  [inline, virtual]
 

Dispatch this FontCommand to all our TextElement children.

Reimplemented in SingleContentElement, FractionElement, IndexElement, MatrixElement, MultilineElement, RootElement, SequenceElement, SymbolElement, and TextElement.

Definition at line 179 of file basicelement.h.

References dispatchFontCommand().

Referenced by SequenceElement::dispatchFontCommand(), and dispatchFontCommand().

void BasicElement::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 in SingleContentElement, FractionElement, IndexElement, MatrixElement, MultilineElement, RootElement, SequenceElement, and SymbolElement.

Definition at line 134 of file basicelement.cc.

References moveLeft().

Referenced by FormulaCursor::elementWillVanish(), MatrixElement::goToPos(), SymbolElement::moveLeft(), RootElement::moveLeft(), IndexElement::moveLeft(), FractionElement::moveLeft(), SingleContentElement::moveLeft(), moveLeft(), and normalize().

void BasicElement::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 in SingleContentElement, FractionElement, IndexElement, MatrixElement, MultilineElement, RootElement, SequenceElement, and SymbolElement.

Definition at line 145 of file basicelement.cc.

References moveRight().

Referenced by SymbolElement::moveRight(), RootElement::moveRight(), IndexElement::moveRight(), FractionElement::moveRight(), SingleContentElement::moveRight(), moveRight(), normalize(), and FormulaCursor::replaceByMainChildContent().

virtual void BasicElement::moveUp FormulaCursor ,
BasicElement
[inline, virtual]
 

Enters this element while moving up starting inside the element `from'.

Searches for a cursor position inside this element or above it.

Reimplemented in SingleContentElement, FractionElement, IndexElement, MatrixElement, MultilineElement, RootElement, SequenceElement, and SymbolElement.

Definition at line 208 of file basicelement.h.

References moveUp().

Referenced by SymbolElement::moveUp(), RootElement::moveUp(), IndexElement::moveUp(), FractionElement::moveUp(), SingleContentElement::moveUp(), and moveUp().

virtual void BasicElement::moveDown FormulaCursor ,
BasicElement
[inline, virtual]
 

Enters this element while moving down starting inside the element `from'.

Searches for a cursor position inside this element or below it.

Reimplemented in SingleContentElement, FractionElement, IndexElement, MatrixElement, MultilineElement, RootElement, SequenceElement, and SymbolElement.

Definition at line 215 of file basicelement.h.

References moveDown().

Referenced by SymbolElement::moveDown(), RootElement::moveDown(), IndexElement::moveDown(), FractionElement::moveDown(), SingleContentElement::moveDown(), and moveDown().

virtual void BasicElement::moveHome FormulaCursor  )  [inline, virtual]
 

Moves the cursor to the first position in this sequence.

(That is before the first child.)

Reimplemented in SequenceElement.

Definition at line 221 of file basicelement.h.

References moveHome().

Referenced by moveHome().

virtual void BasicElement::moveEnd FormulaCursor  )  [inline, virtual]
 

Moves the cursor to the last position in this sequence.

(That is behind the last child.)

Reimplemented in SequenceElement.

Definition at line 227 of file basicelement.h.

References moveEnd().

Referenced by moveEnd().

void BasicElement::goInside FormulaCursor cursor  )  [virtual]
 

Sets the cursor inside this element to its start position.

For most elements that is the main child.

Reimplemented in MatrixElement, MultilineElement, and SequenceElement.

Definition at line 114 of file basicelement.cc.

References getMainChild(), and goInside().

Referenced by goInside(), and FormulaCursor::goInsideElement().

void BasicElement::entered SequenceElement  )  [virtual]
 

The cursor has entered one of our child sequences.

This is a good point to tell the user where he is.

Reimplemented in BracketElement, OverlineElement, UnderlineElement, FractionElement, IndexElement, MatrixElement, MultilineElement, and RootElement.

Definition at line 123 of file basicelement.cc.

References entered(), formula(), and FormulaElement::tell().

Referenced by entered().

virtual SequenceElement* BasicElement::getMainChild  )  [inline, virtual]
 

Removes the child.

If this was the main child this element might request its own removal. The cursor is the one that caused the removal. It has to be moved to the place any user expects the cursor after that particular element has been removed.

Reimplemented in SingleContentElement, FractionElement, IndexElement, MatrixElement, MultilineElement, RootElement, NameSequence, and SymbolElement.

Definition at line 257 of file basicelement.h.

Referenced by goInside(), normalize(), FormulaCursor::removeEnclosingElement(), FormulaCursor::replaceByMainChildContent(), and FormulaCursor::replaceSelectionWith().

virtual void BasicElement::insert FormulaCursor ,
QPtrList< BasicElement > &  ,
Direction 
[inline, virtual]
 

Inserts all new children at the cursor position.

Places the cursor according to the direction.

The list will be emptied but stays the property of the caller.

Reimplemented in FractionElement, IndexElement, MultilineElement, RootElement, SequenceElement, and SymbolElement.

Definition at line 271 of file basicelement.h.

References insert().

Referenced by FormulaCursor::insert(), and insert().

virtual void BasicElement::remove FormulaCursor ,
QPtrList< BasicElement > &  ,
Direction 
[inline, virtual]
 

Removes all selected children and returns them.

Places the cursor to where the children have been.

Reimplemented in SingleContentElement, FractionElement, IndexElement, MultilineElement, RootElement, SequenceElement, and SymbolElement.

Definition at line 277 of file basicelement.h.

References remove().

Referenced by SymbolElement::remove(), RootElement::remove(), IndexElement::remove(), FractionElement::remove(), FormulaCursor::remove(), SingleContentElement::remove(), remove(), and FormulaCursor::replaceSelectionWith().

void BasicElement::normalize FormulaCursor cursor,
Direction  direction
[virtual]
 

Moves the cursor to a normal place where new elements might be inserted.

Reimplemented in SingleContentElement, IndexElement, MultilineElement, RootElement, SequenceElement, and SymbolElement.

Definition at line 155 of file basicelement.cc.

References getMainChild(), moveLeft(), moveRight(), and normalize().

Referenced by FormulaCursor::normalize(), and normalize().

virtual bool BasicElement::isSenseless  )  [inline, virtual]
 

Returns wether the element has no more useful children (except its main child) and should therefore be replaced by its main child's content.

Reimplemented in FractionElement, and IndexElement.

Definition at line 291 of file basicelement.h.

Referenced by FormulaCursor::elementIsSenseless().

virtual BasicElement* BasicElement::getChild FormulaCursor ,
Direction  = beforeCursor
[inline, virtual]
 

Returns the child at the cursor.

Reimplemented in IndexElement, SequenceElement, and SymbolElement.

Definition at line 296 of file basicelement.h.

References getChild().

Referenced by getChild().

virtual void BasicElement::selectChild FormulaCursor ,
BasicElement
[inline, virtual]
 

Sets the cursor to select the child.

The mark is placed before, the position behind it.

Reimplemented in SingleContentElement, FractionElement, IndexElement, MatrixElement, MultilineElement, RootElement, SequenceElement, and SymbolElement.

Definition at line 303 of file basicelement.h.

References selectChild().

Referenced by SymbolElement::remove(), RootElement::remove(), IndexElement::remove(), FractionElement::remove(), FormulaCursor::remove(), SingleContentElement::remove(), FormulaCursor::removeEnclosingElement(), FormulaCursor::replaceSelectionWith(), and selectChild().

virtual void BasicElement::childWillVanish FormulaCursor ,
BasicElement
[inline, virtual]
 

Moves the cursor away from the given child.

The cursor is guaranteed to be inside this element.

Reimplemented in SequenceElement.

Definition at line 310 of file basicelement.h.

References childWillVanish().

Referenced by childWillVanish(), and FormulaCursor::elementWillVanish().

virtual void BasicElement::registerTab BasicElement  )  [inline, virtual]
 

Callback for the tabs among our children.

Needed for alignment.

Definition at line 316 of file basicelement.h.

References registerTab().

Referenced by SpaceElement::calcSizes(), and registerTab().

virtual KCommand* BasicElement::buildCommand Container ,
Request * 
[inline, virtual]
 

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 in FormulaElement, SequenceElement, and NameSequence.

Definition at line 327 of file basicelement.h.

References buildCommand().

Referenced by buildCommand().

virtual KCommand* BasicElement::input Container ,
QKeyEvent
[inline, virtual]
 

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 FormulaElement, and SequenceElement.

Definition at line 334 of file basicelement.h.

References input().

Referenced by input().

QDomElement BasicElement::getElementDom QDomDocument doc  ) 
 

Returns:
a QDomElement that contain as DomChildren the children, and as attribute the attribute of this element.

Definition at line 169 of file basicelement.cc.

References getElementDom(), getTagName(), and writeDom().

Referenced by getElementDom(), SymbolElement::writeDom(), RootElement::writeDom(), IndexElement::writeDom(), FractionElement::writeDom(), and SingleContentElement::writeDom().

void BasicElement::writeMathML QDomDocument  doc,
QDomNode  parent
[virtual]
 

Same as above, just MathML.

Reimplemented in SingleContentElement, BracketElement, OverlineElement, UnderlineElement, FormulaElement, FractionElement, IndexElement, MatrixElement, MultilineElement, RootElement, SequenceElement, NameSequence, SpaceElement, and SymbolElement.

Definition at line 177 of file basicelement.cc.

References getTagName(), and writeMathML().

Referenced by writeMathML().

bool BasicElement::buildFromDom QDomElement  element  ) 
 

Set this element attribute, build children and call their buildFromDom.

Definition at line 183 of file basicelement.cc.

References buildFromDom(), getTagName(), readAttributesFromDom(), and readContentFromDom().

Referenced by buildChild(), SequenceElement::buildChildrenFromDom(), buildFromDom(), Container::load(), MultilineElement::readContentFromDom(), and MatrixElement::readContentFromDom().

int BasicElement::getEvilDestructionCount  )  [inline, static]
 

Heiner's test method.

Should read MathML...

Definition at line 386 of file basicelement.h.

ElementType* BasicElement::getElementType  )  const [inline]
 

Returns:
our type. This is an object from our parent's syntax tree or 0 if there was a very bad parsing error.

Definition at line 392 of file basicelement.h.

Referenced by SequenceElement::calcSizes(), TextElement::draw(), SequenceElement::draw(), TextElement::getFont(), SequenceElement::isFirstOfToken(), TextElement::isInvisible(), TextElement::setUpPainter(), and SequenceElement::writeMathML().

virtual void BasicElement::setElementType ElementType t  )  [inline, virtual]
 

Sets a new type.

This is done during parsing.

Reimplemented in NameSequence.

Definition at line 397 of file basicelement.h.

References setElementType().

Referenced by SequenceElement::parse(), and setElementType().

virtual QString BasicElement::getTagName  )  const [inline, protected, virtual]
 

Returns the tag name of this element type.

Reimplemented in BracketElement, OverlineElement, UnderlineElement, FormulaElement, FractionElement, IndexElement, MatrixElement, MultilineElement, RootElement, SequenceElement, NameSequence, SpaceElement, SymbolElement, TextElement, and EmptyElement.

Definition at line 406 of file basicelement.h.

Referenced by buildFromDom(), getElementDom(), SingleContentElement::readContentFromDom(), and writeMathML().

void BasicElement::writeDom QDomElement  element  )  [protected, virtual]
 

Appends our attributes to the dom element.

Reimplemented in SingleContentElement, BracketElement, FormulaElement, FractionElement, IndexElement, MatrixElement, MultilineElement, RootElement, SequenceElement, SpaceElement, SymbolElement, and TextElement.

Definition at line 199 of file basicelement.cc.

References writeDom().

Referenced by getElementDom(), and writeDom().

bool BasicElement::readAttributesFromDom QDomElement  element  )  [protected, virtual]
 

Reads our attributes from the element.

Returns false if it failed.

Reimplemented in BracketElement, FormulaElement, FractionElement, IndexElement, MatrixElement, MultilineElement, RootElement, SequenceElement, SpaceElement, SymbolElement, and TextElement.

Definition at line 207 of file basicelement.cc.

References readAttributesFromDom().

Referenced by buildFromDom(), and readAttributesFromDom().

bool BasicElement::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 in SingleContentElement, FormulaElement, FractionElement, IndexElement, MatrixElement, MultilineElement, RootElement, SequenceElement, SpaceElement, SymbolElement, and TextElement.

Definition at line 217 of file basicelement.cc.

References readContentFromDom().

Referenced by buildFromDom(), and readContentFromDom().

bool BasicElement::buildChild SequenceElement child,
QDomNode  node,
QString  name
[protected]
 

Returns if the SequenceElement could be constructed from the nodes first child.

The node name must match the given name.

This is a service for all subclasses that contain children.

Definition at line 227 of file basicelement.cc.

References buildChild(), and buildFromDom().

Referenced by buildChild().

QString BasicElement::toLatex  )  [protected, virtual]
 

Returns:
the latex representation of the element and of the element's children

Reimplemented in BracketElement, OverlineElement, UnderlineElement, FormulaElement, FractionElement, IndexElement, MatrixElement, MultilineElement, RootElement, SequenceElement, SpaceElement, SymbolElement, TextElement, and EmptyElement.

Definition at line 242 of file basicelement.cc.

Referenced by SequenceElement::toLatex().


The documentation for this class was generated from the following files:
KDE Logo
This file is part of the documentation for lib Library Version 1.3.5.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Nov 17 06:54:21 2004 by doxygen 1.3.7 written by Dimitri van Heesch, © 1997-2003