25#include <tqpaintdevice.h>
26#include <tqvaluestack.h>
34#include "MatrixDialog.h"
35#include "bracketelement.h"
36#include "creationstrategy.h"
37#include "elementtype.h"
38#include "elementvisitor.h"
39#include "formulacursor.h"
40#include "formulaelement.h"
41#include "fractionelement.h"
42#include "indexelement.h"
43#include "kformulacommand.h"
44#include "kformulacontainer.h"
45#include "kformuladocument.h"
46#include "matrixelement.h"
47#include "rootelement.h"
48#include "sequenceelement.h"
49#include "sequenceparser.h"
50#include "spaceelement.h"
51#include "symbolelement.h"
52#include "symboltable.h"
53#include "textelement.h"
54#include "numberelement.h"
55#include "identifierelement.h"
56#include "operatorelement.h"
60KFORMULA_NAMESPACE_BEGIN
67 creationStrategy = strategy;
70void SequenceElement::setStyle( StyleElement *st )
76 :
BasicElement(parent), parseTree(0), textSequence(true),singlePipe(true), style(0)
78 assert( creationStrategy != 0 );
79 children.setAutoDelete(
true);
83SequenceElement::~SequenceElement()
91 children.setAutoDelete(
true);
92 uint count = other.children.count();
93 for (uint i = 0; i < count; i++) {
95 child->setParent(
this );
96 children.append( child );
103 return visitor->visit(
this );
109 return getParent()->
readOnly(
this );
117 const LuPixelPoint& point,
const LuPixelPoint& parentOrigin )
121 LuPixelPoint myPos(parentOrigin.x() + getX(),
122 parentOrigin.y() + getY());
124 uint count = children.count();
125 for (uint i = 0; i < count; i++) {
127 e = child->
goToPos(cursor, handled, point, myPos);
131 if ((point.x() - myPos.x()) < (e->getX() + e->getWidth()*2/3)) {
132 cursor->
setTo(
this, children.find(e));
135 cursor->
setTo(
this, children.find(e)+1);
142 luPixel dx = point.x() - myPos.x();
145 for (uint i = 0; i < count; i++) {
147 if (dx < child->getX()) {
148 cursor->
setTo(
this, i );
150 return children.at( i );
164 uint count = children.count();
165 for (uint i = 0; i < count; i++) {
181 ContextStyle::IndexStyle istyle,
182 StyleAttributes& style )
184 double factor = style.sizeFactor();
187 luPixel toBaseline = 0;
188 luPixel fromBaseline = 0;
193 TQPtrListIterator<BasicElement> it( children );
194 for ( ; it.current(); ++it ) {
198 child->
calcSizes( context, tstyle, istyle, style );
199 child->setX( width );
200 width += child->getWidth();
202 luPixel childBaseline = child->getBaseline();
203 if ( childBaseline > -1 ) {
204 toBaseline = TQMAX( toBaseline, childBaseline );
205 fromBaseline = TQMAX( fromBaseline,
206 child->getHeight() - childBaseline );
209 luPixel bl = child->getHeight()/2 + context.axisHeight( tstyle, factor );
210 toBaseline = TQMAX( toBaseline, bl );
211 fromBaseline = TQMAX( fromBaseline, child->getHeight() - bl );
215 child->setX( width );
219 width += context.
ptToPixelX( getSpaceAfter( context, tstyle, factor ) );
222 setHeight(toBaseline+fromBaseline);
223 setBaseline(toBaseline);
228 luPixel w = context.getEmptyRectWidth( factor );
229 luPixel h = context.getEmptyRectHeight( factor );
240 TQPtrListIterator<BasicElement> it( children );
241 for ( ; it.current(); ++it ) {
243 child->setY(getBaseline() - child->getBaseline());
256 ContextStyle::IndexStyle istyle,
257 StyleAttributes& style,
258 const LuPixelPoint& parentOrigin )
260 LuPixelPoint myPos( parentOrigin.x() + getX(), parentOrigin.y() + getY() );
267 TQPtrListIterator<BasicElement> it( children );
268 for (
int i = 0 ; it.current(); i++) {
271 child->
draw(painter, r, context, tstyle, istyle, style, myPos);
291 drawEmptyRect( painter, context, style.sizeFactor(), myPos );
311 TQPtrListIterator<BasicElement> it( children );
312 for ( ; it.current(); ++it ) {
319void SequenceElement::drawEmptyRect( TQPainter& painter,
const ContextStyle& context,
320 double factor,
const LuPixelPoint& upperLeft )
322 if ( context.edit() ) {
323 painter.setBrush(TQt::NoBrush);
324 painter.setPen( TQPen( context.getEmptyColor(),
327 context.layoutUnitToPixelY( upperLeft.y() ),
329 context.layoutUnitToPixelY( getHeight() ) );
333void SequenceElement::calcCursorSize(
const ContextStyle& context,
337 uint pos = cursor->getPos();
340 luPixel height = getHeight();
343 luPixel unitY = context.ptToLayoutUnitPixY( 1 );
348 uint mark = cursor->getMark();
350 luPixel x = TQMIN(posX, markX);
351 luPixel width = abs(posX - markX);
354 cursor->cursorSize.setRect( point.x()+x, point.y(), width, height );
357 cursor->cursorSize.setRect( point.x()+x, point.y() - 2*unitY,
358 width + unitX, height + 4*unitY );
363 cursor->cursorSize.setRect( point.x()+posX, point.y(),
367 cursor->cursorSize.setRect( point.x(), point.y() - 2*unitY,
368 getWidth() + unitX, height + 4*unitY );
372 cursor->cursorPoint.setX( point.x()+posX );
373 cursor->cursorPoint.setY( point.y()+getHeight()/2 );
382 bool smallCursor,
bool activeCursor )
384 painter.setRasterOp( TQt::XorROP );
386 const LuPixelRect& r = cursor->cursorSize;
388 context.layoutUnitToPixelY( r.y() ),
390 context.layoutUnitToPixelY( r.height() ),
393 painter.setPen( TQPen( TQt::white,
400 if ( cursor->
isSelection() && cursor->getPos() > cursor->getMark() )
403 context.layoutUnitToPixelY( size.top() ),
405 context.layoutUnitToPixelY( size.bottom() )-1 );
407 context.layoutUnitToPixelY( size.top() ),
409 context.layoutUnitToPixelY( size.bottom() )-1 );
413 context.layoutUnitToPixelY( size.bottom() )-1,
415 context.layoutUnitToPixelY( size.bottom() )-1 );
417 painter.setRasterOp( TQt::CopyROP );
423 if (child < children.count()) {
424 return children.at(child)->getX();
427 if (children.count() > 0) {
428 return children.at(child-1)->getX() + children.at(child-1)->getWidth();
453 if (from == getParent()) {
454 cursor->
setTo(
this, children.count());
456 cursor->setMark( children.count() );
462 else if (from ==
this) {
463 if (cursor->getPos() > 0) {
464 cursor->
setTo(
this, cursor->getPos()-1);
467 if (children.at(cursor->getPos())->isInvisible()) {
473 if (getParent() != 0) {
474 getParent()->
moveLeft(cursor,
this);
477 formula()->moveOutLeft( cursor );
485 int fromPos = children.find(from);
487 children.at( fromPos - 1)->moveLeft( cursor,
this );
506 if (from == getParent()) {
507 cursor->
setTo(
this, 0);
512 else if (from ==
this) {
513 uint pos = cursor->getPos();
514 if (pos < children.count()) {
515 cursor->
setTo(
this, pos+1);
518 if (children.at(pos)->isInvisible()) {
524 if (getParent() != 0) {
528 formula()->moveOutRight( cursor );
536 int fromPos = children.find(from);
537 if ( fromPos < children.count() - 1 ) {
538 children.at( fromPos + 1 )->moveDown( cursor,
this );
541 cursor->
setTo(
this, fromPos+1);
544 cursor->setMark(fromPos);
558 uint pos = cursor->getPos();
560 ElementType* type = children.at(pos-1)->getElementType();
562 cursor->
setTo(
this, type->start());
573 uint pos = cursor->getPos();
574 if (pos < children.count()) {
575 ElementType* type = children.at(pos)->getElementType();
577 cursor->
setTo(
this, type->end());
593 if (from == getParent()) {
596 else if ( from ==
this ) {
597 if ( getParent() != 0 ) {
598 uint pos = cursor->getPos();
599 if ( pos < (children.count() - 1) / 2 ) {
600 getParent()->
moveLeft( cursor,
this );
607 formula()->moveOutAbove( cursor );
611 if (getParent() != 0) {
612 getParent()->
moveUp(cursor,
this);
615 formula()->moveOutAbove( cursor );
627 if (from == getParent()) {
628 cursor->
setTo(
this, 0);
631 else if (from ==
this) {
632 uint pos = cursor->getPos();
633 if (pos < children.count()) {
634 children.at(pos)->moveDown(cursor,
this);
638 if (getParent() != 0) {
639 getParent()->
moveDown(cursor,
this);
642 cursor->
setTo(
this, children.count() );
657 if (element !=
this) {
658 while (element->getParent() !=
this) {
659 element = element->getParent();
661 cursor->setMark(children.find(element)+1);
664 cursor->
setTo(
this, 0);
675 if (element !=
this) {
676 while (element->getParent() !=
this) {
677 element = element->getParent();
679 cursor->setMark(children.count());
684 cursor->setMark(children.find(element));
688 cursor->
setTo(
this, children.count());
698 cursor->
setTo(
this, 0);
708 cursor->
setTo(
this, children.count());
726 return children.insert( index, child );
760 TQPtrList<BasicElement>& newChildren,
763 int pos = cursor->getPos();
764 uint count = newChildren.count();
765 for (uint i = 0; i < count; i++) {
767 child->setParent(
this);
768 children.insert(pos+i, child);
770 if (direction == beforeCursor) {
771 cursor->
setTo(
this, pos+count, pos);
774 cursor->
setTo(
this, pos, pos+count);
789 TQPtrList<BasicElement>& removedChildren,
793 int from = cursor->getSelectionStart();
794 int to = cursor->getSelectionEnd();
795 for (
int i = from; i < to; i++) {
796 removeChild(removedChildren, from);
798 cursor->
setTo(
this, from);
802 if (direction == beforeCursor) {
803 int pos = cursor->getPos() - 1;
809 removedChildren.prepend(child);
815 cursor->
setTo(
this, pos);
820 uint pos = cursor->getPos();
821 if (pos < children.count()) {
822 while (pos < children.count()) {
826 removedChildren.append(child);
834 cursor->
setTo(
this, pos);
846void SequenceElement::removeChild(TQPtrList<BasicElement>& removedChildren,
int pos)
851 removedChildren.append(child);
873 if ( direction == beforeCursor ) {
874 if ( cursor->getPos() > 0 ) {
875 return children.at( cursor->getPos() - 1 );
879 if ( cursor->getPos() < tqRound( children.count() ) ) {
880 return children.at( cursor->getPos() );
893 int pos = children.find(child);
895 cursor->
setTo(
this, pos+1, pos);
901 int childPos = children.find(child);
903 int pos = cursor->getPos();
904 if (pos > childPos) {
907 int mark = cursor->getMark();
908 if (mark > childPos) {
911 cursor->
setTo(
this, pos, mark);
921 cursor->
setTo(
this, children.count(), 0);
924bool SequenceElement::onlyTextSelected(
FormulaCursor* cursor )
927 uint from = TQMIN( cursor->getPos(), cursor->getMark() );
928 uint to = TQMAX( cursor->getPos(), cursor->getMark() );
929 for ( uint i = from; i < to; i++ ) {
948 switch ( *request ) {
951 TextRequest* tr =
static_cast<TextRequest*
>( request );
952 IdentifierElement*
id = creationStrategy->createIdentifierElement();
954 for ( uint i = 0; i < tr->text().length(); i++ ) {
960 case req_addTextChar: {
962 TextCharRequest* tr =
static_cast<TextCharRequest*
>( request );
963 IdentifierElement*
id = creationStrategy->createIdentifierElement();
970 case req_addOperator: {
972 OperatorRequest* opr =
static_cast<OperatorRequest*
>( request );
973 OperatorElement* op = creationStrategy->createOperatorElement();
980 case req_addNumber: {
982 NumberRequest* nr =
static_cast<NumberRequest*
>( request );
983 NumberElement* num = creationStrategy->createNumberElement();
984 num->setParent(
this );
986 text->setParent( num );
992 case req_addEmptyBox: {
993 EmptyElement* element = creationStrategy->createEmptyElement();
994 if ( element != 0 ) {
1001 case req_addNameSequence:
1003 NameSequence* nameSequence = creationStrategy->createNameSequence();
1004 if ( nameSequence != 0 ) {
1006 command->setElement( nameSequence );
1011 case req_addBracket: {
1012 BracketRequest* br =
static_cast<BracketRequest*
>( request );
1014 creationStrategy->createBracketElement( br->left(), br->right() );
1015 if ( bracketElement != 0 ) {
1017 command->setElement( bracketElement );
1022 case req_addOverline: {
1023 OverlineElement* overline = creationStrategy->createOverlineElement();
1024 if ( overline != 0 ) {
1026 command->setElement( overline );
1031 case req_addUnderline: {
1033 if ( underline != 0 ) {
1035 command->setElement( underline );
1040 case req_addMultiline: {
1042 if ( multiline != 0 ) {
1044 command->setElement( multiline );
1049 case req_addSpace: {
1050 SpaceRequest* sr =
static_cast<SpaceRequest*
>( request );
1051 SpaceElement* element = creationStrategy->createSpaceElement( sr->space() );
1052 if ( element != 0 ) {
1059 case req_addFraction: {
1060 FractionElement* fraction = creationStrategy->createFractionElement();
1061 if ( fraction != 0 ) {
1063 command->setElement( fraction );
1069 RootElement* root = creationStrategy->createRootElement();
1072 command->setElement( root );
1077 case req_addSymbol: {
1078 SymbolRequest* sr =
static_cast<SymbolRequest*
>( request );
1079 SymbolElement* symbol = creationStrategy->createSymbolElement( sr->type() );
1080 if ( symbol != 0 ) {
1082 command->setElement( symbol );
1087 case req_addOneByTwoMatrix: {
1089 if ( element != 0 ) {
1092 command->setElement(element);
1096 case req_addMatrix: {
1097 MatrixRequest* mr =
static_cast<MatrixRequest*
>( request );
1098 uint rows = mr->rows(), cols = mr->columns();
1099 if ( ( rows == 0 ) || ( cols == 0 ) ) {
1101 if ( dialog->exec() ) {
1108 if ( ( rows != 0 ) && ( cols != 0 ) ) {
1116 case req_addIndex: {
1117 if ( cursor->getPos() > 0 && !cursor->
isSelection() ) {
1119 dynamic_cast<IndexElement*
>( children.at( cursor->getPos()-1 ) );
1120 if ( element != 0 ) {
1125 IndexElement* element = creationStrategy->createIndexElement();
1126 if ( element != 0 ) {
1128 cursor->moveLeft( SelectMovement | WordMovement );
1130 IndexRequest* ir =
static_cast<IndexRequest*
>( request );
1132 element->
getIndex( ir->index() ) );
1137 case req_removeEnclosing: {
1139 DirectedRemove* dr =
static_cast<DirectedRemove*
>( request );
1147 ( sequence == sequence->
formula() ) &&
1153 DirectedRemove* dr =
static_cast<DirectedRemove*
>( request );
1158 if ( ( cursor->getPos() == 0 ) && ( dr->direction() == beforeCursor ) ) {
1161 if ( ( cursor->getPos() ==
countChildren() ) && ( dr->direction() == afterCursor ) ) {
1165 else if ( getParent() == 0 ) {
1174 case req_compactExpression: {
1176 cursor->moveRight();
1180 case req_makeGreek: {
1182 if ((element != 0) && !element->
isSymbol()) {
1199 case req_formatBold:
1200 case req_formatItalic: {
1202 CharStyleRequest* csr =
static_cast<CharStyleRequest*
>( request );
1203 CharStyle cs = normalChar;
1204 if ( csr->bold() ) cs =
static_cast<CharStyle
>( cs | boldChar );
1205 if ( csr->italic() ) cs =
static_cast<CharStyle
>( cs | italicChar );
1207 int end = cursor->getSelectionEnd();
1208 for (
int i = cursor->getSelectionStart(); i<end; ++i ) {
1215 case req_formatFamily: {
1217 CharFamilyRequest* cfr =
static_cast<CharFamilyRequest*
>( request );
1218 CharFamily cf = cfr->charFamily();
1220 int end = cursor->getSelectionEnd();
1221 for (
int i = cursor->getSelectionStart(); i<end; ++i ) {
1237 TQChar ch =
event->text().at( 0 );
1238 if ( ch.isPrint() ) {
1239 return input( container, ch );
1242 int action =
event->key();
1243 int state =
event->state();
1244 MoveFlag flag = movementFlag(state);
1247 case TQt::Key_BackSpace: {
1248 DirectedRemove r( req_remove, beforeCursor );
1251 case TQt::Key_Delete: {
1252 DirectedRemove r( req_remove, afterCursor );
1255 case TQt::Key_Left: {
1257 cursor->moveLeft( flag );
1261 case TQt::Key_Right: {
1263 cursor->moveRight( flag );
1269 cursor->moveUp( flag );
1273 case TQt::Key_Down: {
1275 cursor->moveDown( flag );
1279 case TQt::Key_Home: {
1281 cursor->moveHome( flag );
1285 case TQt::Key_End: {
1287 cursor->moveEnd( flag );
1292 if ( state & TQt::ControlButton ) {
1293 switch ( event->key() ) {
1294 case TQt::Key_AsciiCircum: {
1295 IndexRequest r( upperLeftPos );
1298 case TQt::Key_Underscore: {
1299 IndexRequest r( lowerLeftPos );
1314 int unicode = ch.unicode();
1317 BracketRequest r( container->
document()->leftBracketChar(),
1318 container->
document()->rightBracketChar() );
1323 BracketRequest r( LeftSquareBracket, RightSquareBracket );
1328 BracketRequest r( LeftCurlyBracket, RightCurlyBracket );
1335 DirectedRemove rDelete( req_remove, beforeCursor );
1339 BracketRequest rBracket( LeftLineBracket , RightLineBracket);
1344 TextCharRequest r(ch);
1353 IndexRequest r( upperRightPos );
1358 IndexRequest r( lowerRightPos );
1369 Request r( req_addEmptyBox );
1378 Request r( req_addNameSequence );
1384 if ( ch.isPunct() || ch.isSymbol() ) {
1385 OperatorRequest r( ch );
1388 if ( ch.isNumber() ) {
1389 NumberRequest r( ch );
1392 TextCharRequest r( ch );
1405 for (uint i = from; i < to; i++) {
1406 TQDomElement tmpEleDom=children.at(i)->getElementDom(doc);
1407 elem.appendChild(tmpEleDom);
1417 for ( uint i = from; i < to; i++ ) {
1418 children.at( i )->writeMathML( doc, parent,
false );
1430 while (!n.isNull()) {
1431 if (n.isElement()) {
1432 TQDomElement e = n.toElement();
1434 TQString tag = e.tagName().upper();
1438 child->setParent(
this);
1451 n = n.nextSibling();
1460 return creationStrategy->createElement( type, element );
1470 uint count = children.count();
1471 TQDomDocument doc = element.ownerDocument();
1506 textSequence =
true;
1509 element = children.next()) {
1513 element->setElementType(0);
1515 if (element->getCharacter().isNull()) {
1516 textSequence =
false;
1522 parseTree = parser.
parse(children);
1547 uint count = children.count();
1548 for ( uint i = 0; i < count; i++ ) {
1559TQString SequenceElement::formulaString()
1562 uint count = children.count();
1563 for ( uint i = 0; i < count; i++ ) {
1568 content += child->formulaString();
1574void SequenceElement::writeMathMLContent( TQDomDocument& doc, TQDomElement& element,
bool oasisFormat )
const
1576 for ( TQPtrListIterator<BasicElement> it( children ); it.current(); ++it ) {
1577 it.current()->writeMathML( doc, element, oasisFormat );
1584 TQPtrListIterator<BasicElement> it( children );
1586 return it.current();
1590int SequenceElement::childPos(
const BasicElement* child )
const
1592 TQPtrListIterator<BasicElement> it( children );
1593 uint count = it.count();
1594 for ( uint i=0; i<count; ++i, ++it ) {
1595 if ( it.current() == child ) {
1611 return visitor->visit(
this );
1615void NameSequence::calcCursorSize(
const ContextStyle& context,
1618 inherited::calcCursorSize( context, cursor, smallCursor );
1621 luPixel unitY = context.ptToLayoutUnitPixY( 1 );
1622 cursor->addCursorSize( LuPixelRect( point.x()-unitX, point.y()-unitY,
1623 getWidth()+2*unitX, getHeight()+2*unitY ) );
1628 bool smallCursor,
bool activeCursor )
1631 painter.setPen( TQPen( context.getEmptyColor(),
1634 luPixel unitY = context.ptToLayoutUnitPixY( 1 );
1636 context.layoutUnitToPixelY( point.y()-unitY ),
1638 context.layoutUnitToPixelY( getHeight()+2*unitY ) );
1645 uint pos = cursor->getPos();
1647 cursor->
setTo(
this, 0 );
1656 int pos = cursor->getPos();
1669 if ( element != 0 ) {
1681 switch ( *request ) {
1682 case req_compactExpression:
1683 return compactExpressionCmd( container );
1687 case req_addOneByTwoMatrix:
1690 case req_addFraction:
1691 case req_addBracket:
1692 case req_addNameSequence:
1703 int unicode = ch.unicode();
1729 Request r( req_compactExpression );
1733 TextCharRequest r( ch );
1748 TQString name = buildName();
1749 TQChar ch = table.
unicode( name );
1750 if ( !ch.isNull() ) {
1754 ch = table.
unicode( i18n( name.latin1() ) );
1755 if ( !ch.isNull() ) {
1767 if ( name ==
"atop" ) {
1792TQString NameSequence::buildName()
1804 if ( sequence == 0 ) {
1807 return sequence->onlyTextSelected( cursor );
1810int SequenceElement::buildChildrenFromMathMLDom(TQPtrList<BasicElement>& list, TQDomNode n)
1812 while (!n.isNull()) {
1814 if (n.isElement()) {
1815 TQDomElement e = n.toElement();
1817 TQString tag = e.tagName().lower();
1819 kdDebug( DEBUGID ) <<
"Sequence Tag: " << tag << endl;
1820 if ( tag ==
"semantics" ) {
1821 TQDomNode node = e.firstChild();
1822 while( ! node.isElement() ) {
1823 node = node.nextSibling();
1824 if ( node.isNull() ) {
1828 e = node.toElement();
1829 tag = e.tagName().lower();
1831 child = creationStrategy->createElement(tag, e);
1833 child->setParent(
this);
1835 child->setStyle(style);
1838 if ( nodeNumber != -1 ) {
1847 kdWarning() <<
"Unsupported MathML element: " << tag << endl;
1850 for (
int i = 0; i < nodeNumber; i++ ) {
1854 n = n.nextSibling();
1864 if ( list.count() > 1 ) {
1865 if ( list.getFirst()->getElementName() ==
"mo" ) {
1866 static_cast<OperatorElement*
>( list.getFirst() )->setForm( PrefixForm );
1868 if ( list.getLast()->getElementName() ==
"mo" ) {
1869 static_cast<OperatorElement*
>( list.getLast() )->setForm( PostfixForm );
1871 for ( uint i = 1; i < list.count() - 1; i++ ) {
1872 if ( list.at( i )->getElementName() ==
"mo" ) {
1873 static_cast<OperatorElement*
>( list.at( i ) )->setForm( InfixForm );
1877 else if ( list.count() == 1 ) {
1878 if ( list.getFirst()->getElementName() ==
"mo" ) {
1879 static_cast<OperatorElement*
>( list.getFirst() )->setForm( InfixForm );
1894 return buildChildrenFromMathMLDom(children, node);
1897int SequenceElement::buildMathMLChild( TQDomNode node )
1899 int nodeCounter = 1;
1900 while ( ! node.isElement() ) {
1901 node = node.nextSibling();
1903 if ( node.isNull() ) {
1907 TQDomElement e = node.toElement();
1909 TQString tag = e.tagName().lower();
1911 child = creationStrategy->createElement(tag, e);
1913 child->setParent(
this);
1915 child->setStyle(style);
1918 children.append(child);
1934KFORMULA_NAMESPACE_END
Basis of every formula element.
LuPixelPoint widgetPos()
Returns our position inside the widget.
virtual FormulaElement * formula()
Provide fast access to the rootElement for each child.
virtual void draw(TQPainter &painter, const LuPixelRect &r, const ContextStyle &context, ContextStyle::TextStyle tstyle, ContextStyle::IndexStyle istyle, StyleAttributes &style, const LuPixelPoint &parentOrigin)=0
Draws the whole element including its children.
virtual bool readContentFromDom(TQDomNode &node)
Reads our content from the node.
virtual bool isInvisible() const
virtual void entered(SequenceElement *)
The cursor has entered one of our child sequences.
virtual int readContentFromMathMLDom(TQDomNode &node)
Reads our content from the MathML node.
virtual void moveUp(FormulaCursor *, BasicElement *)
Enters this element while moving up starting inside the element ‘from’.
int buildFromMathMLDom(TQDomElement element)
Set this element attribute, build children and call their builFromMathMLDom.
virtual bool readOnly(const BasicElement *child) const
virtual TQString toLatex()
virtual void selectChild(FormulaCursor *, BasicElement *)
Sets the cursor to select the child.
virtual void goInside(FormulaCursor *cursor)
Sets the cursor inside this element to its start position.
bool buildFromDom(TQDomElement element)
Set this element attribute, build children and call their buildFromDom.
virtual void calcSizes(const ContextStyle &context, ContextStyle::TextStyle tstyle, ContextStyle::IndexStyle istyle, StyleAttributes &style)=0
Calculates our width and height and our children's parentPosition.
ElementType * getElementType() const
virtual TQChar getCharacter() const
virtual void setElementType(ElementType *t)
Sets a new type.
virtual bool readAttributesFromDom(TQDomElement element)
Reads our attributes from the element.
virtual BasicElement * goToPos(FormulaCursor *, bool &handled, const LuPixelPoint &point, const LuPixelPoint &parentOrigin)
Sets the cursor and returns the element the point is in.
virtual void dispatchFontCommand(FontCommand *)
Dispatch this FontCommand to all our TextElement children.
virtual KCommand * buildCommand(Container *, Request *)
This is called by the container to get a command depending on the current cursor position (this is ho...
virtual void writeDom(TQDomElement element)
Appends our attributes to the dom element.
virtual void moveRight(FormulaCursor *cursor, BasicElement *from)
Enters this element while moving to the right starting inside the element ‘from’.
virtual void moveLeft(FormulaCursor *cursor, BasicElement *from)
Enters this element while moving to the left starting inside the element ‘from’.
virtual void moveDown(FormulaCursor *, BasicElement *)
Enters this element while moving down starting inside the element ‘from’.
A left and/or right bracket around one child.
Changes the char family of a number of elements an their children.
Changes the char style of a number of elements an their children.
virtual Document * document() const
FormulaCursor * activeCursor()
Contains all the style information for the formela.
TextStyle
Textstyles like in TeX.
luPixel getLineWidth(double factor) const
All simple lines like the one that makes up a fraction.
const SymbolTable & getSymbolTable() const
An object of this type needs to be known by the SequenceElement.
virtual TextElement * createTextElement(const TQChar &ch, bool symbol=false)=0
there must always be a TextElement, so this can never return 0
virtual MatrixElement * createMatrixElement(uint rows, uint columns)=0
when this gets called the user has seen the matrix dialog and expects a matrix!
An element that represents an empty box.
Base for all font commands that act on the current selection.
void addElement(BasicElement *element)
Collects all parent elements those children are to be changend.
void showLine(bool line)
Moves the cursor away from the given child.
The element with up to four indexes in the four corners.
ElementIndexPtr getIndex(int position)
Returns the index at the position.
The command that takes the main child out of the selected element and replaces the element with it.
void addContent(BasicElement *element, BasicElement *content)
Collect content for each token.
void addToken(BasicElement *element)
Collect all tokens that are to be added.
void addElement(BasicElement *element)
Collects all elements that are to be added.
Command to remove the parent element.
Command that is used to remove the currently selected element.
Removes the current selection and adds any new tokens afterwards.
Removes the current selection and adds any new elements afterwards.
int ptToPixelX(double pt) const
Basic pt to pixel and pixel to pt conversions, valid at any zoom level, as well as at the Layout Unit...
int ptToLayoutUnitPixX(double x_pt) const
The "document pt" -> "Layout Unit pixels" conversions, for convenience.
int layoutUnitToPixelX(int lupix) const
The "layout unit pixel" -> "[zoomed] view pixel" conversions.
Dialog for entering matrix sizes.
The sequence thats a name.
BasicElement * replaceElement(const SymbolTable &table)
virtual void drawCursor(TQPainter &painter, const ContextStyle &context, StyleAttributes &style, FormulaCursor *cursor, bool smallCursor, bool activeCursor)
If the cursor is inside a sequence it needs to be drawn.
static bool isValidSelection(FormulaCursor *cursor)
Tests whether the selected elements can be inserted in a name sequence.
virtual void moveWordRight(FormulaCursor *cursor)
Moves to the end of this word or if we are there already to the end of the next.
virtual KCommand * buildCommand(Container *, Request *)
This is called by the container to get a command depending on the current cursor position (this is ho...
virtual BasicElement * createElement(TQString type)
Creates a new element with the given type.
virtual void moveWordLeft(FormulaCursor *cursor)
Moves to the beginning of this word or if we are there already to the beginning of the previous.
virtual void setElementType(ElementType *t)
Sets a new type.
virtual KCommand * input(Container *container, TQChar ch)
Parses the input.
virtual bool accept(ElementVisitor *visitor)
Visit this element.
A line above the content.
The element that contains a number of children.
virtual void goInsideLast(FormulaCursor *cursor)
Sets the cursor inside this element to its last position.
virtual KCommand * input(Container *container, TQChar ch)
Parses the input.
uint countChildren() const
virtual TQString toLatex()
void selectAllChildren(FormulaCursor *cursor)
Selects all children.
void getChildrenMathMLDom(TQDomDocument &doc, TQDomNode &elem, uint from, uint to)
Stores the given childrens MathML dom in the element.
virtual void moveEnd(FormulaCursor *cursor)
Moves the cursor to the last position in this sequence.
virtual KCommand * buildCommand(Container *, Request *)
This is called by the container to get a command depending on the current cursor position (this is ho...
virtual void moveWordLeft(FormulaCursor *cursor)
Moves to the beginning of this word or if we are there already to the beginning of the previous.
virtual void remove(FormulaCursor *, TQPtrList< BasicElement > &, Direction)
Removes all selected children and returns them.
virtual bool readAttributesFromDom(TQDomElement element)
Reads our attributes from the element.
void getChildrenDom(TQDomDocument &doc, TQDomElement elem, uint from, uint to)
Stores the given childrens dom in the element.
virtual BasicElement * getChild(FormulaCursor *, Direction=beforeCursor)
Returns the child at the cursor.
virtual bool isFirstOfToken(BasicElement *child)
virtual void moveDown(FormulaCursor *cursor, BasicElement *from)
Enters this element while moving down starting inside the element ‘from’.
virtual void drawCursor(TQPainter &painter, const ContextStyle &context, StyleAttributes &style, FormulaCursor *cursor, bool smallCursor, bool activeCursor)
If the cursor is inside a sequence it needs to be drawn.
virtual void parse()
Parses the sequence and generates a new syntax tree.
virtual void moveRight(FormulaCursor *cursor, BasicElement *from)
Enters this element while moving to the right starting inside the element ‘from’.
virtual void moveWordRight(FormulaCursor *cursor)
Moves to the end of this word or if we are there already to the end of the next.
luPixel getChildPosition(const ContextStyle &context, uint child)
virtual void goInside(FormulaCursor *cursor)
Sets the cursor inside this element to its start position.
virtual void dispatchFontCommand(FontCommand *cmd)
Dispatch this FontCommand to all our TextElement children.
virtual luPt getSpaceBefore(const ContextStyle &, ContextStyle::TextStyle, double)
Space around sequence.
virtual void childWillVanish(FormulaCursor *cursor, BasicElement *child)
Moves the cursor away from the given child.
virtual void calcSizes(const ContextStyle &cstyle, ContextStyle::TextStyle tstyle, ContextStyle::IndexStyle istyle, StyleAttributes &style)
Calculates our width and height and our children's parentPosition.
virtual void writeDom(TQDomElement element)
Appends our attributes to the dom element.
virtual bool accept(ElementVisitor *visitor)
Visit this element.
virtual void selectChild(FormulaCursor *cursor, BasicElement *child)
Sets the cursor to select the child.
bool isChildNumber(uint pos, BasicElement *child)
virtual bool readContentFromDom(TQDomNode &node)
Reads our content from the node.
virtual void setChildrenPositions()
Sets the childrens' positions after their size has been calculated.
virtual bool readOnly(const FormulaCursor *) const
bool buildChildrenFromDom(TQPtrList< BasicElement > &list, TQDomNode n)
Builds elements from the given node and its siblings and puts them into the list.
virtual void moveUp(FormulaCursor *cursor, BasicElement *from)
Enters this element while moving up starting inside the element ‘from’.
virtual void moveLeft(FormulaCursor *cursor, BasicElement *from)
Enters this element while moving to the left starting inside the element ‘from’.
virtual BasicElement * goToPos(FormulaCursor *, bool &handled, const LuPixelPoint &point, const LuPixelPoint &parentOrigin)
Sets the cursor and returns the element the point is in.
virtual void insert(FormulaCursor *, TQPtrList< BasicElement > &, Direction)
Inserts all new children at the cursor position.
virtual int readContentFromMathMLDom(TQDomNode &node)
Reads our content from the MathML node.
virtual BasicElement * createElement(TQString type, const TQDomElement &element)
Creates a new element with the given type.
virtual void normalize(FormulaCursor *, Direction)
Moves the cursor to a normal place where new elements might be inserted.
virtual void draw(TQPainter &painter, const LuPixelRect &r, const ContextStyle &context, ContextStyle::TextStyle tstyle, ContextStyle::IndexStyle istyle, StyleAttributes &style, const LuPixelPoint &parentOrigin)
Draws the whole element including its children.
virtual void moveHome(FormulaCursor *cursor)
Moves the cursor to the first position in this sequence.
The parser that gets the element list and returns a syntax tree.
ElementType * parse(TQPtrList< BasicElement > &elements)
A element that represents a space.
A symbol is simply a piece of art.
TQChar unicodeFromSymbolFont(TQChar pos) const
TQString greekLetters() const
TQChar unicode(TQString name) const
An element that represents one char.
virtual TQChar getCharacter() const
bool isSymbol() const
Moves the cursor away from the given child.
A line below the content.
const char * name(StdAction id)