lib

FormulaCursor Class Reference

#include <formulacursor.h>

Classes

class  CursorData
 

Public Member Functions

 FormulaCursor (FormulaElement *element)
 
FormulaCursor & operator= (const FormulaCursor &)
 
uint 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 (TQPainter &, const ContextStyle &context, StyleAttributes &style, bool smallCursor, bool activeCursor)
 
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 (TQPtrList< BasicElement > &, Direction=beforeCursor)
 
void remove (TQPtrList< BasicElement > &, Direction=beforeCursor)
 
void replaceSelectionWith (BasicElement *, Direction=beforeCursor)
 
BasicElement * replaceByMainChildContent (Direction=beforeCursor)
 
BasicElement * removeEnclosingElement (Direction=beforeCursor)
 
bool elementIsSenseless ()
 
int getSelectionStart () const
 
int getSelectionEnd () const
 
void setTo (BasicElement *element, uint cursor, int mark=-1)
 
void setPos (uint pos)
 
void setMark (int mark)
 
BasicElement * getElement ()
 
const BasicElement * getElement () const
 
void normalize (Direction direction=beforeCursor)
 
SequenceElement * normal ()
 
const SequenceElement * normal () const
 
IndexElement * getActiveIndexElement ()
 
RootElement * getActiveRootElement ()
 
SymbolElement * getActiveSymbolElement ()
 
NameSequence * getActiveNameSequence ()
 
TextElement * getActiveTextElement ()
 
MatrixElement * getActiveMatrixElement ()
 
void selectActiveElement ()
 
void copy (TQDomDocument &doc)
 
bool buildElementsFromDom (TQDomElement root, TQPtrList< BasicElement > &list)
 
bool buildElementsFromMathMLDom (TQDomElement root, TQPtrList< BasicElement > &list)
 
CursorData * getCursorData ()
 
void setCursorData (CursorData *data)
 
void elementWillVanish (BasicElement *element)
 
void formulaLoaded (FormulaElement *rootElement)
 
const LuPixelPoint & getCursorPoint () const
 
const LuPixelRect & getCursorSize () const
 
void addCursorSize (const LuPixelRect &rect)
 
bool isReadOnly () const
 
void setReadOnly (bool ro)
 

Friends

class SequenceElement
 

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

◆ FormulaCursor()

KFORMULA_NAMESPACE_BEGIN FormulaCursor::FormulaCursor ( FormulaElement *  element)

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

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

Definition at line 37 of file formulacursor.cpp.

Member Function Documentation

◆ addCursorSize()

void FormulaCursor::addCursorSize ( const LuPixelRect &  rect)
inline

Definition at line 362 of file formulacursor.h.

◆ buildElementsFromDom()

bool FormulaCursor::buildElementsFromDom ( TQDomElement  root,
TQPtrList< BasicElement > &  list 
)

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

Returns true on success.

Definition at line 662 of file formulacursor.cpp.

◆ buildElementsFromMathMLDom()

bool FormulaCursor::buildElementsFromMathMLDom ( TQDomElement  root,
TQPtrList< BasicElement > &  list 
)

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

Returns true on success.

Definition at line 679 of file formulacursor.cpp.

◆ calcCursorSize()

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.cpp.

◆ clearChangedFlag()

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.

◆ copy()

void FormulaCursor::copy ( TQDomDocument &  doc)

Stores the currently selected elements inside a dom.

Definition at line 639 of file formulacursor.cpp.

◆ draw()

void FormulaCursor::draw ( TQPainter &  painter,
const ContextStyle &  context,
StyleAttributes &  style,
bool  smallCursor,
bool  activeCursor 
)

Draws the cursor at its current position.

The cursor will always be drawn in xor mode.

Definition at line 82 of file formulacursor.cpp.

◆ elementIsSenseless()

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 430 of file formulacursor.cpp.

◆ elementWillVanish()

void FormulaCursor::elementWillVanish ( BasicElement *  element)

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

Definition at line 587 of file formulacursor.cpp.

◆ formulaLoaded()

