00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
#ifndef ROOTELEMENT_H
00022
#define ROOTELEMENT_H
00023
00024
#include <qpoint.h>
00025
00026
#include "basicelement.h"
00027
00028 KFORMULA_NAMESPACE_BEGIN
00029
class SequenceElement;
00030
00031
00035 class RootElement :
public BasicElement {
00036
RootElement& operator=(
const RootElement& ) {
return *
this; }
00037
public:
00038
00039
00040
00041
RootElement(
BasicElement* parent = 0);
00042 ~
RootElement();
00043
00044
RootElement(
const RootElement& );
00045
00046
virtual RootElement* clone() {
00047
return new RootElement( *
this );
00048 }
00049
00050
virtual bool accept(
ElementVisitor* visitor );
00051
00056
virtual void entered(
SequenceElement* child );
00057
00064
virtual BasicElement*
goToPos(
FormulaCursor*,
bool& handled,
00065
const LuPixelPoint& point,
const LuPixelPoint& parentOrigin );
00066
00071
virtual void calcSizes(
const ContextStyle& style, ContextStyle::TextStyle tstyle, ContextStyle::IndexStyle istyle);
00072
00078
virtual void draw(
QPainter& painter,
const LuPixelRect& r,
00079
const ContextStyle& style,
00080 ContextStyle::TextStyle tstyle,
00081 ContextStyle::IndexStyle istyle,
00082
const LuPixelPoint& parentOrigin );
00083
00087
virtual void dispatchFontCommand(
FontCommand* cmd );
00088
00094
virtual void moveLeft(
FormulaCursor* cursor,
BasicElement* from);
00095
00101
virtual void moveRight(
FormulaCursor* cursor,
BasicElement* from);
00102
00108
virtual void moveUp(
FormulaCursor* cursor,
BasicElement* from);
00109
00115
virtual void moveDown(
FormulaCursor* cursor,
BasicElement* from);
00116
00120
virtual void insert(
FormulaCursor*,
QPtrList<BasicElement>&, Direction);
00121
00128
virtual void remove(
FormulaCursor*,
QPtrList<BasicElement>&, Direction);
00129
00134
virtual void normalize(
FormulaCursor*, Direction);
00135
00136
00137
00138
00139
00140
virtual SequenceElement*
getMainChild();
00141
SequenceElement* getRadiant() {
return index; }
00142
00143
00148
virtual void selectChild(
FormulaCursor* cursor,
BasicElement* child);
00149
00154
00155
00156
00157
void moveToIndex(
FormulaCursor*, Direction);
00158
00159
00160
00161
00162
void setToIndex(
FormulaCursor*);
00163
00164
bool hasIndex()
const {
return index != 0; }
00165
00166 ElementIndexPtr getIndex() {
return ElementIndexPtr(
new RootElementIndex(
this ) ); }
00167
00168
00169
00170
00171
00176
virtual QString toLatex();
00177
00178
virtual QString formulaString();
00179
00180
virtual void writeMathML(
QDomDocument doc,
QDomNode parent );
00181
00182
protected:
00183
00184
00185
00189 virtual QString getTagName()
const {
return "ROOT"; }
00190
00194
virtual void writeDom(
QDomElement element);
00195
00200
virtual bool readAttributesFromDom(
QDomElement element);
00201
00207
virtual bool readContentFromDom(
QDomNode& node);
00208
00209
private:
00210
00211
class RootElementIndex :
public ElementIndex {
00212
public:
00213 RootElementIndex(
RootElement* p) : parent(p) {}
00214
virtual void moveToIndex(
FormulaCursor* cursor, Direction direction)
00215 { parent->moveToIndex(cursor, direction); }
00216
virtual void setToIndex(
FormulaCursor* cursor)
00217 { parent->setToIndex(cursor); }
00218
virtual bool hasIndex()
const
00219
{
return parent->hasIndex(); }
00220
virtual RootElement* getElement() {
return parent; }
00221
protected:
00222
RootElement* parent;
00223 };
00224
00225
00229
SequenceElement* content;
00230
00234
SequenceElement* index;
00235
00239
LuPixelPoint rootOffset;
00240 };
00241
00242
00243 KFORMULA_NAMESPACE_END
00244
00245
#endif // ROOTELEMENT_H