lib Library API Documentation

FractionElement Class Reference

A fraction. More...

#include <fractionelement.h>

Inheritance diagram for FractionElement:

Inheritance graph
[legend]
Collaboration diagram for FractionElement:

Collaboration graph
[legend]
List of all members.

Public Types

enum  { numeratorPos, denominatorPos }

Public Member Functions

 FractionElement (BasicElement *parent=0)
 FractionElement (const FractionElement &)
virtual FractionElement * clone ()
virtual bool accept (ElementVisitor *visitor)
virtual TokenType getTokenType () const
virtual void entered (SequenceElement *child)
virtual BasicElement * goToPos (FormulaCursor *, bool &handled, const LuPixelPoint &point, const LuPixelPoint &parentOrigin)
virtual void calcSizes (const ContextStyle &style, ContextStyle::TextStyle tstyle, ContextStyle::IndexStyle istyle)
virtual void draw (QPainter &painter, const LuPixelRect &r, const ContextStyle &style, ContextStyle::TextStyle tstyle, ContextStyle::IndexStyle istyle, const LuPixelPoint &parentOrigin)
virtual void dispatchFontCommand (FontCommand *cmd)
virtual void moveLeft (FormulaCursor *cursor, BasicElement *from)
virtual void moveRight (FormulaCursor *cursor, BasicElement *from)
virtual void moveUp (FormulaCursor *cursor, BasicElement *from)
virtual void moveDown (FormulaCursor *cursor, BasicElement *from)
virtual void insert (FormulaCursor *, QPtrList< BasicElement > &, Direction)
virtual void remove (FormulaCursor *, QPtrList< BasicElement > &, Direction)
virtual SequenceElement * getMainChild ()
SequenceElement * getNumerator ()
SequenceElement * getDenominator ()
virtual bool isSenseless ()
virtual void selectChild (FormulaCursor *cursor, BasicElement *child)
void showLine (bool line)
virtual QString toLatex ()
virtual QString formulaString ()
virtual void writeMathML (QDomDocument &doc, QDomNode parent, bool oasisFormat=false)

Protected Member Functions

virtual QString getTagName () const
virtual void writeDom (QDomElement element)
virtual bool readAttributesFromDom (QDomElement element)
virtual bool readContentFromDom (QDomNode &node)

Detailed Description

A fraction.

Definition at line 33 of file fractionelement.h.


Member Function Documentation

bool FractionElement::accept (  ElementVisitor *  visitor  )  [virtual]
 

Visit this element.

An implementation of the visitor pattern.

Implements BasicElement.

Definition at line 58 of file fractionelement.cc.

virtual TokenType FractionElement::getTokenType (   )  const [inline, virtual]
 

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

Reimplemented from BasicElement.

Definition at line 54 of file fractionelement.h.

