lib

#include <fractionelement.h>

Inheritance diagram for FractionElement:
BasicElement

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 &cstyle, ContextStyle::TextStyle tstyle, ContextStyle::IndexStyle istyle, StyleAttributes &style)
virtual void dispatchFontCommand (FontCommand *cmd)
virtual void insert (FormulaCursor *, TQPtrList< BasicElement > &, Direction)
virtual void remove (FormulaCursor *, TQPtrList< BasicElement > &, Direction)
virtual SequenceElement * getMainChild ()
SequenceElement * getNumerator ()
SequenceElement * getDenominator ()
virtual bool isSenseless ()
virtual void selectChild (FormulaCursor *cursor, BasicElement *child)
void showLine (bool line)
virtual TQString toLatex ()
virtual TQString formulaString ()
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 bool isInvisible () const
LuPixelPoint widgetPos ()
virtual void moveHome (FormulaCursor *)
virtual void moveEnd (FormulaCursor *)
virtual void goInside (FormulaCursor *cursor)
virtual void normalize (FormulaCursor *, Direction)
virtual BasicElement * getChild (FormulaCursor *, Direction=beforeCursor)
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 *)

Protected Member Functions

virtual TQString getTagName () const
virtual void writeDom (TQDomElement element)
virtual bool readAttributesFromDom (TQDomElement element)
virtual bool readContentFromDom (TQDomNode &node)
virtual bool readAttributesFromMathMLDom (const TQDomElement &element)
virtual int readContentFromMathMLDom (TQDomNode &node)
Protected Member Functions inherited from BasicElement
bool buildChild (SequenceElement *child, TQDomNode node, TQString name)
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 fraction.

Definition at line 33 of file fractionelement.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum

Definition at line 37 of file fractionelement.h.

Constructor & Destructor Documentation

◆ FractionElement() [1/2]

FractionElement::FractionElement ( BasicElement * parent = 0)

Definition at line 35 of file fractionelement.cpp.

◆ ~FractionElement()

FractionElement::~FractionElement ( )

Definition at line 45 of file fractionelement.cpp.

◆ FractionElement() [2/2]

FractionElement::FractionElement ( const FractionElement & other)

Definition at line 51 of file fractionelement.cpp.

Member Function Documentation

◆ accept()

bool FractionElement::accept ( ElementVisitor * )
virtual

Visit this element.

An implementation of the visitor pattern.

Implements BasicElement.

Definition at line 67 of file fractionelement.cpp.

◆ calcSizes()

void FractionElement::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 126 of file fractionelement.cpp.

◆ clone()

virtual FractionElement * FractionElement::clone ( )
inlinevirtual

Implements BasicElement.

Definition at line 44 of file fractionelement.h.

◆ dispatchFontCommand()

virtual void FractionElement::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& cstyle, ContextStyle::TextStyle tstyle, ContextStyle::IndexStyle istyle, StyleAttributes& style, const LuPixelPoint& parentOrigin );

/** Dispatch this FontCommand to all our TextElement children.

Reimplemented from BasicElement.

◆ entered()

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 72 of file fractionelement.cpp.

◆ formulaString()

TQString FractionElement::formulaString ( )
virtual

Reimplemented from BasicElement.

Definition at line 575 of file fractionelement.cpp.

◆ getDenominator()

SequenceElement * FractionElement::getDenominator ( )
inline

Definition at line 149 of file fractionelement.h.

◆ getMainChild()

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 378 of file fractionelement.cpp.

◆ getNumerator()

SequenceElement * FractionElement::getNumerator ( )
inline

Definition at line 148 of file fractionelement.h.

◆ getTagName()

virtual TQString FractionElement::getTagName ( ) const
inlineprotectedvirtual

Returns the tag name of this element type.

Reimplemented from BasicElement.

Definition at line 198 of file fractionelement.h.

◆ getTokenType()

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

Reimplemented from BasicElement.

Definition at line 54 of file fractionelement.h.

◆ goToPos()

BasicElement * FractionElement::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 83 of file fractionelement.cpp.

◆ insert()

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

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

Draws the whole element including its children.

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);

/** Reinserts the denominator if it has been removed.

The `parentOrigin' is the point this element's parent starts. We can use our parentPosition to get our own origin then. */ void FractionElement::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;