void FormulaCursor::formulaLoaded ( FormulaElement *  rootElement)

A new formula has been loaded.

Our current element has to change.

Definition at line 611 of file formulacursor.cpp.

◆ getActiveIndexElement()

IndexElement * FormulaCursor::getActiveIndexElement ( )

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

Definition at line 493 of file formulacursor.cpp.

◆ getActiveMatrixElement()

MatrixElement * FormulaCursor::getActiveMatrixElement ( )
Returns
the MatrixElement the cursor is on or 0.

Definition at line 568 of file formulacursor.cpp.

◆ getActiveNameSequence()

NameSequence * FormulaCursor::getActiveNameSequence ( )
Returns
the NameSequence the cursor is on or 0 if there is non.

Definition at line 546 of file formulacursor.cpp.

◆ getActiveRootElement()

RootElement * FormulaCursor::getActiveRootElement ( )

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

Definition at line 511 of file formulacursor.cpp.

◆ getActiveSymbolElement()

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 529 of file formulacursor.cpp.

◆ getActiveTextElement()

TextElement * FormulaCursor::getActiveTextElement ( )
Returns
the TextElement the cursor is on or 0.

Definition at line 562 of file formulacursor.cpp.

◆ getCursorData()

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 696 of file formulacursor.cpp.

◆ getCursorPoint()

const LuPixelPoint & FormulaCursor::getCursorPoint ( ) const
inline
Returns
the point inside the formula widget where the cursor is.

Definition at line 356 of file formulacursor.h.

◆ getCursorSize()

const LuPixelRect & FormulaCursor::getCursorSize ( ) const
inline
Returns
the area the cursor is currently on.

Definition at line 361 of file formulacursor.h.

◆ getElement() [1/2]

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 232 of file formulacursor.h.

◆ getElement() [2/2]

const BasicElement * FormulaCursor::getElement ( ) const
inline

Definition at line 233 of file formulacursor.h.

◆ getLinearMovement()

bool FormulaCursor::getLinearMovement ( ) const
inline

Definition at line 129 of file formulacursor.h.

◆ getMark()

int FormulaCursor::getMark ( ) const
inline

Definition at line 69 of file formulacursor.h.

◆ getPos()

uint FormulaCursor::getPos ( ) const
inline

Definition at line 68 of file formulacursor.h.

◆ getSelectionEnd()

int FormulaCursor::getSelectionEnd ( ) const
inline

Definition at line 204 of file formulacursor.h.

◆ getSelectionStart()

int FormulaCursor::getSelectionStart ( ) const
inline

Definition at line 203 of file formulacursor.h.

◆ goInsideElement()

void FormulaCursor::goInsideElement ( BasicElement *  element)

Moves the cursor inside the element.

Selection is turned off.

Definition at line 274 of file formulacursor.cpp.

◆ hasChanged()

bool FormulaCursor::hasChanged ( ) const
inline

Tells whether the cursor has changed since last cleaning.

Definition at line 74 of file formulacursor.h.

◆ insert() [1/2]

void FormulaCursor::insert ( BasicElement *  child,
Direction  direction = beforeCursor 
)

Inserts the child at the current position.

Ignores the selection.

Definition at line 297 of file formulacursor.cpp.

◆ insert() [2/2]

void FormulaCursor::insert ( TQPtrList< BasicElement > &  children,
Direction  direction = beforeCursor 
)

Inserts the listed children at the current position.

Ignores the selection. The list will be emptied.

Definition at line 304 of file formulacursor.cpp.

◆ isEnd()

bool FormulaCursor::isEnd ( ) const
Returns
whether the cursor is at the last position.

Definition at line 189 of file formulacursor.cpp.

◆ isHome()

bool FormulaCursor::isHome ( ) const
Returns
whether the cursor is at the first position.

Definition at line 184 of file formulacursor.cpp.

◆ isReadOnly()

bool FormulaCursor::isReadOnly ( ) const
Returns
whether we are allowed to alter the document.

Definition at line 621 of file formulacursor.cpp.

◆ isSelection()

