lib Library API Documentation

FormulaCursor Class Reference

The selection. More...

#include <formulacursor.h>

Collaboration diagram for FormulaCursor:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 FormulaCursor (FormulaElement *element)
FormulaCursoroperator= (const FormulaCursor &)
int getPos () const
int getMark () const
bool hasChanged () const
void clearChangedFlag ()
bool isSelectionMode () const
bool isSelection () const
void setSelection (bool selection)
void calcCursorSize (const ContextStyle &context, bool smallCursor)
void draw (QPainter &, const ContextStyle &context, bool smallCursor)
void moveLeft (int flag=NormalMovement)
void moveRight (int flag=NormalMovement)
void moveUp (int flag=NormalMovement)
void moveDown (int flag=NormalMovement)
void moveHome (int flag=NormalMovement)
void moveEnd (int flag=NormalMovement)
bool isHome () const
bool isEnd () const
bool getLinearMovement () const
void setLinearMovement (bool linear)
void goInsideElement (BasicElement *element)
void mousePress (const LuPixelPoint &, int flags)
void mouseMove (const LuPixelPoint &, int flags)
void mouseRelease (const LuPixelPoint &, int flags)
void insert (BasicElement *, Direction=beforeCursor)
void insert (QPtrList< BasicElement > &, Direction=beforeCursor)
void remove (QPtrList< BasicElement > &, Direction=beforeCursor)
void replaceSelectionWith (BasicElement *, Direction=beforeCursor)
BasicElementreplaceByMainChildContent (Direction=beforeCursor)
BasicElementremoveEnclosingElement (Direction=beforeCursor)
bool elementIsSenseless ()
int getSelectionStart () const
int getSelectionEnd () const
void setTo (BasicElement *element, int cursor, int mark=-1)
void setPos (int pos)
void setMark (int mark)
BasicElementgetElement ()
const BasicElementgetElement () const
void normalize (Direction direction=beforeCursor)
SequenceElementnormal ()
const SequenceElementnormal () const
IndexElementgetActiveIndexElement ()
RootElementgetActiveRootElement ()
SymbolElementgetActiveSymbolElement ()
NameSequencegetActiveNameSequence ()
TextElementgetActiveTextElement ()
MatrixElementgetActiveMatrixElement ()
void selectActiveElement ()
void copy (QDomDocument &doc)
bool buildElementsFromDom (QDomElement root, QPtrList< BasicElement > &list)
CursorDatagetCursorData ()
void setCursorData (CursorData *data)
void elementWillVanish (BasicElement *element)
void formulaLoaded (FormulaElement *rootElement)
const LuPixelPointgetCursorPoint () const
const LuPixelRectgetCursorSize () const
void addCursorSize (const LuPixelRect &rect)
bool isReadOnly () const
void setReadOnly (bool ro)

Friends

class SequenceElement

Classes

class  CursorData
 A black box that is supposed to contain everything which is needed to describe a cursor. More...

Detailed Description

The selection.

This might be a position selection or an area. Each view will need one FormulaCursor.

The Container always uses the cursor to operate on the element tree.

Note that it is up to the elements to actually move the cursor. (The cursor has no chance to know how.)

Definition at line 50 of file formulacursor.h.


Constructor & Destructor Documentation

KFORMULA_NAMESPACE_BEGIN FormulaCursor::FormulaCursor FormulaElement element  ) 
 

Creates a cursor and puts is at the beginning of the formula.

Parameters:
element the formula the cursor point to. This must not be 0.

Definition at line 37 of file formulacursor.cc.

References SequenceElement::goInside().


Member Function Documentation

bool FormulaCursor::hasChanged  )  const [inline]
 

Tells whether the cursor has changed since last cleaning.

Definition at line 74 of file formulacursor.h.

void FormulaCursor::clearChangedFlag  )  [inline]
 

Resets the cursor's change flag.

The widget calls this if it has drawn the cursor.

Definition at line 80 of file formulacursor.h.

bool FormulaCursor::isSelectionMode  )  const [inline]
 

