lib

#include <basicelement.h>

Inheritance diagram for BasicElement:
EmptyElement FractionElement IndexElement MatrixElement MultilineElement RootElement SequenceElement SingleContentElement SpaceElement SymbolElement TextElement

Public Member Functions

 BasicElement (BasicElement *parent=0)
 
 BasicElement (const BasicElement &)
 
virtual BasicElement * clone ()=0
 
virtual bool accept (ElementVisitor *)=0
 
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
 
virtual BasicElement * goToPos (FormulaCursor *, bool &handled, const LuPixelPoint &point, const LuPixelPoint &parentOrigin)
 
LuPixelPoint widgetPos ()
 
virtual void calcSizes (const ContextStyle &context, ContextStyle::TextStyle tstyle, ContextStyle::IndexStyle istyle, StyleAttributes &style)=0
 
virtual void draw (TQPainter &painter, const LuPixelRect &r, const ContextStyle &context, ContextStyle::TextStyle tstyle, ContextStyle::IndexStyle istyle, StyleAttributes &style, 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 SequenceElement * getMainChild ()
 
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 selectChild (FormulaCursor *, BasicElement *)
 
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 *)
 
virtual TQString getElementName () const
 

Static Public Member Functions

static int getEvilDestructionCount ()
 

Protected Member Functions

virtual TQString getTagName () const
 
virtual void writeDom (TQDomElement element)
 
virtual void writeMathMLAttributes (TQDomElement &) const
 
virtual void writeMathMLContent (TQDomDocument &, TQDomElement &, bool) const
 
virtual bool readAttributesFromDom (TQDomElement element)
 
virtual bool readContentFromDom (TQDomNode &node)
 
bool buildChild (SequenceElement *child, TQDomNode node, TQString name)
 
virtual bool readAttributesFromMathMLDom (const TQDomElement &element)
 
virtual int readContentFromMathMLDom (TQDomNode &node)
 
virtual TQString toLatex ()
 
virtual TQString formulaString ()
 
double getSize (const TQString &str, SizeType *st)
 
SizeType getSpace (const TQString &str)
 

Friends

class SequenceElement
 
class SequenceParser
 

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().

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 75 of file basicelement.h.

Constructor & Destructor Documentation

◆ BasicElement() [1/2]

BasicElement::BasicElement ( BasicElement *  parent = 0)

Definition at line 36 of file basicelement.cpp.

◆ ~BasicElement()

BasicElement::~BasicElement ( )
virtual

Definition at line 46 of file basicelement.cpp.

◆ BasicElement() [2/2]

BasicElement::BasicElement ( const BasicElement &  other)

Definition at line 51 of file basicelement.cpp.

Member Function Documentation

◆ accept()

virtual bool BasicElement::accept ( ElementVisitor *  )
pure virtual

◆ axis()

luPixel BasicElement::axis ( const ContextStyle &  style,
ContextStyle::TextStyle  tstyle,
double  factor 
) const
inline

Definition at line 364 of file basicelement.h.

◆ buildChild()

bool BasicElement::buildChild ( SequenceElement *  child,
TQDomNode  node,
TQString  name 
)
protected

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

Returns a SequenceElement constructed from the nodes first child if the nodes name matches the given name.

The node name must match the given name.

This is a service for all subclasses that contain children.

Definition at line 241 of file basicelement.cpp.

◆ buildCommand()

virtual KCommand * BasicElement::buildCommand ( Container *  ,
Request *   
)
inlinevirtual

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 332 of file basicelement.h.

◆ buildFromDom()

bool BasicElement::buildFromDom ( TQDomElement  element)

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

Definition at line 185 of file basicelement.cpp.

◆ buildFromMathMLDom()

int BasicElement::buildFromMathMLDom ( TQDomElement  element)

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

Returns the number of nodes processed or -1 if it failed.

Definition at line 198 of file basicelement.cpp.

◆ calcSizes()