void FractionElement::entered (  SequenceElement *  child  )  [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 63 of file fractionelement.cc.

References BasicElement::formula().

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

Definition at line 74 of file fractionelement.cc.

References BasicElement::getHeight(), BasicElement::getX(), BasicElement::getY(), SequenceElement::goToPos(), BasicElement::goToPos(), and SequenceElement::moveLeft().

void FractionElement::calcSizes (  const ContextStyle &  style,
ContextStyle::TextStyle  tstyle,
ContextStyle::IndexStyle  istyle
)  [virtual]
 

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

Implements BasicElement.

Definition at line 117 of file fractionelement.cc.

References SequenceElement::calcSizes(), BasicElement::getHeight(), BasicElement::getWidth(), BasicElement::setX(), and BasicElement::setY().

void FractionElement::draw (  QPainter &  painter,
const LuPixelRect &  r,
const ContextStyle &  style,
ContextStyle::TextStyle  tstyle,
ContextStyle::IndexStyle  istyle,
const LuPixelPoint &  parentOrigin
)  [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.

Implements BasicElement.

Definition at line 147 of file fractionelement.cc.

References ContextStyle::convertIndexStyleLower(), ContextStyle::convertIndexStyleUpper(), ContextStyle::convertTextStyleFraction(), SequenceElement::draw(), ContextStyle::getDefaultColor(), ContextStyle::getLineWidth(), KoZoomHandler::layoutUnitToPixelX(), and KoZoomHandler::layoutUnitToPixelY().

void FractionElement::dispatchFontCommand (  FontCommand *  cmd  )  [virtual]
 

Dispatch this FontCommand to all our TextElement children.

Reimplemented from BasicElement.

Definition at line 177 of file fractionelement.cc.

References SequenceElement::dispatchFontCommand().

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

Definition at line 188 of file fractionelement.cc.

References SequenceElement::moveLeft().

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

Definition at line 218 of file fractionelement.cc.

References SequenceElement::moveRight().

void FractionElement::moveUp (  FormulaCursor *  cursor,
BasicElement *  from
)  [virtual]
 

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

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

Reimplemented from BasicElement.

Definition at line 248 of file fractionelement.cc.

References SequenceElement::moveRight().

void FractionElement::moveDown (  FormulaCursor *  cursor,
BasicElement *  from
)  [virtual]
 

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

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

Reimplemented from BasicElement.

Definition at line 272 of file fractionelement.cc.

References SequenceElement::moveRight().

void FractionElement::insert (  FormulaCursor *  ,
QPtrList< BasicElement > &  ,
Direction 
)  [virtual]
 

Reinserts the denominator if it has been removed.

Reimplemented from BasicElement.

Definition at line 294 of file fractionelement.cc.

References BasicElement::formula(), SequenceElement::moveLeft(), SequenceElement::moveRight(), and BasicElement::setParent().

void FractionElement::remove (  FormulaCursor *  ,
QPtrList< BasicElement > &  ,
Direction 
)  [virtual]
 

Removes all selected children and returns them.

Places the cursor to where the children have been.

We remove ourselve if we are requested to remove our numerator.

It is possible to remove the denominator. But after this we are senseless and the caller is required to replace us.

Reimplemented from BasicElement.

Definition at line 323 of file fractionelement.cc.

References BasicElement::formula(), FormulaCursor::getPos(), and FormulaCursor::setTo().

SequenceElement * FractionElement::getMainChild (   )  [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 from BasicElement.

Definition at line 358 of file fractionelement.cc.

bool FractionElement::isSenseless (   )  [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 from BasicElement.

Definition at line 348 of file fractionelement.cc.

void FractionElement::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 376 of file fractionelement.cc.

References FormulaCursor::setTo().

void FractionElement::showLine (  bool  line  )  [inline]
 

Tells whether the fraction should be drawn with a line.

Definition at line 169 of file fractionelement.h.

Referenced by SequenceElement::buildCommand(), and NameSequence::replaceElement().

QString FractionElement::toLatex (   )  [virtual]
 

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

Reimplemented from BasicElement.

Definition at line 448 of file fractionelement.cc.

References SequenceElement::toLatex().

void FractionElement::writeMathML (  QDomDocument &  doc,
QDomNode  parent,
bool  oasisFormat = false
)  [virtual]
 

Same as above, just MathML.

Reimplemented from BasicElement.

Definition at line 463 of file fractionelement.cc.

References SequenceElement::writeMathML().

virtual QString FractionElement::getTagName (   )  const [inline, protected, virtual]
 

Returns the tag name of this element type.

Reimplemented from BasicElement.

Definition at line 188 of file fractionelement.h.

void FractionElement::writeDom (  QDomElement  element  )  [protected, virtual]
 

Appends our attributes to the dom element.

Reimplemented from BasicElement.

Definition at line 390 of file fractionelement.cc.

References BasicElement::getElementDom(), and BasicElement::writeDom().

bool FractionElement::readAttributesFromDom (  QDomElement  element  )  [protected, virtual]
 

Reads our attributes from the element.

Returns false if it failed.

Reimplemented from BasicElement.

Definition at line 410 of file fractionelement.cc.

References BasicElement::readAttributesFromDom().

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

Definition at line 427 of file fractionelement.cc.

References BasicElement::buildChild(), and BasicElement::readContentFromDom().


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.4.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Mon Feb 13 09:40:39 2006 by doxygen 1.4.2 written by Dimitri van Heesch, © 1997-2003