kformula/flake

TokenElement Class Reference

Baseclass for all token elements. More...

#include <TokenElement.h>

Inheritance diagram for TokenElement:

List of all members.

Public Member Functions

 TokenElement (BasicElement *parent=0)
bool acceptCursor (const FormulaCursor &cursor)
const QList< BasicElement * > childElements () const
virtual QLineF cursorLine (int position) const
double cursorOffset (const int position) const
virtual int endPosition () const
QList< GlyphElement * > glyphList (int position, int length)
virtual bool insertChild (int position, BasicElement *child)
void insertGlyphs (int position, QList< GlyphElement * > glyphs)
virtual bool insertText (int position, const QString &text)
void layout (const AttributeManager *am)
virtual bool moveCursor (FormulaCursor &newcursor, FormulaCursor &oldcursor)
void paint (QPainter &painter, AttributeManager *am)
virtual int removeText (int position, int length=1)
virtual QRectF renderToPath (const QString &raw, QPainterPath &path) const =0
virtual bool setCursorTo (FormulaCursor &cursor, QPointF point)
void setText (const QString &text)
const QStringtext ()
virtual const QString writeElementContent () const

Protected Member Functions

QFont font () const
bool readMathMLContent (const KoXmlElement &parent)
virtual void writeMathMLContent (KoXmlWriter *writer) const

Protected Attributes

QSizeF m_originalSize
QString m_rawString
bool m_stretchHorizontally
bool m_stretchVertically

Detailed Description

Baseclass for all token elements.

The MathML specification describes a number of token elements. The classes of these all derive from TokenElement except of mspace. Because of the huge similarity between the token elements loading, saving, painting and layouting code can mostly be shared. This is because token elements hold some text or string that has to be dealt with. The handling of embedded glyphs is also implemented in TokenEa list of the embedded GlyphElements. The TokenElement's QString m_rawString is the string that holds the raw data for the TokenElement. This string contains also QChar that are set to the QChar::ObjectReplacementCharacter category. For rendering these QChar's are replaced with the content of the glyph elements they represent in the raw string.

Definition at line 46 of file TokenElement.h.


Constructor & Destructor Documentation

TokenElement::TokenElement ( BasicElement parent = 0  ) 

The standart constructor.

Definition at line 30 of file TokenElement.cpp.


Member Function Documentation

bool TokenElement::acceptCursor ( const FormulaCursor cursor  )  [virtual]

Implement the cursor behaviour for the element.

Parameters:
direction Indicates whether the cursor moves up, down, right or left
Returns:
A this pointer if the element accepts if not the element to asked instead

Reimplemented from BasicElement.

Definition at line 257 of file TokenElement.cpp.

const QList< BasicElement * > TokenElement::childElements (  )  const [virtual]

Obtain a list of all child elements of this element.

Returns:
a QList with pointers to all child elements

Reimplemented from BasicElement.

Definition at line 36 of file TokenElement.cpp.

QLineF TokenElement::cursorLine ( int  position  )  const [virtual]

inherited from BasicElement

Reimplemented from BasicElement.

Definition at line 248 of file TokenElement.cpp.

double TokenElement::cursorOffset ( const int  position  )  const

Obtain the x position of the cursor inside this token element.

Parameters:
position The cursor position in the element
Returns:
The offset from the left origin

Definition at line 285 of file TokenElement.cpp.

int TokenElement::endPosition (  )  const [virtual]

inherited from BasicElement

Reimplemented from BasicElement.

Definition at line 66 of file TokenElement.cpp.

QFont TokenElement::font (  )  const [protected]
Returns:
The font to use

Definition at line 290 of file TokenElement.cpp.

QList< GlyphElement * > TokenElement::glyphList ( int  position,
int  length 
)

Definition at line 173 of file TokenElement.cpp.

bool TokenElement::insertChild ( int  position,
BasicElement child 
) [virtual]

inherited from BasicElement

Definition at line 144 of file TokenElement.cpp.

void TokenElement::insertGlyphs ( int  position,
QList< GlyphElement * >  glyphs 
)

insert a list of glyphs without changing rawString, position points to m_glyphs list

Definition at line 158 of file TokenElement.cpp.

bool TokenElement::insertText ( int  position,
const QString text 
) [virtual]

Insert text at position.

Returns:
true, if the insert was succesfull

Reimplemented in OperatorElement.

Definition at line 166 of file TokenElement.cpp.

void TokenElement::layout ( const AttributeManager am  )  [virtual]

Calculate the size of the element and the positions of its children.

Parameters:
am The AttributeManager providing information about attributes values

Reimplemented from BasicElement.

Definition at line 71 of file TokenElement.cpp.

bool TokenElement::moveCursor ( FormulaCursor newcursor,
FormulaCursor oldcursor 
) [virtual]

inherited from BasicElement

Reimplemented from BasicElement.

Definition at line 263 of file TokenElement.cpp.

void TokenElement::paint ( QPainter painter,
AttributeManager am 
) [virtual]

Render the element to the given QPainter.

Parameters:
painter The QPainter to paint the element to
am AttributeManager containing style info

Reimplemented from BasicElement.

Definition at line 45 of file TokenElement.cpp.

bool TokenElement::readMathMLContent ( const KoXmlElement &  parent  )  [protected, virtual]

Read contents of the token element. Content should be unicode text strings or mglyphs.

Reimplemented from BasicElement.

Reimplemented in OperatorElement.

Definition at line 308 of file TokenElement.cpp.

int TokenElement::removeText ( int  position,
int  length = 1 
) [virtual]

remove the letter after position and return the starting position of the removed glyphs in the glyphlist

Definition at line 199 of file TokenElement.cpp.

virtual QRectF TokenElement::renderToPath ( const QString raw,
QPainterPath path 
) const [pure virtual]

Process raw and render it to path.

Implemented in GlyphElement, IdentifierElement, NumberElement, OperatorElement, StringElement, and TextElement.

bool TokenElement::setCursorTo ( FormulaCursor cursor,
QPointF  point 
) [virtual]

inherited from BasicElement

Reimplemented from BasicElement.

Definition at line 225 of file TokenElement.cpp.

void TokenElement::setText ( const QString text  ) 

set m_rawString to text and empty the glyph list

Definition at line 296 of file TokenElement.cpp.

const QString & TokenElement::text (  ) 
Returns:
the raw string

Definition at line 302 of file TokenElement.cpp.

const QString TokenElement::writeElementContent (  )  const [virtual]

return the content of the element to kDebug(), only for debugging

Reimplemented from BasicElement.

Definition at line 361 of file TokenElement.cpp.

void TokenElement::writeMathMLContent ( KoXmlWriter *  writer  )  const [protected, virtual]

Write all content to the KoXmlWriter - reimplemented by the child elements.

Reimplemented from BasicElement.

Definition at line 340 of file TokenElement.cpp.


Member Data Documentation

Size to stretch from.

Definition at line 143 of file TokenElement.h.

The raw string like it is read and written from MathML.

Definition at line 146 of file TokenElement.h.

Whether the element should be stretched horizontally (e.g. arrows).

Definition at line 138 of file TokenElement.h.

Whether the element should be stretched vertically (e.g. brackets).

Definition at line 140 of file TokenElement.h.


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