bool FormulaCursor::isSelection ( ) const
inline

Returns wether there actually is a selection.

Definition at line 90 of file formulacursor.h.

◆ isSelectionMode()

bool FormulaCursor::isSelectionMode ( ) const
inline

Returns wether we are in selection mode.

Definition at line 85 of file formulacursor.h.

◆ mouseMove()

void FormulaCursor::mouseMove ( const LuPixelPoint &  point,
int  flags 
)

Definition at line 211 of file formulacursor.cpp.

◆ mousePress()

void FormulaCursor::mousePress ( const LuPixelPoint &  pos,
int  flags 
)

Definition at line 195 of file formulacursor.cpp.

◆ mouseRelease()

void FormulaCursor::mouseRelease ( const LuPixelPoint &  ,
int  flags 
)

Definition at line 265 of file formulacursor.cpp.

◆ moveDown()

void FormulaCursor::moveDown ( int  flag = NormalMovement)

Definition at line 153 of file formulacursor.cpp.

◆ moveEnd()

void FormulaCursor::moveEnd ( int  flag = NormalMovement)

Definition at line 172 of file formulacursor.cpp.

◆ moveHome()

void FormulaCursor::moveHome ( int  flag = NormalMovement)

Definition at line 160 of file formulacursor.cpp.

◆ moveLeft()

void FormulaCursor::moveLeft ( int  flag = NormalMovement)

Definition at line 110 of file formulacursor.cpp.

◆ moveRight()

void FormulaCursor::moveRight ( int  flag = NormalMovement)

Definition at line 128 of file formulacursor.cpp.

◆ moveUp()

void FormulaCursor::moveUp ( int  flag = NormalMovement)

Definition at line 146 of file formulacursor.cpp.

◆ normal() [1/2]

SequenceElement * FormulaCursor::normal ( )

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

If not returns 0.

Definition at line 736 of file formulacursor.cpp.

◆ normal() [2/2]

const SequenceElement * FormulaCursor::normal ( ) const

Definition at line 741 of file formulacursor.cpp.

◆ normalize()

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 286 of file formulacursor.cpp.

◆ operator=()

FormulaCursor & FormulaCursor::operator= ( const FormulaCursor &  other)

Definition at line 704 of file formulacursor.cpp.

◆ remove()

void FormulaCursor::remove ( TQPtrList< BasicElement > &  children,
Direction  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 318 of file formulacursor.cpp.

◆ removeEnclosingElement()

BasicElement * FormulaCursor::removeEnclosingElement ( Direction  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 412 of file formulacursor.cpp.

◆ replaceByMainChildContent()

BasicElement * FormulaCursor::replaceByMainChildContent ( Direction  direction = beforeCursor)

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

Definition at line 383 of file formulacursor.cpp.

◆ replaceSelectionWith()

void FormulaCursor::replaceSelectionWith ( BasicElement *  element,
Direction  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 346 of file formulacursor.cpp.

◆ selectActiveElement()

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 465 of file formulacursor.cpp.

◆ setCursorData()

void FormulaCursor::setCursorData ( FormulaCursor::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 721 of file formulacursor.cpp.

◆ setLinearMovement()

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 135 of file formulacursor.h.

◆ setMark()

void FormulaCursor::setMark ( int  mark)

Definition at line 66 of file formulacursor.cpp.

◆ setPos()

void FormulaCursor::setPos ( uint  pos)

Definition at line 60 of file formulacursor.cpp.

◆ setReadOnly()

void FormulaCursor::setReadOnly ( bool  ro)
inline

Puts the widget in read only mode.

Definition at line 372 of file formulacursor.h.

◆ setSelection()

void FormulaCursor::setSelection ( bool  selection)
inline

Sets the selection mode.

Definition at line 95 of file formulacursor.h.

◆ setTo()

void FormulaCursor::setTo ( BasicElement *  element,
uint  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.cpp.

Friends And Related Symbol Documentation

◆ SequenceElement

friend class SequenceElement
friend

Definition at line 53 of file formulacursor.h.


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