numerator->draw( painter, r, context, context.convertTextStyleFraction( tstyle ), context.convertIndexStyleUpper( istyle ), style, myPos); if (denominator) { // Can be temporarily 0 see FractionElement::remove denominator->draw( painter, r, context, context.convertTextStyleFraction( tstyle ), context.convertIndexStyleLower( istyle ), style, myPos); }

if ( withLine() ) { TODO: thickness double factor = style.sizeFactor(); double linethickness = lineThickness( context, factor ); painter.setPen( TQPen( style.color(), context.layoutUnitToPixelY( linethickness ) ) ); painter.drawLine( context.layoutUnitToPixelX( myPos.x() ), context.layoutUnitToPixelY( myPos.y() + axis( context, tstyle, factor ) ), context.layoutUnitToPixelX( myPos.x() + getWidth() ), context.layoutUnitToPixelY( myPos.y() + axis( context, tstyle, factor ) ) ); } }

void FractionElement::dispatchFontCommand( FontCommand* cmd ) { numerator->dispatchFontCommand( cmd ); denominator->dispatchFontCommand( cmd ); }

/** 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 FractionElement::moveLeft(FormulaCursor* cursor, BasicElement* from) { if (cursor->isSelectionMode()) { getParent()->moveLeft(cursor, this); } else { bool linear = cursor->getLinearMovement(); if (from == getParent()) { if (linear) { denominator->moveLeft(cursor, this); } else { numerator->moveLeft(cursor, this); } } else if (from == denominator) { numerator->moveLeft(cursor, this); } else { 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 FractionElement::moveRight(FormulaCursor* cursor, BasicElement* from) { if (cursor->isSelectionMode()) { getParent()->moveRight(cursor, this); } else { bool linear = cursor->getLinearMovement(); if (from == getParent()) { numerator->moveRight(cursor, this); } else if (from == numerator) { if (linear) { denominator->moveRight(cursor, this); } else { getParent()->moveRight(cursor, this); } } else { 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 FractionElement::moveUp(FormulaCursor* cursor, BasicElement* from) { if (cursor->isSelectionMode()) { getParent()->moveUp(cursor, this); } else { if (from == getParent()) { denominator->moveRight(cursor, this); } else if (from == denominator) { numerator->moveRight(cursor, this); } else { getParent()->moveUp(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 FractionElement::moveDown(FormulaCursor* cursor, BasicElement* from) { if (cursor->isSelectionMode()) { getParent()->moveDown(cursor, this); } else { if (from == getParent()) { numerator->moveRight(cursor, this); } else if (from == numerator) { denominator->moveRight(cursor, this); } else { getParent()->moveDown(cursor, this); } } }

/** Reinserts the denominator if it has been removed.

Reimplemented from BasicElement.

Definition at line 314 of file fractionelement.cpp.

◆ isSenseless()

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 368 of file fractionelement.cpp.

◆ readAttributesFromDom()

bool FractionElement::readAttributesFromDom ( TQDomElement element)
protectedvirtual

Reads our attributes from the element.

Returns false if it failed.

Reimplemented from BasicElement.

Definition at line 430 of file fractionelement.cpp.

◆ readAttributesFromMathMLDom()

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

Reads our attributes from the MathML element.

Returns false if it failed.

Reimplemented from BasicElement.

Definition at line 447 of file fractionelement.cpp.

◆ readContentFromDom()

bool FractionElement::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 513 of file fractionelement.cpp.

◆ readContentFromMathMLDom()

int FractionElement::readContentFromMathMLDom ( TQDomNode & node)
protectedvirtual

Reads our content from the MathML node.

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

Reimplemented from BasicElement.

Definition at line 539 of file fractionelement.cpp.

◆ remove()

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

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 343 of file fractionelement.cpp.

◆ selectChild()

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 396 of file fractionelement.cpp.

◆ showLine()

void FractionElement::showLine ( bool line)
inline

Moves the cursor away from the given child.

The cursor is guaranteed to be inside this element. Tells whether the fraction should be drawn with a line.

Definition at line 173 of file fractionelement.h.

◆ toLatex()

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

Reimplemented from BasicElement.

Definition at line 565 of file fractionelement.cpp.

◆ writeDom()

void FractionElement::writeDom ( TQDomElement element)
protectedvirtual

Appends our attributes to the dom element.

Reimplemented from BasicElement.

Definition at line 410 of file fractionelement.cpp.


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