lib Library API Documentation

Container Class Reference

The document. More...

#include <kformulacontainer.h>

Inheritance diagram for Container:

Inheritance graph
[legend]
Collaboration diagram for Container:

Collaboration graph
[legend]
List of all members.

Public Types

enum  ViewActions {
  EXIT_LEFT, EXIT_RIGHT, EXIT_ABOVE, EXIT_BELOW,
  INSERT_FORMULA, REMOVE_FORMULA
}

Signals

void cursorMoved (FormulaCursor *cursor)
void leaveFormula (Container *formula, FormulaCursor *cursor, int cmd)
void formulaChanged (int width, int height)
void formulaChanged (double width, double height)
void statusMsg (const QString &msg)
void errorMsg (const QString &)
void elementWillVanish (BasicElement *element)
void formulaLoaded (FormulaElement *)
void baseSizeChanged (int)

Public Member Functions

 Container (Document *doc, int pos, bool registerMe=true)
void initialize ()
FormulaCursor * createCursor ()
void elementRemoval (BasicElement *child)
void changed ()
void cursorHasMoved (FormulaCursor *)
void moveOutLeft (FormulaCursor *)
void moveOutRight (FormulaCursor *)
void moveOutAbove (FormulaCursor *)
void moveOutBelow (FormulaCursor *)
void tell (const QString &msg)
void removeFormula (FormulaCursor *)
void registerFormula (int pos=-1)
void unregisterFormula ()
void baseSizeChanged (int size, bool owned)
void draw (QPainter &painter, const QRect &r, const QColorGroup &cg, bool edit=false)
void draw (QPainter &painter, const QRect &r, bool edit=false)
void save (QDomElement &root)
void saveMathML (QTextStream &stream, bool oasisFormat=false)
bool loadMathML (const QDomDocument &doc, bool oasisFormat=false)
bool load (const QDomElement &fe)
QString texString ()
QString formulaString ()
void print (KPrinter &printer)
QImage drawImage (int width, int height)
FormulaCursor * activeCursor ()
const FormulaCursor * activeCursor () const
void setActiveCursor (FormulaCursor *cursor)
QRect boundingRect () const
QRect coveredRect ()
double width () const
double height () const
double baseline () const
void moveTo (int x, int y)
virtual double getDocumentX () const
virtual double getDocumentY () const
virtual void setDocumentPosition (double, double)
virtual void startEvaluation ()
void testDirty ()
virtual void recalc ()
bool isEmpty ()
virtual Document * document () const
virtual const SymbolTable & getSymbolTable () const
int fontSize () const
void setFontSize (int pointSize, bool forPrint=false)
void setFontSizeDirect (int pointSize)
void updateMatrixActions ()
void input (QKeyEvent *event)
void performRequest (Request *request)
void paste ()
void paste (const QDomDocument &document, QString desc)
void copy ()
void cut ()

Protected Member Functions

KoCommandHistory * getHistory () const
FormulaElement * rootElement () const
virtual FormulaElement * createMainSequence ()
void emitErrorMsg (const QString &)

Friends

class MimeSource
class TestFormulaCursor
class TestFormulaElement
class TestIndexElement
class TestCommands

Detailed Description

The document.

Actually only one part of the whole. Provides everything to edit the formula.

Definition at line 90 of file kformulacontainer.h.


Constructor & Destructor Documentation

Container::Container (  Document *  doc,
int  pos,
bool  registerMe = true
) 
 

Constructs a new formula and register it with the document.

Parameters:
doc the document we belong to.
pos the formulas position inside its document.
registerMe whether the formula is to be registered with the document.

Definition at line 110 of file kformulacontainer.cc.

References registerFormula().


Member Function Documentation

void Container::initialize (   ) 
 

Needs to be called before anything else can be done with a newly created formula! This is required to allow polymorphic formulas.

(The virtual method problem.)

Definition at line 127 of file kformulacontainer.cc.

References createCursor(), createMainSequence(), and recalc().

Referenced by Document::createFormula().

FormulaCursor * Container::createCursor (   ) 
 

Returns a new cursor.

It points to the beginning of the formula. The cursor gets no messages if the formula changes so use this with care!

Definition at line 142 of file kformulacontainer.cc.

References rootElement().

Referenced by initialize().

void Container::elementRemoval (  BasicElement *  child  )  [virtual]
 

Gets called just before the child is removed from the element tree.

Reimplemented from FormulaDocument.

Definition at line 158 of file kformulacontainer.cc.

References elementWillVanish().

void Container::changed (   )  [virtual]
 

Gets called when ever something changes and we need to recalc.

Reimplemented from FormulaDocument.

Definition at line 167 of file kformulacontainer.cc.

void Container::cursorHasMoved (  FormulaCursor *   )  [virtual]
 

Gets called when a request has the side effect of moving the cursor.

In the end any operation that moves the cursor should call this.

Reimplemented from FormulaDocument.