Returns wether we are in selection mode.

Definition at line 85 of file formulacursor.h.

Referenced by MultilineElement::moveDown(), SequenceElement::moveEnd(), SequenceElement::moveLeft(), SequenceElement::moveRight(), MultilineElement::moveRight(), and MultilineElement::moveUp().

bool FormulaCursor::isSelection  )  const [inline]
 

Returns wether there actually is a selection.

Definition at line 90 of file formulacursor.h.

Referenced by SequenceElement::buildCommand(), copy(), Container::cut(), SequenceElement::drawCursor(), getActiveIndexElement(), getActiveMatrixElement(), getActiveNameSequence(), getActiveRootElement(), getActiveSymbolElement(), SequenceElement::remove(), replaceSelectionWith(), and selectActiveElement().

void FormulaCursor::setSelection bool  selection  )  [inline]
 

Sets the selection mode.

Definition at line 95 of file formulacursor.h.

Referenced by SequenceElement::buildCommand(), elementWillVanish(), formulaLoaded(), SequenceElement::goInside(), SequenceElement::normalize(), SequenceElement::remove(), replaceByMainChildContent(), selectActiveElement(), and setTo().

void FormulaCursor::calcCursorSize const ContextStyle context,
bool  smallCursor
 

Calculates the size of the cursor.

Needs to be called before the cursor can be drawn.

Definition at line 72 of file formulacursor.cc.

References SequenceElement::calcCursorSize().

void FormulaCursor::draw QPainter ,
const ContextStyle context,
bool  smallCursor
 

Draws the cursor at its current position.

The cursor will always be drawn in xor mode.

Definition at line 82 of file formulacursor.cc.

References SequenceElement::drawCursor().

Referenced by FormulaElement::draw().

bool FormulaCursor::isHome  )  const
 

Returns:
whether the cursor is at the first position.

Definition at line 183 of file formulacursor.cc.

References getElement().

bool FormulaCursor::isEnd  )  const
 

Returns:
whether the cursor is at the last position.

Definition at line 188 of file formulacursor.cc.

References getElement(), and normal().

void FormulaCursor::setLinearMovement bool  linear  )  [inline]
 

Sets the cursor in linear mode.

This means you can visit every element just by moving left and right.

Definition at line 134 of file formulacursor.h.

void FormulaCursor::goInsideElement BasicElement element  ) 
 

Moves the cursor inside the element.

Selection is turned off.

Definition at line 273 of file formulacursor.cc.

References BasicElement::goInside().

void FormulaCursor::insert BasicElement ,
Direction  = beforeCursor
 

Inserts the child at the current position.

Ignores the selection.

Definition at line 296 of file formulacursor.cc.

Referenced by replaceByMainChildContent(), and replaceSelectionWith().

void FormulaCursor::insert QPtrList< BasicElement > &  ,
Direction  = beforeCursor
 

Inserts the listed children at the current position.

Ignores the selection. The list will be emptied.

Definition at line 303 of file formulacursor.cc.

References getElement(), BasicElement::insert(), and isReadOnly().

void FormulaCursor::remove QPtrList< BasicElement > &  ,
Direction  = beforeCursor
 

Removes the current selected children and returns them.

The cursor needs to be normal (that is be inside a SequenceElement) for this to have any effect.

Definition at line 317 of file formulacursor.cc.

References SequenceElement::countChildren(), BasicElement::getParent(), isReadOnly(), normal(), SequenceElement::remove(), BasicElement::remove(), and BasicElement::selectChild().

Referenced by replaceByMainChildContent().

void FormulaCursor::replaceSelectionWith BasicElement ,
Direction  = beforeCursor
 

Replaces the current selection with the supplied element.

The replaced elements become the new element's main child's content.

Definition at line 345 of file formulacursor.cc.

References getElement(), SequenceElement::goInside(), insert(), isReadOnly(), and isSelection().

BasicElement * FormulaCursor::replaceByMainChildContent Direction  = beforeCursor  ) 
 