virtual void BasicElement::calcSizes ( const ContextStyle &  context,
ContextStyle::TextStyle  tstyle,
ContextStyle::IndexStyle  istyle,
StyleAttributes &  style 
)
pure virtual

◆ childWillVanish()

virtual void BasicElement::childWillVanish ( FormulaCursor *  ,
BasicElement *   
)
inlinevirtual

Moves the cursor away from the given child.

The cursor is guaranteed to be inside this element.

Reimplemented in SequenceElement.

Definition at line 315 of file basicelement.h.

◆ dispatchFontCommand()

virtual void BasicElement::dispatchFontCommand ( FontCommand *  )
inlinevirtual

◆ draw()

virtual void BasicElement::draw ( TQPainter &  painter,
const LuPixelRect &  r,
const ContextStyle &  context,
ContextStyle::TextStyle  tstyle,
ContextStyle::IndexStyle  istyle,
StyleAttributes &  style,
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, IndexElement, MatrixElement, MultilineElement, SequenceElement, SpaceElement, SymbolElement, TextElement, EmptyElement, TokenStyleElement, FractionElement, and RootElement.

◆ entered()

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.cpp.

◆ formula() [1/2]

FormulaElement * BasicElement::formula ( )
virtual

Provide fast access to the rootElement for each child.

Reimplemented in FormulaElement.

Definition at line 70 of file basicelement.cpp.

◆ formula() [2/2]

virtual const FormulaElement * BasicElement::formula ( ) const
inlinevirtual

Provide fast access to the rootElement for each child.

Reimplemented in FormulaElement.

Definition at line 117 of file basicelement.h.

◆ formulaString()

virtual TQString BasicElement::formulaString ( )
inlineprotectedvirtual

Definition at line 474 of file basicelement.h.

◆ getBaseline()

luPixel BasicElement::getBaseline ( ) const
inline

Definition at line 361 of file basicelement.h.

◆ getCharacter()

virtual TQChar BasicElement::getCharacter ( ) const
inlinevirtual
Returns
the character that represents this element. Used for parsing a sequence. This is guaranteed to be TQChar::null for all non-text elements.

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

Definition at line 124 of file basicelement.h.

◆ getChild()

virtual BasicElement * BasicElement::getChild ( FormulaCursor *  ,
Direction  = beforeCursor 
)
inlinevirtual

Returns the child at the cursor.

Reimplemented in IndexElement, SequenceElement, and SymbolElement.

Definition at line 301 of file basicelement.h.

◆ getElementDom()

TQDomElement BasicElement::getElementDom ( TQDomDocument &  doc)
Returns
a TQDomElement that contain as DomChildren the children, and as attribute the attribute of this element.

Definition at line 169 of file basicelement.cpp.

◆ getElementName()

virtual TQString BasicElement::getElementName ( ) const
inlinevirtual

Definition at line 411 of file basicelement.h.

◆ getElementType()

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 402 of file basicelement.h.

◆ getEvilDestructionCount()

static int BasicElement::getEvilDestructionCount ( )
inlinestatic

Definition at line 396 of file basicelement.h.

◆ getHeight()

luPixel BasicElement::getHeight ( ) const
inline

Definition at line 356 of file basicelement.h.

◆ getMainChild()

virtual SequenceElement * BasicElement::getMainChild ( )
inlinevirtual

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 262 of file basicelement.h.

◆ getParent() [1/2]

BasicElement * BasicElement::getParent ( )
inline

Definition at line 344 of file basicelement.h.

◆ getParent() [2/2]

const BasicElement * BasicElement::getParent ( ) const
inline

Definition at line 343 of file basicelement.h.

◆ getSize()

double BasicElement::getSize ( const TQString &  str,
SizeType *  st 
)
protected

Utility function that sets the size type and returns the size value from a MathML attribute string with unit as defined in Section 2.4.4.2.

Returns
the size value
Parameters
strthe attribute string.
stsize type container. It will be properly assigned to its size type or NoSize if str is invalid

Definition at line 290 of file basicelement.cpp.

◆ getSpace()

SizeType BasicElement::getSpace ( const TQString &  str)
protected

Definition at line 332 of file basicelement.cpp.

◆ getTagName()

virtual TQString BasicElement::getTagName ( ) const
inlineprotectedvirtual

◆ getTokenType()

virtual TokenType BasicElement::getTokenType ( ) const
inlinevirtual
Returns
the type of this element. Used for parsing a sequence.

Reimplemented in BracketElement, FractionElement, NameSequence, and TextElement.

Definition at line 130 of file basicelement.h.

◆ getWidth()

luPixel BasicElement::getWidth ( ) const
inline

Definition at line 355 of file basicelement.h.

◆ getX()

luPixel BasicElement::getX ( ) const
inline

Definition at line 347 of file basicelement.h.

◆ getY()

luPixel BasicElement::getY ( ) const
inline

Definition at line 348 of file basicelement.h.

◆ goInside()

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.cpp.

◆ goToPos()

BasicElement * BasicElement::goToPos ( FormulaCursor *  ,
bool &  handled,
const LuPixelPoint &  point,
const LuPixelPoint &  parentOrigin 
)
virtual

Sets the cursor and returns the element the point is in.

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, RootElement, SequenceElement, SymbolElement, and MultilineElement.

Definition at line 82 of file basicelement.cpp.

◆ input()

virtual KCommand * BasicElement::input ( Container *  ,
TQKeyEvent *   
)
inlinevirtual

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 339 of file basicelement.h.

◆ insert()

virtual void BasicElement::insert ( FormulaCursor *  ,
TQPtrList< BasicElement > &  ,
Direction   
)
inlinevirtual

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 276 of file basicelement.h.

◆ isInvisible()

virtual bool BasicElement::isInvisible ( ) const
inlinevirtual
Returns
true if we don't want to see the element.

Reimplemented in TextElement.

Definition at line 135 of file basicelement.h.

◆ isSenseless()

virtual bool BasicElement::isSenseless ( )
inlinevirtual

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 296 of file basicelement.h.

◆ moveDown()

virtual void BasicElement::moveDown ( FormulaCursor *  ,
BasicElement *   
)
inlinevirtual

Enters this element while moving down starting inside the element ‘from’.

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

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

Definition at line 220 of file basicelement.h.

◆ moveEnd()

virtual void BasicElement::moveEnd ( FormulaCursor *  )
inlinevirtual

Moves the cursor to the last position in this sequence.

(That is behind the last child.)

Reimplemented in SequenceElement.

Definition at line 232 of file basicelement.h.

◆ moveHome()

virtual void BasicElement::moveHome ( FormulaCursor *  )
inlinevirtual

Moves the cursor to the first position in this sequence.

(That is before the first child.)

Reimplemented in SequenceElement.

Definition at line 226 of file basicelement.h.

◆ moveLeft()

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.cpp.

◆ moveRight()

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.cpp.

◆ moveUp()

virtual void BasicElement::moveUp ( FormulaCursor *  ,
BasicElement *   
)
inlinevirtual

Enters this element while moving up starting inside the element ‘from’.

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

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

Definition at line 213 of file basicelement.h.

◆ normalize()

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.cpp.

◆ readAttributesFromDom()

bool BasicElement::readAttributesFromDom ( TQDomElement  element)
protectedvirtual

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 222 of file basicelement.cpp.

◆ readAttributesFromMathMLDom()

bool BasicElement::readAttributesFromMathMLDom ( const TQDomElement &  element)
protectedvirtual

Reads our attributes from the MathML element.

Returns false if it failed.

Reimplemented in BracketElement, FractionElement, IndexElement, MatrixElement, RootElement, SpaceElement, and TokenStyleElement.

Definition at line 260 of file basicelement.cpp.

◆ readContentFromDom()

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

Definition at line 232 of file basicelement.cpp.

◆ readContentFromMathMLDom()

int BasicElement::readContentFromMathMLDom ( TQDomNode &  node)
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.

Sets the node to the next node that needs to be read. Returns false if it failed.

Reimplemented in SingleContentElement, BracketElement, FractionElement, IndexElement, MatrixElement, RootElement, and SequenceElement.

Definition at line 270 of file basicelement.cpp.

◆ readOnly()

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.cpp.

◆ registerTab()

virtual void BasicElement::registerTab ( BasicElement *  )
inlinevirtual

Callback for the tabs among our children.

Needed for alignment.

Definition at line 321 of file basicelement.h.

◆ remove()

virtual void BasicElement::remove ( FormulaCursor *  ,
TQPtrList< BasicElement > &  ,
Direction   
)
inlinevirtual

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 282 of file basicelement.h.

◆ selectChild()

virtual void BasicElement::selectChild ( FormulaCursor *  ,
BasicElement *   
)
inlinevirtual

Sets the cursor to select the child.

The mark is placed before, the position behind it.

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

Definition at line 308 of file basicelement.h.

◆ setBaseline()

void BasicElement::setBaseline ( luPixel  line)
inline

Definition at line 362 of file basicelement.h.

◆ setElementType()

virtual void BasicElement::setElementType ( ElementType *  t)
inlinevirtual

Sets a new type.

This is done during parsing.

Reimplemented in NameSequence.

Definition at line 407 of file basicelement.h.

◆ setHeight()

void BasicElement::setHeight ( luPixel  height)
inline

Definition at line 359 of file basicelement.h.

◆ setParent()

void BasicElement::setParent ( BasicElement *  p)
inline

Definition at line 345 of file basicelement.h.

◆ setStyle()

virtual void BasicElement::setStyle ( StyleElement *  )
inlinevirtual

Definition at line 409 of file basicelement.h.

◆ setWidth()

void BasicElement::setWidth ( luPixel  width)
inline

Definition at line 358 of file basicelement.h.

◆ setX()

void BasicElement::setX ( luPixel  x)
inline

Definition at line 350 of file basicelement.h.

◆ setY()

void BasicElement::setY ( luPixel  y)
inline

Definition at line 351 of file basicelement.h.

◆ toLatex()

TQString BasicElement::toLatex ( )
protectedvirtual
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 275 of file basicelement.cpp.

◆ widgetPos()

LuPixelPoint BasicElement::widgetPos ( )

Returns our position inside the widget.

Definition at line 98 of file basicelement.cpp.

◆ writeDom()

void BasicElement::writeDom ( TQDomElement  element)
protectedvirtual

◆ writeMathML()

void BasicElement::writeMathML ( TQDomDocument &  doc,
TQDomNode &  parent,
bool  oasisFormat = false 
) const
virtual

Same as above, just MathML.

It shouldn't be redefined but for exceptional cases, use the general writeMathML* API instead

Reimplemented in OverlineElement, UnderlineElement, FormulaElement, MultilineElement, SymbolElement, and TextElement.

Definition at line 177 of file basicelement.cpp.

◆ writeMathMLAttributes()

virtual void BasicElement::writeMathMLAttributes ( TQDomElement &  ) const
inlineprotectedvirtual

Definition at line 426 of file basicelement.h.

◆ writeMathMLContent()

virtual void BasicElement::writeMathMLContent ( TQDomDocument &  ,
TQDomElement &  ,
bool   
) const
inlineprotectedvirtual

Definition at line 427 of file basicelement.h.

Friends And Related Symbol Documentation

◆ SequenceElement

friend class SequenceElement
friend

Definition at line 77 of file basicelement.h.

◆ SequenceParser

friend class SequenceParser
friend

Definition at line 78 of file basicelement.h.


The documentation for this class was generated from the following files: