lib

#include <symbolelement.h>

Inheritance diagram for SymbolElement:
BasicElement

Public Member Functions

 SymbolElement (SymbolType type=EmptyBracket, BasicElement *parent=0)
 SymbolElement (const SymbolElement &)
virtual SymbolElement * clone ()
virtual bool accept (ElementVisitor *visitor)
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 SequenceElement * getMainChild ()
virtual void insert (FormulaCursor *, TQPtrList< BasicElement > &, Direction)
virtual void remove (FormulaCursor *, TQPtrList< BasicElement > &, Direction)
virtual void normalize (FormulaCursor *, Direction)
virtual BasicElement * getChild (FormulaCursor *, Direction=beforeCursor)
virtual void selectChild (FormulaCursor *cursor, BasicElement *child)
bool hasUpper () const
bool hasLower () const
void setToUpper (FormulaCursor *cursor)
void setToLower (FormulaCursor *cursor)
void moveToUpper (FormulaCursor *, Direction)
void moveToLower (FormulaCursor *, Direction)
ElementIndexPtr getUpperIndex ()
ElementIndexPtr getLowerIndex ()
ElementIndexPtr getIndex (int position)
virtual TQString toLatex ()
virtual TQString formulaString ()
virtual void writeMathML (TQDomDocument &doc, TQDomNode &parent, bool oasisFormat=false) const
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 goInside (FormulaCursor *cursor)
virtual void entered (SequenceElement *)
virtual bool isSenseless ()
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)
bool buildFromDom (TQDomElement element)
int buildFromMathMLDom (TQDomElement element)
ElementType * getElementType () const
virtual void setElementType (ElementType *t)
virtual void setStyle (StyleElement *)
virtual TQString getElementName () const

Protected Member Functions

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

Additional Inherited Members

Static Public Member Functions inherited from BasicElement
static int getEvilDestructionCount ()

Detailed Description

A symbol is simply a piece of art.

Definition at line 33 of file symbolelement.h.

Constructor & Destructor Documentation

◆ SymbolElement() [1/2]

SymbolElement::SymbolElement ( SymbolType type = EmptyBracket,
BasicElement * parent = 0 )

Definition at line 90 of file symbolelement.cpp.

◆ ~SymbolElement()

SymbolElement::~SymbolElement ( )

Definition at line 98 of file symbolelement.cpp.

◆ SymbolElement() [2/2]

SymbolElement::SymbolElement ( const SymbolElement & other)

Definition at line 107 of file symbolelement.cpp.

Member Function Documentation

◆ accept()

bool SymbolElement::accept ( ElementVisitor * )
virtual

Visit this element.

An implementation of the visitor pattern.

Implements BasicElement.

Definition at line 130 of file symbolelement.cpp.

◆ calcSizes()

void SymbolElement::calcSizes ( const ContextStyle & cstyle,
ContextStyle::TextStyle tstyle,
ContextStyle::IndexStyle istyle,
StyleAttributes & style )
virtual

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

Implements BasicElement.

Definition at line 197 of file symbolelement.cpp.

◆ clone()

virtual SymbolElement * SymbolElement::clone ( )
inlinevirtual

Implements BasicElement.

Definition at line 44 of file symbolelement.h.

◆ dispatchFontCommand()

virtual void SymbolElement::dispatchFontCommand ( FontCommand * cmd)
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.

◆ formulaString()

TQString SymbolElement::formulaString ( )
virtual

Reimplemented from BasicElement.

Definition at line 829 of file symbolelement.cpp.

◆ getChild()

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

Returns the child at the cursor.

Reimplemented from BasicElement.

Definition at line 615 of file symbolelement.cpp.

◆ getIndex()

ElementIndexPtr SymbolElement::getIndex ( int position)

Returns the index at the position.

Defaults to upperRight.

Definition at line 693 of file symbolelement.cpp.

◆ getLowerIndex()

ElementIndexPtr SymbolElement::getLowerIndex ( )
inline

Definition at line 211 of file symbolelement.h.

◆ getMainChild()

virtual SequenceElement * SymbolElement::getMainChild ( )
inlinevirtual

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. */ 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* cursor, BasicElement* from);

/** 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* cursor, BasicElement* from);

children

/** 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 from BasicElement.

Definition at line 144 of file symbolelement.h.

◆ getTagName()

virtual TQString SymbolElement::getTagName ( ) const
inlineprotectedvirtual

Returns the tag name of this element type.

Reimplemented from BasicElement.

Definition at line 239 of file symbolelement.h.

◆ getUpperIndex()

ElementIndexPtr SymbolElement::getUpperIndex ( )
inline

Definition at line 210 of file symbolelement.h.

◆ goToPos()

BasicElement * SymbolElement::goToPos ( FormulaCursor * cursor,
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 136 of file symbolelement.cpp.

◆ hasLower()

bool SymbolElement::hasLower ( ) const
inline

Definition at line 197 of file symbolelement.h.

◆ hasUpper()

bool SymbolElement::hasUpper ( ) const
inline

Moves the cursor away from the given child.

The cursor is guaranteed to be inside this element.

Definition at line 196 of file symbolelement.h.

◆ insert()

void SymbolElement::insert ( FormulaCursor * cursor,
TQPtrList< BasicElement > & newChildren,
Direction direction )
virtual

Inserts all new children at the cursor position.

Draws the whole element including its children.

Places the cursor according to the direction.

You only can insert one index at a time. So the list must contain exactly on SequenceElement. And the index you want to insert must not exist already.

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

The `parentOrigin' is the point this element's parent starts. We can use our parentPosition to get our own origin then. */ void SymbolElement::draw( TQPainter& painter, const LuPixelRect& r, 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( r ) ) return;

luPt mySize = context.getAdjustedSize( tstyle, style.sizeFactor() ); symbol->draw( painter, r, context, tstyle, style, mySize, myPos ); content->draw( painter, r, context, tstyle, istyle, style, myPos ); if ( hasUpper() ) { upper->draw( painter, r, context, context.convertTextStyleIndex( tstyle ), context.convertIndexStyleUpper( istyle ), style, myPos ); } if ( hasLower() ) { lower->draw( painter, r, context, context.convertTextStyleIndex( tstyle ), context.convertIndexStyleLower( istyle ), style, myPos ); }

Debug

}