Replaces the element the cursor points to with its main child's content.

Definition at line 382 of file formulacursor.cc.

References SequenceElement::countChildren(), getElement(), BasicElement::getMainChild(), BasicElement::getParent(), insert(), isReadOnly(), remove(), SequenceElement::selectAllChildren(), and setSelection().

Referenced by removeEnclosingElement().

BasicElement * FormulaCursor::removeEnclosingElement Direction  = beforeCursor  ) 
 

Trys to find the element we are the main child of and replace it with our content.

This is simply another form of replaceByMainChildContent. You use this one if the cursor is normalized and inside the main child.

Definition at line 411 of file formulacursor.cc.

References getElement(), BasicElement::getMainChild(), isReadOnly(), replaceByMainChildContent(), and BasicElement::selectChild().

bool FormulaCursor::elementIsSenseless  ) 
 

Returns wether the element the cursor points to should be replaced.

Elements are senseless as soon as they only contain a main child.

Definition at line 429 of file formulacursor.cc.

References getElement(), and BasicElement::isSenseless().

void FormulaCursor::setTo BasicElement element,
int  cursor,
int  mark = -1
 

Sets the cursor to a new position.

This gets called from the element that wants to own the cursor. It is a mistake to call this if you aren't an element.

If you provide a mark >= 0 the selection gets turned on. If there is a selection and you don't provide a mark the current mark won't change.

Definition at line 45 of file formulacursor.cc.

References setSelection().

Referenced by SequenceElement::goInside(), SequenceElement::insert(), MultilineElement::moveDown(), SequenceElement::moveEnd(), SequenceElement::moveLeft(), SequenceElement::moveRight(), MultilineElement::moveUp(), NameSequence::moveWordLeft(), SequenceElement::moveWordLeft(), NameSequence::moveWordRight(), SequenceElement::moveWordRight(), SequenceElement::remove(), RootElement::remove(), FractionElement::remove(), RootElement::selectChild(), MultilineElement::selectChild(), MatrixElement::selectChild(), FractionElement::selectChild(), and SingleContentElement::selectChild().

BasicElement* FormulaCursor::getElement  )  [inline]
 

The element we are in.

In most cases this is a SequenceElement. There is no way to place a cursor outside a SequenceElement by normal movement. But in special cases (e.g. if you remove an index from an IndexElement) the cursor can be placed to odd places. This is the reason why you have to normalize the cursor after each removal.

Definition at line 231 of file formulacursor.h.

Referenced by elementIsSenseless(), elementWillVanish(), getActiveIndexElement(), getActiveNameSequence(), getActiveRootElement(), getActiveSymbolElement(), insert(), isEnd(), isHome(), SequenceElement::moveEnd(), MultilineElement::normalize(), normalize(), removeEnclosingElement(), replaceByMainChildContent(), and replaceSelectionWith().

void FormulaCursor::normalize Direction  direction = beforeCursor  ) 
 

Moves the cursor to a normal position.

That is somewhere inside a SequenceElement. You need to call this after each removal because the cursor might point to some non existing place.

Definition at line 285 of file formulacursor.cc.

References getElement(), and BasicElement::normalize().

SequenceElement * FormulaCursor::normal  ) 
 

Returns the sequence the cursor is in if we are normal.

If not returns 0.

Definition at line 718 of file formulacursor.cc.

Referenced by SequenceElement::buildCommand(), buildElementsFromDom(), copy(), getActiveMatrixElement(), isEnd(), isReadOnly(), NameSequence::isValidSelection(), and remove().

IndexElement * FormulaCursor::getActiveIndexElement  ) 
 

Returns the IndexElement the cursor is on or 0 if there is non.

Definition at line 492 of file formulacursor.cc.

References getElement(), and isSelection().

RootElement * FormulaCursor::getActiveRootElement  ) 
 

Returns the RootElement the cursor is on or 0 if there is non.

Definition at line 510 of file formulacursor.cc.

References getElement(), and isSelection().

SymbolElement * FormulaCursor::getActiveSymbolElement  ) 
 

Returns the SymbolElement the cursor is on or 0 if there is non.

Returns:
the SymbolElement the cursor is on or 0 if there is non.

Definition at line 528 of file formulacursor.cc.

References getElement(), and isSelection().

NameSequence * FormulaCursor::getActiveNameSequence  ) 
 

Returns:
the NameSequence the cursor is on or 0 if there is non.

Definition at line 545 of file formulacursor.cc.

References getElement(), and isSelection().

TextElement * FormulaCursor::getActiveTextElement  ) 
 

Returns:
the TextElement the cursor is on or 0.

Definition at line 561 of file formulacursor.cc.

Referenced by SequenceElement::buildCommand().

MatrixElement * FormulaCursor::getActiveMatrixElement  ) 
 

Returns:
the MatrixElement the cursor is on or 0.

Definition at line 567 of file formulacursor.cc.

References isSelection(), and normal().

void FormulaCursor::selectActiveElement  ) 
 

Selects the element the cursor points to (stands after) if there is such an element and if there is no selection.

Definition at line 464 of file formulacursor.cc.

References isSelection(), and setSelection().

Referenced by SequenceElement::buildCommand().

void FormulaCursor::copy QDomDocument doc  ) 
 

Stores the currently selected elements inside a dom.

Definition at line 638 of file formulacursor.cc.

References BasicElement::formula(), SequenceElement::getChildrenDom(), isSelection(), and normal().

Referenced by Container::copy().

bool FormulaCursor::buildElementsFromDom QDomElement  root,
QPtrList< BasicElement > &  list
 

Inserts the elements that could be read from the dom into the list.

Returns true on success.

Definition at line 660 of file formulacursor.cc.

References SequenceElement::buildChildrenFromDom(), isReadOnly(), and normal().

Referenced by Container::paste().

FormulaCursor::CursorData * FormulaCursor::getCursorData  ) 
 

Creates a new CursorData object that describes the cursor.

It's up to the caller to delete this object.

Definition at line 678 of file formulacursor.cc.

void FormulaCursor::setCursorData CursorData data  ) 
 

Sets the cursor to where the CursorData points to.

No checking is done so you better make sure the point exists.

Definition at line 703 of file formulacursor.cc.

References FormulaCursor::CursorData::current, FormulaCursor::CursorData::cursorPos, FormulaCursor::CursorData::linearMovement, FormulaCursor::CursorData::markPos, FormulaCursor::CursorData::readOnly, and FormulaCursor::CursorData::selectionFlag.

void FormulaCursor::elementWillVanish BasicElement element  ) 
 

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

Definition at line 586 of file formulacursor.cc.

References BasicElement::childWillVanish(), getElement(), BasicElement::getParent(), and setSelection().

void FormulaCursor::formulaLoaded FormulaElement rootElement  ) 
 

A new formula has been loaded.

Our current element has to change.

Definition at line 610 of file formulacursor.cc.

References SequenceElement::goInside(), and setSelection().

const LuPixelPoint& FormulaCursor::getCursorPoint  )  const [inline]
 

Returns:
the point inside the formula widget where the cursor is.

Definition at line 349 of file formulacursor.h.

Referenced by SequenceElement::drawCursor().

const LuPixelRect& FormulaCursor::getCursorSize  )  const [inline]
 

Returns:
the area the cursor is currently on.

Definition at line 354 of file formulacursor.h.

Referenced by SequenceElement::drawCursor().

bool FormulaCursor::isReadOnly  )  const
 

Returns:
whether we are allowed to alter the document.

Definition at line 620 of file formulacursor.cc.

References normal(), and SequenceElement::readOnly().

Referenced by SequenceElement::buildCommand(), buildElementsFromDom(), insert(), remove(), removeEnclosingElement(), replaceByMainChildContent(), and replaceSelectionWith().

void FormulaCursor::setReadOnly bool  ro  )  [inline]
 

Puts the widget in read only mode.

Definition at line 365 of file formulacursor.h.


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