Definition at line 172 of file kformulacontainer.cc.

void Container::moveOutLeft (  FormulaCursor *   )  [virtual]
 

Inside the formula occurred an event that must be handled outside.

Reimplemented from FormulaDocument.

Definition at line 177 of file kformulacontainer.cc.

References leaveFormula().

void Container::registerFormula (  int  pos = -1  ) 
 

Register and unregister this formula with its document.

Definition at line 208 of file kformulacontainer.cc.

References document().

Referenced by Container().

void Container::baseSizeChanged (  int  size,
bool  owned
)  [virtual]
 

The base size changed.

If not owned it uses the default one now.

Reimplemented from FormulaDocument.

Definition at line 219 of file kformulacontainer.cc.

References ContextStyle::baseSize(), and document().

void Container::draw (  QPainter &  painter,
const QRect &  r,
const QColorGroup &  cg,
bool  edit = false
) 
 

Draws the whole thing.

Definition at line 295 of file kformulacontainer.cc.

void Container::draw (  QPainter &  painter,
const QRect &  r,
bool  edit = false
) 
 

Draws the whole thing.

Definition at line 302 of file kformulacontainer.cc.

References document(), KoZoomHandler::pixelToLayoutUnit(), and rootElement().

void Container::save (  QDomElement &  root  ) 
 

Saves the data into the document.

Definition at line 493 of file kformulacontainer.cc.

References rootElement().

void Container::saveMathML (  QTextStream &  stream,
bool  oasisFormat = false
) 
 

Save formula as MathML.

Definition at line 527 of file kformulacontainer.cc.

References rootElement().

bool Container::loadMathML (  const QDomDocument &  doc,
bool  oasisFormat = false
) 
 

Load function.

Load the formula from the specified file containing MathML .

Definition at line 548 of file kformulacontainer.cc.

References document(), MathML2KFormula::getKFormulaDom(), load(), MathML2KFormula::m_error, and MathML2KFormula::startConversion().

bool Container::load (  const QDomElement &  fe  ) 
 

Loads a formula from the document.

Definition at line 503 of file kformulacontainer.cc.

References BasicElement::buildFromDom(), createMainSequence(), formulaLoaded(), recalc(), and rootElement().

Referenced by loadMathML(), and Document::loadXML().

QString Container::texString (   ) 
 

Returns:
Tex string for the formula

Definition at line 610 of file kformulacontainer.cc.

References rootElement().

void Container::print (  KPrinter &  printer  ) 
 

Prints the formula.

Definition at line 565 of file kformulacontainer.cc.

References document(), and rootElement().

QImage Container::drawImage (  int  width,
int  height
) 
 

Returns:
an image that looks like out formula.

Definition at line 578 of file kformulacontainer.cc.

References document(), KoZoomHandler::layoutUnitToPixelX(), KoZoomHandler::layoutUnitToPixelY(), ContextStyle::setZoomAndResolution(), and KoZoomHandler::zoom().

FormulaCursor * Container::activeCursor (   ) 
 

Returns:
the cursor to be used for editing.

Definition at line 230 of file kformulacontainer.cc.

Referenced by SequenceElement::buildCommand(), copy(), cut(), input(), FormulaElement::input(), paste(), recalc(), and updateMatrixActions().

void Container::setActiveCursor (  FormulaCursor *  cursor  ) 
 

Sets the cursor that is to be used for any editing.

The active cursor might 0. In this case you must not request any change from the formula.

Definition at line 245 of file kformulacontainer.cc.

References document().

QRect Container::boundingRect (   )  const
 

Returns:
the formula's size.

Definition at line 408 of file kformulacontainer.cc.

References document(), KoZoomHandler::layoutUnitToPixelX(), KoZoomHandler::layoutUnitToPixelY(), and rootElement().

Referenced by coveredRect().

QRect Container::coveredRect (   ) 
 

Returns:
the formula's size including its active cursor.

Definition at line 417 of file kformulacontainer.cc.

References boundingRect(), document(), KoZoomHandler::layoutUnitToPixelX(), KoZoomHandler::layoutUnitToPixelY(), and rootElement().

double Container::baseline (   )  const
 

Returns:
the distance between the upper bound and the formulas base line.

Definition at line 446 of file kformulacontainer.cc.

References document(), KoTextZoomHandler::layoutUnitPtToPt(), KoZoomHandler::pixelYToPt(), and rootElement().

void Container::moveTo (  int  x,
int  y
) 
 

Moves the formula to a new location.

This location will be the upper left corner of the rectangle that is drawn by the painter.

Definition at line 453 of file kformulacontainer.cc.

References document(), KoZoomHandler::pixelToLayoutUnitX(), KoZoomHandler::pixelToLayoutUnitY(), and rootElement().

virtual double Container::getDocumentX (   )  const [inline, virtual]
 

KWord uses a transformed painter to draw formulas, so every formula has the internal position (0,0).