void SymbolElement::dispatchFontCommand( FontCommand* cmd ) { content->dispatchFontCommand( cmd ); if ( hasUpper() ) { upper->dispatchFontCommand( cmd ); } if ( hasLower() ) { lower->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 SymbolElement::moveLeft(FormulaCursor* cursor, BasicElement* from) { if (cursor->isSelectionMode()) { getParent()->moveLeft(cursor, this); } else { bool linear = cursor->getLinearMovement(); if (from == getParent()) { content->moveLeft(cursor, this); } else if (from == content) { if (linear && hasLower()) { lower->moveLeft(cursor, this); } else if (linear && hasUpper()) { upper->moveLeft(cursor, this); } else { getParent()->moveLeft(cursor, this); } } else if (from == lower) { if (linear && hasUpper()) { upper->moveLeft(cursor, this); } else { getParent()->moveLeft(cursor, this); } } else if (from == upper) { 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 SymbolElement::moveRight(FormulaCursor* cursor, BasicElement* from) { if (cursor->isSelectionMode()) { getParent()->moveRight(cursor, this); } else { bool linear = cursor->getLinearMovement(); if (from == getParent()) { if (linear && hasUpper()) { upper->moveRight(cursor, this); } else if (linear && hasLower()) { lower->moveRight(cursor, this); } else { content->moveRight(cursor, this); } } else if (from == upper) { if (linear && hasLower()) { lower->moveRight(cursor, this); } else { content->moveRight(cursor, this); } } else if (from == lower) { content->moveRight(cursor, this); } else if (from == content) { 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 SymbolElement::moveUp(FormulaCursor* cursor, BasicElement* from) { if (cursor->isSelectionMode()) { getParent()->moveUp(cursor, this); } else { if (from == content) { if (hasUpper()) { upper->moveLeft(cursor, this); } else { getParent()->moveUp(cursor, this); } } else if (from == upper) { getParent()->moveUp(cursor, this); } else if ((from == getParent()) || (from == lower)) { content->moveRight(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 SymbolElement::moveDown(FormulaCursor* cursor, BasicElement* from) { if (cursor->isSelectionMode()) { getParent()->moveDown(cursor, this); } else { if (from == content) { if (hasLower()) { lower->moveLeft(cursor, this); } else { getParent()->moveDown(cursor, this); } } else if (from == lower) { getParent()->moveDown(cursor, this); } else if ((from == getParent()) || (from == upper)) { content->moveRight(cursor, this); } } }

children

main child

If an element has children one has to become the main one.

void SymbolElement::setMainChild(SequenceElement* child) { formula()->elementRemoval(content); content = child; content->setParent(this); formula()->changed(); }

/** Inserts all new children at the cursor position. Places the cursor according to the direction.

You only can insert one index at a time. So the list must contain exactly on SequenceElement. And the index you want to insert must not exist already.

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

Reimplemented from BasicElement.

Definition at line 530 of file symbolelement.cpp.

◆ moveToLower()

void SymbolElement::moveToLower ( FormulaCursor * cursor,
Direction direction )

Definition at line 680 of file symbolelement.cpp.

◆ moveToUpper()

void SymbolElement::moveToUpper ( FormulaCursor * cursor,
Direction direction )

Definition at line 668 of file symbolelement.cpp.

◆ normalize()

void SymbolElement::normalize ( FormulaCursor * cursor,
Direction direction )
virtual

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

Reimplemented from BasicElement.

Definition at line 602 of file symbolelement.cpp.

◆ readAttributesFromDom()

bool SymbolElement::readAttributesFromDom ( TQDomElement element)
protectedvirtual

Reads our attributes from the element.

Returns false if it failed.

Reimplemented from BasicElement.

Definition at line 736 of file symbolelement.cpp.

◆ readContentFromDom()

bool SymbolElement::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 from BasicElement.

Definition at line 755 of file symbolelement.cpp.

◆ remove()

void SymbolElement::remove ( FormulaCursor * cursor,
TQPtrList< BasicElement > & removedChildren,
Direction direction )
virtual

Removes all selected children and returns them.

Places the cursor to where the children have been.

The cursor has to be inside one of our indexes which is supposed to be empty. The index will be removed and the cursor will be placed to the removed index so it can be inserted again. This methode is called by SequenceElement::remove only.

The ownership of the list is passed to the caller.

Reimplemented from BasicElement.

Definition at line 570 of file symbolelement.cpp.

◆ selectChild()

void SymbolElement::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 633 of file symbolelement.cpp.

◆ setToLower()

void SymbolElement::setToLower ( FormulaCursor * cursor)

Definition at line 651 of file symbolelement.cpp.

◆ setToUpper()

void SymbolElement::setToUpper ( FormulaCursor * cursor)

Definition at line 646 of file symbolelement.cpp.

◆ toLatex()

TQString SymbolElement::toLatex ( )
virtual
Returns
the latex representation of the element and of the element's children

Reimplemented from BasicElement.

Definition at line 787 of file symbolelement.cpp.

◆ writeDom()

void SymbolElement::writeDom ( TQDomElement element)
protectedvirtual

Appends our attributes to the dom element.

Reimplemented from BasicElement.

Definition at line 708 of file symbolelement.cpp.

◆ writeMathML()

void SymbolElement::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 from BasicElement.

Definition at line 855 of file symbolelement.cpp.


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