lib
rootelement.h00001
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& cstyle,
00072 ContextStyle::TextStyle tstyle,
00073 ContextStyle::IndexStyle istyle,
00074 StyleAttributes& style );
00075
00081 virtual void draw( QPainter& painter, const LuPixelRect& r,
00082 const ContextStyle& cstyle,
00083 ContextStyle::TextStyle tstyle,
00084 ContextStyle::IndexStyle istyle,
00085 StyleAttributes& style,
00086 const LuPixelPoint& parentOrigin );
00087
00091 virtual void dispatchFontCommand( FontCommand* cmd );
00092
00098 virtual void moveLeft(FormulaCursor* cursor, BasicElement* from);
00099
00105 virtual void moveRight(FormulaCursor* cursor, BasicElement* from);
00106
00112 virtual void moveUp(FormulaCursor* cursor, BasicElement* from);
00113
00119 virtual void moveDown(FormulaCursor* cursor, BasicElement* from);
00120
00124 virtual void insert(FormulaCursor*, QPtrList<BasicElement>&, Direction);
00125
00132 virtual void remove(FormulaCursor*, QPtrList<BasicElement>&, Direction);
00133
00138 virtual void normalize(FormulaCursor*, Direction);
00139
00140
00141
00142
00143
00144 virtual SequenceElement* getMainChild();
00145 SequenceElement* getRadiant() { return index; }
00146
00147
00152 virtual void selectChild(FormulaCursor* cursor, BasicElement* child);
00153
00158
00159
00160
00161 void moveToIndex(FormulaCursor*, Direction);
00162
00163
00164
00165
00166 void setToIndex(FormulaCursor*);
00167
00168 bool hasIndex() const { return index != 0; }
00169
00170 ElementIndexPtr getIndex() { return ElementIndexPtr( new RootElementIndex( this ) ); }
00171
00172
00173
00174
00175
00180 virtual QString toLatex();
00181
00182 virtual QString formulaString();
00183
00184 protected:
00185
00186
00187
00191 virtual QString getTagName() const { return "ROOT"; }
00192
00196 virtual void writeDom(QDomElement element);
00197
00202 virtual bool readAttributesFromDom(QDomElement element);
00203
00209 virtual bool readContentFromDom(QDomNode& node);
00210
00216 virtual bool readAttributesFromMathMLDom(const QDomElement& element);
00217
00223 virtual int readContentFromMathMLDom(QDomNode& node);
00224
00225 private:
00226
00227 virtual QString getElementName() const { return hasIndex() ? "mroot" : "msqrt"; }
00228 virtual void writeMathMLContent( QDomDocument& doc,
00229 QDomElement& element,
00230 bool oasisFormat ) const ;
00231
00232 class RootElementIndex : public ElementIndex {
00233 public:
00234 RootElementIndex(RootElement* p) : parent(p) {}
00235 virtual void moveToIndex(FormulaCursor* cursor, Direction direction)
00236 { parent->moveToIndex(cursor, direction); }
00237 virtual void setToIndex(FormulaCursor* cursor)
00238 { parent->setToIndex(cursor); }
00239 virtual bool hasIndex() const
00240 { return parent->hasIndex(); }
00241 virtual RootElement* getElement() { return parent; }
00242 protected:
00243 RootElement* parent;
00244 };
00245
00246
00250 SequenceElement* content;
00251
00255 SequenceElement* index;
00256
00260 LuPixelPoint rootOffset;
00261
00267 bool square;
00268 };
00269
00270
00271 KFORMULA_NAMESPACE_END
00272
00273 #endif // ROOTELEMENT_H
|