But we might need to sort our formulas according to their position inside the document. (This is only needed for math formulas.)

Definition at line 264 of file kformulacontainer.h.

virtual void Container::startEvaluation (   )  [inline, virtual]
 

Start the documents evaluation at this formula.

This must be the formula that changed. The formulas above it won't be affected by this change.

This has no meaning in not evaluating formulas.

Definition at line 275 of file kformulacontainer.h.

void Container::testDirty (   ) 
 

Recalcs the formula and emits the .

*Changed signals if needed.

Definition at line 263 of file kformulacontainer.cc.

References recalc().

void Container::recalc (   )  [virtual]
 

Recalc the formula.

Definition at line 270 of file kformulacontainer.cc.

References activeCursor(), cursorMoved(), formulaChanged(), KoTextZoomHandler::layoutUnitPtToPt(), KoZoomHandler::layoutUnitToPixelX(), KoZoomHandler::layoutUnitToPixelY(), KoZoomHandler::pixelXToPt(), KoZoomHandler::pixelYToPt(), and rootElement().

Referenced by initialize(), load(), and testDirty().

bool Container::isEmpty (   ) 
 

Returns:
true if there is no element.

Definition at line 283 of file kformulacontainer.cc.

References rootElement().

Document * Container::document (   )  const [virtual]
 

Returns:
the document this formula belongs to.

Definition at line 108 of file kformulacontainer.cc.

Referenced by baseline(), baseSizeChanged(), boundingRect(), SequenceElement::buildCommand(), copy(), coveredRect(), draw(), drawImage(), SequenceElement::input(), loadMathML(), moveTo(), print(), registerFormula(), setActiveCursor(), and updateMatrixActions().

void Container::setFontSize (  int  pointSize,
bool  forPrint = false
) 
 

Sets the base font size of this formula.

Definition at line 471 of file kformulacontainer.cc.

References rootElement().

void Container::updateMatrixActions (   ) 
 

If the cursor is in a matrix, the matrix actions will be enabled, otherwise disabled.

Definition at line 484 of file kformulacontainer.cc.

References activeCursor(), document(), and BasicElement::getParent().

void Container::cursorMoved (  FormulaCursor *  cursor  )  [signal]
 

The cursor has been moved but the formula hasn't been changed.

The view that owns the cursor needs to know this.

Referenced by recalc().

void Container::leaveFormula (  Container *  formula,
FormulaCursor *  cursor,
int  cmd
)  [signal]
 

The cursor wants to leave this formula.

Referenced by moveOutLeft().

void Container::formulaChanged (  int  width,
int  height
)  [signal]
 

The formula has changed and needs to be redrawn.

Referenced by recalc().

void Container::statusMsg (  const QString &  msg  )  [signal]
 

A message that might be a useful hint.

Meant for the statusbar.

void Container::errorMsg (  const QString &   )  [signal]
 

A message that describes an error.

Meant for a message box. (?)

void Container::elementWillVanish (  BasicElement *  element  )  [signal]
 

The element is going to leave the formula with and all its children.

Referenced by elementRemoval().

void Container::formulaLoaded (  FormulaElement *   )  [signal]
 

Tells the cursors that we have just loaded a new formula.

Referenced by load().

void Container::baseSizeChanged (  int   )  [signal]
 

We've got a new base size.

void Container::input (  QKeyEvent *  event  ) 
 

General input.

Definition at line 318 of file kformulacontainer.cc.

References activeCursor().

void Container::paste (   ) 
 

Insert data from the clipboard.

Definition at line 338 of file kformulacontainer.cc.

void Container::paste (  const QDomDocument &  document,
QString  desc
) 
 

Insert data from the document.

Definition at line 352 of file kformulacontainer.cc.

References activeCursor(), KFCAdd::addElement(), and FormulaCursor::buildElementsFromDom().

void Container::copy (   ) 
 

Copy the current selection to the clipboard.

Definition at line 370 of file kformulacontainer.cc.

References activeCursor(), FormulaCursor::copy(), and document().

Referenced by cut().

void Container::cut (   ) 
 

Copy and remove.

Definition at line 382 of file kformulacontainer.cc.

References activeCursor(), copy(), and FormulaCursor::isSelection().

FormulaElement * Container::rootElement (   )  const [protected]
 

Returns:
the root of our element tree. That's the formula's structure.

Definition at line 107 of file kformulacontainer.cc.

Referenced by baseline(), boundingRect(), coveredRect(), createCursor(), draw(), isEmpty(), load(), moveTo(), print(), recalc(), save(), saveMathML(), setFontSize(), and texString().

FormulaElement * Container::createMainSequence (   )  [protected, virtual]
 

Factory method.

Definition at line 136 of file kformulacontainer.cc.

Referenced by initialize(), and load().


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:24 2006 by doxygen 1.4.2 written by Dimitri van Heesch, © 1997-2003